harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gshiman...@apache.org
Subject svn commit: r508525 [5/5] - in /harmony/enhanced/drlvm/trunk: build/custom/msvc_2003/vmcore/ vm/vmcore/src/verifier/
Date Fri, 16 Feb 2007 18:02:39 GMT
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=508525&r1=508524&r2=508525
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_real.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_real.h Fri Feb 16 10:02:37 2007
@@ -15,7 +15,7 @@
  *  limitations under the License.
  */
 /** 
- * @author Pavel Rebriy
+ * @author Pavel Rebriy, Alexei Fedotov
  * @version $Revision: 1.1.2.3.4.4 $
  */  
 
@@ -23,7 +23,11 @@
 #ifndef _VERIFIER_REAL_H_
 #define _VERIFIER_REAL_H_
 
-#include <stdlib.h>
+/**
+ * @file
+ * Verifier internal interfaces.
+ */
+
 #include <fstream>
 #include <sstream>
 #include <assert.h>
@@ -37,11 +41,6 @@
 using namespace std;
 
 /**
- * Set namespace Verifier.
- */
-namespace Verifier {
-
-/** 
  * Verifier defines.
  */
 //===========================================================
@@ -72,6 +71,12 @@
         stream << error_message;                    \
         vf_set_error_message( stream, (context) );  \
     }
+#define VERIFY_REPORT_METHOD(context, error_message )               \
+    VERIFY_REPORT(context,                                          \
+        "(class: " << class_get_name( (context)->m_class )          \
+        << ", method: " << method_get_name( (context)->m_method )   \
+        << method_get_descriptor( (context)->m_method )             \
+        << ") " << error_message )
 
 /**
  * Define source code line and source file name parameters and arguments.
@@ -88,37 +93,9 @@
 #define VERIFY_REPORT_SOURCE                ""
 #endif // _VERIFY_DEBUG
 
-/**
- * Macros hide source line and source file name function arguments.
- */
-#define vf_error()                                                  \
-    vf_error_func(VERIFY_SOURCE_ARGS0)
-#define vf_calloc(number, size_element)                             \
-    vf_calloc_func((number), (size_element), VERIFY_SOURCE_ARGS0)
-#define vf_malloc(size)                                             \
-    vf_malloc_func((size), VERIFY_SOURCE_ARGS0)
-#define vf_free(pointer)                                            \
-    vf_free_func((pointer), VERIFY_SOURCE_ARGS0)
-#define vf_realloc(pointer, resize)                                 \
-    vf_realloc_func((pointer), (resize), VERIFY_SOURCE_ARGS0)
-#define vf_create_pool()                                            \
-    vf_create_pool_func(VERIFY_SOURCE_ARGS0)
-#define vf_alloc_pool_memory(pool, size)                            \
-    vf_alloc_pool_memory_func((pool), (size), VERIFY_SOURCE_ARGS0)
-#define vf_clean_pool_memory(pool)                                  \
-    vf_clean_pool_memory_func((pool), VERIFY_SOURCE_ARGS0)
-#define vf_delete_pool(pool)                                        \
-    vf_delete_pool_func((pool), VERIFY_SOURCE_ARGS0)
-
-/**
- * Initial node mark in verifier graph.
- */
-#define VERIFY_START_MARK       1
-
-/**
- * Memory pool entry size.
- */
-#define VERIFY_POOL_ENTRY_SIZE  0x2000
+//===========================================================
+// Verifier contant pool checks
+//===========================================================
 
 /**
  * Constant pool checks.
@@ -126,98 +103,68 @@
 // for handler id = 0 is legal value
 #define CHECK_HANDLER_CONST_POOL_ID( id, len, context )                                 \
     if( (id) >= (len) ) {                                                               \
-        VERIFY_REPORT( context, "(class: " << class_get_name( (context)->m_class )      \
-            << ", method: " << method_get_name( (context)->m_method )                   \
-            << method_get_descriptor( (context)->m_method )                             \
-            << ") Illegal constant pool index in handler" );                            \
+        VERIFY_REPORT_METHOD( context, "Illegal constant pool index in handler" );      \
         return VER_ErrorHandler;                                                        \
     }
 // for handler id = 0 is legal value
 #define CHECK_HANDLER_CONST_POOL_CLASS( context, id )                                   \
     if( (id) && class_get_cp_tag( (context)->m_class, (id) ) != _CONSTANT_Class ) {     \
-        VERIFY_REPORT( context, "(class: " << class_get_name( (context)->m_class )      \
-            << ", method: " << method_get_name( (context)->m_method )                   \
-            << method_get_descriptor( (context)->m_method )                             \
-            << ") Illegal type in constant pool for handler, "                          \
+        VERIFY_REPORT_METHOD( context, "Illegal type in constant pool for handler, "    \
             << id << ": CONSTANT_Class is expected" );                                  \
         return VER_ErrorHandler;                                                        \
     }
 #define CHECK_CONST_POOL_ID( id, len, context )                                         \
     if( !(id) || (id) >= (len) ) {                                                      \
-        VERIFY_REPORT( context, "(class: " << class_get_name( (context)->m_class )      \
-            << ", method: " << method_get_name( (context)->m_method )                   \
-            << method_get_descriptor( (context)->m_method )                             \
-            << ") Illegal constant pool index" );                                       \
+        VERIFY_REPORT_METHOD( context, "Illegal constant pool index" );                 \
         return VER_ErrorConstantPool;                                                   \
     }
 #define CHECK_CONST_POOL_CLASS( context, id )                                           \
     if( class_get_cp_tag( (context)->m_class, (id) ) != _CONSTANT_Class ) {             \
-        VERIFY_REPORT( context, "(class: " << class_get_name( (context)->m_class )      \
-            << ", method: " << method_get_name( (context)->m_method )                   \
-            << method_get_descriptor( (context)->m_method )                             \
-            << ") Illegal type in constant pool, "                                      \
+        VERIFY_REPORT_METHOD( context, "Illegal type in constant pool, "                \
             << id << ": CONSTANT_Class is expected" );                                  \
         return VER_ErrorConstantPool;                                                   \
     }
 #define CHECK_CONST_POOL_METHOD( context, id )                                          \
     if( class_get_cp_tag( (context)->m_class, (id) ) != _CONSTANT_Methodref ) {         \
-        VERIFY_REPORT( context, "(class: " << class_get_name( (context)->m_class )      \
-            << ", method: " << method_get_name( (context)->m_method )                   \
-            << method_get_descriptor( (context)->m_method )                             \
-            << ") Illegal type in constant pool, "                                      \
+        VERIFY_REPORT_METHOD( context, "Illegal type in constant pool, "                \
             << id << ": CONSTANT_Methodref is expected" );                              \
         return VER_ErrorConstantPool;                                                   \
     }
 #define CHECK_CONST_POOL_INTERFACE( context, id )                                           \
     if( class_get_cp_tag( (context)->m_class, (id) ) != _CONSTANT_InterfaceMethodref ) {    \
-        VERIFY_REPORT( context, "(class: " << class_get_name( (context)->m_class )          \
-            << ", method: " << method_get_name( (context)->m_method )                       \
-            << method_get_descriptor( (context)->m_method )                                 \
-            << ") Illegal type in constant pool, "                                          \
+        VERIFY_REPORT_METHOD( context, "Illegal type in constant pool, "                    \
             << id << ": CONSTANT_InterfaceMethodref is expected" );                         \
         return VER_ErrorConstantPool;                                                       \
     }
 #define CHECK_CONST_POOL_FIELD( context, id )                                           \
     if( class_get_cp_tag( (context)->m_class, (id) ) != _CONSTANT_Fieldref ) {          \
-        VERIFY_REPORT( context, "(class: " << class_get_name( (context)->m_class )      \
-            << ", method: " << method_get_name( (context)->m_method )                   \
-            << method_get_descriptor( (context)->m_method )                             \
-            << ") Illegal type in constant pool, "                                      \
+        VERIFY_REPORT_METHOD( context, "Illegal type in constant pool, "                \
             << id << ": CONSTANT_Fieldref is expected" );                               \
         return VER_ErrorConstantPool;                                                   \
     }
 #define CHECK_CONST_POOL_TYPE( context, id )                                            \
     if( class_get_cp_tag( (context)->m_class, (id) ) != _CONSTANT_NameAndType ) {       \
-        VERIFY_REPORT( context, "(class: " << class_get_name( (context)->m_class )      \
-            << ", method: " << method_get_name( (context)->m_method )                   \
-            << method_get_descriptor( (context)->m_method )                             \
-            << ") Illegal type in constant pool, "                                      \
+        VERIFY_REPORT_METHOD( context, "Illegal type in constant pool, "                \
             << id << ": CONSTANT_NameAndType is expected" );                            \
         return VER_ErrorConstantPool;                                                   \
     }
 #define CHECK_CONST_POOL_STRING( context, id )                                          \
     if( class_get_cp_tag( (context)->m_class, (id) ) != _CONSTANT_String ) {            \
-        VERIFY_REPORT( context, "(class: " << class_get_name( (context)->m_class )      \
-            << ", method: " << method_get_name( (context)->m_method )                   \
-            << method_get_descriptor( (context)->m_method )                             \
-            << ") Illegal type in constant pool, "                                      \
+        VERIFY_REPORT_METHOD( context, "Illegal type in constant pool, "                \
             << id << ": CONSTANT_String is expected" );                                 \
         return VER_ErrorConstantPool;                                                   \
     }
 #define CHECK_CONST_POOL_UTF8( context, id )                                            \
     if( class_get_cp_tag( (context)->m_class, (id) ) != _CONSTANT_Utf8) {               \
-        VERIFY_REPORT( context, "(class: " << class_get_name( (context)->m_class )      \
-            << ", method: " << method_get_name( (context)->m_method )                   \
-            << method_get_descriptor( (context)->m_method )                             \
-            << ") Illegal type in constant pool, "                                      \
+        VERIFY_REPORT_METHOD( context, "Illegal type in constant pool, "                \
             << id << ": CONSTANT_Utf8 is expected" );                                   \
         return VER_ErrorConstantPool;                                                   \
     }
 
-/**
- * Verifier enums
- */
 //===========================================================
