From a45b34226f1e829c0d6724004ad122dfd95f5681 Mon Sep 17 00:00:00 2001 From: Jan de Mooij Date: Fri, 3 Jan 2014 11:19:50 +0100 Subject: [PATCH] Bug 955838 - Remove JSScript::enclosingScriptsCompiledSuccessfully() and some unused friend API functions. r=bhackett --- js/public/OldDebugAPI.h | 6 ------ js/src/jsfriendapi.cpp | 6 ------ js/src/jsfriendapi.h | 3 --- js/src/jsscript.cpp | 24 ---------------------- js/src/jsscript.h | 12 ----------- js/src/vm/OldDebugAPI.cpp | 43 +-------------------------------------- 6 files changed, 1 insertion(+), 93 deletions(-) diff --git a/js/public/OldDebugAPI.h b/js/public/OldDebugAPI.h index 1dfbc2f1a499..26d059f8feba 100644 --- a/js/public/OldDebugAPI.h +++ b/js/public/OldDebugAPI.h @@ -496,12 +496,6 @@ JS_DefineProfilingFunctions(JSContext *cx, JSObject *obj); extern JS_PUBLIC_API(bool) 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) JS_DumpPCCounts(JSContext *cx, JSScript *script); diff --git a/js/src/jsfriendapi.cpp b/js/src/jsfriendapi.cpp index ff0a433c8033..6d022a730871 100644 --- a/js/src/jsfriendapi.cpp +++ b/js/src/jsfriendapi.cpp @@ -443,12 +443,6 @@ js::RunningWithTrustedPrincipals(JSContext *cx) return cx->runningWithTrustedPrincipals(); } -JS_FRIEND_API(bool) -js::IsOriginalScriptFunction(JSFunction *fun) -{ - return fun->nonLazyScript()->function() == fun; -} - JS_FRIEND_API(JSScript *) js::GetOutermostEnclosingFunctionOfScriptedCaller(JSContext *cx) { diff --git a/js/src/jsfriendapi.h b/js/src/jsfriendapi.h index 84f6f23fd110..4709b526bf55 100644 --- a/js/src/jsfriendapi.h +++ b/js/src/jsfriendapi.h @@ -512,9 +512,6 @@ SetDefaultObjectForContext(JSContext *cx, JSObject *obj); JS_FRIEND_API(void) NotifyAnimationActivity(JSObject *obj); -JS_FRIEND_API(bool) -IsOriginalScriptFunction(JSFunction *fun); - /* * Return the outermost enclosing function (script) of the scripted caller. * This function returns nullptr in several cases: diff --git a/js/src/jsscript.cpp b/js/src/jsscript.cpp index 9ab8e3a18914..7332e286efaa 100644 --- a/js/src/jsscript.cpp +++ b/js/src/jsscript.cpp @@ -2102,30 +2102,6 @@ JSScript::uninlinedGlobal() const 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 *fun = &enclosing->as(); - if (!fun->hasScript() || !fun->nonLazyScript()) - return false; - enclosing = fun->nonLazyScript()->enclosingStaticScope(); - } else { - enclosing = enclosing->as().enclosingStaticScope(); - } - } - return true; -} - void js::CallNewScriptHook(JSContext *cx, HandleScript script, HandleFunction fun) { diff --git a/js/src/jsscript.h b/js/src/jsscript.h index f91e031e88a7..39d267e8f86d 100644 --- a/js/src/jsscript.h +++ b/js/src/jsscript.h @@ -1247,18 +1247,6 @@ class JSScript : public js::gc::BarrieredCell 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: bool makeTypes(JSContext *cx); bool makeAnalysis(JSContext *cx); diff --git a/js/src/vm/OldDebugAPI.cpp b/js/src/vm/OldDebugAPI.cpp index 5bd8f6b254ae..22cbf6fe21f9 100644 --- a/js/src/vm/OldDebugAPI.cpp +++ b/js/src/vm/OldDebugAPI.cpp @@ -833,23 +833,6 @@ JS_GetGlobalDebugHooks(JSRuntime *rt) /************************************************************************/ -JS_PUBLIC_API(void) -JS_DumpBytecode(JSContext *cx, JSScript *scriptArg) -{ -#if defined(DEBUG) - Rooted 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) 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()); } -namespace { - -typedef Vector ScriptsToDump; - -static void -DumpBytecodeScriptCallback(JSRuntime *rt, void *data, JSScript *script) -{ - static_cast(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_DumpCompartmentPCCounts(JSContext *cx) { @@ -898,7 +857,7 @@ JS_DumpCompartmentPCCounts(JSContext *cx) if (script->compartment() != cx->compartment()) continue; - if (script->hasScriptCounts() && script->enclosingScriptsCompiledSuccessfully()) + if (script->hasScriptCounts()) JS_DumpPCCounts(cx, script); }