Re: Questions about Bytecode

Christopher Diggins <cdiggins@gmail.com>
26 Apr 2007 09:38:09 -0400

          From comp.compilers

Related articles
[6 earlier articles]
Re: Questions about Bytecode ajohnson@mathworks.com (Andy Johnson) (2007-04-23)
Re: Questions about Bytecode DrDiettrich1@aol.com (Hans-Peter Diettrich) (2007-04-23)
Re: Questions about Bytecode haberg@math.su.se (2007-04-23)
Re: Questions about Bytecode chris.dollin@hp.com (Chris Dollin) (2007-04-23)
Re: Questions about Bytecode gah@ugcs.caltech.edu (glen herrmannsfeldt) (2007-04-25)
Re: Questions about Bytecode Peter_Flass@Yahoo.com (Peter Flass) (2007-04-26)
Re: Questions about Bytecode cdiggins@gmail.com (Christopher Diggins) (2007-04-26)
Re: Questions about Bytecode cdiggins@gmail.com (Christopher Diggins) (2007-04-26)
| List of all articles for this month |
From: Christopher Diggins <cdiggins@gmail.com>
Newsgroups: comp.compilers
Date: 26 Apr 2007 09:38:09 -0400
Organization: Compilers Central
References: 07-04-061
Keywords: VM, interpreter
Posted-Date: 26 Apr 2007 09:38:09 EDT

On Apr 18, 10:50 am, "Bison" <Sean.D.Gilles...@gmail.com> wrote:
> Hello everyone. I've been trying to read about VMs for quite some
> time now, and I am still a bit confused about compiling to bytecode.
>
> How would the typical structure of a bytecode-compiled file look? I
> don't think a java *.class file would be a good example here either,
> just because all java files are also classes.


You can use a bytecode disassembler. A few off of the top of my header
are
- ildasm.exe ( http://msdn2.microsoft.com/en-us/library/f7dy01k1(VS.80).aspx
), for the Common Intermediate Language bytecode emitted by .NET
languages
- OCaml byte code disassembler ( http://pauillac.inria.fr/~lebotlan/docaml_html/english/english004.html
)
- Parrot byte code ( http://www.parrotcode.org/docs/parrotbyte.html )


The fact that Java files are all classes shouldn't dissuade you from
looking at the Java bytecode. I strongly recommend reading the Java
bytecode specification
http://java.sun.com/docs/books/jvms/second_edition/html/VMSpecTOC.doc.html


> More specifically, how would I represent literals, like String and
> numbers? The problem I have with this is, how could the VM
> differentiate between instructions and literal data? I've heard
> someone say that I could use a delimiter to mark start and end points.


What differentiates them, is simply what you do with it. If you try to
execute it, it must be code.


> I'm also wondering if things would likely go in a specific order. For
> example, should code and constants be logically seperated?


Not neccessarily, but it does makes everything more manageable.


> Also, I'm wondering if there are any decent readings on the subject
> other than source code. Are there any VMs that would be good examples
> (and that is open source)?


Parrot and LLVM spring to mind. Personally I liked learning about
bytecode using the CIL (a.k.a. MSIL) since the free tool support is
superb on Windows (C# visual studio express and ildasm.exe). There is
even an API in .NET for generating byte-code (
http://msdn2.microsoft.com/en-us/library/system.reflection.emit.ilgenerator.aspx
).


Christopher Diggins
http://www.cdiggins.com


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.