changeset 18361:6ac7e9c85be6

Split getEncoding into two methods.
author Roland Schatz <roland.schatz@oracle.com>
date Wed, 12 Nov 2014 16:59:39 +0100
parents 6a5dc0bbebe7
children ea0fbb571466
files graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/TestResolvedJavaType.java graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ResolvedJavaType.java graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/BaselineBytecodeParser.java graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBytecodeLIRBuilder.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/DefaultHotSpotLoweringProvider.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectTypeImpl.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedPrimitiveType.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ObjectGetClassNode.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ReflectionGetCallerClassNode.java graal/com.oracle.graal.java/src/com/oracle/graal/java/AbstractBytecodeParser.java graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/LoadHubNode.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/TypeSwitchNode.java graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/info/MultiTypeGuardInlineInfo.java graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/info/TypeGuardInlineInfo.java
diffstat 15 files changed, 40 insertions(+), 64 deletions(-) [+]
line wrap: on
line diff
--- 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",
--- 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.
--- 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");
     }
--- 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
--- 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);
     }
 
--- 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
--- 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
--- 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());
                 }
             }
--- 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;
             }
--- 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);
             }
--- 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);
                 }
             }
 
--- 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()));
         }
     }
--- 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
--- 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));
--- 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);