hotspot/src/share/vm/oops/methodOop.cpp
changeset 13282 9872915dd78d
parent 12960 2989536b61ef
child 13285 5c78ade8d6a3
equal deleted inserted replaced
13102:7342fd50f8d7 13282:9872915dd78d
   109   return buf;
   109   return buf;
   110 }
   110 }
   111 
   111 
   112 int  methodOopDesc::fast_exception_handler_bci_for(KlassHandle ex_klass, int throw_bci, TRAPS) {
   112 int  methodOopDesc::fast_exception_handler_bci_for(KlassHandle ex_klass, int throw_bci, TRAPS) {
   113   // exception table holds quadruple entries of the form (beg_bci, end_bci, handler_bci, klass_index)
   113   // exception table holds quadruple entries of the form (beg_bci, end_bci, handler_bci, klass_index)
   114   const int beg_bci_offset     = 0;
       
   115   const int end_bci_offset     = 1;
       
   116   const int handler_bci_offset = 2;
       
   117   const int klass_index_offset = 3;
       
   118   const int entry_size         = 4;
       
   119   // access exception table
   114   // access exception table
   120   typeArrayHandle table (THREAD, constMethod()->exception_table());
   115   ExceptionTable table(this);
   121   int length = table->length();
   116   int length = table.length();
   122   assert(length % entry_size == 0, "exception table format has changed");
       
   123   // iterate through all entries sequentially
   117   // iterate through all entries sequentially
   124   constantPoolHandle pool(THREAD, constants());
   118   constantPoolHandle pool(THREAD, constants());
   125   for (int i = 0; i < length; i += entry_size) {
   119   for (int i = 0; i < length; i ++) {
   126     int beg_bci = table->int_at(i + beg_bci_offset);
   120     //reacquire the table in case a GC happened
   127     int end_bci = table->int_at(i + end_bci_offset);
   121     ExceptionTable table(this);
       
   122     int beg_bci = table.start_pc(i);
       
   123     int end_bci = table.end_pc(i);
   128     assert(beg_bci <= end_bci, "inconsistent exception table");
   124     assert(beg_bci <= end_bci, "inconsistent exception table");
   129     if (beg_bci <= throw_bci && throw_bci < end_bci) {
   125     if (beg_bci <= throw_bci && throw_bci < end_bci) {
   130       // exception handler bci range covers throw_bci => investigate further
   126       // exception handler bci range covers throw_bci => investigate further
   131       int handler_bci = table->int_at(i + handler_bci_offset);
   127       int handler_bci = table.handler_pc(i);
   132       int klass_index = table->int_at(i + klass_index_offset);
   128       int klass_index = table.catch_type_index(i);
   133       if (klass_index == 0) {
   129       if (klass_index == 0) {
   134         return handler_bci;
   130         return handler_bci;
   135       } else if (ex_klass.is_null()) {
   131       } else if (ex_klass.is_null()) {
   136         return handler_bci;
   132         return handler_bci;
   137       } else {
   133       } else {
   978   cp->pseudo_string_at_put(_imcp_method_type_value, method_type());
   974   cp->pseudo_string_at_put(_imcp_method_type_value, method_type());
   979   methodHandle m;
   975   methodHandle m;
   980   {
   976   {
   981     int flags_bits = (JVM_MH_INVOKE_BITS | JVM_ACC_PUBLIC | JVM_ACC_FINAL);
   977     int flags_bits = (JVM_MH_INVOKE_BITS | JVM_ACC_PUBLIC | JVM_ACC_FINAL);
   982     methodOop m_oop = oopFactory::new_method(0, accessFlags_from(flags_bits),
   978     methodOop m_oop = oopFactory::new_method(0, accessFlags_from(flags_bits),
   983                                              0, 0, 0, IsSafeConc, CHECK_(empty));
   979                                              0, 0, 0, 0, IsSafeConc, CHECK_(empty));
   984     m = methodHandle(THREAD, m_oop);
   980     m = methodHandle(THREAD, m_oop);
   985   }
   981   }
   986   m->set_constants(cp());
   982   m->set_constants(cp());
   987   m->set_name_index(_imcp_invoke_name);
   983   m->set_name_index(_imcp_invoke_name);
   988   m->set_signature_index(_imcp_invoke_signature);
   984   m->set_signature_index(_imcp_invoke_signature);
   992 #ifdef CC_INTERP
   988 #ifdef CC_INTERP
   993   ResultTypeFinder rtf(signature);
   989   ResultTypeFinder rtf(signature);
   994   m->set_result_index(rtf.type());
   990   m->set_result_index(rtf.type());
   995 #endif
   991 #endif
   996   m->compute_size_of_parameters(THREAD);
   992   m->compute_size_of_parameters(THREAD);
   997   m->set_exception_table(Universe::the_empty_int_array());
       
   998   m->init_intrinsic_id();
   993   m->init_intrinsic_id();
   999   assert(m->intrinsic_id() == vmIntrinsics::_invokeExact ||
   994   assert(m->intrinsic_id() == vmIntrinsics::_invokeExact ||
  1000          m->intrinsic_id() == vmIntrinsics::_invokeGeneric, "must be an invoker");
   995          m->intrinsic_id() == vmIntrinsics::_invokeGeneric, "must be an invoker");
  1001 
   996 
  1002   // Finally, set up its entry points.
   997   // Finally, set up its entry points.
  1036   assert(!m->is_native(), "cannot rewrite native methods");
  1031   assert(!m->is_native(), "cannot rewrite native methods");
  1037   // Allocate new methodOop
  1032   // Allocate new methodOop
  1038   AccessFlags flags = m->access_flags();
  1033   AccessFlags flags = m->access_flags();
  1039   int checked_exceptions_len = m->checked_exceptions_length();
  1034   int checked_exceptions_len = m->checked_exceptions_length();
  1040   int localvariable_len = m->localvariable_table_length();
  1035   int localvariable_len = m->localvariable_table_length();
       
  1036   int exception_table_len = m->exception_table_length();
  1041   // Allocate newm_oop with the is_conc_safe parameter set
  1037   // Allocate newm_oop with the is_conc_safe parameter set
  1042   // to IsUnsafeConc to indicate that newm_oop is not yet
  1038   // to IsUnsafeConc to indicate that newm_oop is not yet
  1043   // safe for concurrent processing by a GC.
  1039   // safe for concurrent processing by a GC.
  1044   methodOop newm_oop = oopFactory::new_method(new_code_length,
  1040   methodOop newm_oop = oopFactory::new_method(new_code_length,
  1045                                               flags,
  1041                                               flags,
  1046                                               new_compressed_linenumber_size,
  1042                                               new_compressed_linenumber_size,
  1047                                               localvariable_len,
  1043                                               localvariable_len,
       
  1044                                               exception_table_len,
  1048                                               checked_exceptions_len,
  1045                                               checked_exceptions_len,
  1049                                               IsUnsafeConc,
  1046                                               IsUnsafeConc,
  1050                                               CHECK_(methodHandle()));
  1047                                               CHECK_(methodHandle()));
  1051   methodHandle newm (THREAD, newm_oop);
  1048   methodHandle newm (THREAD, newm_oop);
  1052   NOT_PRODUCT(int nmsz = newm->is_parsable() ? newm->size() : -1;)
  1049   NOT_PRODUCT(int nmsz = newm->is_parsable() ? newm->size() : -1;)