David T. Lewis uploaded a new version of VMMaker to project VM Maker: http://source.squeak.org/VMMaker/VMMaker.oscog-dtl.3123.mcz
==================== Summary ====================
Name: VMMaker.oscog-dtl.3123 Author: dtl Time: 26 December 2021, 12:55:15.357105 pm UUID: a0d4db62-a6ac-4d9c-ba51-5eec2ce0c415 Ancestors: VMMaker.oscog-eem.3122
Support image formats 68533 and 7033. Let the image inform the VM that alternate bytecodes either are or are not in use, and remember the setting when writing or reading the image format number in a shapshot file header. Also support testing the current value of multipleBytecodeSetsActive, and listing the encoder names of supported bytecode sets.
Adds two primitives:
primitiveMultipleBytecodeSetsActive "Given one boolean parameter, set multipleBytecodeSetsActive to inform the VM that alternate bytecode sets such as SistaV1 are now in use and that the image format number should be updated accordingly. With zero parameters, answer the current value of multipleBytecodeSetsActive."
primitiveBytecodeSetsAvailable "Answer the encoder names for the supported bytecode sets."
=============== Diff against VMMaker.oscog-eem.3122 ===============
Item was changed: VMClass subclass: #InterpreterPrimitives + instanceVariableNames: 'objectMemory messageSelector argumentCount newMethod primFailCode secondaryErrorCode exceptionPC inFFIFlags profileMethod profileProcess profileSemaphore nextProfileTick preemptionYields sHEAFn ffiExceptionResponse eventTraceMask multipleBytecodeSetsActive' - instanceVariableNames: 'objectMemory messageSelector argumentCount newMethod primFailCode secondaryErrorCode exceptionPC inFFIFlags profileMethod profileProcess profileSemaphore nextProfileTick preemptionYields sHEAFn ffiExceptionResponse eventTraceMask' classVariableNames: 'CrossedX EndOfRun MillisecondClockMask' poolDictionaries: 'VMBasicConstants VMBytecodeConstants VMMethodCacheConstants VMObjectIndices VMSqueakClassIndices VMStackFrameOffsets' category: 'VMMaker-Interpreter'!
!InterpreterPrimitives commentStamp: 'eem 9/23/2021 13:20' prior: 0! InterpreterPrimitives implements most of the VM's core primitives. It is the root of the interpreter hierarchy so as to share the core primitives amongst the varioius interpreters.
Instance Variables argumentCount <Integer> eventTraceMask <Integer> exceptionPC <Integer> ffiExceptionResponse <Integer> inFFIFlags <Integer> messageSelector <Integer> newMethod <Integer> nextProfileTick <Integer> objectMemory <ObjectMemory> (simulation only) preemptionYields <Boolean> primFailCode <Integer> secondaryErrorCode <Integer> profileMethod <Integer> profileProcess <Integer> profileSemaphore <Integer> sHEAFn <Integer>
argumentCount - the number of arguments of the current message
eventTraceMask - a bit mask corresponding to the Event type codes in sq.h that decides what events are printed in primitiveGetNextEvent
exceptionPC - the pc of an exception for an exception reporting primitive failure such as PrimErrFFIException
ffiExceptionResponse - controls system response to exceptions during FFI calls. See primitiveFailForFFIException:at:
inFFIFlags - flags recording currently only whether the system is in an FFI call
messageSelector - the oop of the selector of the current message
newMethod - the oop of the result of looking up the current message
nextProfileTick - the millisecond clock value of the next profile tick (if profiling is in effect)
objectMemory - the memory manager and garbage collector that manages the heap
preemptionYields - a boolean controlling the process primitives. If true (old, incorrect, blue-book semantics) a preempted process is sent to the back of its run-queue. If false, a process preempted by a higher-priority process is put back at the head of its run queue, hence preserving cooperative scheduling within priorities.
primFailCode - primitive success/failure flag, 0 for success, otherwise the reason code for failure
profileMethod - the primitive method active when the last profile sample was taken (if any)
profileProcess - the process active when the last profile sample was taken profileSemaphore - the semaphore to be signalled when a profile sample is taken; if nil disables profiling
secondaryErrorCode - a 64-bit value settable for clonable primitive failures (PrimErrOSError, PrimErrFFIException et al)
profileMethod - the oop of the method at the time nextProfileTick was reached
profileProcess - the oop of the activeProcess at the time nextProfileTick was reached
profileSemaphore - the oop of the semaphore to signal when nextProfileTick is reached
secondaryErrorCode - an additional value associated with various primitive failures
sHEAFn - the function to call to check if access to the envronment should be granted to primitiveGetenv!
Item was added: + ----- Method: InterpreterPrimitives>>primitiveBytecodeSetsAvailable (in category 'other primitives') ----- + primitiveBytecodeSetsAvailable + "Answer the encoder names for the supported bytecode sets." + <export: true> + | encoderNames | + argumentCount >0 ifTrue: + [^self primitiveFailFor: PrimErrBadNumArgs]. + encoderNames := self instantiateClass: self classArray indexableSize: 3. + self storePointer: 0 ofObject: encoderNames withValue: (objectMemory stringForCString: 'EncoderForV3'). + self storePointer: 1 ofObject: encoderNames withValue: (objectMemory stringForCString: 'EncoderForV3PlusClosures'). + self storePointer: 2 ofObject: encoderNames withValue: (objectMemory stringForCString: 'EncoderForSistaV1'). + self pop: 1 thenPush: encoderNames. + !
Item was added: + ----- Method: InterpreterPrimitives>>primitiveMultipleBytecodeSetsActive (in category 'other primitives') ----- + primitiveMultipleBytecodeSetsActive + "Given one boolean parameter, set multipleBytecodeSetsActive to inform + the VM that alternate bytecode sets such as SistaV1 are now in use and + that the image format number should be updated accordingly. With zero + parameters, answer the current value of multipleBytecodeSetsActive." + + <export: true> + argumentCount >1 ifTrue: + [^self primitiveFailFor: PrimErrBadNumArgs]. + argumentCount = 1 + ifTrue: [self stackTop = objectMemory trueObject + ifTrue: [self cppIf: MULTIPLEBYTECODESETS + ifTrue: [multipleBytecodeSetsActive := true] + ifFalse: [^self primitiveFailFor: PrimErrUnsupported]] + ifFalse: [self stackTop = objectMemory falseObject + ifTrue: [multipleBytecodeSetsActive := false] + ifFalse:[^self primitiveFailFor: PrimErrBadArgument]]]. + multipleBytecodeSetsActive + ifTrue: [self pop: argumentCount + 1 thenPush: objectMemory trueObject] + ifFalse: [self pop: argumentCount + 1 thenPush: objectMemory falseObject]. + !
Item was changed: InterpreterPrimitives subclass: #StackInterpreter (excessive size, no diff calculated)
Item was changed: ----- Method: StackInterpreter class>>initializeMiscConstants (in category 'initialization') ----- initializeMiscConstants
super initializeMiscConstants. STACKVM := true.
"These flags identify a GC operation (& hence a reason to leak check), or just operations the leak checker can be run for." GCModeFull := 1. "stop-the-world global GC" GCModeNewSpace := 2. "Spur's scavenge, or V3's incremental" GCModeIncremental := 4. "incremental global gc (Dijkstra tri-colour marking); as yet unimplemented" GCModeBecome := 8. "v3 post-become sweeping/Spur forwarding" GCCheckImageSegment := 16. "just a flag for leak checking image segments" GCCheckFreeSpace := 32. "just a flag for leak checking free space; Spur only" GCCheckShorten := 64. "just a flag for leak checking object shortening operations; Spur only" GCCheckPrimCall := 128. "just a flag for leak checking external primitive calls"
StackPageTraceInvalid := -1. StackPageUnreached := 0. StackPageReachedButUntraced := 1. StackPageTraced := 2.
DumpStackOnLowSpace := 0. MillisecondClockMask := 16r1FFFFFFF. "Note: The external primitive table should actually be dynamically sized but for the sake of inferior platforms (e.g., Mac :-) who cannot allocate memory in any reasonable way, we keep it static (and cross our fingers...)" MaxExternalPrimitiveTableSize := 4096. "entries"
MaxJumpBuf := 32. "max. callback depth" FailImbalancedPrimitives := InitializationOptions at: #FailImbalancedPrimitives ifAbsentPut: [true]. EnforceAccessControl := InitializationOptions at: #EnforceAccessControl ifAbsent: [true].
ReturnToInterpreter := 1. "setjmp/longjmp code."
"Because of a hack with callbacks in the non-threaded VM they must not conflct with the VM's tag bits." DisownVMForFFICall := 16. + DisownVMForThreading := 32. + + "The multiple bytecodes active bit in the image format number" + MultipleBytecodeSetsBitmask := 512. - DisownVMForThreading := 32 !
Item was changed: ----- Method: StackInterpreter>>readableFormat: (in category 'image save/restore') ----- readableFormat: imageVersion "Anwer true if images of the given format are readable by this interpreter. Allows a virtual machine to accept selected older image formats." <api> + ^ (self imageFormatVersion = (imageVersion bitAnd: ( -1 - MultipleBytecodeSetsBitmask))) "Ignore multiple bytecode support identifier" + or: [objectMemory hasSpurMemoryManagerAPI not "No compatibility version for Spur as yet" - ^imageVersion = self imageFormatVersion "Float words in platform-order" - or: [objectMemory hasSpurMemoryManagerAPI not "No compatibility version for Spur as yet" and: [imageVersion = self imageFormatCompatibilityVersion]] "Float words in BigEndian order"!
Item was changed: ----- Method: StackInterpreter>>writeImageFileIO (in category 'image save/restore') ----- writeImageFileIO "Write the image header and heap contents to imageFile for snapshot. c.f. writeImageFileIOSimulation. The game below is to maintain 64-bit alignment for all putLong:toFile: occurrences." <inline: #never> | imageName headerStart headerSize f imageBytes bytesWritten sCWIfn okToWrite | <var: 'f' type: #sqImageFile> <var: 'headerStart' type: #squeakFileOffsetType> <var: 'sCWIfn' type: #'void *'> <var: 'imageName' declareC: 'extern char imageName[]'>
self cCode: [] inSmalltalk: [imageName := 'sooth compiler'. ^self writeImageFileIOSimulation].
"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 := objectMemory wordSize * 16. "64 or 128; header size in bytes; do not change!!"
f := self sqImageFile: imageName Open: 'wb'. (self invalidSqImageFile: f) ifTrue: "could not open the image file for writing" [^self primitiveFailFor: PrimErrOperationFailed].
imageBytes := objectMemory imageSizeToWrite. headerStart := self sqImage: f File: imageName StartLocation: 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.
+ multipleBytecodeSetsActive + ifTrue: [self putWord32: (self imageFormatVersion bitOr: MultipleBytecodeSetsBitmask) toFile: f] + ifFalse: [self putWord32: self imageFormatVersion toFile: f]. - self putWord32: self imageFormatVersion toFile: f. self putWord32: headerSize toFile: f. self putLong: imageBytes toFile: f. self putLong: objectMemory baseAddressOfImage toFile: f. self putLong: objectMemory specialObjectsOop toFile: f. self putLong: objectMemory newObjectHash toFile: f. self putLong: self getSnapshotScreenSize toFile: f. self putLong: self getImageHeaderFlags toFile: f. self putWord32: extraVMMemory toFile: f. self putShort: desiredNumStackPages toFile: f. self putShort: self unknownShortOrCodeSizeInKs toFile: f. self putWord32: desiredEdenBytes toFile: f. self putShort: (maxExtSemTabSizeSet ifTrue: [self ioGetMaxExtSemTableSize] ifFalse: [0]) toFile: f. self putShort: the2ndUnknownShort toFile: f. objectMemory hasSpurMemoryManagerAPI ifTrue: [self putLong: objectMemory firstSegmentBytes toFile: f. self putLong: objectMemory bytesLeftInOldSpace toFile: f. 2 timesRepeat: [self putLong: 0 toFile: f] "Pad the rest of the header."] ifFalse: [4 timesRepeat: [self putLong: 0 toFile: f]]. "Pad the rest of the header."
objectMemory wordSize = 8 ifTrue: [3 timesRepeat: [self putLong: 0 toFile: f]]. "Pad the rest of the header."
self assert: headerStart + headerSize = (self sqImageFilePosition: f). "position file after the header" self sqImageFile: f Seek: headerStart + headerSize.
self successful ifFalse: "file write or seek failure" [self sqImageFileClose: f. ^nil].
"write the image data" objectMemory hasSpurMemoryManagerAPI ifTrue: [bytesWritten := objectMemory writeImageSegmentsToFile: f] ifFalse: [bytesWritten := self sq: (self pointerForOop: objectMemory baseAddressOfImage) Image: (self sizeof: #char) File: imageBytes Write: f]. self success: bytesWritten = imageBytes. self sqImageFileClose: f!
My apologies, I intended this for the VMMaker inbox. I will move it there now.
Dave
On Sun, Dec 26, 2021 at 08:22:48PM +0000, commits@source.squeak.org wrote:
David T. Lewis uploaded a new version of VMMaker to project VM Maker: http://source.squeak.org/VMMaker/VMMaker.oscog-dtl.3123.mcz
==================== Summary ====================
Name: VMMaker.oscog-dtl.3123 Author: dtl Time: 26 December 2021, 12:55:15.357105 pm UUID: a0d4db62-a6ac-4d9c-ba51-5eec2ce0c415 Ancestors: VMMaker.oscog-eem.3122
Support image formats 68533 and 7033. Let the image inform the VM that alternate bytecodes either are or are not in use, and remember the setting when writing or reading the image format number in a shapshot file header. Also support testing the current value of multipleBytecodeSetsActive, and listing the encoder names of supported bytecode sets.
Adds two primitives:
primitiveMultipleBytecodeSetsActive "Given one boolean parameter, set multipleBytecodeSetsActive to inform the VM that alternate bytecode sets such as SistaV1 are now in use and that the image format number should be updated accordingly. With zero parameters, answer the current value of multipleBytecodeSetsActive."
primitiveBytecodeSetsAvailable "Answer the encoder names for the supported bytecode sets."
=============== Diff against VMMaker.oscog-eem.3122 ===============
Item was changed: VMClass subclass: #InterpreterPrimitives
- instanceVariableNames: 'objectMemory messageSelector argumentCount newMethod primFailCode secondaryErrorCode exceptionPC inFFIFlags profileMethod profileProcess profileSemaphore nextProfileTick preemptionYields sHEAFn ffiExceptionResponse eventTraceMask multipleBytecodeSetsActive'
instanceVariableNames: 'objectMemory messageSelector argumentCount newMethod primFailCode secondaryErrorCode exceptionPC inFFIFlags profileMethod profileProcess profileSemaphore nextProfileTick preemptionYields sHEAFn ffiExceptionResponse eventTraceMask' classVariableNames: 'CrossedX EndOfRun MillisecondClockMask' poolDictionaries: 'VMBasicConstants VMBytecodeConstants VMMethodCacheConstants VMObjectIndices VMSqueakClassIndices VMStackFrameOffsets' category: 'VMMaker-Interpreter'!
!InterpreterPrimitives commentStamp: 'eem 9/23/2021 13:20' prior: 0! InterpreterPrimitives implements most of the VM's core primitives. It is the root of the interpreter hierarchy so as to share the core primitives amongst the varioius interpreters.
Instance Variables argumentCount <Integer> eventTraceMask <Integer> exceptionPC <Integer> ffiExceptionResponse <Integer> inFFIFlags <Integer> messageSelector <Integer> newMethod <Integer> nextProfileTick <Integer> objectMemory <ObjectMemory> (simulation only) preemptionYields <Boolean> primFailCode <Integer> secondaryErrorCode <Integer> profileMethod <Integer> profileProcess <Integer> profileSemaphore <Integer> sHEAFn <Integer>
argumentCount
- the number of arguments of the current message
eventTraceMask
- a bit mask corresponding to the Event type codes in sq.h that decides what events are printed in primitiveGetNextEvent
exceptionPC
- the pc of an exception for an exception reporting primitive failure such as PrimErrFFIException
ffiExceptionResponse
- controls system response to exceptions during FFI calls. See primitiveFailForFFIException:at:
inFFIFlags
- flags recording currently only whether the system is in an FFI call
messageSelector
- the oop of the selector of the current message
newMethod
- the oop of the result of looking up the current message
nextProfileTick
- the millisecond clock value of the next profile tick (if profiling is in effect)
objectMemory
- the memory manager and garbage collector that manages the heap
preemptionYields
- a boolean controlling the process primitives. If true (old, incorrect, blue-book semantics) a preempted process is sent to the back of its run-queue. If false, a process preempted by a higher-priority process is put back at the head of its run queue, hence preserving cooperative scheduling within priorities.
primFailCode
- primitive success/failure flag, 0 for success, otherwise the reason code for failure
profileMethod
- the primitive method active when the last profile sample was taken (if any)
profileProcess
- the process active when the last profile sample was taken
profileSemaphore
- the semaphore to be signalled when a profile sample is taken; if nil disables profiling
secondaryErrorCode
- a 64-bit value settable for clonable primitive failures (PrimErrOSError, PrimErrFFIException et al)
profileMethod
- the oop of the method at the time nextProfileTick was reached
profileProcess
- the oop of the activeProcess at the time nextProfileTick was reached
profileSemaphore
- the oop of the semaphore to signal when nextProfileTick is reached
secondaryErrorCode
- an additional value associated with various primitive failures
sHEAFn
- the function to call to check if access to the envronment should be granted to primitiveGetenv!
Item was added:
- ----- Method: InterpreterPrimitives>>primitiveBytecodeSetsAvailable (in category 'other primitives') -----
- primitiveBytecodeSetsAvailable
- "Answer the encoder names for the supported bytecode sets."
- <export: true>
- | encoderNames |
- argumentCount >0 ifTrue:
[^self primitiveFailFor: PrimErrBadNumArgs].
- encoderNames := self instantiateClass: self classArray indexableSize: 3.
- self storePointer: 0 ofObject: encoderNames withValue: (objectMemory stringForCString: 'EncoderForV3').
- self storePointer: 1 ofObject: encoderNames withValue: (objectMemory stringForCString: 'EncoderForV3PlusClosures').
- self storePointer: 2 ofObject: encoderNames withValue: (objectMemory stringForCString: 'EncoderForSistaV1').
- self pop: 1 thenPush: encoderNames.
- !
Item was added:
- ----- Method: InterpreterPrimitives>>primitiveMultipleBytecodeSetsActive (in category 'other primitives') -----
- primitiveMultipleBytecodeSetsActive
- "Given one boolean parameter, set multipleBytecodeSetsActive to inform
the VM that alternate bytecode sets such as SistaV1 are now in use and
- that the image format number should be updated accordingly. With zero
- parameters, answer the current value of multipleBytecodeSetsActive."
- <export: true>
- argumentCount >1 ifTrue:
[^self primitiveFailFor: PrimErrBadNumArgs].
- argumentCount = 1
ifTrue: [self stackTop = objectMemory trueObject
ifTrue: [self cppIf: MULTIPLEBYTECODESETS
ifTrue: [multipleBytecodeSetsActive := true]
ifFalse: [^self primitiveFailFor: PrimErrUnsupported]]
ifFalse: [self stackTop = objectMemory falseObject
ifTrue: [multipleBytecodeSetsActive := false]
ifFalse:[^self primitiveFailFor: PrimErrBadArgument]]].
- multipleBytecodeSetsActive
ifTrue: [self pop: argumentCount + 1 thenPush: objectMemory trueObject]
ifFalse: [self pop: argumentCount + 1 thenPush: objectMemory falseObject].
- !
Item was changed: InterpreterPrimitives subclass: #StackInterpreter (excessive size, no diff calculated)
Item was changed: ----- Method: StackInterpreter class>>initializeMiscConstants (in category 'initialization') ----- initializeMiscConstants
super initializeMiscConstants. STACKVM := true.
"These flags identify a GC operation (& hence a reason to leak check), or just operations the leak checker can be run for." GCModeFull := 1. "stop-the-world global GC" GCModeNewSpace := 2. "Spur's scavenge, or V3's incremental" GCModeIncremental := 4. "incremental global gc (Dijkstra tri-colour marking); as yet unimplemented" GCModeBecome := 8. "v3 post-become sweeping/Spur forwarding" GCCheckImageSegment := 16. "just a flag for leak checking image segments" GCCheckFreeSpace := 32. "just a flag for leak checking free space; Spur only" GCCheckShorten := 64. "just a flag for leak checking object shortening operations; Spur only" GCCheckPrimCall := 128. "just a flag for leak checking external primitive calls"
StackPageTraceInvalid := -1. StackPageUnreached := 0. StackPageReachedButUntraced := 1. StackPageTraced := 2.
DumpStackOnLowSpace := 0. MillisecondClockMask := 16r1FFFFFFF. "Note: The external primitive table should actually be dynamically sized but for the sake of inferior platforms (e.g., Mac :-) who cannot allocate memory in any reasonable way, we keep it static (and cross our fingers...)" MaxExternalPrimitiveTableSize := 4096. "entries"
MaxJumpBuf := 32. "max. callback depth" FailImbalancedPrimitives := InitializationOptions at: #FailImbalancedPrimitives ifAbsentPut: [true]. EnforceAccessControl := InitializationOptions at: #EnforceAccessControl ifAbsent: [true].
ReturnToInterpreter := 1. "setjmp/longjmp code."
"Because of a hack with callbacks in the non-threaded VM they must not conflct with the VM's tag bits." DisownVMForFFICall := 16.
- DisownVMForThreading := 32.
- "The multiple bytecodes active bit in the image format number"
- MultipleBytecodeSetsBitmask := 512.
- DisownVMForThreading := 32 !
Item was changed: ----- Method: StackInterpreter>>readableFormat: (in category 'image save/restore') ----- readableFormat: imageVersion "Anwer true if images of the given format are readable by this interpreter. Allows a virtual machine to accept selected older image formats."
<api> + ^ (self imageFormatVersion = (imageVersion bitAnd: ( -1 - MultipleBytecodeSetsBitmask))) "Ignore multiple bytecode support identifier" + or: [objectMemory hasSpurMemoryManagerAPI not "No compatibility version for Spur as yet" - ^imageVersion = self imageFormatVersion "Float words in platform-order" - or: [objectMemory hasSpurMemoryManagerAPI not "No compatibility version for Spur as yet" and: [imageVersion = self imageFormatCompatibilityVersion]] "Float words in BigEndian order"!
Item was changed: ----- Method: StackInterpreter>>writeImageFileIO (in category 'image save/restore') ----- writeImageFileIO "Write the image header and heap contents to imageFile for snapshot. c.f. writeImageFileIOSimulation. The game below is to maintain 64-bit alignment for all putLong:toFile: occurrences." <inline: #never> | imageName headerStart headerSize f imageBytes bytesWritten sCWIfn okToWrite | <var: 'f' type: #sqImageFile> <var: 'headerStart' type: #squeakFileOffsetType> <var: 'sCWIfn' type: #'void *'> <var: 'imageName' declareC: 'extern char imageName[]'>
self cCode: [] inSmalltalk: [imageName := 'sooth compiler'. ^self writeImageFileIOSimulation].
"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 := objectMemory wordSize * 16. "64 or 128; header size in bytes; do not change!!"
f := self sqImageFile: imageName Open: 'wb'. (self invalidSqImageFile: f) ifTrue: "could not open the image file for writing" [^self primitiveFailFor: PrimErrOperationFailed].
imageBytes := objectMemory imageSizeToWrite. headerStart := self sqImage: f File: imageName StartLocation: 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.
- multipleBytecodeSetsActive
ifTrue: [self putWord32: (self imageFormatVersion bitOr: MultipleBytecodeSetsBitmask) toFile: f]
ifFalse: [self putWord32: self imageFormatVersion toFile: f].
self putWord32: self imageFormatVersion toFile: f. self putWord32: headerSize toFile: f. self putLong: imageBytes toFile: f. self putLong: objectMemory baseAddressOfImage toFile: f. self putLong: objectMemory specialObjectsOop toFile: f. self putLong: objectMemory newObjectHash toFile: f. self putLong: self getSnapshotScreenSize toFile: f. self putLong: self getImageHeaderFlags toFile: f. self putWord32: extraVMMemory toFile: f. self putShort: desiredNumStackPages toFile: f. self putShort: self unknownShortOrCodeSizeInKs toFile: f. self putWord32: desiredEdenBytes toFile: f. self putShort: (maxExtSemTabSizeSet ifTrue: [self ioGetMaxExtSemTableSize] ifFalse: [0]) toFile: f. self putShort: the2ndUnknownShort toFile: f. objectMemory hasSpurMemoryManagerAPI ifTrue: [self putLong: objectMemory firstSegmentBytes toFile: f. self putLong: objectMemory bytesLeftInOldSpace toFile: f. 2 timesRepeat: [self putLong: 0 toFile: f] "Pad the rest of the header."] ifFalse: [4 timesRepeat: [self putLong: 0 toFile: f]]. "Pad the rest of the header."
objectMemory wordSize = 8 ifTrue: [3 timesRepeat: [self putLong: 0 toFile: f]]. "Pad the rest of the header."
self assert: headerStart + headerSize = (self sqImageFilePosition: f). "position file after the header" self sqImageFile: f Seek: headerStart + headerSize.
self successful ifFalse: "file write or seek failure" [self sqImageFileClose: f. ^nil].
"write the image data" objectMemory hasSpurMemoryManagerAPI ifTrue: [bytesWritten := objectMemory writeImageSegmentsToFile: f] ifFalse: [bytesWritten := self sq: (self pointerForOop: objectMemory baseAddressOfImage) Image: (self sizeof: #char) File: imageBytes Write: f]. self success: bytesWritten = imageBytes. self sqImageFileClose: f!
Hi Dave,
On Sun, Dec 26, 2021 at 12:35 PM David T. Lewis lewis@mail.msen.com wrote:
My apologies, I intended this for the VMMaker inbox. I will move it there now.
no problem.
On Sun, Dec 26, 2021 at 12:23 PM commits@source.squeak.org wrote:
David T. Lewis uploaded a new version of VMMaker to project VM Maker: http://source.squeak.org/VMMaker/VMMaker.oscog-dtl.3123.mcz
==================== Summary ====================
Name: VMMaker.oscog-dtl.3123 Author: dtl Time: 26 December 2021, 12:55:15.357105 pm UUID: a0d4db62-a6ac-4d9c-ba51-5eec2ce0c415 Ancestors: VMMaker.oscog-eem.3122
Support image formats 68533 and 7033. Let the image inform the VM that alternate bytecodes either are or are not in use, and remember the setting when writing or reading the image format number in a shapshot file header. Also support testing the current value of multipleBytecodeSetsActive, and listing the encoder names of supported bytecode sets.
This is cool. But let me suggest...
Item was added:
- ----- Method: InterpreterPrimitives>>primitiveBytecodeSetsAvailable (in
category 'other primitives') -----
- primitiveBytecodeSetsAvailable
"Answer the encoder names for the supported bytecode sets."
<export: true>
| encoderNames |
argumentCount >0 ifTrue:
[^self primitiveFailFor: PrimErrBadNumArgs].
encoderNames := self instantiateClass: self classArray
indexableSize: 3.
self storePointer: 0 ofObject: encoderNames withValue:
(objectMemory stringForCString: 'EncoderForV3').
self storePointer: 1 ofObject: encoderNames withValue:
(objectMemory stringForCString: 'EncoderForV3PlusClosures').
self storePointer: 2 ofObject: encoderNames withValue:
(objectMemory stringForCString: 'EncoderForSistaV1').
self pop: 1 thenPush: encoderNames.
- !
use self methodReturnValue: encoderNames instead of self pop: 1 thenPush: encoderNames.
Item was added:
- ----- Method: InterpreterPrimitives>>primitiveMultipleBytecodeSetsActive
(in category 'other primitives') -----
- primitiveMultipleBytecodeSetsActive
"Given one boolean parameter, set multipleBytecodeSetsActive to
inform
the VM that alternate bytecode sets such as SistaV1 are now in
use and
that the image format number should be updated accordingly. With
zero
parameters, answer the current value of
multipleBytecodeSetsActive."
<export: true>
argumentCount >1 ifTrue:
[^self primitiveFailFor: PrimErrBadNumArgs].
argumentCount = 1
ifTrue: [self stackTop = objectMemory trueObject
ifTrue: [self cppIf: MULTIPLEBYTECODESETS
ifTrue: [multipleBytecodeSetsActive :=
true]
ifFalse: [^self primitiveFailFor:
PrimErrUnsupported]]
ifFalse: [self stackTop = objectMemory falseObject
ifTrue: [multipleBytecodeSetsActive :=
false]
ifFalse:[^self primitiveFailFor:
PrimErrBadArgument]]].
multipleBytecodeSetsActive
ifTrue: [self pop: argumentCount + 1 thenPush:
objectMemory trueObject]
ifFalse: [self pop: argumentCount + 1 thenPush:
objectMemory falseObject].
+ !
use self methodReturnBool: multipleBytecodeSetsActive instead of the last three lines.
Item was changed:
InterpreterPrimitives subclass: #StackInterpreter (excessive size, no diff calculated)
Item was changed: ----- Method: StackInterpreter class>>initializeMiscConstants (in category 'initialization') ----- initializeMiscConstants
super initializeMiscConstants. STACKVM := true. "These flags identify a GC operation (& hence a reason to leak
check), or just operations the leak checker can be run for." GCModeFull := 1. "stop-the-world global GC" GCModeNewSpace := 2. "Spur's scavenge, or V3's incremental" GCModeIncremental := 4. "incremental global gc (Dijkstra tri-colour marking); as yet unimplemented" GCModeBecome := 8. "v3 post-become sweeping/Spur forwarding" GCCheckImageSegment := 16. "just a flag for leak checking image segments" GCCheckFreeSpace := 32. "just a flag for leak checking free space; Spur only" GCCheckShorten := 64. "just a flag for leak checking object shortening operations; Spur only" GCCheckPrimCall := 128. "just a flag for leak checking external primitive calls"
StackPageTraceInvalid := -1. StackPageUnreached := 0. StackPageReachedButUntraced := 1. StackPageTraced := 2. DumpStackOnLowSpace := 0. MillisecondClockMask := 16r1FFFFFFF. "Note: The external primitive table should actually be dynamically
sized but for the sake of inferior platforms (e.g., Mac :-) who cannot allocate memory in any reasonable way, we keep it static (and cross our fingers...)" MaxExternalPrimitiveTableSize := 4096. "entries"
MaxJumpBuf := 32. "max. callback depth" FailImbalancedPrimitives := InitializationOptions at:
#FailImbalancedPrimitives ifAbsentPut: [true]. EnforceAccessControl := InitializationOptions at: #EnforceAccessControl ifAbsent: [true].
ReturnToInterpreter := 1. "setjmp/longjmp code." "Because of a hack with callbacks in the non-threaded VM they must
not conflct with the VM's tag bits." DisownVMForFFICall := 16.
DisownVMForThreading := 32.
"The multiple bytecodes active bit in the image format number"
MultipleBytecodeSetsBitmask := 512.
!DisownVMForThreading := 32
Item was changed: ----- Method: StackInterpreter>>readableFormat: (in category 'image save/restore') ----- readableFormat: imageVersion "Anwer true if images of the given format are readable by this interpreter. Allows a virtual machine to accept selected older image formats." <api>
^ (self imageFormatVersion = (imageVersion bitAnd: ( -1 -
MultipleBytecodeSetsBitmask))) "Ignore multiple bytecode support identifier"
or: [objectMemory hasSpurMemoryManagerAPI not "No
compatibility version for Spur as yet"
^imageVersion = self imageFormatVersion "Float words in
platform-order"
or: [objectMemory hasSpurMemoryManagerAPI not "No compatibility
version for Spur as yet" and: [imageVersion = self imageFormatCompatibilityVersion]] "Float words in BigEndian order"!
Can we write this as is the image version a Spur version? if so... insist on exact match is the image a priori version? If so... filter the acceptable matches otherwise fail for unrecognised version ?
'cuz this way is more readable/commentable/extensible in the long run.
Item was changed:
----- Method: StackInterpreter>>writeImageFileIO (in category 'image save/restore') ----- writeImageFileIO "Write the image header and heap contents to imageFile for snapshot. c.f. writeImageFileIOSimulation. The game below is to maintain 64-bit alignment for all putLong:toFile: occurrences." <inline: #never> | imageName headerStart headerSize f imageBytes bytesWritten sCWIfn okToWrite |
...
multipleBytecodeSetsActive
ifTrue: [self putWord32: (self imageFormatVersion bitOr:
MultipleBytecodeSetsBitmask) toFile: f]
ifFalse: [self putWord32: self imageFormatVersion toFile:
f].
why not extract this to e.g. self imageFormatVersionForSnapshot?
- self putWord32: self imageFormatVersion toFile: f.
self putWord32: headerSize toFile: f.
...
_,,,^..^,,,_ best, Eliot
Thanks Eliot,
I will do an update in the VMM inbox in the next day or so.
Dave
On Sun, Dec 26, 2021 at 01:26:03PM -0800, Eliot Miranda wrote:
Hi Dave,
On Sun, Dec 26, 2021 at 12:35 PM David T. Lewis lewis@mail.msen.com wrote:
My apologies, I intended this for the VMMaker inbox. I will move it there now.
no problem.
On Sun, Dec 26, 2021 at 12:23 PM commits@source.squeak.org wrote:
David T. Lewis uploaded a new version of VMMaker to project VM Maker: http://source.squeak.org/VMMaker/VMMaker.oscog-dtl.3123.mcz
==================== Summary ====================
Name: VMMaker.oscog-dtl.3123 Author: dtl Time: 26 December 2021, 12:55:15.357105 pm UUID: a0d4db62-a6ac-4d9c-ba51-5eec2ce0c415 Ancestors: VMMaker.oscog-eem.3122
Support image formats 68533 and 7033. Let the image inform the VM that alternate bytecodes either are or are not in use, and remember the setting when writing or reading the image format number in a shapshot file header. Also support testing the current value of multipleBytecodeSetsActive, and listing the encoder names of supported bytecode sets.
This is cool. But let me suggest...
Item was added:
- ----- Method: InterpreterPrimitives>>primitiveBytecodeSetsAvailable (in
category 'other primitives') -----
- primitiveBytecodeSetsAvailable
"Answer the encoder names for the supported bytecode sets."
<export: true>
| encoderNames |
argumentCount >0 ifTrue:
[^self primitiveFailFor: PrimErrBadNumArgs].
encoderNames := self instantiateClass: self classArray
indexableSize: 3.
self storePointer: 0 ofObject: encoderNames withValue:
(objectMemory stringForCString: 'EncoderForV3').
self storePointer: 1 ofObject: encoderNames withValue:
(objectMemory stringForCString: 'EncoderForV3PlusClosures').
self storePointer: 2 ofObject: encoderNames withValue:
(objectMemory stringForCString: 'EncoderForSistaV1').
self pop: 1 thenPush: encoderNames.
- !
use self methodReturnValue: encoderNames instead of self pop: 1 thenPush: encoderNames.
Item was added:
- ----- Method: InterpreterPrimitives>>primitiveMultipleBytecodeSetsActive
(in category 'other primitives') -----
- primitiveMultipleBytecodeSetsActive
"Given one boolean parameter, set multipleBytecodeSetsActive to
inform
the VM that alternate bytecode sets such as SistaV1 are now in
use and
that the image format number should be updated accordingly. With
zero
parameters, answer the current value of
multipleBytecodeSetsActive."
<export: true>
argumentCount >1 ifTrue:
[^self primitiveFailFor: PrimErrBadNumArgs].
argumentCount = 1
ifTrue: [self stackTop = objectMemory trueObject
ifTrue: [self cppIf: MULTIPLEBYTECODESETS
ifTrue: [multipleBytecodeSetsActive :=
true]
ifFalse: [^self primitiveFailFor:
PrimErrUnsupported]]
ifFalse: [self stackTop = objectMemory falseObject
ifTrue: [multipleBytecodeSetsActive :=
false]
ifFalse:[^self primitiveFailFor:
PrimErrBadArgument]]].
multipleBytecodeSetsActive
ifTrue: [self pop: argumentCount + 1 thenPush:
objectMemory trueObject]
ifFalse: [self pop: argumentCount + 1 thenPush:
objectMemory falseObject].
- !
use self methodReturnBool: multipleBytecodeSetsActive instead of the last three lines.
Item was changed:
InterpreterPrimitives subclass: #StackInterpreter (excessive size, no diff calculated)
Item was changed: ----- Method: StackInterpreter class>>initializeMiscConstants (in category 'initialization') ----- initializeMiscConstants
super initializeMiscConstants. STACKVM := true. "These flags identify a GC operation (& hence a reason to leak
check), or just operations the leak checker can be run for." GCModeFull := 1. "stop-the-world global GC" GCModeNewSpace := 2. "Spur's scavenge, or V3's incremental" GCModeIncremental := 4. "incremental global gc (Dijkstra tri-colour marking); as yet unimplemented" GCModeBecome := 8. "v3 post-become sweeping/Spur forwarding" GCCheckImageSegment := 16. "just a flag for leak checking image segments" GCCheckFreeSpace := 32. "just a flag for leak checking free space; Spur only" GCCheckShorten := 64. "just a flag for leak checking object shortening operations; Spur only" GCCheckPrimCall := 128. "just a flag for leak checking external primitive calls"
StackPageTraceInvalid := -1. StackPageUnreached := 0. StackPageReachedButUntraced := 1. StackPageTraced := 2. DumpStackOnLowSpace := 0. MillisecondClockMask := 16r1FFFFFFF. "Note: The external primitive table should actually be dynamically
sized but for the sake of inferior platforms (e.g., Mac :-) who cannot allocate memory in any reasonable way, we keep it static (and cross our fingers...)" MaxExternalPrimitiveTableSize := 4096. "entries"
MaxJumpBuf := 32. "max. callback depth" FailImbalancedPrimitives := InitializationOptions at:
#FailImbalancedPrimitives ifAbsentPut: [true]. EnforceAccessControl := InitializationOptions at: #EnforceAccessControl ifAbsent: [true].
ReturnToInterpreter := 1. "setjmp/longjmp code." "Because of a hack with callbacks in the non-threaded VM they must
not conflct with the VM's tag bits." DisownVMForFFICall := 16.
DisownVMForThreading := 32.
"The multiple bytecodes active bit in the image format number"
MultipleBytecodeSetsBitmask := 512.
!DisownVMForThreading := 32
Item was changed: ----- Method: StackInterpreter>>readableFormat: (in category 'image save/restore') ----- readableFormat: imageVersion "Anwer true if images of the given format are readable by this interpreter. Allows a virtual machine to accept selected older image formats." <api>
^ (self imageFormatVersion = (imageVersion bitAnd: ( -1 -
MultipleBytecodeSetsBitmask))) "Ignore multiple bytecode support identifier"
or: [objectMemory hasSpurMemoryManagerAPI not "No
compatibility version for Spur as yet"
^imageVersion = self imageFormatVersion "Float words in
platform-order"
or: [objectMemory hasSpurMemoryManagerAPI not "No compatibility
version for Spur as yet" and: [imageVersion = self imageFormatCompatibilityVersion]] "Float words in BigEndian order"!
Can we write this as is the image version a Spur version? if so... insist on exact match is the image a priori version? If so... filter the acceptable matches otherwise fail for unrecognised version ?
'cuz this way is more readable/commentable/extensible in the long run.
Item was changed:
----- Method: StackInterpreter>>writeImageFileIO (in category 'image save/restore') ----- writeImageFileIO "Write the image header and heap contents to imageFile for snapshot. c.f. writeImageFileIOSimulation. The game below is to maintain 64-bit alignment for all putLong:toFile: occurrences." <inline: #never> | imageName headerStart headerSize f imageBytes bytesWritten sCWIfn okToWrite |
...
multipleBytecodeSetsActive
ifTrue: [self putWord32: (self imageFormatVersion bitOr:
MultipleBytecodeSetsBitmask) toFile: f]
ifFalse: [self putWord32: self imageFormatVersion toFile:
f].
why not extract this to e.g. self imageFormatVersionForSnapshot?
self putWord32: self imageFormatVersion toFile: f.
self putWord32: headerSize toFile: f.
...
_,,,^..^,,,_ best, Eliot
Hi Eliot,
I put VMMaker.oscog-dtl.3124 in the VMM inbox, which includes your recommendations along with a few unit tests to cover the format number handling.
Dave
On Sun, Dec 26, 2021 at 08:49:04PM -0500, David T. Lewis wrote:
Thanks Eliot,
I will do an update in the VMM inbox in the next day or so.
Dave
On Sun, Dec 26, 2021 at 01:26:03PM -0800, Eliot Miranda wrote:
Hi Dave,
On Sun, Dec 26, 2021 at 12:35 PM David T. Lewis lewis@mail.msen.com wrote:
My apologies, I intended this for the VMMaker inbox. I will move it there now.
no problem.
On Sun, Dec 26, 2021 at 12:23 PM commits@source.squeak.org wrote:
David T. Lewis uploaded a new version of VMMaker to project VM Maker: http://source.squeak.org/VMMaker/VMMaker.oscog-dtl.3123.mcz
==================== Summary ====================
Name: VMMaker.oscog-dtl.3123 Author: dtl Time: 26 December 2021, 12:55:15.357105 pm UUID: a0d4db62-a6ac-4d9c-ba51-5eec2ce0c415 Ancestors: VMMaker.oscog-eem.3122
Support image formats 68533 and 7033. Let the image inform the VM that alternate bytecodes either are or are not in use, and remember the setting when writing or reading the image format number in a shapshot file header. Also support testing the current value of multipleBytecodeSetsActive, and listing the encoder names of supported bytecode sets.
This is cool. But let me suggest...
Item was added:
- ----- Method: InterpreterPrimitives>>primitiveBytecodeSetsAvailable (in
category 'other primitives') -----
- primitiveBytecodeSetsAvailable
"Answer the encoder names for the supported bytecode sets."
<export: true>
| encoderNames |
argumentCount >0 ifTrue:
[^self primitiveFailFor: PrimErrBadNumArgs].
encoderNames := self instantiateClass: self classArray
indexableSize: 3.
self storePointer: 0 ofObject: encoderNames withValue:
(objectMemory stringForCString: 'EncoderForV3').
self storePointer: 1 ofObject: encoderNames withValue:
(objectMemory stringForCString: 'EncoderForV3PlusClosures').
self storePointer: 2 ofObject: encoderNames withValue:
(objectMemory stringForCString: 'EncoderForSistaV1').
self pop: 1 thenPush: encoderNames.
- !
use self methodReturnValue: encoderNames instead of self pop: 1 thenPush: encoderNames.
Item was added:
- ----- Method: InterpreterPrimitives>>primitiveMultipleBytecodeSetsActive
(in category 'other primitives') -----
- primitiveMultipleBytecodeSetsActive
"Given one boolean parameter, set multipleBytecodeSetsActive to
inform
the VM that alternate bytecode sets such as SistaV1 are now in
use and
that the image format number should be updated accordingly. With
zero
parameters, answer the current value of
multipleBytecodeSetsActive."
<export: true>
argumentCount >1 ifTrue:
[^self primitiveFailFor: PrimErrBadNumArgs].
argumentCount = 1
ifTrue: [self stackTop = objectMemory trueObject
ifTrue: [self cppIf: MULTIPLEBYTECODESETS
ifTrue: [multipleBytecodeSetsActive :=
true]
ifFalse: [^self primitiveFailFor:
PrimErrUnsupported]]
ifFalse: [self stackTop = objectMemory falseObject
ifTrue: [multipleBytecodeSetsActive :=
false]
ifFalse:[^self primitiveFailFor:
PrimErrBadArgument]]].
multipleBytecodeSetsActive
ifTrue: [self pop: argumentCount + 1 thenPush:
objectMemory trueObject]
ifFalse: [self pop: argumentCount + 1 thenPush:
objectMemory falseObject].
- !
use self methodReturnBool: multipleBytecodeSetsActive instead of the last three lines.
Item was changed:
InterpreterPrimitives subclass: #StackInterpreter (excessive size, no diff calculated)
Item was changed: ----- Method: StackInterpreter class>>initializeMiscConstants (in category 'initialization') ----- initializeMiscConstants
super initializeMiscConstants. STACKVM := true. "These flags identify a GC operation (& hence a reason to leak
check), or just operations the leak checker can be run for." GCModeFull := 1. "stop-the-world global GC" GCModeNewSpace := 2. "Spur's scavenge, or V3's incremental" GCModeIncremental := 4. "incremental global gc (Dijkstra tri-colour marking); as yet unimplemented" GCModeBecome := 8. "v3 post-become sweeping/Spur forwarding" GCCheckImageSegment := 16. "just a flag for leak checking image segments" GCCheckFreeSpace := 32. "just a flag for leak checking free space; Spur only" GCCheckShorten := 64. "just a flag for leak checking object shortening operations; Spur only" GCCheckPrimCall := 128. "just a flag for leak checking external primitive calls"
StackPageTraceInvalid := -1. StackPageUnreached := 0. StackPageReachedButUntraced := 1. StackPageTraced := 2. DumpStackOnLowSpace := 0. MillisecondClockMask := 16r1FFFFFFF. "Note: The external primitive table should actually be dynamically
sized but for the sake of inferior platforms (e.g., Mac :-) who cannot allocate memory in any reasonable way, we keep it static (and cross our fingers...)" MaxExternalPrimitiveTableSize := 4096. "entries"
MaxJumpBuf := 32. "max. callback depth" FailImbalancedPrimitives := InitializationOptions at:
#FailImbalancedPrimitives ifAbsentPut: [true]. EnforceAccessControl := InitializationOptions at: #EnforceAccessControl ifAbsent: [true].
ReturnToInterpreter := 1. "setjmp/longjmp code." "Because of a hack with callbacks in the non-threaded VM they must
not conflct with the VM's tag bits." DisownVMForFFICall := 16.
DisownVMForThreading := 32.
"The multiple bytecodes active bit in the image format number"
MultipleBytecodeSetsBitmask := 512.
!DisownVMForThreading := 32
Item was changed: ----- Method: StackInterpreter>>readableFormat: (in category 'image save/restore') ----- readableFormat: imageVersion "Anwer true if images of the given format are readable by this interpreter. Allows a virtual machine to accept selected older image formats." <api>
^ (self imageFormatVersion = (imageVersion bitAnd: ( -1 -
MultipleBytecodeSetsBitmask))) "Ignore multiple bytecode support identifier"
or: [objectMemory hasSpurMemoryManagerAPI not "No
compatibility version for Spur as yet"
^imageVersion = self imageFormatVersion "Float words in
platform-order"
or: [objectMemory hasSpurMemoryManagerAPI not "No compatibility
version for Spur as yet" and: [imageVersion = self imageFormatCompatibilityVersion]] "Float words in BigEndian order"!
Can we write this as is the image version a Spur version? if so... insist on exact match is the image a priori version? If so... filter the acceptable matches otherwise fail for unrecognised version ?
'cuz this way is more readable/commentable/extensible in the long run.
Item was changed:
----- Method: StackInterpreter>>writeImageFileIO (in category 'image save/restore') ----- writeImageFileIO "Write the image header and heap contents to imageFile for snapshot. c.f. writeImageFileIOSimulation. The game below is to maintain 64-bit alignment for all putLong:toFile: occurrences." <inline: #never> | imageName headerStart headerSize f imageBytes bytesWritten sCWIfn okToWrite |
...
multipleBytecodeSetsActive
ifTrue: [self putWord32: (self imageFormatVersion bitOr:
MultipleBytecodeSetsBitmask) toFile: f]
ifFalse: [self putWord32: self imageFormatVersion toFile:
f].
why not extract this to e.g. self imageFormatVersionForSnapshot?
self putWord32: self imageFormatVersion toFile: f.
self putWord32: headerSize toFile: f.
...
_,,,^..^,,,_ best, Eliot
Hi Dave,
On Sat, Jan 1, 2022 at 1:07 PM David T. Lewis lewis@mail.msen.com wrote:
Hi Eliot,
I put VMMaker.oscog-dtl.3124 in the VMM inbox, which includes your recommendations along with a few unit tests to cover the format number handling.
Cool. The definition and initialization of the new StackInterpreter multipleBytecodeSetsActive inst var is missing. I'm assuming it is an inst var. How should it be initialized? From MULTIPLEBYTECODESETS or left false by default?
Dave
On Sun, Dec 26, 2021 at 08:49:04PM -0500, David T. Lewis wrote:
Thanks Eliot,
I will do an update in the VMM inbox in the next day or so.
Dave
On Sun, Dec 26, 2021 at 01:26:03PM -0800, Eliot Miranda wrote:
Hi Dave,
On Sun, Dec 26, 2021 at 12:35 PM David T. Lewis lewis@mail.msen.com
wrote:
My apologies, I intended this for the VMMaker inbox. I will move it
there
now.
no problem.
On Sun, Dec 26, 2021 at 12:23 PM commits@source.squeak.org wrote:
David T. Lewis uploaded a new version of VMMaker to project VM Maker: http://source.squeak.org/VMMaker/VMMaker.oscog-dtl.3123.mcz
==================== Summary ====================
Name: VMMaker.oscog-dtl.3123 Author: dtl Time: 26 December 2021, 12:55:15.357105 pm UUID: a0d4db62-a6ac-4d9c-ba51-5eec2ce0c415 Ancestors: VMMaker.oscog-eem.3122
Support image formats 68533 and 7033. Let the image inform the VM
that
alternate bytecodes either are or are not in use, and remember the
setting
when writing or reading the image format number in a shapshot file
header.
Also support testing the current value of
multipleBytecodeSetsActive, and
listing the encoder names of supported bytecode sets.
This is cool. But let me suggest...
Item was added:
- ----- Method:
InterpreterPrimitives>>primitiveBytecodeSetsAvailable (in
category 'other primitives') -----
- primitiveBytecodeSetsAvailable
"Answer the encoder names for the supported bytecode sets."
<export: true>
| encoderNames |
argumentCount >0 ifTrue:
[^self primitiveFailFor: PrimErrBadNumArgs].
encoderNames := self instantiateClass: self classArray
indexableSize: 3.
self storePointer: 0 ofObject: encoderNames withValue:
(objectMemory stringForCString: 'EncoderForV3').
self storePointer: 1 ofObject: encoderNames withValue:
(objectMemory stringForCString: 'EncoderForV3PlusClosures').
self storePointer: 2 ofObject: encoderNames withValue:
(objectMemory stringForCString: 'EncoderForSistaV1').
self pop: 1 thenPush: encoderNames.
- !
use self methodReturnValue: encoderNames instead of self pop: 1
thenPush:
encoderNames.
Item was added:
- ----- Method:
InterpreterPrimitives>>primitiveMultipleBytecodeSetsActive
(in category 'other primitives') -----
- primitiveMultipleBytecodeSetsActive
"Given one boolean parameter, set multipleBytecodeSetsActive
to
inform
the VM that alternate bytecode sets such as SistaV1 are now
in
use and
that the image format number should be updated accordingly.
With
zero
parameters, answer the current value of
multipleBytecodeSetsActive."
<export: true>
argumentCount >1 ifTrue:
[^self primitiveFailFor: PrimErrBadNumArgs].
argumentCount = 1
ifTrue: [self stackTop = objectMemory trueObject
ifTrue: [self cppIf: MULTIPLEBYTECODESETS
ifTrue: [multipleBytecodeSetsActive
:=
true]
ifFalse: [^self primitiveFailFor:
PrimErrUnsupported]]
ifFalse: [self stackTop = objectMemory
falseObject
ifTrue: [multipleBytecodeSetsActive
:=
false]
ifFalse:[^self primitiveFailFor:
PrimErrBadArgument]]].
multipleBytecodeSetsActive
ifTrue: [self pop: argumentCount + 1 thenPush:
objectMemory trueObject]
ifFalse: [self pop: argumentCount + 1 thenPush:
objectMemory falseObject].
- !
use self methodReturnBool: multipleBytecodeSetsActive instead of the
last
three lines.
Item was changed:
InterpreterPrimitives subclass: #StackInterpreter (excessive size, no diff calculated)
Item was changed: ----- Method: StackInterpreter class>>initializeMiscConstants (in category 'initialization') ----- initializeMiscConstants
super initializeMiscConstants. STACKVM := true. "These flags identify a GC operation (& hence a reason to
leak
check), or just operations the leak checker can be run for." GCModeFull := 1.
"stop-the-world
global GC" GCModeNewSpace := 2. "Spur's scavenge, or V3's incremental" GCModeIncremental := 4. "incremental global gc
(Dijkstra
tri-colour marking); as yet unimplemented" GCModeBecome := 8. "v3 post-become sweeping/Spur forwarding" GCCheckImageSegment := 16. "just a flag for leak
checking
image segments" GCCheckFreeSpace := 32. "just a flag for leak
checking
free space; Spur only" GCCheckShorten := 64. "just a flag for leak
checking
object shortening operations; Spur only" GCCheckPrimCall := 128. "just a flag for leak
checking
external primitive calls"
StackPageTraceInvalid := -1. StackPageUnreached := 0. StackPageReachedButUntraced := 1. StackPageTraced := 2. DumpStackOnLowSpace := 0. MillisecondClockMask := 16r1FFFFFFF. "Note: The external primitive table should actually be
dynamically
sized but for the sake of inferior platforms (e.g., Mac :-) who
cannot
allocate memory in any reasonable way, we keep it static (and cross
our
fingers...)" MaxExternalPrimitiveTableSize := 4096. "entries"
MaxJumpBuf := 32. "max. callback depth" FailImbalancedPrimitives := InitializationOptions at:
#FailImbalancedPrimitives ifAbsentPut: [true]. EnforceAccessControl := InitializationOptions at: #EnforceAccessControl ifAbsent: [true].
ReturnToInterpreter := 1. "setjmp/longjmp code." "Because of a hack with callbacks in the non-threaded VM
they must
not conflct with the VM's tag bits." DisownVMForFFICall := 16.
DisownVMForThreading := 32.
"The multiple bytecodes active bit in the image format
number"
MultipleBytecodeSetsBitmask := 512.
!DisownVMForThreading := 32
Item was changed: ----- Method: StackInterpreter>>readableFormat: (in category 'image save/restore') ----- readableFormat: imageVersion "Anwer true if images of the given format are readable by
this
interpreter. Allows a virtual machine to accept selected older image
formats."
<api>
^ (self imageFormatVersion = (imageVersion bitAnd: ( -1 -
MultipleBytecodeSetsBitmask))) "Ignore multiple bytecode support
identifier"
or: [objectMemory hasSpurMemoryManagerAPI not "No
compatibility version for Spur as yet"
^imageVersion = self imageFormatVersion "Float words in
platform-order"
or: [objectMemory hasSpurMemoryManagerAPI not "No
compatibility
version for Spur as yet" and: [imageVersion = self imageFormatCompatibilityVersion]] "Float words in BigEndian order"!
Can we write this as is the image version a Spur version? if so... insist on exact match is the image a priori version? If so... filter the acceptable matches otherwise fail for unrecognised version ?
'cuz this way is more readable/commentable/extensible in the long run.
Item was changed:
----- Method: StackInterpreter>>writeImageFileIO (in category
'image
save/restore') ----- writeImageFileIO "Write the image header and heap contents to imageFile for snapshot. c.f. writeImageFileIOSimulation. The game below is to maintain 64-bit alignment for all putLong:toFile: occurrences." <inline: #never> | imageName headerStart headerSize f imageBytes bytesWritten sCWIfn okToWrite |
...
multipleBytecodeSetsActive
ifTrue: [self putWord32: (self imageFormatVersion
bitOr:
MultipleBytecodeSetsBitmask) toFile: f]
ifFalse: [self putWord32: self imageFormatVersion
toFile:
f].
why not extract this to e.g. self imageFormatVersionForSnapshot?
self putWord32: self imageFormatVersion toFile: f.
self putWord32: headerSize toFile: f.
...
_,,,^..^,,,_ best, Eliot
Hi Eliot,
On Sun, Jan 02, 2022 at 01:17:02PM -0800, Eliot Miranda wrote:
On Sat, Jan 1, 2022 at 1:07 PM David T. Lewis lewis@mail.msen.com wrote:
I put VMMaker.oscog-dtl.3124 in the VMM inbox, which includes your recommendations along with a few unit tests to cover the format number handling.
Cool. The definition and initialization of the new StackInterpreter multipleBytecodeSetsActive inst var is missing. I'm assuming it is an inst var. How should it be initialized? From MULTIPLEBYTECODESETS or left false by default?
multipleBytecodeSetsActive (an inst var in InterpreterPrimitives) is initialized in StackInterpreter>>imageFormatVersionFromSnapshot: while reading the image file header. Otherwise it is only updated by primitiveMultipleBytecodeSetsActive.
The inst var might also need to be initialized to MULTIPLEBYTECODESETS in simulation (I did not do that). In the three new tests in FormatNumberTests, I called #imageFormatVersionFromSnapshot: to set up the test data.
The primitiveMultipleBytecodeSetsActive inst var tells us what the image claims to be requiring, as opposed to MULTIPLEBYTECODESETS which is what the VM is actually capable of supporting. It is used only for reading and writing the image format number and has no other effect on the VM itself.
Dave
Hi Dave, hi Eliot, hi all --
I think we can still merge this into the next VM release.
For Squeak 6.0, I only then have to figure out how to produce that new (base) image for the bundles. :-) Probably something in the area of SystemTracer... or I just hack the image header directly? xD
Best, Marcel Am 03.01.2022 04:32:31 schrieb David T. Lewis lewis@mail.msen.com:
Hi Eliot,
On Sun, Jan 02, 2022 at 01:17:02PM -0800, Eliot Miranda wrote:
On Sat, Jan 1, 2022 at 1:07 PM David T. Lewis wrote:
I put VMMaker.oscog-dtl.3124 in the VMM inbox, which includes your recommendations along with a few unit tests to cover the format number handling.
Cool. The definition and initialization of the new StackInterpreter multipleBytecodeSetsActive inst var is missing. I'm assuming it is an inst var. How should it be initialized? From MULTIPLEBYTECODESETS or left false by default?
multipleBytecodeSetsActive (an inst var in InterpreterPrimitives) is initialized in StackInterpreter>>imageFormatVersionFromSnapshot: while reading the image file header. Otherwise it is only updated by primitiveMultipleBytecodeSetsActive.
The inst var might also need to be initialized to MULTIPLEBYTECODESETS in simulation (I did not do that). In the three new tests in FormatNumberTests, I called #imageFormatVersionFromSnapshot: to set up the test data.
The primitiveMultipleBytecodeSetsActive inst var tells us what the image claims to be requiring, as opposed to MULTIPLEBYTECODESETS which is what the VM is actually capable of supporting. It is used only for reading and writing the image format number and has no other effect on the VM itself.
Dave
Hi Marcel,
On Apr 7, 2022, at 4:17 AM, Marcel Taeumel marcel.taeumel@hpi.de wrote:
Hi Dave, hi Eliot, hi all --
I think we can still merge this into the next VM release.
For Squeak 6.0, I only then have to figure out how to produce that new (base) image for the bundles. :-) Probably something in the area of SystemTracer... or I just hack the image header directly? xD
I don’t think you need to anything to the image. This is a vm property, ie does the vm support multiple bytecode sets or not? One should be able to run an image that uses only one bytecode set on a vm that supports two.
Best, Marcel
Am 03.01.2022 04:32:31 schrieb David T. Lewis lewis@mail.msen.com:
Hi Eliot,
On Sun, Jan 02, 2022 at 01:17:02PM -0800, Eliot Miranda wrote:
On Sat, Jan 1, 2022 at 1:07 PM David T. Lewis wrote:
I put VMMaker.oscog-dtl.3124 in the VMM inbox, which includes your recommendations along with a few unit tests to cover the format number handling.
Cool. The definition and initialization of the new StackInterpreter multipleBytecodeSetsActive inst var is missing. I'm assuming it is an inst var. How should it be initialized? From MULTIPLEBYTECODESETS or left false by default?
multipleBytecodeSetsActive (an inst var in InterpreterPrimitives) is initialized in StackInterpreter>>imageFormatVersionFromSnapshot: while reading the image file header. Otherwise it is only updated by primitiveMultipleBytecodeSetsActive.
The inst var might also need to be initialized to MULTIPLEBYTECODESETS in simulation (I did not do that). In the three new tests in FormatNumberTests, I called #imageFormatVersionFromSnapshot: to set up the test data.
The primitiveMultipleBytecodeSetsActive inst var tells us what the image claims to be requiring, as opposed to MULTIPLEBYTECODESETS which is what the VM is actually capable of supporting. It is used only for reading and writing the image format number and has no other effect on the VM itself.
Dave
On Thu, Apr 07, 2022 at 04:22:51AM -0700, Eliot Miranda wrote:
Hi Marcel,
On Apr 7, 2022, at 4:17 AM, Marcel Taeumel marcel.taeumel@hpi.de wrote:
??? Hi Dave, hi Eliot, hi all --
I think we can still merge this into the next VM release.
For Squeak 6.0, I only then have to figure out how to produce that new (base) image for the bundles. :-) Probably something in the area of SystemTracer... or I just hack the image header directly? xD
I don???t think you need to anything to the image. This is a vm property, ie does the vm support multiple bytecode sets or not? One should be able to run an image that uses only one bytecode set on a vm that supports two.
Right. On the image side the only thing to be aware of is this:
CompiledCode class>>multipleBytecodeSetsActive: aBoolean "Inform the VM when multiple bytecode sets, typically the Sista bytecodes in addition to the traditional V3 bytecode set, are now in use in this image. The VM may use this information to update the image format number when saving the image to the file system."
<primitive: 'primitiveMultipleBytecodeSetsActive'>
So for the Squeak 6.0 release, if we are confident that most users of the new release will be using the release VM, and if we are releasing with Sista activated, then we just need to make sure that this method is called in the update stream and/or ReleaseBuilder.
See also the convenience method CompiledCode class>>useSista:
Dave
Ah! save-and-quit will do the trick. Nice. Let me merge VMMaker.oscog-dtl.3123 and see whether I can make this work.
Best, Marcel Am 08.04.2022 01:43:00 schrieb David T. Lewis lewis@mail.msen.com:
On Thu, Apr 07, 2022 at 04:22:51AM -0700, Eliot Miranda wrote:
Hi Marcel,
On Apr 7, 2022, at 4:17 AM, Marcel Taeumel wrote:
??? Hi Dave, hi Eliot, hi all --
I think we can still merge this into the next VM release.
For Squeak 6.0, I only then have to figure out how to produce that new (base) image for the bundles. :-) Probably something in the area of SystemTracer... or I just hack the image header directly? xD
I don???t think you need to anything to the image. This is a vm property, ie does the vm support multiple bytecode sets or not? One should be able to run an image that uses only one bytecode set on a vm that supports two.
Right. On the image side the only thing to be aware of is this:
CompiledCode class>>multipleBytecodeSetsActive: aBoolean "Inform the VM when multiple bytecode sets, typically the Sista bytecodes in addition to the traditional V3 bytecode set, are now in use in this image. The VM may use this information to update the image format number when saving the image to the file system."
So for the Squeak 6.0 release, if we are confident that most users of the new release will be using the release VM, and if we are releasing with Sista activated, then we just need to make sure that this method is called in the update stream and/or ReleaseBuilder.
See also the convenience method CompiledCode class>>useSista:
Dave
Hi Dave,
On Apr 7, 2022, at 4:42 PM, David T. Lewis lewis@mail.msen.com wrote:
On Thu, Apr 07, 2022 at 04:22:51AM -0700, Eliot Miranda wrote:
Hi Marcel,
On Apr 7, 2022, at 4:17 AM, Marcel Taeumel marcel.taeumel@hpi.de wrote:
??? Hi Dave, hi Eliot, hi all --
I think we can still merge this into the next VM release.
For Squeak 6.0, I only then have to figure out how to produce that new (base) image for the bundles. :-) Probably something in the area of SystemTracer... or I just hack the image header directly? xD
I don???t think you need to anything to the image. This is a vm property, ie does the vm support multiple bytecode sets or not? One should be able to run an image that uses only one bytecode set on a vm that supports two.
Right. On the image side the only thing to be aware of is this:
CompiledCode class>>multipleBytecodeSetsActive: aBoolean "Inform the VM when multiple bytecode sets, typically the Sista bytecodes in addition to the traditional V3 bytecode set, are now in use in this image. The VM may use this information to update the image format number when saving the image to the file system."
<primitive: 'primitiveMultipleBytecodeSetsActive'>
So for the Squeak 6.0 release, if we are confident that most users of the new release will be using the release VM, and if we are releasing with Sista activated, then we just need to make sure that this method is called in the update stream and/or ReleaseBuilder.
See also the convenience method CompiledCode class>>useSista:
Can we rename this to be CompiledCode class>>useSistaBytecodeSet: ? Sista refers to the entire system, adaptive optimizer and all. Currently we’re using only the non-optimization part of the bytecode set.
_,,,^..^,,,_ (phone)
Can we rename this to be CompiledCode class>>useSistaBytecodeSet: ?
+1 Am 08.04.2022 16:19:48 schrieb Eliot Miranda eliot.miranda@gmail.com:
Hi Dave,
On Apr 7, 2022, at 4:42 PM, David T. Lewis wrote:
On Thu, Apr 07, 2022 at 04:22:51AM -0700, Eliot Miranda wrote:
Hi Marcel,
On Apr 7, 2022, at 4:17 AM, Marcel Taeumel wrote:
??? Hi Dave, hi Eliot, hi all --
I think we can still merge this into the next VM release.
For Squeak 6.0, I only then have to figure out how to produce that new (base) image for the bundles. :-) Probably something in the area of SystemTracer... or I just hack the image header directly? xD
I don???t think you need to anything to the image. This is a vm property, ie does the vm support multiple bytecode sets or not? One should be able to run an image that uses only one bytecode set on a vm that supports two.
Right. On the image side the only thing to be aware of is this:
CompiledCode class>>multipleBytecodeSetsActive: aBoolean "Inform the VM when multiple bytecode sets, typically the Sista bytecodes in addition to the traditional V3 bytecode set, are now in use in this image. The VM may use this information to update the image format number when saving the image to the file system."
So for the Squeak 6.0 release, if we are confident that most users of the new release will be using the release VM, and if we are releasing with Sista activated, then we just need to make sure that this method is called in the update stream and/or ReleaseBuilder.
See also the convenience method CompiledCode class>>useSista:
Can we rename this to be CompiledCode class>>useSistaBytecodeSet: ? Sista refers to the entire system, adaptive optimizer and all. Currently we’re using only the non-optimization part of the bytecode set.
_,,,^..^,,,_ (phone)
Done via Kernel-mt.1455
Best, Marcel Am 08.04.2022 16:21:50 schrieb Marcel Taeumel marcel.taeumel@hpi.de:
Can we rename this to be CompiledCode class>>useSistaBytecodeSet: ?
+1 Am 08.04.2022 16:19:48 schrieb Eliot Miranda eliot.miranda@gmail.com:
Hi Dave,
On Apr 7, 2022, at 4:42 PM, David T. Lewis wrote:
On Thu, Apr 07, 2022 at 04:22:51AM -0700, Eliot Miranda wrote:
Hi Marcel,
On Apr 7, 2022, at 4:17 AM, Marcel Taeumel wrote:
??? Hi Dave, hi Eliot, hi all --
I think we can still merge this into the next VM release.
For Squeak 6.0, I only then have to figure out how to produce that new (base) image for the bundles. :-) Probably something in the area of SystemTracer... or I just hack the image header directly? xD
I don???t think you need to anything to the image. This is a vm property, ie does the vm support multiple bytecode sets or not? One should be able to run an image that uses only one bytecode set on a vm that supports two.
Right. On the image side the only thing to be aware of is this:
CompiledCode class>>multipleBytecodeSetsActive: aBoolean "Inform the VM when multiple bytecode sets, typically the Sista bytecodes in addition to the traditional V3 bytecode set, are now in use in this image. The VM may use this information to update the image format number when saving the image to the file system."
So for the Squeak 6.0 release, if we are confident that most users of the new release will be using the release VM, and if we are releasing with Sista activated, then we just need to make sure that this method is called in the update stream and/or ReleaseBuilder.
See also the convenience method CompiledCode class>>useSista:
Can we rename this to be CompiledCode class>>useSistaBytecodeSet: ? Sista refers to the entire system, adaptive optimizer and all. Currently we’re using only the non-optimization part of the bytecode set.
_,,,^..^,,,_ (phone)
On Fri, Apr 08, 2022 at 03:17:45PM +0200, Marcel Taeumel wrote:
Ah! save-and-quit will do the trick. Nice. Let me merge??VMMaker.oscog-dtl.3123 and see whether I can make this work.
@marcel it would be VMMaker.oscog-dtl.3124 for the final version that includes Eliot's suggestions, plus some new tests and a bug fix exposed by the tests.
@eliot do you agree that VMMaker.oscog-dtl.3124 should be merged from inbox into VMMaker.oscog?
Dave
I did merge 3124 yesterday. But I did not yet regenerate the sources.
Best, Marcel ________________________________ From: Vm-dev vm-dev-bounces@lists.squeakfoundation.org on behalf of David T. Lewis lewis@mail.msen.com Sent: Saturday, April 9, 2022 2:44:15 AM To: Open Smalltalk Virtual Machine Development Discussion vm-dev@lists.squeakfoundation.org Subject: Re: [Vm-dev] VM Maker: VMMaker.oscog-dtl.3123.mcz
On Fri, Apr 08, 2022 at 03:17:45PM +0200, Marcel Taeumel wrote:
Ah! save-and-quit will do the trick. Nice. Let me merge??VMMaker.oscog-dtl.3123 and see whether I can make this work.
@marcel it would be VMMaker.oscog-dtl.3124 for the final version that includes Eliot's suggestions, plus some new tests and a bug fix exposed by the tests.
@eliot do you agree that VMMaker.oscog-dtl.3124 should be merged from inbox into VMMaker.oscog?
Dave
Marcel,
That's great, thank you :-)
Dave
On Sat, Apr 09, 2022 at 10:51:45AM +0000, Taeumel, Marcel wrote:
I did merge 3124 yesterday. But I did not yet regenerate the sources.
Best, Marcel ________________________________ From: Vm-dev vm-dev-bounces@lists.squeakfoundation.org on behalf of David T. Lewis lewis@mail.msen.com Sent: Saturday, April 9, 2022 2:44:15 AM To: Open Smalltalk Virtual Machine Development Discussion vm-dev@lists.squeakfoundation.org Subject: Re: [Vm-dev] VM Maker: VMMaker.oscog-dtl.3123.mcz
On Fri, Apr 08, 2022 at 03:17:45PM +0200, Marcel Taeumel wrote:
Ah! save-and-quit will do the trick. Nice. Let me merge??VMMaker.oscog-dtl.3123 and see whether I can make this work.
@marcel it would be VMMaker.oscog-dtl.3124 for the final version that includes Eliot's suggestions, plus some new tests and a bug fix exposed by the tests.
@eliot do you agree that VMMaker.oscog-dtl.3124 should be merged from inbox into VMMaker.oscog?
Dave
vm-dev@lists.squeakfoundation.org