src/hotspot/share/oops/method.cpp
changeset 59056 15936b142f86
parent 59016 3b9eeae66fa0
child 59070 22ee476cc664
equal deleted inserted replaced
59055:57ad70bcf06c 59056:15936b142f86
   544   // Do not profile the method if metaspace has hit an OOM previously
   544   // Do not profile the method if metaspace has hit an OOM previously
   545   if (ClassLoaderDataGraph::has_metaspace_oom()) {
   545   if (ClassLoaderDataGraph::has_metaspace_oom()) {
   546     return NULL;
   546     return NULL;
   547   }
   547   }
   548 
   548 
   549   methodHandle mh(m);
   549   methodHandle mh(THREAD, m);
   550   MethodCounters* counters = MethodCounters::allocate(mh, THREAD);
   550   MethodCounters* counters = MethodCounters::allocate(mh, THREAD);
   551   if (HAS_PENDING_EXCEPTION) {
   551   if (HAS_PENDING_EXCEPTION) {
   552     CompileBroker::log_metaspace_failure();
   552     CompileBroker::log_metaspace_failure();
   553     ClassLoaderDataGraph::set_metaspace_oom(true);
   553     ClassLoaderDataGraph::set_metaspace_oom(true);
   554     return NULL;   // return the exception (which is cleared)
   554     return NULL;   // return the exception (which is cleared)
   626   return true;
   626   return true;
   627 }
   627 }
   628 
   628 
   629 
   629 
   630 bool Method::compute_has_loops_flag() {
   630 bool Method::compute_has_loops_flag() {
   631   BytecodeStream bcs(this);
   631   BytecodeStream bcs(methodHandle(Thread::current(), this));
   632   Bytecodes::Code bc;
   632   Bytecodes::Code bc;
   633 
   633 
   634   while ((bc = bcs.next()) >= 0) {
   634   while ((bc = bcs.next()) >= 0) {
   635     switch( bc ) {
   635     switch( bc ) {
   636       case Bytecodes::_ifeq:
   636       case Bytecodes::_ifeq:
   984       set_not_c1_compilable();
   984       set_not_c1_compilable();
   985     if (is_c2_compile(comp_level))
   985     if (is_c2_compile(comp_level))
   986       set_not_c2_compilable();
   986       set_not_c2_compilable();
   987   }
   987   }
   988   CompilationPolicy::policy()->disable_compilation(this);
   988   CompilationPolicy::policy()->disable_compilation(this);
   989   assert(!CompilationPolicy::can_be_compiled(this, comp_level), "sanity check");
   989   assert(!CompilationPolicy::can_be_compiled(methodHandle(Thread::current(), this), comp_level), "sanity check");
   990 }
   990 }
   991 
   991 
   992 bool Method::is_not_osr_compilable(int comp_level) const {
   992 bool Method::is_not_osr_compilable(int comp_level) const {
   993   if (is_not_compilable(comp_level))
   993   if (is_not_compilable(comp_level))
   994     return true;
   994     return true;
  1011       set_not_c1_osr_compilable();
  1011       set_not_c1_osr_compilable();
  1012     if (is_c2_compile(comp_level))
  1012     if (is_c2_compile(comp_level))
  1013       set_not_c2_osr_compilable();
  1013       set_not_c2_osr_compilable();
  1014   }
  1014   }
  1015   CompilationPolicy::policy()->disable_compilation(this);
  1015   CompilationPolicy::policy()->disable_compilation(this);
  1016   assert(!CompilationPolicy::can_be_osr_compiled(this, comp_level), "sanity check");
  1016   assert(!CompilationPolicy::can_be_osr_compiled(methodHandle(Thread::current(), this), comp_level), "sanity check");
  1017 }
  1017 }
  1018 
  1018 
  1019 // Revert to using the interpreter and clear out the nmethod
  1019 // Revert to using the interpreter and clear out the nmethod
  1020 void Method::clear_code() {
  1020 void Method::clear_code() {
  1021   // this may be NULL if c2i adapters have not been made yet
  1021   // this may be NULL if c2i adapters have not been made yet
  1056   _code = NULL;
  1056   _code = NULL;
  1057 
  1057 
  1058   Arguments::assert_is_dumping_archive();
  1058   Arguments::assert_is_dumping_archive();
  1059   // Set the values to what they should be at run time. Note that
  1059   // Set the values to what they should be at run time. Note that
  1060   // this Method can no longer be executed during dump time.
  1060   // this Method can no longer be executed during dump time.
  1061   _i2i_entry = Interpreter::entry_for_cds_method(this);
  1061   _i2i_entry = Interpreter::entry_for_cds_method(methodHandle(Thread::current(), this));
  1062   _from_interpreted_entry = _i2i_entry;
  1062   _from_interpreted_entry = _i2i_entry;
  1063 
  1063 
  1064   if (DynamicDumpSharedSpaces) {
  1064   if (DynamicDumpSharedSpaces) {
  1065     assert(_from_compiled_entry != NULL, "sanity");
  1065     assert(_from_compiled_entry != NULL, "sanity");
  1066   } else {
  1066   } else {
  1568   }
  1568   }
  1569   // Copy stackmap table
  1569   // Copy stackmap table
  1570   if (m->has_stackmap_table()) {
  1570   if (m->has_stackmap_table()) {
  1571     int code_attribute_length = m->stackmap_data()->length();
  1571     int code_attribute_length = m->stackmap_data()->length();
  1572     Array<u1>* stackmap_data =
  1572     Array<u1>* stackmap_data =
  1573       MetadataFactory::new_array<u1>(loader_data, code_attribute_length, 0, CHECK_NULL);
  1573       MetadataFactory::new_array<u1>(loader_data, code_attribute_length, 0, CHECK_(methodHandle()));
  1574     memcpy((void*)stackmap_data->adr_at(0),
  1574     memcpy((void*)stackmap_data->adr_at(0),
  1575            (void*)m->stackmap_data()->adr_at(0), code_attribute_length);
  1575            (void*)m->stackmap_data()->adr_at(0), code_attribute_length);
  1576     newm->set_stackmap_data(stackmap_data);
  1576     newm->set_stackmap_data(stackmap_data);
  1577   }
  1577   }
  1578 
  1578 
  1579   // copy annotations over to new method
  1579   // copy annotations over to new method
  1580   newcm->copy_annotations_from(loader_data, cm, CHECK_NULL);
  1580   newcm->copy_annotations_from(loader_data, cm, CHECK_(methodHandle()));
  1581   return newm;
  1581   return newm;
  1582 }
  1582 }
  1583 
  1583 
  1584 vmSymbols::SID Method::klass_id_for_intrinsics(const Klass* holder) {
  1584 vmSymbols::SID Method::klass_id_for_intrinsics(const Klass* holder) {
  1585   // if loader is not the default loader (i.e., != NULL), we can't know the intrinsics
  1585   // if loader is not the default loader (i.e., != NULL), we can't know the intrinsics
  2216     // jmethodID is a pointer to Method*
  2216     // jmethodID is a pointer to Method*
  2217     return (jmethodID)cld->jmethod_ids()->add_method(m);
  2217     return (jmethodID)cld->jmethod_ids()->add_method(m);
  2218   }
  2218   }
  2219 }
  2219 }
  2220 
  2220 
       
  2221 jmethodID Method::jmethod_id() {
       
  2222   methodHandle mh(Thread::current(), this);
       
  2223   return method_holder()->get_jmethod_id(mh);
       
  2224 }
       
  2225 
  2221 // Mark a jmethodID as free.  This is called when there is a data race in
  2226 // Mark a jmethodID as free.  This is called when there is a data race in
  2222 // InstanceKlass while creating the jmethodID cache.
  2227 // InstanceKlass while creating the jmethodID cache.
  2223 void Method::destroy_jmethod_id(ClassLoaderData* loader_data, jmethodID m) {
  2228 void Method::destroy_jmethod_id(ClassLoaderData* loader_data, jmethodID m) {
  2224   ClassLoaderData* cld = loader_data;
  2229   ClassLoaderData* cld = loader_data;
  2225   Method** ptr = (Method**)m;
  2230   Method** ptr = (Method**)m;