some questions about interpreter

lianshun Liu lsliu0507 at gmail.com
Mon Apr 20 10:58:09 PDT 2009


Hi,

I build latested hotspot(b55) with the C++-Interpreter successfully on Win32, and java.exe can work correctly. But if I change the source code of the interpreter, locates at hotspot\src\share\vm\interpreter\bytecodeInterpreter.cpp, something will be wrong.
BytecodeInterpreter::run()
{
   //¡­¡­
     switch (opcode)
     {
       //¡­¡­ 
       CASE(_bipush):                    
        //  SET_STACK_INT((jbyte)(pc[1]), 0);   
           SET_STACK_INT((jint)(100), 0);
          UPDATE_PC_AND_TOS_AND_CONTINUE(2, 1);
       //¡­¡­
     }
  //¡­¡­
}
SET_STACK_INT((jbyte)(pc[1]), 0) is a macro that puts pc[1] (operand of bipush) onto the stack, it doesn't do anything else. So I thought I could change SET_STACK_INT((jbyte)(pc[1]), 0) into SET_STACK_INT((jint)(100), 0), which will always put 100 onto the stack if the opcode is bipush. But to my surprise, after this change, though hotspot can be build successfully, java.exe can't be launch, following error occured:

E:\openjdk\build\windows-i586\bin>java -version
Error occurred during initialization of VM
java.lang.ExceptionInInitializerError
        at java.lang.System.initializeSystemClass(System.java:1107)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 100
        at java.util.Properties.<clinit>(Properties.java:1109)
        at java.lang.System.initializeSystemClass(System.java:1107)

So my first question is that why the change result in such an error? Can't the source of interpreter be changed?
My second question is also a little odd. This time I do not change the macro, I only embed some code that print some message after CASE(_bipush), still hotspot can build successfully. But when I start java -version on command line, an error arise, as the attachment shows. What surprises me is that though java.exe is failed, BytecodeInterpreter::run() is still executed, and printed message for more than 500 times, means code snippet CASE(_bipush)... will execute for 500+ times. Why?  

Thanks.
Lianshun Liu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/hotspot-runtime-dev/attachments/20090421/08c83a7c/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: javaError.jpg
Type: image/jpeg
Size: 24434 bytes
Desc: not available
Url : http://mail.openjdk.java.net/pipermail/hotspot-runtime-dev/attachments/20090421/08c83a7c/attachment.jpg 


More information about the hotspot-runtime-dev mailing list