< prev index next >

src/share/vm/oops/method.cpp

Print this page
rev 10298 : 8147978: Remove Method::_method_data for C1
Summary: Method::_method_data field removed when not using C2 or JVMCI
Reviewed-by: dholmes, kvn


 366 // collected in the interpreter.
 367 void Method::build_interpreter_method_data(const methodHandle& method, TRAPS) {
 368   // Do not profile the method if metaspace has hit an OOM previously
 369   // allocating profiling data. Callers clear pending exception so don't
 370   // add one here.
 371   if (ClassLoaderDataGraph::has_metaspace_oom()) {
 372     return;
 373   }
 374 
 375   // Do not profile method if current thread holds the pending list lock,
 376   // which avoids deadlock for acquiring the MethodData_lock.
 377   if (InstanceRefKlass::owns_pending_list_lock((JavaThread*)THREAD)) {
 378     return;
 379   }
 380 
 381   // Grab a lock here to prevent multiple
 382   // MethodData*s from being created.
 383   MutexLocker ml(MethodData_lock, THREAD);
 384   if (method->method_data() == NULL) {
 385     ClassLoaderData* loader_data = method->method_holder()->class_loader_data();

 386     MethodData* method_data = MethodData::allocate(loader_data, method, THREAD);
 387     if (HAS_PENDING_EXCEPTION) {
 388       CompileBroker::log_metaspace_failure();
 389       ClassLoaderDataGraph::set_metaspace_oom(true);
 390       return;   // return the exception (which is cleared)
 391     }
 392 
 393     method->set_method_data(method_data);

 394     if (PrintMethodData && (Verbose || WizardMode)) {
 395       ResourceMark rm(THREAD);
 396       tty->print("build_interpreter_method_data for ");
 397       method->print_name(tty);
 398       tty->cr();
 399       // At the end of the run, the MDO, full of data, will be dumped.
 400     }
 401   }
 402 }
 403 
 404 MethodCounters* Method::build_method_counters(Method* m, TRAPS) {
 405   // Do not profile the method if metaspace has hit an OOM previously
 406   if (ClassLoaderDataGraph::has_metaspace_oom()) {
 407     return NULL;
 408   }
 409 
 410   methodHandle mh(m);
 411   MethodCounters* counters = MethodCounters::allocate(mh, THREAD);
 412   if (HAS_PENDING_EXCEPTION) {
 413     CompileBroker::log_metaspace_failure();


 903 
 904 // Called by class data sharing to remove any entry points (which are not shared)
 905 void Method::unlink_method() {
 906   _code = NULL;
 907   _i2i_entry = NULL;
 908   _from_interpreted_entry = NULL;
 909   if (is_native()) {
 910     *native_function_addr() = NULL;
 911     set_signature_handler(NULL);
 912   }
 913   NOT_PRODUCT(set_compiled_invocation_count(0);)
 914   _adapter = NULL;
 915   _from_compiled_entry = NULL;
 916 
 917   // In case of DumpSharedSpaces, _method_data should always be NULL.
 918   //
 919   // During runtime (!DumpSharedSpaces), when we are cleaning a
 920   // shared class that failed to load, this->link_method() may
 921   // have already been called (before an exception happened), so
 922   // this->_method_data may not be NULL.
 923   assert(!DumpSharedSpaces || _method_data == NULL, "unexpected method data?");
 924 
 925   set_method_data(NULL);
 926   clear_method_counters();
 927 }
 928 
 929 // Called when the method_holder is getting linked. Setup entrypoints so the method
 930 // is ready to be called from interpreter, compiler, and vtables.
 931 void Method::link_method(const methodHandle& h_method, TRAPS) {
 932   // If the code cache is full, we may reenter this function for the
 933   // leftover methods that weren't linked.
 934   if (_i2i_entry != NULL) return;
 935 
 936   assert(_adapter == NULL, "init'd to NULL" );
 937   assert( _code == NULL, "nothing compiled yet" );
 938 
 939   // Setup interpreter entrypoint
 940   assert(this == h_method(), "wrong h_method()" );
 941   address entry = Interpreter::entry_for_method(h_method);
 942   assert(entry != NULL, "interpreter entry must be non-null");
 943   // Sets both _i2i_entry and _from_interpreted_entry




 366 // collected in the interpreter.
 367 void Method::build_interpreter_method_data(const methodHandle& method, TRAPS) {
 368   // Do not profile the method if metaspace has hit an OOM previously
 369   // allocating profiling data. Callers clear pending exception so don't
 370   // add one here.
 371   if (ClassLoaderDataGraph::has_metaspace_oom()) {
 372     return;
 373   }
 374 
 375   // Do not profile method if current thread holds the pending list lock,
 376   // which avoids deadlock for acquiring the MethodData_lock.
 377   if (InstanceRefKlass::owns_pending_list_lock((JavaThread*)THREAD)) {
 378     return;
 379   }
 380 
 381   // Grab a lock here to prevent multiple
 382   // MethodData*s from being created.
 383   MutexLocker ml(MethodData_lock, THREAD);
 384   if (method->method_data() == NULL) {
 385     ClassLoaderData* loader_data = method->method_holder()->class_loader_data();
 386 #if defined(COMPILER2) || INCLUDE_JVMCI
 387     MethodData* method_data = MethodData::allocate(loader_data, method, THREAD);
 388     if (HAS_PENDING_EXCEPTION) {
 389       CompileBroker::log_metaspace_failure();
 390       ClassLoaderDataGraph::set_metaspace_oom(true);
 391       return;   // return the exception (which is cleared)
 392     }

 393     method->set_method_data(method_data);
 394 #endif
 395     if (PrintMethodData && (Verbose || WizardMode)) {
 396       ResourceMark rm(THREAD);
 397       tty->print("build_interpreter_method_data for ");
 398       method->print_name(tty);
 399       tty->cr();
 400       // At the end of the run, the MDO, full of data, will be dumped.
 401     }
 402   }
 403 }
 404 
 405 MethodCounters* Method::build_method_counters(Method* m, TRAPS) {
 406   // Do not profile the method if metaspace has hit an OOM previously
 407   if (ClassLoaderDataGraph::has_metaspace_oom()) {
 408     return NULL;
 409   }
 410 
 411   methodHandle mh(m);
 412   MethodCounters* counters = MethodCounters::allocate(mh, THREAD);
 413   if (HAS_PENDING_EXCEPTION) {
 414     CompileBroker::log_metaspace_failure();


 904 
 905 // Called by class data sharing to remove any entry points (which are not shared)
 906 void Method::unlink_method() {
 907   _code = NULL;
 908   _i2i_entry = NULL;
 909   _from_interpreted_entry = NULL;
 910   if (is_native()) {
 911     *native_function_addr() = NULL;
 912     set_signature_handler(NULL);
 913   }
 914   NOT_PRODUCT(set_compiled_invocation_count(0);)
 915   _adapter = NULL;
 916   _from_compiled_entry = NULL;
 917 
 918   // In case of DumpSharedSpaces, _method_data should always be NULL.
 919   //
 920   // During runtime (!DumpSharedSpaces), when we are cleaning a
 921   // shared class that failed to load, this->link_method() may
 922   // have already been called (before an exception happened), so
 923   // this->_method_data may not be NULL.
 924   assert(!DumpSharedSpaces || method_data() == NULL, "unexpected method data?");
 925 
 926   set_method_data(NULL);
 927   clear_method_counters();
 928 }
 929 
 930 // Called when the method_holder is getting linked. Setup entrypoints so the method
 931 // is ready to be called from interpreter, compiler, and vtables.
 932 void Method::link_method(const methodHandle& h_method, TRAPS) {
 933   // If the code cache is full, we may reenter this function for the
 934   // leftover methods that weren't linked.
 935   if (_i2i_entry != NULL) return;
 936 
 937   assert(_adapter == NULL, "init'd to NULL" );
 938   assert( _code == NULL, "nothing compiled yet" );
 939 
 940   // Setup interpreter entrypoint
 941   assert(this == h_method(), "wrong h_method()" );
 942   address entry = Interpreter::entry_for_method(h_method);
 943   assert(entry != NULL, "interpreter entry must be non-null");
 944   // Sets both _i2i_entry and _from_interpreted_entry


< prev index next >