Index: src/mips/builtins-mips.cc |
diff --git a/src/mips/builtins-mips.cc b/src/mips/builtins-mips.cc |
index ae1b8e028661e5afa06f70b246240b66892a1a16..8cf078f89da27aa9d794f0f460f7620117553254 100644 |
--- a/src/mips/builtins-mips.cc |
+++ b/src/mips/builtins-mips.cc |
@@ -32,6 +32,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). |
+ __ lw(cp, FieldMemOperand(a1, JSFunction::kContextOffset)); |
+ |
// Insert extra arguments. |
int num_extra_args = 0; |
switch (extra_args) { |