# HG changeset patch # User Thomas Wuerthinger # Date 1339257683 -7200 # Node ID e42c0df7212a26bef272b53c85506ff20998b737 # Parent 65f832e7476bc728766c3c124695bafc5467bff9 Rename CiTargetMethod => CompilationResult. diff -r 65f832e7476b -r e42c0df7212a graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CiTargetMethod.java --- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CiTargetMethod.java Sat Jun 09 17:54:50 2012 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,555 +0,0 @@ -/* - * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.graal.api.code; - -import java.io.*; -import java.util.*; - -import com.oracle.graal.api.meta.*; - -/** - * Represents the output from compiling a method, including the compiled machine code, associated data and references, - * relocation information, deoptimization information, etc. It is the essential component of a {@link CiResult}, which also includes - * {@linkplain CiStatistics compilation statistics} and {@linkplain CiBailout failure information}. - */ -public class CiTargetMethod implements Serializable { - - private static final long serialVersionUID = -1319947729753702434L; - - /** - * Represents a code position with associated additional information. - */ - public abstract static class Site implements Serializable { - private static final long serialVersionUID = -8214214947651979102L; - /** - * The position (or offset) of this site with respect to the start of the target method. - */ - public final int pcOffset; - - public Site(int pos) { - this.pcOffset = pos; - } - } - - /** - * Represents a safepoint with associated debug info. - */ - public static class Safepoint extends Site implements Comparable { - private static final long serialVersionUID = 2479806696381720162L; - public final CiDebugInfo debugInfo; - - Safepoint(int pcOffset, CiDebugInfo debugInfo) { - super(pcOffset); - this.debugInfo = debugInfo; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append(pcOffset); - sb.append("[]"); - appendDebugInfo(sb, debugInfo); - return sb.toString(); - } - - @Override - public int compareTo(Safepoint o) { - if (pcOffset < o.pcOffset) { - return -1; - } else if (pcOffset > o.pcOffset) { - return 1; - } - return 0; - } - } - - /** - * Represents a call in the code. - */ - public static final class Call extends Safepoint { - private static final long serialVersionUID = 1440741241631046954L; - - /** - * The target of the call. - */ - public final Object target; - - /** - * The size of the call instruction. - */ - public final int size; - - /** - * Specifies if this call is direct or indirect. A direct call has an immediate operand encoding - * the absolute or relative (to the call itself) address of the target. An indirect call has a - * register or memory operand specifying the target address of the call. - */ - public final boolean direct; - - Call(Object target, int pcOffset, int size, boolean direct, CiDebugInfo debugInfo) { - super(pcOffset, debugInfo); - this.size = size; - this.target = target; - this.direct = direct; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append(pcOffset); - sb.append('['); - sb.append(target); - sb.append(']'); - - if (debugInfo != null) { - appendDebugInfo(sb, debugInfo); - } - - return sb.toString(); - } - } - - /** - * Represents a reference to data from the code. The associated data can be any constant. - */ - public static final class DataPatch extends Site { - private static final long serialVersionUID = 5771730331604867476L; - public final Constant constant; - public final int alignment; - - DataPatch(int pcOffset, Constant data, int alignment) { - super(pcOffset); - this.constant = data; - this.alignment = alignment; - } - - @Override - public String toString() { - return String.format("%d[]", pcOffset, constant); - } - } - - /** - * Provides extra information about instructions or data at specific positions in {@link CiTargetMethod#targetCode()}. - * This is optional information that can be used to enhance a disassembly of the code. - */ - public abstract static class CodeAnnotation implements Serializable { - private static final long serialVersionUID = -7903959680749520748L; - public final int position; - - public CodeAnnotation(int position) { - this.position = position; - } - } - - /** - * A string comment about one or more instructions at a specific position in the code. - */ - public static final class CodeComment extends CodeAnnotation { - /** - * - */ - private static final long serialVersionUID = 6802287188701961401L; - public final String value; - public CodeComment(int position, String comment) { - super(position); - this.value = comment; - } - - @Override - public String toString() { - return getClass().getSimpleName() + "@" + position + ": " + value; - } - } - - /** - * Labels some inline data in the code. - */ - public static final class InlineData extends CodeAnnotation { - private static final long serialVersionUID = 305997507263827108L; - public final int size; - public InlineData(int position, int size) { - super(position); - this.size = size; - } - - @Override - public String toString() { - return getClass().getSimpleName() + "@" + position + ": size=" + size; - } - } - - /** - * Describes a table of signed offsets embedded in the code. The offsets are relative to the starting - * address of the table. This type of table maybe generated when translating a multi-way branch - * based on a key value from a dense value set (e.g. the {@code tableswitch} JVM instruction). - * - * The table is indexed by the contiguous range of integers from {@link #low} to {@link #high} inclusive. - */ - public static final class JumpTable extends CodeAnnotation { - private static final long serialVersionUID = 2222194398353801831L; - - /** - * The low value in the key range (inclusive). - */ - public final int low; - - /** - * The high value in the key range (inclusive). - */ - public final int high; - - /** - * The size (in bytes) of each table entry. - */ - public final int entrySize; - - public JumpTable(int position, int low, int high, int entrySize) { - super(position); - this.low = low; - this.high = high; - this.entrySize = entrySize; - } - - @Override - public String toString() { - return getClass().getSimpleName() + "@" + position + ": [" + low + " .. " + high + "]"; - } - } - - /** - * Describes a table of key and offset pairs. The offset in each table entry is relative to the address of - * the table. This type of table maybe generated when translating a multi-way branch - * based on a key value from a sparse value set (e.g. the {@code lookupswitch} JVM instruction). - */ - public static final class LookupTable extends CodeAnnotation { - private static final long serialVersionUID = 8367952567559116160L; - - /** - * The number of entries in the table. - */ - public final int npairs; - - /** - * The size (in bytes) of entry's key. - */ - public final int keySize; - - /** - * The size (in bytes) of entry's offset value. - */ - public final int offsetSize; - - public LookupTable(int position, int npairs, int keySize, int offsetSize) { - super(position); - this.npairs = npairs; - this.keySize = keySize; - this.offsetSize = offsetSize; - } - - @Override - public String toString() { - return getClass().getSimpleName() + "@" + position + ": [npairs=" + npairs + ", keySize=" + keySize + ", offsetSize=" + offsetSize + "]"; - } - } - - /** - * Represents exception handler information for a specific code position. It includes the catch code position as - * well as the caught exception type. - */ - public static final class ExceptionHandler extends Site { - private static final long serialVersionUID = 4897339464722665281L; - public final int handlerPos; - - ExceptionHandler(int pcOffset, int handlerPos) { - super(pcOffset); - this.handlerPos = handlerPos; - } - - @Override - public String toString() { - return String.format("%d[]", pcOffset, handlerPos); - } - } - - public static final class Mark extends Site { - private static final long serialVersionUID = 3612943150662354844L; - public final Object id; - public final Mark[] references; - - Mark(int pcOffset, Object id, Mark[] references) { - super(pcOffset); - this.id = id; - this.references = references; - } - - @Override - public String toString() { - if (id == null) { - return String.format("%d[]", pcOffset, references.length); - } else if (id instanceof Integer) { - return String.format("%d[]", pcOffset, references.length, Integer.toHexString((Integer) id)); - } else { - return String.format("%d[]", pcOffset, references.length, id.toString()); - } - } - } - - /** - * List of safepoints, sorted by {@link Site#pcOffset}. - */ - public final List safepoints = new ArrayList<>(); - - /** - * List of data references. - */ - public final List dataReferences = new ArrayList<>(); - - /** - * List of exception handlers. - */ - public final List exceptionHandlers = new ArrayList<>(); - - /** - * List of marks. - */ - public final List marks = new ArrayList<>(); - - private int frameSize = -1; - private int customStackAreaOffset = -1; - private int registerRestoreEpilogueOffset = -1; - /** - * The buffer containing the emitted machine code. - */ - private byte[] targetCode; - - /** - * The leading number of bytes in {@link #targetCode} containing the emitted machine code. - */ - private int targetCodeSize; - - private ArrayList annotations; - - private CiAssumptions assumptions; - - /** - * Constructs a new target method. - */ - public CiTargetMethod() { - } - - public void setAssumptions(CiAssumptions assumptions) { - this.assumptions = assumptions; - } - - public CiAssumptions assumptions() { - return assumptions; - } - - /** - * Sets the frame size in bytes. Does not include the return address pushed onto the - * stack, if any. - * - * @param size the size of the frame in bytes - */ - public void setFrameSize(int size) { - frameSize = size; - } - - /** - * Sets the machine that has been generated by the compiler. - * - * @param code the machine code generated - * @param size the size of the machine code - */ - public void setTargetCode(byte[] code, int size) { - targetCode = code; - targetCodeSize = size; - } - - /** - * Records a reference to the data section in the code section (e.g. to load an integer or floating point constant). - * - * @param codePos the position in the code where the data reference occurs - * @param data the data that is referenced - * @param alignment the alignment requirement of the data or 0 if there is no alignment requirement - */ - public void recordDataReference(int codePos, Constant data, int alignment) { - assert codePos >= 0 && data != null; - dataReferences.add(new DataPatch(codePos, data, alignment)); - } - - /** - * Records a call in the code array. - * - * @param codePos the position of the call in the code array - * @param size the size of the call instruction - * @param target the {@link CodeCacheProvider#asCallTarget(Object) target} being called - * @param debugInfo the debug info for the call - * @param direct specifies if this is a {@linkplain Call#direct direct} call - */ - public void recordCall(int codePos, int size, Object target, CiDebugInfo debugInfo, boolean direct) { - final Call call = new Call(target, codePos, size, direct, debugInfo); - addSafepoint(call); - } - - /** - * Records an exception handler for this method. - * - * @param codePos the position in the code that is covered by the handler - * @param handlerPos the position of the handler - * @param throwableType the type of exceptions handled by the handler - */ - public void recordExceptionHandler(int codePos, int handlerPos) { - exceptionHandlers.add(new ExceptionHandler(codePos, handlerPos)); - } - - /** - * Records a safepoint in the code array. - * - * @param codePos the position of the safepoint in the code array - * @param debugInfo the debug info for the safepoint - */ - public void recordSafepoint(int codePos, CiDebugInfo debugInfo) { - addSafepoint(new Safepoint(codePos, debugInfo)); - } - - private void addSafepoint(Safepoint safepoint) { - // The safepoints list must always be sorted - if (!safepoints.isEmpty() && safepoints.get(safepoints.size() - 1).pcOffset >= safepoint.pcOffset) { - // This re-sorting should be very rare - Collections.sort(safepoints); - } - safepoints.add(safepoint); - } - - /** - * Records an instruction mark within this method. - * - * @param codePos the position in the code that is covered by the handler - * @param id the identifier for this mark - * @param references an array of other marks that this mark references - */ - public Mark recordMark(int codePos, Object id, Mark[] references) { - Mark mark = new Mark(codePos, id, references); - marks.add(mark); - return mark; - } - - /** - * Allows a method to specify the offset of the epilogue that restores the callee saved registers. Must be called - * iff the method is a callee saved method and stores callee registers on the stack. - * - * @param registerRestoreEpilogueOffset the offset in the machine code where the epilogue begins - */ - public void setRegisterRestoreEpilogueOffset(int registerRestoreEpilogueOffset) { - assert this.registerRestoreEpilogueOffset == -1; - this.registerRestoreEpilogueOffset = registerRestoreEpilogueOffset; - } - - /** - * The frame size of the method in bytes. - * - * @return the frame size - */ - public int frameSize() { - assert frameSize != -1 : "frame size not yet initialized!"; - return frameSize; - } - - /** - * @return the code offset of the start of the epilogue that restores all callee saved registers, or -1 if this is - * not a callee saved method - */ - public int registerRestoreEpilogueOffset() { - return registerRestoreEpilogueOffset; - } - - /** - * Offset in bytes for the custom stack area (relative to sp). - * @return the offset in bytes - */ - public int customStackAreaOffset() { - return customStackAreaOffset; - } - - /** - * @see #customStackAreaOffset() - * @param offset - */ - public void setCustomStackAreaOffset(int offset) { - customStackAreaOffset = offset; - } - - /** - * @return the machine code generated for this method - */ - public byte[] targetCode() { - return targetCode; - } - - /** - * @return the size of the machine code generated for this method - */ - public int targetCodeSize() { - return targetCodeSize; - } - - /** - * @return the code annotations or {@code null} if there are none - */ - public List annotations() { - return annotations; - } - - public void addAnnotation(CodeAnnotation annotation) { - assert annotation != null; - if (annotations == null) { - annotations = new ArrayList<>(); - } - annotations.add(annotation); - } - - private static void appendDebugInfo(StringBuilder sb, CiDebugInfo info) { - if (info != null) { - appendRefMap(sb, "stackMap", info.frameRefMap); - appendRefMap(sb, "registerMap", info.registerRefMap); - CiCodePos codePos = info.codePos; - if (codePos != null) { - CiUtil.appendLocation(sb.append(" "), codePos.method, codePos.bci); - if (info.hasFrame()) { - sb.append(" #locals=").append(info.frame().numLocals).append(" #expr=").append(info.frame().numStack); - if (info.frame().numLocks > 0) { - sb.append(" #locks=").append(info.frame().numLocks); - } - } - } - } - } - - private static void appendRefMap(StringBuilder sb, String name, BitSet map) { - if (map != null) { - sb.append(' ').append(name).append('[').append(map.toString()).append(']'); - } - } -} diff -r 65f832e7476b -r e42c0df7212a graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CodeCacheProvider.java --- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CodeCacheProvider.java Sat Jun 09 17:54:50 2012 +0200 +++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CodeCacheProvider.java Sat Jun 09 18:01:23 2012 +0200 @@ -41,7 +41,7 @@ * @param code the code that should be disassembled * @return a disassembly. This will be of length 0 if the runtime does not support disassembling. */ - String disassemble(CodeInfo code, CiTargetMethod tm); + String disassemble(CodeInfo code, CompilationResult tm); /** * Returns the disassembly of the given method in a {@code javap}-like format. @@ -92,7 +92,7 @@ * Ignored if null, otherwise the info is written to index 0 of this array. * @return a reference to the compiled and ready-to-run code */ - InstalledCode addMethod(ResolvedJavaMethod method, CiTargetMethod code, CodeInfo[] info); + InstalledCode addMethod(ResolvedJavaMethod method, CompilationResult code, CodeInfo[] info); /** * Encodes a deoptimization action and a deoptimization reason in an integer value. diff -r 65f832e7476b -r e42c0df7212a graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CompilationResult.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CompilationResult.java Sat Jun 09 18:01:23 2012 +0200 @@ -0,0 +1,555 @@ +/* + * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.api.code; + +import java.io.*; +import java.util.*; + +import com.oracle.graal.api.meta.*; + +/** + * Represents the output from compiling a method, including the compiled machine code, associated data and references, + * relocation information, deoptimization information, etc. It is the essential component of a {@link CiResult}, which also includes + * {@linkplain CiStatistics compilation statistics} and {@linkplain CiBailout failure information}. + */ +public class CompilationResult implements Serializable { + + private static final long serialVersionUID = -1319947729753702434L; + + /** + * Represents a code position with associated additional information. + */ + public abstract static class Site implements Serializable { + private static final long serialVersionUID = -8214214947651979102L; + /** + * The position (or offset) of this site with respect to the start of the target method. + */ + public final int pcOffset; + + public Site(int pos) { + this.pcOffset = pos; + } + } + + /** + * Represents a safepoint with associated debug info. + */ + public static class Safepoint extends Site implements Comparable { + private static final long serialVersionUID = 2479806696381720162L; + public final CiDebugInfo debugInfo; + + Safepoint(int pcOffset, CiDebugInfo debugInfo) { + super(pcOffset); + this.debugInfo = debugInfo; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append(pcOffset); + sb.append("[]"); + appendDebugInfo(sb, debugInfo); + return sb.toString(); + } + + @Override + public int compareTo(Safepoint o) { + if (pcOffset < o.pcOffset) { + return -1; + } else if (pcOffset > o.pcOffset) { + return 1; + } + return 0; + } + } + + /** + * Represents a call in the code. + */ + public static final class Call extends Safepoint { + private static final long serialVersionUID = 1440741241631046954L; + + /** + * The target of the call. + */ + public final Object target; + + /** + * The size of the call instruction. + */ + public final int size; + + /** + * Specifies if this call is direct or indirect. A direct call has an immediate operand encoding + * the absolute or relative (to the call itself) address of the target. An indirect call has a + * register or memory operand specifying the target address of the call. + */ + public final boolean direct; + + Call(Object target, int pcOffset, int size, boolean direct, CiDebugInfo debugInfo) { + super(pcOffset, debugInfo); + this.size = size; + this.target = target; + this.direct = direct; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append(pcOffset); + sb.append('['); + sb.append(target); + sb.append(']'); + + if (debugInfo != null) { + appendDebugInfo(sb, debugInfo); + } + + return sb.toString(); + } + } + + /** + * Represents a reference to data from the code. The associated data can be any constant. + */ + public static final class DataPatch extends Site { + private static final long serialVersionUID = 5771730331604867476L; + public final Constant constant; + public final int alignment; + + DataPatch(int pcOffset, Constant data, int alignment) { + super(pcOffset); + this.constant = data; + this.alignment = alignment; + } + + @Override + public String toString() { + return String.format("%d[]", pcOffset, constant); + } + } + + /** + * Provides extra information about instructions or data at specific positions in {@link CompilationResult#targetCode()}. + * This is optional information that can be used to enhance a disassembly of the code. + */ + public abstract static class CodeAnnotation implements Serializable { + private static final long serialVersionUID = -7903959680749520748L; + public final int position; + + public CodeAnnotation(int position) { + this.position = position; + } + } + + /** + * A string comment about one or more instructions at a specific position in the code. + */ + public static final class CodeComment extends CodeAnnotation { + /** + * + */ + private static final long serialVersionUID = 6802287188701961401L; + public final String value; + public CodeComment(int position, String comment) { + super(position); + this.value = comment; + } + + @Override + public String toString() { + return getClass().getSimpleName() + "@" + position + ": " + value; + } + } + + /** + * Labels some inline data in the code. + */ + public static final class InlineData extends CodeAnnotation { + private static final long serialVersionUID = 305997507263827108L; + public final int size; + public InlineData(int position, int size) { + super(position); + this.size = size; + } + + @Override + public String toString() { + return getClass().getSimpleName() + "@" + position + ": size=" + size; + } + } + + /** + * Describes a table of signed offsets embedded in the code. The offsets are relative to the starting + * address of the table. This type of table maybe generated when translating a multi-way branch + * based on a key value from a dense value set (e.g. the {@code tableswitch} JVM instruction). + * + * The table is indexed by the contiguous range of integers from {@link #low} to {@link #high} inclusive. + */ + public static final class JumpTable extends CodeAnnotation { + private static final long serialVersionUID = 2222194398353801831L; + + /** + * The low value in the key range (inclusive). + */ + public final int low; + + /** + * The high value in the key range (inclusive). + */ + public final int high; + + /** + * The size (in bytes) of each table entry. + */ + public final int entrySize; + + public JumpTable(int position, int low, int high, int entrySize) { + super(position); + this.low = low; + this.high = high; + this.entrySize = entrySize; + } + + @Override + public String toString() { + return getClass().getSimpleName() + "@" + position + ": [" + low + " .. " + high + "]"; + } + } + + /** + * Describes a table of key and offset pairs. The offset in each table entry is relative to the address of + * the table. This type of table maybe generated when translating a multi-way branch + * based on a key value from a sparse value set (e.g. the {@code lookupswitch} JVM instruction). + */ + public static final class LookupTable extends CodeAnnotation { + private static final long serialVersionUID = 8367952567559116160L; + + /** + * The number of entries in the table. + */ + public final int npairs; + + /** + * The size (in bytes) of entry's key. + */ + public final int keySize; + + /** + * The size (in bytes) of entry's offset value. + */ + public final int offsetSize; + + public LookupTable(int position, int npairs, int keySize, int offsetSize) { + super(position); + this.npairs = npairs; + this.keySize = keySize; + this.offsetSize = offsetSize; + } + + @Override + public String toString() { + return getClass().getSimpleName() + "@" + position + ": [npairs=" + npairs + ", keySize=" + keySize + ", offsetSize=" + offsetSize + "]"; + } + } + + /** + * Represents exception handler information for a specific code position. It includes the catch code position as + * well as the caught exception type. + */ + public static final class ExceptionHandler extends Site { + private static final long serialVersionUID = 4897339464722665281L; + public final int handlerPos; + + ExceptionHandler(int pcOffset, int handlerPos) { + super(pcOffset); + this.handlerPos = handlerPos; + } + + @Override + public String toString() { + return String.format("%d[]", pcOffset, handlerPos); + } + } + + public static final class Mark extends Site { + private static final long serialVersionUID = 3612943150662354844L; + public final Object id; + public final Mark[] references; + + Mark(int pcOffset, Object id, Mark[] references) { + super(pcOffset); + this.id = id; + this.references = references; + } + + @Override + public String toString() { + if (id == null) { + return String.format("%d[]", pcOffset, references.length); + } else if (id instanceof Integer) { + return String.format("%d[]", pcOffset, references.length, Integer.toHexString((Integer) id)); + } else { + return String.format("%d[]", pcOffset, references.length, id.toString()); + } + } + } + + /** + * List of safepoints, sorted by {@link Site#pcOffset}. + */ + public final List safepoints = new ArrayList<>(); + + /** + * List of data references. + */ + public final List dataReferences = new ArrayList<>(); + + /** + * List of exception handlers. + */ + public final List exceptionHandlers = new ArrayList<>(); + + /** + * List of marks. + */ + public final List marks = new ArrayList<>(); + + private int frameSize = -1; + private int customStackAreaOffset = -1; + private int registerRestoreEpilogueOffset = -1; + /** + * The buffer containing the emitted machine code. + */ + private byte[] targetCode; + + /** + * The leading number of bytes in {@link #targetCode} containing the emitted machine code. + */ + private int targetCodeSize; + + private ArrayList annotations; + + private CiAssumptions assumptions; + + /** + * Constructs a new target method. + */ + public CompilationResult() { + } + + public void setAssumptions(CiAssumptions assumptions) { + this.assumptions = assumptions; + } + + public CiAssumptions assumptions() { + return assumptions; + } + + /** + * Sets the frame size in bytes. Does not include the return address pushed onto the + * stack, if any. + * + * @param size the size of the frame in bytes + */ + public void setFrameSize(int size) { + frameSize = size; + } + + /** + * Sets the machine that has been generated by the compiler. + * + * @param code the machine code generated + * @param size the size of the machine code + */ + public void setTargetCode(byte[] code, int size) { + targetCode = code; + targetCodeSize = size; + } + + /** + * Records a reference to the data section in the code section (e.g. to load an integer or floating point constant). + * + * @param codePos the position in the code where the data reference occurs + * @param data the data that is referenced + * @param alignment the alignment requirement of the data or 0 if there is no alignment requirement + */ + public void recordDataReference(int codePos, Constant data, int alignment) { + assert codePos >= 0 && data != null; + dataReferences.add(new DataPatch(codePos, data, alignment)); + } + + /** + * Records a call in the code array. + * + * @param codePos the position of the call in the code array + * @param size the size of the call instruction + * @param target the {@link CodeCacheProvider#asCallTarget(Object) target} being called + * @param debugInfo the debug info for the call + * @param direct specifies if this is a {@linkplain Call#direct direct} call + */ + public void recordCall(int codePos, int size, Object target, CiDebugInfo debugInfo, boolean direct) { + final Call call = new Call(target, codePos, size, direct, debugInfo); + addSafepoint(call); + } + + /** + * Records an exception handler for this method. + * + * @param codePos the position in the code that is covered by the handler + * @param handlerPos the position of the handler + * @param throwableType the type of exceptions handled by the handler + */ + public void recordExceptionHandler(int codePos, int handlerPos) { + exceptionHandlers.add(new ExceptionHandler(codePos, handlerPos)); + } + + /** + * Records a safepoint in the code array. + * + * @param codePos the position of the safepoint in the code array + * @param debugInfo the debug info for the safepoint + */ + public void recordSafepoint(int codePos, CiDebugInfo debugInfo) { + addSafepoint(new Safepoint(codePos, debugInfo)); + } + + private void addSafepoint(Safepoint safepoint) { + // The safepoints list must always be sorted + if (!safepoints.isEmpty() && safepoints.get(safepoints.size() - 1).pcOffset >= safepoint.pcOffset) { + // This re-sorting should be very rare + Collections.sort(safepoints); + } + safepoints.add(safepoint); + } + + /** + * Records an instruction mark within this method. + * + * @param codePos the position in the code that is covered by the handler + * @param id the identifier for this mark + * @param references an array of other marks that this mark references + */ + public Mark recordMark(int codePos, Object id, Mark[] references) { + Mark mark = new Mark(codePos, id, references); + marks.add(mark); + return mark; + } + + /** + * Allows a method to specify the offset of the epilogue that restores the callee saved registers. Must be called + * iff the method is a callee saved method and stores callee registers on the stack. + * + * @param registerRestoreEpilogueOffset the offset in the machine code where the epilogue begins + */ + public void setRegisterRestoreEpilogueOffset(int registerRestoreEpilogueOffset) { + assert this.registerRestoreEpilogueOffset == -1; + this.registerRestoreEpilogueOffset = registerRestoreEpilogueOffset; + } + + /** + * The frame size of the method in bytes. + * + * @return the frame size + */ + public int frameSize() { + assert frameSize != -1 : "frame size not yet initialized!"; + return frameSize; + } + + /** + * @return the code offset of the start of the epilogue that restores all callee saved registers, or -1 if this is + * not a callee saved method + */ + public int registerRestoreEpilogueOffset() { + return registerRestoreEpilogueOffset; + } + + /** + * Offset in bytes for the custom stack area (relative to sp). + * @return the offset in bytes + */ + public int customStackAreaOffset() { + return customStackAreaOffset; + } + + /** + * @see #customStackAreaOffset() + * @param offset + */ + public void setCustomStackAreaOffset(int offset) { + customStackAreaOffset = offset; + } + + /** + * @return the machine code generated for this method + */ + public byte[] targetCode() { + return targetCode; + } + + /** + * @return the size of the machine code generated for this method + */ + public int targetCodeSize() { + return targetCodeSize; + } + + /** + * @return the code annotations or {@code null} if there are none + */ + public List annotations() { + return annotations; + } + + public void addAnnotation(CodeAnnotation annotation) { + assert annotation != null; + if (annotations == null) { + annotations = new ArrayList<>(); + } + annotations.add(annotation); + } + + private static void appendDebugInfo(StringBuilder sb, CiDebugInfo info) { + if (info != null) { + appendRefMap(sb, "stackMap", info.frameRefMap); + appendRefMap(sb, "registerMap", info.registerRefMap); + CiCodePos codePos = info.codePos; + if (codePos != null) { + CiUtil.appendLocation(sb.append(" "), codePos.method, codePos.bci); + if (info.hasFrame()) { + sb.append(" #locals=").append(info.frame().numLocals).append(" #expr=").append(info.frame().numStack); + if (info.frame().numLocks > 0) { + sb.append(" #locks=").append(info.frame().numLocks); + } + } + } + } + } + + private static void appendRefMap(StringBuilder sb, String name, BitSet map) { + if (map != null) { + sb.append(' ').append(name).append('[').append(map.toString()).append(']'); + } + } +} diff -r 65f832e7476b -r e42c0df7212a graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/package-info.java --- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/package-info.java Sat Jun 09 17:54:50 2012 +0200 +++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/package-info.java Sat Jun 09 18:01:23 2012 +0200 @@ -29,7 +29,7 @@ *

