mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-07 16:28:38 +09:00
1320408 - Part 25: Change NativeObject::toDictionaryMode to static method.
This commit is contained in:
parent
83fb6841af
commit
f232a0b574
2 changed files with 17 additions and 19 deletions
|
|
@ -510,7 +510,7 @@ class NativeObject : public ShapedObject
|
|||
*/
|
||||
bool setSlotSpan(ExclusiveContext* cx, uint32_t span);
|
||||
|
||||
bool toDictionaryMode(ExclusiveContext* cx);
|
||||
static MOZ_MUST_USE bool toDictionaryMode(ExclusiveContext* cx, HandleNativeObject obj);
|
||||
|
||||
private:
|
||||
friend class TenuringTracer;
|
||||
|
|
|
|||
|
|
@ -460,15 +460,13 @@ NativeObject::getChildProperty(ExclusiveContext* cx,
|
|||
return shape;
|
||||
}
|
||||
|
||||
bool
|
||||
js::NativeObject::toDictionaryMode(ExclusiveContext* cx)
|
||||
/* static */ bool
|
||||
js::NativeObject::toDictionaryMode(ExclusiveContext* cx, HandleNativeObject obj)
|
||||
{
|
||||
MOZ_ASSERT(!inDictionaryMode());
|
||||
MOZ_ASSERT(cx->isInsideCurrentCompartment(this));
|
||||
MOZ_ASSERT(!obj->inDictionaryMode());
|
||||
MOZ_ASSERT(cx->isInsideCurrentCompartment(obj));
|
||||
|
||||
uint32_t span = slotSpan();
|
||||
|
||||
Rooted<NativeObject*> self(cx, this);
|
||||
uint32_t span = obj->slotSpan();
|
||||
|
||||
// Clone the shapes into a new dictionary list. Don't update the last
|
||||
// property of this object until done, otherwise a GC triggered while
|
||||
|
|
@ -476,7 +474,7 @@ js::NativeObject::toDictionaryMode(ExclusiveContext* cx)
|
|||
RootedShape root(cx);
|
||||
RootedShape dictionaryShape(cx);
|
||||
|
||||
RootedShape shape(cx, lastProperty());
|
||||
RootedShape shape(cx, obj->lastProperty());
|
||||
while (shape) {
|
||||
MOZ_ASSERT(!shape->inDictionary());
|
||||
|
||||
|
|
@ -488,7 +486,7 @@ js::NativeObject::toDictionaryMode(ExclusiveContext* cx)
|
|||
|
||||
GCPtrShape* listp = dictionaryShape ? &dictionaryShape->parent : nullptr;
|
||||
StackShape child(shape);
|
||||
dprop->initDictionaryShape(child, self->numFixedSlots(), listp);
|
||||
dprop->initDictionaryShape(child, obj->numFixedSlots(), listp);
|
||||
|
||||
if (!dictionaryShape)
|
||||
root = dprop;
|
||||
|
|
@ -503,18 +501,18 @@ js::NativeObject::toDictionaryMode(ExclusiveContext* cx)
|
|||
return false;
|
||||
}
|
||||
|
||||
if (IsInsideNursery(self) &&
|
||||
!cx->asJSContext()->gc.nursery.queueDictionaryModeObjectToSweep(self))
|
||||
if (IsInsideNursery(obj) &&
|
||||
!cx->asJSContext()->gc.nursery.queueDictionaryModeObjectToSweep(obj))
|
||||
{
|
||||
ReportOutOfMemory(cx);
|
||||
return false;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(root->listp == nullptr);
|
||||
root->listp = &self->shape_;
|
||||
self->shape_ = root;
|
||||
root->listp = &obj->shape_;
|
||||
obj->shape_ = root;
|
||||
|
||||
MOZ_ASSERT(self->inDictionaryMode());
|
||||
MOZ_ASSERT(obj->inDictionaryMode());
|
||||
root->base()->setSlotSpan(span);
|
||||
|
||||
return true;
|
||||
|
|
@ -592,7 +590,7 @@ NativeObject::addPropertyInternal(ExclusiveContext* cx,
|
|||
if (allowDictionary &&
|
||||
(!stableSlot || ShouldConvertToDictionary(obj)))
|
||||
{
|
||||
if (!obj->toDictionaryMode(cx))
|
||||
if (!toDictionaryMode(cx, obj))
|
||||
return nullptr;
|
||||
table = obj->lastProperty()->maybeTable(keep);
|
||||
entry = &table->search<MaybeAdding::Adding>(id, keep);
|
||||
|
|
@ -834,7 +832,7 @@ NativeObject::putProperty(ExclusiveContext* cx, HandleNativeObject obj, HandleId
|
|||
* addPropertyInternal because a failure under add would lose data.
|
||||
*/
|
||||
if (shape != obj->lastProperty() && !obj->inDictionaryMode()) {
|
||||
if (!obj->toDictionaryMode(cx))
|
||||
if (!toDictionaryMode(cx, obj))
|
||||
return nullptr;
|
||||
ShapeTable* table = obj->lastProperty()->maybeTable(keep);
|
||||
MOZ_ASSERT(table);
|
||||
|
|
@ -988,7 +986,7 @@ NativeObject::removeProperty(ExclusiveContext* cx, HandleNativeObject obj, jsid
|
|||
* be removed, switch to dictionary mode.
|
||||
*/
|
||||
if (!obj->inDictionaryMode() && (shape != obj->lastProperty() || !obj->canRemoveLastProperty())) {
|
||||
if (!obj->toDictionaryMode(cx))
|
||||
if (!toDictionaryMode(cx, obj))
|
||||
return false;
|
||||
ShapeTable* table = obj->lastProperty()->maybeTable(keep);
|
||||
MOZ_ASSERT(table);
|
||||
|
|
@ -1150,7 +1148,7 @@ NativeObject::replaceWithNewEquivalentShape(ExclusiveContext* cx, HandleNativeOb
|
|||
|
||||
if (!obj->inDictionaryMode()) {
|
||||
RootedShape newRoot(cx, newShape);
|
||||
if (!obj->toDictionaryMode(cx))
|
||||
if (!toDictionaryMode(cx, obj))
|
||||
return nullptr;
|
||||
oldShape = obj->lastProperty();
|
||||
newShape = newRoot;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue