Skip to content

Commit

Permalink
feat!: deallocate BumpVec on drop and into_iter, shrink on `into_…
Browse files Browse the repository at this point in the history
…*slice` (#33)
  • Loading branch information
bluurryy authored Sep 16, 2024
1 parent 94fe9e4 commit 4c4fc67
Show file tree
Hide file tree
Showing 27 changed files with 1,739 additions and 475 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased
- **added:** `from_parts` and `into_parts` to `BumpVec` and `BumpString`
- **added:** `FixedBumpString::into_string` returning a `BumpString`
- **breaking:** `BumpVec` and `BumpString` now deallocate on drop, and shrink when calling `into_(boxed_)slice`
- **breaking:** `BumpVec::into_iter` now returns `bump_vec::IntoIter` which deallocates on drop

## 0.8.2 (2024-09-15)
- **added:** `NoDrop` blanket impl for `[T]` is more general, replacing `Copy` bound with `NoDrop`

Expand Down
103 changes: 74 additions & 29 deletions crates/inspect-asm/out/x86-64/alloc_fmt/down.asm
Original file line number Diff line number Diff line change
@@ -1,41 +1,47 @@
inspect_asm::alloc_fmt::down:
push r15
push r14
push r12
push rbx
sub rsp, 112
mov qword ptr [rsp + 32], rsi
mov qword ptr [rsp + 40], rdx
lea rax, [rsp + 32]
mov qword ptr [rsp + 48], rax
lea rax, [rip + <&T as core::fmt::Display>::fmt]
sub rsp, 120
mov qword ptr [rsp + 40], rsi
mov qword ptr [rsp + 48], rdx
lea rax, [rsp + 40]
mov qword ptr [rsp + 56], rax
lea rax, [rip + .L__unnamed_0]
lea rax, [rip + <&T as core::fmt::Display>::fmt]
mov qword ptr [rsp + 64], rax
mov qword ptr [rsp + 72], 2
mov qword ptr [rsp + 96], 0
lea rax, [rsp + 48]
mov qword ptr [rsp + 80], rax
mov qword ptr [rsp + 88], 1
lea rax, [rip + .L__unnamed_0]
mov qword ptr [rsp + 72], rax
mov qword ptr [rsp + 80], 2
mov qword ptr [rsp + 104], 0
lea rax, [rsp + 56]
mov qword ptr [rsp + 88], rax
mov qword ptr [rsp + 96], 1
movups xmm0, xmmword ptr [rip + .L__unnamed_1]
movaps xmmword ptr [rsp], xmm0
mov qword ptr [rsp + 16], 0
mov qword ptr [rsp + 24], rdi
lea rsi, [rip + .L__unnamed_2]
mov rdi, rsp
lea rdx, [rsp + 64]
lea rdx, [rsp + 72]
call qword ptr [rip + core::fmt::write@GOTPCREL]
test al, al
jne .LBB0_4
jne .LBB0_8
mov rsi, qword ptr [rsp]
mov rbx, qword ptr [rsp + 8]
mov r15, qword ptr [rsp + 24]
mov rax, qword ptr [r15]
cmp rsi, qword ptr [rax]
je .LBB0_0
mov rax, qword ptr [rsp + 16]
mov r12, qword ptr [rsp + 24]
mov rcx, qword ptr [r12]
mov rcx, qword ptr [rcx]
cmp rsi, rcx
je .LBB0_1
mov r14, rsi
jmp .LBB0_3
cmp r14, rcx
je .LBB0_4
.LBB0_0:
mov rax, qword ptr [rsp + 16]
mov r15, r14
jmp .LBB0_7
.LBB0_1:
add rax, rsi
xor r14d, r14d
sub rax, rbx
Expand All @@ -44,21 +50,60 @@ inspect_asm::alloc_fmt::down:
mov rdi, r14
mov rdx, rbx
cmp rax, r14
jbe .LBB0_1
jbe .LBB0_2
call qword ptr [rip + memmove@GOTPCREL]
jmp .LBB0_2
.LBB0_1:
call qword ptr [rip + memcpy@GOTPCREL]
jmp .LBB0_3
.LBB0_2:
mov rax, qword ptr [r15]
mov qword ptr [rax], r14
call qword ptr [rip + memcpy@GOTPCREL]
.LBB0_3:
mov rax, r14
mov rax, qword ptr [r12]
mov qword ptr [rax], r14
mov rax, qword ptr [r12]
mov rcx, qword ptr [rax]
mov rax, rbx
cmp r14, rcx
jne .LBB0_0
.LBB0_4:
add rax, rcx
xor edx, edx
sub rax, rbx
cmovae rdx, rax
lea rax, [rbx + rcx]
mov r15, rdx
sub r15, rcx
add r15, r14
mov rdi, r15
mov rsi, r14
cmp rax, rdx
jbe .LBB0_5
mov rdx, rbx
add rsp, 112
call qword ptr [rip + memmove@GOTPCREL]
jmp .LBB0_6
.LBB0_5:
mov rdx, rbx
call qword ptr [rip + memcpy@GOTPCREL]
.LBB0_6:
mov rax, qword ptr [r12]
mov qword ptr [rax], r15
.LBB0_7:
mov rax, r15
mov rdx, rbx
add rsp, 120
pop rbx
pop r12
pop r14
pop r15
ret
.LBB0_4:
.LBB0_8:
call qword ptr [rip + bump_scope::private::format_trait_error@GOTPCREL]
ud2
mov rcx, qword ptr [rsp]
mov rdx, qword ptr [rsp + 24]
mov rdx, qword ptr [rdx]
cmp qword ptr [rdx], rcx
jne .LBB0_9
add rcx, qword ptr [rsp + 16]
mov qword ptr [rdx], rcx
.LBB0_9:
mov rdi, rax
call _Unwind_Resume@PLT
107 changes: 78 additions & 29 deletions crates/inspect-asm/out/x86-64/alloc_fmt/down_a.asm
Original file line number Diff line number Diff line change
@@ -1,41 +1,47 @@
inspect_asm::alloc_fmt::down_a:
push r15
push r14
push r12
push rbx
sub rsp, 112
mov qword ptr [rsp + 32], rsi
mov qword ptr [rsp + 40], rdx
lea rax, [rsp + 32]
mov qword ptr [rsp + 48], rax
lea rax, [rip + <&T as core::fmt::Display>::fmt]
sub rsp, 120
mov qword ptr [rsp + 40], rsi
mov qword ptr [rsp + 48], rdx
lea rax, [rsp + 40]
mov qword ptr [rsp + 56], rax
lea rax, [rip + .L__unnamed_0]
lea rax, [rip + <&T as core::fmt::Display>::fmt]
mov qword ptr [rsp + 64], rax
mov qword ptr [rsp + 72], 2
mov qword ptr [rsp + 96], 0
lea rax, [rsp + 48]
mov qword ptr [rsp + 80], rax
mov qword ptr [rsp + 88], 1
lea rax, [rip + .L__unnamed_0]
mov qword ptr [rsp + 72], rax
mov qword ptr [rsp + 80], 2
mov qword ptr [rsp + 104], 0
lea rax, [rsp + 56]
mov qword ptr [rsp + 88], rax
mov qword ptr [rsp + 96], 1
movups xmm0, xmmword ptr [rip + .L__unnamed_1]
movaps xmmword ptr [rsp], xmm0
mov qword ptr [rsp + 16], 0
mov qword ptr [rsp + 24], rdi
lea rsi, [rip + .L__unnamed_2]
mov rdi, rsp
lea rdx, [rsp + 64]
lea rdx, [rsp + 72]
call qword ptr [rip + core::fmt::write@GOTPCREL]
test al, al
jne .LBB0_4
jne .LBB0_8
mov rsi, qword ptr [rsp]
mov rbx, qword ptr [rsp + 8]
mov r15, qword ptr [rsp + 24]
mov rax, qword ptr [r15]
cmp rsi, qword ptr [rax]
je .LBB0_0
mov rax, qword ptr [rsp + 16]
mov r12, qword ptr [rsp + 24]
mov rcx, qword ptr [r12]
mov rcx, qword ptr [rcx]
cmp rsi, rcx
je .LBB0_1
mov r14, rsi
jmp .LBB0_3
cmp r14, rcx
je .LBB0_4
.LBB0_0:
mov rax, qword ptr [rsp + 16]
mov r15, r14
jmp .LBB0_7
.LBB0_1:
add rax, rsi
xor r14d, r14d
sub rax, rbx
Expand All @@ -45,21 +51,64 @@ inspect_asm::alloc_fmt::down_a:
mov rdi, r14
mov rdx, rbx
cmp rax, r14
jbe .LBB0_1
jbe .LBB0_2
call qword ptr [rip + memmove@GOTPCREL]
jmp .LBB0_2
.LBB0_1:
call qword ptr [rip + memcpy@GOTPCREL]
jmp .LBB0_3
.LBB0_2:
mov rax, qword ptr [r15]
mov qword ptr [rax], r14
call qword ptr [rip + memcpy@GOTPCREL]
.LBB0_3:
mov rax, r14
mov rax, qword ptr [r12]
mov qword ptr [rax], r14
mov rax, qword ptr [r12]
mov rcx, qword ptr [rax]
mov rax, rbx
cmp r14, rcx
jne .LBB0_0
.LBB0_4:
add rax, rcx
xor edx, edx
sub rax, rbx
cmovae rdx, rax
and rdx, -4
lea rax, [rbx + rcx]
mov r15, rdx
sub r15, rcx
add r15, r14
mov rdi, r15
mov rsi, r14
cmp rax, rdx
jbe .LBB0_5
mov rdx, rbx
add rsp, 112
call qword ptr [rip + memmove@GOTPCREL]
jmp .LBB0_6
.LBB0_5:
mov rdx, rbx
call qword ptr [rip + memcpy@GOTPCREL]
.LBB0_6:
mov rax, qword ptr [r12]
mov qword ptr [rax], r15
.LBB0_7:
mov rax, r15
mov rdx, rbx
add rsp, 120
pop rbx
pop r12
pop r14
pop r15
ret
.LBB0_4:
.LBB0_8:
call qword ptr [rip + bump_scope::private::format_trait_error@GOTPCREL]
ud2
mov rdx, qword ptr [rsp]
mov rcx, qword ptr [rsp + 24]
mov rcx, qword ptr [rcx]
cmp qword ptr [rcx], rdx
jne .LBB0_9
mov rsi, qword ptr [rsp + 16]
add rdx, rsi
add rdx, 3
and rdx, -4
mov qword ptr [rcx], rdx
.LBB0_9:
mov rdi, rax
call _Unwind_Resume@PLT
Loading

0 comments on commit 4c4fc67

Please sign in to comment.