annotate graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java @ 21511:47c5e0903d06

Add RegisterAllocationConfig to AllocationContext.
author Josef Eisl <josef.eisl@jku.at>
date Thu, 28 May 2015 10:04:46 +0200
parents da76d7a2b3d4
children ce2113326bc8
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 /*
19694
ab4007bfc67d GraalCompiler: Encapsulate LIR generation in an LIRPhase.
Josef Eisl <josef.eisl@jku.at>
parents: 19686
diff changeset
2 * Copyright (c) 2009, 2015, 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.*;
20923
0e5a0403729c lifted register allocation retry under RegisterPressure to GraalCompiler.emitLIR to account for a register allocator that modifies the LIR
Doug Simon <doug.simon@oracle.com>
parents: 20116
diff changeset
26 import static com.oracle.graal.compiler.common.GraalOptions.*;
0e5a0403729c lifted register allocation retry under RegisterPressure to GraalCompiler.emitLIR to account for a register allocator that modifies the LIR
Doug Simon <doug.simon@oracle.com>
parents: 20116
diff changeset
27 import static com.oracle.graal.compiler.common.alloc.RegisterAllocationConfig.*;
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.*;
19694
ab4007bfc67d GraalCompiler: Encapsulate LIR generation in an LIRPhase.
Josef Eisl <josef.eisl@jku.at>
parents: 19686
diff changeset
36 import com.oracle.graal.compiler.LIRGenerationPhase.LIRGenerationContext;
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;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
42 import com.oracle.graal.lir.*;
20923
0e5a0403729c lifted register allocation retry under RegisterPressure to GraalCompiler.emitLIR to account for a register allocator that modifies the LIR
Doug Simon <doug.simon@oracle.com>
parents: 20116
diff changeset
43 import com.oracle.graal.lir.alloc.lsra.*;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
44 import com.oracle.graal.lir.asm.*;
18443
1c92d437179b FrameMapBuilder: move into package.
Josef Eisl <josef.eisl@jku.at>
parents: 18431
diff changeset
45 import com.oracle.graal.lir.framemap.*;
15292
a38d791982e1 Move LIRGenerationResult* to graal.lir.
Josef Eisl <josef.eisl@jku.at>
parents: 15259
diff changeset
46 import com.oracle.graal.lir.gen.*;
19664
16b239e422d2 Rearrange scopes and timers in emitBackend to match up better
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19563
diff changeset
47 import com.oracle.graal.lir.phases.AllocationPhase.AllocationContext;
19204
16903af7d05c Make EdgeMoveOptimizer a LowLevelLowTierPhase.
Josef Eisl <josef.eisl@jku.at>
parents: 19202
diff changeset
48 import com.oracle.graal.lir.phases.*;
19664
16b239e422d2 Rearrange scopes and timers in emitBackend to match up better
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19563
diff changeset
49 import com.oracle.graal.lir.phases.PostAllocationOptimizationPhase.PostAllocationOptimizationContext;
19464
752a498c1b01 Rename LIRHighTier to PreAllocationOptimizationStage.
Josef Eisl <josef.eisl@jku.at>
parents: 19346
diff changeset
50 import com.oracle.graal.lir.phases.PreAllocationOptimizationPhase.PreAllocationOptimizationContext;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
51 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
52 import com.oracle.graal.nodes.cfg.*;
15337
c4be3c1b2d6d Use NodeLIRBuilderTool instead of NodeLIRBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 15333
diff changeset
53 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
54 import com.oracle.graal.options.*;
20923
0e5a0403729c lifted register allocation retry under RegisterPressure to GraalCompiler.emitLIR to account for a register allocator that modifies the LIR
Doug Simon <doug.simon@oracle.com>
parents: 20116
diff changeset
55 import com.oracle.graal.options.OptionValue.*;
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.*;
6526
ee651c726397 split phases out of graal.phases project into graal.phases.common project
Doug Simon <doug.simon@oracle.com>
parents: 6525
diff changeset
57 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
58 import com.oracle.graal.phases.schedule.*;
9001
94583d9eead8 HighTier phase suite.
Roland Schatz <roland.schatz@oracle.com>
parents: 8983
diff changeset
59 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
60 import com.oracle.graal.phases.util.*;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
61
9615
1089d63ef168 removed 'method' parameter from GraalCompiler.compiledMethod() and renamed the latter to 'compileGraph'.
Doug Simon <doug.simon@oracle.com>
parents: 9614
diff changeset
62 /**
1089d63ef168 removed 'method' parameter from GraalCompiler.compiledMethod() and renamed the latter to 'compileGraph'.
Doug Simon <doug.simon@oracle.com>
parents: 9614
diff changeset
63 * 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
64 */
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
65 public class GraalCompiler {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
66
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
67 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
68 private static final DebugTimer BackEnd = Debug.timer("BackEnd");
19664
16b239e422d2 Rearrange scopes and timers in emitBackend to match up better
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19563
diff changeset
69 private static final DebugTimer EmitLIR = Debug.timer("EmitLIR");
16b239e422d2 Rearrange scopes and timers in emitBackend to match up better
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19563
diff changeset
70 private static final DebugTimer EmitCode = Debug.timer("EmitCode");
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
71
11504
be283d587cfc moved IntrinsificationsEnabled and IntrinsificationsDisabled to new GraalCompiler.Options class
Doug Simon <doug.simon@oracle.com>
parents: 11491
diff changeset
72 static class Options {
be283d587cfc moved IntrinsificationsEnabled and IntrinsificationsDisabled to new GraalCompiler.Options class
Doug Simon <doug.simon@oracle.com>
parents: 11491
diff changeset
73
be283d587cfc moved IntrinsificationsEnabled and IntrinsificationsDisabled to new GraalCompiler.Options class
Doug Simon <doug.simon@oracle.com>
parents: 11491
diff changeset
74 // @formatter:off
19665
6bc0c7c6f690 Add EmitLIRRepeatCount to repeat emitLIR for profiling
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19664
diff changeset
75 @Option(help = "Repeatedly run the LIR code generation pass to improve statistical profiling results.", type = OptionType.Debug)
6bc0c7c6f690 Add EmitLIRRepeatCount to repeat emitLIR for profiling
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19664
diff changeset
76 public static final OptionValue<Integer> EmitLIRRepeatCount = new OptionValue<>(0);
11504
be283d587cfc moved IntrinsificationsEnabled and IntrinsificationsDisabled to new GraalCompiler.Options class
Doug Simon <doug.simon@oracle.com>
parents: 11491
diff changeset
77 // @formatter:on
be283d587cfc moved IntrinsificationsEnabled and IntrinsificationsDisabled to new GraalCompiler.Options class
Doug Simon <doug.simon@oracle.com>
parents: 11491
diff changeset
78
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
9615
1089d63ef168 removed 'method' parameter from GraalCompiler.compiledMethod() and renamed the latter to 'compileGraph'.
Doug Simon <doug.simon@oracle.com>
parents: 9614
diff changeset
81 /**
18297
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
82 * 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
83 */
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
84 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
85 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
86 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
87 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
88 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
89 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
90 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
91 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
92 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
93 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
94 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
95 public final Suites suites;
19270
292442bed972 Rename LowLevelSuites to LIRSuites.
Josef Eisl <josef.eisl@jku.at>
parents: 19235
diff changeset
96 public final LIRSuites lirSuites;
18297
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
97 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
98 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
99
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
100 /**
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
101 * @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
102 * @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
103 * @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
104 * 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
105 * @param providers
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
106 * @param backend
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
107 * @param target
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
108 * @param graphBuilderSuite
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
109 * @param optimisticOpts
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
110 * @param profilingInfo
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
111 * @param speculationLog
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
112 * @param suites
19270
292442bed972 Rename LowLevelSuites to LIRSuites.
Josef Eisl <josef.eisl@jku.at>
parents: 19235
diff changeset
113 * @param lirSuites
18297
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
114 * @param compilationResult
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
115 * @param factory
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
116 */
19047
173bdcc85ab8 Remove unused parameter "stub" from GraalCompiler.compileGraph
Christian Wimmer <christian.wimmer@oracle.com>
parents: 19033
diff changeset
117 public Request(StructuredGraph graph, CallingConvention cc, ResolvedJavaMethod installedCodeOwner, Providers providers, Backend backend, TargetDescription target,
20068
cc3131ff7ce2 Remove GraphCache option.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 20004
diff changeset
118 PhaseSuite<HighTierContext> graphBuilderSuite, OptimisticOptimizations optimisticOpts, ProfilingInfo profilingInfo, SpeculationLog speculationLog, Suites suites,
cc3131ff7ce2 Remove GraphCache option.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 20004
diff changeset
119 LIRSuites lirSuites, T compilationResult, CompilationResultBuilderFactory factory) {
18297
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
120 this.graph = graph;
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
121 this.cc = cc;
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
122 this.installedCodeOwner = installedCodeOwner;
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
123 this.providers = providers;
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
124 this.backend = backend;
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
125 this.target = target;
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
126 this.graphBuilderSuite = graphBuilderSuite;
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
127 this.optimisticOpts = optimisticOpts;
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
128 this.profilingInfo = profilingInfo;
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
129 this.speculationLog = speculationLog;
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
130 this.suites = suites;
19270
292442bed972 Rename LowLevelSuites to LIRSuites.
Josef Eisl <josef.eisl@jku.at>
parents: 19235
diff changeset
131 this.lirSuites = lirSuites;
18297
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
132 this.compilationResult = compilationResult;
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
133 this.factory = factory;
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
134 }
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
135
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
136 /**
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
137 * 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
138 *
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
139 * @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
140 */
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
141 public T execute() {
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
142 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
143 }
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
144 }
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
145
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
146 /**
9615
1089d63ef168 removed 'method' parameter from GraalCompiler.compiledMethod() and renamed the latter to 'compileGraph'.
Doug Simon <doug.simon@oracle.com>
parents: 9614
diff changeset
147 * Requests compilation of a given graph.
14921
88dfaf6448e0 Remove LIRGenerationResult from NodeLIRBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 14888
diff changeset
148 *
9615
1089d63ef168 removed 'method' parameter from GraalCompiler.compiledMethod() and renamed the latter to 'compileGraph'.
Doug Simon <doug.simon@oracle.com>
parents: 9614
diff changeset
149 * @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
150 * @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
151 * @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
152 * 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
153 * @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
154 */
19047
173bdcc85ab8 Remove unused parameter "stub" from GraalCompiler.compileGraph
Christian Wimmer <christian.wimmer@oracle.com>
parents: 19033
diff changeset
155 public static <T extends CompilationResult> T compileGraph(StructuredGraph graph, CallingConvention cc, ResolvedJavaMethod installedCodeOwner, Providers providers, Backend backend,
20068
cc3131ff7ce2 Remove GraphCache option.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 20004
diff changeset
156 TargetDescription target, PhaseSuite<HighTierContext> graphBuilderSuite, OptimisticOptimizations optimisticOpts, ProfilingInfo profilingInfo, SpeculationLog speculationLog,
cc3131ff7ce2 Remove GraphCache option.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 20004
diff changeset
157 Suites suites, LIRSuites lirSuites, T compilationResult, CompilationResultBuilderFactory factory) {
cc3131ff7ce2 Remove GraphCache option.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 20004
diff changeset
158 return compile(new Request<>(graph, cc, installedCodeOwner, providers, backend, target, graphBuilderSuite, optimisticOpts, profilingInfo, speculationLog, suites, lirSuites, compilationResult,
cc3131ff7ce2 Remove GraphCache option.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 20004
diff changeset
159 factory));
18297
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
160 }
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
161
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
162 /**
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
163 * 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
164 *
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
165 * @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
166 */
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
167 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
168 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
169 try (Scope s0 = Debug.scope("GraalCompiler", r.graph, r.providers.getCodeCache())) {
20068
cc3131ff7ce2 Remove GraphCache option.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 20004
diff changeset
170 SchedulePhase schedule = emitFrontEnd(r.providers, r.target, r.graph, r.graphBuilderSuite, r.optimisticOpts, r.profilingInfo, r.speculationLog, r.suites);
19276
313f9a9647e5 Merge (rename LowLevel{Phases,..} to LIR{Phases,..})
Josef Eisl <josef.eisl@jku.at>
parents: 19275 19255
diff changeset
171 emitBackEnd(r.graph, null, r.cc, r.installedCodeOwner, r.backend, r.target, r.compilationResult, r.factory, schedule, null, r.lirSuites);
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
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);
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
174 }
18297
d1f5e41c3afe added GraalCompiler.Request to encapsulate all inputs to a compilation
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
175 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
176 }
6316
2e25b9c14b84 Temporarily remove experimental register allocators.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5891
diff changeset
177
13239
Doug Simon <doug.simon@oracle.com>
parents: 13229 13217
diff changeset
178 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
179 if (graph.method() != null) {
210f58e992a1 Use separate method profile for OSR compilations.
Roland Schatz <roland.schatz@oracle.com>
parents: 13197
diff changeset
180 return graph.method().getProfilingInfo();
210f58e992a1 Use separate method profile for OSR compilations.
Roland Schatz <roland.schatz@oracle.com>
parents: 13197
diff changeset
181 } else {
210f58e992a1 Use separate method profile for OSR compilations.
Roland Schatz <roland.schatz@oracle.com>
parents: 13197
diff changeset
182 return DefaultProfilingInfo.get(TriState.UNKNOWN);
210f58e992a1 Use separate method profile for OSR compilations.
Roland Schatz <roland.schatz@oracle.com>
parents: 13197
diff changeset
183 }
210f58e992a1 Use separate method profile for OSR compilations.
Roland Schatz <roland.schatz@oracle.com>
parents: 13197
diff changeset
184 }
210f58e992a1 Use separate method profile for OSR compilations.
Roland Schatz <roland.schatz@oracle.com>
parents: 13197
diff changeset
185
4265
4643ccd37dac * removed CiStatistics
Lukas Stadler <lukas.stadler@jku.at>
parents: 4263
diff changeset
186 /**
4643ccd37dac * removed CiStatistics
Lukas Stadler <lukas.stadler@jku.at>
parents: 4263
diff changeset
187 * Builds the graph, optimizes it.
4643ccd37dac * removed CiStatistics
Lukas Stadler <lukas.stadler@jku.at>
parents: 4263
diff changeset
188 */
20068
cc3131ff7ce2 Remove GraphCache option.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 20004
diff changeset
189 public static SchedulePhase emitFrontEnd(Providers providers, TargetDescription target, StructuredGraph graph, PhaseSuite<HighTierContext> graphBuilderSuite,
cc3131ff7ce2 Remove GraphCache option.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 20004
diff changeset
190 OptimisticOptimizations optimisticOpts, ProfilingInfo profilingInfo, SpeculationLog speculationLog, Suites suites) {
19686
fa75218e3942 Fix nested Timer and MemUse tracking logic
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19665
diff changeset
191 try (Scope s = Debug.scope("FrontEnd"); DebugCloseable a = FrontEnd.start()) {
15011
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
192 if (speculationLog != null) {
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
193 speculationLog.collectFailedSpeculations();
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
194 }
4353
043bec543161 More work on debug framework. Removed concept of GraalContext.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4352
diff changeset
195
20068
cc3131ff7ce2 Remove GraphCache option.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 20004
diff changeset
196 HighTierContext highTierContext = new HighTierContext(providers, graphBuilderSuite, optimisticOpts);
15011
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
197 if (graph.start().next() == null) {
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
198 graphBuilderSuite.apply(graph, highTierContext);
17094
86888df288ec fixed case of Optionality constants
Doug Simon <doug.simon@oracle.com>
parents: 17065
diff changeset
199 new DeadCodeEliminationPhase(Optional).apply(graph);
15011
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
200 } else {
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
201 Debug.dump(graph, "initial state");
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
202 }
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
203
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
204 suites.getHighTier().apply(graph, highTierContext);
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
205 graph.maybeCompress();
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
206
19250
8ab925a6f724 made Assumptions be part of a StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 19235
diff changeset
207 MidTierContext midTierContext = new MidTierContext(providers, target, optimisticOpts, profilingInfo, speculationLog);
15011
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
208 suites.getMidTier().apply(graph, midTierContext);
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
209 graph.maybeCompress();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
210
19250
8ab925a6f724 made Assumptions be part of a StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 19235
diff changeset
211 LowTierContext lowTierContext = new LowTierContext(providers, target);
15011
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
212 suites.getLowTier().apply(graph, lowTierContext);
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
213 graph.maybeCompress();
8600
c423a5fd8ac7 Cull frame states before lowering.
Roland Schatz <roland.schatz@oracle.com>
parents: 8560
diff changeset
214
15011
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
215 SchedulePhase schedule = new SchedulePhase();
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
216 schedule.apply(graph);
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
217 Debug.dump(schedule, "Final HIR schedule");
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
218 return schedule;
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
219 } catch (Throwable e) {
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
220 throw Debug.handle(e);
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
221 }
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
222 }
8534
4f33d1871dca pipeline: canonicalize after ConditionalElimination and EliminatePartiallyRedundantGuards
Bernhard Urban <bernhard.urban@jku.at>
parents: 8506
diff changeset
223
15011
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
224 public static <T extends CompilationResult> void emitBackEnd(StructuredGraph graph, Object stub, CallingConvention cc, ResolvedJavaMethod installedCodeOwner, Backend backend,
19276
313f9a9647e5 Merge (rename LowLevel{Phases,..} to LIR{Phases,..})
Josef Eisl <josef.eisl@jku.at>
parents: 19275 19255
diff changeset
225 TargetDescription target, T compilationResult, CompilationResultBuilderFactory factory, SchedulePhase schedule, RegisterConfig registerConfig, LIRSuites lirSuites) {
21303
da76d7a2b3d4 GraalCompiler#emitBackEnd: add schedule into debug scope.
Josef Eisl <josef.eisl@jku.at>
parents: 21186
diff changeset
226 try (Scope s = Debug.scope("BackEnd", schedule); DebugCloseable a = BackEnd.start()) {
19665
6bc0c7c6f690 Add EmitLIRRepeatCount to repeat emitLIR for profiling
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19664
diff changeset
227 // Repeatedly run the LIR code generation pass to improve statistical profiling results.
6bc0c7c6f690 Add EmitLIRRepeatCount to repeat emitLIR for profiling
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19664
diff changeset
228 for (int i = 0; i < EmitLIRRepeatCount.getValue(); i++) {
6bc0c7c6f690 Add EmitLIRRepeatCount to repeat emitLIR for profiling
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19664
diff changeset
229 SchedulePhase dummySchedule = new SchedulePhase();
6bc0c7c6f690 Add EmitLIRRepeatCount to repeat emitLIR for profiling
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19664
diff changeset
230 dummySchedule.apply(graph);
6bc0c7c6f690 Add EmitLIRRepeatCount to repeat emitLIR for profiling
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19664
diff changeset
231 emitLIR(backend, target, dummySchedule, graph, stub, cc, registerConfig, lirSuites);
6bc0c7c6f690 Add EmitLIRRepeatCount to repeat emitLIR for profiling
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19664
diff changeset
232 }
6bc0c7c6f690 Add EmitLIRRepeatCount to repeat emitLIR for profiling
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19664
diff changeset
233
15011
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
234 LIRGenerationResult lirGen = null;
19270
292442bed972 Rename LowLevelSuites to LIRSuites.
Josef Eisl <josef.eisl@jku.at>
parents: 19235
diff changeset
235 lirGen = emitLIR(backend, target, schedule, graph, stub, cc, registerConfig, lirSuites);
19664
16b239e422d2 Rearrange scopes and timers in emitBackend to match up better
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19563
diff changeset
236 try (Scope s2 = Debug.scope("CodeGen", lirGen, lirGen.getLIR())) {
19346
2b392a92e27b made it explicit that a StructuredGraph only records method dependencies for inlined methods - the root method is not recorded as it is already available in the 'method' field
Doug Simon <doug.simon@oracle.com>
parents: 19329
diff changeset
237 emitCode(backend, graph.getAssumptions(), graph.method(), graph.getInlinedMethods(), lirGen, compilationResult, installedCodeOwner, factory);
15011
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
238 } catch (Throwable e) {
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
239 throw Debug.handle(e);
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
240 }
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
241 } catch (Throwable e) {
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
diff changeset
242 throw Debug.handle(e);
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14921
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
19232
66c60942c06c GraalCompiler.emitLowLevel: use LowLevelSuites instead of LowLevelCompilerConfiguration.
Josef Eisl <josef.eisl@jku.at>
parents: 19228
diff changeset
246 public static LIRGenerationResult emitLIR(Backend backend, TargetDescription target, SchedulePhase schedule, StructuredGraph graph, Object stub, CallingConvention cc,
19270
292442bed972 Rename LowLevelSuites to LIRSuites.
Josef Eisl <josef.eisl@jku.at>
parents: 19235
diff changeset
247 RegisterConfig registerConfig, LIRSuites lirSuites) {
20923
0e5a0403729c lifted register allocation retry under RegisterPressure to GraalCompiler.emitLIR to account for a register allocator that modifies the LIR
Doug Simon <doug.simon@oracle.com>
parents: 20116
diff changeset
248 try {
0e5a0403729c lifted register allocation retry under RegisterPressure to GraalCompiler.emitLIR to account for a register allocator that modifies the LIR
Doug Simon <doug.simon@oracle.com>
parents: 20116
diff changeset
249 return emitLIR0(backend, target, schedule, graph, stub, cc, registerConfig, lirSuites);
0e5a0403729c lifted register allocation retry under RegisterPressure to GraalCompiler.emitLIR to account for a register allocator that modifies the LIR
Doug Simon <doug.simon@oracle.com>
parents: 20116
diff changeset
250 } catch (OutOfRegistersException e) {
0e5a0403729c lifted register allocation retry under RegisterPressure to GraalCompiler.emitLIR to account for a register allocator that modifies the LIR
Doug Simon <doug.simon@oracle.com>
parents: 20116
diff changeset
251 if (RegisterPressure.getValue() != null && !RegisterPressure.getValue().equals(ALL_REGISTERS)) {
0e5a0403729c lifted register allocation retry under RegisterPressure to GraalCompiler.emitLIR to account for a register allocator that modifies the LIR
Doug Simon <doug.simon@oracle.com>
parents: 20116
diff changeset
252 try (OverrideScope s = OptionValue.override(RegisterPressure, ALL_REGISTERS)) {
0e5a0403729c lifted register allocation retry under RegisterPressure to GraalCompiler.emitLIR to account for a register allocator that modifies the LIR
Doug Simon <doug.simon@oracle.com>
parents: 20116
diff changeset
253 // retry with default register set
0e5a0403729c lifted register allocation retry under RegisterPressure to GraalCompiler.emitLIR to account for a register allocator that modifies the LIR
Doug Simon <doug.simon@oracle.com>
parents: 20116
diff changeset
254 return emitLIR0(backend, target, schedule, graph, stub, cc, registerConfig, lirSuites);
0e5a0403729c lifted register allocation retry under RegisterPressure to GraalCompiler.emitLIR to account for a register allocator that modifies the LIR
Doug Simon <doug.simon@oracle.com>
parents: 20116
diff changeset
255 }
0e5a0403729c lifted register allocation retry under RegisterPressure to GraalCompiler.emitLIR to account for a register allocator that modifies the LIR
Doug Simon <doug.simon@oracle.com>
parents: 20116
diff changeset
256 } else {
0e5a0403729c lifted register allocation retry under RegisterPressure to GraalCompiler.emitLIR to account for a register allocator that modifies the LIR
Doug Simon <doug.simon@oracle.com>
parents: 20116
diff changeset
257 throw e;
0e5a0403729c lifted register allocation retry under RegisterPressure to GraalCompiler.emitLIR to account for a register allocator that modifies the LIR
Doug Simon <doug.simon@oracle.com>
parents: 20116
diff changeset
258 }
0e5a0403729c lifted register allocation retry under RegisterPressure to GraalCompiler.emitLIR to account for a register allocator that modifies the LIR
Doug Simon <doug.simon@oracle.com>
parents: 20116
diff changeset
259 }
0e5a0403729c lifted register allocation retry under RegisterPressure to GraalCompiler.emitLIR to account for a register allocator that modifies the LIR
Doug Simon <doug.simon@oracle.com>
parents: 20116
diff changeset
260 }
0e5a0403729c lifted register allocation retry under RegisterPressure to GraalCompiler.emitLIR to account for a register allocator that modifies the LIR
Doug Simon <doug.simon@oracle.com>
parents: 20116
diff changeset
261
0e5a0403729c lifted register allocation retry under RegisterPressure to GraalCompiler.emitLIR to account for a register allocator that modifies the LIR
Doug Simon <doug.simon@oracle.com>
parents: 20116
diff changeset
262 private static LIRGenerationResult emitLIR0(Backend backend, TargetDescription target, SchedulePhase schedule, StructuredGraph graph, Object stub, CallingConvention cc,
0e5a0403729c lifted register allocation retry under RegisterPressure to GraalCompiler.emitLIR to account for a register allocator that modifies the LIR
Doug Simon <doug.simon@oracle.com>
parents: 20116
diff changeset
263 RegisterConfig registerConfig, LIRSuites lirSuites) {
19686
fa75218e3942 Fix nested Timer and MemUse tracking logic
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19665
diff changeset
264 try (Scope ds = Debug.scope("EmitLIR"); DebugCloseable a = EmitLIR.start()) {
19664
16b239e422d2 Rearrange scopes and timers in emitBackend to match up better
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19563
diff changeset
265 List<Block> blocks = schedule.getCFG().getBlocks();
16b239e422d2 Rearrange scopes and timers in emitBackend to match up better
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19563
diff changeset
266 Block startBlock = schedule.getCFG().getStartBlock();
16b239e422d2 Rearrange scopes and timers in emitBackend to match up better
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19563
diff changeset
267 assert startBlock != null;
16b239e422d2 Rearrange scopes and timers in emitBackend to match up better
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19563
diff changeset
268 assert startBlock.getPredecessorCount() == 0;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
269
19664
16b239e422d2 Rearrange scopes and timers in emitBackend to match up better
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19563
diff changeset
270 LIR lir = null;
16b239e422d2 Rearrange scopes and timers in emitBackend to match up better
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19563
diff changeset
271 List<Block> codeEmittingOrder = null;
16b239e422d2 Rearrange scopes and timers in emitBackend to match up better
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19563
diff changeset
272 List<Block> linearScanOrder = null;
16b239e422d2 Rearrange scopes and timers in emitBackend to match up better
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19563
diff changeset
273 try (Scope s = Debug.scope("ComputeLinearScanOrder", lir)) {
15537
8117e9cadb48 Use List instead of an array in AbstractControlFlowGraph.
Josef Eisl <josef.eisl@jku.at>
parents: 15470
diff changeset
274 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
275 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
276
14144
8bdebcc53d15 Remove nodesForBlock mapping in LIR data structure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14143
diff changeset
277 lir = new LIR(schedule.getCFG(), linearScanOrder, codeEmittingOrder);
14128
d2030fa96c22 Compute LinearScanOrder in emitLIR.
Josef Eisl <josef.eisl@jku.at>
parents: 14070
diff changeset
278 Debug.dump(lir, "After linear scan order");
d2030fa96c22 Compute LinearScanOrder in emitLIR.
Josef Eisl <josef.eisl@jku.at>
parents: 14070
diff changeset
279 } catch (Throwable e) {
d2030fa96c22 Compute LinearScanOrder in emitLIR.
Josef Eisl <josef.eisl@jku.at>
parents: 14070
diff changeset
280 throw Debug.handle(e);
4265
4643ccd37dac * removed CiStatistics
Lukas Stadler <lukas.stadler@jku.at>
parents: 4263
diff changeset
281 }
18154
448be95baef8 Add Backend.newFrameMapBuilder().
Josef Eisl <josef.eisl@jku.at>
parents: 18153
diff changeset
282 FrameMapBuilder frameMapBuilder = backend.newFrameMapBuilder(registerConfig);
20003
422e60a2f4b9 Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19912
diff changeset
283 String compilationUnitName;
422e60a2f4b9 Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19912
diff changeset
284 ResolvedJavaMethod method = graph.method();
422e60a2f4b9 Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19912
diff changeset
285 if (method == null) {
422e60a2f4b9 Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19912
diff changeset
286 compilationUnitName = "<unknown>";
422e60a2f4b9 Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19912
diff changeset
287 } else {
422e60a2f4b9 Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19912
diff changeset
288 compilationUnitName = method.format("%H.%n(%p)");
422e60a2f4b9 Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19912
diff changeset
289 }
422e60a2f4b9 Implement dynamic instruction counters on assembly level
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 19912
diff changeset
290 LIRGenerationResult lirGenRes = backend.newLIRGenerationResult(compilationUnitName, lir, frameMapBuilder, graph.method(), stub);
15333
06ecedffb109 Use LIRGeneratorTool in Backend.
Josef Eisl <josef.eisl@jku.at>
parents: 15292
diff changeset
291 LIRGeneratorTool lirGen = backend.newLIRGenerator(cc, lirGenRes);
15338
5e544920ad9f Rename Backend.newNodeLIRGenerator to Backend.newNodeLIRBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 15337
diff changeset
292 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
293
19694
ab4007bfc67d GraalCompiler: Encapsulate LIR generation in an LIRPhase.
Josef Eisl <josef.eisl@jku.at>
parents: 19686
diff changeset
294 // LIR generation
ab4007bfc67d GraalCompiler: Encapsulate LIR generation in an LIRPhase.
Josef Eisl <josef.eisl@jku.at>
parents: 19686
diff changeset
295 LIRGenerationContext context = new LIRGenerationContext(lirGen, nodeLirGen, graph, schedule);
21186
cdb65346129d GraalCompiler: scope for LIRGenerationPhase.
Josef Eisl <josef.eisl@jku.at>
parents: 20923
diff changeset
296 try (Scope s = Debug.scope("LIRGeneration", nodeLirGen, lir)) {
cdb65346129d GraalCompiler: scope for LIRGenerationPhase.
Josef Eisl <josef.eisl@jku.at>
parents: 20923
diff changeset
297 new LIRGenerationPhase().apply(target, lirGenRes, codeEmittingOrder, linearScanOrder, context);
cdb65346129d GraalCompiler: scope for LIRGenerationPhase.
Josef Eisl <josef.eisl@jku.at>
parents: 20923
diff changeset
298 } catch (Throwable e) {
cdb65346129d GraalCompiler: scope for LIRGenerationPhase.
Josef Eisl <josef.eisl@jku.at>
parents: 20923
diff changeset
299 throw Debug.handle(e);
cdb65346129d GraalCompiler: scope for LIRGenerationPhase.
Josef Eisl <josef.eisl@jku.at>
parents: 20923
diff changeset
300 }
14128
d2030fa96c22 Compute LinearScanOrder in emitLIR.
Josef Eisl <josef.eisl@jku.at>
parents: 14070
diff changeset
301
19695
5d2309d32463 GraalCompiler: add LIR to LIRStages context.
Josef Eisl <josef.eisl@jku.at>
parents: 19694
diff changeset
302 try (Scope s = Debug.scope("LIRStages", nodeLirGen, lir)) {
21511
47c5e0903d06 Add RegisterAllocationConfig to AllocationContext.
Josef Eisl <josef.eisl@jku.at>
parents: 21303
diff changeset
303 return emitLowLevel(target, codeEmittingOrder, linearScanOrder, lirGenRes, lirGen, lirSuites, backend.newRegisterAllocationConfig(registerConfig));
14128
d2030fa96c22 Compute LinearScanOrder in emitLIR.
Josef Eisl <josef.eisl@jku.at>
parents: 14070
diff changeset
304 } catch (Throwable e) {
d2030fa96c22 Compute LinearScanOrder in emitLIR.
Josef Eisl <josef.eisl@jku.at>
parents: 14070
diff changeset
305 throw Debug.handle(e);
d2030fa96c22 Compute LinearScanOrder in emitLIR.
Josef Eisl <josef.eisl@jku.at>
parents: 14070
diff changeset
306 }
13842
a02441dcf05f Do control flow optimizations independent of register allocation.
Roland Schatz <roland.schatz@oracle.com>
parents: 13744
diff changeset
307 } catch (Throwable e) {
a02441dcf05f Do control flow optimizations independent of register allocation.
Roland Schatz <roland.schatz@oracle.com>
parents: 13744
diff changeset
308 throw Debug.handle(e);
a02441dcf05f Do control flow optimizations independent of register allocation.
Roland Schatz <roland.schatz@oracle.com>
parents: 13744
diff changeset
309 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
310 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
311
19560
4d70d150944f Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19467
diff changeset
312 public static <T extends AbstractBlockBase<T>> LIRGenerationResult emitLowLevel(TargetDescription target, List<T> codeEmittingOrder, List<T> linearScanOrder, LIRGenerationResult lirGenRes,
21511
47c5e0903d06 Add RegisterAllocationConfig to AllocationContext.
Josef Eisl <josef.eisl@jku.at>
parents: 21303
diff changeset
313 LIRGeneratorTool lirGen, LIRSuites lirSuites, RegisterAllocationConfig registerAllocationConfig) {
19467
db1e84a9b0d4 GraalCompiler: rename LIRTier scope to LIRStages.
Josef Eisl <josef.eisl@jku.at>
parents: 19466
diff changeset
314 PreAllocationOptimizationContext preAllocOptContext = new PreAllocationOptimizationContext(lirGen);
db1e84a9b0d4 GraalCompiler: rename LIRTier scope to LIRStages.
Josef Eisl <josef.eisl@jku.at>
parents: 19466
diff changeset
315 lirSuites.getPreAllocationOptimizationStage().apply(target, lirGenRes, codeEmittingOrder, linearScanOrder, preAllocOptContext);
13842
a02441dcf05f Do control flow optimizations independent of register allocation.
Roland Schatz <roland.schatz@oracle.com>
parents: 13744
diff changeset
316
21511
47c5e0903d06 Add RegisterAllocationConfig to AllocationContext.
Josef Eisl <josef.eisl@jku.at>
parents: 21303
diff changeset
317 AllocationContext allocContext = new AllocationContext(lirGen.getSpillMoveFactory(), registerAllocationConfig);
19467
db1e84a9b0d4 GraalCompiler: rename LIRTier scope to LIRStages.
Josef Eisl <josef.eisl@jku.at>
parents: 19466
diff changeset
318 lirSuites.getAllocationStage().apply(target, lirGenRes, codeEmittingOrder, linearScanOrder, allocContext);
14128
d2030fa96c22 Compute LinearScanOrder in emitLIR.
Josef Eisl <josef.eisl@jku.at>
parents: 14070
diff changeset
319
19912
94289b44c934 Add BenchmarkCounterFactory to PostAllocationOptimizationContext.
Josef Eisl <josef.eisl@jku.at>
parents: 19826
diff changeset
320 PostAllocationOptimizationContext postAllocOptContext = new PostAllocationOptimizationContext(lirGen);
19467
db1e84a9b0d4 GraalCompiler: rename LIRTier scope to LIRStages.
Josef Eisl <josef.eisl@jku.at>
parents: 19466
diff changeset
321 lirSuites.getPostAllocationOptimizationStage().apply(target, lirGenRes, codeEmittingOrder, linearScanOrder, postAllocOptContext);
19202
0cd7d78a29c5 GraalCompiler: outsource low-level compiler pipeline.
Josef Eisl <josef.eisl@jku.at>
parents: 19201
diff changeset
322
0cd7d78a29c5 GraalCompiler: outsource low-level compiler pipeline.
Josef Eisl <josef.eisl@jku.at>
parents: 19201
diff changeset
323 return lirGenRes;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
324 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
325
19346
2b392a92e27b made it explicit that a StructuredGraph only records method dependencies for inlined methods - the root method is not recorded as it is already available in the 'method' field
Doug Simon <doug.simon@oracle.com>
parents: 19329
diff changeset
326 public static void emitCode(Backend backend, Assumptions assumptions, ResolvedJavaMethod rootMethod, Set<ResolvedJavaMethod> inlinedMethods, LIRGenerationResult lirGenRes,
2b392a92e27b made it explicit that a StructuredGraph only records method dependencies for inlined methods - the root method is not recorded as it is already available in the 'method' field
Doug Simon <doug.simon@oracle.com>
parents: 19329
diff changeset
327 CompilationResult compilationResult, ResolvedJavaMethod installedCodeOwner, CompilationResultBuilderFactory factory) {
19686
fa75218e3942 Fix nested Timer and MemUse tracking logic
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19665
diff changeset
328 try (DebugCloseable a = EmitCode.start()) {
19664
16b239e422d2 Rearrange scopes and timers in emitBackend to match up better
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19563
diff changeset
329 FrameMap frameMap = lirGenRes.getFrameMap();
16b239e422d2 Rearrange scopes and timers in emitBackend to match up better
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19563
diff changeset
330 CompilationResultBuilder crb = backend.newCompilationResultBuilder(lirGenRes, frameMap, compilationResult, factory);
16b239e422d2 Rearrange scopes and timers in emitBackend to match up better
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19563
diff changeset
331 backend.emitCode(crb, lirGenRes.getLIR(), installedCodeOwner);
16b239e422d2 Rearrange scopes and timers in emitBackend to match up better
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19563
diff changeset
332 crb.finish();
16b239e422d2 Rearrange scopes and timers in emitBackend to match up better
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19563
diff changeset
333 if (assumptions != null && !assumptions.isEmpty()) {
16b239e422d2 Rearrange scopes and timers in emitBackend to match up better
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19563
diff changeset
334 compilationResult.setAssumptions(assumptions.toArray());
16b239e422d2 Rearrange scopes and timers in emitBackend to match up better
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19563
diff changeset
335 }
16b239e422d2 Rearrange scopes and timers in emitBackend to match up better
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19563
diff changeset
336 if (inlinedMethods != null) {
16b239e422d2 Rearrange scopes and timers in emitBackend to match up better
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19563
diff changeset
337 compilationResult.setMethods(rootMethod, inlinedMethods);
13226
0b4d38339708 moved CompilationResult metric updating out from TargetMethodAssembler.finish()
Doug Simon <doug.simon@oracle.com>
parents: 13225
diff changeset
338 }
0b4d38339708 moved CompilationResult metric updating out from TargetMethodAssembler.finish()
Doug Simon <doug.simon@oracle.com>
parents: 13225
diff changeset
339
19664
16b239e422d2 Rearrange scopes and timers in emitBackend to match up better
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19563
diff changeset
340 if (Debug.isMeterEnabled()) {
16b239e422d2 Rearrange scopes and timers in emitBackend to match up better
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19563
diff changeset
341 List<DataPatch> ldp = compilationResult.getDataPatches();
16b239e422d2 Rearrange scopes and timers in emitBackend to match up better
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19563
diff changeset
342 Kind[] kindValues = Kind.values();
16b239e422d2 Rearrange scopes and timers in emitBackend to match up better
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19563
diff changeset
343 DebugMetric[] dms = new DebugMetric[kindValues.length];
16b239e422d2 Rearrange scopes and timers in emitBackend to match up better
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19563
diff changeset
344 for (int i = 0; i < dms.length; i++) {
16b239e422d2 Rearrange scopes and timers in emitBackend to match up better
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19563
diff changeset
345 dms[i] = Debug.metric("DataPatches-%s", kindValues[i]);
18176
c2270ad35f57 Better construction of data section and data patches.
Roland Schatz <roland.schatz@oracle.com>
parents: 18157
diff changeset
346 }
19664
16b239e422d2 Rearrange scopes and timers in emitBackend to match up better
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19563
diff changeset
347
16b239e422d2 Rearrange scopes and timers in emitBackend to match up better
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19563
diff changeset
348 for (DataPatch dp : ldp) {
16b239e422d2 Rearrange scopes and timers in emitBackend to match up better
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19563
diff changeset
349 Kind kind = Kind.Illegal;
16b239e422d2 Rearrange scopes and timers in emitBackend to match up better
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19563
diff changeset
350 if (dp.reference instanceof ConstantReference) {
16b239e422d2 Rearrange scopes and timers in emitBackend to match up better
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19563
diff changeset
351 VMConstant constant = ((ConstantReference) dp.reference).getConstant();
16b239e422d2 Rearrange scopes and timers in emitBackend to match up better
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19563
diff changeset
352 kind = ((JavaConstant) constant).getKind();
16b239e422d2 Rearrange scopes and timers in emitBackend to match up better
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19563
diff changeset
353 }
16b239e422d2 Rearrange scopes and timers in emitBackend to match up better
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19563
diff changeset
354 dms[kind.ordinal()].add(1);
16b239e422d2 Rearrange scopes and timers in emitBackend to match up better
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19563
diff changeset
355 }
16b239e422d2 Rearrange scopes and timers in emitBackend to match up better
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19563
diff changeset
356
16b239e422d2 Rearrange scopes and timers in emitBackend to match up better
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19563
diff changeset
357 Debug.metric("CompilationResults").increment();
16b239e422d2 Rearrange scopes and timers in emitBackend to match up better
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19563
diff changeset
358 Debug.metric("CodeBytesEmitted").add(compilationResult.getTargetCodeSize());
16b239e422d2 Rearrange scopes and timers in emitBackend to match up better
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19563
diff changeset
359 Debug.metric("InfopointsEmitted").add(compilationResult.getInfopoints().size());
16b239e422d2 Rearrange scopes and timers in emitBackend to match up better
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19563
diff changeset
360 Debug.metric("DataPatches").add(ldp.size());
16b239e422d2 Rearrange scopes and timers in emitBackend to match up better
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19563
diff changeset
361 Debug.metric("ExceptionHandlersEmitted").add(compilationResult.getExceptionHandlers().size());
13226
0b4d38339708 moved CompilationResult metric updating out from TargetMethodAssembler.finish()
Doug Simon <doug.simon@oracle.com>
parents: 13225
diff changeset
362 }
0b4d38339708 moved CompilationResult metric updating out from TargetMethodAssembler.finish()
Doug Simon <doug.simon@oracle.com>
parents: 13225
diff changeset
363
19664
16b239e422d2 Rearrange scopes and timers in emitBackend to match up better
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19563
diff changeset
364 if (Debug.isLogEnabled()) {
16b239e422d2 Rearrange scopes and timers in emitBackend to match up better
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19563
diff changeset
365 Debug.log("%s", backend.getProviders().getCodeCache().disassemble(compilationResult, null));
16b239e422d2 Rearrange scopes and timers in emitBackend to match up better
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19563
diff changeset
366 }
16b239e422d2 Rearrange scopes and timers in emitBackend to match up better
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19563
diff changeset
367
16b239e422d2 Rearrange scopes and timers in emitBackend to match up better
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19563
diff changeset
368 Debug.dump(compilationResult, "After code generation");
13226
0b4d38339708 moved CompilationResult metric updating out from TargetMethodAssembler.finish()
Doug Simon <doug.simon@oracle.com>
parents: 13225
diff changeset
369 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
370 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
371 }