8147599: [JVMCI] simplify code installation interface
authorrschatz
Wed, 20 Jan 2016 14:22:46 +0100
changeset 35582 c32a0cc19877
parent 35581 dd47cf4734f2
child 35583 3e83096ee8e5
8147599: [JVMCI] simplify code installation interface Reviewed-by: twisti
hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.code/src/jdk/vm/ci/code/CodeCacheProvider.java
hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.code/src/jdk/vm/ci/code/CompilationResult.java
hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.code/src/jdk/vm/ci/code/CompiledCode.java
hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.code/src/jdk/vm/ci/code/DataSection.java
hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.code/src/jdk/vm/ci/code/InfopointReason.java
hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.code/src/jdk/vm/ci/code/package-info.java
hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.code/src/jdk/vm/ci/code/site/Call.java
hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.code/src/jdk/vm/ci/code/site/ConstantReference.java
hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.code/src/jdk/vm/ci/code/site/DataPatch.java
hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.code/src/jdk/vm/ci/code/site/DataSectionReference.java
hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.code/src/jdk/vm/ci/code/site/ExceptionHandler.java
hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.code/src/jdk/vm/ci/code/site/Infopoint.java
hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.code/src/jdk/vm/ci/code/site/InfopointReason.java
hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.code/src/jdk/vm/ci/code/site/Mark.java
hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.code/src/jdk/vm/ci/code/site/Reference.java
hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.code/src/jdk/vm/ci/code/site/Site.java
hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCodeCacheProvider.java
hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCompiledCode.java
hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCompiledNmethod.java
hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java
hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMEventListener.java
hotspot/src/share/vm/jvmci/jvmciCodeInstaller.cpp
hotspot/src/share/vm/jvmci/jvmciCodeInstaller.hpp
hotspot/src/share/vm/jvmci/jvmciJavaClasses.hpp
hotspot/src/share/vm/jvmci/systemDictionary_jvmci.hpp
hotspot/src/share/vm/jvmci/vmSymbols_jvmci.hpp
hotspot/test/compiler/jvmci/code/CodeInstallationTest.java
hotspot/test/compiler/jvmci/code/DataPatchTest.java
hotspot/test/compiler/jvmci/code/TestAssembler.java
hotspot/test/compiler/jvmci/code/amd64/AMD64TestAssembler.java
hotspot/test/compiler/jvmci/code/sparc/SPARCTestAssembler.java
hotspot/test/compiler/jvmci/errors/CodeInstallerTest.java
hotspot/test/compiler/jvmci/errors/TestInvalidCompilationResult.java
hotspot/test/compiler/jvmci/errors/TestInvalidDebugInfo.java
hotspot/test/compiler/jvmci/errors/TestInvalidOopMap.java
hotspot/test/compiler/jvmci/events/JvmciNotifyInstallEventTest.java
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.code/src/jdk/vm/ci/code/CodeCacheProvider.java	Wed Jan 20 16:33:51 2016 +0100
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.code/src/jdk/vm/ci/code/CodeCacheProvider.java	Wed Jan 20 14:22:46 2016 +0100
@@ -22,11 +22,8 @@
  */
 package jdk.vm.ci.code;
 
-import jdk.vm.ci.code.CompilationResult.Call;
-import jdk.vm.ci.code.CompilationResult.DataPatch;
-import jdk.vm.ci.code.CompilationResult.Mark;
-import jdk.vm.ci.code.DataSection.Data;
-import jdk.vm.ci.meta.Constant;
+import jdk.vm.ci.code.site.Call;
+import jdk.vm.ci.code.site.Mark;
 import jdk.vm.ci.meta.ResolvedJavaMethod;
 import jdk.vm.ci.meta.SpeculationLog;
 
@@ -40,7 +37,7 @@
      * default implementation of the method.
      *
      * @param method a method implemented by the installed code
-     * @param compResult the compilation result to be added
+     * @param compiledCode the compiled code to be added
      * @param log the speculation log to be used
      * @param installedCode a predefined {@link InstalledCode} object to use as a reference to the
      *            installed code. If {@code null}, a new {@link InstalledCode} object will be
@@ -48,8 +45,8 @@
      * @return a reference to the ready-to-run code
      * @throws BailoutException if the code installation failed
      */
