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

Side by Side Diff: src/ast.h

Issue 668256: Add AST analysis that flags expressions that will have ToInt32 applied to the... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | src/flag-definitions.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 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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 void set_defined_vars(ZoneList<DefinitionInfo*>* defined_vars) { 230 void set_defined_vars(ZoneList<DefinitionInfo*>* defined_vars) {
231 defined_vars_ = defined_vars; 231 defined_vars_ = defined_vars;
232 } 232 }
233 233
234 // AST analysis results 234 // AST analysis results
235 235
236 // True if the expression rooted at this node can be compiled by the 236 // True if the expression rooted at this node can be compiled by the
237 // side-effect free compiler. 237 // side-effect free compiler.
238 bool side_effect_free() { return SideEffectFreeField::decode(bitfields_); } 238 bool side_effect_free() { return SideEffectFreeField::decode(bitfields_); }
239 void set_side_effect_free(bool is_side_effect_free) { 239 void set_side_effect_free(bool is_side_effect_free) {
240 bitfields_ = (bitfields_ & ~SideEffectFreeField::mask()) | 240 bitfields_ &= ~SideEffectFreeField::mask();
241 SideEffectFreeField::encode(is_side_effect_free); 241 bitfields_ |= SideEffectFreeField::encode(is_side_effect_free);
242 } 242 }
243 243
244 // The number of unary and binary operations contained in the expression 244 // Will ToInt32 ECMA 262-3 9.5) or ToUunt32 (ECMA 262-3 9.6)
245 // rooted at this node. Valid only if side_effect_free() is true. 245 // be applied to the value of this expression?
246 int expression_size() { return ExpressionSizeField::decode(bitfields_); } 246 // If so, we may be able to optimize the calculation of the value.
247 void set_expression_size(int expression_size) { 247 bool to_int32() { return ToInt32Field::decode(bitfields_); }
248 bitfields_ = (bitfields_ & ~ExpressionSizeField::mask()) | 248 void set_to_int32(bool to_int32) {
249 ExpressionSizeField::encode(Min(expression_size, ExpressionSizeMax)); 249 bitfields_ &= ~ToInt32Field::mask();
250 bitfields_ |= ToInt32Field::encode(to_int32);
250 } 251 }
251 252
252 // The number of expression stack slots needed to compute the expression
253 // rooted at this node. Does not count the slot needed by the value
254 // computed by this expression. Valid only if side_effect_free() is true.
255 int stack_height() { return StackHeightField::decode(bitfields_); }
256 void set_stack_height(int stack_height) {
257 bitfields_ &= ~StackHeightField::mask();
258 bitfields_ |=
259 StackHeightField::encode(Min(stack_height, StackHeightMax));
260 }
261 253
262 private: 254 private:
263 uint32_t bitfields_; 255 uint32_t bitfields_;
264 StaticType type_; 256 StaticType type_;
265 257
266 DefinitionInfo* def_; 258 DefinitionInfo* def_;
267 ZoneList<DefinitionInfo*>* defined_vars_; 259 ZoneList<DefinitionInfo*>* defined_vars_;
268 260
269 static const int SideEffectFreeFieldStart = 0; 261 // Using template BitField<type, start, size>.
270 static const int SideEffectFreeFieldLength = 1; 262 class SideEffectFreeField : public BitField<bool, 0, 1> {};
271 class SideEffectFreeField: public BitField<bool, 263 class ToInt32Field : public BitField<bool, 1, 1> {};
272 SideEffectFreeFieldStart,
273 SideEffectFreeFieldLength> {
274 };
275
276 static const int ExpressionSizeFieldStart =
277 SideEffectFreeFieldStart + SideEffectFreeFieldLength;
278 static const int ExpressionSizeFieldLength = 5;
279 static const int ExpressionSizeMax = (1 << ExpressionSizeFieldLength) - 1;
280 class ExpressionSizeField: public BitField<int,
281 ExpressionSizeFieldStart,
282 ExpressionSizeFieldLength> {
283 };
284
285 static const int StackHeightFieldStart =
286 ExpressionSizeFieldStart + ExpressionSizeFieldLength;
287 static const int StackHeightFieldLength = 5;
288 static const int StackHeightMax = (1 << StackHeightFieldLength) - 1;
289 class StackHeightField: public BitField<int,
290 StackHeightFieldStart,
291 StackHeightFieldLength> {
292 };
293 }; 264 };
294 265
295 266
296 /** 267 /**
297 * A sentinel used during pre parsing that represents some expression 268 * A sentinel used during pre parsing that represents some expression
298 * that is a valid left hand side without having to actually build 269 * that is a valid left hand side without having to actually build
299 * the expression. 270 * the expression.
300 */ 271 */
301 class ValidLeftHandSideSentinel: public Expression { 272 class ValidLeftHandSideSentinel: public Expression {
302 public: 273 public:
(...skipping 1600 matching lines...) Expand 10 before | Expand all | Expand 10 after
1903 #undef DEF_VISIT 1874 #undef DEF_VISIT
1904 1875
1905 private: 1876 private:
1906 bool stack_overflow_; 1877 bool stack_overflow_;
1907 }; 1878 };
1908 1879
1909 1880
1910 } } // namespace v8::internal 1881 } } // namespace v8::internal
1911 1882
1912 #endif // V8_AST_H_ 1883 #endif // V8_AST_H_
OLDNEW
« no previous file with comments | « no previous file | src/flag-definitions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698