mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-23 02:05:42 +00:00
Bug 1095145: Remove compileAndGoGlobal argument to Debugger::onNewScript, and simplify accordingly. r=shu
--HG-- extra : rebase_source : d07242d14f9bf46584ebefbdf94c9856f632adad extra : amend_source : f05f1a446818d95d9117b0c3e24b693a3503494e
This commit is contained in:
parent
c097b35626
commit
c29779df0f
@ -509,8 +509,7 @@ js::ExecuteInGlobalAndReturnScope(JSContext *cx, HandleObject global, HandleScri
|
||||
if (!script)
|
||||
return false;
|
||||
|
||||
Rooted<GlobalObject *> global(cx, script->compileAndGo() ? &script->global() : nullptr);
|
||||
Debugger::onNewScript(cx, script, global);
|
||||
Debugger::onNewScript(cx, script);
|
||||
}
|
||||
|
||||
RootedObject scope(cx, JS_NewPlainObject(cx));
|
||||
|
@ -2197,10 +2197,7 @@ BytecodeEmitter::tellDebuggerAboutCompiledScript(ExclusiveContext *cx)
|
||||
// Lazy scripts are never top level (despite always being invoked with a
|
||||
// nullptr parent), and so the hook should never be fired.
|
||||
if (emitterMode != LazyFunction && !parent) {
|
||||
GlobalObject *compileAndGoGlobal = nullptr;
|
||||
if (script->compileAndGo())
|
||||
compileAndGoGlobal = &script->global();
|
||||
Debugger::onNewScript(cx->asJSContext(), script, compileAndGoGlobal);
|
||||
Debugger::onNewScript(cx->asJSContext(), script);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4273,8 +4273,7 @@ JS::CloneAndExecuteScript(JSContext *cx, HandleObject obj, HandleScript scriptAr
|
||||
if (!script)
|
||||
return false;
|
||||
|
||||
Rooted<GlobalObject *> global(cx, script->compileAndGo() ? &script->global() : nullptr);
|
||||
js::Debugger::onNewScript(cx, script, global);
|
||||
js::Debugger::onNewScript(cx, script);
|
||||
}
|
||||
return ExecuteScript(cx, obj, script, nullptr);
|
||||
}
|
||||
|
@ -1090,10 +1090,8 @@ js::XDRScript(XDRState<mode> *xdr, HandleObject enclosingScope, HandleScript enc
|
||||
scriptp.set(script);
|
||||
|
||||
/* see BytecodeEmitter::tellDebuggerAboutCompiledScript */
|
||||
if (!fun) {
|
||||
RootedGlobalObject global(cx, script->compileAndGo() ? &script->global() : nullptr);
|
||||
Debugger::onNewScript(cx, script, global);
|
||||
}
|
||||
if (!fun)
|
||||
Debugger::onNewScript(cx, script);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -3191,8 +3189,7 @@ js::CloneFunctionScript(JSContext *cx, HandleFunction original, HandleFunction c
|
||||
cscript->setFunction(clone);
|
||||
|
||||
script = clone->nonLazyScript();
|
||||
RootedGlobalObject global(cx, script->compileAndGo() ? &script->global() : nullptr);
|
||||
Debugger::onNewScript(cx, script, global);
|
||||
Debugger::onNewScript(cx, script);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1302,47 +1302,27 @@ Debugger::dispatchHook(JSContext *cx, MutableHandleValue vp, Hook which, HandleO
|
||||
return JSTRAP_CONTINUE;
|
||||
}
|
||||
|
||||
static bool
|
||||
AddNewScriptRecipients(GlobalObject::DebuggerVector *src, HandleScript script,
|
||||
AutoValueVector *dest)
|
||||
{
|
||||
bool wasEmpty = dest->length() == 0;
|
||||
for (Debugger **p = src->begin(); p != src->end(); p++) {
|
||||
Debugger *dbg = *p;
|
||||
Value v = ObjectValue(*dbg->toJSObject());
|
||||
if (dbg->observesScript(script) && dbg->observesNewScript() &&
|
||||
(wasEmpty || Find(dest->begin(), dest->end(), v) == dest->end()) &&
|
||||
!dest->append(v))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
Debugger::slowPathOnNewScript(JSContext *cx, HandleScript script, GlobalObject *compileAndGoGlobal_)
|
||||
Debugger::slowPathOnNewScript(JSContext *cx, HandleScript script)
|
||||
{
|
||||
Rooted<GlobalObject*> compileAndGoGlobal(cx, compileAndGoGlobal_);
|
||||
|
||||
MOZ_ASSERT(script->compileAndGo() == !!compileAndGoGlobal);
|
||||
Rooted<GlobalObject*> global(cx, &script->global());
|
||||
|
||||
/*
|
||||
* Build the list of recipients based on the debuggers observing the
|
||||
* script's compartment.
|
||||
*
|
||||
* TODO bug 1064079 will simplify this logic. The meaning of
|
||||
* compile-and-go has changed over the years and is no longer relevant to
|
||||
* Debugger.
|
||||
*/
|
||||
AutoValueVector triggered(cx);
|
||||
GlobalObject::DebuggerVector *debuggers =
|
||||
(script->compileAndGo()
|
||||
? compileAndGoGlobal->getDebuggers()
|
||||
: script->compartment()->maybeGlobal()->getDebuggers());
|
||||
GlobalObject::DebuggerVector *debuggers = global->getDebuggers();
|
||||
if (debuggers) {
|
||||
if (!AddNewScriptRecipients(debuggers, script, &triggered))
|
||||
return;
|
||||
for (Debugger **p = debuggers->begin(); p != debuggers->end(); p++) {
|
||||
Debugger *dbg = *p;
|
||||
if (dbg->observesNewScript() && dbg->observesScript(script)) {
|
||||
if (!triggered.append(ObjectValue(*dbg->toJSObject()))) {
|
||||
js_ReportOutOfMemory(cx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1351,8 +1331,10 @@ Debugger::slowPathOnNewScript(JSContext *cx, HandleScript script, GlobalObject *
|
||||
*/
|
||||
for (Value *p = triggered.begin(); p != triggered.end(); p++) {
|
||||
Debugger *dbg = Debugger::fromJSObject(&p->toObject());
|
||||
if ((!compileAndGoGlobal || dbg->debuggees.has(compileAndGoGlobal)) &&
|
||||
dbg->enabled && dbg->getHook(OnNewScript)) {
|
||||
if (dbg->debuggees.has(global) &&
|
||||
dbg->enabled &&
|
||||
dbg->getHook(OnNewScript))
|
||||
{
|
||||
dbg->fireNewScript(cx, script);
|
||||
}
|
||||
}
|
||||
|
@ -454,8 +454,7 @@ class Debugger : private mozilla::LinkedListElement<Debugger>
|
||||
static bool slowPathOnLeaveFrame(JSContext *cx, AbstractFramePtr frame, bool ok);
|
||||
static JSTrapStatus slowPathOnDebuggerStatement(JSContext *cx, AbstractFramePtr frame);
|
||||
static JSTrapStatus slowPathOnExceptionUnwind(JSContext *cx, AbstractFramePtr frame);
|
||||
static void slowPathOnNewScript(JSContext *cx, HandleScript script,
|
||||
GlobalObject *compileAndGoGlobal);
|
||||
static void slowPathOnNewScript(JSContext *cx, HandleScript script);
|
||||
static void slowPathOnNewGlobalObject(JSContext *cx, Handle<GlobalObject *> global);
|
||||
static bool slowPathOnLogAllocationSite(JSContext *cx, HandleSavedFrame frame,
|
||||
int64_t when, GlobalObject::DebuggerVector &dbgs);
|
||||
@ -600,7 +599,7 @@ class Debugger : private mozilla::LinkedListElement<Debugger>
|
||||
*/
|
||||
static inline bool onLeaveFrame(JSContext *cx, AbstractFramePtr frame, bool ok);
|
||||
|
||||
static inline void onNewScript(JSContext *cx, HandleScript script, GlobalObject *compileAndGoGlobal);
|
||||
static inline void onNewScript(JSContext *cx, HandleScript script);
|
||||
static inline void onNewGlobalObject(JSContext *cx, Handle<GlobalObject *> global);
|
||||
static inline bool onLogAllocationSite(JSContext *cx, HandleSavedFrame frame, int64_t when);
|
||||
static JSTrapStatus onTrap(JSContext *cx, MutableHandleValue vp);
|
||||
@ -878,18 +877,15 @@ Debugger::observesGlobal(GlobalObject *global) const
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
Debugger::onNewScript(JSContext *cx, HandleScript script, GlobalObject *compileAndGoGlobal)
|
||||
Debugger::onNewScript(JSContext *cx, HandleScript script)
|
||||
{
|
||||
MOZ_ASSERT_IF(script->compileAndGo(), compileAndGoGlobal);
|
||||
MOZ_ASSERT_IF(script->compileAndGo(), compileAndGoGlobal == &script->uninlinedGlobal());
|
||||
// We early return in slowPathOnNewScript for self-hosted scripts, so we can
|
||||
// ignore those in our assertion here.
|
||||
MOZ_ASSERT_IF(!script->compartment()->options().invisibleToDebugger() &&
|
||||
!script->selfHosted(),
|
||||
script->compartment()->firedOnNewGlobalObject);
|
||||
MOZ_ASSERT_IF(!script->compileAndGo(), !compileAndGoGlobal);
|
||||
if (script->compartment()->isDebuggee())
|
||||
slowPathOnNewScript(cx, script, compileAndGoGlobal);
|
||||
slowPathOnNewScript(cx, script);
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
|
@ -932,10 +932,7 @@ GlobalHelperThreadState::finishParseTask(JSContext *maybecx, JSRuntime *rt, void
|
||||
|
||||
if (script) {
|
||||
// The Debugger only needs to be told about the topmost script that was compiled.
|
||||
GlobalObject *compileAndGoGlobal = nullptr;
|
||||
if (script->compileAndGo())
|
||||
compileAndGoGlobal = &script->global();
|
||||
Debugger::onNewScript(cx, script, compileAndGoGlobal);
|
||||
Debugger::onNewScript(cx, script);
|
||||
|
||||
// Update the compressed source table with the result. This is normally
|
||||
// called by setCompressedSource when compilation occurs on the main thread.
|
||||
|
Loading…
Reference in New Issue
Block a user