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/code-stubs.h" | 5 #include "src/code-stubs.h" |
6 #include "src/compiler/change-lowering.h" | 6 #include "src/compiler/change-lowering.h" |
7 #include "src/compiler/js-graph.h" | 7 #include "src/compiler/js-graph.h" |
8 #include "src/compiler/linkage.h" | 8 #include "src/compiler/linkage.h" |
9 #include "src/compiler/node-properties.h" | 9 #include "src/compiler/node-properties.h" |
10 #include "src/compiler/simplified-operator.h" | 10 #include "src/compiler/simplified-operator.h" |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 class ChangeLowering32Test : public ChangeLoweringTest { | 174 class ChangeLowering32Test : public ChangeLoweringTest { |
175 public: | 175 public: |
176 ~ChangeLowering32Test() OVERRIDE {} | 176 ~ChangeLowering32Test() OVERRIDE {} |
177 MachineType WordRepresentation() const FINAL { return kRepWord32; } | 177 MachineType WordRepresentation() const FINAL { return kRepWord32; } |
178 }; | 178 }; |
179 | 179 |
180 | 180 |
181 TARGET_TEST_F(ChangeLowering32Test, ChangeInt32ToTagged) { | 181 TARGET_TEST_F(ChangeLowering32Test, ChangeInt32ToTagged) { |
182 Node* val = Parameter(0); | 182 Node* val = Parameter(0); |
183 Node* node = graph()->NewNode(simplified()->ChangeInt32ToTagged(), val); | 183 Node* node = graph()->NewNode(simplified()->ChangeInt32ToTagged(), val); |
184 NodeProperties::SetBounds(val, Bounds(Type::None(), Type::Signed32())); | 184 NodeProperties::SetBounds(val, Bounds(Type::None(), Type::Integral32())); |
185 Reduction reduction = Reduce(node); | 185 Reduction reduction = Reduce(node); |
186 ASSERT_TRUE(reduction.Changed()); | 186 ASSERT_TRUE(reduction.Changed()); |
187 | 187 |
188 Node* phi = reduction.replacement(); | 188 Node* phi = reduction.replacement(); |
189 Capture<Node*> add, branch, heap_number, if_true; | 189 Capture<Node*> add, branch, heap_number, if_true; |
190 EXPECT_THAT( | 190 EXPECT_THAT( |
191 phi, | 191 phi, |
192 IsPhi(kMachAnyTagged, | 192 IsPhi(kMachAnyTagged, |
193 IsFinish(AllOf(CaptureEq(&heap_number), | 193 IsFinish(AllOf(CaptureEq(&heap_number), |
194 IsAllocateHeapNumber(_, CaptureEq(&if_true))), | 194 IsAllocateHeapNumber(_, CaptureEq(&if_true))), |
195 IsStore(StoreRepresentation(kMachFloat64, kNoWriteBarrier), | 195 IsStore(StoreRepresentation(kMachFloat64, kNoWriteBarrier), |
196 CaptureEq(&heap_number), | 196 CaptureEq(&heap_number), |
197 IsIntPtrConstant(HeapNumberValueOffset()), | 197 IsIntPtrConstant(HeapNumberValueOffset()), |
198 IsChangeInt32ToFloat64(val), | 198 IsChangeInt32ToFloat64(val), |
199 CaptureEq(&heap_number), CaptureEq(&if_true))), | 199 CaptureEq(&heap_number), CaptureEq(&if_true))), |
200 IsProjection( | 200 IsProjection( |
201 0, AllOf(CaptureEq(&add), IsInt32AddWithOverflow(val, val))), | 201 0, AllOf(CaptureEq(&add), IsInt32AddWithOverflow(val, val))), |
202 IsMerge(AllOf(CaptureEq(&if_true), IsIfTrue(CaptureEq(&branch))), | 202 IsMerge(AllOf(CaptureEq(&if_true), IsIfTrue(CaptureEq(&branch))), |
203 IsIfFalse(AllOf(CaptureEq(&branch), | 203 IsIfFalse(AllOf(CaptureEq(&branch), |
204 IsBranch(IsProjection(1, CaptureEq(&add)), | 204 IsBranch(IsProjection(1, CaptureEq(&add)), |
205 graph()->start())))))); | 205 graph()->start())))))); |
206 } | 206 } |
207 | 207 |
208 | 208 |
209 TARGET_TEST_F(ChangeLowering32Test, ChangeInt32ToTaggedSmall) { | 209 TARGET_TEST_F(ChangeLowering32Test, ChangeInt32ToTaggedSmall) { |
210 Node* val = Parameter(0); | 210 Node* val = Parameter(0); |
211 Node* node = graph()->NewNode(simplified()->ChangeInt32ToTagged(), val); | 211 Node* node = graph()->NewNode(simplified()->ChangeInt32ToTagged(), val); |
212 NodeProperties::SetBounds(val, Bounds(Type::None(), Type::Signed31())); | 212 NodeProperties::SetBounds(val, Bounds(Type::None(), Type::SignedSmall())); |
213 Reduction reduction = Reduce(node); | 213 Reduction reduction = Reduce(node); |
214 ASSERT_TRUE(reduction.Changed()); | 214 ASSERT_TRUE(reduction.Changed()); |
215 | 215 |
216 Node* change = reduction.replacement(); | 216 Node* change = reduction.replacement(); |
217 Capture<Node*> add, branch, heap_number, if_true; | 217 Capture<Node*> add, branch, heap_number, if_true; |
218 EXPECT_THAT(change, IsWord32Shl(val, IsInt32Constant(SmiShiftAmount()))); | 218 EXPECT_THAT(change, IsWord32Shl(val, IsInt32Constant(SmiShiftAmount()))); |
219 } | 219 } |
220 | 220 |
221 | 221 |
222 TARGET_TEST_F(ChangeLowering32Test, ChangeTaggedToFloat64) { | 222 TARGET_TEST_F(ChangeLowering32Test, ChangeTaggedToFloat64) { |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 IsIfTrue(AllOf(CaptureEq(&branch), | 452 IsIfTrue(AllOf(CaptureEq(&branch), |
453 IsBranch(IsUint32LessThanOrEqual( | 453 IsBranch(IsUint32LessThanOrEqual( |
454 val, IsInt32Constant(SmiMaxValue())), | 454 val, IsInt32Constant(SmiMaxValue())), |
455 graph()->start()))), | 455 graph()->start()))), |
456 AllOf(CaptureEq(&if_false), IsIfFalse(CaptureEq(&branch)))))); | 456 AllOf(CaptureEq(&if_false), IsIfFalse(CaptureEq(&branch)))))); |
457 } | 457 } |
458 | 458 |
459 } // namespace compiler | 459 } // namespace compiler |
460 } // namespace internal | 460 } // namespace internal |
461 } // namespace v8 | 461 } // namespace v8 |
OLD | NEW |