<div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Apr 27, 2012 at 7:37 PM, Eliot Miranda <span dir="ltr">&lt;<a href="mailto:eliot.miranda@gmail.com" target="_blank">eliot.miranda@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 class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Apr 27, 2012 at 12:57 AM, Mariano Martinez Peck <span dir="ltr">&lt;<a href="mailto:marianopeck@gmail.com" target="_blank">marianopeck@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 class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Apr 19, 2012 at 6:06 PM, Eliot Miranda <span dir="ltr">&lt;<a href="mailto:eliot.miranda@gmail.com" target="_blank">eliot.miranda@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><br><br><div class="gmail_quote">On Thu, Apr 19, 2012 at 12:55 AM, Mariano Martinez Peck <span dir="ltr">&lt;<a href="mailto:marianopeck@gmail.com" target="_blank">marianopeck@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><br><div class="gmail_quote"><div>On Thu, Apr 19, 2012 at 6:08 AM, Eliot Miranda <span dir="ltr">&lt;<a href="mailto:eliot.miranda@gmail.com" target="_blank">eliot.miranda@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">
<pre style="word-wrap:break-word;white-space:pre-wrap"><font face="arial, helvetica, sans-serif"><a href="http://www.mirandabanda.org/files/Cog/VM/VM.r2550/" target="_blank">http://www.mirandabanda.org/files/Cog/VM/VM.r2550/</a></font></pre>





<pre style="word-wrap:break-word;white-space:pre-wrap"><font face="arial, helvetica, sans-serif">CogVM binaries as per VMMaker.oscog-eem.157/r2550.

Stack/CoInterpreter/Cogit:
Implement proper bounds checking for byte access to compiled
methods.  Raise errors for accesses outside initialPC to size.

CoInterpreter:
Provide a thorough flush primitive for CompiledMethods that discards all
machine code and makes sure that any contexts using the method have bytecode
pcs.  Primitive #215 (same as 116 in the Stack VM).  This is much slower than
116 (flushCache) since it has to enumerate over all heap contexts.</font></pre></blockquote></div><div><br>Excellent. Does it mean we should implement something like this:<br><br>CompiledMethod &gt;&gt; flushCache<br>    &quot;Tell the interpreter to remove all references to this method from its method lookup cache, if it has one. In addition, it provides a thorough flush primitive for CompiledMethods that discards all machine code and makes sure that any contexts using the method have bytecode<br>




pcs.<br>    This primitive must be called whenever a method is redefined or removed.&quot;<br>    &lt;primitive: 215&gt;<br>    self simpleFlushCache<br><br><br>CompiledMethod &gt;&gt; simpleFlushCache<br>    &quot;Tell the interpreter to remove all references to this method from its method lookup cache, if it has one. This primitive must be called whenever a method is redefined or removed.&quot;<br>




<br>    &lt;primitive: 116&gt;\<br></div></div></blockquote><div><br></div><div>No.  215 is extremely expensive, because it scans the entire heap looking for contexts using the method, and in the common case of redefining a method it is unnecessary.  It is only necessary if you modify a method still in-use; read the comment of the attached method.</div>



<div><br></div><div>Further, I would prefer to update the Interpreter to implement primitive 215 using primitive 116, i.e. in the Interpreter&#39;s primitive table have both</div><div><br></div><div><span style="white-space:pre-wrap">                </span>(116 primitiveFlushCacheByMethod)</div>



<div>...</div><div><span style="white-space:pre-wrap">                </span>(215 primitiveFlushCacheByMethod) &quot;primitiveVoidVMStateForMethod in the CoInterpreter&quot;</div><div><br></div><div>This is what I&#39;ve done in the StackInterpreter.  In fact, we need to put in time to bring the Interpreter&#39;s primitive set into agreement with Cog.</div>



<div><br></div></div></blockquote><div><br><br>Ok, I understand. Now, primitive 215 #primitiveVoidVMStateForMethod receives a CompiledMethod so we implement #voidCogVMState there. However, I see there is also primitive 214 #primitiveVoidVMState.  Should we ALSO add something like<br>


<br>voidCogVMState<br>    &quot;Void all internal VM state in the stack and machine code zones<br>&lt;primitive: 214&gt;
<div><span style="white-space:pre-wrap">        </span>^self primitiveFailed</div><br><br>But implemented in SmallttalkImage/VirtualMachine  ??<br></div></div></div></blockquote><div><br></div><div>Yes.  Find attached. </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div class="gmail_extra"><div class="gmail_quote"><div><br></div></div></div></blockquote></div></div></blockquote><div><br><br>Thanks. I did slice for Pharo.<br><a href="http://code.google.com/p/pharo/issues/detail?id=5728">http://code.google.com/p/pharo/issues/detail?id=5728</a><br>
<br> </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div class="gmail_extra"><div class="gmail_quote"><div><br>thanks!<br> </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div class="gmail_quote"><div></div><div><br></div><div>So I&#39;m expecting we will have</div><div><br></div><div><div>voidCogVMState</div><div><span style="white-space:pre-wrap">        </span>&quot;Tell the VM to remove all references to any machine code form of the method.</div>



