Index: src/x64/builtins-x64.cc |
diff --git a/src/x64/builtins-x64.cc b/src/x64/builtins-x64.cc |
index 5c9d6eb85de500eaa67bcdbe203118e623f02e17..98dc9f5ceb13f32e12cd89350c057a1ee982334b 100644 |
--- a/src/x64/builtins-x64.cc |
+++ b/src/x64/builtins-x64.cc |
@@ -31,6 +31,12 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm, |
// ----------------------------------- |
__ AssertFunction(rdi); |
+ // Make sure we operate in the context of the called function (for example |
+ // ConstructStubs implemented in C++ will be run in the context of the caller |
+ // instead of the callee, due to the way that [[Construct]] is defined for |
+ // ordinary functions). |
+ __ movp(rsi, FieldOperand(rdi, JSFunction::kContextOffset)); |
+ |
// Insert extra arguments. |
int num_extra_args = 0; |
if (extra_args != BuiltinExtraArguments::kNone) { |