[Pkg] The Trunk: Kernel-dtl.655.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 Kernel to project The Trunk:

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

Name: Kernel-dtl.655
Author: dtl
Time: 27 November 2011, 6:50:19.012 pm
UUID: a7fda999-52a1-42f1-92da-9cdae7a9614a
Ancestors: Kernel-bf.654

Fix ReferenceStream handling of weak references. Test and patches by Juan Vuletich.

Packages affected:
  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 Kernel-bf.654 ===============

Item was changed:
  ----- Method: Object>>storeDataOn: (in category 'objects from disk') -----
  storeDataOn: aDataStream
  	"Store myself on a DataStream.  Answer self.  This is a low-level DataStream/ReferenceStream method. See also objectToStoreOnDataStream.  NOTE: This method must send 'aDataStream beginInstance:size:' and then (nextPut:/nextPutWeak:) its subobjects.  readDataFrom:size: reads back what we write here."
  	| cntInstVars cntIndexedVars |
  	cntInstVars := self class instSize.
  	cntIndexedVars := self basicSize.
  		beginInstance: self class
  		size: cntInstVars + cntIndexedVars.
  	1 to: cntInstVars do:
  		[:i | aDataStream nextPut: (self instVarAt: i)].
  	"Write fields of a variable length object.  When writing to a dummy 
  		stream, don't bother to write the bytes"
  	((aDataStream byteStream class == DummyStream) and: [self class isBits]) ifFalse: [
+ 		self class isWeak
+ 			ifTrue: [
+ 				"For weak classes (for example DependentsArray) write the referenced object only
+ 				if referenced from elsewhere in the dumped object graph.
+ 				This means, for instance that if we only dump a model, no dependents are stored, 
+ 				but if we store a view (i.e. a Morph), it is properly handled as a dependent after the object graph is revived."
+ 				1 to: cntIndexedVars do: [ :i |
+ 					aDataStream nextPutWeak: (self basicAt: i)]]
+ 			ifFalse: [
+ 				1 to: cntIndexedVars do: [ :i |
+ 					aDataStream nextPut: (self basicAt: i)]]]!
- 		1 to: cntIndexedVars do:
- 			[:i | aDataStream nextPut: (self basicAt: i)]].
- !

More information about the Packages mailing list