bytecodes (was: 4.1.2 compatibility with 4.0)

Jecel Assumpcao Jr jecel at merlintec.com
Tue Oct 31 18:48:18 UTC 2000


On Tue, 31 Oct 2000, Marko Mikulicic wrote:

> What are the additional bytecodes?
> Can you briefly describe them, so I don't download the sources (I have a
> slow connection) ?

If you have a running Self 4.1.2 system, just call up the
"bytecodeFormat" object and look around.

The opcode is now 4 bits (instead of 3) and the index field is also 4
(instead of 5):

    0  index - extend the index field of the next bytecode
    1  literal - push the literal onto the top of stack (tos)
    2  send - send the message with the literal as selector and tos as
                     receiver
    3  implicitSelfSend - send the message to self with the literal as
                     selector
    4  extended - see below
    5  readLocal - access local slot
    6  writeLocal - change value of local slot
    7  lexicalLevel - change what "local" means for previous
                            instructions
    8  branchAlways - jump to indicated bytecode (literal must be
                                  smallInt)
     9  branchIfTrue - only jump if tos == true
   10 branchIfFalse - only jump if tos == false
   11 branchIndexed - tos is an index into a "branch vector"
   12 delegatee - changes the next "send" into a directed resend
   13 undefined
   14 undefined
   15 undefined

If the opcode is "extended", then the index field is the real opcode:

     0  pushSelf - puts the current receiver on the tos
     1  pop - eliminates the tos
     2  nonLocalReturn - returns from this block's "home context"
     3  undirectedResend - like "super" in Smalltalk
     4  undefined
         ....
    15 undefined

I had to look at the VM sources, interpreter.c in particular, to figure
out the meaning of the bytecodes.

> Are they used by normal self code or are provided for
> easier Java/Smalltalk emulation?

You can send 'disassemble' to a method mirror to have a nice view of
its bytecodes. That showed me that the parser uses most of these
bytecodes. I didn't look too deeply, but the branch bytecodes don't
seem to be used. Looking at the '_PrimitiveList' it isn't clear if the
interpreter is used or not (I didn't see anything to enable/disable it
like the other compilers).

For those who missed it, I had made a proposal which used only 4
bytecodes (0 = push literal, 1 = send, 2 = selfSend, 3 =
nonLocalReturn) and used primitives for resends.

-- Jecel



More information about the Self-interest mailing list