Commit 34d5cc64 authored by chunyang.dai's avatar chunyang.dai Committed by Commit bot

X87: Implement ES6 rest parameters.

port 8bb2e397 (r26645).

original commit message:

BUG=

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

Cr-Commit-Position: refs/heads/master@{#26649}
parent a10ed727
......@@ -840,6 +840,31 @@ void ArgumentsAccessStub::GenerateNewStrict(MacroAssembler* masm) {
}
void RestParamAccessStub::GenerateNew(MacroAssembler* masm) {
// esp[0] : return address
// esp[4] : index of rest parameter
// esp[8] : number of parameters
// esp[12] : receiver displacement
// Check if the calling frame is an arguments adaptor frame.
Label runtime;
__ mov(edx, Operand(ebp, StandardFrameConstants::kCallerFPOffset));
__ mov(ecx, Operand(edx, StandardFrameConstants::kContextOffset));
__ cmp(ecx, Immediate(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
__ j(not_equal, &runtime);
// Patch the arguments.length and the parameters pointer.
__ mov(ecx, Operand(edx, ArgumentsAdaptorFrameConstants::kLengthOffset));
__ mov(Operand(esp, 2 * kPointerSize), ecx);
__ lea(edx, Operand(edx, ecx, times_2,
StandardFrameConstants::kCallerSPOffset));
__ mov(Operand(esp, 3 * kPointerSize), edx);
__ bind(&runtime);
__ TailCallRuntime(Runtime::kNewRestParam, 3, 1);
}
void RegExpExecStub::Generate(MacroAssembler* masm) {
// Just jump directly to runtime if native RegExp is not selected at compile
// time or if regexp entry in generated code is turned off runtime switch or
......
......@@ -233,6 +233,26 @@ void FullCodeGenerator::Generate() {
}
}
// Possibly allocate RestParameters
int rest_index;
Variable* rest_param = scope()->rest_parameter(&rest_index);
if (rest_param) {
Comment cmnt(masm_, "[ Allocate rest parameter array");
int num_parameters = info->scope()->num_parameters();
int offset = num_parameters * kPointerSize;
__ lea(edx,
Operand(ebp, StandardFrameConstants::kCallerSPOffset + offset));
__ push(edx);
__ push(Immediate(Smi::FromInt(num_parameters)));
__ push(Immediate(Smi::FromInt(rest_index)));
RestParamAccessStub stub(isolate());
__ CallStub(&stub);
SetVar(rest_param, eax, ebx, edx);
}
Variable* arguments = scope()->arguments();
if (arguments != NULL) {
// Function uses arguments object.
......@@ -254,7 +274,7 @@ void FullCodeGenerator::Generate() {
// The stub will rewrite receiver and parameter count if the previous
// stack frame was an arguments adapter frame.
ArgumentsAccessStub::Type type;
if (is_strict(language_mode())) {
if (is_strict(language_mode()) || !is_simple_parameter_list()) {
type = ArgumentsAccessStub::NEW_STRICT;
} else if (function()->has_duplicate_parameters()) {
type = ArgumentsAccessStub::NEW_SLOPPY_SLOW;
......
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