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

C API execute with dynamically allocated module #576

Merged
merged 2 commits into from
Oct 12, 2020

Conversation

gumb0
Copy link
Collaborator

@gumb0 gumb0 commented Oct 5, 2020

Alternative to #533 based on #575

@codecov
Copy link

codecov bot commented Oct 5, 2020

Codecov Report

Merging #576 into master will increase coverage by 0.01%.
The diff coverage is 98.81%.

@@            Coverage Diff             @@
##           master     #576      +/-   ##
==========================================
+ Coverage   98.23%   98.24%   +0.01%     
==========================================
  Files          63       63              
  Lines        9011     9180     +169     
==========================================
+ Hits         8852     9019     +167     
- Misses        159      161       +2     

@gumb0 gumb0 force-pushed the dynamic-module branch 2 times, most recently from af24f83 to 0629668 Compare October 6, 2020 14:05
@gumb0 gumb0 force-pushed the capi-execute-dynamic-module branch from 2c89c24 to f74969b Compare October 7, 2020 16:40
@gumb0 gumb0 force-pushed the dynamic-module branch 2 times, most recently from 82f32cc to de689af Compare October 9, 2020 10:08
@gumb0 gumb0 force-pushed the capi-execute-dynamic-module branch from f74969b to 957f3ee Compare October 9, 2020 10:46
@gumb0 gumb0 force-pushed the dynamic-module branch 2 times, most recently from 7aea9d2 to f5f5c3b Compare October 12, 2020 09:41
@gumb0 gumb0 force-pushed the capi-execute-dynamic-module branch from 957f3ee to 2a97ebe Compare October 12, 2020 10:20
@gumb0 gumb0 marked this pull request as ready for review October 12, 2020 10:20
@gumb0 gumb0 requested review from chfast and axic October 12, 2020 10:48
Base automatically changed from dynamic-module to master October 12, 2020 12:52
@gumb0 gumb0 mentioned this pull request Oct 12, 2020
include/fizzy/fizzy.h Outdated Show resolved Hide resolved
bool trapped;
/// Whether function returned a value. Valid only if trapped == false
bool has_value;
/// Value returned from a function. Valid only if has_value == true
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/// Value returned from a function. Valid only if has_value == true
/// Value returned from a function. Valid only if has_value equals true.

Can this be true even if trap is true?

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 true even if trap is true?

@gumb0 ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Clarified in comment

include/fizzy/fizzy.h Outdated Show resolved Hide resolved
include/fizzy/fizzy.h Outdated Show resolved Hide resolved
include/fizzy/fizzy.h Outdated Show resolved Hide resolved
include/fizzy/fizzy.h Outdated Show resolved Hide resolved
@gumb0 gumb0 force-pushed the capi-execute-dynamic-module branch from ad3da6a to e683ce3 Compare October 12, 2020 13:47
@gumb0 gumb0 requested review from axic and chfast October 12, 2020 14:11
return [func, context](fizzy::Instance& instance, fizzy::span<const fizzy::Value> args,
int depth) noexcept -> fizzy::ExecutionResult {
const auto result = func(context, wrap(&instance), wrap(args.data()), args.size(), depth);
return unwrap(result);
Copy link
Member

@axic axic Oct 12, 2020

Choose a reason for hiding this comment

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

This takes result as a reference. Will that reference be valid after exiting this lambda? Is the wrap(result.value) doing a copy?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Both wrap and unwrap for result are doing a copy

/// Parse binary module.
const FizzyModule* fizzy_parse(const uint8_t* wasm_binary, size_t wasm_binary_size);

/// Free resources associated with the module.
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps mention module must be non-null.

Copy link
Member

Choose a reason for hiding this comment

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

And the same comments apply to instantiate.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This calles delete, so is guaranteed to be no-op for null pointer. I'll mention this and add a test.

bool fizzy_validate(const uint8_t* wasm_binary, size_t wasm_binary_size);

/// Parse binary module.
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps mention this returns a non-null module pointer on success.

@axic
Copy link
Member

axic commented Oct 12, 2020

Looks good otherwise.

include/fizzy/fizzy.h Outdated Show resolved Hide resolved
include/fizzy/fizzy.h Outdated Show resolved Hide resolved
@gumb0 gumb0 force-pushed the capi-execute-dynamic-module branch from 4ae9696 to 7a5ec49 Compare October 12, 2020 15:05
Copy link
Member

@axic axic left a comment

Choose a reason for hiding this comment

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

Please squash and add a test for free_module(nullptr) and free_instance(nullptr).

Co-authored-by: Alex Beregszaszi <alex@rtfs.hu>
@gumb0 gumb0 force-pushed the capi-execute-dynamic-module branch from f38f7e5 to 59419bd Compare October 12, 2020 16:34
@axic axic merged commit 5896ba7 into master Oct 12, 2020
@axic axic deleted the capi-execute-dynamic-module branch October 12, 2020 17:16
@axic axic mentioned this pull request May 23, 2022
49 tasks
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