Skip to content
This repository has been archived by the owner on Jul 12, 2024. It is now read-only.

Fix top-level exports corner cases. #128

Merged
merged 3 commits into from
May 15, 2024

Commits on May 14, 2024

  1. Export top-level defs as function functions, not arrow functions.

    This is necessary for exported Scala classes to be instantiable
    with `new ExportedClass()`.
    sjrd committed May 14, 2024
    Configuration menu
    Copy the full SHA
    199fe7d View commit details
    Browse the repository at this point in the history

Commits on May 15, 2024

  1. Redesign top-level export implementation to handle mutable vars.

    The previous strategy for top-level export could not lead to any
    workable support of mutable vars. We now follow a strategy similar
    to what the JS backend uses in its NoModule configuration.
    
    Previously, we compiled top-level exports as Wasm global exports.
    We then had a postprocessing step in the loader to extract the
    `.value` of the `WAGlobal` instances. This correctly captured the
    exported value right after the start function has finished.
    However, it could not update the exported value after a mutable
    static field was reassigned.
    
    Now, we turn everything everything around. Instead of the JS loader
    and wrapper *pulling* values from Wasm, the Wasm code *pushes*
    updates to top-level exports to JavaScript. That means we declare
    setter functions from JavaScript, and that we (counter-intuitively)
    *import* those setters into Wasm. Wasm calls the setters in the
    start function for all top-level exports, and again when assigning
    static fields that are exported.
    sjrd committed May 15, 2024
    Configuration menu
    Copy the full SHA
    e170e2b View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    4fdbed2 View commit details
    Browse the repository at this point in the history