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.
| /// 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.
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.
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.
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.
Perhaps mention module must be non-null.
There was a problem hiding this comment.
And the same comments apply to instantiate.
There was a problem hiding this comment.
This calles delete, so is guaranteed to be no-op for null pointer. I'll mention this and add a test.
| /// Validate binary module. | ||
| bool fizzy_validate(const uint8_t* wasm_binary, size_t wasm_binary_size); | ||
|
|
||
| /// Parse binary module. |
There was a problem hiding this comment.
Perhaps mention this returns a non-null module pointer on success.
|
Looks good otherwise. |
4ae9696 to
7a5ec49
Compare
axic
left a comment
There was a problem hiding this comment.
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