-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Winch atomic loads x64 #9970
Winch atomic loads x64 #9970
Changes from 19 commits
0631e73
4d62aa5
9fdf41a
be25acb
90b5e0f
52de203
b09d73e
a1731f1
5ddbbb8
134d520
a21bd5b
e2d68de
a860bac
f76f2ed
2d59967
422c5b3
b9ec70c
c12c155
431f175
1f4bc09
ac5703e
3393b43
235e5e1
ea23c8f
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,30 @@ | ||
;;! target = "x86_64" | ||
;;! test = "winch" | ||
|
||
(module | ||
(import "env" "memory" (memory 1 1 shared)) | ||
(func (param $foo i32) (result i32) | ||
(i32.atomic.load | ||
(local.get $foo)))) | ||
;; wasm[0]::function[0]: | ||
;; pushq %rbp | ||
;; movq %rsp, %rbp | ||
;; movq 8(%rdi), %r11 | ||
;; movq 0x10(%r11), %r11 | ||
;; addq $0x20, %r11 | ||
;; cmpq %rsp, %r11 | ||
;; ja 0x47 | ||
;; 1c: movq %rdi, %r14 | ||
;; subq $0x20, %rsp | ||
;; movq %rdi, 0x18(%rsp) | ||
;; movq %rsi, 0x10(%rsp) | ||
;; movl %edx, 0xc(%rsp) | ||
;; movl 0xc(%rsp), %eax | ||
;; movq 0x58(%r14), %r11 | ||
;; movq (%r11), %rcx | ||
;; addq %rax, %rcx | ||
;; movl (%rcx), %eax | ||
;; addq $0x20, %rsp | ||
;; popq %rbp | ||
;; retq | ||
;; 47: ud2 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
;;! target = "x86_64" | ||
;;! test = "winch" | ||
|
||
(module | ||
(import "env" "memory" (memory 1 1 shared)) | ||
(func (param $foo i32) (result i32) | ||
(i32.atomic.load16_u | ||
(local.get $foo)))) | ||
;; wasm[0]::function[0]: | ||
;; pushq %rbp | ||
;; movq %rsp, %rbp | ||
;; movq 8(%rdi), %r11 | ||
;; movq 0x10(%r11), %r11 | ||
;; addq $0x20, %r11 | ||
;; cmpq %rsp, %r11 | ||
;; ja 0x49 | ||
;; 1c: movq %rdi, %r14 | ||
;; subq $0x20, %rsp | ||
;; movq %rdi, 0x18(%rsp) | ||
;; movq %rsi, 0x10(%rsp) | ||
;; movl %edx, 0xc(%rsp) | ||
;; movl 0xc(%rsp), %eax | ||
;; movq 0x58(%r14), %r11 | ||
;; movq (%r11), %rcx | ||
;; addq %rax, %rcx | ||
;; movzwq (%rcx), %rax | ||
;; addq $0x20, %rsp | ||
;; popq %rbp | ||
;; retq | ||
;; 49: ud2 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
;;! target = "x86_64" | ||
;;! test = "winch" | ||
|
||
(module | ||
(memory (data "\00\00\00\00\00\00\f4\7f")) | ||
|
||
(func (result i32) | ||
(i32.atomic.load8_u (i32.const 0)))) | ||
;; wasm[0]::function[0]: | ||
;; pushq %rbp | ||
;; movq %rsp, %rbp | ||
;; movq 8(%rdi), %r11 | ||
;; movq 0x10(%r11), %r11 | ||
;; addq $0x10, %r11 | ||
;; cmpq %rsp, %r11 | ||
;; ja 0x42 | ||
;; 1c: movq %rdi, %r14 | ||
;; subq $0x10, %rsp | ||
;; movq %rdi, 8(%rsp) | ||
;; movq %rsi, (%rsp) | ||
;; movl $0, %eax | ||
;; movq 0x60(%r14), %rcx | ||
;; addq %rax, %rcx | ||
;; movzbq (%rcx), %rax | ||
;; addq $0x10, %rsp | ||
;; popq %rbp | ||
;; retq | ||
;; 42: ud2 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
;;! target = "x86_64" | ||
;;! test = "winch" | ||
|
||
(module | ||
(memory (data "\00\00\00\00\00\00\f4\7f")) | ||
|
||
(func (result i64) | ||
(i64.atomic.load | ||
(i32.const 0)))) | ||
;; wasm[0]::function[0]: | ||
;; pushq %rbp | ||
;; movq %rsp, %rbp | ||
;; movq 8(%rdi), %r11 | ||
;; movq 0x10(%r11), %r11 | ||
;; addq $0x10, %r11 | ||
;; cmpq %rsp, %r11 | ||
;; ja 0x41 | ||
;; 1c: movq %rdi, %r14 | ||
;; subq $0x10, %rsp | ||
;; movq %rdi, 8(%rsp) | ||
;; movq %rsi, (%rsp) | ||
;; movl $0, %eax | ||
;; movq 0x60(%r14), %rcx | ||
;; addq %rax, %rcx | ||
;; movq (%rcx), %rax | ||
;; addq $0x10, %rsp | ||
;; popq %rbp | ||
;; retq | ||
;; 41: ud2 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
;;! target = "x86_64" | ||
;;! test = "winch" | ||
|
||
(module | ||
(memory (data "\00\00\00\00\00\00\f4\7f")) | ||
|
||
(func (result i64) | ||
(i64.atomic.load16_u | ||
(i32.const 0)))) | ||
;; wasm[0]::function[0]: | ||
;; pushq %rbp | ||
;; movq %rsp, %rbp | ||
;; movq 8(%rdi), %r11 | ||
;; movq 0x10(%r11), %r11 | ||
;; addq $0x10, %r11 | ||
;; cmpq %rsp, %r11 | ||
;; ja 0x42 | ||
;; 1c: movq %rdi, %r14 | ||
;; subq $0x10, %rsp | ||
;; movq %rdi, 8(%rsp) | ||
;; movq %rsi, (%rsp) | ||
;; movl $0, %eax | ||
;; movq 0x60(%r14), %rcx | ||
;; addq %rax, %rcx | ||
;; movzwq (%rcx), %rax | ||
;; addq $0x10, %rsp | ||
;; popq %rbp | ||
;; retq | ||
;; 42: ud2 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
;;! target = "x86_64" | ||
;;! test = "winch" | ||
|
||
(module | ||
(memory (data "\00\00\00\00\00\00\f4\7f")) | ||
|
||
(func (result i64) | ||
(i64.atomic.load32_u | ||
(i32.const 0)))) | ||
;; wasm[0]::function[0]: | ||
;; pushq %rbp | ||
;; movq %rsp, %rbp | ||
;; movq 8(%rdi), %r11 | ||
;; movq 0x10(%r11), %r11 | ||
;; addq $0x10, %r11 | ||
;; cmpq %rsp, %r11 | ||
;; ja 0x40 | ||
;; 1c: movq %rdi, %r14 | ||
;; subq $0x10, %rsp | ||
;; movq %rdi, 8(%rsp) | ||
;; movq %rsi, (%rsp) | ||
;; movl $0, %eax | ||
;; movq 0x60(%r14), %rcx | ||
;; addq %rax, %rcx | ||
;; movl (%rcx), %eax | ||
;; addq $0x10, %rsp | ||
;; popq %rbp | ||
;; retq | ||
;; 40: ud2 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
;;! target = "x86_64" | ||
;;! test = "winch" | ||
|
||
(module | ||
(memory (data "\00\00\00\00\00\00\f4\7f")) | ||
|
||
(func (result i64) | ||
(i64.atomic.load8_u | ||
(i32.const 0)))) | ||
;; wasm[0]::function[0]: | ||
;; pushq %rbp | ||
;; movq %rsp, %rbp | ||
;; movq 8(%rdi), %r11 | ||
;; movq 0x10(%r11), %r11 | ||
;; addq $0x10, %r11 | ||
;; cmpq %rsp, %r11 | ||
;; ja 0x42 | ||
;; 1c: movq %rdi, %r14 | ||
;; subq $0x10, %rsp | ||
;; movq %rdi, 8(%rsp) | ||
;; movq %rsi, (%rsp) | ||
;; movl $0, %eax | ||
;; movq 0x60(%r14), %rcx | ||
;; addq %rax, %rcx | ||
;; movzbq (%rcx), %rax | ||
;; addq $0x10, %rsp | ||
;; popq %rbp | ||
;; retq | ||
;; 42: ud2 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -870,6 +870,16 @@ impl Masm for MacroAssembler { | |
let _ = (context, kind); | ||
Err(anyhow!(CodeGenError::unimplemented_masm_instruction())) | ||
} | ||
|
||
fn wasm_load_atomic( | ||
&mut self, | ||
_src: Self::Address, | ||
_dst: WritableReg, | ||
_size: OperandSize, | ||
_sextend: Option<ExtendKind>, | ||
) -> Result<()> { | ||
todo!() | ||
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. Could you return a proper I believe we have |
||
} | ||
} | ||
|
||
impl MacroAssembler { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1211,6 +1211,18 @@ impl Masm for MacroAssembler { | |
|
||
Ok(()) | ||
} | ||
|
||
fn wasm_load_atomic( | ||
&mut self, | ||
src: Self::Address, | ||
dst: WritableReg, | ||
size: OperandSize, | ||
kind: Option<ExtendKind>, | ||
) { | ||
// The guarantees of the x86-64 memory model ensure that `SeqCst` | ||
// loads are equivalent to normal loads. | ||
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. Given this comment and for the purposes of this pull request, I wonder if it's necessary to introduce a new method in the MacroAssembler. I'd prefer if possible, if we could instead extend the current load definition to take in a We could simplify to:
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. sure i'll do that |
||
self.wasm_load(src, dst, size, kind); | ||
} | ||
} | ||
|
||
impl MacroAssembler { | ||
|
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.
Rather than a
bool
, which can be error-prone, could you define a small enumWasmLoadKind { Regular, Atomic }
or similar and match on it in this function?