The Trunk: System-nice.778.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: System-nice.778.mcz

commits-2
Nicolas Cellier uploaded a new version of System to project The Trunk:
http://source.squeak.org/trunk/System-nice.778.mcz

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

Name: System-nice.778
Author: nice
Time: 13 November 2015, 12:37:09.849 am
UUID: cc54826e-9a26-4826-a459-9de589d4aee2
Ancestors: System-nice.777

Attempt a better fix for restoring endianness at ImageSegment materialization:

1) get the image segment endianess from the segment WordArray, before it is transformed into an Array.

2) use this information to later restoreEndianness: ifNeeded.

This will require a slight semantic change of #startUpFrom: to which we pass a Boolean rather than an ImageSegment.

=============== Diff against System-nice.777 ===============

Item was changed:
  ----- Method: ImageSegment>>comeFullyUpOnReload: (in category 'fileIn/Out') -----
  comeFullyUpOnReload: smartRefStream
  "fix up the objects in the segment that changed size.  An object in the segment is the wrong size for the modern version of the class. Construct a fake class that is the old size.  Replace the modern class with the old one in outPointers.  Load the segment. Traverse the instances, making new instances by copying fields, and running conversion messages.  Keep the new instances.  Bulk forward become the old to the new.  Let go of the fake objects and classes.
  After the install (below), arrayOfRoots is filled in. Globalize new classes.  Caller may want to do some special install on certain objects in arrayOfRoots.
  May want to write the segment out to disk in its new form."
 
+ | mapFakeClassesToReal receiverClasses rootsToUnhiberhate myProject forgetDoItsClasses endianness |
- | mapFakeClassesToReal receiverClasses rootsToUnhiberhate myProject forgetDoItsClasses |
 
  forgetDoItsClasses := Set new.
  RecentlyRenamedClasses := nil. "in case old data hanging around"
  mapFakeClassesToReal := smartRefStream reshapedClassesIn: outPointers.
  "Dictionary of just the ones that change shape. Substitute them in outPointers."
  self fixCapitalizationOfSymbols.
+ endianness := self endianness.
  arrayOfRoots := self loadSegmentFrom: segment outPointers: outPointers.
  self checkAndReportLoadError.
  "Can't use install.  Not ready for rehashSets"
  mapFakeClassesToReal isEmpty ifFalse: [
  self reshapeClasses: mapFakeClassesToReal refStream: smartRefStream
  ].
  "When a Project is stored, arrayOfRoots has all objects in the project, except those in outPointers"
  arrayOfRoots do: [:importedObject | | existing |
  ((importedObject isMemberOf: WideString) or: [importedObject isMemberOf: WideSymbol]) ifTrue: [
  importedObject mutateJISX0208StringToUnicode.
  importedObject class = WideSymbol ifTrue: [
  "self halt."
  Symbol hasInterned: importedObject asString ifTrue: [:multiSymbol |
  multiSymbol == importedObject ifFalse: [
  importedObject becomeForward: multiSymbol.
  ].
  ].
  ].
  ].
  (importedObject isKindOf: TTCFontSet) ifTrue: [
  existing := TTCFontSet
  familyName: importedObject familyName
  pointSize: importedObject pointSize. "supplies default"
  existing == importedObject ifFalse: [importedObject becomeForward: existing].
  ].
  ].
  "Smalltalk garbageCollect.   MultiSymbol rehash.  These take time and are not urgent, so don't to them.  In the normal case, no bad MultiSymbols will be found."
 
+ receiverClasses := self restoreEndianness: (endianness ~~ Smalltalk endianness). "rehash sets"
- receiverClasses := self restoreEndianness. "rehash sets"
  smartRefStream checkFatalReshape: receiverClasses.
 
  "Classes in this segment."
  arrayOfRoots do: [:importedObject |
  importedObject class class == Metaclass ifTrue: [
  forgetDoItsClasses add: importedObject.
  self declare: importedObject]].
  arrayOfRoots do: [:importedObject |
  importedObject isCompiledMethod ifTrue: [
  importedObject sourcePointer > 0 ifTrue: [importedObject zapSourcePointer]].
  (importedObject isKindOf: Project) ifTrue: [
  myProject := importedObject.
  importedObject ensureChangeSetNameUnique.
  Project addingProject: importedObject.
  importedObject restoreReferences.
  self dependentsRestore: importedObject]].
 
  rootsToUnhiberhate := arrayOfRoots select: [:importedObject |
  importedObject respondsTo: #unhibernate
  "ScriptEditors and ViewerFlapTabs"
  ].
  myProject ifNotNil: [
  myProject world setProperty: #thingsToUnhibernate toValue: rootsToUnhiberhate asArray.
  ].
 
  mapFakeClassesToReal isEmpty ifFalse: [
  mapFakeClassesToReal keysAndValuesDo: [:aFake :aReal |
  aFake removeFromSystemUnlogged.
  "do not assign the fake's hash to the real class"
  aFake becomeForward: aReal copyHash: false].
  SystemOrganization removeEmptyCategories].
  forgetDoItsClasses do: [:c | c forgetDoIts].
  "^ self"
  !

