Index: src/x64/macro-assembler-x64.cc |
diff --git a/src/x64/macro-assembler-x64.cc b/src/x64/macro-assembler-x64.cc |
index 693a5c6b8d4118305ee864e1754106e65fd193af..edbb49eb65f02abcda0e602127844af893b7c675 100644 |
--- a/src/x64/macro-assembler-x64.cc |
+++ b/src/x64/macro-assembler-x64.cc |
@@ -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)) { |
Serializer::TooLateToEnableNow(); |
return Operand(kRootRegister, static_cast<int32_t>(delta)); |
@@ -86,7 +97,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)) { |
Serializer::TooLateToEnableNow(); |
movp(destination, Operand(kRootRegister, static_cast<int32_t>(delta))); |
@@ -105,7 +116,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)) { |
Serializer::TooLateToEnableNow(); |
movp(Operand(kRootRegister, static_cast<int32_t>(delta)), source); |
@@ -125,7 +136,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)) { |
Serializer::TooLateToEnableNow(); |
leap(destination, Operand(kRootRegister, static_cast<int32_t>(delta))); |
@@ -142,7 +153,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)) { |
Serializer::TooLateToEnableNow(); |
// Operand is leap(scratch, Operand(kRootRegister, delta)); |