From fecaed531be62416d977bd2b365f43058f7bf8ba Mon Sep 17 00:00:00 2001 From: "chunyang.dai" Date: Wed, 13 May 2015 04:15:42 -0700 Subject: [PATCH] X87: [strong] Check arity of functions port 3226e980200035f37c86fef4b11fb307e17764a2 (28346). original commit message: [strong] Check arity of functions In strong mode it is an error to call a function with too few arguments. This is enforced inside the ArgumentsAdaptorTrampoline. This does not yet handle rest parameter BUG= Review URL: https://codereview.chromium.org/1139913007 Cr-Commit-Position: refs/heads/master@{#28387} --- src/x87/builtins-x87.cc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/x87/builtins-x87.cc b/src/x87/builtins-x87.cc index 28ead0c..f45f1f0 100644 --- a/src/x87/builtins-x87.cc +++ b/src/x87/builtins-x87.cc @@ -1577,6 +1577,21 @@ void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) { { // Too few parameters: Actual < expected. __ bind(&too_few); + + // If the function is strong we need to throw an error. + Label weak_function; + __ mov(ecx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); + __ test_b(FieldOperand(ecx, SharedFunctionInfo::kStrongModeByteOffset), + 1 << SharedFunctionInfo::kStrongModeBitWithinByte); + __ j(equal, &weak_function, Label::kNear); + + { + FrameScope frame(masm, StackFrame::MANUAL); + EnterArgumentsAdaptorFrame(masm); + __ CallRuntime(Runtime::kThrowStrongModeTooFewArguments, 0); + } + + __ bind(&weak_function); EnterArgumentsAdaptorFrame(masm); // Copy receiver and all actual arguments. -- 2.7.4