Perceus: Garbage Free Reference Counting with Reuse (Extended version)

  • Alex Reinking* ,
  • Ningning Xie* ,
  • Leonardo de Moura ,

MSR-TR-2020-42 |

Published by Microsoft

(*) The first two authors contributed equally to this work. v4, 2021-06-07. Extended version of the PLDI'21 paper.

We introduce Perceus, an algorithm for precise reference counting with
reuse and specialization. Starting from a functional core language with
explicit control-flow, Perceus emits precise reference counting
instructions such that programs are _garbage free_, where only live
references are retained. This enables further optimizations,
like reuse analysis that allows for guaranteed in-place updates at
runtime. This in turn enables a novel programming paradigm that we call
_functional but in-place_ (FBIP). Much like tail-call optimization
enables writing loops with regular function calls, reuse analysis enables
writing in-place mutating algorithms in a purely functional way. We give
a novel formalization of reference counting in a linear resource
calculus, and prove that Perceus is sound and garbage free. We show
evidence that Perceus, as implemented in Koka, has good performance
and is competitive with other state-of-the-art memory collectors.

Téléchargements de publications

Koka

juin 18, 2021

Koka: a Functional Language with Effects Koka is a strongly typed functional-style language with effect types and handlers.