Newsgroups: comp.lang.smalltalk
Path: cantaloupe.srv.cs.cmu.edu!nntp.club.cc.cmu.edu!goldenapple.srv.cs.cmu.edu!das-news2.harvard.edu!cam-news-feed3.bbnplanet.com!cam-news-hub1.bbnplanet.com!cpk-news-hub1.bbnplanet.com!news.bbnplanet.com!rill.news.pipex.net!pipex!blackbush.xlink.net!ins.net!heeg.de!uucp
From: Hans-Martin Mosner <hmm@heeg.de>
Subject: Re: `loop head' and `dup' bytecodes in VW --- help!
Content-Type: text/plain; charset=us-ascii
Message-ID: <3337A474.220A@heeg.de>
Sender: uucp@heeg.de
Content-Transfer-Encoding: 7bit
Organization: Georg Heeg Objektorientierte Systeme
References: <ye67yhfxz6.fsf@gaia.i-have-a-misconfigured-system-so-shoot-me>
Mime-Version: 1.0
Date: Tue, 25 Mar 1997 10:09:56 GMT
X-Mailer: Mozilla 2.01I [de] (WinNT; I)
Lines: 25

Marek Majkut wrote:
> 
> As I understand, the `loop head' bytecode makes some adjustment of the stack
> pointer when a loop is reapeated, is that right?
> 
> `dup first' seems to save the offset to the top of the stack which is used
> in the subsequent `dup' bytecodes to copy the stack slot pointed to by this
> offset. `dup last' resets the stack pointer to the original value, is that
> correct?
> 
> Thanks, Marek Majkut

These bytecodes were introduced in the ParcPlace VM so that the native code generator could be 
simplified when they went from Smalltalk-80 version 2.3 to 2.4.

The loop head bytecode simply tells the code generator that this is the destination of a backward 
branch. The address mapping between n-code and v-code is made much simpler by that. If you look at 
the #loopHead method in class Context, you see that it is implemented as a no-op.

Your observation with respect to the dup bytecodes is right, as far as I know. You can see them in 
action in the Context methods, too. The original 2.3 bytecode set was a little different, it used 
only dup and pop to support the cascade mechanism. I think that the different bytecodes are also 
used to tell the code generator a little bit more about the intended semantics.

Hans-Martin
