What If We Don't Pop the Stack? The Return of 2nd-Class Values
Autor: | Xhebraj, Anxhelo, Bračevac, Oliver, Wei, Guannan, Rompf, Tiark |
---|---|
Jazyk: | angličtina |
Rok vydání: | 2022 |
Předmět: | |
DOI: | 10.4230/lipics.ecoop.2022.15 |
Popis: | Using a stack for managing the local state of procedures as popularized by Algol is a simple but effective way to achieve a primitive form of automatic memory management. Hence, the call stack remains the backbone of most programming language runtimes to the present day. However, the appealing simplicity of the call stack model comes at the price of strictly enforced limitations: since every function return pops the stack, it is difficult to return stack-allocated data from a callee upwards to its caller - especially variable-size data such as closures. This paper proposes a solution by introducing a small tweak to the usual stack semantics. We design a type system that tracks the underlying storage mode of values, and when a function returns a stack-allocated value, we just don't pop the stack! Instead, the stack frame is de-allocated together with a parent the next time a heap-allocated value or primitive is returned. We identify a range of use cases where this delayed-popping strategy is beneficial, ranging from closures to trait objects to other types of variable-size data. Our evaluation shows that this execution model reduces heap and GC pressure and recovers spatial locality of programs improving execution time between 10% and 25% with respect to standard execution. LIPIcs, Vol. 222, 36th European Conference on Object-Oriented Programming (ECOOP 2022), pages 15:1-15:29 |
Databáze: | OpenAIRE |
Externí odkaz: |