Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Side by Side Diff: src/objects.h

Issue 1197133003: Move SetFastElementsCapacity into GrowCapacityAndConvert (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/elements.cc ('k') | src/objects.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 2007 matching lines...) Expand 10 before | Expand all | Expand 10 after
2018 bool WouldConvertToSlowElements(uint32_t index); 2018 bool WouldConvertToSlowElements(uint32_t index);
2019 inline bool WouldConvertToSlowElements(Handle<Object> key); 2019 inline bool WouldConvertToSlowElements(Handle<Object> key);
2020 // Do we want to keep the elements in fast case when increasing the 2020 // Do we want to keep the elements in fast case when increasing the
2021 // capacity? 2021 // capacity?
2022 bool ShouldConvertToSlowElements(int new_capacity); 2022 bool ShouldConvertToSlowElements(int new_capacity);
2023 // Returns true if the backing storage for the slow-case elements of 2023 // Returns true if the backing storage for the slow-case elements of
2024 // this object takes up nearly as much space as a fast-case backing 2024 // this object takes up nearly as much space as a fast-case backing
2025 // storage would. In that case the JSObject should have fast 2025 // storage would. In that case the JSObject should have fast
2026 // elements. 2026 // elements.
2027 bool ShouldConvertToFastElements(); 2027 bool ShouldConvertToFastElements();
2028 // Returns true if the elements of JSObject contains only values that can be 2028 ElementsKind BestFittingFastElementsKind();
2029 // represented in a FixedDoubleArray and has at least one value that can only
2030 // be represented as a double and not a Smi.
2031 bool ShouldConvertToFastDoubleElements(bool* has_smi_only_elements);
2032 2029
2033 // Computes the new capacity when expanding the elements of a JSObject. 2030 // Computes the new capacity when expanding the elements of a JSObject.
2034 static uint32_t NewElementsCapacity(uint32_t old_capacity) { 2031 static uint32_t NewElementsCapacity(uint32_t old_capacity) {
2035 // (old_capacity + 50%) + 16 2032 // (old_capacity + 50%) + 16
2036 return old_capacity + (old_capacity >> 1) + 16; 2033 return old_capacity + (old_capacity >> 1) + 16;
2037 } 2034 }
2038 2035
2039 // These methods do not perform access checks! 2036 // These methods do not perform access checks!
2040 static void UpdateAllocationSite(Handle<JSObject> object, 2037 static void UpdateAllocationSite(Handle<JSObject> object,
2041 ElementsKind to_kind); 2038 ElementsKind to_kind);
2042 2039
2043 enum SetFastElementsCapacitySmiMode {
2044 kAllowSmiElements,
2045 kForceSmiElements,
2046 kDontAllowSmiElements
2047 };
2048
2049 static Handle<FixedArray> SetFastElementsCapacity(
2050 Handle<JSObject> object, int capacity,
2051 SetFastElementsCapacitySmiMode smi_mode);
2052
2053 // Replace the elements' backing store with fast elements of the given
2054 // capacity. Update the length for JSArrays. Returns the new backing
2055 // store.
2056 static Handle<FixedArray> SetFastElementsCapacityAndLength(
2057 Handle<JSObject> object,
2058 int capacity,
2059 int length,
2060 SetFastElementsCapacitySmiMode smi_mode);
2061 static void SetFastDoubleElementsCapacityAndLength(Handle<JSObject> object,
2062 int capacity, int length);
2063
2064 // Lookup interceptors are used for handling properties controlled by host 2040 // Lookup interceptors are used for handling properties controlled by host
2065 // objects. 2041 // objects.
2066 inline bool HasNamedInterceptor(); 2042 inline bool HasNamedInterceptor();
2067 inline bool HasIndexedInterceptor(); 2043 inline bool HasIndexedInterceptor();
2068 2044
2069 // Computes the enumerable keys from interceptors. Used for debug mirrors and 2045 // Computes the enumerable keys from interceptors. Used for debug mirrors and
2070 // by JSReceiver::GetKeys. 2046 // by JSReceiver::GetKeys.
2071 MUST_USE_RESULT static MaybeHandle<JSObject> GetKeysForNamedInterceptor( 2047 MUST_USE_RESULT static MaybeHandle<JSObject> GetKeysForNamedInterceptor(
2072 Handle<JSObject> object, 2048 Handle<JSObject> object,
2073 Handle<JSReceiver> receiver); 2049 Handle<JSReceiver> receiver);
(...skipping 8774 matching lines...) Expand 10 before | Expand all | Expand 10 after
10848 } else { 10824 } else {
10849 value &= ~(1 << bit_position); 10825 value &= ~(1 << bit_position);
10850 } 10826 }
10851 return value; 10827 return value;
10852 } 10828 }
10853 }; 10829 };
10854 10830
10855 } } // namespace v8::internal 10831 } } // namespace v8::internal
10856 10832
10857 #endif // V8_OBJECTS_H_ 10833 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/elements.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698