[squeak-dev] The Trunk: Kernel-ul.1412.mcz

commits at source.squeak.org commits at source.squeak.org
Mon Sep 13 17:44:39 UTC 2021


Levente Uzonyi uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-ul.1412.mcz

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

Name: Kernel-ul.1412
Author: ul
Time: 13 September 2021, 7:42:57.781301 pm
UUID: 99321567-2351-48d2-9568-eb9d99079021
Ancestors: Kernel-eem.1410, Kernel-ul.1411

CompiledCode >> #hash :
- remove #species from the hash calculation because #= doesn't compare that either
- use #hashMultiply to mix in values with fewer collisions (increases the number of different hash values by about 1.5x in the image)
- actualized comments
- reset DebuggerMethodMap's MapCache, so that all collections relying on CompiledCode's #hash in a Trunk image are absent
- finally, rehash all hashed collections just to be sure no collections are left in an invalid state

Also merge with Kernel-ul.1411.

=============== Diff against Kernel-eem.1410 ===============

Item was changed:
  ----- Method: CompiledCode>>hash (in category 'comparing') -----
  hash
+ 	"CompiledCode>>#= compares code, i.e. same literals and same bytecode.
+ 	 So we look at the size, the header and some bytes between initialPC and endPC,
+ 	 but neither selector nor methodClass because the #= does not either..
+ 	 Note that we must override ByteArray>>#hash which looks at all bytes of the receiver.
+ 	 Using bytes from the pointer part of a CompiledCode can lead to a variable 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 size hashMultiply + self header) hashMultiply + initialPC) hashMultiply + endPC) hashMultiply.
- 	hash := self species hash + self header + initialPC + endPC bitAnd: 16rFFFFFFF.
  	"sample approximately 20 bytes"
  	initialPC to: endPC by: (endPC - initialPC // 20 max: 1) do:
+ 		[:i| hash := (hash + (self at: i)) hashMultiply].
- 		[:i| hash := hash + (self at: i)].
  	^hash
  
+ 	"(CompiledCode>>#hash) hash"!
- 	"(CompiledMethod>>#hash) hash"!

Item was added:
+ ----- Method: Fraction>>isPowerOfTwo (in category 'testing') -----
+ isPowerOfTwo
+ 	"Return true if the receiver is an integral power of two."
+ 
+ 	^numerator = 1 and: [ denominator isPowerOfTwo ]!

Item was removed:
- ----- Method: Integer>>isPowerOfTwo (in category 'testing') -----
- isPowerOfTwo
- 	"Return true if the receiver is an integral power of two."
- 	
- 	^self strictlyPositive and: [ (self bitAnd: self - 1) = 0 ]!

Item was added:
+ ----- Method: Number>>isPowerOfTwo (in category 'testing') -----
+ isPowerOfTwo
+ 	"Return true if the receiver is an integral power of two."
+ 
+ 	self subclassResponsibility!

Item was added:
+ ----- Method: ScaledDecimal>>isPowerOfTwo (in category 'testing') -----
+ isPowerOfTwo
+ 	"Return true if the receiver is an integral power of two."
+ 
+ 	^fraction isPowerOfTwo!

Item was added:
+ ----- Method: SmallInteger>>isPowerOfTwo2 (in category 'testing') -----
+ isPowerOfTwo2
+ 	"Return true if the receiver is an integral power of two. Optimized version."
+ 	
+ 	^self strictlyPositive and: [ (self bitAnd: self - 1) = 0 ]!

Item was added:
+ ----- Method: SmallInteger>>isPowerOfTwo3 (in category 'testing') -----
+ isPowerOfTwo3
+ 	"Return true if the receiver is an integral power of two. Optimized version."
+ 	
+ 	self > 0 ifFalse: [ ^false ].
+ 	(self bitAnd: self - 1) = 0 ifFalse: [ ^false ].
+ 	^true!

Item was changed:
+ (PackageInfo named: 'Kernel') postscript: 'DebuggerMethodMap voidMapCache.
+ Smalltalk garbageCollect.
+ HashedCollection rehashAll'!
- (PackageInfo named: 'Kernel') postscript: 'EventSensor initialize..
- EventSensor startUp..'!



More information about the Squeak-dev mailing list