Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Virtual Machine / July 2004

Tip: Looking for answers? Try searching our database.

How to extend Java bytecode list?.

Thread view: 
Ramakrishna Saripalli - 28 Jul 2004 00:15 GMT
Hi,
 I am writing a new Java VM (using the kaffe VM as the basis) for a
very specific purpose. This is for a research purpose. This VM will
need to work with existing Java classes so the VM will support all
existing Java byte code. In the target environment (which is an
embedded environment), I do not need support for swing so the VM will
not need to support swing.

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?.

Thanks,
RK
Roedy Green - 28 Jul 2004 01:37 GMT
>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.

Roedy Green - 28 Jul 2004 01:38 GMT
>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.

Mark Bottomley - 28 Jul 2004 04:08 GMT
> 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...


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.