Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions zerocopy/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ These instructions apply to work in the `zerocopy/` subtree.
In Markdown, indent wrapped bullet continuation lines by two spaces and put a
blank line after each section heading.

- **Derived traits in tests:** For traits whose documentation requires
derive-only implementation, test fixture types **MUST** use Zerocopy's
derives. Do not bypass a derive rejection with a manual implementation;
instead, test the lower-level internal primitive or extend the derive.
Generated derive-output snapshots and crate-owned built-in implementations
are exempt.

## Task-Specific Skills

Use the applicable skills in addition to these standing rules. Skills compose;
Expand Down
29 changes: 14 additions & 15 deletions zerocopy/benches/ref_from_bytes_dynamic_padding.x86-64
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
bench_ref_from_bytes_dynamic_padding:
test dil, 3
jne .LBB5_3
movabs rax, 9223372036854775804
and rax, rsi
cmp rax, 9
jb .LBB5_3
add rax, -9
jne .LBB5_1
cmp rsi, 12
setb al
test sil, 3
setne cl
or cl, al
je .LBB5_3
.LBB5_1:
xor edi, edi
mov rax, rdi
ret
.LBB5_3:
add rsi, -9
movabs rcx, -6148914691236517205
mov rax, rsi
mul rcx
shr rdx
lea rax, [rdx + 2*rdx]
or rax, 3
add rax, 9
cmp rsi, rax
je .LBB5_4
.LBB5_3:
xor edi, edi
mov rdx, rsi
.LBB5_4:
mov rax, rdi
ret
72 changes: 35 additions & 37 deletions zerocopy/benches/ref_from_bytes_dynamic_padding.x86-64.mca
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Iterations: 100
Instructions: 1900
Total Cycles: 645
Total uOps: 2000
Instructions: 1800
Total Cycles: 607
Total uOps: 1900

Dispatch Width: 4
uOps Per Cycle: 3.10
IPC: 2.95
Block RThroughput: 5.0
uOps Per Cycle: 3.13
IPC: 2.97
Block RThroughput: 4.8


Instruction Info:
Expand All @@ -19,22 +19,21 @@ Instruction Info:

[1] [2] [3] [4] [5] [6] Instructions:
1 1 0.33 test dil, 3
1 1 1.00 jne .LBB5_3
1 1 0.33 movabs rax, 9223372036854775804
1 1 0.33 and rax, rsi
1 1 0.33 cmp rax, 9
1 1 1.00 jb .LBB5_3
1 1 0.33 add rax, -9
1 1 1.00 jne .LBB5_1
1 1 0.33 cmp rsi, 12
1 1 0.50 setb al
1 1 0.33 test sil, 3
1 1 0.50 setne cl
1 1 0.33 or cl, al
1 1 1.00 je .LBB5_3
1 0 0.25 xor edi, edi
1 1 0.33 mov rax, rdi
1 1 1.00 U ret
1 1 0.33 add rsi, -9
1 1 0.33 movabs rcx, -6148914691236517205
1 1 0.33 mov rax, rsi
2 4 1.00 mul rcx
1 1 0.50 shr rdx
1 1 0.50 lea rax, [rdx + 2*rdx]
1 1 0.33 or rax, 3
1 1 0.33 add rax, 9
1 1 0.33 cmp rsi, rax
1 1 1.00 je .LBB5_4
1 0 0.25 xor edi, edi
1 1 0.33 mov rdx, rsi
1 1 0.33 mov rax, rdi
1 1 1.00 U ret

Expand All @@ -52,26 +51,25 @@ Resources:

Resource pressure per iteration:
[0] [1] [2] [3] [4] [5] [6.0] [6.1]
- - 6.32 6.33 - 6.35 - -
- - 6.00 6.00 - 6.00 - -

