<div dir="ltr">Oops.  Didn&#39;t mean to upload that twice.  No harm done I hope.</div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Apr 21, 2015 at 7:38 PM,  <span dir="ltr">&lt;<a href="mailto:commits@source.squeak.org" target="_blank">commits@source.squeak.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;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.1234.mcz" target="_blank">http://source.squeak.org/VMMaker/VMMaker.oscog-eem.1234.mcz</a><br>
<br>
==================== Summary ====================<br>
<br>
Name: VMMaker.oscog-eem.1234<br>
Author: eem<br>
Time: 21 April 2015, 6:52:37.482 pm<br>
UUID: 012b3371-995e-451f-85ec-a5144379427d<br>
Ancestors: VMMaker.oscog-tpr.1233<br>
<br>
Cogit:<br>
Allow ARM concretizeMoveCwR use pc-relative<br>
addressing alongside PushCwR.  Fix the effects on<br>
PIC parsing by introducing loadPICLiteralByteSize.<br>
<br>
Correct slip in sub:rn:imm:ror:.<br>
Fix sub:rn:imm:ror:.<br>
Fix relocateMethodReferenceBeforeAddress:by:<br>
for the 4 cases we have now.<br>
<br>
Code compaction now works once again on ARM<br>
but we generate more compact code and most<br>
method/pic self-references are made with non-<br>
relocateable pc-relative addressing.  Woot!<br>
<br>
=============== Diff against VMMaker.oscog-tpr.1233 ===============<br>
<br>
Item was changed:<br>
  ----- Method: CogARMCompiler&gt;&gt;concretizeMoveCwR (in category &#39;generate machine code - concretize&#39;) -----<br>
  concretizeMoveCwR<br>
        &quot;Will get inlined into concretizeAt: switch.&quot;<br>
        &lt;inline: true&gt;<br>
+       ^machineCodeSize := self loadCwInto: (self concreteRegister: (operands at: 1))!<br>
-       | constant destReg |<br>
-       constant := operands at: 0.<br>
-       destReg := self concreteRegister: (operands at: 1).<br>
-       ^machineCodeSize :=self at: 0 moveCw: constant intoR: destReg!<br>
<br>
Item was changed:<br>
  ----- Method: CogARMCompiler&gt;&gt;concretizePushCw (in category &#39;generate machine code - concretize&#39;) -----<br>
  concretizePushCw<br>
        &quot;Will get inlined into concretizeAt: switch.&quot;<br>
        &lt;inline: true&gt;<br>
+       | instrOffset |<br>
+       instrOffset := self loadCwInto: ConcreteIPReg.<br>
-       | operand instrOffset distance |<br>
-       operand := operands at: 0.<br>
-       instrOffset := 0.<br>
-       &quot;First try and encode as a pc-relative reference...&quot;<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: ConcreteIPReg rn: PC imm: immediate ror: rot).<br>
-                               instrOffset := 4]<br>
-                       ifFalse:<br>
-                               [self rotateable8bitImmediate: distance negated<br>
-                                       ifTrue: [ :rot :immediate |<br>
-                                               self machineCodeAt: 0 put: (self sub: ConcreteIPReg rn: PC imm: immediate ror: rot).<br>
-                                               instrOffset := 4]<br>
-                               ifFalse: [instrOffset := 0]]].<br>
-       &quot;If this fails, use the conventional and painfully long 4 instruction sequence.&quot;<br>
-       instrOffset = 0 ifTrue:<br>
-               [instrOffset := self at: 0 moveCw: operand intoR: ConcreteIPReg].<br>
        self machineCodeAt: instrOffset put: (self pushR: ConcreteIPReg).<br>
        ^machineCodeSize := instrOffset + 4!<br>