+// Verifier enums
+//===========================================================
+
 /**
  * Constraint check types enum.
  */
@@ -271,651 +218,282 @@
 } vf_MapType_t;
 
 /**
- * Code instruction flags enum.
+ * Each instruction has a descriptive bitmap.
  */
 typedef enum {
-    VF_FLAG_NONE = 0,
-    VF_FLAG_BEGIN_BASIC_BLOCK = 1,
-    VF_FLAG_START_ENTRY = 2,
-    VF_FLAG_END_ENTRY = 4,
-    VF_FLAG_HANDLER = 8,
-    VF_FLAG_RETURN = 16,
-    VF_FLAG_THROW = 32,
-    VF_FLAG_SUBROUTINE = 64
-} vf_InstructionFlag_t;
+    VF_TYPE_INSTR_NONE        = 0,
+    VF_TYPE_INSTR_RETURN      = 1,
+    VF_TYPE_INSTR_THROW       = 2,
+    VF_TYPE_INSTR_SUBROUTINE  = 3
+} vf_CodeType;
 
-/**
- * Verifier structures.
- */
 //===========================================================
+// Verifier predefined structures
+//===========================================================
+
 /**
- * Predefined structures
+ * @ingroup Handles
+ * The handle of the verifier context.
  */
+typedef const struct vf_Context* vf_ContextHandle;
+
 /// Verifier context structure.
 typedef struct vf_Context vf_Context_t;
+/// Verifier structure for a byte of a bytecode.
+typedef struct vf_BCode vf_BCode_t;
+/// Verifier valid types structure.
+typedef struct vf_ValidType vf_ValidType_t;
+/// Verifier stack map entry structure.
+typedef struct vf_MapEntry vf_MapEntry_t;
 /// Verifier code instruction structure.
-typedef struct vf_Code_s vf_Code_t;
-/// Graph node container structure
-typedef struct vf_NodeContainer_s vf_NodeContainer_t;
-/// Graph edge container structure
-typedef struct vf_EdgeContainer_s vf_EdgeContainer_t;
-/// Verifier graph structure.
-typedef struct vf_Graph vf_Graph_t;
-/// Verifier graph node structure.
-typedef struct vf_Node_s vf_Node_t;
-/// Verifier graph edge structure.
-typedef struct vf_Edge_s vf_Edge_t;
+typedef struct vf_Code vf_Code_t;
+/// Verifier constant pool parse structure.
+typedef union vf_Parse vf_Parse_t;
+/// Verifier graph structure declaration.
+class vf_Graph;
 /// Verifier type constraint structure.
-typedef struct vf_TypeConstraint_s vf_TypeConstraint_t;
+typedef struct vf_TypeConstraint vf_TypeConstraint_t;
 /// Verifier hash table structure.
 typedef struct vf_Hash vf_Hash_t;
 /// Verifier hash table entry structure.
-typedef struct vf_HashEntry_s vf_HashEntry_t;
+typedef struct vf_HashEntry vf_HashEntry_t;
 /// Verifier pool structure.
-typedef struct vf_VerifyPool_s vf_VerifyPool_t;
+typedef struct vf_VerifyPool vf_VerifyPool_t;
 /// Verifier pool internal structure.
-typedef struct vf_VerifyPoolInternal_s vf_VerifyPoolInternal_t;
+typedef struct vf_VerifyPoolInternal vf_VerifyPoolInternal_t;
+/// Verifier structure of class loader constraint data.
+typedef struct vf_ClassLoaderData vf_ClassLoaderData_t;
+
 
-/** 
- * Code instruction structures.
- */
 //===========================================================
-/**
- * Initial struct of bytecode instruction.
- */
-typedef struct {
-    unsigned *m_off;            ///< array of branches
-    unsigned m_instr;           ///< number of code instruction @see vf_Code_s
-    unsigned m_offcount : 31;   ///< number of branches
-    unsigned m_mark : 1;        ///< control flow branch flag
-} vf_Instr_t;
+// Verifier memory management functions diclarations
+//===========================================================
 
 /**
- * Valid types structure.
- */
-typedef struct {
-    unsigned number;          ///< number of types
-    const char *string[1];    ///< type array
-} vf_ValidType_t;
-
-/** 
- * Stack map entry structure.
+ * Memory pool entry size.
  */
-typedef struct {
-    vf_ValidType_t *m_vtype;        ///< valid type for reference
-    union {
-        unsigned m_new;             ///< program count of opcode new for uninitialized
-        unsigned m_pc;              ///< program count of return address for subroutine
-    };
-    union {
-        unsigned short m_local;     ///< number of local variable
-        unsigned short m_index;     ///< constant pool index for access check
-    };
-    unsigned short m_type : 5;      ///< stack map type @see vf_MapType_t
-    unsigned short m_ctype : 4;     ///< constraint type @see vf_CheckConstraint_t
-    unsigned short m_is_local : 1;  ///< local variable modify flag
-                                    ///< true - modify local, false - modify stack
-} vf_MapEntry_t;
+#define VERIFY_POOL_ENTRY_SIZE  0x2000
 
 /**
- * Complete struct of bytecode instructions.
+ * Macros hide source line and source file name function arguments.
  */
-struct vf_Code_s {
-    unsigned char *m_addr;          ///< address of bytecode instruction
-    unsigned *m_off;                ///< array of instruction branches
-    unsigned char *m_handler;       ///< array of instruction handlers
-    vf_MapEntry_t *m_invector;      ///< stack map IN instruction vector
-    vf_MapEntry_t *m_outvector;     ///< stack map OUT instruction vector
-    unsigned m_offcount;            ///< number of instruction branches
-    unsigned short m_minstack;      ///< minimal stack for instruction
-    unsigned short m_inlen;         ///< stack map IN instruction vector length
-    unsigned short m_outlen;        ///< stack map OUT instruction vector length
-    short m_stack;                  ///< stack change for instruction
-    unsigned m_base : 7;            ///< instruction flag @see vf_InstructionFlag_t
-};
+#define vf_error()                                                  \
+    vf_error_func(VERIFY_SOURCE_ARGS0)
+#define vf_calloc(number, size_element)                             \
+    vf_calloc_func((number), (size_element), VERIFY_SOURCE_ARGS0)
+#define vf_malloc(size)                                             \
+    vf_malloc_func((size), VERIFY_SOURCE_ARGS0)
+#define vf_free(pointer)                                            \
+    vf_free_func((pointer), VERIFY_SOURCE_ARGS0)
+#define vf_realloc(pointer, resize)                                 \
+    vf_realloc_func((pointer), (resize), VERIFY_SOURCE_ARGS0)
+#define vf_create_pool()                                            \
+    vf_create_pool_func(VERIFY_SOURCE_ARGS0)
+#define vf_alloc_pool_memory(pool, size)                            \
+    vf_alloc_pool_memory_func((pool), (size), VERIFY_SOURCE_ARGS0)
+#define vf_clean_pool_memory(pool)                                  \
+    vf_clean_pool_memory_func((pool), VERIFY_SOURCE_ARGS0)
+#define vf_delete_pool(pool)                                        \
+    vf_delete_pool_func((pool), VERIFY_SOURCE_ARGS0)
 
