[Vm-dev] [NB] NativeBoost meets JIT

Igor Stasenko siguctua at gmail.com
Fri Sep 21 16:25:22 UTC 2012


On 21 September 2012 17:53, Denis Kudriashov <dionisiydk at gmail.com> wrote:
>
> Hello
>
> 2012/9/21 Igor Stasenko <siguctua at gmail.com>
>>
>> nbFoo2
>>         <primitive: #primitiveNativeCall module: #NativeBoostPlugin error: errorCode>
>>
>>         ^ NBNativeCodeGen methodAssembly: [:gen :proxy :asm |
>>                 asm noStackFrame.
>>                 asm
>>                         mov: (42 << 1) + 1 to: asm EAX;
>>                         ret.
>>         ]
>>
>> And this one uses JIT:
>>
>> nbFoo
>>         <primitive: 220 error: errorCode>
>>
>>         [ errorCode = ErrRunningViaInterpreter  ] whileTrue: [ ^ self nbFoo ].
>>
>>         ^ NBNativeCodeGen jitMethodAssembly: [:gen :proxy :asm |
>>                 asm noStackFrame.
>>                 asm
>>                         mov: (42 << 1) + 1 to: asm EDX;
>>                         ret: 4 asUImm.
>>         ]
>
>
> Why assembly code is different for jitted and non jitted versions?


In short: because Cog JIT code uses different convention(s).
One of them is return value should be in EDX, unlike from cdecl
convention, which is EAX.


> What I should change in my nativeboost assembly to be able to jit it?
>

i think, most of the time it is entry and leave code..
and accessing method's argument(s). The rest, like calling
interpreterProxy's functions
can be left unchanged.
Also, it must be noted, that JIT code uses own stack and making calls
to C functions
might be very dangerous (overflow stack) unless you know that C
function won't consume much stack space.
 (otherwise you need to temporary switch stack when doing such calls).

I don't know too much details right now, but Eliot knows better
because he wrote it :)


> Any way thank's for such impressive work.
>
> Best regards,
> Denis


-- 
Best regards,
Igor Stasenko.


More information about the Vm-dev mailing list