ARM: Optimize AccessArgumentsAt

Optimize register constraints and code generated for AccessArgumentsAt
Lithium instruction.

TEST=none
BUG=
R=ulan@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@17923 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
m.m.capewell@googlemail.com 2013-11-20 13:28:19 +00:00
parent 6557c85ff4
commit 2b1aeec591
2 changed files with 28 additions and 20 deletions

View File

@ -2550,15 +2550,8 @@ LInstruction* LChunkBuilder::DoCapturedObject(HCapturedObject* instr) {
LInstruction* LChunkBuilder::DoAccessArgumentsAt(HAccessArgumentsAt* instr) {
info()->MarkAsRequiresFrame();
LOperand* args = UseRegister(instr->arguments());
LOperand* length;
LOperand* index;
if (instr->length()->IsConstant() && instr->index()->IsConstant()) {
length = UseRegisterOrConstant(instr->length());
index = UseOrConstant(instr->index());
} else {
length = UseTempRegister(instr->length());
index = UseRegisterAtStart(instr->index());
}
LOperand* length = UseRegisterOrConstantAtStart(instr->length());
LOperand* index = UseRegisterOrConstantAtStart(instr->index());
return DefineAsRegister(new(zone()) LAccessArgumentsAt(args, length, index));
}

View File

@ -3186,20 +3186,35 @@ void LCodeGen::DoLoadExternalArrayPointer(
void LCodeGen::DoAccessArgumentsAt(LAccessArgumentsAt* instr) {
Register arguments = ToRegister(instr->arguments());
Register result = ToRegister(instr->result());
if (instr->length()->IsConstantOperand() &&
instr->index()->IsConstantOperand()) {
int const_index = ToInteger32(LConstantOperand::cast(instr->index()));
// There are two words between the frame pointer and the last argument.
// Subtracting from length accounts for one of them add one more.
if (instr->length()->IsConstantOperand()) {
int const_length = ToInteger32(LConstantOperand::cast(instr->length()));
int index = (const_length - const_index) + 1;
__ ldr(result, MemOperand(arguments, index * kPointerSize));
} else {
if (instr->index()->IsConstantOperand()) {
int const_index = ToInteger32(LConstantOperand::cast(instr->index()));
int index = (const_length - const_index) + 1;
__ ldr(result, MemOperand(arguments, index * kPointerSize));
} else {
Register index = ToRegister(instr->index());
__ rsb(result, index, Operand(const_length + 1));
__ ldr(result, MemOperand(arguments, result, LSL, kPointerSizeLog2));
}
} else if (instr->index()->IsConstantOperand()) {
Register length = ToRegister(instr->length());
int const_index = ToInteger32(LConstantOperand::cast(instr->index()));
int loc = const_index - 1;
if (loc != 0) {
__ sub(result, length, Operand(loc));
__ ldr(result, MemOperand(arguments, result, LSL, kPointerSizeLog2));
} else {
__ ldr(result, MemOperand(arguments, length, LSL, kPointerSizeLog2));
}
} else {
Register length = ToRegister(instr->length());
Register index = ToRegister(instr->index());
// There are two words between the frame pointer and the last argument.
// Subtracting from length accounts for one of them add one more.
__ sub(length, length, index);
__ add(length, length, Operand(1));
__ ldr(result, MemOperand(arguments, length, LSL, kPointerSizeLog2));
__ sub(result, length, index);
__ add(result, result, Operand(1));
__ ldr(result, MemOperand(arguments, result, LSL, kPointerSizeLog2));
}
}