Where does WeakMessageSend get new: from?

Ned Konz ned at squeakland.org
Mon Feb 16 20:44:54 UTC 2004


On Monday 16 February 2004 11:32 am, Brian Brown wrote:

> When looking at WeakMessageSend>>new, it calls self new: 1 and responds
> to at:put: but new: isn't in it's protocol.
>
> Then I saw that the class definition is:
> Object weakSubClass: #WeakMessageSend
>
> um, what is that? A primitive? How could I investigate this?

There are several kinds of objects in the system.

Generally, an object can have:

* 0 or more named instance variables containing (non-weak) object references

followed by:

* 0 or more numbered slots, all containing the same sort of thing. You use 
#new: to get the number of slots that you want, and use #at: and #at:put: to 
access the slots.

The choices for the contents of slots are:

	- object references (isVariable & isPointers & isWeak not)
	- weak object references (isVariable & isWeak & isPointers)
	- bytes (isBytes & isVariable)
	- words (32-bit non-object-reference values) (isVariable & isWords & 
isPointers not)

The corresponding creation methods in Class are:

subclass:instanceVariableNames:classVariableNames:poolDictionaries:category:
(just named object references) (most of the classes in the system are of this 
sort)

variableByteSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category:
(named object references followed by numbered bytes)

variableSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category:
(named object references followed by numbered non-weak object references)

variableWordSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category:
(named object references followed by numbered words)

weakSubclass:instanceVariableNames:classVariableNames:poolDictionaries:category:
(named object references followed by numbered weak object references)

We can count them:

counts _ Bag new.
types _ IdentityDictionary new.
Behavior allSubInstances do: [ :cls | | type |
	type _ 0.
	cls isPointers ifTrue: [type _ type + 1]. "isPointers implies isWords"
	cls isBytes ifTrue: [type _ type + 2]. "classes will answer true to either 
isBytes or isWords"
	cls isWeak ifTrue: [type _ type + 4].
	cls isVariable ifTrue: [type _ type + 8].
	cls isMeta ifTrue: [type _ type + 16].
	counts add: type.
	(types at: type ifAbsentPut: [ Set new ]) add: cls name].

counts sortedCounts
	=> a SortedCollection(1704->17 1650->1 16->8 11->9 9->10 5->13)

That is:

1704 metaclasses (just named instance variables)

1650 regular classes (just named object references)

16 variable word classes
(#ColorArray #ShortPointArray #MCMockClassG #IntegerArray #Float #FloatArray 
#SoundBuffer #KlattFrame #ShortRunArray #PointArray #BalloonBuffer 
#MatrixTransform2x3 #ShortIntegerArray #WordArray #WordArrayForSegment 
#Bitmap)

11 variable pointer classes
(#WeakActionSequenceTrappingErrors #ActionSequence #PseudoContext 
#TranslatedMethod #GraphicSymbol #MCMockClassE #MethodContext 
#MethodDictionary #BlockContext #Array #WeakActionSequence)

9 variable byte classes
(#ByteArray #Symbol #String #LargeNegativeInteger #LargePositiveInteger 
#CompiledMethod #ExternalAddress #UUID #MCMockClassH)

5 variable weak pointer classes
(#WeakArray #DependentsArray #WeakValueAssociation #WeakMessageSend 
#MCMockClassI)

-- 
Ned Konz
http://bike-nomad.com/squeak/



More information about the Squeak-dev mailing list