[Vm-beginners] Re: Why Are Only Some Sources Generated

David T. Lewis lewis at mail.msen.com
Thu Mar 26 17:52:31 UTC 2015


I had intended to reply the list on this, apparently I did not "reply all":

> On Wed, Mar 25, 2015 at 03:06:39PM -0700, Sean P. DeNigris wrote:
> Bert Freudenberg wrote
> > Only the actual interpreter/jit core, and some cross-platform plugins are
> > generated from Slang. The platform-dependent "glue code" has always been
> > coded in C.
>
> Why? Could some or all of the platform code be written in Slang?
>

To some extent, this is a matter of what is most convenient and comfortable
for the person who is writing the platform code. If you are dealing with
data structures, or with system calls and complex arguments that need to be
properly declared, then it may be easier to write this in a language such
as C.

On the other hand, I would point to the FilePlugin (which is a critical VM
component) as an example of platform support code written in C that could
just as easily have been written in Smalltalk (slang).

To some extent, it is just a judgement call. If you were writing the glue
code for FilePlugin and you wanted it to be readable in the image, then
you might prefer to write in Smalltalk (slang). If you were really more
interested in writing code that is readable for a person familiar with
the operating system functions, then you might prefer to write the glue
code in C.

As another example, the very lowest level of glue code in the VM would
be the functions that map object addresses (oop values for the object
memory) to actual memory addresses in the platform address space. These
are very performance critical, and they are usually implemented as a set
of C macros in the platform glue code (look for sqMemoryAccess.h in the
platform code). But it turns out that they can be implemented equally
well in Smalltalk (see package MemoryAccess in the VMMaker repository).
The Smalltalk slang implementations perform just as well as the C macros,
because the slang code inliner is extremely effective. They also can
be browsed and debugged in Smalltalk, which might be an advantage if
the C preprocessor is something that makes your head spin.

I think that it really is a matter of preference. Do you prefer to read
and write the glue code in Smalltalk, or do you prefer to use a language
that more closely matches the runtime platform that you are trying to
support? There are good arguments either way.

Dave




More information about the VM-beginners mailing list