6961697: move nmethod constants section before instruction section

Fri, 27 Aug 2010 01:51:27 -0700

author
twisti
date
Fri, 27 Aug 2010 01:51:27 -0700
changeset 2117
0878d7bae69f
parent 2116
14b92b91f460
child 2119
14197af1010e

6961697: move nmethod constants section before instruction section
Summary: This is a preparation for 6961690.
Reviewed-by: kvn, never

src/share/vm/asm/codeBuffer.cpp file | annotate | diff | comparison | revisions
src/share/vm/asm/codeBuffer.hpp file | annotate | diff | comparison | revisions
src/share/vm/code/codeBlob.cpp file | annotate | diff | comparison | revisions
src/share/vm/code/nmethod.cpp file | annotate | diff | comparison | revisions
src/share/vm/code/nmethod.hpp file | annotate | diff | comparison | revisions
src/share/vm/code/relocInfo.cpp file | annotate | diff | comparison | revisions
src/share/vm/code/relocInfo.hpp file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/vm/asm/codeBuffer.cpp	Thu Aug 26 11:05:25 2010 -0700
     1.2 +++ b/src/share/vm/asm/codeBuffer.cpp	Fri Aug 27 01:51:27 2010 -0700
     1.3 @@ -143,13 +143,6 @@
     1.4  
     1.5  void CodeBuffer::initialize_section_size(CodeSection* cs, csize_t size) {
     1.6    assert(cs != &_insts, "insts is the memory provider, not the consumer");
     1.7 -#ifdef ASSERT
     1.8 -  for (int n = (int)SECT_INSTS+1; n < (int)SECT_LIMIT; n++) {
     1.9 -    CodeSection* prevCS = code_section(n);
    1.10 -    if (prevCS == cs)  break;
    1.11 -    assert(!prevCS->is_allocated(), "section allocation must be in reverse order");
    1.12 -  }
    1.13 -#endif
    1.14    csize_t slop = CodeSection::end_slop();  // margin between sections
    1.15    int align = cs->alignment();
    1.16    assert(is_power_of_2(align), "sanity");
    1.17 @@ -199,13 +192,13 @@
    1.18      _total_start = start;
    1.19      _total_size  = end - start;
    1.20    } else {
    1.21 -    #ifdef ASSERT
    1.22 +#ifdef ASSERT
    1.23      // Clean out dangling pointers.
    1.24      _total_start    = badAddress;
    1.25 +    _consts._start  = _consts._end  = badAddress;
    1.26      _insts._start   = _insts._end   = badAddress;
    1.27      _stubs._start   = _stubs._end   = badAddress;
    1.28 -    _consts._start  = _consts._end  = badAddress;
    1.29 -    #endif //ASSERT
    1.30 +#endif //ASSERT
    1.31    }
    1.32  }
    1.33  
    1.34 @@ -221,9 +214,9 @@
    1.35    return NULL;
    1.36  #else //PRODUCT
    1.37    switch (n) {
    1.38 +  case SECT_CONSTS:            return "consts";
    1.39    case SECT_INSTS:             return "insts";
    1.40    case SECT_STUBS:             return "stubs";
    1.41 -  case SECT_CONSTS:            return "consts";
    1.42    default:                     return NULL;
    1.43    }
    1.44  #endif //PRODUCT
    1.45 @@ -445,12 +438,11 @@
    1.46  
    1.47    const CodeSection* prev_cs      = NULL;
    1.48    CodeSection*       prev_dest_cs = NULL;
    1.49 -  for (int n = 0; n < (int)SECT_LIMIT; n++) {
    1.50 +
    1.51 +  for (int n = (int) SECT_FIRST; n < (int) SECT_LIMIT; n++) {
    1.52      // figure compact layout of each section
    1.53      const CodeSection* cs = code_section(n);
    1.54 -    address cstart = cs->start();
    1.55 -    address cend   = cs->end();
    1.56 -    csize_t csize  = cend - cstart;
    1.57 +    csize_t csize = cs->size();
    1.58  
    1.59      CodeSection* dest_cs = dest->code_section(n);
    1.60      if (!cs->is_empty()) {
    1.61 @@ -463,7 +455,7 @@
    1.62          prev_dest_cs->_limit += padding;
    1.63        }
    1.64        #ifdef ASSERT
    1.65 -      if (prev_cs != NULL && prev_cs->is_frozen() && n < SECT_CONSTS) {
    1.66 +      if (prev_cs != NULL && prev_cs->is_frozen() && n < (SECT_LIMIT - 1)) {
    1.67          // Make sure the ends still match up.
    1.68          // This is important because a branch in a frozen section
    1.69          // might target code in a following section, via a Label,
    1.70 @@ -492,22 +484,18 @@
    1.71    assert(dest->verify_section_allocation(), "final configuration works");
    1.72  }
    1.73  
    1.74 -csize_t CodeBuffer::total_offset_of(address addr) const {
    1.75 -  csize_t code_size_so_far = 0;
    1.76 -  for (int n = 0; n < (int)SECT_LIMIT; n++) {
    1.77 -    const CodeSection* cs = code_section(n);
    1.78 -    if (!cs->is_empty()) {
    1.79 -      code_size_so_far = cs->align_at_start(code_size_so_far);
    1.80 +csize_t CodeBuffer::total_offset_of(CodeSection* cs) const {
    1.81 +  csize_t size_so_far = 0;
    1.82 +  for (int n = (int) SECT_FIRST; n < (int) SECT_LIMIT; n++) {
    1.83 +    const CodeSection* cur_cs = code_section(n);
    1.84 +    if (!cur_cs->is_empty()) {
    1.85 +      size_so_far = cur_cs->align_at_start(size_so_far);
    1.86      }
    1.87 -    if (cs->contains2(addr)) {
    1.88 -      return code_size_so_far + (addr - cs->start());
    1.89 +    if (cur_cs->index() == cs->index()) {
    1.90 +      return size_so_far;
    1.91      }
    1.92 -    code_size_so_far += cs->size();
    1.93 +    size_so_far += cur_cs->size();
    1.94    }
    1.95 -#ifndef PRODUCT
    1.96 -  tty->print_cr("Dangling address " PTR_FORMAT " in:", addr);
    1.97 -  ((CodeBuffer*)this)->print();
    1.98 -#endif
    1.99    ShouldNotReachHere();
   1.100    return -1;
   1.101  }
   1.102 @@ -533,7 +521,7 @@
   1.103  
   1.104    csize_t code_end_so_far = 0;
   1.105    csize_t code_point_so_far = 0;
   1.106 -  for (int n = 0; n < (int)SECT_LIMIT; n++) {
   1.107 +  for (int n = (int) SECT_FIRST; n < (int)SECT_LIMIT; n++) {
   1.108      // pull relocs out of each section
   1.109      const CodeSection* cs = code_section(n);
   1.110      assert(!(cs->is_empty() && cs->locs_count() > 0), "sanity");
   1.111 @@ -635,11 +623,14 @@
   1.112    ICache::invalidate_range(dest_blob->code_begin(), dest_blob->code_size());
   1.113  }
   1.114  
   1.115 -// Move all my code into another code buffer.
   1.116 -// Consult applicable relocs to repair embedded addresses.
   1.117 +// Move all my code into another code buffer.  Consult applicable
   1.118 +// relocs to repair embedded addresses.  The layout in the destination
   1.119 +// CodeBuffer is different to the source CodeBuffer: the destination
   1.120 +// CodeBuffer gets the final layout (consts, insts, stubs in order of
   1.121 +// ascending address).
   1.122  void CodeBuffer::relocate_code_to(CodeBuffer* dest) const {
   1.123    DEBUG_ONLY(address dest_end = dest->_total_start + dest->_total_size);
   1.124 -  for (int n = 0; n < (int)SECT_LIMIT; n++) {
   1.125 +  for (int n = (int) SECT_FIRST; n < (int) SECT_LIMIT; n++) {
   1.126      // pull code out of each section
   1.127      const CodeSection* cs = code_section(n);
   1.128      if (cs->is_empty())  continue;  // skip trivial section
   1.129 @@ -681,20 +672,19 @@
   1.130                                                 csize_t* new_capacity) {
   1.131    csize_t new_total_cap = 0;
   1.132  
   1.133 -  int prev_n = -1;
   1.134 -  for (int n = 0; n < (int)SECT_LIMIT; n++) {
   1.135 +  for (int n = (int) SECT_FIRST; n < (int) SECT_LIMIT; n++) {
   1.136      const CodeSection* sect = code_section(n);
   1.137  
   1.138      if (!sect->is_empty()) {
   1.139 -      // Compute initial padding; assign it to the previous non-empty guy.
   1.140 -      // Cf. compute_final_layout.
   1.141 +      // Compute initial padding; assign it to the previous section,
   1.142 +      // even if it's empty (e.g. consts section can be empty).
   1.143 +      // Cf. compute_final_layout
   1.144        csize_t padding = sect->align_at_start(new_total_cap) - new_total_cap;
   1.145        if (padding != 0) {
   1.146          new_total_cap += padding;
   1.147 -        assert(prev_n >= 0, "sanity");
   1.148 -        new_capacity[prev_n] += padding;
   1.149 +        assert(n - 1 >= SECT_FIRST, "sanity");
   1.150 +        new_capacity[n - 1] += padding;
   1.151        }
   1.152 -      prev_n = n;
   1.153      }
   1.154  
   1.155      csize_t exp = sect->size();  // 100% increase
   1.156 @@ -774,11 +764,11 @@
   1.157    this->_before_expand = bxp;
   1.158  
   1.159    // Give each section its required (expanded) capacity.
   1.160 -  for (int n = (int)SECT_LIMIT-1; n >= SECT_INSTS; n--) {
   1.161 +  for (int n = (int)SECT_LIMIT-1; n >= SECT_FIRST; n--) {
   1.162      CodeSection* cb_sect   = cb.code_section(n);
   1.163      CodeSection* this_sect = code_section(n);
   1.164      if (new_capacity[n] == 0)  continue;  // already nulled out
   1.165 -    if (n > SECT_INSTS) {
   1.166 +    if (n != SECT_INSTS) {
   1.167        cb.initialize_section_size(cb_sect, new_capacity[n]);
   1.168      }
   1.169      assert(cb_sect->capacity() >= new_capacity[n], "big enough");
   1.170 @@ -844,17 +834,22 @@
   1.171      assert(tstart >= _blob->content_begin(), "sanity");
   1.172      assert(tend   <= _blob->content_end(),   "sanity");
   1.173    }
   1.174 -  address tcheck = tstart;  // advancing pointer to verify disjointness
   1.175 -  for (int n = 0; n < (int)SECT_LIMIT; n++) {
   1.176 +  // Verify disjointness.
   1.177 +  for (int n = (int) SECT_FIRST; n < (int) SECT_LIMIT; n++) {
   1.178      CodeSection* sect = code_section(n);
   1.179 -    if (!sect->is_allocated())  continue;
   1.180 -    assert(sect->start() >= tcheck, "sanity");
   1.181 -    tcheck = sect->start();
   1.182 -    assert((intptr_t)tcheck % sect->alignment() == 0
   1.183 +    if (!sect->is_allocated() || sect->is_empty())  continue;
   1.184 +    assert((intptr_t)sect->start() % sect->alignment() == 0
   1.185             || sect->is_empty() || _blob == NULL,
   1.186             "start is aligned");
   1.187 -    assert(sect->end()   >= tcheck, "sanity");
   1.188 -    assert(sect->end()   <= tend,   "sanity");
   1.189 +    for (int m = (int) SECT_FIRST; m < (int) SECT_LIMIT; m++) {
   1.190 +      CodeSection* other = code_section(m);
   1.191 +      if (!other->is_allocated() || other == sect)  continue;
   1.192 +      assert(!other->contains(sect->start()    ), "sanity");
   1.193 +      // limit is an exclusive address and can be the start of another
   1.194 +      // section.
   1.195 +      assert(!other->contains(sect->limit() - 1), "sanity");
   1.196 +    }
   1.197 +    assert(sect->end() <= tend, "sanity");
   1.198    }
   1.199    return true;
   1.200  }
     2.1 --- a/src/share/vm/asm/codeBuffer.hpp	Thu Aug 26 11:05:25 2010 -0700
     2.2 +++ b/src/share/vm/asm/codeBuffer.hpp	Fri Aug 27 01:51:27 2010 -0700
     2.3 @@ -289,10 +289,12 @@
     2.4   public:
     2.5    typedef int csize_t;  // code size type; would be size_t except for history
     2.6    enum {
     2.7 -    // Here is the list of all possible sections, in order of ascending address.
     2.8 +    // Here is the list of all possible sections.  The order reflects
     2.9 +    // the final layout.
    2.10 +    SECT_FIRST = 0,
    2.11 +    SECT_CONSTS = SECT_FIRST, // Non-instruction data:  Floats, jump tables, etc.
    2.12      SECT_INSTS,               // Executable instructions.
    2.13      SECT_STUBS,               // Outbound trampolines for supporting call sites.
    2.14 -    SECT_CONSTS,              // Non-instruction data:  Floats, jump tables, etc.
    2.15      SECT_LIMIT, SECT_NONE = -1
    2.16    };
    2.17  
    2.18 @@ -304,9 +306,9 @@
    2.19  
    2.20    const char*  _name;
    2.21  
    2.22 +  CodeSection  _consts;             // constants, jump tables
    2.23    CodeSection  _insts;              // instructions (the main section)
    2.24    CodeSection  _stubs;              // stubs (call site support), deopt, exception handling
    2.25 -  CodeSection  _consts;             // constants, jump tables
    2.26  
    2.27    CodeBuffer*  _before_expand;  // dead buffer, from before the last expansion
    2.28  
    2.29 @@ -334,9 +336,9 @@
    2.30    }
    2.31  
    2.32    void initialize(address code_start, csize_t code_size) {
    2.33 +    _consts.initialize_outer(this,  SECT_CONSTS);
    2.34      _insts.initialize_outer(this,   SECT_INSTS);
    2.35      _stubs.initialize_outer(this,   SECT_STUBS);
    2.36 -    _consts.initialize_outer(this,  SECT_CONSTS);
    2.37      _total_start = code_start;
    2.38      _total_size  = code_size;
    2.39      // Initialize the main section:
    2.40 @@ -414,16 +416,16 @@
    2.41    // construction.
    2.42    void initialize(csize_t code_size, csize_t locs_size);
    2.43  
    2.44 +  CodeSection* consts()            { return &_consts; }
    2.45    CodeSection* insts()             { return &_insts; }
    2.46    CodeSection* stubs()             { return &_stubs; }
    2.47 -  CodeSection* consts()            { return &_consts; }
    2.48  
    2.49 -  // present sections in order; return NULL at end; insts is #0, etc.
    2.50 +  // present sections in order; return NULL at end; consts is #0, etc.
    2.51    CodeSection* code_section(int n) {
    2.52 -    // This makes the slightly questionable but portable assumption that
    2.53 -    // the various members (_insts, _stubs, etc.) are adjacent in the
    2.54 -    // layout of CodeBuffer.
    2.55 -    CodeSection* cs = &_insts + n;
    2.56 +    // This makes the slightly questionable but portable assumption
    2.57 +    // that the various members (_consts, _insts, _stubs, etc.) are
    2.58 +    // adjacent in the layout of CodeBuffer.
    2.59 +    CodeSection* cs = &_consts + n;
    2.60      assert(cs->index() == n || !cs->is_allocated(), "sanity");
    2.61      return cs;
    2.62    }
    2.63 @@ -484,9 +486,9 @@
    2.64    // CodeBlob).
    2.65    csize_t total_content_size() const;
    2.66  
    2.67 -  // combined offset (relative to start of insts) of given address,
    2.68 -  // as eventually found in the final CodeBlob
    2.69 -  csize_t total_offset_of(address addr) const;
    2.70 +  // Combined offset (relative to start of first section) of given
    2.71 +  // section, as eventually found in the final CodeBlob.
    2.72 +  csize_t total_offset_of(CodeSection* cs) const;
    2.73  
    2.74    // allocated size of all relocation data, including index, rounded up
    2.75    csize_t total_relocation_size() const;
     3.1 --- a/src/share/vm/code/codeBlob.cpp	Thu Aug 26 11:05:25 2010 -0700
     3.2 +++ b/src/share/vm/code/codeBlob.cpp	Fri Aug 27 01:51:27 2010 -0700
     3.3 @@ -92,7 +92,7 @@
     3.4    _header_size           = header_size;
     3.5    _relocation_size       = round_to(cb->total_relocation_size(), oopSize);
     3.6    _content_offset        = align_code_offset(header_size + _relocation_size);
     3.7 -  _code_offset           = _content_offset + cb->total_offset_of(cb->insts()->start());
     3.8 +  _code_offset           = _content_offset + cb->total_offset_of(cb->insts());
     3.9    _data_offset           = _content_offset + round_to(cb->total_content_size(), oopSize);
    3.10    assert(_data_offset <= size, "codeBlob is too small");
    3.11  
     4.1 --- a/src/share/vm/code/nmethod.cpp	Thu Aug 26 11:05:25 2010 -0700
     4.2 +++ b/src/share/vm/code/nmethod.cpp	Fri Aug 27 01:51:27 2010 -0700
     4.3 @@ -87,9 +87,9 @@
     4.4    int nmethod_count;
     4.5    int total_size;
     4.6    int relocation_size;
     4.7 +  int consts_size;
     4.8    int insts_size;
     4.9    int stub_size;
    4.10 -  int consts_size;
    4.11    int scopes_data_size;
    4.12    int scopes_pcs_size;
    4.13    int dependencies_size;
    4.14 @@ -101,9 +101,9 @@
    4.15      nmethod_count += 1;
    4.16      total_size          += nm->size();
    4.17      relocation_size     += nm->relocation_size();
    4.18 +    consts_size         += nm->consts_size();
    4.19      insts_size          += nm->insts_size();
    4.20      stub_size           += nm->stub_size();
    4.21 -    consts_size         += nm->consts_size();
    4.22      oops_size           += nm->oops_size();
    4.23      scopes_data_size    += nm->scopes_data_size();
    4.24      scopes_pcs_size     += nm->scopes_pcs_size();
    4.25 @@ -116,9 +116,9 @@
    4.26      tty->print_cr("Statistics for %d bytecoded nmethods:", nmethod_count);
    4.27      if (total_size != 0)          tty->print_cr(" total in heap  = %d", total_size);
    4.28      if (relocation_size != 0)     tty->print_cr(" relocation     = %d", relocation_size);
    4.29 +    if (consts_size != 0)         tty->print_cr(" constants      = %d", consts_size);
    4.30      if (insts_size != 0)          tty->print_cr(" main code      = %d", insts_size);
    4.31      if (stub_size != 0)           tty->print_cr(" stub code      = %d", stub_size);
    4.32 -    if (consts_size != 0)         tty->print_cr(" constants      = %d", consts_size);
    4.33      if (oops_size != 0)           tty->print_cr(" oops           = %d", oops_size);
    4.34      if (scopes_data_size != 0)    tty->print_cr(" scopes data    = %d", scopes_data_size);
    4.35      if (scopes_pcs_size != 0)     tty->print_cr(" scopes pcs     = %d", scopes_pcs_size);
    4.36 @@ -404,9 +404,9 @@
    4.37  
    4.38  int nmethod::total_size() const {
    4.39    return
    4.40 +    consts_size()        +
    4.41      insts_size()         +
    4.42      stub_size()          +
    4.43 -    consts_size()        +
    4.44      scopes_data_size()   +
    4.45      scopes_pcs_size()    +
    4.46      handler_table_size() +
    4.47 @@ -789,13 +789,17 @@
    4.48      _orig_pc_offset          = orig_pc_offset;
    4.49  
    4.50      // Section offsets
    4.51 -    _consts_offset           = content_offset()      + code_buffer->total_offset_of(code_buffer->consts()->start());
    4.52 -    _stub_offset             = content_offset()      + code_buffer->total_offset_of(code_buffer->stubs()->start());
    4.53 +    _consts_offset           = content_offset()      + code_buffer->total_offset_of(code_buffer->consts());
    4.54 +    _stub_offset             = content_offset()      + code_buffer->total_offset_of(code_buffer->stubs());
    4.55  
    4.56      // Exception handler and deopt handler are in the stub section
    4.57      _exception_offset        = _stub_offset          + offsets->value(CodeOffsets::Exceptions);
    4.58      _deoptimize_offset       = _stub_offset          + offsets->value(CodeOffsets::Deopt);
    4.59 -    _deoptimize_mh_offset    = _stub_offset          + offsets->value(CodeOffsets::DeoptMH);
    4.60 +    if (has_method_handle_invokes()) {
    4.61 +      _deoptimize_mh_offset  = _stub_offset          + offsets->value(CodeOffsets::DeoptMH);
    4.62 +    } else {
    4.63 +      _deoptimize_mh_offset  = -1;
    4.64 +    }
    4.65      if (offsets->value(CodeOffsets::UnwindHandler) != -1) {
    4.66        _unwind_handler_offset = code_offset()         + offsets->value(CodeOffsets::UnwindHandler);
    4.67      } else {
    4.68 @@ -885,9 +889,9 @@
    4.69      xtty->print(" address='" INTPTR_FORMAT "'", (intptr_t) this);
    4.70  
    4.71      LOG_OFFSET(xtty, relocation);
    4.72 +    LOG_OFFSET(xtty, consts);
    4.73      LOG_OFFSET(xtty, insts);
    4.74      LOG_OFFSET(xtty, stub);
    4.75 -    LOG_OFFSET(xtty, consts);
    4.76      LOG_OFFSET(xtty, scopes_data);
    4.77      LOG_OFFSET(xtty, scopes_pcs);
    4.78      LOG_OFFSET(xtty, dependencies);
    4.79 @@ -2336,6 +2340,10 @@
    4.80                                                relocation_begin(),
    4.81                                                relocation_end(),
    4.82                                                relocation_size());
    4.83 +  if (consts_size       () > 0) tty->print_cr(" constants      [" INTPTR_FORMAT "," INTPTR_FORMAT "] = %d",
    4.84 +                                              consts_begin(),
    4.85 +                                              consts_end(),
    4.86 +                                              consts_size());
    4.87    if (insts_size        () > 0) tty->print_cr(" main code      [" INTPTR_FORMAT "," INTPTR_FORMAT "] = %d",
    4.88                                                insts_begin(),
    4.89                                                insts_end(),
    4.90 @@ -2344,10 +2352,6 @@
    4.91                                                stub_begin(),
    4.92                                                stub_end(),
    4.93                                                stub_size());
    4.94 -  if (consts_size       () > 0) tty->print_cr(" constants      [" INTPTR_FORMAT "," INTPTR_FORMAT "] = %d",
    4.95 -                                              consts_begin(),
    4.96 -                                              consts_end(),
    4.97 -                                              consts_size());
    4.98    if (oops_size         () > 0) tty->print_cr(" oops           [" INTPTR_FORMAT "," INTPTR_FORMAT "] = %d",
    4.99                                                oops_begin(),
   4.100                                                oops_end(),
   4.101 @@ -2372,10 +2376,6 @@
   4.102                                                nul_chk_table_begin(),
   4.103                                                nul_chk_table_end(),
   4.104                                                nul_chk_table_size());
   4.105 -  if (oops_size         () > 0) tty->print_cr(" oops           [" INTPTR_FORMAT "," INTPTR_FORMAT "] = %d",
   4.106 -                                              oops_begin(),
   4.107 -                                              oops_end(),
   4.108 -                                              oops_size());
   4.109  }
   4.110  
   4.111  void nmethod::print_code() {
     5.1 --- a/src/share/vm/code/nmethod.hpp	Thu Aug 26 11:05:25 2010 -0700
     5.2 +++ b/src/share/vm/code/nmethod.hpp	Fri Aug 27 01:51:27 2010 -0700
     5.3 @@ -143,8 +143,8 @@
     5.4  #ifdef HAVE_DTRACE_H
     5.5    int _trap_offset;
     5.6  #endif // def HAVE_DTRACE_H
     5.7 +  int _consts_offset;
     5.8    int _stub_offset;
     5.9 -  int _consts_offset;
    5.10    int _oops_offset;                       // offset to where embedded oop table begins (inside data)
    5.11    int _scopes_data_offset;
    5.12    int _scopes_pcs_offset;
    5.13 @@ -336,16 +336,16 @@
    5.14    bool is_compiled_by_shark() const;
    5.15  
    5.16    // boundaries for different parts
    5.17 -  address insts_begin           () const          { return code_begin(); }
    5.18 +  address consts_begin          () const          { return           header_begin() + _consts_offset        ; }
    5.19 +  address consts_end            () const          { return           header_begin() +  code_offset()        ; }
    5.20 +  address insts_begin           () const          { return           header_begin() +  code_offset()        ; }
    5.21    address insts_end             () const          { return           header_begin() + _stub_offset          ; }
    5.22 +  address stub_begin            () const          { return           header_begin() + _stub_offset          ; }
    5.23 +  address stub_end              () const          { return           header_begin() + _oops_offset          ; }
    5.24    address exception_begin       () const          { return           header_begin() + _exception_offset     ; }
    5.25    address deopt_handler_begin   () const          { return           header_begin() + _deoptimize_offset    ; }
    5.26    address deopt_mh_handler_begin() const          { return           header_begin() + _deoptimize_mh_offset ; }
    5.27    address unwind_handler_begin  () const          { return _unwind_handler_offset != -1 ? (header_begin() + _unwind_handler_offset) : NULL; }
    5.28 -  address stub_begin            () const          { return           header_begin() + _stub_offset          ; }
    5.29 -  address stub_end              () const          { return           header_begin() + _consts_offset        ; }
    5.30 -  address consts_begin          () const          { return           header_begin() + _consts_offset        ; }
    5.31 -  address consts_end            () const          { return           header_begin() + _oops_offset          ; }
    5.32    oop*    oops_begin            () const          { return (oop*)   (header_begin() + _oops_offset)         ; }
    5.33    oop*    oops_end              () const          { return (oop*)   (header_begin() + _scopes_data_offset)  ; }
    5.34  
    5.35 @@ -361,9 +361,9 @@
    5.36    address nul_chk_table_end     () const          { return           header_begin() + _nmethod_end_offset   ; }
    5.37  
    5.38    // Sizes
    5.39 +  int consts_size       () const                  { return            consts_end       () -            consts_begin       (); }
    5.40    int insts_size        () const                  { return            insts_end        () -            insts_begin        (); }
    5.41    int stub_size         () const                  { return            stub_end         () -            stub_begin         (); }
    5.42 -  int consts_size       () const                  { return            consts_end       () -            consts_begin       (); }
    5.43    int oops_size         () const                  { return (address)  oops_end         () - (address)  oops_begin         (); }
    5.44    int scopes_data_size  () const                  { return            scopes_data_end  () -            scopes_data_begin  (); }
    5.45    int scopes_pcs_size   () const                  { return (intptr_t) scopes_pcs_end   () - (intptr_t) scopes_pcs_begin   (); }
    5.46 @@ -374,9 +374,9 @@
    5.47    int total_size        () const;
    5.48  
    5.49    // Containment
    5.50 +  bool consts_contains       (address addr) const { return consts_begin       () <= addr && addr < consts_end       (); }
    5.51    bool insts_contains        (address addr) const { return insts_begin        () <= addr && addr < insts_end        (); }
    5.52    bool stub_contains         (address addr) const { return stub_begin         () <= addr && addr < stub_end         (); }
    5.53 -  bool consts_contains       (address addr) const { return consts_begin       () <= addr && addr < consts_end       (); }
    5.54    bool oops_contains         (oop*    addr) const { return oops_begin         () <= addr && addr < oops_end         (); }
    5.55    bool scopes_data_contains  (address addr) const { return scopes_data_begin  () <= addr && addr < scopes_data_end  (); }
    5.56    bool scopes_pcs_contains   (PcDesc* addr) const { return scopes_pcs_begin   () <= addr && addr < scopes_pcs_end   (); }
     6.1 --- a/src/share/vm/code/relocInfo.cpp	Thu Aug 26 11:05:25 2010 -0700
     6.2 +++ b/src/share/vm/code/relocInfo.cpp	Fri Aug 27 01:51:27 2010 -0700
     6.3 @@ -128,7 +128,16 @@
     6.4    _code    = nm;
     6.5    _current = nm->relocation_begin() - 1;
     6.6    _end     = nm->relocation_end();
     6.7 -  _addr    = (address) nm->code_begin();
     6.8 +  _addr    = nm->content_begin();
     6.9 +
    6.10 +  // Initialize code sections.
    6.11 +  _section_start[CodeBuffer::SECT_CONSTS] = nm->consts_begin();
    6.12 +  _section_start[CodeBuffer::SECT_INSTS ] = nm->insts_begin() ;
    6.13 +  _section_start[CodeBuffer::SECT_STUBS ] = nm->stub_begin()  ;
    6.14 +
    6.15 +  _section_end  [CodeBuffer::SECT_CONSTS] = nm->consts_end()  ;
    6.16 +  _section_end  [CodeBuffer::SECT_INSTS ] = nm->insts_end()   ;
    6.17 +  _section_end  [CodeBuffer::SECT_STUBS ] = nm->stub_end()    ;
    6.18  
    6.19    assert(!has_current(), "just checking");
    6.20    assert(begin == NULL || begin >= nm->code_begin(), "in bounds");
    6.21 @@ -146,9 +155,11 @@
    6.22    _code    = NULL; // Not cb->blob();
    6.23  
    6.24    CodeBuffer* cb = cs->outer();
    6.25 -  assert((int)SECT_LIMIT == CodeBuffer::SECT_LIMIT, "my copy must be equal");
    6.26 -  for (int n = 0; n < (int)SECT_LIMIT; n++) {
    6.27 -    _section_start[n] = cb->code_section(n)->start();
    6.28 +  assert((int) SECT_LIMIT == CodeBuffer::SECT_LIMIT, "my copy must be equal");
    6.29 +  for (int n = (int) CodeBuffer::SECT_FIRST; n < (int) CodeBuffer::SECT_LIMIT; n++) {
    6.30 +    CodeSection* cs = cb->code_section(n);
    6.31 +    _section_start[n] = cs->start();
    6.32 +    _section_end  [n] = cs->end();
    6.33    }
    6.34  
    6.35    assert(!has_current(), "just checking");
    6.36 @@ -166,6 +177,12 @@
    6.37  };
    6.38  
    6.39  
    6.40 +bool RelocIterator::addr_in_const() const {
    6.41 +  const int n = CodeBuffer::SECT_CONSTS;
    6.42 +  return section_start(n) <= addr() && addr() < section_end(n);
    6.43 +}
    6.44 +
    6.45 +
    6.46  static inline int num_cards(int code_size) {
    6.47    return (code_size-1) / indexCardSize;
    6.48  }
    6.49 @@ -360,31 +377,12 @@
    6.50  }
    6.51  
    6.52  
    6.53 -address RelocIterator::compute_section_start(int n) const {
    6.54 -// This routine not only computes a section start, but also
    6.55 -// memoizes it for later.
    6.56 -#define CACHE ((RelocIterator*)this)->_section_start[n]
    6.57 -  CodeBlob* cb = code();
    6.58 -  guarantee(cb != NULL, "must have a code blob");
    6.59 -  if (n == CodeBuffer::SECT_INSTS)
    6.60 -    return CACHE = cb->code_begin();
    6.61 -  assert(cb->is_nmethod(), "only nmethods have these sections");
    6.62 -  nmethod* nm = (nmethod*) cb;
    6.63 -  address res = NULL;
    6.64 -  switch (n) {
    6.65 -  case CodeBuffer::SECT_STUBS:
    6.66 -    res = nm->stub_begin();
    6.67 -    break;
    6.68 -  case CodeBuffer::SECT_CONSTS:
    6.69 -    res = nm->consts_begin();
    6.70 -    break;
    6.71 -  default:
    6.72 -    ShouldNotReachHere();
    6.73 +void RelocIterator::initialize_misc() {
    6.74 +  set_has_current(false);
    6.75 +  for (int i = (int) CodeBuffer::SECT_FIRST; i < (int) CodeBuffer::SECT_LIMIT; i++) {
    6.76 +    _section_start[i] = NULL;  // these will be lazily computed, if needed
    6.77 +    _section_end  [i] = NULL;
    6.78    }
    6.79 -  assert(nm->contains(res) || res == nm->code_end(), "tame pointer");
    6.80 -  CACHE = res;
    6.81 -  return res;
    6.82 -#undef CACHE
    6.83  }
    6.84  
    6.85  
     7.1 --- a/src/share/vm/code/relocInfo.hpp	Thu Aug 26 11:05:25 2010 -0700
     7.2 +++ b/src/share/vm/code/relocInfo.hpp	Fri Aug 27 01:51:27 2010 -0700
     7.3 @@ -1,5 +1,5 @@
     7.4  /*
     7.5 - * Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
     7.6 + * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
     7.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     7.8   *
     7.9   * This code is free software; you can redistribute it and/or modify it
    7.10 @@ -502,8 +502,7 @@
    7.11  //   }
    7.12  
    7.13  class RelocIterator : public StackObj {
    7.14 -  enum { SECT_CONSTS = 2,
    7.15 -         SECT_LIMIT = 3 };  // must be equal to CodeBuffer::SECT_LIMIT
    7.16 +  enum { SECT_LIMIT = 3 };  // must be equal to CodeBuffer::SECT_LIMIT, checked in ctor
    7.17    friend class Relocation;
    7.18    friend class relocInfo;       // for change_reloc_info_for_address only
    7.19    typedef relocInfo::relocType relocType;
    7.20 @@ -521,6 +520,7 @@
    7.21  
    7.22    // Base addresses needed to compute targets of section_word_type relocs.
    7.23    address    _section_start[SECT_LIMIT];
    7.24 +  address    _section_end  [SECT_LIMIT];
    7.25  
    7.26    void set_has_current(bool b) {
    7.27      _datalen = !b ? -1 : 0;
    7.28 @@ -540,14 +540,7 @@
    7.29  
    7.30    void advance_over_prefix();    // helper method
    7.31  
    7.32 -  void initialize_misc() {
    7.33 -    set_has_current(false);
    7.34 -    for (int i = 0; i < SECT_LIMIT; i++) {
    7.35 -      _section_start[i] = NULL;  // these will be lazily computed, if needed
    7.36 -    }
    7.37 -  }
    7.38 -
    7.39 -  address compute_section_start(int n) const;  // out-of-line helper
    7.40 +  void initialize_misc();
    7.41  
    7.42    void initialize(nmethod* nm, address begin, address limit);
    7.43  
    7.44 @@ -598,11 +591,15 @@
    7.45    bool     has_current()      const { return _datalen >= 0; }
    7.46  
    7.47    void       set_addr(address addr) { _addr = addr; }
    7.48 -  bool   addr_in_const()      const { return addr() >= section_start(SECT_CONSTS); }
    7.49 +  bool   addr_in_const()      const;
    7.50  
    7.51    address section_start(int n) const {
    7.52 -    address res = _section_start[n];
    7.53 -    return (res != NULL) ? res : compute_section_start(n);
    7.54 +    assert(_section_start[n], "must be initialized");
    7.55 +    return _section_start[n];
    7.56 +  }
    7.57 +  address section_end(int n) const {
    7.58 +    assert(_section_end[n], "must be initialized");
    7.59 +    return _section_end[n];
    7.60    }
    7.61  
    7.62    // The address points to the affected displacement part of the instruction.

mercurial