X64 implementation: Change argument to relocator to take a 64-bit delta. Change maximum relocation info encoding length.
Review URL: http://codereview.chromium.org/146021 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@2252 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
7f14958fd4
commit
c19fde4f1c
@ -50,7 +50,7 @@ Condition NegateCondition(Condition cc) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void RelocInfo::apply(int delta) {
|
void RelocInfo::apply(intptr_t delta) {
|
||||||
if (RelocInfo::IsInternalReference(rmode_)) {
|
if (RelocInfo::IsInternalReference(rmode_)) {
|
||||||
// absolute code pointer inside code object moves with the code object.
|
// absolute code pointer inside code object moves with the code object.
|
||||||
int32_t* p = reinterpret_cast<int32_t*>(pc_);
|
int32_t* p = reinterpret_cast<int32_t*>(pc_);
|
||||||
|
@ -183,7 +183,7 @@ class RelocInfo BASE_EMBEDDED {
|
|||||||
intptr_t data() const { return data_; }
|
intptr_t data() const { return data_; }
|
||||||
|
|
||||||
// Apply a relocation by delta bytes
|
// Apply a relocation by delta bytes
|
||||||
INLINE(void apply(int delta));
|
INLINE(void apply(intptr_t delta));
|
||||||
|
|
||||||
// Read/modify the code target in the branch/call instruction
|
// Read/modify the code target in the branch/call instruction
|
||||||
// this relocation applies to;
|
// this relocation applies to;
|
||||||
@ -265,8 +265,12 @@ class RelocInfoWriter BASE_EMBEDDED {
|
|||||||
last_pc_ = pc;
|
last_pc_ = pc;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Max size (bytes) of a written RelocInfo.
|
// Max size (bytes) of a written RelocInfo. Longest encoding is
|
||||||
static const int kMaxSize = 12;
|
// ExtraTag, VariableLengthPCJump, ExtraTag, pc_delta, ExtraTag, data_delta.
|
||||||
|
// On ia32 and arm this is 1 + 4 + 1 + 1 + 1 + 4 = 12.
|
||||||
|
// On x64 this is 1 + 4 + 1 + 1 + 1 + 8 == 16;
|
||||||
|
// Here we use the maximum of the two.
|
||||||
|
static const int kMaxSize = 16;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
inline uint32_t WriteVariableLengthPCJump(uint32_t pc_delta);
|
inline uint32_t WriteVariableLengthPCJump(uint32_t pc_delta);
|
||||||
|
@ -48,7 +48,7 @@ Condition NegateCondition(Condition cc) {
|
|||||||
|
|
||||||
|
|
||||||
// The modes possibly affected by apply must be in kApplyMask.
|
// The modes possibly affected by apply must be in kApplyMask.
|
||||||
void RelocInfo::apply(int delta) {
|
void RelocInfo::apply(intptr_t delta) {
|
||||||
if (rmode_ == RUNTIME_ENTRY || IsCodeTarget(rmode_)) {
|
if (rmode_ == RUNTIME_ENTRY || IsCodeTarget(rmode_)) {
|
||||||
int32_t* p = reinterpret_cast<int32_t*>(pc_);
|
int32_t* p = reinterpret_cast<int32_t*>(pc_);
|
||||||
*p -= delta; // relocate entry
|
*p -= delta; // relocate entry
|
||||||
|
@ -396,10 +396,15 @@ class CpuFeatures : public AllStatic {
|
|||||||
|
|
||||||
class Assembler : public Malloced {
|
class Assembler : public Malloced {
|
||||||
private:
|
private:
|
||||||
// The relocation writer's position is kGap bytes below the end of
|
// We check before assembling an instruction that there is sufficient
|
||||||
|
// space to write an instruction and its relocation information.
|
||||||
|
// The relocation writer's position must be kGap bytes above the end of
|
||||||
// the generated instructions. This leaves enough space for the
|
// the generated instructions. This leaves enough space for the
|
||||||
// longest possible ia32 instruction (17 bytes as of 9/26/06) and
|
// longest possible ia32 instruction, 15 bytes, and the longest possible
|
||||||
// allows for a single, fast space check per instruction.
|
// relocation information encoding, RelocInfoWriter::kMaxLength == 16.
|
||||||
|
// (There is a 15 byte limit on ia32 instruction length that rules out some
|
||||||
|
// otherwise valid instructions.)
|
||||||
|
// This allows for a single, fast space check per instruction.
|
||||||
static const int kGap = 32;
|
static const int kGap = 32;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -147,11 +147,8 @@ void Assembler::set_target_address_at(Address pc, Address target) {
|
|||||||
// Implementation of RelocInfo
|
// Implementation of RelocInfo
|
||||||
|
|
||||||
// The modes possibly affected by apply must be in kApplyMask.
|
// The modes possibly affected by apply must be in kApplyMask.
|
||||||
void RelocInfo::apply(int delta) {
|
void RelocInfo::apply(intptr_t delta) {
|
||||||
if (rmode_ == RUNTIME_ENTRY || IsCodeTarget(rmode_)) {
|
if (IsInternalReference(rmode_)) {
|
||||||
intptr_t* p = reinterpret_cast<intptr_t*>(pc_);
|
|
||||||
*p -= delta; // relocate entry
|
|
||||||
} else if (IsInternalReference(rmode_)) {
|
|
||||||
// absolute code pointer inside code object moves with the code object.
|
// absolute code pointer inside code object moves with the code object.
|
||||||
intptr_t* p = reinterpret_cast<intptr_t*>(pc_);
|
intptr_t* p = reinterpret_cast<intptr_t*>(pc_);
|
||||||
*p += delta; // relocate entry
|
*p += delta; // relocate entry
|
||||||
|
@ -341,8 +341,9 @@ void Assembler::GrowBuffer() {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// copy the data
|
// copy the data
|
||||||
int pc_delta = desc.buffer - buffer_;
|
intptr_t pc_delta = desc.buffer - buffer_;
|
||||||
int rc_delta = (desc.buffer + desc.buffer_size) - (buffer_ + buffer_size_);
|
intptr_t rc_delta = (desc.buffer + desc.buffer_size) -
|
||||||
|
(buffer_ + buffer_size_);
|
||||||
memmove(desc.buffer, buffer_, desc.instr_size);
|
memmove(desc.buffer, buffer_, desc.instr_size);
|
||||||
memmove(rc_delta + reloc_info_writer.pos(),
|
memmove(rc_delta + reloc_info_writer.pos(),
|
||||||
reloc_info_writer.pos(), desc.reloc_size);
|
reloc_info_writer.pos(), desc.reloc_size);
|
||||||
@ -365,11 +366,8 @@ void Assembler::GrowBuffer() {
|
|||||||
// relocate runtime entries
|
// relocate runtime entries
|
||||||
for (RelocIterator it(desc); !it.done(); it.next()) {
|
for (RelocIterator it(desc); !it.done(); it.next()) {
|
||||||
RelocInfo::Mode rmode = it.rinfo()->rmode();
|
RelocInfo::Mode rmode = it.rinfo()->rmode();
|
||||||
if (rmode == RelocInfo::RUNTIME_ENTRY) {
|
if (rmode == RelocInfo::INTERNAL_REFERENCE) {
|
||||||
int32_t* p = reinterpret_cast<int32_t*>(it.rinfo()->pc());
|
intptr_t* p = reinterpret_cast<intptr_t*>(it.rinfo()->pc());
|
||||||
*p -= pc_delta; // relocate entry
|
|
||||||
} else if (rmode == RelocInfo::INTERNAL_REFERENCE) {
|
|
||||||
int32_t* p = reinterpret_cast<int32_t*>(it.rinfo()->pc());
|
|
||||||
if (*p != 0) { // 0 means uninitialized.
|
if (*p != 0) { // 0 means uninitialized.
|
||||||
*p += pc_delta;
|
*p += pc_delta;
|
||||||
}
|
}
|
||||||
@ -1825,9 +1823,7 @@ void Assembler::WriteRecordedPositions() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const int RelocInfo::kApplyMask =
|
const int RelocInfo::kApplyMask = 1 << RelocInfo::INTERNAL_REFERENCE;
|
||||||
RelocInfo::kCodeTargetMask | 1 << RelocInfo::RUNTIME_ENTRY |
|
|
||||||
1 << RelocInfo::JS_RETURN | 1 << RelocInfo::INTERNAL_REFERENCE;
|
|
||||||
|
|
||||||
|
|
||||||
} } // namespace v8::internal
|
} } // namespace v8::internal
|
||||||
|
@ -378,11 +378,15 @@ class CpuFeatures : public AllStatic {
|
|||||||
|
|
||||||
class Assembler : public Malloced {
|
class Assembler : public Malloced {
|
||||||
private:
|
private:
|
||||||
// The relocation writer's position is kGap bytes below the end of
|
// We check before assembling an instruction that there is sufficient
|
||||||
|
// space to write an instruction and its relocation information.
|
||||||
|
// The relocation writer's position must be kGap bytes above the end of
|
||||||
// the generated instructions. This leaves enough space for the
|
// the generated instructions. This leaves enough space for the
|
||||||
// longest possible x64 instruction (There is a 15 byte limit on
|
// longest possible x64 instruction, 15 bytes, and the longest possible
|
||||||
// instruction length, ruling out some otherwise valid instructions) and
|
// relocation information encoding, RelocInfoWriter::kMaxLength == 16.
|
||||||
// allows for a single, fast space check per instruction.
|
// (There is a 15 byte limit on x64 instruction length that rules out some
|
||||||
|
// otherwise valid instructions.)
|
||||||
|
// This allows for a single, fast space check per instruction.
|
||||||
static const int kGap = 32;
|
static const int kGap = 32;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
Loading…
Reference in New Issue
Block a user