harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ge...@apache.org
Subject svn commit: r428040 - in /incubator/harmony/enhanced/drlvm/trunk: src/test/invokespecial_super/ src/test/invokespecial_super/src/ vm/vmcore/src/verifier/
Date Wed, 02 Aug 2006 16:04:07 GMT
Author: geirm
Date: Wed Aug  2 09:04:06 2006
New Revision: 428040

URL: http://svn.apache.org/viewvc?rev=428040&view=rev
Log:
HARMONY-919 : fix to DRLVM verifier for invokespecial
instruction

Also committed the tests for later integration


Added:
    incubator/harmony/enhanced/drlvm/trunk/src/test/invokespecial_super/
    incubator/harmony/enhanced/drlvm/trunk/src/test/invokespecial_super/HowTo.txt   (with
props)
    incubator/harmony/enhanced/drlvm/trunk/src/test/invokespecial_super/src/
    incubator/harmony/enhanced/drlvm/trunk/src/test/invokespecial_super/src/Super.j
    incubator/harmony/enhanced/drlvm/trunk/src/test/invokespecial_super/src/Test.java   (with
props)
    incubator/harmony/enhanced/drlvm/trunk/src/test/invokespecial_super/src/TestInvokeSpecial.j
Modified:
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/Verifier.cpp
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_dataflow.cpp
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_real.h
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_utils.cpp

Added: incubator/harmony/enhanced/drlvm/trunk/src/test/invokespecial_super/HowTo.txt
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/src/test/invokespecial_super/HowTo.txt?rev=428040&view=auto
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/src/test/invokespecial_super/HowTo.txt (added)
+++ incubator/harmony/enhanced/drlvm/trunk/src/test/invokespecial_super/HowTo.txt Wed Aug
 2 09:04:06 2006
