зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1372182 part 1 - Inline NativeObject::dynamicSlotsCount and related methods. r=anba
This commit is contained in:
Родитель
a51632396e
Коммит
e2976163c2
|
@ -500,6 +500,36 @@ NativeObject::create(JSContext* cx, js::gc::AllocKind kind, js::gc::InitialHeap
|
|||
return nobj;
|
||||
}
|
||||
|
||||
MOZ_ALWAYS_INLINE uint32_t
|
||||
NativeObject::numDynamicSlots() const
|
||||
{
|
||||
return dynamicSlotsCount(numFixedSlots(), slotSpan(), getClass());
|
||||
}
|
||||
|
||||
/* static */ MOZ_ALWAYS_INLINE uint32_t
|
||||
NativeObject::dynamicSlotsCount(uint32_t nfixed, uint32_t span, const Class* clasp)
|
||||
{
|
||||
if (span <= nfixed)
|
||||
return 0;
|
||||
span -= nfixed;
|
||||
|
||||
// Increase the slots to SLOT_CAPACITY_MIN to decrease the likelihood
|
||||
// the dynamic slots need to get increased again. ArrayObjects ignore
|
||||
// this because slots are uncommon in that case.
|
||||
if (clasp != &ArrayObject::class_ && span <= SLOT_CAPACITY_MIN)
|
||||
return SLOT_CAPACITY_MIN;
|
||||
|
||||
uint32_t slots = mozilla::RoundUpPow2(span);
|
||||
MOZ_ASSERT(slots >= span);
|
||||
return slots;
|
||||
}
|
||||
|
||||
/* static */ MOZ_ALWAYS_INLINE uint32_t
|
||||
NativeObject::dynamicSlotsCount(Shape* shape)
|
||||
{
|
||||
return dynamicSlotsCount(shape->numFixedSlots(), shape->slotSpan(), shape->getObjectClass());
|
||||
}
|
||||
|
||||
MOZ_ALWAYS_INLINE bool
|
||||
NativeObject::updateSlotsForSpan(JSContext* cx, size_t oldSpan, size_t newSpan)
|
||||
{
|
||||
|
|
|
@ -286,24 +286,6 @@ js::NativeObject::numFixedSlotsForCompilation() const
|
|||
return gc::GetGCKindSlots(kind, getClass());
|
||||
}
|
||||
|
||||
uint32_t
|
||||
js::NativeObject::dynamicSlotsCount(uint32_t nfixed, uint32_t span, const Class* clasp)
|
||||
{
|
||||
if (span <= nfixed)
|
||||
return 0;
|
||||
span -= nfixed;
|
||||
|
||||
// Increase the slots to SLOT_CAPACITY_MIN to decrease the likelihood
|
||||
// the dynamic slots need to get increased again. ArrayObjects ignore
|
||||
// this because slots are uncommon in that case.
|
||||
if (clasp != &ArrayObject::class_ && span <= SLOT_CAPACITY_MIN)
|
||||
return SLOT_CAPACITY_MIN;
|
||||
|
||||
uint32_t slots = mozilla::RoundUpPow2(span);
|
||||
MOZ_ASSERT(slots >= span);
|
||||
return slots;
|
||||
}
|
||||
|
||||
void
|
||||
NativeObject::setLastPropertyShrinkFixedSlots(Shape* shape)
|
||||
{
|
||||
|
|
|
@ -741,9 +741,7 @@ class NativeObject : public ShapedObject
|
|||
bool hasDynamicSlots() const { return !!slots_; }
|
||||
|
||||
/* Compute dynamicSlotsCount() for this object. */
|
||||
uint32_t numDynamicSlots() const {
|
||||
return dynamicSlotsCount(numFixedSlots(), slotSpan(), getClass());
|
||||
}
|
||||
MOZ_ALWAYS_INLINE uint32_t numDynamicSlots() const;
|
||||
|
||||
bool empty() const {
|
||||
return lastProperty()->isEmptyShape();
|
||||
|
@ -1024,10 +1022,9 @@ class NativeObject : public ShapedObject
|
|||
* capacity is not stored explicitly, and the allocated size of the slot
|
||||
* array is kept in sync with this count.
|
||||
*/
|
||||
static uint32_t dynamicSlotsCount(uint32_t nfixed, uint32_t span, const Class* clasp);
|
||||
static uint32_t dynamicSlotsCount(Shape* shape) {
|
||||
return dynamicSlotsCount(shape->numFixedSlots(), shape->slotSpan(), shape->getObjectClass());
|
||||
}
|
||||
static MOZ_ALWAYS_INLINE uint32_t dynamicSlotsCount(uint32_t nfixed, uint32_t span,
|
||||
const Class* clasp);
|
||||
static MOZ_ALWAYS_INLINE uint32_t dynamicSlotsCount(Shape* shape);
|
||||
|
||||
/* Elements accessors. */
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче