changeset 2289:6190d20bd6d6

merge
author Lukas Stadler <lukas.stadler@jku.at>
date Mon, 11 Apr 2011 11:25:06 +0200
parents 8c426c2891c8 (diff) f21664b3dd1c (current diff)
children 1cfdec4e7f07
files c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotField.java c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotRuntime.java c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotTypePrimitive.java c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotTypeResolved.java c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotTypeResolvedImpl.java c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotTypeUnresolved.java c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/InvocationSocket.java src/share/vm/c1x/c1x_VMEntries.cpp src/share/vm/c1x/c1x_VMExits.cpp src/share/vm/classfile/vmSymbols.hpp
diffstat 35 files changed, 939 insertions(+), 634 deletions(-) [+]
line wrap: on
line diff
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/Compiler.java	Mon Apr 11 10:22:05 2011 +0200
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/Compiler.java	Mon Apr 11 11:25:06 2011 +0200
@@ -1,217 +1,33 @@
-/*
- * Copyright (c) 2010 Sun Microsystems, Inc.  All rights reserved.
- *
- * Sun Microsystems, Inc. has intellectual property rights relating to technology embodied in the product
- * that is described in this document. In particular, and without limitation, these intellectual property
- * rights may include one or more of the U.S. patents listed at http://www.sun.com/patents and one or
- * more additional patents or pending patent applications in the U.S. and in other countries.
- *
- * U.S. Government Rights - Commercial software. Government users are subject to the Sun
- * Microsystems, Inc. standard license agreement and applicable provisions of the FAR and its
- * supplements.
- *
- * Use is subject to license terms. Sun, Sun Microsystems, the Sun logo, Java and Solaris are trademarks or
- * registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries. All SPARC trademarks
- * are used under license and are trademarks or registered trademarks of SPARC International, Inc. in the
- * U.S. and other countries.
- *
- * UNIX is a registered trademark in the U.S. and other countries, exclusively licensed through X/Open
- * Company, Ltd.
- */
-package com.sun.hotspot.c1x;
-
-import java.lang.management.*;
-import java.lang.reflect.Proxy;
-import java.net.*;
-
-import com.sun.c1x.*;
-import com.sun.c1x.target.amd64.*;
-import com.sun.cri.ci.*;
-import com.sun.cri.ri.*;
-import com.sun.cri.xir.*;
-import com.sun.hotspot.c1x.logging.*;
-import com.sun.hotspot.c1x.server.CompilationServer.ReplacingInputStream;
-import com.sun.hotspot.c1x.server.CompilationServer.ReplacingOutputStream;
-
-/**
- * Singleton class holding the instance of the C1XCompiler.
- *
- * @author Thomas Wuerthinger, Lukas Stadler
- */
-public final class Compiler {
-
-    private static Compiler theInstance;
-    private static boolean PrintGCStats = false;
-
-    public static Compiler getInstance() {
-        if (theInstance == null) {
-            theInstance = new Compiler();
-            Runtime.getRuntime().addShutdownHook(new ShutdownThread());
-        }
-        return theInstance;
-    }
-
-    private static VMEntries vmEntries;
-
-
-    public static class ShutdownThread extends Thread {
-        @Override
-        public void run() {
-            VMExitsNative.compileMethods = false;
-            if (C1XOptions.PrintMetrics) {
-                C1XMetrics.print();
-            }
-            if (C1XOptions.PrintTimers) {
-                C1XTimers.print();
-            }
-
-            if (PrintGCStats) {
-                printGCStats();
-            }
-        }
-    }
-
-    public static void printGCStats() {
-        long totalGarbageCollections = 0;
-        long garbageCollectionTime = 0;
-
-        for (GarbageCollectorMXBean gc : ManagementFactory.getGarbageCollectorMXBeans()) {
-            long count = gc.getCollectionCount();
-            if (count >= 0) {
-                totalGarbageCollections += count;
-            }
-
-            long time = gc.getCollectionTime();
-            if (time >= 0) {
-                garbageCollectionTime += time;
-            }
-        }
-
-        System.out.println("Total Garbage Collections: " + totalGarbageCollections);
-        System.out.println("Total Garbage Collection Time (ms): " + garbageCollectionTime);
-    }
-
-    public static VMExits initializeServer(VMEntries entries) {
-        if (Logger.ENABLED) {
-            vmEntries = LoggingProxy.getProxy(VMEntries.class, entries);
-            vmExits = LoggingProxy.getProxy(VMExits.class, new VMExitsNative());
-        } else {
-            vmEntries = entries;
-            vmExits = new VMExitsNative();
-        }
-        return vmExits;
-    }
-
-    private static VMEntries initializeClient(VMExits exits) {
-        vmEntries = new VMEntriesNative();
-        vmExits = exits;
-        return vmEntries;
-    }
-
-    public static VMEntries getVMEntries() {
-        if (vmEntries == null) {
-            try {
-                vmEntries = new VMEntriesNative();
-                if (CountingProxy.ENABLED) {
-                    vmEntries = CountingProxy.getProxy(VMEntries.class, vmEntries);
-                }
-                if (Logger.ENABLED) {
-                    vmEntries = LoggingProxy.getProxy(VMEntries.class, vmEntries);
-                }
-            } catch (Throwable t) {
-                t.printStackTrace();
-            }
-        }
-        return vmEntries;
-    }
-
-    private static VMExits vmExits;
-
-    public static VMExits getVMExits() {
-        if (vmExits == null) {
-            String remote = System.getProperty("c1x.remote");
-            assert theInstance == null;
-            assert vmEntries == null;
-            try {
-                if (remote != null) {
-                    System.out.println("C1X compiler started in client/server mode, connection to server " + remote);
-                    Socket socket = new Socket(remote, 1199);
-                    ReplacingOutputStream output = new ReplacingOutputStream(socket.getOutputStream());
-                    ReplacingInputStream input = new ReplacingInputStream(socket.getInputStream());
-
-                    InvocationSocket invocation = new InvocationSocket(output, input);
-                    VMExits exits = (VMExits) Proxy.newProxyInstance(VMExits.class.getClassLoader(), new Class<?>[] {VMExits.class}, invocation);
-                    VMEntries entries = Compiler.initializeClient(exits);
-                    invocation.setDelegate(entries);
-                } else {
-                    vmExits = new VMExitsNative();
-                    if (CountingProxy.ENABLED) {
-                        vmExits = CountingProxy.getProxy(VMExits.class, vmExits);
-                    }
-                    if (Logger.ENABLED) {
-                        vmExits = LoggingProxy.getProxy(VMExits.class, vmExits);
-                    }
-                }
-            } catch (Throwable t) {
-                t.printStackTrace();
-            }
-        }
-        return vmExits;
-    }
-
-    private final C1XCompiler compiler;
-    private final HotSpotVMConfig config;
-    private final HotSpotRuntime runtime;
-    private final HotSpotRegisterConfig registerConfig;
-    private final CiTarget target;
-    private final RiXirGenerator generator;
-
-    private Compiler() {
-        config = getVMEntries().getConfiguration();
-        config.check();
-
-        runtime = new HotSpotRuntime(config);
-        final int wordSize = 8;
-        final int stackFrameAlignment = 16;
-        registerConfig = runtime.globalStubRegConfig;
-        target = new HotSpotTarget(new AMD64(), true, wordSize, stackFrameAlignment, config.vmPageSize, wordSize, true);
-
-        if (Logger.ENABLED) {
-            generator = LoggingProxy.getProxy(RiXirGenerator.class, new HotSpotXirGenerator(config, target, registerConfig));
-        } else {
-            generator = new HotSpotXirGenerator(config, target, registerConfig);
-        }
-        compiler = new C1XCompiler(runtime, target, generator, registerConfig);
-
-        // these options are important - c1x4hotspot will not generate correct code without them
-        C1XOptions.GenSpecialDivChecks = true;
-        C1XOptions.NullCheckUniquePc = true;
-        C1XOptions.InvokeSnippetAfterArguments = true;
-        C1XOptions.StackShadowPages = config.stackShadowPages;
-    }
-
-    public C1XCompiler getCompiler() {
-        return compiler;
-    }
-
-    public HotSpotVMConfig getConfig() {
-        return config;
-    }
-
-    public HotSpotRuntime getRuntime() {
-        return runtime;
-    }
-
-    public RiRegisterConfig getRegisterConfig() {
-        return registerConfig;
-    }
-
-    public CiTarget getTarget() {
-        return target;
-    }
-
-    public RiXirGenerator getGenerator() {
-        return generator;
-    }
-
-}
+/*
+ * Copyright (c) 2011 Sun Microsystems, Inc.  All rights reserved.
+ *
+ * Sun Microsystems, Inc. has intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation, these intellectual property
+ * rights may include one or more of the U.S. patents listed at http://www.sun.com/patents and one or
+ * more additional patents or pending patent applications in the U.S. and in other countries.
+ *
+ * U.S. Government Rights - Commercial software. Government users are subject to the Sun
+ * Microsystems, Inc. standard license agreement and applicable provisions of the FAR and its
+ * supplements.
+ *
+ * Use is subject to license terms. Sun, Sun Microsystems, the Sun logo, Java and Solaris are trademarks or
+ * registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries. All SPARC trademarks
+ * are used under license and are trademarks or registered trademarks of SPARC International, Inc. in the
+ * U.S. and other countries.
+ *
+ * UNIX is a registered trademark in the U.S. and other countries, exclusively licensed through X/Open
+ * Company, Ltd.
+ */
+package com.sun.hotspot.c1x;
+
+import com.sun.c1x.*;
+
+public interface Compiler {
+
+    public VMEntries getVMEntries();
+
+    public VMExits getVMExits();
+
+    public C1XCompiler getCompiler();
+
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/CompilerImpl.java	Mon Apr 11 11:25:06 2011 +0200
@@ -0,0 +1,181 @@
+/*
+ * Copyright (c) 2011 Sun Microsystems, Inc.  All rights reserved.
+ *
+ * Sun Microsystems, Inc. has intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation, these intellectual property
+ * rights may include one or more of the U.S. patents listed at http://www.sun.com/patents and one or
+ * more additional patents or pending patent applications in the U.S. and in other countries.
+ *
+ * U.S. Government Rights - Commercial software. Government users are subject to the Sun
+ * Microsystems, Inc. standard license agreement and applicable provisions of the FAR and its
+ * supplements.
+ *
+ * Use is subject to license terms. Sun, Sun Microsystems, the Sun logo, Java and Solaris are trademarks or
+ * registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries. All SPARC trademarks
+ * are used under license and are trademarks or registered trademarks of SPARC International, Inc. in the
+ * U.S. and other countries.
+ *
+ * UNIX is a registered trademark in the U.S. and other countries, exclusively licensed through X/Open
+ * Company, Ltd.
+ */
+package com.sun.hotspot.c1x;
+
+import java.io.*;
+import java.lang.management.*;
+import java.net.*;
+
+import com.sun.c1x.*;
+import com.sun.c1x.target.amd64.*;
+import com.sun.cri.xir.*;
+import com.sun.hotspot.c1x.logging.*;
+import com.sun.hotspot.c1x.server.*;
+
+/**
+ * Singleton class holding the instance of the C1XCompiler.
+ *
+ * @author Thomas Wuerthinger, Lukas Stadler
+ */
+public final class CompilerImpl implements Compiler, Remote {
+
+    private static Compiler theInstance;
+    private static boolean PrintGCStats = false;
+
+    private final VMEntries vmEntries;
+    private final VMExits vmExits;
+
+    private final C1XCompiler compiler;
+
+    public static Compiler getInstance() {
+        if (theInstance == null) {
+            // remote compilation (will not create a C1XCompiler)
+            String remote = System.getProperty("c1x.remote");
+            if (remote != null) {
+                try {
+                    System.out.println("C1X compiler started in client/server mode, server: " + remote);
+                    Socket socket = new Socket(remote, 1199);
+                    ReplacingStreams streams = new ReplacingStreams(socket.getOutputStream(), socket.getInputStream());
+                    streams.getInvocation().sendResult(new VMEntriesNative());
+
+                    theInstance = (Compiler) streams.getInvocation().waitForResult();
+                } catch (IOException e1) {
+                    System.out.println("Connection to compilation server FAILED.");
+                    throw new RuntimeException(e1);
+                } catch (ClassNotFoundException e2) {
+                    System.out.println("Connection to compilation server FAILED.");
+                    throw new RuntimeException(e2);
+                }
+            } else {
+                theInstance = new CompilerImpl(null);
+                Runtime.getRuntime().addShutdownHook(new ShutdownThread());
+            }
+        }
+        return theInstance;
+    }
+
+    public static class ShutdownThread extends Thread {
+
+        @Override
+        public void run() {
+            VMExitsNative.compileMethods = false;
+            if (C1XOptions.PrintMetrics) {
+                C1XMetrics.print();
+            }
+            if (C1XOptions.PrintTimers) {
+                C1XTimers.print();
+            }
+            if (PrintGCStats) {
+                printGCStats();
+            }
+        }
+    }
+
+    public static void printGCStats() {
+        long totalGarbageCollections = 0;
+        long garbageCollectionTime = 0;
+
+        for (GarbageCollectorMXBean gc : ManagementFactory.getGarbageCollectorMXBeans()) {
+            long count = gc.getCollectionCount();
+            if (count >= 0) {
+                totalGarbageCollections += count;
+            }
+
+            long time = gc.getCollectionTime();
+            if (time >= 0) {
+                garbageCollectionTime += time;
+            }
+        }
+
+        System.out.println("Total Garbage Collections: " + totalGarbageCollections);
+        System.out.println("Total Garbage Collection Time (ms): " + garbageCollectionTime);
+    }
+
+    public static Compiler initializeServer(VMEntries entries) {
+        assert theInstance == null;
+        theInstance = new CompilerImpl(entries);
+        Runtime.getRuntime().addShutdownHook(new ShutdownThread());
+        return theInstance;
+    }
+
+    @Override
+    public VMEntries getVMEntries() {
+        return vmEntries;
+    }
+
+    @Override
+    public VMExits getVMExits() {
+        return vmExits;
+    }
+
+    private CompilerImpl(VMEntries entries) {
+
+        // initialize VMEntries
+        if (entries == null)
+            entries = new VMEntriesNative();
+
+        // initialize VMExits
+        VMExits exits = new VMExitsNative(this);
+
+        // logging, etc.
+        if (CountingProxy.ENABLED) {
+            exits = CountingProxy.getProxy(VMExits.class, exits);
+            entries = CountingProxy.getProxy(VMEntries.class, entries);
+        }
+        if (Logger.ENABLED) {
+            exits = LoggingProxy.getProxy(VMExits.class, exits);
+            entries = LoggingProxy.getProxy(VMEntries.class, entries);
+        }
+
+        // set the final fields
+        vmEntries = entries;
+        vmExits = exits;
+
+        // initialize compiler and C1XOptions
+        HotSpotVMConfig config = vmEntries.getConfiguration();
+        config.check();
+
+        // these options are important - c1x4hotspot will not generate correct code without them
+        C1XOptions.GenSpecialDivChecks = true;
+        C1XOptions.NullCheckUniquePc = true;
+        C1XOptions.InvokeSnippetAfterArguments = true;
+        C1XOptions.StackShadowPages = config.stackShadowPages;
+
+        HotSpotRuntime runtime = new HotSpotRuntime(config, this);
+        HotSpotRegisterConfig registerConfig = runtime.globalStubRegConfig;
+
+        final int wordSize = 8;
+        final int stackFrameAlignment = 16;
+        HotSpotTarget target = new HotSpotTarget(new AMD64(), true, wordSize, stackFrameAlignment, config.vmPageSize, wordSize, true);
+
+        RiXirGenerator generator = new HotSpotXirGenerator(config, target, registerConfig, this);
+        if (Logger.ENABLED) {
+            generator = LoggingProxy.getProxy(RiXirGenerator.class, generator);
+        }
+        compiler = new C1XCompiler(runtime, target, generator, registerConfig);
+    }
+
+    @Override
+    public C1XCompiler getCompiler() {
+        return compiler;
+    }
+
+}
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/CompilerObject.java	Mon Apr 11 10:22:05 2011 +0200
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/CompilerObject.java	Mon Apr 11 11:25:06 2011 +0200
@@ -29,4 +29,10 @@
  * @author Lukas Stadler
  */
 public abstract class CompilerObject implements Serializable {
+    protected final Compiler compiler;
+
+    protected CompilerObject(Compiler compiler) {
+        this.compiler = compiler;
+    }
+
 }
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotConstantPool.java	Mon Apr 11 10:22:05 2011 +0200
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotConstantPool.java	Mon Apr 11 11:25:06 2011 +0200
@@ -20,6 +20,7 @@
  */
 package com.sun.hotspot.c1x;
 
+import java.io.*;
 import java.util.*;
 
 import com.sun.cri.ri.*;
@@ -37,7 +38,7 @@
     private final FastLRUIntCache<RiField> fieldCache = new FastLRUIntCache<RiField>();
     private final FastLRUIntCache<RiType> typeCache = new FastLRUIntCache<RiType>();
 
-    public static class FastLRUIntCache<T> {
+    public static class FastLRUIntCache<T> implements Serializable {
 
         private static final int InitialCapacity = 4;
         private int lastKey;
@@ -96,26 +97,27 @@
         }
     }
 
-    public HotSpotConstantPool(long vmId) {
+    public HotSpotConstantPool(Compiler compiler, long vmId) {
+        super(compiler);
         this.vmId = vmId;
     }
 
     @Override
     public Object lookupConstant(int cpi) {
-        Object constant = Compiler.getVMEntries().RiConstantPool_lookupConstant(vmId, cpi);
+        Object constant = compiler.getVMEntries().RiConstantPool_lookupConstant(vmId, cpi);
         return constant;
     }
 
     @Override
     public RiSignature lookupSignature(int cpi) {
-        return Compiler.getVMEntries().RiConstantPool_lookupSignature(vmId, cpi);
+        return compiler.getVMEntries().RiConstantPool_lookupSignature(vmId, cpi);
     }
 
     @Override
     public RiMethod lookupMethod(int cpi, int byteCode) {
         RiMethod result = methodCache.get(cpi);
         if (result == null) {
-            result = Compiler.getVMEntries().RiConstantPool_lookupMethod(vmId, cpi, (byte) byteCode);
+            result = compiler.getVMEntries().RiConstantPool_lookupMethod(vmId, cpi, (byte) byteCode);
             methodCache.add(cpi, result);
         }
         return result;
@@ -125,7 +127,7 @@
     public RiType lookupType(int cpi, int opcode) {
         RiType result = typeCache.get(cpi);
         if (result == null) {
-            result = Compiler.getVMEntries().RiConstantPool_lookupType(vmId, cpi);
+            result = compiler.getVMEntries().RiConstantPool_lookupType(vmId, cpi);
             typeCache.add(cpi, result);
         }
         return result;
@@ -135,7 +137,7 @@
     public RiField lookupField(int cpi, int opcode) {
         RiField result = fieldCache.get(cpi);
         if (result == null) {
-            result = Compiler.getVMEntries().RiConstantPool_lookupField(vmId, cpi, (byte) opcode);
+            result = compiler.getVMEntries().RiConstantPool_lookupField(vmId, cpi, (byte) opcode);
             fieldCache.add(cpi, result);
         }
         return result;
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotExceptionHandler.java	Mon Apr 11 10:22:05 2011 +0200
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotExceptionHandler.java	Mon Apr 11 11:25:06 2011 +0200
@@ -30,6 +30,10 @@
     private int catchClassIndex;
     private RiType catchClass;
 
+    public HotSpotExceptionHandler() {
+        super(null);
+    }
+
     @Override
     public int startBCI() {
         return startBci;
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotField.java	Mon Apr 11 10:22:05 2011 +0200
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotField.java	Mon Apr 11 11:25:06 2011 +0200
@@ -42,7 +42,8 @@
     private final int offset;
     private CiConstant constant;
 
-    public HotSpotField(RiType holder, String name, RiType type, int offset) {
+    public HotSpotField(Compiler compiler, RiType holder, String name, RiType type, int offset) {
+        super(compiler);
         this.holder = holder;
         this.name = name;
         this.type = type;
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotMethod.java	Mon Apr 11 10:22:05 2011 +0200
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotMethod.java	Mon Apr 11 11:25:06 2011 +0200
@@ -28,6 +28,10 @@
     protected RiType holder;
     protected String name;
 
+    protected HotSpotMethod(Compiler compiler) {
+        super(compiler);
+    }
+
     @Override
     public final RiType holder() {
         return holder;
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotMethodResolved.java	Mon Apr 11 10:22:05 2011 +0200
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotMethodResolved.java	Mon Apr 11 11:25:06 2011 +0200
@@ -43,16 +43,17 @@
     private RiSignature signature;
     private Boolean hasBalancedMonitors;
 
-    public HotSpotMethodResolved(long vmId, String name) {
+    public HotSpotMethodResolved(Compiler compiler, long vmId, String name) {
+        super(compiler);
         this.vmId = vmId;
         this.name = name;
-        this.holder = Compiler.getVMEntries().RiMethod_holder(vmId);
+        this.holder = compiler.getVMEntries().RiMethod_holder(vmId);
     }
 
     @Override
     public int accessFlags() {
         if (accessFlags == -1) {
-            accessFlags = Compiler.getVMEntries().RiMethod_accessFlags(vmId);
+            accessFlags = compiler.getVMEntries().RiMethod_accessFlags(vmId);
         }
         return accessFlags;
     }
@@ -65,7 +66,7 @@
     @Override
     public byte[] code() {
         if (code == null) {
-            code = Compiler.getVMEntries().RiMethod_code(vmId);
+            code = compiler.getVMEntries().RiMethod_code(vmId);
         }
         return code;
     }
@@ -73,7 +74,7 @@
     @Override
     public RiExceptionHandler[] exceptionHandlers() {
         if (exceptionHandlers == null) {
-            exceptionHandlers = Compiler.getVMEntries().RiMethod_exceptionHandlers(vmId);
+            exceptionHandlers = compiler.getVMEntries().RiMethod_exceptionHandlers(vmId);
         }
         return exceptionHandlers;
     }
@@ -81,7 +82,7 @@
     @Override
     public boolean hasBalancedMonitors() {
         if (hasBalancedMonitors == null) {
-            hasBalancedMonitors = Compiler.getVMEntries().RiMethod_hasBalancedMonitors(vmId);
+            hasBalancedMonitors = compiler.getVMEntries().RiMethod_hasBalancedMonitors(vmId);
         }
         return hasBalancedMonitors;
     }
@@ -128,7 +129,7 @@
     @Override
     public int maxLocals() {
         if (maxLocals == -1) {
-            maxLocals = Compiler.getVMEntries().RiMethod_maxLocals(vmId);
+            maxLocals = compiler.getVMEntries().RiMethod_maxLocals(vmId);
         }
         return maxLocals;
     }
@@ -136,7 +137,7 @@
     @Override
     public int maxStackSize() {
         if (maxStackSize == -1) {
-            maxStackSize = Compiler.getVMEntries().RiMethod_maxStackSize(vmId);
+            maxStackSize = compiler.getVMEntries().RiMethod_maxStackSize(vmId);
         }
         return maxStackSize;
     }
@@ -153,13 +154,13 @@
 
     @Override
     public RiMethod uniqueConcreteMethod() {
-        return Compiler.getVMEntries().RiMethod_uniqueConcreteMethod(vmId);
+        return compiler.getVMEntries().RiMethod_uniqueConcreteMethod(vmId);
     }
 
     @Override
     public RiSignature signature() {
         if (signature == null) {
-            signature = new HotSpotSignature(Compiler.getVMEntries().RiMethod_signature(vmId));
+            signature = new HotSpotSignature(compiler, compiler.getVMEntries().RiMethod_signature(vmId));
         }
         return signature;
     }
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotMethodUnresolved.java	Mon Apr 11 10:22:05 2011 +0200
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotMethodUnresolved.java	Mon Apr 11 11:25:06 2011 +0200
@@ -31,10 +31,11 @@
 public final class HotSpotMethodUnresolved extends HotSpotMethod {
     private final RiSignature signature;
 
-    public HotSpotMethodUnresolved(String name, String signature, RiType holder) {
+    public HotSpotMethodUnresolved(Compiler compiler, String name, String signature, RiType holder) {
+        super(compiler);
         this.name = name;
         this.holder = holder;
-        this.signature = new HotSpotSignature(signature);
+        this.signature = new HotSpotSignature(compiler, signature);
     }
 
     @Override
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotRuntime.java	Mon Apr 11 10:22:05 2011 +0200
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotRuntime.java	Mon Apr 11 11:25:06 2011 +0200
@@ -42,10 +42,12 @@
     final HotSpotVMConfig config;
     final HotSpotRegisterConfig regConfig;
     final HotSpotRegisterConfig globalStubRegConfig;
+    private final Compiler compiler;
 
 
-    public HotSpotRuntime(HotSpotVMConfig config) {
+    public HotSpotRuntime(HotSpotVMConfig config, Compiler compiler) {
         this.config = config;
+        this.compiler = compiler;
         regConfig = new HotSpotRegisterConfig(config, false);
         globalStubRegConfig = new HotSpotRegisterConfig(config, true);
     }
@@ -141,7 +143,7 @@
     @Override
     public RiType getRiType(Class<?> javaClass) {
         assert javaClass != null;
-        return Compiler.getVMEntries().getType(javaClass);
+        return compiler.getVMEntries().getType(javaClass);
     }
 
     @Override
@@ -183,7 +185,7 @@
 
     @Override
     public Object registerGlobalStub(CiTargetMethod targetMethod, String name) {
-        return HotSpotTargetMethod.installStub(targetMethod, name);
+        return HotSpotTargetMethod.installStub(compiler, targetMethod, name);
     }
 
     @Override
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotSignature.java	Mon Apr 11 10:22:05 2011 +0200
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotSignature.java	Mon Apr 11 11:25:06 2011 +0200
@@ -38,7 +38,8 @@
     private RiType[] argumentTypes;
     private RiType returnTypeCache;
 
-    public HotSpotSignature(String signature) {
+    public HotSpotSignature(Compiler compiler, String signature) {
+        super(compiler);
         assert signature.length() > 0;
         this.originalString = signature;
 
@@ -116,7 +117,7 @@
         }
         RiType type = argumentTypes[index];
         if (type == null) {
-            type = Compiler.getVMEntries().RiSignature_lookupType(arguments.get(index), (HotSpotTypeResolved) accessingClass);
+            type = compiler.getVMEntries().RiSignature_lookupType(arguments.get(index), (HotSpotTypeResolved) accessingClass);
             argumentTypes[index] = type;
         }
         return type;
@@ -135,7 +136,7 @@
     @Override
     public RiType returnType(RiType accessingClass) {
         if (returnTypeCache == null) {
-            returnTypeCache = Compiler.getVMEntries().RiSignature_lookupType(returnType, (HotSpotTypeResolved) accessingClass);
+            returnTypeCache = compiler.getVMEntries().RiSignature_lookupType(returnType, (HotSpotTypeResolved) accessingClass);
         }
         return returnTypeCache;
     }
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotTargetMethod.java	Mon Apr 11 10:22:05 2011 +0200
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotTargetMethod.java	Mon Apr 11 11:25:06 2011 +0200
@@ -40,7 +40,8 @@
     public final Site[] sites;
     public final ExceptionHandler[] exceptionHandlers;
 
-    private HotSpotTargetMethod(HotSpotMethodResolved method, CiTargetMethod targetMethod) {
+    private HotSpotTargetMethod(Compiler compiler, HotSpotMethodResolved method, CiTargetMethod targetMethod) {
+        super(compiler);
         this.method = method;
         this.targetMethod = targetMethod;
         this.name = null;
@@ -53,7 +54,8 @@
         }
     }
 
-    private HotSpotTargetMethod(CiTargetMethod targetMethod, String name) {
+    private HotSpotTargetMethod(Compiler compiler, CiTargetMethod targetMethod, String name) {
+        super(compiler);
         this.method = null;
         this.targetMethod = targetMethod;
         this.name = name;
@@ -93,12 +95,12 @@
         return result;
     }
 
-    public static void installMethod(HotSpotMethodResolved method, CiTargetMethod targetMethod) {
-        Compiler.getVMEntries().installMethod(new HotSpotTargetMethod(method, targetMethod));
+    public static void installMethod(Compiler compiler, HotSpotMethodResolved method, CiTargetMethod targetMethod) {
+        compiler.getVMEntries().installMethod(new HotSpotTargetMethod(compiler, method, targetMethod));
     }
 
-    public static Object installStub(CiTargetMethod targetMethod, String name) {
-        return Compiler.getVMEntries().installStub(new HotSpotTargetMethod(targetMethod, name));
+    public static Object installStub(Compiler compiler, CiTargetMethod targetMethod, String name) {
+        return compiler.getVMEntries().installStub(new HotSpotTargetMethod(compiler, targetMethod, name));
     }
 
 }
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotType.java	Mon Apr 11 10:22:05 2011 +0200
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotType.java	Mon Apr 11 11:25:06 2011 +0200
@@ -30,6 +30,10 @@
 public abstract class HotSpotType extends CompilerObject implements RiType {
     protected String name;
 
+    protected HotSpotType(Compiler compiler) {
+        super(compiler);
+    }
+
     @Override
     public final String name() {
         return name;
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotTypePrimitive.java	Mon Apr 11 10:22:05 2011 +0200
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotTypePrimitive.java	Mon Apr 11 11:25:06 2011 +0200
@@ -33,17 +33,9 @@
 
     private CiKind kind;
 
-    public static final HotSpotTypePrimitive Boolean = new HotSpotTypePrimitive(CiKind.Boolean);
-    public static final HotSpotTypePrimitive Char = new HotSpotTypePrimitive(CiKind.Char);
-    public static final HotSpotTypePrimitive Float = new HotSpotTypePrimitive(CiKind.Float);
-    public static final HotSpotTypePrimitive Double = new HotSpotTypePrimitive(CiKind.Double);
-    public static final HotSpotTypePrimitive Byte = new HotSpotTypePrimitive(CiKind.Byte);
-    public static final HotSpotTypePrimitive Short = new HotSpotTypePrimitive(CiKind.Short);
-    public static final HotSpotTypePrimitive Int = new HotSpotTypePrimitive(CiKind.Int);
-    public static final HotSpotTypePrimitive Long = new HotSpotTypePrimitive(CiKind.Long);
-    public static final HotSpotTypePrimitive Void = new HotSpotTypePrimitive(CiKind.Void);
 
-    private HotSpotTypePrimitive(CiKind kind) {
+    HotSpotTypePrimitive(Compiler compiler, CiKind kind) {
+        super(compiler);
         this.kind = kind;
         this.name = kind.toString();
     }
@@ -55,7 +47,7 @@
 
     @Override
     public RiType arrayOf() {
-        return Compiler.getVMEntries().getPrimitiveArrayType(kind);
+        return compiler.getVMEntries().getPrimitiveArrayType(kind);
     }
 
     @Override
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotTypeResolved.java	Mon Apr 11 10:22:05 2011 +0200
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotTypeResolved.java	Mon Apr 11 11:25:06 2011 +0200
@@ -1,202 +1,36 @@
-/*
- * Copyright (c) 2010 Sun Microsystems, Inc.  All rights reserved.
- *
- * Sun Microsystems, Inc. has intellectual property rights relating to technology embodied in the product
- * that is described in this document. In particular, and without limitation, these intellectual property
- * rights may include one or more of the U.S. patents listed at http://www.sun.com/patents and one or
- * more additional patents or pending patent applications in the U.S. and in other countries.
- *
- * U.S. Government Rights - Commercial software. Government users are subject to the Sun
- * Microsystems, Inc. standard license agreement and applicable provisions of the FAR and its
- * supplements.
- *
- * Use is subject to license terms. Sun, Sun Microsystems, the Sun logo, Java and Solaris are trademarks or
- * registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries. All SPARC trademarks
- * are used under license and are trademarks or registered trademarks of SPARC International, Inc. in the
- * U.S. and other countries.
- *
- * UNIX is a registered trademark in the U.S. and other countries, exclusively licensed through X/Open
- * Company, Ltd.
- */
-package com.sun.hotspot.c1x;
-
-import java.lang.reflect.*;
-import java.util.*;
-
-import com.sun.cri.ci.*;
-import com.sun.cri.ri.*;
-
-/**
- * Implementation of RiType for resolved non-primitive HotSpot classes.
- *
- * @author Thomas Wuerthinger, Lukas Stadler
- */
-public class HotSpotTypeResolved extends HotSpotType {
-
-    private Class javaMirror;
-    private String simpleName;
-    private int accessFlags;
-    private boolean hasFinalizer;
-    private boolean hasSubclass;
-    private boolean hasFinalizableSubclass;
-    private boolean isInitialized;
-    private boolean isArrayClass;
-    private boolean isInstanceClass;
-    private boolean isInterface;
-    private int instanceSize;
-    private RiType componentType;
-    private HashMap<Integer, RiField> fieldCache;
-    private RiConstantPool pool;
-
-    @Override
-    public int accessFlags() {
-        return accessFlags;
-    }
-
-    @Override
-    public RiType arrayOf() {
-        return Compiler.getVMEntries().RiType_arrayOf(this);
-    }
-
-    @Override
-    public RiType componentType() {
-        return Compiler.getVMEntries().RiType_componentType(this);
-    }
-
-    @Override
-    public RiType uniqueConcreteSubtype() {
-        return Compiler.getVMEntries().RiType_uniqueConcreteSubtype(this);
-    }
-
-    @Override
-    public RiType exactType() {
-        if (Modifier.isFinal(accessFlags)) {
-            return this;
-        }
-        return null;
-    }
-
-    @Override
-    public CiConstant getEncoding(Representation r) {
-        switch (r) {
-            case JavaClass:
-                return CiConstant.forObject(javaClass());
-            case ObjectHub:
-                return CiConstant.forObject(this);
-            case StaticFields:
-                return CiConstant.forObject(this);
-            case TypeInfo:
-                return CiConstant.forObject(this);
-            default:
-                return null;
-        }
-    }
-
-    @Override
-    public CiKind getRepresentationKind(Representation r) {
-        return CiKind.Object;
-    }
-
-    @Override
-    public boolean hasFinalizableSubclass() {
-        return hasFinalizableSubclass;
-    }
-
-    @Override
-    public boolean hasFinalizer() {
-        return hasFinalizer;
-    }
-
-    @Override
-    public boolean hasSubclass() {
-        return hasSubclass;
-    }
-
-    @Override
-    public boolean isArrayClass() {
-        return isArrayClass;
-    }
-
-    @Override
-    public boolean isInitialized() {
-        return isInitialized;
-    }
-
-    @Override
-    public boolean isInstance(CiConstant obj) {
-        return javaMirror.isInstance(obj);
-    }
-
-    @Override
-    public boolean isInstanceClass() {
-        return isInstanceClass;
-    }
-
-    @Override
-    public boolean isInterface() {
-        return isInterface;
-    }
-
-    @Override
-    public boolean isResolved() {
-        return true;
-    }
-
-    @Override
-    public boolean isSubtypeOf(RiType other) {
-        if (other instanceof HotSpotTypeResolved) {
-            return Compiler.getVMEntries().RiType_isSubtypeOf(this, other);
-        }
-        // No resolved type is a subtype of an unresolved type.
-        return false;
-    }
-
-    @Override
-    public Class<?> javaClass() {
-        return javaMirror;
-    }
-
-    @Override
-    public CiKind kind() {
-        return CiKind.Object;
-    }
-
-    @Override
-    public RiMethod resolveMethodImpl(RiMethod method) {
-        assert method instanceof HotSpotMethod;
-        return Compiler.getVMEntries().RiType_resolveMethodImpl(this, method.name(), method.signature().asString());
-    }
-
-    @Override
-    public String toString() {
-        return "HotSpotType<" + simpleName + ", resolved>";
-    }
-
-    public RiConstantPool constantPool() {
-        // TODO: Implement constant pool without the need for VmId and cache the constant pool.
-        return Compiler.getVMEntries().RiType_constantPool(this);
-    }
-
-    public int instanceSize() {
-        return instanceSize;
-    }
-
-    public RiField createRiField(String name, RiType type, int offset) {
-        RiField result = null;
-
-        // (tw) Must cache the fields, because the local load elimination only works if the objects from two field lookups are equal.
-        if (fieldCache == null) {
-            fieldCache = new HashMap<Integer, RiField>(8);
-        } else {
-            result = fieldCache.get(offset);
-        }
-
-        if (result == null) {
-            result = new HotSpotField(this, name, type, offset);
-            fieldCache.put(offset, result);
-        }
-
-        return result;
-    }
-
-}
+/*
+ * Copyright (c) 2011 Sun Microsystems, Inc.  All rights reserved.
+ *
+ * Sun Microsystems, Inc. has intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation, these intellectual property
+ * rights may include one or more of the U.S. patents listed at http://www.sun.com/patents and one or
+ * more additional patents or pending patent applications in the U.S. and in other countries.
+ *
+ * U.S. Government Rights - Commercial software. Government users are subject to the Sun
+ * Microsystems, Inc. standard license agreement and applicable provisions of the FAR and its
+ * supplements.
+ *
+ * Use is subject to license terms. Sun, Sun Microsystems, the Sun logo, Java and Solaris are trademarks or
+ * registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries. All SPARC trademarks
+ * are used under license and are trademarks or registered trademarks of SPARC International, Inc. in the
+ * U.S. and other countries.
+ *
+ * UNIX is a registered trademark in the U.S. and other countries, exclusively licensed through X/Open
+ * Company, Ltd.
+ */
+package com.sun.hotspot.c1x;
+
+import com.sun.cri.ri.*;
+import com.sun.hotspot.c1x.server.*;
+
+public interface HotSpotTypeResolved extends RiType, Remote {
+
+    public String toString();
+
+    public RiConstantPool constantPool();
+
+    public int instanceSize();
+
+    public RiField createRiField(String name, RiType type, int offset);
+
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotTypeResolvedImpl.java	Mon Apr 11 11:25:06 2011 +0200
@@ -0,0 +1,209 @@
+/*
+ * Copyright (c) 2010 Sun Microsystems, Inc.  All rights reserved.
+ *
+ * Sun Microsystems, Inc. has intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation, these intellectual property
+ * rights may include one or more of the U.S. patents listed at http://www.sun.com/patents and one or
+ * more additional patents or pending patent applications in the U.S. and in other countries.
+ *
+ * U.S. Government Rights - Commercial software. Government users are subject to the Sun
+ * Microsystems, Inc. standard license agreement and applicable provisions of the FAR and its
+ * supplements.
+ *
+ * Use is subject to license terms. Sun, Sun Microsystems, the Sun logo, Java and Solaris are trademarks or
+ * registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries. All SPARC trademarks
+ * are used under license and are trademarks or registered trademarks of SPARC International, Inc. in the
+ * U.S. and other countries.
+ *
+ * UNIX is a registered trademark in the U.S. and other countries, exclusively licensed through X/Open
+ * Company, Ltd.
+ */
+package com.sun.hotspot.c1x;
+
+import java.lang.reflect.*;
+import java.util.*;
+
+import com.sun.cri.ci.*;
+import com.sun.cri.ri.*;
+
+/**
+ * Implementation of RiType for resolved non-primitive HotSpot classes.
+ *
+ * @author Thomas Wuerthinger, Lukas Stadler
+ */
+public class HotSpotTypeResolvedImpl extends HotSpotType implements HotSpotTypeResolved {
+
+    private Class javaMirror;
+    private String simpleName;
+    private int accessFlags;
+    private boolean hasFinalizer;
+    private boolean hasSubclass;
+    private boolean hasFinalizableSubclass;
+    private boolean isInitialized;
+    private boolean isArrayClass;
+    private boolean isInstanceClass;
+    private boolean isInterface;
+    private int instanceSize;
+    private RiType componentType;
+    private HashMap<Integer, RiField> fieldCache;
+    private RiConstantPool pool;
+
+    private HotSpotTypeResolvedImpl() {
+        super(null);
+    }
+
+    @Override
+    public int accessFlags() {
+        return accessFlags;
+    }
+
+    @Override
+    public RiType arrayOf() {
+        return compiler.getVMEntries().RiType_arrayOf(this);
+    }
+
+    @Override
+    public RiType componentType() {
+        return compiler.getVMEntries().RiType_componentType(this);
+    }
+
+    @Override
+    public RiType uniqueConcreteSubtype() {
+        return compiler.getVMEntries().RiType_uniqueConcreteSubtype(this);
+    }
+
+    @Override
+    public RiType exactType() {
+        if (Modifier.isFinal(accessFlags)) {
+            return this;
+        }
+        return null;
+    }
+
+    @Override
+    public CiConstant getEncoding(Representation r) {
+        switch (r) {
+            case JavaClass:
+                return CiConstant.forObject(javaClass());
+            case ObjectHub:
+                return CiConstant.forObject(this);
+            case StaticFields:
+                return CiConstant.forObject(this);
+            case TypeInfo:
+                return CiConstant.forObject(this);
+            default:
+                return null;
+        }
+    }
+
+    @Override
+    public CiKind getRepresentationKind(Representation r) {
+        return CiKind.Object;
+    }
+
+    @Override
+    public boolean hasFinalizableSubclass() {
+        return hasFinalizableSubclass;
+    }
+
+    @Override
+    public boolean hasFinalizer() {
+        return hasFinalizer;
+    }
+
+    @Override
+    public boolean hasSubclass() {
+        return hasSubclass;
+    }
+
+    @Override
+    public boolean isArrayClass() {
+        return isArrayClass;
+    }
+
+    @Override
+    public boolean isInitialized() {
+        return isInitialized;
+    }
+
+    @Override
+    public boolean isInstance(CiConstant obj) {
+        return javaMirror.isInstance(obj);
+    }
+
+    @Override
+    public boolean isInstanceClass() {
+        return isInstanceClass;
+    }
+
+    @Override
+    public boolean isInterface() {
+        return isInterface;
+    }
+
+    @Override
+    public boolean isResolved() {
+        return true;
+    }
+
+    @Override
+    public boolean isSubtypeOf(RiType other) {
+        if (other instanceof HotSpotTypeResolved) {
+            return compiler.getVMEntries().RiType_isSubtypeOf(this, other);
+        }
+        // No resolved type is a subtype of an unresolved type.
+        return false;
+    }
+
+    @Override
+    public Class<?> javaClass() {
+        return javaMirror;
+    }
+
+    @Override
+    public CiKind kind() {
+        return CiKind.Object;
+    }
+
+    @Override
+    public RiMethod resolveMethodImpl(RiMethod method) {
+        assert method instanceof HotSpotMethod;
+        return compiler.getVMEntries().RiType_resolveMethodImpl(this, method.name(), method.signature().asString());
+    }
+
+    @Override
+    public String toString() {
+        return "HotSpotType<" + simpleName + ", resolved>";
+    }
+
+    @Override
+    public RiConstantPool constantPool() {
+        // TODO: Implement constant pool without the need for VmId and cache the constant pool.
+        return compiler.getVMEntries().RiType_constantPool(this);
+    }
+
+    @Override
+    public int instanceSize() {
+        return instanceSize;
+    }
+
+    @Override
+    public RiField createRiField(String name, RiType type, int offset) {
+        RiField result = null;
+
+        // (tw) Must cache the fields, because the local load elimination only works if the objects from two field lookups are equal.
+        if (fieldCache == null) {
+            fieldCache = new HashMap<Integer, RiField>(8);
+        } else {
+            result = fieldCache.get(offset);
+        }
+
+        if (result == null) {
+            result = new HotSpotField(compiler, this, name, type, offset);
+            fieldCache.put(offset, result);
+        }
+
+        return result;
+    }
+
+}
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotTypeUnresolved.java	Mon Apr 11 10:22:05 2011 +0200
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotTypeUnresolved.java	Mon Apr 11 11:25:06 2011 +0200
@@ -36,7 +36,8 @@
     /**
      * Creates a new unresolved type for a specified type descriptor.
      */
-    public HotSpotTypeUnresolved(String name) {
+    public HotSpotTypeUnresolved(Compiler compiler, String name) {
+        super(compiler);
         assert name.length() > 0 : "name cannot be empty";
 
         int dimensions = 0;
@@ -58,7 +59,8 @@
         this.dimensions = dimensions;
     }
 
-    public HotSpotTypeUnresolved(String name, int dimensions) {
+    public HotSpotTypeUnresolved(Compiler compiler, String name, int dimensions) {
+        super(compiler);
         assert dimensions >= 0;
         this.simpleName = name;
         this.dimensions = dimensions;
@@ -142,7 +144,7 @@
     @Override
     public RiType componentType() {
         assert isArrayClass() : "no array class" + name();
-        return new HotSpotTypeUnresolved(simpleName, dimensions - 1);
+        return new HotSpotTypeUnresolved(compiler, simpleName, dimensions - 1);
     }
 
     @Override
@@ -152,7 +154,7 @@
 
     @Override
     public RiType arrayOf() {
-        return new HotSpotTypeUnresolved(simpleName, dimensions + 1);
+        return new HotSpotTypeUnresolved(compiler, simpleName, dimensions + 1);
     }
 
     @Override
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotVMConfig.java	Mon Apr 11 10:22:05 2011 +0200
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotVMConfig.java	Mon Apr 11 11:25:06 2011 +0200
@@ -29,6 +29,10 @@
  */
 public class HotSpotVMConfig extends CompilerObject {
 
+    private HotSpotVMConfig() {
+        super(null);
+    }
+
     // os information, register layout, code generation, ...
     public boolean windowsOs;
     public int codeEntryAlignment;
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotXirGenerator.java	Mon Apr 11 10:22:05 2011 +0200
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotXirGenerator.java	Mon Apr 11 11:25:06 2011 +0200
@@ -72,13 +72,15 @@
     private final HotSpotVMConfig config;
     private final CiTarget target;
     private final RiRegisterConfig registerConfig;
+    private final Compiler compiler;
 
     private CiXirAssembler asm;
 
-    public HotSpotXirGenerator(HotSpotVMConfig config, CiTarget target, RiRegisterConfig registerConfig) {
+    public HotSpotXirGenerator(HotSpotVMConfig config, CiTarget target, RiRegisterConfig registerConfig, Compiler compiler) {
         this.config = config;
         this.target = target;
         this.registerConfig = registerConfig;
+        this.compiler = compiler;
     }
 
     private SimpleTemplates prologueTemplates = new SimpleTemplates(STATIC_METHOD) {
@@ -336,8 +338,8 @@
         }
     };
 
-    private static CiRegister getGeneralParameterRegister(int index) {
-        return Compiler.getInstance().getRegisterConfig().getCallingConventionRegisters(CiCallingConvention.Type.RuntimeCall, RegisterFlag.CPU)[index];
+    private CiRegister getGeneralParameterRegister(int index) {
+        return registerConfig.getCallingConventionRegisters(CiCallingConvention.Type.RuntimeCall, RegisterFlag.CPU)[index];
     }
 
     private SimpleTemplates monitorExitTemplates = new SimpleTemplates(NULL_CHECK) {
@@ -1144,7 +1146,7 @@
     @Override
     public XirSnippet genResolveClass(XirSite site, RiType type, Representation rep) {
         assert rep == Representation.ObjectHub || rep == Representation.StaticFields || rep == Representation.JavaClass : "unexpected representation: " + rep;
-        if (type instanceof HotSpotTypeResolved) {
+        if (type.isResolved()) {
             return new XirSnippet(resolveClassTemplates.get(site), XirArgument.forObject(type));
         }
         return new XirSnippet(resolveClassTemplates.get(site, UNRESOLVED));
@@ -1224,7 +1226,7 @@
 
     @Override
     public XirSnippet genNewInstance(XirSite site, RiType type) {
-        if (type instanceof HotSpotTypeResolved) {
+        if (type.isResolved()) {
             int instanceSize = ((HotSpotTypeResolved) type).instanceSize();
             return new XirSnippet(newInstanceTemplates.get(site, instanceSize), XirArgument.forObject(type));
         }
@@ -1234,13 +1236,13 @@
     @Override
     public XirSnippet genNewArray(XirSite site, XirArgument length, CiKind elementKind, RiType componentType, RiType arrayType) {
         if (elementKind == CiKind.Object) {
-            if (arrayType instanceof HotSpotTypeResolved) {
+            if (arrayType.isResolved()) {
                 return new XirSnippet(newObjectArrayTemplates.get(site), length, XirArgument.forObject(arrayType));
             }
             return new XirSnippet(newObjectArrayTemplates.get(site, UNRESOLVED), length);
         }
         assert arrayType == null;
-        arrayType = Compiler.getVMEntries().getPrimitiveArrayType(elementKind);
+        arrayType = compiler.getVMEntries().getPrimitiveArrayType(elementKind);
         return new XirSnippet(newTypeArrayTemplates.get(site, elementKind), length, XirArgument.forObject(arrayType));
     }
 
@@ -1251,7 +1253,7 @@
 
     @Override
     public XirSnippet genNewMultiArray(XirSite site, XirArgument[] lengths, RiType type) {
-        if (type instanceof HotSpotTypeResolved) {
+        if (type.isResolved()) {
             XirArgument[] params = Arrays.copyOf(lengths, lengths.length + 1);
             params[lengths.length] = XirArgument.forObject(type);
             return new XirSnippet(multiNewArrayTemplate.get(site, lengths.length), params);
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/InvocationSocket.java	Mon Apr 11 10:22:05 2011 +0200
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/InvocationSocket.java	Mon Apr 11 11:25:06 2011 +0200
@@ -34,27 +34,24 @@
  *
  * @author Lukas Stadler
  */
-public class InvocationSocket implements InvocationHandler {
+public class InvocationSocket {
 
     private final ObjectOutputStream output;
     private final ObjectInputStream input;
-    private Object delegate;
 
     public InvocationSocket(ObjectOutputStream output, ObjectInputStream input) {
         this.output = output;
         this.input = input;
     }
 
-    public void setDelegate(Object delegate) {
-        this.delegate = delegate;
-    }
-
     private static class Invocation implements Serializable {
 
+        public Object receiver;
         public String methodName;
         public Object[] args;
 
-        public Invocation(String methodName, Object[] args) {
+        public Invocation(Object receiver, String methodName, Object[] args) {
+            this.receiver = receiver;
             this.methodName = methodName;
             this.args = args;
         }
@@ -69,18 +66,29 @@
         }
     }
 
-    @Override
-    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
-        try {
-            Logger.startScope("invoking remote " + method.getName());
-            output.writeObject(new Invocation(method.getName(), args));
-            output.flush();
-            return waitForResult();
-        } catch (Throwable t) {
-            t.printStackTrace();
-            throw t;
-        } finally {
-            Logger.endScope("");
+    public class Handler implements InvocationHandler {
+        private Object receiver;
+
+        public Handler(Object receiver) {
+            this.receiver = receiver;
+        }
+
+        @Override
+        public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+            if (!method.getDeclaringClass().isInterface()) {
+                return method.invoke(receiver, args);
+            }
+            try {
+                Logger.startScope("invoking remote " + method.getName());
+                output.writeObject(new Invocation(receiver, method.getName(), args));
+                output.flush();
+                return waitForResult();
+            } catch (Throwable t) {
+                t.printStackTrace();
+                throw t;
+            } finally {
+                Logger.endScope("");
+            }
         }
     }
 
@@ -97,10 +105,12 @@
 
             Invocation invoke = (Invocation) in;
             Method method = null;
-            for (Method m : delegate.getClass().getDeclaredMethods()) {
-                if (invoke.methodName.equals(m.getName())) {
-                    method = m;
-                    break;
+            for (Class<?> clazz = invoke.receiver.getClass(); clazz != null; clazz = clazz.getSuperclass()) {
+                for (Method m : clazz.getDeclaredMethods()) {
+                    if (invoke.methodName.equals(m.getName())) {
+                        method = m;
+                        break;
+                    }
                 }
             }
             if (method == null) {
@@ -111,11 +121,21 @@
             } else {
                 Object result;
                 try {
-                    Logger.startScope("invoking local " + invoke.methodName);
                     if (invoke.args == null) {
-                        result = method.invoke(delegate);
+                        Logger.startScope("invoking local " + invoke.methodName);
+                        result = method.invoke(invoke.receiver);
                     } else {
-                        result = method.invoke(delegate, invoke.args);
+                        if (Logger.ENABLED) {
+                            StringBuilder str = new StringBuilder();
+                            str.append("invoking local " + invoke.methodName + "(");
+                            for (int i = 0; i < invoke.args.length; i++) {
+                                str.append(i == 0 ? "" : ", ");
+                                str.append(Logger.pretty(invoke.args[i]));
+                            }
+                            str.append(")");
+                            Logger.startScope(str.toString());
+                        }
+                        result = method.invoke(invoke.receiver, invoke.args);
                     }
                     result = new Result(result);
                 } catch (IllegalArgumentException e) {
@@ -139,4 +159,9 @@
         }
     }
 
+    public void sendResult(Object obj) throws IOException {
+        output.writeObject(new Result(obj));
+        output.flush();
+    }
+
 }
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/VMEntriesNative.java	Mon Apr 11 10:22:05 2011 +0200
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/VMEntriesNative.java	Mon Apr 11 11:25:06 2011 +0200
@@ -23,13 +23,14 @@
 
 import com.sun.cri.ci.*;
 import com.sun.cri.ri.*;
+import com.sun.hotspot.c1x.server.*;
 
 /**
  * Entries into the HotSpot VM from Java code.
  *
  * @author Thomas Wuerthinger, Lukas Stadler
  */
-public class VMEntriesNative implements VMEntries {
+public class VMEntriesNative implements VMEntries, Remote {
 
     // Checkstyle: stop
     @Override
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/VMExitsNative.java	Mon Apr 11 10:22:05 2011 +0200
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/VMExitsNative.java	Mon Apr 11 11:25:06 2011 +0200
@@ -30,17 +30,44 @@
 import com.sun.cri.ci.*;
 import com.sun.cri.ri.*;
 import com.sun.hotspot.c1x.logging.*;
+import com.sun.hotspot.c1x.server.*;
 
 /**
  * Exits from the HotSpot VM into Java code.
  *
  * @author Thomas Wuerthinger, Lukas Stadler
  */
-public class VMExitsNative implements VMExits {
+public class VMExitsNative implements VMExits, Remote {
 
     public static final boolean LogCompiledMethods = false;
     public static boolean compileMethods = true;
 
+    private final Compiler compiler;
+
+    public final HotSpotTypePrimitive TypeBoolean;
+    public final HotSpotTypePrimitive TypeChar;
+    public final HotSpotTypePrimitive TypeFloat;
+    public final HotSpotTypePrimitive TypeDouble;
+    public final HotSpotTypePrimitive TypeByte;
+    public final HotSpotTypePrimitive TypeShort;
+    public final HotSpotTypePrimitive TypeInt;
+    public final HotSpotTypePrimitive TypeLong;
+    public final HotSpotTypePrimitive TypeVoid;
+
+    public VMExitsNative(Compiler compiler) {
+        this.compiler = compiler;
+
+        TypeBoolean = new HotSpotTypePrimitive(compiler, CiKind.Boolean);
+        TypeChar = new HotSpotTypePrimitive(compiler, CiKind.Char);
+        TypeFloat = new HotSpotTypePrimitive(compiler, CiKind.Float);
+        TypeDouble = new HotSpotTypePrimitive(compiler, CiKind.Double);
+        TypeByte = new HotSpotTypePrimitive(compiler, CiKind.Byte);
+        TypeShort = new HotSpotTypePrimitive(compiler, CiKind.Short);
+        TypeInt = new HotSpotTypePrimitive(compiler, CiKind.Int);
+        TypeLong = new HotSpotTypePrimitive(compiler, CiKind.Long);
+        TypeVoid = new HotSpotTypePrimitive(compiler, CiKind.Void);
+    }
+
     /**
      * Default option configuration for C1X.
      */
@@ -127,8 +154,7 @@
         }
 
         try {
-            Compiler compiler = Compiler.getInstance();
-            HotSpotMethodResolved riMethod = new HotSpotMethodResolved(methodVmId, name);
+            HotSpotMethodResolved riMethod = new HotSpotMethodResolved(compiler, methodVmId, name);
             CiResult result = compiler.getCompiler().compileMethod(riMethod, -1, null, null);
             if (LogCompiledMethods) {
                 String qualifiedName = CiUtil.toJavaName(riMethod.holder()) + "::" + riMethod.name();
@@ -156,9 +182,9 @@
                 if (cause != null) {
                     s = cause.getMessage();
                 }
-                Compiler.getVMEntries().recordBailout(s);
+                compiler.getVMEntries().recordBailout(s);
             } else {
-                HotSpotTargetMethod.installMethod(riMethod, result.targetMethod());
+                HotSpotTargetMethod.installMethod(compiler, riMethod, result.targetMethod());
             }
         } catch (Throwable t) {
             StringWriter out = new StringWriter();
@@ -170,17 +196,17 @@
 
     @Override
     public RiMethod createRiMethodResolved(long vmId, String name) {
-        return new HotSpotMethodResolved(vmId, name);
+        return new HotSpotMethodResolved(compiler, vmId, name);
     }
 
     @Override
     public RiMethod createRiMethodUnresolved(String name, String signature, RiType holder) {
-        return new HotSpotMethodUnresolved(name, signature, holder);
+        return new HotSpotMethodUnresolved(compiler, name, signature, holder);
     }
 
     @Override
     public RiSignature createRiSignature(String signature) {
-        return new HotSpotSignature(signature);
+        return new HotSpotSignature(compiler, signature);
     }
 
     @Override
@@ -189,7 +215,7 @@
             HotSpotTypeResolved resolved = (HotSpotTypeResolved) holder;
             return resolved.createRiField(name, type, offset);
         }
-        return new HotSpotField(holder, name, type, offset);
+        return new HotSpotField(compiler, holder, name, type, offset);
     }
 
     @Override
@@ -201,23 +227,23 @@
     public RiType createRiTypePrimitive(int basicType) {
         switch (basicType) {
             case 4:
-                return HotSpotTypePrimitive.Boolean;
+                return TypeBoolean;
             case 5:
-                return HotSpotTypePrimitive.Char;
+                return TypeChar;
             case 6:
-                return HotSpotTypePrimitive.Float;
+                return TypeFloat;
             case 7:
-                return HotSpotTypePrimitive.Double;
+                return TypeDouble;
             case 8:
-                return HotSpotTypePrimitive.Byte;
+                return TypeByte;
             case 9:
-                return HotSpotTypePrimitive.Short;
+                return TypeShort;
             case 10:
-                return HotSpotTypePrimitive.Int;
+                return TypeInt;
             case 11:
-                return HotSpotTypePrimitive.Long;
+                return TypeLong;
             case 14:
-                return HotSpotTypePrimitive.Void;
+                return TypeVoid;
             default:
                 throw new IllegalArgumentException("Unknown basic type: " + basicType);
         }
@@ -225,12 +251,12 @@
 
     @Override
     public RiType createRiTypeUnresolved(String name) {
-        return new HotSpotTypeUnresolved(name);
+        return new HotSpotTypeUnresolved(compiler, name);
     }
 
     @Override
     public RiConstantPool createRiConstantPool(long vmId) {
-        return new HotSpotConstantPool(vmId);
+        return new HotSpotConstantPool(compiler, vmId);
     }
 
     @Override
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/logging/CountingProxy.java	Mon Apr 11 10:22:05 2011 +0200
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/logging/CountingProxy.java	Mon Apr 11 11:25:06 2011 +0200
@@ -23,6 +23,8 @@
 import java.lang.reflect.*;
 import java.util.*;
 
+import com.sun.hotspot.c1x.server.*;
+
 /**
  * A java.lang.reflect proxy that hierarchically logs all method invocations along with their parameters and return
  * values.
@@ -66,7 +68,8 @@
     }
 
     public static <T> T getProxy(Class<T> interf, T delegate) {
-        Object obj = Proxy.newProxyInstance(interf.getClassLoader(), new Class[] {interf}, new CountingProxy<T>(delegate));
+        Class<?>[] interfaces = ReplacingStreams.getAllInterfaces(delegate.getClass());
+        Object obj = Proxy.newProxyInstance(interf.getClassLoader(), interfaces, new CountingProxy<T>(delegate));
         return interf.cast(obj);
     }
 
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/logging/LoggingProxy.java	Mon Apr 11 10:22:05 2011 +0200
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/logging/LoggingProxy.java	Mon Apr 11 11:25:06 2011 +0200
@@ -22,6 +22,8 @@
 
 import java.lang.reflect.*;
 
+import com.sun.hotspot.c1x.server.*;
+
 /**
  * A java.lang.reflect proxy that hierarchically logs all method invocations along with their parameters and return values.
  *
@@ -64,8 +66,12 @@
         return result;
     }
 
+    /**
+     * The object returned by this method will implement all interfaces that are implemented by delegate.
+     */
     public static <T> T getProxy(Class<T> interf, T delegate) {
-        Object obj = Proxy.newProxyInstance(interf.getClassLoader(), new Class[] {interf}, new LoggingProxy<T>(delegate));
+        Class<?>[] interfaces = ReplacingStreams.getAllInterfaces(delegate.getClass());
+        Object obj = Proxy.newProxyInstance(interf.getClassLoader(), interfaces, new LoggingProxy<T>(delegate));
         return interf.cast(obj);
     }
 }
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/server/CompilationServer.java	Mon Apr 11 10:22:05 2011 +0200
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/server/CompilationServer.java	Mon Apr 11 11:25:06 2011 +0200
@@ -21,14 +21,10 @@
 package com.sun.hotspot.c1x.server;
 
 import java.io.*;
-import java.lang.reflect.Proxy;
 import java.net.*;
-import java.rmi.registry.*;
 
 import javax.net.*;
 
-import com.sun.cri.ci.*;
-import com.sun.cri.ri.*;
 import com.sun.hotspot.c1x.*;
 import com.sun.hotspot.c1x.Compiler;
 import com.sun.hotspot.c1x.logging.*;
@@ -40,101 +36,33 @@
  */
 public class CompilationServer {
 
-    private Registry registry;
-    private ServerSocket serverSocket;
-    private Socket socket;
-    private ObjectOutputStream output;
-    private ObjectInputStream input;
-
     public static void main(String[] args) throws Exception {
         new CompilationServer().run();
     }
 
-    public static class Container implements Serializable {
-
-        public final Class<?> clazz;
-        public final Object[] values;
-
-        public Container(Class<?> clazz, Object... values) {
-            this.clazz = clazz;
-            this.values = values;
-        }
-    }
-
-    /**
-     * Replaces certain cir objects that cannot easily be made Serializable.
-     */
-    public static class ReplacingOutputStream extends ObjectOutputStream {
-
-        public ReplacingOutputStream(OutputStream out) throws IOException {
-            super(out);
-            enableReplaceObject(true);
-        }
-
-        @Override
-        protected Object replaceObject(Object obj) throws IOException {
-            Class<? extends Object> clazz = obj.getClass();
-            if (clazz == CiConstant.class) {
-                CiConstant o = (CiConstant) obj;
-                return new Container(clazz, o.kind, o.boxedValue());
-            } else if (clazz == CiDebugInfo.class) {
-                CiDebugInfo o = (CiDebugInfo) obj;
-                return new Container(clazz, o.codePos, o.registerRefMap, o.frameRefMap);
-            } else if (clazz == CiCodePos.class) {
-                CiCodePos o = (CiCodePos) obj;
-                return new Container(clazz, o.caller, o.method, o.bci);
-            }
-            return obj;
-        }
-    }
-
-    /**
-     * Replaces certain cir objects that cannot easily be made Serializable.
-     */
-    public static class ReplacingInputStream extends ObjectInputStream {
-
-        public ReplacingInputStream(InputStream in) throws IOException {
-            super(in);
-            enableResolveObject(true);
-        }
-
-        @Override
-        protected Object resolveObject(Object obj) throws IOException {
-            if (obj instanceof Container) {
-                Container c = (Container) obj;
-                if (c.clazz == CiConstant.class) {
-                    return CiConstant.forBoxed((CiKind) c.values[0], c.values[1]);
-                } else if (c.clazz == CiDebugInfo.class) {
-                    return new CiDebugInfo((CiCodePos) c.values[0], (CiBitMap) c.values[2], (CiBitMap) c.values[3]);
-                } else if (c.clazz == CiCodePos.class) {
-                    return new CiCodePos((CiCodePos) c.values[0], (RiMethod) c.values[1], (Integer) c.values[2]);
-                }
-                throw new RuntimeException("unexpected container class");
-            }
-            return obj;
-        }
-    }
-
     private void run() throws IOException, ClassNotFoundException {
-        serverSocket = ServerSocketFactory.getDefault().createServerSocket(1199);
-        while (true) {
+        ServerSocket serverSocket = ServerSocketFactory.getDefault().createServerSocket(1199);
+        do {
+            Socket socket = null;
             try {
                 Logger.log("Compilation server ready, waiting for client to connect...");
                 socket = serverSocket.accept();
                 Logger.log("Connected to " + socket.getRemoteSocketAddress());
-                output = new ReplacingOutputStream(socket.getOutputStream());
-                input = new ReplacingInputStream(socket.getInputStream());
+
+                ReplacingStreams streams = new ReplacingStreams(socket.getOutputStream(), socket.getInputStream());
 
-                InvocationSocket invocation = new InvocationSocket(output, input);
-                VMEntries entries = (VMEntries) Proxy.newProxyInstance(VMEntries.class.getClassLoader(), new Class<?>[] {VMEntries.class}, invocation);
-                VMExits exits = Compiler.initializeServer(entries);
-                invocation.setDelegate(exits);
+                VMEntries entries = (VMEntries) streams.getInvocation().waitForResult();
+                Compiler compiler = CompilerImpl.initializeServer(entries);
 
-                invocation.waitForResult();
+                streams.getInvocation().sendResult(compiler);
+
+                streams.getInvocation().waitForResult();
             } catch (IOException e) {
                 e.printStackTrace();
-                socket.close();
+                if (socket != null) {
+                    socket.close();
+                }
             }
-        }
+        } while (false);
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/server/Remote.java	Mon Apr 11 11:25:06 2011 +0200
@@ -0,0 +1,6 @@
+package com.sun.hotspot.c1x.server;
+
+
+public interface Remote {
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/server/ReplacingStreams.java	Mon Apr 11 11:25:06 2011 +0200
@@ -0,0 +1,211 @@
+/*
+ * Copyright (c) 2011 Sun Microsystems, Inc.  All rights reserved.
+ *
+ * Sun Microsystems, Inc. has intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation, these intellectual property
+ * rights may include one or more of the U.S. patents listed at http://www.sun.com/patents and one or
+ * more additional patents or pending patent applications in the U.S. and in other countries.
+ *
+ * U.S. Government Rights - Commercial software. Government users are subject to the Sun
+ * Microsystems, Inc. standard license agreement and applicable provisions of the FAR and its
+ * supplements.
+ *
+ * Use is subject to license terms. Sun, Sun Microsystems, the Sun logo, Java and Solaris are trademarks or
+ * registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries. All SPARC trademarks
+ * are used under license and are trademarks or registered trademarks of SPARC International, Inc. in the
+ * U.S. and other countries.
+ *
+ * UNIX is a registered trademark in the U.S. and other countries, exclusively licensed through X/Open
+ * Company, Ltd.
+ */
+package com.sun.hotspot.c1x.server;
+
+import java.io.*;
+import java.lang.reflect.*;
+import java.util.*;
+
+import com.sun.cri.ci.*;
+import com.sun.hotspot.c1x.*;
+import com.sun.hotspot.c1x.Compiler;
+
+public class ReplacingStreams {
+
+    private IdentityHashMap<Object, Placeholder> objectMap = new IdentityHashMap<Object, Placeholder>();
+    private ArrayList<Object> objectList = new ArrayList<Object>();
+
+    private ReplacingOutputStream output;
+    private ReplacingInputStream input;
+
+    private InvocationSocket invocation;
+
+    public ReplacingStreams(OutputStream outputStream, InputStream inputStream) throws IOException {
+        output = new ReplacingOutputStream(new BufferedOutputStream(outputStream));
+        // required, because creating an ObjectOutputStream writes a header, but doesn't flush the stream
+        output.flush();
+        input = new ReplacingInputStream(new BufferedInputStream(inputStream));
+        invocation = new InvocationSocket(output, input);
+
+        addStaticObject(CiValue.IllegalValue);
+    }
+
+    public void setInvocationSocket(InvocationSocket invocation) {
+        this.invocation = invocation;
+    }
+
+    public ReplacingOutputStream getOutput() {
+        return output;
+    }
+
+    public ReplacingInputStream getInput() {
+        return input;
+    }
+
+    public InvocationSocket getInvocation() {
+        return invocation;
+    }
+
+    private void addStaticObject(Object obj) {
+        int id = objectList.size();
+        objectList.add(obj);
+        objectMap.put(obj, new Placeholder(id));
+    }
+
+    public static class Placeholder implements Serializable {
+
+        public final int id;
+
+        public Placeholder(int id) {
+            this.id = id;
+        }
+
+        @Override
+        public String toString() {
+            return "#<" + id + ">";
+        }
+    }
+
+    public static class NewRemoteCallPlaceholder implements Serializable {
+
+        public final Class<?>[] interfaces;
+
+        public NewRemoteCallPlaceholder(Class<?>[] interfaces) {
+            this.interfaces = interfaces;
+        }
+    }
+
+    public static class NewDummyPlaceholder implements Serializable {
+    }
+
+    /**
+     * Replaces certain cir objects that cannot easily be made Serializable.
+     */
+    public class ReplacingInputStream extends ObjectInputStream {
+
+        private Compiler compiler;
+
+        public ReplacingInputStream(InputStream in) throws IOException {
+            super(in);
+            enableResolveObject(true);
+        }
+
+        public void setCompiler(Compiler compiler) {
+            this.compiler = compiler;
+        }
+
+        @Override
+        protected Object resolveObject(Object obj) throws IOException {
+            // see ReplacingInputStream.replaceObject for details on when these types of objects are created
+
+            if (obj instanceof Placeholder) {
+                Placeholder placeholder = (Placeholder) obj;
+                obj = objectList.get(placeholder.id);
+                return obj;
+            }
+
+            if (obj instanceof NewRemoteCallPlaceholder) {
+                NewRemoteCallPlaceholder newPlaceholder = (NewRemoteCallPlaceholder) obj;
+                Placeholder placeholder = new Placeholder(objectList.size());
+                obj = Proxy.newProxyInstance(getClass().getClassLoader(), newPlaceholder.interfaces, invocation.new Handler(placeholder));
+                objectMap.put(obj, placeholder);
+                objectList.add(obj);
+                return obj;
+            }
+
+            if (obj instanceof NewDummyPlaceholder) {
+                obj = new Placeholder(objectList.size());
+                objectMap.put(obj, (Placeholder) obj);
+                objectList.add(obj);
+                return obj;
+            }
+
+            return obj;
+        }
+    }
+
+    /**
+     * Replaces certain cir objects that cannot easily be made Serializable.
+     */
+    public class ReplacingOutputStream extends ObjectOutputStream {
+
+        public ReplacingOutputStream(OutputStream out) throws IOException {
+            super(out);
+            enableReplaceObject(true);
+        }
+
+        @Override
+        protected Object replaceObject(Object obj) throws IOException {
+            // is the object a known instance?
+            Placeholder placeholder = objectMap.get(obj);
+            if (placeholder != null) {
+                return placeholder;
+            }
+
+            // is the object an instance of a class that will always be executed remotely?
+            if (obj instanceof Remote) {
+                return createRemoteCallPlaceholder(obj);
+            }
+
+            // is the object a constant of object type?
+            if (obj.getClass() == CiConstant.class) {
+                System.out.println("CiConstant " + obj);
+                CiConstant constant = (CiConstant) obj;
+                // don't replace if the object already is a placeholder
+                if (constant.kind == CiKind.Object && !(constant.asObject() instanceof Placeholder) && constant.asObject() != null) {
+                    return CiConstant.forObject(createDummyPlaceholder(constant.asObject()));
+                }
+            }
+            return obj;
+        }
+    }
+
+    public static Class<?>[] getAllInterfaces(Class<?> clazz) {
+        HashSet<Class< ? >> interfaces = new HashSet<Class<?>>();
+        getAllInterfaces(clazz, interfaces);
+        return interfaces.toArray(new Class<?>[interfaces.size()]);
+    }
+
+    private static void getAllInterfaces(Class<?> clazz, HashSet<Class<?>> interfaces) {
+        for (Class< ? > iface : clazz.getInterfaces()) {
+            if (!interfaces.contains(iface)) {
+                interfaces.add(iface);
+                getAllInterfaces(iface, interfaces);
+            }
+        }
+        if (clazz.getSuperclass() != null) {
+            getAllInterfaces(clazz.getSuperclass(), interfaces);
+        }
+    }
+
+    private Object createRemoteCallPlaceholder(Object obj) {
+        // collect all interfaces that this object's class implements (proxies only support interfaces)
+        objectMap.put(obj, new Placeholder(objectList.size()));
+        objectList.add(obj);
+        return new NewRemoteCallPlaceholder(getAllInterfaces(obj.getClass()));
+    }
+
+    public Object createDummyPlaceholder(Object obj) {
+        objectMap.put(obj, new Placeholder(objectList.size()));
+        objectList.add(obj);
+        return new NewDummyPlaceholder();
+    }
+}
--- a/c1x4hotspotsrc/hotspot/.cproject	Mon Apr 11 10:22:05 2011 +0200
+++ b/c1x4hotspotsrc/hotspot/.cproject	Mon Apr 11 11:25:06 2011 +0200
@@ -20,14 +20,14 @@
 					<folderInfo id="cdt.managedbuild.toolchain.gnu.solaris.base.945602881.305678577" name="/" resourcePath="">
 						<toolChain id="cdt.managedbuild.toolchain.gnu.base.1866612258" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.base">
 							<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="cdt.managedbuild.target.gnu.platform.base.2075405295" name="Debug Platform" osList="linux,hpux,aix,qnx" superClass="cdt.managedbuild.target.gnu.platform.base"/>
-							<builder arguments="${workspace_loc:/hotspot}/../../domake" autoBuildTarget="jvmg1" buildPath="${workspace_loc:/hotspot}/../../make" cleanBuildTarget="clean" command="bash" enableAutoBuild="true" enableCleanBuild="false" enabledIncrementalBuild="true" id="cdt.managedbuild.target.gnu.builder.base.81453037" incrementalBuildTarget="jvmg1" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" parallelizationNumber="1" superClass="cdt.managedbuild.target.gnu.builder.base">
+							<builder arguments="${workspace_loc:/hotspot}/../../domake" autoBuildTarget="jvmg1" buildPath="${workspace_loc:/hotspot}/../../make" cleanBuildTarget="clean" command="bash" enableAutoBuild="true" enableCleanBuild="false" enabledIncrementalBuild="false" id="cdt.managedbuild.target.gnu.builder.base.81453037" incrementalBuildTarget="jvmg1" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" parallelizationNumber="1" superClass="cdt.managedbuild.target.gnu.builder.base">
 								<outputEntries>
 									<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="outputPath" name=""/>
 								</outputEntries>
 							</builder>
 							<tool id="cdt.managedbuild.tool.gnu.archiver.base.1094883386" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/>
 							<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.base.1342888057" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.base">
-								<option id="gnu.cpp.compiler.option.include.paths.801956928" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath"/>
+								<option id="gnu.cpp.compiler.option.include.paths.801956928" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths"/>
 								<option id="gnu.cpp.compiler.option.preprocessor.def.634868600" name="Defined symbols (-D)" superClass="gnu.cpp.compiler.option.preprocessor.def" valueType="definedSymbols">
 									<listOptionValue builtIn="false" value="_LP64=1"/>
 									<listOptionValue builtIn="false" value="COMPILER1=1"/>
--- a/c1x4hotspotsrc/hotspot/.project	Mon Apr 11 10:22:05 2011 +0200
+++ b/c1x4hotspotsrc/hotspot/.project	Mon Apr 11 11:25:06 2011 +0200
@@ -7,7 +7,7 @@
 	<buildSpec>
 		<buildCommand>
 			<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
-			<triggers>auto,full,incremental,</triggers>
+			<triggers>auto,</triggers>
 			<arguments>
 				<dictionary>
 					<key>?children?</key>
@@ -55,7 +55,7 @@
 				</dictionary>
 				<dictionary>
 					<key>org.eclipse.cdt.make.core.enableFullBuild</key>
-					<value>true</value>
+					<value>false</value>
 				</dictionary>
 				<dictionary>
 					<key>org.eclipse.cdt.make.core.fullBuildTarget</key>
@@ -106,11 +106,6 @@
 			<locationURI>PARENT-2-PROJECT_LOC/src/os_cpu/linux_x86</locationURI>
 		</link>
 		<link>
-			<name>src</name>
-			<type>2</type>
-			<locationURI>PARENT-2-PROJECT_LOC/src</locationURI>
-		</link>
-		<link>
 			<name>vm</name>
 			<type>2</type>
 			<locationURI>PARENT-2-PROJECT_LOC/src/share/vm</locationURI>
--- a/domake	Mon Apr 11 10:22:05 2011 +0200
+++ b/domake	Mon Apr 11 11:25:06 2011 +0200
@@ -48,8 +48,9 @@
 
 pushd $graal_home/make
 
-ARCH_DATA_MODEL=64 LANG=C HOTSPOT_BUILD_JOBS=4 ALT_BOOTDIR=$JDK7G INSTALL=$JDK7G/jre make jvmg1
-ARCH_DATA_MODEL=64 LANG=C HOTSPOT_BUILD_JOBS=4 ALT_BOOTDIR=$JDK7 INSTALL=$JDK7/jre make product1
+# the piping magic runs stderr through grep and removes the complaints about Xusage.txt files
+ARCH_DATA_MODEL=64 LANG=C HOTSPOT_BUILD_JOBS=4 ALT_BOOTDIR=$JDK7G INSTALL=y make jvmg1 3>&1 1>&2 2>&3 | grep -v Xusage[.]txt
+ARCH_DATA_MODEL=64 LANG=C HOTSPOT_BUILD_JOBS=4 ALT_BOOTDIR=$JDK7 INSTALL=y make product1 3>&1 1>&2 2>&3 | grep -v Xusage[.]txt
 
 popd
 
--- a/src/share/vm/c1x/c1x_Compiler.cpp	Mon Apr 11 10:22:05 2011 +0200
+++ b/src/share/vm/c1x/c1x_Compiler.cpp	Mon Apr 11 11:25:06 2011 +0200
@@ -146,6 +146,7 @@
   Handle obj = instanceKlass::cast(HotSpotTypeResolved::klass())->allocate_instance(CHECK_NULL);
   assert(obj() != NULL, "must succeed in allocating instance");
 
+  HotSpotTypeResolved::set_compiler(obj, VMExits::compilerInstance()());
 
   if (klass->oop_is_instance()) {
     instanceKlass* ik = (instanceKlass*)klass()->klass_part();
--- a/src/share/vm/c1x/c1x_JavaAccess.hpp	Mon Apr 11 10:22:05 2011 +0200
+++ b/src/share/vm/c1x/c1x_JavaAccess.hpp	Mon Apr 11 11:25:06 2011 +0200
@@ -44,6 +44,7 @@
 
 #define COMPILER_CLASSES_DO(start_class, end_class, char_field, int_field, boolean_field, long_field, oop_field, static_oop_field)   \
   start_class(HotSpotTypeResolved)                                                      \
+    oop_field(HotSpotTypeResolved, compiler, "Lcom/sun/hotspot/c1x/Compiler;")          \
     oop_field(HotSpotTypeResolved, javaMirror, "Ljava/lang/Class;")                     \
     oop_field(HotSpotTypeResolved, simpleName, "Ljava/lang/String;")                    \
     int_field(HotSpotTypeResolved, accessFlags)                                         \
--- a/src/share/vm/c1x/c1x_VMExits.cpp	Mon Apr 11 10:22:05 2011 +0200
+++ b/src/share/vm/c1x/c1x_VMExits.cpp	Mon Apr 11 11:25:06 2011 +0200
@@ -26,32 +26,43 @@
 #include "c1x/c1x_VMExits.hpp"
 
 // this is a *global* handle
+jobject VMExits::_compilerPermObject;
 jobject VMExits::_vmExitsPermObject;
 jobject VMExits::_vmExitsPermKlass;
 
 KlassHandle VMExits::vmExitsKlass() {
   if (JNIHandles::resolve(_vmExitsPermKlass) == NULL) {
     klassOop result = SystemDictionary::resolve_or_null(vmSymbols::com_sun_hotspot_c1x_VMExits(), SystemDictionary::java_system_loader(), NULL, Thread::current());
-    if (result == NULL) {
-      fatal("Could not find class com.sun.hotspot.c1x.VMExits");
-    }
+    check_not_null(result, "Couldn't find class com.sun.hotspot.c1x.VMExits");
     _vmExitsPermKlass = JNIHandles::make_global(result);
   }
   return KlassHandle((klassOop)JNIHandles::resolve_non_null(_vmExitsPermKlass));
 }
 
+Handle VMExits::compilerInstance() {
+  if (JNIHandles::resolve(_compilerPermObject) == NULL) {
+    KlassHandle compilerImplKlass = SystemDictionary::resolve_or_null(vmSymbols::com_sun_hotspot_c1x_CompilerImpl(), SystemDictionary::java_system_loader(), NULL, Thread::current());
+    check_not_null(compilerImplKlass(), "Couldn't find class com.sun.hotspot.c1x.CompilerImpl");
+
+    JavaValue result(T_OBJECT);
+    JavaCalls::call_static(&result, compilerImplKlass, vmSymbols::getInstance_name(), vmSymbols::getInstance_signature(), Thread::current());
+    check_pending_exception("Couldn't get Compiler");
+    _compilerPermObject = JNIHandles::make_global((oop) result.get_jobject());
+  }
+  return Handle(JNIHandles::resolve_non_null(_compilerPermObject));
+}
+
 Handle VMExits::instance() {
   if (JNIHandles::resolve(_vmExitsPermObject) == NULL) {
-    KlassHandle compiler_klass = SystemDictionary::resolve_or_null(vmSymbols::com_sun_hotspot_c1x_Compiler(), SystemDictionary::java_system_loader(), NULL, Thread::current());
-    if (compiler_klass.is_null()) {
-      fatal("Could not find class com.sun.hotspot.c1x.Compiler");
-    }
+    KlassHandle compilerKlass = SystemDictionary::resolve_or_null(vmSymbols::com_sun_hotspot_c1x_Compiler(), SystemDictionary::java_system_loader(), NULL, Thread::current());
+    check_not_null(compilerKlass(), "Couldn't find class com.sun.hotspot.c1x.Compiler");
+
     JavaValue result(T_OBJECT);
     JavaCallArguments args;
-    JavaCalls::call_static(&result, compiler_klass(), vmSymbols::getVMExits_name(), vmSymbols::getVMExits_signature(), &args, Thread::current());
+    args.set_receiver(compilerInstance());
+    JavaCalls::call_interface(&result, compilerKlass, vmSymbols::getVMExits_name(), vmSymbols::getVMExits_signature(), &args, Thread::current());
     check_pending_exception("Couldn't get VMExits");
-    oop res = (oop) result.get_jobject();
-    _vmExitsPermObject = JNIHandles::make_global(res);
+    _vmExitsPermObject = JNIHandles::make_global((oop) result.get_jobject());
   }
   return Handle(JNIHandles::resolve_non_null(_vmExitsPermObject));
 }
@@ -212,9 +223,16 @@
 oop VMExits::createCiConstantObject(Handle object, TRAPS) {
   JavaValue result(T_OBJECT);
   JavaCallArguments args;
+  /*
   args.push_oop(instance());
   args.push_oop(object);
   JavaCalls::call_interface(&result, vmExitsKlass(), vmSymbols::createCiConstantObject_name(), vmSymbols::createCiConstantObject_signature(), &args, THREAD);
   check_pending_exception("Error while calling createCiConstantObject");
+  */
+
+
+  KlassHandle klass = SystemDictionary::resolve_or_null(vmSymbols::com_sun_cri_ci_CiConstant(), SystemDictionary::java_system_loader(), NULL, Thread::current());
+  JavaCalls::call_static(&result, klass(), vmSymbols::forObject_name(), vmSymbols::createCiConstantObject_signature(), object, THREAD);
+  check_pending_exception("Error while calling CiConstant.forObject");
   return (oop) result.get_jobject();
 }
--- a/src/share/vm/c1x/c1x_VMExits.hpp	Mon Apr 11 10:22:05 2011 +0200
+++ b/src/share/vm/c1x/c1x_VMExits.hpp	Mon Apr 11 11:25:06 2011 +0200
@@ -25,6 +25,7 @@
 class VMExits : public AllStatic {
 
 private:
+  static jobject _compilerPermObject;
   static jobject _vmExitsPermObject;
   static jobject _vmExitsPermKlass;
 
@@ -32,6 +33,7 @@
   static Handle instance();
 
 public:
+  static Handle compilerInstance();
 
   // public abstract boolean setOption(String option);
   static jboolean setOption(Handle option);
@@ -76,13 +78,22 @@
   static oop createCiConstantObject(Handle object, TRAPS);
 };
 
-inline void check_pending_exception(const char* message) {
+inline void check_pending_exception(const char* message, bool dump_core = false) {
   Thread* THREAD = Thread::current();
   if (THREAD->has_pending_exception()) {
     Handle exception = PENDING_EXCEPTION;
     CLEAR_PENDING_EXCEPTION;
+    tty->print_cr("%s", message);
     java_lang_Throwable::print(exception, tty);
+    tty->cr();
     java_lang_Throwable::print_stack_trace(exception(), tty);
-    fatal(message);
+    vm_abort(dump_core);
   }
 }
+
+inline void check_not_null(void* value, const char* message, bool dump_core = false) {
+  if (value == NULL) {
+    tty->print_cr("%s", message);
+    vm_abort(dump_core);
+  }
+}
--- a/src/share/vm/classfile/vmSymbols.hpp	Mon Apr 11 10:22:05 2011 +0200
+++ b/src/share/vm/classfile/vmSymbols.hpp	Mon Apr 11 11:25:06 2011 +0200
@@ -265,11 +265,12 @@
   template(com_sun_hotspot_c1x_HotSpotTargetMethod,   "com/sun/hotspot/c1x/HotSpotTargetMethod")                        \
   template(com_sun_hotspot_c1x_HotSpotField,          "com/sun/hotspot/c1x/HotSpotField")                               \
   template(com_sun_c1x_C1XOptions,                    "com/sun/c1x/C1XOptions")                                         \
-  template(com_sun_hotspot_c1x_HotSpotTypeResolved,   "com/sun/hotspot/c1x/HotSpotTypeResolved")                        \
+  template(com_sun_hotspot_c1x_HotSpotTypeResolved,   "com/sun/hotspot/c1x/HotSpotTypeResolvedImpl")                    \
   template(com_sun_hotspot_c1x_HotSpotType,           "com/sun/hotspot/c1x/HotSpotType")                                \
   template(com_sun_hotspot_c1x_HotSpotExceptionHandler,"com/sun/hotspot/c1x/HotSpotExceptionHandler")                   \
   template(com_sun_hotspot_c1x_HotSpotProxy,          "com/sun/hotspot/c1x/HotSpotProxy")                               \
   template(com_sun_hotspot_c1x_Compiler,              "com/sun/hotspot/c1x/Compiler")                                   \
+  template(com_sun_hotspot_c1x_CompilerImpl,          "com/sun/hotspot/c1x/CompilerImpl")                               \
   template(com_sun_cri_ri_RiMethod,                   "com/sun/cri/ri/RiMethod")                                        \
   template(com_sun_cri_ri_RiField,                    "com/sun/cri/ri/RiField")                                         \
   template(com_sun_cri_ri_RiType,                     "com/sun/cri/ri/RiType")                                          \
@@ -313,7 +314,7 @@
   template(createRiTypePrimitive_name,                "createRiTypePrimitive")                                          \
   template(createRiTypePrimitive_signature,           "(I)Lcom/sun/cri/ri/RiType;")                                     \
   template(createRiTypeUnresolved_name,               "createRiTypeUnresolved")                                         \
-  template(createRiTypeUnresolved_signature,          "(Ljava/lang/String;)Lcom/sun/cri/ri/RiType;")                   \
+  template(createRiTypeUnresolved_signature,          "(Ljava/lang/String;)Lcom/sun/cri/ri/RiType;")                    \
   template(createRiConstantPool_name,                 "createRiConstantPool")                                           \
   template(createRiConstantPool_signature,            "(J)Lcom/sun/cri/ri/RiConstantPool;")                             \
   template(createCiConstant_name,                     "createCiConstant")                                               \
@@ -326,6 +327,9 @@
   template(createCiConstantObject_signature,          "(Ljava/lang/Object;)Lcom/sun/cri/ci/CiConstant;")                \
   template(getVMExits_name,                           "getVMExits")                                                     \
   template(getVMExits_signature,                      "()Lcom/sun/hotspot/c1x/VMExits;")                                \
+  template(getInstance_name,                          "getInstance")                                                    \
+  template(getInstance_signature,                     "()Lcom/sun/hotspot/c1x/Compiler;")                               \
+  template(forObject_name,                            "forObject")                                                      \
                                                                                                                         \
   /* common method and field names */                                                             \
   template(object_initializer_name,                   "<init>")                                   \