harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcfi...@apache.org
Subject svn commit: r653525 - in /harmony/enhanced/drlvm/trunk: make/vm/ vm/vmcore/include/ vm/vmcore/src/class_support/ vm/vmcore/src/verifier-3363/base/ vm/vmcore/src/verifier-3363/java6/ vm/vmcore/src/verifier-3363/x_verifier/
Date Mon, 05 May 2008 16:20:27 GMT
Author: mcfirst
Date: Mon May  5 09:20:26 2008
New Revision: 653525

URL: http://svn.apache.org/viewvc?rev=653525&view=rev
Log:
Applying the patch from HARMONY-5764 [drlvm][verifier-ext] Incorrect stack map calculation.
I've slightly modified the patch so that error messages be freed correctly and corresponding
interface function be available to extension users.

Modified:
    harmony/enhanced/drlvm/trunk/make/vm/verifier.xml
    harmony/enhanced/drlvm/trunk/vm/vmcore/include/verifier.h
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Verifier_stub.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/base/context_x.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/base/tpool.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/base/ver.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/java6/context_6.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/java6/context_6.h
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/x_verifier/recompute.h
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/x_verifier/x_verifier.cpp

Modified: harmony/enhanced/drlvm/trunk/make/vm/verifier.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/make/vm/verifier.xml?rev=653525&r1=653524&r2=653525&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/make/vm/verifier.xml (original)
+++ harmony/enhanced/drlvm/trunk/make/vm/verifier.xml Mon May  5 09:20:26 2008
@@ -30,10 +30,11 @@
                 <pathelement location="${vm.home}/include" />
             </includepath>
             <compiler extends="common.cpp.compiler">
-                <fileset dir="${vm.home}/vmcore/src">
-                    <include name="verifier-3363/base/*.cpp" />
-                    <include name="verifier-3363/java5/*.cpp" />
-                    <include name="verifier-3363/java6/*.cpp" />
+                <fileset dir="${vm.home}/vmcore/src/verifier-3363">
+                    <include name="base/*.cpp" />
+                    <include name="java5/*.cpp" />
+                    <include name="java6/*.cpp" />
+                    <include name="x_verifier/*.cpp" if="cfg.is.debug" />
                 </fileset>
 	            <defineset define="BUILDING_VM" />
             </compiler>

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/include/verifier.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/include/verifier.h?rev=653525&r1=653524&r2=653525&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/include/verifier.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/include/verifier.h Mon May  5 09:20:26 2008
@@ -79,7 +79,7 @@
  * @param error - error message of verifier
  * @note Assertion is raised if error_message is equal to null.
  */
-void vf_release_error_message(void* error);
+void vf_release_memory(void* error);
 
 /**
  * Function releases verify data in class loader.

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Verifier_stub.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Verifier_stub.cpp?rev=653525&r1=653524&r2=653525&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Verifier_stub.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Verifier_stub.cpp Mon May  5
09:20:26 2008
@@ -66,7 +66,7 @@
             aulock.ForceUnlock();
             REPORT_FAILED_CLASS_CLASS(m_class_loader, this,
                                       "java/lang/VerifyError", error);
-            vf_release_error_message(error);
+            vf_release_memory(error);
             return false;
         }
     }
@@ -137,7 +137,7 @@
         } else {
             REPORT_FAILED_CLASS_CLASS(m_class_loader, this,
                                       "java/lang/VerifyError", error);
-            vf_release_error_message(error);
+            vf_release_memory(error);
         }
         return false;
     }

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/base/context_x.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/base/context_x.cpp?rev=653525&r1=653524&r2=653525&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/base/context_x.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/base/context_x.cpp Mon May  5
09:20:26 2008
@@ -260,9 +260,6 @@
 
 
 
-
-
-
 #define CHECK_xSTORE( idx, TYPE )                                        \
     if( !workmap_valid_local(idx) ) return error(VF_ErrorLocals,         \
             "invalid local index");                                      \
@@ -350,10 +347,6 @@
 vf_Result vf_Context_x<ActualClass, WorkmapElement, _WorkmapElement, StackmapElement>::dataflow_instruction(Address
instr) {
 
     vf_Result tcr;
-    if( (tcr=dataflow_handlers(instr)) != VF_OK ) {
-        return tcr;
-    }
-
     OpCode opcode = (OpCode)m_bytecode[instr];
     processed_instruction = instr;
 
@@ -1801,6 +1794,10 @@
             assert(0);
             return error(VF_ErrorInternal, "unreachable statement");
     }
+
+    if( (tcr=dataflow_handlers(instr)) != VF_OK ) {
+        return tcr;
+    }
     return VF_OK;
 }
 
@@ -2070,7 +2067,7 @@
         method_get_exc_handler_info( m_method, idx, &start_pc, &end_pc,
             &handler_pc, &handler_cp_index );
 
-        if( instr == end_pc - 1 && instr >= start_pc ) {
+        if( instr < end_pc && instr >= start_pc ) {
             vf_Result tcr;
 
             StackmapHead *handler = getStackmap(handler_pc);

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/base/tpool.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/base/tpool.cpp?rev=653525&r1=653524&r2=653525&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/base/tpool.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/base/tpool.cpp Mon May  5 09:20:26
2008
@@ -15,6 +15,7 @@
  *  limitations under the License.
  */
 #include <assert.h>
