From a95d4e3fb05eab02bbf26d4091e426610e96a158 Mon Sep 17 00:00:00 2001 From: Berkus Decker Date: Sun, 26 Dec 2021 17:16:53 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20Use=20inline(always)=20to?= =?UTF-8?q?=20optimize=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This removes additional dummy jumps. --- bin/chainboot/src/boot.rs | 1 + bin/chainboot/src/main.rs | 2 ++ machine/src/arch/aarch64/boot.rs | 1 + 3 files changed, 4 insertions(+) diff --git a/bin/chainboot/src/boot.rs b/bin/chainboot/src/boot.rs index 63a0069..854f44b 100644 --- a/bin/chainboot/src/boot.rs +++ b/bin/chainboot/src/boot.rs @@ -62,6 +62,7 @@ pub unsafe extern "C" fn _start() -> ! { /// /// The function is called from the assembly `_start` function, keep it to support "asm" feature. #[no_mangle] +#[inline(always)] pub unsafe fn _start_rust(max_kernel_size: u64) -> ! { crate::kernel_init(max_kernel_size) } diff --git a/bin/chainboot/src/main.rs b/bin/chainboot/src/main.rs index 641800c..5a2b3cd 100644 --- a/bin/chainboot/src/main.rs +++ b/bin/chainboot/src/main.rs @@ -25,6 +25,7 @@ mod boot; /// /// - Only a single core must be active and running this function. /// - The init calls in this function must appear in the correct order. +#[inline(always)] unsafe fn kernel_init(max_kernel_size: u64) -> ! { #[cfg(feature = "jtag")] machine::arch::jtag::wait_debugger(); @@ -66,6 +67,7 @@ fn read_u64() -> u64 { } /// The main function running after the early init. +#[inline(always)] fn kernel_main(max_kernel_size: u64) -> ! { #[cfg(test)] test_main(); diff --git a/machine/src/arch/aarch64/boot.rs b/machine/src/arch/aarch64/boot.rs index e4adba4..e089101 100644 --- a/machine/src/arch/aarch64/boot.rs +++ b/machine/src/arch/aarch64/boot.rs @@ -24,6 +24,7 @@ macro_rules! entry { /// # Safety /// Only type-checks! #[export_name = "main"] + #[inline(always)] pub unsafe fn __main() -> ! { // type check the given path let f: fn() -> ! = $path;