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: memory mapping #117

Merged
merged 10 commits into from
Apr 19, 2020
Merged

feat: memory mapping #117

merged 10 commits into from
Apr 19, 2020

Conversation

Wodann
Copy link
Collaborator

@Wodann Wodann commented Apr 8, 2020

When a struct's memory layout changes, we want any existing instances of that struct to be converted to the new memory layout. E.g. given a struct definition:

struct Foo {
    a: int,
    b: float,
    c: float,
}

we construct a Foo { a: 1, b: 3.0, c: 5.0 }. Now we make several changes to the struct definition, as follows:

struct Foo {
    b: float,   // move
    d: int,     // move + rename
//  c: float,   // remove    
    e: int,     // add
}

For all moved fields, we expect the values to be mapped (i.e. copied), whereas new values should be zero initialized. In the example, resulting struct would look like this:

Foo {
    b: 3.0,  // copied from b
    d: 1,    // copied from a
    e: 0,    // zero initialized
}

The current implementation does not support type casting such as fn(f32) -> f64 yet.

PR #140 adds type casting of primitive types.

@Wodann Wodann requested a review from baszalmstra April 8, 2020 15:29
@Wodann Wodann self-assigned this Apr 8, 2020
@codecov
Copy link

codecov bot commented Apr 8, 2020

Codecov Report

Merging #117 into master will increase coverage by 0.66%.
The diff coverage is 89.91%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #117      +/-   ##
==========================================
+ Coverage   82.72%   83.39%   +0.66%     
==========================================
  Files         147      158      +11     
  Lines        9704    10646     +942     
==========================================
+ Hits         8028     8878     +850     
- Misses       1676     1768      +92     
Impacted Files Coverage Δ
crates/mun_abi/src/autogen.rs 64.61% <ø> (ø)
crates/mun_codegen/src/code_gen/linker.rs 23.17% <0.00%> (-2.17%) ⬇️
crates/mun_memory/src/gc.rs 100.00% <ø> (ø)
crates/mun_memory/src/gc/ptr.rs 100.00% <ø> (ø)
crates/mun_memory/src/gc/root_ptr.rs 63.15% <ø> (ø)
crates/mun_memory/tests/gc/alloc.rs 100.00% <ø> (ø)
crates/mun_memory/tests/gc/structs.rs 100.00% <ø> (ø)
crates/mun_memory/tests/gc/util.rs 100.00% <ø> (ø)
crates/mun_runtime/src/function.rs 100.00% <ø> (ø)
crates/mun_runtime/tests/marshalling.rs 100.00% <ø> (ø)
... and 38 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 18425e7...cd68924. Read the comment docs.

@Wodann Wodann force-pushed the feature/mapping branch 3 times, most recently from 910e0dc to 5760961 Compare April 18, 2020 14:23
@Wodann Wodann marked this pull request as ready for review April 18, 2020 14:47
Copy link
Collaborator

@baszalmstra baszalmstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is one crazy PR. I love it! This seems very promising (given the tests). I'm very curious about how good this works in practice!

👏 👏 for this PR. Amazing job!

I've really only got some minor comments.

crates/mun_hir/src/ty.rs Outdated Show resolved Hide resolved
crates/mun_runtime/src/assembly.rs Show resolved Hide resolved
crates/mun_runtime/tests/util.rs Show resolved Hide resolved
Wodann added 10 commits April 19, 2020 14:03
When an assembly has been hot reloaded, but some of its types are still
in use, the entire assembly needs to be kept in memory to maintain
validity of existing TypeInfo pointers
macOS seems to use a shared library's install_name when opening a shared
library. Previously we stored the full path, which caused the OS to
always point to the same file even when copies were made.
@Wodann Wodann requested a review from baszalmstra April 19, 2020 12:09
@Wodann Wodann merged commit c17448d into mun-lang:master Apr 19, 2020
@Wodann
Copy link
Collaborator Author

Wodann commented Apr 19, 2020

Memory mapping

@Wodann Wodann added this to the Mun v0.2 milestone May 14, 2020
@Wodann Wodann deleted the feature/mapping branch May 14, 2020 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants