Goals and subgoals

Hi everybody! As it seems that a JIT compiler doesn't fall into place fully formed in a weekend, I've decided to set myself a few goals - along with smaller subgoals that I hope will help keep me on track. The immediate goal for the week is to compile a subroutine that adds two numbers and returns them, like so:

sub foo() {
    return 3 + 4;
}

Which is literally as basic as you can get it. Nevertheless, quite a few parts have to be up and moving to get this to work. Hence the list. So without further ado, I present you:

  • Modifying the Configure / Make files to run DynASM and link the resulting file.
I've actually already done this, and it was more complicated than it seems, and I'm still not completely happy about it.
  • Obtaining writable memory that can be marked executable
  • Marking said memory executable and non-writable (security folks!)
I plan to do this by hijacking MVM_platform_allocate_pages(), which nobody uses right now.
  • Determine, for a given code graph, whether we can JIT compile it. 
    • Called MVM_can_jit_graph(MVMSpeshGraph*)
  • Transforming a Spesh graph into a JIT graph
    • Note that I don't know yet what that JIT graph will look like.
    • I think it will hold values along with their sizes, though. I'm not sure the spesh graph does that. 
  • Directly construct our very simple code graph, by hand, using MAST.
  • JIT compiling the very simple code graph of our code.
  • UPDATE: attach a JIT code segment to a MVMStaticFrame
  • Calling and returning from that code.
This... will probably be a bit experimental - it's of no use to throw in a full-fledged register allocation and instruction selection algorithm to add two constant numbers. We can - in principle - also do without these, but it will lead to rather poor machine code. 

I've probably forgotten quite a few things in here. But this seems like a start. If there's something you think I missed, please comment :-)

Reacties

Populaire posts van deze blog

Reverse Linear Scan Allocation is probably a good idea

Retrospective of the MoarVM JIT

Something about IR optimization