Function apply(): make all architectures use an IC for performance.

BUG=
R=yangguo@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#28264}
This commit is contained in:
mvstanton 2015-05-06 07:32:03 -07:00 committed by Commit bot
parent 06a792b7cc
commit 9f55ccb828
4 changed files with 62 additions and 51 deletions

View File

@ -1390,33 +1390,36 @@ static void Generate_PushAppliedArguments(MacroAssembler* masm,
const int indexOffset, const int indexOffset,
const int limitOffset) { const int limitOffset) {
Label entry, loop; Label entry, loop;
__ ldr(r0, MemOperand(fp, indexOffset)); Register receiver = LoadDescriptor::ReceiverRegister();
Register key = LoadDescriptor::NameRegister();
__ ldr(key, MemOperand(fp, indexOffset));
__ b(&entry); __ b(&entry);
// Load the current argument from the arguments array and push it to the // Load the current argument from the arguments array.
// stack.
// r0: current argument index
__ bind(&loop); __ bind(&loop);
__ ldr(r1, MemOperand(fp, argumentsOffset)); __ ldr(receiver, MemOperand(fp, argumentsOffset));
__ Push(r1, r0);
// Call the runtime to access the property in the arguments array. // Use inline caching to speed up access to arguments.
__ CallRuntime(Runtime::kGetProperty, 2); Handle<Code> ic = masm->isolate()->builtins()->KeyedLoadIC_Megamorphic();
__ Call(ic, RelocInfo::CODE_TARGET);
// Push the nth argument.
__ push(r0); __ push(r0);
// Use inline caching to access the arguments. __ ldr(key, MemOperand(fp, indexOffset));
__ ldr(r0, MemOperand(fp, indexOffset)); __ add(key, key, Operand(1 << kSmiTagSize));
__ add(r0, r0, Operand(1 << kSmiTagSize)); __ str(key, MemOperand(fp, indexOffset));
__ str(r0, MemOperand(fp, indexOffset));
// Test if the copy loop has finished copying all the elements from the // Test if the copy loop has finished copying all the elements from the
// arguments object. // arguments object.
__ bind(&entry); __ bind(&entry);
__ ldr(r1, MemOperand(fp, limitOffset)); __ ldr(r1, MemOperand(fp, limitOffset));
__ cmp(r0, r1); __ cmp(key, r1);
__ b(ne, &loop); __ b(ne, &loop);
// On exit, the pushed arguments count is in r0, untagged // On exit, the pushed arguments count is in r0, untagged
__ mov(r0, key);
__ SmiUntag(r0); __ SmiUntag(r0);
} }

View File

@ -1386,35 +1386,37 @@ static void Generate_PushAppliedArguments(MacroAssembler* masm,
const int indexOffset, const int indexOffset,
const int limitOffset) { const int limitOffset) {
Label entry, loop; Label entry, loop;
Register current = x0; Register receiver = LoadDescriptor::ReceiverRegister();
__ Ldr(current, MemOperand(fp, indexOffset)); Register key = LoadDescriptor::NameRegister();
__ Ldr(key, MemOperand(fp, indexOffset));
__ B(&entry); __ B(&entry);
// Load the current argument from the arguments array.
__ Bind(&loop); __ Bind(&loop);
// Load the current argument from the arguments array and push it. __ Ldr(receiver, MemOperand(fp, argumentsOffset));
// TODO(all): Couldn't we optimize this for JS arrays?
__ Ldr(x1, MemOperand(fp, argumentsOffset)); // Use inline caching to speed up access to arguments.
__ Push(x1, current); Handle<Code> ic = masm->isolate()->builtins()->KeyedLoadIC_Megamorphic();
__ Call(ic, RelocInfo::CODE_TARGET);
// Call the runtime to access the property in the arguments array. // Push the nth argument.
__ CallRuntime(Runtime::kGetProperty, 2);
__ Push(x0); __ Push(x0);
// Use inline caching to access the arguments. __ Ldr(key, MemOperand(fp, indexOffset));
__ Ldr(current, MemOperand(fp, indexOffset)); __ Add(key, key, Smi::FromInt(1));
__ Add(current, current, Smi::FromInt(1)); __ Str(key, MemOperand(fp, indexOffset));
__ Str(current, MemOperand(fp, indexOffset));
// Test if the copy loop has finished copying all the elements from the // Test if the copy loop has finished copying all the elements from the
// arguments object. // arguments object.
__ Bind(&entry); __ Bind(&entry);
__ Ldr(x1, MemOperand(fp, limitOffset)); __ Ldr(x1, MemOperand(fp, limitOffset));
__ Cmp(current, x1); __ Cmp(key, x1);
__ B(ne, &loop); __ B(ne, &loop);
// On exit, the pushed arguments count is in x0, untagged // On exit, the pushed arguments count is in x0, untagged
__ SmiUntag(current); __ Mov(x0, key);
__ SmiUntag(x0);
} }

View File

@ -1404,32 +1404,35 @@ static void Generate_PushAppliedArguments(MacroAssembler* masm,
const int indexOffset, const int indexOffset,
const int limitOffset) { const int limitOffset) {
Label entry, loop; Label entry, loop;
__ lw(a0, MemOperand(fp, indexOffset)); Register receiver = LoadDescriptor::ReceiverRegister();
Register key = LoadDescriptor::NameRegister();
__ lw(key, MemOperand(fp, indexOffset));
__ Branch(&entry); __ Branch(&entry);
// Load the current argument from the arguments array and push it to the // Load the current argument from the arguments array.
// stack.
// a0: current argument index
__ bind(&loop); __ bind(&loop);
__ lw(a1, MemOperand(fp, argumentsOffset)); __ lw(receiver, MemOperand(fp, argumentsOffset));
__ Push(a1, a0);
// Use inline caching to speed up access to arguments.
Handle<Code> ic = masm->isolate()->builtins()->KeyedLoadIC_Megamorphic();
__ Call(ic, RelocInfo::CODE_TARGET);
// Call the runtime to access the property in the arguments array.
__ CallRuntime(Runtime::kGetProperty, 2);
__ push(v0); __ push(v0);
// Use inline caching to access the arguments. // Use inline caching to access the arguments.
__ lw(a0, MemOperand(fp, indexOffset)); __ lw(key, MemOperand(fp, indexOffset));
__ Addu(a0, a0, Operand(1 << kSmiTagSize)); __ Addu(key, key, Operand(1 << kSmiTagSize));
__ sw(a0, MemOperand(fp, indexOffset)); __ sw(key, MemOperand(fp, indexOffset));
// Test if the copy loop has finished copying all the elements from the // Test if the copy loop has finished copying all the elements from the
// arguments object. // arguments object.
__ bind(&entry); __ bind(&entry);
__ lw(a1, MemOperand(fp, limitOffset)); __ lw(a1, MemOperand(fp, limitOffset));
__ Branch(&loop, ne, a0, Operand(a1)); __ Branch(&loop, ne, key, Operand(a1));
// On exit, the pushed arguments count is in a0, untagged // On exit, the pushed arguments count is in a0, untagged
__ mov(a0, key);
__ SmiUntag(a0); __ SmiUntag(a0);
} }

View File

@ -1411,32 +1411,35 @@ static void Generate_PushAppliedArguments(MacroAssembler* masm,
const int indexOffset, const int indexOffset,
const int limitOffset) { const int limitOffset) {
Label entry, loop; Label entry, loop;
__ ld(a0, MemOperand(fp, indexOffset)); Register receiver = LoadDescriptor::ReceiverRegister();
Register key = LoadDescriptor::NameRegister();
__ ld(key, MemOperand(fp, indexOffset));
__ Branch(&entry); __ Branch(&entry);
// Load the current argument from the arguments array and push it to the // Load the current argument from the arguments array.
// stack.
// a0: current argument index
__ bind(&loop); __ bind(&loop);
__ ld(a1, MemOperand(fp, argumentsOffset)); __ ld(receiver, MemOperand(fp, argumentsOffset));
__ Push(a1, a0);
// Use inline caching to speed up access to arguments.
Handle<Code> ic = masm->isolate()->builtins()->KeyedLoadIC_Megamorphic();
__ Call(ic, RelocInfo::CODE_TARGET);
// Call the runtime to access the property in the arguments array.
__ CallRuntime(Runtime::kGetProperty, 2);
__ push(v0); __ push(v0);
// Use inline caching to access the arguments. // Use inline caching to access the arguments.
__ ld(a0, MemOperand(fp, indexOffset)); __ ld(key, MemOperand(fp, indexOffset));
__ Daddu(a0, a0, Operand(Smi::FromInt(1))); __ Daddu(key, key, Operand(Smi::FromInt(1)));
__ sd(a0, MemOperand(fp, indexOffset)); __ sd(key, MemOperand(fp, indexOffset));
// Test if the copy loop has finished copying all the elements from the // Test if the copy loop has finished copying all the elements from the
// arguments object. // arguments object.
__ bind(&entry); __ bind(&entry);
__ ld(a1, MemOperand(fp, limitOffset)); __ ld(a1, MemOperand(fp, limitOffset));
__ Branch(&loop, ne, a0, Operand(a1)); __ Branch(&loop, ne, key, Operand(a1));
// On exit, the pushed arguments count is in a0, untagged // On exit, the pushed arguments count is in a0, untagged
__ mov(a0, key);
__ SmiUntag(a0); __ SmiUntag(a0);
} }