←back to thread

143 points todsacerdoti | 3 comments | | HN request time: 0s | source
Show context
convivialdingo ◴[] No.43595345[source]
I’ve been modifying the the MIR c2mir JIT compiler to extend the c11 compiler to support simple classes, boxed strings(immutable, nun-nullable) with AOT support.

Imagine if Java and C had a love child, basically.

MIR is a fantastic piece of engineering.

Honestly the hardest part is representing types. Having played around with other compilers it seems to be a typical problem.

I’m stuck in the minutiae of representing highly structured complexity and defining behavior in c. I can understand why many languages have an intermediate compiler - it’s too much work and it will probably change over time.

replies(1): >>43599367 #
1. fuhsnn ◴[] No.43599367[source]
>I’ve been modifying the the MIR c2mir JIT compiler to extend the c11 compiler to support simple classes, boxed strings(immutable, nun-nullable) with AOT support

Is the project public? Really interested in the AOT support, I've always wanted to see its generated code but didn't find an easy way to dump it.

replies(1): >>43605638 #
2. convivialdingo ◴[] No.43605638[source]
Once things are a little more stable, I will put it up!

Right now you can just break before the (fun_call)() delegate and disassemble the fun_call in gdb.

The basic trick is to add reloc support to the x86 translate code, mark external calls and replace with 0x0 placeholders, and copy out the machine_code and data segment output to an object file.

I can do basic main functions with simple prints calls but not much more. It’s a hack for now but I’ll refactor it until it’s solid.

replies(1): >>43620443 #
3. fuhsnn ◴[] No.43620443[source]
Thanks, looking forward to it!