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

Side by Side Diff: src/hydrogen-instructions.h

Issue 6964011: Refactor HCheckInstanceType to allow mask/tag tests. (Closed)
Patch Set: Rebased Created 9 years, 7 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 | « src/hydrogen.cc ('k') | src/hydrogen-instructions.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 1739 matching lines...) Expand 10 before | Expand all | Expand 10 after
1750 return target_.is_identical_to(b->target()); 1750 return target_.is_identical_to(b->target());
1751 } 1751 }
1752 1752
1753 private: 1753 private:
1754 Handle<JSFunction> target_; 1754 Handle<JSFunction> target_;
1755 }; 1755 };
1756 1756
1757 1757
1758 class HCheckInstanceType: public HUnaryOperation { 1758 class HCheckInstanceType: public HUnaryOperation {
1759 public: 1759 public:
1760 // Check that the instance type is in the range [first, last] where 1760 static HCheckInstanceType* NewIsJSObjectOrJSFunction(HValue* value) {
1761 // both first and last are included. 1761 return new HCheckInstanceType(value, IS_JS_OBJECT_OR_JS_FUNCTION);
1762 HCheckInstanceType(HValue* value, InstanceType first, InstanceType last) 1762 }
1763 : HUnaryOperation(value), first_(first), last_(last) { 1763 static HCheckInstanceType* NewIsJSArray(HValue* value) {
1764 ASSERT(first <= last); 1764 return new HCheckInstanceType(value, IS_JS_ARRAY);
1765 set_representation(Representation::Tagged()); 1765 }
1766 SetFlag(kUseGVN); 1766 static HCheckInstanceType* NewIsString(HValue* value) {
1767 if ((FIRST_STRING_TYPE < first && last <= LAST_STRING_TYPE) || 1767 return new HCheckInstanceType(value, IS_STRING);
1768 (FIRST_STRING_TYPE <= first && last < LAST_STRING_TYPE)) { 1768 }
1769 // A particular string instance type can change because of GC or 1769 static HCheckInstanceType* NewIsSymbol(HValue* value) {
1770 // externalization, but the value still remains a string. 1770 return new HCheckInstanceType(value, IS_SYMBOL);
1771 SetFlag(kDependsOnMaps);
1772 }
1773 } 1771 }
1774 1772
1775 virtual bool IsCheckInstruction() const { return true; } 1773 virtual bool IsCheckInstruction() const { return true; }
1776 1774
1777 virtual Representation RequiredInputRepresentation(int index) const { 1775 virtual Representation RequiredInputRepresentation(int index) const {
1778 return Representation::Tagged(); 1776 return Representation::Tagged();
1779 } 1777 }
1780 1778
1781 #ifdef DEBUG 1779 #ifdef DEBUG
1782 virtual void Verify(); 1780 virtual void Verify();
1783 #endif 1781 #endif
1784 1782
1785 virtual HValue* Canonicalize() { 1783 virtual HValue* Canonicalize() {
1786 if (!value()->type().IsUninitialized() && 1784 if (!value()->type().IsUninitialized() &&
1787 value()->type().IsString() && 1785 value()->type().IsString() &&
1788 first() == FIRST_STRING_TYPE && 1786 check_ == IS_STRING) {
1789 last() == LAST_STRING_TYPE) {
1790 return NULL; 1787 return NULL;
1791 } 1788 }
1792 return this; 1789 return this;
1793 } 1790 }
1794 1791
1795 static HCheckInstanceType* NewIsJSObjectOrJSFunction(HValue* value); 1792 bool is_interval_check() const { return check_ <= LAST_INTERVAL_CHECK; }
1796 1793 void GetCheckInterval(InstanceType* first, InstanceType* last);
1797 InstanceType first() const { return first_; } 1794 void GetCheckMaskAndTag(uint8_t* mask, uint8_t* tag);
1798 InstanceType last() const { return last_; }
1799 1795
1800 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType) 1796 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType)
1801 1797
1802 protected: 1798 protected:
1803 // TODO(ager): It could be nice to allow the ommision of instance 1799 // TODO(ager): It could be nice to allow the ommision of instance
1804 // type checks if we have already performed an instance type check 1800 // type checks if we have already performed an instance type check
1805 // with a larger range. 1801 // with a larger range.
1806 virtual bool DataEquals(HValue* other) { 1802 virtual bool DataEquals(HValue* other) {
1807 HCheckInstanceType* b = HCheckInstanceType::cast(other); 1803 HCheckInstanceType* b = HCheckInstanceType::cast(other);
1808 return (first_ == b->first()) && (last_ == b->last()); 1804 return check_ == b->check_;
1809 } 1805 }
1810 1806
1811 private: 1807 private:
1812 InstanceType first_; 1808 enum Check {
1813 InstanceType last_; 1809 IS_JS_OBJECT_OR_JS_FUNCTION,
1810 IS_JS_ARRAY,
1811 IS_STRING,
1812 IS_SYMBOL,
1813 LAST_INTERVAL_CHECK = IS_JS_ARRAY
1814 };
1815
1816 HCheckInstanceType(HValue* value, Check check)
1817 : HUnaryOperation(value), check_(check) {
1818 set_representation(Representation::Tagged());
1819 SetFlag(kUseGVN);
1820 }
1821
1822 const Check check_;
1814 }; 1823 };
1815 1824
1816 1825
1817 class HCheckNonSmi: public HUnaryOperation { 1826 class HCheckNonSmi: public HUnaryOperation {
1818 public: 1827 public:
1819 explicit HCheckNonSmi(HValue* value) : HUnaryOperation(value) { 1828 explicit HCheckNonSmi(HValue* value) : HUnaryOperation(value) {
1820 set_representation(Representation::Tagged()); 1829 set_representation(Representation::Tagged());
1821 SetFlag(kUseGVN); 1830 SetFlag(kUseGVN);
1822 } 1831 }
1823 1832
(...skipping 2006 matching lines...) Expand 10 before | Expand all | Expand 10 after
3830 3839
3831 DECLARE_CONCRETE_INSTRUCTION(In) 3840 DECLARE_CONCRETE_INSTRUCTION(In)
3832 }; 3841 };
3833 3842
3834 #undef DECLARE_INSTRUCTION 3843 #undef DECLARE_INSTRUCTION
3835 #undef DECLARE_CONCRETE_INSTRUCTION 3844 #undef DECLARE_CONCRETE_INSTRUCTION
3836 3845
3837 } } // namespace v8::internal 3846 } } // namespace v8::internal
3838 3847
3839 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ 3848 #endif // V8_HYDROGEN_INSTRUCTIONS_H_
OLDNEW
« no previous file with comments | « src/hydrogen.cc ('k') | src/hydrogen-instructions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698