Index: src/hydrogen-instructions.h |
diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h |
index 537e5c493a426ec680c4a521e4994f023d0e825f..ab72e34c69473ffca987fc382ae3016c9e3ace48 100644 |
--- a/src/hydrogen-instructions.h |
+++ b/src/hydrogen-instructions.h |
@@ -1769,6 +1769,8 @@ class HConstant: public HInstruction { |
Handle<Object> handle() const { return handle_; } |
+ bool InOldSpace() const { return !Heap::InNewSpace(*handle_); } |
+ |
virtual bool EmitAtUses() const { return !representation().IsDouble(); } |
virtual void PrintDataTo(StringStream* stream) const; |
virtual HType CalculateInferredType() const; |
@@ -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 { |
public: |
HStoreNamed(HValue* obj, Handle<Object> name, HValue* val) |
@@ -2704,6 +2712,10 @@ class HStoreNamed: public HBinaryOperation { |
HValue* value() const { return OperandAt(1); } |
void set_value(HValue* value) { SetOperandAt(1, value); } |
+ bool NeedsWriteBarrier() const { |
+ return StoringValueNeedsWriteBarrier(value()); |
+ } |
+ |
DECLARE_INSTRUCTION(StoreNamed) |
protected: |
@@ -2784,6 +2796,10 @@ class HStoreKeyed: public HInstruction { |
HValue* key() const { return OperandAt(1); } |
HValue* value() const { return OperandAt(2); } |
+ bool NeedsWriteBarrier() const { |
+ return StoringValueNeedsWriteBarrier(value()); |
+ } |
+ |
DECLARE_INSTRUCTION(StoreKeyed) |
protected: |
@@ -2803,10 +2819,6 @@ class HStoreKeyedFastElement: public HStoreKeyed { |
SetFlag(kChangesArrayElements); |
} |
- bool NeedsWriteBarrier() const { |
- return !value()->type().IsSmi(); |
- } |
- |
virtual Representation RequiredInputRepresentation(int index) const { |
// The key is supposed to be Integer32. |
return (index == 1) ? Representation::Integer32() |