-    default InstalledCode addCode(ResolvedJavaMethod method, CompilationResult compResult, SpeculationLog log, InstalledCode installedCode) {
-        return installCode(new CompilationRequest(method), compResult, installedCode, log, false);
+    default InstalledCode addCode(ResolvedJavaMethod method, CompiledCode compiledCode, SpeculationLog log, InstalledCode installedCode) {
+        return installCode(method, compiledCode, installedCode, log, false);
     }
 
     /**
@@ -58,21 +55,20 @@
      *
      * @param method a method implemented by the installed code and for which the installed code
      *            becomes the default implementation
-     * @param compResult the compilation result to be added
+     * @param compiledCode the compiled code to be added
      * @return a reference to the ready-to-run code
      * @throws BailoutException if the code installation failed
      */
-    default InstalledCode setDefaultCode(ResolvedJavaMethod method, CompilationResult compResult) {
-        return installCode(new CompilationRequest(method), compResult, null, null, true);
+    default InstalledCode setDefaultCode(ResolvedJavaMethod method, CompiledCode compiledCode) {
+        return installCode(method, compiledCode, null, null, true);
     }
 
     /**
      * Installs code based on a given compilation result.
      *
-     * @param compRequest details of the method compiled to produce {@code compResult} or
-     *            {@code null} if the input to {@code compResult} was not a
-     *            {@link ResolvedJavaMethod}
-     * @param compResult the compilation result to be added
+     * @param method the method compiled to produce {@code compiledCode} or {@code null} if the
+     *            input to {@code compResult} was not a {@link ResolvedJavaMethod}
+     * @param compiledCode the compiled code to be added
      * @param installedCode a pre-allocated {@link InstalledCode} object to use as a reference to
      *            the installed code. If {@code null}, a new {@link InstalledCode} object will be
      *            created.
@@ -84,7 +80,7 @@
      * @return a reference to the compiled and ready-to-run installed code
      * @throws BailoutException if the code installation failed
      */
-    InstalledCode installCode(CompilationRequest compRequest, CompilationResult compResult, InstalledCode installedCode, SpeculationLog log, boolean isDefault);
+    InstalledCode installCode(ResolvedJavaMethod method, CompiledCode compiledCode, InstalledCode installedCode, SpeculationLog log, boolean isDefault);
 
     /**
      * Invalidates {@code installedCode} such that {@link InvalidInstalledCodeException} will be
@@ -121,13 +117,6 @@
     int getMinimumOutgoingSize();
 
     /**
-     * Create a {@link Data} item for one or more {@link Constant Constants}, that can be used in a
-     * {@link DataPatch}. If more than one {@link Constant} is given, then they are tightly packed
-     * into a single {@link Data} item.
-     */
-    Data createDataItem(Constant... constants);
-
-    /**
      * Gets a description of the target architecture.
      */
     TargetDescription getTarget();
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.code/src/jdk/vm/ci/code/CompilationResult.java	Wed Jan 20 16:33:51 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1078 +0,0 @@
-/*
- * Copyright (c) 2009, 2014, 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 jdk.vm.ci.code;
-
-import static java.util.Collections.emptyList;
-import static java.util.Collections.unmodifiableList;
-import static jdk.vm.ci.meta.MetaUtil.identityHashCodeString;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-
-import jdk.vm.ci.meta.Assumptions.Assumption;
-import jdk.vm.ci.meta.InvokeTarget;
-import jdk.vm.ci.meta.JavaConstant;
-import jdk.vm.ci.meta.MetaUtil;
-import jdk.vm.ci.meta.ResolvedJavaMethod;
-import jdk.vm.ci.meta.VMConstant;
-
-/**
- * Represents the output from compiling a method, including the compiled machine code, associated
- * data and references, relocation information, deoptimization information, etc.
- */
-public class CompilationResult {
-
-    /**
-     * Represents a code position with associated additional information.
-     */
-    public abstract static class Site {
-
-        /**
-         * 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;
-        }
-
-        @Override
-        public final int hashCode() {
-            throw new UnsupportedOperationException("hashCode");
-        }
-
-        @Override
-        public String toString() {
-            return identityHashCodeString(this);
-        }
-
-        @Override
-        public abstract boolean equals(Object obj);
-    }
-
-    /**
-     * Represents an infopoint with associated debug info. Note that safepoints are also infopoints.
-     */
-    public static class Infopoint extends Site implements Comparable<Infopoint> {
-
-        public final DebugInfo debugInfo;
-
-        public final InfopointReason reason;
-
-        public Infopoint(int pcOffset, DebugInfo debugInfo, InfopointReason reason) {
-            super(pcOffset);
-            this.debugInfo = debugInfo;
-            this.reason = reason;
-        }
-
-        @Override
-        public String toString() {
-            StringBuilder sb = new StringBuilder();
-            sb.append(pcOffset);
-            sb.append("[<infopoint>]");
-            appendDebugInfo(sb, debugInfo);
-            return sb.toString();
-        }
-
-        @Override
-        public int compareTo(Infopoint o) {
-            if (pcOffset < o.pcOffset) {
-                return -1;
-            } else if (pcOffset > o.pcOffset) {
-                return 1;
-            }
-            return this.reason.compareTo(o.reason);
-        }
-
-        @Override
-        public boolean equals(Object obj) {
-            if (this == obj) {
-                return true;
-            }
-            if (obj != null && obj.getClass() == getClass()) {
-                Infopoint that = (Infopoint) obj;
-                if (this.pcOffset == that.pcOffset && Objects.equals(this.debugInfo, that.debugInfo) && Objects.equals(this.reason, that.reason)) {
-                    return true;
-                }
-            }
-            return false;
-        }
-    }
-
-    public enum MetaSpaceAccessType {
-        Move,
-        Store,  // store only works for compressed oops (memory <- 32bit value). Compressed oops is
-        // not supported using AOT. TODO: Look at HotSpotStoreConstantOp
-        Compare; // HotSpotCompareMemoryConstantOp, HotSpotCompareConstantOp
-
-        private MetaSpaceAccessType() {
-        }
-    }
-
-    /**
-     * Represents a meta space pointer access in the code.
-     */
-    public static final class MetaSpaceAccess extends Infopoint {
-
-        /**
-         * Metaspace reference.
-         */
-        public final Object reference; // Object here is a HotSpotResolvedObjectType or a
-        // HotSpotMetaSpaceConstant
-
-        public final MetaSpaceAccessType type;
-
-        /**
-         * Instruction size.
-         */
-        public final int instructionSize;
-
-        public MetaSpaceAccess(Object reference, int instructionSize, MetaSpaceAccessType type, int pcOffset, DebugInfo debugInfo) {
-            super(pcOffset, debugInfo, InfopointReason.METASPACE_ACCESS);
-            this.type = type;
-            this.reference = reference;
-            this.instructionSize = instructionSize;
-        }
-    }
-
-    /**
-     * Represents a call in the code.
-     */
-    public static final class Call extends Infopoint {
-
-        /**
-         * The target of the call.
-         */
-        public final InvokeTarget 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;
-
-        public Call(InvokeTarget target, int pcOffset, int size, boolean direct, DebugInfo debugInfo) {
-            super(pcOffset, debugInfo, InfopointReason.CALL);
-            this.size = size;
-            this.target = target;
-            this.direct = direct;
-        }
-
-        @Override
-        public boolean equals(Object obj) {
-            if (this == obj) {
-                return true;
-            }
-            if (obj instanceof Call && super.equals(obj)) {
-                Call that = (Call) obj;
-                if (this.size == that.size && this.direct == that.direct && Objects.equals(this.target, that.target)) {
-                    return true;
-                }
-            }
-            return false;
-        }
-
-        @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 some external data that is referenced by the code.
-     */
-    public abstract static class Reference {
-
-        @Override
-        public abstract int hashCode();
-
-        @Override
-        public abstract boolean equals(Object obj);
-    }
-
-    public static final class ConstantReference extends Reference {
-
-        private final VMConstant constant;
-
-        public ConstantReference(VMConstant constant) {
-            this.constant = constant;
-        }
-
-        public VMConstant getConstant() {
-            return constant;
-        }
-
-        @Override
-        public String toString() {
-            return constant.toString();
-        }
-
-        @Override
-        public int hashCode() {
-            return constant.hashCode();
-        }
-
-        @Override
-        public boolean equals(Object obj) {
-            if (this == obj) {
-                return true;
-            }
-            if (obj instanceof ConstantReference) {
-                ConstantReference that = (ConstantReference) obj;
-                return Objects.equals(this.constant, that.constant);
-            }
-            return false;
-        }
-    }
-
-    public static final class DataSectionReference extends Reference {
-
-        private boolean initialized;
-        private int offset;
-
-        public DataSectionReference() {
-            // will be set after the data section layout is fixed
-            offset = 0xDEADDEAD;
-        }
-
-        public int getOffset() {
-            assert initialized;
-
-            return offset;
-        }
-
-        public void setOffset(int offset) {
-            assert !initialized;
-            initialized = true;
-
-            this.offset = offset;
-        }
-
-        @Override
-        public int hashCode() {
-            return offset;
-        }
-
-        @Override
-        public boolean equals(Object obj) {
-            if (this == obj) {
-                return true;
-            }
-            if (obj instanceof DataSectionReference) {
-                DataSectionReference that = (DataSectionReference) obj;
-                return this.offset == that.offset;
-            }
-            return false;
-        }
-
-        @Override
-        public String toString() {
-            if (initialized) {
-                return String.format("DataSection[0x%x]", offset);
-            } else {
-                return "DataSection[?]";
-            }
-        }
-    }
-
-    /**
-     * Represents a code site that references some data. The associated data can be either a
-     * {@link DataSectionReference reference} to the data section, or it may be an inlined
-     * {@link JavaConstant} that needs to be patched.
-     */
-    public static final class DataPatch extends Site {
-
-        public Reference reference;
-        public Object note;
-
-        public DataPatch(int pcOffset, Reference reference) {
-            super(pcOffset);
-            this.reference = reference;
-            this.note = null;
-        }
-
-        public DataPatch(int pcOffset, Reference reference, Object note) {
-            super(pcOffset);
-            this.reference = reference;
-            this.note = note;
-        }
-
-        @Override
-        public String toString() {
-            if (note != null) {
-                return String.format("%d[<data patch referring to %s>, note: %s]", pcOffset, reference.toString(), note.toString());
-            } else {
-                return String.format("%d[<data patch referring to %s>]", pcOffset, reference.toString());
-            }
-        }
-
-        @Override
-        public boolean equals(Object obj) {
-            if (this == obj) {
-                return true;
-            }
-            if (obj instanceof DataPatch) {
-                DataPatch that = (DataPatch) obj;
-                if (this.pcOffset == that.pcOffset && Objects.equals(this.reference, that.reference) && Objects.equals(this.note, that.note)) {
-                    return true;
-                }
-            }
-            return false;
-        }
-    }
-
-    /**
-     * Provides extra information about instructions or data at specific positions in
-     * {@link CompilationResult#getTargetCode()}. This is optional information that can be used to
-     * enhance a disassembly of the code.
-     */
-    public abstract static class CodeAnnotation {
-
-        public final int position;
-
-        public CodeAnnotation(int position) {
-            this.position = position;
-        }
-
-        @Override
-        public final int hashCode() {
-            throw new UnsupportedOperationException("hashCode");
-        }
-
-        @Override
-        public String toString() {
-            return identityHashCodeString(this);
-        }
-
-        @Override
-        public abstract boolean equals(Object obj);
-    }
-
-    /**
-     * A string comment about one or more instructions at a specific position in the code.
-     */
-    public static final class CodeComment extends CodeAnnotation {
-
-        public final String value;
-
-        public CodeComment(int position, String comment) {
-            super(position);
-            this.value = comment;
-        }
-
-        @Override
-        public boolean equals(Object obj) {
-            if (this == obj) {
-                return true;
-            }
-            if (obj instanceof CodeComment) {
-                CodeComment that = (CodeComment) obj;
-                if (this.position == that.position && this.value.equals(that.value)) {
-                    return true;
-                }
-            }
-            return false;
-        }
-
-        @Override
-        public String toString() {
-            return getClass().getSimpleName() + "@" + position + ": " + value;
-        }
-    }
-
-    /**
-     * 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 {
-
-        /**
-         * 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 boolean equals(Object obj) {
-            if (this == obj) {
-                return true;
-            }
-            if (obj instanceof JumpTable) {
-                JumpTable that = (JumpTable) obj;
-                if (this.position == that.position && this.entrySize == that.entrySize && this.low == that.low && this.high == that.high) {
-                    return true;
-                }
-            }
-            return false;
-        }
-
-        @Override
-        public String toString() {
-            return getClass().getSimpleName() + "@" + position + ": [" + low + " .. " + high + "]";
-        }
-    }
-
-    /**
-     * 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 {
-
-        public final int handlerPos;
-
-        ExceptionHandler(int pcOffset, int handlerPos) {
-            super(pcOffset);
-            this.handlerPos = handlerPos;
-        }
-
-        @Override
-        public String toString() {
-            return String.format("%d[<exception edge to %d>]", pcOffset, handlerPos);
-        }
-
-        @Override
-        public boolean equals(Object obj) {
-            if (this == obj) {
-                return true;
-            }
-            if (obj instanceof ExceptionHandler) {
-                ExceptionHandler that = (ExceptionHandler) obj;
-                if (this.pcOffset == that.pcOffset && this.handlerPos == that.handlerPos) {
-                    return true;
-                }
-            }
-            return false;
-        }
-    }
-
-    /**
-     * Represents a mark in the machine code that can be used by the runtime for its own purposes. A
-     * mark can reference other marks.
-     */
-    public static final class Mark extends Site {
-
-        public final Object id;
-
-        public Mark(int pcOffset, Object id) {
-            super(pcOffset);
-            this.id = id;
-        }
-
-        @Override
-        public String toString() {
-            if (id == null) {
-                return String.format("%d[<mar>]", pcOffset);
-            } else if (id instanceof Integer) {
-                return String.format("%d[<mark with id %s>]", pcOffset, Integer.toHexString((Integer) id));
-            } else {
-                return String.format("%d[<mark with id %s>]", pcOffset, id.toString());
-            }
-        }
-
-        @Override
-        public boolean equals(Object obj) {
-            if (this == obj) {
-                return true;
-            }
-            if (obj instanceof Mark) {
-                Mark that = (Mark) obj;
-                if (this.pcOffset == that.pcOffset && Objects.equals(this.id, that.id)) {
-                    return true;
-                }
-            }
-            return false;
-        }
-    }
-
-    /**
-     * Specifies whether this compilation is a {@code +ImmutableCode} {@code +GeneratePIC}
-     * compilation.
-     */
-    private final boolean isImmutablePIC;
-
-    private boolean closed;
-
-    private int entryBCI = -1;
-
-    private final DataSection dataSection = new DataSection();
-
-    private final List<Infopoint> infopoints = new ArrayList<>();
-    private final List<DataPatch> dataPatches = new ArrayList<>();
-    private final List<ExceptionHandler> exceptionHandlers = new ArrayList<>();
-    private final List<Mark> marks = new ArrayList<>();
-
-    private int totalFrameSize = -1;
-    private int customStackAreaOffset = -1;
-
-    private final String name;
-
-    /**
-     * 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<CodeAnnotation> annotations;
-
-    private Assumption[] assumptions;
-
-    /**
-     * The list of the methods whose bytecodes were used as input to the compilation. If
-     * {@code null}, then the compilation did not record method dependencies. Otherwise, the first
-     * element of this array is the root method of the compilation.
-     */
-    private ResolvedJavaMethod[] methods;
-
-    private int bytecodeSize;
-
-    private boolean hasUnsafeAccess;
-
-    public CompilationResult() {
-        this(null);
-    }
-
-    public CompilationResult(String name) {
-        this.name = name;
-        this.isImmutablePIC = false;
-    }
-
-    public CompilationResult(boolean isImmutablePIC) {
-        this.name = null;
-        this.isImmutablePIC = isImmutablePIC;
-    }
-
-    @Override
-    public int hashCode() {
-        // CompilationResult instances should not be used as hash map keys
-        throw new UnsupportedOperationException("hashCode");
-    }
-
-    @Override
-    public String toString() {
-        if (methods != null) {
-            return getClass().getName() + "[" + methods[0].format("%H.%n(%p)%r") + "]";
-        }
-        return identityHashCodeString(this);
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if (this == obj) {
-            return true;
-        }
-        if (obj != null && obj.getClass() == getClass()) {
-            CompilationResult that = (CompilationResult) obj;
-            // @formatter:off
-            if (this.entryBCI == that.entryBCI &&
-                this.customStackAreaOffset == that.customStackAreaOffset &&
-                this.totalFrameSize == that.totalFrameSize &&
-                this.targetCodeSize == that.targetCodeSize &&
-                Objects.equals(this.name, that.name) &&
-                Objects.equals(this.annotations, that.annotations) &&
-                Objects.equals(this.dataSection, that.dataSection) &&
-                Objects.equals(this.exceptionHandlers, that.exceptionHandlers) &&
-                Objects.equals(this.dataPatches, that.dataPatches) &&
-                Objects.equals(this.infopoints, that.infopoints) &&
-                Objects.equals(this.marks,  that.marks) &&
-                Arrays.equals(this.assumptions, that.assumptions) &&
-                Arrays.equals(targetCode, that.targetCode)) {
-                return true;
-            }
-            // @formatter:on
-        }
-        return false;
-    }
-
-    /**
-     * @return true is this is a {@code +ImmutableCode} {@code +GeneratePIC} compilation, false
-     *         otherwise.
-     */
-    public boolean isImmutablePIC() {
-        return isImmutablePIC;
-    }
-
-    /**
-     * @return the entryBCI
-     */
-    public int getEntryBCI() {
-        return entryBCI;
-    }
-
-    /**
-     * @param entryBCI the entryBCI to set
-     */
-    public void setEntryBCI(int entryBCI) {
-        checkOpen();
-        this.entryBCI = entryBCI;
-    }
-
-    /**
-     * Sets the assumptions made during compilation.
-     */
-    public void setAssumptions(Assumption[] assumptions) {
-        checkOpen();
-        this.assumptions = assumptions;
-    }
-
-    /**
-     * Gets the assumptions made during compilation.
-     *
-     * The caller must not modify the contents of the returned array.
-     */
-    public Assumption[] getAssumptions() {
-        return assumptions;
-    }
-
-    /**
-     * Sets the methods whose bytecodes were used as input to the compilation.
-     *
-     * @param rootMethod the root method of the compilation
-     * @param inlinedMethods the methods inlined during compilation
-     */
-    public void setMethods(ResolvedJavaMethod rootMethod, Collection<ResolvedJavaMethod> inlinedMethods) {
-        checkOpen();
-        assert rootMethod != null;
-        assert inlinedMethods != null;
-        if (inlinedMethods.contains(rootMethod)) {
-            methods = inlinedMethods.toArray(new ResolvedJavaMethod[inlinedMethods.size()]);
-            for (int i = 0; i < methods.length; i++) {
-                if (methods[i].equals(rootMethod)) {
-                    if (i != 0) {
-                        ResolvedJavaMethod tmp = methods[0];
-                        methods[0] = methods[i];
-                        methods[i] = tmp;
-                    }
-                    break;
-                }
-            }
-        } else {
-            methods = new ResolvedJavaMethod[1 + inlinedMethods.size()];
-            methods[0] = rootMethod;
-            int i = 1;
-            for (ResolvedJavaMethod m : inlinedMethods) {
-                methods[i++] = m;
-            }
-        }
-    }
-
-    /**
-     * Gets the methods whose bytecodes were used as input to the compilation.
-     *
-     * The caller must not modify the contents of the returned array.
-     *
-     * @return {@code null} if the compilation did not record method dependencies otherwise the
-     *         methods whose bytecodes were used as input to the compilation with the first element
-     *         being the root method of the compilation
-     */
-    public ResolvedJavaMethod[] getMethods() {
-        return methods;
-    }
-
-    public void setBytecodeSize(int bytecodeSize) {
-        checkOpen();
-        this.bytecodeSize = bytecodeSize;
-    }
-
-    public int getBytecodeSize() {
-        return bytecodeSize;
-    }
-
-    public DataSection getDataSection() {
-        return dataSection;
-    }
-
-    /**
-     * The total frame size of the method in bytes. This includes the return address pushed onto the
-     * stack, if any.
-     *
-     * @return the frame size
-     */
-    public int getTotalFrameSize() {
-        assert totalFrameSize != -1 : "frame size not yet initialized!";
-        return totalFrameSize;
-    }
-
-    /**
-     * Sets the total frame size in bytes. This includes the return address pushed onto the stack,
-     * if any.
-     *
-     * @param size the size of the frame in bytes
-     */
-    public void setTotalFrameSize(int size) {
-        checkOpen();
-        totalFrameSize = 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) {
-        checkOpen();
-        targetCode = code;
-        targetCodeSize = size;
-    }
-
-    /**
-     * Records a data patch in the code section. The data patch can refer to something in the
-     * {@link DataSectionReference data section} or directly to an {@link ConstantReference inlined
-     * constant}.
-     *
-     * @param codePos The position in the code that needs to be patched.
-     * @param ref The reference that should be inserted in the code.
-     */
-    public void recordDataPatch(int codePos, Reference ref) {
-        checkOpen();
-        assert codePos >= 0 && ref != null;
-        dataPatches.add(new DataPatch(codePos, ref));
-    }
-
-    /**
-     * Records a data patch in the code section. The data patch can refer to something in the
-     * {@link DataSectionReference data section} or directly to an {@link ConstantReference inlined
-     * constant}.
-     *
-     * @param codePos The position in the code that needs to be patched.
-     * @param ref The reference that should be inserted in the code.
-     * @param note The note attached to data patch for use by post-processing tools
-     */
-    public void recordDataPatchWithNote(int codePos, Reference ref, Object note) {
-        assert codePos >= 0 && ref != null;
-        dataPatches.add(new DataPatch(codePos, ref, note));
-    }
-
-    /**
-     * Records metaspace access.
-     */
-    public void recordMetaspaceAccess(Object reference, int instructionSize, MetaSpaceAccessType type, int codePos, DebugInfo debugInfo) {
-        final MetaSpaceAccess metaspace = new MetaSpaceAccess(reference, instructionSize, type, codePos, debugInfo);
-        addInfopoint(metaspace);
-    }
-
-    /**
-     * 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 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, InvokeTarget target, DebugInfo debugInfo, boolean direct) {
-        checkOpen();
-        final Call call = new Call(target, codePos, size, direct, debugInfo);
-        addInfopoint(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
-     */
-    public void recordExceptionHandler(int codePos, int handlerPos) {
-        checkOpen();
-        assert validateExceptionHandlerAdd(codePos, handlerPos) : String.format("Duplicate exception handler for pc 0x%x handlerPos 0x%x", codePos, handlerPos);
-        exceptionHandlers.add(new ExceptionHandler(codePos, handlerPos));
-    }
-
-    /**
-     * Validate if the exception handler for codePos already exists and handlerPos is different.
-     *
-     * @param codePos
-     * @param handlerPos
-     * @return true if the validation is successful
-     */
-    private boolean validateExceptionHandlerAdd(int codePos, int handlerPos) {
-        ExceptionHandler exHandler = getExceptionHandlerForCodePos(codePos);
-        return exHandler == null || exHandler.handlerPos == handlerPos;
-    }
-
-    /**
-     * Returns the first ExceptionHandler which matches codePos.
-     *
-     * @param codePos position to search for
-     * @return first matching ExceptionHandler
-     */
-    private ExceptionHandler getExceptionHandlerForCodePos(int codePos) {
-        for (ExceptionHandler h : exceptionHandlers) {
-            if (h.pcOffset == codePos) {
-                return h;
-            }
-        }
-        return null;
-    }
-
-    /**
-     * Records an infopoint in the code array.
-     *
-     * @param codePos the position of the infopoint in the code array
-     * @param debugInfo the debug info for the infopoint
-     */
-    public void recordInfopoint(int codePos, DebugInfo debugInfo, InfopointReason reason) {
-        addInfopoint(new Infopoint(codePos, debugInfo, reason));
-    }
-
-    /**
-     * Records a custom infopoint in the code section.
-     *
-     * Compiler implementations can use this method to record non-standard infopoints, which are not
-     * handled by dedicated methods like {@link #recordCall}.
-     *
-     * @param infopoint the infopoint to record, usually a derived class from {@link Infopoint}
-     */
-    public void addInfopoint(Infopoint infopoint) {
-        checkOpen();
-        infopoints.add(infopoint);
-    }
-
-    /**
-     * Records an instruction mark within this method.
-     *
-     * @param codePos the position in the code that is covered by the handler
-     * @param markId the identifier for this mark
-     */
-    public Mark recordMark(int codePos, Object markId) {
-        checkOpen();
-        Mark mark = new Mark(codePos, markId);
-        marks.add(mark);
-        return mark;
-    }
-
-    /**
-     * Offset in bytes for the custom stack area (relative to sp).
-     *
-     * @return the offset in bytes
-     */
-    public int getCustomStackAreaOffset() {
-        return customStackAreaOffset;
-    }
-
-    /**
-     * @see #getCustomStackAreaOffset()
-     * @param offset
-     */
-    public void setCustomStackAreaOffset(int offset) {
-        checkOpen();
-        customStackAreaOffset = offset;
-    }
-
-    /**
-     * @return the machine code generated for this method
-     */
-    public byte[] getTargetCode() {
-        return targetCode;
-    }
-
-    /**
-     * @return the size of the machine code generated for this method
-     */
-    public int getTargetCodeSize() {
-        return targetCodeSize;
-    }
-
-    /**
-     * @return the code annotations or {@code null} if there are none
-     */
-    public List<CodeAnnotation> getAnnotations() {
-        if (annotations == null) {
-            return Collections.emptyList();
-        }
-        return annotations;
-    }
-
-    public void addAnnotation(CodeAnnotation annotation) {
-        checkOpen();
-        assert annotation != null;
-        if (annotations == null) {
-            annotations = new ArrayList<>();
-        }
-        annotations.add(annotation);
-    }
-
-    private static void appendDebugInfo(StringBuilder sb, DebugInfo info) {
-        if (info != null) {
-            ReferenceMap refMap = info.getReferenceMap();
-            if (refMap != null) {
-                sb.append(refMap.toString());
-                sb.append(']');
-            }
-            RegisterSaveLayout calleeSaveInfo = info.getCalleeSaveInfo();
-            if (calleeSaveInfo != null) {
-                sb.append(" callee-save-info[");
-                String sep = "";
-                for (Map.Entry<Register, Integer> e : calleeSaveInfo.registersToSlots(true).entrySet()) {
-                    sb.append(sep).append(e.getKey()).append("->").append(e.getValue());
-                    sep = ", ";
-                }
-                sb.append(']');
-            }
-            BytecodePosition codePos = info.getBytecodePosition();
-            if (codePos != null) {
-                MetaUtil.appendLocation(sb.append(" "), codePos.getMethod(), codePos.getBCI());
-                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);
-                    }
-                }
-            }
-        }
-    }
-
-    /**
-     * @return the list of infopoints, sorted by {@link Site#pcOffset}
-     */
-    public List<Infopoint> getInfopoints() {
-        if (infopoints.isEmpty()) {
-            return emptyList();
-        }
-        return unmodifiableList(infopoints);
-    }
-
-    /**
-     * @return the list of data references
-     */
-    public List<DataPatch> getDataPatches() {
-        if (dataPatches.isEmpty()) {
-            return emptyList();
-        }
-        return unmodifiableList(dataPatches);
-    }
-
-    /**
-     * @return the list of exception handlers
-     */
-    public List<ExceptionHandler> getExceptionHandlers() {
-        if (exceptionHandlers.isEmpty()) {
-            return emptyList();
-        }
-        return unmodifiableList(exceptionHandlers);
-    }
-
-    /**
-     * @return the list of marks
-     */
-    public List<Mark> getMarks() {
-        if (marks.isEmpty()) {
-            return emptyList();
-        }
-        return unmodifiableList(marks);
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public void setHasUnsafeAccess(boolean hasUnsafeAccess) {
-        checkOpen();
-        this.hasUnsafeAccess = hasUnsafeAccess;
-    }
-
-    public boolean hasUnsafeAccess() {
-        return hasUnsafeAccess;
-    }
-
-    /**
-     * Clears the information in this object pertaining to generating code. That is, the
-     * {@linkplain #getMarks() marks}, {@linkplain #getInfopoints() infopoints},
-     * {@linkplain #getExceptionHandlers() exception handlers}, {@linkplain #getDataPatches() data
-     * patches} and {@linkplain #getAnnotations() annotations} recorded in this object are cleared.
-     */
-    public void resetForEmittingCode() {
-        checkOpen();
-        infopoints.clear();
-        dataPatches.clear();
-        exceptionHandlers.clear();
-        marks.clear();
-        dataSection.clear();
-        if (annotations != null) {
-            annotations.clear();
-        }
-    }
-
-    private void checkOpen() {
-        if (closed) {
-            throw new IllegalStateException();
-        }
-    }
-
-    /**
-     * Closes this compilation result to future updates.
-     */
-    public void close() {
-        if (closed) {
-            throw new IllegalStateException("Cannot re-close compilation result " + this);
-        }
-        dataSection.close();
-        closed = true;
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.code/src/jdk/vm/ci/code/CompiledCode.java	Wed Jan 20 14:22:46 2016 +0100
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2016, 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 jdk.vm.ci.code;
+
+/**
+ * The output from compiling a method.
+ */
+public interface CompiledCode {
+}
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.code/src/jdk/vm/ci/code/DataSection.java	Wed Jan 20 16:33:51 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,331 +0,0 @@
-/*
- * Copyright (c) 2014, 2014, 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 jdk.vm.ci.code;
-
-import static jdk.vm.ci.meta.MetaUtil.identityHashCodeString;
-
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.Objects;
-import java.util.function.Consumer;
-
-import jdk.vm.ci.code.CompilationResult.DataPatch;
-import jdk.vm.ci.code.CompilationResult.DataSectionReference;
-import jdk.vm.ci.code.DataSection.Data;
-import jdk.vm.ci.meta.SerializableConstant;
-
-public final class DataSection implements Iterable<Data> {
-
-    @FunctionalInterface
-    public interface DataBuilder {
-
-        void emit(ByteBuffer buffer, Consumer<DataPatch> patch);
-
-        static DataBuilder raw(byte[] data) {
-            return (buffer, patch) -> buffer.put(data);
-        }
-
-        static DataBuilder serializable(SerializableConstant c) {
-            return (buffer, patch) -> c.serialize(buffer);
-        }
-
-        static DataBuilder zero(int size) {
-            switch (size) {
-                case 1:
-                    return (buffer, patch) -> buffer.put((byte) 0);
-                case 2:
-                    return (buffer, patch) -> buffer.putShort((short) 0);
-                case 4:
-                    return (buffer, patch) -> buffer.putInt(0);
-                case 8:
-                    return (buffer, patch) -> buffer.putLong(0L);
-                default:
-                    return (buffer, patch) -> {
-                        int rest = size;
-                        while (rest > 8) {
-                            buffer.putLong(0L);
-                            rest -= 8;
-                        }
-                        while (rest > 0) {
-                            buffer.put((byte) 0);
-                            rest--;
-                        }
-                    };
-            }
-        }
-    }
-
-    public static final class Data {
-
-        private int alignment;
-        private final int size;
-        private final DataBuilder builder;
-
-        private DataSectionReference ref;
-
-        public Data(int alignment, int size, DataBuilder builder) {
-            this.alignment = alignment;
-            this.size = size;
-            this.builder = builder;
-
-            // initialized in DataSection.insertData(Data)
-            ref = null;
-        }
-
-        public void updateAlignment(int newAlignment) {
-            if (newAlignment == alignment) {
-                return;
-            }
-            alignment = lcm(alignment, newAlignment);
-        }
-
-        public int getAlignment() {
-            return alignment;
-        }
-
-        public int getSize() {
-            return size;
-        }
-
-        public DataBuilder getBuilder() {
-            return builder;
-        }
-
-        @Override
-        public int hashCode() {
-            // Data instances should not be used as hash map keys
-            throw new UnsupportedOperationException("hashCode");
-        }
-
-        @Override
-        public String toString() {
-            return identityHashCodeString(this);
-        }
-
-        @Override
-        public boolean equals(Object obj) {
-            assert ref != null;
-            if (obj == this) {
-                return true;
-            }
-            if (obj instanceof Data) {
-                Data that = (Data) obj;
-                if (this.alignment == that.alignment && this.size == that.size && this.ref.equals(that.ref)) {
-                    return true;
-                }
-            }
-            return false;
-        }
-    }
-
-    private final ArrayList<Data> dataItems = new ArrayList<>();
-
-    private boolean closed;
-    private int sectionAlignment;
-    private int sectionSize;
-
-    @Override
-    public int hashCode() {
-        // DataSection instances should not be used as hash map keys
-        throw new UnsupportedOperationException("hashCode");
-    }
-
-    @Override
-    public String toString() {
-        return identityHashCodeString(this);
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if (this == obj) {
-            return true;
-        }
-        if (obj instanceof DataSection) {
-            DataSection that = (DataSection) obj;
-            if (this.closed == that.closed && this.sectionAlignment == that.sectionAlignment && this.sectionSize == that.sectionSize && Objects.equals(this.dataItems, that.dataItems)) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    /**
-     * Inserts a {@link Data} item into the data section. If the item is already in the data
-     * section, the same {@link DataSectionReference} is returned.
-     *
-     * @param data the {@link Data} item to be inserted
-     * @return a unique {@link DataSectionReference} identifying the {@link Data} item
-     */
-    public DataSectionReference insertData(Data data) {
-        checkOpen();
-        synchronized (data) {
-            if (data.ref == null) {
-                data.ref = new DataSectionReference();
-                dataItems.add(data);
-            }
-            return data.ref;
-        }
-    }
-
-    /**
-     * Transfers all {@link Data} from the provided other {@link DataSection} to this
-     * {@link DataSection}, and empties the other section.
-     */
-    public void addAll(DataSection other) {
-        checkOpen();
-        other.checkOpen();
-
-        for (Data data : other.dataItems) {
-            assert data.ref != null;
-            dataItems.add(data);
-        }
-        other.dataItems.clear();
-    }
-
-    /**
-     * Determines if this object has been {@link #close() closed}.
-     */
-    public boolean closed() {
-        return closed;
-    }
-
-    /**
-     * Computes the layout of the data section and closes this object to further updates.
-     *
-     * This must be called exactly once.
-     */
-    void close() {
-        checkOpen();
-        closed = true;
-
-        // simple heuristic: put items with larger alignment requirement first
-        dataItems.sort((a, b) -> a.alignment - b.alignment);
-
-        int position = 0;
-        int alignment = 1;
-        for (Data d : dataItems) {
-            alignment = lcm(alignment, d.alignment);
-            position = align(position, d.alignment);
-
-            d.ref.setOffset(position);
-            position += d.size;
-        }
-
-        sectionAlignment = alignment;
-        sectionSize = position;
-    }
-
-    /**
-     * Gets the size of the data section.
-     *
-     * This must only be called once this object has been {@linkplain #closed() closed}.
-     */
-    public int getSectionSize() {
-        checkClosed();
-        return sectionSize;
-    }
-
-    /**
-     * Gets the minimum alignment requirement of the data section.
-     *
-     * This must only be called once this object has been {@linkplain #closed() closed}.
-     */
-    public int getSectionAlignment() {
-        checkClosed();
-        return sectionAlignment;
-    }
-
-    /**
-     * Builds the data section into a given buffer.
-     *
-     * This must only be called once this object has been {@linkplain #closed() closed}.
-     *
-     * @param buffer the {@link ByteBuffer} where the data section should be built. The buffer must
-     *            hold at least {@link #getSectionSize()} bytes.
-     * @param patch a {@link Consumer} to receive {@link DataPatch data patches} for relocations in
-     *            the data section
-     */
-    public void buildDataSection(ByteBuffer buffer, Consumer<DataPatch> patch) {
-        checkClosed();
-        for (Data d : dataItems) {
-            buffer.position(d.ref.getOffset());
-            d.builder.emit(buffer, patch);
-        }
-    }
-
-    public Data findData(DataSectionReference ref) {
-        for (Data d : dataItems) {
-            if (d.ref == ref) {
-                return d;
-            }
-        }
-        return null;
-    }
-
-    public Iterator<Data> iterator() {
-        return dataItems.iterator();
-    }
-
-    public static int lcm(int x, int y) {
-        if (x == 0) {
-            return y;
-        } else if (y == 0) {
-            return x;
-        }
-
-        int a = Math.max(x, y);
-        int b = Math.min(x, y);
-        while (b > 0) {
-            int tmp = a % b;
-            a = b;
-            b = tmp;
-        }
-
-        int gcd = a;
-        return x * y / gcd;
-    }
-
-    private static int align(int position, int alignment) {
-        return ((position + alignment - 1) / alignment) * alignment;
-    }
-
-    private void checkClosed() {
-        if (!closed) {
-            throw new IllegalStateException();
-        }
-    }
-
-    private void checkOpen() {
-        if (closed) {
-            throw new IllegalStateException();
-        }
-    }
-
-    public void clear() {
-        checkOpen();
-        this.dataItems.clear();
-        this.sectionAlignment = 0;
-        this.sectionSize = 0;
-    }
-}
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.code/src/jdk/vm/ci/code/InfopointReason.java	Wed Jan 20 16:33:51 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2013, 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 jdk.vm.ci.code;
-
-/**
- * A reason for infopoint insertion.
- */
-public enum InfopointReason {
-
-    SAFEPOINT,
-    CALL,
-    IMPLICIT_EXCEPTION,
-    METASPACE_ACCESS,
-    METHOD_START,
-    METHOD_END,
-    BYTECODE_POSITION;
-}
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.code/src/jdk/vm/ci/code/package-info.java	Wed Jan 20 16:33:51 2016 +0100
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.code/src/jdk/vm/ci/code/package-info.java	Wed Jan 20 14:22:46 2016 +0100
@@ -1,26 +1,29 @@
 /*
- * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. DO NOT ALTER OR
- * REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * Copyright (c) 2010, 2016, 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 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
+ * 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.
+ * 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.
+ * 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 that defines the interface between a Java application that wants to install code and the runtime.
  * The runtime provides in implementation of the {@link jdk.vm.ci.code.CodeCacheProvider} interface.
- * The method {@link jdk.vm.ci.code.CodeCacheProvider#addCode(jdk.vm.ci.meta.ResolvedJavaMethod, CompilationResult, jdk.vm.ci.meta.SpeculationLog, InstalledCode)}
+ * The method {@link jdk.vm.ci.code.CodeCacheProvider#addCode(jdk.vm.ci.meta.ResolvedJavaMethod, CompiledCode, jdk.vm.ci.meta.SpeculationLog, InstalledCode)}
  * can be used to install code.
  */
 package jdk.vm.ci.code;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.code/src/jdk/vm/ci/code/site/Call.java	Wed Jan 20 14:22:46 2016 +0100
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2016, 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 jdk.vm.ci.code.site;
+
+import java.util.Objects;
+
+import jdk.vm.ci.code.DebugInfo;
+import jdk.vm.ci.meta.InvokeTarget;
+
+/**
+ * Represents a call in the code.
+ */
+public final class Call extends Infopoint {
+
+    /**
+     * The target of the call.
+     */
+    public final InvokeTarget 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;
+
+    public Call(InvokeTarget target, int pcOffset, int size, boolean direct, DebugInfo debugInfo) {
+        super(pcOffset, debugInfo, InfopointReason.CALL);
+        this.size = size;
+        this.target = target;
+        this.direct = direct;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj instanceof Call && super.equals(obj)) {
+            Call that = (Call) obj;
+            if (this.size == that.size && this.direct == that.direct && Objects.equals(this.target, that.target)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    @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();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.code/src/jdk/vm/ci/code/site/ConstantReference.java	Wed Jan 20 14:22:46 2016 +0100
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2016, 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 jdk.vm.ci.code.site;
+
+import java.util.Objects;
+
+import jdk.vm.ci.meta.VMConstant;
+
+public final class ConstantReference extends Reference {
+
+    private final VMConstant constant;
+
+    public ConstantReference(VMConstant constant) {
+        this.constant = constant;
+    }
+
+    public VMConstant getConstant() {
+        return constant;
+    }
+
+    @Override
+    public String toString() {
+        return constant.toString();
+    }
+
+    @Override
+    public int hashCode() {
+        return constant.hashCode();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj instanceof ConstantReference) {
+            ConstantReference that = (ConstantReference) obj;
+            return Objects.equals(this.constant, that.constant);
+        }
+        return false;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.code/src/jdk/vm/ci/code/site/DataPatch.java	Wed Jan 20 14:22:46 2016 +0100
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2016, 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 jdk.vm.ci.code.site;
+
+import java.util.Objects;
+
+import jdk.vm.ci.meta.JavaConstant;
+
+/**
+ * Represents a code site that references some data. The associated data can be either a
+ * {@link DataSectionReference reference} to the data section, or it may be an inlined
+ * {@link JavaConstant} that needs to be patched.
+ */
+public final class DataPatch extends Site {
+
+    public Reference reference;
+    public Object note;
+
+    public DataPatch(int pcOffset, Reference reference) {
+        super(pcOffset);
+        this.reference = reference;
+        this.note = null;
+    }
+
+    public DataPatch(int pcOffset, Reference reference, Object note) {
+        super(pcOffset);
+        this.reference = reference;
+        this.note = note;
+    }
+
+    @Override
+    public String toString() {
+        if (note != null) {
+            return String.format("%d[<data patch referring to %s>, note: %s]", pcOffset, reference.toString(), note.toString());
+        } else {
+            return String.format("%d[<data patch referring to %s>]", pcOffset, reference.toString());
+        }
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj instanceof DataPatch) {
+            DataPatch that = (DataPatch) obj;
+            if (this.pcOffset == that.pcOffset && Objects.equals(this.reference, that.reference) && Objects.equals(this.note, that.note)) {
+                return true;
+            }
+        }
+        return false;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.code/src/jdk/vm/ci/code/site/DataSectionReference.java	Wed Jan 20 14:22:46 2016 +0100
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2016, 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 jdk.vm.ci.code.site;
+
+public final class DataSectionReference extends Reference {
+
+    private boolean initialized;
+    private int offset;
+
+    public DataSectionReference() {
+        // will be set after the data section layout is fixed
+        offset = 0xDEADDEAD;
+    }
+
+    public int getOffset() {
+        assert initialized;
+
+        return offset;
+    }
+
+    public void setOffset(int offset) {
+        assert !initialized;
+        initialized = true;
+
+        this.offset = offset;
+    }
+
+    @Override
+    public int hashCode() {
+        return offset;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj instanceof DataSectionReference) {
+            DataSectionReference that = (DataSectionReference) obj;
+            return this.offset == that.offset;
+        }
+        return false;
+    }
+
+    @Override
+    public String toString() {
+        if (initialized) {
+            return String.format("DataSection[0x%x]", offset);
+        } else {
+            return "DataSection[?]";
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.code/src/jdk/vm/ci/code/site/ExceptionHandler.java	Wed Jan 20 14:22:46 2016 +0100
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2016, 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 jdk.vm.ci.code.site;
+
+/**
+ * Represents exception handler information for a specific code position. It includes the catch code
+ * position as well as the caught exception type.
+ */
+public final class ExceptionHandler extends Site {
+
+    public final int handlerPos;
+
+    public ExceptionHandler(int pcOffset, int handlerPos) {
+        super(pcOffset);
+        this.handlerPos = handlerPos;
+    }
+
+    @Override
+    public String toString() {
+        return String.format("%d[<exception edge to %d>]", pcOffset, handlerPos);
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj instanceof ExceptionHandler) {
+            ExceptionHandler that = (ExceptionHandler) obj;
+            if (this.pcOffset == that.pcOffset && this.handlerPos == that.handlerPos) {
+                return true;
+            }
+        }
+        return false;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.code/src/jdk/vm/ci/code/site/Infopoint.java	Wed Jan 20 14:22:46 2016 +0100
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2016, 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 jdk.vm.ci.code.site;
+
+import java.util.Map;
+import java.util.Objects;
+
+import jdk.vm.ci.code.BytecodePosition;
+import jdk.vm.ci.code.DebugInfo;
+import jdk.vm.ci.code.ReferenceMap;
+import jdk.vm.ci.code.Register;
+import jdk.vm.ci.code.RegisterSaveLayout;
+import jdk.vm.ci.meta.MetaUtil;
+
+/**
+ * Represents an infopoint with associated debug info. Note that safepoints are also infopoints.
+ */
+public class Infopoint extends Site implements Comparable<Infopoint> {
+
+    public final DebugInfo debugInfo;
+
+    public final InfopointReason reason;
+
+    public Infopoint(int pcOffset, DebugInfo debugInfo, InfopointReason reason) {
+        super(pcOffset);
+        this.debugInfo = debugInfo;
+        this.reason = reason;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append(pcOffset);
+        sb.append("[<infopoint>]");
+        appendDebugInfo(sb, debugInfo);
+        return sb.toString();
+    }
+
+    @Override
+    public int compareTo(Infopoint o) {
+        if (pcOffset < o.pcOffset) {
+            return -1;
+        } else if (pcOffset > o.pcOffset) {
+            return 1;
+        }
+        return this.reason.compareTo(o.reason);
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj != null && obj.getClass() == getClass()) {
+            Infopoint that = (Infopoint) obj;
+            if (this.pcOffset == that.pcOffset && Objects.equals(this.debugInfo, that.debugInfo) && Objects.equals(this.reason, that.reason)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    protected static void appendDebugInfo(StringBuilder sb, DebugInfo info) {
+        if (info != null) {
+            ReferenceMap refMap = info.getReferenceMap();
+            if (refMap != null) {
+                sb.append(refMap.toString());
+                sb.append(']');
+            }
+            RegisterSaveLayout calleeSaveInfo = info.getCalleeSaveInfo();
+            if (calleeSaveInfo != null) {
+                sb.append(" callee-save-info[");
+                String sep = "";
+                for (Map.Entry<Register, Integer> e : calleeSaveInfo.registersToSlots(true).entrySet()) {
+                    sb.append(sep).append(e.getKey()).append("->").append(e.getValue());
+                    sep = ", ";
+                }
+                sb.append(']');
+            }
+            BytecodePosition codePos = info.getBytecodePosition();
+            if (codePos != null) {
+                MetaUtil.appendLocation(sb.append(" "), codePos.getMethod(), codePos.getBCI());
+                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);
+                    }
+                }
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.code/src/jdk/vm/ci/code/site/InfopointReason.java	Wed Jan 20 14:22:46 2016 +0100
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2013, 2016, 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 jdk.vm.ci.code.site;
+
+/**
+ * A reason for infopoint insertion.
+ */
+public enum InfopointReason {
+
+    SAFEPOINT,
+    CALL,
+    IMPLICIT_EXCEPTION,
+    METASPACE_ACCESS,
+    METHOD_START,
+    METHOD_END,
+    BYTECODE_POSITION;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.code/src/jdk/vm/ci/code/site/Mark.java	Wed Jan 20 14:22:46 2016 +0100
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2016, 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 jdk.vm.ci.code.site;
+
+import java.util.Objects;
+
+/**
+ * Represents a mark in the machine code that can be used by the runtime for its own purposes. A
+ * mark can reference other marks.
+ */
+public final class Mark extends Site {
+
+    public final Object id;
+
+    public Mark(int pcOffset, Object id) {
+        super(pcOffset);
+        this.id = id;
+    }
+
+    @Override
+    public String toString() {
+        if (id == null) {
+            return String.format("%d[<mar>]", pcOffset);
+        } else if (id instanceof Integer) {
+            return String.format("%d[<mark with id %s>]", pcOffset, Integer.toHexString((Integer) id));
+        } else {
+            return String.format("%d[<mark with id %s>]", pcOffset, id.toString());
+        }
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj instanceof Mark) {
+            Mark that = (Mark) obj;
+            if (this.pcOffset == that.pcOffset && Objects.equals(this.id, that.id)) {
+                return true;
+            }
+        }
+        return false;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.code/src/jdk/vm/ci/code/site/Reference.java	Wed Jan 20 14:22:46 2016 +0100
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2016, 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 jdk.vm.ci.code.site;
+
+/**
+ * Represents some external data that is referenced by the code.
+ */
+public abstract class Reference {
+
+    @Override
+    public abstract int hashCode();
+
+    @Override
+    public abstract boolean equals(Object obj);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.code/src/jdk/vm/ci/code/site/Site.java	Wed Jan 20 14:22:46 2016 +0100
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2016, 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 jdk.vm.ci.code.site;
+
+import static jdk.vm.ci.meta.MetaUtil.identityHashCodeString;
+
+/**
+ * Represents a code position with associated additional information.
+ */
+public abstract class Site {
+
+    /**
+     * 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;
+    }
+
+    @Override
+    public final int hashCode() {
+        throw new UnsupportedOperationException("hashCode");
+    }
+
+    @Override
+    public String toString() {
+        return identityHashCodeString(this);
+    }
+
+    @Override
+    public abstract boolean equals(Object obj);
+}
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCodeCacheProvider.java	Wed Jan 20 16:33:51 2016 +0100
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCodeCacheProvider.java	Wed Jan 20 14:22:46 2016 +0100
@@ -22,30 +22,18 @@
  */
 package jdk.vm.ci.hotspot;
 
-import static jdk.vm.ci.hotspot.HotSpotCompressedNullConstant.COMPRESSED_NULL;
-
 import java.lang.reflect.Field;
 
 import jdk.vm.ci.code.BailoutException;
 import jdk.vm.ci.code.CodeCacheProvider;
-import jdk.vm.ci.code.CompilationRequest;
-import jdk.vm.ci.code.CompilationResult;
-import jdk.vm.ci.code.CompilationResult.Call;
-import jdk.vm.ci.code.CompilationResult.ConstantReference;
-import jdk.vm.ci.code.CompilationResult.DataPatch;
-import jdk.vm.ci.code.CompilationResult.Mark;
-import jdk.vm.ci.code.DataSection;
-import jdk.vm.ci.code.DataSection.Data;
-import jdk.vm.ci.code.DataSection.DataBuilder;
+import jdk.vm.ci.code.CompiledCode;
 import jdk.vm.ci.code.InstalledCode;
 import jdk.vm.ci.code.RegisterConfig;
 import jdk.vm.ci.code.TargetDescription;
-import jdk.vm.ci.common.JVMCIError;
-import jdk.vm.ci.meta.Constant;
-import jdk.vm.ci.meta.JavaConstant;
-import jdk.vm.ci.meta.SerializableConstant;
+import jdk.vm.ci.code.site.Call;
+import jdk.vm.ci.code.site.Mark;
+import jdk.vm.ci.meta.ResolvedJavaMethod;
 import jdk.vm.ci.meta.SpeculationLog;
-import jdk.vm.ci.meta.VMConstant;
 
 /**
  * HotSpot implementation of {@link CodeCacheProvider}.
@@ -113,41 +101,25 @@
         return runtime.getConfig().runtimeCallStackSize;
     }
 
-    private InstalledCode logOrDump(InstalledCode installedCode, CompilationResult compResult) {
-        ((HotSpotJVMCIRuntime) runtime).notifyInstall(this, installedCode, compResult);
+    private InstalledCode logOrDump(InstalledCode installedCode, CompiledCode compiledCode) {
+        ((HotSpotJVMCIRuntime) runtime).notifyInstall(this, installedCode, compiledCode);
         return installedCode;
     }
 
-    public InstalledCode installCode(CompilationRequest compRequest, CompilationResult compResult, InstalledCode installedCode, SpeculationLog log, boolean isDefault) {
-        HotSpotResolvedJavaMethod method = compRequest != null ? (HotSpotResolvedJavaMethod) compRequest.getMethod() : null;
+    public InstalledCode installCode(ResolvedJavaMethod method, CompiledCode compiledCode, InstalledCode installedCode, SpeculationLog log, boolean isDefault) {
         InstalledCode resultInstalledCode;
         if (installedCode == null) {
             if (method == null) {
                 // Must be a stub
-                resultInstalledCode = new HotSpotRuntimeStub(compResult.getName());
+                resultInstalledCode = new HotSpotRuntimeStub(((HotSpotCompiledCode) compiledCode).getName());
             } else {
-                resultInstalledCode = new HotSpotNmethod(method, compResult.getName(), isDefault);
+                resultInstalledCode = new HotSpotNmethod((HotSpotResolvedJavaMethod) method, ((HotSpotCompiledCode) compiledCode).getName(), isDefault);
             }
         } else {
             resultInstalledCode = installedCode;
         }
-        HotSpotCompiledCode compiledCode;
-        if (method != null) {
-            final int id;
-            final long jvmciEnv;
-            if (compRequest instanceof HotSpotCompilationRequest) {
-                HotSpotCompilationRequest hsCompRequest = (HotSpotCompilationRequest) compRequest;
-                id = hsCompRequest.getId();
-                jvmciEnv = hsCompRequest.getJvmciEnv();
-            } else {
-                id = method.allocateCompileId(compRequest.getEntryBCI());
-                jvmciEnv = 0L;
-            }
-            compiledCode = new HotSpotCompiledNmethod(method, compResult, id, jvmciEnv);
-        } else {
-            compiledCode = new HotSpotCompiledCode(compResult);
-        }
-        int result = runtime.getCompilerToVM().installCode(target, compiledCode, resultInstalledCode, (HotSpotSpeculationLog) log);
+
+        int result = runtime.getCompilerToVM().installCode(target, (HotSpotCompiledCode) compiledCode, resultInstalledCode, (HotSpotSpeculationLog) log);
         if (result != config.codeInstallResultOk) {
             String resultDesc = config.getCodeInstallResultDescription(result);
             if (compiledCode instanceof HotSpotCompiledNmethod) {
@@ -163,83 +135,16 @@
                 }
                 throw new BailoutException(result != config.codeInstallResultDependenciesFailed, msg);
             } else {
-                throw new BailoutException("Error installing %s: %s", compResult.getName(), resultDesc);
+                throw new BailoutException("Error installing %s: %s", ((HotSpotCompiledCode) compiledCode).getName(), resultDesc);
             }
         }
-        return logOrDump(resultInstalledCode, compResult);
+        return logOrDump(resultInstalledCode, compiledCode);
     }
 
     public void invalidateInstalledCode(InstalledCode installedCode) {
         runtime.getCompilerToVM().invalidateInstalledCode(installedCode);
     }
 
-    private Data createSingleDataItem(Constant constant) {
-        int size;
-        DataBuilder builder;
-        if (constant instanceof VMConstant) {
-            VMConstant vmConstant = (VMConstant) constant;
-            boolean compressed;
-            if (constant instanceof HotSpotConstant) {
-                HotSpotConstant c = (HotSpotConstant) vmConstant;
-                compressed = c.isCompressed();
-            } else {
-                throw new JVMCIError(String.valueOf(constant));
-            }
-
-            size = compressed ? 4 : target.wordSize;
-            if (size == 4) {
-                builder = (buffer, patch) -> {
-                    patch.accept(new DataPatch(buffer.position(), new ConstantReference(vmConstant)));
-                    buffer.putInt(0xDEADDEAD);
-                };
-            } else {
-                assert size == 8;
-                builder = (buffer, patch) -> {
-                    patch.accept(new DataPatch(buffer.position(), new ConstantReference(vmConstant)));
-                    buffer.putLong(0xDEADDEADDEADDEADL);
-                };
-            }
-        } else if (JavaConstant.isNull(constant)) {
-            boolean compressed = COMPRESSED_NULL.equals(constant);
-            size = compressed ? 4 : target.wordSize;
-            builder = DataBuilder.zero(size);
-        } else if (constant instanceof SerializableConstant) {
-            SerializableConstant s = (SerializableConstant) constant;
-            size = s.getSerializedSize();
-            builder = DataBuilder.serializable(s);
-        } else {
-            throw new JVMCIError(String.valueOf(constant));
-        }
-
-        return new Data(size, size, builder);
-    }
-
-    public Data createDataItem(Constant... constants) {
-        assert constants.length > 0;
-        if (constants.length == 1) {
-            return createSingleDataItem(constants[0]);
-        } else {
-            DataBuilder[] builders = new DataBuilder[constants.length];
-            int size = 0;
-            int alignment = 1;
-            for (int i = 0; i < constants.length; i++) {
-                Data data = createSingleDataItem(constants[i]);
-
-                assert size % data.getAlignment() == 0 : "invalid alignment in packed constants";
-                alignment = DataSection.lcm(alignment, data.getAlignment());
-
-                builders[i] = data.getBuilder();
-                size += data.getSize();
-            }
-            DataBuilder ret = (buffer, patches) -> {
-                for (DataBuilder b : builders) {
-                    b.emit(buffer, patches);
-                }
-            };
-            return new Data(alignment, size, ret);
-        }
-    }
-
     @Override
     public TargetDescription getTarget() {
         return target;
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCompiledCode.java	Wed Jan 20 16:33:51 2016 +0100
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCompiledCode.java	Wed Jan 20 14:22:46 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, 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
@@ -22,62 +22,86 @@
  */
 package jdk.vm.ci.hotspot;
 
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.EnumMap;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Stream;
-import java.util.stream.Stream.Builder;
-
 import jdk.vm.ci.code.BytecodeFrame;
-import jdk.vm.ci.code.CompilationResult;
-import jdk.vm.ci.code.CompilationResult.CodeAnnotation;
-import jdk.vm.ci.code.CompilationResult.CodeComment;
-import jdk.vm.ci.code.CompilationResult.DataPatch;
-import jdk.vm.ci.code.CompilationResult.ExceptionHandler;
-import jdk.vm.ci.code.CompilationResult.Infopoint;
-import jdk.vm.ci.code.CompilationResult.JumpTable;
-import jdk.vm.ci.code.CompilationResult.Mark;
-import jdk.vm.ci.code.CompilationResult.Site;
-import jdk.vm.ci.code.DataSection;
-import jdk.vm.ci.code.InfopointReason;
-import jdk.vm.ci.common.JVMCIError;
+import jdk.vm.ci.code.CompiledCode;
+import jdk.vm.ci.code.site.DataPatch;
+import jdk.vm.ci.code.site.Infopoint;
+import jdk.vm.ci.code.site.Site;
 import jdk.vm.ci.meta.Assumptions.Assumption;
 import jdk.vm.ci.meta.ResolvedJavaMethod;
 
 /**
- * A {@link CompilationResult} with additional HotSpot-specific information required for installing
- * the code in HotSpot's code cache.
+ * A {@link CompiledCode} with additional HotSpot-specific information required for installing the
+ * code in HotSpot's code cache.
  */
-public class HotSpotCompiledCode {
+public class HotSpotCompiledCode implements CompiledCode {
 
-    public final String name;
-    public final Site[] sites;
-    public final ExceptionHandler[] exceptionHandlers;
-    public final Comment[] comments;
-    public final Assumption[] assumptions;
+    /**
+     * The name of this compilation unit.
+     */
+    protected final String name;
+
+    /**
+     * The buffer containing the emitted machine code.
+     */
+    protected final byte[] targetCode;
 
-    public final byte[] targetCode;
-    public final int targetCodeSize;
+    /**
+     * The leading number of bytes in {@link #targetCode} containing the emitted machine code.
+     */
+    protected final int targetCodeSize;
 
-    public final byte[] dataSection;
-    public final int dataSectionAlignment;
-    public final DataPatch[] dataSectionPatches;
-    public final boolean isImmutablePIC;
+    /**
+     * A list of code annotations describing special sites in {@link #targetCode}.
+     */
+    protected final Site[] sites;
 
-    public final int totalFrameSize;
-    public final int customStackAreaOffset;
+    /**
+     * A list of {@link Assumption} this code relies on.
+     */
+    protected final Assumption[] assumptions;
 
     /**
      * The list of the methods whose bytecodes were used as input to the compilation. If
      * {@code null}, then the compilation did not record method dependencies. Otherwise, the first
      * element of this array is the root method of the compilation.
      */
-    public final ResolvedJavaMethod[] methods;
+    protected final ResolvedJavaMethod[] methods;
+
+    /**
+     * A list of comments that will be included in code dumps.
+     */
+    protected final Comment[] comments;
+
+    /**
+     * The data section containing serialized constants for the emitted machine code.
+     */
+    protected final byte[] dataSection;
+
+    /**
+     * The minimum alignment of the data section.
+     */
+    protected final int dataSectionAlignment;
+
+    /**
+     * A list of relocations in the {@link #dataSection}.
+     */
+    protected final DataPatch[] dataSectionPatches;
+
+    /**
+     * A flag determining whether this code is immutable and position independent.
+     */
+    protected final boolean isImmutablePIC;
+
+    /**
+     * The total size of the stack frame of this compiled method.
+     */
+    protected final int totalFrameSize;
+
+    /**
+     * Offset in bytes for the custom stack area (relative to sp).
+     */
+    protected final int customStackAreaOffset;
 
     public static class Comment {
 
@@ -90,59 +114,38 @@
         }
     }
 
-    public HotSpotCompiledCode(CompilationResult compResult) {
-        name = compResult.getName();
-        sites = getSortedSites(compResult);
-        if (compResult.getExceptionHandlers().isEmpty()) {
-            exceptionHandlers = null;
-        } else {
-            exceptionHandlers = compResult.getExceptionHandlers().toArray(new ExceptionHandler[compResult.getExceptionHandlers().size()]);
-        }
-        List<CodeAnnotation> annotations = compResult.getAnnotations();
-        comments = new Comment[annotations.size()];
-        if (!annotations.isEmpty()) {
-            for (int i = 0; i < comments.length; i++) {
-                CodeAnnotation annotation = annotations.get(i);
-                String text;
-                if (annotation instanceof CodeComment) {
-                    CodeComment codeComment = (CodeComment) annotation;
-                    text = codeComment.value;
-                } else if (annotation instanceof JumpTable) {
-                    JumpTable jumpTable = (JumpTable) annotation;
-                    text = "JumpTable [" + jumpTable.low + " .. " + jumpTable.high + "]";
-                } else {
-                    text = annotation.toString();
-                }
-                comments[i] = new Comment(annotation.position, text);
-            }
-        }
-        assumptions = compResult.getAssumptions();
+    public HotSpotCompiledCode(String name, byte[] targetCode, int targetCodeSize, Site[] sites, Assumption[] assumptions, ResolvedJavaMethod[] methods, Comment[] comments, byte[] dataSection,
+                    int dataSectionAlignment, DataPatch[] dataSectionPatches, boolean isImmutablePIC, int totalFrameSize, int customStackAreaOffset) {
+        this.name = name;
+        this.targetCode = targetCode;
+        this.targetCodeSize = targetCodeSize;
+        this.sites = sites;
+        this.assumptions = assumptions;
+        this.methods = methods;
+
+        this.comments = comments;
+        this.dataSection = dataSection;
+        this.dataSectionAlignment = dataSectionAlignment;
+        this.dataSectionPatches = dataSectionPatches;
+        this.isImmutablePIC = isImmutablePIC;
+        this.totalFrameSize = totalFrameSize;
+        this.customStackAreaOffset = customStackAreaOffset;
+
         assert validateFrames();
-
-        targetCode = compResult.getTargetCode();
-        targetCodeSize = compResult.getTargetCodeSize();
-
-        DataSection data = compResult.getDataSection();
-        dataSection = new byte[data.getSectionSize()];
+    }
 
-        ByteBuffer buffer = ByteBuffer.wrap(dataSection).order(ByteOrder.nativeOrder());
-        Builder<DataPatch> patchBuilder = Stream.builder();
-        data.buildDataSection(buffer, patchBuilder);
-
-        dataSectionAlignment = data.getSectionAlignment();
-        dataSectionPatches = patchBuilder.build().toArray(len -> new DataPatch[len]);
+    public String getName() {
+        return name;
+    }
 
-        isImmutablePIC = compResult.isImmutablePIC();
-
-        totalFrameSize = compResult.getTotalFrameSize();
-        customStackAreaOffset = compResult.getCustomStackAreaOffset();
-
-        methods = compResult.getMethods();
+    @Override
+    public String toString() {
+        return name;
     }
 
     /**
-     * Ensure that all the frames passed into HotSpot are properly formatted with an empty or
-     * illegal slot following double word slots.
+     * Ensure that all the frames passed into the VM are properly formatted with an empty or illegal
+     * slot following double word slots.
      */
     private boolean validateFrames() {
         for (Site site : sites) {
@@ -156,117 +159,4 @@
         }
         return true;
     }
-
-    static class SiteComparator implements Comparator<Site> {
-
-        /**
-         * Defines an order for sorting {@link Infopoint}s based on their
-         * {@linkplain Infopoint#reason reasons}. This is used to choose which infopoint to preserve
-         * when multiple infopoints collide on the same PC offset. A negative order value implies a
-         * non-optional infopoint (i.e., must be preserved). Non-optional infopoints must not
-         * collide.
-         */
-        static final Map<InfopointReason, Integer> HOTSPOT_INFOPOINT_SORT_ORDER = new EnumMap<>(InfopointReason.class);
-        static {
-            HOTSPOT_INFOPOINT_SORT_ORDER.put(InfopointReason.SAFEPOINT, -4);
-            HOTSPOT_INFOPOINT_SORT_ORDER.put(InfopointReason.CALL, -3);
-            HOTSPOT_INFOPOINT_SORT_ORDER.put(InfopointReason.IMPLICIT_EXCEPTION, -2);
-            HOTSPOT_INFOPOINT_SORT_ORDER.put(InfopointReason.METASPACE_ACCESS, 1);
-            HOTSPOT_INFOPOINT_SORT_ORDER.put(InfopointReason.METHOD_START, 2);
-            HOTSPOT_INFOPOINT_SORT_ORDER.put(InfopointReason.METHOD_END, 3);
-            HOTSPOT_INFOPOINT_SORT_ORDER.put(InfopointReason.BYTECODE_POSITION, 4);
-        }
-
-        static int ord(Infopoint info) {
-            return HOTSPOT_INFOPOINT_SORT_ORDER.get(info.reason);
-        }
-
-        static int checkCollision(Infopoint i1, Infopoint i2) {
-            int o1 = ord(i1);
-            int o2 = ord(i2);
-            if (o1 < 0 && o2 < 0) {
-                throw new JVMCIError("Non-optional infopoints cannot collide: %s and %s", i1, i2);
-            }
-            return o1 - o2;
-        }
-
-        /**
-         * Records whether any two {@link Infopoint}s had the same {@link Infopoint#pcOffset}.
-         */
-        boolean sawCollidingInfopoints;
-
-        public int compare(Site s1, Site s2) {
-            if (s1.pcOffset == s2.pcOffset) {
-                // Marks must come first since patching a call site
-                // may need to know the mark denoting the call type
-                // (see uses of CodeInstaller::_next_call_type).
-                boolean s1IsMark = s1 instanceof Mark;
-                boolean s2IsMark = s2 instanceof Mark;
-                if (s1IsMark != s2IsMark) {
-                    return s1IsMark ? -1 : 1;
-                }
-
-                // Infopoints must group together so put them after
-                // other Site types.
-                boolean s1IsInfopoint = s1 instanceof Infopoint;
-                boolean s2IsInfopoint = s2 instanceof Infopoint;
-                if (s1IsInfopoint != s2IsInfopoint) {
-                    return s1IsInfopoint ? 1 : -1;
-                }
-
-                if (s1IsInfopoint) {
-                    sawCollidingInfopoints = true;
-                    return checkCollision((Infopoint) s1, (Infopoint) s2);
-                }
-            }
-            return s1.pcOffset - s2.pcOffset;
-        }
-    }
-
-    /**
-     * HotSpot expects sites to be presented in ascending order of PC (see
-     * {@code DebugInformationRecorder::add_new_pc_offset}). In addition, it expects
-     * {@link Infopoint} PCs to be unique.
-     */
-    private static Site[] getSortedSites(CompilationResult target) {
-        List<?>[] lists = new List<?>[]{target.getInfopoints(), target.getDataPatches(), target.getMarks()};
-        int count = 0;
-        for (List<?> list : lists) {
-            count += list.size();
-        }
-        Site[] result = new Site[count];
-        int pos = 0;
-        for (List<?> list : lists) {
-            for (Object elem : list) {
-                result[pos++] = (Site) elem;
-            }
-        }
-        SiteComparator c = new SiteComparator();
-        Arrays.sort(result, c);
-        if (c.sawCollidingInfopoints) {
-            Infopoint lastInfopoint = null;
-            List<Site> copy = new ArrayList<>(count);
-            for (int i = 0; i < count; i++) {
-                if (result[i] instanceof Infopoint) {
-                    Infopoint info = (Infopoint) result[i];
-                    if (lastInfopoint == null || lastInfopoint.pcOffset != info.pcOffset) {
-                        lastInfopoint = info;
-                        copy.add(info);
-                    } else {
-                        // Omit this colliding infopoint
-                        assert lastInfopoint.reason.compareTo(info.reason) <= 0;
-                    }
-                } else {
-                    copy.add(result[i]);
-                }
-            }
-            result = copy.toArray(new Site[copy.size()]);
-        }
-        return result;
-    }
-
-    @Override
-    public String toString() {
-        return name;
-    }
 }
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCompiledNmethod.java	Wed Jan 20 16:33:51 2016 +0100
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCompiledNmethod.java	Wed Jan 20 14:22:46 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, 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
@@ -22,28 +22,31 @@
  */
 package jdk.vm.ci.hotspot;
 
-import jdk.vm.ci.code.CompilationResult;
+import jdk.vm.ci.code.site.DataPatch;
+import jdk.vm.ci.code.site.Site;
 import jdk.vm.ci.inittimer.SuppressFBWarnings;
+import jdk.vm.ci.meta.Assumptions.Assumption;
+import jdk.vm.ci.meta.ResolvedJavaMethod;
 
 /**
  * {@link HotSpotCompiledCode} destined for installation as an nmethod.
  */
 public final class HotSpotCompiledNmethod extends HotSpotCompiledCode {
 
-    public final HotSpotResolvedJavaMethod method;
-    public final int entryBCI;
+    protected final HotSpotResolvedJavaMethod method;
+    protected final int entryBCI;
 
     /**
      * Compilation identifier.
      */
-    public final int id;
+    protected final int id;
 
     /**
      * Address of a native {@code JVMCIEnv} object or 0L if no such object exists.
      */
-    public final long jvmciEnv;
+    protected final long jvmciEnv;
 
-    public final boolean hasUnsafeAccess;
+    protected final boolean hasUnsafeAccess;
 
     /**
      * May be set by VM if code installation fails. It will describe in more detail why installation
@@ -51,13 +54,15 @@
      */
     @SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "set by the VM") private String installationFailureMessage;
 
-    public HotSpotCompiledNmethod(HotSpotResolvedJavaMethod method, CompilationResult compResult, int id, long jvmciEnv) {
-        super(compResult);
+    public HotSpotCompiledNmethod(String name, byte[] targetCode, int targetCodeSize, Site[] sites, Assumption[] assumptions, ResolvedJavaMethod[] methods, Comment[] comments, byte[] dataSection,
+                    int dataSectionAlignment, DataPatch[] dataSectionPatches, boolean isImmutablePIC, int totalFrameSize, int customStackAreaOffset, HotSpotResolvedJavaMethod method, int entryBCI,
+                    int id, long jvmciEnv, boolean hasUnsafeAccess) {
+        super(name, targetCode, targetCodeSize, sites, assumptions, methods, comments, dataSection, dataSectionAlignment, dataSectionPatches, isImmutablePIC, totalFrameSize, customStackAreaOffset);
         this.method = method;
-        this.entryBCI = compResult.getEntryBCI();
+        this.entryBCI = entryBCI;
         this.id = id;
         this.jvmciEnv = jvmciEnv;
-        this.hasUnsafeAccess = compResult.hasUnsafeAccess();
+        this.hasUnsafeAccess = hasUnsafeAccess;
     }
 
     @Override
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java	Wed Jan 20 16:33:51 2016 +0100
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java	Wed Jan 20 14:22:46 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, 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
@@ -38,7 +38,7 @@
 import java.util.TreeMap;
 
 import jdk.vm.ci.code.Architecture;
-import jdk.vm.ci.code.CompilationResult;
+import jdk.vm.ci.code.CompiledCode;
 import jdk.vm.ci.code.InstalledCode;
 import jdk.vm.ci.common.JVMCIError;
 import jdk.vm.ci.inittimer.InitTimer;
@@ -348,11 +348,11 @@
      *
      * @param hotSpotCodeCacheProvider
      * @param installedCode
-     * @param compResult
+     * @param compiledCode
      */
-    void notifyInstall(HotSpotCodeCacheProvider hotSpotCodeCacheProvider, InstalledCode installedCode, CompilationResult compResult) {
+    void notifyInstall(HotSpotCodeCacheProvider hotSpotCodeCacheProvider, InstalledCode installedCode, CompiledCode compiledCode) {
         for (HotSpotVMEventListener vmEventListener : vmEventListeners) {
-            vmEventListener.notifyInstall(hotSpotCodeCacheProvider, installedCode, compResult);
+            vmEventListener.notifyInstall(hotSpotCodeCacheProvider, installedCode, compiledCode);
         }
     }
 
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMEventListener.java	Wed Jan 20 16:33:51 2016 +0100
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMEventListener.java	Wed Jan 20 14:22:46 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, 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
@@ -22,7 +22,7 @@
  */
 package jdk.vm.ci.hotspot;
 
-import jdk.vm.ci.code.CompilationResult;
+import jdk.vm.ci.code.CompiledCode;
 import jdk.vm.ci.code.InstalledCode;
 import jdk.vm.ci.meta.JVMCIMetaAccessContext;
 import jdk.vm.ci.meta.ResolvedJavaType;
@@ -40,9 +40,9 @@
      *
      * @param hotSpotCodeCacheProvider
      * @param installedCode
-     * @param compResult
+     * @param compiledCode
      */
-    default void notifyInstall(HotSpotCodeCacheProvider hotSpotCodeCacheProvider, InstalledCode installedCode, CompilationResult compResult) {
+    default void notifyInstall(HotSpotCodeCacheProvider hotSpotCodeCacheProvider, InstalledCode installedCode, CompiledCode compiledCode) {
     }
 
     /**
--- a/hotspot/src/share/vm/jvmci/jvmciCodeInstaller.cpp	Wed Jan 20 16:33:51 2016 +0100
+++ b/hotspot/src/share/vm/jvmci/jvmciCodeInstaller.cpp	Wed Jan 20 14:22:46 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, 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
@@ -489,7 +489,6 @@
   if (result != JVMCIEnv::ok) {
     return result;
   }
-  process_exception_handlers();
 
   _debug_recorder->pcs_size(); // ehm, create the sentinel record
 
@@ -523,7 +522,6 @@
   if (result != JVMCIEnv::ok) {
     return result;
   }
-  process_exception_handlers();
 
   int stack_slots = _total_frame_size / HeapWordSize; // conversion to words
 
@@ -574,7 +572,6 @@
     _parameter_count = 0;
   }
   _sites_handle = JNIHandles::make_local(HotSpotCompiledCode::sites(compiled_code));
-  _exception_handlers_handle = JNIHandles::make_local(HotSpotCompiledCode::exceptionHandlers(compiled_code));
 
   _code_handle = JNIHandles::make_local(HotSpotCompiledCode::targetCode(compiled_code));
   _code_size = HotSpotCompiledCode::targetCodeSize(compiled_code);
@@ -608,8 +605,8 @@
   objArrayOop sites = this->sites();
   for (int i = 0; i < sites->length(); i++) {
     oop site = sites->obj_at(i);
-    if (site != NULL && site->is_a(CompilationResult_Mark::klass())) {
-      oop id_obj = CompilationResult_Mark::id(site);
+    if (site != NULL && site->is_a(site_Mark::klass())) {
+      oop id_obj = site_Mark::id(site);
       if (id_obj != NULL) {
         if (!java_lang_boxing_object::is_instance(id_obj, T_INT)) {
           JVMCI_ERROR_0("expected Integer id, got %s", id_obj->klass()->signature_name());
@@ -669,18 +666,18 @@
     if (patch.is_null()) {
       THROW_(vmSymbols::java_lang_NullPointerException(), JVMCIEnv::ok);
     }
-    Handle reference = CompilationResult_DataPatch::reference(patch);
+    Handle reference = site_DataPatch::reference(patch);
     if (reference.is_null()) {
       THROW_(vmSymbols::java_lang_NullPointerException(), JVMCIEnv::ok);
     }
-    if (!reference->is_a(CompilationResult_ConstantReference::klass())) {
+    if (!reference->is_a(site_ConstantReference::klass())) {
       JVMCI_ERROR_OK("invalid patch in data section: %s", reference->klass()->signature_name());
     }
-    Handle constant = CompilationResult_ConstantReference::constant(reference);
+    Handle constant = site_ConstantReference::constant(reference);
     if (constant.is_null()) {
       THROW_(vmSymbols::java_lang_NullPointerException(), JVMCIEnv::ok);
     }
-    address dest = _constants->start() + CompilationResult_Site::pcOffset(patch);
+    address dest = _constants->start() + site_Site::pcOffset(patch);
     if (constant->is_a(HotSpotMetaspaceConstantImpl::klass())) {
       if (HotSpotMetaspaceConstantImpl::compressed(constant)) {
 #ifdef _LP64
@@ -716,27 +713,30 @@
       THROW_(vmSymbols::java_lang_NullPointerException(), JVMCIEnv::ok);
     }
 
-    jint pc_offset = CompilationResult_Site::pcOffset(site);
+    jint pc_offset = site_Site::pcOffset(site);
 
-    if (site->is_a(CompilationResult_Call::klass())) {
+    if (site->is_a(site_Call::klass())) {
       TRACE_jvmci_4("call at %i", pc_offset);
       site_Call(buffer, pc_offset, site, CHECK_OK);
-    } else if (site->is_a(CompilationResult_Infopoint::klass())) {
+    } else if (site->is_a(site_Infopoint::klass())) {
       // three reasons for infopoints denote actual safepoints
-      oop reason = CompilationResult_Infopoint::reason(site);
-      if (InfopointReason::SAFEPOINT() == reason || InfopointReason::CALL() == reason || InfopointReason::IMPLICIT_EXCEPTION() == reason) {
+      oop reason = site_Infopoint::reason(site);
+      if (site_InfopointReason::SAFEPOINT() == reason || site_InfopointReason::CALL() == reason || site_InfopointReason::IMPLICIT_EXCEPTION() == reason) {
         TRACE_jvmci_4("safepoint at %i", pc_offset);
         site_Safepoint(buffer, pc_offset, site, CHECK_OK);
       } else {
         TRACE_jvmci_4("infopoint at %i", pc_offset);
         site_Infopoint(buffer, pc_offset, site, CHECK_OK);
       }
-    } else if (site->is_a(CompilationResult_DataPatch::klass())) {
+    } else if (site->is_a(site_DataPatch::klass())) {
       TRACE_jvmci_4("datapatch at %i", pc_offset);
       site_DataPatch(buffer, pc_offset, site, CHECK_OK);
-    } else if (site->is_a(CompilationResult_Mark::klass())) {
+    } else if (site->is_a(site_Mark::klass())) {
       TRACE_jvmci_4("mark at %i", pc_offset);
       site_Mark(buffer, pc_offset, site, CHECK_OK);
+    } else if (site->is_a(site_ExceptionHandler::klass())) {
+      TRACE_jvmci_4("exceptionhandler at %i", pc_offset);
+      site_ExceptionHandler(pc_offset, site);
     } else {
       JVMCI_ERROR_OK("unexpected site subclass: %s", site->klass()->signature_name());
     }
@@ -802,21 +802,14 @@
   _dependencies->assert_call_site_target_value(callSite(), methodHandle());
 }
 
-void CodeInstaller::process_exception_handlers() {
-  if (exception_handlers() != NULL) {
-    objArrayOop handlers = exception_handlers();
-    for (int i = 0; i < handlers->length(); i++) {
-      oop exc = handlers->obj_at(i);
-      jint pc_offset = CompilationResult_Site::pcOffset(exc);
-      jint handler_offset = CompilationResult_ExceptionHandler::handlerPos(exc);
+void CodeInstaller::site_ExceptionHandler(jint pc_offset, Handle exc) {
+  jint handler_offset = site_ExceptionHandler::handlerPos(exc);
 
-      // Subtable header
-      _exception_handler_table.add_entry(HandlerTableEntry(1, pc_offset, 0));
+  // Subtable header
+  _exception_handler_table.add_entry(HandlerTableEntry(1, pc_offset, 0));
 
-      // Subtable entry
-      _exception_handler_table.add_entry(HandlerTableEntry(-1, handler_offset, 0));
-    }
-  }
+  // Subtable entry
+  _exception_handler_table.add_entry(HandlerTableEntry(-1, handler_offset, 0));
 }
 
 // If deoptimization happens, the interpreter should reexecute these bytecodes.
@@ -988,7 +981,7 @@
 }
 
 void CodeInstaller::site_Safepoint(CodeBuffer& buffer, jint pc_offset, Handle site, TRAPS) {
-  Handle debug_info = CompilationResult_Infopoint::debugInfo(site);
+  Handle debug_info = site_Infopoint::debugInfo(site);
   if (debug_info.is_null()) {
     JVMCI_ERROR("debug info expected at safepoint at %i", pc_offset);
   }
@@ -1002,7 +995,7 @@
 }
 
 void CodeInstaller::site_Infopoint(CodeBuffer& buffer, jint pc_offset, Handle site, TRAPS) {
-  Handle debug_info = CompilationResult_Infopoint::debugInfo(site);
+  Handle debug_info = site_Infopoint::debugInfo(site);
   if (debug_info.is_null()) {
     JVMCI_ERROR("debug info expected at infopoint at %i", pc_offset);
   }
@@ -1017,7 +1010,7 @@
 }
 
 void CodeInstaller::site_Call(CodeBuffer& buffer, jint pc_offset, Handle site, TRAPS) {
-  Handle target = CompilationResult_Call::target(site);
+  Handle target = site_Call::target(site);
   InstanceKlass* target_klass = InstanceKlass::cast(target->klass());
 
   Handle hotspot_method; // JavaMethod
@@ -1029,7 +1022,7 @@
     hotspot_method = target;
   }
 
-  Handle debug_info = CompilationResult_Call::debugInfo(site);
+  Handle debug_info = site_Call::debugInfo(site);
 
   assert(hotspot_method.not_null() ^ foreign_call.not_null(), "Call site needs exactly one type");
 
@@ -1066,11 +1059,11 @@
 }
 
 void CodeInstaller::site_DataPatch(CodeBuffer& buffer, jint pc_offset, Handle site, TRAPS) {
-  Handle reference = CompilationResult_DataPatch::reference(site);
+  Handle reference = site_DataPatch::reference(site);
   if (reference.is_null()) {
     THROW(vmSymbols::java_lang_NullPointerException());
-  } else if (reference->is_a(CompilationResult_ConstantReference::klass())) {
-    Handle constant = CompilationResult_ConstantReference::constant(reference);
+  } else if (reference->is_a(site_ConstantReference::klass())) {
+    Handle constant = site_ConstantReference::constant(reference);
     if (constant.is_null()) {
       THROW(vmSymbols::java_lang_NullPointerException());
     } else if (constant->is_a(HotSpotObjectConstantImpl::klass())) {
@@ -1080,8 +1073,8 @@
     } else {
       JVMCI_ERROR("unknown constant type in data patch: %s", constant->klass()->signature_name());
     }
-  } else if (reference->is_a(CompilationResult_DataSectionReference::klass())) {
-    int data_offset = CompilationResult_DataSectionReference::offset(reference);
+  } else if (reference->is_a(site_DataSectionReference::klass())) {
+    int data_offset = site_DataSectionReference::offset(reference);
     if (0 <= data_offset && data_offset < _constants_size) {
       pd_patch_DataSectionReference(pc_offset, data_offset);
     } else {
@@ -1093,7 +1086,7 @@
 }
 
 void CodeInstaller::site_Mark(CodeBuffer& buffer, jint pc_offset, Handle site, TRAPS) {
-  Handle id_obj = CompilationResult_Mark::id(site);
+  Handle id_obj = site_Mark::id(site);
 
   if (id_obj.not_null()) {
     if (!java_lang_boxing_object::is_instance(id_obj(), T_INT)) {
--- a/hotspot/src/share/vm/jvmci/jvmciCodeInstaller.hpp	Wed Jan 20 16:33:51 2016 +0100
+++ b/hotspot/src/share/vm/jvmci/jvmciCodeInstaller.hpp	Wed Jan 20 14:22:46 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, 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
@@ -120,7 +120,6 @@
   jobject       _data_section_handle;
   jobject       _data_section_patches_handle;
   jobject       _sites_handle;
-  jobject       _exception_handlers_handle;
   CodeOffsets   _offsets;
 
   jobject       _code_handle;
@@ -166,7 +165,6 @@
   arrayOop code() { return (arrayOop) JNIHandles::resolve(_code_handle); }
   arrayOop data_section() { return (arrayOop) JNIHandles::resolve(_data_section_handle); }
   objArrayOop data_section_patches() { return (objArrayOop) JNIHandles::resolve(_data_section_patches_handle); }
-  objArrayOop exception_handlers() { return (objArrayOop) JNIHandles::resolve(_exception_handlers_handle); }
 #ifndef PRODUCT
   objArrayOop comments() { return (objArrayOop) JNIHandles::resolve(_comments_handle); }
 #endif
@@ -196,7 +194,7 @@
   narrowKlass record_narrow_metadata_reference(Handle constant, TRAPS);
 #endif
 
-  // extract the fields of the CompilationResult
+  // extract the fields of the HotSpotCompiledCode
   void initialize_fields(oop target, oop target_method, TRAPS);
   void initialize_dependencies(oop target_method, OopRecorder* oop_recorder, TRAPS);
 
@@ -216,6 +214,7 @@
   void site_Call(CodeBuffer& buffer, jint pc_offset, Handle site, TRAPS);
   void site_DataPatch(CodeBuffer& buffer, jint pc_offset, Handle site, TRAPS);
   void site_Mark(CodeBuffer& buffer, jint pc_offset, Handle site, TRAPS);
+  void site_ExceptionHandler(jint pc_offset, Handle site);
 
   OopMap* create_oop_map(Handle debug_info, TRAPS);
 
@@ -235,7 +234,6 @@
 
   GrowableArray<ScopeValue*>* record_virtual_objects(Handle debug_info, TRAPS);
 
-  void process_exception_handlers();
   int estimateStubSpace(int static_call_stubs);
 };
 
--- a/hotspot/src/share/vm/jvmci/jvmciJavaClasses.hpp	Wed Jan 20 16:33:51 2016 +0100
+++ b/hotspot/src/share/vm/jvmci/jvmciJavaClasses.hpp	Wed Jan 20 14:22:46 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, 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
@@ -79,19 +79,18 @@
   end_class                                                                                                                                                    \
   start_class(HotSpotCompiledCode)                                                                                                                             \
     oop_field(HotSpotCompiledCode, name, "Ljava/lang/String;")                                                                                                 \
-    objArrayOop_field(HotSpotCompiledCode, sites, "[Ljdk/vm/ci/code/CompilationResult$Site;")                                                                  \
-    objArrayOop_field(HotSpotCompiledCode, exceptionHandlers, "[Ljdk/vm/ci/code/CompilationResult$ExceptionHandler;")                                          \
-    objArrayOop_field(HotSpotCompiledCode, comments, "[Ljdk/vm/ci/hotspot/HotSpotCompiledCode$Comment;")                                                       \
-    objArrayOop_field(HotSpotCompiledCode, assumptions, "[Ljdk/vm/ci/meta/Assumptions$Assumption;")                                                            \
     typeArrayOop_field(HotSpotCompiledCode, targetCode, "[B")                                                                                                  \
     int_field(HotSpotCompiledCode, targetCodeSize)                                                                                                             \
+    objArrayOop_field(HotSpotCompiledCode, sites, "[Ljdk/vm/ci/code/site/Site;")                                                                               \
+    objArrayOop_field(HotSpotCompiledCode, assumptions, "[Ljdk/vm/ci/meta/Assumptions$Assumption;")                                                            \
+    objArrayOop_field(HotSpotCompiledCode, methods, "[Ljdk/vm/ci/meta/ResolvedJavaMethod;")                                                                    \
+    objArrayOop_field(HotSpotCompiledCode, comments, "[Ljdk/vm/ci/hotspot/HotSpotCompiledCode$Comment;")                                                       \
     typeArrayOop_field(HotSpotCompiledCode, dataSection, "[B")                                                                                                 \
     int_field(HotSpotCompiledCode, dataSectionAlignment)                                                                                                       \
-    objArrayOop_field(HotSpotCompiledCode, dataSectionPatches, "[Ljdk/vm/ci/code/CompilationResult$DataPatch;")                                                \
+    objArrayOop_field(HotSpotCompiledCode, dataSectionPatches, "[Ljdk/vm/ci/code/site/DataPatch;")                                                             \
     boolean_field(HotSpotCompiledCode, isImmutablePIC)                                                                                                         \
     int_field(HotSpotCompiledCode, totalFrameSize)                                                                                                             \
     int_field(HotSpotCompiledCode, customStackAreaOffset)                                                                                                      \
-    objArrayOop_field(HotSpotCompiledCode, methods, "[Ljdk/vm/ci/meta/ResolvedJavaMethod;")                                                                    \
   end_class                                                                                                                                                    \
   start_class(HotSpotCompiledCode_Comment)                                                                                                                     \
     oop_field(HotSpotCompiledCode_Comment, text, "Ljava/lang/String;")                                                                                         \
@@ -131,36 +130,36 @@
     oop_field(Assumptions_CallSiteTargetValue, callSite, "Ljava/lang/invoke/CallSite;")                                                                        \
     oop_field(Assumptions_CallSiteTargetValue, methodHandle, "Ljava/lang/invoke/MethodHandle;")                                                                \
   end_class                                                                                                                                                    \
-  start_class(CompilationResult_Site)                                                                                                                          \
-    int_field(CompilationResult_Site, pcOffset)                                                                                                                \
+  start_class(site_Site)                                                                                                                                       \
+    int_field(site_Site, pcOffset)                                                                                                                             \
   end_class                                                                                                                                                    \
-  start_class(CompilationResult_Call)                                                                                                                          \
-    oop_field(CompilationResult_Call, target, "Ljdk/vm/ci/meta/InvokeTarget;")                                                                                 \
-    oop_field(CompilationResult_Call, debugInfo, "Ljdk/vm/ci/code/DebugInfo;")                                                                                 \
+  start_class(site_Call)                                                                                                                                       \
+    oop_field(site_Call, target, "Ljdk/vm/ci/meta/InvokeTarget;")                                                                                              \
+    oop_field(site_Call, debugInfo, "Ljdk/vm/ci/code/DebugInfo;")                                                                                              \
   end_class                                                                                                                                                    \
-  start_class(CompilationResult_DataPatch)                                                                                                                     \
-    oop_field(CompilationResult_DataPatch, reference, "Ljdk/vm/ci/code/CompilationResult$Reference;")                                                          \
+  start_class(site_DataPatch)                                                                                                                                  \
+    oop_field(site_DataPatch, reference, "Ljdk/vm/ci/code/site/Reference;")                                                                                    \
   end_class                                                                                                                                                    \
-  start_class(CompilationResult_ConstantReference)                                                                                                             \
-    oop_field(CompilationResult_ConstantReference, constant, "Ljdk/vm/ci/meta/VMConstant;")                                                                    \
+  start_class(site_ConstantReference)                                                                                                                          \
+    oop_field(site_ConstantReference, constant, "Ljdk/vm/ci/meta/VMConstant;")                                                                                 \
   end_class                                                                                                                                                    \
-  start_class(CompilationResult_DataSectionReference)                                                                                                          \
-    int_field(CompilationResult_DataSectionReference, offset)                                                                                                  \
+  start_class(site_DataSectionReference)                                                                                                                       \
+    int_field(site_DataSectionReference, offset)                                                                                                               \
   end_class                                                                                                                                                    \
-  start_class(InfopointReason)                                                                                                                                 \
-    static_oop_field(InfopointReason, SAFEPOINT, "Ljdk/vm/ci/code/InfopointReason;")                                                                           \
-    static_oop_field(InfopointReason, CALL, "Ljdk/vm/ci/code/InfopointReason;")                                                                                \
-    static_oop_field(InfopointReason, IMPLICIT_EXCEPTION, "Ljdk/vm/ci/code/InfopointReason;")                                                                  \
+  start_class(site_InfopointReason)                                                                                                                            \
+    static_oop_field(site_InfopointReason, SAFEPOINT, "Ljdk/vm/ci/code/site/InfopointReason;")                                                                 \
+    static_oop_field(site_InfopointReason, CALL, "Ljdk/vm/ci/code/site/InfopointReason;")                                                                      \
+    static_oop_field(site_InfopointReason, IMPLICIT_EXCEPTION, "Ljdk/vm/ci/code/site/InfopointReason;")                                                        \
   end_class                                                                                                                                                    \
-  start_class(CompilationResult_Infopoint)                                                                                                                     \
-    oop_field(CompilationResult_Infopoint, debugInfo, "Ljdk/vm/ci/code/DebugInfo;")                                                                            \
-    oop_field(CompilationResult_Infopoint, reason, "Ljdk/vm/ci/code/InfopointReason;")                                                                         \
+  start_class(site_Infopoint)                                                                                                                                  \
+    oop_field(site_Infopoint, debugInfo, "Ljdk/vm/ci/code/DebugInfo;")                                                                                         \
+    oop_field(site_Infopoint, reason, "Ljdk/vm/ci/code/site/InfopointReason;")                                                                                 \
   end_class                                                                                                                                                    \
-  start_class(CompilationResult_ExceptionHandler)                                                                                                              \
-    int_field(CompilationResult_ExceptionHandler, handlerPos)                                                                                                  \
+  start_class(site_ExceptionHandler)                                                                                                                           \
+    int_field(site_ExceptionHandler, handlerPos)                                                                                                               \
   end_class                                                                                                                                                    \
-  start_class(CompilationResult_Mark)                                                                                                                          \
-    oop_field(CompilationResult_Mark, id, "Ljava/lang/Object;")                                                                                                \
+  start_class(site_Mark)                                                                                                                                       \
+    oop_field(site_Mark, id, "Ljava/lang/Object;")                                                                                                             \
   end_class                                                                                                                                                    \
   start_class(DebugInfo)                                                                                                                                       \
     oop_field(DebugInfo, bytecodePosition, "Ljdk/vm/ci/code/BytecodePosition;")                                                                                \
--- a/hotspot/src/share/vm/jvmci/systemDictionary_jvmci.hpp	Wed Jan 20 16:33:51 2016 +0100
+++ b/hotspot/src/share/vm/jvmci/systemDictionary_jvmci.hpp	Wed Jan 20 14:22:46 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016, 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
@@ -60,15 +60,6 @@
   do_klass(DebugInfo_klass,                              jdk_vm_ci_code_DebugInfo,                              Jvmci) \
   do_klass(RegisterSaveLayout_klass,                     jdk_vm_ci_code_RegisterSaveLayout,                     Jvmci) \
   do_klass(BytecodeFrame_klass,                          jdk_vm_ci_code_BytecodeFrame,                          Jvmci) \
-  do_klass(CompilationResult_Call_klass,                 jdk_vm_ci_code_CompilationResult_Call,                 Jvmci) \
-  do_klass(CompilationResult_ConstantReference_klass,    jdk_vm_ci_code_CompilationResult_ConstantReference,    Jvmci) \
-  do_klass(CompilationResult_DataPatch_klass,            jdk_vm_ci_code_CompilationResult_DataPatch,            Jvmci) \
-  do_klass(CompilationResult_DataSectionReference_klass, jdk_vm_ci_code_CompilationResult_DataSectionReference, Jvmci) \
-  do_klass(CompilationResult_ExceptionHandler_klass,     jdk_vm_ci_code_CompilationResult_ExceptionHandler,     Jvmci) \
-  do_klass(CompilationResult_Mark_klass,                 jdk_vm_ci_code_CompilationResult_Mark,                 Jvmci) \
-  do_klass(CompilationResult_Infopoint_klass,            jdk_vm_ci_code_CompilationResult_Infopoint,            Jvmci) \
-  do_klass(CompilationResult_Site_klass,                 jdk_vm_ci_code_CompilationResult_Site,                 Jvmci) \
-  do_klass(InfopointReason_klass,                        jdk_vm_ci_code_InfopointReason,                        Jvmci) \
   do_klass(InstalledCode_klass,                          jdk_vm_ci_code_InstalledCode,                          Jvmci) \
   do_klass(code_Location_klass,                          jdk_vm_ci_code_Location,                               Jvmci) \
   do_klass(code_Register_klass,                          jdk_vm_ci_code_Register,                               Jvmci) \
@@ -76,6 +67,15 @@
   do_klass(StackSlot_klass,                              jdk_vm_ci_code_StackSlot,                              Jvmci) \
   do_klass(StackLockValue_klass,                         jdk_vm_ci_code_StackLockValue,                         Jvmci) \
   do_klass(VirtualObject_klass,                          jdk_vm_ci_code_VirtualObject,                          Jvmci) \
+  do_klass(site_Call_klass,                              jdk_vm_ci_code_site_Call,                              Jvmci) \
+  do_klass(site_ConstantReference_klass,                 jdk_vm_ci_code_site_ConstantReference,                 Jvmci) \
+  do_klass(site_DataPatch_klass,                         jdk_vm_ci_code_site_DataPatch,                         Jvmci) \
+  do_klass(site_DataSectionReference_klass,              jdk_vm_ci_code_site_DataSectionReference,              Jvmci) \
+  do_klass(site_ExceptionHandler_klass,                  jdk_vm_ci_code_site_ExceptionHandler,                  Jvmci) \
+  do_klass(site_Mark_klass,                              jdk_vm_ci_code_site_Mark,                              Jvmci) \
+  do_klass(site_Infopoint_klass,                         jdk_vm_ci_code_site_Infopoint,                         Jvmci) \
+  do_klass(site_Site_klass,                              jdk_vm_ci_code_site_Site,                              Jvmci) \
+  do_klass(site_InfopointReason_klass,                   jdk_vm_ci_code_site_InfopointReason,                   Jvmci) \
   do_klass(JavaConstant_klass,                           jdk_vm_ci_meta_JavaConstant,                           Jvmci) \
   do_klass(PrimitiveConstant_klass,                      jdk_vm_ci_meta_PrimitiveConstant,                      Jvmci) \
   do_klass(RawConstant_klass,                            jdk_vm_ci_meta_RawConstant,                            Jvmci) \
--- a/hotspot/src/share/vm/jvmci/vmSymbols_jvmci.hpp	Wed Jan 20 16:33:51 2016 +0100
+++ b/hotspot/src/share/vm/jvmci/vmSymbols_jvmci.hpp	Wed Jan 20 14:22:46 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016, 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
@@ -64,28 +64,28 @@
   template(jdk_vm_ci_meta_Assumptions_ConcreteMethod,             "jdk/vm/ci/meta/Assumptions$ConcreteMethod")             \
   template(jdk_vm_ci_meta_Assumptions_CallSiteTargetValue,        "jdk/vm/ci/meta/Assumptions$CallSiteTargetValue")        \
   template(jdk_vm_ci_code_Architecture,                           "jdk/vm/ci/code/Architecture")                           \
-  template(jdk_vm_ci_code_TargetDescription,                      "jdk/vm/ci/code/TargetDescription")                      \
-  template(jdk_vm_ci_code_CompilationResult_Call,                 "jdk/vm/ci/code/CompilationResult$Call")                 \
-  template(jdk_vm_ci_code_CompilationResult_ConstantReference,    "jdk/vm/ci/code/CompilationResult$ConstantReference")    \
-  template(jdk_vm_ci_code_CompilationResult_DataPatch,            "jdk/vm/ci/code/CompilationResult$DataPatch")            \
-  template(jdk_vm_ci_code_CompilationResult_DataSectionReference, "jdk/vm/ci/code/CompilationResult$DataSectionReference") \
-  template(jdk_vm_ci_code_CompilationResult_ExceptionHandler,     "jdk/vm/ci/code/CompilationResult$ExceptionHandler")     \
-  template(jdk_vm_ci_code_CompilationResult_Mark,                 "jdk/vm/ci/code/CompilationResult$Mark")                 \
-  template(jdk_vm_ci_code_CompilationResult_Infopoint,            "jdk/vm/ci/code/CompilationResult$Infopoint")            \
-  template(jdk_vm_ci_code_CompilationResult_Site,                 "jdk/vm/ci/code/CompilationResult$Site")                 \
-  template(jdk_vm_ci_code_InfopointReason,                        "jdk/vm/ci/code/InfopointReason")                        \
-  template(jdk_vm_ci_code_InstalledCode,                          "jdk/vm/ci/code/InstalledCode")                          \
   template(jdk_vm_ci_code_BytecodeFrame,                          "jdk/vm/ci/code/BytecodeFrame")                          \
   template(jdk_vm_ci_code_BytecodePosition,                       "jdk/vm/ci/code/BytecodePosition")                       \
   template(jdk_vm_ci_code_DebugInfo,                              "jdk/vm/ci/code/DebugInfo")                              \
+  template(jdk_vm_ci_code_InstalledCode,                          "jdk/vm/ci/code/InstalledCode")                          \
   template(jdk_vm_ci_code_Location,                               "jdk/vm/ci/code/Location")                               \
   template(jdk_vm_ci_code_Register,                               "jdk/vm/ci/code/Register")                               \
   template(jdk_vm_ci_code_RegisterValue,                          "jdk/vm/ci/code/RegisterValue")                          \
   template(jdk_vm_ci_code_StackSlot,                              "jdk/vm/ci/code/StackSlot")                              \
   template(jdk_vm_ci_code_StackLockValue,                         "jdk/vm/ci/code/StackLockValue")                         \
+  template(jdk_vm_ci_code_TargetDescription,                      "jdk/vm/ci/code/TargetDescription")                      \
   template(jdk_vm_ci_code_VirtualObject,                          "jdk/vm/ci/code/VirtualObject")                          \
   template(jdk_vm_ci_code_RegisterSaveLayout,                     "jdk/vm/ci/code/RegisterSaveLayout")                     \
   template(jdk_vm_ci_code_InvalidInstalledCodeException,          "jdk/vm/ci/code/InvalidInstalledCodeException")          \
+  template(jdk_vm_ci_code_site_Call,                              "jdk/vm/ci/code/site/Call")                              \
+  template(jdk_vm_ci_code_site_ConstantReference,                 "jdk/vm/ci/code/site/ConstantReference")                 \
+  template(jdk_vm_ci_code_site_DataPatch,                         "jdk/vm/ci/code/site/DataPatch")                         \
+  template(jdk_vm_ci_code_site_DataSectionReference,              "jdk/vm/ci/code/site/DataSectionReference")              \
+  template(jdk_vm_ci_code_site_ExceptionHandler,                  "jdk/vm/ci/code/site/ExceptionHandler")                  \
+  template(jdk_vm_ci_code_site_Mark,                              "jdk/vm/ci/code/site/Mark")                              \
+  template(jdk_vm_ci_code_site_Infopoint,                         "jdk/vm/ci/code/site/Infopoint")                         \
+  template(jdk_vm_ci_code_site_Site,                              "jdk/vm/ci/code/site/Site")                              \
+  template(jdk_vm_ci_code_site_InfopointReason,                   "jdk/vm/ci/code/site/InfopointReason")                   \
   template(jdk_vm_ci_common_JVMCIError,                           "jdk/vm/ci/common/JVMCIError")                           \
   template(compileMethod_name,                                    "compileMethod")                                         \
   template(compileMethod_signature,                               "(Ljdk/vm/ci/hotspot/HotSpotResolvedJavaMethod;IJI)V")   \
--- a/hotspot/test/compiler/jvmci/code/CodeInstallationTest.java	Wed Jan 20 16:33:51 2016 +0100
+++ b/hotspot/test/compiler/jvmci/code/CodeInstallationTest.java	Wed Jan 20 14:22:46 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, 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
@@ -27,12 +27,12 @@
 import jdk.vm.ci.amd64.AMD64;
 import jdk.vm.ci.code.Architecture;
 import jdk.vm.ci.code.CodeCacheProvider;
-import jdk.vm.ci.code.CompilationResult;
 import jdk.vm.ci.code.InstalledCode;
 import jdk.vm.ci.code.TargetDescription;
+import jdk.vm.ci.hotspot.HotSpotCompiledCode;
+import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod;
 import jdk.vm.ci.meta.ConstantReflectionProvider;
 import jdk.vm.ci.meta.MetaAccessProvider;
-import jdk.vm.ci.meta.ResolvedJavaMethod;
 import jdk.vm.ci.runtime.JVMCI;
 import jdk.vm.ci.runtime.JVMCIBackend;
 import jdk.vm.ci.sparc.SPARC;
@@ -65,12 +65,12 @@
         void compile(TestAssembler asm);
     }
 
-    private TestAssembler createAssembler(CompilationResult result) {
+    private TestAssembler createAssembler() {
         Architecture arch = codeCache.getTarget().arch;
         if (arch instanceof AMD64) {
-            return new AMD64TestAssembler(result, codeCache);
+            return new AMD64TestAssembler(codeCache);
         } else if (arch instanceof SPARC) {
-            return new SPARCTestAssembler(result, codeCache);
+            return new SPARCTestAssembler(codeCache);
         } else {
             Assert.fail("unsupported architecture");
             return null;
@@ -87,17 +87,14 @@
     }
 
     protected void test(TestCompiler compiler, Method method, Object... args) {
-        CompilationResult result = new CompilationResult(method.getName());
-        TestAssembler asm = createAssembler(result);
+        HotSpotResolvedJavaMethod resolvedMethod = (HotSpotResolvedJavaMethod) metaAccess.lookupJavaMethod(method);
+        TestAssembler asm = createAssembler();
 
         asm.emitPrologue();
         compiler.compile(asm);
-        asm.finish();
 
-        result.close();
-
-        ResolvedJavaMethod resolvedMethod = metaAccess.lookupJavaMethod(method);
-        InstalledCode installed = codeCache.addCode(resolvedMethod, result, null, null);
+        HotSpotCompiledCode code = asm.finish(resolvedMethod);
+        InstalledCode installed = codeCache.addCode(resolvedMethod, code, null, null);
 
         try {
             Object expected = method.invoke(null, args);
--- a/hotspot/test/compiler/jvmci/code/DataPatchTest.java	Wed Jan 20 16:33:51 2016 +0100
+++ b/hotspot/test/compiler/jvmci/code/DataPatchTest.java	Wed Jan 20 14:22:46 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, 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
@@ -30,9 +30,8 @@
 
 package compiler.jvmci.code;
 
-import jdk.vm.ci.code.CompilationResult.DataSectionReference;
-import jdk.vm.ci.code.DataSection.Data;
 import jdk.vm.ci.code.Register;
+import jdk.vm.ci.code.site.DataSectionReference;
 import jdk.vm.ci.hotspot.HotSpotConstant;
 import jdk.vm.ci.hotspot.HotSpotVMConfig;
 import jdk.vm.ci.meta.ResolvedJavaType;
@@ -53,7 +52,6 @@
         test(compiler, getMethod("getConstClass"));
     }
 
-
     @Test
     public void testInlineObject() {
         test(asm -> {
@@ -81,8 +79,7 @@
         test(asm -> {
             ResolvedJavaType type = metaAccess.lookupJavaType(getConstClass());
             HotSpotConstant c = (HotSpotConstant) type.getJavaClass();
-            Data data = codeCache.createDataItem(c);
-            DataSectionReference ref = asm.result.getDataSection().insertData(data);
+            DataSectionReference ref = asm.emitDataItem(c);
             Register ret = asm.emitLoadPointer(ref);
             asm.emitPointerRet(ret);
         });
@@ -95,8 +92,7 @@
             ResolvedJavaType type = metaAccess.lookupJavaType(getConstClass());
             HotSpotConstant c = (HotSpotConstant) type.getJavaClass();
             HotSpotConstant cCompressed = (HotSpotConstant) c.compress();
-            Data data = codeCache.createDataItem(cCompressed);
-            DataSectionReference ref = asm.result.getDataSection().insertData(data);
+            DataSectionReference ref = asm.emitDataItem(cCompressed);
             Register compressed = asm.emitLoadNarrowPointer(ref);
             Register ret = asm.emitUncompressPointer(compressed, HotSpotVMConfig.config().narrowOopBase, HotSpotVMConfig.config().narrowOopShift);
             asm.emitPointerRet(ret);
@@ -131,8 +127,7 @@
         test(asm -> {
             ResolvedJavaType type = metaAccess.lookupJavaType(getConstClass());
             HotSpotConstant hub = (HotSpotConstant) type.getObjectHub();
-            Data data = codeCache.createDataItem(hub);
-            DataSectionReference ref = asm.result.getDataSection().insertData(data);
+            DataSectionReference ref = asm.emitDataItem(hub);
             Register klass = asm.emitLoadPointer(ref);
             Register ret = asm.emitLoadPointer(klass, HotSpotVMConfig.config().classMirrorOffset);
             asm.emitPointerRet(ret);
@@ -146,8 +141,7 @@
             ResolvedJavaType type = metaAccess.lookupJavaType(getConstClass());
             HotSpotConstant hub = (HotSpotConstant) type.getObjectHub();
             HotSpotConstant narrowHub = (HotSpotConstant) hub.compress();
-            Data data = codeCache.createDataItem(narrowHub);
-            DataSectionReference ref = asm.result.getDataSection().insertData(data);
+            DataSectionReference ref = asm.emitDataItem(narrowHub);
             Register narrowKlass = asm.emitLoadNarrowPointer(ref);
             Register klass = asm.emitUncompressPointer(narrowKlass, HotSpotVMConfig.config().narrowKlassBase, HotSpotVMConfig.config().narrowKlassShift);
             Register ret = asm.emitLoadPointer(klass, HotSpotVMConfig.config().classMirrorOffset);
--- a/hotspot/test/compiler/jvmci/code/TestAssembler.java	Wed Jan 20 16:33:51 2016 +0100
+++ b/hotspot/test/compiler/jvmci/code/TestAssembler.java	Wed Jan 20 14:22:46 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, 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
@@ -25,17 +25,30 @@
 
 import java.nio.ByteBuffer;
 import java.nio.ByteOrder;
+import java.util.ArrayList;
 import java.util.Arrays;
 
 import jdk.vm.ci.code.CodeCacheProvider;
-import jdk.vm.ci.code.CompilationResult;
-import jdk.vm.ci.code.CompilationResult.DataSectionReference;
 import jdk.vm.ci.code.DebugInfo;
 import jdk.vm.ci.code.Register;
 import jdk.vm.ci.code.StackSlot;
+import jdk.vm.ci.code.site.ConstantReference;
+import jdk.vm.ci.code.site.DataPatch;
+import jdk.vm.ci.code.site.DataSectionReference;
+import jdk.vm.ci.code.site.Infopoint;
+import jdk.vm.ci.code.site.InfopointReason;
+import jdk.vm.ci.code.site.Reference;
+import jdk.vm.ci.code.site.Site;
+import jdk.vm.ci.hotspot.HotSpotCompiledCode;
+import jdk.vm.ci.hotspot.HotSpotCompiledCode.Comment;
+import jdk.vm.ci.hotspot.HotSpotCompiledNmethod;
 import jdk.vm.ci.hotspot.HotSpotConstant;
+import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod;
+import jdk.vm.ci.meta.Assumptions.Assumption;
 import jdk.vm.ci.meta.LIRKind;
 import jdk.vm.ci.meta.PlatformKind;
+import jdk.vm.ci.meta.ResolvedJavaMethod;
+import jdk.vm.ci.meta.VMConstant;
 
 /**
  * Simple assembler used by the code installation tests.
@@ -49,6 +62,7 @@
 
     /**
      * Emit code to grow the stack frame.
+     *
      * @param size the size in bytes that the stack should grow
      */
     public abstract void emitGrowStack(int size);
@@ -84,18 +98,20 @@
     public abstract Register emitLoadFloat(float value);
 
     /**
-     * Emit code to load a constant oop or metaspace pointer to a register.
-     * The pointer may be wide or narrow, depending on {@link HotSpotConstant#isCompressed() c.isCompressed()}.
+     * Emit code to load a constant oop or metaspace pointer to a register. The pointer may be wide
+     * or narrow, depending on {@link HotSpotConstant#isCompressed() c.isCompressed()}.
      */
     public abstract Register emitLoadPointer(HotSpotConstant c);
 
     /**
-     * Emit code to load a wide pointer from the {@link DataSection} to a register.
+     * Emit code to load a wide pointer from the {@link HotSpotCompiledCode#dataSection} to a
+     * register.
      */
     public abstract Register emitLoadPointer(DataSectionReference ref);
 
     /**
-     * Emit code to load a narrow pointer from the {@link DataSection} to a register.
+     * Emit code to load a narrow pointer from the {@link HotSpotCompiledCode#dataSection} to a
+     * register.
      */
     public abstract Register emitLoadNarrowPointer(DataSectionReference ref);
 
@@ -149,14 +165,13 @@
      */
     public abstract void emitTrap(DebugInfo info);
 
-    protected int position() {
-        return data.position();
-    }
-
-    public final CompilationResult result;
     public final LIRKind narrowOopKind;
 
-    private ByteBuffer data;
+    protected final Buffer code;
+    protected final Buffer data;
+    private final ArrayList<Site> sites;
+    private final ArrayList<DataPatch> dataPatches;
+
     protected final CodeCacheProvider codeCache;
 
     private final Register[] registers;
@@ -166,11 +181,14 @@
     private int stackAlignment;
     private int curStackSlot;
 
-    protected TestAssembler(CompilationResult result, CodeCacheProvider codeCache, int initialFrameSize, int stackAlignment, PlatformKind narrowOopKind, Register... registers) {
-        this.result = result;
+    protected TestAssembler(CodeCacheProvider codeCache, int initialFrameSize, int stackAlignment, PlatformKind narrowOopKind, Register... registers) {
         this.narrowOopKind = LIRKind.reference(narrowOopKind);
 
-        this.data = ByteBuffer.allocate(32).order(ByteOrder.nativeOrder());
+        this.code = new Buffer();
+        this.data = new Buffer();
+        this.sites = new ArrayList<>();
+        this.dataPatches = new ArrayList<>();
+
         this.codeCache = codeCache;
 
         this.registers = registers;
@@ -198,38 +216,87 @@
         return StackSlot.get(kind, -curStackSlot, true);
     }
 
-    public void finish() {
-        result.setTotalFrameSize(frameSize);
-        result.setTargetCode(data.array(), data.position());
+    protected void recordImplicitException(DebugInfo info) {
+        sites.add(new Infopoint(code.position(), info, InfopointReason.IMPLICIT_EXCEPTION));
+    }
+
+    protected void recordDataPatchInCode(Reference ref) {
+        sites.add(new DataPatch(code.position(), ref));
+    }
+
+    protected void recordDataPatchInData(Reference ref) {
+        dataPatches.add(new DataPatch(data.position(), ref));
     }
 
-    private void ensureSize(int length) {
-        if (length >= data.limit()) {
-            byte[] newBuf = Arrays.copyOf(data.array(), length * 4);
-            ByteBuffer newData = ByteBuffer.wrap(newBuf);
-            newData.order(data.order());
-            newData.position(data.position());
-            data = newData;
+    public DataSectionReference emitDataItem(HotSpotConstant c) {
+        DataSectionReference ref = new DataSectionReference();
+        ref.setOffset(data.position());
+
+        recordDataPatchInData(new ConstantReference((VMConstant) c));
+        if (c.isCompressed()) {
+            data.emitInt(0xDEADDEAD);
+        } else {
+            data.emitLong(0xDEADDEADDEADDEADL);
         }
+
+        return ref;
+    }
+
+    public HotSpotCompiledCode finish(HotSpotResolvedJavaMethod method) {
+        int id = method.allocateCompileId(0);
+        byte[] finishedCode = code.finish();
+        Site[] finishedSites = sites.toArray(new Site[0]);
+        byte[] finishedData = data.finish();
+        DataPatch[] finishedDataPatches = dataPatches.toArray(new DataPatch[0]);
+        return new HotSpotCompiledNmethod(method.getName(), finishedCode, finishedCode.length, finishedSites, new Assumption[0], new ResolvedJavaMethod[]{method}, new Comment[0], finishedData, 16,
+                        finishedDataPatches, false, frameSize, 0, method, 0, id, 0L, false);
     }
 
-    protected void emitByte(int b) {
-        ensureSize(data.position() + 1);
-        data.put((byte) (b & 0xFF));
-    }
+    protected static class Buffer {
+
+        private ByteBuffer data = ByteBuffer.allocate(32).order(ByteOrder.nativeOrder());
+
+        private void ensureSize(int length) {
+            if (length >= data.limit()) {
+                byte[] newBuf = Arrays.copyOf(data.array(), length * 4);
+                ByteBuffer newData = ByteBuffer.wrap(newBuf);
+                newData.order(data.order());
+                newData.position(data.position());
+                data = newData;
+            }
+        }
+
+        public int position() {
+            return data.position();
+        }
+
+        public void emitByte(int b) {
+            ensureSize(data.position() + 1);
+            data.put((byte) (b & 0xFF));
+        }
 
-    protected void emitShort(int b) {
-        ensureSize(data.position() + 2);
-        data.putShort((short) b);
-    }
+        public void emitShort(int b) {
+            ensureSize(data.position() + 2);
+            data.putShort((short) b);
+        }
+
+        public void emitInt(int b) {
+            ensureSize(data.position() + 4);
+            data.putInt(b);
+        }
 
-    protected void emitInt(int b) {
-        ensureSize(data.position() + 4);
-        data.putInt(b);
-    }
+        public void emitLong(long b) {
+            ensureSize(data.position() + 8);
+            data.putLong(b);
+        }
 
-    protected void emitLong(long b) {
-        ensureSize(data.position() + 8);
-        data.putLong(b);
+        public void emitFloat(float f) {
+            ensureSize(data.position() + 4);
+            data.putFloat(f);
+        }
+
+        private byte[] finish() {
+            return Arrays.copyOf(data.array(), data.position());
+        }
     }
 }
--- a/hotspot/test/compiler/jvmci/code/amd64/AMD64TestAssembler.java	Wed Jan 20 16:33:51 2016 +0100
+++ b/hotspot/test/compiler/jvmci/code/amd64/AMD64TestAssembler.java	Wed Jan 20 14:22:46 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, 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
@@ -25,18 +25,14 @@
 
 import jdk.vm.ci.amd64.AMD64;
 import jdk.vm.ci.amd64.AMD64Kind;
+import jdk.vm.ci.code.CallingConvention.Type;
 import jdk.vm.ci.code.CodeCacheProvider;
-import jdk.vm.ci.code.CompilationResult;
-import jdk.vm.ci.code.CompilationResult.ConstantReference;
-import jdk.vm.ci.code.CompilationResult.DataSectionReference;
-import jdk.vm.ci.code.DataSection.Data;
 import jdk.vm.ci.code.DebugInfo;
-import jdk.vm.ci.code.InfopointReason;
 import jdk.vm.ci.code.Register;
 import jdk.vm.ci.code.StackSlot;
-import jdk.vm.ci.code.CallingConvention.Type;
+import jdk.vm.ci.code.site.ConstantReference;
+import jdk.vm.ci.code.site.DataSectionReference;
 import jdk.vm.ci.hotspot.HotSpotConstant;
-import jdk.vm.ci.meta.JavaConstant;
 import jdk.vm.ci.meta.JavaKind;
 import jdk.vm.ci.meta.LIRKind;
 import jdk.vm.ci.meta.VMConstant;
@@ -45,27 +41,31 @@
 
 public class AMD64TestAssembler extends TestAssembler {
 
-    public AMD64TestAssembler(CompilationResult result, CodeCacheProvider codeCache) {
-        super(result, codeCache, 16, 16, AMD64Kind.DWORD, AMD64.rax, AMD64.rcx, AMD64.rdi, AMD64.r8, AMD64.r9, AMD64.r10);
+    public AMD64TestAssembler(CodeCacheProvider codeCache) {
+        super(codeCache, 16, 16, AMD64Kind.DWORD, AMD64.rax, AMD64.rcx, AMD64.rdi, AMD64.r8, AMD64.r9, AMD64.r10);
     }
 
+    @Override
     public void emitPrologue() {
-        emitByte(0x50 | AMD64.rbp.encoding);  // PUSH rbp
-        emitMove(true, AMD64.rbp, AMD64.rsp); // MOV rbp, rsp
+        code.emitByte(0x50 | AMD64.rbp.encoding);  // PUSH rbp
+        emitMove(true, AMD64.rbp, AMD64.rsp);      // MOV rbp, rsp
     }
 
+    @Override
     public void emitGrowStack(int size) {
         // SUB rsp, size
-        emitByte(0x48);
-        emitByte(0x81);
-        emitByte(0xEC);
-        emitInt(size);
+        code.emitByte(0x48);
+        code.emitByte(0x81);
+        code.emitByte(0xEC);
+        code.emitInt(size);
     }
 
+    @Override
     public Register emitIntArg0() {
         return codeCache.getRegisterConfig().getCallingConventionRegisters(Type.JavaCall, JavaKind.Int)[0];
     }
 
+    @Override
     public Register emitIntArg1() {
         return codeCache.getRegisterConfig().getCallingConventionRegisters(Type.JavaCall, JavaKind.Int)[1];
     }
@@ -73,60 +73,66 @@
     private void emitREX(boolean w, int r, int x, int b) {
         int wrxb = (w ? 0x08 : 0) | ((r >> 3) << 2) | ((x >> 3) << 1) | (b >> 3);
         if (wrxb != 0) {
-            emitByte(0x40 | wrxb);
+            code.emitByte(0x40 | wrxb);
         }
     }
 
     private void emitModRMReg(boolean w, int opcode, int r, int m) {
         emitREX(w, r, 0, m);
-        emitByte((byte) opcode);
-        emitByte((byte) 0xC0 | ((r & 0x7) << 3) | (m & 0x7));
+        code.emitByte((byte) opcode);
+        code.emitByte((byte) 0xC0 | ((r & 0x7) << 3) | (m & 0x7));
     }
 
     private void emitModRMMemory(boolean w, int opcode, int r, int b, int offset) {
         emitREX(w, r, 0, b);
-        emitByte((byte) opcode);
-        emitByte((byte) 0x80 | ((r & 0x7) << 3) | (b & 0x7));
-        emitInt(offset);
+        code.emitByte((byte) opcode);
+        code.emitByte((byte) 0x80 | ((r & 0x7) << 3) | (b & 0x7));
+        code.emitInt(offset);
     }
 
+    @Override
     public Register emitLoadInt(int c) {
         Register ret = newRegister();
         emitREX(false, 0, 0, ret.encoding);
-        emitByte(0xB8 | (ret.encoding & 0x7)); // MOV r32, imm32
-        emitInt(c);
+        code.emitByte(0xB8 | (ret.encoding & 0x7)); // MOV r32, imm32
+        code.emitInt(c);
         return ret;
     }
 
+    @Override
     public Register emitLoadLong(long c) {
         Register ret = newRegister();
         emitREX(true, 0, 0, ret.encoding);
-        emitByte(0xB8 | (ret.encoding & 0x7)); // MOV r64, imm64
-        emitLong(c);
+        code.emitByte(0xB8 | (ret.encoding & 0x7)); // MOV r64, imm64
+        code.emitLong(c);
         return ret;
     }
 
+    @Override
     public Register emitLoadFloat(float c) {
-        Data data = codeCache.createDataItem(JavaConstant.forFloat(c));
-        DataSectionReference ref = result.getDataSection().insertData(data);
-        result.recordDataPatch(position(), ref);
+        DataSectionReference ref = new DataSectionReference();
+        ref.setOffset(data.position());
+        data.emitFloat(c);
+
+        recordDataPatchInCode(ref);
         Register ret = AMD64.xmm0;
         emitREX(false, ret.encoding, 0, 0);
-        emitByte(0xF3);
-        emitByte(0x0F);
-        emitByte(0x10);                               // MOVSS xmm1, xmm2/m32
-        emitByte(0x05 | ((ret.encoding & 0x7) << 3)); // xmm, [rip+offset]
-        emitInt(0xDEADDEAD);
+        code.emitByte(0xF3);
+        code.emitByte(0x0F);
+        code.emitByte(0x10);                               // MOVSS xmm1, xmm2/m32
+        code.emitByte(0x05 | ((ret.encoding & 0x7) << 3)); // xmm, [rip+offset]
+        code.emitInt(0xDEADDEAD);
         return ret;
     }
 
+    @Override
     public Register emitLoadPointer(HotSpotConstant c) {
-        result.recordDataPatch(position(), new ConstantReference((VMConstant) c));
+        recordDataPatchInCode(new ConstantReference((VMConstant) c));
         if (c.isCompressed()) {
             Register ret = newRegister();
             emitREX(false, 0, 0, ret.encoding);
-            emitByte(0xB8 | (ret.encoding & 0x7)); // MOV r32, imm32
-            emitInt(0xDEADDEAD);
+            code.emitByte(0xB8 | (ret.encoding & 0x7)); // MOV r32, imm32
+            code.emitInt(0xDEADDEAD);
             return ret;
         } else {
             return emitLoadLong(0xDEADDEADDEADDEADl);
@@ -134,68 +140,77 @@
     }
 
     private Register emitLoadPointer(DataSectionReference ref, boolean narrow) {
-        result.recordDataPatch(position(), ref);
+        recordDataPatchInCode(ref);
         Register ret = newRegister();
         emitREX(!narrow, ret.encoding, 0, 0);
-        emitByte(0x8B);                               // MOV r64,r/m64
-        emitByte(0x05 | ((ret.encoding & 0x7) << 3)); // r64, [rip+offset]
-        emitInt(0xDEADDEAD);
+        code.emitByte(0x8B);                               // MOV r64,r/m64
+        code.emitByte(0x05 | ((ret.encoding & 0x7) << 3)); // r64, [rip+offset]
+        code.emitInt(0xDEADDEAD);
         return ret;
     }
 
+    @Override
     public Register emitLoadPointer(DataSectionReference ref) {
         return emitLoadPointer(ref, false);
     }
 
+    @Override
     public Register emitLoadNarrowPointer(DataSectionReference ref) {
         return emitLoadPointer(ref, true);
     }
 
+    @Override
     public Register emitLoadPointer(Register b, int offset) {
         Register ret = newRegister();
         emitModRMMemory(true, 0x8B, ret.encoding, b.encoding, offset); // MOV r64,r/m64
         return ret;
     }
 
+    @Override
     public StackSlot emitIntToStack(Register a) {
         StackSlot ret = newStackSlot(LIRKind.value(AMD64Kind.DWORD));
         emitModRMMemory(false, 0x89, a.encoding, AMD64.rbp.encoding, ret.getRawOffset() + 16); // MOV r/m32,r32
         return ret;
     }
 
+    @Override
     public StackSlot emitLongToStack(Register a) {
         StackSlot ret = newStackSlot(LIRKind.value(AMD64Kind.QWORD));
         emitModRMMemory(true, 0x89, a.encoding, AMD64.rbp.encoding, ret.getRawOffset() + 16); // MOV r/m64,r64
         return ret;
     }
 
+    @Override
     public StackSlot emitFloatToStack(Register a) {
         StackSlot ret = newStackSlot(LIRKind.value(AMD64Kind.SINGLE));
         emitREX(false, a.encoding, 0, 0);
-        emitByte(0xF3);
-        emitByte(0x0F);
-        emitByte(0x11);                               // MOVSS xmm2/m32, xmm1
-        emitByte(0x85 | ((a.encoding & 0x7) << 3));   // [rbp+offset]
-        emitInt(ret.getRawOffset() + 16);
+        code.emitByte(0xF3);
+        code.emitByte(0x0F);
+        code.emitByte(0x11);                               // MOVSS xmm2/m32, xmm1
+        code.emitByte(0x85 | ((a.encoding & 0x7) << 3));   // [rbp+offset]
+        code.emitInt(ret.getRawOffset() + 16);
         return ret;
     }
 
+    @Override
     public StackSlot emitPointerToStack(Register a) {
         StackSlot ret = newStackSlot(LIRKind.reference(AMD64Kind.QWORD));
         emitModRMMemory(true, 0x89, a.encoding, AMD64.rbp.encoding, ret.getRawOffset() + 16); // MOV r/m64,r64
         return ret;
     }
 
+    @Override
     public StackSlot emitNarrowPointerToStack(Register a) {
         StackSlot ret = newStackSlot(LIRKind.reference(AMD64Kind.DWORD));
         emitModRMMemory(false, 0x89, a.encoding, AMD64.rbp.encoding, ret.getRawOffset() + 16); // MOV r/m32,r32
         return ret;
     }
 
+    @Override
     public Register emitUncompressPointer(Register compressed, long base, int shift) {
         if (shift > 0) {
             emitModRMReg(true, 0xC1, 4, compressed.encoding);
-            emitByte(shift);
+            code.emitByte(shift);
         }
         if (base == 0) {
             return compressed;
@@ -206,6 +221,7 @@
         }
     }
 
+    @Override
     public Register emitIntAdd(Register a, Register b) {
         emitModRMReg(false, 0x03, a.encoding, b.encoding);
         return a;
@@ -217,26 +233,29 @@
         }
     }
 
+    @Override
     public void emitIntRet(Register a) {
-        emitMove(false, AMD64.rax, a);        // MOV eax, ...
-        emitMove(true, AMD64.rsp, AMD64.rbp); // MOV rsp, rbp
-        emitByte(0x58 | AMD64.rbp.encoding);  // POP rbp
-        emitByte(0xC3);                       // RET
+        emitMove(false, AMD64.rax, a);             // MOV eax, ...
+        emitMove(true, AMD64.rsp, AMD64.rbp);      // MOV rsp, rbp
+        code.emitByte(0x58 | AMD64.rbp.encoding);  // POP rbp
+        code.emitByte(0xC3);                       // RET
     }
 
+    @Override
     public void emitPointerRet(Register a) {
-        emitMove(true, AMD64.rax, a);         // MOV rax, ...
-        emitMove(true, AMD64.rsp, AMD64.rbp); // MOV rsp, rbp
-        emitByte(0x58 | AMD64.rbp.encoding);  // POP rbp
-        emitByte(0xC3);                       // RET
+        emitMove(true, AMD64.rax, a);              // MOV rax, ...
+        emitMove(true, AMD64.rsp, AMD64.rbp);      // MOV rsp, rbp
+        code.emitByte(0x58 | AMD64.rbp.encoding);  // POP rbp
+        code.emitByte(0xC3);                       // RET
     }
 
+    @Override
     public void emitTrap(DebugInfo info) {
-        result.recordInfopoint(position(), info, InfopointReason.IMPLICIT_EXCEPTION);
+        recordImplicitException(info);
         // MOV rax, [0]
-        emitByte(0x8B);
-        emitByte(0x04);
-        emitByte(0x25);
-        emitInt(0);
+        code.emitByte(0x8B);
+        code.emitByte(0x04);
+        code.emitByte(0x25);
+        code.emitInt(0);
     }
 }
--- a/hotspot/test/compiler/jvmci/code/sparc/SPARCTestAssembler.java	Wed Jan 20 16:33:51 2016 +0100
+++ b/hotspot/test/compiler/jvmci/code/sparc/SPARCTestAssembler.java	Wed Jan 20 14:22:46 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, 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
@@ -23,18 +23,16 @@
 
 package compiler.jvmci.code.sparc;
 
+import jdk.vm.ci.code.CallingConvention.Type;
 import jdk.vm.ci.code.CodeCacheProvider;
-import jdk.vm.ci.code.CompilationResult;
-import jdk.vm.ci.code.CompilationResult.ConstantReference;
-import jdk.vm.ci.code.CompilationResult.DataSectionReference;
-import jdk.vm.ci.code.DataSection.Data;
 import jdk.vm.ci.code.DebugInfo;
-import jdk.vm.ci.code.InfopointReason;
 import jdk.vm.ci.code.Register;
 import jdk.vm.ci.code.StackSlot;
-import jdk.vm.ci.code.CallingConvention.Type;
+import jdk.vm.ci.code.site.ConstantReference;
+import jdk.vm.ci.code.site.DataSectionReference;
+import jdk.vm.ci.hotspot.HotSpotCompiledCode;
 import jdk.vm.ci.hotspot.HotSpotConstant;
-import jdk.vm.ci.meta.JavaConstant;
+import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod;
 import jdk.vm.ci.meta.JavaKind;
 import jdk.vm.ci.meta.LIRKind;
 import jdk.vm.ci.meta.VMConstant;
@@ -47,48 +45,53 @@
 
     private static final int MASK13 = (1 << 13) - 1;
 
-    public SPARCTestAssembler(CompilationResult result, CodeCacheProvider codeCache) {
-        super(result, codeCache, 0, 16, SPARCKind.WORD, SPARC.l0, SPARC.l1, SPARC.l2, SPARC.l3, SPARC.l4, SPARC.l5, SPARC.l6, SPARC.l7);
+    public SPARCTestAssembler(CodeCacheProvider codeCache) {
+        super(codeCache, 0, 16, SPARCKind.WORD, SPARC.l0, SPARC.l1, SPARC.l2, SPARC.l3, SPARC.l4, SPARC.l5, SPARC.l6, SPARC.l7);
     }
 
     private void emitOp2(Register rd, int op2, int imm22) {
-        emitInt((0b00 << 30) | (rd.encoding << 25) | (op2 << 22) | imm22);
+        code.emitInt((0b00 << 30) | (rd.encoding << 25) | (op2 << 22) | imm22);
     }
 
     private void emitOp3(int op, Register rd, int op3, Register rs1, Register rs2) {
-        emitInt((op << 30) | (rd.encoding << 25) | (op3 << 19) | (rs1.encoding << 14) | rs2.encoding);
+        code.emitInt((op << 30) | (rd.encoding << 25) | (op3 << 19) | (rs1.encoding << 14) | rs2.encoding);
     }
 
     private void emitOp3(int op, Register rd, int op3, Register rs1, int simm13) {
-        emitInt((op << 30) | (rd.encoding << 25) | (op3 << 19) | (rs1.encoding << 14) | (1 << 13) | (simm13 & MASK13));
+        code.emitInt((op << 30) | (rd.encoding << 25) | (op3 << 19) | (rs1.encoding << 14) | (1 << 13) | (simm13 & MASK13));
     }
 
     private void emitNop() {
-        emitInt(1 << 24);
+        code.emitInt(1 << 24);
     }
 
+    @Override
     public void emitPrologue() {
         emitOp3(0b10, SPARC.sp, 0b111100, SPARC.sp, -SPARC.REGISTER_SAFE_AREA_SIZE); // SAVE sp, -128, sp
     }
 
     @Override
-    public void finish() {
+    public HotSpotCompiledCode finish(HotSpotResolvedJavaMethod method) {
         frameSize += SPARC.REGISTER_SAFE_AREA_SIZE;
-        super.finish();
+        return super.finish(method);
     }
 
+    @Override
     public void emitGrowStack(int size) {
         emitOp3(0b10, SPARC.sp, 0b000100, SPARC.sp, size); // SUB sp, size, sp
     }
 
+    @Override
     public Register emitIntArg0() {
         return codeCache.getRegisterConfig().getCallingConventionRegisters(Type.JavaCallee, JavaKind.Int)[0];
     }
 
+    @Override
     public Register emitIntArg1() {
         return codeCache.getRegisterConfig().getCallingConventionRegisters(Type.JavaCallee, JavaKind.Int)[1];
     }
 
+    @Override
     public Register emitLoadInt(int c) {
         Register ret = newRegister();
         int hi = c >>> 10;
@@ -104,41 +107,46 @@
         return ret;
     }
 
+    @Override
     public Register emitLoadLong(long c) {
         if ((c & 0xFFFFFFFF) == c) {
             return emitLoadInt((int) c);
         } else {
-            Data data = codeCache.createDataItem(JavaConstant.forLong(c));
-            DataSectionReference ref = result.getDataSection().insertData(data);
+            DataSectionReference ref = new DataSectionReference();
+            ref.setOffset(data.position());
+            data.emitLong(c);
             return emitLoadPointer(ref);
         }
     }
 
     private void emitPatchableSethi(Register ret, boolean wide) {
-        int startPos = position();
+        int startPos = code.position();
         emitOp2(ret, 0b100, 0);              // SETHI 0, ret
         if (wide) {
             // pad for later patching
-            while (position() < (startPos + 28)) {
+            while (code.position() < (startPos + 28)) {
                 emitNop();
             }
         }
     }
 
+    @Override
     public Register emitLoadFloat(float c) {
-        Data data = codeCache.createDataItem(JavaConstant.forFloat(c));
-        DataSectionReference ref = result.getDataSection().insertData(data);
+        DataSectionReference ref = new DataSectionReference();
+        ref.setOffset(data.position());
+        data.emitFloat(c);
 
         Register ptr = newRegister();
-        result.recordDataPatch(position(), ref);
+        recordDataPatchInCode(ref);
         emitPatchableSethi(ptr, true);
         emitOp3(0b11, SPARC.f0, 0b100000, ptr, 0); // LDF [ptr+0], f0
         return SPARC.f0;
     }
 
+    @Override
     public Register emitLoadPointer(HotSpotConstant c) {
         Register ret = newRegister();
-        result.recordDataPatch(position(), new ConstantReference((VMConstant) c));
+        recordDataPatchInCode(new ConstantReference((VMConstant) c));
 
         emitPatchableSethi(ret, !c.isCompressed());
         emitOp3(0b10, ret, 0b000010, ret, 0); // OR ret, 0, ret
@@ -146,58 +154,67 @@
         return ret;
     }
 
+    @Override
     public Register emitLoadPointer(DataSectionReference ref) {
         Register ret = newRegister();
-        result.recordDataPatch(position(), ref);
+        recordDataPatchInCode(ref);
         emitPatchableSethi(ret, true);
         emitOp3(0b11, ret, 0b001011, ret, 0); // LDX [ret+0], ret
         return ret;
     }
 
+    @Override
     public Register emitLoadNarrowPointer(DataSectionReference ref) {
         Register ret = newRegister();
-        result.recordDataPatch(position(), ref);
+        recordDataPatchInCode(ref);
         emitPatchableSethi(ret, true);
         emitOp3(0b11, ret, 0b000000, ret, 0); // LDUW [ret+0], ret
         return ret;
     }
 
+    @Override
     public Register emitLoadPointer(Register b, int offset) {
         Register ret = newRegister();
         emitOp3(0b11, ret, 0b001011, b, offset); // LDX [b+offset], ret
         return ret;
     }
 
+    @Override
     public StackSlot emitIntToStack(Register a) {
         StackSlot ret = newStackSlot(LIRKind.value(SPARCKind.WORD));
         emitOp3(0b11, a, 0b000100, SPARC.fp, ret.getRawOffset() + SPARC.STACK_BIAS); // STW a, [fp+offset]
         return ret;
     }
 
+    @Override
     public StackSlot emitLongToStack(Register a) {
         StackSlot ret = newStackSlot(LIRKind.value(SPARCKind.XWORD));
         emitOp3(0b11, a, 0b001110, SPARC.fp, ret.getRawOffset() + SPARC.STACK_BIAS); // STX a, [fp+offset]
         return ret;
     }
 
+    @Override
     public StackSlot emitFloatToStack(Register a) {
         StackSlot ret = newStackSlot(LIRKind.value(SPARCKind.SINGLE));
         emitOp3(0b11, a, 0b100100, SPARC.fp, ret.getRawOffset() + SPARC.STACK_BIAS); // STF a, [fp+offset]
         return ret;
     }
 
+    @Override
     public StackSlot emitPointerToStack(Register a) {
         StackSlot ret = newStackSlot(LIRKind.reference(SPARCKind.XWORD));
         emitOp3(0b11, a, 0b001110, SPARC.fp, ret.getRawOffset() + SPARC.STACK_BIAS); // STX a, [fp+offset]
         return ret;
     }
 
+    @Override
     public StackSlot emitNarrowPointerToStack(Register a) {
         StackSlot ret = newStackSlot(LIRKind.reference(SPARCKind.WORD));
         emitOp3(0b11, a, 0b000100, SPARC.fp, ret.getRawOffset() + SPARC.STACK_BIAS); // STW a, [fp+offset]
         return ret;
     }
 
+    @Override
     public Register emitUncompressPointer(Register compressed, long base, int shift) {
         Register ret;
         if (shift > 0) {
@@ -215,6 +232,7 @@
         }
     }
 
+    @Override
     public Register emitIntAdd(Register a, Register b) {
         Register ret = newRegister();
         emitOp3(0b10, ret, 0b00000, a, b); // ADD a, b, ret
@@ -227,18 +245,21 @@
         }
     }
 
+    @Override
     public void emitIntRet(Register a) {
         emitPointerRet(a);
     }
 
+    @Override
     public void emitPointerRet(Register a) {
         emitMove(SPARC.i0, a);
         emitOp3(0b10, SPARC.g0, 0b111000, SPARC.i7, 8);        // JMPL [i7+8], g0
         emitOp3(0b10, SPARC.g0, 0b111101, SPARC.g0, SPARC.g0); // RESTORE g0, g0, g0
     }
 
+    @Override
     public void emitTrap(DebugInfo info) {
-        result.recordInfopoint(position(), info, InfopointReason.IMPLICIT_EXCEPTION);
+        recordImplicitException(info);
         emitOp3(0b11, SPARC.g0, 0b001011, SPARC.g0, 0); // LDX [g0+0], g0
     }
 }
--- a/hotspot/test/compiler/jvmci/errors/CodeInstallerTest.java	Wed Jan 20 16:33:51 2016 +0100
+++ b/hotspot/test/compiler/jvmci/errors/CodeInstallerTest.java	Wed Jan 20 14:22:46 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, 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
@@ -27,12 +27,16 @@
 
 import jdk.vm.ci.code.Architecture;
 import jdk.vm.ci.code.CodeCacheProvider;
-import jdk.vm.ci.code.CompilationResult;
 import jdk.vm.ci.code.Register;
+import jdk.vm.ci.code.site.DataPatch;
+import jdk.vm.ci.code.site.Site;
+import jdk.vm.ci.hotspot.HotSpotCompiledCode;
+import jdk.vm.ci.hotspot.HotSpotCompiledCode.Comment;
+import jdk.vm.ci.hotspot.HotSpotConstantReflectionProvider;
+import jdk.vm.ci.meta.Assumptions.Assumption;
 import jdk.vm.ci.meta.MetaAccessProvider;
 import jdk.vm.ci.meta.PlatformKind;
 import jdk.vm.ci.meta.ResolvedJavaMethod;
-import jdk.vm.ci.hotspot.HotSpotConstantReflectionProvider;
 import jdk.vm.ci.runtime.JVMCI;
 import jdk.vm.ci.runtime.JVMCIBackend;
 
@@ -67,22 +71,18 @@
         dummyMethod = metaAccess.lookupJavaMethod(method);
     }
 
-    protected void installCode(CompilationResult result) {
-        result.close();
-        codeCache.addCode(dummyMethod, result, null, null);
-    }
-
-    protected CompilationResult createEmptyCompilationResult() {
-        CompilationResult ret = new CompilationResult();
-        ret.setTotalFrameSize(0);
-        return ret;
+    protected void installEmptyCode(Site[] sites, Assumption[] assumptions, Comment[] comments, int dataSectionAlignment, DataPatch[] dataSectionPatches) {
+        HotSpotCompiledCode code = new HotSpotCompiledCode("dummyMethod", new byte[0], 0, sites, assumptions, new ResolvedJavaMethod[]{dummyMethod}, comments, new byte[8], dataSectionAlignment,
+                        dataSectionPatches, false, 0, 0);
+        codeCache.addCode(dummyMethod, code, null, null);
     }
 
     protected Register getRegister(PlatformKind kind, int index) {
+        int idx = index;
         Register[] allRegs = arch.getAvailableValueRegisters();
         for (int i = 0; i < allRegs.length; i++) {
             if (arch.canStoreValue(allRegs[i].getRegisterCategory(), kind)) {
-                if (index-- == 0) {
+                if (idx-- == 0) {
                     return allRegs[i];
                 }
             }
--- a/hotspot/test/compiler/jvmci/errors/TestInvalidCompilationResult.java	Wed Jan 20 16:33:51 2016 +0100
+++ b/hotspot/test/compiler/jvmci/errors/TestInvalidCompilationResult.java	Wed Jan 20 14:22:46 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, 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
@@ -30,20 +30,18 @@
 
 package compiler.jvmci.errors;
 
-import static jdk.vm.ci.code.CompilationResult.ConstantReference;
-import static jdk.vm.ci.code.CompilationResult.DataPatch;
-import static jdk.vm.ci.code.CompilationResult.DataSectionReference;
-import static jdk.vm.ci.code.CompilationResult.Infopoint;
-import static jdk.vm.ci.code.CompilationResult.Reference;
-import static jdk.vm.ci.code.DataSection.Data;
-import static jdk.vm.ci.code.DataSection.DataBuilder;
-import static jdk.vm.ci.meta.Assumptions.Assumption;
-
-import jdk.vm.ci.code.CompilationResult;
-import jdk.vm.ci.code.InfopointReason;
+import jdk.vm.ci.code.site.ConstantReference;
+import jdk.vm.ci.code.site.DataPatch;
+import jdk.vm.ci.code.site.DataSectionReference;
+import jdk.vm.ci.code.site.Infopoint;
+import jdk.vm.ci.code.site.InfopointReason;
+import jdk.vm.ci.code.site.Mark;
+import jdk.vm.ci.code.site.Reference;
+import jdk.vm.ci.code.site.Site;
 import jdk.vm.ci.common.JVMCIError;
+import jdk.vm.ci.hotspot.HotSpotCompiledCode.Comment;
 import jdk.vm.ci.hotspot.HotSpotConstant;
-import jdk.vm.ci.meta.ResolvedJavaType;
+import jdk.vm.ci.meta.Assumptions.Assumption;
 import jdk.vm.ci.meta.VMConstant;
 
 import org.junit.Test;
@@ -82,153 +80,104 @@
 
     @Test(expected = JVMCIError.class)
     public void testInvalidAssumption() {
-        CompilationResult result = createEmptyCompilationResult();
-        result.setAssumptions(new Assumption[]{new InvalidAssumption()});
-        installCode(result);
+        installEmptyCode(new Site[0], new Assumption[]{new InvalidAssumption()}, new Comment[0], 16, new DataPatch[0]);
     }
 
     @Test(expected = JVMCIError.class)
     public void testInvalidAlignment() {
-        CompilationResult result = createEmptyCompilationResult();
-        result.getDataSection().insertData(new Data(7, 1, DataBuilder.zero(1)));
-        installCode(result);
+        installEmptyCode(new Site[0], new Assumption[0], new Comment[0], 7, new DataPatch[0]);
     }
 
     @Test(expected = NullPointerException.class)
     public void testNullDataPatchInDataSection() {
-        CompilationResult result = createEmptyCompilationResult();
-        Data data = new Data(1, 1, (buffer, patch) -> {
-            patch.accept(null);
-            buffer.put((byte) 0);
-        });
-        result.getDataSection().insertData(data);
-        installCode(result);
+        installEmptyCode(new Site[0], new Assumption[0], new Comment[0], 16, new DataPatch[]{null});
     }
 
     @Test(expected = NullPointerException.class)
     public void testNullReferenceInDataSection() {
-        CompilationResult result = createEmptyCompilationResult();
-        Data data = new Data(1, 1, (buffer, patch) -> {
-            patch.accept(new DataPatch(buffer.position(), null));
-            buffer.put((byte) 0);
-        });
-        result.getDataSection().insertData(data);
-        installCode(result);
+        installEmptyCode(new Site[0], new Assumption[0], new Comment[0], 16, new DataPatch[]{new DataPatch(0, null)});
     }
 
     @Test(expected = JVMCIError.class)
     public void testInvalidDataSectionReference() {
-        CompilationResult result = createEmptyCompilationResult();
-        DataSectionReference ref = result.getDataSection().insertData(new Data(1, 1, DataBuilder.zero(1)));
-        Data data = new Data(1, 1, (buffer, patch) -> {
-            patch.accept(new DataPatch(buffer.position(), ref));
-            buffer.put((byte) 0);
-        });
-        result.getDataSection().insertData(data);
-        installCode(result);
+        DataSectionReference ref = new DataSectionReference();
+        ref.setOffset(0);
+        installEmptyCode(new Site[0], new Assumption[0], new Comment[0], 16, new DataPatch[]{new DataPatch(0, ref)});
     }
 
     @Test(expected = JVMCIError.class)
     public void testInvalidNarrowMethodInDataSection() {
-        CompilationResult result = createEmptyCompilationResult();
         HotSpotConstant c = (HotSpotConstant) dummyMethod.getEncoding();
-        Data data = new Data(4, 4, (buffer, patch) -> {
-            patch.accept(new DataPatch(buffer.position(), new ConstantReference((VMConstant) c.compress())));
-            buffer.putInt(0);
-        });
-        result.getDataSection().insertData(data);
-        installCode(result);
+        ConstantReference ref = new ConstantReference((VMConstant) c.compress());
+        installEmptyCode(new Site[0], new Assumption[0], new Comment[0], 16, new DataPatch[]{new DataPatch(0, ref)});
     }
 
     @Test(expected = NullPointerException.class)
     public void testNullConstantInDataSection() {
-        CompilationResult result = createEmptyCompilationResult();
-        Data data = new Data(1, 1, (buffer, patch) -> {
-            patch.accept(new DataPatch(buffer.position(), new ConstantReference(null)));
-        });
-        result.getDataSection().insertData(data);
-        installCode(result);
+        ConstantReference ref = new ConstantReference(null);
+        installEmptyCode(new Site[0], new Assumption[0], new Comment[0], 16, new DataPatch[]{new DataPatch(0, ref)});
     }
 
     @Test(expected = JVMCIError.class)
     public void testInvalidConstantInDataSection() {
-        CompilationResult result = createEmptyCompilationResult();
-        Data data = new Data(1, 1, (buffer, patch) -> {
-            patch.accept(new DataPatch(buffer.position(), new ConstantReference(new InvalidVMConstant())));
-        });
-        result.getDataSection().insertData(data);
-        installCode(result);
+        ConstantReference ref = new ConstantReference(new InvalidVMConstant());
+        installEmptyCode(new Site[0], new Assumption[0], new Comment[0], 16, new DataPatch[]{new DataPatch(0, ref)});
     }
 
     @Test(expected = NullPointerException.class)
     public void testNullReferenceInCode() {
-        CompilationResult result = createEmptyCompilationResult();
-        result.recordDataPatch(0, null);
-        installCode(result);
+        installEmptyCode(new Site[]{new DataPatch(0, null)}, new Assumption[0], new Comment[0], 16, new DataPatch[0]);
     }
 
     @Test(expected = NullPointerException.class)
     public void testNullConstantInCode() {
-        CompilationResult result = createEmptyCompilationResult();
-        result.recordDataPatch(0, new ConstantReference(null));
-        installCode(result);
+        ConstantReference ref = new ConstantReference(null);
+        installEmptyCode(new Site[]{new DataPatch(0, ref)}, new Assumption[0], new Comment[0], 16, new DataPatch[0]);
     }
 
     @Test(expected = JVMCIError.class)
     public void testInvalidConstantInCode() {
-        CompilationResult result = createEmptyCompilationResult();
-        result.recordDataPatch(0, new ConstantReference(new InvalidVMConstant()));
-        installCode(result);
+        ConstantReference ref = new ConstantReference(new InvalidVMConstant());
+        installEmptyCode(new Site[]{new DataPatch(0, ref)}, new Assumption[0], new Comment[0], 16, new DataPatch[0]);
     }
 
     @Test(expected = JVMCIError.class)
     public void testInvalidReference() {
-        CompilationResult result = createEmptyCompilationResult();
-        result.recordDataPatch(0, new InvalidReference());
-        installCode(result);
+        InvalidReference ref = new InvalidReference();
+        installEmptyCode(new Site[]{new DataPatch(0, ref)}, new Assumption[0], new Comment[0], 16, new DataPatch[0]);
     }
 
     @Test(expected = JVMCIError.class)
     public void testOutOfBoundsDataSectionReference() {
-        CompilationResult result = createEmptyCompilationResult();
         DataSectionReference ref = new DataSectionReference();
         ref.setOffset(0x1000);
-        result.recordDataPatch(0, ref);
-        installCode(result);
+        installEmptyCode(new Site[]{new DataPatch(0, ref)}, new Assumption[0], new Comment[0], 16, new DataPatch[0]);
     }
 
     @Test(expected = JVMCIError.class)
     public void testInvalidMark() {
-        CompilationResult result = createEmptyCompilationResult();
-        result.recordMark(0, new Object());
-        installCode(result);
+        installEmptyCode(new Site[]{new Mark(0, new Object())}, new Assumption[0], new Comment[0], 16, new DataPatch[0]);
     }
 
     @Test(expected = JVMCIError.class)
     public void testInvalidMarkInt() {
-        CompilationResult result = createEmptyCompilationResult();
-        result.recordMark(0, -1);
-        installCode(result);
+        installEmptyCode(new Site[]{new Mark(0, -1)}, new Assumption[0], new Comment[0], 16, new DataPatch[0]);
     }
 
     @Test(expected = NullPointerException.class)
-    public void testNullInfopoint() {
-        CompilationResult result = createEmptyCompilationResult();
-        result.addInfopoint(null);
-        installCode(result);
+    public void testNullSite() {
+        installEmptyCode(new Site[]{null}, new Assumption[0], new Comment[0], 16, new DataPatch[0]);
     }
 
     @Test(expected = JVMCIError.class)
     public void testInfopointMissingDebugInfo() {
-        CompilationResult result = createEmptyCompilationResult();
-        result.addInfopoint(new Infopoint(0, null, InfopointReason.METHOD_START));
-        installCode(result);
+        Infopoint info = new Infopoint(0, null, InfopointReason.METHOD_START);
+        installEmptyCode(new Site[]{info}, new Assumption[0], new Comment[0], 16, new DataPatch[0]);
     }
 
     @Test(expected = JVMCIError.class)
     public void testSafepointMissingDebugInfo() {
-        CompilationResult result = createEmptyCompilationResult();
-        result.addInfopoint(new Infopoint(0, null, InfopointReason.SAFEPOINT));
-        installCode(result);
+        Infopoint info = new Infopoint(0, null, InfopointReason.SAFEPOINT);
+        installEmptyCode(new Site[]{info}, new Assumption[0], new Comment[0], 16, new DataPatch[0]);
     }
 }
--- a/hotspot/test/compiler/jvmci/errors/TestInvalidDebugInfo.java	Wed Jan 20 16:33:51 2016 +0100
+++ b/hotspot/test/compiler/jvmci/errors/TestInvalidDebugInfo.java	Wed Jan 20 14:22:46 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, 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
@@ -30,24 +30,26 @@
 
 package compiler.jvmci.errors;
 
-import static jdk.vm.ci.code.CompilationResult.Infopoint;
-
 import jdk.vm.ci.code.BytecodeFrame;
-import jdk.vm.ci.code.CompilationResult;
 import jdk.vm.ci.code.DebugInfo;
-import jdk.vm.ci.code.InfopointReason;
 import jdk.vm.ci.code.Location;
 import jdk.vm.ci.code.Register;
 import jdk.vm.ci.code.StackSlot;
 import jdk.vm.ci.code.VirtualObject;
+import jdk.vm.ci.code.site.DataPatch;
+import jdk.vm.ci.code.site.Infopoint;
+import jdk.vm.ci.code.site.InfopointReason;
+import jdk.vm.ci.code.site.Site;
+import jdk.vm.ci.common.JVMCIError;
+import jdk.vm.ci.hotspot.HotSpotCompiledCode.Comment;
 import jdk.vm.ci.hotspot.HotSpotReferenceMap;
+import jdk.vm.ci.meta.Assumptions.Assumption;
 import jdk.vm.ci.meta.JavaConstant;
 import jdk.vm.ci.meta.JavaKind;
 import jdk.vm.ci.meta.JavaValue;
 import jdk.vm.ci.meta.LIRKind;
 import jdk.vm.ci.meta.ResolvedJavaType;
 import jdk.vm.ci.meta.Value;
-import jdk.vm.ci.common.JVMCIError;
 
 import org.junit.Test;
 
@@ -67,10 +69,7 @@
         BytecodeFrame frame = new BytecodeFrame(null, dummyMethod, 0, false, false, values, slotKinds, locals, stack, locks);
         DebugInfo info = new DebugInfo(frame, vobj);
         info.setReferenceMap(new HotSpotReferenceMap(new Location[0], new Location[0], new int[0], 8));
-
-        CompilationResult result = createEmptyCompilationResult();
-        result.addInfopoint(new Infopoint(0, info, InfopointReason.SAFEPOINT));
-        installCode(result);
+        installEmptyCode(new Site[]{new Infopoint(0, info, InfopointReason.SAFEPOINT)}, new Assumption[0], new Comment[0], 16, new DataPatch[0]);
     }
 
     @Test(expected = NullPointerException.class)
--- a/hotspot/test/compiler/jvmci/errors/TestInvalidOopMap.java	Wed Jan 20 16:33:51 2016 +0100
+++ b/hotspot/test/compiler/jvmci/errors/TestInvalidOopMap.java	Wed Jan 20 14:22:46 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, 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
@@ -30,21 +30,22 @@
 
 package compiler.jvmci.errors;
 
-import static jdk.vm.ci.code.CompilationResult.Infopoint;
-
 import jdk.vm.ci.code.BytecodePosition;
-import jdk.vm.ci.code.CompilationResult;
 import jdk.vm.ci.code.DebugInfo;
-import jdk.vm.ci.code.InfopointReason;
 import jdk.vm.ci.code.Location;
 import jdk.vm.ci.code.ReferenceMap;
 import jdk.vm.ci.code.Register;
+import jdk.vm.ci.code.site.DataPatch;
+import jdk.vm.ci.code.site.Infopoint;
+import jdk.vm.ci.code.site.InfopointReason;
+import jdk.vm.ci.code.site.Site;
+import jdk.vm.ci.common.JVMCIError;
+import jdk.vm.ci.hotspot.HotSpotCompiledCode.Comment;
 import jdk.vm.ci.hotspot.HotSpotReferenceMap;
 import jdk.vm.ci.hotspot.HotSpotVMConfig;
+import jdk.vm.ci.meta.Assumptions.Assumption;
 import jdk.vm.ci.meta.JavaKind;
-import jdk.vm.ci.meta.LIRKind;
 import jdk.vm.ci.meta.PlatformKind;
-import jdk.vm.ci.common.JVMCIError;
 
 import org.junit.Test;
 
@@ -60,10 +61,7 @@
         BytecodePosition pos = new BytecodePosition(null, dummyMethod, 0);
         DebugInfo info = new DebugInfo(pos);
         info.setReferenceMap(refMap);
-
-        CompilationResult result = createEmptyCompilationResult();
-        result.addInfopoint(new Infopoint(0, info, InfopointReason.SAFEPOINT));
-        installCode(result);
+        installEmptyCode(new Site[]{new Infopoint(0, info, InfopointReason.SAFEPOINT)}, new Assumption[0], new Comment[0], 16, new DataPatch[0]);
     }
 
     @Test(expected = NullPointerException.class)
--- a/hotspot/test/compiler/jvmci/events/JvmciNotifyInstallEventTest.java	Wed Jan 20 16:33:51 2016 +0100
+++ b/hotspot/test/compiler/jvmci/events/JvmciNotifyInstallEventTest.java	Wed Jan 20 14:22:46 2016 +0100
@@ -58,10 +58,15 @@
 import jdk.test.lib.Asserts;
 import java.lang.reflect.Method;
 import jdk.vm.ci.hotspot.HotSpotVMEventListener;
-import jdk.vm.ci.code.CompilationResult;
+import jdk.vm.ci.code.CompiledCode;
 import jdk.vm.ci.code.InstalledCode;
+import jdk.vm.ci.code.site.DataPatch;
+import jdk.vm.ci.code.site.Site;
+import jdk.vm.ci.meta.Assumptions.Assumption;
+import jdk.vm.ci.meta.ResolvedJavaMethod;
 import jdk.vm.ci.hotspot.HotSpotCodeCacheProvider;
-import jdk.vm.ci.hotspot.HotSpotCompilationRequest;
+import jdk.vm.ci.hotspot.HotSpotCompiledCode;
+import jdk.vm.ci.hotspot.HotSpotCompiledCode.Comment;
 import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime;
 import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod;
 
@@ -102,17 +107,15 @@
         }
         HotSpotResolvedJavaMethod method = CTVMUtilities
                 .getResolvedMethod(SimpleClass.class, testMethod);
-        CompilationResult compResult = new CompilationResult(METHOD_NAME);
-        HotSpotCompilationRequest compRequest = new HotSpotCompilationRequest(method, -1, 0L);
-        // to pass sanity check of default -1
-        compResult.setTotalFrameSize(0);
-        compResult.close();
-        codeCache.installCode(compRequest, compResult, /* installedCode = */ null, /* speculationLog = */ null,
+        HotSpotCompiledCode compiledCode = new HotSpotCompiledCode(METHOD_NAME, new byte[0], 0, new Site[0],
+                new Assumption[0], new ResolvedJavaMethod[]{method}, new Comment[0], new byte[0], 16,
+                new DataPatch[0], false, 0, 0);
+        codeCache.installCode(method, compiledCode, /* installedCode = */ null, /* speculationLog = */ null,
                 /* isDefault = */ false);
         Asserts.assertEQ(gotInstallNotification, 1,
                 "Got unexpected event count after 1st install attempt");
         // since "empty" compilation result is ok, a second attempt should be ok
-        codeCache.installCode(compRequest, compResult, /* installedCode = */ null, /* speculationLog = */ null,
+        codeCache.installCode(method, compiledCode, /* installedCode = */ null, /* speculationLog = */ null,
                 /* isDefault = */ false);
         Asserts.assertEQ(gotInstallNotification, 2,
                 "Got unexpected event count after 2nd install attempt");
@@ -120,7 +123,7 @@
 
     @Override
     public void notifyInstall(HotSpotCodeCacheProvider hotSpotCodeCacheProvider,
-            InstalledCode installedCode, CompilationResult compResult) {
+            InstalledCode installedCode, CompiledCode compiledCode) {
         gotInstallNotification++;
     }
 }