<br><br><div class="gmail_quote">On Wed, Oct 13, 2010 at 5:11 PM, Mariano Martinez Peck <span dir="ltr">&lt;<a href="mailto:marianopeck@gmail.com">marianopeck@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;">
Hi. Sorry if the question is newbie. I am still reading the blue book, so in case this is explained there I would just appreciate a link to it. <br><br>The problem is the following: I have implemented some functionality in Interpreter to trace objects usage. I have modified all bytecodes and different primitives and now I am almost sure I am covering all the &quot;methods sends&quot;. Now, I have a problem with bitOr: and bitAnd: for example.<br>

<br>If I do   9999999999999999 bitOr:   8888888888888888888<br>I would like to trace both intances of LargePositiveInteger as used. <br><br>LargePositiveInteger &gt;&gt; bitOr:  <br>bitOr: anInteger <br>    &quot;Primitive. Answer an Integer whose bits are the logical OR of the<br>

    receiver&#39;s bits and those of the argument. Fail if the receiver or argument<br>    is greater than 32 bits. See Object documentation whatIsAPrimitive.&quot;<br>    &lt;primitive: 15&gt;<br>    ^ super bitOr: anInteger<br>

<br>So...clearly, this will fail since both obects are more than 32 bits. So....we will do ^ super bitOr: anInteger<br><br>bitOr: n <br>    &quot;Answer an Integer whose bits are the logical OR of the receiver&#39;s bits  <br>

    and those of the argument, n.&quot;<br>    | norm |<br>    &lt;primitive: &#39;primDigitBitOr&#39; module:&#39;LargeIntegers&#39;&gt;<br>    norm := n normalize.<br>    ^ self<br>        digitLogic: norm<br>        op: #bitOr:<br>

        length: (self digitLength max: norm digitLength)<br><br><br>So...it will call the primDigitBitOr  in the plugin LargeIntegers<br><br>In Interpreter I put an instVar for example to flag if I need to trace or not, and several helpers and primitives methods. The &quot;main&quot; method is:<br>

<br>Interpreter &gt;&gt; traceObjectUsage: rcvr<br>    ((self isIntegerObject: rcvr) not and: [hasToTrace])<br>        ifTrue: [ <br>            self internalTurnOnUsedBit: rcvr.<br>            ]<br><br><br>Now, the problem is, how can I trace that 8888888888888888888 was used???    9999999999999999  is used, because at least one it goes trough the #normalSend <br>

<br>Two options:<br><br>1) In the fail of Interprter &gt;&gt; primitiveBitOr:   I check if the class is LargePositiveInteger, I mark it.  I don&#39;t like this solution because actually I &quot;think&quot; it will be used, but this is just because of the implemetnation on bitOr: in the image. Maybe it changes, I don&#39;t know.<br>

<br>2) Ttry to trace this in the LargeInteger plugin. I would like this idea, but I found several problems:<br><br>2.a)  It is ok that I cannot access/send messages  to Interpreter from plugins?  It seems I am only allowed to do to InterpreterPlugin. But, I don&#39;t want to duplicate all my code from Interpreter to InterpreterProxy.<br>

2.b) So my idea was to do something like this:<br><br>InterpreterProxy &gt;&gt; traceObjectUsage: anObject<br>anObject markAsUsed<br><br></blockquote><div><br>Maybe this is not possible. But even with this:<br><br>traceObjectUsage: rcvr<br>
    &quot;rcvr markAsUsed &quot;<br>    <br><br>I have the bad access :(<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;">And Object &gt;&gt; markAsUsed will just be a primitive that actually calls #traceObjectUsage<br>

<br>Trying to do that, I failed because sqVirtualMachine.h was not generated automatically, thus such struct didn&#39;t understand traceObjectUsage. For that, I added by hand to sqVirtualMachine.h something like this:<br>

<br><br>#if VM_PROXY_MINOR &gt; 8<br>    sqInt  (*traceObjectUsage)(sqInt oop);<br>#endif<br><br>With this it compiles, but when trying to run (actually in the start) the image I get a bad access error.<br><br>2.c) why is not sqVirtualMemory, or let&#39;s say, InterpreterProxy methods not automatically generated with VMMaker?  I am doing something wrong ?<br>

<br>2.d) I saw there are more than one sqVirtualMemory. One in &quot;/platforms/Cross/vm&quot;  and another one in &quot;/platforms/Cross/plugins/IA32ABI/sqVirtualMachine.h&quot;  . After testin a little, it seems in my case it is using the second one. Why we have 2? and why it is using the second one ?<br>

<br><br>Ok, thanks for any help you can give me and sorry for so many (and probably newbie) questions. <br><br>Best regards,<br><font color="#888888"><br>mariano<br><br><br><br>
</font></blockquote></div><br>