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

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

Issue 10827387: Reenable elimination of strict equals when right side is true. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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
« no previous file with comments | « runtime/vm/flow_graph.cc ('k') | runtime/vm/intermediate_language.cc » ('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 (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_INTERMEDIATE_LANGUAGE_H_ 5 #ifndef VM_INTERMEDIATE_LANGUAGE_H_
6 #define VM_INTERMEDIATE_LANGUAGE_H_ 6 #define VM_INTERMEDIATE_LANGUAGE_H_
7 7
8 #include "vm/allocation.h" 8 #include "vm/allocation.h"
9 #include "vm/ast.h" 9 #include "vm/ast.h"
10 #include "vm/growable_array.h" 10 #include "vm/growable_array.h"
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 // Returns true, if this computation can deoptimize. 149 // Returns true, if this computation can deoptimize.
150 virtual bool CanDeoptimize() const = 0; 150 virtual bool CanDeoptimize() const = 0;
151 151
152 // Optimize this computation. Returns a replacement for the instruction 152 // Optimize this computation. Returns a replacement for the instruction
153 // that wraps this computation or NULL if nothing to replace. 153 // that wraps this computation or NULL if nothing to replace.
154 virtual Definition* TryReplace(BindInstr* instr) { return NULL; } 154 virtual Definition* TryReplace(BindInstr* instr) { return NULL; }
155 155
156 // Compile time type of the computation, which typically depends on the 156 // Compile time type of the computation, which typically depends on the
157 // compile time types (and possibly propagated types) of its inputs. 157 // compile time types (and possibly propagated types) of its inputs.
158 virtual RawAbstractType* CompileType() const = 0; 158 virtual RawAbstractType* CompileType() const = 0;
159 // TODO(srdjan): Make this abstract so that it gets correctly implemented
160 // in all computations.
161 virtual intptr_t ResultCid() const { return kDynamicCid; } 159 virtual intptr_t ResultCid() const { return kDynamicCid; }
162 160
163 // Mutate assigned_vars to add the local variable index for all 161 // Mutate assigned_vars to add the local variable index for all
164 // frame-allocated locals assigned to by the computation. 162 // frame-allocated locals assigned to by the computation.
165 virtual void RecordAssignedVars(BitVector* assigned_vars, 163 virtual void RecordAssignedVars(BitVector* assigned_vars,
166 intptr_t fixed_parameter_count); 164 intptr_t fixed_parameter_count);
167 165
168 virtual const char* DebugName() const = 0; 166 virtual const char* DebugName() const = 0;
169 167
170 // Printing support. These functions are sometimes overridden for custom 168 // Printing support. These functions are sometimes overridden for custom
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 class Value : public TemplateComputation<0> { 296 class Value : public TemplateComputation<0> {
299 public: 297 public:
300 Value() { } 298 Value() { }
301 299
302 // Returns true if the value represents a constant. 300 // Returns true if the value represents a constant.
303 virtual bool BindsToConstant() const = 0; 301 virtual bool BindsToConstant() const = 0;
304 302
305 // Returns true if the value represents constant null. 303 // Returns true if the value represents constant null.
306 virtual bool BindsToConstantNull() const = 0; 304 virtual bool BindsToConstantNull() const = 0;
307 305
306 // Assert if BindsToConstant() is false, otherwise returns constant.
307 virtual const Object& BoundConstant() const = 0;
308
308 // Reminder: The type of the constant null is the bottom type, which is more 309 // Reminder: The type of the constant null is the bottom type, which is more
309 // specific than any type. 310 // specific than any type.
310 bool CompileTypeIsMoreSpecificThan(const AbstractType& dst_type) const; 311 bool CompileTypeIsMoreSpecificThan(const AbstractType& dst_type) const;
311 312
312 virtual void RemoveFromUseList() = 0; 313 virtual void RemoveFromUseList() = 0;
313 314
314 private: 315 private:
315 DISALLOW_COPY_AND_ASSIGN(Value); 316 DISALLOW_COPY_AND_ASSIGN(Value);
316 }; 317 };
317 318
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 public: 354 public:
354 explicit UseVal(Definition* definition); 355 explicit UseVal(Definition* definition);
355 356
356 DECLARE_VALUE(Use) 357 DECLARE_VALUE(Use)
357 358
358 inline Definition* definition() const; 359 inline Definition* definition() const;
359 void SetDefinition(Definition* definition); 360 void SetDefinition(Definition* definition);
360 361
361 // Returns true if the value represents a constant. 362 // Returns true if the value represents a constant.
362 virtual bool BindsToConstant() const; 363 virtual bool BindsToConstant() const;
364 virtual const Object& BoundConstant() const;
363 365
364 // Returns true if the value represents constant null. 366 // Returns true if the value represents constant null.
365 virtual bool BindsToConstantNull() const; 367 virtual bool BindsToConstantNull() const;
366 368
367 virtual bool CanDeoptimize() const { return false; } 369 virtual bool CanDeoptimize() const { return false; }
368 370
369 UseVal* next_use() const { return next_use_; } 371 UseVal* next_use() const { return next_use_; }
370 UseVal* previous_use() const { return previous_use_; } 372 UseVal* previous_use() const { return previous_use_; }
371 virtual void RemoveFromUseList(); 373 virtual void RemoveFromUseList();
372 virtual void RemoveInputUses() { RemoveFromUseList(); } 374 virtual void RemoveInputUses() { RemoveFromUseList(); }
(...skipping 19 matching lines...) Expand all
392 ASSERT(value.IsZoneHandle()); 394 ASSERT(value.IsZoneHandle());
393 ASSERT(value.IsSmi() || value.IsOld()); 395 ASSERT(value.IsSmi() || value.IsOld());
394 } 396 }
395 397
396 DECLARE_VALUE(Constant) 398 DECLARE_VALUE(Constant)
397 399
398 const Object& value() const { return value_; } 400 const Object& value() const { return value_; }
399 401
400 // Returns true if the value represents a constant. 402 // Returns true if the value represents a constant.
401 virtual bool BindsToConstant() const { return true; } 403 virtual bool BindsToConstant() const { return true; }
404 virtual const Object& BoundConstant() const { return value(); }
402 405
403 // Returns true if the value represents constant null. 406 // Returns true if the value represents constant null.
404 virtual bool BindsToConstantNull() const { return value().IsNull(); } 407 virtual bool BindsToConstantNull() const { return value().IsNull(); }
405 408
406 virtual bool CanDeoptimize() const { return false; } 409 virtual bool CanDeoptimize() const { return false; }
407 410
408 virtual void RemoveFromUseList() { } 411 virtual void RemoveFromUseList() { }
409 412
410 virtual intptr_t ResultCid() const; 413 virtual intptr_t ResultCid() const;
411 414
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 return is_eliminated_; 501 return is_eliminated_;
499 } 502 }
500 void eliminate() { 503 void eliminate() {
501 ASSERT(!is_eliminated_); 504 ASSERT(!is_eliminated_);
502 is_eliminated_ = true; 505 is_eliminated_ = true;
503 } 506 }
504 507
505 virtual void PrintOperandsTo(BufferFormatter* f) const; 508 virtual void PrintOperandsTo(BufferFormatter* f) const;
506 509
507 virtual bool CanDeoptimize() const { return false; } 510 virtual bool CanDeoptimize() const { return false; }
508
509 virtual intptr_t ResultCid() const { return kBoolCid; } 511 virtual intptr_t ResultCid() const { return kBoolCid; }
510 512
511 private: 513 private:
512 const intptr_t token_pos_; 514 const intptr_t token_pos_;
513 const intptr_t try_index_; 515 const intptr_t try_index_;
514 bool is_eliminated_; 516 bool is_eliminated_;
515 517
516 DISALLOW_COPY_AND_ASSIGN(AssertBooleanComp); 518 DISALLOW_COPY_AND_ASSIGN(AssertBooleanComp);
517 }; 519 };
518 520
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 ASSERT((kind == Token::kEQ_STRICT) || (kind == Token::kNE_STRICT)); 696 ASSERT((kind == Token::kEQ_STRICT) || (kind == Token::kNE_STRICT));
695 } 697 }
696 698
697 DECLARE_COMPUTATION(StrictCompare) 699 DECLARE_COMPUTATION(StrictCompare)
698 700
699 virtual void PrintOperandsTo(BufferFormatter* f) const; 701 virtual void PrintOperandsTo(BufferFormatter* f) const;
700 702
701 virtual bool CanDeoptimize() const { return false; } 703 virtual bool CanDeoptimize() const { return false; }
702 704
703 virtual Definition* TryReplace(BindInstr* instr); 705 virtual Definition* TryReplace(BindInstr* instr);
704
705 virtual intptr_t ResultCid() const { return kBoolCid; } 706 virtual intptr_t ResultCid() const { return kBoolCid; }
706 707
707 private: 708 private:
708 DISALLOW_COPY_AND_ASSIGN(StrictCompareComp); 709 DISALLOW_COPY_AND_ASSIGN(StrictCompareComp);
709 }; 710 };
710 711
711 712
712 class EqualityCompareComp : public ComparisonComp { 713 class EqualityCompareComp : public ComparisonComp {
713 public: 714 public:
714 EqualityCompareComp(intptr_t token_pos, 715 EqualityCompareComp(intptr_t token_pos,
(...skipping 13 matching lines...) Expand all
728 intptr_t token_pos() const { return token_pos_; } 729 intptr_t token_pos() const { return token_pos_; }
729 intptr_t try_index() const { return try_index_; } 730 intptr_t try_index() const { return try_index_; }
730 731
731 // Receiver class id is computed from collected ICData. 732 // Receiver class id is computed from collected ICData.
732 void set_receiver_class_id(intptr_t value) { receiver_class_id_ = value; } 733 void set_receiver_class_id(intptr_t value) { receiver_class_id_ = value; }
733 intptr_t receiver_class_id() const { return receiver_class_id_; } 734 intptr_t receiver_class_id() const { return receiver_class_id_; }
734 735
735 virtual void PrintOperandsTo(BufferFormatter* f) const; 736 virtual void PrintOperandsTo(BufferFormatter* f) const;
736 737
737 virtual bool CanDeoptimize() const { return true; } 738 virtual bool CanDeoptimize() const { return true; }
738 739 virtual intptr_t ResultCid() const;
739 virtual intptr_t ResultCid() const { return kBoolCid; }
740 740
741 private: 741 private:
742 const intptr_t token_pos_; 742 const intptr_t token_pos_;
743 const intptr_t try_index_; 743 const intptr_t try_index_;
744 intptr_t receiver_class_id_; // Set by optimizer. 744 intptr_t receiver_class_id_; // Set by optimizer.
745 745
746 DISALLOW_COPY_AND_ASSIGN(EqualityCompareComp); 746 DISALLOW_COPY_AND_ASSIGN(EqualityCompareComp);
747 }; 747 };
748 748
749 749
(...skipping 20 matching lines...) Expand all
770 // between boxed and unboxed doubles and integers. 770 // between boxed and unboxed doubles and integers.
771 void set_operands_class_id(intptr_t value) { 771 void set_operands_class_id(intptr_t value) {
772 operands_class_id_ = value; 772 operands_class_id_ = value;
773 } 773 }
774 774
775 intptr_t operands_class_id() const { return operands_class_id_; } 775 intptr_t operands_class_id() const { return operands_class_id_; }
776 776
777 virtual void PrintOperandsTo(BufferFormatter* f) const; 777 virtual void PrintOperandsTo(BufferFormatter* f) const;
778 778
779 virtual bool CanDeoptimize() const { return true; } 779 virtual bool CanDeoptimize() const { return true; }
780 780 virtual intptr_t ResultCid() const;
781 virtual intptr_t ResultCid() const { return kBoolCid; }
782 781
783 private: 782 private:
784 const intptr_t token_pos_; 783 const intptr_t token_pos_;
785 const intptr_t try_index_; 784 const intptr_t try_index_;
786 intptr_t operands_class_id_; // class id of both operands. 785 intptr_t operands_class_id_; // class id of both operands.
787 786
788 DISALLOW_COPY_AND_ASSIGN(RelationalOpComp); 787 DISALLOW_COPY_AND_ASSIGN(RelationalOpComp);
789 }; 788 };
790 789
791 790
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
1157 Value* instantiator_type_arguments() const { return inputs_[2]; } 1156 Value* instantiator_type_arguments() const { return inputs_[2]; }
1158 1157
1159 bool negate_result() const { return negate_result_; } 1158 bool negate_result() const { return negate_result_; }
1160 const AbstractType& type() const { return type_; } 1159 const AbstractType& type() const { return type_; }
1161 intptr_t token_pos() const { return token_pos_; } 1160 intptr_t token_pos() const { return token_pos_; }
1162 intptr_t try_index() const { return try_index_; } 1161 intptr_t try_index() const { return try_index_; }
1163 1162
1164 virtual void PrintOperandsTo(BufferFormatter* f) const; 1163 virtual void PrintOperandsTo(BufferFormatter* f) const;
1165 1164
1166 virtual bool CanDeoptimize() const { return false; } 1165 virtual bool CanDeoptimize() const { return false; }
1166 virtual intptr_t ResultCid() const { return kBoolCid; }
1167 1167
1168 private: 1168 private:
1169 const intptr_t token_pos_; 1169 const intptr_t token_pos_;
1170 const intptr_t try_index_; 1170 const intptr_t try_index_;
1171 Value* value_; 1171 Value* value_;
1172 Value* instantiator_; 1172 Value* instantiator_;
1173 Value* type_arguments_; 1173 Value* type_arguments_;
1174 const AbstractType& type_; 1174 const AbstractType& type_;
1175 const bool negate_result_; 1175 const bool negate_result_;
1176 1176
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
1609 1609
1610 OperandsType operands_type() const { return operands_type_; } 1610 OperandsType operands_type() const { return operands_type_; }
1611 1611
1612 InstanceCallComp* instance_call() const { return instance_call_; } 1612 InstanceCallComp* instance_call() const { return instance_call_; }
1613 1613
1614 virtual void PrintOperandsTo(BufferFormatter* f) const; 1614 virtual void PrintOperandsTo(BufferFormatter* f) const;
1615 1615
1616 DECLARE_COMPUTATION(BinaryOp) 1616 DECLARE_COMPUTATION(BinaryOp)
1617 1617
1618 virtual bool CanDeoptimize() const { return true; } 1618 virtual bool CanDeoptimize() const { return true; }
1619 virtual intptr_t ResultCid() const;
1619 1620
1620 private: 1621 private:
1621 const Token::Kind op_kind_; 1622 const Token::Kind op_kind_;
1622 const OperandsType operands_type_; 1623 const OperandsType operands_type_;
1623 InstanceCallComp* instance_call_; 1624 InstanceCallComp* instance_call_;
1624 1625
1625 DISALLOW_COPY_AND_ASSIGN(BinaryOpComp); 1626 DISALLOW_COPY_AND_ASSIGN(BinaryOpComp);
1626 }; 1627 };
1627 1628
1628 1629
1629 class DoubleBinaryOpComp : public TemplateComputation<0> { 1630 class DoubleBinaryOpComp : public TemplateComputation<0> {
1630 public: 1631 public:
1631 DoubleBinaryOpComp(Token::Kind op_kind, InstanceCallComp* instance_call) 1632 DoubleBinaryOpComp(Token::Kind op_kind, InstanceCallComp* instance_call)
1632 : op_kind_(op_kind), instance_call_(instance_call) { } 1633 : op_kind_(op_kind), instance_call_(instance_call) { }
1633 1634
1634 Token::Kind op_kind() const { return op_kind_; } 1635 Token::Kind op_kind() const { return op_kind_; }
1635 1636
1636 InstanceCallComp* instance_call() const { return instance_call_; } 1637 InstanceCallComp* instance_call() const { return instance_call_; }
1637 1638
1638 virtual void PrintOperandsTo(BufferFormatter* f) const; 1639 virtual void PrintOperandsTo(BufferFormatter* f) const;
1639 1640
1640 DECLARE_CALL_COMPUTATION(DoubleBinaryOp) 1641 DECLARE_CALL_COMPUTATION(DoubleBinaryOp)
1641 1642
1642 virtual intptr_t ArgumentCount() const { return 2; } 1643 virtual intptr_t ArgumentCount() const { return 2; }
1643 1644
1644 virtual bool CanDeoptimize() const { return true; } 1645 virtual bool CanDeoptimize() const { return true; }
1646 virtual intptr_t ResultCid() const;
1645 1647
1646 private: 1648 private:
1647 const Token::Kind op_kind_; 1649 const Token::Kind op_kind_;
1648 InstanceCallComp* instance_call_; 1650 InstanceCallComp* instance_call_;
1649 1651
1650 DISALLOW_COPY_AND_ASSIGN(DoubleBinaryOpComp); 1652 DISALLOW_COPY_AND_ASSIGN(DoubleBinaryOpComp);
1651 }; 1653 };
1652 1654
1653 1655
1654 // Handles both Smi operations: BIT_OR and NEGATE. 1656 // Handles both Smi operations: BIT_OR and NEGATE.
(...skipping 10 matching lines...) Expand all
1665 Value* value() const { return inputs_[0]; } 1667 Value* value() const { return inputs_[0]; }
1666 Token::Kind op_kind() const { return op_kind_; } 1668 Token::Kind op_kind() const { return op_kind_; }
1667 1669
1668 InstanceCallComp* instance_call() const { return instance_call_; } 1670 InstanceCallComp* instance_call() const { return instance_call_; }
1669 1671
1670 virtual void PrintOperandsTo(BufferFormatter* f) const; 1672 virtual void PrintOperandsTo(BufferFormatter* f) const;
1671 1673
1672 DECLARE_COMPUTATION(UnarySmiOp) 1674 DECLARE_COMPUTATION(UnarySmiOp)
1673 1675
1674 virtual bool CanDeoptimize() const { return true; } 1676 virtual bool CanDeoptimize() const { return true; }
1677 virtual intptr_t ResultCid() const { return kSmiCid; }
1675 1678
1676 private: 1679 private:
1677 const Token::Kind op_kind_; 1680 const Token::Kind op_kind_;
1678 InstanceCallComp* instance_call_; 1681 InstanceCallComp* instance_call_;
1679 1682
1680 DISALLOW_COPY_AND_ASSIGN(UnarySmiOpComp); 1683 DISALLOW_COPY_AND_ASSIGN(UnarySmiOpComp);
1681 }; 1684 };
1682 1685
1683 1686
1684 // Handles non-Smi NEGATE operations 1687 // Handles non-Smi NEGATE operations
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1734 inputs_[0] = value; 1737 inputs_[0] = value;
1735 } 1738 }
1736 1739
1737 Value* value() const { return inputs_[0]; } 1740 Value* value() const { return inputs_[0]; }
1738 1741
1739 InstanceCallComp* instance_call() const { return instance_call_; } 1742 InstanceCallComp* instance_call() const { return instance_call_; }
1740 1743
1741 DECLARE_COMPUTATION(DoubleToDouble) 1744 DECLARE_COMPUTATION(DoubleToDouble)
1742 1745
1743 virtual bool CanDeoptimize() const { return true; } 1746 virtual bool CanDeoptimize() const { return true; }
1747 virtual intptr_t ResultCid() const { return kDoubleCid; }
1744 1748
1745 private: 1749 private:
1746 InstanceCallComp* instance_call_; 1750 InstanceCallComp* instance_call_;
1747 1751
1748 DISALLOW_COPY_AND_ASSIGN(DoubleToDoubleComp); 1752 DISALLOW_COPY_AND_ASSIGN(DoubleToDoubleComp);
1749 }; 1753 };
1750 1754
1751 1755
1752 class SmiToDoubleComp : public TemplateComputation<0> { 1756 class SmiToDoubleComp : public TemplateComputation<0> {
1753 public: 1757 public:
1754 explicit SmiToDoubleComp(InstanceCallComp* instance_call) 1758 explicit SmiToDoubleComp(InstanceCallComp* instance_call)
1755 : instance_call_(instance_call) { } 1759 : instance_call_(instance_call) { }
1756 1760
1757 InstanceCallComp* instance_call() const { return instance_call_; } 1761 InstanceCallComp* instance_call() const { return instance_call_; }
1758 1762
1759 DECLARE_CALL_COMPUTATION(SmiToDouble) 1763 DECLARE_CALL_COMPUTATION(SmiToDouble)
1760 1764
1761 virtual intptr_t ArgumentCount() const { return 1; } 1765 virtual intptr_t ArgumentCount() const { return 1; }
1762 1766
1763 virtual bool CanDeoptimize() const { return true; } 1767 virtual bool CanDeoptimize() const { return true; }
1768 virtual intptr_t ResultCid() const { return kDoubleCid; }
1764 1769
1765 private: 1770 private:
1766 InstanceCallComp* instance_call_; 1771 InstanceCallComp* instance_call_;
1767 1772
1768 DISALLOW_COPY_AND_ASSIGN(SmiToDoubleComp); 1773 DISALLOW_COPY_AND_ASSIGN(SmiToDoubleComp);
1769 }; 1774 };
1770 1775
1771 1776
1772 #undef DECLARE_COMPUTATION 1777 #undef DECLARE_COMPUTATION
1773 1778
(...skipping 1186 matching lines...) Expand 10 before | Expand all | Expand 10 after
2960 ForwardInstructionIterator* current_iterator_; 2965 ForwardInstructionIterator* current_iterator_;
2961 2966
2962 private: 2967 private:
2963 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); 2968 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor);
2964 }; 2969 };
2965 2970
2966 2971
2967 } // namespace dart 2972 } // namespace dart
2968 2973
2969 #endif // VM_INTERMEDIATE_LANGUAGE_H_ 2974 #endif // VM_INTERMEDIATE_LANGUAGE_H_
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph.cc ('k') | runtime/vm/intermediate_language.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698