+#include <stdio.h>
 
 #include "open/vm_field_access.h"
 #include "open/vm_method_access.h"
@@ -581,3 +582,47 @@
     return !strcmp(class_cp_get_utf8_bytes( k_class, name_idx ), "<init>");
 }
 
+/* FIXME: deserve separate file probably */
+void vf_release_memory(void* error)
+{
+            tc_free(error);
+}
+
+/**
+ *  * Creates error message to be reported with verify error
+ *   */
+void vf_create_error_message(Method_Handle method, vf_Context_Base context, char
+        ** error_msg)
+{
+    char pass[12], instr[12];
+    sprintf(pass, "%d", context.pass);
+    sprintf(instr, "%d", context.processed_instruction);
+    const char* cname = class_get_name(method_get_class(method));
+    const char* mname = method_get_name(method);
+    const char* mdesc = method_get_descriptor(method);
+    const char *format = "%s.%s%s, pass: %s, instr: %s, reason: %s";
+    unsigned msg_len = strlen(cname) + strlen(mname) + strlen(mdesc)
+        + strlen(pass) + strlen(instr) + strlen(context.error_message)
+        + strlen(format);
+    *error_msg = (char*)tc_malloc(msg_len);
+    if(*error_msg != NULL) {
+        sprintf(*error_msg, format,
+            cname, mname, mdesc, pass, instr, context.error_message);
+    }
+}
+
+void vf_create_error_message(Class_Handle klass, vf_TypeConstraint* constraint,
+        char** error_msg)
+{
+    const char* cname = class_get_name(klass);
+    const char *format = "constraint check failed, class: %s, source: %s, target: %s";
+    unsigned msg_len = strlen(cname) +
+        + strlen(constraint->source)
+        + strlen(constraint->target) + strlen(format);
+    *error_msg = (char*)tc_malloc(msg_len);
+    if(*error_msg != NULL) {
+        sprintf(*error_msg, format,
+            cname, constraint->source, constraint->target);
+    }
+}
+

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/base/ver.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/base/ver.cpp?rev=653525&r1=653524&r2=653525&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/base/ver.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/base/ver.cpp Mon May  5 09:20:26
2008
@@ -14,12 +14,13 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-#include <stdio.h>
 #include "verifier.h"
-#include "ver_utils.h"
 #include "../java5/context_5.h"
 #include "../java6/context_6.h"
-#include "time.h"
+#ifndef _NDEBUG
+#include "../x_verifier/recompute.h"
+#include "class_interface.h"
+#endif
 
 #include "open/vm_class_manipulation.h"
 #include "open/vm_method_access.h"
@@ -60,9 +61,8 @@
     return result;
 } // vf_verify5_class
 
