-
Notifications
You must be signed in to change notification settings - Fork 824
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
Remove backend::Backend from runtime-core #1099
Conversation
bors try |
tryBuild failed
|
bors try |
bors r- |
bors try- |
bors try |
tryBuild succeeded
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll do a full review later but my knee-jerk reaction is that I don't like this change. I do agree that we should have better support for other backends and that the current Backend
enum in runtime-core doesn't seem to be flexible enough for what we want. I'll have to think about alternatives more later though
fn backend_id() -> Backend { | ||
Backend::Cranelift | ||
fn backend_id() -> String { | ||
"cranelift".to_string() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better to have typed backend ids. An approach similar to InternalField
for middlewares might work:
wasmer/lib/runtime-core/src/vm.rs
Line 139 in f2f1a08
pub struct InternalField { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can do this with a wrapper struct and (static) strings too.
I think we'll probably want to have a way to print out the name of the backend in either case, so we'll either need to have the string be part of the id
or have a mapping from id to string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's a list of issues I see from most severe to least severe:
- the current changes to the
Makefile
in thecheck
section remove most of the checking we do -- we can't ship that. - this changes some of the semantics of the crates: we need to document them in any case, but especially with these changes. We may want to add a crate between
runtime
andruntime-core
. edit: after reviewing the PR in depth, I don't see a use for an additional crate right now. - We can improve type safety, in addition or instead of using a static string (described below), by providing a wrapper type -- this is more for our sake than the public API's sake, but I think it will improve readability in some places.
- I think
&'static str
might be a better choice thanString
.String
is a dynamic, runtime value,&'static str
is a compile-time string. It seems that being forced to use values you declared at compile-time is less error prone than a dynamic string here. I personally can't think of any case where the string would need to be dynamic right now.
1cf7ab0
to
d544f5a
Compare
I just reverted that
Agreed. I talked with @losfair and he thinks we can use a similar strategy as we are doing with Internal Fields (here's a POC: #1106 ). I think we can merge this, and then merge the other PR apart, or we can do the static str changes meanwhile. Let me know! |
Sure, I'm fine merging in in-progress work in general as long as we have plans to follow up and we don't release until the public APIs are in the shape we want them to be. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The core changes look good -- I'm not fully on board with this being the way the public API looks though but as discussed, we can follow up on that!
One last thought: perhaps it would simplify the code to have the Backend
enum always contain all our backends regardless of features and have the conditional compilation logic in other places Not high priority, but because you've just interacted with this code you're in a good position to decide if that kind of change would be helpful.
lib/runtime-core/Cargo.toml
Outdated
@@ -52,7 +52,7 @@ cc = "1.0" | |||
[features] | |||
debug = [] | |||
trace = ["debug"] | |||
# backend flags used in conditional compilation of Backend::variants | |||
# backend flags no longer used |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer just deleting them if we're not using them!
features = ["rc"] | ||
[dependencies.serde_derive] | ||
version = "1.0" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this chunk of the Cargo.toml came from runtime-core
, do you know if we can remove the feature from runtime-core
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately both need serde_derive
as they use #[derive(Serialize, Deserialize, ...)]
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, the git diff shows 4 lines, I intended to point to just the top one with features = ["rc"]
!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a very minor thing, just thought it'd be better to remove it if it's not needed
bors r+ |
1099: Remove backend::Backend from runtime-core r=syrusakbary a=syrusakbary <!-- Prior to submitting a PR, review the CONTRIBUTING.md document for recommendations on how to test: https://github.com/wasmerio/wasmer/blob/master/CONTRIBUTING.md#pull-requests --> # Description This PR removes the dependency of a Backend in runtime-core. So it's agnostic and more backends can be plugged in easily. Why this is important? * By removing backends from wasmer-runtime-core we can make the runtime agnostic, so anyone can plug their own backend into Wasmer without needing to touch the main source code (V8, JavascriptCore, wasm3, ...). * It simplifies the codebase and avoids code leaks from the backend to the runtime API. <!-- Provide details regarding the change including motivation, links to related issues, and the context of the PR. --> # Review - [x] Add a short description of the the change to the CHANGELOG.md file Co-authored-by: Syrus <[email protected]> Co-authored-by: Syrus Akbary <[email protected]>
Build failed
|
Bumps [getrandom](https://github.com/rust-random/getrandom) from 0.1.13 to 0.1.14. - [Release notes](https://github.com/rust-random/getrandom/releases) - [Changelog](https://github.com/rust-random/getrandom/blob/master/CHANGELOG.md) - [Commits](rust-random/getrandom@v0.1.13...v0.1.14) Signed-off-by: dependabot-preview[bot] <[email protected]>
Bumps [parking_lot](https://github.com/Amanieu/parking_lot) from 0.9.0 to 0.10.0. - [Release notes](https://github.com/Amanieu/parking_lot/releases) - [Changelog](https://github.com/Amanieu/parking_lot/blob/master/CHANGELOG.md) - [Commits](Amanieu/parking_lot@0.9.0...0.10.0) Signed-off-by: dependabot-preview[bot] <[email protected]>
Bumps [regex](https://github.com/rust-lang/regex) from 1.3.1 to 1.3.3. - [Release notes](https://github.com/rust-lang/regex/releases) - [Changelog](https://github.com/rust-lang/regex/blob/master/CHANGELOG.md) - [Commits](rust-lang/regex@1.3.1...1.3.3) Signed-off-by: dependabot-preview[bot] <[email protected]>
Bumps [cc](https://github.com/alexcrichton/cc-rs) from 1.0.48 to 1.0.50. - [Release notes](https://github.com/alexcrichton/cc-rs/releases) - [Commits](rust-lang/cc-rs@1.0.48...1.0.50) Signed-off-by: dependabot-preview[bot] <[email protected]>
bors r+ |
1099: Remove backend::Backend from runtime-core r=syrusakbary a=syrusakbary <!-- Prior to submitting a PR, review the CONTRIBUTING.md document for recommendations on how to test: https://github.com/wasmerio/wasmer/blob/master/CONTRIBUTING.md#pull-requests --> # Description This PR removes the dependency of a Backend in runtime-core. So it's agnostic and more backends can be plugged in easily. Why this is important? * By removing backends from wasmer-runtime-core we can make the runtime agnostic, so anyone can plug their own backend into Wasmer without needing to touch the main source code (V8, JavascriptCore, wasm3, ...). * It simplifies the codebase and avoids code leaks from the backend to the runtime API. <!-- Provide details regarding the change including motivation, links to related issues, and the context of the PR. --> # Review - [x] Add a short description of the the change to the CHANGELOG.md file Co-authored-by: Syrus <[email protected]> Co-authored-by: Syrus Akbary <[email protected]> Co-authored-by: Mark McCaskey <[email protected]> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Build failed
|
bors r+ |
1099: Remove backend::Backend from runtime-core r=syrusakbary a=syrusakbary <!-- Prior to submitting a PR, review the CONTRIBUTING.md document for recommendations on how to test: https://github.com/wasmerio/wasmer/blob/master/CONTRIBUTING.md#pull-requests --> # Description This PR removes the dependency of a Backend in runtime-core. So it's agnostic and more backends can be plugged in easily. Why this is important? * By removing backends from wasmer-runtime-core we can make the runtime agnostic, so anyone can plug their own backend into Wasmer without needing to touch the main source code (V8, JavascriptCore, wasm3, ...). * It simplifies the codebase and avoids code leaks from the backend to the runtime API. <!-- Provide details regarding the change including motivation, links to related issues, and the context of the PR. --> # Review - [x] Add a short description of the the change to the CHANGELOG.md file Co-authored-by: Syrus <[email protected]> Co-authored-by: Syrus Akbary <[email protected]> Co-authored-by: Mark McCaskey <[email protected]> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Build succeeded
|
1143: Set backend_id to static str r=MarkMcCaskey a=syrusakbary <!-- Prior to submitting a PR, review the CONTRIBUTING.md document for recommendations on how to test: https://github.com/wasmerio/wasmer/blob/master/CONTRIBUTING.md#pull-requests --> # Description As per feedback in #1099, set backend_id to static str. <!-- Provide details regarding the change including motivation, links to related issues, and the context of the PR. --> # Review - [ ] Add a short description of the the change to the CHANGELOG.md file Co-authored-by: Syrus <[email protected]> Co-authored-by: Mark McCaskey <[email protected]>
Description
This PR removes the dependency of a Backend in runtime-core. So it's agnostic and more backends can be plugged in easily.
Why this is important?
Review