VM Maker Inbox: VMMaker-dtl.409.mcz

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

VM Maker Inbox: VMMaker-dtl.409.mcz

commits-2
 
David T. Lewis uploaded a new version of VMMaker to project VM Maker Inbox:
http://source.squeak.org/VMMakerInbox/VMMaker-dtl.409.mcz

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

Name: VMMaker-dtl.409
Author: dtl
Time: 2 December 2019, 7:15:49.04 pm
UUID: 2f30017c-5c17-49a2-b431-9fcdb82b7770
Ancestors: VMMaker-dtl.408

Let primitiveResumeFromSnapshot fail if the current interpreter cannot support the image format of the snapshot object.

=============== Diff against VMMaker-dtl.408 ===============

Item was changed:
  ----- Method: ContextInterpreter>>primitiveResumeFromSnapshot (in category 'snapshot utility primitives') -----
  primitiveResumeFromSnapshot
  "Discard the current object memory and resume interpreter execution
  in the provided snapshot."
 
  <export: true>
  | expectedArraySize snapshotValues size newMemoryBytesOrBitmap bigEndian snapshotImageFormat snapshotStartOfMemory snapshotSpecialObjectsOop snapshotLastHash screenSizePoint headerSize imageBytes imageHeaderFlags snapshotExtraVMMemory swapBytes snapshotFullScreen defaultHeapSize desiredHeapSize |
  expectedArraySize := 11. "ImageSnapshot new asValues size => 11"
  argumentCount == 1
  ifFalse: [ ^self primitiveFailFor: PrimErrBadNumArgs].
  snapshotValues := self stackObjectValue: 0.
  self assertClassOf: snapshotValues is: (objectMemory splObj: ClassArray).
  self successful
  ifFalse: [ ^self primitiveFailFor: PrimErrBadArgument].
  size := objectMemory numSlotsOf: snapshotValues.
  size < expectedArraySize ifTrue: [ ^self primitiveFailFor: PrimErrBadArgument].
  newMemoryBytesOrBitmap := objectMemory fetchPointer: 0 ofObject: snapshotValues.
  bigEndian := (objectMemory fetchPointer: 1 ofObject: snapshotValues) = objectMemory trueObject.
  snapshotImageFormat := objectMemory integerValueOf: (objectMemory fetchPointer: 2 ofObject: snapshotValues)..
+ (self readableFormat: snapshotImageFormat)
+ ifFalse: [ ^self primitiveFailFor: PrimErrInappropriate ].
  headerSize := objectMemory integerValueOf: (objectMemory fetchPointer: 3 ofObject: snapshotValues)..
  imageBytes := self positive32BitValueOf: (objectMemory fetchPointer: 4 ofObject: snapshotValues).. "good for up to 2GB image"
  snapshotStartOfMemory := objectMemory integerValueOf: (objectMemory fetchPointer: 5 ofObject: snapshotValues)..
  snapshotSpecialObjectsOop := objectMemory integerValueOf: (objectMemory fetchPointer: 6 ofObject: snapshotValues)..
  snapshotLastHash := objectMemory integerValueOf: (objectMemory fetchPointer: 7 ofObject: snapshotValues)..
  screenSizePoint := objectMemory fetchPointer: 8 ofObject: snapshotValues..
  self assertClassOf: screenSizePoint is: (objectMemory splObj: ClassPoint).
  self successful
  ifFalse: [ ^self primitiveFailFor: PrimErrBadArgument].
  imageHeaderFlags := objectMemory integerValueOf: (objectMemory fetchPointer: 9 ofObject: snapshotValues)..
  snapshotExtraVMMemory := objectMemory integerValueOf: (objectMemory fetchPointer: 10 ofObject: snapshotValues)..
 
  swapBytes := bigEndian ~= self isBigEnder.
  snapshotFullScreen := false. "FIXME"
 
  "From sqUnixMain.c
  #define DefaultHeapSize           20
  megabytes BEYOND actual image size"
  defaultHeapSize := 20 * 1000 * 1000.
  desiredHeapSize := defaultHeapSize + imageBytes.
 
  self
  snapshotResume: newMemoryBytesOrBitmap
  heapSize: desiredHeapSize
  swapBytes: swapBytes
  oldBaseAddr: snapshotStartOfMemory
  specialObjectsOop: snapshotSpecialObjectsOop
  lastHash: snapshotLastHash
  savedWindowSize: screenSizePoint
  fullScreenFlag: snapshotFullScreen
  extraVMMemory: snapshotExtraVMMemory.
 
  self pop: 1 thenPush: newMemoryBytesOrBitmap.
 
  !

Item was changed:
  ----- Method: ContextInterpreter>>snapshotResume:heapSize:swapBytes:oldBaseAddr:specialObjectsOop:lastHash:savedWindowSize:fullScreenFlag:extraVMMemory: (in category 'snapshot utility primitives') -----
  snapshotResume: byteArrayOrBitmap heapSize: desiredHeapSize swapBytes: swapBytes oldBaseAddr: oldBaseAddr specialObjectsOop: specialObjects lastHash: hashValue savedWindowSize: windowSize fullScreenFlag: fullScreen extraVMMemory: extraMemory
  "Arrange for the interpreter to resume execution from a snapshot of saved
  memory and interpreter state. The current object memory and interpreter
  state is discarded, and the interpreter resumes execution at the point of
+ the supplied image snapshot."
- the supplied image snapshot.."
 
  | dataSize sourceBytes mem |
  <returnTypeC: 'usqInt'>
  <var: #desiredHeapSize type: 'usqInt'>
  <var: #dataSize type: 'size_t '>
  <var: #sourceBytes type: 'char *'>
  <var: #mem type: 'char *'>
 
  "Notes - The parameters windowSize, fullScreen and extraMemory are currently
  not used when resuming the VM in a new image. The display size and fullscreen
  mode are probably best set from the image by calling primitiveSetDisplayMode
  prior to primitiveResumeFromSnapshot. The extraMemory parameter is ignored
  here because we are simply copying the new object memory over a previously
  allocated heap space."
 
  dataSize := objectMemory byteSizeOf: byteArrayOrBitmap.
  sourceBytes := objectMemory firstIndexableField: byteArrayOrBitmap.
  objectMemory setSpecialObjectsOop: specialObjects.
  objectMemory setLastHash: hashValue.
 
  "Copy object memory into allocated space"
  objectMemory setMemoryLimits: dataSize heapSize: desiredHeapSize.
  mem := objectMemory pointerForOop: objectMemory getMemory.
  self mem: mem
  cp: sourceBytes
  y: dataSize.
 
  self swapBytesAndPrepareToInterpret: swapBytes oldBaseAddr: oldBaseAddr.
    self interpret. "Resume interpreter execution in the snapshot."
  !

Item was changed:
  ----- Method: VMMaker class>>versionString (in category 'version testing') -----
  versionString
 
  "VMMaker versionString"
 
+ ^'4.17.2'!
- ^'4.17.1'!