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:
@@ -2722,6 +2722,26 @@ nsresult ScriptLoader::EvaluateScriptElement(ScriptLoadRequest* 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(
|
||||
JSContext* aCx, JSExecutionContext& aExec,
|
||||
JS::CompileOptions& aCompileOptions, ScriptLoadRequest* aRequest,
|
||||
|
||||
Reference in New Issue
Block a user