Index: src/ia32/lithium-ia32.cc |
diff --git a/src/ia32/lithium-ia32.cc b/src/ia32/lithium-ia32.cc |
index c023fd15b6ac3391a5e28231062a83da0e265406..8bb2d09b244d553808005efc00acba54b77ca6ec 100644 |
--- a/src/ia32/lithium-ia32.cc |
+++ b/src/ia32/lithium-ia32.cc |
@@ -601,6 +601,11 @@ LOperand* LChunkBuilder::UseRegisterOrConstantAtStart(HValue* value) { |
} |
+LOperand* LChunkBuilder::UseConstant(HValue* value) { |
+ return chunk_->DefineConstantOperand(HConstant::cast(value)); |
+} |
+ |
+ |
LOperand* LChunkBuilder::UseAny(HValue* value) { |
return value->IsConstant() |
? chunk_->DefineConstantOperand(HConstant::cast(value)) |
@@ -2287,19 +2292,6 @@ LOperand* LChunkBuilder::GetStoreKeyedValueOperand(HStoreKeyed* instr) { |
} |
-// DoStoreKeyed and DoStoreNamedField have special considerations for allowing |
-// use of a constant instead of a register. |
-static bool StoreConstantValueAllowed(HValue* value) { |
- if (value->IsConstant()) { |
- HConstant* constant_value = HConstant::cast(value); |
- return constant_value->HasSmiValue() |
- || constant_value->HasDoubleValue() |
- || constant_value->ImmortalImmovable(); |
- } |
- return false; |
-} |
- |
- |
LInstruction* LChunkBuilder::DoStoreKeyed(HStoreKeyed* instr) { |
if (!instr->is_external()) { |
ASSERT(instr->elements()->representation().IsTagged()); |
@@ -2327,17 +2319,8 @@ LInstruction* LChunkBuilder::DoStoreKeyed(HStoreKeyed* instr) { |
val = UseTempRegister(instr->value()); |
key = UseTempRegister(instr->key()); |
} else { |
- if (StoreConstantValueAllowed(instr->value())) { |
- val = UseRegisterOrConstantAtStart(instr->value()); |
- } else { |
- val = UseRegisterAtStart(instr->value()); |
- } |
- |
- if (StoreConstantValueAllowed(instr->key())) { |
- key = UseRegisterOrConstantAtStart(instr->key()); |
- } else { |
- key = UseRegisterAtStart(instr->key()); |
- } |
+ val = UseRegisterOrConstantAtStart(instr->value()); |
+ key = UseRegisterOrConstantAtStart(instr->key()); |
} |
return new(zone()) LStoreKeyed(obj, key, val); |
} |
@@ -2438,10 +2421,13 @@ LInstruction* LChunkBuilder::DoStoreNamedField(HStoreNamedField* instr) { |
: UseRegisterAtStart(instr->object()); |
} |
+ bool can_be_constant = instr->value()->IsConstant() && |
+ !HConstant::cast(instr->value())->InNewSpace(); |
+ |
LOperand* val; |
if (needs_write_barrier) { |
val = UseTempRegister(instr->value()); |
- } else if (StoreConstantValueAllowed(instr->value())) { |
+ } else if (can_be_constant) { |
val = UseRegisterOrConstant(instr->value()); |
} else { |
val = UseRegister(instr->value()); |
@@ -2516,8 +2502,9 @@ LInstruction* LChunkBuilder::DoAllocateObject(HAllocateObject* instr) { |
LInstruction* LChunkBuilder::DoAllocate(HAllocate* instr) { |
info()->MarkAsDeferredCalling(); |
LOperand* context = UseAny(instr->context()); |
- // TODO(mvstanton): why can't size be a constant if possible? |
- LOperand* size = UseTempRegister(instr->size()); |
+ LOperand* size = instr->size()->IsConstant() |
+ ? UseConstant(instr->size()) |
+ : UseTempRegister(instr->size()); |
LOperand* temp = TempRegister(); |
LAllocate* result = new(zone()) LAllocate(context, size, temp); |
return AssignPointerMap(DefineAsRegister(result)); |