annotate graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java @ 13226:0b4d38339708

moved CompilationResult metric updating out from TargetMethodAssembler.finish()
author Doug Simon <doug.simon@oracle.com>
date Tue, 03 Dec 2013 10:08:35 +0100
parents f83540edfcd4
children 1a66453f73db
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1 /*
4281
62cb0e636094 Copyright fixes
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4278
diff changeset
2 * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
4 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
8 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
13 * accompanied this code).
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
14 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
18 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
21 * questions.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
22 */
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
23 package com.oracle.graal.compiler;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
24
11504
be283d587cfc moved IntrinsificationsEnabled and IntrinsificationsDisabled to new GraalCompiler.Options class
Doug Simon <doug.simon@oracle.com>
parents: 11491
diff changeset
25 import static com.oracle.graal.compiler.GraalCompiler.Options.*;
11491
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 11487
diff changeset
26 import static com.oracle.graal.compiler.MethodFilter.*;
9864
063a712fe8d8 converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 9855
diff changeset
27 import static com.oracle.graal.phases.GraalOptions.*;
063a712fe8d8 converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 9855
diff changeset
28
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
29 import java.util.*;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
30
6317
3ee3eb48e683 Clean up ComputeLinearScanOrder. Rename to ComputeBlockOrder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6316
diff changeset
31 import com.oracle.graal.alloc.*;
5510
426c605c9d3c Move cri.ci to api.code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5507
diff changeset
32 import com.oracle.graal.api.code.*;
13226
0b4d38339708 moved CompilationResult metric updating out from TargetMethodAssembler.finish()
Doug Simon <doug.simon@oracle.com>
parents: 13225
diff changeset
33 import com.oracle.graal.api.code.CompilationResult.*;
9621
e97dc9bbfedc introduced installedCodeOwner parameter of type ResolvedJavaMethod to GraalCompiler.compileGraph to properly distinguish the source method of a graph from the method under which the code compiled for the graph will be installed
Doug Simon <doug.simon@oracle.com>
parents: 9615
diff changeset
34 import com.oracle.graal.api.meta.*;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
35 import com.oracle.graal.compiler.alloc.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
36 import com.oracle.graal.compiler.gen.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
37 import com.oracle.graal.compiler.target.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
38 import com.oracle.graal.debug.*;
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
39 import com.oracle.graal.debug.Debug.Scope;
11487
21738e530332 added metrics for timing front-end, back-end and code installation (GRAAL-448)
Doug Simon <doug.simon@oracle.com>
parents: 10937
diff changeset
40 import com.oracle.graal.debug.internal.*;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
41 import com.oracle.graal.lir.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
42 import com.oracle.graal.lir.asm.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
43 import com.oracle.graal.nodes.*;
6529
2e96dc4eb8e2 renamed package: com.oracle.graal.lir.cfg -> com.oracle.graal.nodes.cfg
Doug Simon <doug.simon@oracle.com>
parents: 6526
diff changeset
44 import com.oracle.graal.nodes.cfg.*;
5720
46ad94a0574a moved everything from com.oracle.graal.nodes.cri into com.oracle.graal.nodes.spi
Doug Simon <doug.simon@oracle.com>
parents: 5718
diff changeset
45 import com.oracle.graal.nodes.spi.*;
9238
8f01fe16e473 refactorings and cleanups for the removal of FixedNode.probability
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9234
diff changeset
46 import com.oracle.graal.nodes.util.*;
11504
be283d587cfc moved IntrinsificationsEnabled and IntrinsificationsDisabled to new GraalCompiler.Options class
Doug Simon <doug.simon@oracle.com>
parents: 11491
diff changeset
47 import com.oracle.graal.options.*;
6525
2c913b643422 rename packages in graal.phases to match project name
Doug Simon <doug.simon@oracle.com>
parents: 6524
diff changeset
48 import com.oracle.graal.phases.*;
6650
ea38da80dd29 refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents: 6587
diff changeset
49 import com.oracle.graal.phases.PhasePlan.PhasePosition;
6526
ee651c726397 split phases out of graal.phases project into graal.phases.common project
Doug Simon <doug.simon@oracle.com>
parents: 6525
diff changeset
50 import com.oracle.graal.phases.common.*;
9238
8f01fe16e473 refactorings and cleanups for the removal of FixedNode.probability
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9234
diff changeset
51 import com.oracle.graal.phases.graph.*;
6525
2c913b643422 rename packages in graal.phases to match project name
Doug Simon <doug.simon@oracle.com>
parents: 6524
diff changeset
52 import com.oracle.graal.phases.schedule.*;
9001
94583d9eead8 HighTier phase suite.
Roland Schatz <roland.schatz@oracle.com>
parents: 8983
diff changeset
53 import com.oracle.graal.phases.tiers.*;
12054
bba234a1670e grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 12052
diff changeset
54 import com.oracle.graal.phases.util.*;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
55
9615
1089d63ef168 removed 'method' parameter from GraalCompiler.compiledMethod() and renamed the latter to 'compileGraph'.
Doug Simon <doug.simon@oracle.com>
parents: 9614
diff changeset
56 /**
1089d63ef168 removed 'method' parameter from GraalCompiler.compiledMethod() and renamed the latter to 'compileGraph'.
Doug Simon <doug.simon@oracle.com>
parents: 9614
diff changeset
57 * Static methods for orchestrating the compilation of a {@linkplain StructuredGraph graph}.
1089d63ef168 removed 'method' parameter from GraalCompiler.compiledMethod() and renamed the latter to 'compileGraph'.
Doug Simon <doug.simon@oracle.com>
parents: 9614
diff changeset
58 */
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
59 public class GraalCompiler {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
60
11487
21738e530332 added metrics for timing front-end, back-end and code installation (GRAAL-448)
Doug Simon <doug.simon@oracle.com>
parents: 10937
diff changeset
61 private static final DebugTimer FrontEnd = Debug.timer("FrontEnd");
21738e530332 added metrics for timing front-end, back-end and code installation (GRAAL-448)
Doug Simon <doug.simon@oracle.com>
parents: 10937
diff changeset
62 private static final DebugTimer BackEnd = Debug.timer("BackEnd");
21738e530332 added metrics for timing front-end, back-end and code installation (GRAAL-448)
Doug Simon <doug.simon@oracle.com>
parents: 10937
diff changeset
63
11504
be283d587cfc moved IntrinsificationsEnabled and IntrinsificationsDisabled to new GraalCompiler.Options class
Doug Simon <doug.simon@oracle.com>
parents: 11491
diff changeset
64 /**
be283d587cfc moved IntrinsificationsEnabled and IntrinsificationsDisabled to new GraalCompiler.Options class
Doug Simon <doug.simon@oracle.com>
parents: 11491
diff changeset
65 * The set of positive filters specified by the {@code -G:IntrinsificationsEnabled} option. To
be283d587cfc moved IntrinsificationsEnabled and IntrinsificationsDisabled to new GraalCompiler.Options class
Doug Simon <doug.simon@oracle.com>
parents: 11491
diff changeset
66 * enable a fast path in {@link #shouldIntrinsify(JavaMethod)}, this field is {@code null} when
be283d587cfc moved IntrinsificationsEnabled and IntrinsificationsDisabled to new GraalCompiler.Options class
Doug Simon <doug.simon@oracle.com>
parents: 11491
diff changeset
67 * no enabling/disabling filters are specified.
be283d587cfc moved IntrinsificationsEnabled and IntrinsificationsDisabled to new GraalCompiler.Options class
Doug Simon <doug.simon@oracle.com>
parents: 11491
diff changeset
68 */
11491
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 11487
diff changeset
69 private static final MethodFilter[] positiveIntrinsificationFilter;
11504
be283d587cfc moved IntrinsificationsEnabled and IntrinsificationsDisabled to new GraalCompiler.Options class
Doug Simon <doug.simon@oracle.com>
parents: 11491
diff changeset
70
be283d587cfc moved IntrinsificationsEnabled and IntrinsificationsDisabled to new GraalCompiler.Options class
Doug Simon <doug.simon@oracle.com>
parents: 11491
diff changeset
71 /**
be283d587cfc moved IntrinsificationsEnabled and IntrinsificationsDisabled to new GraalCompiler.Options class
Doug Simon <doug.simon@oracle.com>
parents: 11491
diff changeset
72 * The set of negative filters specified by the {@code -G:IntrinsificationsDisabled} option.
be283d587cfc moved IntrinsificationsEnabled and IntrinsificationsDisabled to new GraalCompiler.Options class
Doug Simon <doug.simon@oracle.com>
parents: 11491
diff changeset
73 */
11491
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 11487
diff changeset
74 private static final MethodFilter[] negativeIntrinsificationFilter;
11504
be283d587cfc moved IntrinsificationsEnabled and IntrinsificationsDisabled to new GraalCompiler.Options class
Doug Simon <doug.simon@oracle.com>
parents: 11491
diff changeset
75
be283d587cfc moved IntrinsificationsEnabled and IntrinsificationsDisabled to new GraalCompiler.Options class
Doug Simon <doug.simon@oracle.com>
parents: 11491
diff changeset
76 static class Options {
be283d587cfc moved IntrinsificationsEnabled and IntrinsificationsDisabled to new GraalCompiler.Options class
Doug Simon <doug.simon@oracle.com>
parents: 11491
diff changeset
77
be283d587cfc moved IntrinsificationsEnabled and IntrinsificationsDisabled to new GraalCompiler.Options class
Doug Simon <doug.simon@oracle.com>
parents: 11491
diff changeset
78 // @formatter:off
be283d587cfc moved IntrinsificationsEnabled and IntrinsificationsDisabled to new GraalCompiler.Options class
Doug Simon <doug.simon@oracle.com>
parents: 11491
diff changeset
79 /**
be283d587cfc moved IntrinsificationsEnabled and IntrinsificationsDisabled to new GraalCompiler.Options class
Doug Simon <doug.simon@oracle.com>
parents: 11491
diff changeset
80 * @see MethodFilter
be283d587cfc moved IntrinsificationsEnabled and IntrinsificationsDisabled to new GraalCompiler.Options class
Doug Simon <doug.simon@oracle.com>
parents: 11491
diff changeset
81 */
be283d587cfc moved IntrinsificationsEnabled and IntrinsificationsDisabled to new GraalCompiler.Options class
Doug Simon <doug.simon@oracle.com>
parents: 11491
diff changeset
82 @Option(help = "Pattern for method(s) to which intrinsification (if available) will be applied. " +
be283d587cfc moved IntrinsificationsEnabled and IntrinsificationsDisabled to new GraalCompiler.Options class
Doug Simon <doug.simon@oracle.com>
parents: 11491
diff changeset
83 "By default, all available intrinsifications are applied except for methods matched " +
be283d587cfc moved IntrinsificationsEnabled and IntrinsificationsDisabled to new GraalCompiler.Options class
Doug Simon <doug.simon@oracle.com>
parents: 11491
diff changeset
84 "by IntrinsificationsDisabled. See MethodFilter class for pattern syntax.")
be283d587cfc moved IntrinsificationsEnabled and IntrinsificationsDisabled to new GraalCompiler.Options class
Doug Simon <doug.simon@oracle.com>
parents: 11491
diff changeset
85 public static final OptionValue<String> IntrinsificationsEnabled = new OptionValue<>(null);
be283d587cfc moved IntrinsificationsEnabled and IntrinsificationsDisabled to new GraalCompiler.Options class
Doug Simon <doug.simon@oracle.com>
parents: 11491
diff changeset
86 /**
be283d587cfc moved IntrinsificationsEnabled and IntrinsificationsDisabled to new GraalCompiler.Options class
Doug Simon <doug.simon@oracle.com>
parents: 11491
diff changeset
87 * @see MethodFilter
be283d587cfc moved IntrinsificationsEnabled and IntrinsificationsDisabled to new GraalCompiler.Options class
Doug Simon <doug.simon@oracle.com>
parents: 11491
diff changeset
88 */
be283d587cfc moved IntrinsificationsEnabled and IntrinsificationsDisabled to new GraalCompiler.Options class
Doug Simon <doug.simon@oracle.com>
parents: 11491
diff changeset
89 @Option(help = "Pattern for method(s) to which intrinsification will not be applied. " +
be283d587cfc moved IntrinsificationsEnabled and IntrinsificationsDisabled to new GraalCompiler.Options class
Doug Simon <doug.simon@oracle.com>
parents: 11491
diff changeset
90 "See MethodFilter class for pattern syntax.")
11871
69a527047c40 fix, simplify and enable ObjectClone intrinsification
Lukas Stadler <lukas.stadler@jku.at>
parents: 11833
diff changeset
91 public static final OptionValue<String> IntrinsificationsDisabled = new OptionValue<>(null);
11504
be283d587cfc moved IntrinsificationsEnabled and IntrinsificationsDisabled to new GraalCompiler.Options class
Doug Simon <doug.simon@oracle.com>
parents: 11491
diff changeset
92 // @formatter:on
be283d587cfc moved IntrinsificationsEnabled and IntrinsificationsDisabled to new GraalCompiler.Options class
Doug Simon <doug.simon@oracle.com>
parents: 11491
diff changeset
93
be283d587cfc moved IntrinsificationsEnabled and IntrinsificationsDisabled to new GraalCompiler.Options class
Doug Simon <doug.simon@oracle.com>
parents: 11491
diff changeset
94 }
be283d587cfc moved IntrinsificationsEnabled and IntrinsificationsDisabled to new GraalCompiler.Options class
Doug Simon <doug.simon@oracle.com>
parents: 11491
diff changeset
95
11491
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 11487
diff changeset
96 static {
11504
be283d587cfc moved IntrinsificationsEnabled and IntrinsificationsDisabled to new GraalCompiler.Options class
Doug Simon <doug.simon@oracle.com>
parents: 11491
diff changeset
97 if (IntrinsificationsDisabled.getValue() != null) {
be283d587cfc moved IntrinsificationsEnabled and IntrinsificationsDisabled to new GraalCompiler.Options class
Doug Simon <doug.simon@oracle.com>
parents: 11491
diff changeset
98 negativeIntrinsificationFilter = parse(IntrinsificationsDisabled.getValue());
11491
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 11487
diff changeset
99 } else {
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 11487
diff changeset
100 negativeIntrinsificationFilter = null;
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 11487
diff changeset
101 }
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 11487
diff changeset
102
11504
be283d587cfc moved IntrinsificationsEnabled and IntrinsificationsDisabled to new GraalCompiler.Options class
Doug Simon <doug.simon@oracle.com>
parents: 11491
diff changeset
103 if (Options.IntrinsificationsEnabled.getValue() != null) {
be283d587cfc moved IntrinsificationsEnabled and IntrinsificationsDisabled to new GraalCompiler.Options class
Doug Simon <doug.simon@oracle.com>
parents: 11491
diff changeset
104 positiveIntrinsificationFilter = parse(IntrinsificationsEnabled.getValue());
11491
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 11487
diff changeset
105 } else if (negativeIntrinsificationFilter != null) {
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 11487
diff changeset
106 positiveIntrinsificationFilter = new MethodFilter[0];
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 11487
diff changeset
107 } else {
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 11487
diff changeset
108 positiveIntrinsificationFilter = null;
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 11487
diff changeset
109 }
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 11487
diff changeset
110 }
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 11487
diff changeset
111
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 11487
diff changeset
112 /**
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 11487
diff changeset
113 * Determines if a given method should be intrinsified based on the values of
11504
be283d587cfc moved IntrinsificationsEnabled and IntrinsificationsDisabled to new GraalCompiler.Options class
Doug Simon <doug.simon@oracle.com>
parents: 11491
diff changeset
114 * {@link Options#IntrinsificationsEnabled} and {@link Options#IntrinsificationsDisabled}.
11491
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 11487
diff changeset
115 */
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 11487
diff changeset
116 public static boolean shouldIntrinsify(JavaMethod method) {
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 11487
diff changeset
117 if (positiveIntrinsificationFilter == null) {
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 11487
diff changeset
118 return true;
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 11487
diff changeset
119 }
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 11487
diff changeset
120 if (positiveIntrinsificationFilter.length == 0 || matches(positiveIntrinsificationFilter, method)) {
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 11487
diff changeset
121 return negativeIntrinsificationFilter == null || !matches(negativeIntrinsificationFilter, method);
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 11487
diff changeset
122 }
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 11487
diff changeset
123 return false;
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 11487
diff changeset
124 }
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 11487
diff changeset
125
9615
1089d63ef168 removed 'method' parameter from GraalCompiler.compiledMethod() and renamed the latter to 'compileGraph'.
Doug Simon <doug.simon@oracle.com>
parents: 9614
diff changeset
126 /**
1089d63ef168 removed 'method' parameter from GraalCompiler.compiledMethod() and renamed the latter to 'compileGraph'.
Doug Simon <doug.simon@oracle.com>
parents: 9614
diff changeset
127 * Requests compilation of a given graph.
1089d63ef168 removed 'method' parameter from GraalCompiler.compiledMethod() and renamed the latter to 'compileGraph'.
Doug Simon <doug.simon@oracle.com>
parents: 9614
diff changeset
128 *
1089d63ef168 removed 'method' parameter from GraalCompiler.compiledMethod() and renamed the latter to 'compileGraph'.
Doug Simon <doug.simon@oracle.com>
parents: 9614
diff changeset
129 * @param graph the graph to be compiled
1089d63ef168 removed 'method' parameter from GraalCompiler.compiledMethod() and renamed the latter to 'compileGraph'.
Doug Simon <doug.simon@oracle.com>
parents: 9614
diff changeset
130 * @param cc the calling convention for calls to the code compiled for {@code graph}
9621
e97dc9bbfedc introduced installedCodeOwner parameter of type ResolvedJavaMethod to GraalCompiler.compileGraph to properly distinguish the source method of a graph from the method under which the code compiled for the graph will be installed
Doug Simon <doug.simon@oracle.com>
parents: 9615
diff changeset
131 * @param installedCodeOwner the method the compiled code will be
e97dc9bbfedc introduced installedCodeOwner parameter of type ResolvedJavaMethod to GraalCompiler.compileGraph to properly distinguish the source method of a graph from the method under which the code compiled for the graph will be installed
Doug Simon <doug.simon@oracle.com>
parents: 9615
diff changeset
132 * {@linkplain InstalledCode#getMethod() associated} with once installed. This
e97dc9bbfedc introduced installedCodeOwner parameter of type ResolvedJavaMethod to GraalCompiler.compileGraph to properly distinguish the source method of a graph from the method under which the code compiled for the graph will be installed
Doug Simon <doug.simon@oracle.com>
parents: 9615
diff changeset
133 * argument can be null.
9615
1089d63ef168 removed 'method' parameter from GraalCompiler.compiledMethod() and renamed the latter to 'compileGraph'.
Doug Simon <doug.simon@oracle.com>
parents: 9614
diff changeset
134 * @return the result of the compilation
1089d63ef168 removed 'method' parameter from GraalCompiler.compiledMethod() and renamed the latter to 'compileGraph'.
Doug Simon <doug.simon@oracle.com>
parents: 9614
diff changeset
135 */
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
136 public static <T extends CompilationResult> T compileGraph(StructuredGraph graph, CallingConvention cc, ResolvedJavaMethod installedCodeOwner, Providers providers, Backend backend,
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
137 TargetDescription target, GraphCache cache, PhasePlan plan, OptimisticOptimizations optimisticOpts, SpeculationLog speculationLog, Suites suites, T compilationResult) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
138 try (Scope s = Debug.scope("GraalCompiler", graph, providers.getCodeCache())) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
139 compileGraphNoScope(graph, cc, installedCodeOwner, providers, backend, target, cache, plan, optimisticOpts, speculationLog, suites, compilationResult);
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
140 } catch (Throwable e) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
141 throw Debug.handle(e);
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
142 }
12544
c69d0a705553 improved debug scope context when compiling Truffle IR graphs by making a Truffle compilable masquerade as a JavaMethod
Doug Simon <doug.simon@oracle.com>
parents: 12488
diff changeset
143 return compilationResult;
c69d0a705553 improved debug scope context when compiling Truffle IR graphs by making a Truffle compilable masquerade as a JavaMethod
Doug Simon <doug.simon@oracle.com>
parents: 12488
diff changeset
144 }
6316
2e25b9c14b84 Temporarily remove experimental register allocators.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5891
diff changeset
145
12544
c69d0a705553 improved debug scope context when compiling Truffle IR graphs by making a Truffle compilable masquerade as a JavaMethod
Doug Simon <doug.simon@oracle.com>
parents: 12488
diff changeset
146 /**
c69d0a705553 improved debug scope context when compiling Truffle IR graphs by making a Truffle compilable masquerade as a JavaMethod
Doug Simon <doug.simon@oracle.com>
parents: 12488
diff changeset
147 * Same as {@link #compileGraph} but without entering a
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
148 * {@linkplain Debug#scope(String, Object...) debug scope}.
12544
c69d0a705553 improved debug scope context when compiling Truffle IR graphs by making a Truffle compilable masquerade as a JavaMethod
Doug Simon <doug.simon@oracle.com>
parents: 12488
diff changeset
149 */
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
150 public static <T extends CompilationResult> T compileGraphNoScope(StructuredGraph graph, CallingConvention cc, ResolvedJavaMethod installedCodeOwner, Providers providers, Backend backend,
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
151 TargetDescription target, GraphCache cache, PhasePlan plan, OptimisticOptimizations optimisticOpts, SpeculationLog speculationLog, Suites suites, T compilationResult) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
152 Assumptions assumptions = new Assumptions(OptAssumptions.getValue());
6316
2e25b9c14b84 Temporarily remove experimental register allocators.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5891
diff changeset
153
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
154 LIR lir = null;
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
155 try (Scope s = Debug.scope("FrontEnd"); TimerCloseable a = FrontEnd.start()) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
156 lir = emitHIR(providers, target, graph, assumptions, cache, plan, optimisticOpts, speculationLog, suites);
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
157 } catch (Throwable e) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
158 throw Debug.handle(e);
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
159 }
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
160 try (TimerCloseable a = BackEnd.start()) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
161 LIRGenerator lirGen = null;
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
162 try (Scope s = Debug.scope("BackEnd", lir)) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
163 lirGen = emitLIR(backend, target, lir, graph, cc);
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
164 } catch (Throwable e) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
165 throw Debug.handle(e);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
166 }
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
167 try (Scope s = Debug.scope("CodeGen", lirGen)) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
168 emitCode(backend, getLeafGraphIdArray(graph), assumptions, lirGen, compilationResult, installedCodeOwner);
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
169 } catch (Throwable e) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
170 throw Debug.handle(e);
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
171 }
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
172 } catch (Throwable e) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
173 throw Debug.handle(e);
12544
c69d0a705553 improved debug scope context when compiling Truffle IR graphs by making a Truffle compilable masquerade as a JavaMethod
Doug Simon <doug.simon@oracle.com>
parents: 12488
diff changeset
174 }
8281
8fde1be81b2d LIRGenerator is transmitted across backend passes instead of just the LIR so that backend-specific, per-compilation information can be attached to the backend-specific LIRGenerator object
Doug Simon <doug.simon@oracle.com>
parents: 8271
diff changeset
175
8fde1be81b2d LIRGenerator is transmitted across backend passes instead of just the LIR so that backend-specific, per-compilation information can be attached to the backend-specific LIRGenerator object
Doug Simon <doug.simon@oracle.com>
parents: 8271
diff changeset
176 return compilationResult;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
177 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
178
7660
0b646334c5f7 keep track of leafGraphIds only at the StructuredGraph level (see GRAAL-60)
Lukas Stadler <lukas.stadler@jku.at>
parents: 7539
diff changeset
179 private static long[] getLeafGraphIdArray(StructuredGraph graph) {
0b646334c5f7 keep track of leafGraphIds only at the StructuredGraph level (see GRAAL-60)
Lukas Stadler <lukas.stadler@jku.at>
parents: 7539
diff changeset
180 long[] leafGraphIdArray = new long[graph.getLeafGraphIds().size() + 1];
0b646334c5f7 keep track of leafGraphIds only at the StructuredGraph level (see GRAAL-60)
Lukas Stadler <lukas.stadler@jku.at>
parents: 7539
diff changeset
181 int i = 0;
0b646334c5f7 keep track of leafGraphIds only at the StructuredGraph level (see GRAAL-60)
Lukas Stadler <lukas.stadler@jku.at>
parents: 7539
diff changeset
182 leafGraphIdArray[i++] = graph.graphId();
0b646334c5f7 keep track of leafGraphIds only at the StructuredGraph level (see GRAAL-60)
Lukas Stadler <lukas.stadler@jku.at>
parents: 7539
diff changeset
183 for (long id : graph.getLeafGraphIds()) {
0b646334c5f7 keep track of leafGraphIds only at the StructuredGraph level (see GRAAL-60)
Lukas Stadler <lukas.stadler@jku.at>
parents: 7539
diff changeset
184 leafGraphIdArray[i++] = id;
0b646334c5f7 keep track of leafGraphIds only at the StructuredGraph level (see GRAAL-60)
Lukas Stadler <lukas.stadler@jku.at>
parents: 7539
diff changeset
185 }
0b646334c5f7 keep track of leafGraphIds only at the StructuredGraph level (see GRAAL-60)
Lukas Stadler <lukas.stadler@jku.at>
parents: 7539
diff changeset
186 return leafGraphIdArray;
0b646334c5f7 keep track of leafGraphIds only at the StructuredGraph level (see GRAAL-60)
Lukas Stadler <lukas.stadler@jku.at>
parents: 7539
diff changeset
187 }
0b646334c5f7 keep track of leafGraphIds only at the StructuredGraph level (see GRAAL-60)
Lukas Stadler <lukas.stadler@jku.at>
parents: 7539
diff changeset
188
4265
4643ccd37dac * removed CiStatistics
Lukas Stadler <lukas.stadler@jku.at>
parents: 4263
diff changeset
189 /**
4643ccd37dac * removed CiStatistics
Lukas Stadler <lukas.stadler@jku.at>
parents: 4263
diff changeset
190 * Builds the graph, optimizes it.
4643ccd37dac * removed CiStatistics
Lukas Stadler <lukas.stadler@jku.at>
parents: 4263
diff changeset
191 */
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
192 public static LIR emitHIR(Providers providers, TargetDescription target, StructuredGraph graph, Assumptions assumptions, GraphCache cache, PhasePlan plan, OptimisticOptimizations optimisticOpts,
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
193 SpeculationLog speculationLog, Suites suites) {
8217
dce9cefed571 Draft speculation log.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8207
diff changeset
194
dce9cefed571 Draft speculation log.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8207
diff changeset
195 if (speculationLog != null) {
dce9cefed571 Draft speculation log.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8207
diff changeset
196 speculationLog.snapshot();
dce9cefed571 Draft speculation log.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8207
diff changeset
197 }
4353
043bec543161 More work on debug framework. Removed concept of GraalContext.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4352
diff changeset
198
043bec543161 More work on debug framework. Removed concept of GraalContext.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4352
diff changeset
199 if (graph.start().next() == null) {
043bec543161 More work on debug framework. Removed concept of GraalContext.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4352
diff changeset
200 plan.runPhases(PhasePosition.AFTER_PARSING, graph);
043bec543161 More work on debug framework. Removed concept of GraalContext.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4352
diff changeset
201 new DeadCodeEliminationPhase().apply(graph);
043bec543161 More work on debug framework. Removed concept of GraalContext.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4352
diff changeset
202 } else {
043bec543161 More work on debug framework. Removed concept of GraalContext.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4352
diff changeset
203 Debug.dump(graph, "initial state");
043bec543161 More work on debug framework. Removed concept of GraalContext.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4352
diff changeset
204 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
205
12054
bba234a1670e grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 12052
diff changeset
206 HighTierContext highTierContext = new HighTierContext(providers, assumptions, cache, plan, optimisticOpts);
9968
3df534c97af1 Create Suites instance in runtime.
Roland Schatz <roland.schatz@oracle.com>
parents: 9967
diff changeset
207 suites.getHighTier().apply(graph, highTierContext);
12687
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12544
diff changeset
208 graph.maybeCompress();
8600
c423a5fd8ac7 Cull frame states before lowering.
Roland Schatz <roland.schatz@oracle.com>
parents: 8560
diff changeset
209
12054
bba234a1670e grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 12052
diff changeset
210 MidTierContext midTierContext = new MidTierContext(providers, assumptions, target, optimisticOpts);
9968
3df534c97af1 Create Suites instance in runtime.
Roland Schatz <roland.schatz@oracle.com>
parents: 9967
diff changeset
211 suites.getMidTier().apply(graph, midTierContext);
12687
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12544
diff changeset
212 graph.maybeCompress();
8534
4f33d1871dca pipeline: canonicalize after ConditionalElimination and EliminatePartiallyRedundantGuards
Bernhard Urban <bernhard.urban@jku.at>
parents: 8506
diff changeset
213
12054
bba234a1670e grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 12052
diff changeset
214 LowTierContext lowTierContext = new LowTierContext(providers, assumptions, target);
9968
3df534c97af1 Create Suites instance in runtime.
Roland Schatz <roland.schatz@oracle.com>
parents: 9967
diff changeset
215 suites.getLowTier().apply(graph, lowTierContext);
12687
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12544
diff changeset
216 graph.maybeCompress();
9954
fd0e5587a07d Avoid storing statistics about OSR compilations.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9916
diff changeset
217
fd0e5587a07d Avoid storing statistics about OSR compilations.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9916
diff changeset
218 // we do not want to store statistics about OSR compilations because it may prevent inlining
10055
9469034773b2 Fixed an issue concerning statistics for OSR compilations.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 10009
diff changeset
219 if (!graph.isOSR()) {
9954
fd0e5587a07d Avoid storing statistics about OSR compilations.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9916
diff changeset
220 InliningPhase.storeStatisticsAfterLowTier(graph);
fd0e5587a07d Avoid storing statistics about OSR compilations.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9916
diff changeset
221 }
9264
3df022b2eebe LowTier phase suite.
Roland Schatz <roland.schatz@oracle.com>
parents: 9251
diff changeset
222
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
223 SchedulePhase schedule = new SchedulePhase();
4353
043bec543161 More work on debug framework. Removed concept of GraalContext.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4352
diff changeset
224 schedule.apply(graph);
4522
cf13124efdd9 Restructure phi functions in LIR; Re-enabled C1Visualizer output
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4477
diff changeset
225 Debug.dump(schedule, "final schedule");
4265
4643ccd37dac * removed CiStatistics
Lukas Stadler <lukas.stadler@jku.at>
parents: 4263
diff changeset
226
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
227 Block[] blocks = schedule.getCFG().getBlocks();
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
228 Block startBlock = schedule.getCFG().getStartBlock();
4353
043bec543161 More work on debug framework. Removed concept of GraalContext.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4352
diff changeset
229 assert startBlock != null;
7497
0f8c6dbf68be Code clean up and documentation for ComputeBlockOrder class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7493
diff changeset
230 assert startBlock.getPredecessorCount() == 0;
4265
4643ccd37dac * removed CiStatistics
Lukas Stadler <lukas.stadler@jku.at>
parents: 4263
diff changeset
231
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
232 try (Scope s = Debug.scope("ComputeLinearScanOrder")) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
233 NodesToDoubles nodeProbabilities = new ComputeProbabilityClosure(graph).apply();
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
234 List<Block> codeEmittingOrder = ComputeBlockOrder.computeCodeEmittingOrder(blocks.length, startBlock, nodeProbabilities);
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
235 List<Block> linearScanOrder = ComputeBlockOrder.computeLinearScanOrder(blocks.length, startBlock, nodeProbabilities);
4265
4643ccd37dac * removed CiStatistics
Lukas Stadler <lukas.stadler@jku.at>
parents: 4263
diff changeset
236
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
237 LIR lir = new LIR(schedule.getCFG(), schedule.getBlockToNodesMap(), linearScanOrder, codeEmittingOrder);
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
238 Debug.dump(lir, "After linear scan order");
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
239 return lir;
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
240 } catch (Throwable e) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
241 throw Debug.handle(e);
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
242 }
7307
dc3e86fd3be1 Introduce cutomization capability for canonicalizer.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7246
diff changeset
243
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
244 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
245
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
246 private static void emitBlock(LIRGenerator lirGen, Block b) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
247 if (lirGen.lir.lir(b) == null) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
248 for (Block pred : b.getPredecessors()) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
249 if (!b.isLoopHeader() || !pred.isLoopEnd()) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
250 emitBlock(lirGen, pred);
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
251 }
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
252 }
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
253 lirGen.doBlock(b);
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
254 }
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
255 }
6316
2e25b9c14b84 Temporarily remove experimental register allocators.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5891
diff changeset
256
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
257 public static LIRGenerator emitLIR(Backend backend, TargetDescription target, LIR lir, StructuredGraph graph, CallingConvention cc) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
258 FrameMap frameMap = backend.newFrameMap();
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
259 LIRGenerator lirGen = backend.newLIRGenerator(graph, frameMap, cc, lir);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
260
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
261 try (Scope s = Debug.scope("LIRGen", lirGen)) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
262 for (Block b : lir.linearScanOrder()) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
263 emitBlock(lirGen, b);
4265
4643ccd37dac * removed CiStatistics
Lukas Stadler <lukas.stadler@jku.at>
parents: 4263
diff changeset
264 }
7370
39a4192ae632 Experiment with new block order for LSRA.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7348
diff changeset
265
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
266 Debug.dump(lir, "After LIR generation");
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
267 } catch (Throwable e) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
268 throw Debug.handle(e);
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
269 }
4265
4643ccd37dac * removed CiStatistics
Lukas Stadler <lukas.stadler@jku.at>
parents: 4263
diff changeset
270
8282
59744882ddeb moved logic for reserving a special area/slot in a frame (e.g., for use during deoptimization) out of FrameMap and into platform specific backend class
Doug Simon <doug.simon@oracle.com>
parents: 8281
diff changeset
271 lirGen.beforeRegisterAllocation();
59744882ddeb moved logic for reserving a special area/slot in a frame (e.g., for use during deoptimization) out of FrameMap and into platform specific backend class
Doug Simon <doug.simon@oracle.com>
parents: 8281
diff changeset
272
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
273 try (Scope s = Debug.scope("Allocator")) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
274 if (backend.shouldAllocateRegisters()) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
275 new LinearScan(target, lir, lirGen, frameMap).allocate();
4265
4643ccd37dac * removed CiStatistics
Lukas Stadler <lukas.stadler@jku.at>
parents: 4263
diff changeset
276 }
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
277 } catch (Throwable e) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
278 throw Debug.handle(e);
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
279 }
8281
8fde1be81b2d LIRGenerator is transmitted across backend passes instead of just the LIR so that backend-specific, per-compilation information can be attached to the backend-specific LIRGenerator object
Doug Simon <doug.simon@oracle.com>
parents: 8271
diff changeset
280 return lirGen;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
281 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
282
9621
e97dc9bbfedc introduced installedCodeOwner parameter of type ResolvedJavaMethod to GraalCompiler.compileGraph to properly distinguish the source method of a graph from the method under which the code compiled for the graph will be installed
Doug Simon <doug.simon@oracle.com>
parents: 9615
diff changeset
283 public static void emitCode(Backend backend, long[] leafGraphIds, Assumptions assumptions, LIRGenerator lirGen, CompilationResult compilationResult, ResolvedJavaMethod installedCodeOwner) {
8281
8fde1be81b2d LIRGenerator is transmitted across backend passes instead of just the LIR so that backend-specific, per-compilation information can be attached to the backend-specific LIRGenerator object
Doug Simon <doug.simon@oracle.com>
parents: 8271
diff changeset
284 TargetMethodAssembler tasm = backend.newAssembler(lirGen, compilationResult);
9621
e97dc9bbfedc introduced installedCodeOwner parameter of type ResolvedJavaMethod to GraalCompiler.compileGraph to properly distinguish the source method of a graph from the method under which the code compiled for the graph will be installed
Doug Simon <doug.simon@oracle.com>
parents: 9615
diff changeset
285 backend.emitCode(tasm, lirGen, installedCodeOwner);
13225
f83540edfcd4 removed PTXTargetMethodAssembler
Doug Simon <doug.simon@oracle.com>
parents: 13224
diff changeset
286 tasm.finish();
7064
8d16b9b2c51e first part of refactoring the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7063
diff changeset
287 if (!assumptions.isEmpty()) {
13224
7086a2fe7370 renamed TargetMethodAssembler.finishTargetMethod to finalize and made its return type void
Doug Simon <doug.simon@oracle.com>
parents: 13197
diff changeset
288 compilationResult.setAssumptions(assumptions);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
289 }
13224
7086a2fe7370 renamed TargetMethodAssembler.finishTargetMethod to finalize and made its return type void
Doug Simon <doug.simon@oracle.com>
parents: 13197
diff changeset
290 compilationResult.setLeafGraphIds(leafGraphIds);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
291
13226
0b4d38339708 moved CompilationResult metric updating out from TargetMethodAssembler.finish()
Doug Simon <doug.simon@oracle.com>
parents: 13225
diff changeset
292 if (Debug.isMeterEnabled()) {
0b4d38339708 moved CompilationResult metric updating out from TargetMethodAssembler.finish()
Doug Simon <doug.simon@oracle.com>
parents: 13225
diff changeset
293 List<DataPatch> ldp = compilationResult.getDataReferences();
0b4d38339708 moved CompilationResult metric updating out from TargetMethodAssembler.finish()
Doug Simon <doug.simon@oracle.com>
parents: 13225
diff changeset
294 DebugMetric[] dms = new DebugMetric[Kind.values().length];
0b4d38339708 moved CompilationResult metric updating out from TargetMethodAssembler.finish()
Doug Simon <doug.simon@oracle.com>
parents: 13225
diff changeset
295 for (int i = 0; i < dms.length; i++) {
0b4d38339708 moved CompilationResult metric updating out from TargetMethodAssembler.finish()
Doug Simon <doug.simon@oracle.com>
parents: 13225
diff changeset
296 dms[i] = Debug.metric("DataPatches-" + Kind.values()[i].toString());
0b4d38339708 moved CompilationResult metric updating out from TargetMethodAssembler.finish()
Doug Simon <doug.simon@oracle.com>
parents: 13225
diff changeset
297 }
0b4d38339708 moved CompilationResult metric updating out from TargetMethodAssembler.finish()
Doug Simon <doug.simon@oracle.com>
parents: 13225
diff changeset
298 DebugMetric dmRaw = Debug.metric("DataPatches-raw");
0b4d38339708 moved CompilationResult metric updating out from TargetMethodAssembler.finish()
Doug Simon <doug.simon@oracle.com>
parents: 13225
diff changeset
299
0b4d38339708 moved CompilationResult metric updating out from TargetMethodAssembler.finish()
Doug Simon <doug.simon@oracle.com>
parents: 13225
diff changeset
300 for (DataPatch dp : ldp) {
0b4d38339708 moved CompilationResult metric updating out from TargetMethodAssembler.finish()
Doug Simon <doug.simon@oracle.com>
parents: 13225
diff changeset
301 if (dp.constant != null) {
0b4d38339708 moved CompilationResult metric updating out from TargetMethodAssembler.finish()
Doug Simon <doug.simon@oracle.com>
parents: 13225
diff changeset
302 dms[dp.constant.getKind().ordinal()].add(1);
0b4d38339708 moved CompilationResult metric updating out from TargetMethodAssembler.finish()
Doug Simon <doug.simon@oracle.com>
parents: 13225
diff changeset
303 } else {
0b4d38339708 moved CompilationResult metric updating out from TargetMethodAssembler.finish()
Doug Simon <doug.simon@oracle.com>
parents: 13225
diff changeset
304 dmRaw.add(1);
0b4d38339708 moved CompilationResult metric updating out from TargetMethodAssembler.finish()
Doug Simon <doug.simon@oracle.com>
parents: 13225
diff changeset
305 }
0b4d38339708 moved CompilationResult metric updating out from TargetMethodAssembler.finish()
Doug Simon <doug.simon@oracle.com>
parents: 13225
diff changeset
306 }
0b4d38339708 moved CompilationResult metric updating out from TargetMethodAssembler.finish()
Doug Simon <doug.simon@oracle.com>
parents: 13225
diff changeset
307
0b4d38339708 moved CompilationResult metric updating out from TargetMethodAssembler.finish()
Doug Simon <doug.simon@oracle.com>
parents: 13225
diff changeset
308 Debug.metric("CompilationResults").increment();
0b4d38339708 moved CompilationResult metric updating out from TargetMethodAssembler.finish()
Doug Simon <doug.simon@oracle.com>
parents: 13225
diff changeset
309 Debug.metric("CodeBytesEmitted").add(compilationResult.getTargetCodeSize());
0b4d38339708 moved CompilationResult metric updating out from TargetMethodAssembler.finish()
Doug Simon <doug.simon@oracle.com>
parents: 13225
diff changeset
310 Debug.metric("InfopointsEmitted").add(compilationResult.getInfopoints().size());
0b4d38339708 moved CompilationResult metric updating out from TargetMethodAssembler.finish()
Doug Simon <doug.simon@oracle.com>
parents: 13225
diff changeset
311 Debug.metric("DataPatches").add(ldp.size());
0b4d38339708 moved CompilationResult metric updating out from TargetMethodAssembler.finish()
Doug Simon <doug.simon@oracle.com>
parents: 13225
diff changeset
312 Debug.metric("ExceptionHandlersEmitted").add(compilationResult.getExceptionHandlers().size());
0b4d38339708 moved CompilationResult metric updating out from TargetMethodAssembler.finish()
Doug Simon <doug.simon@oracle.com>
parents: 13225
diff changeset
313 }
0b4d38339708 moved CompilationResult metric updating out from TargetMethodAssembler.finish()
Doug Simon <doug.simon@oracle.com>
parents: 13225
diff changeset
314
12472
85d03b72f269 added support disassembling during CodeGen
Doug Simon <doug.simon@oracle.com>
parents: 12362
diff changeset
315 if (Debug.isLogEnabled()) {
13224
7086a2fe7370 renamed TargetMethodAssembler.finishTargetMethod to finalize and made its return type void
Doug Simon <doug.simon@oracle.com>
parents: 13197
diff changeset
316 Debug.log("%s", backend.getProviders().getCodeCache().disassemble(compilationResult, null));
12472
85d03b72f269 added support disassembling during CodeGen
Doug Simon <doug.simon@oracle.com>
parents: 12362
diff changeset
317 }
85d03b72f269 added support disassembling during CodeGen
Doug Simon <doug.simon@oracle.com>
parents: 12362
diff changeset
318
13224
7086a2fe7370 renamed TargetMethodAssembler.finishTargetMethod to finalize and made its return type void
Doug Simon <doug.simon@oracle.com>
parents: 13197
diff changeset
319 Debug.dump(compilationResult, "After code generation");
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
320 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
321 }