[squeak-dev] Re: A small idea how to get closer to hardware with small efforts :)

Igor Stasenko siguctua at gmail.com
Mon Apr 5 12:13:51 UTC 2010


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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: NativeCodeTrailers.1.cs
Type: application/octet-stream
Size: 6527 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20100405/41616e48/NativeCodeTrailers.1.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: NativeCodeTests.2.cs
Type: application/octet-stream
Size: 1092 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20100405/41616e48/NativeCodeTests.2.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Interpreter-primitiveNativeCall.st
Type: application/octet-stream
Size: 1319 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20100405/41616e48/Interpreter-primitiveNativeCall.obj


More information about the Squeak-dev mailing list