Bug 555631 - Convert STOBJ_* macros to inline functions. r=gal.

This commit is contained in:
Nicholas Nethercote
2010-03-30 14:42:48 -07:00
parent a5987adfdf
commit a10895039d
39 changed files with 281 additions and 270 deletions

View File

@@ -1923,7 +1923,7 @@ JS_PrintTraceThingInfo(char *buf, size_t bufsize, JSTracer *trc,
case JSTRACE_OBJECT: case JSTRACE_OBJECT:
{ {
JSObject *obj = (JSObject *)thing; JSObject *obj = (JSObject *)thing;
JSClass *clasp = STOBJ_GET_CLASS(obj); JSClass *clasp = obj->getClass();
name = clasp->name; name = clasp->name;
#ifdef HAVE_XPCONNECT #ifdef HAVE_XPCONNECT
@@ -1975,7 +1975,7 @@ JS_PrintTraceThingInfo(char *buf, size_t bufsize, JSTracer *trc,
case JSTRACE_OBJECT: case JSTRACE_OBJECT:
{ {
JSObject *obj = (JSObject *)thing; JSObject *obj = (JSObject *)thing;
JSClass *clasp = STOBJ_GET_CLASS(obj); JSClass *clasp = obj->getClass();
if (clasp == &js_FunctionClass) { if (clasp == &js_FunctionClass) {
JSFunction *fun = GET_FUNCTION_PRIVATE(trc->context, obj); JSFunction *fun = GET_FUNCTION_PRIVATE(trc->context, obj);
if (!fun) { if (!fun) {
@@ -2817,7 +2817,7 @@ JS_SealObject(JSContext *cx, JSObject *obj, JSBool deep)
/* Walk slots in obj and if any value is a non-null object, seal it. */ /* Walk slots in obj and if any value is a non-null object, seal it. */
nslots = scope->freeslot; nslots = scope->freeslot;
for (i = 0; i != nslots; ++i) { for (i = 0; i != nslots; ++i) {
v = STOBJ_GET_SLOT(obj, i); v = obj->getSlot(i);
if (i == JSSLOT_PRIVATE && (obj->getClass()->flags & JSCLASS_HAS_PRIVATE)) if (i == JSSLOT_PRIVATE && (obj->getClass()->flags & JSCLASS_HAS_PRIVATE))
continue; continue;
if (JSVAL_IS_PRIMITIVE(v)) if (JSVAL_IS_PRIMITIVE(v))
@@ -4027,7 +4027,7 @@ JS_NextProperty(JSContext *cx, JSObject *iterobj, jsid *idp)
*idp = JSVAL_VOID; *idp = JSVAL_VOID;
} else { } else {
*idp = ida->vector[--i]; *idp = ida->vector[--i];
STOBJ_SET_SLOT(iterobj, JSSLOT_ITER_INDEX, INT_TO_JSVAL(i)); iterobj->setSlot(JSSLOT_ITER_INDEX, INT_TO_JSVAL(i));
} }
} }
return JS_TRUE; return JS_TRUE;

View File

@@ -1312,10 +1312,10 @@ js_MakeArraySlow(JSContext *cx, JSObject *obj)
uint32 capacity = js_DenseArrayCapacity(obj); uint32 capacity = js_DenseArrayCapacity(obj);
if (capacity) { if (capacity) {
scope->freeslot = STOBJ_NSLOTS(obj) + JS_INITIAL_NSLOTS; scope->freeslot = obj->numSlots() + JS_INITIAL_NSLOTS;
obj->dslots[-1] = JS_INITIAL_NSLOTS + capacity; obj->dslots[-1] = JS_INITIAL_NSLOTS + capacity;
} else { } else {
scope->freeslot = STOBJ_NSLOTS(obj); scope->freeslot = obj->numSlots();
} }
/* Create new properties pointing to existing values in dslots */ /* Create new properties pointing to existing values in dslots */

View File

@@ -218,8 +218,8 @@ js_AddProperty(JSContext* cx, JSObject* obj, JSScopeProperty* sprop)
} }
if (!scope->table) { if (!scope->table) {
if (slot < STOBJ_NSLOTS(obj) && !OBJ_GET_CLASS(cx, obj)->reserveSlots) { if (slot < obj->numSlots() && !OBJ_GET_CLASS(cx, obj)->reserveSlots) {
JS_ASSERT(JSVAL_IS_VOID(STOBJ_GET_SLOT(obj, scope->freeslot))); JS_ASSERT(JSVAL_IS_VOID(obj->getSlot(scope->freeslot)));
++scope->freeslot; ++scope->freeslot;
} else { } else {
if (!js_AllocSlot(cx, obj, &slot)) if (!js_AllocSlot(cx, obj, &slot))

View File

@@ -64,6 +64,7 @@
#include "jsstr.h" #include "jsstr.h"
#include "jsatominlines.h" #include "jsatominlines.h"
#include "jsobjinlines.h"
#include "jsscopeinlines.h" #include "jsscopeinlines.h"
#include "jsautooplen.h" #include "jsautooplen.h"
@@ -630,7 +631,7 @@ js_watch_set(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
/* NB: wp is held, so we can safely dereference it still. */ /* NB: wp is held, so we can safely dereference it still. */
ok = wp->handler(cx, obj, propid, ok = wp->handler(cx, obj, propid,
SPROP_HAS_VALID_SLOT(sprop, scope) SPROP_HAS_VALID_SLOT(sprop, scope)
? OBJ_GET_SLOT(cx, obj, sprop->slot) ? obj->lockAndGetSlot(cx, sprop->slot)
: JSVAL_VOID, : JSVAL_VOID,
vp, wp->closure); vp, wp->closure);
if (ok) { if (ok) {

View File

@@ -204,7 +204,7 @@ UpdateDepth(JSContext *cx, JSCodeGenerator *cg, ptrdiff_t target)
JS_ASSERT(op == JSOP_ENTERBLOCK); JS_ASSERT(op == JSOP_ENTERBLOCK);
JS_ASSERT(nuses == 0); JS_ASSERT(nuses == 0);
blockObj = cg->objectList.lastbox->object; blockObj = cg->objectList.lastbox->object;
JS_ASSERT(STOBJ_GET_CLASS(blockObj) == &js_BlockClass); JS_ASSERT(blockObj->getClass() == &js_BlockClass);
JS_ASSERT(JSVAL_IS_VOID(blockObj->fslots[JSSLOT_BLOCK_DEPTH])); JS_ASSERT(JSVAL_IS_VOID(blockObj->fslots[JSSLOT_BLOCK_DEPTH]));
OBJ_SET_BLOCK_DEPTH(cx, blockObj, cg->stackDepth); OBJ_SET_BLOCK_DEPTH(cx, blockObj, cg->stackDepth);
@@ -1859,7 +1859,7 @@ EmitEnterBlock(JSContext *cx, JSParseNode *pn, JSCodeGenerator *cg)
for (uintN slot = JSSLOT_FREE(&js_BlockClass), for (uintN slot = JSSLOT_FREE(&js_BlockClass),
limit = slot + OBJ_BLOCK_COUNT(cx, blockObj); limit = slot + OBJ_BLOCK_COUNT(cx, blockObj);
slot < limit; slot++) { slot < limit; slot++) {
jsval v = STOBJ_GET_SLOT(blockObj, slot); jsval v = blockObj->getSlot(slot);
/* Beware the empty destructuring dummy. */ /* Beware the empty destructuring dummy. */
if (JSVAL_IS_VOID(v)) { if (JSVAL_IS_VOID(v)) {

View File

@@ -80,6 +80,7 @@
#endif #endif
#include "jsatominlines.h" #include "jsatominlines.h"
#include "jsobjinlines.h"
using namespace js; using namespace js;
@@ -743,8 +744,8 @@ JSClass js_DeclEnvClass = {
static JSBool static JSBool
CheckForEscapingClosure(JSContext *cx, JSObject *obj, jsval *vp) CheckForEscapingClosure(JSContext *cx, JSObject *obj, jsval *vp)
{ {
JS_ASSERT(STOBJ_GET_CLASS(obj) == &js_CallClass || JS_ASSERT(obj->getClass() == &js_CallClass ||
STOBJ_GET_CLASS(obj) == &js_DeclEnvClass); obj->getClass() == &js_DeclEnvClass);
jsval v = *vp; jsval v = *vp;
@@ -846,7 +847,7 @@ js_GetCallObject(JSContext *cx, JSStackFrame *fp)
callobj->setPrivate(fp); callobj->setPrivate(fp);
JS_ASSERT(fp->argv); JS_ASSERT(fp->argv);
JS_ASSERT(fp->fun == GET_FUNCTION_PRIVATE(cx, fp->calleeObject())); JS_ASSERT(fp->fun == GET_FUNCTION_PRIVATE(cx, fp->calleeObject()));
STOBJ_SET_SLOT(callobj, JSSLOT_CALLEE, fp->calleeValue()); callobj->setSlot(JSSLOT_CALLEE, fp->calleeValue());
fp->callobj = callobj; fp->callobj = callobj;
/* /*
@@ -864,7 +865,7 @@ js_CreateCallObjectOnTrace(JSContext *cx, JSFunction *fun, JSObject *callee, JSO
JSObject *callobj = NewCallObject(cx, fun, scopeChain); JSObject *callobj = NewCallObject(cx, fun, scopeChain);
if (!callobj) if (!callobj)
return NULL; return NULL;
STOBJ_SET_SLOT(callobj, JSSLOT_CALLEE, OBJECT_TO_JSVAL(callee)); callobj->setSlot(JSSLOT_CALLEE, OBJECT_TO_JSVAL(callee));
return callobj; return callobj;
} }
@@ -876,8 +877,8 @@ js_GetCallObjectFunction(JSObject *obj)
{ {
jsval v; jsval v;
JS_ASSERT(STOBJ_GET_CLASS(obj) == &js_CallClass); JS_ASSERT(obj->getClass() == &js_CallClass);
v = STOBJ_GET_SLOT(obj, JSSLOT_CALLEE); v = obj->getSlot(JSSLOT_CALLEE);
if (JSVAL_IS_VOID(v)) { if (JSVAL_IS_VOID(v)) {
/* Newborn or prototype object. */ /* Newborn or prototype object. */
return NULL; return NULL;
@@ -902,7 +903,7 @@ js_PutCallObject(JSContext *cx, JSStackFrame *fp)
/* Get the arguments object to snapshot fp's actual argument values. */ /* Get the arguments object to snapshot fp's actual argument values. */
if (fp->argsobj) { if (fp->argsobj) {
if (!(fp->flags & JSFRAME_OVERRIDE_ARGS)) if (!(fp->flags & JSFRAME_OVERRIDE_ARGS))
STOBJ_SET_SLOT(callobj, JSSLOT_CALL_ARGUMENTS, fp->argsobj); callobj->setSlot(JSSLOT_CALL_ARGUMENTS, fp->argsobj);
js_PutArgsObject(cx, fp); js_PutArgsObject(cx, fp);
} }
@@ -917,7 +918,7 @@ js_PutCallObject(JSContext *cx, JSStackFrame *fp)
JS_STATIC_ASSERT(JS_INITIAL_NSLOTS - JSSLOT_PRIVATE == JS_STATIC_ASSERT(JS_INITIAL_NSLOTS - JSSLOT_PRIVATE ==
1 + CALL_CLASS_FIXED_RESERVED_SLOTS); 1 + CALL_CLASS_FIXED_RESERVED_SLOTS);
if (n != 0) { if (n != 0) {
JS_ASSERT(STOBJ_NSLOTS(callobj) >= JS_INITIAL_NSLOTS + n); JS_ASSERT(callobj->numSlots() >= JS_INITIAL_NSLOTS + n);
n += JS_INITIAL_NSLOTS; n += JS_INITIAL_NSLOTS;
CopyValuesToCallObject(callobj, fun->nargs, fp->argv, fun->u.i.nvars, fp->slots); CopyValuesToCallObject(callobj, fun->nargs, fp->argv, fun->u.i.nvars, fp->slots);
} }
@@ -926,7 +927,7 @@ js_PutCallObject(JSContext *cx, JSStackFrame *fp)
if (js_IsNamedLambda(fun)) { if (js_IsNamedLambda(fun)) {
JSObject *env = callobj->getParent(); JSObject *env = callobj->getParent();
JS_ASSERT(STOBJ_GET_CLASS(env) == &js_DeclEnvClass); JS_ASSERT(env->getClass() == &js_DeclEnvClass);
JS_ASSERT(env->getPrivate() == fp); JS_ASSERT(env->getPrivate() == fp);
env->setPrivate(NULL); env->setPrivate(NULL);
} }
@@ -1028,7 +1029,7 @@ CallPropertyOp(JSContext *cx, JSObject *obj, jsid id, jsval *vp,
jsval *array; jsval *array;
if (kind == JSCPK_UPVAR) { if (kind == JSCPK_UPVAR) {
JSObject *callee = JSVAL_TO_OBJECT(STOBJ_GET_SLOT(obj, JSSLOT_CALLEE)); JSObject *callee = JSVAL_TO_OBJECT(obj->getSlot(JSSLOT_CALLEE));
#ifdef DEBUG #ifdef DEBUG
JSFunction *callee_fun = (JSFunction *) callee->getPrivate(); JSFunction *callee_fun = (JSFunction *) callee->getPrivate();
@@ -1048,7 +1049,7 @@ CallPropertyOp(JSContext *cx, JSObject *obj, jsid id, jsval *vp,
if (setter) { if (setter) {
if (fp) if (fp)
fp->flags |= JSFRAME_OVERRIDE_ARGS; fp->flags |= JSFRAME_OVERRIDE_ARGS;
STOBJ_SET_SLOT(obj, JSSLOT_CALL_ARGUMENTS, *vp); obj->setSlot(JSSLOT_CALL_ARGUMENTS, *vp);
} else { } else {
if (fp && !(fp->flags & JSFRAME_OVERRIDE_ARGS)) { if (fp && !(fp->flags & JSFRAME_OVERRIDE_ARGS)) {
JSObject *argsobj; JSObject *argsobj;
@@ -1058,7 +1059,7 @@ CallPropertyOp(JSContext *cx, JSObject *obj, jsid id, jsval *vp,
return false; return false;
*vp = OBJECT_TO_JSVAL(argsobj); *vp = OBJECT_TO_JSVAL(argsobj);
} else { } else {
*vp = STOBJ_GET_SLOT(obj, JSSLOT_CALL_ARGUMENTS); *vp = obj->getSlot(JSSLOT_CALL_ARGUMENTS);
} }
} }
return true; return true;
@@ -1177,13 +1178,13 @@ call_resolve(JSContext *cx, JSObject *obj, jsval idval, uintN flags,
JSPropertyOp getter, setter; JSPropertyOp getter, setter;
uintN slot, attrs; uintN slot, attrs;
JS_ASSERT(STOBJ_GET_CLASS(obj) == &js_CallClass); JS_ASSERT(obj->getClass() == &js_CallClass);
JS_ASSERT(!obj->getProto()); JS_ASSERT(!obj->getProto());
if (!JSVAL_IS_STRING(idval)) if (!JSVAL_IS_STRING(idval))
return JS_TRUE; return JS_TRUE;
callee = STOBJ_GET_SLOT(obj, JSSLOT_CALLEE); callee = obj->getSlot(JSSLOT_CALLEE);
if (JSVAL_IS_VOID(callee)) if (JSVAL_IS_VOID(callee))
return JS_TRUE; return JS_TRUE;
fun = GET_FUNCTION_PRIVATE(cx, JSVAL_TO_OBJECT(callee)); fun = GET_FUNCTION_PRIVATE(cx, JSVAL_TO_OBJECT(callee));

View File

@@ -2508,7 +2508,7 @@ ProcessSetSlotRequest(JSContext *cx, JSSetSlotRequest *ssr)
ssr->cycle = true; ssr->cycle = true;
return; return;
} }
pobj = JSVAL_TO_OBJECT(STOBJ_GET_SLOT(pobj, slot)); pobj = JSVAL_TO_OBJECT(pobj->getSlot(slot));
} }
pobj = ssr->pobj; pobj = ssr->pobj;

View File

@@ -561,7 +561,7 @@ NoSuchMethod(JSContext *cx, uintN argc, jsval *vp, uint32 flags)
JS_ASSERT(!JSVAL_IS_PRIMITIVE(vp[0])); JS_ASSERT(!JSVAL_IS_PRIMITIVE(vp[0]));
JS_ASSERT(!JSVAL_IS_PRIMITIVE(vp[1])); JS_ASSERT(!JSVAL_IS_PRIMITIVE(vp[1]));
obj = JSVAL_TO_OBJECT(vp[0]); obj = JSVAL_TO_OBJECT(vp[0]);
JS_ASSERT(STOBJ_GET_CLASS(obj) == &js_NoSuchMethodClass); JS_ASSERT(obj->getClass() == &js_NoSuchMethodClass);
invokevp[0] = obj->fslots[JSSLOT_FOUND_FUNCTION]; invokevp[0] = obj->fslots[JSSLOT_FOUND_FUNCTION];
invokevp[1] = vp[1]; invokevp[1] = vp[1];

View File

@@ -93,10 +93,10 @@ js_CloseNativeIterator(JSContext *cx, JSObject *iterobj)
jsval state; jsval state;
JSObject *iterable; JSObject *iterable;
JS_ASSERT(STOBJ_GET_CLASS(iterobj) == &js_IteratorClass); JS_ASSERT(iterobj->getClass() == &js_IteratorClass);
/* Avoid double work if js_CloseNativeIterator was called on obj. */ /* Avoid double work if js_CloseNativeIterator was called on obj. */
state = STOBJ_GET_SLOT(iterobj, JSSLOT_ITER_STATE); state = iterobj->getSlot(JSSLOT_ITER_STATE);
if (JSVAL_IS_NULL(state)) if (JSVAL_IS_NULL(state))
return; return;
@@ -104,7 +104,7 @@ js_CloseNativeIterator(JSContext *cx, JSObject *iterobj)
iterable = iterobj->getParent(); iterable = iterobj->getParent();
if (iterable) { if (iterable) {
#if JS_HAS_XML_SUPPORT #if JS_HAS_XML_SUPPORT
uintN flags = JSVAL_TO_INT(STOBJ_GET_SLOT(iterobj, JSSLOT_ITER_FLAGS)); uintN flags = JSVAL_TO_INT(iterobj->getSlot(JSSLOT_ITER_FLAGS));
if ((flags & JSITER_FOREACH) && OBJECT_IS_XML(cx, iterable)) { if ((flags & JSITER_FOREACH) && OBJECT_IS_XML(cx, iterable)) {
js_EnumerateXMLValues(cx, iterable, JSENUMERATE_DESTROY, &state, js_EnumerateXMLValues(cx, iterable, JSENUMERATE_DESTROY, &state,
NULL, NULL); NULL, NULL);
@@ -112,7 +112,7 @@ js_CloseNativeIterator(JSContext *cx, JSObject *iterobj)
#endif #endif
iterable->enumerate(cx, JSENUMERATE_DESTROY, &state, NULL); iterable->enumerate(cx, JSENUMERATE_DESTROY, &state, NULL);
} }
STOBJ_SET_SLOT(iterobj, JSSLOT_ITER_STATE, JSVAL_NULL); iterobj->setSlot(JSSLOT_ITER_STATE, JSVAL_NULL);
} }
static void static void
@@ -150,12 +150,12 @@ InitNativeIterator(JSContext *cx, JSObject *iterobj, JSObject *obj, uintN flags)
jsval state; jsval state;
JSBool ok; JSBool ok;
JS_ASSERT(STOBJ_GET_CLASS(iterobj) == &js_IteratorClass); JS_ASSERT(iterobj->getClass() == &js_IteratorClass);
/* Initialize iterobj in case of enumerate hook failure. */ /* Initialize iterobj in case of enumerate hook failure. */
iterobj->setParent(obj); iterobj->setParent(obj);
STOBJ_SET_SLOT(iterobj, JSSLOT_ITER_STATE, JSVAL_NULL); iterobj->setSlot(JSSLOT_ITER_STATE, JSVAL_NULL);
STOBJ_SET_SLOT(iterobj, JSSLOT_ITER_FLAGS, INT_TO_JSVAL(flags)); iterobj->setSlot(JSSLOT_ITER_FLAGS, INT_TO_JSVAL(flags));
if (!js_RegisterCloseableIterator(cx, iterobj)) if (!js_RegisterCloseableIterator(cx, iterobj))
return JS_FALSE; return JS_FALSE;
if (!obj) if (!obj)
@@ -171,7 +171,7 @@ InitNativeIterator(JSContext *cx, JSObject *iterobj, JSObject *obj, uintN flags)
if (!ok) if (!ok)
return JS_FALSE; return JS_FALSE;
STOBJ_SET_SLOT(iterobj, JSSLOT_ITER_STATE, state); iterobj->setSlot(JSSLOT_ITER_STATE, state);
if (flags & JSITER_ENUMERATE) { if (flags & JSITER_ENUMERATE) {
/* /*
* The enumerating iterator needs the original object to suppress * The enumerating iterator needs the original object to suppress
@@ -236,11 +236,11 @@ IteratorNextImpl(JSContext *cx, JSObject *obj, jsval *rval)
iterable = obj->getParent(); iterable = obj->getParent();
JS_ASSERT(iterable); JS_ASSERT(iterable);
state = STOBJ_GET_SLOT(obj, JSSLOT_ITER_STATE); state = obj->getSlot(JSSLOT_ITER_STATE);
if (JSVAL_IS_NULL(state)) if (JSVAL_IS_NULL(state))
goto stop; goto stop;
flags = JSVAL_TO_INT(STOBJ_GET_SLOT(obj, JSSLOT_ITER_FLAGS)); flags = JSVAL_TO_INT(obj->getSlot(JSSLOT_ITER_FLAGS));
JS_ASSERT(!(flags & JSITER_ENUMERATE)); JS_ASSERT(!(flags & JSITER_ENUMERATE));
foreach = (flags & JSITER_FOREACH) != 0; foreach = (flags & JSITER_FOREACH) != 0;
ok = ok =
@@ -254,7 +254,7 @@ IteratorNextImpl(JSContext *cx, JSObject *obj, jsval *rval)
if (!ok) if (!ok)
return JS_FALSE; return JS_FALSE;
STOBJ_SET_SLOT(obj, JSSLOT_ITER_STATE, state); obj->setSlot(JSSLOT_ITER_STATE, state);
if (JSVAL_IS_NULL(state)) if (JSVAL_IS_NULL(state))
goto stop; goto stop;
@@ -273,7 +273,7 @@ IteratorNextImpl(JSContext *cx, JSObject *obj, jsval *rval)
return JS_TRUE; return JS_TRUE;
stop: stop:
JS_ASSERT(STOBJ_GET_SLOT(obj, JSSLOT_ITER_STATE) == JSVAL_NULL); JS_ASSERT(obj->getSlot(JSSLOT_ITER_STATE) == JSVAL_NULL);
*rval = JSVAL_HOLE; *rval = JSVAL_HOLE;
return JS_TRUE; return JS_TRUE;
} }
@@ -329,7 +329,7 @@ js_GetNativeIteratorFlags(JSContext *cx, JSObject *iterobj)
{ {
if (OBJ_GET_CLASS(cx, iterobj) != &js_IteratorClass) if (OBJ_GET_CLASS(cx, iterobj) != &js_IteratorClass)
return 0; return 0;
return JSVAL_TO_INT(STOBJ_GET_SLOT(iterobj, JSSLOT_ITER_FLAGS)); return JSVAL_TO_INT(iterobj->getSlot(JSSLOT_ITER_FLAGS));
} }
/* /*
@@ -465,7 +465,7 @@ CallEnumeratorNext(JSContext *cx, JSObject *iterobj, uintN flags, jsval *rval)
obj = iterobj->getParent(); obj = iterobj->getParent();
origobj = iterobj->getProto(); origobj = iterobj->getProto();
state = STOBJ_GET_SLOT(iterobj, JSSLOT_ITER_STATE); state = iterobj->getSlot(JSSLOT_ITER_STATE);
if (JSVAL_IS_NULL(state)) if (JSVAL_IS_NULL(state))
goto stop; goto stop;
@@ -485,7 +485,7 @@ CallEnumeratorNext(JSContext *cx, JSObject *iterobj, uintN flags, jsval *rval)
if (!obj->enumerate(cx, JSENUMERATE_NEXT, &state, &id)) if (!obj->enumerate(cx, JSENUMERATE_NEXT, &state, &id))
return JS_FALSE; return JS_FALSE;
} }
STOBJ_SET_SLOT(iterobj, JSSLOT_ITER_STATE, state); iterobj->setSlot(JSSLOT_ITER_STATE, state);
if (JSVAL_IS_NULL(state)) if (JSVAL_IS_NULL(state))
goto stop; goto stop;
} else } else
@@ -495,7 +495,7 @@ CallEnumeratorNext(JSContext *cx, JSObject *iterobj, uintN flags, jsval *rval)
if (!obj->enumerate(cx, JSENUMERATE_NEXT, &state, &id)) if (!obj->enumerate(cx, JSENUMERATE_NEXT, &state, &id))
return JS_FALSE; return JS_FALSE;
STOBJ_SET_SLOT(iterobj, JSSLOT_ITER_STATE, state); iterobj->setSlot(JSSLOT_ITER_STATE, state);
if (JSVAL_IS_NULL(state)) { if (JSVAL_IS_NULL(state)) {
#if JS_HAS_XML_SUPPORT #if JS_HAS_XML_SUPPORT
if (OBJECT_IS_XML(cx, obj)) { if (OBJECT_IS_XML(cx, obj)) {
@@ -515,7 +515,7 @@ CallEnumeratorNext(JSContext *cx, JSObject *iterobj, uintN flags, jsval *rval)
iterobj->setParent(obj); iterobj->setParent(obj);
if (!obj->enumerate(cx, JSENUMERATE_INIT, &state, NULL)) if (!obj->enumerate(cx, JSENUMERATE_INIT, &state, NULL))
return JS_FALSE; return JS_FALSE;
STOBJ_SET_SLOT(iterobj, JSSLOT_ITER_STATE, state); iterobj->setSlot(JSSLOT_ITER_STATE, state);
if (!JSVAL_IS_NULL(state)) if (!JSVAL_IS_NULL(state))
goto restart; goto restart;
} }
@@ -571,7 +571,7 @@ CallEnumeratorNext(JSContext *cx, JSObject *iterobj, uintN flags, jsval *rval)
return JS_TRUE; return JS_TRUE;
stop: stop:
JS_ASSERT(STOBJ_GET_SLOT(iterobj, JSSLOT_ITER_STATE) == JSVAL_NULL); JS_ASSERT(iterobj->getSlot(JSSLOT_ITER_STATE) == JSVAL_NULL);
*rval = JSVAL_HOLE; *rval = JSVAL_HOLE;
return JS_TRUE; return JS_TRUE;
} }
@@ -583,7 +583,7 @@ js_CallIteratorNext(JSContext *cx, JSObject *iterobj, jsval *rval)
/* Fast path for native iterators */ /* Fast path for native iterators */
if (OBJ_GET_CLASS(cx, iterobj) == &js_IteratorClass) { if (OBJ_GET_CLASS(cx, iterobj) == &js_IteratorClass) {
flags = JSVAL_TO_INT(STOBJ_GET_SLOT(iterobj, JSSLOT_ITER_FLAGS)); flags = JSVAL_TO_INT(iterobj->getSlot(JSSLOT_ITER_FLAGS));
if (flags & JSITER_ENUMERATE) if (flags & JSITER_ENUMERATE)
return CallEnumeratorNext(cx, iterobj, flags, rval); return CallEnumeratorNext(cx, iterobj, flags, rval);
@@ -882,7 +882,7 @@ SendToGenerator(JSContext *cx, JSGeneratorOp op, JSObject *obj,
static JS_REQUIRES_STACK JSBool static JS_REQUIRES_STACK JSBool
CloseGenerator(JSContext *cx, JSObject *obj) CloseGenerator(JSContext *cx, JSObject *obj)
{ {
JS_ASSERT(STOBJ_GET_CLASS(obj) == &js_GeneratorClass); JS_ASSERT(obj->getClass() == &js_GeneratorClass);
JSGenerator *gen = (JSGenerator *) obj->getPrivate(); JSGenerator *gen = (JSGenerator *) obj->getPrivate();
if (!gen) { if (!gen) {
@@ -1010,8 +1010,8 @@ js_InitIteratorClasses(JSContext *cx, JSObject *obj)
NULL, iterator_methods, NULL, NULL); NULL, iterator_methods, NULL, NULL);
if (!proto) if (!proto)
return NULL; return NULL;
STOBJ_SET_SLOT(proto, JSSLOT_ITER_STATE, JSVAL_NULL); proto->setSlot(JSSLOT_ITER_STATE, JSVAL_NULL);
STOBJ_SET_SLOT(proto, JSSLOT_ITER_FLAGS, JSVAL_ZERO); proto->setSlot(JSSLOT_ITER_FLAGS, JSVAL_ZERO);
#if JS_HAS_GENERATORS #if JS_HAS_GENERATORS
/* Initialize the generator internals if configured. */ /* Initialize the generator internals if configured. */

View File

@@ -130,7 +130,7 @@ static inline bool
js_ValueIsStopIteration(jsval v) js_ValueIsStopIteration(jsval v)
{ {
return !JSVAL_IS_PRIMITIVE(v) && return !JSVAL_IS_PRIMITIVE(v) &&
STOBJ_GET_CLASS(JSVAL_TO_OBJECT(v)) == &js_StopIterationClass; JSVAL_TO_OBJECT(v)->getClass() == &js_StopIterationClass;
} }
extern JSObject * extern JSObject *

View File

@@ -487,7 +487,7 @@ FinishSharingTitle(JSContext *cx, JSTitle *title)
uint32 nslots = scope->freeslot; uint32 nslots = scope->freeslot;
JS_ASSERT(nslots >= JSSLOT_START(obj->getClass())); JS_ASSERT(nslots >= JSSLOT_START(obj->getClass()));
for (uint32 i = JSSLOT_START(obj->getClass()); i != nslots; ++i) { for (uint32 i = JSSLOT_START(obj->getClass()); i != nslots; ++i) {
jsval v = STOBJ_GET_SLOT(obj, i); jsval v = obj->getSlot(i);
if (JSVAL_IS_STRING(v) && if (JSVAL_IS_STRING(v) &&
!js_MakeStringImmutable(cx, JSVAL_TO_STRING(v))) { !js_MakeStringImmutable(cx, JSVAL_TO_STRING(v))) {
/* /*
@@ -496,7 +496,7 @@ FinishSharingTitle(JSContext *cx, JSTitle *title)
* ignoring errors except out-of-memory, which should have been * ignoring errors except out-of-memory, which should have been
* reported through JS_ReportOutOfMemory at this point. * reported through JS_ReportOutOfMemory at this point.
*/ */
STOBJ_SET_SLOT(obj, i, JSVAL_VOID); obj->setSlot(i, JSVAL_VOID);
} }
} }
} }
@@ -707,7 +707,7 @@ js_GetSlotThreadSafe(JSContext *cx, JSObject *obj, uint32 slot)
if (CX_THREAD_IS_RUNNING_GC(cx) || if (CX_THREAD_IS_RUNNING_GC(cx) ||
scope->sealed() || scope->sealed() ||
(title->ownercx && ClaimTitle(title, cx))) { (title->ownercx && ClaimTitle(title, cx))) {
return STOBJ_GET_SLOT(obj, slot); return obj->getSlot(slot);
} }
#ifndef NSPR_LOCK #ifndef NSPR_LOCK
@@ -722,7 +722,7 @@ js_GetSlotThreadSafe(JSContext *cx, JSObject *obj, uint32 slot)
* lock release followed by fat lock acquisition. * lock release followed by fat lock acquisition.
*/ */
if (scope == OBJ_SCOPE(obj)) { if (scope == OBJ_SCOPE(obj)) {
v = STOBJ_GET_SLOT(obj, slot); v = obj->getSlot(slot);
if (!NativeCompareAndSwap(&tl->owner, me, 0)) { if (!NativeCompareAndSwap(&tl->owner, me, 0)) {
/* Assert that scope locks never revert to flyweight. */ /* Assert that scope locks never revert to flyweight. */
JS_ASSERT(title->ownercx != cx); JS_ASSERT(title->ownercx != cx);
@@ -736,12 +736,12 @@ js_GetSlotThreadSafe(JSContext *cx, JSObject *obj, uint32 slot)
js_Dequeue(tl); js_Dequeue(tl);
} }
else if (Thin_RemoveWait(ReadWord(tl->owner)) == me) { else if (Thin_RemoveWait(ReadWord(tl->owner)) == me) {
return STOBJ_GET_SLOT(obj, slot); return obj->getSlot(slot);
} }
#endif #endif
js_LockObj(cx, obj); js_LockObj(cx, obj);
v = STOBJ_GET_SLOT(obj, slot); v = obj->getSlot(slot);
/* /*
* Test whether cx took ownership of obj's scope during js_LockObj. * Test whether cx took ownership of obj's scope during js_LockObj.

View File

@@ -3046,7 +3046,7 @@ js_NewInstance(JSContext *cx, JSClass *clasp, JSObject *ctor)
} }
JSScopeProperty *sprop = scope->lookup(ATOM_TO_JSID(atom)); JSScopeProperty *sprop = scope->lookup(ATOM_TO_JSID(atom));
jsval pval = sprop ? STOBJ_GET_SLOT(ctor, sprop->slot) : JSVAL_HOLE; jsval pval = sprop ? ctor->getSlot(sprop->slot) : JSVAL_HOLE;
JSObject *proto; JSObject *proto;
if (!JSVAL_IS_PRIMITIVE(pval)) { if (!JSVAL_IS_PRIMITIVE(pval)) {
@@ -3352,7 +3352,7 @@ JSObject *
js_CloneBlockObject(JSContext *cx, JSObject *proto, JSStackFrame *fp) js_CloneBlockObject(JSContext *cx, JSObject *proto, JSStackFrame *fp)
{ {
JS_ASSERT(!OBJ_IS_CLONED_BLOCK(proto)); JS_ASSERT(!OBJ_IS_CLONED_BLOCK(proto));
JS_ASSERT(STOBJ_GET_CLASS(proto) == &js_BlockClass); JS_ASSERT(proto->getClass() == &js_BlockClass);
JSObject *clone = js_NewGCObject(cx); JSObject *clone = js_NewGCObject(cx);
if (!clone) if (!clone)
@@ -3394,7 +3394,7 @@ js_PutBlockObject(JSContext *cx, JSBool normalUnwind)
JS_ASSERT(OBJ_SCOPE(obj)->object != obj); JS_ASSERT(OBJ_SCOPE(obj)->object != obj);
/* Block objects should not have reserved slots before they are put. */ /* Block objects should not have reserved slots before they are put. */
JS_ASSERT(STOBJ_NSLOTS(obj) == JS_INITIAL_NSLOTS); JS_ASSERT(obj->numSlots() == JS_INITIAL_NSLOTS);
/* The block and its locals must be on the current stack for GC safety. */ /* The block and its locals must be on the current stack for GC safety. */
depth = OBJ_BLOCK_DEPTH(cx, obj); depth = OBJ_BLOCK_DEPTH(cx, obj);
@@ -3447,8 +3447,8 @@ block_getProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
/* Values are in reserved slots immediately following DEPTH. */ /* Values are in reserved slots immediately following DEPTH. */
uint32 slot = JSSLOT_BLOCK_DEPTH + 1 + index; uint32 slot = JSSLOT_BLOCK_DEPTH + 1 + index;
JS_LOCK_OBJ(cx, obj); JS_LOCK_OBJ(cx, obj);
JS_ASSERT(slot < STOBJ_NSLOTS(obj)); JS_ASSERT(slot < obj->numSlots());
*vp = STOBJ_GET_SLOT(obj, slot); *vp = obj->getSlot(slot);
JS_UNLOCK_OBJ(cx, obj); JS_UNLOCK_OBJ(cx, obj);
return true; return true;
} }
@@ -3472,8 +3472,8 @@ block_setProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
/* Values are in reserved slots immediately following DEPTH. */ /* Values are in reserved slots immediately following DEPTH. */
uint32 slot = JSSLOT_BLOCK_DEPTH + 1 + index; uint32 slot = JSSLOT_BLOCK_DEPTH + 1 + index;
JS_LOCK_OBJ(cx, obj); JS_LOCK_OBJ(cx, obj);
JS_ASSERT(slot < STOBJ_NSLOTS(obj)); JS_ASSERT(slot < obj->numSlots());
STOBJ_SET_SLOT(obj, slot, *vp); obj->setSlot(slot, *vp);
JS_UNLOCK_OBJ(cx, obj); JS_UNLOCK_OBJ(cx, obj);
return true; return true;
} }
@@ -3575,7 +3575,7 @@ js_XDRBlockObject(JSXDRState *xdr, JSObject **objp)
if (xdr->mode == JSXDR_DECODE) { if (xdr->mode == JSXDR_DECODE) {
depth = (uint16)(tmp >> 16); depth = (uint16)(tmp >> 16);
count = (uint16)tmp; count = (uint16)tmp;
STOBJ_SET_SLOT(obj, JSSLOT_BLOCK_DEPTH, INT_TO_JSVAL(depth)); obj->setSlot(JSSLOT_BLOCK_DEPTH, INT_TO_JSVAL(depth));
} }
/* /*
@@ -3907,8 +3907,8 @@ js_EnsureReservedSlots(JSContext *cx, JSObject *obj, size_t nreserved)
JS_ASSERT(OBJ_IS_NATIVE(obj)); JS_ASSERT(OBJ_IS_NATIVE(obj));
JS_ASSERT(!obj->dslots); JS_ASSERT(!obj->dslots);
uintN nslots = JSSLOT_FREE(STOBJ_GET_CLASS(obj)) + nreserved; uintN nslots = JSSLOT_FREE(obj->getClass()) + nreserved;
if (nslots > STOBJ_NSLOTS(obj) && !AllocSlots(cx, obj, nslots)) if (nslots > obj->numSlots() && !AllocSlots(cx, obj, nslots))
return false; return false;
JSScope *scope = OBJ_SCOPE(obj); JSScope *scope = OBJ_SCOPE(obj);
@@ -3916,7 +3916,7 @@ js_EnsureReservedSlots(JSContext *cx, JSObject *obj, size_t nreserved)
#ifdef JS_THREADSAFE #ifdef JS_THREADSAFE
JS_ASSERT(scope->title.ownercx->thread == cx->thread); JS_ASSERT(scope->title.ownercx->thread == cx->thread);
#endif #endif
JS_ASSERT(scope->freeslot == JSSLOT_FREE(STOBJ_GET_CLASS(obj))); JS_ASSERT(scope->freeslot == JSSLOT_FREE(obj->getClass()));
if (scope->freeslot < nslots) if (scope->freeslot < nslots)
scope->freeslot = nslots; scope->freeslot = nslots;
} }
@@ -4167,13 +4167,13 @@ js_AllocSlot(JSContext *cx, JSObject *obj, uint32 *slotp)
scope->freeslot += clasp->reserveSlots(cx, obj); scope->freeslot += clasp->reserveSlots(cx, obj);
} }
if (scope->freeslot >= STOBJ_NSLOTS(obj) && if (scope->freeslot >= obj->numSlots() &&
!js_GrowSlots(cx, obj, scope->freeslot + 1)) { !js_GrowSlots(cx, obj, scope->freeslot + 1)) {
return JS_FALSE; return JS_FALSE;
} }
/* js_ReallocSlots or js_FreeSlot should set the free slots to void. */ /* js_ReallocSlots or js_FreeSlot should set the free slots to void. */
JS_ASSERT(JSVAL_IS_VOID(STOBJ_GET_SLOT(obj, scope->freeslot))); JS_ASSERT(JSVAL_IS_VOID(obj->getSlot(scope->freeslot)));
*slotp = scope->freeslot++; *slotp = scope->freeslot++;
return JS_TRUE; return JS_TRUE;
} }
@@ -4300,7 +4300,7 @@ js_PurgeScopeChainHelper(JSContext *cx, JSObject *obj, jsid id)
* properties with the same names have been cached or traced. Call objects * properties with the same names have been cached or traced. Call objects
* may gain such properties via eval introducing new vars; see bug 490364. * may gain such properties via eval introducing new vars; see bug 490364.
*/ */
if (STOBJ_GET_CLASS(obj) == &js_CallClass) { if (obj->getClass() == &js_CallClass) {
while ((obj = obj->getParent()) != NULL) { while ((obj = obj->getParent()) != NULL) {
if (PurgeProtoChain(cx, obj, id)) if (PurgeProtoChain(cx, obj, id))
break; break;
@@ -6567,7 +6567,7 @@ js_TraceObject(JSTracer *trc, JSObject *obj)
* that share their scope, scope->freeslot can be an underestimate. * that share their scope, scope->freeslot can be an underestimate.
*/ */
size_t slots = scope->freeslot; size_t slots = scope->freeslot;
if (STOBJ_NSLOTS(obj) != slots) if (obj->numSlots() != slots)
js_ShrinkSlots(cx, obj, slots); js_ShrinkSlots(cx, obj, slots);
} }
@@ -6594,19 +6594,19 @@ js_TraceObject(JSTracer *trc, JSObject *obj)
/* /*
* An unmutated object that shares a prototype object's scope. We can't * An unmutated object that shares a prototype object's scope. We can't
* tell how many slots are in use in obj by looking at its scope, so we * tell how many slots are in use in obj by looking at its scope, so we
* use STOBJ_NSLOTS(obj). * use obj->numSlots().
* *
* NB: In case clasp->mark mutates something, leave this code here -- * NB: In case clasp->mark mutates something, leave this code here --
* don't move it up and unify it with the |if (!traceScope)| section * don't move it up and unify it with the |if (!traceScope)| section
* above. * above.
*/ */
uint32 nslots = STOBJ_NSLOTS(obj); uint32 nslots = obj->numSlots();
if (!scope->isSharedEmpty() && scope->freeslot < nslots) if (!scope->isSharedEmpty() && scope->freeslot < nslots)
nslots = scope->freeslot; nslots = scope->freeslot;
JS_ASSERT(nslots >= JSSLOT_START(clasp)); JS_ASSERT(nslots >= JSSLOT_START(clasp));
for (uint32 i = JSSLOT_START(clasp); i != nslots; ++i) { for (uint32 i = JSSLOT_START(clasp); i != nslots; ++i) {
jsval v = STOBJ_GET_SLOT(obj, i); jsval v = obj->getSlot(i);
if (JSVAL_IS_TRACEABLE(v)) { if (JSVAL_IS_TRACEABLE(v)) {
JS_SET_TRACING_DETAILS(trc, js_PrintObjectSlotName, obj, i); JS_SET_TRACING_DETAILS(trc, js_PrintObjectSlotName, obj, i);
js_CallGCMarker(trc, JSVAL_TO_TRACEABLE(v), JSVAL_TRACE_KIND(v)); js_CallGCMarker(trc, JSVAL_TO_TRACEABLE(v), JSVAL_TRACE_KIND(v));
@@ -6632,10 +6632,10 @@ js_Clear(JSContext *cx, JSObject *obj)
scope->clear(cx); scope->clear(cx);
/* Clear slot values and reset freeslot so we're consistent. */ /* Clear slot values and reset freeslot so we're consistent. */
i = STOBJ_NSLOTS(obj); i = obj->numSlots();
n = JSSLOT_FREE(obj->getClass()); n = JSSLOT_FREE(obj->getClass());
while (--i >= n) while (--i >= n)
STOBJ_SET_SLOT(obj, i, JSVAL_VOID); obj->setSlot(i, JSVAL_VOID);
scope->freeslot = n; scope->freeslot = n;
} }
JS_UNLOCK_OBJ(cx, obj); JS_UNLOCK_OBJ(cx, obj);
@@ -6676,7 +6676,7 @@ js_GetReservedSlot(JSContext *cx, JSObject *obj, uint32 index, jsval *vp)
return false; return false;
uint32 slot = JSSLOT_START(clasp) + index; uint32 slot = JSSLOT_START(clasp) + index;
*vp = (slot < STOBJ_NSLOTS(obj)) ? STOBJ_GET_SLOT(obj, slot) : JSVAL_VOID; *vp = (slot < obj->numSlots()) ? obj->getSlot(slot) : JSVAL_VOID;
JS_UNLOCK_OBJ(cx, obj); JS_UNLOCK_OBJ(cx, obj);
return true; return true;
} }
@@ -6717,13 +6717,13 @@ js_SetReservedSlot(JSContext *cx, JSObject *obj, uint32 index, jsval v)
* If scope is shared, do not modify scope->freeslot. It is OK for freeslot * If scope is shared, do not modify scope->freeslot. It is OK for freeslot
* to be an underestimate in objects with shared scopes, as they will get * to be an underestimate in objects with shared scopes, as they will get
* their own scopes before mutating, and elsewhere (e.g. js_TraceObject) we * their own scopes before mutating, and elsewhere (e.g. js_TraceObject) we
* use STOBJ_NSLOTS(obj) rather than rely on freeslot. * use obj->numSlots() rather than rely on freeslot.
*/ */
JSScope *scope = OBJ_SCOPE(obj); JSScope *scope = OBJ_SCOPE(obj);
if (!scope->isSharedEmpty() && slot >= scope->freeslot) if (!scope->isSharedEmpty() && slot >= scope->freeslot)
scope->freeslot = slot + 1; scope->freeslot = slot + 1;
STOBJ_SET_SLOT(obj, slot, v); obj->setSlot(slot, v);
GC_POKE(cx, JS_NULL); GC_POKE(cx, JS_NULL);
JS_UNLOCK_SCOPE(cx, scope); JS_UNLOCK_SCOPE(cx, scope);
return true; return true;
@@ -6853,7 +6853,7 @@ dumpValue(jsval val)
(void *) fun); (void *) fun);
} else if (JSVAL_IS_OBJECT(val)) { } else if (JSVAL_IS_OBJECT(val)) {
JSObject *obj = JSVAL_TO_OBJECT(val); JSObject *obj = JSVAL_TO_OBJECT(val);
JSClass *cls = STOBJ_GET_CLASS(obj); JSClass *cls = obj->getClass();
fprintf(stderr, "<%s%s at %p>", fprintf(stderr, "<%s%s at %p>",
cls->name, cls->name,
cls == &js_ObjectClass ? "" : " object", cls == &js_ObjectClass ? "" : " object",
@@ -6924,7 +6924,7 @@ js_DumpObject(JSObject *obj)
jsuint reservedEnd; jsuint reservedEnd;
fprintf(stderr, "object %p\n", (void *) obj); fprintf(stderr, "object %p\n", (void *) obj);
clasp = STOBJ_GET_CLASS(obj); clasp = obj->getClass();
fprintf(stderr, "class %p %s\n", (void *)clasp, clasp->name); fprintf(stderr, "class %p %s\n", (void *)clasp, clasp->name);
if (obj->isDenseArray()) { if (obj->isDenseArray()) {
@@ -6973,13 +6973,13 @@ js_DumpObject(JSObject *obj)
reservedEnd = i + JSCLASS_RESERVED_SLOTS(clasp); reservedEnd = i + JSCLASS_RESERVED_SLOTS(clasp);
slots = (OBJ_IS_NATIVE(obj) && !OBJ_SCOPE(obj)->isSharedEmpty()) slots = (OBJ_IS_NATIVE(obj) && !OBJ_SCOPE(obj)->isSharedEmpty())
? OBJ_SCOPE(obj)->freeslot ? OBJ_SCOPE(obj)->freeslot
: STOBJ_NSLOTS(obj); : obj->numSlots();
for (; i < slots; i++) { for (; i < slots; i++) {
fprintf(stderr, " %3d ", i); fprintf(stderr, " %3d ", i);
if (i < reservedEnd) if (i < reservedEnd)
fprintf(stderr, "(reserved) "); fprintf(stderr, "(reserved) ");
fprintf(stderr, "= "); fprintf(stderr, "= ");
dumpValue(STOBJ_GET_SLOT(obj, i)); dumpValue(obj->getSlot(i));
fputc('\n', stderr); fputc('\n', stderr);
} }
fputc('\n', stderr); fputc('\n', stderr);

View File

@@ -284,6 +284,42 @@ struct JSObject {
classword |= jsuword(2); classword |= jsuword(2);
} }
uint32 numSlots(void) {
return dslots ? (uint32)dslots[-1] : (uint32)JS_INITIAL_NSLOTS;
}
jsval& getSlotRef(uintN slot) {
return (slot < JS_INITIAL_NSLOTS)
? fslots[slot]
: (JS_ASSERT(slot < (uint32)dslots[-1]),
dslots[slot - JS_INITIAL_NSLOTS]);
}
jsval getSlot(uintN slot) const {
return (slot < JS_INITIAL_NSLOTS)
? fslots[slot]
: (JS_ASSERT(slot < (uint32)dslots[-1]),
dslots[slot - JS_INITIAL_NSLOTS]);
}
void setSlot(uintN slot, jsval value) {
if (slot < JS_INITIAL_NSLOTS) {
fslots[slot] = value;
} else {
JS_ASSERT(slot < (uint32)dslots[-1]);
dslots[slot - JS_INITIAL_NSLOTS] = value;
}
}
/*
* These ones are for multi-threaded objects. Use getSlot(),
* getSlotRef(), setSlot() to directly manipulate slots in obj when only
* one thread can access obj, or when accessing read-only slots within
* JS_INITIAL_NSLOTS.
*/
jsval lockAndGetSlot(JSContext *cx, uintN slot);
void lockAndSetSlot(JSContext *cx, uintN slot, jsval value);
JSObject *getProto() const { JSObject *getProto() const {
return JSVAL_TO_OBJECT(fslots[JSSLOT_PROTO]); return JSVAL_TO_OBJECT(fslots[JSSLOT_PROTO]);
} }
@@ -464,77 +500,19 @@ struct JSObject {
#define MAX_DSLOTS_LENGTH (JS_MAX(~uint32(0), ~size_t(0)) / sizeof(jsval) - 1) #define MAX_DSLOTS_LENGTH (JS_MAX(~uint32(0), ~size_t(0)) / sizeof(jsval) - 1)
#define MAX_DSLOTS_LENGTH32 (~uint32(0) / sizeof(jsval) - 1) #define MAX_DSLOTS_LENGTH32 (~uint32(0) / sizeof(jsval) - 1)
/*
* STOBJ prefix means Single Threaded Object. Use the following fast macros to
* directly manipulate slots in obj when only one thread can access obj, or
* when accessing read-only slots within JS_INITIAL_NSLOTS.
*/
#define STOBJ_NSLOTS(obj) \
((obj)->dslots ? (uint32)(obj)->dslots[-1] : (uint32)JS_INITIAL_NSLOTS)
inline jsval&
STOBJ_GET_SLOT(JSObject *obj, uintN slot)
{
return (slot < JS_INITIAL_NSLOTS)
? obj->fslots[slot]
: (JS_ASSERT(slot < (uint32)obj->dslots[-1]),
obj->dslots[slot - JS_INITIAL_NSLOTS]);
}
inline void
STOBJ_SET_SLOT(JSObject *obj, uintN slot, jsval value)
{
if (slot < JS_INITIAL_NSLOTS) {
obj->fslots[slot] = value;
} else {
JS_ASSERT(slot < (uint32)obj->dslots[-1]);
obj->dslots[slot - JS_INITIAL_NSLOTS] = value;
}
}
inline JSClass*
STOBJ_GET_CLASS(const JSObject* obj)
{
return obj->getClass();
}
#define OBJ_CHECK_SLOT(obj,slot) \ #define OBJ_CHECK_SLOT(obj,slot) \
(JS_ASSERT(obj->isNative()), JS_ASSERT(slot < OBJ_SCOPE(obj)->freeslot)) (JS_ASSERT(obj->isNative()), JS_ASSERT(slot < OBJ_SCOPE(obj)->freeslot))
#define LOCKED_OBJ_GET_SLOT(obj,slot) \ #define LOCKED_OBJ_GET_SLOT(obj,slot) \
(OBJ_CHECK_SLOT(obj, slot), STOBJ_GET_SLOT(obj, slot)) (OBJ_CHECK_SLOT(obj, slot), obj->getSlot(slot))
#define LOCKED_OBJ_SET_SLOT(obj,slot,value) \ #define LOCKED_OBJ_SET_SLOT(obj,slot,value) \
(OBJ_CHECK_SLOT(obj, slot), STOBJ_SET_SLOT(obj, slot, value)) (OBJ_CHECK_SLOT(obj, slot), obj->setSlot(slot, value))
#ifdef JS_THREADSAFE #ifdef JS_THREADSAFE
/* Thread-safe functions and wrapper macros for accessing slots in obj. */
#define OBJ_GET_SLOT(cx,obj,slot) \
(OBJ_CHECK_SLOT(obj, slot), \
(OBJ_SCOPE(obj)->title.ownercx == cx) \
? LOCKED_OBJ_GET_SLOT(obj, slot) \
: js_GetSlotThreadSafe(cx, obj, slot))
#define OBJ_SET_SLOT(cx,obj,slot,value) \
JS_BEGIN_MACRO \
OBJ_CHECK_SLOT(obj, slot); \
if (OBJ_SCOPE(obj)->title.ownercx == cx) \
LOCKED_OBJ_SET_SLOT(obj, slot, value); \
else \
js_SetSlotThreadSafe(cx, obj, slot, value); \
JS_END_MACRO
/* /*
* If thread-safe, define an OBJ_GET_SLOT wrapper that bypasses, for a native
* object, the lock-free "fast path" test of (OBJ_SCOPE(obj)->ownercx == cx),
* to avoid needlessly switching from lock-free to lock-full scope when doing
* GC on a different context from the last one to own the scope. The caller
* in this case is probably a JSClass.mark function, e.g., fun_mark, or maybe
* a finalizer.
*
* The GC runs only when all threads except the one on which the GC is active * The GC runs only when all threads except the one on which the GC is active
* are suspended at GC-safe points, so calling STOBJ_GET_SLOT from the GC's * are suspended at GC-safe points, so calling obj->getSlot() from the GC's
* thread is safe when rt->gcRunning is set. See jsgc.c for details. * thread is safe when rt->gcRunning is set. See jsgc.c for details.
*/ */
#define THREAD_IS_RUNNING_GC(rt, thread) \ #define THREAD_IS_RUNNING_GC(rt, thread) \
@@ -543,18 +521,13 @@ STOBJ_GET_CLASS(const JSObject* obj)
#define CX_THREAD_IS_RUNNING_GC(cx) \ #define CX_THREAD_IS_RUNNING_GC(cx) \
THREAD_IS_RUNNING_GC((cx)->runtime, (cx)->thread) THREAD_IS_RUNNING_GC((cx)->runtime, (cx)->thread)
#else /* !JS_THREADSAFE */ #endif /* JS_THREADSAFE */
#define OBJ_GET_SLOT(cx,obj,slot) LOCKED_OBJ_GET_SLOT(obj,slot)
#define OBJ_SET_SLOT(cx,obj,slot,value) LOCKED_OBJ_SET_SLOT(obj,slot,value)
#endif /* !JS_THREADSAFE */
/* /*
* Class is invariant and comes from the fixed clasp member. Thus no locking * Class is invariant and comes from the fixed clasp member. Thus no locking
* is necessary to read it. Same for the private slot. * is necessary to read it. Same for the private slot.
*/ */
#define OBJ_GET_CLASS(cx,obj) STOBJ_GET_CLASS(obj) #define OBJ_GET_CLASS(cx,obj) (obj)->getClass()
#ifdef __cplusplus #ifdef __cplusplus
inline void inline void
@@ -617,9 +590,9 @@ js_DefineBlockVariable(JSContext *cx, JSObject *obj, jsid id, intN index);
#define OBJ_BLOCK_COUNT(cx,obj) \ #define OBJ_BLOCK_COUNT(cx,obj) \
(OBJ_SCOPE(OBJ_IS_CLONED_BLOCK(obj) ? obj->getProto() : obj)->entryCount) (OBJ_SCOPE(OBJ_IS_CLONED_BLOCK(obj) ? obj->getProto() : obj)->entryCount)
#define OBJ_BLOCK_DEPTH(cx,obj) \ #define OBJ_BLOCK_DEPTH(cx,obj) \
JSVAL_TO_INT(STOBJ_GET_SLOT(obj, JSSLOT_BLOCK_DEPTH)) JSVAL_TO_INT(obj->getSlot(JSSLOT_BLOCK_DEPTH))
#define OBJ_SET_BLOCK_DEPTH(cx,obj,depth) \ #define OBJ_SET_BLOCK_DEPTH(cx,obj,depth) \
STOBJ_SET_SLOT(obj, JSSLOT_BLOCK_DEPTH, INT_TO_JSVAL(depth)) obj->setSlot(JSSLOT_BLOCK_DEPTH, INT_TO_JSVAL(depth))
/* /*
* To make sure this slot is well-defined, always call js_NewWithObject to * To make sure this slot is well-defined, always call js_NewWithObject to
@@ -889,7 +862,7 @@ js_IsCacheableNonGlobalScope(JSObject *obj)
extern JS_FRIEND_DATA(JSClass) js_DeclEnvClass; extern JS_FRIEND_DATA(JSClass) js_DeclEnvClass;
JS_ASSERT(obj->getParent()); JS_ASSERT(obj->getParent());
JSClass *clasp = STOBJ_GET_CLASS(obj); JSClass *clasp = obj->getClass();
bool cacheable = (clasp == &js_CallClass || bool cacheable = (clasp == &js_CallClass ||
clasp == &js_BlockClass || clasp == &js_BlockClass ||
clasp == &js_DeclEnvClass); clasp == &js_DeclEnvClass);

View File

@@ -44,6 +44,41 @@
#include "jsobj.h" #include "jsobj.h"
#include "jsscope.h" #include "jsscope.h"
inline jsval
JSObject::lockAndGetSlot(JSContext *cx, uintN slot) {
#ifdef JS_THREADSAFE
/*
* If thread-safe, define a lockAndGetSlot() that bypasses, for a native
* object, the lock-free "fast path" test of
* (OBJ_SCOPE(obj)->ownercx == cx), to avoid needlessly switching from
* lock-free to lock-full scope when doing GC on a different context
* from the last one to own the scope. The caller in this case is
* probably a JSClass.mark function, e.g., fun_mark, or maybe a
* finalizer.
*/
OBJ_CHECK_SLOT(this, slot);
return (OBJ_SCOPE(this)->title.ownercx == cx)
? LOCKED_OBJ_GET_SLOT(this, slot)
: js_GetSlotThreadSafe(cx, this, slot);
#else
return LOCKED_OBJ_GET_SLOT(this, slot);
#endif
}
inline void
JSObject::lockAndSetSlot(JSContext *cx, uintN slot, jsval value) {
#ifdef JS_THREADSAFE
/* Thread-safe way to set a slot. */
OBJ_CHECK_SLOT(this, slot);
if (OBJ_SCOPE(this)->title.ownercx == cx)
LOCKED_OBJ_SET_SLOT(this, slot, value);
else
js_SetSlotThreadSafe(cx, this, slot, value);
#else
LOCKED_OBJ_SET_SLOT(this, slot, value);
#endif
}
inline void inline void
JSObject::initSharingEmptyScope(JSClass *clasp, JSObject *proto, JSObject *parent, JSObject::initSharingEmptyScope(JSClass *clasp, JSObject *proto, JSObject *parent,
jsval privateSlotValue) jsval privateSlotValue)

View File

@@ -1400,7 +1400,7 @@ BEGIN_CASE(JSOP_GVARINC)
} }
slot = JSVAL_TO_INT(lval); slot = JSVAL_TO_INT(lval);
JS_ASSERT(fp->varobj(cx) == cx->activeCallStack()->getInitialVarObj()); JS_ASSERT(fp->varobj(cx) == cx->activeCallStack()->getInitialVarObj());
rval = OBJ_GET_SLOT(cx, cx->activeCallStack()->getInitialVarObj(), slot); rval = cx->activeCallStack()->getInitialVarObj()->lockAndGetSlot(cx, slot);
if (JS_LIKELY(CAN_DO_FAST_INC_DEC(rval))) { if (JS_LIKELY(CAN_DO_FAST_INC_DEC(rval))) {
PUSH_OPND(rval + incr2); PUSH_OPND(rval + incr2);
rval += incr; rval += incr;
@@ -1412,7 +1412,7 @@ BEGIN_CASE(JSOP_GVARINC)
rval = regs.sp[-1]; rval = regs.sp[-1];
--regs.sp; --regs.sp;
} }
OBJ_SET_SLOT(cx, fp->varobj(cx), slot, rval); fp->varobj(cx)->lockAndSetSlot(cx, slot, rval);
len = JSOP_INCGVAR_LENGTH; /* all gvar incops are same length */ len = JSOP_INCGVAR_LENGTH; /* all gvar incops are same length */
JS_ASSERT(len == js_CodeSpec[op].length); JS_ASSERT(len == js_CodeSpec[op].length);
DO_NEXT_OP(len); DO_NEXT_OP(len);
@@ -1769,7 +1769,7 @@ BEGIN_CASE(JSOP_SETMETHOD)
* reserveSlots hook to allocate a number of reserved * reserveSlots hook to allocate a number of reserved
* slots that may vary with obj. * slots that may vary with obj.
*/ */
if (slot < STOBJ_NSLOTS(obj) && if (slot < obj->numSlots() &&
!OBJ_GET_CLASS(cx, obj)->reserveSlots) { !OBJ_GET_CLASS(cx, obj)->reserveSlots) {
++scope->freeslot; ++scope->freeslot;
} else { } else {
@@ -2748,7 +2748,7 @@ BEGIN_CASE(JSOP_CALLGVAR)
JS_ASSERT(fp->varobj(cx) == cx->activeCallStack()->getInitialVarObj()); JS_ASSERT(fp->varobj(cx) == cx->activeCallStack()->getInitialVarObj());
obj = cx->activeCallStack()->getInitialVarObj(); obj = cx->activeCallStack()->getInitialVarObj();
slot = JSVAL_TO_INT(lval); slot = JSVAL_TO_INT(lval);
rval = OBJ_GET_SLOT(cx, obj, slot); rval = obj->lockAndGetSlot(cx, slot);
PUSH_OPND(rval); PUSH_OPND(rval);
if (op == JSOP_CALLGVAR) if (op == JSOP_CALLGVAR)
PUSH_OPND(OBJECT_TO_JSVAL(obj)); PUSH_OPND(OBJECT_TO_JSVAL(obj));
@@ -3392,7 +3392,7 @@ BEGIN_CASE(JSOP_INITMETHOD)
/* Fast path. Property cache hit. */ /* Fast path. Property cache hit. */
slot = sprop->slot; slot = sprop->slot;
JS_ASSERT(slot == scope->freeslot); JS_ASSERT(slot == scope->freeslot);
if (slot < STOBJ_NSLOTS(obj)) { if (slot < obj->numSlots()) {
++scope->freeslot; ++scope->freeslot;
} else { } else {
if (!js_AllocSlot(cx, obj, &slot)) if (!js_AllocSlot(cx, obj, &slot))

View File

@@ -3227,12 +3227,12 @@ BindLet(JSContext *cx, BindData *data, JSAtom *atom, JSTreeContext *tc)
* slots in jsemit.cpp:EmitEnterBlock. * slots in jsemit.cpp:EmitEnterBlock.
*/ */
uintN slot = JSSLOT_FREE(&js_BlockClass) + n; uintN slot = JSSLOT_FREE(&js_BlockClass) + n;
if (slot >= STOBJ_NSLOTS(blockObj) && if (slot >= blockObj->numSlots() &&
!js_GrowSlots(cx, blockObj, slot + 1)) { !js_GrowSlots(cx, blockObj, slot + 1)) {
return JS_FALSE; return JS_FALSE;
} }
OBJ_SCOPE(blockObj)->freeslot = slot + 1; OBJ_SCOPE(blockObj)->freeslot = slot + 1;
STOBJ_SET_SLOT(blockObj, slot, PRIVATE_TO_JSVAL(pn)); blockObj->setSlot(slot, PRIVATE_TO_JSVAL(pn));
return JS_TRUE; return JS_TRUE;
} }

View File

@@ -106,7 +106,7 @@ js_GetMutableScope(JSContext *cx, JSObject *obj)
* Compile-time block objects each have their own scope, created at * Compile-time block objects each have their own scope, created at
* birth, and runtime clone of a block objects are never mutated. * birth, and runtime clone of a block objects are never mutated.
*/ */
JS_ASSERT(STOBJ_GET_CLASS(obj) != &js_BlockClass); JS_ASSERT(obj->getClass() != &js_BlockClass);
newscope = JSScope::create(cx, scope->ops, obj->getClass(), obj, scope->shape); newscope = JSScope::create(cx, scope->ops, obj->getClass(), obj, scope->shape);
if (!newscope) if (!newscope)
return NULL; return NULL;
@@ -116,8 +116,8 @@ js_GetMutableScope(JSContext *cx, JSObject *obj)
JS_ASSERT(JS_IS_SCOPE_LOCKED(cx, newscope)); JS_ASSERT(JS_IS_SCOPE_LOCKED(cx, newscope));
obj->map = newscope; obj->map = newscope;
JS_ASSERT(newscope->freeslot == JSSLOT_FREE(STOBJ_GET_CLASS(obj))); JS_ASSERT(newscope->freeslot == JSSLOT_FREE(obj->getClass()));
clasp = STOBJ_GET_CLASS(obj); clasp = obj->getClass();
if (clasp->reserveSlots) { if (clasp->reserveSlots) {
/* /*
* FIXME: Here we change OBJ_SCOPE(obj)->freeslot without changing * FIXME: Here we change OBJ_SCOPE(obj)->freeslot without changing
@@ -126,8 +126,8 @@ js_GetMutableScope(JSContext *cx, JSObject *obj)
* js_AddProperty. See bug 535416. * js_AddProperty. See bug 535416.
*/ */
freeslot = JSSLOT_FREE(clasp) + clasp->reserveSlots(cx, obj); freeslot = JSSLOT_FREE(clasp) + clasp->reserveSlots(cx, obj);
if (freeslot > STOBJ_NSLOTS(obj)) if (freeslot > obj->numSlots())
freeslot = STOBJ_NSLOTS(obj); freeslot = obj->numSlots();
if (newscope->freeslot < freeslot) if (newscope->freeslot < freeslot)
newscope->freeslot = freeslot; newscope->freeslot = freeslot;
} }

View File

@@ -984,7 +984,7 @@ JSScopeProperty::get(JSContext* cx, JSObject* obj, JSObject *pobj, jsval* vp)
* objects. XPConnect objects don't expect the hook to be called here, * objects. XPConnect objects don't expect the hook to be called here,
* but with objects do. * but with objects do.
*/ */
if (STOBJ_GET_CLASS(obj) == &js_WithClass) if (obj->getClass() == &js_WithClass)
obj = obj->map->ops->thisObject(cx, obj); obj = obj->map->ops->thisObject(cx, obj);
return getterOp()(cx, obj, SPROP_USERID(this), vp); return getterOp()(cx, obj, SPROP_USERID(this), vp);
} }
@@ -1003,7 +1003,7 @@ JSScopeProperty::set(JSContext* cx, JSObject* obj, jsval* vp)
return !!js_ReportGetterOnlyAssignment(cx); return !!js_ReportGetterOnlyAssignment(cx);
/* See the comment in JSScopeProperty::get as to why we can check for With. */ /* See the comment in JSScopeProperty::get as to why we can check for With. */
if (STOBJ_GET_CLASS(obj) == &js_WithClass) if (obj->getClass() == &js_WithClass)
obj = obj->map->ops->thisObject(cx, obj); obj = obj->map->ops->thisObject(cx, obj);
return setterOp()(cx, obj, SPROP_USERID(this), vp); return setterOp()(cx, obj, SPROP_USERID(this), vp);
} }

View File

@@ -312,7 +312,7 @@ js_XDRScript(JSXDRState *xdr, JSScript **scriptp, bool needMutableScript,
JSObject **objp = &script->objects()->vector[i]; JSObject **objp = &script->objects()->vector[i];
uint32 isBlock; uint32 isBlock;
if (xdr->mode == JSXDR_ENCODE) { if (xdr->mode == JSXDR_ENCODE) {
JSClass *clasp = STOBJ_GET_CLASS(*objp); JSClass *clasp = (*objp)->getClass();
JS_ASSERT(clasp == &js_FunctionClass || JS_ASSERT(clasp == &js_FunctionClass ||
clasp == &js_BlockClass); clasp == &js_BlockClass);
isBlock = (clasp == &js_BlockClass) ? 1 : 0; isBlock = (clasp == &js_BlockClass) ? 1 : 0;

View File

@@ -63,7 +63,7 @@ JSScript::getRegExp(size_t index)
JSObjectArray *arr = regexps(); JSObjectArray *arr = regexps();
JS_ASSERT((uint32) index < arr->length); JS_ASSERT((uint32) index < arr->length);
JSObject *obj = arr->vector[index]; JSObject *obj = arr->vector[index];
JS_ASSERT(STOBJ_GET_CLASS(obj) == &js_RegExpClass); JS_ASSERT(obj->getClass() == &js_RegExpClass);
return obj; return obj;
} }

View File

@@ -1793,7 +1793,7 @@ VisitGlobalSlots(Visitor &visitor, JSContext *cx, JSObject *globalObj,
{ {
for (unsigned n = 0; n < ngslots; ++n) { for (unsigned n = 0; n < ngslots; ++n) {
unsigned slot = gslots[n]; unsigned slot = gslots[n];
visitor.visitGlobalSlot(&STOBJ_GET_SLOT(globalObj, slot), n, slot); visitor.visitGlobalSlot(&globalObj->getSlotRef(slot), n, slot);
} }
} }
@@ -2504,7 +2504,7 @@ bool
TraceRecorder::isGlobal(jsval* p) const TraceRecorder::isGlobal(jsval* p) const
{ {
return ((size_t(p - globalObj->fslots) < JS_INITIAL_NSLOTS) || return ((size_t(p - globalObj->fslots) < JS_INITIAL_NSLOTS) ||
(size_t(p - globalObj->dslots) < (STOBJ_NSLOTS(globalObj) - JS_INITIAL_NSLOTS))); (size_t(p - globalObj->dslots) < (globalObj->numSlots() - JS_INITIAL_NSLOTS)));
} }
/* /*
@@ -3514,9 +3514,9 @@ JS_REQUIRES_STACK void
TraceRecorder::importGlobalSlot(unsigned slot) TraceRecorder::importGlobalSlot(unsigned slot)
{ {
JS_ASSERT(slot == uint16(slot)); JS_ASSERT(slot == uint16(slot));
JS_ASSERT(STOBJ_NSLOTS(globalObj) <= MAX_GLOBAL_SLOTS); JS_ASSERT(globalObj->numSlots() <= MAX_GLOBAL_SLOTS);
jsval* vp = &STOBJ_GET_SLOT(globalObj, slot); jsval* vp = &globalObj->getSlotRef(slot);
JS_ASSERT(!known(vp)); JS_ASSERT(!known(vp));
/* Add the slot to the list of interned global slots. */ /* Add the slot to the list of interned global slots. */
@@ -3548,9 +3548,9 @@ TraceRecorder::lazilyImportGlobalSlot(unsigned slot)
* If the global object grows too large, alloca in ExecuteTree might fail, * If the global object grows too large, alloca in ExecuteTree might fail,
* so abort tracing on global objects with unreasonably many slots. * so abort tracing on global objects with unreasonably many slots.
*/ */
if (STOBJ_NSLOTS(globalObj) > MAX_GLOBAL_SLOTS) if (globalObj->numSlots() > MAX_GLOBAL_SLOTS)
return false; return false;
jsval* vp = &STOBJ_GET_SLOT(globalObj, slot); jsval* vp = &globalObj->getSlotRef(slot);
if (known(vp)) if (known(vp))
return true; /* we already have it */ return true; /* we already have it */
importGlobalSlot(slot); importGlobalSlot(slot);
@@ -5084,7 +5084,7 @@ TraceRecorder::emitTreeCall(TreeFragment* inner, VMSideExit* exit)
SlotList& gslots = *tree->globalSlots; SlotList& gslots = *tree->globalSlots;
for (unsigned i = 0; i < gslots.length(); i++) { for (unsigned i = 0; i < gslots.length(); i++) {
unsigned slot = gslots[i]; unsigned slot = gslots[i];
jsval* vp = &STOBJ_GET_SLOT(globalObj, slot); jsval* vp = &globalObj->getSlotRef(slot);
tracker.set(vp, NULL); tracker.set(vp, NULL);
} }
@@ -5287,7 +5287,7 @@ CheckGlobalObjectShape(JSContext* cx, TraceMonitor* tm, JSObject* globalObj,
return false; return false;
} }
if (STOBJ_NSLOTS(globalObj) > MAX_GLOBAL_SLOTS) { if (globalObj->numSlots() > MAX_GLOBAL_SLOTS) {
if (tm->recorder) if (tm->recorder)
AbortRecording(cx, "too many slots in global object"); AbortRecording(cx, "too many slots in global object");
return false; return false;
@@ -6435,7 +6435,7 @@ ScopeChainCheck(JSContext* cx, TreeFragment* f)
} }
/* Make sure the global object is sane. */ /* Make sure the global object is sane. */
JS_ASSERT(STOBJ_NSLOTS(f->globalObj) <= MAX_GLOBAL_SLOTS); JS_ASSERT(f->globalObj->numSlots() <= MAX_GLOBAL_SLOTS);
JS_ASSERT(f->nGlobalTypes() == f->globalSlots->length()); JS_ASSERT(f->nGlobalTypes() == f->globalSlots->length());
JS_ASSERT_IF(f->globalSlots->length() != 0, JS_ASSERT_IF(f->globalSlots->length() != 0,
OBJ_SHAPE(f->globalObj) == f->globalShape); OBJ_SHAPE(f->globalObj) == f->globalShape);
@@ -6478,7 +6478,7 @@ ExecuteTree(JSContext* cx, TreeFragment* f, uintN& inlineCallCount,
f->maxNativeStackSlots, f->maxNativeStackSlots,
f->code()); f->code());
debug_only_stmt(uint32 globalSlots = STOBJ_NSLOTS(globalObj);) debug_only_stmt(uint32 globalSlots = globalObj->numSlots();)
debug_only_stmt(*(uint64*)&tm->storage->global()[globalSlots] = 0xdeadbeefdeadbeefLL;) debug_only_stmt(*(uint64*)&tm->storage->global()[globalSlots] = 0xdeadbeefdeadbeefLL;)
/* Execute trace. */ /* Execute trace. */
@@ -7855,7 +7855,7 @@ TraceRecorder::scopeChainProp(JSObject* chainHead, jsval*& vp, LIns*& ins, NameR
obj2->dropProperty(cx, prop); obj2->dropProperty(cx, prop);
RETURN_STOP_A("lazy import of global slot failed"); RETURN_STOP_A("lazy import of global slot failed");
} }
vp = &STOBJ_GET_SLOT(obj, sprop->slot); vp = &obj->getSlotRef(sprop->slot);
ins = get(vp); ins = get(vp);
obj2->dropProperty(cx, prop); obj2->dropProperty(cx, prop);
nr.tracked = true; nr.tracked = true;
@@ -8506,7 +8506,7 @@ TraceRecorder::incProp(jsint incr, bool pre)
if (slot == SPROP_INVALID_SLOT) if (slot == SPROP_INVALID_SLOT)
RETURN_STOP_A("incProp on invalid slot"); RETURN_STOP_A("incProp on invalid slot");
jsval& v = STOBJ_GET_SLOT(obj, slot); jsval& v = obj->getSlotRef(slot);
CHECK_STATUS_A(inc(v, v_ins, incr, pre)); CHECK_STATUS_A(inc(v, v_ins, incr, pre));
LIns* dslots_ins = NULL; LIns* dslots_ins = NULL;
@@ -11188,7 +11188,7 @@ TraceRecorder::nativeSet(JSObject* obj, LIns* obj_ins, JSScopeProperty* sprop,
if (obj == globalObj) { if (obj == globalObj) {
if (!lazilyImportGlobalSlot(slot)) if (!lazilyImportGlobalSlot(slot))
RETURN_STOP("lazy import of global slot failed"); RETURN_STOP("lazy import of global slot failed");
set(&STOBJ_GET_SLOT(obj, slot), v_ins); set(&obj->getSlotRef(slot), v_ins);
} else { } else {
LIns* dslots_ins = NULL; LIns* dslots_ins = NULL;
stobj_set_slot(obj_ins, slot, dslots_ins, boxed_ins); stobj_set_slot(obj_ins, slot, dslots_ins, boxed_ins);
@@ -12744,7 +12744,7 @@ TraceRecorder::name(jsval*& vp, LIns*& ins, NameResult& nr)
if (!lazilyImportGlobalSlot(slot)) if (!lazilyImportGlobalSlot(slot))
RETURN_STOP_A("lazy import of global slot failed"); RETURN_STOP_A("lazy import of global slot failed");
vp = &STOBJ_GET_SLOT(obj, slot); vp = &obj->getSlotRef(slot);
ins = get(vp); ins = get(vp);
nr.tracked = true; nr.tracked = true;
return ARECORD_CONTINUE; return ARECORD_CONTINUE;
@@ -12895,7 +12895,7 @@ TraceRecorder::propTail(JSObject* obj, LIns* obj_ins, JSObject* obj2, PCVal pcva
} }
LIns* dslots_ins = NULL; LIns* dslots_ins = NULL;
LIns* v_ins = unbox_jsval(STOBJ_GET_SLOT(obj, slot), LIns* v_ins = unbox_jsval(obj->getSlot(slot),
stobj_get_slot(obj_ins, slot, dslots_ins), stobj_get_slot(obj_ins, slot, dslots_ins),
snapshot(BRANCH_EXIT)); snapshot(BRANCH_EXIT));
@@ -14254,7 +14254,7 @@ TraceRecorder::record_JSOP_GETGVAR()
if (!lazilyImportGlobalSlot(slot)) if (!lazilyImportGlobalSlot(slot))
RETURN_STOP_A("lazy import of global slot failed"); RETURN_STOP_A("lazy import of global slot failed");
stack(0, get(&STOBJ_GET_SLOT(globalObj, slot))); stack(0, get(&globalObj->getSlotRef(slot)));
return ARECORD_CONTINUE; return ARECORD_CONTINUE;
} }
@@ -14270,7 +14270,7 @@ TraceRecorder::record_JSOP_SETGVAR()
if (!lazilyImportGlobalSlot(slot)) if (!lazilyImportGlobalSlot(slot))
RETURN_STOP_A("lazy import of global slot failed"); RETURN_STOP_A("lazy import of global slot failed");
set(&STOBJ_GET_SLOT(globalObj, slot), stack(-1)); set(&globalObj->getSlotRef(slot), stack(-1));
return ARECORD_CONTINUE; return ARECORD_CONTINUE;
} }
@@ -14287,7 +14287,7 @@ TraceRecorder::record_JSOP_INCGVAR()
if (!lazilyImportGlobalSlot(slot)) if (!lazilyImportGlobalSlot(slot))
RETURN_STOP_A("lazy import of global slot failed"); RETURN_STOP_A("lazy import of global slot failed");
return InjectStatus(inc(STOBJ_GET_SLOT(globalObj, slot), 1)); return InjectStatus(inc(globalObj->getSlotRef(slot), 1));
} }
JS_REQUIRES_STACK AbortableRecordingStatus JS_REQUIRES_STACK AbortableRecordingStatus
@@ -14303,7 +14303,7 @@ TraceRecorder::record_JSOP_DECGVAR()
if (!lazilyImportGlobalSlot(slot)) if (!lazilyImportGlobalSlot(slot))
RETURN_STOP_A("lazy import of global slot failed"); RETURN_STOP_A("lazy import of global slot failed");
return InjectStatus(inc(STOBJ_GET_SLOT(globalObj, slot), -1)); return InjectStatus(inc(globalObj->getSlotRef(slot), -1));
} }
JS_REQUIRES_STACK AbortableRecordingStatus JS_REQUIRES_STACK AbortableRecordingStatus
@@ -14319,7 +14319,7 @@ TraceRecorder::record_JSOP_GVARINC()
if (!lazilyImportGlobalSlot(slot)) if (!lazilyImportGlobalSlot(slot))
RETURN_STOP_A("lazy import of global slot failed"); RETURN_STOP_A("lazy import of global slot failed");
return InjectStatus(inc(STOBJ_GET_SLOT(globalObj, slot), 1, false)); return InjectStatus(inc(globalObj->getSlotRef(slot), 1, false));
} }
JS_REQUIRES_STACK AbortableRecordingStatus JS_REQUIRES_STACK AbortableRecordingStatus
@@ -14335,7 +14335,7 @@ TraceRecorder::record_JSOP_GVARDEC()
if (!lazilyImportGlobalSlot(slot)) if (!lazilyImportGlobalSlot(slot))
RETURN_STOP_A("lazy import of global slot failed"); RETURN_STOP_A("lazy import of global slot failed");
return InjectStatus(inc(STOBJ_GET_SLOT(globalObj, slot), -1, false)); return InjectStatus(inc(globalObj->getSlotRef(slot), -1, false));
} }
JS_REQUIRES_STACK AbortableRecordingStatus JS_REQUIRES_STACK AbortableRecordingStatus
@@ -14826,7 +14826,7 @@ TraceRecorder::record_JSOP_CALLGVAR()
if (!lazilyImportGlobalSlot(slot)) if (!lazilyImportGlobalSlot(slot))
RETURN_STOP_A("lazy import of global slot failed"); RETURN_STOP_A("lazy import of global slot failed");
jsval& v = STOBJ_GET_SLOT(globalObj, slot); jsval& v = globalObj->getSlotRef(slot);
stack(0, get(&v)); stack(0, get(&v));
stack(1, INS_NULL()); stack(1, INS_NULL());
return ARECORD_CONTINUE; return ARECORD_CONTINUE;

View File

@@ -71,6 +71,7 @@
#include "jsvector.h" #include "jsvector.h"
#include "jscntxtinlines.h" #include "jscntxtinlines.h"
#include "jsobjinlines.h"
#ifdef DEBUG #ifdef DEBUG
#include <string.h> /* for #ifdef DEBUG memset calls */ #include <string.h> /* for #ifdef DEBUG memset calls */
@@ -155,9 +156,9 @@ GetSlotString(const JSObject *obj, uint32 slot)
JS_ASSERT(slot == JSSLOT_PREFIX || JS_ASSERT(slot == JSSLOT_PREFIX ||
slot == JSSLOT_URI || slot == JSSLOT_URI ||
slot == JSSLOT_LOCAL_NAME); slot == JSSLOT_LOCAL_NAME);
JS_ASSERT(STOBJ_GET_CLASS(obj) == &js_NamespaceClass.base || JS_ASSERT(obj->getClass() == &js_NamespaceClass.base ||
IsQNameClass(STOBJ_GET_CLASS(obj))); IsQNameClass(obj->getClass()));
JS_ASSERT_IF(STOBJ_GET_CLASS(obj) == &js_NamespaceClass.base, JS_ASSERT_IF(obj->getClass() == &js_NamespaceClass.base,
slot != JSSLOT_LOCAL_NAME); slot != JSSLOT_LOCAL_NAME);
v = obj->fslots[slot]; v = obj->fslots[slot];
@@ -190,7 +191,7 @@ IsDeclared(const JSObject *obj)
{ {
jsval v; jsval v;
JS_ASSERT(STOBJ_GET_CLASS(obj) == &js_NamespaceClass.base); JS_ASSERT(obj->getClass() == &js_NamespaceClass.base);
v = obj->fslots[JSSLOT_DECLARED]; v = obj->fslots[JSSLOT_DECLARED];
JS_ASSERT(JSVAL_IS_VOID(v) || v == JSVAL_TRUE); JS_ASSERT(JSVAL_IS_VOID(v) || v == JSVAL_TRUE);
return v == JSVAL_TRUE; return v == JSVAL_TRUE;
@@ -226,7 +227,7 @@ namespace_getProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
if (!JSVAL_IS_INT(id)) if (!JSVAL_IS_INT(id))
return JS_TRUE; return JS_TRUE;
if (STOBJ_GET_CLASS(obj) != &js_NamespaceClass.base) if (obj->getClass() != &js_NamespaceClass.base)
return JS_TRUE; return JS_TRUE;
switch (JSVAL_TO_INT(id)) { switch (JSVAL_TO_INT(id)) {
@@ -334,7 +335,7 @@ qname_getProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
if (!JSVAL_IS_INT(id)) if (!JSVAL_IS_INT(id))
return JS_TRUE; return JS_TRUE;
if (STOBJ_GET_CLASS(obj) != &js_QNameClass.base) if (obj->getClass() != &js_QNameClass.base)
return JS_TRUE; return JS_TRUE;
switch (JSVAL_TO_INT(id)) { switch (JSVAL_TO_INT(id)) {
@@ -7284,7 +7285,7 @@ js_InitXMLClass(JSContext *cx, JSObject *obj)
JS_ASSERT(prop); JS_ASSERT(prop);
sprop = (JSScopeProperty *) prop; sprop = (JSScopeProperty *) prop;
JS_ASSERT(SPROP_HAS_VALID_SLOT(sprop, OBJ_SCOPE(pobj))); JS_ASSERT(SPROP_HAS_VALID_SLOT(sprop, OBJ_SCOPE(pobj)));
cval = OBJ_GET_SLOT(cx, pobj, sprop->slot); cval = pobj->lockAndGetSlot(cx, sprop->slot);
pobj->dropProperty(cx, prop); pobj->dropProperty(cx, prop);
JS_ASSERT(VALUE_IS_FUNCTION(cx, cval)); JS_ASSERT(VALUE_IS_FUNCTION(cx, cval));

View File

@@ -316,7 +316,7 @@ ThrowException(nsresult rv, JSContext *cx)
static inline JSObject * static inline JSObject *
GetWrappedJSObject(JSContext *cx, JSObject *obj) GetWrappedJSObject(JSContext *cx, JSObject *obj)
{ {
JSClass *clasp = STOBJ_GET_CLASS(obj); JSClass *clasp = obj->getClass();
if (!(clasp->flags & JSCLASS_IS_EXTENDED)) { if (!(clasp->flags & JSCLASS_IS_EXTENDED)) {
return obj; return obj;
} }
@@ -340,7 +340,7 @@ static inline
JSObject * JSObject *
GetWrapper(JSObject *obj) GetWrapper(JSObject *obj)
{ {
while (STOBJ_GET_CLASS(obj) != &COWClass.base) { while (obj->getClass() != &COWClass.base) {
obj = obj->getProto(); obj = obj->getProto();
if (!obj) { if (!obj) {
break; break;
@@ -707,7 +707,7 @@ XPC_COW_Convert(JSContext *cx, JSObject *obj, JSType type, jsval *vp)
return ThrowException(NS_ERROR_FAILURE, cx); return ThrowException(NS_ERROR_FAILURE, cx);
} }
if (!STOBJ_GET_CLASS(wrappedObj)->convert(cx, wrappedObj, type, vp)) { if (!wrappedObj->getClass()->convert(cx, wrappedObj, type, vp)) {
return JS_FALSE; return JS_FALSE;
} }
@@ -752,7 +752,7 @@ XPC_COW_Equality(JSContext *cx, JSObject *obj, jsval v, JSBool *bp)
XPCWrappedNative *me = XPCWrappedNative::GetWrappedNativeOfJSObject(cx, obj); XPCWrappedNative *me = XPCWrappedNative::GetWrappedNativeOfJSObject(cx, obj);
obj = me->GetFlatJSObject(); obj = me->GetFlatJSObject();
test = other->GetFlatJSObject(); test = other->GetFlatJSObject();
return ((JSExtendedClass *)STOBJ_GET_CLASS(obj))-> return ((JSExtendedClass *)obj->getClass())->
equality(cx, obj, OBJECT_TO_JSVAL(test), bp); equality(cx, obj, OBJECT_TO_JSVAL(test), bp);
} }

View File

@@ -125,7 +125,7 @@ static inline
JSObject * JSObject *
GetWrapper(JSObject *obj) GetWrapper(JSObject *obj)
{ {
while (STOBJ_GET_CLASS(obj) != &XPCCrossOriginWrapper::XOWClass.base) { while (obj->getClass() != &XPCCrossOriginWrapper::XOWClass.base) {
obj = obj->getProto(); obj = obj->getProto();
if (!obj) { if (!obj) {
break; break;
@@ -354,7 +354,7 @@ WrapObject(JSContext *cx, JSObject *parent, jsval *vp, XPCWrappedNative* wn)
JSObject *wrappedObj; JSObject *wrappedObj;
if (JSVAL_IS_PRIMITIVE(*vp) || if (JSVAL_IS_PRIMITIVE(*vp) ||
!(wrappedObj = JSVAL_TO_OBJECT(*vp)) || !(wrappedObj = JSVAL_TO_OBJECT(*vp)) ||
STOBJ_GET_CLASS(wrappedObj) == &XOWClass.base) { wrappedObj->getClass() == &XOWClass.base) {
return JS_TRUE; return JS_TRUE;
} }
@@ -368,7 +368,7 @@ WrapObject(JSContext *cx, JSObject *parent, jsval *vp, XPCWrappedNative* wn)
// The parent must be the inner global object for its scope. // The parent must be the inner global object for its scope.
parent = JS_GetGlobalForObject(cx, parent); parent = JS_GetGlobalForObject(cx, parent);
JSClass *clasp = STOBJ_GET_CLASS(parent); JSClass *clasp = parent->getClass();
if (clasp->flags & JSCLASS_IS_EXTENDED) { if (clasp->flags & JSCLASS_IS_EXTENDED) {
JSExtendedClass *xclasp = reinterpret_cast<JSExtendedClass *>(clasp); JSExtendedClass *xclasp = reinterpret_cast<JSExtendedClass *>(clasp);
if (xclasp->innerObject) { if (xclasp->innerObject) {
@@ -384,7 +384,7 @@ WrapObject(JSContext *cx, JSObject *parent, jsval *vp, XPCWrappedNative* wn)
#ifdef DEBUG_mrbkap_off #ifdef DEBUG_mrbkap_off
printf("Wrapping object at %p (%s) [%p]\n", printf("Wrapping object at %p (%s) [%p]\n",
(void *)wrappedObj, STOBJ_GET_CLASS(wrappedObj)->name, (void *)wrappedObj, wrappedObj->getClass()->name,
(void *)parentScope); (void *)parentScope);
#endif #endif
@@ -393,7 +393,7 @@ WrapObject(JSContext *cx, JSObject *parent, jsval *vp, XPCWrappedNative* wn)
outerObj = map->Find(wrappedObj); outerObj = map->Find(wrappedObj);
if (outerObj) { if (outerObj) {
NS_ASSERTION(STOBJ_GET_CLASS(outerObj) == &XOWClass.base, NS_ASSERTION(outerObj->getClass() == &XOWClass.base,
"What crazy object are we getting here?"); "What crazy object are we getting here?");
#ifdef DEBUG_mrbkap_off #ifdef DEBUG_mrbkap_off
printf("But found a wrapper in the map %p!\n", (void *)outerObj); printf("But found a wrapper in the map %p!\n", (void *)outerObj);
@@ -434,7 +434,7 @@ static JSBool
IsValFrame(JSObject *obj, jsval v, XPCWrappedNative *wn) IsValFrame(JSObject *obj, jsval v, XPCWrappedNative *wn)
{ {
// Fast path for the common case. // Fast path for the common case.
if (STOBJ_GET_CLASS(obj)->name[0] != 'W') { if (obj->getClass()->name[0] != 'W') {
return JS_FALSE; return JS_FALSE;
} }
@@ -530,7 +530,7 @@ WrapSameOriginProp(JSContext *cx, JSObject *outerObj, jsval *vp)
} }
JSObject *wrappedObj = JSVAL_TO_OBJECT(*vp); JSObject *wrappedObj = JSVAL_TO_OBJECT(*vp);
JSClass *clasp = STOBJ_GET_CLASS(wrappedObj); JSClass *clasp = wrappedObj->getClass();
if (ClassNeedsXOW(clasp->name)) { if (ClassNeedsXOW(clasp->name)) {
return WrapObject(cx, JS_GetGlobalForObject(cx, outerObj), vp); return WrapObject(cx, JS_GetGlobalForObject(cx, outerObj), vp);
} }
@@ -682,7 +682,7 @@ XPC_XOW_GetOrSetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp,
return ThrowException(NS_ERROR_NOT_INITIALIZED, cx); return ThrowException(NS_ERROR_NOT_INITIALIZED, cx);
} }
rv = ssm->CheckPropertyAccess(cx, wrappedObj, rv = ssm->CheckPropertyAccess(cx, wrappedObj,
STOBJ_GET_CLASS(wrappedObj)->name, wrappedObj->getClass()->name,
id, isSet ? sSecMgrSetProp id, isSet ? sSecMgrSetProp
: sSecMgrGetProp); : sSecMgrGetProp);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
@@ -805,7 +805,7 @@ XPC_XOW_Enumerate(JSContext *cx, JSObject *obj)
static JSObject * static JSObject *
GetUXPCObject(JSContext *cx, JSObject *obj) GetUXPCObject(JSContext *cx, JSObject *obj)
{ {
NS_ASSERTION(STOBJ_GET_CLASS(obj) == &XOWClass.base, "wrong object"); NS_ASSERTION(obj->getClass() == &XOWClass.base, "wrong object");
jsval v; jsval v;
if (!JS_GetReservedSlot(cx, obj, sFlagsSlot, &v)) { if (!JS_GetReservedSlot(cx, obj, sFlagsSlot, &v)) {
@@ -895,7 +895,7 @@ XPC_XOW_NewResolve(JSContext *cx, JSObject *obj, jsval id, uintN flags,
? sSecMgrSetProp ? sSecMgrSetProp
: sSecMgrGetProp; : sSecMgrGetProp;
rv = ssm->CheckPropertyAccess(cx, wrappedObj, rv = ssm->CheckPropertyAccess(cx, wrappedObj,
STOBJ_GET_CLASS(wrappedObj)->name, wrappedObj->getClass()->name,
id, action); id, action);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
// The security manager threw an exception for us. // The security manager threw an exception for us.
@@ -975,7 +975,7 @@ XPC_XOW_Convert(JSContext *cx, JSObject *obj, JSType type, jsval *vp)
return JS_FALSE; return JS_FALSE;
} }
if (!STOBJ_GET_CLASS(wrappedObj)->convert(cx, wrappedObj, type, vp)) { if (!wrappedObj->getClass()->convert(cx, wrappedObj, type, vp)) {
return JS_FALSE; return JS_FALSE;
} }
@@ -1111,7 +1111,7 @@ XPC_XOW_HasInstance(JSContext *cx, JSObject *obj, jsval v, JSBool *bp)
return JS_FALSE; return JS_FALSE;
} }
JSClass *clasp = STOBJ_GET_CLASS(iface); JSClass *clasp = iface->getClass();
*bp = JS_FALSE; *bp = JS_FALSE;
if (!clasp->hasInstance) { if (!clasp->hasInstance) {
@@ -1142,7 +1142,7 @@ XPC_XOW_Equality(JSContext *cx, JSObject *obj, jsval v, JSBool *bp)
} }
JSObject *test = JSVAL_TO_OBJECT(v); JSObject *test = JSVAL_TO_OBJECT(v);
if (STOBJ_GET_CLASS(test) == &XOWClass.base) { if (test->getClass() == &XOWClass.base) {
if (!JS_GetReservedSlot(cx, test, sWrappedObjSlot, &v)) { if (!JS_GetReservedSlot(cx, test, sWrappedObjSlot, &v)) {
return JS_FALSE; return JS_FALSE;
} }
@@ -1169,7 +1169,7 @@ XPC_XOW_Equality(JSContext *cx, JSObject *obj, jsval v, JSBool *bp)
XPCWrappedNative *me = XPCWrappedNative::GetWrappedNativeOfJSObject(cx, obj); XPCWrappedNative *me = XPCWrappedNative::GetWrappedNativeOfJSObject(cx, obj);
obj = me->GetFlatJSObject(); obj = me->GetFlatJSObject();
test = other->GetFlatJSObject(); test = other->GetFlatJSObject();
return ((JSExtendedClass *)STOBJ_GET_CLASS(obj))-> return ((JSExtendedClass *)obj->getClass())->
equality(cx, obj, OBJECT_TO_JSVAL(test), bp); equality(cx, obj, OBJECT_TO_JSVAL(test), bp);
} }
@@ -1260,7 +1260,7 @@ XPC_XOW_toString(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
return ThrowException(NS_ERROR_NOT_INITIALIZED, cx); return ThrowException(NS_ERROR_NOT_INITIALIZED, cx);
} }
rv = ssm->CheckPropertyAccess(cx, wrappedObj, rv = ssm->CheckPropertyAccess(cx, wrappedObj,
STOBJ_GET_CLASS(wrappedObj)->name, wrappedObj->getClass()->name,
GetRTStringByIndex(cx, XPCJSRuntime::IDX_TO_STRING), GetRTStringByIndex(cx, XPCJSRuntime::IDX_TO_STRING),
nsIXPCSecurityManager::ACCESS_GET_PROPERTY); nsIXPCSecurityManager::ACCESS_GET_PROPERTY);
} }

View File

@@ -262,7 +262,7 @@ RewrapIfDeepWrapper(JSContext *cx, JSObject *obj, jsval v, jsval *rval)
// if (HAS_FLAGS(flags, FLAG_DEEP). // if (HAS_FLAGS(flags, FLAG_DEEP).
if (HAS_FLAGS(flags, FLAG_DEEP) && !primitive) { if (HAS_FLAGS(flags, FLAG_DEEP) && !primitive) {
// Unwrap a cross origin wrapper, since we're more restrictive. // Unwrap a cross origin wrapper, since we're more restrictive.
if (STOBJ_GET_CLASS(nativeObj) == &XPCCrossOriginWrapper::XOWClass.base) { if (nativeObj->getClass() == &XPCCrossOriginWrapper::XOWClass.base) {
if (!::JS_GetReservedSlot(cx, nativeObj, sWrappedObjSlot, if (!::JS_GetReservedSlot(cx, nativeObj, sWrappedObjSlot,
&v)) { &v)) {
return JS_FALSE; return JS_FALSE;
@@ -334,10 +334,10 @@ using namespace XPCNativeWrapper;
// in the call from XPC_NW_Convert, for example. // in the call from XPC_NW_Convert, for example.
#define XPC_NW_CALL_HOOK(obj, hook, args) \ #define XPC_NW_CALL_HOOK(obj, hook, args) \
return STOBJ_GET_CLASS(obj)->hook args; return obj->getClass()->hook args;
#define XPC_NW_CAST_HOOK(obj, type, hook, args) \ #define XPC_NW_CAST_HOOK(obj, type, hook, args) \
return ((type) STOBJ_GET_CLASS(obj)->hook) args; return ((type) obj->getClass()->hook) args;
static JSBool static JSBool
ShouldBypassNativeWrapper(JSContext *cx, JSObject *obj) ShouldBypassNativeWrapper(JSContext *cx, JSObject *obj)
@@ -381,7 +381,7 @@ ShouldBypassNativeWrapper(JSContext *cx, JSObject *obj)
#define XPC_NW_BYPASS_TEST(cx, obj, hook, args) \ #define XPC_NW_BYPASS_TEST(cx, obj, hook, args) \
XPC_NW_BYPASS_BASE(cx, obj, \ XPC_NW_BYPASS_BASE(cx, obj, \
JSClass *clasp_ = STOBJ_GET_CLASS(obj); \ JSClass *clasp_ = obj->getClass(); \
return !clasp_->hook || clasp_->hook args; \ return !clasp_->hook || clasp_->hook args; \
) )
@@ -445,7 +445,7 @@ EnsureLegalActivity(JSContext *cx, JSObject *obj,
(accessType & (sSecMgrSetProp | sSecMgrGetProp)) && (accessType & (sSecMgrSetProp | sSecMgrGetProp)) &&
(flatObj = wn->GetFlatJSObject())) { (flatObj = wn->GetFlatJSObject())) {
rv = ssm->CheckPropertyAccess(cx, flatObj, rv = ssm->CheckPropertyAccess(cx, flatObj,
STOBJ_GET_CLASS(flatObj)->name, flatObj->getClass()->name,
id, accessType); id, accessType);
return NS_SUCCEEDED(rv); return NS_SUCCEEDED(rv);
} }
@@ -846,7 +846,7 @@ XPC_NW_CheckAccess(JSContext *cx, JSObject *obj, jsval id,
JSObject *wrapperJSObject = wrappedNative->GetFlatJSObject(); JSObject *wrapperJSObject = wrappedNative->GetFlatJSObject();
JSClass *clazz = STOBJ_GET_CLASS(wrapperJSObject); JSClass *clazz = wrapperJSObject->getClass();
return !clazz->checkAccess || return !clazz->checkAccess ||
clazz->checkAccess(cx, wrapperJSObject, id, mode, vp); clazz->checkAccess(cx, wrapperJSObject, id, mode, vp);
} }

View File

@@ -213,7 +213,7 @@ FindObjectPrincipals(JSContext *cx, JSObject *safeObj, JSObject *innerObj)
static inline JSObject * static inline JSObject *
FindSafeObject(JSObject *obj) FindSafeObject(JSObject *obj)
{ {
while (STOBJ_GET_CLASS(obj) != &SJOWClass.base) { while (obj->getClass() != &SJOWClass.base) {
obj = obj->getProto(); obj = obj->getProto();
if (!obj) { if (!obj) {
@@ -692,7 +692,7 @@ XPC_SJOW_CheckAccess(JSContext *cx, JSObject *obj, jsval id,
return JS_FALSE; return JS_FALSE;
} }
JSClass *clazz = STOBJ_GET_CLASS(unsafeObj); JSClass *clazz = unsafeObj->getClass();
return !clazz->checkAccess || return !clazz->checkAccess ||
clazz->checkAccess(cx, unsafeObj, id, mode, vp); clazz->checkAccess(cx, unsafeObj, id, mode, vp);
} }
@@ -804,7 +804,7 @@ XPC_SJOW_Construct(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
// with XPCSafeJSObjectWrapper, and never let the eval function // with XPCSafeJSObjectWrapper, and never let the eval function
// object be directly wrapped. // object be directly wrapped.
if (STOBJ_GET_CLASS(objToWrap) == &js_ScriptClass || if (objToWrap->getClass() == &js_ScriptClass ||
(::JS_ObjectIsFunction(cx, objToWrap) && (::JS_ObjectIsFunction(cx, objToWrap) &&
::JS_GetFunctionFastNative(cx, ::JS_ValueToFunction(cx, argv[0])) == ::JS_GetFunctionFastNative(cx, ::JS_ValueToFunction(cx, argv[0])) ==
XPCWrapper::sEvalNative)) { XPCWrapper::sEvalNative)) {

View File

@@ -223,7 +223,7 @@ using namespace SystemOnlyWrapper;
static inline JSObject * static inline JSObject *
GetWrappedJSObject(JSContext *cx, JSObject *obj) GetWrappedJSObject(JSContext *cx, JSObject *obj)
{ {
JSClass *clasp = STOBJ_GET_CLASS(obj); JSClass *clasp = obj->getClass();
if (!(clasp->flags & JSCLASS_IS_EXTENDED)) { if (!(clasp->flags & JSCLASS_IS_EXTENDED)) {
return obj; return obj;
} }
@@ -241,7 +241,7 @@ static inline
JSObject * JSObject *
GetWrapper(JSObject *obj) GetWrapper(JSObject *obj)
{ {
while (STOBJ_GET_CLASS(obj) != &SOWClass.base) { while (obj->getClass() != &SOWClass.base) {
obj = obj->getProto(); obj = obj->getProto();
if (!obj) { if (!obj) {
break; break;
@@ -360,7 +360,7 @@ XPC_SOW_RewrapValue(JSContext *cx, JSObject *wrapperObj, jsval *vp)
return XPC_SOW_WrapFunction(cx, wrapperObj, obj, vp); return XPC_SOW_WrapFunction(cx, wrapperObj, obj, vp);
} }
if (STOBJ_GET_CLASS(obj) == &SOWClass.base) { if (obj->getClass() == &SOWClass.base) {
// We are extra careful about content-polluted wrappers here. I don't know // We are extra careful about content-polluted wrappers here. I don't know
// if it's possible to reach them through objects that we wrap, but figuring // if it's possible to reach them through objects that we wrap, but figuring
// that out is more expensive (and harder) than simply checking and // that out is more expensive (and harder) than simply checking and
@@ -385,7 +385,7 @@ XPC_SOW_RewrapValue(JSContext *cx, JSObject *wrapperObj, jsval *vp)
static JSBool static JSBool
XPC_SOW_AddProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) XPC_SOW_AddProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
{ {
NS_ASSERTION(STOBJ_GET_CLASS(obj) == &SOWClass.base, "Wrong object"); NS_ASSERTION(obj->getClass() == &SOWClass.base, "Wrong object");
jsval resolving; jsval resolving;
if (!JS_GetReservedSlot(cx, obj, sFlagsSlot, &resolving)) { if (!JS_GetReservedSlot(cx, obj, sFlagsSlot, &resolving)) {
@@ -533,7 +533,7 @@ XPC_SOW_Convert(JSContext *cx, JSObject *obj, JSType type, jsval *vp)
return JS_TRUE; return JS_TRUE;
} }
return STOBJ_GET_CLASS(wrappedObj)->convert(cx, wrappedObj, type, vp); return wrappedObj->getClass()->convert(cx, wrappedObj, type, vp);
} }
static JSBool static JSBool
@@ -568,7 +568,7 @@ XPC_SOW_HasInstance(JSContext *cx, JSObject *obj, jsval v, JSBool *bp)
return JS_TRUE; return JS_TRUE;
} }
JSClass *clasp = STOBJ_GET_CLASS(iface); JSClass *clasp = iface->getClass();
*bp = JS_FALSE; *bp = JS_FALSE;
if (!clasp->hasInstance) { if (!clasp->hasInstance) {
@@ -614,7 +614,7 @@ XPC_SOW_Equality(JSContext *cx, JSObject *obj, jsval v, JSBool *bp)
if (lhs) { if (lhs) {
// Delegate to our wrapped object if we can. // Delegate to our wrapped object if we can.
JSClass *clasp = STOBJ_GET_CLASS(lhs); JSClass *clasp = lhs->getClass();
if (clasp->flags & JSCLASS_IS_EXTENDED) { if (clasp->flags & JSCLASS_IS_EXTENDED) {
JSExtendedClass *xclasp = (JSExtendedClass *) clasp; JSExtendedClass *xclasp = (JSExtendedClass *) clasp;
// NB: JSExtendedClass.equality is a required field. // NB: JSExtendedClass.equality is a required field.
@@ -623,7 +623,7 @@ XPC_SOW_Equality(JSContext *cx, JSObject *obj, jsval v, JSBool *bp)
} }
// We know rhs is non-null. // We know rhs is non-null.
JSClass *clasp = STOBJ_GET_CLASS(rhs); JSClass *clasp = rhs->getClass();
if (clasp->flags & JSCLASS_IS_EXTENDED) { if (clasp->flags & JSCLASS_IS_EXTENDED) {
JSExtendedClass *xclasp = (JSExtendedClass *) clasp; JSExtendedClass *xclasp = (JSExtendedClass *) clasp;
// NB: JSExtendedClass.equality is a required field. // NB: JSExtendedClass.equality is a required field.

View File

@@ -59,7 +59,7 @@ const PRUint32 sSecMgrGetProp = nsIXPCSecurityManager::ACCESS_GET_PROPERTY;
JSObject * JSObject *
Unwrap(JSContext *cx, JSObject *wrapper) Unwrap(JSContext *cx, JSObject *wrapper)
{ {
JSClass *clasp = STOBJ_GET_CLASS(wrapper); JSClass *clasp = wrapper->getClass();
if (clasp == &XPCCrossOriginWrapper::XOWClass.base) { if (clasp == &XPCCrossOriginWrapper::XOWClass.base) {
return UnwrapXOW(cx, wrapper); return UnwrapXOW(cx, wrapper);
} }

View File

@@ -285,7 +285,7 @@ MaybePreserveWrapper(JSContext *cx, XPCWrappedNative *wn, uintN flags)
inline JSBool inline JSBool
IsSecurityWrapper(JSObject *wrapper) IsSecurityWrapper(JSObject *wrapper)
{ {
JSClass *clasp = STOBJ_GET_CLASS(wrapper); JSClass *clasp = wrapper->getClass();
return (clasp->flags & JSCLASS_IS_EXTENDED) && return (clasp->flags & JSCLASS_IS_EXTENDED) &&
((JSExtendedClass*)clasp)->wrappedObject; ((JSExtendedClass*)clasp)->wrappedObject;
} }
@@ -309,7 +309,7 @@ Unwrap(JSContext *cx, JSObject *wrapper);
inline JSObject * inline JSObject *
UnwrapGeneric(JSContext *cx, const JSExtendedClass *xclasp, JSObject *wrapper) UnwrapGeneric(JSContext *cx, const JSExtendedClass *xclasp, JSObject *wrapper)
{ {
if (STOBJ_GET_CLASS(wrapper) != &xclasp->base) { if (wrapper->getClass() != &xclasp->base) {
return nsnull; return nsnull;
} }

View File

@@ -1949,7 +1949,7 @@ nsXPConnect::RestoreWrappedNativePrototype(JSContext * aJSContext,
if(NS_FAILED(rv)) if(NS_FAILED(rv))
return UnexpectedFailure(rv); return UnexpectedFailure(rv);
if(!IS_PROTO_CLASS(STOBJ_GET_CLASS(protoJSObject))) if(!IS_PROTO_CLASS(protoJSObject->getClass()))
return UnexpectedFailure(NS_ERROR_INVALID_ARG); return UnexpectedFailure(NS_ERROR_INVALID_ARG);
XPCWrappedNativeScope* scope = XPCWrappedNativeScope* scope =
@@ -2541,7 +2541,7 @@ nsXPConnect::GetWrapperForObject(JSContext* aJSContext,
JSBool sameOrigin; JSBool sameOrigin;
JSBool sameScope = xpc_SameScope(objectscope, xpcscope, &sameOrigin); JSBool sameScope = xpc_SameScope(objectscope, xpcscope, &sameOrigin);
JSBool forceXOW = JSBool forceXOW =
XPCCrossOriginWrapper::ClassNeedsXOW(STOBJ_GET_CLASS(aObject)->name); XPCCrossOriginWrapper::ClassNeedsXOW(aObject->getClass()->name);
// We can do nothing if: // We can do nothing if:
// - We're wrapping a system object // - We're wrapping a system object
@@ -2747,7 +2747,7 @@ nsXPConnect::SetSafeJSContext(JSContext * aSafeJSContext)
nsIPrincipal* nsIPrincipal*
nsXPConnect::GetPrincipal(JSObject* obj, PRBool allowShortCircuit) const nsXPConnect::GetPrincipal(JSObject* obj, PRBool allowShortCircuit) const
{ {
NS_ASSERTION(IS_WRAPPER_CLASS(STOBJ_GET_CLASS(obj)), NS_ASSERTION(IS_WRAPPER_CLASS(obj->getClass()),
"What kind of wrapper is this?"); "What kind of wrapper is this?");
if(IS_WN_WRAPPER_OBJECT(obj)) if(IS_WN_WRAPPER_OBJECT(obj))

View File

@@ -3546,7 +3546,7 @@ xpc_EvalInSandbox(JSContext *cx, JSObject *sandbox, const nsAString& source,
const char *filename, PRInt32 lineNo, const char *filename, PRInt32 lineNo,
JSVersion jsVersion, PRBool returnStringOnly, jsval *rval) JSVersion jsVersion, PRBool returnStringOnly, jsval *rval)
{ {
if (STOBJ_GET_CLASS(sandbox) != &SandboxClass) if (sandbox->getClass() != &SandboxClass)
return NS_ERROR_INVALID_ARG; return NS_ERROR_INVALID_ARG;
nsIScriptObjectPrincipal *sop = nsIScriptObjectPrincipal *sop =

View File

@@ -153,7 +153,7 @@ XPCConvert::IsMethodReflectable(const XPTMethodDescriptor& info)
JSBool JSBool
XPCConvert::GetISupportsFromJSObject(JSObject* obj, nsISupports** iface) XPCConvert::GetISupportsFromJSObject(JSObject* obj, nsISupports** iface)
{ {
JSClass* jsclass = STOBJ_GET_CLASS(obj); JSClass* jsclass = obj->getClass();
NS_ASSERTION(jsclass, "obj has no class"); NS_ASSERTION(jsclass, "obj has no class");
if(jsclass && if(jsclass &&
(jsclass->flags & JSCLASS_HAS_PRIVATE) && (jsclass->flags & JSCLASS_HAS_PRIVATE) &&
@@ -474,7 +474,7 @@ XPCConvert::NativeData2JS(XPCLazyCallContext& lccx, jsval* d, const void* s,
#ifdef DEBUG #ifdef DEBUG
JSObject* jsobj = JSVAL_TO_OBJECT(*d); JSObject* jsobj = JSVAL_TO_OBJECT(*d);
if(jsobj && !jsobj->getParent()) if(jsobj && !jsobj->getParent())
NS_ASSERTION(STOBJ_GET_CLASS(jsobj)->flags & JSCLASS_IS_GLOBAL, NS_ASSERTION(jsobj->getClass()->flags & JSCLASS_IS_GLOBAL,
"Why did we recreate this wrapper?"); "Why did we recreate this wrapper?");
#endif #endif
} }
@@ -1185,7 +1185,7 @@ XPCConvert::NativeInterface2JSObject(XPCLazyCallContext& lccx,
} }
} }
NS_ASSERTION(!flat || IS_WRAPPER_CLASS(STOBJ_GET_CLASS(flat)), NS_ASSERTION(!flat || IS_WRAPPER_CLASS(flat->getClass()),
"What kind of wrapper is this?"); "What kind of wrapper is this?");
nsresult rv; nsresult rv;
@@ -1397,7 +1397,7 @@ XPCConvert::NativeInterface2JSObject(XPCLazyCallContext& lccx,
} }
} }
const char *name = STOBJ_GET_CLASS(flat)->name; const char *name = flat->getClass()->name;
if(allowNativeWrapper && if(allowNativeWrapper &&
!(flags & JSFILENAME_SYSTEM) && !(flags & JSFILENAME_SYSTEM) &&
!JS_IsSystemObject(ccx, flat) && !JS_IsSystemObject(ccx, flat) &&

View File

@@ -428,7 +428,7 @@ static void PrintObjectBasics(JSObject* obj)
{ {
if(OBJ_IS_NATIVE(obj)) if(OBJ_IS_NATIVE(obj))
printf("%p 'native' <%s>", printf("%p 'native' <%s>",
(void *)obj, STOBJ_GET_CLASS(obj)->name); (void *)obj, obj->getClass()->name);
else else
printf("%p 'host'", (void *)obj); printf("%p 'host'", (void *)obj);
} }

View File

@@ -1356,7 +1356,7 @@ xpc_InitWrappedNativeJSOps();
inline JSBool inline JSBool
DebugCheckWrapperClass(JSObject* obj) DebugCheckWrapperClass(JSObject* obj)
{ {
NS_ASSERTION(IS_WRAPPER_CLASS(STOBJ_GET_CLASS(obj)), NS_ASSERTION(IS_WRAPPER_CLASS(obj->getClass()),
"Forgot to check if this is a wrapper?"); "Forgot to check if this is a wrapper?");
return JS_TRUE; return JS_TRUE;
} }
@@ -1367,21 +1367,21 @@ DebugCheckWrapperClass(JSObject* obj)
// also holds a pointer to its XPCWrappedNativeProto in a reserved slot, we can // also holds a pointer to its XPCWrappedNativeProto in a reserved slot, we can
// check that slot for a non-void value to distinguish between the two. // check that slot for a non-void value to distinguish between the two.
// Only use these macros if IS_WRAPPER_CLASS(STOBJ_GET_CLASS(obj)) is true. // Only use these macros if IS_WRAPPER_CLASS(obj->getClass()) is true.
#define IS_WN_WRAPPER_OBJECT(obj) \ #define IS_WN_WRAPPER_OBJECT(obj) \
(DebugCheckWrapperClass(obj) && \ (DebugCheckWrapperClass(obj) && \
JSVAL_IS_VOID(STOBJ_GET_SLOT(obj, JSSLOT_START(STOBJ_GET_CLASS(obj))))) JSVAL_IS_VOID(obj->getSlot(JSSLOT_START(obj->getClass()))))
#define IS_SLIM_WRAPPER_OBJECT(obj) \ #define IS_SLIM_WRAPPER_OBJECT(obj) \
(DebugCheckWrapperClass(obj) && \ (DebugCheckWrapperClass(obj) && \
!JSVAL_IS_VOID(STOBJ_GET_SLOT(obj, JSSLOT_START(STOBJ_GET_CLASS(obj))))) !JSVAL_IS_VOID(obj->getSlot(JSSLOT_START(obj->getClass()))))
// Use these macros if IS_WRAPPER_CLASS(STOBJ_GET_CLASS(obj)) might be false. // Use these macros if IS_WRAPPER_CLASS(obj->getClass()) might be false.
// Avoid calling them if IS_WRAPPER_CLASS(STOBJ_GET_CLASS(obj)) can only be // Avoid calling them if IS_WRAPPER_CLASS(obj->getClass()) can only be
// true, as we'd do a redundant call to IS_WRAPPER_CLASS. // true, as we'd do a redundant call to IS_WRAPPER_CLASS.
#define IS_WN_WRAPPER(obj) \ #define IS_WN_WRAPPER(obj) \
(IS_WRAPPER_CLASS(STOBJ_GET_CLASS(obj)) && IS_WN_WRAPPER_OBJECT(obj)) (IS_WRAPPER_CLASS(obj->getClass()) && IS_WN_WRAPPER_OBJECT(obj))
#define IS_SLIM_WRAPPER(obj) \ #define IS_SLIM_WRAPPER(obj) \
(IS_WRAPPER_CLASS(STOBJ_GET_CLASS(obj)) && IS_SLIM_WRAPPER_OBJECT(obj)) (IS_WRAPPER_CLASS(obj->getClass()) && IS_SLIM_WRAPPER_OBJECT(obj))
// Comes from xpcwrappednativeops.cpp // Comes from xpcwrappednativeops.cpp
extern void extern void
@@ -2238,7 +2238,7 @@ extern JSBool MorphSlimWrapper(JSContext *cx, JSObject *obj);
static inline XPCWrappedNativeProto* static inline XPCWrappedNativeProto*
GetSlimWrapperProto(JSObject *obj) GetSlimWrapperProto(JSObject *obj)
{ {
jsval v = STOBJ_GET_SLOT(obj, JSSLOT_START(STOBJ_GET_CLASS(obj))); jsval v = obj->getSlot(JSSLOT_START(obj->getClass()));
return static_cast<XPCWrappedNativeProto*>(JSVAL_TO_PRIVATE(v)); return static_cast<XPCWrappedNativeProto*>(JSVAL_TO_PRIVATE(v));
} }

View File

@@ -293,7 +293,7 @@ LookupGetterOrSetter(JSContext *cx, JSBool wantGetter, uintN argc, jsval *vp)
? JS_GetStringBytes(JSVAL_TO_STRING(idval)) ? JS_GetStringBytes(JSVAL_TO_STRING(idval))
: nsnull; : nsnull;
if(!name || if(!name ||
!IS_PROTO_CLASS(STOBJ_GET_CLASS(desc.obj)) || !IS_PROTO_CLASS(desc.obj->getClass()) ||
(desc.attrs & (JSPROP_GETTER | JSPROP_SETTER)) || (desc.attrs & (JSPROP_GETTER | JSPROP_SETTER)) ||
!(desc.getter || desc.setter)) !(desc.getter || desc.setter))
{ {
@@ -362,7 +362,7 @@ DefineGetterOrSetter(JSContext *cx, uintN argc, JSBool wantGetter, jsval *vp)
if(!obj2 || if(!obj2 ||
(attrs & (JSPROP_GETTER | JSPROP_SETTER)) || (attrs & (JSPROP_GETTER | JSPROP_SETTER)) ||
!(getter || setter) || !(getter || setter) ||
!IS_PROTO_CLASS(STOBJ_GET_CLASS(obj2))) !IS_PROTO_CLASS(obj2->getClass()))
return forward(cx, argc, vp); return forward(cx, argc, vp);
// Reify the getter and setter... // Reify the getter and setter...
@@ -503,8 +503,8 @@ GetMemberInfo(JSObject *obj,
// but this code often produces a more specific error message, e.g. // but this code often produces a more specific error message, e.g.
*ifaceName = "Unknown"; *ifaceName = "Unknown";
NS_ASSERTION(IS_WRAPPER_CLASS(STOBJ_GET_CLASS(obj)) || NS_ASSERTION(IS_WRAPPER_CLASS(obj->getClass()) ||
STOBJ_GET_CLASS(obj) == &XPC_WN_Tearoff_JSClass, obj->getClass() == &XPC_WN_Tearoff_JSClass,
"obj must be a wrapper"); "obj must be a wrapper");
XPCWrappedNativeProto *proto; XPCWrappedNativeProto *proto;
if(IS_SLIM_WRAPPER(obj)) if(IS_SLIM_WRAPPER(obj))
@@ -1092,7 +1092,7 @@ xpc_qsXPCOMObjectToJsval(XPCLazyCallContext &lccx, nsISupports *p,
#ifdef DEBUG #ifdef DEBUG
JSObject* jsobj = JSVAL_TO_OBJECT(*rval); JSObject* jsobj = JSVAL_TO_OBJECT(*rval);
if(jsobj && !jsobj->getParent()) if(jsobj && !jsobj->getParent())
NS_ASSERTION(STOBJ_GET_CLASS(jsobj)->flags & JSCLASS_IS_GLOBAL, NS_ASSERTION(jsobj->getClass()->flags & JSCLASS_IS_GLOBAL,
"Why did we recreate this wrapper?"); "Why did we recreate this wrapper?");
#endif #endif

View File

@@ -779,7 +779,7 @@ nsXPCWrappedJSClass::DelegatedQueryInterface(nsXPCWrappedJS* self,
PRBool isSystem; PRBool isSystem;
rv = secMan->IsSystemPrincipal(objPrin, &isSystem); rv = secMan->IsSystemPrincipal(objPrin, &isSystem);
if((NS_FAILED(rv) || !isSystem) && if((NS_FAILED(rv) || !isSystem) &&
!IS_WRAPPER_CLASS(STOBJ_GET_CLASS(selfObj))) !IS_WRAPPER_CLASS(selfObj->getClass()))
{ {
// A content object. // A content object.
nsRefPtr<SameOriginCheckedComponent> checked = nsRefPtr<SameOriginCheckedComponent> checked =

View File

@@ -1638,7 +1638,7 @@ XPCWrappedNative::GetWrappedNativeOfJSObject(JSContext* cx,
JSObject* funObjParent = funobj->getParent(); JSObject* funObjParent = funobj->getParent();
NS_ASSERTION(funObjParent, "funobj has no parent"); NS_ASSERTION(funObjParent, "funobj has no parent");
JSClass* funObjParentClass = STOBJ_GET_CLASS(funObjParent); JSClass* funObjParentClass = funObjParent->getClass();
if(IS_PROTO_CLASS(funObjParentClass)) if(IS_PROTO_CLASS(funObjParentClass))
{ {
@@ -1669,7 +1669,7 @@ XPCWrappedNative::GetWrappedNativeOfJSObject(JSContext* cx,
{ {
// this is on two lines to make the compiler happy given the goto. // this is on two lines to make the compiler happy given the goto.
JSClass* clazz; JSClass* clazz;
clazz = STOBJ_GET_CLASS(cur); clazz = cur->getClass();
if(IS_WRAPPER_CLASS(clazz)) if(IS_WRAPPER_CLASS(clazz))
{ {
@@ -1726,7 +1726,7 @@ return_tearoff:
// If we didn't find a wrapper using the given funobj and obj, try // If we didn't find a wrapper using the given funobj and obj, try
// again with obj's outer object, if it's got one. // again with obj's outer object, if it's got one.
JSClass *clazz = STOBJ_GET_CLASS(obj); JSClass *clazz = obj->getClass();
if((clazz->flags & JSCLASS_IS_EXTENDED) && if((clazz->flags & JSCLASS_IS_EXTENDED) &&
((JSExtendedClass*)clazz)->outerObject) ((JSExtendedClass*)clazz)->outerObject)
@@ -1735,7 +1735,7 @@ return_tearoff:
// Protect against infinite recursion through XOWs. // Protect against infinite recursion through XOWs.
JSObject *unsafeObj; JSObject *unsafeObj;
clazz = STOBJ_GET_CLASS(outer); clazz = outer->getClass();
if(clazz == &XPCCrossOriginWrapper::XOWClass.base && if(clazz == &XPCCrossOriginWrapper::XOWClass.base &&
(unsafeObj = XPCWrapper::UnwrapXOW(cx, outer))) (unsafeObj = XPCWrapper::UnwrapXOW(cx, outer)))
{ {

View File

@@ -853,7 +853,7 @@ XPC_WN_Equality(JSContext *cx, JSObject *obj, jsval v, JSBool *bp)
return Throw(rv, cx); return Throw(rv, cx);
if(!*bp && !JSVAL_IS_PRIMITIVE(v) && if(!*bp && !JSVAL_IS_PRIMITIVE(v) &&
STOBJ_GET_CLASS(JSVAL_TO_OBJECT(v)) == &XPCSafeJSObjectWrapper::SJOWClass.base) JSVAL_TO_OBJECT(v)->getClass() == &XPCSafeJSObjectWrapper::SJOWClass.base)
{ {
v = OBJECT_TO_JSVAL(XPCSafeJSObjectWrapper::GetUnsafeObject(cx, JSVAL_TO_OBJECT(v))); v = OBJECT_TO_JSVAL(XPCSafeJSObjectWrapper::GetUnsafeObject(cx, JSVAL_TO_OBJECT(v)));
@@ -1327,7 +1327,7 @@ static JSBool
XPC_WN_JSOp_Enumerate(JSContext *cx, JSObject *obj, JSIterateOp enum_op, XPC_WN_JSOp_Enumerate(JSContext *cx, JSObject *obj, JSIterateOp enum_op,
jsval *statep, jsid *idp) jsval *statep, jsid *idp)
{ {
JSClass *clazz = STOBJ_GET_CLASS(obj); JSClass *clazz = obj->getClass();
if(!IS_WRAPPER_CLASS(clazz) || clazz == &XPC_WN_NoHelper_JSClass.base) if(!IS_WRAPPER_CLASS(clazz) || clazz == &XPC_WN_NoHelper_JSClass.base)
{ {
// obj must be a prototype object or a wrapper w/o a // obj must be a prototype object or a wrapper w/o a

View File

@@ -240,7 +240,7 @@ XPCWrappedNativeScope::SetGlobal(XPCCallContext& ccx, JSObject* aGlobal)
mScriptObjectPrincipal = nsnull; mScriptObjectPrincipal = nsnull;
// Now init our script object principal, if the new global has one // Now init our script object principal, if the new global has one
const JSClass* jsClass = STOBJ_GET_CLASS(aGlobal); const JSClass* jsClass = aGlobal->getClass();
if(!(~jsClass->flags & (JSCLASS_HAS_PRIVATE | if(!(~jsClass->flags & (JSCLASS_HAS_PRIVATE |
JSCLASS_PRIVATE_IS_NSISUPPORTS))) JSCLASS_PRIVATE_IS_NSISUPPORTS)))
{ {
@@ -719,7 +719,7 @@ XPCWrappedNativeScope*
GetScopeOfObject(JSObject* obj) GetScopeOfObject(JSObject* obj)
{ {
nsISupports* supports; nsISupports* supports;
JSClass* clazz = STOBJ_GET_CLASS(obj); JSClass* clazz = obj->getClass();
JSBool isWrapper = IS_WRAPPER_CLASS(clazz); JSBool isWrapper = IS_WRAPPER_CLASS(clazz);
if(isWrapper && IS_SLIM_WRAPPER_OBJECT(obj)) if(isWrapper && IS_SLIM_WRAPPER_OBJECT(obj))