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

Side by Side Diff: src/compiler/ast-graph-builder.h

Issue 448113002: Minor simplification and cleanup of graph builder. (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 | « no previous file | src/compiler/ast-graph-builder.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_GRAPH_BUILDER_H_ 5 #ifndef V8_COMPILER_AST_GRAPH_BUILDER_H_
6 #define V8_COMPILER_AST_GRAPH_BUILDER_H_ 6 #define V8_COMPILER_AST_GRAPH_BUILDER_H_
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/ast.h" 10 #include "src/ast.h"
11 #include "src/compiler/graph-builder.h" 11 #include "src/compiler/graph-builder.h"
12 #include "src/compiler/js-graph.h" 12 #include "src/compiler/js-graph.h"
13 13
14 namespace v8 { 14 namespace v8 {
15 namespace internal { 15 namespace internal {
16 namespace compiler { 16 namespace compiler {
17 17
18 class ControlBuilder; 18 class ControlBuilder;
19 class LoopBuilder; 19 class LoopBuilder;
20 class Graph; 20 class Graph;
21 21
22 // The AstGraphBuilder produces a high-level IR graph, based on an 22 // The AstGraphBuilder produces a high-level IR graph, based on an
23 // underlying AST. The produced graph can either be compiled into a 23 // underlying AST. The produced graph can either be compiled into a
24 // stand-alone function or be wired into another graph for the purposes 24 // stand-alone function or be wired into another graph for the purposes
25 // of function inlining. 25 // of function inlining.
26 class AstGraphBuilder : public StructuredGraphBuilder, public AstVisitor { 26 class AstGraphBuilder : public StructuredGraphBuilder, public AstVisitor {
27 public: 27 public:
28 AstGraphBuilder(CompilationInfo* info, JSGraph* jsgraph, 28 AstGraphBuilder(CompilationInfo* info, JSGraph* jsgraph);
29 SourcePositionTable* source_positions_);
30 29
31 // Creates a graph by visiting the entire AST. 30 // Creates a graph by visiting the entire AST.
32 bool CreateGraph(); 31 bool CreateGraph();
33 32
34 protected: 33 protected:
35 class AstContext; 34 class AstContext;
36 class AstEffectContext; 35 class AstEffectContext;
37 class AstValueContext; 36 class AstValueContext;
38 class AstTestContext; 37 class AstTestContext;
39 class BreakableScope; 38 class BreakableScope;
40 class ContextScope; 39 class ContextScope;
41 class Environment; 40 class Environment;
42 41
43 Environment* environment() { 42 Environment* environment() {
44 return reinterpret_cast<Environment*>(environment_internal()); 43 return reinterpret_cast<Environment*>(
44 StructuredGraphBuilder::environment());
45 } 45 }
46 46
47 AstContext* ast_context() const { return ast_context_; } 47 AstContext* ast_context() const { return ast_context_; }
48 BreakableScope* breakable() const { return breakable_; } 48 BreakableScope* breakable() const { return breakable_; }
49 ContextScope* execution_context() const { return execution_context_; } 49 ContextScope* execution_context() const { return execution_context_; }
50 50
51 void set_ast_context(AstContext* ctx) { ast_context_ = ctx; } 51 void set_ast_context(AstContext* ctx) { ast_context_ = ctx; }
52 void set_breakable(BreakableScope* brk) { breakable_ = brk; } 52 void set_breakable(BreakableScope* brk) { breakable_ = brk; }
53 void set_execution_context(ContextScope* ctx) { execution_context_ = ctx; } 53 void set_execution_context(ContextScope* ctx) { execution_context_ = ctx; }
54 54
55 // Support for control flow builders. The concrete type of the environment 55 // Support for control flow builders. The concrete type of the environment
56 // depends on the graph builder, but environments themselves are not virtual. 56 // depends on the graph builder, but environments themselves are not virtual.
57 typedef StructuredGraphBuilder::Environment BaseEnvironment; 57 typedef StructuredGraphBuilder::Environment BaseEnvironment;
58 virtual BaseEnvironment* CopyEnvironment(BaseEnvironment* env); 58 virtual BaseEnvironment* CopyEnvironment(BaseEnvironment* env);
59 59
60 SourcePositionTable* source_positions() { return source_positions_; }
61
62 // TODO(mstarzinger): The pipeline only needs to be a friend to access the 60 // TODO(mstarzinger): The pipeline only needs to be a friend to access the
63 // function context. Remove as soon as the context is a parameter. 61 // function context. Remove as soon as the context is a parameter.
64 friend class Pipeline; 62 friend class Pipeline;
65 63
66 // Getters for values in the activation record. 64 // Getters for values in the activation record.
67 Node* GetFunctionClosure(); 65 Node* GetFunctionClosure();
68 Node* GetFunctionContext(); 66 Node* GetFunctionContext();
69 67
70 // 68 //
71 // The following build methods all generate graph fragments and return one 69 // The following build methods all generate graph fragments and return one
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 AST_NODE_LIST(DECLARE_VISIT) 105 AST_NODE_LIST(DECLARE_VISIT)
108 #undef DECLARE_VISIT 106 #undef DECLARE_VISIT
109 107
110 // Visiting function for declarations list is overridden. 108 // Visiting function for declarations list is overridden.
111 virtual void VisitDeclarations(ZoneList<Declaration*>* declarations); 109 virtual void VisitDeclarations(ZoneList<Declaration*>* declarations);
112 110
113 private: 111 private:
114 CompilationInfo* info_; 112 CompilationInfo* info_;
115 AstContext* ast_context_; 113 AstContext* ast_context_;
116 JSGraph* jsgraph_; 114 JSGraph* jsgraph_;
117 SourcePositionTable* source_positions_;
118 115
119 // List of global declarations for functions and variables. 116 // List of global declarations for functions and variables.
120 ZoneList<Handle<Object> > globals_; 117 ZoneList<Handle<Object> > globals_;
121 118
122 // Stack of breakable statements entered by the visitor. 119 // Stack of breakable statements entered by the visitor.
123 BreakableScope* breakable_; 120 BreakableScope* breakable_;
124 121
125 // Stack of context objects pushed onto the chain by the visitor. 122 // Stack of context objects pushed onto the chain by the visitor.
126 ContextScope* execution_context_; 123 ContextScope* execution_context_;
127 124
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 }; 409 };
413 410
414 Scope* AstGraphBuilder::current_scope() const { 411 Scope* AstGraphBuilder::current_scope() const {
415 return execution_context_->scope(); 412 return execution_context_->scope();
416 } 413 }
417 } 414 }
418 } 415 }
419 } // namespace v8::internal::compiler 416 } // namespace v8::internal::compiler
420 417
421 #endif // V8_COMPILER_AST_GRAPH_BUILDER_H_ 418 #endif // V8_COMPILER_AST_GRAPH_BUILDER_H_
OLDNEW
« no previous file with comments | « no previous file | src/compiler/ast-graph-builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698