X87: Partial revert of rest parameter desugaring.

port d3f074b231 (r33024)

  original commit message:
  We'll be able to optimize rest parameters in TurboFan similarly to the arguments array. This CL restores the previous behavior, and a follow-on will enable TurboFan optimization.

  (TBR for rossberg since we discussed the revert beforehand. The only changes are a few lines related to tests and rebasing.)

BUG=

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

Cr-Commit-Position: refs/heads/master@{#33034}
This commit is contained in:
zhengxing.li 2015-12-24 00:07:01 -08:00 committed by Commit bot
parent 0bd4131426
commit d9cfa7293d
2 changed files with 47 additions and 0 deletions

View File

@ -251,6 +251,27 @@ void FullCodeGenerator::Generate() {
SetVar(new_target_var, edx, ebx, ecx); SetVar(new_target_var, edx, ebx, ecx);
} }
// 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)));
__ push(Immediate(Smi::FromInt(language_mode())));
function_in_register = false;
RestParamAccessStub stub(isolate());
__ CallStub(&stub);
SetVar(rest_param, eax, ebx, edx);
}
Variable* arguments = scope()->arguments(); Variable* arguments = scope()->arguments();
if (arguments != NULL) { if (arguments != NULL) {
// Function uses arguments object. // Function uses arguments object.

View File

@ -853,6 +853,32 @@ void ArgumentsAccessStub::GenerateNewStrict(MacroAssembler* masm) {
} }
void RestParamAccessStub::GenerateNew(MacroAssembler* masm) {
// esp[0] : return address
// esp[4] : language mode
// esp[8] : index of rest parameter
// esp[12] : number of parameters
// esp[16] : 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, 3 * kPointerSize), ecx);
__ lea(edx,
Operand(edx, ecx, times_2, StandardFrameConstants::kCallerSPOffset));
__ mov(Operand(esp, 4 * kPointerSize), edx);
__ bind(&runtime);
__ TailCallRuntime(Runtime::kNewRestParam, 4, 1);
}
void RegExpExecStub::Generate(MacroAssembler* masm) { void RegExpExecStub::Generate(MacroAssembler* masm) {
// Just jump directly to runtime if native RegExp is not selected at compile // 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 // time or if regexp entry in generated code is turned off runtime switch or