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/change-lowering.h" | 5 #include "src/compiler/change-lowering.h" |
6 #include "src/compiler/js-graph.h" | 6 #include "src/compiler/js-graph.h" |
7 #include "src/compiler/node-properties-inl.h" | 7 #include "src/compiler/node-properties-inl.h" |
8 #include "src/compiler/simplified-operator.h" | 8 #include "src/compiler/simplified-operator.h" |
9 #include "src/compiler/typer.h" | 9 #include "src/compiler/typer.h" |
10 #include "test/compiler-unittests/graph-unittest.h" | 10 #include "test/compiler-unittests/graph-unittest.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 Matcher<Node*> IsAllocateHeapNumber(const Matcher<Node*>& effect_matcher, | 98 Matcher<Node*> IsAllocateHeapNumber(const Matcher<Node*>& effect_matcher, |
99 const Matcher<Node*>& control_matcher) { | 99 const Matcher<Node*>& control_matcher) { |
100 return IsCall( | 100 return IsCall( |
101 _, IsHeapConstant(PrintableUnique<HeapObject>::CreateImmovable( | 101 _, IsHeapConstant(PrintableUnique<HeapObject>::CreateImmovable( |
102 zone(), CEntryStub(isolate(), 1).GetCode())), | 102 zone(), CEntryStub(isolate(), 1).GetCode())), |
103 IsExternalConstant(ExternalReference( | 103 IsExternalConstant(ExternalReference( |
104 Runtime::FunctionForId(Runtime::kAllocateHeapNumber), isolate())), | 104 Runtime::FunctionForId(Runtime::kAllocateHeapNumber), isolate())), |
105 IsInt32Constant(0), IsNumberConstant(0.0), effect_matcher, | 105 IsInt32Constant(0), IsNumberConstant(0.0), effect_matcher, |
106 control_matcher); | 106 control_matcher); |
107 } | 107 } |
108 Matcher<Node*> IsFalse() { | |
109 return IsHeapConstant(PrintableUnique<HeapObject>::CreateImmovable( | |
110 zone(), factory()->false_value())); | |
111 } | |
112 Matcher<Node*> IsTrue() { | |
113 return IsHeapConstant(PrintableUnique<HeapObject>::CreateImmovable( | |
114 zone(), factory()->true_value())); | |
115 } | |
116 Matcher<Node*> IsWordEqual(const Matcher<Node*>& lhs_matcher, | 108 Matcher<Node*> IsWordEqual(const Matcher<Node*>& lhs_matcher, |
117 const Matcher<Node*>& rhs_matcher) { | 109 const Matcher<Node*>& rhs_matcher) { |
118 return Is32() ? IsWord32Equal(lhs_matcher, rhs_matcher) | 110 return Is32() ? IsWord32Equal(lhs_matcher, rhs_matcher) |
119 : IsWord64Equal(lhs_matcher, rhs_matcher); | 111 : IsWord64Equal(lhs_matcher, rhs_matcher); |
120 } | 112 } |
121 | 113 |
122 private: | 114 private: |
123 SimplifiedOperatorBuilder simplified_; | 115 SimplifiedOperatorBuilder simplified_; |
124 }; | 116 }; |
125 | 117 |
(...skipping 16 matching lines...) Expand all Loading... |
142 | 134 |
143 TARGET_TEST_P(ChangeLoweringCommonTest, ChangeBitToBool) { | 135 TARGET_TEST_P(ChangeLoweringCommonTest, ChangeBitToBool) { |
144 Node* val = Parameter(0); | 136 Node* val = Parameter(0); |
145 Node* node = graph()->NewNode(simplified()->ChangeBitToBool(), val); | 137 Node* node = graph()->NewNode(simplified()->ChangeBitToBool(), val); |
146 Reduction reduction = Reduce(node); | 138 Reduction reduction = Reduce(node); |
147 ASSERT_TRUE(reduction.Changed()); | 139 ASSERT_TRUE(reduction.Changed()); |
148 | 140 |
149 Node* phi = reduction.replacement(); | 141 Node* phi = reduction.replacement(); |
150 Capture<Node*> branch; | 142 Capture<Node*> branch; |
151 EXPECT_THAT(phi, | 143 EXPECT_THAT(phi, |
152 IsPhi(IsTrue(), IsFalse(), | 144 IsPhi(IsTrueConstant(), IsFalseConstant(), |
153 IsMerge(IsIfTrue(AllOf(CaptureEq(&branch), | 145 IsMerge(IsIfTrue(AllOf(CaptureEq(&branch), |
154 IsBranch(val, graph()->start()))), | 146 IsBranch(val, graph()->start()))), |
155 IsIfFalse(CaptureEq(&branch))))); | 147 IsIfFalse(CaptureEq(&branch))))); |
156 } | 148 } |
157 | 149 |
158 | 150 |
159 TARGET_TEST_P(ChangeLoweringCommonTest, ChangeBoolToBit) { | 151 TARGET_TEST_P(ChangeLoweringCommonTest, ChangeBoolToBit) { |
160 Node* val = Parameter(0); | 152 Node* val = Parameter(0); |
161 Node* node = graph()->NewNode(simplified()->ChangeBoolToBit(), val); | 153 Node* node = graph()->NewNode(simplified()->ChangeBoolToBit(), val); |
162 Reduction reduction = Reduce(node); | 154 Reduction reduction = Reduce(node); |
163 ASSERT_TRUE(reduction.Changed()); | 155 ASSERT_TRUE(reduction.Changed()); |
164 | 156 |
165 EXPECT_THAT(reduction.replacement(), IsWordEqual(val, IsTrue())); | 157 EXPECT_THAT(reduction.replacement(), IsWordEqual(val, IsTrueConstant())); |
166 } | 158 } |
167 | 159 |
168 | 160 |
169 TARGET_TEST_P(ChangeLoweringCommonTest, ChangeFloat64ToTagged) { | 161 TARGET_TEST_P(ChangeLoweringCommonTest, ChangeFloat64ToTagged) { |
170 Node* val = Parameter(0); | 162 Node* val = Parameter(0); |
171 Node* node = graph()->NewNode(simplified()->ChangeFloat64ToTagged(), val); | 163 Node* node = graph()->NewNode(simplified()->ChangeFloat64ToTagged(), val); |
172 Reduction reduction = Reduce(node); | 164 Reduction reduction = Reduce(node); |
173 ASSERT_TRUE(reduction.Changed()); | 165 ASSERT_TRUE(reduction.Changed()); |
174 | 166 |
175 Node* finish = reduction.replacement(); | 167 Node* finish = reduction.replacement(); |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 IsIfTrue(AllOf(CaptureEq(&branch), | 469 IsIfTrue(AllOf(CaptureEq(&branch), |
478 IsBranch(IsUint32LessThanOrEqual( | 470 IsBranch(IsUint32LessThanOrEqual( |
479 val, IsInt32Constant(SmiMaxValue())), | 471 val, IsInt32Constant(SmiMaxValue())), |
480 graph()->start()))), | 472 graph()->start()))), |
481 AllOf(CaptureEq(&if_false), IsIfFalse(CaptureEq(&branch)))))); | 473 AllOf(CaptureEq(&if_false), IsIfFalse(CaptureEq(&branch)))))); |
482 } | 474 } |
483 | 475 |
484 } // namespace compiler | 476 } // namespace compiler |
485 } // namespace internal | 477 } // namespace internal |
486 } // namespace v8 | 478 } // namespace v8 |
OLD | NEW |