[Pkg] The Trunk: Kernel-eem.692.mcz

commits at source.squeak.org commits at source.squeak.org
Sun May 27 22:10:03 UTC 2012

Eliot Miranda uploaded a new version of Kernel to project The Trunk:

==================== Summary ====================

Name: Kernel-eem.692
Author: eem
Time: 27 May 2012, 3:08:41.389 pm
UUID: 72f75218-3cfc-4575-b159-8de0e44aa479
Ancestors: Kernel-nice.691

Implement CompiledMethod>>#hash, both to accord with
CompiledMethod>>#= and to override ByteArray>>#hash
which looks at all bytes of the receiver and hence may
produce a variable hash if the GC moves literals in a method.

=============== Diff against Kernel-nice.691 ===============

Item was added:
+ ----- Method: CompiledMethod>>hash (in category 'comparing') -----
+ hash
+ 	"CompiledMethod>>#= compares code, i.e. same literals and same bytecode.
+ 	 So we look at the header, methodClass and some bytes between initialPC and endPC,
+ 	 but /not/ the selector because the equal method does not compare selectors.
+ 	 Note that we must override ByteArray>hash which looks at all bytes of the receiver.
+ 	 Using bytes from the pointer part of a COmpiledmethod can lead to a variable hash
+ 	 if and when when the GC moves literals in the receiver."
+ 	| initialPC endPC hash |
+ 	initialPC := self initialPC.
+ 	endPC := self endPC.
+ 	hash := self species hash + self header + initialPC + endPC + self methodClass hash bitAnd: 16rFFFFFFF.
+ 	"sample approximately 20 bytes"
+ 	initialPC to: endPC by: (endPC - initialPC // 20 max: 1) do:
+ 		[:i| hash := hash + (self at: i)].
+ 	^hash
+ 	"(CompiledMethod>>#hash) hash"!

More information about the Packages mailing list