<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small">Hi Dave,<br></div></div><div><br></div><div><div dir="ltr" class="gmail_attr">On Sun, Dec 26, 2021 at 12:35 PM David T. Lewis <<a href="mailto:lewis@mail.msen.com">lewis@mail.msen.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"> <br>My apologies, I intended this for the VMMaker inbox. I will move it there now.</blockquote><div><br></div><div class="gmail_default" style="font-size:small">no problem.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Dec 26, 2021 at 12:23 PM <<a href="mailto:commits@source.squeak.org">commits@source.squeak.org</a>> wrote:</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"> <br>
David T. Lewis uploaded a new version of VMMaker to project VM Maker:<br>
<a href="http://source.squeak.org/VMMaker/VMMaker.oscog-dtl.3123.mcz" rel="noreferrer" target="_blank">http://source.squeak.org/VMMaker/VMMaker.oscog-dtl.3123.mcz</a><br>
<br>
==================== Summary ====================<br>
<br>
Name: VMMaker.oscog-dtl.3123<br>
Author: dtl<br>
Time: 26 December 2021, 12:55:15.357105 pm<br>
UUID: a0d4db62-a6ac-4d9c-ba51-5eec2ce0c415<br>
Ancestors: VMMaker.oscog-eem.3122<br>
<br>
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.<br></blockquote><div><br></div><div class="gmail_default" style="font-size:small">This is cool. But let me suggest...</div><div class="gmail_default" style="font-size:small"></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
Item was added:<br>
+ ----- Method: InterpreterPrimitives>>primitiveBytecodeSetsAvailable (in category 'other primitives') -----<br>
+ primitiveBytecodeSetsAvailable<br>
+       "Answer the encoder names for the supported bytecode sets."<br>
+       <export: true><br>
+       | encoderNames |<br>
+       argumentCount >0 ifTrue:<br>
+               [^self primitiveFailFor: PrimErrBadNumArgs].<br>
+       encoderNames := self instantiateClass: self classArray indexableSize: 3.<br>
+       self storePointer: 0 ofObject: encoderNames withValue: (objectMemory stringForCString: 'EncoderForV3').<br>
+       self storePointer: 1 ofObject: encoderNames withValue: (objectMemory stringForCString: 'EncoderForV3PlusClosures').<br>
+       self storePointer: 2 ofObject: encoderNames withValue: (objectMemory stringForCString: 'EncoderForSistaV1').<br>
+       self pop: 1 thenPush: encoderNames.<br>
+ !<br></blockquote><div><br></div><div class="gmail_default" style="font-size:small">use self methodReturnValue: encoderNames instead of self pop: 1 thenPush: encoderNames.</div><div class="gmail_default" style="font-size:small"><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">Item was added:<br>
+ ----- Method: InterpreterPrimitives>>primitiveMultipleBytecodeSetsActive (in category 'other primitives') -----<br>
+ primitiveMultipleBytecodeSetsActive<br>
+       "Given one boolean parameter, set multipleBytecodeSetsActive to inform<br>
+        the VM that alternate bytecode sets such as SistaV1 are now in use and<br>
+       that the image format number should be updated accordingly. With zero<br>
+       parameters, answer the current value of multipleBytecodeSetsActive."<br>
+ <br>
+       <export: true><br>
+       argumentCount >1 ifTrue:<br>
+               [^self primitiveFailFor: PrimErrBadNumArgs].<br>
+       argumentCount = 1<br>
+               ifTrue: [self stackTop = objectMemory trueObject<br>
+                       ifTrue: [self cppIf: MULTIPLEBYTECODESETS<br>
+                               ifTrue: [multipleBytecodeSetsActive := true]<br>
+                               ifFalse: [^self primitiveFailFor: PrimErrUnsupported]]<br>
+                       ifFalse: [self stackTop = objectMemory falseObject<br>
+                               ifTrue: [multipleBytecodeSetsActive := false]<br>
+                               ifFalse:[^self primitiveFailFor: PrimErrBadArgument]]].<br>
+       multipleBytecodeSetsActive<br>
+               ifTrue: [self pop: argumentCount + 1 thenPush: objectMemory trueObject]<br>
+               ifFalse: [self pop: argumentCount + 1 thenPush: objectMemory falseObject]. </blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
+ !<br></blockquote><div><br></div><div class="gmail_default" style="font-size:small">use self methodReturnBool: multipleBytecodeSetsActive instead of the last three lines.</div><div class="gmail_default" style="font-size:small"><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">Item was changed:<br>
  InterpreterPrimitives subclass: #StackInterpreter<br>
(excessive size, no diff calculated)<br>
<br>
Item was changed:<br>
  ----- Method: StackInterpreter class>>initializeMiscConstants (in category 'initialization') -----<br>
  initializeMiscConstants<br>
<br>
        super initializeMiscConstants.<br>
        STACKVM := true.<br>
<br>
        "These flags identify a GC operation (& hence a reason to leak check),<br>
         or just operations the leak checker can be run for."<br>
        GCModeFull := 1.                                "stop-the-world global GC"<br>
        GCModeNewSpace := 2.            "Spur's scavenge, or V3's incremental"<br>
        GCModeIncremental := 4.         "incremental global gc (Dijkstra tri-colour marking); as yet unimplemented"<br>
        GCModeBecome := 8.                      "v3 post-become sweeping/Spur forwarding"<br>
        GCCheckImageSegment := 16.      "just a flag for leak checking image segments"<br>
        GCCheckFreeSpace := 32.         "just a flag for leak checking free space; Spur only"<br>
        GCCheckShorten := 64.           "just a flag for leak checking object shortening operations; Spur only"<br>
        GCCheckPrimCall := 128.         "just a flag for leak checking external primitive calls"<br>
<br>
        StackPageTraceInvalid := -1.<br>
        StackPageUnreached := 0.<br>
        StackPageReachedButUntraced := 1.<br>
        StackPageTraced := 2.<br>
<br>
        DumpStackOnLowSpace := 0.<br>
        MillisecondClockMask := 16r1FFFFFFF.<br>
        "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...)"<br>
        MaxExternalPrimitiveTableSize := 4096. "entries"<br>
<br>
        MaxJumpBuf := 32. "max. callback depth"<br>
        FailImbalancedPrimitives := InitializationOptions at: #FailImbalancedPrimitives ifAbsentPut: [true].<br>
        EnforceAccessControl := InitializationOptions at: #EnforceAccessControl ifAbsent: [true].<br>
<br>
        ReturnToInterpreter := 1. "setjmp/longjmp code."<br>
<br>
        "Because of a hack with callbacks in the non-threaded VM they must not conflct with the VM's tag bits."<br>
        DisownVMForFFICall := 16.<br>
+       DisownVMForThreading := 32.<br>
+       <br>
+       "The multiple bytecodes active bit in the image format number"<br>
+       MultipleBytecodeSetsBitmask := 512.<br>
-       DisownVMForThreading := 32<br>
  !<br>
<br>
Item was changed:<br>
  ----- Method: StackInterpreter>>readableFormat: (in category 'image save/restore') -----<br>
  readableFormat: imageVersion<br>
        "Anwer true if images of the given format are readable by this interpreter.<br>
         Allows a virtual machine to accept selected older image formats."<br>
        <api><br>
+       ^ (self imageFormatVersion = (imageVersion bitAnd: ( -1 - MultipleBytecodeSetsBitmask))) "Ignore multiple bytecode support identifier"<br>
+               or: [objectMemory hasSpurMemoryManagerAPI not "No compatibility version for Spur as yet"<br>
-       ^imageVersion = self imageFormatVersion "Float words in platform-order"<br>
-          or: [objectMemory hasSpurMemoryManagerAPI not "No compatibility version for Spur as yet"<br>
                        and: [imageVersion = self imageFormatCompatibilityVersion]] "Float words in BigEndian order"!<br></blockquote><div><br></div><div class="gmail_default" style="font-size:small">Can we write this as</div><div class="gmail_default" style="font-size:small">    is the image version a Spur version? if so...</div><div class="gmail_default" style="font-size:small">        insist on exact match</div><div class="gmail_default" style="font-size:small">    is the image a priori version? If so...</div><div class="gmail_default" style="font-size:small">        filter the acceptable matches</div><div class="gmail_default" style="font-size:small">    otherwise</div><div class="gmail_default" style="font-size:small">        fail for unrecognised version</div><div class="gmail_default" style="font-size:small">?</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">'cuz this way is more readable/commentable/extensible in the long run.</div><div class="gmail_default" style="font-size:small"><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">Item was changed:<br>
  ----- Method: StackInterpreter>>writeImageFileIO (in category 'image save/restore') -----<br>
  writeImageFileIO<br>
        "Write the image header and heap contents to imageFile for snapshot. c.f. writeImageFileIOSimulation.<br>
         The game below is to maintain 64-bit alignment for all putLong:toFile: occurrences."<br>
        <inline: #never><br>
        | imageName headerStart headerSize f imageBytes bytesWritten sCWIfn okToWrite |<br></blockquote><div class="gmail_default" style="font-size:small">...</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">+       multipleBytecodeSetsActive<br>
+               ifTrue: [self putWord32: (self imageFormatVersion bitOr: MultipleBytecodeSetsBitmask) toFile: f]<br>
+               ifFalse: [self putWord32: self imageFormatVersion toFile: f].<br></blockquote><div><br></div><div class="gmail_default" style="font-size:small">why not extract this to e.g. self imageFormatVersionForSnapshot?</div><div class="gmail_default" style="font-size:small"><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
-       self putWord32: self imageFormatVersion toFile: f.<br>
        self putWord32: headerSize toFile: f.</blockquote><div class="gmail_default" style="font-size:small">...</div></div><div><br></div><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><span style="font-size:small;border-collapse:separate"><div>_,,,^..^,,,_<br></div><div>best, Eliot</div></span></div></div></div></div>