The Trunk: System-eem.986.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-eem.986.mcz

commits-2
Eliot Miranda uploaded a new version of System to project The Trunk:
http://source.squeak.org/trunk/System-eem.986.mcz

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

Name: System-eem.986
Author: eem
Time: 15 December 2017, 1:20:51.087309 pm
UUID: c2b6f9bb-8a44-41c6-ada3-41bdff1b0676
Ancestors: System-eem.985

Doh!  PCs in contexts and blocks must also be mapped when moving between word sizes.  This fixes loading 64-bit projects into 32-bits.  Still seem to be issues going the other way.

Also eliminate an activation by inlining uint32At: into readUint32.

=============== Diff against System-eem.985 ===============

Item was added:
+ ----- Method: Spur32BitImageSegmentLoader>>mapPC:in: (in category 'private') -----
+ mapPC: pc in: compiledCode
+ "Assuming the word size of compiledCode is 8, and that the pc is one for a word size of 4, map the pc from 4 to 8.
+ The filter is in updatePCDependentObjects."
+ ^pc + (compiledCode numLiterals + 1 * 4)!

Item was added:
+ ----- Method: Spur32BitImageSegmentLoader>>updatePCDependentObjects (in category 'reading') -----
+ updatePCDependentObjects
+ Smalltalk wordSize ~= 4 ifTrue:
+ [super updatePCDependentObjects]!

Item was added:
+ ----- Method: Spur64BitImageSegmentLoader>>mapPC:in: (in category 'private') -----
+ mapPC: pc in: compiledCode
+ "Assuming the word size of compiledCode is 4, and that the pc is one for a word size of 8, map the pc from 8 to 4.
+ The filter is in updatePCDependentObjects."
+ ^pc - (compiledCode numLiterals + 1 * 4)!

Item was added:
+ ----- Method: Spur64BitImageSegmentLoader>>updatePCDependentObjects (in category 'filling') -----
+ updatePCDependentObjects
+ Smalltalk wordSize ~= 8 ifTrue:
+ [super updatePCDependentObjects]!

Item was changed:
  Object subclass: #SpurImageSegmentLoader
+ instanceVariableNames: 'segment outPointers oopMap position pcDependentObjects'
- instanceVariableNames: 'segment outPointers oopMap position'
  classVariableNames: 'TopHashBit'
  poolDictionaries: ''
  category: 'System-Object Storage'!
 
  !SpurImageSegmentLoader commentStamp: 'eem 12/15/2017 11:20' prior: 0!
  SpurImageSegmentLoader is the abstract class for loaders of 32-bit and 64-bit Spur image segments.  The VM has both storing and loading primitives and the store primitive is always used.  The load primitive is used when the word size of the current system matches that of the stored segment (orf the word size of the system in which the segment was stored).  A word on encoding.  The keys in oopMap are byte positions of the start of the object, offset by the 64-bit version stamp.  So the first object, which has oop 0, is in the map at 0, and corresponds to index 3 in the segment data.
 
  position starts at zero and readUInt32 increments position by 4 before using uint32At: to access segment.  Hence the first access via readUInt32 is of index 1 in segment data.  Later on position is reset to 8 bytes beyond the oop to access the data.
 
  Instance Variables
  oopMap: <Dictionary of: oop (Integer) -> object>
  outPointers: <Array>
  position: <Integer>
  segment: <WordArrayForSegment>
 
  oopMap
  - the map from the oop of an object to the object with that oop
 
  outPointers
  - the array of imported objects, objects not in the segment but referred to by the segment
 
  position
  - the current position when parsing the segment
 
  segment
  - the segment data, which starts with 64-bits of version stamp, so the first object starts at index 3, and has oop 0.
  !

Item was changed:
  ----- Method: SpurImageSegmentLoader>>fillObject:oop: (in category 'filling') -----
  fillObject: object oop: oop
+ "Fill the object's inst vars with data/other objects.  Remember any pc-dependent objects (contexts
+ and blocks) so that their pcs can be updated when their methods have been brought in as well."
- "Fill the object's inst vars with data/other objects."
  | class |
  "First set position to 4 bytes before the first field, in readiness to read the object's data"
  position := oop + 16. "8 bytes of version stamp  + 8 bytes of object header - 4 bytes of preincrement + 4 bytes 0->1 relative index"
  class := object class.
  class isPointers ifTrue:
  [class isVariable ifTrue:
  [object isContext ifTrue:
+ [pcDependentObjects addLast: object.
+ ^self fillContext: object oop: oop].
+ object isBlock ifTrue:
+ [pcDependentObjects addLast: object].
- [^self fillContext: object oop: oop].
  ^self fillVariablePointers: object oop: oop].
  object isBehavior ifTrue:
  [^self fillBehavior: object oop: oop].
  ^self fillPointers: object oop: oop].
  class isBytes ifTrue:
  [object isCompiledCode ifTrue:
  [^self fillCompiledCode: object oop: oop].
  ^self fillBytes: object oop: oop].
  class isWords ifTrue:
  [^self fillWords: object oop: oop].
  class isLongs ifTrue:
  [^self fillWords: object oop: oop].
  ^self fillShorts: object oop: oop!

Item was changed:
  ----- Method: SpurImageSegmentLoader>>loadSegmentFrom:outPointers: (in category 'loading') -----
  loadSegmentFrom: segmentWordArray outPointers: outPointerArray
  | version end memory |
  segment := segmentWordArray.
  outPointers := outPointerArray.
  position := 0.
  version := self readUint32.
  (self validImageSegmentVersion: (version bitAnd: 16rFFFFFF)) ifFalse:
  [^self error: 'Cannot read this segment (endianness?)'].
  "First allocate all objects, then fill in their fields via oopMap"
  memory := OrderedCollection new: 1000.
  oopMap := Dictionary new.
+ pcDependentObjects := OrderedCollection new.
  end := segment size * 4.
  position := 8.
  [position < end] whileTrue:
  [memory addLast: self readObject].
  self ignoringAccessToWordAfterSegmentDo:
  [oopMap keysAndValuesDo:
  [:oop :obj | self fillObject: obj oop: oop]].
+ self updatePCDependentObjects.
  "Answer list of all objects (unlike primitive, which returned the first object and relied on other objects being consecutive in memory)"
  ^memory!

Item was changed:
  ----- Method: SpurImageSegmentLoader>>readUint32 (in category 'reading') -----
  readUint32
+ ^segment at: (position := position + 4) // 4!
- ^self uint32At: (position := position + 4)!

Item was removed:
- ----- Method: SpurImageSegmentLoader>>uint32At: (in category 'reading') -----
- uint32At: addr
- "TODO: do endian conversion here"
- "also read the class comment"
- ^segment at: addr // 4!

Item was added:
+ ----- Method: SpurImageSegmentLoader>>updatePCDependentObjects (in category 'filling') -----
+ updatePCDependentObjects
+ pcDependentObjects do:
+ [:contextOrBlock|
+
+ contextOrBlock isContext ifTrue:
+ [contextOrBlock pc ifNotNil:
+ [:pc| contextOrBlock pc: (self mapPC: pc in: contextOrBlock method)]].
+
+ (contextOrBlock isBlock
+ and: [contextOrBlock isFullBlock not])ifTrue:
+ [contextOrBlock instVarNamed: 'startpc' put: (self mapPC: contextOrBlock startpc in: contextOrBlock method)]]!