mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-02 12:07:52 +00:00
Bug 1710075 part 1 - Add CanUseFixedElementsForArray helper function. r=jonco
Differential Revision: https://phabricator.services.mozilla.com/D114603
This commit is contained in:
parent
5689f0cd89
commit
fd935d4299
@ -46,6 +46,14 @@ static inline AllocKind GetGCObjectKind(const JSClass* clasp) {
|
||||
return GetGCObjectKind(nslots);
|
||||
}
|
||||
|
||||
static bool CanUseFixedElementsForArray(size_t numElements) {
|
||||
if (numElements > NativeObject::MAX_DENSE_ELEMENTS_COUNT) {
|
||||
return false;
|
||||
}
|
||||
size_t numSlots = numElements + ObjectElements::VALUES_PER_HEADER;
|
||||
return numSlots < SLOTS_TO_THING_KIND_LIMIT;
|
||||
}
|
||||
|
||||
/* As for GetGCObjectKind, but for dense array allocation. */
|
||||
static inline AllocKind GetGCArrayKind(size_t numElements) {
|
||||
/*
|
||||
@ -55,9 +63,7 @@ static inline AllocKind GetGCArrayKind(size_t numElements) {
|
||||
* unused.
|
||||
*/
|
||||
static_assert(ObjectElements::VALUES_PER_HEADER == 2);
|
||||
if (numElements > NativeObject::MAX_DENSE_ELEMENTS_COUNT ||
|
||||
numElements + ObjectElements::VALUES_PER_HEADER >=
|
||||
SLOTS_TO_THING_KIND_LIMIT) {
|
||||
if (!CanUseFixedElementsForArray(numElements)) {
|
||||
return AllocKind::OBJECT2;
|
||||
}
|
||||
return slotsToThingKind[numElements + ObjectElements::VALUES_PER_HEADER];
|
||||
|
Loading…
x
Reference in New Issue
Block a user