| 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/assembler.h" | 8 #include "src/assembler.h" |
| 9 #include "src/ast/ast-types.h" | 9 #include "src/ast/ast-types.h" |
| 10 #include "src/ast/ast-value-factory.h" | 10 #include "src/ast/ast-value-factory.h" |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 // names because [] for string objects is handled only by keyed ICs. | 313 // names because [] for string objects is handled only by keyed ICs. |
| 314 bool IsPropertyName() const; | 314 bool IsPropertyName() const; |
| 315 | 315 |
| 316 // True iff the expression is a class or function expression without | 316 // True iff the expression is a class or function expression without |
| 317 // a syntactic name. | 317 // a syntactic name. |
| 318 bool IsAnonymousFunctionDefinition() const; | 318 bool IsAnonymousFunctionDefinition() const; |
| 319 | 319 |
| 320 // True iff the expression is a literal represented as a smi. | 320 // True iff the expression is a literal represented as a smi. |
| 321 bool IsSmiLiteral() const; | 321 bool IsSmiLiteral() const; |
| 322 | 322 |
| 323 // True iff the expression is a literal represented as a number. |
| 324 bool IsNumberLiteral() const; |
| 325 |
| 323 // True iff the expression is a string literal. | 326 // True iff the expression is a string literal. |
| 324 bool IsStringLiteral() const; | 327 bool IsStringLiteral() const; |
| 325 | 328 |
| 326 // True iff the expression is the null literal. | 329 // True iff the expression is the null literal. |
| 327 bool IsNullLiteral() const; | 330 bool IsNullLiteral() const; |
| 328 | 331 |
| 329 // True if we can prove that the expression is the undefined literal. Note | 332 // True if we can prove that the expression is the undefined literal. Note |
| 330 // that this also checks for loads of the global "undefined" variable. | 333 // that this also checks for loads of the global "undefined" variable. |
| 331 bool IsUndefinedLiteral() const; | 334 bool IsUndefinedLiteral() const; |
| 332 | 335 |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 722 return subject(); | 725 return subject(); |
| 723 } | 726 } |
| 724 | 727 |
| 725 Expression* each() const { return each_; } | 728 Expression* each() const { return each_; } |
| 726 Expression* subject() const { return subject_; } | 729 Expression* subject() const { return subject_; } |
| 727 | 730 |
| 728 void set_each(Expression* e) { each_ = e; } | 731 void set_each(Expression* e) { each_ = e; } |
| 729 void set_subject(Expression* e) { subject_ = e; } | 732 void set_subject(Expression* e) { subject_ = e; } |
| 730 | 733 |
| 731 // Type feedback information. | 734 // Type feedback information. |
| 732 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, | 735 void AssignFeedbackVectorSlots(FeedbackVectorSpec* spec, |
| 733 FeedbackVectorSlotCache* cache); | 736 FeedbackVectorSlotCache* cache); |
| 734 FeedbackVectorSlot EachFeedbackSlot() const { return each_slot_; } | 737 FeedbackVectorSlot EachFeedbackSlot() const { return each_slot_; } |
| 735 FeedbackVectorSlot ForInFeedbackSlot() { | 738 FeedbackVectorSlot ForInFeedbackSlot() { |
| 736 DCHECK(!for_in_feedback_slot_.IsInvalid()); | 739 DCHECK(!for_in_feedback_slot_.IsInvalid()); |
| 737 return for_in_feedback_slot_; | 740 return for_in_feedback_slot_; |
| 738 } | 741 } |
| 739 | 742 |
| 740 enum ForInType { FAST_FOR_IN, SLOW_FOR_IN }; | 743 enum ForInType { FAST_FOR_IN, SLOW_FOR_IN }; |
| 741 ForInType for_in_type() const { return ForInTypeField::decode(bit_field_); } | 744 ForInType for_in_type() const { return ForInTypeField::decode(bit_field_); } |
| 742 void set_for_in_type(ForInType type) { | 745 void set_for_in_type(ForInType type) { |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 944 static int num_ids() { return parent_num_ids() + 2; } | 947 static int num_ids() { return parent_num_ids() + 2; } |
| 945 BailoutId EntryId() const { return BailoutId(local_id(0)); } | 948 BailoutId EntryId() const { return BailoutId(local_id(0)); } |
| 946 TypeFeedbackId CompareId() { return TypeFeedbackId(local_id(1)); } | 949 TypeFeedbackId CompareId() { return TypeFeedbackId(local_id(1)); } |
| 947 | 950 |
| 948 AstType* compare_type() { return compare_type_; } | 951 AstType* compare_type() { return compare_type_; } |
| 949 void set_compare_type(AstType* type) { compare_type_ = type; } | 952 void set_compare_type(AstType* type) { compare_type_ = type; } |
| 950 | 953 |
| 951 // CaseClause will have both a slot in the feedback vector and the | 954 // CaseClause will have both a slot in the feedback vector and the |
| 952 // TypeFeedbackId to record the type information. TypeFeedbackId is used by | 955 // TypeFeedbackId to record the type information. TypeFeedbackId is used by |
| 953 // full codegen and the feedback vector slot is used by interpreter. | 956 // full codegen and the feedback vector slot is used by interpreter. |
| 954 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, | 957 void AssignFeedbackVectorSlots(FeedbackVectorSpec* spec, |
| 955 FeedbackVectorSlotCache* cache); | 958 FeedbackVectorSlotCache* cache); |
| 956 | 959 |
| 957 FeedbackVectorSlot CompareOperationFeedbackSlot() { | 960 FeedbackVectorSlot CompareOperationFeedbackSlot() { |
| 958 return type_feedback_slot_; | 961 return type_feedback_slot_; |
| 959 } | 962 } |
| 960 | 963 |
| 961 private: | 964 private: |
| 962 friend class AstNodeFactory; | 965 friend class AstNodeFactory; |
| 963 | 966 |
| 964 static int parent_num_ids() { return Expression::num_ids(); } | 967 static int parent_num_ids() { return Expression::num_ids(); } |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1280 void set_is_simple(bool is_simple) { | 1283 void set_is_simple(bool is_simple) { |
| 1281 bit_field_ = IsSimpleField::update(bit_field_, is_simple); | 1284 bit_field_ = IsSimpleField::update(bit_field_, is_simple); |
| 1282 } | 1285 } |
| 1283 friend class CompileTimeValue; | 1286 friend class CompileTimeValue; |
| 1284 | 1287 |
| 1285 void set_depth(int depth) { | 1288 void set_depth(int depth) { |
| 1286 DCHECK_LE(1, depth); | 1289 DCHECK_LE(1, depth); |
| 1287 depth_ = depth; | 1290 depth_ = depth; |
| 1288 } | 1291 } |
| 1289 | 1292 |
| 1293 // Populate the depth field and any flags the literal has. |
| 1294 void InitDepthAndFlags(); |
| 1295 |
| 1290 // Populate the constant properties/elements fixed array. | 1296 // Populate the constant properties/elements fixed array. |
| 1291 void BuildConstants(Isolate* isolate); | 1297 void BuildConstants(Isolate* isolate); |
| 1292 friend class ArrayLiteral; | 1298 friend class ArrayLiteral; |
| 1293 friend class ObjectLiteral; | 1299 friend class ObjectLiteral; |
| 1294 | 1300 |
| 1295 // If the expression is a literal, return the literal value; | 1301 // If the expression is a literal, return the literal value; |
| 1296 // if the expression is a materialized literal and is simple return a | 1302 // if the expression is a materialized literal and is simple return a |
| 1297 // compile time value as encoded by CompileTimeValue::GetValue(). | 1303 // compile time value as encoded by CompileTimeValue::GetValue(). |
| 1298 // Otherwise, return undefined literal as the placeholder | 1304 // Otherwise, return undefined literal as the placeholder |
| 1299 // in the object literal boilerplate. | 1305 // in the object literal boilerplate. |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1380 }; | 1386 }; |
| 1381 | 1387 |
| 1382 | 1388 |
| 1383 // An object literal has a boilerplate object that is used | 1389 // An object literal has a boilerplate object that is used |
| 1384 // for minimizing the work when constructing it at runtime. | 1390 // for minimizing the work when constructing it at runtime. |
| 1385 class ObjectLiteral final : public MaterializedLiteral { | 1391 class ObjectLiteral final : public MaterializedLiteral { |
| 1386 public: | 1392 public: |
| 1387 typedef ObjectLiteralProperty Property; | 1393 typedef ObjectLiteralProperty Property; |
| 1388 | 1394 |
| 1389 Handle<FixedArray> constant_properties() const { | 1395 Handle<FixedArray> constant_properties() const { |
| 1396 DCHECK(!constant_properties_.is_null()); |
| 1390 return constant_properties_; | 1397 return constant_properties_; |
| 1391 } | 1398 } |
| 1392 int properties_count() const { return boilerplate_properties_; } | 1399 int properties_count() const { return boilerplate_properties_; } |
| 1393 ZoneList<Property*>* properties() const { return properties_; } | 1400 ZoneList<Property*>* properties() const { return properties_; } |
| 1394 bool fast_elements() const { return FastElementsField::decode(bit_field_); } | 1401 bool fast_elements() const { return FastElementsField::decode(bit_field_); } |
| 1395 bool may_store_doubles() const { | 1402 bool may_store_doubles() const { |
| 1396 return MayStoreDoublesField::decode(bit_field_); | 1403 return MayStoreDoublesField::decode(bit_field_); |
| 1397 } | 1404 } |
| 1398 bool has_elements() const { return HasElementsField::decode(bit_field_); } | 1405 bool has_elements() const { return HasElementsField::decode(bit_field_); } |
| 1399 bool has_shallow_properties() const { | 1406 bool has_shallow_properties() const { |
| 1400 return depth() == 1 && !has_elements() && !may_store_doubles(); | 1407 return depth() == 1 && !has_elements() && !may_store_doubles(); |
| 1401 } | 1408 } |
| 1402 | 1409 |
| 1403 // Decide if a property should be in the object boilerplate. | 1410 // Decide if a property should be in the object boilerplate. |
| 1404 static bool IsBoilerplateProperty(Property* property); | 1411 static bool IsBoilerplateProperty(Property* property); |
| 1405 | 1412 |
| 1413 // Populate the depth field and flags. |
| 1414 void InitDepthAndFlags(); |
| 1415 |
| 1416 // Get the constant properties fixed array, populating it if necessary. |
| 1417 Handle<FixedArray> GetOrBuildConstantProperties(Isolate* isolate) { |
| 1418 if (constant_properties_.is_null()) { |
| 1419 BuildConstantProperties(isolate); |
| 1420 } |
| 1421 return constant_properties(); |
| 1422 } |
| 1423 |
| 1406 // Populate the constant properties fixed array. | 1424 // Populate the constant properties fixed array. |
| 1407 void BuildConstantProperties(Isolate* isolate); | 1425 void BuildConstantProperties(Isolate* isolate); |
| 1408 | 1426 |
| 1409 // Mark all computed expressions that are bound to a key that | 1427 // Mark all computed expressions that are bound to a key that |
| 1410 // is shadowed by a later occurrence of the same key. For the | 1428 // is shadowed by a later occurrence of the same key. For the |
| 1411 // marked expressions, no store code is emitted. | 1429 // marked expressions, no store code is emitted. |
| 1412 void CalculateEmitStore(Zone* zone); | 1430 void CalculateEmitStore(Zone* zone); |
| 1413 | 1431 |
| 1414 // Determines whether the {FastCloneShallowObject} builtin can be used. | 1432 // Determines whether the {FastCloneShallowObject} builtin can be used. |
| 1415 bool IsFastCloningSupported() const; | 1433 bool IsFastCloningSupported() const; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1444 | 1462 |
| 1445 // Return an AST id for a property that is used in simulate instructions. | 1463 // Return an AST id for a property that is used in simulate instructions. |
| 1446 BailoutId GetIdForPropertySet(int i) { return BailoutId(local_id(i + 1)); } | 1464 BailoutId GetIdForPropertySet(int i) { return BailoutId(local_id(i + 1)); } |
| 1447 | 1465 |
| 1448 // Unlike other AST nodes, this number of bailout IDs allocated for an | 1466 // Unlike other AST nodes, this number of bailout IDs allocated for an |
| 1449 // ObjectLiteral can vary, so num_ids() is not a static method. | 1467 // ObjectLiteral can vary, so num_ids() is not a static method. |
| 1450 int num_ids() const { return parent_num_ids() + 1 + properties()->length(); } | 1468 int num_ids() const { return parent_num_ids() + 1 + properties()->length(); } |
| 1451 | 1469 |
| 1452 // Object literals need one feedback slot for each non-trivial value, as well | 1470 // Object literals need one feedback slot for each non-trivial value, as well |
| 1453 // as some slots for home objects. | 1471 // as some slots for home objects. |
| 1454 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, | 1472 void AssignFeedbackVectorSlots(FeedbackVectorSpec* spec, |
| 1455 FeedbackVectorSlotCache* cache); | 1473 FeedbackVectorSlotCache* cache); |
| 1456 | 1474 |
| 1457 private: | 1475 private: |
| 1458 friend class AstNodeFactory; | 1476 friend class AstNodeFactory; |
| 1459 | 1477 |
| 1460 ObjectLiteral(ZoneList<Property*>* properties, int literal_index, | 1478 ObjectLiteral(ZoneList<Property*>* properties, int literal_index, |
| 1461 uint32_t boilerplate_properties, int pos) | 1479 uint32_t boilerplate_properties, int pos) |
| 1462 : MaterializedLiteral(literal_index, pos, kObjectLiteral), | 1480 : MaterializedLiteral(literal_index, pos, kObjectLiteral), |
| 1463 boilerplate_properties_(boilerplate_properties), | 1481 boilerplate_properties_(boilerplate_properties), |
| 1464 properties_(properties) { | 1482 properties_(properties) { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1543 | 1561 |
| 1544 BailoutId CreateLiteralId() const { return BailoutId(local_id(0)); } | 1562 BailoutId CreateLiteralId() const { return BailoutId(local_id(0)); } |
| 1545 | 1563 |
| 1546 // Return an AST id for an element that is used in simulate instructions. | 1564 // Return an AST id for an element that is used in simulate instructions. |
| 1547 BailoutId GetIdForElement(int i) { return BailoutId(local_id(i + 1)); } | 1565 BailoutId GetIdForElement(int i) { return BailoutId(local_id(i + 1)); } |
| 1548 | 1566 |
| 1549 // Unlike other AST nodes, this number of bailout IDs allocated for an | 1567 // Unlike other AST nodes, this number of bailout IDs allocated for an |
| 1550 // ArrayLiteral can vary, so num_ids() is not a static method. | 1568 // ArrayLiteral can vary, so num_ids() is not a static method. |
| 1551 int num_ids() const { return parent_num_ids() + 1 + values()->length(); } | 1569 int num_ids() const { return parent_num_ids() + 1 + values()->length(); } |
| 1552 | 1570 |
| 1571 // Populate the depth field and flags. |
| 1572 void InitDepthAndFlags(); |
| 1573 |
| 1574 // Get the constant elements fixed array, populating it if necessary. |
| 1575 Handle<ConstantElementsPair> GetOrBuildConstantElements(Isolate* isolate) { |
| 1576 if (constant_elements_.is_null()) { |
| 1577 BuildConstantElements(isolate); |
| 1578 } |
| 1579 return constant_elements(); |
| 1580 } |
| 1581 |
| 1553 // Populate the constant elements fixed array. | 1582 // Populate the constant elements fixed array. |
| 1554 void BuildConstantElements(Isolate* isolate); | 1583 void BuildConstantElements(Isolate* isolate); |
| 1555 | 1584 |
| 1556 // Determines whether the {FastCloneShallowArray} builtin can be used. | 1585 // Determines whether the {FastCloneShallowArray} builtin can be used. |
| 1557 bool IsFastCloningSupported() const; | 1586 bool IsFastCloningSupported() const; |
| 1558 | 1587 |
| 1559 // Assemble bitfield of flags for the CreateArrayLiteral helper. | 1588 // Assemble bitfield of flags for the CreateArrayLiteral helper. |
| 1560 int ComputeFlags(bool disable_mementos = false) const { | 1589 int ComputeFlags(bool disable_mementos = false) const { |
| 1561 int flags = depth() == 1 ? kShallowElements : kNoFlags; | 1590 int flags = depth() == 1 ? kShallowElements : kNoFlags; |
| 1562 if (disable_mementos) { | 1591 if (disable_mementos) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1577 values_->Rewind(first_spread_index_); | 1606 values_->Rewind(first_spread_index_); |
| 1578 first_spread_index_ = -1; | 1607 first_spread_index_ = -1; |
| 1579 } | 1608 } |
| 1580 | 1609 |
| 1581 enum Flags { | 1610 enum Flags { |
| 1582 kNoFlags = 0, | 1611 kNoFlags = 0, |
| 1583 kShallowElements = 1, | 1612 kShallowElements = 1, |
| 1584 kDisableMementos = 1 << 1 | 1613 kDisableMementos = 1 << 1 |
| 1585 }; | 1614 }; |
| 1586 | 1615 |
| 1587 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, | 1616 void AssignFeedbackVectorSlots(FeedbackVectorSpec* spec, |
| 1588 FeedbackVectorSlotCache* cache); | 1617 FeedbackVectorSlotCache* cache); |
| 1589 FeedbackVectorSlot LiteralFeedbackSlot() const { return literal_slot_; } | 1618 FeedbackVectorSlot LiteralFeedbackSlot() const { return literal_slot_; } |
| 1590 | 1619 |
| 1591 private: | 1620 private: |
| 1592 friend class AstNodeFactory; | 1621 friend class AstNodeFactory; |
| 1593 | 1622 |
| 1594 ArrayLiteral(ZoneList<Expression*>* values, int first_spread_index, | 1623 ArrayLiteral(ZoneList<Expression*>* values, int first_spread_index, |
| 1595 int literal_index, int pos) | 1624 int literal_index, int pos) |
| 1596 : MaterializedLiteral(literal_index, pos, kArrayLiteral), | 1625 : MaterializedLiteral(literal_index, pos, kArrayLiteral), |
| 1597 first_spread_index_(first_spread_index), | 1626 first_spread_index_(first_spread_index), |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1656 HoleCheckModeField::update(bit_field_, HoleCheckMode::kRequired); | 1685 HoleCheckModeField::update(bit_field_, HoleCheckMode::kRequired); |
| 1657 } | 1686 } |
| 1658 | 1687 |
| 1659 // Bind this proxy to the variable var. | 1688 // Bind this proxy to the variable var. |
| 1660 void BindTo(Variable* var); | 1689 void BindTo(Variable* var); |
| 1661 | 1690 |
| 1662 bool UsesVariableFeedbackSlot() const { | 1691 bool UsesVariableFeedbackSlot() const { |
| 1663 return var()->IsUnallocated() || var()->IsLookupSlot(); | 1692 return var()->IsUnallocated() || var()->IsLookupSlot(); |
| 1664 } | 1693 } |
| 1665 | 1694 |
| 1666 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, | 1695 void AssignFeedbackVectorSlots(FeedbackVectorSpec* spec, |
| 1667 FeedbackVectorSlotCache* cache); | 1696 FeedbackVectorSlotCache* cache); |
| 1668 | 1697 |
| 1669 FeedbackVectorSlot VariableFeedbackSlot() { return variable_feedback_slot_; } | 1698 FeedbackVectorSlot VariableFeedbackSlot() { return variable_feedback_slot_; } |
| 1670 | 1699 |
| 1671 static int num_ids() { return parent_num_ids() + 1; } | 1700 static int num_ids() { return parent_num_ids() + 1; } |
| 1672 BailoutId BeforeId() const { return BailoutId(local_id(0)); } | 1701 BailoutId BeforeId() const { return BailoutId(local_id(0)); } |
| 1673 void set_next_unresolved(VariableProxy* next) { next_unresolved_ = next; } | 1702 void set_next_unresolved(VariableProxy* next) { next_unresolved_ = next; } |
| 1674 VariableProxy* next_unresolved() { return next_unresolved_; } | 1703 VariableProxy* next_unresolved() { return next_unresolved_; } |
| 1675 | 1704 |
| 1676 private: | 1705 private: |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1752 void set_inline_cache_state(InlineCacheState state) { | 1781 void set_inline_cache_state(InlineCacheState state) { |
| 1753 bit_field_ = InlineCacheStateField::update(bit_field_, state); | 1782 bit_field_ = InlineCacheStateField::update(bit_field_, state); |
| 1754 } | 1783 } |
| 1755 void mark_for_call() { | 1784 void mark_for_call() { |
| 1756 bit_field_ = IsForCallField::update(bit_field_, true); | 1785 bit_field_ = IsForCallField::update(bit_field_, true); |
| 1757 } | 1786 } |
| 1758 bool is_for_call() const { return IsForCallField::decode(bit_field_); } | 1787 bool is_for_call() const { return IsForCallField::decode(bit_field_); } |
| 1759 | 1788 |
| 1760 bool IsSuperAccess() { return obj()->IsSuperPropertyReference(); } | 1789 bool IsSuperAccess() { return obj()->IsSuperPropertyReference(); } |
| 1761 | 1790 |
| 1762 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, | 1791 void AssignFeedbackVectorSlots(FeedbackVectorSpec* spec, |
| 1763 FeedbackVectorSlotCache* cache) { | 1792 FeedbackVectorSlotCache* cache) { |
| 1764 FeedbackVectorSlotKind kind = key()->IsPropertyName() | 1793 FeedbackVectorSlotKind kind = key()->IsPropertyName() |
| 1765 ? FeedbackVectorSlotKind::LOAD_IC | 1794 ? FeedbackVectorSlotKind::LOAD_IC |
| 1766 : FeedbackVectorSlotKind::KEYED_LOAD_IC; | 1795 : FeedbackVectorSlotKind::KEYED_LOAD_IC; |
| 1767 property_feedback_slot_ = spec->AddSlot(kind); | 1796 property_feedback_slot_ = spec->AddSlot(kind); |
| 1768 } | 1797 } |
| 1769 | 1798 |
| 1770 FeedbackVectorSlot PropertyFeedbackSlot() const { | 1799 FeedbackVectorSlot PropertyFeedbackSlot() const { |
| 1771 return property_feedback_slot_; | 1800 return property_feedback_slot_; |
| 1772 } | 1801 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1810 | 1839 |
| 1811 | 1840 |
| 1812 class Call final : public Expression { | 1841 class Call final : public Expression { |
| 1813 public: | 1842 public: |
| 1814 Expression* expression() const { return expression_; } | 1843 Expression* expression() const { return expression_; } |
| 1815 ZoneList<Expression*>* arguments() const { return arguments_; } | 1844 ZoneList<Expression*>* arguments() const { return arguments_; } |
| 1816 | 1845 |
| 1817 void set_expression(Expression* e) { expression_ = e; } | 1846 void set_expression(Expression* e) { expression_ = e; } |
| 1818 | 1847 |
| 1819 // Type feedback information. | 1848 // Type feedback information. |
| 1820 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, | 1849 void AssignFeedbackVectorSlots(FeedbackVectorSpec* spec, |
| 1821 FeedbackVectorSlotCache* cache); | 1850 FeedbackVectorSlotCache* cache); |
| 1822 | 1851 |
| 1823 FeedbackVectorSlot CallFeedbackICSlot() const { return ic_slot_; } | 1852 FeedbackVectorSlot CallFeedbackICSlot() const { return ic_slot_; } |
| 1824 | 1853 |
| 1825 SmallMapList* GetReceiverTypes() { | 1854 SmallMapList* GetReceiverTypes() { |
| 1826 if (expression()->IsProperty()) { | 1855 if (expression()->IsProperty()) { |
| 1827 return expression()->AsProperty()->GetReceiverTypes(); | 1856 return expression()->AsProperty()->GetReceiverTypes(); |
| 1828 } | 1857 } |
| 1829 return nullptr; | 1858 return nullptr; |
| 1830 } | 1859 } |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1928 | 1957 |
| 1929 | 1958 |
| 1930 class CallNew final : public Expression { | 1959 class CallNew final : public Expression { |
| 1931 public: | 1960 public: |
| 1932 Expression* expression() const { return expression_; } | 1961 Expression* expression() const { return expression_; } |
| 1933 ZoneList<Expression*>* arguments() const { return arguments_; } | 1962 ZoneList<Expression*>* arguments() const { return arguments_; } |
| 1934 | 1963 |
| 1935 void set_expression(Expression* e) { expression_ = e; } | 1964 void set_expression(Expression* e) { expression_ = e; } |
| 1936 | 1965 |
| 1937 // Type feedback information. | 1966 // Type feedback information. |
| 1938 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, | 1967 void AssignFeedbackVectorSlots(FeedbackVectorSpec* spec, |
| 1939 FeedbackVectorSlotCache* cache) { | 1968 FeedbackVectorSlotCache* cache) { |
| 1940 // CallNew stores feedback in the exact same way as Call. We can | 1969 // CallNew stores feedback in the exact same way as Call. We can |
| 1941 // piggyback on the type feedback infrastructure for calls. | 1970 // piggyback on the type feedback infrastructure for calls. |
| 1942 callnew_feedback_slot_ = spec->AddCallICSlot(); | 1971 callnew_feedback_slot_ = spec->AddCallICSlot(); |
| 1943 } | 1972 } |
| 1944 | 1973 |
| 1945 FeedbackVectorSlot CallNewFeedbackSlot() { | 1974 FeedbackVectorSlot CallNewFeedbackSlot() { |
| 1946 DCHECK(!callnew_feedback_slot_.IsInvalid()); | 1975 DCHECK(!callnew_feedback_slot_.IsInvalid()); |
| 1947 return callnew_feedback_slot_; | 1976 return callnew_feedback_slot_; |
| 1948 } | 1977 } |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2102 } | 2131 } |
| 2103 | 2132 |
| 2104 // The short-circuit logical operations need an AST ID for their | 2133 // The short-circuit logical operations need an AST ID for their |
| 2105 // right-hand subexpression. | 2134 // right-hand subexpression. |
| 2106 static int num_ids() { return parent_num_ids() + 2; } | 2135 static int num_ids() { return parent_num_ids() + 2; } |
| 2107 BailoutId RightId() const { return BailoutId(local_id(0)); } | 2136 BailoutId RightId() const { return BailoutId(local_id(0)); } |
| 2108 | 2137 |
| 2109 // BinaryOperation will have both a slot in the feedback vector and the | 2138 // BinaryOperation will have both a slot in the feedback vector and the |
| 2110 // TypeFeedbackId to record the type information. TypeFeedbackId is used | 2139 // TypeFeedbackId to record the type information. TypeFeedbackId is used |
| 2111 // by full codegen and the feedback vector slot is used by interpreter. | 2140 // by full codegen and the feedback vector slot is used by interpreter. |
| 2112 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, | 2141 void AssignFeedbackVectorSlots(FeedbackVectorSpec* spec, |
| 2113 FeedbackVectorSlotCache* cache); | 2142 FeedbackVectorSlotCache* cache); |
| 2114 | 2143 |
| 2115 FeedbackVectorSlot BinaryOperationFeedbackSlot() const { | 2144 FeedbackVectorSlot BinaryOperationFeedbackSlot() const { |
| 2116 return type_feedback_slot_; | 2145 return type_feedback_slot_; |
| 2117 } | 2146 } |
| 2118 | 2147 |
| 2119 TypeFeedbackId BinaryOperationFeedbackId() const { | 2148 TypeFeedbackId BinaryOperationFeedbackId() const { |
| 2120 return TypeFeedbackId(local_id(1)); | 2149 return TypeFeedbackId(local_id(1)); |
| 2121 } | 2150 } |
| 2122 Maybe<int> fixed_right_arg() const { | 2151 Maybe<int> fixed_right_arg() const { |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2195 } | 2224 } |
| 2196 TypeFeedbackId CountStoreFeedbackId() const { | 2225 TypeFeedbackId CountStoreFeedbackId() const { |
| 2197 return TypeFeedbackId(local_id(3)); | 2226 return TypeFeedbackId(local_id(3)); |
| 2198 } | 2227 } |
| 2199 | 2228 |
| 2200 // Feedback slot for binary operation is only used by ignition. | 2229 // Feedback slot for binary operation is only used by ignition. |
| 2201 FeedbackVectorSlot CountBinaryOpFeedbackSlot() const { | 2230 FeedbackVectorSlot CountBinaryOpFeedbackSlot() const { |
| 2202 return binary_operation_slot_; | 2231 return binary_operation_slot_; |
| 2203 } | 2232 } |
| 2204 | 2233 |
| 2205 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, | 2234 void AssignFeedbackVectorSlots(FeedbackVectorSpec* spec, |
| 2206 FeedbackVectorSlotCache* cache); | 2235 FeedbackVectorSlotCache* cache); |
| 2207 FeedbackVectorSlot CountSlot() const { return slot_; } | 2236 FeedbackVectorSlot CountSlot() const { return slot_; } |
| 2208 | 2237 |
| 2209 private: | 2238 private: |
| 2210 friend class AstNodeFactory; | 2239 friend class AstNodeFactory; |
| 2211 | 2240 |
| 2212 CountOperation(Token::Value op, bool is_prefix, Expression* expr, int pos) | 2241 CountOperation(Token::Value op, bool is_prefix, Expression* expr, int pos) |
| 2213 : Expression(pos, kCountOperation), type_(NULL), expression_(expr) { | 2242 : Expression(pos, kCountOperation), type_(NULL), expression_(expr) { |
| 2214 bit_field_ |= | 2243 bit_field_ |= |
| 2215 IsPrefixField::encode(is_prefix) | KeyTypeField::encode(ELEMENT) | | 2244 IsPrefixField::encode(is_prefix) | KeyTypeField::encode(ELEMENT) | |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2247 static int num_ids() { return parent_num_ids() + 1; } | 2276 static int num_ids() { return parent_num_ids() + 1; } |
| 2248 TypeFeedbackId CompareOperationFeedbackId() const { | 2277 TypeFeedbackId CompareOperationFeedbackId() const { |
| 2249 return TypeFeedbackId(local_id(0)); | 2278 return TypeFeedbackId(local_id(0)); |
| 2250 } | 2279 } |
| 2251 AstType* combined_type() const { return combined_type_; } | 2280 AstType* combined_type() const { return combined_type_; } |
| 2252 void set_combined_type(AstType* type) { combined_type_ = type; } | 2281 void set_combined_type(AstType* type) { combined_type_ = type; } |
| 2253 | 2282 |
| 2254 // CompareOperation will have both a slot in the feedback vector and the | 2283 // CompareOperation will have both a slot in the feedback vector and the |
| 2255 // TypeFeedbackId to record the type information. TypeFeedbackId is used | 2284 // TypeFeedbackId to record the type information. TypeFeedbackId is used |
| 2256 // by full codegen and the feedback vector slot is used by interpreter. | 2285 // by full codegen and the feedback vector slot is used by interpreter. |
| 2257 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, | 2286 void AssignFeedbackVectorSlots(FeedbackVectorSpec* spec, |
| 2258 FeedbackVectorSlotCache* cache); | 2287 FeedbackVectorSlotCache* cache); |
| 2259 | 2288 |
| 2260 FeedbackVectorSlot CompareOperationFeedbackSlot() const { | 2289 FeedbackVectorSlot CompareOperationFeedbackSlot() const { |
| 2261 return type_feedback_slot_; | 2290 return type_feedback_slot_; |
| 2262 } | 2291 } |
| 2263 | 2292 |
| 2264 // Match special cases. | 2293 // Match special cases. |
| 2265 bool IsLiteralCompareTypeof(Expression** expr, Handle<String>* check); | 2294 bool IsLiteralCompareTypeof(Expression** expr, Handle<String>* check); |
| 2266 bool IsLiteralCompareUndefined(Expression** expr); | 2295 bool IsLiteralCompareUndefined(Expression** expr); |
| 2267 bool IsLiteralCompareNull(Expression** expr); | 2296 bool IsLiteralCompareNull(Expression** expr); |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2393 void set_is_uninitialized(bool b) { | 2422 void set_is_uninitialized(bool b) { |
| 2394 bit_field_ = IsUninitializedField::update(bit_field_, b); | 2423 bit_field_ = IsUninitializedField::update(bit_field_, b); |
| 2395 } | 2424 } |
| 2396 void set_key_type(IcCheckType key_type) { | 2425 void set_key_type(IcCheckType key_type) { |
| 2397 bit_field_ = KeyTypeField::update(bit_field_, key_type); | 2426 bit_field_ = KeyTypeField::update(bit_field_, key_type); |
| 2398 } | 2427 } |
| 2399 void set_store_mode(KeyedAccessStoreMode mode) { | 2428 void set_store_mode(KeyedAccessStoreMode mode) { |
| 2400 bit_field_ = StoreModeField::update(bit_field_, mode); | 2429 bit_field_ = StoreModeField::update(bit_field_, mode); |
| 2401 } | 2430 } |
| 2402 | 2431 |
| 2403 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, | 2432 void AssignFeedbackVectorSlots(FeedbackVectorSpec* spec, |
| 2404 FeedbackVectorSlotCache* cache); | 2433 FeedbackVectorSlotCache* cache); |
| 2405 FeedbackVectorSlot AssignmentSlot() const { return slot_; } | 2434 FeedbackVectorSlot AssignmentSlot() const { return slot_; } |
| 2406 | 2435 |
| 2407 private: | 2436 private: |
| 2408 friend class AstNodeFactory; | 2437 friend class AstNodeFactory; |
| 2409 | 2438 |
| 2410 Assignment(Token::Value op, Expression* target, Expression* value, int pos); | 2439 Assignment(Token::Value op, Expression* target, Expression* value, int pos); |
| 2411 | 2440 |
| 2412 static int parent_num_ids() { return Expression::num_ids(); } | 2441 static int parent_num_ids() { return Expression::num_ids(); } |
| 2413 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 2442 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2560 int SourceSize() const { return end_position() - start_position(); } | 2589 int SourceSize() const { return end_position() - start_position(); } |
| 2561 bool is_declaration() const { return function_type() == kDeclaration; } | 2590 bool is_declaration() const { return function_type() == kDeclaration; } |
| 2562 bool is_named_expression() const { | 2591 bool is_named_expression() const { |
| 2563 return function_type() == kNamedExpression; | 2592 return function_type() == kNamedExpression; |
| 2564 } | 2593 } |
| 2565 bool is_anonymous_expression() const { | 2594 bool is_anonymous_expression() const { |
| 2566 return function_type() == kAnonymousExpression; | 2595 return function_type() == kAnonymousExpression; |
| 2567 } | 2596 } |
| 2568 LanguageMode language_mode() const; | 2597 LanguageMode language_mode() const; |
| 2569 | 2598 |
| 2570 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, | 2599 void AssignFeedbackVectorSlots(FeedbackVectorSpec* spec, |
| 2571 FeedbackVectorSlotCache* cache) { | 2600 FeedbackVectorSlotCache* cache) { |
| 2572 // The + 1 is because we need an array with room for the literals | 2601 // The + 1 is because we need an array with room for the literals |
| 2573 // as well as the feedback vector. | 2602 // as well as the feedback vector. |
| 2574 literal_feedback_slot_ = | 2603 literal_feedback_slot_ = |
| 2575 spec->AddCreateClosureSlot(materialized_literal_count_ + 1); | 2604 spec->AddCreateClosureSlot(materialized_literal_count_ + 1); |
| 2576 } | 2605 } |
| 2577 | 2606 |
| 2578 FeedbackVectorSlot LiteralFeedbackSlot() const { | 2607 FeedbackVectorSlot LiteralFeedbackSlot() const { |
| 2579 return literal_feedback_slot_; | 2608 return literal_feedback_slot_; |
| 2580 } | 2609 } |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2779 int end_position() const { return end_position_; } | 2808 int end_position() const { return end_position_; } |
| 2780 bool has_name_static_property() const { | 2809 bool has_name_static_property() const { |
| 2781 return HasNameStaticProperty::decode(bit_field_); | 2810 return HasNameStaticProperty::decode(bit_field_); |
| 2782 } | 2811 } |
| 2783 bool has_static_computed_names() const { | 2812 bool has_static_computed_names() const { |
| 2784 return HasStaticComputedNames::decode(bit_field_); | 2813 return HasStaticComputedNames::decode(bit_field_); |
| 2785 } | 2814 } |
| 2786 | 2815 |
| 2787 // Object literals need one feedback slot for each non-trivial value, as well | 2816 // Object literals need one feedback slot for each non-trivial value, as well |
| 2788 // as some slots for home objects. | 2817 // as some slots for home objects. |
| 2789 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, | 2818 void AssignFeedbackVectorSlots(FeedbackVectorSpec* spec, |
| 2790 FeedbackVectorSlotCache* cache); | 2819 FeedbackVectorSlotCache* cache); |
| 2791 | 2820 |
| 2792 bool NeedsProxySlot() const { | 2821 bool NeedsProxySlot() const { |
| 2793 return class_variable_proxy() != nullptr && | 2822 return class_variable_proxy() != nullptr && |
| 2794 class_variable_proxy()->var()->IsUnallocated(); | 2823 class_variable_proxy()->var()->IsUnallocated(); |
| 2795 } | 2824 } |
| 2796 | 2825 |
| 2797 FeedbackVectorSlot HomeObjectSlot() const { return home_object_slot_; } | 2826 FeedbackVectorSlot HomeObjectSlot() const { return home_object_slot_; } |
| 2798 FeedbackVectorSlot ProxySlot() const { return proxy_slot_; } | 2827 FeedbackVectorSlot ProxySlot() const { return proxy_slot_; } |
| 2799 | 2828 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 2830 | 2859 |
| 2831 | 2860 |
| 2832 class NativeFunctionLiteral final : public Expression { | 2861 class NativeFunctionLiteral final : public Expression { |
| 2833 public: | 2862 public: |
| 2834 Handle<String> name() const { return name_->string(); } | 2863 Handle<String> name() const { return name_->string(); } |
| 2835 v8::Extension* extension() const { return extension_; } | 2864 v8::Extension* extension() const { return extension_; } |
| 2836 FeedbackVectorSlot LiteralFeedbackSlot() const { | 2865 FeedbackVectorSlot LiteralFeedbackSlot() const { |
| 2837 return literal_feedback_slot_; | 2866 return literal_feedback_slot_; |
| 2838 } | 2867 } |
| 2839 | 2868 |
| 2840 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, | 2869 void AssignFeedbackVectorSlots(FeedbackVectorSpec* spec, |
| 2841 FeedbackVectorSlotCache* cache) { | 2870 FeedbackVectorSlotCache* cache) { |
| 2842 // 0 is a magic number here. It means we are holding the literals | 2871 // 0 is a magic number here. It means we are holding the literals |
| 2843 // array for a native function literal, which needs to be | 2872 // array for a native function literal, which needs to be |
| 2844 // the empty literals array. | 2873 // the empty literals array. |
| 2845 // TODO(mvstanton): The FeedbackVectorSlotCache can be adapted | 2874 // TODO(mvstanton): The FeedbackVectorSlotCache can be adapted |
| 2846 // to always return the same slot for this case. | 2875 // to always return the same slot for this case. |
| 2847 literal_feedback_slot_ = spec->AddCreateClosureSlot(0); | 2876 literal_feedback_slot_ = spec->AddCreateClosureSlot(0); |
| 2848 } | 2877 } |
| 2849 | 2878 |
| 2850 private: | 2879 private: |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2935 // (defined at https://tc39.github.io/ecma262/#sec-getiterator). Ignition | 2964 // (defined at https://tc39.github.io/ecma262/#sec-getiterator). Ignition |
| 2936 // desugars this into a LoadIC / JSLoadNamed, CallIC, and a type-check to | 2965 // desugars this into a LoadIC / JSLoadNamed, CallIC, and a type-check to |
| 2937 // validate return value of the Symbol.iterator() call. | 2966 // validate return value of the Symbol.iterator() call. |
| 2938 class GetIterator final : public Expression { | 2967 class GetIterator final : public Expression { |
| 2939 public: | 2968 public: |
| 2940 Expression* iterable() const { return iterable_; } | 2969 Expression* iterable() const { return iterable_; } |
| 2941 void set_iterable(Expression* iterable) { iterable_ = iterable; } | 2970 void set_iterable(Expression* iterable) { iterable_ = iterable; } |
| 2942 | 2971 |
| 2943 static int num_ids() { return parent_num_ids(); } | 2972 static int num_ids() { return parent_num_ids(); } |
| 2944 | 2973 |
| 2945 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, | 2974 void AssignFeedbackVectorSlots(FeedbackVectorSpec* spec, |
| 2946 FeedbackVectorSlotCache* cache) { | 2975 FeedbackVectorSlotCache* cache) { |
| 2947 iterator_property_feedback_slot_ = | 2976 iterator_property_feedback_slot_ = |
| 2948 spec->AddSlot(FeedbackVectorSlotKind::LOAD_IC); | 2977 spec->AddSlot(FeedbackVectorSlotKind::LOAD_IC); |
| 2949 iterator_call_feedback_slot_ = | 2978 iterator_call_feedback_slot_ = |
| 2950 spec->AddSlot(FeedbackVectorSlotKind::CALL_IC); | 2979 spec->AddSlot(FeedbackVectorSlotKind::CALL_IC); |
| 2951 } | 2980 } |
| 2952 | 2981 |
| 2953 FeedbackVectorSlot IteratorPropertyFeedbackSlot() const { | 2982 FeedbackVectorSlot IteratorPropertyFeedbackSlot() const { |
| 2954 return iterator_property_feedback_slot_; | 2983 return iterator_property_feedback_slot_; |
| 2955 } | 2984 } |
| (...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3617 : NULL; \ | 3646 : NULL; \ |
| 3618 } | 3647 } |
| 3619 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) | 3648 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) |
| 3620 #undef DECLARE_NODE_FUNCTIONS | 3649 #undef DECLARE_NODE_FUNCTIONS |
| 3621 | 3650 |
| 3622 | 3651 |
| 3623 } // namespace internal | 3652 } // namespace internal |
| 3624 } // namespace v8 | 3653 } // namespace v8 |
| 3625 | 3654 |
| 3626 #endif // V8_AST_AST_H_ | 3655 #endif // V8_AST_AST_H_ |
| OLD | NEW |