| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/access-builder.h" | 5 #include "src/compiler/access-builder.h" |
| 6 #include "src/compiler/diamond.h" | 6 #include "src/compiler/diamond.h" |
| 7 #include "src/compiler/js-graph.h" | 7 #include "src/compiler/js-graph.h" |
| 8 #include "src/compiler/js-intrinsic-lowering.h" | 8 #include "src/compiler/js-intrinsic-lowering.h" |
| 9 #include "src/compiler/js-operator.h" | 9 #include "src/compiler/js-operator.h" |
| 10 #include "test/unittests/compiler/graph-unittest.h" | 10 #include "test/unittests/compiler/graph-unittest.h" |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 Node* const context = Parameter(1); | 169 Node* const context = Parameter(1); |
| 170 Node* const effect = graph()->start(); | 170 Node* const effect = graph()->start(); |
| 171 Node* const control = graph()->start(); | 171 Node* const control = graph()->start(); |
| 172 Reduction const r = Reduce(graph()->NewNode( | 172 Reduction const r = Reduce(graph()->NewNode( |
| 173 javascript()->CallRuntime(Runtime::kInlineIsJSReceiver, 1), input, | 173 javascript()->CallRuntime(Runtime::kInlineIsJSReceiver, 1), input, |
| 174 context, effect, control)); | 174 context, effect, control)); |
| 175 ASSERT_TRUE(r.Changed()); | 175 ASSERT_TRUE(r.Changed()); |
| 176 EXPECT_THAT(r.replacement(), IsObjectIsReceiver(input)); | 176 EXPECT_THAT(r.replacement(), IsObjectIsReceiver(input)); |
| 177 } | 177 } |
| 178 | 178 |
| 179 | |
| 180 // ----------------------------------------------------------------------------- | |
| 181 // %_ValueOf | |
| 182 | |
| 183 | |
| 184 TEST_F(JSIntrinsicLoweringTest, InlineValueOf) { | |
| 185 Node* const input = Parameter(0); | |
| 186 Node* const context = Parameter(1); | |
| 187 Node* const effect = graph()->start(); | |
| 188 Node* const control = graph()->start(); | |
| 189 Reduction const r = Reduce( | |
| 190 graph()->NewNode(javascript()->CallRuntime(Runtime::kInlineValueOf, 1), | |
| 191 input, context, effect, control)); | |
| 192 ASSERT_TRUE(r.Changed()); | |
| 193 | |
| 194 Node* phi = r.replacement(); | |
| 195 Capture<Node*> branch0, if_false0, branch1, if_true1; | |
| 196 EXPECT_THAT( | |
| 197 phi, | |
| 198 IsPhi( | |
| 199 MachineRepresentation::kTagged, input, | |
| 200 IsPhi(MachineRepresentation::kTagged, | |
| 201 IsLoadField(AccessBuilder::ForValue(), input, effect, | |
| 202 CaptureEq(&if_true1)), | |
| 203 input, | |
| 204 IsMerge( | |
| 205 AllOf(CaptureEq(&if_true1), IsIfTrue(CaptureEq(&branch1))), | |
| 206 IsIfFalse(AllOf( | |
| 207 CaptureEq(&branch1), | |
| 208 IsBranch( | |
| 209 IsWord32Equal( | |
| 210 IsLoadField( | |
| 211 AccessBuilder::ForMapInstanceType(), | |
| 212 IsLoadField(AccessBuilder::ForMap(), input, | |
| 213 effect, CaptureEq(&if_false0)), | |
| 214 effect, _), | |
| 215 IsInt32Constant(JS_VALUE_TYPE)), | |
| 216 CaptureEq(&if_false0)))))), | |
| 217 IsMerge( | |
| 218 IsIfTrue(AllOf(CaptureEq(&branch0), | |
| 219 IsBranch(IsObjectIsSmi(input), control))), | |
| 220 AllOf(CaptureEq(&if_false0), IsIfFalse(CaptureEq(&branch0)))))); | |
| 221 } | |
| 222 | |
| 223 } // namespace compiler | 179 } // namespace compiler |
| 224 } // namespace internal | 180 } // namespace internal |
| 225 } // namespace v8 | 181 } // namespace v8 |
| OLD | NEW |