Commit 3416e7bc authored by haitao.feng@intel.com's avatar haitao.feng@intel.com

Return int64_t instead of intptr_t for RootRegisterDelta and support x32 as well.

R=verwaest@chromium.org

Review URL: https://codereview.chromium.org/236753002

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20863 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 6e405733
......@@ -54,10 +54,10 @@ MacroAssembler::MacroAssembler(Isolate* arg_isolate, void* buffer, int size)
}
static const int kInvalidRootRegisterDelta = -1;
static const int64_t kInvalidRootRegisterDelta = -1;
intptr_t MacroAssembler::RootRegisterDelta(ExternalReference other) {
int64_t MacroAssembler::RootRegisterDelta(ExternalReference other) {
if (predictable_code_size() &&
(other.address() < reinterpret_cast<Address>(isolate()) ||
other.address() >= reinterpret_cast<Address>(isolate() + 1))) {
......@@ -65,7 +65,18 @@ intptr_t MacroAssembler::RootRegisterDelta(ExternalReference other) {
}
Address roots_register_value = kRootRegisterBias +
reinterpret_cast<Address>(isolate()->heap()->roots_array_start());
intptr_t delta = other.address() - roots_register_value;
int64_t delta = kInvalidRootRegisterDelta; // Bogus initialization.
if (kPointerSize == kInt64Size) {
delta = other.address() - roots_register_value;
} else {
// For x32, zero extend the address to 64-bit and calculate the delta.
uint64_t o = static_cast<uint32_t>(
reinterpret_cast<intptr_t>(other.address()));
uint64_t r = static_cast<uint32_t>(
reinterpret_cast<intptr_t>(roots_register_value));
delta = o - r;
}
return delta;
}
......@@ -73,7 +84,7 @@ intptr_t MacroAssembler::RootRegisterDelta(ExternalReference other) {
Operand MacroAssembler::ExternalOperand(ExternalReference target,
Register scratch) {
if (root_array_available_ && !Serializer::enabled()) {
intptr_t delta = RootRegisterDelta(target);
int64_t delta = RootRegisterDelta(target);
if (delta != kInvalidRootRegisterDelta && is_int32(delta)) {
return Operand(kRootRegister, static_cast<int32_t>(delta));
}
......@@ -85,7 +96,7 @@ Operand MacroAssembler::ExternalOperand(ExternalReference target,
void MacroAssembler::Load(Register destination, ExternalReference source) {
if (root_array_available_ && !Serializer::enabled()) {
intptr_t delta = RootRegisterDelta(source);
int64_t delta = RootRegisterDelta(source);
if (delta != kInvalidRootRegisterDelta && is_int32(delta)) {
movp(destination, Operand(kRootRegister, static_cast<int32_t>(delta)));
return;
......@@ -103,7 +114,7 @@ void MacroAssembler::Load(Register destination, ExternalReference source) {
void MacroAssembler::Store(ExternalReference destination, Register source) {
if (root_array_available_ && !Serializer::enabled()) {
intptr_t delta = RootRegisterDelta(destination);
int64_t delta = RootRegisterDelta(destination);
if (delta != kInvalidRootRegisterDelta && is_int32(delta)) {
movp(Operand(kRootRegister, static_cast<int32_t>(delta)), source);
return;
......@@ -122,7 +133,7 @@ void MacroAssembler::Store(ExternalReference destination, Register source) {
void MacroAssembler::LoadAddress(Register destination,
ExternalReference source) {
if (root_array_available_ && !Serializer::enabled()) {
intptr_t delta = RootRegisterDelta(source);
int64_t delta = RootRegisterDelta(source);
if (delta != kInvalidRootRegisterDelta && is_int32(delta)) {
leap(destination, Operand(kRootRegister, static_cast<int32_t>(delta)));
return;
......@@ -138,7 +149,7 @@ int MacroAssembler::LoadAddressSize(ExternalReference source) {
// This calculation depends on the internals of LoadAddress.
// It's correctness is ensured by the asserts in the Call
// instruction below.
intptr_t delta = RootRegisterDelta(source);
int64_t delta = RootRegisterDelta(source);
if (delta != kInvalidRootRegisterDelta && is_int32(delta)) {
// Operand is leap(scratch, Operand(kRootRegister, delta));
// Opcodes : REX.W 8D ModRM Disp8/Disp32 - 4 or 7.
......
......@@ -1465,7 +1465,7 @@ class MacroAssembler: public Assembler {
// modified. It may be the "smi 1 constant" register.
Register GetSmiConstant(Smi* value);
intptr_t RootRegisterDelta(ExternalReference other);
int64_t RootRegisterDelta(ExternalReference other);
// Moves the smi value to the destination register.
void LoadSmiConstant(Register dst, Smi* value);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment