In the code generator, avoid loading the arguments object to the

expression stack when it is already there.  Also, cleanup up the
(two!) extra copies of the arguments object left on the stack.
Review URL: http://codereview.chromium.org/5667

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@410 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent eca6c6ae
...@@ -576,22 +576,17 @@ void ArmCodeGenerator::GenCode(FunctionLiteral* fun) { ...@@ -576,22 +576,17 @@ void ArmCodeGenerator::GenCode(FunctionLiteral* fun) {
if (scope->arguments() != NULL) { if (scope->arguments() != NULL) {
ASSERT(scope->arguments_shadow() != NULL); ASSERT(scope->arguments_shadow() != NULL);
Comment cmnt(masm_, "[ allocate arguments object"); Comment cmnt(masm_, "[ allocate arguments object");
{ { Reference shadow_ref(this, scope->arguments_shadow());
Reference target(this, scope->arguments()); { Reference arguments_ref(this, scope->arguments());
__ ldr(r0, FunctionOperand()); __ ldr(r0, FunctionOperand());
__ push(r0); __ push(r0);
__ CallRuntime(Runtime::kNewArguments, 1); __ CallRuntime(Runtime::kNewArguments, 1);
__ push(r0); __ push(r0);
SetValue(&target); SetValue(&arguments_ref);
} }
// The value of arguments must also be stored in .arguments. SetValue(&shadow_ref);
// TODO(1241813): This code can probably be improved by fusing it with
// the code that stores the arguments object above.
{
Reference target(this, scope->arguments_shadow());
Load(scope->arguments());
SetValue(&target);
} }
__ pop(r0); // Value is no longer needed.
} }
// Generate code to 'execute' declarations and initialize // Generate code to 'execute' declarations and initialize
......
...@@ -661,21 +661,27 @@ void Ia32CodeGenerator::GenCode(FunctionLiteral* fun) { ...@@ -661,21 +661,27 @@ void Ia32CodeGenerator::GenCode(FunctionLiteral* fun) {
ASSERT(scope->arguments() != NULL); ASSERT(scope->arguments() != NULL);
ASSERT(scope->arguments_shadow() != NULL); ASSERT(scope->arguments_shadow() != NULL);
Comment cmnt(masm_, "[ store arguments object"); Comment cmnt(masm_, "[ store arguments object");
{ { Reference shadow_ref(this, scope->arguments_shadow());
Reference target(this, scope->arguments()); { Reference arguments_ref(this, scope->arguments());
// If the newly-allocated arguments object is already on the
// stack, we make use of the property that references representing
// variables take up no space on the expression stack (ie, it
// doesn't matter that the stored value is actually below the
// reference).
ASSERT(arguments_ref.size() == 0);
ASSERT(shadow_ref.size() == 0);
// If the newly-allocated argument object is not already on the
// stack, we rely on the property that loading a
// (zero-sized) reference will not clobber the ecx register.
if (!arguments_object_saved) { if (!arguments_object_saved) {
__ push(Operand(ecx)); __ push(ecx);
} }
SetValue(&target); SetValue(&arguments_ref);
} }
// The value of arguments must also be stored in .arguments. SetValue(&shadow_ref);
// TODO(1241813): This code can probably be improved by fusing it with
// the code that stores the arguments object above.
{
Reference target(this, scope->arguments_shadow());
Load(scope->arguments());
SetValue(&target);
} }
__ pop(eax); // Value is no longer needed.
} }
// Generate code to 'execute' declarations and initialize // Generate code to 'execute' declarations and initialize
......
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