hotspot/src/share/vm/ci/ciMethod.cpp

Print this page




  39   assert(h_m() != NULL, "no null method");
  40 
  41   // These fields are always filled in in loaded methods.
  42   _flags = ciFlags(h_m()->access_flags());
  43 
  44   // Easy to compute, so fill them in now.
  45   _max_stack          = h_m()->max_stack();
  46   _max_locals         = h_m()->max_locals();
  47   _code_size          = h_m()->code_size();
  48   _intrinsic_id       = h_m()->intrinsic_id();
  49   _handler_count      = h_m()->exception_table()->length() / 4;
  50   _uses_monitors      = h_m()->access_flags().has_monitor_bytecodes();
  51   _balanced_monitors  = !_uses_monitors || h_m()->access_flags().is_monitor_matching();
  52   _is_compilable      = !h_m()->is_not_compilable();
  53   // Lazy fields, filled in on demand.  Require allocation.
  54   _code               = NULL;
  55   _exception_handlers = NULL;
  56   _liveness           = NULL;
  57   _bcea = NULL;
  58   _method_blocks = NULL;
  59 #ifdef COMPILER2
  60   _flow               = NULL;
  61 #endif // COMPILER2
  62 
  63   ciEnv *env = CURRENT_ENV;
  64   if (env->jvmti_can_hotswap_or_post_breakpoint() && _is_compilable) {
  65     // 6328518 check hotswap conditions under the right lock.
  66     MutexLocker locker(Compile_lock);
  67     if (Dependencies::check_evol_method(h_m()) != NULL) {
  68       _is_compilable = false;
  69     }
  70   } else {
  71     CHECK_UNHANDLED_OOPS_ONLY(Thread::current()->clear_unhandled_oops());
  72   }
  73 
  74   if (instanceKlass::cast(h_m()->method_holder())->is_linked()) {
  75     _can_be_statically_bound = h_m()->can_be_statically_bound();
  76   } else {
  77     // Have to use a conservative value in this case.
  78     _can_be_statically_bound = false;
  79   }
  80 
  81   // Adjust the definition of this condition to be more useful:


 107 }
 108 
 109 
 110 // ------------------------------------------------------------------
 111 // ciMethod::ciMethod
 112 //
 113 // Unloaded method.
 114 ciMethod::ciMethod(ciInstanceKlass* holder,
 115                    ciSymbol* name,
 116                    ciSymbol* signature) : ciObject(ciMethodKlass::make()) {
 117   // These fields are always filled in.
 118   _name = name;
 119   _holder = holder;
 120   _signature = new (CURRENT_ENV->arena()) ciSignature(_holder, signature);
 121   _intrinsic_id = vmIntrinsics::_none;
 122   _liveness = NULL;
 123   _can_be_statically_bound = false;
 124   _bcea = NULL;
 125   _method_blocks = NULL;
 126   _method_data = NULL;
 127 #ifdef COMPILER2
 128   _flow = NULL;
 129 #endif // COMPILER2
 130 }
 131 
 132 
 133 // ------------------------------------------------------------------
 134 // ciMethod::load_code
 135 //
 136 // Load the bytecodes and exception handler table for this method.
 137 void ciMethod::load_code() {
 138   VM_ENTRY_MARK;
 139   assert(is_loaded(), "only loaded methods have code");
 140 
 141   methodOop me = get_methodOop();
 142   Arena* arena = CURRENT_THREAD_ENV->arena();
 143 
 144   // Load the bytecodes.
 145   _code = (address)arena->Amalloc(code_size());
 146   memcpy(_code, me->code_base(), code_size());
 147 
 148   // Revert any breakpoint bytecodes in ci's copy
 149   if (me->number_of_breakpoints() > 0) {


 212 // ciMethod::line_number_from_bci
 213 int ciMethod::line_number_from_bci(int bci) const {
 214   check_is_loaded();
 215   VM_ENTRY_MARK;
 216   return get_methodOop()->line_number_from_bci(bci);
 217 }
 218 
 219 
 220 // ------------------------------------------------------------------
 221 // ciMethod::vtable_index
 222 //
 223 // Get the position of this method's entry in the vtable, if any.
 224 int ciMethod::vtable_index() {
 225   check_is_loaded();
 226   assert(holder()->is_linked(), "must be linked");
 227   VM_ENTRY_MARK;
 228   return get_methodOop()->vtable_index();
 229 }
 230 
 231 














 232 // ------------------------------------------------------------------
 233 // ciMethod::native_entry
 234 //
 235 // Get the address of this method's native code, if any.
 236 address ciMethod::native_entry() {
 237   check_is_loaded();
 238   assert(flags().is_native(), "must be native method");
 239   VM_ENTRY_MARK;
 240   methodOop method = get_methodOop();
 241   address entry = method->native_function();
 242   assert(entry != NULL, "must be valid entry point");
 243   return entry;
 244 }
 245 
 246 
 247 // ------------------------------------------------------------------
 248 // ciMethod::interpreter_entry
 249 //
 250 // Get the entry point for running this method in the interpreter.
 251 address ciMethod::interpreter_entry() {


 277   }
 278 
 279   {
 280     EXCEPTION_MARK;
 281     ResourceMark rm(THREAD);
 282     GeneratePairingInfo gpi(method);
 283     gpi.compute_map(CATCH);
 284     if (!gpi.monitor_safe()) {
 285       return false;
 286     }
 287     method->set_guaranteed_monitor_matching();
 288     _balanced_monitors = true;
 289   }
 290   return true;
 291 }
 292 
 293 
 294 // ------------------------------------------------------------------
 295 // ciMethod::get_flow_analysis
 296 ciTypeFlow* ciMethod::get_flow_analysis() {
 297 #ifdef COMPILER2
 298   if (_flow == NULL) {
 299     ciEnv* env = CURRENT_ENV;
 300     _flow = new (env->arena()) ciTypeFlow(env, this);
 301     _flow->do_flow();
 302   }
 303   return _flow;
 304 #else // COMPILER2
 305   ShouldNotReachHere();
 306   return NULL;
 307 #endif // COMPILER2
 308 }
 309 
 310 
 311 // ------------------------------------------------------------------
 312 // ciMethod::get_osr_flow_analysis
 313 ciTypeFlow* ciMethod::get_osr_flow_analysis(int osr_bci) {
 314 #ifdef COMPILER2
 315   // OSR entry points are always place after a call bytecode of some sort
 316   assert(osr_bci >= 0, "must supply valid OSR entry point");
 317   ciEnv* env = CURRENT_ENV;
 318   ciTypeFlow* flow = new (env->arena()) ciTypeFlow(env, this, osr_bci);
 319   flow->do_flow();
 320   return flow;
 321 #else // COMPILER2
 322   ShouldNotReachHere();
 323   return NULL;
 324 #endif // COMPILER2
 325 }
 326 
 327 // ------------------------------------------------------------------
 328 // ciMethod::raw_liveness_at_bci
 329 //
 330 // Which local variables are live at a specific bci?
 331 MethodLivenessResult ciMethod::raw_liveness_at_bci(int bci) {
 332   check_is_loaded();
 333   if (_liveness == NULL) {
 334     // Create the liveness analyzer.
 335     Arena* arena = CURRENT_ENV->arena();
 336     _liveness = new (arena) MethodLiveness(arena, this);
 337     _liveness->compute_liveness();
 338   }
 339   return _liveness->get_liveness_at(bci);
 340 }
 341 
 342 // ------------------------------------------------------------------
 343 // ciMethod::liveness_at_bci
 344 //




  39   assert(h_m() != NULL, "no null method");
  40 
  41   // These fields are always filled in in loaded methods.
  42   _flags = ciFlags(h_m()->access_flags());
  43 
  44   // Easy to compute, so fill them in now.
  45   _max_stack          = h_m()->max_stack();
  46   _max_locals         = h_m()->max_locals();
  47   _code_size          = h_m()->code_size();
  48   _intrinsic_id       = h_m()->intrinsic_id();
  49   _handler_count      = h_m()->exception_table()->length() / 4;
  50   _uses_monitors      = h_m()->access_flags().has_monitor_bytecodes();
  51   _balanced_monitors  = !_uses_monitors || h_m()->access_flags().is_monitor_matching();
  52   _is_compilable      = !h_m()->is_not_compilable();
  53   // Lazy fields, filled in on demand.  Require allocation.
  54   _code               = NULL;
  55   _exception_handlers = NULL;
  56   _liveness           = NULL;
  57   _bcea = NULL;
  58   _method_blocks = NULL;
  59 #if defined(COMPILER2) || defined(SHARK)
  60   _flow               = NULL;
  61 #endif // COMPILER2 || SHARK
  62 
  63   ciEnv *env = CURRENT_ENV;
  64   if (env->jvmti_can_hotswap_or_post_breakpoint() && _is_compilable) {
  65     // 6328518 check hotswap conditions under the right lock.
  66     MutexLocker locker(Compile_lock);
  67     if (Dependencies::check_evol_method(h_m()) != NULL) {
  68       _is_compilable = false;
  69     }
  70   } else {
  71     CHECK_UNHANDLED_OOPS_ONLY(Thread::current()->clear_unhandled_oops());
  72   }
  73 
  74   if (instanceKlass::cast(h_m()->method_holder())->is_linked()) {
  75     _can_be_statically_bound = h_m()->can_be_statically_bound();
  76   } else {
  77     // Have to use a conservative value in this case.
  78     _can_be_statically_bound = false;
  79   }
  80 
  81   // Adjust the definition of this condition to be more useful:


 107 }
 108 
 109 
 110 // ------------------------------------------------------------------
 111 // ciMethod::ciMethod
 112 //
 113 // Unloaded method.
 114 ciMethod::ciMethod(ciInstanceKlass* holder,
 115                    ciSymbol* name,
 116                    ciSymbol* signature) : ciObject(ciMethodKlass::make()) {
 117   // These fields are always filled in.
 118   _name = name;
 119   _holder = holder;
 120   _signature = new (CURRENT_ENV->arena()) ciSignature(_holder, signature);
 121   _intrinsic_id = vmIntrinsics::_none;
 122   _liveness = NULL;
 123   _can_be_statically_bound = false;
 124   _bcea = NULL;
 125   _method_blocks = NULL;
 126   _method_data = NULL;
 127 #if defined(COMPILER2) || defined(SHARK)
 128   _flow = NULL;
 129 #endif // COMPILER2 || SHARK
 130 }
 131 
 132 
 133 // ------------------------------------------------------------------
 134 // ciMethod::load_code
 135 //
 136 // Load the bytecodes and exception handler table for this method.
 137 void ciMethod::load_code() {
 138   VM_ENTRY_MARK;
 139   assert(is_loaded(), "only loaded methods have code");
 140 
 141   methodOop me = get_methodOop();
 142   Arena* arena = CURRENT_THREAD_ENV->arena();
 143 
 144   // Load the bytecodes.
 145   _code = (address)arena->Amalloc(code_size());
 146   memcpy(_code, me->code_base(), code_size());
 147 
 148   // Revert any breakpoint bytecodes in ci's copy
 149   if (me->number_of_breakpoints() > 0) {


 212 // ciMethod::line_number_from_bci
 213 int ciMethod::line_number_from_bci(int bci) const {
 214   check_is_loaded();
 215   VM_ENTRY_MARK;
 216   return get_methodOop()->line_number_from_bci(bci);
 217 }
 218 
 219 
 220 // ------------------------------------------------------------------
 221 // ciMethod::vtable_index
 222 //
 223 // Get the position of this method's entry in the vtable, if any.
 224 int ciMethod::vtable_index() {
 225   check_is_loaded();
 226   assert(holder()->is_linked(), "must be linked");
 227   VM_ENTRY_MARK;
 228   return get_methodOop()->vtable_index();
 229 }
 230 
 231 
 232 #ifdef SHARK
 233 // ------------------------------------------------------------------
 234 // ciMethod::itable_index
 235 //
 236 // Get the position of this method's entry in the itable, if any.
 237 int ciMethod::itable_index() {
 238   check_is_loaded();
 239   assert(holder()->is_linked(), "must be linked");
 240   VM_ENTRY_MARK;
 241   return klassItable::compute_itable_index(get_methodOop());
 242 }
 243 #endif // SHARK
 244 
 245 
 246 // ------------------------------------------------------------------
 247 // ciMethod::native_entry
 248 //
 249 // Get the address of this method's native code, if any.
 250 address ciMethod::native_entry() {
 251   check_is_loaded();
 252   assert(flags().is_native(), "must be native method");
 253   VM_ENTRY_MARK;
 254   methodOop method = get_methodOop();
 255   address entry = method->native_function();
 256   assert(entry != NULL, "must be valid entry point");
 257   return entry;
 258 }
 259 
 260 
 261 // ------------------------------------------------------------------
 262 // ciMethod::interpreter_entry
 263 //
 264 // Get the entry point for running this method in the interpreter.
 265 address ciMethod::interpreter_entry() {


 291   }
 292 
 293   {
 294     EXCEPTION_MARK;
 295     ResourceMark rm(THREAD);
 296     GeneratePairingInfo gpi(method);
 297     gpi.compute_map(CATCH);
 298     if (!gpi.monitor_safe()) {
 299       return false;
 300     }
 301     method->set_guaranteed_monitor_matching();
 302     _balanced_monitors = true;
 303   }
 304   return true;
 305 }
 306 
 307 
 308 // ------------------------------------------------------------------
 309 // ciMethod::get_flow_analysis
 310 ciTypeFlow* ciMethod::get_flow_analysis() {
 311 #if defined(COMPILER2) || defined(SHARK)
 312   if (_flow == NULL) {
 313     ciEnv* env = CURRENT_ENV;
 314     _flow = new (env->arena()) ciTypeFlow(env, this);
 315     _flow->do_flow();
 316   }
 317   return _flow;
 318 #else // COMPILER2 || SHARK
 319   ShouldNotReachHere();
 320   return NULL;
 321 #endif // COMPILER2 || SHARK
 322 }
 323 
 324 
 325 // ------------------------------------------------------------------
 326 // ciMethod::get_osr_flow_analysis
 327 ciTypeFlow* ciMethod::get_osr_flow_analysis(int osr_bci) {
 328 #if defined(COMPILER2) || defined(SHARK)
 329   // OSR entry points are always place after a call bytecode of some sort
 330   assert(osr_bci >= 0, "must supply valid OSR entry point");
 331   ciEnv* env = CURRENT_ENV;
 332   ciTypeFlow* flow = new (env->arena()) ciTypeFlow(env, this, osr_bci);
 333   flow->do_flow();
 334   return flow;
 335 #else // COMPILER2 || SHARK
 336   ShouldNotReachHere();
 337   return NULL;
 338 #endif // COMPILER2 || SHARK
 339 }
 340 
 341 // ------------------------------------------------------------------
 342 // ciMethod::raw_liveness_at_bci
 343 //
 344 // Which local variables are live at a specific bci?
 345 MethodLivenessResult ciMethod::raw_liveness_at_bci(int bci) {
 346   check_is_loaded();
 347   if (_liveness == NULL) {
 348     // Create the liveness analyzer.
 349     Arena* arena = CURRENT_ENV->arena();
 350     _liveness = new (arena) MethodLiveness(arena, this);
 351     _liveness->compute_liveness();
 352   }
 353   return _liveness->get_liveness_at(bci);
 354 }
 355 
 356 // ------------------------------------------------------------------
 357 // ciMethod::liveness_at_bci
 358 //