[Vm-dev] InterpreterProxy and big-endian simulation

David T. Lewis lewis at mail.msen.com
Wed Apr 6 00:04:48 UTC 2016


On Wed, Apr 06, 2016 at 12:19:32AM +0200, Nicolas Cellier wrote:
>  
> Hi,
> I now need to use byteSwapped32IfBigEndian: in LargeIntegersPlugin in order
> to support 32bits digit on hypothetical bigEndian machines.
> 
> This message will be replaced with a macro during C code generation, so
> it's only a problem for simulation.
> 
> My first idea was to delegate to interpreterProxy.
> Alas, the interpreterProxy is not associated to an objectMemory (or more
> exactly a simulator of objectMemory)
> 
> I'm not very satisfied with InterpreterProxy>>vmEndianness
> It will use the image endianness instead of the simulator endianness...
> With this, I would be able to simulate littleEndian (most VM/Images are),
> but I won't be able to simulate bigEndian...
> 
> Augmenting InterpreterProxy with proper knowledge of ObjectMemory simulator
> is above my skills...
> There are 18 class refs, and it does not seems like it has been designed
> for such support.

I do not have an easy answer, but I would say that the approach you describe
here seems right to me.

I say this because when I did the ObjectMemory/Interpreter refactoring in
VMM trunk (based on Eliot's initial organization in oscog), I first arranged
that an interpreter should know about its object memory (hence instance
var #objectMemory in class InterpreterPrimitives from which Interpreter
inherits).

Although it seemed logical that an object memory should not need to know
about its interpreter, in practice this did not work and I had to add
instance var #interpreter to class ObjectMemory. In a perfect world, an
object memory should not need to know this, but in practice there was
no way around it.

I think that the idea of an interpreter knowing the object memory that
it is interpreting makes sense conceptually. And beyond that, the link
from object memory back to interpreter is necessary to make various
things work, but conceptually it seems like a hack.

So it seems to me that if an interpreter should know its object memory,
then the InterpreterProxy should be able to know it also, and this could
be carried on into similation classes.

Dave


> 
> Alternatively, I could implement byteSwapped32IfBigEndian: in
> LargeIntegersPlugin.
> There even is a simulator inst. var. in smart plugins.
> Alas, this simulator inst. var. is filled with a SmartSyntaxPluginSimulator
> which also is completely unware of objectMemory...
> 
> Any idea how I could support big-endian simulation properly?



More information about the Vm-dev mailing list