<div dir="ltr">Hi Nicolas,<div class="gmail_extra"><br><div class="gmail_quote">On Thu, Mar 17, 2016 at 3:24 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:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><br>
Nicolas Cellier uploaded a new version of VMMaker to project VM Maker:<br>
<a href="http://source.squeak.org/VMMaker/VMMaker.oscog-nice.1732.mcz" rel="noreferrer" target="_blank">http://source.squeak.org/VMMaker/VMMaker.oscog-nice.1732.mcz</a><br>
<br>
==================== Summary ====================<br>
<br>
Name: VMMaker.oscog-nice.1732<br>
Author: nice<br>
Time: 17 March 2016, 11:22:07.715 pm<br>
UUID: ea9dd158-4847-464e-9642-9786252797dc<br>
Ancestors: VMMaker.oscog-nice.1731<br>
<br>
Use little endian accelerators too for fetching 32 &amp; 64 bits large integers value (like the ones used for storing value).<br>
<br>
Dramatically simplify fetching of signedInteger values by using an intermediate unsigned magnitude.<br>
<br>
Declare the positive32/64BitIntegerFor: and maybeInlinePositive32BitIntegerFor: parameter as unsigned since it is interpreted as positive.<br>
<br>
Use asUnsignedInteger in isIntegerValue: tests, integerObjectOf: and rotatedFloatBitsOf: in order to ban potential UB.<br>
<br>
Simplify bit operations using positiveMachineIntegerValueOf:/positiveMachineIntegerFor: rather than doing 32/64 bits dissertation.<br>
<br>
Fetch magnitude of positive large ints into an unsigned for large int bit ops.<br></blockquote><div><br></div><div><br></div><div>In the following</div><div><br></div> ----- Method: StackInterpreter&gt;&gt;maybeInlinePositive32BitIntegerFor: (in category &#39;primitive support&#39;) -----<br>  maybeInlinePositive32BitIntegerFor: integerValue<br>        &quot;N.B. will *not* cause a GC.<br>         integerValue is interpreted as POSITIVE, e.g. as the result of Bitmap&gt;at:.&quot;<br>        &lt;notOption: #Spur64BitMemoryManager&gt;<br>+       &lt;var: &#39;integerValue&#39; type: #&#39;unsigned int&#39;&gt;<br>        | newLargeInteger |<br>        self deny: objectMemory hasSixtyFourBitImmediates.<br>+       integerValue &lt;= objectMemory maxSmallInteger<br>+               ifTrue: [^ objectMemory integerObjectOf: integerValue].<br>-       (integerValue asInteger &gt;= 0<br>-        and: [objectMemory isIntegerValue: integerValue]) ifTrue:<br>-               [^objectMemory integerObjectOf: integerValue].<br><div><br></div><div>shouldn&#39;t we compare against minSmallInteger as well, because e.g. -16r80000000 could overflow SmallInteger and answer 0?</div><div><br></div><div><br></div><div><br></div><div>P.S.  Lovely seeing this code getting some good loving.</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br>
=============== Diff against VMMaker.oscog-nice.1731 ===============<br>
<br>
Item was changed:<br>
  ----- Method: InterpreterPrimitives&gt;&gt;magnitude64BitIntegerFor:neg: (in category &#39;primitive support&#39;) -----<br>
  magnitude64BitIntegerFor: magnitude neg: isNegative<br>
        &quot;Return a Large Integer object for the given integer magnitude and sign&quot;<br>
        | newLargeInteger largeClass highWord sz isSmall smallVal |<br>
        &lt;var: &#39;magnitude&#39; type: #usqLong&gt;<br>
        &lt;var: &#39;highWord&#39; type: #usqInt&gt;<br>
<br>
        isSmall := isNegative<br>
                                ifTrue: [magnitude &lt;= (objectMemory maxSmallInteger + 1)]<br>
                                ifFalse: [magnitude &lt;= objectMemory maxSmallInteger].<br>
        isSmall ifTrue:<br>
                [smallVal := self cCoerceSimple: magnitude to: #sqInt.<br>
                 isNegative ifTrue: [smallVal := 0 - smallVal].<br>
                 ^objectMemory integerObjectOf: smallVal].<br>
<br>
        largeClass := isNegative<br>
                                        ifTrue: [objectMemory classLargeNegativeInteger]<br>
                                        ifFalse: [objectMemory classLargePositiveInteger].<br>
        objectMemory wordSize = 8<br>
                ifTrue: [sz := 8]<br>
                ifFalse:<br>
                        [(highWord := magnitude &gt;&gt; 32) = 0<br>
                                ifTrue: [sz := 4]<br>
                                ifFalse:<br>
                                        [sz := 5.<br>
                                         (highWord := highWord &gt;&gt; 8) = 0 ifFalse:<br>
                                                [sz := sz + 1.<br>
                                                 (highWord := highWord &gt;&gt; 8) = 0 ifFalse:<br>
                                                        [sz := sz + 1.<br>
                                                         (highWord := highWord &gt;&gt; 8) = 0 ifFalse: [sz := sz + 1]]]]].<br>
        newLargeInteger := objectMemory instantiateClass: largeClass indexableSize:  sz.<br>
        self cppIf: VMBIGENDIAN<br>
                ifTrue:<br>
                        [sz &gt; 4 ifTrue:<br>
                                [objectMemory<br>
                                        storeByte: 7 ofObject: newLargeInteger withValue: (magnitude &gt;&gt; 56 bitAnd: 16rFF);<br>
                                        storeByte: 6 ofObject: newLargeInteger withValue: (magnitude &gt;&gt; 48 bitAnd: 16rFF);<br>
                                        storeByte: 5 ofObject: newLargeInteger withValue: (magnitude &gt;&gt; 40 bitAnd: 16rFF);<br>
                                        storeByte: 4 ofObject: newLargeInteger withValue: (magnitude &gt;&gt; 32 bitAnd: 16rFF)].<br>
                        objectMemory<br>
                                storeByte: 3 ofObject: newLargeInteger withValue: (magnitude &gt;&gt; 24 bitAnd: 16rFF);<br>
                                storeByte: 2 ofObject: newLargeInteger withValue: (magnitude &gt;&gt; 16 bitAnd: 16rFF);<br>
                                storeByte: 1 ofObject: newLargeInteger withValue: (magnitude &gt;&gt;   8 bitAnd: 16rFF);<br>
                                storeByte: 0 ofObject: newLargeInteger withValue: (magnitude &quot;&gt;&gt; 0&quot; bitAnd: 16rFF)]<br>
                ifFalse:<br>
+                       [sz &gt; 4<br>
+                               ifTrue: [objectMemory storeLong64: 0 ofObject: newLargeInteger withValue: magnitude]<br>
+                               ifFalse: [objectMemory storeLong32: 0 ofObject: newLargeInteger withValue: (self cCode: [magnitude] inSmalltalk: [magnitude bitAnd: 16rFFFFFFFF])]].<br>
-                       [sz &gt; 4 ifTrue:<br>
-                               [objectMemory storeLong32: 1 ofObject: newLargeInteger withValue: magnitude &gt;&gt; 32].<br>
-                       objectMemory<br>
-                               storeLong32: 0<br>
-                               ofObject: newLargeInteger<br>
-                               withValue: (self cCode: [magnitude] inSmalltalk: [magnitude bitAnd: 16rFFFFFFFF])].<br>
<br>
        ^newLargeInteger!<br>
<br>
Item was changed:<br>
  ----- Method: InterpreterPrimitives&gt;&gt;magnitude64BitValueOf: (in category &#39;primitive support&#39;) -----<br>
  magnitude64BitValueOf: oop<br>
        &quot;Convert the given object into an integer value.<br>
        The object may be either a positive SmallInteger or an eight-byte LargeInteger.&quot;<br>
        | sz value ok smallIntValue |<br>
        &lt;returnTypeC: #usqLong&gt;<br>
        &lt;var: #value type: #usqLong&gt;<br>
<br>
        (objectMemory isIntegerObject: oop) ifTrue:<br>
                [smallIntValue := (objectMemory integerValueOf: oop).<br>
                smallIntValue &lt; 0 ifTrue: [smallIntValue := 0 - smallIntValue].<br>
                ^self cCoerce: smallIntValue to: #usqLong].<br>
<br>
        (objectMemory isNonIntegerImmediate: oop) ifTrue:<br>
                [self primitiveFail.<br>
                 ^0].<br>
<br>
        ok := objectMemory isClassOfNonImm: oop<br>
                                        equalTo: (objectMemory splObj: ClassLargePositiveInteger)<br>
                                        compactClassIndex: ClassLargePositiveIntegerCompactIndex.<br>
        ok<br>
                ifFalse:<br>
                        [ok := objectMemory isClassOfNonImm: oop<br>
                                                        equalTo: (objectMemory splObj: ClassLargeNegativeInteger)<br>
                                                        compactClassIndex: ClassLargeNegativeIntegerCompactIndex.<br>
                        ok ifFalse:<br>
                                [self primitiveFail.<br>
                                 ^0]].<br>
        sz := objectMemory numBytesOfBytes: oop.<br>
        sz &gt; (self sizeof: #sqLong) ifTrue:<br>
                [self primitiveFail.<br>
                 ^0].<br>
<br>
+       self cppIf: VMBIGENDIAN<br>
+               ifTrue:<br>
+                       [value := objectMemory fetchByte: sz - 1 ofObject: oop.<br>
+                       sz - 2 to: 0 by: -1 do:<br>
+                               [:i | value := value &lt;&lt; 8 + (objectMemory fetchByte: i ofObject: oop)]]<br>
+               ifFalse:<br>
+                       [sz &gt; 4<br>
+                               ifTrue: [value := self cCoerceSimple: (objectMemory fetchLong64: 0 ofObject: oop) to: #usqLong]<br>
+                               ifFalse: [value := self cCoerceSimple: (objectMemory fetchLong32: 0 ofObject: oop) to: #&#39;unsigned int&#39;].].<br>
-       value := objectMemory fetchByte: sz - 1 ofObject: oop.<br>
-       sz - 2 to: 0 by: -1 do:<br>
-               [:i | value := value &lt;&lt; 8 + (objectMemory fetchByte: i ofObject: oop)].<br>
        ^value!<br>
<br>
Item was changed:<br>
  ----- Method: InterpreterPrimitives&gt;&gt;positive64BitValueOf: (in category &#39;primitive support&#39;) -----<br>
  positive64BitValueOf: oop<br>
        &quot;Convert the given object into an integer value.<br>
        The object may be either a positive SmallInteger or an eight-byte LargePositiveInteger.&quot;<br>
<br>
        &lt;returnTypeC: #usqLong&gt;<br>
        | sz value ok |<br>
        &lt;var: #value type: #usqLong&gt;<br>
        (objectMemory isIntegerObject: oop) ifTrue:<br>
                [(objectMemory integerValueOf: oop) &lt; 0 ifTrue:<br>
                        [^self primitiveFail].<br>
                 ^objectMemory integerValueOf: oop].<br>
<br>
        (objectMemory isNonIntegerImmediate: oop) ifTrue:<br>
                [self primitiveFail.<br>
                 ^0].<br>
<br>
        ok := objectMemory<br>
                        isClassOfNonImm: oop<br>
                        equalTo: (objectMemory splObj: ClassLargePositiveInteger)<br>
                        compactClassIndex: ClassLargePositiveIntegerCompactIndex.<br>
        ok ifFalse:<br>
                [self primitiveFail.<br>
                 ^0].<br>
        sz := objectMemory numBytesOfBytes: oop.<br>
        sz &gt; (self sizeof: #sqLong) ifTrue:<br>
                [self primitiveFail.<br>
                 ^0].<br>
<br>
+       self cppIf: VMBIGENDIAN<br>
+               ifTrue:<br>
+                       [value := 0.<br>
+                       0 to: sz - 1 do: [:i |<br>
+                               value := value + ((self cCoerce: (objectMemory fetchByte: i ofObject: oop) to: #usqLong) &lt;&lt;  (i*8))]]<br>
+               ifFalse:<br>
+                       [sz &gt; 4<br>
+                               ifTrue: [value := self cCoerceSimple: (objectMemory fetchLong64: 0 ofObject: oop) to: #usqLong]<br>
+                               ifFalse: [value := self cCoerceSimple: (objectMemory fetchLong32: 0 ofObject: oop) to: #&#39;unsigned int&#39;].].<br>
-       value := 0.<br>
-       0 to: sz - 1 do: [:i |<br>
-               value := value + ((self cCoerce: (objectMemory fetchByte: i ofObject: oop) to: #usqLong) &lt;&lt;  (i*8))].<br>
        ^value!<br>
<br>
Item was changed:<br>
  ----- Method: InterpreterPrimitives&gt;&gt;primitiveBitAnd (in category &#39;arithmetic integer primitives&#39;) -----<br>
  primitiveBitAnd<br>
        &lt;inline: false&gt;<br>
+       &lt;var: &#39;integerArgument&#39; type: #usqInt&gt;<br>
+       &lt;var: &#39;intergerReceiver&#39; type: #usqInt&gt;<br>
        | integerReceiver integerArgument |<br>
        integerArgument := self stackTop.<br>
        integerReceiver := self stackValue: 1.<br>
        &quot;Comment out the short-cut.  Either the inline interpreter bytecode or the JIT primitive will handle this case.<br>
         ((objectMemory isIntegerObject: integerArgument)<br>
         and: [objectMemory isIntegerObject: integerReceiver])<br>
                ifTrue: [self pop: 2 thenPush: (integerArgument bitAnd: integerReceiver)]<br>
                ifFalse:<br>
+                       [&quot;<br>
+                       integerArgument := self positiveMachineIntegerValueOf: integerArgument.<br>
+                       integerReceiver := self positiveMachineIntegerValueOf: integerReceiver.<br>
+                       self successful ifTrue:<br>
+                                       [self pop: 2 thenPush: (self positiveMachineIntegerFor: (integerArgument bitAnd: integerReceiver))]<br>
-                       [&quot;objectMemory wordSize = 8<br>
-                               ifTrue:<br>
-                                       [integerArgument := self positive64BitValueOf: integerArgument.<br>
-                                        integerReceiver := self positive64BitValueOf: integerReceiver.<br>
-                                        self successful ifTrue:<br>
-                                               [self pop: 2 thenPush: (self positive64BitIntegerFor: (integerArgument bitAnd: integerReceiver))]]<br>
                                ifFalse:<br>
+                                       []&quot;]&quot;!<br>
-                                       [integerArgument := self positive32BitValueOf: integerArgument.<br>
-                                        integerReceiver := self positive32BitValueOf: integerReceiver.<br>
-                                        self successful ifTrue:<br>
-                                               [self pop: 2 thenPush: (self positive32BitIntegerFor: (integerArgument bitAnd: integerReceiver))]]&quot;]&quot;!<br>
<br>
Item was changed:<br>
  ----- Method: InterpreterPrimitives&gt;&gt;primitiveBitAndLargeIntegers (in category &#39;arithmetic largeint primitives&#39;) -----<br>
  primitiveBitAndLargeIntegers<br>
        &quot;Primitive logical operations for large integers in 64 bit range&quot;<br>
        | integerRcvr integerArg oopResult |<br>
        &lt;export: true&gt;<br>
+       &lt;var: &#39;integerRcvr&#39; type: &#39;usqLong&#39;&gt;<br>
+       &lt;var: &#39;integerArg&#39; type: &#39;usqLong&#39;&gt;<br>
-       &lt;var: &#39;integerRcvr&#39; type: &#39;sqLong&#39;&gt;<br>
-       &lt;var: &#39;integerArg&#39; type: &#39;sqLong&#39;&gt;<br>
<br>
        integerArg := self positive64BitValueOf: (self stackValue: 0).<br>
        integerRcvr := self positive64BitValueOf: (self stackValue: 1).<br>
        self successful ifFalse:[^nil].<br>
<br>
        oopResult := self positive64BitIntegerFor: (integerRcvr bitAnd: integerArg).<br>
        self successful ifTrue:[self pop: 2 thenPush: oopResult]!<br>
<br>
Item was changed:<br>
  ----- Method: InterpreterPrimitives&gt;&gt;primitiveBitOr (in category &#39;arithmetic integer primitives&#39;) -----<br>
  primitiveBitOr<br>
        &lt;inline: false&gt;<br>
+       &lt;var: &#39;integerArgument&#39; type: #usqInt&gt;<br>
+       &lt;var: &#39;intergerReceiver&#39; type: #usqInt&gt;<br>
        | integerReceiver integerArgument |<br>
        integerArgument := self stackTop.<br>
        integerReceiver := self stackValue: 1.<br>
        &quot;Comment out the short-cut.  Either the inline interpreter bytecode or the JIT primitive will handle this case.<br>
         ((objectMemory isIntegerObject: integerArgument)<br>
         and: [objectMemory isIntegerObject: integerReceiver])<br>
                ifTrue: [self pop: 2 thenPush: (integerArgument bitOr: integerReceiver)]<br>
                ifFalse:<br>
+                       [&quot;<br>
+                       integerArgument := self positiveMachineIntegerValueOf: integerArgument.<br>
+                       integerReceiver := self positiveMachineIntegerValueOf: integerReceiver.<br>
+                       self successful ifTrue:<br>
+                                       [self pop: 2 thenPush: (self positiveMachineIntegerFor: (integerArgument bitOr: integerReceiver))]<br>
-                       [&quot;objectMemory wordSize = 8<br>
-                               ifTrue:<br>
-                                       [integerArgument := self positive64BitValueOf: integerArgument.<br>
-                                        integerReceiver := self positive64BitValueOf: integerReceiver.<br>
-                                        self successful ifTrue:<br>
-                                               [self pop: 2 thenPush: (self positive64BitIntegerFor: (integerArgument bitOr: integerReceiver))]]<br>
                                ifFalse:<br>
+                                       []&quot;]&quot;!<br>
-                                       [integerArgument := self positive32BitValueOf: integerArgument.<br>
-                                        integerReceiver := self positive32BitValueOf: integerReceiver.<br>
-                                        self successful ifTrue:<br>
-                                               [self pop: 2 thenPush: (self positive32BitIntegerFor: (integerArgument bitOr: integerReceiver))]]&quot;]&quot;!<br>
<br>
Item was changed:<br>
  ----- Method: InterpreterPrimitives&gt;&gt;primitiveBitOrLargeIntegers (in category &#39;arithmetic largeint primitives&#39;) -----<br>
  primitiveBitOrLargeIntegers<br>
        &quot;Primitive logical operations for large integers in 64 bit range&quot;<br>
        | integerRcvr integerArg oopResult |<br>
        &lt;export: true&gt;<br>
+       &lt;var: &#39;integerRcvr&#39; type: &#39;usqLong&#39;&gt;<br>
+       &lt;var: &#39;integerArg&#39; type: &#39;usqLong&#39;&gt;<br>
-       &lt;var: &#39;integerRcvr&#39; type: &#39;sqLong&#39;&gt;<br>
-       &lt;var: &#39;integerArg&#39; type: &#39;sqLong&#39;&gt;<br>
<br>
        integerArg := self positive64BitValueOf: (self stackValue: 0).<br>
        integerRcvr := self positive64BitValueOf: (self stackValue: 1).<br>
        self successful ifFalse:[^nil].<br>
<br>
        oopResult := self positive64BitIntegerFor: (integerRcvr bitOr: integerArg).<br>
        self successful ifTrue:[self pop: 2 thenPush: oopResult]!<br>
<br>
Item was changed:<br>
  ----- Method: InterpreterPrimitives&gt;&gt;primitiveBitXor (in category &#39;arithmetic integer primitives&#39;) -----<br>
  primitiveBitXor<br>
        &lt;inline: false&gt;<br>
        | integerReceiver integerArgument |<br>
        integerArgument := self stackTop.<br>
        integerReceiver := self stackValue: 1.<br>
        ((objectMemory isIntegerObject: integerArgument)<br>
         and: [objectMemory isIntegerObject: integerReceiver])<br>
                ifTrue: &quot;xoring will leave the tag bits zero, whether the tag is 1 or zero, so add it back in.&quot;<br>
                        [self pop: 2 thenPush: (integerArgument bitXor: integerReceiver) + objectMemory smallIntegerTag]<br>
                ifFalse:<br>
+                       [integerArgument := self positiveMachineIntegerValueOf: integerArgument.<br>
+                        integerReceiver := self positiveMachineIntegerValueOf: integerReceiver.<br>
+                        self successful ifTrue:<br>
+                               [self pop: 2 thenPush: (self positiveMachineIntegerFor: (integerArgument bitXor: integerReceiver))]]!<br>
-                       [objectMemory wordSize = 8<br>
-                               ifTrue:<br>
-                                       [integerArgument := self positive64BitValueOf: integerArgument.<br>
-                                        integerReceiver := self positive64BitValueOf: integerReceiver.<br>
-                                        self successful ifTrue:<br>
-                                               [self pop: 2 thenPush: (self positive64BitIntegerFor: (integerArgument bitXor: integerReceiver))]]<br>
-                               ifFalse:<br>
-                                       [integerArgument := self positive32BitValueOf: integerArgument.<br>
-                                        integerReceiver := self positive32BitValueOf: integerReceiver.<br>
-                                        self successful ifTrue:<br>
-                                               [self pop: 2 thenPush: (self positive32BitIntegerFor: (integerArgument bitXor: integerReceiver))]]]!<br>
<br>
Item was changed:<br>
  ----- Method: InterpreterPrimitives&gt;&gt;primitiveBitXorLargeIntegers (in category &#39;arithmetic largeint primitives&#39;) -----<br>
  primitiveBitXorLargeIntegers<br>
        &quot;Primitive logical operations for large integers in 64 bit range&quot;<br>
        | integerRcvr integerArg oopResult |<br>
        &lt;export: true&gt;<br>
+       &lt;var: &#39;integerRcvr&#39; type: &#39;usqLong&#39;&gt;<br>
+       &lt;var: &#39;integerArg&#39; type: &#39;usqLong&#39;&gt;<br>
-       &lt;var: &#39;integerRcvr&#39; type: &#39;sqLong&#39;&gt;<br>
-       &lt;var: &#39;integerArg&#39; type: &#39;sqLong&#39;&gt;<br>
<br>
        integerArg := self positive64BitValueOf: (self stackValue: 0).<br>
        integerRcvr := self positive64BitValueOf: (self stackValue: 1).<br>
        self successful ifFalse:[^nil].<br>
<br>
        oopResult := self positive64BitIntegerFor: (integerRcvr bitXor: integerArg).<br>
        self successful ifTrue:[self pop: 2 thenPush: oopResult]!<br>
<br>
Item was changed:<br>
  ----- Method: InterpreterPrimitives&gt;&gt;signed32BitValueOf: (in category &#39;primitive support&#39;) -----<br>
  signed32BitValueOf: oop<br>
        &quot;Convert the given object into an integer value.<br>
        The object may be either a positive SmallInteger or a four-byte LargeInteger.&quot;<br>
+       | value negative ok magnitude |<br>
-       | value negative ok |<br>
        &lt;inline: false&gt;<br>
        &lt;returnTypeC: #int&gt;<br>
        &lt;var: #value type: #int&gt;<br>
+       &lt;var: #magnitude type: #&#39;unsigned int&#39;&gt;<br>
        &lt;var: #value64 type: #long&gt;<br>
        (objectMemory isIntegerObject: oop) ifTrue:<br>
                [objectMemory wordSize = 4<br>
                        ifTrue:<br>
                                [^objectMemory integerValueOf: oop]<br>
                        ifFalse: &quot;Must fail for SmallIntegers with digitLength &gt; 4&quot;<br>
                                [| value64 |<br>
                                 value64 := objectMemory integerValueOf: oop.<br>
                                 (self cCode: [(self cCoerceSimple: value64 to: #int) ~= value64]<br>
                                                inSmalltalk: [value64 &gt;&gt; 31 ~= 0 and: [value64 &gt;&gt; 31 ~= -1]]) ifTrue:<br>
                                        [self primitiveFail. value64 := 0].<br>
                                 ^value64]].<br>
<br>
        (objectMemory isNonIntegerImmediate: oop) ifTrue:<br>
                [self primitiveFail.<br>
                 ^0].<br>
<br>
        ok := objectMemory<br>
                        isClassOfNonImm: oop<br>
                        equalTo: (objectMemory splObj: ClassLargePositiveInteger)<br>
                        compactClassIndex: ClassLargePositiveIntegerCompactIndex.<br>
        ok<br>
                ifTrue: [negative := false]<br>
                ifFalse:<br>
                        [negative := true.<br>
                         ok := objectMemory isClassOfNonImm: oop<br>
                                                        equalTo: (objectMemory splObj: ClassLargeNegativeInteger)<br>
                                                        compactClassIndex: ClassLargeNegativeIntegerCompactIndex.<br>
                         ok ifFalse:<br>
                                [self primitiveFail.<br>
                                 ^0]].<br>
        (objectMemory numBytesOfBytes: oop) &gt; 4 ifTrue:<br>
                [^self primitiveFail].<br>
<br>
+       magnitude := self cppIf: VMBIGENDIAN<br>
-       value := self cppIf: VMBIGENDIAN<br>
                                ifTrue:<br>
                                        [ (objectMemory fetchByte: 0 ofObject: oop) +<br>
                                         ((objectMemory fetchByte: 1 ofObject: oop) &lt;&lt;  8) +<br>
                                         ((objectMemory fetchByte: 2 ofObject: oop) &lt;&lt; 16) +<br>
                                         ((objectMemory fetchByte: 3 ofObject: oop) &lt;&lt; 24)]<br>
                                ifFalse:<br>
+                                       [(objectMemory fetchLong32: 0 ofObject: oop) asUnsignedInteger].<br>
+<br>
+       (negative<br>
+               ifTrue: [magnitude &gt; 16r80000000]<br>
+               ifFalse: [magnitude &gt;= 16r80000000])<br>
+                       ifTrue:<br>
+                               [self primitiveFail.<br>
+                               ^0].<br>
+       negative<br>
+               ifTrue: [value := 0 - magnitude]<br>
+               ifFalse: [value := magnitude].<br>
+       ^value!<br>
-                                       [objectMemory fetchLong32: 0 ofObject: oop].<br>
-       self cCode: []<br>
-               inSmalltalk:<br>
-                       [(value anyMask: 16r80000000) ifTrue:<br>
-                               [value := value - 16r100000000]].<br>
-       &quot;Filter out values out of range for the signed interpretation such as<br>
-        16rFFFFFFFF (positive w/ bit 32 set) and -16rFFFFFFFF (negative w/ bit<br>
-        32 set). Since the sign is implicit in the class we require that the high<br>
-        bit of the magnitude is not set which is a simple test here.  Note that<br>
-        we have to handle the most negative 32-bit value -2147483648 specially.&quot;<br>
-       value &lt; 0 ifTrue:<br>
-               [self assert: (self sizeof: value) == 4.<br>
-                &quot;Don&#39;t fail for -16r80000000/-2147483648<br>
-                 Alas the simple (negative and: [value - 1 &gt; 0]) isn&#39;t adequate since in C the result of signed integer<br>
-                 overflow is undefined and hence under optimization this may fail.  The shift, however, is well-defined.&quot;<br>
-                (negative and: [0 = (self cCode: [value &lt;&lt; 1]<br>
-                                                                       inSmalltalk: [value &lt;&lt; 1 bitAnd: (1 &lt;&lt; 32) - 1])]) ifTrue:<br>
-                       [^value].<br>
-                self primitiveFail.<br>
-                ^0].<br>
-       ^negative<br>
-               ifTrue: [0 - value]<br>
-               ifFalse: [value]!<br>
<br>
Item was changed:<br>
  ----- Method: InterpreterPrimitives&gt;&gt;signed64BitValueOf: (in category &#39;primitive support&#39;) -----<br>
  signed64BitValueOf: oop<br>
        &quot;Convert the given object into an integer value.<br>
         The object may be either a positive SmallInteger or a eight-byte LargeInteger.&quot;<br>
+       | sz value negative ok magnitude |<br>
-       | sz value negative ok |<br>
        &lt;inline: false&gt;<br>
        &lt;returnTypeC: #sqLong&gt;<br>
        &lt;var: #value type: #sqLong&gt;<br>
+       &lt;var: #magnitude type: #usqLong&gt;<br>
        (objectMemory isIntegerObject: oop) ifTrue:<br>
                [^self cCoerce: (objectMemory integerValueOf: oop) to: #sqLong].<br>
<br>
        (objectMemory isNonIntegerImmediate: oop) ifTrue:<br>
                [self primitiveFail.<br>
                 ^0].<br>
<br>
        ok := objectMemory isClassOfNonImm: oop<br>
                                        equalTo: (objectMemory splObj: ClassLargePositiveInteger)<br>
                                        compactClassIndex: ClassLargePositiveIntegerCompactIndex.<br>
        ok<br>
                ifTrue: [negative := false]<br>
                ifFalse:<br>
                        [negative := true.<br>
                         ok := objectMemory isClassOfNonImm: oop<br>
                                                        equalTo: (objectMemory splObj: ClassLargeNegativeInteger)<br>
                                                        compactClassIndex: ClassLargeNegativeIntegerCompactIndex.<br>
                        ok ifFalse:<br>
                                [self primitiveFail.<br>
                                 ^0]].<br>
        sz := objectMemory numBytesOfBytes: oop.<br>
        sz &gt; (self sizeof: #sqLong) ifTrue:<br>
                [self primitiveFail.<br>
                 ^0].<br>
<br>
        self cppIf: VMBIGENDIAN<br>
                ifTrue:<br>
+                       [magnitude := objectMemory fetchByte: sz - 1 ofObject: oop.<br>
-                       [value := objectMemory fetchByte: sz - 1 ofObject: oop.<br>
                         sz - 2 to: 0 by: -1 do: [:i |<br>
+                               magnitude := magnitude &lt;&lt; 8 + (objectMemory fetchByte: i ofObject: oop)]]<br>
-                               value := value &lt;&lt; 8 + (objectMemory fetchByte: i ofObject: oop)]]<br>
                ifFalse:<br>
+                       [magnitude := sz &gt; 4<br>
-                       [value := sz &gt; 4<br>
                                                ifTrue: [objectMemory fetchLong64: 0 ofObject: oop]<br>
                                                ifFalse: [(objectMemory fetchLong32: 0 ofObject: oop) asUnsignedInteger]].<br>
+<br>
+       (negative<br>
+               ifTrue: [magnitude &gt; 16r8000000000000000]<br>
+               ifFalse: [magnitude &gt;= 16r8000000000000000])<br>
+                       ifTrue: [self primitiveFail.<br>
+                               ^0].<br>
+       negative<br>
+               ifTrue: [value := 0 - magnitude]<br>
+               ifFalse: [value := magnitude].<br>
+       ^value!<br>
-       &quot;Filter out values out of range for the signed interpretation such as<br>
-       16rFFFFFFFF... (positive w/ bit 64 set) and -16rFFFFFFFF... (negative w/ bit<br>
-       64 set). Since the sign is implicit in the class we require that the high bit of<br>
-       the magnitude is not set which is a simple test here.  Note that we have to<br>
-       handle the most negative 64-bit value -9223372036854775808 specially.&quot;<br>
-       self cCode: []<br>
-               inSmalltalk:<br>
-                       [(value anyMask: 16r8000000000000000) ifTrue:<br>
-                               [value := value - 16r10000000000000000]].<br>
-       value &lt; 0 ifTrue:<br>
-               [self cCode:<br>
-                       [self assert: (self sizeof: value) == 8.<br>
-                        self assert: (self sizeof: value &lt;&lt; 1) == 8].<br>
-               &quot;Don&#39;t fail for -9223372036854775808/-16r8000000000000000.<br>
-                Alas the simple (negative and: [value - 1 &gt; 0]) isn&#39;t adequate since in C the result of signed integer<br>
-                overflow is undefined and hence under optimization this may fail.  The shift, however, is well-defined.&quot;<br>
-                (negative and: [0 = (self cCode: [value &lt;&lt; 1]<br>
-                                                                       inSmalltalk: [value &lt;&lt; 1 bitAnd: (1 &lt;&lt; 64) - 1])]) ifTrue:<br>
-                       [^value].<br>
-                self primitiveFail.<br>
-                ^0].<br>
-       ^negative<br>
-               ifTrue:[0 - value]<br>
-               ifFalse:[value]!<br>
<br>
Item was changed:<br>
  ----- Method: InterpreterPrimitives&gt;&gt;signedMachineIntegerValueOf: (in category &#39;primitive support&#39;) -----<br>
  signedMachineIntegerValueOf: oop<br>
        &quot;Answer a signed value of an integer up to the size of a machine word.<br>
        The object may be either a positive SmallInteger or a LargeInteger of size &lt;= word size.&quot;<br>
        &lt;returnTypeC: #&#39;long&#39;&gt;<br>
+       | negative ok bs value limit magnitude |<br>
-       | negative ok bs value bits |<br>
        &lt;var: #value type: #long&gt;<br>
+       &lt;var: #magnitude type: #usqInt&gt;<br>
+       &lt;var: #limit type: #usqInt&gt;<br>
        (objectMemory isIntegerObject: oop) ifTrue:<br>
                [^objectMemory integerValueOf: oop].<br>
<br>
        (objectMemory isNonIntegerImmediate: oop) ifTrue:<br>
                [^self primitiveFail].<br>
<br>
        ok := objectMemory isClassOfNonImm: oop<br>
                                        equalTo: (objectMemory splObj: ClassLargePositiveInteger)<br>
                                        compactClassIndex: ClassLargePositiveIntegerCompactIndex.<br>
        ok<br>
                ifTrue: [negative := false]<br>
                ifFalse:<br>
                        [negative := true.<br>
                         ok := objectMemory isClassOfNonImm: oop<br>
                                                        equalTo: (objectMemory splObj: ClassLargeNegativeInteger)<br>
                                                        compactClassIndex: ClassLargeNegativeIntegerCompactIndex.<br>
                        ok ifFalse: [^self primitiveFail]].<br>
        bs := objectMemory numBytesOf: oop.<br>
        bs &gt; (self sizeof: #&#39;unsigned long&#39;) ifTrue:<br>
                [^self primitiveFail].<br>
<br>
        ((self sizeof: #&#39;unsigned long&#39;) = 8<br>
        and: [bs &gt; 4]) ifTrue:<br>
+               [magnitude := self cppIf: VMBIGENDIAN<br>
-               [value := self cppIf: VMBIGENDIAN<br>
                                        ifTrue:<br>
                                                [    (objectMemory fetchByte: 0 ofObject: oop)<br>
                                                 + ((objectMemory fetchByte: 1 ofObject: oop) &lt;&lt;  8)<br>
                                                 + ((objectMemory fetchByte: 2 ofObject: oop) &lt;&lt; 16)<br>
                                                 + ((objectMemory fetchByte: 3 ofObject: oop) &lt;&lt; 24)<br>
                                                 + ((objectMemory fetchByte: 4 ofObject: oop) &lt;&lt; 32)<br>
                                                 + ((objectMemory fetchByte: 5 ofObject: oop) &lt;&lt; 40)<br>
                                                 + ((objectMemory fetchByte: 6 ofObject: oop) &lt;&lt; 48)<br>
                                                 + ((objectMemory fetchByte: 7 ofObject: oop) &lt;&lt; 56)]<br>
                                        ifFalse:<br>
                                                [objectMemory fetchLong64: 0 ofObject: oop]]<br>
                ifFalse:<br>
+                       [magnitude := self cppIf: VMBIGENDIAN<br>
-                       [value := self cppIf: VMBIGENDIAN<br>
                                                ifTrue:<br>
                                                        [    (objectMemory fetchByte: 0 ofObject: oop)<br>
                                                         + ((objectMemory fetchByte: 1 ofObject: oop) &lt;&lt;  8)<br>
                                                         + ((objectMemory fetchByte: 2 ofObject: oop) &lt;&lt; 16)<br>
                                                         + ((objectMemory fetchByte: 3 ofObject: oop) &lt;&lt; 24)]<br>
                                                ifFalse:<br>
                                                        [(objectMemory fetchLong32: 0 ofObject: oop) asUnsignedInteger]].<br>
+<br>
+       limit := 1 asUnsignedInteger &lt;&lt; ((self sizeof: #usqInt) * 8 - 1).<br>
+       (negative<br>
+               ifTrue: [magnitude &gt; limit]<br>
+               ifFalse: [magnitude &gt;= limit])<br>
+                       ifTrue: [self primitiveFail.<br>
+                               ^0].<br>
+       negative<br>
+               ifTrue: [value := 0 - magnitude]<br>
+               ifFalse: [value := magnitude].<br>
+       ^value!<br>
-<br>
-       self cCode: []<br>
-               inSmalltalk:<br>
-                       [bits := (self sizeof: #long) * 8.<br>
-                        (value bitShift: 1 - bits) &gt; 0 ifTrue:<br>
-                               [value := value - (1 bitShift: bits)]].<br>
-       value &lt; 0 ifTrue:<br>
-               [&quot;Don&#39;t fail for -16r80000000[00000000].<br>
-                 Alas the simple (negative and: [value - 1 &gt; 0]) isn&#39;t adequate since in C the result of signed integer<br>
-                 overflow is undefined and hence under optimization this may fail.  The shift, however, is well-defined.&quot;<br>
-                (negative and: [0 = (self cCode: [value &lt;&lt; 1]<br>
-                                                                       inSmalltalk: [value &lt;&lt; 1 bitAnd: (1 &lt;&lt; bits) - 1])]) ifTrue:<br>
-                       [^value].<br>
-                ^self primitiveFail].<br>
-       ^negative<br>
-               ifTrue: [0 - value]<br>
-               ifFalse: [value]!<br>
<br>
Item was changed:<br>
  ----- Method: InterpreterProxy&gt;&gt;positive32BitIntegerFor: (in category &#39;converting&#39;) -----<br>
  positive32BitIntegerFor: integerValue<br>
+       &lt;var: &#39;integerValue&#39; type: #&#39;unsigned int&#39;&gt;<br>
        integerValue isInteger ifFalse:[self error:&#39;Not an Integer object&#39;].<br>
        ^integerValue &gt; 0<br>
                ifTrue:[integerValue]<br>
                ifFalse:[ (1 bitShift: 32) + integerValue]!<br>
<br>
Item was changed:<br>
  ----- Method: InterpreterProxy&gt;&gt;positive64BitIntegerFor: (in category &#39;converting&#39;) -----<br>
  positive64BitIntegerFor: integerValue<br>
        &lt;api&gt;<br>
        &lt;returnTypeC: #sqInt&gt; &quot;...because answering the 64-bit argument causes the type inferencer to say this answers 64-bits.&quot;<br>
+       &lt;var: &#39;integerValue&#39; type: #usqLong&gt;<br>
-       &lt;var: &#39;integerValue&#39; type: #sqLong&gt;<br>
        integerValue isInteger ifFalse:[self error:&#39;Not an Integer object&#39;].<br>
        ^integerValue &gt; 0<br>
                ifTrue:[integerValue]<br>
                ifFalse:[ (1 bitShift: 64) + integerValue]!<br>
<br>
Item was changed:<br>
  ----- Method: ObjectMemory&gt;&gt;isIntegerValue: (in category &#39;interpreter access&#39;) -----<br>
  isIntegerValue: intValue<br>
        &quot;Answer if the given value can be represented as a Smalltalk integer value.<br>
         In C, use a shift and XOR to set the sign bit if and only if the top two bits of the given<br>
         value are the same, then test the sign bit. Note that the top two bits are equal for<br>
         exactly those integers in the range that can be represented in 31-bits or 63-bits.&quot;<br>
        &lt;api&gt;<br>
        ^self<br>
+               cCode: [(intValue asUnsignedInteger bitXor: (intValue asUnsignedInteger &lt;&lt; 1)) asInteger &gt;= 0]<br>
+               inSmalltalk: [intValue &gt;= self minSmallInteger and: [intValue &lt;= self maxSmallInteger]]!<br>
-               cCode: [(intValue bitXor: (intValue &lt;&lt; 1)) asInteger &gt;= 0]<br>
-               inSmalltalk: [intValue &gt;= 16r-40000000 and: [intValue &lt;= 16r3FFFFFFF]]!<br>
<br>
Item was changed:<br>
  ----- Method: Spur32BitMemoryManager&gt;&gt;isIntegerValue: (in category &#39;interpreter access&#39;) -----<br>
  isIntegerValue: intValue<br>
        &quot;Answer if the given value can be represented as a Smalltalk integer value.<br>
         In C, use a shift and XOR to set the sign bit if and only if the top two bits of the given<br>
         value are the same, then test the sign bit. Note that the top two bits are equal for<br>
         exactly those integers in the range that can be represented in 31-bits or 63-bits.&quot;<br>
        &lt;api&gt;<br>
        ^self<br>
+               cCode: [(intValue asUnsignedInteger bitXor: (intValue asUnsignedInteger &lt;&lt; 1)) asInteger &gt;= 0]<br>
+               inSmalltalk: [intValue &gt;= self minSmallInteger and: [intValue &lt;= self maxSmallInteger]]!<br>
-               cCode: [(intValue bitXor: (intValue &lt;&lt; 1)) asInteger &gt;= 0]<br>
-               inSmalltalk: [intValue &gt;= 16r-40000000 and: [intValue &lt;= 16r3FFFFFFF]]!<br>
<br>
Item was changed:<br>
  ----- Method: Spur64BitMemoryManager&gt;&gt;integerObjectOf: (in category &#39;immediates&#39;) -----<br>
  integerObjectOf: value<br>
        &quot;Convert the integer value, assumed to be in SmallInteger range, into a tagged SmallInteger object.<br>
         In C, use a shift and an add to set the tag bit.<br>
         In Smalltalk we have to work harder because the simulator works with strictly positive bit patterns.&quot;<br>
        &lt;returnTypeC: #sqInt&gt;<br>
        ^self<br>
+               cCode: [value asUnsignedInteger &lt;&lt; self numTagBits + 1]<br>
-               cCode: [value &lt;&lt; self numTagBits + 1]<br>
                inSmalltalk: [value &lt;&lt; self numTagBits<br>
                                        + (value &gt;= 0<br>
                                                ifTrue: [1]<br>
                                                ifFalse: [16r10000000000000001])]!<br>
<br>
Item was changed:<br>
  ----- Method: Spur64BitMemoryManager&gt;&gt;isIntegerValue: (in category &#39;interpreter access&#39;) -----<br>
  isIntegerValue: intValue<br>
        &quot;Answer if the given value can be represented as a Smalltalk integer value.<br>
         In 64-bits we use a 3 bit tag which leaves 61 bits for 2&#39;s complement signed<br>
         integers. In C, use a shift add and mask to test if the top 4 bits are all the same.<br>
         Since 16rFFFFFFFFFFFFFFFF &gt;&gt; 60 = 16rF the computation intValue &gt;&gt; 60 + 1 bitAnd: 16rF<br>
         maps in-range -ve values to 0 and in-range +ve values to 1.&quot;<br>
        &lt;api&gt;<br>
        ^self<br>
                cCode: [(intValue &gt;&gt; 60 + 1 bitAnd: 16rF) &lt;= 1] &quot;N.B. (16rFFFFFFFFFFFFFFFF &gt;&gt; 60) + 1 = 16&quot;<br>
+               inSmalltalk: [intValue &gt;= self minSmallInteger and: [intValue &lt;= self maxSmallInteger]]!<br>
-               inSmalltalk: [intValue &gt;= -16r1000000000000000 and: [intValue &lt;= 16rFFFFFFFFFFFFFFF]]!<br>
<br>
Item was changed:<br>
  ----- Method: Spur64BitMemoryManager&gt;&gt;rotatedFloatBitsOf: (in category &#39;interpreter access&#39;) -----<br>
  rotatedFloatBitsOf: oop<br>
        &quot;Answer the signed, but unadjusted value of a SmallFloat64, suitable for use as a hash.<br>
         Keeping the exponent unadjusted keeps the value in the SmallInteger range.<br>
         See section 61-bit Immediate Floats in the SpurMemoryManager class comment.<br>
                                                        msb                                             lsb<br>
         Decode:                                [8expsubset][52mantissa][1s][3tags]<br>
         shift away tags &amp; sign:        [   0000   ][8expsubset][52mantissa]<br>
         add sign:                              [    ssss   ][8expsubset][52mantissa]&quot;<br>
        self assert: (self isImmediateFloat: oop).<br>
        ^oop asUnsignedInteger &gt;&gt; (self numTagBits + 1)<br>
         + ((oop anyMask: self smallFloatSignBit)<br>
+               ifTrue: [-1 asUnsignedInteger &lt;&lt; (64 - self numTagBits - 1)]<br>
-               ifTrue: [-1 &lt;&lt; (64 - self numTagBits - 1)]<br>
                ifFalse: [0])!<br>
<br>
Item was changed:<br>
  ----- Method: StackInterpreter&gt;&gt;maybeInlinePositive32BitIntegerFor: (in category &#39;primitive support&#39;) -----<br>
  maybeInlinePositive32BitIntegerFor: integerValue<br>
        &quot;N.B. will *not* cause a GC.<br>
         integerValue is interpreted as POSITIVE, e.g. as the result of Bitmap&gt;at:.&quot;<br>
        &lt;notOption: #Spur64BitMemoryManager&gt;<br>
+       &lt;var: &#39;integerValue&#39; type: #&#39;unsigned int&#39;&gt;<br>
        | newLargeInteger |<br>
        self deny: objectMemory hasSixtyFourBitImmediates.<br>
+       integerValue &lt;= objectMemory maxSmallInteger<br>
+               ifTrue: [^ objectMemory integerObjectOf: integerValue].<br>
-       (integerValue asInteger &gt;= 0<br>
-        and: [objectMemory isIntegerValue: integerValue]) ifTrue:<br>
-               [^objectMemory integerObjectOf: integerValue].<br>
        newLargeInteger := objectMemory<br>
                                                        eeInstantiateSmallClassIndex: ClassLargePositiveIntegerCompactIndex<br>
                                                        format: (objectMemory byteFormatForNumBytes: 4)<br>
                                                        numSlots: 1.<br>
        self cppIf: VMBIGENDIAN<br>
                ifTrue:<br>
                        [objectMemory<br>
                                storeByte: 3 ofObject: newLargeInteger withValue: (integerValue &gt;&gt; 24 bitAnd: 16rFF);<br>
                                storeByte: 2 ofObject: newLargeInteger withValue: (integerValue &gt;&gt; 16 bitAnd: 16rFF);<br>
                                storeByte: 1 ofObject: newLargeInteger withValue: (integerValue &gt;&gt;   8 bitAnd: 16rFF);<br>
                                storeByte: 0 ofObject: newLargeInteger withValue: (integerValue &quot;&gt;&gt; 0&quot; bitAnd: 16rFF)]<br>
                ifFalse:<br>
                        [objectMemory storeLong32: 0 ofObject: newLargeInteger withValue: integerValue].<br>
        ^newLargeInteger!<br>
<br>
Item was changed:<br>
  ----- Method: StackInterpreter&gt;&gt;positive32BitIntegerFor: (in category &#39;primitive support&#39;) -----<br>
  positive32BitIntegerFor: integerValue<br>
        &quot;integerValue is interpreted as POSITIVE, e.g. as the result of Bitmap&gt;at:.<br>
         N.B.  Returning in each arm separately enables Slang inlining.<br>
         /Don&#39;t/ return the ifTrue:ifFalse: unless Slang inlining of conditionals is fixed.&quot;<br>
        &lt;inline: true&gt;<br>
+       &lt;var: &#39;integerValue&#39; type: #&#39;unsigned int&#39;&gt;<br>
        objectMemory hasSixtyFourBitImmediates<br>
                ifTrue:<br>
                        [^objectMemory integerObjectOf: (integerValue bitAnd: 16rFFFFFFFF)]<br>
                ifFalse:<br>
                        [^self maybeInlinePositive32BitIntegerFor: integerValue]!<br>
<br>
Item was changed:<br>
  ----- Method: StackInterpreter&gt;&gt;positive64BitIntegerFor: (in category &#39;primitive support&#39;) -----<br>
  positive64BitIntegerFor: integerValue<br>
        &lt;api&gt;<br>
+       &lt;var: &#39;integerValue&#39; type: #usqLong&gt;<br>
+       &lt;var: &#39;highWord&#39; type: #&#39;unsigned int&#39;&gt;<br>
-       &lt;var: &#39;integerValue&#39; type: #sqLong&gt;<br>
        &quot;Answer a Large Positive Integer object for the given integer value.  N.B. will *not* cause a GC.&quot;<br>
        | newLargeInteger highWord sz |<br>
        objectMemory hasSixtyFourBitImmediates<br>
                ifTrue:<br>
+                       [integerValue &lt;= objectMemory maxSmallInteger ifTrue:<br>
-                       [(integerValue &gt;= 0 and: [objectMemory isIntegerValue: integerValue]) ifTrue:<br>
                                [^objectMemory integerObjectOf: integerValue].<br>
                         sz := 8]<br>
                ifFalse:<br>
+                       [(highWord := integerValue &gt;&gt; 32) = 0 ifTrue:<br>
-                       [(highWord := integerValue &gt;&gt;&gt; 32) = 0 ifTrue:<br>
                                [^self positive32BitIntegerFor: integerValue].<br>
                         sz := 5.<br>
                         (highWord := highWord &gt;&gt; 8) = 0 ifFalse:<br>
                                [sz := sz + 1.<br>
                                 (highWord := highWord &gt;&gt; 8) = 0 ifFalse:<br>
                                        [sz := sz + 1.<br>
                                         (highWord := highWord &gt;&gt; 8) = 0 ifFalse:[sz := sz + 1]]]].<br>
        newLargeInteger := objectMemory<br>
                                                        eeInstantiateSmallClassIndex: ClassLargePositiveIntegerCompactIndex<br>
                                                        format: (objectMemory byteFormatForNumBytes: sz)<br>
                                                        numSlots: 8 / objectMemory bytesPerOop.<br>
        self cppIf: VMBIGENDIAN<br>
                ifTrue:<br>
                        [objectMemory<br>
                                storeByte: 7 ofObject: newLargeInteger withValue: (integerValue &gt;&gt; 56 bitAnd: 16rFF);<br>
                                storeByte: 6 ofObject: newLargeInteger withValue: (integerValue &gt;&gt; 48 bitAnd: 16rFF);<br>
                                storeByte: 5 ofObject: newLargeInteger withValue: (integerValue &gt;&gt; 40 bitAnd: 16rFF);<br>
                                storeByte: 4 ofObject: newLargeInteger withValue: (integerValue &gt;&gt; 32 bitAnd: 16rFF);<br>
                                storeByte: 3 ofObject: newLargeInteger withValue: (integerValue &gt;&gt; 24 bitAnd: 16rFF);<br>
                                storeByte: 2 ofObject: newLargeInteger withValue: (integerValue &gt;&gt; 16 bitAnd: 16rFF);<br>
                                storeByte: 1 ofObject: newLargeInteger withValue: (integerValue &gt;&gt;   8 bitAnd: 16rFF);<br>
                                storeByte: 0 ofObject: newLargeInteger withValue: (integerValue &quot;&gt;&gt; 0&quot; bitAnd: 16rFF)]<br>
                ifFalse:<br>
                        [objectMemory storeLong64: 0 ofObject: newLargeInteger withValue: integerValue].<br>
        ^newLargeInteger<br>
  !<br>
<br>
Item was changed:<br>
  ----- Method: StackInterpreter&gt;&gt;signed64BitIntegerFor: (in category &#39;primitive support&#39;) -----<br>
  signed64BitIntegerFor: integerValue<br>
        &lt;var: &#39;integerValue&#39; type: #sqLong&gt;<br>
        &quot;Answer a Large Integer object for the given integer value.  N.B. will *not* cause a GC.&quot;<br>
        | newLargeInteger magnitude largeClass highWord sz |<br>
        &lt;inline: false&gt;<br>
+       &lt;var: &#39;magnitude&#39; type: #usqLong&gt;<br>
-       &lt;var: &#39;magnitude&#39; type: #sqLong&gt;<br>
        &lt;var: &#39;highWord&#39; type: #usqInt&gt;<br>
<br>
-       objectMemory wordSize = 8 ifTrue:<br>
-               [(objectMemory isIntegerValue: integerValue) ifTrue:<br>
-                       [^objectMemory integerObjectOf: integerValue].<br>
-                sz := 8].<br>
-<br>
        integerValue &lt; 0<br>
+               ifTrue:[        integerValue &gt;= objectMemory minSmallInteger ifTrue: [^objectMemory integerObjectOf: integerValue asInteger].<br>
+                               largeClass := ClassLargeNegativeIntegerCompactIndex.<br>
+                               magnitude := 0 - (self cCoerceSimple: integerValue to: #usqLong)]<br>
+               ifFalse:[       integerValue &lt;= objectMemory maxSmallInteger ifTrue: [^objectMemory integerObjectOf: integerValue asInteger].<br>
+                               largeClass := ClassLargePositiveIntegerCompactIndex.<br>
-               ifTrue:[        largeClass := ClassLargeNegativeIntegerCompactIndex.<br>
-                               magnitude := 0 - integerValue]<br>
-               ifFalse:[       largeClass := ClassLargePositiveIntegerCompactIndex.<br>
                                magnitude := integerValue].<br>
<br>
+       objectMemory wordSize = 8<br>
+               ifTrue: [sz := 8]<br>
+               ifFalse: [<br>
-       &quot;Make sure to handle the most -ve value correctly. 0 - most -ve = most -ve and most -ve - 1<br>
-        is +ve.  Alas the simple (negative or: [integerValue - 1 &lt; 0]) fails with contemporary gcc and icc<br>
-        versions with optimization and sometimes without.  The shift works on all, touch wood.&quot;<br>
-<br>
-       objectMemory wordSize = 4 ifTrue:<br>
-               [(magnitude &lt;= 16r7FFFFFFF<br>
-                 and: [integerValue &gt;= 0<br>
-                         or: [0 ~= (self cCode: [integerValue &lt;&lt; 1]<br>
-                                                       inSmalltalk: [integerValue &lt;&lt; 1 bitAnd: (1 &lt;&lt; 64) - 1])]]) ifTrue:<br>
-                               [^self signed32BitIntegerFor: integerValue].<br>
-<br>
                 (highWord := magnitude &gt;&gt; 32) = 0<br>
                        ifTrue: [sz := 4]<br>
                        ifFalse:<br>
                                [sz := 5.<br>
                                 (highWord := highWord &gt;&gt; 8) = 0 ifFalse:<br>
                                        [sz := sz + 1.<br>
                                         (highWord := highWord &gt;&gt; 8) = 0 ifFalse:<br>
                                                [sz := sz + 1.<br>
                                                 (highWord := highWord &gt;&gt; 8) = 0 ifFalse:<br>
                                                        [sz := sz + 1]]]]].<br>
<br>
        newLargeInteger := objectMemory<br>
                                                        eeInstantiateSmallClassIndex: largeClass<br>
                                                        format: (objectMemory byteFormatForNumBytes: sz)<br>
                                                        numSlots: sz + 3 // objectMemory bytesPerOop.<br>
        self cppIf: VMBIGENDIAN<br>
                ifTrue:<br>
                        [sz &gt; 4 ifTrue:<br>
                                [objectMemory<br>
                                        storeByte: 7 ofObject: newLargeInteger withValue: (magnitude &gt;&gt; 56 bitAnd: 16rFF);<br>
                                        storeByte: 6 ofObject: newLargeInteger withValue: (magnitude &gt;&gt; 48 bitAnd: 16rFF);<br>
                                        storeByte: 5 ofObject: newLargeInteger withValue: (magnitude &gt;&gt; 40 bitAnd: 16rFF);<br>
                                        storeByte: 4 ofObject: newLargeInteger withValue: (magnitude &gt;&gt; 32 bitAnd: 16rFF)].<br>
                        objectMemory<br>
                                storeByte: 3 ofObject: newLargeInteger withValue: (magnitude &gt;&gt; 24 bitAnd: 16rFF);<br>
                                storeByte: 2 ofObject: newLargeInteger withValue: (magnitude &gt;&gt; 16 bitAnd: 16rFF);<br>
                                storeByte: 1 ofObject: newLargeInteger withValue: (magnitude &gt;&gt;   8 bitAnd: 16rFF);<br>
                                storeByte: 0 ofObject: newLargeInteger withValue: (magnitude &quot;&gt;&gt; 0&quot; bitAnd: 16rFF)]<br>
                ifFalse:<br>
+                       [sz &gt; 4<br>
+                               ifTrue: [objectMemory storeLong64: 0 ofObject: newLargeInteger withValue: magnitude]<br>
+                               ifFalse: [objectMemory storeLong32: 0 ofObject: newLargeInteger withValue: (self cCode: [magnitude] inSmalltalk: [magnitude bitAnd: 16rFFFFFFFF])]].<br>
-                       [sz &gt; 4 ifTrue:<br>
-                               [objectMemory storeLong32: 1 ofObject: newLargeInteger withValue: magnitude &gt;&gt; 32.<br>
-                                magnitude := magnitude bitAnd: 16rFFFFFFFF].<br>
-                       objectMemory storeLong32: 0 ofObject: newLargeInteger withValue: magnitude].<br>
        ^newLargeInteger!<br>
<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div 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></div>