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 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 | 303 |
304 TEST_F(JSIntrinsicLoweringTest, Likely) { | 304 TEST_F(JSIntrinsicLoweringTest, Likely) { |
305 Node* const input = Parameter(0); | 305 Node* const input = Parameter(0); |
306 Node* const context = Parameter(1); | 306 Node* const context = Parameter(1); |
307 Node* const effect = graph()->start(); | 307 Node* const effect = graph()->start(); |
308 Node* const control = graph()->start(); | 308 Node* const control = graph()->start(); |
309 Node* const likely = | 309 Node* const likely = |
310 graph()->NewNode(javascript()->CallRuntime(Runtime::kInlineLikely, 1), | 310 graph()->NewNode(javascript()->CallRuntime(Runtime::kInlineLikely, 1), |
311 input, context, effect, control); | 311 input, context, effect, control); |
312 Node* const to_boolean = | 312 Node* const to_boolean = |
313 graph()->NewNode(javascript()->ToBoolean(), likely, context); | 313 graph()->NewNode(javascript()->ToBoolean(), likely, context, effect); |
314 Diamond d(graph(), common(), to_boolean); | 314 Diamond d(graph(), common(), to_boolean); |
315 graph()->SetEnd(graph()->NewNode(common()->End(1), d.merge)); | 315 graph()->SetEnd(graph()->NewNode(common()->End(1), d.merge)); |
316 | 316 |
317 ASSERT_EQ(BranchHint::kNone, BranchHintOf(d.branch->op())); | 317 ASSERT_EQ(BranchHint::kNone, BranchHintOf(d.branch->op())); |
318 Reduction const r = Reduce(likely); | 318 Reduction const r = Reduce(likely); |
319 ASSERT_TRUE(r.Changed()); | 319 ASSERT_TRUE(r.Changed()); |
320 EXPECT_THAT(r.replacement(), input); | 320 EXPECT_THAT(r.replacement(), input); |
321 ASSERT_EQ(BranchHint::kTrue, BranchHintOf(d.branch->op())); | 321 ASSERT_EQ(BranchHint::kTrue, BranchHintOf(d.branch->op())); |
322 } | 322 } |
323 | 323 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 | 398 |
399 TEST_F(JSIntrinsicLoweringTest, Unlikely) { | 399 TEST_F(JSIntrinsicLoweringTest, Unlikely) { |
400 Node* const input = Parameter(0); | 400 Node* const input = Parameter(0); |
401 Node* const context = Parameter(1); | 401 Node* const context = Parameter(1); |
402 Node* const effect = graph()->start(); | 402 Node* const effect = graph()->start(); |
403 Node* const control = graph()->start(); | 403 Node* const control = graph()->start(); |
404 Node* const unlikely = | 404 Node* const unlikely = |
405 graph()->NewNode(javascript()->CallRuntime(Runtime::kInlineUnlikely, 1), | 405 graph()->NewNode(javascript()->CallRuntime(Runtime::kInlineUnlikely, 1), |
406 input, context, effect, control); | 406 input, context, effect, control); |
407 Node* const to_boolean = | 407 Node* const to_boolean = |
408 graph()->NewNode(javascript()->ToBoolean(), unlikely, context); | 408 graph()->NewNode(javascript()->ToBoolean(), unlikely, context, effect); |
409 Diamond d(graph(), common(), to_boolean); | 409 Diamond d(graph(), common(), to_boolean); |
410 graph()->SetEnd(graph()->NewNode(common()->End(1), d.merge)); | 410 graph()->SetEnd(graph()->NewNode(common()->End(1), d.merge)); |
411 | 411 |
412 ASSERT_EQ(BranchHint::kNone, BranchHintOf(d.branch->op())); | 412 ASSERT_EQ(BranchHint::kNone, BranchHintOf(d.branch->op())); |
413 Reduction const r = Reduce(unlikely); | 413 Reduction const r = Reduce(unlikely); |
414 ASSERT_TRUE(r.Changed()); | 414 ASSERT_TRUE(r.Changed()); |
415 EXPECT_THAT(r.replacement(), input); | 415 EXPECT_THAT(r.replacement(), input); |
416 ASSERT_EQ(BranchHint::kFalse, BranchHintOf(d.branch->op())); | 416 ASSERT_EQ(BranchHint::kFalse, BranchHintOf(d.branch->op())); |
417 } | 417 } |
418 | 418 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 CaptureEq(&if_false0)))))), | 455 CaptureEq(&if_false0)))))), |
456 IsMerge( | 456 IsMerge( |
457 IsIfTrue(AllOf(CaptureEq(&branch0), | 457 IsIfTrue(AllOf(CaptureEq(&branch0), |
458 IsBranch(IsObjectIsSmi(input), control))), | 458 IsBranch(IsObjectIsSmi(input), control))), |
459 AllOf(CaptureEq(&if_false0), IsIfFalse(CaptureEq(&branch0)))))); | 459 AllOf(CaptureEq(&if_false0), IsIfFalse(CaptureEq(&branch0)))))); |
460 } | 460 } |
461 | 461 |
462 } // namespace compiler | 462 } // namespace compiler |
463 } // namespace internal | 463 } // namespace internal |
464 } // namespace v8 | 464 } // namespace v8 |
OLD | NEW |