Bug 770092 (part 1) - Move the new script notification code out of JSScript::fullyInitFromEmitter().

--HG--
extra : rebase_source : 03bc8061c11874af7bbf1a9b3edf49bec5601e80
This commit is contained in:
Nicholas Nethercote 2012-07-02 00:01:54 -07:00
parent 116e4b0304
commit 72929eae3f
4 changed files with 22 additions and 12 deletions

View File

@ -235,6 +235,8 @@ frontend::CompileScript(JSContext *cx, HandleObject scopeChain, StackFrame *call
if (!script->fullyInitFromEmitter(cx, &bce))
return NULL;
bce.tellDebuggerAboutCompiledScript(cx);
if (!MarkInnerAndOuterFunctions(cx, script))
return NULL;

View File

@ -36,6 +36,7 @@
#include "frontend/BytecodeEmitter.h"
#include "frontend/Parser.h"
#include "frontend/TokenStream.h"
#include "vm/Debugger.h"
#include "vm/RegExpObject.h"
#include "jsatominlines.h"
@ -1587,6 +1588,21 @@ BytecodeEmitter::needsImplicitThis()
return false;
}
void
BytecodeEmitter::tellDebuggerAboutCompiledScript(JSContext *cx)
{
js_CallNewScriptHook(cx, script, script->function());
if (!parent) {
GlobalObject *compileAndGoGlobal = NULL;
if (script->compileAndGo) {
compileAndGoGlobal = script->globalObject;
if (!compileAndGoGlobal)
compileAndGoGlobal = &sc->scopeChain()->global();
}
Debugger::onNewScript(cx, script, compileAndGoGlobal);
}
}
bool
BytecodeEmitter::reportError(ParseNode *pn, unsigned errorNumber, ...)
{
@ -2553,6 +2569,8 @@ frontend::EmitFunctionScript(JSContext *cx, BytecodeEmitter *bce, ParseNode *bod
if (!bce->script->fullyInitFromEmitter(cx, bce))
return false;
bce->tellDebuggerAboutCompiledScript(cx);
return true;
}

View File

@ -176,6 +176,8 @@ struct BytecodeEmitter
bool needsImplicitThis();
void tellDebuggerAboutCompiledScript(JSContext *cx);
TokenStream *tokenStream() { return &parser->tokenStream; }
jsbytecode *base() const { return current->base; }

View File

@ -1365,18 +1365,6 @@ JSScript::fullyInitFromEmitter(JSContext *cx, BytecodeEmitter *bce)
fun->setScript(script);
}
/* Tell the debugger about this compiled script. */
js_CallNewScriptHook(cx, script, fun);
if (!bce->parent) {
GlobalObject *compileAndGoGlobal = NULL;
if (script->compileAndGo) {
compileAndGoGlobal = script->globalObject;
if (!compileAndGoGlobal)
compileAndGoGlobal = &bce->sc->scopeChain()->global();
}
Debugger::onNewScript(cx, script, compileAndGoGlobal);
}
/*
* initScriptCounts updates scriptCountsMap if necessary. The other script
* maps in JSCompartment are populated lazily.