Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump to version 117 #101

Merged
merged 663 commits into from
Jul 12, 2024
Merged

Bump to version 117 #101

merged 663 commits into from
Jul 12, 2024
This pull request is big! We’re only showing the most recent 250 commits.

Commits on Oct 25, 2023

  1. Add missing includes (WebAssembly#6049)

    These missing includes were not a problem in our standard build configuration,
    but were breaking other build configurations.
    tlively authored Oct 25, 2023
    Configuration menu
    Copy the full SHA
    dfd8c7e View commit details
    Browse the repository at this point in the history
  2. [analysis] Simplify core analysis code (WebAssembly#6034)

    Simplify the monotone analyzer by replacing all the state it used to store in
    `BlockState` with a simple vector of lattice elements. Use simple indices to
    refer to both blocks and their associated states in the vector. Remove the
    ability for transfer functions to control the initial enqueued order of basic
    blocks since that was a leaky abstraction. Replace the worklist with a
    UniqueDeferredQueue since that has generally proven to be more efficient in
    smiilarly contexts, and more importantly, it has a nicer API. Make miscellaneous
    simplifications to other code as well.
    
    Delete a few unit tests that exposed the order in which blocks were analyzed
    because they printed intermediate results. These tests should be replaced with
    tests of analyses' public APIs in the future.
    tlively authored Oct 25, 2023
    Configuration menu
    Copy the full SHA
    ef8e424 View commit details
    Browse the repository at this point in the history
  3. [analysis][NFC] Rename makeLeastUpperBound to join and move it to…

    … lattice (WebAssembly#6035)
    
    In general, the operation of taking the least upper bound of two lattice
    elements may depend on some state stored in the lattice object rather than in
    the elements themselves. To avoid forcing the elements to be larger and more
    complicated in that case (by storing a parent pointer back to the lattice), move
    the least upper bound operation to make it a method of the lattice rather than
    the lattice element. This is also more consistent with where we put e.g. the
    `compare` method.
    
    While we are at it, rename `makeLeastUpperBound` to `join`, which is much
    shorter and nicer. Usually we avoid using esoteric mathematical jargon like
    this, but "join" as a normal verb actually describes the operation nicely, so I
    think it is ok in this case.
    tlively authored Oct 25, 2023
    Configuration menu
    Copy the full SHA
    9af7abd View commit details
    Browse the repository at this point in the history
  4. [analysis] Implement a Bool lattice (WebAssembly#6036)

    This is a lattice with two elements: `false` is bottom and `true` is top.
    
    Add a new gtest file for testing lattices.
    tlively authored Oct 25, 2023
    Configuration menu
    Copy the full SHA
    2b65663 View commit details
    Browse the repository at this point in the history
  5. [analysis] Implement an Int lattice (WebAssembly#6037)

    Implement a generic lattice template for integral types ordered by `<`.
    tlively authored Oct 25, 2023
    Configuration menu
    Copy the full SHA
    a09ea69 View commit details
    Browse the repository at this point in the history
  6. [analysis] Add a FullLattice concept and Inverted lattice (WebAssembl…

    …y#6038)
    
    The FullLattice concept extends the base Lattice with `getTop` and `meet`
    operations. The `Inverted` lattice uses these operations to reverse the order of
    an arbitrary full lattice, for example to create a lattice of integers ordered
    by `>` rather than by `<`.
    tlively authored Oct 25, 2023
    Configuration menu
    Copy the full SHA
    6ba0f3d View commit details
    Browse the repository at this point in the history
  7. [analysis] Implement Flat lattice (WebAssembly#6039)

    Given a type `T`, `Flat<T>` is the lattice where none of the values of `T` are
    comparable except with themselves, but they are all greater than a common bottom
    element not in `T` and less than a common top element also not in `T`.
    tlively authored Oct 25, 2023
    Configuration menu
    Copy the full SHA
    ea6bcd0 View commit details
    Browse the repository at this point in the history
  8. Precompute: Check defaultability, not nullability (WebAssembly#6052)

    Followup to WebAssembly#6048, we did not handle nondefaultable tuples because of this.
    kripken authored Oct 25, 2023
    Configuration menu
    Copy the full SHA
    7a6d962 View commit details
    Browse the repository at this point in the history
  9. [analysis] Implement a Lift lattice (WebAssembly#6040)

    This lattice "lifts" another lattice by inserting a new bottom element
    underneath it.
    tlively authored Oct 25, 2023
    Configuration menu
    Copy the full SHA
    1dcc859 View commit details
    Browse the repository at this point in the history

Commits on Oct 26, 2023

  1. Fix Alpine CI by removing old node flag (WebAssembly#6054)

    Apparently the version of node on the Alpine runner was updated and no longer
    recognizes the --experimental-wasm-threads option. Delete this option out of the
    test that was using it.
    tlively authored Oct 26, 2023
    Configuration menu
    Copy the full SHA
    889422e View commit details
    Browse the repository at this point in the history
  2. Allow rec groups of public function types in closed world (WebAssembl…

    …y#6053)
    
    Closed-world mode allows function types to escape if they are on exported functions,
    because that has been possible since wasm MVP and cannot be avoided. But we need to
    also allow all types in those type's rec groups as well. Consider this case:
    
    (module
     (rec
      (type $0 (func))
      (type $1 (func))
     )
     (func "0" (type $0)
      (nop)
     )
     (func "1" (type $1)
      (nop)
     )
    )
    
    The two exported functions make the two types public, so this module validates in
    closed world mode. Now imagine that metadce removes one export:
    
    (module
     (rec
      (type $0 (func))
      (type $1 (func))
     )
     (func "0" (type $0)
      (nop)
     )
     ;; The export "1" is gone.
    )
    
    Before this PR that no longer validates, because it only marks the type $0 as public.
    But when a type is public that makes its entire rec group public, so $1 is errored on.
    
    To fix that, this PR allows all types in a rec group of an exported function's type, which
    makes that last module validate.
    kripken authored Oct 26, 2023
    Configuration menu
    Copy the full SHA
    0aa46e4 View commit details
    Browse the repository at this point in the history

Commits on Oct 27, 2023

  1. [analysis] Improve lattice fuzzer (WebAssembly#6050)

    Implement new `RandomLattice` and `RandomFullLattice` utilities that are
    lattices randomly created from other lattices. By recursively using themselves
    as the parameter lattices for lattices like `Inverted` and `Lift`, these random
    lattices can become arbitrarily nested.
    
    Decouple the checking of lattice properties from the checking of transfer
    function properties by creating a new, standalone `checkLatticeProperties`
    function.
    tlively authored Oct 27, 2023
    Configuration menu
    Copy the full SHA
    57e0b2f View commit details
    Browse the repository at this point in the history

Commits on Oct 30, 2023

  1. Support one-line-one-function file format for asyncify lists (WebAsse…

    …mbly#6051)
    
    If there are newlines in the list, then we split using them in a simple manner
    (that does not take into account nesting of any other delimiters).
    
    Fixes WebAssembly#6047
    Fixes WebAssembly#5271
    caiiiycuk authored Oct 30, 2023
    Configuration menu
    Copy the full SHA
    7dcc532 View commit details
    Browse the repository at this point in the history
  2. [analysis][NFC] Rename parameters to join and meet methods (WebAssemb…

    …ly#6056)
    
    Since these methods, which operate on lattice elements, moved to the lattice
    types, it no longer makes much sense for their parameters to be called `self`
    and `other`. Rename them to `joinee` and `joiner` for joins and `meetee` and
    `meeter` for meets.
    tlively authored Oct 30, 2023
    Configuration menu
    Copy the full SHA
    e8dd518 View commit details
    Browse the repository at this point in the history

Commits on Oct 31, 2023

  1. [analysis] Implement an array lattice (WebAssembly#6057)

    The elements of `Array<L, N>` lattice are arrays of length `N` of elements of
    `L`, compared pairwise with each other. This lattice is a concrete
    implementation of what would be written L^N with pen and paper.
    tlively authored Oct 31, 2023
    Configuration menu
    Copy the full SHA
    bdc8b4d View commit details
    Browse the repository at this point in the history
  2. [analysis] Implement a vector lattice (WebAssembly#6058)

    The vector lattice is nearly identical to the array lattice, except that the
    size of the elements is specified at runtime when the lattice object is created
    rather than at compile time. The code and tests are largely copy-pasted and
    fixed up from the array implementation, but there are a couple differences.
    First, initializing vector elements does not need the template magic used to
    initialize array elements. Second, the obvious implementations of join and meet
    do not work for vectors of bools because they might be specialized to be bit
    vectors, so we need workarounds for that particular case.
    tlively authored Oct 31, 2023
    Configuration menu
    Copy the full SHA
    220196e View commit details
    Browse the repository at this point in the history
  3. [analysis] Add a tuple lattice (WebAssembly#6062)

    This lattice combines any number of other lattices into a single lattice whose
    elements are tuples of elements of the other lattices. This will be one of the
    most important lattices in the analysis framework because it will be used to
    combine information about different parts of the program, e.g. locals and the
    value stack, into a single lattice.
    tlively authored Oct 31, 2023
    Configuration menu
    Copy the full SHA
    68ba799 View commit details
    Browse the repository at this point in the history
  4. OnceReduction: Optimize bodies of trivial "once" functions (WebAssemb…

    …ly#6061)
    
    In particular, if the body just calls another "once" function, then we can
    skip the early-exit logic.
    kripken authored Oct 31, 2023
    Configuration menu
    Copy the full SHA
    fad0698 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    c82627e View commit details
    Browse the repository at this point in the history

Commits on Nov 1, 2023

  1. [analysis] Add a lattice for value types (WebAssembly#6064)

    Add a lattice that is a thin wrapper around `wasm::Type` giving it the interface
    of a lattice. As usual, `Type::unreachable` is the bottom element, but unlike in
    the underlying API, we uniformly treat `Type::none` as the top type so that we
    have a proper lattice.
    tlively authored Nov 1, 2023
    Configuration menu
    Copy the full SHA
    74237bf View commit details
    Browse the repository at this point in the history
  2. [analysis][NFC] Refactor lattice unit tests (WebAssembly#6065)

    Many of the lattice tests were essentially copy-pasted from one lattice to the
    next because they all tested isomorphic subsets of the various lattices,
    specifically in the shape of a diamond. Refactor the code so that all lattices
    that have tests of this shape use the same utility test functions.
    tlively authored Nov 1, 2023
    Configuration menu
    Copy the full SHA
    5618d21 View commit details
    Browse the repository at this point in the history
  3. NonNullable => !Defaultable in SimplifyLocals (WebAssembly#6070)

    We handled references but not tuples in one place.
    kripken authored Nov 1, 2023
    Configuration menu
    Copy the full SHA
    1890834 View commit details
    Browse the repository at this point in the history
  4. [Wasm64] Fix PostEmscripten::optimizeExceptions on invokes with an i6…

    …4 argument (WebAssembly#6074)
    
    In wasm64, function pointers are 64-bit like all pointers.
    
    fixes WebAssembly#6073
    kripken authored Nov 1, 2023
    Configuration menu
    Copy the full SHA
    b14bf89 View commit details
    Browse the repository at this point in the history
  5. Fuzzer: Better handling of globals from initial content (WebAssembly#…

    …6072)
    
    Previously the fuzzer never added gets or sets of globals from initial content. That was
    an oversight, I'm pretty sure - it's just that the code that sets up the lists from which we
    pick globals for gets and sets was in another place. That is, any globals in the initial
    content file were never used in new random code the fuzzer generates (only new
    globals the fuzzer generated were used there).
    
    This PR allows us to use those globals, but also ignores them with some probability,
    to avoid breaking patterns like "once" globals (that we want to only be used from
    initial content, at least much of the time).
    
    Also simplify the code here: we don't need isInvalidGlobal just to handle the hang
    limit global, which is already handled by not being added to the lists we pick names
    from anyhow.
    kripken authored Nov 1, 2023
    Configuration menu
    Copy the full SHA
    f1d5b26 View commit details
    Browse the repository at this point in the history

Commits on Nov 2, 2023

  1. Configuration menu
    Copy the full SHA
    34cbf00 View commit details
    Browse the repository at this point in the history
  2. [analysis] Add a "Shared" lattice to represent shared state (WebAssem…

    …bly#6067)
    
    The analysis framework stores a separate lattice element for each basic block
    being analyzed to represent the program state at the beginning of the block.
    However, in many analyses a significant portion of program state is not
    flow-sensitive, so does not benefit from having a separate copy per block. For
    example, an analysis might track constraints on the types of locals that do not
    vary across blocks, so it really only needs a single copy of the constrains for
    each local. It would be correct to simply duplicate the state across blocks
    anyway, but it would not be efficient.
    
    To make it possible to share a single copy of a lattice element across basic
    blocks, introduce a `Shared<L>` lattice. Mathematically, this lattice represents
    a single ascending chain in the underlying lattice and its elements are ordered
    according to sequence numbers corresponding to positions in that chain.
    Concretely, though, the `Shared<L>` lattice only ever materializes a single,
    monotonically increasing element of `L` and all of its elements provide access
    to that shared underlying element.
    
    `Shared<L>` will let us get the benefits of having mutable shared state in the
    concrete implementation of analyses without losing the benefits of keeping those
    analyses expressible purely in terms of the monotone framework.
    tlively authored Nov 2, 2023
    Configuration menu
    Copy the full SHA
    bc88d5d View commit details
    Browse the repository at this point in the history
  3. [analysis] Simplify the stack lattice (WebAssembly#6069)

    Remove the ability to represent the top element of the stack lattice since it
    isn't necessary. Also simplify the element type to be a simple vector, update
    the lattice method implementations to be more consistent with implementations in
    other lattices, and make the tests more consistent with the tests for other
    lattices.
    tlively authored Nov 2, 2023
    Configuration menu
    Copy the full SHA
    f191ace View commit details
    Browse the repository at this point in the history
  4. [analysis] Allow joining a single vector element efficiently (WebAsse…

    …mbly#6071)
    
    Previously, modifying a single vector element of a `Shared<Vector>` element
    required materializing a full vector to do the join. When there is just a single
    element to update, materializing all the other elements with bottom value is
    useless work. Add a `Vector<L>::SingletonElement` utility that represents but
    does not materialize a vector with a single non-bottom element and allow it to
    be passed to `Vector<L>::join`. Also update `Shared` and `Inverted` so that
    `SingletonElement` joins still work on vectors wrapped in those other lattices.
    tlively authored Nov 2, 2023
    Configuration menu
    Copy the full SHA
    2c3860b View commit details
    Browse the repository at this point in the history
  5. [analysis] Make it easier to implement a transfer function (WebAssemb…

    …ly#6077)
    
    Combine the `transfer` and `getDependents` methods of a transfer function so
    that a transfer function only has to implement `transfer`, which now returns a
    range of basic blocks that may need to be re-analyzed.
    
    To make it easier to implement the returned basic block range, change the
    requirement so that it provides iterators to `const BasicBlock*` rather than
    `BasicBlock`. This allows us to entirely remove cfg-impl.h.
    tlively authored Nov 2, 2023
    Configuration menu
    Copy the full SHA
    4fba26a View commit details
    Browse the repository at this point in the history

Commits on Nov 6, 2023

  1. Configuration menu
    Copy the full SHA
    e3d2716 View commit details
    Browse the repository at this point in the history
  2. Update CFGWalker to generate consolidated exit blocks (WebAssembly#6079)

    Previously CFGWalker designated a particular block as the "exit" block, but it
    was just the block that happened to appear at the end of the function that
    returned values by implicitly flowing them out. That exit block was not tied in
    any way to other blocks that might end in returns, so analyses that needed to
    perform some action at the end of the function would have had to perform that
    action at the end of the designated exit block but also separately at any return
    instruction.
    
    Update CFGWalker to make the exit block a synthetic empty block that is a
    successor of all other blocks tthat implicitly or explicitly return from the
    function in case there are multiple such blocks, or to make the exit block the
    single returning block if there is only one. This means that analyses will only
    perform their end-of-function actions at the end of the exit block rather than
    additionally at every return instruction.
    tlively authored Nov 6, 2023
    Configuration menu
    Copy the full SHA
    ba2ebea View commit details
    Browse the repository at this point in the history

Commits on Nov 7, 2023

  1. Fix build failure on older Ubuntu (WebAssembly#6085)

    Update the C++20 builder to use Ubuntu 20.04 to catch problems building with its
    system compiler. Also fix such a problem in wasm-fuzz-lattices.cpp.
    tlively authored Nov 7, 2023
    Configuration menu
    Copy the full SHA
    0167c65 View commit details
    Browse the repository at this point in the history

Commits on Nov 8, 2023

  1. [Parser] Parse call and return_call (WebAssembly#6086)

    To support parsing calls, add support for parsing function indices and building
    calls with IRBuilder.
    tlively authored Nov 8, 2023
    Configuration menu
    Copy the full SHA
    3640f9c View commit details
    Browse the repository at this point in the history
  2. LocalCSE: Do not optimize small things like global.get (WebAssembly#6087

    )
    
    LocalCSE is nice for large expressions, but for small things it has always been of
    unclear benefit since VMs also do GVN/CSE anyhow. So we are likely not speeding
    anything up, but hopefully we are reducing code size at least. Doing LocalCSE on
    something small like a global.get is very possibly going to increase code size,
    however (since we add a tee, and since the local gets are of similar size to global
    gets - depends on LUB sizes). On real-world Java code that overhead is noticeable,
    so this PR makes us more careful, and we skip things of size 1 (no children).
    kripken authored Nov 8, 2023
    Configuration menu
    Copy the full SHA
    9627c83 View commit details
    Browse the repository at this point in the history
  3. Move --separate-data-segments into a pass so it can be run from wasm-…

    …opt (WebAssembly#6088)
    
    Because we currently strip some data segments (i.e. EM_JS strings)
    during `--post-emscripten` this is too late as `--separate-data-segments`
    always runs in `wasm-emscripten-finalize`.
    
    Once emscripten switches over to using the pass directly we can remove
    the support from `wasm-emscripten-finalize`
    sbc100 authored Nov 8, 2023
    Configuration menu
    Copy the full SHA
    7849601 View commit details
    Browse the repository at this point in the history
  4. [analysis] Add an experimental TypeGeneralizing optimization (WebAsse…

    …mbly#6080)
    
    This new optimization will eventually weaken casts by generalizing (i.e.
    un-refining) their output types. If a cast is weakened enough that its output
    type is a supertype of its input type, the cast will be able to be removed by
    OptimizeInstructions.
    
    Unlike refining cast inputs, generalizing cast outputs can break module
    validation. For example, if the result of a cast is stored to a local and the
    cast is weakened enough that its output type is no longer a subtype of that
    local's type, then the local.set after the cast will no longer validate. To
    avoid this validation failure, this optimization would have to generalize the
    type of the local as well. In general, the more we can generalize the types of
    program locations, the more we can weaken casts of values that flow into those
    locations.
    
    This initial implementation only generalizes the types of locals and does not
    actually weaken casts yet. It serves as a proof of concept for the analysis
    required to perform the full optimization, though. The analysis uses the new
    analysis framework to perform a reverse analysis tracking type requirements for
    each local and reference-typed stack value in a function.
    
    Planned and potential future work includes:
    
     - Implementing the transfer function for all kinds of expressions.
     - Tracking requirements on the dynamic types of each location to generalize
       allocations as well.
     - Making the analysis interprocedural and generalizing the types of more
       program locations.
     - Optimizing tuple-typed locations.
     - Generalizing only those locations necessary to eliminate at least one cast
       (although this would make the anlysis bidirectional, so it is probably better
       left to separate passes).
    tlively authored Nov 8, 2023
    Configuration menu
    Copy the full SHA
    d6df91b View commit details
    Browse the repository at this point in the history

Commits on Nov 9, 2023

  1. Heap2Local: Fix an ordering issue with children having different inte…

    …ractions with a parent (WebAssembly#6089)
    
    We had a simple rule that if we reach an expression twice then we give up, which makes
    sense for say a block: if one allocation flows out of it, then another can't - it would get
    mixed in with the other one, which is a case we don't optimize. However, there are
    cases where a parent has multiple children and different interactions with them, like
    a struct.set: the reference child does not escape, but the value child does. Before this
    PR if we reached the value child first, we'd mark the parent as seen, and then the reference
    child would see it isn't the first to get here, and not optimize.
    
    To fix this, reorder the code to handle this case. The manner of interaction between the
    child and the parent decides whether we mark the parent as seen and to be further
    avoided.
    
    Noticed by the determinism fuzzer, since the order of analysis mattered here.
    kripken authored Nov 9, 2023
    Configuration menu
    Copy the full SHA
    c37fc09 View commit details
    Browse the repository at this point in the history
  2. [NFC] StackIR: Add comments on local2stack handling of tuples (WebAss…

    …embly#6092)
    
    Also add testcases to be comprehensive and notice changes if we ever decide to
    modify that behavior.
    kripken authored Nov 9, 2023
    Configuration menu
    Copy the full SHA
    536b066 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    b8422c5 View commit details
    Browse the repository at this point in the history
  4. [Parser][NFC] Filter out unused instructions in gen-s-parser.py (WebA…

    …ssembly#6095)
    
    The new wat parser parses block, if, loop, then, and else keywords directly
    rather than depending on code generated from gen-s-parser.py. Filter these
    keywords out in gen-s-parser.py when generating the new wat parser and delete
    the stub functions that the removed generated code used to depend on.
    tlively authored Nov 9, 2023
    Configuration menu
    Copy the full SHA
    b289577 View commit details
    Browse the repository at this point in the history
  5. [NFC] Add explicit deduction guides for CTAD (WebAssembly#6094)

    Class template argument deduction (CTAD) is a C++17 feature that allows
    variables to be declared with class template types without specifying the
    template parameters. Deduction guides are a mechanism by which template authors
    can control how the template parameters are inferred when CTAD is used. The
    Google style guide prohibits the use of CTAD except where template authors opt
    in to supporting it by providing explicit deduction guides. For compatibility
    with users adhering to Google style, set the compiler flag to check this
    condition and add the necessary deduction guides to make the compiler happy
    again.
    tlively authored Nov 9, 2023
    Configuration menu
    Copy the full SHA
    af93434 View commit details
    Browse the repository at this point in the history

Commits on Nov 13, 2023

  1. [Outlining] Adds Outlining pass (WebAssembly#6110)

    Adds an outlining pass that performs outlining on a module end to end, and two tests.
    ashleynh authored Nov 13, 2023
    Configuration menu
    Copy the full SHA
    84f51cd View commit details
    Browse the repository at this point in the history

Commits on Nov 14, 2023

  1. OptimizeAddedConstants: Handle a final added constant properly (WebAs…

    …sembly#6115)
    
    We had an assert there that was wrong. In fact the assert is just in one of two code paths,
    and an optional one: the end situation is we have an expression and a constant to add to it,
    and the assert was in the case that the expression is a Const so we can do the add at
    compile time (the other code path does the add at runtime). This code path is optional as
    Precompute would do such compile-time addition anyhow, but it is nice to fix and leave that
    path so that this pass emits fully optimal code.
    kripken authored Nov 14, 2023
    Configuration menu
    Copy the full SHA
    c0d1902 View commit details
    Browse the repository at this point in the history
  2. [NFC] Add LocalLocation for future use (WebAssembly#6105)

    This is not needed in GUFA as it tracks local values precisely (each set is connected to
    the gets that actually read from it), but in a future PR it will be useful to track local
    values per index (each set is connected to all gets for that index, i.e., each local index
    is a single "location").
    kripken authored Nov 14, 2023
    Configuration menu
    Copy the full SHA
    53e6e86 View commit details
    Browse the repository at this point in the history
  3. [Outlining] Add SKIP_OUTLINING macro

    Allow outlining to be excluded from the command line on non-Emscripten builds.
    ashleynh authored Nov 14, 2023
    Configuration menu
    Copy the full SHA
    1c3a5be View commit details
    Browse the repository at this point in the history
  4. Remove various testing spam (WebAssembly#6109)

    Avoid some common warnings and stop printing various stdout/stderr stuff.
    
    Helps WebAssembly#6104
    kripken authored Nov 14, 2023
    Configuration menu
    Copy the full SHA
    77facb1 View commit details
    Browse the repository at this point in the history

Commits on Nov 15, 2023

  1. Configuration menu
    Copy the full SHA
    9846aab View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    8eb4899 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    325d588 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    b01c950 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    89fd9c8 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    1496f97 View commit details
    Browse the repository at this point in the history
  7. [Parser] Parse call_ref (WebAssembly#6103)

    Also mark array.new_elem as unimplemented as a drive-by; it previously had an
    incorrect implementation.
    tlively authored Nov 15, 2023
    Configuration menu
    Copy the full SHA
    001be44 View commit details
    Browse the repository at this point in the history
  8. SignatureRefining: Notice LUB requirements of intrinsic calls (WebAss…

    …embly#6122)
    
    call.without.effects implies a call to the function reference in the last parameter,
    so the values sent in the other parameters must be taken into account when
    computing LUBs for refining arguments, otherwise we might refine so much that
    the intrinsic call no longer validates.
    kripken authored Nov 15, 2023
    Configuration menu
    Copy the full SHA
    20fe882 View commit details
    Browse the repository at this point in the history
  9. Implement more TypeGeneralizing transfer functions (WebAssembly#6118)

    Finish the transfer functions for all expressions except for string
    instructions, exception handling instructions, tuple instructions, and branch
    instructions that carry values. The latter require more work in the CFG builder
    because dropping the extra stack values happens after the branch but before the
    target block.
    tlively authored Nov 15, 2023
    Configuration menu
    Copy the full SHA
    bf76357 View commit details
    Browse the repository at this point in the history

Commits on Nov 16, 2023

  1. [NFC] Refactor out subtyping discovery code (WebAssembly#6106)

    This implements an idea I mentioned in the past, to extract the subtyping discovery
    code out of Unsubtyping so it could be reused elsewhere. Example possible uses:
    the validator could use to remove a lot of code, and also a future PR of mine will
    need it. Separately from those, I think this is a nice refactoring as it makes Unsubtyping
    much smaller.
    
    This just moves the code out and adds some C++ template elbow grease as needed.
    kripken authored Nov 16, 2023
    Configuration menu
    Copy the full SHA
    1fcb57e View commit details
    Browse the repository at this point in the history
  2. [Outlining] Adding more tests (WebAssembly#6117)

    Checking a couple of testing TODOs off and adding more tests of the outlining pass for outlining:
    - a sequence at the beginning of an existing function
    - a sequence that is outlined into a function that takes no arguments
    - multiple sequences from the same source function into different outlined functions
    ashleynh authored Nov 16, 2023
    Configuration menu
    Copy the full SHA
    2412c32 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    0e37557 View commit details
    Browse the repository at this point in the history
  4. Update IRBuilder to visit control flow correctly (WebAssembly#6124)

    Besides If, no control flow structure consumes values from the stack. Fix a
    bug in IRBuilder that was causing it to pop control flow children. Also fix a
    follow on bug in outlining where it did not make the If condition available on
    the stack when starting to visit an If. This required making push() part of
    the public API of IRBuilder.
    
    As a drive-by, also add helpful debug logging to IRBuilder.
    
    Co-authored-by: Ashley Nelson <[email protected]>
    tlively and ashleynh authored Nov 16, 2023
    Configuration menu
    Copy the full SHA
    5241d87 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    b43b70d View commit details
    Browse the repository at this point in the history

Commits on Nov 17, 2023

  1. [Outlining] Adds filter tests (WebAssembly#6119)

    Adds tests that ensure outlining is skipping repeat sequences that include local.get, local.set, br, and return instructions.
    ashleynh authored Nov 17, 2023
    Configuration menu
    Copy the full SHA
    7ae1185 View commit details
    Browse the repository at this point in the history
  2. [Outlining] Test single and multivalue return (WebAssembly#6120)

    Adds two tests, creates an outlined function that returns a single value and creates an outlined function that returns multivalue.
    ashleynh authored Nov 17, 2023
    Configuration menu
    Copy the full SHA
    67f2fdc View commit details
    Browse the repository at this point in the history

Commits on Nov 21, 2023

  1. [IRBuilder] Add visitCallIndirect and makeCallIndirect (WebAssembly#6127

    )
    
    Adds support for call_indirect to wasm-ir-builder. Tests this works by outlining a sequence including call_indirect.
    ashleynh authored Nov 21, 2023
    Configuration menu
    Copy the full SHA
    a1e8bdc View commit details
    Browse the repository at this point in the history
  2. Fix a bug with unreachable control flow in IRBuilder (WebAssembly#6130)

    When branches target control flow structures other than blocks or loops, the
    IRBuilder wraps those control flow structures with an extra block for the
    branches to target in Binaryen IR. Usually that block has the same type as the
    control flow structure it wraps, but when the control flow structure is
    unreachable because all its bodies are unreachable, the wrapper block may still
    need to have a non-unreachable type if it is targeted by branches.
    
    Previously the wrapper block would also be unreachable in that case. Fix the bug
    by tracking whether the wrapper block will be targeted by any branches and use
    the control flow structure's original, non-unreachable type if so.
    tlively authored Nov 21, 2023
    Configuration menu
    Copy the full SHA
    beb816b View commit details
    Browse the repository at this point in the history
  3. [Parser] Parse tags and throw (WebAssembly#6126)

    Also fix the parser to correctly error if an imported item appears after a
    non-imported item and make the corresponding fix to the test.
    tlively authored Nov 21, 2023
    Configuration menu
    Copy the full SHA
    cccc7a6 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    c5db74c View commit details
    Browse the repository at this point in the history

Commits on Nov 27, 2023

  1. Configuration menu
    Copy the full SHA
    e031490 View commit details
    Browse the repository at this point in the history

Commits on Nov 28, 2023

  1. Improve browser build target (WebAssembly#6135)

    * No `SINGLE_FILE` when building for browser
    * Ensure `STACK_SIZE` is big enough
    * Fix indentation
    tomayac authored Nov 28, 2023
    Configuration menu
    Copy the full SHA
    2ea7668 View commit details
    Browse the repository at this point in the history
  2. [NFC] Move InstrumentedPass logic out and use it in another place (We…

    …bAssembly#6132)
    
    Asyncify gained a way to wrap a pass so that it only runs on a given set of
    functions, rather than on all functions, so the wrapper "filters" what the pass
    operates on. That was useful in Asyncify as we wanted to only do work on
    functions that Asyncify actually instrumented.
    
    There is another place in the code that needs such functionality,
    optimizeAfterInlining, which runs optimizations after we inline; again, we
    only want to optimize on the functions we know are relevant because they
    changed. To do that, move that logic out to a general place so it can be
    reused. This makes the code there a lot less hackish.
    
    While doing so make the logic only work on function-parallel passes. It
    never did anyhow, but now it asserts on that. (It can't run on a general
    pass because a general one does not provide an interface to affect which
    functions it operates on; a general pass is entirely opaque in that way.)
    kripken authored Nov 28, 2023
    Configuration menu
    Copy the full SHA
    dbcac17 View commit details
    Browse the repository at this point in the history

Commits on Nov 30, 2023

  1. Configuration menu
    Copy the full SHA
    2474258 View commit details
    Browse the repository at this point in the history
  2. [Parser] Parse try/catch/catch_all/delegate (WebAssembly#6128)

    Parse the legacy v3 syntax for try/catch/catch_all/delegate in both its folded
    and unfolded forms.
    
    The first sources of significant complexity is the optional IDs after `catch`
    and `catch_all` in the unfolded form, which can be confused for tag indices and
    require backtracking to parse correctly.
    
    The second source of complexity is the handling of delegate labels, which are
    relative to the try's parent scope despite being parsed after the try's scope
    has already started. Handling this correctly requires punching a whole big
    enough to drive a truck through through both the parser and IRBuilder
    abstractions.
    tlively authored Nov 30, 2023
    Configuration menu
    Copy the full SHA
    71b9cc0 View commit details
    Browse the repository at this point in the history
  3. wasm-metadce: Improve name deduplication (WebAssembly#6138)

    Avoid adding suffixes when we don't need them to keep names unique.
    
    As background, the suffixes are not used by emcc at all, so they are just
    for internal use in the tool. How that works is that metadce gets as input
    the list of things the user cares about, with names for them, so it knows
    the proper names to give imports and exports, and makes up names for
    other things. Those made up names will not be read by the user, so we
    can make them prettier as this PR does without breaking anything.
    
    The main benefit of this PR is to make debugging easier.
    kripken authored Nov 30, 2023
    Configuration menu
    Copy the full SHA
    a191d66 View commit details
    Browse the repository at this point in the history
  4. wasm-metadce all the things (WebAssembly#6142)

    Remove hardcoded paths for globals/functions/etc. in favor of general code
    paths that support all the module elements uniformly. As a result of that, we
    now support all parts of wasm, such as tables and element segments, that
    we didn't before.
    
    This refactoring is NFC aside from adding functionality. Note that this reduces
    the size of wasm-metadce by 10% while increasing its functionality - the
    benefits of writing generic code.
    
    To support this, add some trivial generic helpers to get or iterate over module
    elements using their kind in a dynamic manner. Using them might make
    wasm-metadce slightly slower, but I can't measure any difference.
    kripken authored Nov 30, 2023
    Configuration menu
    Copy the full SHA
    42cddbf View commit details
    Browse the repository at this point in the history

Commits on Dec 5, 2023

  1. Inlining: Inline trivial calls (WebAssembly#6143)

    A trivial call is something like a function that just calls another immediately,
    
    function foo(x, y) {
      return bar(y, 15);
    }
    
    We can inline those and expect to benefit in most cases, though we might
    increase code size slightly. Hence it makes sense to inline such cases, even
    though in general we are careful and do not inline functions with calls in
    them; a "trampoline" like that likely has most of the work in the call itself,
    which we can avoid by inlining.
    
    Suggested based on findings in Java.
    kripken authored Dec 5, 2023
    Configuration menu
    Copy the full SHA
    66277f9 View commit details
    Browse the repository at this point in the history

Commits on Dec 6, 2023

  1. Add no-inline IR annotation, and passes to set it based on function n…

    …ame (WebAssembly#6146)
    
    Any function can now be annotated as not to be inlined fully (normally) or not to be
    inlined partially. In the future we'll want to read those annotations from the proposed
    wasm metadata section on code hints, and from wat text as well, but for now add
    trivial passes that set those fields based on function name wildcards, e.g.:
    
    --no-inline=*leave-alone* --inlining
    
    That will not inline any function whose name contains "leave-alone" in the name.
    
    --no-inline disables all inlining (full or partial) while --no-full-inline and
    --no-partial-inline affect only full or partial inlining.
    kripken authored Dec 6, 2023
    Configuration menu
    Copy the full SHA
    f722171 View commit details
    Browse the repository at this point in the history

Commits on Dec 7, 2023

  1. [Parser] Parse tables and element segments (WebAssembly#6147)

    These module fields are especially complex to parse because they contain both
    nontrivial types and instructions, so their parsing logic needs to be spread out
    across the ParseDecls, ParseModuleTypes, and ParseDefs phases of parsing. This
    applies to in-line elements in table definitions as well, which means we need to
    be able to match a table to its in-line element segment across multiple phases.
    tlively authored Dec 7, 2023
    Configuration menu
    Copy the full SHA
    4a83a0f View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    89ad929 View commit details
    Browse the repository at this point in the history
  3. [Outlining] Fix outlining control flow

    Changes the controlFlowQueue used in stringify-walker to push values of Expression*,  This ensures that we walk the Wasm module in the same order, regardless of whether the control flow expression is outlined.
    
    Reviewers: tlively
    
    Reviewed By: tlively
    
    Pull Request: WebAssembly#6139
    ashleynh authored Dec 7, 2023
    Configuration menu
    Copy the full SHA
    b8cf386 View commit details
    Browse the repository at this point in the history
  4. [Outlining] Improve debug logging

    - Change outlining debug logs to use std::cerr
    - Add controlFlowQueue push log
    - Fix build error with wasm-ir-builder log's use of ShallowExpression
    
    Reviewers: tlively
    
    Reviewed By: tlively
    
    Pull Request: WebAssembly#6140
    ashleynh authored Dec 7, 2023
    Configuration menu
    Copy the full SHA
    e28efb0 View commit details
    Browse the repository at this point in the history
  5. [Outlining] Add loop instruction support

    Adds support for the loop instruction to be outlined and a test showing a repeat loop being outlined.
    
    Reviewers: tlively
    
    Reviewed By: tlively
    
    Pull Request: WebAssembly#6141
    ashleynh authored Dec 7, 2023
    Configuration menu
    Copy the full SHA
    2049ee8 View commit details
    Browse the repository at this point in the history
  6. [Outlining] Add variations of call_indirect tests

    Mixes up the number of results, params, and operands used in
    call_indirect instructions that are outlined. Also adds a function
    identifier to the original call_indirect test to improve test output
    readability.
    
    Reviewers: tlively
    
    Reviewed By: tlively
    
    Pull Request: WebAssembly#6152
    ashleynh authored Dec 7, 2023
    Configuration menu
    Copy the full SHA
    f2eea9d View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    9efe1d0 View commit details
    Browse the repository at this point in the history

Commits on Dec 8, 2023

  1. binaryen.js: Remove closure flags that set the ES version (WebAssembl…

    …y#6157)
    
    Emscripten sets that itself these days.
    kripken authored Dec 8, 2023
    Configuration menu
    Copy the full SHA
    7dec416 View commit details
    Browse the repository at this point in the history
  2. [test] Move basic tests in lit/ to lit/basic/ (WebAssembly#6156)

    Here 'basic' tests means that what we have in `binaryen/test/`. We checked
    three things with those tests:
    - Run `wasm-opt -all -g` on it and compare the output with `*.from-wast`
    - Run `wasm-as -all -g` and `wasm-dis` on it and compare the output with
      `*.fromBinary`.
    - Run `wasm-as -all` and `wasm-dis` on it and compare the output with
      `*.fromBinary.noDebugInfo`.
    
    I planned to move those to `test/lit/`. But `test/lit/` has other kind of
    tests as well, so I think it'd be nice to have a dedicated directory for
    these tests.
    
    Before doing that, I noticed there are already four tests that have been
    already ported to do this, and this PR moves them to `test/lit/basic/`.
    
    I couldn't come up with a better name than `basic`. If you have other
    suggestions please let me know.
    aheejin authored Dec 8, 2023
    Configuration menu
    Copy the full SHA
    48373b6 View commit details
    Browse the repository at this point in the history
  3. [EH] Add exnref type back (WebAssembly#6149)

    At the Oct hybrid CG meeting, we decided to add back `exnref`, which was
    removed in 2020:
    https://github.com/WebAssembly/meetings/blob/main/main/2023/CG-10.md
    
    The new version of the proposal reflected in the explainer:
    https://github.com/WebAssembly/exception-handling/blob/main/proposals/exception-handling/Exceptions.md
    
    While adding support for `exnref` in the current codebase which has all
    GC subtype hierarchies, I noticed we might need `noexn` heap type for
    the bottom type of `exn`. We don't have it now so I just set it to 0xff
    for the moment.
    aheejin authored Dec 8, 2023
    Configuration menu
    Copy the full SHA
    1d615b3 View commit details
    Browse the repository at this point in the history

Commits on Dec 12, 2023

  1. [CI] Use --break-system-packages on Alpine (WebAssembly#6167)

    Something changed in how CI sets up Python and now this is needed to avoid an error.
    kripken authored Dec 12, 2023
    Configuration menu
    Copy the full SHA
    cfb2a6e View commit details
    Browse the repository at this point in the history
  2. [test] Make get_tests return only files (WebAssembly#6164)

    Currently `get_tests` returns files and directories, especially when
    the extension is not given. This makes `get_tests` return a directory
    like `test/wasm2js/` as a test.
    
    `wasm2js.py`'s `check_for_stale_files` errors out when there are files
    within `test/wasm2js/` whose basenames don't match any files within any
    of `test/`, `test/spec/`, `test/wasm2js/`.
    https://github.com/WebAssembly/binaryen/blob/1d615b38dd4152494d2f4d3520c8b1d917624a30/scripts/test/wasm2js.py#L33-L46
    
    `wasm2js.wast.asserts` is apparently a special case for asserts test:
    https://github.com/WebAssembly/binaryen/blob/1d615b38dd4152494d2f4d3520c8b1d917624a30/scripts/test/wasm2js.py#L28
    and this doesn't seem to have the matching `wast` tests in the three
    test directories. But it just happened to not error out because
    `get_tests` returns directory names too and one of them was `wasm2js`
    (`test/wasm2js/` directory).
    
    This makes `get_tests` return only files, and make files in
    `assert_tests` not error out additionally.
    aheejin authored Dec 12, 2023
    Configuration menu
    Copy the full SHA
    9e07c82 View commit details
    Browse the repository at this point in the history
  3. [test] Remove / move *.js tests from test/ (WebAssembly#6163)

    `wasm2js.asserts.js` and `wasm2js.traps.js` seem to be used in wasm2js
    asserts test:
    https://github.com/WebAssembly/binaryen/blob/1d615b38dd4152494d2f4d3520c8b1d917624a30/scripts/test/wasm2js.py#L28
    https://github.com/WebAssembly/binaryen/blob/1d615b38dd4152494d2f4d3520c8b1d917624a30/scripts/test/wasm2js.py#L126-L127
    
    But other `*.js` tests in `test/` don't seem to be used anywhere. Please
    let me know if they are actually being used.
    
    This moves `wasm2js.asserts.js` and `wasm2js.traps.js`, which are only
    used in wasmjs tests, to `test/wasm2js/`, and deletes all other `*.js`
    tests in `test/`.
    aheejin authored Dec 12, 2023
    Configuration menu
    Copy the full SHA
    cba8e18 View commit details
    Browse the repository at this point in the history
  4. [test] Remove asm2wasm tests from scripts (WebAssembly#6162)

    We don't have `*.fromasm` files anymore. Also `BIN_DIR` and
    `WATERFALL_BUILD_DIR` variables don't seem to be used as well.
    aheejin authored Dec 12, 2023
    Configuration menu
    Copy the full SHA
    8613b14 View commit details
    Browse the repository at this point in the history
  5. [test] Tweak RUN commands of test/lit/basic/ (WebAssembly#6159)

    This tweaks generated file names and `filecheck` prefixes to be more
    (IMHO) consistent. Also shortened binary/BINARY to bin/BIN for
    conciseness. This also changes the order of `RUN` commands a little.
    
    And this changes
    ```console
    wasm-opt %t.wast -all -o %t.text.wast -g -S
    ```
    to
    ```console
    wasm-opt %s -all -o %t.text.wast -g -S
    ```
    The current command doesn't take the source file but the generated file
    from the command above `wasm-dis`, which is not the behavior of
    `check.py`. This changes it back to the original source (`%s`).
    
    As a result of `wasm-opt` change, some tests are now failing because of
    the order of `(type)`s. So I just deleted all `CHECK` lines and
    regenerated them using `update_lit_checks.py --all-items`. The large
    amount of `CHECK` line changes are mainly because I moved `CHECK-TEXT`
    before `CHECK-BINARY` and not meaningful.
    aheejin authored Dec 12, 2023
    Configuration menu
    Copy the full SHA
    5db8eb2 View commit details
    Browse the repository at this point in the history
  6. [test] Fix wasm2js stale check failure (WebAssembly#6168)

    I tried to exclude wasm2js asserts tests from `check_for_stale_files` in
     WebAssembly#6164, but ended up doing it incorrectly. The file I checked for was
    `wasm2js.wast.asserts`, while the output I should have excluded was
    `wasm2js.asserts.js`. This fixes the code so we now check the prefix and
    not the filename.
    aheejin authored Dec 12, 2023
    Configuration menu
    Copy the full SHA
    ee113c7 View commit details
    Browse the repository at this point in the history
  7. [EH] Use random value for exnref encoding when legacy GC is used (Web…

    …Assembly#6166)
    
    Currently the legacy GC encoding's nullexternref encoding overlaps with
    exnref's. We assume the legacy GC encoding won't be used with the exnref
    for the moment and assign a random value to it to prevent the clash.
    aheejin authored Dec 12, 2023
    Configuration menu
    Copy the full SHA
    0b70948 View commit details
    Browse the repository at this point in the history
  8. Inlining: Copy no-inline flags when copying a function (WebAssembly#6165

    )
    
    Those fields should be copied together with all the rest of the metadata that
    already is. This was just missed in the prior PR.
    kripken authored Dec 12, 2023
    Configuration menu
    Copy the full SHA
    36e21c6 View commit details
    Browse the repository at this point in the history
  9. Add J2CL optimization pass to binaryen. (WebAssembly#6151)

    This PR creates a new pass to optimize J2CL specific patterns
    that would otherwise difficult to recognize/prove generically
    by other binaryen passes.
    
    The pass currently handles fields what we call as "constant-like".
    These fields are fields initialized once and unconditionally through
    "clinit" function and technically they do have 2 observable states;
     - initial null/0 state
     - initialized state.
    However you can only observe initial null/0 state in contrived examples,
    not in real world/correct applications.
    
    This pass moves such "clinit" initialized fields to global initialization.
    
    Above pattern also matches other lazy init construct like String and Class
    literals (which binaryen already reduces to constant expressions). So
    the pass is generalized to include them as well. (by matching any functions
    with the name pattern "_@once_")
    
    In order for this pass to be effective:
    1. It needs to run between O3 passes
    2. We need to stop inlining of "once" functions.
    
    Stopping inlining of the once functions are important to preserve their
    structure. This both helps existing OnceReducer pass and new J2CL pass to
    be a lot more effective. Also it is not useful to inline these functions
    as by defintion they only executed once. This could be achieved by passing
    no-inline filter.
    
    Although the inlining is generally disabled for these functions, it is
    still needed for some cases since inliner is effectively responsible for
    removal of the once functions that are simplified into empty or simple
    delegating functions. For this reason, the pass will rename such trivial
    function so no-inline filter will no longer match them.
    
    Also note that after all optimizations completed, it does make sense to
    have a final stage where the "partial inline" of all once functions are
    allowed. This will speed them up by moving the initialization check to
    call-site.
    gkdn authored Dec 12, 2023
    Configuration menu
    Copy the full SHA
    71dad87 View commit details
    Browse the repository at this point in the history
  10. Update tuple.make text format to include arity (WebAssembly#6169)

    Previously, the number of tuple elements was inferred from the number of
    s-expression children of the `tuple.make` expression, but that scheme would not
    work in the new wat parser, where s-expressions are optional and cannot be
    semantically meaningful.
    
    Update the text format to take the number of tuple elements (i.e. the tuple
    arity) as an immediate. This new format will be able to be implemented in the
    new parser as follow-on work.
    tlively authored Dec 12, 2023
    Configuration menu
    Copy the full SHA
    a2a59e9 View commit details
    Browse the repository at this point in the history
  11. Add a tuple.drop text pseudoinstruction (WebAssembly#6170)

    We previously overloaded `drop` to mean both normal drops of single values and
    also drops of tuple values. That works fine in the legacy text parser since it
    can infer parent-child relationships directly from the s-expression structure of
    the input, so it knows that a drop should drop an entire tuple if the
    tuple-producing instruction is a child of the drop. The new text parser,
    however, is much more like the binary parser in that it uses instruction types
    to create parent-child instructions. The new parser always assumes that `drop`
    is meant to drop just a single value because that's what it does in WebAssembly.
    
    Since we want to continue to let `Drop` IR expressions consume tuples, and since
    we will need a way to write tests for that IR pattern that work with the new
    parser, introduce a new pseudoinstruction, `tuple.drop`, to represent drops of
    tuples. This pseudoinstruction only exists in the text format and it parses to
    normal `Drop` expressions. `tuple.drop` takes the arity of its operand as an
    immediate, which will let the new parser parse it correctly in the future.
    tlively authored Dec 12, 2023
    Configuration menu
    Copy the full SHA
    a6c1165 View commit details
    Browse the repository at this point in the history
  12. J2CL: Add extra guardrails (WebAssembly#6171)

    The patch puts a new guardrail that will only hoist the field
    if it is initialized with the owner class.
    
    The constant hoisting optimization in J2CL pass relies on the
    assumption that clinit that will initialize the field will be
    executed before the read of the field. That means the field
    that is optimized is within the same class:
    
    class Foo {
      public static final Object field = new Object();
    }
    
    Although it is possible to observe the initial value, that is
    not intention of the developer (which the point of the
    optimization).
    
    However can also see a similar pattern in following:
    
    class Foo {
      public static Object field;
    }
    
    class Zoo {
      static {
        Foo.field = new Object();
      }
    }
    
    Currently the pass also optimizes it as well since the field
    is only initialized once and by a clinit. However Zoo clinit
    is not guaranteed to be run before Foo.field access so it is
    less safe to speculate on the intention of the developer here
    hence it is not worth the risk.
    
    FWIW, we haven't seen this issue. But this is something we
    are also guarding in Closure Compiler so I decided it is
    worthwhile to do here as well.
    gkdn authored Dec 12, 2023
    Configuration menu
    Copy the full SHA
    da18e25 View commit details
    Browse the repository at this point in the history
  13. [Parser] Parse table operations (WebAssembly#6154)

    Including table.get, table.set, table.size, table.grow, table.fill, and
    table.copy.
    tlively authored Dec 12, 2023
    Configuration menu
    Copy the full SHA
    b59b2fc View commit details
    Browse the repository at this point in the history

Commits on Dec 13, 2023

  1. Add an arity immediate to tuple.extract (WebAssembly#6172)

    Once support for tuple.extract lands in the new WAT parser, this arity immediate
    will let the parser determine how many values it should pop off the stack to
    serve as the tuple operand to `tuple.extract`. This will usually coincide with
    the arity of a tuple-producing instruction on top of the stack, but in the
    spirit of treating the input as a proper stack machine, it will not have to and
    the parser will still work correctly.
    tlively authored Dec 13, 2023
    Configuration menu
    Copy the full SHA
    28bea54 View commit details
    Browse the repository at this point in the history
  2. [Parser] Parse rethrow (WebAssembly#6155)

    Like `delegate`, rethrow takes a `Try` label. Refactor the delegate handling so
    that `Try` can share its logic.
    tlively authored Dec 13, 2023
    Configuration menu
    Copy the full SHA
    8e91992 View commit details
    Browse the repository at this point in the history
  3. [Parser] Parse the remaining array operations (WebAssembly#6158)

    Parse `array.new_elem`, `array.init_data`, and `array.init_elem`.
    
    Accidentally also includes:
    
    * [Parser] Parse string types and operations (WebAssembly#6161)
    tlively authored Dec 13, 2023
    Configuration menu
    Copy the full SHA
    9e63685 View commit details
    Browse the repository at this point in the history
  4. [test] Port tests in test/ to test/lit/basic/ (WebAssembly#6160)

    This ports all tests from `test/` to `test/lit/basic/`. The set of
    commands and `CHECK` lines used are the same as the ones in WebAssembly#6159. Now
     we use `lit` to test these, this also deletes all `.wast`,
    `.wast.from-wast`, `.wast.fromBinary`, and
    `.wast.fromBinary.noDebugInfo` files from `test/` and all related test
    routines from the python scripts.
    
    All `CHECK` lines are generated by `update_lit_checks.py --all-items`.
    
    This also deletes these three multi-memory tests in `test/lit/`, because
    they seem to contain the same code with the ones in `test/`, which have
    been ported to `test/lit/basic/` along with other tests.
    - `test/lit/multi-memories-atomics64.wast`
    - `test/lit/multi-memories-basics.wast`
    - `test/lit/multi-memories-simd.wast`
    
    This also adds newlines between `(func`s in case there are none to make
    `CHECK` lines easy to view, and removes some extra existing newlines
    here and there.
    aheejin authored Dec 13, 2023
    Configuration menu
    Copy the full SHA
    0024c8b View commit details
    Browse the repository at this point in the history
  5. [EH][test] Slice test code into different functions (WebAssembly#6177)

    We ported basic tests to `test/lit/basic/` in WebAssembly#6160, but comparing
    `CHECK` lines with the test code for long functions is not easy, even
    though it wouldn't necessarily be worse than the the separate files we
    used to have in `test/`. This slices `exception-handling.wast` into
    functions so that the `CHECK` lines are easy to check.
    aheejin authored Dec 13, 2023
    Configuration menu
    Copy the full SHA
    1da1363 View commit details
    Browse the repository at this point in the history
  6. J2CL: Use a more future proof naming convention for once functions (W…

    …ebAssembly#6173)
    
    Existing convention uses _@once@_ but we also use @ for class separation.
    It is cleaner&more future proof to use something other convention like _<once>_.
    gkdn authored Dec 13, 2023
    Configuration menu
    Copy the full SHA
    61c3666 View commit details
    Browse the repository at this point in the history
  7. [EH][test] Split EH tests into old and new spec (WebAssembly#6178)

    This moves tests for the old EH spec to `exception-handling-old.wast`
    and moves the new `exnref` test into `exception-handling.wast`, onto
    which I plan to add more tests for the new EH spec.
    
    The primary reason for splitting the files is I plan to exclude the new
    EH test from the fuzzing while the new spec's implementation is in
    progress, and I don't want to exclude the old EH tests altogether.
    aheejin authored Dec 13, 2023
    Configuration menu
    Copy the full SHA
    94f9b9a View commit details
    Browse the repository at this point in the history
  8. Preserve multivalue drops in IRBuilder (WebAssembly#6150)

    In Binaryen IR, we allow single `Drop` expressions to drop multiple values
    packaged up as a tuple. When using IRBuilder to rebuild IR containing such a
    drop, it previously treated the drop as a normal WebAssembly drop that dropped
    only a single value, producing invalid IR that had extra, undropped values. Fix
    the problem by preserving the arity of `Drop` inputs in IRBuilder. To avoid
    bloating the IR, thread the size of the desired value through IRBuilder's pop
    implementation so that tuple values do not need to be split up and recombined.
    tlively authored Dec 13, 2023
    Configuration menu
    Copy the full SHA
    e9b012f View commit details
    Browse the repository at this point in the history
  9. [Parser] Parse tuple operations (WebAssembly#6174)

    Parse `tuple.make`, `tuple.extract`, and `tuple.drop`. Also slightly improve the
    way we break up tuples into individual elements in IRBuilder by using a
    `local.tee` instead of a block containing a `local.set` and `local.get`.
    tlively authored Dec 13, 2023
    Configuration menu
    Copy the full SHA
    7adc82b View commit details
    Browse the repository at this point in the history

Commits on Dec 14, 2023

  1. Configuration menu
    Copy the full SHA
    bdd96e8 View commit details
    Browse the repository at this point in the history
  2. Remove empty _ARRAY/_VECTOR defines (NFC) (WebAssembly#6182)

    `_VECTOR` or `_ARRAY` defines in `wasm-delegations-fields.def` are
    supposed to be defined in terms of their non-vector/array counterparts
    when undefined. This removes empty `_VECTOR`/`_ARRAY` defines when
    including `wasm-delegations-fields.def`, while adding definitions for
    `DELEGATE_GET_FIELD` in case it is missing.
    aheejin authored Dec 14, 2023
    Configuration menu
    Copy the full SHA
    cad983c View commit details
    Browse the repository at this point in the history

Commits on Dec 19, 2023

  1. [EH] Add instructions for new proposal (WebAssembly#6181)

    This adds basic support for the new instructions in the new EH proposal
    passed at the Oct CG hybrid CG meeting:
    https://github.com/WebAssembly/meetings/blob/main/main/2023/CG-10.md
    https://github.com/WebAssembly/exception-handling/blob/main/proposals/exception-handling/Exceptions.md
    
    This mainly adds two instructions: `try_table` and `throw_ref`. This is
    the bare minimum required to read and write text and binary format, and
    does not include analyses or optimizations. (It includes some analysis
    required for validation of existing instructions.) Validation for
    the new instructions is not yet included.
    
    `try_table` faces the same problem with the `resume` instruction in
     WebAssembly#6083 that without the module-level tag info, we are unable to know the
    'sent types' of `try_table`. This solves it with a similar approach
    taken in WebAssembly#6083: this adds `Module*` parameter to `finalize` methods,
    which defaults to `nullptr` when not given. The `Module*` parameter is
    given when called from the binary and text parser, and we cache those
    tag types in `sentTypes` array within `TryTable` class. In later
    optimization passes, as long as they don't touch tags, it is fine to
    call `finalize` without the `Module*`. Refer to
    WebAssembly#6083 (comment)
    and WebAssembly#6096 for related discussions when `resume` was added.
    aheejin authored Dec 19, 2023
    Configuration menu
    Copy the full SHA
    4c53361 View commit details
    Browse the repository at this point in the history
  2. Add tuple.drop validation (WebAssembly#6186)

    Without this fuzzer testcases fail if the initial content has a tuple.drop but multivalue
    is disabled (then the initial content validates erroneously, and that content is remixed
    into more content using multivalue which fails to validate).
    kripken authored Dec 19, 2023
    Configuration menu
    Copy the full SHA
    eb5666e View commit details
    Browse the repository at this point in the history

Commits on Dec 20, 2023

  1. [EH] Add validation for new instructions (WebAssembly#6185)

    This adds validation for the new EH instructions (`try_table` and
    `throw_ref`):
    https://github.com/WebAssembly/exception-handling/blob/main/proposals/exception-handling/Exceptions.md
    
    This also adds a spec test for checking invalid modules. We cannot check
    the executions yet because we don't have the interpreter implementation.
    The new test file also contains tests for the existing `throw`, because
    this is meant to replace the old spec test someday.
    aheejin authored Dec 20, 2023
    Configuration menu
    Copy the full SHA
    11e3af0 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    a5235cb View commit details
    Browse the repository at this point in the history
  3. [EH][test] Add a few more tests (WebAssembly#6189)

    This adds tests that test all four kinds of `catch` clauses for an empty
    tag and a multivalue tag. (Previously we had this test only for an `i32`
    tag.)
    aheejin authored Dec 20, 2023
    Configuration menu
    Copy the full SHA
    2b81d39 View commit details
    Browse the repository at this point in the history
  4. Drop support for non-standard quoted function names (WebAssembly#6188)

    We previously supported a non-standard `(func "name" ...` syntax for declaring
    functions exported with the quoted name. Since that is not part of the standard
    text format, drop support for it, replacing it with the standard `(func $name
    (export "name") ...` syntax instead.
    
    Also replace our other usage of the quoted form in our text output, which was
    where we quoted names containing characters that are not allowed to appear in
    standard names. To handle that case, adjust our output from `"$name"` to
    `$"name"`, which is the standards-track way of supporting such names. Also fix
    how we detect non-standard name characters to match the spec.
    
    Update the lit test output generation script to account for these changes,
    including by making the `$` prefix on names mandatory. This causes the script to
    stop interpreting declarative element segments with the `(elem declare ...`
    syntax as being named "declare", so prevent our generated output from regressing
    by counting "declare" as a name in the script.
    tlively authored Dec 20, 2023
    Configuration menu
    Copy the full SHA
    fb7d00b View commit details
    Browse the repository at this point in the history

Commits on Dec 21, 2023

  1. Unify method pairs with and without Type param (WebAssembly#6184)

    As suggested in
    WebAssembly#6181 (comment),
    using `std::optional<Type>`, this unifies two different versions of
    `make***`, for  block-like structures (`block`, `if`, `loop`, `try`, and
    `try_table`) with and without a type parameter.
    
    This also allows unifying of `finalize` methods, with and without a
    type. This also sets `breakability` argument of `Block::finalize` to
    `Unknown` so we can only have one `Block::finalize` that handles all
    cases.
    
    This also adds an optional `std::optional<Type> type` parameter to
    `blockifyWithName`, and `makeSequence` functions in `wasm-builder.h`.
    blockify was not included because it has a variadic parameter.
    aheejin authored Dec 21, 2023
    Configuration menu
    Copy the full SHA
    98cef80 View commit details
    Browse the repository at this point in the history

Commits on Jan 2, 2024

  1. Match names more precisely in update_lit_checks.py (WebAssembly#6190)

    Previously the lit test update script interpreted module names as the names of
    import items and export names as the names of export items, but it is more
    precise to use the actual identifiers of the imported or exported items as the
    names instead.
    
    Update update_lit_checks.py to use a more correct regex to match names and to
    correctly use the identifiers of import and export items as their names. In some
    cases this can improve the readability of test output.
    tlively authored Jan 2, 2024
    Configuration menu
    Copy the full SHA
    95ed4f3 View commit details
    Browse the repository at this point in the history
  2. [Parser] Support standalone import definitions (WebAssembly#6191)

    We previously support the in-line import abbreviation, but now add support for
    explicit, non-abbreviated imports as well.
    tlively authored Jan 2, 2024
    Configuration menu
    Copy the full SHA
    5e3f81c View commit details
    Browse the repository at this point in the history
  3. wasm-reduce: Improve tryToReduceCurrentToConst() (WebAssembly#6193)

    Avoid replacing with the exact same thing in the case of RefNull and a default
    tuple.
    
    Also be more careful with handling of numbers. Before we exited immediately
    if we saw a number, but we can try to replace a number with a 0 or a 1, even
    if it was a number before. That is, we consider 1 simpler than e.g. 12345678, and
    0 simpler than 1.
    kripken authored Jan 2, 2024
    Configuration menu
    Copy the full SHA
    4acd476 View commit details
    Browse the repository at this point in the history

Commits on Jan 3, 2024

  1. [EH] Misc. fixes for EH (WebAssembly#6195)

    - Deletes a stray whitespace after `throw_ref`
    - Adds missing `makeThrowRef` to `wasm-builder.h`
    - Adds a case for `TryTable` in `ControlFlowWalker`
    aheejin authored Jan 3, 2024
    Configuration menu
    Copy the full SHA
    260fdfc View commit details
    Browse the repository at this point in the history
  2. [Parser] Parse folded instructions that contain parentheses (WebAssem…

    …bly#6196)
    
    To parse folded instructions in the right order, we need to defer parsing each
    instruction until we have parsed each of its children and found its closing
    parenthesis. Previously we naively looked for parentheses to determine where
    instructions began and ended before we parsed them, but that scheme did not
    correctly handle instructions that can contain parentheses in their immediates,
    such as call_indirect.
    
    Fix the problem by using the actual instruction parser functions with a
    placeholder context to find the end of the instructions, including any kind of
    immediates they might have.
    tlively authored Jan 3, 2024
    Configuration menu
    Copy the full SHA
    a6bc954 View commit details
    Browse the repository at this point in the history
  3. Drop support for type annotations on array.len (WebAssembly#6197)

    These type annotations were removed during the development of the GC proposal,
    but we maintained support for parsing them to ease the transition. Now that GC
    is shipped, remove support for the non-standard annotation and update our tests
    accordingly.
    tlively authored Jan 3, 2024
    Configuration menu
    Copy the full SHA
    c923521 View commit details
    Browse the repository at this point in the history
  4. [Parser] Parse br_on_cast{_fail} input annotations (WebAssembly#6198)

    And validate in IRBuilder both that the input annotation is valid and that the
    input matches it.
    tlively authored Jan 3, 2024
    Configuration menu
    Copy the full SHA
    328bd7a View commit details
    Browse the repository at this point in the history
  5. [Parser] Go back to "sub final" intead of "sub open" (WebAssembly#6199)

    The planned spec change to use "sub open" never came together, so the standard
    format remains "sub final".
    tlively authored Jan 3, 2024
    Configuration menu
    Copy the full SHA
    1878403 View commit details
    Browse the repository at this point in the history
  6. Use the standard shared memory text format (WebAssembly#6200)

    Update the legacy text parser and all tests to use the standard text format for shared memories, e.g. `(memory $m 1 1 shared)` rather than `(memory $m (shared 1 1))`. Also remove support for non-standard in-line "data" or "segment" declarations.
    
    This change makes the tests more compatible with the new text parser, which only supports the standard format.
    tlively authored Jan 3, 2024
    Configuration menu
    Copy the full SHA
    0ed42cf View commit details
    Browse the repository at this point in the history

Commits on Jan 4, 2024

  1. Require then and else with if (WebAssembly#6201)

    We previously supported (and primarily used) a non-standard text format for
    conditionals in which the condition, if-true expression, and if-false expression
    were all simply s-expression children of the `if` expression. The standard text
    format, however, requires the use of `then` and `else` forms to introduce the
    if-true and if-false arms of the conditional. Update the legacy text parser to
    require the standard format and update all tests to match. Update the printer to
    print the standard format as well.
    
    The .wast and .wat test inputs were mechanically updated with this script:
    https://gist.github.com/tlively/85ae7f01f92f772241ec994c840ccbb1
    tlively authored Jan 4, 2024
    Configuration menu
    Copy the full SHA
    a58281c View commit details
    Browse the repository at this point in the history
  2. [Parser] Parse br_if correctly (WebAssembly#6202)

    The new text parser and IRBuilder were previously not differentiating between
    `br` and `br_if`. Handle `br_if` correctly by popping and assigning a condition.
    tlively authored Jan 4, 2024
    Configuration menu
    Copy the full SHA
    d312604 View commit details
    Browse the repository at this point in the history

Commits on Jan 5, 2024

  1. Configuration menu
    Copy the full SHA
    bdafd11 View commit details
    Browse the repository at this point in the history

Commits on Jan 6, 2024

  1. Rename CMake vars for modified intrinsics file (WebAssembly#6204)

    The intrinsics file changed in WebAssembly#6201 and somehow CMake doesn't automatically
    update itself, and needs a manual step for people with existing checkouts (a new
    fresh checkout always works). To avoid annoyance for existing checkouts, rename
    the vars, which forces CMake to recompute the contents.
    kripken authored Jan 6, 2024
    Configuration menu
    Copy the full SHA
    436d639 View commit details
    Browse the repository at this point in the history
  2. Fix branches to loops in IRBuilder (WebAssembly#6205)

    Since branches to loops go to the beginnings of the loops, they should send
    values matching the input types for the loops (which are always none because we
    don't support loop input types). IRBuilder was previously using the output types
    of loops to determine what values the branches should carry, which was
    incorrect. Fix it.
    tlively authored Jan 6, 2024
    Configuration menu
    Copy the full SHA
    c3b2f24 View commit details
    Browse the repository at this point in the history
  3. Fix cmake dependency on wasm-intrinsics.wat (WebAssembly#6206)

    I think this is a nicer/better way to do WebAssembly#6204.
    sbc100 authored Jan 6, 2024
    Configuration menu
    Copy the full SHA
    82057de View commit details
    Browse the repository at this point in the history

Commits on Jan 8, 2024

  1. Fix incorrect wat in tests (WebAssembly#6207)

    The new wat parser is much more strict than the legacy wat parser; the latter
    accepts all sorts of things that the spec does not allow. To ease an eventual
    transition to using the new wat parser by default, update the tests to use the
    standard text format in many places where they previously did not. We do not yet
    have a way to prevent new errors from being introduced into the test suite, but
    at least there will now be many fewer errors when it comes time to make the
    switch.
    tlively authored Jan 8, 2024
    Configuration menu
    Copy the full SHA
    cc0fab9 View commit details
    Browse the repository at this point in the history

Commits on Jan 9, 2024

  1. Fix global effect computation with -O flags (WebAssembly#6211)

    We tested --generate-global-effects --vacuum and such, but not
    --generate-global-effects -O3 or the other -O flags. Unfortunately, our
    targeted testing missed a bug because of that. Specifically, we have special
    logic for -O flags to make sure the passes they expand into run with the
    proper opt and shrink levels, but that logic happened to also interfere with
    global effect computation. It would also interfere with allowing GUFA info
    or other things to be stored on the side, which we've proposed. This PR
    fixes that + future issues.
    
    The fix is to just allow a pass runner to execute more than once. We thought
    to avoid that and assert against it to keep the model "hermetic" (you create
    a pass runner, you run the passes, and you throw it out), which feels nice in
    a way, but it led to the bug here, and I'm not sure it would prevent any other
    ones really. It is also more code. It is simpler to allow a runner to execute more
    than once, and add a method to clear it. With that, the logic for -O3 execution
    is both simpler and does not interfere with anything but the opt and shrink
    level flags: we create a single runner, give it the proper options, and then keep
    using that runner + those options as we go, normally.
    kripken authored Jan 9, 2024
    Configuration menu
    Copy the full SHA
    1850199 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    75145b7 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    20b1ccc View commit details
    Browse the repository at this point in the history

Commits on Jan 10, 2024

  1. [Parser] Parse remaining heap and reference types (WebAssembly#6218)

    Parse types like `exnref` and `nofunc` that we did not previously support.
    tlively authored Jan 10, 2024
    Configuration menu
    Copy the full SHA
    97a61bd View commit details
    Browse the repository at this point in the history
  2. Precompute into select arms (WebAssembly#6212)

    E.g.
    
    (i32.add
      (select
        (i32.const 100)
        (i32.const 200)
        (..condition..)
      )
      (i32.const 50)
    )
    
    ;; =>
    
    (select
      (i32.const 150)
      (i32.const 250)
      (..condition..)
    )
    
    We cannot fully precompute the select, but we can "partially precompute" it, by precomputing
    its arms using the parent.
    
    This may require looking several steps up the parent chain, which is an awkward operation in
    our simple walkers, so to do it we capture stacks of parents and operate directly on them. This
    is a little slower than a normal walk, so only do it when we see a promising select, and only in
    -O2 and above (this makes the pass 7% or so slower; not a large cost, but best to avoid it in
    -O1).
    kripken authored Jan 10, 2024
    Configuration menu
    Copy the full SHA
    141f7ca View commit details
    Browse the repository at this point in the history

Commits on Jan 11, 2024

  1. wasm-merge: Sort globals to ensure proper validation (WebAssembly#6221)

    If the first module has a global that reads from a global that appears in a later
    module, then we need to reorder the globals, because if we just append the
    globals from the later module we'd end up with a global reading from another
    that is not before it.
    
    Changes to the existing renamings test are just due to the global sorting
    pass that now runs (it not only fixes up validation errors but also tries to sort
    in a more optimal order for size).
    
    Fixes WebAssembly#6220
    kripken authored Jan 11, 2024
    Configuration menu
    Copy the full SHA
    e5948a9 View commit details
    Browse the repository at this point in the history
  2. Typed continuations: resume instructions (WebAssembly#6083)

    This PR is part of a series that adds basic support for the [typed continuations proposal](https://github.com/wasmfx/specfx).
    
    This particular PR adds support for the `resume` instruction. The most notable missing feature is validation, which is not implemented, yet.
    frank-emrich authored Jan 11, 2024
    Configuration menu
    Copy the full SHA
    b4dee3d View commit details
    Browse the repository at this point in the history

Commits on Jan 12, 2024

  1. Configuration menu
    Copy the full SHA
    1db044e View commit details
    Browse the repository at this point in the history

Commits on Jan 16, 2024

  1. Make blockifyWithName correctly use name and type (WebAssembly#6223)

    - This passes `name` to `makeBlock` call, because `makeBlock` uses
      `BranchSeeker` when finalizing only when the block has a `name`.
    - This also refinalizes the block when an optional `type` is given.
    
    This was spun off from WebAssembly#6210, but I'm not sure how to add a standalone
    test for this.
    aheejin authored Jan 16, 2024
    Configuration menu
    Copy the full SHA
    2dfa01f View commit details
    Browse the repository at this point in the history

Commits on Jan 17, 2024

  1. Configuration menu
    Copy the full SHA
    823bf60 View commit details
    Browse the repository at this point in the history

Commits on Jan 18, 2024

  1. SimplifyGlobals: Apply constant globals to segment offsets (WebAssemb…

    …ly#6226)
    
    We already applied such globals to other globals, but can do the same to offsets
    of data and element segments.
    
    Suggested in WebAssembly#6220
    kripken authored Jan 18, 2024
    Configuration menu
    Copy the full SHA
    3049fb8 View commit details
    Browse the repository at this point in the history

Commits on Jan 22, 2024

  1. Remove incorrect validation of segment sizes (WebAssembly#6228)

    This should be a runtime error, not a validator error. It caused a fuzzer failure on
    wasm-ctor-eval.
    kripken authored Jan 22, 2024
    Configuration menu
    Copy the full SHA
    459e0d2 View commit details
    Browse the repository at this point in the history
  2. [EH] Rename -eh lit test names to -eh-old (WebAssembly#6227)

    This renames all existing EH lit tests with filenames `*eh*` to
    `*eh-old*`. This is a prep work so that we can add tests for the new EH
    spec using `*eh*`. The reason I'm trying to split old and new EH test
    files is we don't support fuzzing for the new EH yet and I wouldn't want
    to exclude old EH tests from fuzzing too because of that.
    aheejin authored Jan 22, 2024
    Configuration menu
    Copy the full SHA
    e06e17e View commit details
    Browse the repository at this point in the history

Commits on Jan 23, 2024

  1. Configuration menu
    Copy the full SHA
    c23253f View commit details
    Browse the repository at this point in the history
  2. Rename stack variables in CFGWalker (NFC) (WebAssembly#6232)

    This renames `***Stack` variables in `CFGWalker` to be consistent, as a
    preparation for adding another stack for the new EH. Currently `ifStack`
    and `loopStack` contains `BasicBlock*`s but `tryStack` contains
    `Expression*`, and `Try` expressions are rather contained in
    `unwindExprStack`, which to me is confusing.
    aheejin authored Jan 23, 2024
    Configuration menu
    Copy the full SHA
    de223c5 View commit details
    Browse the repository at this point in the history

Commits on Jan 24, 2024

  1. Stop propagating/inlining string constants (WebAssembly#6234)

    This causes overhead atm since in VMs executing a string.const will actually allocate a
    string, and more copies means more allocations. For now, just do not add more. This
    required changes to two passes: SimplifyGlobals and Precompute.
    kripken authored Jan 24, 2024
    Configuration menu
    Copy the full SHA
    9090ce5 View commit details
    Browse the repository at this point in the history
  2. [EH] Add translator from old to new EH instructions (WebAssembly#6210)

    This translates the old Phase 3 EH instructions, which include `try`,
    `catch`, `catch_all`, `delegate`, and `rethrow`, into the new EH
    instructions, which include `try_table` (with `catch` / `catch_ref` /
    `catch_all` / `catch_all_ref`) and `throw_ref`, passed at the Oct 2023
    CG meeting.
    
    This translator can be used as a standalone tool by users of the
    previous EH toolchain to generate binaries for the new spec without
    recompiling, and also can be used at the end of the Binaryen pipeline to
    produce binaries for the new spec while the end-to-end toolchain
    implementation for the new spec is in progress.
    
    While the goal of this pass is not optimization, this tries to a little
    better than the most naive implementation, namely by omitting a few
    instructions where possible and trying to minimize the number of
    additional locals, because this can be used as a standalone translator
    or the last stage of the pipeline while we can't post-optimize the
    results because the whole pipeline (-On) is not ready for the new EH.
    aheejin authored Jan 24, 2024
    Configuration menu
    Copy the full SHA
    1ce851d View commit details
    Browse the repository at this point in the history
  3. Memory flattening: Check for overflow (WebAssembly#6233)

    Fixes a fuzz testcase for wasm-ctor-eval.
    
    Add the beginnings of a polyfill for stdckdint.h to help that.
    kripken authored Jan 24, 2024
    Configuration menu
    Copy the full SHA
    6453fd5 View commit details
    Browse the repository at this point in the history

Commits on Jan 25, 2024

  1. Configuration menu
    Copy the full SHA
    c0e688e View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    482f3aa View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    976bd6d View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    0375d95 View commit details
    Browse the repository at this point in the history
  5. RemoveUnusedModuleElements: Do not remove unused-but-trapping segments (

    WebAssembly#6242)
    
    An out of bounds active segment traps during startup, which is an effect we must
    preserve.
    
    To avoid a regression here, ignore this in TNH mode (where the user assures us
    nothing will trap), and also check if a segment will trivially be in bounds and not
    trap (if so, it can be removed).
    
    Fixes the remove-unused-module-elements part of WebAssembly#6230
    
    The small change to an existing testcase made a segment there be in bounds,
    to avoid this affecting it. Tests for this are in a new file.
    kripken authored Jan 25, 2024
    Configuration menu
    Copy the full SHA
    662835a View commit details
    Browse the repository at this point in the history
  6. MemoryPacking: Ignore empty segments (WebAssembly#6243)

    They might trap. Leave that for RemoveUnusedModuleElements.
    
    Fixes WebAssembly#6230
    kripken authored Jan 25, 2024
    Configuration menu
    Copy the full SHA
    5fb2137 View commit details
    Browse the repository at this point in the history

Commits on Jan 26, 2024

  1. [EH] Support CFGWalker for new EH spec (WebAssembly#6235)

    This adds support `CFGWalker` for the new EH instructions (`try_table`
    and `throw_ref`). `CFGWalker` is used by many different passes, but in
    the same vein as WebAssembly#3494, this adds tests for `RedundantSetElimination`
    pass. `rse-eh.wast` file is created from translated and simplified
    version of `rse-eh-old.wast`, but many tests were removed because we
    don't have special `catch` block or `delegate` anymore.
    aheejin authored Jan 26, 2024
    Configuration menu
    Copy the full SHA
    d23a63f View commit details
    Browse the repository at this point in the history
  2. Update the text syntax for tuple types (WebAssembly#6246)

    Instead of e.g. `(i32 i32)`, use `(tuple i32 i32)`. Having a keyword to
    introduce the s-expression is more consistent with the rest of the language.
    tlively authored Jan 26, 2024
    Configuration menu
    Copy the full SHA
    5d297dc View commit details
    Browse the repository at this point in the history

Commits on Jan 29, 2024

  1. Configuration menu
    Copy the full SHA
    6454f5b View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    053b591 View commit details
    Browse the repository at this point in the history
  3. [Parser] Parse tuple types (WebAssembly#6249)

    Use the new `(tuple ...)` syntax. Enforce that tuples have a valid number of
    elements and are not nested to avoid assertion failures when parsing invalid
    input.
    tlively authored Jan 29, 2024
    Configuration menu
    Copy the full SHA
    9a31d7e View commit details
    Browse the repository at this point in the history

Commits on Jan 30, 2024

  1. [Parser] Parse local.set and global.set of tuple values correctly (We…

    …bAssembly#6250)
    
    These instructions always pop a single value, except when tuples are involved,
    in which case they need special handling to know how many values to pop.
    tlively authored Jan 30, 2024
    Configuration menu
    Copy the full SHA
    c0046ad View commit details
    Browse the repository at this point in the history
  2. Update pop text syntax (WebAssembly#6251)

    Rather than `(pop valtype*)`, use `(pop valtype)`, where `valtype` is now
    allowed to be a tuple. This will make it possible to parse un-folded multivalue
    pops in the new text parser. The alternative would have been to put an arity in
    the syntax like we have for other tuple instructions, but that's much uglier.
    tlively authored Jan 30, 2024
    Configuration menu
    Copy the full SHA
    88d6b7c View commit details
    Browse the repository at this point in the history
  3. [Parser] Parse pops (by doing nothing) (WebAssembly#6252)

    Parse pop expressions and check that they have the expected types, but do not
    actually create new Pop expressions or push anything onto the stack because we
    already create Pop expressions as necessary when visiting the beginning of catch
    blocks.
    
    Unlike the legacy text parser, the new text parser is not capable of parsing
    pops in invalid locations in the IR. This means that the new text parser will
    never be able to parse test/lit/catch-pop-fixup-eh-old.wast, which deliberately
    parses invalid IR to check that the pops can be fixed up and moved to the
    correct locations. It should be acceptable to delete that test when we turn on
    the new parser by default, though, so that won't be a problem.
    tlively authored Jan 30, 2024
    Configuration menu
    Copy the full SHA
    9361edf View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    8b85d5d View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    8504571 View commit details
    Browse the repository at this point in the history

Commits on Jan 31, 2024

  1. [EH] Change translator option name (WebAssembly#6259)

    The previous name feels too verbose and unwieldy.
    
    This also removes the "new-to-old EH" placeholder. I think it'd be
    better to add it back when it is actually added.
    aheejin authored Jan 31, 2024
    Configuration menu
    Copy the full SHA
    cf14a9f View commit details
    Browse the repository at this point in the history
  2. [PostEmscripten] Fix calcSegmentOffsets for large offsets (WebAssembl…

    …y#6260)
    
    Specifically offsets larger than 2^32 which were being interpreted
    misinterpreted here as very large int64_t values.
    sbc100 authored Jan 31, 2024
    Configuration menu
    Copy the full SHA
    396a826 View commit details
    Browse the repository at this point in the history
  3. StringGathering pass (WebAssembly#6257)

    This pass finds all string.const and creates globals for them. After this transform, no
    string.const appears anywhere but in a global, and each string appears in one global
    which is then global.get-ed everywhere.
    
    This avoids overhead in VMs where executing a string.const is an allocation, and is
    also a good step towards imported strings. For that, this pass will be extended from
    gathering to a full lowering pass, which will first gather into globals as this pass does,
    and then turn each of those globals with a string.const into an imported externref.
    (For that reason this pass is in a file called StringLowering, as the two passes will
    share much of their code, and the larger pass should decide the name I think.)
    
    This pass runs in -O2 and above. Repeated executions have no downside (see
    details in code).
    kripken authored Jan 31, 2024
    Configuration menu
    Copy the full SHA
    dfcae55 View commit details
    Browse the repository at this point in the history
  4. Revert "Stop propagating/inlining string constants (WebAssembly#6234)" (

    WebAssembly#6258)
    
    This reverts commit 9090ce5.
    
    This has the effect of once more propagating string constants from
    globals to other places (and from non-globals too), which is useful
    for various optimizations even if it isn't useful in the final output.
    To fix the final output problem, WebAssembly#6257 added a pass that is run at the
    end to collect string.const to globals, which allows us to once more
    propagate strings in the optimizer, now without a downside.
    kripken authored Jan 31, 2024
    Configuration menu
    Copy the full SHA
    b593849 View commit details
    Browse the repository at this point in the history

Commits on Feb 1, 2024

  1. [EH] Test StackIR's local2stack on translator output (WebAssembly#6264)

    This adds `STACKIR-OPT` filecheck lines to `translate-to-new-eh.wast`
    to see if StackIR's `local2stack` optimization successfully removes some
    of unnecessary `local.set`/`local.get`s.
    
    While supporting the whole Binayren optimization pipeline for the new EH
    instructions is not the goal for the very near-term future, StackIR's
    `local2stack` optimization can help with a very common pattern generated
    by this translator, which is:
    ```wast
    (try $l
      (do ... )
      (catch_all
        (call $destructor)
        (rethrow $l)
      )
    )
    ```
    is translated to
    ```wast
    (block $outer
      (local.set $exn     ;; can be optimized away
        (block $catch_all (result exnref)
          (try_table (catch_all_ref $catch_all)
            ...
          )
          (br $outer)
        )
      )
      (call $destructor)
      (throw_ref
        (local.get $exn)  ;; can be optimized away
      )
    )
    ```
    
    Here we don't really need `local.set $exn` and `local.get $exn`, and
    these can be optimized away using StackIR's local2stack. After
    optimizing them away in Stack IR, the code can be like
    ```wast
    block $outer
      block $catch_all (result exnref)
        try_table (catch_all_ref $catch_all)
          ...
        end
        br $outer
      end
      call $destructor
      throw_ref
    end
    ```
    
    This optimization alone reduces the code size increased caused by
    translating significantly. For Adobe Photoshop, the code size increase
    goes down from 4.2% to 2.8%, and for Binaryen, it goes down from 3.8% to
    2.0%.
    aheejin authored Feb 1, 2024
    Configuration menu
    Copy the full SHA
    19fb1f4 View commit details
    Browse the repository at this point in the history
  2. GUFA: Propagate string literals (WebAssembly#6262)

    We only noted the type but not the literal value.
    kripken authored Feb 1, 2024
    Configuration menu
    Copy the full SHA
    76a422b View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    6c70fcd View commit details
    Browse the repository at this point in the history
  4. C API: Use segment names (WebAssembly#6254)

    Move from segment indexes to names. This is a breaking change to make the API more
    capable and consistent. An effort has been made to reduce the burden on C API users
    where possible (specifically, you can avoid providing names and let Binaryen make them
    for you, which will basically be numbers that match the indexes from before).
    
    Fixes WebAssembly#6247
    ericvergnaud authored Feb 1, 2024
    Configuration menu
    Copy the full SHA
    2b3a2e8 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    5526027 View commit details
    Browse the repository at this point in the history
  6. MemoryPacking: Handle non-empty trapping segments (WebAssembly#6261)

    Followup to WebAssembly#6243 which handled empty ones.
    kripken authored Feb 1, 2024
    Configuration menu
    Copy the full SHA
    845e070 View commit details
    Browse the repository at this point in the history

Commits on Feb 5, 2024

  1. [Parser] Templatize lexing of integers (WebAssembly#6272)

    Have a single implementation for lexing each of unsigned, signed, and
    uninterpreted integers, each generic over the bit width of the integer. This
    reduces duplication in the existing code and it will make it much easier to
    support lexing more 8- and 16-bit integers.
    tlively authored Feb 5, 2024
    Configuration menu
    Copy the full SHA
    ed15efe View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    be13e0f View commit details
    Browse the repository at this point in the history
  3. wasm-ctor-eval: Properly eval strings (WebAssembly#6276)

    WebAssembly#6244 tried to do this but was not quite right. It treated a string like an array
    or a struct, which means create a global for it. But just creating a global isn't
    enough, as it needs to also be sorted in the right place etc. which requires
    changes in other places. But there is a much simpler solution here: string
    constants are just constants, which we can emit in-line, so do that.
    kripken authored Feb 5, 2024
    Configuration menu
    Copy the full SHA
    a549c59 View commit details
    Browse the repository at this point in the history
  4. StringLowering pass (WebAssembly#6271)

    This extends StringGathering by replacing the gathered string globals to imported
    globals. It adds a custom section with the strings that the imports are expected to
    provide. It also replaces the string type with extern.
    
    This is a complete lowering of strings, except for string operations that are a TODO.
    
    After running this, no strings remain in the wasm, and the outside JS is expected
    to provide the proper imports, which it can do by processing the JSON of the
    strings in the custom section "string.consts", which looks like
    
    ["foo", "bar", ..]
    
    That is, an array of strings, which are imported as
    
    (import "string.const" "0" (global $string.const_foo (ref extern))) ;; foo
    (import "string.const" "1" (global $string.const_bar (ref extern))) ;; bar
    kripken authored Feb 5, 2024
    Configuration menu
    Copy the full SHA
    d490318 View commit details
    Browse the repository at this point in the history

Commits on Feb 6, 2024

  1. [EH] Add --experimental-new-eh option to wasm-opt (WebAssembly#6270)

    This adds `--experimental-new-eh` option to `wasm-opt`. The difference
    between this and `--translate-to-new-eh` is, `--translate-to-new-eh`
    just runs `TranslateToNewEH` pass, while `--experimental-new-eh`
    attaches `TranslateToNewEH` pass at the end of the whole optimization
    pipeline. So if no other passes or optimization options (`-On`) are
    specified, it is equivalent to `--translate-to-new-eh`. If other
    optimization passes are specified, it runs them and at the end run the
    translator to ensure the new EH instructions are emitted. The reason we
    are doing this this way is that the optimization pipeline as a whole
    does not support the new EH instruction yet, but we would like to
    provide an option to emit a reasonably OK code with the new EH
    instructions.
    
    This also means when the optimization level > 3, it will also run
    the StackIR + local2stack optimization after the translation.
    
    Not sure how to test the output of this option, given that there is not
    much point in testing the default optimization passes, and it is also
    not clear how to print the stack IR if the stack ir generation and
    optimization runs as a part of the pipeline and not the explicit command
    line options.
    
    This is created in favor of WebAssembly#6267, which added the option to
    `optimization-options.h`. It had a problem of running the translator
    multiple times when `-On` was given multiple times in the command line,
    which I learned was rather a common usage. This adds the option directly
    to `wasm-opt.cpp`, which avoids the problem. With this, it is still
    possible to create and optimize Stack IR unnecessarily, but that feels a
    better alternative.
    aheejin authored Feb 6, 2024
    Configuration menu
    Copy the full SHA
    3db60df View commit details
    Browse the repository at this point in the history
  2. Make array.new_fixed length annotations mandatory (WebAssembly#6277)

    They were previously optional to ease the transition to the standard text
    format, but now we can make them mandatory to match the spec. This will simplify
    the new text parser as well.
    tlively authored Feb 6, 2024
    Configuration menu
    Copy the full SHA
    41b365e View commit details
    Browse the repository at this point in the history
  3. [Parser] Support string-style identifiers (WebAssembly#6278)

    In addition to normal identifiers, support parsing identifiers of the format
    `$"..."`. This format is not yet allowed by the standard, but it is a popular
    proposed extension (see WebAssembly/spec#617 and
    WebAssembly/annotations#21).
    
    Binaryen has historically allowed a similar format and has supported arbitrary
    non-standard identifier characters, so it's much easier to support this extended
    syntax than to fix everything to use the restricted standard syntax.
    tlively authored Feb 6, 2024
    Configuration menu
    Copy the full SHA
    8cce4d1 View commit details
    Browse the repository at this point in the history
  4. Properly stringify names in tests (WebAssembly#6279)

    Update identifiers used in tests to use a format supported by the new text
    parser, i.e. either the standard format with its limited set of allowed
    characters or the non-standard `$"..."` format. Notably, any name containing
    square or curly braces now uses the string format.
    
    Input automatically updated with this script:
    https://gist.github.com/tlively/4e22311736661849e641d02e521a0748
    
    The printer is updated to properly escape names in more places as well. The
    logic for escaping names is moved to a common location so that the type
    printing logic in wasm-type.cpp can use it as well.
    tlively authored Feb 6, 2024
    Configuration menu
    Copy the full SHA
    3a41065 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    a238cf9 View commit details
    Browse the repository at this point in the history
  6. [NFC] Move code to string.cpp (WebAssembly#6282)

    Now that we have a .cpp file, none of the code that was in string.h needs to be
    in a header any more.
    tlively authored Feb 6, 2024
    Configuration menu
    Copy the full SHA
    f12977d View commit details
    Browse the repository at this point in the history

Commits on Feb 7, 2024

  1. Get more tests working with the new text parser (WebAssembly#6284)

    The new parser enforces the rule that imports must come before declarations
    (except for type declarations). The old parser does not enforce this rule, so
    many of our tests did not follow it. Fix them to follow that rule and fix other
    invalid syntax. Also add missing finalization of Load expressions in
    wasm-builder.h that was causing a test to fail under the new parser and guard
    against an error case in wasm-ir-builder.cpp that used to cause a segfault.
    tlively authored Feb 7, 2024
    Configuration menu
    Copy the full SHA
    d4c3fdd View commit details
    Browse the repository at this point in the history

Commits on Feb 8, 2024

  1. SimplifyGlobals: Propagate constant globals into nested gets in other…

    … globals (WebAssembly#6285)
    
    Before we propagated to the top level, but not to anything interior.
    kripken authored Feb 8, 2024
    Configuration menu
    Copy the full SHA
    4e0796d View commit details
    Browse the repository at this point in the history
  2. [Parser] Do not involve IRBuilder for imported functions (WebAssembly…

    …#6286)
    
    We previously had a bug where we would begin and end an IRBuilder context for
    imported functions even though they don't have bodies. For functions that return
    results, ending this empty scope should have produced an error except that we
    had another bug where we only produced that error for multivalue functions. We
    did not previously have imported multivalue functions in wat-kitchen-sink.wast,
    so both of these bugs went undetected. Fix both bugs and update the test to
    include an imported multivalue function so that it would have failed without
    this fix.
    tlively authored Feb 8, 2024
    Configuration menu
    Copy the full SHA
    0724bab View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    f172920 View commit details
    Browse the repository at this point in the history
  4. Add a pass to propagate global constants to other globals (WebAssembl…

    …y#6287)
    
    SimplifyGlobals already does this, so this is a subset of that pass, and does not
    add anything new. It is useful for testing, however.
    
    In particular it allows testing that we propagate subsequent globals in a single
    pass, that is if one global reads from another and becomes constant, then it
    can be propagated as well. SimplifyGlobals runs multiple passes so this always
    worked, but with this pass we can test that we do it efficiently in one pass.
    
    This will also be useful for comparing stringref to imported strings, as it
    allows gathered strings to be propagated to other globals (possible with
    stringref, but not imported strings) but not anywhere else (which might have
    downsides as it could lead to more allocations).
    
    Also add an additional test for simplify-globals that we do not get confused by
    an unoptimizable global.get in the middle (see last part).
    kripken authored Feb 8, 2024
    Configuration menu
    Copy the full SHA
    6e1e53f View commit details
    Browse the repository at this point in the history
  5. Add package.json for unit tests (WebAssembly#6245)

    The JS there is not an ES6 module, so declare it so (otherwise a package.json in a
    parent, perhaps in folders outside of our own project that we are pasted in, can
    cause an error, as require does not work in ES6 modules and we might be forced
    to be seen as one).
    
    Fixes WebAssembly#6240
    kripken authored Feb 8, 2024
    Configuration menu
    Copy the full SHA
    f09af77 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    0f58ef5 View commit details
    Browse the repository at this point in the history
  7. Remove support for legacy stringref text syntax (WebAssembly#6289)

    Removing support for the legacy syntax will allow us to avoid implementing
    support for it in the new text parser.
    tlively authored Feb 8, 2024
    Configuration menu
    Copy the full SHA
    e7b3470 View commit details
    Browse the repository at this point in the history
  8. Update lit tests to parse with the new parser (WebAssembly#6290)

    Get as many of the lit tests as possible to parse with the new parser, mostly by
    moving declared module items to be after imports. Also fix a bug in the new
    parser's pop validation to allow supertypes of the expected type.
    
    The two big issues that still prevent some lit tests from working correctly
    under the new parser are missing support for symbolic field names and missing
    support for source map annotations.
    tlively authored Feb 8, 2024
    Configuration menu
    Copy the full SHA
    f5d8d30 View commit details
    Browse the repository at this point in the history

Commits on Feb 9, 2024

  1. [Parser] Support references to struct fields by name (WebAssembly#6293)

    Construct a mapping from heap type and field name to field index, then use it
    while parsing instructions.
    tlively authored Feb 9, 2024
    Configuration menu
    Copy the full SHA
    90087f0 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    7e20a3b View commit details
    Browse the repository at this point in the history

Commits on Feb 12, 2024

  1. Fuzz shell: Add a j2wasm import (WebAssembly#6296)

    With this, the fuzz shell can run a hello world Java file compiled by j2wasm.
    kripken authored Feb 12, 2024
    Configuration menu
    Copy the full SHA
    1e9838e View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    34d35ae View commit details
    Browse the repository at this point in the history
  3. Precompute: Optimize array.len (WebAssembly#6299)

    Arrays have immutable length, so we can optimize them like immutable fields.
    kripken authored Feb 12, 2024
    Configuration menu
    Copy the full SHA
    1948008 View commit details
    Browse the repository at this point in the history
  4. Fuzzer: Use a directory for important fuzz testcases (WebAssembly#6297)

    Users can put files in ./fuzz and they will be fuzzed with high priority.
    
    Docs in source and https://github.com/WebAssembly/binaryen/wiki/Fuzzing#helper-scripts
    kripken authored Feb 12, 2024
    Configuration menu
    Copy the full SHA
    88fe1b6 View commit details
    Browse the repository at this point in the history

Commits on Feb 13, 2024

  1. StringLowering: Modify string=>extern also in public types (WebAssemb…

    …ly#6301)
    
    We want to actually remove all stringref appearances, in both public and
    private types.
    kripken authored Feb 13, 2024
    Configuration menu
    Copy the full SHA
    cdc9ad9 View commit details
    Browse the repository at this point in the history
  2. StringLowering: Hack around if issue with bottom types (WebAssembly#6303

    )
    
    Replacing the string heap type with extern is dangerous as they do not share top/bottom
    types. In practice this works out almost everywhere except for a few ifs, which we can fix
    up as a hack for now.
    kripken authored Feb 13, 2024
    Configuration menu
    Copy the full SHA
    32a2782 View commit details
    Browse the repository at this point in the history
  3. Fix --spill-pointers for the stack growing down (WebAssembly#6294)

    The LLVM wasm backend grows the stack downwards, and this pass did not
    fully account for that before.
    yamt authored Feb 13, 2024
    Configuration menu
    Copy the full SHA
    78516ae View commit details
    Browse the repository at this point in the history

Commits on Feb 14, 2024

  1. StringLowering: Use an array16 type in its own rec group (WebAssembly…

    …#6302)
    
    The input module might use an array of 16-bit elements type that is somewhere in a
    giant rec group, but that is not valid for imported strings: that array type is now on an
    import and must match the expected ABI, which is to be in its own personal rec group.
    
    The old array16 type remains in the module after this transformation, but all uses of it
    are replaced with uses of the new array16 type.
    
    Also move makeImports to after updateTypes: there are no types to update in the new
    imports. That does not matter but it can make debugging less pleasant, so improve it.
    kripken authored Feb 14, 2024
    Configuration menu
    Copy the full SHA
    9784f01 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    df3784e View commit details
    Browse the repository at this point in the history
  3. Strings: Add some interpreter support (WebAssembly#6304)

    This adds just enough support to be able to --fuzz-exec a small but realistic fuzz
    testcase from Java.
    
    To that end, just implement the minimal ops we need, which are all related to
    JS-style strings.
    kripken authored Feb 14, 2024
    Configuration menu
    Copy the full SHA
    5ef1aba View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    99e54a0 View commit details
    Browse the repository at this point in the history
  5. StringLowering: Properly handle nullable inputs to StringAs (WebAssem…

    …bly#6307)
    
    StringAs's output must be non-nullable, so add a cast.
    kripken authored Feb 14, 2024
    Configuration menu
    Copy the full SHA
    36d2093 View commit details
    Browse the repository at this point in the history
  6. Fuzzer: Remove Asyncify integration (WebAssembly#6309)

    Fuzzing Asyncify has a significant cost both in terms of the complexity in
    the fuzzer and the slowness of the fuzzing. In practice it was useful years ago
    when Asyncify was written but hasn't found anything for a while, and Asyncify
    is really deprecated given JSPI. For all those reasons, remove it from the fuzzer.
    
    We do still have lots of normal coverage of asyncify in lit tests, unit tests, and
    the Emscripten test suite.
    
    Removing this will also make future improvements to the fuzzer simpler.
    kripken authored Feb 14, 2024
    Configuration menu
    Copy the full SHA
    feb8f24 View commit details
    Browse the repository at this point in the history

Commits on Feb 20, 2024

  1. Configuration menu
    Copy the full SHA
    2b512ce View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    a9f01c0 View commit details
    Browse the repository at this point in the history
  3. [Parser] Simplify the lexer interface (WebAssembly#6319)

    The lexer was previously an iterator over tokens, but that expressivity is not
    actually used in the parser. Instead, we have `input.h` that adapts the token
    iterator interface into an iterface that is actually useful.
    
    As a first step toward simplifying the lexer implementation to no longer be an
    iterator over tokens, update its interface by moving the adaptation from input.h
    to the lexer itself. This requires extensive changes to the lexer unit tests,
    which will not have to change further when we actually simplify the lexer
    implementation.
    tlively authored Feb 20, 2024
    Configuration menu
    Copy the full SHA
    c0cdd26 View commit details
    Browse the repository at this point in the history
  4. JS Bindings: Use stringToUTF8OnStack instead of deprecated allocateUT…

    …F8OnStack (WebAssembly#6324)
    
    This avoids a warning on recent Emscripten.
    kripken authored Feb 20, 2024
    Configuration menu
    Copy the full SHA
    d0fa710 View commit details
    Browse the repository at this point in the history
  5. StringLowering: Escape the JSON in the custom section (WebAssembly#6316)

    Also add an end-to-end test using node to verify we can parse the escaped
    content properly using TextDecoder+JSON.parse.
    kripken authored Feb 20, 2024
    Configuration menu
    Copy the full SHA
    07b91a8 View commit details
    Browse the repository at this point in the history
  6. subtype-exprs.h additions [NFC] (WebAssembly#6323)

    This pulls out the subtype-exprs.h parts of WebAssembly#6108
    
    These are NFC in the current codebase, but are fixes for that unlanded PR, and
    another unrelated PR that will be opened shortly.
    kripken authored Feb 20, 2024
    Configuration menu
    Copy the full SHA
    40a4bd0 View commit details
    Browse the repository at this point in the history
  7. Validate function imports (WebAssembly#6315)

    We validate functions in parallel, but function-parallel passes do not run on imports,
    so we did not issue a validation error on an import using a disallowed type, for example.
    
    All the changes in visitFunction are just to group all the parts using body to the
    end, and putting them behind a check for body.
    kripken authored Feb 20, 2024
    Configuration menu
    Copy the full SHA
    4031538 View commit details
    Browse the repository at this point in the history
  8. Fuzzer: Remove --emit-js-shell logic and reuse fuzz_shell.js instead (W…

    …ebAssembly#6310)
    
    We had two JS files that could run a wasm file for fuzzing purposes:
    
    * --emit-js-shell, which emitted a custom JS file that runs the wasm.
    * scripts/fuzz_shell.js, which was a generic file that did the same.
    
    Both of those load the wasm and then call the exports in order and print out
    logging as it goes of their return values (if any), exceptions, etc. Then the
    fuzzer compares that output to running the same wasm in another VM, etc. The
    difference is that one was custom for the wasm file, and one was generic. Aside
    from that they are similar and duplicated a bunch of code.
    
    This PR improves things by removing 1 and using 2 in all places, that is, we
    now use the generic file everywhere.
    
    I believe we added 1 because we thought a generic file can't do all the
    things we need, like know the order of exports and the types of return values,
    but in practice there are ways to do those things: The exports are in fact
    in the proper order (JS order of iteration is deterministic, thankfully), and
    for the type we don't want to print type internals anyhow since that would
    limit fuzzing --closed-world. We do need to be careful with types in JS (see
    notes in the PR about the type of null) but it's not too bad. As for the types
    of params, it's fine to pass in null for them all anyhow (null converts to a
    number or a reference without error).
    kripken authored Feb 20, 2024
    Configuration menu
    Copy the full SHA
    60b2dae View commit details
    Browse the repository at this point in the history

Commits on Feb 21, 2024

  1. [NFC] Use SubtypingDiscoverer in StringLowering (WebAssembly#6325)

    This replaces horrible hacks to find which nulls need to switch (from none to
    noext) with general code using SubtypingDiscoverer. That helper is aware of
    where each expression is written, so we can find those nulls trivially.
    
    This is NFC on existing usage but should fix any remaining bugs with null
    constants.
    kripken authored Feb 21, 2024
    Configuration menu
    Copy the full SHA
    1c30853 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    0ecea77 View commit details
    Browse the repository at this point in the history
  3. Fuzzer: Add a pass to prune illegal imports and exports for JS (WebAs…

    …sembly#6312)
    
    We already have passes to legalize i64 imports and exports, which the fuzzer will
    run so that we can run wasm files in JS VMs. SIMD and multivalue also pose a
    problem as they trap on the boundary. In principle we could legalize them as well,
    but that is substantial effort, so instead just prune them: given a wasm module,
    remove any imports or exports that use SIMD or multivalue (or anything else that
    is not legal for JS).
    
    Running this in the fuzzer will allow us to not skip running v8 on any testcase we
    enable SIMD and multivalue for.
    
    (Multivalue is allowed in newer VMs, so that part of this PR could be removed
    eventually.)
    
    Also remove the limitation on running v8 with multimemory (v8 now supports
    that).
    kripken authored Feb 21, 2024
    Configuration menu
    Copy the full SHA
    1441bcb View commit details
    Browse the repository at this point in the history
  4. [NFC] DeNaN: Avoid calls on constants (WebAssembly#6326)

    A constant is either fixed up immediately, or does not need a call. This makes us
    slightly faster in the fuzzer, but does not change behavior as before those calls all
    ended up doing nothing (as the numbers were not nans).
    kripken authored Feb 21, 2024
    Configuration menu
    Copy the full SHA
    30828d4 View commit details
    Browse the repository at this point in the history
  5. [EH] Add noexn's opcode (WebAssembly#6329)

    We had a temporary value 0xff there, but now it is added:
    WebAssembly/exception-handling#298
    aheejin authored Feb 21, 2024
    Configuration menu
    Copy the full SHA
    a2fa559 View commit details
    Browse the repository at this point in the history
  6. Improve JSON string encoding (WebAssembly#6328)

    Catch and report all kinds of WTF-8 encoding errors in the source strings,
    including invalid leading bytes, invalid trailing bytes, unexpected ends of
    strings, and invalid surrogate sequences. Insert replacement characters into the
    output as necessary. Add a TODO about minimizing size by escaping only those
    code points mandated to be escaped by the JSON spec. Generally improve
    readability of the code.
    tlively authored Feb 21, 2024
    Configuration menu
    Copy the full SHA
    39ae6cf View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    93b4970 View commit details
    Browse the repository at this point in the history
  8. Validator: ArrayNew|InitData require Bulk Memory (WebAssembly#6331)

    Those instructions refer to a data segment, which mean the DataCount section
    must be emitted before them (so that, per the spec, they can be validated by
    looking only at previous sections), which implies bulk-memory is needed.
    kripken authored Feb 21, 2024
    Configuration menu
    Copy the full SHA
    e4d2e7c View commit details
    Browse the repository at this point in the history

Commits on Feb 22, 2024

  1. [Parser][NFC] Remove parser/input.h (WebAssembly#6332)

    Remove the layer of abstraction sitting between the parser and the lexer now
    that the lexer has an interface the parser can use directly.
    tlively authored Feb 22, 2024
    Configuration menu
    Copy the full SHA
    f9a49fa View commit details
    Browse the repository at this point in the history
  2. [Parser][NFC] Remove Token from lexer interface (WebAssembly#6333)

    Replace the general `peek` method that returned a `Token` with specific peek
    methods that look for (but do not consume) specific kinds of tokens. This change
    is a prerequisite for simplifying the lexer implementation by removing `Token`
    entirely.
    tlively authored Feb 22, 2024
    Configuration menu
    Copy the full SHA
    f6bb943 View commit details
    Browse the repository at this point in the history
  3. Fuzzer: Match the logging of i31ref between JS and C++ (WebAssembly#6335

    )
    
    JS engines print i31ref as just a number, so we need a small regex to
    standardize the representation (similar to what we do for funcrefs on
    the code above).
    
    On the C++ side, make it actually print the i31ref rather than treat it
    like a generic reference (for whom we only print "object"). To do that
    we must unwrap an externalized i31 as necessary, and add a case for
    i31 in the printing logic.
    
    Also move that printing logic to its own function, as it was starting to
    get quite long.
    kripken authored Feb 22, 2024
    Configuration menu
    Copy the full SHA
    4969f93 View commit details
    Browse the repository at this point in the history
  4. Fuzzer: Allow using initial content with V8 (WebAssembly#6327)

    One problem was that spec testcases had exports with names that are not
    valid to write as JS exports.name. For example an export with a - in the
    name would end up as exports.foo-bar etc. Since WebAssembly#6310 that is fixed as
    we do not emit such JS (we use the generic fuzz_shell.js script which iterates
    over the keys in exports with exports[name]).
    
    Also fix a few trivial fuzzer issues that initial content uncovered:
    
    - Ignore a wat file with invalid utf-8.
    - Print string literals in the same way from JS as from C++.
    - Enable the stringref flag in V8.
    - Remove tag imports (the same as we do for global and function and other imports).
    kripken authored Feb 22, 2024
    Configuration menu
    Copy the full SHA
    212f7c3 View commit details
    Browse the repository at this point in the history
  5. Fuzzer: Adjust feature fuzzing frequency (WebAssembly#6305)

    We used to fuzz MVP 1/3, all 1/3, and a mixture 1/3, but that gives far too much
    priority to the MVP which is increasingly less important. It is also a good idea to
    give "all" more priority as that enables more initial content to run (the fuzzer will
    discard initial content if it doesn't validate with the features chosen in the current
    iteration).
    
    Also (NFC) rename POSSIBLE_FEATURE_OPTS to make the code easier to follow.
    kripken authored Feb 22, 2024
    Configuration menu
    Copy the full SHA
    2ceff4d View commit details
    Browse the repository at this point in the history
  6. Typed continuations: cont.new instructions (WebAssembly#6308)

    This PR is part of a series that adds basic support for the [typed
    continuations/wasmfx proposal](https://github.com/wasmfx/specfx).
    
    This particular PR adds support for the `cont.new` instruction for creating
    continuations, documented [here(https://github.com/wasmfx/specfx/blob/main/proposals/continuations/Overview.md#instructions).
    
    In short, these instructions are of the form `(cont.new $ct)` where `$ct` must
    be a continuation type. The instruction takes a single (nullable) function
    reference as its argument, which means that the folded representation of the
    instruction is of the form `(cont.new $ct (foo ...))`. 
    
    Support for the instruction is implemented in both the old and the new wat
    parser.
    
    Note that this PR does not implement validation of the new instruction.
    frank-emrich authored Feb 22, 2024
    Configuration menu
    Copy the full SHA
    e2420f0 View commit details
    Browse the repository at this point in the history
  7. Fuzzer: Ignore V8 errors on uninitialized non-defaultable locals (Web…

    …Assembly#6337)
    
    See WebAssembly#5665 WebAssembly#5599, this is an existing issue and we have a workaround for it
    using --dce, but it does not always work. I seem to be seeing this in higher
    frequency since landing recent fuzzer improvements, so ignore it.
    
    There is some risk of us missing real bugs here (that we validate and V8
    does not), but this is a validation error which is not as serious as a difference
    in behavior. And this is a long-standing issue that hasn't bitten us yet.
    kripken authored Feb 22, 2024
    Configuration menu
    Copy the full SHA
    dabfd5b View commit details
    Browse the repository at this point in the history

Commits on Feb 23, 2024

  1. [Parser] Condense redundant pop values (WebAssembly#6339)

    A bit of clean-up, changes getBranchValue to use pop().
    ashleynh authored Feb 23, 2024
    Configuration menu
    Copy the full SHA
    e3450ca View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    2fc33e6 View commit details
    Browse the repository at this point in the history
  3. Implement dropping of active Element Segments (WebAssembly#6343)

    Also rename the existing droppedSegments to droppedDataSegments for clarity.
    kripken authored Feb 23, 2024
    Configuration menu
    Copy the full SHA
    7cb213c View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    999781a View commit details
    Browse the repository at this point in the history

Commits on Feb 26, 2024

  1. [Emscripten port] Improve emcc flags (WebAssembly#6349)

    No changes here to binaryen.js/wasm builds.
    
    1. Add a flag to enable pthreads.
    
    2. Use SINGLE_FILE on binaryen.js/.wasm as before, which is nice for library users
    as they want just a single file to distribute for Binaryen support. For other builds
    like wasm-opt.js etc. no longer set SINGLE_FILE, as that type of build wants to be
    a replacement for a normal wasm-opt build as much as possible, so avoid the
    overhead of SINGLE_FILE.
    
    (Previously we disabled SINGLE_FILE also in the case of BUILD_FOR_BROWSER
    but I don't think we need to special-case that any more.)
    kripken authored Feb 26, 2024
    Configuration menu
    Copy the full SHA
    df0d283 View commit details
    Browse the repository at this point in the history

Commits on Feb 27, 2024

  1. Fuzzer: Fix BigInt printing (WebAssembly#6348)

    Before this we only printed the type of a BigInt and not the value.
    kripken authored Feb 27, 2024
    Configuration menu
    Copy the full SHA
    703ff00 View commit details
    Browse the repository at this point in the history
  2. [Emscripten port] Fix core count logic for Emscripten+pthreads (WebAs…

    …sembly#6350)
    
    Before this all Emscripten builds would use 1 core, but it is important to
    allow pthreads builds there to use more.
    kripken authored Feb 27, 2024
    Configuration menu
    Copy the full SHA
    55c2062 View commit details
    Browse the repository at this point in the history
  3. [Parser] Parse annotations, including source map comments (WebAssembl…

    …y#6345)
    
    Parse annotations using the standards-track `(@annotation ...)` format as well
    as the `;;@ source-map:0:1` format. Have the lexer implicitly collect
    annotations while it skips whitespace and add lexer APIs to access the
    annotations since the last token was parsed. Collect annotations before parsing
    each instruction and pass the annotations explicitly to the parser and parser
    context functions for instructions. Add an API to `IRBuilder` to set a debug
    location to be attached to the next visited or created instruction and use it
    from the parser.
    tlively authored Feb 27, 2024
    Configuration menu
    Copy the full SHA
    f8b07f7 View commit details
    Browse the repository at this point in the history
  4. [StringLowering] Lower stringview_wtf16.get_codeunit to charCodeAt (

    WebAssembly#6353)
    
    Previously we lowered this to `getCodePointAt`, which has different semantics
    around surrogate pairs.
    tlively authored Feb 27, 2024
    Configuration menu
    Copy the full SHA
    063e1a2 View commit details
    Browse the repository at this point in the history
  5. Add a WebAssembly build to release (WebAssembly#6351)

    Simply build wasm-opt with Emscripten and bundle that up.
    
    Example build:
    
    https://github.com/kripken/binaryen/releases/tag/wasm-build-1
    
    Specifically
    
    binaryen-wasm-build-1-wasm.tar.gz
    
    Only 1.72 MB, as it's just wasm-opt and not any other tool, so it is
    much smaller than our other targets. Perhaps we will add more of the
    tools later as needed (wasm-metadce, wasm-split, etc.).
    
    Also update the readme regarding which toolchains use us as a library, that I
    noticed while editing it to add the release platforms.
    kripken authored Feb 27, 2024
    Configuration menu
    Copy the full SHA
    6a42941 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    dbae094 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    f868137 View commit details
    Browse the repository at this point in the history
  8. SubtypingDiscoverer: Differentiate non-flow subtyping constraints (We…

    …bAssembly#6344)
    
    When we do a local.set of a value into a local then we have both a subtyping constraint - for
    the value to be valid to put in that local - and also a flow of a value, which can then reach
    more places. Such flow then interacts with casts in Unsubtyping, since it needs to know
    what can flow where in order to know how casts force us to keep subtyping relations.
    
    That regressed in the not-actually-NFC WebAssembly#6323 in which I added the innocuous lines
    to add subtyping constraints in ref.eq. It seems fine to require that the arms of a
    RefEq must be of type eqref, but Unsubtyping then assuming those arms flowed into
    a location of type eqref... which means casts might force us to not optimize some
    things.
    
    To fix this, differentiate the rare case of non-flowing subtyping constraints, which is
    basically only RefEq. There are perhaps a few more cases (like i31 operations) but they
    do not matter in practice for Unsubtyping anyhow; I suggest we land this first to undo
    the regression and then at our leisure investigate the other instructions.
    kripken authored Feb 27, 2024
    Configuration menu
    Copy the full SHA
    d5157e0 View commit details
    Browse the repository at this point in the history
  9. Fuzzer: Separate arguments used to make the fuzz wasm from the opts w…

    …e run on it (WebAssembly#6357)
    
    Before FUZZ_OPTS was used both when doing --translate-to-fuzz/-ttf to generate the
    wasm from the random bytes and also when later running optimizations to generate
    a second wasm file for comparison. That is, we ended up doing this, if the opts were -O3:
    
    wasm-opt random.input -ttf -o a.wasm -O3
    wasm-opt a.wasm -O3 -o b.wasm
    
    Now we have a pair a.wasm,b.wasm which we can test. However, we have run -O3
    on both which is a little silly - the second -O3 might not actually have anything left
    to do, which would mean we compare the same wasm to itself.
    
    Worse, this is incorrect, as there are things we need to do only during the
    generation phase, like --denan. We need that in order to generate a valid wasm to
    test on, but it is "destructive" in itself: when removing NaNs (to avoid nondeterminism)
    if replaces them with 0, which is different. As a result, running --denan when
    generating the second wasm from the first could lead to different execution in them.
    This was always a problem, but became more noticable recently now that DeNaN
    modifies SIMD operations, as one optimization we do is to replace a memory.copy
    with v128.load + v128.store, and --denan will make sure the loaded value has no
    NaNs...
    
    To fix this, separate the generation and optimization phase. Instead of
    
    wasm-opt random.input -ttf -o a.wasm --denan -O3
    wasm-opt a.wasm --denan -O3 -o b.wasm
    
    (note how --denan -O3 appears twice), do this:
    
    wasm-opt random.input -ttf -o a.wasm --denan
    wasm-opt a.wasm -O3 -o b.wasm
    
    (note how --denan appears in generation, and -O3 in optimization).
    kripken authored Feb 27, 2024
    Configuration menu
    Copy the full SHA
    a1afe47 View commit details
    Browse the repository at this point in the history

Commits on Feb 28, 2024

  1. Configuration menu
    Copy the full SHA
    c62a0c9 View commit details
    Browse the repository at this point in the history

Commits on Jun 3, 2024

  1. Configuration menu
    Copy the full SHA
    079ec07 View commit details
    Browse the repository at this point in the history

Commits on Jun 5, 2024

  1. Fix stack-use-after-scope on Windows in Precompute (WebAssembly#6643)

    Create a temp var to store the ChildIterator.
    
    Fixes WebAssembly#6639
    mtb0x1 authored and radekdoulik committed Jun 5, 2024
    Configuration menu
    Copy the full SHA
    e8744c8 View commit details
    Browse the repository at this point in the history