David T. Lewis uploaded a new version of VMMaker to project VM Maker: http://source.squeak.org/VMMaker/VMMaker-dtl.411.mcz ==================== Summary ==================== Name: VMMaker-dtl.411 Author: dtl Time: 29 February 2020, 6:15:00.474 pm UUID: 1c47be83-c009-41bc-a567-1dde81aa4f99 Ancestors: VMMaker-dtl.410 Misc cleanups, remove unreferenced method, eliminate code duplication, fix a comment typo. =============== Diff against VMMaker-dtl.410 =============== Item was removed: - ----- Method: ContextInterpreter>>initialImageFormatVersion (in category 'image save/restore') ----- - initialImageFormatVersion - "This is the image format version that was saved to in the previous image snapshot. - The interpreter checks this value at image load time to determine if it is able to load - and run the image file. When the image is next saved, it will be saved using the current - imageFormatVersion, which may be different from imageFormatInitialVersion. - Selector name chosen to avoid conflict with variable declaration in generated code." - ^imageFormatInitialVersion! Item was changed: ----- Method: ContextInterpreter>>memoryHeaderState: (in category 'primitive support') ----- memoryHeaderState: dataSize "Answer current interpreter and object memory state information." | splObjsOop oopStart headerSize results hash displayExtent | + "see ContextInterpreter>>writeImageFileIO:" - "seee ContextInterpreter>>writeImageFileIO:" "self putLong: (self imageFormatVersion) toFile: f. self putLong: headerSize toFile: f. self putLong: imageBytes toFile: f. self putLong: (objectMemory startOfMemory) toFile: f. self putLong: objectMemory getSpecialObjectsOop toFile: f. self putLong: objectMemory getLastHash toFile: f. self putLong: (self ioScreenSize) toFile: f. self putLong: fullScreenFlag toFile: f. self putLong: extraVMMemory toFile: f. 1 to: 7 do: [:i | self putLong: 0 toFile: f]." "fill remaining header words with zeros" headerSize := 16 * objectMemory bytesPerWord. "header size in bytes; do not change!!" oopStart := objectMemory startOfMemory. splObjsOop := objectMemory getSpecialObjectsOop. hash := objectMemory integerObjectOf: objectMemory getLastHash. "self ioScreenSize." "fullScreenFlag" "extraVMMemory" "Pad the rest of the header." "7 timesRepeat: [self putLong: 0 toFile: file]." InterpreterProxy pushRemappableOop: (objectMemory instantiateClass: (objectMemory classArray) indexableSize: 16). "results array" displayExtent := self displayExtent: self ioScreenSize. "may trigger GC" results := interpreterProxy popRemappableOop. objectMemory storePointer: 0 ofObject: results withValue: (objectMemory integerObjectOf: self imageFormatVersion). objectMemory storePointer: 1 ofObject: results withValue: (objectMemory integerObjectOf: headerSize). objectMemory storePointer: 2 ofObject: results withValue: (self positive64BitIntegerFor: dataSize). objectMemory storePointer: 3 ofObject: results withValue: (objectMemory integerObjectOf: oopStart). objectMemory storePointer: 4 ofObject: results withValue: (objectMemory integerObjectOf: splObjsOop). objectMemory storePointer: 5 ofObject: results withValue: (objectMemory integerObjectOf: hash). objectMemory storePointer: 6 ofObject: results withValue: displayExtent. objectMemory storePointer: 7 ofObject: results withValue: (objectMemory integerObjectOf: fullScreenFlag).. objectMemory storePointer: 8 ofObject: results withValue: (objectMemory integerObjectOf: extraVMMemory).. objectMemory storePointer: 9 ofObject: results withValue: (objectMemory integerObjectOf: 0). objectMemory storePointer: 10 ofObject: results withValue: (objectMemory integerObjectOf: 0). objectMemory storePointer: 11 ofObject: results withValue: (objectMemory integerObjectOf: 0). objectMemory storePointer: 12 ofObject: results withValue: (objectMemory integerObjectOf: 0). objectMemory storePointer: 13 ofObject: results withValue: (objectMemory integerObjectOf: 0). objectMemory storePointer: 14 ofObject: results withValue: (objectMemory integerObjectOf: 0). objectMemory storePointer: 15 ofObject: results withValue: (objectMemory integerObjectOf: 0). ^ results.! Item was changed: ----- Method: ContextInterpreter>>swapBytesAndPrepareToInterpret:oldBaseAddr: (in category 'snapshot resume') ----- swapBytesAndPrepareToInterpret: swapBytes oldBaseAddr: oldBaseAddr "An object memory has been loaded from a snapshot. Prepare it to be executed by an interpreter." | bytesToShift | objectMemory headerTypeBytesAt: 0 put: objectMemory bytesPerWord * 2. "3-word header (type 0)" objectMemory headerTypeBytesAt: 1 put: objectMemory bytesPerWord. "2-word header (type 1)" objectMemory headerTypeBytesAt: 2 put: 0. "free chunk (type 2)" objectMemory headerTypeBytesAt: 3 put: 0. "1-word header (type 3)" swapBytes ifTrue: [self reverseBytesInImage]. "compute difference between old and new memory base addresses" bytesToShift := objectMemory startOfMemory - oldBaseAddr. self initializeInterpreter: bytesToShift. "adjusts all oops to new location" self isBigEnder. "work out the machine endianness and cache the answer" + (imageFormatInitialVersion bitAnd: 1) = 1 - (self initialImageFormatVersion bitAnd: 1) = 1 ifTrue: ["Low order bit set, indicating that the image was saved from a StackInterpreter (Cog) VM. Storage of all Float objects must be returned to older object memory format." self normalizeFloatOrderingInImage]. ! Item was changed: ----- Method: ContextInterpreter>>writeImageFileIO: (in category 'image save/restore') ----- writeImageFileIO: imageBytes + ^self writeImageFileIO: imageBytes embedded: true - | headerStart headerSize f bytesWritten sCWIfn okToWrite | - <var: #f type: 'sqImageFile'> - <var: #headerStart type: 'squeakFileOffsetType '> - <var: #sCWIfn type: 'void *'> - - "If the security plugin can be loaded, use it to check for write permission. - If not, assume it's ok" - sCWIfn := self ioLoadFunction: 'secCanWriteImage' From: 'SecurityPlugin'. - sCWIfn ~= 0 ifTrue:[okToWrite := self cCode: '((sqInt (*)(void))sCWIfn)()'. - okToWrite ifFalse:[^self primitiveFail]]. - - "local constants" - headerStart := 0. - headerSize := 16 * objectMemory bytesPerWord. "header size in bytes; do not change!!" - - f := self cCode: 'sqImageFileOpen(imageName, "wb")'. - f = nil ifTrue: [ - "could not open the image file for writing" - self success: false. - ^ nil]. - - headerStart := self cCode: 'sqImageFileStartLocation(f,imageName,headerSize+imageBytes)'. - self cCode: '/* Note: on Unix systems one could put an exec command here, padded to 512 bytes */'. - "position file to start of header" - self sqImageFile: f Seek: headerStart. - - self putLong: (self imageFormatVersion) toFile: f. - self putLong: headerSize toFile: f. - self putLong: imageBytes toFile: f. - self putLong: (objectMemory startOfMemory) toFile: f. - self putLong: objectMemory getSpecialObjectsOop toFile: f. - self putLong: objectMemory getLastHash toFile: f. - self putLong: (self ioScreenSize) toFile: f. - self putLong: fullScreenFlag toFile: f. - self putLong: extraVMMemory toFile: f. - 1 to: 7 do: [:i | self putLong: 0 toFile: f]. "fill remaining header words with zeros" - self successful ifFalse: [ - "file write or seek failure" - self cCode: 'sqImageFileClose(f)'. - ^ nil]. - - "position file after the header" - self sqImageFile: f Seek: headerStart + headerSize. - - "write the image data" - bytesWritten := self - sqImage: (objectMemory pointerForOop: objectMemory getMemory) - write: f - size: (self cCode: 'sizeof(unsigned char)') - length: imageBytes. - self success: bytesWritten = imageBytes. - self cCode: 'sqImageFileClose(f)'. - ! Item was changed: ----- Method: StackInterpreter>>writeImageFileIO: (in category 'image save/restore') ----- writeImageFileIO: imageBytes + ^self writeImageFileIO: imageBytes embedded: true - | headerStart headerSize f bytesWritten sCWIfn okToWrite memStart | - <var: #f type: 'sqImageFile'> - <var: #headerStart type: 'squeakFileOffsetType '> - <var: #sCWIfn type: 'void *'> - - "If the security plugin can be loaded, use it to check for write permission. - If not, assume it's ok" - sCWIfn := self ioLoadFunction: 'secCanWriteImage' From: 'SecurityPlugin'. - sCWIfn ~= 0 ifTrue: - [okToWrite := self cCode: '((sqInt (*)(void))sCWIfn)()'. - okToWrite ifFalse:[^self primitiveFail]]. - - "local constants" - headerStart := 0. - headerSize := 64. "header size in bytes; do not change!!" - - f := self cCode: 'sqImageFileOpen(imageName, "wb")'. - f = nil ifTrue: "could not open the image file for writing" - [^self primitiveFail]. - - headerStart := self cCode: 'sqImageFileStartLocation(f,imageName,headerSize+imageBytes)'. - self cCode: '/* Note: on Unix systems one could put an exec command here, padded to 512 bytes */'. - "position file to start of header" - self sqImageFile: f Seek: headerStart. - - self putLong: self imageFormatVersion toFile: f. - self putLong: headerSize toFile: f. - self putLong: imageBytes toFile: f. - self putLong: objectMemory startOfMemory toFile: f. - self putLong: objectMemory getSpecialObjectsOop toFile: f. - self putLong: objectMemory newObjectHash toFile: f. - self putLong: self ioScreenSize toFile: f. - self putLong: self getImageHeaderFlags toFile: f. - self putLong: extraVMMemory toFile: f. - self putShort: desiredNumStackPages toFile: f. - self putShort: self unknownShortOrCodeSizeInKs toFile: f. - self putLong: desiredEdenBytes toFile: f. - self putShort: (maxExtSemTabSizeSet ifTrue: [self ioGetMaxExtSemTableSize] ifFalse: [0]) toFile: f. - self putShort: 0 toFile: f. - 1 to: 4 do: [:i | self putLong: 0 toFile: f]. "fill remaining header words with zeros" - self successful ifFalse: [ - "file write or seek failure" - self cCode: 'sqImageFileClose(f)'. - ^ nil]. - - "position file after the header" - self sqImageFile: f Seek: headerStart + headerSize. - - "write the image data" - memStart := objectMemory startOfMemory. - bytesWritten := self cCode: 'sqImageFileWrite(pointerForOop(memStart), sizeof(unsigned char), imageBytes, f)'. - self success: bytesWritten = imageBytes. - self touch: memStart. - self cCode: 'sqImageFileClose(f)' ! |
Free forum by Nabble | Edit this page |