зеркало из 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;
|
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
|
MOZ_ALWAYS_INLINE bool
|
||||||
NativeObject::updateSlotsForSpan(JSContext* cx, size_t oldSpan, size_t newSpan)
|
NativeObject::updateSlotsForSpan(JSContext* cx, size_t oldSpan, size_t newSpan)
|
||||||
{
|
{
|
||||||
|
|
|
@ -286,24 +286,6 @@ js::NativeObject::numFixedSlotsForCompilation() const
|
||||||
return gc::GetGCKindSlots(kind, getClass());
|
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
|
void
|
||||||
NativeObject::setLastPropertyShrinkFixedSlots(Shape* shape)
|
NativeObject::setLastPropertyShrinkFixedSlots(Shape* shape)
|
||||||
{
|
{
|
||||||
|
|
|
@ -741,9 +741,7 @@ class NativeObject : public ShapedObject
|
||||||
bool hasDynamicSlots() const { return !!slots_; }
|
bool hasDynamicSlots() const { return !!slots_; }
|
||||||
|
|
||||||
/* Compute dynamicSlotsCount() for this object. */
|
/* Compute dynamicSlotsCount() for this object. */
|
||||||
uint32_t numDynamicSlots() const {
|
MOZ_ALWAYS_INLINE uint32_t numDynamicSlots() const;
|
||||||
return dynamicSlotsCount(numFixedSlots(), slotSpan(), getClass());
|
|
||||||
}
|
|
||||||
|
|
||||||
bool empty() const {
|
bool empty() const {
|
||||||
return lastProperty()->isEmptyShape();
|
return lastProperty()->isEmptyShape();
|
||||||
|
@ -1024,10 +1022,9 @@ class NativeObject : public ShapedObject
|
||||||
* capacity is not stored explicitly, and the allocated size of the slot
|
* capacity is not stored explicitly, and the allocated size of the slot
|
||||||
* array is kept in sync with this count.
|
* array is kept in sync with this count.
|
||||||
*/
|
*/
|
||||||
static uint32_t dynamicSlotsCount(uint32_t nfixed, uint32_t span, const Class* clasp);
|
static MOZ_ALWAYS_INLINE uint32_t dynamicSlotsCount(uint32_t nfixed, uint32_t span,
|
||||||
static uint32_t dynamicSlotsCount(Shape* shape) {
|
const Class* clasp);
|
||||||
return dynamicSlotsCount(shape->numFixedSlots(), shape->slotSpan(), shape->getObjectClass());
|
static MOZ_ALWAYS_INLINE uint32_t dynamicSlotsCount(Shape* shape);
|
||||||
}
|
|
||||||
|
|
||||||
/* Elements accessors. */
|
/* Elements accessors. */
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче