# HG changeset patch # User Roland Schatz # Date 1415807979 -3600 # Node ID 6ac7e9c85be67940357967b61b59fed6efba07f6 # Parent 6a5dc0bbebe7e78250f733eda733413f4bb37a9c Split getEncoding into two methods. diff -r 6a5dc0bbebe7 -r 6ac7e9c85be6 graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/TestResolvedJavaType.java --- a/graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/TestResolvedJavaType.java Wed Nov 12 11:48:54 2014 +0100 +++ b/graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/TestResolvedJavaType.java Wed Nov 12 16:59:39 2014 +0100 @@ -837,7 +837,8 @@ "getDeclaredConstructors", "isInitialized", "isLinked", - "getEncoding", + "getJavaClass", + "getObjectHub", "hasFinalizableSubclass", "hasFinalizer", "getSourceFileName", diff -r 6a5dc0bbebe7 -r 6ac7e9c85be6 graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ResolvedJavaType.java --- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ResolvedJavaType.java Wed Nov 12 11:48:54 2014 +0100 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ResolvedJavaType.java Wed Nov 12 16:59:39 2014 +0100 @@ -34,31 +34,15 @@ public interface ResolvedJavaType extends JavaType, ModifiersProvider { /** - * Represents each of the several different parts of the runtime representation of a type which - * compiled code may need to reference individually. These may or may not be different objects - * or data structures, depending on the runtime system. + * Gets the runtime representation of the Java class object of this type. */ - public enum Representation { - /** - * The runtime representation of the Java class object of this type. - */ - JavaClass, - - /** - * The runtime representation of the "hub" of this type--that is, the closest part of the - * type representation which is typically stored in the object header. - */ - ObjectHub - } + JavaConstant getJavaClass(); /** - * Gets the encoding of (that is, a constant representing the value of) the specified part of - * this type. - * - * @param r the part of this type - * @return a constant representing a reference to the specified part of this type + * Gets the runtime representation of the "hub" of this type--that is, the closest part of the + * type representation which is typically stored in the object header. */ - JavaConstant getEncoding(Representation r); + JavaConstant getObjectHub(); /** * Checks whether this type has a finalizer method. diff -r 6a5dc0bbebe7 -r 6ac7e9c85be6 graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/BaselineBytecodeParser.java --- a/graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/BaselineBytecodeParser.java Wed Nov 12 11:48:54 2014 +0100 +++ b/graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/BaselineBytecodeParser.java Wed Nov 12 16:59:39 2014 +0100 @@ -29,7 +29,6 @@ import com.oracle.graal.alloc.*; import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; -import com.oracle.graal.api.meta.ResolvedJavaType.Representation; import com.oracle.graal.bytecode.*; import com.oracle.graal.compiler.alloc.*; import com.oracle.graal.compiler.common.*; @@ -232,7 +231,7 @@ } @Override - protected void handleUnresolvedExceptionType(Representation representation, JavaType type) { + protected void handleUnresolvedExceptionType(JavaType type) { // TODO Auto-generated method stub throw GraalInternalError.unimplemented("Auto-generated method stub"); } diff -r 6a5dc0bbebe7 -r 6ac7e9c85be6 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBytecodeLIRBuilder.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBytecodeLIRBuilder.java Wed Nov 12 11:48:54 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBytecodeLIRBuilder.java Wed Nov 12 16:59:39 2014 +0100 @@ -26,7 +26,6 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; -import com.oracle.graal.api.meta.ResolvedJavaType.Representation; import com.oracle.graal.compiler.gen.*; import com.oracle.graal.hotspot.amd64.AMD64HotSpotLIRGenerator.SaveRbp; import com.oracle.graal.hotspot.meta.*; @@ -88,7 +87,7 @@ @Override public JavaConstant getClassConstant(ResolvedJavaType declaringClass) { - return declaringClass.getEncoding(Representation.JavaClass); + return declaringClass.getJavaClass(); } @Override diff -r 6a5dc0bbebe7 -r 6ac7e9c85be6 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/DefaultHotSpotLoweringProvider.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/DefaultHotSpotLoweringProvider.java Wed Nov 12 11:48:54 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/DefaultHotSpotLoweringProvider.java Wed Nov 12 16:59:39 2014 +0100 @@ -32,7 +32,6 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; -import com.oracle.graal.api.meta.ResolvedJavaType.Representation; import com.oracle.graal.compiler.common.*; import com.oracle.graal.compiler.common.type.*; import com.oracle.graal.graph.*; @@ -239,7 +238,7 @@ @Override protected ValueNode staticFieldBase(StructuredGraph graph, ResolvedJavaField f) { HotSpotResolvedJavaField field = (HotSpotResolvedJavaField) f; - JavaConstant base = field.getDeclaringClass().getEncoding(Representation.JavaClass); + JavaConstant base = field.getDeclaringClass().getJavaClass(); return ConstantNode.forConstant(base, metaAccess, graph); } diff -r 6a5dc0bbebe7 -r 6ac7e9c85be6 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectTypeImpl.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectTypeImpl.java Wed Nov 12 11:48:54 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectTypeImpl.java Wed Nov 12 16:59:39 2014 +0100 @@ -278,15 +278,13 @@ } @Override - public JavaConstant getEncoding(Representation r) { - switch (r) { - case JavaClass: - return HotSpotObjectConstantImpl.forObject(mirror()); - case ObjectHub: - return klass(); - default: - throw GraalInternalError.shouldNotReachHere("unexpected representation " + r); - } + public JavaConstant getJavaClass() { + return HotSpotObjectConstantImpl.forObject(mirror()); + } + + @Override + public JavaConstant getObjectHub() { + return klass(); } @Override diff -r 6a5dc0bbebe7 -r 6ac7e9c85be6 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedPrimitiveType.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedPrimitiveType.java Wed Nov 12 11:48:54 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedPrimitiveType.java Wed Nov 12 16:59:39 2014 +0100 @@ -114,8 +114,13 @@ } @Override - public JavaConstant getEncoding(Representation r) { - throw GraalInternalError.unimplemented("HotSpotResolvedPrimitiveType.getEncoding"); + public JavaConstant getObjectHub() { + throw GraalInternalError.unimplemented("HotSpotResolvedPrimitiveType.getObjectHub"); + } + + @Override + public JavaConstant getJavaClass() { + throw GraalInternalError.unimplemented("HotSpotResolvedPrimitiveType.getJavaClass"); } @Override diff -r 6a5dc0bbebe7 -r 6ac7e9c85be6 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ObjectGetClassNode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ObjectGetClassNode.java Wed Nov 12 11:48:54 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ObjectGetClassNode.java Wed Nov 12 16:59:39 2014 +0100 @@ -25,7 +25,6 @@ import static com.oracle.graal.compiler.common.GraalOptions.*; import com.oracle.graal.api.meta.*; -import com.oracle.graal.api.meta.ResolvedJavaType.Representation; import com.oracle.graal.graph.*; import com.oracle.graal.graph.spi.*; import com.oracle.graal.nodeinfo.*; @@ -60,7 +59,7 @@ } State state = tool.getObjectState(getObject()); if (state != null) { - JavaConstant clazz = state.getVirtualObject().type().getEncoding(Representation.JavaClass); + JavaConstant clazz = state.getVirtualObject().type().getJavaClass(); tool.replaceWithValue(ConstantNode.forConstant(clazz, tool.getMetaAccessProvider(), graph())); } } @@ -75,14 +74,14 @@ } else { ResolvedJavaType type = StampTool.typeOrNull(getObject()); if (StampTool.isExactType(getObject())) { - JavaConstant clazz = type.getEncoding(Representation.JavaClass); + JavaConstant clazz = type.getJavaClass(); return ConstantNode.forConstant(clazz, tool.getMetaAccess()); } if (type != null && tool.assumptions().useOptimisticAssumptions()) { ResolvedJavaType exactType = type.findUniqueConcreteSubtype(); if (exactType != null) { tool.assumptions().recordConcreteSubtype(type, exactType); - JavaConstant clazz = exactType.getEncoding(Representation.JavaClass); + JavaConstant clazz = exactType.getJavaClass(); return ConstantNode.forConstant(clazz, tool.getMetaAccess()); } } diff -r 6a5dc0bbebe7 -r 6ac7e9c85be6 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ReflectionGetCallerClassNode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ReflectionGetCallerClassNode.java Wed Nov 12 11:48:54 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ReflectionGetCallerClassNode.java Wed Nov 12 16:59:39 2014 +0100 @@ -25,7 +25,6 @@ import static com.oracle.graal.compiler.GraalCompiler.*; import com.oracle.graal.api.meta.*; -import com.oracle.graal.api.meta.ResolvedJavaType.Representation; import com.oracle.graal.compiler.common.*; import com.oracle.graal.graph.*; import com.oracle.graal.graph.spi.*; @@ -101,7 +100,7 @@ if (!method.ignoredBySecurityStackWalk()) { // We have reached the desired frame; return the holder class. HotSpotResolvedObjectType callerClass = method.getDeclaringClass(); - return ConstantNode.forConstant(callerClass.getEncoding(Representation.JavaClass), metaAccess); + return ConstantNode.forConstant(callerClass.getJavaClass(), metaAccess); } break; } diff -r 6a5dc0bbebe7 -r 6ac7e9c85be6 graal/com.oracle.graal.java/src/com/oracle/graal/java/AbstractBytecodeParser.java --- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/AbstractBytecodeParser.java Wed Nov 12 11:48:54 2014 +0100 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/AbstractBytecodeParser.java Wed Nov 12 16:59:39 2014 +0100 @@ -31,7 +31,6 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.api.meta.ProfilingInfo.TriState; -import com.oracle.graal.api.meta.ResolvedJavaType.Representation; import com.oracle.graal.bytecode.*; import com.oracle.graal.compiler.common.*; import com.oracle.graal.compiler.common.calc.*; @@ -177,10 +176,9 @@ protected abstract void handleUnresolvedStoreField(JavaField field, T value, T receiver); /** - * @param representation * @param type */ - protected abstract void handleUnresolvedExceptionType(Representation representation, JavaType type); + protected abstract void handleUnresolvedExceptionType(JavaType type); // protected abstract void handleUnresolvedInvoke(JavaMethod javaMethod, InvokeKind invokeKind); @@ -193,7 +191,7 @@ // this is a load of class constant which might be unresolved JavaType type = (JavaType) con; if (type instanceof ResolvedJavaType) { - frameState.push(Kind.Object, appendConstant(((ResolvedJavaType) type).getEncoding(Representation.JavaClass))); + frameState.push(Kind.Object, appendConstant(((ResolvedJavaType) type).getJavaClass())); } else { handleUnresolvedLoadConstant(type); } diff -r 6a5dc0bbebe7 -r 6ac7e9c85be6 graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java --- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java Wed Nov 12 11:48:54 2014 +0100 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java Wed Nov 12 16:59:39 2014 +0100 @@ -32,7 +32,6 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.api.meta.ProfilingInfo.TriState; -import com.oracle.graal.api.meta.ResolvedJavaType.Representation; import com.oracle.graal.bytecode.*; import com.oracle.graal.compiler.common.*; import com.oracle.graal.compiler.common.calc.*; @@ -407,11 +406,10 @@ } /** - * @param representation * @param type */ @Override - protected void handleUnresolvedExceptionType(Representation representation, JavaType type) { + protected void handleUnresolvedExceptionType(JavaType type) { assert !graphBuilderConfig.eagerResolving(); append(DeoptimizeNode.create(InvalidateRecompile, Unresolved)); } @@ -1136,7 +1134,7 @@ private ValueNode synchronizedObject(HIRFrameStateBuilder state, ResolvedJavaMethod target) { if (target.isStatic()) { - return appendConstant(target.getDeclaringClass().getEncoding(Representation.JavaClass)); + return appendConstant(target.getDeclaringClass().getJavaClass()); } else { return state.loadLocal(0); } @@ -1256,7 +1254,7 @@ checkCast.setNext(catchSuccessor); append(IfNode.create(currentGraph.unique(InstanceOfNode.create((ResolvedJavaType) catchType, exception, null)), checkCast, nextDispatch, 0.5)); } else { - handleUnresolvedExceptionType(Representation.ObjectHub, catchType); + handleUnresolvedExceptionType(catchType); } } diff -r 6a5dc0bbebe7 -r 6ac7e9c85be6 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/LoadHubNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/LoadHubNode.java Wed Nov 12 11:48:54 2014 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/LoadHubNode.java Wed Nov 12 16:59:39 2014 +0100 @@ -23,7 +23,6 @@ package com.oracle.graal.nodes.extended; import com.oracle.graal.api.meta.*; -import com.oracle.graal.api.meta.ResolvedJavaType.Representation; import com.oracle.graal.compiler.common.type.*; import com.oracle.graal.graph.spi.*; import com.oracle.graal.nodeinfo.*; @@ -31,8 +30,7 @@ import com.oracle.graal.nodes.spi.*; /** - * Loads an object's {@linkplain Representation#ObjectHub hub}. The object is not null-checked by - * this operation. + * Loads an object's hub. The object is not null-checked by this operation. */ @NodeInfo public class LoadHubNode extends FloatingGuardedNode implements Lowerable, Canonicalizable, Virtualizable { @@ -90,7 +88,7 @@ } if (exactType != null) { - return ConstantNode.forConstant(exactType.getEncoding(Representation.ObjectHub), metaAccess); + return ConstantNode.forConstant(exactType.getObjectHub(), metaAccess); } } return this; @@ -100,7 +98,7 @@ public void virtualize(VirtualizerTool tool) { State state = tool.getObjectState(value); if (state != null) { - JavaConstant constantHub = state.getVirtualObject().type().getEncoding(Representation.ObjectHub); + JavaConstant constantHub = state.getVirtualObject().type().getObjectHub(); tool.replaceWithValue(ConstantNode.forConstant(constantHub, tool.getMetaAccessProvider(), graph())); } } diff -r 6a5dc0bbebe7 -r 6ac7e9c85be6 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/TypeSwitchNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/TypeSwitchNode.java Wed Nov 12 11:48:54 2014 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/TypeSwitchNode.java Wed Nov 12 16:59:39 2014 +0100 @@ -25,7 +25,6 @@ import java.util.*; import com.oracle.graal.api.meta.*; -import com.oracle.graal.api.meta.ResolvedJavaType.Representation; import com.oracle.graal.compiler.common.type.*; import com.oracle.graal.graph.spi.*; import com.oracle.graal.nodeinfo.*; @@ -106,7 +105,7 @@ @Override public JavaConstant keyAt(int index) { - return keys[index].getEncoding(Representation.ObjectHub); + return keys[index].getObjectHub(); } @Override diff -r 6a5dc0bbebe7 -r 6ac7e9c85be6 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/info/MultiTypeGuardInlineInfo.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/info/MultiTypeGuardInlineInfo.java Wed Nov 12 11:48:54 2014 +0100 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/info/MultiTypeGuardInlineInfo.java Wed Nov 12 16:59:39 2014 +0100 @@ -343,7 +343,7 @@ private boolean createDispatchOnTypeBeforeInvoke(StructuredGraph graph, BeginNode[] successors, boolean invokeIsOnlySuccessor, MetaAccessProvider metaAccess) { assert ptypes.size() >= 1; ValueNode nonNullReceiver = InliningUtil.nonNullReceiver(invoke); - Constant hubConstant = ((MethodCallTargetNode) invoke.callTarget()).targetMethod().getDeclaringClass().getEncoding(ResolvedJavaType.Representation.ObjectHub); + Constant hubConstant = ((MethodCallTargetNode) invoke.callTarget()).targetMethod().getDeclaringClass().getObjectHub(); Stamp hubStamp = ((StampProvider) hubConstant).stamp(); Kind hubKind = hubStamp.getStackKind(); LoadHubNode hub = graph.unique(LoadHubNode.create(nonNullReceiver, hubKind)); diff -r 6a5dc0bbebe7 -r 6ac7e9c85be6 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/info/TypeGuardInlineInfo.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/info/TypeGuardInlineInfo.java Wed Nov 12 11:48:54 2014 +0100 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/info/TypeGuardInlineInfo.java Wed Nov 12 16:59:39 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -103,7 +103,7 @@ private void createGuard(StructuredGraph graph, MetaAccessProvider metaAccess) { ValueNode nonNullReceiver = InliningUtil.nonNullReceiver(invoke); - ConstantNode typeHub = ConstantNode.forConstant(type.getEncoding(ResolvedJavaType.Representation.ObjectHub), metaAccess, graph); + ConstantNode typeHub = ConstantNode.forConstant(type.getObjectHub(), metaAccess, graph); LoadHubNode receiverHub = graph.unique(LoadHubNode.create(nonNullReceiver, typeHub.getKind())); CompareNode typeCheck = CompareNode.createCompareNode(graph, Condition.EQ, receiverHub, typeHub);