hotspot/src/share/vm/code/nmethod.cpp
changeset 6418 6671edbd230e
parent 6268 9e96dde307e9
child 6432 d36e09b60939
--- a/hotspot/src/share/vm/code/nmethod.cpp	Mon Aug 23 09:09:36 2010 -0700
+++ b/hotspot/src/share/vm/code/nmethod.cpp	Wed Aug 25 05:27:54 2010 -0700
@@ -87,7 +87,7 @@
   int nmethod_count;
   int total_size;
   int relocation_size;
-  int code_size;
+  int insts_size;
   int stub_size;
   int consts_size;
   int scopes_data_size;
@@ -101,7 +101,7 @@
     nmethod_count += 1;
     total_size          += nm->size();
     relocation_size     += nm->relocation_size();
-    code_size           += nm->code_size();
+    insts_size          += nm->insts_size();
     stub_size           += nm->stub_size();
     consts_size         += nm->consts_size();
     oops_size           += nm->oops_size();
@@ -116,7 +116,7 @@
     tty->print_cr("Statistics for %d bytecoded nmethods:", nmethod_count);
     if (total_size != 0)          tty->print_cr(" total in heap  = %d", total_size);
     if (relocation_size != 0)     tty->print_cr(" relocation     = %d", relocation_size);
-    if (code_size != 0)           tty->print_cr(" main code      = %d", code_size);
+    if (insts_size != 0)          tty->print_cr(" main code      = %d", insts_size);
     if (stub_size != 0)           tty->print_cr(" stub code      = %d", stub_size);
     if (consts_size != 0)         tty->print_cr(" constants      = %d", consts_size);
     if (oops_size != 0)           tty->print_cr(" oops           = %d", oops_size);
@@ -130,13 +130,13 @@
   int native_nmethod_count;
   int native_total_size;
   int native_relocation_size;
-  int native_code_size;
+  int native_insts_size;
   int native_oops_size;
   void note_native_nmethod(nmethod* nm) {
     native_nmethod_count += 1;
     native_total_size       += nm->size();
     native_relocation_size  += nm->relocation_size();
-    native_code_size        += nm->code_size();
+    native_insts_size       += nm->insts_size();
     native_oops_size        += nm->oops_size();
   }
   void print_native_nmethod_stats() {
@@ -144,7 +144,7 @@
     tty->print_cr("Statistics for %d native nmethods:", native_nmethod_count);
     if (native_total_size != 0)       tty->print_cr(" N. total size  = %d", native_total_size);
     if (native_relocation_size != 0)  tty->print_cr(" N. relocation  = %d", native_relocation_size);
-    if (native_code_size != 0)        tty->print_cr(" N. main code   = %d", native_code_size);
+    if (native_insts_size != 0)       tty->print_cr(" N. main code   = %d", native_insts_size);
     if (native_oops_size != 0)        tty->print_cr(" N. oops        = %d", native_oops_size);
   }
 
