Index: src/x64/stub-cache-x64.cc |
diff --git a/src/x64/stub-cache-x64.cc b/src/x64/stub-cache-x64.cc |
index 3e06865451e78101f1ae06af507a7ab1d162542f..a43d709b17d82db410c2defe2cf31d760cb843be 100644 |
--- a/src/x64/stub-cache-x64.cc |
+++ b/src/x64/stub-cache-x64.cc |
@@ -1182,6 +1182,7 @@ Handle<Code> StoreStubCompiler::CompileStoreCallback( |
void StoreStubCompiler::GenerateStoreViaSetter( |
MacroAssembler* masm, |
+ Handle<HeapType> type, |
Handle<JSFunction> setter) { |
// ----------- S t a t e ------------- |
// -- rax : value |
@@ -1191,14 +1192,21 @@ void StoreStubCompiler::GenerateStoreViaSetter( |
// ----------------------------------- |
{ |
FrameScope scope(masm, StackFrame::INTERNAL); |
+ Register receiver = rdx; |
+ Register value = rax; |
// Save value register, so we can restore it later. |
- __ push(rax); |
+ __ push(value); |
if (!setter.is_null()) { |
// Call the JavaScript setter with receiver and value on the stack. |
- __ push(rdx); |
- __ push(rax); |
+ if (IC::TypeToMap(*type, masm->isolate())->IsJSGlobalObjectMap()) { |
+ // Swap in the global receiver. |
+ __ movp(receiver, |
+ FieldOperand(receiver, JSGlobalObject::kGlobalReceiverOffset)); |
+ } |
+ __ push(receiver); |
+ __ push(value); |
ParameterCount actual(1); |
ParameterCount expected(setter); |
__ InvokeFunction(setter, expected, actual, |
@@ -1325,6 +1333,7 @@ Register* KeyedStoreStubCompiler::registers() { |
void LoadStubCompiler::GenerateLoadViaGetter(MacroAssembler* masm, |
+ Handle<HeapType> type, |
Register receiver, |
Handle<JSFunction> getter) { |
// ----------- S t a t e ------------- |
@@ -1337,6 +1346,11 @@ void LoadStubCompiler::GenerateLoadViaGetter(MacroAssembler* masm, |
if (!getter.is_null()) { |
// Call the JavaScript getter with the receiver on the stack. |
+ if (IC::TypeToMap(*type, masm->isolate())->IsJSGlobalObjectMap()) { |
+ // Swap in the global receiver. |
+ __ movp(receiver, |
+ FieldOperand(receiver, JSGlobalObject::kGlobalReceiverOffset)); |
+ } |
__ push(receiver); |
ParameterCount actual(0); |
ParameterCount expected(getter); |