Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: test/cctest/compiler/test-simplified-lowering.cc

Issue 2107783004: [turbofan] Disallow typing for change/checked operators. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@TurboFan_RepresentationSelection_Typer
Patch Set: ReferenceEqual foo Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler/typer.cc ('k') | test/unittests/compiler/simplified-operator-reducer-unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <limits> 5 #include <limits>
6 6
7 #include "src/ast/scopes.h" 7 #include "src/ast/scopes.h"
8 #include "src/compiler/access-builder.h" 8 #include "src/compiler/access-builder.h"
9 #include "src/compiler/control-builders.h" 9 #include "src/compiler/control-builders.h"
10 #include "src/compiler/effect-control-linearizer.h" 10 #include "src/compiler/effect-control-linearizer.h"
(...skipping 19 matching lines...) Expand all
30 namespace v8 { 30 namespace v8 {
31 namespace internal { 31 namespace internal {
32 namespace compiler { 32 namespace compiler {
33 33
34 template <typename ReturnType> 34 template <typename ReturnType>
35 class SimplifiedLoweringTester : public GraphBuilderTester<ReturnType> { 35 class SimplifiedLoweringTester : public GraphBuilderTester<ReturnType> {
36 public: 36 public:
37 SimplifiedLoweringTester(MachineType p0 = MachineType::None(), 37 SimplifiedLoweringTester(MachineType p0 = MachineType::None(),
38 MachineType p1 = MachineType::None()) 38 MachineType p1 = MachineType::None())
39 : GraphBuilderTester<ReturnType>(p0, p1), 39 : GraphBuilderTester<ReturnType>(p0, p1),
40 typer(this->isolate(), this->graph()), 40 typer(new Typer(this->isolate(), this->graph())),
41 javascript(this->zone()), 41 javascript(this->zone()),
42 jsgraph(this->isolate(), this->graph(), this->common(), &javascript, 42 jsgraph(this->isolate(), this->graph(), this->common(), &javascript,
43 this->simplified(), this->machine()), 43 this->simplified(), this->machine()),
44 source_positions(jsgraph.graph()), 44 source_positions(jsgraph.graph()),
45 lowering(&jsgraph, this->zone(), &source_positions) {} 45 lowering(&jsgraph, this->zone(), &source_positions) {}
46 ~SimplifiedLoweringTester() final { delete typer; }
46 47
47 Typer typer; 48 Typer* typer = nullptr;
48 JSOperatorBuilder javascript; 49 JSOperatorBuilder javascript;
49 JSGraph jsgraph; 50 JSGraph jsgraph;
50 SourcePositionTable source_positions; 51 SourcePositionTable source_positions;
51 SimplifiedLowering lowering; 52 SimplifiedLowering lowering;
52 53
53 void LowerAllNodes() { 54 void LowerAllNodes() {
54 this->End(); 55 this->End();
55 typer.Run(); 56 typer->Run();
57 delete typer, typer = nullptr;
56 lowering.LowerAllNodes(); 58 lowering.LowerAllNodes();
57 } 59 }
58 60
59 void LowerAllNodesAndLowerChanges() { 61 void LowerAllNodesAndLowerChanges() {
60 this->End(); 62 this->End();
61 typer.Run(); 63 typer->Run();
64 delete typer, typer = nullptr;
62 lowering.LowerAllNodes(); 65 lowering.LowerAllNodes();
63 66
64 Schedule* schedule = Scheduler::ComputeSchedule(this->zone(), this->graph(), 67 Schedule* schedule = Scheduler::ComputeSchedule(this->zone(), this->graph(),
65 Scheduler::kNoFlags); 68 Scheduler::kNoFlags);
66 EffectControlLinearizer linearizer(&jsgraph, schedule, this->zone()); 69 EffectControlLinearizer linearizer(&jsgraph, schedule, this->zone());
67 linearizer.Run(); 70 linearizer.Run();
68 71
69 MemoryOptimizer memory_optimizer(&jsgraph, this->zone()); 72 MemoryOptimizer memory_optimizer(&jsgraph, this->zone());
70 memory_optimizer.Optimize(); 73 memory_optimizer.Optimize();
71 } 74 }
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 CHECK(t.heap()->new_space()->Contains(result) || flag[i] == TENURED); 678 CHECK(t.heap()->new_space()->Contains(result) || flag[i] == TENURED);
676 CHECK(t.heap()->old_space()->Contains(result) || flag[i] == NOT_TENURED); 679 CHECK(t.heap()->old_space()->Contains(result) || flag[i] == NOT_TENURED);
677 CHECK(result->IsHeapNumber()); 680 CHECK(result->IsHeapNumber());
678 } 681 }
679 } 682 }
680 683
681 684
682 // Fills in most of the nodes of the graph in order to make tests shorter. 685 // Fills in most of the nodes of the graph in order to make tests shorter.
683 class TestingGraph : public HandleAndZoneScope, public GraphAndBuilders { 686 class TestingGraph : public HandleAndZoneScope, public GraphAndBuilders {
684 public: 687 public:
685 Typer typer; 688 Typer* typer = nullptr;
686 JSOperatorBuilder javascript; 689 JSOperatorBuilder javascript;
687 JSGraph jsgraph; 690 JSGraph jsgraph;
688 Node* p0; 691 Node* p0;
689 Node* p1; 692 Node* p1;
690 Node* p2; 693 Node* p2;
691 Node* start; 694 Node* start;
692 Node* end; 695 Node* end;
693 Node* ret; 696 Node* ret;
694 697
695 explicit TestingGraph(Type* p0_type, Type* p1_type = Type::None(), 698 explicit TestingGraph(Type* p0_type, Type* p1_type = Type::None(),
696 Type* p2_type = Type::None()) 699 Type* p2_type = Type::None())
697 : GraphAndBuilders(main_zone()), 700 : GraphAndBuilders(main_zone()),
698 typer(main_isolate(), graph()), 701 typer(new Typer(main_isolate(), graph())),
699 javascript(main_zone()), 702 javascript(main_zone()),
700 jsgraph(main_isolate(), graph(), common(), &javascript, simplified(), 703 jsgraph(main_isolate(), graph(), common(), &javascript, simplified(),
701 machine()) { 704 machine()) {
702 start = graph()->NewNode(common()->Start(4)); 705 start = graph()->NewNode(common()->Start(4));
703 graph()->SetStart(start); 706 graph()->SetStart(start);
704 ret = 707 ret =
705 graph()->NewNode(common()->Return(), jsgraph.Constant(0), start, start); 708 graph()->NewNode(common()->Return(), jsgraph.Constant(0), start, start);
706 end = graph()->NewNode(common()->End(1), ret); 709 end = graph()->NewNode(common()->End(1), ret);
707 graph()->SetEnd(end); 710 graph()->SetEnd(end);
708 p0 = graph()->NewNode(common()->Parameter(0), start); 711 p0 = graph()->NewNode(common()->Parameter(0), start);
709 p1 = graph()->NewNode(common()->Parameter(1), start); 712 p1 = graph()->NewNode(common()->Parameter(1), start);
710 p2 = graph()->NewNode(common()->Parameter(2), start); 713 p2 = graph()->NewNode(common()->Parameter(2), start);
711 typer.Run(); 714 typer->Run();
712 NodeProperties::SetType(p0, p0_type); 715 NodeProperties::SetType(p0, p0_type);
713 NodeProperties::SetType(p1, p1_type); 716 NodeProperties::SetType(p1, p1_type);
714 NodeProperties::SetType(p2, p2_type); 717 NodeProperties::SetType(p2, p2_type);
715 } 718 }
719 ~TestingGraph() { delete typer; }
716 720
717 void CheckLoweringBinop(IrOpcode::Value expected, const Operator* op) { 721 void CheckLoweringBinop(IrOpcode::Value expected, const Operator* op) {
718 Node* node = Return(graph()->NewNode(op, p0, p1)); 722 Node* node = Return(graph()->NewNode(op, p0, p1));
719 Lower(); 723 Lower();
720 CHECK_EQ(expected, node->opcode()); 724 CHECK_EQ(expected, node->opcode());
721 } 725 }
722 726
723 void CheckLoweringStringBinop(IrOpcode::Value expected, const Operator* op) { 727 void CheckLoweringStringBinop(IrOpcode::Value expected, const Operator* op) {
724 Node* node = Return( 728 Node* node = Return(
725 graph()->NewNode(op, p0, p1, graph()->start(), graph()->start())); 729 graph()->NewNode(op, p0, p1, graph()->start(), graph()->start()));
726 Lower(); 730 Lower();
727 CHECK_EQ(expected, node->opcode()); 731 CHECK_EQ(expected, node->opcode());
728 } 732 }
729 733
730 void CheckLoweringTruncatedBinop(IrOpcode::Value expected, const Operator* op, 734 void CheckLoweringTruncatedBinop(IrOpcode::Value expected, const Operator* op,
731 const Operator* trunc) { 735 const Operator* trunc) {
732 Node* node = graph()->NewNode(op, p0, p1); 736 Node* node = graph()->NewNode(op, p0, p1);
733 Return(graph()->NewNode(trunc, node)); 737 Return(graph()->NewNode(trunc, node));
734 Lower(); 738 Lower();
735 CHECK_EQ(expected, node->opcode()); 739 CHECK_EQ(expected, node->opcode());
736 } 740 }
737 741
738 void Lower() { 742 void Lower() {
743 delete typer;
739 SourcePositionTable table(jsgraph.graph()); 744 SourcePositionTable table(jsgraph.graph());
740 SimplifiedLowering(&jsgraph, jsgraph.zone(), &table).LowerAllNodes(); 745 SimplifiedLowering(&jsgraph, jsgraph.zone(), &table).LowerAllNodes();
746 typer = new Typer(main_isolate(), graph());
741 } 747 }
742 748
743 void LowerAllNodesAndLowerChanges() { 749 void LowerAllNodesAndLowerChanges() {
750 delete typer;
744 SourcePositionTable table(jsgraph.graph()); 751 SourcePositionTable table(jsgraph.graph());
745 SimplifiedLowering(&jsgraph, jsgraph.zone(), &table).LowerAllNodes(); 752 SimplifiedLowering(&jsgraph, jsgraph.zone(), &table).LowerAllNodes();
746 753
747 Schedule* schedule = Scheduler::ComputeSchedule(this->zone(), this->graph(), 754 Schedule* schedule = Scheduler::ComputeSchedule(this->zone(), this->graph(),
748 Scheduler::kNoFlags); 755 Scheduler::kNoFlags);
749 EffectControlLinearizer linearizer(&jsgraph, schedule, this->zone()); 756 EffectControlLinearizer linearizer(&jsgraph, schedule, this->zone());
750 linearizer.Run(); 757 linearizer.Run();
751 758
752 MemoryOptimizer memory_optimizer(&jsgraph, this->zone()); 759 MemoryOptimizer memory_optimizer(&jsgraph, this->zone());
753 memory_optimizer.Optimize(); 760 memory_optimizer.Optimize();
761 typer = new Typer(main_isolate(), graph());
754 } 762 }
755 763
756 // Inserts the node as the return value of the graph. 764 // Inserts the node as the return value of the graph.
757 Node* Return(Node* node) { 765 Node* Return(Node* node) {
758 ret->ReplaceInput(0, node); 766 ret->ReplaceInput(0, node);
759 return node; 767 return node;
760 } 768 }
761 769
762 // Inserts the node as the effect input to the return of the graph. 770 // Inserts the node as the effect input to the return of the graph.
763 void Effect(Node* node) { ret->ReplaceInput(1, node); } 771 void Effect(Node* node) { ret->ReplaceInput(1, node); }
(...skipping 1187 matching lines...) Expand 10 before | Expand all | Expand 10 after
1951 t.Return(use); 1959 t.Return(use);
1952 t.Lower(); 1960 t.Lower();
1953 1961
1954 CHECK_EQ(d.expected, PhiRepresentationOf(phi->op())); 1962 CHECK_EQ(d.expected, PhiRepresentationOf(phi->op()));
1955 } 1963 }
1956 } 1964 }
1957 1965
1958 } // namespace compiler 1966 } // namespace compiler
1959 } // namespace internal 1967 } // namespace internal
1960 } // namespace v8 1968 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/typer.cc ('k') | test/unittests/compiler/simplified-operator-reducer-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698