-/** 
- * Constant pool parse structure.
+/**
+ * Function performs abend exit from VM.
+ * @note <i>VERIFY_SOURCE_PARAMS</i> - debug parameters source line and source file name
+ * @see VERIFY_SOURCE_PARAMS
+ * @see vf_error
  */
-typedef union {
-    struct {
-        vf_MapEntry_t *m_invector;   ///< method IN stack vector
-        vf_MapEntry_t *m_outvector;  ///< method OUT stack vector
-        const char *m_name;          ///< invoked method name
-        int m_inlen;                 ///< IN vector length
-        int m_outlen;                ///< OUT vector length
-    } method;
-    struct {
-        vf_MapEntry_t *f_vector;     ///< field type map vector
-        int f_vlen;                  ///< field type map vector len
-    } field;
-} vf_Parse_t;
+void
+vf_error_func( VERIFY_SOURCE_PARAMS );
 
 /**
- * Verifier control flow graph structures.
+ * Function allocates an array in memory with elements initialized to zero. 
+ * @param number        - number of elements
+ * @param element_size  - size of element
+ * @note <i>VERIFY_SOURCE_PARAMS</i> - debug parameters source line and source file name
+ * @return Pointer to allocated memory block.
+ * @see VERIFY_SOURCE_PARAMS
+ * @see vf_calloc
+ * @note Assertion is raised if <i>number</i> or <i>element_size</i>
+ *       are equal to zero or if out of memory error is arisen.
+ * @note Trace is available with argument <b>verifier:memory</b>.
  */
-//===========================================================
+void *
+vf_calloc_func( unsigned number, unsigned element_size, VERIFY_SOURCE_PARAMS );
+
 /**
- * Structure of stack map vector.
+ * Function allocates memory blocks.
+ * @param size - size of memory block
+ * @note <i>VERIFY_SOURCE_PARAMS</i> - debug parameters source line and source file name
+ * @return Pointer to allocated memory block.
+ * @see VERIFY_SOURCE_PARAMS
+ * @see vf_malloc
+ * @note Assertion is raised if <i>size</i> is equal to zero
+ *       or if out of memory error is arisen.
+ * @note Trace is available with argument <b>verifier:memory</b>.
  */
-typedef struct {
-    vf_MapEntry_t *m_stack;         ///< stack map vector
-    vf_MapEntry_t *m_local;         ///< locals map vector
-    unsigned short m_number;        ///< number of locals
-    unsigned short m_deep;          ///< stack deep
-    unsigned short m_maxstack;      ///< max stack length
-    unsigned short m_maxlocal;      ///< max local number
-} vf_MapVector_t;
+void *
+vf_malloc_func( unsigned size, VERIFY_SOURCE_PARAMS );
 
 /**
- * Graph node structure.
+ * Function releases allocated memory blocks.
+ * @param pointer - pointer to allocated block
+ * @note <i>VERIFY_SOURCE_PARAMS</i> - debug parameters source line and source file name
+ * @see VERIFY_SOURCE_PARAMS
+ * @see vf_free
+ * @note Assertion is raised if <i>pointer</i> is equal to null.
+ * @note Trace is available with argument <b>verifier:memory</b>.
  */
-struct vf_Node_s
-{
-    vf_MapVector_t m_invector;          ///< stack map IN node vector
-    vf_MapVector_t m_outvector;         ///< stack map OUT node vector
-    unsigned m_start;                   ///< beginning of the first instruction of the BB
-    unsigned m_end;                     ///< beginning of the last instruction of the BB.
-    unsigned m_inedge;                  ///< the first of incoming node edges
-    unsigned m_outedge;                 ///< the first of outcoming node edges
-    unsigned m_len;                     ///< length of the basic block
-    unsigned m_innum;                   ///< number of incoming edges
-    unsigned m_outnum;                  ///< number of outcoming edges
-    unsigned m_nodecount;               ///< node count in enumeration
-    int m_stack;                        ///< stack deep of node
-    int m_mark;                         ///< node mark
-    bool m_initialized;                 ///< reference in local variable should be initialized
-};
+void
+vf_free_func( void *pointer, VERIFY_SOURCE_PARAMS );
 
 /**
- * Graph edge structure.
+ * Function reallocates memory blocks.
+ * @param pointer   - pointer to allocated block
+ * @param resize    - new size of memory block
+ * @note <i>VERIFY_SOURCE_PARAMS</i> - debug parameters source line and source file name
+ * @return Pointer to reallocated memory block.
+ * @see VERIFY_SOURCE_PARAMS
+ * @see vf_realloc
+ * @note Assertion is raised if <i>resize</i> is equal to zero
+ *       or if out of memory error is arisen.
+ * @note If <i>pointer</i> is equal to null function works like vf_malloc_func.
+ * @note Trace is available with argument <b>verifier:memory</b>.
  */
-struct vf_Edge_s
-{
-    unsigned m_start;       ///< start edge node
-    unsigned m_end;         ///< end edge node
-    unsigned m_innext;      ///< next incoming edge
-    unsigned m_outnext;     ///< next outcoming edge
-};
+void *
+vf_realloc_func( void *pointer, unsigned resize, VERIFY_SOURCE_PARAMS );
 
 /**
- * Graph node container structure.
+ * Function creates memory pool structure.
+ * @note <i>VERIFY_SOURCE_PARAMS</i> - debug parameters source line and source file name
+ * @return Pointer to created memory pool.
+ * @see VERIFY_SOURCE_PARAMS
+ * @see vf_create_pool
+ * @see vf_VerifyPool_t
+ * @note Trace is available with argument <b>verifier:memory:pool</b>.
  */
-struct vf_NodeContainer_s
-{
-    vf_NodeContainer_t* m_next;     ///< next container
-    unsigned m_max;                 ///< max number of nodes in container
-    unsigned m_used;                ///< number of nodes in container
-    vf_Node_t m_node[1];            ///< array of container nodes
-};
+vf_VerifyPool_t *
+vf_create_pool_func( VERIFY_SOURCE_PARAMS );
 
 /**
- * Graph edge container structure.
+ * Function allocates memory blocks in current pool.
+ * @param pool - pointer to memory pool structure
+ * @param size - memory block size
+ * @note <i>VERIFY_SOURCE_PARAMS</i> - debug parameters source line and source file name
+ * @return Pointer to allocated memory block.
+ * @see VERIFY_SOURCE_PARAMS
+ * @see vf_alloc_pool_memory
+ * @see vf_VerifyPool_t
+ * @note Trace is available with argument <b>verifier:memory:pool</b>.
  */
-struct vf_EdgeContainer_s
-{
-    vf_EdgeContainer_t* m_next;     ///< next container
-    unsigned m_max;                 ///< max number of edges in container
-    unsigned m_used;                ///< number of edges in container
-    vf_Edge_t m_edge[1];            ///< array of container edges
-};
+void *
+vf_alloc_pool_memory_func( vf_VerifyPool_t *pool, unsigned size, VERIFY_SOURCE_PARAMS );
 
 /**
- * Verifier control flow graph structure.
+ * Function cleans given pool.
+ * @param pool - memory pool structure
+ * @note <i>VERIFY_SOURCE_PARAMS</i> - debug parameters source line and source file name
+ * @see VERIFY_SOURCE_PARAMS
+ * @see vf_clean_pool_memory
+ * @see vf_VerifyPool_t
+ * @note Trace is available with argument <b>verifier:memory:pool</b>.
  */
