harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mloe...@apache.org
Subject svn commit: r595765 - in /harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/java5: context_5.cpp context_5.h instr_props_5.h
Date Fri, 16 Nov 2007 18:15:05 GMT
Author: mloenko
Date: Fri Nov 16 10:15:03 2007
New Revision: 595765

URL: http://svn.apache.org/viewvc?rev=595765&view=rev
Log:
do not parse knownly dead code

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
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/java5/instr_props_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=595765&r1=595764&r2=595765&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 Fri Nov 16
10:15:03 2007
@@ -53,9 +53,7 @@
         while( instr < m_code_length ) {
             if( props.isParsePassed(instr) ) {
                 // more than one branch leads to this instruction
-                if( !dead_code_parsing ) {
-                    props.setMultiway(instr);
-                }
+                props.setMultiway(instr);
                 return VF_OK;
             }
 
@@ -117,11 +115,6 @@
                 mark_stackmap_point(target);
 
                 if( instr_direct(pi, opcode, m_bytecode, instr) ) {
-                    //TODO: though the spec does not require to check the dead code for correctness
-                    //RI seems to check it and some Harmony negative tests have broken dead
code
-
-                    dead_code_stack.push(instr+instr_len);
-
                     instr = target; // it is not an if* - go to jump target
                 } else {
                     // process conditional jump target or jsr
@@ -131,8 +124,6 @@
                     instr += instr_len;
                 }
             } else if( instr_direct(pi, opcode, m_bytecode, instr) ) {
-                dead_code_stack.push(instr+instr_len);
-
                 // it is not a jump ==> it is return or throw or ret
                 return VF_OK;
             } else {
@@ -428,20 +419,16 @@
         unsigned short handler_pc;
         unsigned short handler_cp_index;
 
+        //check validness of try blocks
+        //TODO: is verifier the right place for that?
         for( idx = 0; idx < m_handlecount; idx++ ) {
-            method_get_exc_handler_info( m_method, idx, &start_pc, &end_pc,
-                &handler_pc, &handler_cp_index );
+            method_get_exc_handler_info( m_method, idx, &start_pc, &end_pc, &handler_pc,
&handler_cp_index );
 
             if( start_pc >= end_pc || end_pc > m_code_length ) {
                 return error(VF_ErrorHandler, "start_pc >= end_pc OR end_pc > code_length");
             }
-            stack.push(handler_pc);
         }
 
-        //we have different slightly rules for processing dead and live code
-        //e.g. it's not a problem if dead code runs out of the method
-        //but we still have to verify it for corrupted instructions to follow RI
-        dead_code_parsing = 0;
         do {
             while( !stack.is_empty() ) {
                 vf_Result tcr = parse(stack.pop());
@@ -450,23 +437,32 @@
                 }
             }
 
-            dead_code_parsing = 1;
+            for( idx = 0; idx < m_handlecount; idx++ ) {
+                method_get_exc_handler_info( m_method, idx, &start_pc, &end_pc, &handler_pc,
&handler_cp_index );
 
-            while( !dead_code_stack.is_empty() ) {
-                vf_Result tcr = parse(dead_code_stack.pop());
-                if( tcr != VF_OK ) {
-                    return tcr;
+                if( props.isParsePassed(handler_pc)) {
+                    props.setMultiway(handler_pc);
+                    continue;
                 }
-            }
-        } while (!stack.is_empty());
 
-        touch_remaining_dead_code();
+                if( props.isOperand(handler_pc) ) {
+                    return error(VF_ErrorCodeEnd, "handler_pc at the middle of an instruction");
+                }
 
+                for( Address i = start_pc + 1; i < end_pc; i++ ) {
+                    //check if there was a reachable code in try block
+                    if( props.isParsePassed(i) ) {
+                        //push handler if there was
+                        stack.push(handler_pc);
+                        break;
+                    }
+                }
+            }
+        } while (!stack.is_empty());
 
         for( idx = 0; idx < m_handlecount; idx++ ) {
 
-            method_get_exc_handler_info( m_method, idx, &start_pc, &end_pc,
-                &handler_pc, &handler_cp_index );
+            method_get_exc_handler_info( m_method, idx, &start_pc, &end_pc, &handler_pc,
&handler_cp_index );
 
             if( end_pc < m_code_length && props.isOperand(end_pc) || props.isOperand(start_pc)
) {
                 return error(VF_ErrorCodeEnd, "start_pc or end_pc are at the middle of an
instruction");
@@ -489,6 +485,7 @@
 
         //////////////////////////// SECOND PASS /////////////////////////
         pass = 2;
+        props.pass2started(stackmapattr_calculation, m_code_length);
 
         stack.xPush(0);
         while( !stack.is_empty() ) {

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=595765&r1=595764&r2=595765&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 Fri Nov 16
10:15:03 2007
@@ -51,9 +51,6 @@
         // stack to push instructions like branch targets, etc to go thru the method. the
stack is method-wide.
         MarkableStack stack;
 
-        FastStack<Address> dead_code_stack;
-        bool      dead_code_parsing;
-
         //we would like to flush StackMapTable attribute from this method
         bool      stackmapattr_calculation;
 
@@ -63,23 +60,12 @@
             if( stackmapattr_calculation ) stack.push(target);
         }
 
-        void touch_remaining_dead_code() {
-            if( stackmapattr_calculation ) {
-                for( Address i = 0; i < m_code_length; i++ ) {
-                    // for masks 00 set them to 01
-                    props.touchDeadAndMiddles(i);
-                }
-            }
-        }
-
         static const short MARK_SUBROUTINE_DONE = -1;
 
         //init method-wide data
         void init(method_handler _m_method) {
             vf_Context_x<vf_Context_5, WorkmapElement, _WorkmapElement, StackmapElement>::init(_m_method);
             stack.init();
-            dead_code_stack.init();
-
             props.init(mem, m_code_length);
         }
 
@@ -179,7 +165,6 @@
             }
             return VF_OK;
         }
-
 
         ///////////////////////////////////  "VIRTUAL" METHODS /////////////////////////////////////////////
     public:

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/java5/instr_props_5.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/java5/instr_props_5.h?rev=595765&r1=595764&r2=595765&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/java5/instr_props_5.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/java5/instr_props_5.h Fri Nov
16 10:15:03 2007
@@ -124,8 +124,13 @@
             clear_mask(instr, 1);
         }
 
-        void touchDeadAndMiddles(Address instr) {
-            fill_mask(instr, 1);
+        void pass2started(int stackmapattr_calculation, Address code_length) {
+            //touch dead and middles so that we can distinguish between two times passed
and dead 
+            if( stackmapattr_calculation ) {
+                for( Address instr = 0; instr < code_length; instr++ ) {
+                    fill_mask(instr, 1);
+                }
+            }
         }
 
         int isDeadCodeStart(Address instr) { //dead block begins with 01, middles are 11,
ends with 10 or 00



Mime
View raw message