Skip to content

0.29.0

Latest

Choose a tag to compare

@github-actions github-actions released this 25 Nov 17:49
de1155d

Added

  • ModuleConfig::function_order takes a closure that decides the order
    defined functions are emitted, and so numbered, in. It is given every
    defined function as a FunctionInfo, with its size and how many times its
    index is written, in the default order (largest first) to reorder. For
    example, sorting by Reverse(f.uses()) gives the shortest LEB128 indices to
    the most-referenced functions, which makes most modules smaller. The default
    order isn't guaranteed and may change; give a closure to depend on one.
  • ModuleConfig::generate_source_map and Module::emit_wasm_with_source_map
    build a source map of the emitted module from its DWARF, with the
    Scopes of its functions
    and inlined calls, and point the module at it with a sourceMappingURL
    section. Each source file gets a Module scope around the Function
    scopes of its functions, which the generic copies and shims of a function
    share.
    ModuleConfig::source_map_scopes(false) leaves the Scopes out, for a map
    with only mappings.

Changed

  • An if whose else arm is empty is emitted without the else, saving a
    byte per if. This was a TODO in the emitter; parsing already turned a
    missing else into an empty one.
  • gimli is updated from 0.32 to 0.34. ModuleDebugData::dwarf is a gimli
    type, so code that reads it needs gimli 0.34 too.
  • The minimum supported Rust version is now 1.88, which gimli 0.34 requires,
    and Cargo.toml declares it. gimli's Dwarf::convert API first shipped in
    0.33, which also requires 1.88.
  • ModuleDebugData has a private field, so it can no longer be built with a
    struct expression; use Default.
  • With generate_dwarf, DW_AT_macros, DW_AT_macro_info and
    DW_AT_GNU_macros are removed. walrus never emitted the macro sections
    they point into, because gimli can't write them.
  • With the parallel feature, parsing finds the block types of legacy catch
    handlers in parallel. This scan decodes every function body. It runs for
    any module with a tag that has params, such as an Emscripten module built
    with C++ exceptions, or with a function type that has two or more results.

Fixed

  • VisitorMut's per-instruction methods (visit_const_mut and so on) no
    longer visit the instruction's fields by default. The traversal already
    does that, so a VisitorMut that only overrode, say, visit_value_mut saw
    every field twice. Visitor already behaved this way.
  • visit_instr_seq_id is no longer called for the branch target of
    br_on_null, br_on_non_null, br_on_cast and br_on_cast_fail, matching
    br, br_if and br_table.
  • visit_instr_seq_id is now called for legacy try catch and catch_all
    handler blocks, matching the try body.
  • With generate_dwarf, location and range lists now follow the code walrus
    moved. Offsets from a base address (DWARF 4 .debug_loc/.debug_ranges
    entries and DWARF 5 DW_LLE_offset_pair/DW_RLE_offset_pair) were
    previously treated as addresses or copied unchanged, so almost every
    location list LLVM writes pointed at the wrong code. walrus now converts
    DWARF with gimli's Dwarf::convert API instead of Dwarf::from, which
    gimli documents as unsuitable for complex address transformations.
  • generate_dwarf no longer panics on DWARF 5 line programs that use file
    index 0, as clang writes them.
  • A line sequence that covers several functions is split per function, so
    its rows stay in address order after walrus reorders functions.
  • With generate_dwarf, the local and global indices in
    DW_OP_WASM_location are remapped to the ones walrus emits. walrus groups
    locals by type and drops unused ones, so 10-24% of the local indices in
    optimized Rust builds named the wrong local. Locations of removed locals
    and globals are dropped.
  • With generate_dwarf, DW_OP_addr keeps its address. In Wasm it's a
    linear memory address of static data, but walrus treated it as a code
    address, so the locations of static and global variables were replaced,
    usually with the removed-code tombstone.
  • DWARF now follows code that passes insert, copy or remove, and locals they
    replace. Each line row, range, location list entry and code address is
    derived from where its input instructions were emitted, so code that is
    now in several places gets a DW_AT_ranges list, and a local a pass
    replaced is found through the instructions that used it. A variable whose
    code was copied into another function, which numbers its locals
    differently, gets a location list with the right local in each, and code
    copied from another compile unit keeps its line rows. Previously
    addresses were mapped through a table that kept one place per input
    instruction.
  • Line rows stay on the instructions they describe. In a Rust -O0 build,
    133 instructions whose row was line 0 were given other lines. delegate
    also keeps its row now.