Contact
Search
Essays
« Garbage Collection | Main | The Difference Between Extended Basic Blocks and Traces »
Tuesday
Jan132009

SquirrelFish JIT code

I'm really surprised at SquirrelFish's simplicity. I was expecting some kind of register allocator, even a linear scan. Linear scan register allocation is fast because you only have to iterate over all the code once instead of building an interference graph. An interference graph has nodes which represents each physical register on the machine. If two registers are needed at the same time, the two nodes are connected in the graph. Then you color the graph with however many physical registers you have to assign registers. If you can't color the graph, you remove a node by "spilling" it and removing the node from the graph. A spilled node means that the value is stored in memory instead of a register. However, SquirrelFish says forget that! Let's just store everything in memory. Doing an operation involves loading something from memory, the operation, then storing it back. Primitive bytecode operations are done in direct x86. Addition for example, are done with an actual x86 addition. More complex opcodes such as resolv_func have C functions. Here's some sample x86 code for the bytecode resolve_func:

010E01CE  mov         dword ptr [edi+8],0Ah
010E01D5 mov eax,0Ah
010E01DA mov dword ptr [edi+18h],eax
010E01DD mov dword ptr [esp+4],0BAFB10h
010E01E5 mov ecx,esp
010E01E7 mov dword ptr [esp+38h],edi
010E01EB call JSC::Interpreter::cti_op_resolve_func (4A1340h)
For all it's simplicity, it's smoking fast. wow. If you want more on Register Allocation, checkout my favorite source, Wikipedia!

PrintView Printer Friendly Version

EmailEmail Article to Friend

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>