Commit b111ad21 authored by mstarzinger's avatar mstarzinger Committed by Commit bot

[runtime] Cleanup runtime support for rest arguments.

R=mvstanton@chromium.org

Review URL: https://codereview.chromium.org/1569223002

Cr-Commit-Position: refs/heads/master@{#33174}
parent 63953140
...@@ -641,46 +641,22 @@ RUNTIME_FUNCTION(Runtime_NewStrictArguments) { ...@@ -641,46 +641,22 @@ RUNTIME_FUNCTION(Runtime_NewStrictArguments) {
} }
static Handle<JSArray> NewRestParam(Isolate* isolate, Object** parameters,
int num_params, int rest_index) {
parameters -= rest_index;
int num_elements = std::max(0, num_params - rest_index);
Handle<FixedArray> elements =
isolate->factory()->NewUninitializedFixedArray(num_elements);
for (int i = 0; i < num_elements; ++i) {
elements->set(i, *--parameters);
}
return isolate->factory()->NewJSArrayWithElements(elements, FAST_ELEMENTS,
num_elements);
}
RUNTIME_FUNCTION(Runtime_NewRestParam) { RUNTIME_FUNCTION(Runtime_NewRestParam) {
HandleScope scope(isolate); HandleScope scope(isolate);
DCHECK(args.length() == 3); DCHECK(args.length() == 3);
CONVERT_SMI_ARG_CHECKED(num_params, 0); CONVERT_SMI_ARG_CHECKED(num_params, 0);
Object** parameters = reinterpret_cast<Object**>(args[1]); Object** parameters = reinterpret_cast<Object**>(args[1]);
CONVERT_SMI_ARG_CHECKED(rest_index, 2); CONVERT_SMI_ARG_CHECKED(rest_index, 2);
#ifdef DEBUG
return *NewRestParam(isolate, parameters, num_params, rest_index); // This runtime function does not materialize the correct arguments when the
} // caller has been inlined, better make sure we are not hitting that case.
RUNTIME_FUNCTION(Runtime_NewRestParamSlow) {
HandleScope scope(isolate);
DCHECK(args.length() == 1);
CONVERT_SMI_ARG_CHECKED(rest_index, 0);
JavaScriptFrameIterator it(isolate); JavaScriptFrameIterator it(isolate);
DCHECK(!it.frame()->HasInlinedFrames());
// Find the frame that holds the actual arguments passed to the function. #endif // DEBUG
it.AdvanceToArgumentsFrame(); Handle<JSFunction> callee;
JavaScriptFrame* frame = it.frame(); ParameterArguments argument_getter(parameters);
return *NewRestArguments(isolate, callee, argument_getter, num_params,
int argument_count = frame->GetArgumentsLength(); rest_index);
Object** parameters = reinterpret_cast<Object**>(frame->GetParameterSlot(-1));
return *NewRestParam(isolate, parameters, argument_count, rest_index);
} }
......
...@@ -557,7 +557,6 @@ namespace internal { ...@@ -557,7 +557,6 @@ namespace internal {
F(NewSloppyArguments, 3, 1) \ F(NewSloppyArguments, 3, 1) \
F(NewStrictArguments, 3, 1) \ F(NewStrictArguments, 3, 1) \
F(NewRestParam, 3, 1) \ F(NewRestParam, 3, 1) \
F(NewRestParamSlow, 1, 1) \
F(NewClosure, 1, 1) \ F(NewClosure, 1, 1) \
F(NewClosure_Tenured, 1, 1) \ F(NewClosure_Tenured, 1, 1) \
F(NewScriptContext, 2, 1) \ F(NewScriptContext, 2, 1) \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment