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: Mathieu Suen
Subject: Re: [Help-smalltalk] Understanding the object layout.
Date: Tue, 4 May 2010 19:52:43 +0200

On May 4, 2010, at 8:04 AM, Paolo Bonzini wrote:

>> 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.

Ok so I guess the GC compactor is faster. But it imply also that the 
oop_s structure should not be compact only the object_s is compact.

Are the oop_s and object_s structure in the same heap space?

> 
>> 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).

Ok the C confuse me, but it is true that you never allocate an object by hand 
so the 1 doesn't mean anything. :)

Does you keep null terminal string?

As far as I remember you have a way in the object syntax declaration (using 
pragma) to declare the underlining object structure.


> 
>> 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).

Ok thanks for you help.
I will try to understand how the GC is implemented.
And also it could be interesting to discuss on the way to implement the 
copy-on-write feature.
I guess is might have some impact on the object layout.

> 
> Paolo






___________________________________________________________________________
Yahoo! Mail réinvente le mail ! Découvrez le nouveau Yahoo! Mail et son 
interface révolutionnaire.
http://fr.mail.yahoo.com




reply via email to

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