Index: src/ppc/builtins-ppc.cc |
diff --git a/src/ppc/builtins-ppc.cc b/src/ppc/builtins-ppc.cc |
index 7269b18b4c11a90fdec76da24ada712e91aa0b5f..cdbb1c24a076d7446d8ab230bd1f110ccc9be9da 100644 |
--- a/src/ppc/builtins-ppc.cc |
+++ b/src/ppc/builtins-ppc.cc |
@@ -21,11 +21,12 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm, CFunctionId id, |
BuiltinExtraArguments extra_args) { |
// ----------- S t a t e ------------- |
// -- r3 : number of arguments excluding receiver |
- // -- r4 : called function (only guaranteed when |
- // extra_args requires it) |
+ // (only guaranteed when the called function |
+ // is not marked as DontAdaptArguments) |
+ // -- r4 : called function |
// -- sp[0] : last argument |
// -- ... |
- // -- sp[4 * (argc - 1)] : first argument (argc == r0) |
+ // -- sp[4 * (argc - 1)] : first argument |
// -- sp[4 * argc] : receiver |
// ----------------------------------- |
__ AssertFunction(r4); |
@@ -46,9 +47,27 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm, CFunctionId id, |
DCHECK(extra_args == NO_EXTRA_ARGUMENTS); |
} |
- // JumpToExternalReference expects r0 to contain the number of arguments |
- // including the receiver and the extra arguments. |
+ // JumpToExternalReference expects r3 to contain the number of arguments |
+ // including the receiver and the extra arguments. But r3 is only valid |
+ // if the called function is marked as DontAdaptArguments, otherwise we |
+ // need to load the argument count from the SharedFunctionInfo. |
+ __ LoadP(r5, FieldMemOperand(r4, JSFunction::kSharedFunctionInfoOffset)); |
+ __ LoadWordArith( |
+ r5, FieldMemOperand(r5, SharedFunctionInfo::kFormalParameterCountOffset)); |
+#if !V8_TARGET_ARCH_PPC64 |
+ __ SmiUntag(r5); |
+#endif |
+ __ cmpi(r5, Operand(SharedFunctionInfo::kDontAdaptArgumentsSentinel)); |
+ if (CpuFeatures::IsSupported(ISELECT)) { |
+ __ isel(ne, r3, r5, r3); |
+ } else { |
+ Label skip; |
+ __ beq(&skip); |
+ __ mr(r3, r5); |
+ __ bind(&skip); |
+ } |
__ addi(r3, r3, Operand(num_extra_args + 1)); |
+ |
__ JumpToExternalReference(ExternalReference(id, masm->isolate())); |
} |