<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 08 Mar 2016, at 22:50, Nicolas Cellier &lt;<a href="mailto:nicolas.cellier.aka.nice@gmail.com" class="">nicolas.cellier.aka.nice@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><br class=""><div class="gmail_extra"><br class=""><div class="gmail_quote">2016-03-08 22:10 GMT+01:00 Esteban Lorenzano <span dir="ltr" class="">&lt;<a href="mailto:estebanlm@gmail.com" target="_blank" class="">estebanlm@gmail.com</a>&gt;</span>:<br class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">&nbsp;<br class=""><div style="word-wrap:break-word" class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On 08 Mar 2016, at 21:38, Nicolas Cellier &lt;<a href="mailto:nicolas.cellier.aka.nice@gmail.com" target="_blank" class="">nicolas.cellier.aka.nice@gmail.com</a>&gt; wrote:</div><br class=""><div class=""><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class="">IMO the right fix would be to force coercion here:<br class=""><span class=""><br class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ifTrue:[interpreterProxy signed64BitIntegerFor: (</span><span class="">self cCoerceSimple: value to: #sqLong)]<br class=""></span></div></div></blockquote></div></div></blockquote></div></div></div></div></blockquote><div><br class=""></div><div>mmm… kind of disagree, but ok, you know a lot more than me in this issues :)</div><div>nevertheless just coercing keeps failing :(<div class="">what actually worked was to use *machine* methods (btw now I understand them)… I’m committing now.</div></div><div><br class=""></div>Esteban</div><div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word" class=""><div class=""><div class=""><br class=""></div><div class="">why?&nbsp;</div></div></div></blockquote><div class=""><div class=""><br class=""></div>I recommend writing simple programs like below, compile and run:<br class=""><br class=""></div><div class="">#include &lt;stdio.h&gt;<br class=""></div><div class="">int main() {<br class=""></div><div class="">&nbsp;&nbsp;&nbsp; int x=-1;<br class=""></div><div class="">&nbsp;&nbsp;&nbsp; unsigned long long y;<br class=""></div><div class="">&nbsp;&nbsp; y = (signed) x;<br class=""></div><div class="">&nbsp;&nbsp; printf(" y &lt;- (signed) x :%llx\n", y);<br class=""><div class="">&nbsp;&nbsp; y = (unsigned) x;<br class=""></div>&nbsp;&nbsp; printf(" y &lt;- (unsigned) x :%llx\n", y);<br class="">}<br class=""></div><div class="">&nbsp;<br class=""></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word" class=""><div class=""><div class="">forcing a coercion to "unsigned int” while we always use sqTypes didn’t feel correct… also long32At will always answer an sqLong, that’s why I thought simpler approach was to remove a coercion instead adding two…&nbsp;</div><br class=""></div></div></blockquote>&nbsp;<br class=""></div><div class="gmail_quote">I wouldn't trust it too much. What is long32At doing exactly?<br class="">I can see two versions of it in platforms/Cross/vm/sqMemoryAccess.h ...<br class=""><br class="">#define long32At&nbsp;&nbsp;&nbsp; intAt<br class=""># define intAt(oop)&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; intAtPointer(atPointerArg(oop))<br class=""># define intAtPointer(ptr)&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ((sqInt)(*((int *)(ptr))))<br class=""><br class=""></div><div class="gmail_quote">In this case, there will be sign promotion and (ref integerAt: 1 size: 4 signed: false) will be broken on 64bits VM...<br class=""><br class=""></div><div class="gmail_quote">But with the other #if #else branch:<br class=""><br class="">static inline sqInt intAt(sqInt oop)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { return intAtPointer(pointerForOop(oop)); }<br class="">static inline sqInt intAtPointer(char *ptr)&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; { return (sqInt)(*((unsigned int *)ptr)); }<br class=""><br class=""></div><div class="gmail_quote">there won't be any sign promotion, and this time the problem will be with (ref integerAt: 1 size: 4 signed: true)on 64 bits VM<br class=""><br class=""></div><div class="gmail_quote">So the 32 high bits of long32 SHOULD be UNTRUSTED and that's why we need to force (int) or (unsigned int) cast in 64 bits VM.<br class=""></div><div class="gmail_quote">It's a mistake to have long32 returning a sqInt, it should return a 32bits int.<br class="">Currently, int would fit for supported platform, but to be future proof, it should have been int32_t<br class=""></div><div class="gmail_quote"><br class=""></div><div class="gmail_quote">In my own VM brand I have defined unsignedLong32At to be sure to avoid these nasty horrible things...<br class=""></div><div class="gmail_quote">Most of the time handling unsigned is the right thing to do, they have well defined, least surprising behavior.<br class=""><br class=""></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word" class=""><div class=""><blockquote type="cite" class=""><div class=""><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><span class=""><br class=""></span></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><span class="">But maybe we can avoid signed64/unsigned64 and use signedMachineInteger and positiveMachineInteger when byteSize = bytePerWord...<br class=""></span></div></div></blockquote></div><br class=""><div class="">that, I have no idea, maybe :)</div></div></blockquote><div class=""><br class=""></div><div class="">It's just an optimization for avoiding unecessary 64bits ops.<br class="">&nbsp;<br class=""></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word" class=""><div class=""><br class=""></div><div class="">Esteban</div></div><br class=""></blockquote></div><br class=""></div></div>
</div></blockquote></div><br class=""></body></html>