FFI is sloooow ; ) [ Was: Re: [squeak-dev] Re: Alien vs. FFI
benchmarks (Re: Trying to load ALienOpenGL into 4.1 alpha...) ]
Igor Stasenko
siguctua at gmail.com
Fri Apr 9 09:17:17 UTC 2010
On 9 April 2010 11:49, Bert Freudenberg <bert at freudenbergs.de> wrote:
>
> Way cool :)
>
:)
And here is most important piece of puzzle, and it wooorks!!!
testMovableStuff
"test that if native code calls a VM function which triggers
a full gc and relocates a native code, it will survive the move,
a native code should return a difference between old and new primitive method,
in case if its moved, the difference will be nonzero"
| asm fullGC primitiveMethod code |
asm := AJx86AsmBuilder x86.
primitiveMethod := NBInterpreterProxyGen functions at: #primitiveMethod.
fullGC := NBInterpreterProxyGen functions at: #fullGC .
asm
push: EBP;
mov: ESP->EBP;
mov: (asm mem: EBP) + 12 to: EAX;
mov: (asm mem: EAX) + (primitiveMethod index * 4) to: EAX;
call: EAX;
push: EAX;
"push function to call - fullGC"
mov: (asm mem: EBP) + 12 to: EAX;
mov: (asm mem: EAX) + (fullGC index * 4) to: EAX;
push: EAX;
" call gate function"
mov: (asm mem: EBP) + 8 to: EAX;
call: EAX;
mov: (asm mem: EBP) + 12 to: EAX;
mov: (asm mem: EAX) + (primitiveMethod index * 4) to: EAX;
call: EAX;
pop: EDX;
sub: EAX with: EDX;
shl: EAX with: 1;
inc: EAX;
" clear the stack "
leave;
ret.
code := asm bytes.
" we should not crash here ;) "
10 timesRepeat: [ Array new: 10.
self install: code into: (self class methodDict at: #movableStub).
self movableStub ]
------------
NativeCodeTests new testMovableStuff
#(-1581816 -2544 -3916 -2544 -2544 -2544 -2544 -2544 -2544 -2544)
this means, that while native code calls fullGC, it moves the code away,
but then a magic 'call gate' finds the way back to the right piece of code! :)
> - Bert -
>
>
>
>
--
Best regards,
Igor Stasenko AKA sig.
More information about the Squeak-dev
mailing list
|