Bug 955838 - Remove JSScript::enclosingScriptsCompiledSuccessfully() and some unused friend API functions. r=bhackett

This commit is contained in:
Jan de Mooij 2014-01-03 11:19:50 +01:00
Родитель 415c36488e
Коммит a45b34226f
6 изменённых файлов: 1 добавлений и 93 удалений

Просмотреть файл

@ -496,12 +496,6 @@ JS_DefineProfilingFunctions(JSContext *cx, JSObject *obj);
extern JS_PUBLIC_API(bool) extern JS_PUBLIC_API(bool)
JS_DefineDebuggerObject(JSContext *cx, JSObject *obj); JS_DefineDebuggerObject(JSContext *cx, JSObject *obj);
extern JS_PUBLIC_API(void)
JS_DumpBytecode(JSContext *cx, JSScript *script);
extern JS_PUBLIC_API(void)
JS_DumpCompartmentBytecode(JSContext *cx);
extern JS_PUBLIC_API(void) extern JS_PUBLIC_API(void)
JS_DumpPCCounts(JSContext *cx, JSScript *script); JS_DumpPCCounts(JSContext *cx, JSScript *script);

Просмотреть файл

@ -443,12 +443,6 @@ js::RunningWithTrustedPrincipals(JSContext *cx)
return cx->runningWithTrustedPrincipals(); return cx->runningWithTrustedPrincipals();
} }
JS_FRIEND_API(bool)
js::IsOriginalScriptFunction(JSFunction *fun)
{
return fun->nonLazyScript()->function() == fun;
}
JS_FRIEND_API(JSScript *) JS_FRIEND_API(JSScript *)
js::GetOutermostEnclosingFunctionOfScriptedCaller(JSContext *cx) js::GetOutermostEnclosingFunctionOfScriptedCaller(JSContext *cx)
{ {

Просмотреть файл

@ -512,9 +512,6 @@ SetDefaultObjectForContext(JSContext *cx, JSObject *obj);
JS_FRIEND_API(void) JS_FRIEND_API(void)
NotifyAnimationActivity(JSObject *obj); NotifyAnimationActivity(JSObject *obj);
JS_FRIEND_API(bool)
IsOriginalScriptFunction(JSFunction *fun);
/* /*
* Return the outermost enclosing function (script) of the scripted caller. * Return the outermost enclosing function (script) of the scripted caller.
* This function returns nullptr in several cases: * This function returns nullptr in several cases:

Просмотреть файл

@ -2102,30 +2102,6 @@ JSScript::uninlinedGlobal() const
return global(); return global();
} }
bool
JSScript::enclosingScriptsCompiledSuccessfully() const
{
/*
* When a nested script is succesfully compiled, it is eagerly given the
* static JSFunction of its enclosing script. The enclosing function's
* 'script' field will be nullptr until the enclosing script successfully
* compiles. Thus, we can detect failed compilation by looking for
* JSFunctions in the enclosingScope chain without scripts.
*/
JSObject *enclosing = enclosingStaticScope();
while (enclosing) {
if (enclosing->is<JSFunction>()) {
JSFunction *fun = &enclosing->as<JSFunction>();
if (!fun->hasScript() || !fun->nonLazyScript())
return false;
enclosing = fun->nonLazyScript()->enclosingStaticScope();
} else {
enclosing = enclosing->as<StaticBlockObject>().enclosingStaticScope();
}
}
return true;
}
void void
js::CallNewScriptHook(JSContext *cx, HandleScript script, HandleFunction fun) js::CallNewScriptHook(JSContext *cx, HandleScript script, HandleFunction fun)
{ {

Просмотреть файл

@ -1247,18 +1247,6 @@ class JSScript : public js::gc::BarrieredCell<JSScript>
return enclosingScopeOrOriginalFunction_; return enclosingScopeOrOriginalFunction_;
} }
/*
* If a compile error occurs in an enclosing function after parsing a
* nested function, the enclosing function's JSFunction, which appears on
* the nested function's enclosingScope chain, will be invalid. Normal VM
* operation only sees scripts where all enclosing scripts have been
* successfully compiled. Any path that may look at scripts left over from
* unsuccessful compilation (e.g., by iterating over all scripts in the
* compartment) should check this predicate before doing any operation that
* uses enclosingScope (e.g., ScopeCoordinateName).
*/
bool enclosingScriptsCompiledSuccessfully() const;
private: private:
bool makeTypes(JSContext *cx); bool makeTypes(JSContext *cx);
bool makeAnalysis(JSContext *cx); bool makeAnalysis(JSContext *cx);

Просмотреть файл

@ -833,23 +833,6 @@ JS_GetGlobalDebugHooks(JSRuntime *rt)
/************************************************************************/ /************************************************************************/
JS_PUBLIC_API(void)
JS_DumpBytecode(JSContext *cx, JSScript *scriptArg)
{
#if defined(DEBUG)
Rooted<JSScript*> script(cx, scriptArg);
Sprinter sprinter(cx);
if (!sprinter.init())
return;
fprintf(stdout, "--- SCRIPT %s:%d ---\n", script->filename(), (int) script->lineno());
js_Disassemble(cx, script, true, &sprinter);
fputs(sprinter.string(), stdout);
fprintf(stdout, "--- END SCRIPT %s:%d ---\n", script->filename(), (int) script->lineno());
#endif
}
extern JS_PUBLIC_API(void) extern JS_PUBLIC_API(void)
JS_DumpPCCounts(JSContext *cx, JSScript *scriptArg) JS_DumpPCCounts(JSContext *cx, JSScript *scriptArg)
{ {
@ -866,30 +849,6 @@ JS_DumpPCCounts(JSContext *cx, JSScript *scriptArg)
fprintf(stdout, "--- END SCRIPT %s:%d ---\n", script->filename(), (int) script->lineno()); fprintf(stdout, "--- END SCRIPT %s:%d ---\n", script->filename(), (int) script->lineno());
} }
namespace {
typedef Vector<JSScript *, 0, SystemAllocPolicy> ScriptsToDump;
static void
DumpBytecodeScriptCallback(JSRuntime *rt, void *data, JSScript *script)
{
static_cast<ScriptsToDump *>(data)->append(script);
}
} /* anonymous namespace */
JS_PUBLIC_API(void)
JS_DumpCompartmentBytecode(JSContext *cx)
{
ScriptsToDump scripts;
IterateScripts(cx->runtime(), cx->compartment(), &scripts, DumpBytecodeScriptCallback);
for (size_t i = 0; i < scripts.length(); i++) {
if (scripts[i]->enclosingScriptsCompiledSuccessfully())
JS_DumpBytecode(cx, scripts[i]);
}
}
JS_PUBLIC_API(void) JS_PUBLIC_API(void)
JS_DumpCompartmentPCCounts(JSContext *cx) JS_DumpCompartmentPCCounts(JSContext *cx)
{ {
@ -898,7 +857,7 @@ JS_DumpCompartmentPCCounts(JSContext *cx)
if (script->compartment() != cx->compartment()) if (script->compartment() != cx->compartment())
continue; continue;
if (script->hasScriptCounts() && script->enclosingScriptsCompiledSuccessfully()) if (script->hasScriptCounts())
JS_DumpPCCounts(cx, script); JS_DumpPCCounts(cx, script);
} }