You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by gs...@apache.org on 2006/11/28 17:07:00 UTC

svn commit: r480110 - in /harmony/enhanced/drlvm/trunk/vm/vmcore: include/ src/class_support/ src/verifier/

Author: gshimansky
Date: Tue Nov 28 08:06:59 2006
New Revision: 480110

URL: http://svn.apache.org/viewvc?view=rev&rev=480110
Log:
Aplied HARMONY-2299 [drlvm][verifier] Support JDK 1.4 class file

Tests passed on windows xp, ubuntu and suse 10 x86_64


Modified:
    harmony/enhanced/drlvm/trunk/vm/vmcore/include/Class.h
    harmony/enhanced/drlvm/trunk/vm/vmcore/include/class_interface.h
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Class_File_Loader.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/class_impl.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/Verifier.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_dataflow.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_real.h

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/include/Class.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/include/Class.h?view=diff&rev=480110&r1=480109&r2=480110
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/include/Class.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/include/Class.h Tue Nov 28 08:06:59 2006
@@ -829,6 +829,9 @@
     // that points to the corresponding Class data structure.
     ManagedObject** m_class_handle;
 
+    // class file major version
+    uint16 m_version;
+
     // Access and properties flags of a class
     uint16 m_access_flags;
 
@@ -1367,6 +1370,10 @@
 
     /** Gets the class ID.*/
     unsigned get_id() const { return m_id; }
+
+    /** Gets major version of class file.
+     * @return Major version of class file.*/
+    uint16 get_version() const { return m_version; }
 
     /** Gets access and properties flags of the given class.
      * @return The 16-bit integer representing access and properties flags

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/include/class_interface.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/include/class_interface.h?view=diff&rev=480110&r1=480109&r2=480110
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/include/class_interface.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/include/class_interface.h Tue Nov 28 08:06:59 2006
@@ -61,6 +61,15 @@
  * Class interface
  */
 
+/**
+ * Function returns class major version.
+ * @param klass - class handler
+ * @return Class name bytes.
+ * @note Assertion is raised if klass is equal to null.
+ */
+unsigned short
+class_get_version( class_handler klass );
+
 /** 
  * Function returns class name.
  * @param klass - class handler

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Class_File_Loader.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Class_File_Loader.cpp?view=diff&rev=480110&r1=480109&r2=480110
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Class_File_Loader.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Class_File_Loader.cpp Tue Nov 28 08:06:59 2006
@@ -2155,18 +2155,17 @@
         return false;
     }
 
-    uint16 major_version;
-    if (!cfs.parse_u2_be(&major_version)) {
+    if (!cfs.parse_u2_be(&m_version)) {
         REPORT_FAILED_CLASS_CLASS(m_class_loader, this, "java/lang/ClassFormatError",
             "could not parse major version");
         return false;
     }
 
-    if (!(major_version >= CLASSFILE_MAJOR
-        && major_version <= CLASSFILE_MAJOR_MAX))
+    if (!(m_version >= CLASSFILE_MAJOR
+        && m_version <= CLASSFILE_MAJOR_MAX))
     {
         REPORT_FAILED_CLASS_CLASS(m_class_loader, this, "java/lang/UnsupportedClassVersionError",
-            "class has version number " << major_version);
+            "class has version number " << m_version);
         return false;
     }
 

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/class_impl.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/class_impl.cpp?view=diff&rev=480110&r1=480109&r2=480110
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/class_impl.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/class_impl.cpp Tue Nov 28 08:06:59 2006
@@ -27,7 +27,18 @@
 #include "classloader.h"
 #include "environment.h"
 
-/** 
+/**
+ * Function returns class major version.
+ */
+unsigned short
+class_get_version( class_handler klass )
+{
+    assert( klass );
+    Class *clss = (Class*)klass;
+    return clss->get_version();
+} // class_get_version
+
+/**
  * Function returns class name.
  */
 const char *

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=480110&r1=480109&r2=480110
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/Verifier.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/Verifier.cpp Tue Nov 28 08:06:59 2006
@@ -1829,15 +1829,23 @@
         vf_set_vector_stack_entry_ref( cp_parse->field.f_vector, 0, type );
         break;
 	case _CONSTANT_Class:
