OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_OBJECTS_H_ | 5 #ifndef V8_OBJECTS_H_ |
6 #define V8_OBJECTS_H_ | 6 #define V8_OBJECTS_H_ |
7 | 7 |
8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
9 #include "src/assert-scope.h" | 9 #include "src/assert-scope.h" |
10 #include "src/builtins.h" | 10 #include "src/builtins.h" |
(...skipping 1378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1389 | 1389 |
1390 // Filler objects (fillers and free space objects). | 1390 // Filler objects (fillers and free space objects). |
1391 INLINE(bool IsFiller() const); | 1391 INLINE(bool IsFiller() const); |
1392 | 1392 |
1393 // Extract the number. | 1393 // Extract the number. |
1394 inline double Number(); | 1394 inline double Number(); |
1395 INLINE(bool IsNaN() const); | 1395 INLINE(bool IsNaN() const); |
1396 bool ToInt32(int32_t* value); | 1396 bool ToInt32(int32_t* value); |
1397 bool ToUint32(uint32_t* value); | 1397 bool ToUint32(uint32_t* value); |
1398 | 1398 |
1399 // Indicates whether OptimalRepresentation can do its work, or whether it | 1399 inline Representation OptimalRepresentation() { |
1400 // always has to return Representation::Tagged(). | |
1401 enum ValueType { | |
1402 OPTIMAL_REPRESENTATION, | |
1403 FORCE_TAGGED | |
1404 }; | |
1405 | |
1406 inline Representation OptimalRepresentation( | |
1407 ValueType type = OPTIMAL_REPRESENTATION) { | |
1408 if (!FLAG_track_fields) return Representation::Tagged(); | 1400 if (!FLAG_track_fields) return Representation::Tagged(); |
1409 if (type == FORCE_TAGGED) return Representation::Tagged(); | |
1410 if (IsSmi()) { | 1401 if (IsSmi()) { |
1411 return Representation::Smi(); | 1402 return Representation::Smi(); |
1412 } else if (FLAG_track_double_fields && IsHeapNumber()) { | 1403 } else if (FLAG_track_double_fields && IsHeapNumber()) { |
1413 return Representation::Double(); | 1404 return Representation::Double(); |
1414 } else if (FLAG_track_computed_fields && IsUninitialized()) { | 1405 } else if (FLAG_track_computed_fields && IsUninitialized()) { |
1415 return Representation::None(); | 1406 return Representation::None(); |
1416 } else if (FLAG_track_heap_object_fields) { | 1407 } else if (FLAG_track_heap_object_fields) { |
1417 ASSERT(IsHeapObject()); | 1408 ASSERT(IsHeapObject()); |
1418 return Representation::HeapObject(); | 1409 return Representation::HeapObject(); |
1419 } else { | 1410 } else { |
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2140 enum ExecutableAccessorInfoHandling { | 2131 enum ExecutableAccessorInfoHandling { |
2141 DEFAULT_HANDLING, | 2132 DEFAULT_HANDLING, |
2142 DONT_FORCE_FIELD | 2133 DONT_FORCE_FIELD |
2143 }; | 2134 }; |
2144 | 2135 |
2145 MUST_USE_RESULT static MaybeHandle<Object> SetOwnPropertyIgnoreAttributes( | 2136 MUST_USE_RESULT static MaybeHandle<Object> SetOwnPropertyIgnoreAttributes( |
2146 Handle<JSObject> object, | 2137 Handle<JSObject> object, |
2147 Handle<Name> key, | 2138 Handle<Name> key, |
2148 Handle<Object> value, | 2139 Handle<Object> value, |
2149 PropertyAttributes attributes, | 2140 PropertyAttributes attributes, |
2150 ValueType value_type = OPTIMAL_REPRESENTATION, | |
2151 StoreMode mode = ALLOW_AS_CONSTANT, | 2141 StoreMode mode = ALLOW_AS_CONSTANT, |
2152 ExtensibilityCheck extensibility_check = PERFORM_EXTENSIBILITY_CHECK, | 2142 ExtensibilityCheck extensibility_check = PERFORM_EXTENSIBILITY_CHECK, |
2153 StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED, | 2143 StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED, |
2154 ExecutableAccessorInfoHandling handling = DEFAULT_HANDLING); | 2144 ExecutableAccessorInfoHandling handling = DEFAULT_HANDLING); |
2155 | 2145 |
2156 static void AddProperty(Handle<JSObject> object, | 2146 static void AddProperty(Handle<JSObject> object, |
2157 Handle<Name> key, | 2147 Handle<Name> key, |
2158 Handle<Object> value, | 2148 Handle<Object> value, |
2159 PropertyAttributes attributes, | 2149 PropertyAttributes attributes, |
2160 ValueType value_type = OPTIMAL_REPRESENTATION, | |
2161 StoreMode mode = ALLOW_AS_CONSTANT); | 2150 StoreMode mode = ALLOW_AS_CONSTANT); |
2162 | 2151 |
2163 // Extend the receiver with a single fast property appeared first in the | 2152 // Extend the receiver with a single fast property appeared first in the |
2164 // passed map. This also extends the property backing store if necessary. | 2153 // passed map. This also extends the property backing store if necessary. |
2165 static void AllocateStorageForMap(Handle<JSObject> object, Handle<Map> map); | 2154 static void AllocateStorageForMap(Handle<JSObject> object, Handle<Map> map); |
2166 | 2155 |
2167 // Migrates the given object to a map whose field representations are the | 2156 // Migrates the given object to a map whose field representations are the |
2168 // lowest upper bound of all known representations for that field. | 2157 // lowest upper bound of all known representations for that field. |
2169 static void MigrateInstance(Handle<JSObject> instance); | 2158 static void MigrateInstance(Handle<JSObject> instance); |
2170 | 2159 |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2492 | 2481 |
2493 // ES5 Object.freeze | 2482 // ES5 Object.freeze |
2494 MUST_USE_RESULT static MaybeHandle<Object> Freeze(Handle<JSObject> object); | 2483 MUST_USE_RESULT static MaybeHandle<Object> Freeze(Handle<JSObject> object); |
2495 | 2484 |
2496 // Called the first time an object is observed with ES7 Object.observe. | 2485 // Called the first time an object is observed with ES7 Object.observe. |
2497 static void SetObserved(Handle<JSObject> object); | 2486 static void SetObserved(Handle<JSObject> object); |
2498 | 2487 |
2499 // Copy object. | 2488 // Copy object. |
2500 enum DeepCopyHints { | 2489 enum DeepCopyHints { |
2501 kNoHints = 0, | 2490 kNoHints = 0, |
2502 kObjectIsShallowArray = 1 | 2491 kObjectIsShallow = 1 |
2503 }; | 2492 }; |
2504 | 2493 |
2505 static Handle<JSObject> Copy(Handle<JSObject> object); | 2494 static Handle<JSObject> Copy(Handle<JSObject> object); |
2506 MUST_USE_RESULT static MaybeHandle<JSObject> DeepCopy( | 2495 MUST_USE_RESULT static MaybeHandle<JSObject> DeepCopy( |
2507 Handle<JSObject> object, | 2496 Handle<JSObject> object, |
2508 AllocationSiteUsageContext* site_context, | 2497 AllocationSiteUsageContext* site_context, |
2509 DeepCopyHints hints = kNoHints); | 2498 DeepCopyHints hints = kNoHints); |
2510 MUST_USE_RESULT static MaybeHandle<JSObject> DeepWalk( | 2499 MUST_USE_RESULT static MaybeHandle<JSObject> DeepWalk( |
2511 Handle<JSObject> object, | 2500 Handle<JSObject> object, |
2512 AllocationSiteCreationContext* site_context); | 2501 AllocationSiteCreationContext* site_context); |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2758 | 2747 |
2759 // Add a property to an object. | 2748 // Add a property to an object. |
2760 MUST_USE_RESULT static MaybeHandle<Object> AddPropertyInternal( | 2749 MUST_USE_RESULT static MaybeHandle<Object> AddPropertyInternal( |
2761 Handle<JSObject> object, | 2750 Handle<JSObject> object, |
2762 Handle<Name> name, | 2751 Handle<Name> name, |
2763 Handle<Object> value, | 2752 Handle<Object> value, |
2764 PropertyAttributes attributes, | 2753 PropertyAttributes attributes, |
2765 StrictMode strict_mode, | 2754 StrictMode strict_mode, |
2766 StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED, | 2755 StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED, |
2767 ExtensibilityCheck extensibility_check = PERFORM_EXTENSIBILITY_CHECK, | 2756 ExtensibilityCheck extensibility_check = PERFORM_EXTENSIBILITY_CHECK, |
2768 ValueType value_type = OPTIMAL_REPRESENTATION, | |
2769 StoreMode mode = ALLOW_AS_CONSTANT, | 2757 StoreMode mode = ALLOW_AS_CONSTANT, |
2770 TransitionFlag flag = INSERT_TRANSITION); | 2758 TransitionFlag flag = INSERT_TRANSITION); |
2771 | 2759 |
2772 // Add a property to a fast-case object. | 2760 // Add a property to a fast-case object. |
2773 static void AddFastProperty(Handle<JSObject> object, | 2761 static void AddFastProperty(Handle<JSObject> object, |
2774 Handle<Name> name, | 2762 Handle<Name> name, |
2775 Handle<Object> value, | 2763 Handle<Object> value, |
2776 PropertyAttributes attributes, | 2764 PropertyAttributes attributes, |
2777 StoreFromKeyed store_mode, | 2765 StoreFromKeyed store_mode, |
2778 ValueType value_type, | |
2779 TransitionFlag flag); | 2766 TransitionFlag flag); |
2780 | 2767 |
2781 // Add a property to a slow-case object. | 2768 // Add a property to a slow-case object. |
2782 static void AddSlowProperty(Handle<JSObject> object, | 2769 static void AddSlowProperty(Handle<JSObject> object, |
2783 Handle<Name> name, | 2770 Handle<Name> name, |
2784 Handle<Object> value, | 2771 Handle<Object> value, |
2785 PropertyAttributes attributes); | 2772 PropertyAttributes attributes); |
2786 | 2773 |
2787 MUST_USE_RESULT static MaybeHandle<Object> DeleteProperty( | 2774 MUST_USE_RESULT static MaybeHandle<Object> DeleteProperty( |
2788 Handle<JSObject> object, | 2775 Handle<JSObject> object, |
(...skipping 8386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11175 } else { | 11162 } else { |
11176 value &= ~(1 << bit_position); | 11163 value &= ~(1 << bit_position); |
11177 } | 11164 } |
11178 return value; | 11165 return value; |
11179 } | 11166 } |
11180 }; | 11167 }; |
11181 | 11168 |
11182 } } // namespace v8::internal | 11169 } } // namespace v8::internal |
11183 | 11170 |
11184 #endif // V8_OBJECTS_H_ | 11171 #endif // V8_OBJECTS_H_ |
OLD | NEW |