harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcfi...@apache.org
Subject svn commit: r649574 [3/6] - in /harmony/enhanced/drlvm/trunk: ./ make/vm/ vm/include/open/ vm/vmcore/include/ vm/vmcore/src/verifier-3363/base/ vm/vmcore/src/verifier-3363/java5/ vm/vmcore/src/verifier-3363/java6/ vm/vmcore/src/verifier-3363/x_verifier/
Date Fri, 18 Apr 2008 15:29:41 GMT
Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/base/tpool.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/base/tpool.h?rev=649574&r1=649573&r2=649574&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/base/tpool.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/base/tpool.h Fri Apr 18 08:29:36 2008
@@ -14,10 +14,6 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-/** 
- * @author Mikhail Loenko, Vladimir Molotkov
- */  
-
 #ifndef __TPOOL_H_
 #define __TPOOL_H_
 
@@ -28,263 +24,259 @@
 #include "memory.h"
 #include "ver_utils.h"
 
-namespace CPVerifier {
-
-    /**
-    * Verification type constraint structure.
-    */
-    struct vf_TypeConstraint {
-        const char *source;         // constraint source class name
-        const char *target;         // constraint target class name
-        vf_TypeConstraint *next;  // next constraint
-    };
-    typedef vf_TypeConstraint* vf_TypeConstraint_p;
-
-    //verifier's data stored in classloader
-    typedef struct {
-        Memory    *pool;        // constraint memory pool
-        vf_Hash *hash;        // constraint hash table
-        vf_Hash *string;      // string pool hash table
-    } vf_ClassLoaderData_t;
-
-
-    struct vf_ValidType {
-        Class_Handle cls;      //class handler
-        const char*  name;     //name of the class
-    };
+/**
+ * Verification type constraint structure.
+ */
+struct vf_TypeConstraint {
+    const char *source;         // constraint source class name
+    const char *target;         // constraint target class name
+    vf_TypeConstraint *next;  // next constraint
+};
+typedef vf_TypeConstraint* vf_TypeConstraint_p;
+
+//verifier's data stored in classloader
+typedef struct {
+    Memory    *pool;        // constraint memory pool
+    vf_Hash *hash;        // constraint hash table
+    vf_Hash *string;      // string pool hash table
+} vf_ClassLoaderData_t;
+
+
+struct vf_ValidType {
+    Class_Handle cls;      //class handler
+    const char*  name;     //name of the class
+};
 
 #define CLASS_NOT_LOADED ((Class_Handle)-1)
 
-    class SharedClasswideData;
-
-    /**
-    * utility class for dealing with Java types, converting object references to SmConstant,
-    * parsing constantpool, etc
-    * TODO: remove constant pool parse and verification from the bytecode verifier
-    */
-    class vf_TypePool {
-
-    public:
-        vf_TypePool(SharedClasswideData *_classwide, Class_Handle _klass, unsigned table_incr);
-
-        ~vf_TypePool() {
-            if( validTypes ) tc_free(validTypes);
-        }
-
-        SmConstant cpool_get_ldcarg(unsigned short cp_idx);
-        SmConstant cpool_get_ldc2arg(unsigned short cp_idx);
-        int cpool_is_reftype(unsigned short cp_idx);
-        int cpool_get_class(unsigned short cp_idx, SmConstant *ref, int expected_dim = 0);
-
-        int cpool_get_array(unsigned short cp_idx, SmConstant *ref);
-        int cpool_get_field(unsigned short cp_idx, SmConstant *ref, SmConstant *value);
-        int cpool_method_start(unsigned short cp_idx, const char **state, SmConstant *objectref,
-            unsigned short *name_idx, int opcode);
-        int cpool_method_get_rettype(const char **state, SmConstant *rettype, int *args_sz);
-        int cpool_method_next_arg(const char **state, SmConstant *argument);
-        int cpool_method_is_constructor_call(unsigned short name_idx);
-
-
-        SmConstant get_type(const char *type_name, int name_len);
-        SmConstant get_ref_type(const char *type_name, int name_len);
-        SmConstant get_primitive_type(const char type_char);
-        SmConstant get_ref_from_array(SmConstant element);
-
-
-        SmConstant get_type(const char *type_name) {
-            return get_type(type_name, (int)strlen(type_name) );
-        }
-
-        SmConstant get_ref_type(const char *type_name) {
-            return get_ref_type(type_name, (int)strlen(type_name) );
-        }
-
-        int mustbe_assignable(SmConstant from, SmConstant to);
-        int ref_mustbe_assignable(SmConstant from, SmConstant to);
-
-
-        vf_ValidType *getVaildType(unsigned index) {
-            assert(index && validTypes && index < validTypesTableSz);
-            return validTypes + index;
-        }
-
-        Class_Handle sm_get_handler(SmConstant type) {
-            unsigned index = type.getReferenceIdx();
-            return getVaildType(index)->cls;
-        }
-
-        const char* sm_get_refname(SmConstant type) {
-            unsigned index = type.getReferenceIdx();
-            return getVaildType(index)->name;
-        }
-
-        //return SmConstant (known verification type) corresponding to 'type_name' and cache result in the 'cache'
-        SmConstant sm_get_const_existing(const char* type_name, SmConstant* cache) {
-            if( (*cache) == SM_NONE ) {
-                //TODO: check asm code for strlen
-                (*cache) = get_ref_type(type_name, (int)strlen(type_name));
-            }
-            return (*cache);
-        }
-
-        //return SmConstant (known verification type) corresponding to the super class of the class being verified
-        //returned value is cached
-        SmConstant sm_get_const_super() {
-            const char* _super = class_get_name( class_get_super_class( k_class ));
-            return get_ref_type(_super, (int)strlen(_super) );
-        }
-
-        //return SmConstant (known verification type) corresponding to the class being verified
-        //returned value is cached
-        SmConstant sm_get_const_this() {
-            return sm_get_const_existing(class_get_name(k_class), &const_this);
-        }
-
-        //return SmConstant (known verification type) corresponding to java/lang/Object
-        //returned value is cached
-        SmConstant sm_get_const_object() {
-            return sm_get_const_existing("java/lang/Object", &const_object);
-        }
-
-        //return SmConstant (known verification type) corresponding to java/lang/Class
-        //returned value is cached
-        SmConstant sm_get_const_class() {
-            return sm_get_const_existing("java/lang/Class", &const_class);
-        }
-
-        //return SmConstant (known verification type) corresponding to java/lang/String
-        //returned value is cached
-        SmConstant sm_get_const_string() {
-            return sm_get_const_existing("java/lang/String", &const_string);
-        }
-
-        //return SmConstant (known verification type) corresponding to java/lang/Throwable
-        //returned value is cached
-        SmConstant sm_get_const_throwable() {
-            return sm_get_const_existing("java/lang/Throwable", &const_throwable);
-        }
-
-        //return SmConstant (known verification type) corresponding to uint8[]
-        //returned value is cached
-        SmConstant sm_get_const_arrayref_of_bb() {
-            return sm_get_const_existing("[B", &const_arrayref_of_bb);
-        }
-
-        //return SmConstant (known verification type) corresponding to char[]
-        //returned value is cached
-        SmConstant sm_get_const_arrayref_of_char() {
-            return sm_get_const_existing("[C", &const_arrayref_of_char);
-        }
-
-        //return SmConstant (known verification type) corresponding to double[]
-        //returned value is cached
-        SmConstant sm_get_const_arrayref_of_double() {
-            return sm_get_const_existing("[D", &const_arrayref_of_double);
-        }
-
-        //return SmConstant (known verification type) corresponding to float[]
-        //returned value is cached
-        SmConstant sm_get_const_arrayref_of_float() {
-            return sm_get_const_existing("[F", &const_arrayref_of_float);
-        }
-
-        //return SmConstant (known verification type) corresponding to int[]
-        //returned value is cached
-        SmConstant sm_get_const_arrayref_of_integer() {
-            return sm_get_const_existing("[I", &const_arrayref_of_integer);
-        }
-
-        //return SmConstant (known verification type) corresponding to long[]
-        //returned value is cached
-        SmConstant sm_get_const_arrayref_of_long() {
-            return sm_get_const_existing("[J", &const_arrayref_of_long);
-        }
-
-        //return SmConstant (known verification type) corresponding to short[]
-        //returned value is cached
-        SmConstant sm_get_const_arrayref_of_short() {
-            return sm_get_const_existing("[S", &const_arrayref_of_short);
-        }
-
-        //return SmConstant (known verification type) corresponding to Object[]
-        //returned value is cached
-        SmConstant sm_get_const_arrayref_of_object() {
-            return sm_get_const_existing("[Ljava/lang/Object;", &const_arrayref_of_object);
-        }
-
-        //return SmConstant represented array of specified type
-        //the type is specified in the OP_NEWARRAY instruction. See the spec for possible types
-        SmConstant sm_get_const_arrayref(uint8 see_spec) {
-            switch ( see_spec ) {
-        case 4: //T_BOOLEAN
-        case 8: //T_BYTE
-            return sm_get_const_arrayref_of_bb();
-        case 5: //T_CHAR
-            return sm_get_const_arrayref_of_char();
-        case 6: //T_FLOAT
-            return sm_get_const_arrayref_of_float();
-        case 7: //T_DOUBLE
-            return sm_get_const_arrayref_of_double();
-        case 9: //T_SHORT
-            return sm_get_const_arrayref_of_short();
-        case 10: //T_INT
-            return sm_get_const_arrayref_of_integer();
-        case 11: //T_LONG
-            return sm_get_const_arrayref_of_long();
-            }
-            assert(0);
-            return SM_BOGUS;
-        }
-
-        //check if expected_ref is a super class of 'this', its package differs, and it's protected
-        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);
-    private:
-        //ref to the main class of the verifier
-        SharedClasswideData *classwide;
-
-        //class handler of the class being verified
-        Class_Handle k_class;
-
-        //constantpool length
-        unsigned k_cp_length;
-
-        //hash table storing class names
-        vf_Hash hash;
-        vf_ValidType *validTypes;
-        unsigned tableIncr;
-        unsigned validTypesTableMax;
-        unsigned validTypesTableSz;
-
-        /*****************/
-        //cache for SmConstant constants;
-        SmConstant 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,
-            const_arrayref_of_object, const_this;
-
-
-        void NewConstraint(const char *available, const char *required);
-
-        //Get next free table entry index.
-        //Reallocate table if out of free entries.
-        unsigned check_table() {
-            if( validTypesTableSz + 1 >= validTypesTableMax ) {
-                validTypesTableMax += tableIncr;
-                validTypes = (vf_ValidType*)tc_realloc(validTypes, sizeof(vf_ValidType) * validTypesTableMax);
-            }
-            return validTypesTableSz++;
-        }
+class SharedClasswideData;
 
-        int is_bool_array_conv_needed(const char *type_name, int length);
+/**
+ * Utility class for dealing with Java types, converting object references to SmConstant,
+ * parsing constantpool, etc.
+ * TODO: remove constant pool parse and verification from the bytecode verifier.
+ */
+class vf_TypePool {
+
+public:
+    vf_TypePool(SharedClasswideData *_classwide, Class_Handle _klass, unsigned table_incr);
+
+    ~vf_TypePool() {
+        if( validTypes ) tc_free(validTypes);
+    }
+
+    SmConstant cpool_get_ldcarg(unsigned short cp_idx);
+    SmConstant cpool_get_ldc2arg(unsigned short cp_idx);
+    int cpool_is_reftype(unsigned short cp_idx);
+    int cpool_get_class(unsigned short cp_idx, SmConstant *ref, int expected_dim = 0);
+
+    int cpool_get_array(unsigned short cp_idx, SmConstant *ref);
+    int cpool_get_field(unsigned short cp_idx, SmConstant *ref, SmConstant *value);
+    int cpool_method_start(unsigned short cp_idx, const char **state, SmConstant *objectref,
+        unsigned short *name_idx, int opcode);
+    int cpool_method_get_rettype(const char **state, SmConstant *rettype, int *args_sz);
+    int cpool_method_next_arg(const char **state, SmConstant *argument);
+    int cpool_method_is_constructor_call(unsigned short name_idx);
+
+
+    SmConstant get_type(const char *type_name, int name_len);
+    SmConstant get_ref_type(const char *type_name, int name_len);
+    SmConstant get_primitive_type(const char type_char);
+    SmConstant get_ref_from_array(SmConstant element);
+
+
+    SmConstant get_type(const char *type_name) {
+        return get_type(type_name, (int)strlen(type_name) );
+    }
+
+    SmConstant get_ref_type(const char *type_name) {
+        return get_ref_type(type_name, (int)strlen(type_name) );
+    }
+
+    int mustbe_assignable(SmConstant from, SmConstant to);
+    int ref_mustbe_assignable(SmConstant from, SmConstant to);
+
+
+    vf_ValidType *getVaildType(unsigned index) {
+        assert(index && validTypes && index < validTypesTableSz);
+        return validTypes + index;
+    }
+
+    Class_Handle sm_get_handler(SmConstant type) {
+        unsigned index = type.getReferenceIdx();
+        return getVaildType(index)->cls;
+    }
+
+    const char* sm_get_refname(SmConstant type) {
+        unsigned index = type.getReferenceIdx();
+        return getVaildType(index)->name;
+    }
+
+    //return SmConstant (known verification type) corresponding to 'type_name' and cache result in the 'cache'
+    SmConstant sm_get_const_existing(const char* type_name, SmConstant* cache) {
+        if( (*cache) == SM_NONE ) {
+            //TODO: check asm code for strlen
+            (*cache) = get_ref_type(type_name, (int)strlen(type_name));
+        }
+        return (*cache);
+    }
+
+    //return SmConstant (known verification type) corresponding to the super class of the class being verified
+    //returned value is cached
+    SmConstant sm_get_const_super() {
+        const char* _super = class_get_name( class_get_super_class( k_class ));
+        return get_ref_type(_super, (int)strlen(_super) );
+    }
+
+    //return SmConstant (known verification type) corresponding to the class being verified
+    //returned value is cached
+    SmConstant sm_get_const_this() {
+        return sm_get_const_existing(class_get_name(k_class), &const_this);
+    }
+
+    //return SmConstant (known verification type) corresponding to java/lang/Object
+    //returned value is cached
+    SmConstant sm_get_const_object() {
+        return sm_get_const_existing("java/lang/Object", &const_object);
+    }
+
+    //return SmConstant (known verification type) corresponding to java/lang/Class
+    //returned value is cached
+    SmConstant sm_get_const_class() {
+        return sm_get_const_existing("java/lang/Class", &const_class);
+    }
+
+    //return SmConstant (known verification type) corresponding to java/lang/String
+    //returned value is cached
+    SmConstant sm_get_const_string() {
+        return sm_get_const_existing("java/lang/String", &const_string);
+    }
+
+    //return SmConstant (known verification type) corresponding to java/lang/Throwable
+    //returned value is cached
+    SmConstant sm_get_const_throwable() {
+        return sm_get_const_existing("java/lang/Throwable", &const_throwable);
+    }
+
+    //return SmConstant (known verification type) corresponding to uint8[]
+    //returned value is cached
+    SmConstant sm_get_const_arrayref_of_bb() {
+        return sm_get_const_existing("[B", &const_arrayref_of_bb);
+    }
+
+    //return SmConstant (known verification type) corresponding to char[]
+    //returned value is cached
+    SmConstant sm_get_const_arrayref_of_char() {
+        return sm_get_const_existing("[C", &const_arrayref_of_char);
+    }
+
+    //return SmConstant (known verification type) corresponding to double[]
+    //returned value is cached
+    SmConstant sm_get_const_arrayref_of_double() {
+        return sm_get_const_existing("[D", &const_arrayref_of_double);
+    }
+
+    //return SmConstant (known verification type) corresponding to float[]
+    //returned value is cached
+    SmConstant sm_get_const_arrayref_of_float() {
+        return sm_get_const_existing("[F", &const_arrayref_of_float);
+    }
+
+    //return SmConstant (known verification type) corresponding to int[]
+    //returned value is cached
+    SmConstant sm_get_const_arrayref_of_integer() {
+        return sm_get_const_existing("[I", &const_arrayref_of_integer);
+    }
+
+    //return SmConstant (known verification type) corresponding to long[]
+    //returned value is cached
+    SmConstant sm_get_const_arrayref_of_long() {
+        return sm_get_const_existing("[J", &const_arrayref_of_long);
+    }
+
+    //return SmConstant (known verification type) corresponding to short[]
+    //returned value is cached
+    SmConstant sm_get_const_arrayref_of_short() {
+        return sm_get_const_existing("[S", &const_arrayref_of_short);
+    }
+
+    //return SmConstant (known verification type) corresponding to Object[]
+    //returned value is cached
+    SmConstant sm_get_const_arrayref_of_object() {
+        return sm_get_const_existing("[Ljava/lang/Object;", &const_arrayref_of_object);
+    }
+
+    //return SmConstant represented array of specified type
+    //the type is specified in the OP_NEWARRAY instruction. See the spec for possible types
+    SmConstant sm_get_const_arrayref(uint8 see_spec) {
+        switch ( see_spec ) {
+    case 4: //T_BOOLEAN
+    case 8: //T_BYTE
+        return sm_get_const_arrayref_of_bb();
+    case 5: //T_CHAR
+        return sm_get_const_arrayref_of_char();
+    case 6: //T_FLOAT
+        return sm_get_const_arrayref_of_float();
+    case 7: //T_DOUBLE
+        return sm_get_const_arrayref_of_double();
+    case 9: //T_SHORT
+        return sm_get_const_arrayref_of_short();
+    case 10: //T_INT
+        return sm_get_const_arrayref_of_integer();
+    case 11: //T_LONG
+        return sm_get_const_arrayref_of_long();
+        }
+        assert(0);
+        return SM_BOGUS;
+    }
+
+    //check if expected_ref is a super class of 'this', its package differs, and it's protected
+    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);
+private:
+    //ref to the main class of the verifier
+    SharedClasswideData *classwide;
+
+    //class handler of the class being verified
+    Class_Handle k_class;
+
+    //constantpool length
+    unsigned k_cp_length;
+
+    //hash table storing class names
+    vf_Hash hash;
+    vf_ValidType *validTypes;
+    unsigned tableIncr;
+    unsigned validTypesTableMax;
+    unsigned validTypesTableSz;
+
+    /*****************/
+    //cache for SmConstant constants;
+    SmConstant 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,
+        const_arrayref_of_object, const_this;
+
+
+    void NewConstraint(const char *available, const char *required);
+
+    //Get next free table entry index.
+    //Reallocate table if out of free entries.
+    unsigned check_table() {
+        if( validTypesTableSz + 1 >= validTypesTableMax ) {
+            validTypesTableMax += tableIncr;
+            validTypes = (vf_ValidType*)tc_realloc(validTypes, sizeof(vf_ValidType) * validTypesTableMax);
+        }
+        return validTypesTableSz++;
+    }
 
-    };
+    int is_bool_array_conv_needed(const char *type_name, int length);
 
