From: <cap...@us...> - 2007-04-16 21:25:37
|
Revision: 58 http://svn.sourceforge.net/pearcolator/?rev=58&view=rev Author: captain5050 Date: 2007-04-16 14:25:39 -0700 (Mon, 16 Apr 2007) Log Message: ----------- Changes to reflect recent changes in the RVM Modified Paths: -------------- ext/org/jikesrvm/classloader/VM_Member.java ext/org/jikesrvm/compilers/opt/ir/OPT_BC2IR.java Modified: ext/org/jikesrvm/classloader/VM_Member.java =================================================================== --- ext/org/jikesrvm/classloader/VM_Member.java 2007-04-14 14:51:26 UTC (rev 57) +++ ext/org/jikesrvm/classloader/VM_Member.java 2007-04-16 21:25:39 UTC (rev 58) @@ -14,17 +14,19 @@ /** * A field or method of a java class. - * + * * @author Bowen Alpern * @author Dave Grove * @author Derek Lieber */ -public abstract class VM_Member extends VM_AnnotatedElement implements - VM_Constants, VM_ClassLoaderConstants { +public abstract class VM_Member extends VM_AnnotatedElement implements VM_Constants, VM_ClassLoaderConstants { + /** Initial value for a field offset - indicates field not laid out. */ + private static final int NO_OFFSET = Short.MIN_VALUE+1; + /** - * The class that declared this member, avaliable by calling getDeclaringClass - * once the class is loaded. + * The class that declared this member, avaliable by calling + * getDeclaringClass once the class is loaded. */ private final VM_TypeReference declaringClass; @@ -39,53 +41,46 @@ public final short modifiers; /** - * The signature is a string representing the generic type for this field or - * method declaration, may be null + * The signature is a string representing the generic type for this + * field or method declaration, may be null */ private final VM_Atom signature; /** - * The member's jtoc/obj/tib offset in bytes. Set by - * {@link VM_Class#resolve()} + * The member's jtoc/obj/tib offset in bytes. + * Set by {@link VM_Class#resolve()} */ protected int offset; /** - * NOTE: Only {@link VM_Class} is allowed to create an instance of a - * VM_Member. + * NOTE: Only {@link VM_Class} is allowed to create an instance of a VM_Member. * - * @param declaringClass - * the VM_TypeReference object of the class that declared this member - * @param memRef - * the canonical memberReference for this member. - * @param modifiers - * modifiers associated with this member. - * @param signature - * generic type of this member - * @param annotations - * array of runtime visible annotations + * @param declaringClass the VM_TypeReference object of the class that declared this member + * @param memRef the canonical memberReference for this member. + * @param modifiers modifiers associated with this member. + * @param signature generic type of this member + * @param annotations array of runtime visible annotations */ - protected VM_Member(VM_TypeReference declaringClass, - VM_MemberReference memRef, short modifiers, VM_Atom signature, - VM_Annotation[] annotations) { + protected VM_Member(VM_TypeReference declaringClass, VM_MemberReference memRef, + short modifiers, VM_Atom signature, + VM_Annotation[] annotations) { super(annotations); this.declaringClass = declaringClass; this.memRef = memRef; this.modifiers = modifiers; this.signature = signature; - this.offset = Short.MIN_VALUE + 1; // invalid value. Set to valid value - // during VM_Class.resolve() + this.offset = NO_OFFSET; // invalid value. Set to valid value during VM_Class.resolve() } - // --------------------------------------------------------------------// - // Section 1. // - // The following are available after class loading. // - // --------------------------------------------------------------------// + //--------------------------------------------------------------------// + // Section 1. // + // The following are available after class loading. // + //--------------------------------------------------------------------// /** - * Class that declared this field or method. Not available before the class is - * loaded. - */ + * Class that declared this field or method. Not available before + * the class is loaded. + */ @Uninterruptible public final VM_Class getDeclaringClass() { return declaringClass.peekResolvedType().asClass(); @@ -93,26 +88,26 @@ /** * Canonical member reference for this member. - */ + */ @Uninterruptible - public final VM_MemberReference getMemberRef() { + public final VM_MemberReference getMemberRef() { return memRef; } /** * Name of this member. - */ + */ @Uninterruptible - public final VM_Atom getName() { + public final VM_Atom getName() { return memRef.getName(); } /** - * Descriptor for this member. something like "I" for a field or "(I)V" for a - * method. - */ + * Descriptor for this member. + * something like "I" for a field or "(I)V" for a method. + */ @Uninterruptible - public final VM_Atom getDescriptor() { + public final VM_Atom getDescriptor() { return memRef.getDescriptor(); } @@ -124,47 +119,47 @@ } /** - * Get a unique id for this member. The id is the id of the canonical - * VM_MemberReference for this member and thus may be used to find the member - * by first finding the member reference. + * Get a unique id for this member. + * The id is the id of the canonical VM_MemberReference for this member + * and thus may be used to find the member by first finding the member reference. */ @Uninterruptible - public final int getId() { + public final int getId() { return memRef.getId(); } /* - * Define hashcode in terms of VM_Atom.hashCode to enable consistent hash - * codes during bootImage writing and run-time. + * Define hashcode in terms of VM_Atom.hashCode to enable + * consistent hash codes during bootImage writing and run-time. */ - public int hashCode() { + public int hashCode() { return memRef.hashCode(); } public final String toString() { return declaringClass + "." + getName() + " " + getDescriptor(); } - + /** * Usable from classes outside its package? - */ + */ public final boolean isPublic() { - return (modifiers & ACC_PUBLIC) != 0; + return (modifiers & ACC_PUBLIC) != 0; } /** * Usable only from this class? - */ - public final boolean isPrivate() { - return (modifiers & ACC_PRIVATE) != 0; + */ + public final boolean isPrivate() { + return (modifiers & ACC_PRIVATE) != 0; } - + /** * Usable from subclasses? - */ - public final boolean isProtected() { - return (modifiers & ACC_PROTECTED) != 0; - } + */ + public final boolean isProtected() { + return (modifiers & ACC_PROTECTED) != 0; + } /** * Get the member's modifiers. @@ -172,35 +167,42 @@ public final int getModifiers() { return modifiers; } + + /** + * Has the field been laid out in the object yet ? + * + * @return + */ + public final boolean hasOffset() { + return !(offset == NO_OFFSET); + } - // ------------------------------------------------------------------// - // Section 2. // - // The following are available after the declaring class has been // - // "resolved". // - // ------------------------------------------------------------------// + //------------------------------------------------------------------// + // Section 2. // + // The following are available after the declaring class has been // + // "resolved". // + //------------------------------------------------------------------// /** * Offset of this field or method, in bytes. * <ul> - * <li> For a static field: offset of field from start of jtoc - * <li> For a static method: offset of code object reference from start of - * jtoc - * <li> For a non-static field: offset of field from start of object - * <li> For a non-static method: offset of code object reference from start of - * tib + * <li> For a static field: offset of field from start of jtoc + * <li> For a static method: offset of code object reference from start of jtoc + * <li> For a non-static field: offset of field from start of object + * <li> For a non-static method: offset of code object reference from start of tib * </ul> - */ + */ @Uninterruptible - public final Offset getOffset() { - if (VM.VerifyAssertions) - VM._assert(declaringClass.isResolved()); + public final Offset getOffset() { + if (VM.VerifyAssertions) VM._assert(declaringClass.isResolved()); + if (VM.VerifyAssertions) VM._assert(offset != NO_OFFSET); return Offset.fromIntSignExtend(offset); } /** - * Only meant to be used by VM_ObjectModel.layoutInstanceFields. TODO: - * refactor system so this functionality is in the classloader package and - * this method doesn't have to be final. + * Only meant to be used by VM_ObjectModel.layoutInstanceFields. + * TODO: refactor system so this functionality is in the classloader package + * and this method doesn't have to be final. */ public final void setOffset(Offset off) { offset = off.toInt(); Modified: ext/org/jikesrvm/compilers/opt/ir/OPT_BC2IR.java =================================================================== --- ext/org/jikesrvm/compilers/opt/ir/OPT_BC2IR.java 2007-04-14 14:51:26 UTC (rev 57) +++ ext/org/jikesrvm/compilers/opt/ir/OPT_BC2IR.java 2007-04-16 21:25:39 UTC (rev 58) @@ -2686,7 +2686,12 @@ s.markAsNonPEI(); } for (int i = params.length - 1; i >= 0; i--) { - Call.setParam(s, i + numHiddenParams, pop(params[i])); + try { + Call.setParam(s, i + numHiddenParams, pop(params[i])); + } catch (OPT_OptimizingCompilerException.IllegalUpcast e) { + throw new Error("Illegal upcast creating call to " + meth + + " from " + gc.method + " argument " + i, e); + } } if (numHiddenParams != 0) { OPT_Operand ref = pop(); @@ -3211,6 +3216,15 @@ // Can't assert the following due to approximations by // OPT_ClassLoaderProxy.findCommonSuperclass // if (VM.VerifyAssertions) assertIsType(r, type); + if (VM.VerifyAssertions) { + if ((type == VM_TypeReference.JavaLangObject) && + (r.getType().isMagicType()) && + (r.getType() != VM_TypeReference.ObjectReference) && + !gc.method.getDeclaringClass().isMagicType() + ) { + throw new OPT_OptimizingCompilerException.IllegalUpcast(r.getType()); + } + } if (type.isLongType() || type.isDoubleType()) popDummy(); return r; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |