OLD | NEW |
---|---|
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/intermediate_language.h" | 5 #include "vm/intermediate_language.h" |
6 | 6 |
7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" |
8 #include "vm/dart_entry.h" | 8 #include "vm/dart_entry.h" |
9 #include "vm/flow_graph_allocator.h" | 9 #include "vm/flow_graph_allocator.h" |
10 #include "vm/flow_graph_builder.h" | 10 #include "vm/flow_graph_builder.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
96 // TODO(fschneider): Make sure ic_data are sorted to hit more cases. | 96 // TODO(fschneider): Make sure ic_data are sorted to hit more cases. |
97 if (unary_checks().GetReceiverClassIdAt(i) != | 97 if (unary_checks().GetReceiverClassIdAt(i) != |
98 other_check->unary_checks().GetReceiverClassIdAt(i)) { | 98 other_check->unary_checks().GetReceiverClassIdAt(i)) { |
99 return false; | 99 return false; |
100 } | 100 } |
101 } | 101 } |
102 return true; | 102 return true; |
103 } | 103 } |
104 | 104 |
105 | 105 |
106 bool CheckClassInstr::AffectedBySideEffect() const { | 106 EffectSet CheckClassInstr::Dependencies() const { |
107 // The class-id of string objects is not invariant: Externalization of strings | 107 // Externalization of strings via the API can change the class-id. |
108 // via the API can change the class-id. | 108 const bool externalizable = |
109 return unary_checks().HasReceiverClassId(kOneByteStringCid) | 109 unary_checks().HasReceiverClassId(kOneByteStringCid) || |
110 || unary_checks().HasReceiverClassId(kTwoByteStringCid); | 110 unary_checks().HasReceiverClassId(kTwoByteStringCid); |
srdjan
2013/04/29 17:16:26
Need to add all typed data arrays as well.
Vyacheslav Egorov (Google)
2013/04/30 14:01:33
I suggest we add them in a separate CL.
| |
111 return externalizable ? EffectSet::All() : EffectSet::None(); | |
Florian Schneider
2013/04/29 12:11:54
Shouldn't the dependencies be EffectSet::kExternal
Vyacheslav Egorov (Google)
2013/04/30 14:01:33
Done.
| |
111 } | 112 } |
112 | 113 |
113 | 114 |
114 bool GuardFieldInstr::AttributesEqual(Instruction* other) const { | 115 bool GuardFieldInstr::AttributesEqual(Instruction* other) const { |
115 return field().raw() == other->AsGuardField()->field().raw(); | 116 return field().raw() == other->AsGuardField()->field().raw(); |
116 } | 117 } |
117 | 118 |
118 | 119 |
119 bool GuardFieldInstr::AffectedBySideEffect() const { | |
120 return false; | |
121 } | |
122 | |
123 | |
124 bool CheckArrayBoundInstr::AttributesEqual(Instruction* other) const { | 120 bool CheckArrayBoundInstr::AttributesEqual(Instruction* other) const { |
125 CheckArrayBoundInstr* other_check = other->AsCheckArrayBound(); | 121 CheckArrayBoundInstr* other_check = other->AsCheckArrayBound(); |
126 ASSERT(other_check != NULL); | 122 ASSERT(other_check != NULL); |
127 return array_type() == other_check->array_type(); | 123 return array_type() == other_check->array_type(); |
128 } | 124 } |
129 | 125 |
130 | 126 |
131 bool AssertAssignableInstr::AttributesEqual(Instruction* other) const { | 127 bool AssertAssignableInstr::AttributesEqual(Instruction* other) const { |
132 AssertAssignableInstr* other_assert = other->AsAssertAssignable(); | 128 AssertAssignableInstr* other_assert = other->AsAssertAssignable(); |
133 ASSERT(other_assert != NULL); | 129 ASSERT(other_assert != NULL); |
(...skipping 12 matching lines...) Expand all Loading... | |
146 | 142 |
147 bool BinarySmiOpInstr::AttributesEqual(Instruction* other) const { | 143 bool BinarySmiOpInstr::AttributesEqual(Instruction* other) const { |
148 BinarySmiOpInstr* other_op = other->AsBinarySmiOp(); | 144 BinarySmiOpInstr* other_op = other->AsBinarySmiOp(); |
149 ASSERT(other_op != NULL); | 145 ASSERT(other_op != NULL); |
150 return (op_kind() == other_op->op_kind()) && | 146 return (op_kind() == other_op->op_kind()) && |
151 (overflow_ == other_op->overflow_) && | 147 (overflow_ == other_op->overflow_) && |
152 (is_truncating_ == other_op->is_truncating_); | 148 (is_truncating_ == other_op->is_truncating_); |
153 } | 149 } |
154 | 150 |
155 | 151 |
152 EffectSet LoadFieldInstr::Dependencies() const { | |
153 return immutable_ ? EffectSet::None() : EffectSet::All(); | |
154 } | |
155 | |
156 | |
156 bool LoadFieldInstr::AttributesEqual(Instruction* other) const { | 157 bool LoadFieldInstr::AttributesEqual(Instruction* other) const { |
157 LoadFieldInstr* other_load = other->AsLoadField(); | 158 LoadFieldInstr* other_load = other->AsLoadField(); |
158 ASSERT(other_load != NULL); | 159 ASSERT(other_load != NULL); |
159 ASSERT((offset_in_bytes() != other_load->offset_in_bytes()) || | 160 ASSERT((offset_in_bytes() != other_load->offset_in_bytes()) || |
160 ((immutable_ == other_load->immutable_))); | 161 ((immutable_ == other_load->immutable_))); |
161 return offset_in_bytes() == other_load->offset_in_bytes(); | 162 return offset_in_bytes() == other_load->offset_in_bytes(); |
162 } | 163 } |
163 | 164 |
164 | 165 |
166 EffectSet LoadStaticFieldInstr::Dependencies() const { | |
167 return field().is_final() ? EffectSet::None() : EffectSet::All(); | |
168 } | |
169 | |
170 | |
165 bool LoadStaticFieldInstr::AttributesEqual(Instruction* other) const { | 171 bool LoadStaticFieldInstr::AttributesEqual(Instruction* other) const { |
166 LoadStaticFieldInstr* other_load = other->AsLoadStaticField(); | 172 LoadStaticFieldInstr* other_load = other->AsLoadStaticField(); |
167 ASSERT(other_load != NULL); | 173 ASSERT(other_load != NULL); |
168 // Assert that the field is initialized. | 174 // Assert that the field is initialized. |
169 ASSERT(field().value() != Object::sentinel().raw()); | 175 ASSERT(field().value() != Object::sentinel().raw()); |
170 ASSERT(field().value() != Object::transition_sentinel().raw()); | 176 ASSERT(field().value() != Object::transition_sentinel().raw()); |
171 return field().raw() == other_load->field().raw(); | 177 return field().raw() == other_load->field().raw(); |
172 } | 178 } |
173 | 179 |
174 | 180 |
181 EffectSet LoadIndexedInstr::Dependencies() const { | |
182 return EffectSet::All(); | |
183 } | |
184 | |
185 | |
175 bool LoadIndexedInstr::AttributesEqual(Instruction* other) const { | 186 bool LoadIndexedInstr::AttributesEqual(Instruction* other) const { |
176 LoadIndexedInstr* other_load = other->AsLoadIndexed(); | 187 LoadIndexedInstr* other_load = other->AsLoadIndexed(); |
177 ASSERT(other_load != NULL); | 188 ASSERT(other_load != NULL); |
178 return class_id() == other_load->class_id(); | 189 return class_id() == other_load->class_id(); |
179 } | 190 } |
180 | 191 |
181 | 192 |
182 bool ConstantInstr::AttributesEqual(Instruction* other) const { | 193 bool ConstantInstr::AttributesEqual(Instruction* other) const { |
183 ConstantInstr* other_constant = other->AsConstant(); | 194 ConstantInstr* other_constant = other->AsConstant(); |
184 ASSERT(other_constant != NULL); | 195 ASSERT(other_constant != NULL); |
(...skipping 1518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1703 defn = defn->AsConstraint()->value()->definition(); | 1714 defn = defn->AsConstraint()->value()->definition(); |
1704 } | 1715 } |
1705 return defn; | 1716 return defn; |
1706 } | 1717 } |
1707 | 1718 |
1708 | 1719 |
1709 static bool AreEqualDefinitions(Definition* a, Definition* b) { | 1720 static bool AreEqualDefinitions(Definition* a, Definition* b) { |
1710 a = UnwrapConstraint(a); | 1721 a = UnwrapConstraint(a); |
1711 b = UnwrapConstraint(b); | 1722 b = UnwrapConstraint(b); |
1712 return (a == b) || | 1723 return (a == b) || |
1713 (!a->AffectedBySideEffect() && | 1724 (a->AllowsCSE() && |
1714 !b->AffectedBySideEffect() && | 1725 a->Dependencies().IsNone() && |
1726 b->AllowsCSE() && | |
1727 b->Dependencies().IsNone() && | |
1715 a->Equals(b)); | 1728 a->Equals(b)); |
1716 } | 1729 } |
1717 | 1730 |
1718 | 1731 |
1719 // Returns true if two range boundaries refer to the same symbol. | 1732 // Returns true if two range boundaries refer to the same symbol. |
1720 static bool DependOnSameSymbol(const RangeBoundary& a, const RangeBoundary& b) { | 1733 static bool DependOnSameSymbol(const RangeBoundary& a, const RangeBoundary& b) { |
1721 return a.IsSymbol() && b.IsSymbol() && | 1734 return a.IsSymbol() && b.IsSymbol() && |
1722 AreEqualDefinitions(a.symbol(), b.symbol()); | 1735 AreEqualDefinitions(a.symbol(), b.symbol()); |
1723 } | 1736 } |
1724 | 1737 |
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2380 default: | 2393 default: |
2381 UNREACHABLE(); | 2394 UNREACHABLE(); |
2382 } | 2395 } |
2383 return kPowRuntimeEntry; | 2396 return kPowRuntimeEntry; |
2384 } | 2397 } |
2385 | 2398 |
2386 | 2399 |
2387 #undef __ | 2400 #undef __ |
2388 | 2401 |
2389 } // namespace dart | 2402 } // namespace dart |
OLD | NEW |