Bug 1724236 - Move Decode to ScriptLoader r=arai
ScriptLoader is the only place that calls it, and inlining it made the call site too hard to follow. Differential Revision: https://phabricator.services.mozilla.com/D218453
This commit is contained in:
@@ -120,24 +120,6 @@ void Compile(JSContext* aCx, JS::CompileOptions& aCompileOptions,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Decode(JSContext* aCx, JS::CompileOptions& aCompileOptions,
|
|
||||||
const JS::TranscodeRange& aBytecodeBuf,
|
|
||||||
RefPtr<JS::Stencil>& aStencil, ErrorResult& aRv) {
|
|
||||||
JS::DecodeOptions decodeOptions(aCompileOptions);
|
|
||||||
decodeOptions.borrowBuffer = true;
|
|
||||||
|
|
||||||
MOZ_ASSERT(aCompileOptions.noScriptRval);
|
|
||||||
JS::TranscodeResult tr = JS::DecodeStencil(aCx, decodeOptions, aBytecodeBuf,
|
|
||||||
getter_AddRefs(aStencil));
|
|
||||||
// These errors are external parameters which should be handled before the
|
|
||||||
// decoding phase, and which are the only reasons why you might want to
|
|
||||||
// fallback on decoding failures.
|
|
||||||
MOZ_ASSERT(tr != JS::TranscodeResult::Failure_BadBuildId);
|
|
||||||
if (tr != JS::TranscodeResult::Ok) {
|
|
||||||
aRv = NS_ERROR_DOM_JS_DECODING_ERROR;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} // namespace mozilla::dom
|
} // namespace mozilla::dom
|
||||||
|
|
||||||
void JSExecutionContext::InstantiateStencil(
|
void JSExecutionContext::InstantiateStencil(
|
||||||
|
|||||||
@@ -93,11 +93,6 @@ void Compile(JSContext* aCx, JS::CompileOptions& aCompileOptions,
|
|||||||
const nsAString& aScript, RefPtr<JS::Stencil>& aStencil,
|
const nsAString& aScript, RefPtr<JS::Stencil>& aStencil,
|
||||||
ErrorResult& aRv);
|
ErrorResult& aRv);
|
||||||
|
|
||||||
// Decode a script contained in a buffer.
|
|
||||||
void Decode(JSContext* aCx, JS::CompileOptions& aCompileOptions,
|
|
||||||
const JS::TranscodeRange& aBytecodeBuf,
|
|
||||||
RefPtr<JS::Stencil>& aStencil, ErrorResult& aRv);
|
|
||||||
|
|
||||||
} // namespace dom
|
} // namespace dom
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
|
|||||||
@@ -2722,6 +2722,26 @@ nsresult ScriptLoader::EvaluateScriptElement(ScriptLoadRequest* aRequest) {
|
|||||||
return EvaluateScript(globalObject, aRequest);
|
return EvaluateScript(globalObject, aRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Decode a script contained in a buffer.
|
||||||
|
static void Decode(JSContext* aCx, JS::CompileOptions& aCompileOptions,
|
||||||
|
const JS::TranscodeRange& aBytecodeBuf,
|
||||||
|
RefPtr<JS::Stencil>& aStencil, ErrorResult& aRv) {
|
||||||
|
JS::DecodeOptions decodeOptions(aCompileOptions);
|
||||||
|
decodeOptions.borrowBuffer = true;
|
||||||
|
|
||||||
|
MOZ_ASSERT(aCompileOptions.noScriptRval);
|
||||||
|
JS::TranscodeResult tr = JS::DecodeStencil(aCx, decodeOptions, aBytecodeBuf,
|
||||||
|
getter_AddRefs(aStencil));
|
||||||
|
// These errors are external parameters which should be handled before the
|
||||||
|
// decoding phase, and which are the only reasons why you might want to
|
||||||
|
// fallback on decoding failures.
|
||||||
|
MOZ_ASSERT(tr != JS::TranscodeResult::Failure_BadBuildId);
|
||||||
|
if (tr != JS::TranscodeResult::Ok) {
|
||||||
|
aRv = NS_ERROR_DOM_JS_DECODING_ERROR;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ScriptLoader::InstantiateClassicScriptFromMaybeEncodedSource(
|
void ScriptLoader::InstantiateClassicScriptFromMaybeEncodedSource(
|
||||||
JSContext* aCx, JSExecutionContext& aExec,
|
JSContext* aCx, JSExecutionContext& aExec,
|
||||||
JS::CompileOptions& aCompileOptions, ScriptLoadRequest* aRequest,
|
JS::CompileOptions& aCompileOptions, ScriptLoadRequest* aRequest,
|
||||||
|
|||||||
Reference in New Issue
Block a user