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

Side by Side Diff: src/ast.h

Issue 5908001: Fix issue 977, occasional failure of the DeltaBlue benchmark. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge/build/ia32
Patch Set: Created 10 years 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/ast-inl.h » ('j') | src/full-codegen.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 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 } 469 }
470 470
471 Expression* cond() const { return cond_; } 471 Expression* cond() const { return cond_; }
472 472
473 // Position where condition expression starts. We need it to make 473 // Position where condition expression starts. We need it to make
474 // the loop's condition a breakable location. 474 // the loop's condition a breakable location.
475 int condition_position() { return condition_position_; } 475 int condition_position() { return condition_position_; }
476 void set_condition_position(int pos) { condition_position_ = pos; } 476 void set_condition_position(int pos) { condition_position_ = pos; }
477 477
478 // Bailout support. 478 // Bailout support.
479 virtual int ContinueId() const { return next_id_; } 479 virtual int ContinueId() const { return continue_id_; }
480 int BackEdgeId() const { return back_edge_id_; }
480 481
481 private: 482 private:
482 Expression* cond_; 483 Expression* cond_;
483 int condition_position_; 484 int condition_position_;
484 int next_id_; 485 int continue_id_;
486 int back_edge_id_;
485 }; 487 };
486 488
487 489
488 class WhileStatement: public IterationStatement { 490 class WhileStatement: public IterationStatement {
489 public: 491 public:
490 explicit inline WhileStatement(ZoneStringList* labels); 492 explicit inline WhileStatement(ZoneStringList* labels);
491 493
492 DECLARE_NODE_TYPE(WhileStatement) 494 DECLARE_NODE_TYPE(WhileStatement)
493 495
494 void Initialize(Expression* cond, Statement* body) { 496 void Initialize(Expression* cond, Statement* body) {
495 IterationStatement::Initialize(body); 497 IterationStatement::Initialize(body);
496 cond_ = cond; 498 cond_ = cond;
497 } 499 }
498 500
499 Expression* cond() const { return cond_; } 501 Expression* cond() const { return cond_; }
500 bool may_have_function_literal() const { 502 bool may_have_function_literal() const {
501 return may_have_function_literal_; 503 return may_have_function_literal_;
502 } 504 }
503 void set_may_have_function_literal(bool value) { 505 void set_may_have_function_literal(bool value) {
504 may_have_function_literal_ = value; 506 may_have_function_literal_ = value;
505 } 507 }
506 508
507 // Bailout support. 509 // Bailout support.
508 virtual int ContinueId() const { return EntryId(); } 510 virtual int ContinueId() const { return EntryId(); }
511 int BodyId() const { return body_id_; }
509 512
510 private: 513 private:
511 Expression* cond_; 514 Expression* cond_;
512 // True if there is a function literal subexpression in the condition. 515 // True if there is a function literal subexpression in the condition.
513 bool may_have_function_literal_; 516 bool may_have_function_literal_;
517 int body_id_;
514 }; 518 };
515 519
516 520
517 class ForStatement: public IterationStatement { 521 class ForStatement: public IterationStatement {
518 public: 522 public:
519 explicit inline ForStatement(ZoneStringList* labels); 523 explicit inline ForStatement(ZoneStringList* labels);
520 524
521 DECLARE_NODE_TYPE(ForStatement) 525 DECLARE_NODE_TYPE(ForStatement)
522 526
523 void Initialize(Statement* init, 527 void Initialize(Statement* init,
(...skipping 11 matching lines...) Expand all
535 Statement* next() const { return next_; } 539 Statement* next() const { return next_; }
536 540
537 bool may_have_function_literal() const { 541 bool may_have_function_literal() const {
538 return may_have_function_literal_; 542 return may_have_function_literal_;
539 } 543 }
540 void set_may_have_function_literal(bool value) { 544 void set_may_have_function_literal(bool value) {
541 may_have_function_literal_ = value; 545 may_have_function_literal_ = value;
542 } 546 }
543 547
544 // Bailout support. 548 // Bailout support.
545 virtual int ContinueId() const { return next_id_; } 549 virtual int ContinueId() const { return continue_id_; }
550 int BodyId() const { return body_id_; }
546 551
547 bool is_fast_smi_loop() { return loop_variable_ != NULL; } 552 bool is_fast_smi_loop() { return loop_variable_ != NULL; }
548 Variable* loop_variable() { return loop_variable_; } 553 Variable* loop_variable() { return loop_variable_; }
549 void set_loop_variable(Variable* var) { loop_variable_ = var; } 554 void set_loop_variable(Variable* var) { loop_variable_ = var; }
550 555
551 private: 556 private:
552 Statement* init_; 557 Statement* init_;
553 Expression* cond_; 558 Expression* cond_;
554 Statement* next_; 559 Statement* next_;
555 // True if there is a function literal subexpression in the condition. 560 // True if there is a function literal subexpression in the condition.
556 bool may_have_function_literal_; 561 bool may_have_function_literal_;
557 Variable* loop_variable_; 562 Variable* loop_variable_;
558 int next_id_; 563 int continue_id_;
564 int body_id_;
559 }; 565 };
560 566
561 567
562 class ForInStatement: public IterationStatement { 568 class ForInStatement: public IterationStatement {
563 public: 569 public:
564 explicit inline ForInStatement(ZoneStringList* labels); 570 explicit inline ForInStatement(ZoneStringList* labels);
565 571
566 DECLARE_NODE_TYPE(ForInStatement) 572 DECLARE_NODE_TYPE(ForInStatement)
567 573
568 void Initialize(Expression* each, Expression* enumerable, Statement* body) { 574 void Initialize(Expression* each, Expression* enumerable, Statement* body) {
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
728 // the parser implicitly creates an empty statement. Use the 734 // the parser implicitly creates an empty statement. Use the
729 // HasThenStatement() and HasElseStatement() functions to check if a 735 // HasThenStatement() and HasElseStatement() functions to check if a
730 // given if-statement has a then- or an else-part containing code. 736 // given if-statement has a then- or an else-part containing code.
731 class IfStatement: public Statement { 737 class IfStatement: public Statement {
732 public: 738 public:
733 IfStatement(Expression* condition, 739 IfStatement(Expression* condition,
734 Statement* then_statement, 740 Statement* then_statement,
735 Statement* else_statement) 741 Statement* else_statement)
736 : condition_(condition), 742 : condition_(condition),
737 then_statement_(then_statement), 743 then_statement_(then_statement),
738 else_statement_(else_statement) { } 744 else_statement_(else_statement),
745 then_id_(GetNextId()),
746 else_id_(GetNextId()) {
747 }
739 748
740 DECLARE_NODE_TYPE(IfStatement) 749 DECLARE_NODE_TYPE(IfStatement)
741 750
742 virtual bool IsInlineable() const; 751 virtual bool IsInlineable() const;
743 752
744 bool HasThenStatement() const { return !then_statement()->IsEmpty(); } 753 bool HasThenStatement() const { return !then_statement()->IsEmpty(); }
745 bool HasElseStatement() const { return !else_statement()->IsEmpty(); } 754 bool HasElseStatement() const { return !else_statement()->IsEmpty(); }
746 755
747 Expression* condition() const { return condition_; } 756 Expression* condition() const { return condition_; }
748 Statement* then_statement() const { return then_statement_; } 757 Statement* then_statement() const { return then_statement_; }
749 Statement* else_statement() const { return else_statement_; } 758 Statement* else_statement() const { return else_statement_; }
750 759
760 int ThenId() const { return then_id_; }
761 int ElseId() const { return else_id_; }
762
751 private: 763 private:
752 Expression* condition_; 764 Expression* condition_;
753 Statement* then_statement_; 765 Statement* then_statement_;
754 Statement* else_statement_; 766 Statement* else_statement_;
767 int then_id_;
768 int else_id_;
755 }; 769 };
756 770
757 771
758 // NOTE: TargetCollectors are represented as nodes to fit in the target 772 // NOTE: TargetCollectors are represented as nodes to fit in the target
759 // stack in the compiler; this should probably be reworked. 773 // stack in the compiler; this should probably be reworked.
760 class TargetCollector: public AstNode { 774 class TargetCollector: public AstNode {
761 public: 775 public:
762 explicit TargetCollector(ZoneList<BreakTarget*>* targets) 776 explicit TargetCollector(ZoneList<BreakTarget*>* targets)
763 : targets_(targets) { 777 : targets_(targets) {
764 } 778 }
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after
1369 1383
1370 1384
1371 class BinaryOperation: public Expression { 1385 class BinaryOperation: public Expression {
1372 public: 1386 public:
1373 BinaryOperation(Token::Value op, 1387 BinaryOperation(Token::Value op,
1374 Expression* left, 1388 Expression* left,
1375 Expression* right, 1389 Expression* right,
1376 int pos) 1390 int pos)
1377 : op_(op), left_(left), right_(right), pos_(pos), is_smi_only_(false) { 1391 : op_(op), left_(left), right_(right), pos_(pos), is_smi_only_(false) {
1378 ASSERT(Token::IsBinaryOp(op)); 1392 ASSERT(Token::IsBinaryOp(op));
1393 right_id_ = (op == Token::AND || op == Token::OR)
1394 ? GetNextId()
1395 : AstNode::kNoNumber;
1379 } 1396 }
1380 1397
1381 // Create the binary operation corresponding to a compound assignment. 1398 // Create the binary operation corresponding to a compound assignment.
1382 explicit BinaryOperation(Assignment* assignment); 1399 explicit BinaryOperation(Assignment* assignment);
1383 1400
1384 DECLARE_NODE_TYPE(BinaryOperation) 1401 DECLARE_NODE_TYPE(BinaryOperation)
1385 1402
1386 virtual bool IsInlineable() const; 1403 virtual bool IsInlineable() const;
1387 1404
1388 virtual bool ResultOverwriteAllowed(); 1405 virtual bool ResultOverwriteAllowed();
1389 1406
1390 Token::Value op() const { return op_; } 1407 Token::Value op() const { return op_; }
1391 Expression* left() const { return left_; } 1408 Expression* left() const { return left_; }
1392 Expression* right() const { return right_; } 1409 Expression* right() const { return right_; }
1393 int position() const { return pos_; } 1410 int position() const { return pos_; }
1394 1411
1395 // Type feedback information. 1412 // Type feedback information.
1396 void RecordTypeFeedback(TypeFeedbackOracle* oracle); 1413 void RecordTypeFeedback(TypeFeedbackOracle* oracle);
1397 bool IsSmiOnly() const { return is_smi_only_; } 1414 bool IsSmiOnly() const { return is_smi_only_; }
1398 1415
1416 // Bailout support.
1417 int RightId() const { return right_id_; }
1418
1399 private: 1419 private:
1400 Token::Value op_; 1420 Token::Value op_;
1401 Expression* left_; 1421 Expression* left_;
1402 Expression* right_; 1422 Expression* right_;
1403 int pos_; 1423 int pos_;
1404 bool is_smi_only_; 1424 bool is_smi_only_;
1425 // The short-circuit logical operations have an AST ID for their
1426 // right-hand subexpression.
1427 int right_id_;
1405 }; 1428 };
1406 1429
1407 1430
1408 class IncrementOperation: public Expression { 1431 class IncrementOperation: public Expression {
1409 public: 1432 public:
1410 IncrementOperation(Token::Value op, Expression* expr) 1433 IncrementOperation(Token::Value op, Expression* expr)
1411 : op_(op), expression_(expr) { 1434 : op_(op), expression_(expr) {
1412 ASSERT(Token::IsCountOp(op)); 1435 ASSERT(Token::IsCountOp(op));
1413 } 1436 }
1414 1437
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
1519 public: 1542 public:
1520 Conditional(Expression* condition, 1543 Conditional(Expression* condition,
1521 Expression* then_expression, 1544 Expression* then_expression,
1522 Expression* else_expression, 1545 Expression* else_expression,
1523 int then_expression_position, 1546 int then_expression_position,
1524 int else_expression_position) 1547 int else_expression_position)
1525 : condition_(condition), 1548 : condition_(condition),
1526 then_expression_(then_expression), 1549 then_expression_(then_expression),
1527 else_expression_(else_expression), 1550 else_expression_(else_expression),
1528 then_expression_position_(then_expression_position), 1551 then_expression_position_(then_expression_position),
1529 else_expression_position_(else_expression_position) { } 1552 else_expression_position_(else_expression_position),
1553 then_id_(GetNextId()),
1554 else_id_(GetNextId()) {
1555 }
1530 1556
1531 DECLARE_NODE_TYPE(Conditional) 1557 DECLARE_NODE_TYPE(Conditional)
1532 1558
1533 virtual bool IsInlineable() const; 1559 virtual bool IsInlineable() const;
1534 1560
1535 Expression* condition() const { return condition_; } 1561 Expression* condition() const { return condition_; }
1536 Expression* then_expression() const { return then_expression_; } 1562 Expression* then_expression() const { return then_expression_; }
1537 Expression* else_expression() const { return else_expression_; } 1563 Expression* else_expression() const { return else_expression_; }
1538 1564
1539 int then_expression_position() { return then_expression_position_; } 1565 int then_expression_position() const { return then_expression_position_; }
1540 int else_expression_position() { return else_expression_position_; } 1566 int else_expression_position() const { return else_expression_position_; }
1567
1568 int ThenId() const { return then_id_; }
1569 int ElseId() const { return else_id_; }
1541 1570
1542 private: 1571 private:
1543 Expression* condition_; 1572 Expression* condition_;
1544 Expression* then_expression_; 1573 Expression* then_expression_;
1545 Expression* else_expression_; 1574 Expression* else_expression_;
1546 int then_expression_position_; 1575 int then_expression_position_;
1547 int else_expression_position_; 1576 int else_expression_position_;
1577 int then_id_;
1578 int else_id_;
1548 }; 1579 };
1549 1580
1550 1581
1551 class Assignment: public Expression { 1582 class Assignment: public Expression {
1552 public: 1583 public:
1553 Assignment(Token::Value op, Expression* target, Expression* value, int pos); 1584 Assignment(Token::Value op, Expression* target, Expression* value, int pos);
1554 1585
1555 DECLARE_NODE_TYPE(Assignment) 1586 DECLARE_NODE_TYPE(Assignment)
1556 1587
1557 virtual bool IsInlineable() const; 1588 virtual bool IsInlineable() const;
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
2129 AST_NODE_LIST(DEF_VISIT) 2160 AST_NODE_LIST(DEF_VISIT)
2130 #undef DEF_VISIT 2161 #undef DEF_VISIT
2131 2162
2132 private: 2163 private:
2133 bool stack_overflow_; 2164 bool stack_overflow_;
2134 }; 2165 };
2135 2166
2136 } } // namespace v8::internal 2167 } } // namespace v8::internal
2137 2168
2138 #endif // V8_AST_H_ 2169 #endif // V8_AST_H_
OLDNEW
« no previous file with comments | « no previous file | src/ast-inl.h » ('j') | src/full-codegen.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698