--- old/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/meta/HotSpotClassInitializationPlugin.java 2017-06-26 15:43:50.000000000 -0700 +++ new/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/meta/HotSpotClassInitializationPlugin.java 2017-06-26 15:43:50.000000000 -0700 @@ -26,7 +26,9 @@ import org.graalvm.compiler.core.common.type.Stamp; import org.graalvm.compiler.core.common.type.StampFactory; import org.graalvm.compiler.hotspot.nodes.aot.InitializeKlassNode; +import org.graalvm.compiler.hotspot.nodes.aot.ResolveConstantNode; import org.graalvm.compiler.nodes.ConstantNode; +import org.graalvm.compiler.nodes.DeoptimizingFixedWithNextNode; import org.graalvm.compiler.nodes.FrameState; import org.graalvm.compiler.nodes.ValueNode; import org.graalvm.compiler.nodes.graphbuilderconf.ClassInitializationPlugin; @@ -40,18 +42,24 @@ @Override public boolean shouldApply(GraphBuilderContext builder, ResolvedJavaType type) { if (!builder.parsingIntrinsic()) { - ResolvedJavaMethod method = builder.getGraph().method(); - ResolvedJavaType methodHolder = method.getDeclaringClass(); - // We can elide initialization nodes if type >=: methodHolder. - // The type is already initialized by either "new" or "invokestatic". + if (!type.isArray()) { + ResolvedJavaMethod method = builder.getGraph().method(); + ResolvedJavaType methodHolder = method.getDeclaringClass(); + // We can elide initialization nodes if type >=: methodHolder. + // The type is already initialized by either "new" or "invokestatic". - // Emit initialization node if type is an interface since: - // JLS 12.4: Before a class is initialized, its direct superclass must be initialized, - // but interfaces implemented by the class are not initialized. - // and a class or interface type T will be initialized immediately - // before the first occurrence of accesses listed in JLS 12.4.1. + // Emit initialization node if type is an interface since: + // JLS 12.4: Before a class is initialized, its direct superclass must be + // initialized, but interfaces implemented by the class are not + // initialized and a class or interface type T will be initialized + // immediately before the first occurrence of accesses listed + // in JLS 12.4.1. - return !type.isAssignableFrom(methodHolder) || type.isInterface(); + return !type.isAssignableFrom(methodHolder) || type.isInterface(); + } else if (!type.getComponentType().isPrimitive()) { + // Always apply to object array types + return true; + } } return false; } @@ -61,8 +69,8 @@ assert shouldApply(builder, type); Stamp hubStamp = builder.getStampProvider().createHubStamp((ObjectStamp) StampFactory.objectNonNull()); ConstantNode hub = builder.append(ConstantNode.forConstant(hubStamp, ((HotSpotResolvedObjectType) type).klass(), builder.getMetaAccess(), builder.getGraph())); - InitializeKlassNode initialize = builder.append(new InitializeKlassNode(hub)); - initialize.setStateBefore(frameState); - return initialize; + DeoptimizingFixedWithNextNode result = builder.append(type.isArray() ? new ResolveConstantNode(hub) : new InitializeKlassNode(hub)); + result.setStateBefore(frameState); + return result; } }