-
Notifications
You must be signed in to change notification settings - Fork 858
[wasm-split] Fix table naming conflicts #8708
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
Changes from 2 commits
9abfe78
d38d9fa
57d63fc
24a4d91
8e621fc
cf68bab
2273159
23a296a
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 |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| ;; RUN: wasm-split %s -all -g -o1 %t.1.wasm -o2 %t.2.wasm --split-funcs=split | ||
| ;; RUN: wasm-dis %t.1.wasm | filecheck %s --check-prefix PRIMARY | ||
| ;; RUN: wasm-dis %t.2.wasm | filecheck %s --check-prefix SECONDARY | ||
|
|
||
| ;; Regression test for a bug when an existing table, which is to be split to the | ||
| ;; secondary module, has the name '0'. The newly created active table should | ||
| ;; have a different name. | ||
|
|
||
| (module | ||
| (table $0 0 externref) | ||
| (export "split" (func $split)) | ||
| (func $split | ||
| (table.set $0 | ||
| (i32.const 0) | ||
| (ref.null extern) | ||
| ) | ||
| ) | ||
| ) | ||
|
|
||
| ;; PRIMARY: (module | ||
| ;; PRIMARY-NEXT: (type $0 (func)) | ||
| ;; PRIMARY-NEXT: (import "placeholder.deferred" "0" (func $placeholder_0)) | ||
| ;; PRIMARY-NEXT: (table $0 1 funcref) | ||
|
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. Table names are not actually shown in the output because its
Member
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. Are you saying that
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'm not sure if I understand. So the input file's table name is (table $0 0 externref)And when it tries to make an active table, we start from But because the table's As I said in #8708 (comment), we can make it preserved if debug option is enabled.
Member
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. Oh I see, I was missing that there was a round-trip through the binary involved.
Member
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. IIRC, we can pass -S to wasm-split to have it write text modules, then we can
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. Done: 24a4d91
Member
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. It looks like the new table is still called
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. #8708 (comment) |
||
| ;; PRIMARY-NEXT: (elem $0 (i32.const 0) $placeholder_0) | ||
| ;; PRIMARY-NEXT: (export "split" (func $trampoline_split)) | ||
| ;; PRIMARY-NEXT: (export "table" (table $0)) | ||
| ;; PRIMARY-NEXT: (func $trampoline_split | ||
| ;; PRIMARY-NEXT: (call_indirect (type $0) | ||
| ;; PRIMARY-NEXT: (i32.const 0) | ||
| ;; PRIMARY-NEXT: ) | ||
| ;; PRIMARY-NEXT: ) | ||
| ;; PRIMARY-NEXT: ) | ||
|
|
||
| ;; SECONDARY: (module | ||
| ;; SECONDARY-NEXT: (type $0 (func)) | ||
| ;; SECONDARY-NEXT: (import "primary" "table" (table $timport$0 1 funcref)) | ||
| ;; SECONDARY-NEXT: (table $0 0 externref) | ||
| ;; SECONDARY-NEXT: (elem $0 (table $timport$0) (i32.const 0) func $split) | ||
| ;; SECONDARY-NEXT: (func $split | ||
| ;; SECONDARY-NEXT: (table.set $0 | ||
| ;; SECONDARY-NEXT: (i32.const 0) | ||
| ;; SECONDARY-NEXT: (ref.null noextern) | ||
| ;; SECONDARY-NEXT: ) | ||
| ;; SECONDARY-NEXT: ) | ||
| ;; SECONDARY-NEXT: ) | ||
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.
We don't want to iterate through all the secondaries multiple times in case it takes several iterations to find a good name. Let's iterate through them just once and create a set of all the table names we have to avoid.
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.
But we only create an active table once, no?
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.
Right. I mean that we should create this set just once at the beginning of
makeTable.getValidName()can call the predicate an arbitrary number of times until it finds a valid name, so we want to avoid that being pathologically expensive.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.
Done: 57d63fc