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