Reviewers: Vyacheslav Egorov,
Description:
Don't emit a write barrier when storing a known old space value.
Please review this at http://codereview.chromium.org/6072009/
Affected files:
M src/hydrogen-instructions.h
M src/ia32/lithium-ia32.cc
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()
Index: src/ia32/lithium-ia32.cc
diff --git a/src/ia32/lithium-ia32.cc b/src/ia32/lithium-ia32.cc
index
dede47013587984341f456394166eb787bf576cc..44f0417744cb4b732ceecbefe5cf7bf3372c8d0d
100644
--- a/src/ia32/lithium-ia32.cc
+++ b/src/ia32/lithium-ia32.cc
@@ -1939,7 +1939,7 @@ LInstruction*
LChunkBuilder::DoStoreKeyedGeneric(HStoreKeyedGeneric* 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
? UseTempRegister(instr->object())
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev