SnapShotImageMemory.st
changeset 3326 4ecde59f7563
parent 3324 dee0c393db4e
child 3630 5e718e0a754e
equal deleted inserted replaced
3325:8ce2df5fc1f7 3326:4ecde59f7563
       
     1 "{ Encoding: utf8 }"
       
     2 
     1 "{ Package: 'stx:libtool2' }"
     3 "{ Package: 'stx:libtool2' }"
     2 
     4 
     3 "{ NameSpace: Smalltalk }"
     5 "{ NameSpace: Smalltalk }"
     4 
     6 
     5 Object subclass:#SnapShotImageMemory
     7 Object subclass:#SnapShotImageMemory
    38 	privateIn:SnapShotImageMemory
    40 	privateIn:SnapShotImageMemory
    39 !
    41 !
    40 
    42 
    41 SnapShotImageMemory::ImageObject variableSubclass:#ImageClassObject
    43 SnapShotImageMemory::ImageObject variableSubclass:#ImageClassObject
    42 	instanceVariableNames:'cachedCategory cachedFlags cachedName'
    44 	instanceVariableNames:'cachedCategory cachedFlags cachedName'
       
    45 	classVariableNames:''
       
    46 	poolDictionaries:''
       
    47 	privateIn:SnapShotImageMemory
       
    48 !
       
    49 
       
    50 SnapShotImageMemory::ImageHeader variableWordSubclass:#ImageWordObject
       
    51 	instanceVariableNames:''
    43 	classVariableNames:''
    52 	classVariableNames:''
    44 	poolDictionaries:''
    53 	poolDictionaries:''
    45 	privateIn:SnapShotImageMemory
    54 	privateIn:SnapShotImageMemory
    46 !
    55 !
    47 
    56 
   236         ].
   245         ].
   237 
   246 
   238 "/Transcript show:'#'.
   247 "/Transcript show:'#'.
   239 "/Transcript show:((ByteArray new:nBytes-1) replaceFrom:1 to:nBytes-1 with:o startingAt:1) asString.
   248 "/Transcript show:((ByteArray new:nBytes-1) replaceFrom:1 to:nBytes-1 with:o startingAt:1) asString.
   240 "/Transcript cr.
   249 "/Transcript cr.
   241 
   250         ^ o
   242     ] ifFalse:[
   251     ].
   243         (indexTypeFlags = Behavior flagNotIndexed) ifFalse:[ 
   252     (indexTypeFlags = Behavior flagWords) ifTrue:[
   244             (indexTypeFlags ~= Behavior flagPointers) ifTrue:[
   253         |nWords|
   245                 (indexTypeFlags ~= Behavior flagWeakPointers) ifTrue:[
   254         
   246                     self halt 
   255         nBytes := (size - hdrSize).
   247                 ]
   256         nWords := nBytes//2.
   248             ].
   257         o := ImageWordObject new:nWords.
   249         ].
       
   250 
       
   251         nInsts := (size - hdrSize) // intSize.
       
   252         (flags bitTest:Behavior flagBehavior)
       
   253         "/ classRef isImageBehavior 
       
   254         ifTrue:[
       
   255             o := ImageClassObject new:nInsts.
       
   256         ] ifFalse:[
       
   257             (flags bitTest:Behavior flagMethod) ifTrue:[
       
   258                 o := ImageMethodObject new:nInsts.
       
   259             ] ifFalse:[
       
   260                 o := ImageObject new:nInsts.
       
   261             ]
       
   262         ].
       
   263         o memory:self.
   258         o memory:self.
   264         o address:baseAddr.
   259         o address:baseAddr.
   265         o classRef:classRef.
   260         o classRef:classRef.
   266         "/ size > 8000 ifTrue:[self halt].
   261         "/ size > 8000 ifTrue:[self halt].
   267         o byteSize:size.
   262         o byteSize:size.
   268         o bits:bits.
   263         o bits:bits.
   269         addrToObjectMapping at:(baseAddr bitShift:-2) put:o.
   264         addrToObjectMapping at:(baseAddr bitShift:-2) put:o.
   270 
   265 
   271         1 to:nInsts do:[:idx |
   266         1 to:nWords do:[:idx |
   272             o at:idx put:(fetchINT value).
   267             o at:idx put:(stream nextUnsignedInt16MSB:msb).
       
   268             addr := addr + 2.
       
   269         ].
       
   270 
       
   271 "/Transcript show:'#'.
       
   272 "/Transcript show:((ByteArray new:nBytes-1) replaceFrom:1 to:nBytes-1 with:o startingAt:1) asString.
       
   273 "/Transcript cr.
       
   274         ^ o
       
   275     ].
       
   276     
       
   277     (indexTypeFlags = Behavior flagNotIndexed) ifFalse:[ 
       
   278         (indexTypeFlags ~= Behavior flagPointers) ifTrue:[
       
   279             (indexTypeFlags ~= Behavior flagWeakPointers) ifTrue:[
       
   280                 self halt 
       
   281             ]
       
   282         ].
       
   283     ].
       
   284 
       
   285     nInsts := (size - hdrSize) // intSize.
       
   286     (flags bitTest:Behavior flagBehavior)
       
   287     "/ classRef isImageBehavior 
       
   288     ifTrue:[
       
   289         o := ImageClassObject new:nInsts.
       
   290     ] ifFalse:[
       
   291         (flags bitTest:Behavior flagMethod) ifTrue:[
       
   292             o := ImageMethodObject new:nInsts.
       
   293         ] ifFalse:[
       
   294             o := ImageObject new:nInsts.
       
   295         ]
       
   296     ].
       
   297     o memory:self.
       
   298     o address:baseAddr.
       
   299     o classRef:classRef.
       
   300     "/ size > 8000 ifTrue:[self halt].
       
   301     o byteSize:size.
       
   302     o bits:bits.
       
   303     addrToObjectMapping at:(baseAddr bitShift:-2) put:o.
       
   304 
       
   305     1 to:nInsts do:[:idx |
       
   306         o at:idx put:(fetchINT value).
   273 "/            o at:idx put:(self fetchObjectAt:(self fetchUnboxedIntegerAt:addr)).
   307 "/            o at:idx put:(self fetchObjectAt:(self fetchUnboxedIntegerAt:addr)).
   274             addr := addr + ptrSize.
   308         addr := addr + ptrSize.
   275         ]
       
   276     ].
   309     ].
   277     ^ o
   310     ^ o
   278 !
   311 !
   279 
   312 
   280 fetchPointerAt:addr
   313 fetchPointerAt:addr
  4258 
  4291 
  4259 wasAutoloaded
  4292 wasAutoloaded
  4260     ^ false
  4293     ^ false
  4261 ! !
  4294 ! !
  4262 
  4295 
       
  4296 !SnapShotImageMemory::ImageWordObject methodsFor:'queries'!
       
  4297 
       
  4298 size
       
  4299     ^ byteSize // 2
       
  4300 ! !
       
  4301 
  4263 !SnapShotImageMemory::SpaceInfo methodsFor:'accessing'!
  4302 !SnapShotImageMemory::SpaceInfo methodsFor:'accessing'!
  4264 
  4303 
  4265 end
  4304 end
  4266     "return the value of the instance variable 'end' (automatically generated)"
  4305     "return the value of the instance variable 'end' (automatically generated)"
  4267 
  4306