<br>
Item was added:<br>
+ ----- Method: CogARMCompiler&gt;&gt;instructionIsPush: (in category &#39;testing&#39;) -----<br>
+ instructionIsPush: instr<br>
+       &quot;is this a push -str r??, [sp, #-4] -  instruction?&quot;<br>
+       ^instr &gt;&gt; 28 &lt; 16rF &quot;test for allowed condcode - 0xF is extension&quot;<br>
+         and: [(instr bitAnd: 16rFFF0FFF) = 16r52D0004]!<br>
<br>
Item was added:<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 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 added:<br>
+ ----- Method: CogARMCompiler&gt;&gt;loadPICLiteralByteSize (in category &#39;accessing&#39;) -----<br>
+ loadPICLiteralByteSize<br>
+       &quot;Answer the byte size of a MoveCwR opcode&#39;s corresponding machine code<br>
+        when the argument is a PIC.  This is for the self-reference at the end of a<br>
+        closed PIC.  On ARM this is a single instruction pc-relative register load.&quot;<br>
+       ^4!<br>
<br>
Item was removed:<br>
- ----- Method: CogARMCompiler&gt;&gt;movePCRelative:into: (in category &#39;generate machine code - support&#39;) -----<br>
- movePCRelative: operand into: reg<br>
-       &quot;Load a pc relative value into the register&quot;<br>
-       | offset sign instr |<br>
-       offset := operand - (address + 8).<br>
-       sign := offset &gt;= 0 ifTrue: [1] ifFalse: [0].<br>
-       instr := self ldr: reg rn: PC plus: sign imm: offset abs.<br>
-       self machineCodeAt: 0 put: instr.<br>
-       ^4!<br>
<br>
Item was changed:<br>
  ----- Method: CogARMCompiler&gt;&gt;relocateMethodReferenceBeforeAddress:by: (in category &#39;inline cacheing&#39;) -----<br>
  relocateMethodReferenceBeforeAddress: pc by: delta<br>
        &quot;If possible we generate the method address using pc-relative addressing.<br>
         If so we don&#39;t need to relocate it in code.  So check if pc-relative code was<br>
+        generated, and if not, adjust a long sequence.  There are two cases, a push<br>
+        or a register load.  If a push, then there is a register load, but in the instruction<br>
+        before.&quot;<br>
+       | pcPreceedingLoad reference |<br>
+       pcPreceedingLoad := (self instructionIsPush: (self instructionBeforeAddress: pc))<br>
+                                                       ifTrue: [pc - 4]<br>
+                                                       ifFalse: [pc].<br>
+       &quot;If the load is not done via pc-relative addressing we have to relocate.&quot;<br>
+       (self isPCRelativeValueLoad: (self instructionBeforeAddress: pcPreceedingLoad)) ifFalse:<br>
+               [reference := self extract32BitOperandFrom4InstructionsPreceeding: pcPreceedingLoad.<br>
+                reference := reference + delta.<br>
+                self insert32BitOperand: reference into4InstructionsPreceeding: pcPreceedingLoad]!<br>
-        generated, and if not, adjust a long sequence.&quot;<br>
-       | location |<br>
-       (self isPCRelativeValueLoad: (self instructionBeforeAddress: pc - 4)) ifFalse:<br>
-               [location := self extract32BitOperandFrom4InstructionsPreceeding: pc - 4.<br>
-                location := location + delta.<br>
-                self insert32BitOperand: location into4InstructionsPreceeding: pc - 4]!<br>
<br>
Item was changed:<br>
  ----- Method: CogARMCompiler&gt;&gt;sub:rn:imm:ror: (in category &#39;ARM convenience instructions&#39;) -----<br>
  sub: destReg rn: srcReg imm: immediate ror: rot<br>
  &quot;     Remember the ROR is doubled by the cpu so use 30&gt;&gt;1 etc<br>
        SUB destReg, srcReg, #immediate ROR rot&quot;<br>
<br>
+       ^self type: 1 op: SubOpcode set: 0 rn: srcReg rd: destReg shifterOperand: ((rot&gt;&gt;1) &lt;&lt;8 bitOr: immediate)!<br>
-       ^self type: 1 op: 2 set: 0 rn: srcReg rd: destReg shifterOperand: ((rot&gt;&gt;1) &lt;&lt;8 bitOr: immediate)!<br>
<br>
Item was changed:<br>
  ----- Method: CogAbstractInstruction&gt;&gt;isPCRelativeValueLoad: (in category &#39;testing&#39;) -----<br>
  isPCRelativeValueLoad: instr<br>
+       &lt;var: &#39;instr&#39; type: #&#39;unsigned int&#39;&gt;<br>
+       &quot;add xx, pc, blah or sub xx, pc, blah&quot;<br>
+       ^(instr &gt;&gt; 16) = 16rE28F or: [instr &gt;&gt; 16 = 16rE24F]!<br>
-       &quot;add ip, pc, blah-&gt;  &#39;16rE28FC000&#39;<br>
-        sub ip, pc, blah -&gt; &#39;16rE24FC000&#39;&quot;<br>
-       ^(instr bitAnd: 16rFFFFF000) = 16rE28FC000<br>
-         or: [(instr bitAnd: 16rFFFFF000) = 16rE24FC000]!<br>
<br>
Item was added:<br>
+ ----- Method: CogAbstractInstruction&gt;&gt;loadPICLiteralByteSize (in category &#39;accessing&#39;) -----<br>
+ loadPICLiteralByteSize<br>
+       &quot;Answer the byte size of a MoveCwR opcode&#39;s corresponding machine code<br>
+        when the argument is a PIC.  This is for the self-reference at the end of a<br>
+        closed PIC.&quot;<br>
+       self subclassResponsibility!<br>
<br>
Item was added:<br>
+ ----- Method: CogIA32Compiler&gt;&gt;loadPICLiteralByteSize (in category &#39;accessing&#39;) -----<br>
+ loadPICLiteralByteSize<br>
+       &quot;Answer the byte size of a MoveCwR opcode&#39;s corresponding machine code<br>
+        when the argument is a PIC.  This is for the self-reference at the end of a<br>
+        closed PIC.&quot;<br>
+       &lt;inline: true&gt;<br>
+       ^self loadLiteralByteSize!<br>
<br>
Item was changed:<br>
  ----- Method: Cogit&gt;&gt;addressIsInCodeZone: (in category &#39;testing&#39;) -----<br>
  addressIsInCodeZone: address<br>
        &quot;N.B. We /don&#39;t/ write this as address between: codeBase and: methodZone limitZony in case we&#39;re<br>
         testing an address in a method whose code has yet to be allocated and is hence &gt;= methodZone limitZony&quot;<br>
        ^address asUnsignedInteger &gt;= codeBase<br>
+         and: [address &lt; (methodZone youngReferrers ifNil: [0])]!<br>
-         and: [address &lt; methodZone youngReferrers]!<br>
<br>
Item was changed:<br>
  ----- Method: Cogit&gt;&gt;compileClosedPICPrototype (in category &#39;in-line cacheing&#39;) -----<br>
  compileClosedPICPrototype<br>
        &quot;Compile the abstract instructions for a full closed PIC used to initialize closedPICSize.<br>
         The loads into SendNumArgsReg are those for optional method objects which may be<br>
         used in MNU cases.&quot;<br>
        | numArgs jumpNext |<br>
        &lt;var: #jumpNext type: #&#39;AbstractInstruction *&#39;&gt;<br>
        numArgs := 0.<br>
        self compilePICAbort: numArgs.<br>
        jumpNext := self compileCPICEntry.<br>
        self MoveCw: 16r5EAF00D R: SendNumArgsReg.<br>
        self JumpLong: methodZoneBase + 16rCA5E10.<br>
        jumpNext jmpTarget: (endCPICCase0 := self Label).<br>
        1 to: numPICCases - 1 do:<br>
                [:h|<br>
                self CmpCw: 16rBABE1F15+h R: TempReg.<br>
                self MoveCw: 16rBADA550 + h R: SendNumArgsReg.<br>
                self JumpLongZero: 16rCA5E10 + (h * 16).<br>
                h = 1 ifTrue:<br>
                        [endCPICCase1 := self Label]].<br>
+       self MoveCw: methodZoneBase R: ClassReg.<br>
-       self MoveCw: 16rAB5CE55 R: ClassReg.<br>
        self JumpLong: (self cPICMissTrampolineFor: numArgs).<br>
        ^0!<br>
<br>
Item was changed:<br>
  ----- Method: Cogit&gt;&gt;relocateCallsInClosedPIC: (in category &#39;compaction&#39;) -----<br>
  relocateCallsInClosedPIC: cPIC<br>
        &lt;var: #cPIC type: #&#39;CogMethod *&#39;&gt;<br>
        | delta pc entryPoint targetMethod |<br>
        &lt;var: #targetMethod type: #&#39;CogMethod *&#39;&gt;<br>
        delta := cPIC objectHeader.<br>
        self assert: (backEnd callTargetFromReturnAddress: cPIC asInteger + missOffset)<br>
                                        = (self picAbortTrampolineFor: cPIC cmNumArgs).<br>
        backEnd relocateCallBeforeReturnPC: cPIC asInteger + missOffset by: delta negated.<br>
<br>
        pc := cPIC asInteger + firstCPICCaseOffset.<br>
        1 to: cPIC cPICNumCases do:<br>
                [:i|<br>
                entryPoint := backEnd jumpLongTargetBeforeFollowingAddress: pc.<br>
                &quot;Find target from jump.  Ignore jumps to the interpret and MNU calls within this PIC&quot;<br>
                (entryPoint &lt; cPIC asInteger<br>
                 or: [entryPoint &gt; (cPIC asInteger + cPIC blockSize)]) ifTrue:<br>
                        [targetMethod := self cCoerceSimple: entryPoint - cmNoCheckEntryOffset to: #&#39;CogMethod *&#39;.<br>
                         self assert: targetMethod cmType = CMMethod.<br>
                         backEnd<br>
                                relocateJumpLongBeforeFollowingAddress: pc<br>
                                by: (delta - targetMethod objectHeader) negated].<br>
                pc := pc + cPICCaseSize].<br>
        self assert: cPIC cPICNumCases &gt; 0.<br>
        pc := pc - cPICCaseSize.<br>
        &quot;Finally relocate the load of the PIC and the jump to the overflow routine ceCPICMiss:receiver:&quot;<br>
+       backEnd relocateMethodReferenceBeforeAddress: pc + backEnd loadPICLiteralByteSize by: delta.<br>
-       backEnd relocateMethodReferenceBeforeAddress: pc + backEnd loadLiteralByteSize by: delta.<br>
        backEnd relocateJumpLongBeforeFollowingAddress: pc + cPICEndSize by: delta negated!<br>
<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">best,<div>Eliot</div></div>
</div>