# HG changeset patch # User Doug Simon # Date 1288368857 -7200 # Node ID d0c8d3a2a7e83a70d74a7d5afb4d78405c10ed5d # Parent a7a0ef3c685851438231a34f5f98cbcf66bfadcc Modified domake script to use (and require) JRE7 environment variable for find the base of a JRE 7 installation. This script no also ensures that $JRE7/lib/amd64/jvm.cfg has the right value for '-client'. Added c1x4hotspotsrc/hotspot/java as indirect launcher for $JRE7/bin/java that can be referenced from Eclipse launch configuration. Copied .checkstyle_checks.xml from C1X project to c1x4hotspotsrc/HotSpotVM so that it can be used by HotSpotVM project without hard coded path to C1X in another Eclipse workspace. Various other changes to reflect changes in CRI and C1X. diff -r a7a0ef3c6858 -r d0c8d3a2a7e8 c1x4hotspotsrc/HotSpotTest/src/C1XTest.java --- a/c1x4hotspotsrc/HotSpotTest/src/C1XTest.java Mon Oct 25 18:35:34 2010 +0200 +++ b/c1x4hotspotsrc/HotSpotTest/src/C1XTest.java Fri Oct 29 18:14:17 2010 +0200 @@ -1,4 +1,4 @@ -import java.io.IOException; +import java.io.*; public class C1XTest { @@ -25,6 +25,18 @@ } System.out.println("exit"); } + + public static void main2(String[] args) { +// Other.I[] array = new Other.I[] { new Other.A(), new Other.B(), +// new Other.C(), new Other.A(), new Other.B(), new Other.C() }; +// +// int sum = 0; +// for (int i = 0; i < 20; i++) +// for (Other.I o : array) { +// sum += o.v(); +// } +// System.out.println(sum); + } public static void main(String[] args) throws IOException, Exception { for (int i = 0; i < 10000; i++) { diff -r a7a0ef3c6858 -r d0c8d3a2a7e8 c1x4hotspotsrc/HotSpotVM/.checkstyle --- a/c1x4hotspotsrc/HotSpotVM/.checkstyle Mon Oct 25 18:35:34 2010 +0200 +++ b/c1x4hotspotsrc/HotSpotVM/.checkstyle Fri Oct 29 18:14:17 2010 +0200 @@ -1,10 +1,10 @@ - + - + diff -r a7a0ef3c6858 -r d0c8d3a2a7e8 c1x4hotspotsrc/HotSpotVM/.checkstyle_checks.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c1x4hotspotsrc/HotSpotVM/.checkstyle_checks.xml Fri Oct 29 18:14:17 2010 +0200 @@ -0,0 +1,182 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r a7a0ef3c6858 -r d0c8d3a2a7e8 c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/Compiler.java --- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/Compiler.java Mon Oct 25 18:35:34 2010 +0200 +++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/Compiler.java Fri Oct 29 18:14:17 2010 +0200 @@ -20,8 +20,11 @@ */ package com.sun.hotspot.c1x; +import static com.sun.c1x.target.amd64.AMD64.*; + import java.lang.reflect.Proxy; import java.net.*; +import java.util.*; import com.sun.c1x.*; import com.sun.c1x.target.amd64.*; @@ -137,6 +140,23 @@ private final CiTarget target; private final RiXirGenerator generator; + public static final CiRegisterSaveArea RSA; + static { + int offset = 0; + CiRegister[] rsaRegs = { + rax, rcx, rdx, rbx, rsp, rbp, rsi, rdi, + r8, r9, r10, r11, r12, r13, r14, r15, + xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, + xmm8, xmm9, xmm10, xmm11, xmm12, xmm13, xmm14, xmm15 + }; + Map registerOffsets = new HashMap(rsaRegs.length); + for (CiRegister reg : rsaRegs) { + registerOffsets.put(reg, offset); + offset += reg.isFpu() ? 16 : 8; + } + RSA = new CiRegisterSaveArea(offset, registerOffsets, 8, rax, r15); + } + private Compiler() { config = getVMEntries().getConfiguration(); config.check(); @@ -144,15 +164,15 @@ runtime = new HotSpotRuntime(config); final int wordSize = 8; final int stackFrameAlignment = 16; - registerConfig = new HotSpotRegisterConfig(config); - target = new HotSpotTarget(new AMD64(), registerConfig, true, wordSize, wordSize, wordSize, stackFrameAlignment, config.vmPageSize, wordSize, wordSize, config.codeEntryAlignment, true); + registerConfig = runtime.regConfig; + target = new HotSpotTarget(new AMD64(), RSA, true, wordSize, wordSize, wordSize, stackFrameAlignment, config.vmPageSize, wordSize, wordSize, config.codeEntryAlignment, 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); + compiler = new C1XCompiler(runtime, target, generator, registerConfig); C1XOptions.setOptimizationLevel(3); C1XOptions.OptInlineExcept = false; diff -r a7a0ef3c6858 -r d0c8d3a2a7e8 c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotMethodResolved.java --- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotMethodResolved.java Mon Oct 25 18:35:34 2010 +0200 +++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotMethodResolved.java Fri Oct 29 18:14:17 2010 +0200 @@ -170,14 +170,11 @@ @Override public Class accessor() { - // TODO Auto-generated method stub return null; } @Override public int intrinsic() { - // TODO Auto-generated method stub return 0; } - } diff -r a7a0ef3c6858 -r d0c8d3a2a7e8 c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotMethodUnresolved.java --- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotMethodUnresolved.java Mon Oct 25 18:35:34 2010 +0200 +++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotMethodUnresolved.java Fri Oct 29 18:14:17 2010 +0200 @@ -140,14 +140,11 @@ @Override public Class accessor() { - // TODO Auto-generated method stub return null; } @Override public int intrinsic() { - // TODO Auto-generated method stub return 0; } - } diff -r a7a0ef3c6858 -r d0c8d3a2a7e8 c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotRegisterConfig.java --- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotRegisterConfig.java Mon Oct 25 18:35:34 2010 +0200 +++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotRegisterConfig.java Fri Oct 29 18:14:17 2010 +0200 @@ -20,6 +20,10 @@ */ package com.sun.hotspot.c1x; +import static com.sun.c1x.target.amd64.AMD64.*; + +import java.util.*; + import com.sun.c1x.target.amd64.AMD64; import com.sun.c1x.util.Util; import com.sun.cri.ci.CiCallingConvention; @@ -28,7 +32,8 @@ import com.sun.cri.ci.CiStackSlot; import com.sun.cri.ci.CiTarget; import com.sun.cri.ci.CiValue; -import com.sun.cri.ri.RiRegisterConfig; +import com.sun.cri.ci.CiRegister.*; +import com.sun.cri.ri.*; /** * @author Thomas Wuerthinger @@ -37,26 +42,41 @@ public class HotSpotRegisterConfig implements RiRegisterConfig { // be careful - the contents of this array are duplicated in c1x_CodeInstaller.cpp + private final CiRegister[] allocatable = { + rax, rbx, rcx, rdx, rsi, rdi, r8, r9, /* r10, */r11, r12, r13, r14, + xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, + xmm8, xmm9, xmm10, xmm11, xmm12, xmm13, xmm14, xmm15 + }; + + private final EnumMap categorized = CiRegister.categorize(allocatable); + + private final RiRegisterAttributes[] attributesMap; + @Override public CiRegister[] getAllocatableRegisters() { - return new CiRegister[] {AMD64.rax, AMD64.rbx, AMD64.rcx, AMD64.rdx, AMD64.rsi, AMD64.rdi, AMD64.r8, AMD64.r9, /* AMD64.r10, */AMD64.r11, AMD64.r12, AMD64.r13, AMD64.r14, AMD64.xmm0, AMD64.xmm1, AMD64.xmm2, - AMD64.xmm3, AMD64.xmm4, AMD64.xmm5, AMD64.xmm6, AMD64.xmm7, AMD64.xmm8, AMD64.xmm9, AMD64.xmm10, AMD64.xmm11, AMD64.xmm12, AMD64.xmm13, AMD64.xmm14, AMD64.xmm15}; + return allocatable; + } + + @Override + public EnumMap getCategorizedAllocatableRegisters() { + return categorized; + } + + @Override + public RiRegisterAttributes[] getAttributesMap() { + return attributesMap; } 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}; + private final CiRegister[] xmmParameterRegisters = {xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7}; public HotSpotRegisterConfig(HotSpotVMConfig config) { if (config.windowsOs) { - generalParameterRegisters = new CiRegister[] {AMD64.rdx, AMD64.r8, AMD64.r9, AMD64.rdi, AMD64.rsi, AMD64.rcx}; + generalParameterRegisters = new CiRegister[] {rdx, r8, r9, rdi, rsi, rcx}; } else { - generalParameterRegisters = new CiRegister[] {AMD64.rsi, AMD64.rdx, AMD64.rcx, AMD64.r8, AMD64.r9, AMD64.rdi}; + generalParameterRegisters = new CiRegister[] {rsi, rdx, rcx, r8, r9, rdi}; } - } - - @Override - public int getCalleeSaveRegisterOffset(CiRegister register) { - return 0; + attributesMap = RiRegisterAttributes.createMap(this, AMD64.allRegisters); } @Override @@ -64,13 +84,15 @@ return getAllocatableRegisters(); } + private final CiRegister[] none = {}; + @Override - public CiRegister getFramePointerRegister() { - return AMD64.rbp; + public CiRegister[] getCalleeSaveRegisters() { + return none; } @Override - public CiRegister getIntegerRegister(int index) { + public CiRegister getRegister(int index) { throw new UnsupportedOperationException(); } @@ -125,21 +147,11 @@ } @Override - public int getMinimumCalleeSaveFrameSize() { - return 0; - } - - @Override public CiCallingConvention getNativeCallingConvention(CiKind[] parameters, boolean outgoing, CiTarget target) { throw new UnsupportedOperationException(); } @Override - public CiRegister[] getRegisterReferenceMapOrder() { - return getAllocatableRegisters(); - } - - @Override public CiRegister getReturnRegister(CiKind kind) { switch (kind) { case Boolean: @@ -150,10 +162,10 @@ case Long: case Object: case Word: - return AMD64.rax; + return rax; case Float: case Double: - return AMD64.xmm0; + return xmm0; case Void: case Illegal: return null; @@ -169,12 +181,21 @@ @Override public CiRegister getScratchRegister() { - return AMD64.r10; + return r10; + } + + @Override + public CiRegister getFrameRegister() { + return rsp; } @Override - public CiRegister getStackPointerRegister() { - return AMD64.rsp; + public String toString() { + String res = String.format( + "Allocatable: " + Arrays.toString(getAllocatableRegisters()) + "%n" + + "CallerSave: " + Arrays.toString(getCallerSaveRegisters()) + "%n" + + "CalleeSave: " + Arrays.toString(getCalleeSaveRegisters()) + "%n" + + "Scratch: " + getScratchRegister() + "%n"); + return res; } - } diff -r a7a0ef3c6858 -r d0c8d3a2a7e8 c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotRuntime.java --- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotRuntime.java Mon Oct 25 18:35:34 2010 +0200 +++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotRuntime.java Fri Oct 29 18:14:17 2010 +0200 @@ -39,10 +39,13 @@ */ public class HotSpotRuntime implements RiRuntime { - private final HotSpotVMConfig config; + final HotSpotVMConfig config; + final HotSpotRegisterConfig regConfig; + public HotSpotRuntime(HotSpotVMConfig config) { this.config = config; + regConfig = new HotSpotRegisterConfig(config); } @Override @@ -57,7 +60,7 @@ private String disassemble(byte[] code, DisassemblyPrinter disassemblyPrinter) { final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); - final InstructionSet instructionSet = InstructionSet.AMD64; + final ISA instructionSet = ISA.AMD64; Disassembler.disassemble(byteArrayOutputStream, code, instructionSet, WordWidth.BITS_64, 0, null, disassemblyPrinter); return byteArrayOutputStream.toString(); } @@ -218,4 +221,8 @@ return false; } + @Override + public RiRegisterConfig getRegisterConfig(RiMethod method) { + return regConfig; + } } diff -r a7a0ef3c6858 -r d0c8d3a2a7e8 c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotTarget.java --- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotTarget.java Mon Oct 25 18:35:34 2010 +0200 +++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotTarget.java Fri Oct 29 18:14:17 2010 +0200 @@ -21,7 +21,6 @@ package com.sun.hotspot.c1x; import com.sun.cri.ci.*; -import com.sun.cri.ri.*; /** * HotSpot-specific CiTarget that provides the correct stack frame size alignment. @@ -30,9 +29,9 @@ */ public class HotSpotTarget extends CiTarget { - public HotSpotTarget(CiArchitecture arch, RiRegisterConfig registerConfig, boolean isMP, int spillSlotSize, int wordSize, int referenceSize, int stackAlignment, int pageSize, int cacheAlignment, + public HotSpotTarget(CiArchitecture arch, CiRegisterSaveArea rsa, boolean isMP, int spillSlotSize, int wordSize, int referenceSize, int stackAlignment, int pageSize, int cacheAlignment, int heapAlignment, int codeAlignment, boolean inlineObjects) { - super(arch, registerConfig, isMP, spillSlotSize, wordSize, referenceSize, stackAlignment, pageSize, cacheAlignment, heapAlignment, codeAlignment, inlineObjects); + super(arch, rsa, isMP, spillSlotSize, wordSize, referenceSize, stackAlignment, pageSize, cacheAlignment, heapAlignment, codeAlignment, inlineObjects); } @Override diff -r a7a0ef3c6858 -r d0c8d3a2a7e8 c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/VMEntries.java --- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/VMEntries.java Mon Oct 25 18:35:34 2010 +0200 +++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/VMEntries.java Fri Oct 29 18:14:17 2010 +0200 @@ -31,7 +31,7 @@ */ public interface VMEntries { - // CHECKSTYLE:OFF + // Checkstyle: stop byte[] RiMethod_code(long vmId); @@ -81,5 +81,5 @@ boolean RiMethod_hasBalancedMonitors(long vmId); - // CHECKSTYLE:ON + // Checkstyle: resume } diff -r a7a0ef3c6858 -r d0c8d3a2a7e8 c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/VMEntriesNative.java --- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/VMEntriesNative.java Mon Oct 25 18:35:34 2010 +0200 +++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/VMEntriesNative.java Fri Oct 29 18:14:17 2010 +0200 @@ -31,6 +31,7 @@ */ public class VMEntriesNative implements VMEntries { + // Checkstyle: stop @Override public native byte[] RiMethod_code(long vmId); @@ -102,5 +103,5 @@ @Override public native boolean RiMethod_hasBalancedMonitors(long vmId); - + // Checkstyle: resume } diff -r a7a0ef3c6858 -r d0c8d3a2a7e8 c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/VMExitsNative.java --- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/VMExitsNative.java Mon Oct 25 18:35:34 2010 +0200 +++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/VMExitsNative.java Fri Oct 29 18:14:17 2010 +0200 @@ -110,7 +110,7 @@ try { Compiler compiler = Compiler.getInstance(); HotSpotMethodResolved riMethod = new HotSpotMethodResolved(methodVmId, name); - CiResult result = compiler.getCompiler().compileMethod(riMethod, null); + CiResult result = compiler.getCompiler().compileMethod(riMethod, -1, null); if (result.bailout() != null) { StringWriter out = new StringWriter(); diff -r a7a0ef3c6858 -r d0c8d3a2a7e8 c1x4hotspotsrc/hotspot/hotspot Default.launch --- a/c1x4hotspotsrc/hotspot/hotspot Default.launch Mon Oct 25 18:35:34 2010 +0200 +++ b/c1x4hotspotsrc/hotspot/hotspot Default.launch Fri Oct 29 18:14:17 2010 +0200 @@ -3,7 +3,7 @@ - + diff -r a7a0ef3c6858 -r d0c8d3a2a7e8 c1x4hotspotsrc/hotspot/hotspot SciMark.launch --- a/c1x4hotspotsrc/hotspot/hotspot SciMark.launch Mon Oct 25 18:35:34 2010 +0200 +++ b/c1x4hotspotsrc/hotspot/hotspot SciMark.launch Fri Oct 29 18:14:17 2010 +0200 @@ -16,7 +16,7 @@ - + diff -r a7a0ef3c6858 -r d0c8d3a2a7e8 c1x4hotspotsrc/hotspot/hotspot jtt.launch --- a/c1x4hotspotsrc/hotspot/hotspot jtt.launch Mon Oct 25 18:35:34 2010 +0200 +++ b/c1x4hotspotsrc/hotspot/hotspot jtt.launch Fri Oct 29 18:14:17 2010 +0200 @@ -2,8 +2,8 @@ - - + + diff -r a7a0ef3c6858 -r d0c8d3a2a7e8 c1x4hotspotsrc/hotspot/java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c1x4hotspotsrc/hotspot/java Fri Oct 29 18:14:17 2010 +0200 @@ -0,0 +1,6 @@ +#!/bin/bash +# Launcher for JRE7 modified to run the HotSpotX compiler + +test -n "$JRE7" || { echo "Need to set JRE7 environment variable to the base of a JRE 1.7"; exit 1; } +exec $JRE7/bin/java "$@" + diff -r a7a0ef3c6858 -r d0c8d3a2a7e8 domake --- a/domake Mon Oct 25 18:35:34 2010 +0200 +++ b/domake Fri Oct 29 18:14:17 2010 +0200 @@ -1,7 +1,25 @@ #!/bin/bash -pushd make + +test -n "$JRE7" || { echo "Need to set JRE7 environment variable to the base of a JRE 1.7"; exit 1; } + +# Resolve location of this script +me="${BASH_SOURCE[0]}" +while [ -h "$me" ]; do + me=`readlink -e "$me"` +done + +grep '-client KNOWN' $JRE7/lib/amd64/jvm.cfg >/dev/null +if [ $? -ne 0 ] ; then + echo "The setting for -client in $JRE7/lib/amd64/jvm.cfg must be:" + echo + echo " -client KNOWN" + echo + exit 1 +fi + +pushd $(dirname "$me")/make ALT_BOOTDIR=/usr/lib/jvm/java-6-openjdk/ LANG=C ARCH_DATA_MODEL=64 HOTSPOT_BUILD_JOBS=2 make jvmg1 -cp ../build/linux/linux_amd64_compiler1/jvmg/libjvm.so ../../jre1.7.0/lib/amd64/client -cp ../build/linux/linux_amd64_compiler1/jvmg/libjsig.so ../../jre1.7.0/lib/amd64/client +cp ../build/linux/linux_amd64_compiler1/jvmg/libjvm.so $JRE7/lib/amd64/client +cp ../build/linux/linux_amd64_compiler1/jvmg/libjsig.so $JRE7/lib/amd64/client popd diff -r a7a0ef3c6858 -r d0c8d3a2a7e8 src/share/vm/c1x/c1x_CodeInstaller.cpp --- a/src/share/vm/c1x/c1x_CodeInstaller.cpp Mon Oct 25 18:35:34 2010 +0200 +++ b/src/share/vm/c1x/c1x_CodeInstaller.cpp Fri Oct 29 18:14:17 2010 +0200 @@ -50,7 +50,7 @@ arrayOop register_map = (arrayOop) CiDebugInfo::registerRefMap(debug_info); arrayOop frame_map = (arrayOop) CiDebugInfo::frameRefMap(debug_info); - assert(register_map->length() == (NUM_REGS + 7) / 8, "unexpected register_map length"); + assert(register_map->length() == (NUM_CPU_REGS + 7) / 8, "unexpected register_map length"); for (jint i = 0; i < NUM_REGS; i++) { unsigned char byte = ((unsigned char*) register_map->base(T_BYTE))[i / 8];