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

 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 = NULL;
 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 (UseHeavyMonitors) {
 758     lock->set_obj(obj);
 759   }
 760   assert(obj == lock->obj(), "must match");
 761   SharedRuntime::monitor_enter_helper(obj, lock->lock(), current);
 762 JRT_END
 763 
 764 
 765 JRT_LEAF(void, Runtime1::monitorexit(JavaThread* current, BasicObjectLock* lock))
 766 #ifndef PRODUCT
 767   if (PrintC1Statistics) {
 768     _monitorexit_slowcase_cnt++;
 769   }
 770 #endif

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

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

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





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




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

1507 #ifndef PRODUCT
1508 void Runtime1::print_statistics() {
1509   tty->print_cr("C1 Runtime statistics:");
1510   tty->print_cr(" _resolve_invoke_virtual_cnt:     %d", SharedRuntime::_resolve_virtual_ctr);
1511   tty->print_cr(" _resolve_invoke_opt_virtual_cnt: %d", SharedRuntime::_resolve_opt_virtual_ctr);
1512   tty->print_cr(" _resolve_invoke_static_cnt:      %d", SharedRuntime::_resolve_static_ctr);
1513   tty->print_cr(" _handle_wrong_method_cnt:        %d", SharedRuntime::_wrong_method_ctr);
1514   tty->print_cr(" _ic_miss_cnt:                    %d", SharedRuntime::_ic_miss_ctr);
1515   tty->print_cr(" _generic_arraycopystub_cnt:      %d", _generic_arraycopystub_cnt);
1516   tty->print_cr(" _byte_arraycopy_cnt:             %d", _byte_arraycopy_stub_cnt);
1517   tty->print_cr(" _short_arraycopy_cnt:            %d", _short_arraycopy_stub_cnt);
1518   tty->print_cr(" _int_arraycopy_cnt:              %d", _int_arraycopy_stub_cnt);
1519   tty->print_cr(" _long_arraycopy_cnt:             %d", _long_arraycopy_stub_cnt);
1520   tty->print_cr(" _oop_arraycopy_cnt:              %d", _oop_arraycopy_stub_cnt);
1521   tty->print_cr(" _arraycopy_slowcase_cnt:         %d", _arraycopy_slowcase_cnt);
1522   tty->print_cr(" _arraycopy_checkcast_cnt:        %d", _arraycopy_checkcast_cnt);
1523   tty->print_cr(" _arraycopy_checkcast_attempt_cnt:%d", _arraycopy_checkcast_attempt_cnt);
1524 
1525   tty->print_cr(" _new_type_array_slowcase_cnt:    %d", _new_type_array_slowcase_cnt);
1526   tty->print_cr(" _new_object_array_slowcase_cnt:  %d", _new_object_array_slowcase_cnt);

1527   tty->print_cr(" _new_instance_slowcase_cnt:      %d", _new_instance_slowcase_cnt);
1528   tty->print_cr(" _new_multi_array_slowcase_cnt:   %d", _new_multi_array_slowcase_cnt);






1529   tty->print_cr(" _monitorenter_slowcase_cnt:      %d", _monitorenter_slowcase_cnt);
1530   tty->print_cr(" _monitorexit_slowcase_cnt:       %d", _monitorexit_slowcase_cnt);
1531   tty->print_cr(" _patch_code_slowcase_cnt:        %d", _patch_code_slowcase_cnt);
1532 
1533   tty->print_cr(" _throw_range_check_exception_count:            %d:", _throw_range_check_exception_count);
1534   tty->print_cr(" _throw_index_exception_count:                  %d:", _throw_index_exception_count);
1535   tty->print_cr(" _throw_div0_exception_count:                   %d:", _throw_div0_exception_count);
1536   tty->print_cr(" _throw_null_pointer_exception_count:           %d:", _throw_null_pointer_exception_count);
1537   tty->print_cr(" _throw_class_cast_exception_count:             %d:", _throw_class_cast_exception_count);
1538   tty->print_cr(" _throw_incompatible_class_change_error_count:  %d:", _throw_incompatible_class_change_error_count);

1539   tty->print_cr(" _throw_count:                                  %d:", _throw_count);
1540 
1541   SharedRuntime::print_ic_miss_histogram();
1542   tty->cr();
1543 }
1544 #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;

 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 != NULL) {
 482     ProfileData* data = md->bci_to_data(bci);
 483     assert(data != NULL && 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_flattened_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_flattened_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_flattened_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_flattened_array_slowcase_cnt++;)
 507   if (value == NULL) {
 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::PrimitiveObjectMethods_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 = NULL;
 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 (UseHeavyMonitors) {
 887     lock->set_obj(obj);
 888   }
 889   assert(obj == lock->obj(), "must match");
 890   SharedRuntime::monitor_enter_helper(obj, lock->lock(), current);
 891 JRT_END
 892 
 893 
 894 JRT_LEAF(void, Runtime1::monitorexit(JavaThread* current, BasicObjectLock* lock))
 895 #ifndef PRODUCT
 896   if (PrintC1Statistics) {
 897     _monitorexit_slowcase_cnt++;
 898   }
 899 #endif

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

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

1646 #ifndef PRODUCT
1647 void Runtime1::print_statistics() {
1648   tty->print_cr("C1 Runtime statistics:");
1649   tty->print_cr(" _resolve_invoke_virtual_cnt:     %d", SharedRuntime::_resolve_virtual_ctr);
1650   tty->print_cr(" _resolve_invoke_opt_virtual_cnt: %d", SharedRuntime::_resolve_opt_virtual_ctr);
1651   tty->print_cr(" _resolve_invoke_static_cnt:      %d", SharedRuntime::_resolve_static_ctr);
1652   tty->print_cr(" _handle_wrong_method_cnt:        %d", SharedRuntime::_wrong_method_ctr);
1653   tty->print_cr(" _ic_miss_cnt:                    %d", SharedRuntime::_ic_miss_ctr);
1654   tty->print_cr(" _generic_arraycopystub_cnt:      %d", _generic_arraycopystub_cnt);
1655   tty->print_cr(" _byte_arraycopy_cnt:             %d", _byte_arraycopy_stub_cnt);
1656   tty->print_cr(" _short_arraycopy_cnt:            %d", _short_arraycopy_stub_cnt);
1657   tty->print_cr(" _int_arraycopy_cnt:              %d", _int_arraycopy_stub_cnt);
1658   tty->print_cr(" _long_arraycopy_cnt:             %d", _long_arraycopy_stub_cnt);
1659   tty->print_cr(" _oop_arraycopy_cnt:              %d", _oop_arraycopy_stub_cnt);
1660   tty->print_cr(" _arraycopy_slowcase_cnt:         %d", _arraycopy_slowcase_cnt);
1661   tty->print_cr(" _arraycopy_checkcast_cnt:        %d", _arraycopy_checkcast_cnt);
1662   tty->print_cr(" _arraycopy_checkcast_attempt_cnt:%d", _arraycopy_checkcast_attempt_cnt);
1663 
1664   tty->print_cr(" _new_type_array_slowcase_cnt:    %d", _new_type_array_slowcase_cnt);
1665   tty->print_cr(" _new_object_array_slowcase_cnt:  %d", _new_object_array_slowcase_cnt);
1666   tty->print_cr(" _new_flat_array_slowcase_cnt:    %d", _new_flat_array_slowcase_cnt);
1667   tty->print_cr(" _new_instance_slowcase_cnt:      %d", _new_instance_slowcase_cnt);
1668   tty->print_cr(" _new_multi_array_slowcase_cnt:   %d", _new_multi_array_slowcase_cnt);
1669   tty->print_cr(" _load_flattened_array_slowcase_cnt:   %d", _load_flattened_array_slowcase_cnt);
1670   tty->print_cr(" _store_flattened_array_slowcase_cnt:  %d", _store_flattened_array_slowcase_cnt);
1671   tty->print_cr(" _substitutability_check_slowcase_cnt: %d", _substitutability_check_slowcase_cnt);
1672   tty->print_cr(" _buffer_inline_args_slowcase_cnt:%d", _buffer_inline_args_slowcase_cnt);
1673   tty->print_cr(" _buffer_inline_args_no_receiver_slowcase_cnt:%d", _buffer_inline_args_no_receiver_slowcase_cnt);
1674 
1675   tty->print_cr(" _monitorenter_slowcase_cnt:      %d", _monitorenter_slowcase_cnt);
1676   tty->print_cr(" _monitorexit_slowcase_cnt:       %d", _monitorexit_slowcase_cnt);
1677   tty->print_cr(" _patch_code_slowcase_cnt:        %d", _patch_code_slowcase_cnt);
1678 
1679   tty->print_cr(" _throw_range_check_exception_count:            %d:", _throw_range_check_exception_count);
1680   tty->print_cr(" _throw_index_exception_count:                  %d:", _throw_index_exception_count);
1681   tty->print_cr(" _throw_div0_exception_count:                   %d:", _throw_div0_exception_count);
1682   tty->print_cr(" _throw_null_pointer_exception_count:           %d:", _throw_null_pointer_exception_count);
1683   tty->print_cr(" _throw_class_cast_exception_count:             %d:", _throw_class_cast_exception_count);
1684   tty->print_cr(" _throw_incompatible_class_change_error_count:  %d:", _throw_incompatible_class_change_error_count);
1685   tty->print_cr(" _throw_illegal_monitor_state_exception_count:  %d:", _throw_illegal_monitor_state_exception_count);
1686   tty->print_cr(" _throw_count:                                  %d:", _throw_count);
1687 
1688   SharedRuntime::print_ic_miss_histogram();
1689   tty->cr();
1690 }
1691 #endif // PRODUCT
< prev index next >