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

Side by Side Diff: runtime/vm/ast.h

Issue 22640019: Fix for running with --throw_on_javascript_int_overflow: recognize pattern (a << b) & mask and test… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 4 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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef VM_AST_H_ 5 #ifndef VM_AST_H_
6 #define VM_AST_H_ 6 #define VM_AST_H_
7 7
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/allocation.h" 9 #include "vm/allocation.h"
10 #include "vm/growable_array.h" 10 #include "vm/growable_array.h"
11 #include "vm/scopes.h" 11 #include "vm/scopes.h"
12 #include "vm/object.h" 12 #include "vm/object.h"
13 #include "vm/native_entry.h" 13 #include "vm/native_entry.h"
14 #include "vm/token.h" 14 #include "vm/token.h"
15 15
16 namespace dart { 16 namespace dart {
17 17
18 #define NODE_LIST(V) \ 18 #define NODE_LIST(V) \
19 V(ReturnNode, "return") \ 19 V(ReturnNode, "return") \
20 V(LiteralNode, "literal") \ 20 V(LiteralNode, "literal") \
21 V(TypeNode, "type") \ 21 V(TypeNode, "type") \
22 V(AssignableNode, "assignable") \ 22 V(AssignableNode, "assignable") \
23 V(BinaryOpNode, "binop") \ 23 V(BinaryOpNode, "binop") \
24 V(BinaryOpWithMask32Node, "binop with mask 32") \
24 V(ComparisonNode, "compare") \ 25 V(ComparisonNode, "compare") \
25 V(UnaryOpNode, "unaryop") \ 26 V(UnaryOpNode, "unaryop") \
26 V(ConditionalExprNode, "?:") \ 27 V(ConditionalExprNode, "?:") \
27 V(IfNode, "if") \ 28 V(IfNode, "if") \
28 V(SwitchNode, "switch") \ 29 V(SwitchNode, "switch") \
29 V(CaseNode, "case") \ 30 V(CaseNode, "case") \
30 V(WhileNode, "while") \ 31 V(WhileNode, "while") \
31 V(DoWhileNode, "dowhile") \ 32 V(DoWhileNode, "dowhile") \
32 V(ForNode, "for") \ 33 V(ForNode, "for") \
33 V(JumpNode, "jump") \ 34 V(JumpNode, "jump") \
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 : AstNode(token_pos), kind_(kind), left_(left), right_(right) { 573 : AstNode(token_pos), kind_(kind), left_(left), right_(right) {
573 ASSERT(left_ != NULL); 574 ASSERT(left_ != NULL);
574 ASSERT(right_ != NULL); 575 ASSERT(right_ != NULL);
575 ASSERT(IsKindValid()); 576 ASSERT(IsKindValid());
576 } 577 }
577 578
578 Token::Kind kind() const { return kind_; } 579 Token::Kind kind() const { return kind_; }
579 AstNode* left() const { return left_; } 580 AstNode* left() const { return left_; }
580 AstNode* right() const { return right_; } 581 AstNode* right() const { return right_; }
581 582
583 virtual bool has_mask32() const { return false; }
584 virtual int64_t mask32() const {
585 UNREACHABLE();
586 return 0;
587 }
588
582 virtual void VisitChildren(AstNodeVisitor* visitor) const { 589 virtual void VisitChildren(AstNodeVisitor* visitor) const {
583 left()->Visit(visitor); 590 left()->Visit(visitor);
584 right()->Visit(visitor); 591 right()->Visit(visitor);
585 } 592 }
586 593
587 virtual const char* Name() const; 594 virtual const char* Name() const;
588 virtual bool IsPotentiallyConst() const; 595 virtual bool IsPotentiallyConst() const;
589 virtual const Instance* EvalConstExpr() const; 596 virtual const Instance* EvalConstExpr() const;
590 597
591 DECLARE_COMMON_NODE_FUNCTIONS(BinaryOpNode); 598 DECLARE_COMMON_NODE_FUNCTIONS(BinaryOpNode);
592 599
593 private: 600 private:
594 const Token::Kind kind_; 601 const Token::Kind kind_;
595 AstNode* left_; 602 AstNode* left_;
596 AstNode* right_; 603 AstNode* right_;
597 604
598 bool IsKindValid() const; 605 bool IsKindValid() const;
599 606
600 DISALLOW_IMPLICIT_CONSTRUCTORS(BinaryOpNode); 607 DISALLOW_IMPLICIT_CONSTRUCTORS(BinaryOpNode);
601 }; 608 };
602 609
603 610
611 class BinaryOpWithMask32Node : public BinaryOpNode {
612 public:
613 BinaryOpWithMask32Node(intptr_t token_pos,
614 Token::Kind kind_value,
615 AstNode* left,
616 AstNode* right,
617 int64_t mask32)
618 : BinaryOpNode(token_pos, kind_value, left, right), mask32_(mask32) {
619 ASSERT(mask32 >= 0 && Utils::IsUint(32, mask32));
620 ASSERT((kind_value != Token::kAND) && (kind_value != Token::kOR));
621 }
622
623 // The optional 32-bit mask must be a an unsigned 32-bit value.
624 virtual bool has_mask32() const { return true; }
625 virtual int64_t mask32() const {
626 ASSERT(has_mask32());
627 return mask32_;
628 }
629
630 virtual const char* Name() const;
631 DECLARE_COMMON_NODE_FUNCTIONS(BinaryOpWithMask32Node);
632
633 private:
634 // Optional unsigned 32 bit mask applied on result. No mask: -1.
635 const int64_t mask32_;
636
637 DISALLOW_IMPLICIT_CONSTRUCTORS(BinaryOpWithMask32Node);
638 };
639
640
641
604 class UnaryOpNode : public AstNode { 642 class UnaryOpNode : public AstNode {
605 public: 643 public:
606 // Returns optimized version, e.g., for ('-' '1') ('-1') literal is returned. 644 // Returns optimized version, e.g., for ('-' '1') ('-1') literal is returned.
607 static AstNode* UnaryOpOrLiteral(intptr_t token_pos, 645 static AstNode* UnaryOpOrLiteral(intptr_t token_pos,
608 Token::Kind kind, 646 Token::Kind kind,
609 AstNode* operand); 647 AstNode* operand);
610 UnaryOpNode(intptr_t token_pos, 648 UnaryOpNode(intptr_t token_pos,
611 Token::Kind kind, 649 Token::Kind kind,
612 AstNode* operand) 650 AstNode* operand)
613 : AstNode(token_pos), kind_(kind), operand_(operand) { 651 : AstNode(token_pos), kind_(kind), operand_(operand) {
(...skipping 1096 matching lines...) Expand 10 before | Expand all | Expand 10 after
1710 const intptr_t try_index_; 1748 const intptr_t try_index_;
1711 1749
1712 DISALLOW_IMPLICIT_CONSTRUCTORS(InlinedFinallyNode); 1750 DISALLOW_IMPLICIT_CONSTRUCTORS(InlinedFinallyNode);
1713 }; 1751 };
1714 1752
1715 } // namespace dart 1753 } // namespace dart
1716 1754
1717 #undef DECLARE_COMMON_NODE_FUNCTIONS 1755 #undef DECLARE_COMMON_NODE_FUNCTIONS
1718 1756
1719 #endif // VM_AST_H_ 1757 #endif // VM_AST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698