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