<br><br><div class="gmail_quote">On Sun, May 24, 2009 at 1:13 PM, John M McIntosh <span dir="ltr">&lt;<a href="mailto:johnmci@smalltalkconsulting.com" target="_blank">johnmci@smalltalkconsulting.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>
<br>
<br>
Begin forwarded message:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
From: Stéphane Ducasse &lt;<a href="mailto:stephane.ducasse@inria.fr" target="_blank">stephane.ducasse@inria.fr</a>&gt;<br>
Date: May 24, 2009 1:35:01 AM PDT (CA)<br>
To: Pharo Development &lt;<a href="mailto:Pharo-project@lists.gforge.inria.fr" target="_blank">Pharo-project@lists.gforge.inria.fr</a>&gt;<br>
Subject: [Pharo-project] Could not load VMMaker in 10315<br>
Reply-To: <a href="mailto:Pharo-project@lists.gforge.inria.fr" target="_blank">Pharo-project@lists.gforge.inria.fr</a><br>
<br>
Hi<br>
<br>
I did<br>
<br>
ScriptLoader loadFFI<br>
Then loaded VMMaker-dtl.122<br>
Then proceeded when asked about klatt.<br>
<br>
And I got Cannot compile -- stack including temps is too deep<br>
<br>
what did I miss?</blockquote></blockquote><div><br></div><div>Nothing.  There is a method in the GeniePlugin who&#39;s stack is too deep to compile with closures.  Here are some workarounds and solutions in increasing levels of difficulty:</div>

