On 2010-06-08, at 9:30 PM, chevalma@iro.umontreal.ca wrote:
Ok. I'd like to use your Gambit code as a reference, but I also think it would be neat(er) to write the writing of x86 code in JS. I would rather avoid having to call external code to do the x86 code writing. I would ideally have each x86 IR instruction have a JS method that can write its own representation into a heap allocated array of bytes, or something of that sort.
Yes that's what I have in mind. Something like:
var code = new CodeBlock();
code.x86_movl(x86_mem(esp,4), eax); code.x86_addl(eax, eax); code.x86_ret();
code.assemble();
print(code.execute(11)); // prints 22
Actually, perhaps we're both thinking of the same thing here. I just want to make sure we don't blindly translate your code. If I want to be able to do on-stack replacement, I will need to have a fairly deep understanding of x86 code. Erick will also want to understand this pretty well in order to really understand how the bootstrapping will work.
Sure, you can both study/translate the Scheme code to JS. I can give a short presentation on the general format of x86 code. The code is general purpose (i.e. no dependencies with other stuff and easy to adapt to any back-end).
Marc