<div dir="ltr"><div><div><div><div><div><div><div><div><div>But the 32bits VM is already dealing with 64 bits integers specially.<br></div>Take + for example.<br></div>SmallInteger>>+ calls primitive: 1 (that is primitiveAdd)<br>LargePositiveInteger>>+ calls primitive: 21 (that is primitiveAddLargeIntegers)<br></div>Integer>>+ call digitAdd: which calls primitive: 'primDigitAdd' module:'LargeIntegers'<br><br></div>So what happens if you peform 1<<63+1 ?<br></div>It calls primitive: 21 which is doing this:<br>primitiveAddLargeIntegers<br> "Primitive arithmetic operations for large integers in 64 bit range"<br> | a b result oopResult aIsNegative bIsNegative resultIsNegative oopArg oopRcvr |<br> <export: true><br> <var: 'a' type: 'usqLong'><br> <var: 'b' type: 'usqLong'><br> <var: 'result' type: 'usqLong'><br><br> oopArg := self stackValue: 0.<br> oopRcvr := self stackValue: 1.<br> aIsNegative := self isNegativeIntegerValueOf: oopRcvr.<br> bIsNegative := self isNegativeIntegerValueOf: oopArg.<br> a := self magnitude64BitValueOf: oopRcvr.<br> b := self magnitude64BitValueOf: oopArg.<br> self successful ifFalse:[^nil].<br> (aIsNegative = bIsNegative)<br> ifTrue:<br> ["Protect against overflow"<br> a > (16rFFFFFFFFFFFFFFFF - b) ifTrue: [self primitiveFail. ^nil].<br> result := a + b.<br> resultIsNegative := aIsNegative]<br> ifFalse:<br> [(a >= b)<br> ifTrue:<br> [result := a - b.<br> resultIsNegative := aIsNegative]<br> ifFalse:<br> [result := b - a.<br> resultIsNegative := bIsNegative]].<br> oopResult := self magnitude64BitIntegerFor: result neg: resultIsNegative.<br> self successful ifTrue:[self pop: 2 thenPush: oopResult].<br><br></div>So you see, it just perform 64 bits arithmetic primitively.<br><br></div>However, if you do 1+(1<<63), then you invoke:<br>primitiveAdd<br><br> self pop2AndPushIntegerIfOK: (self stackIntegerValue: 1) + (self stackIntegerValue: 0)<br><br></div>That will fail because the argument is not a SmallInteger. Then you fallback to Integer>>+ which invokes digitAdd:<br><br></div>The only thing that changes with 64bits spur VM is that SmallInteger have 61bits and can represent any int in ((1<<60) negated to: (1<<60-1)). So 1+(1<<59) would still be a SmallInteger, but the other examples above would run unchanged.<br><div><div><div><div><br><br></div></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-10-14 0:22 GMT+02:00 Benoit St-Jean <span dir="ltr"><<a href="mailto:bstjean@yahoo.com" target="_blank">bstjean@yahoo.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div style="color:#000;background-color:#fff;font-family:times new roman,new york,times,serif;font-size:16px"><div id="m_3839342526852660740yui_3_16_0_ym19_1_1476379454522_45744" dir="ltr"><span id="m_3839342526852660740yui_3_16_0_ym19_1_1476379454522_46014">I was wondering if the 64-bit VM (such as the one for Squeak 5.1) will support 64-bit integer arithmetic with primitives for positive integers. Right now, 64 positive integers support bitwise operations but through code (LargePositiveInteger). Any plan to move those calculations/operations to primitives to speed things up? <br></span></div><div dir="ltr" id="m_3839342526852660740yui_3_16_0_ym19_1_1476379454522_46058"><span id="m_3839342526852660740yui_3_16_0_ym19_1_1476379454522_46014"><br></span></div><div dir="ltr" id="m_3839342526852660740yui_3_16_0_ym19_1_1476379454522_46100"><span id="m_3839342526852660740yui_3_16_0_ym19_1_1476379454522_46014">That would be so wonderful and nice for someone like me wanting to fully use a 64-bit architecture & Squeak/Cog/Pharo/Whatever/VM for a chess engine project!</span></div><div id="m_3839342526852660740yui_3_16_0_ym19_1_1476379454522_45883"> </div><div class="m_3839342526852660740signature" id="m_3839342526852660740yui_3_16_0_ym19_1_1476379454522_45831">----------------- <br>Benoît St-Jean <br>Yahoo! Messenger: bstjean
<br>Twitter: @BenLeChialeux
<br>Pinterest: benoitstjean
<br>Instagram: Chef_Benito<br>IRC: lamneth
<br>Blogue: <a href="http://endormitoire.wordpress.com" target="_blank">endormitoire.wordpress.com</a>
<br>"A standpoint is an intellectual horizon of radius zero". (A. Einstein)</div></div></div><br><br>
<br></blockquote></div><br></div>