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

Side by Side Diff: src/compiler/control-builders.h

Issue 894073002: [turbofan] Put StructuredGraphBuilder out of its misery and merge its remnants back into the AstGra… (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 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/graph-builder.h » ('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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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_CONTROL_BUILDERS_H_ 5 #ifndef V8_COMPILER_CONTROL_BUILDERS_H_
6 #define V8_COMPILER_CONTROL_BUILDERS_H_ 6 #define V8_COMPILER_CONTROL_BUILDERS_H_
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/compiler/graph-builder.h" 10 #include "src/compiler/ast-graph-builder.h"
11 #include "src/compiler/node.h" 11 #include "src/compiler/node.h"
12 12
13 namespace v8 { 13 namespace v8 {
14 namespace internal { 14 namespace internal {
15 namespace compiler { 15 namespace compiler {
16 16
17 // Base class for all control builders. Also provides a common interface for 17 // Base class for all control builders. Also provides a common interface for
18 // control builders to handle 'break' and 'continue' statements when they are 18 // control builders to handle 'break' and 'continue' statements when they are
19 // used to model breakable statements. 19 // used to model breakable statements.
20 class ControlBuilder { 20 class ControlBuilder {
21 public: 21 public:
22 explicit ControlBuilder(StructuredGraphBuilder* builder) 22 explicit ControlBuilder(AstGraphBuilder* builder) : builder_(builder) {}
23 : builder_(builder) {}
24 virtual ~ControlBuilder() {} 23 virtual ~ControlBuilder() {}
25 24
26 // Interface for break and continue. 25 // Interface for break and continue.
27 virtual void Break() { UNREACHABLE(); } 26 virtual void Break() { UNREACHABLE(); }
28 virtual void Continue() { UNREACHABLE(); } 27 virtual void Continue() { UNREACHABLE(); }
29 28
30 protected: 29 protected:
31 typedef StructuredGraphBuilder Builder; 30 typedef AstGraphBuilder Builder;
32 typedef StructuredGraphBuilder::Environment Environment; 31 typedef AstGraphBuilder::Environment Environment;
33 32
34 Zone* zone() const { return builder_->local_zone(); } 33 Zone* zone() const { return builder_->local_zone(); }
35 Environment* environment() { return builder_->environment(); } 34 Environment* environment() { return builder_->environment(); }
36 void set_environment(Environment* env) { builder_->set_environment(env); } 35 void set_environment(Environment* env) { builder_->set_environment(env); }
37 36
38 Builder* builder_; 37 Builder* builder_;
39 }; 38 };
40 39
41 40
42 // Tracks control flow for a conditional statement. 41 // Tracks control flow for a conditional statement.
43 class IfBuilder FINAL : public ControlBuilder { 42 class IfBuilder FINAL : public ControlBuilder {
44 public: 43 public:
45 explicit IfBuilder(StructuredGraphBuilder* builder) 44 explicit IfBuilder(AstGraphBuilder* builder)
46 : ControlBuilder(builder), 45 : ControlBuilder(builder),
47 then_environment_(NULL), 46 then_environment_(NULL),
48 else_environment_(NULL) {} 47 else_environment_(NULL) {}
49 48
50 // Primitive control commands. 49 // Primitive control commands.
51 void If(Node* condition, BranchHint hint = BranchHint::kNone); 50 void If(Node* condition, BranchHint hint = BranchHint::kNone);
52 void Then(); 51 void Then();
53 void Else(); 52 void Else();
54 void End(); 53 void End();
55 54
56 private: 55 private:
57 Environment* then_environment_; // Environment after the 'then' body. 56 Environment* then_environment_; // Environment after the 'then' body.
58 Environment* else_environment_; // Environment for the 'else' body. 57 Environment* else_environment_; // Environment for the 'else' body.
59 }; 58 };
60 59
61 60
62 // Tracks control flow for an iteration statement. 61 // Tracks control flow for an iteration statement.
63 class LoopBuilder FINAL : public ControlBuilder { 62 class LoopBuilder FINAL : public ControlBuilder {
64 public: 63 public:
65 explicit LoopBuilder(StructuredGraphBuilder* builder) 64 explicit LoopBuilder(AstGraphBuilder* builder)
66 : ControlBuilder(builder), 65 : ControlBuilder(builder),
67 loop_environment_(NULL), 66 loop_environment_(NULL),
68 continue_environment_(NULL), 67 continue_environment_(NULL),
69 break_environment_(NULL) {} 68 break_environment_(NULL) {}
70 69
71 // Primitive control commands. 70 // Primitive control commands.
72 void BeginLoop(BitVector* assigned, bool is_osr = false); 71 void BeginLoop(BitVector* assigned, bool is_osr = false);
73 void EndBody(); 72 void EndBody();
74 void EndLoop(); 73 void EndLoop();
75 74
76 // Primitive support for break and continue. 75 // Primitive support for break and continue.
77 void Continue() FINAL; 76 void Continue() FINAL;
78 void Break() FINAL; 77 void Break() FINAL;
79 78
80 // Compound control commands for conditional break. 79 // Compound control commands for conditional break.
81 void BreakUnless(Node* condition); 80 void BreakUnless(Node* condition);
82 void BreakWhen(Node* condition); 81 void BreakWhen(Node* condition);
83 82
84 private: 83 private:
85 Environment* loop_environment_; // Environment of the loop header. 84 Environment* loop_environment_; // Environment of the loop header.
86 Environment* continue_environment_; // Environment after the loop body. 85 Environment* continue_environment_; // Environment after the loop body.
87 Environment* break_environment_; // Environment after the loop exits. 86 Environment* break_environment_; // Environment after the loop exits.
88 }; 87 };
89 88
90 89
91 // Tracks control flow for a switch statement. 90 // Tracks control flow for a switch statement.
92 class SwitchBuilder FINAL : public ControlBuilder { 91 class SwitchBuilder FINAL : public ControlBuilder {
93 public: 92 public:
94 explicit SwitchBuilder(StructuredGraphBuilder* builder, int case_count) 93 explicit SwitchBuilder(AstGraphBuilder* builder, int case_count)
95 : ControlBuilder(builder), 94 : ControlBuilder(builder),
96 body_environment_(NULL), 95 body_environment_(NULL),
97 label_environment_(NULL), 96 label_environment_(NULL),
98 break_environment_(NULL), 97 break_environment_(NULL),
99 body_environments_(case_count, zone()) {} 98 body_environments_(case_count, zone()) {}
100 99
101 // Primitive control commands. 100 // Primitive control commands.
102 void BeginSwitch(); 101 void BeginSwitch();
103 void BeginLabel(int index, Node* condition); 102 void BeginLabel(int index, Node* condition);
104 void EndLabel(); 103 void EndLabel();
(...skipping 12 matching lines...) Expand all
117 Environment* body_environment_; // Environment after last case body. 116 Environment* body_environment_; // Environment after last case body.
118 Environment* label_environment_; // Environment for next label condition. 117 Environment* label_environment_; // Environment for next label condition.
119 Environment* break_environment_; // Environment after the switch exits. 118 Environment* break_environment_; // Environment after the switch exits.
120 ZoneVector<Environment*> body_environments_; 119 ZoneVector<Environment*> body_environments_;
121 }; 120 };
122 121
123 122
124 // Tracks control flow for a block statement. 123 // Tracks control flow for a block statement.
125 class BlockBuilder FINAL : public ControlBuilder { 124 class BlockBuilder FINAL : public ControlBuilder {
126 public: 125 public:
127 explicit BlockBuilder(StructuredGraphBuilder* builder) 126 explicit BlockBuilder(AstGraphBuilder* builder)
128 : ControlBuilder(builder), break_environment_(NULL) {} 127 : ControlBuilder(builder), break_environment_(NULL) {}
129 128
130 // Primitive control commands. 129 // Primitive control commands.
131 void BeginBlock(); 130 void BeginBlock();
132 void EndBlock(); 131 void EndBlock();
133 132
134 // Primitive support for break. 133 // Primitive support for break.
135 void Break() FINAL; 134 void Break() FINAL;
136 135
137 private: 136 private:
138 Environment* break_environment_; // Environment after the block exits. 137 Environment* break_environment_; // Environment after the block exits.
139 }; 138 };
140 139
141 } // namespace compiler 140 } // namespace compiler
142 } // namespace internal 141 } // namespace internal
143 } // namespace v8 142 } // namespace v8
144 143
145 #endif // V8_COMPILER_CONTROL_BUILDERS_H_ 144 #endif // V8_COMPILER_CONTROL_BUILDERS_H_
OLDNEW
« no previous file with comments | « src/compiler/ast-graph-builder.cc ('k') | src/compiler/graph-builder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698