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