Reviewers: arv, dstence, michael_dawson,

Description:
PPC: [strong] Function arity check should be based on required parameters

Port 78f0452d310221ac74b6221140d376d8302c4579

Original commit message:
Also check whether the arguments count is smaller than the number of
required parameters which is the same as the SharedFunctionInfo length.

[email protected], [email protected], [email protected]
BUG=

Please review this at https://codereview.chromium.org/1133093004/

Base URL: https://chromium.googlesource.com/v8/v8.git@master

Affected files (+16, -5 lines):
  M src/ppc/builtins-ppc.cc


Index: src/ppc/builtins-ppc.cc
diff --git a/src/ppc/builtins-ppc.cc b/src/ppc/builtins-ppc.cc
index 9c969fd3f902d4279b105e8bc57897d74c8e6cd5..ee89116313a7f9707b8b66436561e6a27d888f41 100644
--- a/src/ppc/builtins-ppc.cc
+++ b/src/ppc/builtins-ppc.cc
@@ -1765,17 +1765,28 @@ void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) {
     __ bind(&too_few);

     // If the function is strong we need to throw an error.
-    Label weak_function;
+    Label no_strong_error;
__ LoadP(r7, FieldMemOperand(r4, JSFunction::kSharedFunctionInfoOffset)); - __ lwz(r7, FieldMemOperand(r7, SharedFunctionInfo::kCompilerHintsOffset));
-    __ TestBit(r7,
+ __ lwz(r8, FieldMemOperand(r7, SharedFunctionInfo::kCompilerHintsOffset));
+    __ TestBit(r8,
 #if V8_TARGET_ARCH_PPC64
                SharedFunctionInfo::kStrongModeFunction,
 #else
                SharedFunctionInfo::kStrongModeFunction + kSmiTagSize,
 #endif
                r0);
-    __ beq(&weak_function, cr0);
+    __ beq(&no_strong_error, cr0);
+
+    // What we really care about is the required number of arguments.
+    __ lwa(r7, FieldMemOperand(r7, SharedFunctionInfo::kLengthOffset));
+#if V8_TARGET_ARCH_PPC64
+    // See commment near kLenghtOffset in src/objects.h
+    __ srawi(r7, r7, kSmiTagSize);
+#else
+    __ SmiUntag(r7);
+#endif
+    __ cmp(r3, r7);
+    __ bge(&no_strong_error);

     {
       FrameScope frame(masm, StackFrame::MANUAL);
@@ -1783,7 +1794,7 @@ void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) {
       __ CallRuntime(Runtime::kThrowStrongModeTooFewArguments, 0);
     }

-    __ bind(&weak_function);
+    __ bind(&no_strong_error);
     EnterArgumentsAdaptorFrame(masm);

     // Calculate copy start address into r0 and copy end address is fp.


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to