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/compiler/js-typed-lowering.h" | 5 #include "src/compiler/js-typed-lowering.h" |
6 #include "src/code-factory.h" | 6 #include "src/code-factory.h" |
7 #include "src/compilation-dependencies.h" | 7 #include "src/compilation-dependencies.h" |
8 #include "src/compiler/access-builder.h" | 8 #include "src/compiler/access-builder.h" |
9 #include "src/compiler/js-graph.h" | 9 #include "src/compiler/js-graph.h" |
10 #include "src/compiler/js-operator.h" | 10 #include "src/compiler/js-operator.h" |
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 // ----------------------------------------------------------------------------- | 516 // ----------------------------------------------------------------------------- |
517 // JSLoadContext | 517 // JSLoadContext |
518 | 518 |
519 | 519 |
520 TEST_F(JSTypedLoweringTest, JSLoadContext) { | 520 TEST_F(JSTypedLoweringTest, JSLoadContext) { |
521 Node* const context = Parameter(Type::Any()); | 521 Node* const context = Parameter(Type::Any()); |
522 Node* const effect = graph()->start(); | 522 Node* const effect = graph()->start(); |
523 static bool kBooleans[] = {false, true}; | 523 static bool kBooleans[] = {false, true}; |
524 TRACED_FOREACH(size_t, index, kIndices) { | 524 TRACED_FOREACH(size_t, index, kIndices) { |
525 TRACED_FOREACH(bool, immutable, kBooleans) { | 525 TRACED_FOREACH(bool, immutable, kBooleans) { |
526 Reduction const r1 = Reduce( | 526 Reduction const r1 = Reduce(graph()->NewNode( |
527 graph()->NewNode(javascript()->LoadContext(0, index, immutable), | 527 javascript()->LoadContext(0, index, immutable), context, effect)); |
528 context, context, effect)); | |
529 ASSERT_TRUE(r1.Changed()); | 528 ASSERT_TRUE(r1.Changed()); |
530 EXPECT_THAT(r1.replacement(), | 529 EXPECT_THAT(r1.replacement(), |
531 IsLoadField(AccessBuilder::ForContextSlot(index), context, | 530 IsLoadField(AccessBuilder::ForContextSlot(index), context, |
532 effect, graph()->start())); | 531 effect, graph()->start())); |
533 | 532 |
534 Reduction const r2 = Reduce( | 533 Reduction const r2 = Reduce(graph()->NewNode( |
535 graph()->NewNode(javascript()->LoadContext(1, index, immutable), | 534 javascript()->LoadContext(1, index, immutable), context, effect)); |
536 context, context, effect)); | |
537 ASSERT_TRUE(r2.Changed()); | 535 ASSERT_TRUE(r2.Changed()); |
538 EXPECT_THAT(r2.replacement(), | 536 EXPECT_THAT(r2.replacement(), |
539 IsLoadField(AccessBuilder::ForContextSlot(index), | 537 IsLoadField(AccessBuilder::ForContextSlot(index), |
540 IsLoadField(AccessBuilder::ForContextSlot( | 538 IsLoadField(AccessBuilder::ForContextSlot( |
541 Context::PREVIOUS_INDEX), | 539 Context::PREVIOUS_INDEX), |
542 context, effect, graph()->start()), | 540 context, effect, graph()->start()), |
543 _, graph()->start())); | 541 _, graph()->start())); |
544 } | 542 } |
545 } | 543 } |
546 } | 544 } |
547 | 545 |
548 | 546 |
549 // ----------------------------------------------------------------------------- | 547 // ----------------------------------------------------------------------------- |
550 // JSStoreContext | 548 // JSStoreContext |
551 | 549 |
552 | 550 |
553 TEST_F(JSTypedLoweringTest, JSStoreContext) { | 551 TEST_F(JSTypedLoweringTest, JSStoreContext) { |
554 Node* const context = Parameter(Type::Any()); | 552 Node* const context = Parameter(Type::Any()); |
555 Node* const effect = graph()->start(); | 553 Node* const effect = graph()->start(); |
556 Node* const control = graph()->start(); | 554 Node* const control = graph()->start(); |
557 TRACED_FOREACH(size_t, index, kIndices) { | 555 TRACED_FOREACH(size_t, index, kIndices) { |
558 TRACED_FOREACH(Type*, type, kJSTypes) { | 556 TRACED_FOREACH(Type*, type, kJSTypes) { |
559 Node* const value = Parameter(type); | 557 Node* const value = Parameter(type); |
560 | 558 |
561 Reduction const r1 = | 559 Reduction const r1 = |
562 Reduce(graph()->NewNode(javascript()->StoreContext(0, index), context, | 560 Reduce(graph()->NewNode(javascript()->StoreContext(0, index), value, |
563 value, context, effect, control)); | 561 context, effect, control)); |
564 ASSERT_TRUE(r1.Changed()); | 562 ASSERT_TRUE(r1.Changed()); |
565 EXPECT_THAT(r1.replacement(), | 563 EXPECT_THAT(r1.replacement(), |
566 IsStoreField(AccessBuilder::ForContextSlot(index), context, | 564 IsStoreField(AccessBuilder::ForContextSlot(index), context, |
567 value, effect, control)); | 565 value, effect, control)); |
568 | 566 |
569 Reduction const r2 = | 567 Reduction const r2 = |
570 Reduce(graph()->NewNode(javascript()->StoreContext(1, index), context, | 568 Reduce(graph()->NewNode(javascript()->StoreContext(1, index), value, |
571 value, context, effect, control)); | 569 context, effect, control)); |
572 ASSERT_TRUE(r2.Changed()); | 570 ASSERT_TRUE(r2.Changed()); |
573 EXPECT_THAT(r2.replacement(), | 571 EXPECT_THAT(r2.replacement(), |
574 IsStoreField(AccessBuilder::ForContextSlot(index), | 572 IsStoreField(AccessBuilder::ForContextSlot(index), |
575 IsLoadField(AccessBuilder::ForContextSlot( | 573 IsLoadField(AccessBuilder::ForContextSlot( |
576 Context::PREVIOUS_INDEX), | 574 Context::PREVIOUS_INDEX), |
577 context, effect, graph()->start()), | 575 context, effect, graph()->start()), |
578 value, _, control)); | 576 value, _, control)); |
579 } | 577 } |
580 } | 578 } |
581 } | 579 } |
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1012 EmptyFrameState(), effect, control)); | 1010 EmptyFrameState(), effect, control)); |
1013 ASSERT_TRUE(r.Changed()); | 1011 ASSERT_TRUE(r.Changed()); |
1014 EXPECT_THAT(r.replacement(), IsSpeculativeNumberBitwiseXor( | 1012 EXPECT_THAT(r.replacement(), IsSpeculativeNumberBitwiseXor( |
1015 NumberOperationHint::kNumberOrOddball, lhs, | 1013 NumberOperationHint::kNumberOrOddball, lhs, |
1016 rhs, effect, control)); | 1014 rhs, effect, control)); |
1017 } | 1015 } |
1018 | 1016 |
1019 } // namespace compiler | 1017 } // namespace compiler |
1020 } // namespace internal | 1018 } // namespace internal |
1021 } // namespace v8 | 1019 } // namespace v8 |
OLD | NEW |