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

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
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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 295
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;
305 // Assert if BindsToConstant() is false, otherwise returns constant.
regis 2012/08/16 21:43:52 Missing empty line. Or group with BindsToConstant(
srdjan 2012/08/16 22:11:06 Added empty line.
306 virtual const Object& BoundConstant() const = 0;
307 307
308 // Reminder: The type of the constant null is the bottom type, which is more 308 // Reminder: The type of the constant null is the bottom type, which is more
309 // specific than any type. 309 // specific than any type.
310 bool CompileTypeIsMoreSpecificThan(const AbstractType& dst_type) const; 310 bool CompileTypeIsMoreSpecificThan(const AbstractType& dst_type) const;
311 311
312 virtual void RemoveFromUseList() = 0; 312 virtual void RemoveFromUseList() = 0;
313 313
314 private: 314 private:
315 DISALLOW_COPY_AND_ASSIGN(Value); 315 DISALLOW_COPY_AND_ASSIGN(Value);
316 }; 316 };
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 public: 353 public:
354 explicit UseVal(Definition* definition); 354 explicit UseVal(Definition* definition);
355 355
356 DECLARE_VALUE(Use) 356 DECLARE_VALUE(Use)
357 357
358 inline Definition* definition() const; 358 inline Definition* definition() const;
359 void SetDefinition(Definition* definition); 359 void SetDefinition(Definition* definition);
360 360
361 // Returns true if the value represents a constant. 361 // Returns true if the value represents a constant.
362 virtual bool BindsToConstant() const; 362 virtual bool BindsToConstant() const;
363 virtual const Object& BoundConstant() const;
363 364
364 // Returns true if the value represents constant null. 365 // Returns true if the value represents constant null.
365 virtual bool BindsToConstantNull() const; 366 virtual bool BindsToConstantNull() const;
366 367
367 virtual bool CanDeoptimize() const { return false; } 368 virtual bool CanDeoptimize() const { return false; }
368 369
369 UseVal* next_use() const { return next_use_; } 370 UseVal* next_use() const { return next_use_; }
370 UseVal* previous_use() const { return previous_use_; } 371 UseVal* previous_use() const { return previous_use_; }
371 virtual void RemoveFromUseList(); 372 virtual void RemoveFromUseList();
372 virtual void RemoveInputUses() { RemoveFromUseList(); } 373 virtual void RemoveInputUses() { RemoveFromUseList(); }
(...skipping 19 matching lines...) Expand all
392 ASSERT(value.IsZoneHandle()); 393 ASSERT(value.IsZoneHandle());
393 ASSERT(value.IsSmi() || value.IsOld()); 394 ASSERT(value.IsSmi() || value.IsOld());
394 } 395 }
395 396
396 DECLARE_VALUE(Constant) 397 DECLARE_VALUE(Constant)
397 398
398 const Object& value() const { return value_; } 399 const Object& value() const { return value_; }
399 400
400 // Returns true if the value represents a constant. 401 // Returns true if the value represents a constant.
401 virtual bool BindsToConstant() const { return true; } 402 virtual bool BindsToConstant() const { return true; }
403 virtual const Object& BoundConstant() const { return value(); }
402 404
403 // Returns true if the value represents constant null. 405 // Returns true if the value represents constant null.
404 virtual bool BindsToConstantNull() const { return value().IsNull(); } 406 virtual bool BindsToConstantNull() const { return value().IsNull(); }
405 407
406 virtual bool CanDeoptimize() const { return false; } 408 virtual bool CanDeoptimize() const { return false; }
407 409
408 virtual void RemoveFromUseList() { } 410 virtual void RemoveFromUseList() { }
409 411
410 virtual intptr_t ResultCid() const; 412 virtual intptr_t ResultCid() const;
411 413
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 return is_eliminated_; 500 return is_eliminated_;
499 } 501 }
500 void eliminate() { 502 void eliminate() {
501 ASSERT(!is_eliminated_); 503 ASSERT(!is_eliminated_);
502 is_eliminated_ = true; 504 is_eliminated_ = true;
503 } 505 }
504 506
505 virtual void PrintOperandsTo(BufferFormatter* f) const; 507 virtual void PrintOperandsTo(BufferFormatter* f) const;
506 508
507 virtual bool CanDeoptimize() const { return false; } 509 virtual bool CanDeoptimize() const { return false; }
508
509 virtual intptr_t ResultCid() const { return kBoolCid; } 510 virtual intptr_t ResultCid() const { return kBoolCid; }
510 511
511 private: 512 private:
512 const intptr_t token_pos_; 513 const intptr_t token_pos_;
513 const intptr_t try_index_; 514 const intptr_t try_index_;
514 bool is_eliminated_; 515 bool is_eliminated_;
515 516
516 DISALLOW_COPY_AND_ASSIGN(AssertBooleanComp); 517 DISALLOW_COPY_AND_ASSIGN(AssertBooleanComp);
517 }; 518 };
518 519
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 ASSERT((kind == Token::kEQ_STRICT) || (kind == Token::kNE_STRICT)); 695 ASSERT((kind == Token::kEQ_STRICT) || (kind == Token::kNE_STRICT));
695 } 696 }
696 697
697 DECLARE_COMPUTATION(StrictCompare) 698 DECLARE_COMPUTATION(StrictCompare)
698 699
699 virtual void PrintOperandsTo(BufferFormatter* f) const; 700 virtual void PrintOperandsTo(BufferFormatter* f) const;
700 701
701 virtual bool CanDeoptimize() const { return false; } 702 virtual bool CanDeoptimize() const { return false; }
702 703
703 virtual Definition* TryReplace(BindInstr* instr); 704 virtual Definition* TryReplace(BindInstr* instr);
704
705 virtual intptr_t ResultCid() const { return kBoolCid; } 705 virtual intptr_t ResultCid() const { return kBoolCid; }
706 706
707 private: 707 private:
708 DISALLOW_COPY_AND_ASSIGN(StrictCompareComp); 708 DISALLOW_COPY_AND_ASSIGN(StrictCompareComp);
709 }; 709 };
710 710
711 711
712 class EqualityCompareComp : public ComparisonComp { 712 class EqualityCompareComp : public ComparisonComp {
713 public: 713 public:
714 EqualityCompareComp(intptr_t token_pos, 714 EqualityCompareComp(intptr_t token_pos,
(...skipping 13 matching lines...) Expand all
728 intptr_t token_pos() const { return token_pos_; } 728 intptr_t token_pos() const { return token_pos_; }
729 intptr_t try_index() const { return try_index_; } 729 intptr_t try_index() const { return try_index_; }
730 730
731 // Receiver class id is computed from collected ICData. 731 // Receiver class id is computed from collected ICData.
732 void set_receiver_class_id(intptr_t value) { receiver_class_id_ = value; } 732 void set_receiver_class_id(intptr_t value) { receiver_class_id_ = value; }
733 intptr_t receiver_class_id() const { return receiver_class_id_; } 733 intptr_t receiver_class_id() const { return receiver_class_id_; }
734 734
735 virtual void PrintOperandsTo(BufferFormatter* f) const; 735 virtual void PrintOperandsTo(BufferFormatter* f) const;
736 736
737 virtual bool CanDeoptimize() const { return true; } 737 virtual bool CanDeoptimize() const { return true; }
738 738 virtual intptr_t ResultCid() const;
739 virtual intptr_t ResultCid() const { return kBoolCid; }
740 739
741 private: 740 private:
742 const intptr_t token_pos_; 741 const intptr_t token_pos_;
743 const intptr_t try_index_; 742 const intptr_t try_index_;
744 intptr_t receiver_class_id_; // Set by optimizer. 743 intptr_t receiver_class_id_; // Set by optimizer.
745 744
746 DISALLOW_COPY_AND_ASSIGN(EqualityCompareComp); 745 DISALLOW_COPY_AND_ASSIGN(EqualityCompareComp);
747 }; 746 };
748 747
749 748
(...skipping 20 matching lines...) Expand all
770 // between boxed and unboxed doubles and integers. 769 // between boxed and unboxed doubles and integers.
771 void set_operands_class_id(intptr_t value) { 770 void set_operands_class_id(intptr_t value) {
772 operands_class_id_ = value; 771 operands_class_id_ = value;
773 } 772 }
774 773
775 intptr_t operands_class_id() const { return operands_class_id_; } 774 intptr_t operands_class_id() const { return operands_class_id_; }
776 775
777 virtual void PrintOperandsTo(BufferFormatter* f) const; 776 virtual void PrintOperandsTo(BufferFormatter* f) const;
778 777
779 virtual bool CanDeoptimize() const { return true; } 778 virtual bool CanDeoptimize() const { return true; }
780 779 virtual intptr_t ResultCid() const;
781 virtual intptr_t ResultCid() const { return kBoolCid; }
782 780
783 private: 781 private:
784 const intptr_t token_pos_; 782 const intptr_t token_pos_;
785 const intptr_t try_index_; 783 const intptr_t try_index_;
786 intptr_t operands_class_id_; // class id of both operands. 784 intptr_t operands_class_id_; // class id of both operands.
787 785
788 DISALLOW_COPY_AND_ASSIGN(RelationalOpComp); 786 DISALLOW_COPY_AND_ASSIGN(RelationalOpComp);
789 }; 787 };
790 788
791 789
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
1157 Value* instantiator_type_arguments() const { return inputs_[2]; } 1155 Value* instantiator_type_arguments() const { return inputs_[2]; }
1158 1156
1159 bool negate_result() const { return negate_result_; } 1157 bool negate_result() const { return negate_result_; }
1160 const AbstractType& type() const { return type_; } 1158 const AbstractType& type() const { return type_; }
1161 intptr_t token_pos() const { return token_pos_; } 1159 intptr_t token_pos() const { return token_pos_; }
1162 intptr_t try_index() const { return try_index_; } 1160 intptr_t try_index() const { return try_index_; }
1163 1161
1164 virtual void PrintOperandsTo(BufferFormatter* f) const; 1162 virtual void PrintOperandsTo(BufferFormatter* f) const;
1165 1163
1166 virtual bool CanDeoptimize() const { return false; } 1164 virtual bool CanDeoptimize() const { return false; }
1165 virtual intptr_t ResultCid() const { return kBoolCid; }
1167 1166
1168 private: 1167 private:
1169 const intptr_t token_pos_; 1168 const intptr_t token_pos_;
1170 const intptr_t try_index_; 1169 const intptr_t try_index_;
1171 Value* value_; 1170 Value* value_;
1172 Value* instantiator_; 1171 Value* instantiator_;
1173 Value* type_arguments_; 1172 Value* type_arguments_;
1174 const AbstractType& type_; 1173 const AbstractType& type_;
1175 const bool negate_result_; 1174 const bool negate_result_;
1176 1175
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
1609 1608
1610 OperandsType operands_type() const { return operands_type_; } 1609 OperandsType operands_type() const { return operands_type_; }
1611 1610
1612 InstanceCallComp* instance_call() const { return instance_call_; } 1611 InstanceCallComp* instance_call() const { return instance_call_; }
1613 1612
1614 virtual void PrintOperandsTo(BufferFormatter* f) const; 1613 virtual void PrintOperandsTo(BufferFormatter* f) const;
1615 1614
1616 DECLARE_COMPUTATION(BinaryOp) 1615 DECLARE_COMPUTATION(BinaryOp)
1617 1616
1618 virtual bool CanDeoptimize() const { return true; } 1617 virtual bool CanDeoptimize() const { return true; }
1618 virtual intptr_t ResultCid() const;
1619 1619
1620 private: 1620 private:
1621 const Token::Kind op_kind_; 1621 const Token::Kind op_kind_;
1622 const OperandsType operands_type_; 1622 const OperandsType operands_type_;
1623 InstanceCallComp* instance_call_; 1623 InstanceCallComp* instance_call_;
1624 1624
1625 DISALLOW_COPY_AND_ASSIGN(BinaryOpComp); 1625 DISALLOW_COPY_AND_ASSIGN(BinaryOpComp);
1626 }; 1626 };
1627 1627
1628 1628
1629 class DoubleBinaryOpComp : public TemplateComputation<0> { 1629 class DoubleBinaryOpComp : public TemplateComputation<0> {
1630 public: 1630 public:
1631 DoubleBinaryOpComp(Token::Kind op_kind, InstanceCallComp* instance_call) 1631 DoubleBinaryOpComp(Token::Kind op_kind, InstanceCallComp* instance_call)
1632 : op_kind_(op_kind), instance_call_(instance_call) { } 1632 : op_kind_(op_kind), instance_call_(instance_call) { }
1633 1633
1634 Token::Kind op_kind() const { return op_kind_; } 1634 Token::Kind op_kind() const { return op_kind_; }
1635 1635
1636 InstanceCallComp* instance_call() const { return instance_call_; } 1636 InstanceCallComp* instance_call() const { return instance_call_; }
1637 1637
1638 virtual void PrintOperandsTo(BufferFormatter* f) const; 1638 virtual void PrintOperandsTo(BufferFormatter* f) const;
1639 1639
1640 DECLARE_CALL_COMPUTATION(DoubleBinaryOp) 1640 DECLARE_CALL_COMPUTATION(DoubleBinaryOp)
1641 1641
1642 virtual intptr_t ArgumentCount() const { return 2; } 1642 virtual intptr_t ArgumentCount() const { return 2; }
1643 1643
1644 virtual bool CanDeoptimize() const { return true; } 1644 virtual bool CanDeoptimize() const { return true; }
1645 virtual intptr_t ResultCid() const;
1645 1646
1646 private: 1647 private:
1647 const Token::Kind op_kind_; 1648 const Token::Kind op_kind_;
1648 InstanceCallComp* instance_call_; 1649 InstanceCallComp* instance_call_;
1649 1650
1650 DISALLOW_COPY_AND_ASSIGN(DoubleBinaryOpComp); 1651 DISALLOW_COPY_AND_ASSIGN(DoubleBinaryOpComp);
1651 }; 1652 };
1652 1653
1653 1654
1654 // Handles both Smi operations: BIT_OR and NEGATE. 1655 // Handles both Smi operations: BIT_OR and NEGATE.
(...skipping 10 matching lines...) Expand all
1665 Value* value() const { return inputs_[0]; } 1666 Value* value() const { return inputs_[0]; }
1666 Token::Kind op_kind() const { return op_kind_; } 1667 Token::Kind op_kind() const { return op_kind_; }
1667 1668
1668 InstanceCallComp* instance_call() const { return instance_call_; } 1669 InstanceCallComp* instance_call() const { return instance_call_; }
1669 1670
1670 virtual void PrintOperandsTo(BufferFormatter* f) const; 1671 virtual void PrintOperandsTo(BufferFormatter* f) const;
1671 1672
1672 DECLARE_COMPUTATION(UnarySmiOp) 1673 DECLARE_COMPUTATION(UnarySmiOp)
1673 1674
1674 virtual bool CanDeoptimize() const { return true; } 1675 virtual bool CanDeoptimize() const { return true; }
1676 virtual intptr_t ResultCid() const { return kSmiCid; }
1675 1677
1676 private: 1678 private:
1677 const Token::Kind op_kind_; 1679 const Token::Kind op_kind_;
1678 InstanceCallComp* instance_call_; 1680 InstanceCallComp* instance_call_;
1679 1681
1680 DISALLOW_COPY_AND_ASSIGN(UnarySmiOpComp); 1682 DISALLOW_COPY_AND_ASSIGN(UnarySmiOpComp);
1681 }; 1683 };
1682 1684
1683 1685
1684 // Handles non-Smi NEGATE operations 1686 // Handles non-Smi NEGATE operations
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1734 inputs_[0] = value; 1736 inputs_[0] = value;
1735 } 1737 }
1736 1738
1737 Value* value() const { return inputs_[0]; } 1739 Value* value() const { return inputs_[0]; }
1738 1740
1739 InstanceCallComp* instance_call() const { return instance_call_; } 1741 InstanceCallComp* instance_call() const { return instance_call_; }
1740 1742
1741 DECLARE_COMPUTATION(DoubleToDouble) 1743 DECLARE_COMPUTATION(DoubleToDouble)
1742 1744
1743 virtual bool CanDeoptimize() const { return true; } 1745 virtual bool CanDeoptimize() const { return true; }
1746 virtual intptr_t ResultCid() const { return kDoubleCid; }
1744 1747
1745 private: 1748 private:
1746 InstanceCallComp* instance_call_; 1749 InstanceCallComp* instance_call_;
1747 1750
1748 DISALLOW_COPY_AND_ASSIGN(DoubleToDoubleComp); 1751 DISALLOW_COPY_AND_ASSIGN(DoubleToDoubleComp);
1749 }; 1752 };
1750 1753
1751 1754
1752 class SmiToDoubleComp : public TemplateComputation<0> { 1755 class SmiToDoubleComp : public TemplateComputation<0> {
1753 public: 1756 public:
1754 explicit SmiToDoubleComp(InstanceCallComp* instance_call) 1757 explicit SmiToDoubleComp(InstanceCallComp* instance_call)
1755 : instance_call_(instance_call) { } 1758 : instance_call_(instance_call) { }
1756 1759
1757 InstanceCallComp* instance_call() const { return instance_call_; } 1760 InstanceCallComp* instance_call() const { return instance_call_; }
1758 1761
1759 DECLARE_CALL_COMPUTATION(SmiToDouble) 1762 DECLARE_CALL_COMPUTATION(SmiToDouble)
1760 1763
1761 virtual intptr_t ArgumentCount() const { return 1; } 1764 virtual intptr_t ArgumentCount() const { return 1; }
1762 1765
1763 virtual bool CanDeoptimize() const { return true; } 1766 virtual bool CanDeoptimize() const { return true; }
1767 virtual intptr_t ResultCid() const { return kDoubleCid; }
1764 1768
1765 private: 1769 private:
1766 InstanceCallComp* instance_call_; 1770 InstanceCallComp* instance_call_;
1767 1771
1768 DISALLOW_COPY_AND_ASSIGN(SmiToDoubleComp); 1772 DISALLOW_COPY_AND_ASSIGN(SmiToDoubleComp);
1769 }; 1773 };
1770 1774
1771 1775
1772 #undef DECLARE_COMPUTATION 1776 #undef DECLARE_COMPUTATION
1773 1777
(...skipping 1186 matching lines...) Expand 10 before | Expand all | Expand 10 after
2960 ForwardInstructionIterator* current_iterator_; 2964 ForwardInstructionIterator* current_iterator_;
2961 2965
2962 private: 2966 private:
2963 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); 2967 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor);
2964 }; 2968 };
2965 2969
2966 2970
2967 } // namespace dart 2971 } // namespace dart
2968 2972
2969 #endif // VM_INTERMEDIATE_LANGUAGE_H_ 2973 #endif // VM_INTERMEDIATE_LANGUAGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698