Mercurial > hg > truffle
changeset 19325:1b51524ff1c9
Graph builder plugin for isInstance.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Thu, 12 Feb 2015 20:28:45 +0100 |
parents | 51b6ea17aebe |
children | 85b21777ce42 |
files | graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotGraphBuilderPluginsProvider.java |
diffstat | 1 files changed, 13 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 20:44:08 2015 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotGraphBuilderPluginsProvider.java Thu Feb 12 20:28:45 2015 +0100 @@ -75,6 +75,19 @@ return false; } }); + r.register2("isInstance", 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()) { + builder.push(Kind.Boolean.getStackKind(), builder.append(ConstantNode.forBoolean(type.isInstance(object.asJavaConstant())))); + return true; + } + } + return false; + } + }); + // StableOptionValue.class r = new Registration(plugins, metaAccess, StableOptionValue.class); r.register1("getValue", Receiver.class, new InvocationPlugin() {