[squeak-dev] What is an instSpec?

Vanessa Freudenberg vanessa at codefrau.net
Tue Aug 11 22:03:39 UTC 2020


On Tue, Aug 11, 2020 at 2:26 PM David T. Lewis <lewis at mail.msen.com> wrote:

> One of the interesting aspects of Squeak is how a Class in the image is
> used to make new object instances in the Squeak VM object memory.
>
> I collected some of my recent notes on this topic and put them on the
> swiki at http://wiki.squeak.org/squeak/6646
>
> Dave
>

You are right that some values in the instSpec are unused. However, the
instSpec is only used to initialize each object's format bits. Some of the
bits are used to store the size of values that are smaller than a full 32
bit word. The size in the object header always refers to full words, so the
actual size in e.g. bytes is sizeInWords * 4 - sizeFromFormatBits.

So you can't use format code 9 to mean "indexable short (16-bit) field"
because codes 8-11 are already used for 8-bit fields of differing sizes
between whole words. Format 8 means all 4 bytes of the last word are used,
format 9 means only 3 bytes of the last word are actually used, format 10
means 2 bytes are used, and format 11 means only one byte is used. (Or the
other way around, I forgot)

To add 16 bit fields you need 2 unused format codes, one fore even and one
for odd length.

For 64 bit fields you would only need a single code.

Unless you find another unused bit in the object header we don't have
enough bits to represent both 16 and 64 bit arrays. One way may be to not
ever allow odd 16 bit arrays I guess?

- Vanessa -
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20200811/8691ff3d/attachment.html>


More information about the Squeak-dev mailing list