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

Implement the GC in Rust #1750

Merged
merged 21 commits into from
Sep 3, 2020
Merged

Implement the GC in Rust #1750

merged 21 commits into from
Sep 3, 2020

Commits on Sep 3, 2020

  1. Implement the GC in Rust

    This implements the current garbage collector in Rust. No changes were
    made to the GC design -- it's just ports the one implemented in code
    generator to Rust.
    
    The goals are:
    
    - Evaluate Rust for Motoko's RTS implementation
    - Make the collector easier to read, understand, modify, and extend.
    
    Currently passes the tests locally. We can't run this branch on CI yet
    as it needs to download rustc nightly and xargo and the domains are not
    allowed on the CI. I think in the final version we'll have to build
    rustc outselves instead of downloading.
    
    (Nightly rustc is needed as "core" distributed with rustc is not built
    with PIC relocation model on wam32, so we can't use it to generate a
    shared wasm32 library)
    
    Main changes:
    
    - New Rust crate "motoko-rts" introduced, which currently implements the
      garbage collector. It also has some utilities for printing the heap or
      individual objects, to be used when debugging.
    
    - Nix files updated to download rustc and xargo. These are used to build
      Rust's "core" library with PIC relocation model for wasm32.
    
    - We no longer build memset and memcpy of musl as those are provided by
      Rust's "core" now.
    
    The main algorithm is in `gc.rs`. Rest of the Rust files are helpers,
    mainly for debugging.
    
    Other changes:
    
    - I had to update lots of ic-ref-run outputs. See #1854 for the details.
    
    Remaining work and issues:
    
    - Figure out how to use rustc nightly (with PIC wasm32 libraries) in CI.
    
    Note to reviewers:
    
    - The main algorithm is in `gc.rs`, everything else is helpers. Start
      reading from `gc.rs`.
    osa1 committed Sep 3, 2020
    Configuration menu
    Copy the full SHA
    f245b75 View commit details
    Browse the repository at this point in the history
  2. Apply suggestions from code review

    Co-authored-by: Joachim Breitner <mail@joachim-breitner.de>
    osa1 and nomeata committed Sep 3, 2020
    Configuration menu
    Copy the full SHA
    ce9828a View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    eb33aac View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    5adcd4e View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    c99c3fe View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    b413d98 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    755a096 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    ee53aa0 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    e59f35b View commit details
    Browse the repository at this point in the history
  10. Use memcpy from libc

    Also tweaks the build system a little bit to avoid linking multiple
    versions of compiler_builtins.
    osa1 committed Sep 3, 2020
    Configuration menu
    Copy the full SHA
    3da969c View commit details
    Browse the repository at this point in the history
  11. Encapsulate offset(1) code

    Rust doesn't allow implementing methods on pointer types so we have to
    use associated functions.
    osa1 committed Sep 3, 2020
    Configuration menu
    Copy the full SHA
    2b2a8f7 View commit details
    Browse the repository at this point in the history
  12. Implement some helper methods for Word and Bytes types

    - Add and AddAssign to support + and +=
    - Conversion methods instead of functions and From
    osa1 committed Sep 3, 2020
    Configuration menu
    Copy the full SHA
    3d3a9be View commit details
    Browse the repository at this point in the history
  13. Tweak pub modifiers

    osa1 committed Sep 3, 2020
    Configuration menu
    Copy the full SHA
    bd13ac9 View commit details
    Browse the repository at this point in the history
  14. Remove magic values in object_size, refactor Bytes/Words a little bit…

    … more, fix BigInt layout
    
    - I figured out how to implement methods on pointer types, make
      payload_addr a method on pointers
    
    - Fix BigInt layout (sign field was missing)
    
    - Remove magic values in object_size
    osa1 committed Sep 3, 2020
    Configuration menu
    Copy the full SHA
    59890cc View commit details
    Browse the repository at this point in the history
  15. Configuration menu
    Copy the full SHA
    53f24e5 View commit details
    Browse the repository at this point in the history
  16. Configuration menu
    Copy the full SHA
    567475e View commit details
    Browse the repository at this point in the history
  17. Update Object.hash_ptr comments

    osa1 committed Sep 3, 2020
    Configuration menu
    Copy the full SHA
    1f8b54a View commit details
    Browse the repository at this point in the history
  18. Configuration menu
    Copy the full SHA
    a8f1c90 View commit details
    Browse the repository at this point in the history
  19. Configuration menu
    Copy the full SHA
    52060df View commit details
    Browse the repository at this point in the history
  20. Rename indirection -> forwarding pointer

    (The word "forwarding pointer" is used widely in the literature for
    these things)
    osa1 committed Sep 3, 2020
    Configuration menu
    Copy the full SHA
    8d02c33 View commit details
    Browse the repository at this point in the history
  21. Configuration menu
    Copy the full SHA
    01758d0 View commit details
    Browse the repository at this point in the history