-
Notifications
You must be signed in to change notification settings - Fork 780
Implement return_call_ref, ref.as_non_null, br_on_[non_]null instructions #2567
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
Conversation
|
Which proposal are these instruction part of? |
|
Thank you for checking the patch. These are the instructions: I am working on function references phase 5 proposal at the moment, which is requirement for the (latest) GC proposal. The work is split into two parts: #2562 adds the concepts of This patch adds the instructions from the proposal. This is the generic testsuite, also used by wabt: My aim is to make all test pass in this directory. |
92898bd to
bce48df
Compare
|
What can I do with this test on s390x: The test is also slow on x86. It does a lot of recursion. I did not write the test, it is a spec test. |
|
you might be able to add |
bce48df to
758858b
Compare
|
Great idea! Thanks it worked! |
758858b to
ef7290e
Compare
1184506 to
10500a7
Compare
|
Ok the fuzzer using this patch found another issue in the code, which is not related to this patch. Example code: The compiled code is With a hexeditor I changed the 0x41 (i32.const) to 0x11 (call_indirect). Then I run objdump: wasm-objdump: .../wabt/wabt/src/binary-reader-objdump.cc:661: void wabt::{anonymous}::BinaryReaderObjdumpDisassemble::LogOpcode(const char*, ...): Assertion `in_function_body' failed. The reason is that init expressions are not validated by objdump. If I change 0x41 to 0x45 ( What shall we do? |
|
My suggestion: I suspect objdump does not validate the code intentionally, just dumps it. Then validation related sanity checks does not make sense, so maybe setting |
Fixes the fuzzer bug in #2567 I noticed all objdump logs are guarded by `if (!in_function_body)`. The code crashes without this check.
ec09f77 to
69054bf
Compare
13fc7b7 to
d03887c
Compare
2c092e7 to
126985f
Compare
ab7cd3c to
c652aee
Compare
c652aee to
5855654
Compare
5017a02 to
9ab4bd1
Compare
8bb32da to
1e29a04
Compare
80f22fa to
073a9d8
Compare
073a9d8 to
528f5a0
Compare
| FuncType func_type; | ||
| result |= typechecker_.OnReturnCallRef(function_type_var.to_type()); | ||
| result |= CheckFuncTypeIndex(function_type_var, &func_type); | ||
| result |= typechecker_.OnReturnCall(func_type.params, func_type.results); |
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 code is based on the original implementation in 9aac0a2, although OnReturnCallIndirect uses its own function which report errors as "call_indirect" rather than "call". Maybe adding a string "descriptor" argument would be better than duplicating the whole function. Call indirect has the code duplication as well, perhaps we could simplify the whole thing with the string argument.
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.
Seems like a good idea, could certainly be in a followup too
| Result NameApplier::OnBrOnNullExpr(BrOnNullExpr* expr) { | ||
| std::string_view label = FindLabelByVar(&expr->var); | ||
| UseNameForVar(label, &expr->var); | ||
| return Result::Ok; |
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.
Unrelated to this PR but this seems to be a repeated pattern here.. i wonder if we could refactor/tempetize/macro somehow?
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.
True. I will do it.
| FuncType func_type; | ||
| result |= typechecker_.OnReturnCallRef(function_type_var.to_type()); | ||
| result |= CheckFuncTypeIndex(function_type_var, &func_type); | ||
| result |= typechecker_.OnReturnCall(func_type.params, func_type.results); |
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.
Seems like a good idea, could certainly be in a followup too
This is just a small set of changes which should follow #2567.
Followup to #2562
Another 1000 lines addition. Depends on the previous work. Currently implements 3 opcodes, but I might add the remaining opcode (return_call_ref).