<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Hi Eliot,</div><div><br></div>Ok, after spending 2.5 days on this (but well... now I know a lot about this stuff, he), I found that the problem with our compilation is that two flags are needed:&nbsp;<div><br></div><div>STACK_ALIGN_BYTES=16</div><div>ALLOCA_LIES_SO_USE_GETSP=0 //Yep, alloca is not lying here<br><div><br></div><div>problem is... while first flag can be set by command line, second one is setted on preamble for ThreadedFFIPlugin, then I need to change it...&nbsp;</div><div><br></div><div>so, here my question:&nbsp;</div><div><br></div><div>Why is working as is for you and not for us? (I think both of us are using mingw, and I installed gcc 3.4.5 to use same version as you) Do I'm missing something?</div><div><br></div><div>best,</div><div>Esteban<br><div><br><div><div>On Apr 25, 2012, at 1:20 AM, Eliot Miranda wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><br><br><div class="gmail_quote">On Tue, Apr 24, 2012 at 2:53 PM, Igor Stasenko <span dir="ltr">&lt;<a href="mailto:siguctua@gmail.com">siguctua@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
On 24 April 2012 19:16, Torsten Bergmann &lt;<a href="mailto:astares@gmx.de">astares@gmx.de</a>&gt; wrote:<br>
&gt;<br>
&gt; Load latest from ConfigurationOfFFI from MetacellRepository:<br>
&gt;<br>
&gt; For me the FFIPluginTest fails with latest Pharo 1.4 VM<br>
&gt; - so at least one has a reproducable case.<br>
&gt;<br>
Esteban spent whole day today trying to find the offending bug.<br>
Source code match 1:1 with Eliot's code, because there was no any<br>
changes in it..<br>
still the results is that it refuses to work correctly on windoze.<br></blockquote><div><br></div><div>You need to understand what the&nbsp;ThreadedFFIPlugin&nbsp;tries to do with alloca and that various compilers may implement alloca in a number of different ways. &nbsp;You then need to look at what the compiler actually does and figure out how to subvert it to do what you want to do.</div>
<div><br></div><div>1. &nbsp;the ThreadedFFIPlugin uses alloca to stack-allocate the space for the outgoing parameters of the FFI call. &nbsp;Sicne on x86 all parameters are passed on the stack and none in registers alloca is ideal. &nbsp;Notionally the plugin can call alloca to extend the stack downwards (stacks grow down, the result answered by alloca is a pointer to the start of N bytes, hence it is effectively the stack pointer. If this doesn't make sense to you *draw a picture on a whiteboard* of what you expect alloca(29) to do)</div>
<div><br></div><div>2. some C compilers are nice and implement alloca(N) as effectively stackPointer := stackPointer - roundUpTo(N,StackAlignment). &nbsp;For these compilers we don't need to do anything. &nbsp;Some C compilers try and be clever and answer stackPointer + 4, or something else. &nbsp;In these cases we need to get the actual stack pointer. &nbsp;So see the code ThreadedFFIPlugin class&gt;&gt;preambleCCode.</div>
<div><br></div><div>3. &nbsp;look at what the C compiler produces for the alloca call (and/or run under gdb) to see what happens to the stack pointer and what ends up in the allocation var in&nbsp;ffiCall:ArgArrayOrNil:NumArgs:.</div>
<div><br></div><div>4. update&nbsp;ThreadedFFIPlugin class&gt;&gt;preambleCCode. appropriately until you've bent alloca and the C compiler to your will.</div><div><br></div><div>You will not make this work without trying to understand what is going on and looking at what your C compiler produces. &nbsp;This is low-level hackery that aims to avoid having to write any assembler (outside of very few C asm statements).</div>
<div><br></div><div>HTH</div><div>Eliot</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
&gt; Thx<br>
&gt; T.<br>
<span class="HOEnZb"><font color="#888888">&gt; --<br>
&gt; NEU: FreePhone 3-fach-Flat mit kostenlosem Smartphone!<br>
&gt; Jetzt informieren: <a href="http://mobile.1und1.de/?ac=OM.PW.PW003K20328T7073a" target="_blank">http://mobile.1und1.de/?ac=OM.PW.PW003K20328T7073a</a><br>
<br>
<br>
<br>
--<br>
Best regards,<br>
Igor Stasenko.<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br>best,<div>Eliot</div><br>
</blockquote></div><br></div></div></div>
</body></html>