* A {@code CiResult} encapsulates * {@linkplain com.oracle.max.cri.ci.CiStatistics compilation statistics}, possible {@linkplain com.oracle.graal.api.code.CiBailout error state} - * and the {@linkplain com.oracle.graal.api.code.CiTargetMethod compiled code and metadata}. + * and the {@linkplain com.oracle.graal.api.code.CompilationResult compiled code and metadata}. * {@link com.oracle.graal.api.code.CiCodePos} and {@link com.oracle.graal.api.code.CiDebugInfo} provide detailed information to the * runtime to support debugging and deoptimization of the compiled code. *

diff -r 65f832e7476b -r e42c0df7212a graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java Sat Jun 09 17:54:50 2012 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java Sat Jun 09 18:01:23 2012 +0200 @@ -74,14 +74,14 @@ } - public CiTargetMethod compileMethod(final ResolvedJavaMethod method, final StructuredGraph graph, int osrBCI, final RiGraphCache cache, final PhasePlan plan, final OptimisticOptimizations optimisticOpts) { + public CompilationResult compileMethod(final ResolvedJavaMethod method, final StructuredGraph graph, int osrBCI, final RiGraphCache cache, final PhasePlan plan, final OptimisticOptimizations optimisticOpts) { assert (method.accessFlags() & Modifier.NATIVE) == 0 : "compiling native methods is not supported"; if (osrBCI != -1) { throw new CiBailout("No OSR supported"); } - return Debug.scope("GraalCompiler", new Object[] {graph, method, this}, new Callable() { - public CiTargetMethod call() { + return Debug.scope("GraalCompiler", new Object[] {graph, method, this}, new Callable() { + public CompilationResult call() { final CiAssumptions assumptions = GraalOptions.OptAssumptions ? new CiAssumptions() : null; final LIR lir = Debug.scope("FrontEnd", new Callable() { public LIR call() { @@ -93,8 +93,8 @@ return emitLIR(lir, graph, method, assumptions); } }); - return Debug.scope("CodeGen", frameMap, new Callable() { - public CiTargetMethod call() { + return Debug.scope("CodeGen", frameMap, new Callable() { + public CompilationResult call() { return emitCode(assumptions, method, lir, frameMap); } }); @@ -262,10 +262,10 @@ return frameMap; } - public CiTargetMethod emitCode(CiAssumptions assumptions, ResolvedJavaMethod method, LIR lir, FrameMap frameMap) { + public CompilationResult emitCode(CiAssumptions assumptions, ResolvedJavaMethod method, LIR lir, FrameMap frameMap) { TargetMethodAssembler tasm = backend.newAssembler(frameMap, lir); backend.emitCode(tasm, method, lir); - CiTargetMethod targetMethod = tasm.finishTargetMethod(method, false); + CompilationResult targetMethod = tasm.finishTargetMethod(method, false); if (assumptions != null && !assumptions.isEmpty()) { targetMethod.setAssumptions(assumptions); } diff -r 65f832e7476b -r e42c0df7212a graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java Sat Jun 09 17:54:50 2012 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java Sat Jun 09 18:01:23 2012 +0200 @@ -30,7 +30,7 @@ import java.util.Map.Entry; import com.oracle.graal.api.code.*; -import com.oracle.graal.api.code.CiTargetMethod.*; +import com.oracle.graal.api.code.CompilationResult.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.api.meta.JavaType.*; import com.oracle.graal.compiler.*; diff -r 65f832e7476b -r e42c0df7212a graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/amd64/AMD64LIRGenerator.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/amd64/AMD64LIRGenerator.java Sat Jun 09 17:54:50 2012 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/amd64/AMD64LIRGenerator.java Sat Jun 09 18:01:23 2012 +0200 @@ -35,7 +35,7 @@ import com.oracle.max.cri.xir.CiXirAssembler.XirMark; import com.oracle.max.cri.xir.*; import com.oracle.graal.api.code.*; -import com.oracle.graal.api.code.CiTargetMethod.*; +import com.oracle.graal.api.code.CompilationResult.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.gen.*; import com.oracle.graal.compiler.target.*; diff -r 65f832e7476b -r e42c0df7212a graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/amd64/AMD64XirOp.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/amd64/AMD64XirOp.java Sat Jun 09 17:54:50 2012 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/amd64/AMD64XirOp.java Sat Jun 09 18:01:23 2012 +0200 @@ -29,7 +29,7 @@ import java.util.*; import com.oracle.graal.api.code.*; -import com.oracle.graal.api.code.CiTargetMethod.*; +import com.oracle.graal.api.code.CompilationResult.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.graph.*; import com.oracle.graal.lir.*; diff -r 65f832e7476b -r e42c0df7212a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java Sat Jun 09 17:54:50 2012 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java Sat Jun 09 18:01:23 2012 +0200 @@ -108,13 +108,13 @@ TTY.println(String.format("%-6d Graal %-70s %-45s %-50s ...", id, method.holder().name(), method.name(), method.signature().asString())); } - CiTargetMethod result = null; + CompilationResult result = null; TTY.Filter filter = new TTY.Filter(GraalOptions.PrintFilter, method); try { - result = Debug.scope("Compiling", new DebugDumpScope(String.valueOf(id), true), new Callable() { + result = Debug.scope("Compiling", new DebugDumpScope(String.valueOf(id), true), new Callable() { @Override - public CiTargetMethod call() throws Exception { + public CompilationResult call() throws Exception { compiler.evictDeoptedGraphs(); StructuredGraph graph = new StructuredGraph(method); return compiler.getCompiler().compileMethod(method, graph, -1, compiler.getCache(), plan, optimisticOpts); @@ -147,7 +147,7 @@ stats.finish(method); } - private void installMethod(final CiTargetMethod tm) { + private void installMethod(final CompilationResult tm) { Debug.scope("CodeInstall", new Object[] {new DebugDumpScope(String.valueOf(id), true), compiler.getCompiler(), method}, new Runnable() { @Override public void run() { diff -r 65f832e7476b -r e42c0df7212a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotTargetMethod.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotTargetMethod.java Sat Jun 09 17:54:50 2012 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotTargetMethod.java Sat Jun 09 18:01:23 2012 +0200 @@ -25,7 +25,7 @@ import java.util.*; import com.oracle.graal.api.code.*; -import com.oracle.graal.api.code.CiTargetMethod.*; +import com.oracle.graal.api.code.CompilationResult.*; import com.oracle.graal.hotspot.logging.*; import com.oracle.graal.hotspot.ri.*; @@ -35,14 +35,14 @@ public final class HotSpotTargetMethod extends CompilerObject { private static final long serialVersionUID = 7807321392203253218L; - public final CiTargetMethod targetMethod; + public final CompilationResult targetMethod; public final HotSpotMethodResolved method; // used only for methods public final String name; // used only for stubs public final Site[] sites; public final ExceptionHandler[] exceptionHandlers; - public HotSpotTargetMethod(HotSpotMethodResolved method, CiTargetMethod targetMethod) { + public HotSpotTargetMethod(HotSpotMethodResolved method, CompilationResult targetMethod) { this.method = method; this.targetMethod = targetMethod; this.name = null; @@ -55,7 +55,7 @@ } } - private static Site[] getSortedSites(CiTargetMethod target) { + private static Site[] getSortedSites(CompilationResult target) { List[] lists = new List[] {target.safepoints, target.dataReferences, target.marks}; int count = 0; for (List list : lists) { diff -r 65f832e7476b -r e42c0df7212a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/ri/HotSpotCodeInfo.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/ri/HotSpotCodeInfo.java Sat Jun 09 17:54:50 2012 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/ri/HotSpotCodeInfo.java Sat Jun 09 18:01:23 2012 +0200 @@ -35,10 +35,10 @@ private long start; private byte[] code; - public final CiTargetMethod targetMethod; + public final CompilationResult targetMethod; private HotSpotMethodResolved method; - public HotSpotCodeInfo(CiTargetMethod targetMethod, HotSpotMethodResolved method) { + public HotSpotCodeInfo(CompilationResult targetMethod, HotSpotMethodResolved method) { assert targetMethod != null; this.method = method; this.targetMethod = targetMethod; diff -r 65f832e7476b -r e42c0df7212a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/ri/HotSpotRuntime.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/ri/HotSpotRuntime.java Sat Jun 09 17:54:50 2012 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/ri/HotSpotRuntime.java Sat Jun 09 18:01:23 2012 +0200 @@ -28,7 +28,7 @@ import java.util.*; import com.oracle.graal.api.code.*; -import com.oracle.graal.api.code.CiTargetMethod.*; +import com.oracle.graal.api.code.CompilationResult.*; import com.oracle.graal.api.code.CiUtil.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.api.meta.JavaType.*; @@ -81,7 +81,7 @@ } @Override - public String disassemble(CodeInfo info, CiTargetMethod tm) { + public String disassemble(CodeInfo info, CompilationResult tm) { byte[] code = info.code(); CiTarget target = compiler.getTarget(); HexCodeFile hcf = new HexCodeFile(code, info.start(), target.arch.name, target.wordSize * 8); @@ -152,11 +152,11 @@ return "MARK:" + mark.id; } - private static void addExceptionHandlersComment(CiTargetMethod tm, HexCodeFile hcf) { + private static void addExceptionHandlersComment(CompilationResult tm, HexCodeFile hcf) { if (!tm.exceptionHandlers.isEmpty()) { String nl = HexCodeFile.NEW_LINE; StringBuilder buf = new StringBuilder("------ Exception Handlers ------").append(nl); - for (CiTargetMethod.ExceptionHandler e : tm.exceptionHandlers) { + for (CompilationResult.ExceptionHandler e : tm.exceptionHandlers) { buf.append(" "). append(e.pcOffset).append(" -> "). append(e.handlerPos). @@ -465,7 +465,7 @@ return (ResolvedJavaMethod) compiler.getCompilerToVM().getRiMethod(reflectionMethod); } - private static HotSpotCodeInfo makeInfo(ResolvedJavaMethod method, CiTargetMethod code, CodeInfo[] info) { + private static HotSpotCodeInfo makeInfo(ResolvedJavaMethod method, CompilationResult code, CodeInfo[] info) { HotSpotCodeInfo hsInfo = null; if (info != null && info.length > 0) { hsInfo = new HotSpotCodeInfo(code, (HotSpotMethodResolved) method); @@ -474,13 +474,13 @@ return hsInfo; } - public void installMethod(ResolvedJavaMethod method, CiTargetMethod code, CodeInfo[] info) { + public void installMethod(ResolvedJavaMethod method, CompilationResult code, CodeInfo[] info) { HotSpotCodeInfo hsInfo = makeInfo(method, code, info); compiler.getCompilerToVM().installMethod(new HotSpotTargetMethod((HotSpotMethodResolved) method, code), true, hsInfo); } @Override - public InstalledCode addMethod(ResolvedJavaMethod method, CiTargetMethod code, CodeInfo[] info) { + public InstalledCode addMethod(ResolvedJavaMethod method, CompilationResult code, CodeInfo[] info) { HotSpotCodeInfo hsInfo = makeInfo(method, code, info); return compiler.getCompilerToVM().installMethod(new HotSpotTargetMethod((HotSpotMethodResolved) method, code), false, hsInfo); } @@ -491,7 +491,7 @@ } @Override - public CiTargetMethod compile(ResolvedJavaMethod method, StructuredGraph graph) { + public CompilationResult compile(ResolvedJavaMethod method, StructuredGraph graph) { OptimisticOptimizations optimisticOpts = OptimisticOptimizations.ALL; return compiler.getCompiler().compileMethod(method, graph, -1, compiler.getCache(), compiler.getVMToCompiler().createPhasePlan(optimisticOpts), optimisticOpts); } diff -r 65f832e7476b -r e42c0df7212a graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Call.java --- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Call.java Sat Jun 09 17:54:50 2012 +0200 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Call.java Sat Jun 09 18:01:23 2012 +0200 @@ -29,7 +29,7 @@ import com.oracle.max.asm.target.amd64.*; import com.oracle.max.cri.xir.CiXirAssembler.XirMark; import com.oracle.graal.api.code.*; -import com.oracle.graal.api.code.CiTargetMethod.*; +import com.oracle.graal.api.code.CompilationResult.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.graph.*; import com.oracle.graal.lir.*; diff -r 65f832e7476b -r e42c0df7212a graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64ControlFlow.java --- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64ControlFlow.java Sat Jun 09 17:54:50 2012 +0200 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64ControlFlow.java Sat Jun 09 18:01:23 2012 +0200 @@ -31,7 +31,7 @@ import com.oracle.max.asm.target.amd64.AMD64Assembler.ConditionFlag; import com.oracle.graal.api.code.*; import com.oracle.graal.api.code.CiAddress.*; -import com.oracle.graal.api.code.CiTargetMethod.*; +import com.oracle.graal.api.code.CompilationResult.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.graph.*; import com.oracle.graal.lir.*; diff -r 65f832e7476b -r e42c0df7212a graal/com.oracle.graal.lir/src/com/oracle/graal/lir/FrameMap.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/FrameMap.java Sat Jun 09 17:54:50 2012 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/FrameMap.java Sat Jun 09 18:01:23 2012 +0200 @@ -72,7 +72,7 @@ *
* A runtime has two ways to reserve space in the stack frame for its own use:

    *
  • A memory block somewhere in the frame of size {@link CodeCacheProvider#getCustomStackAreaSize()}. The offset - * to this block is returned in {@link CiTargetMethod#customStackAreaOffset()}. + * to this block is returned in {@link CompilationResult#customStackAreaOffset()}. *
  • At the beginning of the overflow argument area: The calling convention can specify that the first * overflow stack argument is not at offset 0, but at a specified offset o. Use * {@link CodeCacheProvider#getMinimumOutgoingSize()} to make sure that call-free methods also have this space diff -r 65f832e7476b -r e42c0df7212a graal/com.oracle.graal.lir/src/com/oracle/graal/lir/asm/TargetMethodAssembler.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/asm/TargetMethodAssembler.java Sat Jun 09 17:54:50 2012 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/asm/TargetMethodAssembler.java Sat Jun 09 18:01:23 2012 +0200 @@ -47,7 +47,7 @@ } public final AbstractAssembler asm; - public final CiTargetMethod targetMethod; + public final CompilationResult targetMethod; public final CiTarget target; public final CodeCacheProvider runtime; public final FrameMap frameMap; @@ -72,7 +72,7 @@ this.frameMap = frameMap; this.stubs = stubs; this.asm = asm; - this.targetMethod = new CiTargetMethod(); + this.targetMethod = new CompilationResult(); this.frameContext = frameContext; // 0 is a valid pc for safepoints in template methods this.lastSafepointPos = -1; @@ -82,19 +82,19 @@ targetMethod.setFrameSize(frameSize); } - public CiTargetMethod.Mark recordMark(Object id) { + public CompilationResult.Mark recordMark(Object id) { return targetMethod.recordMark(asm.codeBuffer.position(), id, null); } - public CiTargetMethod.Mark recordMark(Object id, CiTargetMethod.Mark[] references) { + public CompilationResult.Mark recordMark(Object id, CompilationResult.Mark[] references) { return targetMethod.recordMark(asm.codeBuffer.position(), id, references); } public void blockComment(String s) { - targetMethod.addAnnotation(new CiTargetMethod.CodeComment(asm.codeBuffer.position(), s)); + targetMethod.addAnnotation(new CompilationResult.CodeComment(asm.codeBuffer.position(), s)); } - public CiTargetMethod finishTargetMethod(Object name, boolean isStub) { + public CompilationResult finishTargetMethod(Object name, boolean isStub) { // Install code, data and frame size targetMethod.setTargetCode(asm.codeBuffer.close(false), asm.codeBuffer.position()); diff -r 65f832e7476b -r e42c0df7212a graal/com.oracle.graal.nodes/src/com/oracle/graal/cri/ExtendedRiRuntime.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/cri/ExtendedRiRuntime.java Sat Jun 09 17:54:50 2012 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/cri/ExtendedRiRuntime.java Sat Jun 09 18:01:23 2012 +0200 @@ -38,6 +38,6 @@ StructuredGraph intrinsicGraph(ResolvedJavaMethod caller, int bci, ResolvedJavaMethod method, List parameters); - CiTargetMethod compile(ResolvedJavaMethod method, StructuredGraph graph); + CompilationResult compile(ResolvedJavaMethod method, StructuredGraph graph); } diff -r 65f832e7476b -r e42c0df7212a graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CFGPrinterObserver.java --- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CFGPrinterObserver.java Sat Jun 09 17:54:50 2012 +0200 +++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CFGPrinterObserver.java Sat Jun 09 18:01:23 2012 +0200 @@ -137,8 +137,8 @@ } cfgPrinter.printCFG(message, Arrays.asList(cfgPrinter.cfg.getBlocks())); - } else if (object instanceof CiTargetMethod) { - final CiTargetMethod tm = (CiTargetMethod) object; + } else if (object instanceof CompilationResult) { + final CompilationResult tm = (CompilationResult) object; final byte[] code = Arrays.copyOf(tm.targetCode(), tm.targetCodeSize()); CodeInfo info = new CodeInfo() { public ResolvedJavaMethod method() { diff -r 65f832e7476b -r e42c0df7212a graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/GraphTest.java --- a/graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/GraphTest.java Sat Jun 09 17:54:50 2012 +0200 +++ b/graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/GraphTest.java Sat Jun 09 18:01:23 2012 +0200 @@ -150,13 +150,13 @@ protected InstalledCode compile(final ResolvedJavaMethod method, final StructuredGraph graph) { return Debug.scope("Compiling", new DebugDumpScope(String.valueOf(compilationId++), true), new Callable() { public InstalledCode call() throws Exception { - CiTargetMethod targetMethod = runtime.compile(method, graph); + CompilationResult targetMethod = runtime.compile(method, graph); return addMethod(method, targetMethod); } }); } - protected InstalledCode addMethod(final ResolvedJavaMethod method, final CiTargetMethod tm) { + protected InstalledCode addMethod(final ResolvedJavaMethod method, final CompilationResult tm) { return Debug.scope("CodeInstall", new Object[] {method}, new Callable() { @Override public InstalledCode call() throws Exception { diff -r 65f832e7476b -r e42c0df7212a graal/com.oracle.max.cri/src/com/oracle/max/cri/xir/XirSnippet.java --- a/graal/com.oracle.max.cri/src/com/oracle/max/cri/xir/XirSnippet.java Sat Jun 09 17:54:50 2012 +0200 +++ b/graal/com.oracle.max.cri/src/com/oracle/max/cri/xir/XirSnippet.java Sat Jun 09 18:01:23 2012 +0200 @@ -24,7 +24,7 @@ import java.util.*; -import com.oracle.graal.api.code.CiTargetMethod.*; +import com.oracle.graal.api.code.CompilationResult.*; import com.oracle.graal.api.meta.*; import com.oracle.max.cri.xir.CiXirAssembler.*; diff -r 65f832e7476b -r e42c0df7212a graal/com.oracle.max.criutils/src/com/oracle/max/criutils/HexCodeFile.java --- a/graal/com.oracle.max.criutils/src/com/oracle/max/criutils/HexCodeFile.java Sat Jun 09 17:54:50 2012 +0200 +++ b/graal/com.oracle.max.criutils/src/com/oracle/max/criutils/HexCodeFile.java Sat Jun 09 18:01:23 2012 +0200 @@ -28,7 +28,7 @@ import java.util.regex.*; import com.oracle.graal.api.code.*; -import com.oracle.graal.api.code.CiTargetMethod.*; +import com.oracle.graal.api.code.CompilationResult.*; /** diff -r 65f832e7476b -r e42c0df7212a src/share/vm/classfile/vmSymbols.hpp --- a/src/share/vm/classfile/vmSymbols.hpp Sat Jun 09 17:54:50 2012 +0200 +++ b/src/share/vm/classfile/vmSymbols.hpp Sat Jun 09 18:01:23 2012 +0200 @@ -293,13 +293,13 @@ template(com_oracle_max_cri_ci_CiAssumptions_ConcreteSubtype, "com/oracle/graal/api/code/CiAssumptions$ConcreteSubtype") \ template(com_oracle_max_cri_ci_CiAssumptions_ConcreteMethod, "com/oracle/graal/api/code/CiAssumptions$ConcreteMethod") \ template(com_oracle_max_cri_ci_CiGenericCallback, "com/oracle/graal/api/code/CiGenericCallback") \ - template(com_oracle_max_cri_ci_CiTargetMethod, "com/oracle/graal/api/code/CiTargetMethod") \ - template(com_oracle_max_cri_ci_CiTargetMethod_Site, "com/oracle/graal/api/code/CiTargetMethod$Site") \ - template(com_oracle_max_cri_ci_CiTargetMethod_Call, "com/oracle/graal/api/code/CiTargetMethod$Call") \ - template(com_oracle_max_cri_ci_CiTargetMethod_DataPatch, "com/oracle/graal/api/code/CiTargetMethod$DataPatch") \ - template(com_oracle_max_cri_ci_CiTargetMethod_Safepoint, "com/oracle/graal/api/code/CiTargetMethod$Safepoint") \ - template(com_oracle_max_cri_ci_CiTargetMethod_ExceptionHandler, "com/oracle/graal/api/code/CiTargetMethod$ExceptionHandler") \ - template(com_oracle_max_cri_ci_CiTargetMethod_Mark, "com/oracle/graal/api/code/CiTargetMethod$Mark") \ + template(com_oracle_max_cri_ci_CiTargetMethod, "com/oracle/graal/api/code/CompilationResult") \ + template(com_oracle_max_cri_ci_CiTargetMethod_Site, "com/oracle/graal/api/code/CompilationResult$Site") \ + template(com_oracle_max_cri_ci_CiTargetMethod_Call, "com/oracle/graal/api/code/CompilationResult$Call") \ + template(com_oracle_max_cri_ci_CiTargetMethod_DataPatch, "com/oracle/graal/api/code/CompilationResult$DataPatch") \ + template(com_oracle_max_cri_ci_CiTargetMethod_Safepoint, "com/oracle/graal/api/code/CompilationResult$Safepoint") \ + template(com_oracle_max_cri_ci_CiTargetMethod_ExceptionHandler, "com/oracle/graal/api/code/CompilationResult$ExceptionHandler") \ + template(com_oracle_max_cri_ci_CiTargetMethod_Mark, "com/oracle/graal/api/code/CompilationResult$Mark") \ template(com_oracle_max_cri_ci_CiBitMap, "java/util/BitSet") \ template(com_oracle_max_cri_ci_CiDebugInfo, "com/oracle/graal/api/code/CiDebugInfo") \ template(com_oracle_max_cri_ci_CiFrame, "com/oracle/graal/api/code/CiFrame") \ diff -r 65f832e7476b -r e42c0df7212a src/share/vm/graal/graalJavaAccess.hpp --- a/src/share/vm/graal/graalJavaAccess.hpp Sat Jun 09 17:54:50 2012 +0200 +++ b/src/share/vm/graal/graalJavaAccess.hpp Sat Jun 09 18:01:23 2012 +0200 @@ -95,11 +95,11 @@ static_oop_field(HotSpotProxy, DUMMY_CONSTANT_OBJ, "Ljava/lang/Long;") \ end_class \ start_class(HotSpotTargetMethod) \ - oop_field(HotSpotTargetMethod, targetMethod, "Lcom/oracle/graal/api/code/CiTargetMethod;") \ + oop_field(HotSpotTargetMethod, targetMethod, "Lcom/oracle/graal/api/code/CompilationResult;") \ oop_field(HotSpotTargetMethod, method, "Lcom/oracle/graal/hotspot/ri/HotSpotMethodResolved;") \ oop_field(HotSpotTargetMethod, name, "Ljava/lang/String;") \ - oop_field(HotSpotTargetMethod, sites, "[Lcom/oracle/graal/api/code/CiTargetMethod$Site;") \ - oop_field(HotSpotTargetMethod, exceptionHandlers, "[Lcom/oracle/graal/api/code/CiTargetMethod$ExceptionHandler;") \ + oop_field(HotSpotTargetMethod, sites, "[Lcom/oracle/graal/api/code/CompilationResult$Site;") \ + oop_field(HotSpotTargetMethod, exceptionHandlers, "[Lcom/oracle/graal/api/code/CompilationResult$ExceptionHandler;") \ end_class \ start_class(HotSpotExceptionHandler) \ int_field(HotSpotExceptionHandler, startBCI) \ @@ -149,7 +149,7 @@ end_class \ start_class(CiTargetMethod_Mark) \ oop_field(CiTargetMethod_Mark, id, "Ljava/lang/Object;") \ - oop_field(CiTargetMethod_Mark, references, "[Lcom/oracle/graal/api/code/CiTargetMethod$Mark;") \ + oop_field(CiTargetMethod_Mark, references, "[Lcom/oracle/graal/api/code/CompilationResult$Mark;") \ end_class \ start_class(CiDebugInfo) \ oop_field(CiDebugInfo, codePos, "Lcom/oracle/graal/api/code/CiCodePos;") \