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

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

Issue 656123005: Implement loop variable assignment analysis. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 1 month 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef V8_COMPILER_AST_LOOP_ASSIGNMENT_ANALYZER_H_
6 #define V8_COMPILER_AST_LOOP_ASSIGNMENT_ANALYZER_H_
7
8 #include "src/ast.h"
9 #include "src/data-flow.h"
10 #include "src/v8.h"
11 #include "src/zone-containers.h"
12
13 namespace v8 {
14 namespace internal {
15 namespace compiler {
16
17 // The result of analyzing loop assignments.
18 class LoopAssignmentAnalysis : public ZoneObject {
19 public:
20 BitVector* GetVariablesAssignedInLoop(IterationStatement* loop) {
21 for (size_t i = 0; i < list_.size(); i++) {
22 // TODO(turbofan): hashmap or binary search for loop assignments.
23 if (list_[i].first == loop) return list_[i].second;
24 }
25 UNREACHABLE(); // should never ask for loops that aren't here!
26 return NULL;
27 }
28
29 private:
30 friend class AstLoopAssignmentAnalyzer;
31 explicit LoopAssignmentAnalysis(Zone* zone) : list_(zone) {}
32 ZoneVector<std::pair<IterationStatement*, BitVector*>> list_;
33 };
34
35
36 // The class that performs loop assignment analysis by walking the AST.
37 class AstLoopAssignmentAnalyzer : public AstVisitor {
38 public:
39 AstLoopAssignmentAnalyzer(Zone* zone, CompilationInfo* info);
40
41 LoopAssignmentAnalysis* Analyze();
42
43 #define DECLARE_VISIT(type) virtual void Visit##type(type* node);
44 AST_NODE_LIST(DECLARE_VISIT)
45 #undef DECLARE_VISIT
46
47 private:
48 CompilationInfo* info_;
49 ZoneDeque<BitVector*> loop_stack_;
50 LoopAssignmentAnalysis* result_;
51
52 CompilationInfo* info() { return info_; }
53
54 void Enter(IterationStatement* loop);
55 void Exit(IterationStatement* loop);
56
57 void VisitIfNotNull(AstNode* node) {
58 if (node != NULL) Visit(node);
59 }
60
61 void AnalyzeAssignment(Variable* var);
62
63 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS();
64 DISALLOW_COPY_AND_ASSIGN(AstLoopAssignmentAnalyzer);
65 };
66 }
67 }
68 } // namespace v8::internal::compiler
69
70 #endif // V8_COMPILER_AST_LOOP_ASSIGNMENT_ANALYZER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698