Mercurial > hg > graal-compiler
annotate graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/InfopointReasonTest.java @ 11959:23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Thu, 10 Oct 2013 16:14:55 +0200 |
parents | a0566c8dcabf |
children | 0fc653a9e019 |
rev | line source |
---|---|
9003
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
1 /* |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
4 * |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
8 * |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
14 * |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
18 * |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
21 * questions. |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
22 */ |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
23 package com.oracle.graal.compiler.test; |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
24 |
9612
66db0353f55a
compilation is explicitly given a CallingConvention for the graph being compiled instead of deriving it from a method
Doug Simon <doug.simon@oracle.com>
parents:
9036
diff
changeset
|
25 import static com.oracle.graal.api.code.CodeUtil.*; |
9003
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
26 import static org.junit.Assert.*; |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
27 |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
28 import java.lang.reflect.*; |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
29 |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
30 import org.junit.*; |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
31 |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
32 import com.oracle.graal.api.code.*; |
9612
66db0353f55a
compilation is explicitly given a CallingConvention for the graph being compiled instead of deriving it from a method
Doug Simon <doug.simon@oracle.com>
parents:
9036
diff
changeset
|
33 import com.oracle.graal.api.code.CallingConvention.Type; |
9003
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
34 import com.oracle.graal.api.code.CompilationResult.Call; |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
35 import com.oracle.graal.api.code.CompilationResult.Infopoint; |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
36 import com.oracle.graal.compiler.*; |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
37 import com.oracle.graal.nodes.*; |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
38 import com.oracle.graal.phases.*; |
9036
7309bde698f3
mark infopoint-related tests as long
Michael Haupt <michael.haupt@oracle.com>
parents:
9003
diff
changeset
|
39 import com.oracle.graal.test.*; |
9003
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
40 |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
41 /** |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
42 * Test that infopoints in {@link CompilationResult}s have correctly assigned reasons. |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
43 */ |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
44 public class InfopointReasonTest extends GraalCompilerTest { |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
45 |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
46 public static final String[] STRINGS = new String[]{"world", "everyone", "you"}; |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
47 |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
48 public String testMethod() { |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
49 StringBuilder sb = new StringBuilder("Hello "); |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
50 for (String s : STRINGS) { |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
51 sb.append(s).append(", "); |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
52 } |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
53 sb.replace(sb.length() - 2, sb.length(), "!"); |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
54 return sb.toString(); |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
55 } |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
56 |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
57 @Test |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
58 public void callInfopoints() { |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
59 final Method method = getMethod("testMethod"); |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
60 final StructuredGraph graph = parse(method); |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11633
diff
changeset
|
61 CallingConvention cc = getCallingConvention(getCodeCache(), Type.JavaCallee, graph.method(), false); |
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11633
diff
changeset
|
62 final CompilationResult cr = GraalCompiler.compileGraph(graph, cc, graph.method(), getMetaAccess(), getCodeCache(), replacements, backend, getCodeCache().getTarget(), null, getDefaultPhasePlan(), |
10577
9c7d9e2c8326
PTX kernel execution - no args or return value
Morris Meyer <morris.meyer@oracle.com>
parents:
9968
diff
changeset
|
63 OptimisticOptimizations.ALL, new SpeculationLog(), suites, new CompilationResult()); |
9003
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
64 for (Infopoint sp : cr.getInfopoints()) { |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
65 assertNotNull(sp.reason); |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
66 if (sp instanceof Call) { |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
67 assertEquals(InfopointReason.CALL, sp.reason); |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
68 } |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
69 } |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
70 } |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
71 |
9036
7309bde698f3
mark infopoint-related tests as long
Michael Haupt <michael.haupt@oracle.com>
parents:
9003
diff
changeset
|
72 @LongTest |
9003
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
73 public void lineInfopoints() { |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
74 final Method method = getMethod("testMethod"); |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
75 final StructuredGraph graph = parseDebug(method); |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
76 int graphLineSPs = 0; |
11633
a0566c8dcabf
removed IterableNodeType from some classes for which typed node iterators were never used or were only used in tests
Doug Simon <doug.simon@oracle.com>
parents:
10577
diff
changeset
|
77 for (InfopointNode ipn : graph.getNodes().filter(InfopointNode.class)) { |
9003
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
78 if (ipn.reason == InfopointReason.LINE_NUMBER) { |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
79 ++graphLineSPs; |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
80 } |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
81 } |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
82 assertTrue(graphLineSPs > 0); |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11633
diff
changeset
|
83 CallingConvention cc = getCallingConvention(getCodeCache(), Type.JavaCallee, graph.method(), false); |
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11633
diff
changeset
|
84 final CompilationResult cr = GraalCompiler.compileGraph(graph, cc, graph.method(), getMetaAccess(), getCodeCache(), replacements, backend, getCodeCache().getTarget(), null, getDefaultPhasePlan(true), |
10577
9c7d9e2c8326
PTX kernel execution - no args or return value
Morris Meyer <morris.meyer@oracle.com>
parents:
9968
diff
changeset
|
85 OptimisticOptimizations.ALL, new SpeculationLog(), suites, new CompilationResult()); |
9003
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
86 int lineSPs = 0; |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
87 for (Infopoint sp : cr.getInfopoints()) { |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
88 assertNotNull(sp.reason); |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
89 if (sp.reason == InfopointReason.LINE_NUMBER) { |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
90 ++lineSPs; |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
91 } |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
92 } |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
93 assertTrue(lineSPs > 0); |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
94 } |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
95 |
a8fea2979e63
eager infopoint mode (fka debug mode)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff
changeset
|
96 } |