[Vm-dev] VM Maker: VMMaker.oscog-dtl.3123.mcz

Eliot Miranda eliot.miranda at gmail.com
Sun Dec 26 21:26:03 UTC 2021


Hi Dave,

On Sun, Dec 26, 2021 at 12:35 PM David T. Lewis <lewis at 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 at 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20211226/97cc7766/attachment-0001.html>


More information about the Vm-dev mailing list