Mercurial > hg > graal-jvmci-8
changeset 18232:31832ebd40cf
Fine grained naming of immutable HotSpot LocationIdentities
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java Mon Nov 03 13:37:10 2014 -0800 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java Mon Nov 03 14:07:50 2014 -0800 @@ -824,7 +824,6 @@ @HotSpotVMField(name = "Klass::_modifier_flags", type = "jint", get = HotSpotVMField.Type.OFFSET) @Stable public int klassModifierFlagsOffset; @HotSpotVMField(name = "Klass::_access_flags", type = "AccessFlags", get = HotSpotVMField.Type.OFFSET) @Stable public int klassAccessFlagsOffset; @HotSpotVMField(name = "Klass::_layout_helper", type = "jint", get = HotSpotVMField.Type.OFFSET) @Stable public int klassLayoutHelperOffset; - @HotSpotVMField(name = "Klass::_layout_helper", type = "jint", get = HotSpotVMField.Type.OFFSET) @Stable public int klassInstanceSizeOffset; @HotSpotVMConstant(name = "Klass::_lh_neutral_value") @Stable public int klassLayoutHelperNeutralValue; @HotSpotVMConstant(name = "Klass::_lh_instance_slow_path_bit") @Stable public int klassLayoutHelperInstanceSlowPathBit;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/DefaultHotSpotLoweringProvider.java Mon Nov 03 13:37:10 2014 -0800 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/DefaultHotSpotLoweringProvider.java Mon Nov 03 14:07:50 2014 -0800 @@ -250,7 +250,7 @@ @Override protected ValueNode createReadArrayComponentHub(StructuredGraph graph, ValueNode arrayHub, FixedNode anchor) { Kind wordKind = runtime.getTarget().wordKind; - LocationNode location = ConstantLocationNode.create(FINAL_LOCATION, wordKind, runtime.getConfig().arrayClassElementOffset, graph); + LocationNode location = ConstantLocationNode.create(OBJ_ARRAY_KLASS_ELEMENT_KLASS_LOCATION, wordKind, runtime.getConfig().arrayClassElementOffset, graph); /* * Anchor the read of the element klass to the cfg, because it is only valid when arrayClass * is an object class, which might not be the case in other parts of the compiled method. @@ -401,7 +401,7 @@ protected ValueNode createReadHub(StructuredGraph graph, ValueNode object, GuardingNode guard) { Kind wordKind = target.wordKind; HotSpotVMConfig config = runtime.getConfig(); - LocationNode location = ConstantLocationNode.create(FINAL_LOCATION, wordKind, config.hubOffset, graph); + LocationNode location = ConstantLocationNode.create(HUB_LOCATION, wordKind, config.hubOffset, graph); assert !object.isConstant() || object.asJavaConstant().isNull(); Stamp hubStamp; @@ -421,7 +421,7 @@ private WriteNode createWriteHub(StructuredGraph graph, Kind wordKind, ValueNode object, ValueNode value) { HotSpotVMConfig config = runtime.getConfig(); - LocationNode location = ConstantLocationNode.create(HUB_LOCATION, wordKind, config.hubOffset, graph); + LocationNode location = ConstantLocationNode.create(HUB_WRITE_LOCATION, wordKind, config.hubOffset, graph); assert !object.isConstant() || object.asJavaConstant().isNull(); ValueNode writeValue = value;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/LoadJavaMirrorWithKlassPhase.java Mon Nov 03 13:37:10 2014 -0800 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/LoadJavaMirrorWithKlassPhase.java Mon Nov 03 14:07:50 2014 -0800 @@ -23,6 +23,7 @@ package com.oracle.graal.hotspot.phases; import static com.oracle.graal.api.meta.LocationIdentity.*; +import static com.oracle.graal.hotspot.replacements.HotSpotReplacementsUtil.*; import static com.oracle.graal.nodes.ConstantNode.*; import com.oracle.graal.api.meta.*; @@ -65,7 +66,7 @@ JavaConstant klass; LocationNode location; if (type instanceof HotSpotResolvedObjectType) { - location = ConstantLocationNode.create(FINAL_LOCATION, Kind.Object, classMirrorOffset, graph); + location = ConstantLocationNode.create(CLASS_MIRROR_LOCATION, Kind.Object, classMirrorOffset, graph); klass = ((HotSpotResolvedObjectType) type).klass(); } else { /*
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ClassSubstitutions.java Mon Nov 03 13:37:10 2014 -0800 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ClassSubstitutions.java Mon Nov 03 14:07:50 2014 -0800 @@ -27,7 +27,6 @@ import java.lang.reflect.*; -import com.oracle.graal.api.meta.*; import com.oracle.graal.api.replacements.*; import com.oracle.graal.hotspot.nodes.*; import com.oracle.graal.nodes.calc.*; @@ -48,7 +47,7 @@ // Class for primitive type return Modifier.ABSTRACT | Modifier.FINAL | Modifier.PUBLIC; } else { - return klass.readInt(klassModifierFlagsOffset(), LocationIdentity.FINAL_LOCATION); + return klass.readInt(klassModifierFlagsOffset(), KLASS_MODIFIER_FLAGS_LOCATION); } } @@ -59,7 +58,7 @@ if (klass.equal(0)) { return false; } else { - int accessFlags = klass.readInt(klassAccessFlagsOffset(), LocationIdentity.FINAL_LOCATION); + int accessFlags = klass.readInt(klassAccessFlagsOffset(), KLASS_ACCESS_FLAGS_LOCATION); return (accessFlags & Modifier.INTERFACE) != 0; } } @@ -90,16 +89,16 @@ public static Class<?> getSuperclass(final Class<?> thisObj) { Word klass = loadWordFromObject(thisObj, klassOffset()); if (klass.notEqual(0)) { - int accessFlags = klass.readInt(klassAccessFlagsOffset(), LocationIdentity.FINAL_LOCATION); + int accessFlags = klass.readInt(klassAccessFlagsOffset(), KLASS_ACCESS_FLAGS_LOCATION); if ((accessFlags & Modifier.INTERFACE) == 0) { if (klassIsArray(klass)) { return Object.class; } else { - Word superKlass = klass.readWord(klassSuperKlassOffset(), LocationIdentity.FINAL_LOCATION); + Word superKlass = klass.readWord(klassSuperKlassOffset(), KLASS_SUPER_KLASS_LOCATION); if (superKlass.equal(0)) { return null; } else { - return piCastExactNonNull(superKlass.readObject(classMirrorOffset(), LocationIdentity.FINAL_LOCATION), Class.class); + return piCastExactNonNull(superKlass.readObject(classMirrorOffset(), CLASS_MIRROR_LOCATION), Class.class); } } } @@ -113,7 +112,7 @@ Word klass = loadWordFromObject(thisObj, klassOffset()); if (klass.notEqual(0)) { if (klassIsArray(klass)) { - return piCastExactNonNull(klass.readObject(arrayKlassComponentMirrorOffset(), LocationIdentity.FINAL_LOCATION), Class.class); + return piCastExactNonNull(klass.readObject(arrayKlassComponentMirrorOffset(), ARRAY_KLASS_COMPONENT_MIRROR), Class.class); } } return null;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HotSpotReplacementsUtil.java Mon Nov 03 13:37:10 2014 -0800 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HotSpotReplacementsUtil.java Mon Nov 03 14:07:50 2014 -0800 @@ -232,11 +232,15 @@ return result; } + public static final LocationIdentity JAVA_THREAD_THREAD_OBJECT_LOCATION = new NamedLocationIdentity("JavaThread::_threadObj"); + @Fold public static int threadObjectOffset() { return config().threadObjectOffset; } + public static final LocationIdentity JAVA_THREAD_OSTHREAD_LOCATION = new NamedLocationIdentity("JavaThread::_osthread"); + @Fold public static int osThreadOffset() { return config().osThreadOffset; @@ -279,18 +283,22 @@ return config().arrayPrototypeMarkWord(); } + public static final LocationIdentity KLASS_ACCESS_FLAGS_LOCATION = new NamedLocationIdentity("Klass::_access_flags", true); + @Fold public static int klassAccessFlagsOffset() { return config().klassAccessFlagsOffset; } + public static final LocationIdentity KLASS_LAYOUT_HELPER_LOCATION = new NamedLocationIdentity("Klass::_layout_helper", true); + @Fold public static int klassLayoutHelperOffset() { return config().klassLayoutHelperOffset; } public static int readLayoutHelper(Word hub) { - return hub.readInt(klassLayoutHelperOffset(), LocationIdentity.FINAL_LOCATION); + return hub.readInt(klassLayoutHelperOffset(), KLASS_LAYOUT_HELPER_LOCATION); } /** @@ -311,11 +319,15 @@ return (layoutHelper < layoutHelperNeutralValue); } + public static final LocationIdentity ARRAY_KLASS_COMPONENT_MIRROR = new NamedLocationIdentity("ArrayKlass::_component_mirror", true); + @Fold public static int arrayKlassComponentMirrorOffset() { return config().arrayKlassComponentMirrorOffset; } + public static final LocationIdentity KLASS_SUPER_KLASS_LOCATION = new NamedLocationIdentity("Klass::_super", true); + @Fold public static int klassSuperKlassOffset() { return config().klassSuperKlassOffset; @@ -328,7 +340,9 @@ return config().markOffset; } - public static final LocationIdentity HUB_LOCATION = new NamedLocationIdentity("Hub"); + public static final LocationIdentity HUB_WRITE_LOCATION = new NamedLocationIdentity("Hub"); + + public static final LocationIdentity HUB_LOCATION = new NamedLocationIdentity("Hub", true); @Fold private static int hubOffset() { @@ -465,6 +479,8 @@ return config().g1SATBQueueBufferOffset(); } + public static final LocationIdentity KLASS_SUPER_CHECK_OFFSET_LOCATION = new NamedLocationIdentity("Klass::_super_check_offset", true); + @Fold public static int superCheckOffsetOffset() { return config().superCheckOffsetOffset; @@ -607,6 +623,8 @@ return hub.readByte(instanceKlassInitStateOffset(), CLASS_STATE_LOCATION); } + public static final LocationIdentity KLASS_MODIFIER_FLAGS_LOCATION = new NamedLocationIdentity("Klass::_modifier_flags", true); + @Fold public static int klassModifierFlagsOffset() { return config().klassModifierFlagsOffset; @@ -629,16 +647,13 @@ return config().instanceKlassNodeClassOffset; } + public static final LocationIdentity CLASS_MIRROR_LOCATION = new NamedLocationIdentity("Klass::_java_mirror", true); + @Fold public static int classMirrorOffset() { return config().classMirrorOffset; } - @Fold - public static int klassInstanceSizeOffset() { - return config().klassInstanceSizeOffset; - } - public static final LocationIdentity HEAP_TOP_LOCATION = new NamedLocationIdentity("HeapTop"); @Fold @@ -802,4 +817,12 @@ throw new GraalInternalError(e); } } + + public static final LocationIdentity OBJ_ARRAY_KLASS_ELEMENT_KLASS_LOCATION = new NamedLocationIdentity("ObjArrayKlass::_element_klass", true); + + public static final LocationIdentity PRIMARY_SUPERS_LOCATION = new NamedLocationIdentity("PrimarySupers", true); + + public static final LocationIdentity METASPACE_ARRAY_LENGTH_LOCATION = new NamedLocationIdentity("MetaspaceArrayLength", true); + + public static final LocationIdentity SECONDARY_SUPERS_ELEMENT_LOCATION = new NamedLocationIdentity("SecondarySupersElement", true); }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/InstanceOfSnippets.java Mon Nov 03 13:37:10 2014 -0800 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/InstanceOfSnippets.java Mon Nov 03 14:07:50 2014 -0800 @@ -141,7 +141,7 @@ } GuardingNode anchorNode = SnippetAnchorNode.anchor(); Word objectHub = loadHubIntrinsic(object, getWordKind(), anchorNode); - if (probability(NOT_LIKELY_PROBABILITY, objectHub.readWord(superCheckOffset, LocationIdentity.FINAL_LOCATION).notEqual(hub))) { + if (probability(NOT_LIKELY_PROBABILITY, objectHub.readWord(superCheckOffset, PRIMARY_SUPERS_LOCATION).notEqual(hub))) { displayMiss.inc(); return falseValue; }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ObjectSubstitutions.java Mon Nov 03 13:37:10 2014 -0800 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ObjectSubstitutions.java Mon Nov 03 14:07:50 2014 -0800 @@ -25,7 +25,6 @@ import static com.oracle.graal.hotspot.replacements.HotSpotReplacementsUtil.*; import static com.oracle.graal.nodes.PiNode.*; -import com.oracle.graal.api.meta.*; import com.oracle.graal.api.replacements.*; import com.oracle.graal.nodes.java.*; import com.oracle.graal.nodes.spi.*; @@ -41,7 +40,7 @@ @MethodSubstitution(isStatic = false, forced = true) public static Class<?> getClass(final Object thisObj) { Word hub = loadHub(thisObj); - return piCastExactNonNull(hub.readObject(Word.signed(classMirrorOffset()), LocationIdentity.FINAL_LOCATION), Class.class); + return piCastExactNonNull(hub.readObject(Word.signed(classMirrorOffset()), CLASS_MIRROR_LOCATION), Class.class); } @MethodSubstitution(isStatic = false)
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ThreadSubstitutions.java Mon Nov 03 13:37:10 2014 -0800 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ThreadSubstitutions.java Mon Nov 03 14:07:50 2014 -0800 @@ -45,15 +45,15 @@ @MethodSubstitution public static Thread currentThread() { - return PiNode.piCastNonNull(CurrentJavaThreadNode.get(getWordKind()).readObject(threadObjectOffset(), LocationIdentity.FINAL_LOCATION), Thread.class); + return PiNode.piCastNonNull(CurrentJavaThreadNode.get(getWordKind()).readObject(threadObjectOffset(), JAVA_THREAD_THREAD_OBJECT_LOCATION), Thread.class); } @MethodSubstitution(isStatic = false) public static boolean isInterrupted(final Thread thisObject, boolean clearInterrupted) { Word javaThread = CurrentJavaThreadNode.get(getWordKind()); - Object thread = javaThread.readObject(threadObjectOffset(), LocationIdentity.FINAL_LOCATION); + Object thread = javaThread.readObject(threadObjectOffset(), JAVA_THREAD_THREAD_OBJECT_LOCATION); if (thisObject == thread) { - Word osThread = javaThread.readWord(osThreadOffset(), LocationIdentity.FINAL_LOCATION); + Word osThread = javaThread.readWord(osThreadOffset(), JAVA_THREAD_OSTHREAD_LOCATION); boolean interrupted = osThread.readInt(osThreadInterruptedOffset(), ANY_LOCATION) != 0; if (!interrupted || !clearInterrupted) { return interrupted;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/TypeCheckSnippetUtils.java Mon Nov 03 13:37:10 2014 -0800 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/TypeCheckSnippetUtils.java Mon Nov 03 14:07:50 2014 -0800 @@ -42,8 +42,6 @@ */ public class TypeCheckSnippetUtils { - public static final LocationIdentity TYPE_DISPLAY_LOCATION = new NamedLocationIdentity("TypeDisplay"); - static boolean checkSecondarySubType(Word t, Word s) { // if (S.cache == T) return true if (s.readWord(secondarySuperCacheOffset(), SECONDARY_SUPER_CACHE_LOCATION).equal(t)) { @@ -56,11 +54,11 @@ static boolean checkUnknownSubType(Word t, Word s) { // int off = T.offset - int superCheckOffset = t.readInt(superCheckOffsetOffset(), LocationIdentity.FINAL_LOCATION); + int superCheckOffset = t.readInt(superCheckOffsetOffset(), KLASS_SUPER_CHECK_OFFSET_LOCATION); boolean primary = superCheckOffset != secondarySuperCacheOffset(); // if (T = S[off]) return true - if (s.readWord(superCheckOffset, TYPE_DISPLAY_LOCATION).equal(t)) { + if (s.readWord(superCheckOffset, PRIMARY_SUPERS_LOCATION).equal(t)) { if (primary) { cacheHit.inc(); } else { @@ -87,7 +85,7 @@ // if (S.scan_s_s_array(T)) { S.cache = T; return true; } Word secondarySupers = s.readWord(secondarySupersOffset(), SECONDARY_SUPERS_LOCATION); - int length = secondarySupers.readInt(metaspaceArrayLengthOffset(), LocationIdentity.FINAL_LOCATION); + int length = secondarySupers.readInt(metaspaceArrayLengthOffset(), METASPACE_ARRAY_LENGTH_LOCATION); for (int i = 0; i < length; i++) { if (probability(NOT_LIKELY_PROBABILITY, t.equal(loadSecondarySupersElement(secondarySupers, i)))) { s.writeWord(secondarySuperCacheOffset(), t, SECONDARY_SUPER_CACHE_LOCATION); @@ -141,7 +139,7 @@ } static Word loadSecondarySupersElement(Word metaspaceArray, int index) { - return metaspaceArray.readWord(metaspaceArrayBaseOffset() + index * wordSize(), LocationIdentity.FINAL_LOCATION); + return metaspaceArray.readWord(metaspaceArrayBaseOffset() + index * wordSize(), SECONDARY_SUPERS_ELEMENT_LOCATION); } private static final SnippetCounter.Group counters = SnippetCounters.getValue() ? new SnippetCounter.Group("TypeCheck") : null;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewArrayStub.java Mon Nov 03 13:37:10 2014 -0800 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewArrayStub.java Mon Nov 03 14:07:50 2014 -0800 @@ -83,7 +83,7 @@ */ @Snippet private static Object newArray(Word hub, int length, @ConstantParameter Word intArrayHub, @ConstantParameter Register threadRegister) { - int layoutHelper = hub.readInt(klassLayoutHelperOffset(), LocationIdentity.FINAL_LOCATION); + int layoutHelper = hub.readInt(klassLayoutHelperOffset(), KLASS_LAYOUT_HELPER_LOCATION); int log2ElementSize = (layoutHelper >> layoutHelperLog2ElementSizeShift()) & layoutHelperLog2ElementSizeMask(); int headerSize = (layoutHelper >> layoutHelperHeaderSizeShift()) & layoutHelperHeaderSizeMask(); int elementKind = (layoutHelper >> layoutHelperElementTypeShift()) & layoutHelperElementTypeMask();
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewInstanceStub.java Mon Nov 03 13:37:10 2014 -0800 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewInstanceStub.java Mon Nov 03 14:07:50 2014 -0800 @@ -96,7 +96,11 @@ */ @Snippet private static Object newInstance(Word hub, @ConstantParameter Word intArrayHub, @ConstantParameter Register threadRegister) { - int sizeInBytes = hub.readInt(klassInstanceSizeOffset(), LocationIdentity.FINAL_LOCATION); + /* + * The type is known to be an instance so Klass::_layout_helper is the instance size as a + * raw number + */ + int sizeInBytes = hub.readInt(klassLayoutHelperOffset(), KLASS_LAYOUT_HELPER_LOCATION); Word thread = registerAsWord(threadRegister); if (!forceSlowPath() && inlineContiguousAllocationSupported()) { if (isInstanceKlassFullyInitialized(hub)) {