зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1759206 - Part 1: Add module variant of JS::FinishIncrementalEncoding. r=nbp
Depends on D141742 Differential Revision: https://phabricator.services.mozilla.com/D141743
This commit is contained in:
Родитель
4285debbc2
Коммит
6a0d34e5bd
|
@ -83,10 +83,24 @@ inline bool IsTranscodingBytecodeAligned(const void* offset) {
|
|||
|
||||
// Finish incremental encoding started by one of:
|
||||
// * JS::CompileAndStartIncrementalEncoding
|
||||
// * JS::FinishOffThreadScriptAndStartIncrementalEncoding
|
||||
// * JS::StartIncrementalEncoding
|
||||
//
|
||||
// The |script| argument of |FinishIncrementalEncoding| should be the top-level
|
||||
// script returned from one of the above.
|
||||
// For |JS::CompileAndStartIncrementalEncoding| case, the |script|
|
||||
// argument of |FinishIncrementalEncoding| must be the top-level script
|
||||
// returned from it.
|
||||
//
|
||||
// For |JS::StartIncrementalEncoding| case:
|
||||
// * Regular script case
|
||||
// the |script| argument must be the top-level script returned from
|
||||
// |JS::InstantiateGlobalStencil| with the same stencil
|
||||
// * Module script case
|
||||
// the |script| argument must be the script returned by
|
||||
// |JS::GetModuleScript| called on the module returned by
|
||||
// |JS::InstantiateModuleStencil| with the same stencil
|
||||
//
|
||||
// NOTE: |JS::GetModuleScript| doesn't work after evaluating the
|
||||
// module script. For the case, use Handle<JSObject*> variant of
|
||||
// this function below.
|
||||
//
|
||||
// The |buffer| argument of |FinishIncrementalEncoding| is used for appending
|
||||
// the encoded bytecode into the buffer. If any of these functions failed, the
|
||||
|
@ -106,6 +120,15 @@ extern JS_PUBLIC_API bool FinishIncrementalEncoding(JSContext* cx,
|
|||
Handle<JSScript*> script,
|
||||
TranscodeBuffer& buffer);
|
||||
|
||||
// Similar to |JS::FinishIncrementalEncoding|, but receives module obect.
|
||||
//
|
||||
// The |module| argument must be the module returned by
|
||||
// |JS::InstantiateModuleStencil| with the same stencil that's passed to
|
||||
// |JS::StartIncrementalEncoding|.
|
||||
extern JS_PUBLIC_API bool FinishIncrementalEncoding(JSContext* cx,
|
||||
Handle<JSObject*> module,
|
||||
TranscodeBuffer& buffer);
|
||||
|
||||
// Check if the compile options and script's flag matches.
|
||||
//
|
||||
// JS::DecodeScript* and JS::DecodeOffThreadScript internally check this.
|
||||
|
|
|
@ -4516,6 +4516,18 @@ JS_PUBLIC_API bool JS::FinishIncrementalEncoding(JSContext* cx,
|
|||
return true;
|
||||
}
|
||||
|
||||
JS_PUBLIC_API bool JS::FinishIncrementalEncoding(JSContext* cx,
|
||||
JS::Handle<JSObject*> module,
|
||||
TranscodeBuffer& buffer) {
|
||||
if (!module->as<ModuleObject>()
|
||||
.scriptSourceObject()
|
||||
->source()
|
||||
->xdrFinalizeEncoder(cx, buffer)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool JS::IsWasmModuleObject(HandleObject obj) {
|
||||
return obj->canUnwrapAs<WasmModuleObject>();
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче