<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">2015-05-21 6:56 GMT+02:00  <span dir="ltr">&lt;<a href="mailto:commits@source.squeak.org" target="_blank">commits@source.squeak.org</a>&gt;</span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
Eliot Miranda uploaded a new version of VMMaker to project VM Maker:<br>
<a href="http://source.squeak.org/VMMaker/VMMaker.oscog-eem.1317.mcz" target="_blank">http://source.squeak.org/VMMaker/VMMaker.oscog-eem.1317.mcz</a><br>
<br>
==================== Summary ====================<br>
<br>
Name: VMMaker.oscog-eem.1317<br>
Author: eem<br>
Time: 20 May 2015, 9:56:04.05 pm<br>
UUID: a7e082b5-1ad8-42ef-84cc-0079605c8440<br>
Ancestors: VMMaker.oscog-eem.1316<br>
<br>
Cogit:<br>
Fix the performance regression on x86 in r3308<br>
VMMaker.oscog-eem.1178 through the use of the XCHG<br>
instruction in CogIA32Compiler&gt;&gt;genPushRegisterArgsForNumArgs:.<br>
Since SendNumArgsReg is not live with small arity sends<br>
it can be used instead of TempReg.<br>
<br>
Replace uses of the magic constant 2 with<br>
NumSendTrampolines - 2 (actually &lt;= 2 =&gt;<br>
&lt; (NumSendTrampolines - 1)) where appropriate. Hence<br>
NumSendTrampolines moved to CogCompilationConstants.<br>
<br>
Fix bug on ARM with pc-relative addressing. pc-relative<br>
addressing can only be used within a method because of relocation.<br>
The old code would use pc-relative addressing to access<br>
trampolines for methods close to the trampolines and then<br>
not for methods further away, causing changes in the code<br>
generated by compileInterpreterPrimitive:.<br>
<br>
To support this, rationalize the PIC compilation code, being sure<br>
to initialize and concretize methodLabel at the start of each PIC.<br>
Don&#39;t bother to pass PIC size as a parameter given we have<br>
PIC-specific header-filling routines now.<br>
<br>
Spur:<br>
Firm up the checkTraversableSortedFreeList assert routine to<br>
check that the list is traversable from lastFreeChunk, not just firstFreeChunk.<br>
<br>
Slang:<br>
Make promoteArithmeticTypes:and: obey C99&#39;s promotion rules<br>
more closely in an effort to generate more stable sources.<br>
Types were flipping between sqInt &amp; usqInt for variables that<br>
were assigned both types, so that one generation would produce<br>
one type and a subsequent one another (Set/Dictionary hashing?).<br>
<br>
Simulation/In-image Compilation:<br>
Fix varBaseAddress calculations for in-image compilation so that<br>
it jives with real compilation.<br>
<br>
Allow setting of recordPrimTrace through initializationOptions.<br>
<br>
=============== Diff against VMMaker.oscog-eem.1316 ===============<br>
<br>
Item was changed:<br>
  ----- Method: CCodeGenerator&gt;&gt;promoteArithmeticTypes:and: (in category &#39;type inference&#39;) -----<br>
  promoteArithmeticTypes: firstType and: secondType<br>
+       &quot;Answer the return type for an arithmetic send.  This is so that the inliner can still inline<br>
+        simple expressions.  Deal with pointer arithmetic, floating point arithmetic and promotion.&quot;<br>
+       | firstSize secondSize |<br>
-       &quot;Answer the return type for an arithmetic sendThis is so that the inliner can still<br>
-        inline simple expressions.  Deal with pointer arithmetic, floating point arithmetic<br>
-        and promotion.&quot;<br>
        ((#(#double float) includes: firstType)<br>
         or: [#(#double float) includes: secondType]) ifTrue:<br>
                [^(firstType = #float and: [secondType = #float])<br>
                        ifTrue: [#float]<br>
                        ifFalse: [#double]].<br>
        &quot;deal with unknowns, answering nil.&quot;<br>
        (firstType isNil or: [secondType isNil]) ifTrue:<br>
                [^nil].<br>
+       &quot;Deal with promotion; answer the longest type, defaulting to the recever if they&#39;re the same.<br>
+        See e.g. section 6.3.1.8 Usual arithmetic conversions, from the C99 standard:<br>
+               Otherwise, the integer promotions are performed on both operands<br>
+               Then the following rules are applied to the promoted operands:<br>
+<br>
+                       If both operands have the same type, then no further conversion is needed.<br>
+<br>
+                       Otherwise, if both operands have signed integer types or both have unsigned integer<br>
+                       types, the operand with the type of lesser integer conversion rank is converted to the<br>
+                       type of the operand with greater rank.<br>
+<br>
+                       Otherwise, if the operand that has unsigned integer type has rank greater or equal to<br>
+                       the rank of the type of the other operand, then the operand with signed integer type<br>
+                       is converted to the type of the operand with unsigned integer type.<br>
+<br>
+                       Otherwise, if the type of the operand with signed integer type can represent all of the<br>
+                       values of the type of the operand with unsigned integer type, then the operand with<br>
+                       unsigned integer type is converted to the type of the operand with signed integer type.<br>
+<br>
+                       Otherwise, both operands are converted to the unsigned integer type corresponding to<br>
+                       the type of the operand with signed integer type.<br>
+<br>
+       It is important to choose deterministically to get stable source generation.  So if the types have<br>
+       the same size but differ in signedness we choose the unsigned type, which is in partial agreement<br>
+       with the above&quot;<br>
+       ^(firstSize := self sizeOfIntegralCType: firstType) = (secondSize := self sizeOfIntegralCType: secondType)<br>
+               ifTrue:<br>
+                       [(firstType first = $u)<br>
+                               ifTrue: [firstType]<br>
+                               ifFalse: [(secondType first = $u) ifTrue: [secondType] ifFalse: [firstType]]]<br>
+               ifFalse:<br>
+                       [firstSize &gt; secondSize ifTrue: [firstType] ifFalse: [secondType]]!<br>
-       &quot;deal with promotion; answer the longest type, defaulting to the recever if they&#39;re the same&quot;<br>
-       ^(self sizeOfIntegralCType: firstType) &gt;= (self sizeOfIntegralCType: secondType)<br>
-               ifTrue: [firstType]<br>
-               ifFalse: [secondType]!<br>
<br></blockquote><div><br>+1<br><br></div><div>That&#39;s how I wrote it a few weeks ago in my experimental branch:<br><a href="http://smalltalkhub.com/mc/nice/NiceVMExperiments/main">http://smalltalkhub.com/mc/nice/NiceVMExperiments/main</a><br><br>promoteIntegerArithmeticTypes: firstType and: secondType<br>    &quot;Answer the return type for an arithmetic send. This is so that the inliner can still<br>     inline simple expressions.  Deal with integer arithmetic and promotion.&quot;<br>    | length1 length2 |<br>    length1 := self sizeOfIntegralCType: firstType.<br>    length2 := self sizeOfIntegralCType: secondType.<br>    length1 &gt; length2 ifTrue: [^firstType].<br>    length2 &gt; length1 ifTrue: [^secondType].<br>    firstType first = $u ifTrue: [^firstType].<br>    secondType first = $u ifTrue: [^secondType].<br>    ^firstType<br><br> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Item was changed:<br>
  ----- Method: CoInterpreter&gt;&gt;varBaseAddress (in category &#39;cog jit support&#39;) -----<br>
  varBaseAddress<br>
        &lt;api&gt;<br>
        &lt;returnTypeC: #usqInt&gt;<br>
+       ^self cCode: [(self addressOf: stackPointer) asUnsignedInteger - 16r42]<br>
+               inSmalltalk: [cogit fakeVarBaseAddress]!<br>
-       ^(self addressOf: stackPointer) asUnsignedInteger - 16r42!<br>
<br>
Item was changed:<br>
  ----- Method: CogARMCompiler&gt;&gt;loadCwInto: (in category &#39;generate machine code - support&#39;) -----<br>
  loadCwInto: destReg<br>
        &quot;Load the operand into the destination register, answering<br>
         the size of the instructions generated to do so.&quot;<br>
        | operand distance |<br>
        operand := operands at: 0.<br>
        &quot;First try and encode as a pc-relative reference...&quot;<br>
+       (cogit addressIsInCurrentCompilation: operand) ifTrue:<br>
+               [distance := operand - (address + 8).<br>
-       (cogit addressIsInCodeZone: operand) ifTrue:<br>
-               [distance := operand  - (address + 8).<br>
                 self rotateable8bitImmediate: distance<br>
                        ifTrue: [ :rot :immediate |<br>
                                self machineCodeAt: 0 put: (self add: destReg rn: PC imm: immediate ror: rot).<br>
                                ^4]<br>
                        ifFalse:<br>
                                [self rotateable8bitImmediate: distance negated<br>
                                        ifTrue: [ :rot :immediate |<br>
                                                self machineCodeAt: 0 put: (self sub: destReg rn: PC imm: immediate ror: rot).<br>
                                                ^4]<br>
                                        ifFalse: []]].<br>
        &quot;If this fails, use the conventional and painfully long 4 instruction sequence.&quot;<br>
        ^self at: 0 moveCw: operand intoR: destReg!<br>
<br>
Item was changed:<br>
  VMStructType subclass: #CogAbstractInstruction<br>
        instanceVariableNames: &#39;opcode machineCodeSize maxSize machineCode operands address dependent cogit objectMemory bcpc&#39;<br>
        classVariableNames: &#39;NumOperands&#39;<br>
+       poolDictionaries: &#39;CogCompilationConstants CogRTLOpcodes&#39;<br>
-       poolDictionaries: &#39;CogRTLOpcodes&#39;<br>
        category: &#39;VMMaker-JIT&#39;!<br>
<br>
  !CogAbstractInstruction commentStamp: &#39;eem 4/21/2015 09:12&#39; prior: 0!<br>
  I am an abstract instruction generated by the Cogit.  I am subsequently concretized to machine code for the current processor.  A sequence of concretized CogAbstractInstructions are concatenated to form the code for a CogMethod.  I am an abstract class.  My concrete subclasses concretize to the machine code of a specific processor.<br>
<br>
  Instance Variables<br>
        address:                        &lt;Integer&gt;<br>
        bcpc:                           &lt;Integer&gt;<br>
        cogit:                          &lt;Cogit&gt;<br>
        dependent:                      &lt;AbstractInstruction|nil&gt;<br>
        machineCode:            &lt;CArray on: (ByteArray|Array)&gt;<br>
        machineCodeSize:        &lt;Integer&gt;<br>
        maxSize:                        &lt;Integer&gt;<br>
        objectMemory:           &lt;NewCoObjectMemory|SpurCoMemoryManager etc&gt;<br>
        opcode:                 &lt;Integer&gt;<br>
        operands:                       &lt;CArray on: Array&gt;<br>
<br>
  address<br>
        - the address at which the instruction will be generated<br>
<br>
  bcpc<br>
        - the bytecode pc for which the instruction was generated; simulation only<br>
<br>
  cogit<br>
        - the Cogit assembling the receiver; simulation only<br>
<br>
  dependent<br>
        - a reference to another instruction which depends on the receiver, if any; in C this is a pointer<br>
<br>
  machineCode<br>
        - the array of machine code the receiver generates when concretized<br>
<br>
  machineCodeSize<br>
        - the size of machineCode in bytes<br>
<br>
  maxSize<br>
        - the maximum size of machine code that the current instruction will generate, in bytes<br>
<br>
  objectMemory<br>
        - the memory manager for the system; simulation only<br>
<br>
  opcode<br>
        - the opcode for the receiver which defines which abstract opcode it represents; see CogRTLOpcodes class&gt;&gt;initialize and CogAbstractInstruction subclass initialize methods<br>
<br>
  operands<br>
        - the array containing any operands the instruction may have; the opcode defines implicitly how many operands are consdered!<br>
<br>
Item was changed:<br>
  SharedPool subclass: #CogCompilationConstants<br>
        instanceVariableNames: &#39;&#39;<br>
+       classVariableNames: &#39;BadRegisterSet NumSendTrampolines SSBaseOffset SSConstant SSIllegal SSRegister SSSpill&#39;<br>
-       classVariableNames: &#39;BadRegisterSet SSBaseOffset SSConstant SSIllegal SSRegister SSSpill&#39;<br>
        poolDictionaries: &#39;&#39;<br>
        category: &#39;VMMaker-JIT&#39;!<br>
<br>
Item was changed:<br>
  ----- Method: CogIA32Compiler&gt;&gt;genPushRegisterArgsForNumArgs: (in category &#39;smalltalk calling convention&#39;) -----<br>
  genPushRegisterArgsForNumArgs: numArgs<br>
+       &quot;Ensure that the register args are pushed before the retpc for arity &lt;= self numRegArgs.  This<br>
+        won&#39;t be as clumsy on a RISC.  But putting the receiver and args above the return address<br>
+        means the CoInterpreter has a single machine-code frame format which saves us a lot of work.<br>
+        N.B. Take great care to /not/ smash TempReg, which is used in directed send marshalling.<br>
+        We could use XCHG to swap the ReceiverResultReg and top-of-stack return address, pushing the<br>
+        the ret pc (now in ReceiverResultReg) later, but XCHG is very slow.  We can use SendNumArgsReg<br>
+        because it is only live in sends of arity &gt;= (NumSendTrampolines - 1).&quot;<br>
+       self assert: cogit numRegArgs &lt; (NumSendTrampolines - 1).<br>
-       &quot;Ensure that the register args are pushed before the retpc for arity &lt;= self numRegArgs.&quot;<br>
-       &quot;This won&#39;t be as clumsy on a RISC.  But putting the receiver and<br>
-        args above the return address means the CoInterpreter has a<br>
-        single machine-code frame format which saves us a lot of work.&quot;<br>
        numArgs &lt;= cogit numRegArgs ifTrue:<br>
                [self assert: cogit numRegArgs &lt;= 2.<br>
+                false &quot;these two variants show the same performance on Intel Core i7, but the second one may be shorter.&quot;<br>
+                       ifTrue:<br>
+                               [cogit MoveMw: 0 r: SPReg R: SendNumArgsReg. &quot;Save return pc&quot;<br>
+                                numArgs &gt; 0 ifTrue:<br>
+                                       [cogit PushR: Arg0Reg.<br>
+                                        numArgs &gt; 1 ifTrue:<br>
+                                               [cogit PushR: Arg1Reg]].<br>
+                                cogit PushR: SendNumArgsReg.<br>
+                                cogit MoveR: ReceiverResultReg Mw: objectMemory wordSize * (1 + numArgs) r: SPReg]<br>
+                       ifFalse:<br>
+                               [&quot;a.k.a.<br>
+                                       cogit gen: XCHGMwrR operand: 0 operand: SPReg operand: ReceiverResultReg.<br>
+                                 but XCHG is slow.&quot;<br>
+                                cogit MoveMw: 0 r: SPReg R: SendNumArgsReg. &quot;Save return pc&quot;<br>
+                                cogit MoveR: ReceiverResultReg Mw: 0 r: SPReg.<br>
+                                numArgs &gt; 0 ifTrue:<br>
+                                       [cogit PushR: Arg0Reg.<br>
+                                        numArgs &gt; 1 ifTrue:<br>
+                                               [cogit PushR: Arg1Reg]].<br>
+                                cogit PushR: SendNumArgsReg]] &quot;Restore return address&quot;!<br>
-                &quot;N.B. Take great care to /not/ smash TempReg, which is used in directed send marshalling.&quot;<br>
-                &quot;Swap the return address with ReceiverResultReg&quot;<br>
-                cogit gen: XCHGMwrR operand: 0 operand: SPReg operand: ReceiverResultReg. &quot;Save return address; replace with receiver&quot;<br>
-                numArgs &gt; 0 ifTrue:<br>
-                       [cogit PushR: Arg0Reg.<br>
-                        numArgs &gt; 1 ifTrue:<br>
-                               [cogit PushR: Arg1Reg]].<br>
-               cogit PushR: ReceiverResultReg.<br>
-               &quot;Reload ReceiverResultReg&quot;<br>
-               cogit MoveMw: numArgs + 1 * objectMemory wordSize r: SPReg R: ReceiverResultReg]!<br>
<br>
Item was changed:<br>
  CogClass subclass: #Cogit<br>
        instanceVariableNames: &#39;coInterpreter objectMemory objectRepresentation processor threadManager methodZone methodZoneBase codeBase minValidCallAddress lastNInstructions simulatedAddresses simulatedTrampolines simulatedVariableGetters simulatedVariableSetters printRegisters printInstructions compilationTrace clickConfirm breakPC breakBlock singleStep guardPageSize traceFlags traceStores breakMethod methodObj initialPC endPC methodOrBlockNumArgs inBlock needsFrame hasYoungReferent primitiveIndex backEnd callerSavedRegMask postCompileHook primInvokeLabel methodLabel stackCheckLabel blockEntryLabel blockEntryNoContextSwitch blockNoContextSwitchOffset stackOverflowCall sendMiss missOffset entryPointMask checkedEntryAlignment uncheckedEntryAlignment cmEntryOffset entry cmNoCheckEntryOffset noCheckEntry picMNUAbort picInterpretAbort endCPICCase0 endCPICCase1 numPICCases firstCPICCaseOffset cPICCaseSize cPICEndSize closedPICSize openPICSize fixups abstractOpcodes annotations generatorTable primitiveGeneratorTable byte0 byte1 byte2 byte3 bytecodePC bytecodeSetOffset opcodeIndex numAbstractOpcodes annotationIndex blockStarts blockCount labelCounter cStackAlignment expectedSPAlignment expectedFPAlignment codeModified maxLitIndex ceMethodAbortTrampoline cePICAbortTrampoline ceCheckForInterruptTrampoline ceCPICMissTrampoline ceReturnToInterpreterTrampoline ceBaseFrameReturnTrampoline ceSendMustBeBooleanAddTrueTrampoline ceSendMustBeBooleanAddFalseTrampoline ceCannotResumeTrampoline ceEnterCogCodePopReceiverReg ceCallCogCodePopReceiverReg ceCallCogCodePopReceiverAndClassRegs cePrimReturnEnterCogCode cePrimReturnEnterCogCodeProfiling ceNonLocalReturnTrampoline ceFetchContextInstVarTrampoline ceStoreContextInstVarTrampoline ceEnclosingObjectTrampoline ceCaptureCStackPointers ceFlushICache ceCheckFeaturesFunction ceTraceLinkedSendTrampoline ceTraceBlockActivationTrampoline ceTraceStoreTrampoline ceGetSP ordinarySendTrampolines superSendTrampolines directedSuperSendTrampolines dynamicSuperSendTrampolines outerSendTrampolines selfSendTrampolines firstSend lastSend realCEEnterCogCodePopReceiverReg realCECallCogCodePopReceiverReg realCECallCogCodePopReceiverAndClassRegs trampolineTableIndex trampolineAddresses objectReferencesInRuntime runtimeObjectRefIndex cFramePointerInUse debugPrimCallStackOffset ceTryLockVMOwner ceUnlockVMOwner cogMethodSurrogateClass cogBlockMethodSurrogateClass extA extB numIRCs indexOfIRC theIRCs implicitReceiverSendTrampolines nsSendCacheSurrogateClass tempOop&#39;<br>
+       classVariableNames: &#39;AltBlockCreationBytecodeSize AltFirstSpecialSelector AltNSSendIsPCAnnotated AnnotationConstantNames AnnotationShift AnnotationsWithBytecodePCs BlockCreationBytecodeSize Debug DisplacementMask DisplacementX2N EagerInstructionDecoration FirstAnnotation FirstSpecialSelector HasBytecodePC IsAbsPCReference IsAnnotationExtension IsDirectedSuperSend IsDisplacementX2N IsNSDynamicSuperSend IsNSImplicitReceiverSend IsNSSelfSend IsNSSendCall IsObjectReference IsRelativeCall IsSendCall IsSuperSend MapEnd MaxCompiledPrimitiveIndex MaxStackAllocSize MaxX2NDisplacement NSCClassTagIndex NSCEnclosingObjectIndex NSCNumArgsIndex NSCSelectorIndex NSCTargetIndex NSSendIsPCAnnotated NumObjRefsInRuntime NumOopsPerNSC NumTrampolines ProcessorClass&#39;<br>
-       classVariableNames: &#39;AltBlockCreationBytecodeSize AltFirstSpecialSelector AltNSSendIsPCAnnotated AnnotationConstantNames AnnotationShift AnnotationsWithBytecodePCs BlockCreationBytecodeSize Debug DisplacementMask DisplacementX2N EagerInstructionDecoration FirstAnnotation FirstSpecialSelector HasBytecodePC IsAbsPCReference IsAnnotationExtension IsDirectedSuperSend IsDisplacementX2N IsNSDynamicSuperSend IsNSImplicitReceiverSend IsNSSelfSend IsNSSendCall IsObjectReference IsRelativeCall IsSendCall IsSuperSend MapEnd MaxCompiledPrimitiveIndex MaxStackAllocSize MaxX2NDisplacement NSCClassTagIndex NSCEnclosingObjectIndex NSCNumArgsIndex NSCSelectorIndex NSCTargetIndex NSSendIsPCAnnotated NumObjRefsInRuntime NumOopsPerNSC NumSendTrampolines NumTrampolines ProcessorClass&#39;<br>
        poolDictionaries: &#39;CogCompilationConstants CogMethodConstants CogRTLOpcodes VMBasicConstants VMBytecodeConstants VMObjectIndices VMStackFrameOffsets&#39;<br>
        category: &#39;VMMaker-JIT&#39;!<br>
  Cogit class<br>
        instanceVariableNames: &#39;generatorTable primitiveTable&#39;!<br>
<br>
  !Cogit commentStamp: &#39;eem 4/6/2015 15:56&#39; prior: 0!<br>
  I am the code generator for the Cog VM.  My job is to produce machine code versions of methods for faster execution and to manage inline caches for faster send performance.  I can be tested in the current image using my class-side in-image compilation facilities.  e.g. try<br>
<br>
        StackToRegisterMappingCogit genAndDis: (Integer &gt;&gt; #benchFib)<br>
<br>
  I have concrete subclasses that implement different levels of optimization:<br>
        SimpleStackBasedCogit is the simplest code generator.<br>
<br>
        StackToRegisterMappingCogit is the current production code generator  It defers pushing operands<br>
        to the stack until necessary and implements a register-based calling convention for low-arity sends.<br>
<br>
        StackToRegisterMappingCogit is an experimental code generator with support for counting<br>
        conditional branches, intended to support adaptive optimization.<br>
<br>
  coInterpreter &lt;CoInterpreterSimulator&gt;<br>
        the VM&#39;s interpreter with which I cooperate<br>
  methodZoneManager &lt;CogMethodZoneManager&gt;<br>
        the manager of the machine code zone<br>
  objectRepresentation &lt;CogObjectRepresentation&gt;<br>
        the object used to generate object accesses<br>
  processor &lt;BochsIA32Alien|?&gt;<br>
        the simulator that executes the IA32/x86 machine code I generate when simulating execution in Smalltalk<br>
  simulatedTrampolines &lt;Dictionary of Integer -&gt; MessageSend&gt;<br>
        the dictionary mapping trap jump addresses to run-time routines used to warp from simulated machine code in to the Smalltalk run-time.<br>
  simulatedVariableGetters &lt;Dictionary of Integer -&gt; MessageSend&gt;<br>
        the dictionary mapping trap read addresses to variables in run-time objects used to allow simulated machine code to read variables in the Smalltalk run-time.<br>
  simulatedVariableSetters &lt;Dictionary of Integer -&gt; MessageSend&gt;<br>
        the dictionary mapping trap write addresses to variables in run-time objects used to allow simulated machine code to write variables in the Smalltalk run-time.<br>
  printRegisters printInstructions clickConfirm &lt;Boolean&gt;<br>
        flags controlling debug printing and code simulation<br>
  breakPC &lt;Integer&gt;<br>
        machine code pc breakpoint<br>
  cFramePointer cStackPointer &lt;Integer&gt;<br>
        the variables representing the C stack &amp; frame pointers, which must change on FFI callback and return<br>
  selectorOop &lt;sqInt&gt;<br>
        the oop of the methodObj being compiled<br>
  methodObj &lt;sqInt&gt;<br>
        the bytecode method being compiled<br>
  initialPC endPC &lt;Integer&gt;<br>
        the start and end pcs of the methodObj being compiled<br>
  methodOrBlockNumArgs &lt;Integer&gt;<br>
        argument count of current method or block being compiled<br>
  needsFrame &lt;Boolean&gt;<br>
        whether methodObj or block needs a frame to execute<br>
  primitiveIndex &lt;Integer&gt;<br>
        primitive index of current method being compiled<br>
  methodLabel &lt;CogAbstractOpcode&gt;<br>
        label for the method header<br>
  blockEntryLabel &lt;CogAbstractOpcode&gt;<br>
        label for the start of the block dispatch code<br>
  stackOverflowCall &lt;CogAbstractOpcode&gt;<br>
        label for the call of ceStackOverflow in the method prolog<br>
  sendMissCall &lt;CogAbstractOpcode&gt;<br>
        label for the call of ceSICMiss in the method prolog<br>
  entryOffset &lt;Integer&gt;<br>
        offset of method entry code from start (header) of method<br>
  entry &lt;CogAbstractOpcode&gt;<br>
        label for the first instruction of the method entry code<br>
  noCheckEntryOffset &lt;Integer&gt;<br>
        offset of the start of a method proper (after the method entry code) from start (header) of method<br>
  noCheckEntry &lt;CogAbstractOpcode&gt;<br>
        label for the first instruction of start of a method proper<br>
  fixups &lt;Array of &lt;AbstractOpcode Label | nil&gt;&gt;<br>
        the labels for forward jumps that will be fixed up when reaching the relevant bytecode.  fixup shas one element per byte in methodObj&#39;s bytecode<br>
  abstractOpcodes &lt;Array of &lt;AbstractOpcode&gt;&gt;<br>
        the code generated when compiling methodObj<br>
  byte0 byte1 byte2 byte3 &lt;Integer&gt;<br>
        individual bytes of current bytecode being compiled in methodObj<br>
  bytecodePointer &lt;Integer&gt;<br>
        bytecode pc (same as Smalltalk) of the current bytecode being compiled<br>
  opcodeIndex &lt;Integer&gt;<br>
        the index of the next free entry in abstractOpcodes (this code is translated into C where OrderedCollection et al do not exist)<br>
  numAbstractOpcodes &lt;Integer&gt;<br>
        the number of elements in abstractOpcocdes<br>
  blockStarts &lt;Array of &lt;BlockStart&gt;&gt;<br>
        the starts of blocks in the current method<br>
  blockCount<br>
        the index into blockStarts as they are being noted, and hence eventually the total number of blocks in the current method<br>
  labelCounter &lt;Integer&gt;<br>
        a nicety for numbering labels not needed in the production system but probably not expensive enough to worry about<br>
  ceStackOverflowTrampoline &lt;Integer&gt;<br>
  ceSend0ArgsTrampoline &lt;Integer&gt;<br>
  ceSend1ArgsTrampoline &lt;Integer&gt;<br>
  ceSend2ArgsTrampoline &lt;Integer&gt;<br>
  ceSendNArgsTrampoline &lt;Integer&gt;<br>
  ceSendSuper0ArgsTrampoline &lt;Integer&gt;<br>
  ceSendSuper1ArgsTrampoline &lt;Integer&gt;<br>
  ceSendSuper2ArgsTrampoline &lt;Integer&gt;<br>
  ceSendSuperNArgsTrampoline &lt;Integer&gt;<br>
  ceSICMissTrampoline &lt;Integer&gt;<br>
  ceCPICMissTrampoline &lt;Integer&gt;<br>
  ceStoreCheckTrampoline &lt;Integer&gt;<br>
  ceReturnToInterpreterTrampoline &lt;Integer&gt;<br>
  ceBaseFrameReturnTrampoline &lt;Integer&gt;<br>
  ceSendMustBeBooleanTrampoline &lt;Integer&gt;<br>
  ceClosureCopyTrampoline &lt;Integer&gt;<br>
        the various trampolines (system-call-like jumps from machine code to the run-time).<br>
        See Cogit&gt;&gt;generateTrampolines for the mapping from trampoline to run-time<br>
        routine and then read the run-time routine for a funcitonal description.<br>
  ceEnterCogCodePopReceiverReg &lt;Integer&gt;<br>
        the enilopmart (jump from run-time to machine-code)<br>
  methodZoneBase &lt;Integer&gt;<br>
  !<br>
  Cogit class<br>
        instanceVariableNames: &#39;generatorTable primitiveTable&#39;!<br>
<br>
Item was added:<br>
+ ----- Method: Cogit&gt;&gt;addressIsInCurrentCompilation: (in category &#39;testing&#39;) -----<br>
+ addressIsInCurrentCompilation: address<br>
+       ^address asUnsignedInteger &gt;= methodLabel address<br>
+         and: [address &lt; (methodLabel address + (1 &lt;&lt; 16))]!<br>
<br>
Item was changed:<br>
  ----- Method: Cogit&gt;&gt;codeRangesFor: (in category &#39;disassembly&#39;) -----<br>
  codeRangesFor: cogMethod<br>
        &quot;Answer a sequence of ranges of code for the main method and all of the blocks in a CogMethod.<br>
         N.B.  These are in order of block dispatch, _not_ necessarily address order in the method.&quot;<br>
        &lt;doNotGenerate&gt;<br>
        | pc end blockEntry starts |<br>
        cogMethod cmType = CMClosedPIC ifTrue:<br>
                [end := (self addressOfEndOfCase: cogMethod cPICNumCases - 1 inCPIC: cogMethod) + cPICEndSize.<br>
                 ^{ CogCodeRange<br>
                                from: cogMethod asInteger + (self sizeof: CogMethod)<br>
                                to: end<br>
                                cogMethod: cogMethod<br>
                                startpc: nil }].<br>
        end := (self mapEndFor: cogMethod) - 1.<br>
        cogMethod blockEntryOffset = 0 ifTrue:<br>
                [^{ CogCodeRange<br>
                                from: cogMethod asInteger + (self sizeof: CogMethod)<br>
                                to: end<br>
                                cogMethod: cogMethod<br>
+                               startpc: (cogMethod cmType ~= CMOpenPIC ifTrue:<br>
+                                                       [coInterpreter startPCOfMethodHeader: cogMethod methodHeader]) }].<br>
-                               startpc: (coInterpreter startPCOfMethodHeader: cogMethod methodHeader) }].<br>
        pc := blockEntry := cogMethod blockEntryOffset + cogMethod asInteger.<br>
        starts := OrderedCollection with: cogMethod.<br>
        [pc &lt; end] whileTrue:<br>
                [| targetpc |<br>
                 targetpc := blockEntry.<br>
                 (backEnd isJumpAt: pc) ifTrue:<br>
                        [targetpc := backEnd jumpTargetPCAt: pc.<br>
                         targetpc &lt; blockEntry ifTrue:<br>
                                [starts add: (self cCoerceSimple: targetpc - (self sizeof: CogBlockMethod) to: #&#39;CogBlockMethod *&#39;)]].<br>
                 pc := pc + (backEnd instructionSizeAt: pc)].<br>
        starts := starts asSortedCollection.<br>
        ^(1 to: starts size + 1) collect:<br>
                [:i| | cogSubMethod nextpc |<br>
                i &lt;= starts size<br>
                        ifTrue:<br>
                                [cogSubMethod := starts at: i.<br>
                                 nextpc := i &lt; starts size ifTrue: [(starts at: i + 1) address] ifFalse: [blockEntry].<br>
                                 CogCodeRange<br>
                                        from: cogSubMethod address + (self sizeof: cogSubMethod)<br>
                                        to: nextpc - 1<br>
                                        cogMethod: cogSubMethod<br>
                                        startpc: (i = 1<br>
                                                                ifTrue: [coInterpreter startPCOfMethodHeader: cogMethod methodHeader]<br>
                                                                ifFalse: [cogSubMethod startpc])]<br>
                        ifFalse:<br>
                                [CogCodeRange<br>
                                        from: blockEntry<br>
                                        to: end]]!<br>
<br>
Item was changed:<br>
  ----- Method: Cogit&gt;&gt;cogMNUPICSelector:receiver:methodOperand:numArgs: (in category &#39;in-line cacheing&#39;) -----<br>
  cogMNUPICSelector: selector receiver: rcvr methodOperand: methodOperand numArgs: numArgs<br>
        &lt;api&gt;<br>
        &quot;Attempt to create a one-case PIC for an MNU.<br>
         The tag for the case is at the send site and so doesn&#39;t need to be generated.&quot;<br>
        &lt;returnTypeC: #&#39;CogMethod *&#39;&gt;<br>
+       | startAddress size end |<br>
-       | startAddress headerSize size end |<br>
        ((objectMemory isYoung: selector)<br>
         or: [(objectRepresentation inlineCacheTagForInstance: rcvr) = self picAbortDiscriminatorValue]) ifTrue:<br>
                [^0].<br>
        coInterpreter<br>
                compilationBreak: selector<br>
                point: (objectMemory numBytesOf: selector)<br>
                isMNUCase: true.<br>
        self assert: endCPICCase0 notNil.<br>
        startAddress := methodZone allocate: closedPICSize.<br>
        startAddress = 0 ifTrue:<br>
                [coInterpreter callForCogCompiledCodeCompaction.<br>
                 ^0].<br>
        methodLabel<br>
                address: startAddress;<br>
                dependent: nil.<br>
        &quot;stack allocate the various collections so that they<br>
         are effectively garbage collected on return.&quot;<br>
        self allocateOpcodes: numPICCases * 7 bytecodes: 0.<br>
        self compileMNUCPIC: (self cCoerceSimple: startAddress to: #&#39;CogMethod *&#39;)<br>
                methodOperand: methodOperand<br>
                numArgs: numArgs.<br>
        self computeMaximumSizes.<br>
+       methodLabel concretizeAt: startAddress.<br>
+       size := self generateInstructionsAt: startAddress + (self sizeof: CogMethod).<br>
+       end := self outputInstructionsAt: startAddress + (self sizeof: CogMethod).<br>
-       headerSize := self sizeof: CogMethod.<br>
-       size := self generateInstructionsAt: startAddress + headerSize.<br>
-       end := self outputInstructionsAt: startAddress + headerSize.<br>
        &quot;The missOffset is the same as the interpretOffset. On RISCs it includes an additional instruction.&quot;<br>
        self assert: missOffset = ((backEnd hasLinkRegister ifTrue: [backEnd callInstructionByteSize] ifFalse: [0])<br>
                                                                + picInterpretAbort address + picInterpretAbort machineCodeSize - startAddress).<br>
        self assert: startAddress + cmEntryOffset = entry address.<br>
        ^self<br>
                fillInCPICHeader: (self cCoerceSimple: startAddress to: #&#39;CogMethod *&#39;)<br>
-               size: closedPICSize<br>
                numArgs: numArgs<br>
                numCases: 1<br>
                hasMNUCase: true<br>
                selector: selector !<br>
<br>
Item was changed:<br>
  ----- Method: Cogit&gt;&gt;cogOpenPICSelector:numArgs: (in category &#39;in-line cacheing&#39;) -----<br>
  cogOpenPICSelector: selector numArgs: numArgs<br>
        &quot;Create an Open PIC.  Temporarily create a direct call of ceSendFromOpenPIC:.<br>
         Should become a probe of the first-level method lookup cache followed by a<br>
         call of ceSendFromOpenPIC: if the probe fails.&quot;<br>
        &lt;returnTypeC: #&#39;CogMethod *&#39;&gt;<br>
+       | startAddress codeSize mapSize end |<br>
-       | startAddress headerSize codeSize mapSize end |<br>
        coInterpreter<br>
                compilationBreak: selector<br>
                point: (objectMemory numBytesOf: selector)<br>
                isMNUCase: false.<br>
        startAddress := methodZone allocate: openPICSize.<br>
        startAddress = 0 ifTrue:<br>
                [^self cCoerceSimple: InsufficientCodeSpace to: #&#39;CogMethod *&#39;].<br>
        methodLabel<br>
                address: startAddress;<br>
                dependent: nil.<br>
        &quot;stack allocate the various collections so that they<br>
         are effectively garbage collected on return.&quot;<br>
        self allocateOpcodes: 100 bytecodes: 0.<br>
        self compileOpenPIC: selector numArgs: numArgs.<br>
        self computeMaximumSizes.<br>
        methodLabel concretizeAt: startAddress.<br>
+       codeSize := self generateInstructionsAt: startAddress + (self sizeof: CogMethod).<br>
-       headerSize := self sizeof: CogMethod.<br>
-       codeSize := self generateInstructionsAt: startAddress + headerSize.<br>
        mapSize := self generateMapAt: startAddress + openPICSize - 1 start: startAddress + cmNoCheckEntryOffset.<br>
        self assert: entry address - startAddress = cmEntryOffset.<br>
+       self assert: (methodZone roundUpLength: (self sizeof: CogMethod) + codeSize) + (methodZone roundUpLength: mapSize) &lt;= openPICSize.<br>
+       end := self outputInstructionsAt: startAddress + (self sizeof: CogMethod).<br>
-       self assert: headerSize + codeSize + mapSize &lt;= openPICSize.<br>
-       end := self outputInstructionsAt: startAddress + headerSize.<br>
        ^self<br>
                fillInOPICHeader: (self cCoerceSimple: startAddress to: #&#39;CogMethod *&#39;)<br>
-               size: openPICSize<br>
                numArgs: numArgs<br>
                selector: selector !<br>
<br>
Item was changed:<br>
  ----- Method: Cogit&gt;&gt;cogPICSelector:numArgs:Case0Method:Case1Method:tag:isMNUCase: (in category &#39;in-line cacheing&#39;) -----<br>
  cogPICSelector: selector numArgs: numArgs Case0Method: case0CogMethod Case1Method: case1MethodOrNil tag: case1Tag isMNUCase: isMNUCase<br>
        &quot;Attempt to create a two-case PIC for case0CogMethod and  case1Method,case1Tag.<br>
         The tag for case0CogMethod is at the send site and so doesn&#39;t need to be generated.<br>
         case1Method may be any of<br>
                - a Cog method; link to its unchecked entry-point<br>
                - a CompiledMethod; link to ceInterpretMethodFromPIC:<br>
                - a CompiledMethod; link to ceMNUFromPICMNUMethod:receiver:&quot;<br>
        &lt;var: #case0CogMethod type: #&#39;CogMethod *&#39;&gt;<br>
        &lt;returnTypeC: #&#39;CogMethod *&#39;&gt;<br>
+       | startAddress size end |<br>
-       | startAddress headerSize size end |<br>
        (objectMemory isYoung: selector) ifTrue:<br>
                [^self cCoerceSimple: YoungSelectorInPIC to: #&#39;CogMethod *&#39;].<br>
        coInterpreter<br>
                compilationBreak: selector<br>
                point: (objectMemory numBytesOf: selector)<br>
                isMNUCase: isMNUCase.<br>
        startAddress := methodZone allocate: closedPICSize.<br>
        startAddress = 0 ifTrue:<br>
                [^self cCoerceSimple: InsufficientCodeSpace to: #&#39;CogMethod *&#39;].<br>
        methodLabel<br>
                address: startAddress;<br>
                dependent: nil.<br>
        &quot;stack allocate the various collections so that they<br>
         are effectively garbage collected on return.&quot;<br>
        self allocateOpcodes: numPICCases * 7 bytecodes: 0.<br>
        self compileCPIC: (self cCoerceSimple: startAddress to: #&#39;CogMethod *&#39;)<br>
                Case0: case0CogMethod<br>
                Case1Method: case1MethodOrNil<br>
                tag: case1Tag<br>
                isMNUCase: isMNUCase<br>
                numArgs: numArgs.<br>
        self computeMaximumSizes.<br>
+       methodLabel concretizeAt: startAddress.<br>
+       size := self generateInstructionsAt: startAddress + (self sizeof: CogMethod).<br>
+       end := self outputInstructionsAt: startAddress + (self sizeof: CogMethod).<br>
-       headerSize := self sizeof: CogMethod.<br>
-       size := self generateInstructionsAt: startAddress + headerSize.<br>
-       end := self outputInstructionsAt: startAddress + headerSize.<br>
        &quot;The missOffset is the same as the interpretOffset. On RISCs it includes an additional instruction.&quot;<br>
        self assert: missOffset = ((backEnd hasLinkRegister ifTrue: [backEnd callInstructionByteSize] ifFalse: [0])<br>
                                                                + picInterpretAbort address + picInterpretAbort machineCodeSize - startAddress).<br>
        self assert: startAddress + cmEntryOffset = entry address.<br>
        self assert: endCPICCase0 address = (startAddress + firstCPICCaseOffset).<br>
        self assert: endCPICCase1 address = (startAddress + firstCPICCaseOffset + cPICCaseSize).<br>
        ^self<br>
                fillInCPICHeader: (self cCoerceSimple: startAddress to: #&#39;CogMethod *&#39;)<br>
-               size: closedPICSize<br>
                numArgs: numArgs<br>
                numCases: 2<br>
                hasMNUCase: isMNUCase<br>
                selector: selector !<br>
<br>
Item was added:<br>
+ ----- Method: Cogit&gt;&gt;fakeVarBaseAddress (in category &#39;accessing&#39;) -----<br>
+ fakeVarBaseAddress<br>
+       &quot;We expect simulatedAddresses to have around 40 entries.  48 is hopefully a good maximum.&quot;<br>
+       &lt;doNotGenerate&gt;<br>
+       ^self fakeAddressFor: nil index: 48!<br>
<br>
Item was added:<br>
+ ----- Method: Cogit&gt;&gt;fillInCPICHeader:numArgs:numCases:hasMNUCase:selector: (in category &#39;generate machine code&#39;) -----<br>
+ fillInCPICHeader: pic numArgs: numArgs numCases: numCases hasMNUCase: hasMNUCase selector: selector<br>
+       &lt;returnTypeC: #&#39;CogMethod *&#39;&gt;<br>
+       &lt;var: #pic type: #&#39;CogMethod *&#39;&gt;<br>
+       &lt;inline: true&gt;<br>
+       self assert: (objectMemory isYoung: selector) not.<br>
+       pic cmType: CMClosedPIC.<br>
+       pic objectHeader: 0.<br>
+       pic blockSize: closedPICSize.<br>
+       pic methodObject: 0.<br>
+       pic methodHeader: 0.<br>
+       pic selector: selector.<br>
+       pic cmNumArgs: numArgs.<br>
+       pic cmRefersToYoung: false.<br>
+       pic cmUsageCount: self initialClosedPICUsageCount.<br>
+       pic cpicHasMNUCase: hasMNUCase.<br>
+       pic cPICNumCases: numCases.<br>
+       pic blockEntryOffset: 0.<br>
+       self assert: pic cmType = CMClosedPIC.<br>
+       self assert: pic selector = selector.<br>
+       self assert: pic cmNumArgs = numArgs.<br>
+       self assert: pic cPICNumCases = numCases.<br>
+       self assert: (backEnd callTargetFromReturnAddress: pic asInteger + missOffset) = (self picAbortTrampolineFor: numArgs).<br>
+       self assert: closedPICSize = (methodZone roundUpLength: closedPICSize).<br>
+       processor flushICacheFrom: pic asUnsignedInteger to: pic asUnsignedInteger + closedPICSize.<br>
+       ^pic!<br>
<br>
Item was removed:<br>
- ----- Method: Cogit&gt;&gt;fillInCPICHeader:size:numArgs:numCases:hasMNUCase:selector: (in category &#39;generate machine code&#39;) -----<br>
- fillInCPICHeader: pic size: size numArgs: numArgs numCases: numCases hasMNUCase: hasMNUCase selector: selector<br>
-       &lt;returnTypeC: #&#39;CogMethod *&#39;&gt;<br>
-       &lt;var: #pic type: #&#39;CogMethod *&#39;&gt;<br>
-       self assert: (objectMemory isYoung: selector) not.<br>
-       pic cmType: CMClosedPIC.<br>
-       pic objectHeader: 0.<br>
-       pic blockSize: size.<br>
-       pic methodObject: 0.<br>
-       pic methodHeader: 0.<br>
-       pic selector: selector.<br>
-       pic cmNumArgs: numArgs.<br>
-       pic cmRefersToYoung: false.<br>
-       pic cmUsageCount: self initialClosedPICUsageCount.<br>
-       pic cpicHasMNUCase: hasMNUCase.<br>
-       pic cPICNumCases: numCases.<br>
-       pic blockEntryOffset: 0.<br>
-       self assert: pic cmType = CMClosedPIC.<br>
-       self assert: pic selector = selector.<br>
-       self assert: pic cmNumArgs = numArgs.<br>
-       self assert: pic cPICNumCases = numCases.<br>
-       self assert: (backEnd callTargetFromReturnAddress: pic asInteger + missOffset) = (self picAbortTrampolineFor: numArgs).<br>
-       self assert: size = (methodZone roundUpLength: size).<br>
-       processor flushICacheFrom: pic asUnsignedInteger to: pic asUnsignedInteger + size.<br>
-       ^pic!<br>
<br>
Item was added:<br>
+ ----- Method: Cogit&gt;&gt;fillInOPICHeader:numArgs:selector: (in category &#39;generate machine code&#39;) -----<br>
+ fillInOPICHeader: pic numArgs: numArgs selector: selector<br>
+       &lt;returnTypeC: #&#39;CogMethod *&#39;&gt;<br>
+       &lt;var: #pic type: #&#39;CogMethod *&#39;&gt;<br>
+       &lt;inline: true&gt;<br>
+       pic cmType: CMOpenPIC.<br>
+       pic objectHeader: 0.<br>
+       pic blockSize: openPICSize.<br>
+       &quot;pic methodObject: 0.&quot;&quot;This is also the nextOpenPIC link so don&#39;t initialize it&quot;<br>
+       methodZone addToOpenPICList: pic.<br>
+       pic methodHeader: 0.<br>
+       pic selector: selector.<br>
+       pic cmNumArgs: numArgs.<br>
+       (pic cmRefersToYoung: (objectMemory isYoung: selector)) ifTrue:<br>
+               [methodZone addToYoungReferrers: pic].<br>
+       pic cmUsageCount: self initialOpenPICUsageCount.<br>
+       pic cpicHasMNUCase: false.<br>
+       pic cPICNumCases: 0.<br>
+       pic blockEntryOffset: 0.<br>
+       self assert: pic cmType = CMOpenPIC.<br>
+       self assert: pic selector = selector.<br>
+       self assert: pic cmNumArgs = numArgs.<br>
+       self assert: (backEnd callTargetFromReturnAddress: pic asInteger + missOffset) = (self picAbortTrampolineFor: numArgs).<br>
+       self assert: openPICSize = (methodZone roundUpLength: openPICSize).<br>
+       processor flushICacheFrom: pic asUnsignedInteger to: pic asUnsignedInteger + openPICSize.<br>
+       ^pic!<br>
<br>
Item was removed:<br>
- ----- Method: Cogit&gt;&gt;fillInOPICHeader:size:numArgs:selector: (in category &#39;generate machine code&#39;) -----<br>
- fillInOPICHeader: pic size: size numArgs: numArgs selector: selector<br>
-       &lt;returnTypeC: #&#39;CogMethod *&#39;&gt;<br>
-       &lt;var: #pic type: #&#39;CogMethod *&#39;&gt;<br>
-       pic cmType: CMOpenPIC.<br>
-       pic objectHeader: 0.<br>
-       pic blockSize: size.<br>
-       &quot;pic methodObject: 0.&quot;&quot;This is also the nextOpenPIC link so don&#39;t initialize it&quot;<br>
-       methodZone addToOpenPICList: pic.<br>
-       pic methodHeader: 0.<br>
-       pic selector: selector.<br>
-       pic cmNumArgs: numArgs.<br>
-       (pic cmRefersToYoung: (objectMemory isYoung: selector)) ifTrue:<br>
-               [methodZone addToYoungReferrers: pic].<br>
-       pic cmUsageCount: self initialOpenPICUsageCount.<br>
-       pic cpicHasMNUCase: false.<br>
-       pic cPICNumCases: 0.<br>
-       pic blockEntryOffset: 0.<br>
-       self assert: pic cmType = CMOpenPIC.<br>
-       self assert: pic selector = selector.<br>
-       self assert: pic cmNumArgs = numArgs.<br>
-       self assert: (backEnd callTargetFromReturnAddress: pic asInteger + missOffset) = (self picAbortTrampolineFor: numArgs).<br>
-       self assert: size = (methodZone roundUpLength: size).<br>
-       processor flushICacheFrom: pic asUnsignedInteger to: pic asUnsignedInteger + size.<br>
-       ^pic!<br>
<br>
Item was changed:<br>
  ----- Method: Cogit&gt;&gt;generateClosedPICPrototype (in category &#39;initialization&#39;) -----<br>
  generateClosedPICPrototype<br>
        &quot;Generate the prototype ClosedPIC to determine how much space as full PIC takes.<br>
         When we first allocate a closed PIC it only has one or two cases and we want to grow it.<br>
         So we have to determine how big a full one is before hand.&quot;<br>
-       | headerSize |<br>
        numPICCases := 6.<br>
        &quot;stack allocate the various collections so that they<br>
         are effectively garbage collected on return.&quot;<br>
        self allocateOpcodes: numPICCases * 7 bytecodes: 0.<br>
        self compileClosedPICPrototype.<br>
        self computeMaximumSizes.<br>
+       methodLabel concretizeAt: methodZoneBase.<br>
+       closedPICSize := (self sizeof: CogMethod) + (self generateInstructionsAt: methodZoneBase + (self sizeof: CogMethod)).<br>
-       headerSize := self sizeof: CogMethod.<br>
-       closedPICSize := headerSize + (self generateInstructionsAt: methodZoneBase + headerSize).<br>
        firstCPICCaseOffset := endCPICCase0 address - methodZoneBase.<br>
        cPICCaseSize := endCPICCase1 address - endCPICCase0 address.<br>
        cPICEndSize := closedPICSize - (numPICCases - 1 * cPICCaseSize + firstCPICCaseOffset).<br>
        closedPICSize := methodZone roundUpLength: closedPICSize<br>
        &quot;self cCode: &#39;&#39;<br>
                inSmalltalk:<br>
                        [| end |<br>
                         end := self outputInstructionsAt: methodZoneBase + headerSize.<br>
                         self disassembleFrom: methodZoneBase + headerSize to: end - 1.<br>
                         self halt]&quot;!<br>
<br>
Item was changed:<br>
  ----- Method: Cogit&gt;&gt;generateOpenPICPrototype (in category &#39;initialization&#39;) -----<br>
  generateOpenPICPrototype<br>
        &quot;Generate the prototype ClosedPIC to determine how much space as full PIC takes.<br>
         When we first allocate a closed PIC it only has one or two cases and we want to grow it.<br>
         So we have to determine how big a full one is before hand.&quot;<br>
+       | codeSize mapSize |<br>
-       | headerSize codeSize mapSize |<br>
        &quot;stack allocate the various collections so that they<br>
         are effectively garbage collected on return.&quot;<br>
        self allocateOpcodes: 100 bytecodes: 0.<br>
+       methodLabel<br>
+               address: methodZoneBase;<br>
+               dependent: nil.<br>
+       &quot;Need a real selector here so that the map accomodates the annotations for the selector.<br>
+        Use self numRegArgs to generate the longest possible code sequence due to<br>
+        genPushRegisterArgsForNumArgs:&quot;<br>
-       &quot;Ned a real selector here so that the map accomodates the annotations for the selector.&quot;<br>
        self compileOpenPIC: (coInterpreter specialSelector: 0) numArgs: self numRegArgs.<br>
        self computeMaximumSizes.<br>
-       headerSize := self sizeof: CogMethod.<br>
        methodLabel concretizeAt: methodZoneBase.<br>
+       codeSize := self generateInstructionsAt: methodZoneBase + (self sizeof: CogMethod).<br>
-       codeSize := self generateInstructionsAt: methodZoneBase + headerSize.<br>
        mapSize := self generateMapAt: nil start: methodZoneBase + cmNoCheckEntryOffset.<br>
+       openPICSize := (methodZone roundUpLength: (self sizeof: CogMethod) + codeSize) + (methodZone roundUpLength: mapSize).<br>
-       openPICSize := (methodZone roundUpLength: headerSize + codeSize) + (methodZone roundUpLength: mapSize).<br>
        &quot;self cCode: &#39;&#39;<br>
                inSmalltalk:<br>
                        [| end |<br>
                         end := self outputInstructionsAt: methodZoneBase + headerSize.<br>
+                        self disassembleFrom: methodZoneBase + (self sizeof: CogMethod) to: end - 1.<br>
-                        self disassembleFrom: methodZoneBase + headerSize to: end - 1.<br>
                         self halt]&quot;!<br>
<br>
Item was changed:<br>
  ----- Method: Cogit&gt;&gt;generateTrampolines (in category &#39;initialization&#39;) -----<br>
  generateTrampolines<br>
        &quot;Generate the run-time entries and exits at the base of the native code zone and update the base.<br>
         Read the class-side method trampolines for documentation on the various trampolines&quot;<br>
        | methodZoneStart |<br>
        methodZoneStart := methodZoneBase.<br>
+       methodLabel address: methodZoneStart.<br>
        self allocateOpcodes: 80 bytecodes: 0.<br>
        initialPC := 0.<br>
        endPC := numAbstractOpcodes - 1.<br>
        hasYoungReferent := false.<br>
        self generateSendTrampolines.<br>
        self generateMissAbortTrampolines.<br>
        objectRepresentation generateObjectRepresentationTrampolines.<br>
        self generateRunTimeTrampolines.<br>
        self cppIf: NewspeakVM ifTrue:  [self generateNewspeakRuntime].<br>
        self cppIf: SistaVM ifTrue: [self generateSistaRuntime].<br>
        self generateEnilopmarts.<br>
        self generateTracingTrampolines.<br>
<br>
        &quot;finish up&quot;<br>
        self recordGeneratedRunTime: &#39;methodZoneBase&#39; address: methodZoneBase.<br>
        processor flushICacheFrom: methodZoneStart to: methodZoneBase!<br>
<br>
Item was added:<br>
+ ----- Method: Cogit&gt;&gt;methodLabel (in category &#39;accessing&#39;) -----<br>
+ methodLabel<br>
+       &lt;cmacro: &#39;() methodLabel&#39;&gt;<br>
+       ^methodLabel!<br>
<br>
Item was changed:<br>
  ----- Method: Cogit&gt;&gt;setInterpreter: (in category &#39;initialization&#39;) -----<br>
  setInterpreter: aCoInterpreter<br>
        &quot;Initialization of the code generator in the simulator.<br>
         These objects already exist in the generated C VM<br>
         or are used only in the simulation.&quot;<br>
        &lt;doNotGenerate&gt;<br>
        coInterpreter := aCoInterpreter.<br>
        objectMemory := aCoInterpreter objectMemory.<br>
        threadManager := aCoInterpreter threadManager. &quot;N.B. may be nil&quot;<br>
        methodZone := CogMethodZone new.<br>
        objectRepresentation := objectMemory objectRepresentationClass<br>
                                                                forCogit: self methodZone: methodZone.<br>
        methodZone setInterpreter: aCoInterpreter<br>
                                objectRepresentation: objectRepresentation<br>
                                cogit: self.<br>
        generatorTable := self class generatorTable.<br>
        primitiveGeneratorTable := self class primitiveTable.<br>
        processor := ProcessorClass new.<br>
        simulatedAddresses := Dictionary new.<br>
        simulatedTrampolines := Dictionary new.<br>
        simulatedVariableGetters := Dictionary new.<br>
        simulatedVariableSetters := Dictionary new.<br>
        traceStores := 0.<br>
+       traceFlags := (self class initializationOptions at: #recordPrimTrace ifAbsent: [true])<br>
+                                       ifTrue: [8] &quot;record prim trace on by default (see Cogit class&gt;&gt;decareCVarsIn:)&quot;<br>
+                                       ifFalse: [0].<br>
-       traceFlags := 8. &quot;record prim trace on by default (see Cogit class&gt;&gt;decareCVarsIn:)&quot;<br>
        debugPrimCallStackOffset := 0.<br>
        singleStep := printRegisters := printInstructions := clickConfirm := false.<br>
        breakBlock ifNil: [self breakPC: breakPC].<br>
        (backEnd := processor abstractInstructionCompilerClass new) cogit: self.<br>
        (methodLabel := processor abstractInstructionCompilerClass new) cogit: self.<br>
        ordinarySendTrampolines := CArrayAccessor on: (Array new: NumSendTrampolines).<br>
        superSendTrampolines := CArrayAccessor on: (Array new: NumSendTrampolines).<br>
        BytecodeSetHasDirectedSuperSend ifTrue:<br>
                [directedSuperSendTrampolines := CArrayAccessor on: (Array new: NumSendTrampolines)].<br>
        NewspeakVM ifTrue:<br>
                [selfSendTrampolines := CArrayAccessor on: (Array new: NumSendTrampolines).<br>
                dynamicSuperSendTrampolines := CArrayAccessor on: (Array new: NumSendTrampolines).<br>
                implicitReceiverSendTrampolines := CArrayAccessor on: (Array new: NumSendTrampolines).<br>
                outerSendTrampolines := CArrayAccessor on: (Array new: NumSendTrampolines)].<br>
        &quot;debug metadata&quot;<br>
        objectReferencesInRuntime := CArrayAccessor on: (Array new: NumObjRefsInRuntime).<br>
        runtimeObjectRefIndex := 0.<br>
        &quot;debug metadata&quot;<br>
        trampolineAddresses := CArrayAccessor on: (Array new: NumTrampolines * 2).<br>
        trampolineTableIndex := 0.<br>
<br>
        compilationTrace ifNil: [compilationTrace := self class initializationOptions at: #compilationTrace ifAbsent: [0]].<br>
        extA := extB := 0!<br>
<br>
Item was changed:<br>
  ----- Method: Cogit&gt;&gt;varBaseAddress (in category &#39;accessing&#39;) -----<br>
  varBaseAddress<br>
        &quot;We expect simulatedAddresses to have around 40 entries.  48 is hopefully a good maximum.&quot;<br>
        &lt;doNotGenerate&gt;<br>
+       ^coInterpreter varBaseAddress!<br>
-       ^self cCode: [coInterpreter varBaseAddress]<br>
-               inSmalltalk: [self fakeAddressFor: nil index: 48]!<br>
<br>
Item was changed:<br>
  ----- Method: CurrentImageCoInterpreterFacade&gt;&gt;addressForLabel: (in category &#39;labels&#39;) -----<br>
  addressForLabel: l<br>
+       ^variables at: l ifAbsentPut: [variables size * 4 + self variablesBase]!<br>
-       ^variables<br>
-               at: l<br>
-               ifAbsentPut:<br>
-                       [(self isLabelRelativeToCogitVarBaseReg: l)<br>
-                               ifTrue: [cogit fakeAddressFor: l index: variables size + 48]<br>
-                               ifFalse: [variables size * 4 + self variablesBase]]!<br>
<br>
Item was added:<br>
+ ----- Method: CurrentImageCoInterpreterFacade&gt;&gt;varBaseAddress (in category &#39;accessing&#39;) -----<br>
+ varBaseAddress<br>
+       &quot;This value is chosen for ARM, which has the ability to do 12-bit relative addresses from the var base register.&quot;<br>
+       ^(variables at: &#39;stackLimit&#39;) - (1 &lt;&lt; 11)!<br>
<br>
Item was changed:<br>
  ----- Method: SimpleStackBasedCogit&gt;&gt;genSend:numArgs:sendTable: (in category &#39;bytecode generator support&#39;) -----<br>
  genSend: selector numArgs: numArgs sendTable: sendTable<br>
        &lt;inline: false&gt;<br>
        &lt;var: #sendTable type: #&#39;sqInt *&#39;&gt;<br>
        | annotation |<br>
        (objectMemory isYoung: selector) ifTrue:<br>
                [hasYoungReferent := true].<br>
        self assert: needsFrame.<br>
        annotation := self annotationForSendTable: sendTable.<br>
        self assert: (numArgs between: 0 and: 255). &quot;say&quot;<br>
        self assert: (objectMemory addressCouldBeOop: selector).<br>
        self MoveMw: numArgs * objectMemory wordSize r: SPReg R: ReceiverResultReg.<br>
        &quot;Deal with stale super sends; see SpurMemoryManager&#39;s class comment.&quot;<br>
        (self annotationIsForUncheckedEntryPoint: annotation) ifTrue:<br>
                [objectRepresentation genEnsureOopInRegNotForwarded: ReceiverResultReg scratchReg: TempReg].<br>
+       &quot;0 through (NumSendTrampolines - 2) numArgs sends have the arg count implciti in the trampoline.<br>
+        The last send trampoline (NumSendTrampolines - 1) passes numArgs in SendNumArgsReg.&quot;<br>
+       numArgs &gt;= (NumSendTrampolines - 1) ifTrue:<br>
-       numArgs &gt; 2 ifTrue:<br>
                [self MoveCq: numArgs R: SendNumArgsReg].<br>
        (BytecodeSetHasDirectedSuperSend<br>
         and: [annotation = IsDirectedSuperSend]) ifTrue:<br>
                [self genMoveConstant: tempOop R: TempReg].<br>
        self MoveCw: selector R: ClassReg.<br>
        self annotate: (self Call: (sendTable at: (numArgs min: NumSendTrampolines - 1)))<br>
                with: annotation.<br>
        self PushR: ReceiverResultReg.<br>
        ^0!<br>
<br>
Item was added:<br>
+ ----- Method: SistaStackToRegisterMappingCogit&gt;&gt;fillInCPICHeader:numArgs:numCases:hasMNUCase:selector: (in category &#39;generate machine code&#39;) -----<br>
+ fillInCPICHeader: pic numArgs: numArgs numCases: numCases hasMNUCase: hasMNUCase selector: selector<br>
+       pic counters: 0.<br>
+       ^super fillInCPICHeader: pic numArgs: numArgs numCases: numCases hasMNUCase: hasMNUCase selector: selector!<br>
<br>
Item was removed:<br>
- ----- Method: SistaStackToRegisterMappingCogit&gt;&gt;fillInCPICHeader:size:numArgs:numCases:hasMNUCase:selector: (in category &#39;generate machine code&#39;) -----<br>
- fillInCPICHeader: pic size: size numArgs: numArgs numCases: numCases hasMNUCase: hasMNUCase selector: selector<br>
-       pic counters: 0.<br>
-       ^super fillInCPICHeader: pic size: size numArgs: numArgs numCases: numCases hasMNUCase: hasMNUCase selector: selector!<br>
<br>
Item was added:<br>
+ ----- Method: SistaStackToRegisterMappingCogit&gt;&gt;fillInOPICHeader:numArgs:selector: (in category &#39;generate machine code&#39;) -----<br>
+ fillInOPICHeader: pic numArgs: numArgs selector: selector<br>
+       pic counters: 0.<br>
+       ^super fillInOPICHeader: pic numArgs: numArgs selector: selector!<br>
<br>
Item was removed:<br>
- ----- Method: SistaStackToRegisterMappingCogit&gt;&gt;fillInOPICHeader:size:numArgs:selector: (in category &#39;generate machine code&#39;) -----<br>
- fillInOPICHeader: pic size: size numArgs: numArgs selector: selector<br>
-       pic counters: 0.<br>
-       ^super fillInOPICHeader: pic size: size numArgs: numArgs selector: selector!<br>
<br>
Item was changed:<br>
  ----- Method: SpurMemoryManager&gt;&gt;checkTraversableSortedFreeList (in category &#39;simulation only&#39;) -----<br>
  checkTraversableSortedFreeList<br>
+       | prevFree prevPrevFree freeChunk |<br>
-       | prevFree freeChunk |<br>
        &lt;api&gt;<br>
        &lt;inline: false&gt;<br>
+       prevFree := prevPrevFree := 0.<br>
-       prevFree := 0.<br>
        freeChunk := firstFreeChunk.<br>
        self allOldSpaceEntitiesDo:<br>
                [:o| | objOop next limit |<br>
                (self isFreeObject: o) ifTrue:<br>
                        [self assert: o = freeChunk.<br>
                         next := self nextInSortedFreeListLink: freeChunk given: prevFree.<br>
                         limit := next = 0 ifTrue: [endOfMemory] ifFalse: [next].<br>
                         &quot;coInterpreter transcript cr; print: freeChunk; tab; print: o; tab; print: prevFree; nextPutAll: &#39;&lt;-&gt;&#39;; print: next; flush.&quot;<br>
                         objOop := freeChunk.<br>
                         [self oop: (objOop := self objectAfter: objOop) isLessThan: limit] whileTrue:<br>
                                [self assert: (self isFreeObject: objOop) not].<br>
+                        prevPrevFree := prevFree.<br>
                         prevFree := freeChunk.<br>
                         freeChunk := next]].<br>
        self assert: prevFree = lastFreeChunk.<br>
+       self assert: (self nextInSortedFreeListLink: lastFreeChunk given: 0) = prevPrevFree.<br>
        self assert: freeChunk = 0.<br>
        ^true!<br>
<br>
Item was changed:<br>
  ----- Method: StackToRegisterMappingCogit&gt;&gt;genMarshalledSend:numArgs:sendTable: (in category &#39;bytecode generator support&#39;) -----<br>
  genMarshalledSend: selector numArgs: numArgs sendTable: sendTable<br>
        &lt;inline: false&gt;<br>
        &lt;var: #sendTable type: #&#39;sqInt *&#39;&gt;<br>
        | annotation |<br>
        (objectMemory isYoung: selector) ifTrue:<br>
                [hasYoungReferent := true].<br>
        self assert: needsFrame.<br>
        annotation := self annotationForSendTable: sendTable.<br>
        &quot;Deal with stale super sends; see SpurMemoryManager&#39;s class comment.&quot;<br>
        (self annotationIsForUncheckedEntryPoint: annotation) ifTrue:<br>
                [objectRepresentation genEnsureOopInRegNotForwarded: ReceiverResultReg scratchReg: TempReg].<br>
+       &quot;0 through (NumSendTrampolines - 2) numArgs sends have the arg count implciti in the trampoline.<br>
+        The last send trampoline (NumSendTrampolines - 1) passes numArgs in SendNumArgsReg.&quot;<br>
+       numArgs &gt;= (NumSendTrampolines - 1) ifTrue:<br>
-       numArgs &gt; 2 ifTrue:<br>
                [self MoveCq: numArgs R: SendNumArgsReg].<br>
        (BytecodeSetHasDirectedSuperSend<br>
         and: [annotation = IsDirectedSuperSend]) ifTrue:<br>
                [self genMoveConstant: tempOop R: TempReg].<br>
        self MoveCw: selector R: ClassReg.<br>
        self annotate: (self Call: (sendTable at: (numArgs min: NumSendTrampolines - 1)))<br>
                with: annotation.<br>
        optStatus isReceiverResultRegLive: false.<br>
        ^self ssPushRegister: ReceiverResultReg!<br>
<br>
</blockquote></div><br></div></div>