OLD | NEW |
---|---|
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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
176 // Evaluated for control flow and side effects. Value is also | 176 // Evaluated for control flow and side effects. Value is also |
177 // needed if true. | 177 // needed if true. |
178 kValueTest, | 178 kValueTest, |
179 // Evaluated for control flow and side effects. Value is also | 179 // Evaluated for control flow and side effects. Value is also |
180 // needed if false. | 180 // needed if false. |
181 kTestValue | 181 kTestValue |
182 }; | 182 }; |
183 | 183 |
184 static const int kNoLabel = -1; | 184 static const int kNoLabel = -1; |
185 | 185 |
186 Expression() : num_(kNoLabel), def_(NULL), defined_vars_(NULL) {} | 186 Expression() |
187 : bitfields_(0), | |
188 num_(kNoLabel), | |
189 def_(NULL), | |
190 defined_vars_(NULL) {} | |
187 | 191 |
188 virtual Expression* AsExpression() { return this; } | 192 virtual Expression* AsExpression() { return this; } |
189 | 193 |
190 virtual bool IsValidLeftHandSide() { return false; } | 194 virtual bool IsValidLeftHandSide() { return false; } |
191 | 195 |
192 // Symbols that cannot be parsed as array indices are considered property | 196 // Symbols that cannot be parsed as array indices are considered property |
193 // names. We do not treat symbols that can be array indexes as property | 197 // names. We do not treat symbols that can be array indexes as property |
194 // names because [] for string objects is handled only by keyed ICs. | 198 // names because [] for string objects is handled only by keyed ICs. |
195 virtual bool IsPropertyName() { return false; } | 199 virtual bool IsPropertyName() { return false; } |
196 | 200 |
(...skipping 21 matching lines...) Expand all Loading... | |
218 | 222 |
219 // Data flow information. | 223 // Data flow information. |
220 DefinitionInfo* var_def() { return def_; } | 224 DefinitionInfo* var_def() { return def_; } |
221 void set_var_def(DefinitionInfo* def) { def_ = def; } | 225 void set_var_def(DefinitionInfo* def) { def_ = def; } |
222 | 226 |
223 ZoneList<DefinitionInfo*>* defined_vars() { return defined_vars_; } | 227 ZoneList<DefinitionInfo*>* defined_vars() { return defined_vars_; } |
224 void set_defined_vars(ZoneList<DefinitionInfo*>* defined_vars) { | 228 void set_defined_vars(ZoneList<DefinitionInfo*>* defined_vars) { |
225 defined_vars_ = defined_vars; | 229 defined_vars_ = defined_vars; |
226 } | 230 } |
227 | 231 |
232 // AST analysis results | |
233 | |
234 // True if the expression rooted at this node can be compiled by the | |
235 // side-effect free compiler. | |
236 bool side_effect_free() { return SideEffectFreeField::decode(bitfields_); } | |
237 void set_side_effect_free(bool is_side_effect_free) { | |
238 bitfields_ = (bitfields_ & ~SideEffectFreeField::mask()) | | |
Kevin Millikin (Chromium)
2010/03/02 14:33:06
It's a little weird that there are three different
| |
239 SideEffectFreeField::encode(is_side_effect_free); | |
240 } | |
241 | |
242 // The number of unary and binary operations contained in the expression | |
243 // rooted at this node. Valid only if side_effect_free() is true. | |
244 int expression_size() { return ExpressionSizeField::decode(bitfields_); } | |
245 void set_expression_size(int expression_size) { | |
246 bitfields_ = (bitfields_ & ~ExpressionSizeField::mask()) | | |
247 ExpressionSizeField::encode(Min(expression_size, ExpressionSizeMax)); | |
248 } | |
249 | |
250 // The number of expression stack slots needed to compute the expression | |
251 // rooted at this node. Does not count the slot needed by the value | |
252 // computed by this expression. Valid only if side_effect_free() is true. | |
253 int stack_height() { return StackHeightField::decode(bitfields_); } | |
254 void set_stack_height(int stack_height) { | |
255 bitfields_ &= ~StackHeightField::mask(); | |
256 bitfields_ |= | |
257 StackHeightField::encode(Min(stack_height, StackHeightMax)); | |
258 } | |
259 | |
228 private: | 260 private: |
261 uint32_t bitfields_; | |
229 StaticType type_; | 262 StaticType type_; |
263 | |
230 int num_; | 264 int num_; |
231 DefinitionInfo* def_; | 265 DefinitionInfo* def_; |
232 ZoneList<DefinitionInfo*>* defined_vars_; | 266 ZoneList<DefinitionInfo*>* defined_vars_; |
267 | |
268 static const int SideEffectFreeFieldStart = 0; | |
Kevin Millikin (Chromium)
2010/03/02 14:33:06
These constants don't help anything. They're used
| |
269 static const int SideEffectFreeFieldLength = 1; | |
270 class SideEffectFreeField: public BitField<bool, | |
271 SideEffectFreeFieldStart, | |
272 SideEffectFreeFieldLength> { | |
273 }; | |
274 | |
275 static const int ExpressionSizeFieldStart = | |
276 SideEffectFreeFieldStart + SideEffectFreeFieldLength; | |
277 static const int ExpressionSizeFieldLength = 5; | |
278 static const int ExpressionSizeMax = (1 << ExpressionSizeFieldLength) - 1; | |
279 class ExpressionSizeField: public BitField<int, | |
280 ExpressionSizeFieldStart, | |
281 ExpressionSizeFieldLength> { | |
282 }; | |
283 | |
284 static const int StackHeightFieldStart = | |
285 ExpressionSizeFieldStart + ExpressionSizeFieldLength; | |
286 static const int StackHeightFieldLength = 5; | |
287 static const int StackHeightMax = (1 << StackHeightFieldLength) - 1; | |
288 class StackHeightField: public BitField<int, | |
289 StackHeightFieldStart, | |
290 StackHeightFieldLength> { | |
291 }; | |
233 }; | 292 }; |
234 | 293 |
235 | 294 |
236 /** | 295 /** |
237 * A sentinel used during pre parsing that represents some expression | 296 * A sentinel used during pre parsing that represents some expression |
238 * that is a valid left hand side without having to actually build | 297 * that is a valid left hand side without having to actually build |
239 * the expression. | 298 * the expression. |
240 */ | 299 */ |
241 class ValidLeftHandSideSentinel: public Expression { | 300 class ValidLeftHandSideSentinel: public Expression { |
242 public: | 301 public: |
(...skipping 1606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1849 #undef DEF_VISIT | 1908 #undef DEF_VISIT |
1850 | 1909 |
1851 private: | 1910 private: |
1852 bool stack_overflow_; | 1911 bool stack_overflow_; |
1853 }; | 1912 }; |
1854 | 1913 |
1855 | 1914 |
1856 } } // namespace v8::internal | 1915 } } // namespace v8::internal |
1857 | 1916 |
1858 #endif // V8_AST_H_ | 1917 #endif // V8_AST_H_ |
OLD | NEW |