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 907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
918 V(GlobalObject) \ | 918 V(GlobalObject) \ |
919 V(JSGlobalObject) \ | 919 V(JSGlobalObject) \ |
920 V(JSBuiltinsObject) \ | 920 V(JSBuiltinsObject) \ |
921 V(JSGlobalProxy) \ | 921 V(JSGlobalProxy) \ |
922 V(UndetectableObject) \ | 922 V(UndetectableObject) \ |
923 V(AccessCheckNeeded) \ | 923 V(AccessCheckNeeded) \ |
924 V(JSGlobalPropertyCell) \ | 924 V(JSGlobalPropertyCell) \ |
925 V(ObjectHashTable) \ | 925 V(ObjectHashTable) \ |
926 | 926 |
927 | 927 |
928 class JSReceiver; | |
929 | |
930 // Object is the abstract superclass for all classes in the | 928 // Object is the abstract superclass for all classes in the |
931 // object hierarchy. | 929 // object hierarchy. |
932 // Object does not use any virtual functions to avoid the | 930 // Object does not use any virtual functions to avoid the |
933 // allocation of the C++ vtable. | 931 // allocation of the C++ vtable. |
934 // Since Smi and Failure are subclasses of Object no | 932 // Since Smi and Failure are subclasses of Object no |
935 // data members can be present in Object. | 933 // data members can be present in Object. |
936 class Object : public MaybeObject { | 934 class Object : public MaybeObject { |
937 public: | 935 public: |
938 // Type testing. | 936 // Type testing. |
939 bool IsObject() { return true; } | 937 bool IsObject() { return true; } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
984 Object* ToBoolean(); // ECMA-262 9.2. | 982 Object* ToBoolean(); // ECMA-262 9.2. |
985 | 983 |
986 // Convert to a JSObject if needed. | 984 // Convert to a JSObject if needed. |
987 // native_context is used when creating wrapper object. | 985 // native_context is used when creating wrapper object. |
988 MUST_USE_RESULT MaybeObject* ToObject(Context* native_context); | 986 MUST_USE_RESULT MaybeObject* ToObject(Context* native_context); |
989 | 987 |
990 // Converts this to a Smi if possible. | 988 // Converts this to a Smi if possible. |
991 // Failure is returned otherwise. | 989 // Failure is returned otherwise. |
992 MUST_USE_RESULT inline MaybeObject* ToSmi(); | 990 MUST_USE_RESULT inline MaybeObject* ToSmi(); |
993 | 991 |
994 void Lookup(String* name, LookupResult* result); | 992 void Lookup(Name* name, LookupResult* result); |
995 | 993 |
996 // Property access. | 994 // Property access. |
997 MUST_USE_RESULT inline MaybeObject* GetProperty(String* key); | 995 MUST_USE_RESULT inline MaybeObject* GetProperty(Name* key); |
998 MUST_USE_RESULT inline MaybeObject* GetProperty( | 996 MUST_USE_RESULT inline MaybeObject* GetProperty( |
999 String* key, | 997 Name* key, |
1000 PropertyAttributes* attributes); | 998 PropertyAttributes* attributes); |
1001 MUST_USE_RESULT MaybeObject* GetPropertyWithReceiver( | 999 MUST_USE_RESULT MaybeObject* GetPropertyWithReceiver( |
1002 Object* receiver, | 1000 Object* receiver, |
1003 String* key, | 1001 Name* key, |
1004 PropertyAttributes* attributes); | 1002 PropertyAttributes* attributes); |
1005 | 1003 |
1006 static Handle<Object> GetProperty(Handle<Object> object, Handle<String> key); | 1004 static Handle<Object> GetProperty(Handle<Object> object, Handle<Name> key); |
1007 static Handle<Object> GetProperty(Handle<Object> object, | 1005 static Handle<Object> GetProperty(Handle<Object> object, |
1008 Handle<Object> receiver, | 1006 Handle<Object> receiver, |
1009 LookupResult* result, | 1007 LookupResult* result, |
1010 Handle<String> key, | 1008 Handle<Name> key, |
1011 PropertyAttributes* attributes); | 1009 PropertyAttributes* attributes); |
1012 | 1010 |
1013 MUST_USE_RESULT MaybeObject* GetProperty(Object* receiver, | 1011 MUST_USE_RESULT MaybeObject* GetProperty(Object* receiver, |
1014 LookupResult* result, | 1012 LookupResult* result, |
1015 String* key, | 1013 Name* key, |
1016 PropertyAttributes* attributes); | 1014 PropertyAttributes* attributes); |
1017 | 1015 |
1018 MUST_USE_RESULT MaybeObject* GetPropertyWithDefinedGetter(Object* receiver, | 1016 MUST_USE_RESULT MaybeObject* GetPropertyWithDefinedGetter(Object* receiver, |
1019 JSReceiver* getter); | 1017 JSReceiver* getter); |
1020 | 1018 |
1021 static Handle<Object> GetElement(Handle<Object> object, uint32_t index); | 1019 static Handle<Object> GetElement(Handle<Object> object, uint32_t index); |
1022 MUST_USE_RESULT inline MaybeObject* GetElement(uint32_t index); | 1020 MUST_USE_RESULT inline MaybeObject* GetElement(uint32_t index); |
1023 // For use when we know that no exception can be thrown. | 1021 // For use when we know that no exception can be thrown. |
1024 inline Object* GetElementNoExceptionThrown(uint32_t index); | 1022 inline Object* GetElementNoExceptionThrown(uint32_t index); |
1025 MUST_USE_RESULT MaybeObject* GetElementWithReceiver(Object* receiver, | 1023 MUST_USE_RESULT MaybeObject* GetElementWithReceiver(Object* receiver, |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1472 // be added even though the receiver is non-extensible. | 1470 // be added even though the receiver is non-extensible. |
1473 enum ExtensibilityCheck { | 1471 enum ExtensibilityCheck { |
1474 PERFORM_EXTENSIBILITY_CHECK, | 1472 PERFORM_EXTENSIBILITY_CHECK, |
1475 OMIT_EXTENSIBILITY_CHECK | 1473 OMIT_EXTENSIBILITY_CHECK |
1476 }; | 1474 }; |
1477 | 1475 |
1478 // Casting. | 1476 // Casting. |
1479 static inline JSReceiver* cast(Object* obj); | 1477 static inline JSReceiver* cast(Object* obj); |
1480 | 1478 |
1481 static Handle<Object> SetProperty(Handle<JSReceiver> object, | 1479 static Handle<Object> SetProperty(Handle<JSReceiver> object, |
1482 Handle<String> key, | 1480 Handle<Name> key, |
1483 Handle<Object> value, | 1481 Handle<Object> value, |
1484 PropertyAttributes attributes, | 1482 PropertyAttributes attributes, |
1485 StrictModeFlag strict_mode); | 1483 StrictModeFlag strict_mode); |
1486 // Can cause GC. | 1484 // Can cause GC. |
1487 MUST_USE_RESULT MaybeObject* SetProperty( | 1485 MUST_USE_RESULT MaybeObject* SetProperty( |
1488 String* key, | 1486 Name* key, |
1489 Object* value, | 1487 Object* value, |
1490 PropertyAttributes attributes, | 1488 PropertyAttributes attributes, |
1491 StrictModeFlag strict_mode, | 1489 StrictModeFlag strict_mode, |
1492 StoreFromKeyed store_from_keyed = MAY_BE_STORE_FROM_KEYED); | 1490 StoreFromKeyed store_from_keyed = MAY_BE_STORE_FROM_KEYED); |
1493 MUST_USE_RESULT MaybeObject* SetProperty( | 1491 MUST_USE_RESULT MaybeObject* SetProperty( |
1494 LookupResult* result, | 1492 LookupResult* result, |
1495 String* key, | 1493 Name* key, |
1496 Object* value, | 1494 Object* value, |
1497 PropertyAttributes attributes, | 1495 PropertyAttributes attributes, |
1498 StrictModeFlag strict_mode, | 1496 StrictModeFlag strict_mode, |
1499 StoreFromKeyed store_from_keyed = MAY_BE_STORE_FROM_KEYED); | 1497 StoreFromKeyed store_from_keyed = MAY_BE_STORE_FROM_KEYED); |
1500 MUST_USE_RESULT MaybeObject* SetPropertyWithDefinedSetter(JSReceiver* setter, | 1498 MUST_USE_RESULT MaybeObject* SetPropertyWithDefinedSetter(JSReceiver* setter, |
1501 Object* value); | 1499 Object* value); |
1502 | 1500 |
1503 MUST_USE_RESULT MaybeObject* DeleteProperty(String* name, DeleteMode mode); | 1501 MUST_USE_RESULT MaybeObject* DeleteProperty(Name* name, DeleteMode mode); |
1504 MUST_USE_RESULT MaybeObject* DeleteElement(uint32_t index, DeleteMode mode); | 1502 MUST_USE_RESULT MaybeObject* DeleteElement(uint32_t index, DeleteMode mode); |
1505 | 1503 |
1506 // Set the index'th array element. | 1504 // Set the index'th array element. |
1507 // Can cause GC, or return failure if GC is required. | 1505 // Can cause GC, or return failure if GC is required. |
1508 MUST_USE_RESULT MaybeObject* SetElement(uint32_t index, | 1506 MUST_USE_RESULT MaybeObject* SetElement(uint32_t index, |
1509 Object* value, | 1507 Object* value, |
1510 PropertyAttributes attributes, | 1508 PropertyAttributes attributes, |
1511 StrictModeFlag strict_mode, | 1509 StrictModeFlag strict_mode, |
1512 bool check_prototype); | 1510 bool check_prototype); |
1513 | 1511 |
1514 // Tests for the fast common case for property enumeration. | 1512 // Tests for the fast common case for property enumeration. |
1515 bool IsSimpleEnum(); | 1513 bool IsSimpleEnum(); |
1516 | 1514 |
1517 // Returns the class name ([[Class]] property in the specification). | 1515 // Returns the class name ([[Class]] property in the specification). |
1518 String* class_name(); | 1516 String* class_name(); |
1519 | 1517 |
1520 // Returns the constructor name (the name (possibly, inferred name) of the | 1518 // Returns the constructor name (the name (possibly, inferred name) of the |
1521 // function that was used to instantiate the object). | 1519 // function that was used to instantiate the object). |
1522 String* constructor_name(); | 1520 String* constructor_name(); |
1523 | 1521 |
1524 inline PropertyAttributes GetPropertyAttribute(String* name); | 1522 inline PropertyAttributes GetPropertyAttribute(Name* name); |
1525 PropertyAttributes GetPropertyAttributeWithReceiver(JSReceiver* receiver, | 1523 PropertyAttributes GetPropertyAttributeWithReceiver(JSReceiver* receiver, |
1526 String* name); | 1524 Name* name); |
1527 PropertyAttributes GetLocalPropertyAttribute(String* name); | 1525 PropertyAttributes GetLocalPropertyAttribute(Name* name); |
1528 | 1526 |
1529 inline PropertyAttributes GetElementAttribute(uint32_t index); | 1527 inline PropertyAttributes GetElementAttribute(uint32_t index); |
1530 inline PropertyAttributes GetLocalElementAttribute(uint32_t index); | 1528 inline PropertyAttributes GetLocalElementAttribute(uint32_t index); |
1531 | 1529 |
1532 // Can cause a GC. | 1530 // Can cause a GC. |
1533 inline bool HasProperty(String* name); | 1531 inline bool HasProperty(Name* name); |
1534 inline bool HasLocalProperty(String* name); | 1532 inline bool HasLocalProperty(Name* name); |
1535 inline bool HasElement(uint32_t index); | 1533 inline bool HasElement(uint32_t index); |
1536 inline bool HasLocalElement(uint32_t index); | 1534 inline bool HasLocalElement(uint32_t index); |
1537 | 1535 |
1538 // Return the object's prototype (might be Heap::null_value()). | 1536 // Return the object's prototype (might be Heap::null_value()). |
1539 inline Object* GetPrototype(); | 1537 inline Object* GetPrototype(); |
1540 | 1538 |
1541 // Return the constructor function (may be Heap::null_value()). | 1539 // Return the constructor function (may be Heap::null_value()). |
1542 inline Object* GetConstructor(); | 1540 inline Object* GetConstructor(); |
1543 | 1541 |
1544 // Set the object's prototype (only JSReceiver and null are allowed). | 1542 // Set the object's prototype (only JSReceiver and null are allowed). |
1545 MUST_USE_RESULT MaybeObject* SetPrototype(Object* value, | 1543 MUST_USE_RESULT MaybeObject* SetPrototype(Object* value, |
1546 bool skip_hidden_prototypes); | 1544 bool skip_hidden_prototypes); |
1547 | 1545 |
1548 // Retrieves a permanent object identity hash code. The undefined value might | 1546 // Retrieves a permanent object identity hash code. The undefined value might |
1549 // be returned in case no hash was created yet and OMIT_CREATION was used. | 1547 // be returned in case no hash was created yet and OMIT_CREATION was used. |
1550 inline MUST_USE_RESULT MaybeObject* GetIdentityHash(CreationFlag flag); | 1548 inline MUST_USE_RESULT MaybeObject* GetIdentityHash(CreationFlag flag); |
1551 | 1549 |
1552 // Lookup a property. If found, the result is valid and has | 1550 // Lookup a property. If found, the result is valid and has |
1553 // detailed information. | 1551 // detailed information. |
1554 void LocalLookup(String* name, LookupResult* result, | 1552 void LocalLookup(Name* name, LookupResult* result, |
1555 bool search_hidden_prototypes = false); | 1553 bool search_hidden_prototypes = false); |
1556 void Lookup(String* name, LookupResult* result); | 1554 void Lookup(Name* name, LookupResult* result); |
1557 | 1555 |
1558 protected: | 1556 protected: |
1559 Smi* GenerateIdentityHash(); | 1557 Smi* GenerateIdentityHash(); |
1560 | 1558 |
1561 private: | 1559 private: |
1562 PropertyAttributes GetPropertyAttributeForResult(JSReceiver* receiver, | 1560 PropertyAttributes GetPropertyAttributeForResult(JSReceiver* receiver, |
1563 LookupResult* result, | 1561 LookupResult* result, |
1564 String* name, | 1562 Name* name, |
1565 bool continue_search); | 1563 bool continue_search); |
1566 | 1564 |
1567 DISALLOW_IMPLICIT_CONSTRUCTORS(JSReceiver); | 1565 DISALLOW_IMPLICIT_CONSTRUCTORS(JSReceiver); |
1568 }; | 1566 }; |
1569 | 1567 |
1570 // The JSObject describes real heap allocated JavaScript objects with | 1568 // The JSObject describes real heap allocated JavaScript objects with |
1571 // properties. | 1569 // properties. |
1572 // Note that the map of JSObject changes during execution to enable inline | 1570 // Note that the map of JSObject changes during execution to enable inline |
1573 // caching. | 1571 // caching. |
1574 class JSObject: public JSReceiver { | 1572 class JSObject: public JSReceiver { |
1575 public: | 1573 public: |
1576 // [properties]: Backing storage for properties. | 1574 // [properties]: Backing storage for properties. |
1577 // properties is a FixedArray in the fast case and a Dictionary in the | 1575 // properties is a FixedArray in the fast case and a Dictionary in the |
1578 // slow case. | 1576 // slow case. |
1579 DECL_ACCESSORS(properties, FixedArray) // Get and set fast properties. | 1577 DECL_ACCESSORS(properties, FixedArray) // Get and set fast properties. |
1580 inline void initialize_properties(); | 1578 inline void initialize_properties(); |
1581 inline bool HasFastProperties(); | 1579 inline bool HasFastProperties(); |
1582 inline StringDictionary* property_dictionary(); // Gets slow properties. | 1580 inline NameDictionary* property_dictionary(); // Gets slow properties. |
1583 | 1581 |
1584 // [elements]: The elements (properties with names that are integers). | 1582 // [elements]: The elements (properties with names that are integers). |
1585 // | 1583 // |
1586 // Elements can be in two general modes: fast and slow. Each mode | 1584 // Elements can be in two general modes: fast and slow. Each mode |
1587 // corrensponds to a set of object representations of elements that | 1585 // corrensponds to a set of object representations of elements that |
1588 // have something in common. | 1586 // have something in common. |
1589 // | 1587 // |
1590 // In the fast mode elements is a FixedArray and so each element can | 1588 // In the fast mode elements is a FixedArray and so each element can |
1591 // be quickly accessed. This fact is used in the generated code. The | 1589 // be quickly accessed. This fact is used in the generated code. The |
1592 // elements array can have one of three maps in this mode: | 1590 // elements array can have one of three maps in this mode: |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1646 // Collects elements starting at index 0. | 1644 // Collects elements starting at index 0. |
1647 // Undefined values are placed after non-undefined values. | 1645 // Undefined values are placed after non-undefined values. |
1648 // Returns the number of non-undefined values. | 1646 // Returns the number of non-undefined values. |
1649 MUST_USE_RESULT MaybeObject* PrepareElementsForSort(uint32_t limit); | 1647 MUST_USE_RESULT MaybeObject* PrepareElementsForSort(uint32_t limit); |
1650 // As PrepareElementsForSort, but only on objects where elements is | 1648 // As PrepareElementsForSort, but only on objects where elements is |
1651 // a dictionary, and it will stay a dictionary. | 1649 // a dictionary, and it will stay a dictionary. |
1652 MUST_USE_RESULT MaybeObject* PrepareSlowElementsForSort(uint32_t limit); | 1650 MUST_USE_RESULT MaybeObject* PrepareSlowElementsForSort(uint32_t limit); |
1653 | 1651 |
1654 MUST_USE_RESULT MaybeObject* GetPropertyWithCallback(Object* receiver, | 1652 MUST_USE_RESULT MaybeObject* GetPropertyWithCallback(Object* receiver, |
1655 Object* structure, | 1653 Object* structure, |
1656 String* name); | 1654 Name* name); |
1657 | 1655 |
1658 // Can cause GC. | 1656 // Can cause GC. |
1659 MUST_USE_RESULT MaybeObject* SetPropertyForResult(LookupResult* result, | 1657 MUST_USE_RESULT MaybeObject* SetPropertyForResult(LookupResult* result, |
1660 String* key, | 1658 Name* key, |
1661 Object* value, | 1659 Object* value, |
1662 PropertyAttributes attributes, | 1660 PropertyAttributes attributes, |
1663 StrictModeFlag strict_mode, | 1661 StrictModeFlag strict_mode, |
1664 StoreFromKeyed store_mode); | 1662 StoreFromKeyed store_mode); |
1665 MUST_USE_RESULT MaybeObject* SetPropertyWithFailedAccessCheck( | 1663 MUST_USE_RESULT MaybeObject* SetPropertyWithFailedAccessCheck( |
1666 LookupResult* result, | 1664 LookupResult* result, |
1667 String* name, | 1665 Name* name, |
1668 Object* value, | 1666 Object* value, |
1669 bool check_prototype, | 1667 bool check_prototype, |
1670 StrictModeFlag strict_mode); | 1668 StrictModeFlag strict_mode); |
1671 MUST_USE_RESULT MaybeObject* SetPropertyWithCallback( | 1669 MUST_USE_RESULT MaybeObject* SetPropertyWithCallback( |
1672 Object* structure, | 1670 Object* structure, |
1673 String* name, | 1671 Name* name, |
1674 Object* value, | 1672 Object* value, |
1675 JSObject* holder, | 1673 JSObject* holder, |
1676 StrictModeFlag strict_mode); | 1674 StrictModeFlag strict_mode); |
1677 MUST_USE_RESULT MaybeObject* SetPropertyWithInterceptor( | 1675 MUST_USE_RESULT MaybeObject* SetPropertyWithInterceptor( |
1678 String* name, | 1676 Name* name, |
1679 Object* value, | 1677 Object* value, |
1680 PropertyAttributes attributes, | 1678 PropertyAttributes attributes, |
1681 StrictModeFlag strict_mode); | 1679 StrictModeFlag strict_mode); |
1682 MUST_USE_RESULT MaybeObject* SetPropertyPostInterceptor( | 1680 MUST_USE_RESULT MaybeObject* SetPropertyPostInterceptor( |
1683 String* name, | 1681 Name* name, |
1684 Object* value, | 1682 Object* value, |
1685 PropertyAttributes attributes, | 1683 PropertyAttributes attributes, |
1686 StrictModeFlag strict_mode, | 1684 StrictModeFlag strict_mode, |
1687 ExtensibilityCheck extensibility_check); | 1685 ExtensibilityCheck extensibility_check); |
1688 | 1686 |
1689 static Handle<Object> SetLocalPropertyIgnoreAttributes( | 1687 static Handle<Object> SetLocalPropertyIgnoreAttributes( |
1690 Handle<JSObject> object, | 1688 Handle<JSObject> object, |
1691 Handle<String> key, | 1689 Handle<Name> key, |
1692 Handle<Object> value, | 1690 Handle<Object> value, |
1693 PropertyAttributes attributes); | 1691 PropertyAttributes attributes); |
1694 | 1692 |
1695 // Try to follow an existing transition to a field with attributes NONE. The | 1693 // Try to follow an existing transition to a field with attributes NONE. The |
1696 // return value indicates whether the transition was successful. | 1694 // return value indicates whether the transition was successful. |
1697 static inline bool TryTransitionToField(Handle<JSObject> object, | 1695 static inline bool TryTransitionToField(Handle<JSObject> object, |
1698 Handle<String> key); | 1696 Handle<Name> key); |
1699 | 1697 |
1700 inline int LastAddedFieldIndex(); | 1698 inline int LastAddedFieldIndex(); |
1701 | 1699 |
1702 // Extend the receiver with a single fast property appeared first in the | 1700 // Extend the receiver with a single fast property appeared first in the |
1703 // passed map. This also extends the property backing store if necessary. | 1701 // passed map. This also extends the property backing store if necessary. |
1704 static void AddFastPropertyUsingMap(Handle<JSObject> object, Handle<Map> map); | 1702 static void AddFastPropertyUsingMap(Handle<JSObject> object, Handle<Map> map); |
1705 inline MUST_USE_RESULT MaybeObject* AddFastPropertyUsingMap(Map* map); | 1703 inline MUST_USE_RESULT MaybeObject* AddFastPropertyUsingMap(Map* map); |
1706 | 1704 |
1707 // Can cause GC. | 1705 // Can cause GC. |
1708 MUST_USE_RESULT MaybeObject* SetLocalPropertyIgnoreAttributes( | 1706 MUST_USE_RESULT MaybeObject* SetLocalPropertyIgnoreAttributes( |
1709 String* key, | 1707 Name* key, |
1710 Object* value, | 1708 Object* value, |
1711 PropertyAttributes attributes); | 1709 PropertyAttributes attributes); |
1712 | 1710 |
1713 // Retrieve a value in a normalized object given a lookup result. | 1711 // Retrieve a value in a normalized object given a lookup result. |
1714 // Handles the special representation of JS global objects. | 1712 // Handles the special representation of JS global objects. |
1715 Object* GetNormalizedProperty(LookupResult* result); | 1713 Object* GetNormalizedProperty(LookupResult* result); |
1716 | 1714 |
1717 // Sets the property value in a normalized object given a lookup result. | 1715 // Sets the property value in a normalized object given a lookup result. |
1718 // Handles the special representation of JS global objects. | 1716 // Handles the special representation of JS global objects. |
1719 Object* SetNormalizedProperty(LookupResult* result, Object* value); | 1717 Object* SetNormalizedProperty(LookupResult* result, Object* value); |
1720 | 1718 |
1721 // Sets the property value in a normalized object given (key, value, details). | 1719 // Sets the property value in a normalized object given (key, value, details). |
1722 // Handles the special representation of JS global objects. | 1720 // Handles the special representation of JS global objects. |
1723 static Handle<Object> SetNormalizedProperty(Handle<JSObject> object, | 1721 static Handle<Object> SetNormalizedProperty(Handle<JSObject> object, |
1724 Handle<String> key, | 1722 Handle<Name> key, |
1725 Handle<Object> value, | 1723 Handle<Object> value, |
1726 PropertyDetails details); | 1724 PropertyDetails details); |
1727 | 1725 |
1728 MUST_USE_RESULT MaybeObject* SetNormalizedProperty(String* name, | 1726 MUST_USE_RESULT MaybeObject* SetNormalizedProperty(Name* name, |
1729 Object* value, | 1727 Object* value, |
1730 PropertyDetails details); | 1728 PropertyDetails details); |
1731 | 1729 |
1732 // Deletes the named property in a normalized object. | 1730 // Deletes the named property in a normalized object. |
1733 MUST_USE_RESULT MaybeObject* DeleteNormalizedProperty(String* name, | 1731 MUST_USE_RESULT MaybeObject* DeleteNormalizedProperty(Name* name, |
1734 DeleteMode mode); | 1732 DeleteMode mode); |
1735 | 1733 |
1736 MUST_USE_RESULT MaybeObject* OptimizeAsPrototype(); | 1734 MUST_USE_RESULT MaybeObject* OptimizeAsPrototype(); |
1737 | 1735 |
1738 // Retrieve interceptors. | 1736 // Retrieve interceptors. |
1739 InterceptorInfo* GetNamedInterceptor(); | 1737 InterceptorInfo* GetNamedInterceptor(); |
1740 InterceptorInfo* GetIndexedInterceptor(); | 1738 InterceptorInfo* GetIndexedInterceptor(); |
1741 | 1739 |
1742 // Used from JSReceiver. | 1740 // Used from JSReceiver. |
1743 PropertyAttributes GetPropertyAttributePostInterceptor(JSObject* receiver, | 1741 PropertyAttributes GetPropertyAttributePostInterceptor(JSObject* receiver, |
1744 String* name, | 1742 Name* name, |
1745 bool continue_search); | 1743 bool continue_search); |
1746 PropertyAttributes GetPropertyAttributeWithInterceptor(JSObject* receiver, | 1744 PropertyAttributes GetPropertyAttributeWithInterceptor(JSObject* receiver, |
1747 String* name, | 1745 Name* name, |
1748 bool continue_search); | 1746 bool continue_search); |
1749 PropertyAttributes GetPropertyAttributeWithFailedAccessCheck( | 1747 PropertyAttributes GetPropertyAttributeWithFailedAccessCheck( |
1750 Object* receiver, | 1748 Object* receiver, |
1751 LookupResult* result, | 1749 LookupResult* result, |
1752 String* name, | 1750 Name* name, |
1753 bool continue_search); | 1751 bool continue_search); |
1754 PropertyAttributes GetElementAttributeWithReceiver(JSReceiver* receiver, | 1752 PropertyAttributes GetElementAttributeWithReceiver(JSReceiver* receiver, |
1755 uint32_t index, | 1753 uint32_t index, |
1756 bool continue_search); | 1754 bool continue_search); |
1757 | 1755 |
1758 static void DefineAccessor(Handle<JSObject> object, | 1756 static void DefineAccessor(Handle<JSObject> object, |
1759 Handle<String> name, | 1757 Handle<Name> name, |
1760 Handle<Object> getter, | 1758 Handle<Object> getter, |
1761 Handle<Object> setter, | 1759 Handle<Object> setter, |
1762 PropertyAttributes attributes); | 1760 PropertyAttributes attributes); |
1763 // Can cause GC. | 1761 // Can cause GC. |
1764 MUST_USE_RESULT MaybeObject* DefineAccessor(String* name, | 1762 MUST_USE_RESULT MaybeObject* DefineAccessor(Name* name, |
1765 Object* getter, | 1763 Object* getter, |
1766 Object* setter, | 1764 Object* setter, |
1767 PropertyAttributes attributes); | 1765 PropertyAttributes attributes); |
1768 // Try to define a single accessor paying attention to map transitions. | 1766 // Try to define a single accessor paying attention to map transitions. |
1769 // Returns a JavaScript null if this was not possible and we have to use the | 1767 // Returns a JavaScript null if this was not possible and we have to use the |
1770 // slow case. Note that we can fail due to allocations, too. | 1768 // slow case. Note that we can fail due to allocations, too. |
1771 MUST_USE_RESULT MaybeObject* DefineFastAccessor( | 1769 MUST_USE_RESULT MaybeObject* DefineFastAccessor( |
1772 String* name, | 1770 Name* name, |
1773 AccessorComponent component, | 1771 AccessorComponent component, |
1774 Object* accessor, | 1772 Object* accessor, |
1775 PropertyAttributes attributes); | 1773 PropertyAttributes attributes); |
1776 Object* LookupAccessor(String* name, AccessorComponent component); | 1774 Object* LookupAccessor(Name* name, AccessorComponent component); |
1777 | 1775 |
1778 MUST_USE_RESULT MaybeObject* DefineAccessor(AccessorInfo* info); | 1776 MUST_USE_RESULT MaybeObject* DefineAccessor(AccessorInfo* info); |
1779 | 1777 |
1780 // Used from Object::GetProperty(). | 1778 // Used from Object::GetProperty(). |
1781 MUST_USE_RESULT MaybeObject* GetPropertyWithFailedAccessCheck( | 1779 MUST_USE_RESULT MaybeObject* GetPropertyWithFailedAccessCheck( |
1782 Object* receiver, | 1780 Object* receiver, |
1783 LookupResult* result, | 1781 LookupResult* result, |
1784 String* name, | 1782 Name* name, |
1785 PropertyAttributes* attributes); | 1783 PropertyAttributes* attributes); |
1786 MUST_USE_RESULT MaybeObject* GetPropertyWithInterceptor( | 1784 MUST_USE_RESULT MaybeObject* GetPropertyWithInterceptor( |
1787 Object* receiver, | 1785 Object* receiver, |
1788 String* name, | 1786 Name* name, |
1789 PropertyAttributes* attributes); | 1787 PropertyAttributes* attributes); |
1790 MUST_USE_RESULT MaybeObject* GetPropertyPostInterceptor( | 1788 MUST_USE_RESULT MaybeObject* GetPropertyPostInterceptor( |
1791 Object* receiver, | 1789 Object* receiver, |
1792 String* name, | 1790 Name* name, |
1793 PropertyAttributes* attributes); | 1791 PropertyAttributes* attributes); |
1794 MUST_USE_RESULT MaybeObject* GetLocalPropertyPostInterceptor( | 1792 MUST_USE_RESULT MaybeObject* GetLocalPropertyPostInterceptor( |
1795 Object* receiver, | 1793 Object* receiver, |
1796 String* name, | 1794 Name* name, |
1797 PropertyAttributes* attributes); | 1795 PropertyAttributes* attributes); |
1798 | 1796 |
1799 // Returns true if this is an instance of an api function and has | 1797 // Returns true if this is an instance of an api function and has |
1800 // been modified since it was created. May give false positives. | 1798 // been modified since it was created. May give false positives. |
1801 bool IsDirty(); | 1799 bool IsDirty(); |
1802 | 1800 |
1803 // If the receiver is a JSGlobalProxy this method will return its prototype, | 1801 // If the receiver is a JSGlobalProxy this method will return its prototype, |
1804 // otherwise the result is the receiver itself. | 1802 // otherwise the result is the receiver itself. |
1805 inline Object* BypassGlobalProxy(); | 1803 inline Object* BypassGlobalProxy(); |
1806 | 1804 |
1807 // Accessors for hidden properties object. | 1805 // Accessors for hidden properties object. |
1808 // | 1806 // |
1809 // Hidden properties are not local properties of the object itself. | 1807 // Hidden properties are not local properties of the object itself. |
1810 // Instead they are stored in an auxiliary structure kept as a local | 1808 // Instead they are stored in an auxiliary structure kept as a local |
1811 // property with a special name Heap::hidden_string(). But if the | 1809 // property with a special name Heap::hidden_string(). But if the |
1812 // receiver is a JSGlobalProxy then the auxiliary object is a property | 1810 // receiver is a JSGlobalProxy then the auxiliary object is a property |
1813 // of its prototype, and if it's a detached proxy, then you can't have | 1811 // of its prototype, and if it's a detached proxy, then you can't have |
1814 // hidden properties. | 1812 // hidden properties. |
1815 | 1813 |
1816 // Sets a hidden property on this object. Returns this object if successful, | 1814 // Sets a hidden property on this object. Returns this object if successful, |
1817 // undefined if called on a detached proxy. | 1815 // undefined if called on a detached proxy. |
1818 static Handle<Object> SetHiddenProperty(Handle<JSObject> obj, | 1816 static Handle<Object> SetHiddenProperty(Handle<JSObject> obj, |
1819 Handle<String> key, | 1817 Handle<Name> key, |
1820 Handle<Object> value); | 1818 Handle<Object> value); |
1821 // Returns a failure if a GC is required. | 1819 // Returns a failure if a GC is required. |
1822 MUST_USE_RESULT MaybeObject* SetHiddenProperty(String* key, Object* value); | 1820 MUST_USE_RESULT MaybeObject* SetHiddenProperty(Name* key, Object* value); |
1823 // Gets the value of a hidden property with the given key. Returns undefined | 1821 // Gets the value of a hidden property with the given key. Returns undefined |
1824 // if the property doesn't exist (or if called on a detached proxy), | 1822 // if the property doesn't exist (or if called on a detached proxy), |
1825 // otherwise returns the value set for the key. | 1823 // otherwise returns the value set for the key. |
1826 Object* GetHiddenProperty(String* key); | 1824 Object* GetHiddenProperty(Name* key); |
1827 // Deletes a hidden property. Deleting a non-existing property is | 1825 // Deletes a hidden property. Deleting a non-existing property is |
1828 // considered successful. | 1826 // considered successful. |
1829 void DeleteHiddenProperty(String* key); | 1827 void DeleteHiddenProperty(Name* key); |
1830 // Returns true if the object has a property with the hidden string as name. | 1828 // Returns true if the object has a property with the hidden string as name. |
1831 bool HasHiddenProperties(); | 1829 bool HasHiddenProperties(); |
1832 | 1830 |
1833 static int GetIdentityHash(Handle<JSObject> obj); | 1831 static int GetIdentityHash(Handle<JSObject> obj); |
1834 MUST_USE_RESULT MaybeObject* GetIdentityHash(CreationFlag flag); | 1832 MUST_USE_RESULT MaybeObject* GetIdentityHash(CreationFlag flag); |
1835 MUST_USE_RESULT MaybeObject* SetIdentityHash(Smi* hash, CreationFlag flag); | 1833 MUST_USE_RESULT MaybeObject* SetIdentityHash(Smi* hash, CreationFlag flag); |
1836 | 1834 |
1837 static Handle<Object> DeleteProperty(Handle<JSObject> obj, | 1835 static Handle<Object> DeleteProperty(Handle<JSObject> obj, |
1838 Handle<String> name); | 1836 Handle<Name> name); |
1839 // Can cause GC. | 1837 // Can cause GC. |
1840 MUST_USE_RESULT MaybeObject* DeleteProperty(String* name, DeleteMode mode); | 1838 MUST_USE_RESULT MaybeObject* DeleteProperty(Name* name, DeleteMode mode); |
1841 | 1839 |
1842 static Handle<Object> DeleteElement(Handle<JSObject> obj, uint32_t index); | 1840 static Handle<Object> DeleteElement(Handle<JSObject> obj, uint32_t index); |
1843 MUST_USE_RESULT MaybeObject* DeleteElement(uint32_t index, DeleteMode mode); | 1841 MUST_USE_RESULT MaybeObject* DeleteElement(uint32_t index, DeleteMode mode); |
1844 | 1842 |
1845 inline void ValidateElements(); | 1843 inline void ValidateElements(); |
1846 | 1844 |
1847 // Makes sure that this object can contain HeapObject as elements. | 1845 // Makes sure that this object can contain HeapObject as elements. |
1848 MUST_USE_RESULT inline MaybeObject* EnsureCanContainHeapObjectElements(); | 1846 MUST_USE_RESULT inline MaybeObject* EnsureCanContainHeapObjectElements(); |
1849 | 1847 |
1850 // Makes sure that this object can contain the specified elements. | 1848 // Makes sure that this object can contain the specified elements. |
(...skipping 23 matching lines...) Expand all Loading... |
1874 // represented in a FixedDoubleArray and has at least one value that can only | 1872 // represented in a FixedDoubleArray and has at least one value that can only |
1875 // be represented as a double and not a Smi. | 1873 // be represented as a double and not a Smi. |
1876 bool ShouldConvertToFastDoubleElements(bool* has_smi_only_elements); | 1874 bool ShouldConvertToFastDoubleElements(bool* has_smi_only_elements); |
1877 | 1875 |
1878 // Computes the new capacity when expanding the elements of a JSObject. | 1876 // Computes the new capacity when expanding the elements of a JSObject. |
1879 static int NewElementsCapacity(int old_capacity) { | 1877 static int NewElementsCapacity(int old_capacity) { |
1880 // (old_capacity + 50%) + 16 | 1878 // (old_capacity + 50%) + 16 |
1881 return old_capacity + (old_capacity >> 1) + 16; | 1879 return old_capacity + (old_capacity >> 1) + 16; |
1882 } | 1880 } |
1883 | 1881 |
1884 PropertyType GetLocalPropertyType(String* name); | 1882 PropertyType GetLocalPropertyType(Name* name); |
1885 PropertyType GetLocalElementType(uint32_t index); | 1883 PropertyType GetLocalElementType(uint32_t index); |
1886 | 1884 |
1887 // These methods do not perform access checks! | 1885 // These methods do not perform access checks! |
1888 AccessorPair* GetLocalPropertyAccessorPair(String* name); | 1886 AccessorPair* GetLocalPropertyAccessorPair(Name* name); |
1889 AccessorPair* GetLocalElementAccessorPair(uint32_t index); | 1887 AccessorPair* GetLocalElementAccessorPair(uint32_t index); |
1890 | 1888 |
1891 MUST_USE_RESULT MaybeObject* SetFastElement(uint32_t index, | 1889 MUST_USE_RESULT MaybeObject* SetFastElement(uint32_t index, |
1892 Object* value, | 1890 Object* value, |
1893 StrictModeFlag strict_mode, | 1891 StrictModeFlag strict_mode, |
1894 bool check_prototype); | 1892 bool check_prototype); |
1895 | 1893 |
1896 MUST_USE_RESULT MaybeObject* SetDictionaryElement( | 1894 MUST_USE_RESULT MaybeObject* SetDictionaryElement( |
1897 uint32_t index, | 1895 uint32_t index, |
1898 Object* value, | 1896 Object* value, |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1951 MUST_USE_RESULT MaybeObject* SetFastDoubleElementsCapacityAndLength( | 1949 MUST_USE_RESULT MaybeObject* SetFastDoubleElementsCapacityAndLength( |
1952 int capacity, | 1950 int capacity, |
1953 int length); | 1951 int length); |
1954 | 1952 |
1955 // Lookup interceptors are used for handling properties controlled by host | 1953 // Lookup interceptors are used for handling properties controlled by host |
1956 // objects. | 1954 // objects. |
1957 inline bool HasNamedInterceptor(); | 1955 inline bool HasNamedInterceptor(); |
1958 inline bool HasIndexedInterceptor(); | 1956 inline bool HasIndexedInterceptor(); |
1959 | 1957 |
1960 // Support functions for v8 api (needed for correct interceptor behavior). | 1958 // Support functions for v8 api (needed for correct interceptor behavior). |
1961 bool HasRealNamedProperty(String* key); | 1959 bool HasRealNamedProperty(Name* key); |
1962 bool HasRealElementProperty(uint32_t index); | 1960 bool HasRealElementProperty(uint32_t index); |
1963 bool HasRealNamedCallbackProperty(String* key); | 1961 bool HasRealNamedCallbackProperty(Name* key); |
1964 | 1962 |
1965 // Get the header size for a JSObject. Used to compute the index of | 1963 // Get the header size for a JSObject. Used to compute the index of |
1966 // internal fields as well as the number of internal fields. | 1964 // internal fields as well as the number of internal fields. |
1967 inline int GetHeaderSize(); | 1965 inline int GetHeaderSize(); |
1968 | 1966 |
1969 inline int GetInternalFieldCount(); | 1967 inline int GetInternalFieldCount(); |
1970 inline int GetInternalFieldOffset(int index); | 1968 inline int GetInternalFieldOffset(int index); |
1971 inline Object* GetInternalField(int index); | 1969 inline Object* GetInternalField(int index); |
1972 inline void SetInternalField(int index, Object* value); | 1970 inline void SetInternalField(int index, Object* value); |
1973 inline void SetInternalField(int index, Smi* value); | 1971 inline void SetInternalField(int index, Smi* value); |
1974 | 1972 |
1975 // The following lookup functions skip interceptors. | 1973 // The following lookup functions skip interceptors. |
1976 void LocalLookupRealNamedProperty(String* name, LookupResult* result); | 1974 void LocalLookupRealNamedProperty(Name* name, LookupResult* result); |
1977 void LookupRealNamedProperty(String* name, LookupResult* result); | 1975 void LookupRealNamedProperty(Name* name, LookupResult* result); |
1978 void LookupRealNamedPropertyInPrototypes(String* name, LookupResult* result); | 1976 void LookupRealNamedPropertyInPrototypes(Name* name, LookupResult* result); |
1979 MUST_USE_RESULT MaybeObject* SetElementWithCallbackSetterInPrototypes( | 1977 MUST_USE_RESULT MaybeObject* SetElementWithCallbackSetterInPrototypes( |
1980 uint32_t index, Object* value, bool* found, StrictModeFlag strict_mode); | 1978 uint32_t index, Object* value, bool* found, StrictModeFlag strict_mode); |
1981 void LookupCallbackProperty(String* name, LookupResult* result); | 1979 void LookupCallbackProperty(Name* name, LookupResult* result); |
1982 | 1980 |
1983 // Returns the number of properties on this object filtering out properties | 1981 // Returns the number of properties on this object filtering out properties |
1984 // with the specified attributes (ignoring interceptors). | 1982 // with the specified attributes (ignoring interceptors). |
1985 int NumberOfLocalProperties(PropertyAttributes filter = NONE); | 1983 int NumberOfLocalProperties(PropertyAttributes filter = NONE); |
1986 // Fill in details for properties into storage starting at the specified | 1984 // Fill in details for properties into storage starting at the specified |
1987 // index. | 1985 // index. |
1988 void GetLocalPropertyNames(FixedArray* storage, int index); | 1986 void GetLocalPropertyNames(FixedArray* storage, int index); |
1989 | 1987 |
1990 // Returns the number of properties on this object filtering out properties | 1988 // Returns the number of properties on this object filtering out properties |
1991 // with the specified attributes (ignoring interceptors). | 1989 // with the specified attributes (ignoring interceptors). |
1992 int NumberOfLocalElements(PropertyAttributes filter); | 1990 int NumberOfLocalElements(PropertyAttributes filter); |
1993 // Returns the number of enumerable elements (ignoring interceptors). | 1991 // Returns the number of enumerable elements (ignoring interceptors). |
1994 int NumberOfEnumElements(); | 1992 int NumberOfEnumElements(); |
1995 // Returns the number of elements on this object filtering out elements | 1993 // Returns the number of elements on this object filtering out elements |
1996 // with the specified attributes (ignoring interceptors). | 1994 // with the specified attributes (ignoring interceptors). |
1997 int GetLocalElementKeys(FixedArray* storage, PropertyAttributes filter); | 1995 int GetLocalElementKeys(FixedArray* storage, PropertyAttributes filter); |
1998 // Count and fill in the enumerable elements into storage. | 1996 // Count and fill in the enumerable elements into storage. |
1999 // (storage->length() == NumberOfEnumElements()). | 1997 // (storage->length() == NumberOfEnumElements()). |
2000 // If storage is NULL, will count the elements without adding | 1998 // If storage is NULL, will count the elements without adding |
2001 // them to any storage. | 1999 // them to any storage. |
2002 // Returns the number of enumerable elements. | 2000 // Returns the number of enumerable elements. |
2003 int GetEnumElementKeys(FixedArray* storage); | 2001 int GetEnumElementKeys(FixedArray* storage); |
2004 | 2002 |
2005 // Add a property to a fast-case object using a map transition to | 2003 // Add a property to a fast-case object using a map transition to |
2006 // new_map. | 2004 // new_map. |
2007 MUST_USE_RESULT MaybeObject* AddFastPropertyUsingMap(Map* new_map, | 2005 MUST_USE_RESULT MaybeObject* AddFastPropertyUsingMap(Map* new_map, |
2008 String* name, | 2006 Name* name, |
2009 Object* value, | 2007 Object* value, |
2010 int field_index); | 2008 int field_index); |
2011 | 2009 |
2012 // Add a constant function property to a fast-case object. | 2010 // Add a constant function property to a fast-case object. |
2013 // This leaves a CONSTANT_TRANSITION in the old map, and | 2011 // This leaves a CONSTANT_TRANSITION in the old map, and |
2014 // if it is called on a second object with this map, a | 2012 // if it is called on a second object with this map, a |
2015 // normal property is added instead, with a map transition. | 2013 // normal property is added instead, with a map transition. |
2016 // This avoids the creation of many maps with the same constant | 2014 // This avoids the creation of many maps with the same constant |
2017 // function, all orphaned. | 2015 // function, all orphaned. |
2018 MUST_USE_RESULT MaybeObject* AddConstantFunctionProperty( | 2016 MUST_USE_RESULT MaybeObject* AddConstantFunctionProperty( |
2019 String* name, | 2017 Name* name, |
2020 JSFunction* function, | 2018 JSFunction* function, |
2021 PropertyAttributes attributes); | 2019 PropertyAttributes attributes); |
2022 | 2020 |
2023 MUST_USE_RESULT MaybeObject* ReplaceSlowProperty( | 2021 MUST_USE_RESULT MaybeObject* ReplaceSlowProperty( |
2024 String* name, | 2022 Name* name, |
2025 Object* value, | 2023 Object* value, |
2026 PropertyAttributes attributes); | 2024 PropertyAttributes attributes); |
2027 | 2025 |
2028 // Returns a new map with all transitions dropped from the object's current | 2026 // Returns a new map with all transitions dropped from the object's current |
2029 // map and the ElementsKind set. | 2027 // map and the ElementsKind set. |
2030 static Handle<Map> GetElementsTransitionMap(Handle<JSObject> object, | 2028 static Handle<Map> GetElementsTransitionMap(Handle<JSObject> object, |
2031 ElementsKind to_kind); | 2029 ElementsKind to_kind); |
2032 inline MUST_USE_RESULT MaybeObject* GetElementsTransitionMap( | 2030 inline MUST_USE_RESULT MaybeObject* GetElementsTransitionMap( |
2033 Isolate* isolate, | 2031 Isolate* isolate, |
2034 ElementsKind elements_kind); | 2032 ElementsKind elements_kind); |
2035 MUST_USE_RESULT MaybeObject* GetElementsTransitionMapSlow( | 2033 MUST_USE_RESULT MaybeObject* GetElementsTransitionMapSlow( |
2036 ElementsKind elements_kind); | 2034 ElementsKind elements_kind); |
2037 | 2035 |
2038 static Handle<Object> TransitionElementsKind(Handle<JSObject> object, | 2036 static Handle<Object> TransitionElementsKind(Handle<JSObject> object, |
2039 ElementsKind to_kind); | 2037 ElementsKind to_kind); |
2040 | 2038 |
2041 MUST_USE_RESULT MaybeObject* TransitionElementsKind(ElementsKind to_kind); | 2039 MUST_USE_RESULT MaybeObject* TransitionElementsKind(ElementsKind to_kind); |
2042 MUST_USE_RESULT MaybeObject* PossiblyTransitionArrayBoilerplate( | 2040 MUST_USE_RESULT MaybeObject* PossiblyTransitionArrayBoilerplate( |
2043 ElementsKind to_kind); | 2041 ElementsKind to_kind); |
2044 | 2042 |
2045 // Replaces an existing transition with a transition to a map with a FIELD. | 2043 // Replaces an existing transition with a transition to a map with a FIELD. |
2046 MUST_USE_RESULT MaybeObject* ConvertTransitionToMapTransition( | 2044 MUST_USE_RESULT MaybeObject* ConvertTransitionToMapTransition( |
2047 int transition_index, | 2045 int transition_index, |
2048 String* name, | 2046 Name* name, |
2049 Object* new_value, | 2047 Object* new_value, |
2050 PropertyAttributes attributes); | 2048 PropertyAttributes attributes); |
2051 | 2049 |
2052 // Converts a descriptor of any other type to a real field, backed by the | 2050 // Converts a descriptor of any other type to a real field, backed by the |
2053 // properties array. | 2051 // properties array. |
2054 MUST_USE_RESULT MaybeObject* ConvertDescriptorToField( | 2052 MUST_USE_RESULT MaybeObject* ConvertDescriptorToField( |
2055 String* name, | 2053 Name* name, |
2056 Object* new_value, | 2054 Object* new_value, |
2057 PropertyAttributes attributes); | 2055 PropertyAttributes attributes); |
2058 | 2056 |
2059 // Add a property to a fast-case object. | 2057 // Add a property to a fast-case object. |
2060 MUST_USE_RESULT MaybeObject* AddFastProperty( | 2058 MUST_USE_RESULT MaybeObject* AddFastProperty( |
2061 String* name, | 2059 Name* name, |
2062 Object* value, | 2060 Object* value, |
2063 PropertyAttributes attributes, | 2061 PropertyAttributes attributes, |
2064 StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED); | 2062 StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED); |
2065 | 2063 |
2066 // Add a property to a slow-case object. | 2064 // Add a property to a slow-case object. |
2067 MUST_USE_RESULT MaybeObject* AddSlowProperty(String* name, | 2065 MUST_USE_RESULT MaybeObject* AddSlowProperty(Name* name, |
2068 Object* value, | 2066 Object* value, |
2069 PropertyAttributes attributes); | 2067 PropertyAttributes attributes); |
2070 | 2068 |
2071 // Add a property to an object. May cause GC. | 2069 // Add a property to an object. May cause GC. |
2072 MUST_USE_RESULT MaybeObject* AddProperty( | 2070 MUST_USE_RESULT MaybeObject* AddProperty( |
2073 String* name, | 2071 Name* name, |
2074 Object* value, | 2072 Object* value, |
2075 PropertyAttributes attributes, | 2073 PropertyAttributes attributes, |
2076 StrictModeFlag strict_mode, | 2074 StrictModeFlag strict_mode, |
2077 StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED, | 2075 StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED, |
2078 ExtensibilityCheck extensibility_check = PERFORM_EXTENSIBILITY_CHECK); | 2076 ExtensibilityCheck extensibility_check = PERFORM_EXTENSIBILITY_CHECK); |
2079 | 2077 |
2080 // Convert the object to use the canonical dictionary | 2078 // Convert the object to use the canonical dictionary |
2081 // representation. If the object is expected to have additional properties | 2079 // representation. If the object is expected to have additional properties |
2082 // added this number can be indicated to have the backing store allocated to | 2080 // added this number can be indicated to have the backing store allocated to |
2083 // an initial capacity for holding these properties. | 2081 // an initial capacity for holding these properties. |
2084 static void NormalizeProperties(Handle<JSObject> object, | 2082 static void NormalizeProperties(Handle<JSObject> object, |
2085 PropertyNormalizationMode mode, | 2083 PropertyNormalizationMode mode, |
2086 int expected_additional_properties); | 2084 int expected_additional_properties); |
2087 | 2085 |
2088 MUST_USE_RESULT MaybeObject* NormalizeProperties( | 2086 MUST_USE_RESULT MaybeObject* NormalizeProperties( |
2089 PropertyNormalizationMode mode, | 2087 PropertyNormalizationMode mode, |
2090 int expected_additional_properties); | 2088 int expected_additional_properties); |
2091 | 2089 |
2092 // Convert and update the elements backing store to be a | 2090 // Convert and update the elements backing store to be a |
2093 // SeededNumberDictionary dictionary. Returns the backing after conversion. | 2091 // SeededNumberDictionary dictionary. Returns the backing after conversion. |
2094 static Handle<SeededNumberDictionary> NormalizeElements( | 2092 static Handle<SeededNumberDictionary> NormalizeElements( |
2095 Handle<JSObject> object); | 2093 Handle<JSObject> object); |
2096 | 2094 |
2097 MUST_USE_RESULT MaybeObject* NormalizeElements(); | 2095 MUST_USE_RESULT MaybeObject* NormalizeElements(); |
2098 | 2096 |
2099 static void UpdateMapCodeCache(Handle<JSObject> object, | 2097 static void UpdateMapCodeCache(Handle<JSObject> object, |
2100 Handle<String> name, | 2098 Handle<Name> name, |
2101 Handle<Code> code); | 2099 Handle<Code> code); |
2102 | 2100 |
2103 MUST_USE_RESULT MaybeObject* UpdateMapCodeCache(String* name, Code* code); | 2101 MUST_USE_RESULT MaybeObject* UpdateMapCodeCache(Name* name, Code* code); |
2104 | 2102 |
2105 // Transform slow named properties to fast variants. | 2103 // Transform slow named properties to fast variants. |
2106 // Returns failure if allocation failed. | 2104 // Returns failure if allocation failed. |
2107 static void TransformToFastProperties(Handle<JSObject> object, | 2105 static void TransformToFastProperties(Handle<JSObject> object, |
2108 int unused_property_fields); | 2106 int unused_property_fields); |
2109 | 2107 |
2110 MUST_USE_RESULT MaybeObject* TransformToFastProperties( | 2108 MUST_USE_RESULT MaybeObject* TransformToFastProperties( |
2111 int unused_property_fields); | 2109 int unused_property_fields); |
2112 | 2110 |
2113 // Access fast-case object properties at index. | 2111 // Access fast-case object properties at index. |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2230 STATIC_CHECK(kHeaderSize == Internals::kJSObjectHeaderSize); | 2228 STATIC_CHECK(kHeaderSize == Internals::kJSObjectHeaderSize); |
2231 | 2229 |
2232 class BodyDescriptor : public FlexibleBodyDescriptor<kPropertiesOffset> { | 2230 class BodyDescriptor : public FlexibleBodyDescriptor<kPropertiesOffset> { |
2233 public: | 2231 public: |
2234 static inline int SizeOf(Map* map, HeapObject* object); | 2232 static inline int SizeOf(Map* map, HeapObject* object); |
2235 }; | 2233 }; |
2236 | 2234 |
2237 // Enqueue change record for Object.observe. May cause GC. | 2235 // Enqueue change record for Object.observe. May cause GC. |
2238 static void EnqueueChangeRecord(Handle<JSObject> object, | 2236 static void EnqueueChangeRecord(Handle<JSObject> object, |
2239 const char* type, | 2237 const char* type, |
2240 Handle<String> name, | 2238 Handle<Name> name, |
2241 Handle<Object> old_value); | 2239 Handle<Object> old_value); |
2242 | 2240 |
2243 // Deliver change records to observers. May cause GC. | 2241 // Deliver change records to observers. May cause GC. |
2244 static void DeliverChangeRecords(Isolate* isolate); | 2242 static void DeliverChangeRecords(Isolate* isolate); |
2245 | 2243 |
2246 private: | 2244 private: |
2247 friend class DictionaryElementsAccessor; | 2245 friend class DictionaryElementsAccessor; |
2248 | 2246 |
2249 MUST_USE_RESULT MaybeObject* GetElementWithCallback(Object* receiver, | 2247 MUST_USE_RESULT MaybeObject* GetElementWithCallback(Object* receiver, |
2250 Object* structure, | 2248 Object* structure, |
(...skipping 26 matching lines...) Expand all Loading... |
2277 PropertyAttributes attributes, | 2275 PropertyAttributes attributes, |
2278 StrictModeFlag strict_mode, | 2276 StrictModeFlag strict_mode, |
2279 bool check_prototype, | 2277 bool check_prototype, |
2280 SetPropertyMode set_mode); | 2278 SetPropertyMode set_mode); |
2281 | 2279 |
2282 // Searches the prototype chain for property 'name'. If it is found and | 2280 // Searches the prototype chain for property 'name'. If it is found and |
2283 // has a setter, invoke it and set '*done' to true. If it is found and is | 2281 // has a setter, invoke it and set '*done' to true. If it is found and is |
2284 // read-only, reject and set '*done' to true. Otherwise, set '*done' to | 2282 // read-only, reject and set '*done' to true. Otherwise, set '*done' to |
2285 // false. Can cause GC and can return a failure result with '*done==true'. | 2283 // false. Can cause GC and can return a failure result with '*done==true'. |
2286 MUST_USE_RESULT MaybeObject* SetPropertyViaPrototypes( | 2284 MUST_USE_RESULT MaybeObject* SetPropertyViaPrototypes( |
2287 String* name, | 2285 Name* name, |
2288 Object* value, | 2286 Object* value, |
2289 PropertyAttributes attributes, | 2287 PropertyAttributes attributes, |
2290 StrictModeFlag strict_mode, | 2288 StrictModeFlag strict_mode, |
2291 bool* done); | 2289 bool* done); |
2292 | 2290 |
2293 MUST_USE_RESULT MaybeObject* DeletePropertyPostInterceptor(String* name, | 2291 MUST_USE_RESULT MaybeObject* DeletePropertyPostInterceptor(Name* name, |
2294 DeleteMode mode); | 2292 DeleteMode mode); |
2295 MUST_USE_RESULT MaybeObject* DeletePropertyWithInterceptor(String* name); | 2293 MUST_USE_RESULT MaybeObject* DeletePropertyWithInterceptor(Name* name); |
2296 | 2294 |
2297 MUST_USE_RESULT MaybeObject* DeleteElementWithInterceptor(uint32_t index); | 2295 MUST_USE_RESULT MaybeObject* DeleteElementWithInterceptor(uint32_t index); |
2298 | 2296 |
2299 MUST_USE_RESULT MaybeObject* DeleteFastElement(uint32_t index); | 2297 MUST_USE_RESULT MaybeObject* DeleteFastElement(uint32_t index); |
2300 MUST_USE_RESULT MaybeObject* DeleteDictionaryElement(uint32_t index, | 2298 MUST_USE_RESULT MaybeObject* DeleteDictionaryElement(uint32_t index, |
2301 DeleteMode mode); | 2299 DeleteMode mode); |
2302 | 2300 |
2303 bool ReferencesObjectFromElements(FixedArray* elements, | 2301 bool ReferencesObjectFromElements(FixedArray* elements, |
2304 ElementsKind kind, | 2302 ElementsKind kind, |
2305 Object* object); | 2303 Object* object); |
2306 | 2304 |
2307 // Returns true if most of the elements backing storage is used. | 2305 // Returns true if most of the elements backing storage is used. |
2308 bool HasDenseElements(); | 2306 bool HasDenseElements(); |
2309 | 2307 |
2310 // Gets the current elements capacity and the number of used elements. | 2308 // Gets the current elements capacity and the number of used elements. |
2311 void GetElementsCapacityAndUsage(int* capacity, int* used); | 2309 void GetElementsCapacityAndUsage(int* capacity, int* used); |
2312 | 2310 |
2313 bool CanSetCallback(String* name); | 2311 bool CanSetCallback(Name* name); |
2314 MUST_USE_RESULT MaybeObject* SetElementCallback( | 2312 MUST_USE_RESULT MaybeObject* SetElementCallback( |
2315 uint32_t index, | 2313 uint32_t index, |
2316 Object* structure, | 2314 Object* structure, |
2317 PropertyAttributes attributes); | 2315 PropertyAttributes attributes); |
2318 MUST_USE_RESULT MaybeObject* SetPropertyCallback( | 2316 MUST_USE_RESULT MaybeObject* SetPropertyCallback( |
2319 String* name, | 2317 Name* name, |
2320 Object* structure, | 2318 Object* structure, |
2321 PropertyAttributes attributes); | 2319 PropertyAttributes attributes); |
2322 MUST_USE_RESULT MaybeObject* DefineElementAccessor( | 2320 MUST_USE_RESULT MaybeObject* DefineElementAccessor( |
2323 uint32_t index, | 2321 uint32_t index, |
2324 Object* getter, | 2322 Object* getter, |
2325 Object* setter, | 2323 Object* setter, |
2326 PropertyAttributes attributes); | 2324 PropertyAttributes attributes); |
2327 MUST_USE_RESULT MaybeObject* CreateAccessorPairFor(String* name); | 2325 MUST_USE_RESULT MaybeObject* CreateAccessorPairFor(Name* name); |
2328 MUST_USE_RESULT MaybeObject* DefinePropertyAccessor( | 2326 MUST_USE_RESULT MaybeObject* DefinePropertyAccessor( |
2329 String* name, | 2327 Name* name, |
2330 Object* getter, | 2328 Object* getter, |
2331 Object* setter, | 2329 Object* setter, |
2332 PropertyAttributes attributes); | 2330 PropertyAttributes attributes); |
2333 | 2331 |
2334 | 2332 |
2335 enum InitializeHiddenProperties { | 2333 enum InitializeHiddenProperties { |
2336 CREATE_NEW_IF_ABSENT, | 2334 CREATE_NEW_IF_ABSENT, |
2337 ONLY_RETURN_INLINE_VALUE | 2335 ONLY_RETURN_INLINE_VALUE |
2338 }; | 2336 }; |
2339 | 2337 |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2620 | 2618 |
2621 void ClearEnumCache(); | 2619 void ClearEnumCache(); |
2622 | 2620 |
2623 // Initialize or change the enum cache, | 2621 // Initialize or change the enum cache, |
2624 // using the supplied storage for the small "bridge". | 2622 // using the supplied storage for the small "bridge". |
2625 void SetEnumCache(FixedArray* bridge_storage, | 2623 void SetEnumCache(FixedArray* bridge_storage, |
2626 FixedArray* new_cache, | 2624 FixedArray* new_cache, |
2627 Object* new_index_cache); | 2625 Object* new_index_cache); |
2628 | 2626 |
2629 // Accessors for fetching instance descriptor at descriptor number. | 2627 // Accessors for fetching instance descriptor at descriptor number. |
2630 inline String* GetKey(int descriptor_number); | 2628 inline Name* GetKey(int descriptor_number); |
2631 inline Object** GetKeySlot(int descriptor_number); | 2629 inline Object** GetKeySlot(int descriptor_number); |
2632 inline Object* GetValue(int descriptor_number); | 2630 inline Object* GetValue(int descriptor_number); |
2633 inline Object** GetValueSlot(int descriptor_number); | 2631 inline Object** GetValueSlot(int descriptor_number); |
2634 inline Object** GetDescriptorStartSlot(int descriptor_number); | 2632 inline Object** GetDescriptorStartSlot(int descriptor_number); |
2635 inline Object** GetDescriptorEndSlot(int descriptor_number); | 2633 inline Object** GetDescriptorEndSlot(int descriptor_number); |
2636 inline PropertyDetails GetDetails(int descriptor_number); | 2634 inline PropertyDetails GetDetails(int descriptor_number); |
2637 inline PropertyType GetType(int descriptor_number); | 2635 inline PropertyType GetType(int descriptor_number); |
2638 inline int GetFieldIndex(int descriptor_number); | 2636 inline int GetFieldIndex(int descriptor_number); |
2639 inline JSFunction* GetConstantFunction(int descriptor_number); | 2637 inline JSFunction* GetConstantFunction(int descriptor_number); |
2640 inline Object* GetCallbacksObject(int descriptor_number); | 2638 inline Object* GetCallbacksObject(int descriptor_number); |
2641 inline AccessorDescriptor* GetCallbacks(int descriptor_number); | 2639 inline AccessorDescriptor* GetCallbacks(int descriptor_number); |
2642 | 2640 |
2643 inline String* GetSortedKey(int descriptor_number); | 2641 inline Name* GetSortedKey(int descriptor_number); |
2644 inline int GetSortedKeyIndex(int descriptor_number); | 2642 inline int GetSortedKeyIndex(int descriptor_number); |
2645 inline void SetSortedKey(int pointer, int descriptor_number); | 2643 inline void SetSortedKey(int pointer, int descriptor_number); |
2646 | 2644 |
2647 // Accessor for complete descriptor. | 2645 // Accessor for complete descriptor. |
2648 inline void Get(int descriptor_number, Descriptor* desc); | 2646 inline void Get(int descriptor_number, Descriptor* desc); |
2649 inline void Set(int descriptor_number, | 2647 inline void Set(int descriptor_number, |
2650 Descriptor* desc, | 2648 Descriptor* desc, |
2651 const WhitenessWitness&); | 2649 const WhitenessWitness&); |
2652 inline void Set(int descriptor_number, Descriptor* desc); | 2650 inline void Set(int descriptor_number, Descriptor* desc); |
2653 | 2651 |
2654 // Append automatically sets the enumeration index. This should only be used | 2652 // Append automatically sets the enumeration index. This should only be used |
2655 // to add descriptors in bulk at the end, followed by sorting the descriptor | 2653 // to add descriptors in bulk at the end, followed by sorting the descriptor |
2656 // array. | 2654 // array. |
2657 inline void Append(Descriptor* desc, const WhitenessWitness&); | 2655 inline void Append(Descriptor* desc, const WhitenessWitness&); |
2658 inline void Append(Descriptor* desc); | 2656 inline void Append(Descriptor* desc); |
2659 | 2657 |
2660 // Transfer a complete descriptor from the src descriptor array to this | 2658 // Transfer a complete descriptor from the src descriptor array to this |
2661 // descriptor array. | 2659 // descriptor array. |
2662 void CopyFrom(int dst_index, | 2660 void CopyFrom(int dst_index, |
2663 DescriptorArray* src, | 2661 DescriptorArray* src, |
2664 int src_index, | 2662 int src_index, |
2665 const WhitenessWitness&); | 2663 const WhitenessWitness&); |
2666 | 2664 |
2667 MUST_USE_RESULT MaybeObject* CopyUpTo(int enumeration_index); | 2665 MUST_USE_RESULT MaybeObject* CopyUpTo(int enumeration_index); |
2668 | 2666 |
2669 // Sort the instance descriptors by the hash codes of their keys. | 2667 // Sort the instance descriptors by the hash codes of their keys. |
2670 void Sort(); | 2668 void Sort(); |
2671 | 2669 |
2672 // Search the instance descriptors for given name. | 2670 // Search the instance descriptors for given name. |
2673 INLINE(int Search(String* name, int number_of_own_descriptors)); | 2671 INLINE(int Search(Name* name, int number_of_own_descriptors)); |
2674 | 2672 |
2675 // As the above, but uses DescriptorLookupCache and updates it when | 2673 // As the above, but uses DescriptorLookupCache and updates it when |
2676 // necessary. | 2674 // necessary. |
2677 INLINE(int SearchWithCache(String* name, Map* map)); | 2675 INLINE(int SearchWithCache(Name* name, Map* map)); |
2678 | 2676 |
2679 // Allocates a DescriptorArray, but returns the singleton | 2677 // Allocates a DescriptorArray, but returns the singleton |
2680 // empty descriptor array object if number_of_descriptors is 0. | 2678 // empty descriptor array object if number_of_descriptors is 0. |
2681 MUST_USE_RESULT static MaybeObject* Allocate(int number_of_descriptors, | 2679 MUST_USE_RESULT static MaybeObject* Allocate(int number_of_descriptors, |
2682 int slack = 0); | 2680 int slack = 0); |
2683 | 2681 |
2684 // Casting. | 2682 // Casting. |
2685 static inline DescriptorArray* cast(Object* obj); | 2683 static inline DescriptorArray* cast(Object* obj); |
2686 | 2684 |
2687 // Constant for denoting key was not found. | 2685 // Constant for denoting key was not found. |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2776 // Swap first and second descriptor. | 2774 // Swap first and second descriptor. |
2777 inline void SwapSortedKeys(int first, int second); | 2775 inline void SwapSortedKeys(int first, int second); |
2778 | 2776 |
2779 DISALLOW_IMPLICIT_CONSTRUCTORS(DescriptorArray); | 2777 DISALLOW_IMPLICIT_CONSTRUCTORS(DescriptorArray); |
2780 }; | 2778 }; |
2781 | 2779 |
2782 | 2780 |
2783 enum SearchMode { ALL_ENTRIES, VALID_ENTRIES }; | 2781 enum SearchMode { ALL_ENTRIES, VALID_ENTRIES }; |
2784 | 2782 |
2785 template<SearchMode search_mode, typename T> | 2783 template<SearchMode search_mode, typename T> |
2786 inline int LinearSearch(T* array, String* name, int len, int valid_entries); | 2784 inline int LinearSearch(T* array, Name* name, int len, int valid_entries); |
2787 | 2785 |
2788 | 2786 |
2789 template<SearchMode search_mode, typename T> | 2787 template<SearchMode search_mode, typename T> |
2790 inline int Search(T* array, String* name, int valid_entries = 0); | 2788 inline int Search(T* array, Name* name, int valid_entries = 0); |
2791 | 2789 |
2792 | 2790 |
2793 // HashTable is a subclass of FixedArray that implements a hash table | 2791 // HashTable is a subclass of FixedArray that implements a hash table |
2794 // that uses open addressing and quadratic probing. | 2792 // that uses open addressing and quadratic probing. |
2795 // | 2793 // |
2796 // In order for the quadratic probing to work, elements that have not | 2794 // In order for the quadratic probing to work, elements that have not |
2797 // yet been used and elements that have been deleted are | 2795 // yet been used and elements that have been deleted are |
2798 // distinguished. Probing continues when deleted elements are | 2796 // distinguished. Probing continues when deleted elements are |
2799 // encountered and stops when unused elements are encountered. | 2797 // encountered and stops when unused elements are encountered. |
2800 // | 2798 // |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3108 return key->AsObject(); | 3106 return key->AsObject(); |
3109 } | 3107 } |
3110 | 3108 |
3111 static const int kPrefixSize = 0; | 3109 static const int kPrefixSize = 0; |
3112 static const int kEntrySize = 2; | 3110 static const int kEntrySize = 2; |
3113 }; | 3111 }; |
3114 | 3112 |
3115 | 3113 |
3116 // MapCache. | 3114 // MapCache. |
3117 // | 3115 // |
3118 // Maps keys that are a fixed array of internalized strings to a map. | 3116 // Maps keys that are a fixed array of unique names to a map. |
3119 // Used for canonicalize maps for object literals. | 3117 // Used for canonicalize maps for object literals. |
3120 class MapCache: public HashTable<MapCacheShape, HashTableKey*> { | 3118 class MapCache: public HashTable<MapCacheShape, HashTableKey*> { |
3121 public: | 3119 public: |
3122 // Find cached value for a string key, otherwise return null. | 3120 // Find cached value for a name key, otherwise return null. |
3123 Object* Lookup(FixedArray* key); | 3121 Object* Lookup(FixedArray* key); |
3124 MUST_USE_RESULT MaybeObject* Put(FixedArray* key, Map* value); | 3122 MUST_USE_RESULT MaybeObject* Put(FixedArray* key, Map* value); |
3125 static inline MapCache* cast(Object* obj); | 3123 static inline MapCache* cast(Object* obj); |
3126 | 3124 |
3127 private: | 3125 private: |
3128 DISALLOW_IMPLICIT_CONSTRUCTORS(MapCache); | 3126 DISALLOW_IMPLICIT_CONSTRUCTORS(MapCache); |
3129 }; | 3127 }; |
3130 | 3128 |
3131 | 3129 |
3132 template <typename Shape, typename Key> | 3130 template <typename Shape, typename Key> |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3231 uint32_t hash); | 3229 uint32_t hash); |
3232 | 3230 |
3233 // Generate new enumeration indices to avoid enumeration index overflow. | 3231 // Generate new enumeration indices to avoid enumeration index overflow. |
3234 MUST_USE_RESULT MaybeObject* GenerateNewEnumerationIndices(); | 3232 MUST_USE_RESULT MaybeObject* GenerateNewEnumerationIndices(); |
3235 static const int kMaxNumberKeyIndex = | 3233 static const int kMaxNumberKeyIndex = |
3236 HashTable<Shape, Key>::kPrefixStartIndex; | 3234 HashTable<Shape, Key>::kPrefixStartIndex; |
3237 static const int kNextEnumerationIndexIndex = kMaxNumberKeyIndex + 1; | 3235 static const int kNextEnumerationIndexIndex = kMaxNumberKeyIndex + 1; |
3238 }; | 3236 }; |
3239 | 3237 |
3240 | 3238 |
3241 class StringDictionaryShape : public BaseShape<String*> { | 3239 class NameDictionaryShape : public BaseShape<Name*> { |
3242 public: | 3240 public: |
3243 static inline bool IsMatch(String* key, Object* other); | 3241 static inline bool IsMatch(Name* key, Object* other); |
3244 static inline uint32_t Hash(String* key); | 3242 static inline uint32_t Hash(Name* key); |
3245 static inline uint32_t HashForObject(String* key, Object* object); | 3243 static inline uint32_t HashForObject(Name* key, Object* object); |
3246 MUST_USE_RESULT static inline MaybeObject* AsObject(String* key); | 3244 MUST_USE_RESULT static inline MaybeObject* AsObject(Name* key); |
3247 static const int kPrefixSize = 2; | 3245 static const int kPrefixSize = 2; |
3248 static const int kEntrySize = 3; | 3246 static const int kEntrySize = 3; |
3249 static const bool kIsEnumerable = true; | 3247 static const bool kIsEnumerable = true; |
3250 }; | 3248 }; |
3251 | 3249 |
3252 | 3250 |
3253 class StringDictionary: public Dictionary<StringDictionaryShape, String*> { | 3251 class NameDictionary: public Dictionary<NameDictionaryShape, Name*> { |
3254 public: | 3252 public: |
3255 static inline StringDictionary* cast(Object* obj) { | 3253 static inline NameDictionary* cast(Object* obj) { |
3256 ASSERT(obj->IsDictionary()); | 3254 ASSERT(obj->IsDictionary()); |
3257 return reinterpret_cast<StringDictionary*>(obj); | 3255 return reinterpret_cast<NameDictionary*>(obj); |
3258 } | 3256 } |
3259 | 3257 |
3260 // Copies enumerable keys to preallocated fixed array. | 3258 // Copies enumerable keys to preallocated fixed array. |
3261 FixedArray* CopyEnumKeysTo(FixedArray* storage); | 3259 FixedArray* CopyEnumKeysTo(FixedArray* storage); |
3262 static void DoGenerateNewEnumerationIndices( | 3260 static void DoGenerateNewEnumerationIndices( |
3263 Handle<StringDictionary> dictionary); | 3261 Handle<NameDictionary> dictionary); |
3264 | 3262 |
3265 // For transforming properties of a JSObject. | 3263 // For transforming properties of a JSObject. |
3266 MUST_USE_RESULT MaybeObject* TransformPropertiesToFastFor( | 3264 MUST_USE_RESULT MaybeObject* TransformPropertiesToFastFor( |
3267 JSObject* obj, | 3265 JSObject* obj, |
3268 int unused_property_fields); | 3266 int unused_property_fields); |
3269 | 3267 |
3270 // Find entry for key, otherwise return kNotFound. Optimized version of | 3268 // Find entry for key, otherwise return kNotFound. Optimized version of |
3271 // HashTable::FindEntry. | 3269 // HashTable::FindEntry. |
3272 int FindEntry(String* key); | 3270 int FindEntry(Name* key); |
3273 }; | 3271 }; |
3274 | 3272 |
3275 | 3273 |
3276 class NumberDictionaryShape : public BaseShape<uint32_t> { | 3274 class NumberDictionaryShape : public BaseShape<uint32_t> { |
3277 public: | 3275 public: |
3278 static inline bool IsMatch(uint32_t key, Object* other); | 3276 static inline bool IsMatch(uint32_t key, Object* other); |
3279 MUST_USE_RESULT static inline MaybeObject* AsObject(uint32_t key); | 3277 MUST_USE_RESULT static inline MaybeObject* AsObject(uint32_t key); |
3280 static const int kEntrySize = 3; | 3278 static const int kEntrySize = 3; |
3281 static const bool kIsEnumerable = false; | 3279 static const bool kIsEnumerable = false; |
3282 }; | 3280 }; |
(...skipping 1622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4905 static bool IsValidElementsTransition(ElementsKind from_kind, | 4903 static bool IsValidElementsTransition(ElementsKind from_kind, |
4906 ElementsKind to_kind); | 4904 ElementsKind to_kind); |
4907 | 4905 |
4908 inline bool HasTransitionArray(); | 4906 inline bool HasTransitionArray(); |
4909 inline bool HasElementsTransition(); | 4907 inline bool HasElementsTransition(); |
4910 inline Map* elements_transition_map(); | 4908 inline Map* elements_transition_map(); |
4911 MUST_USE_RESULT inline MaybeObject* set_elements_transition_map( | 4909 MUST_USE_RESULT inline MaybeObject* set_elements_transition_map( |
4912 Map* transitioned_map); | 4910 Map* transitioned_map); |
4913 inline void SetTransition(int transition_index, Map* target); | 4911 inline void SetTransition(int transition_index, Map* target); |
4914 inline Map* GetTransition(int transition_index); | 4912 inline Map* GetTransition(int transition_index); |
4915 MUST_USE_RESULT inline MaybeObject* AddTransition(String* key, | 4913 MUST_USE_RESULT inline MaybeObject* AddTransition(Name* key, |
4916 Map* target, | 4914 Map* target, |
4917 SimpleTransitionFlag flag); | 4915 SimpleTransitionFlag flag); |
4918 DECL_ACCESSORS(transitions, TransitionArray) | 4916 DECL_ACCESSORS(transitions, TransitionArray) |
4919 inline void ClearTransitions(Heap* heap, | 4917 inline void ClearTransitions(Heap* heap, |
4920 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); | 4918 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); |
4921 | 4919 |
4922 // Tells whether the map is attached to SharedFunctionInfo | 4920 // Tells whether the map is attached to SharedFunctionInfo |
4923 // (for inobject slack tracking). | 4921 // (for inobject slack tracking). |
4924 inline void set_attached_to_shared_function_info(bool value); | 4922 inline void set_attached_to_shared_function_info(bool value); |
4925 | 4923 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5003 FixedArray* cache = GetPrototypeTransitions(); | 5001 FixedArray* cache = GetPrototypeTransitions(); |
5004 ASSERT(cache->length() != 0); | 5002 ASSERT(cache->length() != 0); |
5005 cache->set_unchecked(kProtoTransitionNumberOfEntriesOffset, | 5003 cache->set_unchecked(kProtoTransitionNumberOfEntriesOffset, |
5006 Smi::FromInt(value)); | 5004 Smi::FromInt(value)); |
5007 } | 5005 } |
5008 | 5006 |
5009 // Lookup in the map's instance descriptors and fill out the result | 5007 // Lookup in the map's instance descriptors and fill out the result |
5010 // with the given holder if the name is found. The holder may be | 5008 // with the given holder if the name is found. The holder may be |
5011 // NULL when this function is used from the compiler. | 5009 // NULL when this function is used from the compiler. |
5012 inline void LookupDescriptor(JSObject* holder, | 5010 inline void LookupDescriptor(JSObject* holder, |
5013 String* name, | 5011 Name* name, |
5014 LookupResult* result); | 5012 LookupResult* result); |
5015 | 5013 |
5016 inline void LookupTransition(JSObject* holder, | 5014 inline void LookupTransition(JSObject* holder, |
5017 String* name, | 5015 Name* name, |
5018 LookupResult* result); | 5016 LookupResult* result); |
5019 | 5017 |
5020 // The size of transition arrays are limited so they do not end up in large | 5018 // The size of transition arrays are limited so they do not end up in large |
5021 // object space. Otherwise ClearNonLiveTransitions would leak memory while | 5019 // object space. Otherwise ClearNonLiveTransitions would leak memory while |
5022 // applying in-place right trimming. | 5020 // applying in-place right trimming. |
5023 inline bool CanHaveMoreTransitions(); | 5021 inline bool CanHaveMoreTransitions(); |
5024 | 5022 |
5025 int LastAdded() { | 5023 int LastAdded() { |
5026 int number_of_own_descriptors = NumberOfOwnDescriptors(); | 5024 int number_of_own_descriptors = NumberOfOwnDescriptors(); |
5027 ASSERT(number_of_own_descriptors > 0); | 5025 ASSERT(number_of_own_descriptors > 0); |
(...skipping 28 matching lines...) Expand all Loading... |
5056 inline bool owns_descriptors(); | 5054 inline bool owns_descriptors(); |
5057 inline void set_owns_descriptors(bool is_shared); | 5055 inline void set_owns_descriptors(bool is_shared); |
5058 inline bool is_observed(); | 5056 inline bool is_observed(); |
5059 inline void set_is_observed(bool is_observed); | 5057 inline void set_is_observed(bool is_observed); |
5060 | 5058 |
5061 MUST_USE_RESULT MaybeObject* RawCopy(int instance_size); | 5059 MUST_USE_RESULT MaybeObject* RawCopy(int instance_size); |
5062 MUST_USE_RESULT MaybeObject* CopyWithPreallocatedFieldDescriptors(); | 5060 MUST_USE_RESULT MaybeObject* CopyWithPreallocatedFieldDescriptors(); |
5063 MUST_USE_RESULT MaybeObject* CopyDropDescriptors(); | 5061 MUST_USE_RESULT MaybeObject* CopyDropDescriptors(); |
5064 MUST_USE_RESULT MaybeObject* CopyReplaceDescriptors( | 5062 MUST_USE_RESULT MaybeObject* CopyReplaceDescriptors( |
5065 DescriptorArray* descriptors, | 5063 DescriptorArray* descriptors, |
5066 String* name, | 5064 Name* name, |
5067 TransitionFlag flag, | 5065 TransitionFlag flag, |
5068 int descriptor_index); | 5066 int descriptor_index); |
5069 MUST_USE_RESULT MaybeObject* ShareDescriptor(DescriptorArray* descriptors, | 5067 MUST_USE_RESULT MaybeObject* ShareDescriptor(DescriptorArray* descriptors, |
5070 Descriptor* descriptor); | 5068 Descriptor* descriptor); |
5071 MUST_USE_RESULT MaybeObject* CopyAddDescriptor(Descriptor* descriptor, | 5069 MUST_USE_RESULT MaybeObject* CopyAddDescriptor(Descriptor* descriptor, |
5072 TransitionFlag flag); | 5070 TransitionFlag flag); |
5073 MUST_USE_RESULT MaybeObject* CopyInsertDescriptor(Descriptor* descriptor, | 5071 MUST_USE_RESULT MaybeObject* CopyInsertDescriptor(Descriptor* descriptor, |
5074 TransitionFlag flag); | 5072 TransitionFlag flag); |
5075 MUST_USE_RESULT MaybeObject* CopyReplaceDescriptor( | 5073 MUST_USE_RESULT MaybeObject* CopyReplaceDescriptor( |
5076 DescriptorArray* descriptors, | 5074 DescriptorArray* descriptors, |
5077 Descriptor* descriptor, | 5075 Descriptor* descriptor, |
5078 int index, | 5076 int index, |
5079 TransitionFlag flag); | 5077 TransitionFlag flag); |
5080 MUST_USE_RESULT MaybeObject* CopyAsElementsKind(ElementsKind kind, | 5078 MUST_USE_RESULT MaybeObject* CopyAsElementsKind(ElementsKind kind, |
5081 TransitionFlag flag); | 5079 TransitionFlag flag); |
5082 | 5080 |
5083 MUST_USE_RESULT MaybeObject* CopyNormalized(PropertyNormalizationMode mode, | 5081 MUST_USE_RESULT MaybeObject* CopyNormalized(PropertyNormalizationMode mode, |
5084 NormalizedMapSharingMode sharing); | 5082 NormalizedMapSharingMode sharing); |
5085 | 5083 |
5086 inline void AppendDescriptor(Descriptor* desc, | 5084 inline void AppendDescriptor(Descriptor* desc, |
5087 const DescriptorArray::WhitenessWitness&); | 5085 const DescriptorArray::WhitenessWitness&); |
5088 | 5086 |
5089 // Returns a copy of the map, with all transitions dropped from the | 5087 // Returns a copy of the map, with all transitions dropped from the |
5090 // instance descriptors. | 5088 // instance descriptors. |
5091 MUST_USE_RESULT MaybeObject* Copy(); | 5089 MUST_USE_RESULT MaybeObject* Copy(); |
5092 | 5090 |
5093 // Returns the property index for name (only valid for FAST MODE). | 5091 // Returns the property index for name (only valid for FAST MODE). |
5094 int PropertyIndexFor(String* name); | 5092 int PropertyIndexFor(Name* name); |
5095 | 5093 |
5096 // Returns the next free property index (only valid for FAST MODE). | 5094 // Returns the next free property index (only valid for FAST MODE). |
5097 int NextFreePropertyIndex(); | 5095 int NextFreePropertyIndex(); |
5098 | 5096 |
5099 // Returns the number of properties described in instance_descriptors | 5097 // Returns the number of properties described in instance_descriptors |
5100 // filtering out properties with the specified attributes. | 5098 // filtering out properties with the specified attributes. |
5101 int NumberOfDescribedProperties(DescriptorFlag which = OWN_DESCRIPTORS, | 5099 int NumberOfDescribedProperties(DescriptorFlag which = OWN_DESCRIPTORS, |
5102 PropertyAttributes filter = NONE); | 5100 PropertyAttributes filter = NONE); |
5103 | 5101 |
5104 // Casting. | 5102 // Casting. |
5105 static inline Map* cast(Object* obj); | 5103 static inline Map* cast(Object* obj); |
5106 | 5104 |
5107 // Locate an accessor in the instance descriptor. | 5105 // Locate an accessor in the instance descriptor. |
5108 AccessorDescriptor* FindAccessor(String* name); | 5106 AccessorDescriptor* FindAccessor(Name* name); |
5109 | 5107 |
5110 // Code cache operations. | 5108 // Code cache operations. |
5111 | 5109 |
5112 // Clears the code cache. | 5110 // Clears the code cache. |
5113 inline void ClearCodeCache(Heap* heap); | 5111 inline void ClearCodeCache(Heap* heap); |
5114 | 5112 |
5115 // Update code cache. | 5113 // Update code cache. |
5116 static void UpdateCodeCache(Handle<Map> map, | 5114 static void UpdateCodeCache(Handle<Map> map, |
5117 Handle<String> name, | 5115 Handle<Name> name, |
5118 Handle<Code> code); | 5116 Handle<Code> code); |
5119 MUST_USE_RESULT MaybeObject* UpdateCodeCache(String* name, Code* code); | 5117 MUST_USE_RESULT MaybeObject* UpdateCodeCache(Name* name, Code* code); |
5120 | 5118 |
5121 // Extend the descriptor array of the map with the list of descriptors. | 5119 // Extend the descriptor array of the map with the list of descriptors. |
5122 // In case of duplicates, the latest descriptor is used. | 5120 // In case of duplicates, the latest descriptor is used. |
5123 static void AppendCallbackDescriptors(Handle<Map> map, | 5121 static void AppendCallbackDescriptors(Handle<Map> map, |
5124 Handle<Object> descriptors); | 5122 Handle<Object> descriptors); |
5125 | 5123 |
5126 static void EnsureDescriptorSlack(Handle<Map> map, int slack); | 5124 static void EnsureDescriptorSlack(Handle<Map> map, int slack); |
5127 | 5125 |
5128 // Returns the found code or undefined if absent. | 5126 // Returns the found code or undefined if absent. |
5129 Object* FindInCodeCache(String* name, Code::Flags flags); | 5127 Object* FindInCodeCache(Name* name, Code::Flags flags); |
5130 | 5128 |
5131 // Returns the non-negative index of the code object if it is in the | 5129 // Returns the non-negative index of the code object if it is in the |
5132 // cache and -1 otherwise. | 5130 // cache and -1 otherwise. |
5133 int IndexInCodeCache(Object* name, Code* code); | 5131 int IndexInCodeCache(Object* name, Code* code); |
5134 | 5132 |
5135 // Removes a code object from the code cache at the given index. | 5133 // Removes a code object from the code cache at the given index. |
5136 void RemoveFromCodeCache(String* name, Code* code, int index); | 5134 void RemoveFromCodeCache(Name* name, Code* code, int index); |
5137 | 5135 |
5138 // Set all map transitions from this map to dead maps to null. Also clear | 5136 // Set all map transitions from this map to dead maps to null. Also clear |
5139 // back pointers in transition targets so that we do not process this map | 5137 // back pointers in transition targets so that we do not process this map |
5140 // again while following back pointers. | 5138 // again while following back pointers. |
5141 void ClearNonLiveTransitions(Heap* heap); | 5139 void ClearNonLiveTransitions(Heap* heap); |
5142 | 5140 |
5143 // Computes a hash value for this map, to be used in HashTables and such. | 5141 // Computes a hash value for this map, to be used in HashTables and such. |
5144 int Hash(); | 5142 int Hash(); |
5145 | 5143 |
5146 // Compares this map to another to see if they describe equivalent objects. | 5144 // Compares this map to another to see if they describe equivalent objects. |
(...skipping 1190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6337 // [global receiver]: the global receiver object of the context | 6335 // [global receiver]: the global receiver object of the context |
6338 DECL_ACCESSORS(global_receiver, JSObject) | 6336 DECL_ACCESSORS(global_receiver, JSObject) |
6339 | 6337 |
6340 // Retrieve the property cell used to store a property. | 6338 // Retrieve the property cell used to store a property. |
6341 JSGlobalPropertyCell* GetPropertyCell(LookupResult* result); | 6339 JSGlobalPropertyCell* GetPropertyCell(LookupResult* result); |
6342 | 6340 |
6343 // This is like GetProperty, but is used when you know the lookup won't fail | 6341 // This is like GetProperty, but is used when you know the lookup won't fail |
6344 // by throwing an exception. This is for the debug and builtins global | 6342 // by throwing an exception. This is for the debug and builtins global |
6345 // objects, where it is known which properties can be expected to be present | 6343 // objects, where it is known which properties can be expected to be present |
6346 // on the object. | 6344 // on the object. |
6347 Object* GetPropertyNoExceptionThrown(String* key) { | 6345 Object* GetPropertyNoExceptionThrown(Name* key) { |
6348 Object* answer = GetProperty(key)->ToObjectUnchecked(); | 6346 Object* answer = GetProperty(key)->ToObjectUnchecked(); |
6349 return answer; | 6347 return answer; |
6350 } | 6348 } |
6351 | 6349 |
6352 // Ensure that the global object has a cell for the given property name. | 6350 // Ensure that the global object has a cell for the given property name. |
6353 static Handle<JSGlobalPropertyCell> EnsurePropertyCell( | 6351 static Handle<JSGlobalPropertyCell> EnsurePropertyCell( |
6354 Handle<GlobalObject> global, | 6352 Handle<GlobalObject> global, |
6355 Handle<String> name); | 6353 Handle<Name> name); |
6356 // TODO(kmillikin): This function can be eliminated once the stub cache is | 6354 // TODO(kmillikin): This function can be eliminated once the stub cache is |
6357 // fully handlified (and the static helper can be written directly). | 6355 // fully handlified (and the static helper can be written directly). |
6358 MUST_USE_RESULT MaybeObject* EnsurePropertyCell(String* name); | 6356 MUST_USE_RESULT MaybeObject* EnsurePropertyCell(Name* name); |
6359 | 6357 |
6360 // Casting. | 6358 // Casting. |
6361 static inline GlobalObject* cast(Object* obj); | 6359 static inline GlobalObject* cast(Object* obj); |
6362 | 6360 |
6363 // Layout description. | 6361 // Layout description. |
6364 static const int kBuiltinsOffset = JSObject::kHeaderSize; | 6362 static const int kBuiltinsOffset = JSObject::kHeaderSize; |
6365 static const int kNativeContextOffset = kBuiltinsOffset + kPointerSize; | 6363 static const int kNativeContextOffset = kBuiltinsOffset + kPointerSize; |
6366 static const int kGlobalContextOffset = kNativeContextOffset + kPointerSize; | 6364 static const int kGlobalContextOffset = kNativeContextOffset + kPointerSize; |
6367 static const int kGlobalReceiverOffset = kGlobalContextOffset + kPointerSize; | 6365 static const int kGlobalReceiverOffset = kGlobalContextOffset + kPointerSize; |
6368 static const int kHeaderSize = kGlobalReceiverOffset + kPointerSize; | 6366 static const int kHeaderSize = kGlobalReceiverOffset + kPointerSize; |
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6799 DISALLOW_IMPLICIT_CONSTRUCTORS(CompilationCacheTable); | 6797 DISALLOW_IMPLICIT_CONSTRUCTORS(CompilationCacheTable); |
6800 }; | 6798 }; |
6801 | 6799 |
6802 | 6800 |
6803 class CodeCache: public Struct { | 6801 class CodeCache: public Struct { |
6804 public: | 6802 public: |
6805 DECL_ACCESSORS(default_cache, FixedArray) | 6803 DECL_ACCESSORS(default_cache, FixedArray) |
6806 DECL_ACCESSORS(normal_type_cache, Object) | 6804 DECL_ACCESSORS(normal_type_cache, Object) |
6807 | 6805 |
6808 // Add the code object to the cache. | 6806 // Add the code object to the cache. |
6809 MUST_USE_RESULT MaybeObject* Update(String* name, Code* code); | 6807 MUST_USE_RESULT MaybeObject* Update(Name* name, Code* code); |
6810 | 6808 |
6811 // Lookup code object in the cache. Returns code object if found and undefined | 6809 // Lookup code object in the cache. Returns code object if found and undefined |
6812 // if not. | 6810 // if not. |
6813 Object* Lookup(String* name, Code::Flags flags); | 6811 Object* Lookup(Name* name, Code::Flags flags); |
6814 | 6812 |
6815 // Get the internal index of a code object in the cache. Returns -1 if the | 6813 // Get the internal index of a code object in the cache. Returns -1 if the |
6816 // code object is not in that cache. This index can be used to later call | 6814 // code object is not in that cache. This index can be used to later call |
6817 // RemoveByIndex. The cache cannot be modified between a call to GetIndex and | 6815 // RemoveByIndex. The cache cannot be modified between a call to GetIndex and |
6818 // RemoveByIndex. | 6816 // RemoveByIndex. |
6819 int GetIndex(Object* name, Code* code); | 6817 int GetIndex(Object* name, Code* code); |
6820 | 6818 |
6821 // Remove an object from the cache with the provided internal index. | 6819 // Remove an object from the cache with the provided internal index. |
6822 void RemoveByIndex(Object* name, Code* code, int index); | 6820 void RemoveByIndex(Object* name, Code* code, int index); |
6823 | 6821 |
6824 static inline CodeCache* cast(Object* obj); | 6822 static inline CodeCache* cast(Object* obj); |
6825 | 6823 |
6826 // Dispatched behavior. | 6824 // Dispatched behavior. |
6827 DECLARE_PRINTER(CodeCache) | 6825 DECLARE_PRINTER(CodeCache) |
6828 DECLARE_VERIFIER(CodeCache) | 6826 DECLARE_VERIFIER(CodeCache) |
6829 | 6827 |
6830 static const int kDefaultCacheOffset = HeapObject::kHeaderSize; | 6828 static const int kDefaultCacheOffset = HeapObject::kHeaderSize; |
6831 static const int kNormalTypeCacheOffset = | 6829 static const int kNormalTypeCacheOffset = |
6832 kDefaultCacheOffset + kPointerSize; | 6830 kDefaultCacheOffset + kPointerSize; |
6833 static const int kSize = kNormalTypeCacheOffset + kPointerSize; | 6831 static const int kSize = kNormalTypeCacheOffset + kPointerSize; |
6834 | 6832 |
6835 private: | 6833 private: |
6836 MUST_USE_RESULT MaybeObject* UpdateDefaultCache(String* name, Code* code); | 6834 MUST_USE_RESULT MaybeObject* UpdateDefaultCache(Name* name, Code* code); |
6837 MUST_USE_RESULT MaybeObject* UpdateNormalTypeCache(String* name, Code* code); | 6835 MUST_USE_RESULT MaybeObject* UpdateNormalTypeCache(Name* name, Code* code); |
6838 Object* LookupDefaultCache(String* name, Code::Flags flags); | 6836 Object* LookupDefaultCache(Name* name, Code::Flags flags); |
6839 Object* LookupNormalTypeCache(String* name, Code::Flags flags); | 6837 Object* LookupNormalTypeCache(Name* name, Code::Flags flags); |
6840 | 6838 |
6841 // Code cache layout of the default cache. Elements are alternating name and | 6839 // Code cache layout of the default cache. Elements are alternating name and |
6842 // code objects for non normal load/store/call IC's. | 6840 // code objects for non normal load/store/call IC's. |
6843 static const int kCodeCacheEntrySize = 2; | 6841 static const int kCodeCacheEntrySize = 2; |
6844 static const int kCodeCacheEntryNameOffset = 0; | 6842 static const int kCodeCacheEntryNameOffset = 0; |
6845 static const int kCodeCacheEntryCodeOffset = 1; | 6843 static const int kCodeCacheEntryCodeOffset = 1; |
6846 | 6844 |
6847 DISALLOW_IMPLICIT_CONSTRUCTORS(CodeCache); | 6845 DISALLOW_IMPLICIT_CONSTRUCTORS(CodeCache); |
6848 }; | 6846 }; |
6849 | 6847 |
(...skipping 17 matching lines...) Expand all Loading... |
6867 } | 6865 } |
6868 | 6866 |
6869 static const int kPrefixSize = 0; | 6867 static const int kPrefixSize = 0; |
6870 static const int kEntrySize = 2; | 6868 static const int kEntrySize = 2; |
6871 }; | 6869 }; |
6872 | 6870 |
6873 | 6871 |
6874 class CodeCacheHashTable: public HashTable<CodeCacheHashTableShape, | 6872 class CodeCacheHashTable: public HashTable<CodeCacheHashTableShape, |
6875 HashTableKey*> { | 6873 HashTableKey*> { |
6876 public: | 6874 public: |
6877 Object* Lookup(String* name, Code::Flags flags); | 6875 Object* Lookup(Name* name, Code::Flags flags); |
6878 MUST_USE_RESULT MaybeObject* Put(String* name, Code* code); | 6876 MUST_USE_RESULT MaybeObject* Put(Name* name, Code* code); |
6879 | 6877 |
6880 int GetIndex(String* name, Code::Flags flags); | 6878 int GetIndex(Name* name, Code::Flags flags); |
6881 void RemoveByIndex(int index); | 6879 void RemoveByIndex(int index); |
6882 | 6880 |
6883 static inline CodeCacheHashTable* cast(Object* obj); | 6881 static inline CodeCacheHashTable* cast(Object* obj); |
6884 | 6882 |
6885 // Initial size of the fixed array backing the hash table. | 6883 // Initial size of the fixed array backing the hash table. |
6886 static const int kInitialSize = 64; | 6884 static const int kInitialSize = 64; |
6887 | 6885 |
6888 private: | 6886 private: |
6889 DISALLOW_IMPLICIT_CONSTRUCTORS(CodeCacheHashTable); | 6887 DISALLOW_IMPLICIT_CONSTRUCTORS(CodeCacheHashTable); |
6890 }; | 6888 }; |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7155 // Get and set the hash field of the name. | 7153 // Get and set the hash field of the name. |
7156 inline uint32_t hash_field(); | 7154 inline uint32_t hash_field(); |
7157 inline void set_hash_field(uint32_t value); | 7155 inline void set_hash_field(uint32_t value); |
7158 | 7156 |
7159 // Tells whether the hash code has been computed. | 7157 // Tells whether the hash code has been computed. |
7160 inline bool HasHashCode(); | 7158 inline bool HasHashCode(); |
7161 | 7159 |
7162 // Returns a hash value used for the property table | 7160 // Returns a hash value used for the property table |
7163 inline uint32_t Hash(); | 7161 inline uint32_t Hash(); |
7164 | 7162 |
| 7163 // Equality operations. |
| 7164 inline bool Equals(Name* other); |
| 7165 |
| 7166 // Conversion. |
| 7167 inline bool AsArrayIndex(uint32_t* index); |
| 7168 |
7165 // Casting. | 7169 // Casting. |
7166 static inline Name* cast(Object* obj); | 7170 static inline Name* cast(Object* obj); |
7167 | 7171 |
| 7172 DECLARE_PRINTER(Name) |
| 7173 |
7168 // Layout description. | 7174 // Layout description. |
7169 static const int kHashFieldOffset = HeapObject::kHeaderSize; | 7175 static const int kHashFieldOffset = HeapObject::kHeaderSize; |
7170 static const int kSize = kHashFieldOffset + kPointerSize; | 7176 static const int kSize = kHashFieldOffset + kPointerSize; |
7171 | 7177 |
7172 // Mask constant for checking if a name has a computed hash code | 7178 // Mask constant for checking if a name has a computed hash code |
7173 // and if it is a string that is an array index. The least significant bit | 7179 // and if it is a string that is an array index. The least significant bit |
7174 // indicates whether a hash code has been computed. If the hash code has | 7180 // indicates whether a hash code has been computed. If the hash code has |
7175 // been computed the 2nd bit tells whether the string can be used as an | 7181 // been computed the 2nd bit tells whether the string can be used as an |
7176 // array index. | 7182 // array index. |
7177 static const int kHashNotComputedMask = 1; | 7183 static const int kHashNotComputedMask = 1; |
(...skipping 900 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8078 public: | 8084 public: |
8079 // [handler]: The handler property. | 8085 // [handler]: The handler property. |
8080 DECL_ACCESSORS(handler, Object) | 8086 DECL_ACCESSORS(handler, Object) |
8081 | 8087 |
8082 // [hash]: The hash code property (undefined if not initialized yet). | 8088 // [hash]: The hash code property (undefined if not initialized yet). |
8083 DECL_ACCESSORS(hash, Object) | 8089 DECL_ACCESSORS(hash, Object) |
8084 | 8090 |
8085 // Casting. | 8091 // Casting. |
8086 static inline JSProxy* cast(Object* obj); | 8092 static inline JSProxy* cast(Object* obj); |
8087 | 8093 |
8088 bool HasPropertyWithHandler(String* name); | 8094 bool HasPropertyWithHandler(Name* name); |
8089 bool HasElementWithHandler(uint32_t index); | 8095 bool HasElementWithHandler(uint32_t index); |
8090 | 8096 |
8091 MUST_USE_RESULT MaybeObject* GetPropertyWithHandler( | 8097 MUST_USE_RESULT MaybeObject* GetPropertyWithHandler( |
8092 Object* receiver, | 8098 Object* receiver, |
8093 String* name); | 8099 Name* name); |
8094 MUST_USE_RESULT MaybeObject* GetElementWithHandler( | 8100 MUST_USE_RESULT MaybeObject* GetElementWithHandler( |
8095 Object* receiver, | 8101 Object* receiver, |
8096 uint32_t index); | 8102 uint32_t index); |
8097 | 8103 |
8098 MUST_USE_RESULT MaybeObject* SetPropertyWithHandler( | 8104 MUST_USE_RESULT MaybeObject* SetPropertyWithHandler( |
8099 JSReceiver* receiver, | 8105 JSReceiver* receiver, |
8100 String* name, | 8106 Name* name, |
8101 Object* value, | 8107 Object* value, |
8102 PropertyAttributes attributes, | 8108 PropertyAttributes attributes, |
8103 StrictModeFlag strict_mode); | 8109 StrictModeFlag strict_mode); |
8104 MUST_USE_RESULT MaybeObject* SetElementWithHandler( | 8110 MUST_USE_RESULT MaybeObject* SetElementWithHandler( |
8105 JSReceiver* receiver, | 8111 JSReceiver* receiver, |
8106 uint32_t index, | 8112 uint32_t index, |
8107 Object* value, | 8113 Object* value, |
8108 StrictModeFlag strict_mode); | 8114 StrictModeFlag strict_mode); |
8109 | 8115 |
8110 // If the handler defines an accessor property with a setter, invoke it. | 8116 // If the handler defines an accessor property with a setter, invoke it. |
8111 // If it defines an accessor property without a setter, or a data property | 8117 // If it defines an accessor property without a setter, or a data property |
8112 // that is read-only, throw. In all these cases set '*done' to true, | 8118 // that is read-only, throw. In all these cases set '*done' to true, |
8113 // otherwise set it to false. | 8119 // otherwise set it to false. |
8114 MUST_USE_RESULT MaybeObject* SetPropertyViaPrototypesWithHandler( | 8120 MUST_USE_RESULT MaybeObject* SetPropertyViaPrototypesWithHandler( |
8115 JSReceiver* receiver, | 8121 JSReceiver* receiver, |
8116 String* name, | 8122 Name* name, |
8117 Object* value, | 8123 Object* value, |
8118 PropertyAttributes attributes, | 8124 PropertyAttributes attributes, |
8119 StrictModeFlag strict_mode, | 8125 StrictModeFlag strict_mode, |
8120 bool* done); | 8126 bool* done); |
8121 | 8127 |
8122 MUST_USE_RESULT MaybeObject* DeletePropertyWithHandler( | 8128 MUST_USE_RESULT MaybeObject* DeletePropertyWithHandler( |
8123 String* name, | 8129 Name* name, |
8124 DeleteMode mode); | 8130 DeleteMode mode); |
8125 MUST_USE_RESULT MaybeObject* DeleteElementWithHandler( | 8131 MUST_USE_RESULT MaybeObject* DeleteElementWithHandler( |
8126 uint32_t index, | 8132 uint32_t index, |
8127 DeleteMode mode); | 8133 DeleteMode mode); |
8128 | 8134 |
8129 MUST_USE_RESULT PropertyAttributes GetPropertyAttributeWithHandler( | 8135 MUST_USE_RESULT PropertyAttributes GetPropertyAttributeWithHandler( |
8130 JSReceiver* receiver, | 8136 JSReceiver* receiver, |
8131 String* name); | 8137 Name* name); |
8132 MUST_USE_RESULT PropertyAttributes GetElementAttributeWithHandler( | 8138 MUST_USE_RESULT PropertyAttributes GetElementAttributeWithHandler( |
8133 JSReceiver* receiver, | 8139 JSReceiver* receiver, |
8134 uint32_t index); | 8140 uint32_t index); |
8135 | 8141 |
8136 MUST_USE_RESULT MaybeObject* GetIdentityHash(CreationFlag flag); | 8142 MUST_USE_RESULT MaybeObject* GetIdentityHash(CreationFlag flag); |
8137 | 8143 |
8138 // Turn this into an (empty) JSObject. | 8144 // Turn this into an (empty) JSObject. |
8139 void Fix(); | 8145 void Fix(); |
8140 | 8146 |
8141 // Initializes the body after the handler slot. | 8147 // Initializes the body after the handler slot. |
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8945 } else { | 8951 } else { |
8946 value &= ~(1 << bit_position); | 8952 value &= ~(1 << bit_position); |
8947 } | 8953 } |
8948 return value; | 8954 return value; |
8949 } | 8955 } |
8950 }; | 8956 }; |
8951 | 8957 |
8952 } } // namespace v8::internal | 8958 } } // namespace v8::internal |
8953 | 8959 |
8954 #endif // V8_OBJECTS_H_ | 8960 #endif // V8_OBJECTS_H_ |
OLD | NEW |