Resource pressure by instruction:
[0] [1] [2] [3] [4] [5] [6.0] [6.1] Instructions:
- - 0.64 0.35 - 0.01 - - test dil, 3
- - - - - 1.00 - - jne .LBB5_3
- - 0.34 0.65 - 0.01 - - movabs rax, 9223372036854775804
- - 0.35 0.65 - - - - and rax, rsi
- - 0.33 0.34 - 0.33 - - cmp rax, 9
- - - - - 1.00 - - jb .LBB5_3
- - 0.35 - - 0.65 - - add rax, -9
- - 0.97 0.01 - 0.02 - - movabs rcx, -6148914691236517205
- - 1.00 1.00 - - - - mul rcx
- - 0.99 - - 0.01 - - shr rdx
- - 0.33 0.67 - - - - lea rax, [rdx + 2*rdx]
- - 0.34 0.66 - - - - or rax, 3
- - 0.33 0.66 - 0.01 - - add rax, 9
- - 0.01 0.99 - - - - cmp rsi, rax
- - - - - 1.00 - - je .LBB5_4
- - 0.50 0.49 - 0.01 - - test dil, 3
- - - - - 1.00 - - jne .LBB5_1
- - 0.49 0.01 - 0.50 - - cmp rsi, 12
- - 1.00 - - - - - setb al
- - - 1.00 - - - - test sil, 3
- - 0.51 - - 0.49 - - setne cl
- - 0.50 - - 0.50 - - or cl, al
- - - - - 1.00 - - je .LBB5_3
- - - - - - - - xor edi, edi
- - 0.32 0.01 - 0.67 - - mov rdx, rsi
- - 0.02 0.34 - 0.64 - - mov rax, rdi
- - - 0.51 - 0.49 - - mov rax, rdi
- - - - - 1.00 - - ret
- - - 0.99 - 0.01 - - add rsi, -9
- - - 1.00 - - - - movabs rcx, -6148914691236517205
- - 0.51 0.49 - - - - mov rax, rsi
- - 1.00 1.00 - - - - mul rcx
- - 1.00 - - - - - shr rdx
- - 0.49 0.51 - - - - mov rax, rdi
- - - - - 1.00 - - ret
25 changes: 11 additions & 14 deletions zerocopy/benches/ref_from_bytes_dynamic_size.x86-64
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
bench_ref_from_bytes_dynamic_size:
mov rax, rdi
test al, 1
jne .LBB5_1
mov rdx, rsi
cmp rsi, 4
setb al
or al, dil
test al, 1
je .LBB5_2
setb cl
or sil, cl
test sil, 1
je .LBB5_3
.LBB5_1:
xor eax, eax
ret
.LBB5_2:
lea rcx, [rdx - 4]
mov rsi, rcx
and rsi, -2
add rsi, 4
shr rcx
xor eax, eax
cmp rdx, rsi
cmove rdx, rcx
cmove rax, rdi
.LBB5_3:
add rdx, -4
shr rdx
ret
62 changes: 27 additions & 35 deletions zerocopy/benches/ref_from_bytes_dynamic_size.x86-64.mca
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Iterations: 100
Instructions: 1800
Total Cycles: 704
Total uOps: 2000
Instructions: 1400
Total Cycles: 438
Total uOps: 1400

Dispatch Width: 4
uOps Per Cycle: 2.84
IPC: 2.56
Block RThroughput: 5.0
uOps Per Cycle: 3.20
IPC: 3.20
Block RThroughput: 4.0


Instruction Info:
Expand All @@ -18,23 +18,19 @@ Instruction Info:
[6]: HasSideEffects (U)

[1] [2] [3] [4] [5] [6] Instructions:
1 1 0.33 mov rax, rdi
1 1 0.33 test al, 1
1 1 1.00 jne .LBB5_1
1 1 0.33 mov rdx, rsi
1 1 0.33 cmp rsi, 4
1 1 0.50 setb al
1 1 0.33 or al, dil
1 1 0.33 test al, 1
1 1 1.00 je .LBB5_2
1 1 0.50 setb cl
1 1 0.33 or sil, cl
1 1 0.33 test sil, 1
1 1 1.00 je .LBB5_3
1 0 0.25 xor eax, eax
1 1 1.00 U ret
1 1 0.50 lea rcx, [rdx - 4]
1 1 0.33 mov rsi, rcx
1 1 0.33 and rsi, -2
1 1 0.33 add rsi, 4
1 1 0.50 shr rcx
1 0 0.25 xor eax, eax
1 1 0.33 cmp rdx, rsi
2 2 0.67 cmove rdx, rcx
2 2 0.67 cmove rax, rdi
1 1 0.33 add rdx, -4
1 1 0.50 shr rdx
1 1 1.00 U ret


Expand All @@ -51,25 +47,21 @@ Resources:

Resource pressure per iteration:
[0] [1] [2] [3] [4] [5] [6.0] [6.1]
- - 5.97 5.98 - 6.05 - -
- - 4.32 4.33 - 4.35 - -

