Commit 24e560fe authored by vitalyr@chromium.org's avatar vitalyr@chromium.org

Don't emit a write barrier when storing a known old space value.

Review URL: http://codereview.chromium.org/6072009

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6120 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent da8c3550
...@@ -1769,6 +1769,8 @@ class HConstant: public HInstruction { ...@@ -1769,6 +1769,8 @@ class HConstant: public HInstruction {
Handle<Object> handle() const { return handle_; } Handle<Object> handle() const { return handle_; }
bool InOldSpace() const { return !Heap::InNewSpace(*handle_); }
virtual bool EmitAtUses() const { return !representation().IsDouble(); } virtual bool EmitAtUses() const { return !representation().IsDouble(); }
virtual void PrintDataTo(StringStream* stream) const; virtual void PrintDataTo(StringStream* stream) const;
virtual HType CalculateInferredType() const; virtual HType CalculateInferredType() const;
...@@ -2687,6 +2689,12 @@ class HLoadKeyedGeneric: public HLoadKeyed { ...@@ -2687,6 +2689,12 @@ class HLoadKeyedGeneric: public HLoadKeyed {
}; };
static inline bool StoringValueNeedsWriteBarrier(HValue* value) {
return !value->type().IsSmi() &&
!(value->IsConstant() && HConstant::cast(value)->InOldSpace());
}
class HStoreNamed: public HBinaryOperation { class HStoreNamed: public HBinaryOperation {
public: public:
HStoreNamed(HValue* obj, Handle<Object> name, HValue* val) HStoreNamed(HValue* obj, Handle<Object> name, HValue* val)
...@@ -2704,6 +2712,10 @@ class HStoreNamed: public HBinaryOperation { ...@@ -2704,6 +2712,10 @@ class HStoreNamed: public HBinaryOperation {
HValue* value() const { return OperandAt(1); } HValue* value() const { return OperandAt(1); }
void set_value(HValue* value) { SetOperandAt(1, value); } void set_value(HValue* value) { SetOperandAt(1, value); }
bool NeedsWriteBarrier() const {
return StoringValueNeedsWriteBarrier(value());
}
DECLARE_INSTRUCTION(StoreNamed) DECLARE_INSTRUCTION(StoreNamed)
protected: protected:
...@@ -2784,6 +2796,10 @@ class HStoreKeyed: public HInstruction { ...@@ -2784,6 +2796,10 @@ class HStoreKeyed: public HInstruction {
HValue* key() const { return OperandAt(1); } HValue* key() const { return OperandAt(1); }
HValue* value() const { return OperandAt(2); } HValue* value() const { return OperandAt(2); }
bool NeedsWriteBarrier() const {
return StoringValueNeedsWriteBarrier(value());
}
DECLARE_INSTRUCTION(StoreKeyed) DECLARE_INSTRUCTION(StoreKeyed)
protected: protected:
...@@ -2803,10 +2819,6 @@ class HStoreKeyedFastElement: public HStoreKeyed { ...@@ -2803,10 +2819,6 @@ class HStoreKeyedFastElement: public HStoreKeyed {
SetFlag(kChangesArrayElements); SetFlag(kChangesArrayElements);
} }
bool NeedsWriteBarrier() const {
return !value()->type().IsSmi();
}
virtual Representation RequiredInputRepresentation(int index) const { virtual Representation RequiredInputRepresentation(int index) const {
// The key is supposed to be Integer32. // The key is supposed to be Integer32.
return (index == 1) ? Representation::Integer32() return (index == 1) ? Representation::Integer32()
......
...@@ -1939,7 +1939,7 @@ LInstruction* LChunkBuilder::DoStoreKeyedGeneric(HStoreKeyedGeneric* instr) { ...@@ -1939,7 +1939,7 @@ LInstruction* LChunkBuilder::DoStoreKeyedGeneric(HStoreKeyedGeneric* instr) {
LInstruction* LChunkBuilder::DoStoreNamedField(HStoreNamedField* instr) { LInstruction* LChunkBuilder::DoStoreNamedField(HStoreNamedField* instr) {
bool needs_write_barrier = !instr->value()->type().IsSmi(); bool needs_write_barrier = instr->NeedsWriteBarrier();
LOperand* obj = needs_write_barrier LOperand* obj = needs_write_barrier
? UseTempRegister(instr->object()) ? UseTempRegister(instr->object())
......
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