-
Notifications
You must be signed in to change notification settings - Fork 34
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
Conversation
Codecov Report
@@ 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 |
af24f83
to
0629668
Compare
2c89c24
to
f74969b
Compare
82f32cc
to
de689af
Compare
f74969b
to
957f3ee
Compare
7aea9d2
to
f5f5c3b
Compare
957f3ee
to
2a97ebe
Compare
include/fizzy/fizzy.h
Outdated
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 |
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.
/// 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?
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.
Can this be true even if trap is true?
@gumb0 ?
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.
Clarified in comment
ad3da6a
to
e683ce3
Compare
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); |
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.
This takes result
as a reference. Will that reference be valid after exiting this lambda? Is the wrap(result.value)
doing a copy?
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.
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. |
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.
Perhaps mention module
must be non-null.
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.
And the same comments apply to instantiate.
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.
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. |
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.
Perhaps mention this returns a non-null module pointer on success.
Looks good otherwise. |
4ae9696
to
7a5ec49
Compare
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.
Please squash and add a test for free_module(nullptr)
and free_instance(nullptr)
.
Co-authored-by: Alex Beregszaszi <alex@rtfs.hu>
f38f7e5
to
59419bd
Compare
Alternative to #533 based on #575