mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-23 20:44:41 +02:00
6961697: move nmethod constants section before instruction section
This is a preparation for 6961690. Reviewed-by: kvn, never
This commit is contained in:
parent
45d90a7775
commit
6a0c40f1fe
7 changed files with 122 additions and 130 deletions
|
@ -92,7 +92,7 @@ CodeBlob::CodeBlob(
|
|||
_header_size = header_size;
|
||||
_relocation_size = round_to(cb->total_relocation_size(), oopSize);
|
||||
_content_offset = align_code_offset(header_size + _relocation_size);
|
||||
_code_offset = _content_offset + cb->total_offset_of(cb->insts()->start());
|
||||
_code_offset = _content_offset + cb->total_offset_of(cb->insts());
|
||||
_data_offset = _content_offset + round_to(cb->total_content_size(), oopSize);
|
||||
assert(_data_offset <= size, "codeBlob is too small");
|
||||
|
||||
|
|
|
@ -87,9 +87,9 @@ struct nmethod_stats_struct {
|
|||
int nmethod_count;
|
||||
int total_size;
|
||||
int relocation_size;
|
||||
int consts_size;
|
||||
int insts_size;
|
||||
int stub_size;
|
||||
int consts_size;
|
||||
int scopes_data_size;
|
||||
int scopes_pcs_size;
|
||||
int dependencies_size;
|
||||
|
@ -101,9 +101,9 @@ struct nmethod_stats_struct {
|
|||
nmethod_count += 1;
|
||||
total_size += nm->size();
|
||||
relocation_size += nm->relocation_size();
|
||||
consts_size += nm->consts_size();
|
||||
insts_size += nm->insts_size();
|
||||
stub_size += nm->stub_size();
|
||||
consts_size += nm->consts_size();
|
||||
oops_size += nm->oops_size();
|
||||
scopes_data_size += nm->scopes_data_size();
|
||||
scopes_pcs_size += nm->scopes_pcs_size();
|
||||
|
@ -116,9 +116,9 @@ struct nmethod_stats_struct {
|
|||
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 (consts_size != 0) tty->print_cr(" constants = %d", consts_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);
|
||||
if (scopes_data_size != 0) tty->print_cr(" scopes data = %d", scopes_data_size);
|
||||
if (scopes_pcs_size != 0) tty->print_cr(" scopes pcs = %d", scopes_pcs_size);
|
||||
|
@ -404,9 +404,9 @@ void nmethod::add_handler_for_exception_and_pc(Handle exception, address pc, add
|
|||
|
||||
int nmethod::total_size() const {
|
||||
return
|
||||
consts_size() +
|
||||
insts_size() +
|
||||
stub_size() +
|
||||
consts_size() +
|
||||
scopes_data_size() +
|
||||
scopes_pcs_size() +
|
||||
handler_table_size() +
|
||||
|
@ -789,13 +789,17 @@ nmethod::nmethod(
|
|||
_orig_pc_offset = orig_pc_offset;
|
||||
|
||||
// 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());
|
||||
_consts_offset = content_offset() + code_buffer->total_offset_of(code_buffer->consts());
|
||||
_stub_offset = content_offset() + code_buffer->total_offset_of(code_buffer->stubs());
|
||||
|
||||
// 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);
|
||||
if (has_method_handle_invokes()) {
|
||||
_deoptimize_mh_offset = _stub_offset + offsets->value(CodeOffsets::DeoptMH);
|
||||
} else {
|
||||
_deoptimize_mh_offset = -1;
|
||||
}
|
||||
if (offsets->value(CodeOffsets::UnwindHandler) != -1) {
|
||||
_unwind_handler_offset = code_offset() + offsets->value(CodeOffsets::UnwindHandler);
|
||||
} else {
|
||||
|
@ -885,9 +889,9 @@ void nmethod::log_new_nmethod() const {
|
|||
xtty->print(" address='" INTPTR_FORMAT "'", (intptr_t) this);
|
||||
|
||||
LOG_OFFSET(xtty, relocation);
|
||||
LOG_OFFSET(xtty, consts);
|
||||
LOG_OFFSET(xtty, insts);
|
||||
LOG_OFFSET(xtty, stub);
|
||||
LOG_OFFSET(xtty, consts);
|
||||
LOG_OFFSET(xtty, scopes_data);
|
||||
LOG_OFFSET(xtty, scopes_pcs);
|
||||
LOG_OFFSET(xtty, dependencies);
|
||||
|
@ -2336,6 +2340,10 @@ void nmethod::print() const {
|
|||
relocation_begin(),
|
||||
relocation_end(),
|
||||
relocation_size());
|
||||
if (consts_size () > 0) tty->print_cr(" constants [" INTPTR_FORMAT "," INTPTR_FORMAT "] = %d",
|
||||
consts_begin(),
|
||||
consts_end(),
|
||||
consts_size());
|
||||
if (insts_size () > 0) tty->print_cr(" main code [" INTPTR_FORMAT "," INTPTR_FORMAT "] = %d",
|
||||
insts_begin(),
|
||||
insts_end(),
|
||||
|
@ -2344,10 +2352,6 @@ void nmethod::print() const {
|
|||
stub_begin(),
|
||||
stub_end(),
|
||||
stub_size());
|
||||
if (consts_size () > 0) tty->print_cr(" constants [" INTPTR_FORMAT "," INTPTR_FORMAT "] = %d",
|
||||
consts_begin(),
|
||||
consts_end(),
|
||||
consts_size());
|
||||
if (oops_size () > 0) tty->print_cr(" oops [" INTPTR_FORMAT "," INTPTR_FORMAT "] = %d",
|
||||
oops_begin(),
|
||||
oops_end(),
|
||||
|
@ -2372,10 +2376,6 @@ void nmethod::print() const {
|
|||
nul_chk_table_begin(),
|
||||
nul_chk_table_end(),
|
||||
nul_chk_table_size());
|
||||
if (oops_size () > 0) tty->print_cr(" oops [" INTPTR_FORMAT "," INTPTR_FORMAT "] = %d",
|
||||
oops_begin(),
|
||||
oops_end(),
|
||||
oops_size());
|
||||
}
|
||||
|
||||
void nmethod::print_code() {
|
||||
|
|
|
@ -143,8 +143,8 @@ class nmethod : public CodeBlob {
|
|||
#ifdef HAVE_DTRACE_H
|
||||
int _trap_offset;
|
||||
#endif // def HAVE_DTRACE_H
|
||||
int _stub_offset;
|
||||
int _consts_offset;
|
||||
int _stub_offset;
|
||||
int _oops_offset; // offset to where embedded oop table begins (inside data)
|
||||
int _scopes_data_offset;
|
||||
int _scopes_pcs_offset;
|
||||
|
@ -336,16 +336,16 @@ class nmethod : public CodeBlob {
|
|||
bool is_compiled_by_shark() const;
|
||||
|
||||
// boundaries for different parts
|
||||
address insts_begin () const { return code_begin(); }
|
||||
address consts_begin () const { return header_begin() + _consts_offset ; }
|
||||
address consts_end () const { return header_begin() + code_offset() ; }
|
||||
address insts_begin () const { return header_begin() + code_offset() ; }
|
||||
address insts_end () const { return header_begin() + _stub_offset ; }
|
||||
address stub_begin () const { return header_begin() + _stub_offset ; }
|
||||
address stub_end () const { return header_begin() + _oops_offset ; }
|
||||
address exception_begin () const { return header_begin() + _exception_offset ; }
|
||||
address deopt_handler_begin () const { return header_begin() + _deoptimize_offset ; }
|
||||
address deopt_mh_handler_begin() const { return header_begin() + _deoptimize_mh_offset ; }
|
||||
address unwind_handler_begin () const { return _unwind_handler_offset != -1 ? (header_begin() + _unwind_handler_offset) : NULL; }
|
||||
address stub_begin () const { return header_begin() + _stub_offset ; }
|
||||
address stub_end () const { return header_begin() + _consts_offset ; }
|
||||
address consts_begin () const { return header_begin() + _consts_offset ; }
|
||||
address consts_end () const { return header_begin() + _oops_offset ; }
|
||||
oop* oops_begin () const { return (oop*) (header_begin() + _oops_offset) ; }
|
||||
oop* oops_end () const { return (oop*) (header_begin() + _scopes_data_offset) ; }
|
||||
|
||||
|
@ -361,9 +361,9 @@ class nmethod : public CodeBlob {
|
|||
address nul_chk_table_end () const { return header_begin() + _nmethod_end_offset ; }
|
||||
|
||||
// Sizes
|
||||
int consts_size () const { return consts_end () - consts_begin (); }
|
||||
int insts_size () const { return insts_end () - insts_begin (); }
|
||||
int stub_size () const { return stub_end () - stub_begin (); }
|
||||
int consts_size () const { return consts_end () - consts_begin (); }
|
||||
int oops_size () const { return (address) oops_end () - (address) oops_begin (); }
|
||||
int scopes_data_size () const { return scopes_data_end () - scopes_data_begin (); }
|
||||
int scopes_pcs_size () const { return (intptr_t) scopes_pcs_end () - (intptr_t) scopes_pcs_begin (); }
|
||||
|
@ -374,9 +374,9 @@ class nmethod : public CodeBlob {
|
|||
int total_size () const;
|
||||
|
||||
// Containment
|
||||
bool consts_contains (address addr) const { return consts_begin () <= addr && addr < consts_end (); }
|
||||
bool insts_contains (address addr) const { return insts_begin () <= addr && addr < insts_end (); }
|
||||
bool stub_contains (address addr) const { return stub_begin () <= addr && addr < stub_end (); }
|
||||
bool consts_contains (address addr) const { return consts_begin () <= addr && addr < consts_end (); }
|
||||
bool oops_contains (oop* addr) const { return oops_begin () <= addr && addr < oops_end (); }
|
||||
bool scopes_data_contains (address addr) const { return scopes_data_begin () <= addr && addr < scopes_data_end (); }
|
||||
bool scopes_pcs_contains (PcDesc* addr) const { return scopes_pcs_begin () <= addr && addr < scopes_pcs_end (); }
|
||||
|
|
|
@ -128,7 +128,16 @@ void RelocIterator::initialize(nmethod* nm, address begin, address limit) {
|
|||
_code = nm;
|
||||
_current = nm->relocation_begin() - 1;
|
||||
_end = nm->relocation_end();
|
||||
_addr = (address) nm->code_begin();
|
||||
_addr = nm->content_begin();
|
||||
|
||||
// Initialize code sections.
|
||||
_section_start[CodeBuffer::SECT_CONSTS] = nm->consts_begin();
|
||||
_section_start[CodeBuffer::SECT_INSTS ] = nm->insts_begin() ;
|
||||
_section_start[CodeBuffer::SECT_STUBS ] = nm->stub_begin() ;
|
||||
|
||||
_section_end [CodeBuffer::SECT_CONSTS] = nm->consts_end() ;
|
||||
_section_end [CodeBuffer::SECT_INSTS ] = nm->insts_end() ;
|
||||
_section_end [CodeBuffer::SECT_STUBS ] = nm->stub_end() ;
|
||||
|
||||
assert(!has_current(), "just checking");
|
||||
assert(begin == NULL || begin >= nm->code_begin(), "in bounds");
|
||||
|
@ -146,9 +155,11 @@ RelocIterator::RelocIterator(CodeSection* cs, address begin, address limit) {
|
|||
_code = NULL; // Not cb->blob();
|
||||
|
||||
CodeBuffer* cb = cs->outer();
|
||||
assert((int)SECT_LIMIT == CodeBuffer::SECT_LIMIT, "my copy must be equal");
|
||||
for (int n = 0; n < (int)SECT_LIMIT; n++) {
|
||||
_section_start[n] = cb->code_section(n)->start();
|
||||
assert((int) SECT_LIMIT == CodeBuffer::SECT_LIMIT, "my copy must be equal");
|
||||
for (int n = (int) CodeBuffer::SECT_FIRST; n < (int) CodeBuffer::SECT_LIMIT; n++) {
|
||||
CodeSection* cs = cb->code_section(n);
|
||||
_section_start[n] = cs->start();
|
||||
_section_end [n] = cs->end();
|
||||
}
|
||||
|
||||
assert(!has_current(), "just checking");
|
||||
|
@ -166,6 +177,12 @@ struct RelocIndexEntry {
|
|||
};
|
||||
|
||||
|
||||
bool RelocIterator::addr_in_const() const {
|
||||
const int n = CodeBuffer::SECT_CONSTS;
|
||||
return section_start(n) <= addr() && addr() < section_end(n);
|
||||
}
|
||||
|
||||
|
||||
static inline int num_cards(int code_size) {
|
||||
return (code_size-1) / indexCardSize;
|
||||
}
|
||||
|
@ -360,31 +377,12 @@ void RelocIterator::advance_over_prefix() {
|
|||
}
|
||||
|
||||
|
||||
address RelocIterator::compute_section_start(int n) const {
|
||||
// This routine not only computes a section start, but also
|
||||
// memoizes it for later.
|
||||
#define CACHE ((RelocIterator*)this)->_section_start[n]
|
||||
CodeBlob* cb = code();
|
||||
guarantee(cb != NULL, "must have a code blob");
|
||||
if (n == CodeBuffer::SECT_INSTS)
|
||||
return CACHE = cb->code_begin();
|
||||
assert(cb->is_nmethod(), "only nmethods have these sections");
|
||||
nmethod* nm = (nmethod*) cb;
|
||||
address res = NULL;
|
||||
switch (n) {
|
||||
case CodeBuffer::SECT_STUBS:
|
||||
res = nm->stub_begin();
|
||||
break;
|
||||
case CodeBuffer::SECT_CONSTS:
|
||||
res = nm->consts_begin();
|
||||
break;
|
||||
default:
|
||||
ShouldNotReachHere();
|
||||
void RelocIterator::initialize_misc() {
|
||||
set_has_current(false);
|
||||
for (int i = (int) CodeBuffer::SECT_FIRST; i < (int) CodeBuffer::SECT_LIMIT; i++) {
|
||||
_section_start[i] = NULL; // these will be lazily computed, if needed
|
||||
_section_end [i] = NULL;
|
||||
}
|
||||
assert(nm->contains(res) || res == nm->code_end(), "tame pointer");
|
||||
CACHE = res;
|
||||
return res;
|
||||
#undef CACHE
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -502,8 +502,7 @@ class RelocationHolder VALUE_OBJ_CLASS_SPEC {
|
|||
// }
|
||||
|
||||
class RelocIterator : public StackObj {
|
||||
enum { SECT_CONSTS = 2,
|
||||
SECT_LIMIT = 3 }; // must be equal to CodeBuffer::SECT_LIMIT
|
||||
enum { SECT_LIMIT = 3 }; // must be equal to CodeBuffer::SECT_LIMIT, checked in ctor
|
||||
friend class Relocation;
|
||||
friend class relocInfo; // for change_reloc_info_for_address only
|
||||
typedef relocInfo::relocType relocType;
|
||||
|
@ -521,6 +520,7 @@ class RelocIterator : public StackObj {
|
|||
|
||||
// Base addresses needed to compute targets of section_word_type relocs.
|
||||
address _section_start[SECT_LIMIT];
|
||||
address _section_end [SECT_LIMIT];
|
||||
|
||||
void set_has_current(bool b) {
|
||||
_datalen = !b ? -1 : 0;
|
||||
|
@ -540,14 +540,7 @@ class RelocIterator : public StackObj {
|
|||
|
||||
void advance_over_prefix(); // helper method
|
||||
|
||||
void initialize_misc() {
|
||||
set_has_current(false);
|
||||
for (int i = 0; i < SECT_LIMIT; i++) {
|
||||
_section_start[i] = NULL; // these will be lazily computed, if needed
|
||||
}
|
||||
}
|
||||
|
||||
address compute_section_start(int n) const; // out-of-line helper
|
||||
void initialize_misc();
|
||||
|
||||
void initialize(nmethod* nm, address begin, address limit);
|
||||
|
||||
|
@ -598,11 +591,15 @@ class RelocIterator : public StackObj {
|
|||
bool has_current() const { return _datalen >= 0; }
|
||||
|
||||
void set_addr(address addr) { _addr = addr; }
|
||||
bool addr_in_const() const { return addr() >= section_start(SECT_CONSTS); }
|
||||
bool addr_in_const() const;
|
||||
|
||||
address section_start(int n) const {
|
||||
address res = _section_start[n];
|
||||
return (res != NULL) ? res : compute_section_start(n);
|
||||
assert(_section_start[n], "must be initialized");
|
||||
return _section_start[n];
|
||||
}
|
||||
address section_end(int n) const {
|
||||
assert(_section_end[n], "must be initialized");
|
||||
return _section_end[n];
|
||||
}
|
||||
|
||||
// The address points to the affected displacement part of the instruction.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue