This commit is contained in:
Vladimir Kozlov 2014-02-20 12:20:56 -08:00
commit 4200d0d095
358 changed files with 58894 additions and 1801 deletions

View file

@ -597,7 +597,7 @@ nmethod* nmethod::new_nmethod(methodHandle method,
InstanceKlass::cast(klass)->add_dependent_nmethod(nm);
}
NOT_PRODUCT(nmethod_stats.note_nmethod(nm));
if (PrintAssembly) {
if (PrintAssembly || CompilerOracle::has_option_string(method, "PrintAssembly")) {
Disassembler::decode(nm);
}
}

View file

@ -582,6 +582,18 @@ void static_stub_Relocation::unpack_data() {
_static_call = address_from_scaled_offset(unpack_1_int(), base);
}
void trampoline_stub_Relocation::pack_data_to(CodeSection* dest ) {
short* p = (short*) dest->locs_end();
CodeSection* insts = dest->outer()->insts();
normalize_address(_owner, insts);
p = pack_1_int_to(p, scaled_offset(_owner, insts->start()));
dest->set_locs_end((relocInfo*) p);
}
void trampoline_stub_Relocation::unpack_data() {
address base = binding()->section_start(CodeBuffer::SECT_INSTS);
_owner = address_from_scaled_offset(unpack_1_int(), base);
}
void external_word_Relocation::pack_data_to(CodeSection* dest) {
short* p = (short*) dest->locs_end();
@ -811,6 +823,25 @@ address static_call_Relocation::static_stub() {
return NULL;
}
// Finds the trampoline address for a call. If no trampoline stub is
// found NULL is returned which can be handled by the caller.
address trampoline_stub_Relocation::get_trampoline_for(address call, nmethod* code) {
// There are no relocations available when the code gets relocated
// because of CodeBuffer expansion.
if (code->relocation_size() == 0)
return NULL;
RelocIterator iter(code, call);
while (iter.next()) {
if (iter.type() == relocInfo::trampoline_stub_type) {
if (iter.trampoline_stub_reloc()->owner() == call) {
return iter.addr();
}
}
}
return NULL;
}
void static_stub_Relocation::clear_inline_cache() {
// Call stub is only used when calling the interpreted code.
@ -975,6 +1006,12 @@ void RelocIterator::print_current() {
tty->print(" | [static_call=" INTPTR_FORMAT "]", r->static_call());
break;
}
case relocInfo::trampoline_stub_type:
{
trampoline_stub_Relocation* r = (trampoline_stub_Relocation*) reloc();
tty->print(" | [trampoline owner=" INTPTR_FORMAT "]", r->owner());
break;
}
}
tty->cr();
}

View file