-        type = ctex->m_type->NewType( "Ljava/lang/Class", 16 );
-        vf_set_vector_stack_entry_ref( cp_parse->field.f_vector, 0, type );
-		break;
+        if( !vf_is_class_version_14(ctex) ) {
+            type = ctex->m_type->NewType( "Ljava/lang/Class", 16 );
+            vf_set_vector_stack_entry_ref( cp_parse->field.f_vector, 0, type );
+		    break;
+        }
+        // if class version is 1.4 verifier fails in default
     default:
         VERIFY_REPORT( ctex, "(class: " << class_get_name( ctex->m_class )
             << ", method: " << method_get_name( ctex->m_method )
             << method_get_descriptor( ctex->m_method )
-            << ") Illegal type in constant pool,"
-            << index << ": CONSTANT_Integer, CONSTANT_Float, CONSTANT_String or CONSTANT_Class are expected" );
+            << ") Illegal type for constant pool entry #"
+            << index
+            << (vf_is_class_version_14(ctex)
+                ? ": CONSTANT_Integer, CONSTANT_Float or CONSTANT_String"
+                : ": CONSTANT_Integer, CONSTANT_Float, CONSTANT_String "
+                  "or CONSTANT_Class")
+            << " are expected for ldc/ldc_w instruction" );
         return VER_ErrorConstantPool;
     }
     return VER_OK;
@@ -2638,9 +2646,13 @@
     vf_set_in_vector_stack_entry_ref( code, 0, NULL );
     vf_set_in_vector_check( code, 0, VF_CHECK_REF_ARRAY );
     vf_set_in_vector_stack_entry_int( code, 1 );
-    vf_set_in_vector_stack_entry_ref( code, 2, NULL );
+    if( vf_is_class_version_14(ctex) ) {
+        vf_set_in_vector_type( code, 2, SM_UP_ARRAY );
+    } else {
+        vf_set_in_vector_stack_entry_ref( code, 2, NULL );
+    }
     return;
-} // vf_opcode_fastore
+} // vf_opcode_aastore
 
 /**
  * Function sets code instruction structure for opcode pop.

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_dataflow.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_dataflow.cpp?view=diff&rev=480110&r1=480109&r2=480110
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_dataflow.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_dataflow.cpp Tue Nov 28 08:06:59 2006
@@ -764,7 +764,8 @@
 {
     unsigned index;
     vf_MapEntry_t *entry,
-                  *vector;
+                  *vector,
+                  *newvector;
     Verifier_Result result;
 
     // check IN vector entries
@@ -781,6 +782,27 @@
         case SM_TOP:
             // copy entry
             copy = true;
+            break;
+        case SM_UP_ARRAY:
+            // check reference array element
+            assert( index > 0 );
+            newvector = &buf[index];
+            // check assignment conversion
+            vf_set_array_element_type( newvector, vector, &buf[0], ctex );
+            if( newvector->m_vtype ) {
+                newvector->m_ctype = VF_CHECK_ASSIGN_WEAK;
+            } else {
+                newvector->m_ctype = VF_CHECK_NONE;
+            }
+            // check entry types
+            result = vf_check_entry_refs( entry, newvector, ctex );
+            if( result != VER_OK ) {
+                VERIFY_REPORT( ctex, "(class: " << class_get_name( ctex->m_class )
+                    << ", method: " << method_get_name( ctex->m_method )
+                    << method_get_descriptor( ctex->m_method )
+                    << ") Incompatible types for array assignment" );
+                return result;
+            }
             break;
         case SM_REF:
             // check entry references

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_real.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_real.h?view=diff&rev=480110&r1=480109&r2=480110
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_real.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_real.h Tue Nov 28 08:06:59 2006
@@ -1572,6 +1572,16 @@
     return;
 } // vf_set_error_message
 
+/**
+ * Checks version of class file
+ * @param context - verifier context
+ */
+static inline bool
+vf_is_class_version_14( vf_Context_t *context )
+{
+    return (class_get_version(context->m_class) < 49) ? true : false;
+} // vf_is_class_version_14
+
 } // namespace Verifier
 
 using namespace Verifier;