Skip to content
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

Add #[inline] annotation to the max() function. #34

Merged
merged 1 commit into from
Sep 21, 2023

Conversation

Kmeakin
Copy link
Contributor

@Kmeakin Kmeakin commented Sep 21, 2023

This function is called from EcoVec::align() and EcoVec::offset() functions. Although they are marked #[inline], and max is private, that is not sufficient to ensure it is inlined, and as a result, EcoVec::new() and related functions have 2 calls to max in them!

Before

cargo asm --release
    Finished release [optimized] target(s) in 0.00s

.section .text.uses_ecow::new,"ax",@progbits
        .globl  uses_ecow::new
        .p2align        4, 0x90
        .type   uses_ecow::new,@function
uses_ecow::new:

        .cfi_startproc
        push rbx
        .cfi_def_cfa_offset 16
        .cfi_offset rbx, -16
        mov rbx, qword ptr [rip + ecow::vec::max@GOTPCREL]
        mov edi, 8
        mov esi, 4
        call rbx

        mov edi, 16
        mov rsi, rax
        call rbx

        xor edx, edx
        pop rbx
        .cfi_def_cfa_offset 8
        ret

After

cargo asm --release                                   
    Finished release [optimized] target(s) in 0.00s

.section .text.uses_ecow::new,"ax",@progbits
        .globl  uses_ecow::new
        .p2align        4, 0x90
        .type   uses_ecow::new,@function
uses_ecow::new:

        .cfi_startproc
        mov eax, 16
        xor edx, edx
        ret

This function is called from `EcoVec::align` and `EcoVec::offset`
functions. Although they are marked `#[inline]`, and `max` is private,
that is not sufficient to ensure that it is inlined, and as a result,
`EcoVec::new()` and related functions have calls to `max` in them.
@codecov-commenter
Copy link

Codecov Report

Patch has no changes to coverable lines.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Files Changed Coverage
src/vec.rs ø

📢 Thoughts on this report? Let us know!.

@laurmaedje laurmaedje merged commit 6a413d9 into typst:main Sep 21, 2023
4 checks passed
@laurmaedje
Copy link
Member

Good catch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants