[Pkg] The Trunk: Environments-nice.36.mcz

commits at source.squeak.org commits at source.squeak.org
Thu Dec 19 23:37:07 UTC 2013

Nicolas Cellier uploaded a new version of Environments to project The Trunk:

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

Name: Environments-nice.36
Author: nice
Time: 20 December 2013, 12:36:50.563 am
UUID: 203a26be-b85d-4abf-9e82-73222b27a2b5
Ancestors: Environments-nice.35

Some undesirable Alias have been introduced in the system (Smalltalk globals) during the update process by a previously incorrect method (Association>>asBinding: around update 227).
Add a postscript focused on removing those (and only those) undesirable Aliases.

=============== Diff against Environments-nice.35 ===============

Item was added:
+ (PackageInfo named: 'Environments') postscript: '"below, add code to be run after the loading of this package"
+ | allAliases toBeRecompiled undesirableAliases |
+ "Collect the CompiledMethods pointing to an Alias"
+ allAliases := Alias allInstances.
+ toBeRecompiled := CompiledMethod allInstances select: [:c | c isInstalled and: [allAliases anySatisfy: [:a | c pointsTo: a]]].
+ "Collect the Aliases pointing to some class binding in the same Environment with same name"
+ undesirableAliases := (Smalltalk globals instVarNamed: ''references'') associations select: [:e |
+ 	e class = Alias and: [e key = e source key
+ 		and: [(Smalltalk globals instVarNamed: ''declarations'') associations includes: e source]]].
+ "Replace the undesirable Aliases with their source binding"
+ undesirableAliases do: [:a | a becomeForward: a source].
+ "Rehash the references because they pointed to those Aliases - hope there''s nothing else to rehash"
+ (Smalltalk globals instVarNamed: ''references'') rehash.
+ "Recompile the CompiledMethod that used to point to an Alias, because the bytecodes do change"
+ Symbol rehash.
+ toBeRecompiled do: [:c | c methodClass recompile: c selector].
+ allAliases := toBeRecompiled := undesirableAliases := nil.
+ Smalltalk garbageCollect.
+ Alias allInstances size.
+ '!

More information about the Packages mailing list