-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Fix fn () -> Result<T, JsValue>
leaking stack space
#2710
Merged
Merged
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
4f794df
add Descriptor RESULT and Instruction::UnwrapResult
cormacrelf c3de03b
ResultAbi / ResultAbiUnion
cormacrelf 9676d51
Reverse the fields on ResultAbi, remove is_ok as err can be 0
cormacrelf 75c97b1
implement ResultAbi
cormacrelf 5ce54c8
Add tests for `-> Result<T, JsError>`
cormacrelf 3bf2f11
split result.rs tests in two
cormacrelf 9662fbb
initial implementation of `-> Result<T, JsError>`
cormacrelf 3fcec72
docs on JsError, move to lib.rs
cormacrelf 490fc29
Add test for returning Result<(), _>
cormacrelf ec441f1
Add failing test for returning `Result<Option<f64>, _>`
cormacrelf 5fbba71
Make LoadRetptr offsets factor in alignment and previously read values
cormacrelf 98c31b6
Add a doc comment to UnwrapResult
cormacrelf 61b1d59
Slight correction to a comment
cormacrelf 29cb459
Better error message
cormacrelf b5d12e9
un-implement OptionIntoWasmAbi for JsValue, use discriminant instead
cormacrelf f0cef2c
Add some documentation from the PR discussion to ResultAbi
cormacrelf ab2d482
un-implement OptionIntoWasmAbi for &'a JsValue too
cormacrelf 5b24678
bless some UI tests, not sure why
cormacrelf 390a5a4
bless the CLI's output tests
cormacrelf bb892ca
fix indentation of if (is_ok === 0) { throw ... } code
cormacrelf 0e588c1
add tests for async fn() -> Result<_, JsError> and custom error types
cormacrelf 1e3dda7
cargo fmt
cormacrelf c755921
fix bug where takeObject was missing
cormacrelf a5bcf99
support externref in UnwrapResult
cormacrelf dec2d8a
add a WASM_BINDGEN_EXTERNREF=1 test to ci
cormacrelf 81b4d9b
getFromExternrefTable -> takeFromExternrefTable
cormacrelf 8df853e
rewrite outgoing_result
cormacrelf f7be77e
rename is_ok -> is_err, which makes generated glue easier to read
cormacrelf a7933aa
update ui tests
cormacrelf 6880631
add a crashing (if you uncomment the throw) test of Result<String, _>
cormacrelf 2205f69
add result-string reference test
cormacrelf e907229
Fix the crashy Result<String, _> by setting ptr/len to 0 on error
cormacrelf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Are the changes in this block still necessary?
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.
Yes. The offsets placed in the generated LoadRetptr instructions have changed from
.enumerate()
indexes, into correct quad offsets. So before, Optionalf64 worked by a fluke, because the f64 LoadRetptr had offset=1 size=8, and the f64 field was aligned to 8 bytes, and that happened to line up. Now, the same situation gives youoffset=2
. So this code has to change at least a little bit, in order to get f64 LoadRetptrs to divide that quad offset by 2 to get an offset into the Float64Array.The variable names uniqueness is the rest of it, we introduce
scaled_offset
to keepoffset
for use in thevar r{} = ...
below, asoffset
is unique to each LoadRetptr butscaled_offset
is not (sometimes being divided by two).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.
Hm sorry so discuss this further, I don't really understand why the term "quad" is being used in wasm-bindgen. I think it would make more sense for everything to be byte-based instead of quad-based. I realize that wasm-bindgen only works with 4 and 8-byte things but I think it makes more sense to still use bytes internally instead of bytes some places and quads/etc other places
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.
Fair enough, it would be better with only bytes. I'll submit a separate PR, it requires modifying this function alongside the
StructUnpacker
. Fortunately doing so is at most a glue code variable name change (as opposed to an ABI change).