Commit fe630701 authored by yangguo@chromium.org's avatar yangguo@chromium.org

MIPS: Improve constant element index access code generation

Port r12232 (588ccf83)

BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com/10825263
Patch from Akos Palfi <palfia@homejinni.com>.

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@12283 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 93fe6abc
...@@ -2587,11 +2587,21 @@ void LCodeGen::DoAccessArgumentsAt(LAccessArgumentsAt* instr) { ...@@ -2587,11 +2587,21 @@ void LCodeGen::DoAccessArgumentsAt(LAccessArgumentsAt* instr) {
void LCodeGen::DoLoadKeyedFastElement(LLoadKeyedFastElement* instr) { void LCodeGen::DoLoadKeyedFastElement(LLoadKeyedFastElement* instr) {
Register elements = ToRegister(instr->elements()); Register elements = ToRegister(instr->elements());
Register key = EmitLoadRegister(instr->key(), scratch0());
Register result = ToRegister(instr->result()); Register result = ToRegister(instr->result());
Register scratch = scratch0(); Register scratch = scratch0();
// Load the result. if (instr->key()->IsConstantOperand()) {
LConstantOperand* const_operand = LConstantOperand::cast(instr->key());
int offset =
(ToInteger32(const_operand) + instr->additional_index()) * kPointerSize
+ FixedArray::kHeaderSize;
__ lw(result, FieldMemOperand(elements, offset));
} else {
Register key = EmitLoadRegister(instr->key(), scratch);
// Even though the HLoadKeyedFastElement instruction forces the input
// representation for the key to be an integer, the input gets replaced
// during bound check elimination with the index argument to the bounds
// check, which can be tagged, so that case must be handled here, too.
if (instr->hydrogen()->key()->representation().IsTagged()) { if (instr->hydrogen()->key()->representation().IsTagged()) {
__ sll(scratch, key, kPointerSizeLog2 - kSmiTagSize); __ sll(scratch, key, kPointerSizeLog2 - kSmiTagSize);
__ addu(scratch, elements, scratch); __ addu(scratch, elements, scratch);
...@@ -2602,6 +2612,7 @@ void LCodeGen::DoLoadKeyedFastElement(LLoadKeyedFastElement* instr) { ...@@ -2602,6 +2612,7 @@ void LCodeGen::DoLoadKeyedFastElement(LLoadKeyedFastElement* instr) {
uint32_t offset = FixedArray::kHeaderSize + uint32_t offset = FixedArray::kHeaderSize +
(instr->additional_index() << kPointerSizeLog2); (instr->additional_index() << kPointerSizeLog2);
__ lw(result, FieldMemOperand(scratch, offset)); __ lw(result, FieldMemOperand(scratch, offset));
}
// Check for the hole value. // Check for the hole value.
if (instr->hydrogen()->RequiresHoleCheck()) { if (instr->hydrogen()->RequiresHoleCheck()) {
...@@ -3647,10 +3658,24 @@ void LCodeGen::DoStoreNamedGeneric(LStoreNamedGeneric* instr) { ...@@ -3647,10 +3658,24 @@ void LCodeGen::DoStoreNamedGeneric(LStoreNamedGeneric* instr) {
void LCodeGen::DoBoundsCheck(LBoundsCheck* instr) { void LCodeGen::DoBoundsCheck(LBoundsCheck* instr) {
if (instr->index()->IsConstantOperand()) {
int constant_index =
ToInteger32(LConstantOperand::cast(instr->index()));
if (instr->hydrogen()->length()->representation().IsTagged()) {
__ li(at, Operand(Smi::FromInt(constant_index)));
} else {
__ li(at, Operand(constant_index));
}
DeoptimizeIf(hs,
instr->environment(),
at,
Operand(ToRegister(instr->length())));
} else {
DeoptimizeIf(hs, DeoptimizeIf(hs,
instr->environment(), instr->environment(),
ToRegister(instr->index()), ToRegister(instr->index()),
Operand(ToRegister(instr->length()))); Operand(ToRegister(instr->length())));
}
} }
...@@ -3669,6 +3694,10 @@ void LCodeGen::DoStoreKeyedFastElement(LStoreKeyedFastElement* instr) { ...@@ -3669,6 +3694,10 @@ void LCodeGen::DoStoreKeyedFastElement(LStoreKeyedFastElement* instr) {
+ FixedArray::kHeaderSize; + FixedArray::kHeaderSize;
__ sw(value, FieldMemOperand(elements, offset)); __ sw(value, FieldMemOperand(elements, offset));
} else { } else {
// Even though the HLoadKeyedFastElement instruction forces the input
// representation for the key to be an integer, the input gets replaced
// during bound check elimination with the index argument to the bounds
// check, which can be tagged, so that case must be handled here, too.
if (instr->hydrogen()->key()->representation().IsTagged()) { if (instr->hydrogen()->key()->representation().IsTagged()) {
__ sll(scratch, key, kPointerSizeLog2 - kSmiTagSize); __ sll(scratch, key, kPointerSizeLog2 - kSmiTagSize);
__ addu(scratch, elements, scratch); __ addu(scratch, elements, scratch);
...@@ -3676,12 +3705,9 @@ void LCodeGen::DoStoreKeyedFastElement(LStoreKeyedFastElement* instr) { ...@@ -3676,12 +3705,9 @@ void LCodeGen::DoStoreKeyedFastElement(LStoreKeyedFastElement* instr) {
__ sll(scratch, key, kPointerSizeLog2); __ sll(scratch, key, kPointerSizeLog2);
__ addu(scratch, elements, scratch); __ addu(scratch, elements, scratch);
} }
if (instr->additional_index() != 0) { uint32_t offset = FixedArray::kHeaderSize +
__ Addu(scratch, (instr->additional_index() << kPointerSizeLog2);
scratch, __ sw(value, FieldMemOperand(scratch, offset));
instr->additional_index() << kPointerSizeLog2);
}
__ sw(value, FieldMemOperand(scratch, FixedArray::kHeaderSize));
} }
if (instr->hydrogen()->NeedsWriteBarrier()) { if (instr->hydrogen()->NeedsWriteBarrier()) {
......
...@@ -1502,7 +1502,7 @@ LInstruction* LChunkBuilder::DoDateField(HDateField* instr) { ...@@ -1502,7 +1502,7 @@ LInstruction* LChunkBuilder::DoDateField(HDateField* instr) {
LInstruction* LChunkBuilder::DoBoundsCheck(HBoundsCheck* instr) { LInstruction* LChunkBuilder::DoBoundsCheck(HBoundsCheck* instr) {
LOperand* value = UseRegisterAtStart(instr->index()); LOperand* value = UseRegisterOrConstantAtStart(instr->index());
LOperand* length = UseRegister(instr->length()); LOperand* length = UseRegister(instr->length());
return AssignEnvironment(new(zone()) LBoundsCheck(value, length)); return AssignEnvironment(new(zone()) LBoundsCheck(value, length));
} }
...@@ -1795,7 +1795,7 @@ LInstruction* LChunkBuilder::DoLoadKeyedFastElement( ...@@ -1795,7 +1795,7 @@ LInstruction* LChunkBuilder::DoLoadKeyedFastElement(
ASSERT(instr->key()->representation().IsInteger32() || ASSERT(instr->key()->representation().IsInteger32() ||
instr->key()->representation().IsTagged()); instr->key()->representation().IsTagged());
LOperand* obj = UseRegisterAtStart(instr->object()); LOperand* obj = UseRegisterAtStart(instr->object());
LOperand* key = UseRegisterAtStart(instr->key()); LOperand* key = UseRegisterOrConstantAtStart(instr->key());
LLoadKeyedFastElement* result = new(zone()) LLoadKeyedFastElement(obj, key); LLoadKeyedFastElement* result = new(zone()) LLoadKeyedFastElement(obj, key);
if (instr->RequiresHoleCheck()) AssignEnvironment(result); if (instr->RequiresHoleCheck()) AssignEnvironment(result);
return DefineAsRegister(result); return DefineAsRegister(result);
......
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