Rename freeslot appropriately (593256 separated cosmetics-only patch, r=jorendorff).

This commit is contained in:
Brendan Eich 2010-09-03 11:05:43 -07:00
Родитель 53962e33a7
Коммит 857b88f290
13 изменённых файлов: 69 добавлений и 69 удалений

Просмотреть файл

@ -2965,7 +2965,7 @@ JS_SealObject(JSContext *cx, JSObject *obj, JSBool deep)
return true;
/* Walk slots in obj and if any value is a non-null object, seal it. */
for (uint32 i = 0, n = obj->freeslot(); i != n; ++i) {
for (uint32 i = 0, n = obj->slotSpan(); i != n; ++i) {
const Value &v = obj->getSlot(i);
if (i == JSSLOT_PRIVATE && (obj->getClass()->flags & JSCLASS_HAS_PRIVATE))
continue;

Просмотреть файл

@ -195,7 +195,7 @@ AddPropertyHelper(JSContext* cx, JSObject* obj, Shape* shape, bool isDefinitelyA
uint32 slot;
slot = shape->slot;
JS_ASSERT(slot == obj->freeslot());
JS_ASSERT(slot == obj->slotSpan());
if (slot < obj->numSlots()) {
JS_ASSERT(obj->getSlot(slot).isUndefined());

Просмотреть файл

@ -968,7 +968,7 @@ NewCallObject(JSContext *cx, JSFunction *fun, JSObject *scopeChain)
for (Shape::Range r = callobj->lastProp; !r.empty(); r.popFront()) {
const Shape &s = r.front();
if (s.slot != SHAPE_INVALID_SLOT) {
JS_ASSERT(s.slot + 1 == callobj->freeslot());
JS_ASSERT(s.slot + 1 == callobj->slotSpan());
break;
}
}
@ -2415,7 +2415,7 @@ JSObject::initBoundFunction(JSContext *cx, const Value &thisArg,
if (!empty)
return false;
empty->freeslot += argslen;
empty->slotSpan += argslen;
map = empty;
if (!ensureInstanceReservedSlots(cx, argslen))
@ -3212,8 +3212,8 @@ JSFunction::addLocal(JSContext *cx, JSAtom *atom, JSLocalKind kind)
if (findArgInsertionPoint) {
while (parent->parent && parent->getter() != js_GetCallArg) {
++parent->slot;
JS_ASSERT(parent->slot == parent->freeslot);
++parent->freeslot;
JS_ASSERT(parent->slot == parent->slotSpan);
++parent->slotSpan;
listp = &parent->parent;
parent = *listp;
}

Просмотреть файл

@ -4196,7 +4196,7 @@ BEGIN_CASE(JSOP_SETMETHOD)
entry->vshape() == rt->protoHazardShape &&
shape->hasDefaultSetter()) {
slot = shape->slot;
JS_ASSERT(slot == obj->freeslot());
JS_ASSERT(slot == obj->slotSpan());
/*
* Fast path: adding a plain old property that was once at
@ -5861,7 +5861,7 @@ BEGIN_CASE(JSOP_INITMETHOD)
/* Fast path. Property cache hit. */
uint32 slot = shape->slot;
JS_ASSERT(slot == obj->freeslot());
JS_ASSERT(slot == obj->slotSpan());
JS_ASSERT(slot >= JSSLOT_FREE(obj->getClass()));
if (slot < obj->numSlots()) {
JS_ASSERT(obj->getSlot(slot).isUndefined());

Просмотреть файл

@ -507,7 +507,7 @@ FinishSharingTitle(JSContext *cx, JSTitle *title)
JSObject *obj = TITLE_TO_OBJECT(title);
if (obj) {
uint32 nslots = obj->freeslot();
uint32 nslots = obj->slotSpan();
JS_ASSERT(nslots >= JSSLOT_START(obj->getClass()));
for (uint32 i = JSSLOT_START(obj->getClass()); i != nslots; ++i) {
Value v = obj->getSlot(i);

Просмотреть файл

@ -3866,7 +3866,7 @@ js_ConstructObject(JSContext *cx, Class *clasp, JSObject *proto, JSObject *paren
bool
JSObject::allocSlot(JSContext *cx, uint32 *slotp)
{
uint32 slot = freeslot();
uint32 slot = slotSpan();
JS_ASSERT(slot >= JSSLOT_FREE(clasp));
/*
@ -3874,7 +3874,7 @@ JSObject::allocSlot(JSContext *cx, uint32 *slotp)
* pull a free slot from the property table's slot-number freelist.
*/
if (inDictionaryMode() && lastProp->table) {
uint32 &last = lastProp->table->freeslot;
uint32 &last = lastProp->table->freelist;
if (last != SHAPE_INVALID_SLOT) {
#ifdef DEBUG
JS_ASSERT(last < slot);
@ -3903,12 +3903,12 @@ JSObject::allocSlot(JSContext *cx, uint32 *slotp)
void
JSObject::freeSlot(JSContext *cx, uint32 slot)
{
uint32 limit = freeslot();
uint32 limit = slotSpan();
JS_ASSERT(slot < limit);
Value &vref = getSlotRef(slot);
if (inDictionaryMode() && lastProp->table) {
uint32 &last = lastProp->table->freeslot;
uint32 &last = lastProp->table->freelist;
/* Can't afford to check the whole freelist, but let's check the head. */
JS_ASSERT_IF(last != SHAPE_INVALID_SLOT, last < limit && last != slot);
@ -3920,7 +3920,7 @@ JSObject::freeSlot(JSContext *cx, uint32 slot)
* js_TraceObject.
*/
if (slot + 1 < limit) {
JS_ASSERT_IF(last != SHAPE_INVALID_SLOT, last < freeslot());
JS_ASSERT_IF(last != SHAPE_INVALID_SLOT, last < slotSpan());
vref.setPrivateUint32(last);
last = slot;
return;
@ -5921,7 +5921,7 @@ js_TraceObject(JSTracer *trc, JSObject *obj)
* The !obj->nativeEmpty() guard above is due to the bug described by
* the FIXME comment below.
*/
size_t slots = obj->freeslot();
size_t slots = obj->slotSpan();
if (obj->numSlots() != slots)
obj->shrinkSlots(cx, slots);
}
@ -5953,14 +5953,14 @@ js_TraceObject(JSTracer *trc, JSObject *obj)
* want to be defensive), leave this code here -- don't move it up and
* unify it with the |if (!traceScope)| section above.
*
* FIXME: We minimize nslots against obj->freeslot because native objects
* such as Date instances may have failed to advance freeslot to cover all
* FIXME: We minimize nslots against obj->slotSpan because native objects
* such as Date instances may have failed to advance slotSpan to cover all
* reserved slots (this Date issue may be a bug in JSObject::growSlots, but
* the general problem occurs in other built-in class implementations).
*/
uint32 nslots = obj->numSlots();
if (!obj->nativeEmpty() && obj->freeslot() < nslots)
nslots = obj->freeslot();
if (!obj->nativeEmpty() && obj->slotSpan() < nslots)
nslots = obj->slotSpan();
JS_ASSERT(nslots >= JSSLOT_START(clasp));
for (uint32 i = JSSLOT_START(clasp); i != nslots; ++i) {
@ -5982,7 +5982,7 @@ js_ClearNative(JSContext *cx, JSObject *obj)
/* Now that we're done using real properties, clear obj. */
obj->clear(cx);
/* Clear slot values and reset freeslot so we're consistent. */
/* Clear slot values since obj->clear reset our shape to empty. */
uint32 freeslot = JSSLOT_FREE(obj->getClass());
uint32 n = obj->numSlots();
for (uint32 i = freeslot; i < n; ++i)
@ -6332,7 +6332,7 @@ js_DumpObject(JSObject *obj)
fprintf(stderr, "slots:\n");
reservedEnd = i + JSCLASS_RESERVED_SLOTS(clasp);
slots = obj->freeslot();
slots = obj->slotSpan();
for (; i < slots; i++) {
fprintf(stderr, " %3d ", i);
if (i < reservedEnd)

Просмотреть файл

@ -181,10 +181,10 @@ struct JSObjectMap {
static JS_FRIEND_DATA(const JSObjectMap) sharedNonNative;
uint32 shape; /* shape identifier */
uint32 freeslot; /* first free object slot */
uint32 slotSpan; /* one more than maximum live slot number */
explicit JSObjectMap(uint32 shape) : shape(shape), freeslot(0) {}
JSObjectMap(uint32 shape, uint32 freeslot) : shape(shape), freeslot(freeslot) {}
explicit JSObjectMap(uint32 shape) : shape(shape), slotSpan(0) {}
JSObjectMap(uint32 shape, uint32 slotSpan) : shape(shape), slotSpan(slotSpan) {}
enum { INVALID_SHAPE = 0x8fffffff, SHAPELESS = 0xffffffff };
@ -356,8 +356,8 @@ struct JSObject {
#endif
/*
* Return an immutable, shareable, empty scope with the same ops as this
* and the same freeslot as this had when empty.
* Return an immutable, shareable, empty shape with the same clasp as this
* and the same slotSpan as this had when empty.
*
* If |this| is the scope of an object |proto|, the resulting scope can be
* used as the scope of a new object whose prototype is |proto|.
@ -577,9 +577,9 @@ struct JSObject {
inline bool ensureClassReservedSlots(JSContext *cx);
uint32 freeslot() const { return map->freeslot; }
uint32 slotSpan() const { return map->slotSpan; }
bool containsSlot(uint32 slot) const { return slot < freeslot(); }
bool containsSlot(uint32 slot) const { return slot < slotSpan(); }
js::Value& getSlotRef(uintN slot) {
return (slot < JS_INITIAL_NSLOTS)

Просмотреть файл

@ -777,7 +777,7 @@ Compiler::compileScript(JSContext *cx, JSObject *scopeChain, JSStackFrame *calle
if (!js_GetClassPrototype(cx, scopeChain, JSProto_Function, &tobj))
return NULL;
globalScope.globalFreeSlot = globalObj->freeslot();
globalScope.globalFreeSlot = globalObj->slotSpan();
}
/* Null script early in case of error, to reduce our code footprint. */
@ -947,7 +947,7 @@ Compiler::compileScript(JSContext *cx, JSObject *scopeChain, JSStackFrame *calle
}
if (globalScope.defs.length()) {
JS_ASSERT(globalObj->freeslot() == globalScope.globalFreeSlot);
JS_ASSERT(globalObj->slotSpan() == globalScope.globalFreeSlot);
JS_ASSERT(!cg.compilingForEval());
for (size_t i = 0; i < globalScope.defs.length(); i++) {
GlobalScope::GlobalDef &def = globalScope.defs[i];

Просмотреть файл

@ -133,7 +133,7 @@ JS_ALWAYS_INLINE bool
PropertyCache::testForInit(JSRuntime *rt, jsbytecode *pc, JSObject *obj,
const js::Shape **shapep, PropertyCacheEntry **entryp)
{
JS_ASSERT(obj->freeslot() >= JSSLOT_FREE(obj->getClass()));
JS_ASSERT(obj->slotSpan() >= JSSLOT_FREE(obj->getClass()));
JS_ASSERT(!obj->sealed());
uint32 kshape = obj->shape();
PropertyCacheEntry *entry = &table[hash(pc, kshape)];

Просмотреть файл

@ -107,7 +107,7 @@ JSObject::ensureClassReservedSlotsForEmptyObject(JSContext *cx)
* (a) never escape anywhere an ad-hoc property could be set on them; or
*
* (b) protect their instance-reserved slots with shapes, at least a custom
* empty shape with the right freeslot member.
* empty shape with the right slotSpan member.
*
* Block objects are the only objects that fall into category (a). While
* Call objects cannot escape, they can grow ad-hoc properties via eval
@ -528,7 +528,7 @@ Shape::newDictionaryShape(JSContext *cx, const Shape &child, Shape **listp)
new (dprop) Shape(child.id, child.rawGetter, child.rawSetter, child.slot, child.attrs,
(child.flags & ~FROZEN) | IN_DICTIONARY, child.shortid,
js_GenerateShape(cx, false), child.freeslot);
js_GenerateShape(cx, false), child.slotSpan);
dprop->listp = NULL;
dprop->insertIntoDictionary(listp);
@ -647,9 +647,9 @@ JSObject::checkShapeConsistency()
if (inDictionaryMode()) {
if (PropertyTable *table = shape->table) {
for (uint32 fslot = table->freeslot; fslot != SHAPE_INVALID_SLOT;
for (uint32 fslot = table->freelist; fslot != SHAPE_INVALID_SLOT;
fslot = getSlotRef(fslot).toPrivateUint32()) {
JS_ASSERT(fslot < shape->freeslot);
JS_ASSERT(fslot < shape->slotSpan);
}
for (int n = throttle; --n >= 0 && shape->parent; shape = shape->parent) {
@ -666,13 +666,13 @@ JSObject::checkShapeConsistency()
shape = lastProp;
for (int n = throttle; --n >= 0 && shape; shape = shape->parent) {
JS_ASSERT_IF(shape->slot != SHAPE_INVALID_SLOT, shape->slot < shape->freeslot);
JS_ASSERT_IF(shape->slot != SHAPE_INVALID_SLOT, shape->slot < shape->slotSpan);
if (!prev) {
JS_ASSERT(shape == lastProp);
JS_ASSERT(shape->listp == &lastProp);
} else {
JS_ASSERT(shape->listp == &prev->parent);
JS_ASSERT(prev->freeslot >= shape->freeslot);
JS_ASSERT(prev->slotSpan >= shape->slotSpan);
}
prev = shape;
}
@ -686,7 +686,7 @@ JSObject::checkShapeConsistency()
}
}
if (prev) {
JS_ASSERT(prev->freeslot >= shape->freeslot);
JS_ASSERT(prev->slotSpan >= shape->slotSpan);
if (shape->kids.isShape()) {
JS_ASSERT(shape->kids.toShape() == prev);
} else if (shape->kids.isChunk()) {
@ -904,11 +904,11 @@ JSObject::putProperty(JSContext *cx, jsid id,
#ifdef DEBUG
if (shape == oldLastProp) {
JS_ASSERT(lastProp->freeslot <= shape->freeslot);
JS_ASSERT(lastProp->slotSpan <= shape->slotSpan);
if (shape->hasSlot())
JS_ASSERT(shape->slot < shape->freeslot);
if (lastProp->freeslot < numSlots())
getSlotRef(lastProp->freeslot).setUndefined();
JS_ASSERT(shape->slot < shape->slotSpan);
if (lastProp->slotSpan < numSlots())
getSlotRef(lastProp->slotSpan).setUndefined();
}
#endif
@ -1119,16 +1119,16 @@ JSObject::removeProperty(JSContext *cx, jsid id)
if (shape == oldLastProp) {
JS_ASSERT(shape->table == table);
JS_ASSERT(shape->parent == lastProp);
JS_ASSERT(shape->freeslot >= lastProp->freeslot);
JS_ASSERT_IF(hadSlot, shape->slot + 1 <= shape->freeslot);
JS_ASSERT(shape->slotSpan >= lastProp->slotSpan);
JS_ASSERT_IF(hadSlot, shape->slot + 1 <= shape->slotSpan);
/*
* If the dictionary table's freelist is non-empty, we must
* preserve lastProp->freeslot. We can't reduce freeslot even
* by one or we might lose non-decreasing freeslot order.
* preserve lastProp->slotSpan. We can't reduce slotSpan even
* by one or we might lose non-decreasing slotSpan order.
*/
if (table->freeslot != SHAPE_INVALID_SLOT)
lastProp->freeslot = shape->freeslot;
if (table->freelist != SHAPE_INVALID_SLOT)
lastProp->slotSpan = shape->slotSpan;
}
/* Hand off table from old to new lastProp. */

Просмотреть файл

@ -228,7 +228,7 @@ struct PropertyTable {
uint32 entryCount; /* number of entries in table */
uint32 removedCount; /* removed entry sentinels in table */
uint32 freeslot; /* SHAPE_INVALID_SLOT or head of slot
uint32 freelist; /* SHAPE_INVALID_SLOT or head of slot
freelist in owning dictionary-mode
object */
js::Shape **entries; /* table of ptrs to shared tree nodes */
@ -237,7 +237,7 @@ struct PropertyTable {
: hashShift(JS_DHASH_BITS - MIN_SIZE_LOG2),
entryCount(nentries),
removedCount(0),
freeslot(SHAPE_INVALID_SLOT)
freelist(SHAPE_INVALID_SLOT)
{
/* NB: entries is set by init, which must be called. */
}
@ -361,28 +361,28 @@ struct Shape : public JSObjectMap
bool maybeHash(JSContext *cx);
void setTable(js::PropertyTable *t) const {
JS_ASSERT_IF(t && t->freeslot != SHAPE_INVALID_SLOT, t->freeslot < freeslot);
JS_ASSERT_IF(t && t->freelist != SHAPE_INVALID_SLOT, t->freelist < slotSpan);
table = t;
}
/*
* Setter for parent. The challenge is to maintain JSObjectMap::freeslot in
* Setter for parent. The challenge is to maintain JSObjectMap::slotSpan in
* the face of arbitrary slot order.
*
* By induction, an empty shape has a freeslot member correctly computed as
* By induction, an empty shape has a slotSpan member correctly computed as
* JSCLASS_FREE(clasp) -- see EmptyShape's constructor in jsscopeinlines.h.
* This is the basis case, where p is null.
*
* Any child shape, whether in a shape tree or in a dictionary list, must
* have a freeslot either one greater than its slot value (if the child's
* have a slotSpan either one greater than its slot value (if the child's
* slot is SHAPE_INVALID_SLOT, this will yield 0; the static assertion just
* after the SHAPE_INVALID_SLOT definition enforces this), or equal to its
* parent p's freeslot, whichever is greater. This is the inductive step.
* parent p's slotSpan, whichever is greater. This is the inductive step.
*
* If we maintained shape paths such that parent slot was always one less
* than child slot, possibly with an exception for SHAPE_INVALID_SLOT slot
* values where we would use another way of computing freeslot based on the
* PropertyTable (as JSC does), then we would not need to store freeslot in
* values where we would use another way of computing slotSpan based on the
* PropertyTable (as JSC does), then we would not need to store slotSpan in
* Shape (to be precise, in its base struct, JSobjectMap).
*
* But we currently scramble slots along shape paths due to resolve-based
@ -396,20 +396,20 @@ struct Shape : public JSObjectMap
* it always switches the target object to dictionary mode, so the cost of
* a pinned table is less onerous.
*
* Note that allocating a uint32 freeslot member in JSObjectMap takes no
* Note that allocating a uint32 slotSpan member in JSObjectMap takes no
* net extra space on 64-bit targets (it packs with shape). And on 32-bit
* targets, adding freeslot to JSObjectMap takes no gross extra space,
* targets, adding slotSpan to JSObjectMap takes no gross extra space,
* because Shape rounds up to an even number of 32-bit words (required for
* GC-thing and js::Value allocation in any event) on 32-bit targets.
*
* So in terms of space, we can afford to maintain both freeslot and slot,
* but it might be better if we eliminated freeslot using slot combined
* So in terms of space, we can afford to maintain both slotSpan and slot,
* but it might be better if we eliminated slotSpan using slot combined
* with an auxiliary mechanism based on table.
*/
void setParent(js::Shape *p) {
if (p)
freeslot = JS_MAX(p->freeslot, slot + 1);
JS_ASSERT(freeslot < JSObject::NSLOTS_LIMIT);
slotSpan = JS_MAX(p->slotSpan, slot + 1);
JS_ASSERT(slotSpan < JSObject::NSLOTS_LIMIT);
parent = p;
}
@ -490,7 +490,7 @@ struct Shape : public JSObjectMap
};
Shape(jsid id, js::PropertyOp getter, js::PropertyOp setter, uint32 slot, uintN attrs,
uintN flags, intN shortid, uint32 shape = INVALID_SHAPE, uint32 freeslot = 0);
uintN flags, intN shortid, uint32 shape = INVALID_SHAPE, uint32 slotSpan = 0);
/* Used by EmptyShape (see jsscopeinlines.h). */
Shape(JSContext *cx, Class *aclasp);

Просмотреть файл

@ -145,12 +145,12 @@ namespace js {
inline
Shape::Shape(jsid id, js::PropertyOp getter, js::PropertyOp setter, uint32 slot, uintN attrs,
uintN flags, intN shortid, uint32 shape, uint32 freeslot)
: JSObjectMap(shape, freeslot),
uintN flags, intN shortid, uint32 shape, uint32 slotSpan)
: JSObjectMap(shape, slotSpan),
table(NULL), id(id), rawGetter(getter), rawSetter(setter), slot(slot), attrs(uint8(attrs)),
flags(uint8(flags)), shortid(int16(shortid)), parent(NULL)
{
JS_ASSERT_IF(freeslot != SHAPE_INVALID_SLOT, freeslot < JSObject::NSLOTS_LIMIT);
JS_ASSERT_IF(slotSpan != SHAPE_INVALID_SLOT, slotSpan < JSObject::NSLOTS_LIMIT);
JS_ASSERT_IF(getter && (attrs & JSPROP_GETTER), getterObj->isCallable());
JS_ASSERT_IF(setter && (attrs & JSPROP_SETTER), setterObj->isCallable());
kids.setNull();

Просмотреть файл

@ -197,7 +197,7 @@ stubs::SetName(VMFrame &f, JSAtom *origAtom)
entry->vshape() == cx->runtime->protoHazardShape &&
shape->hasDefaultSetter()) {
slot = shape->slot;
JS_ASSERT(slot == obj->freeslot());
JS_ASSERT(slot == obj->slotSpan());
/*
* Fast path: adding a plain old property that was once at
@ -2179,7 +2179,7 @@ InitPropOrMethod(VMFrame &f, JSAtom *atom, JSOp op)
/* Fast path. Property cache hit. */
uint32 slot = shape->slot;
JS_ASSERT(slot == obj->freeslot());
JS_ASSERT(slot == obj->slotSpan());
JS_ASSERT(slot >= JSSLOT_FREE(obj->getClass()));
if (slot < obj->numSlots()) {
JS_ASSERT(obj->getSlot(slot).isUndefined());