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

Side by Side Diff: test/cctest/compiler/test-graph-reducer.cc

Issue 420033003: Fix 64-bit VS2010 build (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « test/cctest/compiler/test-branch-combine.cc ('k') | test/cctest/compiler/test-instruction.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 "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "graph-tester.h" 7 #include "graph-tester.h"
8 #include "src/compiler/generic-node-inl.h" 8 #include "src/compiler/generic-node-inl.h"
9 #include "src/compiler/graph-reducer.h" 9 #include "src/compiler/graph-reducer.h"
10 10
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 181
182 // Simply records the nodes visited. 182 // Simply records the nodes visited.
183 class ReducerRecorder : public Reducer { 183 class ReducerRecorder : public Reducer {
184 public: 184 public:
185 explicit ReducerRecorder(Zone* zone) 185 explicit ReducerRecorder(Zone* zone)
186 : set(NodeSet::key_compare(), NodeSet::allocator_type(zone)) {} 186 : set(NodeSet::key_compare(), NodeSet::allocator_type(zone)) {}
187 virtual Reduction Reduce(Node* node) { 187 virtual Reduction Reduce(Node* node) {
188 set.insert(node); 188 set.insert(node);
189 return NoChange(); 189 return NoChange();
190 } 190 }
191 void CheckContains(Node* node) { CHECK_EQ(1, set.count(node)); } 191 void CheckContains(Node* node) {
192 CHECK_EQ(1, static_cast<int>(set.count(node)));
193 }
192 NodeSet set; 194 NodeSet set;
193 }; 195 };
194 196
195 197
196 TEST(ReduceGraphFromEnd1) { 198 TEST(ReduceGraphFromEnd1) {
197 GraphTester graph; 199 GraphTester graph;
198 200
199 Node* n1 = graph.NewNode(&OPA0); 201 Node* n1 = graph.NewNode(&OPA0);
200 Node* end = graph.NewNode(&OPA1, n1); 202 Node* end = graph.NewNode(&OPA1, n1);
201 graph.SetEnd(end); 203 graph.SetEnd(end);
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 } 623 }
622 624
623 625
624 // Tests that a reducer is only applied once. 626 // Tests that a reducer is only applied once.
625 class OneTimeReducer : public Reducer { 627 class OneTimeReducer : public Reducer {
626 public: 628 public:
627 OneTimeReducer(Reducer* reducer, Zone* zone) 629 OneTimeReducer(Reducer* reducer, Zone* zone)
628 : reducer_(reducer), 630 : reducer_(reducer),
629 nodes_(NodeSet::key_compare(), NodeSet::allocator_type(zone)) {} 631 nodes_(NodeSet::key_compare(), NodeSet::allocator_type(zone)) {}
630 virtual Reduction Reduce(Node* node) { 632 virtual Reduction Reduce(Node* node) {
631 CHECK_EQ(0, nodes_.count(node)); 633 CHECK_EQ(0, static_cast<int>(nodes_.count(node)));
632 nodes_.insert(node); 634 nodes_.insert(node);
633 return reducer_->Reduce(node); 635 return reducer_->Reduce(node);
634 } 636 }
635 Reducer* reducer_; 637 Reducer* reducer_;
636 NodeSet nodes_; 638 NodeSet nodes_;
637 }; 639 };
638 640
639 641
640 TEST(OneTimeReduce1) { 642 TEST(OneTimeReduce1) {
641 GraphTester graph; 643 GraphTester graph;
642 644
643 Node* n1 = graph.NewNode(&OPA0); 645 Node* n1 = graph.NewNode(&OPA0);
644 Node* end = graph.NewNode(&OPA1, n1); 646 Node* end = graph.NewNode(&OPA1, n1);
645 graph.SetEnd(end); 647 graph.SetEnd(end);
646 648
647 GraphReducer reducer(&graph); 649 GraphReducer reducer(&graph);
648 InPlaceABReducer r; 650 InPlaceABReducer r;
649 OneTimeReducer once(&r, graph.zone()); 651 OneTimeReducer once(&r, graph.zone());
650 reducer.AddReducer(&once); 652 reducer.AddReducer(&once);
651 653
652 // Tests A* => B* with in-place updates. Should only be applied once. 654 // Tests A* => B* with in-place updates. Should only be applied once.
653 int before = graph.NodeCount(); 655 int before = graph.NodeCount();
654 reducer.ReduceGraph(); 656 reducer.ReduceGraph();
655 CHECK_EQ(before, graph.NodeCount()); 657 CHECK_EQ(before, graph.NodeCount());
656 CHECK_EQ(&OPB0, n1->op()); 658 CHECK_EQ(&OPB0, n1->op());
657 CHECK_EQ(&OPB1, end->op()); 659 CHECK_EQ(&OPB1, end->op());
658 CHECK_EQ(n1, end->InputAt(0)); 660 CHECK_EQ(n1, end->InputAt(0));
659 } 661 }
OLDNEW
« no previous file with comments | « test/cctest/compiler/test-branch-combine.cc ('k') | test/cctest/compiler/test-instruction.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698