<br><br><div class="gmail_quote">On Fri, Dec 3, 2010 at 6:42 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: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div><div></div><div class="h5"><br>
On 3 December 2010 16:58, Mariano Martinez Peck &lt;<a href="mailto:marianopeck@gmail.com">marianopeck@gmail.com</a>&gt; wrote:<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; On Fri, Dec 3, 2010 at 3:41 PM, Mariano Martinez Peck &lt;<a href="mailto:marianopeck@gmail.com">marianopeck@gmail.com</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; Hi folks. After fighting and fighting about crashes using SmallInteger as methods, I finally could debug the VM (thanks Esteban for the help in compiling and debugging!!) and I think I found a problem in theGC.<br>

&gt;&gt; In the mark phase of the GC, it tries to mark all interpreter oops in the method:  markAndTraceInterpreterOops<br>
&gt;&gt;<br>
&gt;&gt; If you see that method....it does this (a part of it):<br>
&gt;&gt;<br>
&gt;&gt; compilerInitialized<br>
&gt;&gt;         ifTrue: [self markAndTrace: receiver.<br>
&gt;&gt;             self markAndTrace: method]<br>
&gt;&gt;         ifFalse: [self markAndTrace: activeContext].<br>
&gt;&gt;     self markAndTrace: messageSelector.<br>
&gt;&gt;     self markAndTrace: newMethod.<br>
&gt;&gt;<br>
&gt;&gt; If you are using SmallInteger as methods.....newMethod can be a SmallIneteger, and not a method....so if we then see the method markAndTrace:<br>
&gt;&gt;<br>
&gt;&gt; the first lines are:<br>
&gt;&gt;<br>
&gt;&gt;     | header lastFieldOffset action statMarkCountLocal |<br>
&gt;&gt;     header := self longAt: oop.<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; And of course, it crash in that #longAt:<br>
&gt;&gt;<br>
&gt;&gt; :)<br>
&gt;&gt;<br>
&gt;&gt; So, solutions:<br>
&gt;&gt;<br>
&gt;&gt; 1) Put an if in each place where it uses newMethod or method or newNativeMethod or suspendedMethods  or whatever<br>
&gt;&gt; 2) Put an if in #markAndSweep.<br>
&gt;&gt;<br>
&gt;&gt; I think 2) is easier and it is just adding one line of code at the beginning:<br>
&gt;&gt;<br>
&gt;&gt;     | header lastFieldOffset action statMarkCountLocal |<br>
&gt;&gt;     (self isIntegerObject: oop) ifTrue: [ ^ 0 ].<br>
&gt;&gt;     header := self longAt: oop.<br>
&gt;&gt; ....<br>
&gt;&gt;<br>
&gt;&gt; what do you think ?<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; Finally, I am afraid that there are more places where Interpreter uses any of those instVar that represent methods, and treat them as real objects.<br>
&gt;&gt; So maybe there still pending future possible crashes?<br>
&gt;&gt;<br>
&gt;<br>
&gt;<br>
&gt; For example, take a look to the methods:<br>
&gt;<br>
&gt; printUnbalancedStackFromNamedPrimitive<br>
&gt; primitiveMethod<br>
&gt; internalJustActivateNewMethod<br>
&gt; internalActivateNewMethod<br>
&gt; activateNewMethod<br>
&gt;<br>
&gt; And all the senders of<br>
&gt;<br>
&gt; literal: offset ofMethod: methodPointer<br>
&gt; literalCountOf: methodPointer<br>
&gt; primitiveIndexOf:<br>
&gt;<br>
</div></div>no, but these  methods usually should be fired only after you already<br>
determined that given oop is a compiled method,<br>
not a smallinteger or something else.<br>
<div class="im"><br></div></blockquote><div><br>But they do not. Let&#39;s take an example: literal: offset ofMethod: methodPointer<br>sender: methodClassOf: methodPointer<br>sender: superclassSend<br>sender: doubleExtendedDoAnythingBytecode and singleExtendedSuperBytecode<br>
<br>did I miss something?<br><br><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="im">
&gt; maybe supporting SmallInteger as methods was not a good idea :(<br>
&gt;<br>
</div>it should work.<br>
<br>
&gt; cheers<br>
&gt;<br>
&gt; mariano<br>
&gt;<br>
&gt;<br>
&gt;&gt;<br>
&gt;&gt; Thanks<br>
&gt;&gt;<br>
&gt;&gt; Mariano<br>
&gt;<br>
&gt;<br>
&gt;<br>
<font color="#888888"><br>
<br>
<br>
--<br>
Best regards,<br>
Igor Stasenko AKA sig.<br>
</font></blockquote></div><br>