# HG changeset patch # User Matthias Grimmer # Date 1364547506 -3600 # Node ID 6388d983385a938319b3d2871f82000a30eacb58 # Parent 645f216a00c431ccedad0b98e64829a63a495efb Renamings of installed code replacements diff -r 645f216a00c4 -r 6388d983385a graal/com.oracle.graal.rawnativecall.test/test/com/oracle/graal/rawnativecall/test/InstalledCodeExecuteHelperTest.java --- a/graal/com.oracle.graal.rawnativecall.test/test/com/oracle/graal/rawnativecall/test/InstalledCodeExecuteHelperTest.java Thu Mar 28 14:33:19 2013 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2012, 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.rawnativecall.test; - -import java.lang.reflect.*; - -import org.junit.*; - -import com.oracle.graal.api.meta.*; -import com.oracle.graal.api.runtime.*; -import com.oracle.graal.compiler.test.*; -import com.oracle.graal.hotspot.meta.*; -import com.oracle.graal.nodes.spi.*; - -public class InstalledCodeExecuteHelperTest extends GraalCompilerTest { - - private static final int ITERATIONS = 10000000; - - @Ignore - @Test - public void test1() throws NoSuchMethodException, SecurityException { - - final Method benchrMethod = InstalledCodeExecuteHelperTest.class.getMethod("bench", long.class, long.class); - final ResolvedJavaMethod benchJavaMethod = Graal.getRequiredCapability(GraalCodeCacheProvider.class).lookupJavaMethod(benchrMethod); - HotSpotInstalledCode benchCode = (HotSpotInstalledCode) getCode(benchJavaMethod, parse(benchrMethod)); - - final Method wrapperMethod = InstalledCodeExecuteHelperTest.class.getMethod("executeWrapper", long.class, long.class, Object.class, Object.class, Object.class); - final ResolvedJavaMethod wrapperJavaMethod = Graal.getRequiredCapability(GraalCodeCacheProvider.class).lookupJavaMethod(wrapperMethod); - HotSpotInstalledCode wrapperCode = (HotSpotInstalledCode) getCode(wrapperJavaMethod, parse(wrapperMethod)); - - final Method fooMethod = InstalledCodeExecuteHelperTest.class.getMethod("foo", Object.class, Object.class, Object.class); - final HotSpotResolvedJavaMethod fooJavaMethod = (HotSpotResolvedJavaMethod) Graal.getRequiredCapability(GraalCodeCacheProvider.class).lookupJavaMethod(fooMethod); - HotSpotInstalledCode fooCode = (HotSpotInstalledCode) getCode(fooJavaMethod, parse(fooMethod)); - - System.out.println(wrapperCode.executeVarargs(fooCode.getnmethod(), fooJavaMethod.getMetaspaceMethod(), null, null, null)); - - long nmethod = fooCode.getnmethod(); - long metaspacemethod = fooJavaMethod.getMetaspaceMethod(); - - System.out.println("Without replaced InstalledCode.execute:" + bench(nmethod, metaspacemethod)); - - System.out.println("WITH replaced InstalledCode.execute:" + benchCode.executeVarargs(nmethod, metaspacemethod)); - - } - - public static Long bench(long nmethod, long metaspacemethod) { - long start = System.currentTimeMillis(); - - for (int i = 0; i < ITERATIONS; i++) { - HotSpotInstalledCode.executeHelper(nmethod, metaspacemethod, null, null, null); - } - - long end = System.currentTimeMillis(); - return (end - start); - } - - public static Object foo(@SuppressWarnings("unused") Object a1, @SuppressWarnings("unused") Object a2, @SuppressWarnings("unused") Object a3) { - return 42; - } - - public static Object executeWrapper(long nmethod, long metaspaceMethod, Object arg1, Object arg2, Object arg3) { - return HotSpotInstalledCode.executeHelper(nmethod, metaspaceMethod, arg1, arg2, arg3); - } - -} diff -r 645f216a00c4 -r 6388d983385a graal/com.oracle.graal.rawnativecall/src/com/oracle/graal/rawnativecall/nodes/HotSpotInstalledCodeExecuteNode.java --- a/graal/com.oracle.graal.rawnativecall/src/com/oracle/graal/rawnativecall/nodes/HotSpotInstalledCodeExecuteNode.java Thu Mar 28 14:33:19 2013 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2011, 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.rawnativecall.nodes; - -import com.oracle.graal.api.code.*; -import com.oracle.graal.api.meta.*; -import com.oracle.graal.hotspot.nodes.*; -import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.extended.*; -import com.oracle.graal.nodes.spi.*; -import com.oracle.graal.nodes.type.*; -import com.oracle.graal.word.*; - -public class HotSpotInstalledCodeExecuteNode extends AbstractCallNode implements Lowerable { - - @Input private final ValueNode targetAddress; - @Input private final ValueNode metaspaceObject; - private final Class[] signature; - - public HotSpotInstalledCodeExecuteNode(Kind kind, ValueNode targetAddress, ValueNode metaspaceObject, Class[] signature, ValueNode arg1, ValueNode arg2, ValueNode arg3) { - super(StampFactory.forKind(kind), new ValueNode[]{arg1, arg2, arg3}); - this.targetAddress = targetAddress; - this.metaspaceObject = metaspaceObject; - this.signature = signature; - } - - @Override - public Object[] getLocationIdentities() { - return new Object[]{LocationNode.ANY_LOCATION}; - } - - @Override - public void lower(LoweringTool tool) { - replaceWithInvoke(tool); - } - - private InvokeNode replaceWithInvoke(LoweringTool tool) { - InvokeNode invoke = createInvoke(tool); - ((StructuredGraph) graph()).replaceFixedWithFixed(this, invoke); - return invoke; - } - - protected InvokeNode createInvoke(LoweringTool tool) { - ResolvedJavaMethod method = null; - try { - method = tool.getRuntime().lookupJavaMethod(HotSpotInstalledCodeExecuteNode.class.getMethod("placeholder", Object.class, Object.class, Object.class)); - } catch (NoSuchMethodException | SecurityException e) { - throw new IllegalStateException(); - } - ResolvedJavaType[] signatureTypes = new ResolvedJavaType[signature.length]; - for (int i = 0; i < signature.length; i++) { - signatureTypes[i] = tool.getRuntime().lookupJavaType(signature[i]); - } - HotSpotIndirectCallTargetNode callTarget = graph().add( - new HotSpotIndirectCallTargetNode(metaspaceObject, targetAddress, arguments, stamp(), signatureTypes, method, CallingConvention.Type.JavaCall)); - InvokeNode invoke = graph().add(new InvokeNode(callTarget, 0)); - invoke.setStateAfter(stateAfter()); - return invoke; - } - - public static Object placeholder(@SuppressWarnings("unused") Object a1, @SuppressWarnings("unused") Object a2, @SuppressWarnings("unused") Object a3) { - return 1; - } - - @NodeIntrinsic - public static native T call(@ConstantNodeParameter Kind kind, Word targetAddress, long metaspaceObject, @ConstantNodeParameter Class[] signature, Object arg1, Object arg2, Object arg3); - -} diff -r 645f216a00c4 -r 6388d983385a graal/com.oracle.graal.rawnativecall/src/com/oracle/graal/rawnativecall/replacements/HotSpotInstalledCodeIntrinsics.java --- a/graal/com.oracle.graal.rawnativecall/src/com/oracle/graal/rawnativecall/replacements/HotSpotInstalledCodeIntrinsics.java Thu Mar 28 14:33:19 2013 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2013, 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.rawnativecall.replacements; - -import com.oracle.graal.api.runtime.*; -import com.oracle.graal.phases.*; -import com.oracle.graal.replacements.*; - -@ServiceProvider(ReplacementsProvider.class) -public class HotSpotInstalledCodeIntrinsics implements ReplacementsProvider { - - @Override - public void installReplacements(ReplacementsInstaller installer) { - if (GraalOptions.IntrinsifyInstalledCodeMethods) { - installer.installSubstitutions(HotSpotInstalledCodeSubstitutions.class); - } - } -} diff -r 645f216a00c4 -r 6388d983385a graal/com.oracle.graal.rawnativecall/src/com/oracle/graal/rawnativecall/replacements/HotSpotInstalledCodeSubstitutions.java --- a/graal/com.oracle.graal.rawnativecall/src/com/oracle/graal/rawnativecall/replacements/HotSpotInstalledCodeSubstitutions.java Thu Mar 28 14:33:19 2013 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2013, 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.rawnativecall.replacements; - -import com.oracle.graal.api.meta.*; -import com.oracle.graal.api.replacements.*; -import com.oracle.graal.hotspot.meta.*; -import com.oracle.graal.hotspot.replacements.*; -import com.oracle.graal.rawnativecall.nodes.*; -import com.oracle.graal.replacements.Snippet.Fold; -import com.oracle.graal.word.*; - -@ClassSubstitution(HotSpotInstalledCode.class) -public class HotSpotInstalledCodeSubstitutions { - - @MethodSubstitution - public static Object executeHelper(long nmethod, long metaspaceMethod, final Object arg1, final Object arg2, final Object arg3) { - final int verifiedEntryPointOffset = HotSpotSnippetUtils.verifiedEntryPointOffset(); - final Word callTarget = Word.unsigned(nmethod).readWord(verifiedEntryPointOffset); - return HotSpotInstalledCodeExecuteNode.call(Kind.Object, callTarget, metaspaceMethod, getSignature(), arg1, arg2, arg3); - } - - @Fold - private static Class[] getSignature() { - return new Class[]{Object.class, Object.class, Object.class}; - } -} diff -r 645f216a00c4 -r 6388d983385a graal/com.oracle.graal.replacements.installedcode.test/test/com/oracle/graal/replacements/installedcode/test/InstalledCodeExecuteHelperTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.replacements.installedcode.test/test/com/oracle/graal/replacements/installedcode/test/InstalledCodeExecuteHelperTest.java Fri Mar 29 09:58:26 2013 +0100 @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2012, 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.replacements.installedcode.test; + +import java.lang.reflect.*; + +import org.junit.*; + +import com.oracle.graal.api.meta.*; +import com.oracle.graal.api.runtime.*; +import com.oracle.graal.compiler.test.*; +import com.oracle.graal.hotspot.meta.*; +import com.oracle.graal.nodes.spi.*; + +public class InstalledCodeExecuteHelperTest extends GraalCompilerTest { + + private static final int ITERATIONS = 100000000; + + @Ignore + @Test + public void test1() throws NoSuchMethodException, SecurityException { + + final Method benchrMethod = InstalledCodeExecuteHelperTest.class.getMethod("bench", long.class, long.class); + final ResolvedJavaMethod benchJavaMethod = Graal.getRequiredCapability(GraalCodeCacheProvider.class).lookupJavaMethod(benchrMethod); + HotSpotInstalledCode benchCode = (HotSpotInstalledCode) getCode(benchJavaMethod, parse(benchrMethod)); + + final Method wrapperMethod = InstalledCodeExecuteHelperTest.class.getMethod("executeWrapper", long.class, long.class, Object.class, Object.class, Object.class); + final ResolvedJavaMethod wrapperJavaMethod = Graal.getRequiredCapability(GraalCodeCacheProvider.class).lookupJavaMethod(wrapperMethod); + HotSpotInstalledCode wrapperCode = (HotSpotInstalledCode) getCode(wrapperJavaMethod, parse(wrapperMethod)); + + final Method fooMethod = InstalledCodeExecuteHelperTest.class.getMethod("foo", Object.class, Object.class, Object.class); + final HotSpotResolvedJavaMethod fooJavaMethod = (HotSpotResolvedJavaMethod) Graal.getRequiredCapability(GraalCodeCacheProvider.class).lookupJavaMethod(fooMethod); + HotSpotInstalledCode fooCode = (HotSpotInstalledCode) getCode(fooJavaMethod, parse(fooMethod)); + + System.out.println(wrapperCode.executeVarargs(fooCode.getnmethod(), fooJavaMethod.getMetaspaceMethod(), null, null, null)); + + long nmethod = fooCode.getnmethod(); + long metaspacemethod = fooJavaMethod.getMetaspaceMethod(); + + System.out.println("Without replaced InstalledCode.execute:" + bench(nmethod, metaspacemethod)); + + System.out.println("WITH replaced InstalledCode.execute:" + benchCode.executeVarargs(nmethod, metaspacemethod)); + + } + + public static Long bench(long nmethod, long metaspacemethod) { + long start = System.currentTimeMillis(); + + for (int i = 0; i < ITERATIONS; i++) { + HotSpotInstalledCode.executeHelper(nmethod, metaspacemethod, null, null, null); + } + + long end = System.currentTimeMillis(); + return (end - start); + } + + public static Object foo(@SuppressWarnings("unused") Object a1, @SuppressWarnings("unused") Object a2, @SuppressWarnings("unused") Object a3) { + return 42; + } + + public static Object executeWrapper(long nmethod, long metaspaceMethod, Object arg1, Object arg2, Object arg3) { + return HotSpotInstalledCode.executeHelper(nmethod, metaspaceMethod, arg1, arg2, arg3); + } + +} diff -r 645f216a00c4 -r 6388d983385a graal/com.oracle.graal.replacements.installedcode/src/com/oracle/graal/replacements/installedcode/HotSpotInstalledCodeIntrinsics.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.replacements.installedcode/src/com/oracle/graal/replacements/installedcode/HotSpotInstalledCodeIntrinsics.java Fri Mar 29 09:58:26 2013 +0100 @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2013, 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.replacements.installedcode; + +import com.oracle.graal.api.runtime.*; +import com.oracle.graal.phases.*; +import com.oracle.graal.replacements.*; + +@ServiceProvider(ReplacementsProvider.class) +public class HotSpotInstalledCodeIntrinsics implements ReplacementsProvider { + + @Override + public void installReplacements(ReplacementsInstaller installer) { + if (GraalOptions.IntrinsifyInstalledCodeMethods) { + installer.installSubstitutions(HotSpotInstalledCodeSubstitutions.class); + } + } +} diff -r 645f216a00c4 -r 6388d983385a graal/com.oracle.graal.replacements.installedcode/src/com/oracle/graal/replacements/installedcode/HotSpotInstalledCodeSubstitutions.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.replacements.installedcode/src/com/oracle/graal/replacements/installedcode/HotSpotInstalledCodeSubstitutions.java Fri Mar 29 09:58:26 2013 +0100 @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2013, 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.replacements.installedcode; + +import com.oracle.graal.api.meta.*; +import com.oracle.graal.api.replacements.*; +import com.oracle.graal.hotspot.meta.*; +import com.oracle.graal.hotspot.replacements.*; +import com.oracle.graal.replacements.Snippet.Fold; +import com.oracle.graal.replacements.installedcode.nodes.*; +import com.oracle.graal.word.*; + +@ClassSubstitution(HotSpotInstalledCode.class) +public class HotSpotInstalledCodeSubstitutions { + + @MethodSubstitution + public static Object executeHelper(long nmethod, long metaspaceMethod, final Object arg1, final Object arg2, final Object arg3) { + final int verifiedEntryPointOffset = HotSpotSnippetUtils.verifiedEntryPointOffset(); + final Word callTarget = Word.unsigned(nmethod).readWord(verifiedEntryPointOffset); + return HotSpotInstalledCodeExecuteNode.call(Kind.Object, callTarget, metaspaceMethod, getSignature(), arg1, arg2, arg3); + } + + @Fold + private static Class[] getSignature() { + return new Class[]{Object.class, Object.class, Object.class}; + } +} diff -r 645f216a00c4 -r 6388d983385a graal/com.oracle.graal.replacements.installedcode/src/com/oracle/graal/replacements/installedcode/nodes/HotSpotInstalledCodeExecuteNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.replacements.installedcode/src/com/oracle/graal/replacements/installedcode/nodes/HotSpotInstalledCodeExecuteNode.java Fri Mar 29 09:58:26 2013 +0100 @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2011, 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.replacements.installedcode.nodes; + +import com.oracle.graal.api.code.*; +import com.oracle.graal.api.meta.*; +import com.oracle.graal.hotspot.nodes.*; +import com.oracle.graal.nodes.*; +import com.oracle.graal.nodes.extended.*; +import com.oracle.graal.nodes.spi.*; +import com.oracle.graal.nodes.type.*; +import com.oracle.graal.word.*; + +public class HotSpotInstalledCodeExecuteNode extends AbstractCallNode implements Lowerable { + + @Input private final ValueNode targetAddress; + @Input private final ValueNode metaspaceObject; + private final Class[] signature; + + public HotSpotInstalledCodeExecuteNode(Kind kind, ValueNode targetAddress, ValueNode metaspaceObject, Class[] signature, ValueNode arg1, ValueNode arg2, ValueNode arg3) { + super(StampFactory.forKind(kind), new ValueNode[]{arg1, arg2, arg3}); + this.targetAddress = targetAddress; + this.metaspaceObject = metaspaceObject; + this.signature = signature; + } + + @Override + public Object[] getLocationIdentities() { + return new Object[]{LocationNode.ANY_LOCATION}; + } + + @Override + public void lower(LoweringTool tool) { + replaceWithInvoke(tool); + } + + private InvokeNode replaceWithInvoke(LoweringTool tool) { + InvokeNode invoke = createInvoke(tool); + ((StructuredGraph) graph()).replaceFixedWithFixed(this, invoke); + return invoke; + } + + protected InvokeNode createInvoke(LoweringTool tool) { + ResolvedJavaMethod method = null; + try { + method = tool.getRuntime().lookupJavaMethod(HotSpotInstalledCodeExecuteNode.class.getMethod("placeholder", Object.class, Object.class, Object.class)); + } catch (NoSuchMethodException | SecurityException e) { + throw new IllegalStateException(); + } + ResolvedJavaType[] signatureTypes = new ResolvedJavaType[signature.length]; + for (int i = 0; i < signature.length; i++) { + signatureTypes[i] = tool.getRuntime().lookupJavaType(signature[i]); + } + HotSpotIndirectCallTargetNode callTarget = graph().add( + new HotSpotIndirectCallTargetNode(metaspaceObject, targetAddress, arguments, stamp(), signatureTypes, method, CallingConvention.Type.JavaCall)); + InvokeNode invoke = graph().add(new InvokeNode(callTarget, 0)); + invoke.setStateAfter(stateAfter()); + return invoke; + } + + public static Object placeholder(@SuppressWarnings("unused") Object a1, @SuppressWarnings("unused") Object a2, @SuppressWarnings("unused") Object a3) { + return 1; + } + + @NodeIntrinsic + public static native T call(@ConstantNodeParameter Kind kind, Word targetAddress, long metaspaceObject, @ConstantNodeParameter Class[] signature, Object arg1, Object arg2, Object arg3); + +} diff -r 645f216a00c4 -r 6388d983385a mx/projects --- a/mx/projects Thu Mar 28 14:33:19 2013 +0100 +++ b/mx/projects Fri Mar 29 09:58:26 2013 +0100 @@ -23,7 +23,7 @@ library@DACAPO_SCALA@urls=http://repo.scalabench.org/snapshots/org/scalabench/benchmarks/scala-benchmark-suite/0.1.0-SNAPSHOT/scala-benchmark-suite-0.1.0-20120216.103539-3.jar distribution@GRAAL@path=graal.jar -distribution@GRAAL@dependencies=com.oracle.graal.hotspot.amd64,com.oracle.graal.hotspot.sparc, com.oracle.graal.rawnativecall +distribution@GRAAL@dependencies=com.oracle.graal.hotspot.amd64,com.oracle.graal.hotspot.sparc, com.oracle.graal.replacements.installedcode # graal.api.runtime project@com.oracle.graal.api.runtime@subDir=graal @@ -386,20 +386,20 @@ project@com.oracle.graal.asm.sparc@checkstyle=com.oracle.graal.graph project@com.oracle.graal.asm.sparc@javaCompliance=1.7 -# graal.rawnativecall -project@com.oracle.graal.rawnativecall@subDir=graal -project@com.oracle.graal.rawnativecall@sourceDirs=src -project@com.oracle.graal.rawnativecall@dependencies=com.oracle.graal.hotspot -project@com.oracle.graal.rawnativecall@checkstyle=com.oracle.graal.graph -project@com.oracle.graal.rawnativecall@annotationProcessors=com.oracle.graal.replacements.verifier, com.oracle.graal.service.processor -project@com.oracle.graal.rawnativecall@javaCompliance=1.7 +# graal.replacements.installedcode +project@com.oracle.graal.replacements.installedcode@subDir=graal +project@com.oracle.graal.replacements.installedcode@sourceDirs=src +project@com.oracle.graal.replacements.installedcode@dependencies=com.oracle.graal.hotspot +project@com.oracle.graal.replacements.installedcode@checkstyle=com.oracle.graal.graph +project@com.oracle.graal.replacements.installedcode@annotationProcessors=com.oracle.graal.replacements.verifier, com.oracle.graal.service.processor +project@com.oracle.graal.replacements.installedcode@javaCompliance=1.7 -# graal.rawnativecall.test -project@com.oracle.graal.rawnativecall.test@subDir=graal -project@com.oracle.graal.rawnativecall.test@sourceDirs=test -project@com.oracle.graal.rawnativecall.test@dependencies=com.oracle.graal.compiler.test,com.oracle.graal.hotspot -project@com.oracle.graal.rawnativecall.test@checkstyle=com.oracle.graal.graph -project@com.oracle.graal.rawnativecall.test@javaCompliance=1.7 +# graal.replacements.installedcode.test +project@com.oracle.graal.replacements.installedcode.test@subDir=graal +project@com.oracle.graal.replacements.installedcode.test@sourceDirs=test +project@com.oracle.graal.replacements.installedcode.test@dependencies=com.oracle.graal.compiler.test,com.oracle.graal.hotspot +project@com.oracle.graal.replacements.installedcode.test@checkstyle=com.oracle.graal.graph +project@com.oracle.graal.replacements.installedcode.test@javaCompliance=1.7 # truffle.api project@com.oracle.truffle.api@subDir=graal