OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_AST_H_ | 5 #ifndef V8_AST_H_ |
6 #define V8_AST_H_ | 6 #define V8_AST_H_ |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/assembler.h" | 10 #include "src/assembler.h" |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 bool IsNullLiteral() const; | 352 bool IsNullLiteral() const; |
353 | 353 |
354 // True if we can prove that the expression is the undefined literal. | 354 // True if we can prove that the expression is the undefined literal. |
355 bool IsUndefinedLiteral(Isolate* isolate) const; | 355 bool IsUndefinedLiteral(Isolate* isolate) const; |
356 | 356 |
357 // Expression type bounds | 357 // Expression type bounds |
358 Bounds bounds() const { return bounds_; } | 358 Bounds bounds() const { return bounds_; } |
359 void set_bounds(Bounds bounds) { bounds_ = bounds; } | 359 void set_bounds(Bounds bounds) { bounds_ = bounds; } |
360 | 360 |
361 // Whether the expression is parenthesized | 361 // Whether the expression is parenthesized |
362 bool is_parenthesized() const { return is_parenthesized_; } | 362 bool is_parenthesized() const { |
363 bool is_multi_parenthesized() const { return is_multi_parenthesized_; } | 363 return IsParenthesizedField::decode(bit_field_); |
| 364 } |
| 365 bool is_multi_parenthesized() const { |
| 366 return IsMultiParenthesizedField::decode(bit_field_); |
| 367 } |
364 void increase_parenthesization_level() { | 368 void increase_parenthesization_level() { |
365 is_multi_parenthesized_ = is_parenthesized_; | 369 bit_field_ = |
366 is_parenthesized_ = true; | 370 IsMultiParenthesizedField::update(bit_field_, is_parenthesized()); |
| 371 bit_field_ = IsParenthesizedField::update(bit_field_, true); |
367 } | 372 } |
368 | 373 |
369 // Type feedback information for assignments and properties. | 374 // Type feedback information for assignments and properties. |
370 virtual bool IsMonomorphic() { | 375 virtual bool IsMonomorphic() { |
371 UNREACHABLE(); | 376 UNREACHABLE(); |
372 return false; | 377 return false; |
373 } | 378 } |
374 virtual SmallMapList* GetReceiverTypes() { | 379 virtual SmallMapList* GetReceiverTypes() { |
375 UNREACHABLE(); | 380 UNREACHABLE(); |
376 return NULL; | 381 return NULL; |
377 } | 382 } |
378 virtual KeyedAccessStoreMode GetStoreMode() { | 383 virtual KeyedAccessStoreMode GetStoreMode() const { |
379 UNREACHABLE(); | 384 UNREACHABLE(); |
380 return STANDARD_STORE; | 385 return STANDARD_STORE; |
381 } | 386 } |
382 virtual IcCheckType GetKeyType() { | 387 virtual IcCheckType GetKeyType() const { |
383 UNREACHABLE(); | 388 UNREACHABLE(); |
384 return ELEMENT; | 389 return ELEMENT; |
385 } | 390 } |
386 | 391 |
387 // TODO(rossberg): this should move to its own AST node eventually. | 392 // TODO(rossberg): this should move to its own AST node eventually. |
388 virtual void RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle); | 393 virtual void RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle); |
389 byte to_boolean_types() const { return to_boolean_types_; } | 394 byte to_boolean_types() const { |
| 395 return ToBooleanTypesField::decode(bit_field_); |
| 396 } |
390 | 397 |
391 void set_base_id(int id) { base_id_ = id; } | 398 void set_base_id(int id) { base_id_ = id; } |
392 static int num_ids() { return parent_num_ids() + 2; } | 399 static int num_ids() { return parent_num_ids() + 2; } |
393 BailoutId id() const { return BailoutId(local_id(0)); } | 400 BailoutId id() const { return BailoutId(local_id(0)); } |
394 TypeFeedbackId test_id() const { return TypeFeedbackId(local_id(1)); } | 401 TypeFeedbackId test_id() const { return TypeFeedbackId(local_id(1)); } |
395 | 402 |
396 protected: | 403 protected: |
397 Expression(Zone* zone, int pos) | 404 Expression(Zone* zone, int pos) |
398 : AstNode(pos), | 405 : AstNode(pos), |
399 base_id_(BailoutId::None().ToInt()), | 406 base_id_(BailoutId::None().ToInt()), |
400 bounds_(Bounds::Unbounded(zone)), | 407 bounds_(Bounds::Unbounded(zone)), |
401 is_parenthesized_(false), | 408 bit_field_(0) {} |
402 is_multi_parenthesized_(false) {} | |
403 static int parent_num_ids() { return 0; } | 409 static int parent_num_ids() { return 0; } |
404 void set_to_boolean_types(byte types) { to_boolean_types_ = types; } | 410 void set_to_boolean_types(byte types) { |
| 411 bit_field_ = ToBooleanTypesField::update(bit_field_, types); |
| 412 } |
405 | 413 |
406 int base_id() const { | 414 int base_id() const { |
407 DCHECK(!BailoutId(base_id_).IsNone()); | 415 DCHECK(!BailoutId(base_id_).IsNone()); |
408 return base_id_; | 416 return base_id_; |
409 } | 417 } |
410 | 418 |
411 private: | 419 private: |
412 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 420 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
413 | 421 |
414 int base_id_; | 422 int base_id_; |
415 Bounds bounds_; | 423 Bounds bounds_; |
416 byte to_boolean_types_; | 424 class ToBooleanTypesField : public BitField16<byte, 0, 8> {}; |
417 bool is_parenthesized_ : 1; | 425 class IsParenthesizedField : public BitField16<bool, 8, 1> {}; |
418 bool is_multi_parenthesized_ : 1; | 426 class IsMultiParenthesizedField : public BitField16<bool, 9, 1> {}; |
| 427 uint16_t bit_field_; |
| 428 // Ends with 16-bit field; deriving classes in turn begin with |
| 429 // 16-bit fields for optimum packing efficiency. |
419 }; | 430 }; |
420 | 431 |
421 | 432 |
422 class BreakableStatement : public Statement { | 433 class BreakableStatement : public Statement { |
423 public: | 434 public: |
424 enum BreakableType { | 435 enum BreakableType { |
425 TARGET_FOR_ANONYMOUS, | 436 TARGET_FOR_ANONYMOUS, |
426 TARGET_FOR_NAMED_ONLY | 437 TARGET_FOR_NAMED_ONLY |
427 }; | 438 }; |
428 | 439 |
(...skipping 1261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1690 Variable* var() const { | 1701 Variable* var() const { |
1691 DCHECK(is_resolved()); | 1702 DCHECK(is_resolved()); |
1692 return var_; | 1703 return var_; |
1693 } | 1704 } |
1694 void set_var(Variable* v) { | 1705 void set_var(Variable* v) { |
1695 DCHECK(!is_resolved()); | 1706 DCHECK(!is_resolved()); |
1696 DCHECK_NOT_NULL(v); | 1707 DCHECK_NOT_NULL(v); |
1697 var_ = v; | 1708 var_ = v; |
1698 } | 1709 } |
1699 | 1710 |
1700 bool is_this() const { return is_this_; } | 1711 bool is_this() const { return IsThisField::decode(bit_field_); } |
1701 | 1712 |
1702 bool is_assigned() const { return is_assigned_; } | 1713 bool is_assigned() const { return IsAssignedField::decode(bit_field_); } |
1703 void set_is_assigned() { is_assigned_ = true; } | 1714 void set_is_assigned() { |
| 1715 bit_field_ = IsAssignedField::update(bit_field_, true); |
| 1716 } |
1704 | 1717 |
1705 bool is_resolved() const { return is_resolved_; } | 1718 bool is_resolved() const { return IsResolvedField::decode(bit_field_); } |
1706 void set_is_resolved() { is_resolved_ = true; } | 1719 void set_is_resolved() { |
| 1720 bit_field_ = IsResolvedField::update(bit_field_, true); |
| 1721 } |
1707 | 1722 |
1708 Interface* interface() const { return interface_; } | 1723 Interface* interface() const { return interface_; } |
1709 | 1724 |
1710 // Bind this proxy to the variable var. Interfaces must match. | 1725 // Bind this proxy to the variable var. Interfaces must match. |
1711 void BindTo(Variable* var); | 1726 void BindTo(Variable* var); |
1712 | 1727 |
1713 virtual FeedbackVectorRequirements ComputeFeedbackRequirements() OVERRIDE { | 1728 virtual FeedbackVectorRequirements ComputeFeedbackRequirements() OVERRIDE { |
1714 return FeedbackVectorRequirements(0, FLAG_vector_ics ? 1 : 0); | 1729 return FeedbackVectorRequirements(0, FLAG_vector_ics ? 1 : 0); |
1715 } | 1730 } |
1716 virtual void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot) OVERRIDE { | 1731 virtual void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot) OVERRIDE { |
1717 variable_feedback_slot_ = slot; | 1732 variable_feedback_slot_ = slot; |
1718 } | 1733 } |
1719 | 1734 |
1720 FeedbackVectorICSlot VariableFeedbackSlot() { | 1735 FeedbackVectorICSlot VariableFeedbackSlot() { |
1721 return variable_feedback_slot_; | 1736 return variable_feedback_slot_; |
1722 } | 1737 } |
1723 | 1738 |
1724 protected: | 1739 protected: |
1725 VariableProxy(Zone* zone, Variable* var, int position); | 1740 VariableProxy(Zone* zone, Variable* var, int position); |
1726 | 1741 |
1727 VariableProxy(Zone* zone, const AstRawString* name, bool is_this, | 1742 VariableProxy(Zone* zone, const AstRawString* name, bool is_this, |
1728 Interface* interface, int position); | 1743 Interface* interface, int position); |
1729 | 1744 |
1730 bool is_this_ : 1; | 1745 class IsThisField : public BitField8<bool, 0, 1> {}; |
1731 bool is_assigned_ : 1; | 1746 class IsAssignedField : public BitField8<bool, 1, 1> {}; |
1732 bool is_resolved_ : 1; | 1747 class IsResolvedField : public BitField8<bool, 2, 1> {}; |
| 1748 |
| 1749 // Start with 16-bit (or smaller) field, which should get packed together |
| 1750 // with Expression's trailing 16-bit field. |
| 1751 uint8_t bit_field_; |
1733 FeedbackVectorICSlot variable_feedback_slot_; | 1752 FeedbackVectorICSlot variable_feedback_slot_; |
1734 union { | 1753 union { |
1735 const AstRawString* raw_name_; // if !is_resolved_ | 1754 const AstRawString* raw_name_; // if !is_resolved_ |
1736 Variable* var_; // if is_resolved_ | 1755 Variable* var_; // if is_resolved_ |
1737 }; | 1756 }; |
1738 Interface* interface_; | 1757 Interface* interface_; |
1739 }; | 1758 }; |
1740 | 1759 |
1741 | 1760 |
1742 class Property FINAL : public Expression { | 1761 class Property FINAL : public Expression { |
1743 public: | 1762 public: |
1744 DECLARE_NODE_TYPE(Property) | 1763 DECLARE_NODE_TYPE(Property) |
1745 | 1764 |
1746 virtual bool IsValidReferenceExpression() const OVERRIDE { return true; } | 1765 virtual bool IsValidReferenceExpression() const OVERRIDE { return true; } |
1747 | 1766 |
1748 Expression* obj() const { return obj_; } | 1767 Expression* obj() const { return obj_; } |
1749 Expression* key() const { return key_; } | 1768 Expression* key() const { return key_; } |
1750 | 1769 |
1751 static int num_ids() { return parent_num_ids() + 2; } | 1770 static int num_ids() { return parent_num_ids() + 2; } |
1752 BailoutId LoadId() const { return BailoutId(local_id(0)); } | 1771 BailoutId LoadId() const { return BailoutId(local_id(0)); } |
1753 TypeFeedbackId PropertyFeedbackId() { return TypeFeedbackId(local_id(1)); } | 1772 TypeFeedbackId PropertyFeedbackId() { return TypeFeedbackId(local_id(1)); } |
1754 | 1773 |
1755 bool IsStringAccess() const { return is_string_access_; } | 1774 bool IsStringAccess() const { |
| 1775 return IsStringAccessField::decode(bit_field_); |
| 1776 } |
1756 | 1777 |
1757 // Type feedback information. | 1778 // Type feedback information. |
1758 virtual bool IsMonomorphic() OVERRIDE { | 1779 virtual bool IsMonomorphic() OVERRIDE { |
1759 return receiver_types_.length() == 1; | 1780 return receiver_types_.length() == 1; |
1760 } | 1781 } |
1761 virtual SmallMapList* GetReceiverTypes() OVERRIDE { | 1782 virtual SmallMapList* GetReceiverTypes() OVERRIDE { |
1762 return &receiver_types_; | 1783 return &receiver_types_; |
1763 } | 1784 } |
1764 virtual KeyedAccessStoreMode GetStoreMode() OVERRIDE { | 1785 virtual KeyedAccessStoreMode GetStoreMode() const OVERRIDE { |
1765 return STANDARD_STORE; | 1786 return STANDARD_STORE; |
1766 } | 1787 } |
1767 virtual IcCheckType GetKeyType() OVERRIDE { | 1788 virtual IcCheckType GetKeyType() const OVERRIDE { |
1768 // PROPERTY key types currently aren't implemented for KeyedLoadICs. | 1789 // PROPERTY key types currently aren't implemented for KeyedLoadICs. |
1769 return ELEMENT; | 1790 return ELEMENT; |
1770 } | 1791 } |
1771 bool IsUninitialized() { return !is_for_call_ && is_uninitialized_; } | 1792 bool IsUninitialized() const { |
1772 bool HasNoTypeInformation() { | 1793 return !is_for_call() && HasNoTypeInformation(); |
1773 return is_uninitialized_; | |
1774 } | 1794 } |
1775 void set_is_uninitialized(bool b) { is_uninitialized_ = b; } | 1795 bool HasNoTypeInformation() const { |
1776 void set_is_string_access(bool b) { is_string_access_ = b; } | 1796 return IsUninitializedField::decode(bit_field_); |
1777 void mark_for_call() { is_for_call_ = true; } | 1797 } |
1778 bool IsForCall() { return is_for_call_; } | 1798 void set_is_uninitialized(bool b) { |
| 1799 bit_field_ = IsUninitializedField::update(bit_field_, b); |
| 1800 } |
| 1801 void set_is_string_access(bool b) { |
| 1802 bit_field_ = IsStringAccessField::update(bit_field_, b); |
| 1803 } |
| 1804 void mark_for_call() { |
| 1805 bit_field_ = IsForCallField::update(bit_field_, true); |
| 1806 } |
| 1807 bool is_for_call() const { return IsForCallField::decode(bit_field_); } |
1779 | 1808 |
1780 bool IsSuperAccess() { | 1809 bool IsSuperAccess() { |
1781 return obj()->IsSuperReference(); | 1810 return obj()->IsSuperReference(); |
1782 } | 1811 } |
1783 | 1812 |
1784 virtual FeedbackVectorRequirements ComputeFeedbackRequirements() OVERRIDE { | 1813 virtual FeedbackVectorRequirements ComputeFeedbackRequirements() OVERRIDE { |
1785 return FeedbackVectorRequirements(0, FLAG_vector_ics ? 1 : 0); | 1814 return FeedbackVectorRequirements(0, FLAG_vector_ics ? 1 : 0); |
1786 } | 1815 } |
1787 virtual void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot) OVERRIDE { | 1816 virtual void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot) OVERRIDE { |
1788 property_feedback_slot_ = slot; | 1817 property_feedback_slot_ = slot; |
1789 } | 1818 } |
1790 | 1819 |
1791 FeedbackVectorICSlot PropertyFeedbackSlot() const { | 1820 FeedbackVectorICSlot PropertyFeedbackSlot() const { |
1792 return property_feedback_slot_; | 1821 return property_feedback_slot_; |
1793 } | 1822 } |
1794 | 1823 |
1795 protected: | 1824 protected: |
1796 Property(Zone* zone, Expression* obj, Expression* key, int pos) | 1825 Property(Zone* zone, Expression* obj, Expression* key, int pos) |
1797 : Expression(zone, pos), | 1826 : Expression(zone, pos), |
1798 is_for_call_(false), | 1827 bit_field_(IsForCallField::encode(false) | |
1799 is_uninitialized_(false), | 1828 IsUninitializedField::encode(false) | |
1800 is_string_access_(false), | 1829 IsStringAccessField::encode(false)), |
1801 property_feedback_slot_(FeedbackVectorICSlot::Invalid()), | 1830 property_feedback_slot_(FeedbackVectorICSlot::Invalid()), |
1802 obj_(obj), | 1831 obj_(obj), |
1803 key_(key) {} | 1832 key_(key) {} |
1804 static int parent_num_ids() { return Expression::num_ids(); } | 1833 static int parent_num_ids() { return Expression::num_ids(); } |
1805 | 1834 |
1806 private: | 1835 private: |
1807 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 1836 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
1808 | 1837 |
1809 bool is_for_call_ : 1; | 1838 class IsForCallField : public BitField8<bool, 0, 1> {}; |
1810 bool is_uninitialized_ : 1; | 1839 class IsUninitializedField : public BitField8<bool, 1, 1> {}; |
1811 bool is_string_access_ : 1; | 1840 class IsStringAccessField : public BitField8<bool, 2, 1> {}; |
| 1841 uint8_t bit_field_; |
1812 FeedbackVectorICSlot property_feedback_slot_; | 1842 FeedbackVectorICSlot property_feedback_slot_; |
1813 Expression* obj_; | 1843 Expression* obj_; |
1814 Expression* key_; | 1844 Expression* key_; |
1815 SmallMapList receiver_types_; | 1845 SmallMapList receiver_types_; |
1816 }; | 1846 }; |
1817 | 1847 |
1818 | 1848 |
1819 class Call FINAL : public Expression { | 1849 class Call FINAL : public Expression { |
1820 public: | 1850 public: |
1821 DECLARE_NODE_TYPE(Call) | 1851 DECLARE_NODE_TYPE(Call) |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2113 Expression* left_; | 2143 Expression* left_; |
2114 Expression* right_; | 2144 Expression* right_; |
2115 Handle<AllocationSite> allocation_site_; | 2145 Handle<AllocationSite> allocation_site_; |
2116 }; | 2146 }; |
2117 | 2147 |
2118 | 2148 |
2119 class CountOperation FINAL : public Expression { | 2149 class CountOperation FINAL : public Expression { |
2120 public: | 2150 public: |
2121 DECLARE_NODE_TYPE(CountOperation) | 2151 DECLARE_NODE_TYPE(CountOperation) |
2122 | 2152 |
2123 bool is_prefix() const { return is_prefix_; } | 2153 bool is_prefix() const { return IsPrefixField::decode(bit_field_); } |
2124 bool is_postfix() const { return !is_prefix_; } | 2154 bool is_postfix() const { return !is_prefix(); } |
2125 | 2155 |
2126 Token::Value op() const { return op_; } | 2156 Token::Value op() const { return TokenField::decode(bit_field_); } |
2127 Token::Value binary_op() { | 2157 Token::Value binary_op() { |
2128 return (op() == Token::INC) ? Token::ADD : Token::SUB; | 2158 return (op() == Token::INC) ? Token::ADD : Token::SUB; |
2129 } | 2159 } |
2130 | 2160 |
2131 Expression* expression() const { return expression_; } | 2161 Expression* expression() const { return expression_; } |
2132 | 2162 |
2133 virtual bool IsMonomorphic() OVERRIDE { | 2163 virtual bool IsMonomorphic() OVERRIDE { |
2134 return receiver_types_.length() == 1; | 2164 return receiver_types_.length() == 1; |
2135 } | 2165 } |
2136 virtual SmallMapList* GetReceiverTypes() OVERRIDE { | 2166 virtual SmallMapList* GetReceiverTypes() OVERRIDE { |
2137 return &receiver_types_; | 2167 return &receiver_types_; |
2138 } | 2168 } |
2139 virtual IcCheckType GetKeyType() OVERRIDE { return key_type_; } | 2169 virtual IcCheckType GetKeyType() const OVERRIDE { |
2140 virtual KeyedAccessStoreMode GetStoreMode() OVERRIDE { | 2170 return KeyTypeField::decode(bit_field_); |
2141 return store_mode_; | 2171 } |
| 2172 virtual KeyedAccessStoreMode GetStoreMode() const OVERRIDE { |
| 2173 return StoreModeField::decode(bit_field_); |
2142 } | 2174 } |
2143 Type* type() const { return type_; } | 2175 Type* type() const { return type_; } |
2144 void set_key_type(IcCheckType type) { key_type_ = type; } | 2176 void set_key_type(IcCheckType type) { |
2145 void set_store_mode(KeyedAccessStoreMode mode) { store_mode_ = mode; } | 2177 bit_field_ = KeyTypeField::update(bit_field_, type); |
| 2178 } |
| 2179 void set_store_mode(KeyedAccessStoreMode mode) { |
| 2180 bit_field_ = StoreModeField::update(bit_field_, mode); |
| 2181 } |
2146 void set_type(Type* type) { type_ = type; } | 2182 void set_type(Type* type) { type_ = type; } |
2147 | 2183 |
2148 static int num_ids() { return parent_num_ids() + 3; } | 2184 static int num_ids() { return parent_num_ids() + 3; } |
2149 BailoutId AssignmentId() const { return BailoutId(local_id(0)); } | 2185 BailoutId AssignmentId() const { return BailoutId(local_id(0)); } |
2150 TypeFeedbackId CountBinOpFeedbackId() const { | 2186 TypeFeedbackId CountBinOpFeedbackId() const { |
2151 return TypeFeedbackId(local_id(1)); | 2187 return TypeFeedbackId(local_id(1)); |
2152 } | 2188 } |
2153 TypeFeedbackId CountStoreFeedbackId() const { | 2189 TypeFeedbackId CountStoreFeedbackId() const { |
2154 return TypeFeedbackId(local_id(2)); | 2190 return TypeFeedbackId(local_id(2)); |
2155 } | 2191 } |
2156 | 2192 |
2157 protected: | 2193 protected: |
2158 CountOperation(Zone* zone, Token::Value op, bool is_prefix, Expression* expr, | 2194 CountOperation(Zone* zone, Token::Value op, bool is_prefix, Expression* expr, |
2159 int pos) | 2195 int pos) |
2160 : Expression(zone, pos), | 2196 : Expression(zone, pos), |
2161 op_(op), | 2197 bit_field_(IsPrefixField::encode(is_prefix) | |
2162 is_prefix_(is_prefix), | 2198 KeyTypeField::encode(ELEMENT) | |
2163 key_type_(ELEMENT), | 2199 StoreModeField::encode(STANDARD_STORE) | |
2164 store_mode_(STANDARD_STORE), | 2200 TokenField::encode(op)), |
| 2201 type_(NULL), |
2165 expression_(expr) {} | 2202 expression_(expr) {} |
2166 static int parent_num_ids() { return Expression::num_ids(); } | 2203 static int parent_num_ids() { return Expression::num_ids(); } |
2167 | 2204 |
2168 private: | 2205 private: |
2169 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 2206 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
2170 | 2207 |
2171 Token::Value op_; | 2208 class IsPrefixField : public BitField16<bool, 0, 1> {}; |
2172 bool is_prefix_ : 1; | 2209 class KeyTypeField : public BitField16<IcCheckType, 1, 1> {}; |
2173 IcCheckType key_type_ : 1; | 2210 class StoreModeField : public BitField16<KeyedAccessStoreMode, 2, 4> {}; |
2174 KeyedAccessStoreMode store_mode_ : 5; // Windows treats as signed, | 2211 class TokenField : public BitField16<Token::Value, 6, 8> {}; |
2175 // must have extra bit. | 2212 |
| 2213 // Starts with 16-bit field, which should get packed together with |
| 2214 // Expression's trailing 16-bit field. |
| 2215 uint16_t bit_field_; |
2176 Type* type_; | 2216 Type* type_; |
2177 Expression* expression_; | 2217 Expression* expression_; |
2178 SmallMapList receiver_types_; | 2218 SmallMapList receiver_types_; |
2179 }; | 2219 }; |
2180 | 2220 |
2181 | 2221 |
2182 class CompareOperation FINAL : public Expression { | 2222 class CompareOperation FINAL : public Expression { |
2183 public: | 2223 public: |
2184 DECLARE_NODE_TYPE(CompareOperation) | 2224 DECLARE_NODE_TYPE(CompareOperation) |
2185 | 2225 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2254 | 2294 |
2255 | 2295 |
2256 class Assignment FINAL : public Expression { | 2296 class Assignment FINAL : public Expression { |
2257 public: | 2297 public: |
2258 DECLARE_NODE_TYPE(Assignment) | 2298 DECLARE_NODE_TYPE(Assignment) |
2259 | 2299 |
2260 Assignment* AsSimpleAssignment() { return !is_compound() ? this : NULL; } | 2300 Assignment* AsSimpleAssignment() { return !is_compound() ? this : NULL; } |
2261 | 2301 |
2262 Token::Value binary_op() const; | 2302 Token::Value binary_op() const; |
2263 | 2303 |
2264 Token::Value op() const { return op_; } | 2304 Token::Value op() const { return TokenField::decode(bit_field_); } |
2265 Expression* target() const { return target_; } | 2305 Expression* target() const { return target_; } |
2266 Expression* value() const { return value_; } | 2306 Expression* value() const { return value_; } |
2267 BinaryOperation* binary_operation() const { return binary_operation_; } | 2307 BinaryOperation* binary_operation() const { return binary_operation_; } |
2268 | 2308 |
2269 // This check relies on the definition order of token in token.h. | 2309 // This check relies on the definition order of token in token.h. |
2270 bool is_compound() const { return op() > Token::ASSIGN; } | 2310 bool is_compound() const { return op() > Token::ASSIGN; } |
2271 | 2311 |
2272 static int num_ids() { return parent_num_ids() + 2; } | 2312 static int num_ids() { return parent_num_ids() + 2; } |
2273 BailoutId AssignmentId() const { return BailoutId(local_id(0)); } | 2313 BailoutId AssignmentId() const { return BailoutId(local_id(0)); } |
2274 | 2314 |
2275 // Type feedback information. | 2315 // Type feedback information. |
2276 TypeFeedbackId AssignmentFeedbackId() { return TypeFeedbackId(local_id(1)); } | 2316 TypeFeedbackId AssignmentFeedbackId() { return TypeFeedbackId(local_id(1)); } |
2277 virtual bool IsMonomorphic() OVERRIDE { | 2317 virtual bool IsMonomorphic() OVERRIDE { |
2278 return receiver_types_.length() == 1; | 2318 return receiver_types_.length() == 1; |
2279 } | 2319 } |
2280 bool IsUninitialized() { return is_uninitialized_; } | 2320 bool IsUninitialized() const { |
| 2321 return IsUninitializedField::decode(bit_field_); |
| 2322 } |
2281 bool HasNoTypeInformation() { | 2323 bool HasNoTypeInformation() { |
2282 return is_uninitialized_; | 2324 return IsUninitializedField::decode(bit_field_); |
2283 } | 2325 } |
2284 virtual SmallMapList* GetReceiverTypes() OVERRIDE { | 2326 virtual SmallMapList* GetReceiverTypes() OVERRIDE { |
2285 return &receiver_types_; | 2327 return &receiver_types_; |
2286 } | 2328 } |
2287 virtual IcCheckType GetKeyType() OVERRIDE { return key_type_; } | 2329 virtual IcCheckType GetKeyType() const OVERRIDE { |
2288 virtual KeyedAccessStoreMode GetStoreMode() OVERRIDE { | 2330 return KeyTypeField::decode(bit_field_); |
2289 return store_mode_; | |
2290 } | 2331 } |
2291 void set_is_uninitialized(bool b) { is_uninitialized_ = b; } | 2332 virtual KeyedAccessStoreMode GetStoreMode() const OVERRIDE { |
2292 void set_key_type(IcCheckType key_type) { key_type_ = key_type; } | 2333 return StoreModeField::decode(bit_field_); |
2293 void set_store_mode(KeyedAccessStoreMode mode) { store_mode_ = mode; } | 2334 } |
| 2335 void set_is_uninitialized(bool b) { |
| 2336 bit_field_ = IsUninitializedField::update(bit_field_, b); |
| 2337 } |
| 2338 void set_key_type(IcCheckType key_type) { |
| 2339 bit_field_ = KeyTypeField::update(bit_field_, key_type); |
| 2340 } |
| 2341 void set_store_mode(KeyedAccessStoreMode mode) { |
| 2342 bit_field_ = StoreModeField::update(bit_field_, mode); |
| 2343 } |
2294 | 2344 |
2295 protected: | 2345 protected: |
2296 Assignment(Zone* zone, Token::Value op, Expression* target, Expression* value, | 2346 Assignment(Zone* zone, Token::Value op, Expression* target, Expression* value, |
2297 int pos); | 2347 int pos); |
2298 static int parent_num_ids() { return Expression::num_ids(); } | 2348 static int parent_num_ids() { return Expression::num_ids(); } |
2299 | 2349 |
2300 template <class Visitor> | 2350 template <class Visitor> |
2301 void Init(AstNodeFactory<Visitor>* factory) { | 2351 void Init(AstNodeFactory<Visitor>* factory) { |
2302 DCHECK(Token::IsAssignmentOp(op_)); | 2352 DCHECK(Token::IsAssignmentOp(op())); |
2303 if (is_compound()) { | 2353 if (is_compound()) { |
2304 binary_operation_ = factory->NewBinaryOperation( | 2354 binary_operation_ = factory->NewBinaryOperation( |
2305 binary_op(), target_, value_, position() + 1); | 2355 binary_op(), target_, value_, position() + 1); |
2306 } | 2356 } |
2307 } | 2357 } |
2308 | 2358 |
2309 private: | 2359 private: |
2310 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 2360 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
2311 | 2361 |
2312 bool is_uninitialized_ : 1; | 2362 class IsUninitializedField : public BitField16<bool, 0, 1> {}; |
2313 IcCheckType key_type_ : 1; | 2363 class KeyTypeField : public BitField16<IcCheckType, 1, 1> {}; |
2314 KeyedAccessStoreMode store_mode_ : 5; // Windows treats as signed, | 2364 class StoreModeField : public BitField16<KeyedAccessStoreMode, 2, 4> {}; |
2315 // must have extra bit. | 2365 class TokenField : public BitField16<Token::Value, 6, 8> {}; |
2316 Token::Value op_; | 2366 |
| 2367 // Starts with 16-bit field, which should get packed together with |
| 2368 // Expression's trailing 16-bit field. |
| 2369 uint16_t bit_field_; |
2317 Expression* target_; | 2370 Expression* target_; |
2318 Expression* value_; | 2371 Expression* value_; |
2319 BinaryOperation* binary_operation_; | 2372 BinaryOperation* binary_operation_; |
2320 SmallMapList receiver_types_; | 2373 SmallMapList receiver_types_; |
2321 }; | 2374 }; |
2322 | 2375 |
2323 | 2376 |
2324 class Yield FINAL : public Expression { | 2377 class Yield FINAL : public Expression { |
2325 public: | 2378 public: |
2326 DECLARE_NODE_TYPE(Yield) | 2379 DECLARE_NODE_TYPE(Yield) |
(...skipping 1318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3645 private: | 3698 private: |
3646 Zone* zone_; | 3699 Zone* zone_; |
3647 Visitor visitor_; | 3700 Visitor visitor_; |
3648 AstValueFactory* ast_value_factory_; | 3701 AstValueFactory* ast_value_factory_; |
3649 }; | 3702 }; |
3650 | 3703 |
3651 | 3704 |
3652 } } // namespace v8::internal | 3705 } } // namespace v8::internal |
3653 | 3706 |
3654 #endif // V8_AST_H_ | 3707 #endif // V8_AST_H_ |
OLD | NEW |