# HG changeset patch # User Tom Rodriguez # Date 1404268664 25200 # Node ID 9ce3b1efc4e712096e087c4e3388d9c2f628d194 # Parent e0f77d30ad07f5b92104b3e52b0284708a223b9e InstanceKlass::_init_state only exists for InstanceKlasses diff -r e0f77d30ad07 -r 9ce3b1efc4e7 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 Jul 01 19:36:36 2014 -0700 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java Tue Jul 01 19:37:44 2014 -0700 @@ -865,14 +865,14 @@ @HotSpotVMField(name = "Array::_length", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int metaspaceArrayLengthOffset; @HotSpotVMField(name = "Array::_data[0]", type = "Klass*", get = HotSpotVMField.Type.OFFSET) @Stable public int metaspaceArrayBaseOffset; - @HotSpotVMField(name = "InstanceKlass::_graal_node_class", type = "oop", get = HotSpotVMField.Type.OFFSET) @Stable public int klassNodeClassOffset; - @HotSpotVMField(name = "InstanceKlass::_source_file_name_index", type = "u2", get = HotSpotVMField.Type.OFFSET) @Stable public int klassSourceFileNameIndexOffset; - @HotSpotVMField(name = "InstanceKlass::_init_state", type = "u1", get = HotSpotVMField.Type.OFFSET) @Stable public int klassStateOffset; + @HotSpotVMField(name = "InstanceKlass::_graal_node_class", type = "oop", get = HotSpotVMField.Type.OFFSET) @Stable public int instanceKlassNodeClassOffset; + @HotSpotVMField(name = "InstanceKlass::_source_file_name_index", type = "u2", get = HotSpotVMField.Type.OFFSET) @Stable public int instanceKlassSourceFileNameIndexOffset; + @HotSpotVMField(name = "InstanceKlass::_init_state", type = "u1", get = HotSpotVMField.Type.OFFSET) @Stable public int instanceKlassInitStateOffset; @HotSpotVMField(name = "InstanceKlass::_constants", type = "ConstantPool*", get = HotSpotVMField.Type.OFFSET) @Stable public int instanceKlassConstantsOffset; @HotSpotVMField(name = "InstanceKlass::_fields", type = "Array*", get = HotSpotVMField.Type.OFFSET) @Stable public int instanceKlassFieldsOffset; - @HotSpotVMConstant(name = "InstanceKlass::linked") @Stable public int klassStateLinked; - @HotSpotVMConstant(name = "InstanceKlass::fully_initialized") @Stable public int klassStateFullyInitialized; + @HotSpotVMConstant(name = "InstanceKlass::linked") @Stable public int instanceKlassStateLinked; + @HotSpotVMConstant(name = "InstanceKlass::fully_initialized") @Stable public int instanceKlassStateFullyInitialized; @HotSpotVMField(name = "ObjArrayKlass::_element_klass", type = "Klass*", get = HotSpotVMField.Type.OFFSET) @Stable public int arrayClassElementOffset; diff -r e0f77d30ad07 -r 9ce3b1efc4e7 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectType.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectType.java Tue Jul 01 19:36:36 2014 -0700 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectType.java Tue Jul 01 19:37:44 2014 -0700 @@ -293,14 +293,12 @@ @Override public boolean isInitialized() { - final int state = getState(); - return state == runtime().getConfig().klassStateFullyInitialized; + return isArray() ? true : getInitState() == runtime().getConfig().instanceKlassStateFullyInitialized; } @Override public boolean isLinked() { - final int state = getState(); - return state >= runtime().getConfig().klassStateLinked; + return isArray() ? true : getInitState() >= runtime().getConfig().instanceKlassStateLinked; } /** @@ -309,8 +307,9 @@ * * @return state field value of this type */ - private int getState() { - return unsafe.getByte(getMetaspaceKlass() + runtime().getConfig().klassStateOffset) & 0xFF; + private int getInitState() { + assert !isArray() : "_init_state only exists in InstanceKlass"; + return unsafe.getByte(getMetaspaceKlass() + runtime().getConfig().instanceKlassInitStateOffset) & 0xFF; } @Override @@ -695,7 +694,7 @@ @Override public String getSourceFileName() { HotSpotVMConfig config = runtime().getConfig(); - final int sourceFileNameIndex = unsafe.getChar(getMetaspaceKlass() + config.klassSourceFileNameIndexOffset); + final int sourceFileNameIndex = unsafe.getChar(getMetaspaceKlass() + config.instanceKlassSourceFileNameIndexOffset); if (sourceFileNameIndex == 0) { return null; } diff -r e0f77d30ad07 -r 9ce3b1efc4e7 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HotSpotNodeSubstitutions.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HotSpotNodeSubstitutions.java Tue Jul 01 19:36:36 2014 -0700 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HotSpotNodeSubstitutions.java Tue Jul 01 19:37:44 2014 -0700 @@ -42,6 +42,6 @@ // so we are guaranteed to read a non-null value here. As long as NodeClass // is final, the stamp of the PiNode below will automatically be exact. Word klass = loadHub(node); - return piCastNonNull(klass.readObject(Word.signed(klassNodeClassOffset()), KLASS_NODE_CLASS), NodeClass.class); + return piCastNonNull(klass.readObject(Word.signed(instanceKlassNodeClassOffset()), KLASS_NODE_CLASS), NodeClass.class); } } diff -r e0f77d30ad07 -r 9ce3b1efc4e7 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HotSpotReplacementsUtil.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HotSpotReplacementsUtil.java Tue Jul 01 19:36:36 2014 -0700 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HotSpotReplacementsUtil.java Tue Jul 01 19:37:44 2014 -0700 @@ -586,21 +586,26 @@ public static final LocationIdentity CLASS_STATE_LOCATION = new NamedLocationIdentity("ClassState"); @Fold - public static int klassStateOffset() { - return config().klassStateOffset; + public static int instanceKlassInitStateOffset() { + return config().instanceKlassInitStateOffset; } @Fold - public static int klassStateFullyInitialized() { - return config().klassStateFullyInitialized; + public static int instanceKlassStateFullyInitialized() { + return config().instanceKlassStateFullyInitialized; } - public static boolean isKlassFullyInitialized(Word hub) { - return readKlassState(hub) == klassStateFullyInitialized(); + /** + * + * @param hub the hub of an InstanceKlass + * @return true is the InstanceKlass represented by hub is fully initialized + */ + public static boolean isInstanceKlassFullyInitialized(Word hub) { + return readInstanceKlassState(hub) == instanceKlassStateFullyInitialized(); } - public static byte readKlassState(Word hub) { - return hub.readByte(klassStateOffset(), CLASS_STATE_LOCATION); + private static byte readInstanceKlassState(Word hub) { + return hub.readByte(instanceKlassInitStateOffset(), CLASS_STATE_LOCATION); } @Fold @@ -621,8 +626,8 @@ public static final LocationIdentity KLASS_NODE_CLASS = new NamedLocationIdentity("KlassNodeClass"); @Fold - public static int klassNodeClassOffset() { - return config().klassNodeClassOffset; + public static int instanceKlassNodeClassOffset() { + return config().instanceKlassNodeClassOffset; } @Fold diff -r e0f77d30ad07 -r 9ce3b1efc4e7 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/NewObjectSnippets.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/NewObjectSnippets.java Tue Jul 01 19:36:36 2014 -0700 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/NewObjectSnippets.java Tue Jul 01 19:37:44 2014 -0700 @@ -154,7 +154,7 @@ public static Object allocateInstanceDynamic(Class type, @ConstantParameter boolean fillContents, @ConstantParameter Register threadRegister, @ConstantParameter String typeContext) { Word hub = loadWordFromObject(type, klassOffset()); if (probability(FAST_PATH_PROBABILITY, !hub.equal(Word.zero()))) { - if (probability(FAST_PATH_PROBABILITY, isKlassFullyInitialized(hub))) { + if (probability(FAST_PATH_PROBABILITY, isInstanceKlassFullyInitialized(hub))) { int layoutHelper = readLayoutHelper(hub); /* * src/share/vm/oops/klass.hpp: For instances, layout helper is a positive number, diff -r e0f77d30ad07 -r 9ce3b1efc4e7 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewInstanceStub.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewInstanceStub.java Tue Jul 01 19:36:36 2014 -0700 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewInstanceStub.java Tue Jul 01 19:37:44 2014 -0700 @@ -99,7 +99,7 @@ int sizeInBytes = hub.readInt(klassInstanceSizeOffset(), LocationIdentity.FINAL_LOCATION); Word thread = registerAsWord(threadRegister); if (!forceSlowPath() && inlineContiguousAllocationSupported()) { - if (isKlassFullyInitialized(hub)) { + if (isInstanceKlassFullyInitialized(hub)) { Word memory = refillAllocate(thread, intArrayHub, sizeInBytes, logging()); if (memory.notEqual(0)) { Word prototypeMarkWord = hub.readWord(prototypeMarkWordOffset(), PROTOTYPE_MARK_WORD_LOCATION); diff -r e0f77d30ad07 -r 9ce3b1efc4e7 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/DynamicNewInstanceNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/DynamicNewInstanceNode.java Tue Jul 01 19:36:36 2014 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/DynamicNewInstanceNode.java Tue Jul 01 19:37:44 2014 -0700 @@ -41,7 +41,7 @@ public Node canonical(CanonicalizerTool tool) { if (clazz.isConstant()) { ResolvedJavaType type = tool.getConstantReflection().asJavaType(clazz.asConstant()); - if (type != null && type.isInitialized()) { + if (type != null && type.isInitialized() && !type.isArray() && !type.isInterface() && !type.isPrimitive()) { return new NewInstanceNode(type, fillContents()); } } diff -r e0f77d30ad07 -r 9ce3b1efc4e7 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/NewInstanceNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/NewInstanceNode.java Tue Jul 01 19:36:36 2014 -0700 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/NewInstanceNode.java Tue Jul 01 19:37:44 2014 -0700 @@ -42,20 +42,20 @@ /** * Constructs a NewInstanceNode. - * + * * @param type the class being allocated * @param fillContents determines whether the new object's fields should be initialized to * zero/null. */ public NewInstanceNode(ResolvedJavaType type, boolean fillContents) { super(StampFactory.exactNonNull(type), fillContents); - assert !type.isArray(); + assert !type.isArray() && !type.isInterface() && !type.isPrimitive(); this.instanceClass = type; } /** * Gets the instance class being allocated by this node. - * + * * @return the instance class allocated */ public ResolvedJavaType instanceClass() {