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

Side by Side Diff: src/ast.h

Issue 660449: Initial implementation of an edge-labeled instruction flow graph. (Closed)
Patch Set: Remove unused depth-first search function. Created 10 years, 9 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 | « no previous file | src/compiler.cc » ('j') | src/data-flow.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 110
111 111
112 // Typedef only introduced to avoid unreadable code. 112 // Typedef only introduced to avoid unreadable code.
113 // Please do appreciate the required space in "> >". 113 // Please do appreciate the required space in "> >".
114 typedef ZoneList<Handle<String> > ZoneStringList; 114 typedef ZoneList<Handle<String> > ZoneStringList;
115 typedef ZoneList<Handle<Object> > ZoneObjectList; 115 typedef ZoneList<Handle<Object> > ZoneObjectList;
116 116
117 117
118 class AstNode: public ZoneObject { 118 class AstNode: public ZoneObject {
119 public: 119 public:
120 static const int kNoNumber = -1;
121
122 AstNode() : num_(kNoNumber) {}
120 virtual ~AstNode() { } 123 virtual ~AstNode() { }
121 virtual void Accept(AstVisitor* v) = 0; 124 virtual void Accept(AstVisitor* v) = 0;
122 125
123 // Type testing & conversion. 126 // Type testing & conversion.
124 virtual Statement* AsStatement() { return NULL; } 127 virtual Statement* AsStatement() { return NULL; }
125 virtual ExpressionStatement* AsExpressionStatement() { return NULL; } 128 virtual ExpressionStatement* AsExpressionStatement() { return NULL; }
126 virtual EmptyStatement* AsEmptyStatement() { return NULL; } 129 virtual EmptyStatement* AsEmptyStatement() { return NULL; }
127 virtual Expression* AsExpression() { return NULL; } 130 virtual Expression* AsExpression() { return NULL; }
128 virtual Literal* AsLiteral() { return NULL; } 131 virtual Literal* AsLiteral() { return NULL; }
129 virtual Slot* AsSlot() { return NULL; } 132 virtual Slot* AsSlot() { return NULL; }
130 virtual VariableProxy* AsVariableProxy() { return NULL; } 133 virtual VariableProxy* AsVariableProxy() { return NULL; }
131 virtual Property* AsProperty() { return NULL; } 134 virtual Property* AsProperty() { return NULL; }
132 virtual Call* AsCall() { return NULL; } 135 virtual Call* AsCall() { return NULL; }
133 virtual TargetCollector* AsTargetCollector() { return NULL; } 136 virtual TargetCollector* AsTargetCollector() { return NULL; }
134 virtual BreakableStatement* AsBreakableStatement() { return NULL; } 137 virtual BreakableStatement* AsBreakableStatement() { return NULL; }
135 virtual IterationStatement* AsIterationStatement() { return NULL; } 138 virtual IterationStatement* AsIterationStatement() { return NULL; }
136 virtual UnaryOperation* AsUnaryOperation() { return NULL; } 139 virtual UnaryOperation* AsUnaryOperation() { return NULL; }
137 virtual BinaryOperation* AsBinaryOperation() { return NULL; } 140 virtual BinaryOperation* AsBinaryOperation() { return NULL; }
138 virtual Assignment* AsAssignment() { return NULL; } 141 virtual Assignment* AsAssignment() { return NULL; }
139 virtual FunctionLiteral* AsFunctionLiteral() { return NULL; } 142 virtual FunctionLiteral* AsFunctionLiteral() { return NULL; }
140 virtual MaterializedLiteral* AsMaterializedLiteral() { return NULL; } 143 virtual MaterializedLiteral* AsMaterializedLiteral() { return NULL; }
141 virtual ObjectLiteral* AsObjectLiteral() { return NULL; } 144 virtual ObjectLiteral* AsObjectLiteral() { return NULL; }
142 virtual ArrayLiteral* AsArrayLiteral() { return NULL; } 145 virtual ArrayLiteral* AsArrayLiteral() { return NULL; }
143 virtual CompareOperation* AsCompareOperation() { return NULL; } 146 virtual CompareOperation* AsCompareOperation() { return NULL; }
147
148 int num() { return num_; }
149 void set_num(int n) { num_ = n; }
150
151 private:
152 // Support for ast node numbering.
153 int num_;
144 }; 154 };
145 155
146 156
147 class Statement: public AstNode { 157 class Statement: public AstNode {
148 public: 158 public:
149 Statement() : statement_pos_(RelocInfo::kNoPosition) {} 159 Statement() : statement_pos_(RelocInfo::kNoPosition) {}
150 160
151 virtual Statement* AsStatement() { return this; } 161 virtual Statement* AsStatement() { return this; }
152 virtual ReturnStatement* AsReturnStatement() { return NULL; } 162 virtual ReturnStatement* AsReturnStatement() { return NULL; }
153 163
(...skipping 20 matching lines...) Expand all
174 // Evaluated for control flow (and side effects). 184 // Evaluated for control flow (and side effects).
175 kTest, 185 kTest,
176 // Evaluated for control flow and side effects. Value is also 186 // Evaluated for control flow and side effects. Value is also
177 // needed if true. 187 // needed if true.
178 kValueTest, 188 kValueTest,
179 // Evaluated for control flow and side effects. Value is also 189 // Evaluated for control flow and side effects. Value is also
180 // needed if false. 190 // needed if false.
181 kTestValue 191 kTestValue
182 }; 192 };
183 193
184 static const int kNoLabel = -1;
185
186 Expression() 194 Expression()
187 : bitfields_(0), 195 : bitfields_(0),
188 num_(kNoLabel),
189 def_(NULL), 196 def_(NULL),
190 defined_vars_(NULL) {} 197 defined_vars_(NULL) {}
191 198
192 virtual Expression* AsExpression() { return this; } 199 virtual Expression* AsExpression() { return this; }
193 200
194 virtual bool IsValidLeftHandSide() { return false; } 201 virtual bool IsValidLeftHandSide() { return false; }
195 202
196 // Symbols that cannot be parsed as array indices are considered property 203 // Symbols that cannot be parsed as array indices are considered property
197 // names. We do not treat symbols that can be array indexes as property 204 // names. We do not treat symbols that can be array indexes as property
198 // names because [] for string objects is handled only by keyed ICs. 205 // names because [] for string objects is handled only by keyed ICs.
199 virtual bool IsPropertyName() { return false; } 206 virtual bool IsPropertyName() { return false; }
200 207
201 // True if the expression does not have (evaluated) subexpressions. 208 // True if the expression does not have (evaluated) subexpressions.
202 // Function literals are leaves because their subexpressions are not 209 // Function literals are leaves because their subexpressions are not
203 // evaluated. 210 // evaluated.
204 virtual bool IsLeaf() { return false; } 211 virtual bool IsLeaf() { return false; }
205 212
206 // True if the expression has no side effects and is safe to 213 // True if the expression has no side effects and is safe to
207 // evaluate out of order. 214 // evaluate out of order.
208 virtual bool IsTrivial() { return false; } 215 virtual bool IsTrivial() { return false; }
209 216
210 // Mark the expression as being compiled as an expression 217 // Mark the expression as being compiled as an expression
211 // statement. This is used to transform postfix increments to 218 // statement. This is used to transform postfix increments to
212 // (faster) prefix increments. 219 // (faster) prefix increments.
213 virtual void MarkAsStatement() { /* do nothing */ } 220 virtual void MarkAsStatement() { /* do nothing */ }
214 221
215 // Static type information for this expression. 222 // Static type information for this expression.
216 StaticType* type() { return &type_; } 223 StaticType* type() { return &type_; }
217 224
218 int num() { return num_; }
219
220 // AST node numbering ordered by evaluation order.
221 void set_num(int n) { num_ = n; }
222
223 // Data flow information. 225 // Data flow information.
224 DefinitionInfo* var_def() { return def_; } 226 DefinitionInfo* var_def() { return def_; }
225 void set_var_def(DefinitionInfo* def) { def_ = def; } 227 void set_var_def(DefinitionInfo* def) { def_ = def; }
226 228
227 ZoneList<DefinitionInfo*>* defined_vars() { return defined_vars_; } 229 ZoneList<DefinitionInfo*>* defined_vars() { return defined_vars_; }
228 void set_defined_vars(ZoneList<DefinitionInfo*>* defined_vars) { 230 void set_defined_vars(ZoneList<DefinitionInfo*>* defined_vars) {
229 defined_vars_ = defined_vars; 231 defined_vars_ = defined_vars;
230 } 232 }
231 233
232 // AST analysis results 234 // AST analysis results
(...skipping 21 matching lines...) Expand all
254 void set_stack_height(int stack_height) { 256 void set_stack_height(int stack_height) {
255 bitfields_ &= ~StackHeightField::mask(); 257 bitfields_ &= ~StackHeightField::mask();
256 bitfields_ |= 258 bitfields_ |=
257 StackHeightField::encode(Min(stack_height, StackHeightMax)); 259 StackHeightField::encode(Min(stack_height, StackHeightMax));
258 } 260 }
259 261
260 private: 262 private:
261 uint32_t bitfields_; 263 uint32_t bitfields_;
262 StaticType type_; 264 StaticType type_;
263 265
264 int num_;
265 DefinitionInfo* def_; 266 DefinitionInfo* def_;
266 ZoneList<DefinitionInfo*>* defined_vars_; 267 ZoneList<DefinitionInfo*>* defined_vars_;
267 268
268 static const int SideEffectFreeFieldStart = 0; 269 static const int SideEffectFreeFieldStart = 0;
269 static const int SideEffectFreeFieldLength = 1; 270 static const int SideEffectFreeFieldLength = 1;
270 class SideEffectFreeField: public BitField<bool, 271 class SideEffectFreeField: public BitField<bool,
271 SideEffectFreeFieldStart, 272 SideEffectFreeFieldStart,
272 SideEffectFreeFieldLength> { 273 SideEffectFreeFieldLength> {
273 }; 274 };
274 275
(...skipping 1633 matching lines...) Expand 10 before | Expand all | Expand 10 after
1908 #undef DEF_VISIT 1909 #undef DEF_VISIT
1909 1910
1910 private: 1911 private:
1911 bool stack_overflow_; 1912 bool stack_overflow_;
1912 }; 1913 };
1913 1914
1914 1915
1915 } } // namespace v8::internal 1916 } } // namespace v8::internal
1916 1917
1917 #endif // V8_AST_H_ 1918 #endif // V8_AST_H_
OLDNEW
« no previous file with comments | « no previous file | src/compiler.cc » ('j') | src/data-flow.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698