harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcfi...@apache.org
Subject svn commit: r649574 [5/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/java5/stackmap_5.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/java5/stackmap_5.h?rev=649574&r1=649573&r2=649574&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/java5/stackmap_5.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/java5/stackmap_5.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 __STACKMAP5_H__
 #define __STACKMAP5_H__
 
@@ -26,341 +22,332 @@
 #include <assert.h>
 #include "../base/stackmap_x.h"
 
-using namespace CPVerifier;
-
-namespace CPVerifier_5 {
-
-    struct StackmapElement;
-    struct WorkmapElement;
-
-    //possible relations between verificaton types
-    enum ConstraintType {
-        CT_GENERIC = 0,         // sub-defined type A is assignable to sub-defined type B
-        CT_ARRAY2REF = 1,       // A is a known-type array. element of A is assignable to sub-defined type B
-        CT_EXPECTED_TYPE = 2,   // sub-defined type A is assignable to known-type B
-        CT_INCOMING_VALUE = 3   // known-type A is assignable to sub-defined type B
-    };
-
-    //structure for maintaining subroutine-specific data
-    //until subroutine is passed with the second (dataflow) pass we record to the wait list all JSR instructions
-    //calling this subroutine. Once the subroutine is over we continue 2nd pass for each wait-listed instruction
-    //see vf_Context_Base::SubroutineDone
-    struct SubroutineData {
-        Address caller;         //first JSR instruction that called this subroutine
-        short retCount;         //number of ret instructions for this subroutine
-        uint8  subrDataflowed;   // =1 if dataflow pass for the subroutine is over
-    };
-
-    //list constant verification type (i.e. known-type) that are assignable to some sub-definite type (i.e. StackMapElement)
-    //see StackmapElement
-    struct IncomingType {
-        //next in the list
-        IncomingType *nxt;
-
-        //value of the verification type recorded as int
-        //TODO: don't remember why it's 'int' rather than 'SmConstant'
-        int value;
-
-        //simple next in the list
-        IncomingType *next() {
-            return nxt;
-        }
-    };
-
-    //list of constraints for some sub-definite verification type (i.e. StackMapElement)
-    //see StackmapElement
-
-    struct Constraint {
-        //next in the list
-        Constraint *nxt;
-
-        //either
-        union {
-            StackmapElement *variable; // sub-definite verificarion type
-            int value;                 // or constant (known) verification type rcorded as int
-        };
-
-        //consatrint type
-        ConstraintType type;
-
-        //next constrait of type 't'
-        static Constraint *next(Constraint *cur, int t) {
-            while( cur && cur->type != t ) {
-                cur = (Constraint*)cur->next();
-            }
-            return cur;
-        }
-
-        //simple next in the list
-        Constraint *next() {
-            return nxt;
-        }
-    };
-
-    //constraint of the CT_EXPECTED_TYPE type: sub-defined type A is assignable to known-type B
-    struct ExpectedType : Constraint {
-        ExpectedType *next() {
-            return (ExpectedType *) Constraint::next(Constraint::next(), CT_EXPECTED_TYPE);
-        }
-    };
-
-    //constraint of the CT_GENERIC type: sub-defined type A is assignable to sub-defined type B
-    struct GenericCnstr : Constraint {
-        GenericCnstr *next() {
-            return (GenericCnstr *) Constraint::next(Constraint::next(), CT_GENERIC);
-        }
-    };
-
-    //constraint of the CT_ARRAY2REF type: A is a known-type array. element of A is assignable to sub-defined type B
-    struct ArrayCnstr : Constraint {
-        //there can be only one CT_ARRAY2REF per StackMap Element
-        ArrayCnstr *next() {
-            assert(0);
-            return 0;
-        }
-    };
-
-
-    //StackMapElement structure represens sub-definite verification type: we don't know what type is it, but
-    //we know about instructions that expect ExpectedTypes here and we know that IncomingValues can be here
-    //we also know that this type must be assignable to other sub-defenite types as indicated by CT_GENERIC
-    //constrains and there can be special limitations represented by CT_ARRAY2REF constraints
-    struct StackmapElement { //TODO: should be rewritten to save footprint
-        //list of IncomingType constraint
-        IncomingType *incoming;
-
-        //list of all the conatraints of other types
-        Constraint *others;
-
-        //return value from any IncomingType constraint
-        //when we need to compae to some unmergable type we don;t need to interate thru the list
-        //also used to assert that an IncomingValue constraint exists
-        SmConstant getAnyIncomingValue() {
-            assert(firstIncoming());
-            return firstIncoming()->value;
-        }
-
-        //return first IncomingType constraint
-        IncomingType *firstIncoming() {
-            //TODO: I have to store somewhere the "modified" bit. Sorry.
-            return (IncomingType*)( (POINTER_SIZE_INT)incoming & ~3 );
-        }
-
-        //return first conatrint of any type except IncomingType
-        Constraint *firstOthers() {
-            return others;
-        }
-
-        //return first CT_EXPECTED_TYPE constraint
-        ExpectedType *firstExpected() {
-            return (ExpectedType*)Constraint::next(others, CT_EXPECTED_TYPE);
-        }
-
-        //return first CT_GENERIC constraint
-        GenericCnstr *firstGenericCnstr() {
-            return (GenericCnstr*)Constraint::next(others, CT_GENERIC);
-        }
-
-        //return first (and the only) CT_ARRAY2REF constraint
-        ArrayCnstr *firstArrayCnstr() {
-            return (ArrayCnstr*)Constraint::next(others, CT_ARRAY2REF);
-        }
-
-        //clean-up
-        void init() {
-            incoming = 0;
-            others = 0;
-        }
-
-        //add incoming type with the 'value' value
-        void newIncomingType(Memory *mem, SmConstant value) {
-            IncomingType *in = (IncomingType *)mem->malloc(sizeof(IncomingType));
-
-            POINTER_SIZE_INT mask = (POINTER_SIZE_INT)incoming & 3;
-            incoming = (IncomingType *) ((POINTER_SIZE_INT)incoming & ~3);
-
-            in->nxt = value == SM_BOGUS ? 0 : incoming;
-            //in->type = CT_INCOMING_VALUE;
-            in->value = value.c;
-
-            incoming = in;
-
-            incoming = (IncomingType *) ((POINTER_SIZE_INT)incoming | mask);
-        }
-
-        //add expected type with the 'value' value
-        void newExpectedType(Memory *mem, SmConstant value) {
-            newConstraint(mem, CT_EXPECTED_TYPE)->value = value.c;
-        }
-
-        Constraint *newConstraint(Memory *mem, int type) {
-            Constraint *o = (Constraint *)mem->malloc(sizeof(Constraint));
-
-            o->nxt = others;
-            o->type = (ConstraintType)type;
-
-            others = o;
-            return o;
-        }
-
-        //add generic constraint ('this' is assignable to 'to')
-        void newGenericConstraint(Memory *mem, StackmapElement *to) {
-            newConstraint(mem, CT_GENERIC)->variable = to;
-        }
-
-        //add generic constraint ('this' is an array, which element is assignable to 'to')
-        void newArrayConversionConstraint(Memory *mem, StackmapElement *to) {
-            assert(!firstArrayCnstr());
-            newConstraint(mem, CT_ARRAY2REF)->variable = to;
-        }
-
-        // return 'modified' flag for the stackmap. the flag is stored in the first bit of the 'incoming' pointer
-        // "modified" is about subroutines: you have to track which locals were changed
-        int isJsrModified() {
-            return (int)(POINTER_SIZE_INT)incoming & 1;
-        }
-
-        //set 'modified' flag for the stackmap. the flag is stored in the first bit of the 'incoming' pointer
-        // "modified" is about subroutines: you have to track which locals were changed
-        void setJsrModified() {
-            incoming = (IncomingType *) ((POINTER_SIZE_INT)incoming | 1);
-        }
-
-        //clear 'modified' flag for the stackmap. the flag is stored in the first bit of the 'incoming' pointer
-        // "modified" is about subroutines: you have to track which locals were changed
-        void clearJsrModified() {
-            incoming = (IncomingType *) ((POINTER_SIZE_INT)incoming & ~1);
-        }
-    };
-
-    //WorkMapElement structure represent an element of the workmap vector -- vector of the derived types
-    //a type might be either constant (or known) (e.g. if some previous instruction has put something on stack or locals)
-    //or sub-definite (e.g. if we've recently passed a branch target and don't know which types were on stack or locals)
-    struct WorkmapElement {
-        //value. two low bits a used to store flags
-        union {
-            _SmConstant const_val;      //either a constant (known-type)
-            StackmapElement *var_ptr;   //or a variable (sub-definite type)
-        };
-
-        //is it a sub-definite (not constant) type?
-        int isVariable() {
-            assert(const_val != SM_NONE);
-            return !((POINTER_SIZE_INT)var_ptr & 1);
-        }
-
-        //get value for the constant (known) verification type
-        SmConstant getConst() {
-            return const_val;
-        }
-
-        //get variable representing sub-definite verification type
-        StackmapElement *getVariable() {
-            return (StackmapElement *) ((POINTER_SIZE_INT)var_ptr & ~3);
-        }
-
-        //when we need to compae to some unmergable type we don;t need to interate thru the list
-        //also used to assert that an IncomingValue constraint exists
-        SmConstant getAnyPossibleValue() {
-            SmConstant ret = isVariable() ? getVariable()->getAnyIncomingValue() : const_val;
-            assert(ret != SM_NONE);
-            return ret;
-        }
-
-        // return 'modified' flag for the workmap element. the flag is stored in the second bit of the union
-        //"modified" is about subroutines: you have to track which locals were changed
-        //it's easier to think of all the constants as "modified"
-        int isJsrModified() {
-            return (int)(POINTER_SIZE_INT)var_ptr & 3;
-        }
-
-        // set 'modified' flag for the workmap element. the flag is stored in the second bit of the union
-        void setJsrModified() {
-            if( isVariable() ) {
-                var_ptr = (StackmapElement*)((POINTER_SIZE_INT)var_ptr | 2);
-            }
-        }
-    };
-
-    //WorkmapElement type with some constructors
-    struct _WorkmapElement : WorkmapElement {
-        _WorkmapElement(WorkmapElement other) {
-            const_val = other.const_val;
-        }
-
-        _WorkmapElement(StackmapElement *s) {
-            var_ptr = s;
-            if( s->isJsrModified() ) {
-                setJsrModified();
-            }
-        }
-
-        _WorkmapElement(SmConstant c) {
-            const_val = c;
-        }
-    };
-
-    //Store various data for the given instruction. Possible data are: StackMap vector, WorkMap vector,
-    //Subroutine-specific data
-    //for a single instruction it might be either
-    // 1) no data
-    // 2) workmap only
-    // 3) stackmap only
-    // 4) stackmap and subroutine data. in this case two PropsHead structures are created the first one for the StackMap,
-    //    it's 'next' points to the second PropsHead containing Subroutine info. In this case second PropsHead keeps 0xFFFF
-    //    instead of 'instr'
-    // the list is used to organize storing Props as a HashTable
-    struct PropsHead : public PropsHeadBase {
-        typedef MapHead<WorkmapElement> WorkmapHead;
-        typedef MapHead<StackmapElement> StackmapHead;
-
-        // really one bit is used: FF_ISWORKMAP. TODO: merge with (Stack|Work)map->flags
-        unsigned short instr_flags; 
-
-        //possible flag value
-        static const short FF_ISWORKMAP = 1;
-
-        //actual properties
-        union {
-            WorkmapHead workmap;
-            StackmapHead stackmap;
-        };
-
-        //get workmap stored here
-        WorkmapHead *getWorkmap() {
-            assert(is_workmap());
-            return &workmap;
-        }
-
-        //get stackmap stored here
-        StackmapHead *getStackmap() {
-            assert(!is_workmap());
-            return &stackmap;
-        }
-
-        //get subroutine data stored here
-        SubroutineData *getSubrData(int el_cnt) {
-            assert(instr == 0xFFFF);
-            return (SubroutineData *) &stackmap.elements[el_cnt];
-        }
-
-        //is it a workmap?
-        int is_workmap() {
-            return instr_flags & FF_ISWORKMAP;
-        }
-
-        //set 'is workmap' flag
-        void set_as_workmap() {
-            instr_flags |= FF_ISWORKMAP;
-        }
-
-        //clear flag
-        void clearInstrFlag(short flag) {
-            instr_flags &= ~flag;
-        }
-    };
-
+struct StackmapElement_5;
+struct WorkmapElement_5;
 
-} // namespace CPVerifier_5
+//possible relations between verificaton types
+enum ConstraintType {
+    CT_GENERIC = 0,         // sub-defined type A is assignable to sub-defined type B
+    CT_ARRAY2REF = 1,       // A is a known-type array. element of A is assignable to sub-defined type B
+    CT_EXPECTED_TYPE = 2,   // sub-defined type A is assignable to known-type B
+    CT_INCOMING_VALUE = 3   // known-type A is assignable to sub-defined type B
+};
+
+//list constant verification type (i.e. known-type) that are assignable to some sub-definite type (i.e. StackMapElement)
+//see StackmapElement
+struct IncomingType {
+    //next in the list
+    IncomingType *nxt;
+
+    //value of the verification type recorded as int
+    //TODO: don't remember why it's 'int' rather than 'SmConstant'
+    int value;
+
+    //simple next in the list
+    IncomingType *next() {
+        return nxt;
+    }
+};
+
+//list of constraints for some sub-definite verification type (i.e. StackMapElement)
+//see StackmapElement
+struct Constraint {
+    //next in the list
+    Constraint *nxt;
+
+    //either
+    union {
+        StackmapElement_5 *variable; // sub-definite verificarion type
+        int value;                 // or constant (known) verification type rcorded as int
+    };
+
+    //consatrint type
+    ConstraintType type;
+
+    //next constrait of type 't'
+    static Constraint *next(Constraint *cur, int t) {
+        while( cur && cur->type != t ) {
+            cur = (Constraint*)cur->next();
+        }
+        return cur;
+    }
+
+    //simple next in the list
+    Constraint *next() {
+        return nxt;
+    }
+};
+
+//constraint of the CT_EXPECTED_TYPE type: sub-defined type A is assignable to known-type B
+struct ExpectedType : Constraint {
+    ExpectedType *next() {
+        return (ExpectedType *) Constraint::next(Constraint::next(), CT_EXPECTED_TYPE);
+    }
+};
+
+//constraint of the CT_GENERIC type: sub-defined type A is assignable to sub-defined type B
+struct GenericCnstr : Constraint {
+    GenericCnstr *next() {
+        return (GenericCnstr *) Constraint::next(Constraint::next(), CT_GENERIC);
+    }
+};
+
+//constraint of the CT_ARRAY2REF type: A is a known-type array. element of A is assignable to sub-defined type B
+struct ArrayCnstr : Constraint {
+    //there can be only one CT_ARRAY2REF per StackMap Element
+    ArrayCnstr *next() {
+        assert(0);
+        return 0;
+    }
+};
+
+//StackMapElement structure represens sub-definite verification type: we don't know what type is it, but
+//we know about instructions that expect ExpectedTypes here and we know that IncomingValues can be here
+//we also know that this type must be assignable to other sub-defenite types as indicated by CT_GENERIC
+//constrains and there can be special limitations represented by CT_ARRAY2REF constraints
+struct StackmapElement_5 { //TODO: should be rewritten to save footprint
+    //list of IncomingType constraint
+    IncomingType *incoming;
+
+    //list of all the conatraints of other types
+    Constraint *others;
+
+    //return value from any IncomingType constraint
+    //when we need to compae to some unmergable type we don;t need to interate thru the list
+    //also used to assert that an IncomingValue constraint exists
+    SmConstant getAnyIncomingValue() {
+        assert(firstIncoming());
+        return firstIncoming()->value;
+    }
+
+    //return first IncomingType constraint
+    IncomingType *firstIncoming() {
+        //TODO: I have to store somewhere the "modified" bit. Sorry.
+        return (IncomingType*)( (POINTER_SIZE_INT)incoming & ~3 );
+    }
+
+    //return first conatrint of any type except IncomingType
+    Constraint *firstOthers() {
+        return others;
+    }
+
+    //return first CT_EXPECTED_TYPE constraint
+    ExpectedType *firstExpected() {
+        return (ExpectedType*)Constraint::next(others, CT_EXPECTED_TYPE);
+    }
+
+    //return first CT_GENERIC constraint
+    GenericCnstr *firstGenericCnstr() {
+        return (GenericCnstr*)Constraint::next(others, CT_GENERIC);
+    }
+
+    //return first (and the only) CT_ARRAY2REF constraint
+    ArrayCnstr *firstArrayCnstr() {
+        return (ArrayCnstr*)Constraint::next(others, CT_ARRAY2REF);
+    }
+
+    //clean-up
+    void init() {
+        incoming = 0;
+        others = 0;
+    }
+
+    //add incoming type with the 'value' value
+    void newIncomingType(Memory *mem, SmConstant value) {
+        IncomingType *in = (IncomingType *)mem->malloc(sizeof(IncomingType));
+
+        POINTER_SIZE_INT mask = (POINTER_SIZE_INT)incoming & 3;
+        incoming = (IncomingType *) ((POINTER_SIZE_INT)incoming & ~3);
+
+        in->nxt = value == SM_BOGUS ? 0 : incoming;
+        //in->type = CT_INCOMING_VALUE;
+        in->value = value.c;
+
+        incoming = in;
+
+        incoming = (IncomingType *) ((POINTER_SIZE_INT)incoming | mask);
+    }
+
+    //add expected type with the 'value' value
+    void newExpectedType(Memory *mem, SmConstant value) {
+        newConstraint(mem, CT_EXPECTED_TYPE)->value = value.c;
+    }
+
+    Constraint *newConstraint(Memory *mem, int type) {
+        Constraint *o = (Constraint *)mem->malloc(sizeof(Constraint));
+
+        o->nxt = others;
+        o->type = (ConstraintType)type;
+
+        others = o;
+        return o;
+    }
+
+    //add generic constraint ('this' is assignable to 'to')
+    void newGenericConstraint(Memory *mem, StackmapElement_5 *to) {
+        newConstraint(mem, CT_GENERIC)->variable = to;
+    }
+
+    //add generic constraint ('this' is an array, which element is assignable to 'to')
+    void newArrayConversionConstraint(Memory *mem, StackmapElement_5 *to) {
+        assert(!firstArrayCnstr());
+        newConstraint(mem, CT_ARRAY2REF)->variable = to;
+    }
+
+    // return 'modified' flag for the stackmap. the flag is stored in the first bit of the 'incoming' pointer
+    // "modified" is about subroutines: you have to track which locals were changed
+    int isJsrModified() {
+        return (int)(POINTER_SIZE_INT)incoming & 1;
+    }
+
+    //set 'modified' flag for the stackmap. the flag is stored in the first bit of the 'incoming' pointer
+    // "modified" is about subroutines: you have to track which locals were changed
+    void setJsrModified() {
+        incoming = (IncomingType *) ((POINTER_SIZE_INT)incoming | 1);
+    }
+
+    //clear 'modified' flag for the stackmap. the flag is stored in the first bit of the 'incoming' pointer
+    // "modified" is about subroutines: you have to track which locals were changed
+    void clearJsrModified() {
+        incoming = (IncomingType *) ((POINTER_SIZE_INT)incoming & ~1);
+    }
+};
+
+//WorkMapElement structure represent an element of the workmap vector -- vector of the derived types
+//a type might be either constant (or known) (e.g. if some previous instruction has put something on stack or locals)
+//or sub-definite (e.g. if we've recently passed a branch target and don't know which types were on stack or locals)
+struct WorkmapElement_5 {
+    //value. two low bits a used to store flags
+    union {
+        _SmConstant const_val;      //either a constant (known-type)
+        StackmapElement_5 *var_ptr;   //or a variable (sub-definite type)
+    };
+
+    //is it a sub-definite (not constant) type?
+    int isVariable() {
+        assert(const_val != SM_NONE);
+        return !((POINTER_SIZE_INT)var_ptr & 1);
+    }
+
+    //get value for the constant (known) verification type
+    SmConstant getConst() {
+        return const_val;
+    }
+
+    //get variable representing sub-definite verification type
+    StackmapElement_5 *getVariable() {
+        return (StackmapElement_5 *) ((POINTER_SIZE_INT)var_ptr & ~3);
+    }
+
+    //when we need to compae to some unmergable type we don;t need to interate thru the list
+    //also used to assert that an IncomingValue constraint exists
+    SmConstant getAnyPossibleValue() {
+        SmConstant ret = isVariable() ? getVariable()->getAnyIncomingValue() : const_val;
+        assert(ret != SM_NONE);
+        return ret;
+    }
+
+    // return 'modified' flag for the workmap element. the flag is stored in the second bit of the union
+    //"modified" is about subroutines: you have to track which locals were changed
+    //it's easier to think of all the constants as "modified"
+    int isJsrModified() {
+        return (int)(POINTER_SIZE_INT)var_ptr & 3;
+    }
+
+    // set 'modified' flag for the workmap element. the flag is stored in the second bit of the union
+    void setJsrModified() {
+        if( isVariable() ) {
+            var_ptr = (StackmapElement_5*)((POINTER_SIZE_INT)var_ptr | 2);
+        }
+    }
+};
+
+//WorkmapElement type with some constructors
+struct _WorkmapElement_5 : WorkmapElement_5 {
+    _WorkmapElement_5(WorkmapElement_5 other) {
+        const_val = other.const_val;
+    }
+
+    _WorkmapElement_5(StackmapElement_5 *s) {
+        var_ptr = s;
+        if( s->isJsrModified() ) {
+            setJsrModified();
+        }
+    }
+
+    _WorkmapElement_5(SmConstant c) {
+        const_val = c;
+    }
+};
+
+//possible flag value
+static const short FF_ISWORKMAP = 1;
+
+//structure for maintaining subroutine-specific data
+//until subroutine is passed with the second (dataflow) pass we record to the wait list all JSR instructions
+//calling this subroutine. Once the subroutine is over we continue 2nd pass for each wait-listed instruction
+//see vf_Context_Base::SubroutineDone
+struct SubroutineData {
+    Address caller;         //first JSR instruction that called this subroutine
+    short retCount;         //number of ret instructions for this subroutine
+    uint8  subrDataflowed;   // =1 if dataflow pass for the subroutine is over
+};
+
+//Store various data for the given instruction. Possible data are: StackMap vector, WorkMap vector,
+//Subroutine-specific data
+//for a single instruction it might be either
+// 1) no data
+// 2) workmap only
+// 3) stackmap only
+// 4) stackmap and subroutine data. in this case two PropsHead structures are created the first one for the StackMap,
+//    it's 'next' points to the second PropsHead containing Subroutine info. In this case second PropsHead keeps 0xFFFF
+//    instead of 'instr'
+// the list is used to organize storing Props as a HashTable
+struct PropsHead_5 : public PropsHeadBase {
+    typedef MapHead<WorkmapElement_5> WorkmapHead;
+    typedef MapHead<StackmapElement_5> StackmapHead;
+
+    // really one bit is used: FF_ISWORKMAP. TODO: merge with (Stack|Work)map->flags
+    unsigned short instr_flags; 
+
+    //actual properties
+    union {
+        WorkmapHead workmap;
+        StackmapHead stackmap;
+    };
+
+    //get workmap stored here
+    WorkmapHead *getWorkmap() {
+        assert(is_workmap());
+        return &workmap;
+    }
+
+    //get stackmap stored here
+    StackmapHead *getStackmap() {
+        assert(!is_workmap());
+        return &stackmap;
+    }
+
+    //get subroutine data stored here
+    SubroutineData *getSubrData(int el_cnt) {
+        assert(instr == 0xFFFF);
+        return (SubroutineData *) &stackmap.elements[el_cnt];
+    }
+
+    //is it a workmap?
+    int is_workmap() {
+        return instr_flags & FF_ISWORKMAP;
+    }
+
+    //set 'is workmap' flag
+    void set_as_workmap() {
+        instr_flags |= FF_ISWORKMAP;
+    }
+
+    //clear flag
+    void clearInstrFlag(short flag) {
+        instr_flags &= ~flag;
+    }
+};
 
 #endif

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/java6/context_6.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/java6/context_6.cpp?rev=649574&r1=649573&r2=649574&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/java6/context_6.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/java6/context_6.cpp Fri Apr 18 08:29:36 2008
@@ -14,431 +14,424 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-/** 
- * @author Mikhail Loenko, Vladimir Molotkov
- */  
-
 #include "open/vm_method_access.h"
 
 #include "context_6.h"
 
-namespace CPVerifier_6 {
+/**
+ * Does Java6 verification of a method.
+ */
+vf_Result vf_Context_6::verify_method(Method_Handle method) {
+    vf_Result tcr;
 
-    /*
-    * Do Java6 verification of a method
-    */
-    vf_Result vf_Context_6::verify_method(Method_Handle method) {
-        vf_Result tcr;
+    //nothing to verify
+    if( !method_get_bytecode_length( method ) ) {
+        return VF_OK;
+    }
 
-        //nothing to verify
-        if( !method_get_bytecode_length( method ) ) {
-            return VF_OK;
-        }
+    //load memory storage, read variable like max_stack, etc
+    init(method);
 
-        //load memory storage, read variable like max_stack, etc
-        init(method);
+    //create workmap for zero instruction from method arguments
+    if((tcr = create_method_initial_workmap()) != VF_OK ) {
+        return tcr;
+    }
 
-        //create workmap for zero instruction from method arguments
-        if((tcr = create_method_initial_workmap()) != VF_OK ) {
-            return tcr;
-        }
+    //parse stackmaptable, create Stackmaps for jump targets and exception handlers (catch block starts)
+    if((tcr = load_stackmaptable()) != VF_OK ) {
+        return tcr;
+    }
 
-        //parse stackmaptable, create Stackmaps for jump targets and exception handlers (catch block starts)
-        if((tcr = load_stackmaptable()) != VF_OK ) {
-            return tcr;
-        }
+    //////////////////////////// Check Exception Handlers (catch block starts) /////////////////////////
 
-        //////////////////////////// Check Exception Handlers (catch block starts) /////////////////////////
+    for( unsigned short idx = 0; idx < m_handlecount; idx++ ) {
+        uint16 start_pc;
+        uint16 end_pc;
+        uint16 handler_pc;
+        uint16 handler_cp_index;
+
+        method_get_exc_handler_info( m_method, idx, &start_pc, &end_pc,
+            &handler_pc, &handler_cp_index );
+
+        //just in case: it has been checked in classloader
+        if( start_pc >= end_pc || end_pc > m_code_length ) {
+            return error(VF_ErrorHandler, "start_pc >= end_pc OR end_pc > code_length");
+        }
 
-        for( unsigned short idx = 0; idx < m_handlecount; idx++ ) {
-            unsigned short start_pc;
-            unsigned short end_pc;
-            unsigned short handler_pc;
-            unsigned short handler_cp_index;
-
-            method_get_exc_handler_info( m_method, idx, &start_pc, &end_pc,
-                &handler_pc, &handler_cp_index );
-
-            //just in case: it has been checked in classloader
-            if( start_pc >= end_pc || end_pc > m_code_length ) {
-                return error(VF_ErrorHandler, "start_pc >= end_pc OR end_pc > code_length");
-            }
-
-            SmConstant handler_type;
-            if( handler_cp_index ) {
-                //check that expected exception is of type throwable
-                if( !tpool.cpool_get_class(handler_cp_index, &handler_type) ||
-                    !tpool.mustbe_assignable(handler_type, tpool.sm_get_const_throwable()) )
-                {
-                    return error(VF_ErrorHandler, "incorrect constantpool entry");
-                }
-            } else {
-                handler_type = tpool.sm_get_const_throwable();
+        SmConstant handler_type;
+        if( handler_cp_index ) {
+            //check that expected exception is of type throwable
+            if( !tpool.cpool_get_class(handler_cp_index, &handler_type) ||
+                !tpool.mustbe_assignable(handler_type, tpool.sm_get_const_throwable()) )
+            {
+                return error(VF_ErrorHandler, "incorrect constantpool entry");
             }
+        } else {
+            handler_type = tpool.sm_get_const_throwable();
+        }
 
-            //check stackmap at the point of exception handler
-            if((tcr = checkHandlerStackmap(handler_pc, handler_type)) != VF_OK ) {
-                return tcr;
-            }
+        //check stackmap at the point of exception handler
+        if((tcr = checkHandlerStackmap(handler_pc, handler_type)) != VF_OK ) {
+            return tcr;
         }
+    }
 
-        //use Java5 method to find first applicable try block
-        next_start_pc = 0;
+    //use Java5 method to find first applicable try block
+    next_start_pc = 0;
 
-        //////////////////////////// Dataflow Pass /////////////////////////
+    //////////////////////////// Dataflow Pass /////////////////////////
 
-        Address instr = 0;
-        int afterJump = false;
-        while( instr < m_code_length ) {
+    Address instr = 0;
+    int afterJump = false;
+    while( instr < m_code_length ) {
+
+        OpCode opcode = (OpCode)m_bytecode[instr];
+        processed_instruction = instr;
+
+        // does code correspond to any valid instruction?
+        if( !instr_is_valid_bytecode(opcode) || instr_is_jsr(opcode) ) {
+            //to check WIDE RET we need to check m_code_length
+            //anyway check for JSR is enough
+            return error(VF_ErrorInstruction, "invalid opcode");
+        }
 
-            OpCode opcode = (OpCode)m_bytecode[instr];
-            processed_instruction = instr;
+        // keep all nessesary information about instruction
+        ParseInfo &pi = instr_get_parse_info(opcode);
 
-            // does code correspond to any valid instruction?
-            if( !instr_is_valid_bytecode(opcode) || instr_is_jsr(opcode) ) {
-                //to check WIDE RET we need to check m_code_length
-                //anyway check for JSR is enough
-                return error(VF_ErrorInstruction, "invalid opcode");
-            }
+        // get MINIMAL length of the instruction with operands
+        unsigned instr_len = instr_get_minlen(pi);
 
-            // keep all nessesary information about instruction
-            ParseInfo &pi = instr_get_parse_info(opcode);
+        // code does not correspond to any valid instruction or method length is less than required
+        if( instr + instr_len > m_code_length ) {
+            return error(VF_ErrorInstruction, "method length is less than required");
+        }
 
-            // get MINIMAL length of the instruction with operands
-            unsigned instr_len = instr_get_minlen(pi);
+        if( instr_is_compound(opcode, pi) ) {
+            // get ACTUAL length for variable length insgtructions
+            instr_len = instr_get_len_compound(instr, opcode);
 
-            // code does not correspond to any valid instruction or method length is less than required
+            // method length is less than required
             if( instr + instr_len > m_code_length ) {
-                return error(VF_ErrorInstruction, "method length is less than required");
-            }
-
-            if( instr_is_compound(opcode, pi) ) {
-                // get ACTUAL length for variable length insgtructions
-                instr_len = instr_get_len_compound(instr, opcode);
-
-                // method length is less than required
-                if( instr + instr_len > m_code_length ) {
-                    return error(VF_ErrorInstruction, "compound instruction: method length is less than required");
-                }
+                return error(VF_ErrorInstruction, "compound instruction: method length is less than required");
             }
+        }
 
-            // check that no other instruction jumps to the middle of the current instruction
-            for( Address i = instr + 1; i < instr + instr_len; i++ ) {
-                if( props.getInstrProps(i) ) {
-                    //there is a stack map recorded for this instruction
-                    return error(VF_ErrorStackmap, "StackMapTable at the middle of instruction");
-                }
+        // check that no other instruction jumps to the middle of the current instruction
+        for( Address i = instr + 1; i < instr + instr_len; i++ ) {
+            if( props.getInstrProps(i) ) {
+                //there is a stack map recorded for this instruction
+                return error(VF_ErrorStackmap, "StackMapTable at the middle of instruction");
             }
+        }
 
 
-            /////////////////////////////////////////////////////////////////////////
-
-            if( props.getInstrProps(instr) ) {
-                //if instruction has a stackmap
-                if( !afterJump && (tcr=new_generic_vector_constraint(instr)) != VF_OK ) {
-                    return tcr;
-                }
+        /////////////////////////////////////////////////////////////////////////
 
-                fill_workmap(instr);
-            } else {
-                if( afterJump ) return error(VF_ErrorBranch, "Stackmap expected");
-            }
-            afterJump = false;
-
-            //check IN types, create OUT types, check exception
-            if( (tcr=dataflow_instruction(instr)) != VF_OK ) {
+        if( props.getInstrProps(instr) ) {
+            //if instruction has a stackmap
+            if( !afterJump && (tcr=new_generic_vector_constraint(instr)) != VF_OK ) {
                 return tcr;
             }
 
-            if( instr_is_jump(pi) ) {
-                afterJump = instr_direct(pi, opcode, m_bytecode, instr);
+            fill_workmap(instr);
+        } else {
+            if( afterJump ) return error(VF_ErrorBranch, "Stackmap expected");
+        }
+        afterJump = false;
 
-                Address target = instr_get_jump_target(pi, m_bytecode, instr);
+        //check IN types, create OUT types, check exception
+        if( (tcr=dataflow_instruction(instr)) != VF_OK ) {
+            return tcr;
+        }
 
-                if( (tcr=new_generic_vector_constraint(target)) != VF_OK ) {
-                    return tcr;
-                }
-            } else if( instr_direct(pi, opcode, m_bytecode, instr) ) {
-                // it is not a jump ==> it is ret, return or throw
-                afterJump = true;
-            } else if( instr_is_switch(pi) ) {
-                afterJump = true;
+        if( instr_is_jump(pi) ) {
+            afterJump = instr_direct(pi, opcode, m_bytecode, instr);
 
-                Address next_target_adr = (instr & (~3) ) + 4;
+            Address target = instr_get_jump_target(pi, m_bytecode, instr);
 
-                //default target
-                Address target = instr + read_int32(m_bytecode + next_target_adr);
+            if( (tcr=new_generic_vector_constraint(target)) != VF_OK ) {
+                return tcr;
+            }
+        } else if( instr_direct(pi, opcode, m_bytecode, instr) ) {
+            // it is not a jump ==> it is ret, return or throw
+            afterJump = true;
+        } else if( instr_is_switch(pi) ) {
+            afterJump = true;
+
+            Address next_target_adr = (instr & (~3) ) + 4;
+
+            //default target
+            Address target = instr + read_int32(m_bytecode + next_target_adr);
+            new_generic_vector_constraint(target);
+
+            // in tableswitch instruction target offsets are stored with shift = 4,
+            // in lookupswitch with shift = 8
+            int shift = (opcode == OP_TABLESWITCH) ? 4 : 8;
+
+            // process conditional jump target
+            for (next_target_adr += 12;
+                next_target_adr < instr + instr_len;
+                next_target_adr += shift)
+            {
+                target = instr + read_int32(m_bytecode + next_target_adr);
                 new_generic_vector_constraint(target);
-
-                // in tableswitch instruction target offsets are stored with shift = 4,
-                // in lookupswitch with shift = 8
-                int shift = (opcode == OP_TABLESWITCH) ? 4 : 8;
-
-                // process conditional jump target
-                for (next_target_adr += 12;
-                    next_target_adr < instr + instr_len;
-                    next_target_adr += shift)
-                {
-                    target = instr + read_int32(m_bytecode + next_target_adr);
-                    new_generic_vector_constraint(target);
-                }
-            } else {
-                assert( instr_is_regular(pi) );
             }
-            instr += instr_len;
+        } else {
+            assert( instr_is_regular(pi) );
         }
-
-        // control went out of method bounds
-        return afterJump ? VF_OK : error(VF_ErrorCodeEnd, "control went out of method bounds");
+        instr += instr_len;
     }
 
+    // control went out of method bounds
+    return afterJump ? VF_OK : error(VF_ErrorCodeEnd, "control went out of method bounds");
+}
 
-    /*
-    * parse StackMapTable attribute and store Stackmap vectors for the instructions 
-    */
-    vf_Result vf_Context_6::load_stackmaptable() {
-        vf_Result tcr;
 
-        uint8* stackmaptable = method_get_stackmaptable(m_method);
+/**
+ * Parses StackMapTable attribute and store Stackmap vectors for the instructions.
+ */
+vf_Result vf_Context_6::load_stackmaptable() {
+    vf_Result tcr;
 
-        if(!stackmaptable) return VF_OK;
+    Byte* stackmaptable = method_get_stackmaptable(m_method);
 
-        uint8* read_ptr = stackmaptable;
+    if(!stackmaptable) return VF_OK;
 
-        read_ptr+=2; //skip uint16 attribute_name_index
+    Byte* read_ptr = stackmaptable;
 
-        uint32 attribute_length = read_int32(read_ptr); 
-        read_ptr+=4;
-        uint8 *attribute_end = stackmaptable + attribute_length + 6;
+    read_ptr+=2; //skip uint16 attribute_name_index
 
-        if( read_ptr + 2 > attribute_end ) return error(VF_ErrorStackmap, "corrupted StackMapTable");
-        uint16 number_of_entries = read_int16(read_ptr);
-        read_ptr+=2;
+    uint32 attribute_length = read_int32(read_ptr); 
+    read_ptr+=4;
+    Byte *attribute_end = stackmaptable + attribute_length + 6;
 
-        //create working copy fr previous stackmap frame, offeset, and number of locals
-        WorkmapHead *lastWorkmap = newWorkmap(m_stack_start + m_max_stack);
-        tc_memcpy(lastWorkmap, workmap, sizeof(WorkmapHead) + sizeof(WorkmapElement) * (m_stack_start + workmap->depth));
-
-        unsigned last_maxlocals = m_max_locals;
-        while( last_maxlocals > 0 ) {
-            if( workmap->elements[last_maxlocals - 1].const_val != SM_BOGUS ) 
-            {
-                break;
-            }
-            last_maxlocals--;
-        }
+    if( read_ptr + 2 > attribute_end ) return error(VF_ErrorStackmap, "corrupted StackMapTable");
+    uint16 number_of_entries = read_int16(read_ptr);
+    read_ptr+=2;
 
-        int last_offset = -1;
+    //create working copy fr previous stackmap frame, offeset, and number of locals
+    WorkmapHead *lastWorkmap = newWorkmap(m_stack_start + m_max_stack);
+    tc_memcpy(lastWorkmap, workmap, sizeof(WorkmapHead) + sizeof(WorkmapElement_6) * (m_stack_start + workmap->depth));
 
-        for( unsigned entry = 0; entry < number_of_entries; entry++) {
-            if( read_ptr + 1 > attribute_end ) return error(VF_ErrorStackmap, "corrupted StackMapTable");
+    unsigned last_maxlocals = m_max_locals;
+    while( last_maxlocals > 0 ) {
+        if( workmap->elements[last_maxlocals - 1].const_val != SM_BOGUS ) 
+        {
+            break;
+        }
+        last_maxlocals--;
+    }
 
-            uint8 frame_type = (*read_ptr++);
-            unsigned offset;
-            if( frame_type <= 63 ) { // 0-63
-                //same locals as previous, stack is empty. offset calculated from frame_type
-                offset = frame_type;
-                lastWorkmap->depth = 0;
+    int last_offset = -1;
 
-            } else if (frame_type <= 127 ) { //64-127 
-                //same locals as previous, stack contains single element specified here. offset calculated from frame_type
-                offset = frame_type - 64;
+    for( unsigned entry = 0; entry < number_of_entries; entry++) {
+        if( read_ptr + 1 > attribute_end ) return error(VF_ErrorStackmap, "corrupted StackMapTable");
 
-                unsigned k = 1; // k may change in read_types(): if it's LONG or DOUBLE stack size will be '2'
-                if( (tcr=read_types(&read_ptr, attribute_end, &lastWorkmap->elements[m_stack_start], &k, m_max_stack)) != VF_OK ) {
-                    return tcr;
-                }
-                lastWorkmap->depth = k;
+        uint8 frame_type = (*read_ptr++);
+        unsigned offset;
+        if( frame_type <= 63 ) { // 0-63
+            //same locals as previous, stack is empty. offset calculated from frame_type
+            offset = frame_type;
+            lastWorkmap->depth = 0;
+
+        } else if (frame_type <= 127 ) { //64-127 
+            //same locals as previous, stack contains single element specified here. offset calculated from frame_type
+            offset = frame_type - 64;
 
-            } else if (frame_type <= 246 ) {
-                //reserved
-                error(VF_ErrorStackmap, "corrupted StackMapTable");
-
-            } else if (frame_type == 247 ) {
-                //same locals as previous, stack contains single element specified here. offset is explicitely specified
-                if( read_ptr + 2 > attribute_end ) return error(VF_ErrorStackmap, "corrupted StackMapTable");
-                offset = read_int16(read_ptr);
-                read_ptr+=2;
-
-                unsigned k = 1; // k may change in read_types(): if it's LONG or DOUBLE stack size will be '2'
-                if( (tcr=read_types(&read_ptr, attribute_end, &lastWorkmap->elements[m_stack_start], &k, m_max_stack)) != VF_OK ) {
-                    return tcr;
-                }
-                lastWorkmap->depth = k;
+            unsigned k = 1; // k may change in read_types(): if it's LONG or DOUBLE stack size will be '2'
+            if( (tcr=read_types(&read_ptr, attribute_end, &lastWorkmap->elements[m_stack_start], &k, m_max_stack)) != VF_OK ) {
+                return tcr;
+            }
+            lastWorkmap->depth = k;
 
-            } else if (frame_type <= 250) { // 248-250
-                //stack is empty, locals the same (tail is cut)
-                unsigned k = 251 - frame_type; // last k locals are missing (k may change if there are LONG or DOUBLE there)
+        } else if (frame_type <= 246 ) {
+            //reserved
+            error(VF_ErrorStackmap, "corrupted StackMapTable");
+
+        } else if (frame_type == 247 ) {
+            //same locals as previous, stack contains single element specified here. offset is explicitely specified
+            if( read_ptr + 2 > attribute_end ) return error(VF_ErrorStackmap, "corrupted StackMapTable");
+            offset = read_int16(read_ptr);
+            read_ptr+=2;
 
-                while ( k ) {
-                    if( 0 == last_maxlocals-- ) return error(VF_ErrorStackmap, "corrupted StackMapTable");
+            unsigned k = 1; // k may change in read_types(): if it's LONG or DOUBLE stack size will be '2'
+            if( (tcr=read_types(&read_ptr, attribute_end, &lastWorkmap->elements[m_stack_start], &k, m_max_stack)) != VF_OK ) {
+                return tcr;
+            }
+            lastWorkmap->depth = k;
 
-                    if( lastWorkmap->elements[last_maxlocals].const_val == SM_HIGH_WORD) {
-                        ++k;
-                    }
+        } else if (frame_type <= 250) { // 248-250
+            //stack is empty, locals the same (tail is cut)
+            unsigned k = 251 - frame_type; // last k locals are missing (k may change if there are LONG or DOUBLE there)
 
-                    lastWorkmap->elements[last_maxlocals].const_val = SmConstant(SM_BOGUS);
-                    --k;
-                }
+            while ( k ) {
+                if( 0 == last_maxlocals-- ) return error(VF_ErrorStackmap, "corrupted StackMapTable");
 
-                if( read_ptr + 2 > attribute_end ) return error(VF_ErrorStackmap, "corrupted StackMapTable");
-                offset = read_int16(read_ptr);
-                read_ptr+=2;
-
-                lastWorkmap->depth = 0;
-            } else if (frame_type == 251 ) { // 251
-                //same locals as previous, stack is empty. offset is explicitely specified
-                if( read_ptr + 2 > attribute_end ) return error(VF_ErrorStackmap, "corrupted StackMapTable");
-                offset = read_int16(read_ptr);
-                read_ptr+=2;
-
-                lastWorkmap->depth = 0;
-            } else if (frame_type <= 254 ) { // 252-254
-                //stack is empty, locals are extended
-                if( read_ptr + 2 > attribute_end ) return error(VF_ErrorStackmap, "corrupted StackMapTable");
-                offset = read_int16(read_ptr);
-                read_ptr+=2;
-
-                unsigned k = frame_type - 251; //may change in read_types()
-                if( (tcr=read_types(&read_ptr, attribute_end, &lastWorkmap->elements[last_maxlocals], &k, m_max_locals - last_maxlocals)) != VF_OK ) {
-                    return tcr;
+                if( lastWorkmap->elements[last_maxlocals].const_val == SM_HIGH_WORD) {
+                    ++k;
                 }
-                last_maxlocals += k;
-
-                lastWorkmap->depth = 0;
-            } else {
-                //all entries are specified explicitely
-                assert(frame_type == 255);
-
-                if( read_ptr + 4 > attribute_end ) return error(VF_ErrorStackmap, "corrupted StackMapTable");
-                offset = read_int16(read_ptr);
-                read_ptr+=2;
 
-                last_maxlocals = read_int16(read_ptr); //may change in read_types()
-                read_ptr+=2;
+                lastWorkmap->elements[last_maxlocals].const_val = SmConstant(SM_BOGUS);
+                --k;
+            }
 
-                if( (tcr=read_types(&read_ptr, attribute_end, &lastWorkmap->elements[0], &last_maxlocals, m_max_locals)) != VF_OK ) {
-                    return tcr;
-                }
+            if( read_ptr + 2 > attribute_end ) return error(VF_ErrorStackmap, "corrupted StackMapTable");
+            offset = read_int16(read_ptr);
+            read_ptr+=2;
 
-                for( unsigned i = last_maxlocals; i < m_stack_start; i++ ) {
-                    lastWorkmap->elements[i].const_val = SmConstant(SM_BOGUS);
-                }
+            lastWorkmap->depth = 0;
+        } else if (frame_type == 251 ) { // 251
+            //same locals as previous, stack is empty. offset is explicitely specified
+            if( read_ptr + 2 > attribute_end ) return error(VF_ErrorStackmap, "corrupted StackMapTable");
+            offset = read_int16(read_ptr);
+            read_ptr+=2;
 
-                if( read_ptr + 2 > attribute_end ) return error(VF_ErrorStackmap, "corrupted StackMapTable");
-                unsigned depth = read_int16(read_ptr); //may change in read_types()
-                read_ptr+=2;
+            lastWorkmap->depth = 0;
+        } else if (frame_type <= 254 ) { // 252-254
+            //stack is empty, locals are extended
+            if( read_ptr + 2 > attribute_end ) return error(VF_ErrorStackmap, "corrupted StackMapTable");
+            offset = read_int16(read_ptr);
+            read_ptr+=2;
 
-                if( (tcr=read_types(&read_ptr, attribute_end, &lastWorkmap->elements[m_stack_start], &depth, m_max_stack)) != VF_OK ) {
-                    return tcr;
-                }
-                lastWorkmap->depth = depth;
+            unsigned k = frame_type - 251; //may change in read_types()
+            if( (tcr=read_types(&read_ptr, attribute_end, &lastWorkmap->elements[last_maxlocals], &k, m_max_locals - last_maxlocals)) != VF_OK ) {
+                return tcr;
             }
+            last_maxlocals += k;
+
+            lastWorkmap->depth = 0;
+        } else {
+            //all entries are specified explicitely
+            assert(frame_type == 255);
 
-            //calculate instruction address
-            last_offset = last_offset == -1 ? offset : last_offset + offset + 1;
+            if( read_ptr + 4 > attribute_end ) return error(VF_ErrorStackmap, "corrupted StackMapTable");
+            offset = read_int16(read_ptr);
+            read_ptr+=2;
 
-            //record stackmap for the instruction
-            PropsHead *pro = newStackmap(m_stack_start + lastWorkmap->depth);
-            props.setInstrProps(last_offset, pro);
-            StackmapHead *sm = pro->getStackmap();
+            last_maxlocals = read_int16(read_ptr); //may change in read_types()
+            read_ptr+=2;
 
-            //set stack depth
-            sm->depth = lastWorkmap->depth;
+            if( (tcr=read_types(&read_ptr, attribute_end, &lastWorkmap->elements[0], &last_maxlocals, m_max_locals)) != VF_OK ) {
+                return tcr;
+            }
 
-            unsigned i = 0;
-            SmConstant flag_element = tpool.sm_get_const_this();
-            //copy obtained data to stackmap of the instruction, check whether there is SM_THISUNINIT on stack or in locals
-            for( ; i < m_max_locals; i++ ) {
-                sm->elements[i].const_val = lastWorkmap->elements[i].const_val;
-                if( sm->elements[i].const_val == SM_THISUNINIT ) flag_element = SmConstant(SM_THISUNINIT);
+            for( unsigned i = last_maxlocals; i < m_stack_start; i++ ) {
+                lastWorkmap->elements[i].const_val = SmConstant(SM_BOGUS);
             }
 
-            //skip copying workmap->elements[m_max_locals] that in case of constructor contains flags
+            if( read_ptr + 2 > attribute_end ) return error(VF_ErrorStackmap, "corrupted StackMapTable");
+            unsigned depth = read_int16(read_ptr); //may change in read_types()
+            read_ptr+=2;
 
-            for( i = m_stack_start; i < m_stack_start + lastWorkmap->depth; i++ ) {
-                sm->elements[i].const_val = lastWorkmap->elements[i].const_val;
-                if( sm->elements[i].const_val == SM_THISUNINIT ) flag_element = SmConstant(SM_THISUNINIT);
+            if( (tcr=read_types(&read_ptr, attribute_end, &lastWorkmap->elements[m_stack_start], &depth, m_max_stack)) != VF_OK ) {
+                return tcr;
             }
+            lastWorkmap->depth = depth;
+        }
 
-            //initialize the flags
-            if( m_is_constructor ) sm->elements[m_max_locals].const_val = flag_element;
+        //calculate instruction address
+        last_offset = last_offset == -1 ? offset : last_offset + offset + 1;
 
+        //record stackmap for the instruction
+        PropsHead_6 *pro = newStackmap(m_stack_start + lastWorkmap->depth);
+        props.setInstrProps(last_offset, pro);
+        StackmapHead *sm = pro->getStackmap();
+
+        //set stack depth
+        sm->depth = lastWorkmap->depth;
+
+        unsigned i = 0;
+        SmConstant flag_element = tpool.sm_get_const_this();
+        //copy obtained data to stackmap of the instruction, check whether there is SM_THISUNINIT on stack or in locals
+        for( ; i < m_max_locals; i++ ) {
+            sm->elements[i].const_val = lastWorkmap->elements[i].const_val;
+            if( sm->elements[i].const_val == SM_THISUNINIT ) flag_element = SmConstant(SM_THISUNINIT);
         }
 
-        if( read_ptr < attribute_end ) return error(VF_ErrorStackmap, "corrupted StackMapTable");
-        return VF_OK;
+        //skip copying workmap->elements[m_max_locals] that in case of constructor contains flags
+
+        for( i = m_stack_start; i < m_stack_start + lastWorkmap->depth; i++ ) {
+            sm->elements[i].const_val = lastWorkmap->elements[i].const_val;
+            if( sm->elements[i].const_val == SM_THISUNINIT ) flag_element = SmConstant(SM_THISUNINIT);
+        }
+
+        //initialize the flags
+        if( m_is_constructor ) sm->elements[m_max_locals].const_val = flag_element;
+
     }
 
-    /*
-    * Read cnt types from a row bytearray representing StackMapTable and record to workmap starting at 
-    * the specified element. If Long or Double happens in StackMapTable, record SM_HIGH_WORD after SM_LONG or SM_DOUBLE
-    * to the workmap and increase cnt. Check space_available when record to the workmap
-    */
-    vf_Result vf_Context_6::read_types(uint8 **attr, uint8 *end, WorkmapElement* element, unsigned *cnt, unsigned space_available) {
-        uint16 idx = 0;
-        //read (*cnt) types
-        while( idx < *cnt ) {
-
-            //attribute truncated?
-            if( (*attr) > end ) return error(VF_ErrorStackmap, "corrupted StackMapTable");
-
-            //more elemens than max_locals or max_stack
-            if( idx >= space_available ) return error(VF_ErrorStackmap, "corrupted StackMapTable");
-
-            uint8 tag = *((*attr)++);
-            switch (tag) {
-                case ITEM_TOP:
-                    element[idx++].const_val = SmConstant(SM_BOGUS);
-                    break;
-                case ITEM_INTEGER:
-                    element[idx++].const_val = SmConstant(SM_INTEGER);
-                    break;
-                case ITEM_FLOAT:
-                    element[idx++].const_val = SmConstant(SM_FLOAT);
-                    break;
-                case ITEM_DOUBLE:
-                    element[idx++].const_val = SmConstant(SM_DOUBLE);
-                    if( idx >= space_available ) return error(VF_ErrorStackmap, "corrupted StackMapTable");
-                    (*cnt)++;
-                    element[idx++].const_val = SmConstant(SM_HIGH_WORD);
-                    break;
-                case ITEM_LONG:
-                    element[idx++].const_val = SmConstant(SM_LONG);
-                    if( idx >= space_available ) return error(VF_ErrorStackmap, "corrupted StackMapTable");
-                    (*cnt)++;
-                    element[idx++].const_val = SmConstant(SM_HIGH_WORD);
-                    break;
-                case ITEM_NULL:
-                    element[idx++].const_val = SmConstant(SM_NULL);
-                    break;
-                case ITEM_UNINITIALIZEDTHIS:
-                    element[idx++].const_val = SmConstant(SM_THISUNINIT);
-                    break;
-                case ITEM_OBJECT: {
-                    if( (*attr) + 2 > end ) return error(VF_ErrorStackmap, "corrupted StackMapTable");
-                    uint16 cp_idx = read_int16(*attr);
-                    (*attr)+=2;
-
-                    SmConstant c;
-                    if( !tpool.cpool_get_class(cp_idx, &c) ) return error(VF_ErrorStackmap, "incorrect constantpool entry");
-                    element[idx++].const_val = c;
-
-                    break;
-                        }
-                case ITEM_UNINITIALIZED: {
-                    if( (*attr) + 2 > end ) return error(VF_ErrorStackmap, "corrupted StackMapTable");
-                    uint16 address = read_int16(*attr);
-                    (*attr)+=2;
-
-                    element[idx++].const_val = SmConstant::getNewObject(address);
-                    break;
-                        }
-                default:
-                    return error(VF_ErrorStackmap, "corrupted StackMapTable");
-            }
+    if( read_ptr < attribute_end ) return error(VF_ErrorStackmap, "corrupted StackMapTable");
+    return VF_OK;
+}
+
+/**
+ * Reads cnt types from a row bytearray representing StackMapTable and record to workmap starting at 
+ * the specified element. If Long or Double happens in StackMapTable, record SM_HIGH_WORD after SM_LONG or SM_DOUBLE
+ * to the workmap and increase cnt. Check space_available when record to the workmap
+ */
+vf_Result vf_Context_6::read_types(Byte **attr, Byte *end, WorkmapElement_6* element,
+                                   unsigned *cnt, unsigned space_available) {
+    uint16 idx = 0;
+    //read (*cnt) types
+    while( idx < *cnt ) {
+
+        //attribute truncated?
+        if( (*attr) > end ) return error(VF_ErrorStackmap, "corrupted StackMapTable");
+
+        //more elemens than max_locals or max_stack
+        if( idx >= space_available ) return error(VF_ErrorStackmap, "corrupted StackMapTable");
+
+        uint8 tag = *((*attr)++);
+        switch (tag) {
+            case ITEM_TOP:
+                element[idx++].const_val = SmConstant(SM_BOGUS);
+                break;
+            case ITEM_INTEGER:
+                element[idx++].const_val = SmConstant(SM_INTEGER);
+                break;
+            case ITEM_FLOAT:
+                element[idx++].const_val = SmConstant(SM_FLOAT);
+                break;
+            case ITEM_DOUBLE:
+                element[idx++].const_val = SmConstant(SM_DOUBLE);
+                if( idx >= space_available ) return error(VF_ErrorStackmap, "corrupted StackMapTable");
+                (*cnt)++;
+                element[idx++].const_val = SmConstant(SM_HIGH_WORD);
+                break;
+            case ITEM_LONG:
+                element[idx++].const_val = SmConstant(SM_LONG);
+                if( idx >= space_available ) return error(VF_ErrorStackmap, "corrupted StackMapTable");
+                (*cnt)++;
+                element[idx++].const_val = SmConstant(SM_HIGH_WORD);
+                break;
+            case ITEM_NULL:
+                element[idx++].const_val = SmConstant(SM_NULL);
+                break;
+            case ITEM_UNINITIALIZEDTHIS:
+                element[idx++].const_val = SmConstant(SM_THISUNINIT);
+                break;
+            case ITEM_OBJECT: {
+                if( (*attr) + 2 > end ) return error(VF_ErrorStackmap, "corrupted StackMapTable");
+                uint16 cp_idx = read_int16(*attr);
+                (*attr)+=2;
+
+                SmConstant c;
+                if( !tpool.cpool_get_class(cp_idx, &c) ) return error(VF_ErrorStackmap, "incorrect constantpool entry");
+                element[idx++].const_val = c;
+
+                break;
+                    }
+            case ITEM_UNINITIALIZED: {
+                if( (*attr) + 2 > end ) return error(VF_ErrorStackmap, "corrupted StackMapTable");
+                uint16 address = read_int16(*attr);
+                (*attr)+=2;
+
+                element[idx++].const_val = SmConstant::getNewObject(address);
+                break;
+                    }
+            default:
+                return error(VF_ErrorStackmap, "corrupted StackMapTable");
         }
-        return VF_OK;
     }
- 
-} // namespace CPVerifier
+    return VF_OK;
+}

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/java6/context_6.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/java6/context_6.h?rev=649574&r1=649573&r2=649574&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/java6/context_6.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/java6/context_6.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 __CONTEXT6_H__
 #define __CONTEXT6_H__
 
@@ -26,125 +22,117 @@
 #include "../base/context_x.h"
 #include "stackmap_6.h"
 
-using namespace CPVerifier;
-
-
-namespace CPVerifier_6 {
-
-    //
-    // Context - main class of Type Checker
-    //
-
-    class vf_Context_6 : public vf_Context_x<vf_Context_6, WorkmapElement, _WorkmapElement, StackmapElement> {
-    public:
-        vf_Context_6(SharedClasswideData &classwide) :
-          vf_Context_x<vf_Context_6, WorkmapElement, _WorkmapElement, StackmapElement>(classwide) {}
-
-          vf_Result verify_method(Method_Handle method);
-    protected:
-        // stackmaps for instructions
-        InstrPropsBase props;
-
-        //init method-wide data
-        void init(Method_Handle _m_method) {
-            vf_Context_x<vf_Context_6, WorkmapElement, _WorkmapElement, StackmapElement>::init(_m_method);
-            props.init(mem, m_code_length);
-        }
-
-        // load derived types previously stored for the given instruction
-        void fill_workmap(Address instr) {
-            PropsHead *head = (PropsHead*)props.getInstrProps(instr);
-            assert(sizeof(StackmapElement) == sizeof(WorkmapElement));
-            tc_memcpy(workmap, head->getStackmap(), sizeof(WorkmapHead) + sizeof(WorkmapElement) * (m_stack_start + head->stackmap.depth));
-        }
-
-        //create a stackmap vector of the given size sz (max_locals <= sz <= max_locals+max_stack)
-        PropsHead* newStackmap(int sz) {
-            return (PropsHead*)mem.calloc(sizeof(PropsHead) + sizeof(StackmapElement) * sz);
-        }
-
-        //parse StackMapTable attribute and store Stackmap vectors for the instructions 
-        vf_Result load_stackmaptable();
-
-        //Read cnt types from a row bytearray representing StackMapTable and record to workmap starting at 
-        //the specified element. If Long or Double happens in StackMapTable, record SM_HIGH_WORD after SM_LONG or SM_DOUBLE
-        //to the workmap and increase cnt. Check space_available when record to the workmap
-        vf_Result read_types(uint8 **attr, uint8 *end, WorkmapElement* element, unsigned *cnt, unsigned space_available);
-
-
-        ///////////////////////////////////  "VIRTUAL" METHODS /////////////////////////////////////////////
-    public:
-        //create constraint vector in case of a branch 
-        //simple conatraints are created for pairs of both locals and stack (current must be assignable to target)
-        vf_Result new_generic_vector_constraint(Address target_instr) {
-            StackmapHead *target = getStackmap(target_instr);
-            return target ? new_generic_vector_constraint_impl(target) : error(VF_ErrorBranch, "no stackmap at branch target");
-        }
-
-        //when we hit RET instruction we update the data for the given subroutine with current derived types
-        vf_Result new_ret_vector_constraint(Address target_instr) {
-            assert(0);
-            return error(VF_ErrorInternal, "unexpected JSR/RET instruction");
-        }
-
-        // Java5 anachronism: push catch-block to the stack of branches to pass, empty in Java6
-        void push_handler(Address handler_pc) {
-        }
-
-        //check stackmap for exception handler start
-        vf_Result checkHandlerStackmap(Address handler_pc, SmConstant type) {
-            StackmapHead *map = getStackmap(handler_pc);
-            if( !map ) {
-                return error(VF_ErrorHandler, "no stackmap at catch");
-            }
-            if( map->depth != 1 ) {
-                return error(VF_ErrorHandler, "incorrect stack at catch");
-            }
-            return add_incoming_value(type, &map->elements[m_stack_start]);
-        }
-
-        //returns stackmap for the 'instr' instruction or 0 if it does not exist
-        StackmapHead *getStackmap(Address instr) {
-            PropsHead *pro = (PropsHead*) props.getInstrProps(instr);
-            return pro ? pro->getStackmap() : 0;
-        }
-
-        /////////////// expect some type //////////////
-
-        //expect exactly this type
-        int workmap_expect_strict( WorkmapElement &el, SmConstant type ) {
-            assert(type != SM_BOGUS);
-            return type == el.const_val;
-        }
-
-        int workmap_expect( WorkmapElement &el, SmConstant type ) {
-            return tpool.mustbe_assignable(el.const_val, type);
-        }
-
-        //create simple single constraint: "'from' is assingable to 'to'"
-        vf_Result new_scalar_constraint(WorkmapElement *from, StackmapElement *to) {
-            return add_incoming_value(from->const_val, to);
-        }
-
-        //add one more possible value (type) that can come to the given point (local or stack)
-        vf_Result add_incoming_value(SmConstant new_value, StackmapElement *destination) {
-            return tpool.mustbe_assignable(new_value, destination->const_val) ? VF_OK : 
-                error(VF_ErrorIncompatibleArgument, "incompatible argument");
-        }
-
-        //create special type of conatraint: "'from' is an array and it's element is assignable to 'to'"
-        vf_Result new_scalar_array2ref_constraint(WorkmapElement *from, WorkmapElement *to) {
-            //although new_scalar_conatraint() whould process from constants correctly 
-            // we just do not need new variable if it is really a constant
-            *to = _WorkmapElement( tpool.get_ref_from_array(from->const_val) );
-            return VF_OK;
-        }
-
-        void new_bogus_propagation_constraint(WorkmapElement &wm_el, SmConstant init_val) {
-            wm_el = _WorkmapElement (init_val);
-        }
-    };
-
-} // namespace CPVerifier
+//
+// Context - main class of Type Checker
+//
+class vf_Context_6 : public vf_Context_x<vf_Context_6, WorkmapElement_6, _WorkmapElement_6, StackmapElement_6> {
+public:
+    vf_Context_6(SharedClasswideData &classwide) :
+      vf_Context_x<vf_Context_6, WorkmapElement_6, _WorkmapElement_6, StackmapElement_6>(classwide) {}
+
+      vf_Result verify_method(Method_Handle method);
+protected:
+    // stackmaps for instructions
+    InstrPropsBase props;
+
+    //init method-wide data
+    void init(Method_Handle _m_method) {
+        vf_Context_x<vf_Context_6, WorkmapElement_6, _WorkmapElement_6, StackmapElement_6>::init(_m_method);
+        props.init(mem, m_code_length);
+    }
+
+    // load derived types previously stored for the given instruction
+    void fill_workmap(Address instr) {
+        PropsHead_6 *head = (PropsHead_6*)props.getInstrProps(instr);
+        assert(sizeof(StackmapElement_6) == sizeof(WorkmapElement_6));
+        tc_memcpy(workmap, head->getStackmap(), sizeof(WorkmapHead) + sizeof(WorkmapElement_6) * (m_stack_start + head->stackmap.depth));
+    }
+
+    //create a stackmap vector of the given size sz (max_locals <= sz <= max_locals+max_stack)
+    PropsHead_6* newStackmap(int sz) {
+        return (PropsHead_6*)mem.calloc(sizeof(PropsHead_6) + sizeof(StackmapElement_6) * sz);
+    }
+
+    //parse StackMapTable attribute and store Stackmap vectors for the instructions 
+    vf_Result load_stackmaptable();
+
+    //Read cnt types from a row bytearray representing StackMapTable and record to workmap starting at 
+    //the specified element. If Long or Double happens in StackMapTable, record SM_HIGH_WORD after SM_LONG or SM_DOUBLE
+    //to the workmap and increase cnt. Check space_available when record to the workmap
+    vf_Result read_types(Byte **attr, Byte *end, WorkmapElement_6* element, unsigned *cnt, unsigned space_available);
+
+
+    ///////////////////////////////////  "VIRTUAL" METHODS /////////////////////////////////////////////
+public:
+    //create constraint vector in case of a branch 
+    //simple conatraints are created for pairs of both locals and stack (current must be assignable to target)
+    vf_Result new_generic_vector_constraint(Address target_instr) {
+        StackmapHead *target = getStackmap(target_instr);
+        return target ? new_generic_vector_constraint_impl(target) : error(VF_ErrorBranch, "no stackmap at branch target");
+    }
+
+    //when we hit RET instruction we update the data for the given subroutine with current derived types
+    vf_Result new_ret_vector_constraint(Address target_instr) {
+        assert(0);
+        return error(VF_ErrorInternal, "unexpected JSR/RET instruction");
+    }
+
+    // Java5 anachronism: push catch-block to the stack of branches to pass, empty in Java6
+    void push_handler(Address handler_pc) {
+    }
+
+    //check stackmap for exception handler start
+    vf_Result checkHandlerStackmap(Address handler_pc, SmConstant type) {
+        StackmapHead *map = getStackmap(handler_pc);
+        if( !map ) {
+            return error(VF_ErrorHandler, "no stackmap at catch");
+        }
+        if( map->depth != 1 ) {
+            return error(VF_ErrorHandler, "incorrect stack at catch");
+        }
+        return add_incoming_value(type, &map->elements[m_stack_start]);
+    }
+
+    //returns stackmap for the 'instr' instruction or 0 if it does not exist
+    StackmapHead *getStackmap(Address instr) {
+        PropsHead_6 *pro = (PropsHead_6*) props.getInstrProps(instr);
+        return pro ? pro->getStackmap() : 0;
+    }
+
+    /////////////// expect some type //////////////
+
+    //expect exactly this type
+    int workmap_expect_strict( WorkmapElement_6 &el, SmConstant type ) {
+        assert(type != SM_BOGUS);
+        return type == el.const_val;
+    }
+
+    int workmap_expect( WorkmapElement_6 &el, SmConstant type ) {
+        return tpool.mustbe_assignable(el.const_val, type);
+    }
+
+    //create simple single constraint: "'from' is assingable to 'to'"
+    vf_Result new_scalar_constraint(WorkmapElement_6 *from, StackmapElement_6 *to) {
+        return add_incoming_value(from->const_val, to);
+    }
+
+    //add one more possible value (type) that can come to the given point (local or stack)
+    vf_Result add_incoming_value(SmConstant new_value, StackmapElement_6 *destination) {
+        return tpool.mustbe_assignable(new_value, destination->const_val) ? VF_OK : 
+            error(VF_ErrorIncompatibleArgument, "incompatible argument");
+    }
+
+    //create special type of conatraint: "'from' is an array and it's element is assignable to 'to'"
+    vf_Result new_scalar_array2ref_constraint(WorkmapElement_6 *from, WorkmapElement_6 *to) {
+        //although new_scalar_conatraint() whould process from constants correctly 
+        // we just do not need new variable if it is really a constant
+        *to = _WorkmapElement_6( tpool.get_ref_from_array(from->const_val) );
+        return VF_OK;
+    }
+
+    void new_bogus_propagation_constraint(WorkmapElement_6 &wm_el, SmConstant init_val) {
+        wm_el = _WorkmapElement_6 (init_val);
+    }
+};
 
 #endif

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/java6/stackmap_6.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/java6/stackmap_6.h?rev=649574&r1=649573&r2=649574&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/java6/stackmap_6.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/java6/stackmap_6.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 __STACKMAP6_H__
 #define __STACKMAP6_H__
 
@@ -26,68 +22,64 @@
 #include <assert.h>
 #include "../base/stackmap_x.h"
 
-using namespace CPVerifier;
-
-namespace CPVerifier_6 {
-
-    //Constant for parsing StackMapTable attribute 
-    enum StackMapTableItems {
-        ITEM_TOP = 0,
-        ITEM_INTEGER = 1,
-        ITEM_FLOAT = 2,
-        ITEM_DOUBLE = 3,
-        ITEM_LONG = 4,
-        ITEM_NULL = 5,
-        ITEM_UNINITIALIZEDTHIS = 6,
-        ITEM_OBJECT = 7,
-        ITEM_UNINITIALIZED = 8
-    };
-
-
-    //StackMapElement structure represens recorded verification types
-    //it's read from class file StackMapTable attribute
-    struct StackmapElement {
-        //list of IncomingType constraint
-        _SmConstant const_val;
-    };
-
-    //WorkMapElement structure represent an element of the workmap vector -- vector of the derived types
-    //in Java6 verification type might be constant (or known) only 
-    struct WorkmapElement {
-        //the value
-        _SmConstant const_val;      //either a constant (known-type)
-
-        //// Java5 anachonisms ////
-        void setJsrModified() {};
-        int isJsrModified() { return 1;};
-        SmConstant getAnyPossibleValue() { return const_val; }
-        SmConstant getConst() { return const_val; }
-    };
-
-    //WorkmapElement type with some constructors
-    struct _WorkmapElement : WorkmapElement {
-        _WorkmapElement(WorkmapElement other) {
-            const_val = other.const_val;
-        }
-
-        _WorkmapElement(SmConstant c) {
-            const_val = c;
-        }
-    };
-
-    //Store stackmap data for the given instruction
-    // the list is used to organize storing Props as a HashTable
-    struct PropsHead : public PropsHeadBase {
-        typedef MapHead<StackmapElement> StackmapHead;
-
-        //possible properties
-        StackmapHead stackmap;
-
-        //get stackmap stored here
-        StackmapHead *getStackmap() {
-            return &stackmap;
-        }
-    };
-} // namespace CPVerifier_6
+//Constant for parsing StackMapTable attribute 
+enum StackMapTableItems {
+    ITEM_TOP = 0,
+    ITEM_INTEGER = 1,
+    ITEM_FLOAT = 2,
+    ITEM_DOUBLE = 3,
+    ITEM_LONG = 4,
+    ITEM_NULL = 5,
+    ITEM_UNINITIALIZEDTHIS = 6,
+    ITEM_OBJECT = 7,
+    ITEM_UNINITIALIZED = 8
+};
+
+
+//StackMapElement structure represens recorded verification types
+//it's read from class file StackMapTable attribute
+struct StackmapElement_6 {
+    //list of IncomingType constraint
+    _SmConstant const_val;
+};
+
+//WorkMapElement structure represent an element of the workmap vector -- vector of the derived types
+//in Java6 verification type might be constant (or known) only 
+struct WorkmapElement_6 {
+    //the value
+    _SmConstant const_val;      //either a constant (known-type)
+
+    //// Java5 anachonisms ////
+    void setJsrModified() {};
+    int isJsrModified() { return 1;};
+    SmConstant getAnyPossibleValue() { return const_val; }
+    SmConstant getConst() { return const_val; }
+};
+
+//WorkmapElement type with some constructors
+struct _WorkmapElement_6 : WorkmapElement_6 {
+    _WorkmapElement_6(WorkmapElement_6 other) {
+        const_val = other.const_val;
+    }
+
+    _WorkmapElement_6(SmConstant c) {
+        const_val = c;
+    }
+};
+
+
+//Store stackmap data for the given instruction
+// the list is used to organize storing Props as a HashTable
+struct PropsHead_6 : public PropsHeadBase {
+    typedef MapHead<StackmapElement_6> StackmapHead;
+
+    //possible properties
+    StackmapHead stackmap;
+
+    //get stackmap stored here
+    StackmapHead *getStackmap() {
+        return &stackmap;
+    }
+};
 
 #endif

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/x_verifier/recompute.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/x_verifier/recompute.cpp?rev=649574&r1=649573&r2=649574&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/x_verifier/recompute.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/x_verifier/recompute.cpp Fri Apr 18 08:29:36 2008
@@ -14,30 +14,16 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-/** 
- * @author Mikhail Loenko
- */  
-
-
-
-#include <iostream>
-
-using namespace std;
-
+#include <stdio.h>
 #include "recompute.h"
 #include "../java5/stackmap_5.h"
 #include "time.h"
 
-using namespace CPVerifier;
-using namespace CPVerifier_5;
-
-
 static char err_message[5000];
 
 /**
-* Function recomputes StackMapTable attribute.
-*
-*/
+ * Recomputes StackMapTable attribute.
+ */
 vf_Result
 vf_recompute_stackmaptable(Method_Handle method, uint8** attrBytes, char** error,
                            void* trustedPairs )
@@ -96,7 +82,7 @@
 
     curFrame = newWorkmap(m_stack_start + m_max_stack);
     for( Address instr = 0; instr < m_code_length; instr++) {
-        PropsHead *head = (PropsHead*)props.getInstrProps(instr);
+        PropsHead_5 *head = (PropsHead_5*)props.getInstrProps(instr);
         if (head) {
             if( (tcr=fillCurFrame(head)) != VF_OK ) {
                 return tcr;
@@ -107,32 +93,33 @@
 
             /////////////////////////////////
             workmap->depth = curFrame->depth;
-            tc_memcpy(&workmap->elements[0], &curFrame->elements[0], sizeof(WorkmapElement) * (m_stack_start + workmap->depth));
+            tc_memcpy(&workmap->elements[0], &curFrame->elements[0],
+                sizeof(WorkmapElement_5) * (m_stack_start + workmap->depth));
         }
     }
 
     if( written_stackmap ) {
-        written_stackmap[7] = entryNo & 0xFF;
+        written_stackmap[7] = (uint8) entryNo & 0xFF;
         entryNo >>= 8;
 
-        written_stackmap[6] = entryNo & 0xFF;
+        written_stackmap[6] = (uint8) entryNo & 0xFF;
         ////////////
-        written_stackmap[5] = attrLen & 0xFF;
+        written_stackmap[5] = (uint8) attrLen & 0xFF;
         attrLen >>= 8;
 
-        written_stackmap[4] = attrLen & 0xFF;
+        written_stackmap[4] = (uint8) attrLen & 0xFF;
         attrLen >>= 8;
 
-        written_stackmap[3] = attrLen & 0xFF;
+        written_stackmap[3] = (uint8) attrLen & 0xFF;
         attrLen >>= 8;
 
-        written_stackmap[2] = attrLen & 0xFF;
+        written_stackmap[2] = (uint8) attrLen & 0xFF;
     }
 
     return VF_OK;
 } // recompute_stackmaptable
 
-vf_Result vf_Context_5e::fillCurFrame(PropsHead *head) {
+vf_Result vf_Context_5e::fillCurFrame(PropsHead_5 *head) {
     curFrame->depth = head->is_workmap() ? head->getWorkmap()->depth : head->getStackmap()->depth;
     
     int high_word_expected = false;
@@ -156,6 +143,10 @@
     parseTrustedPairs();
 
     vf_Result tcr;
+
+    // iterator
+    int i;
+
     //we skip workmap vectors when do iteration
     //workmap vectors may contain constant, refs to stackmap elements that are parts of other vectrs
     //(and thus iterated thru), or temporary stackmap elements created by 
@@ -196,11 +187,11 @@
             //dead code start: place workmap here
             assert(!props.getInstrProps(dead_code_start));
 
-            PropsHead* dead = newWorkmapProps(m_stack_start + 1);
+            PropsHead_5* dead = newWorkmapProps(m_stack_start + 1);
             props.setInstrProps(dead_code_start, dead);
             WorkmapHead *wm = dead->getWorkmap();
 
-            PropsHead* alive = (PropsHead*)props.getInstrProps(instr);
+            PropsHead_5* alive = (PropsHead_5*)props.getInstrProps(instr);
             assert( alive );
 
             for( unsigned i = 0; i < m_stack_start; i++ ) {
@@ -218,7 +209,7 @@
 
 
 //insert reversed generic constraints
-void vf_Context_5e::insert_back_refs(StackmapElement *el) {
+void vf_Context_5e::insert_back_refs(StackmapElement_5 *el) {
     //stackmap is know already for this element ==> it won't participae in backtracking
     if (is_node_calculated(el)) return;
 
@@ -246,7 +237,7 @@
 //when we have more classes loaded, list of candidates might be wider, but the "right" type would be the same
 //this difference is intended and maintained for future use, e.g. if we gt instrumentation and can't
 //build attribute for the class, we may consider further algorithm improving
-vf_Result vf_Context_5e::mantain_node_consistency(StackmapElement *el) {
+vf_Result vf_Context_5e::mantain_node_consistency(StackmapElement_5 *el) {
 
     vf_Result tcr;
 
@@ -412,7 +403,7 @@
 //check that each stackmap candidates in the nodes accessible from the current one
 //has an arc-consitent value in the current mode 
 //the method is called each time set of candidates for the given node is changed
-vf_Result vf_Context_5e::arc_consistensy_in_node(StackmapElement *el, int depth) {
+vf_Result vf_Context_5e::arc_consistensy_in_node(StackmapElement_5 *el, int depth) {
 
     for( Constraint *adjacent = el->firstOthers(); adjacent; adjacent = adjacent->next() ) {
         if( !is_arc(adjacent) ) continue;
@@ -466,7 +457,7 @@
     return VF_OK;
 }
 
-void vf_Context_5e::push_subgraph(StackmapElement *el) {
+void vf_Context_5e::push_subgraph(StackmapElement_5 *el) {
     if( subgraph_stack.instack( el ) ) return;
 
     subgraph_stack.push( el );
@@ -477,7 +468,7 @@
 }
 
 
-vf_Result vf_Context_5e::calculate_subgraph(StackmapElement *el) {
+vf_Result vf_Context_5e::calculate_subgraph(StackmapElement_5 *el) {
     if( is_node_calculated(el) || no_stackmap_choice((StackmapElement_Ex*)el) ) return VF_OK;
 
     subgraph_stack.init();
@@ -506,13 +497,14 @@
     }
 
     //first 'remove' all remaining stackmaps
-    for( StackmapAttrCnstr *sm = cur->firstStackmapAttrCnstr(); sm; sm = sm->next() ) {
+    StackmapAttrCnstr *sm;
+    for( sm = cur->firstStackmapAttrCnstr(); sm; sm = sm->next() ) {
         assert(sm->depth < depth);
         if( !sm->depth ) sm->depth = depth;
     }
 
     //then try to include them one-by-one 
-    for( StackmapAttrCnstr *sm = cur->firstStackmapAttrCnstr(); sm; sm = sm->next() ) {
+    for( sm = cur->firstStackmapAttrCnstr(); sm; sm = sm->next() ) {
         if( sm->depth != depth ) continue;
 
         sm->depth = 0;
@@ -630,13 +622,14 @@
     trustedPairsCnt = 0;
     if( !class_constraints ) return;
 
-    for( vf_TypeConstraint *constraint = (vf_TypeConstraint*)unparsedPairs; constraint; constraint = constraint->next ) {
+    vf_TypeConstraint *constraint;
+    for( constraint = (vf_TypeConstraint*)unparsedPairs; constraint; constraint = constraint->next ) {
         trustedPairsCnt++;
     }
     trustedPairs = (TrustedPair*)mem.malloc(trustedPairsCnt * sizeof(TrustedPair));
 
     int i = 0;
-    for( vf_TypeConstraint *constraint = (vf_TypeConstraint*)unparsedPairs; constraint; constraint = constraint->next ) {
+    for( constraint = (vf_TypeConstraint*)unparsedPairs; constraint; constraint = constraint->next ) {
         trustedPairs[i].from = tpool.get_ref_type(constraint->source);
         tryResolve(trustedPairs[i].from);
 



Mime
View raw message