harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mloe...@apache.org
Subject svn commit: r563763 - in /harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363: Pass2.cpp Ver.cpp tpool.cpp tpool.h ver_utils.h vf_resolve.cpp
Date Wed, 08 Aug 2007 06:15:13 GMT
Author: mloenko
Date: Tue Aug  7 23:15:12 2007
New Revision: 563763

URL: http://svn.apache.org/viewvc?view=rev&rev=563763
Log:
fixing HARMONY-4579 (crash of jdtcoremodel suite 'dom' from EUT3.3)

Modified:
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/Pass2.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/Ver.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/tpool.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/tpool.h
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/ver_utils.h
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/vf_resolve.cpp

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/Pass2.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/Pass2.cpp?view=diff&rev=563763&r1=563762&r2=563763
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/Pass2.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/Pass2.cpp Tue Aug  7 23:15:12
2007
@@ -2175,8 +2175,8 @@
                 // create hash entry for checked class
                 cc->source = string->NewHashEntry( constraint->source )->key;
 
-                cc->next = (CPVerifier::vf_TypeConstraint_t*)hash_entry->data;
-                hash_entry->data = cc;
+                cc->next = (CPVerifier::vf_TypeConstraint_t*)hash_entry->data_ptr;
+                hash_entry->data_ptr = cc;
             }
 
             // unlock data modification
