< prev index next >

src/share/vm/opto/runtime.cpp

Print this page




  84 
  85 
  86 
  87 
  88 // Compiled code entry points
  89 address OptoRuntime::_new_instance_Java                           = NULL;
  90 address OptoRuntime::_new_array_Java                              = NULL;
  91 address OptoRuntime::_new_array_nozero_Java                       = NULL;
  92 address OptoRuntime::_multianewarray2_Java                        = NULL;
  93 address OptoRuntime::_multianewarray3_Java                        = NULL;
  94 address OptoRuntime::_multianewarray4_Java                        = NULL;
  95 address OptoRuntime::_multianewarray5_Java                        = NULL;
  96 address OptoRuntime::_multianewarrayN_Java                        = NULL;
  97 address OptoRuntime::_g1_wb_pre_Java                              = NULL;
  98 address OptoRuntime::_g1_wb_post_Java                             = NULL;
  99 address OptoRuntime::_vtable_must_compile_Java                    = NULL;
 100 address OptoRuntime::_complete_monitor_locking_Java               = NULL;
 101 address OptoRuntime::_monitor_notify_Java                         = NULL;
 102 address OptoRuntime::_monitor_notifyAll_Java                      = NULL;
 103 address OptoRuntime::_rethrow_Java                                = NULL;

 104 
 105 address OptoRuntime::_slow_arraycopy_Java                         = NULL;
 106 address OptoRuntime::_register_finalizer_Java                     = NULL;
 107 
 108 ExceptionBlob* OptoRuntime::_exception_blob;
 109 
 110 // This should be called in an assertion at the start of OptoRuntime routines
 111 // which are entered from compiled code (all of them)
 112 #ifdef ASSERT
 113 static bool check_compiled_frame(JavaThread* thread) {
 114   assert(thread->last_frame().is_runtime_frame(), "cannot call runtime directly from compiled code");
 115   RegisterMap map(thread, false);
 116   frame caller = thread->last_frame().sender(&map);
 117   assert(caller.is_compiled_frame(), "not being called from compiled like code");
 118   return true;
 119 }
 120 #endif // ASSERT
 121 
 122 
 123 #define gen(env, var, type_func_gen, c_func, fancy_jump, pass_tls, save_arg_regs, return_pc) \


 129   generate_exception_blob();
 130 
 131   // Note: tls: Means fetching the return oop out of the thread-local storage
 132   //
 133   //   variable/name                       type-function-gen              , runtime method                  ,fncy_jp, tls,save_args,retpc
 134   // -------------------------------------------------------------------------------------------------------------------------------
 135   gen(env, _new_instance_Java              , new_instance_Type            , new_instance_C                  ,    0 , true , false, false);
 136   gen(env, _new_array_Java                 , new_array_Type               , new_array_C                     ,    0 , true , false, false);
 137   gen(env, _new_array_nozero_Java          , new_array_Type               , new_array_nozero_C              ,    0 , true , false, false);
 138   gen(env, _multianewarray2_Java           , multianewarray2_Type         , multianewarray2_C               ,    0 , true , false, false);
 139   gen(env, _multianewarray3_Java           , multianewarray3_Type         , multianewarray3_C               ,    0 , true , false, false);
 140   gen(env, _multianewarray4_Java           , multianewarray4_Type         , multianewarray4_C               ,    0 , true , false, false);
 141   gen(env, _multianewarray5_Java           , multianewarray5_Type         , multianewarray5_C               ,    0 , true , false, false);
 142   gen(env, _multianewarrayN_Java           , multianewarrayN_Type         , multianewarrayN_C               ,    0 , true , false, false);
 143   gen(env, _g1_wb_pre_Java                 , g1_wb_pre_Type               , SharedRuntime::g1_wb_pre        ,    0 , false, false, false);
 144   gen(env, _g1_wb_post_Java                , g1_wb_post_Type              , SharedRuntime::g1_wb_post       ,    0 , false, false, false);
 145   gen(env, _complete_monitor_locking_Java  , complete_monitor_enter_Type  , SharedRuntime::complete_monitor_locking_C, 0, false, false, false);
 146   gen(env, _monitor_notify_Java            , monitor_notify_Type          , monitor_notify_C                ,    0 , false, false, false);
 147   gen(env, _monitor_notifyAll_Java         , monitor_notify_Type          , monitor_notifyAll_C             ,    0 , false, false, false);
 148   gen(env, _rethrow_Java                   , rethrow_Type                 , rethrow_C                       ,    2 , true , false, true );

 149 
 150   gen(env, _slow_arraycopy_Java            , slow_arraycopy_Type          , SharedRuntime::slow_arraycopy_C ,    0 , false, false, false);
 151   gen(env, _register_finalizer_Java        , register_finalizer_Type      , register_finalizer              ,    0 , false, false, false);
 152 
 153   return true;
 154 }
 155 
 156 #undef gen
 157 
 158 
 159 // Helper method to do generation of RunTimeStub's
 160 address OptoRuntime::generate_stub( ciEnv* env,
 161                                     TypeFunc_generator gen, address C_function,
 162                                     const char *name, int is_fancy_jump,
 163                                     bool pass_tls,
 164                                     bool save_argument_registers,
 165                                     bool return_pc) {
 166 
 167   // Matching the default directive, we currently have no method to match.
 168   DirectiveSet* directive = DirectivesStack::getDefaultDirective(CompileBroker::compiler(CompLevel_full_optimization));


 411 JRT_END
 412 
 413 JRT_ENTRY(void, OptoRuntime::multianewarrayN_C(Klass* elem_type, arrayOopDesc* dims, JavaThread *thread))
 414   assert(check_compiled_frame(thread), "incorrect caller");
 415   assert(elem_type->is_klass(), "not a class");
 416   assert(oop(dims)->is_typeArray(), "not an array");
 417 
 418   ResourceMark rm;
 419   jint len = dims->length();
 420   assert(len > 0, "Dimensions array should contain data");
 421   jint *j_dims = typeArrayOop(dims)->int_at_addr(0);
 422   jint *c_dims = NEW_RESOURCE_ARRAY(jint, len);
 423   Copy::conjoint_jints_atomic(j_dims, c_dims, len);
 424 
 425   Handle holder(THREAD, elem_type->klass_holder()); // keep the klass alive
 426   oop obj = ArrayKlass::cast(elem_type)->multi_allocate(len, c_dims, THREAD);
 427   deoptimize_caller_frame(thread, HAS_PENDING_EXCEPTION);
 428   thread->set_vm_result(obj);
 429 JRT_END
 430 




 431 JRT_BLOCK_ENTRY(void, OptoRuntime::monitor_notify_C(oopDesc* obj, JavaThread *thread))
 432 
 433   // Very few notify/notifyAll operations find any threads on the waitset, so
 434   // the dominant fast-path is to simply return.
 435   // Relatedly, it's critical that notify/notifyAll be fast in order to
 436   // reduce lock hold times.
 437   if (!SafepointSynchronize::is_synchronizing()) {
 438     if (ObjectSynchronizer::quick_notify(obj, thread, false)) {
 439       return;
 440     }
 441   }
 442 
 443   // This is the case the fast-path above isn't provisioned to handle.
 444   // The fast-path is designed to handle frequently arising cases in an efficient manner.
 445   // (The fast-path is just a degenerate variant of the slow-path).
 446   // Perform the dreaded state transition and pass control into the slow-path.
 447   JRT_BLOCK;
 448   Handle h_obj(THREAD, obj);
 449   ObjectSynchronizer::notify(h_obj, CHECK);
 450   JRT_BLOCK_END;


 578 
 579 const TypeFunc *OptoRuntime::g1_wb_post_Type() {
 580 
 581   const Type **fields = TypeTuple::fields(2);
 582   fields[TypeFunc::Parms+0] = TypeRawPtr::NOTNULL;  // Card addr
 583   fields[TypeFunc::Parms+1] = TypeRawPtr::NOTNULL;  // thread
 584   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields);
 585 
 586   // create result type (range)
 587   fields = TypeTuple::fields(0);
 588   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms, fields);
 589 
 590   return TypeFunc::make(domain, range);
 591 }
 592 
 593 const TypeFunc *OptoRuntime::uncommon_trap_Type() {
 594   // create input type (domain)
 595   const Type **fields = TypeTuple::fields(1);
 596   fields[TypeFunc::Parms+0] = TypeInt::INT; // trap_reason (deopt reason and action)
 597   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1, fields);














 598 
 599   // create result type (range)
 600   fields = TypeTuple::fields(0);
 601   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0, fields);
 602 
 603   return TypeFunc::make(domain, range);
 604 }
 605 
 606 //-----------------------------------------------------------------------------
 607 // Monitor Handling
 608 const TypeFunc *OptoRuntime::complete_monitor_enter_Type() {
 609   // create input type (domain)
 610   const Type **fields = TypeTuple::fields(2);
 611   fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL;  // Object to be Locked
 612   fields[TypeFunc::Parms+1] = TypeRawPtr::BOTTOM;   // Address of stack location for lock
 613   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2,fields);
 614 
 615   // create result type (range)
 616   fields = TypeTuple::fields(0);
 617 




  84 
  85 
  86 
  87 
  88 // Compiled code entry points
  89 address OptoRuntime::_new_instance_Java                           = NULL;
  90 address OptoRuntime::_new_array_Java                              = NULL;
  91 address OptoRuntime::_new_array_nozero_Java                       = NULL;
  92 address OptoRuntime::_multianewarray2_Java                        = NULL;
  93 address OptoRuntime::_multianewarray3_Java                        = NULL;
  94 address OptoRuntime::_multianewarray4_Java                        = NULL;
  95 address OptoRuntime::_multianewarray5_Java                        = NULL;
  96 address OptoRuntime::_multianewarrayN_Java                        = NULL;
  97 address OptoRuntime::_g1_wb_pre_Java                              = NULL;
  98 address OptoRuntime::_g1_wb_post_Java                             = NULL;
  99 address OptoRuntime::_vtable_must_compile_Java                    = NULL;
 100 address OptoRuntime::_complete_monitor_locking_Java               = NULL;
 101 address OptoRuntime::_monitor_notify_Java                         = NULL;
 102 address OptoRuntime::_monitor_notifyAll_Java                      = NULL;
 103 address OptoRuntime::_rethrow_Java                                = NULL;
 104 address OptoRuntime::_array_out_of_bounds_Java                    = NULL;
 105 
 106 address OptoRuntime::_slow_arraycopy_Java                         = NULL;
 107 address OptoRuntime::_register_finalizer_Java                     = NULL;
 108 
 109 ExceptionBlob* OptoRuntime::_exception_blob;
 110 
 111 // This should be called in an assertion at the start of OptoRuntime routines
 112 // which are entered from compiled code (all of them)
 113 #ifdef ASSERT
 114 static bool check_compiled_frame(JavaThread* thread) {
 115   assert(thread->last_frame().is_runtime_frame(), "cannot call runtime directly from compiled code");
 116   RegisterMap map(thread, false);
 117   frame caller = thread->last_frame().sender(&map);
 118   assert(caller.is_compiled_frame(), "not being called from compiled like code");
 119   return true;
 120 }
 121 #endif // ASSERT
 122 
 123 
 124 #define gen(env, var, type_func_gen, c_func, fancy_jump, pass_tls, save_arg_regs, return_pc) \


 130   generate_exception_blob();
 131 
 132   // Note: tls: Means fetching the return oop out of the thread-local storage
 133   //
 134   //   variable/name                       type-function-gen              , runtime method                  ,fncy_jp, tls,save_args,retpc
 135   // -------------------------------------------------------------------------------------------------------------------------------
 136   gen(env, _new_instance_Java              , new_instance_Type            , new_instance_C                  ,    0 , true , false, false);
 137   gen(env, _new_array_Java                 , new_array_Type               , new_array_C                     ,    0 , true , false, false);
 138   gen(env, _new_array_nozero_Java          , new_array_Type               , new_array_nozero_C              ,    0 , true , false, false);
 139   gen(env, _multianewarray2_Java           , multianewarray2_Type         , multianewarray2_C               ,    0 , true , false, false);
 140   gen(env, _multianewarray3_Java           , multianewarray3_Type         , multianewarray3_C               ,    0 , true , false, false);
 141   gen(env, _multianewarray4_Java           , multianewarray4_Type         , multianewarray4_C               ,    0 , true , false, false);
 142   gen(env, _multianewarray5_Java           , multianewarray5_Type         , multianewarray5_C               ,    0 , true , false, false);
 143   gen(env, _multianewarrayN_Java           , multianewarrayN_Type         , multianewarrayN_C               ,    0 , true , false, false);
 144   gen(env, _g1_wb_pre_Java                 , g1_wb_pre_Type               , SharedRuntime::g1_wb_pre        ,    0 , false, false, false);
 145   gen(env, _g1_wb_post_Java                , g1_wb_post_Type              , SharedRuntime::g1_wb_post       ,    0 , false, false, false);
 146   gen(env, _complete_monitor_locking_Java  , complete_monitor_enter_Type  , SharedRuntime::complete_monitor_locking_C, 0, false, false, false);
 147   gen(env, _monitor_notify_Java            , monitor_notify_Type          , monitor_notify_C                ,    0 , false, false, false);
 148   gen(env, _monitor_notifyAll_Java         , monitor_notify_Type          , monitor_notifyAll_C             ,    0 , false, false, false);
 149   gen(env, _rethrow_Java                   , rethrow_Type                 , rethrow_C                       ,    2 , true , false, true );
 150   gen(env, _array_out_of_bounds_Java       , array_out_of_bounds_Type     , array_out_of_bounds             ,    0 , false, false, false);
 151 
 152   gen(env, _slow_arraycopy_Java            , slow_arraycopy_Type          , SharedRuntime::slow_arraycopy_C ,    0 , false, false, false);
 153   gen(env, _register_finalizer_Java        , register_finalizer_Type      , register_finalizer              ,    0 , false, false, false);
 154 
 155   return true;
 156 }
 157 
 158 #undef gen
 159 
 160 
 161 // Helper method to do generation of RunTimeStub's
 162 address OptoRuntime::generate_stub( ciEnv* env,
 163                                     TypeFunc_generator gen, address C_function,
 164                                     const char *name, int is_fancy_jump,
 165                                     bool pass_tls,
 166                                     bool save_argument_registers,
 167                                     bool return_pc) {
 168 
 169   // Matching the default directive, we currently have no method to match.
 170   DirectiveSet* directive = DirectivesStack::getDefaultDirective(CompileBroker::compiler(CompLevel_full_optimization));


 413 JRT_END
 414 
 415 JRT_ENTRY(void, OptoRuntime::multianewarrayN_C(Klass* elem_type, arrayOopDesc* dims, JavaThread *thread))
 416   assert(check_compiled_frame(thread), "incorrect caller");
 417   assert(elem_type->is_klass(), "not a class");
 418   assert(oop(dims)->is_typeArray(), "not an array");
 419 
 420   ResourceMark rm;
 421   jint len = dims->length();
 422   assert(len > 0, "Dimensions array should contain data");
 423   jint *j_dims = typeArrayOop(dims)->int_at_addr(0);
 424   jint *c_dims = NEW_RESOURCE_ARRAY(jint, len);
 425   Copy::conjoint_jints_atomic(j_dims, c_dims, len);
 426 
 427   Handle holder(THREAD, elem_type->klass_holder()); // keep the klass alive
 428   oop obj = ArrayKlass::cast(elem_type)->multi_allocate(len, c_dims, THREAD);
 429   deoptimize_caller_frame(thread, HAS_PENDING_EXCEPTION);
 430   thread->set_vm_result(obj);
 431 JRT_END
 432 
 433 JRT_ENTRY(void, OptoRuntime::array_out_of_bounds(int index, int length, JavaThread *thread))
 434   fatal("Array index out of bounds: index = %d, length = %d", index, length);
 435 JRT_END
 436 
 437 JRT_BLOCK_ENTRY(void, OptoRuntime::monitor_notify_C(oopDesc* obj, JavaThread *thread))
 438 
 439   // Very few notify/notifyAll operations find any threads on the waitset, so
 440   // the dominant fast-path is to simply return.
 441   // Relatedly, it's critical that notify/notifyAll be fast in order to
 442   // reduce lock hold times.
 443   if (!SafepointSynchronize::is_synchronizing()) {
 444     if (ObjectSynchronizer::quick_notify(obj, thread, false)) {
 445       return;
 446     }
 447   }
 448 
 449   // This is the case the fast-path above isn't provisioned to handle.
 450   // The fast-path is designed to handle frequently arising cases in an efficient manner.
 451   // (The fast-path is just a degenerate variant of the slow-path).
 452   // Perform the dreaded state transition and pass control into the slow-path.
 453   JRT_BLOCK;
 454   Handle h_obj(THREAD, obj);
 455   ObjectSynchronizer::notify(h_obj, CHECK);
 456   JRT_BLOCK_END;


 584 
 585 const TypeFunc *OptoRuntime::g1_wb_post_Type() {
 586 
 587   const Type **fields = TypeTuple::fields(2);
 588   fields[TypeFunc::Parms+0] = TypeRawPtr::NOTNULL;  // Card addr
 589   fields[TypeFunc::Parms+1] = TypeRawPtr::NOTNULL;  // thread
 590   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields);
 591 
 592   // create result type (range)
 593   fields = TypeTuple::fields(0);
 594   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms, fields);
 595 
 596   return TypeFunc::make(domain, range);
 597 }
 598 
 599 const TypeFunc *OptoRuntime::uncommon_trap_Type() {
 600   // create input type (domain)
 601   const Type **fields = TypeTuple::fields(1);
 602   fields[TypeFunc::Parms+0] = TypeInt::INT; // trap_reason (deopt reason and action)
 603   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1, fields);
 604 
 605   // create result type (range)
 606   fields = TypeTuple::fields(0);
 607   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0, fields);
 608 
 609   return TypeFunc::make(domain, range);
 610 }
 611 
 612 const TypeFunc *OptoRuntime::array_out_of_bounds_Type() {
 613   // create input type (domain)
 614   const Type **fields = TypeTuple::fields(2);
 615   fields[TypeFunc::Parms+0] = TypeInt::INT; // index
 616   fields[TypeFunc::Parms+1] = TypeInt::INT; // length
 617   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields);
 618 
 619   // create result type (range)
 620   fields = TypeTuple::fields(0);
 621   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0, fields);
 622 
 623   return TypeFunc::make(domain, range);
 624 }
 625 
 626 //-----------------------------------------------------------------------------
 627 // Monitor Handling
 628 const TypeFunc *OptoRuntime::complete_monitor_enter_Type() {
 629   // create input type (domain)
 630   const Type **fields = TypeTuple::fields(2);
 631   fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL;  // Object to be Locked
 632   fields[TypeFunc::Parms+1] = TypeRawPtr::BOTTOM;   // Address of stack location for lock
 633   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2,fields);
 634 
 635   // create result type (range)
 636   fields = TypeTuple::fields(0);
 637 


< prev index next >