diff --git a/src/x64/macro-assembler-x64.cc b/src/x64/macro-assembler-x64.cc index 12e653cc48..53becf6c3c 100644 --- a/src/x64/macro-assembler-x64.cc +++ b/src/x64/macro-assembler-x64.cc @@ -150,6 +150,20 @@ int MacroAssembler::LoadAddressSize(ExternalReference source) { } +void MacroAssembler::PushAddress(ExternalReference source) { + int64_t address = reinterpret_cast(source.address()); + if (is_int32(address) && !Serializer::enabled()) { + if (emit_debug_code()) { + movq(kScratchRegister, BitCast(kZapValue), RelocInfo::NONE); + } + push(Immediate(static_cast(address))); + return; + } + LoadAddress(kScratchRegister, source); + push(kScratchRegister); +} + + void MacroAssembler::LoadRoot(Register destination, Heap::RootListIndex index) { ASSERT(root_array_available_); movq(destination, Operand(kRootRegister, diff --git a/src/x64/macro-assembler-x64.h b/src/x64/macro-assembler-x64.h index 6bb5cfeb42..66587d5319 100644 --- a/src/x64/macro-assembler-x64.h +++ b/src/x64/macro-assembler-x64.h @@ -127,6 +127,8 @@ class MacroAssembler: public Assembler { // Returns the size of the code generated by LoadAddress. // Used by CallSize(ExternalReference) to find the size of a call. int LoadAddressSize(ExternalReference source); + // Pushes the address of the external reference onto the stack. + void PushAddress(ExternalReference source); // Operations on roots in the root-array. void LoadRoot(Register destination, Heap::RootListIndex index); diff --git a/src/x64/stub-cache-x64.cc b/src/x64/stub-cache-x64.cc index 8edda731c6..9312c65c45 100644 --- a/src/x64/stub-cache-x64.cc +++ b/src/x64/stub-cache-x64.cc @@ -379,8 +379,7 @@ static void PushInterceptorArguments(MacroAssembler* masm, __ push(receiver); __ push(holder); __ push(FieldOperand(kScratchRegister, InterceptorInfo::kDataOffset)); - __ movq(kScratchRegister, ExternalReference::isolate_address()); - __ push(kScratchRegister); + __ PushAddress(ExternalReference::isolate_address()); } @@ -1012,8 +1011,7 @@ void StubCompiler::GenerateLoadCallback(Handle object, } else { __ Push(Handle(callback->data())); } - __ movq(kScratchRegister, ExternalReference::isolate_address()); - __ push(kScratchRegister); // isolate + __ PushAddress(ExternalReference::isolate_address()); // isolate __ push(name_reg); // name // Save a pointer to where we pushed the arguments pointer. // This will be passed as the const AccessorInfo& to the C++ callback. @@ -1191,8 +1189,7 @@ void StubCompiler::GenerateLoadInterceptor(Handle object, __ push(holder_reg); __ Move(holder_reg, callback); __ push(FieldOperand(holder_reg, AccessorInfo::kDataOffset)); - __ movq(kScratchRegister, ExternalReference::isolate_address()); - __ push(kScratchRegister); + __ PushAddress(ExternalReference::isolate_address()); __ push(holder_reg); __ push(name_reg); __ push(scratch2); // restore return address