-    Class_Handle vf_resolve_class(Class_Handle k_class, const char* name, bool need_load);
-    int vf_is_extending(Class_Handle from, Class_Handle to);
+};
 
-} // namespace CPVerifier
+Class_Handle vf_resolve_class(Class_Handle k_class, const char* name, bool need_load);
+int vf_is_extending(Class_Handle from, Class_Handle to);
 
 #endif

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=649574&r1=649573&r2=649574&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 Fri Apr 18 08:29:36 2008
@@ -14,6 +14,7 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
+#include <stdio.h>
 #include "verifier.h"
 #include "../java5/context_5.h"
 #include "../java6/context_6.h"
@@ -23,15 +24,11 @@
 #include "open/vm_method_access.h"
 #include "open/vm_class_loading.h"
 
-using namespace CPVerifier;
-using namespace CPVerifier_5;
-using namespace CPVerifier_6;
-
 static char err_message[5000];
 
 
 /**
-* Function provides initial java-5 verification of class.
+* Provides initial java-5 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 
@@ -133,7 +130,7 @@
 
 
 /**
-* Function provides initial verification of class.
+* Provides initial verification of a 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 

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/base/ver_utils.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/base/ver_utils.h?rev=649574&r1=649573&r2=649574&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/base/ver_utils.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/base/ver_utils.h Fri Apr 18 08:29:36 2008
@@ -14,22 +14,16 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-/** 
- * @author Mikhail Loenko, Vladimir Molotkov
- */  
-
 #ifndef __VER_UTILS_H_
 #define __VER_UTILS_H_
 
 #include <assert.h>
 #include "open/types.h"
