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