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 1997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2008 Handle<JSObject> object, | 2008 Handle<JSObject> object, |
2009 Arguments* arguments, | 2009 Arguments* arguments, |
2010 uint32_t first_arg, | 2010 uint32_t first_arg, |
2011 uint32_t arg_count, | 2011 uint32_t arg_count, |
2012 EnsureElementsMode mode); | 2012 EnsureElementsMode mode); |
2013 | 2013 |
2014 // Would we convert a fast elements array to dictionary mode given | 2014 // Would we convert a fast elements array to dictionary mode given |
2015 // an access at key? | 2015 // an access at key? |
2016 bool WouldConvertToSlowElements(uint32_t index); | 2016 bool WouldConvertToSlowElements(uint32_t index); |
2017 inline bool WouldConvertToSlowElements(Handle<Object> key); | 2017 inline bool WouldConvertToSlowElements(Handle<Object> key); |
2018 // Do we want to keep the elements in fast case when increasing the | 2018 // Do we want to keep fast elements when adding an element at |index|? |
2019 // capacity? | 2019 // Returns |new_capacity| indicating to which capacity the object should be |
2020 bool ShouldConvertToSlowElements(int new_capacity); | 2020 // increased. |
2021 // Returns true if the backing storage for the slow-case elements of | 2021 bool ShouldConvertToSlowElements(uint32_t capacity, uint32_t index, |
2022 // this object takes up nearly as much space as a fast-case backing | 2022 uint32_t* new_capacity); |
2023 // storage would. In that case the JSObject should have fast | |
2024 // elements. | |
2025 bool ShouldConvertToFastElements(); | |
2026 ElementsKind BestFittingFastElementsKind(); | 2023 ElementsKind BestFittingFastElementsKind(); |
2027 | 2024 |
2028 // Computes the new capacity when expanding the elements of a JSObject. | 2025 // Computes the new capacity when expanding the elements of a JSObject. |
2029 static uint32_t NewElementsCapacity(uint32_t old_capacity) { | 2026 static uint32_t NewElementsCapacity(uint32_t old_capacity) { |
2030 // (old_capacity + 50%) + 16 | 2027 // (old_capacity + 50%) + 16 |
2031 return old_capacity + (old_capacity >> 1) + 16; | 2028 return old_capacity + (old_capacity >> 1) + 16; |
2032 } | 2029 } |
2033 | 2030 |
2034 // These methods do not perform access checks! | 2031 // These methods do not perform access checks! |
2035 static void UpdateAllocationSite(Handle<JSObject> object, | 2032 static void UpdateAllocationSite(Handle<JSObject> object, |
(...skipping 8097 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10133 // - slow, backing storage is a HashTable with numbers as keys. | 10130 // - slow, backing storage is a HashTable with numbers as keys. |
10134 class JSArray: public JSObject { | 10131 class JSArray: public JSObject { |
10135 public: | 10132 public: |
10136 // [length]: The length property. | 10133 // [length]: The length property. |
10137 DECL_ACCESSORS(length, Object) | 10134 DECL_ACCESSORS(length, Object) |
10138 | 10135 |
10139 // Overload the length setter to skip write barrier when the length | 10136 // Overload the length setter to skip write barrier when the length |
10140 // is set to a smi. This matches the set function on FixedArray. | 10137 // is set to a smi. This matches the set function on FixedArray. |
10141 inline void set_length(Smi* length); | 10138 inline void set_length(Smi* length); |
10142 | 10139 |
10143 static void JSArrayUpdateLengthFromIndex(Handle<JSArray> array, | |
10144 uint32_t index, | |
10145 Handle<Object> value); | |
10146 | |
10147 static bool HasReadOnlyLength(Handle<JSArray> array); | 10140 static bool HasReadOnlyLength(Handle<JSArray> array); |
10148 static bool WouldChangeReadOnlyLength(Handle<JSArray> array, uint32_t index); | 10141 static bool WouldChangeReadOnlyLength(Handle<JSArray> array, uint32_t index); |
10149 static MaybeHandle<Object> ReadOnlyLengthError(Handle<JSArray> array); | 10142 static MaybeHandle<Object> ReadOnlyLengthError(Handle<JSArray> array); |
10150 | 10143 |
10151 // Initialize the array with the given capacity. The function may | 10144 // Initialize the array with the given capacity. The function may |
10152 // fail due to out-of-memory situations, but only if the requested | 10145 // fail due to out-of-memory situations, but only if the requested |
10153 // capacity is non-zero. | 10146 // capacity is non-zero. |
10154 static void Initialize(Handle<JSArray> array, int capacity, int length = 0); | 10147 static void Initialize(Handle<JSArray> array, int capacity, int length = 0); |
10155 | 10148 |
10156 // If the JSArray has fast elements, and new_length would result in | 10149 // If the JSArray has fast elements, and new_length would result in |
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10822 } else { | 10815 } else { |
10823 value &= ~(1 << bit_position); | 10816 value &= ~(1 << bit_position); |
10824 } | 10817 } |
10825 return value; | 10818 return value; |
10826 } | 10819 } |
10827 }; | 10820 }; |
10828 | 10821 |
10829 } } // namespace v8::internal | 10822 } } // namespace v8::internal |
10830 | 10823 |
10831 #endif // V8_OBJECTS_H_ | 10824 #endif // V8_OBJECTS_H_ |
OLD | NEW |