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

Side by Side Diff: src/ast.h

Issue 1074009: Mark all loop conditions. (Closed)
Patch Set: Negate test to match previous (and correct) behavior. 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/ast.cc » ('j') | src/data-flow.cc » ('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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 virtual bool IsPrimitive() = 0; 232 virtual bool IsPrimitive() = 0;
233 233
234 // Mark the expression as being compiled as an expression 234 // Mark the expression as being compiled as an expression
235 // statement. This is used to transform postfix increments to 235 // statement. This is used to transform postfix increments to
236 // (faster) prefix increments. 236 // (faster) prefix increments.
237 virtual void MarkAsStatement() { /* do nothing */ } 237 virtual void MarkAsStatement() { /* do nothing */ }
238 238
239 // Static type information for this expression. 239 // Static type information for this expression.
240 StaticType* type() { return &type_; } 240 StaticType* type() { return &type_; }
241 241
242 // True if the expression is a loop condition.
243 bool is_loop_condition() const {
244 return LoopConditionField::decode(bitfields_);
245 }
246 void set_is_loop_condition(bool flag) {
247 bitfields_ = (bitfields_ & ~LoopConditionField::mask()) |
248 LoopConditionField::encode(flag);
249 }
250
242 // AST analysis results 251 // AST analysis results
243 252
244 // True if the expression rooted at this node can be compiled by the 253 // True if the expression rooted at this node can be compiled by the
245 // side-effect free compiler. 254 // side-effect free compiler.
246 bool side_effect_free() { return SideEffectFreeField::decode(bitfields_); } 255 bool side_effect_free() { return SideEffectFreeField::decode(bitfields_); }
247 void set_side_effect_free(bool is_side_effect_free) { 256 void set_side_effect_free(bool is_side_effect_free) {
248 bitfields_ &= ~SideEffectFreeField::mask(); 257 bitfields_ &= ~SideEffectFreeField::mask();
249 bitfields_ |= SideEffectFreeField::encode(is_side_effect_free); 258 bitfields_ |= SideEffectFreeField::encode(is_side_effect_free);
250 } 259 }
251 260
(...skipping 26 matching lines...) Expand all
278 static const int kMaxNumBitOps = (1 << 5) - 1; 287 static const int kMaxNumBitOps = (1 << 5) - 1;
279 288
280 uint32_t bitfields_; 289 uint32_t bitfields_;
281 StaticType type_; 290 StaticType type_;
282 291
283 // Using template BitField<type, start, size>. 292 // Using template BitField<type, start, size>.
284 class SideEffectFreeField : public BitField<bool, 0, 1> {}; 293 class SideEffectFreeField : public BitField<bool, 0, 1> {};
285 class NoNegativeZeroField : public BitField<bool, 1, 1> {}; 294 class NoNegativeZeroField : public BitField<bool, 1, 1> {};
286 class ToInt32Field : public BitField<bool, 2, 1> {}; 295 class ToInt32Field : public BitField<bool, 2, 1> {};
287 class NumBitOpsField : public BitField<int, 3, 5> {}; 296 class NumBitOpsField : public BitField<int, 3, 5> {};
297 class LoopConditionField: public BitField<bool, 8, 1> {};
288 }; 298 };
289 299
290 300
291 /** 301 /**
292 * A sentinel used during pre parsing that represents some expression 302 * A sentinel used during pre parsing that represents some expression
293 * that is a valid left hand side without having to actually build 303 * that is a valid left hand side without having to actually build
294 * the expression. 304 * the expression.
295 */ 305 */
296 class ValidLeftHandSideSentinel: public Expression { 306 class ValidLeftHandSideSentinel: public Expression {
297 public: 307 public:
(...skipping 1120 matching lines...) Expand 10 before | Expand all | Expand 10 after
1418 private: 1428 private:
1419 bool is_prefix_; 1429 bool is_prefix_;
1420 Token::Value op_; 1430 Token::Value op_;
1421 Expression* expression_; 1431 Expression* expression_;
1422 }; 1432 };
1423 1433
1424 1434
1425 class CompareOperation: public Expression { 1435 class CompareOperation: public Expression {
1426 public: 1436 public:
1427 CompareOperation(Token::Value op, Expression* left, Expression* right) 1437 CompareOperation(Token::Value op, Expression* left, Expression* right)
1428 : op_(op), left_(left), right_(right), is_for_loop_condition_(false) { 1438 : op_(op), left_(left), right_(right) {
1429 ASSERT(Token::IsCompareOp(op)); 1439 ASSERT(Token::IsCompareOp(op));
1430 } 1440 }
1431 1441
1432 CompareOperation(CompareOperation* other, 1442 CompareOperation(CompareOperation* other,
1433 Expression* left, 1443 Expression* left,
1434 Expression* right); 1444 Expression* right);
1435 1445
1436 virtual void Accept(AstVisitor* v); 1446 virtual void Accept(AstVisitor* v);
1437 1447
1438 virtual bool IsPrimitive(); 1448 virtual bool IsPrimitive();
1439 1449
1440 Token::Value op() const { return op_; } 1450 Token::Value op() const { return op_; }
1441 Expression* left() const { return left_; } 1451 Expression* left() const { return left_; }
1442 Expression* right() const { return right_; } 1452 Expression* right() const { return right_; }
1443 1453
1444 // Accessors for flag whether this compare operation is hanging of a for loop.
1445 bool is_for_loop_condition() const { return is_for_loop_condition_; }
1446 void set_is_for_loop_condition() { is_for_loop_condition_ = true; }
1447
1448 // Type testing & conversion 1454 // Type testing & conversion
1449 virtual CompareOperation* AsCompareOperation() { return this; } 1455 virtual CompareOperation* AsCompareOperation() { return this; }
1450 1456
1451 private: 1457 private:
1452 Token::Value op_; 1458 Token::Value op_;
1453 Expression* left_; 1459 Expression* left_;
1454 Expression* right_; 1460 Expression* right_;
1455 bool is_for_loop_condition_;
1456 }; 1461 };
1457 1462
1458 1463
1459 class Conditional: public Expression { 1464 class Conditional: public Expression {
1460 public: 1465 public:
1461 Conditional(Expression* condition, 1466 Conditional(Expression* condition,
1462 Expression* then_expression, 1467 Expression* then_expression,
1463 Expression* else_expression) 1468 Expression* else_expression)
1464 : condition_(condition), 1469 : condition_(condition),
1465 then_expression_(then_expression), 1470 then_expression_(then_expression),
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after
2084 2089
2085 // Holds the result of copying an expression. 2090 // Holds the result of copying an expression.
2086 Expression* expr_; 2091 Expression* expr_;
2087 // Holds the result of copying a statement. 2092 // Holds the result of copying a statement.
2088 Statement* stmt_; 2093 Statement* stmt_;
2089 }; 2094 };
2090 2095
2091 } } // namespace v8::internal 2096 } } // namespace v8::internal
2092 2097
2093 #endif // V8_AST_H_ 2098 #endif // V8_AST_H_
OLDNEW
« no previous file with comments | « no previous file | src/ast.cc » ('j') | src/data-flow.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698