1 /*
  2  * Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
  3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4  *
  5  * This code is free software; you can redistribute it and/or modify it
  6  * under the terms of the GNU General Public License version 2 only, as
  7  * published by the Free Software Foundation.
  8  *
  9  * This code is distributed in the hope that it will be useful, but WITHOUT
 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *
 23  */
 24 
 25 #include "precompiled.hpp"
 26 #include "classfile/vmClasses.hpp"
 27 #include "compiler/compilerDefinitions.inline.hpp"
 28 #include "runtime/handles.inline.hpp"
 29 #include "jfr/support/jfrIntrinsics.hpp"
 30 #include "opto/c2compiler.hpp"
 31 #include "opto/compile.hpp"
 32 #include "opto/optoreg.hpp"
 33 #include "opto/output.hpp"
 34 #include "opto/runtime.hpp"
 35 #include "runtime/stubRoutines.hpp"
 36 #include "utilities/macros.hpp"
 37 
 38 
 39 // register information defined by ADLC
 40 extern const char register_save_policy[];
 41 extern const int  register_save_type[];
 42 
 43 const char* C2Compiler::retry_no_subsuming_loads() {
 44   return "retry without subsuming loads";
 45 }
 46 const char* C2Compiler::retry_no_escape_analysis() {
 47   return "retry without escape analysis";
 48 }
 49 const char* C2Compiler::retry_no_locks_coarsening() {
 50   return "retry without locks coarsening";
 51 }
 52 const char* C2Compiler::retry_no_iterative_escape_analysis() {
 53   return "retry without iterative escape analysis";
 54 }
 55 const char* C2Compiler::retry_class_loading_during_parsing() {
 56   return "retry class loading during parsing";
 57 }
 58 bool C2Compiler::init_c2_runtime() {
 59 
 60   // Check assumptions used while running ADLC
 61   Compile::adlc_verification();
 62   assert(REG_COUNT <= ConcreteRegisterImpl::number_of_registers, "incompatible register counts");
 63 
 64   for (int i = 0; i < ConcreteRegisterImpl::number_of_registers ; i++ ) {
 65       OptoReg::vm2opto[i] = OptoReg::Bad;
 66   }
 67 
 68   for( OptoReg::Name i=OptoReg::Name(0); i<OptoReg::Name(REG_COUNT); i = OptoReg::add(i,1) ) {
 69     VMReg r = OptoReg::as_VMReg(i);
 70     if (r->is_valid()) {
 71       OptoReg::vm2opto[r->value()] = i;
 72     }
 73   }
 74 
 75   DEBUG_ONLY( Node::init_NodeProperty(); )
 76 
 77   Compile::pd_compiler2_init();
 78 
 79   CompilerThread* thread = CompilerThread::current();
 80 
 81   HandleMark handle_mark(thread);
 82   return OptoRuntime::generate(thread->env());
 83 }
 84 
 85 void C2Compiler::initialize() {
 86   assert(!CompilerConfig::is_c1_or_interpreter_only_no_jvmci(), "C2 compiler is launched, it's not c1/interpreter only mode");
 87   // The first compiler thread that gets here will initialize the
 88   // small amount of global state (and runtime stubs) that C2 needs.
 89 
 90   // There is a race possible once at startup and then we're fine
 91 
 92   // Note that this is being called from a compiler thread not the
 93   // main startup thread.
 94   if (should_perform_init()) {
 95     bool successful = C2Compiler::init_c2_runtime();
 96     int new_state = (successful) ? initialized : failed;
 97     set_state(new_state);
 98   }
 99 }
