Index: src/mips64/builtins-mips64.cc |
diff --git a/src/mips64/builtins-mips64.cc b/src/mips64/builtins-mips64.cc |
index f86c1770fe5b2f8bcbeca8348d83796cc3c3868d..07a7030505309903c906863f305e686729ed1191 100644 |
--- a/src/mips64/builtins-mips64.cc |
+++ b/src/mips64/builtins-mips64.cc |
@@ -31,6 +31,12 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm, |
// ----------------------------------- |
__ AssertFunction(a1); |
+ // 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). |
+ __ ld(cp, FieldMemOperand(a1, JSFunction::kContextOffset)); |
+ |
// Insert extra arguments. |
int num_extra_args = 0; |
switch (extra_args) { |