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