harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gshiman...@apache.org
Subject svn commit: r495564 - in /harmony/enhanced/drlvm/trunk/vm/vmcore: include/ src/class_support/ src/init/ src/verifier/
Date Fri, 12 Jan 2007 12:55:51 GMT
Author: gshimansky
Date: Fri Jan 12 04:55:50 2007
New Revision: 495564

URL: http://svn.apache.org/viewvc?view=rev&rev=495564
Log:
Applied HARMONY-2755 [drlvm][verifier] vm fails with -Xverify flag set

Tests passed on Ubuntu6 x86, Windows 2003 server x86 and SuSE9 x86_64


Modified:
    harmony/enhanced/drlvm/trunk/vm/vmcore/include/environment.h
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Environment.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Verifier_stub.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/classloader.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/parse_arguments.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/Verifier.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_utils.cpp

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/include/environment.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/include/environment.h?view=diff&rev=495564&r1=495563&r2=495564
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/include/environment.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/include/environment.h Fri Jan 12 04:55:50 2007
@@ -71,10 +71,11 @@
     bool strings_are_compressed;    // 2003-05-19: The VM searches the java.lang.String class
for a "byte[] bvalue" field at startup,
                                     // as an indication that the Java class library supports
compressed strings with 8-bit characters.
     bool use_large_pages;           // 20040109 Use large pages for class-related data such
as vtables.
-    size_t system_page_size;        // system page size according to use_large_pages value
-    bool verify_all;                // psrebriy 20050815 Verify all classes including loaded
by bootstrap class loader
     bool pin_interned_strings;      // if true, interned strings are never moved
     bool retain_invisible_annotations; // retain InvisibleAnnotation and InvisibleParameterAnnotation
+    bool verify_all;                // Verify all classes including loaded by bootstrap class
loader
+    bool verify_strict;             // Do strict verification
+    size_t system_page_size;        // system page size according to use_large_pages value
     
     Lock_Manager *p_jit_a_method_lock;
     Lock_Manager *p_vtable_patch_lock;

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Environment.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Environment.cpp?view=diff&rev=495564&r1=495563&r2=495564
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Environment.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Environment.cpp Fri Jan 12 04:55:50
2007
@@ -135,6 +135,7 @@
 	}
 
     verify_all = false;
+    verify_strict = false;
     pin_interned_strings = false; 
     retain_invisible_annotations = false;
 

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?view=diff&rev=495564&r1=495563&r2=495564
==============================================================================
--- 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 Fri Jan 12
04:55:50 2007
@@ -41,10 +41,17 @@
     if(m_state >= ST_BytecodesVerified)
         return true;
 
+    if(is_array()) {
+        // no need do bytecode verification for arrays
+        m_state = ST_BytecodesVerified;
+        return true;
+    }
+
     /**
      * Get verifier enable status
      */
     Boolean is_forced = env->verify_all;
+    Boolean is_strict = env->verify_strict;
     Boolean is_bootstrap = m_class_loader->IsBootstrap();
     Boolean is_enabled = get_boolean_property("vm.use_verifier", TRUE, VM_PROPERTIES);
 
@@ -56,7 +63,7 @@
         && (is_bootstrap == FALSE || is_forced == TRUE))
     {
         char *error;
-        Verifier_Result result = vf_verify_class((class_handler)this, is_forced, &error);
+        Verifier_Result result = vf_verify_class((class_handler)this, is_strict, &error);
         if( result != VER_OK ) {
             aulock.ForceUnlock();
             REPORT_FAILED_CLASS_CLASS(m_class_loader, this,
@@ -98,8 +105,15 @@
     }
     assert(m_state == ST_Prepared);
 
+    if(is_array()) {
+        // no need do constraint verification for arrays
+        m_state = ST_ConstraintsVerified;
+        unlock();
+        return true;
+    }
+
     // get verifier enable status
-    Boolean verify_all = env->verify_all;
+    Boolean is_strict = env->verify_strict;
 
     // unlock a class before calling to verifier
     unlock();
@@ -107,7 +121,7 @@
     // check method constraints
     char *error;
     Verifier_Result result =
-        vf_verify_class_constraints((class_handler)this, verify_all, &error);
+        vf_verify_class_constraints((class_handler)this, is_strict, &error);
 
     // lock class and check result
     lock();

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/classloader.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/classloader.cpp?view=diff&rev=495564&r1=495563&r2=495564
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/classloader.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/classloader.cpp Fri Jan 12 04:55:50
2007
@@ -864,22 +864,22 @@
             FailedLoadingClass(classNameString);
         }
         return klass;
-    } else {
-        // we should wait here for creating class
-        if((klass = WaitDefinition(env, classNameString)) != NULL)
-            return klass;
+    }
 
-        // create class
-        klass = NewClass(env, classNameString);
-        if (!klass) {
-            FailedLoadingClass(classNameString);
-            return NULL;
-        }
+    // we should wait here for creating class
+    if((klass = WaitDefinition(env, classNameString)) != NULL)
+        return klass;
 
