[squeak-dev] The Trunk: Kernel-tfel.1001.mcz

commits at source.squeak.org commits at source.squeak.org
Fri Feb 19 11:51:04 UTC 2016


Tim Felgentreff uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-tfel.1001.mcz

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

Name: Kernel-tfel.1001
Author: tfel
Time: 19 February 2016, 12:50:25.522776 pm
UUID: 26062a02-5ef1-43e2-b6d1-228cedef5a72
Ancestors: Kernel-eem.1000

Fix fallback code in Large(Positive|Negative)Integer>>normalize. The code incorrectly assumed that if you max/min integer is larger than -2**30 / 2**30-1 then you are on 64bit. Some VMs do not do Integer tagging, and for those the check should be as on the machine level (-2**31 / 2**31-1)

=============== Diff against Kernel-eem.1000 ===============

Item was changed:
  ----- Method: LargeNegativeInteger>>normalize (in category 'converting') -----
  normalize
  	"Check for leading zeroes and return shortened copy if so"
  	| sLen val len oldLen minVal |
  	<primitive: 'primNormalizeNegative' module: 'LargeIntegers'>
  	"First establish len = significant length"
  	len := oldLen := self digitLength.
  	[len = 0 ifTrue: [^0].
  	(self digitAt: len) = 0]
  		whileTrue: [len := len - 1].
  
  	"Now check if in SmallInteger range.
  	 Fast compute SmallInteger minVal digitLength"
+ 	sLen := SmallInteger minVal < -16r80000000 "we're definitely on 64bit if we are smaller than (-2 raisedTo: 31)"
- 	sLen := SmallInteger minVal < -16r40000000
  				ifTrue: [8]
  				ifFalse: [4].
  	len <= sLen ifTrue:
  		[minVal := SmallInteger minVal.
  		(len < sLen
  		 or: [(self digitAt: sLen) < minVal lastDigit])
  			ifTrue: ["If high digit less, then can be small"
  					val := 0.
  					len to: 1 by: -1 do:
  						[:i | val := (val *256) - (self digitAt: i)].
  					^ val].
  		1 to: sLen do:  "If all digits same, then = minVal"
  			[:i | (self digitAt: i) = (minVal digitAt: i)
  					ifFalse: ["Not so; return self shortened"
  							len < oldLen
  								ifTrue: [^ self growto: len]
  								ifFalse: [^ self]]].
  		^ minVal].
  
  	"Return self, or a shortened copy"
  	len < oldLen
  		ifTrue: [^ self growto: len]
  		ifFalse: [^ self]!

Item was changed:
  ----- Method: LargePositiveInteger>>normalize (in category 'converting') -----
  normalize
  	"Check for leading zeroes and return shortened copy if so"
  	| sLen val len oldLen |
  	<primitive: 'primNormalizePositive' module:'LargeIntegers'>
  	"First establish len = significant length"
  	len := oldLen := self digitLength.
  	[len = 0 ifTrue: [^0].
  	(self digitAt: len) = 0]
  		whileTrue: [len := len - 1].
  
  	"Now check if in SmallInteger range.  Fast compute SmallInteger maxVal digitLength"
+ 	sLen := SmallInteger maxVal > 16r7FFFFFFF "we're definitely on 64bit if we are larger than (2 raisedTo: 31) - 1"
- 	sLen := SmallInteger maxVal > 16r3FFFFFFF
  				ifTrue: [8]
  				ifFalse: [4].
  	(len <= sLen
  	 and: [(self digitAt: sLen) <= (SmallInteger maxVal digitAt: sLen)])
  		ifTrue: ["If so, return its SmallInt value"
  				val := 0.
  				len to: 1 by: -1 do:
  					[:i | val := (val *256) + (self digitAt: i)].
  				^ val].
  
  	"Return self, or a shortened copy"
  	len < oldLen
  		ifTrue: [^ self growto: len]
  		ifFalse: [^ self]!



More information about the Squeak-dev mailing list