Index: src/x64/macro-assembler-x64.cc |
=================================================================== |
--- src/x64/macro-assembler-x64.cc (revision 12237) |
+++ src/x64/macro-assembler-x64.cc (working copy) |
@@ -53,9 +53,17 @@ |
} |
-static intptr_t RootRegisterDelta(ExternalReference other, Isolate* isolate) { |
+static const int kInvalidRootRegisterDelta = -1; |
+ |
+ |
+intptr_t MacroAssembler::RootRegisterDelta(ExternalReference other) { |
+ if (predictable_code_size() && |
+ (other.address() < reinterpret_cast<Address>(isolate()) || |
+ other.address() >= reinterpret_cast<Address>(isolate() + 1))) { |
+ return kInvalidRootRegisterDelta; |
+ } |
Address roots_register_value = kRootRegisterBias + |
- reinterpret_cast<Address>(isolate->heap()->roots_array_start()); |
+ reinterpret_cast<Address>(isolate()->heap()->roots_array_start()); |
intptr_t delta = other.address() - roots_register_value; |
return delta; |
} |
@@ -64,8 +72,8 @@ |
Operand MacroAssembler::ExternalOperand(ExternalReference target, |
Register scratch) { |
if (root_array_available_ && !Serializer::enabled()) { |
- intptr_t delta = RootRegisterDelta(target, isolate()); |
- if (is_int32(delta)) { |
+ intptr_t delta = RootRegisterDelta(target); |
+ if (delta != kInvalidRootRegisterDelta && is_int32(delta)) { |
Serializer::TooLateToEnableNow(); |
return Operand(kRootRegister, static_cast<int32_t>(delta)); |
} |
@@ -77,8 +85,8 @@ |
void MacroAssembler::Load(Register destination, ExternalReference source) { |
if (root_array_available_ && !Serializer::enabled()) { |
- intptr_t delta = RootRegisterDelta(source, isolate()); |
- if (is_int32(delta)) { |
+ intptr_t delta = RootRegisterDelta(source); |
+ if (delta != kInvalidRootRegisterDelta && is_int32(delta)) { |
Serializer::TooLateToEnableNow(); |
movq(destination, Operand(kRootRegister, static_cast<int32_t>(delta))); |
return; |
@@ -96,8 +104,8 @@ |
void MacroAssembler::Store(ExternalReference destination, Register source) { |
if (root_array_available_ && !Serializer::enabled()) { |
- intptr_t delta = RootRegisterDelta(destination, isolate()); |
- if (is_int32(delta)) { |
+ intptr_t delta = RootRegisterDelta(destination); |
+ if (delta != kInvalidRootRegisterDelta && is_int32(delta)) { |
Serializer::TooLateToEnableNow(); |
movq(Operand(kRootRegister, static_cast<int32_t>(delta)), source); |
return; |
@@ -116,8 +124,8 @@ |
void MacroAssembler::LoadAddress(Register destination, |
ExternalReference source) { |
if (root_array_available_ && !Serializer::enabled()) { |
- intptr_t delta = RootRegisterDelta(source, isolate()); |
- if (is_int32(delta)) { |
+ intptr_t delta = RootRegisterDelta(source); |
+ if (delta != kInvalidRootRegisterDelta && is_int32(delta)) { |
Serializer::TooLateToEnableNow(); |
lea(destination, Operand(kRootRegister, static_cast<int32_t>(delta))); |
return; |
@@ -133,8 +141,8 @@ |
// 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, isolate()); |
- if (is_int32(delta)) { |
+ intptr_t delta = RootRegisterDelta(source); |
+ if (delta != kInvalidRootRegisterDelta && is_int32(delta)) { |
Serializer::TooLateToEnableNow(); |
// Operand is lea(scratch, Operand(kRootRegister, delta)); |
// Opcodes : REX.W 8D ModRM Disp8/Disp32 - 4 or 7. |
@@ -216,7 +224,7 @@ |
Register scratch, |
SaveFPRegsMode save_fp, |
RememberedSetFinalAction and_then) { |
- if (FLAG_debug_code) { |
+ if (emit_debug_code()) { |
Label ok; |
JumpIfNotInNewSpace(object, scratch, &ok, Label::kNear); |
int3(); |
@@ -397,7 +405,7 @@ |
return; |
} |
- if (FLAG_debug_code) { |
+ if (emit_debug_code()) { |
Label ok; |
cmpq(value, Operand(address, 0)); |
j(equal, &ok, Label::kNear); |
@@ -3992,7 +4000,7 @@ |
int min_length, |
Register scratch) { |
ASSERT(min_length >= 0); |
- if (FLAG_debug_code) { |
+ if (emit_debug_code()) { |
cmpl(length, Immediate(min_length)); |
Assert(greater_equal, "Invalid min_length"); |
} |
@@ -4369,7 +4377,7 @@ |
testq(Operand(bitmap_scratch, MemoryChunk::kHeaderSize), mask_scratch); |
j(not_zero, &done, Label::kNear); |
- if (FLAG_debug_code) { |
+ if (emit_debug_code()) { |
// Check for impossible bit pattern. |
Label ok; |
push(mask_scratch); |