<div><span style="white-space:pre-wrap">        </span> This primitive must be called whenever a method is in use and modified.  This is</div><div><span style="white-space:pre-wrap">        </span> more aggressive (and *much* more costly) than flushCache since it must search</div>



<div><span style="white-space:pre-wrap">        </span> through all context objects, making sure that none have a (hidden) machine code pc</div><div><span style="white-space:pre-wrap">        </span> in the receiver.  Since modifying a method will likely change the generated machine code,</div>



<div><span style="white-space:pre-wrap">        </span> modifying a method (rather than redefining it) requires this more aggressive flush.&quot;</div><div><br></div><div><span style="white-space:pre-wrap">        </span>&lt;primitive: 215&gt;</div>



<div><span style="white-space:pre-wrap">        </span>^self primitiveFailed</div></div><div><br></div><div><div>flushCache</div><div><span style="white-space:pre-wrap">        </span>&quot;Tell the interpreter to remove all references to this method from its method lookup cache, if it has one.  This primitive must be called whenever a method is defined or removed.</div>



<div><span style="white-space:pre-wrap">        </span>NOTE:  Only one of two selective flush methods needs to be used.</div><div><span style="white-space:pre-wrap">        </span>Squeak 2.2 and earlier uses 119 (See Symbol flushCache).</div>



<div><span style="white-space:pre-wrap">        </span>Squeak 2.3 and later uses 116 (See CompiledMethod flushCache).&quot;</div><div><br></div><div><span style="white-space:pre-wrap">        </span>&lt;primitive: 116&gt;</div>
</div><div><br></div><div>or</div><div><br></div><div><div><div>voidCogVMState</div><div><span style="white-space:pre-wrap">        </span>&quot;Tell the VM to remove all references to any machine code form of the method.</div>



<div><span style="white-space:pre-wrap">        </span> This primitive must be called whenever a method is in use and modified.  This is</div><div><span style="white-space:pre-wrap">        </span> more aggressive (and *much* more costly) than flushCache since it must search</div>



<div><span style="white-space:pre-wrap">        </span> through all context objects, making sure that none have a (hidden) machine code pc</div><div><span style="white-space:pre-wrap">        </span> in the receiver.  Since modifying a method will likely change the generated machine code,</div>



<div><span style="white-space:pre-wrap">        </span> modifying a method (rather than redefining it) requires this more aggressive flush.&quot;</div><div><br></div><div><span style="white-space:pre-wrap">        </span>&lt;primitive: 215&gt;</div>



<div><span style="white-space:pre-wrap">        </span>^self flushCache</div></div></div><div><br></div><div><div>flushCache</div><div><span style="white-space:pre-wrap">        </span>&quot;Tell the interpreter to remove all references to this method from its method lookup cache, if it has one.  This primitive must be called whenever a method is defined or removed.</div>



<div><span style="white-space:pre-wrap">        </span>NOTE:  Only one of two selective flush methods needs to be used.</div><div><span style="white-space:pre-wrap">        </span>Squeak 2.2 and earlier uses 119 (See Symbol flushCache).</div>



<div><span style="white-space:pre-wrap">        </span>Squeak 2.3 and later uses 116 (See CompiledMethod flushCache).&quot;</div><div><br></div><div><span style="white-space:pre-wrap">        </span>&lt;primitive: 116&gt;</div>
</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_quote"><div><br><br> <br>If you have a better name for #simpleFlushCache please let me know. <br>



if you agree, I will open an issue for this.<br><br>Cheers<br><br><br></div><div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<pre style="word-wrap:break-word;white-space:pre-wrap"><font face="arial, helvetica, sans-serif">

Provide an xray primitive for CompiledMethod that answers if a method has
machine code, and if so if it&#39;s machine code is frameless, and/or refers
to a young object.  No primitive number.  Used to test the above.

Make printOopShort: print Association keys.  Useful for
longPrintOop:, and hence printReferencesTo: etc.

Mac OS: add fflush to debug printing in sqMacUIEventsUniversal.c so output
appears promptly.

Fix the annoying bogus error messages from the mprotect calls by getting the
length arg to mprotect right.

Add version infor for the Cross/plugins tree.  Add a -version switch to win32</font></pre><span><font color="#888888"><pre style="word-wrap:break-word;white-space:pre-wrap"><span style="font-family:arial,helvetica,sans-serif;white-space:normal">-- </span></pre>





<pre style="word-wrap:break-word;white-space:pre-wrap"><span style="font-family:arial,helvetica,sans-serif;white-space:normal">best,</span></pre><div><font face="arial, helvetica, sans-serif">Eliot</font></div>
<br>
</font></span><br><br>
<br></blockquote></div></div><span><font color="#888888"><br><br clear="all"><br>-- <br>Mariano<br><a href="http://marianopeck.wordpress.com" target="_blank">http://marianopeck.wordpress.com</a><br><br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br>best,<div>Eliot</div><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>Mariano<br><a href="http://marianopeck.wordpress.com" target="_blank">http://marianopeck.wordpress.com</a><br><br>
</div>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br>best,<div>Eliot</div><br>
</div>
<br></blockquote></div><br><br clear="all"><br>-- <br>Mariano<br><a href="http://marianopeck.wordpress.com" target="_blank">http://marianopeck.wordpress.com</a><br><br>
</div>