harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mloe...@apache.org
Subject svn commit: r637717 - in /harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/x_verifier: recompute.cpp recompute.h
Date Mon, 17 Mar 2008 04:52:41 GMT
Author: mloenko
Date: Sun Mar 16 21:52:32 2008
New Revision: 637717

URL: http://svn.apache.org/viewvc?rev=637717&view=rev
Log:
make loading of classes unnecessary for stackmap recomputing (it's not necessary to load super-superclass
as well as support class_is_extending_class any more)

Modified:
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/x_verifier/recompute.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/x_verifier/recompute.h

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=637717&r1=637716&r2=637717&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 Sun
Mar 16 21:52:32 2008
@@ -279,7 +279,6 @@
 
     //MORE THAN ONE incoming element exists
 
-    SmConstant any_resolved = SM_NONE;
     int array_of_primitive_exists = false;
     int assignable_from_object_exists = false;
 
@@ -288,7 +287,6 @@
 
     //first we remove NULLs from incoming values, check whether non-references exist among
incomings
     //see arrays and compare their dimensions, see if there is Object or arrays of Object
among incoming
-    //and see if any resolved type exist among incomings
     for( IncomingType *inc = el->firstIncoming(); inc; inc = inc->next() ) {
         //we don't use isNonMergeable() here since there are different merging rules for
Java5 and Java6
         if( inc->value == SM_NULL ) {
@@ -312,11 +310,6 @@
                 array_of_primitive_exists = true;
             } else {
                 assignable_from_object_exists |= isObjectOrInterface(z);
-
-                //remember any resolved type if it exists
-                if( any_resolved == SM_NONE && (tpool.sm_get_handler(z) != CLASS_NOT_LOADED)
) {
-                    any_resolved = z;
-                }
             }
         }
     }
@@ -356,97 +349,43 @@
     }
 
 
