theseus-os / Theseus

Theseus is a modern OS written from scratch in Rust that explores 𝐢𝐧𝐭𝐫𝐚𝐥𝐢𝐧𝐠𝐮𝐚𝐥 𝐝𝐞𝐬𝐢𝐠𝐧: closing the semantic gap between compiler and hardware by maximally leveraging the power of language safety and affine types. Theseus aims to shift OS responsibilities like resource management into the compiler.
https://www.theseus-os.com/
MIT License
2.92k stars 172 forks source link

Attempt to remove runtime `match` statement for `Frames` const generic state #1017

Closed kevinaboos closed 1 year ago

kevinaboos commented 1 year ago

Not relevant until PR #1004 is merged in.

That was actually my first attempt but Rust doesn't allow for specialized Drop implementations :( (link)

Also, I checked the binary for a simplified version of the Frames tyepstates, and it doesn't seem like the match statement is elided. A generic drop function is called for all Frames objects.

_Originally posted by @Ramla-I in https://github.com/theseus-os/Theseus/pull/1004#discussion_r1272686882_

kevinaboos commented 1 year ago

Never mind, thanks to @tsoutsman's analysis, this does not result in a runtime operation, as the const param is monomorphized out before runtime.