Index: src/ic/x64/handler-compiler-x64.cc |
diff --git a/src/ic/x64/handler-compiler-x64.cc b/src/ic/x64/handler-compiler-x64.cc |
index feea10360f51ec0b54239ccbff2a9504684562cb..466b04e9a18161e38389b7b49edbe35fdba28419 100644 |
--- a/src/ic/x64/handler-compiler-x64.cc |
+++ b/src/ic/x64/handler-compiler-x64.cc |
@@ -109,7 +109,7 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall( |
Register data = rbx; |
Register holder = rcx; |
Register api_function_address = rdx; |
- scratch = no_reg; |
+ Register context = rsi; |
// Put callee in place. |
__ LoadAccessor(callee, accessor_holder, accessor_index, |
@@ -155,8 +155,20 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall( |
__ Move(api_function_address, function_address, |
RelocInfo::EXTERNAL_REFERENCE); |
+ // Put context in place. |
+ const bool is_lazy = !optimization.is_constant_call(); |
+ if (is_lazy) { |
+ // load context from holder |
+ __ movp(scratch, FieldOperand(holder, HeapObject::kMapOffset)); |
+ __ GetMapConstructor(scratch, scratch, context); |
+ __ movp(context, FieldOperand(scratch, JSFunction::kContextOffset)); |
+ } else { |
+ // load context from callee |
+ __ movp(context, FieldOperand(callee, JSFunction::kContextOffset)); |
+ } |
+ |
// Jump to stub. |
- CallApiCallbackStub stub(isolate, is_store, !optimization.is_constant_call()); |
+ CallApiCallbackStub stub(isolate, is_store, is_lazy); |
__ TailCallStub(&stub); |
} |