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

Add types and methods to provide updated API #1313

Merged
merged 22 commits into from
Mar 31, 2020
Merged

Add types and methods to provide updated API #1313

merged 22 commits into from
Mar 31, 2020

Conversation

MarkMcCaskey
Copy link
Contributor

@MarkMcCaskey MarkMcCaskey commented Mar 17, 2020

Improving the API in a number of ways.

Current status
  • Get exports from Instance
    • Func
      • Documented
      • Tested
    • DynFunc
      • Documented
      • Tested
    • Memory
      • Documented
      • Tested
    • Table
      • Documented
      • Tested ; fully testing this now will be difficult, blocked on Table API being completed
    • Global
      • Documented
      • Tested
    • Field syntax (fairly non-trivial)
  • Get imports from Module
    • Maybe update this to be an iterator instead of a Vec (side note, we may want to have a way to access specific types of imports too)
    • Documented
    • Tested
  • Get exports from Module
    • Documented
    • Tested
  • Get custom section from Module
    • Figure out correct solution
    • Ship separate PR that updates custom section code
    • Documented
    • Tested
  • Updated Memory API
    • Added conversion methods to bytes/pages with From
    • Documented
    • Tested
  • Table APIs ; blocked on wrap being not linear time update (this update should also make it possible to retrieve a Func from vm::Anyfunc)
    • Table set (implemented needs to be checked)
      • Documented with examples
      • Implemented
    • Table grow (implemented needs to be checked)
      • Documented with examples
      • Implemented
    • Table get
      • Structure implemented
      • Documented
      • Tested
  • Module APIs (probably separate)
  • Update import object macro to handle a lack of trailing commas as well
    • Add line in changelog about it
    • Tested

Review

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

@MarkMcCaskey MarkMcCaskey added the 📦 lib-deprecated About the deprecated crates label Mar 17, 2020
@MarkMcCaskey MarkMcCaskey requested a review from Hywan as a code owner March 17, 2020 22:37
Mark McCaskey added 2 commits March 17, 2020 16:17
We now use `,*` on the outside of a `$()` expression to match on
interspersed commas instead of trailing commas. To continue to handle
the trailing comma case, we optionally match on an extra comma at the
end with `$(,)?`.
/// Get an export.
///
/// ```
/// # use wasmer_runtime_core::{DynFunc, Func, Instance};
Copy link
Member

Choose a reason for hiding this comment

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

Can this be wasmer_runtime instead? I would prefer people depending on the the outer shell.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, it's possible to move the doc comments with examples to wasmer_runtime instead, though the # on that line means that it's invisible to users in the docs, so it doesn't matter here

Mark McCaskey added 2 commits March 18, 2020 18:06
This commit also leaves comments explaining the current state of
things so that when it's unblocked it can be finished and the API made public.
}

// copied from Rust stdlib: https://doc.rust-lang.org/nightly/nightly-rustc/src/serialize/leb128.rs.html#4-14
macro_rules! impl_write_unsigned_leb128 {
Copy link
Member

Choose a reason for hiding this comment

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

Why this is needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not strictly needed, but in case we needed the other functions, I figured it might be good to have around. I can macro-expand/inline the one function I need for the custom section writing if you'd prefer that!

@syrusakbary
Copy link
Member

Can you make instance.func to use the new externals function under the hood? (and also mark it as deprecated)

@MarkMcCaskey
Copy link
Contributor Author

bors try

bors bot added a commit that referenced this pull request Mar 27, 2020
@bors
Copy link
Contributor

bors bot commented Mar 27, 2020

try

Build failed

@MarkMcCaskey
Copy link
Contributor Author

bors try

bors bot added a commit that referenced this pull request Mar 27, 2020
@bors
Copy link
Contributor

bors bot commented Mar 27, 2020

try

Build failed

@bors
Copy link
Contributor

bors bot commented Mar 27, 2020

try

Timed out

Mark McCaskey and others added 2 commits March 30, 2020 17:38
Deprecate more methods on `Instance`, add `into_iter` method on
`Exports`, add FuncSig to ImportType and other updates.
@MarkMcCaskey
Copy link
Contributor Author

bors try

bors bot added a commit that referenced this pull request Mar 31, 2020
@bors
Copy link
Contributor

bors bot commented Mar 31, 2020

try

Build succeeded

lib/api/src/lib.rs Outdated Show resolved Hide resolved
lib/api/src/lib.rs Outdated Show resolved Hide resolved
lib/api/src/lib.rs Outdated Show resolved Hide resolved
@MarkMcCaskey
Copy link
Contributor Author

bors try

bors bot added a commit that referenced this pull request Mar 31, 2020
@bors
Copy link
Contributor

bors bot commented Mar 31, 2020

try

Build failed

@MarkMcCaskey
Copy link
Contributor Author

bors try

bors bot added a commit that referenced this pull request Mar 31, 2020
@@ -716,10 +716,19 @@ impl LocalGlobal {
}

/// Identifier for a function signature.
///
/// A transparent `SigIndex`
#[derive(Debug, Clone, Copy)]
#[repr(transparent)]
pub struct SigId(pub u32);
Copy link
Member

Choose a reason for hiding this comment

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

Should we replace all uses of SigId with SigIndex ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The fact that it's transparent may be important to its use. I just added the comment because I get confused every time I see it.

Copy link
Member

Choose a reason for hiding this comment

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

Is there any way to verify that we are making use of transparent (kind of: tests without it will pass?)

If tests pass, then we can just remove this type and use SigIndex directly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's stored by pointer and might be accessed by the generator code, having it not be transparent could mean that depending on the optimization level, for example, it might just corrupt the data that generated code sees. It is possible to have tests for this, but it's probably not the simplest thing to test. I don't really know how it's used, so maybe it's easier to test than I think it is.

@bors
Copy link
Contributor

bors bot commented Mar 31, 2020

try

Build succeeded

/// The name identifying the export.
pub name: &'a str,
/// The type of the export.
pub ty: ExportType,
Copy link
Member

Choose a reason for hiding this comment

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

Can we have here ty: ExternType ?

@MarkMcCaskey
Copy link
Contributor Author

bors try

bors bot added a commit that referenced this pull request Mar 31, 2020
@MarkMcCaskey
Copy link
Contributor Author

bors try-

@MarkMcCaskey
Copy link
Contributor Author

bors r+

@bors
Copy link
Contributor

bors bot commented Mar 31, 2020

Build succeeded

  • wasmerio.wasmer

@bors bors bot merged commit ecafa75 into master Mar 31, 2020
@bors bors bot deleted the feature/update-api branch March 31, 2020 23:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 lib-deprecated About the deprecated crates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants