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

Side by Side Diff: runtime/vm/flow_graph_builder.h

Issue 10014006: Try/catch in graph builder. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 8 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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef VM_FLOW_GRAPH_BUILDER_H_ 5 #ifndef VM_FLOW_GRAPH_BUILDER_H_
6 #define VM_FLOW_GRAPH_BUILDER_H_ 6 #define VM_FLOW_GRAPH_BUILDER_H_
7 7
8 #include "vm/allocation.h" 8 #include "vm/allocation.h"
9 #include "vm/ast.h" 9 #include "vm/ast.h"
10 #include "vm/growable_array.h" 10 #include "vm/growable_array.h"
11 #include "vm/intermediate_language.h" 11 #include "vm/intermediate_language.h"
12 12
13 namespace dart { 13 namespace dart {
14 14
15 class Instruction; 15 class Instruction;
16 class ParsedFunction; 16 class ParsedFunction;
17 17
18 // Build a flow graph from a parsed function's AST. 18 // Build a flow graph from a parsed function's AST.
19 class FlowGraphBuilder: public ValueObject { 19 class FlowGraphBuilder: public ValueObject {
20 public: 20 public:
21 explicit FlowGraphBuilder(const ParsedFunction& parsed_function) 21 explicit FlowGraphBuilder(const ParsedFunction& parsed_function);
22 : parsed_function_(parsed_function),
23 preorder_block_entries_(),
24 postorder_block_entries_(),
25 context_level_(0) { }
26 22
27 void BuildGraph(); 23 void BuildGraph();
28 24
29 const ParsedFunction& parsed_function() const { return parsed_function_; } 25 const ParsedFunction& parsed_function() const { return parsed_function_; }
30 26
31 const GrowableArray<BlockEntryInstr*>& postorder_block_entries() const { 27 const GrowableArray<BlockEntryInstr*>& postorder_block_entries() const {
32 return postorder_block_entries_; 28 return postorder_block_entries_;
33 } 29 }
34 30
35 void Bailout(const char* reason); 31 void Bailout(const char* reason);
36 32
37 void set_context_level(intptr_t value) { context_level_ = value; } 33 void set_context_level(intptr_t value) { context_level_ = value; }
38 intptr_t context_level() const { return context_level_; } 34 intptr_t context_level() const { return context_level_; }
39 35
36 intptr_t allocate_try_index() { return ++last_used_try_index_; }
regis 2012/04/10 22:58:24 Shouldn't this be camel case?
srdjan 2012/04/10 23:11:58 Done.
37 void set_try_index(intptr_t value) { try_index_ = value; }
38 intptr_t try_index() const { return try_index_; }
39
40 void AddCatchEntry(intptr_t try_index, Instruction* entry);
41
40 private: 42 private:
41 void ComputeDominators(GrowableArray<BlockEntryInstr*>* preorder, 43 void ComputeDominators(GrowableArray<BlockEntryInstr*>* preorder,
42 GrowableArray<intptr_t>* parent); 44 GrowableArray<intptr_t>* parent);
43 void CompressPath(intptr_t start_index, 45 void CompressPath(intptr_t start_index,
44 intptr_t current_index, 46 intptr_t current_index,
45 GrowableArray<intptr_t>* parent, 47 GrowableArray<intptr_t>* parent,
46 GrowableArray<intptr_t>* label); 48 GrowableArray<intptr_t>* label);
47 49
48 const ParsedFunction& parsed_function_; 50 const ParsedFunction& parsed_function_;
49 GrowableArray<BlockEntryInstr*> preorder_block_entries_; 51 GrowableArray<BlockEntryInstr*> preorder_block_entries_;
50 GrowableArray<BlockEntryInstr*> postorder_block_entries_; 52 GrowableArray<BlockEntryInstr*> postorder_block_entries_;
51 intptr_t context_level_; 53 intptr_t context_level_;
54 intptr_t last_used_try_index_;
55 intptr_t try_index_;
56 GrowableArray<Instruction*> catch_entries_;
57
58 DISALLOW_IMPLICIT_CONSTRUCTORS(FlowGraphBuilder);
52 }; 59 };
53 60
54 61
55 class TestGraphVisitor; 62 class TestGraphVisitor;
56 63
57 // Translate an AstNode to a control-flow graph fragment for its effects 64 // Translate an AstNode to a control-flow graph fragment for its effects
58 // (e.g., a statement or an expression in an effect context). Implements a 65 // (e.g., a statement or an expression in an effect context). Implements a
59 // function from an AstNode and next temporary index to a graph fragment 66 // function from an AstNode and next temporary index to a graph fragment
60 // with a single entry and at most one exit. The fragment is represented by 67 // with a single entry and at most one exit. The fragment is represented by
61 // an (entry, exit) pair of Instruction pointers: 68 // an (entry, exit) pair of Instruction pointers:
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 163
157 virtual void CompiletimeStringInterpolation(const Function& interpol_func, 164 virtual void CompiletimeStringInterpolation(const Function& interpol_func,
158 const Array& literals); 165 const Array& literals);
159 166
160 TempVal* BuildObjectAllocation(ConstructorCallNode* node, 167 TempVal* BuildObjectAllocation(ConstructorCallNode* node,
161 int start_index); 168 int start_index);
162 void BuildConstructorCall(ConstructorCallNode* node, 169 void BuildConstructorCall(ConstructorCallNode* node,
163 int start_index, 170 int start_index,
164 Value* alloc_value); 171 Value* alloc_value);
165 172
173 void BuildStoreContext(const LocalVariable& variable, intptr_t start_index);
174 void BuildLoadContext(const LocalVariable& context_variable,
175 intptr_t start_index);
176
166 void BuildThrowNode(ThrowNode* node); 177 void BuildThrowNode(ThrowNode* node);
167 178
168 private: 179 private:
169 // Specify a computation as the final result. Adds a Do instruction to 180 // Specify a computation as the final result. Adds a Do instruction to
170 // the graph, but normally overridden in subclasses. 181 // the graph, but normally overridden in subclasses.
171 virtual void ReturnComputation(Computation* computation) { 182 virtual void ReturnComputation(Computation* computation) {
172 AddInstruction(new DoInstr(computation)); 183 AddInstruction(new DoInstr(computation));
173 } 184 }
174 185
175 // Shared global state. 186 // Shared global state.
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 } 303 }
293 304
294 // Output parameters. 305 // Output parameters.
295 TargetEntryInstr** true_successor_address_; 306 TargetEntryInstr** true_successor_address_;
296 TargetEntryInstr** false_successor_address_; 307 TargetEntryInstr** false_successor_address_;
297 }; 308 };
298 309
299 } // namespace dart 310 } // namespace dart
300 311
301 #endif // VM_FLOW_GRAPH_BUILDER_H_ 312 #endif // VM_FLOW_GRAPH_BUILDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698