VM – Extended Object Descriptor

I mentioned the possibility to embed expressions into If, Call, Raise, While etc to avoid having a Plain Assembly that split into several instructions. This is a 1st draft where I truncate the Data-Type flag in the Object Descriptor and use the MSB to flag an Extended Object Descriptor.

The Extension here contain a Tag indicating that this is a math table and number of entries to follow. The math entry is 10 bytes “as is”, so I will look into ways of truncating the Object Descriptor. One idea is to drop Size and truncate Type to 4 bits. Size is actually known since all build-in types have a fixed size and I can add another Tag entry to specify non-standard extensions. I am even considering truncating Data Offset to 10 bits (1K) and have a Tag extension to address larger offsets. 1K is actually quite a lot of data for an embedded design, so a majority of instructions would work perfectly with the truncated descriptor. This would reduce the Object Descriptor from 4 to 2 bytes and math entry from 10 to 6.

The Tag also allow me to add things like table indexing and actually address data larger than 64Kb if we need to.

Truncated 16 bit Object Descriptor:

  • 1 Extension bit flag.
  • 4 Type bits. This leaves us 16 build- in data types (Bit, Byte, int16,uint16,int32,uint32,real32,real64,string, number) + 6 spare codes.
  • 1 Stack/Data bit so we can differ between stack and data offset,
  • 10 Data Offset bits to address 1Kb

The price I pay for this is extra coding in the VM (larger footprint) + we are digging into binary decoding of structures that will reduce performance a little bit. I like the idea, so lets see if it stick or if we can come up with a better one.

Leave a Reply