< prev index next >

src/hotspot/share/opto/runtime.cpp

Print this page




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

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


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

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


 674   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+2, fields);
 675 
 676   return TypeFunc::make(domain, range);
 677 }
 678 
 679 //-------------- currentTimeMillis, currentTimeNanos, etc
 680 
 681 const TypeFunc* OptoRuntime::void_long_Type() {
 682   // create input type (domain)
 683   const Type **fields = TypeTuple::fields(0);
 684   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+0, fields);
 685 
 686   // create result type (range)
 687   fields = TypeTuple::fields(2);
 688   fields[TypeFunc::Parms+0] = TypeLong::LONG;
 689   fields[TypeFunc::Parms+1] = Type::HALF;
 690   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+2, fields);
 691 
 692   return TypeFunc::make(domain, range);
 693 }








































 694 
 695 // arraycopy stub variations:
 696 enum ArrayCopyType {
 697   ac_fast,                      // void(ptr, ptr, size_t)
 698   ac_checkcast,                 //  int(ptr, ptr, size_t, size_t, ptr)
 699   ac_slow,                      // void(ptr, int, ptr, int, int)
 700   ac_generic                    //  int(ptr, int, ptr, int, int)
 701 };
 702 
 703 static const TypeFunc* make_arraycopy_Type(ArrayCopyType act) {
 704   // create input type (domain)
 705   int num_args      = (act == ac_fast ? 3 : 5);
 706   int num_size_args = (act == ac_fast ? 1 : act == ac_checkcast ? 2 : 0);
 707   int argcnt = num_args;
 708   LP64_ONLY(argcnt += num_size_args); // halfwords for lengths
 709   const Type** fields = TypeTuple::fields(argcnt);
 710   int argp = TypeFunc::Parms;
 711   fields[argp++] = TypePtr::NOTNULL;    // src
 712   if (num_size_args == 0) {
 713     fields[argp++] = TypeInt::INT;      // src_pos




  86 
  87 
  88 
  89 // Compiled code entry points
  90 address OptoRuntime::_new_instance_Java                           = NULL;
  91 address OptoRuntime::_new_array_Java                              = NULL;
  92 address OptoRuntime::_new_array_nozero_Java                       = NULL;
  93 address OptoRuntime::_multianewarray2_Java                        = NULL;
  94 address OptoRuntime::_multianewarray3_Java                        = NULL;
  95 address OptoRuntime::_multianewarray4_Java                        = NULL;
  96 address OptoRuntime::_multianewarray5_Java                        = NULL;
  97 address OptoRuntime::_multianewarrayN_Java                        = NULL;
  98 address OptoRuntime::_vtable_must_compile_Java                    = NULL;
  99 address OptoRuntime::_complete_monitor_locking_Java               = NULL;
 100 address OptoRuntime::_monitor_notify_Java                         = NULL;
 101 address OptoRuntime::_monitor_notifyAll_Java                      = NULL;
 102 address OptoRuntime::_rethrow_Java                                = NULL;
 103 
 104 address OptoRuntime::_slow_arraycopy_Java                         = NULL;
 105 address OptoRuntime::_register_finalizer_Java                     = NULL;
 106 address OptoRuntime::_continuation_getFP_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) \
 124   var = generate_stub(env, type_func_gen, CAST_FROM_FN_PTR(address, c_func), #var, fancy_jump, pass_tls, save_arg_regs, return_pc); \
 125   if (var == NULL) { return false; }
 126 


 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, _complete_monitor_locking_Java  , complete_monitor_enter_Type  , SharedRuntime::complete_monitor_locking_C, 0, false, false, false);
 144   gen(env, _monitor_notify_Java            , monitor_notify_Type          , monitor_notify_C                ,    0 , false, false, false);
 145   gen(env, _monitor_notifyAll_Java         , monitor_notify_Type          , monitor_notifyAll_C             ,    0 , false, false, false);
 146   gen(env, _rethrow_Java                   , rethrow_Type                 , rethrow_C                       ,    2 , true , false, true );
 147 
 148   gen(env, _slow_arraycopy_Java            , slow_arraycopy_Type          , SharedRuntime::slow_arraycopy_C ,    0 , false, false, false);
 149   gen(env, _register_finalizer_Java        , register_finalizer_Type      , register_finalizer              ,    0 , false, false, false);
 150   gen(env, _continuation_getFP_Java        , void_long_Type               , SharedRuntime::continuation_getFP,    0 , false, false, false);
 151 
 152   return true;
 153 }
 154 
 155 #undef gen
 156 
 157 
 158 // Helper method to do generation of RunTimeStub's
 159 address OptoRuntime::generate_stub( ciEnv* env,
 160                                     TypeFunc_generator gen, address C_function,
 161                                     const char *name, int is_fancy_jump,
 162                                     bool pass_tls,
 163                                     bool save_argument_registers,
 164                                     bool return_pc) {
 165 
 166   // Matching the default directive, we currently have no method to match.
 167   DirectiveSet* directive = DirectivesStack::getDefaultDirective(CompileBroker::compiler(CompLevel_full_optimization));
 168   ResourceMark rm;
 169   Compile C( env, gen, C_function, name, is_fancy_jump, pass_tls, save_argument_registers, return_pc, directive);
 170   DirectivesStack::release(directive);


 676   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+2, fields);
 677 
 678   return TypeFunc::make(domain, range);
 679 }
 680 
 681 //-------------- currentTimeMillis, currentTimeNanos, etc
 682 
 683 const TypeFunc* OptoRuntime::void_long_Type() {
 684   // create input type (domain)
 685   const Type **fields = TypeTuple::fields(0);
 686   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+0, fields);
 687 
 688   // create result type (range)
 689   fields = TypeTuple::fields(2);
 690   fields[TypeFunc::Parms+0] = TypeLong::LONG;
 691   fields[TypeFunc::Parms+1] = Type::HALF;
 692   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+2, fields);
 693 
 694   return TypeFunc::make(domain, range);
 695 }
 696 
 697 const TypeFunc* OptoRuntime::void_void_Type() {
 698    // create input type (domain)
 699    const Type **fields = TypeTuple::fields(0);
 700    const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+0, fields);
 701 
 702    // create result type (range)
 703    fields = TypeTuple::fields(0);
 704    const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0, fields);
 705    return TypeFunc::make(domain, range);
 706  }
 707 
 708  const TypeFunc* OptoRuntime::continuation_doYield_Type() {
 709    const Type**fields = TypeTuple::fields(1);
 710    fields[TypeFunc::Parms+0] = TypeInt::INT;
 711    const TypeTuple *args = TypeTuple::make(TypeFunc::Parms+1, fields);
 712 
 713    fields = TypeTuple::fields(1);
 714    fields[TypeFunc::Parms+0] = TypeInt::INT;
 715    const TypeTuple *result = TypeTuple::make(TypeFunc::Parms+1, fields);
 716 
 717    return TypeFunc::make(args, result);
 718  }
 719 
 720  const TypeFunc* OptoRuntime::continuation_jump_Type() {
 721   // create input type (domain)
 722   const Type **fields = TypeTuple::fields(6);
 723   fields[TypeFunc::Parms+0] = TypeLong::LONG;
 724   fields[TypeFunc::Parms+1] = Type::HALF;
 725   fields[TypeFunc::Parms+2] = TypeLong::LONG;
 726   fields[TypeFunc::Parms+3] = Type::HALF;
 727   fields[TypeFunc::Parms+4] = TypeLong::LONG;
 728   fields[TypeFunc::Parms+5] = Type::HALF;
 729   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+6, fields);
 730 
 731   // create result type (range)
 732   fields = TypeTuple::fields(0);
 733   const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0, fields);
 734   return TypeFunc::make(domain, range);
 735  }
 736 
 737 // arraycopy stub variations:
 738 enum ArrayCopyType {
 739   ac_fast,                      // void(ptr, ptr, size_t)
 740   ac_checkcast,                 //  int(ptr, ptr, size_t, size_t, ptr)
 741   ac_slow,                      // void(ptr, int, ptr, int, int)
 742   ac_generic                    //  int(ptr, int, ptr, int, int)
 743 };
 744 
 745 static const TypeFunc* make_arraycopy_Type(ArrayCopyType act) {
 746   // create input type (domain)
 747   int num_args      = (act == ac_fast ? 3 : 5);
 748   int num_size_args = (act == ac_fast ? 1 : act == ac_checkcast ? 2 : 0);
 749   int argcnt = num_args;
 750   LP64_ONLY(argcnt += num_size_args); // halfwords for lengths
 751   const Type** fields = TypeTuple::fields(argcnt);
 752   int argp = TypeFunc::Parms;
 753   fields[argp++] = TypePtr::NOTNULL;    // src
 754   if (num_size_args == 0) {
 755     fields[argp++] = TypeInt::INT;      // src_pos


< prev index next >