Marcus Denker wrote:
Hi Travis!
Yes, you are right: the current version does not have primitives. The primitives are "normal" Smaltalk-To-C statically compiled methods (with inlined C-code).
But: The problem is that the image is not portable across architectures anymore. You can even run into problemes simply by re-compiling the VM using a different compiler. (There are pointers in the saved image to code generated by the C-compiler, these won't be the same on an other architecture) There are some hacks to prevent running such an image, and it tries hard to fix the refences, but according to Claus this never really worked in all cases. So he decided that the new VM (I think for version 5?) will have "real" primitives. (As an execution-mechanism, it will look the same for the programmer. You won't see <primitive 224> but the code of the primitive...) He talked a little bit about the new vm some time ago, the following is what I understood from his description (My understanding might not be entirely correct...):
The "primitive" methods are like "normal", not-yet-jitted Smalltalk methods (*codeptr is nil), but they have the "primitive" bit set. If such a method is called the first time, the vm looks up the right adress for the primitive and sets the *codeptr.
If the codeptr is nil and we have a non-primitive method, the jitter is called to produce native code. The code is held in a cache outside the image, and the adress of the code is stored in the codeptr.
If we compile a Method with the Smtlk-To-C Compiler, stc produces a C-source-file, gcc compiles this to an dll (.so), it's loaded at runtime (dlopen()), and the *codeptr is updated to point to the right function.
If the codeptr is not-nil, run the code at that adress.
In a way, I think that's too bad. I'm trying to remember the last time in 10 years I actually took advantage of xplatform image portability. I can remember two cases. I've done it many more times than that, but usually just for a "isn't that cool" grin. I've got two platforms (Squeak and VW) that have xplatform binary portability. If Claus does this I'll have three, but (IMO) the _best_ Smalltalk for looking at image/VM interaction/coupling will no longer be. Sad.