Mercurial > hg > graal-jvmci-8
changeset 19198:5b75ec42c975
added graph builder plugin for Class.cast()
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Tue, 10 Feb 2015 14:36:36 +0100 |
parents | c75f5c9c8b6b |
children | e9e99e6f2c6b afe5d805c88a |
files | graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotGraphBuilderPluginsProvider.java |
diffstat | 1 files changed, 14 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotGraphBuilderPluginsProvider.java Tue Feb 10 14:14:53 2015 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotGraphBuilderPluginsProvider.java Tue Feb 10 14:36:36 2015 +0100 @@ -61,6 +61,20 @@ } }); + // Class.class + r = new Registration(plugins, metaAccess, Class.class); + r.register2("cast", Receiver.class, Object.class, new InvocationPlugin() { + public boolean apply(GraphBuilderContext builder, ValueNode rcvr, ValueNode object) { + if (rcvr.isConstant() && !rcvr.isNullConstant() && object.isConstant()) { + ResolvedJavaType type = builder.getConstantReflection().asJavaType(rcvr.asConstant()); + if (type != null && !type.isPrimitive() && type.isInstance(object.asJavaConstant())) { + builder.push(Kind.Object, object); + return true; + } + } + return false; + } + }); // StableOptionValue.class r = new Registration(plugins, metaAccess, StableOptionValue.class); r.register1("getValue", Receiver.class, new InvocationPlugin() {