Byte Code

SmalltalkLanguage ByteCodes (From the BlueBook):

[source methods] are translated by a compiler into sequences of 8-bit instructions called bytecodes. The compiler and bytecodes are the subject of this chapter's first section. The bytecodes produced by the compiler are instructions for an interpreter, which is described in the second section.

The center message is used to find the Point equidistant from a Rectangle's four sides.

center
^origin + corner/2

Source methods are translated by the system's compiler into sequences of instructions for a stack-oriented interpreter. The instructions are eight-bit numbers called bytecodes. For example, the bytecodes corresponding to the source method above are,

0, 1, 176, 119, 185, 124

The compiler creates an instance of CompiledMethod to hold the bytecode translation of a source method. In addition to the bytecodes themselves, a CompiledMethod contains a set of objects called its literal frame. The literal frame contains any objects that could not be referred to directly by bytecodes.

The interpreter understands 256 bytecode instructions that fall into five categories: pushes, stores, sends, returns, and jumps.

Please note that these are not necessarily in files, they do not contain an executable program (instead, they are embedded in objects that are interpreted by the VirtualMachine), they are fixed in size (well, they are 8 or 16 bits in length), and they are usually compiled (on the fly) into machine code for the target platform.

In particular, the purity of the Smalltalk environment (together with its metastructure) allows an implementation of the SmalltalkVirtualMachine to do cross-bytecode optimization during the compilation (to machine code) process.


The following link does not accurately describe Smalltalk bytecodes. I don't know enough about other VirtualMachines to comment on its accuracy for them.

See http://foldoc.doc.ic.ac.uk/foldoc/foldoc.cgi?query=byte+code&action=Search
CategoryLanguage

EditText of this page (last edited January 15, 2005) or FindPage with title or text search