< 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 int Runtime1::_generic_arraycopystub_cnt = 0;
 120 int Runtime1::_arraycopy_slowcase_cnt = 0;
 121 int Runtime1::_arraycopy_checkcast_cnt = 0;
 122 int Runtime1::_arraycopy_checkcast_attempt_cnt = 0;
 123 int Runtime1::_new_type_array_slowcase_cnt = 0;
 124 int Runtime1::_new_object_array_slowcase_cnt = 0;

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





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

 136 int Runtime1::_throw_count = 0;
 137 
 138 static int _byte_arraycopy_stub_cnt = 0;
 139 static int _short_arraycopy_stub_cnt = 0;
 140 static int _int_arraycopy_stub_cnt = 0;
 141 static int _long_arraycopy_stub_cnt = 0;
 142 static int _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;

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












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






















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

















































































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

 716     _throw_class_cast_exception_count++;
 717   }
 718 #endif
 719   ResourceMark rm(current);
 720   char* message = SharedRuntime::generate_class_cast_message(current, object->klass());
 721   SharedRuntime::throw_and_post_jvmti_exception(current, vmSymbols::java_lang_ClassCastException(), message);
 722 JRT_END
 723 
 724 
 725 JRT_ENTRY(void, Runtime1::throw_incompatible_class_change_error(JavaThread* current))
 726 #ifndef PRODUCT
 727   if (PrintC1Statistics) {
 728     _throw_incompatible_class_change_error_count++;
 729   }
 730 #endif
 731   ResourceMark rm(current);
 732   SharedRuntime::throw_and_post_jvmti_exception(current, vmSymbols::java_lang_IncompatibleClassChangeError());
 733 JRT_END
 734 
 735 






 736 JRT_BLOCK_ENTRY(void, Runtime1::monitorenter(JavaThread* current, oopDesc* obj, BasicObjectLock* lock))
 737 #ifndef PRODUCT
 738   if (PrintC1Statistics) {
 739     _monitorenter_slowcase_cnt++;
 740   }
 741 #endif
 742   if (!UseFastLocking) {
 743     lock->set_obj(obj);
 744   }
 745   assert(obj == lock->obj(), "must match");
 746   SharedRuntime::monitor_enter_helper(obj, lock->lock(), current);
 747 JRT_END
 748 
 749 
 750 JRT_LEAF(void, Runtime1::monitorexit(JavaThread* current, BasicObjectLock* lock))
 751 #ifndef PRODUCT
 752   if (PrintC1Statistics) {
 753     _monitorexit_slowcase_cnt++;
 754   }
 755 #endif

 930   // this is used by assertions in the access_field_patching_id
 931   BasicType patch_field_type = T_ILLEGAL;
 932   bool deoptimize_for_volatile = false;
 933   bool deoptimize_for_atomic = false;
 934   int patch_field_offset = -1;
 935   Klass* init_klass = NULL; // klass needed by load_klass_patching code
 936   Klass* load_klass = NULL; // klass needed by load_klass_patching code
 937   Handle mirror(current, NULL);                    // oop needed by load_mirror_patching code
 938   Handle appendix(current, NULL);                  // oop needed by appendix_patching code
 939   bool load_klass_or_mirror_patch_id =
 940     (stub_id == Runtime1::load_klass_patching_id || stub_id == Runtime1::load_mirror_patching_id);
 941 
 942   if (stub_id == Runtime1::access_field_patching_id) {
 943 
 944     Bytecode_field field_access(caller_method, bci);
 945     fieldDescriptor result; // initialize class if needed
 946     Bytecodes::Code code = field_access.code();
 947     constantPoolHandle constants(current, caller_method->constants());
 948     LinkResolver::resolve_field_access(result, constants, field_access.index(), caller_method, Bytecodes::java_code(code), CHECK);
 949     patch_field_offset = result.offset();

 950 
 951     // If we're patching a field which is volatile then at compile it
 952     // must not have been know to be volatile, so the generated code
 953     // isn't correct for a volatile reference.  The nmethod has to be
 954     // deoptimized so that the code can be regenerated correctly.
 955     // This check is only needed for access_field_patching since this
 956     // is the path for patching field offsets.  load_klass is only
 957     // used for patching references to oops which don't need special
 958     // handling in the volatile case.
 959 
 960     deoptimize_for_volatile = result.access_flags().is_volatile();
 961 
 962     // If we are patching a field which should be atomic, then
 963     // the generated code is not correct either, force deoptimizing.
 964     // We need to only cover T_LONG and T_DOUBLE fields, as we can
 965     // break access atomicity only for them.
 966 
 967     // Strictly speaking, the deoptimization on 64-bit platforms
 968     // is unnecessary, and T_LONG stores on 32-bit platforms need
 969     // to be handled by special patching code when AlwaysAtomicAccesses

 972     // accesses.
 973 
 974     patch_field_type = result.field_type();
 975     deoptimize_for_atomic = (AlwaysAtomicAccesses && (patch_field_type == T_DOUBLE || patch_field_type == T_LONG));
 976 
 977   } else if (load_klass_or_mirror_patch_id) {
 978     Klass* k = NULL;
 979     switch (code) {
 980       case Bytecodes::_putstatic:
 981       case Bytecodes::_getstatic:
 982         { Klass* klass = resolve_field_return_klass(caller_method, bci, CHECK);
 983           init_klass = klass;
 984           mirror = Handle(current, klass->java_mirror());
 985         }
 986         break;
 987       case Bytecodes::_new:
 988         { Bytecode_new bnew(caller_method(), caller_method->bcp_from(bci));
 989           k = caller_method->constants()->klass_at(bnew.index(), CHECK);
 990         }
 991         break;





 992       case Bytecodes::_multianewarray:
 993         { Bytecode_multianewarray mna(caller_method(), caller_method->bcp_from(bci));
 994           k = caller_method->constants()->klass_at(mna.index(), CHECK);




 995         }
 996         break;
 997       case Bytecodes::_instanceof:
 998         { Bytecode_instanceof io(caller_method(), caller_method->bcp_from(bci));
 999           k = caller_method->constants()->klass_at(io.index(), CHECK);
1000         }
1001         break;
1002       case Bytecodes::_checkcast:
1003         { Bytecode_checkcast cc(caller_method(), caller_method->bcp_from(bci));
1004           k = caller_method->constants()->klass_at(cc.index(), CHECK);
1005         }
1006         break;
1007       case Bytecodes::_anewarray:
1008         { Bytecode_anewarray anew(caller_method(), caller_method->bcp_from(bci));
1009           Klass* ek = caller_method->constants()->klass_at(anew.index(), CHECK);
1010           k = ek->array_klass(CHECK);
1011         }
1012         break;
1013       case Bytecodes::_ldc:
1014       case Bytecodes::_ldc_w:

1488 #ifndef PRODUCT
1489 void Runtime1::print_statistics() {
1490   tty->print_cr("C1 Runtime statistics:");
1491   tty->print_cr(" _resolve_invoke_virtual_cnt:     %d", SharedRuntime::_resolve_virtual_ctr);
1492   tty->print_cr(" _resolve_invoke_opt_virtual_cnt: %d", SharedRuntime::_resolve_opt_virtual_ctr);
1493   tty->print_cr(" _resolve_invoke_static_cnt:      %d", SharedRuntime::_resolve_static_ctr);
1494   tty->print_cr(" _handle_wrong_method_cnt:        %d", SharedRuntime::_wrong_method_ctr);
1495   tty->print_cr(" _ic_miss_cnt:                    %d", SharedRuntime::_ic_miss_ctr);
1496   tty->print_cr(" _generic_arraycopystub_cnt:      %d", _generic_arraycopystub_cnt);
1497   tty->print_cr(" _byte_arraycopy_cnt:             %d", _byte_arraycopy_stub_cnt);
1498   tty->print_cr(" _short_arraycopy_cnt:            %d", _short_arraycopy_stub_cnt);
1499   tty->print_cr(" _int_arraycopy_cnt:              %d", _int_arraycopy_stub_cnt);
1500   tty->print_cr(" _long_arraycopy_cnt:             %d", _long_arraycopy_stub_cnt);
1501   tty->print_cr(" _oop_arraycopy_cnt:              %d", _oop_arraycopy_stub_cnt);
1502   tty->print_cr(" _arraycopy_slowcase_cnt:         %d", _arraycopy_slowcase_cnt);
1503   tty->print_cr(" _arraycopy_checkcast_cnt:        %d", _arraycopy_checkcast_cnt);
1504   tty->print_cr(" _arraycopy_checkcast_attempt_cnt:%d", _arraycopy_checkcast_attempt_cnt);
1505 
1506   tty->print_cr(" _new_type_array_slowcase_cnt:    %d", _new_type_array_slowcase_cnt);
1507   tty->print_cr(" _new_object_array_slowcase_cnt:  %d", _new_object_array_slowcase_cnt);

1508   tty->print_cr(" _new_instance_slowcase_cnt:      %d", _new_instance_slowcase_cnt);
1509   tty->print_cr(" _new_multi_array_slowcase_cnt:   %d", _new_multi_array_slowcase_cnt);






1510   tty->print_cr(" _monitorenter_slowcase_cnt:      %d", _monitorenter_slowcase_cnt);
1511   tty->print_cr(" _monitorexit_slowcase_cnt:       %d", _monitorexit_slowcase_cnt);
1512   tty->print_cr(" _patch_code_slowcase_cnt:        %d", _patch_code_slowcase_cnt);
1513 
1514   tty->print_cr(" _throw_range_check_exception_count:            %d:", _throw_range_check_exception_count);
1515   tty->print_cr(" _throw_index_exception_count:                  %d:", _throw_index_exception_count);
1516   tty->print_cr(" _throw_div0_exception_count:                   %d:", _throw_div0_exception_count);
1517   tty->print_cr(" _throw_null_pointer_exception_count:           %d:", _throw_null_pointer_exception_count);
1518   tty->print_cr(" _throw_class_cast_exception_count:             %d:", _throw_class_cast_exception_count);
1519   tty->print_cr(" _throw_incompatible_class_change_error_count:  %d:", _throw_incompatible_class_change_error_count);

1520   tty->print_cr(" _throw_count:                                  %d:", _throw_count);
1521 
1522   SharedRuntime::print_ic_miss_histogram();
1523   tty->cr();
1524 }
1525 #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 int Runtime1::_generic_arraycopystub_cnt = 0;
 122 int Runtime1::_arraycopy_slowcase_cnt = 0;
 123 int Runtime1::_arraycopy_checkcast_cnt = 0;
 124 int Runtime1::_arraycopy_checkcast_attempt_cnt = 0;
 125 int Runtime1::_new_type_array_slowcase_cnt = 0;
 126 int Runtime1::_new_object_array_slowcase_cnt = 0;
 127 int Runtime1::_new_flat_array_slowcase_cnt = 0;
 128 int Runtime1::_new_instance_slowcase_cnt = 0;
 129 int Runtime1::_new_multi_array_slowcase_cnt = 0;
 130 int Runtime1::_load_flattened_array_slowcase_cnt = 0;
 131 int Runtime1::_store_flattened_array_slowcase_cnt = 0;
 132 int Runtime1::_substitutability_check_slowcase_cnt = 0;
 133 int Runtime1::_buffer_inline_args_slowcase_cnt = 0;
 134 int Runtime1::_buffer_inline_args_no_receiver_slowcase_cnt = 0;
 135 int Runtime1::_monitorenter_slowcase_cnt = 0;
 136 int Runtime1::_monitorexit_slowcase_cnt = 0;
 137 int Runtime1::_patch_code_slowcase_cnt = 0;
 138 int Runtime1::_throw_range_check_exception_count = 0;
 139 int Runtime1::_throw_index_exception_count = 0;
 140 int Runtime1::_throw_div0_exception_count = 0;
 141 int Runtime1::_throw_null_pointer_exception_count = 0;
 142 int Runtime1::_throw_class_cast_exception_count = 0;
 143 int Runtime1::_throw_incompatible_class_change_error_count = 0;
 144 int Runtime1::_throw_illegal_monitor_state_exception_count = 0;
 145 int Runtime1::_throw_count = 0;
 146 
 147 static int _byte_arraycopy_stub_cnt = 0;
 148 static int _short_arraycopy_stub_cnt = 0;
 149 static int _int_arraycopy_stub_cnt = 0;
 150 static int _long_arraycopy_stub_cnt = 0;
 151 static int _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;

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

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

 839     _throw_class_cast_exception_count++;
 840   }
 841 #endif
 842   ResourceMark rm(current);
 843   char* message = SharedRuntime::generate_class_cast_message(current, object->klass());
 844   SharedRuntime::throw_and_post_jvmti_exception(current, vmSymbols::java_lang_ClassCastException(), message);
 845 JRT_END
 846 
 847 
 848 JRT_ENTRY(void, Runtime1::throw_incompatible_class_change_error(JavaThread* current))
 849 #ifndef PRODUCT
 850   if (PrintC1Statistics) {
 851     _throw_incompatible_class_change_error_count++;
 852   }
 853 #endif
 854   ResourceMark rm(current);
 855   SharedRuntime::throw_and_post_jvmti_exception(current, vmSymbols::java_lang_IncompatibleClassChangeError());
 856 JRT_END
 857 
 858 
 859 JRT_ENTRY(void, Runtime1::throw_illegal_monitor_state_exception(JavaThread* current))
 860   NOT_PRODUCT(_throw_illegal_monitor_state_exception_count++;)
 861   ResourceMark rm(current);
 862   SharedRuntime::throw_and_post_jvmti_exception(current, vmSymbols::java_lang_IllegalMonitorStateException());
 863 JRT_END
 864 
 865 JRT_BLOCK_ENTRY(void, Runtime1::monitorenter(JavaThread* current, oopDesc* obj, BasicObjectLock* lock))
 866 #ifndef PRODUCT
 867   if (PrintC1Statistics) {
 868     _monitorenter_slowcase_cnt++;
 869   }
 870 #endif
 871   if (!UseFastLocking) {
 872     lock->set_obj(obj);
 873   }
 874   assert(obj == lock->obj(), "must match");
 875   SharedRuntime::monitor_enter_helper(obj, lock->lock(), current);
 876 JRT_END
 877 
 878 
 879 JRT_LEAF(void, Runtime1::monitorexit(JavaThread* current, BasicObjectLock* lock))
 880 #ifndef PRODUCT
 881   if (PrintC1Statistics) {
 882     _monitorexit_slowcase_cnt++;
 883   }
 884 #endif

1059   // this is used by assertions in the access_field_patching_id
1060   BasicType patch_field_type = T_ILLEGAL;
1061   bool deoptimize_for_volatile = false;
1062   bool deoptimize_for_atomic = false;
1063   int patch_field_offset = -1;
1064   Klass* init_klass = NULL; // klass needed by load_klass_patching code
1065   Klass* load_klass = NULL; // klass needed by load_klass_patching code
1066   Handle mirror(current, NULL);                    // oop needed by load_mirror_patching code
1067   Handle appendix(current, NULL);                  // oop needed by appendix_patching code
1068   bool load_klass_or_mirror_patch_id =
1069     (stub_id == Runtime1::load_klass_patching_id || stub_id == Runtime1::load_mirror_patching_id);
1070 
1071   if (stub_id == Runtime1::access_field_patching_id) {
1072 
1073     Bytecode_field field_access(caller_method, bci);
1074     fieldDescriptor result; // initialize class if needed
1075     Bytecodes::Code code = field_access.code();
1076     constantPoolHandle constants(current, caller_method->constants());
1077     LinkResolver::resolve_field_access(result, constants, field_access.index(), caller_method, Bytecodes::java_code(code), CHECK);
1078     patch_field_offset = result.offset();
1079     assert(!result.is_inlined(), "Can not patch access to flattened field");
1080 
1081     // If we're patching a field which is volatile then at compile it
1082     // must not have been know to be volatile, so the generated code
1083     // isn't correct for a volatile reference.  The nmethod has to be
1084     // deoptimized so that the code can be regenerated correctly.
1085     // This check is only needed for access_field_patching since this
1086     // is the path for patching field offsets.  load_klass is only
1087     // used for patching references to oops which don't need special
1088     // handling in the volatile case.
1089 
1090     deoptimize_for_volatile = result.access_flags().is_volatile();
1091 
1092     // If we are patching a field which should be atomic, then
1093     // the generated code is not correct either, force deoptimizing.
1094     // We need to only cover T_LONG and T_DOUBLE fields, as we can
1095     // break access atomicity only for them.
1096 
1097     // Strictly speaking, the deoptimization on 64-bit platforms
1098     // is unnecessary, and T_LONG stores on 32-bit platforms need
1099     // to be handled by special patching code when AlwaysAtomicAccesses

1102     // accesses.
1103 
1104     patch_field_type = result.field_type();
1105     deoptimize_for_atomic = (AlwaysAtomicAccesses && (patch_field_type == T_DOUBLE || patch_field_type == T_LONG));
1106 
1107   } else if (load_klass_or_mirror_patch_id) {
1108     Klass* k = NULL;
1109     switch (code) {
1110       case Bytecodes::_putstatic:
1111       case Bytecodes::_getstatic:
1112         { Klass* klass = resolve_field_return_klass(caller_method, bci, CHECK);
1113           init_klass = klass;
1114           mirror = Handle(current, klass->java_mirror());
1115         }
1116         break;
1117       case Bytecodes::_new:
1118         { Bytecode_new bnew(caller_method(), caller_method->bcp_from(bci));
1119           k = caller_method->constants()->klass_at(bnew.index(), CHECK);
1120         }
1121         break;
1122       case Bytecodes::_defaultvalue:
1123         { Bytecode_defaultvalue bdefaultvalue(caller_method(), caller_method->bcp_from(bci));
1124           k = caller_method->constants()->klass_at(bdefaultvalue.index(), CHECK);
1125         }
1126         break;
1127       case Bytecodes::_multianewarray:
1128         { Bytecode_multianewarray mna(caller_method(), caller_method->bcp_from(bci));
1129           k = caller_method->constants()->klass_at(mna.index(), CHECK);
1130           if (k->name()->is_Q_array_signature()) {
1131             // Logically creates elements, ensure klass init
1132             k->initialize(CHECK);
1133           }
1134         }
1135         break;
1136       case Bytecodes::_instanceof:
1137         { Bytecode_instanceof io(caller_method(), caller_method->bcp_from(bci));
1138           k = caller_method->constants()->klass_at(io.index(), CHECK);
1139         }
1140         break;
1141       case Bytecodes::_checkcast:
1142         { Bytecode_checkcast cc(caller_method(), caller_method->bcp_from(bci));
1143           k = caller_method->constants()->klass_at(cc.index(), CHECK);
1144         }
1145         break;
1146       case Bytecodes::_anewarray:
1147         { Bytecode_anewarray anew(caller_method(), caller_method->bcp_from(bci));
1148           Klass* ek = caller_method->constants()->klass_at(anew.index(), CHECK);
1149           k = ek->array_klass(CHECK);
1150         }
1151         break;
1152       case Bytecodes::_ldc:
1153       case Bytecodes::_ldc_w:

1627 #ifndef PRODUCT
1628 void Runtime1::print_statistics() {
1629   tty->print_cr("C1 Runtime statistics:");
1630   tty->print_cr(" _resolve_invoke_virtual_cnt:     %d", SharedRuntime::_resolve_virtual_ctr);
1631   tty->print_cr(" _resolve_invoke_opt_virtual_cnt: %d", SharedRuntime::_resolve_opt_virtual_ctr);
1632   tty->print_cr(" _resolve_invoke_static_cnt:      %d", SharedRuntime::_resolve_static_ctr);
1633   tty->print_cr(" _handle_wrong_method_cnt:        %d", SharedRuntime::_wrong_method_ctr);
1634   tty->print_cr(" _ic_miss_cnt:                    %d", SharedRuntime::_ic_miss_ctr);
1635   tty->print_cr(" _generic_arraycopystub_cnt:      %d", _generic_arraycopystub_cnt);
1636   tty->print_cr(" _byte_arraycopy_cnt:             %d", _byte_arraycopy_stub_cnt);
1637   tty->print_cr(" _short_arraycopy_cnt:            %d", _short_arraycopy_stub_cnt);
1638   tty->print_cr(" _int_arraycopy_cnt:              %d", _int_arraycopy_stub_cnt);
1639   tty->print_cr(" _long_arraycopy_cnt:             %d", _long_arraycopy_stub_cnt);
1640   tty->print_cr(" _oop_arraycopy_cnt:              %d", _oop_arraycopy_stub_cnt);
1641   tty->print_cr(" _arraycopy_slowcase_cnt:         %d", _arraycopy_slowcase_cnt);
1642   tty->print_cr(" _arraycopy_checkcast_cnt:        %d", _arraycopy_checkcast_cnt);
1643   tty->print_cr(" _arraycopy_checkcast_attempt_cnt:%d", _arraycopy_checkcast_attempt_cnt);
1644 
1645   tty->print_cr(" _new_type_array_slowcase_cnt:    %d", _new_type_array_slowcase_cnt);
1646   tty->print_cr(" _new_object_array_slowcase_cnt:  %d", _new_object_array_slowcase_cnt);
1647   tty->print_cr(" _new_flat_array_slowcase_cnt:    %d", _new_flat_array_slowcase_cnt);
1648   tty->print_cr(" _new_instance_slowcase_cnt:      %d", _new_instance_slowcase_cnt);
1649   tty->print_cr(" _new_multi_array_slowcase_cnt:   %d", _new_multi_array_slowcase_cnt);
1650   tty->print_cr(" _load_flattened_array_slowcase_cnt:   %d", _load_flattened_array_slowcase_cnt);
1651   tty->print_cr(" _store_flattened_array_slowcase_cnt:  %d", _store_flattened_array_slowcase_cnt);
1652   tty->print_cr(" _substitutability_check_slowcase_cnt: %d", _substitutability_check_slowcase_cnt);
1653   tty->print_cr(" _buffer_inline_args_slowcase_cnt:%d", _buffer_inline_args_slowcase_cnt);
1654   tty->print_cr(" _buffer_inline_args_no_receiver_slowcase_cnt:%d", _buffer_inline_args_no_receiver_slowcase_cnt);
1655 
1656   tty->print_cr(" _monitorenter_slowcase_cnt:      %d", _monitorenter_slowcase_cnt);
1657   tty->print_cr(" _monitorexit_slowcase_cnt:       %d", _monitorexit_slowcase_cnt);
1658   tty->print_cr(" _patch_code_slowcase_cnt:        %d", _patch_code_slowcase_cnt);
1659 
1660   tty->print_cr(" _throw_range_check_exception_count:            %d:", _throw_range_check_exception_count);
1661   tty->print_cr(" _throw_index_exception_count:                  %d:", _throw_index_exception_count);
1662   tty->print_cr(" _throw_div0_exception_count:                   %d:", _throw_div0_exception_count);
1663   tty->print_cr(" _throw_null_pointer_exception_count:           %d:", _throw_null_pointer_exception_count);
1664   tty->print_cr(" _throw_class_cast_exception_count:             %d:", _throw_class_cast_exception_count);
1665   tty->print_cr(" _throw_incompatible_class_change_error_count:  %d:", _throw_incompatible_class_change_error_count);
1666   tty->print_cr(" _throw_illegal_monitor_state_exception_count:  %d:", _throw_illegal_monitor_state_exception_count);
1667   tty->print_cr(" _throw_count:                                  %d:", _throw_count);
1668 
1669   SharedRuntime::print_ic_miss_histogram();
1670   tty->cr();
1671 }
1672 #endif // PRODUCT
< prev index next >