annotate graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/InstalledCodeExecuteHelperTest.java @ 8944:e7766460ddb3

Move tests into *.test packages.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Tue, 09 Apr 2013 15:26:29 +0200
parents graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/InstalledCodeExecuteHelperTest.java@6a5a980714d4
children 7fee8bd5d2bd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
bbd8167f21f9 Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
25 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
26
bbd8167f21f9 Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
27 import org.junit.*;
bbd8167f21f9 Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
28
bbd8167f21f9 Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
29 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
30 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
31 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
32 import com.oracle.graal.hotspot.meta.*;
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.nodes.spi.*;
bbd8167f21f9 Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
34
bbd8167f21f9 Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
35 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
36
8577
6388d983385a Renamings of installed code replacements
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 8564
diff changeset
37 private static final int ITERATIONS = 100000000;
8564
bbd8167f21f9 Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
38
bbd8167f21f9 Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
39 @Ignore
bbd8167f21f9 Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
40 @Test
bbd8167f21f9 Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
41 public void test1() throws NoSuchMethodException, SecurityException {
bbd8167f21f9 Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
42
bbd8167f21f9 Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
43 final Method benchrMethod = InstalledCodeExecuteHelperTest.class.getMethod("bench", long.class, long.class);
bbd8167f21f9 Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
44 final ResolvedJavaMethod benchJavaMethod = Graal.getRequiredCapability(GraalCodeCacheProvider.class).lookupJavaMethod(benchrMethod);
bbd8167f21f9 Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
45 HotSpotInstalledCode benchCode = (HotSpotInstalledCode) getCode(benchJavaMethod, parse(benchrMethod));
bbd8167f21f9 Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
46
bbd8167f21f9 Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
47 final Method wrapperMethod = InstalledCodeExecuteHelperTest.class.getMethod("executeWrapper", long.class, long.class, Object.class, Object.class, Object.class);
bbd8167f21f9 Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
48 final ResolvedJavaMethod wrapperJavaMethod = Graal.getRequiredCapability(GraalCodeCacheProvider.class).lookupJavaMethod(wrapperMethod);
bbd8167f21f9 Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
49 HotSpotInstalledCode wrapperCode = (HotSpotInstalledCode) getCode(wrapperJavaMethod, parse(wrapperMethod));
bbd8167f21f9 Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
50
bbd8167f21f9 Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
51 final Method fooMethod = InstalledCodeExecuteHelperTest.class.getMethod("foo", Object.class, Object.class, Object.class);
bbd8167f21f9 Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
52 final HotSpotResolvedJavaMethod fooJavaMethod = (HotSpotResolvedJavaMethod) Graal.getRequiredCapability(GraalCodeCacheProvider.class).lookupJavaMethod(fooMethod);
bbd8167f21f9 Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
53 HotSpotInstalledCode fooCode = (HotSpotInstalledCode) getCode(fooJavaMethod, parse(fooMethod));
bbd8167f21f9 Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
54
bbd8167f21f9 Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
55 System.out.println(wrapperCode.executeVarargs(fooCode.getnmethod(), fooJavaMethod.getMetaspaceMethod(), null, null, null));
bbd8167f21f9 Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
56
bbd8167f21f9 Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
57 long nmethod = fooCode.getnmethod();
bbd8167f21f9 Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
58 long metaspacemethod = fooJavaMethod.getMetaspaceMethod();
bbd8167f21f9 Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
59
bbd8167f21f9 Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
60 System.out.println("Without replaced InstalledCode.execute:" + bench(nmethod, metaspacemethod));
bbd8167f21f9 Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
61
bbd8167f21f9 Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
62 System.out.println("WITH replaced InstalledCode.execute:" + benchCode.executeVarargs(nmethod, metaspacemethod));
bbd8167f21f9 Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
63
bbd8167f21f9 Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
64 }
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 public static Long bench(long nmethod, long metaspacemethod) {
bbd8167f21f9 Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
67 long start = System.currentTimeMillis();
bbd8167f21f9 Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
68
bbd8167f21f9 Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
69 for (int i = 0; i < ITERATIONS; i++) {
bbd8167f21f9 Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
70 HotSpotInstalledCode.executeHelper(nmethod, metaspacemethod, null, null, null);
bbd8167f21f9 Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
71 }
bbd8167f21f9 Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
72
bbd8167f21f9 Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
73 long end = System.currentTimeMillis();
bbd8167f21f9 Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
74 return (end - start);
bbd8167f21f9 Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
75 }
bbd8167f21f9 Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
76
bbd8167f21f9 Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
77 public static Object foo(@SuppressWarnings("unused") Object a1, @SuppressWarnings("unused") Object a2, @SuppressWarnings("unused") Object a3) {
bbd8167f21f9 Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
78 return 42;
bbd8167f21f9 Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
79 }
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 public static Object executeWrapper(long nmethod, long metaspaceMethod, Object arg1, Object arg2, Object arg3) {
bbd8167f21f9 Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
82 return HotSpotInstalledCode.executeHelper(nmethod, metaspaceMethod, arg1, arg2, arg3);
bbd8167f21f9 Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
83 }
bbd8167f21f9 Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
84
bbd8167f21f9 Added executeHelper to HotSpotInstalled code that gets replaced by a MethodSubstitution
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
diff changeset
85 }