<div><br></div><div>1. since the GeniePlugin is inessential simply move it to another package and ignore the problem (this is what we have done at Qwaq).</div><div><br></div><div>2a. Since the method is never executed one can temporarily change the stack limit (e.g. CompiledMethod classPool at: #LargeFrame put: 57) and load the package, reverting the stack limit after loading (Compiledmethod classPool at: #LargeFrame put: 56)</div>

<div><br></div><div>2b. change CompiledMethod&gt;&gt;needsFrame: so that proceeding from the error still creates a compiled method (i.e. remove the ^ return from the method so that it reads</div><div><span style="font-family:Times;font-size:16px"><font color="#000000">        needsFrameSize: </font><font color="#000080">newFrameSize</font><font color="#000000"> <br>

                        </font><font color="#008080">&quot;Set the largeFrameBit to accomodate the newFrameSize&quot;</font><font color="#000000"> <br>                        </font><font color="#808080">|</font><font color="#000000"> </font><font color="#6B6767">largeFrameBit</font><font color="#000000"> </font><font color="#6B6767">header</font><font color="#000000"> </font><font color="#808080">|</font><font color="#000000"> <br>

                        </font><font color="#6B6767">largeFrameBit</font><font color="#000000"> </font><b>:=</b><font color="#000000"> </font><font color="#800000">16r20000</font><font color="#000000">. <br>                        (</font><font color="#800000">self</font><font color="#000000"> </font><font color="#000080">numTemps</font><font color="#000000"> </font><font color="#000080">+</font><font color="#000000"> </font><font color="#000080">newFrameSize</font><font color="#000000">) </font><font color="#000080">&gt;</font><font color="#000000"> </font><font color="#404040">LargeFrame</font><font color="#000000"> </font><font color="#000080">ifTrue:</font><font color="#000000"> <br>

                                        [</font><font color="#800000">self</font><font color="#000000"> </font><font color="#000080">error:</font><font color="#000000"> </font><font color="#800080"><font size="0.9" face="&#39;Accuny&#39;">&#39;Cannot compile -- stack including temps is too deep&#39;</font></font><font color="#000000">]. <br>

                        </font><font color="#6B6767">header</font><font color="#000000"> </font><b>:=</b><font color="#000000"> </font><font color="#800000">self</font><font color="#000000"> </font><font color="#000080">objectAt:</font><font color="#000000"> </font><font color="#800000">1</font><font color="#000000">. <br>

                        (</font><font color="#6B6767">header</font><font color="#000000"> </font><font color="#000080">bitAnd:</font><font color="#000000"> </font><font color="#6B6767">largeFrameBit</font><font color="#000000">) </font><font color="#000080">~=</font><font color="#000000"> </font><font color="#800000">0</font><font color="#000000"> <br>

                                        </font><font color="#000080">ifTrue:</font><font color="#000000"> [</font><font color="#6B6767">header</font><font color="#000000"> </font><b>:=</b><font color="#000000"> </font><font color="#6B6767">header</font><font color="#000000"> </font><font color="#000080">-</font><font color="#000000"> </font><font color="#6B6767">largeFrameBit</font><font color="#000000">]. <br>

                        </font><font color="#800000">self</font><font color="#000000"> </font><font color="#000080">objectAt:</font><font color="#000000"> </font><font color="#800000">1</font><font color="#000000"> </font><font color="#000080">put:</font><font color="#000000"> </font><font color="#6B6767">header</font><font color="#000000"> <br>

                                                        </font><font color="#000080">+</font><font color="#000000"> (</font><font color="#008000">(</font><font color="#800000">self</font><font color="#000000"> </font><font color="#000080">numTemps</font><font color="#000000"> </font><font color="#000080">+</font><font color="#000000"> </font><font color="#000080">newFrameSize</font><font color="#008000">)</font><font color="#000000"> </font><font color="#000080">&gt;</font><font color="#000000"> </font><font color="#404040">SmallFrame</font><font color="#000000"> <br>

                                                                                        </font><font color="#000080">ifTrue:</font><font color="#000000"> </font><font color="#008000">[</font><font color="#6B6767">largeFrameBit</font><font color="#008000">]</font><font color="#000000"> <br>

                                                                                        </font><font color="#000080">ifFalse:</font><font color="#000000"> </font><font color="#008000">[</font><font color="#800000">0</font><font color="#008000">]</font><font color="#000000">)</font></span></div>

<div><span style="font-family:Times;font-size:16px"><br></span></div><div>then file-in the method and proceed through the warning.</div><div>Both of these are tedious but since you&#39;re probably not going to be changing the method and since Monticello won&#39;t recompile it once it is loaded it&#39;ll sit there quite happily once compiled.</div>

<div><br></div><div>3. refactor the GeniePlugin method into an outer args parser and an inner engine method and solve the problem.  Since VMMaker will inline anyway this shouldn&#39;t make performance worse.  I haven&#39;t done this because I&#39;m not the author and it is quite a complex method.</div>

<div><br></div><div>4. modify the Closure compiler so that it reuses temporaries in optimized blocks.  The method compiles with the BlueBook compiler because in</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>1 to: n do: [:i| .......].<br>
</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>...<br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>1 to: n do: [:i| .......].<br></div><div>the two block variables &quot;i&quot; are the same &quot;physical&quot; variable stored in the same location in the home context (because BlueBook blocks do not have local arguments or temporaries).</div>
<div>But in the Closure compiler they are logically distinct variables and if the blocks were real and not optimized they would occupy different &quot;physical&quot; locations.  Since they are optimized blocks their temporaries do get allocated in the home context, but they occupy different locations, and hence the stack size is larger in the Closure compiler.  The Closure compiler could be modified to use a more sophisticated temporary variable scope analysis that would allow it to determine that the first block&#39;s &quot;i&quot; is out of scope when the second block is compiled and hence that the location can be reused.</div>
<div>This is non-trivial because it requires rewriting much of the temporary scope management (see TempVariableNode&gt;&gt;scope[:] &amp; senders of scope:).  If I had hit the stack limit in more than this one method I probably would have tried to solve this but for now there are fatter fish to fry.</div>
<div><br></div><div><br></div><div>I plan that eventually the Cog VM will support a CompiledMethod format that will have a higher argument, temp and total frame size limit, but this isn&#39;t a priority right now.</div>
<div><br></div><div>Apologies</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"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<br>
<br>
Stef<br>
<br>
_______________________________________________<br>
Pharo-project mailing list<br>
<a href="mailto:Pharo-project@lists.gforge.inria.fr" target="_blank">Pharo-project@lists.gforge.inria.fr</a><br>
<a href="http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project" target="_blank">http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project</a><br>
</blockquote>
<br>
--<br>
=<br>
=<br>
=<br>
========================================================================<br>
John M. McIntosh &lt;<a href="mailto:johnmci@smalltalkconsulting.com" target="_blank">johnmci@smalltalkconsulting.com</a>&gt;   Twitter:  squeaker68882<br>
Corporate Smalltalk Consulting Ltd.  <a href="http://www.smalltalkconsulting.com" target="_blank">http://www.smalltalkconsulting.com</a><br>
===========================================================================<br>
<br>
<br>
<br>
<br>
</blockquote></div><br>