@@ -0,0 +1,14 @@
+How to compile and run test:
+
+1) To compile you need to have a Jasmin version 1.1.
+This can be downloaded from http://jasmin.sourceforge.net
+
+2) The Jasmin distribution contains a jasmin.jar file holding the Jasmin assembler. 
+To compile sources execute the following commands:
+
+$ java -jar <path to Jasmin 1.1>/jasmin.jar src/*.j
+$ java -d . src/Test.java
+
+3) To run test execute the following command:
+
+$ java Test

Propchange: incubator/harmony/enhanced/drlvm/trunk/src/test/invokespecial_super/HowTo.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/drlvm/trunk/src/test/invokespecial_super/src/Super.j
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/src/test/invokespecial_super/src/Super.j?rev=428040&view=auto
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/src/test/invokespecial_super/src/Super.j (added)
+++ incubator/harmony/enhanced/drlvm/trunk/src/test/invokespecial_super/src/Super.j Wed Aug
 2 09:04:06 2006
@@ -0,0 +1,12 @@
+.class public Super
+.super java/lang/Object
+
+.method public <init>()V
+    aload_0
+    invokespecial java/lang/Object/<init>()V
+    return
+.end method
+
+.method public TestSuper()V
+    return
+.end method

Added: incubator/harmony/enhanced/drlvm/trunk/src/test/invokespecial_super/src/Test.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/src/test/invokespecial_super/src/Test.java?rev=428040&view=auto
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/src/test/invokespecial_super/src/Test.java (added)
+++ incubator/harmony/enhanced/drlvm/trunk/src/test/invokespecial_super/src/Test.java Wed
Aug  2 09:04:06 2006
@@ -0,0 +1,15 @@
+public class Test {
+    public static void main(String [] argv) {
+        // check invokespecial
+        try { 
+            Class cl = Class.forName("TestInvokeSpecial");
+            cl.newInstance();
+            System.out.println("TestInvokeSpecial: Fails");
+        } catch (LinkageError e) {
+            System.out.println("TestInvokeSpecial: Passes: " + e);
+        } catch (Throwable e) {
+            System.out.println("Test Failed, caught unexpected exception");
+            e.printStackTrace(System.out);
+        }
+    }
+}

Propchange: incubator/harmony/enhanced/drlvm/trunk/src/test/invokespecial_super/src/Test.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/drlvm/trunk/src/test/invokespecial_super/src/TestInvokeSpecial.j
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/src/test/invokespecial_super/src/TestInvokeSpecial.j?rev=428040&view=auto
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/src/test/invokespecial_super/src/TestInvokeSpecial.j
(added)
+++ incubator/harmony/enhanced/drlvm/trunk/src/test/invokespecial_super/src/TestInvokeSpecial.j
Wed Aug  2 09:04:06 2006
@@ -0,0 +1,22 @@
+.class public TestInvokeSpecial
+.super Super
+
+.method public <init>()V
+    aload_0
+    invokespecial Super/<init>()V
+    return
+.end method
+
+.method public static main([Ljava/lang/String;)V
+   
+    .limit stack 2
+   
+    new Super
+    dup
+    invokespecial Super/<init>()V
+
+    ; object is instance of super class
+    invokespecial Super/TestSuper()V
+ 
+    return
+.end method

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/Verifier.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/Verifier.cpp?rev=428040&r1=428039&r2=428040&view=diff
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/Verifier.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/Verifier.cpp Wed Aug  2
09:04:06 2006
@@ -3678,9 +3678,11 @@
     if( !strcmp( cp_parse.method.m_name, "<init>" ) ) {
         // set uninitialized check
         vf_set_in_vector_type( code, 0, SM_UNINITIALIZED );
+        vf_set_in_vector_check( code, 0, VF_CHECK_DIRECT_SUPER );
+    } else {
+        // set method access check
+        vf_set_in_vector_check( code, 0, VF_CHECK_INVOKESPECIAL );
     }
-    // set method access check
-    vf_set_in_vector_check( code, 0, VF_CHECK_ACCESS_METHOD );
     vf_set_in_vector_check_index( code, 0, cp_index );
     return VER_OK;
 } // vf_opcode_invokespecial
@@ -5322,7 +5324,10 @@
             result = vf_verify_method_bytecode( &context );
             context.ClearContext();
         }
-        if (result != VER_OK) {
+        if( result == VER_NoSupportJSR ) {
+            result = VER_OK;
+        }
+        if (result != VER_OK ) {
             goto labelEnd_verifyClass;
         }
     }
@@ -5344,9 +5349,6 @@
     vf_delete_pool( context.m_pool );
     delete context.m_type;
     *message = context.m_error;
-    if( result == VER_NoSupportJSR ) {
-        result = VER_OK;
-    }
 #if _VERIFY_DEBUG
     if( result != VER_OK ) {
         VERIFY_DEBUG( "VerifyError: " << (context.m_error ? context.m_error : "NULL")
);

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_dataflow.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_dataflow.cpp?rev=428040&r1=428039&r2=428040&view=diff
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_dataflow.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_dataflow.cpp Wed Aug
 2 09:04:06 2006
@@ -505,6 +505,14 @@
             return result;
         }
         break;
+    case VF_CHECK_DIRECT_SUPER:     // check is target class is direct super class of source
+        is_error = ctex->m_type->CheckTypes( target->m_vtype, source->m_vtype,
+            0, VF_CHECK_DIRECT_SUPER );
+        break;
+    case VF_CHECK_INVOKESPECIAL:    // check invokespecial object reference
+        is_error = ctex->m_type->CheckTypes( target->m_vtype, source->m_vtype,
+                    0, VF_CHECK_INVOKESPECIAL );
+        break;
     default:
         DIE( "Verifier: vf_check_entry_refs: unknown check in switch" );
     }
@@ -822,7 +830,7 @@
                 VERIFY_REPORT( ctex, "(class: " << class_get_name( ctex->m_class
) 
                     << ", method: " << method_get_name( ctex->m_method )
                     << method_get_descriptor( ctex->m_method )
-                    << ") Data flow analysis error" );
+                    << ") Data flow analysis error (uninitialized)" );
                 return result;
             }
             // check initialization class in constructor

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_real.h
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_real.h?rev=428040&r1=428039&r2=428040&view=diff
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_real.h (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_real.h Wed Aug  2 09:04:06
2006
@@ -233,6 +233,7 @@
     VF_CHECK_ACCESS_FIELD,
     VF_CHECK_ACCESS_METHOD,
     VF_CHECK_DIRECT_SUPER,
+    VF_CHECK_INVOKESPECIAL,
     VF_CHECK_NUM
 } vf_CheckConstraint_t;
 

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_utils.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_utils.cpp?rev=428040&r1=428039&r2=428040&view=diff
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_utils.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_utils.cpp Wed Aug  2
09:04:06 2006
@@ -477,6 +477,7 @@
             }
         }
         return false;
+
     case VF_CHECK_ACCESS_FIELD:    // check field access
         // compare types
         assert( required->number == 1 );
@@ -490,6 +491,7 @@
                             index, VF_CHECK_ACCESS_FIELD );
         }
         return false;
+
     case VF_CHECK_ACCESS_METHOD:   // check method access
         // compare types
         assert( required->number == 1 );
@@ -503,10 +505,29 @@
                             index, VF_CHECK_ACCESS_METHOD );
         }
         return false;
+    case VF_CHECK_DIRECT_SUPER:
+        if( required->number == 1 && available->number == 1 ) {
+            if( required->string[0] != available->string[0] ) {
+                SetRestriction( required->string[0], available->string[0],
+                                    0, VF_CHECK_DIRECT_SUPER );
+            }
+            return false;
+        }
+        return true;
+
+    case VF_CHECK_INVOKESPECIAL:
+        assert( required->number == 1 );
+        for( index1 = 0; index1 < available->number; index1++ ) {
+            SetRestriction( required->string[0], available->string[index1],
+                            index, VF_CHECK_INVOKESPECIAL );
+        }
+        return false;
     default:
         DIE("Verifier: CompareTypes: unknown check type in switch");
+        return true;
     }
-    return true;
+    // unreachable code
+    assert(0);
 } // vf_TypePool::CheckTypes
 
 /**
@@ -968,7 +989,8 @@
 static bool
 vf_is_valid( class_handler source,              // checked class
              class_handler target,              // required class
-             vf_CheckConstraint_t check)        // checked class type
+             class_handler current,             // current class
+             unsigned check)                    // checked class type
 {
     switch( check )
     {
@@ -986,18 +1008,25 @@
         return class_is_same_class( class_get_super_class( source ), target );
     case VF_CHECK_ACCESS_FIELD:     // protected field access
     case VF_CHECK_ACCESS_METHOD:    // protected method acceess
-        if( class_is_same_package( source, target )
-            || vf_is_super_class( source, target ) )
+        if( class_is_same_package( source, current )
+            || vf_is_super_class( source, current ) )
         {
             return true;
         }
-        break;
+        return false;
+    case VF_CHECK_INVOKESPECIAL:
+        if( vf_is_super_class( source, current ) 
+            && vf_is_super_class( current, target ) )
+        {
+            return true;
+        }
+        return false;
     default:
-        VERIFY_DEBUG( "vf_is_valid: invalid check type" );
-        vf_error();
-        break;
+        DIE( "Verifier: vf_is_valid: invalid check type" );
+        return false;
     }
-    return false;
+    // unreachable code
+    assert(0);
 } // vf_is_valid
 
 /**
@@ -1009,7 +1038,7 @@
 {
     switch( restriction->check_type )
     {
-    case VF_CHECK_DIRECT_SUPER:
+    case VF_CHECK_SUPER:
         /**
          * Extension for class java/lang/Object doesn't check
          * because it's expected all references extend it.
@@ -1106,7 +1135,7 @@
     }
 
     // check restriction
-    if( !vf_is_valid( source, target, (vf_CheckConstraint_t)restriction->check_type )
) {
+    if( !vf_is_valid( source, target, ctex->m_class, restriction->check_type ) ) {
         // return error
         switch( restriction->check_type )
         {
@@ -1230,7 +1259,7 @@
     }
 
     // check access constraint
-    if( !vf_is_valid( instance, ctex->m_class, check_type ) )
+    if( !vf_is_valid( instance, NULL, ctex->m_class, check_type ) )
     {
         // return error
         switch( check_type )
@@ -1389,7 +1418,7 @@
     }
 
     // check restriction
-    if( !vf_is_valid( source, target, check ) )
+    if( !vf_is_valid( source, target, ctex->m_class, check ) )
     {
         switch( check )
         {



Mime
View raw message