Index: src/ppc/builtins-ppc.cc |
diff --git a/src/ppc/builtins-ppc.cc b/src/ppc/builtins-ppc.cc |
index b1a8a83c69f8af2e13d4f56e28b5eae9ee395b03..c431fc18682ce008a5250f5cb243b7de016d24c3 100644 |
--- a/src/ppc/builtins-ppc.cc |
+++ b/src/ppc/builtins-ppc.cc |
@@ -30,6 +30,12 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm, CFunctionId id, |
// ----------------------------------- |
__ AssertFunction(r4); |
+ // 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). |
+ __ LoadP(cp, FieldMemOperand(r4, JSFunction::kContextOffset)); |
+ |
// Insert extra arguments. |
int num_extra_args = 0; |
switch (extra_args) { |