# HG changeset patch # User Tom Rodriguez # Date 1400618794 25200 # Node ID dffc37fa7157f4ce10a942c50118d91e9d7e8f52 # Parent bde6fbdbbe38325fc51fb39fa4153b6a55cbef55 initialize HotSpotVMConfig fields efficiently from C++ diff -r bde6fbdbbe38 -r dffc37fa7157 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java Tue May 20 21:38:31 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java Tue May 20 13:46:34 2014 -0700 @@ -30,6 +30,7 @@ import com.oracle.graal.compiler.common.*; import com.oracle.graal.hotspot.bridge.*; import com.oracle.graal.hotspot.meta.*; +import com.oracle.graal.hotspotvmconfig.*; /** * Used to access native configuration details. @@ -65,14 +66,21 @@ public final int maxFrameSize = 16 * 1024; HotSpotVMConfig(CompilerToVM compilerToVm) { + compilerToVm.initializeConfiguration(this); + assert verifyInitialization(); + + oopEncoding = new CompressEncoding(narrowOopBase, narrowOopShift, logMinObjAlignment()); + klassEncoding = new CompressEncoding(narrowKlassBase, narrowKlassShift, logKlassAlignment); + + assert check(); + } + + /** + * Check that the initialization produces the same result as the values captured through + * vmStructs. + */ + private boolean verifyInitialization() { /** These fields are set in {@link CompilerToVM#initializeConfiguration}. */ - gHotSpotVMStructs = 0; - gHotSpotVMTypes = 0; - gHotSpotVMIntConstants = 0; - gHotSpotVMLongConstants = 0; - - compilerToVm.initializeConfiguration(this); - assert gHotSpotVMStructs != 0; assert gHotSpotVMTypes != 0; assert gHotSpotVMIntConstants != 0; @@ -114,7 +122,7 @@ String type = annotation.type(); VMFields.Field entry = vmFields.get(name); if (entry == null) { - if (annotation.optional() || !isRequired(currentArch, annotation.archs())) { + if (!isRequired(currentArch, annotation.archs())) { continue; } throw new IllegalArgumentException("field not found: " + name); @@ -129,13 +137,13 @@ switch (annotation.get()) { case OFFSET: - setField(f, entry.getOffset()); + checkField(f, entry.getOffset()); break; case ADDRESS: - setField(f, entry.getAddress()); + checkField(f, entry.getAddress()); break; case VALUE: - setField(f, entry.getValue()); + checkField(f, entry.getValue()); break; default: throw GraalInternalError.shouldNotReachHere("unknown kind " + annotation.get()); @@ -149,7 +157,7 @@ } switch (annotation.get()) { case SIZE: - setField(f, entry.getSize()); + checkField(f, entry.getSize()); break; default: throw GraalInternalError.shouldNotReachHere("unknown kind " + annotation.get()); @@ -164,7 +172,7 @@ } throw new IllegalArgumentException("constant not found: " + name); } - setField(f, entry.getValue()); + checkField(f, entry.getValue()); } else if (f.isAnnotationPresent(HotSpotVMFlag.class)) { HotSpotVMFlag annotation = f.getAnnotation(HotSpotVMFlag.class); String name = annotation.name(); @@ -176,14 +184,10 @@ throw new IllegalArgumentException("flag not found: " + name); } - setField(f, entry.getValue()); + checkField(f, entry.getValue()); } } - - oopEncoding = new CompressEncoding(narrowOopBase, narrowOopShift, logMinObjAlignment()); - klassEncoding = new CompressEncoding(narrowKlassBase, narrowKlassShift, logKlassAlignment); - - assert check(); + return true; } private final CompressEncoding oopEncoding; @@ -197,29 +201,29 @@ return klassEncoding; } - private void setField(Field field, Object value) { + private void checkField(Field field, Object value) { try { Class fieldType = field.getType(); if (fieldType == boolean.class) { if (value instanceof String) { - field.setBoolean(this, Boolean.valueOf((String) value)); + assert field.getBoolean(this) == Boolean.valueOf((String) value) : field + " " + value + " " + field.getBoolean(this); } else if (value instanceof Boolean) { - field.setBoolean(this, (boolean) value); + assert field.getBoolean(this) == (boolean) value : field + " " + value + " " + field.getBoolean(this); } else if (value instanceof Long) { - field.setBoolean(this, ((long) value) != 0); + assert field.getBoolean(this) == (((long) value) != 0) : field + " " + value + " " + field.getBoolean(this); } else { GraalInternalError.shouldNotReachHere(value.getClass().getSimpleName()); } } else if (fieldType == int.class) { if (value instanceof Integer) { - field.setInt(this, (int) value); + assert field.getInt(this) == (int) value : field + " " + value + " " + field.getInt(this); } else if (value instanceof Long) { - field.setInt(this, (int) (long) value); + assert field.getInt(this) == (int) (long) value : field + " " + value + " " + field.getInt(this); } else { GraalInternalError.shouldNotReachHere(value.getClass().getSimpleName()); } } else if (fieldType == long.class) { - field.setLong(this, (long) value); + assert field.getLong(this) == (long) value : field + " " + value + " " + field.getLong(this); } else { GraalInternalError.shouldNotReachHere(field.toString()); } @@ -248,14 +252,14 @@ /** * VMStructEntry (see vmStructs.hpp). */ - private long gHotSpotVMStructs; - private long gHotSpotVMStructEntryTypeNameOffset; - private long gHotSpotVMStructEntryFieldNameOffset; - private long gHotSpotVMStructEntryTypeStringOffset; - private long gHotSpotVMStructEntryIsStaticOffset; - private long gHotSpotVMStructEntryOffsetOffset; - private long gHotSpotVMStructEntryAddressOffset; - private long gHotSpotVMStructEntryArrayStride; + @HotSpotVMValue(expression = "gHotSpotVMStructs", get = HotSpotVMValue.Type.ADDRESS) @Stable private long gHotSpotVMStructs; + @HotSpotVMValue(expression = "gHotSpotVMStructEntryTypeNameOffset") @Stable private long gHotSpotVMStructEntryTypeNameOffset; + @HotSpotVMValue(expression = "gHotSpotVMStructEntryFieldNameOffset") @Stable private long gHotSpotVMStructEntryFieldNameOffset; + @HotSpotVMValue(expression = "gHotSpotVMStructEntryTypeStringOffset") @Stable private long gHotSpotVMStructEntryTypeStringOffset; + @HotSpotVMValue(expression = "gHotSpotVMStructEntryIsStaticOffset") @Stable private long gHotSpotVMStructEntryIsStaticOffset; + @HotSpotVMValue(expression = "gHotSpotVMStructEntryOffsetOffset") @Stable private long gHotSpotVMStructEntryOffsetOffset; + @HotSpotVMValue(expression = "gHotSpotVMStructEntryAddressOffset") @Stable private long gHotSpotVMStructEntryAddressOffset; + @HotSpotVMValue(expression = "gHotSpotVMStructEntryArrayStride") @Stable private long gHotSpotVMStructEntryArrayStride; class VMFields implements Iterable { @@ -364,14 +368,14 @@ /** * VMTypeEntry (see vmStructs.hpp). */ - private long gHotSpotVMTypes; - private long gHotSpotVMTypeEntryTypeNameOffset; - private long gHotSpotVMTypeEntrySuperclassNameOffset; - private long gHotSpotVMTypeEntryIsOopTypeOffset; - private long gHotSpotVMTypeEntryIsIntegerTypeOffset; - private long gHotSpotVMTypeEntryIsUnsignedOffset; - private long gHotSpotVMTypeEntrySizeOffset; - private long gHotSpotVMTypeEntryArrayStride; + @HotSpotVMValue(expression = "gHotSpotVMTypes", get = HotSpotVMValue.Type.ADDRESS) @Stable private long gHotSpotVMTypes; + @HotSpotVMValue(expression = "gHotSpotVMTypeEntryTypeNameOffset") @Stable private long gHotSpotVMTypeEntryTypeNameOffset; + @HotSpotVMValue(expression = "gHotSpotVMTypeEntrySuperclassNameOffset") @Stable private long gHotSpotVMTypeEntrySuperclassNameOffset; + @HotSpotVMValue(expression = "gHotSpotVMTypeEntryIsOopTypeOffset") @Stable private long gHotSpotVMTypeEntryIsOopTypeOffset; + @HotSpotVMValue(expression = "gHotSpotVMTypeEntryIsIntegerTypeOffset") @Stable private long gHotSpotVMTypeEntryIsIntegerTypeOffset; + @HotSpotVMValue(expression = "gHotSpotVMTypeEntryIsUnsignedOffset") @Stable private long gHotSpotVMTypeEntryIsUnsignedOffset; + @HotSpotVMValue(expression = "gHotSpotVMTypeEntrySizeOffset") @Stable private long gHotSpotVMTypeEntrySizeOffset; + @HotSpotVMValue(expression = "gHotSpotVMTypeEntryArrayStride") @Stable private long gHotSpotVMTypeEntryArrayStride; class VMTypes implements Iterable { @@ -476,10 +480,10 @@ /** * VMIntConstantEntry (see vmStructs.hpp). */ - private long gHotSpotVMIntConstants; - private long gHotSpotVMIntConstantEntryNameOffset; - private long gHotSpotVMIntConstantEntryValueOffset; - private long gHotSpotVMIntConstantEntryArrayStride; + @HotSpotVMValue(expression = "gHotSpotVMIntConstants", get = HotSpotVMValue.Type.ADDRESS) @Stable private long gHotSpotVMIntConstants; + @HotSpotVMValue(expression = "gHotSpotVMIntConstantEntryNameOffset") @Stable private long gHotSpotVMIntConstantEntryNameOffset; + @HotSpotVMValue(expression = "gHotSpotVMIntConstantEntryValueOffset") @Stable private long gHotSpotVMIntConstantEntryValueOffset; + @HotSpotVMValue(expression = "gHotSpotVMIntConstantEntryArrayStride") @Stable private long gHotSpotVMIntConstantEntryArrayStride; class VMIntConstants implements Iterable { @@ -540,10 +544,10 @@ /** * VMLongConstantEntry (see vmStructs.hpp). */ - private long gHotSpotVMLongConstants; - private long gHotSpotVMLongConstantEntryNameOffset; - private long gHotSpotVMLongConstantEntryValueOffset; - private long gHotSpotVMLongConstantEntryArrayStride; + @HotSpotVMValue(expression = "gHotSpotVMLongConstants", get = HotSpotVMValue.Type.ADDRESS) @Stable private long gHotSpotVMLongConstants; + @HotSpotVMValue(expression = "gHotSpotVMLongConstantEntryNameOffset") @Stable private long gHotSpotVMLongConstantEntryNameOffset; + @HotSpotVMValue(expression = "gHotSpotVMLongConstantEntryValueOffset") @Stable private long gHotSpotVMLongConstantEntryValueOffset; + @HotSpotVMValue(expression = "gHotSpotVMLongConstantEntryArrayStride") @Stable private long gHotSpotVMLongConstantEntryArrayStride; class VMLongConstants implements Iterable { @@ -699,7 +703,7 @@ } // os information, register layout, code generation, ... - @HotSpotVMConstant(name = "ASSERT") @Stable public boolean cAssertions; + @HotSpotVMValue(expression = "DEBUG_ONLY(1) NOT_DEBUG(0)") @Stable public boolean cAssertions; public final boolean windowsOs = System.getProperty("os.name", "").startsWith("Windows"); @HotSpotVMFlag(name = "CodeEntryAlignment") @Stable public int codeEntryAlignment; @@ -708,8 +712,8 @@ @HotSpotVMFlag(name = "CITimeEach") @Stable public boolean ciTimeEach; @HotSpotVMFlag(name = "CompileThreshold") @Stable public long compileThreshold; @HotSpotVMFlag(name = "CompileTheWorld") @Stable public boolean compileTheWorld; - @HotSpotVMFlag(name = "CompileTheWorldStartAt") @Stable public int compileTheWorldStartAt; - @HotSpotVMFlag(name = "CompileTheWorldStopAt") @Stable public int compileTheWorldStopAt; + @HotSpotVMFlag(name = "CompileTheWorldStartAt", optional = true) @Stable public int compileTheWorldStartAt; + @HotSpotVMFlag(name = "CompileTheWorldStopAt", optional = true) @Stable public int compileTheWorldStopAt; @HotSpotVMFlag(name = "DontCompileHugeMethods") @Stable public boolean dontCompileHugeMethods; @HotSpotVMFlag(name = "HugeMethodLimit") @Stable public int hugeMethodLimit; @HotSpotVMFlag(name = "PrintCompilation") @Stable public boolean printCompilation; @@ -848,12 +852,12 @@ @HotSpotVMType(name = "vtableEntry", get = HotSpotVMType.Type.SIZE) @Stable public int vtableEntrySize; @HotSpotVMField(name = "vtableEntry::_method", type = "Method*", get = HotSpotVMField.Type.OFFSET) @Stable public int vtableEntryMethodOffset; - @Stable public int instanceKlassVtableStartOffset; + @HotSpotVMValue(expression = "InstanceKlass::vtable_start_offset() * HeapWordSize") @Stable public int instanceKlassVtableStartOffset; /** * The offset of the array length word in an array object's header. */ - @Stable public int arrayLengthOffset; + @HotSpotVMValue(expression = "arrayOopDesc::length_offset_in_bytes()") @Stable public int arrayLengthOffset; @HotSpotVMField(name = "Array::_length", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int arrayU1LengthOffset; @HotSpotVMField(name = "Array::_data", type = "", get = HotSpotVMField.Type.OFFSET) @Stable public int arrayU1DataOffset; @@ -895,7 +899,7 @@ @HotSpotVMField(name = "JavaThread::_is_method_handle_return", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int threadIsMethodHandleReturnOffset; @HotSpotVMField(name = "JavaThread::_satb_mark_queue", type = "ObjPtrQueue", get = HotSpotVMField.Type.OFFSET) @Stable public int javaThreadSatbMarkQueueOffset; @HotSpotVMField(name = "JavaThread::_vm_result", type = "oop", get = HotSpotVMField.Type.OFFSET) @Stable public int threadObjectResultOffset; - @HotSpotVMField(name = "JavaThread::_graal_counters[0]", type = "jlong", get = HotSpotVMField.Type.OFFSET, optional = true) @Stable public int graalCountersThreadOffset; + @HotSpotVMValue(expression = "in_bytes(JavaThread::graal_counters_offset())") @Stable public int graalCountersThreadOffset; /** * An invalid value for {@link #rtldDefault}. @@ -909,7 +913,7 @@ * void* (const char *filename, char *ebuf, int ebuflen) * */ - @Stable public long dllLoad; + @HotSpotVMValue(expression = "os::dll_load", get = HotSpotVMValue.Type.ADDRESS) @Stable public long dllLoad; /** * Address of the library lookup routine. The C signature of this routine is: @@ -918,7 +922,7 @@ * void* (void* handle, const char* name) * */ - @Stable public long dllLookup; + @HotSpotVMValue(expression = "os::dll_lookup", get = HotSpotVMValue.Type.ADDRESS) @Stable public long dllLookup; /** * A pseudo-handle which when used as the first argument to {@link #dllLookup} means lookup will @@ -926,7 +930,7 @@ * this field is {@value #INVALID_RTLD_DEFAULT_HANDLE}, then this capability is not supported on * the current platform. */ - @Stable public long rtldDefault = INVALID_RTLD_DEFAULT_HANDLE; + @HotSpotVMValue(expression = "RTLD_DEFAULT", defines = {"TARGET_OS_FAMILY_bsd", "TARGET_OS_FAMILY_linux"}, get = HotSpotVMValue.Type.ADDRESS) @Stable public long rtldDefault = INVALID_RTLD_DEFAULT_HANDLE; /** * This field is used to pass exception objects into and out of the runtime system during @@ -1077,7 +1081,7 @@ /** * Value of Method::extra_stack_entries(). */ - @Stable public int extraStackEntries; + @HotSpotVMValue(expression = "Method::extra_stack_entries()") @Stable public int extraStackEntries; @HotSpotVMField(name = "ConstMethod::_constants", type = "ConstantPool*", get = HotSpotVMField.Type.OFFSET) @Stable public int constMethodConstantsOffset; @HotSpotVMField(name = "ConstMethod::_flags", type = "u2", get = HotSpotVMField.Type.OFFSET) @Stable public int constMethodFlagsOffset; @@ -1158,8 +1162,8 @@ @HotSpotVMField(name = "Universe::_non_oop_bits", type = "intptr_t", get = HotSpotVMField.Type.VALUE) @Stable public long nonOopBits; @HotSpotVMField(name = "StubRoutines::_verify_oop_count", type = "jint", get = HotSpotVMField.Type.ADDRESS) @Stable public long verifyOopCounterAddress; - @Stable public long verifyOopMask; - @Stable public long verifyOopBits; + @HotSpotVMValue(expression = "Universe::verify_oop_mask()") @Stable public long verifyOopMask; + @HotSpotVMValue(expression = "Universe::verify_oop_bits()") @Stable public long verifyOopBits; @HotSpotVMField(name = "CollectedHeap::_barrier_set", type = "BarrierSet*", get = HotSpotVMField.Type.OFFSET) @Stable public int collectedHeapBarrierSetOffset; @@ -1249,13 +1253,13 @@ @HotSpotVMType(name = "BasicLock", get = HotSpotVMType.Type.SIZE) @Stable public int basicLockSize; @HotSpotVMField(name = "BasicLock::_displaced_header", type = "markOop", get = HotSpotVMField.Type.OFFSET) @Stable public int basicLockDisplacedHeaderOffset; - @Stable public long heapEndAddress; - @Stable public long heapTopAddress; + @HotSpotVMValue(expression = "Universe::heap()->end_addr()", get = HotSpotVMValue.Type.ADDRESS) @Stable public long heapEndAddress; + @HotSpotVMValue(expression = "Universe::heap()->top_addr()", get = HotSpotVMValue.Type.ADDRESS) @Stable public long heapTopAddress; @HotSpotVMField(name = "Thread::_allocated_bytes", type = "jlong", get = HotSpotVMField.Type.OFFSET) @Stable public int threadAllocatedBytesOffset; @HotSpotVMFlag(name = "TLABWasteIncrement") @Stable public int tlabRefillWasteIncrement; - @Stable public int tlabAlignmentReserve; + @HotSpotVMValue(expression = "ThreadLocalAllocBuffer::alignment_reserve()") @Stable public int tlabAlignmentReserve; @HotSpotVMField(name = "ThreadLocalAllocBuffer::_start", type = "HeapWord*", get = HotSpotVMField.Type.OFFSET) @Stable private int threadLocalAllocBufferStartOffset; @HotSpotVMField(name = "ThreadLocalAllocBuffer::_end", type = "HeapWord*", get = HotSpotVMField.Type.OFFSET) @Stable private int threadLocalAllocBufferEndOffset; @@ -1304,7 +1308,7 @@ } @HotSpotVMFlag(name = "TLABStats") @Stable public boolean tlabStats; - @Stable public boolean inlineContiguousAllocationSupported; + @HotSpotVMValue(expression = " !CMSIncrementalMode && Universe::heap()->supports_inline_contig_alloc()") @Stable public boolean inlineContiguousAllocationSupported; /** * The DataLayout header size is the same as the cell size. @@ -1396,41 +1400,43 @@ @HotSpotVMField(name = "StubRoutines::_unsafe_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long unsafeArraycopy; @HotSpotVMField(name = "StubRoutines::_generic_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long genericArraycopy; - @Stable public long newInstanceAddress; - @Stable public long newArrayAddress; - @Stable public long newMultiArrayAddress; - @Stable public long dynamicNewArrayAddress; - @Stable public long dynamicNewInstanceAddress; - @Stable public long registerFinalizerAddress; - @Stable public long threadIsInterruptedAddress; - @Stable public long vmMessageAddress; - @Stable public long identityHashCodeAddress; - @Stable public long exceptionHandlerForPcAddress; - @Stable public long exceptionHandlerForReturnAddressAddress; - @Stable public long osrMigrationEndAddress; - @Stable public long monitorenterAddress; - @Stable public long monitorexitAddress; - @Stable public long createNullPointerExceptionAddress; - @Stable public long createOutOfBoundsExceptionAddress; - @Stable public long logPrimitiveAddress; - @Stable public long logObjectAddress; - @Stable public long logPrintfAddress; - @Stable public long vmErrorAddress; - @Stable public long writeBarrierPreAddress; - @Stable public long writeBarrierPostAddress; - @Stable public long validateObject; - @Stable public long javaTimeMillisAddress; - @Stable public long javaTimeNanosAddress; - @Stable public long arithmeticSinAddress; - @Stable public long arithmeticCosAddress; - @Stable public long arithmeticTanAddress; - @Stable public long loadAndClearExceptionAddress; + @HotSpotVMValue(expression = "GraalRuntime::new_instance", get = HotSpotVMValue.Type.ADDRESS) @Stable public long newInstanceAddress; + @HotSpotVMValue(expression = "GraalRuntime::new_array", get = HotSpotVMValue.Type.ADDRESS) @Stable public long newArrayAddress; + @HotSpotVMValue(expression = "GraalRuntime::new_multi_array", get = HotSpotVMValue.Type.ADDRESS) @Stable public long newMultiArrayAddress; + @HotSpotVMValue(expression = "GraalRuntime::dynamic_new_array", get = HotSpotVMValue.Type.ADDRESS) @Stable public long dynamicNewArrayAddress; + @HotSpotVMValue(expression = "GraalRuntime::dynamic_new_instance", get = HotSpotVMValue.Type.ADDRESS) @Stable public long dynamicNewInstanceAddress; + @HotSpotVMValue(expression = "GraalRuntime::thread_is_interrupted", get = HotSpotVMValue.Type.ADDRESS) @Stable public long threadIsInterruptedAddress; + @HotSpotVMValue(expression = "GraalRuntime::vm_message", get = HotSpotVMValue.Type.ADDRESS) @Stable public long vmMessageAddress; + @HotSpotVMValue(expression = "GraalRuntime::identity_hash_code", get = HotSpotVMValue.Type.ADDRESS) @Stable public long identityHashCodeAddress; + @HotSpotVMValue(expression = "GraalRuntime::exception_handler_for_pc", get = HotSpotVMValue.Type.ADDRESS) @Stable public long exceptionHandlerForPcAddress; + @HotSpotVMValue(expression = "GraalRuntime::monitorenter", get = HotSpotVMValue.Type.ADDRESS) @Stable public long monitorenterAddress; + @HotSpotVMValue(expression = "GraalRuntime::monitorexit", get = HotSpotVMValue.Type.ADDRESS) @Stable public long monitorexitAddress; + @HotSpotVMValue(expression = "GraalRuntime::create_null_exception", get = HotSpotVMValue.Type.ADDRESS) @Stable public long createNullPointerExceptionAddress; + @HotSpotVMValue(expression = "GraalRuntime::create_out_of_bounds_exception", get = HotSpotVMValue.Type.ADDRESS) @Stable public long createOutOfBoundsExceptionAddress; + @HotSpotVMValue(expression = "GraalRuntime::log_primitive", get = HotSpotVMValue.Type.ADDRESS) @Stable public long logPrimitiveAddress; + @HotSpotVMValue(expression = "GraalRuntime::log_object", get = HotSpotVMValue.Type.ADDRESS) @Stable public long logObjectAddress; + @HotSpotVMValue(expression = "GraalRuntime::log_printf", get = HotSpotVMValue.Type.ADDRESS) @Stable public long logPrintfAddress; + @HotSpotVMValue(expression = "GraalRuntime::vm_error", get = HotSpotVMValue.Type.ADDRESS) @Stable public long vmErrorAddress; + @HotSpotVMValue(expression = "GraalRuntime::load_and_clear_exception", get = HotSpotVMValue.Type.ADDRESS) @Stable public long loadAndClearExceptionAddress; + @HotSpotVMValue(expression = "GraalRuntime::write_barrier_pre", get = HotSpotVMValue.Type.ADDRESS) @Stable public long writeBarrierPreAddress; + @HotSpotVMValue(expression = "GraalRuntime::write_barrier_post", get = HotSpotVMValue.Type.ADDRESS) @Stable public long writeBarrierPostAddress; + @HotSpotVMValue(expression = "GraalRuntime::validate_object", get = HotSpotVMValue.Type.ADDRESS) @Stable public long validateObject; - @Stable public int graalCountersSize; + @HotSpotVMValue(expression = "SharedRuntime::register_finalizer", get = HotSpotVMValue.Type.ADDRESS) @Stable public long registerFinalizerAddress; + @HotSpotVMValue(expression = "SharedRuntime::exception_handler_for_return_address", get = HotSpotVMValue.Type.ADDRESS) @Stable public long exceptionHandlerForReturnAddressAddress; + @HotSpotVMValue(expression = "SharedRuntime::OSR_migration_end", get = HotSpotVMValue.Type.ADDRESS) @Stable public long osrMigrationEndAddress; - @Stable public long deoptimizationFetchUnrollInfo; - @Stable public long deoptimizationUncommonTrap; - @Stable public long deoptimizationUnpackFrames; + @HotSpotVMValue(expression = "os::javaTimeMillis", get = HotSpotVMValue.Type.ADDRESS) @Stable public long javaTimeMillisAddress; + @HotSpotVMValue(expression = "os::javaTimeNanos", get = HotSpotVMValue.Type.ADDRESS) @Stable public long javaTimeNanosAddress; + @HotSpotVMValue(expression = "SharedRuntime::dsin", get = HotSpotVMValue.Type.ADDRESS) @Stable public long arithmeticSinAddress; + @HotSpotVMValue(expression = "SharedRuntime::dcos", get = HotSpotVMValue.Type.ADDRESS) @Stable public long arithmeticCosAddress; + @HotSpotVMValue(expression = "SharedRuntime::dtan", get = HotSpotVMValue.Type.ADDRESS) @Stable public long arithmeticTanAddress; + + @HotSpotVMValue(expression = "(jint) GraalCounterSize") @Stable public int graalCountersSize; + + @HotSpotVMValue(expression = "Deoptimization::fetch_unroll_info", get = HotSpotVMValue.Type.ADDRESS) @Stable public long deoptimizationFetchUnrollInfo; + @HotSpotVMValue(expression = "Deoptimization::uncommon_trap", get = HotSpotVMValue.Type.ADDRESS) @Stable public long deoptimizationUncommonTrap; + @HotSpotVMValue(expression = "Deoptimization::unpack_frames", get = HotSpotVMValue.Type.ADDRESS) @Stable public long deoptimizationUnpackFrames; @HotSpotVMConstant(name = "Deoptimization::Reason_none") @Stable public int deoptReasonNone; @HotSpotVMConstant(name = "Deoptimization::Reason_null_check") @Stable public int deoptReasonNullCheck; diff -r bde6fbdbbe38 -r dffc37fa7157 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConstant.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConstant.java Tue May 20 21:38:31 2014 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.graal.hotspot; - -import java.lang.annotation.*; - -/** - * Refers to a C++ constant in the VM. - */ -@Target(ElementType.FIELD) -@Retention(RetentionPolicy.RUNTIME) -public @interface HotSpotVMConstant { - - /** - * Returns the name of the constant. - * - * @return name of constant - */ - String name(); - - /** - * List of architectures where this constant is required. Names are derived from - * {@link HotSpotVMConfig#getHostArchitectureName()}. An empty list implies that the constant is - * required on all architectures. - */ - String[] archs() default {}; - -} diff -r bde6fbdbbe38 -r dffc37fa7157 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMField.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMField.java Tue May 20 21:38:31 2014 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.graal.hotspot; - -import java.lang.annotation.*; - -/** - * Refers to a C++ field in the VM. - */ -@Target(ElementType.FIELD) -@Retention(RetentionPolicy.RUNTIME) -public @interface HotSpotVMField { - - /** - * Types of information this annotation can return. - */ - enum Type { - /** - * Returns the offset of this field within the type. Only valid for instance fields. - */ - OFFSET, - - /** - * Returns the absolute address of this field. Only valid for static fields. - */ - ADDRESS, - - /** - * Returns the value of this field. Only valid for static fields. - */ - VALUE; - } - - /** - * Specifies what type of information to return. - * - * @see Type - */ - Type get(); - - /** - * Returns the type name containing this field. - * - * @return name of containing type - */ - String type(); - - /** - * Returns the name of this field. - * - * @return name of field - */ - String name(); - - /** - * List of architectures where this constant is required. Names are derived from - * {@link HotSpotVMConfig#getHostArchitectureName()}. An empty list implies that the constant is - * required on all architectures. - */ - String[] archs() default {}; - - boolean optional() default false; -} diff -r bde6fbdbbe38 -r dffc37fa7157 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMFlag.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMFlag.java Tue May 20 21:38:31 2014 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.graal.hotspot; - -import java.lang.annotation.*; - -/** - * Refers to a C++ flag in the VM. - */ -@Target(ElementType.FIELD) -@Retention(RetentionPolicy.RUNTIME) -public @interface HotSpotVMFlag { - - /** - * Returns the name of this flag. - * - * @return name of flag. - */ - String name(); - - /** - * List of architectures where this constant is required. Names are derived from - * {@link HotSpotVMConfig#getHostArchitectureName()}. An empty list implies that the constant is - * required on all architectures. - */ - String[] archs() default {}; - - boolean optional() default false; -} diff -r bde6fbdbbe38 -r dffc37fa7157 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMType.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMType.java Tue May 20 21:38:31 2014 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.graal.hotspot; - -import java.lang.annotation.*; - -/** - * Refers to a C++ type in the VM. - */ -@Target(ElementType.FIELD) -@Retention(RetentionPolicy.RUNTIME) -public @interface HotSpotVMType { - - /** - * Types of information this annotation can return. - */ - enum Type { - /** - * Returns the size of the type (C++ {@code sizeof()}). - */ - SIZE; - } - - /** - * Specifies what type of information to return. - * - * @see Type - */ - Type get(); - - /** - * Returns the name of the type. - * - * @return name of type - */ - String name(); -} diff -r bde6fbdbbe38 -r dffc37fa7157 graal/com.oracle.graal.hotspotvmconfig/src/META-INF/services/javax.annotation.processing.Processor --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspotvmconfig/src/META-INF/services/javax.annotation.processing.Processor Tue May 20 13:46:34 2014 -0700 @@ -0,0 +1,1 @@ +com.oracle.graal.hotspotvmconfig.HotSpotVMConfigProcessor diff -r bde6fbdbbe38 -r dffc37fa7157 graal/com.oracle.graal.hotspotvmconfig/src/com/oracle/graal/hotspotvmconfig/HotSpotVMConfigProcessor.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspotvmconfig/src/com/oracle/graal/hotspotvmconfig/HotSpotVMConfigProcessor.java Tue May 20 13:46:34 2014 -0700 @@ -0,0 +1,418 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.hotspotvmconfig; + +import java.io.*; +import java.lang.annotation.*; +import java.util.*; +import java.util.Map.Entry; + +import javax.annotation.processing.*; +import javax.lang.model.*; +import javax.lang.model.element.*; +import javax.tools.Diagnostic.Kind; +import javax.tools.*; + +import com.oracle.graal.compiler.common.*; + +@SupportedAnnotationTypes({"com.oracle.graal.hotspotvmconfig.HotSpotVMConstant", "com.oracle.graal.hotspotvmconfig.HotSpotVMFlag", "com.oracle.graal.hotspotvmconfig.HotSpotVMField", + "com.oracle.graal.hotspotvmconfig.HotSpotVMType", "com.oracle.graal.hotspotvmconfig.HotSpotVMValue"}) +public class HotSpotVMConfigProcessor extends AbstractProcessor { + + public HotSpotVMConfigProcessor() { + } + + @Override + public SourceVersion getSupportedSourceVersion() { + return SourceVersion.latest(); + } + + /** + * Set to true to enable logging to a local file during annotation processing. There's no normal + * channel for any debug messages and debugging annotation processors requires some special + * setup. + */ + private static final boolean DEBUG = true; + + private static final String LOGFILE = "/tmp/hotspotvmconfigprocessor.log"; + + private static PrintWriter log; + + /** + * Logging facility for the debugging the annotation processor. + */ + + private static synchronized PrintWriter getLog() { + if (log == null) { + try { + log = new PrintWriter(new FileWriter(LOGFILE, true)); + } catch (IOException e) { + // Do nothing + } + } + return log; + } + + private static synchronized void logMessage(String format, Object... args) { + if (!DEBUG) { + return; + } + PrintWriter bw = getLog(); + if (bw != null) { + bw.printf(format, args); + bw.flush(); + } + } + + private static synchronized void logException(Throwable t) { + if (!DEBUG) { + return; + } + PrintWriter bw = getLog(); + if (bw != null) { + t.printStackTrace(bw); + bw.flush(); + } + } + + /** + * Bugs in an annotation processor can cause silent failure so try to report any exception + * throws as errors. + */ + private void reportExceptionThrow(Element element, Throwable t) { + if (element != null) { + logMessage("throw for %s:\n", element); + } + logException(t); + processingEnv.getMessager().printMessage(Kind.ERROR, "Exception throw during processing: " + t.toString() + " " + Arrays.toString(Arrays.copyOf(t.getStackTrace(), 8)), element); + } + + //@formatter:off + String[] prologue = new String[]{ + "// The normal wrappers boolAt and intxAt skip constant flags", + "static bool boolAt(char* name, bool* value) {", + " Flag* result = Flag::find_flag(name, strlen(name), true, true);", + " if (result == NULL) return false;", + " if (!result->is_bool()) return false;", + " *value = result->get_bool();", + " return true;", + "}", + "", + "static bool intxAt(char* name, intx* value) {", + " Flag* result = Flag::find_flag(name, strlen(name), true, true);", + " if (result == NULL) return false;", + " if (!result->is_intx()) return false;", + " *value = result->get_intx();", + " return true;", + "}", + "", + "#define set_boolean(name, value) vmconfig_oop->bool_field_put(fs.offset(), value)", + "#define set_int(name, value) vmconfig_oop->int_field_put(fs.offset(), (int)value)", + "#define set_long(name, value) vmconfig_oop->long_field_put(fs.offset(), value)", + "#define set_address(name, value) do { set_long(name, (jlong) value); } while (0)", + "", + "#define set_optional_boolean_flag(varName, flagName) do { bool flagValue; if (boolAt((char*) flagName, &flagValue)) { set_boolean(varName, flagValue); } } while (0)", + "#define set_optional_int_flag(varName, flagName) do { intx flagValue; if (intxAt((char*) flagName, &flagValue)) { set_int(varName, flagValue); } } while (0)", + "#define set_optional_long_flag(varName, flagName) do { intx flagValue; if (intxAt((char*) flagName, &flagValue)) { set_long(varName, flagValue); } } while (0)", + "", + "void VMStructs::initHotSpotVMConfig(JNIEnv *env, jobject config) {", + " oop vmconfig_oop = JNIHandles::resolve(config);", + " InstanceKlass* vmconfig_klass = InstanceKlass::cast(vmconfig_oop->klass());", + "", + " for (JavaFieldStream fs(vmconfig_klass); !fs.done(); fs.next()) {", + }; + //@formatter:on + + String outputName = "HotSpotVMConfig.inline.hpp"; + String outputDirectory = "hotspot"; + + private void createFiles(Map annotations, Element element) { + + Filer filer = processingEnv.getFiler(); + try (PrintWriter out = createSourceFile(outputDirectory, outputName, filer, element)) { + + for (String line : prologue) { + out.println(line); + } + + out.println(); + + Set fieldTypes = new HashSet<>(); + for (String key : annotations.keySet()) { + fieldTypes.add(annotations.get(key).getType()); + } + // For each type of field, generate a switch on the length of the symbol and then do a + // direct compare. In general this reduces each operation to 2 tests plus a string + // compare. Being more prefect than that is probably not worth it. + for (String type : fieldTypes) { + String sigtype = type.equals("boolean") ? "bool" : type; + out.println(" if (fs.signature() == vmSymbols::" + sigtype + "_signature()) {"); + Set lengths = new HashSet<>(); + for (Entry entry : annotations.entrySet()) { + if (entry.getValue().getType().equals(type)) { + lengths.add(entry.getKey().length()); + } + } + out.println(" switch (fs.name()->utf8_length()) {"); + for (int len : lengths) { + out.println(" case " + len + ":"); + for (Entry entry : annotations.entrySet()) { + if (entry.getValue().getType().equals(type) && entry.getKey().length() == len) { + out.println(" if (fs.name()->equals(\"" + entry.getKey() + "\")) {"); + entry.getValue().emit(out); + out.println(" continue;"); + out.println(" }"); + } + } + out.println(" continue;"); + } + out.println(" } // switch"); + out.println(" continue;"); + out.println(" } // if"); + } + out.println(" } // for"); + out.println("}"); + } + } + + protected PrintWriter createSourceFile(String pkg, String relativeName, Filer filer, Element... originatingElements) { + try { + // Ensure Unix line endings to comply with Graal code style guide checked by Checkstyle + FileObject sourceFile = filer.createResource(StandardLocation.SOURCE_OUTPUT, pkg, relativeName, originatingElements); + logMessage("%s\n", sourceFile); + return new PrintWriter(sourceFile.openWriter()) { + + @Override + public void println() { + print("\n"); + } + }; + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + class VMConfigField { + final VariableElement field; + final Annotation annotation; + + public VMConfigField(VariableElement field, Annotation value) { + super(); + this.field = field; + this.annotation = value; + } + + public String getType() { + return field.asType().toString(); + } + + private String archDefine(String arch) { + switch (arch) { + case "amd64": + return "defined(AMD64)"; + case "sparcv9": + return "(defined(SPARC) && defined(_LP64))"; + case "sparc": + return "defined(SPARC)"; + default: + throw new GraalInternalError("unexpected arch: " + arch); + } + } + + private String archDefines(String[] archs) { + if (archs.length == 0) { + return null; + } + if (archs.length == 1) { + return archDefine(archs[0]); + } + String[] defs = new String[archs.length]; + int i = 0; + for (String arch : archs) { + defs[i++] = archDefine(arch); + } + return String.join(" ||", defs); + } + + public void emit(PrintWriter out) { + if (annotation instanceof HotSpotVMField) { + emitField(out, (HotSpotVMField) annotation); + } else if (annotation instanceof HotSpotVMType) { + emitType(out, (HotSpotVMType) annotation); + } else if (annotation instanceof HotSpotVMFlag) { + emitFlag(out, (HotSpotVMFlag) annotation); + } else if (annotation instanceof HotSpotVMConstant) { + emitConstant(out, (HotSpotVMConstant) annotation); + } else if (annotation instanceof HotSpotVMValue) { + emitValue(out, (HotSpotVMValue) annotation); + } else { + throw new InternalError(annotation.toString()); + } + + } + + private void emitField(PrintWriter out, HotSpotVMField value) { + String type = field.asType().toString(); + String define = archDefines(value.archs()); + if (define != null) { + out.printf("#if %s\n", define); + } + + String name = value.name(); + int i = name.lastIndexOf("::"); + switch (value.get()) { + case OFFSET: + out.printf(" set_%s(\"%s\", offset_of(%s, %s));\n", type, field.getSimpleName(), name.substring(0, i), name.substring(i + 2)); + break; + case ADDRESS: + out.printf(" set_address(\"%s\", &%s);\n", field.getSimpleName(), name); + break; + case VALUE: + out.printf(" set_%s(\"%s\", (%s) (intptr_t) %s);\n", type, field.getSimpleName(), type, name); + break; + } + if (define != null) { + out.printf("#endif\n"); + } + } + + private void emitType(PrintWriter out, HotSpotVMType value) { + String type = field.asType().toString(); + out.printf(" set_%s(\"%s\", sizeof(%s));\n", type, field.getSimpleName(), value.name()); + } + + private void emitValue(PrintWriter out, HotSpotVMValue value) { + String type = field.asType().toString(); + int length = value.defines().length; + if (length != 0) { + out.printf("#if "); + for (int i = 0; i < length; i++) { + out.printf("defined(%s)", value.defines()[i]); + if (i + 1 < length) { + out.printf(" || "); + } + } + out.println(); + } + if (value.get() == HotSpotVMValue.Type.ADDRESS) { + out.printf(" set_address(\"%s\", %s);\n", field.getSimpleName(), value.expression()); + } else { + out.printf(" set_%s(\"%s\", %s);\n", type, field.getSimpleName(), value.expression()); + } + if (length != 0) { + out.println("#endif"); + } + } + + private void emitConstant(PrintWriter out, HotSpotVMConstant value) { + String define = archDefines(value.archs()); + if (define != null) { + out.printf("#if %s\n", define); + } + String type = field.asType().toString(); + out.printf(" set_%s(\"%s\", %s);\n", type, field.getSimpleName(), value.name()); + if (define != null) { + out.printf("#endif\n"); + } + } + + private void emitFlag(PrintWriter out, HotSpotVMFlag value) { + String type = field.asType().toString(); + + String define = archDefines(value.archs()); + if (define != null) { + out.printf("#if %s\n", define); + } + if (value.optional()) { + out.printf(" set_optional_%s_flag(\"%s\", \"%s\");\n", type, field.getSimpleName(), value.name()); + } else { + out.printf(" set_%s(\"%s\", %s);\n", type, field.getSimpleName(), value.name()); + } + if (define != null) { + out.printf("#endif\n"); + } + } + + } + + private void collectAnnotations(RoundEnvironment roundEnv, Map annotationMap, Class annotationClass) { + for (Element element : roundEnv.getElementsAnnotatedWith(annotationClass)) { + Annotation constant = element.getAnnotation(annotationClass); + if (element.getKind() != ElementKind.FIELD) { + errorMessage(element, "%s annotations may only be on fields", annotationClass.getSimpleName()); + } + if (annotationClass == HotSpotVMValue.class) { + HotSpotVMValue value = (HotSpotVMValue) constant; + if (value.get() == HotSpotVMValue.Type.ADDRESS && !element.asType().toString().equals("long")) { + errorMessage(element, "HotSpotVMValue with get == ADDRESS must be of type long, but found %s", element.asType()); + } + } + if (currentTypeElement == null) { + currentTypeElement = element.getEnclosingElement(); + } else { + if (!currentTypeElement.equals(element.getEnclosingElement())) { + errorMessage(element, "Multiple types encountered. Only HotSpotVMConfig is supported"); + } + } + annotationMap.put(element.getSimpleName().toString(), new VMConfigField((VariableElement) element, constant)); + } + } + + private void errorMessage(Element element, String format, Object... args) { + processingEnv.getMessager().printMessage(Kind.ERROR, String.format(format, args), element); + } + + Element currentTypeElement = null; + + @Override + public boolean process(Set annotations, RoundEnvironment roundEnv) { + if (roundEnv.processingOver()) { + return true; + } + logMessage("Starting round %s %s\n", roundEnv, annotations); + try { + + currentTypeElement = null; + + // First collect all the annotations. + Map annotationMap = new HashMap<>(); + collectAnnotations(roundEnv, annotationMap, HotSpotVMConstant.class); + collectAnnotations(roundEnv, annotationMap, HotSpotVMFlag.class); + collectAnnotations(roundEnv, annotationMap, HotSpotVMField.class); + collectAnnotations(roundEnv, annotationMap, HotSpotVMType.class); + collectAnnotations(roundEnv, annotationMap, HotSpotVMValue.class); + + if (annotationMap.isEmpty()) { + return true; + } + + logMessage("type element %s\n", currentTypeElement); + createFiles(annotationMap, currentTypeElement); + + } catch (Throwable t) { + reportExceptionThrow(null, t); + } + + return true; + } +} diff -r bde6fbdbbe38 -r dffc37fa7157 graal/com.oracle.graal.hotspotvmconfig/src/com/oracle/graal/hotspotvmconfig/HotSpotVMConstant.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspotvmconfig/src/com/oracle/graal/hotspotvmconfig/HotSpotVMConstant.java Tue May 20 13:46:34 2014 -0700 @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.hotspotvmconfig; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Refers to a C++ constant in the VM. + */ +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +public @interface HotSpotVMConstant { + + /** + * Returns the name of the constant. + * + * @return name of constant + */ + String name(); + + /** + * List of architectures where this constant is required. Names are derived from + * {@link HotSpotVMConfig#getHostArchitectureName()}. An empty list implies that the constant is + * required on all architectures. + */ + @SuppressWarnings("javadoc") + String[] archs() default {}; + +} diff -r bde6fbdbbe38 -r dffc37fa7157 graal/com.oracle.graal.hotspotvmconfig/src/com/oracle/graal/hotspotvmconfig/HotSpotVMField.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspotvmconfig/src/com/oracle/graal/hotspotvmconfig/HotSpotVMField.java Tue May 20 13:46:34 2014 -0700 @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.hotspotvmconfig; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Refers to a C++ field in the VM. + */ +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +public @interface HotSpotVMField { + + /** + * Types of information this annotation can return. + */ + enum Type { + /** + * Returns the offset of this field within the type. Only valid for instance fields. + */ + OFFSET, + + /** + * Returns the absolute address of this field. Only valid for static fields. + */ + ADDRESS, + + /** + * Returns the value of this field. Only valid for static fields. + */ + VALUE; + } + + /** + * Specifies what type of information to return. + * + * @see Type + */ + Type get(); + + /** + * Returns the type name containing this field. + * + * @return name of containing type + */ + String type(); + + /** + * Returns the name of this field. + * + * @return name of field + */ + String name(); + + /** + * List of architectures where this constant is required. Names are derived from + * {@link HotSpotVMConfig#getHostArchitectureName()}. An empty list implies that the constant is + * required on all architectures. + */ + @SuppressWarnings("javadoc") + String[] archs() default {}; +} diff -r bde6fbdbbe38 -r dffc37fa7157 graal/com.oracle.graal.hotspotvmconfig/src/com/oracle/graal/hotspotvmconfig/HotSpotVMFlag.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspotvmconfig/src/com/oracle/graal/hotspotvmconfig/HotSpotVMFlag.java Tue May 20 13:46:34 2014 -0700 @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.hotspotvmconfig; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Refers to a C++ flag in the VM. + */ +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +public @interface HotSpotVMFlag { + + /** + * Returns the name of this flag. + * + * @return name of flag. + */ + String name(); + + /** + * List of architectures where this constant is required. Names are derived from + * {@link HotSpotVMConfig#getHostArchitectureName()}. An empty list implies that the constant is + * required on all architectures. + */ + @SuppressWarnings("javadoc") + String[] archs() default {}; + + boolean optional() default false; +} diff -r bde6fbdbbe38 -r dffc37fa7157 graal/com.oracle.graal.hotspotvmconfig/src/com/oracle/graal/hotspotvmconfig/HotSpotVMType.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspotvmconfig/src/com/oracle/graal/hotspotvmconfig/HotSpotVMType.java Tue May 20 13:46:34 2014 -0700 @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.hotspotvmconfig; + +import java.lang.annotation.*; + +/** + * Refers to a C++ type in the VM. + */ +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +public @interface HotSpotVMType { + + /** + * Types of information this annotation can return. + */ + enum Type { + /** + * Returns the size of the type (C++ {@code sizeof()}). + */ + SIZE; + } + + /** + * Specifies what type of information to return. + * + * @see Type + */ + Type get(); + + /** + * Returns the name of the type. + * + * @return name of type + */ + String name(); +} diff -r bde6fbdbbe38 -r dffc37fa7157 graal/com.oracle.graal.hotspotvmconfig/src/com/oracle/graal/hotspotvmconfig/HotSpotVMValue.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspotvmconfig/src/com/oracle/graal/hotspotvmconfig/HotSpotVMValue.java Tue May 20 13:46:34 2014 -0700 @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.hotspotvmconfig; + +import java.lang.annotation.*; + +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +public @interface HotSpotVMValue { + + /** + * A C++ expression to be evaluated and assigned to the field. + */ + String expression(); + + enum Type { + /** + * A C++ address which might require extra casts to be safely assigned to a Java field. + */ + ADDRESS, + + /** + * A simple value which can be assigned to a regular Java field. + */ + VALUE + } + + Type get() default Type.VALUE; + + /** + * List of preprocessor symbols that should guard initialization of this value. + */ + String[] defines() default {}; + +} diff -r bde6fbdbbe38 -r dffc37fa7157 make/bsd/makefiles/vm.make --- a/make/bsd/makefiles/vm.make Tue May 20 21:38:31 2014 +0200 +++ b/make/bsd/makefiles/vm.make Tue May 20 13:46:34 2014 -0700 @@ -229,6 +229,7 @@ else GRAAL_SPECIFIC_FILES := GRAAL_SPECIFIC_GPU_FILES := + Src_Dirs_I += $(HS_COMMON_SRC)/../graal/com.oracle.graal.hotspot/src_gen/hotspot endif # Always exclude these. diff -r bde6fbdbbe38 -r dffc37fa7157 make/linux/makefiles/vm.make --- a/make/linux/makefiles/vm.make Tue May 20 21:38:31 2014 +0200 +++ b/make/linux/makefiles/vm.make Tue May 20 13:46:34 2014 -0700 @@ -211,6 +211,7 @@ else GRAAL_SPECIFIC_FILES := GRAAL_SPECIFIC_GPU_FILES := + Src_Dirs_I += $(HS_COMMON_SRC)/../graal/com.oracle.graal.hotspot/src_gen/hotspot endif # Always exclude these. diff -r bde6fbdbbe38 -r dffc37fa7157 make/solaris/makefiles/vm.make --- a/make/solaris/makefiles/vm.make Tue May 20 21:38:31 2014 +0200 +++ b/make/solaris/makefiles/vm.make Tue May 20 13:46:34 2014 -0700 @@ -229,6 +229,7 @@ else GRAAL_SPECIFIC_FILES := GRAAL_SPECIFIC_GPU_FILES := + Src_Dirs_I += $(HS_COMMON_SRC)/../graal/com.oracle.graal.hotspot/src_gen/hotspot endif # Always exclude these. diff -r bde6fbdbbe38 -r dffc37fa7157 make/windows/makefiles/projectcreator.make --- a/make/windows/makefiles/projectcreator.make Tue May 20 21:38:31 2014 +0200 +++ b/make/windows/makefiles/projectcreator.make Tue May 20 13:46:34 2014 -0700 @@ -57,6 +57,7 @@ -relativeInclude src\os_cpu\windows_$(Platform_arch)\vm \ -relativeInclude src\cpu\$(Platform_arch)\vm \ -relativeInclude src\gpu \ + -relativeInclude graal\com.oracle.graal.hotspot\src_gen\hotspot \ -absoluteInclude $(HOTSPOTBUILDSPACE)/%f/generated \ -relativeSrcInclude src \ -absoluteSrcInclude $(HOTSPOTBUILDSPACE) \ @@ -151,7 +152,7 @@ ProjectCreatorIDEOptionsIgnoreGraal=\ -ignorePath_TARGET src/share/vm/graal \ - -ignorePath_TARGET graal/generated \ + -ignorePath_TARGET graal\com.oracle.graal.hotspot\src_gen\hotspot \ -ignorePath_TARGET vm/graal ProjectCreatorIDEOptionsIgnoreCompiler2=\ @@ -175,7 +176,6 @@ ProjectCreatorIDEOptions=$(ProjectCreatorIDEOptions) \ -define_compiler1 COMPILER1 \ -define_compiler1 GRAAL \ - -ignorePath_compiler1 graal/generated \ $(ProjectCreatorIDEOptionsIgnoreCompiler2:TARGET=compiler1) ################################################## @@ -195,7 +195,6 @@ -define_compiler2 COMPILER1 \ -define_compiler2 COMPILER2 \ -define_compiler2 GRAAL \ - -ignorePath_compiler2 graal/generated \ -additionalFile_compiler2 $(Platform_arch_model).ad \ -additionalFile_compiler2 ad_$(Platform_arch_model).cpp \ -additionalFile_compiler2 ad_$(Platform_arch_model).hpp \ diff -r bde6fbdbbe38 -r dffc37fa7157 mx/mx_graal.py --- a/mx/mx_graal.py Tue May 20 21:38:31 2014 +0200 +++ b/mx/mx_graal.py Tue May 20 13:46:34 2014 -0700 @@ -690,7 +690,7 @@ mustBuild = False timestamp = os.path.getmtime(timestampFile) sources = [] - for d in ['src', 'make']: + for d in ['src', 'make', 'graal/com.oracle.graal.hotspot/src_gen/hotspot']: for root, dirnames, files in os.walk(join(_graal_home, d)): # ignore /src/share/tools if root == join(_graal_home, 'src', 'share'): diff -r bde6fbdbbe38 -r dffc37fa7157 mx/projects --- a/mx/projects Tue May 20 21:38:31 2014 +0200 +++ b/mx/projects Tue May 20 13:46:34 2014 -0700 @@ -182,10 +182,20 @@ project@com.oracle.graal.sparc@javaCompliance=1.8 project@com.oracle.graal.sparc@workingSets=Graal,SPARC +# graal.hotspotvmconfig +project@com.oracle.graal.hotspotvmconfig@subDir=graal +project@com.oracle.graal.hotspotvmconfig@sourceDirs=src +project@com.oracle.graal.hotspotvmconfig@dependencies=com.oracle.graal.compiler.common +project@com.oracle.graal.hotspotvmconfig@checkstyle=com.oracle.graal.graph +project@com.oracle.graal.hotspotvmconfig@annotationProcessors=com.oracle.graal.service.processor +project@com.oracle.graal.hotspotvmconfig@annotationProcessorForDependents=true +project@com.oracle.graal.hotspotvmconfig@javaCompliance=1.8 +project@com.oracle.graal.hotspotvmconfig@workingSets=Graal,HotSpot + # graal.hotspot project@com.oracle.graal.hotspot@subDir=graal project@com.oracle.graal.hotspot@sourceDirs=src -project@com.oracle.graal.hotspot@dependencies=com.oracle.graal.replacements,com.oracle.graal.runtime,com.oracle.graal.printer,com.oracle.graal.baseline +project@com.oracle.graal.hotspot@dependencies=com.oracle.graal.replacements,com.oracle.graal.runtime,com.oracle.graal.printer,com.oracle.graal.baseline,com.oracle.graal.hotspotvmconfig project@com.oracle.graal.hotspot@checkstyle=com.oracle.graal.graph project@com.oracle.graal.hotspot@annotationProcessors=com.oracle.graal.replacements.verifier,com.oracle.graal.service.processor project@com.oracle.graal.hotspot@javaCompliance=1.8 diff -r bde6fbdbbe38 -r dffc37fa7157 src/share/vm/graal/graalCompilerToVM.cpp --- a/src/share/vm/graal/graalCompilerToVM.cpp Tue May 20 21:38:31 2014 +0200 +++ b/src/share/vm/graal/graalCompilerToVM.cpp Tue May 20 13:46:34 2014 -0700 @@ -91,125 +91,8 @@ extern uint64_t gHotSpotVMLongConstantEntryArrayStride; } -// helpers used to set fields in the HotSpotVMConfig object -static jfieldID getFieldID(JNIEnv* env, jobject obj, const char* name, const char* sig) { - jfieldID id = env->GetFieldID(env->GetObjectClass(obj), name, sig); - if (id == NULL) { - fatal(err_msg("field not found: %s (%s)", name, sig)); - } - return id; -} - -C2V_ENTRY(void, initializeConfiguration, (JNIEnv *env, jobject, jobject config)) - -#define set_boolean(name, value) do { env->SetBooleanField(config, getFieldID(env, config, name, "Z"), value); } while (0) -#define set_int(name, value) do { env->SetIntField(config, getFieldID(env, config, name, "I"), value); } while (0) -#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) - - guarantee(HeapWordSize == sizeof(char*), "Graal assumption that HeadWordSize == machine word size is wrong"); - - set_address("gHotSpotVMStructs", gHotSpotVMStructs); - set_long("gHotSpotVMStructEntryTypeNameOffset", gHotSpotVMStructEntryTypeNameOffset); - set_long("gHotSpotVMStructEntryFieldNameOffset", gHotSpotVMStructEntryFieldNameOffset); - set_long("gHotSpotVMStructEntryTypeStringOffset", gHotSpotVMStructEntryTypeStringOffset); - set_long("gHotSpotVMStructEntryIsStaticOffset", gHotSpotVMStructEntryIsStaticOffset); - set_long("gHotSpotVMStructEntryOffsetOffset", gHotSpotVMStructEntryOffsetOffset); - set_long("gHotSpotVMStructEntryAddressOffset", gHotSpotVMStructEntryAddressOffset); - set_long("gHotSpotVMStructEntryArrayStride", gHotSpotVMStructEntryArrayStride); - - set_address("gHotSpotVMTypes", gHotSpotVMTypes); - set_long("gHotSpotVMTypeEntryTypeNameOffset", gHotSpotVMTypeEntryTypeNameOffset); - set_long("gHotSpotVMTypeEntrySuperclassNameOffset", gHotSpotVMTypeEntrySuperclassNameOffset); - set_long("gHotSpotVMTypeEntryIsOopTypeOffset", gHotSpotVMTypeEntryIsOopTypeOffset); - set_long("gHotSpotVMTypeEntryIsIntegerTypeOffset", gHotSpotVMTypeEntryIsIntegerTypeOffset); - set_long("gHotSpotVMTypeEntryIsUnsignedOffset", gHotSpotVMTypeEntryIsUnsignedOffset); - set_long("gHotSpotVMTypeEntrySizeOffset", gHotSpotVMTypeEntrySizeOffset); - set_long("gHotSpotVMTypeEntryArrayStride", gHotSpotVMTypeEntryArrayStride); - - set_address("gHotSpotVMIntConstants", gHotSpotVMIntConstants); - set_long("gHotSpotVMIntConstantEntryNameOffset", gHotSpotVMIntConstantEntryNameOffset); - set_long("gHotSpotVMIntConstantEntryValueOffset", gHotSpotVMIntConstantEntryValueOffset); - set_long("gHotSpotVMIntConstantEntryArrayStride", gHotSpotVMIntConstantEntryArrayStride); - - set_address("gHotSpotVMLongConstants", gHotSpotVMLongConstants); - set_long("gHotSpotVMLongConstantEntryNameOffset", gHotSpotVMLongConstantEntryNameOffset); - set_long("gHotSpotVMLongConstantEntryValueOffset", gHotSpotVMLongConstantEntryValueOffset); - set_long("gHotSpotVMLongConstantEntryArrayStride", gHotSpotVMLongConstantEntryArrayStride); - - //------------------------------------------------------------------------------------------------ - - set_int("arrayLengthOffset", arrayOopDesc::length_offset_in_bytes()); - - set_int("extraStackEntries", Method::extra_stack_entries()); - - set_int("tlabAlignmentReserve", (int32_t)ThreadLocalAllocBuffer::alignment_reserve()); - set_long("heapTopAddress", (jlong)(address) Universe::heap()->top_addr()); - set_long("heapEndAddress", (jlong)(address) Universe::heap()->end_addr()); - - set_boolean("inlineContiguousAllocationSupported", !CMSIncrementalMode && Universe::heap()->supports_inline_contig_alloc()); - - set_long("verifyOopMask", Universe::verify_oop_mask()); - set_long("verifyOopBits", Universe::verify_oop_bits()); - - set_int("instanceKlassVtableStartOffset", InstanceKlass::vtable_start_offset() * HeapWordSize); - - //------------------------------------------------------------------------------------------------ - - set_address("registerFinalizerAddress", SharedRuntime::register_finalizer); - set_address("exceptionHandlerForReturnAddressAddress", SharedRuntime::exception_handler_for_return_address); - set_address("osrMigrationEndAddress", SharedRuntime::OSR_migration_end); - - set_address("javaTimeMillisAddress", CAST_FROM_FN_PTR(address, os::javaTimeMillis)); - set_address("javaTimeNanosAddress", CAST_FROM_FN_PTR(address, os::javaTimeNanos)); - set_address("arithmeticSinAddress", CAST_FROM_FN_PTR(address, SharedRuntime::dsin)); - set_address("arithmeticCosAddress", CAST_FROM_FN_PTR(address, SharedRuntime::dcos)); - set_address("arithmeticTanAddress", CAST_FROM_FN_PTR(address, SharedRuntime::dtan)); - - set_address("newInstanceAddress", GraalRuntime::new_instance); - set_address("newArrayAddress", GraalRuntime::new_array); - set_address("newMultiArrayAddress", GraalRuntime::new_multi_array); - set_address("dynamicNewArrayAddress", GraalRuntime::dynamic_new_array); - set_address("dynamicNewInstanceAddress", GraalRuntime::dynamic_new_instance); - set_address("threadIsInterruptedAddress", GraalRuntime::thread_is_interrupted); - set_address("vmMessageAddress", GraalRuntime::vm_message); - set_address("identityHashCodeAddress", GraalRuntime::identity_hash_code); - set_address("exceptionHandlerForPcAddress", GraalRuntime::exception_handler_for_pc); - set_address("monitorenterAddress", GraalRuntime::monitorenter); - set_address("monitorexitAddress", GraalRuntime::monitorexit); - set_address("createNullPointerExceptionAddress", GraalRuntime::create_null_exception); - set_address("createOutOfBoundsExceptionAddress", GraalRuntime::create_out_of_bounds_exception); - set_address("logPrimitiveAddress", GraalRuntime::log_primitive); - set_address("logObjectAddress", GraalRuntime::log_object); - set_address("logPrintfAddress", GraalRuntime::log_printf); - set_address("vmErrorAddress", GraalRuntime::vm_error); - set_address("loadAndClearExceptionAddress", GraalRuntime::load_and_clear_exception); - set_address("writeBarrierPreAddress", GraalRuntime::write_barrier_pre); - set_address("writeBarrierPostAddress", GraalRuntime::write_barrier_post); - set_address("validateObject", GraalRuntime::validate_object); - - set_address("deoptimizationFetchUnrollInfo", Deoptimization::fetch_unroll_info); - set_address("deoptimizationUncommonTrap", Deoptimization::uncommon_trap); - set_address("deoptimizationUnpackFrames", Deoptimization::unpack_frames); - - //------------------------------------------------------------------------------------------------ - - set_int("graalCountersThreadOffset", in_bytes(JavaThread::graal_counters_offset())); - set_int("graalCountersSize", (jint) GraalCounterSize); - - //------------------------------------------------------------------------------------------------ - - set_long("dllLoad", (jlong) os::dll_load); - set_long("dllLookup", (jlong) os::dll_lookup); - #if defined(TARGET_OS_FAMILY_bsd) || defined(TARGET_OS_FAMILY_linux) - set_long("rtldDefault", (jlong) RTLD_DEFAULT); - #endif - -#undef set_boolean -#undef set_int -#undef set_long -#undef set_address - +C2V_VMENTRY(void, initializeConfiguration, (JNIEnv *env, jobject, jobject config)) + VMStructs::initHotSpotVMConfig(env, config); C2V_END C2V_ENTRY(jbyteArray, initializeBytecode, (JNIEnv *env, jobject, jlong metaspace_method, jbyteArray result)) diff -r bde6fbdbbe38 -r dffc37fa7157 src/share/vm/runtime/globals.cpp --- a/src/share/vm/runtime/globals.cpp Tue May 20 21:38:31 2014 +0200 +++ b/src/share/vm/runtime/globals.cpp Tue May 20 13:46:34 2014 -0700 @@ -477,12 +477,12 @@ } // Search the flag table for a named flag -Flag* Flag::find_flag(const char* name, size_t length, bool allow_locked) { +Flag* Flag::find_flag(const char* name, size_t length, bool allow_locked, bool allow_constant) { for (Flag* current = &flagTable[0]; current->_name != NULL; current++) { if (str_equal(current->_name, name, length)) { // Found a matching entry. // Don't report notproduct and develop flags in product builds. - if (current->is_constant_in_binary()) { + if (current->is_constant_in_binary() && !allow_constant) { return NULL; } // Report locked flags only if allowed. diff -r bde6fbdbbe38 -r dffc37fa7157 src/share/vm/runtime/globals.hpp --- a/src/share/vm/runtime/globals.hpp Tue May 20 21:38:31 2014 +0200 +++ b/src/share/vm/runtime/globals.hpp Tue May 20 13:46:34 2014 -0700 @@ -256,7 +256,7 @@ // number of flags static size_t numFlags; - static Flag* find_flag(const char* name, size_t length, bool allow_locked = false); + static Flag* find_flag(const char* name, size_t length, bool allow_locked = false, bool allow_constant = false); static Flag* fuzzy_match(const char* name, size_t length, bool allow_locked = false); void check_writable(); diff -r bde6fbdbbe38 -r dffc37fa7157 src/share/vm/runtime/vmStructs.cpp --- a/src/share/vm/runtime/vmStructs.cpp Tue May 20 21:38:31 2014 +0200 +++ b/src/share/vm/runtime/vmStructs.cpp Tue May 20 13:46:34 2014 -0700 @@ -70,6 +70,9 @@ #include "oops/constMethod.hpp" #include "oops/constantPool.hpp" #include "oops/cpCache.hpp" +#ifdef GRAAL +#include "oops/fieldStreams.hpp" +#endif #include "oops/instanceClassLoaderKlass.hpp" #include "oops/instanceKlass.hpp" #include "oops/instanceMirrorKlass.hpp" @@ -105,6 +108,7 @@ #include "utilities/hashtable.hpp" #include "utilities/macros.hpp" #ifdef GRAAL +# include "graal/graalRuntime.hpp" # include "graal/vmStructs_graal.hpp" # include "hsail/vm/vmStructs_hsail.hpp" #endif @@ -3479,3 +3483,11 @@ } } #endif + + +#ifdef GRAAL +// Emit intialization code for HotSpotVMConfig. It's placed here so +// it can take advantage of the relaxed access checking enjoyed by +// VMStructs. +#include "HotSpotVMConfig.inline.hpp" +#endif diff -r bde6fbdbbe38 -r dffc37fa7157 src/share/vm/runtime/vmStructs.hpp --- a/src/share/vm/runtime/vmStructs.hpp Tue May 20 21:38:31 2014 +0200 +++ b/src/share/vm/runtime/vmStructs.hpp Tue May 20 13:46:34 2014 -0700 @@ -126,6 +126,10 @@ static void test(); #endif +#ifdef GRAAL + static void initHotSpotVMConfig(JNIEnv *env, jobject config); +#endif + private: // Look up a type in localHotSpotVMTypes using strcmp() (debug build only). // Returns 1 if found, 0 if not.