100 
101 void C2Compiler::compile_method(ciEnv* env, ciMethod* target, int entry_bci, bool install_code, DirectiveSet* directive) {
102   assert(is_initialized(), "Compiler thread must be initialized");
103 
104   bool subsume_loads = SubsumeLoads;
105   bool do_escape_analysis = DoEscapeAnalysis;
106   bool do_iterative_escape_analysis = DoEscapeAnalysis;
107   bool eliminate_boxing = EliminateAutoBox;
108   bool do_locks_coarsening = EliminateLocks;
109 
110   while (!env->failing()) {
111     // Attempt to compile while subsuming loads into machine instructions.
112     Options options(subsume_loads, do_escape_analysis, do_iterative_escape_analysis, eliminate_boxing, do_locks_coarsening, install_code);
113     Compile C(env, target, entry_bci, options, directive);
114 
115     // Check result and retry if appropriate.
116     if (C.failure_reason() != NULL) {
117       if (C.failure_reason_is(retry_class_loading_during_parsing())) {
118         env->report_failure(C.failure_reason());
119         continue;  // retry
120       }
121       if (C.failure_reason_is(retry_no_subsuming_loads())) {
122         assert(subsume_loads, "must make progress");
123         subsume_loads = false;
124         env->report_failure(C.failure_reason());
125         continue;  // retry
126       }
127       if (C.failure_reason_is(retry_no_escape_analysis())) {
128         assert(do_escape_analysis, "must make progress");
129         do_escape_analysis = false;
130         env->report_failure(C.failure_reason());
131         continue;  // retry
132       }
133       if (C.failure_reason_is(retry_no_iterative_escape_analysis())) {
134         assert(do_iterative_escape_analysis, "must make progress");
135         do_iterative_escape_analysis = false;
136         env->report_failure(C.failure_reason());
137         continue;  // retry
138       }
139       if (C.failure_reason_is(retry_no_locks_coarsening())) {
140         assert(do_locks_coarsening, "must make progress");
141         do_locks_coarsening = false;
142         env->report_failure(C.failure_reason());
143         continue;  // retry
144       }
145       if (C.has_boxed_value()) {
146         // Recompile without boxing elimination regardless failure reason.
147         assert(eliminate_boxing, "must make progress");
148         eliminate_boxing = false;
149         env->report_failure(C.failure_reason());
150         continue;  // retry
151       }
152       // Pass any other failure reason up to the ciEnv.
153       // Note that serious, irreversible failures are already logged
154       // on the ciEnv via env->record_method_not_compilable().
155       env->record_failure(C.failure_reason());
156     }
157     if (StressRecompilation) {
158       if (subsume_loads) {
159         subsume_loads = false;
160         continue;  // retry
161       }
162       if (do_escape_analysis) {
163         do_escape_analysis = false;
164         continue;  // retry
165       }
166       if (do_locks_coarsening) {
167         do_locks_coarsening = false;
168         continue;  // retry
169       }
170     }
171     // print inlining for last compilation only
172     C.dump_print_inlining();
173 
174     // No retry; just break the loop.
175     break;
176   }
177 }
178 
179 void C2Compiler::print_timers() {
180   Compile::print_timers();
181 }
182 
183 bool C2Compiler::is_intrinsic_supported(const methodHandle& method, bool is_virtual) {
184   vmIntrinsics::ID id = method->intrinsic_id();
185   assert(id != vmIntrinsics::_none, "must be a VM intrinsic");
186 
187   if (id < vmIntrinsics::FIRST_ID || id > vmIntrinsics::LAST_COMPILER_INLINE) {
188     return false;
189   }
190 
191   // Only Object.hashCode and Object.clone intrinsics implement also a virtual
192   // dispatch because calling both methods is expensive but both methods are
193   // frequently overridden. All other intrinsics implement only a non-virtual
194   // dispatch.
195   if (is_virtual) {
196     switch (id) {
197     case vmIntrinsics::_hashCode:
198     case vmIntrinsics::_clone:
199       break;
200     default:
201       return false;
202     }
203   }
204 
205   switch (id) {
206   case vmIntrinsics::_compressStringC:
207   case vmIntrinsics::_compressStringB:
208     if (!Matcher::match_rule_supported(Op_StrCompressedCopy)) return false;
209     break;
210   case vmIntrinsics::_inflateStringC:
211   case vmIntrinsics::_inflateStringB:
212     if (!Matcher::match_rule_supported(Op_StrInflatedCopy)) return false;
213     break;
214   case vmIntrinsics::_compareToL:
215   case vmIntrinsics::_compareToU:
216   case vmIntrinsics::_compareToLU:
217   case vmIntrinsics::_compareToUL:
218     if (!Matcher::match_rule_supported(Op_StrComp)) return false;
219     break;
220   case vmIntrinsics::_equalsL:
221   case vmIntrinsics::_equalsU:
222     if (!Matcher::match_rule_supported(Op_StrEquals)) return false;
223     break;
224   case vmIntrinsics::_equalsB:
225   case vmIntrinsics::_equalsC:
226     if (!Matcher::match_rule_supported(Op_AryEq)) return false;
227     break;
228   case vmIntrinsics::_copyMemory:
229     if (StubRoutines::unsafe_arraycopy() == NULL) return false;
230     break;
231   case vmIntrinsics::_encodeAsciiArray:
232     if (!Matcher::match_rule_supported(Op_EncodeISOArray) || !Matcher::supports_encode_ascii_array) return false;
233     break;
234   case vmIntrinsics::_encodeISOArray:
235   case vmIntrinsics::_encodeByteISOArray:
236     if (!Matcher::match_rule_supported(Op_EncodeISOArray)) return false;
237     break;
238   case vmIntrinsics::_countPositives:
239     if (!Matcher::match_rule_supported(Op_CountPositives))  return false;
240     break;
241   case vmIntrinsics::_bitCount_i:
242     if (!Matcher::match_rule_supported(Op_PopCountI)) return false;
243     break;
244   case vmIntrinsics::_bitCount_l:
245     if (!Matcher::match_rule_supported(Op_PopCountL)) return false;
246     break;
247   case vmIntrinsics::_compress_i:
248   case vmIntrinsics::_compress_l:
249     if (!Matcher::match_rule_supported(Op_CompressBits)) return false;
250     break;
251   case vmIntrinsics::_expand_i:
252   case vmIntrinsics::_expand_l:
253     if (!Matcher::match_rule_supported(Op_ExpandBits)) return false;
254     break;
255   case vmIntrinsics::_numberOfLeadingZeros_i:
256     if (!Matcher::match_rule_supported(Op_CountLeadingZerosI)) return false;
257     break;
258   case vmIntrinsics::_numberOfLeadingZeros_l:
259     if (!Matcher::match_rule_supported(Op_CountLeadingZerosL)) return false;
260     break;
261   case vmIntrinsics::_numberOfTrailingZeros_i:
262     if (!Matcher::match_rule_supported(Op_CountTrailingZerosI)) return false;
263     break;
264   case vmIntrinsics::_numberOfTrailingZeros_l:
265     if (!Matcher::match_rule_supported(Op_CountTrailingZerosL)) return false;
266     break;
267   case vmIntrinsics::_reverse_i:
268     if (!Matcher::match_rule_supported(Op_ReverseI)) return false;
269     break;
270   case vmIntrinsics::_reverse_l:
271     if (!Matcher::match_rule_supported(Op_ReverseL)) return false;
272     break;
273   case vmIntrinsics::_reverseBytes_c:
274     if (!Matcher::match_rule_supported(Op_ReverseBytesUS)) return false;
275     break;
276   case vmIntrinsics::_reverseBytes_s:
277     if (!Matcher::match_rule_supported(Op_ReverseBytesS)) return false;
278     break;
279   case vmIntrinsics::_reverseBytes_i:
280     if (!Matcher::match_rule_supported(Op_ReverseBytesI)) return false;
281     break;
282   case vmIntrinsics::_reverseBytes_l:
283     if (!Matcher::match_rule_supported(Op_ReverseBytesL)) return false;
284     break;
285   case vmIntrinsics::_compareUnsigned_i:
286     if (!Matcher::match_rule_supported(Op_CmpU3)) return false;
287     break;
288   case vmIntrinsics::_compareUnsigned_l:
289     if (!Matcher::match_rule_supported(Op_CmpUL3)) return false;
290     break;
291   case vmIntrinsics::_divideUnsigned_i:
292     if (!Matcher::match_rule_supported(Op_UDivI)) return false;
293     break;
294   case vmIntrinsics::_remainderUnsigned_i:
295     if (!Matcher::match_rule_supported(Op_UModI)) return false;
296     break;
297   case vmIntrinsics::_divideUnsigned_l:
298     if (!Matcher::match_rule_supported(Op_UDivL)) return false;
299     break;
300   case vmIntrinsics::_remainderUnsigned_l:
301     if (!Matcher::match_rule_supported(Op_UModL)) return false;
302     break;
303 
304   /* CompareAndSet, Object: */
305   case vmIntrinsics::_compareAndSetReference:
306 #ifdef _LP64
307     if ( UseCompressedOops && !Matcher::match_rule_supported(Op_CompareAndSwapN)) return false;
308     if (!UseCompressedOops && !Matcher::match_rule_supported(Op_CompareAndSwapP)) return false;
309 #else
310     if (!Matcher::match_rule_supported(Op_CompareAndSwapP)) return false;
311 #endif
312     break;
313   case vmIntrinsics::_weakCompareAndSetReferencePlain:
314   case vmIntrinsics::_weakCompareAndSetReferenceAcquire:
315   case vmIntrinsics::_weakCompareAndSetReferenceRelease:
316   case vmIntrinsics::_weakCompareAndSetReference:
317 #ifdef _LP64
318     if ( UseCompressedOops && !Matcher::match_rule_supported(Op_WeakCompareAndSwapN)) return false;
319     if (!UseCompressedOops && !Matcher::match_rule_supported(Op_WeakCompareAndSwapP)) return false;
320 #else
321     if (!Matcher::match_rule_supported(Op_WeakCompareAndSwapP)) return false;
322 #endif
323     break;
324   /* CompareAndSet, Long: */
325   case vmIntrinsics::_compareAndSetLong:
326     if (!Matcher::match_rule_supported(Op_CompareAndSwapL)) return false;
327     break;
328   case vmIntrinsics::_weakCompareAndSetLongPlain:
329   case vmIntrinsics::_weakCompareAndSetLongAcquire:
330   case vmIntrinsics::_weakCompareAndSetLongRelease:
331   case vmIntrinsics::_weakCompareAndSetLong:
332     if (!Matcher::match_rule_supported(Op_WeakCompareAndSwapL)) return false;
333     break;
334 
335   /* CompareAndSet, Int: */
336   case vmIntrinsics::_compareAndSetInt:
337     if (!Matcher::match_rule_supported(Op_CompareAndSwapI)) return false;
338     break;
339   case vmIntrinsics::_weakCompareAndSetIntPlain:
340   case vmIntrinsics::_weakCompareAndSetIntAcquire:
341   case vmIntrinsics::_weakCompareAndSetIntRelease:
342   case vmIntrinsics::_weakCompareAndSetInt:
343     if (!Matcher::match_rule_supported(Op_WeakCompareAndSwapI)) return false;
344     break;
345 
346   /* CompareAndSet, Byte: */
347   case vmIntrinsics::_compareAndSetByte:
348     if (!Matcher::match_rule_supported(Op_CompareAndSwapB)) return false;
349     break;
350   case vmIntrinsics::_weakCompareAndSetBytePlain:
351   case vmIntrinsics::_weakCompareAndSetByteAcquire:
352   case vmIntrinsics::_weakCompareAndSetByteRelease:
353   case vmIntrinsics::_weakCompareAndSetByte:
354     if (!Matcher::match_rule_supported(Op_WeakCompareAndSwapB)) return false;
355     break;
356 
357   /* CompareAndSet, Short: */
358   case vmIntrinsics::_compareAndSetShort:
359     if (!Matcher::match_rule_supported(Op_CompareAndSwapS)) return false;
360     break;
361   case vmIntrinsics::_weakCompareAndSetShortPlain:
362   case vmIntrinsics::_weakCompareAndSetShortAcquire:
363   case vmIntrinsics::_weakCompareAndSetShortRelease:
364   case vmIntrinsics::_weakCompareAndSetShort:
365     if (!Matcher::match_rule_supported(Op_WeakCompareAndSwapS)) return false;
366     break;
367 
368   /* CompareAndExchange, Object: */
369   case vmIntrinsics::_compareAndExchangeReference:
370   case vmIntrinsics::_compareAndExchangeReferenceAcquire:
371   case vmIntrinsics::_compareAndExchangeReferenceRelease:
372 #ifdef _LP64
373     if ( UseCompressedOops && !Matcher::match_rule_supported(Op_CompareAndExchangeN)) return false;
374     if (!UseCompressedOops && !Matcher::match_rule_supported(Op_CompareAndExchangeP)) return false;
375 #else
376     if (!Matcher::match_rule_supported(Op_CompareAndExchangeP)) return false;
377 #endif
378     break;
379 
380   /* CompareAndExchange, Long: */
381   case vmIntrinsics::_compareAndExchangeLong:
382   case vmIntrinsics::_compareAndExchangeLongAcquire:
383   case vmIntrinsics::_compareAndExchangeLongRelease:
384     if (!Matcher::match_rule_supported(Op_CompareAndExchangeL)) return false;
385     break;
386 
387   /* CompareAndExchange, Int: */
388   case vmIntrinsics::_compareAndExchangeInt:
389   case vmIntrinsics::_compareAndExchangeIntAcquire:
390   case vmIntrinsics::_compareAndExchangeIntRelease:
391     if (!Matcher::match_rule_supported(Op_CompareAndExchangeI)) return false;
392     break;
393 
394   /* CompareAndExchange, Byte: */
395   case vmIntrinsics::_compareAndExchangeByte:
396   case vmIntrinsics::_compareAndExchangeByteAcquire:
397   case vmIntrinsics::_compareAndExchangeByteRelease:
398     if (!Matcher::match_rule_supported(Op_CompareAndExchangeB)) return false;
399     break;
400 
401   /* CompareAndExchange, Short: */
402   case vmIntrinsics::_compareAndExchangeShort:
403   case vmIntrinsics::_compareAndExchangeShortAcquire:
404   case vmIntrinsics::_compareAndExchangeShortRelease:
405     if (!Matcher::match_rule_supported(Op_CompareAndExchangeS)) return false;
406     break;
407 
408   case vmIntrinsics::_getAndAddByte:
409     if (!Matcher::match_rule_supported(Op_GetAndAddB)) return false;
410     break;
411   case vmIntrinsics::_getAndAddShort:
412     if (!Matcher::match_rule_supported(Op_GetAndAddS)) return false;
413     break;
414   case vmIntrinsics::_getAndAddInt:
415     if (!Matcher::match_rule_supported(Op_GetAndAddI)) return false;
416     break;
417   case vmIntrinsics::_getAndAddLong:
418     if (!Matcher::match_rule_supported(Op_GetAndAddL)) return false;
419     break;
420 
421   case vmIntrinsics::_getAndSetByte:
422     if (!Matcher::match_rule_supported(Op_GetAndSetB)) return false;
423     break;
424   case vmIntrinsics::_getAndSetShort:
425     if (!Matcher::match_rule_supported(Op_GetAndSetS)) return false;
426     break;
427   case vmIntrinsics::_getAndSetInt:
428     if (!Matcher::match_rule_supported(Op_GetAndSetI)) return false;
429     break;
430   case vmIntrinsics::_getAndSetLong:
431     if (!Matcher::match_rule_supported(Op_GetAndSetL)) return false;
432     break;
433   case vmIntrinsics::_getAndSetReference:
434 #ifdef _LP64
435     if (!UseCompressedOops && !Matcher::match_rule_supported(Op_GetAndSetP)) return false;
436     if (UseCompressedOops && !Matcher::match_rule_supported(Op_GetAndSetN)) return false;
437     break;
438 #else
439     if (!Matcher::match_rule_supported(Op_GetAndSetP)) return false;
440     break;
441 #endif
442   case vmIntrinsics::_incrementExactI:
443   case vmIntrinsics::_addExactI:
444     if (!Matcher::match_rule_supported(Op_OverflowAddI)) return false;
445     break;
446   case vmIntrinsics::_incrementExactL:
447   case vmIntrinsics::_addExactL:
448     if (!Matcher::match_rule_supported(Op_OverflowAddL)) return false;
449     break;
450   case vmIntrinsics::_decrementExactI:
451   case vmIntrinsics::_subtractExactI:
452     if (!Matcher::match_rule_supported(Op_OverflowSubI)) return false;
453     break;
454   case vmIntrinsics::_decrementExactL:
455   case vmIntrinsics::_subtractExactL:
456     if (!Matcher::match_rule_supported(Op_OverflowSubL)) return false;
457     break;
458   case vmIntrinsics::_negateExactI:
459     if (!Matcher::match_rule_supported(Op_OverflowSubI)) return false;
460     break;
461   case vmIntrinsics::_negateExactL:
462     if (!Matcher::match_rule_supported(Op_OverflowSubL)) return false;
463     break;
464   case vmIntrinsics::_multiplyExactI:
465     if (!Matcher::match_rule_supported(Op_OverflowMulI)) return false;
466     break;
467   case vmIntrinsics::_multiplyExactL:
468     if (!Matcher::match_rule_supported(Op_OverflowMulL)) return false;
469     break;
470   case vmIntrinsics::_multiplyHigh:
471     if (!Matcher::match_rule_supported(Op_MulHiL)) return false;
472     break;
473   case vmIntrinsics::_unsignedMultiplyHigh:
474     if (!Matcher::match_rule_supported(Op_UMulHiL)) return false;
475     break;
476   case vmIntrinsics::_getCallerClass:
477     if (vmClasses::reflect_CallerSensitive_klass() == NULL) return false;
478     break;
479   case vmIntrinsics::_onSpinWait:
480     if (!Matcher::match_rule_supported(Op_OnSpinWait)) return false;
481     break;
482   case vmIntrinsics::_fmaD:
483     if (!UseFMA || !Matcher::match_rule_supported(Op_FmaD)) return false;
484     break;
485   case vmIntrinsics::_fmaF:
486     if (!UseFMA || !Matcher::match_rule_supported(Op_FmaF)) return false;
487     break;
488   case vmIntrinsics::_isDigit:
489     if (!Matcher::match_rule_supported(Op_Digit)) return false;
490     break;
491   case vmIntrinsics::_isLowerCase:
492     if (!Matcher::match_rule_supported(Op_LowerCase)) return false;
493     break;
494   case vmIntrinsics::_isUpperCase:
495     if (!Matcher::match_rule_supported(Op_UpperCase)) return false;
496     break;
497   case vmIntrinsics::_isWhitespace:
498     if (!Matcher::match_rule_supported(Op_Whitespace)) return false;
499     break;
500   case vmIntrinsics::_maxF:
501   case vmIntrinsics::_maxF_strict:
502     if (!Matcher::match_rule_supported(Op_MaxF)) return false;
503     break;
504   case vmIntrinsics::_minF:
505   case vmIntrinsics::_minF_strict:
506     if (!Matcher::match_rule_supported(Op_MinF)) return false;
507     break;
508   case vmIntrinsics::_maxD:
509   case vmIntrinsics::_maxD_strict:
510     if (!Matcher::match_rule_supported(Op_MaxD)) return false;
511     break;
512   case vmIntrinsics::_minD:
513   case vmIntrinsics::_minD_strict:
514     if (!Matcher::match_rule_supported(Op_MinD)) return false;
515     break;
516   case vmIntrinsics::_writeback0:
517     if (!Matcher::match_rule_supported(Op_CacheWB)) return false;
518     break;
519   case vmIntrinsics::_writebackPreSync0:
520     if (!Matcher::match_rule_supported(Op_CacheWBPreSync)) return false;
521     break;
522   case vmIntrinsics::_writebackPostSync0:
523     if (!Matcher::match_rule_supported(Op_CacheWBPostSync)) return false;
524     break;
525   case vmIntrinsics::_rint:
526   case vmIntrinsics::_ceil:
527   case vmIntrinsics::_floor:
528     if (!Matcher::match_rule_supported(Op_RoundDoubleMode)) return false;
529     break;
530   case vmIntrinsics::_dcopySign:
531     if (!Matcher::match_rule_supported(Op_CopySignD)) return false;
532     break;
533   case vmIntrinsics::_fcopySign:
534     if (!Matcher::match_rule_supported(Op_CopySignF)) return false;
535     break;
536   case vmIntrinsics::_dsignum:
537     if (!Matcher::match_rule_supported(Op_SignumD)) return false;
538     break;
539   case vmIntrinsics::_fsignum:
540     if (!Matcher::match_rule_supported(Op_SignumF)) return false;
541     break;
542   case vmIntrinsics::_floatIsInfinite:
543     if (!Matcher::match_rule_supported(Op_IsInfiniteF)) return false;
544     break;
545   case vmIntrinsics::_doubleIsInfinite:
546     if (!Matcher::match_rule_supported(Op_IsInfiniteD)) return false;
547     break;
548   case vmIntrinsics::_hashCode:
549   case vmIntrinsics::_identityHashCode:
550   case vmIntrinsics::_getClass:
551   case vmIntrinsics::_dsin:
552   case vmIntrinsics::_dcos:
553   case vmIntrinsics::_dtan:
554   case vmIntrinsics::_dabs:
555   case vmIntrinsics::_fabs:
556   case vmIntrinsics::_iabs:
557   case vmIntrinsics::_labs:
558   case vmIntrinsics::_datan2:
559   case vmIntrinsics::_dsqrt:
560   case vmIntrinsics::_dsqrt_strict:
561   case vmIntrinsics::_dexp:
562   case vmIntrinsics::_dlog:
563   case vmIntrinsics::_dlog10:
564   case vmIntrinsics::_dpow:
565   case vmIntrinsics::_roundD:
566   case vmIntrinsics::_roundF:
567   case vmIntrinsics::_min:
568   case vmIntrinsics::_max:
569   case vmIntrinsics::_min_strict:
570   case vmIntrinsics::_max_strict:
571   case vmIntrinsics::_arraycopy:
572   case vmIntrinsics::_indexOfL:
573   case vmIntrinsics::_indexOfU:
574   case vmIntrinsics::_indexOfUL:
575   case vmIntrinsics::_indexOfIL:
576   case vmIntrinsics::_indexOfIU:
577   case vmIntrinsics::_indexOfIUL:
578   case vmIntrinsics::_indexOfU_char:
579   case vmIntrinsics::_indexOfL_char:
580   case vmIntrinsics::_toBytesStringU:
581   case vmIntrinsics::_getCharsStringU:
582   case vmIntrinsics::_getCharStringU:
583   case vmIntrinsics::_putCharStringU:
584   case vmIntrinsics::_makePrivateBuffer:
585   case vmIntrinsics::_finishPrivateBuffer:
586   case vmIntrinsics::_getReference:
587   case vmIntrinsics::_getBoolean:
588   case vmIntrinsics::_getByte:
589   case vmIntrinsics::_getShort:
590   case vmIntrinsics::_getChar:
591   case vmIntrinsics::_getInt:
592   case vmIntrinsics::_getLong:
593   case vmIntrinsics::_getFloat:
594   case vmIntrinsics::_getDouble:
595   case vmIntrinsics::_getValue:
596   case vmIntrinsics::_putReference:
597   case vmIntrinsics::_putBoolean:
598   case vmIntrinsics::_putByte:
599   case vmIntrinsics::_putShort:
600   case vmIntrinsics::_putChar:
601   case vmIntrinsics::_putInt:
602   case vmIntrinsics::_putLong:
603   case vmIntrinsics::_putFloat:
604   case vmIntrinsics::_putDouble:
605   case vmIntrinsics::_putValue:
606   case vmIntrinsics::_getReferenceVolatile:
607   case vmIntrinsics::_getBooleanVolatile:
608   case vmIntrinsics::_getByteVolatile:
609   case vmIntrinsics::_getShortVolatile:
610   case vmIntrinsics::_getCharVolatile:
611   case vmIntrinsics::_getIntVolatile:
612   case vmIntrinsics::_getLongVolatile:
613   case vmIntrinsics::_getFloatVolatile:
614   case vmIntrinsics::_getDoubleVolatile:
615   case vmIntrinsics::_putReferenceVolatile:
616   case vmIntrinsics::_putBooleanVolatile:
617   case vmIntrinsics::_putByteVolatile:
618   case vmIntrinsics::_putShortVolatile:
619   case vmIntrinsics::_putCharVolatile:
620   case vmIntrinsics::_putIntVolatile:
621   case vmIntrinsics::_putLongVolatile:
622   case vmIntrinsics::_putFloatVolatile:
623   case vmIntrinsics::_putDoubleVolatile:
624   case vmIntrinsics::_getReferenceAcquire:
625   case vmIntrinsics::_getBooleanAcquire:
626   case vmIntrinsics::_getByteAcquire:
627   case vmIntrinsics::_getShortAcquire:
628   case vmIntrinsics::_getCharAcquire:
629   case vmIntrinsics::_getIntAcquire:
630   case vmIntrinsics::_getLongAcquire:
631   case vmIntrinsics::_getFloatAcquire:
632   case vmIntrinsics::_getDoubleAcquire:
633   case vmIntrinsics::_putReferenceRelease:
634   case vmIntrinsics::_putBooleanRelease:
635   case vmIntrinsics::_putByteRelease:
636   case vmIntrinsics::_putShortRelease:
637   case vmIntrinsics::_putCharRelease:
638   case vmIntrinsics::_putIntRelease:
639   case vmIntrinsics::_putLongRelease:
640   case vmIntrinsics::_putFloatRelease:
641   case vmIntrinsics::_putDoubleRelease:
642   case vmIntrinsics::_getReferenceOpaque:
643   case vmIntrinsics::_getBooleanOpaque:
644   case vmIntrinsics::_getByteOpaque:
645   case vmIntrinsics::_getShortOpaque:
646   case vmIntrinsics::_getCharOpaque:
647   case vmIntrinsics::_getIntOpaque:
648   case vmIntrinsics::_getLongOpaque:
649   case vmIntrinsics::_getFloatOpaque:
650   case vmIntrinsics::_getDoubleOpaque:
651   case vmIntrinsics::_putReferenceOpaque:
652   case vmIntrinsics::_putBooleanOpaque:
653   case vmIntrinsics::_putByteOpaque:
654   case vmIntrinsics::_putShortOpaque:
655   case vmIntrinsics::_putCharOpaque:
656   case vmIntrinsics::_putIntOpaque:
657   case vmIntrinsics::_putLongOpaque:
658   case vmIntrinsics::_putFloatOpaque:
659   case vmIntrinsics::_putDoubleOpaque:
660   case vmIntrinsics::_getShortUnaligned:
661   case vmIntrinsics::_getCharUnaligned:
662   case vmIntrinsics::_getIntUnaligned:
663   case vmIntrinsics::_getLongUnaligned:
664   case vmIntrinsics::_putShortUnaligned:
665   case vmIntrinsics::_putCharUnaligned:
666   case vmIntrinsics::_putIntUnaligned:
667   case vmIntrinsics::_putLongUnaligned:
668   case vmIntrinsics::_loadFence:
669   case vmIntrinsics::_storeFence:
670   case vmIntrinsics::_storeStoreFence:
671   case vmIntrinsics::_fullFence:
672   case vmIntrinsics::_currentCarrierThread:
673   case vmIntrinsics::_currentThread:
674   case vmIntrinsics::_setCurrentThread:
675   case vmIntrinsics::_extentLocalCache:
676   case vmIntrinsics::_setExtentLocalCache:
677 #ifdef JFR_HAVE_INTRINSICS
678   case vmIntrinsics::_counterTime:
679   case vmIntrinsics::_getEventWriter:
680 #endif
681   case vmIntrinsics::_currentTimeMillis:
682   case vmIntrinsics::_nanoTime:
683   case vmIntrinsics::_allocateInstance:
684   case vmIntrinsics::_allocateUninitializedArray:
685   case vmIntrinsics::_newArray:
686   case vmIntrinsics::_getLength:
687   case vmIntrinsics::_copyOf:
688   case vmIntrinsics::_copyOfRange:
689   case vmIntrinsics::_clone:
690   case vmIntrinsics::_asPrimaryType:
691   case vmIntrinsics::_asPrimaryTypeArg:
692   case vmIntrinsics::_asValueType:
693   case vmIntrinsics::_asValueTypeArg:
694   case vmIntrinsics::_isAssignableFrom:
695   case vmIntrinsics::_isInstance:
696   case vmIntrinsics::_getModifiers:
697   case vmIntrinsics::_isInterface:
698   case vmIntrinsics::_isArray:
699   case vmIntrinsics::_isPrimitive:
700   case vmIntrinsics::_isHidden:
701   case vmIntrinsics::_getSuperclass:
702   case vmIntrinsics::_getClassAccessFlags:
703   case vmIntrinsics::_floatToRawIntBits:
704   case vmIntrinsics::_floatToIntBits:
705   case vmIntrinsics::_intBitsToFloat:
706   case vmIntrinsics::_doubleToRawLongBits:
707   case vmIntrinsics::_doubleToLongBits:
708   case vmIntrinsics::_longBitsToDouble:
709   case vmIntrinsics::_Reference_get:
710   case vmIntrinsics::_Reference_refersTo0:
711   case vmIntrinsics::_PhantomReference_refersTo0:
712   case vmIntrinsics::_Class_cast:
713   case vmIntrinsics::_aescrypt_encryptBlock:
714   case vmIntrinsics::_aescrypt_decryptBlock:
715   case vmIntrinsics::_cipherBlockChaining_encryptAESCrypt:
716   case vmIntrinsics::_cipherBlockChaining_decryptAESCrypt:
717   case vmIntrinsics::_electronicCodeBook_encryptAESCrypt:
718   case vmIntrinsics::_electronicCodeBook_decryptAESCrypt:
719   case vmIntrinsics::_counterMode_AESCrypt:
720   case vmIntrinsics::_galoisCounterMode_AESCrypt:
721   case vmIntrinsics::_md5_implCompress:
722   case vmIntrinsics::_sha_implCompress:
723   case vmIntrinsics::_sha2_implCompress:
724   case vmIntrinsics::_sha5_implCompress:
725   case vmIntrinsics::_sha3_implCompress:
726   case vmIntrinsics::_digestBase_implCompressMB:
727   case vmIntrinsics::_multiplyToLen:
728   case vmIntrinsics::_squareToLen:
729   case vmIntrinsics::_mulAdd:
730   case vmIntrinsics::_montgomeryMultiply:
731   case vmIntrinsics::_montgomerySquare:
732   case vmIntrinsics::_bigIntegerRightShiftWorker:
733   case vmIntrinsics::_bigIntegerLeftShiftWorker:
734   case vmIntrinsics::_vectorizedMismatch:
735   case vmIntrinsics::_ghash_processBlocks:
736   case vmIntrinsics::_base64_encodeBlock:
737   case vmIntrinsics::_base64_decodeBlock:
738   case vmIntrinsics::_updateCRC32:
739   case vmIntrinsics::_updateBytesCRC32:
740   case vmIntrinsics::_updateByteBufferCRC32:
741   case vmIntrinsics::_updateBytesCRC32C:
742   case vmIntrinsics::_updateDirectByteBufferCRC32C:
743   case vmIntrinsics::_updateBytesAdler32:
744   case vmIntrinsics::_updateByteBufferAdler32:
745   case vmIntrinsics::_profileBoolean:
746   case vmIntrinsics::_isCompileConstant:
747   case vmIntrinsics::_Preconditions_checkIndex:
748   case vmIntrinsics::_Preconditions_checkLongIndex:
749   case vmIntrinsics::_getObjectSize:
750     break;
751 
752   case vmIntrinsics::_VectorCompressExpand:
753   case vmIntrinsics::_VectorUnaryOp:
754   case vmIntrinsics::_VectorBinaryOp:
755   case vmIntrinsics::_VectorTernaryOp:
756   case vmIntrinsics::_VectorFromBitsCoerced:
757   case vmIntrinsics::_VectorShuffleIota:
758   case vmIntrinsics::_VectorShuffleToVector:
759   case vmIntrinsics::_VectorLoadOp:
760   case vmIntrinsics::_VectorLoadMaskedOp:
761   case vmIntrinsics::_VectorStoreOp:
762   case vmIntrinsics::_VectorStoreMaskedOp:
763   case vmIntrinsics::_VectorGatherOp:
764   case vmIntrinsics::_VectorScatterOp:
765   case vmIntrinsics::_VectorReductionCoerced:
766   case vmIntrinsics::_VectorTest:
767   case vmIntrinsics::_VectorBlend:
768   case vmIntrinsics::_VectorRearrange:
769   case vmIntrinsics::_VectorCompare:
770   case vmIntrinsics::_VectorBroadcastInt:
771   case vmIntrinsics::_VectorConvert:
772   case vmIntrinsics::_VectorInsert:
773   case vmIntrinsics::_VectorExtract:
774   case vmIntrinsics::_VectorMaskOp:
775     return EnableVectorSupport;
776   case vmIntrinsics::_blackhole:
777     break;
778 
779   default:
780     return false;
781   }
782   return true;
783 }
784 
785 int C2Compiler::initial_code_buffer_size(int const_size) {
786   // See Compile::init_scratch_buffer_blob
787   int locs_size = sizeof(relocInfo) * PhaseOutput::MAX_locs_size;
788   int slop = 2 * CodeSection::end_slop(); // space between sections
789   return PhaseOutput::MAX_inst_size + PhaseOutput::MAX_stubs_size + const_size + slop + locs_size;
790 }