|Questions about Bytecode Sean.D.Gillespie@gmail.com (Bison) (2007-04-18)|
|Re: Questions about Bytecode firstname.lastname@example.org (Eric) (2007-04-19)|
|Re: Questions about Bytecode DrDiettrich1@aol.com (Hans-Peter Diettrich) (2007-04-19)|
|Re: Questions about Bytecode cfc@shell01.TheWorld.com (Chris F Clark) (2007-04-19)|
|Re: Questions about Bytecode Sean.D.Gillespie@gmail.com (Bison) (2007-04-20)|
|Re: Questions about Bytecode email@example.com (2007-04-23)|
|Re: Questions about Bytecode firstname.lastname@example.org (Andy Johnson) (2007-04-23)|
|[7 later articles]|
|Date:||18 Apr 2007 13:50:27 -0400|
|Posted-Date:||18 Apr 2007 13:50:27 EDT|
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.
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.
I'm also wondering if things would likely go in a specific order. For
example, should code and constants be logically seperated?
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)?
Thanks in advance for any information you may have.
[You can do it any way you want. Some bytecodes put constants in a
literal pool, some put them inline. If you have a lot of strings, and
in particular if the same string or prefixes or suffixes show up
repeatedly, you can often save a lot of space by combining them in a
constant pool rather than repeating them in line. For numbers, it's
not such a big deal. Your interpreter might be a little simpler if
you can use the same addressing for constants and variables so you can
use the same load operator for either. Or, depending on the design of
your interpreter, that might not be a big deal either. If your bytecode
is intended to be translated into machine code before running, then you'll
probably need a constant pool since large in-line constants tend to be
ugly in machine code. -John]
Return to the
Search the comp.compilers archives again.