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(compiler)!: Add --memory-base flag #1115

Merged
merged 15 commits into from
Jan 22, 2022
Merged

Conversation

peblair
Copy link
Member

@peblair peblair commented Jan 22, 2022

Closes #1111. The introduction of the attrs result to transl_prim felt a little awkward, but I think it was the cleanest way to slide this into the existing well-formedness checks in the compiler.

Also, I'm open to better names for this PR.

Closes #935 (supersedes it)

…onstant-valued primitives to reify these addresses in the runtime
@peblair peblair requested a review from a team January 22, 2022 12:39
@peblair
Copy link
Member Author

peblair commented Jan 22, 2022

@ospencer This appears to have not caused any snapshot changes. Is that not a bit weird?

Copy link
Member

@ospencer ospencer left a comment

Choose a reason for hiding this comment

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

Nice! And it makes sense that no snapshots changed since the newly generated code should be exactly the same as the old code.

The major thing we need to fix is just that one Binaryen setting so it doesn't trash data in the space that you "reserved" 😂

A couple of tests would be good as well. The big one I'm interested in is starting with a memory base that's larger than the initial number of memory pages—I think we start with something like 64 pages. Just want to make sure that if you try to reserve more space than that everything still works.

Also, I believe you need to declare the new flag in the CLI so it can be used.

For the PR title, I think it's not bad really, but we do want to mark it as breaking in case anyone was depending on the static values, since they should use the primitives now. Maybe

feat(compiler)!: Add `--memory-base` flag

to highlight how to use it?

compiler/src/typed/translprim.re Outdated Show resolved Hide resolved
compiler/src/typed/translprim.re Outdated Show resolved Hide resolved
compiler/src/typed/translprim.re Outdated Show resolved Hide resolved
compiler/src/typed/translprim.re Outdated Show resolved Hide resolved
compiler/src/utils/config.re Outdated Show resolved Hide resolved
@ospencer ospencer assigned peblair and unassigned ospencer Jan 22, 2022
Copy link
Member

@phated phated left a comment

Choose a reason for hiding this comment

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

One style question, but I was also wondering if the attributes are even needed if we land #1074?

compiler/src/codegen/compcore.re Outdated Show resolved Hide resolved
@peblair peblair requested a review from ospencer January 22, 2022 18:59
@peblair peblair changed the title feat(compiler): Adjustable heap base feat(compiler)!: Add --memory-base flag Jan 22, 2022
@peblair
Copy link
Member Author

peblair commented Jan 22, 2022

@phated

but I was also wondering if the attributes are even needed if we land #1074?

No, they are not. If this lands before that does, then that PR should probably remove the attrs value added here. I'm remiss to say that this should be blocked by #1074, though, since this is such a small change (ATM).

@ospencer
Copy link
Member

Hmm, we might still need the attributes, since the way we have it working right now would require @unsafe instead of @disableGC. We could maybe change that though.

@peblair
Copy link
Member Author

peblair commented Jan 22, 2022

That's a good point. Even less reason for this to be blocked 🙂

@peblair
Copy link
Member Author

peblair commented Jan 22, 2022

Tests added.
To be super safe, I checked that the constant gets wired up correctly by veryLarge.gr in the runtime/string WAT, and it looks like it is working great:
image

@peblair peblair requested a review from phated January 22, 2022 19:55
compiler/src/codegen/compcore.re Outdated Show resolved Hide resolved
compiler/test/suites/memory_base.re Outdated Show resolved Hide resolved
compiler/test/suites/memory_base.re Outdated Show resolved Hide resolved
peblair and others added 2 commits January 22, 2022 21:11
Co-authored-by: Oscar Spencer <oscar@grain-lang.org>
@peblair peblair requested a review from ospencer January 22, 2022 20:13
Copy link
Member

@ospencer ospencer left a comment

Choose a reason for hiding this comment

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

Perfect!

@phated
Copy link
Member

phated commented Jan 22, 2022

Can you add Closes #935 (supersedes it) to your PR body or link it in the sidebar?

peblair and others added 3 commits January 22, 2022 21:58
Copy link
Member

@phated phated left a comment

Choose a reason for hiding this comment

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

Excellent work! Love that we're knocking 0.5 things down so quickly ❤️

Copy link
Member

@marcusroberts marcusroberts left a comment

Choose a reason for hiding this comment

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

Looks very good!

@@ -1406,25 +1422,80 @@ let transl_prim = (env, desc) => {
| Not_found => failwith("This primitive does not exist.")
};

let diable_gc = [(Location.mknoloc("disableGC"), [])];
let disable_gc = [(Location.mknoloc("disableGC"), [])];
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice

@peblair peblair merged commit 0680826 into main Jan 22, 2022
@peblair peblair deleted the philip/adjustable-heap-base branch January 22, 2022 22:05
@github-actions github-actions bot mentioned this pull request Jan 22, 2022
@github-actions github-actions bot mentioned this pull request May 16, 2022
@github-actions github-actions bot mentioned this pull request May 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Compiler: Add heap.base primitive
5 participants