Closed Bug 1691612 Opened 4 years ago Closed 4 years ago

Add public APIs for CompilationStencil

Categories

(Core :: JavaScript Engine, task, P1)

task

Tracking

()

RESOLVED FIXED
Tracking Status
firefox-esr78 --- unaffected
firefox86 --- unaffected
firefox87 --- fixed

People

(Reporter: tcampbell, Assigned: tcampbell)

References

(Blocks 1 open bug)

Details

Attachments

(2 files)

The js::frontend::CompilationStencil is the main structure for representing parsed JS before it is turned into GC-scripts. To support the various Stencil objectives, we would like a fool-proof abstraction that can be manipulated from Gecko. This bug is about defining that API and resolving footguns.

The CompilationStencil references the following external VM things:

  • SharedImmutableScriptData
  • ScriptSource
  • AsmJS WasmModule

These do not contain GC-things but a lightly coupled to the JSRuntime. These restrictions are minimal and we can reduce over time. In practice though, our domain of sharing would always have a common parent-runtime.

The CompilationStencil itself should have a ref-counting mode. A policy for mutation should be established. For example, if we are delazifying, can we update/append an existing stencil and how should this support threading.

Another important external reference is the XDRBuffer if we decoded the stencil directly from XDR. We should probably make a ref-counted XDRBuffer and have the stencil hold a strong reference if we rely on the data.

Another wrinkle now is the atom-cache that is part of CompilationInput.

A rough design here might look like:

  • Add JS::Stencil type in public that is alias of js::frontend::CompilationStencil
  • Add refCount field to CompilationStencil
  • Add public JS::StencilAddRef / JS::StencilRelease
  • Use RefPtrTraits to allow opaque type to call the non-member JS::StencilAddRef
  • The public CompileToStencil can then return the already_AddRefed<CompilationStencil>
  • Use the js/public/experimental directory for now

The widget/gtk/GRefPtr.h is a rough example of this (where GObject is an opaque type implemented in external library).

Store the max*DataLength values on the StencilDelazificationSet so that it
can be used for multiple instantiations. Separate out the preparation of the
stencil from the gc-output structure for the same reasons.

Introduce an opaque JS::Stencil type for working with CompilationStencil via
the public API (such as in Gecko).

Depends on D104744

Keywords: metaleave-open
Summary: [meta] Add public APIs for CompilationStencil → Add public APIs for CompilationStencil
Assignee: nobody → tcampbell
Attachment #9202423 - Attachment description: Bug 1691612 - Simplify the CompilationStencil preparation code → Bug 1691612 - Simplify the CompilationStencil preparation code. r?arai!
Status: NEW → ASSIGNED
Attachment #9202424 - Attachment description: Bug 1691612 - Add public API for JS::Stencil → Bug 1691612 - Add public API for JS::Stencil. r?arai!
Pushed by tcampbell@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/4b1348088c24 Simplify the CompilationStencil preparation code. r=arai https://hg.mozilla.org/integration/autoland/rev/3d32b5d798f4 Add public API for JS::Stencil. r=arai
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Keywords: leave-open
Resolution: --- → FIXED
See Also: → 1701305
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: