<br><br><div class="gmail_quote">On Tue, Oct 5, 2010 at 9:04 PM, Eliot Miranda <span dir="ltr"><<a href="mailto:eliot.miranda@gmail.com">eliot.miranda@gmail.com</a>></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;">
<br><br><br><div class="gmail_quote">On Tue, Oct 5, 2010 at 12:00 PM, Mariano Martinez Peck <span dir="ltr"><<a href="mailto:marianopeck@gmail.com" target="_blank">marianopeck@gmail.com</a>></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;">
<br><br><br><div class="gmail_quote">On Tue, Oct 5, 2010 at 8:48 PM, Eliot Miranda <span dir="ltr"><<a href="mailto:eliot.miranda@gmail.com" target="_blank">eliot.miranda@gmail.com</a>></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;">
<br><br><br><div class="gmail_quote">On Tue, Oct 5, 2010 at 11:20 AM, Mariano Martinez Peck <span dir="ltr"><<a href="mailto:marianopeck@gmail.com" target="_blank">marianopeck@gmail.com</a>></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;">
<br><br><br><div class="gmail_quote">On Tue, Oct 5, 2010 at 7:50 PM, Eliot Miranda <span dir="ltr"><<a href="mailto:eliot.miranda@gmail.com" target="_blank">eliot.miranda@gmail.com</a>></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;">
<br><br><br><div class="gmail_quote">On Tue, Oct 5, 2010 at 9:23 AM, Mariano Martinez Peck <span dir="ltr"><<a href="mailto:marianopeck@gmail.com" target="_blank">marianopeck@gmail.com</a>></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;">
<br>Hi. So....if I want to intercept ALL message sends....going to #normalSend is not enough since I have #class, #==, Float>>#+ etc that are executed directly like bytecodes. So...my questions are now:<br><br>1) Those special selectors are those that are in "Smalltalk specialSelectors" ? are there more? all from there are special?<br>
<br>2) All those "Smalltalk specialSelectors" have their associated bytecode primitive in Interpreter?? If true, then I should modify all bytecodePrim* in Interpreter. I am right? If I do that, that's all ? I am intercepting everything?<br>
</blockquote><div><br></div><div>Right. Just modify all of them to eliminate the optimized code and to revert to normalSend. </div></div></blockquote><div><br>Thanks Eliot. I didn't understand. What is the optimized code? I checked all bytecodePrim* and the ones that DO NOT send "self normalSend" at the end, are very few. The problem is that some return before returning "self normalSend". So...I should modify all those who DO NOT call "self normalSend" at the end and those which return before. <br>
</div></div></blockquote><div><br></div><div>Change them all so they do a normalSend and nothing else, e.g.</div><div><br></div><div>bytecodePrimAdd</div><div><span style="white-space: pre-wrap;">        </span>messageSelector := self specialSelector: 0.</div>
<div><span style="white-space: pre-wrap;">        </span>argumentCount := 1.</div><div><span style="white-space: pre-wrap;">        </span>self normalSend</div><div><br></div></div></blockquote><div><br>Ok, but suppose I DON'T want to slow down the system.... what if I change to this for example<br>
<br>bytecodePrimAdd<br> | rcvr arg result |<br> rcvr := self internalStackValue: 1.<br> arg := self internalStackValue: 0.<br> (self areIntegers: rcvr and: arg)<br> ifTrue: [result := (self integerValueOf: rcvr) + (self integerValueOf: arg).<br>
(self isIntegerValue: result) ifTrue:<br> [self internalPop: 2 thenPush: (self integerObjectOf: result).<br> <span style="background-color: rgb(255, 0, 0);">self markObjectUsage: rcvr.</span><br>
^ self fetchNextBytecode "success"]]<br> ifFalse: [successFlag := true.<br> self externalizeIPandSP.<br> self primitiveFloatAdd: rcvr toArg: arg.<br> self internalizeIPandSP.<br>
successFlag ifTrue: [<span style="background-color: rgb(255, 0, 0);">self markObjectUsage:
rcvr.</span> ^ self fetchNextBytecode "success"]].<br><br> messageSelector := self specialSelector: 0.<br> argumentCount := 1.<br> self normalSend<br><br>Ok...I have to manually check each method, but I don't have problem.<br>
<br>Should that work and be almost as fast as normally?<br></div></div></blockquote><div><br></div><div>But it doesn't mark the method right?</div></div></blockquote><div><br><br>hehe you guessed my following question (it was going to be in another thread, but since you ask).<br>
Yes, (maybe) I would like to mark, for EACH normal message sent:<br>1) the obejct that receives the message<br>2) its class<br>3) the method dictionary<br>4) the compiled method.<br><br>If I first think about normal messages, then:<br>
<br>- 1) and 2) can be done in #normalSend:<br><br>normalSend<br> "Send a message, starting lookup with the receiver's class."<br> "Assume: messageSelector and argumentCount have been set, and that <br>
the receiver and arguments have been pushed onto the stack,"<br> "Note: This method is inlined into the interpreter dispatch loop."<br> | rcvr |<br> self inline: true.<br> self sharedCodeNamed: 'normalSend' inCase: 131.<br>
rcvr := self internalStackValue: argumentCount.<br> self traceObjectUsage: rcvr.<br> lkupClass := self fetchClassOf: rcvr.<br> receiverClass := lkupClass.<br> self traceObjectUsage: receiverClass.<br> self commonSend.<br>
<br> <br><br><br>3) I have no idea.<br><br>4) I am not sure. I wanted to ask you :) Maybe #internalActivateNewMethod is a good place? Maybe adding a "self markObjectUsage: newMethod" ?<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="gmail_quote"><div> It only marks the objects. However if you analyse the bytecodePrimFoo implementations you should be able to work out which methods are used, SmallInteger>>#+, Float>>#+ et al.</div>
<div><br></div></div></blockquote><div><br>I didn't understand this last sentence. <br><br>Thanks Eliot!!<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="gmail_quote"><div></div><div> </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"><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>Or change the part of the bytecode table that specifies the special selector primitives to read</div>
<div><div><span style="white-space: pre-wrap;">                </span>(176 207 sendSpecialSelectorBytecode)</div><div><br></div><div><div>sendSpecialSelectorBytecode</div><div><span style="white-space: pre-wrap;">        </span>| selectorIndex specialSelectors |</div>
<div><span style="white-space: pre-wrap;">        </span>selectorIndex := (currentBytecode - 176) * 2.</div><div><span style="white-space: pre-wrap;">        </span>specialSelectors := self splObj: SpecialSelectors.</div>
<div><span style="white-space: pre-wrap;">        </span>messageSelector := self fetchPointer: selectorIndex</div><div><span style="white-space: pre-wrap;">                                                        </span>ofObject: specialSelectors.</div>
<div><span style="white-space: pre-wrap;">        </span>argumentCount := self fetchInteger: selectorIndex + 1</div><div><span style="white-space: pre-wrap;">                                                        </span>ofObject: specialSelectors.</div>
<div><span style="white-space: pre-wrap;">        </span>self normalSend</div></div><div><br></div><div>But most of all try and slow down and understand what is going on; then you will be able to answer your own questions. Reading the <a href="http://www.mirandabanda.org/bluebook/bluebook_imp_toc.html" target="_blank">blue book</a> will help.</div>
</div><div> </div></div></blockquote><div><br>hehehehehe what an idea :) I didn't know I could do that. Thanks for the blue book. I read the vm chapters but several months ago. I should read it again since the first time I didn't understand very much hehehehe. <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"><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>
<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>Providing you also look at the perform and method evaluation primitives I think you'll get all sends. </div>
<div><br></div></div></blockquote><div><br>#primitivePerform* and #primitiveExecuteMethod* ???<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_quote"><div></div><div>There is another way. Modify the Smalltalk compiler to to use the special selector sends.</div><div><br></div></div></blockquote><div><br>Thanks Eliot for the idea. Can you explain me a little more (sorry, newbie here!). You mean that with the Compiler I can do that all method sends use the normal send instead of special bytecodes or primitives?<br>
</div></div></blockquote><div><br></div><div>Yes. If you modify the compiler not to use the StdSelectors then the compiler will emit normal sends for all the special selectors. Again I think if you slowed down and started playing ore you would discover this for yourself and in the end be more productive. I know its hard and frustrating initially. But my own competence comes directly from having played around in this way.</div>
<div><br></div></div></blockquote><div><br>Thanks Eliot. I will consider this alternative also.<br><br>Best regards.<br><br>Mariano<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>best,</div><div>Eliot</div><div><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>
<br>Thank you very much.<br><br>Mariano<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><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<br>Thanks a lot in advance,<br><br>Mariano<br><br><br><br><div class="gmail_quote">On Sun, Oct 3, 2010 at 11:09 PM, Craig Latta <span dir="ltr"><<a href="mailto:craig@netjam.org" target="_blank">craig@netjam.org</a>></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;"><br>
<br>
> Craig Latta has done all this work, talk to him.<br>
<br>
Sure, I'd be happy to discuss it.<br>
<br>
<br>
-C<br>
<font color="#888888"><br>
--<br>
Craig Latta<br>
<a href="http://www.netjam.org" target="_blank">www.netjam.org</a><br>
+ 31 020 894 6247<br>
+ 1 415 287 3547<br>
<br>
<br>
<br>
</font></blockquote></div><br>
<br></blockquote></div><br>
<br></blockquote></div><br>
<br></blockquote></div><br>
<br></blockquote></div><br>
<br></blockquote></div><br>
<br></blockquote></div><br>