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