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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 | 98 |
99 class ChangeLoweringCommonTest | 99 class ChangeLoweringCommonTest |
100 : public ChangeLoweringTest, | 100 : public ChangeLoweringTest, |
101 public ::testing::WithParamInterface<MachineRepresentation> { | 101 public ::testing::WithParamInterface<MachineRepresentation> { |
102 public: | 102 public: |
103 ~ChangeLoweringCommonTest() override {} | 103 ~ChangeLoweringCommonTest() override {} |
104 | 104 |
105 MachineRepresentation WordRepresentation() const final { return GetParam(); } | 105 MachineRepresentation WordRepresentation() const final { return GetParam(); } |
106 }; | 106 }; |
107 | 107 |
108 | |
109 TARGET_TEST_P(ChangeLoweringCommonTest, ChangeBitToBool) { | |
110 Node* value = Parameter(Type::Boolean()); | |
111 Reduction r = | |
112 Reduce(graph()->NewNode(simplified()->ChangeBitToBool(), value)); | |
113 ASSERT_TRUE(r.Changed()); | |
114 EXPECT_THAT(r.replacement(), IsSelect(MachineRepresentation::kTagged, value, | |
115 IsTrueConstant(), IsFalseConstant())); | |
116 } | |
117 | |
118 | |
119 TARGET_TEST_P(ChangeLoweringCommonTest, ChangeBoolToBit) { | |
120 Node* value = Parameter(Type::Number()); | |
121 Reduction r = | |
122 Reduce(graph()->NewNode(simplified()->ChangeBoolToBit(), value)); | |
123 ASSERT_TRUE(r.Changed()); | |
124 EXPECT_THAT(r.replacement(), IsWordEqual(value, IsTrueConstant())); | |
125 } | |
126 | |
127 TARGET_TEST_P(ChangeLoweringCommonTest, ChangeInt31ToTagged) { | |
128 Node* value = Parameter(Type::SignedSmall()); | |
129 Reduction r = | |
130 Reduce(graph()->NewNode(simplified()->ChangeInt31ToTagged(), value)); | |
131 ASSERT_TRUE(r.Changed()); | |
132 EXPECT_THAT(r.replacement(), IsChangeInt32ToSmi(value)); | |
133 } | |
134 | |
135 TARGET_TEST_P(ChangeLoweringCommonTest, StoreFieldSmi) { | 108 TARGET_TEST_P(ChangeLoweringCommonTest, StoreFieldSmi) { |
136 FieldAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, | 109 FieldAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, |
137 Handle<Name>::null(), Type::Any(), | 110 Handle<Name>::null(), Type::Any(), |
138 MachineType::AnyTagged()}; | 111 MachineType::AnyTagged()}; |
139 Node* p0 = Parameter(Type::TaggedPointer()); | 112 Node* p0 = Parameter(Type::TaggedPointer()); |
140 Node* p1 = Parameter(Type::TaggedSigned()); | 113 Node* p1 = Parameter(Type::TaggedSigned()); |
141 Node* store = graph()->NewNode(simplified()->StoreField(access), p0, p1, | 114 Node* store = graph()->NewNode(simplified()->StoreField(access), p0, p1, |
142 graph()->start(), graph()->start()); | 115 graph()->start(), graph()->start()); |
143 Reduction r = Reduce(store); | 116 Reduction r = Reduce(store); |
144 | 117 |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 Reduction r = Reduce(alloc); | 264 Reduction r = Reduce(alloc); |
292 | 265 |
293 // Only check that we lowered, but do not specify the exact form since | 266 // Only check that we lowered, but do not specify the exact form since |
294 // this is subject to change. | 267 // this is subject to change. |
295 ASSERT_TRUE(r.Changed()); | 268 ASSERT_TRUE(r.Changed()); |
296 } | 269 } |
297 | 270 |
298 } // namespace compiler | 271 } // namespace compiler |
299 } // namespace internal | 272 } // namespace internal |
300 } // namespace v8 | 273 } // namespace v8 |
OLD | NEW |