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-factory.h" | 5 #include "src/code-factory.h" |
6 #include "src/compiler/access-builder.h" | 6 #include "src/compiler/access-builder.h" |
7 #include "src/compiler/js-graph.h" | 7 #include "src/compiler/js-graph.h" |
8 #include "src/compiler/js-operator.h" | 8 #include "src/compiler/js-operator.h" |
9 #include "src/compiler/js-typed-lowering.h" | 9 #include "src/compiler/js-typed-lowering.h" |
10 #include "src/compiler/machine-operator.h" | 10 #include "src/compiler/machine-operator.h" |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 Node* const effect = graph()->start(); | 457 Node* const effect = graph()->start(); |
458 Node* const control = graph()->start(); | 458 Node* const control = graph()->start(); |
459 Reduction r = Reduce(graph()->NewNode(javascript()->ToObject(), input, | 459 Reduction r = Reduce(graph()->NewNode(javascript()->ToObject(), input, |
460 context, frame_state, effect, control)); | 460 context, frame_state, effect, control)); |
461 ASSERT_TRUE(r.Changed()); | 461 ASSERT_TRUE(r.Changed()); |
462 EXPECT_EQ(input, r.replacement()); | 462 EXPECT_EQ(input, r.replacement()); |
463 } | 463 } |
464 | 464 |
465 | 465 |
466 // ----------------------------------------------------------------------------- | 466 // ----------------------------------------------------------------------------- |
| 467 // JSToString |
| 468 |
| 469 |
| 470 TEST_F(JSTypedLoweringTest, JSToStringWithBoolean) { |
| 471 Node* const input = Parameter(Type::Boolean(), 0); |
| 472 Node* const context = Parameter(Type::Any(), 1); |
| 473 Node* const frame_state = EmptyFrameState(); |
| 474 Node* const effect = graph()->start(); |
| 475 Node* const control = graph()->start(); |
| 476 Reduction r = Reduce(graph()->NewNode(javascript()->ToString(), input, |
| 477 context, frame_state, effect, control)); |
| 478 ASSERT_TRUE(r.Changed()); |
| 479 EXPECT_THAT( |
| 480 r.replacement(), |
| 481 IsSelect(kMachAnyTagged, input, IsHeapConstant(factory()->true_string()), |
| 482 IsHeapConstant(factory()->false_string()))); |
| 483 } |
| 484 |
| 485 |
| 486 // ----------------------------------------------------------------------------- |
467 // JSStrictEqual | 487 // JSStrictEqual |
468 | 488 |
469 | 489 |
470 TEST_F(JSTypedLoweringTest, JSStrictEqualWithTheHole) { | 490 TEST_F(JSTypedLoweringTest, JSStrictEqualWithTheHole) { |
471 Node* const the_hole = HeapConstant(factory()->the_hole_value()); | 491 Node* const the_hole = HeapConstant(factory()->the_hole_value()); |
472 Node* const context = UndefinedConstant(); | 492 Node* const context = UndefinedConstant(); |
473 TRACED_FOREACH(Type*, type, kJSTypes) { | 493 TRACED_FOREACH(Type*, type, kJSTypes) { |
474 Node* const lhs = Parameter(type); | 494 Node* const lhs = Parameter(type); |
475 Reduction r = | 495 Reduction r = |
476 Reduce(graph()->NewNode(javascript()->StrictEqual(), lhs, the_hole, | 496 Reduce(graph()->NewNode(javascript()->StrictEqual(), lhs, the_hole, |
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1144 EXPECT_THAT(r.replacement(), | 1164 EXPECT_THAT(r.replacement(), |
1145 IsFinishRegion(IsAllocate(IsNumberConstant(Context::SizeFor( | 1165 IsFinishRegion(IsAllocate(IsNumberConstant(Context::SizeFor( |
1146 Context::MIN_CONTEXT_SLOTS)), | 1166 Context::MIN_CONTEXT_SLOTS)), |
1147 IsBeginRegion(effect), control), | 1167 IsBeginRegion(effect), control), |
1148 _)); | 1168 _)); |
1149 } | 1169 } |
1150 | 1170 |
1151 } // namespace compiler | 1171 } // namespace compiler |
1152 } // namespace internal | 1172 } // namespace internal |
1153 } // namespace v8 | 1173 } // namespace v8 |
OLD | NEW |