< 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;

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












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






















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

















































































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

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






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

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

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

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





 989       case Bytecodes::_multianewarray:
 990         { Bytecode_multianewarray mna(caller_method(), caller_method->bcp_from(bci));
 991           k = caller_method->constants()->klass_at(mna.index(), CHECK);




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

1444 #ifndef PRODUCT
1445 void Runtime1::print_statistics() {
1446   tty->print_cr("C1 Runtime statistics:");
1447   tty->print_cr(" _resolve_invoke_virtual_cnt:     %d", SharedRuntime::_resolve_virtual_ctr);
1448   tty->print_cr(" _resolve_invoke_opt_virtual_cnt: %d", SharedRuntime::_resolve_opt_virtual_ctr);
1449   tty->print_cr(" _resolve_invoke_static_cnt:      %d", SharedRuntime::_resolve_static_ctr);
1450   tty->print_cr(" _handle_wrong_method_cnt:        %d", SharedRuntime::_wrong_method_ctr);
1451   tty->print_cr(" _ic_miss_cnt:                    %d", SharedRuntime::_ic_miss_ctr);
1452   tty->print_cr(" _generic_arraycopystub_cnt:      %d", _generic_arraycopystub_cnt);
1453   tty->print_cr(" _byte_arraycopy_cnt:             %d", _byte_arraycopy_stub_cnt);
1454   tty->print_cr(" _short_arraycopy_cnt:            %d", _short_arraycopy_stub_cnt);
1455   tty->print_cr(" _int_arraycopy_cnt:              %d", _int_arraycopy_stub_cnt);
1456   tty->print_cr(" _long_arraycopy_cnt:             %d", _long_arraycopy_stub_cnt);
1457   tty->print_cr(" _oop_arraycopy_cnt:              %d", _oop_arraycopy_stub_cnt);
1458   tty->print_cr(" _arraycopy_slowcase_cnt:         %d", _arraycopy_slowcase_cnt);
1459   tty->print_cr(" _arraycopy_checkcast_cnt:        %d", _arraycopy_checkcast_cnt);
1460   tty->print_cr(" _arraycopy_checkcast_attempt_cnt:%d", _arraycopy_checkcast_attempt_cnt);
1461 
1462   tty->print_cr(" _new_type_array_slowcase_cnt:    %d", _new_type_array_slowcase_cnt);
1463   tty->print_cr(" _new_object_array_slowcase_cnt:  %d", _new_object_array_slowcase_cnt);

1464   tty->print_cr(" _new_instance_slowcase_cnt:      %d", _new_instance_slowcase_cnt);
1465   tty->print_cr(" _new_multi_array_slowcase_cnt:   %d", _new_multi_array_slowcase_cnt);






1466   tty->print_cr(" _monitorenter_slowcase_cnt:      %d", _monitorenter_slowcase_cnt);
1467   tty->print_cr(" _monitorexit_slowcase_cnt:       %d", _monitorexit_slowcase_cnt);
1468   tty->print_cr(" _patch_code_slowcase_cnt:        %d", _patch_code_slowcase_cnt);
1469 
1470   tty->print_cr(" _throw_range_check_exception_count:            %d:", _throw_range_check_exception_count);
1471   tty->print_cr(" _throw_index_exception_count:                  %d:", _throw_index_exception_count);
1472   tty->print_cr(" _throw_div0_exception_count:                   %d:", _throw_div0_exception_count);
1473   tty->print_cr(" _throw_null_pointer_exception_count:           %d:", _throw_null_pointer_exception_count);
1474   tty->print_cr(" _throw_class_cast_exception_count:             %d:", _throw_class_cast_exception_count);
1475   tty->print_cr(" _throw_incompatible_class_change_error_count:  %d:", _throw_incompatible_class_change_error_count);

1476   tty->print_cr(" _throw_count:                                  %d:", _throw_count);
1477 
1478   SharedRuntime::print_ic_miss_histogram();
1479   tty->cr();
1480 }
1481 #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;

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

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

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

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

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

1583 #ifndef PRODUCT
1584 void Runtime1::print_statistics() {
1585   tty->print_cr("C1 Runtime statistics:");
1586   tty->print_cr(" _resolve_invoke_virtual_cnt:     %d", SharedRuntime::_resolve_virtual_ctr);
1587   tty->print_cr(" _resolve_invoke_opt_virtual_cnt: %d", SharedRuntime::_resolve_opt_virtual_ctr);
1588   tty->print_cr(" _resolve_invoke_static_cnt:      %d", SharedRuntime::_resolve_static_ctr);
1589   tty->print_cr(" _handle_wrong_method_cnt:        %d", SharedRuntime::_wrong_method_ctr);
1590   tty->print_cr(" _ic_miss_cnt:                    %d", SharedRuntime::_ic_miss_ctr);
1591   tty->print_cr(" _generic_arraycopystub_cnt:      %d", _generic_arraycopystub_cnt);
1592   tty->print_cr(" _byte_arraycopy_cnt:             %d", _byte_arraycopy_stub_cnt);
1593   tty->print_cr(" _short_arraycopy_cnt:            %d", _short_arraycopy_stub_cnt);
1594   tty->print_cr(" _int_arraycopy_cnt:              %d", _int_arraycopy_stub_cnt);
1595   tty->print_cr(" _long_arraycopy_cnt:             %d", _long_arraycopy_stub_cnt);
1596   tty->print_cr(" _oop_arraycopy_cnt:              %d", _oop_arraycopy_stub_cnt);
1597   tty->print_cr(" _arraycopy_slowcase_cnt:         %d", _arraycopy_slowcase_cnt);
1598   tty->print_cr(" _arraycopy_checkcast_cnt:        %d", _arraycopy_checkcast_cnt);
1599   tty->print_cr(" _arraycopy_checkcast_attempt_cnt:%d", _arraycopy_checkcast_attempt_cnt);
1600 
1601   tty->print_cr(" _new_type_array_slowcase_cnt:    %d", _new_type_array_slowcase_cnt);
1602   tty->print_cr(" _new_object_array_slowcase_cnt:  %d", _new_object_array_slowcase_cnt);
1603   tty->print_cr(" _new_flat_array_slowcase_cnt:    %d", _new_flat_array_slowcase_cnt);
1604   tty->print_cr(" _new_instance_slowcase_cnt:      %d", _new_instance_slowcase_cnt);
1605   tty->print_cr(" _new_multi_array_slowcase_cnt:   %d", _new_multi_array_slowcase_cnt);
1606   tty->print_cr(" _load_flattened_array_slowcase_cnt:   %d", _load_flattened_array_slowcase_cnt);
1607   tty->print_cr(" _store_flattened_array_slowcase_cnt:  %d", _store_flattened_array_slowcase_cnt);
1608   tty->print_cr(" _substitutability_check_slowcase_cnt: %d", _substitutability_check_slowcase_cnt);
1609   tty->print_cr(" _buffer_inline_args_slowcase_cnt:%d", _buffer_inline_args_slowcase_cnt);
1610   tty->print_cr(" _buffer_inline_args_no_receiver_slowcase_cnt:%d", _buffer_inline_args_no_receiver_slowcase_cnt);
1611 
1612   tty->print_cr(" _monitorenter_slowcase_cnt:      %d", _monitorenter_slowcase_cnt);
1613   tty->print_cr(" _monitorexit_slowcase_cnt:       %d", _monitorexit_slowcase_cnt);
1614   tty->print_cr(" _patch_code_slowcase_cnt:        %d", _patch_code_slowcase_cnt);
1615 
1616   tty->print_cr(" _throw_range_check_exception_count:            %d:", _throw_range_check_exception_count);
1617   tty->print_cr(" _throw_index_exception_count:                  %d:", _throw_index_exception_count);
1618   tty->print_cr(" _throw_div0_exception_count:                   %d:", _throw_div0_exception_count);
1619   tty->print_cr(" _throw_null_pointer_exception_count:           %d:", _throw_null_pointer_exception_count);
1620   tty->print_cr(" _throw_class_cast_exception_count:             %d:", _throw_class_cast_exception_count);
1621   tty->print_cr(" _throw_incompatible_class_change_error_count:  %d:", _throw_incompatible_class_change_error_count);
1622   tty->print_cr(" _throw_illegal_monitor_state_exception_count:  %d:", _throw_illegal_monitor_state_exception_count);
1623   tty->print_cr(" _throw_count:                                  %d:", _throw_count);
1624 
1625   SharedRuntime::print_ic_miss_histogram();
1626   tty->cr();
1627 }
1628 #endif // PRODUCT
< prev index next >