Add dump() to JSString, JSAtom, and JSObject as an easier-to-type alias to js_Dump*. Also add equals(const char*) methods to JSAtom and JSString. These methods are all to be used *only* while debugging. No bug, rs=luke over IRC

This commit is contained in:
Jeff Walden 2012-01-31 15:48:27 -08:00
parent 3f191286a8
commit 3e916d11bc
4 changed files with 45 additions and 0 deletions

View File

@ -6709,6 +6709,12 @@ DumpProperty(JSObject *obj, const Shape &shape)
fprintf(stderr, "\n");
}
void
JSObject::dump()
{
js_DumpObject(this);
}
JS_FRIEND_API(void)
js_DumpObject(JSObject *obj)
{

View File

@ -1474,6 +1474,9 @@ struct JSObject : js::gc::Cell
JS_STATIC_ASSERT(offsetof(JSObject, type_) == offsetof(js::shadow::Object, type));
JS_STATIC_ASSERT(sizeof(JSObject) == sizeof(js::shadow::Object));
}
/* For debugging purposes only! */
void dump();
};
/*

View File

@ -114,6 +114,29 @@ JSString::sizeOfExcludingThis(JSMallocSizeOfFun mallocSizeOf)
return mallocSizeOf(fixed.chars());
}
void
JSString::dump()
{
js_DumpString(this);
}
bool
JSString::equals(const char *s)
{
const jschar *c = getChars(NULL);
if (!c) {
fprintf(stderr, "OOM in JSString::equals!\n");
return false;
}
while (*c && *s) {
if (*c != *s)
return false;
c++;
s++;
}
return *c == *s;
}
static JS_ALWAYS_INLINE bool
AllocChars(JSContext *maybecx, size_t length, jschar **chars, size_t *capacity)
{
@ -390,6 +413,12 @@ JSFlatString::isIndex(uint32_t *indexp) const
return false;
}
void
JSAtom::dump()
{
js_DumpAtom(this);
}
/*
* Set up some tools to make it easier to generate large tables. After constant
* folding, for each n, Rn(0) is the comma-separated list R(0), R(1), ..., R(2^n-1).

View File

@ -198,6 +198,10 @@ class JSString : public js::gc::Cell
};
} d;
/* These are for debugging purposes only! */
void dump();
bool equals(const char *s);
public:
/* Flags exposed only for jits */
@ -693,6 +697,9 @@ class JSAtom : public JSFixedString
bool isAtom() const MOZ_DELETE;
JSAtom &asAtom() const MOZ_DELETE;
/* This is for debugging purposes only! */
void dump();
public:
/* Returns the PropertyName for this. isIndex() must be false. */
inline js::PropertyName *asPropertyName();