-        // setup array-related fields
-        klass->setup_as_array(env, n_dimensions, isArrayOfPrimitives,
-            baseClass, elementClass);
+    // create class
+    klass = NewClass(env, classNameString);
+    if (!klass) {
+        FailedLoadingClass(classNameString);
+        return NULL;
     }
+
+    // setup array-related fields
+    klass->setup_as_array(env, n_dimensions, isArrayOfPrimitives,
+        baseClass, elementClass);
 
     if(!klass->load_ancestors(env)) {
         FailedLoadingClass(classNameString);

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/parse_arguments.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/parse_arguments.cpp?view=diff&rev=495564&r1=495563&r2=495564
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/parse_arguments.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/parse_arguments.cpp Fri Jan 12 04:55:50
2007
@@ -175,7 +175,7 @@
         "              Set up logging via log4cxx configuration file\n"
         "    -Xverboselog:<file>\n"
         "              Log verbose output to a file\n"
-        "    -Xverify\n"
+        "    -Xverify[:none|all]\n"
         "              Do full bytecode verification\n"
         "    -Xinvisible\n"
         "              Retain invisible annotations at runtime\n"
@@ -442,6 +442,13 @@
         }
         else if (strcmp(option, "-Xverify") == 0) {
             p_env->verify_all = true;
+        }
+        else if (strcmp(option, "-Xverify:none") == 0 || strcmp(option, "-noverify") == 0)
{
+            p_env->VmProperties()->set("vm.use_verifier", "false");
+        }
+        else if (strcmp(option, "-Xverify:all") == 0) {
+            p_env->verify_all = true;
+            p_env->verify_strict = true;
         }
         else if (strcmp(option, "-verify") == 0) {
             p_env->verify_all = true;

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/Verifier.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/Verifier.cpp?view=diff&rev=495564&r1=495563&r2=495564
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/Verifier.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/Verifier.cpp Fri Jan 12 04:55:50 2007
@@ -5472,8 +5472,7 @@
         }
         if( result == VER_NoSupportJSR ) {
             result = VER_OK;
-        }
-        if (result != VER_OK ) {
+        } else  if (result != VER_OK ) {
             goto labelEnd_verifyClass;
         }
     }

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_utils.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_utils.cpp?view=diff&rev=495564&r1=495563&r2=495564
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_utils.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_utils.cpp Fri Jan 12 04:55:50
2007
@@ -848,7 +848,7 @@
         }
     } else {
         // source class is class
-        if( !strcmp( class_get_name( source ), "java/lang/Object" ) ) {
+        if( !memcmp( class_get_name( source ), "java/lang/Object", 17 ) ) {
             // source class is Object
             return true;
         }
@@ -1164,8 +1164,8 @@
         // check assignment reference conversions
         if( restriction->source[0] == '[' ) {
             // source class is array
-            if( !strcmp( restriction->target, "Ljava/lang/Cloneable" )
-                || !strcmp( restriction->target, "Ljava/io/Serializable" ) )
+            if( !memcmp( restriction->target, "Ljava/lang/Cloneable", 21 )
+                || !memcmp( restriction->target, "Ljava/io/Serializable", 22 ) )
             {
                 // target class is java/lang/Cloneable 
                 // or java/lang/Serializable interface
@@ -1218,6 +1218,18 @@
         return VER_ClassNotLoaded;
     }
 
+    /**
+     * Verifier which is built on Java VM Specification 2nd Edition (4.9.2)
+     * recommendation of verification proccess doesn't check interfaces usage.
+     * Unfortunately, a lot of Java applications depends on this neglect.
+     * To be compatible with those applications we should do full constraint
+     * checks only if -Xverify:all option is present in command line.
+     */
+    if( !ctex->m_dump.m_verify && class_is_interface_( target ) ) {
+        // skip constraint check
+        return VER_OK;
+    }
+
     // check restriction
     if( !vf_is_valid( source, target, ctex->m_class, restriction->check_type ) ) {
         // return error
@@ -1280,7 +1292,7 @@
             return VER_OK;
         }
         if( method_is_protected( method ) ) {
-            if( instance_name[0] == '[' && !strcmp( method_get_name( method ), "clone"
) ) {
+            if( instance_name[0] == '[' && !memcmp( method_get_name( method ), "clone",
7 ) ) {
                 // for arrays function clone is public
             } else {
                 need_check = true;
@@ -1403,7 +1415,7 @@
      * recommendation of verification proccess doesn't check interfaces usage.
      * Unfortunately, a lot of Java applications depends on this neglect.
      * To be compatible with those applications we should do full constraint
-     * checks only if -Xverify option is present in command line.
+     * checks only if -Xverify:all option is present in command line.
      */
     if( !ctex->m_dump.m_verify && class_is_interface_( target ) ) {
         // skip constraint check



Mime
View raw message