Mercurial > hg > truffle
changeset 10897:9c4f90e48c60
read HotSpot VM options via HotSpotDiagnosticMXBean
author | twisti |
---|---|
date | Fri, 26 Jul 2013 14:03:07 -0700 |
parents | 8106edbdeac9 |
children | ea308a63760b |
files | graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java src/share/vm/graal/graalCompilerToVM.cpp |
diffstat | 2 files changed, 99 insertions(+), 54 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java Fri Jul 26 20:18:46 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java Fri Jul 26 14:03:07 2013 -0700 @@ -22,6 +22,9 @@ */ package com.oracle.graal.hotspot; +import com.sun.management.HotSpotDiagnosticMXBean; +import sun.management.ManagementFactoryHelper; + /** * Used to communicate configuration details, runtime offsets, etc. to Graal upon compileMethod. */ @@ -29,45 +32,101 @@ private static final long serialVersionUID = -4744897993263044184L; + private final HotSpotDiagnosticMXBean diagnostic = ManagementFactoryHelper.getDiagnosticMXBean(); + HotSpotVMConfig() { } + /** + * Gets the value of an VM option. + * + * @param name option's name + * @return value of option + * @throws IllegalArgumentException if option doesn't exist + */ + private int getVMOptionInt(String name) { + String value = diagnostic.getVMOption(name).getValue(); + return new Integer(value).intValue(); + } + + /** + * Gets the value of an VM option. + * + * @param name option's name + * @param defaultValue default value if option is not exists (e.g. development options) + * @return value of option or defaultValue if option doesn't exist + */ + private int getVMOption(String name, int defaultValue) { + try { + return getVMOptionInt(name); + } catch (IllegalArgumentException e) { + return defaultValue; + } + } + + /** + * Gets the value of an VM option. + * + * @param name option's name + * @return value of option + * @throws IllegalArgumentException if option doesn't exist + */ + private boolean getVMOption(String name) { + String value = diagnostic.getVMOption(name).getValue(); + return new Boolean(value).booleanValue(); + } + + /** + * Gets the value of an VM option. + * + * @param name option's name + * @param defaultValue default value if option is not exists (e.g. development options) + * @return value of option or defaultValue if option doesn't exist + */ + private boolean getVMOption(String name, boolean defaultValue) { + try { + return getVMOption(name); + } catch (IllegalArgumentException e) { + return defaultValue; + } + } + // os information, register layout, code generation, ... public boolean cAssertions; public final boolean windowsOs = System.getProperty("os.name", "").startsWith("Windows"); public int codeEntryAlignment; - public boolean verifyOops; - public boolean ciTime; - public int compileThreshold; - public boolean compileTheWorld; - public int compileTheWorldStartAt; - public int compileTheWorldStopAt; - public boolean printCompilation; - public boolean printInlining; - public boolean useFastLocking; - public boolean useTLAB; - public boolean useBiasedLocking; - public boolean usePopCountInstruction; - public boolean useAESIntrinsics; - public boolean useG1GC; + public final boolean verifyOops = getVMOption("VerifyOops", false); + public final boolean ciTime = getVMOption("CITime"); + public final int compileThreshold = getVMOptionInt("CompileThreshold"); + public final boolean compileTheWorld = getVMOption("CompileTheWorld", false); + public final int compileTheWorldStartAt = getVMOption("CompileTheWorldStartAt", 1); + public final int compileTheWorldStopAt = getVMOption("CompileTheWorldStopAt", Integer.MAX_VALUE); + public final boolean printCompilation = getVMOption("PrintCompilation"); + public final boolean printInlining = getVMOption("PrintInlining", false); + public final boolean useFastLocking = getVMOption("GraalUseFastLocking", true); + public final boolean useTLAB = getVMOption("UseTLAB"); + public final boolean useBiasedLocking = getVMOption("UseBiasedLocking"); + public final boolean usePopCountInstruction = getVMOption("UsePopCountInstruction"); + public final boolean useAESIntrinsics = getVMOption("UseAESIntrinsics"); + public final boolean useG1GC = getVMOption("UseG1GC"); public long gcTotalCollectionsAddress; // Compressed Oops related values. - public boolean useCompressedOops; - public boolean useCompressedKlassPointers; + public boolean useCompressedOops = getVMOption("UseCompressedOops"); + public boolean useCompressedKlassPointers = getVMOption("UseCompressedKlassPointers"); public long narrowOopBase; public int narrowOopShift; - public int logMinObjAlignment; + public final int logMinObjAlignment = (int) (Math.log(getVMOptionInt("ObjectAlignmentInBytes")) / Math.log(2)); public long narrowKlassBase; public int narrowKlassShift; public int logKlassAlignment; // CPU capabilities - public int useSSE; - public int useAVX; + public final int useSSE = getVMOptionInt("UseSSE"); + public final int useAVX = getVMOption("UseAVX", 99); // offsets, ... - public int stackShadowPages; + public final int stackShadowPages = getVMOptionInt("StackShadowPages"); /** * The offset of the mark word in an object's header. @@ -371,8 +430,18 @@ public int threadTlabSizeOffset; public int threadAllocatedBytesOffset; public int threadLastJavaSpOffset; + public int threadLastJavaPcOffset; + + /** + * This value is only valid on AMD64. + */ public int threadLastJavaFpOffset; - public int threadLastJavaPcOffset; + + /** + * This value is only valid on SPARC. + */ + public int threadJavaFrameAnchorFlagsOffset; + public int threadObjectResultOffset; public int tlabRefillWasteLimitOffset; public int tlabRefillWasteIncrement; @@ -380,7 +449,7 @@ public int tlabSlowAllocationsOffset; public int tlabFastRefillWasteOffset; public int tlabNumberOfRefillsOffset; - public boolean tlabStats; + public final boolean tlabStats = getVMOption("TLABStats"); public int klassInstanceSizeOffset; public boolean inlineContiguousAllocationSupported; public long arrayPrototypeMarkWord; @@ -402,9 +471,10 @@ public int dataLayoutBCIOffset; public int dataLayoutCellsOffset; public int dataLayoutCellSize; - public int bciProfileWidth; - public int typeProfileWidth; - public int methodProfileWidth; + public final int bciProfileWidth = getVMOption("BciProfileWidth", 2); // develop flag; might +// change + public final int typeProfileWidth = getVMOptionInt("TypeProfileWidth"); + public final int methodProfileWidth = getVMOptionInt("MethodProfileWidth"); public long inlineCacheMissStub; public long handleDeoptStub;
--- a/src/share/vm/graal/graalCompilerToVM.cpp Fri Jul 26 20:18:46 2013 +0200 +++ b/src/share/vm/graal/graalCompilerToVM.cpp Fri Jul 26 14:03:07 2013 -0700 @@ -663,31 +663,11 @@ #define set_long(name, value) do { env->SetLongField(config, getFieldID(env, config, name, "J"), value); } while (0) #define set_address(name, value) do { set_long(name, (jlong) value); } while (0) #define set_object(name, value) do { env->SetObjectField(config, getFieldID(env, config, name, "Ljava/lang/Object;"), value); } while (0) -#define set_int_array(name, value) do { env->SetObjectField(config, getFieldID(env, config, name, "[I"), value); } while (0) guarantee(HeapWordSize == sizeof(char*), "Graal assumption that HeadWordSize == machine word size is wrong"); set_boolean("cAssertions", DEBUG_ONLY(true) NOT_DEBUG(false)); - set_boolean("verifyOops", VerifyOops); - set_boolean("ciTime", CITime); - set_int("compileThreshold", CompileThreshold); - set_boolean("compileTheWorld", CompileTheWorld); - set_int("compileTheWorldStartAt", CompileTheWorldStartAt); - set_int("compileTheWorldStopAt", CompileTheWorldStopAt); - set_boolean("printCompilation", PrintCompilation); - set_boolean("printInlining", PrintInlining); - set_boolean("useFastLocking", GraalUseFastLocking); - set_boolean("useBiasedLocking", UseBiasedLocking); - set_boolean("usePopCountInstruction", UsePopCountInstruction); - set_boolean("useAESIntrinsics", UseAESIntrinsics); - set_boolean("useTLAB", UseTLAB); - set_boolean("useG1GC", UseG1GC); -#ifdef TARGET_ARCH_x86 - set_int("useSSE", UseSSE); - set_int("useAVX", UseAVX); -#endif set_int("codeEntryAlignment", CodeEntryAlignment); - set_int("stackShadowPages", StackShadowPages); set_int("hubOffset", oopDesc::klass_offset_in_bytes()); set_int("markOffset", oopDesc::mark_offset_in_bytes()); set_int("prototypeMarkWordOffset", in_bytes(Klass::prototype_header_offset())); @@ -760,9 +740,6 @@ set_int("dataLayoutBCIOffset", in_bytes(DataLayout::bci_offset())); set_int("dataLayoutCellsOffset", in_bytes(DataLayout::cell_offset(0))); set_int("dataLayoutCellSize", DataLayout::cell_size); - set_int("bciProfileWidth", BciProfileWidth); - set_int("typeProfileWidth", TypeProfileWidth); - set_int("methodProfileWidth", MethodProfileWidth); set_int("tlabAlignmentReserve", (int32_t)ThreadLocalAllocBuffer::alignment_reserve()); set_long("tlabIntArrayMarkWord", (intptr_t)markOopDesc::prototype()->copy_set_hash(0x2)); @@ -772,10 +749,13 @@ set_int("threadTlabSizeOffset", in_bytes(JavaThread::tlab_size_offset())); set_int("threadAllocatedBytesOffset", in_bytes(JavaThread::allocated_bytes_offset())); set_int("threadLastJavaSpOffset", in_bytes(JavaThread::last_Java_sp_offset())); + set_int("threadLastJavaPcOffset", in_bytes(JavaThread::last_Java_pc_offset())); #ifdef TARGET_ARCH_x86 set_int("threadLastJavaFpOffset", in_bytes(JavaThread::last_Java_fp_offset())); #endif - set_int("threadLastJavaPcOffset", in_bytes(JavaThread::last_Java_pc_offset())); +#ifdef TARGET_ARCH_sparc + set_int("threadJavaFrameAnchorFlagsOffset", in_bytes(JavaThread::frame_anchor_offset() + JavaFrameAnchor::flags_offset())); +#endif set_int("threadObjectResultOffset", in_bytes(JavaThread::vm_result_offset())); set_int("tlabSlowAllocationsOffset", in_bytes(JavaThread::tlab_slow_allocations_offset())); set_int("tlabFastRefillWasteOffset", in_bytes(JavaThread::tlab_fast_refill_waste_offset())); @@ -783,7 +763,6 @@ set_int("tlabRefillWasteLimitOffset", in_bytes(JavaThread::tlab_refill_waste_limit_offset())); set_int("tlabRefillWasteIncrement", (int32_t) ThreadLocalAllocBuffer::refill_waste_limit_increment()); set_int("klassInstanceSizeOffset", in_bytes(Klass::layout_helper_offset())); - set_boolean("tlabStats", TLABStats); set_boolean("inlineContiguousAllocationSupported", !CMSIncrementalMode && Universe::heap()->supports_inline_contig_alloc()); set_address("nonOopBits", Universe::non_oop_word()); @@ -863,11 +842,8 @@ set_int("vmIntrinsicLinkToSpecial", vmIntrinsics::_linkToSpecial); set_int("vmIntrinsicLinkToInterface", vmIntrinsics::_linkToInterface); - set_boolean("useCompressedOops", UseCompressedOops); - set_boolean("useCompressedKlassPointers", UseCompressedKlassPointers); set_address("narrowOopBase", Universe::narrow_oop_base()); set_int("narrowOopShift", Universe::narrow_oop_shift()); - set_int("logMinObjAlignment", LogMinObjAlignmentInBytes); set_address("narrowKlassBase", Universe::narrow_klass_base()); set_int("narrowKlassShift", Universe::narrow_klass_shift()); set_int("logKlassAlignment", LogKlassAlignmentInBytes); @@ -912,7 +888,6 @@ #undef set_int #undef set_long #undef set_object -#undef set_int_array C2V_END