unisonweb / unison

A friendly programming language from the future
https://unison-lang.org
Other
5.81k stars 271 forks source link

Unified unboxed/boxed stacks in interpreter #5397

Closed ChrisPenner closed 1 month ago

ChrisPenner commented 1 month ago

Overview

This converts the stack machine in the interpreter from two completely independent stacks (unboxed and boxed) into a single logical stack with unboxed and boxed slots.

The existing unboxed stack was only really used for tags and branches and not for arithmetic. This refactor should allow us to better leverage the usage of unboxed data as well.

~Note: This change in itself is not expected to result in a performance improvement, it is a refactor necessary to enable future perf improvements.~ Turns out we got a 1.1x -> 1.25x perf improvement for free!

Implementation notes

Interesting/controversial decisions

Nah not really.

Test coverage

I'd like to add some round-trip property tests for our MCode and ANF serialization layers, would've saved me a few hours of staring, and this error was barely caught by tests, I was really lucky. This doesn't need to wait for those though.

Loose ends

There are several perf improvements we can make once this is in.

ChrisPenner commented 1 month ago

This build is ready to go once @dolio signs off on it, it's passing all tests and the nimbus tests.