# HG changeset patch # User Gilles Duboscq # Date 1354101514 -3600 # Node ID fa3c8913d674bd5d1a700d377121a23e0e852c9d # Parent 3e61ffb9ce29fdb945635085f885c13271116b89 Remove unsafe mirror() method from HotSpotTypeUnresolved. Use a HotSpotMirrorHolder interface for HotSpotResolvedJavaType and HotSpotTypePrimitive which always hold valid mirrors. diff -r 3e61ffb9ce29 -r fa3c8913d674 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotRuntimeInterpreterInterface.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotRuntimeInterpreterInterface.java Wed Nov 28 09:01:39 2012 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotRuntimeInterpreterInterface.java Wed Nov 28 12:18:34 2012 +0100 @@ -41,7 +41,7 @@ } public Class< ? > getMirror(ResolvedJavaType type) { - return ((HotSpotJavaType) type).mirror(); + return ((HotSpotMirrorHolder) type).mirror(); } public native Object invoke(ResolvedJavaMethod method, Object... args); diff -r 3e61ffb9ce29 -r fa3c8913d674 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotJavaType.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotJavaType.java Wed Nov 28 09:01:39 2012 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotJavaType.java Wed Nov 28 12:18:34 2012 +0100 @@ -41,6 +41,4 @@ public final String getName() { return name; } - - public abstract Class mirror(); } diff -r 3e61ffb9ce29 -r fa3c8913d674 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMirrorHolder.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMirrorHolder.java Wed Nov 28 12:18:34 2012 +0100 @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2012, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.hotspot.meta; + + +public interface HotSpotMirrorHolder { + Class mirror(); +} diff -r 3e61ffb9ce29 -r fa3c8913d674 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java Wed Nov 28 09:01:39 2012 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java Wed Nov 28 12:18:34 2012 +0100 @@ -263,7 +263,7 @@ int count = sig.getParameterCount(false); Class< ? >[] result = new Class< ? >[count]; for (int i = 0; i < result.length; ++i) { - result[i] = ((HotSpotJavaType) sig.getParameterType(i, holder).resolve(holder)).mirror(); + result[i] = ((HotSpotMirrorHolder) sig.getParameterType(i, holder).resolve(holder)).mirror(); } return result; } diff -r 3e61ffb9ce29 -r fa3c8913d674 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaType.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaType.java Wed Nov 28 09:01:39 2012 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaType.java Wed Nov 28 12:18:34 2012 +0100 @@ -37,7 +37,7 @@ /** * Implementation of {@link JavaType} for resolved non-primitive HotSpot classes. */ -public final class HotSpotResolvedJavaType extends HotSpotJavaType implements ResolvedJavaType { +public final class HotSpotResolvedJavaType extends HotSpotJavaType implements ResolvedJavaType, HotSpotMirrorHolder { private static final long serialVersionUID = 3481514353553840471L; diff -r 3e61ffb9ce29 -r fa3c8913d674 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java Wed Nov 28 09:01:39 2012 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java Wed Nov 28 12:18:34 2012 +0100 @@ -607,12 +607,14 @@ ValueNode obj = (ValueNode) parameters.get(0); ObjectStamp stamp = (ObjectStamp) obj.stamp(); if (stamp.nonNull() && stamp.isExactType()) { - StructuredGraph graph = new StructuredGraph(); HotSpotJavaType type = (HotSpotJavaType) stamp.type(); - ValueNode result = ConstantNode.forObject(type.mirror(), this, graph); - ReturnNode ret = graph.add(new ReturnNode(result)); - graph.start().setNext(ret); - return graph; + if (type instanceof HotSpotMirrorHolder) { + StructuredGraph graph = new StructuredGraph(); + ValueNode result = ConstantNode.forObject(((HotSpotMirrorHolder) type).mirror(), this, graph); + ReturnNode ret = graph.add(new ReturnNode(result)); + graph.start().setNext(ret); + return graph; + } } StructuredGraph graph = new StructuredGraph(); LocalNode receiver = graph.unique(new LocalNode(0, StampFactory.objectNonNull())); diff -r 3e61ffb9ce29 -r fa3c8913d674 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotTypePrimitive.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotTypePrimitive.java Wed Nov 28 09:01:39 2012 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotTypePrimitive.java Wed Nov 28 12:18:34 2012 +0100 @@ -31,7 +31,7 @@ /** * Implementation of {@link JavaType} for primitive HotSpot types. */ -public final class HotSpotTypePrimitive extends HotSpotJavaType implements ResolvedJavaType { +public final class HotSpotTypePrimitive extends HotSpotJavaType implements ResolvedJavaType, HotSpotMirrorHolder { private static final long serialVersionUID = -6208552348908071473L; private final Kind kind; diff -r 3e61ffb9ce29 -r fa3c8913d674 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotTypeUnresolved.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotTypeUnresolved.java Wed Nov 28 09:01:39 2012 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotTypeUnresolved.java Wed Nov 28 12:18:34 2012 +0100 @@ -87,9 +87,4 @@ public ResolvedJavaType resolve(ResolvedJavaType accessingClass) { return (ResolvedJavaType) HotSpotGraalRuntime.getInstance().lookupType(getName(), (HotSpotResolvedJavaType) accessingClass, true); } - - @Override - public Class mirror() { - return ((HotSpotJavaType) resolve(null)).mirror(); - } }