Index: src/runtime/runtime-scopes.cc |
diff --git a/src/runtime/runtime-scopes.cc b/src/runtime/runtime-scopes.cc |
index 50f5704f3275a5566eb9ef087fdbce8671716c97..f6fcf34224bb4d8ad0c706d1453c1506b924ac95 100644 |
--- a/src/runtime/runtime-scopes.cc |
+++ b/src/runtime/runtime-scopes.cc |
@@ -590,12 +590,29 @@ RUNTIME_FUNCTION(Runtime_NewRestParameter) { |
RUNTIME_FUNCTION(Runtime_NewSloppyArguments) { |
HandleScope scope(isolate); |
- DCHECK_EQ(3, args.length()); |
+ DCHECK_EQ(1, args.length()); |
CONVERT_ARG_HANDLE_CHECKED(JSFunction, callee, 0); |
- Object** parameters = reinterpret_cast<Object**>(args[1]); |
- CONVERT_SMI_ARG_CHECKED(argument_count, 2); |
+ StackFrameIterator iterator(isolate); |
+ |
+ // Stub/interpreter handler frame |
+ iterator.Advance(); |
+ DCHECK(iterator.frame()->type() == StackFrame::STUB); |
+ |
+ // Function frame |
+ iterator.Advance(); |
+ JavaScriptFrame* function_frame = JavaScriptFrame::cast(iterator.frame()); |
+ DCHECK(function_frame->is_java_script()); |
+ int argc = function_frame->GetArgumentsLength(); |
+ Address fp = function_frame->fp(); |
+ if (function_frame->has_adapted_arguments()) { |
+ iterator.Advance(); |
+ fp = iterator.frame()->fp(); |
+ } |
+ |
+ Object** parameters = reinterpret_cast<Object**>( |
+ fp + argc * kPointerSize + StandardFrameConstants::kCallerSPOffset); |
ParameterArguments argument_getter(parameters); |
- return *NewSloppyArguments(isolate, callee, argument_getter, argument_count); |
+ return *NewSloppyArguments(isolate, callee, argument_getter, argc); |
} |
RUNTIME_FUNCTION(Runtime_NewArgumentsElements) { |