@ -260,8 +260,8 @@ class relocInfo VALUE_OBJ_CLASS_SPEC {
poll_type = 10, // polling instruction for safepoints
poll_return_type = 11, // polling instruction for safepoints at return
metadata_type = 12, // metadata that used to be oops
yet_unused_type_1 = 13, // Still unused
yet_unused_type_2 = 14, // Still unused
trampoline_stub_type = 13, // stub-entry for trampoline
yet_unused_type_1 = 14, // Still unused
data_prefix_tag = 15, // tag for a prefix (carries data arguments)
type_mask = 15 // A mask which selects only the above values
};
@ -301,6 +301,7 @@ class relocInfo VALUE_OBJ_CLASS_SPEC {
visitor(poll) \
visitor(poll_return) \
visitor(section_word) \
visitor(trampoline_stub) \
public:
@ -364,7 +365,7 @@ class relocInfo VALUE_OBJ_CLASS_SPEC {
// "immediate" in the prefix header word itself. This optimization
// is invisible outside this module.)
inline friend relocInfo prefix_relocInfo(int datalen = 0);
inline friend relocInfo prefix_relocInfo(int datalen);
protected:
// an immediate relocInfo optimizes a prefix with one 10-bit unsigned value
@ -459,7 +460,7 @@ inline relocInfo filler_relocInfo() {
return relocInfo(relocInfo::none, relocInfo::offset_limit() - relocInfo::offset_unit);
}
inline relocInfo prefix_relocInfo(int datalen) {
inline relocInfo prefix_relocInfo(int datalen = 0) {
assert(relocInfo::fits_into_immediate(datalen), "datalen in limits");
return relocInfo(relocInfo::data_prefix_tag, relocInfo::RAW_BITS, relocInfo::datalen_tag | datalen);
}
@ -1150,6 +1151,43 @@ class runtime_call_Relocation : public CallRelocation {
public:
};
// Trampoline Relocations.
// A trampoline allows to encode a small branch in the code, even if there
// is the chance that this branch can not reach all possible code locations.
// If the relocation finds that a branch is too far for the instruction
// in the code, it can patch it to jump to the trampoline where is
// sufficient space for a far branch. Needed on PPC.
class trampoline_stub_Relocation : public Relocation {
relocInfo::relocType type() { return relocInfo::trampoline_stub_type; }
public:
static RelocationHolder spec(address static_call) {
RelocationHolder rh = newHolder();
return (new (rh) trampoline_stub_Relocation(static_call));
}
private:
address _owner; // Address of the NativeCall that owns the trampoline.
trampoline_stub_Relocation(address owner) {
_owner = owner;
}
friend class RelocIterator;
trampoline_stub_Relocation() { }
public:
// Return the address of the NativeCall that owns the trampoline.
address owner() { return _owner; }
void pack_data_to(CodeSection * dest);
void unpack_data();
// Find the trampoline stub for a call.
static address get_trampoline_for(address call, nmethod* code);
};
class external_word_Relocation : public DataRelocation {
relocInfo::relocType type() { return relocInfo::external_word_type; }

View file

@ -36,6 +36,9 @@
#ifdef TARGET_OS_FAMILY_windows
# include "os_windows.inline.hpp"
#endif
#ifdef TARGET_OS_FAMILY_aix
# include "os_aix.inline.hpp"
#endif
#ifdef TARGET_OS_FAMILY_bsd
# include "os_bsd.inline.hpp"
#endif

View file

@ -47,8 +47,11 @@
#ifdef TARGET_ARCH_MODEL_arm
# include "adfiles/adGlobals_arm.hpp"
#endif
#ifdef TARGET_ARCH_MODEL_ppc
# include "adfiles/adGlobals_ppc.hpp"
#ifdef TARGET_ARCH_MODEL_ppc_32
# include "adfiles/adGlobals_ppc_32.hpp"
#endif
#ifdef TARGET_ARCH_MODEL_ppc_64
# include "adfiles/adGlobals_ppc_64.hpp"
#endif
#endif
@ -70,7 +73,7 @@ friend class OptoReg;
// friend class Location;
private:
enum {
BAD = -1
BAD_REG = -1
};
@ -83,7 +86,7 @@ private:
public:
static VMReg as_VMReg(int val, bool bad_ok = false) { assert(val > BAD || bad_ok, "invalid"); return (VMReg) (intptr_t) val; }
static VMReg as_VMReg(int val, bool bad_ok = false) { assert(val > BAD_REG || bad_ok, "invalid"); return (VMReg) (intptr_t) val; }
const char* name() {
if (is_reg()) {
@ -95,8 +98,8 @@ public:
return "STACKED REG";
}
}
static VMReg Bad() { return (VMReg) (intptr_t) BAD; }
bool is_valid() const { return ((intptr_t) this) != BAD; }
static VMReg Bad() { return (VMReg) (intptr_t) BAD_REG; }
bool is_valid() const { return ((intptr_t) this) != BAD_REG; }
bool is_stack() const { return (intptr_t) this >= (intptr_t) stack0; }
bool is_reg() const { return is_valid() && !is_stack(); }