harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mloe...@apache.org
Subject svn commit: r598952 - in /harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/java5: context_5.cpp context_5.h
Date Wed, 28 Nov 2007 10:52:20 GMT
Author: mloenko
Date: Wed Nov 28 02:52:18 2007
New Revision: 598952

URL: http://svn.apache.org/viewvc?rev=598952&view=rev
Log:
fixed VTS regression

Modified:
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/java5/context_5.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/java5/context_5.h

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/java5/context_5.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/java5/context_5.cpp?rev=598952&r1=598951&r2=598952&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/java5/context_5.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/java5/context_5.cpp Wed Nov 28
02:52:18 2007
@@ -44,7 +44,7 @@
     If it comes to a goto then it continues from the jump target
     */
 
-    vf_Result vf_Context_5::parse(Address instr) {
+    vf_Result vf_Context_5::parse(Address instr, int dead_code_parsing, FastStack<Address>*
deadstack) {
         // instruction is out of the method or in the middle of another instruction
         if( instr > m_code_length || props.isOperand(instr) ) {
             return error(VF_ErrorCodeEnd, "jump to the middle of instruction or out of the
method");
@@ -53,7 +53,9 @@
         while( instr < m_code_length ) {
             if( props.isParsePassed(instr) ) {
                 // more than one branch leads to this instruction
-                props.setMultiway(instr);
+                if( !dead_code_parsing ) {
+                    props.setMultiway(instr);
+                }
                 return VF_OK;
             }
 
@@ -115,6 +117,8 @@
                 mark_stackmap_point(target);
 
                 if( instr_direct(pi, opcode, m_bytecode, instr) ) {
+                    if( instr + instr_len < m_code_length ) deadstack->push(instr +
instr_len);
+
                     instr = target; // it is not an if* - go to jump target
                 } else {
                     // process conditional jump target or jsr
@@ -125,6 +129,7 @@
                 }
             } else if( instr_direct(pi, opcode, m_bytecode, instr) ) {
                 // it is not a jump ==> it is return or throw or ret
+                if( instr + instr_len < m_code_length ) deadstack->push(instr + instr_len);
                 return VF_OK;
             } else {
                 assert( instr_is_switch(pi) );
@@ -155,6 +160,7 @@
                     mark_stackmap_point(target);
                 }
 
+                if( instr + instr_len < m_code_length ) deadstack->push(instr + instr_len);
                 return VF_OK;
             }
         }
@@ -429,9 +435,10 @@
             }
         }
 
+        FastStack<Address> deadstack;
         do {
             while( !stack.is_empty() ) {
-                vf_Result tcr = parse(stack.pop());
+                vf_Result tcr = parse(stack.pop(), false, &deadstack);
                 if( tcr != VF_OK ) {
                     return tcr;
                 }
@@ -459,6 +466,31 @@
                 }
             }
         } while (!stack.is_empty());
+
+        //parsing dead code: check that no invalid opcodes are there and no jumps to the
middles of the instructions
+        //clean up the dead stack, (new pushs will go to the regular stack)
+        while( !deadstack.is_empty() ) {
+            vf_Result tcr = parse(deadstack.pop(), true, &stack);
+            if( tcr != VF_OK ) {
+                return tcr;
+            }
+        }
+
+        //put all handlers, even for the dead try blocks
+        for( idx = 0; idx < m_handlecount; idx++ ) {
+            method_get_exc_handler_info( m_method, idx, &start_pc, &end_pc, &handler_pc,
&handler_cp_index );
+            stack.push(handler_pc);
+        }
+
+        //clean up the stack, (check jumps to the middle)
+        while( !stack.is_empty() ) {
+            vf_Result tcr = parse(stack.pop(), true, &stack);
+            if( tcr != VF_OK ) {
+                return tcr;
+            }
+        }
+        //end of dead code parsing
+
 
         for( idx = 0; idx < m_handlecount; idx++ ) {
 

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/java5/context_5.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/java5/context_5.h?rev=598952&r1=598951&r2=598952&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/java5/context_5.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/java5/context_5.h Wed Nov 28
02:52:18 2007
@@ -124,7 +124,7 @@
 
         //First verification pass thru the method. checks that no jump outside the method
or to the middle of instruction
         //checks that opcodes are valid
-        vf_Result parse(Address instr);
+        vf_Result parse(Address instr, int dead_code_parsing, FastStack<Address> *deadstack);
 
         //Second pass: dataflow of a piece of the method starting from the beginning or a
branch target and finishing
         //on return, athrow or hitting previously passed instruction. 



Mime
View raw message