< prev index next >

src/hotspot/share/c1/c1_Runtime1.cpp

Print this page




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


  56 #include "runtime/atomic.hpp"
  57 #include "runtime/biasedLocking.hpp"
  58 #include "runtime/compilationPolicy.hpp"
  59 #include "runtime/fieldDescriptor.inline.hpp"
  60 #include "runtime/frame.inline.hpp"
  61 #include "runtime/handles.inline.hpp"
  62 #include "runtime/interfaceSupport.inline.hpp"
  63 #include "runtime/javaCalls.hpp"
  64 #include "runtime/sharedRuntime.hpp"
  65 #include "runtime/threadCritical.hpp"
  66 #include "runtime/vframe.inline.hpp"
  67 #include "runtime/vframeArray.hpp"
  68 #include "runtime/vm_version.hpp"
  69 #include "utilities/copy.hpp"
  70 #include "utilities/events.hpp"
  71 
  72 
  73 // Implementation of StubAssembler
  74 
  75 StubAssembler::StubAssembler(CodeBuffer* code, const char * name, int stub_id) : C1_MacroAssembler(code) {


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

 121 int Runtime1::_new_instance_slowcase_cnt = 0;
 122 int Runtime1::_new_multi_array_slowcase_cnt = 0;





 123 int Runtime1::_monitorenter_slowcase_cnt = 0;
 124 int Runtime1::_monitorexit_slowcase_cnt = 0;
 125 int Runtime1::_patch_code_slowcase_cnt = 0;
 126 int Runtime1::_throw_range_check_exception_count = 0;
 127 int Runtime1::_throw_index_exception_count = 0;
 128 int Runtime1::_throw_div0_exception_count = 0;
 129 int Runtime1::_throw_null_pointer_exception_count = 0;
 130 int Runtime1::_throw_class_cast_exception_count = 0;
 131 int Runtime1::_throw_incompatible_class_change_error_count = 0;

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


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






















 400 JRT_ENTRY(void, Runtime1::new_multi_array(JavaThread* thread, Klass* klass, int rank, jint* dims))
 401   NOT_PRODUCT(_new_multi_array_slowcase_cnt++;)
 402 
 403   assert(klass->is_klass(), "not a class");
 404   assert(rank >= 1, "rank must be nonzero");
 405   Handle holder(THREAD, klass->klass_holder()); // keep the klass alive
 406   oop obj = ArrayKlass::cast(klass)->multi_allocate(rank, dims, CHECK);
 407   thread->set_vm_result(obj);
 408 JRT_END
 409 
 410 










































































 411 JRT_ENTRY(void, Runtime1::unimplemented_entry(JavaThread* thread, StubID id))
 412   tty->print_cr("Runtime1::entry_for(%d) returned unimplemented entry point", id);
 413 JRT_END
 414 
 415 
 416 JRT_ENTRY(void, Runtime1::throw_array_store_exception(JavaThread* thread, oopDesc* obj))
 417   ResourceMark rm(thread);
 418   const char* klass_name = obj->klass()->external_name();
 419   SharedRuntime::throw_and_post_jvmti_exception(thread, vmSymbols::java_lang_ArrayStoreException(), klass_name);
 420 JRT_END
 421 
 422 
 423 // counter_overflow() is called from within C1-compiled methods. The enclosing method is the method
 424 // associated with the top activation record. The inlinee (that is possibly included in the enclosing
 425 // method) method oop is passed as an argument. In order to do that it is embedded in the code as
 426 // a constant.
 427 static nmethod* counter_overflow_helper(JavaThread* THREAD, int branch_bci, Method* m) {
 428   nmethod* osr_nm = NULL;
 429   methodHandle method(THREAD, m);
 430 


 676 JRT_END
 677 
 678 
 679 JRT_ENTRY(void, Runtime1::throw_class_cast_exception(JavaThread* thread, oopDesc* object))
 680   NOT_PRODUCT(_throw_class_cast_exception_count++;)
 681   ResourceMark rm(thread);
 682   char* message = SharedRuntime::generate_class_cast_message(
 683     thread, object->klass());
 684   SharedRuntime::throw_and_post_jvmti_exception(
 685     thread, vmSymbols::java_lang_ClassCastException(), message);
 686 JRT_END
 687 
 688 
 689 JRT_ENTRY(void, Runtime1::throw_incompatible_class_change_error(JavaThread* thread))
 690   NOT_PRODUCT(_throw_incompatible_class_change_error_count++;)
 691   ResourceMark rm(thread);
 692   SharedRuntime::throw_and_post_jvmti_exception(thread, vmSymbols::java_lang_IncompatibleClassChangeError());
 693 JRT_END
 694 
 695 







 696 JRT_ENTRY_NO_ASYNC(void, Runtime1::monitorenter(JavaThread* thread, oopDesc* obj, BasicObjectLock* lock))
 697   NOT_PRODUCT(_monitorenter_slowcase_cnt++;)
 698   if (PrintBiasedLockingStatistics) {
 699     Atomic::inc(BiasedLocking::slow_path_entry_count_addr());
 700   }
 701   Handle h_obj(thread, obj);
 702   if (UseBiasedLocking) {
 703     // Retry fast entry if bias is revoked to avoid unnecessary inflation
 704     ObjectSynchronizer::fast_enter(h_obj, lock->lock(), true, CHECK);
 705   } else {
 706     if (UseFastLocking) {
 707       // When using fast locking, the compiled code has already tried the fast case
 708       assert(obj == lock->obj(), "must match");
 709       ObjectSynchronizer::slow_enter(h_obj, lock->lock(), THREAD);
 710     } else {
 711       lock->set_obj(obj);
 712       ObjectSynchronizer::fast_enter(h_obj, lock->lock(), false, THREAD);
 713     }
 714   }
 715 JRT_END


 941     // accesses.
 942 
 943     patch_field_type = result.field_type();
 944     deoptimize_for_atomic = (AlwaysAtomicAccesses && (patch_field_type == T_DOUBLE || patch_field_type == T_LONG));
 945 
 946   } else if (load_klass_or_mirror_patch_id) {
 947     Klass* k = NULL;
 948     switch (code) {
 949       case Bytecodes::_putstatic:
 950       case Bytecodes::_getstatic:
 951         { Klass* klass = resolve_field_return_klass(caller_method, bci, CHECK);
 952           init_klass = klass;
 953           mirror = Handle(THREAD, klass->java_mirror());
 954         }
 955         break;
 956       case Bytecodes::_new:
 957         { Bytecode_new bnew(caller_method(), caller_method->bcp_from(bci));
 958           k = caller_method->constants()->klass_at(bnew.index(), CHECK);
 959         }
 960         break;





 961       case Bytecodes::_multianewarray:
 962         { Bytecode_multianewarray mna(caller_method(), caller_method->bcp_from(bci));
 963           k = caller_method->constants()->klass_at(mna.index(), CHECK);




 964         }
 965         break;
 966       case Bytecodes::_instanceof:
 967         { Bytecode_instanceof io(caller_method(), caller_method->bcp_from(bci));
 968           k = caller_method->constants()->klass_at(io.index(), CHECK);
 969         }
 970         break;
 971       case Bytecodes::_checkcast:
 972         { Bytecode_checkcast cc(caller_method(), caller_method->bcp_from(bci));
 973           k = caller_method->constants()->klass_at(cc.index(), CHECK);
 974         }
 975         break;
 976       case Bytecodes::_anewarray:
 977         { Bytecode_anewarray anew(caller_method(), caller_method->bcp_from(bci));
 978           Klass* ek = caller_method->constants()->klass_at(anew.index(), CHECK);
 979           k = ek->array_klass(CHECK);





 980         }
 981         break;
 982       case Bytecodes::_ldc:
 983       case Bytecodes::_ldc_w:
 984         {
 985           Bytecode_loadconstant cc(caller_method, bci);
 986           oop m = cc.resolve_constant(CHECK);
 987           mirror = Handle(THREAD, m);
 988         }
 989         break;
 990       default: fatal("unexpected bytecode for load_klass_or_mirror_patch_id");
 991     }
 992     load_klass = k;
 993   } else if (stub_id == load_appendix_patching_id) {
 994     Bytecode_invoke bytecode(caller_method, bci);
 995     Bytecodes::Code bc = bytecode.invoke_code();
 996 
 997     CallInfo info;
 998     constantPoolHandle pool(thread, caller_method->constants());
 999     int index = bytecode.index();


1465 void Runtime1::print_statistics() {
1466   tty->print_cr("C1 Runtime statistics:");
1467   tty->print_cr(" _resolve_invoke_virtual_cnt:     %d", SharedRuntime::_resolve_virtual_ctr);
1468   tty->print_cr(" _resolve_invoke_opt_virtual_cnt: %d", SharedRuntime::_resolve_opt_virtual_ctr);
1469   tty->print_cr(" _resolve_invoke_static_cnt:      %d", SharedRuntime::_resolve_static_ctr);
1470   tty->print_cr(" _handle_wrong_method_cnt:        %d", SharedRuntime::_wrong_method_ctr);
1471   tty->print_cr(" _ic_miss_cnt:                    %d", SharedRuntime::_ic_miss_ctr);
1472   tty->print_cr(" _generic_arraycopy_cnt:          %d", _generic_arraycopy_cnt);
1473   tty->print_cr(" _generic_arraycopystub_cnt:      %d", _generic_arraycopystub_cnt);
1474   tty->print_cr(" _byte_arraycopy_cnt:             %d", _byte_arraycopy_stub_cnt);
1475   tty->print_cr(" _short_arraycopy_cnt:            %d", _short_arraycopy_stub_cnt);
1476   tty->print_cr(" _int_arraycopy_cnt:              %d", _int_arraycopy_stub_cnt);
1477   tty->print_cr(" _long_arraycopy_cnt:             %d", _long_arraycopy_stub_cnt);
1478   tty->print_cr(" _oop_arraycopy_cnt:              %d", _oop_arraycopy_stub_cnt);
1479   tty->print_cr(" _arraycopy_slowcase_cnt:         %d", _arraycopy_slowcase_cnt);
1480   tty->print_cr(" _arraycopy_checkcast_cnt:        %d", _arraycopy_checkcast_cnt);
1481   tty->print_cr(" _arraycopy_checkcast_attempt_cnt:%d", _arraycopy_checkcast_attempt_cnt);
1482 
1483   tty->print_cr(" _new_type_array_slowcase_cnt:    %d", _new_type_array_slowcase_cnt);
1484   tty->print_cr(" _new_object_array_slowcase_cnt:  %d", _new_object_array_slowcase_cnt);

1485   tty->print_cr(" _new_instance_slowcase_cnt:      %d", _new_instance_slowcase_cnt);
1486   tty->print_cr(" _new_multi_array_slowcase_cnt:   %d", _new_multi_array_slowcase_cnt);






1487   tty->print_cr(" _monitorenter_slowcase_cnt:      %d", _monitorenter_slowcase_cnt);
1488   tty->print_cr(" _monitorexit_slowcase_cnt:       %d", _monitorexit_slowcase_cnt);
1489   tty->print_cr(" _patch_code_slowcase_cnt:        %d", _patch_code_slowcase_cnt);
1490 
1491   tty->print_cr(" _throw_range_check_exception_count:            %d:", _throw_range_check_exception_count);
1492   tty->print_cr(" _throw_index_exception_count:                  %d:", _throw_index_exception_count);
1493   tty->print_cr(" _throw_div0_exception_count:                   %d:", _throw_div0_exception_count);
1494   tty->print_cr(" _throw_null_pointer_exception_count:           %d:", _throw_null_pointer_exception_count);
1495   tty->print_cr(" _throw_class_cast_exception_count:             %d:", _throw_class_cast_exception_count);
1496   tty->print_cr(" _throw_incompatible_class_change_error_count:  %d:", _throw_incompatible_class_change_error_count);

1497   tty->print_cr(" _throw_array_store_exception_count:            %d:", _throw_array_store_exception_count);
1498   tty->print_cr(" _throw_count:                                  %d:", _throw_count);
1499 
1500   SharedRuntime::print_ic_miss_histogram();
1501   tty->cr();
1502 }
1503 #endif // PRODUCT


  36 #include "code/compiledIC.hpp"
  37 #include "code/pcDesc.hpp"
  38 #include "code/scopeDesc.hpp"
  39 #include "code/vtableStubs.hpp"
  40 #include "compiler/disassembler.hpp"
  41 #include "gc/shared/barrierSet.hpp"
  42 #include "gc/shared/c1/barrierSetC1.hpp"
  43 #include "gc/shared/collectedHeap.hpp"
  44 #include "interpreter/bytecode.hpp"
  45 #include "interpreter/interpreter.hpp"
  46 #include "jfr/support/jfrIntrinsics.hpp"
  47 #include "logging/log.hpp"
  48 #include "memory/allocation.inline.hpp"
  49 #include "memory/oopFactory.hpp"
  50 #include "memory/resourceArea.hpp"
  51 #include "memory/universe.hpp"
  52 #include "oops/access.inline.hpp"
  53 #include "oops/objArrayOop.inline.hpp"
  54 #include "oops/objArrayKlass.hpp"
  55 #include "oops/oop.inline.hpp"
  56 #include "oops/valueArrayKlass.hpp"
  57 #include "oops/valueArrayOop.inline.hpp"
  58 #include "runtime/atomic.hpp"
  59 #include "runtime/biasedLocking.hpp"
  60 #include "runtime/compilationPolicy.hpp"
  61 #include "runtime/fieldDescriptor.inline.hpp"
  62 #include "runtime/frame.inline.hpp"
  63 #include "runtime/handles.inline.hpp"
  64 #include "runtime/interfaceSupport.inline.hpp"
  65 #include "runtime/javaCalls.hpp"
  66 #include "runtime/sharedRuntime.hpp"
  67 #include "runtime/threadCritical.hpp"
  68 #include "runtime/vframe.inline.hpp"
  69 #include "runtime/vframeArray.hpp"
  70 #include "runtime/vm_version.hpp"
  71 #include "utilities/copy.hpp"
  72 #include "utilities/events.hpp"
  73 
  74 
  75 // Implementation of StubAssembler
  76 
  77 StubAssembler::StubAssembler(CodeBuffer* code, const char * name, int stub_id) : C1_MacroAssembler(code) {


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


 378   BasicType elt_type = TypeArrayKlass::cast(klass)->element_type();
 379   oop obj = oopFactory::new_typeArray(elt_type, length, CHECK);
 380   thread->set_vm_result(obj);
 381   // This is pretty rare but this runtime patch is stressful to deoptimization
 382   // if we deoptimize here so force a deopt to stress the path.
 383   if (DeoptimizeALot) {
 384     deopt_caller();
 385   }
 386 
 387 JRT_END
 388 
 389 
 390 JRT_ENTRY(void, Runtime1::new_object_array(JavaThread* thread, Klass* array_klass, jint length))
 391   NOT_PRODUCT(_new_object_array_slowcase_cnt++;)
 392 
 393   // Note: no handle for klass needed since they are not used
 394   //       anymore after new_objArray() and no GC can happen before.
 395   //       (This may have to change if this code changes!)
 396   assert(array_klass->is_klass(), "not a class");
 397   Handle holder(THREAD, array_klass->klass_holder()); // keep the klass alive
 398   Klass* elem_klass = ArrayKlass::cast(array_klass)->element_klass();
 399   objArrayOop obj = oopFactory::new_objArray(elem_klass, length, CHECK);
 400   thread->set_vm_result(obj);
 401   // This is pretty rare but this runtime patch is stressful to deoptimization
 402   // if we deoptimize here so force a deopt to stress the path.
 403   if (DeoptimizeALot) {
 404     deopt_caller();
 405   }
 406 JRT_END
 407 
 408 
 409 JRT_ENTRY(void, Runtime1::new_value_array(JavaThread* thread, Klass* array_klass, jint length))
 410   NOT_PRODUCT(_new_value_array_slowcase_cnt++;)
 411 
 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(THREAD, array_klass->klass_holder()); // keep the klass alive
 417   Klass* elem_klass = ArrayKlass::cast(array_klass)->element_klass();
 418   assert(elem_klass->is_value(), "must be");
 419   // Logically creates elements, ensure klass init
 420   elem_klass->initialize(CHECK);
 421   arrayOop obj = oopFactory::new_valueArray(elem_klass, length, CHECK);
 422   thread->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();
 427   }
 428 JRT_END
 429 
 430 
 431 JRT_ENTRY(void, Runtime1::new_multi_array(JavaThread* thread, Klass* klass, int rank, jint* dims))
 432   NOT_PRODUCT(_new_multi_array_slowcase_cnt++;)
 433 
 434   assert(klass->is_klass(), "not a class");
 435   assert(rank >= 1, "rank must be nonzero");
 436   Handle holder(THREAD, klass->klass_holder()); // keep the klass alive
 437   oop obj = ArrayKlass::cast(klass)->multi_allocate(rank, dims, CHECK);
 438   thread->set_vm_result(obj);
 439 JRT_END
 440 
 441 
 442 JRT_ENTRY(void, Runtime1::load_flattened_array(JavaThread* thread, valueArrayOopDesc* array, int index))
 443   NOT_PRODUCT(_load_flattened_array_slowcase_cnt++;)
 444   Klass* klass = array->klass();
 445   assert(klass->is_valueArray_klass(), "expected value array oop");
 446   assert(array->length() > 0 && index < array->length(), "already checked");
 447 
 448   ValueArrayKlass* vaklass = ValueArrayKlass::cast(klass);
 449   ValueKlass* vklass = vaklass->element_klass();
 450 
 451   // We have a non-empty flattened array, so the element type must have been initialized.
 452   assert(vklass->is_initialized(), "must be");
 453   Handle holder(THREAD, vklass->klass_holder()); // keep the vklass alive
 454   valueArrayHandle ha(THREAD, array);
 455   oop obj = vklass->allocate_instance(CHECK);
 456 
 457   void* src = ha()->value_at_addr(index, vaklass->layout_helper());
 458   vklass->value_store(src, vklass->data_for_oop(obj),
 459                       vaklass->element_byte_size(), true, false);
 460   thread->set_vm_result(obj);
 461 JRT_END
 462 
 463 
 464 JRT_ENTRY(void, Runtime1::store_flattened_array(JavaThread* thread, valueArrayOopDesc* array, int index, oopDesc* value))
 465   NOT_PRODUCT(_store_flattened_array_slowcase_cnt++;)
 466   if (value == NULL) {
 467     SharedRuntime::throw_and_post_jvmti_exception(thread, vmSymbols::java_lang_NullPointerException());
 468   } else {
 469     Klass* klass = array->klass();
 470     assert(klass->is_valueArray_klass(), "expected value array");
 471     assert(ArrayKlass::cast(klass)->element_klass() == value->klass(), "Store type incorrect");
 472 
 473     ValueArrayKlass* vaklass = ValueArrayKlass::cast(klass);
 474     ValueKlass* vklass = vaklass->element_klass();
 475     const int lh = vaklass->layout_helper();
 476     vklass->value_store(vklass->data_for_oop(value), array->value_at_addr(index, lh),
 477                         vaklass->element_byte_size(), true, false);
 478   }
 479 JRT_END
 480 
 481 
 482 JRT_ENTRY(int, Runtime1::substitutability_check(JavaThread* thread, oopDesc* left, oopDesc* right))
 483   NOT_PRODUCT(_substitutability_check_slowcase_cnt++;)
 484   JavaCallArguments args;
 485   args.push_oop(Handle(THREAD, left));
 486   args.push_oop(Handle(THREAD, right));
 487   JavaValue result(T_BOOLEAN);
 488   JavaCalls::call_static(&result,
 489                          SystemDictionary::ValueBootstrapMethods_klass(),
 490                          vmSymbols::isSubstitutable_name(),
 491                          vmSymbols::object_object_boolean_signature(),
 492                          &args, CHECK_0);
 493   return result.get_jboolean() ? 1 : 0;
 494 JRT_END
 495 
 496 
 497 extern "C" void ps();
 498 
 499 void Runtime1::buffer_value_args_impl(JavaThread* thread, Method* m, bool allocate_receiver) {
 500   Thread* THREAD = thread;
 501   methodHandle method(m); // We are inside the verified_entry or verified_value_ro_entry of this method.
 502   oop obj = SharedRuntime::allocate_value_types_impl(thread, method, allocate_receiver, CHECK);
 503   thread->set_vm_result(obj);
 504 }
 505 
 506 JRT_ENTRY(void, Runtime1::buffer_value_args(JavaThread* thread, Method* method))
 507   NOT_PRODUCT(_buffer_value_args_slowcase_cnt++;)
 508   buffer_value_args_impl(thread, method, true);
 509 JRT_END
 510 
 511 JRT_ENTRY(void, Runtime1::buffer_value_args_no_receiver(JavaThread* thread, Method* method))
 512   NOT_PRODUCT(_buffer_value_args_no_receiver_slowcase_cnt++;)
 513   buffer_value_args_impl(thread, method, false);
 514 JRT_END
 515 
 516 JRT_ENTRY(void, Runtime1::unimplemented_entry(JavaThread* thread, StubID id))
 517   tty->print_cr("Runtime1::entry_for(%d) returned unimplemented entry point", id);
 518 JRT_END
 519 
 520 
 521 JRT_ENTRY(void, Runtime1::throw_array_store_exception(JavaThread* thread, oopDesc* obj))
 522   ResourceMark rm(thread);
 523   const char* klass_name = obj->klass()->external_name();
 524   SharedRuntime::throw_and_post_jvmti_exception(thread, vmSymbols::java_lang_ArrayStoreException(), klass_name);
 525 JRT_END
 526 
 527 
 528 // counter_overflow() is called from within C1-compiled methods. The enclosing method is the method
 529 // associated with the top activation record. The inlinee (that is possibly included in the enclosing
 530 // method) method oop is passed as an argument. In order to do that it is embedded in the code as
 531 // a constant.
 532 static nmethod* counter_overflow_helper(JavaThread* THREAD, int branch_bci, Method* m) {
 533   nmethod* osr_nm = NULL;
 534   methodHandle method(THREAD, m);
 535 


 781 JRT_END
 782 
 783 
 784 JRT_ENTRY(void, Runtime1::throw_class_cast_exception(JavaThread* thread, oopDesc* object))
 785   NOT_PRODUCT(_throw_class_cast_exception_count++;)
 786   ResourceMark rm(thread);
 787   char* message = SharedRuntime::generate_class_cast_message(
 788     thread, object->klass());
 789   SharedRuntime::throw_and_post_jvmti_exception(
 790     thread, vmSymbols::java_lang_ClassCastException(), message);
 791 JRT_END
 792 
 793 
 794 JRT_ENTRY(void, Runtime1::throw_incompatible_class_change_error(JavaThread* thread))
 795   NOT_PRODUCT(_throw_incompatible_class_change_error_count++;)
 796   ResourceMark rm(thread);
 797   SharedRuntime::throw_and_post_jvmti_exception(thread, vmSymbols::java_lang_IncompatibleClassChangeError());
 798 JRT_END
 799 
 800 
 801 JRT_ENTRY(void, Runtime1::throw_illegal_monitor_state_exception(JavaThread* thread))
 802   NOT_PRODUCT(_throw_illegal_monitor_state_exception_count++;)
 803   ResourceMark rm(thread);
 804   SharedRuntime::throw_and_post_jvmti_exception(thread, vmSymbols::java_lang_IllegalMonitorStateException());
 805 JRT_END
 806 
 807 
 808 JRT_ENTRY_NO_ASYNC(void, Runtime1::monitorenter(JavaThread* thread, oopDesc* obj, BasicObjectLock* lock))
 809   NOT_PRODUCT(_monitorenter_slowcase_cnt++;)
 810   if (PrintBiasedLockingStatistics) {
 811     Atomic::inc(BiasedLocking::slow_path_entry_count_addr());
 812   }
 813   Handle h_obj(thread, obj);
 814   if (UseBiasedLocking) {
 815     // Retry fast entry if bias is revoked to avoid unnecessary inflation
 816     ObjectSynchronizer::fast_enter(h_obj, lock->lock(), true, CHECK);
 817   } else {
 818     if (UseFastLocking) {
 819       // When using fast locking, the compiled code has already tried the fast case
 820       assert(obj == lock->obj(), "must match");
 821       ObjectSynchronizer::slow_enter(h_obj, lock->lock(), THREAD);
 822     } else {
 823       lock->set_obj(obj);
 824       ObjectSynchronizer::fast_enter(h_obj, lock->lock(), false, THREAD);
 825     }
 826   }
 827 JRT_END


1053     // accesses.
1054 
1055     patch_field_type = result.field_type();
1056     deoptimize_for_atomic = (AlwaysAtomicAccesses && (patch_field_type == T_DOUBLE || patch_field_type == T_LONG));
1057 
1058   } else if (load_klass_or_mirror_patch_id) {
1059     Klass* k = NULL;
1060     switch (code) {
1061       case Bytecodes::_putstatic:
1062       case Bytecodes::_getstatic:
1063         { Klass* klass = resolve_field_return_klass(caller_method, bci, CHECK);
1064           init_klass = klass;
1065           mirror = Handle(THREAD, klass->java_mirror());
1066         }
1067         break;
1068       case Bytecodes::_new:
1069         { Bytecode_new bnew(caller_method(), caller_method->bcp_from(bci));
1070           k = caller_method->constants()->klass_at(bnew.index(), CHECK);
1071         }
1072         break;
1073       case Bytecodes::_defaultvalue:
1074         { Bytecode_defaultvalue bdefaultvalue(caller_method(), caller_method->bcp_from(bci));
1075           k = caller_method->constants()->klass_at(bdefaultvalue.index(), CHECK);
1076         }
1077         break;
1078       case Bytecodes::_multianewarray:
1079         { Bytecode_multianewarray mna(caller_method(), caller_method->bcp_from(bci));
1080           k = caller_method->constants()->klass_at(mna.index(), CHECK);
1081           if (k->name()->is_Q_array_signature()) {
1082             // Logically creates elements, ensure klass init
1083             k->initialize(CHECK);
1084           }
1085         }
1086         break;
1087       case Bytecodes::_instanceof:
1088         { Bytecode_instanceof io(caller_method(), caller_method->bcp_from(bci));
1089           k = caller_method->constants()->klass_at(io.index(), CHECK);
1090         }
1091         break;
1092       case Bytecodes::_checkcast:
1093         { Bytecode_checkcast cc(caller_method(), caller_method->bcp_from(bci));
1094           k = caller_method->constants()->klass_at(cc.index(), CHECK);
1095         }
1096         break;
1097       case Bytecodes::_anewarray:
1098         { Bytecode_anewarray anew(caller_method(), caller_method->bcp_from(bci));
1099           Klass* ek = caller_method->constants()->klass_at(anew.index(), CHECK);
1100           if (ek->is_value() && caller_method->constants()->klass_at_noresolve(anew.index())->is_Q_signature()) {
1101             k = ek->array_klass(ArrayStorageProperties::flattened_and_null_free, 1, CHECK);
1102             assert(ArrayKlass::cast(k)->storage_properties().is_null_free(), "Expect a null-free array class here");
1103           } else {
1104             k = ek->array_klass(CHECK);
1105           }
1106         }
1107         break;
1108       case Bytecodes::_ldc:
1109       case Bytecodes::_ldc_w:
1110         {
1111           Bytecode_loadconstant cc(caller_method, bci);
1112           oop m = cc.resolve_constant(CHECK);
1113           mirror = Handle(THREAD, m);
1114         }
1115         break;
1116       default: fatal("unexpected bytecode for load_klass_or_mirror_patch_id");
1117     }
1118     load_klass = k;
1119   } else if (stub_id == load_appendix_patching_id) {
1120     Bytecode_invoke bytecode(caller_method, bci);
1121     Bytecodes::Code bc = bytecode.invoke_code();
1122 
1123     CallInfo info;
1124     constantPoolHandle pool(thread, caller_method->constants());
1125     int index = bytecode.index();


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