Bug 1724236 - Pass debugger parameters as arguments instead of members r=arai
Differential Revision: https://phabricator.services.mozilla.com/D218454
This commit is contained in:
@@ -68,9 +68,7 @@ JSExecutionContext::JSExecutionContext(
|
||||
JS::CompileOptions& aCompileOptions, ErrorResult& aRv,
|
||||
JS::Handle<JS::Value> aDebuggerPrivateValue,
|
||||
JS::Handle<JSScript*> aDebuggerIntroductionScript)
|
||||
: mDebuggerPrivateValue(aCx, aDebuggerPrivateValue),
|
||||
mDebuggerIntroductionScript(aCx, aDebuggerIntroductionScript),
|
||||
mSkip(false) {
|
||||
: mSkip(false) {
|
||||
MOZ_ASSERT(aCx == nsContentUtils::GetCurrentJSContext());
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(CycleCollectedJSContext::Get() &&
|
||||
@@ -122,10 +120,29 @@ void Compile(JSContext* aCx, JS::CompileOptions& aCompileOptions,
|
||||
|
||||
} // namespace mozilla::dom
|
||||
|
||||
void JSExecutionContext::InstantiateStencil(
|
||||
JSContext* aCx, JS::CompileOptions& aCompileOptions,
|
||||
RefPtr<JS::Stencil>& aStencil, JS::MutableHandle<JSScript*> aScript,
|
||||
ErrorResult& aRv) {
|
||||
MOZ_ASSERT(!JS::InstantiateOptions(aCompileOptions).deferDebugMetadata);
|
||||
MOZ_ASSERT(!mSkip);
|
||||
MOZ_ASSERT(!aScript);
|
||||
|
||||
JS::InstantiateOptions instantiateOptions(aCompileOptions);
|
||||
aScript.set(
|
||||
JS::InstantiateGlobalStencil(aCx, instantiateOptions, aStencil, nullptr));
|
||||
if (!aScript) {
|
||||
mSkip = true;
|
||||
aRv.NoteJSContextException(aCx);
|
||||
}
|
||||
}
|
||||
|
||||
void JSExecutionContext::InstantiateStencil(
|
||||
JSContext* aCx, JS::CompileOptions& aCompileOptions,
|
||||
RefPtr<JS::Stencil>&& aStencil, JS::MutableHandle<JSScript*> aScript,
|
||||
bool& incrementalEncodingAlreadyStarted, ErrorResult& aRv,
|
||||
bool& incrementalEncodingAlreadyStarted,
|
||||
JS::Handle<JS::Value> aDebuggerPrivateValue,
|
||||
JS::Handle<JSScript*> aDebuggerIntroductionScript, ErrorResult& aRv,
|
||||
bool aEncodeBytecode /* = false */, JS::InstantiationStorage* aStorage) {
|
||||
MOZ_ASSERT(!mSkip);
|
||||
JS::InstantiateOptions instantiateOptions(aCompileOptions);
|
||||
@@ -152,8 +169,8 @@ void JSExecutionContext::InstantiateStencil(
|
||||
|
||||
if (instantiateOptions.deferDebugMetadata) {
|
||||
if (!JS::UpdateDebugMetadata(aCx, aScript, instantiateOptions,
|
||||
mDebuggerPrivateValue, nullptr,
|
||||
mDebuggerIntroductionScript, nullptr)) {
|
||||
aDebuggerPrivateValue, nullptr,
|
||||
aDebuggerIntroductionScript, nullptr)) {
|
||||
aRv = NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,14 +35,6 @@ class ScriptLoadContext;
|
||||
nsresult EvaluationExceptionToNSResult(ErrorResult& aRv);
|
||||
|
||||
class MOZ_STACK_CLASS JSExecutionContext final {
|
||||
// Debug Metadata: Values managed for the benefit of the debugger when
|
||||
// inspecting code.
|
||||
//
|
||||
// For more details see CompilationAndEvaluation.h, and the comments on
|
||||
// UpdateDebugMetadata
|
||||
JS::Rooted<JS::Value> mDebuggerPrivateValue;
|
||||
JS::Rooted<JSScript*> mDebuggerIntroductionScript;
|
||||
|
||||
// Used to skip upcoming phases in case of a failure. In such case the
|
||||
// result is carried by mRv.
|
||||
bool mSkip;
|
||||
@@ -78,12 +70,21 @@ class MOZ_STACK_CLASS JSExecutionContext final {
|
||||
ScriptLoadContext* aContext, RefPtr<JS::Stencil>& aStencil,
|
||||
JS::InstantiationStorage& aStorage, ErrorResult& aRv);
|
||||
|
||||
// Instantiate (on main-thread) a JS::Stencil generated by
|
||||
// main-thread parsing, without encoding bytecode or deferring debug metadata.
|
||||
void InstantiateStencil(JSContext* aCx, JS::CompileOptions& aCompileOptions,
|
||||
RefPtr<JS::Stencil>& aStencil,
|
||||
JS::MutableHandle<JSScript*> aScript,
|
||||
ErrorResult& aRv);
|
||||
|
||||
// Instantiate (on main-thread) a JS::Stencil generated by off-thread or
|
||||
// main-thread parsing or decoding.
|
||||
void InstantiateStencil(JSContext* aCx, JS::CompileOptions& aCompileOptions,
|
||||
RefPtr<JS::Stencil>&& aStencil,
|
||||
JS::MutableHandle<JSScript*> aScript,
|
||||
bool& incrementalEncodingAlreadyStarted,
|
||||
JS::Handle<JS::Value> aDebuggerPrivateValue,
|
||||
JS::Handle<JSScript*> aDebuggerIntroductionScript,
|
||||
ErrorResult& aRv, bool aEncodeBytecode = false,
|
||||
JS::InstantiationStorage* aStorage = nullptr);
|
||||
};
|
||||
|
||||
@@ -6104,9 +6104,7 @@ bool WindowScriptTimeoutHandler::Call(const char* aExecutionReason) {
|
||||
JS::Rooted<JSScript*> script(aes.cx());
|
||||
Compile(aes.cx(), options, mExpr, stencil, erv);
|
||||
if (stencil) {
|
||||
bool unused;
|
||||
exec.InstantiateStencil(aes.cx(), options, std::move(stencil), &script,
|
||||
unused, erv);
|
||||
exec.InstantiateStencil(aes.cx(), options, stencil, &script, erv);
|
||||
}
|
||||
|
||||
if (script) {
|
||||
|
||||
@@ -397,9 +397,8 @@ nsresult nsJSThunk::EvaluateScript(
|
||||
mozilla::dom::Compile(cx, options, NS_ConvertUTF8toUTF16(script), stencil,
|
||||
erv);
|
||||
if (stencil) {
|
||||
bool unused;
|
||||
exec.InstantiateStencil(aes.cx(), options, std::move(stencil),
|
||||
&compiledScript, unused, erv);
|
||||
exec.InstantiateStencil(aes.cx(), options, stencil, &compiledScript,
|
||||
erv);
|
||||
}
|
||||
|
||||
if (!erv.Failed()) {
|
||||
|
||||
@@ -2746,7 +2746,9 @@ void ScriptLoader::InstantiateClassicScriptFromMaybeEncodedSource(
|
||||
JSContext* aCx, JSExecutionContext& aExec,
|
||||
JS::CompileOptions& aCompileOptions, ScriptLoadRequest* aRequest,
|
||||
JS::MutableHandle<JSScript*> aScript, bool aKeepStencil,
|
||||
RefPtr<JS::Stencil>& aStencilDup, ErrorResult& aRv) {
|
||||
RefPtr<JS::Stencil>& aStencilDup,
|
||||
JS::Handle<JS::Value> aDebuggerPrivateValue,
|
||||
JS::Handle<JSScript*> aDebuggerIntroductionScript, ErrorResult& aRv) {
|
||||
nsAutoCString profilerLabelString;
|
||||
aRequest->GetScriptLoadContext()->GetProfilerLabel(profilerLabelString);
|
||||
|
||||
@@ -2769,7 +2771,9 @@ void ScriptLoader::InstantiateClassicScriptFromMaybeEncodedSource(
|
||||
if (stencil) {
|
||||
bool unused;
|
||||
aExec.InstantiateStencil(aCx, aCompileOptions, std::move(stencil),
|
||||
aScript, unused, aRv, false, &storage);
|
||||
aScript, unused, aDebuggerPrivateValue,
|
||||
aDebuggerIntroductionScript, aRv, false,
|
||||
&storage);
|
||||
}
|
||||
} else {
|
||||
LOG(("ScriptLoadRequest (%p): Decode Bytecode and Execute", aRequest));
|
||||
@@ -2790,7 +2794,8 @@ void ScriptLoader::InstantiateClassicScriptFromMaybeEncodedSource(
|
||||
if (stencil) {
|
||||
bool unused;
|
||||
aExec.InstantiateStencil(aCx, aCompileOptions, std::move(stencil),
|
||||
aScript, unused, aRv);
|
||||
aScript, unused, aDebuggerPrivateValue,
|
||||
aDebuggerIntroductionScript, aRv);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2825,7 +2830,9 @@ void ScriptLoader::InstantiateClassicScriptFromMaybeEncodedSource(
|
||||
if (stencil) {
|
||||
bool unused;
|
||||
aExec.InstantiateStencil(aCx, aCompileOptions, std::move(stencil),
|
||||
aScript, unused, aRv, encodeBytecode, &storage);
|
||||
aScript, unused, aDebuggerPrivateValue,
|
||||
aDebuggerIntroductionScript, aRv, encodeBytecode,
|
||||
&storage);
|
||||
}
|
||||
} else {
|
||||
// Main thread parsing (inline and small scripts)
|
||||
@@ -2861,7 +2868,8 @@ void ScriptLoader::InstantiateClassicScriptFromMaybeEncodedSource(
|
||||
if (stencil) {
|
||||
bool unused;
|
||||
aExec.InstantiateStencil(aCx, aCompileOptions, std::move(stencil),
|
||||
aScript, unused, erv);
|
||||
aScript, unused, aDebuggerPrivateValue,
|
||||
aDebuggerIntroductionScript, erv);
|
||||
}
|
||||
|
||||
mMainThreadParseTime += TimeStamp::Now() - startTime;
|
||||
@@ -2874,7 +2882,8 @@ void ScriptLoader::InstantiateClassicScriptFromCachedStencil(
|
||||
JSContext* aCx, JSExecutionContext& aExec,
|
||||
JS::CompileOptions& aCompileOptions, ScriptLoadRequest* aRequest,
|
||||
JS::Stencil* aStencil, JS::MutableHandle<JSScript*> aScript,
|
||||
ErrorResult& aRv) {
|
||||
JS::Handle<JS::Value> aDebuggerPrivateValue,
|
||||
JS::Handle<JSScript*> aDebuggerIntroductionScript, ErrorResult& aRv) {
|
||||
RefPtr<JS::Stencil> stencil = JS::DuplicateStencil(aCx, aStencil);
|
||||
if (!stencil) {
|
||||
aRv = NS_ERROR_FAILURE;
|
||||
@@ -2883,7 +2892,9 @@ void ScriptLoader::InstantiateClassicScriptFromCachedStencil(
|
||||
|
||||
bool incrementalEncodingAlreadyStarted = false;
|
||||
aExec.InstantiateStencil(aCx, aCompileOptions, std::move(stencil), aScript,
|
||||
incrementalEncodingAlreadyStarted, aRv,
|
||||
incrementalEncodingAlreadyStarted,
|
||||
aDebuggerPrivateValue, aDebuggerIntroductionScript,
|
||||
aRv,
|
||||
/* aEncodeBytecode */ true);
|
||||
if (incrementalEncodingAlreadyStarted) {
|
||||
aRequest->MarkSkippedBytecodeEncoding();
|
||||
@@ -2893,11 +2904,14 @@ void ScriptLoader::InstantiateClassicScriptFromCachedStencil(
|
||||
void ScriptLoader::InstantiateClassicScriptFromAny(
|
||||
JSContext* aCx, JSExecutionContext& aExec,
|
||||
JS::CompileOptions& aCompileOptions, ScriptLoadRequest* aRequest,
|
||||
JS::MutableHandle<JSScript*> aScript, ErrorResult& aRv) {
|
||||
JS::MutableHandle<JSScript*> aScript,
|
||||
JS::Handle<JS::Value> aDebuggerPrivateValue,
|
||||
JS::Handle<JSScript*> aDebuggerIntroductionScript, ErrorResult& aRv) {
|
||||
if (aRequest->IsStencil()) {
|
||||
RefPtr<JS::Stencil> stencil = aRequest->GetStencil();
|
||||
InstantiateClassicScriptFromCachedStencil(aCx, aExec, aCompileOptions,
|
||||
aRequest, stencil, aScript, aRv);
|
||||
InstantiateClassicScriptFromCachedStencil(
|
||||
aCx, aExec, aCompileOptions, aRequest, stencil, aScript,
|
||||
aDebuggerPrivateValue, aDebuggerIntroductionScript, aRv);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2915,9 +2929,9 @@ void ScriptLoader::InstantiateClassicScriptFromAny(
|
||||
}
|
||||
|
||||
RefPtr<JS::Stencil> stencilDup;
|
||||
InstantiateClassicScriptFromMaybeEncodedSource(aCx, aExec, aCompileOptions,
|
||||
aRequest, aScript, createCache,
|
||||
stencilDup, aRv);
|
||||
InstantiateClassicScriptFromMaybeEncodedSource(
|
||||
aCx, aExec, aCompileOptions, aRequest, aScript, createCache, stencilDup,
|
||||
aDebuggerPrivateValue, aDebuggerIntroductionScript, aRv);
|
||||
if (!aRv.Failed()) {
|
||||
if (createCache) {
|
||||
MOZ_ASSERT(mCache);
|
||||
@@ -3098,7 +3112,8 @@ nsresult ScriptLoader::EvaluateScript(nsIGlobalObject* aGlobalObject,
|
||||
JS::ProfilingCategoryPair::JS);
|
||||
JSAutoRealm autoRealm(cx, global);
|
||||
JS::Rooted<JSScript*> script(cx);
|
||||
InstantiateClassicScriptFromAny(cx, exec, options, aRequest, &script, erv);
|
||||
InstantiateClassicScriptFromAny(cx, exec, options, aRequest, &script,
|
||||
classicScriptValue, introductionScript, erv);
|
||||
|
||||
if (!erv.Failed()) {
|
||||
MaybePrepareForBytecodeEncodingBeforeExecute(aRequest, script);
|
||||
|
||||
@@ -638,12 +638,12 @@ class ScriptLoader final : public JS::loader::ScriptLoaderInterface {
|
||||
// * text source
|
||||
// * encoded bytecode
|
||||
// * cached stencil
|
||||
void InstantiateClassicScriptFromAny(JSContext* aCx,
|
||||
JSExecutionContext& aExec,
|
||||
JS::CompileOptions& aCompileOptions,
|
||||
ScriptLoadRequest* aRequest,
|
||||
void InstantiateClassicScriptFromAny(
|
||||
JSContext* aCx, JSExecutionContext& aExec,
|
||||
JS::CompileOptions& aCompileOptions, ScriptLoadRequest* aRequest,
|
||||
JS::MutableHandle<JSScript*> aScript,
|
||||
ErrorResult& aRv);
|
||||
JS::Handle<JS::Value> aDebuggerPrivateValue,
|
||||
JS::Handle<JSScript*> aDebuggerIntroductionScript, ErrorResult& aRv);
|
||||
|
||||
// Instantiate classic script from one of the following data:
|
||||
// * text source
|
||||
@@ -655,7 +655,9 @@ class ScriptLoader final : public JS::loader::ScriptLoaderInterface {
|
||||
JSContext* aCx, JSExecutionContext& aExec,
|
||||
JS::CompileOptions& aCompileOptions, ScriptLoadRequest* aRequest,
|
||||
JS::MutableHandle<JSScript*> aScript, bool keepStencil,
|
||||
RefPtr<JS::Stencil>& aStencilDup, ErrorResult& aRv);
|
||||
RefPtr<JS::Stencil>& aStencilDup,
|
||||
JS::Handle<JS::Value> aDebuggerPrivateValue,
|
||||
JS::Handle<JSScript*> aDebuggerIntroductionScript, ErrorResult& aRv);
|
||||
|
||||
// Instantiate classic script from the following data:
|
||||
// * cached stencil
|
||||
@@ -663,7 +665,8 @@ class ScriptLoader final : public JS::loader::ScriptLoaderInterface {
|
||||
JSContext* aCx, JSExecutionContext& aExec,
|
||||
JS::CompileOptions& aCompileOptions, ScriptLoadRequest* aRequest,
|
||||
JS::Stencil* aStencil, JS::MutableHandle<JSScript*> aScript,
|
||||
ErrorResult& aRv);
|
||||
JS::Handle<JS::Value> aDebuggerPrivateValue,
|
||||
JS::Handle<JSScript*> aDebuggerIntroductionScript, ErrorResult& aRv);
|
||||
|
||||
static nsCString& BytecodeMimeTypeFor(ScriptLoadRequest* aRequest);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user