Changes: Christan Thalinger
- $Id: resolve.c 5728 2006-10-09 23:21:37Z edwin $
+ $Id: resolve.c 5729 2006-10-09 23:53:42Z edwin $
*/
#endif /* defined(ENABLE_VERIFIER) */
-/* resolve_method_type_checks **************************************************
+/* resolve_method_instance_type_checks *****************************************
- Check parameter types of a method invocation.
+ Check the instance type of a method invocation.
IN:
- jd...............jitdata of the method doing the call
refmethod........the method containing the reference
- iptr.............the invoke instruction
mi...............the methodinfo of the resolved method
- invokestatic.....true if the method is invoked by INVOKESTATIC
+ instanceti.......typeinfo of the instance slot
invokespecial....true if the method is invoked by INVOKESPECIAL
RETURN VALUE:
*******************************************************************************/
#if defined(ENABLE_VERIFIER)
-resolve_result_t resolve_method_type_checks(jitdata *jd,
- methodinfo *refmethod,
- instruction *iptr,
- methodinfo *mi,
- bool invokestatic,
- bool invokespecial)
+resolve_result_t resolve_method_instance_type_checks(methodinfo *refmethod,
+ methodinfo *mi,
+ typeinfo *instanceti,
+ bool invokespecial)
{
- varinfo *instanceslot;
- varinfo *param;
typeinfo tinfo;
+ typeinfo *tip;
resolve_result_t result;
- methoddesc *md;
- typedesc *paramtypes;
- s4 type;
- s4 instancecount;
- s4 i;
- /* for non-static methods we have to check the constraints on the */
- /* instance type */
-
- assert(jd);
-
- if (invokestatic) {
- instancecount = 0;
- instanceslot = NULL;
+ if (invokespecial && TYPEINFO_IS_NEWOBJECT(*instanceti))
+ { /* XXX clean up */
+ instruction *ins = (instruction *) TYPEINFO_NEWOBJECT_INSTRUCTION(*instanceti);
+ classref_or_classinfo initclass = (ins) ? ins[-1].sx.val.c
+ : CLASSREF_OR_CLASSINFO(refmethod->class);
+ tip = &tinfo;
+ if (!typeinfo_init_class(tip, initclass))
+ return false;
}
else {
- instancecount = 1;
- instanceslot = VAR(iptr->sx.s23.s2.args[0]);
+ tip = instanceti;
}
- assert((instanceslot && instancecount == 1) || invokestatic);
-
- /* record subtype constraints for the instance type, if any */
- if (instanceslot) {
- typeinfo *tip;
-
- assert(instanceslot->type == TYPE_ADR);
+ result = resolve_lazy_subtype_checks(refmethod,
+ tip,
+ CLASSREF_OR_CLASSINFO(mi->class),
+ resolveLinkageError);
+ if (result != resolveSucceeded)
+ return result;
- if (invokespecial && TYPEINFO_IS_NEWOBJECT(instanceslot->typeinfo))
- { /* XXX clean up */
- instruction *ins = (instruction *) TYPEINFO_NEWOBJECT_INSTRUCTION(instanceslot->typeinfo);
- classref_or_classinfo initclass = (ins) ? ins[-1].sx.val.c
- : CLASSREF_OR_CLASSINFO(refmethod->class);
- tip = &tinfo;
- if (!typeinfo_init_class(tip,initclass))
- return false;
- }
- else {
- tip = &(instanceslot->typeinfo);
- }
+ /* check protected access */
+ /* XXX use other `declarer` than mi->class? */
+ if (((mi->flags & ACC_PROTECTED) != 0)
+ && !SAME_PACKAGE(mi->class, refmethod->class))
+ {
result = resolve_lazy_subtype_checks(refmethod,
- tip,
- CLASSREF_OR_CLASSINFO(mi->class),
- resolveLinkageError);
+ tip,
+ CLASSREF_OR_CLASSINFO(refmethod->class),
+ resolveIllegalAccessError);
if (result != resolveSucceeded)
return result;
+ }
- /* check protected access */
+ /* everything ok */
- /* XXX use other `declarer` than mi->class? */
- if (((mi->flags & ACC_PROTECTED) != 0)
- && !SAME_PACKAGE(mi->class, refmethod->class))
- {
- result = resolve_lazy_subtype_checks(refmethod,
- tip,
- CLASSREF_OR_CLASSINFO(refmethod->class),
- resolveIllegalAccessError);
- if (result != resolveSucceeded)
- return result;
- }
+ return resolveSucceeded;
+}
+#endif /* defined(ENABLE_VERIFIER) */
- }
+
+/* resolve_method_param_type_checks ********************************************
+
+ Check non-instance parameter types of a method invocation.
+
+ IN:
+ jd...............jitdata of the method doing the call
+ refmethod........the method containing the reference
+ iptr.............the invoke instruction
+ mi...............the methodinfo of the resolved method
+ invokestatic.....true if the method is invoked by INVOKESTATIC
+
+ RETURN VALUE:
+ resolveSucceeded....everything ok
+ resolveDeferred.....tests could not be done, have been deferred
+ resolveFailed.......exception has been thrown
+
+*******************************************************************************/
+
+#if defined(ENABLE_VERIFIER)
+resolve_result_t resolve_method_param_type_checks(jitdata *jd,
+ methodinfo *refmethod,
+ instruction *iptr,
+ methodinfo *mi,
+ bool invokestatic)
+{
+ varinfo *param;
+ resolve_result_t result;
+ methoddesc *md;
+ typedesc *paramtypes;
+ s4 type;
+ s4 instancecount;
+ s4 i;
+
+ assert(jd);
+
+ instancecount = (invokestatic) ? 0 : 1;
/* check subtype constraints for TYPE_ADR parameters */
Changes:
- $Id: resolve.h 5727 2006-10-09 23:17:56Z edwin $
+ $Id: resolve.h 5729 2006-10-09 23:53:42Z edwin $
*/
resolve_result_t resolve_field_lazy(methodinfo *refmethod,
constant_FMIref *fieldref);
-#ifdef ENABLE_VERIFIER
+#if defined(ENABLE_VERIFIER)
resolve_result_t resolve_field_verifier_checks(methodinfo *refmethod,
constant_FMIref *fieldref,
classinfo *container,
methodinfo *mi,
bool invokestatic);
-resolve_result_t resolve_method_type_checks(jitdata *jd,
- methodinfo *refmethod,
- instruction *iptr,
- methodinfo *mi,
- bool invokestatic,
- bool invokespecial);
+resolve_result_t resolve_method_instance_type_checks(methodinfo *refmethod,
+ methodinfo *mi,
+ typeinfo *instanceti,
+ bool invokespecial);
+
+resolve_result_t resolve_method_param_type_checks(jitdata *jd,
+ methodinfo *refmethod,
+ instruction *iptr,
+ methodinfo *mi,
+ bool invokestatic);
bool resolve_method_loading_constraints(classinfo *referer,
methodinfo *mi);
unresolved_method *ref, classinfo *referer,
methodinfo *refmethod, instruction *iptr);
-#endif
+#endif /* defined(ENABLE_VERIFIER) */
#ifndef NDEBUG
void unresolved_class_debug_dump(unresolved_class *ref,FILE *file);