< prev index next >

src/hotspot/share/ci/ciMethod.cpp

Print this page
rev 47445 : 8171853: Remove Shark compiler


  36 #include "classfile/systemDictionary.hpp"
  37 #include "compiler/abstractCompiler.hpp"
  38 #include "compiler/methodLiveness.hpp"
  39 #include "interpreter/interpreter.hpp"
  40 #include "interpreter/linkResolver.hpp"
  41 #include "interpreter/oopMapCache.hpp"
  42 #include "memory/allocation.inline.hpp"
  43 #include "memory/resourceArea.hpp"
  44 #include "oops/generateOopMap.hpp"
  45 #include "oops/oop.inline.hpp"
  46 #include "prims/nativeLookup.hpp"
  47 #include "runtime/deoptimization.hpp"
  48 #include "utilities/bitMap.inline.hpp"
  49 #include "utilities/xmlstream.hpp"
  50 #include "trace/tracing.hpp"
  51 #ifdef COMPILER2
  52 #include "ci/bcEscapeAnalyzer.hpp"
  53 #include "ci/ciTypeFlow.hpp"
  54 #include "oops/method.hpp"
  55 #endif
  56 #ifdef SHARK
  57 #include "ci/ciTypeFlow.hpp"
  58 #include "oops/method.hpp"
  59 #endif
  60 
  61 // ciMethod
  62 //
  63 // This class represents a Method* in the HotSpot virtual
  64 // machine.
  65 
  66 
  67 // ------------------------------------------------------------------
  68 // ciMethod::ciMethod
  69 //
  70 // Loaded method.
  71 ciMethod::ciMethod(const methodHandle& h_m, ciInstanceKlass* holder) :
  72   ciMetadata(h_m()),
  73   _holder(holder)
  74 {
  75   assert(h_m() != NULL, "no null method");
  76 
  77   if (LogTouchedMethods) {
  78     h_m()->log_touched(Thread::current());
  79   }
  80   // These fields are always filled in in loaded methods.
  81   _flags = ciFlags(h_m()->access_flags());
  82 
  83   // Easy to compute, so fill them in now.
  84   _max_stack          = h_m()->max_stack();
  85   _max_locals         = h_m()->max_locals();
  86   _code_size          = h_m()->code_size();
  87   _intrinsic_id       = h_m()->intrinsic_id();
  88   _handler_count      = h_m()->exception_table_length();
  89   _size_of_parameters = h_m()->size_of_parameters();
  90   _uses_monitors      = h_m()->access_flags().has_monitor_bytecodes();
  91   _balanced_monitors  = !_uses_monitors || h_m()->access_flags().is_monitor_matching();
  92   _is_c1_compilable   = !h_m()->is_not_c1_compilable();
  93   _is_c2_compilable   = !h_m()->is_not_c2_compilable();
  94   _has_reserved_stack_access = h_m()->has_reserved_stack_access();
  95   // Lazy fields, filled in on demand.  Require allocation.
  96   _code               = NULL;
  97   _exception_handlers = NULL;
  98   _liveness           = NULL;
  99   _method_blocks = NULL;
 100 #if defined(COMPILER2) || defined(SHARK)
 101   _flow               = NULL;
 102   _bcea               = NULL;
 103 #endif // COMPILER2 || SHARK
 104 
 105   ciEnv *env = CURRENT_ENV;
 106   if (env->jvmti_can_hotswap_or_post_breakpoint() && can_be_compiled()) {
 107     // 6328518 check hotswap conditions under the right lock.
 108     MutexLocker locker(Compile_lock);
 109     if (Dependencies::check_evol_method(h_m()) != NULL) {
 110       _is_c1_compilable = false;
 111       _is_c2_compilable = false;
 112     }
 113   } else {
 114     CHECK_UNHANDLED_OOPS_ONLY(Thread::current()->clear_unhandled_oops());
 115   }
 116 
 117   if (h_m()->method_holder()->is_linked()) {
 118     _can_be_statically_bound = h_m()->can_be_statically_bound();
 119   } else {
 120     // Have to use a conservative value in this case.
 121     _can_be_statically_bound = false;
 122   }
 123 


 156 #endif
 157 }
 158 
 159 
 160 // ------------------------------------------------------------------
 161 // ciMethod::ciMethod
 162 //
 163 // Unloaded method.
 164 ciMethod::ciMethod(ciInstanceKlass* holder,
 165                    ciSymbol*        name,
 166                    ciSymbol*        signature,
 167                    ciInstanceKlass* accessor) :
 168   ciMetadata((Metadata*)NULL),
 169   _name(                   name),
 170   _holder(                 holder),
 171   _intrinsic_id(           vmIntrinsics::_none),
 172   _liveness(               NULL),
 173   _can_be_statically_bound(false),
 174   _method_blocks(          NULL),
 175   _method_data(            NULL)
 176 #if defined(COMPILER2) || defined(SHARK)
 177   ,
 178   _flow(                   NULL),
 179   _bcea(                   NULL),
 180   _instructions_size(-1)
 181 #endif // COMPILER2 || SHARK
 182 {
 183   // Usually holder and accessor are the same type but in some cases
 184   // the holder has the wrong class loader (e.g. invokedynamic call
 185   // sites) so we pass the accessor.
 186   _signature = new (CURRENT_ENV->arena()) ciSignature(accessor, constantPoolHandle(), signature);
 187 }
 188 
 189 
 190 // ------------------------------------------------------------------
 191 // ciMethod::load_code
 192 //
 193 // Load the bytecodes and exception handler table for this method.
 194 void ciMethod::load_code() {
 195   VM_ENTRY_MARK;
 196   assert(is_loaded(), "only loaded methods have code");
 197 
 198   Method* me = get_Method();
 199   Arena* arena = CURRENT_THREAD_ENV->arena();
 200 
 201   // Load the bytecodes.


 270 // ciMethod::line_number_from_bci
 271 int ciMethod::line_number_from_bci(int bci) const {
 272   check_is_loaded();
 273   VM_ENTRY_MARK;
 274   return get_Method()->line_number_from_bci(bci);
 275 }
 276 
 277 
 278 // ------------------------------------------------------------------
 279 // ciMethod::vtable_index
 280 //
 281 // Get the position of this method's entry in the vtable, if any.
 282 int ciMethod::vtable_index() {
 283   check_is_loaded();
 284   assert(holder()->is_linked(), "must be linked");
 285   VM_ENTRY_MARK;
 286   return get_Method()->vtable_index();
 287 }
 288 
 289 
 290 #ifdef SHARK
 291 // ------------------------------------------------------------------
 292 // ciMethod::itable_index
 293 //
 294 // Get the position of this method's entry in the itable, if any.
 295 int ciMethod::itable_index() {
 296   check_is_loaded();
 297   assert(holder()->is_linked(), "must be linked");
 298   VM_ENTRY_MARK;
 299   Method* m = get_Method();
 300   if (!m->has_itable_index())
 301     return Method::nonvirtual_vtable_index;
 302   return m->itable_index();
 303 }
 304 #endif // SHARK
 305 
 306 
 307 // ------------------------------------------------------------------
 308 // ciMethod::native_entry
 309 //
 310 // Get the address of this method's native code, if any.
 311 address ciMethod::native_entry() {
 312   check_is_loaded();
 313   assert(flags().is_native(), "must be native method");
 314   VM_ENTRY_MARK;
 315   Method* method = get_Method();
 316   address entry = method->native_function();
 317   assert(entry != NULL, "must be valid entry point");
 318   return entry;
 319 }
 320 
 321 
 322 // ------------------------------------------------------------------
 323 // ciMethod::interpreter_entry
 324 //
 325 // Get the entry point for running this method in the interpreter.
 326 address ciMethod::interpreter_entry() {


 352   }
 353 
 354   {
 355     EXCEPTION_MARK;
 356     ResourceMark rm(THREAD);
 357     GeneratePairingInfo gpi(method);
 358     gpi.compute_map(CATCH);
 359     if (!gpi.monitor_safe()) {
 360       return false;
 361     }
 362     method->set_guaranteed_monitor_matching();
 363     _balanced_monitors = true;
 364   }
 365   return true;
 366 }
 367 
 368 
 369 // ------------------------------------------------------------------
 370 // ciMethod::get_flow_analysis
 371 ciTypeFlow* ciMethod::get_flow_analysis() {
 372 #if defined(COMPILER2) || defined(SHARK)
 373   if (_flow == NULL) {
 374     ciEnv* env = CURRENT_ENV;
 375     _flow = new (env->arena()) ciTypeFlow(env, this);
 376     _flow->do_flow();
 377   }
 378   return _flow;
 379 #else // COMPILER2 || SHARK
 380   ShouldNotReachHere();
 381   return NULL;
 382 #endif // COMPILER2 || SHARK
 383 }
 384 
 385 
 386 // ------------------------------------------------------------------
 387 // ciMethod::get_osr_flow_analysis
 388 ciTypeFlow* ciMethod::get_osr_flow_analysis(int osr_bci) {
 389 #if defined(COMPILER2) || defined(SHARK)
 390   // OSR entry points are always place after a call bytecode of some sort
 391   assert(osr_bci >= 0, "must supply valid OSR entry point");
 392   ciEnv* env = CURRENT_ENV;
 393   ciTypeFlow* flow = new (env->arena()) ciTypeFlow(env, this, osr_bci);
 394   flow->do_flow();
 395   return flow;
 396 #else // COMPILER2 || SHARK
 397   ShouldNotReachHere();
 398   return NULL;
 399 #endif // COMPILER2 || SHARK
 400 }
 401 
 402 // ------------------------------------------------------------------
 403 // ciMethod::raw_liveness_at_bci
 404 //
 405 // Which local variables are live at a specific bci?
 406 MethodLivenessResult ciMethod::raw_liveness_at_bci(int bci) {
 407   check_is_loaded();
 408   if (_liveness == NULL) {
 409     // Create the liveness analyzer.
 410     Arena* arena = CURRENT_ENV->arena();
 411     _liveness = new (arena) MethodLiveness(arena, this);
 412     _liveness->compute_liveness();
 413   }
 414   return _liveness->get_liveness_at(bci);
 415 }
 416 
 417 // ------------------------------------------------------------------
 418 // ciMethod::liveness_at_bci
 419 //




  36 #include "classfile/systemDictionary.hpp"
  37 #include "compiler/abstractCompiler.hpp"
  38 #include "compiler/methodLiveness.hpp"
  39 #include "interpreter/interpreter.hpp"
  40 #include "interpreter/linkResolver.hpp"
  41 #include "interpreter/oopMapCache.hpp"
  42 #include "memory/allocation.inline.hpp"
  43 #include "memory/resourceArea.hpp"
  44 #include "oops/generateOopMap.hpp"
  45 #include "oops/oop.inline.hpp"
  46 #include "prims/nativeLookup.hpp"
  47 #include "runtime/deoptimization.hpp"
  48 #include "utilities/bitMap.inline.hpp"
  49 #include "utilities/xmlstream.hpp"
  50 #include "trace/tracing.hpp"
  51 #ifdef COMPILER2
  52 #include "ci/bcEscapeAnalyzer.hpp"
  53 #include "ci/ciTypeFlow.hpp"
  54 #include "oops/method.hpp"
  55 #endif




  56 
  57 // ciMethod
  58 //
  59 // This class represents a Method* in the HotSpot virtual
  60 // machine.
  61 
  62 
  63 // ------------------------------------------------------------------
  64 // ciMethod::ciMethod
  65 //
  66 // Loaded method.
  67 ciMethod::ciMethod(const methodHandle& h_m, ciInstanceKlass* holder) :
  68   ciMetadata(h_m()),
  69   _holder(holder)
  70 {
  71   assert(h_m() != NULL, "no null method");
  72 
  73   if (LogTouchedMethods) {
  74     h_m()->log_touched(Thread::current());
  75   }
  76   // These fields are always filled in in loaded methods.
  77   _flags = ciFlags(h_m()->access_flags());
  78 
  79   // Easy to compute, so fill them in now.
  80   _max_stack          = h_m()->max_stack();
  81   _max_locals         = h_m()->max_locals();
  82   _code_size          = h_m()->code_size();
  83   _intrinsic_id       = h_m()->intrinsic_id();
  84   _handler_count      = h_m()->exception_table_length();
  85   _size_of_parameters = h_m()->size_of_parameters();
  86   _uses_monitors      = h_m()->access_flags().has_monitor_bytecodes();
  87   _balanced_monitors  = !_uses_monitors || h_m()->access_flags().is_monitor_matching();
  88   _is_c1_compilable   = !h_m()->is_not_c1_compilable();
  89   _is_c2_compilable   = !h_m()->is_not_c2_compilable();
  90   _has_reserved_stack_access = h_m()->has_reserved_stack_access();
  91   // Lazy fields, filled in on demand.  Require allocation.
  92   _code               = NULL;
  93   _exception_handlers = NULL;
  94   _liveness           = NULL;
  95   _method_blocks = NULL;
  96 #if defined(COMPILER2)
  97   _flow               = NULL;
  98   _bcea               = NULL;
  99 #endif // COMPILER2
 100 
 101   ciEnv *env = CURRENT_ENV;
 102   if (env->jvmti_can_hotswap_or_post_breakpoint() && can_be_compiled()) {
 103     // 6328518 check hotswap conditions under the right lock.
 104     MutexLocker locker(Compile_lock);
 105     if (Dependencies::check_evol_method(h_m()) != NULL) {
 106       _is_c1_compilable = false;
 107       _is_c2_compilable = false;
 108     }
 109   } else {
 110     CHECK_UNHANDLED_OOPS_ONLY(Thread::current()->clear_unhandled_oops());
 111   }
 112 
 113   if (h_m()->method_holder()->is_linked()) {
 114     _can_be_statically_bound = h_m()->can_be_statically_bound();
 115   } else {
 116     // Have to use a conservative value in this case.
 117     _can_be_statically_bound = false;
 118   }
 119 


 152 #endif
 153 }
 154 
 155 
 156 // ------------------------------------------------------------------
 157 // ciMethod::ciMethod
 158 //
 159 // Unloaded method.
 160 ciMethod::ciMethod(ciInstanceKlass* holder,
 161                    ciSymbol*        name,
 162                    ciSymbol*        signature,
 163                    ciInstanceKlass* accessor) :
 164   ciMetadata((Metadata*)NULL),
 165   _name(                   name),
 166   _holder(                 holder),
 167   _intrinsic_id(           vmIntrinsics::_none),
 168   _liveness(               NULL),
 169   _can_be_statically_bound(false),
 170   _method_blocks(          NULL),
 171   _method_data(            NULL)
 172 #if defined(COMPILER2)
 173   ,
 174   _flow(                   NULL),
 175   _bcea(                   NULL),
 176   _instructions_size(-1)
 177 #endif // COMPILER2
 178 {
 179   // Usually holder and accessor are the same type but in some cases
 180   // the holder has the wrong class loader (e.g. invokedynamic call
 181   // sites) so we pass the accessor.
 182   _signature = new (CURRENT_ENV->arena()) ciSignature(accessor, constantPoolHandle(), signature);
 183 }
 184 
 185 
 186 // ------------------------------------------------------------------
 187 // ciMethod::load_code
 188 //
 189 // Load the bytecodes and exception handler table for this method.
 190 void ciMethod::load_code() {
 191   VM_ENTRY_MARK;
 192   assert(is_loaded(), "only loaded methods have code");
 193 
 194   Method* me = get_Method();
 195   Arena* arena = CURRENT_THREAD_ENV->arena();
 196 
 197   // Load the bytecodes.


 266 // ciMethod::line_number_from_bci
 267 int ciMethod::line_number_from_bci(int bci) const {
 268   check_is_loaded();
 269   VM_ENTRY_MARK;
 270   return get_Method()->line_number_from_bci(bci);
 271 }
 272 
 273 
 274 // ------------------------------------------------------------------
 275 // ciMethod::vtable_index
 276 //
 277 // Get the position of this method's entry in the vtable, if any.
 278 int ciMethod::vtable_index() {
 279   check_is_loaded();
 280   assert(holder()->is_linked(), "must be linked");
 281   VM_ENTRY_MARK;
 282   return get_Method()->vtable_index();
 283 }
 284 
 285 

















 286 // ------------------------------------------------------------------
 287 // ciMethod::native_entry
 288 //
 289 // Get the address of this method's native code, if any.
 290 address ciMethod::native_entry() {
 291   check_is_loaded();
 292   assert(flags().is_native(), "must be native method");
 293   VM_ENTRY_MARK;
 294   Method* method = get_Method();
 295   address entry = method->native_function();
 296   assert(entry != NULL, "must be valid entry point");
 297   return entry;
 298 }
 299 
 300 
 301 // ------------------------------------------------------------------
 302 // ciMethod::interpreter_entry
 303 //
 304 // Get the entry point for running this method in the interpreter.
 305 address ciMethod::interpreter_entry() {


 331   }
 332 
 333   {
 334     EXCEPTION_MARK;
 335     ResourceMark rm(THREAD);
 336     GeneratePairingInfo gpi(method);
 337     gpi.compute_map(CATCH);
 338     if (!gpi.monitor_safe()) {
 339       return false;
 340     }
 341     method->set_guaranteed_monitor_matching();
 342     _balanced_monitors = true;
 343   }
 344   return true;
 345 }
 346 
 347 
 348 // ------------------------------------------------------------------
 349 // ciMethod::get_flow_analysis
 350 ciTypeFlow* ciMethod::get_flow_analysis() {
 351 #if defined(COMPILER2)
 352   if (_flow == NULL) {
 353     ciEnv* env = CURRENT_ENV;
 354     _flow = new (env->arena()) ciTypeFlow(env, this);
 355     _flow->do_flow();
 356   }
 357   return _flow;
 358 #else // COMPILER2
 359   ShouldNotReachHere();
 360   return NULL;
 361 #endif // COMPILER2
 362 }
 363 
 364 
 365 // ------------------------------------------------------------------
 366 // ciMethod::get_osr_flow_analysis
 367 ciTypeFlow* ciMethod::get_osr_flow_analysis(int osr_bci) {
 368 #if defined(COMPILER2)
 369   // OSR entry points are always place after a call bytecode of some sort
 370   assert(osr_bci >= 0, "must supply valid OSR entry point");
 371   ciEnv* env = CURRENT_ENV;
 372   ciTypeFlow* flow = new (env->arena()) ciTypeFlow(env, this, osr_bci);
 373   flow->do_flow();
 374   return flow;
 375 #else // COMPILER2
 376   ShouldNotReachHere();
 377   return NULL;
 378 #endif // COMPILER2
 379 }
 380 
 381 // ------------------------------------------------------------------
 382 // ciMethod::raw_liveness_at_bci
 383 //
 384 // Which local variables are live at a specific bci?
 385 MethodLivenessResult ciMethod::raw_liveness_at_bci(int bci) {
 386   check_is_loaded();
 387   if (_liveness == NULL) {
 388     // Create the liveness analyzer.
 389     Arena* arena = CURRENT_ENV->arena();
 390     _liveness = new (arena) MethodLiveness(arena, this);
 391     _liveness->compute_liveness();
 392   }
 393   return _liveness->get_liveness_at(bci);
 394 }
 395 
 396 // ------------------------------------------------------------------
 397 // ciMethod::liveness_at_bci
 398 //


< prev index next >