< prev index next >

src/hotspot/share/c1/c1_Runtime1.cpp

Print this page

  36 #include "code/codeBlob.hpp"
  37 #include "code/compiledIC.hpp"
  38 #include "code/pcDesc.hpp"
  39 #include "code/scopeDesc.hpp"
  40 #include "code/vtableStubs.hpp"
  41 #include "compiler/compilationPolicy.hpp"
  42 #include "compiler/disassembler.hpp"
  43 #include "compiler/oopMap.hpp"
  44 #include "gc/shared/barrierSet.hpp"
  45 #include "gc/shared/c1/barrierSetC1.hpp"
  46 #include "gc/shared/collectedHeap.hpp"
  47 #include "interpreter/bytecode.hpp"
  48 #include "interpreter/interpreter.hpp"
  49 #include "jfr/support/jfrIntrinsics.hpp"
  50 #include "logging/log.hpp"
  51 #include "memory/allocation.inline.hpp"
  52 #include "memory/oopFactory.hpp"
  53 #include "memory/resourceArea.hpp"
  54 #include "memory/universe.hpp"
  55 #include "oops/access.inline.hpp"


  56 #include "oops/klass.inline.hpp"
  57 #include "oops/objArrayOop.inline.hpp"
  58 #include "oops/objArrayKlass.hpp"
  59 #include "oops/oop.inline.hpp"
  60 #include "prims/jvmtiExport.hpp"
  61 #include "runtime/atomic.hpp"
  62 #include "runtime/fieldDescriptor.inline.hpp"
  63 #include "runtime/frame.inline.hpp"
  64 #include "runtime/handles.inline.hpp"
  65 #include "runtime/interfaceSupport.inline.hpp"
  66 #include "runtime/javaCalls.hpp"
  67 #include "runtime/sharedRuntime.hpp"
  68 #include "runtime/stackWatermarkSet.hpp"
  69 #include "runtime/stubRoutines.hpp"
  70 #include "runtime/threadCritical.hpp"
  71 #include "runtime/vframe.inline.hpp"
  72 #include "runtime/vframeArray.hpp"
  73 #include "runtime/vm_version.hpp"
  74 #include "utilities/copy.hpp"
  75 #include "utilities/events.hpp"

 105     _num_rt_args = args;
 106   }
 107   assert(_num_rt_args == args, "can't change the number of args");
 108 }
 109 
 110 // Implementation of Runtime1
 111 
 112 CodeBlob* Runtime1::_blobs[Runtime1::number_of_ids];
 113 const char *Runtime1::_blob_names[] = {
 114   RUNTIME1_STUBS(STUB_NAME, LAST_STUB_NAME)
 115 };
 116 
 117 #ifndef PRODUCT
 118 // statistics
 119 uint Runtime1::_generic_arraycopystub_cnt = 0;
 120 uint Runtime1::_arraycopy_slowcase_cnt = 0;
 121 uint Runtime1::_arraycopy_checkcast_cnt = 0;
 122 uint Runtime1::_arraycopy_checkcast_attempt_cnt = 0;
 123 uint Runtime1::_new_type_array_slowcase_cnt = 0;
 124 uint Runtime1::_new_object_array_slowcase_cnt = 0;

 125 uint Runtime1::_new_instance_slowcase_cnt = 0;
 126 uint Runtime1::_new_multi_array_slowcase_cnt = 0;





 127 uint Runtime1::_monitorenter_slowcase_cnt = 0;
 128 uint Runtime1::_monitorexit_slowcase_cnt = 0;
 129 uint Runtime1::_patch_code_slowcase_cnt = 0;
 130 uint Runtime1::_throw_range_check_exception_count = 0;
 131 uint Runtime1::_throw_index_exception_count = 0;
 132 uint Runtime1::_throw_div0_exception_count = 0;
 133 uint Runtime1::_throw_null_pointer_exception_count = 0;
 134 uint Runtime1::_throw_class_cast_exception_count = 0;
 135 uint Runtime1::_throw_incompatible_class_change_error_count = 0;

 136 uint Runtime1::_throw_count = 0;
 137 
 138 static uint _byte_arraycopy_stub_cnt = 0;
 139 static uint _short_arraycopy_stub_cnt = 0;
 140 static uint _int_arraycopy_stub_cnt = 0;
 141 static uint _long_arraycopy_stub_cnt = 0;
 142 static uint _oop_arraycopy_stub_cnt = 0;
 143 
 144 address Runtime1::arraycopy_count_address(BasicType type) {
 145   switch (type) {
 146   case T_BOOLEAN:
 147   case T_BYTE:   return (address)&_byte_arraycopy_stub_cnt;
 148   case T_CHAR:
 149   case T_SHORT:  return (address)&_short_arraycopy_stub_cnt;
 150   case T_FLOAT:
 151   case T_INT:    return (address)&_int_arraycopy_stub_cnt;
 152   case T_DOUBLE:
 153   case T_LONG:   return (address)&_long_arraycopy_stub_cnt;
 154   case T_ARRAY:
 155   case T_OBJECT: return (address)&_oop_arraycopy_stub_cnt;

 331 #ifdef JFR_HAVE_INTRINSICS
 332   FUNCTION_CASE(entry, JfrTime::time_function());
 333 #endif
 334   FUNCTION_CASE(entry, StubRoutines::updateBytesCRC32());
 335   FUNCTION_CASE(entry, StubRoutines::updateBytesCRC32C());
 336   FUNCTION_CASE(entry, StubRoutines::vectorizedMismatch());
 337   FUNCTION_CASE(entry, StubRoutines::dexp());
 338   FUNCTION_CASE(entry, StubRoutines::dlog());
 339   FUNCTION_CASE(entry, StubRoutines::dlog10());
 340   FUNCTION_CASE(entry, StubRoutines::dpow());
 341   FUNCTION_CASE(entry, StubRoutines::dsin());
 342   FUNCTION_CASE(entry, StubRoutines::dcos());
 343   FUNCTION_CASE(entry, StubRoutines::dtan());
 344 
 345 #undef FUNCTION_CASE
 346 
 347   // Soft float adds more runtime names.
 348   return pd_name_for_address(entry);
 349 }
 350 
 351 
 352 JRT_ENTRY(void, Runtime1::new_instance(JavaThread* current, Klass* klass))
 353 #ifndef PRODUCT
 354   if (PrintC1Statistics) {
 355     _new_instance_slowcase_cnt++;
 356   }
 357 #endif
 358   assert(klass->is_klass(), "not a class");
 359   Handle holder(current, klass->klass_holder()); // keep the klass alive
 360   InstanceKlass* h = InstanceKlass::cast(klass);
 361   h->check_valid_for_instantiation(true, CHECK);
 362   // make sure klass is initialized
 363   h->initialize(CHECK);
 364   // allocate instance and return via TLS
 365   oop obj = h->allocate_instance(CHECK);
 366   current->set_vm_result(obj);
 367 JRT_END
 368 












 369 
 370 JRT_ENTRY(void, Runtime1::new_type_array(JavaThread* current, Klass* klass, jint length))
 371 #ifndef PRODUCT
 372   if (PrintC1Statistics) {
 373     _new_type_array_slowcase_cnt++;
 374   }
 375 #endif
 376   // Note: no handle for klass needed since they are not used
 377   //       anymore after new_typeArray() and no GC can happen before.
 378   //       (This may have to change if this code changes!)
 379   assert(klass->is_klass(), "not a class");
 380   BasicType elt_type = TypeArrayKlass::cast(klass)->element_type();
 381   oop obj = oopFactory::new_typeArray(elt_type, length, CHECK);
 382   current->set_vm_result(obj);
 383   // This is pretty rare but this runtime patch is stressful to deoptimization
 384   // if we deoptimize here so force a deopt to stress the path.
 385   if (DeoptimizeALot) {
 386     deopt_caller(current);
 387   }
 388 
 389 JRT_END
 390 
 391 
 392 JRT_ENTRY(void, Runtime1::new_object_array(JavaThread* current, Klass* array_klass, jint length))
 393 #ifndef PRODUCT
 394   if (PrintC1Statistics) {
 395     _new_object_array_slowcase_cnt++;
 396   }
 397 #endif
 398   // Note: no handle for klass needed since they are not used
 399   //       anymore after new_objArray() and no GC can happen before.
 400   //       (This may have to change if this code changes!)
 401   assert(array_klass->is_klass(), "not a class");
 402   Handle holder(current, array_klass->klass_holder()); // keep the klass alive
 403   Klass* elem_klass = ObjArrayKlass::cast(array_klass)->element_klass();
 404   objArrayOop obj = oopFactory::new_objArray(elem_klass, length, CHECK);
 405   current->set_vm_result(obj);
 406   // This is pretty rare but this runtime patch is stressful to deoptimization
 407   // if we deoptimize here so force a deopt to stress the path.
 408   if (DeoptimizeALot) {
 409     deopt_caller(current);
 410   }
 411 JRT_END
 412 
 413 






















 414 JRT_ENTRY(void, Runtime1::new_multi_array(JavaThread* current, Klass* klass, int rank, jint* dims))
 415 #ifndef PRODUCT
 416   if (PrintC1Statistics) {
 417     _new_multi_array_slowcase_cnt++;
 418   }
 419 #endif
 420   assert(klass->is_klass(), "not a class");
 421   assert(rank >= 1, "rank must be nonzero");
 422   Handle holder(current, klass->klass_holder()); // keep the klass alive
 423   oop obj = ArrayKlass::cast(klass)->multi_allocate(rank, dims, CHECK);
 424   current->set_vm_result(obj);
 425 JRT_END
 426 
 427 

















































































 428 JRT_ENTRY(void, Runtime1::unimplemented_entry(JavaThread* current, StubID id))
 429   tty->print_cr("Runtime1::entry_for(%d) returned unimplemented entry point", id);
 430 JRT_END
 431 
 432 
 433 JRT_ENTRY(void, Runtime1::throw_array_store_exception(JavaThread* current, oopDesc* obj))
 434   ResourceMark rm(current);
 435   const char* klass_name = obj->klass()->external_name();
 436   SharedRuntime::throw_and_post_jvmti_exception(current, vmSymbols::java_lang_ArrayStoreException(), klass_name);
 437 JRT_END
 438 
 439 
 440 // counter_overflow() is called from within C1-compiled methods. The enclosing method is the method
 441 // associated with the top activation record. The inlinee (that is possibly included in the enclosing
 442 // method) method is passed as an argument. In order to do that it is embedded in the code as
 443 // a constant.
 444 static nmethod* counter_overflow_helper(JavaThread* current, int branch_bci, Method* m) {
 445   nmethod* osr_nm = nullptr;
 446   methodHandle method(current, m);
 447 

 731     _throw_class_cast_exception_count++;
 732   }
 733 #endif
 734   ResourceMark rm(current);
 735   char* message = SharedRuntime::generate_class_cast_message(current, object->klass());
 736   SharedRuntime::throw_and_post_jvmti_exception(current, vmSymbols::java_lang_ClassCastException(), message);
 737 JRT_END
 738 
 739 
 740 JRT_ENTRY(void, Runtime1::throw_incompatible_class_change_error(JavaThread* current))
 741 #ifndef PRODUCT
 742   if (PrintC1Statistics) {
 743     _throw_incompatible_class_change_error_count++;
 744   }
 745 #endif
 746   ResourceMark rm(current);
 747   SharedRuntime::throw_and_post_jvmti_exception(current, vmSymbols::java_lang_IncompatibleClassChangeError());
 748 JRT_END
 749 
 750 






 751 JRT_BLOCK_ENTRY(void, Runtime1::monitorenter(JavaThread* current, oopDesc* obj, BasicObjectLock* lock))
 752 #ifndef PRODUCT
 753   if (PrintC1Statistics) {
 754     _monitorenter_slowcase_cnt++;
 755   }
 756 #endif
 757   if (LockingMode == LM_MONITOR) {
 758     lock->set_obj(obj);
 759   }
 760   assert(LockingMode == LM_LIGHTWEIGHT || obj == lock->obj(), "must match");
 761   SharedRuntime::monitor_enter_helper(obj, LockingMode == LM_LIGHTWEIGHT ? nullptr : lock->lock(), current);
 762 JRT_END
 763 
 764 
 765 JRT_LEAF(void, Runtime1::monitorexit(JavaThread* current, BasicObjectLock* lock))
 766   assert(current == JavaThread::current(), "pre-condition");
 767 #ifndef PRODUCT
 768   if (PrintC1Statistics) {
 769     _monitorexit_slowcase_cnt++;
 770   }

 952   // this is used by assertions in the access_field_patching_id
 953   BasicType patch_field_type = T_ILLEGAL;
 954   bool deoptimize_for_volatile = false;
 955   bool deoptimize_for_atomic = false;
 956   int patch_field_offset = -1;
 957   Klass* init_klass = nullptr; // klass needed by load_klass_patching code
 958   Klass* load_klass = nullptr; // klass needed by load_klass_patching code
 959   Handle mirror(current, nullptr); // oop needed by load_mirror_patching code
 960   Handle appendix(current, nullptr); // oop needed by appendix_patching code
 961   bool load_klass_or_mirror_patch_id =
 962     (stub_id == Runtime1::load_klass_patching_id || stub_id == Runtime1::load_mirror_patching_id);
 963 
 964   if (stub_id == Runtime1::access_field_patching_id) {
 965 
 966     Bytecode_field field_access(caller_method, bci);
 967     fieldDescriptor result; // initialize class if needed
 968     Bytecodes::Code code = field_access.code();
 969     constantPoolHandle constants(current, caller_method->constants());
 970     LinkResolver::resolve_field_access(result, constants, field_access.index(), caller_method, Bytecodes::java_code(code), CHECK);
 971     patch_field_offset = result.offset();

 972 
 973     // If we're patching a field which is volatile then at compile it
 974     // must not have been know to be volatile, so the generated code
 975     // isn't correct for a volatile reference.  The nmethod has to be
 976     // deoptimized so that the code can be regenerated correctly.
 977     // This check is only needed for access_field_patching since this
 978     // is the path for patching field offsets.  load_klass is only
 979     // used for patching references to oops which don't need special
 980     // handling in the volatile case.
 981 
 982     deoptimize_for_volatile = result.access_flags().is_volatile();
 983 
 984     // If we are patching a field which should be atomic, then
 985     // the generated code is not correct either, force deoptimizing.
 986     // We need to only cover T_LONG and T_DOUBLE fields, as we can
 987     // break access atomicity only for them.
 988 
 989     // Strictly speaking, the deoptimization on 64-bit platforms
 990     // is unnecessary, and T_LONG stores on 32-bit platforms need
 991     // to be handled by special patching code when AlwaysAtomicAccesses

 994     // accesses.
 995 
 996     patch_field_type = result.field_type();
 997     deoptimize_for_atomic = (AlwaysAtomicAccesses && (patch_field_type == T_DOUBLE || patch_field_type == T_LONG));
 998 
 999   } else if (load_klass_or_mirror_patch_id) {
1000     Klass* k = nullptr;
1001     switch (code) {
1002       case Bytecodes::_putstatic:
1003       case Bytecodes::_getstatic:
1004         { Klass* klass = resolve_field_return_klass(caller_method, bci, CHECK);
1005           init_klass = klass;
1006           mirror = Handle(current, klass->java_mirror());
1007         }
1008         break;
1009       case Bytecodes::_new:
1010         { Bytecode_new bnew(caller_method(), caller_method->bcp_from(bci));
1011           k = caller_method->constants()->klass_at(bnew.index(), CHECK);
1012         }
1013         break;





1014       case Bytecodes::_multianewarray:
1015         { Bytecode_multianewarray mna(caller_method(), caller_method->bcp_from(bci));
1016           k = caller_method->constants()->klass_at(mna.index(), CHECK);




1017         }
1018         break;
1019       case Bytecodes::_instanceof:
1020         { Bytecode_instanceof io(caller_method(), caller_method->bcp_from(bci));
1021           k = caller_method->constants()->klass_at(io.index(), CHECK);
1022         }
1023         break;
1024       case Bytecodes::_checkcast:
1025         { Bytecode_checkcast cc(caller_method(), caller_method->bcp_from(bci));
1026           k = caller_method->constants()->klass_at(cc.index(), CHECK);
1027         }
1028         break;
1029       case Bytecodes::_anewarray:
1030         { Bytecode_anewarray anew(caller_method(), caller_method->bcp_from(bci));
1031           Klass* ek = caller_method->constants()->klass_at(anew.index(), CHECK);
1032           k = ek->array_klass(CHECK);
1033         }
1034         break;
1035       case Bytecodes::_ldc:
1036       case Bytecodes::_ldc_w:

1520 #ifndef PRODUCT
1521 void Runtime1::print_statistics() {
1522   tty->print_cr("C1 Runtime statistics:");
1523   tty->print_cr(" _resolve_invoke_virtual_cnt:     %u", SharedRuntime::_resolve_virtual_ctr);
1524   tty->print_cr(" _resolve_invoke_opt_virtual_cnt: %u", SharedRuntime::_resolve_opt_virtual_ctr);
1525   tty->print_cr(" _resolve_invoke_static_cnt:      %u", SharedRuntime::_resolve_static_ctr);
1526   tty->print_cr(" _handle_wrong_method_cnt:        %u", SharedRuntime::_wrong_method_ctr);
1527   tty->print_cr(" _ic_miss_cnt:                    %u", SharedRuntime::_ic_miss_ctr);
1528   tty->print_cr(" _generic_arraycopystub_cnt:      %u", _generic_arraycopystub_cnt);
1529   tty->print_cr(" _byte_arraycopy_cnt:             %u", _byte_arraycopy_stub_cnt);
1530   tty->print_cr(" _short_arraycopy_cnt:            %u", _short_arraycopy_stub_cnt);
1531   tty->print_cr(" _int_arraycopy_cnt:              %u", _int_arraycopy_stub_cnt);
1532   tty->print_cr(" _long_arraycopy_cnt:             %u", _long_arraycopy_stub_cnt);
1533   tty->print_cr(" _oop_arraycopy_cnt:              %u", _oop_arraycopy_stub_cnt);
1534   tty->print_cr(" _arraycopy_slowcase_cnt:         %u", _arraycopy_slowcase_cnt);
1535   tty->print_cr(" _arraycopy_checkcast_cnt:        %u", _arraycopy_checkcast_cnt);
1536   tty->print_cr(" _arraycopy_checkcast_attempt_cnt:%u", _arraycopy_checkcast_attempt_cnt);
1537 
1538   tty->print_cr(" _new_type_array_slowcase_cnt:    %u", _new_type_array_slowcase_cnt);
1539   tty->print_cr(" _new_object_array_slowcase_cnt:  %u", _new_object_array_slowcase_cnt);

1540   tty->print_cr(" _new_instance_slowcase_cnt:      %u", _new_instance_slowcase_cnt);
1541   tty->print_cr(" _new_multi_array_slowcase_cnt:   %u", _new_multi_array_slowcase_cnt);






1542   tty->print_cr(" _monitorenter_slowcase_cnt:      %u", _monitorenter_slowcase_cnt);
1543   tty->print_cr(" _monitorexit_slowcase_cnt:       %u", _monitorexit_slowcase_cnt);
1544   tty->print_cr(" _patch_code_slowcase_cnt:        %u", _patch_code_slowcase_cnt);
1545 
1546   tty->print_cr(" _throw_range_check_exception_count:            %u:", _throw_range_check_exception_count);
1547   tty->print_cr(" _throw_index_exception_count:                  %u:", _throw_index_exception_count);
1548   tty->print_cr(" _throw_div0_exception_count:                   %u:", _throw_div0_exception_count);
1549   tty->print_cr(" _throw_null_pointer_exception_count:           %u:", _throw_null_pointer_exception_count);
1550   tty->print_cr(" _throw_class_cast_exception_count:             %u:", _throw_class_cast_exception_count);
1551   tty->print_cr(" _throw_incompatible_class_change_error_count:  %u:", _throw_incompatible_class_change_error_count);

1552   tty->print_cr(" _throw_count:                                  %u:", _throw_count);
1553 
1554   SharedRuntime::print_ic_miss_histogram();
1555   tty->cr();
1556 }
1557 #endif // PRODUCT

  36 #include "code/codeBlob.hpp"
  37 #include "code/compiledIC.hpp"
  38 #include "code/pcDesc.hpp"
  39 #include "code/scopeDesc.hpp"
  40 #include "code/vtableStubs.hpp"
  41 #include "compiler/compilationPolicy.hpp"
  42 #include "compiler/disassembler.hpp"
  43 #include "compiler/oopMap.hpp"
  44 #include "gc/shared/barrierSet.hpp"
  45 #include "gc/shared/c1/barrierSetC1.hpp"
  46 #include "gc/shared/collectedHeap.hpp"
  47 #include "interpreter/bytecode.hpp"
  48 #include "interpreter/interpreter.hpp"
  49 #include "jfr/support/jfrIntrinsics.hpp"
  50 #include "logging/log.hpp"
  51 #include "memory/allocation.inline.hpp"
  52 #include "memory/oopFactory.hpp"
  53 #include "memory/resourceArea.hpp"
  54 #include "memory/universe.hpp"
  55 #include "oops/access.inline.hpp"
  56 #include "oops/flatArrayKlass.hpp"
  57 #include "oops/flatArrayOop.inline.hpp"
  58 #include "oops/klass.inline.hpp"
  59 #include "oops/objArrayOop.inline.hpp"
  60 #include "oops/objArrayKlass.hpp"
  61 #include "oops/oop.inline.hpp"
  62 #include "prims/jvmtiExport.hpp"
  63 #include "runtime/atomic.hpp"
  64 #include "runtime/fieldDescriptor.inline.hpp"
  65 #include "runtime/frame.inline.hpp"
  66 #include "runtime/handles.inline.hpp"
  67 #include "runtime/interfaceSupport.inline.hpp"
  68 #include "runtime/javaCalls.hpp"
  69 #include "runtime/sharedRuntime.hpp"
  70 #include "runtime/stackWatermarkSet.hpp"
  71 #include "runtime/stubRoutines.hpp"
  72 #include "runtime/threadCritical.hpp"
  73 #include "runtime/vframe.inline.hpp"
  74 #include "runtime/vframeArray.hpp"
  75 #include "runtime/vm_version.hpp"
  76 #include "utilities/copy.hpp"
  77 #include "utilities/events.hpp"

 107     _num_rt_args = args;
 108   }
 109   assert(_num_rt_args == args, "can't change the number of args");
 110 }
 111 
 112 // Implementation of Runtime1
 113 
 114 CodeBlob* Runtime1::_blobs[Runtime1::number_of_ids];
 115 const char *Runtime1::_blob_names[] = {
 116   RUNTIME1_STUBS(STUB_NAME, LAST_STUB_NAME)
 117 };
 118 
 119 #ifndef PRODUCT
 120 // statistics
 121 uint Runtime1::_generic_arraycopystub_cnt = 0;
 122 uint Runtime1::_arraycopy_slowcase_cnt = 0;
 123 uint Runtime1::_arraycopy_checkcast_cnt = 0;
 124 uint Runtime1::_arraycopy_checkcast_attempt_cnt = 0;
 125 uint Runtime1::_new_type_array_slowcase_cnt = 0;
 126 uint Runtime1::_new_object_array_slowcase_cnt = 0;
 127 uint Runtime1::_new_flat_array_slowcase_cnt = 0;
 128 uint Runtime1::_new_instance_slowcase_cnt = 0;
 129 uint Runtime1::_new_multi_array_slowcase_cnt = 0;
 130 uint Runtime1::_load_flat_array_slowcase_cnt = 0;
 131 uint Runtime1::_store_flat_array_slowcase_cnt = 0;
 132 uint Runtime1::_substitutability_check_slowcase_cnt = 0;
 133 uint Runtime1::_buffer_inline_args_slowcase_cnt = 0;
 134 uint Runtime1::_buffer_inline_args_no_receiver_slowcase_cnt = 0;
 135 uint Runtime1::_monitorenter_slowcase_cnt = 0;
 136 uint Runtime1::_monitorexit_slowcase_cnt = 0;
 137 uint Runtime1::_patch_code_slowcase_cnt = 0;
 138 uint Runtime1::_throw_range_check_exception_count = 0;
 139 uint Runtime1::_throw_index_exception_count = 0;
 140 uint Runtime1::_throw_div0_exception_count = 0;
 141 uint Runtime1::_throw_null_pointer_exception_count = 0;
 142 uint Runtime1::_throw_class_cast_exception_count = 0;
 143 uint Runtime1::_throw_incompatible_class_change_error_count = 0;
 144 uint Runtime1::_throw_illegal_monitor_state_exception_count = 0;
 145 uint Runtime1::_throw_count = 0;
 146 
 147 static uint _byte_arraycopy_stub_cnt = 0;
 148 static uint _short_arraycopy_stub_cnt = 0;
 149 static uint _int_arraycopy_stub_cnt = 0;
 150 static uint _long_arraycopy_stub_cnt = 0;
 151 static uint _oop_arraycopy_stub_cnt = 0;
 152 
 153 address Runtime1::arraycopy_count_address(BasicType type) {
 154   switch (type) {
 155   case T_BOOLEAN:
 156   case T_BYTE:   return (address)&_byte_arraycopy_stub_cnt;
 157   case T_CHAR:
 158   case T_SHORT:  return (address)&_short_arraycopy_stub_cnt;
 159   case T_FLOAT:
 160   case T_INT:    return (address)&_int_arraycopy_stub_cnt;
 161   case T_DOUBLE:
 162   case T_LONG:   return (address)&_long_arraycopy_stub_cnt;
 163   case T_ARRAY:
 164   case T_OBJECT: return (address)&_oop_arraycopy_stub_cnt;

 340 #ifdef JFR_HAVE_INTRINSICS
 341   FUNCTION_CASE(entry, JfrTime::time_function());
 342 #endif
 343   FUNCTION_CASE(entry, StubRoutines::updateBytesCRC32());
 344   FUNCTION_CASE(entry, StubRoutines::updateBytesCRC32C());
 345   FUNCTION_CASE(entry, StubRoutines::vectorizedMismatch());
 346   FUNCTION_CASE(entry, StubRoutines::dexp());
 347   FUNCTION_CASE(entry, StubRoutines::dlog());
 348   FUNCTION_CASE(entry, StubRoutines::dlog10());
 349   FUNCTION_CASE(entry, StubRoutines::dpow());
 350   FUNCTION_CASE(entry, StubRoutines::dsin());
 351   FUNCTION_CASE(entry, StubRoutines::dcos());
 352   FUNCTION_CASE(entry, StubRoutines::dtan());
 353 
 354 #undef FUNCTION_CASE
 355 
 356   // Soft float adds more runtime names.
 357   return pd_name_for_address(entry);
 358 }
 359 
 360 static void allocate_instance(JavaThread* current, Klass* klass, TRAPS) {

 361 #ifndef PRODUCT
 362   if (PrintC1Statistics) {
 363     Runtime1::_new_instance_slowcase_cnt++;
 364   }
 365 #endif
 366   assert(klass->is_klass(), "not a class");
 367   Handle holder(current, klass->klass_holder()); // keep the klass alive
 368   InstanceKlass* h = InstanceKlass::cast(klass);
 369   h->check_valid_for_instantiation(true, CHECK);
 370   // make sure klass is initialized
 371   h->initialize(CHECK);
 372   // allocate instance and return via TLS
 373   oop obj = h->allocate_instance(CHECK);
 374   current->set_vm_result(obj);
 375 JRT_END
 376 
 377 JRT_ENTRY(void, Runtime1::new_instance(JavaThread* current, Klass* klass))
 378   allocate_instance(current, klass, CHECK);
 379 JRT_END
 380 
 381 // Same as new_instance but throws error for inline klasses
 382 JRT_ENTRY(void, Runtime1::new_instance_no_inline(JavaThread* current, Klass* klass))
 383   if (klass->is_inline_klass()) {
 384     SharedRuntime::throw_and_post_jvmti_exception(current, vmSymbols::java_lang_InstantiationError());
 385   } else {
 386     allocate_instance(current, klass, CHECK);
 387   }
 388 JRT_END
 389 
 390 JRT_ENTRY(void, Runtime1::new_type_array(JavaThread* current, Klass* klass, jint length))
 391 #ifndef PRODUCT
 392   if (PrintC1Statistics) {
 393     _new_type_array_slowcase_cnt++;
 394   }
 395 #endif
 396   // Note: no handle for klass needed since they are not used
 397   //       anymore after new_typeArray() and no GC can happen before.
 398   //       (This may have to change if this code changes!)
 399   assert(klass->is_klass(), "not a class");
 400   BasicType elt_type = TypeArrayKlass::cast(klass)->element_type();
 401   oop obj = oopFactory::new_typeArray(elt_type, length, CHECK);
 402   current->set_vm_result(obj);
 403   // This is pretty rare but this runtime patch is stressful to deoptimization
 404   // if we deoptimize here so force a deopt to stress the path.
 405   if (DeoptimizeALot) {
 406     deopt_caller(current);
 407   }
 408 
 409 JRT_END
 410 
 411 
 412 JRT_ENTRY(void, Runtime1::new_object_array(JavaThread* current, Klass* array_klass, jint length))
 413 #ifndef PRODUCT
 414   if (PrintC1Statistics) {
 415     _new_object_array_slowcase_cnt++;
 416   }
 417 #endif
 418   // Note: no handle for klass needed since they are not used
 419   //       anymore after new_objArray() and no GC can happen before.
 420   //       (This may have to change if this code changes!)
 421   assert(array_klass->is_klass(), "not a class");
 422   Handle holder(current, array_klass->klass_holder()); // keep the klass alive
 423   Klass* elem_klass = ArrayKlass::cast(array_klass)->element_klass();
 424   objArrayOop obj = oopFactory::new_objArray(elem_klass, length, CHECK);
 425   current->set_vm_result(obj);
 426   // This is pretty rare but this runtime patch is stressful to deoptimization
 427   // if we deoptimize here so force a deopt to stress the path.
 428   if (DeoptimizeALot) {
 429     deopt_caller(current);
 430   }
 431 JRT_END
 432 
 433 
 434 JRT_ENTRY(void, Runtime1::new_flat_array(JavaThread* current, Klass* array_klass, jint length))
 435   NOT_PRODUCT(_new_flat_array_slowcase_cnt++;)
 436 
 437   // Note: no handle for klass needed since they are not used
 438   //       anymore after new_objArray() and no GC can happen before.
 439   //       (This may have to change if this code changes!)
 440   assert(array_klass->is_klass(), "not a class");
 441   Handle holder(THREAD, array_klass->klass_holder()); // keep the klass alive
 442   Klass* elem_klass = ArrayKlass::cast(array_klass)->element_klass();
 443   assert(elem_klass->is_inline_klass(), "must be");
 444   // Logically creates elements, ensure klass init
 445   elem_klass->initialize(CHECK);
 446   arrayOop obj = oopFactory::new_valueArray(elem_klass, length, CHECK);
 447   current->set_vm_result(obj);
 448   // This is pretty rare but this runtime patch is stressful to deoptimization
 449   // if we deoptimize here so force a deopt to stress the path.
 450   if (DeoptimizeALot) {
 451     deopt_caller(current);
 452   }
 453 JRT_END
 454 
 455 
 456 JRT_ENTRY(void, Runtime1::new_multi_array(JavaThread* current, Klass* klass, int rank, jint* dims))
 457 #ifndef PRODUCT
 458   if (PrintC1Statistics) {
 459     _new_multi_array_slowcase_cnt++;
 460   }
 461 #endif
 462   assert(klass->is_klass(), "not a class");
 463   assert(rank >= 1, "rank must be nonzero");
 464   Handle holder(current, klass->klass_holder()); // keep the klass alive
 465   oop obj = ArrayKlass::cast(klass)->multi_allocate(rank, dims, CHECK);
 466   current->set_vm_result(obj);
 467 JRT_END
 468 
 469 
 470 static void profile_flat_array(JavaThread* current) {
 471   ResourceMark rm(current);
 472   vframeStream vfst(current, true);
 473   assert(!vfst.at_end(), "Java frame must exist");
 474   // Check if array access profiling is enabled
 475   if (vfst.nm()->comp_level() != CompLevel_full_profile || !C1UpdateMethodData) {
 476     return;
 477   }
 478   int bci = vfst.bci();
 479   Method* method = vfst.method();
 480   MethodData* md = method->method_data();
 481   if (md != nullptr) {
 482     ProfileData* data = md->bci_to_data(bci);
 483     assert(data != nullptr && data->is_ArrayLoadStoreData(), "incorrect profiling entry");
 484     ArrayLoadStoreData* load_store = (ArrayLoadStoreData*)data;
 485     load_store->set_flat_array();
 486   }
 487 }
 488 
 489 JRT_ENTRY(void, Runtime1::load_flat_array(JavaThread* current, flatArrayOopDesc* array, int index))
 490   assert(array->klass()->is_flatArray_klass(), "should not be called");
 491   profile_flat_array(current);
 492 
 493   NOT_PRODUCT(_load_flat_array_slowcase_cnt++;)
 494   assert(array->length() > 0 && index < array->length(), "already checked");
 495   flatArrayHandle vah(current, array);
 496   oop obj = flatArrayOopDesc::value_alloc_copy_from_index(vah, index, CHECK);
 497   current->set_vm_result(obj);
 498 JRT_END
 499 
 500 
 501 JRT_ENTRY(void, Runtime1::store_flat_array(JavaThread* current, flatArrayOopDesc* array, int index, oopDesc* value))
 502   if (array->klass()->is_flatArray_klass()) {
 503     profile_flat_array(current);
 504   }
 505 
 506   NOT_PRODUCT(_store_flat_array_slowcase_cnt++;)
 507   if (value == nullptr) {
 508     assert(array->klass()->is_flatArray_klass() || array->klass()->is_null_free_array_klass(), "should not be called");
 509     SharedRuntime::throw_and_post_jvmti_exception(current, vmSymbols::java_lang_NullPointerException());
 510   } else {
 511     assert(array->klass()->is_flatArray_klass(), "should not be called");
 512     array->value_copy_to_index(value, index);
 513   }
 514 JRT_END
 515 
 516 
 517 JRT_ENTRY(int, Runtime1::substitutability_check(JavaThread* current, oopDesc* left, oopDesc* right))
 518   NOT_PRODUCT(_substitutability_check_slowcase_cnt++;)
 519   JavaCallArguments args;
 520   args.push_oop(Handle(THREAD, left));
 521   args.push_oop(Handle(THREAD, right));
 522   JavaValue result(T_BOOLEAN);
 523   JavaCalls::call_static(&result,
 524                          vmClasses::ValueObjectMethods_klass(),
 525                          vmSymbols::isSubstitutable_name(),
 526                          vmSymbols::object_object_boolean_signature(),
 527                          &args, CHECK_0);
 528   return result.get_jboolean() ? 1 : 0;
 529 JRT_END
 530 
 531 
 532 extern "C" void ps();
 533 
 534 void Runtime1::buffer_inline_args_impl(JavaThread* current, Method* m, bool allocate_receiver) {
 535   JavaThread* THREAD = current;
 536   methodHandle method(current, m); // We are inside the verified_entry or verified_inline_ro_entry of this method.
 537   oop obj = SharedRuntime::allocate_inline_types_impl(current, method, allocate_receiver, CHECK);
 538   current->set_vm_result(obj);
 539 }
 540 
 541 JRT_ENTRY(void, Runtime1::buffer_inline_args(JavaThread* current, Method* method))
 542   NOT_PRODUCT(_buffer_inline_args_slowcase_cnt++;)
 543   buffer_inline_args_impl(current, method, true);
 544 JRT_END
 545 
 546 JRT_ENTRY(void, Runtime1::buffer_inline_args_no_receiver(JavaThread* current, Method* method))
 547   NOT_PRODUCT(_buffer_inline_args_no_receiver_slowcase_cnt++;)
 548   buffer_inline_args_impl(current, method, false);
 549 JRT_END
 550 
 551 JRT_ENTRY(void, Runtime1::unimplemented_entry(JavaThread* current, StubID id))
 552   tty->print_cr("Runtime1::entry_for(%d) returned unimplemented entry point", id);
 553 JRT_END
 554 
 555 
 556 JRT_ENTRY(void, Runtime1::throw_array_store_exception(JavaThread* current, oopDesc* obj))
 557   ResourceMark rm(current);
 558   const char* klass_name = obj->klass()->external_name();
 559   SharedRuntime::throw_and_post_jvmti_exception(current, vmSymbols::java_lang_ArrayStoreException(), klass_name);
 560 JRT_END
 561 
 562 
 563 // counter_overflow() is called from within C1-compiled methods. The enclosing method is the method
 564 // associated with the top activation record. The inlinee (that is possibly included in the enclosing
 565 // method) method is passed as an argument. In order to do that it is embedded in the code as
 566 // a constant.
 567 static nmethod* counter_overflow_helper(JavaThread* current, int branch_bci, Method* m) {
 568   nmethod* osr_nm = nullptr;
 569   methodHandle method(current, m);
 570 

 854     _throw_class_cast_exception_count++;
 855   }
 856 #endif
 857   ResourceMark rm(current);
 858   char* message = SharedRuntime::generate_class_cast_message(current, object->klass());
 859   SharedRuntime::throw_and_post_jvmti_exception(current, vmSymbols::java_lang_ClassCastException(), message);
 860 JRT_END
 861 
 862 
 863 JRT_ENTRY(void, Runtime1::throw_incompatible_class_change_error(JavaThread* current))
 864 #ifndef PRODUCT
 865   if (PrintC1Statistics) {
 866     _throw_incompatible_class_change_error_count++;
 867   }
 868 #endif
 869   ResourceMark rm(current);
 870   SharedRuntime::throw_and_post_jvmti_exception(current, vmSymbols::java_lang_IncompatibleClassChangeError());
 871 JRT_END
 872 
 873 
 874 JRT_ENTRY(void, Runtime1::throw_illegal_monitor_state_exception(JavaThread* current))
 875   NOT_PRODUCT(_throw_illegal_monitor_state_exception_count++;)
 876   ResourceMark rm(current);
 877   SharedRuntime::throw_and_post_jvmti_exception(current, vmSymbols::java_lang_IllegalMonitorStateException());
 878 JRT_END
 879 
 880 JRT_BLOCK_ENTRY(void, Runtime1::monitorenter(JavaThread* current, oopDesc* obj, BasicObjectLock* lock))
 881 #ifndef PRODUCT
 882   if (PrintC1Statistics) {
 883     _monitorenter_slowcase_cnt++;
 884   }
 885 #endif
 886   if (LockingMode == LM_MONITOR) {
 887     lock->set_obj(obj);
 888   }
 889   assert(LockingMode == LM_LIGHTWEIGHT || obj == lock->obj(), "must match");
 890   SharedRuntime::monitor_enter_helper(obj, LockingMode == LM_LIGHTWEIGHT ? nullptr : lock->lock(), current);
 891 JRT_END
 892 
 893 
 894 JRT_LEAF(void, Runtime1::monitorexit(JavaThread* current, BasicObjectLock* lock))
 895   assert(current == JavaThread::current(), "pre-condition");
 896 #ifndef PRODUCT
 897   if (PrintC1Statistics) {
 898     _monitorexit_slowcase_cnt++;
 899   }

1081   // this is used by assertions in the access_field_patching_id
1082   BasicType patch_field_type = T_ILLEGAL;
1083   bool deoptimize_for_volatile = false;
1084   bool deoptimize_for_atomic = false;
1085   int patch_field_offset = -1;
1086   Klass* init_klass = nullptr; // klass needed by load_klass_patching code
1087   Klass* load_klass = nullptr; // klass needed by load_klass_patching code
1088   Handle mirror(current, nullptr); // oop needed by load_mirror_patching code
1089   Handle appendix(current, nullptr); // oop needed by appendix_patching code
1090   bool load_klass_or_mirror_patch_id =
1091     (stub_id == Runtime1::load_klass_patching_id || stub_id == Runtime1::load_mirror_patching_id);
1092 
1093   if (stub_id == Runtime1::access_field_patching_id) {
1094 
1095     Bytecode_field field_access(caller_method, bci);
1096     fieldDescriptor result; // initialize class if needed
1097     Bytecodes::Code code = field_access.code();
1098     constantPoolHandle constants(current, caller_method->constants());
1099     LinkResolver::resolve_field_access(result, constants, field_access.index(), caller_method, Bytecodes::java_code(code), CHECK);
1100     patch_field_offset = result.offset();
1101     assert(!result.is_flat(), "Can not patch access to flat field");
1102 
1103     // If we're patching a field which is volatile then at compile it
1104     // must not have been know to be volatile, so the generated code
1105     // isn't correct for a volatile reference.  The nmethod has to be
1106     // deoptimized so that the code can be regenerated correctly.
1107     // This check is only needed for access_field_patching since this
1108     // is the path for patching field offsets.  load_klass is only
1109     // used for patching references to oops which don't need special
1110     // handling in the volatile case.
1111 
1112     deoptimize_for_volatile = result.access_flags().is_volatile();
1113 
1114     // If we are patching a field which should be atomic, then
1115     // the generated code is not correct either, force deoptimizing.
1116     // We need to only cover T_LONG and T_DOUBLE fields, as we can
1117     // break access atomicity only for them.
1118 
1119     // Strictly speaking, the deoptimization on 64-bit platforms
1120     // is unnecessary, and T_LONG stores on 32-bit platforms need
1121     // to be handled by special patching code when AlwaysAtomicAccesses

1124     // accesses.
1125 
1126     patch_field_type = result.field_type();
1127     deoptimize_for_atomic = (AlwaysAtomicAccesses && (patch_field_type == T_DOUBLE || patch_field_type == T_LONG));
1128 
1129   } else if (load_klass_or_mirror_patch_id) {
1130     Klass* k = nullptr;
1131     switch (code) {
1132       case Bytecodes::_putstatic:
1133       case Bytecodes::_getstatic:
1134         { Klass* klass = resolve_field_return_klass(caller_method, bci, CHECK);
1135           init_klass = klass;
1136           mirror = Handle(current, klass->java_mirror());
1137         }
1138         break;
1139       case Bytecodes::_new:
1140         { Bytecode_new bnew(caller_method(), caller_method->bcp_from(bci));
1141           k = caller_method->constants()->klass_at(bnew.index(), CHECK);
1142         }
1143         break;
1144       case Bytecodes::_aconst_init:
1145         { Bytecode_aconst_init baconst_init(caller_method(), caller_method->bcp_from(bci));
1146           k = caller_method->constants()->klass_at(baconst_init.index(), CHECK);
1147         }
1148         break;
1149       case Bytecodes::_multianewarray:
1150         { Bytecode_multianewarray mna(caller_method(), caller_method->bcp_from(bci));
1151           k = caller_method->constants()->klass_at(mna.index(), CHECK);
1152           if (k->name()->is_Q_array_signature()) {
1153             // Logically creates elements, ensure klass init
1154             k->initialize(CHECK);
1155           }
1156         }
1157         break;
1158       case Bytecodes::_instanceof:
1159         { Bytecode_instanceof io(caller_method(), caller_method->bcp_from(bci));
1160           k = caller_method->constants()->klass_at(io.index(), CHECK);
1161         }
1162         break;
1163       case Bytecodes::_checkcast:
1164         { Bytecode_checkcast cc(caller_method(), caller_method->bcp_from(bci));
1165           k = caller_method->constants()->klass_at(cc.index(), CHECK);
1166         }
1167         break;
1168       case Bytecodes::_anewarray:
1169         { Bytecode_anewarray anew(caller_method(), caller_method->bcp_from(bci));
1170           Klass* ek = caller_method->constants()->klass_at(anew.index(), CHECK);
1171           k = ek->array_klass(CHECK);
1172         }
1173         break;
1174       case Bytecodes::_ldc:
1175       case Bytecodes::_ldc_w:

1659 #ifndef PRODUCT
1660 void Runtime1::print_statistics() {
1661   tty->print_cr("C1 Runtime statistics:");
1662   tty->print_cr(" _resolve_invoke_virtual_cnt:     %u", SharedRuntime::_resolve_virtual_ctr);
1663   tty->print_cr(" _resolve_invoke_opt_virtual_cnt: %u", SharedRuntime::_resolve_opt_virtual_ctr);
1664   tty->print_cr(" _resolve_invoke_static_cnt:      %u", SharedRuntime::_resolve_static_ctr);
1665   tty->print_cr(" _handle_wrong_method_cnt:        %u", SharedRuntime::_wrong_method_ctr);
1666   tty->print_cr(" _ic_miss_cnt:                    %u", SharedRuntime::_ic_miss_ctr);
1667   tty->print_cr(" _generic_arraycopystub_cnt:      %u", _generic_arraycopystub_cnt);
1668   tty->print_cr(" _byte_arraycopy_cnt:             %u", _byte_arraycopy_stub_cnt);
1669   tty->print_cr(" _short_arraycopy_cnt:            %u", _short_arraycopy_stub_cnt);
1670   tty->print_cr(" _int_arraycopy_cnt:              %u", _int_arraycopy_stub_cnt);
1671   tty->print_cr(" _long_arraycopy_cnt:             %u", _long_arraycopy_stub_cnt);
1672   tty->print_cr(" _oop_arraycopy_cnt:              %u", _oop_arraycopy_stub_cnt);
1673   tty->print_cr(" _arraycopy_slowcase_cnt:         %u", _arraycopy_slowcase_cnt);
1674   tty->print_cr(" _arraycopy_checkcast_cnt:        %u", _arraycopy_checkcast_cnt);
1675   tty->print_cr(" _arraycopy_checkcast_attempt_cnt:%u", _arraycopy_checkcast_attempt_cnt);
1676 
1677   tty->print_cr(" _new_type_array_slowcase_cnt:    %u", _new_type_array_slowcase_cnt);
1678   tty->print_cr(" _new_object_array_slowcase_cnt:  %u", _new_object_array_slowcase_cnt);
1679   tty->print_cr(" _new_flat_array_slowcase_cnt:    %u", _new_flat_array_slowcase_cnt);
1680   tty->print_cr(" _new_instance_slowcase_cnt:      %u", _new_instance_slowcase_cnt);
1681   tty->print_cr(" _new_multi_array_slowcase_cnt:   %u", _new_multi_array_slowcase_cnt);
1682   tty->print_cr(" _load_flat_array_slowcase_cnt:   %u", _load_flat_array_slowcase_cnt);
1683   tty->print_cr(" _store_flat_array_slowcase_cnt:  %u", _store_flat_array_slowcase_cnt);
1684   tty->print_cr(" _substitutability_check_slowcase_cnt: %u", _substitutability_check_slowcase_cnt);
1685   tty->print_cr(" _buffer_inline_args_slowcase_cnt:%u", _buffer_inline_args_slowcase_cnt);
1686   tty->print_cr(" _buffer_inline_args_no_receiver_slowcase_cnt:%u", _buffer_inline_args_no_receiver_slowcase_cnt);
1687 
1688   tty->print_cr(" _monitorenter_slowcase_cnt:      %u", _monitorenter_slowcase_cnt);
1689   tty->print_cr(" _monitorexit_slowcase_cnt:       %u", _monitorexit_slowcase_cnt);
1690   tty->print_cr(" _patch_code_slowcase_cnt:        %u", _patch_code_slowcase_cnt);
1691 
1692   tty->print_cr(" _throw_range_check_exception_count:            %u:", _throw_range_check_exception_count);
1693   tty->print_cr(" _throw_index_exception_count:                  %u:", _throw_index_exception_count);
1694   tty->print_cr(" _throw_div0_exception_count:                   %u:", _throw_div0_exception_count);
1695   tty->print_cr(" _throw_null_pointer_exception_count:           %u:", _throw_null_pointer_exception_count);
1696   tty->print_cr(" _throw_class_cast_exception_count:             %u:", _throw_class_cast_exception_count);
1697   tty->print_cr(" _throw_incompatible_class_change_error_count:  %u:", _throw_incompatible_class_change_error_count);
1698   tty->print_cr(" _throw_illegal_monitor_state_exception_count:  %u:", _throw_illegal_monitor_state_exception_count);
1699   tty->print_cr(" _throw_count:                                  %u:", _throw_count);
1700 
1701   SharedRuntime::print_ic_miss_histogram();
1702   tty->cr();
1703 }
1704 #endif // PRODUCT
< prev index next >