<br><br><div class="gmail_quote">On Tue, Oct 9, 2012 at 11:24 AM, Bert Freudenberg <span dir="ltr">&lt;<a href="mailto:bert@freudenbergs.de" target="_blank">bert@freudenbergs.de</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
On 06.10.2012, at 16:13, Chris Cunnington &lt;<a href="mailto:smalltalktelevision@gmail.com">smalltalktelevision@gmail.com</a>&gt; wrote:<br>
<br>
&gt; How are stack languages related to Smalltalk?<br>
<br>
The Squeak VM *is* a stack machine. For passing arguments to a method it uses a stack exclusively (in contrast to most microprocessors, which use registers, and only use the stack for larger function calls). E.g., you can switch a Squeak browser to show byte codes. That demonstrates how the stack is used:<br>

<br>
plus<br>
        ^ 3 + 4<br>
<br>
switch to byte codes:<br>
<br>
21 &lt;20&gt; pushConstant: 3<br>
22 &lt;21&gt; pushConstant: 4<br>
23 &lt;B0&gt; send: +<br>
24 &lt;7C&gt; returnTop<br>
<br>
&gt; And then I realized the StackVM is called a StackVM because it uses a ... STACK.<br>
<br>
No, every Squeak VM (interpreter, Cog, etc) with the current byte code set uses a stack. The Stack VM is so called because it maps the Smalltalk stack to the native C code stack for speed.<br></blockquote><div><br></div>
<div>&lt;pedantry alert&gt;</div><div>Not quite.  The virtual Smalltalk-80 machine is a spaghetti stack, composed of a chain of MethodContext objects, each contaning its own stack for evaluation.  The interpreter operates on these context objects directly, maintaining an activeContext and using its stack for evaluation.  The stack VM maps contexts to a machine stack, so that arguments don&#39;t have to be copied from sender context to new context, and so that context objects do not have to be allocated on every send, both of which are crucial for performance.  But this machine stack is distinct from the C stack, organized as a set of pages of fixed size, so as to make the stack effectively infinite (overflowing onto the heap in the form of contexts).  The interpreter&#39;s implementation (the C functions making up the interpreter), and in Cog, the JIT&#39;s compiler implementation, run on the C stack, but Smalltalk is not executed on the C stack in any of the Squeak VMs.</div>
<div><div>&lt;/pedantry alert&gt;</div></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class="HOEnZb"><font color="#888888"><br>
- Bert -<br>
<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br>best,<div>Eliot</div><br>