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

Refactor vm #2281

Merged
merged 13 commits into from
May 3, 2021
Merged

Refactor vm #2281

merged 13 commits into from
May 3, 2021

Conversation

syrusakbary
Copy link
Member

@syrusakbary syrusakbary commented May 1, 2021

Description

This PR simplifies the VM code. and improves it's resiliency:

  • Removed unnecessary Exported structs
  • Reuse same VM data when available. Fixing Add test that shows local memory/table lifetime bug #2131
  • Removed unnecessary Function Definition in the API
  • Fixes the NativeEngine by automatically deallocating the libraries when the module is no longer used

Review

  • Add a short description of the change to the CHANGELOG.md file

@syrusakbary
Copy link
Member Author

bors try

bors bot added a commit that referenced this pull request May 1, 2021
@bors
Copy link
Contributor

bors bot commented May 1, 2021

try

Build failed:

@syrusakbary
Copy link
Member Author

bors try-

@syrusakbary
Copy link
Member Author

bors try

bors bot added a commit that referenced this pull request May 1, 2021
@bors
Copy link
Contributor

bors bot commented May 1, 2021

try

Build failed:

@syrusakbary
Copy link
Member Author

bors try

bors bot added a commit that referenced this pull request May 1, 2021
@bors
Copy link
Contributor

bors bot commented May 1, 2021

@@ -1285,6 +1167,7 @@ mod inner {

/// An empty struct to help Rust typing to determine
/// when a `HostFunction` does not have an environment.
#[derive(Clone)]
Copy link
Contributor

Choose a reason for hiding this comment

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

Cloning an empty struct? Why? Is the struct just used in the type system? Or is it compared by pointer?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's required for WasmerEnv to be clonable

Comment on lines +147 to +149
std::ptr::copy_nonoverlapping(src_pointer,
rets_list,
num_rets);
Copy link
Contributor

Choose a reason for hiding this comment

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

Indentation looks wrong? Does this pass lint?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, weird. This change was made by the linter

Copy link
Contributor

Choose a reason for hiding this comment

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

The body of macros are not formatted by rustfmt. If the formatting looks wrong, it has to be fixed manually. It was likely caused by your editor if you didn't do it

#[derive(Debug, Clone)]
pub struct VMExportMemory {
#[derive(Debug, Clone, MemoryUsage)]
pub struct VMMemory {
Copy link
Contributor

Choose a reason for hiding this comment

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

No action required. FWIW I think that naming these things VM* is a bug. It's not a new bug introduced in your PR. VM* should mean "used by the VM" as in "the generated code uses this" which implies "must be repr(C) and contain things that are available in repr(C)" which would exclude Arc for instance (I've been arguing we should make a VMArc).

@syrusakbary
Copy link
Member Author

bors r+

@bors
Copy link
Contributor

bors bot commented May 3, 2021

@bors bors bot merged commit d3c58bf into master May 3, 2021
@bors bors bot deleted the refactor-vm branch May 3, 2021 19:55
Copy link
Contributor

@MarkMcCaskey MarkMcCaskey left a comment

Choose a reason for hiding this comment

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

Some of the refactoring here looks really good, I didn't realize some of that was possible. The large PR and touching so many critical pieces made me concerned that this PR introduced a large breaking change that got past our tests but upon further review I don't think that's the case (at least my initial concerns were wrong). I haven't been able to fully review all the changes in this PR yet though.

FunctionDefinition::Wasm(wasm) => {
self.call_wasm(&wasm, params, &mut results)?;
}
// TODO: we can trivially hit this, look into it
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably shouldn't remove this comment unless it's been fixed by this PR

Comment on lines +147 to +149
std::ptr::copy_nonoverlapping(src_pointer,
rets_list,
num_rets);
Copy link
Contributor

Choose a reason for hiding this comment

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

The body of macros are not formatted by rustfmt. If the formatting looks wrong, it has to be fixed manually. It was likely caused by your editor if you didn't do it

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.

3 participants