-#include <iostream>
-using namespace std;
 
-namespace CPVerifier {
+// convenience types
+typedef unsigned short Address;
 
-    // convenience types
-    typedef unsigned short Address;
+static const int BUFSIZE = 100;
 
     //TODO:
 #define tc_free(ptr)                free(ptr)
@@ -39,409 +33,406 @@
 #define tc_memcpy(ptr1, ptr2, sz)   vf_memcpy(ptr1, ptr2, sz)
 #define tc_memset(ptr, i1, i2)      vf_memset(ptr, i1, i2)
 
-    //TODO: delegate to compiler
-    inline void *vf_memcpy(void *dest, const void *src, size_t count) {
-        char *d = (char *)dest;
-        const char *s = (const char *)src;
-        for (; count; count--) {
-            *d++ = *s++;
-        }
-        return dest;
-    }
-
-    //TODO: delegate to compiler
-    inline void *vf_memset(void *dest, int val, size_t count) {
-        char *d = (char *)dest;
-        char v = (char) val;
-        for (; count; count--) {
-            *d++ = v;
-        }
-        return dest;
+//TODO: delegate to compiler
+inline void *vf_memcpy(void *dest, const void *src, size_t count) {
+    char *d = (char *)dest;
+    const char *s = (const char *)src;
+    for (; count; count--) {
+        *d++ = *s++;
     }
+    return dest;
+}
 
-    /**
-    * Structure of hash entry.
-    */
-    struct vf_HashEntry_t {
-        const char *key;            // hash entry key
-        int key_size;               // hash entry key size
-        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
+//TODO: delegate to compiler
+inline void *vf_memset(void *dest, int val, size_t count) {
+    char *d = (char *)dest;
+    char v = (char) val;
+    for (; count; count--) {
+        *d++ = v;
+    }
+    return dest;
+}
+
+/**
+* Structure of hash entry.
+*/
+struct vf_HashEntry_t {
+    const char *key;            // hash entry key
+    int key_size;               // hash entry key size
+    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
+};
 
-    template<typename T>
-    class Stack {
-    protected:
-        int max_depth;
-        T* stack;
-        int depth;
-
-    public:
-        Stack() :
-          max_depth(0), stack(0), depth(0)
-          {}
+template<typename T>
+class Stack {
+protected:
+    int max_depth;
+    T* stack;
+    int depth;
+
+public:
+    Stack() :
+      max_depth(0), stack(0), depth(0)
+      {}
+
+
+      ~Stack() {
+          tc_free(stack);
+      }
+
+      void push(T value) {
+          if( depth == max_depth ) {
+              assert(sizeof(T) < 4096);
+              max_depth += 4096/sizeof(T);
+              stack = (T*) tc_realloc(stack, sizeof(T) * max_depth);
+          }
 
+          stack[depth++] = value;
+      }
 
-          ~Stack() {
-              tc_free(stack);
-          }
+      T pop() {
+          assert(depth > 0);
+          return stack[--depth];
+      }
+
+      bool is_empty() {
+          return !depth;
+      }
+
+      void init() {
+          depth = 0;
+      }
+};
+
+template<typename T>
+class FastStack : Stack<T> {
+public:
+    FastStack() : fdepth(0) 
+    {}
+
+    void push(T value) {
+        if( fdepth < BUFSIZE ) {
+            buffer[fdepth++] = value;
+        } else {
+            Stack<T>::push(value);
+        }
+    }
 
-          void push(T value) {
-              if( depth == max_depth ) {
-                  assert(sizeof(T) < 4096);
-                  max_depth += 4096/sizeof(T);
-                  stack = (T*) tc_realloc(stack, sizeof(T) * max_depth);
-              }
+    T pop() {
+        assert(fdepth > 0);
+        return Stack<T>::is_empty() ? buffer[--fdepth] : Stack<T>::pop();
+    }
 
-              stack[depth++] = value;
-          }
+    bool is_empty() {
+        return !fdepth;
+    }
 
-          T pop() {
-              assert(depth > 0);
-              return stack[--depth];
-          }
+    void init() {
+        fdepth = 0;
+        Stack<T>::init();
+    }
 
-          bool is_empty() {
-              return !depth;
-          }
+    int get_depth() {
+        return fdepth < BUFSIZE ? fdepth : BUFSIZE + Stack<T>::depth;
+    }
 
-          void init() {
-              depth = 0;
-          }
-    };
+    T at(int d) {
+        assert(d < get_depth());
+        return d < BUFSIZE ? buffer[d] : Stack<T>::stack[d - BUFSIZE];
+    }
 
-    template<typename T>
-    class FastStack : Stack<T> {
-    public:
-        FastStack() : fdepth(0) 
-        {}
-
-        void push(T value) {
-            if( fdepth < BUFSIZE ) {
-                buffer[fdepth++] = value;
-            } else {
-                Stack<T>::push(value);
-            }
+    int instack(T other) {
+        int i;
+        for( i = 0; i < fdepth; i++ ) {
+            if( buffer[i] == other ) return true;
         }
-
-        T pop() {
-            assert(fdepth > 0);
-            return Stack<T>::is_empty() ? buffer[--fdepth] : Stack<T>::pop();
+        for( i = 0; i < Stack<T>::depth; i++ ) {
+            if( Stack<T>::stack[i] == other ) return true;
         }
+        return false;
+    }
 
-        bool is_empty() {
-            return !fdepth;
-        }
+private:
+    int fdepth;
+    T buffer[BUFSIZE];
+};
+
+class MarkableStack : public FastStack<Address> {
+    // contains the following entries:
+    // <address, mark> no mask means zero mark
+
+    // <non-zero address, 0> is pushed as {address}
+    // <0, 0> is pushed as {0, 0}
+    // <any address, non-zero mark> is pushed as {address, mark, 0}
+
+public:
+    void xPop(Address *addr, short *mark) {
+        *addr = pop();
+        *mark = (*addr) ? 0 : pop();
 
-        void init() {
-            fdepth = 0;
-            Stack<T>::init();
+        if( *mark ) {
+            *addr = pop();
         }
+    }
 
-        int get_depth() {
-            return fdepth < BUFSIZE ? fdepth : BUFSIZE + Stack<T>::depth;
+    void xPush(Address value) {
+        if( value ) { 
+            push(value);
+        } else {
+            push(0);
+            push(0);
         }
+    }
 
-        T at(int d) {
-            assert(d < get_depth());
-            return d < BUFSIZE ? buffer[d] : Stack<T>::stack[d - BUFSIZE];
-        }
+    void xPush(Address addr, short m) {
+        push(addr);
+        push(m);
+        push(0);
+    }
+};
 
-        int instack(T other) {
-            for( int i = 0; i < fdepth; i++ ) {
-                if( buffer[i] == other ) return true;
-            }
-            for( int i = 0; i < Stack<T>::depth; i++ ) {
-                if( Stack<T>::stack[i] == other ) return true;
-            }
-            return false;
+struct MemoryPageHead {
+    MemoryPageHead *next;
+    size_t size;
+
+    MemoryPageHead *get_next(size_t min_size, size_t max_size) {
+        assert(this);
+        MemoryPageHead *ret = this;
+        while ( ret->next && ret->next->size < min_size ) {
+            ret = ret->next;
         }
 
-    private:
-        static const int BUFSIZE = 100;
-        int fdepth;
-        T buffer[BUFSIZE];
-    };
+        return ret->next ? ret->next : (ret->next = create_next(max_size));
+    }
 
-    class MarkableStack : public FastStack<Address> {
-        // contains the following entries:
-        // <address, mark> no mask means zero mark
-
-        // <non-zero address, 0> is pushed as {address}
-        // <0, 0> is pushed as {0, 0}
-        // <any address, non-zero mark> is pushed as {address, mark, 0}
+    MemoryPageHead *create_next(size_t max_size) {
+        MemoryPageHead *ret =(MemoryPageHead*)tc_malloc(max_size + sizeof(MemoryPageHead));
+        ret->size = max_size;
+        ret->next = 0;
+        return ret;
+    }
+};
 
-    public:
-        void xPop(Address *addr, short *mark) {
-            *addr = pop();
-            *mark = (*addr) ? 0 : pop();
+static const int STATICSZ = 2000;
 
-            if( *mark ) {
-                *addr = pop();
-            }
-        }
+class Memory {
+    MemoryPageHead *static_page;
+    MemoryPageHead *current_page;
+
+    uint8           static_mem[STATICSZ + sizeof (MemoryPageHead) ];
+
+    size_t  page_size;
+    size_t  used;
+public:
+    Memory() 
+    {
+        //in 90% of cases no memory allocation will be required
+        static_page = (MemoryPageHead *)&static_mem;
+        static_page->next = 0;
+        static_page->size = STATICSZ;
 
-        void xPush(Address value) {
-            if( value ) { 
-                push(value);
-            } else {
-                push(0);
-                push(0);
-            }
-        }
+        init();
+    }
 
-        void xPush(Address addr, short m) {
-            push(addr);
-            push(m);
-            push(0);
+    ~Memory() {
+        current_page = static_page->next;
+        while (current_page) {
+            MemoryPageHead *next = current_page->next;
+            tc_free(current_page);
+            current_page = next;
         }
-    };
+    }
 
-    struct MemoryPageHead {
-        MemoryPageHead *next;
-        size_t size;
-
-        MemoryPageHead *get_next(size_t min_size, size_t max_size) {
-            assert(this);
-            MemoryPageHead *ret = this;
-            while ( ret->next && ret->next->size < min_size ) {
-                ret = ret->next;
-            }
+    void init() {
+        used = 0;
+        current_page = static_page;
+        page_size = current_page->size;
+    }
 
-            return ret->next ? ret->next : (ret->next = create_next(max_size));
-        }
+    void *malloc(size_t sz) {
+        size_t need_on_page = used + sz;
 
-        MemoryPageHead *create_next(size_t max_size) {
-            MemoryPageHead *ret =(MemoryPageHead*)tc_malloc(max_size + sizeof(MemoryPageHead));
-            ret->size = max_size;
-            ret->next = 0;
-            return ret;
-        }
-    };
+        if( need_on_page > page_size ) {
+            //create next page
 
-    class Memory {
-        MemoryPageHead *static_page;
-        MemoryPageHead *current_page;
-
-        static const int STATICSZ = 2000;
-        uint8           static_mem[STATICSZ + sizeof (MemoryPageHead) ];
-
-        size_t  page_size;
-        size_t  used;
-    public:
-        Memory() 
-        {
-            //in 90% of cases no memory allocation will be required
-            static_page = (MemoryPageHead *)&static_mem;
-            static_page->next = 0;
-            static_page->size = STATICSZ;
-
-            init();
-        }
-
-        ~Memory() {
-            current_page = static_page->next;
-            while (current_page) {
-                MemoryPageHead *next = current_page->next;
-                tc_free(current_page);
-                current_page = next;
-            }
-        }
+            //define new page size - some heuristic formula. subject to change
+            size_t desired_size = need_on_page + need_on_page/2 + 128;
 
-        void init() {
+            //allocating next page
+            current_page = current_page->get_next(sz, desired_size);
+            if( !static_page ) {
+                static_page = current_page;
+            }
             used = 0;
-            current_page = static_page;
             page_size = current_page->size;
         }
 
-        void *malloc(size_t sz) {
-            size_t need_on_page = used + sz;
-
-            if( need_on_page > page_size ) {
-                //create next page
+        void *ret = (uint8*)current_page + sizeof(MemoryPageHead) + used;
+        used += sz;
+        return ret;
+    }
 
-                //define new page size - some heuristic formula. subject to change
-                size_t desired_size = need_on_page + need_on_page/2 + 128;
+    void *calloc(size_t sz) {
+        void *ret = malloc(sz);
+        tc_memset(ret, 0, sz);
+        return ret;
+    }
 
-                //allocating next page
-                current_page = current_page->get_next(sz, desired_size);
-                if( !static_page ) {
-                    static_page = current_page;
-                }
-                used = 0;
-                page_size = current_page->size;
-            }
+    void dealloc_last(void* ptr, size_t sz) {
+        assert( ((uint8*)ptr) + sz == (uint8*)current_page + sizeof(MemoryPageHead) + used );
+        used -= sz;
+    }
+};
 
-            void *ret = (uint8*)current_page + sizeof(MemoryPageHead) + used;
-            used += sz;
-            return ret;
-        }
+static const unsigned HASH_SIZE = 128;   ///< hash table size
+static const unsigned HASH_MASK = 127;   ///< hash table mask to avoid division
 
-        void *calloc(size_t sz) {
-            void *ret = malloc(sz);
-            tc_memset(ret, 0, sz);
-            return ret;
-        }
+/**
+* Verifier hash table structure.
+*/
+struct vf_Hash {
+public:
+    /**
+    * Hash table constructor.
+    * @note Function allocates memory for hash pool and hash table.
+    */
+    vf_Hash() 
+    {
+        memoryPool.init();
+        m_hash = (vf_HashEntry_t**)memoryPool.calloc(HASH_SIZE * sizeof(vf_HashEntry_t*));
+        assert((0xFFFFFFFF & HASH_MASK) + 1 == HASH_SIZE );
+    } // vf_Hash::vf_Hash
 
-        void dealloc_last(void* ptr, size_t sz) {
-            assert( ((uint8*)ptr) + sz == (uint8*)current_page + sizeof(MemoryPageHead) + used );
-            used -= sz;
-        }
-    };
 
     /**
-    * Verifier hash table structure.
+    * Function looks up hash entry which is identical to given hash key.
+    * @param key - given hash key
+    * @return Hash entry which is identical to given hash key.
+    * @see vf_HashEntry_t
     */
-    struct vf_Hash {
-    public:
-        /**
-        * Hash table constructor.
-        * @note Function allocates memory for hash pool and hash table.
-        */
-        vf_Hash() 
-        {
-            memoryPool.init();
-            m_hash = (vf_HashEntry_t**)memoryPool.calloc(HASH_SIZE * sizeof(vf_HashEntry_t*));
-            assert((0xFFFFFFFF & HASH_MASK) + 1 == HASH_SIZE );
-        } // vf_Hash::vf_Hash
-
-
-        /**
-        * Function looks up hash entry which is identical to given hash key.
-        * @param key - given hash key
-        * @return Hash entry which is identical to given hash key.
-        * @see vf_HashEntry_t
-        */
-        vf_HashEntry_t * Lookup( const char *key ) {
-            assert( key );
-            int length = (int)strlen(key);
-
-            unsigned hash_index = HashFunc( key, length );
-
-            vf_HashEntry_t *hash_entry = m_hash[hash_index];
-            while( hash_entry != NULL ) {
-                if( CheckKey( hash_entry, key, length ) ) {
-                    return hash_entry;
-                }
-                hash_entry = hash_entry->next;
+    vf_HashEntry_t * Lookup( const char *key ) {
+        assert( key );
+        int length = (int)strlen(key);
+
+        unsigned hash_index = HashFunc( key, length );
+
+        vf_HashEntry_t *hash_entry = m_hash[hash_index];
+        while( hash_entry != NULL ) {
+            if( CheckKey( hash_entry, key, length ) ) {
+                return hash_entry;
             }
-            return NULL;
-        } // vf_Hash::Lookup( key )
+            hash_entry = hash_entry->next;
+        }
+        return NULL;
+    } // vf_Hash::Lookup( key )
 
+    /**
+     * Creates a hash entry which is identical to a given hash key.
+     * @param key - given hash key
+     * @param length - length for the key
+     * @return Hash entry which are identical to given hash key.
+     * @see vf_HashEntry_t
+     * @note Created hash key and hash entry is allocated into hash memory pool.
+    */
+    vf_HashEntry_t * NewHashEntry( const char *key, int length ) {
+        // lookup type in hash
+        assert( key );
+        unsigned hash_index = HashFunc( key, length );
 
-        /**
-        * Function creates hash entry which is identical to given hash key.
-        * @param key - given hash key
-        * @param length - length for the key
-        * @return Hash entry which are identical to given hash key.
-        * @see vf_HashEntry_t
-        * @note Created hash key and hash entry is allocated into hash memory pool.
-        */
-        vf_HashEntry_t * NewHashEntry( const char *key, int length ) {
-            // lookup type in hash
-            assert( key );
-            unsigned hash_index = HashFunc( key, length );
-
-            vf_HashEntry_t *hash_entry = m_hash[hash_index];
-            while( hash_entry != NULL ) {
-                if( CheckKey( hash_entry, key, length ) ) {
-                    return hash_entry;
-                }
-                hash_entry = hash_entry->next;
+        vf_HashEntry_t *hash_entry = m_hash[hash_index];
+        while( hash_entry != NULL ) {
+            if( CheckKey( hash_entry, key, length ) ) {
+                return hash_entry;
             }
+            hash_entry = hash_entry->next;
+        }
 
-            if( !hash_entry ) {
-                // create key string
-                char *hash_key = (char*)memoryPool.malloc( (length & (~3)) + 4);
-                tc_memcpy( hash_key, key, length );
-                hash_key[length] = 0;
-
-                hash_entry = (vf_HashEntry_t*)memoryPool.malloc(sizeof(vf_HashEntry_t));
-                hash_entry->key = hash_key;
-                hash_entry->key_size = length;
-                hash_entry->next = m_hash[hash_index];
+        if( !hash_entry ) {
+            // create key string
+            char *hash_key = (char*)memoryPool.malloc( (length & (~3)) + 4);
+            tc_memcpy( hash_key, key, length );
+            hash_key[length] = 0;
 
-                hash_entry->data_ptr = 0;
-                hash_entry->data_index = 0;
+            hash_entry = (vf_HashEntry_t*)memoryPool.malloc(sizeof(vf_HashEntry_t));
+            hash_entry->key = hash_key;
+            hash_entry->key_size = length;
+            hash_entry->next = m_hash[hash_index];
 
-                m_hash[hash_index] = hash_entry;
-            }
+            hash_entry->data_ptr = 0;
+            hash_entry->data_index = 0;
 
-            return hash_entry;
-        } // vf_Hash::NewHashEntry( key, length )
+            m_hash[hash_index] = hash_entry;
+        }
 
-        /**
-        * Function creates hash entry which is identical to given hash key.
-        * @param key - given hash key
-        * @return Hash entry which are identical to given hash key.
-        * @see vf_HashEntry_t
-        * @note Created hash key and hash entry is allocated into hash memory pool.
-        */
-        vf_HashEntry_t * NewHashEntry( const char *key) {
-            return NewHashEntry(key, (int)strlen(key));
-        } // vf_Hash::NewHashEntry( key )
-
-    private:
-        static const unsigned HASH_SIZE = 128;   ///< hash table size
-        static const unsigned HASH_MASK = 127;   ///< hash table mask to avoid division
-
-        Memory memoryPool;
-        vf_HashEntry_t **m_hash;    ///< hash table
-
-        /**
-        * Function checks key identity.
-        * @param hash_entry - checked hash entry
-        * @param key        - checked key
-        * @return If keys are identical function returns <code>true</code>,
-        *         else returns <code>false</code>.
-        * @see vf_HashEntry_t
-        */
-        int CheckKey( vf_HashEntry_t *hash_entry, const char *key, int length) {
-            if( hash_entry->key_size != length ) return false;
+        return hash_entry;
+    } // vf_Hash::NewHashEntry( key, length )
 
-            const char* h_key = hash_entry->key; 
-            int idx = 0;
+    /**
+    * Function creates hash entry which is identical to given hash key.
+    * @param key - given hash key
+    * @return Hash entry which are identical to given hash key.
+    * @see vf_HashEntry_t
+    * @note Created hash key and hash entry is allocated into hash memory pool.
+    */
+    vf_HashEntry_t * NewHashEntry( const char *key) {
+        return NewHashEntry(key, (int)strlen(key));
+    } // vf_Hash::NewHashEntry( key )
+
+private:
+    Memory memoryPool;
+    vf_HashEntry_t **m_hash;    ///< hash table
 
-            for( ; idx < length - 3; idx += 4 ) {
-                if( *((uint32*) (key+idx) ) != *((uint32*) (h_key+idx) ) ) return false;
-            }
+    /**
+    * Function checks key identity.
+    * @param hash_entry - checked hash entry
+    * @param key        - checked key
+    * @return If keys are identical function returns <code>true</code>,
+    *         else returns <code>false</code>.
+    * @see vf_HashEntry_t
+    */
+    int CheckKey( vf_HashEntry_t *hash_entry, const char *key, int length) {
+        if( hash_entry->key_size != length ) return false;
 
-            for( ; idx < length; idx++) {
-                if( *(key+idx) != *(h_key+idx) ) return false;
-            }
+        const char* h_key = hash_entry->key; 
+        int idx = 0;
 
-            return true;
+        for( ; idx < length - 3; idx += 4 ) {
+            if( *((uint32*) (key+idx) ) != *((uint32*) (h_key+idx) ) ) return false;
         }
 
-        /**
-        * Hash function.
-        * @param key - key for hash function
-        * @return Hash index relevant to key.
-        */
-        unsigned HashFunc( const char *key, int length ) {
-            unsigned result = 0;
+        for( ; idx < length; idx++) {
+            if( *(key+idx) != *(h_key+idx) ) return false;
+        }
 
-            int idx = 0;
+        return true;
+    }
 
-            for( ; idx < length - 3; idx += 4 ) {
-                result += *((uint32*) (key+idx) );
-            }
+    /**
+    * Hash function.
+    * @param key - key for hash function
+    * @return Hash index relevant to key.
+    */
+    unsigned HashFunc( const char *key, int length ) {
+        unsigned result = 0;
 
-            for( ; idx < length; idx++) {
-                result += *(key+idx);
-            }
+        int idx = 0;
 
-            uint8 *bres = (uint8*) &result;
+        for( ; idx < length - 3; idx += 4 ) {
+            result += *((uint32*) (key+idx) );
+        }
 
-            return (bres[0] + bres[1] + bres[2] + bres[3]) & HASH_MASK;
-        } // vf_Hash::HashFunc( key )
+        for( ; idx < length; idx++) {
+            result += *(key+idx);
+        }
 
-    }; // struct vf_Hash
+        uint8 *bres = (uint8*) &result;
 
-} // namespace CPVerifier
+        return (bres[0] + bres[1] + bres[2] + bres[3]) & HASH_MASK;
+    } // vf_Hash::HashFunc( key )
 
+}; // struct vf_Hash
 
 #endif

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/base/vf_resolve.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/base/vf_resolve.cpp?rev=649574&r1=649573&r2=649574&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/base/vf_resolve.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/base/vf_resolve.cpp Fri Apr 18 08:29:36 2008
@@ -14,85 +14,74 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-/** 
- * @author Mikhail Loenko, Vladimir Molotkov
- */
-
 #include "open/vm_class_manipulation.h"
 #include "open/vm_class_loading.h"
 
 #include "verifier.h"
 #include "context_base.h"
-#include "time.h"
 
-namespace CPVerifier {
+/**
+ * Checkes constraint for given class and loads classes if it's needed.
+ */
+vf_Result vf_force_check_constraint(Class_Handle klass,
+    vf_TypeConstraint* constraint)    // class constraint
+{
+    // get target class
+    Class_Handle target = vf_resolve_class( klass, constraint->target, true );
+    if( !target ) {
+        return VF_ErrorLoadClass;
+    }
 
-    /**
-    * Function checkes constraint for given class.
-    * Function loads classes if it's needed.
-    */
-    vf_Result vf_force_check_constraint(Class_Handle klass,
-        vf_TypeConstraint* constraint)    // class constraint
-    {
-        // get target class
-        Class_Handle target = vf_resolve_class( klass, constraint->target, true );
-        if( !target ) {
-            return VF_ErrorLoadClass;
-        }
-
-        //no need to load the source
-        if(class_is_interface(target)){
-            return VF_OK;
-        }
-
-
-        // get stack reference class
-        Class_Handle source = vf_resolve_class( klass, constraint->source, true );
-        if( !source ) {
-            return VF_ErrorLoadClass;
-        }
-
-        // check restriction
-        if( !vf_is_extending( source, target ) ) {
-            return VF_ErrorIncompatibleArgument;
-        }
+    //no need to load the source
+    if(class_is_interface(target)){
         return VF_OK;
-    } // vf_force_check_constraint
+    }
 
 
-    /**
-    * Returns true if 'from' is (not necessarily directly) extending 'to'
-    */
-    int vf_is_extending(Class_Handle from, Class_Handle to) {
-        while (from) {
-            if( from == to ) return true;
-            from = class_get_super_class(from);
-        }
-        return false;
+    // get stack reference class
+    Class_Handle source = vf_resolve_class( klass, constraint->source, true );
+    if( !source ) {
+        return VF_ErrorLoadClass;
     }
 
-    /**
-    * Function receives class by given class name, loads it if it's needed.
-    */
-    Class_Handle
-        vf_resolve_class( Class_Handle k_class,    // current class
-        const char *name,         // resolved class name
-        bool need_load)      // load flag
-    {
-        Class_Handle result;
-
-        // get class loader
-        ClassLoaderHandle class_loader = class_get_class_loader( k_class );
-
-        result = need_load ?
-            class_loader_load_class( class_loader, name )
-            : class_loader_lookup_class( class_loader, name );
-
-        //we assume that this pre-defined constant is not a valid class-handler
-        assert(CLASS_NOT_LOADED != result);
-        
-        return result;
-    } // vf_resolve_class
+    // check restriction
+    if( !vf_is_extending( source, target ) ) {
+        return VF_ErrorIncompatibleArgument;
+    }
+    return VF_OK;
+} // vf_force_check_constraint
 
 
-} // namespace CPVerifier
+/**
+ * Returns true if 'from' is (not necessarily directly) extending 'to'.
+ */
+int vf_is_extending(Class_Handle from, Class_Handle to) {
+    while (from) {
+        if( from == to ) return true;
+        from = class_get_super_class(from);
+    }
+    return false;
+}
+
+/**
+ * Receives class by given class name, loads it if it's needed.
+ */
+Class_Handle
+    vf_resolve_class( Class_Handle k_class,    // current class
+    const char *name,         // resolved class name
+    bool need_load)      // load flag
+{
+    Class_Handle result;
+
+    // get class loader
+    ClassLoaderHandle class_loader = class_get_class_loader( k_class );
+
+    result = need_load ?
+        class_loader_load_class( class_loader, name )
+        : class_loader_lookup_class( class_loader, name );
+
+    //we assume that this pre-defined constant is not a valid class-handler
+    assert(CLASS_NOT_LOADED != result);
+    
+    return result;
+} // vf_resolve_class



Mime
View raw message