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

Side by Side Diff: src/compiler/ast-loop-assignment-analyzer.h

Issue 2212383003: Revert of Separate Scope into DeclarationScope and Scope (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 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
« no previous file with comments | « src/compiler/ast-graph-builder.cc ('k') | src/compiler/ast-loop-assignment-analyzer.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 #ifndef V8_COMPILER_AST_LOOP_ASSIGNMENT_ANALYZER_H_ 5 #ifndef V8_COMPILER_AST_LOOP_ASSIGNMENT_ANALYZER_H_
6 #define V8_COMPILER_AST_LOOP_ASSIGNMENT_ANALYZER_H_ 6 #define V8_COMPILER_AST_LOOP_ASSIGNMENT_ANALYZER_H_
7 7
8 #include "src/ast/ast.h" 8 #include "src/ast/ast.h"
9 #include "src/bit-vector.h" 9 #include "src/bit-vector.h"
10 #include "src/zone-containers.h" 10 #include "src/zone-containers.h"
(...skipping 12 matching lines...) Expand all
23 public: 23 public:
24 BitVector* GetVariablesAssignedInLoop(IterationStatement* loop) { 24 BitVector* GetVariablesAssignedInLoop(IterationStatement* loop) {
25 for (size_t i = 0; i < list_.size(); i++) { 25 for (size_t i = 0; i < list_.size(); i++) {
26 // TODO(turbofan): hashmap or binary search for loop assignments. 26 // TODO(turbofan): hashmap or binary search for loop assignments.
27 if (list_[i].first == loop) return list_[i].second; 27 if (list_[i].first == loop) return list_[i].second;
28 } 28 }
29 UNREACHABLE(); // should never ask for loops that aren't here! 29 UNREACHABLE(); // should never ask for loops that aren't here!
30 return nullptr; 30 return nullptr;
31 } 31 }
32 32
33 int GetAssignmentCountForTesting(DeclarationScope* scope, Variable* var); 33 int GetAssignmentCountForTesting(Scope* scope, Variable* var);
34 34
35 private: 35 private:
36 friend class AstLoopAssignmentAnalyzer; 36 friend class AstLoopAssignmentAnalyzer;
37 explicit LoopAssignmentAnalysis(Zone* zone) : list_(zone) {} 37 explicit LoopAssignmentAnalysis(Zone* zone) : list_(zone) {}
38 ZoneVector<std::pair<IterationStatement*, BitVector*>> list_; 38 ZoneVector<std::pair<IterationStatement*, BitVector*>> list_;
39 }; 39 };
40 40
41 41
42 // The class that performs loop assignment analysis by walking the AST. 42 // The class that performs loop assignment analysis by walking the AST.
43 class AstLoopAssignmentAnalyzer final 43 class AstLoopAssignmentAnalyzer final
44 : public AstVisitor<AstLoopAssignmentAnalyzer> { 44 : public AstVisitor<AstLoopAssignmentAnalyzer> {
45 public: 45 public:
46 AstLoopAssignmentAnalyzer(Zone* zone, CompilationInfo* info); 46 AstLoopAssignmentAnalyzer(Zone* zone, CompilationInfo* info);
47 47
48 LoopAssignmentAnalysis* Analyze(); 48 LoopAssignmentAnalysis* Analyze();
49 49
50 #define DECLARE_VISIT(type) void Visit##type(type* node); 50 #define DECLARE_VISIT(type) void Visit##type(type* node);
51 AST_NODE_LIST(DECLARE_VISIT) 51 AST_NODE_LIST(DECLARE_VISIT)
52 #undef DECLARE_VISIT 52 #undef DECLARE_VISIT
53 53
54 static int GetVariableIndex(DeclarationScope* scope, Variable* var); 54 static int GetVariableIndex(Scope* scope, Variable* var);
55 55
56 private: 56 private:
57 CompilationInfo* info_; 57 CompilationInfo* info_;
58 Zone* zone_; 58 Zone* zone_;
59 ZoneDeque<BitVector*> loop_stack_; 59 ZoneDeque<BitVector*> loop_stack_;
60 LoopAssignmentAnalysis* result_; 60 LoopAssignmentAnalysis* result_;
61 61
62 CompilationInfo* info() { return info_; } 62 CompilationInfo* info() { return info_; }
63 63
64 void Enter(IterationStatement* loop); 64 void Enter(IterationStatement* loop);
65 void Exit(IterationStatement* loop); 65 void Exit(IterationStatement* loop);
66 66
67 void VisitIfNotNull(AstNode* node) { 67 void VisitIfNotNull(AstNode* node) {
68 if (node != nullptr) Visit(node); 68 if (node != nullptr) Visit(node);
69 } 69 }
70 70
71 void AnalyzeAssignment(Variable* var); 71 void AnalyzeAssignment(Variable* var);
72 72
73 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); 73 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS();
74 DISALLOW_COPY_AND_ASSIGN(AstLoopAssignmentAnalyzer); 74 DISALLOW_COPY_AND_ASSIGN(AstLoopAssignmentAnalyzer);
75 }; 75 };
76 } // namespace compiler 76 } // namespace compiler
77 } // namespace internal 77 } // namespace internal
78 } // namespace v8 78 } // namespace v8
79 79
80 #endif // V8_COMPILER_AST_LOOP_ASSIGNMENT_ANALYZER_H_ 80 #endif // V8_COMPILER_AST_LOOP_ASSIGNMENT_ANALYZER_H_
OLDNEW
« no previous file with comments | « src/compiler/ast-graph-builder.cc ('k') | src/compiler/ast-loop-assignment-analyzer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698