Here the proof of concept implementation.

1. Build VM with a new primitive (in Interpreter-primitiveNativeCall.st)

2. run image with new VM
 - file-in a NativeCodeTrailers
 - then NativeCodeTests

I found that on my WinXP, i even haven't to change a platform-specific
code to run it - only this tiny primitive!!
Seems like someone put a right flags into memory allocation procedure already :)

If you look at primitive, it is quite primitive :)
The one thing, which bothers me above everything is a sanity check,
which should be done more appropriately.
A primitive checks that trailer contains a right platform code, and if
it contains something else, then it fails.
This is done, obviously, in order to prevent running a native code,
generated for different platform.
The problem, that VMMaker don't having any notion of platform code, to
my knowledge,
so i put there '1' for now. But for correct behavior, there should be
one, set by VMMaker at initialization,
so for different platforms, VM built for that platform will answer
different code, i.e. windoze32 = 1, linux32 = 2 ... and so on.

So, here the questions, which i like to be answered:
1. reserve a numbered primitive
2. discuss the calling convention
3. add a 'platform id' code to VMMaker, and let language side know ,
on which platform id VM currently runs on (through additional
primitive)

P.S. And yes. The ' MethodNativeCodeTest new testAnswer42 '  runs
flawlessly , at least on my box :)
And I'm already having an tiny assember lying over there , which i can
use for generating the native stuff ..
It would be cool to adapt this stuff for generating an FFI/Alien
trampoline code.

-- 
Best regards,
Igor Stasenko AKA sig.

Attachment: NativeCodeTrailers.1.cs
Description: Binary data

Attachment: NativeCodeTests.2.cs
Description: Binary data

Attachment: Interpreter-primitiveNativeCall.st
Description: Binary data

_______________________________________________
Pharo-project mailing list
[email protected]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

Reply via email to