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