| 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 <iosfwd> | 8 #include <iosfwd> |
| 9 | 9 |
| 10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
| (...skipping 1881 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1892 | 1892 |
| 1893 // Migrates the given object only if the target map is already available, | 1893 // Migrates the given object only if the target map is already available, |
| 1894 // or returns false if such a map is not yet available. | 1894 // or returns false if such a map is not yet available. |
| 1895 static bool TryMigrateInstance(Handle<JSObject> instance); | 1895 static bool TryMigrateInstance(Handle<JSObject> instance); |
| 1896 | 1896 |
| 1897 // Sets the property value in a normalized object given (key, value, details). | 1897 // Sets the property value in a normalized object given (key, value, details). |
| 1898 // Handles the special representation of JS global objects. | 1898 // Handles the special representation of JS global objects. |
| 1899 static void SetNormalizedProperty(Handle<JSObject> object, Handle<Name> name, | 1899 static void SetNormalizedProperty(Handle<JSObject> object, Handle<Name> name, |
| 1900 Handle<Object> value, | 1900 Handle<Object> value, |
| 1901 PropertyDetails details); | 1901 PropertyDetails details); |
| 1902 static void AddDictionaryElement(Handle<JSObject> object, uint32_t index, | |
| 1903 Handle<Object> value, | |
| 1904 PropertyAttributes attributes); | |
| 1905 static void SetDictionaryElement(Handle<JSObject> object, uint32_t index, | 1902 static void SetDictionaryElement(Handle<JSObject> object, uint32_t index, |
| 1906 Handle<Object> value, | 1903 Handle<Object> value, |
| 1907 PropertyAttributes attributes); | 1904 PropertyAttributes attributes); |
| 1908 static void SetDictionaryArgumentsElement(Handle<JSObject> object, | 1905 static void SetDictionaryArgumentsElement(Handle<JSObject> object, |
| 1909 uint32_t index, | 1906 uint32_t index, |
| 1910 Handle<Object> value, | 1907 Handle<Object> value, |
| 1911 PropertyAttributes attributes); | 1908 PropertyAttributes attributes); |
| 1912 | 1909 |
| 1913 static void OptimizeAsPrototype(Handle<JSObject> object, | 1910 static void OptimizeAsPrototype(Handle<JSObject> object, |
| 1914 PrototypeOptimizationMode mode); | 1911 PrototypeOptimizationMode mode); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2004 Handle<JSObject> object, | 2001 Handle<JSObject> object, |
| 2005 Arguments* arguments, | 2002 Arguments* arguments, |
| 2006 uint32_t first_arg, | 2003 uint32_t first_arg, |
| 2007 uint32_t arg_count, | 2004 uint32_t arg_count, |
| 2008 EnsureElementsMode mode); | 2005 EnsureElementsMode mode); |
| 2009 | 2006 |
| 2010 // Would we convert a fast elements array to dictionary mode given | 2007 // Would we convert a fast elements array to dictionary mode given |
| 2011 // an access at key? | 2008 // an access at key? |
| 2012 bool WouldConvertToSlowElements(uint32_t index); | 2009 bool WouldConvertToSlowElements(uint32_t index); |
| 2013 inline bool WouldConvertToSlowElements(Handle<Object> key); | 2010 inline bool WouldConvertToSlowElements(Handle<Object> key); |
| 2014 // Do we want to keep fast elements when adding an element at |index|? | |
| 2015 // Returns |new_capacity| indicating to which capacity the object should be | |
| 2016 // increased. | |
| 2017 bool ShouldConvertToSlowElements(uint32_t capacity, uint32_t index, | |
| 2018 uint32_t* new_capacity); | |
| 2019 ElementsKind BestFittingFastElementsKind(); | |
| 2020 | 2011 |
| 2021 // Computes the new capacity when expanding the elements of a JSObject. | 2012 // Computes the new capacity when expanding the elements of a JSObject. |
| 2022 static uint32_t NewElementsCapacity(uint32_t old_capacity) { | 2013 static uint32_t NewElementsCapacity(uint32_t old_capacity) { |
| 2023 // (old_capacity + 50%) + 16 | 2014 // (old_capacity + 50%) + 16 |
| 2024 return old_capacity + (old_capacity >> 1) + 16; | 2015 return old_capacity + (old_capacity >> 1) + 16; |
| 2025 } | 2016 } |
| 2026 | 2017 |
| 2027 // These methods do not perform access checks! | 2018 // These methods do not perform access checks! |
| 2028 static void UpdateAllocationSite(Handle<JSObject> object, | 2019 static void UpdateAllocationSite(Handle<JSObject> object, |
| 2029 ElementsKind to_kind); | 2020 ElementsKind to_kind); |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2278 static inline int SizeOf(Map* map, HeapObject* object); | 2269 static inline int SizeOf(Map* map, HeapObject* object); |
| 2279 }; | 2270 }; |
| 2280 | 2271 |
| 2281 Context* GetCreationContext(); | 2272 Context* GetCreationContext(); |
| 2282 | 2273 |
| 2283 // Enqueue change record for Object.observe. May cause GC. | 2274 // Enqueue change record for Object.observe. May cause GC. |
| 2284 MUST_USE_RESULT static MaybeHandle<Object> EnqueueChangeRecord( | 2275 MUST_USE_RESULT static MaybeHandle<Object> EnqueueChangeRecord( |
| 2285 Handle<JSObject> object, const char* type, Handle<Name> name, | 2276 Handle<JSObject> object, const char* type, Handle<Name> name, |
| 2286 Handle<Object> old_value); | 2277 Handle<Object> old_value); |
| 2287 | 2278 |
| 2279 // Gets the current elements capacity and the number of used elements. |
| 2280 void GetElementsCapacityAndUsage(int* capacity, int* used); |
| 2281 |
| 2288 private: | 2282 private: |
| 2289 friend class DictionaryElementsAccessor; | 2283 friend class DictionaryElementsAccessor; |
| 2290 friend class JSReceiver; | 2284 friend class JSReceiver; |
| 2291 friend class Object; | 2285 friend class Object; |
| 2292 | 2286 |
| 2293 static void MigrateFastToFast(Handle<JSObject> object, Handle<Map> new_map); | 2287 static void MigrateFastToFast(Handle<JSObject> object, Handle<Map> new_map); |
| 2294 static void MigrateFastToSlow(Handle<JSObject> object, | 2288 static void MigrateFastToSlow(Handle<JSObject> object, |
| 2295 Handle<Map> new_map, | 2289 Handle<Map> new_map, |
| 2296 int expected_additional_properties); | 2290 int expected_additional_properties); |
| 2297 | 2291 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2312 LookupIterator* it); | 2306 LookupIterator* it); |
| 2313 | 2307 |
| 2314 // Deletes an existing named property in a normalized object. | 2308 // Deletes an existing named property in a normalized object. |
| 2315 static void DeleteNormalizedProperty(Handle<JSObject> object, | 2309 static void DeleteNormalizedProperty(Handle<JSObject> object, |
| 2316 Handle<Name> name); | 2310 Handle<Name> name); |
| 2317 | 2311 |
| 2318 bool ReferencesObjectFromElements(FixedArray* elements, | 2312 bool ReferencesObjectFromElements(FixedArray* elements, |
| 2319 ElementsKind kind, | 2313 ElementsKind kind, |
| 2320 Object* object); | 2314 Object* object); |
| 2321 | 2315 |
| 2322 // Returns true if most of the elements backing storage is used. | |
| 2323 bool HasDenseElements(); | |
| 2324 | |
| 2325 // Gets the current elements capacity and the number of used elements. | |
| 2326 void GetElementsCapacityAndUsage(int* capacity, int* used); | |
| 2327 | |
| 2328 static bool CanSetCallback(Handle<JSObject> object, Handle<Name> name); | 2316 static bool CanSetCallback(Handle<JSObject> object, Handle<Name> name); |
| 2329 static void SetElementCallback(Handle<JSObject> object, | 2317 static void SetElementCallback(Handle<JSObject> object, |
| 2330 uint32_t index, | 2318 uint32_t index, |
| 2331 Handle<Object> structure, | 2319 Handle<Object> structure, |
| 2332 PropertyAttributes attributes); | 2320 PropertyAttributes attributes); |
| 2333 static void SetPropertyCallback(Handle<JSObject> object, | 2321 static void SetPropertyCallback(Handle<JSObject> object, |
| 2334 Handle<Name> name, | 2322 Handle<Name> name, |
| 2335 Handle<Object> structure, | 2323 Handle<Object> structure, |
| 2336 PropertyAttributes attributes); | 2324 PropertyAttributes attributes); |
| 2337 static void DefineElementAccessor(Handle<JSObject> object, | 2325 static void DefineElementAccessor(Handle<JSObject> object, |
| (...skipping 8468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10806 } else { | 10794 } else { |
| 10807 value &= ~(1 << bit_position); | 10795 value &= ~(1 << bit_position); |
| 10808 } | 10796 } |
| 10809 return value; | 10797 return value; |
| 10810 } | 10798 } |
| 10811 }; | 10799 }; |
| 10812 | 10800 |
| 10813 } } // namespace v8::internal | 10801 } } // namespace v8::internal |
| 10814 | 10802 |
| 10815 #endif // V8_OBJECTS_H_ | 10803 #endif // V8_OBJECTS_H_ |
| OLD | NEW |