Commit 90d0b6cd authored by palfia@homejinni.com's avatar palfia@homejinni.com

MIPS: Avoid Unnecessary Smi Checks.

Port r15344 (9fd1942)

BUG=

Review URL: https://codereview.chromium.org/17887007
Patch from Balazs Kilvady <kilvadyb@homejinni.com>.

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@15345 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 21cd74ea
...@@ -1709,9 +1709,11 @@ void LCodeGen::DoValueOf(LValueOf* instr) { ...@@ -1709,9 +1709,11 @@ void LCodeGen::DoValueOf(LValueOf* instr) {
Register map = ToRegister(instr->temp()); Register map = ToRegister(instr->temp());
Label done; Label done;
// If the object is a smi return the object. if (!instr->hydrogen()->value()->IsHeapObject()) {
__ Move(result, input); // If the object is a smi return the object.
__ JumpIfSmi(input, &done); __ Move(result, input);
__ JumpIfSmi(input, &done);
}
// If the object is not a value type, return the object. // If the object is not a value type, return the object.
__ GetObjectType(input, map, map); __ GetObjectType(input, map, map);
...@@ -2305,8 +2307,11 @@ void LCodeGen::DoIsObjectAndBranch(LIsObjectAndBranch* instr) { ...@@ -2305,8 +2307,11 @@ void LCodeGen::DoIsObjectAndBranch(LIsObjectAndBranch* instr) {
Condition LCodeGen::EmitIsString(Register input, Condition LCodeGen::EmitIsString(Register input,
Register temp1, Register temp1,
Label* is_not_string) { Label* is_not_string,
__ JumpIfSmi(input, is_not_string); SmiCheck check_needed = INLINE_SMI_CHECK) {
if (check_needed == INLINE_SMI_CHECK) {
__ JumpIfSmi(input, is_not_string);
}
__ GetObjectType(input, temp1, temp1); __ GetObjectType(input, temp1, temp1);
return lt; return lt;
...@@ -2317,8 +2322,11 @@ void LCodeGen::DoIsStringAndBranch(LIsStringAndBranch* instr) { ...@@ -2317,8 +2322,11 @@ void LCodeGen::DoIsStringAndBranch(LIsStringAndBranch* instr) {
Register reg = ToRegister(instr->value()); Register reg = ToRegister(instr->value());
Register temp1 = ToRegister(instr->temp()); Register temp1 = ToRegister(instr->temp());
SmiCheck check_needed =
instr->hydrogen()->value()->IsHeapObject()
? OMIT_SMI_CHECK : INLINE_SMI_CHECK;
Condition true_cond = Condition true_cond =
EmitIsString(reg, temp1, instr->FalseLabel(chunk_)); EmitIsString(reg, temp1, instr->FalseLabel(chunk_), check_needed);
EmitBranch(instr, true_cond, temp1, EmitBranch(instr, true_cond, temp1,
Operand(FIRST_NONSTRING_TYPE)); Operand(FIRST_NONSTRING_TYPE));
...@@ -2336,7 +2344,9 @@ void LCodeGen::DoIsUndetectableAndBranch(LIsUndetectableAndBranch* instr) { ...@@ -2336,7 +2344,9 @@ void LCodeGen::DoIsUndetectableAndBranch(LIsUndetectableAndBranch* instr) {
Register input = ToRegister(instr->value()); Register input = ToRegister(instr->value());
Register temp = ToRegister(instr->temp()); Register temp = ToRegister(instr->temp());
__ JumpIfSmi(input, instr->FalseLabel(chunk_)); if (!instr->hydrogen()->value()->IsHeapObject()) {
__ JumpIfSmi(input, instr->FalseLabel(chunk_));
}
__ lw(temp, FieldMemOperand(input, HeapObject::kMapOffset)); __ lw(temp, FieldMemOperand(input, HeapObject::kMapOffset));
__ lbu(temp, FieldMemOperand(temp, Map::kBitFieldOffset)); __ lbu(temp, FieldMemOperand(temp, Map::kBitFieldOffset));
__ And(at, temp, Operand(1 << Map::kIsUndetectable)); __ And(at, temp, Operand(1 << Map::kIsUndetectable));
...@@ -2400,7 +2410,9 @@ void LCodeGen::DoHasInstanceTypeAndBranch(LHasInstanceTypeAndBranch* instr) { ...@@ -2400,7 +2410,9 @@ void LCodeGen::DoHasInstanceTypeAndBranch(LHasInstanceTypeAndBranch* instr) {
Register scratch = scratch0(); Register scratch = scratch0();
Register input = ToRegister(instr->value()); Register input = ToRegister(instr->value());
__ JumpIfSmi(input, instr->FalseLabel(chunk_)); if (!instr->hydrogen()->value()->IsHeapObject()) {
__ JumpIfSmi(input, instr->FalseLabel(chunk_));
}
__ GetObjectType(input, scratch, scratch); __ GetObjectType(input, scratch, scratch);
EmitBranch(instr, EmitBranch(instr,
...@@ -2837,9 +2849,9 @@ void LCodeGen::DoStoreContextSlot(LStoreContextSlot* instr) { ...@@ -2837,9 +2849,9 @@ void LCodeGen::DoStoreContextSlot(LStoreContextSlot* instr) {
__ sw(value, target); __ sw(value, target);
if (instr->hydrogen()->NeedsWriteBarrier()) { if (instr->hydrogen()->NeedsWriteBarrier()) {
HType type = instr->hydrogen()->value()->type();
SmiCheck check_needed = SmiCheck check_needed =
type.IsHeapObject() ? OMIT_SMI_CHECK : INLINE_SMI_CHECK; instr->hydrogen()->value()->IsHeapObject()
? OMIT_SMI_CHECK : INLINE_SMI_CHECK;
__ RecordWriteContextSlot(context, __ RecordWriteContextSlot(context,
target.offset(), target.offset(),
value, value,
...@@ -4127,9 +4139,9 @@ void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) { ...@@ -4127,9 +4139,9 @@ void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) {
// Do the store. // Do the store.
Register value = ToRegister(instr->value()); Register value = ToRegister(instr->value());
ASSERT(!object.is(value)); ASSERT(!object.is(value));
HType type = instr->hydrogen()->value()->type();
SmiCheck check_needed = SmiCheck check_needed =
type.IsHeapObject() ? OMIT_SMI_CHECK : INLINE_SMI_CHECK; instr->hydrogen()->value()->IsHeapObject()
? OMIT_SMI_CHECK : INLINE_SMI_CHECK;
if (access.IsInobject()) { if (access.IsInobject()) {
__ sw(value, FieldMemOperand(object, offset)); __ sw(value, FieldMemOperand(object, offset));
if (instr->hydrogen()->NeedsWriteBarrier()) { if (instr->hydrogen()->NeedsWriteBarrier()) {
...@@ -4354,9 +4366,9 @@ void LCodeGen::DoStoreKeyedFixedArray(LStoreKeyed* instr) { ...@@ -4354,9 +4366,9 @@ void LCodeGen::DoStoreKeyedFixedArray(LStoreKeyed* instr) {
__ sw(value, FieldMemOperand(store_base, offset)); __ sw(value, FieldMemOperand(store_base, offset));
if (instr->hydrogen()->NeedsWriteBarrier()) { if (instr->hydrogen()->NeedsWriteBarrier()) {
HType type = instr->hydrogen()->value()->type();
SmiCheck check_needed = SmiCheck check_needed =
type.IsHeapObject() ? OMIT_SMI_CHECK : INLINE_SMI_CHECK; instr->hydrogen()->value()->IsHeapObject()
? OMIT_SMI_CHECK : INLINE_SMI_CHECK;
// Compute address of modified element and store it into key register. // Compute address of modified element and store it into key register.
__ Addu(key, store_base, Operand(offset - kHeapObjectTag)); __ Addu(key, store_base, Operand(offset - kHeapObjectTag));
__ RecordWrite(elements, __ RecordWrite(elements,
...@@ -5107,9 +5119,11 @@ void LCodeGen::DoCheckSmi(LCheckSmi* instr) { ...@@ -5107,9 +5119,11 @@ void LCodeGen::DoCheckSmi(LCheckSmi* instr) {
void LCodeGen::DoCheckNonSmi(LCheckNonSmi* instr) { void LCodeGen::DoCheckNonSmi(LCheckNonSmi* instr) {
LOperand* input = instr->value(); if (!instr->hydrogen()->value()->IsHeapObject()) {
__ And(at, ToRegister(input), Operand(kSmiTagMask)); LOperand* input = instr->value();
DeoptimizeIf(eq, instr->environment(), at, Operand(zero_reg)); __ And(at, ToRegister(input), Operand(kSmiTagMask));
DeoptimizeIf(eq, instr->environment(), at, Operand(zero_reg));
}
} }
......
...@@ -365,7 +365,8 @@ class LCodeGen BASE_EMBEDDED { ...@@ -365,7 +365,8 @@ class LCodeGen BASE_EMBEDDED {
// true and false label should be made, to optimize fallthrough. // true and false label should be made, to optimize fallthrough.
Condition EmitIsString(Register input, Condition EmitIsString(Register input,
Register temp1, Register temp1,
Label* is_not_string); Label* is_not_string,
SmiCheck check_needed);
// Emits optimized code for %_IsConstructCall(). // Emits optimized code for %_IsConstructCall().
// Caller should branch on equal condition. // Caller should branch on equal condition.
......
...@@ -1920,7 +1920,7 @@ LInstruction* LChunkBuilder::DoChange(HChange* instr) { ...@@ -1920,7 +1920,7 @@ LInstruction* LChunkBuilder::DoChange(HChange* instr) {
} }
LInstruction* LChunkBuilder::DoCheckNonSmi(HCheckNonSmi* instr) { LInstruction* LChunkBuilder::DoCheckHeapObject(HCheckHeapObject* instr) {
LOperand* value = UseRegisterAtStart(instr->value()); LOperand* value = UseRegisterAtStart(instr->value());
return AssignEnvironment(new(zone()) LCheckNonSmi(value)); return AssignEnvironment(new(zone()) LCheckNonSmi(value));
} }
......
...@@ -2394,6 +2394,7 @@ class LCheckNonSmi: public LTemplateInstruction<0, 1, 0> { ...@@ -2394,6 +2394,7 @@ class LCheckNonSmi: public LTemplateInstruction<0, 1, 0> {
LOperand* value() { return inputs_[0]; } LOperand* value() { return inputs_[0]; }
DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi") DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
}; };
......
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