-struct vf_Graph
-{
-public:
-
-    /**
-     * Control flow graph constructor.
-     * @param node - number of graph nodes
-     * @param edge - number of graph edges
-     * @note Function allocates memory for graph structure, nodes and edges.
-     */
-    vf_Graph( unsigned node, unsigned edge );
-
-    /**
-     * Control flow graph constructor.
-     * @param node - number of graph nodes
-     * @param edge - number of graph edges
-     * @param pool - external memory pool
-     * @note Function allocates memory for graph structure, nodes and edges.
-     */
-    vf_Graph( unsigned node, unsigned edge, vf_VerifyPool_t *pool );
-
-    /**
-     * Control flow graph destructor.
-     * @note Function release memory for graph structure, nodes and edges.
-     */
-    ~vf_Graph();
-
-    /**
-     * Function create graph nodes.
-     * @param count - number of graph nodes
-     * @note Function allocates memory for graph nodes.
-     */
-    void CreateNodes( unsigned count );
-
-    /**
-     * Gets graph node.
-     * Parameter <i>node_num</i> must be in range.
-     *
-     * @param[in] node_num  - node number
-     *
-     * @return The pointer to node structure.
-     */
-    vf_Node_t* GetNode( unsigned node_num );
-
-    /**
-     * Creates a new node and sets data to it.
-     * Node array must have enough free space for a new element.
-     *
-     * @param[in] begin_instr   - begin code instruction of node
-     * @param[in] end_instr     - end code instruction of code
-     * @param[in] bytecode_len  - bytecode length of node instructions
-     */
-    void NewNode( unsigned begin_instr,
-                  unsigned end_instr,
-                  unsigned bytecode_len);
-
-    /**
-     * Function set data to graph node.
-     * @param node_num      - number of graph node
-     * @param begin_instr   - begin code instruction of node
-     * @param end_instr     - end code instruction of code
-     * @param bytecode_len  - bytecode length of node instructions
-     * @note Assertion is raised if <i>node_num</i> is out of range.
-     */
-    void SetNode( unsigned node_num,
-                  unsigned begin_instr,
-                  unsigned end_instr,
-                  unsigned bytecode_len );
-
-    /**
-     * Gets graph edge.
-     * Parameter <i>edge_num</i> must be in range.
-     *
-     * @param[in] edge_num  - edge number
-     *
-     * @return The pointer to edge structure.
-     */
-    vf_Edge_t* GetEdge( unsigned edge_num );
-
-    /**
-     * Creates a new edge for graph nodes.
-     *
-     * @param start_node    - start edge node
-     * @param end_node      - end edge node
-     * @note Edge is set as out edge for start_node and as in edge for end_node.
-     */
-    void NewEdge( unsigned start_node,
-                  unsigned end_node);
-
-    /**
-     * Function receive first code instruction of graph node.
-     * @param node_num - graph node number
-     * @return Number of first code instruction of graph node.
-     * @note Assertion is raised if <i>node_num</i> is out of range.
-     */
-    unsigned GetNodeFirstInstr( unsigned node_num );
-
-    /**
-     * Function receive last code instruction of graph node.
-     * @param node_num - graph node number
-     * @return Number of last code instruction of graph node.
-     * @note Assertion is raised if <i>node_num</i> is out of range.
-     */
-    unsigned GetNodeLastInstr( unsigned node_num );
-
-    /**
-     * Function receive bytecode length of graph node instructions.
-     * @param node_num - graph node number
-     * @return Bytecode length of graph node instructions.
-     * @note Assertion is raised if <i>node_num</i> is out of range.
-     */
-    unsigned GetNodeByteCodeLen( unsigned node_num );
-
-    /**
-     * Function receive stack modifier of graph.
-     * @param node_num - graph node number
-     * @return Stack modifier of graph node.
-     * @note Assertion is raised if <i>node_num</i> is out of range.
-     */
-    int GetNodeStackModifier( unsigned node_num );
-
-    /**
-     * Function sets graph node stack modifier.
-     * @param node_num - graph node number
-     * @param stack    - stack modifier (signed value)
-     * @note Assertion is raised if <i>node_num</i> is out of range.
-     */
-    void SetNodeStackModifier( unsigned node_num, int stack );
-
-    /**
-     * Function returns number of graph nodes.
-     * @return Number of graph nodes.
-     */
-    unsigned GetNodeNumber();
-
-    /**
-     * Function marks graph node.
-     * @param node_num - graph node number
-     * @param mark     - node mark
-     * @note Assertion is raised if <i>node_num</i> is out of range.
-     */
-    void SetNodeMark( unsigned node_num, int mark );
-
-    /**
-     * Function returns graph node mark.
-     * @param  node_num - graph node number
-     * @return Function returns graph node mark.
-     * @note Assertion is raised if <i>node_num</i> is out of range.
-     */
-    int GetNodeMark( unsigned node_num );
-
-    /**
-     * Function checks if node is marked.
-     * @param  node_num - graph node number
-     * @return Returns <code>true</code> if node is marked, else returns <code>false</code>.
-     * @note Assertion is raised if <i>node_num</i> is out of range.
-     */
-    bool IsNodeMarked( unsigned node_num );
-
-    /**
-     * Function removes node mark.
-     */
-    void CleanNodesMark();
-
-    /**
-     * Sets local variable reference initialization flag for node.
-     * @param node_num - graph node number
-     * @param flag     - node flag
-     */
-    void SetNodeInitFlag( unsigned node_num, bool flag );
-
-    /**
-     * Gets local variable reference initialization flag for node.
-     * @param node_num - graph node number
-     * @return Returns <code>true</code> if local variable reference have
-     *  to be initialized else returns <code>false</code>.
-     */
-    bool GetNodeInitFlag( unsigned node_num );
-
-    /**
-     * Function creates <i>IN</i> data flow vector of node.
-     * @param node_num  - graph node number
-     * @param example   - current data flow vector
-     * @param need_copy - copy flag
-     * @note If copy flag <code>true</code>, incoming vector is copied to <i>IN</i>,
-     *       else if copy flag <code>false</code>, <i>IN</i> vector is created
-     *       with parameters of current vector.
-     * @note Assertion is raised if <i>node_num</i> is out of range.
-     * @see vf_MapVector_t
-     */
-    void SetNodeInVector( unsigned node_num,
-                          vf_MapVector_t *example,
-                          bool need_copy);
-
-    /**
-     * Function creates <i>OUT</i> data flow vector of node.
-     * @param node_num  - graph node number
-     * @param example   - current data flow vector
-     * @param need_copy - copy flag
-     * @note If copy flag <code>true</code>, incoming vector is copied to <i>OUT</i>,
-     *       else if copy flag <code>false</code>, <i>OUT</i> vector is created
-     *       with parameters of current vector.
-     * @note Assertion is raised if <i>node_num</i> is out of range.
-     * @see vf_MapVector_t
-     */
-    void SetNodeOutVector( unsigned node_num,
-                           vf_MapVector_t *example,
-                           bool need_copy );
-
-    /**
-     * Function receives <i>IN</i> data flow vector of node.
-     * @param node_num  - graph node number
-     * @return <i>IN</i> data flow stack map vector of node.
-     * @note Assertion is raised if <i>node_num</i> is out of range.
-     * @see vf_MapVector_t
-     */
-    vf_MapVector_t * GetNodeInVector( unsigned node_num );
-
-    /**
-     * Function receives <i>OUT</i> data flow vector of node.
-     * @param node_num  - graph node number
-     * @return <i>OUT</i> data flow stack map vector of node.
-     * @note Assertion is raised if <i>node_num</i> is out of range.
-     * @see vf_MapVector_t
-     */
-    vf_MapVector_t * GetNodeOutVector( unsigned node_num );
-
-    /**
-     * Function creates graph edges.
-     * @param number - number of edges 
-     */
-    void CreateEdges( unsigned number );
-
-    /**
-     * Function receives next <i>IN</i> edge of graph node.
-     * @param edge_num - number of graph edge
-     * @return Number of next <i>IN</i> edge of node.
-     * @note Assertion is raised if <i>edge_num</i> is out of range.
-     */
-    unsigned GetEdgeNextInEdge( unsigned edge_num );
-
-    /**
-     * Function receives next <i>OUT</i> edge of graph node.
-     * @param edge_num - number of graph edge
-     * @return Number of next <i>OUT</i> edge of node.
-     * @note Assertion is raised if <i>edge_num</i> is out of range.
-     */
-    unsigned GetEdgeNextOutEdge( unsigned edge_num );
-
-    /**
-     * Function receives start graph node of edge.
-     * @param edge_num - number of graph edge
-     * @return Number start graph node of edge.
-     * @note Assertion is raised if <i>edge_num</i> is out of range.
-     */
-    unsigned GetEdgeStartNode( unsigned edge_num );
-
-    /**
-     * Function receives end graph node of edge.
-     * @param edge_num - number of graph edge
-     * @return Number end graph node of edge.
-     * @note Assertion is raised if <i>edge_num</i> is out of range.
-     */
-    unsigned GetEdgeEndNode( unsigned edge_num );
-
-    /**
-     * Function receives number of <i>IN</i> edges of graph node.
-     * @param node_num - number of graph node
-     * @return Number of <i>IN</i> edges of graph node.
-     * @note Assertion is raised if <i>node_num</i> is out of range.
-     */
-    unsigned GetNodeInEdgeNumber( unsigned node_num );
-
-    /**
-     * Function receives number of <i>OUT</i> edges of graph node.
-     * @param node_num - number of graph node
-     * @return Number of <i>OUT</i> edges of graph node.
-     * @note Assertion is raised if <i>node_num</i> is out of range.
-     */
-    unsigned GetNodeOutEdgeNumber( unsigned node_num );
-
-    /**
-     * Function receives first <i>IN</i> edge of graph node.
-     * @param node_num - number of graph node
-     * @return First <i>IN</i> edges of node.
-     * @note Assertion is raised if <i>node_num</i> is out of range.
-     */
-    unsigned GetNodeFirstInEdge( unsigned node_num );
-
-    /**
-     * Function receives first <i>OUT</i> edge of graph node.
-     * @param node_num - number of graph node
-     * @return First <i>OUT</i> edges of node.
-     * @note Assertion is raised if <i>node_num</i> is out of range.
-     */
-    unsigned GetNodeFirstOutEdge( unsigned node_num );
-
-    /**
-     * Function allocates memory in graph memory pool.
-     * @param size - size of memory block
-     * @return Allocated memory pointer
-     *         or <code>NULL</code>if memory allocation is failed.
-     */
-    void * AllocMemory( unsigned size );
-
-    /**
-     * Function cleans graph node enumeration, creates new graph
-     * enumeration structure and sets first enumeration element.
-     * @param node_num - first enumeration node
-     * @note Assertion is raised if <i>node_num</i> is out of range.
-     */
-    void SetStartCountNode( unsigned node_num );
-
-    /**
-     * Function receives number of enumerated nodes.
-     * @return Function returns number of enumerated nodes.
-     */
-    unsigned GetEnumCount();
-
-    /**
-     * Function sets next enumeration element in graph enumeration structure.
-     * @param node_num - next enumeration node
-     * @note Assertion is raised if <i>node_num</i> is out of range.
-     */
-    void SetNextCountNode( unsigned node_num );
-
-    /**
-     * Function receives first enumerated graph node.
-     * @return First enumerated graph node in graph enumeration structure.
-     */
-    unsigned GetStartCountNode();
-
-    /**
-     * Function receives graph node relevant to enumeration element.
-     * @param count - given enumeration element
-     * @return Graph node relevant to enumeration element.
-     * @note Assertion is raised if <i>count</i> is out of range.
-     */
-    unsigned GetCountElementNode( unsigned count );
-
-    /**
-     * Function receives graph node enumeration count.
-     * @param node_num - given node
-     * @return Graph node enumeration count.
-     * @note Assertion is raised if <i>node_num</i> is out of range.
-     */
-    unsigned GetNodeCountElement( unsigned node_num );
-
-    /**
-     * Function prints graph structure in <code>stderr</code>.
-     * @param context - current verifier context
-     * @note Function is valid in debug mode.
-     * @see vf_Context_t
-     */
-    void DumpGraph( vf_Context_t *context );
-
-    /**
-     * Function dumps verifier graph in file in DOT format.
-     * @param context - current verifier context
-     * @note Function is valid in debug mode.
-     * @note File name is created from class and method names with .dot extension.
-     * @see vf_Context_t
-     */
-    void DumpDotGraph( vf_Context_t *context );
-
-private:
-    vf_NodeContainer_t *m_nodes;        ///< array of nodes
-    vf_EdgeContainer_t *m_edges;        ///< array of edges
-    vf_VerifyPool_t *m_pool;            ///< graph memory pool
-    unsigned *m_enum;                   ///< graph node enumeration structure
-    unsigned m_nodenum;                 ///< number of nodes
-    unsigned m_edgenum;                 ///< number of edges
-    unsigned m_enummax;                 ///< max number of enumerated elements
-    unsigned m_enumcount;               ///< number of enumerated elements
-    bool m_free;                        ///< need to free pool
-
-    /**
-     * Function prints graph node in <code>stderr</code>.
-     * @param node_num  - number of graph node
-     * @param context      - current verifier context
-     * @note Function is valid in debug mode.
-     * @note Assertion is raised if <i>node_num</i> is out of range.
-     * @see vf_Context_t
-     */
-    void DumpNode( unsigned node_num, vf_Context_t *context );
-
-    /**
-     * Function prints graph node instruction in stream.
-     * @param node_num   - number of graph node
-     * @param context    - current verifier context
-     * @note Function is valid in debug mode.
-     * @note Assertion is raised if <i>node_num</i> is out of range.
-     * @see vf_Context_t
-     */
-    void DumpNodeInternal( unsigned node_num,
-                           vf_Context_t *context);
-
+void
+vf_clean_pool_memory_func( vf_VerifyPool_t *pool, VERIFY_SOURCE_PARAMS );
 
-    /**
-     * Function dumps graph header in file in DOT format.
-     * @param graph_name    - graph name
-     * @param fout          - file stream
-     * @note Function is valid in debug mode.
-     * @note Graph name is created from class and method names.
-     */
-    void DumpDotHeader( char *graph_name, ofstream &fout );
+/**
+ * Function releases memory from given pool.
+ * @param pool - memory pool structure
+ * @note <i>VERIFY_SOURCE_PARAMS</i> - debug parameters source line and source file name
+ * @see VERIFY_SOURCE_PARAMS
+ * @see vf_delete_pool
+ * @see vf_VerifyPool_t
+ * @note Trace is available with argument <b>verifier:memory:pool</b>.
+ */
+void
+vf_delete_pool_func( vf_VerifyPool_t *pool, VERIFY_SOURCE_PARAMS );
 
-    /**
-     * Function dumps graph node in file in DOT format.
-     * @param node_num - number of graph node
-     * @param fout     - file stream
-     * @param context  - current verifier context
-     * @note Function is valid in debug mode.
-     * @note Assertion is raised if <i>node_num</i> is out of range.
-     * @see vf_Context_t
-     */
-    void DumpDotNode( unsigned node_num, ofstream &fout, vf_Context_t *context );
+//===========================================================
+// Code instruction structures.
+//===========================================================
 
-    /**
-     * Function dumps graph node instruction in file stream in DOT format.
-     * @param node_num   - number of graph node
-     * @param next_node  - separator between nodes in stream
-     * @param next_instr - separator between instructions in stream
-     * @param fout       - output file stream
-     * @param context    - current verifier context
-     * @note Function is valid in debug mode.
-     * @note Assertion is raised if <i>node_num</i> is out of range.
-     * @see vf_Context_t
-     */
-    void DumpDotNodeInternal( unsigned node_num,
-                              char *next_node,
-                              char *next_instr,
-                              ofstream &fout,
-                              vf_Context_t *context);
+/**
+ * A byte of a bytecode.
+ */
+struct vf_BCode {
+    unsigned m_instr;       ///< a number + 1 of code instruction at
+                            ///< vf_Context.m_code
+    unsigned m_mark : 1;    ///< control flow branch flag
+};
 
-    /**
-     * Function dumps graph end in file in DOT format.
-     * @param fout - output file stream
-     * @note Function is valid in debug mode.
-     */
-    void DumpDotEnd( ofstream &fout );
+/**
+ * Valid types structure.
+ */
+struct vf_ValidType {
+    unsigned number;          ///< number of types
+    const char *string[1];    ///< type array
+};
 
-}; // struct vf_Graph
+/** 
+ * Stack map entry structure.
+ */
+struct vf_MapEntry {
+    vf_ValidType_t *m_vtype;        ///< valid type for reference
+    union {
+        unsigned m_new;             ///< program count of opcode new for uninitialized
+        unsigned m_pc;              ///< program count of return address for subroutine
+    };
+    union {
+        unsigned short m_local;     ///< number of local variable
+        unsigned short m_index;     ///< constant pool index for access check
+    };
+    unsigned short m_type : 5;      ///< stack map type @see vf_MapType_t
+    unsigned short m_ctype : 4;     ///< constraint type @see vf_CheckConstraint_t
+    unsigned short m_is_local : 1;  ///< local variable modify flag
+                                    ///< true - modify local, false - modify stack
+};
 
 /**
- * Verifier hash table structures.
+ * Complete struct of bytecode instructions.
+ */
+struct vf_Code {
+    unsigned char *m_addr;          ///< address of bytecode instruction
+    unsigned *m_off;                ///< array of instruction branches
+    vf_MapEntry_t *m_invector;      ///< stack map IN instruction vector
+    vf_MapEntry_t *m_outvector;     ///< stack map OUT instruction vector
+    unsigned m_offcount;            ///< number of instruction branches
+    unsigned short m_minstack;      ///< minimal stack for instruction
+    unsigned short m_inlen;         ///< stack map IN instruction vector length
+    unsigned short m_outlen;        ///< stack map OUT instruction vector length
+    short m_stack;                  ///< stack change for instruction
+    vf_CodeType m_type;             ///< instruction flag @see vf_CodeType_t
+    bool m_basic_block_start : 1;   ///< begin of a basic block
+};
+
+/** 
+ * Constant pool parse structure.
  */
