>I am looking for ways to support the existing byte code range but also
>add new ones in the new VM. How do I go about adding new byte codes?.
You look at all code that looks for op codes. You will find it in the
byte code verifier, in the inner interpreter, and probably other
places. Then you do monkey see, monkey do.
Try searching for a strings matching the names of byte codes.

Signature
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
>I am looking for ways to support the existing byte code range but also
>add new ones in the new VM. How do I go about adding new byte codes?.
You might take a week to learn forth and how a forth interpreter
works. This will serve you in good stead. Just stick with a 16 bit
version and figure out how the inner loop works to execute a string of
tokens.

Signature
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
> Hi,
> I am writing a new Java VM (using the kaffe VM as the basis) for a
[quoted text clipped - 9 lines]
> Thanks,
> RK
To extend the bytecodes, you probably want to disable the JIT first. You
can usually do that with a command line option then it means you only
need add handling for additional bytecodes in the interpreter. You will also
need to initially turn off the verifier as it will reject unrecognized
bytecodes.
I'm not knowledgable of the internal specifics of Kaffe, but I would check
the interpreter to see if they use any additional bytecodes internally after
class loading and verification (sometimes VMs do special things with
invokes, get/put/field/static, or others).
As for standard VM bytecodes, you have available bytecodes 203-255
IIRC. (also 186? which is unused). Depending on how many instructions
you wish to add, you can either map them as single bytes each or use
"escape" prefixes to extend the instruction set as they were considering
with the impdep1/impdep2 bytecodes (254/255) in the JVM spec,
similar to the way the "wide" prefix is used. You also need to consider
what, if any parameters, the bytecodes will have e.g. constant pool
indices, local variable indices, constants, (I/O addresses?), or other.
Mark...
Ramakrishna Saripalli - 28 Jul 2004 19:25 GMT
Mark,
Thanks for the response. Let me indicate clearly what it is I am trying to
do. My target environment is a very custom environment ( almost bordering on
embedded ) with a IA-32 / AMD64 execution environment. I need to extend the
bytecode so that memory allocation can be done not just from the heap but
also from specific areas that may map to either on board device address
ranges or off-board device ranges.
My first instinct was to define an equivalent to "new" but I ruled it out .
SO now in my environment, when java byte code runs, they are handed
references to a specific environment Interface in which they can call
methods to allocate memory ranges. They get arrays of bytes but they can use
it in DataInputStream/DataOutputStream to read / write longs, ints, shorts
whatever. This will be noncached or cached depending on the memory ranges
but the Java code need not know about it( or at least knows about it but
ignores it ).
So I am thinking I need to make the VM more intelligent if I want the user
code to be the same without learning new programming paradigms. What do you
think?.
RK
> > Hi,
> > I am writing a new Java VM (using the kaffe VM as the basis) for a
[quoted text clipped - 31 lines]
>
> Mark...
Roedy Green - 28 Jul 2004 20:11 GMT
>So I am thinking I need to make the VM more intelligent if I want the user
>code to be the same without learning new programming paradigms. What do you
>think?.
for that sort of API, there is no need for new byte codes. a JNI
method would suffice.

Signature
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
Mark Bottomley - 29 Jul 2004 00:14 GMT
> Mark,
> Thanks for the response. Let me indicate clearly what it is I am trying to
[quoted text clipped - 56 lines]
> >
> > Mark...
I agree with Roedy's response. You should be looking at writing JNI
calls and not messing inside the VM. That will mean memory is available
with the usual lack of safety nets from any ordinary C methods. JNI is not
trivial to do correctly, but I think that Sun has many public examples and
there are several good books on the topic. Are you running the VM on
Windows, Linux, or some other executive? Also, if you are playing with
memory directly, that is outside of Java's normal scope. In Java, all memory
is controlled by the VM and freed by the Garbage Collector. What you are
trying to do is reminiscent of the Java Real Time Specification, although
I'm not sure of the state of that (abandoned, pending, other). It's prime
motivations seemed to be providing direct memory manipulation because
at the time, many GC's would stop the world making the systems not
real time.
The Kaffe pages contain a native methods FAQ and a static natives FAQ.
Mark...