<div>On Thu, Aug 30, 2018 at 09:22 Ben Coman <<a href="mailto:btc@openinworld.com">btc@openinworld.com</a>> wrote:<br></div><div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> <div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Wed, 29 Aug 2018 at 11:08, Eliot Miranda <<a href="mailto:eliot.miranda@gmail.com" target="_blank">eliot.miranda@gmail.com</a>> wrote:</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div><br></div></div></div></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div>The Slang translator and the interpreter code collaborate to inline much of the interpreter, including every method beginning with internal, into the interpret routine in which localFP localSP and localIP are declared, hence allowing a C compiler to assign these variables to registers.  </div></div></div></blockquote><div><br></div><div>Ahhh. Maybe I finally get what "internal" means. </div></div></div></div></div></div></div></div></div></div></blockquote><div dir="auto"><br></div><div dir="auto">Dan Ingalls described the secret recipe to achieve high performance in a dynamic language as the Art of Cheating Without Getting Caught.</div><div dir="auto"><br></div><div dir="auto">That's what the "internal" vs "external" is about. To external code, everything looks like expected - e.g.  when you inspect a context object, its stack has all the temp objects and it's instruction pointer is right past the last bytecode it executed, just like the Blue Book describes.</div><div dir="auto"><br></div><div dir="auto">But in order to get higher performance, even the plain interpreter cheats, the stack interpreter a lot more, and Cog / Spur does unmentionable things.</div><div dir="auto"><br></div><div dir="auto">To avoid getting caught (by the image or by primitives that are blissfully unaware of the amount of cheating going on) the internal state gets externalized at strategic points to preserve the illusion of order. Nothing to see here, move on.</div><div dir="auto"><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div class="gmail_quote"><div>That sounds like each Context has its own instructionPointer, but I didn't think that was so </div></div></div></div></div></div></div></div></div></div></blockquote><div dir="auto"><br></div><div dir="auto">That's exactly what happens. The VM has an active context, and each context has an instruction pointer for the next bytecode, as well as a stack pointer into its own little stack  for values (not for return addresses). Each send creates a new context object which </div><div dir="auto">is linked to its sender via the "sender" inst var.  This linked list is the equivalent of a call stack in other languages. </div><div dir="auto"><br></div><div dir="auto">And the cool thing is you can inspect all of that in the image. The even cooler thing is that you can manipulate the context objects, like switching out the sender to a completely different context (that's how co-routines work in e.g. a Squeak Generator). The coolest thing is that ever since the StackVM, there is something completely different going on behind the scenes that's much more performant, while still maintaining all the features.</div><div dir="auto"><br></div><div dir="auto">HTH</div><div dir="auto"><br></div><div dir="auto">- Bert -</div></div></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr">-- </div><div dir="ltr">Dr. Bert Freudenberg</div><div dir="ltr">7275 Franklin Avenue #210</div><div dir="ltr">Los Angeles CA 90046</div><div dir="ltr"><span style="letter-spacing:0.2px">+1 (818) 482-3991</span><br></div><div dir="ltr"> </div></div></div></div></div></div>