+union vf_Parse {
+    struct {
+        vf_MapEntry_t *m_invector;   ///< method IN stack vector
+        vf_MapEntry_t *m_outvector;  ///< method OUT stack vector
+        const char *m_name;          ///< invoked method name
+        int m_inlen;                 ///< IN vector length
+        int m_outlen;                ///< OUT vector length
+    } method;
+    struct {
+        vf_MapEntry_t *f_vector;     ///< field type map vector
+        int f_vlen;                  ///< field type map vector len
+    } field;
+};
+
+//===========================================================
+// Verifier hash table structures.
 //===========================================================
 
 /**
  * Structure of hash entry.
  */
-struct vf_HashEntry_s {
+struct vf_HashEntry {
     const char *key;            ///< hash entry key
     void *data;                 ///< pointer to hash entry data
     vf_HashEntry_t *next;       ///< next hash entry
@@ -1025,14 +603,14 @@
     unsigned HashFunc( const char *key, unsigned len );
 }; // struct vf_Hash
 
-/**
- * Verifier type constraint structures.
- */
 //===========================================================
+// Verifier type constraint structures.
+//===========================================================
+
 /**
  * Verifier type constraint structure.
  */
-struct vf_TypeConstraint_s {
+struct vf_TypeConstraint {
     const char *source;         ///< constraint source class name
     const char *target;         ///< constraint target class name
     method_handler method;      ///< constraint for method
@@ -1143,10 +721,12 @@
     vf_TypeConstraint_t *m_restriction;     ///< array of the class constraints
 }; // vf_TypePool
 
-/**
- * Verifier type constraint structures.
- */
 //===========================================================
+// Verifier type constraint structures.
+//===========================================================
+
+void vf_clean_pool_memory_func( vf_VerifyPool_t *pool, VERIFY_SOURCE_PARAMS );
+
 /**
  * Structure of verifier context
  */
@@ -1159,13 +739,13 @@
     vf_Context() : m_class(NULL), m_type(NULL), m_error(NULL),
         m_method(NULL), m_graph(NULL), m_pool(NULL), m_code(NULL), 
         m_codeNum(0), m_nodeNum(0), m_edgeNum(0)
-        {
-            vf_ContextDump zero1 = {0};
-            vf_ContextVType zero2 = {0};
-
-            m_dump = zero1;
-            m_vtype = zero2;
-        }
+    {
+        vf_ContextDump zero1 = {0};
+        vf_ContextVType zero2 = {0};
+
+        m_dump = zero1;
+        m_vtype = zero2;
+    }
 
     /**
      * Verifier context destructor
@@ -1175,19 +755,33 @@
     /**
      * Function clears context.
      */
-    void ClearContext();
+    void ClearContext()
+    {
+        m_method = NULL;
+        m_is_constructor = false;
+        m_graph = NULL;
+        m_code = NULL;
+        m_bc   = NULL;
+        m_codeNum = 0;
+        m_nodeNum = 0;
+        m_edgeNum = 0;
+        vf_clean_pool_memory( m_pool );
+    } // vf_ClearContext
 
 public:
-    class_handler m_class;              ///< context class
     vf_TypePool *m_type;                ///< context type constraint collection
     char *m_error;                      ///< context error message
-    method_handler m_method;            ///< context method
-    vf_Graph_t *m_graph;                ///< context control flow graph
+    vf_Graph *m_graph;                  ///< context control flow graph
     vf_VerifyPool_t *m_pool;            ///< context memory pool
     vf_Code_t *m_code;                  ///< context code instruction of method
+    vf_BCode_t* m_bc;                   ///< bytecode to code mapping
+    class_handler m_class;              ///< context class
+    method_handler m_method;            ///< context method
     unsigned m_codeNum;                 ///< code instruction number
     unsigned m_nodeNum;                 ///< graph node number
     unsigned m_edgeNum;                 ///< graph edge number
+    bool m_is_constructor;              ///< <code>true</code> if the
+                                        ///< method is a constructor
 
     /**
      * Structure contains useful valid types
@@ -1217,16 +811,17 @@
         unsigned m_code_vector : 1;     ///< print data flow node code instruction vectors
         unsigned m_merge_vector : 1;    ///< print result of merge data flow vectors
     } m_dump;
+
 }; // struct vf_Context
 
-/**
- * Other structures.
- */
 //===========================================================
+// Other structures.
+//===========================================================
+
 /**
  * Head structure of memory pool.
  */
-struct vf_VerifyPool_s {
+struct vf_VerifyPool {
     vf_VerifyPoolInternal_t *m_pool;    ///< pool entry
     unsigned m_memory;                  ///< allocated memory size
     unsigned m_used;                    ///< used memory size
@@ -1236,7 +831,7 @@
 /**
  * Internal structure of memory pool.
  */
-struct vf_VerifyPoolInternal_s {
+struct vf_VerifyPoolInternal {
     void *m_memory;                     ///< pool entry memory
     char *m_free;                       ///< free space in pool entry
     vf_VerifyPoolInternal_t *m_next;    ///< next pool entry
@@ -1246,15 +841,15 @@
 /**
  * Structure of class loader constraint data.
  */
-typedef struct {
+struct vf_ClassLoaderData {
     vf_VerifyPool_t *pool;  ///< constraint memory pool
     vf_Hash_t *string;      ///< string pool hash table
-} vf_ClassLoaderData_t;
+};
 
-/**
- * Verifier data
- */
 //===========================================================
+// Verifier debug data
+//===========================================================
+
 /**
  * Array of opcode names. Available in debug mode.
  */
@@ -1262,125 +857,9 @@
 extern const char *vf_opcode_names[];
 #endif // _VERIFY_DEBUG
 
-/**
- * Verifier functions.
- */
 //===========================================================
-/**
- * Function performs abend exit from VM.
- * @note <i>VERIFY_SOURCE_PARAMS</i> - debug parameters source line and source file name
- * @see VERIFY_SOURCE_PARAMS
- * @see vf_error
- */
-void
-vf_error_func( VERIFY_SOURCE_PARAMS );
-
-/**
- * Function allocates an array in memory with elements initialized to zero. 
- * @param number        - number of elements
- * @param element_size  - size of element
- * @note <i>VERIFY_SOURCE_PARAMS</i> - debug parameters source line and source file name
- * @return Pointer to allocated memory block.
- * @see VERIFY_SOURCE_PARAMS
- * @see vf_calloc
- * @note Assertion is raised if <i>number</i> or <i>element_size</i>
- *       are equal to zero or if out of memory error is arisen.
- * @note Trace is available with argument <b>verifier:memory</b>.
- */
-void *
-vf_calloc_func( unsigned number, unsigned element_size, VERIFY_SOURCE_PARAMS );
-
-/**
- * Function allocates memory blocks.
- * @param size - size of memory block
- * @note <i>VERIFY_SOURCE_PARAMS</i> - debug parameters source line and source file name
- * @return Pointer to allocated memory block.
- * @see VERIFY_SOURCE_PARAMS
- * @see vf_malloc
- * @note Assertion is raised if <i>size</i> is equal to zero
- *       or if out of memory error is arisen.
- * @note Trace is available with argument <b>verifier:memory</b>.
- */
-void *
-vf_malloc_func( unsigned size, VERIFY_SOURCE_PARAMS );
-
-/**
- * Function releases allocated memory blocks.
- * @param pointer - pointer to allocated block
- * @note <i>VERIFY_SOURCE_PARAMS</i> - debug parameters source line and source file name
- * @see VERIFY_SOURCE_PARAMS
- * @see vf_free
- * @note Assertion is raised if <i>pointer</i> is equal to null.
- * @note Trace is available with argument <b>verifier:memory</b>.
- */
-void
-vf_free_func( void *pointer, VERIFY_SOURCE_PARAMS );
-
-/**
- * Function reallocates memory blocks.
- * @param pointer   - pointer to allocated block
- * @param resize    - new size of memory block
- * @note <i>VERIFY_SOURCE_PARAMS</i> - debug parameters source line and source file name
- * @return Pointer to reallocated memory block.
- * @see VERIFY_SOURCE_PARAMS
- * @see vf_realloc
- * @note Assertion is raised if <i>resize</i> is equal to zero
- *       or if out of memory error is arisen.
- * @note If <i>pointer</i> is equal to null function works like vf_malloc_func.
- * @note Trace is available with argument <b>verifier:memory</b>.
- */
-void *
-vf_realloc_func( void *pointer, unsigned resize, VERIFY_SOURCE_PARAMS );
-
-/**
- * Function creates memory pool structure.
- * @note <i>VERIFY_SOURCE_PARAMS</i> - debug parameters source line and source file name
- * @return Pointer to created memory pool.
- * @see VERIFY_SOURCE_PARAMS
- * @see vf_create_pool
- * @see vf_VerifyPool_t
- * @note Trace is available with argument <b>verifier:memory:pool</b>.
- */
-vf_VerifyPool_t *
-vf_create_pool_func( VERIFY_SOURCE_PARAMS );
-
-/**
- * Function allocates memory blocks in current pool.
- * @param pool - pointer to memory pool structure
- * @param size - memory block size
- * @note <i>VERIFY_SOURCE_PARAMS</i> - debug parameters source line and source file name
- * @return Pointer to allocated memory block.
- * @see VERIFY_SOURCE_PARAMS
- * @see vf_alloc_pool_memory
- * @see vf_VerifyPool_t
- * @note Trace is available with argument <b>verifier:memory:pool</b>.
- */
-void *
-vf_alloc_pool_memory_func( vf_VerifyPool_t *pool, unsigned size, VERIFY_SOURCE_PARAMS );
-
-/**
- * Function cleans given pool.
- * @param pool - memory pool structure
- * @note <i>VERIFY_SOURCE_PARAMS</i> - debug parameters source line and source file name
- * @see VERIFY_SOURCE_PARAMS
- * @see vf_clean_pool_memory
- * @see vf_VerifyPool_t
- * @note Trace is available with argument <b>verifier:memory:pool</b>.
- */
-void
-vf_clean_pool_memory_func( vf_VerifyPool_t *pool, VERIFY_SOURCE_PARAMS );
-
-/**
- * Function releases memory from given pool.
- * @param pool - memory pool structure
- * @note <i>VERIFY_SOURCE_PARAMS</i> - debug parameters source line and source file name
- * @see VERIFY_SOURCE_PARAMS
- * @see vf_delete_pool
- * @see vf_VerifyPool_t
- * @note Trace is available with argument <b>verifier:memory:pool</b>.
- */
-void
-vf_delete_pool_func( vf_VerifyPool_t *pool, VERIFY_SOURCE_PARAMS );
+// Verifier functions.
+//===========================================================
 
 /**
  * Function creates bytecode control flow graph.
@@ -1393,14 +872,14 @@
 vf_create_graph( vf_Context_t *context );
 
 /**
- * Function provides some checks of control flow and data flow structures of graph.
- * @param context - verifier context
- * @return Checks result.
- * @see vf_Context_t
- * @see Verifier_Result
+ * Checks control flow and data flow of graph.
+ *
+ * @param[in] context a verifier context
+ *
+ * @return a result of graph checks
  */
 Verifier_Result
-vf_graph_checks( vf_Context_t *context );
+vf_check_graph( vf_Context_t *context );
 
 /**
  * Function provides data flow checks of verifier graph structure.
@@ -1450,6 +929,24 @@
                            vf_Context_t *context);
 
 /**
+ * Gets a class name from a constant pool.
+ *
+ * @param[in] klass  a handle of the class
+ * @param[in] index  the entry index
+ *
+ * @return a pointer to UTF8 constant pool entry
+ */
+static inline const char*
+vf_get_cp_class_name( class_handler klass,
+                      unsigned short index )
+{
+    unsigned short class_name_index =
+        class_get_cp_class_name_index(klass, index);
+    const char* name = class_get_cp_utf8_bytes(klass, class_name_index);
+    return name;
+} // vf_get_cp_class_name
+
+/**
  * Function creates valid type by given class name.
  * @param class_name - class name
  * @param context    - verifier context
@@ -1506,67 +1003,10 @@
                             vf_Context_t *ctex);                // verifier context
 
 /**
- * Function clears verifier context.
- */
-inline void
-vf_Context::ClearContext()
-{
-    m_method = NULL;
-    m_graph = NULL;
-    m_code = NULL;
-    m_codeNum = 0;
-    m_nodeNum = 0;
-    m_edgeNum = 0;
-    vf_clean_pool_memory( m_pool );
-} // vf_Context::vf_ClearContext
-
-/**
- * Function checks basic block flag for given instruction.
- * @param code - bytecode instruction
- * @return If given instruction has basic block flag returns <code>true</code>,
- *         else returns <code>false</code>.
- * @see vf_Code_t
- */
-static inline bool
-vf_is_begin_basic_block( vf_Code_t *code )
-{
-    return (code->m_base & VF_FLAG_BEGIN_BASIC_BLOCK) != 0;
-} // vf_is_begin_basic_block
-
-/**
- * Function checks flags for given instruction.
- * @param code - bytecode instruction
- * @param flag - checked flags
- * @return If given instruction has checked flag returns <code>true</code>,
- *         else returns <code>false</code>.
- * @see vf_Code_t
- */
-static inline bool
-vf_is_instruction_has_flags( vf_Code_t *code,
-                             unsigned flag)
-{
-    return ((unsigned)code->m_base & flag) != 0;
-} // vf_is_instruction_has_flags
-
-/**
- * Function checks what given instruction has any flags.
- * @param code - bytecode instruction
- * @return If given instruction has any flags returns <code>true</code>,
- *         else returns <code>false</code>.
- * @see vf_Code_t
- */
-static inline bool
-vf_is_instruction_has_any_flags( vf_Code_t *code )
-{
-    return (code->m_base != 0);
-} // vf_is_instruction_has_flags
-
-
-/**
- * Function sets error message of verifier.
- * @param stream - stringstream object with message
- * @param ctex   - verifier context
- * @see vf_Context_t
+ * Sets error message of verifier.
+ *
+ * @param[in] stream stringstream object with a message
+ * @param[in] ctex   a verifier context
  */
 static inline void
 vf_set_error_message( stringstream &stream,
@@ -1589,8 +1029,11 @@
 } // vf_set_error_message
 
 /**
- * Checks version of class file
- * @param context - verifier context
+ * Checks a version of a class file.
+ *
+ * @param[in] context a verifier context
+ *
+ * @return <code>true</code> if a class version is less than 1.4
  */
 static inline bool
 vf_is_class_version_14( vf_Context_t *context )
@@ -1598,8 +1041,78 @@
     return (class_get_version(context->m_class) < 49) ? true : false;
 } // vf_is_class_version_14
 
-} // namespace Verifier
+/**
+ * Returns branch target for a given branch number.
+ *
+ * @param[in] code        a reference to instruction
+ * @param[in] branch_num  a branch number
+ *
+ * @return an absolute bytecode position to which the executuion
+ * branches
+ */
+static inline int
+vf_get_code_branch( vf_Code_t* code, unsigned branch_num )
+{
+    assert(branch_num < code->m_offcount);
+    return code->m_off[branch_num];
+} // vf_get_instruction_branch
+
+/**
+ * Allocates memory for a new stack map vector.
+ *
+ * @param[out] vector a reference to vector
+ * @param[in]  len    vector length
+ * @param[in]  pool   memory pool
+ */
+static inline void 
+vf_new_vector( vf_MapEntry_t** vector,
+               unsigned len,
+               vf_VerifyPool_t *pool)
+{
+    // create new vector
+    (*vector) = (vf_MapEntry_t*) vf_alloc_pool_memory(pool, 
+        len * sizeof(vf_MapEntry_t));
+    return;
+} // vf_new_vector
 
-using namespace Verifier;
+/**
+ * Sets a reference data type for a given stack map vector entry.
+ *
+ * @param[in, out] vector a reference to a stack map
+ * @param[in]      num    stack map index
+ * @param[in]      type   reference type
+ */
+static inline void
+vf_set_vector_stack_entry_ref( vf_MapEntry_t* vector,
+                               unsigned num,
+                               vf_ValidType_t* type)
+{
+    // set a stack map vector entry by ref
+    vector[num].m_type = SM_REF;
+    vector[num].m_vtype = type;
+} // vf_set_vector_stack_entry_ref
+
+/**
+ * Calls destructor of graph, if any.
+ *
+ * @param[in] context a context of verifier
+ */
+void vf_free_graph( vf_Context_t* context );
+
+/**
+ * Inline subroutines in the call graph.
+ *
+ * <p>Here is the algorithm sketch: we define subroutine boundaries with
+ * simplified data flow analysis and duplicate subroutine nodes
+ * in the call graph. For more details check a
+ * <a href="http://wiki.apache.org/harmony/Subroutine_Verification">wiki
+ * page</a>.</p>
+ *
+ * @param[in] context a verifier context
+ * @return VER_OK if subroutines were inlined successfully,
+ * an error code otherwise
+ */
+Verifier_Result
+vf_inline_subroutines(vf_ContextHandle context);
 
 #endif // _VERIFIER_REAL_H_

Added: harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_subroutine.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_subroutine.cpp?view=auto&rev=508525
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_subroutine.cpp (added)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_subroutine.cpp Fri Feb 16 10:02:37 2007
@@ -0,0 +1,39 @@
+/*
+ *  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.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+#include "ver_subroutine.h"
+
+static vf_Result
+MarkTopcode(vf_ContextHandle context, vf_NodeHandle nh) {
+    return VER_OK;
+} // MarkTopcode
+
+static vf_Result
+InlineMarkedSubNodes(vf_ContextHandle context) {
+    return VER_OK;
+} // InlineMarkedSubNodes
+
+vf_Result
+vf_inline_subroutines(vf_ContextHandle context) {
+
+    vf_Result r = MarkTopcode(context, context->m_graph->GetFirstNode());
+    if (VER_OK != r) {
+        return r;
+    }
+
+    r = InlineMarkedSubNodes(context);
+    return r;
+} // InlineSubroutines

Propchange: harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_subroutine.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_subroutine.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_subroutine.h?view=auto&rev=508525
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_subroutine.h (added)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_subroutine.h Fri Feb 16 10:02:37 2007
@@ -0,0 +1,23 @@
+/*
+ *  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.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+#include "ver_graph.h"
+
+
+/**
+ * Verifier error codes.
+ */
+typedef Verifier_Result vf_Result;

Propchange: harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_subroutine.h
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_utils.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_utils.cpp?view=diff&rev=508525&r1=508524&r2=508525
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_utils.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier/ver_utils.cpp Fri Feb 16 10:02:37 2007
@@ -28,11 +28,6 @@
 // Macro enable verifier memory trace
 #define VERIFY_TRACE_MEMORY 0
 
-/**
- * Set namespace Verifier
- */
-namespace Verifier {
-
 /************************************************************
  *********************** Hash class *************************
  ************************************************************/
@@ -1031,52 +1026,36 @@
     switch( check )
     {
     case VF_CHECK_PARAM:
-        VERIFY_REPORT( ctex, "(class: " << class_get_name( ctex->m_class ) 
-            << ", method: " << method_get_name( method )
-            << method_get_descriptor( method )
-            << ") Incompatible argument for function" );
+        VERIFY_REPORT_METHOD( ctex,
+            "Incompatible argument for function" );
         break;
     case VF_CHECK_ASSIGN:
-        VERIFY_REPORT( ctex, "(class: " << class_get_name( ctex->m_class ) 
-            << ", method: " << method_get_name( method )
-            << method_get_descriptor( method )
-            << ") Incompatible types for field assignment" );
+        VERIFY_REPORT_METHOD( ctex,
+            "Incompatible types for field assignment" );
         break;
     case VF_CHECK_ASSIGN_WEAK:
-        VERIFY_REPORT( ctex, "(class: " << class_get_name( ctex->m_class ) 
-            << ", method: " << method_get_name( method )
-            << method_get_descriptor( method )
-            << ") Incompatible types for array assignment" );
+        VERIFY_REPORT_METHOD( ctex, 
+            "Incompatible types for array assignment" );
         break;
     case VF_CHECK_SUPER:
-        VERIFY_REPORT( ctex, "(class: " << class_get_name( ctex->m_class ) 
-            << ", method: " << method_get_name( method )
-            << method_get_descriptor( method )
-            << ") Exception class not a subclass of Throwable" );
+        VERIFY_REPORT_METHOD( ctex,
+            "Exception class not a subclass of Throwable" );
         break;
     case VF_CHECK_ACCESS_FIELD:
-        VERIFY_REPORT( ctex, "(class: " << class_get_name( ctex->m_class ) 
-            << ", method: " << method_get_name( method )
-            << method_get_descriptor( method )
-            << ") Bad access to protected field" );
+        VERIFY_REPORT_METHOD( ctex,
+            "Bad access to protected field" );
         break;
     case VF_CHECK_ACCESS_METHOD:
-        VERIFY_REPORT( ctex, "(class: " << class_get_name( ctex->m_class ) 
-            << ", method: " << method_get_name( method )
-            << method_get_descriptor( method )
-            << ") Bad access to protected method" );
+        VERIFY_REPORT_METHOD( ctex,
+            "Bad access to protected method" );
         break;
     case VF_CHECK_DIRECT_SUPER:
-        VERIFY_REPORT( ctex, "(class: " << class_get_name( ctex->m_class ) 
-            << ", method: " << method_get_name( method )
-            << method_get_descriptor( method )
-            << ") Call to wrong initialization method" );
+        VERIFY_REPORT_METHOD( ctex,
+            "Call to wrong initialization method" );
         break;
     case VF_CHECK_INVOKESPECIAL:
-        VERIFY_REPORT( ctex, "(class: " << class_get_name( ctex->m_class ) 
-            << ", method: " << method_get_name( method )
-            << method_get_descriptor( method )
-            << ") Incompatible object argument for invokespecial" );
+        VERIFY_REPORT_METHOD( ctex,
+            "Incompatible object argument for invokespecial" );
         break;
     default:
         LDIE(41, "Verifier: vf_set_error: unknown check type" );
@@ -1396,7 +1375,8 @@
         while( constraint->target[index++] != 'L' ) {
             assert( constraint->target[index] != '\0' );
         }
-        VERIFY_REPORT( ctex, &(constraint->target[index]) );
+        VERIFY_REPORT( ctex, "Couldn't load class: "
+            << &(constraint->target[index]) );
         return VER_ErrorLoadClass;
     }
 
@@ -1448,7 +1428,8 @@
         while( constraint->source[index++] != 'L' ) {
             assert( constraint->source[index] != '\0' );
         }
-        VERIFY_REPORT( ctex, &(constraint->source[index]) );
+        VERIFY_REPORT( ctex, "Couldn't load class: "
+            << &(constraint->source[index]) );
         return VER_ErrorLoadClass;
     }
 
@@ -1479,7 +1460,7 @@
 /**
  * Function verifies class constraints.
  */
-Verifier_Result
+static Verifier_Result
 vf_verify_class_constraints( vf_Context_t *ctex )        // verifier context
 {
     // get method verify data
@@ -1815,8 +1796,6 @@
     return;
 } // vf_delete_pool_func
 
-} // namespace Verifier
-
 /**
  * Function provides final constraint checks for a given class.
  */
@@ -1834,7 +1813,7 @@
     context.m_dump.m_verify = verifyAll ? 1 : 0;
 
     // verified constraint for a given method
-    Verifier_Result result = Verifier::vf_verify_class_constraints( &context );
+    Verifier_Result result = vf_verify_class_constraints( &context );
     *message = context.m_error;
 
 #if _VERIFY_DEBUG



Mime
View raw message