| 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 1388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1399 | 1399 |
| 1400 // Filler objects (fillers and free space objects). | 1400 // Filler objects (fillers and free space objects). |
| 1401 INLINE(bool IsFiller() const); | 1401 INLINE(bool IsFiller() const); |
| 1402 | 1402 |
| 1403 // Extract the number. | 1403 // Extract the number. |
| 1404 inline double Number(); | 1404 inline double Number(); |
| 1405 INLINE(bool IsNaN() const); | 1405 INLINE(bool IsNaN() const); |
| 1406 bool ToInt32(int32_t* value); | 1406 bool ToInt32(int32_t* value); |
| 1407 bool ToUint32(uint32_t* value); | 1407 bool ToUint32(uint32_t* value); |
| 1408 | 1408 |
| 1409 inline Representation OptimalRepresentation() { | 1409 // Indicates whether OptimalRepresentation can do its work, or whether it |
| 1410 // always has to return Representation::Tagged(). |
| 1411 enum ValueType { |
| 1412 OPTIMAL_REPRESENTATION, |
| 1413 FORCE_TAGGED |
| 1414 }; |
| 1415 |
| 1416 inline Representation OptimalRepresentation( |
| 1417 ValueType type = OPTIMAL_REPRESENTATION) { |
| 1410 if (!FLAG_track_fields) return Representation::Tagged(); | 1418 if (!FLAG_track_fields) return Representation::Tagged(); |
| 1419 if (type == FORCE_TAGGED) return Representation::Tagged(); |
| 1411 if (IsSmi()) { | 1420 if (IsSmi()) { |
| 1412 return Representation::Smi(); | 1421 return Representation::Smi(); |
| 1413 } else if (FLAG_track_double_fields && IsHeapNumber()) { | 1422 } else if (FLAG_track_double_fields && IsHeapNumber()) { |
| 1414 return Representation::Double(); | 1423 return Representation::Double(); |
| 1415 } else if (FLAG_track_computed_fields && IsUninitialized()) { | 1424 } else if (FLAG_track_computed_fields && IsUninitialized()) { |
| 1416 return Representation::None(); | 1425 return Representation::None(); |
| 1417 } else if (FLAG_track_heap_object_fields) { | 1426 } else if (FLAG_track_heap_object_fields) { |
| 1418 ASSERT(IsHeapObject()); | 1427 ASSERT(IsHeapObject()); |
| 1419 return Representation::HeapObject(); | 1428 return Representation::HeapObject(); |
| 1420 } else { | 1429 } else { |
| (...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2151 enum ExecutableAccessorInfoHandling { | 2160 enum ExecutableAccessorInfoHandling { |
| 2152 DEFAULT_HANDLING, | 2161 DEFAULT_HANDLING, |
| 2153 DONT_FORCE_FIELD | 2162 DONT_FORCE_FIELD |
| 2154 }; | 2163 }; |
| 2155 | 2164 |
| 2156 MUST_USE_RESULT static MaybeHandle<Object> SetOwnPropertyIgnoreAttributes( | 2165 MUST_USE_RESULT static MaybeHandle<Object> SetOwnPropertyIgnoreAttributes( |
| 2157 Handle<JSObject> object, | 2166 Handle<JSObject> object, |
| 2158 Handle<Name> key, | 2167 Handle<Name> key, |
| 2159 Handle<Object> value, | 2168 Handle<Object> value, |
| 2160 PropertyAttributes attributes, | 2169 PropertyAttributes attributes, |
| 2170 ValueType value_type = OPTIMAL_REPRESENTATION, |
| 2161 StoreMode mode = ALLOW_AS_CONSTANT, | 2171 StoreMode mode = ALLOW_AS_CONSTANT, |
| 2162 ExtensibilityCheck extensibility_check = PERFORM_EXTENSIBILITY_CHECK, | 2172 ExtensibilityCheck extensibility_check = PERFORM_EXTENSIBILITY_CHECK, |
| 2163 StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED, | 2173 StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED, |
| 2164 ExecutableAccessorInfoHandling handling = DEFAULT_HANDLING); | 2174 ExecutableAccessorInfoHandling handling = DEFAULT_HANDLING); |
| 2165 | 2175 |
| 2166 static void AddProperty(Handle<JSObject> object, | 2176 static void AddProperty(Handle<JSObject> object, |
| 2167 Handle<Name> key, | 2177 Handle<Name> key, |
| 2168 Handle<Object> value, | 2178 Handle<Object> value, |
| 2169 PropertyAttributes attributes, | 2179 PropertyAttributes attributes, |
| 2180 ValueType value_type = OPTIMAL_REPRESENTATION, |
| 2170 StoreMode mode = ALLOW_AS_CONSTANT); | 2181 StoreMode mode = ALLOW_AS_CONSTANT); |
| 2171 | 2182 |
| 2172 // Extend the receiver with a single fast property appeared first in the | 2183 // Extend the receiver with a single fast property appeared first in the |
| 2173 // passed map. This also extends the property backing store if necessary. | 2184 // passed map. This also extends the property backing store if necessary. |
| 2174 static void AllocateStorageForMap(Handle<JSObject> object, Handle<Map> map); | 2185 static void AllocateStorageForMap(Handle<JSObject> object, Handle<Map> map); |
| 2175 | 2186 |
| 2176 // Migrates the given object to a map whose field representations are the | 2187 // Migrates the given object to a map whose field representations are the |
| 2177 // lowest upper bound of all known representations for that field. | 2188 // lowest upper bound of all known representations for that field. |
| 2178 static void MigrateInstance(Handle<JSObject> instance); | 2189 static void MigrateInstance(Handle<JSObject> instance); |
| 2179 | 2190 |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2499 MUST_USE_RESULT static MaybeHandle<Object> PreventExtensions( | 2510 MUST_USE_RESULT static MaybeHandle<Object> PreventExtensions( |
| 2500 Handle<JSObject> object); | 2511 Handle<JSObject> object); |
| 2501 | 2512 |
| 2502 // ES5 Object.freeze | 2513 // ES5 Object.freeze |
| 2503 MUST_USE_RESULT static MaybeHandle<Object> Freeze(Handle<JSObject> object); | 2514 MUST_USE_RESULT static MaybeHandle<Object> Freeze(Handle<JSObject> object); |
| 2504 | 2515 |
| 2505 // Called the first time an object is observed with ES7 Object.observe. | 2516 // Called the first time an object is observed with ES7 Object.observe. |
| 2506 static void SetObserved(Handle<JSObject> object); | 2517 static void SetObserved(Handle<JSObject> object); |
| 2507 | 2518 |
| 2508 // Copy object. | 2519 // Copy object. |
| 2509 enum DeepCopyHints { kNoHints = 0, kObjectIsShallow = 1 }; | 2520 enum DeepCopyHints { |
| 2521 kNoHints = 0, |
| 2522 kObjectIsShallowArray = 1 |
| 2523 }; |
| 2510 | 2524 |
| 2511 static Handle<JSObject> Copy(Handle<JSObject> object); | 2525 static Handle<JSObject> Copy(Handle<JSObject> object); |
| 2512 MUST_USE_RESULT static MaybeHandle<JSObject> DeepCopy( | 2526 MUST_USE_RESULT static MaybeHandle<JSObject> DeepCopy( |
| 2513 Handle<JSObject> object, | 2527 Handle<JSObject> object, |
| 2514 AllocationSiteUsageContext* site_context, | 2528 AllocationSiteUsageContext* site_context, |
| 2515 DeepCopyHints hints = kNoHints); | 2529 DeepCopyHints hints = kNoHints); |
| 2516 MUST_USE_RESULT static MaybeHandle<JSObject> DeepWalk( | 2530 MUST_USE_RESULT static MaybeHandle<JSObject> DeepWalk( |
| 2517 Handle<JSObject> object, | 2531 Handle<JSObject> object, |
| 2518 AllocationSiteCreationContext* site_context); | 2532 AllocationSiteCreationContext* site_context); |
| 2519 | 2533 |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2764 | 2778 |
| 2765 // Add a property to an object. | 2779 // Add a property to an object. |
| 2766 MUST_USE_RESULT static MaybeHandle<Object> AddPropertyInternal( | 2780 MUST_USE_RESULT static MaybeHandle<Object> AddPropertyInternal( |
| 2767 Handle<JSObject> object, | 2781 Handle<JSObject> object, |
| 2768 Handle<Name> name, | 2782 Handle<Name> name, |
| 2769 Handle<Object> value, | 2783 Handle<Object> value, |
| 2770 PropertyAttributes attributes, | 2784 PropertyAttributes attributes, |
| 2771 StrictMode strict_mode, | 2785 StrictMode strict_mode, |
| 2772 StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED, | 2786 StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED, |
| 2773 ExtensibilityCheck extensibility_check = PERFORM_EXTENSIBILITY_CHECK, | 2787 ExtensibilityCheck extensibility_check = PERFORM_EXTENSIBILITY_CHECK, |
| 2788 ValueType value_type = OPTIMAL_REPRESENTATION, |
| 2774 StoreMode mode = ALLOW_AS_CONSTANT, | 2789 StoreMode mode = ALLOW_AS_CONSTANT, |
| 2775 TransitionFlag flag = INSERT_TRANSITION); | 2790 TransitionFlag flag = INSERT_TRANSITION); |
| 2776 | 2791 |
| 2777 // Add a property to a fast-case object. | 2792 // Add a property to a fast-case object. |
| 2778 static void AddFastProperty(Handle<JSObject> object, | 2793 static void AddFastProperty(Handle<JSObject> object, |
| 2779 Handle<Name> name, | 2794 Handle<Name> name, |
| 2780 Handle<Object> value, | 2795 Handle<Object> value, |
| 2781 PropertyAttributes attributes, | 2796 PropertyAttributes attributes, |
| 2782 StoreFromKeyed store_mode, | 2797 StoreFromKeyed store_mode, |
| 2798 ValueType value_type, |
| 2783 TransitionFlag flag); | 2799 TransitionFlag flag); |
| 2784 | 2800 |
| 2785 // Add a property to a slow-case object. | 2801 // Add a property to a slow-case object. |
| 2786 static void AddSlowProperty(Handle<JSObject> object, | 2802 static void AddSlowProperty(Handle<JSObject> object, |
| 2787 Handle<Name> name, | 2803 Handle<Name> name, |
| 2788 Handle<Object> value, | 2804 Handle<Object> value, |
| 2789 PropertyAttributes attributes); | 2805 PropertyAttributes attributes); |
| 2790 | 2806 |
| 2791 MUST_USE_RESULT static MaybeHandle<Object> DeleteProperty( | 2807 MUST_USE_RESULT static MaybeHandle<Object> DeleteProperty( |
| 2792 Handle<JSObject> object, | 2808 Handle<JSObject> object, |
| (...skipping 8418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11211 } else { | 11227 } else { |
| 11212 value &= ~(1 << bit_position); | 11228 value &= ~(1 << bit_position); |
| 11213 } | 11229 } |
| 11214 return value; | 11230 return value; |
| 11215 } | 11231 } |
| 11216 }; | 11232 }; |
| 11217 | 11233 |
| 11218 } } // namespace v8::internal | 11234 } } // namespace v8::internal |
| 11219 | 11235 |
| 11220 #endif // V8_OBJECTS_H_ | 11236 #endif // V8_OBJECTS_H_ |
| OLD | NEW |