Hi Igor,<br><br><div class="gmail_quote">On Tue, Jul 1, 2008 at 6:02 PM, Igor Stasenko &lt;<a href="mailto:siguctua@gmail.com">siguctua@gmail.com</a>&gt; wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div><div></div><div class="Wj3C7c">2008/7/2 Eliot Miranda &lt;<a href="mailto:eliot.miranda@gmail.com">eliot.miranda@gmail.com</a>&gt;:<br>
&gt;<br>
&gt;<br>
&gt; On Tue, Jul 1, 2008 at 5:05 PM, Igor Stasenko &lt;<a href="mailto:siguctua@gmail.com">siguctua@gmail.com</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; 2008/7/2 Eliot Miranda &lt;<a href="mailto:eliot.miranda@gmail.com">eliot.miranda@gmail.com</a>&gt;:<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; This is the &quot;mirrors&quot; approach I alluded to. &nbsp;The right approach is to<br>
&gt;&gt; &gt; implement the debugger with a mirror between it and the system it looks<br>
&gt;&gt; &gt; at.<br>
&gt;&gt; &gt; &nbsp;There is a mirror for local debugging taht is fairly transparent. &nbsp;then<br>
&gt;&gt; &gt; there is a mirror for the renoter system which is much more involved<br>
&gt;&gt; &gt; because<br>
&gt;&gt; &gt; it has to use peek and poke to examine the memory space of the target<br>
&gt;&gt; &gt; process and it has to extract meta information &nbsp; from it (and in the<br>
&gt;&gt; &gt; presence of errors, e.g. the hard crash could have corrupted memory).<br>
&gt;&gt; &gt;<br>
&gt;&gt;<br>
&gt;&gt; I have some ideas about it.<br>
&gt;&gt; First: nobody prevents me to have image containing separate object<br>
&gt;&gt; memories. Its only a question how to load and bootstrap it :)<br>
&gt;&gt;<br>
&gt;&gt; Or, more specific: i think i will introduce the island model (or vats)<br>
&gt;&gt; from the start.<br>
&gt;&gt; So there will be a multiple islands (which can be possibly run in<br>
&gt;&gt; parallel native threads), which don&#39;t share anything, or sharing a<br>
&gt;&gt; protected memory region, writing to which is guarded by a lot of<br>
&gt;&gt; checks and rules :)<br>
&gt;&gt;<br>
&gt;&gt; Since there is nothing outside, which dictates me to have: single<br>
&gt;&gt; heap, single GC, single object memory; it is possible to implement a<br>
&gt;&gt; system, which could have different memory regions governed by<br>
&gt;&gt; different memory managers and garbage collectors.<br>
&gt;<br>
&gt; This assumes that an error in one island can&#39;t corrupt the heap of another<br>
&gt; island, not a safe assumption. &nbsp;You really need to use separate address<br>
&gt; spaces for isolation. &nbsp;If the mirrors are done right the tool side of things<br>
&gt; is the same anyway.<br>
&gt;<br>
<br>
</div></div>Then its coming closer to a point, when without speaking directly with<br>
hardware (without being restricted by OS) is the only reliable option.<br>
It would be much painless if things could operate on zero ring (kernel mode).<br>
But without it.. we have to live in user-mode memory model, provided<br>
by OS. And hence, should heed what OS dictates: use separate process<br>
to debug another process.<br>
<br>
Things are really, can be a lot easier, if it could manage physical<br>
memory itself.. For instance, i feel headache each time when i<br>
thinking how to make Processes cheap. A straightforward approach is to<br>
use separate native thread for each Process instance, and let OS<br>
manage the stack. But this is far from cheap. A single native thread<br>
reserving at least two/three pages of physical memory for stack.<br>
I could make own stack, and use separate stack (not provided by OS by<br>
default), and can make own checks for stack space left. But then in<br>
case when you do foreign calls, things makes the whole idea not so<br>
attractive - foreign functions have no idea how large my stack is, and<br>
can&#39;t check it in same way is my code does.</blockquote><div><br>A foreign call is a perfect time to do a stack switch. &nbsp;One has to marshall arguments from one language to another so it doesn&#39;t add asny overhead to marshall objects one one stack into values passed out on another stack. &nbsp;You pay a little bit extra on the return path where you do have to change stacks, but its not a huge cost (system calls are not that expensive anymore).<br>
<br>If you take this approach (which is taken by the VisualWorks VM for all primitives written in C, everything except a subset of the core language primitives) you can easily manage your own stack. &nbsp;(It is even easy to allocate the small amount of stack you use on the thread&#39;s C stack using alloca. :) )<br>
<br>The native Cog will do this. &nbsp;The StackInterpreter Cog (that today executes 325k bytecodes before hitting incomplete simulation code in BitBltSimulator, sob - I wanted to see some pixels) also does this but only interprets in the stack rather than running natively on it.</div>
</div>