[Pkg] The Trunk: System-dtl.461.mcz

commits at source.squeak.org commits at source.squeak.org
Wed Nov 30 12:13:08 UTC 2011


David T. Lewis uploaded a new version of System to project The Trunk:
http://source.squeak.org/trunk/System-dtl.461.mcz

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

Name: System-dtl.461
Author: dtl
Time: 27 November 2011, 6:50:49.443 pm
UUID: 11a6c0c8-eceb-43c1-bede-0c884b9323a6
Ancestors: System-eem.460

Fix ReferenceStream handling of weak references. Test and patches by Juan Vuletich.
<http://lists.squeakfoundation.org/pipermail/squeak-dev/2011-November/162285.html>

Packages affected:
  Kernel-Objects
  System-Object Storage
  Tests-Object Storage

If we serialize a model with weak references to views, only the model should be serialized and not the views.

The bug became apparent only when dumping a model to a SmartRefStream, that calls #references, and the serialized stream was later materialized in an image where the view classes had been deleted. In such rare cases, materialization would fail when trying to reference these absent classes. If serializing to a ReferenceStream, the bug didn't become apparent (views were never serialized). If serializing to a SmartRefStream, but view classes still existed, the bug didn't really become apparent (because views were not actually deserialized), the only effect was a larger file.

=============== Diff against System-eem.460 ===============

Item was changed:
  ----- Method: DiskProxy>>storeDataOn: (in category 'i/o') -----
+ storeDataOn: aReferenceStream
- storeDataOn: aDataStream
  	"Besides just storing, get me inserted into references, so structures will know about class DiskProxy."
  
+ 	super storeDataOn: aReferenceStream.
+ 
+ 	"just so instVarInfo: will find it and put it into structures"
+ "	aReferenceStream references at: self put: #none."
+ 	aReferenceStream addSpecialReference: self!
- 	super storeDataOn: aDataStream.
- 	aDataStream references at: self put: #none.
- 		"just so instVarInfo: will find it and put it into structures"!

Item was added:
+ ----- Method: ReferenceStream>>addSpecialReference: (in category 'writing') -----
+ addSpecialReference: aDiskProxy
+ 	"See senders. Added to avoid breaking encapsulation (assuming that #references would answer the actual collection)"
+ 	references at: aDiskProxy put: #none!

Item was changed:
  ----- Method: ReferenceStream>>references (in category 'writing') -----
  references
+ 	"Do not include provisory references created in #nextPutWeak that never became normal references,
+ 	because the referenced object was never added from a call to #nextPut:"
+ 	^ references select: [ :value | value isNumber ]!
- 	^ references!

Item was changed:
  ----- Method: ReferenceStream>>statisticsOfRefs (in category 'statistics') -----
  statisticsOfRefs
  	"Analyze the information in references, the objects being written out"
  
+ 	| parents ownerBags tallies n nm owners normalReferences |
+ 	normalReferences := self references.	"Exclude unrealized weaks"
+ 	parents := IdentityDictionary new: normalReferences size * 2.
- 	| parents ownerBags tallies n nm owners |
- 	parents := IdentityDictionary new: references size * 2.
  	n := 0.
  	'Finding Owners...'
+ 	displayProgressFrom: 0 to: normalReferences size
- 	displayProgressFrom: 0 to: references size
  	during: [:bar |
+ 	normalReferences keysDo:
- 	references keysDo:
  		[:parent | | kids |
  		bar value: (n := n+1).
  		kids := parent class isFixed
+ 			ifTrue: [(1 to: parent class instSize) collect: [:i | parent instVarAt: i]]
- 			ifTrue: [(1 to: parent class instSize) collect: [:i | parent
- instVarAt: i]]
  			ifFalse: [parent class isBits ifTrue: [Array new]
+ 					 ifFalse: [(1 to: parent basicSize) collect: [:i | parent basicAt: i]]].
+ 		(kids select: [:x | normalReferences includesKey: x])
- 					 ifFalse: [(1 to: parent basicSize) collect: [:i | parent basicAt:
- i]]].
- 		(kids select: [:x | references includesKey: x])
  			do: [:child | parents at: child put: parent]]].
  	ownerBags := Dictionary new.
  	tallies := Bag new.
  	n := 0.
  	'Tallying Owners...'
+ 	displayProgressFrom: 0 to: normalReferences size
- 	displayProgressFrom: 0 to: references size
  	during: [:bar |
+ 	normalReferences keysDo:  "For each class of obj, tally a bag of owner classes"
- 	references keysDo:  "For each class of obj, tally a bag of owner
- classes"
  		[:obj | | objParent | bar value: (n := n+1).
  		nm := obj class name.
  		tallies add: nm.
  		owners := ownerBags at: nm ifAbsent: [ownerBags at: nm put: Bag new].
  		(objParent := parents at: obj ifAbsent: [nil]) == nil
  			ifFalse: [owners add: objParent class name]]].
  	^ String streamContents:
  		[:strm |  tallies sortedCounts do:
  			[:assn | n := assn key.  nm := assn value.
  			owners := ownerBags at: nm.
  			strm cr; nextPutAll: nm; space; print: n.
  			owners size > 0 ifTrue:
  				[strm cr; tab; print: owners sortedCounts]]]!



More information about the Packages mailing list