[squeak-dev] The Inbox: Kernel-ul.664.mcz

Bert Freudenberg bert at freudenbergs.de
Mon Jan 9 10:22:25 UTC 2012

On 09.01.2012, at 01:47, commits at source.squeak.org wrote:

> A new version of Kernel was added to project The Inbox:
> http://source.squeak.org/inbox/Kernel-ul.664.mcz
> ==================== Summary ====================
> Name: Kernel-ul.664
> Author: ul
> Time: 9 January 2012, 2:46:30.214 am
> UUID: cc70b7c6-5bbd-4a4e-9bd1-4a22915a61de
> Ancestors: Kernel-bf.663
> Enhanced pointer tracing:
> - handle SmallIntegers correctly (they don't point to any object)
> - handle instances of compact classes correctly (they don't point to their class)
> - weak references are ignored, because they don't stop the garbage collector in collecting objects
> These changes modify the behavior of #pointsTo:, #outboundPointersDo: and #inboundPointersExcluding:.

The pointsTo: method used to be the fastest way to test for inclusion in performance-sensitive code. Maybe instead of changing its behavior, make a new method pointsStronglyTo:? I'd revert pointsTo: back to its original which goes straight to the primitive. PointerFinder and Co. could use the new, more exhaustive, but ultimately slower method. The proposed method is still 5x faster than unoptimized code, but the original was more than 10x faster. 

n := 10000000.
	'includes:' -> [1 to: n do: [:i | 
			#(up down left right) includes: #right]
	] timeToRun.
	'identityIncludes:' -> [1 to: n do: [:i | 
			#(up down left right) identityIncludes: #right]
	] timeToRun.
	'proposed pointsTo:' -> [1 to: n do: [:i | 
			#(up down left right) pointsStronglyTo: #right]
	] timeToRun.
	'current pointsTo:' -> [1 to: n do: [:i | 
			#(up down left right) pointsTo: #right]
	] timeToRun.
	'original pointsTo:' -> [1 to: n do: [:i | 
			#(up down left right) instVarsInclude: #right]
	] timeToRun.

==> {	'includes:'->1668 . 
	'identityIncludes:'->1925 .
	'proposed pointsTo:'->314 .
	'current pointsTo:'->178 .
	'original pointsTo:'->131 } 

- Bert -

For reference, this is primitive 132:

	| rcvr thang lastField |
	thang := self popStack.
	rcvr := self popStack.
	(self isIntegerObject: rcvr) ifTrue: [^self pushBool: false].

	lastField := self lastPointerOf: rcvr.
	self baseHeaderSize to: lastField by: self bytesPerWord do:
		[:i | (self longAt: rcvr + i) = thang
			ifTrue: [^ self pushBool: true]].
	self pushBool: false.

More information about the Squeak-dev mailing list