-
Notifications
You must be signed in to change notification settings - Fork 18.7k
[WebAssembly] Cooperative threading for WASIP3 #200855
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
Merged
+231
−64
Merged
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
83c5f9a
Cooperative multithreading changes
TartanLlama 8fea1e2
Cleanup createInitTLSFunction
TartanLlama ca1b293
Remove newline
TartanLlama e76828d
Replace libcall-thread-context flag
TartanLlama 77c1c71
fmt
TartanLlama 763392d
Correct output segments
TartanLlama c68d4de
Cleanup
TartanLlama c1a1569
Cleanup options
TartanLlama 8434913
fmt
TartanLlama 6a5feb4
Merge branch 'main' into sy/wasip3-coop
TartanLlama d25493b
Merge branch 'main' into sy/wasip3-coop
TartanLlama 95db2cb
Fix tests
TartanLlama 83ffa2f
Merge branch 'main' into sy/wasip3-coop
TartanLlama 617d774
Update comment
TartanLlama dd5aace
Update test
TartanLlama 8258f16
Cooperative multithreading -> cooperative threading
TartanLlama e1218c4
Simplify comment
TartanLlama bec4064
Fix test
TartanLlama b4c392e
Update comment
TartanLlama 8dc9294
fmt
TartanLlama 321cbf0
Merge branch 'main' into sy/wasip3-coop
TartanLlama 751bb96
Don't change thread model in wasip3 without atomics
TartanLlama c5abbd0
Merge branch 'sy/wasip3-coop' of github.com:TartanLlama/llvm-project …
TartanLlama feb6df8
Special case coop threading for atomics and pthreads
TartanLlama 886664a
fmt
TartanLlama 1956bc7
Mark setTLSBase and getTLSBase as live
TartanLlama 183d32d
Mark TLS functions as used
TartanLlama 7fbe0ba
Remove semicolon
TartanLlama ae9f01a
Indentation
TartanLlama b34cf85
Don't call stripThreadLocals twice
TartanLlama 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| # Test that --cooperative-threading uses the libcall ABI naming for | ||
| # thread-context globals (__init_stack_pointer, __init_tls_base, etc.) and | ||
| # works without --shared-memory and atomics. | ||
|
|
||
| # RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t.o %s | ||
| # RUN: wasm-ld --cooperative-threading -no-gc-sections -o %t.wasm %t.o | ||
| # RUN: obj2yaml %t.wasm | FileCheck %s | ||
| # RUN: llvm-objdump -d --no-print-imm-hex --no-show-raw-insn %t.wasm | FileCheck %s --check-prefix=DIS | ||
|
|
||
| # Test that --cooperative-threading and --shared-memory are mutually exclusive. | ||
| # RUN: not wasm-ld --cooperative-threading --shared-memory %t.o -o %t2.wasm 2>&1 | FileCheck %s --check-prefix=INCOMPAT | ||
| # INCOMPAT: --cooperative-threading is incompatible with --shared-memory | ||
|
|
||
| .globl __wasm_get_tls_base | ||
| __wasm_get_tls_base: | ||
| .functype __wasm_get_tls_base () -> (i32) | ||
| i32.const 0 | ||
| end_function | ||
|
|
||
| .globl _start | ||
| _start: | ||
| .functype _start () -> (i32) | ||
| call __wasm_get_tls_base | ||
| i32.const tls1@TLSREL | ||
| i32.add | ||
| i32.load 0 | ||
| call __wasm_get_tls_base | ||
| i32.const tls2@TLSREL | ||
| i32.add | ||
| i32.load 0 | ||
| i32.add | ||
| end_function | ||
|
|
||
| .section .tdata.tls1,"",@ | ||
| .globl tls1 | ||
| tls1: | ||
| .int32 1 | ||
| .size tls1, 4 | ||
|
|
||
| .section .tdata.tls2,"",@ | ||
| .globl tls2 | ||
| tls2: | ||
| .int32 2 | ||
| .size tls2, 4 | ||
|
|
||
| .section .custom_section.target_features,"",@ | ||
| .int8 2 | ||
| .int8 43 | ||
| .int8 11 | ||
| .ascii "bulk-memory" | ||
| .int8 43 | ||
| .int8 7 | ||
| .ascii "atomics" | ||
|
|
||
| # Memory must NOT be marked as shared. | ||
| # CHECK: - Type: MEMORY | ||
| # CHECK-NEXT: Memories: | ||
| # CHECK-NEXT: - Minimum: 0x2 | ||
| # CHECK-NOT: Shared | ||
|
|
||
| # Globals should use the libcall ABI naming, not the global ABI. | ||
| # CHECK: GlobalNames: | ||
| # CHECK-NEXT: - Index: 0 | ||
| # CHECK-NEXT: Name: __init_stack_pointer | ||
| # CHECK-NEXT: - Index: 1 | ||
| # CHECK-NEXT: Name: __init_tls_base | ||
| # CHECK-NEXT: - Index: 2 | ||
| # CHECK-NEXT: Name: __tls_size | ||
| # CHECK-NEXT: - Index: 3 | ||
| # CHECK-NEXT: Name: __tls_align | ||
|
|
||
| # DIS-LABEL: <__wasm_init_memory>: | ||
|
|
||
| # DIS-LABEL: <_start>: | ||
| # DIS-EMPTY: | ||
| # DIS-NEXT: call {{[0-9]+}} | ||
| # DIS-NEXT: i32.const 0 | ||
| # DIS-NEXT: i32.add | ||
| # DIS-NEXT: i32.load 0 | ||
| # DIS-NEXT: call {{[0-9]+}} | ||
| # DIS-NEXT: i32.const 4 | ||
| # DIS-NEXT: i32.add | ||
| # DIS-NEXT: i32.load 0 | ||
| # DIS-NEXT: i32.add | ||
| # DIS-NEXT: end |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Was this a typo from the previous commit?
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.
Indeed