annotate graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java @ 19234:e9e99e6f2c6b

GraalCompiler.emitBackEnd: do not box objects for scope.
author Josef Eisl <josef.eisl@jku.at>
date Tue, 10 Feb 2015 12:17:53 +0100
parents 98967b613c88
children 9f411d79ffc0
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 /*
18176
c2270ad35f57 Better construction of data section and data patches.
Roland Schatz <roland.schatz@oracle.com>
parents: 18157
diff changeset
2 * Copyright (c) 2009, 2014, 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.*;
15259
d90e5c22ba55 Move GraalOptions to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents: 15192
diff changeset
27 import static com.oracle.graal.compiler.common.GraalOptions.*;
17065
37d6d174bc40 denote certain applications of DeadCodeEliminationPhase as optional and only run them if -G:-ReduceDCE
Doug Simon <doug.simon@oracle.com>
parents: 16952
diff changeset
28 import static com.oracle.graal.phases.common.DeadCodeEliminationPhase.Optionality.*;
9864
063a712fe8d8 converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 9855
diff changeset
29
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
30 import java.util.*;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
31
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.*;
18176
c2270ad35f57 Better construction of data section and data patches.
Roland Schatz <roland.schatz@oracle.com>
parents: 18157
diff changeset
33 import com.oracle.graal.api.code.CompilationResult.ConstantReference;
14172
cd22c8dbda4f Made graph caching compilation local
Doug Simon <doug.simon@oracle.com>
parents: 14148
diff changeset
34 import com.oracle.graal.api.code.CompilationResult.DataPatch;
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
35 import com.oracle.graal.api.meta.*;
14172
cd22c8dbda4f Made graph caching compilation local
Doug Simon <doug.simon@oracle.com>
parents: 14148
diff changeset
36 import com.oracle.graal.api.meta.ProfilingInfo.TriState;
19165
b3b81dfff200 Move ComputeBlockOrder to compiler.common and delete c.o.g.alloc project.
Josef Eisl <josef.eisl@jku.at>
parents: 19092
diff changeset
37 import com.oracle.graal.compiler.common.alloc.*;
15192
644dfe49c0f4 Move packages com.oracle.graal.cfg to com.oracle.graal.compiler.common.cfg.
Josef Eisl <josef.eisl@jku.at>
parents: 15170
diff changeset
38 import com.oracle.graal.compiler.common.cfg.*;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
39 import com.oracle.graal.compiler.target.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
40 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
41 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
42 import com.oracle.graal.debug.internal.*;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
43 import com.oracle.graal.lir.*;
19166
39e99cf01468 Move LinearScan to c.o.g.lir.alloc.lsra.
Josef Eisl <josef.eisl@jku.at>
parents: 19165
diff changeset
44 import com.oracle.graal.lir.alloc.lsra.*;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
45 import com.oracle.graal.lir.asm.*;
16952
2451521ed26f Add ConstantLoadOptimization.
Josef Eisl <josef.eisl@jku.at>
parents: 15838
diff changeset
46 import com.oracle.graal.lir.constopt.*;
18443
1c92d437179b FrameMapBuilder: move into package.
Josef Eisl <josef.eisl@jku.at>
parents: 18431
diff changeset
47 import com.oracle.graal.lir.framemap.*;
15292
a38d791982e1 Move LIRGenerationResult* to graal.lir.
Josef Eisl <josef.eisl@jku.at>
parents: 15259
diff changeset
48 import com.oracle.graal.lir.gen.*;
19031
beb7c10b7747 Move StackSlotAllocators into a package.
Josef Eisl <josef.eisl@jku.at>
parents: 19028
diff changeset
49 import com.oracle.graal.lir.stackslotalloc.*;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
50 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
51 import com.oracle.graal.nodes.cfg.*;
15337
c4be3c1b2d6d Use NodeLIRBuilderTool instead of NodeLIRBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 15333
diff changeset
52 import com.oracle.graal.nodes.spi.*;
11504
be283d587cfc moved IntrinsificationsEnabled and IntrinsificationsDisabled to new GraalCompiler.Options class
Doug Simon <doug.simon@oracle.com>
parents: 11491
diff changeset
53 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
54 import com.oracle.graal.phases.*;
6526
ee651c726397 split phases out of graal.phases project into graal.phases.common project
Doug Simon <doug.simon@oracle.com>
parents: 6525
diff changeset
55 import com.oracle.graal.phases.common.*;
6525
2c913b643422 rename packages in graal.phases to match project name
Doug Simon <doug.simon@oracle.com>
parents: 6524
diff changeset
56 import com.oracle.graal.phases.schedule.*;
9001
94583d9eead8 HighTier phase suite.
Roland Schatz <roland.schatz@oracle.com>
parents: 8983
diff changeset
57 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
58 import com.oracle.graal.phases.util.*;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
59
9615
1089d63ef168 removed 'method' parameter from GraalCompiler.compiledMethod() and renamed the latter to 'compileGraph'.
Doug Simon <doug.simon@oracle.com>
parents: 9614
diff changeset
60 /**
1089d63ef168 removed 'method' parameter from GraalCompiler.compiledMethod() and renamed the latter to 'compileGraph'.
Doug Simon <doug.simon@oracle.com>
parents: 9614
diff changeset
61 * 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
62 */
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
63 public class GraalCompiler {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
64
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
65 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
66 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
67
11504
be283d587cfc moved IntrinsificationsEnabled and IntrinsificationsDisabled to new GraalCompiler.Options class
Doug Simon <doug.simon@oracle.com>
parents: 11491
diff changeset
68 /**
be283d587cfc moved IntrinsificationsEnabled and IntrinsificationsDisabled to new GraalCompiler.Options class
Doug Simon <doug.simon@oracle.com>
parents: 11491
diff changeset
69 * 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
70 * 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
71 * 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
72 */
11491
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 11487
diff changeset
73 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
74
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 * 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
77 */
11491
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 11487
diff changeset
78 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
79
be283d587cfc moved IntrinsificationsEnabled and IntrinsificationsDisabled to new GraalCompiler.Options class
Doug Simon <doug.simon@oracle.com>
parents: 11491
diff changeset
80 static class Options {
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 // @formatter:off
be283d587cfc moved IntrinsificationsEnabled and IntrinsificationsDisabled to new GraalCompiler.Options class
Doug Simon <doug.simon@oracle.com>
parents: 11491
diff changeset
83 /**
be283d587cfc moved IntrinsificationsEnabled and IntrinsificationsDisabled to new GraalCompiler.Options class
Doug Simon <doug.simon@oracle.com>
parents: 11491
diff changeset
84 * @see MethodFilter
be283d587cfc moved IntrinsificationsEnabled and IntrinsificationsDisabled to new GraalCompiler.Options class
Doug Simon <doug.simon@oracle.com>
parents: 11491
diff changeset
85 */
be283d587cfc moved IntrinsificationsEnabled and IntrinsificationsDisabled to new GraalCompiler.Options class
Doug Simon <doug.simon@oracle.com>
parents: 11491
diff changeset
86 @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
87 "By default, all available intrinsifications are applied except for methods matched " +
18674
ecb9d0cedbab First draft of option classification.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18610
diff changeset
88 "by IntrinsificationsDisabled. See MethodFilter class for pattern syntax.", type = OptionType.Debug)
11504
be283d587cfc moved IntrinsificationsEnabled and IntrinsificationsDisabled to new GraalCompiler.Options class
Doug Simon <doug.simon@oracle.com>
parents: 11491
diff changeset
89 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
90 /**
be283d587cfc moved IntrinsificationsEnabled and IntrinsificationsDisabled to new GraalCompiler.Options class
Doug Simon <doug.simon@oracle.com>
parents: 11491
diff changeset
91 * @see MethodFilter
be283d587cfc moved IntrinsificationsEnabled and IntrinsificationsDisabled to new GraalCompiler.Options class
Doug Simon <doug.simon@oracle.com>
parents: 11491
diff changeset
92 */
be283d587cfc moved IntrinsificationsEnabled and IntrinsificationsDisabled to new GraalCompiler.Options class
Doug Simon <doug.simon@oracle.com>
parents: 11491
diff changeset
93 @Option(help = "Pattern for method(s) to which intrinsification will not be applied. " +
18674
ecb9d0cedbab First draft of option classification.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18610
diff changeset
94 "See MethodFilter class for pattern syntax.", type = OptionType.Debug)
11871
69a527047c40 fix, simplify and enable ObjectClone intrinsification
Lukas Stadler <lukas.stadler@jku.at>
parents: 11833
diff changeset
95 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
96 // @formatter:on
be283d587cfc moved IntrinsificationsEnabled and IntrinsificationsDisabled to new GraalCompiler.Options class
Doug Simon <doug.simon@oracle.com>
parents: 11491
diff changeset
97
be283d587cfc moved IntrinsificationsEnabled and IntrinsificationsDisabled to new GraalCompiler.Options class
Doug Simon <doug.simon@oracle.com>
parents: 11491
diff changeset
98 }
be283d587cfc moved IntrinsificationsEnabled and IntrinsificationsDisabled to new GraalCompiler.Options class
Doug Simon <doug.simon@oracle.com>
parents: 11491
diff changeset
99
11491
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 11487
diff changeset
100 static {
11504
be283d587cfc moved IntrinsificationsEnabled and IntrinsificationsDisabled to new GraalCompiler.Options class
Doug Simon <doug.simon@oracle.com>
parents: 11491
diff changeset
101 if (IntrinsificationsDisabled.getValue() != null) {
be283d587cfc moved IntrinsificationsEnabled and IntrinsificationsDisabled to new GraalCompiler.Options class
Doug Simon <doug.simon@oracle.com>
parents: 11491
diff changeset
102 negativeIntrinsificationFilter = parse(IntrinsificationsDisabled.getValue());
11491
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 11487
diff changeset
103 } else {
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 11487
diff changeset
104 negativeIntrinsificationFilter = null;
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 11487
diff changeset
105 }
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 11487
diff changeset
106
11504
be283d587cfc moved IntrinsificationsEnabled and IntrinsificationsDisabled to new GraalCompiler.Options class
Doug Simon <doug.simon@oracle.com>
parents: 11491
diff changeset
107 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
108 positiveIntrinsificationFilter = parse(IntrinsificationsEnabled.getValue());
11491
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 11487
diff changeset
109 } else if (negativeIntrinsificationFilter != null) {
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 11487
diff changeset
110 positiveIntrinsificationFilter = new MethodFilter[0];
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 11487
diff changeset
111 } else {
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 11487
diff changeset
112 positiveIntrinsificationFilter = null;
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 11487
diff changeset
113 }
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 11487
diff changeset
114 }
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 /**
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 11487
diff changeset
117 * 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
118 * {@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
119 */
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 11487
diff changeset
120 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
121 if (positiveIntrinsificationFilter == null) {
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 11487
diff changeset
122 return true;
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 11487
diff changeset
123 }
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 11487
diff changeset
124 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
125 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
126 }
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 11487
diff changeset
127 return false;
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 11487
diff changeset
128 }
a03452edfc4d made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents: 11487
diff changeset
129
9615
1089d63ef168 removed 'method' parameter from GraalCompiler.compiledMethod() and renamed the latter to 'compileGraph'.
Doug Simon <doug.simon@oracle.com>
parents: 9614
diff changeset
130 /**
18297
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
131 * Encapsulates all the inputs to a {@linkplain GraalCompiler#compile(Request) compilation}.
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
132 */
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
133 public static class Request<T extends CompilationResult> {
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
134 public final StructuredGraph graph;
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
135 public final CallingConvention cc;
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
136 public final ResolvedJavaMethod installedCodeOwner;
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
137 public final Providers providers;
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
138 public final Backend backend;
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
139 public final TargetDescription target;
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
140 public final Map<ResolvedJavaMethod, StructuredGraph> cache;
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
141 public final PhaseSuite<HighTierContext> graphBuilderSuite;
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
142 public final OptimisticOptimizations optimisticOpts;
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
143 public final ProfilingInfo profilingInfo;
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
144 public final SpeculationLog speculationLog;
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
145 public final Suites suites;
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
146 public final T compilationResult;
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
147 public final CompilationResultBuilderFactory factory;
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
148
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
149 /**
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
150 * @param graph the graph to be compiled
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
151 * @param cc the calling convention for calls to the code compiled for {@code graph}
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
152 * @param installedCodeOwner the method the compiled code will be associated with once
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
153 * installed. This argument can be null.
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
154 * @param providers
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
155 * @param backend
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
156 * @param target
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
157 * @param cache
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
158 * @param graphBuilderSuite
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
159 * @param optimisticOpts
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
160 * @param profilingInfo
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
161 * @param speculationLog
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
162 * @param suites
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
163 * @param compilationResult
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
164 * @param factory
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
165 */
19047
173bdcc85ab8 Remove unused parameter "stub" from GraalCompiler.compileGraph
Christian Wimmer <christian.wimmer@oracle.com>
parents: 19033
diff changeset
166 public Request(StructuredGraph graph, CallingConvention cc, ResolvedJavaMethod installedCodeOwner, Providers providers, Backend backend, TargetDescription target,
18297
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
167 Map<ResolvedJavaMethod, StructuredGraph> cache, PhaseSuite<HighTierContext> graphBuilderSuite, OptimisticOptimizations optimisticOpts, ProfilingInfo profilingInfo,
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
168 SpeculationLog speculationLog, Suites suites, T compilationResult, CompilationResultBuilderFactory factory) {
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
169 this.graph = graph;
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
170 this.cc = cc;
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
171 this.installedCodeOwner = installedCodeOwner;
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
172 this.providers = providers;
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
173 this.backend = backend;
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
174 this.target = target;
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
175 this.cache = cache;
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
176 this.graphBuilderSuite = graphBuilderSuite;
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
177 this.optimisticOpts = optimisticOpts;
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
178 this.profilingInfo = profilingInfo;
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
179 this.speculationLog = speculationLog;
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
180 this.suites = suites;
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
181 this.compilationResult = compilationResult;
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
182 this.factory = factory;
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
183 }
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
184
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
185 /**
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
186 * Executes this compilation request.
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
187 *
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
188 * @return the result of the compilation
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
189 */
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
190 public T execute() {
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
191 return GraalCompiler.compile(this);
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
192 }
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
193 }
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
194
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
195 /**
9615
1089d63ef168 removed 'method' parameter from GraalCompiler.compiledMethod() and renamed the latter to 'compileGraph'.
Doug Simon <doug.simon@oracle.com>
parents: 9614
diff changeset
196 * Requests compilation of a given graph.
14921
88dfaf6448e0 Remove LIRGenerationResult from NodeLIRBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 14888
diff changeset
197 *
9615
1089d63ef168 removed 'method' parameter from GraalCompiler.compiledMethod() and renamed the latter to 'compileGraph'.
Doug Simon <doug.simon@oracle.com>
parents: 9614
diff changeset
198 * @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
199 * @param cc the calling convention for calls to the code compiled for {@code graph}
15161
2c940b1a48d8 Convert InstalledCode from an interface into an abstract class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15011
diff changeset
200 * @param installedCodeOwner the method the compiled code will be associated with once
2c940b1a48d8 Convert InstalledCode from an interface into an abstract class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15011
diff changeset
201 * installed. This 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
202 * @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
203 */
19047
173bdcc85ab8 Remove unused parameter "stub" from GraalCompiler.compileGraph
Christian Wimmer <christian.wimmer@oracle.com>
parents: 19033
diff changeset
204 public static <T extends CompilationResult> T compileGraph(StructuredGraph graph, CallingConvention cc, ResolvedJavaMethod installedCodeOwner, Providers providers, Backend backend,
14172
cd22c8dbda4f Made graph caching compilation local
Doug Simon <doug.simon@oracle.com>
parents: 14148
diff changeset
205 TargetDescription target, Map<ResolvedJavaMethod, StructuredGraph> cache, PhaseSuite<HighTierContext> graphBuilderSuite, OptimisticOptimizations optimisticOpts,
cd22c8dbda4f Made graph caching compilation local
Doug Simon <doug.simon@oracle.com>
parents: 14148
diff changeset
206 ProfilingInfo profilingInfo, SpeculationLog speculationLog, Suites suites, T compilationResult, CompilationResultBuilderFactory factory) {
19047
173bdcc85ab8 Remove unused parameter "stub" from GraalCompiler.compileGraph
Christian Wimmer <christian.wimmer@oracle.com>
parents: 19033
diff changeset
207 return compile(new Request<>(graph, cc, installedCodeOwner, providers, backend, target, cache, graphBuilderSuite, optimisticOpts, profilingInfo, speculationLog, suites, compilationResult,
173bdcc85ab8 Remove unused parameter "stub" from GraalCompiler.compileGraph
Christian Wimmer <christian.wimmer@oracle.com>
parents: 19033
diff changeset
208 factory));
18297
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
209 }
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
210
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
211 /**
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
212 * Services a given compilation request.
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
213 *
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
214 * @return the result of the compilation
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
215 */
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
216 public static <T extends CompilationResult> T compile(Request<T> r) {
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
217 assert !r.graph.isFrozen();
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
218 try (Scope s0 = Debug.scope("GraalCompiler", r.graph, r.providers.getCodeCache())) {
13228
4568980f7257 removed GraalCompiler.compileGraphNoScope
Doug Simon <doug.simon@oracle.com>
parents: 13227
diff changeset
219 Assumptions assumptions = new Assumptions(OptAssumptions.getValue());
18297
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
220 SchedulePhase schedule = emitFrontEnd(r.providers, r.target, r.graph, assumptions, r.cache, r.graphBuilderSuite, r.optimisticOpts, r.profilingInfo, r.speculationLog, r.suites);
19047
173bdcc85ab8 Remove unused parameter "stub" from GraalCompiler.compileGraph
Christian Wimmer <christian.wimmer@oracle.com>
parents: 19033
diff changeset
221 emitBackEnd(r.graph, null, r.cc, r.installedCodeOwner, r.backend, r.target, r.compilationResult, r.factory, assumptions, schedule, null);
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
222 } 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
223 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
224 }
18297
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
225 return r.compilationResult;
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
226 }
6316
2e25b9c14b84 Temporarily remove experimental register allocators.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5891
diff changeset
227
13239
Doug Simon <doug.simon@oracle.com>
parents: 13229 13217
diff changeset
228 public static ProfilingInfo getProfilingInfo(StructuredGraph graph) {
13217
210f58e992a1 Use separate method profile for OSR compilations.
Roland Schatz <roland.schatz@oracle.com>
parents: 13197
diff changeset
229 if (graph.method() != null) {
210f58e992a1 Use separate method profile for OSR compilations.
Roland Schatz <roland.schatz@oracle.com>
parents: 13197
diff changeset
230 return graph.method().getProfilingInfo();
210f58e992a1 Use separate method profile for OSR compilations.
Roland Schatz <roland.schatz@oracle.com>
parents: 13197
diff changeset
231 } else {
210f58e992a1 Use separate method profile for OSR compilations.
Roland Schatz <roland.schatz@oracle.com>
parents: 13197
diff changeset
232 return DefaultProfilingInfo.get(TriState.UNKNOWN);
210f58e992a1 Use separate method profile for OSR compilations.
Roland Schatz <roland.schatz@oracle.com>
parents: 13197
diff changeset
233 }
210f58e992a1 Use separate method profile for OSR compilations.
Roland Schatz <roland.schatz@oracle.com>
parents: 13197
diff changeset
234 }
210f58e992a1 Use separate method profile for OSR compilations.
Roland Schatz <roland.schatz@oracle.com>
parents: 13197
diff changeset
235
4265
4643ccd37dac * removed CiStatistics
Lukas Stadler <lukas.stadler@jku.at>
parents: 4263
diff changeset
236 /**
4643ccd37dac * removed CiStatistics
Lukas Stadler <lukas.stadler@jku.at>
parents: 4263
diff changeset
237 * Builds the graph, optimizes it.
4643ccd37dac * removed CiStatistics
Lukas Stadler <lukas.stadler@jku.at>
parents: 4263
diff changeset
238 */
15011
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
239 public static SchedulePhase emitFrontEnd(Providers providers, TargetDescription target, StructuredGraph graph, Assumptions assumptions, Map<ResolvedJavaMethod, StructuredGraph> cache,
14172
cd22c8dbda4f Made graph caching compilation local
Doug Simon <doug.simon@oracle.com>
parents: 14148
diff changeset
240 PhaseSuite<HighTierContext> graphBuilderSuite, OptimisticOptimizations optimisticOpts, ProfilingInfo profilingInfo, SpeculationLog speculationLog, Suites suites) {
15011
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
241 try (Scope s = Debug.scope("FrontEnd"); TimerCloseable a = FrontEnd.start()) {
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
242 if (speculationLog != null) {
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
243 speculationLog.collectFailedSpeculations();
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
244 }
4353
043bec543161 More work on debug framework. Removed concept of GraalContext.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4352
diff changeset
245
15011
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
246 HighTierContext highTierContext = new HighTierContext(providers, assumptions, cache, graphBuilderSuite, optimisticOpts);
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
247 if (graph.start().next() == null) {
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
248 graphBuilderSuite.apply(graph, highTierContext);
17094
86888df288ec fixed case of Optionality constants
Doug Simon <doug.simon@oracle.com>
parents: 17065
diff changeset
249 new DeadCodeEliminationPhase(Optional).apply(graph);
15011
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
250 } else {
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
251 Debug.dump(graph, "initial state");
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
252 }
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
253
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
254 suites.getHighTier().apply(graph, highTierContext);
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
255 graph.maybeCompress();
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
256
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
257 MidTierContext midTierContext = new MidTierContext(providers, assumptions, target, optimisticOpts, profilingInfo, speculationLog);
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
258 suites.getMidTier().apply(graph, midTierContext);
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
259 graph.maybeCompress();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
260
15011
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
261 LowTierContext lowTierContext = new LowTierContext(providers, assumptions, target);
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
262 suites.getLowTier().apply(graph, lowTierContext);
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
263 graph.maybeCompress();
8600
c423a5fd8ac7 Cull frame states before lowering.
Roland Schatz <roland.schatz@oracle.com>
parents: 8560
diff changeset
264
15011
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
265 SchedulePhase schedule = new SchedulePhase();
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
266 schedule.apply(graph);
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
267 Debug.dump(schedule, "Final HIR schedule");
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
268 return schedule;
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
269 } catch (Throwable e) {
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
270 throw Debug.handle(e);
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
271 }
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
272 }
8534
4f33d1871dca pipeline: canonicalize after ConditionalElimination and EliminatePartiallyRedundantGuards
Bernhard Urban <bernhard.urban@jku.at>
parents: 8506
diff changeset
273
15011
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
274 public static <T extends CompilationResult> void emitBackEnd(StructuredGraph graph, Object stub, CallingConvention cc, ResolvedJavaMethod installedCodeOwner, Backend backend,
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
275 TargetDescription target, T compilationResult, CompilationResultBuilderFactory factory, Assumptions assumptions, SchedulePhase schedule, RegisterConfig registerConfig) {
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
276 try (TimerCloseable a = BackEnd.start()) {
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
277 LIRGenerationResult lirGen = null;
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
278 lirGen = emitLIR(backend, target, schedule, graph, stub, cc, registerConfig);
19234
e9e99e6f2c6b GraalCompiler.emitBackEnd: do not box objects for scope.
Josef Eisl <josef.eisl@jku.at>
parents: 19185
diff changeset
279 try (Scope s = Debug.scope("CodeGen", lirGen, lirGen.getLIR())) {
15011
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
280 emitCode(backend, assumptions, lirGen, compilationResult, installedCodeOwner, factory);
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
281 } catch (Throwable e) {
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
282 throw Debug.handle(e);
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
283 }
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
284 } catch (Throwable e) {
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
285 throw Debug.handle(e);
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
286 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
287 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
288
18941
c943ba97b2a7 Remove class ScheduledNode from the node class hierarchy.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18674
diff changeset
289 private static void emitBlock(NodeLIRBuilderTool nodeLirGen, LIRGenerationResult lirGenRes, Block b, StructuredGraph graph, BlockMap<List<ValueNode>> blockMap) {
14813
fafbff0eeebf Removed NodeLIRGenerator again.
Josef Eisl <josef.eisl@jku.at>
parents: 14809
diff changeset
290 if (lirGenRes.getLIR().getLIRforBlock(b) == null) {
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
291 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
292 if (!b.isLoopHeader() || !pred.isLoopEnd()) {
14841
47e4d2e01c6e Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents: 14826
diff changeset
293 emitBlock(nodeLirGen, lirGenRes, pred, graph, blockMap);
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
294 }
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
295 }
14841
47e4d2e01c6e Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents: 14826
diff changeset
296 nodeLirGen.doBlock(b, graph, blockMap);
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
297 }
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
298 }
6316
2e25b9c14b84 Temporarily remove experimental register allocators.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5891
diff changeset
299
15011
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
300 public static LIRGenerationResult emitLIR(Backend backend, TargetDescription target, SchedulePhase schedule, StructuredGraph graph, Object stub, CallingConvention cc, RegisterConfig registerConfig) {
15537
8117e9cadb48 Use List instead of an array in AbstractControlFlowGraph.
Josef Eisl <josef.eisl@jku.at>
parents: 15470
diff changeset
301 List<Block> blocks = schedule.getCFG().getBlocks();
14128
d2030fa96c22 Compute LinearScanOrder in emitLIR.
Josef Eisl <josef.eisl@jku.at>
parents: 14070
diff changeset
302 Block startBlock = schedule.getCFG().getStartBlock();
d2030fa96c22 Compute LinearScanOrder in emitLIR.
Josef Eisl <josef.eisl@jku.at>
parents: 14070
diff changeset
303 assert startBlock != null;
d2030fa96c22 Compute LinearScanOrder in emitLIR.
Josef Eisl <josef.eisl@jku.at>
parents: 14070
diff changeset
304 assert startBlock.getPredecessorCount() == 0;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
305
14128
d2030fa96c22 Compute LinearScanOrder in emitLIR.
Josef Eisl <josef.eisl@jku.at>
parents: 14070
diff changeset
306 LIR lir = null;
14786
a6595f1b55b0 Make LIR use AbstractBlock. (errors)
Josef Eisl <josef.eisl@jku.at>
parents: 14148
diff changeset
307 List<Block> codeEmittingOrder = null;
a6595f1b55b0 Make LIR use AbstractBlock. (errors)
Josef Eisl <josef.eisl@jku.at>
parents: 14148
diff changeset
308 List<Block> linearScanOrder = null;
14128
d2030fa96c22 Compute LinearScanOrder in emitLIR.
Josef Eisl <josef.eisl@jku.at>
parents: 14070
diff changeset
309 try (Scope ds = Debug.scope("MidEnd")) {
d2030fa96c22 Compute LinearScanOrder in emitLIR.
Josef Eisl <josef.eisl@jku.at>
parents: 14070
diff changeset
310 try (Scope s = Debug.scope("ComputeLinearScanOrder")) {
15537
8117e9cadb48 Use List instead of an array in AbstractControlFlowGraph.
Josef Eisl <josef.eisl@jku.at>
parents: 15470
diff changeset
311 codeEmittingOrder = ComputeBlockOrder.computeCodeEmittingOrder(blocks.size(), startBlock);
8117e9cadb48 Use List instead of an array in AbstractControlFlowGraph.
Josef Eisl <josef.eisl@jku.at>
parents: 15470
diff changeset
312 linearScanOrder = ComputeBlockOrder.computeLinearScanOrder(blocks.size(), startBlock);
7370
39a4192ae632 Experiment with new block order for LSRA.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7348
diff changeset
313
14144
8bdebcc53d15 Remove nodesForBlock mapping in LIR data structure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14143
diff changeset
314 lir = new LIR(schedule.getCFG(), linearScanOrder, codeEmittingOrder);
14128
d2030fa96c22 Compute LinearScanOrder in emitLIR.
Josef Eisl <josef.eisl@jku.at>
parents: 14070
diff changeset
315 Debug.dump(lir, "After linear scan order");
d2030fa96c22 Compute LinearScanOrder in emitLIR.
Josef Eisl <josef.eisl@jku.at>
parents: 14070
diff changeset
316 } catch (Throwable e) {
d2030fa96c22 Compute LinearScanOrder in emitLIR.
Josef Eisl <josef.eisl@jku.at>
parents: 14070
diff changeset
317 throw Debug.handle(e);
4265
4643ccd37dac * removed CiStatistics
Lukas Stadler <lukas.stadler@jku.at>
parents: 4263
diff changeset
318 }
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
319 } 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
320 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
321 }
14128
d2030fa96c22 Compute LinearScanOrder in emitLIR.
Josef Eisl <josef.eisl@jku.at>
parents: 14070
diff changeset
322 try (Scope ds = Debug.scope("BackEnd", lir)) {
18154
448be95baef8 Add Backend.newFrameMapBuilder().
Josef Eisl <josef.eisl@jku.at>
parents: 18153
diff changeset
323 FrameMapBuilder frameMapBuilder = backend.newFrameMapBuilder(registerConfig);
18151
04b54406c292 Use FrameMapBuilder in Backend.newLIRGenerationResult().
Josef Eisl <josef.eisl@jku.at>
parents: 18149
diff changeset
324 LIRGenerationResult lirGenRes = backend.newLIRGenerationResult(lir, frameMapBuilder, graph.method(), stub);
15333
06ecedffb109 Use LIRGeneratorTool in Backend.
Josef Eisl <josef.eisl@jku.at>
parents: 15292
diff changeset
325 LIRGeneratorTool lirGen = backend.newLIRGenerator(cc, lirGenRes);
15338
5e544920ad9f Rename Backend.newNodeLIRGenerator to Backend.newNodeLIRBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 15337
diff changeset
326 NodeLIRBuilderTool nodeLirGen = backend.newNodeLIRBuilder(graph, lirGen);
13842
a02441dcf05f Do control flow optimizations independent of register allocation.
Roland Schatz <roland.schatz@oracle.com>
parents: 13744
diff changeset
327
14128
d2030fa96c22 Compute LinearScanOrder in emitLIR.
Josef Eisl <josef.eisl@jku.at>
parents: 14070
diff changeset
328 try (Scope s = Debug.scope("LIRGen", lirGen)) {
14813
fafbff0eeebf Removed NodeLIRGenerator again.
Josef Eisl <josef.eisl@jku.at>
parents: 14809
diff changeset
329 for (Block b : linearScanOrder) {
14841
47e4d2e01c6e Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents: 14826
diff changeset
330 emitBlock(nodeLirGen, lirGenRes, b, graph, schedule.getBlockToNodesMap());
14128
d2030fa96c22 Compute LinearScanOrder in emitLIR.
Josef Eisl <josef.eisl@jku.at>
parents: 14070
diff changeset
331 }
d2030fa96c22 Compute LinearScanOrder in emitLIR.
Josef Eisl <josef.eisl@jku.at>
parents: 14070
diff changeset
332 lirGen.beforeRegisterAllocation();
d2030fa96c22 Compute LinearScanOrder in emitLIR.
Josef Eisl <josef.eisl@jku.at>
parents: 14070
diff changeset
333
d2030fa96c22 Compute LinearScanOrder in emitLIR.
Josef Eisl <josef.eisl@jku.at>
parents: 14070
diff changeset
334 Debug.dump(lir, "After LIR generation");
d2030fa96c22 Compute LinearScanOrder in emitLIR.
Josef Eisl <josef.eisl@jku.at>
parents: 14070
diff changeset
335 } catch (Throwable e) {
d2030fa96c22 Compute LinearScanOrder in emitLIR.
Josef Eisl <josef.eisl@jku.at>
parents: 14070
diff changeset
336 throw Debug.handle(e);
13937
814800074308 Allow disabling of redundant move elimination
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13842
diff changeset
337 }
14128
d2030fa96c22 Compute LinearScanOrder in emitLIR.
Josef Eisl <josef.eisl@jku.at>
parents: 14070
diff changeset
338
16952
2451521ed26f Add ConstantLoadOptimization.
Josef Eisl <josef.eisl@jku.at>
parents: 15838
diff changeset
339 if (ConstantLoadOptimization.Options.ConstantLoadOptimization.getValue()) {
2451521ed26f Add ConstantLoadOptimization.
Josef Eisl <josef.eisl@jku.at>
parents: 15838
diff changeset
340 try (Scope s = Debug.scope("ConstantLoadOptimization", lir)) {
2451521ed26f Add ConstantLoadOptimization.
Josef Eisl <josef.eisl@jku.at>
parents: 15838
diff changeset
341 ConstantLoadOptimization.optimize(lirGenRes.getLIR(), lirGen);
2451521ed26f Add ConstantLoadOptimization.
Josef Eisl <josef.eisl@jku.at>
parents: 15838
diff changeset
342 Debug.dump(lir, "After constant load optimization");
2451521ed26f Add ConstantLoadOptimization.
Josef Eisl <josef.eisl@jku.at>
parents: 15838
diff changeset
343 } catch (Throwable e) {
2451521ed26f Add ConstantLoadOptimization.
Josef Eisl <josef.eisl@jku.at>
parents: 15838
diff changeset
344 throw Debug.handle(e);
2451521ed26f Add ConstantLoadOptimization.
Josef Eisl <josef.eisl@jku.at>
parents: 15838
diff changeset
345 }
2451521ed26f Add ConstantLoadOptimization.
Josef Eisl <josef.eisl@jku.at>
parents: 15838
diff changeset
346 }
2451521ed26f Add ConstantLoadOptimization.
Josef Eisl <josef.eisl@jku.at>
parents: 15838
diff changeset
347
14841
47e4d2e01c6e Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents: 14826
diff changeset
348 try (Scope s = Debug.scope("Allocator", nodeLirGen)) {
14128
d2030fa96c22 Compute LinearScanOrder in emitLIR.
Josef Eisl <josef.eisl@jku.at>
parents: 14070
diff changeset
349 if (backend.shouldAllocateRegisters()) {
18152
ff694c40bdee LIRGenerationResult: add buildFrameMap() and getFrameMap().
Josef Eisl <josef.eisl@jku.at>
parents: 18151
diff changeset
350 LinearScan.allocate(target, lirGenRes);
14128
d2030fa96c22 Compute LinearScanOrder in emitLIR.
Josef Eisl <josef.eisl@jku.at>
parents: 14070
diff changeset
351 }
d2030fa96c22 Compute LinearScanOrder in emitLIR.
Josef Eisl <josef.eisl@jku.at>
parents: 14070
diff changeset
352 } catch (Throwable e) {
d2030fa96c22 Compute LinearScanOrder in emitLIR.
Josef Eisl <josef.eisl@jku.at>
parents: 14070
diff changeset
353 throw Debug.handle(e);
d2030fa96c22 Compute LinearScanOrder in emitLIR.
Josef Eisl <josef.eisl@jku.at>
parents: 14070
diff changeset
354 }
13842
a02441dcf05f Do control flow optimizations independent of register allocation.
Roland Schatz <roland.schatz@oracle.com>
parents: 13744
diff changeset
355
19019
56e6b5756886 LinearScan: remove support for markFrameLocations.
Josef Eisl <josef.eisl@jku.at>
parents: 18674
diff changeset
356 try (Scope s1 = Debug.scope("BuildFrameMap")) {
56e6b5756886 LinearScan: remove support for markFrameLocations.
Josef Eisl <josef.eisl@jku.at>
parents: 18674
diff changeset
357 // build frame map
19028
f59fc4850df5 StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents: 19022
diff changeset
358 final StackSlotAllocator allocator;
19076
76dd59e530b2 Rename EnableLSStackSlotAllocation command line flag to LSStackSlotAllocation.
Josef Eisl <josef.eisl@jku.at>
parents: 19033
diff changeset
359 if (LSStackSlotAllocator.Options.LSStackSlotAllocation.getValue()) {
19028
f59fc4850df5 StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents: 19022
diff changeset
360 allocator = new LSStackSlotAllocator();
f59fc4850df5 StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents: 19022
diff changeset
361 } else {
f59fc4850df5 StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents: 19022
diff changeset
362 allocator = new SimpleStackSlotAllocator();
18610
6a6291c31657 Add LocationMarker.
Josef Eisl <josef.eisl@jku.at>
parents: 18443
diff changeset
363 }
19028
f59fc4850df5 StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents: 19022
diff changeset
364 lirGenRes.buildFrameMap(allocator);
19019
56e6b5756886 LinearScan: remove support for markFrameLocations.
Josef Eisl <josef.eisl@jku.at>
parents: 18674
diff changeset
365 Debug.dump(lir, "After FrameMap building");
56e6b5756886 LinearScan: remove support for markFrameLocations.
Josef Eisl <josef.eisl@jku.at>
parents: 18674
diff changeset
366 }
56e6b5756886 LinearScan: remove support for markFrameLocations.
Josef Eisl <josef.eisl@jku.at>
parents: 18674
diff changeset
367 try (Scope s1 = Debug.scope("MarkLocations")) {
56e6b5756886 LinearScan: remove support for markFrameLocations.
Josef Eisl <josef.eisl@jku.at>
parents: 18674
diff changeset
368 if (backend.shouldAllocateRegisters()) {
56e6b5756886 LinearScan: remove support for markFrameLocations.
Josef Eisl <josef.eisl@jku.at>
parents: 18674
diff changeset
369 // currently we mark locations only if we do register allocation
56e6b5756886 LinearScan: remove support for markFrameLocations.
Josef Eisl <josef.eisl@jku.at>
parents: 18674
diff changeset
370 LocationMarker.markLocations(lir, lirGenRes.getFrameMap());
18610
6a6291c31657 Add LocationMarker.
Josef Eisl <josef.eisl@jku.at>
parents: 18443
diff changeset
371 }
6a6291c31657 Add LocationMarker.
Josef Eisl <josef.eisl@jku.at>
parents: 18443
diff changeset
372 }
6a6291c31657 Add LocationMarker.
Josef Eisl <josef.eisl@jku.at>
parents: 18443
diff changeset
373
14128
d2030fa96c22 Compute LinearScanOrder in emitLIR.
Josef Eisl <josef.eisl@jku.at>
parents: 14070
diff changeset
374 try (Scope s = Debug.scope("ControlFlowOptimizations")) {
d2030fa96c22 Compute LinearScanOrder in emitLIR.
Josef Eisl <josef.eisl@jku.at>
parents: 14070
diff changeset
375 EdgeMoveOptimizer.optimize(lir);
14787
6ce74db1c9fb Use List<T> instead of Iterable<T> in AbstractBlock to (temporary) allow editing.
Josef Eisl <josef.eisl@jku.at>
parents: 14786
diff changeset
376 ControlFlowOptimizer.optimize(lir, codeEmittingOrder);
14128
d2030fa96c22 Compute LinearScanOrder in emitLIR.
Josef Eisl <josef.eisl@jku.at>
parents: 14070
diff changeset
377 if (lirGen.canEliminateRedundantMoves()) {
18151
04b54406c292 Use FrameMapBuilder in Backend.newLIRGenerationResult().
Josef Eisl <josef.eisl@jku.at>
parents: 18149
diff changeset
378 RedundantMoveElimination.optimize(lir, frameMapBuilder);
14128
d2030fa96c22 Compute LinearScanOrder in emitLIR.
Josef Eisl <josef.eisl@jku.at>
parents: 14070
diff changeset
379 }
d2030fa96c22 Compute LinearScanOrder in emitLIR.
Josef Eisl <josef.eisl@jku.at>
parents: 14070
diff changeset
380 NullCheckOptimizer.optimize(lir, target.implicitNullCheckLimit);
d2030fa96c22 Compute LinearScanOrder in emitLIR.
Josef Eisl <josef.eisl@jku.at>
parents: 14070
diff changeset
381
d2030fa96c22 Compute LinearScanOrder in emitLIR.
Josef Eisl <josef.eisl@jku.at>
parents: 14070
diff changeset
382 Debug.dump(lir, "After control flow optimization");
d2030fa96c22 Compute LinearScanOrder in emitLIR.
Josef Eisl <josef.eisl@jku.at>
parents: 14070
diff changeset
383 } catch (Throwable e) {
d2030fa96c22 Compute LinearScanOrder in emitLIR.
Josef Eisl <josef.eisl@jku.at>
parents: 14070
diff changeset
384 throw Debug.handle(e);
d2030fa96c22 Compute LinearScanOrder in emitLIR.
Josef Eisl <josef.eisl@jku.at>
parents: 14070
diff changeset
385 }
14813
fafbff0eeebf Removed NodeLIRGenerator again.
Josef Eisl <josef.eisl@jku.at>
parents: 14809
diff changeset
386 return lirGenRes;
13842
a02441dcf05f Do control flow optimizations independent of register allocation.
Roland Schatz <roland.schatz@oracle.com>
parents: 13744
diff changeset
387 } catch (Throwable e) {
a02441dcf05f Do control flow optimizations independent of register allocation.
Roland Schatz <roland.schatz@oracle.com>
parents: 13744
diff changeset
388 throw Debug.handle(e);
a02441dcf05f Do control flow optimizations independent of register allocation.
Roland Schatz <roland.schatz@oracle.com>
parents: 13744
diff changeset
389 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
390 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
391
14809
73774616a6b3 Decoupled LIRGenerator and LIRGenerationResult.
Josef Eisl <josef.eisl@jku.at>
parents: 14806
diff changeset
392 public static void emitCode(Backend backend, Assumptions assumptions, LIRGenerationResult lirGenRes, CompilationResult compilationResult, ResolvedJavaMethod installedCodeOwner,
13229
325b4e4efb60 added CompilationResultBuilderFactory to support peep-hole instrumentation of methods as their code is emitted
Doug Simon <doug.simon@oracle.com>
parents: 13228
diff changeset
393 CompilationResultBuilderFactory factory) {
18152
ff694c40bdee LIRGenerationResult: add buildFrameMap() and getFrameMap().
Josef Eisl <josef.eisl@jku.at>
parents: 18151
diff changeset
394 FrameMap frameMap = lirGenRes.getFrameMap();
18148
aed00dc20923 Pass FrameMap to Backend.newCompilationResultBuilder().
Josef Eisl <josef.eisl@jku.at>
parents: 17126
diff changeset
395 CompilationResultBuilder crb = backend.newCompilationResultBuilder(lirGenRes, frameMap, compilationResult, factory);
14809
73774616a6b3 Decoupled LIRGenerator and LIRGenerationResult.
Josef Eisl <josef.eisl@jku.at>
parents: 14806
diff changeset
396 backend.emitCode(crb, lirGenRes.getLIR(), installedCodeOwner);
13227
1a66453f73db renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents: 13226
diff changeset
397 crb.finish();
7064
8d16b9b2c51e first part of refactoring the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7063
diff changeset
398 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
399 compilationResult.setAssumptions(assumptions);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
400 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
401
13226
0b4d38339708 moved CompilationResult metric updating out from TargetMethodAssembler.finish()
Doug Simon <doug.simon@oracle.com>
parents: 13225
diff changeset
402 if (Debug.isMeterEnabled()) {
18176
c2270ad35f57 Better construction of data section and data patches.
Roland Schatz <roland.schatz@oracle.com>
parents: 18157
diff changeset
403 List<DataPatch> ldp = compilationResult.getDataPatches();
14616
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14595
diff changeset
404 Kind[] kindValues = Kind.values();
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14595
diff changeset
405 DebugMetric[] dms = new DebugMetric[kindValues.length];
13226
0b4d38339708 moved CompilationResult metric updating out from TargetMethodAssembler.finish()
Doug Simon <doug.simon@oracle.com>
parents: 13225
diff changeset
406 for (int i = 0; i < dms.length; i++) {
14616
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14595
diff changeset
407 dms[i] = Debug.metric("DataPatches-%s", kindValues[i]);
13226
0b4d38339708 moved CompilationResult metric updating out from TargetMethodAssembler.finish()
Doug Simon <doug.simon@oracle.com>
parents: 13225
diff changeset
408 }
0b4d38339708 moved CompilationResult metric updating out from TargetMethodAssembler.finish()
Doug Simon <doug.simon@oracle.com>
parents: 13225
diff changeset
409
0b4d38339708 moved CompilationResult metric updating out from TargetMethodAssembler.finish()
Doug Simon <doug.simon@oracle.com>
parents: 13225
diff changeset
410 for (DataPatch dp : ldp) {
18176
c2270ad35f57 Better construction of data section and data patches.
Roland Schatz <roland.schatz@oracle.com>
parents: 18157
diff changeset
411 Kind kind = Kind.Illegal;
c2270ad35f57 Better construction of data section and data patches.
Roland Schatz <roland.schatz@oracle.com>
parents: 18157
diff changeset
412 if (dp.reference instanceof ConstantReference) {
18186
ef357effbda7 Backout of changeset 9a804ec7f707 (converted Constant and Value to be interfaces).
Roland Schatz <roland.schatz@oracle.com>
parents: 18176
diff changeset
413 VMConstant constant = ((ConstantReference) dp.reference).getConstant();
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 18186
diff changeset
414 kind = ((JavaConstant) constant).getKind();
18176
c2270ad35f57 Better construction of data section and data patches.
Roland Schatz <roland.schatz@oracle.com>
parents: 18157
diff changeset
415 }
c2270ad35f57 Better construction of data section and data patches.
Roland Schatz <roland.schatz@oracle.com>
parents: 18157
diff changeset
416 dms[kind.ordinal()].add(1);
13226
0b4d38339708 moved CompilationResult metric updating out from TargetMethodAssembler.finish()
Doug Simon <doug.simon@oracle.com>
parents: 13225
diff changeset
417 }
0b4d38339708 moved CompilationResult metric updating out from TargetMethodAssembler.finish()
Doug Simon <doug.simon@oracle.com>
parents: 13225
diff changeset
418
0b4d38339708 moved CompilationResult metric updating out from TargetMethodAssembler.finish()
Doug Simon <doug.simon@oracle.com>
parents: 13225
diff changeset
419 Debug.metric("CompilationResults").increment();
0b4d38339708 moved CompilationResult metric updating out from TargetMethodAssembler.finish()
Doug Simon <doug.simon@oracle.com>
parents: 13225
diff changeset
420 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
421 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
422 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
423 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
424 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
425
12472
85d03b72f269 added support disassembling during CodeGen
Doug Simon <doug.simon@oracle.com>
parents: 12362
diff changeset
426 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
427 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
428 }
85d03b72f269 added support disassembling during CodeGen
Doug Simon <doug.simon@oracle.com>
parents: 12362
diff changeset
429
13224
7086a2fe7370 renamed TargetMethodAssembler.finishTargetMethod to finalize and made its return type void
Doug Simon <doug.simon@oracle.com>
parents: 13197
diff changeset
430 Debug.dump(compilationResult, "After code generation");
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
431 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
432 }