* src/vm/resolve.c (resolve_method_verifier_checks): Factored out
authoredwin <none@none>
Mon, 9 Oct 2006 22:19:22 +0000 (22:19 +0000)
committeredwin <none@none>
Mon, 9 Oct 2006 22:19:22 +0000 (22:19 +0000)
loading constraints into a separate function.

(resolve_method_loading_constraints): New function.

(resolve_method): Call resolve_method_loading_constraints.

* src/vm/resolve.h (resolve_method_loading_constraints): New function.

* src/vm/jit/verify/typecheck.c (verify_invocation): Call
resolve_method_loading_constraints.

src/vm/jit/verify/typecheck.c
src/vm/resolve.c
src/vm/resolve.h

index 773bbde16a1cf13d359afefa2d190d7e1364374c..399f4970ff76f6619c3a3b463c23970ca6d12425 100644 (file)
@@ -28,7 +28,7 @@
 
    Changes: Christian Thalinger
 
-   $Id: typecheck.c 5724 2006-10-09 17:08:38Z edwin $
+   $Id: typecheck.c 5725 2006-10-09 22:19:22Z edwin $
 
 */
 
@@ -971,7 +971,10 @@ verify_invocation(verifier_state *state)
        /* if resolved, perform verification checks */
 
        if (result == resolveSucceeded) {
-               methodinfo *mi = mref->p.method;
+
+               assert(IS_FMIREF_RESOLVED(mref));
+
+               mi = mref->p.method;
 
                result = resolve_method_verifier_checks(jd,
                                                                                                state->m, 
@@ -983,16 +986,20 @@ verify_invocation(verifier_state *state)
                                                                                                state->iptr);
        }
 
+       /* if resolved, impose loading constraints */
+
+       if (result == resolveSucceeded) {
+               /* XXX state->m->class may have to be wrong when inlining */
+               if (!resolve_method_loading_constraints(state->m->class, mi))
+                       return false;
+       }
+
        if (result == resolveFailed)
                return false;
 
        if (result == resolveSucceeded) {
-               methodinfo *mi = mref->p.method;
-
                /* if this call is monomorphic, turn it into an INVOKESPECIAL */
 
-               assert(IS_FMIREF_RESOLVED(state->iptr->sx.s23.s3.fmiref));
-
                if ((state->iptr->opc == ICMD_INVOKEVIRTUAL)
                        && (mi->flags & (ACC_FINAL | ACC_PRIVATE)))
                {
index 3e156c241f993fff312a3a31b0509fbc36078779..18d445703939d834480c2c06390d61be7e6228f7 100644 (file)
@@ -28,7 +28,7 @@
 
    Changes: Christan Thalinger
 
-   $Id: resolve.c 5724 2006-10-09 17:08:38Z edwin $
+   $Id: resolve.c 5725 2006-10-09 22:19:22Z edwin $
 
 */
 
@@ -1628,20 +1628,52 @@ resolve_result_t resolve_method_verifier_checks(jitdata *jd,
 
        } /* if (iptr) */
 
+       /* everything ok */
+
+       return resolveSucceeded;
+}
+#endif /* defined(ENABLE_VERIFIER) */
+
+
+/* resolve_method_loading_constraints ******************************************
+
+   Impose loading constraints on the parameters and return type of the
+   given method.
+
+   IN:
+       referer..........the class refering to the method
+          mi...............the method
+
+   RETURN VALUE:
+       true................everything ok
+          false...............an exception has been thrown
+
+*******************************************************************************/
+
+#if defined(ENABLE_VERIFIER)
+bool resolve_method_loading_constraints(classinfo *referer,
+                                                                               methodinfo *mi)
+{
+       methoddesc *md;
+       typedesc   *paramtypes;
+       utf        *name;
+       s4          i;
+       s4          instancecount;
+
        /* impose loading constraints on parameters (including instance) */
 
+       md = mi->parseddesc;
        paramtypes = md->paramtypes;
+       instancecount = (mi->flags & ACC_STATIC) / ACC_STATIC;
 
        for (i = 0; i < md->paramcount; i++) {
                if (i < instancecount || paramtypes[i].type == TYPE_ADR) {
-                       utf *name;
-
                        if (i < instancecount) {
                                /* The type of the 'this' pointer is the class containing */
                                /* the method definition. Since container is the same as, */
                                /* or a subclass of declarer, we also constrain declarer  */
                                /* by transitivity of loading constraints.                */
-                               name = container->name;
+                               name = mi->class->name;
                        }
                        else {
                                name = paramtypes[i].classref->name;
@@ -1650,8 +1682,8 @@ resolve_result_t resolve_method_verifier_checks(jitdata *jd,
                        /* The caller (referer) and the callee (container) must agree */
                        /* on the types of the parameters.                            */
                        if (!classcache_add_constraint(referer->classloader,
-                                                                                  container->classloader, name))
-                               return resolveFailed; /* exception */
+                                                                                  mi->class->classloader, name))
+                               return false; /* exception */
                }
        }
 
@@ -1660,16 +1692,19 @@ resolve_result_t resolve_method_verifier_checks(jitdata *jd,
        if (md->returntype.type == TYPE_ADR) {
                /* The caller (referer) and the callee (container) must agree */
                /* on the return type.                                        */
-               if (!classcache_add_constraint(referer->classloader,container->classloader,
-                               md->returntype.classref->name))
-                       return resolveFailed; /* exception */
+               if (!classcache_add_constraint(referer->classloader,
+                                       mi->class->classloader,
+                                       md->returntype.classref->name))
+                       return false; /* exception */
        }
 
        /* everything ok */
-       return resolveSucceeded;
+
+       return true;
 }
 #endif /* defined(ENABLE_VERIFIER) */
 
+
 /* resolve_method_lazy *********************************************************
  
    Resolve an unresolved method reference lazily
@@ -1911,6 +1946,11 @@ resolved_the_method:
                if (checkresult != resolveSucceeded)
                        return (bool) checkresult;
 
+               /* impose loading constraints on params and return type */
+
+               if (!resolve_method_loading_constraints(referer, mi))
+                       return false;
+
                declarer = mi->class;
                assert(declarer);
                assert(referer->state & CLASS_LINKED);
index 4105d63dad785aae7e01dedd5cc4590e22b47a40..fdbee35b1565e888e383a536efde47b8ed971714 100644 (file)
@@ -28,7 +28,7 @@
 
    Changes:
 
-   $Id: resolve.h 5724 2006-10-09 17:08:38Z edwin $
+   $Id: resolve.h 5725 2006-10-09 22:19:22Z edwin $
 
 */
 
@@ -214,6 +214,10 @@ resolve_result_t resolve_method_verifier_checks(jitdata *jd,
                                                                                                bool invokestatic,
                                                                                                bool invokespecial,
                                                                                                instruction *iptr);
+
+bool resolve_method_loading_constraints(classinfo *referer,
+                                                                               methodinfo *mi);
+
 bool constrain_unresolved_method(jitdata *jd,
                                                                         unresolved_method *ref, classinfo *referer,
                                                                         methodinfo *refmethod, instruction *iptr);