-
Notifications
You must be signed in to change notification settings - Fork 699
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
binary/wat: Implement EHv4 #2470
base: main
Are you sure you want to change the base?
Conversation
marking this as ready for review even if it's not fully complete, would love to hear feedback. |
Adding @aheejin too |
include/wabt/type.h
Outdated
@@ -87,6 +88,8 @@ class Type { | |||
case Type::V128: return "v128"; | |||
case Type::I8: return "i8"; | |||
case Type::I16: return "i16"; | |||
case Type::ExnRef: | |||
return "exnref"; |
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.
Use a single line like the surrounding code here and below?
if (!buffer.empty()) { | ||
// remove trailing space | ||
buffer.pop_back(); | ||
} |
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.
I wonder if there is some way to refactor this such to avoid adding and removing the trailing whitespace like this?
src/interp/binary-reader-interp.cc
Outdated
{}, | ||
{Istream::kInvalidOffset}, | ||
static_cast<u32>(local_decl_count_), | ||
0}); |
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.
Why did this code move?
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.
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.
Yup, lets split out whatever we can.
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.
Wow, thanks for all the work on this. Very impressive!
Looks good so far.
Fixes the value stack size of the catch handler. There were two (related) issues here: - The previous code used `func_->locals.size()` as soon as the function was available, but it hadn't processed the function's locals yet, so it was always empty. (This might not matter in practice, as it's only used by the "function-wide catch handler", which just rethrows.) - The previous code didn't take the function's locals into account when computing the value stack height (relative to the function frame) for a try-catch block. So, it would drop the locals when catching an exception. Closes #2476 (Split from #2470 )
@sbc100 how do you fix the lint task? |
I think you want to add |
there we go. good enough. smh. sigh... |
we can bump the testsuite later, so we're splitting that out as well... |
there are a lot of TODOs related to reftypes in the interpreter... |
we believe that's all we really need for EHv4, @sbc100 let us know if there's something we missed (or if you have any ideas for how to split this up, because we don't...) |
@sbc100 when do you think you can get around to reviewing this? |
Do you want to rebase this change and we can see how much of it remains after the split out changes. |
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.
Thanks!
This PR is still pretty huge. I manged to glance over it and it looks good, but I didn't dive into the interp stuff or the wasm2c stuff.
@keithw @aheejin do either of you have time to help review this?
I think maybe landing the wasm2c change after everything else might be one more logical place to split this?
Index tag; | ||
Index depth; | ||
}; | ||
using RawCatchVector = std::vector<RawCatch>; |
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.
Why is "Raw" in the name here?
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.
they match what's in the binary, vs the representation used in the wabt IR.
src/interp/binary-reader-interp.cc
Outdated
// TryTable blocks need a try_end_offset | ||
Label* local_label = TopLabel(); | ||
HandlerDesc& desc = func_->handlers[local_label->handler_desc_index]; | ||
desc.try_end_offset = istream_.end(); |
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.
Is this different to above block? Looks like maybe only in the assertion?
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.
should we merge them? what do we do about the assert?
Thanks for the work! I'll be OOO for a week from tomorrow; I'm not an expert of Wabt but I can take a look once I come back. (You don't need to wait for me in case others think the PR is good to land, for sure) But first I'd also like to suggest to split the PR. Smaller PRs are easier to review. I think this can probably be splitted into text parsing / binary parsing / type checking / interpreter / wasm2c. |
e634e83
to
f92fff4
Compare
split out the wasm2c stuff |
It looks this still contains many stuff other than the interpreter. I think parsing and printing can go first before the interpreter and split to another PR. |
parsing and printing are tricky because we don't run roundtrip against spec 🙃 |
yeeted interp, why not |
@sbc100 ptal |
This pull request implements EHv4. Binary is mostly untested until interp is working.