[squeak-dev] The Trunk: Collections-fbs.482.mcz

commits at source.squeak.org commits at source.squeak.org
Fri Aug 3 20:28:26 UTC 2012


Frank Shearar uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-fbs.482.mcz

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

Name: Collections-fbs.482
Author: fbs
Time: 3 August 2012, 9:26:33.402 pm
UUID: f236f58a-ba49-4c8c-8314-731f82206158
Ancestors: Collections-ael.481

Merge Collections-ael.481

remove spurious sharing of associations between a dictionary and another created from it

=============== Diff against Collections-cwp.480 ===============

Item was changed:
  ----- Method: Dictionary class>>newFrom: (in category 'instance creation') -----
  newFrom: aDict 
  	"Answer an instance of me containing the same associations as aDict.
  	 Error if any key appears twice."
  	| newDictionary |
  	newDictionary := self new: aDict size.
  	aDict associationsDo:
  		[:x |
  		(newDictionary includesKey: x key)
  			ifTrue: [self error: 'Duplicate key: ', x key printString]
+ 			ifFalse: [newDictionary add: x copy]].
- 			ifFalse: [newDictionary add: x]].
  	^ newDictionary
  
  "	NewDictionary newFrom: {1->#a. 2->#b. 3->#c}
  	{1->#a. 2->#b. 3->#c} as: NewDictionary
  	NewDictionary newFrom: {1->#a. 2->#b. 1->#c}
  	{1->#a. 2->#b. 1->#c} as: NewDictionary
  "!

Item was added:
+ ----- Method: WeakRegistry class>>migrateOldRegistries (in category 'migrating registry') -----
+ migrateOldRegistries
+ 	Smalltalk at: #WeakFinalizationRegistry ifAbsent: [ ^ self "already done" ].
+ 	
+ 	Smalltalk recreateSpecialObjectsArray.
+ 	WeakArray restartFinalizationProcess.
+ 	
+ 	Smalltalk garbageCollect; garbageCollect.
+ 	
+ 	"leave no chance to interrupt migration"	
+ 	Compiler evaluate: '
+ 	[ | old new oldClass newClass |
+ 		old := OrderedCollection new.
+ 		new := OrderedCollection new.
+ 		WeakRegistry allInstancesDo: [:registry | | newr |
+ 			old add: registry.
+ 			newr := WeakFinalizationRegistry basicNew initialize.
+ 			registry migrateTo: newr.
+ 			new add: newr ].
+ 		old asArray elementsForwardIdentityTo: new asArray.
+ 		
+ 		oldClass := WeakRegistry.
+ 		newClass := WeakFinalizationRegistry.
+ 		
+ 		Smalltalk forgetClass: newClass logged: false.
+ 		newClass superclass removeSubclass: newClass.
+ 		newClass setName: #WeakRegistry.
+ 		oldClass becomeForward: newClass.
+ 	] forkAt: Processor highestPriority.
+ 	'.
+ !



More information about the Squeak-dev mailing list