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 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 Reduction r = | 427 Reduction r = |
428 Reduce(graph()->NewNode(javascript()->ToNumber(), input, context, | 428 Reduce(graph()->NewNode(javascript()->ToNumber(), input, context, |
429 EmptyFrameState(), effect, control)); | 429 EmptyFrameState(), effect, control)); |
430 ASSERT_TRUE(r.Changed()); | 430 ASSERT_TRUE(r.Changed()); |
431 EXPECT_THAT(r.replacement(), IsToNumber(input, IsNumberConstant(BitEq(0.0)), | 431 EXPECT_THAT(r.replacement(), IsToNumber(input, IsNumberConstant(BitEq(0.0)), |
432 graph()->start(), control)); | 432 graph()->start(), control)); |
433 } | 433 } |
434 | 434 |
435 | 435 |
436 // ----------------------------------------------------------------------------- | 436 // ----------------------------------------------------------------------------- |
| 437 // JSToObject |
| 438 |
| 439 |
| 440 TEST_F(JSTypedLoweringTest, JSToObjectWithAny) { |
| 441 Node* const input = Parameter(Type::Any(), 0); |
| 442 Node* const context = Parameter(Type::Any(), 1); |
| 443 Node* const frame_state = EmptyFrameState(); |
| 444 Node* const effect = graph()->start(); |
| 445 Node* const control = graph()->start(); |
| 446 Reduction r = Reduce(graph()->NewNode(javascript()->ToObject(), input, |
| 447 context, frame_state, effect, control)); |
| 448 ASSERT_TRUE(r.Changed()); |
| 449 EXPECT_THAT(r.replacement(), IsPhi(kMachAnyTagged, _, _, _)); |
| 450 } |
| 451 |
| 452 |
| 453 TEST_F(JSTypedLoweringTest, JSToObjectWithReceiver) { |
| 454 Node* const input = Parameter(Type::Receiver(), 0); |
| 455 Node* const context = Parameter(Type::Any(), 1); |
| 456 Node* const frame_state = EmptyFrameState(); |
| 457 Node* const effect = graph()->start(); |
| 458 Node* const control = graph()->start(); |
| 459 Reduction r = Reduce(graph()->NewNode(javascript()->ToObject(), input, |
| 460 context, frame_state, effect, control)); |
| 461 ASSERT_TRUE(r.Changed()); |
| 462 EXPECT_EQ(input, r.replacement()); |
| 463 } |
| 464 |
| 465 |
| 466 // ----------------------------------------------------------------------------- |
437 // JSStrictEqual | 467 // JSStrictEqual |
438 | 468 |
439 | 469 |
440 TEST_F(JSTypedLoweringTest, JSStrictEqualWithTheHole) { | 470 TEST_F(JSTypedLoweringTest, JSStrictEqualWithTheHole) { |
441 Node* const the_hole = HeapConstant(factory()->the_hole_value()); | 471 Node* const the_hole = HeapConstant(factory()->the_hole_value()); |
442 Node* const context = UndefinedConstant(); | 472 Node* const context = UndefinedConstant(); |
443 TRACED_FOREACH(Type*, type, kJSTypes) { | 473 TRACED_FOREACH(Type*, type, kJSTypes) { |
444 Node* const lhs = Parameter(type); | 474 Node* const lhs = Parameter(type); |
445 Reduction r = | 475 Reduction r = |
446 Reduce(graph()->NewNode(javascript()->StrictEqual(), lhs, the_hole, | 476 Reduce(graph()->NewNode(javascript()->StrictEqual(), lhs, the_hole, |
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1184 EXPECT_THAT(r.replacement(), | 1214 EXPECT_THAT(r.replacement(), |
1185 IsFinishRegion(IsAllocate(IsNumberConstant(Context::SizeFor( | 1215 IsFinishRegion(IsAllocate(IsNumberConstant(Context::SizeFor( |
1186 Context::MIN_CONTEXT_SLOTS)), | 1216 Context::MIN_CONTEXT_SLOTS)), |
1187 IsBeginRegion(effect), control), | 1217 IsBeginRegion(effect), control), |
1188 _)); | 1218 _)); |
1189 } | 1219 } |
1190 | 1220 |
1191 } // namespace compiler | 1221 } // namespace compiler |
1192 } // namespace internal | 1222 } // namespace internal |
1193 } // namespace v8 | 1223 } // namespace v8 |
OLD | NEW |