@@ -2571,7 +2571,6 @@
 
         vf_Result vf_Context_t::popFieldRef(SmConstant expected_ref, unsigned short cp_idx)
{
             int check = tpool.checkFieldAccess( expected_ref, cp_idx);
-            if ( check == vf_TypePool::_BOGUS ) return error(VF_ErrorResolve, "can't resolve
constantpool class");
 
             if( check != vf_TypePool::_FALSE ) {
                 assert(check == vf_TypePool::_TRUE);
@@ -2592,7 +2591,6 @@
 
         vf_Result vf_Context_t::popVirtualRef(SmConstant expected_ref, unsigned short cp_idx)
{
             int check = tpool.checkVirtualAccess( expected_ref, cp_idx);
-            if ( check == vf_TypePool::_BOGUS ) return error(VF_ErrorResolve, "can't resolve
constantpool class");
 
             if( check != vf_TypePool::_FALSE ) {
                 if( !workmap_can_pop(1) ) return error(VF_ErrorDataFlow, "unable to pop from
empty operand stack");

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/Ver.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/Ver.cpp?view=diff&rev=563763&r1=563762&r2=563763
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/Ver.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/Ver.cpp Tue Aug  7 23:15:12 2007
@@ -96,13 +96,13 @@
 
     // get constraints for class
     vf_HashEntry_t *hash_entry = hash->Lookup( class_get_name( klass ) );
-    if( !hash_entry || !hash_entry->data ) {
+    if( !hash_entry || !hash_entry->data_ptr ) {
         // no constraint data
         return VF_OK;
     }
 
     // check method constraints
-    vf_TypeConstraint_t *constraint = (vf_TypeConstraint_t*)hash_entry->data;
+    vf_TypeConstraint_t *constraint = (vf_TypeConstraint_t*)hash_entry->data_ptr;
     for( ; constraint; constraint = constraint->next )
     {
         vf_Result result = vf_force_check_constraint( klass, constraint );

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/tpool.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/tpool.cpp?view=diff&rev=563763&r1=563762&r2=563763
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/tpool.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/tpool.cpp Tue Aug  7 23:15:12
2007
@@ -24,12 +24,10 @@
 
 namespace CPVerifier {
 
-    vf_TypePool::vf_TypePool(vf_Context_t *_context, unsigned init_table_size)
-        : context(_context), k_class(_context->k_class), tableIncr(init_table_size),
-        tableSize(init_table_size), currentTypeId(0)
+    vf_TypePool::vf_TypePool(vf_Context_t *_context, unsigned table_incr)
+        : context(_context), k_class(_context->k_class), tableIncr(table_incr),
+        validTypesTableMax(0), validTypesTableSz(1), validTypes(0)
     {
-        validTypes = (vf_ValidType *)tc_malloc(sizeof(vf_ValidType)*tableIncr);
-
         const_object = const_class = const_string = const_throwable = const_arrayref_of_bb
=
             const_arrayref_of_char = const_arrayref_of_double = const_arrayref_of_float =
             const_arrayref_of_integer = const_arrayref_of_long = const_arrayref_of_short
= 
@@ -52,13 +50,10 @@
         //TODO: this assert raise false alarms when type name starts with 'L'
         //assert(type_name[0] != 'L');
 
-        int index = -1;
         // find type in hash
         vf_HashEntry_t *entry = hash.NewHashEntry( type_name, length );
-        if( entry->data ) {
-            index = (int)((vf_ValidType*)entry->data - validTypes);
-            assert(index >= 0 && (unsigned)index < tableSize);
-        } else {
+        unsigned index = entry->data_index;
+        if( !index ) {
             //convert array of booleans to array of bytes
             if( is_bool_array_conv_needed(type_name, length) ) {
                 char *new_name = (char*)context->mem.malloc(length+1);
@@ -68,13 +63,15 @@
                 context->mem.dealloc_last(new_name, length+1);
             }
             // Get next free table entry index
-            if( index == -1 ) {
+            if( !index ) {
                 index = check_table();
-                (validTypes+index)->cls = 0;
-                (validTypes+index)->name = entry->key;
+                validTypes[index].cls = 0;
+                validTypes[index].name = entry->key;
             }
-            entry->data = (void*)(validTypes+index);
+            entry->data_index = index;
         }
+
+        assert(index < validTypesTableSz);
         return SmConstant::getReference(index);
     }
 
@@ -188,8 +185,8 @@
     int vf_TypePool::ref_mustbe_assignable(SmConstant from, SmConstant to) {
         if( to == sm_get_const_object() ) return true;
 
-        vf_ValidType *to_type = &validTypes[to.getReferenceIdx()];
-        vf_ValidType *from_type = &validTypes[from.getReferenceIdx()];
+        vf_ValidType *to_type = getVaildType(to.getReferenceIdx());
+        vf_ValidType *from_type = getVaildType(from.getReferenceIdx());
 
         const char *to_name = to_type->name;
         const char *from_name = from_type->name;
@@ -264,36 +261,30 @@
     //check if expected_ref is a super class of 'this', its package differs
     int vf_TypePool::checkSuperAndPackage(SmConstant expected_ref) {
         //check that expected ref is a super of 'this'
-        vf_ValidType *expected_type = &validTypes[expected_ref.getReferenceIdx()];
-
-        if (!class_is_extending_class(k_class, (char*)expected_type->name)) {
-            return _FALSE;
-        }
-
+        vf_ValidType *expected_type = getVaildType(expected_ref.getReferenceIdx());
         class_handler &referred = expected_type->cls;
 
-        if( !referred || referred == CLASS_NOT_LOADED ) {
-            //we need to ersolve class here
-            referred = vf_resolve_class(k_class, expected_type->name, true);
-
-            //referred class can't be resolved ==> return anything
-            if( !referred ) return _BOGUS;
+        if( referred == CLASS_NOT_LOADED ) {
+            //referred class can't be resolved ==> it's not a super class
+            return false;
         }
 
-        //check that they are in different packages and method is protected
-        if( class_is_same_package(k_class, referred) ) {
-            return _FALSE;
+        if( !referred ) {
+            //try to get class here
+            referred = vf_resolve_class(k_class, expected_type->name, false);
+
+            //referred class can't be resolved ==> it's not a super class
+            if( !referred ) return false;
         }
 
-        return _TRUE;
+        return !class_is_same_package(k_class, referred) && vf_is_extending(k_class,
referred);
     }
 
     //check if expected_ref is a super class of 'this', its package differs, and it's protected
     int vf_TypePool::checkVirtualAccess(SmConstant expected_ref, unsigned short method_idx)
{
         //check if expected_ref is a super class of 'this', its package differs
-        int sp;
-        if( (sp = checkSuperAndPackage(expected_ref)) != _TRUE ) {
-            return sp;
+        if( !checkSuperAndPackage(expected_ref) ) {
+            return _FALSE;
         }
 
         //check further
@@ -312,9 +303,8 @@
     //check if expected_ref is a super class of 'this', its package differs, and it's protected
     int vf_TypePool::checkFieldAccess(SmConstant expected_ref, unsigned short field_idx)
{
         //check if expected_ref is a super class of 'this', its package differs
-        int sp;
-        if( (sp = checkSuperAndPackage(expected_ref)) != _TRUE ) {
-            return sp;
+        if( !checkSuperAndPackage(expected_ref) ) {
+            return _FALSE;
         }
 
         //check further

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/tpool.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/tpool.h?view=diff&rev=563763&r1=563762&r2=563763
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/tpool.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/tpool.h Tue Aug  7 23:15:12 2007
@@ -1,4 +1,4 @@
-/*
+/*
  *  Licensed to the Apache Software Foundation (ASF) under one or more
  *  contributor license agreements.  See the NOTICE file distributed with
  *  this work for additional information regarding copyright ownership.
@@ -69,10 +69,10 @@
     class vf_TypePool {
 
     public:
-        vf_TypePool(vf_Context_t *_context, unsigned init_table_size);
+        vf_TypePool(vf_Context_t *_context, unsigned table_incr);
 
         ~vf_TypePool() {
-            tc_free(validTypes);
+            if( validTypes ) tc_free(validTypes);
         }
 
         SmConstant cpool_get_ldcarg(unsigned short cp_idx);
@@ -104,16 +104,19 @@
         int ref_mustbe_assignable(SmConstant from, SmConstant to);
 
 
+        vf_ValidType *getVaildType(unsigned index) {
+            assert(index && validTypes && index < validTypesTableSz);
+            return validTypes + index;
+        }
+
         class_handler sm_get_handler(SmConstant type) {
             unsigned index = type.getReferenceIdx();
-            assert(index <= currentTypeId);
-            return (validTypes+index)->cls;
+            return getVaildType(index)->cls;
         }
 
         const char* sm_get_refname(SmConstant type) {
             unsigned index = type.getReferenceIdx();
-            assert(index <= currentTypeId);
-            return (validTypes+index)->name;
+            return getVaildType(index)->name;
         }
 
         //return SmConstant (known verification type) corresponding to 'type_name' and cache
result in the 'cache'
@@ -235,7 +238,7 @@
         }
 
         //check if expected_ref is a super class of 'this', its package differs, and it's
protected
-        enum FieldAndMethodCheck {_FALSE, _CLONE, _BOGUS, _TRUE};
+        enum FieldAndMethodCheck {_FALSE, _CLONE, _TRUE};
         int checkFieldAccess(SmConstant expected_ref, unsigned short method_idx);
         int checkVirtualAccess(SmConstant expected_ref, unsigned short method_idx);
         int checkSuperAndPackage(SmConstant expected_ref);
@@ -253,8 +256,8 @@
         vf_Hash hash;
         vf_ValidType *validTypes;
         unsigned tableIncr;
-        unsigned tableSize;
-        unsigned currentTypeId;
+        unsigned validTypesTableMax;
+        unsigned validTypesTableSz;
 
         /*****************/
         //cache for SmConstant constants;
@@ -269,10 +272,11 @@
         //Get next free table entry index.
         //Reallocate table if out of free entries.
         unsigned check_table() {
-            if( currentTypeId == tableSize - 1) {
-                validTypes = (vf_ValidType*)tc_realloc(validTypes, tableSize+=tableIncr);
+            if( validTypesTableSz + 1 >= validTypesTableMax ) {
+                validTypesTableMax += tableIncr;
+                validTypes = (vf_ValidType*)tc_realloc(validTypes, sizeof(vf_ValidType) *
validTypesTableMax);
             }
-            return currentTypeId++;
+            return validTypesTableSz++;
         }
 
         int is_bool_array_conv_needed(const char *type_name, int length);
@@ -281,6 +285,7 @@
 
     class_handler vf_resolve_class( class_handler k_class, const char *name, bool need_load);
     int vf_is_valid(class_handler from, class_handler to);
+    int vf_is_extending(class_handler from, class_handler to);
 
 } // namespace CPVerifier
 

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/ver_utils.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/ver_utils.h?view=diff&rev=563763&r1=563762&r2=563763
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/ver_utils.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/ver_utils.h Tue Aug  7 23:15:12
2007
@@ -66,12 +66,13 @@
     struct vf_HashEntry_t {
         const char *key;            // hash entry key
         int key_size;               // hash entry key size
-        void *data;                 // pointer to hash entry data
+        union {                     // hash entry data
+            unsigned data_index;    // when it's an index
+            void* data_ptr;         // when it's data
+        };
         vf_HashEntry_t *next;       // next hash entry
     };
 
-
-
     class Stack {
     protected:
         int max_depth;
@@ -341,7 +342,10 @@
                 hash_entry->key = hash_key;
                 hash_entry->key_size = length;
                 hash_entry->next = m_hash[hash_index];
-                hash_entry->data = 0;
+
+                hash_entry->data_ptr = 0;
+                hash_entry->data_index = 0;
+
                 m_hash[hash_index] = hash_entry;
             }
 

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/vf_resolve.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/vf_resolve.cpp?view=diff&rev=563763&r1=563762&r2=563763
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/vf_resolve.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/vf_resolve.cpp Tue Aug  7 23:15:12
2007
@@ -61,6 +61,13 @@
             return true;
         }
 
+        return vf_is_extending(from, to);
+    }
+
+    /**
+    * Returns true if 'from' is (not necessarily directly) extending 'to'
+    */
+    int vf_is_extending(class_handler from, class_handler to) {
         while (from) {
             if( from == to ) return true;
             from = class_get_super_class(from);
@@ -76,18 +83,26 @@
         const char *name,         // resolved class name
         bool need_load)      // load flag
     {
-        // get class loader
-        classloader_handler class_loader = class_get_class_loader( k_class );
-
-        // receive class
-        class_handler result;
         if( need_load ) {
-            result = cl_load_class( class_loader, name );
+            return cl_load_class( class_get_class_loader( k_class ), name );
         } else {
-            result = cl_get_class( class_loader, name );
-        }
+            // get class loader
+            classloader_handler class_loader = 0;
+            class_handler sup = k_class;
 
-        return result;
+            while( sup ) {
+                classloader_handler class_loader2 = class_get_class_loader( k_class );
+                if( class_loader != class_loader2 ) {
+                    class_loader = class_loader2;
+                    class_handler result = cl_get_class( class_loader, name );
+                    if( result ) {
+                        return result;
+                    }
+                }
+                sup = class_get_super_class(sup);
+            }
+            return 0;
+        }
     } // vf_resolve_class
 
 } // namespace CPVerifier



Mime
View raw message