# HG changeset patch # User Lukas Stadler # Date 1302183145 -7200 # Node ID 569d3fe7d65c8d4383db1b0a3b3a33ed501a82ea # Parent 0309d394eb5fe39f9b8a42aecda342cba7fad7fb non-static VMEntries and VMExits, CompilationServer simplifications diff -r 0309d394eb5f -r 569d3fe7d65c c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/Compiler.java --- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/Compiler.java Mon Apr 04 21:02:45 2011 +0200 +++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/Compiler.java Thu Apr 07 15:32:25 2011 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010 Sun Microsystems, Inc. All rights reserved. + * 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 @@ -20,14 +20,13 @@ */ package com.sun.hotspot.c1x; +import java.io.*; 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; @@ -43,18 +42,19 @@ private static Compiler theInstance; private static boolean PrintGCStats = false; + private final VMEntries vmEntries; + private final VMExits vmExits; + public static Compiler getInstance() { if (theInstance == null) { - theInstance = new Compiler(); + theInstance = new Compiler(null); Runtime.getRuntime().addShutdownHook(new ShutdownThread()); } return theInstance; } - private static VMEntries vmEntries; + public static class ShutdownThread extends Thread { - - public static class ShutdownThread extends Thread { @Override public void run() { VMExitsNative.compileMethods = false; @@ -64,7 +64,6 @@ if (C1XOptions.PrintTimers) { C1XTimers.print(); } - if (PrintGCStats) { printGCStats(); } @@ -91,127 +90,95 @@ 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; + public static Compiler initializeServer(VMEntries entries) { + assert theInstance == null; + theInstance = new Compiler(entries); + return theInstance; } - private static VMEntries initializeClient(VMExits exits) { - vmEntries = new VMEntriesNative(); - vmExits = exits; + public VMEntries getVMEntries() { 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(); - } - } + public VMExits getVMExits() { 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(); + private Compiler(VMEntries entries) { + // 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); + + ReplacingOutputStream output = new ReplacingOutputStream(new BufferedOutputStream(socket.getOutputStream())); + // required, because creating an ObjectOutputStream writes a header, but doesn't flush the stream + output.flush(); + ReplacingInputStream input = new ReplacingInputStream(new BufferedInputStream(socket.getInputStream())); + input.setCompiler(this); - 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); + InvocationSocket invocation = new InvocationSocket(output, input); + vmEntries = new VMEntriesNative(); + vmExits = (VMExits) Proxy.newProxyInstance(VMExits.class.getClassLoader(), new Class[] { VMExits.class}, invocation); + invocation.setDelegate(vmEntries); + compiler = null; + return; + } catch (IOException t) { + System.out.println("Connection to compilation server FAILED."); + throw new RuntimeException(t); + } + } + + // 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) { - generator = LoggingProxy.getProxy(RiXirGenerator.class, new HotSpotXirGenerator(config, target, registerConfig)); - } else { - generator = new HotSpotXirGenerator(config, target, registerConfig); + exits = LoggingProxy.getProxy(VMExits.class, exits); + entries = LoggingProxy.getProxy(VMEntries.class, entries); } - compiler = new C1XCompiler(runtime, target, generator, registerConfig); + + // 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); } 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; - } - } diff -r 0309d394eb5f -r 569d3fe7d65c c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/CompilerObject.java --- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/CompilerObject.java Mon Apr 04 21:02:45 2011 +0200 +++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/CompilerObject.java Thu Apr 07 15:32:25 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; + } + } diff -r 0309d394eb5f -r 569d3fe7d65c c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotConstantPool.java --- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotConstantPool.java Mon Apr 04 21:02:45 2011 +0200 +++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotConstantPool.java Thu Apr 07 15:32:25 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 fieldCache = new FastLRUIntCache(); private final FastLRUIntCache typeCache = new FastLRUIntCache(); - public static class FastLRUIntCache { + public static class FastLRUIntCache 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; diff -r 0309d394eb5f -r 569d3fe7d65c c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotExceptionHandler.java --- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotExceptionHandler.java Mon Apr 04 21:02:45 2011 +0200 +++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotExceptionHandler.java Thu Apr 07 15:32:25 2011 +0200 @@ -30,6 +30,10 @@ private int catchClassIndex; private RiType catchClass; + public HotSpotExceptionHandler() { + super(null); + } + @Override public int startBCI() { return startBci; diff -r 0309d394eb5f -r 569d3fe7d65c c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotField.java --- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotField.java Mon Apr 04 21:02:45 2011 +0200 +++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotField.java Thu Apr 07 15:32:25 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; diff -r 0309d394eb5f -r 569d3fe7d65c c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotMethod.java --- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotMethod.java Mon Apr 04 21:02:45 2011 +0200 +++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotMethod.java Thu Apr 07 15:32:25 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; diff -r 0309d394eb5f -r 569d3fe7d65c c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotMethodResolved.java --- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotMethodResolved.java Mon Apr 04 21:02:45 2011 +0200 +++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotMethodResolved.java Thu Apr 07 15:32:25 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; } diff -r 0309d394eb5f -r 569d3fe7d65c c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotMethodUnresolved.java --- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotMethodUnresolved.java Mon Apr 04 21:02:45 2011 +0200 +++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotMethodUnresolved.java Thu Apr 07 15:32:25 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 diff -r 0309d394eb5f -r 569d3fe7d65c c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotRuntime.java --- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotRuntime.java Mon Apr 04 21:02:45 2011 +0200 +++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotRuntime.java Thu Apr 07 15:32:25 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 @@ -166,7 +168,7 @@ @Override public Object registerGlobalStub(CiTargetMethod targetMethod, String name) { - return HotSpotTargetMethod.installStub(targetMethod, name); + return HotSpotTargetMethod.installStub(compiler, targetMethod, name); } @Override diff -r 0309d394eb5f -r 569d3fe7d65c c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotSignature.java --- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotSignature.java Mon Apr 04 21:02:45 2011 +0200 +++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotSignature.java Thu Apr 07 15:32:25 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; } diff -r 0309d394eb5f -r 569d3fe7d65c c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotTargetMethod.java --- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotTargetMethod.java Mon Apr 04 21:02:45 2011 +0200 +++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotTargetMethod.java Thu Apr 07 15:32:25 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)); } } diff -r 0309d394eb5f -r 569d3fe7d65c c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotType.java --- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotType.java Mon Apr 04 21:02:45 2011 +0200 +++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotType.java Thu Apr 07 15:32:25 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; diff -r 0309d394eb5f -r 569d3fe7d65c c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotTypePrimitive.java --- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotTypePrimitive.java Mon Apr 04 21:02:45 2011 +0200 +++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotTypePrimitive.java Thu Apr 07 15:32:25 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 diff -r 0309d394eb5f -r 569d3fe7d65c c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotTypeResolved.java --- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotTypeResolved.java Mon Apr 04 21:02:45 2011 +0200 +++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotTypeResolved.java Thu Apr 07 15:32:25 2011 +0200 @@ -48,6 +48,10 @@ private HashMap fieldCache; private RiConstantPool pool; + private HotSpotTypeResolved() { + super(null); + } + @Override public int accessFlags() { return accessFlags; @@ -55,17 +59,17 @@ @Override public RiType arrayOf() { - return Compiler.getVMEntries().RiType_arrayOf(this); + return compiler.getVMEntries().RiType_arrayOf(this); } @Override public RiType componentType() { - return Compiler.getVMEntries().RiType_componentType(this); + return compiler.getVMEntries().RiType_componentType(this); } @Override public RiType uniqueConcreteSubtype() { - return Compiler.getVMEntries().RiType_uniqueConcreteSubtype(this); + return compiler.getVMEntries().RiType_uniqueConcreteSubtype(this); } @Override @@ -145,7 +149,7 @@ @Override public boolean isSubtypeOf(RiType other) { if (other instanceof HotSpotTypeResolved) { - return Compiler.getVMEntries().RiType_isSubtypeOf(this, other); + return compiler.getVMEntries().RiType_isSubtypeOf(this, other); } // No resolved type is a subtype of an unresolved type. return false; @@ -164,7 +168,7 @@ @Override public RiMethod resolveMethodImpl(RiMethod method) { assert method instanceof HotSpotMethod; - return Compiler.getVMEntries().RiType_resolveMethodImpl(this, method.name(), method.signature().asString()); + return compiler.getVMEntries().RiType_resolveMethodImpl(this, method.name(), method.signature().asString()); } @Override @@ -174,7 +178,7 @@ public RiConstantPool constantPool() { // TODO: Implement constant pool without the need for VmId and cache the constant pool. - return Compiler.getVMEntries().RiType_constantPool(this); + return compiler.getVMEntries().RiType_constantPool(this); } public int instanceSize() { @@ -192,7 +196,7 @@ } if (result == null) { - result = new HotSpotField(this, name, type, offset); + result = new HotSpotField(compiler, this, name, type, offset); fieldCache.put(offset, result); } diff -r 0309d394eb5f -r 569d3fe7d65c c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotTypeUnresolved.java --- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotTypeUnresolved.java Mon Apr 04 21:02:45 2011 +0200 +++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotTypeUnresolved.java Thu Apr 07 15:32:25 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 diff -r 0309d394eb5f -r 569d3fe7d65c c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotVMConfig.java --- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotVMConfig.java Mon Apr 04 21:02:45 2011 +0200 +++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotVMConfig.java Thu Apr 07 15:32:25 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; diff -r 0309d394eb5f -r 569d3fe7d65c c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotXirGenerator.java --- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotXirGenerator.java Mon Apr 04 21:02:45 2011 +0200 +++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotXirGenerator.java Thu Apr 07 15:32:25 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) { @@ -1240,7 +1242,7 @@ 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)); } diff -r 0309d394eb5f -r 569d3fe7d65c c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/InvocationSocket.java --- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/InvocationSocket.java Mon Apr 04 21:02:45 2011 +0200 +++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/InvocationSocket.java Thu Apr 07 15:32:25 2011 +0200 @@ -39,6 +39,7 @@ private final ObjectOutputStream output; private final ObjectInputStream input; private Object delegate; + private DelegateCallback callback; public InvocationSocket(ObjectOutputStream output, ObjectInputStream input) { this.output = output; @@ -49,6 +50,14 @@ this.delegate = delegate; } + public static interface DelegateCallback { + public Object getDelegate(); + } + + public void setDelegateCallback(DelegateCallback callback) { + this.callback = callback; + } + private static class Invocation implements Serializable { public String methodName; @@ -95,6 +104,11 @@ throw new RuntimeException((Throwable) in); } + if (delegate == null) { + delegate = callback.getDelegate(); + callback = null; + } + Invocation invoke = (Invocation) in; Method method = null; for (Method m : delegate.getClass().getDeclaredMethods()) { diff -r 0309d394eb5f -r 569d3fe7d65c c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/VMExitsNative.java --- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/VMExitsNative.java Mon Apr 04 21:02:45 2011 +0200 +++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/VMExitsNative.java Thu Apr 07 15:32:25 2011 +0200 @@ -41,6 +41,32 @@ 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 +153,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 +181,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 +195,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 +214,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 +226,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 +250,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 diff -r 0309d394eb5f -r 569d3fe7d65c c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/server/CompilationServer.java --- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/server/CompilationServer.java Mon Apr 04 21:02:45 2011 +0200 +++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/server/CompilationServer.java Thu Apr 07 15:32:25 2011 +0200 @@ -28,9 +28,9 @@ 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.InvocationSocket.DelegateCallback; import com.sun.hotspot.c1x.logging.*; /** @@ -43,8 +43,10 @@ private Registry registry; private ServerSocket serverSocket; private Socket socket; - private ObjectOutputStream output; - private ObjectInputStream input; + + private ReplacingOutputStream output; + private ReplacingInputStream input; + public static void main(String[] args) throws Exception { new CompilationServer().run(); @@ -77,12 +79,10 @@ 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); + } else if (obj == CiValue.IllegalValue) { + return new Container(CiValue.class); + } else if (obj instanceof Compiler) { + return new Container(Compiler.class); } return obj; } @@ -92,24 +92,30 @@ * Replaces certain cir objects that cannot easily be made Serializable. */ public static 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 { 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]); + } else if (c.clazz == CiValue.class) { + return CiValue.IllegalValue; + } else if (c.clazz == Compiler.class) { + assert compiler != null; + return compiler; } - throw new RuntimeException("unexpected container class"); + throw new RuntimeException("unexpected container class: " + c.clazz); } return obj; } @@ -117,24 +123,32 @@ private void run() throws IOException, ClassNotFoundException { serverSocket = ServerSocketFactory.getDefault().createServerSocket(1199); - while (true) { + do { 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()); + + output = new ReplacingOutputStream(new BufferedOutputStream(socket.getOutputStream())); + // required, because creating an ObjectOutputStream writes a header, but doesn't flush the stream + output.flush(); + input = new ReplacingInputStream(new BufferedInputStream(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); + final InvocationSocket invocation = new InvocationSocket(output, input); + invocation.setDelegateCallback( new DelegateCallback() { + public Object getDelegate() { + VMEntries entries = (VMEntries) Proxy.newProxyInstance(VMEntries.class.getClassLoader(), new Class[] {VMEntries.class}, invocation); + Compiler compiler = Compiler.initializeServer(entries); + input.setCompiler(compiler); + return compiler.getVMExits(); + } + }); invocation.waitForResult(); } catch (IOException e) { e.printStackTrace(); socket.close(); } - } + } while (false); } } diff -r 0309d394eb5f -r 569d3fe7d65c src/share/vm/c1x/c1x_Compiler.cpp --- a/src/share/vm/c1x/c1x_Compiler.cpp Mon Apr 04 21:02:45 2011 +0200 +++ b/src/share/vm/c1x/c1x_Compiler.cpp Thu Apr 07 15:32:25 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(); diff -r 0309d394eb5f -r 569d3fe7d65c src/share/vm/c1x/c1x_JavaAccess.hpp --- a/src/share/vm/c1x/c1x_JavaAccess.hpp Mon Apr 04 21:02:45 2011 +0200 +++ b/src/share/vm/c1x/c1x_JavaAccess.hpp Thu Apr 07 15:32:25 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) \ diff -r 0309d394eb5f -r 569d3fe7d65c src/share/vm/c1x/c1x_VMExits.cpp --- a/src/share/vm/c1x/c1x_VMExits.cpp Mon Apr 04 21:02:45 2011 +0200 +++ b/src/share/vm/c1x/c1x_VMExits.cpp Thu Apr 07 15:32:25 2011 +0200 @@ -26,32 +26,49 @@ #include "c1x/c1x_VMExits.hpp" // this is a *global* handle +jobject VMExits::_compilerPermObject; +jobject VMExits::_compilerPermKlass; jobject VMExits::_vmExitsPermObject; jobject VMExits::_vmExitsPermKlass; +KlassHandle VMExits::compilerKlass() { + if (JNIHandles::resolve(_compilerPermKlass) == NULL) { + klassOop result = SystemDictionary::resolve_or_null(vmSymbols::com_sun_hotspot_c1x_Compiler(), SystemDictionary::java_system_loader(), NULL, Thread::current()); + if (result == NULL) { + fatal("Couldn't find class com.sun.hotspot.c1x.Compiler"); + } + _compilerPermKlass = JNIHandles::make_global(result); + } + return KlassHandle((klassOop)JNIHandles::resolve_non_null(_compilerPermKlass)); +} + 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"); + fatal("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) { + JavaValue result(T_OBJECT); + JavaCalls::call_static(&result, compilerKlass(), 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"); - } JavaValue result(T_OBJECT); - JavaCallArguments args; - JavaCalls::call_static(&result, compiler_klass(), vmSymbols::getVMExits_name(), vmSymbols::getVMExits_signature(), &args, Thread::current()); + JavaCalls::call_virtual(&result, compilerInstance(), compilerKlass(), vmSymbols::getVMExits_name(), vmSymbols::getVMExits_signature(), 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)); } diff -r 0309d394eb5f -r 569d3fe7d65c src/share/vm/c1x/c1x_VMExits.hpp --- a/src/share/vm/c1x/c1x_VMExits.hpp Mon Apr 04 21:02:45 2011 +0200 +++ b/src/share/vm/c1x/c1x_VMExits.hpp Thu Apr 07 15:32:25 2011 +0200 @@ -26,12 +26,16 @@ private: static jobject _vmExitsPermObject; + static jobject _compilerPermKlass; + static jobject _compilerPermObject; static jobject _vmExitsPermKlass; + static KlassHandle compilerKlass(); static KlassHandle vmExitsKlass(); static Handle instance(); public: + static Handle compilerInstance(); // public abstract boolean setOption(String option); static jboolean setOption(Handle option); @@ -76,13 +80,14 @@ 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; java_lang_Throwable::print(exception, tty); + tty->cr(); java_lang_Throwable::print_stack_trace(exception(), tty); - fatal(message); + vm_abort(dump_core); } } diff -r 0309d394eb5f -r 569d3fe7d65c src/share/vm/classfile/vmSymbols.hpp --- a/src/share/vm/classfile/vmSymbols.hpp Mon Apr 04 21:02:45 2011 +0200 +++ b/src/share/vm/classfile/vmSymbols.hpp Thu Apr 07 15:32:25 2011 +0200 @@ -313,7 +313,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 +326,8 @@ 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;") \ \ /* common method and field names */ \ template(object_initializer_name, "") \