cmsc430 / cmsc430.github.io

CMSC 430 Design and Implementation of Programming Languages
https://cmsc430.github.io/
45 stars 33 forks source link

Simplify unload-bits-asm and asm-interp when there's a heap #134

Open dvanhorn opened 1 year ago

dvanhorn commented 1 year ago

Currently asm-interp changes it's return type if the runtime uses a heap and produces a pair of the result and a pointer to the heap. The latter is only used to free the memory after the value has been reconstructed. You don't need the heap pointer to reconstruct the value.

It seems to make more sense to just not free the memory and return the bits in rax, from which the value can be reconstructed. This keeps the concept of asm-interp simple and consistent from Abscond through to the end.

There's some worry about leaking memory, but one solution is to have asm-interp re-use the heap memory on each call (it may already do this, I'm not sure). This means you have to be done using the memory before another call to asm-interp happens, but that seems reasonable.

dvanhorn commented 1 year ago

Closed by a6d4745.