Item was changed:
  ----- Method: ImageSegment>>restoreEndianness (in category 'fileIn/Out') -----
  restoreEndianness
+ ^self restoreEndianness: self endianness ~~ Smalltalk endianness!
- "Fix endianness (byte order) of any objects not already fixed.  Do this by discovering classes that need a startUp message sent to each instance, and sending it.
- I have just been brought in and converted to live objects.  Find all Sets and Dictionaries in the newly created objects and rehash them.  Segment is near then end of memory, since is was newly brought in (and a new object created for it).
- Also, collect all classes of receivers of blocks which refer to instance variables.  Return them.  Caller will check if they have been reshaped."
-
- | hashedCollections receiverClasses noStartUpNeeded startUps |
-
- hashedCollections := OrderedCollection new.
- receiverClasses := IdentitySet new.
- noStartUpNeeded := IdentitySet new. "classes that don't have a per-instance startUp message"
- startUps := IdentityDictionary new. "class -> MessageSend of a startUp message"
- self allObjectsDo:
- [:object| | cls msg |
- object isInMemory ifTrue:
- [(object isCollection and: [object isKindOf: HashedCollection]) ifTrue:
- [hashedCollections add: object].
- (object isContext and: [object hasInstVarRef]) ifTrue:
- [receiverClasses add: object receiver class]].
- (noStartUpNeeded includes: object class) ifFalse:
- [cls := object class.
- (msg := startUps at: cls ifAbsent: nil) ifNil:
- [msg := cls startUpFrom: self. "a Message, if we need to swap bytes this time"
- msg ifNil: [noStartUpNeeded add: cls]
- ifNotNil: [startUps at: cls put: msg]].
- msg ifNotNil: [msg sentTo: object]]].
- hashedCollections do: [ :each | each compact ]. "our purpose"
- ^ receiverClasses "our secondary job"!

Item was added:
+ ----- Method: ImageSegment>>restoreEndianness: (in category 'fileIn/Out') -----
+ restoreEndianness: endiannessHasToBeFixed
+ "If endiannessHasToBeFixed, then fix endianness (byte order) of any objects not already fixed.  Do this by discovering classes that need a startUp message sent to each instance, and sending it..
+ I have just been brought in and converted to live objects.  Find all Sets and Dictionaries in the newly created objects and rehash them.  Segment is near then end of memory, since is was newly brought in (and a new object created for it).
+ Also, collect all classes of receivers of blocks which refer to instance variables.  Return them.  Caller will check if they have been reshaped."
+
+ | hashedCollections receiverClasses noStartUpNeeded startUps |
+
+ hashedCollections := OrderedCollection new.
+ receiverClasses := IdentitySet new.
+ noStartUpNeeded := IdentitySet new. "classes that don't have a per-instance startUp message"
+ startUps := IdentityDictionary new. "class -> MessageSend of a startUp message"
+ self allObjectsDo:
+ [:object| | cls msg |
+ object isInMemory ifTrue:
+ [(object isCollection and: [object isKindOf: HashedCollection]) ifTrue:
+ [hashedCollections add: object].
+ (object isContext and: [object hasInstVarRef]) ifTrue:
+ [receiverClasses add: object receiver class]].
+ (noStartUpNeeded includes: object class) ifFalse:
+ [cls := object class.
+ (msg := startUps at: cls ifAbsent: nil) ifNil:
+ [msg := cls startUpFrom: endiannessHasToBeFixed. "a Message, if we need to swap bytes this time"
+ msg ifNil: [noStartUpNeeded add: cls]
+ ifNotNil: [startUps at: cls put: msg]].
+ msg ifNotNil: [msg sentTo: object]]].
+ hashedCollections do: [ :each | each compact ]. "our purpose"
+ ^ receiverClasses "our secondary job"!