help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-smalltalk] Understanding the object layout.


From: Paolo Bonzini
Subject: Re: [Help-smalltalk] Understanding the object layout.
Date: Tue, 4 May 2010 08:04:47 +0200

> So if I understand correctly the main structures is
> object_s and oop_s.
>
> object_s contain size and class pointer plus the object ivs.
> oops_s contain flags for GC I guess plus the pointer to an object_s.

Correct.

> My first question is why 2 structure?

Because it allows to move the object data without rewriting all the
pointers in the OOPs.  The only case in which we have to scan the
whole OOPs is for one-way become.

> My second question is concerning the object_s struct why there will always be 
> at least one data?
>  OOP data[1];                  /* variable length, may not be objects,
>                                   but will always be at least this
>                                   big.  */

Actually not true.  It's a common C idiom to declare data[1] when
there could be zero items.

However, the comment is not false, it is simply poorly written.  It
means that even if you have bytes, shorts, or any kind of instance
variable other than pointers, the allocated size is always a multiple
of sizeof(OOP).

> In other word: what would contain data if the instance is from a class with 
> no ivs?

Only two words.

> Finally I am wondering why objSize has type OOP? Is it because it is a real 
> pointer to a SmallInteger?

Yes.  It slightly simplifies some code (I think it was the Cheney
breadth-first scan during newspace garbage collection -
http://en.wikipedia.org/wiki/Cheney's_algorithm).

Paolo




reply via email to

[Prev in Thread] Current Thread [Next in Thread]