From: <mic...@us...> - 2007-03-31 22:03:22
|
Revision: 17 http://svn.sourceforge.net/pearcolator/?rev=17&view=rev Author: michael_baer Date: 2007-03-31 15:03:22 -0700 (Sat, 31 Mar 2007) Log Message: ----------- Enforced JRVM formatting guidelines, introduced generics, reduced no. of warnings Modified Paths: -------------- ext/org/jikesrvm/classloader/VM_Member.java ext/org/jikesrvm/classloader/VM_Method.java ext/org/jikesrvm/classloader/VM_NormalMethod.java ext/org/jikesrvm/ppc/PPC_Disassembler.java ext/org/jikesrvm/ppc/opcodeXX.java ext/org/jikesrvm/ppc/opcode_tab.java src/org/binarytranslator/DBT_Options.java src/org/binarytranslator/Main.java src/org/binarytranslator/arch/arm/os/process/ARM_ProcessSpace.java src/org/binarytranslator/arch/arm/os/process/ARM_Registers.java src/org/binarytranslator/arch/arm/os/process/linux/ARM_LinuxProcessSpace.java src/org/binarytranslator/arch/arm/os/process/linux/ARM_SyscallArgumentIterator.java src/org/binarytranslator/arch/ppc/decoder/PPC2IR.java src/org/binarytranslator/arch/ppc/decoder/PPC_Constants.java src/org/binarytranslator/arch/ppc/decoder/PPC_InstructionDecoder.java src/org/binarytranslator/arch/ppc/decoder/PPC_Laziness.java src/org/binarytranslator/arch/ppc/os/process/linux/PPC_LinuxProcessSpace.java src/org/binarytranslator/arch/ppc/os/process/linux/PPC_LinuxSyscallArgumentIterator.java src/org/binarytranslator/arch/x86/decoder/X862IR.java src/org/binarytranslator/arch/x86/decoder/X86_Constants.java src/org/binarytranslator/arch/x86/decoder/X86_DecodedOperand.java src/org/binarytranslator/arch/x86/decoder/X86_FlagLaziness.java src/org/binarytranslator/arch/x86/decoder/X86_InstructionDecoder.java src/org/binarytranslator/arch/x86/decoder/X86_Laziness.java src/org/binarytranslator/arch/x86/decoder/X86_ModRM_Decoder.java src/org/binarytranslator/arch/x86/decoder/X86_RegisterSyncLaziness.java src/org/binarytranslator/arch/x86/decoder/X86_Registers.java src/org/binarytranslator/arch/x86/decoder/X86_SIB_Decoder.java src/org/binarytranslator/arch/x86/os/abi/linux/X86_LinuxSystemCalls.java src/org/binarytranslator/generic/branch/BranchLogic.java src/org/binarytranslator/generic/branch/CallAndReturnAddress.java src/org/binarytranslator/generic/branch/ProcedureInformation.java src/org/binarytranslator/generic/decoder/DecoderUtils.java src/org/binarytranslator/generic/decoder/InstructionDecoder.java src/org/binarytranslator/generic/decoder/Laziness.java src/org/binarytranslator/generic/gdbstub/GDBStub.java src/org/binarytranslator/generic/gdbstub/GDBTarget.java src/org/binarytranslator/generic/memory/ByteAddressedByteSwapMemory.java src/org/binarytranslator/generic/memory/ByteAddressedMemory.java src/org/binarytranslator/generic/memory/ByteAddressedReversedMemory.java src/org/binarytranslator/generic/memory/CallBasedMemory.java src/org/binarytranslator/generic/memory/IntAddressedByteSwapMemory.java src/org/binarytranslator/generic/memory/IntAddressedMemory.java src/org/binarytranslator/generic/memory/IntAddressedPreSwappedMemory.java src/org/binarytranslator/generic/memory/IntAddressedReversedMemory.java src/org/binarytranslator/generic/memory/Memory.java src/org/binarytranslator/generic/memory/MemoryMapException.java src/org/binarytranslator/generic/os/abi/linux/LinuxSystemCalls.java src/org/binarytranslator/generic/os/loader/elf/ELF_Loader.java src/org/binarytranslator/generic/os/loader/image/ImageLoader.java src/org/binarytranslator/generic/os/process/ProcessSpace.java src/org/binarytranslator/vmInterface/DBT_ConvertBinaryToHIR.java src/org/binarytranslator/vmInterface/DBT_Trace.java src/org/binarytranslator/vmInterface/DynamicCodeRunner.java src/org/binarytranslator/vmInterface/TranslationHelper.java Modified: ext/org/jikesrvm/classloader/VM_Member.java =================================================================== --- ext/org/jikesrvm/classloader/VM_Member.java 2007-03-31 14:04:36 UTC (rev 16) +++ ext/org/jikesrvm/classloader/VM_Member.java 2007-03-31 22:03:22 UTC (rev 17) @@ -14,16 +14,17 @@ /** * 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 { /** - * 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; @@ -38,46 +39,53 @@ 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 = Short.MIN_VALUE + 1; // 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(); @@ -85,26 +93,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(); } @@ -116,47 +124,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. @@ -165,31 +173,34 @@ return modifiers; } - //------------------------------------------------------------------// - // 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()); 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/classloader/VM_Method.java =================================================================== --- ext/org/jikesrvm/classloader/VM_Method.java 2007-03-31 14:04:36 UTC (rev 16) +++ ext/org/jikesrvm/classloader/VM_Method.java 2007-03-31 22:03:22 UTC (rev 17) @@ -21,121 +21,143 @@ import org.vmmagic.pragma.*; /** - * A method of a java class corresponding to a method_info structure - * in the class file. A method is read from a class file using the - * {@link #readMethod} method. - * + * A method of a java class corresponding to a method_info structure in the + * class file. A method is read from a class file using the {@link #readMethod} + * method. + * * @author Bowen Alpern * @author Dave Grove * @author Derek Lieber * @author Ian Rogers */ -public abstract class VM_Method extends VM_Member implements VM_BytecodeConstants { +public abstract class VM_Method extends VM_Member implements + VM_BytecodeConstants { /** * current compiled method for this method */ protected VM_CompiledMethod currentCompiledMethod; + /** * exceptions this method might throw (null --> none) */ protected final VM_TypeReference[] exceptionTypes; + /** - * Method paramter annotations from the class file that are - * described as runtime visible. These annotations are available to - * the reflection API. + * Method paramter annotations from the class file that are described as + * runtime visible. These annotations are available to the reflection API. */ protected final VM_Annotation[] parameterAnnotations; + /** * A value present in the method info tables of annotation types. It * represents the default result from an annotation method. */ protected final Object annotationDefault; + /** - * The offset of this virtual method in the jtoc if it's been placed - * there by constant propagation, otherwise 0. + * The offset of this virtual method in the jtoc if it's been placed there by + * constant propagation, otherwise 0. */ private Offset jtocOffset; /** * Construct a read method - * - * @param declaringClass the VM_Class object of the class that declared this field - * @param memRef the canonical memberReference for this method. - * @param modifiers modifiers associated with this method. - * @param exceptionTypes exceptions thrown by this method. - * @param signature generic type of this method. - * @param annotations array of runtime visible annotations - * @param parameterAnnotations array of runtime visible parameter annotations - * @param annotationDefault value for this annotation that appears + * + * @param declaringClass + * the VM_Class object of the class that declared this field + * @param memRef + * the canonical memberReference for this method. + * @param modifiers + * modifiers associated with this method. + * @param exceptionTypes + * exceptions thrown by this method. + * @param signature + * generic type of this method. + * @param annotations + * array of runtime visible annotations + * @param parameterAnnotations + * array of runtime visible parameter annotations + * @param annotationDefault + * value for this annotation that appears */ - protected VM_Method(VM_TypeReference declaringClass, VM_MemberReference memRef, - short modifiers, VM_TypeReference[] exceptionTypes, VM_Atom signature, - VM_Annotation[] annotations, - VM_Annotation[] parameterAnnotations, - Object annotationDefault) - { - super(declaringClass, memRef, (short)(modifiers & APPLICABLE_TO_METHODS), signature, annotations); + protected VM_Method(VM_TypeReference declaringClass, + VM_MemberReference memRef, short modifiers, + VM_TypeReference[] exceptionTypes, VM_Atom signature, + VM_Annotation[] annotations, VM_Annotation[] parameterAnnotations, + Object annotationDefault) { + super(declaringClass, memRef, (short) (modifiers & APPLICABLE_TO_METHODS), + signature, annotations); this.parameterAnnotations = parameterAnnotations; this.annotationDefault = annotationDefault; memRef.asMethodReference().setResolvedMember(this); this.exceptionTypes = exceptionTypes; this.jtocOffset = Offset.fromIntSignExtend(-1); } - + /** - * Called from {@link VM_Class#readClass(VM_TypeReference, DataInputStream)} to create an - * instance of a VM_Method by reading the relevant data from the argument bytecode stream. + * Called from {@link VM_Class#readClass(VM_TypeReference, DataInputStream)} + * to create an instance of a VM_Method by reading the relevant data from the + * argument bytecode stream. * - * @param declaringClass the VM_TypeReference of the class being loaded - * @param constantPool the constantPool of the VM_Class object that's being constructed - * @param memRef the canonical memberReference for this member. - * @param modifiers modifiers associated with this member. - * @param input the DataInputStream to read the method's attributes from + * @param declaringClass + * the VM_TypeReference of the class being loaded + * @param constantPool + * the constantPool of the VM_Class object that's being constructed + * @param memRef + * the canonical memberReference for this member. + * @param modifiers + * modifiers associated with this member. + * @param input + * the DataInputStream to read the method's attributes from */ - static VM_Method readMethod(VM_TypeReference declaringClass, int[] constantPool, VM_MemberReference memRef, - short modifiers, DataInputStream input) throws IOException { + static VM_Method readMethod(VM_TypeReference declaringClass, + int[] constantPool, VM_MemberReference memRef, short modifiers, + DataInputStream input) throws IOException { short tmp_localWords = 0; - short tmp_operandWords = 0; - byte[] tmp_bytecodes = null; + short tmp_operandWords = 0; + byte[] tmp_bytecodes = null; VM_ExceptionHandlerMap tmp_exceptionHandlerMap = null; VM_TypeReference[] tmp_exceptionTypes = null; - int[] tmp_lineNumberMap = null; + int[] tmp_lineNumberMap = null; VM_Atom tmp_signature = null; VM_Annotation[] annotations = null; VM_Annotation[] parameterAnnotations = null; Object tmp_annotationDefault = null; // Read the attributes - for (int i = 0, n = input.readUnsignedShort(); i<n; i++) { - VM_Atom attName = VM_Class.getUtf(constantPool, input.readUnsignedShort()); - int attLength = input.readInt(); + for (int i = 0, n = input.readUnsignedShort(); i < n; i++) { + VM_Atom attName = VM_Class + .getUtf(constantPool, input.readUnsignedShort()); + int attLength = input.readInt(); // Only bother to interpret non-boring Method attributes if (attName == VM_ClassLoader.codeAttributeName) { tmp_operandWords = input.readShort(); - tmp_localWords = input.readShort(); + tmp_localWords = input.readShort(); tmp_bytecodes = new byte[input.readInt()]; input.readFully(tmp_bytecodes); - tmp_exceptionHandlerMap = VM_ExceptionHandlerMap.readExceptionHandlerMap(input, constantPool); + tmp_exceptionHandlerMap = VM_ExceptionHandlerMap + .readExceptionHandlerMap(input, constantPool); // Read the attributes portion of the code attribute - for (int j = 0, n2 = input.readUnsignedShort(); j<n2; j++) { - attName = VM_Class.getUtf(constantPool, input.readUnsignedShort()); + for (int j = 0, n2 = input.readUnsignedShort(); j < n2; j++) { + attName = VM_Class.getUtf(constantPool, input.readUnsignedShort()); attLength = input.readInt(); if (attName == VM_ClassLoader.lineNumberTableAttributeName) { int cnt = input.readUnsignedShort(); if (cnt != 0) { tmp_lineNumberMap = new int[cnt]; - for (int k = 0; k<cnt; k++) { + for (int k = 0; k < cnt; k++) { int startPC = input.readUnsignedShort(); int lineNumber = input.readUnsignedShort(); tmp_lineNumberMap[k] = (lineNumber << BITS_IN_SHORT) | startPC; } } } else { - // All other entries in the attribute portion of the code attribute are boring. + // All other entries in the attribute portion of the code attribute + // are boring. input.skipBytes(attLength); } } @@ -144,24 +166,26 @@ if (cnt != 0) { tmp_exceptionTypes = new VM_TypeReference[cnt]; for (int j = 0, m = tmp_exceptionTypes.length; j < m; ++j) { - tmp_exceptionTypes[j] = VM_Class.getTypeRef(constantPool, input.readUnsignedShort()); + tmp_exceptionTypes[j] = VM_Class.getTypeRef(constantPool, input + .readUnsignedShort()); } } } else if (attName == VM_ClassLoader.syntheticAttributeName) { modifiers |= ACC_SYNTHETIC; } else if (attName == VM_ClassLoader.signatureAttributeName) { - tmp_signature = VM_Class.getUtf(constantPool, input.readUnsignedShort()); + tmp_signature = VM_Class + .getUtf(constantPool, input.readUnsignedShort()); } else if (attName == VM_ClassLoader.runtimeVisibleAnnotationsAttributeName) { - annotations = VM_AnnotatedElement.readAnnotations(constantPool, input, 2, - declaringClass.getClassLoader()); + annotations = VM_AnnotatedElement.readAnnotations(constantPool, input, + 2, declaringClass.getClassLoader()); } else if (attName == VM_ClassLoader.runtimeVisibleParameterAnnotationsAttributeName) { - parameterAnnotations = VM_AnnotatedElement.readAnnotations(constantPool, input, 1, - declaringClass.getClassLoader()); + parameterAnnotations = VM_AnnotatedElement.readAnnotations( + constantPool, input, 1, declaringClass.getClassLoader()); } else if (attName == VM_ClassLoader.annotationDefaultAttributeName) { try { - tmp_annotationDefault = VM_Annotation.readValue(constantPool, input, declaringClass.getClassLoader()); - } - catch (ClassNotFoundException e){ + tmp_annotationDefault = VM_Annotation.readValue(constantPool, input, + declaringClass.getClassLoader()); + } catch (ClassNotFoundException e) { throw new Error(e); } } else { @@ -171,175 +195,173 @@ } VM_Method method; if ((modifiers & ACC_NATIVE) != 0) { - method = new VM_NativeMethod(declaringClass, memRef, modifiers, tmp_exceptionTypes, tmp_signature, - annotations, parameterAnnotations, tmp_annotationDefault); + method = new VM_NativeMethod(declaringClass, memRef, modifiers, + tmp_exceptionTypes, tmp_signature, annotations, parameterAnnotations, + tmp_annotationDefault); } else if ((modifiers & ACC_ABSTRACT) != 0) { - method = new VM_AbstractMethod(declaringClass, memRef, modifiers, tmp_exceptionTypes, tmp_signature, - annotations, parameterAnnotations, tmp_annotationDefault); + method = new VM_AbstractMethod(declaringClass, memRef, modifiers, + tmp_exceptionTypes, tmp_signature, annotations, parameterAnnotations, + tmp_annotationDefault); } else { - method = new VM_NormalMethod(declaringClass, memRef, modifiers, tmp_exceptionTypes, - tmp_localWords, tmp_operandWords, tmp_bytecodes, - tmp_exceptionHandlerMap, tmp_lineNumberMap, - constantPool, tmp_signature, - annotations, parameterAnnotations, tmp_annotationDefault); + method = new VM_NormalMethod(declaringClass, memRef, modifiers, + tmp_exceptionTypes, tmp_localWords, tmp_operandWords, tmp_bytecodes, + tmp_exceptionHandlerMap, tmp_lineNumberMap, constantPool, + tmp_signature, annotations, parameterAnnotations, + tmp_annotationDefault); } return method; } /** - * Create a copy of the method that occurs in the annotation - * interface. The method body will contain a read of the field at - * the constant pool index specified. - * - * @param annotationClass the class this method belongs to - * @param constantPool for the class - * @param memRef the member reference corresponding to this method - * @param interfaceMethod the interface method that will copied to - * produce the annotation method - * @param constantPoolIndex the index of the field that will be - * returned by this method + * Create a copy of the method that occurs in the annotation interface. The + * method body will contain a read of the field at the constant pool index + * specified. + * + * @param annotationClass + * the class this method belongs to + * @param constantPool + * for the class + * @param memRef + * the member reference corresponding to this method + * @param interfaceMethod + * the interface method that will copied to produce the annotation + * method + * @param constantPoolIndex + * the index of the field that will be returned by this method * @return the created method */ - static VM_Method createAnnotationMethod(VM_TypeReference annotationClass, int[] constantPool, - VM_MemberReference memRef, VM_Method interfaceMethod, - int constantPoolIndex) { - byte[] bytecodes = new byte[] { - (byte)JBC_aload_0, - (byte)JBC_getfield, - (byte)(constantPoolIndex >>> 8), - (byte)constantPoolIndex, - // Xreturn - (byte)typeRefToReturnBytecode(interfaceMethod.getReturnType()) - }; - return new VM_NormalMethod(annotationClass, memRef, (short)(ACC_PUBLIC|ACC_FINAL|ACC_SYNTHETIC), null, - (short)1, (short)2, bytecodes, - null, null, - constantPool, - null, null, null, null); + static VM_Method createAnnotationMethod(VM_TypeReference annotationClass, + int[] constantPool, VM_MemberReference memRef, VM_Method interfaceMethod, + int constantPoolIndex) { + byte[] bytecodes = new byte[] { (byte) JBC_aload_0, (byte) JBC_getfield, + (byte) (constantPoolIndex >>> 8), (byte) constantPoolIndex, + // Xreturn + (byte) typeRefToReturnBytecode(interfaceMethod.getReturnType()) }; + return new VM_NormalMethod(annotationClass, memRef, (short) (ACC_PUBLIC + | ACC_FINAL | ACC_SYNTHETIC), null, (short) 1, (short) 2, bytecodes, + null, null, constantPool, null, null, null, null); } + /** * Create a method to initialise the annotation class - * - * @param aClass the class this method belongs to - * @param constantPool for the class - * @param memRef the member reference corresponding to this method - * @param objectInitIndex an index into the constant pool for a - * method reference to java.lang.Object.<init> + * + * @param aClass + * the class this method belongs to + * @param constantPool + * for the class + * @param memRef + * the member reference corresponding to this method + * @param objectInitIndex + * an index into the constant pool for a method reference to + * java.lang.Object.<init> * @param aFields * @param aMethods * @return the created method */ - static VM_Method createAnnotationInit(VM_TypeReference aClass, int[] constantPool, - VM_MemberReference memRef, int objectInitIndex, - VM_Field[] aFields, VM_Method[] aMethods, - int[] defaultConstants) { - byte[] bytecode = new byte[6+(defaultConstants.length*7)]; - bytecode[0] = (byte)JBC_aload_0; // stack[0] = this - bytecode[1] = (byte)JBC_aload_1; // stack[1] = instanceof VM_Annotation - bytecode[2] = (byte)JBC_invokespecial; - bytecode[3] = (byte)(objectInitIndex >>> 8); - bytecode[4] = (byte)objectInitIndex; - for(int i=0, j=0; i < aMethods.length; i++) { - if(aMethods[i].annotationDefault != null) { - bytecode[(j*7)+5+0] = (byte)JBC_aload_0; // stack[0] = this - if(VM_Class.getLiteralSize(constantPool, defaultConstants[j]) == BYTES_IN_INT) { - bytecode[(j*7)+5+1] = (byte)JBC_ldc_w; // stack[1] = value + static VM_Method createAnnotationInit(VM_TypeReference aClass, + int[] constantPool, VM_MemberReference memRef, int objectInitIndex, + VM_Field[] aFields, VM_Method[] aMethods, int[] defaultConstants) { + byte[] bytecode = new byte[6 + (defaultConstants.length * 7)]; + bytecode[0] = (byte) JBC_aload_0; // stack[0] = this + bytecode[1] = (byte) JBC_aload_1; // stack[1] = instanceof VM_Annotation + bytecode[2] = (byte) JBC_invokespecial; + bytecode[3] = (byte) (objectInitIndex >>> 8); + bytecode[4] = (byte) objectInitIndex; + for (int i = 0, j = 0; i < aMethods.length; i++) { + if (aMethods[i].annotationDefault != null) { + bytecode[(j * 7) + 5 + 0] = (byte) JBC_aload_0; // stack[0] = this + if (VM_Class.getLiteralSize(constantPool, defaultConstants[j]) == BYTES_IN_INT) { + bytecode[(j * 7) + 5 + 1] = (byte) JBC_ldc_w; // stack[1] = value + } else { + bytecode[(j * 7) + 5 + 1] = (byte) JBC_ldc2_w;// stack[1&2] = value } - else { - bytecode[(j*7)+5+1] = (byte)JBC_ldc2_w;// stack[1&2] = value - } - bytecode[(j*7)+5+2] = (byte)(defaultConstants[j] >>> 8); - bytecode[(j*7)+5+3] = (byte)defaultConstants[j]; - bytecode[(j*7)+5+4] = (byte)JBC_putfield; - bytecode[(j*7)+5+5] = (byte)(i >>> 8); - bytecode[(j*7)+5+6] = (byte)i; + bytecode[(j * 7) + 5 + 2] = (byte) (defaultConstants[j] >>> 8); + bytecode[(j * 7) + 5 + 3] = (byte) defaultConstants[j]; + bytecode[(j * 7) + 5 + 4] = (byte) JBC_putfield; + bytecode[(j * 7) + 5 + 5] = (byte) (i >>> 8); + bytecode[(j * 7) + 5 + 6] = (byte) i; j++; } } - bytecode[bytecode.length-1] = (byte)JBC_return; - return new VM_NormalMethod(aClass, memRef, (short)(ACC_PUBLIC|ACC_FINAL|ACC_SYNTHETIC), null, - (short)2, (short)3, bytecode, - null, null, - constantPool, - null, null, null, null); + bytecode[bytecode.length - 1] = (byte) JBC_return; + return new VM_NormalMethod(aClass, memRef, + (short) (ACC_PUBLIC | ACC_FINAL | ACC_SYNTHETIC), null, (short) 2, + (short) 3, bytecode, null, null, constantPool, null, null, null, null); } /** - * What would be the appropriate return bytecode for the given type - * reference? + * What would be the appropriate return bytecode for the given type reference? */ private static int typeRefToReturnBytecode(VM_TypeReference tr) { - if(!tr.isPrimitiveType()) { + if (!tr.isPrimitiveType()) { return JBC_areturn; } else { - VM_Primitive pt = (VM_Primitive)tr.peekResolvedType(); - if((pt == VM_Type.BooleanType)||(pt == VM_Type.ByteType)||(pt == VM_Type.ShortType)|| - (pt == VM_Type.CharType)||(pt == VM_Type.IntType)) { + VM_Primitive pt = (VM_Primitive) tr.peekResolvedType(); + if ((pt == VM_Type.BooleanType) || (pt == VM_Type.ByteType) + || (pt == VM_Type.ShortType) || (pt == VM_Type.CharType) + || (pt == VM_Type.IntType)) { return JBC_ireturn; - } - else if(pt == VM_Type.LongType) { + } else if (pt == VM_Type.LongType) { return JBC_lreturn; - } - else if(pt == VM_Type.FloatType) { + } else if (pt == VM_Type.FloatType) { return JBC_freturn; - } - else if(pt == VM_Type.DoubleType) { + } else if (pt == VM_Type.DoubleType) { return JBC_dreturn; - } - else { + } else { VM._assert(false); return -1; } } } + /** * Is this method a class initializer? */ @Uninterruptible - public final boolean isClassInitializer() { - return getName() == VM_ClassLoader.StandardClassInitializerMethodName; + public final boolean isClassInitializer() { + return getName() == VM_ClassLoader.StandardClassInitializerMethodName; } /** * Is this method an object initializer? */ @Uninterruptible - public final boolean isObjectInitializer() { - return getName() == VM_ClassLoader.StandardObjectInitializerMethodName; + public final boolean isObjectInitializer() { + return getName() == VM_ClassLoader.StandardObjectInitializerMethodName; } /** * Is this method a compiler-generated object initializer helper? */ @Uninterruptible - public final boolean isObjectInitializerHelper() { - return getName() == VM_ClassLoader.StandardObjectInitializerHelperMethodName; + public final boolean isObjectInitializerHelper() { + return getName() == VM_ClassLoader.StandardObjectInitializerHelperMethodName; } /** * Type of this method's return value. */ @Uninterruptible - public final VM_TypeReference getReturnType() { + public final VM_TypeReference getReturnType() { return memRef.asMethodReference().getReturnType(); } /** - * Type of this method's parameters. - * Note: does *not* include implicit "this" parameter, if any. + * Type of this method's parameters. Note: does *not* include implicit "this" + * parameter, if any. */ @Uninterruptible - public final VM_TypeReference[] getParameterTypes() { + public final VM_TypeReference[] getParameterTypes() { return memRef.asMethodReference().getParameterTypes(); } /** - * Space required by this method for its parameters, in words. - * Note: does *not* include implicit "this" parameter, if any. + * Space required by this method for its parameters, in words. Note: does + * *not* include implicit "this" parameter, if any. */ @Uninterruptible - public final int getParameterWords() { + public final int getParameterWords() { return memRef.asMethodReference().getParameterWords(); } @@ -351,15 +373,16 @@ } /** - * Get the current compiled method for this method. - * Will return null if there is no current compiled method! - * - * We make this method Unpreemptible to avoid a race-condition - * in VM_Reflection.invoke. + * Get the current compiled method for this method. Will return null if there + * is no current compiled method! + * + * We make this method Unpreemptible to avoid a race-condition in + * VM_Reflection.invoke. + * * @return compiled method - */ + */ @Unpreemptible - public final synchronized VM_CompiledMethod getCurrentCompiledMethod() { + public final synchronized VM_CompiledMethod getCurrentCompiledMethod() { return currentCompiledMethod; } @@ -367,7 +390,7 @@ * Declared as statically dispatched? */ @Uninterruptible - public final boolean isStatic() { + public final boolean isStatic() { return (modifiers & ACC_STATIC) != 0; } @@ -375,7 +398,7 @@ * Declared as non-overridable by subclasses? */ @Uninterruptible - public final boolean isFinal() { + public final boolean isFinal() { return (modifiers & ACC_FINAL) != 0; } @@ -383,7 +406,7 @@ * Guarded by monitorenter/monitorexit? */ @Uninterruptible - public final boolean isSynchronized() { + public final boolean isSynchronized() { return (modifiers & ACC_SYNCHRONIZED) != 0; } @@ -391,7 +414,7 @@ * Not implemented in java? */ @Uninterruptible - public final boolean isNative() { + public final boolean isNative() { return (modifiers & ACC_NATIVE) != 0; } @@ -399,14 +422,15 @@ * Not implemented in Java and use C not JNI calling convention */ public final boolean isSysCall() { - return isNative() && isStatic() && isAnnotationDeclared(VM_TypeReference.SysCall); + return isNative() && isStatic() + && isAnnotationDeclared(VM_TypeReference.SysCall); } - + /** * Implemented in subclass? */ @Uninterruptible - public final boolean isAbstract() { + public final boolean isAbstract() { return (modifiers & ACC_ABSTRACT) != 0; } @@ -418,46 +442,58 @@ } /** - * Exceptions thrown by this method - - * something like { "java/lang/IOException", "java/lang/EOFException" } + * Exceptions thrown by this method - something like { + * "java/lang/IOException", "java/lang/EOFException" } + * * @return info (null --> method doesn't throw any exceptions) */ @Uninterruptible - public final VM_TypeReference[] getExceptionTypes() { + public final VM_TypeReference[] getExceptionTypes() { return exceptionTypes; } /** - * Is this method interruptible? - * In other words, should the compiler insert yieldpoints - * in method prologue, epilogue, and backwards branches. - * Also, only methods that are Interruptible have stackoverflow checks - * in the method prologue (since there is no mechanism for handling a stackoverflow - * that doesn't violate the uninterruptiblity of the method). - * To determine if a method is interruptible, the following conditions - * are checked (<em>in order</em>): + * Is this method interruptible? In other words, should the compiler insert + * yieldpoints in method prologue, epilogue, and backwards branches. Also, + * only methods that are Interruptible have stackoverflow checks in the method + * prologue (since there is no mechanism for handling a stackoverflow that + * doesn't violate the uninterruptiblity of the method). To determine if a + * method is interruptible, the following conditions are checked (<em>in order</em>): * <ul> * <li> If it is a <clinit> or <init> method then it is interruptible. - * <li> If is the synthetic 'this' method used by jikes to - * factor out default initializers for <init> methods then it is interruptible. - * <li> If it is annotated with <CODE>Interruptible</CODE> it is interruptible. - * <li> If it is annotated with <CODE>Preemptible</CODE> it is interruptible. - * <li> If it is annotated with <CODE>Uninterruptible</CODE> it is not interruptible. - * <li> If it is annotated with <CODE>UninterruptibleNoWarn</CODE> it is not interruptible. - * <li> If it is annotated with <CODE>Unpreemptible</CODE> it is not interruptible. + * <li> If is the synthetic 'this' method used by jikes to factor out default + * initializers for <init> methods then it is interruptible. + * <li> If it is annotated with <CODE>Interruptible</CODE> it is + * interruptible. + * <li> If it is annotated with <CODE>Preemptible</CODE> it is + * interruptible. + * <li> If it is annotated with <CODE>Uninterruptible</CODE> it is not + * interruptible. + * <li> If it is annotated with <CODE>UninterruptibleNoWarn</CODE> it is not + * interruptible. + * <li> If it is annotated with <CODE>Unpreemptible</CODE> it is not + * interruptible. * <li> If its declaring class is annotated with <CODE>Uninterruptible</CODE> - * or <CODE>Unpreemptible</CODE> it is not interruptible. + * or <CODE>Unpreemptible</CODE> it is not interruptible. * </ul> */ public final boolean isInterruptible() { - if (isClassInitializer() || isObjectInitializer()) return true; - if (isObjectInitializerHelper()) return true; - if (hasInterruptibleAnnotation()) return true; - if (hasPreemptibleAnnotation()) return true; - if (hasUninterruptibleNoWarnAnnotation()) return false; - if (hasUninterruptibleAnnotation()) return false; - if (hasUnpreemptibleAnnotation()) return false; - if (getDeclaringClass().hasUnpreemptibleAnnotation()) return false; + if (isClassInitializer() || isObjectInitializer()) + return true; + if (isObjectInitializerHelper()) + return true; + if (hasInterruptibleAnnotation()) + return true; + if (hasPreemptibleAnnotation()) + return true; + if (hasUninterruptibleNoWarnAnnotation()) + return false; + if (hasUninterruptibleAnnotation()) + return false; + if (hasUnpreemptibleAnnotation()) + return false; + if (getDeclaringClass().hasUnpreemptibleAnnotation()) + return false; return !getDeclaringClass().hasUninterruptibleAnnotation(); } @@ -465,13 +501,20 @@ * Is the method Unpreemptible? See the comment in {@link #isInterruptible} */ public final boolean isUnpreemptible() { - if (isClassInitializer() || isObjectInitializer()) return false; - if (isObjectInitializerHelper()) return false; - if (hasInterruptibleAnnotation()) return false; - if (hasPreemptibleAnnotation()) return false; - if (hasUninterruptibleAnnotation()) return false; - if (hasUninterruptibleNoWarnAnnotation()) return false; - if (hasUnpreemptibleAnnotation()) return true; + if (isClassInitializer() || isObjectInitializer()) + return false; + if (isObjectInitializerHelper()) + return false; + if (hasInterruptibleAnnotation()) + return false; + if (hasPreemptibleAnnotation()) + return false; + if (hasUninterruptibleAnnotation()) + return false; + if (hasUninterruptibleNoWarnAnnotation()) + return false; + if (hasUnpreemptibleAnnotation()) + return true; return getDeclaringClass().hasUnpreemptibleAnnotation(); } @@ -479,20 +522,27 @@ * Is the method Uninterruptible? See the comment in {@link #isInterruptible} */ public final boolean isUninterruptible() { - if (isClassInitializer() || isObjectInitializer()) return false; - if (isObjectInitializerHelper()) return false; - if (hasInterruptibleAnnotation()) return false; - if (hasPreemptibleAnnotation()) return false; - if (hasUnpreemptibleAnnotation()) return false; - if (hasUninterruptibleAnnotation()) return true; - if (hasUninterruptibleNoWarnAnnotation()) return true; + if (isClassInitializer() || isObjectInitializer()) + return false; + if (isObjectInitializerHelper()) + return false; + if (hasInterruptibleAnnotation()) + return false; + if (hasPreemptibleAnnotation()) + return false; + if (hasUnpreemptibleAnnotation()) + return false; + if (hasUninterruptibleAnnotation()) + return true; + if (hasUninterruptibleNoWarnAnnotation()) + return true; return getDeclaringClass().hasUninterruptibleAnnotation(); } /** - * Has this method been marked as forbidden to inline? - * ie., it is marked with the <CODE>NoInline</CODE> annotation or - * the <CODE>NoOptCompile</CODE> annotation? + * Has this method been marked as forbidden to inline? ie., it is marked with + * the <CODE>NoInline</CODE> annotation or the <CODE>NoOptCompile</CODE> + * annotation? */ public final boolean hasNoInlinePragma() { return (hasNoInlineAnnotation() || hasNoOptCompileAnnotation()); @@ -502,70 +552,81 @@ * @return true if the method may write to a given field */ public boolean mayWrite(VM_Field field) { - return true; // be conservative. native methods can write to anything + return true; // be conservative. native methods can write to anything } /** - * @return true if the method is the implementation of a runtime service - * that is called "under the covers" from the generated code and thus is not subject to - * inlining via the normal mechanisms. + * @return true if the method is the implementation of a runtime service that + * is called "under the covers" from the generated code and thus is + * not subject to inlining via the normal mechanisms. */ public boolean isRuntimeServiceMethod() { - return false; // only VM_NormalMethods can be runtime service impls in Jikes RVM and they override this method + return false; // only VM_NormalMethods can be runtime service impls in Jikes + // RVM and they override this method } - //------------------------------------------------------------------// - // 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". // + // ------------------------------------------------------------------// /** - * Get the code array that corresponds to the entry point (prologue) for the method. + * Get the code array that corresponds to the entry point (prologue) for the + * method. */ public final synchronized VM_CodeArray getCurrentEntryCodeArray() { VM_Class declaringClass = getDeclaringClass(); - if (VM.VerifyAssertions) VM._assert(declaringClass.isResolved()); + if (VM.VerifyAssertions) + VM._assert(declaringClass.isResolved()); if (isCompiled()) { return currentCompiledMethod.getEntryCodeArray(); } else if (!VM.writingBootImage || isNative()) { if (!isStatic() && !isObjectInitializer() && !isPrivate()) { // A non-private virtual method. - if (declaringClass.isJavaLangObjectType() || - declaringClass.getSuperClass().findVirtualMethod(getName(), getDescriptor()) == null) { - // The root method of a virtual method family can use the lazy method invoker directly. - return VM_Entrypoints.lazyMethodInvokerMethod.getCurrentEntryCodeArray(); + if (declaringClass.isJavaLangObjectType() + || declaringClass.getSuperClass().findVirtualMethod(getName(), + getDescriptor()) == null) { + // The root method of a virtual method family can use the lazy method + // invoker directly. + return VM_Entrypoints.lazyMethodInvokerMethod + .getCurrentEntryCodeArray(); } else { - // All other virtual methods in the family must generate unique stubs to - // ensure correct operation of the method test (guarded inlining of virtual calls). + // All other virtual methods in the family must generate unique stubs + // to + // ensure correct operation of the method test (guarded inlining of + // virtual calls). return VM_LazyCompilationTrampolineGenerator.getTrampoline(); } } else { // We'll never do a method test against this method. // Therefore we can use the lazy method invoker directly. - return VM_Entrypoints.lazyMethodInvokerMethod.getCurrentEntryCodeArray(); + return VM_Entrypoints.lazyMethodInvokerMethod + .getCurrentEntryCodeArray(); } } else { - compile(); + compile(); return currentCompiledMethod.getEntryCodeArray(); } } /** - * Generate machine code for this method if valid - * machine code doesn't already exist. - * Return the resulting VM_CompiledMethod object. + * Generate machine code for this method if valid machine code doesn't already + * exist. Return the resulting VM_CompiledMethod object. */ public final synchronized void compile() { - if (VM.VerifyAssertions) VM._assert(getDeclaringClass().isResolved()); - if (isCompiled()) return; + if (VM.VerifyAssertions) + VM._assert(getDeclaringClass().isResolved()); + if (isCompiled()) + return; - if (VM.TraceClassLoading && VM.runningVM) VM.sysWrite("VM_Method: (begin) compiling " + this + "\n"); + if (VM.TraceClassLoading && VM.runningVM) + VM.sysWrite("VM_Method: (begin) compiling " + this + "\n"); VM_CompiledMethod cm = genCode(); // Ensure that cm wasn't invalidated while it was being compiled. - synchronized(cm) { + synchronized (cm) { if (cm.isInvalid()) { VM_CompiledMethods.setCompiledMethodObsolete(cm); } else { @@ -573,34 +634,40 @@ } } - if (VM.TraceClassLoading && VM.runningVM) VM.sysWrite("VM_Method: (end) compiling " + this + "\n"); + if (VM.TraceClassLoading && VM.runningVM) + VM.sysWrite("VM_Method: (end) compiling " + this + "\n"); } protected abstract VM_CompiledMethod genCode(); - //----------------------------------------------------------------// - // Section 3. // - // The following are available after the declaring class has been // - // "instantiated". // - //----------------------------------------------------------------// + // ----------------------------------------------------------------// + // Section 3. // + // The following are available after the declaring class has been // + // "instantiated". // + // ----------------------------------------------------------------// /** - * Change machine code that will be used by future executions of this method + * Change machine code that will be used by future executions of this method * (ie. optimized <-> non-optimized) - * @param compiledMethod new machine code - * Side effect: updates jtoc or method dispatch tables - * ("type information blocks") - * for this class and its subclasses - */ - public synchronized void replaceCompiledMethod(VM_CompiledMethod compiledMethod) { - if (VM.VerifyAssertions) VM._assert(getDeclaringClass().isInstantiated()); - // If we're replacing with a non-null compiledMethod, ensure that is still valid! + * + * @param compiledMethod + * new machine code Side effect: updates jtoc or method dispatch + * tables ("type information blocks") for this class and its + * subclasses + */ + public synchronized void replaceCompiledMethod( + VM_CompiledMethod compiledMethod) { + if (VM.VerifyAssertions) + VM._assert(getDeclaringClass().isInstantiated()); + // If we're replacing with a non-null compiledMethod, ensure that is still + // valid! if (compiledMethod != null) { - synchronized(compiledMethod) { - if (compiledMethod.isInvalid()) return; + synchronized (compiledMethod) { + if (compiledMethod.isInvalid()) + return; } } - + // Grab version that is being replaced VM_CompiledMethod oldCompiledMethod = currentCompiledMethod; currentCompiledMethod = compiledMethod; @@ -610,7 +677,7 @@ getDeclaringClass().updateMethod(this); // Replace constant-ified virtual method in JTOC if necessary - if(jtocOffset.toInt() != -1) { + if (jtocOffset.toInt() != -1) { VM_Statics.setSlotContents(jtocOffset, getCurrentEntryCodeArray()); } @@ -621,10 +688,11 @@ } /** - * If CM is the current compiled code for this, then invaldiate it. + * If CM is the current compiled code for this, then invaldiate it. */ public final synchronized void invalidateCompiledMethod(VM_CompiledMethod cm) { - if (VM.VerifyAssertions) VM._assert(getDeclaringClass().isInstantiated()); + if (VM.VerifyAssertions) + VM._assert(getDeclaringClass().isInstantiated()); if (currentCompiledMethod == cm) { replaceCompiledMethod(null); } @@ -634,8 +702,9 @@ * Find or create a jtoc offset for this method */ public final synchronized Offset findOrCreateJtocOffset() { - if (VM.VerifyAssertions) VM._assert(!isStatic() && !isObjectInitializer()); - if(jtocOffset.EQ(Offset.zero())) { + if (VM.VerifyAssertions) + VM._assert(!isStatic() && !isObjectInitializer()); + if (jtocOffset.EQ(Offset.zero())) { jtocOffset = VM_Statics.allocateReferenceSlot(); VM_Statics.setSlotContents(jtocOffset, getCurrentEntryCodeArray()); } Modified: ext/org/jikesrvm/classloader/VM_NormalMethod.java =================================================================== --- ext/org/jikesrvm/classloader/VM_NormalMethod.java 2007-03-31 14:04:36 UTC (rev 16) +++ ext/org/jikesrvm/classloader/VM_NormalMethod.java 2007-03-31 22:03:22 UTC (rev 17) @@ -17,80 +17,103 @@ /** * A method of a java class that has bytecodes. - * + * * @author Bowen Alpern * @author Stephen Fink * @author Dave Grove * @author Derek Lieber * @modified Ian Rogers */ -public class VM_NormalMethod - extends VM_Method - implements VM_BytecodeConstants -{ +public class VM_NormalMethod extends VM_Method implements VM_BytecodeConstants { - /* As we read the bytecodes for the method, we compute - * a simple summary of some interesting properties of the method. - * Because we do this for every method, we require the summarization to - * be fast and the computed summary to be very space efficient. + /* + * As we read the bytecodes for the method, we compute a simple summary of + * some interesting properties of the method. Because we do this for every + * method, we require the summarization to be fast and the computed summary to + * be very space efficient. * - * The following constants encode the estimated relative cost in - * machine instructions when a particular class of bytecode is compiled - * by the optimizing compiler. The estimates approximate the typical - * optimization the compiler is able to perform. - * This information is used to estimate how big a method will be when - * it is inlined. + * The following constants encode the estimated relative cost in machine + * instructions when a particular class of bytecode is compiled by the + * optimizing compiler. The estimates approximate the typical optimization the + * compiler is able to perform. This information is used to estimate how big a + * method will be when it is inlined. */ public static final int SIMPLE_OPERATION_COST = 1; + public static final int LONG_OPERATION_COST = 2; + public static final int ARRAY_LOAD_COST = 2; + public static final int ARRAY_STORE_COST = 2; + public static final int JSR_COST = 5; + public static final int CALL_COST = 6; + // Bias to inlining methods with magic // most magics are quite cheap (0-1 instructions) public static final int MAGIC_COST = 0; + // News are actually more expensive than calls // but bias to inline methods that allocate - // objects becuase we expect better downstream optimization of + // objects becuase we expect better downstream optimization of // the caller due to class analysis // and propagation of nonNullness public static final int ALLOCATION_COST = 4; + // Approximations, assuming some CSE/PRE of object model computations - public static final int CLASS_CHECK_COST = 2*SIMPLE_OPERATION_COST; - public static final int STORE_CHECK_COST = 4*SIMPLE_OPERATION_COST; + public static final int CLASS_CHECK_COST = 2 * SIMPLE_OPERATION_COST; + + public static final int STORE_CHECK_COST = 4 * SIMPLE_OPERATION_COST; + // Just a call. public static final int THROW_COST = CALL_COST; + // Really a bunch of operations plus a call, but undercharge because // we don't have worry about this causing an exponential growth of call chain - // and we probably want to inline synchronization + // and we probably want to inline synchronization // (to get a chance to optimize it). - public static final int SYNCH_COST = 4*SIMPLE_OPERATION_COST; - // The additional cost of a switch isn't that large, since if the - // switch has more than a few cases the method will be too big to inline + public static final int SYNCH_COST = 4 * SIMPLE_OPERATION_COST; + + // The additional cost of a switch isn't that large, since if the + // switch has more than a few cases the method will be too big to inline // anyways. public static final int SWITCH_COST = CALL_COST; // Definition of flag bits - protected static final char HAS_MAGIC = 0x8000; - protected static final char HAS_SYNCH = 0x4000; + protected static final char HAS_MAGIC = 0x8000; + + protected static final char HAS_SYNCH = 0x4000; + protected static final char HAS_ALLOCATION = 0x2000; - protected static final char HAS_THROW = 0x1000; - protected static final char HAS_INVOKE = 0x0800; + + protected static final char HAS_THROW = 0x1000; + + protected static final char HAS_INVOKE = 0x0800; + protected static final char HAS_FIELD_READ = 0x0400; - protected static final char HAS_FIELD_WRITE= 0x0200; + + protected static final char HAS_FIELD_WRITE = 0x0200; + protected static final char HAS_ARRAY_READ = 0x0100; - protected static final char HAS_ARRAY_WRITE= 0x0080; - protected static final char HAS_JSR = 0x0040; - protected static final char HAS_COND_BRANCH= 0x0020; - protected static final char HAS_SWITCH = 0x0010; - protected static final char HAS_BACK_BRANCH= 0x0008; - protected static final char IS_RS_METHOD = 0x0004; - + + protected static final char HAS_ARRAY_WRITE = 0x0080; + + protected static final char HAS_JSR = 0x0040; + + protected static final char HAS_COND_BRANCH = 0x0020; + + protected static final char HAS_SWITCH = 0x0010; + + protected static final char HAS_BACK_BRANCH = 0x0008; + + protected static final char IS_RS_METHOD = 0x0004; + /** * storage for bytecode summary flags */ protected char summaryFlags; + /** * storage for bytecode summary size */ @@ -99,68 +122,83 @@ /** * words needed for local variables (including parameters) */ - private final short localWords; + private final short localWords; /** - * words needed for operand stack (high water mark) - * TODO: OSR redesign; add subclass of NormalMethod for OSR method - * and then make this field final in NormalMethod. + * words needed for operand stack (high water mark) TODO: OSR redesign; add + * subclass of NormalMethod for OSR method and then make this field final in + * NormalMethod. */ - private short operandWords; + private short operandWords; /** * bytecodes for this method (null --> none) */ - public final byte[] bytecodes; + public final byte[] bytecodes; /** * try/catch/finally blocks for this method (null --> none) */ - private final VM_ExceptionHandlerMap exceptionHandlerMap; + private final VM_ExceptionHandlerMap exceptionHandlerMap; /** - * pc to source-line info (null --> none) - * Each entry contains both the line number (upper 16 bits) - * and corresponding start PC (lower 16 bits). + * pc to source-line info (null --> none) Each entry contains both the line + * number (upper 16 bits) and corresponding start PC (lower 16 bits). */ - private final int[] lineNumberMap; + private final int[] lineNumberMap; // Extra fields for on-stack replacement - // TODO: rework the system so we don't waste space for this on the VM_Method object + //... [truncated message content] |