diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp index caa407eac58..aecc9020506 100644 --- a/js/src/jsapi.cpp +++ b/js/src/jsapi.cpp @@ -4278,7 +4278,7 @@ JS_CloneFunctionObject(JSContext *cx, JSObject *funobj, JSObject *parent) * but looking up the property by name instead of frame slot. */ if (FUN_FLAT_CLOSURE(fun)) { - JS_ASSERT(DSLOTS_IS_NOT_NULL(funobj)); + JS_ASSERT(funobj->dslots); if (!js_EnsureReservedSlots(cx, clone, fun->countInterpretedReservedSlots())) { return NULL; diff --git a/js/src/jsarray.cpp b/js/src/jsarray.cpp index 6dbc702695f..8264b42f515 100644 --- a/js/src/jsarray.cpp +++ b/js/src/jsarray.cpp @@ -315,9 +315,9 @@ ResizeSlots(JSContext *cx, JSObject *obj, uint32 oldlen, uint32 newlen, jsval *slots, *newslots; if (newlen == 0) { - if (DSLOTS_IS_NOT_NULL(obj)) { + if (obj->dslots) { cx->free(obj->dslots - 1); - obj->dslots = DSLOTS_NULL_RESIZE_SLOTS; + obj->dslots = NULL; } return JS_TRUE; } @@ -327,7 +327,7 @@ ResizeSlots(JSContext *cx, JSObject *obj, uint32 oldlen, uint32 newlen, return JS_FALSE; } - slots = DSLOTS_IS_NOT_NULL(obj) ? obj->dslots - 1 : NULL; + slots = obj->dslots ? obj->dslots - 1 : NULL; newslots = (jsval *) cx->realloc(slots, (size_t(newlen) + 1) * sizeof(jsval)); if (!newslots) return JS_FALSE; @@ -1210,9 +1210,9 @@ slowarray_enumerate(JSContext *cx, JSObject *obj, JSIterateOp enum_op, static void array_finalize(JSContext *cx, JSObject *obj) { - if (DSLOTS_IS_NOT_NULL(obj)) + if (obj->dslots) cx->free(obj->dslots - 1); - obj->dslots = DSLOTS_NULL_ARRAY_FINALIZE; + obj->dslots = NULL; } static void @@ -1826,7 +1826,7 @@ array_reverse(JSContext *cx, uintN argc, jsval *vp) if (OBJ_IS_DENSE_ARRAY(cx, obj) && !js_PrototypeHasIndexedProperties(cx, obj)) { /* An empty array or an array with no elements is already reversed. */ - if (len == 0 || !DSLOTS_IS_NOT_NULL(obj)) + if (len == 0 || !obj->dslots) return JS_TRUE; /* @@ -2553,7 +2553,7 @@ array_shift(JSContext *cx, uintN argc, jsval *vp) if (OBJ_IS_DENSE_ARRAY(cx, obj) && !js_PrototypeHasIndexedProperties(cx, obj) && length < js_DenseArrayCapacity(obj)) { - if (JS_LIKELY(DSLOTS_IS_NOT_NULL(obj))) { + if (JS_LIKELY(obj->dslots != NULL)) { *vp = obj->dslots[0]; if (*vp == JSVAL_HOLE) *vp = JSVAL_VOID; @@ -3420,7 +3420,7 @@ js_NewEmptyArray(JSContext* cx, JSObject* proto) obj->fslots[JSSLOT_ARRAY_COUNT] = 0; for (unsigned i = JSSLOT_ARRAY_COUNT + 1; i != JS_INITIAL_NSLOTS; ++i) obj->fslots[i] = JSVAL_VOID; - obj->dslots = DSLOTS_NULL_NEW_EMPTY_ARRAY; + obj->dslots = NULL; return obj; } #ifdef JS_TRACER diff --git a/js/src/jsarray.h b/js/src/jsarray.h index ff54ceb326d..9a44afd992b 100644 --- a/js/src/jsarray.h +++ b/js/src/jsarray.h @@ -123,14 +123,14 @@ static JS_INLINE uint32 js_DenseArrayCapacity(JSObject *obj) { JS_ASSERT(js_IsDenseArray(obj)); - return DSLOTS_IS_NOT_NULL(obj) ? (uint32) obj->dslots[-1] : 0; + return obj->dslots ? (uint32) obj->dslots[-1] : 0; } static JS_INLINE void js_SetDenseArrayCapacity(JSObject *obj, uint32 capacity) { JS_ASSERT(js_IsDenseArray(obj)); - JS_ASSERT(DSLOTS_IS_NOT_NULL(obj)); + JS_ASSERT(obj->dslots); obj->dslots[-1] = (jsval) capacity; } diff --git a/js/src/jsbuiltins.cpp b/js/src/jsbuiltins.cpp index 6a56e5ba035..c87ba1e4592 100644 --- a/js/src/jsbuiltins.cpp +++ b/js/src/jsbuiltins.cpp @@ -422,8 +422,7 @@ js_NewNullClosure(JSContext* cx, JSObject* funobj, JSObject* proto, JSObject* pa closure->map = scope; closure->init(&js_FunctionClass, proto, parent, - reinterpret_cast(fun), - DSLOTS_NULL_INIT_CLOSURE); + reinterpret_cast(fun)); return closure; } JS_DEFINE_CALLINFO_4(extern, OBJECT, js_NewNullClosure, CONTEXT, OBJECT, OBJECT, OBJECT, 0, 0) diff --git a/js/src/jsdbgapi.cpp b/js/src/jsdbgapi.cpp index 4ec3a9c9ea8..68063b1e8e2 100644 --- a/js/src/jsdbgapi.cpp +++ b/js/src/jsdbgapi.cpp @@ -1595,7 +1595,7 @@ JS_GetObjectTotalSize(JSContext *cx, JSObject *obj) JSScope *scope; nbytes = sizeof *obj; - if (DSLOTS_IS_NOT_NULL(obj)) { + if (obj->dslots) { nbytes += ((uint32)obj->dslots[-1] - JS_INITIAL_NSLOTS + 1) * sizeof obj->dslots[0]; } diff --git a/js/src/jsobj.cpp b/js/src/jsobj.cpp index 9373ce90912..b0d08f8c0f4 100644 --- a/js/src/jsobj.cpp +++ b/js/src/jsobj.cpp @@ -2099,7 +2099,6 @@ obj_keys(JSContext *cx, uintN argc, jsval *vp) return JS_FALSE; *vp = OBJECT_TO_JSVAL(aobj); - JS_ASSERT(DSLOTS_IS_NOT_NULL(aobj)); jsval *slots = aobj->dslots; size_t len = ida.length(); JS_ASSERT(js_DenseArrayCapacity(aobj) >= len); @@ -2194,8 +2193,6 @@ InitScopeForObject(JSContext* cx, JSObject* obj, JSObject* proto, JSObjectOps* o scope = OBJ_SCOPE(proto)->getEmptyScope(cx, clasp); if (!scope) goto bad; - if (!DSLOTS_IS_NOT_NULL(obj)) - DSLOTS_BUMP_1(obj); } else { scope = JSScope::create(cx, ops, clasp, obj, js_GenerateShape(cx, false)); if (!scope) @@ -2262,8 +2259,7 @@ js_NewObjectWithGivenProto(JSContext *cx, JSClass *clasp, JSObject *proto, obj->init(clasp, proto, (!parent && proto) ? proto->getParent() : parent, - JSObject::defaultPrivate(clasp), - OPS_IS_NATIVE(ops) ? DSLOTS_NULL_INIT_OBJECT_NATIVE : DSLOTS_NULL_INIT_OBJECT_NONNATIVE); + JSObject::defaultPrivate(clasp)); if (OPS_IS_NATIVE(ops)) { if (!InitScopeForObject(cx, obj, proto, ops)) { @@ -2354,7 +2350,7 @@ NewNativeObject(JSContext* cx, JSClass* clasp, JSObject* proto, if (!obj) return NULL; - obj->init(clasp, proto, parent, privateSlotValue, DSLOTS_NULL_INIT_NATIVE); + obj->init(clasp, proto, parent, privateSlotValue); return InitScopeForObject(cx, obj, proto, &js_ObjectOps) ? obj : NULL; } @@ -2706,7 +2702,7 @@ js_CloneBlockObject(JSContext *cx, JSObject *proto, JSStackFrame *fp) JS_ASSERT(scope->freeslot == JSSLOT_BLOCK_DEPTH + 1); for (uint32 i = JSSLOT_BLOCK_DEPTH + 1; i < JS_INITIAL_NSLOTS; ++i) clone->fslots[i] = JSVAL_VOID; - clone->dslots = DSLOTS_NULL_CLONE_BLOCK_OBJECT; + clone->dslots = NULL; JS_ASSERT(OBJ_IS_CLONED_BLOCK(clone)); return clone; } @@ -3142,7 +3138,7 @@ bad: static bool AllocSlots(JSContext *cx, JSObject *obj, size_t nslots) { - JS_ASSERT(!DSLOTS_IS_NOT_NULL(obj)); + JS_ASSERT(!obj->dslots); JS_ASSERT(nslots > JS_INITIAL_NSLOTS); jsval* slots; @@ -3198,7 +3194,7 @@ js_GrowSlots(JSContext *cx, JSObject *obj, size_t nslots) * If nothing was allocated yet, treat it as initial allocation (but with * the exponential growth algorithm applied). */ - jsval* slots = DSLOTS_NORMALIZE(obj); + jsval* slots = obj->dslots; if (!slots) return AllocSlots(cx, obj, nslots); @@ -3219,7 +3215,7 @@ js_GrowSlots(JSContext *cx, JSObject *obj, size_t nslots) void js_ShrinkSlots(JSContext *cx, JSObject *obj, size_t nslots) { - jsval* slots = DSLOTS_NORMALIZE(obj); + jsval* slots = obj->dslots; /* Nothing to shrink? */ if (!slots) @@ -3230,7 +3226,7 @@ js_ShrinkSlots(JSContext *cx, JSObject *obj, size_t nslots) if (nslots <= JS_INITIAL_NSLOTS) { cx->free(slots - 1); - obj->dslots = DSLOTS_NULL_SHRINK_SLOTS; + obj->dslots = NULL; } else { size_t nwords = SLOTS_TO_DYNAMIC_WORDS(nslots); slots = (jsval*) cx->realloc(slots - 1, nwords * sizeof(jsval)); @@ -3243,7 +3239,7 @@ bool js_EnsureReservedSlots(JSContext *cx, JSObject *obj, size_t nreserved) { JS_ASSERT(OBJ_IS_NATIVE(obj)); - JS_ASSERT(!DSLOTS_IS_NOT_NULL(obj)); + JS_ASSERT(!obj->dslots); uintN nslots = JSSLOT_FREE(STOBJ_GET_CLASS(obj)) + nreserved; if (nslots > STOBJ_NSLOTS(obj) && !AllocSlots(cx, obj, nslots)) @@ -3299,8 +3295,7 @@ js_NewNativeObject(JSContext *cx, JSClass *clasp, JSObject *proto, return NULL; } obj->map = scope; - obj->init(clasp, proto, proto->getParent(), privateSlotValue, - DSLOTS_NULL_INIT_JSNATIVE); + obj->init(clasp, proto, proto->getParent(), privateSlotValue); return obj; } @@ -6024,7 +6019,7 @@ js_SetReservedSlot(JSContext *cx, JSObject *obj, uint32 index, jsval v) return false; uint32 slot = JSSLOT_START(clasp) + index; - if (slot >= JS_INITIAL_NSLOTS && !DSLOTS_IS_NOT_NULL(obj)) { + if (slot >= JS_INITIAL_NSLOTS && !obj->dslots) { /* * At this point, obj may or may not own scope, and we may or may not * need to allocate dslots. If scope is shared, scope->freeslot may not diff --git a/js/src/jsobj.h b/js/src/jsobj.h index 92f0bb9d33a..7bbdefe22ad 100644 --- a/js/src/jsobj.h +++ b/js/src/jsobj.h @@ -233,7 +233,7 @@ struct JSObject { /* The map field is not initialized here and should be set separately. */ void init(JSClass *clasp, JSObject *proto, JSObject *parent, - jsval privateSlotValue, jsval *nullPtr) { + jsval privateSlotValue) { JS_ASSERT(((jsuword) clasp & 3) == 0); JS_STATIC_ASSERT(JSSLOT_PRIVATE + 3 == JS_INITIAL_NSLOTS); JS_ASSERT_IF(clasp->flags & JSCLASS_HAS_PRIVATE, @@ -248,7 +248,7 @@ struct JSObject { fslots[JSSLOT_PRIVATE] = privateSlotValue; fslots[JSSLOT_PRIVATE + 1] = JSVAL_VOID; fslots[JSSLOT_PRIVATE + 2] = JSVAL_VOID; - dslots = nullPtr; + dslots = NULL; } JSBool lookupProperty(JSContext *cx, jsid id, @@ -349,7 +349,7 @@ struct JSObject { */ #define STOBJ_NSLOTS(obj) \ - (DSLOTS_IS_NOT_NULL(obj) ? (uint32)(obj)->dslots[-1] : (uint32)JS_INITIAL_NSLOTS) + ((obj)->dslots ? (uint32)(obj)->dslots[-1] : (uint32)JS_INITIAL_NSLOTS) inline jsval& STOBJ_GET_SLOT(JSObject *obj, uintN slot) @@ -663,7 +663,7 @@ js_ShrinkSlots(JSContext *cx, JSObject *obj, size_t nslots); static inline void js_FreeSlots(JSContext *cx, JSObject *obj) { - if (DSLOTS_IS_NOT_NULL(obj)) + if (obj->dslots) js_ShrinkSlots(cx, obj, 0); } diff --git a/js/src/jsops.cpp b/js/src/jsops.cpp index fe761515d58..06c6bb1ee61 100644 --- a/js/src/jsops.cpp +++ b/js/src/jsops.cpp @@ -1522,10 +1522,6 @@ BEGIN_CASE(JSOP_GETXPROP) } else if (PCVAL_IS_SLOT(entry->vword)) { slot = PCVAL_TO_SLOT(entry->vword); JS_ASSERT(slot < OBJ_SCOPE(obj2)->freeslot); - if (!DSLOTS_IS_NOT_NULL(obj2) && - OBJ_SHAPE(obj2) >= SHAPE_OVERFLOW_BIT) { - DSLOTS_BUMP_2(obj2); - } rval = LOCKED_OBJ_GET_SLOT(obj2, slot); } else { JS_ASSERT(PCVAL_IS_SPROP(entry->vword)); @@ -2862,7 +2858,7 @@ BEGIN_CASE(JSOP_CALLDSLOT) JS_ASSERT(fp->argv); obj = JSVAL_TO_OBJECT(fp->argv[-2]); JS_ASSERT(obj); - JS_ASSERT(DSLOTS_IS_NOT_NULL(obj)); + JS_ASSERT(obj->dslots); index = GET_UINT16(regs.pc); JS_ASSERT(JS_INITIAL_NSLOTS + index < jsatomid(obj->dslots[-1])); diff --git a/js/src/jsprvtd.h b/js/src/jsprvtd.h index 71c2edd5c79..8ce4784f155 100644 --- a/js/src/jsprvtd.h +++ b/js/src/jsprvtd.h @@ -370,24 +370,4 @@ extern JSBool js_CStringsAreUTF8; */ #define JS_ARGS_LENGTH_MAX (JS_BIT(24) - 1) -#define DSLOTS_NULL_SHIFT 8 -#define DSLOTS_NULL_RESIZE_SLOTS ((jsval*) (1 << DSLOTS_NULL_SHIFT)) -#define DSLOTS_NULL_ARRAY_FINALIZE ((jsval*) (2 << DSLOTS_NULL_SHIFT)) -#define DSLOTS_NULL_NEW_EMPTY_ARRAY ((jsval*) (3 << DSLOTS_NULL_SHIFT)) -#define DSLOTS_NULL_CLONE_BLOCK_OBJECT ((jsval*) (4 << DSLOTS_NULL_SHIFT)) -#define DSLOTS_NULL_SHRINK_SLOTS ((jsval*) (5 << DSLOTS_NULL_SHIFT)) - -#define DSLOTS_NULL_INIT_OBJECT_NATIVE ((jsval*) (6 << DSLOTS_NULL_SHIFT)) -#define DSLOTS_NULL_INIT_OBJECT_NONNATIVE ((jsval*) (7 << DSLOTS_NULL_SHIFT)) -#define DSLOTS_NULL_INIT_NATIVE ((jsval*) (8 << DSLOTS_NULL_SHIFT)) -#define DSLOTS_NULL_INIT_JSNATIVE ((jsval*) (9 << DSLOTS_NULL_SHIFT)) -#define DSLOTS_NULL_INIT_CLOSURE ((jsval*) (10 << DSLOTS_NULL_SHIFT)) - -#define DSLOTS_NULL_LIMIT (16 << DSLOTS_NULL_SHIFT) - -#define DSLOTS_IS_NOT_NULL(obj) (uintptr_t(obj->dslots) >= DSLOTS_NULL_LIMIT) -#define DSLOTS_NORMALIZE(obj) (DSLOTS_IS_NOT_NULL(obj) ? (obj)->dslots : NULL) -#define DSLOTS_BUMP_1(obj) (obj->dslots = (jsval*) (uintptr_t((obj)->dslots) | (1 << (DSLOTS_NULL_SHIFT-1)))) -#define DSLOTS_BUMP_2(obj) (obj->dslots = (jsval*) (uintptr_t((obj)->dslots) | (1 << (DSLOTS_NULL_SHIFT-2)))) - #endif /* jsprvtd_h___ */ diff --git a/js/src/jstracer.cpp b/js/src/jstracer.cpp index 86e4be37130..b8f8f872aab 100644 --- a/js/src/jstracer.cpp +++ b/js/src/jstracer.cpp @@ -280,7 +280,6 @@ js_InitJITStatsClass(JSContext *cx, JSObject *glob) #define INS_ATOM(atom) INS_CONSTSTR(ATOM_TO_STRING(atom)) #define INS_NULL() INS_CONSTPTR(NULL) #define INS_VOID() INS_CONST(JSVAL_TO_SPECIAL(JSVAL_VOID)) -#define INS_DSLOTSNULL(ins) lir->ins2(LIR_pult, (ins), INS_CONSTPTR((jsval*) DSLOTS_NULL_LIMIT)) static avmplus::AvmCore s_core = avmplus::AvmCore(); static avmplus::AvmCore* core = &s_core; @@ -12642,7 +12641,7 @@ TraceRecorder::denseArrayElement(jsval& oval, jsval& ival, jsval*& vp, LIns*& v_ NULL); /* If dslots is NULL, stay on trace (and read value as undefined). */ - LIns* br3 = lir->insBranch(LIR_jt, INS_DSLOTSNULL(dslots_ins), NULL); + LIns* br3 = lir->insBranch(LIR_jt, lir->ins_peq0(dslots_ins), NULL); /* If not idx < capacity, stay on trace (and read value as undefined). */ LIns* br4 = lir->insBranch(LIR_jf, @@ -12684,7 +12683,7 @@ TraceRecorder::denseArrayElement(jsval& oval, jsval& ival, jsval*& vp, LIns*& v_ /* dslots must not be NULL */ guard(false, - INS_DSLOTSNULL(dslots_ins), + lir->ins_peq0(dslots_ins), exit); /* Guard array capacity */