Andreas Raab uploaded a new version of KernelTests to project The Trunk:
http://source.squeak.org/trunk/KernelTests-ar.113.mcz
==================== Summary ====================
Name: KernelTests-ar.113
Author: ar
Time: 30 November 2009, 10:10 am
UUID: bae112c0-a146-104a-b56f-eaa16910b2e6
Ancestors: KernelTests-nice.112
Add tests for compact class index of LPI and LNI.
=============== Diff against KernelTests-nice.112 ===============
Item was added:
+ ----- Method: LargeNegativeIntegerTest>>testCompactClassIndex (in category 'tests') -----
+ testCompactClassIndex
+ self assert: LargeNegativeInteger indexIfCompact = 4.
+ !
Item was added:
+ ----- Method: LargePositiveIntegerTest>>testCompactClassIndex (in category 'tests') -----
+ testCompactClassIndex
+ self assert: LargePositiveInteger indexIfCompact = 5.!
Andreas Raab uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-ar.315.mcz
==================== Summary ====================
Name: Kernel-ar.315
Author: ar
Time: 30 November 2009, 10:08:08 am
UUID: b39007e6-1381-184d-a2c8-58052fd71231
Ancestors: Kernel-ul.314
Future proofing: For speed and simplicity, Cog requires LargeNegativeInteger to be compact at 4 (replacing PseudoContext). Integer>>initialize now takes care of that and documents (via LPITest and LNITest) the compact class requirements of LPI and LNI.
There is no actual impact except that LNIs will shave off a header word which in typical images makes no difference whatsover (LargeNegativeInteger instanceCount < 100 in a typical trunk image).
=============== Diff against Kernel-ul.314 ===============
Item was added:
+ ----- Method: Integer class>>initialize (in category 'class initialization') -----
+ initialize "Integer initialize"
+ "Ensure we have the right compact class index"
+
+ "LPI has been a compact class forever - just ensure basic correctness"
+ (LargePositiveInteger indexIfCompact = 5) ifFalse:[
+ (Smalltalk compactClassesArray at: 5)
+ ifNil:[LargePositiveInteger becomeCompactSimplyAt: 5]
+ ifNotNil:[self error: 'Unexpected compact class setup']].
+
+ "Cog requires LNI to be compact at 4 (replacing PseudoContext)"
+ (LargeNegativeInteger indexIfCompact = 4) ifFalse:[
+ "PseudoContext will likely get removed at some point so write this test
+ without introducing a hard dependency"
+ (Smalltalk compactClassesArray at: 4) name == #PseudoContext
+ ifTrue:[Smalltalk compactClassesArray at: 4 put: nil].
+ (Smalltalk compactClassesArray at: 4)
+ ifNil:[LargeNegativeInteger becomeCompactSimplyAt: 4]
+ ifNotNil:[self error: 'Unexpected compact class setup']].
+ !
Andreas Raab uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-ul.236.mcz
==================== Summary ====================
Name: Collections-ul.236
Author: ul
Time: 1 December 2009, 4:54:17 am
UUID: 7574c4aa-b907-1f4e-ba28-661aa9c084ae
Ancestors: Collections-ul.235
- revert #do: #associationsDo: and the senders of #scanForEmptySlotFor:
- removed preamble
- add grow tweak to WeakSet
- rehash everything at postscript
=============== Diff against Collections-ul.235 ===============
Item was changed:
----- Method: KeyedSet>>noCheckNoGrowFillFrom: (in category 'private') -----
noCheckNoGrowFillFrom: anArray
"Add the elements of anArray except nils to me assuming that I don't contain any of them, they are unique and I have more free space than they require."
1 to: anArray size do: [ :index |
| object |
(object := anArray at: index) ifNotNil: [
array
+ at: (self scanForEmptySlotFor: (keyBlock value: object))
- at: (self scanFor: (keyBlock value: object))
put: object ] ]!
Item was changed:
----- Method: WeakSet>>noCheckNoGrowFillFrom: (in category 'private') -----
noCheckNoGrowFillFrom: anArray
"Add the elements of anArray except nils and flag to me assuming that I don't contain any of them, they are unique and I have more free space than they require."
tally := 0.
1 to: anArray size do: [ :index |
| object |
((object := anArray at: index) == flag or: [
object == nil ]) ifFalse: [
array
+ at: (self scanForEmptySlotFor: object)
- at: (self scanFor: object)
put: object.
tally := tally + 1 ] ]!
Item was changed:
----- Method: Set>>noCheckNoGrowFillFrom: (in category 'private') -----
noCheckNoGrowFillFrom: anArray
"Add the elements of anArray except nils to me assuming that I don't contain any of them, they are unique and I have more free space than they require."
1 to: anArray size do: [ :index |
| object |
(object := anArray at: index) ifNotNil: [
array
+ at: (self scanForEmptySlotFor: object)
- at: (self scanFor: object)
put: object ] ]!
Item was added:
+ ----- Method: WeakSet>>grow (in category 'private') -----
+ grow
+ "Grow the elements array if needed.
+ Since WeakSets just nil their slots, a lot of the occupied (in the eyes of the set) slots are usually empty. Doubling size if unneeded can lead to BAD performance, therefore we see if reassigning the <live> elements to a Set of similiar size leads to a sufficiently (50% used here) empty set first"
+
+ | oldTally |
+ oldTally := tally.
+ self rehash.
+ oldTally // 2 < tally ifTrue: [ super grow ]!
Item was changed:
----- Method: Dictionary>>noCheckNoGrowFillFrom: (in category 'private') -----
noCheckNoGrowFillFrom: anArray
"Add the elements of anArray except nils to me assuming that I don't contain any of them, they are unique and I have more free space than they require."
1 to: anArray size do: [ :index |
| object |
(object := anArray at: index) ifNotNil: [
array
+ at: (self scanForEmptySlotFor: object key)
- at: (self scanFor: object key)
put: object ] ]!
Item was changed:
----- Method: WeakKeyDictionary>>noCheckNoGrowFillFrom: (in category 'private') -----
noCheckNoGrowFillFrom: anArray
"Add the elements of anArray except nils and flag to me assuming that I don't contain any of them, they are unique and I have more free space than they require."
tally := 0.
1 to: anArray size do:[ :i |
| association |
(association := anArray at: i) ifNotNil: [
array
+ at: (self scanForEmptySlotFor: association key)
- at: (self scanFor: association key)
put: association.
tally := tally + 1 ] ]!
Item was changed:
----- Method: WeakSet>>do: (in category 'public') -----
do: aBlock
+ tally = 0 ifTrue: [ ^self ].
+ 1 to: array size do: [ :index |
+ | each |
+ ((each := array at: index) == nil or: [ each == flag ])
- tally = 0 ifTrue: [^self].
- array do: [ :each |
- (each == nil or: [each == flag])
ifFalse: [ aBlock value: each ] ]!
Item was changed:
----- Method: WeakKeyDictionary>>finalizeValues: (in category 'finalization') -----
finalizeValues: finiObjects
"Remove all associations with key == nil and value is in finiObjects.
This method is folded with #rehash for efficiency."
| oldArray |
oldArray := array.
array := Array new: oldArray size.
tally := 0.
1 to: array size do:[ :i |
| association |
(association := oldArray at: i) ifNotNil: [
| key |
((key := association key) == nil and: [ "Don't let the key go away"
finiObjects includes: association value ])
ifFalse: [
array
+ at: (self scanForEmptySlotFor: key)
- at: (self scanFor: key)
put: association.
tally := tally + 1 ] ] ]!
Item was changed:
Item was changed:
----- Method: WeakKeyToCollectionDictionary>>noCheckNoGrowFillFrom: (in category 'as yet unclassified') -----
noCheckNoGrowFillFrom: anArray
"Add the elements of anArray except nils and associations with empty collections (or with only nils) to me assuming that I don't contain any of them, they are unique and I have more free space than they require."
tally := 0.
1 to: anArray size do:[ :i |
| association cleanedValue |
((association := anArray at: i) == nil or: [
(cleanedValue := association value copyWithout: nil) isEmpty ])
ifFalse: [
association value: cleanedValue.
array
+ at: (self scanForEmptySlotFor: association key)
- at: (self scanFor: association key)
put: association.
tally := tally + 1 ] ]!
Item was changed:
Item was changed:
----- Method: Dictionary>>associationsDo: (in category 'enumerating') -----
associationsDo: aBlock
"Evaluate aBlock for each of the receiver's elements (key/value
associations)."
tally = 0 ifTrue: [ ^self].
+ 1 to: array size do: [ :index |
+ | each |
+ (each := array at: index)
+ ifNotNil: [ aBlock value: each ] ]!
- array do: [ :each | each ifNotNil: [ aBlock value: each ] ]!
Item was changed:
----- Method: WeakSet>>growTo: (in category 'private') -----
growTo: anInteger
"Grow the elements array and reinsert the old elements"
| oldElements |
-
oldElements := array.
array := WeakArray new: anInteger.
array atAllPut: flag.
self noCheckNoGrowFillFrom: oldElements!
Item was changed:
----- Method: Set>>do: (in category 'enumerating') -----
do: aBlock
tally = 0 ifTrue: [ ^self ].
+ 1 to: array size do: [ :index |
+ | each |
+ (each := array at: index)
+ ifNotNil: [ aBlock value: each ] ]!
- array do: [ :each | each ifNotNil: [ aBlock value: each ] ]!
Andreas Raab uploaded a new version of System to project The Trunk:
http://source.squeak.org/trunk/System-ar.188.mcz
==================== Summary ====================
Name: System-ar.188
Author: ar
Time: 30 November 2009, 9:10:54 am
UUID: f1bfb76a-e8f7-d34c-9aae-3348656d871b
Ancestors: System-ar.187, System-ul.187
Merging System-ul.187:
Remove preamble.
=============== Diff against System-ar.187 ===============
Item was changed:
Andreas Raab uploaded a new version of System to project The Trunk:
http://source.squeak.org/trunk/System-ar.187.mcz
==================== Summary ====================
Name: System-ar.187
Author: ar
Time: 30 November 2009, 9:08:46 am
UUID: d896e46c-2d98-224d-b891-6900997ff309
Ancestors: System-ar.186, System-ul.186
Merging System-ul.186:
Part 2 of SystemDictionary hash change.
=============== Diff against System-ar.186 ===============
Item was changed:
Item was changed:
----- Method: SystemDictionary>>scanFor: (in category 'private') -----
scanFor: anObject
"Scan the key array for the first slot containing either a nil (indicating an empty slot) or an element that matches anObject. Answer the index of that slot or raise an error if no slot is found. This method will be overridden in various subclasses that have different interpretations for matching elements."
| index start |
- CollectionRehashingUtility quickRehashBecause: #systemDictionaryScanForChanged.
index := start := anObject hash \\ array size + 1.
[
| element |
((element := array at: index) == nil or: [ element key == anObject ])
ifTrue: [ ^index ].
(index := index \\ array size + 1) = start ] whileFalse.
self errorNoFreeSpace!
Andreas Raab uploaded a new version of System to project The Trunk:
http://source.squeak.org/trunk/System-ar.186.mcz
==================== Summary ====================
Name: System-ar.186
Author: ar
Time: 30 November 2009, 9:06:25 am
UUID: 64524af6-b3c1-7c40-a1dc-2d31cf44f3e2
Ancestors: System-dtl.185, System-ul.185
Merging System-ul.185:
Part 1 of SystemDictionary hash change (use #hash instead of #identityHash)
=============== Diff against System-dtl.185 ===============
Item was added:
+ ----- Method: SystemDictionary>>scanForEmptySlotFor: (in category 'private') -----
+ scanForEmptySlotFor: anObject
+ "Scan the key array for the first slot containing an empty slot (indicated by a nil). Answer the index of that slot. This method will be overridden in various subclasses that have different interpretations for matching elements."
+
+ | index start |
+ index := start := anObject hash \\ array size + 1.
+ [
+ (array at: index) ifNil: [ ^index ].
+ (index := index \\ array size + 1) = start ] whileFalse.
+ self errorNoFreeSpace!
Item was added:
+ ----- Method: SystemDictionary>>scanFor: (in category 'private') -----
+ scanFor: anObject
+ "Scan the key array for the first slot containing either a nil (indicating an empty slot) or an element that matches anObject. Answer the index of that slot or raise an error if no slot is found. This method will be overridden in various subclasses that have different interpretations for matching elements."
+
+ | index start |
+ CollectionRehashingUtility quickRehashBecause: #systemDictionaryScanForChanged.
+ index := start := anObject hash \\ array size + 1.
+ [
+ | element |
+ ((element := array at: index) == nil or: [ element key == anObject ])
+ ifTrue: [ ^index ].
+ (index := index \\ array size + 1) = start ] whileFalse.
+ self errorNoFreeSpace!
Andreas Raab uploaded a new version of System to project The Trunk:
http://source.squeak.org/trunk/System-ul.185.mcz
==================== Summary ====================
Name: System-ul.185
Author: ul
Time: 30 November 2009, 5:16:10 am
UUID: 9fe63fab-5342-9240-aa04-748fb8c843de
Ancestors: System-dtl.184
Part 1 of SystemDictionary hash change (use #hash instead of #identityHash)
=============== Diff against System-dtl.184 ===============
Item was added:
+ ----- Method: SystemDictionary>>scanForEmptySlotFor: (in category 'private') -----
+ scanForEmptySlotFor: anObject
+ "Scan the key array for the first slot containing an empty slot (indicated by a nil). Answer the index of that slot. This method will be overridden in various subclasses that have different interpretations for matching elements."
+
+ | index start |
+ index := start := anObject hash \\ array size + 1.
+ [
+ (array at: index) ifNil: [ ^index ].
+ (index := index \\ array size + 1) = start ] whileFalse.
+ self errorNoFreeSpace!
Item was added:
+ ----- Method: SystemDictionary>>scanFor: (in category 'private') -----
+ scanFor: anObject
+ "Scan the key array for the first slot containing either a nil (indicating an empty slot) or an element that matches anObject. Answer the index of that slot or raise an error if no slot is found. This method will be overridden in various subclasses that have different interpretations for matching elements."
+
+ | index start |
+ CollectionRehashingUtility quickRehashBecause: #systemDictionaryScanForChanged.
+ index := start := anObject hash \\ array size + 1.
+ [
+ | element |
+ ((element := array at: index) == nil or: [ element key == anObject ])
+ ifTrue: [ ^index ].
+ (index := index \\ array size + 1) = start ] whileFalse.
+ self errorNoFreeSpace!
Andreas Raab uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-ul.235.mcz
==================== Summary ====================
Name: Collections-ul.235
Author: ul
Time: 1 December 2009, 4:39:23 am
UUID: 602bd45e-622a-a248-b87d-12efe1f99c84
Ancestors: Collections-ul.234
Part 2 of IdentitySet hash change.
=============== Diff against Collections-ul.234 ===============
Item was changed:
Item was changed:
----- Method: IdentitySet>>scanFor: (in category 'private') -----
scanFor: anObject
"Scan the key array for the first slot containing either a nil (indicating an empty slot) or an element that matches anObject. Answer the index of that slot or raise an error if no slot is found. This method will be overridden in various subclasses that have different interpretations for matching elements."
| index start |
- CollectionRehashingUtility quickRehashBecause: #identitySetScanForChanged.
index := start := anObject scaledIdentityHash \\ array size + 1.
[
| element |
((element := array at: index) == nil or: [ element == anObject ])
ifTrue: [ ^index ].
(index := index \\ array size + 1) = start ] whileFalse.
self errorNoFreeSpace!
Andreas Raab uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-ul.234.mcz
==================== Summary ====================
Name: Collections-ul.234
Author: ul
Time: 1 December 2009, 4:38:39 am
UUID: cbf77c63-cfff-dd40-9dac-e48fce824ea4
Ancestors: Collections-ul.233
Part 1 of IdentitySet hash change.
Also removed previous preamble.
=============== Diff against Collections-ul.233 ===============
Item was changed:
----- Method: IdentitySet>>scanForEmptySlotFor: (in category 'private') -----
scanForEmptySlotFor: anObject
"Scan the key array for the first slot containing an empty slot (indicated by a nil). Answer the index of that slot. This method will be overridden in various subclasses that have different interpretations for matching elements."
+ | index start |
+ index := start := anObject scaledIdentityHash \\ array size + 1.
- | index start hash |
- array size >= 8192
- ifTrue: [ hash := anObject identityHash * (array size // 4096) ]
- ifFalse: [ hash := anObject identityHash ].
- index := start := hash \\ array size + 1.
[
(array at: index) ifNil: [ ^index ].
(index := index \\ array size + 1) = start ] whileFalse.
self errorNoFreeSpace!
Item was changed:
Item was changed:
----- Method: IdentitySet>>scanFor: (in category 'private') -----
scanFor: anObject
"Scan the key array for the first slot containing either a nil (indicating an empty slot) or an element that matches anObject. Answer the index of that slot or raise an error if no slot is found. This method will be overridden in various subclasses that have different interpretations for matching elements."
+ | index start |
+ CollectionRehashingUtility quickRehashBecause: #identitySetScanForChanged.
+ index := start := anObject scaledIdentityHash \\ array size + 1.
- | index start hash |
- array size >= 8192
- ifTrue: [ hash := anObject identityHash * (array size // 4096) ]
- ifFalse: [ hash := anObject identityHash ].
- index := start := hash \\ array size + 1.
[
| element |
((element := array at: index) == nil or: [ element == anObject ])
ifTrue: [ ^index ].
(index := index \\ array size + 1) = start ] whileFalse.
self errorNoFreeSpace!