@@ -404,7 +404,7 @@
 
 int nmethod::total_size() const {
   return
-    code_size()          +
+    insts_size()         +
     stub_size()          +
     consts_size()        +
     scopes_data_size()   +
@@ -618,8 +618,8 @@
     _deoptimize_mh_offset    = 0;
     _orig_pc_offset          = 0;
 
+    _consts_offset           = data_offset();
     _stub_offset             = data_offset();
-    _consts_offset           = data_offset();
     _oops_offset             = data_offset();
     _scopes_data_offset      = _oops_offset          + round_to(code_buffer->total_oop_size(), oopSize);
     _scopes_pcs_offset       = _scopes_data_offset;
@@ -629,8 +629,8 @@
     _nmethod_end_offset      = _nul_chk_table_offset;
     _compile_id              = 0;  // default
     _comp_level              = CompLevel_none;
-    _entry_point             = instructions_begin();
-    _verified_entry_point    = instructions_begin() + offsets->value(CodeOffsets::Verified_Entry);
+    _entry_point             = code_begin()          + offsets->value(CodeOffsets::Entry);
+    _verified_entry_point    = code_begin()          + offsets->value(CodeOffsets::Verified_Entry);
     _osr_entry_point         = NULL;
     _exception_cache         = NULL;
     _pc_desc_cache.reset_to(NULL);
@@ -696,8 +696,8 @@
     _unwind_handler_offset   = -1;
     _trap_offset             = offsets->value(CodeOffsets::Dtrace_trap);
     _orig_pc_offset          = 0;
+    _consts_offset           = data_offset();
     _stub_offset             = data_offset();
-    _consts_offset           = data_offset();
     _oops_offset             = data_offset();
     _scopes_data_offset      = _oops_offset          + round_to(code_buffer->total_oop_size(), oopSize);
     _scopes_pcs_offset       = _scopes_data_offset;
@@ -707,8 +707,8 @@
     _nmethod_end_offset      = _nul_chk_table_offset;
     _compile_id              = 0;  // default
     _comp_level              = CompLevel_none;
-    _entry_point             = instructions_begin();
-    _verified_entry_point    = instructions_begin() + offsets->value(CodeOffsets::Verified_Entry);
+    _entry_point             = code_begin()          + offsets->value(CodeOffsets::Entry);
+    _verified_entry_point    = code_begin()          + offsets->value(CodeOffsets::Verified_Entry);
     _osr_entry_point         = NULL;
     _exception_cache         = NULL;
     _pc_desc_cache.reset_to(NULL);
@@ -787,18 +787,21 @@
     _comp_level              = comp_level;
     _compiler                = compiler;
     _orig_pc_offset          = orig_pc_offset;
-    _stub_offset             = instructions_offset() + code_buffer->total_offset_of(code_buffer->stubs()->start());
+
+    // Section offsets
+    _consts_offset           = content_offset()      + code_buffer->total_offset_of(code_buffer->consts()->start());
+    _stub_offset             = content_offset()      + code_buffer->total_offset_of(code_buffer->stubs()->start());
 
     // Exception handler and deopt handler are in the stub section
-    _exception_offset        = _stub_offset + offsets->value(CodeOffsets::Exceptions);
-    _deoptimize_offset       = _stub_offset + offsets->value(CodeOffsets::Deopt);
-    _deoptimize_mh_offset    = _stub_offset + offsets->value(CodeOffsets::DeoptMH);
+    _exception_offset        = _stub_offset          + offsets->value(CodeOffsets::Exceptions);
+    _deoptimize_offset       = _stub_offset          + offsets->value(CodeOffsets::Deopt);
+    _deoptimize_mh_offset    = _stub_offset          + offsets->value(CodeOffsets::DeoptMH);
     if (offsets->value(CodeOffsets::UnwindHandler) != -1) {
-      _unwind_handler_offset   = instructions_offset() + offsets->value(CodeOffsets::UnwindHandler);
+      _unwind_handler_offset = code_offset()         + offsets->value(CodeOffsets::UnwindHandler);
     } else {
-      _unwind_handler_offset   = -1;
+      _unwind_handler_offset = -1;
     }
-    _consts_offset           = instructions_offset() + code_buffer->total_offset_of(code_buffer->consts()->start());
+
     _oops_offset             = data_offset();
     _scopes_data_offset      = _oops_offset          + round_to(code_buffer->total_oop_size (), oopSize);
     _scopes_pcs_offset       = _scopes_data_offset   + round_to(debug_info->data_size       (), oopSize);
@@ -807,9 +810,9 @@
     _nul_chk_table_offset    = _handler_table_offset + round_to(handler_table->size_in_bytes(), oopSize);
     _nmethod_end_offset      = _nul_chk_table_offset + round_to(nul_chk_table->size_in_bytes(), oopSize);
 
-    _entry_point             = instructions_begin();
-    _verified_entry_point    = instructions_begin() + offsets->value(CodeOffsets::Verified_Entry);
-    _osr_entry_point         = instructions_begin() + offsets->value(CodeOffsets::OSR_Entry);
+    _entry_point             = code_begin()          + offsets->value(CodeOffsets::Entry);
+    _verified_entry_point    = code_begin()          + offsets->value(CodeOffsets::Verified_Entry);
+    _osr_entry_point         = code_begin()          + offsets->value(CodeOffsets::OSR_Entry);
     _exception_cache         = NULL;
     _pc_desc_cache.reset_to(scopes_pcs_begin());
 
@@ -878,12 +881,11 @@
     HandleMark hm;
     xtty->begin_elem("nmethod");
     log_identity(xtty);
-    xtty->print(" entry='" INTPTR_FORMAT "' size='%d'",
-                instructions_begin(), size());
+    xtty->print(" entry='" INTPTR_FORMAT "' size='%d'", code_begin(), size());
     xtty->print(" address='" INTPTR_FORMAT "'", (intptr_t) this);
 
     LOG_OFFSET(xtty, relocation);
-    LOG_OFFSET(xtty, code);
+    LOG_OFFSET(xtty, insts);
     LOG_OFFSET(xtty, stub);
     LOG_OFFSET(xtty, consts);
     LOG_OFFSET(xtty, scopes_data);
@@ -1460,7 +1462,7 @@
       moop->name()->utf8_length(),
       moop->signature()->bytes(),
       moop->signature()->utf8_length(),
-      code_begin(), code_size());
+      insts_begin(), insts_size());
 
   if (JvmtiExport::should_post_compiled_method_load() ||
       JvmtiExport::should_post_compiled_method_unload()) {
@@ -1502,7 +1504,7 @@
   if (_jmethod_id != NULL && JvmtiExport::should_post_compiled_method_unload()) {
     assert(!unload_reported(), "already unloaded");
     HandleMark hm;
-    JvmtiExport::post_compiled_method_unload(_jmethod_id, code_begin());
+    JvmtiExport::post_compiled_method_unload(_jmethod_id, insts_begin());
   }
 
   // The JVMTI CompiledMethodUnload event can be enabled or disabled at
@@ -1854,7 +1856,7 @@
   // Adjust the final sentinel downward.
   PcDesc* last_pc = &scopes_pcs_begin()[count-1];
   assert(last_pc->pc_offset() == PcDesc::upper_offset_limit, "sanity");
-  last_pc->set_pc_offset(instructions_size() + 1);
+  last_pc->set_pc_offset(content_size() + 1);
   for (; last_pc + 1 < scopes_pcs_end(); last_pc += 1) {
     // Fill any rounding gaps with copies of the last record.
     last_pc[1] = last_pc[0];
@@ -1894,7 +1896,7 @@
 
 // Finds a PcDesc with real-pc equal to "pc"
 PcDesc* nmethod::find_pc_desc_internal(address pc, bool approximate) {
-  address base_address = instructions_begin();
+  address base_address = code_begin();
   if ((pc < base_address) ||
       (pc - base_address) >= (ptrdiff_t) PcDesc::upper_offset_limit) {
     return NULL;  // PC is wildly out of range
@@ -2042,7 +2044,7 @@
 
 
 bool nmethod::is_patchable_at(address instr_addr) {
-  assert (code_contains(instr_addr), "wrong nmethod used");
+  assert(insts_contains(instr_addr), "wrong nmethod used");
   if (is_zombie()) {
     // a zombie may never be patched
     return false;
@@ -2054,7 +2056,7 @@
 address nmethod::continuation_for_implicit_exception(address pc) {
   // Exception happened outside inline-cache check code => we are inside
   // an active nmethod => use cpc to determine a return address
-  int exception_offset = pc - instructions_begin();
+  int exception_offset = pc - code_begin();
   int cont_offset = ImplicitExceptionTable(this).at( exception_offset );
 #ifdef ASSERT
   if (cont_offset == 0) {
@@ -2075,7 +2077,7 @@
     // Let the normal error handling report the exception
     return NULL;
   }
-  return instructions_begin() + cont_offset;
+  return code_begin() + cont_offset;
 }
 
 
@@ -2334,10 +2336,10 @@
                                               relocation_begin(),
                                               relocation_end(),
                                               relocation_size());
-  if (code_size         () > 0) tty->print_cr(" main code      [" INTPTR_FORMAT "," INTPTR_FORMAT "] = %d",
-                                              code_begin(),
-                                              code_end(),
-                                              code_size());
+  if (insts_size        () > 0) tty->print_cr(" main code      [" INTPTR_FORMAT "," INTPTR_FORMAT "] = %d",
+                                              insts_begin(),
+                                              insts_end(),
+                                              insts_size());
   if (stub_size         () > 0) tty->print_cr(" stub code      [" INTPTR_FORMAT "," INTPTR_FORMAT "] = %d",
                                               stub_begin(),
                                               stub_end(),
@@ -2607,7 +2609,7 @@
   // First, find an oopmap in (begin, end].
   // We use the odd half-closed interval so that oop maps and scope descs
   // which are tied to the byte after a call are printed with the call itself.
-  address base = instructions_begin();
+  address base = code_begin();
   OopMapSet* oms = oop_maps();
   if (oms != NULL) {
     for (int i = 0, imax = oms->size(); i < imax; i++) {
@@ -2695,10 +2697,10 @@
     st->move_to(column);
     st->print(";   {%s}", str);
   }
-  int cont_offset = ImplicitExceptionTable(this).at(begin - instructions_begin());
+  int cont_offset = ImplicitExceptionTable(this).at(begin - code_begin());
   if (cont_offset != 0) {
     st->move_to(column);
-    st->print("; implicit exception: dispatches to " INTPTR_FORMAT, instructions_begin() + cont_offset);
+    st->print("; implicit exception: dispatches to " INTPTR_FORMAT, code_begin() + cont_offset);
   }
 
 }
@@ -2732,7 +2734,7 @@
 }
 
 void nmethod::print_nul_chk_table() {
-  ImplicitExceptionTable(this).print(instructions_begin());
+  ImplicitExceptionTable(this).print(code_begin());
 }
 
 void nmethod::print_statistics() {