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

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

Issue 6964011: Refactor HCheckInstanceType to allow mask/tag tests. (Closed)
Patch Set: 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 static HCheckInstanceType* NewIsJSArray(HValue* value) {
1762 HCheckInstanceType(HValue* value, InstanceType first, InstanceType last) 1762 return new HCheckInstanceType(value, JS_ARRAY_TYPE, JS_ARRAY_TYPE, 0, 0);
1763 : HUnaryOperation(value), first_(first), last_(last) { 1763 }
1764 ASSERT(first <= last); 1764 static HCheckInstanceType* NewIsString(HValue* value) {
1765 set_representation(Representation::Tagged()); 1765 return new HCheckInstanceType(value,
1766 SetFlag(kUseGVN); 1766 FIRST_TYPE, FIRST_TYPE,
1767 if ((FIRST_STRING_TYPE < first && last <= LAST_STRING_TYPE) || 1767 kIsNotStringMask, kStringTag);
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,
1771 SetFlag(kDependsOnMaps); 1771 FIRST_TYPE, FIRST_TYPE,
1772 } 1772 kIsSymbolMask, kSymbolTag);
1773 } 1773 }
1774 1774
1775 virtual bool IsCheckInstruction() const { return true; } 1775 virtual bool IsCheckInstruction() const { return true; }
1776 1776
1777 virtual Representation RequiredInputRepresentation(int index) const { 1777 virtual Representation RequiredInputRepresentation(int index) const {
1778 return Representation::Tagged(); 1778 return Representation::Tagged();
1779 } 1779 }
1780 1780
1781 #ifdef DEBUG 1781 #ifdef DEBUG
1782 virtual void Verify(); 1782 virtual void Verify();
1783 #endif 1783 #endif
1784 1784
1785 virtual HValue* Canonicalize() { 1785 virtual HValue* Canonicalize() {
1786 if (!value()->type().IsUninitialized() && 1786 if (!value()->type().IsUninitialized() &&
1787 value()->type().IsString() && 1787 value()->type().IsString() &&
1788 first() == FIRST_STRING_TYPE && 1788 !is_range() &&
1789 last() == LAST_STRING_TYPE) { 1789 mask() == kIsNotStringMask &&
1790 tag() == kStringTag) {
1790 return NULL; 1791 return NULL;
1791 } 1792 }
1792 return this; 1793 return this;
1793 } 1794 }
1794 1795
1795 static HCheckInstanceType* NewIsJSObjectOrJSFunction(HValue* value); 1796 bool is_range() const { return mask_ == 0; }
1796 1797
1797 InstanceType first() const { return first_; } 1798 InstanceType first() const {
1798 InstanceType last() const { return last_; } 1799 ASSERT(is_range());
1800 return first_;
1801 }
1802
1803 InstanceType last() {
1804 ASSERT(is_range());
1805 return last_;
1806 }
1807
1808 uint8_t mask() const {
1809 ASSERT(!is_range());
1810 return mask_;
1811 }
1812
1813 uint8_t tag() const {
1814 ASSERT(!is_range());
1815 return tag_;
1816 }
1799 1817
1800 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType) 1818 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType)
1801 1819
1802 protected: 1820 protected:
1803 // TODO(ager): It could be nice to allow the ommision of instance 1821 // TODO(ager): It could be nice to allow the ommision of instance
1804 // type checks if we have already performed an instance type check 1822 // type checks if we have already performed an instance type check
1805 // with a larger range. 1823 // with a larger range.
1806 virtual bool DataEquals(HValue* other) { 1824 virtual bool DataEquals(HValue* other) {
1807 HCheckInstanceType* b = HCheckInstanceType::cast(other); 1825 HCheckInstanceType* b = HCheckInstanceType::cast(other);
1808 return (first_ == b->first()) && (last_ == b->last()); 1826 return first_ == b->first_ && last_ == b->last_ &&
1827 mask_ == b->mask_ && tag_ == b->tag_;
1809 } 1828 }
1810 1829
1811 private: 1830 private:
1831 // Check that the instance type is in the range [first, last] where
Mads Ager (chromium) 2011/05/09 16:57:51 Comment needs updating.
1832 // both first and last are included.
1833 HCheckInstanceType(HValue* value,
1834 InstanceType first, InstanceType last,
1835 uint8_t mask, uint8_t tag)
1836 : HUnaryOperation(value),
1837 first_(first), last_(last),
1838 mask_(mask), tag_(tag) {
1839 ASSERT(first <= last);
1840 set_representation(Representation::Tagged());
1841 SetFlag(kUseGVN);
1842 if (is_range() && first_ < FIRST_NONSTRING_TYPE) {
1843 // A particular string instance type can change because of GC or
1844 // externalization, but the value still remains a string.
1845 SetFlag(kDependsOnMaps);
1846 }
1847 }
1848
1812 InstanceType first_; 1849 InstanceType first_;
1813 InstanceType last_; 1850 InstanceType last_;
1851 uint8_t mask_;
Mads Ager (chromium) 2011/05/09 16:57:51 I don't like this much. Create two types of instru
1852 uint8_t tag_;
1814 }; 1853 };
1815 1854
1816 1855
1817 class HCheckNonSmi: public HUnaryOperation { 1856 class HCheckNonSmi: public HUnaryOperation {
1818 public: 1857 public:
1819 explicit HCheckNonSmi(HValue* value) : HUnaryOperation(value) { 1858 explicit HCheckNonSmi(HValue* value) : HUnaryOperation(value) {
1820 set_representation(Representation::Tagged()); 1859 set_representation(Representation::Tagged());
1821 SetFlag(kUseGVN); 1860 SetFlag(kUseGVN);
1822 } 1861 }
1823 1862
(...skipping 2004 matching lines...) Expand 10 before | Expand all | Expand 10 after
3828 3867
3829 DECLARE_CONCRETE_INSTRUCTION(In) 3868 DECLARE_CONCRETE_INSTRUCTION(In)
3830 }; 3869 };
3831 3870
3832 #undef DECLARE_INSTRUCTION 3871 #undef DECLARE_INSTRUCTION
3833 #undef DECLARE_CONCRETE_INSTRUCTION 3872 #undef DECLARE_CONCRETE_INSTRUCTION
3834 3873
3835 } } // namespace v8::internal 3874 } } // namespace v8::internal
3836 3875
3837 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ 3876 #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