A question about bytecodes

Stephen Dawkins elfarto+hs at elfarto.com
Tue Jan 6 05:00:48 PST 2009


Hi

I've been hacking around on the JVM, attempting to add support for
unsigned integers. I've managed to add several opcodes (based on baload,
bipush, iinc, i2l, saload and sipush) that do zero-extending, rather than
sign-extending.

However, I came across a limit in the JVM. In bytecodes.cpp, there is this
line:

assert(number_of_codes <= 256, "too many bytecodes");

My question is, why is the JVM itself limited to 256 bytecodes? I
understand the class file is limited due to a bytecode being 1 byte long,
but I am confused as to why there is a hard limit like this.

The only place I've seen so far which requires the bytecode to be 1 byte,
is the C++ interpreter which casts the opcode to a jbyte. Are there any
other places that require a bytecode to be 1 byte long?

I was hoping to implement unsigned integers by just adding an 'unsigned'
opcode, followed by the the opcode to modify (baload, etc) then remap the
opcode to a 'virtual' unsigned_baload opcode when loading the class into
the JVM.

Thanks & Regards
Stephen




More information about the hotspot-dev mailing list