Resource pressure by instruction:
[0] [1] [2] [3] [4] [5] [6.0] [6.1] Instructions:
- - 0.97 0.01 - 0.02 - - mov rdx, rsi
- - 0.01 0.02 - 0.97 - - cmp rsi, 4
- - 0.03 - - 0.97 - - setb al
- - 0.01 0.02 - 0.97 - - or al, dil
- - - 0.98 - 0.02 - - test al, 1
- - - - - 1.00 - - je .LBB5_2
- - 0.33 0.66 - 0.01 - - mov rax, rdi
- - 0.67 0.33 - - - - test al, 1
- - - - - 1.00 - - jne .LBB5_1
- - 0.33 0.34 - 0.33 - - mov rdx, rsi
- - 0.33 0.66 - 0.01 - - cmp rsi, 4
- - 1.00 - - - - - setb cl
- - - 1.00 - - - - or sil, cl
- - - 1.00 - - - - test sil, 1
- - - - - 1.00 - - je .LBB5_3
- - - - - - - - xor eax, eax
- - - - - 1.00 - - ret
- - 0.98 0.02 - - - - lea rcx, [rdx - 4]
- - 0.01 0.99 - - - - mov rsi, rcx
- - - 0.98 - 0.02 - - and rsi, -2
- - 0.98 0.01 - 0.01 - - add rsi, 4
- - 0.99 - - 0.01 - - shr rcx
- - - - - - - - xor eax, eax
- - 0.02 0.97 - 0.01 - - cmp rdx, rsi
- - 0.99 0.99 - 0.02 - - cmove rdx, rcx
- - 0.98 0.99 - 0.03 - - cmove rax, rdi
- - 0.66 0.34 - - - - add rdx, -4
- - 1.00 - - - - - shr rdx
- - - - - 1.00 - - ret
14 changes: 7 additions & 7 deletions zerocopy/benches/ref_from_prefix_dynamic_padding.x86-64
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
bench_ref_from_prefix_dynamic_padding:
test dil, 3
sete al
cmp rsi, 12
setae cl
test al, cl
jne .LBB5_2
movabs rax, 9223372036854775804
and rsi, rax
cmp rsi, 8
ja .LBB5_3
.LBB5_2:
xor edx, edx
test dil, 3
sete dl
xor edi, edi
mov rax, rdi
ret
.LBB5_3:
add rsi, -9
.LBB5_2:
or rsi, 3
add rsi, -12
movabs rcx, -6148914691236517205
mov rax, rsi
mul rcx
Expand Down
48 changes: 25 additions & 23 deletions zerocopy/benches/ref_from_prefix_dynamic_padding.x86-64.mca
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Iterations: 100
Instructions: 1900
Total Cycles: 607
Total uOps: 2000
Instructions: 2000
Total Cycles: 640
Total uOps: 2100

Dispatch Width: 4
uOps Per Cycle: 3.29
uOps Per Cycle: 3.28
IPC: 3.13
Block RThroughput: 5.0
Block RThroughput: 5.3


Instruction Info:
Expand All @@ -19,18 +19,19 @@ Instruction Info:

[1] [2] [3] [4] [5] [6] Instructions:
1 1 0.33 test dil, 3
1 1 0.50 sete al
1 1 0.33 cmp rsi, 12
1 1 0.50 setae cl
1 1 0.33 test al, cl
1 1 1.00 jne .LBB5_2
1 1 0.33 movabs rax, 9223372036854775804
1 1 0.33 and rsi, rax
1 1 0.33 cmp rsi, 8
1 1 1.00 ja .LBB5_3
1 0 0.25 xor edx, edx
1 1 0.33 test dil, 3
1 1 0.50 sete dl
1 0 0.25 xor edi, edi
1 1 0.33 mov rax, rdi
1 1 1.00 U ret
1 1 0.33 add rsi, -9
1 1 0.33 or rsi, 3
1 1 0.33 add rsi, -12
1 1 0.33 movabs rcx, -6148914691236517205
1 1 0.33 mov rax, rsi
2 4 1.00 mul rcx
Expand All @@ -52,26 +53,27 @@ Resources:

Resource pressure per iteration:
[0] [1] [2] [3] [4] [5] [6.0] [6.1]
- - 6.00 5.99 - 6.01 - -
- - 6.33 6.33 - 6.34 - -

Resource pressure by instruction:
[0] [1] [2] [3] [4] [5] [6.0] [6.1] Instructions:
- - 0.01 0.98 - 0.01 - - test dil, 3
- - 0.65 0.34 - 0.01 - - test dil, 3
- - 0.99 - - 0.01 - - sete al
- - 0.01 0.33 - 0.66 - - cmp rsi, 12
- - 0.34 - - 0.66 - - setae cl
- - 1.00 - - - - - test al, cl
- - - - - 1.00 - - jne .LBB5_2
- - 0.98 0.01 - 0.01 - - movabs rax, 9223372036854775804
- - 0.01 0.99 - - - - and rsi, rax
- - 0.01 0.99 - - - - cmp rsi, 8
- - - - - 1.00 - - ja .LBB5_3
- - - - - - - - xor edx, edx
- - 0.99 0.01 - - - - test dil, 3
- - 0.99 - - 0.01 - - sete dl
- - - 0.99 - 0.01 - - test dil, 3
- - - - - 1.00 - - sete dl
- - - - - - - - xor edi, edi
- - - 0.01 - 0.99 - - mov rax, rdi
- - - 1.00 - - - - mov rax, rdi
- - - - - 1.00 - - ret
- - 0.01 0.99 - - - - add rsi, -9
- - - 1.00 - - - - movabs rcx, -6148914691236517205
- - 1.00 - - - - - mov rax, rsi
- - 0.01 0.99 - - - - or rsi, 3
- - 0.33 0.67 - - - - add rsi, -12
- - 0.66 0.34 - - - - movabs rcx, -6148914691236517205
- - 0.34 0.33 - 0.33 - - mov rax, rsi
- - 1.00 1.00 - - - - mul rcx
- - 1.00 - - - - - shr rdx
- - - 0.01 - 0.99 - - mov rax, rdi
- - - 0.34 - 0.66 - - mov rax, rdi
- - - - - 1.00 - - ret
Loading
Loading