changeset 1419:7bf6a77b9c5a

implement recent safepoint & exceptionobject ci changes, HotSpotVMConfig
author Lukas Stadler <lukas.stadler@oracle.com>
date Mon, 12 Jul 2010 15:05:17 -0700
parents 55ac38887415
children 44efca8a02d6
files c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/Compiler.java c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotRegisterConfig.java c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotRuntime.java c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotVMConfig.java c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotXirGenerator.java c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/VMEntries.java src/share/vm/c1x/c1x_VMEntries.cpp src/share/vm/c1x/c1x_VMEntries.hpp
diffstat 8 files changed, 90 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/Compiler.java	Fri Jul 09 16:33:03 2010 -0700
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/Compiler.java	Mon Jul 12 15:05:17 2010 -0700
@@ -51,13 +51,14 @@
 	
 	private static CiCompiler createCompiler() {
 
-		final HotSpotRuntime runtime = new HotSpotRuntime();
-		final RiXirGenerator generator = new HotSpotXirGenerator();
+		final HotSpotVMConfig config = VMEntries.getConfiguration();
+		final HotSpotRuntime runtime = new HotSpotRuntime(config);
+		final RiXirGenerator generator = new HotSpotXirGenerator(config);
 		final int wordSize = 8;
 		final int stackFrameAlignment = 8;
 		final int pageSize = 1024;
-		final RiRegisterConfig config = new HotSpotRegisterConfig(System.getProperty("os.name").startsWith("Windows"));
-        final CiTarget target = new CiTarget(new AMD64(), config, true, wordSize, wordSize, wordSize, stackFrameAlignment, pageSize, wordSize, wordSize, 16);
+		final RiRegisterConfig registerConfig = new HotSpotRegisterConfig(config);
+        final CiTarget target = new CiTarget(new AMD64(), registerConfig, true, wordSize, wordSize, wordSize, stackFrameAlignment, pageSize, wordSize, wordSize, 16);
         final CiCompiler compiler = new C1XCompiler(runtime, target, generator);
         
         C1XOptions.setOptimizationLevel(3);
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotRegisterConfig.java	Fri Jul 09 16:33:03 2010 -0700
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotRegisterConfig.java	Mon Jul 12 15:05:17 2010 -0700
@@ -44,8 +44,8 @@
     private final CiRegister[] generalParameterRegisters;
     private final CiRegister[] xmmParameterRegisters = new CiRegister[]{AMD64.xmm0, AMD64.xmm1, AMD64.xmm2, AMD64.xmm3, AMD64.xmm4, AMD64.xmm5, AMD64.xmm6, AMD64.xmm7};
 
-	public HotSpotRegisterConfig(boolean windowsRegisterLayout) {
-		if(windowsRegisterLayout) {
+	public HotSpotRegisterConfig(HotSpotVMConfig config) {
+		if(config.isWindowsOs()) {
 		    generalParameterRegisters = new CiRegister[]{AMD64.rdx, AMD64.r8, AMD64.r9, AMD64.rdi, AMD64.rsi, AMD64.rcx};
 		} else {
 		    generalParameterRegisters = new CiRegister[]{AMD64.rsi, AMD64.rdx, AMD64.rcx, AMD64.r8, AMD64.r9, AMD64.rdi};
@@ -149,11 +149,6 @@
 	}
 
 	@Override
-	public CiRegister getSafepointRegister() {
-		return AMD64.r13;
-	}
-
-	@Override
 	public CiRegister getScratchRegister() {
 		return AMD64.r15;
 	}
@@ -163,9 +158,4 @@
 		return AMD64.rsp;
 	}
 
-	@Override
-	public CiRegister getThreadRegister() {
-		return AMD64.r14;
-	}
-
 }
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotRuntime.java	Fri Jul 09 16:33:03 2010 -0700
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotRuntime.java	Mon Jul 12 15:05:17 2010 -0700
@@ -53,6 +53,12 @@
  */
 public class HotSpotRuntime implements RiRuntime {
 
+	private final HotSpotVMConfig config;
+
+	public HotSpotRuntime(HotSpotVMConfig config) {
+		this.config = config;
+	}
+
 	@Override
 	public int basicObjectLockOffsetInBytes() {
 		// TODO Auto-generated method stub
@@ -197,12 +203,6 @@
 	}
 
 	@Override
-	public int threadExceptionOffset() {
-		// TODO Auto-generated method stub
-		return 0;
-	}
-
-	@Override
 	public RiField getRiField(Field javaField) {
 		// TODO Auto-generated method stub
 		return null;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotVMConfig.java	Mon Jul 12 15:05:17 2010 -0700
@@ -0,0 +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;
+
+/**
+ * Used to communicate configuration details, runtime offsets, etc. to c1x upon compileMethod.
+ * 
+ * @author Lukas Stadler
+ * 
+ */
+public class HotSpotVMConfig {
+	private boolean windowsOs;
+	
+	public boolean isWindowsOs() {
+		return windowsOs;
+	}
+	
+}
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotXirGenerator.java	Fri Jul 09 16:33:03 2010 -0700
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotXirGenerator.java	Mon Jul 12 15:05:17 2010 -0700
@@ -44,6 +44,11 @@
 public class HotSpotXirGenerator extends RiXirGenerator {
 
 	private XirTemplate[] emptyTemplates = new XirTemplate[CiKind.values().length];
+	private final HotSpotVMConfig config;
+
+	public HotSpotXirGenerator(HotSpotVMConfig config) {
+		this.config = config;
+	}
 
 	@Override
 	public List<XirTemplate> buildTemplates(CiXirAssembler asm) {
@@ -200,4 +205,9 @@
 		return new XirSnippet(emptyTemplates[CiKind.Void.ordinal()]);
 	}
 
+	@Override
+	public XirSnippet genExceptionObject(XirSite site) {
+		return new XirSnippet(emptyTemplates[CiKind.Object.ordinal()]);
+	}
+
 }
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/VMEntries.java	Fri Jul 09 16:33:03 2010 -0700
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/VMEntries.java	Mon Jul 12 15:05:17 2010 -0700
@@ -29,4 +29,5 @@
 	public static native boolean RiType_isInterface(Object klassOop);
 	public static native int RiMethod_accessFlags(Object methodOop);
 	public static native void installCode(Object methodOop, byte[] code, int frameSize);
+	public static native HotSpotVMConfig getConfiguration();
 }
--- a/src/share/vm/c1x/c1x_VMEntries.cpp	Fri Jul 09 16:33:03 2010 -0700
+++ b/src/share/vm/c1x/c1x_VMEntries.cpp	Mon Jul 12 15:05:17 2010 -0700
@@ -358,6 +358,27 @@
   }
 }
 
+// helpers used to set fields in the HotSpotVMConfig object
+#define SET_CONFIG_BOOLEAN(name, value) { jfieldID id = jniEnv->GetFieldID(klass, #name, "Z"); jniEnv->SetBooleanField(config, id, value); }
+#define SET_CONFIG_INT(name, value) { jfieldID id = jniEnv->GetFieldID(klass, #name, "I"); jniEnv->SetIntField(config, id, value); }
+
+/*
+* Class:     com_sun_hotspot_c1x_VMEntries
+* Method:    getConfiguration
+* Signature: ()Lcom/sun/hotspot/c1x/HotSpotVMConfig;
+*/
+JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_getConfiguration(JNIEnv *jniEnv, jclass) {
+  jclass klass = jniEnv->FindClass("com/sun/hotspot/c1x/HotSpotVMConfig");
+  assert(klass != NULL, "HotSpot vm config class not found");
+  jobject config = jniEnv->AllocObject(klass);
+  jfieldID id = jniEnv->GetFieldID(klass, "windowsOs", "Z");
+#ifdef _WIN64
+  SET_CONFIG_BOOLEAN(windowsOs, true)
+#else
+  SET_CONFIG_BOOLEAN(windowsOs, false)
+#endif
+  return config;
+}
 
 
 JNINativeMethod VMEntries_methods[] = {
@@ -380,7 +401,8 @@
   {CC"RiType_isInstanceClass",          CC"(Ljava/lang/Object;)Z",                                                  FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiType_1isInstanceClass)},
   {CC"RiType_isInterface",              CC"(Ljava/lang/Object;)Z",                                                  FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiType_1isInterface)},
   {CC"RiMethod_accessFlags",            CC"(Ljava/lang/Object;)I",                                                  FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1accessFlags)},
-  {CC"installCode",                     CC"(Ljava/lang/Object;[BI)V",                                               FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_installCode)}
+  {CC"installCode",                     CC"(Ljava/lang/Object;[BI)V",                                               FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_installCode)},
+  {CC"getConfiguration",                CC"()Lcom/sun/hotspot/c1x/HotSpotVMConfig;",                                FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_getConfiguration)}
 };
 
 int VMEntries_methods_count() {
--- a/src/share/vm/c1x/c1x_VMEntries.hpp	Fri Jul 09 16:33:03 2010 -0700
+++ b/src/share/vm/c1x/c1x_VMEntries.hpp	Mon Jul 12 15:05:17 2010 -0700
@@ -206,6 +206,13 @@
 JNIEXPORT void JNICALL Java_com_sun_hotspot_c1x_VMEntries_installCode
 (JNIEnv *, jclass, jobject, jbyteArray, jint);
 
+/*
+* Class:     com_sun_hotspot_c1x_VMEntries
+* Method:    getConfiguration
+* Signature: ()Lcom/sun/hotspot/c1x/HotSpotVMConfig;
+*/
+JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_getConfiguration
+(JNIEnv *, jclass);
 
 
 extern JNINativeMethod VMEntries_methods[];