<div dir="ltr">Hi Ryan,<div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jun 9, 2015 at 10:58 PM, Ryan Macnak <span dir="ltr">&lt;<a href="mailto:rmacnak@gmail.com" target="_blank">rmacnak@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><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Jun 9, 2015 at 8:36 AM, Eliot Miranda <span dir="ltr">&lt;<a href="mailto:eliot.miranda@gmail.com" target="_blank">eliot.miranda@gmail.com</a>&gt;</span> wrote:<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"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>Hi Ryan,</div><div><br></div><div>    IMO the likely issue is register usage in trampoline calls.  The JIT tries to reduce register saving and restoring across trampoline calls by using a notion of the ABI&#39;s caller-saved registers.  Callee-saved registers shouldn&#39;t be an issue because either a run-time call returns to the same trampoline that invoked it, hence restoring callee-saved registers, or enters machine code via an enlopmart which assumes no registers are live and restores any and all registers as appropriate.  But there could be bugs here, and certainly gcc could change over versions, perhaps becoming more aggressive in register saving, and surfacing previously undetected bugs here.</div></div></div></div></blockquote><div><br></div><div>I&#39;ve been using the same compiler versions though, did this change recently in Cog?</div><div><br></div><div>The runtime entries should be marked &quot;extern&quot;. <a href="https://github.com/dart-lang/sdk/blob/6542a451c38c650a5ce9323e474982384a5daf31/runtime/vm/runtime_entry.h#L67" target="_blank">Compare a VM that works at -O3.</a></div></div></div></div></blockquote><div><br></div><div>OK, so the compiler is interpreting &quot;void foo(decl)&quot; differently to &quot;extern void foo(decl); void foo(decl)&quot;.  Back in the day these were equivalent and C compilers only teated &quot;static&quot; as meaningful.  e.g. The C Programming Language, 2nd ed, sec A11.2 Linkage, p 228: </div><div>    &quot;As discussed in §A10.2, the first external declaration for an identifier gives the identifier internal linkage if the <font class="Apple-style-span" face="monospace, monospace">static</font> specifier is used, external linkage otherwise.&quot;</div><div>but I guess providing optimized intra-compilation-unit linkage produces some benefits.  Anyway, see VMMaker.oscog-eem.1349 which now spits out extern or static for each function declaration.  I&#39;ll commit C source soon.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><br></div><div>Some quick and dirty sed hacking and this partially fixes NSVM on clang 3.4 (can now complete the test suite without crashing about half of the time).</div><div><br></div><div><div>find ns*src -name &#39;*.c&#39; -o -name &#39;*.h&#39; -print0 | xargs -0 sed -i &#39;&#39; -e &#39;s/void ce/extern void ce/&#39;</div><div>find ns*src -name &#39;*.c&#39; -o -name &#39;*.h&#39; -print0 | xargs -0 sed -i &#39;&#39; -e &#39;s/void (\*ce/extern void (\*ce/&#39;</div><div>find ns*src -name &#39;*.c&#39; -o -name &#39;*.h&#39; -print0 | xargs -0 sed -i &#39;&#39; -e &#39;s/sqInt ce/extern sqInt ce/&#39;</div><div>find ns*src -name &#39;*.c&#39; -o -name &#39;*.h&#39; -print0 | xargs -0 sed -i &#39;&#39; -e &#39;s/VM_EXPORT extern/extern/&#39;</div><div>find ns*src -name &#39;*.c&#39; -o -name &#39;*.h&#39; -print0 | xargs -0 sed -i &#39;&#39; -e &#39;s/static extern/static/&#39;</div><div>find ns*src -name &#39;*.c&#39; -o -name &#39;*.h&#39; -print0 | xargs -0 sed -i &#39;&#39; -e &#39;s/extern sqInt cesoRetAddr/sqInt cesoRetAddr/&#39;</div></div><div><br></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"><span style="font-size:12.8000001907349px">One thing to do is compare a StackInterpreter VM against Cog, at least to locate the blame.</span></blockquote><div><br></div><div>The stack VM is fine.</div><div><br></div><div><br></div><div><br></div><div> </div></div><br></div></div>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">best,<div>Eliot</div></div>
</div></div>