What is an instSpec?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

What is an instSpec?

David T. Lewis
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

Reply | Threaded
Open this post in threaded view
|

Re: What is an instSpec?

codefrau
On Tue, Aug 11, 2020 at 2:26 PM David T. Lewis <[hidden email]> 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 -
 


Reply | Threaded
Open this post in threaded view
|

Re: What is an instSpec?

David T. Lewis
On Tue, Aug 11, 2020 at 03:03:39PM -0700, Vanessa Freudenberg wrote:

> On Tue, Aug 11, 2020 at 2:26 PM David T. Lewis <[hidden email]> 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,

Thank you for the careful review and for the correction. I added a short note
on the swiki page, and I'll clean it up properly soon-ish.

Much appreciated,

Dave