-    //if there is a resolved type then solution for this element is 
-    //a super class of the resolved class or the resolved class itself
-    if( any_resolved != SM_NONE ) {
-        
-        IncomingType *inc = el->firstIncoming();
-        tryResolve(inc->value);
-
-        SmConstant general_type = any_resolved;
-        for (; general_type != tpool.sm_get_const_object(); general_type = sm_get_super(general_type)
) {
-            //we don't reinitialize 'inc' since all previous are assignable to a sub class

-            //of 'general_type' and thus to 'general_type' as well
-            for( ; inc; inc = inc->next() ) {
-                if( !knownly_assignable( get_zerodim(inc->value), general_type) ) {
-                    break;
-                }
-            }
+    //now we need to create a set of possible stackmap solutions
+    //S={s_i} so that each s_i is a super class of each incoming and a sub class of each
expected value
+    SmConstant sm_value = el->firstIncoming()->value;
+    SmConstant z = get_zerodim(sm_value);
 
-            if( !inc ) { //all are assignable
-                break;
-            }
+    parseTrustedData(z);
+    int possible_stackmap_cnt = 0;
+    for( SmConstant *sm = parsedTrustedData[z.getReferenceIdx()].superclasses(); *sm != SM_NONE;
sm++ ) {
+        sm_value = get_ref_array(min_arr_dims, *sm);
+        if( check_possible_stackmap(el, sm_value) ) {
+            ((StackmapElement_Ex*)el)->newStackmapAttrCnstr(&mem, sm_value);
+            possible_stackmap_cnt++;
         }
-        SmConstant found_solution = get_ref_array(min_arr_dims, general_type);
+    }
 
-        //we COULD use TRUSTED_DATA to compute solution of this mode
-        //here we validate solution to report the error sooner
-        for( ExpectedType *exp = el->firstExpected(); exp; exp = exp->next() ) {
-            if( !knownly_assignable(found_solution, exp->value) ) {
-                return error(VF_ErrorInternal, "not enough data to build stackmaptable attr:
need to load more classes");
-            }
-        }
+    if( !possible_stackmap_cnt ) {
+        return error(VF_ErrorInternal, "not enough data to build stackmaptable attr: need
to load more classes");
+    }
 
-        //now each incoming type s assignable to general_type
-        ((StackmapElement_Ex*)el)->newStackmapAttrCnstr(&mem, found_solution);
-    } else {
-        //now we need to create a set of possible stackmap solutions
-        //S={s_i} so that each s_i is a super class of each incoming and a sub class of each
expected value
-        SmConstant sm_value = el->firstIncoming()->value;
-        SmConstant z = get_zerodim(sm_value);
-
-        parseTrustedData(z);
-
-        if( tpool.sm_get_handler(z) != CLASS_NOT_LOADED ) {
-            assert(tpool.sm_get_handler(z));
-
-            while( z != SM_NONE ) {
-                sm_value = get_ref_array(min_arr_dims, z);
-                if( check_possible_stackmap(el, sm_value) ) {
-                    ((StackmapElement_Ex*)el)->newStackmapAttrCnstr(&mem, sm_value);
-                    //we don't put those classes that have subclasses in this set ==>
break
+    //now we reduce the set by eliminating those classes that have subclasses in this set
+    if( possible_stackmap_cnt > 1 ) {
+        for( StackmapAttrCnstr* sm1 = ((StackmapElement_Ex*)el)->firstStackmapAttrCnstr();
sm1; sm1 = sm1->next() ) {
+            for( StackmapAttrCnstr* sm2 = sm1->next(); sm2; sm2 = sm2->next() ) {
+
+                if( knownly_assignable(sm1->value, sm2->value) ) {
+                    //remove this stackmap element, since its subclass exists in the set
+                    ((StackmapElement_Ex*)el)->removeOther(sm2);
                     break;
                 }
-                z = sm_get_super(z);
-            }
 
-            if( z == SM_NONE ) {
-                return error(VF_ErrorInternal, "not enough data to build stackmaptable attr:
need to load more classes");
-            }
-        } else {
-            int possible_stackmap_cnt = 0;
-            for( SmConstant *sm = parsedTrustedData[z.getReferenceIdx()].subclasses(); *sm
!= SM_NONE; sm++ ) {
-                sm_value = get_ref_array(min_arr_dims, *sm);
-                if( check_possible_stackmap(el, sm_value) ) {
-                    ((StackmapElement_Ex*)el)->newStackmapAttrCnstr(&mem, sm_value);
-                    possible_stackmap_cnt++;
-                }
-            }
-
-            if( !possible_stackmap_cnt ) {
-                return error(VF_ErrorInternal, "not enough data to build stackmaptable attr:
need to load more classes");
-            }
-
-            //now we reduce the set by eliminating those classes that have subclasses in
this set
-            if( possible_stackmap_cnt > 1 ) {
-                for( StackmapAttrCnstr* sm1 = ((StackmapElement_Ex*)el)->firstStackmapAttrCnstr();
sm1; sm1 = sm1->next() ) {
-                    for( StackmapAttrCnstr* sm2 = sm1->next(); sm2; sm2 = sm2->next()
) {
-
-                        if( knownly_assignable(sm1->value, sm2->value) ) {
-                            //remove this stackmap element, since its subclass exists in
the set
-                            ((StackmapElement_Ex*)el)->removeOther(sm2);
-                            break;
-                        }
-
-                        if( knownly_assignable(sm2->value, sm1->value) ) {
-                            //replace sm1 with sm2 and remove original sm2 
-                            //i.e. remove sm1 actually, since its subclass exists in the
set
-                            sm1->value = sm2->value; 
-                            assert(sm1->depth == sm2->depth);
-                            ((StackmapElement_Ex*)el)->removeOther(sm2);
-                            break;
-                        }
-                    }
+                if( knownly_assignable(sm2->value, sm1->value) ) {
+                    //replace sm1 with sm2 and remove original sm2 
+                    //i.e. remove sm1 actually, since its subclass exists in the set
+                    sm1->value = sm2->value; 
+                    assert(sm1->depth == sm2->depth);
+                    ((StackmapElement_Ex*)el)->removeOther(sm2);
+                    break;
                 }
             }
         }
@@ -494,7 +433,7 @@
                         knownly_assignable(sm2->value, sm_this->value, adjacent->type
== CTX_REVERSED_ARRAY2REF);
 
                     if( valid_arc_found ) {
-                        //stackmap has a subclass in a branch target ==> this arc is OK,
check next one
+                        //stackmap has a superclass in a branch target ==> this arc is
OK, check next one
                         possible_stackmap_cnt++;
                         break;
                     }
@@ -613,6 +552,8 @@
     }
     parsedTrustedData[idx].set_being_calculated();
 
+    SmConstant sup = SM_NONE;
+
     vf_ValidType *t = tpool.getVaildType(idx);
     if( !t->cls ) {
         t->cls = vf_resolve_class(k_class, t->name, false);
@@ -622,14 +563,29 @@
     if( t->cls != CLASS_NOT_LOADED ) {
         if( class_is_interface_(t->cls) ) {
             parsedTrustedData[idx].set_interface();
-        } else {
-            SmConstant* subcls = (SmConstant*)mem.malloc(2*sizeof(SmConstant));
-            subcls[0] = value;
-            subcls[1] = SM_NONE;
-            
-            parsedTrustedData[idx].set_subclasses(subcls);
+            return;
+        }
+        class_handler h_sup = class_get_super_class(t->cls);
+        if( h_sup ) {
+            sup = tpool.get_ref_type( class_get_name(h_sup));
+            int sup_idx = sup.getReferenceIdx();
+            vf_ValidType *sup_type = tpool.getVaildType(sup_idx);
+
+            if( sup_type->cls == CLASS_NOT_LOADED ) {
+                //classloader delegation model is broken
+                if( sup_idx < parsedDataSz && parsedTrustedData[sup_idx].is_calculated()
) {
+                    parsedTrustedData[sup_idx].init();
+                }
+            }
+                
+            sup_type->cls = h_sup;
+            parseTrustedData( sup );
+        }            
+    } else {
+        if( value != tpool.sm_get_const_object() ) {
+            sup = tpool.sm_get_const_object();
+            parseTrustedData( sup );
         }
-        return;
     }
 
     int c;
@@ -640,11 +596,17 @@
     }
 
     class_stack.init();
-    class_stack.push(tpool.sm_get_const_object());
     class_stack.push(value);
+
+    if( sup != SM_NONE ) { //i.e. value != java/lang/Object
+        for( SmConstant *sm = parsedTrustedData[sup.getReferenceIdx()].superclasses(); *sm
!= SM_NONE; sm++ ) {
+            if( !class_stack.instack(*sm) ) class_stack.push(*sm);
+        }
+    }
+
     for( c = 0; c < trustedPairsCnt; c++ ) {
         if( trustedPairs[c].from == value ) {
-            for( SmConstant *sm = parsedTrustedData[trustedPairs[c].to.getReferenceIdx()].subclasses();
*sm != SM_NONE; sm++ ) {
+            for( SmConstant *sm = parsedTrustedData[trustedPairs[c].to.getReferenceIdx()].superclasses();
*sm != SM_NONE; sm++ ) {
                 if( !class_stack.instack(*sm) ) class_stack.push(*sm);
             }
         }
@@ -653,12 +615,12 @@
     if( parsedTrustedData[idx].is_interface() ) {
         while ( !class_stack.is_empty() ) parsedTrustedData[class_stack.pop().getReferenceIdx()].set_interface();
     } else {
-        SmConstant* subcls = (SmConstant*)mem.malloc((class_stack.get_depth()+1)*sizeof(SmConstant));
+        SmConstant* supercls = (SmConstant*)mem.malloc((class_stack.get_depth()+1)*sizeof(SmConstant));
 
-        parsedTrustedData[idx].set_subclasses(subcls);
+        parsedTrustedData[idx].set_superclasses(supercls);
         int i = 0;
-        while ( !class_stack.is_empty() ) subcls[i++] = class_stack.pop();
-        subcls[i] = SM_NONE;
+        while ( !class_stack.is_empty() ) supercls[i++] = class_stack.pop();
+        supercls[i] = SM_NONE;
     }
 }
 
@@ -680,36 +642,6 @@
         tryResolve(trustedPairs[i].to);
 
         i++;
-    }
-
-    //find all classes that are subclasses of the loaded classes but due to broken 
-    //delegation model in classloaders are not loaded (this is necessary because
-    //we don't check against trusted pairs when we check assignability and 'from' is loaded
-    int changed;
-    do {
-        changed = false;
-        for( i = 0; i < trustedPairsCnt; i++ ) {
-            class_handler from_cls = tpool.sm_get_handler(trustedPairs[i].from);
-
-            if( from_cls != CLASS_NOT_LOADED && 
-                tpool.sm_get_handler(trustedPairs[i].to) == CLASS_NOT_LOADED ) 
-            {
-                class_handler to_cls = class_is_extending_class(from_cls, tpool.sm_get_refname(trustedPairs[i].to));
-
-                if( to_cls ) {
-                    tpool.getVaildType(trustedPairs[i].to.getReferenceIdx())->cls = to_cls;
-                    changed = true;
-                }
-            }
-        }
-    } while (changed);
-
-    for( i = 0; i < trustedPairsCnt; i++ ) {
-        if( tpool.sm_get_handler(trustedPairs[i].from) != CLASS_NOT_LOADED && 
-            tpool.sm_get_handler(trustedPairs[i].to) == CLASS_NOT_LOADED ) 
-        {
-            parseTrustedData(trustedPairs[i].to, true);
-        }
     }
 
     tryResolve(tpool.sm_get_const_object());

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/x_verifier/recompute.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/x_verifier/recompute.h?rev=637717&r1=637716&r2=637717&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/x_verifier/recompute.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/verifier-3363/x_verifier/recompute.h Sun Mar
16 21:52:32 2008
@@ -137,7 +137,7 @@
 
     struct RefInfo {
         union {
-            SmConstant *subcls;
+            SmConstant *supercls;
             unsigned    mask;
         };
 
@@ -158,22 +158,22 @@
         }
 
         int is_interface() {
-            return !subcls;
+            return !supercls;
         }
 
         void set_interface() {
-            subcls = 0;
+            supercls = 0;
             *((SmConstant*)&mask) = SM_NONE;
         }
 
-        SmConstant *subclasses() {
+        SmConstant *superclasses() {
             //always return valis pointer
-            return subcls ? subcls : (SmConstant*)&mask;
+            return supercls ? supercls : (SmConstant*)&mask;
         }
 
-        void set_subclasses(SmConstant *s) {
+        void set_superclasses(SmConstant *s) {
             mask = 0; //just in case
-            subcls = s;
+            supercls = s;
         }
     };
 
@@ -358,23 +358,17 @@
 
             parseTrustedData(from); // it may change class_handler for 'to'
 
-            class_handler f = tpool.sm_get_handler(from);
-            assert(f);
             class_handler t = tpool.sm_get_handler(to);
             assert(t);
 
-            if( f != CLASS_NOT_LOADED ) {
-                return t != CLASS_NOT_LOADED && vf_is_extending(f, t);
-            }
-
-            for( SmConstant *sm = parsedTrustedData[from.getReferenceIdx()].subclasses();
*sm != SM_NONE; sm++ ) {
+            for( SmConstant *sm = parsedTrustedData[from.getReferenceIdx()].superclasses();
*sm != SM_NONE; sm++ ) {
                 if( *sm == to ) {
                     return true;
                 }
 
                 if( t != CLASS_NOT_LOADED ) {
-                    class_handler f1 = tpool.sm_get_handler(*sm);
-                    if( f1 != CLASS_NOT_LOADED && vf_is_extending(f1, t) ) return
true;
+                    class_handler f = tpool.sm_get_handler(*sm);
+                    if( f != CLASS_NOT_LOADED && vf_is_extending(f, t) ) return true;
                 }                
             }
             return false;
@@ -396,20 +390,6 @@
                 }
             }
             return true;
-        }
-
-        SmConstant sm_get_super(SmConstant value) {
-            class_handler h = tpool.sm_get_handler(value);
-            assert(h && h!= CLASS_NOT_LOADED);
-            h = class_get_super_class(h);
-            if( h ) {
-                SmConstant sup = tpool.get_ref_type( class_get_name(h));
-                vf_ValidType *s = tpool.getVaildType(sup.getReferenceIdx());
-                s->cls = h;
-
-                return sup;
-            }
-            return SM_NONE;
         }
 
         int is_arc(Constraint *c) {



Mime
View raw message