Mercurial > hg > truffle
annotate graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/InstalledCodeExecuteHelperTest.java @ 15529:c5ce68561b75
Fix stamp of LoweredAtomicReadAndWriteNode to only inherit kind from written value.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Tue, 06 May 2014 04:07:30 +0200 |
parents | db4254246f9a |
children | d3fc4779fc60 |
rev | line source |
---|---|
8564
bbd8167f21f9
Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff
changeset
|
1 /* |
bbd8167f21f9
Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff
changeset
|
2 * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved. |
bbd8167f21f9
Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
bbd8167f21f9
Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff
changeset
|
4 * |
bbd8167f21f9
Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
bbd8167f21f9
Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
bbd8167f21f9
Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
bbd8167f21f9
Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff
changeset
|
8 * |
bbd8167f21f9
Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
bbd8167f21f9
Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
bbd8167f21f9
Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
bbd8167f21f9
Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
bbd8167f21f9
Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff
changeset
|
13 * accompanied this code). |
bbd8167f21f9
Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff
changeset
|
14 * |
bbd8167f21f9
Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
bbd8167f21f9
Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
bbd8167f21f9
Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
bbd8167f21f9
Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff
changeset
|
18 * |
bbd8167f21f9
Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
bbd8167f21f9
Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
bbd8167f21f9
Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff
changeset
|
21 * questions. |
bbd8167f21f9
Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff
changeset
|
22 */ |
8944
e7766460ddb3
Move tests into *.test packages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8582
diff
changeset
|
23 package com.oracle.graal.hotspot.test; |
8564
bbd8167f21f9
Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff
changeset
|
24 |
9040
640996823a81
InstalledCode intrinsification fixes
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
9025
diff
changeset
|
25 import static com.oracle.graal.api.meta.MetaUtil.*; |
640996823a81
InstalledCode intrinsification fixes
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
9025
diff
changeset
|
26 import static java.lang.reflect.Modifier.*; |
640996823a81
InstalledCode intrinsification fixes
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
9025
diff
changeset
|
27 |
8564
bbd8167f21f9
Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff
changeset
|
28 import java.lang.reflect.*; |
bbd8167f21f9
Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff
changeset
|
29 |
9040
640996823a81
InstalledCode intrinsification fixes
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
9025
diff
changeset
|
30 import org.junit.*; |
640996823a81
InstalledCode intrinsification fixes
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
9025
diff
changeset
|
31 |
9041 | 32 import com.oracle.graal.api.code.*; |
8564
bbd8167f21f9
Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff
changeset
|
33 import com.oracle.graal.api.meta.*; |
bbd8167f21f9
Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff
changeset
|
34 import com.oracle.graal.api.runtime.*; |
bbd8167f21f9
Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff
changeset
|
35 import com.oracle.graal.compiler.test.*; |
bbd8167f21f9
Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff
changeset
|
36 import com.oracle.graal.hotspot.meta.*; |
9040
640996823a81
InstalledCode intrinsification fixes
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
9025
diff
changeset
|
37 import com.oracle.graal.nodes.*; |
12488
1a4dc163cd0a
abstracted HotSpotGraalRuntime as a RuntimeProvider which removes the recent selector addition to the Graal capabilities API and also makes Truffle independent of the graal.hotspot project (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents:
12049
diff
changeset
|
38 import com.oracle.graal.runtime.*; |
8564
bbd8167f21f9
Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff
changeset
|
39 |
bbd8167f21f9
Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff
changeset
|
40 public class InstalledCodeExecuteHelperTest extends GraalCompilerTest { |
bbd8167f21f9
Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff
changeset
|
41 |
9044
5eab174fb727
Remove non-test from InstalledCodeExecuteHelperTest
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
9042
diff
changeset
|
42 private static final int ITERATIONS = 100000; |
12049
3cd7b1a27645
rename: metaAccessProvider -> metaAccess
Doug Simon <doug.simon@oracle.com>
parents:
11959
diff
changeset
|
43 private final MetaAccessProvider metaAccess; |
9040
640996823a81
InstalledCode intrinsification fixes
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
9025
diff
changeset
|
44 Object[] argsToBind; |
8564
bbd8167f21f9
Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff
changeset
|
45 |
9040
640996823a81
InstalledCode intrinsification fixes
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
9025
diff
changeset
|
46 public InstalledCodeExecuteHelperTest() { |
12488
1a4dc163cd0a
abstracted HotSpotGraalRuntime as a RuntimeProvider which removes the recent selector addition to the Graal capabilities API and also makes Truffle independent of the graal.hotspot project (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents:
12049
diff
changeset
|
47 this.metaAccess = Graal.getRequiredCapability(RuntimeProvider.class).getHostBackend().getProviders().getMetaAccess(); |
9040
640996823a81
InstalledCode intrinsification fixes
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
9025
diff
changeset
|
48 } |
8564
bbd8167f21f9
Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff
changeset
|
49 |
9040
640996823a81
InstalledCode intrinsification fixes
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
9025
diff
changeset
|
50 @Test |
9041 | 51 public void test1() throws NoSuchMethodException, SecurityException, InvalidInstalledCodeException { |
14991
64dcb92ee75a
Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
13614
diff
changeset
|
52 final Method fooMethod = InstalledCodeExecuteHelperTest.class.getMethod("foo"); |
12049
3cd7b1a27645
rename: metaAccessProvider -> metaAccess
Doug Simon <doug.simon@oracle.com>
parents:
11959
diff
changeset
|
53 final HotSpotResolvedJavaMethod fooJavaMethod = (HotSpotResolvedJavaMethod) metaAccess.lookupJavaMethod(fooMethod); |
9040
640996823a81
InstalledCode intrinsification fixes
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
9025
diff
changeset
|
54 final HotSpotInstalledCode fooCode = (HotSpotInstalledCode) getCode(fooJavaMethod, parse(fooMethod)); |
8564
bbd8167f21f9
Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff
changeset
|
55 |
9040
640996823a81
InstalledCode intrinsification fixes
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
9025
diff
changeset
|
56 argsToBind = new Object[]{fooCode}; |
8564
bbd8167f21f9
Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff
changeset
|
57 |
9040
640996823a81
InstalledCode intrinsification fixes
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
9025
diff
changeset
|
58 final Method benchmarkMethod = InstalledCodeExecuteHelperTest.class.getMethod("benchmark", HotSpotInstalledCode.class); |
12049
3cd7b1a27645
rename: metaAccessProvider -> metaAccess
Doug Simon <doug.simon@oracle.com>
parents:
11959
diff
changeset
|
59 final ResolvedJavaMethod benchmarkJavaMethod = metaAccess.lookupJavaMethod(benchmarkMethod); |
9040
640996823a81
InstalledCode intrinsification fixes
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
9025
diff
changeset
|
60 final HotSpotInstalledCode installedBenchmarkCode = (HotSpotInstalledCode) getCode(benchmarkJavaMethod, parse(benchmarkMethod)); |
8564
bbd8167f21f9
Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff
changeset
|
61 |
9040
640996823a81
InstalledCode intrinsification fixes
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
9025
diff
changeset
|
62 Assert.assertEquals(Integer.valueOf(42), benchmark(fooCode)); |
8564
bbd8167f21f9
Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff
changeset
|
63 |
9040
640996823a81
InstalledCode intrinsification fixes
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
9025
diff
changeset
|
64 Assert.assertEquals(Integer.valueOf(42), installedBenchmarkCode.executeVarargs(argsToBind[0])); |
8564
bbd8167f21f9
Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff
changeset
|
65 |
bbd8167f21f9
Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff
changeset
|
66 } |
bbd8167f21f9
Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff
changeset
|
67 |
9041 | 68 public static Integer benchmark(HotSpotInstalledCode code) throws InvalidInstalledCodeException { |
9040
640996823a81
InstalledCode intrinsification fixes
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
9025
diff
changeset
|
69 int val = 0; |
9044
5eab174fb727
Remove non-test from InstalledCodeExecuteHelperTest
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
9042
diff
changeset
|
70 for (int j = 0; j < 100; j++) { |
5eab174fb727
Remove non-test from InstalledCodeExecuteHelperTest
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
9042
diff
changeset
|
71 for (int i = 0; i < ITERATIONS; i++) { |
14991
64dcb92ee75a
Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
13614
diff
changeset
|
72 val = (Integer) code.executeVarargs(); |
9044
5eab174fb727
Remove non-test from InstalledCodeExecuteHelperTest
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
9042
diff
changeset
|
73 } |
9040
640996823a81
InstalledCode intrinsification fixes
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
9025
diff
changeset
|
74 } |
640996823a81
InstalledCode intrinsification fixes
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
9025
diff
changeset
|
75 return val; |
640996823a81
InstalledCode intrinsification fixes
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
9025
diff
changeset
|
76 } |
640996823a81
InstalledCode intrinsification fixes
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
9025
diff
changeset
|
77 |
14991
64dcb92ee75a
Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
13614
diff
changeset
|
78 public static Integer foo() { |
8564
bbd8167f21f9
Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff
changeset
|
79 return 42; |
bbd8167f21f9
Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff
changeset
|
80 } |
bbd8167f21f9
Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff
changeset
|
81 |
9040
640996823a81
InstalledCode intrinsification fixes
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
9025
diff
changeset
|
82 @Override |
640996823a81
InstalledCode intrinsification fixes
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
9025
diff
changeset
|
83 protected StructuredGraph parse(Method m) { |
640996823a81
InstalledCode intrinsification fixes
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
9025
diff
changeset
|
84 StructuredGraph graph = super.parse(m); |
640996823a81
InstalledCode intrinsification fixes
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
9025
diff
changeset
|
85 if (argsToBind != null) { |
640996823a81
InstalledCode intrinsification fixes
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
9025
diff
changeset
|
86 Object receiver = isStatic(m.getModifiers()) ? null : this; |
640996823a81
InstalledCode intrinsification fixes
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
9025
diff
changeset
|
87 Object[] args = argsWithReceiver(receiver, argsToBind); |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
9044
diff
changeset
|
88 JavaType[] parameterTypes = signatureToTypes(getMetaAccess().lookupJavaMethod(m)); |
9040
640996823a81
InstalledCode intrinsification fixes
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
9025
diff
changeset
|
89 assert parameterTypes.length == args.length; |
640996823a81
InstalledCode intrinsification fixes
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
9025
diff
changeset
|
90 for (int i = 0; i < argsToBind.length; i++) { |
13614
0774f3303c2e
rename LocalNode to ParameterNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
12488
diff
changeset
|
91 ParameterNode param = graph.getParameter(i); |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14991
diff
changeset
|
92 Constant c = HotSpotObjectConstant.forBoxedValue(parameterTypes[i].getKind(), argsToBind[i]); |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
9044
diff
changeset
|
93 ConstantNode replacement = ConstantNode.forConstant(c, getMetaAccess(), graph); |
13614
0774f3303c2e
rename LocalNode to ParameterNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
12488
diff
changeset
|
94 param.replaceAtUsages(replacement); |
9040
640996823a81
InstalledCode intrinsification fixes
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
9025
diff
changeset
|
95 } |
640996823a81
InstalledCode intrinsification fixes
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
9025
diff
changeset
|
96 } |
640996823a81
InstalledCode intrinsification fixes
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
9025
diff
changeset
|
97 return graph; |
8564
bbd8167f21f9
Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff
changeset
|
98 } |
bbd8167f21f9
Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff
changeset
|
99 } |