-
Notifications
You must be signed in to change notification settings - Fork 833
[Parser] Parse ref.func #6097
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
[Parser] Parse ref.func #6097
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -840,7 +840,10 @@ Result<> IRBuilder::makeRefIsNull() { | |
| return Ok{}; | ||
| } | ||
|
|
||
| // Result<> IRBuilder::makeRefFunc() {} | ||
| Result<> IRBuilder::makeRefFunc(Name func) { | ||
| push(builder.makeRefFunc(func, wasm.getFunction(func)->type)); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider adding a comment about wasm-ir-builder having a stricter makeRefFunc() than wasm-builder, one that will throw an exception if the function being made reference to is not already added to the module.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll add a general comment about this to the top-level IRBuilder doc comment because this applies to many functions. |
||
| return Ok{}; | ||
| } | ||
|
|
||
| Result<> IRBuilder::makeRefEq() { | ||
| RefEq curr; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -214,6 +214,8 @@ | |
|
|
||
| ;; CHECK: (data $1 (memory $mem-i64) (i64.const 0) "64-bit") | ||
|
|
||
| ;; CHECK: (elem declare func $ref-func) | ||
|
|
||
| ;; CHECK: (export "g1" (global $g1)) | ||
|
|
||
| ;; CHECK: (export "g1.1" (global $g1)) | ||
|
|
@@ -2205,6 +2207,21 @@ | |
| ref.is_null | ||
| ) | ||
|
|
||
| ;; CHECK: (func $ref-func (type $void) | ||
| ;; CHECK-NEXT: (drop | ||
| ;; CHECK-NEXT: (ref.func $ref-func) | ||
| ;; CHECK-NEXT: ) | ||
| ;; CHECK-NEXT: (drop | ||
| ;; CHECK-NEXT: (ref.func $ref-func) | ||
| ;; CHECK-NEXT: ) | ||
| ;; CHECK-NEXT: ) | ||
| (func $ref-func | ||
| ref.func $ref-func | ||
| drop | ||
| ref.func 102 | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How did you know $ref-func was at function index 102?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. trial and error ;) |
||
| drop | ||
| ) | ||
|
|
||
| ;; CHECK: (func $ref-eq (type $28) (param $0 eqref) (param $1 eqref) (result i32) | ||
| ;; CHECK-NEXT: (ref.eq | ||
| ;; CHECK-NEXT: (local.get $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.
What's the NullInstrParserCtx for?
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.
The first few phases of parsing only care about finding top-level module elements like globals, functions, etc, or parsing types, so they don't need to do anything interesting with the instructions. The parser contexts for those phases inherit from
NullInstrParserCtxto avoid having to repeat this "do nothing" behavior for each of them separately.