If I were going to modify the VM I'd simply add a bytecode to answer thisProcess. e.g. the thisContext bytecode would become a two-byte bytecode (i is very rare in practice) and the second byte would indicate what special pseudo-variable to answer. What you propose below has the overhead of an anonymous class per process (my closure scheme doesn't use BlockContext at all any more). Fun, but too expensive for my tastes :)<div>
<br><br><div class="gmail_quote">On Thu, Jul 16, 2009 at 6:44 PM, Igor Stasenko <span dir="ltr"><<a href="mailto:siguctua@gmail.com">siguctua@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
2009/7/17 Eliot Miranda <<a href="mailto:eliot.miranda@gmail.com">eliot.miranda@gmail.com</a>>:<br>
<div><div></div><div class="h5">> Hi All,<br>
> does anyone have a neat hack to make Processor activeProcess answer<br>
> what's expected in the context of the debugger? i.e. anyone made the Squeak<br>
> debugger answer the process being debugger when Processor activeProcess is<br>
> stepped over or through, rather than the debugger process, or made the<br>
> debugger run as the process being debugged rather than its own?<br>
<br>
</div></div>Very good question, Eliot!<br>
I always wondered, why to access the active process we use global - Processor.<br>
A running process is closely related to contexts, and therefore it<br>
would be more correct to ask a context about it's process rather than<br>
global:<br>
<br>
thisContext process<br>
instead of<br>
Processor activeProcess.<br>
<br>
I have an idea about this.<br>
Its hacky and will require VM modifications - but having much benefits IMO :)<br>
I think this is most clean & lean way to deal with process-local<br>
storage in smalltalk:<br>
<br>
- add 3 __class instance__ variables to ContextPart:<br>
- methodContextClass<br>
- blockContextClass<br>
- process<br>
<br>
Now, when creating a new process , create a two anonymous subclasses<br>
of MethodContext and BlockContext,<br>
and fill these ivars in each one appropriately.<br>
<br>
Then, all contexts which allocated for given process should use these<br>
anonymous subclasses as their classes.<br>
For VM this means, that when it allocating new context, it should copy<br>
the class reference from caller context (or read a<br>
methodContextClass or blockContextClass ivars in caller context<br>
class object).<br>
<br>
And then accessing a process ( or process-local storage) is trivial & quick:<br>
<br>
ContextPart>>process<br>
^ self class process<br>
<br>
<br>
> TIA<br>
> Eliot<br>
><br>
><br>
><br>
<font color="#888888"><br>
<br>
<br>
--<br>
Best regards,<br>
Igor Stasenko AKA sig.<br>
<br>
</font></blockquote></div><br></div>