Organizing VM sources, CCodeGenerator: suggestions and questions

Raab, Andreas Andreas.Raab at disney.com
Thu Dec 23 21:29:35 UTC 1999


Stephan,

> isBytes: oop
> 	^ (interpreterProxy isIntegerObject: oop) not and:
> [interpreterProxy
> isBytes: oop]
>
> has led to
>
> int isBytes(int oop) {
>         return (!((oop & 1))) && (interpreterProxy->isBytes(oop));
> }
>
> . Compiling works only without inlining, otherwise it runs into an
> infinite recursion.

That's a bug in the code generator, but trivial to fix. Just change your
method into

isBytes: oop
	self inline: false.
	^(interpreterProxy isIntegerObject: oop) not and:
		[interpreterProxy isBytes: oop]

The code generator doesn't take the receiver into account which is somewhat
ugly and should be fixed but I don't know a simple way of fixing this.

> The plugin runs in simulation, but in calling this function
> in C crashes the VM.
>
> The problem here is that this function interferes with the same
> signatured function from 'sqVirtualMachine.c'.

sqVirtualMachine.c must *never* be compiled with the plugin itself. It
merely defines the interpreter interface and is compiled with the VM not
with the plugin! All you need in the plugin is the definition of the
interface (e.g., from sqVirtualMachine.h) since you don't know beforehand
with what version of the interpreter you're running.

> This leads me to the following suggestions:
>
> - A compiler warning would be nice, if someone overrides a predefined
> function.

See above - this shouldn't be necessary if in a plugin.

> - Wouldn't it be good to make all user plugin functions which are not
> exported 'static' as default?

Yes and no ... sometimes it's very convenient if one has outside access to
these functions and so far I haven't found a case where this causes any
problems.

> - Wouldn't it be better to make 'int isBytes(int oop);' and similar
> functions in 'sqVirtualMachine.c' static? For plugins they are called
> indirectly by 'interpreterProxy->isBytes(oop)' anyway.

sqVirtualMachine.c does *not* define these functions. Again,
sqVirtualMachine.c is just for the VM - not for the plugin.

> Couldn't there arise any compatibility problems between different
> plugins in the current situation?

Not that I know of.

> Greetings, Merry Christmas,

Und ebenfalls schoene Weihnachten und ein frohes neues J2K (oder wie heisst
das in Deutsch?!)

  Andreas





More information about the Squeak-dev mailing list