Readd jsparse.cpp and jsparse.h changes for bug 548702.

This commit is contained in:
Jeff Walden 2010-03-29 12:03:43 -07:00
parent 739d62b244
commit bfbc9141af
2 changed files with 13 additions and 17 deletions

View File

@ -172,7 +172,6 @@ JSCompiler::init(const jschar *base, size_t length,
/* Root atoms and objects allocated for the parsed tree. */
JS_KEEP_ATOMS(cx->runtime);
JS_PUSH_TEMP_ROOT_COMPILER(cx, this, &tempRoot);
return true;
}
@ -182,8 +181,6 @@ JSCompiler::~JSCompiler()
if (principals)
JSPRINCIPALS_DROP(cx, principals);
JS_ASSERT(tempRoot.u.compiler == this);
JS_POP_TEMP_ROOT(cx, &tempRoot);
JS_UNKEEP_ATOMS(cx->runtime);
tokenStream.close();
JS_ARENA_RELEASE(&cx->tempPool, tempPoolMark);
@ -288,10 +285,7 @@ JSFunctionBox::shouldUnbrand(uintN methods, uintN slowMethods) const
void
JSCompiler::trace(JSTracer *trc)
{
JSObjectBox *objbox;
JS_ASSERT(tempRoot.u.compiler == this);
objbox = traceListHead;
JSObjectBox *objbox = traceListHead;
while (objbox) {
JS_CALL_OBJECT_TRACER(trc, objbox->object, "parser.object");
objbox = objbox->traceLink;
@ -8715,7 +8709,6 @@ FoldXMLConstants(JSContext *cx, JSParseNode *pn, JSTreeContext *tc)
JSParseNode **pnp, *pn1, *pn2;
JSString *accum, *str;
uint32 i, j;
JSTempValueRooter tvr;
JS_ASSERT(pn->pn_arity == PN_LIST);
tt = PN_TYPE(pn);
@ -8806,11 +8799,12 @@ FoldXMLConstants(JSContext *cx, JSParseNode *pn, JSTreeContext *tc)
}
if (accum) {
JS_PUSH_TEMP_ROOT_STRING(cx, accum, &tvr);
str = ((tt == TOK_XMLSTAGO || tt == TOK_XMLPTAGC) && i != 0)
? js_AddAttributePart(cx, i & 1, accum, str)
: js_ConcatStrings(cx, accum, str);
JS_POP_TEMP_ROOT(cx, &tvr);
{
AutoValueRooter tvr(cx, accum);
str = ((tt == TOK_XMLSTAGO || tt == TOK_XMLPTAGC) && i != 0)
? js_AddAttributePart(cx, i & 1, accum, str)
: js_ConcatStrings(cx, accum, str);
}
if (!str)
return JS_FALSE;
#ifdef DEBUG_brendanXXX

View File

@ -912,8 +912,8 @@ class JSTreeContext;
typedef struct BindData BindData;
struct JSCompiler {
JSContext * const context;
struct JSCompiler : private js::AutoGCRooter {
JSContext * const context; /* FIXME Bug 551291: use AutoGCRooter::context? */
JSAtomListElement *aleFreeList;
void *tempFreeList[NUM_TEMP_FREELISTS];
js::TokenStream tokenStream;
@ -925,10 +925,9 @@ struct JSCompiler {
uint32 functionCount; /* number of functions in current unit */
JSObjectBox *traceListHead; /* list of parsed object for GC tracing */
JSTreeContext *tc; /* innermost tree context (stack-allocated) */
JSTempValueRooter tempRoot; /* root to trace traceListHead */
JSCompiler(JSContext *cx, JSPrincipals *prin = NULL, JSStackFrame *cfp = NULL)
: context(cx),
: js::AutoGCRooter(cx, COMPILER), context(cx),
aleFreeList(NULL), tokenStream(cx), principals(NULL), callerFrame(cfp),
callerVarObj(cfp ? cfp->varobj(cx->containingCallStack(cfp)) : NULL),
nodeList(NULL), functionCount(0), traceListHead(NULL), tc(NULL)
@ -940,6 +939,9 @@ struct JSCompiler {
~JSCompiler();
friend void js::AutoGCRooter::trace(JSTracer *trc);
friend class JSTreeContext;
/*
* Initialize a compiler. Parameters are passed on to init tokenStream.
* The compiler owns the arena pool "tops-of-stack" space above the current