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 1932 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1943 // Internal properties (e.g. the hidden properties dictionary) might | 1943 // Internal properties (e.g. the hidden properties dictionary) might |
1944 // be added even though the receiver is non-extensible. | 1944 // be added even though the receiver is non-extensible. |
1945 enum ExtensibilityCheck { | 1945 enum ExtensibilityCheck { |
1946 PERFORM_EXTENSIBILITY_CHECK, | 1946 PERFORM_EXTENSIBILITY_CHECK, |
1947 OMIT_EXTENSIBILITY_CHECK | 1947 OMIT_EXTENSIBILITY_CHECK |
1948 }; | 1948 }; |
1949 | 1949 |
1950 // Casting. | 1950 // Casting. |
1951 static inline JSReceiver* cast(Object* obj); | 1951 static inline JSReceiver* cast(Object* obj); |
1952 | 1952 |
| 1953 // Implementation of [[Put]], see ECMA-262 5th edition, section 8.12.5. |
1953 static Handle<Object> SetProperty(Handle<JSReceiver> object, | 1954 static Handle<Object> SetProperty(Handle<JSReceiver> object, |
1954 Handle<Name> key, | 1955 Handle<Name> key, |
1955 Handle<Object> value, | 1956 Handle<Object> value, |
1956 PropertyAttributes attributes, | 1957 PropertyAttributes attributes, |
1957 StrictModeFlag strict_mode); | 1958 StrictModeFlag strict_mode, |
| 1959 StoreFromKeyed store_mode = |
| 1960 MAY_BE_STORE_FROM_KEYED); |
1958 static Handle<Object> SetElement(Handle<JSReceiver> object, | 1961 static Handle<Object> SetElement(Handle<JSReceiver> object, |
1959 uint32_t index, | 1962 uint32_t index, |
1960 Handle<Object> value, | 1963 Handle<Object> value, |
1961 PropertyAttributes attributes, | 1964 PropertyAttributes attributes, |
1962 StrictModeFlag strict_mode); | 1965 StrictModeFlag strict_mode); |
1963 | 1966 |
1964 MUST_USE_RESULT static MaybeObject* SetPropertyOrFail( | |
1965 Handle<JSReceiver> object, | |
1966 Handle<Name> key, | |
1967 Handle<Object> value, | |
1968 PropertyAttributes attributes, | |
1969 StrictModeFlag strict_mode, | |
1970 StoreFromKeyed store_from_keyed = MAY_BE_STORE_FROM_KEYED); | |
1971 | |
1972 // Can cause GC. | |
1973 MUST_USE_RESULT MaybeObject* SetProperty( | |
1974 Name* key, | |
1975 Object* value, | |
1976 PropertyAttributes attributes, | |
1977 StrictModeFlag strict_mode, | |
1978 StoreFromKeyed store_from_keyed = MAY_BE_STORE_FROM_KEYED); | |
1979 MUST_USE_RESULT MaybeObject* SetProperty( | |
1980 LookupResult* result, | |
1981 Name* key, | |
1982 Object* value, | |
1983 PropertyAttributes attributes, | |
1984 StrictModeFlag strict_mode, | |
1985 StoreFromKeyed store_from_keyed = MAY_BE_STORE_FROM_KEYED); | |
1986 MUST_USE_RESULT MaybeObject* SetPropertyWithDefinedSetter(JSReceiver* setter, | 1967 MUST_USE_RESULT MaybeObject* SetPropertyWithDefinedSetter(JSReceiver* setter, |
1987 Object* value); | 1968 Object* value); |
1988 | 1969 |
| 1970 // Implementation of [[Delete]], see ECMA-262 5th edition, section 8.12.7. |
1989 static Handle<Object> DeleteProperty(Handle<JSReceiver> object, | 1971 static Handle<Object> DeleteProperty(Handle<JSReceiver> object, |
1990 Handle<Name> name, | 1972 Handle<Name> name, |
1991 DeleteMode mode = NORMAL_DELETION); | 1973 DeleteMode mode = NORMAL_DELETION); |
1992 static Handle<Object> DeleteElement(Handle<JSReceiver> object, | 1974 static Handle<Object> DeleteElement(Handle<JSReceiver> object, |
1993 uint32_t index, | 1975 uint32_t index, |
1994 DeleteMode mode = NORMAL_DELETION); | 1976 DeleteMode mode = NORMAL_DELETION); |
1995 | 1977 |
1996 // Tests for the fast common case for property enumeration. | 1978 // Tests for the fast common case for property enumeration. |
1997 bool IsSimpleEnum(); | 1979 bool IsSimpleEnum(); |
1998 | 1980 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2035 | 2017 |
2036 protected: | 2018 protected: |
2037 Smi* GenerateIdentityHash(); | 2019 Smi* GenerateIdentityHash(); |
2038 | 2020 |
2039 private: | 2021 private: |
2040 PropertyAttributes GetPropertyAttributeForResult(JSReceiver* receiver, | 2022 PropertyAttributes GetPropertyAttributeForResult(JSReceiver* receiver, |
2041 LookupResult* result, | 2023 LookupResult* result, |
2042 Name* name, | 2024 Name* name, |
2043 bool continue_search); | 2025 bool continue_search); |
2044 | 2026 |
| 2027 static Handle<Object> SetProperty(Handle<JSReceiver> receiver, |
| 2028 LookupResult* result, |
| 2029 Handle<Name> key, |
| 2030 Handle<Object> value, |
| 2031 PropertyAttributes attributes, |
| 2032 StrictModeFlag strict_mode, |
| 2033 StoreFromKeyed store_from_keyed); |
| 2034 |
2045 DISALLOW_IMPLICIT_CONSTRUCTORS(JSReceiver); | 2035 DISALLOW_IMPLICIT_CONSTRUCTORS(JSReceiver); |
2046 }; | 2036 }; |
2047 | 2037 |
2048 // The JSObject describes real heap allocated JavaScript objects with | 2038 // The JSObject describes real heap allocated JavaScript objects with |
2049 // properties. | 2039 // properties. |
2050 // Note that the map of JSObject changes during execution to enable inline | 2040 // Note that the map of JSObject changes during execution to enable inline |
2051 // caching. | 2041 // caching. |
2052 class JSObject: public JSReceiver { | 2042 class JSObject: public JSReceiver { |
2053 public: | 2043 public: |
2054 // [properties]: Backing storage for properties. | 2044 // [properties]: Backing storage for properties. |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2128 // Returns the number of non-undefined values. | 2118 // Returns the number of non-undefined values. |
2129 MUST_USE_RESULT MaybeObject* PrepareElementsForSort(uint32_t limit); | 2119 MUST_USE_RESULT MaybeObject* PrepareElementsForSort(uint32_t limit); |
2130 // As PrepareElementsForSort, but only on objects where elements is | 2120 // As PrepareElementsForSort, but only on objects where elements is |
2131 // a dictionary, and it will stay a dictionary. | 2121 // a dictionary, and it will stay a dictionary. |
2132 MUST_USE_RESULT MaybeObject* PrepareSlowElementsForSort(uint32_t limit); | 2122 MUST_USE_RESULT MaybeObject* PrepareSlowElementsForSort(uint32_t limit); |
2133 | 2123 |
2134 MUST_USE_RESULT MaybeObject* GetPropertyWithCallback(Object* receiver, | 2124 MUST_USE_RESULT MaybeObject* GetPropertyWithCallback(Object* receiver, |
2135 Object* structure, | 2125 Object* structure, |
2136 Name* name); | 2126 Name* name); |
2137 | 2127 |
2138 // Can cause GC. | |
2139 MUST_USE_RESULT MaybeObject* SetPropertyForResult(LookupResult* result, | |
2140 Name* key, | |
2141 Object* value, | |
2142 PropertyAttributes attributes, | |
2143 StrictModeFlag strict_mode, | |
2144 StoreFromKeyed store_mode); | |
2145 MUST_USE_RESULT MaybeObject* SetPropertyWithFailedAccessCheck( | 2128 MUST_USE_RESULT MaybeObject* SetPropertyWithFailedAccessCheck( |
2146 LookupResult* result, | 2129 LookupResult* result, |
2147 Name* name, | 2130 Name* name, |
2148 Object* value, | 2131 Object* value, |
2149 bool check_prototype, | 2132 bool check_prototype, |
2150 StrictModeFlag strict_mode); | 2133 StrictModeFlag strict_mode); |
2151 MUST_USE_RESULT MaybeObject* SetPropertyWithCallback( | 2134 MUST_USE_RESULT MaybeObject* SetPropertyWithCallback( |
2152 Object* structure, | 2135 Object* structure, |
2153 Name* name, | 2136 Name* name, |
2154 Object* value, | 2137 Object* value, |
2155 JSObject* holder, | 2138 JSObject* holder, |
2156 StrictModeFlag strict_mode); | 2139 StrictModeFlag strict_mode); |
2157 MUST_USE_RESULT MaybeObject* SetPropertyWithInterceptor( | 2140 static Handle<Object> SetPropertyWithInterceptor( |
2158 Name* name, | 2141 Handle<JSObject> object, |
2159 Object* value, | 2142 Handle<Name> name, |
| 2143 Handle<Object> value, |
2160 PropertyAttributes attributes, | 2144 PropertyAttributes attributes, |
2161 StrictModeFlag strict_mode); | 2145 StrictModeFlag strict_mode); |
2162 MUST_USE_RESULT MaybeObject* SetPropertyPostInterceptor( | 2146 |
2163 Name* name, | 2147 static Handle<Object> SetPropertyForResult( |
2164 Object* value, | 2148 Handle<JSObject> object, |
| 2149 LookupResult* result, |
| 2150 Handle<Name> name, |
| 2151 Handle<Object> value, |
2165 PropertyAttributes attributes, | 2152 PropertyAttributes attributes, |
2166 StrictModeFlag strict_mode, | 2153 StrictModeFlag strict_mode, |
2167 StoreMode mode = ALLOW_AS_CONSTANT); | 2154 StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED); |
2168 | 2155 |
2169 static Handle<Object> SetLocalPropertyIgnoreAttributes( | 2156 static Handle<Object> SetLocalPropertyIgnoreAttributes( |
2170 Handle<JSObject> object, | 2157 Handle<JSObject> object, |
2171 Handle<Name> key, | 2158 Handle<Name> key, |
2172 Handle<Object> value, | 2159 Handle<Object> value, |
2173 PropertyAttributes attributes, | 2160 PropertyAttributes attributes, |
2174 ValueType value_type = OPTIMAL_REPRESENTATION, | 2161 ValueType value_type = OPTIMAL_REPRESENTATION, |
2175 StoreMode mode = ALLOW_AS_CONSTANT, | 2162 StoreMode mode = ALLOW_AS_CONSTANT, |
2176 ExtensibilityCheck extensibility_check = PERFORM_EXTENSIBILITY_CHECK); | 2163 ExtensibilityCheck extensibility_check = PERFORM_EXTENSIBILITY_CHECK); |
2177 | 2164 |
2178 static inline Handle<String> ExpectedTransitionKey(Handle<Map> map); | 2165 static inline Handle<String> ExpectedTransitionKey(Handle<Map> map); |
2179 static inline Handle<Map> ExpectedTransitionTarget(Handle<Map> map); | 2166 static inline Handle<Map> ExpectedTransitionTarget(Handle<Map> map); |
2180 | 2167 |
2181 // Try to follow an existing transition to a field with attributes NONE. The | 2168 // Try to follow an existing transition to a field with attributes NONE. The |
2182 // return value indicates whether the transition was successful. | 2169 // return value indicates whether the transition was successful. |
2183 static inline Handle<Map> FindTransitionToField(Handle<Map> map, | 2170 static inline Handle<Map> FindTransitionToField(Handle<Map> map, |
2184 Handle<Name> key); | 2171 Handle<Name> key); |
2185 | 2172 |
2186 inline int LastAddedFieldIndex(); | 2173 inline int LastAddedFieldIndex(); |
2187 | 2174 |
2188 // Extend the receiver with a single fast property appeared first in the | 2175 // Extend the receiver with a single fast property appeared first in the |
2189 // passed map. This also extends the property backing store if necessary. | 2176 // passed map. This also extends the property backing store if necessary. |
2190 static void AllocateStorageForMap(Handle<JSObject> object, Handle<Map> map); | 2177 static void AllocateStorageForMap(Handle<JSObject> object, Handle<Map> map); |
2191 inline MUST_USE_RESULT MaybeObject* AllocateStorageForMap(Map* map); | 2178 inline MUST_USE_RESULT MaybeObject* AllocateStorageForMap(Map* map); |
2192 | 2179 |
2193 static void MigrateInstance(Handle<JSObject> instance); | 2180 static void MigrateInstance(Handle<JSObject> instance); |
2194 inline MUST_USE_RESULT MaybeObject* MigrateInstance(); | |
2195 | 2181 |
2196 static Handle<Object> TryMigrateInstance(Handle<JSObject> instance); | 2182 static Handle<Object> TryMigrateInstance(Handle<JSObject> instance); |
2197 inline MUST_USE_RESULT MaybeObject* TryMigrateInstance(); | 2183 inline MUST_USE_RESULT MaybeObject* TryMigrateInstance(); |
2198 | 2184 |
2199 // Can cause GC. | 2185 // Can cause GC. |
2200 MUST_USE_RESULT MaybeObject* SetLocalPropertyIgnoreAttributesTrampoline( | 2186 MUST_USE_RESULT MaybeObject* SetLocalPropertyIgnoreAttributesTrampoline( |
2201 Name* key, | 2187 Name* key, |
2202 Object* value, | 2188 Object* value, |
2203 PropertyAttributes attributes, | 2189 PropertyAttributes attributes, |
2204 ValueType value_type = OPTIMAL_REPRESENTATION, | 2190 ValueType value_type = OPTIMAL_REPRESENTATION, |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2476 // Returns the number of elements on this object filtering out elements | 2462 // Returns the number of elements on this object filtering out elements |
2477 // with the specified attributes (ignoring interceptors). | 2463 // with the specified attributes (ignoring interceptors). |
2478 int GetLocalElementKeys(FixedArray* storage, PropertyAttributes filter); | 2464 int GetLocalElementKeys(FixedArray* storage, PropertyAttributes filter); |
2479 // Count and fill in the enumerable elements into storage. | 2465 // Count and fill in the enumerable elements into storage. |
2480 // (storage->length() == NumberOfEnumElements()). | 2466 // (storage->length() == NumberOfEnumElements()). |
2481 // If storage is NULL, will count the elements without adding | 2467 // If storage is NULL, will count the elements without adding |
2482 // them to any storage. | 2468 // them to any storage. |
2483 // Returns the number of enumerable elements. | 2469 // Returns the number of enumerable elements. |
2484 int GetEnumElementKeys(FixedArray* storage); | 2470 int GetEnumElementKeys(FixedArray* storage); |
2485 | 2471 |
2486 // Add a property to a fast-case object using a map transition to | |
2487 // new_map. | |
2488 MUST_USE_RESULT MaybeObject* AddFastPropertyUsingMap( | |
2489 Map* new_map, | |
2490 Name* name, | |
2491 Object* value, | |
2492 int field_index, | |
2493 Representation representation); | |
2494 | |
2495 // Add a constant function property to a fast-case object. | |
2496 // This leaves a CONSTANT_TRANSITION in the old map, and | |
2497 // if it is called on a second object with this map, a | |
2498 // normal property is added instead, with a map transition. | |
2499 // This avoids the creation of many maps with the same constant | |
2500 // function, all orphaned. | |
2501 MUST_USE_RESULT MaybeObject* AddConstantProperty( | |
2502 Name* name, | |
2503 Object* constant, | |
2504 PropertyAttributes attributes, | |
2505 TransitionFlag flag); | |
2506 | |
2507 MUST_USE_RESULT MaybeObject* ReplaceSlowProperty( | |
2508 Name* name, | |
2509 Object* value, | |
2510 PropertyAttributes attributes); | |
2511 | |
2512 // Returns a new map with all transitions dropped from the object's current | 2472 // Returns a new map with all transitions dropped from the object's current |
2513 // map and the ElementsKind set. | 2473 // map and the ElementsKind set. |
2514 static Handle<Map> GetElementsTransitionMap(Handle<JSObject> object, | 2474 static Handle<Map> GetElementsTransitionMap(Handle<JSObject> object, |
2515 ElementsKind to_kind); | 2475 ElementsKind to_kind); |
2516 inline MUST_USE_RESULT MaybeObject* GetElementsTransitionMap( | 2476 inline MUST_USE_RESULT MaybeObject* GetElementsTransitionMap( |
2517 Isolate* isolate, | 2477 Isolate* isolate, |
2518 ElementsKind elements_kind); | 2478 ElementsKind elements_kind); |
2519 MUST_USE_RESULT MaybeObject* GetElementsTransitionMapSlow( | 2479 MUST_USE_RESULT MaybeObject* GetElementsTransitionMapSlow( |
2520 ElementsKind elements_kind); | 2480 ElementsKind elements_kind); |
2521 | 2481 |
2522 static Handle<Object> TransitionElementsKind(Handle<JSObject> object, | 2482 static Handle<Object> TransitionElementsKind(Handle<JSObject> object, |
2523 ElementsKind to_kind); | 2483 ElementsKind to_kind); |
2524 | 2484 |
2525 MUST_USE_RESULT MaybeObject* TransitionElementsKind(ElementsKind to_kind); | 2485 MUST_USE_RESULT MaybeObject* TransitionElementsKind(ElementsKind to_kind); |
2526 MUST_USE_RESULT MaybeObject* UpdateAllocationSite(ElementsKind to_kind); | 2486 MUST_USE_RESULT MaybeObject* UpdateAllocationSite(ElementsKind to_kind); |
2527 | 2487 |
| 2488 static void MigrateToMap(Handle<JSObject> object, Handle<Map> new_map); |
2528 MUST_USE_RESULT MaybeObject* MigrateToMap(Map* new_map); | 2489 MUST_USE_RESULT MaybeObject* MigrateToMap(Map* new_map); |
2529 MUST_USE_RESULT MaybeObject* GeneralizeFieldRepresentation( | 2490 static void GeneralizeFieldRepresentation(Handle<JSObject> object, |
2530 int modify_index, | 2491 int modify_index, |
2531 Representation new_representation, | 2492 Representation new_representation, |
2532 StoreMode store_mode); | 2493 StoreMode store_mode); |
2533 | |
2534 // Add a property to a fast-case object. | |
2535 MUST_USE_RESULT MaybeObject* AddFastProperty( | |
2536 Name* name, | |
2537 Object* value, | |
2538 PropertyAttributes attributes, | |
2539 StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED, | |
2540 ValueType value_type = OPTIMAL_REPRESENTATION, | |
2541 TransitionFlag flag = INSERT_TRANSITION); | |
2542 | |
2543 // Add a property to a slow-case object. | |
2544 MUST_USE_RESULT MaybeObject* AddSlowProperty(Name* name, | |
2545 Object* value, | |
2546 PropertyAttributes attributes); | |
2547 | |
2548 // Add a property to an object. May cause GC. | |
2549 MUST_USE_RESULT MaybeObject* AddProperty( | |
2550 Name* name, | |
2551 Object* value, | |
2552 PropertyAttributes attributes, | |
2553 StrictModeFlag strict_mode, | |
2554 StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED, | |
2555 ExtensibilityCheck extensibility_check = PERFORM_EXTENSIBILITY_CHECK, | |
2556 ValueType value_type = OPTIMAL_REPRESENTATION, | |
2557 StoreMode mode = ALLOW_AS_CONSTANT, | |
2558 TransitionFlag flag = INSERT_TRANSITION); | |
2559 | 2494 |
2560 // Convert the object to use the canonical dictionary | 2495 // Convert the object to use the canonical dictionary |
2561 // representation. If the object is expected to have additional properties | 2496 // representation. If the object is expected to have additional properties |
2562 // added this number can be indicated to have the backing store allocated to | 2497 // added this number can be indicated to have the backing store allocated to |
2563 // an initial capacity for holding these properties. | 2498 // an initial capacity for holding these properties. |
2564 static void NormalizeProperties(Handle<JSObject> object, | 2499 static void NormalizeProperties(Handle<JSObject> object, |
2565 PropertyNormalizationMode mode, | 2500 PropertyNormalizationMode mode, |
2566 int expected_additional_properties); | 2501 int expected_additional_properties); |
2567 | 2502 |
2568 MUST_USE_RESULT MaybeObject* NormalizeProperties( | 2503 MUST_USE_RESULT MaybeObject* NormalizeProperties( |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2728 Handle<Name> name, | 2663 Handle<Name> name, |
2729 Handle<Object> old_value); | 2664 Handle<Object> old_value); |
2730 | 2665 |
2731 // Deliver change records to observers. May cause GC. | 2666 // Deliver change records to observers. May cause GC. |
2732 static void DeliverChangeRecords(Isolate* isolate); | 2667 static void DeliverChangeRecords(Isolate* isolate); |
2733 | 2668 |
2734 private: | 2669 private: |
2735 friend class DictionaryElementsAccessor; | 2670 friend class DictionaryElementsAccessor; |
2736 friend class JSReceiver; | 2671 friend class JSReceiver; |
2737 | 2672 |
2738 // TODO(mstarzinger): Soon to be handlified. | |
2739 MUST_USE_RESULT MaybeObject* SetLocalPropertyIgnoreAttributes( | |
2740 Name* key, | |
2741 Object* value, | |
2742 PropertyAttributes attributes, | |
2743 ValueType value_type = OPTIMAL_REPRESENTATION, | |
2744 StoreMode mode = ALLOW_AS_CONSTANT, | |
2745 ExtensibilityCheck extensibility_check = PERFORM_EXTENSIBILITY_CHECK); | |
2746 | |
2747 MUST_USE_RESULT MaybeObject* GetElementWithCallback(Object* receiver, | 2673 MUST_USE_RESULT MaybeObject* GetElementWithCallback(Object* receiver, |
2748 Object* structure, | 2674 Object* structure, |
2749 uint32_t index, | 2675 uint32_t index, |
2750 Object* holder); | 2676 Object* holder); |
2751 MUST_USE_RESULT PropertyAttributes GetElementAttributeWithInterceptor( | 2677 MUST_USE_RESULT PropertyAttributes GetElementAttributeWithInterceptor( |
2752 JSReceiver* receiver, | 2678 JSReceiver* receiver, |
2753 uint32_t index, | 2679 uint32_t index, |
2754 bool continue_search); | 2680 bool continue_search); |
2755 MUST_USE_RESULT PropertyAttributes GetElementAttributeWithoutInterceptor( | 2681 MUST_USE_RESULT PropertyAttributes GetElementAttributeWithoutInterceptor( |
2756 JSReceiver* receiver, | 2682 JSReceiver* receiver, |
(...skipping 16 matching lines...) Expand all Loading... |
2773 uint32_t index, | 2699 uint32_t index, |
2774 Object* value, | 2700 Object* value, |
2775 PropertyAttributes attributes, | 2701 PropertyAttributes attributes, |
2776 StrictModeFlag strict_mode, | 2702 StrictModeFlag strict_mode, |
2777 bool check_prototype, | 2703 bool check_prototype, |
2778 SetPropertyMode set_mode); | 2704 SetPropertyMode set_mode); |
2779 | 2705 |
2780 // Searches the prototype chain for property 'name'. If it is found and | 2706 // Searches the prototype chain for property 'name'. If it is found and |
2781 // has a setter, invoke it and set '*done' to true. If it is found and is | 2707 // has a setter, invoke it and set '*done' to true. If it is found and is |
2782 // read-only, reject and set '*done' to true. Otherwise, set '*done' to | 2708 // read-only, reject and set '*done' to true. Otherwise, set '*done' to |
2783 // false. Can cause GC and can return a failure result with '*done==true'. | 2709 // false. Can throw and return an empty handle with '*done==true'. |
2784 MUST_USE_RESULT MaybeObject* SetPropertyViaPrototypes( | 2710 static Handle<Object> SetPropertyViaPrototypes( |
2785 Name* name, | 2711 Handle<JSObject> object, |
2786 Object* value, | 2712 Handle<Name> name, |
| 2713 Handle<Object> value, |
2787 PropertyAttributes attributes, | 2714 PropertyAttributes attributes, |
2788 StrictModeFlag strict_mode, | 2715 StrictModeFlag strict_mode, |
2789 bool* done); | 2716 bool* done); |
| 2717 static Handle<Object> SetPropertyPostInterceptor( |
| 2718 Handle<JSObject> object, |
| 2719 Handle<Name> name, |
| 2720 Handle<Object> value, |
| 2721 PropertyAttributes attributes, |
| 2722 StrictModeFlag strict_mode); |
| 2723 static Handle<Object> SetPropertyUsingTransition( |
| 2724 Handle<JSObject> object, |
| 2725 LookupResult* lookup, |
| 2726 Handle<Name> name, |
| 2727 Handle<Object> value, |
| 2728 PropertyAttributes attributes); |
| 2729 |
| 2730 // Add a property to an object. |
| 2731 static Handle<Object> AddProperty( |
| 2732 Handle<JSObject> object, |
| 2733 Handle<Name> name, |
| 2734 Handle<Object> value, |
| 2735 PropertyAttributes attributes, |
| 2736 StrictModeFlag strict_mode, |
| 2737 StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED, |
| 2738 ExtensibilityCheck extensibility_check = PERFORM_EXTENSIBILITY_CHECK, |
| 2739 ValueType value_type = OPTIMAL_REPRESENTATION, |
| 2740 StoreMode mode = ALLOW_AS_CONSTANT, |
| 2741 TransitionFlag flag = INSERT_TRANSITION); |
| 2742 |
| 2743 // Add a constant function property to a fast-case object. |
| 2744 // This leaves a CONSTANT_TRANSITION in the old map, and |
| 2745 // if it is called on a second object with this map, a |
| 2746 // normal property is added instead, with a map transition. |
| 2747 // This avoids the creation of many maps with the same constant |
| 2748 // function, all orphaned. |
| 2749 static void AddConstantProperty(Handle<JSObject> object, |
| 2750 Handle<Name> name, |
| 2751 Handle<Object> constant, |
| 2752 PropertyAttributes attributes, |
| 2753 TransitionFlag flag); |
| 2754 |
| 2755 // Add a property to a fast-case object. |
| 2756 static void AddFastProperty(Handle<JSObject> object, |
| 2757 Handle<Name> name, |
| 2758 Handle<Object> value, |
| 2759 PropertyAttributes attributes, |
| 2760 StoreFromKeyed store_mode, |
| 2761 ValueType value_type, |
| 2762 TransitionFlag flag); |
| 2763 |
| 2764 // Add a property to a fast-case object using a map transition to |
| 2765 // new_map. |
| 2766 static Handle<Object> AddFastPropertyUsingMap(Handle<JSObject> object, |
| 2767 Handle<Map> new_map, |
| 2768 Handle<Name> name, |
| 2769 Handle<Object> value, |
| 2770 int field_index, |
| 2771 Representation representation); |
| 2772 MUST_USE_RESULT MaybeObject* AddFastPropertyUsingMap( |
| 2773 Map* new_map, |
| 2774 Name* name, |
| 2775 Object* value, |
| 2776 int field_index, |
| 2777 Representation representation); |
| 2778 |
| 2779 // Add a property to a slow-case object. |
| 2780 static void AddSlowProperty(Handle<JSObject> object, |
| 2781 Handle<Name> name, |
| 2782 Handle<Object> value, |
| 2783 PropertyAttributes attributes); |
2790 | 2784 |
2791 static Handle<Object> DeleteProperty(Handle<JSObject> object, | 2785 static Handle<Object> DeleteProperty(Handle<JSObject> object, |
2792 Handle<Name> name, | 2786 Handle<Name> name, |
2793 DeleteMode mode); | 2787 DeleteMode mode); |
2794 static Handle<Object> DeletePropertyPostInterceptor(Handle<JSObject> object, | 2788 static Handle<Object> DeletePropertyPostInterceptor(Handle<JSObject> object, |
2795 Handle<Name> name, | 2789 Handle<Name> name, |
2796 DeleteMode mode); | 2790 DeleteMode mode); |
2797 static Handle<Object> DeletePropertyWithInterceptor(Handle<JSObject> object, | 2791 static Handle<Object> DeletePropertyWithInterceptor(Handle<JSObject> object, |
2798 Handle<Name> name); | 2792 Handle<Name> name); |
2799 | 2793 |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3169 // array. | 3163 // array. |
3170 inline void Append(Descriptor* desc, const WhitenessWitness&); | 3164 inline void Append(Descriptor* desc, const WhitenessWitness&); |
3171 inline void Append(Descriptor* desc); | 3165 inline void Append(Descriptor* desc); |
3172 | 3166 |
3173 // Transfer a complete descriptor from the src descriptor array to this | 3167 // Transfer a complete descriptor from the src descriptor array to this |
3174 // descriptor array. | 3168 // descriptor array. |
3175 void CopyFrom(int dst_index, | 3169 void CopyFrom(int dst_index, |
3176 DescriptorArray* src, | 3170 DescriptorArray* src, |
3177 int src_index, | 3171 int src_index, |
3178 const WhitenessWitness&); | 3172 const WhitenessWitness&); |
| 3173 static Handle<DescriptorArray> Merge(Handle<DescriptorArray> desc, |
| 3174 int verbatim, |
| 3175 int valid, |
| 3176 int new_size, |
| 3177 int modify_index, |
| 3178 StoreMode store_mode, |
| 3179 Handle<DescriptorArray> other); |
3179 MUST_USE_RESULT MaybeObject* Merge(int verbatim, | 3180 MUST_USE_RESULT MaybeObject* Merge(int verbatim, |
3180 int valid, | 3181 int valid, |
3181 int new_size, | 3182 int new_size, |
3182 int modify_index, | 3183 int modify_index, |
3183 StoreMode store_mode, | 3184 StoreMode store_mode, |
3184 DescriptorArray* other); | 3185 DescriptorArray* other); |
3185 | 3186 |
3186 bool IsMoreGeneralThan(int verbatim, | 3187 bool IsMoreGeneralThan(int verbatim, |
3187 int valid, | 3188 int valid, |
3188 int new_size, | 3189 int new_size, |
(...skipping 2422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5611 | 5612 |
5612 bool InstancesNeedRewriting(Map* target, | 5613 bool InstancesNeedRewriting(Map* target, |
5613 int target_number_of_fields, | 5614 int target_number_of_fields, |
5614 int target_inobject, | 5615 int target_inobject, |
5615 int target_unused); | 5616 int target_unused); |
5616 static Handle<Map> GeneralizeRepresentation( | 5617 static Handle<Map> GeneralizeRepresentation( |
5617 Handle<Map> map, | 5618 Handle<Map> map, |
5618 int modify_index, | 5619 int modify_index, |
5619 Representation new_representation, | 5620 Representation new_representation, |
5620 StoreMode store_mode); | 5621 StoreMode store_mode); |
5621 MUST_USE_RESULT MaybeObject* GeneralizeRepresentation( | 5622 static Handle<Map> CopyGeneralizeAllRepresentations( |
5622 int modify_index, | 5623 Handle<Map> map, |
5623 Representation representation, | |
5624 StoreMode store_mode); | |
5625 MUST_USE_RESULT MaybeObject* CopyGeneralizeAllRepresentations( | |
5626 int modify_index, | 5624 int modify_index, |
5627 StoreMode store_mode, | 5625 StoreMode store_mode, |
5628 PropertyAttributes attributes, | 5626 PropertyAttributes attributes, |
5629 const char* reason); | 5627 const char* reason); |
5630 | 5628 |
5631 void PrintGeneralization(FILE* file, | 5629 void PrintGeneralization(FILE* file, |
5632 const char* reason, | 5630 const char* reason, |
5633 int modify_index, | 5631 int modify_index, |
5634 int split, | 5632 int split, |
5635 int descriptors, | 5633 int descriptors, |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5795 | 5793 |
5796 MUST_USE_RESULT MaybeObject* RawCopy(int instance_size); | 5794 MUST_USE_RESULT MaybeObject* RawCopy(int instance_size); |
5797 MUST_USE_RESULT MaybeObject* CopyWithPreallocatedFieldDescriptors(); | 5795 MUST_USE_RESULT MaybeObject* CopyWithPreallocatedFieldDescriptors(); |
5798 static Handle<Map> CopyDropDescriptors(Handle<Map> map); | 5796 static Handle<Map> CopyDropDescriptors(Handle<Map> map); |
5799 MUST_USE_RESULT MaybeObject* CopyDropDescriptors(); | 5797 MUST_USE_RESULT MaybeObject* CopyDropDescriptors(); |
5800 MUST_USE_RESULT MaybeObject* CopyReplaceDescriptors( | 5798 MUST_USE_RESULT MaybeObject* CopyReplaceDescriptors( |
5801 DescriptorArray* descriptors, | 5799 DescriptorArray* descriptors, |
5802 TransitionFlag flag, | 5800 TransitionFlag flag, |
5803 Name* name = NULL, | 5801 Name* name = NULL, |
5804 SimpleTransitionFlag simple_flag = FULL_TRANSITION); | 5802 SimpleTransitionFlag simple_flag = FULL_TRANSITION); |
| 5803 static Handle<Map> CopyInstallDescriptors( |
| 5804 Handle<Map> map, |
| 5805 int new_descriptor, |
| 5806 Handle<DescriptorArray> descriptors); |
5805 MUST_USE_RESULT MaybeObject* CopyInstallDescriptors( | 5807 MUST_USE_RESULT MaybeObject* CopyInstallDescriptors( |
5806 int new_descriptor, | 5808 int new_descriptor, |
5807 DescriptorArray* descriptors); | 5809 DescriptorArray* descriptors); |
5808 MUST_USE_RESULT MaybeObject* ShareDescriptor(DescriptorArray* descriptors, | 5810 MUST_USE_RESULT MaybeObject* ShareDescriptor(DescriptorArray* descriptors, |
5809 Descriptor* descriptor); | 5811 Descriptor* descriptor); |
5810 MUST_USE_RESULT MaybeObject* CopyAddDescriptor(Descriptor* descriptor, | 5812 MUST_USE_RESULT MaybeObject* CopyAddDescriptor(Descriptor* descriptor, |
5811 TransitionFlag flag); | 5813 TransitionFlag flag); |
5812 MUST_USE_RESULT MaybeObject* CopyInsertDescriptor(Descriptor* descriptor, | 5814 MUST_USE_RESULT MaybeObject* CopyInsertDescriptor(Descriptor* descriptor, |
5813 TransitionFlag flag); | 5815 TransitionFlag flag); |
5814 MUST_USE_RESULT MaybeObject* CopyReplaceDescriptor( | 5816 MUST_USE_RESULT MaybeObject* CopyReplaceDescriptor( |
(...skipping 3198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9013 void set_type(Type* value, WriteBarrierMode mode = UPDATE_WRITE_BARRIER); | 9015 void set_type(Type* value, WriteBarrierMode mode = UPDATE_WRITE_BARRIER); |
9014 | 9016 |
9015 // [dependent_code]: dependent code that depends on the type of the global | 9017 // [dependent_code]: dependent code that depends on the type of the global |
9016 // property. | 9018 // property. |
9017 DECL_ACCESSORS(dependent_code, DependentCode) | 9019 DECL_ACCESSORS(dependent_code, DependentCode) |
9018 | 9020 |
9019 // Sets the value of the cell and updates the type field to be the union | 9021 // Sets the value of the cell and updates the type field to be the union |
9020 // of the cell's current type and the value's type. If the change causes | 9022 // of the cell's current type and the value's type. If the change causes |
9021 // a change of the type of the cell's contents, code dependent on the cell | 9023 // a change of the type of the cell's contents, code dependent on the cell |
9022 // will be deoptimized. | 9024 // will be deoptimized. |
| 9025 static void SetValueInferType(Handle<PropertyCell> cell, |
| 9026 Handle<Object> value, |
| 9027 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); |
9023 MUST_USE_RESULT MaybeObject* SetValueInferType( | 9028 MUST_USE_RESULT MaybeObject* SetValueInferType( |
9024 Object* value, | 9029 Object* value, |
9025 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); | 9030 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); |
9026 | 9031 |
9027 // Casting. | 9032 // Casting. |
9028 static inline PropertyCell* cast(Object* obj); | 9033 static inline PropertyCell* cast(Object* obj); |
9029 | 9034 |
9030 inline Address TypeAddress() { | 9035 inline Address TypeAddress() { |
9031 return address() + kTypeOffset; | 9036 return address() + kTypeOffset; |
9032 } | 9037 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9075 bool HasPropertyWithHandler(Name* name); | 9080 bool HasPropertyWithHandler(Name* name); |
9076 bool HasElementWithHandler(uint32_t index); | 9081 bool HasElementWithHandler(uint32_t index); |
9077 | 9082 |
9078 MUST_USE_RESULT MaybeObject* GetPropertyWithHandler( | 9083 MUST_USE_RESULT MaybeObject* GetPropertyWithHandler( |
9079 Object* receiver, | 9084 Object* receiver, |
9080 Name* name); | 9085 Name* name); |
9081 MUST_USE_RESULT MaybeObject* GetElementWithHandler( | 9086 MUST_USE_RESULT MaybeObject* GetElementWithHandler( |
9082 Object* receiver, | 9087 Object* receiver, |
9083 uint32_t index); | 9088 uint32_t index); |
9084 | 9089 |
9085 MUST_USE_RESULT MaybeObject* SetPropertyWithHandler( | |
9086 JSReceiver* receiver, | |
9087 Name* name, | |
9088 Object* value, | |
9089 PropertyAttributes attributes, | |
9090 StrictModeFlag strict_mode); | |
9091 | |
9092 // If the handler defines an accessor property with a setter, invoke it. | 9090 // If the handler defines an accessor property with a setter, invoke it. |
9093 // If it defines an accessor property without a setter, or a data property | 9091 // If it defines an accessor property without a setter, or a data property |
9094 // that is read-only, throw. In all these cases set '*done' to true, | 9092 // that is read-only, throw. In all these cases set '*done' to true, |
9095 // otherwise set it to false. | 9093 // otherwise set it to false. |
9096 MUST_USE_RESULT MaybeObject* SetPropertyViaPrototypesWithHandler( | 9094 MUST_USE_RESULT MaybeObject* SetPropertyViaPrototypesWithHandler( |
9097 JSReceiver* receiver, | 9095 JSReceiver* receiver, |
9098 Name* name, | 9096 Name* name, |
9099 Object* value, | 9097 Object* value, |
9100 PropertyAttributes attributes, | 9098 PropertyAttributes attributes, |
9101 StrictModeFlag strict_mode, | 9099 StrictModeFlag strict_mode, |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9137 | 9135 |
9138 STATIC_CHECK(kPaddingSize >= 0); | 9136 STATIC_CHECK(kPaddingSize >= 0); |
9139 | 9137 |
9140 typedef FixedBodyDescriptor<kHandlerOffset, | 9138 typedef FixedBodyDescriptor<kHandlerOffset, |
9141 kPaddingOffset, | 9139 kPaddingOffset, |
9142 kSize> BodyDescriptor; | 9140 kSize> BodyDescriptor; |
9143 | 9141 |
9144 private: | 9142 private: |
9145 friend class JSReceiver; | 9143 friend class JSReceiver; |
9146 | 9144 |
| 9145 static Handle<Object> SetPropertyWithHandler(Handle<JSProxy> proxy, |
| 9146 Handle<JSReceiver> receiver, |
| 9147 Handle<Name> name, |
| 9148 Handle<Object> value, |
| 9149 PropertyAttributes attributes, |
| 9150 StrictModeFlag strict_mode); |
9147 static Handle<Object> SetElementWithHandler(Handle<JSProxy> proxy, | 9151 static Handle<Object> SetElementWithHandler(Handle<JSProxy> proxy, |
9148 Handle<JSReceiver> receiver, | 9152 Handle<JSReceiver> receiver, |
9149 uint32_t index, | 9153 uint32_t index, |
9150 Handle<Object> value, | 9154 Handle<Object> value, |
9151 StrictModeFlag strict_mode); | 9155 StrictModeFlag strict_mode); |
9152 | 9156 |
9153 static Handle<Object> DeletePropertyWithHandler(Handle<JSProxy> proxy, | 9157 static Handle<Object> DeletePropertyWithHandler(Handle<JSProxy> proxy, |
9154 Handle<Name> name, | 9158 Handle<Name> name, |
9155 DeleteMode mode); | 9159 DeleteMode mode); |
9156 static Handle<Object> DeleteElementWithHandler(Handle<JSProxy> proxy, | 9160 static Handle<Object> DeleteElementWithHandler(Handle<JSProxy> proxy, |
(...skipping 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10245 } else { | 10249 } else { |
10246 value &= ~(1 << bit_position); | 10250 value &= ~(1 << bit_position); |
10247 } | 10251 } |
10248 return value; | 10252 return value; |
10249 } | 10253 } |
10250 }; | 10254 }; |
10251 | 10255 |
10252 } } // namespace v8::internal | 10256 } } // namespace v8::internal |
10253 | 10257 |
10254 #endif // V8_OBJECTS_H_ | 10258 #endif // V8_OBJECTS_H_ |
OLD | NEW |