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

feat: introduce experimental packaging format #278

Merged
merged 18 commits into from
Aug 27, 2024
Merged

Commits on Aug 27, 2024

  1. Configuration menu
    Copy the full SHA
    c5a9869 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    5395e9e View commit details
    Browse the repository at this point in the history
  3. fix: use less fragile method for rodata segment init

    Previous to this commit, we were expecting the rodata segments to be
    encoded in a specific order, and placed on the advice stack before
    anything else. With this commit, we now simply expect to the advice map
    to contain each segment keyed by its commitment hash, which we then move
    to the advice stack on demand, and immediately pipe to memory.
    
    This means the order of the segments no longer matters, and the advice
    stack is not sensitive to codegen changes or other influences which
    might perturb the advice stack or otherwise disrupt our assumptions. It
    also sets the stage for us to be able to initialize rodata after a
    context switch, as at that point the advice stack will be in an unknown
    condition, and using the advice map gives us certainty that we can
    arrange to have exactly what we need on the advice stack, when we need
    it.
    
    Additionally, I've updated the `midenc debug` input config file, as well
    as the usage documentation to reflect this.
    
    The last related change to this, will be emitting the rodata segments to
    disk in a convenient form, so that when the compiler emits the program,
    it also emits the segments alongside it, making it convenient to run the
    debugger against that program (or via the VM directly).
    bitwalker committed Aug 27, 2024
    Configuration menu
    Copy the full SHA
    71626a9 View commit details
    Browse the repository at this point in the history
  4. feat: implement packaging prototype

    This commit implements a basic package format for Miden programs and
    libraries, with the metadata needed to simplify using them together. The
    format is experimental, and can be changed at any time, however it does
    use a header that lets us identify whether a package was produced with
    the same specification or not.
    
    This also modifies the compiler and debugger to emit and consume,
    respectively, the package format as their primary artifact. The debugger
    uses this, for example, to initialize the VM with the necessary
    libraries and rodata segments required by the program.
    
    The package format is described using the structures in
    `codegen/masm/src/packaging/package.rs`, and is encoded using a tiny,
    but efficient binary format from the `bitcode` crate, using `serde` to
    facilitate the lowering of our high-level types to that format. This
    made it relatively straightforward to implement the format without
    having to mess around with the low-level byte representation. The
    `bitcode` crate is designed with stability in mind, though because we
    are using it via `serde`, the stability is subject to being violated if
    `serde` changes something that causes `bitcode` to serialize a type
    differently. For now, this is a non-issue, longer term we might want to
    actually implement `bitcode::{Encode, Decode}` for our types if we want
    to gain more stability.
    bitwalker committed Aug 27, 2024
    Configuration menu
    Copy the full SHA
    3322c53 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    4debaf6 View commit details
    Browse the repository at this point in the history
  6. fix: regression in midenc compile

    Some recent changes caused the `midenc compile` command to emit no
    outputs when `--emit` was not provided.
    
    Also fixed:
    
    * Moved some unnecessary debug logs to trace level
    * Added more debug logging to the compiler to aid in troubleshooting
    * Fixed serialization of packages involving more complex inputs which
      were hitting an issue with fields marked as skippable via serde; this
      is not supported via bitcode, so those attributes were removed
    bitwalker committed Aug 27, 2024
    Configuration menu
    Copy the full SHA
    511f0d3 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    86cf309 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    f2f4045 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    a1d7585 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    c2b2f3b View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    ae525ea View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    6d4353c View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    7bd7c72 View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    5215164 View commit details
    Browse the repository at this point in the history
  15. Configuration menu
    Copy the full SHA
    23c4d2d View commit details
    Browse the repository at this point in the history
  16. Configuration menu
    Copy the full SHA
    50ff2c9 View commit details
    Browse the repository at this point in the history
  17. fix(frontend-wasm): reserve memory allocated for use by rust

    It turns out we were assuming that Rust was laying out its memory using
    the default LLVM layout, but rustc actually specifies a larger shadow
    stack. We were not properly handling the defined memory in Wasm modules
    parsed by the frontend, and so we ended up incorrectly placing global
    variables and other data in the middle of memory that rust was using for
    either the shadow stack or static data. Because of the size of the
    shadow stack region reserved by Rust, this was not causing any
    corruption in our tests, but it was causing other assumptions to be
    invalid, and miscompilations were the result.
    
    This commit treats the Wasm memory for a parsed module as reserved for
    use by the code in that module, which causes midenc to place any global
    variables it defines after that region, and computes the start of the
    heap as immediately following any such data. It does so by propagating
    the page size and reserved number of pages through the IR and to the
    backend, taking that information into account as needed.
    bitwalker committed Aug 27, 2024
    Configuration menu
    Copy the full SHA
    5586482 View commit details
    Browse the repository at this point in the history
  18. Configuration menu
    Copy the full SHA
    ce99ba4 View commit details
    Browse the repository at this point in the history