| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 1677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1688 virtual bool IsMonomorphic() V8_OVERRIDE { | 1688 virtual bool IsMonomorphic() V8_OVERRIDE { |
| 1689 return receiver_types_.length() == 1; | 1689 return receiver_types_.length() == 1; |
| 1690 } | 1690 } |
| 1691 virtual SmallMapList* GetReceiverTypes() V8_OVERRIDE { | 1691 virtual SmallMapList* GetReceiverTypes() V8_OVERRIDE { |
| 1692 return &receiver_types_; | 1692 return &receiver_types_; |
| 1693 } | 1693 } |
| 1694 virtual KeyedAccessStoreMode GetStoreMode() V8_OVERRIDE { | 1694 virtual KeyedAccessStoreMode GetStoreMode() V8_OVERRIDE { |
| 1695 return STANDARD_STORE; | 1695 return STANDARD_STORE; |
| 1696 } | 1696 } |
| 1697 bool IsUninitialized() { return is_uninitialized_; } | 1697 bool IsUninitialized() { return is_uninitialized_; } |
| 1698 bool IsPreMonomorphic() { return is_pre_monomorphic_; } | |
| 1699 bool HasNoTypeInformation() { | 1698 bool HasNoTypeInformation() { |
| 1700 return is_uninitialized_ || is_pre_monomorphic_; | 1699 return is_uninitialized_; |
| 1701 } | 1700 } |
| 1702 void set_is_uninitialized(bool b) { is_uninitialized_ = b; } | 1701 void set_is_uninitialized(bool b) { is_uninitialized_ = b; } |
| 1703 void set_is_pre_monomorphic(bool b) { is_pre_monomorphic_ = b; } | |
| 1704 void set_is_string_access(bool b) { is_string_access_ = b; } | 1702 void set_is_string_access(bool b) { is_string_access_ = b; } |
| 1705 void set_is_function_prototype(bool b) { is_function_prototype_ = b; } | 1703 void set_is_function_prototype(bool b) { is_function_prototype_ = b; } |
| 1704 void mark_for_call() { is_for_call_ = true; } |
| 1705 bool IsForCall() { return is_for_call_; } |
| 1706 | 1706 |
| 1707 TypeFeedbackId PropertyFeedbackId() { return reuse(id()); } | 1707 TypeFeedbackId PropertyFeedbackId() { return reuse(id()); } |
| 1708 | 1708 |
| 1709 protected: | 1709 protected: |
| 1710 Property(Zone* zone, | 1710 Property(Zone* zone, |
| 1711 Expression* obj, | 1711 Expression* obj, |
| 1712 Expression* key, | 1712 Expression* key, |
| 1713 int pos) | 1713 int pos) |
| 1714 : Expression(zone, pos), | 1714 : Expression(zone, pos), |
| 1715 obj_(obj), | 1715 obj_(obj), |
| 1716 key_(key), | 1716 key_(key), |
| 1717 load_id_(GetNextId(zone)), | 1717 load_id_(GetNextId(zone)), |
| 1718 is_pre_monomorphic_(false), | 1718 is_for_call_(false), |
| 1719 is_uninitialized_(false), | 1719 is_uninitialized_(false), |
| 1720 is_string_access_(false), | 1720 is_string_access_(false), |
| 1721 is_function_prototype_(false) { } | 1721 is_function_prototype_(false) { } |
| 1722 | 1722 |
| 1723 private: | 1723 private: |
| 1724 Expression* obj_; | 1724 Expression* obj_; |
| 1725 Expression* key_; | 1725 Expression* key_; |
| 1726 const BailoutId load_id_; | 1726 const BailoutId load_id_; |
| 1727 | 1727 |
| 1728 SmallMapList receiver_types_; | 1728 SmallMapList receiver_types_; |
| 1729 bool is_pre_monomorphic_ : 1; | 1729 bool is_for_call_ : 1; |
| 1730 bool is_uninitialized_ : 1; | 1730 bool is_uninitialized_ : 1; |
| 1731 bool is_string_access_ : 1; | 1731 bool is_string_access_ : 1; |
| 1732 bool is_function_prototype_ : 1; | 1732 bool is_function_prototype_ : 1; |
| 1733 }; | 1733 }; |
| 1734 | 1734 |
| 1735 | 1735 |
| 1736 class Call V8_FINAL : public Expression { | 1736 class Call V8_FINAL : public Expression { |
| 1737 public: | 1737 public: |
| 1738 DECLARE_NODE_TYPE(Call) | 1738 DECLARE_NODE_TYPE(Call) |
| 1739 | 1739 |
| 1740 Expression* expression() const { return expression_; } | 1740 Expression* expression() const { return expression_; } |
| 1741 ZoneList<Expression*>* arguments() const { return arguments_; } | 1741 ZoneList<Expression*>* arguments() const { return arguments_; } |
| 1742 | 1742 |
| 1743 // Type feedback information. | 1743 // Type feedback information. |
| 1744 TypeFeedbackId CallFeedbackId() const { return reuse(id()); } | 1744 TypeFeedbackId CallFeedbackId() const { return reuse(id()); } |
| 1745 void RecordTypeFeedback(TypeFeedbackOracle* oracle); | 1745 |
| 1746 virtual SmallMapList* GetReceiverTypes() V8_OVERRIDE { | 1746 virtual SmallMapList* GetReceiverTypes() V8_OVERRIDE { |
| 1747 return &receiver_types_; | 1747 if (expression()->IsProperty()) { |
| 1748 } | 1748 return expression()->AsProperty()->GetReceiverTypes(); |
| 1749 virtual bool IsMonomorphic() V8_OVERRIDE { return is_monomorphic_; } | 1749 } |
| 1750 bool KeyedArrayCallIsHoley() { return keyed_array_call_is_holey_; } | 1750 return NULL; |
| 1751 CheckType check_type() const { return check_type_; } | |
| 1752 | |
| 1753 void set_string_check(Handle<JSObject> holder) { | |
| 1754 holder_ = holder; | |
| 1755 check_type_ = STRING_CHECK; | |
| 1756 } | 1751 } |
| 1757 | 1752 |
| 1758 void set_number_check(Handle<JSObject> holder) { | 1753 virtual bool IsMonomorphic() V8_OVERRIDE { |
| 1759 holder_ = holder; | 1754 if (expression()->IsProperty()) { |
| 1760 check_type_ = NUMBER_CHECK; | 1755 return expression()->AsProperty()->IsMonomorphic(); |
| 1761 } | 1756 } |
| 1762 | 1757 return !target_.is_null(); |
| 1763 void set_map_check() { | |
| 1764 holder_ = Handle<JSObject>::null(); | |
| 1765 check_type_ = RECEIVER_MAP_CHECK; | |
| 1766 } | 1758 } |
| 1767 | 1759 |
| 1768 Handle<JSFunction> target() { return target_; } | 1760 Handle<JSFunction> target() { return target_; } |
| 1769 | 1761 |
| 1770 // A cache for the holder, set as a side effect of computing the target of the | |
| 1771 // call. Note that it contains the null handle when the receiver is the same | |
| 1772 // as the holder! | |
| 1773 Handle<JSObject> holder() { return holder_; } | |
| 1774 | |
| 1775 Handle<Cell> cell() { return cell_; } | 1762 Handle<Cell> cell() { return cell_; } |
| 1776 | 1763 |
| 1777 bool ComputeTarget(Handle<Map> type, Handle<String> name); | 1764 void set_target(Handle<JSFunction> target) { target_ = target; } |
| 1778 bool ComputeGlobalTarget(Handle<GlobalObject> global, LookupResult* lookup); | 1765 bool ComputeGlobalTarget(Handle<GlobalObject> global, LookupResult* lookup); |
| 1779 | 1766 |
| 1780 BailoutId ReturnId() const { return return_id_; } | 1767 BailoutId ReturnId() const { return return_id_; } |
| 1781 | 1768 |
| 1782 enum CallType { | 1769 enum CallType { |
| 1783 POSSIBLY_EVAL_CALL, | 1770 POSSIBLY_EVAL_CALL, |
| 1784 GLOBAL_CALL, | 1771 GLOBAL_CALL, |
| 1785 LOOKUP_SLOT_CALL, | 1772 LOOKUP_SLOT_CALL, |
| 1786 PROPERTY_CALL, | 1773 PROPERTY_CALL, |
| 1787 OTHER_CALL | 1774 OTHER_CALL |
| 1788 }; | 1775 }; |
| 1789 | 1776 |
| 1790 // Helpers to determine how to handle the call. | 1777 // Helpers to determine how to handle the call. |
| 1791 CallType GetCallType(Isolate* isolate) const; | 1778 CallType GetCallType(Isolate* isolate) const; |
| 1792 | 1779 |
| 1793 // TODO(rossberg): this should really move somewhere else (and be merged with | |
| 1794 // various similar methods in objets.cc), but for now... | |
| 1795 static Handle<JSObject> GetPrototypeForPrimitiveCheck( | |
| 1796 CheckType check, Isolate* isolate); | |
| 1797 | |
| 1798 #ifdef DEBUG | 1780 #ifdef DEBUG |
| 1799 // Used to assert that the FullCodeGenerator records the return site. | 1781 // Used to assert that the FullCodeGenerator records the return site. |
| 1800 bool return_is_recorded_; | 1782 bool return_is_recorded_; |
| 1801 #endif | 1783 #endif |
| 1802 | 1784 |
| 1803 protected: | 1785 protected: |
| 1804 Call(Zone* zone, | 1786 Call(Zone* zone, |
| 1805 Expression* expression, | 1787 Expression* expression, |
| 1806 ZoneList<Expression*>* arguments, | 1788 ZoneList<Expression*>* arguments, |
| 1807 int pos) | 1789 int pos) |
| 1808 : Expression(zone, pos), | 1790 : Expression(zone, pos), |
| 1809 expression_(expression), | 1791 expression_(expression), |
| 1810 arguments_(arguments), | 1792 arguments_(arguments), |
| 1811 is_monomorphic_(false), | 1793 return_id_(GetNextId(zone)) { |
| 1812 keyed_array_call_is_holey_(true), | 1794 if (expression->IsProperty()) { |
| 1813 check_type_(RECEIVER_MAP_CHECK), | 1795 expression->AsProperty()->mark_for_call(); |
| 1814 return_id_(GetNextId(zone)) { } | 1796 } |
| 1797 } |
| 1815 | 1798 |
| 1816 private: | 1799 private: |
| 1817 Expression* expression_; | 1800 Expression* expression_; |
| 1818 ZoneList<Expression*>* arguments_; | 1801 ZoneList<Expression*>* arguments_; |
| 1819 | 1802 |
| 1820 bool is_monomorphic_; | |
| 1821 bool keyed_array_call_is_holey_; | |
| 1822 CheckType check_type_; | |
| 1823 SmallMapList receiver_types_; | |
| 1824 Handle<JSFunction> target_; | 1803 Handle<JSFunction> target_; |
| 1825 Handle<JSObject> holder_; | |
| 1826 Handle<Cell> cell_; | 1804 Handle<Cell> cell_; |
| 1827 | 1805 |
| 1828 const BailoutId return_id_; | 1806 const BailoutId return_id_; |
| 1829 }; | 1807 }; |
| 1830 | 1808 |
| 1831 | 1809 |
| 1832 class CallNew V8_FINAL : public Expression { | 1810 class CallNew V8_FINAL : public Expression { |
| 1833 public: | 1811 public: |
| 1834 DECLARE_NODE_TYPE(CallNew) | 1812 DECLARE_NODE_TYPE(CallNew) |
| 1835 | 1813 |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2147 bool is_compound() const { return op() > Token::ASSIGN; } | 2125 bool is_compound() const { return op() > Token::ASSIGN; } |
| 2148 | 2126 |
| 2149 BailoutId AssignmentId() const { return assignment_id_; } | 2127 BailoutId AssignmentId() const { return assignment_id_; } |
| 2150 | 2128 |
| 2151 // Type feedback information. | 2129 // Type feedback information. |
| 2152 TypeFeedbackId AssignmentFeedbackId() { return reuse(id()); } | 2130 TypeFeedbackId AssignmentFeedbackId() { return reuse(id()); } |
| 2153 virtual bool IsMonomorphic() V8_OVERRIDE { | 2131 virtual bool IsMonomorphic() V8_OVERRIDE { |
| 2154 return receiver_types_.length() == 1; | 2132 return receiver_types_.length() == 1; |
| 2155 } | 2133 } |
| 2156 bool IsUninitialized() { return is_uninitialized_; } | 2134 bool IsUninitialized() { return is_uninitialized_; } |
| 2157 bool IsPreMonomorphic() { return is_pre_monomorphic_; } | |
| 2158 bool HasNoTypeInformation() { | 2135 bool HasNoTypeInformation() { |
| 2159 return is_uninitialized_ || is_pre_monomorphic_; | 2136 return is_uninitialized_; |
| 2160 } | 2137 } |
| 2161 virtual SmallMapList* GetReceiverTypes() V8_OVERRIDE { | 2138 virtual SmallMapList* GetReceiverTypes() V8_OVERRIDE { |
| 2162 return &receiver_types_; | 2139 return &receiver_types_; |
| 2163 } | 2140 } |
| 2164 virtual KeyedAccessStoreMode GetStoreMode() V8_OVERRIDE { | 2141 virtual KeyedAccessStoreMode GetStoreMode() V8_OVERRIDE { |
| 2165 return store_mode_; | 2142 return store_mode_; |
| 2166 } | 2143 } |
| 2167 void set_is_uninitialized(bool b) { is_uninitialized_ = b; } | 2144 void set_is_uninitialized(bool b) { is_uninitialized_ = b; } |
| 2168 void set_is_pre_monomorphic(bool b) { is_pre_monomorphic_ = b; } | |
| 2169 void set_store_mode(KeyedAccessStoreMode mode) { store_mode_ = mode; } | 2145 void set_store_mode(KeyedAccessStoreMode mode) { store_mode_ = mode; } |
| 2170 | 2146 |
| 2171 protected: | 2147 protected: |
| 2172 Assignment(Zone* zone, | 2148 Assignment(Zone* zone, |
| 2173 Token::Value op, | 2149 Token::Value op, |
| 2174 Expression* target, | 2150 Expression* target, |
| 2175 Expression* value, | 2151 Expression* value, |
| 2176 int pos); | 2152 int pos); |
| 2177 | 2153 |
| 2178 template<class Visitor> | 2154 template<class Visitor> |
| 2179 void Init(Zone* zone, AstNodeFactory<Visitor>* factory) { | 2155 void Init(Zone* zone, AstNodeFactory<Visitor>* factory) { |
| 2180 ASSERT(Token::IsAssignmentOp(op_)); | 2156 ASSERT(Token::IsAssignmentOp(op_)); |
| 2181 if (is_compound()) { | 2157 if (is_compound()) { |
| 2182 binary_operation_ = factory->NewBinaryOperation( | 2158 binary_operation_ = factory->NewBinaryOperation( |
| 2183 binary_op(), target_, value_, position() + 1); | 2159 binary_op(), target_, value_, position() + 1); |
| 2184 } | 2160 } |
| 2185 } | 2161 } |
| 2186 | 2162 |
| 2187 private: | 2163 private: |
| 2188 Token::Value op_; | 2164 Token::Value op_; |
| 2189 Expression* target_; | 2165 Expression* target_; |
| 2190 Expression* value_; | 2166 Expression* value_; |
| 2191 BinaryOperation* binary_operation_; | 2167 BinaryOperation* binary_operation_; |
| 2192 const BailoutId assignment_id_; | 2168 const BailoutId assignment_id_; |
| 2193 | 2169 |
| 2194 bool is_uninitialized_ : 1; | 2170 bool is_uninitialized_ : 1; |
| 2195 bool is_pre_monomorphic_ : 1; | |
| 2196 KeyedAccessStoreMode store_mode_ : 5; // Windows treats as signed, | 2171 KeyedAccessStoreMode store_mode_ : 5; // Windows treats as signed, |
| 2197 // must have extra bit. | 2172 // must have extra bit. |
| 2198 SmallMapList receiver_types_; | 2173 SmallMapList receiver_types_; |
| 2199 }; | 2174 }; |
| 2200 | 2175 |
| 2201 | 2176 |
| 2202 class Yield V8_FINAL : public Expression { | 2177 class Yield V8_FINAL : public Expression { |
| 2203 public: | 2178 public: |
| 2204 DECLARE_NODE_TYPE(Yield) | 2179 DECLARE_NODE_TYPE(Yield) |
| 2205 | 2180 |
| (...skipping 1115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3321 | 3296 |
| 3322 private: | 3297 private: |
| 3323 Zone* zone_; | 3298 Zone* zone_; |
| 3324 Visitor visitor_; | 3299 Visitor visitor_; |
| 3325 }; | 3300 }; |
| 3326 | 3301 |
| 3327 | 3302 |
| 3328 } } // namespace v8::internal | 3303 } } // namespace v8::internal |
| 3329 | 3304 |
| 3330 #endif // V8_AST_H_ | 3305 #endif // V8_AST_H_ |
| OLD | NEW |