-
 /**
-* Function provides initial java-6 verification of class.
+* Provides initial java-6 verification of class.
 *
 * If when verifying the class a check of type "class A must be assignable to class B" needs
to be done 
 * and either A or B is not loaded at the moment then a constraint 
@@ -108,6 +108,17 @@
                 return result;
             }
         }
+
+#ifndef _NDEBUG
+        vf_recompute_stackmaptable(method, &context6.substitution, error, classwide.class_constraints);
+
+        result = context6.verify_method(method);
+        if (result != VF_OK) {
+            vf_create_error_message(method, context6, error);
+        }
+        tc_free(context6.substitution);
+        context6.substitution = NULL;
+#endif  
     }
 
     /**
@@ -177,14 +188,8 @@
     return VF_OK;
 } // vf_verify_method_constraints
 
-
-void vf_release_error_message(void* error)
-{
-    tc_free(error);
-}
-
 /**
-* Function releases verify data in class loader (used to store constraints)
+* Releases verify data in class loader (used to store constraints)
 */
 void
 vf_release_verify_data( void *data )
@@ -196,36 +201,30 @@
     delete cl_data->pool;
 } // vf_release_verify_data
 
-/**
- * Creates error message to be reported with verify error
- */
-void vf_create_error_message(Method_Handle method, vf_Context_Base context, char** error_msg)
-{
-    char pass[12], instr[12];
-    sprintf(pass, "%d", context.pass);
-    sprintf(instr, "%d", context.processed_instruction);
-    const char* cname = class_get_name(method_get_class(method));
-    const char* mname = method_get_name(method);
-    const char* mdesc = method_get_descriptor(method);
-    const char *format = "%s.%s%s, pass: %s, instr: %s, reason: %s";
-    unsigned msg_len = strlen(cname) + strlen(mname) + strlen(mdesc)
-        + strlen(pass) + strlen(instr) + strlen(context.error_message) +
-        strlen(format);
-    *error_msg = (char*)tc_malloc(msg_len);
-    if(*error_msg != NULL) {
-        sprintf(*error_msg, format,
-            cname, mname, mdesc, pass, instr, context.error_message);
-    }
+#ifndef _NDEBUG
+void method_remove_exc_handler( Method_Handle method, unsigned short idx ) {
+    //unimplemented, needed for stack map re-computation testing
+    assert(0);
 }
 
-void vf_create_error_message(Class_Handle klass, vf_TypeConstraint* constraint, char** error_msg)
+void method_modify_exc_handler_info( Method_Handle method, unsigned short idx,
+                                     unsigned short start_pc, unsigned short end_pc,
+                                     unsigned short handler_pc, unsigned short handler_cp_index
)
 {
-    const char* cname = class_get_name(klass);
-    const char *format = "constraint check failed, class: %s, source: %s, target: %s";
-    unsigned msg_len = strlen(cname) +
-        + strlen(constraint->source)
-        + strlen(constraint->target) + strlen(format);
-    *error_msg = (char*)tc_malloc(msg_len);
-    sprintf(*error_msg, format,
-        cname, constraint->source, constraint->target);
+    //unimplemented
+    assert(0);
 }
+
+unsigned short class_cp_get_class_entry(Class_Handle k_class, const char* name) {
+    for( unsigned short i = 1; i < class_cp_get_size( k_class ); i++ ) {
+        if( class_cp_get_tag( k_class, i ) == _CONSTANT_Class ) {
+            unsigned short name_idx = class_cp_get_class_name_index(k_class, i);
+            const char* cp_name = class_cp_get_utf8_bytes( k_class, name_idx );
+
+            if( !strcmp(name, cp_name) ) return i;
+        }
+    }
+    return 0;
+}
+#endif
+

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/java6/context_6.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/java6/context_6.cpp?rev=653525&r1=653524&r2=653525&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/java6/context_6.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/java6/context_6.cpp Mon May 
5 09:20:26 2008
@@ -195,6 +195,10 @@
 
     Byte* stackmaptable = method_get_stackmaptable(m_method);
 
+#ifndef _NDEBUG
+    if (substitution) stackmaptable = substitution;
+#endif
+
     if(!stackmaptable) return VF_OK;
 
     Byte* read_ptr = stackmaptable;

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/java6/context_6.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/java6/context_6.h?rev=653525&r1=653524&r2=653525&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/java6/context_6.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/java6/context_6.h Mon May  5
09:20:26 2008
@@ -25,10 +25,15 @@
 //
 // Context - main class of Type Checker
 //
-class vf_Context_6 : public vf_Context_x<vf_Context_6, WorkmapElement_6, _WorkmapElement_6,
StackmapElement_6> {
+class vf_Context_6 : public vf_Context_x<vf_Context_6, WorkmapElement_6, _WorkmapElement_6,
StackmapElement_6>
+{
 public:
     vf_Context_6(SharedClasswideData &classwide) :
-      vf_Context_x<vf_Context_6, WorkmapElement_6, _WorkmapElement_6, StackmapElement_6>(classwide)
{}
+      vf_Context_x<vf_Context_6, WorkmapElement_6, _WorkmapElement_6, StackmapElement_6>(classwide)
+#ifndef _NDEBUG
+      , substitution(NULL)
+#endif
+      {}
 
       vf_Result verify_method(Method_Handle method);
 protected:
@@ -61,7 +66,6 @@
     //to the workmap and increase cnt. Check space_available when record to the workmap
     vf_Result read_types(Byte **attr, Byte *end, WorkmapElement_6* element, unsigned *cnt,
unsigned space_available);
 
-
     ///////////////////////////////////  "VIRTUAL" METHODS /////////////////////////////////////////////
 public:
     //create constraint vector in case of a branch 
@@ -133,6 +137,11 @@
     void new_bogus_propagation_constraint(WorkmapElement_6 &wm_el, SmConstant init_val)
{
         wm_el = _WorkmapElement_6 (init_val);
     }
+
+    //recomputed stack map used for testing
+#ifndef _NDEBUG
+    Byte *substitution;
+#endif
 };
 
 #endif

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/x_verifier/recompute.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/x_verifier/recompute.h?rev=653525&r1=653524&r2=653525&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/x_verifier/recompute.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/x_verifier/recompute.h Mon May
 5 09:20:26 2008
@@ -450,9 +450,9 @@
 
 
 
-#define ITERATE_THRU_STACKMAP_VECTORS(CODE)                                         \
-for( i = 0; i < props.hash_size; i++ ) {                                    \
-    PropsHead_5 *pro = (PropsHead_5*)(props.propHashTable[i]);                      \
+#define ITERATE_THRU_STACKMAP_VECTORS(CODE)                                     \
+for( i = 0; i < props.hash_size; i++ ) {                                        \
+    PropsHead_5 *pro = (PropsHead_5*)(props.propHashTable[i]);                  \
     while(pro) {                                                                \
         if( !pro->is_workmap() ) {                                              \
             StackmapHead *sm = pro->getStackmap();                              \
@@ -461,11 +461,11 @@
                 /*skip uninit flag*/                                            \
                 if( j == m_max_locals && j < m_stack_start ) continue;       
  \
                                                                                 \
-                StackmapElement_5 *el = &(sm->elements[j]);                      
\
+                StackmapElement_5 *el = &(sm->elements[j]);                     \
                 CODE;                                                           \
             }                                                                   \
         }                                                                       \
-        pro=(PropsHead_5 *)pro->next;                                             \
+        pro=(PropsHead_5 *)pro->next;                                           \
     }                                                                           \
 }                                                                               \
 

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/x_verifier/x_verifier.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/x_verifier/x_verifier.cpp?rev=653525&r1=653524&r2=653525&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/x_verifier/x_verifier.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/x_verifier/x_verifier.cpp Mon
May  5 09:20:26 2008
@@ -65,7 +65,13 @@
                                   verification_context context)
 {
     char* error_message;
-    return vf_recompute_stackmaptable(method, attrBytes, &error_message, ((SharedClasswideData*)context)->class_constraints);
+    vf_Result result = vf_recompute_stackmaptable(method,
+        attrBytes, &error_message,
+        ((SharedClasswideData*)context)->class_constraints);
+    if(result != VF_OK) {
+        vf_release_memory(error_message);
+    }
+    return result;
 }
 
 



Mime
View raw message