[Vm-dev] Adding object to foo->scpecialObject
Mathieu Suen
mathk.sue at gmail.com
Thu Jul 26 10:19:28 UTC 2007
Could/should we push this method in 3.10?
Mth
On Jul 26, 2007, at 12:10 PM, <bryce at kampjes.demon.co.uk> wrote:
> Behavior>>becomeCompactAt: anInteger
> "Here are the restrictions on compact classes in order for export
> segments to work: A compact class index may not be reused. If a
> class was compact in a release of Squeak, no other class may use
> that index. The class might not be compact later, and there should
> be nil in its place in the array."
> | cct index |
>
> self isWeak ifTrue:[^ self halt: 'You must not make a weak class
> compact'].
> cct := self environment compactClassesArray.
> (self indexIfCompact > 0 or: [cct includes: self])
> ifTrue: [^ self halt: self name , 'is already compact'].
> index := anInteger.
> (cct at: index) isNil ifFalse: [self halt: 'The compact class
> index is already used'].
> "Install this class in the compact class table"
> cct at: index put: self.
> "Update instspec so future instances will be compact"
> format := format + (index bitShift: 11).
> "Make up new instances and become old ones into them"
> self updateInstancesFrom: self.
> "Purge any old instances"
> Smalltalk garbageCollect.
More information about the Vm-dev
mailing list