*Update on the Mu computer's memory-safe language*

I wrote about it last week at akkartik.name/post/mu-2019-2, but already that post is growing out of date. Here's an initial sketch: akkartik.github.io/mu/html/app

So far all that works is function definitions with no arguments or body. They emit just the prologue and epilogue code sequences.

But I have a sketch of the next few steps of the design in there.


The design in akkartik.name/post/mu-2019-2 has changed in 2 ways.

#1: no more uninitialized variables. There's just no safe way to avoid initialization when structs can contain pointers.

This adds overheads to local variables in two ways: performance, and translator complexity for length-prefixed arrays. We can't just zero out everything, we also have to write array lengths in. Since structs may contain arrays, initializing a variable may involve writing lengths to multiple locations.

#2: unwinding the stack when exiting a scope. I can't just increment the stack pointer, I need to also restore any necessary registers along the way.

Another complication is that I need Java's labeled `break`s: docs.oracle.com/javase/tutoria. Since `break` does double-duty for both conditionals and loops, it's too onerous to only be able to `break` out of one scope at a time. But labeled `break`s increase the frequency with which I need to unwind the stack. More overhead.

The common theme here seems to be that the translator needs to maintain 'symbolic' representations of contiguous memory regions, tracking either values or register bindings for offsets.

I'm not sure how I feel about these choices. Perhaps I should give up on this whole design and switch to something more traditional. A memory-safe C-like language. So I'd love to hear feedback and suggestions, either here or over email: ak@akkartik.com

Project link: github.com/akkartik/mu#readme

cc @vertigo @rain@niu.moe

*Update on the Mu computer's memory-safe language*

First statements now translating!


`fn foo {}` => function prologue and epilogue

`increment x` when x is on the stack.

`foo x` when x is on the stack and foo is a user-defined function.

Seems like small progress, but.. rampantgames.com/blog/?p=7745

I feel like I'm finally starting to get closure on news.ycombinator.com/item?id=1

(Project page: github.com/akkartik/mu#readme)

@vertigo @rain@niu.moe

*Update on the Mu computer's memory-safe language*

Not much to report this week. Last week I implemented the instruction `increment x` when `x` is on the stack. This week I did `x <- increment` when x is a register.

(In Mu, registers written to are return values, while memory locations written to are just passed in by reference.)

The good news: I now have a core data structure in place for code-generating different instructions, and this includes static dispatch.


*Update on the Mu computer's memory-safe language*

In the last 2 weeks I went from being able to translate:

fn foo {


fn foo n: int {
increment n

That required 2k LoC. So it seems fair to say that things are still in the "black triangles" phase. And there are still gaping holes. Variable declarations don't really exist yet. (I can just parse them.)

(Project page: github.com/akkartik/mu#readme)

· · Web · 0 · 0 · 1
Sign in to participate in the conversation

The original server operated by the Mastodon gGmbH non-profit