Add verbose native stack frame printing.

This commit is contained in:
Andreas Gal 2008-07-09 17:09:22 -07:00
parent 25d02bc059
commit a529e2f6b2

View File

@ -587,8 +587,10 @@ static bool
unbox_jsval(jsval v, uint8 t, double* slot)
{
jsuint type = TYPEMAP_GET_TYPE(t);
if (type == TYPEMAP_TYPE_ANY)
if (type == TYPEMAP_TYPE_ANY) {
verbose_only(printf("any ");)
return true;
}
if (type == JSVAL_INT) {
jsint i;
if (JSVAL_IS_INT(v))
@ -597,6 +599,7 @@ unbox_jsval(jsval v, uint8 t, double* slot)
*(jsint*)slot = i;
else
return false;
verbose_only(printf("int<%d> ", i);)
return true;
}
if (type == JSVAL_DOUBLE) {
@ -608,6 +611,7 @@ unbox_jsval(jsval v, uint8 t, double* slot)
else
return false;
*(jsdouble*)slot = d;
verbose_only(printf("double<%g> ", d);)
return true;
}
if (JSVAL_TAG(v) != type)
@ -615,13 +619,17 @@ unbox_jsval(jsval v, uint8 t, double* slot)
switch (JSVAL_TAG(v)) {
case JSVAL_BOOLEAN:
*(bool*)slot = JSVAL_TO_BOOLEAN(v);
verbose_only(printf("boolean<%d> ", *(bool*)slot);)
break;
case JSVAL_STRING:
*(JSString**)slot = JSVAL_TO_STRING(v);
verbose_only(printf("string<%p> ", *(JSString**)slot);)
break;
default:
JS_ASSERT(JSVAL_IS_GCTHING(v));
*(void**)slot = JSVAL_TO_GCTHING(v);
JS_ASSERT(JSVAL_IS_OBJECT(v));
*(JSObject**)slot = JSVAL_TO_OBJECT(v);
verbose_only(printf("object<%p:%s> ", *(JSObject**)slot,
STOBJ_GET_CLASS(JSVAL_TO_OBJECT(v))->name);)
}
return true;
}
@ -633,16 +641,20 @@ static bool
box_jsval(JSContext* cx, jsval& v, uint8 t, double* slot)
{
jsuint type = TYPEMAP_GET_TYPE(t);
if (type == TYPEMAP_TYPE_ANY)
if (type == TYPEMAP_TYPE_ANY) {
verbose_only(printf("any ");)
return true;
}
jsint i;
jsdouble d;
switch (type) {
case JSVAL_BOOLEAN:
v = BOOLEAN_TO_JSVAL(*(bool*)slot);
verbose_only(printf("boolean<%d> ", *(bool*)slot);)
break;
case JSVAL_INT:
i = *(jsint*)slot;
verbose_only(printf("int<%d> ", i);)
store_int:
if (INT_FITS_IN_JSVAL(i)) {
v = INT_TO_JSVAL(i);
@ -652,6 +664,7 @@ box_jsval(JSContext* cx, jsval& v, uint8 t, double* slot)
goto store_double;
case JSVAL_DOUBLE:
d = *slot;
verbose_only(printf("double<%g> ", d);)
if (JSDOUBLE_IS_INT(d, i))
goto store_int;
store_double:
@ -661,10 +674,12 @@ box_jsval(JSContext* cx, jsval& v, uint8 t, double* slot)
return js_NewDoubleInRootedValue(cx, d, &v);
case JSVAL_STRING:
v = STRING_TO_JSVAL(*(JSString**)slot);
verbose_only(printf("string<%p> ", *(JSString**)slot);)
break;
default:
JS_ASSERT(t == JSVAL_OBJECT);
v = OBJECT_TO_JSVAL(*(JSObject**)slot);
verbose_only(printf("object<%p> ", *(JSObject**)slot);)
break;
}
return true;
@ -675,11 +690,13 @@ box_jsval(JSContext* cx, jsval& v, uint8 t, double* slot)
static bool
unbox(JSStackFrame* entryFrame, JSStackFrame* currentFrame, uint8* m, double* native)
{
verbose_only(printf("unbox native@%p ", native);)
FORALL_SLOTS_IN_PENDING_FRAMES(entryFrame, currentFrame,
if (vp && !unbox_jsval(*vp, *m, native))
return false;
++m; ++native
);
verbose_only(printf("\n");)
return true;
}
@ -688,11 +705,13 @@ unbox(JSStackFrame* entryFrame, JSStackFrame* currentFrame, uint8* m, double* na
static bool
box(JSContext* cx, JSStackFrame* entryFrame, JSStackFrame* currentFrame, uint8* m, double* native)
{
verbose_only(printf("box native@%p ", native);)
FORALL_SLOTS_IN_PENDING_FRAMES(entryFrame, currentFrame,
if (vp && !box_jsval(cx, *vp, *m, native))
return false;
++m; ++native
);
verbose_only(printf("\n");)
return true;
}