OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/compiler/simplified-lowering.h" | 5 #include "src/compiler/simplified-lowering.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "src/address-map.h" | 9 #include "src/address-map.h" |
10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 ReplaceEffectControlUses(node, effect, control); | 121 ReplaceEffectControlUses(node, effect, control); |
122 node->TrimInputCount(new_op->ValueInputCount()); | 122 node->TrimInputCount(new_op->ValueInputCount()); |
123 } else { | 123 } else { |
124 DCHECK_EQ(0, node->op()->ControlInputCount()); | 124 DCHECK_EQ(0, node->op()->ControlInputCount()); |
125 } | 125 } |
126 NodeProperties::ChangeOp(node, new_op); | 126 NodeProperties::ChangeOp(node, new_op); |
127 } | 127 } |
128 | 128 |
129 #ifdef DEBUG | 129 #ifdef DEBUG |
130 // Helpers for monotonicity checking. | 130 // Helpers for monotonicity checking. |
131 bool MachineRepresentationIsSubtype(MachineRepresentation r1, | |
132 MachineRepresentation r2) { | |
133 switch (r1) { | |
134 case MachineRepresentation::kNone: | |
135 return true; | |
136 case MachineRepresentation::kBit: | |
137 return r2 == MachineRepresentation::kBit || | |
138 r2 == MachineRepresentation::kTagged; | |
139 case MachineRepresentation::kWord8: | |
140 return r2 == MachineRepresentation::kWord8 || | |
141 r2 == MachineRepresentation::kWord16 || | |
142 r2 == MachineRepresentation::kWord32 || | |
143 r2 == MachineRepresentation::kWord64 || | |
144 r2 == MachineRepresentation::kFloat32 || | |
145 r2 == MachineRepresentation::kFloat64 || | |
146 r2 == MachineRepresentation::kTagged; | |
147 case MachineRepresentation::kWord16: | |
148 return r2 == MachineRepresentation::kWord16 || | |
149 r2 == MachineRepresentation::kWord32 || | |
150 r2 == MachineRepresentation::kWord64 || | |
151 r2 == MachineRepresentation::kFloat32 || | |
152 r2 == MachineRepresentation::kFloat64 || | |
153 r2 == MachineRepresentation::kTagged; | |
154 case MachineRepresentation::kWord32: | |
155 return r2 == MachineRepresentation::kWord32 || | |
156 r2 == MachineRepresentation::kWord64 || | |
157 r2 == MachineRepresentation::kFloat64 || | |
158 r2 == MachineRepresentation::kTagged; | |
159 case MachineRepresentation::kWord64: | |
160 return r2 == MachineRepresentation::kWord64; | |
161 case MachineRepresentation::kFloat32: | |
162 return r2 == MachineRepresentation::kFloat32 || | |
163 r2 == MachineRepresentation::kFloat64 || | |
164 r2 == MachineRepresentation::kTagged; | |
165 case MachineRepresentation::kFloat64: | |
166 return r2 == MachineRepresentation::kFloat64 || | |
167 r2 == MachineRepresentation::kTagged; | |
168 case MachineRepresentation::kSimd128: | |
169 return r2 == MachineRepresentation::kSimd128 || | |
170 r2 == MachineRepresentation::kTagged; | |
171 case MachineRepresentation::kTagged: | |
172 return r2 == MachineRepresentation::kTagged; | |
173 } | |
174 UNREACHABLE(); | |
175 return false; | |
176 } | |
177 | |
178 | |
179 class InputUseInfos { | 131 class InputUseInfos { |
180 public: | 132 public: |
181 explicit InputUseInfos(Zone* zone) : input_use_infos_(zone) {} | 133 explicit InputUseInfos(Zone* zone) : input_use_infos_(zone) {} |
182 | 134 |
183 void SetAndCheckInput(Node* node, int index, UseInfo use_info) { | 135 void SetAndCheckInput(Node* node, int index, UseInfo use_info) { |
184 if (input_use_infos_.empty()) { | 136 if (input_use_infos_.empty()) { |
185 input_use_infos_.resize(node->InputCount(), UseInfo::None()); | 137 input_use_infos_.resize(node->InputCount(), UseInfo::None()); |
186 } | 138 } |
187 // Check that the new use informatin is a super-type of the old | 139 // Check that the new use informatin is a super-type of the old |
188 // one. | 140 // one. |
189 CHECK(IsUseLessGeneral(input_use_infos_[index], use_info)); | 141 CHECK(IsUseLessGeneral(input_use_infos_[index], use_info)); |
190 input_use_infos_[index] = use_info; | 142 input_use_infos_[index] = use_info; |
191 } | 143 } |
192 | 144 |
193 private: | 145 private: |
194 ZoneVector<UseInfo> input_use_infos_; | 146 ZoneVector<UseInfo> input_use_infos_; |
195 | 147 |
196 static bool IsUseLessGeneral(UseInfo use1, UseInfo use2) { | 148 static bool IsUseLessGeneral(UseInfo use1, UseInfo use2) { |
197 return MachineRepresentationIsSubtype(use1.representation(), | 149 return use1.truncation().IsLessGeneralThan(use2.truncation()); |
198 use2.representation()) && | |
199 use1.truncation().IsLessGeneralThan(use2.truncation()); | |
200 } | 150 } |
201 }; | 151 }; |
202 | 152 |
203 #endif // DEBUG | 153 #endif // DEBUG |
204 | 154 |
205 } // namespace | 155 } // namespace |
206 | 156 |
207 | 157 |
208 class RepresentationSelector { | 158 class RepresentationSelector { |
209 public: | 159 public: |
(...skipping 3301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3511 isolate(), graph()->zone(), callable.descriptor(), 0, flags, | 3461 isolate(), graph()->zone(), callable.descriptor(), 0, flags, |
3512 Operator::kNoProperties); | 3462 Operator::kNoProperties); |
3513 to_number_operator_.set(common()->Call(desc)); | 3463 to_number_operator_.set(common()->Call(desc)); |
3514 } | 3464 } |
3515 return to_number_operator_.get(); | 3465 return to_number_operator_.get(); |
3516 } | 3466 } |
3517 | 3467 |
3518 } // namespace compiler | 3468 } // namespace compiler |
3519 } // namespace internal | 3469 } // namespace internal |
3520 } // namespace v8 | 3470 } // namespace v8 |
OLD | NEW |