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_AST_H_ | 5 #ifndef V8_AST_AST_H_ |
6 #define V8_AST_AST_H_ | 6 #define V8_AST_AST_H_ |
7 | 7 |
8 #include "src/ast/ast-value-factory.h" | 8 #include "src/ast/ast-value-factory.h" |
9 #include "src/ast/modules.h" | 9 #include "src/ast/modules.h" |
10 #include "src/ast/variables.h" | 10 #include "src/ast/variables.h" |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
311 // True iff the expression is a valid reference expression. | 311 // True iff the expression is a valid reference expression. |
312 bool IsValidReferenceExpression() const; | 312 bool IsValidReferenceExpression() const; |
313 | 313 |
314 // Helpers for ToBoolean conversion. | 314 // Helpers for ToBoolean conversion. |
315 bool ToBooleanIsTrue() const; | 315 bool ToBooleanIsTrue() const; |
316 bool ToBooleanIsFalse() const; | 316 bool ToBooleanIsFalse() const; |
317 | 317 |
318 // Symbols that cannot be parsed as array indices are considered property | 318 // Symbols that cannot be parsed as array indices are considered property |
319 // names. We do not treat symbols that can be array indexes as property | 319 // names. We do not treat symbols that can be array indexes as property |
320 // names because [] for string objects is handled only by keyed ICs. | 320 // names because [] for string objects is handled only by keyed ICs. |
321 bool IsPropertyName() const; | 321 bool IsPropertyName( |
marja
2016/08/08 08:20:13
For all calls, the guarantee you want to give is t
rmcilroy
2016/08/08 13:05:56
For GetCallType yes this is the case. For IsProper
| |
322 HandleDereferenceMode deref_mode = | |
323 HandleDereferenceMode::kHandleDereferenceAllowed) const; | |
322 | 324 |
323 // True iff the expression is a class or function expression without | 325 // True iff the expression is a class or function expression without |
324 // a syntactic name. | 326 // a syntactic name. |
325 bool IsAnonymousFunctionDefinition() const; | 327 bool IsAnonymousFunctionDefinition() const; |
326 | 328 |
327 // True iff the expression is a literal represented as a smi. | 329 // True iff the expression is a literal represented as a smi. |
328 bool IsSmiLiteral() const; | 330 bool IsSmiLiteral() const; |
329 | 331 |
330 // True iff the expression is a string literal. | 332 // True iff the expression is a string literal. |
331 bool IsStringLiteral() const; | 333 bool IsStringLiteral() const; |
(...skipping 902 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1234 | 1236 |
1235 Statement* statement_; | 1237 Statement* statement_; |
1236 Scope* const scope_; | 1238 Scope* const scope_; |
1237 }; | 1239 }; |
1238 | 1240 |
1239 | 1241 |
1240 class Literal final : public Expression { | 1242 class Literal final : public Expression { |
1241 public: | 1243 public: |
1242 DECLARE_NODE_TYPE(Literal) | 1244 DECLARE_NODE_TYPE(Literal) |
1243 | 1245 |
1244 bool IsPropertyName() const { return value_->IsPropertyName(); } | 1246 bool IsPropertyName( |
1247 HandleDereferenceMode deref_mode = | |
1248 HandleDereferenceMode::kHandleDereferenceAllowed) const { | |
1249 return value_->IsPropertyName(deref_mode); | |
1250 } | |
1245 | 1251 |
1246 Handle<String> AsPropertyName() { | 1252 Handle<String> AsPropertyName() { |
1247 DCHECK(IsPropertyName()); | 1253 DCHECK(IsPropertyName(HandleDereferenceMode::kHandleDereferenceDisallowed)); |
1248 return Handle<String>::cast(value()); | 1254 return Handle<String>::cast(value()); |
1249 } | 1255 } |
1250 | 1256 |
1251 const AstRawString* AsRawPropertyName() { | 1257 const AstRawString* AsRawPropertyName() { |
1252 DCHECK(IsPropertyName()); | 1258 DCHECK(IsPropertyName()); |
1253 return value_->AsString(); | 1259 return value_->AsString(); |
1254 } | 1260 } |
1255 | 1261 |
1256 bool ToBooleanIsTrue() const { return value()->BooleanValue(); } | 1262 bool ToBooleanIsTrue() const { return raw_value()->BooleanValue(); } |
1257 bool ToBooleanIsFalse() const { return !value()->BooleanValue(); } | 1263 bool ToBooleanIsFalse() const { return !raw_value()->BooleanValue(); } |
1258 | 1264 |
1259 Handle<Object> value() const { return value_->value(); } | 1265 Handle<Object> value() const { return value_->value(); } |
1260 const AstValue* raw_value() const { return value_; } | 1266 const AstValue* raw_value() const { return value_; } |
1261 | 1267 |
1262 // Support for using Literal as a HashMap key. NOTE: Currently, this works | 1268 // Support for using Literal as a HashMap key. NOTE: Currently, this works |
1263 // only for string and number literals! | 1269 // only for string and number literals! |
1264 uint32_t Hash(); | 1270 uint32_t Hash(); |
1265 static bool Match(void* literal1, void* literal2); | 1271 static bool Match(void* literal1, void* literal2); |
1266 | 1272 |
1267 static int num_ids() { return parent_num_ids() + 1; } | 1273 static int num_ids() { return parent_num_ids() + 1; } |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1404 // for minimizing the work when constructing it at runtime. | 1410 // for minimizing the work when constructing it at runtime. |
1405 class ObjectLiteral final : public MaterializedLiteral { | 1411 class ObjectLiteral final : public MaterializedLiteral { |
1406 public: | 1412 public: |
1407 typedef ObjectLiteralProperty Property; | 1413 typedef ObjectLiteralProperty Property; |
1408 | 1414 |
1409 DECLARE_NODE_TYPE(ObjectLiteral) | 1415 DECLARE_NODE_TYPE(ObjectLiteral) |
1410 | 1416 |
1411 Handle<FixedArray> constant_properties() const { | 1417 Handle<FixedArray> constant_properties() const { |
1412 return constant_properties_; | 1418 return constant_properties_; |
1413 } | 1419 } |
1414 int properties_count() const { return constant_properties_->length() / 2; } | 1420 int properties_count() const { return boilerplate_properties_; } |
1415 ZoneList<Property*>* properties() const { return properties_; } | 1421 ZoneList<Property*>* properties() const { return properties_; } |
1416 bool fast_elements() const { return fast_elements_; } | 1422 bool fast_elements() const { return fast_elements_; } |
1417 bool may_store_doubles() const { return may_store_doubles_; } | 1423 bool may_store_doubles() const { return may_store_doubles_; } |
1418 bool has_elements() const { return has_elements_; } | 1424 bool has_elements() const { return has_elements_; } |
1419 bool has_shallow_properties() const { | 1425 bool has_shallow_properties() const { |
1420 return depth() == 1 && !has_elements() && !may_store_doubles(); | 1426 return depth() == 1 && !has_elements() && !may_store_doubles(); |
1421 } | 1427 } |
1422 | 1428 |
1423 // Decide if a property should be in the object boilerplate. | 1429 // Decide if a property should be in the object boilerplate. |
1424 static bool IsBoilerplateProperty(Property* property); | 1430 static bool IsBoilerplateProperty(Property* property); |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1779 FeedbackVectorSlotKind kind = key()->IsPropertyName() | 1785 FeedbackVectorSlotKind kind = key()->IsPropertyName() |
1780 ? FeedbackVectorSlotKind::LOAD_IC | 1786 ? FeedbackVectorSlotKind::LOAD_IC |
1781 : FeedbackVectorSlotKind::KEYED_LOAD_IC; | 1787 : FeedbackVectorSlotKind::KEYED_LOAD_IC; |
1782 property_feedback_slot_ = spec->AddSlot(kind); | 1788 property_feedback_slot_ = spec->AddSlot(kind); |
1783 } | 1789 } |
1784 | 1790 |
1785 FeedbackVectorSlot PropertyFeedbackSlot() const { | 1791 FeedbackVectorSlot PropertyFeedbackSlot() const { |
1786 return property_feedback_slot_; | 1792 return property_feedback_slot_; |
1787 } | 1793 } |
1788 | 1794 |
1789 static LhsKind GetAssignType(Property* property) { | 1795 static LhsKind GetAssignType( |
1796 Property* property, | |
1797 HandleDereferenceMode deref_mode = | |
1798 HandleDereferenceMode::kHandleDereferenceAllowed) { | |
1790 if (property == NULL) return VARIABLE; | 1799 if (property == NULL) return VARIABLE; |
1791 bool super_access = property->IsSuperAccess(); | 1800 bool super_access = property->IsSuperAccess(); |
1792 return (property->key()->IsPropertyName()) | 1801 return (property->key()->IsPropertyName(deref_mode)) |
1793 ? (super_access ? NAMED_SUPER_PROPERTY : NAMED_PROPERTY) | 1802 ? (super_access ? NAMED_SUPER_PROPERTY : NAMED_PROPERTY) |
1794 : (super_access ? KEYED_SUPER_PROPERTY : KEYED_PROPERTY); | 1803 : (super_access ? KEYED_SUPER_PROPERTY : KEYED_PROPERTY); |
1795 } | 1804 } |
1796 | 1805 |
1797 protected: | 1806 protected: |
1798 Property(Zone* zone, Expression* obj, Expression* key, int pos) | 1807 Property(Zone* zone, Expression* obj, Expression* key, int pos) |
1799 : Expression(zone, pos, kProperty), | 1808 : Expression(zone, pos, kProperty), |
1800 bit_field_(IsForCallField::encode(false) | | 1809 bit_field_(IsForCallField::encode(false) | |
1801 IsStringAccessField::encode(false) | | 1810 IsStringAccessField::encode(false) | |
1802 InlineCacheStateField::encode(UNINITIALIZED)), | 1811 InlineCacheStateField::encode(UNINITIALIZED)), |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1897 LOOKUP_SLOT_CALL, | 1906 LOOKUP_SLOT_CALL, |
1898 NAMED_PROPERTY_CALL, | 1907 NAMED_PROPERTY_CALL, |
1899 KEYED_PROPERTY_CALL, | 1908 KEYED_PROPERTY_CALL, |
1900 NAMED_SUPER_PROPERTY_CALL, | 1909 NAMED_SUPER_PROPERTY_CALL, |
1901 KEYED_SUPER_PROPERTY_CALL, | 1910 KEYED_SUPER_PROPERTY_CALL, |
1902 SUPER_CALL, | 1911 SUPER_CALL, |
1903 OTHER_CALL | 1912 OTHER_CALL |
1904 }; | 1913 }; |
1905 | 1914 |
1906 // Helpers to determine how to handle the call. | 1915 // Helpers to determine how to handle the call. |
1907 CallType GetCallType(Isolate* isolate) const; | 1916 CallType GetCallType( |
1908 bool IsUsingCallFeedbackSlot(Isolate* isolate) const; | 1917 Isolate* isolate, |
1909 bool IsUsingCallFeedbackICSlot(Isolate* isolate) const; | 1918 HandleDereferenceMode deref_mode = |
1919 HandleDereferenceMode::kHandleDereferenceAllowed) const; | |
1920 bool IsUsingCallFeedbackSlot( | |
1921 Isolate* isolate, | |
1922 HandleDereferenceMode deref_mode = | |
1923 HandleDereferenceMode::kHandleDereferenceAllowed) const; | |
1924 bool IsUsingCallFeedbackICSlot( | |
1925 Isolate* isolate, | |
1926 HandleDereferenceMode deref_mode = | |
1927 HandleDereferenceMode::kHandleDereferenceAllowed) const; | |
1910 | 1928 |
1911 #ifdef DEBUG | 1929 #ifdef DEBUG |
1912 // Used to assert that the FullCodeGenerator records the return site. | 1930 // Used to assert that the FullCodeGenerator records the return site. |
1913 bool return_is_recorded_; | 1931 bool return_is_recorded_; |
1914 #endif | 1932 #endif |
1915 | 1933 |
1916 protected: | 1934 protected: |
1917 Call(Zone* zone, Expression* expression, ZoneList<Expression*>* arguments, | 1935 Call(Zone* zone, Expression* expression, ZoneList<Expression*>* arguments, |
1918 int pos) | 1936 int pos) |
1919 : Expression(zone, pos, kCall), | 1937 : Expression(zone, pos, kCall), |
(...skipping 1628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3548 : NULL; \ | 3566 : NULL; \ |
3549 } | 3567 } |
3550 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) | 3568 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) |
3551 #undef DECLARE_NODE_FUNCTIONS | 3569 #undef DECLARE_NODE_FUNCTIONS |
3552 | 3570 |
3553 | 3571 |
3554 } // namespace internal | 3572 } // namespace internal |
3555 } // namespace v8 | 3573 } // namespace v8 |
3556 | 3574 |
3557 #endif // V8_AST_AST_H_ | 3575 #endif // V8_AST_AST_H_ |
OLD | NEW |