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 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 SmallMapList(int capacity, Zone* zone) : list_(capacity, zone) {} | 272 SmallMapList(int capacity, Zone* zone) : list_(capacity, zone) {} |
273 | 273 |
274 void Reserve(int capacity, Zone* zone) { list_.Reserve(capacity, zone); } | 274 void Reserve(int capacity, Zone* zone) { list_.Reserve(capacity, zone); } |
275 void Clear() { list_.Clear(); } | 275 void Clear() { list_.Clear(); } |
276 void Sort() { list_.Sort(); } | 276 void Sort() { list_.Sort(); } |
277 | 277 |
278 bool is_empty() const { return list_.is_empty(); } | 278 bool is_empty() const { return list_.is_empty(); } |
279 int length() const { return list_.length(); } | 279 int length() const { return list_.length(); } |
280 | 280 |
281 void AddMapIfMissing(Handle<Map> map, Zone* zone) { | 281 void AddMapIfMissing(Handle<Map> map, Zone* zone) { |
282 Map* updated = map->CurrentMapForDeprecated(); | 282 map = Map::CurrentMapForDeprecated(map); |
283 if (updated == NULL) return; | 283 if (map.is_null()) return; |
284 map = Handle<Map>(updated); | |
285 for (int i = 0; i < length(); ++i) { | 284 for (int i = 0; i < length(); ++i) { |
286 if (at(i).is_identical_to(map)) return; | 285 if (at(i).is_identical_to(map)) return; |
287 } | 286 } |
288 Add(map, zone); | 287 Add(map, zone); |
289 } | 288 } |
290 | 289 |
291 void FilterForPossibleTransitions(Map* root_map) { | 290 void FilterForPossibleTransitions(Map* root_map) { |
292 for (int i = list_.length() - 1; i >= 0; i--) { | 291 for (int i = list_.length() - 1; i >= 0; i--) { |
293 if (at(i)->FindRootMap() != root_map) { | 292 if (at(i)->FindRootMap() != root_map) { |
294 list_.RemoveElement(list_.at(i)); | 293 list_.RemoveElement(list_.at(i)); |
(...skipping 1389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1684 | 1683 |
1685 Expression* obj() const { return obj_; } | 1684 Expression* obj() const { return obj_; } |
1686 Expression* key() const { return key_; } | 1685 Expression* key() const { return key_; } |
1687 | 1686 |
1688 BailoutId LoadId() const { return load_id_; } | 1687 BailoutId LoadId() const { return load_id_; } |
1689 | 1688 |
1690 bool IsStringAccess() const { return is_string_access_; } | 1689 bool IsStringAccess() const { return is_string_access_; } |
1691 bool IsFunctionPrototype() const { return is_function_prototype_; } | 1690 bool IsFunctionPrototype() const { return is_function_prototype_; } |
1692 | 1691 |
1693 // Type feedback information. | 1692 // Type feedback information. |
1694 virtual bool IsMonomorphic() V8_OVERRIDE { return is_monomorphic_; } | 1693 virtual bool IsMonomorphic() V8_OVERRIDE { |
| 1694 return receiver_types_.length() == 1; |
| 1695 } |
1695 virtual SmallMapList* GetReceiverTypes() V8_OVERRIDE { | 1696 virtual SmallMapList* GetReceiverTypes() V8_OVERRIDE { |
1696 return &receiver_types_; | 1697 return &receiver_types_; |
1697 } | 1698 } |
1698 virtual KeyedAccessStoreMode GetStoreMode() V8_OVERRIDE { | 1699 virtual KeyedAccessStoreMode GetStoreMode() V8_OVERRIDE { |
1699 return STANDARD_STORE; | 1700 return STANDARD_STORE; |
1700 } | 1701 } |
1701 bool IsUninitialized() { return is_uninitialized_; } | 1702 bool IsUninitialized() { return is_uninitialized_; } |
1702 bool IsPreMonomorphic() { return is_pre_monomorphic_; } | 1703 bool IsPreMonomorphic() { return is_pre_monomorphic_; } |
1703 bool HasNoTypeInformation() { | 1704 bool HasNoTypeInformation() { |
1704 return is_uninitialized_ || is_pre_monomorphic_; | 1705 return is_uninitialized_ || is_pre_monomorphic_; |
1705 } | 1706 } |
1706 void set_is_uninitialized(bool b) { is_uninitialized_ = b; } | 1707 void set_is_uninitialized(bool b) { is_uninitialized_ = b; } |
1707 void set_is_monomorphic(bool b) { is_monomorphic_ = b; } | |
1708 void set_is_pre_monomorphic(bool b) { is_pre_monomorphic_ = b; } | 1708 void set_is_pre_monomorphic(bool b) { is_pre_monomorphic_ = b; } |
1709 void set_is_string_access(bool b) { is_string_access_ = b; } | 1709 void set_is_string_access(bool b) { is_string_access_ = b; } |
1710 void set_is_function_prototype(bool b) { is_function_prototype_ = b; } | 1710 void set_is_function_prototype(bool b) { is_function_prototype_ = b; } |
1711 | 1711 |
1712 TypeFeedbackId PropertyFeedbackId() { return reuse(id()); } | 1712 TypeFeedbackId PropertyFeedbackId() { return reuse(id()); } |
1713 | 1713 |
1714 protected: | 1714 protected: |
1715 Property(Isolate* isolate, | 1715 Property(Isolate* isolate, |
1716 Expression* obj, | 1716 Expression* obj, |
1717 Expression* key, | 1717 Expression* key, |
1718 int pos) | 1718 int pos) |
1719 : Expression(isolate, pos), | 1719 : Expression(isolate, pos), |
1720 obj_(obj), | 1720 obj_(obj), |
1721 key_(key), | 1721 key_(key), |
1722 load_id_(GetNextId(isolate)), | 1722 load_id_(GetNextId(isolate)), |
1723 is_monomorphic_(false), | |
1724 is_pre_monomorphic_(false), | 1723 is_pre_monomorphic_(false), |
1725 is_uninitialized_(false), | 1724 is_uninitialized_(false), |
1726 is_string_access_(false), | 1725 is_string_access_(false), |
1727 is_function_prototype_(false) { } | 1726 is_function_prototype_(false) { } |
1728 | 1727 |
1729 private: | 1728 private: |
1730 Expression* obj_; | 1729 Expression* obj_; |
1731 Expression* key_; | 1730 Expression* key_; |
1732 const BailoutId load_id_; | 1731 const BailoutId load_id_; |
1733 | 1732 |
1734 SmallMapList receiver_types_; | 1733 SmallMapList receiver_types_; |
1735 bool is_monomorphic_ : 1; | |
1736 bool is_pre_monomorphic_ : 1; | 1734 bool is_pre_monomorphic_ : 1; |
1737 bool is_uninitialized_ : 1; | 1735 bool is_uninitialized_ : 1; |
1738 bool is_string_access_ : 1; | 1736 bool is_string_access_ : 1; |
1739 bool is_function_prototype_ : 1; | 1737 bool is_function_prototype_ : 1; |
1740 }; | 1738 }; |
1741 | 1739 |
1742 | 1740 |
1743 class Call V8_FINAL : public Expression { | 1741 class Call V8_FINAL : public Expression { |
1744 public: | 1742 public: |
1745 DECLARE_NODE_TYPE(Call) | 1743 DECLARE_NODE_TYPE(Call) |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1994 bool is_prefix() const { return is_prefix_; } | 1992 bool is_prefix() const { return is_prefix_; } |
1995 bool is_postfix() const { return !is_prefix_; } | 1993 bool is_postfix() const { return !is_prefix_; } |
1996 | 1994 |
1997 Token::Value op() const { return op_; } | 1995 Token::Value op() const { return op_; } |
1998 Token::Value binary_op() { | 1996 Token::Value binary_op() { |
1999 return (op() == Token::INC) ? Token::ADD : Token::SUB; | 1997 return (op() == Token::INC) ? Token::ADD : Token::SUB; |
2000 } | 1998 } |
2001 | 1999 |
2002 Expression* expression() const { return expression_; } | 2000 Expression* expression() const { return expression_; } |
2003 | 2001 |
2004 virtual bool IsMonomorphic() V8_OVERRIDE { return is_monomorphic_; } | 2002 virtual bool IsMonomorphic() V8_OVERRIDE { |
| 2003 return receiver_types_.length() == 1; |
| 2004 } |
2005 virtual SmallMapList* GetReceiverTypes() V8_OVERRIDE { | 2005 virtual SmallMapList* GetReceiverTypes() V8_OVERRIDE { |
2006 return &receiver_types_; | 2006 return &receiver_types_; |
2007 } | 2007 } |
2008 virtual KeyedAccessStoreMode GetStoreMode() V8_OVERRIDE { | 2008 virtual KeyedAccessStoreMode GetStoreMode() V8_OVERRIDE { |
2009 return store_mode_; | 2009 return store_mode_; |
2010 } | 2010 } |
2011 Handle<Type> type() const { return type_; } | 2011 Handle<Type> type() const { return type_; } |
2012 void set_is_monomorphic(bool b) { is_monomorphic_ = b; } | |
2013 void set_store_mode(KeyedAccessStoreMode mode) { store_mode_ = mode; } | 2012 void set_store_mode(KeyedAccessStoreMode mode) { store_mode_ = mode; } |
2014 void set_type(Handle<Type> type) { type_ = type; } | 2013 void set_type(Handle<Type> type) { type_ = type; } |
2015 | 2014 |
2016 BailoutId AssignmentId() const { return assignment_id_; } | 2015 BailoutId AssignmentId() const { return assignment_id_; } |
2017 | 2016 |
2018 TypeFeedbackId CountBinOpFeedbackId() const { return count_id_; } | 2017 TypeFeedbackId CountBinOpFeedbackId() const { return count_id_; } |
2019 TypeFeedbackId CountStoreFeedbackId() const { return reuse(id()); } | 2018 TypeFeedbackId CountStoreFeedbackId() const { return reuse(id()); } |
2020 | 2019 |
2021 protected: | 2020 protected: |
2022 CountOperation(Isolate* isolate, | 2021 CountOperation(Isolate* isolate, |
2023 Token::Value op, | 2022 Token::Value op, |
2024 bool is_prefix, | 2023 bool is_prefix, |
2025 Expression* expr, | 2024 Expression* expr, |
2026 int pos) | 2025 int pos) |
2027 : Expression(isolate, pos), | 2026 : Expression(isolate, pos), |
2028 op_(op), | 2027 op_(op), |
2029 is_prefix_(is_prefix), | 2028 is_prefix_(is_prefix), |
2030 is_monomorphic_(false), | |
2031 store_mode_(STANDARD_STORE), | 2029 store_mode_(STANDARD_STORE), |
2032 expression_(expr), | 2030 expression_(expr), |
2033 assignment_id_(GetNextId(isolate)), | 2031 assignment_id_(GetNextId(isolate)), |
2034 count_id_(GetNextId(isolate)) {} | 2032 count_id_(GetNextId(isolate)) {} |
2035 | 2033 |
2036 private: | 2034 private: |
2037 Token::Value op_; | 2035 Token::Value op_; |
2038 bool is_prefix_ : 1; | 2036 bool is_prefix_ : 1; |
2039 bool is_monomorphic_ : 1; | |
2040 KeyedAccessStoreMode store_mode_ : 5; // Windows treats as signed, | 2037 KeyedAccessStoreMode store_mode_ : 5; // Windows treats as signed, |
2041 // must have extra bit. | 2038 // must have extra bit. |
2042 Handle<Type> type_; | 2039 Handle<Type> type_; |
2043 | 2040 |
2044 Expression* expression_; | 2041 Expression* expression_; |
2045 const BailoutId assignment_id_; | 2042 const BailoutId assignment_id_; |
2046 const TypeFeedbackId count_id_; | 2043 const TypeFeedbackId count_id_; |
2047 SmallMapList receiver_types_; | 2044 SmallMapList receiver_types_; |
2048 }; | 2045 }; |
2049 | 2046 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2135 Expression* value() const { return value_; } | 2132 Expression* value() const { return value_; } |
2136 BinaryOperation* binary_operation() const { return binary_operation_; } | 2133 BinaryOperation* binary_operation() const { return binary_operation_; } |
2137 | 2134 |
2138 // This check relies on the definition order of token in token.h. | 2135 // This check relies on the definition order of token in token.h. |
2139 bool is_compound() const { return op() > Token::ASSIGN; } | 2136 bool is_compound() const { return op() > Token::ASSIGN; } |
2140 | 2137 |
2141 BailoutId AssignmentId() const { return assignment_id_; } | 2138 BailoutId AssignmentId() const { return assignment_id_; } |
2142 | 2139 |
2143 // Type feedback information. | 2140 // Type feedback information. |
2144 TypeFeedbackId AssignmentFeedbackId() { return reuse(id()); } | 2141 TypeFeedbackId AssignmentFeedbackId() { return reuse(id()); } |
2145 virtual bool IsMonomorphic() V8_OVERRIDE { return is_monomorphic_; } | 2142 virtual bool IsMonomorphic() V8_OVERRIDE { |
| 2143 return receiver_types_.length() == 1; |
| 2144 } |
2146 bool IsUninitialized() { return is_uninitialized_; } | 2145 bool IsUninitialized() { return is_uninitialized_; } |
2147 bool IsPreMonomorphic() { return is_pre_monomorphic_; } | 2146 bool IsPreMonomorphic() { return is_pre_monomorphic_; } |
2148 bool HasNoTypeInformation() { | 2147 bool HasNoTypeInformation() { |
2149 return is_uninitialized_ || is_pre_monomorphic_; | 2148 return is_uninitialized_ || is_pre_monomorphic_; |
2150 } | 2149 } |
2151 virtual SmallMapList* GetReceiverTypes() V8_OVERRIDE { | 2150 virtual SmallMapList* GetReceiverTypes() V8_OVERRIDE { |
2152 return &receiver_types_; | 2151 return &receiver_types_; |
2153 } | 2152 } |
2154 virtual KeyedAccessStoreMode GetStoreMode() V8_OVERRIDE { | 2153 virtual KeyedAccessStoreMode GetStoreMode() V8_OVERRIDE { |
2155 return store_mode_; | 2154 return store_mode_; |
2156 } | 2155 } |
2157 void set_is_uninitialized(bool b) { is_uninitialized_ = b; } | 2156 void set_is_uninitialized(bool b) { is_uninitialized_ = b; } |
2158 void set_is_monomorphic(bool b) { is_monomorphic_ = b; } | |
2159 void set_is_pre_monomorphic(bool b) { is_pre_monomorphic_ = b; } | 2157 void set_is_pre_monomorphic(bool b) { is_pre_monomorphic_ = b; } |
2160 void set_store_mode(KeyedAccessStoreMode mode) { store_mode_ = mode; } | 2158 void set_store_mode(KeyedAccessStoreMode mode) { store_mode_ = mode; } |
2161 | 2159 |
2162 protected: | 2160 protected: |
2163 Assignment(Isolate* isolate, | 2161 Assignment(Isolate* isolate, |
2164 Token::Value op, | 2162 Token::Value op, |
2165 Expression* target, | 2163 Expression* target, |
2166 Expression* value, | 2164 Expression* value, |
2167 int pos); | 2165 int pos); |
2168 | 2166 |
2169 template<class Visitor> | 2167 template<class Visitor> |
2170 void Init(Isolate* isolate, AstNodeFactory<Visitor>* factory) { | 2168 void Init(Isolate* isolate, AstNodeFactory<Visitor>* factory) { |
2171 ASSERT(Token::IsAssignmentOp(op_)); | 2169 ASSERT(Token::IsAssignmentOp(op_)); |
2172 if (is_compound()) { | 2170 if (is_compound()) { |
2173 binary_operation_ = factory->NewBinaryOperation( | 2171 binary_operation_ = factory->NewBinaryOperation( |
2174 binary_op(), target_, value_, position() + 1); | 2172 binary_op(), target_, value_, position() + 1); |
2175 } | 2173 } |
2176 } | 2174 } |
2177 | 2175 |
2178 private: | 2176 private: |
2179 Token::Value op_; | 2177 Token::Value op_; |
2180 Expression* target_; | 2178 Expression* target_; |
2181 Expression* value_; | 2179 Expression* value_; |
2182 BinaryOperation* binary_operation_; | 2180 BinaryOperation* binary_operation_; |
2183 const BailoutId assignment_id_; | 2181 const BailoutId assignment_id_; |
2184 | 2182 |
2185 bool is_monomorphic_ : 1; | |
2186 bool is_uninitialized_ : 1; | 2183 bool is_uninitialized_ : 1; |
2187 bool is_pre_monomorphic_ : 1; | 2184 bool is_pre_monomorphic_ : 1; |
2188 KeyedAccessStoreMode store_mode_ : 5; // Windows treats as signed, | 2185 KeyedAccessStoreMode store_mode_ : 5; // Windows treats as signed, |
2189 // must have extra bit. | 2186 // must have extra bit. |
2190 SmallMapList receiver_types_; | 2187 SmallMapList receiver_types_; |
2191 }; | 2188 }; |
2192 | 2189 |
2193 | 2190 |
2194 class Yield V8_FINAL : public Expression { | 2191 class Yield V8_FINAL : public Expression { |
2195 public: | 2192 public: |
(...skipping 1105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3301 private: | 3298 private: |
3302 Isolate* isolate_; | 3299 Isolate* isolate_; |
3303 Zone* zone_; | 3300 Zone* zone_; |
3304 Visitor visitor_; | 3301 Visitor visitor_; |
3305 }; | 3302 }; |
3306 | 3303 |
3307 | 3304 |
3308 } } // namespace v8::internal | 3305 } } // namespace v8::internal |
3309 | 3306 |
3310 #endif // V8_AST_H_ | 3307 #endif // V8_AST_H_ |
OLD | NEW |