Mercurial > hg > graal-compiler
annotate graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningPhase.java @ 7063:0d7dfa5b79e8
merged inlining and intrinsification phases
some optimizations for Integer- and TypeSwitch
added iterator to do the inlining in control-flow order
author | Christian Haeubl <haeubl@ssw.jku.at> |
---|---|
date | Thu, 15 Nov 2012 15:10:41 +0100 |
parents | 2463eb24b644 |
children | 8d16b9b2c51e |
rev | line source |
---|---|
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1 /* |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. |
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 */ |
6526
ee651c726397
split phases out of graal.phases project into graal.phases.common project
Doug Simon <doug.simon@oracle.com>
parents:
6525
diff
changeset
|
23 package com.oracle.graal.phases.common; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
24 |
5177
a26b6248d398
added graph caching (-G:+CacheGraphs)
Lukas Stadler <lukas.stadler@jku.at>
parents:
5114
diff
changeset
|
25 import java.lang.reflect.*; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
26 import java.util.*; |
5177
a26b6248d398
added graph caching (-G:+CacheGraphs)
Lukas Stadler <lukas.stadler@jku.at>
parents:
5114
diff
changeset
|
27 import java.util.concurrent.*; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
28 |
5510
426c605c9d3c
Move cri.ci to api.code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5507
diff
changeset
|
29 import com.oracle.graal.api.code.*; |
5507
dc71b06d09f8
Moving classes from cri.ri to api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5503
diff
changeset
|
30 import com.oracle.graal.api.meta.*; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
31 import com.oracle.graal.debug.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
32 import com.oracle.graal.debug.internal.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
33 import com.oracle.graal.graph.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
34 import com.oracle.graal.nodes.*; |
5720
46ad94a0574a
moved everything from com.oracle.graal.nodes.cri into com.oracle.graal.nodes.spi
Doug Simon <doug.simon@oracle.com>
parents:
5718
diff
changeset
|
35 import com.oracle.graal.nodes.spi.*; |
6525
2c913b643422
rename packages in graal.phases to match project name
Doug Simon <doug.simon@oracle.com>
parents:
6522
diff
changeset
|
36 import com.oracle.graal.phases.*; |
7063
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
37 import com.oracle.graal.phases.PhasePlan.PhasePosition; |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
38 import com.oracle.graal.phases.common.InliningUtil.InlineInfo; |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
39 import com.oracle.graal.phases.common.InliningUtil.InliningCallback; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
40 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
41 public class InliningPhase extends Phase implements InliningCallback { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
42 /* |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
43 * - Detect method which only call another method with some parameters set to constants: void foo(a) -> void foo(a, b) -> void foo(a, b, c) ... |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
44 * These should not be taken into account when determining inlining depth. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
45 * - honor the result of overrideInliningDecision(0, caller, invoke.bci, method, true); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
46 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
47 |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5541
diff
changeset
|
48 private final TargetDescription target; |
5718
10341299528c
renamings: ExtendedRiRuntime -> GraalCodeCacheProvider, CiLoweringTool -> LoweringTool, RiGraphCache -> GraphCache
Doug Simon <doug.simon@oracle.com>
parents:
5674
diff
changeset
|
49 private final GraalCodeCacheProvider runtime; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
50 |
4434 | 51 private final Collection<? extends Invoke> hints; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
52 |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5541
diff
changeset
|
53 private Assumptions assumptions; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
54 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
55 private final PhasePlan plan; |
5718
10341299528c
renamings: ExtendedRiRuntime -> GraalCodeCacheProvider, CiLoweringTool -> LoweringTool, RiGraphCache -> GraphCache
Doug Simon <doug.simon@oracle.com>
parents:
5674
diff
changeset
|
56 private final GraphCache cache; |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
57 private final WeightComputationPolicy weightComputationPolicy; |
4468
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
58 private final InliningPolicy inliningPolicy; |
5114
dad1ac9dba7d
finished first implementation of disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5109
diff
changeset
|
59 private final OptimisticOptimizations optimisticOpts; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
60 |
4348
d49c90e641cb
Remove GraalMetrics, replace with new syntax for metrics.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4205
diff
changeset
|
61 // Metrics |
4356
249752adcb8d
Rename Timer DebugTimer and Metric DebugMetric.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4352
diff
changeset
|
62 private static final DebugMetric metricInliningPerformed = Debug.metric("InliningPerformed"); |
249752adcb8d
Rename Timer DebugTimer and Metric DebugMetric.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4352
diff
changeset
|
63 private static final DebugMetric metricInliningConsidered = Debug.metric("InliningConsidered"); |
4598
6a44a26ed9e6
set default inlining policy to the greedy one
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4594
diff
changeset
|
64 private static final DebugMetric metricInliningStoppedByMaxDesiredSize = Debug.metric("InliningStoppedByMaxDesiredSize"); |
7063
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
65 private static final DebugMetric metricInliningRuns = Debug.metric("Runs"); |
4348
d49c90e641cb
Remove GraalMetrics, replace with new syntax for metrics.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4205
diff
changeset
|
66 |
5718
10341299528c
renamings: ExtendedRiRuntime -> GraalCodeCacheProvider, CiLoweringTool -> LoweringTool, RiGraphCache -> GraphCache
Doug Simon <doug.simon@oracle.com>
parents:
5674
diff
changeset
|
67 public InliningPhase(TargetDescription target, GraalCodeCacheProvider runtime, Collection<? extends Invoke> hints, Assumptions assumptions, GraphCache cache, PhasePlan plan, OptimisticOptimizations optimisticOpts) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
68 this.target = target; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
69 this.runtime = runtime; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
70 this.hints = hints; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
71 this.assumptions = assumptions; |
5177
a26b6248d398
added graph caching (-G:+CacheGraphs)
Lukas Stadler <lukas.stadler@jku.at>
parents:
5114
diff
changeset
|
72 this.cache = cache; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
73 this.plan = plan; |
5114
dad1ac9dba7d
finished first implementation of disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5109
diff
changeset
|
74 this.optimisticOpts = optimisticOpts; |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
75 this.weightComputationPolicy = createWeightComputationPolicy(); |
4468
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
76 this.inliningPolicy = createInliningPolicy(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
77 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
78 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
79 @Override |
5316
8ac40aed34bf
Consistent output of inlining decisions. Make all inlining decisions be printable using -G:Log=InliningDecisions
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5299
diff
changeset
|
80 protected void run(final StructuredGraph graph) { |
7063
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
81 NodeBitMap visitedFixedNodes = graph.createNodeBitMap(true); |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
82 Deque<Invoke> sortedInvokes = new ArrayDeque<>(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
83 |
7063
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
84 queueInvokes(graph.start(), sortedInvokes, visitedFixedNodes); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
85 |
7063
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
86 while (!sortedInvokes.isEmpty() && graph.getNodeCount() < GraalOptions.MaximumDesiredSize) { |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
87 final Invoke invoke = sortedInvokes.pop(); |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
88 if (hints != null && !hints.contains(invoke)) { |
5674
b5a53a04913c
In inlining, refresh InlineInfo when making inline decision in case the receiver has a better stamp than when the original InlineInfo where created
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5547
diff
changeset
|
89 continue; |
b5a53a04913c
In inlining, refresh InlineInfo when making inline decision in case the receiver has a better stamp than when the original InlineInfo where created
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5547
diff
changeset
|
90 } |
5316
8ac40aed34bf
Consistent output of inlining decisions. Make all inlining decisions be printable using -G:Log=InliningDecisions
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5299
diff
changeset
|
91 |
7063
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
92 InlineInfo candidate = Debug.scope("InliningDecisions", new Callable<InlineInfo>() { |
5316
8ac40aed34bf
Consistent output of inlining decisions. Make all inlining decisions be printable using -G:Log=InliningDecisions
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5299
diff
changeset
|
93 @Override |
7063
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
94 public InlineInfo call() throws Exception { |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
95 InlineInfo info = InliningUtil.getInlineInfo(invoke, computeInliningLevel(invoke), runtime, assumptions, InliningPhase.this, optimisticOpts); |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
96 if (info == null || !info.invoke.node().isAlive() || info.level > GraalOptions.MaximumInlineLevel) { |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
97 return null; |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
98 } |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
99 metricInliningConsidered.increment(); |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
100 if (inliningPolicy.isWorthInlining(graph, info)) { |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
101 return info; |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
102 } else { |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
103 return null; |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
104 } |
5316
8ac40aed34bf
Consistent output of inlining decisions. Make all inlining decisions be printable using -G:Log=InliningDecisions
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5299
diff
changeset
|
105 } |
8ac40aed34bf
Consistent output of inlining decisions. Make all inlining decisions be printable using -G:Log=InliningDecisions
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5299
diff
changeset
|
106 }); |
8ac40aed34bf
Consistent output of inlining decisions. Make all inlining decisions be printable using -G:Log=InliningDecisions
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5299
diff
changeset
|
107 |
7063
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
108 // TEMP: |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
109 // if (GraalOptions.AlwaysInlineTrivialMethods) { |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
110 // TODO: Continue; |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
111 // } |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
112 |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
113 if (candidate != null) { |
5380
8be0c73cf118
made graph marking stateless (in the graph) to ensure recursive marking is safe
Doug Simon <doug.simon@oracle.com>
parents:
5357
diff
changeset
|
114 int mark = graph.getMark(); |
5019
836e4fce33ab
changed inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5018
diff
changeset
|
115 try { |
7063
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
116 FixedNode predecessor = (FixedNode) invoke.predecessor(); |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
117 candidate.inline(graph, runtime, InliningPhase.this); |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
118 Debug.dump(graph, "after %s", candidate); |
5019
836e4fce33ab
changed inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5018
diff
changeset
|
119 if (GraalOptions.OptCanonicalizer) { |
5380
8be0c73cf118
made graph marking stateless (in the graph) to ensure recursive marking is safe
Doug Simon <doug.simon@oracle.com>
parents:
5357
diff
changeset
|
120 new CanonicalizerPhase(target, runtime, assumptions, mark, null).apply(graph); |
5019
836e4fce33ab
changed inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5018
diff
changeset
|
121 } |
836e4fce33ab
changed inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5018
diff
changeset
|
122 metricInliningPerformed.increment(); |
7063
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
123 |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
124 queueInvokes(predecessor, sortedInvokes, visitedFixedNodes); |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5541
diff
changeset
|
125 } catch (BailoutException bailout) { |
5019
836e4fce33ab
changed inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5018
diff
changeset
|
126 // TODO determine if we should really bail out of the whole compilation. |
836e4fce33ab
changed inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5018
diff
changeset
|
127 throw bailout; |
836e4fce33ab
changed inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5018
diff
changeset
|
128 } catch (AssertionError e) { |
7063
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
129 throw new GraalInternalError(e).addContext(candidate.toString()); |
5019
836e4fce33ab
changed inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5018
diff
changeset
|
130 } catch (RuntimeException e) { |
7063
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
131 throw new GraalInternalError(e).addContext(candidate.toString()); |
5019
836e4fce33ab
changed inlining debug output
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5018
diff
changeset
|
132 } catch (GraalInternalError e) { |
7063
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
133 throw e.addContext(candidate.toString()); |
4468
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
134 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
135 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
136 } |
4598
6a44a26ed9e6
set default inlining policy to the greedy one
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4594
diff
changeset
|
137 |
7063
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
138 if (graph.getNodeCount() >= GraalOptions.MaximumDesiredSize) { |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
139 if (GraalOptions.Debug) { |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
140 Debug.scope("InliningDecisions", new Runnable() { |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
141 public void run() { |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
142 Debug.log("inlining is cut off by MaximumDesiredSize"); |
5316
8ac40aed34bf
Consistent output of inlining decisions. Make all inlining decisions be printable using -G:Log=InliningDecisions
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5299
diff
changeset
|
143 } |
7063
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
144 }); |
5316
8ac40aed34bf
Consistent output of inlining decisions. Make all inlining decisions be printable using -G:Log=InliningDecisions
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5299
diff
changeset
|
145 |
7063
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
146 metricInliningStoppedByMaxDesiredSize.increment(); |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
147 } |
4598
6a44a26ed9e6
set default inlining policy to the greedy one
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4594
diff
changeset
|
148 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
149 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
150 |
7063
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
151 private static void queueInvokes(FixedNode start, Deque<Invoke> invokes, NodeBitMap visitedFixedNodes) { |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
152 ArrayList<Invoke> results = new ArrayList<>(); |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
153 new InliningIterator(start, results, visitedFixedNodes).apply(); |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
154 // insert the newly found invokes in their correct control-flow order |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
155 for (int i = results.size() - 1; i >= 0; i--) { |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
156 invokes.addFirst(results.get(i)); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
157 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
158 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
159 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
160 @Override |
5541
b4c406861c33
More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
161 public StructuredGraph buildGraph(final ResolvedJavaMethod method) { |
6353
2590d9cc3b6d
remove unnecessary debug scope during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
5788
diff
changeset
|
162 metricInliningRuns.increment(); |
2590d9cc3b6d
remove unnecessary debug scope during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
5788
diff
changeset
|
163 if (GraalOptions.CacheGraphs && cache != null) { |
2590d9cc3b6d
remove unnecessary debug scope during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
5788
diff
changeset
|
164 StructuredGraph cachedGraph = cache.get(method); |
2590d9cc3b6d
remove unnecessary debug scope during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
5788
diff
changeset
|
165 if (cachedGraph != null) { |
2590d9cc3b6d
remove unnecessary debug scope during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
5788
diff
changeset
|
166 return cachedGraph; |
2590d9cc3b6d
remove unnecessary debug scope during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
5788
diff
changeset
|
167 } |
2590d9cc3b6d
remove unnecessary debug scope during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
5788
diff
changeset
|
168 } |
2590d9cc3b6d
remove unnecessary debug scope during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
5788
diff
changeset
|
169 StructuredGraph newGraph = new StructuredGraph(method); |
2590d9cc3b6d
remove unnecessary debug scope during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
5788
diff
changeset
|
170 if (plan != null) { |
2590d9cc3b6d
remove unnecessary debug scope during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
5788
diff
changeset
|
171 plan.runPhases(PhasePosition.AFTER_PARSING, newGraph); |
2590d9cc3b6d
remove unnecessary debug scope during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
5788
diff
changeset
|
172 } |
2590d9cc3b6d
remove unnecessary debug scope during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
5788
diff
changeset
|
173 assert newGraph.start().next() != null : "graph needs to be populated during PhasePosition.AFTER_PARSING"; |
5177
a26b6248d398
added graph caching (-G:+CacheGraphs)
Lukas Stadler <lukas.stadler@jku.at>
parents:
5114
diff
changeset
|
174 |
6353
2590d9cc3b6d
remove unnecessary debug scope during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
5788
diff
changeset
|
175 if (GraalOptions.ProbabilityAnalysis) { |
2590d9cc3b6d
remove unnecessary debug scope during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
5788
diff
changeset
|
176 new DeadCodeEliminationPhase().apply(newGraph); |
2590d9cc3b6d
remove unnecessary debug scope during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
5788
diff
changeset
|
177 new ComputeProbabilityPhase().apply(newGraph); |
2590d9cc3b6d
remove unnecessary debug scope during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
5788
diff
changeset
|
178 } |
2590d9cc3b6d
remove unnecessary debug scope during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
5788
diff
changeset
|
179 if (GraalOptions.OptCanonicalizer) { |
2590d9cc3b6d
remove unnecessary debug scope during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
5788
diff
changeset
|
180 new CanonicalizerPhase(target, runtime, assumptions).apply(newGraph); |
2590d9cc3b6d
remove unnecessary debug scope during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
5788
diff
changeset
|
181 } |
2590d9cc3b6d
remove unnecessary debug scope during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
5788
diff
changeset
|
182 if (GraalOptions.CullFrameStates) { |
2590d9cc3b6d
remove unnecessary debug scope during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
5788
diff
changeset
|
183 new CullFrameStatesPhase().apply(newGraph); |
2590d9cc3b6d
remove unnecessary debug scope during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
5788
diff
changeset
|
184 } |
2590d9cc3b6d
remove unnecessary debug scope during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
5788
diff
changeset
|
185 if (GraalOptions.CacheGraphs && cache != null) { |
2590d9cc3b6d
remove unnecessary debug scope during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
5788
diff
changeset
|
186 cache.put(newGraph); |
2590d9cc3b6d
remove unnecessary debug scope during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
5788
diff
changeset
|
187 } |
2590d9cc3b6d
remove unnecessary debug scope during inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
5788
diff
changeset
|
188 return newGraph; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
189 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
190 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
191 @Override |
5541
b4c406861c33
More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
192 public double inliningWeight(ResolvedJavaMethod caller, ResolvedJavaMethod method, Invoke invoke) { |
4468
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
193 boolean preferred = hints != null && hints.contains(invoke); |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
194 return weightComputationPolicy.computeWeight(caller, method, invoke, preferred); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
195 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
196 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
197 public static int graphComplexity(StructuredGraph graph) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
198 int result = 0; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
199 for (Node node : graph.getNodes()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
200 if (node instanceof ConstantNode || node instanceof LocalNode || node instanceof BeginNode || node instanceof ReturnNode || node instanceof UnwindNode) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
201 result += 0; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
202 } else if (node instanceof PhiNode) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
203 result += 5; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
204 } else if (node instanceof MergeNode || node instanceof Invoke || node instanceof LoopEndNode || node instanceof EndNode) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
205 result += 0; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
206 } else if (node instanceof ControlSplitNode) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
207 result += ((ControlSplitNode) node).blockSuccessorCount(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
208 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
209 result += 1; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
210 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
211 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
212 return Math.max(1, result); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
213 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
214 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
215 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
216 @Override |
5541
b4c406861c33
More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
217 public void recordConcreteMethodAssumption(ResolvedJavaMethod method, ResolvedJavaType context, ResolvedJavaMethod impl) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
218 assumptions.recordConcreteMethod(method, context, impl); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
219 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
220 |
4670
41034914e2ee
add MethodContents assumption to fix debbugging issue
Lukas Stadler <lukas.stadler@jku.at>
parents:
4598
diff
changeset
|
221 @Override |
5541
b4c406861c33
More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
222 public void recordMethodContentsAssumption(ResolvedJavaMethod method) { |
4672
7167f487cc31
fix NPE in tests caused by recordMethodContents
Lukas Stadler <lukas.stadler@jku.at>
parents:
4670
diff
changeset
|
223 if (assumptions != null) { |
7167f487cc31
fix NPE in tests caused by recordMethodContents
Lukas Stadler <lukas.stadler@jku.at>
parents:
4670
diff
changeset
|
224 assumptions.recordMethodContents(method); |
7167f487cc31
fix NPE in tests caused by recordMethodContents
Lukas Stadler <lukas.stadler@jku.at>
parents:
4670
diff
changeset
|
225 } |
4670
41034914e2ee
add MethodContents assumption to fix debbugging issue
Lukas Stadler <lukas.stadler@jku.at>
parents:
4598
diff
changeset
|
226 } |
41034914e2ee
add MethodContents assumption to fix debbugging issue
Lukas Stadler <lukas.stadler@jku.at>
parents:
4598
diff
changeset
|
227 |
4564
8fc6920e064b
avoid recursive inlining, escape analysis does no longer restart inlining with level 0, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4531
diff
changeset
|
228 private static int computeInliningLevel(Invoke invoke) { |
5788
8c9ce2cb3afe
recompute inlining level instead of caching it
Lukas Stadler <lukas.stadler@jku.at>
parents:
5727
diff
changeset
|
229 int count = -1; |
4564
8fc6920e064b
avoid recursive inlining, escape analysis does no longer restart inlining with level 0, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4531
diff
changeset
|
230 FrameState curState = invoke.stateAfter(); |
8fc6920e064b
avoid recursive inlining, escape analysis does no longer restart inlining with level 0, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4531
diff
changeset
|
231 while (curState != null) { |
8fc6920e064b
avoid recursive inlining, escape analysis does no longer restart inlining with level 0, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4531
diff
changeset
|
232 count++; |
8fc6920e064b
avoid recursive inlining, escape analysis does no longer restart inlining with level 0, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4531
diff
changeset
|
233 curState = curState.outerFrameState(); |
8fc6920e064b
avoid recursive inlining, escape analysis does no longer restart inlining with level 0, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4531
diff
changeset
|
234 } |
5788
8c9ce2cb3afe
recompute inlining level instead of caching it
Lukas Stadler <lukas.stadler@jku.at>
parents:
5727
diff
changeset
|
235 return count; |
4564
8fc6920e064b
avoid recursive inlining, escape analysis does no longer restart inlining with level 0, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4531
diff
changeset
|
236 } |
8fc6920e064b
avoid recursive inlining, escape analysis does no longer restart inlining with level 0, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4531
diff
changeset
|
237 |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
238 private static InliningPolicy createInliningPolicy() { |
4569
333ce00358f4
added another inlining policy, added option to disable propagation of loop frequencies
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4564
diff
changeset
|
239 switch(GraalOptions.InliningPolicy) { |
333ce00358f4
added another inlining policy, added option to disable propagation of loop frequencies
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4564
diff
changeset
|
240 case 0: return new WeightBasedInliningPolicy(); |
333ce00358f4
added another inlining policy, added option to disable propagation of loop frequencies
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4564
diff
changeset
|
241 case 1: return new C1StaticSizeBasedInliningPolicy(); |
333ce00358f4
added another inlining policy, added option to disable propagation of loop frequencies
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4564
diff
changeset
|
242 case 2: return new MinimumCodeSizeBasedInliningPolicy(); |
333ce00358f4
added another inlining policy, added option to disable propagation of loop frequencies
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4564
diff
changeset
|
243 case 3: return new DynamicSizeBasedInliningPolicy(); |
333ce00358f4
added another inlining policy, added option to disable propagation of loop frequencies
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4564
diff
changeset
|
244 case 4: return new GreedySizeBasedInliningPolicy(); |
333ce00358f4
added another inlining policy, added option to disable propagation of loop frequencies
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4564
diff
changeset
|
245 default: |
333ce00358f4
added another inlining policy, added option to disable propagation of loop frequencies
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4564
diff
changeset
|
246 GraalInternalError.shouldNotReachHere(); |
333ce00358f4
added another inlining policy, added option to disable propagation of loop frequencies
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4564
diff
changeset
|
247 return null; |
4468
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
248 } |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
249 } |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
250 |
5177
a26b6248d398
added graph caching (-G:+CacheGraphs)
Lukas Stadler <lukas.stadler@jku.at>
parents:
5114
diff
changeset
|
251 private static WeightComputationPolicy createWeightComputationPolicy() { |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
252 switch(GraalOptions.WeightComputationPolicy) { |
5177
a26b6248d398
added graph caching (-G:+CacheGraphs)
Lukas Stadler <lukas.stadler@jku.at>
parents:
5114
diff
changeset
|
253 case 0: throw new GraalInternalError("removed because of invokation counter changes"); |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
254 case 1: return new BytecodeSizeBasedWeightComputationPolicy(); |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
255 case 2: return new ComplexityBasedWeightComputationPolicy(); |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
256 default: |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
257 GraalInternalError.shouldNotReachHere(); |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
258 return null; |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
259 } |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
260 } |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
261 |
4468
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
262 private interface InliningPolicy { |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
263 boolean isWorthInlining(StructuredGraph callerGraph, InlineInfo info); |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
264 } |
87a12a816e99
added C1 inlining policy for comparison, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4461
diff
changeset
|
265 |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
266 private static class WeightBasedInliningPolicy implements InliningPolicy { |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
267 @Override |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
268 public boolean isWorthInlining(StructuredGraph callerGraph, InlineInfo info) { |
5040
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
269 if (!checkCompiledCodeSize(info)) { |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
270 return false; |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
271 } |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
272 |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
273 double penalty = Math.pow(GraalOptions.InliningSizePenaltyExp, callerGraph.getNodeCount() / (double) GraalOptions.MaximumDesiredSize) / GraalOptions.InliningSizePenaltyExp; |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
274 if (info.weight > GraalOptions.MaximumInlineWeight / (1 + penalty * GraalOptions.InliningSizePenalty)) { |
5316
8ac40aed34bf
Consistent output of inlining decisions. Make all inlining decisions be printable using -G:Log=InliningDecisions
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5299
diff
changeset
|
275 Debug.log("not inlining %s (cut off by weight %e)", InliningUtil.methodName(info), info.weight); |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
276 return false; |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
277 } |
5005
c2ebd3d559f7
fixed probabilities when polymorphic inlining is used
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4993
diff
changeset
|
278 |
5316
8ac40aed34bf
Consistent output of inlining decisions. Make all inlining decisions be printable using -G:Log=InliningDecisions
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5299
diff
changeset
|
279 Debug.log("inlining %s (weight %f): %s", InliningUtil.methodName(info), info.weight); |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
280 return true; |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
281 } |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
282 } |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
283 |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
284 private static class C1StaticSizeBasedInliningPolicy implements InliningPolicy { |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
285 @Override |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
286 public boolean isWorthInlining(StructuredGraph callerGraph, InlineInfo info) { |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
287 double maxSize = Math.max(GraalOptions.MaximumTrivialSize, Math.pow(GraalOptions.NestedInliningSizeRatio, info.level) * GraalOptions.MaximumInlineSize); |
5040
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
288 return decideSizeBasedInlining(info, maxSize); |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
289 } |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
290 } |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
291 |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
292 private static class MinimumCodeSizeBasedInliningPolicy implements InliningPolicy { |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
293 @Override |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
294 public boolean isWorthInlining(StructuredGraph callerGraph, InlineInfo info) { |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
295 assert GraalOptions.ProbabilityAnalysis; |
5040
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
296 if (!checkCompiledCodeSize(info)) { |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
297 return false; |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
298 } |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
299 |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
300 double inlineWeight = Math.min(GraalOptions.ProbabilityCapForInlining, info.invoke.probability()); |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
301 double maxSize = Math.pow(GraalOptions.NestedInliningSizeRatio, info.level) * GraalOptions.MaximumInlineSize * inlineWeight; |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
302 maxSize = Math.max(GraalOptions.MaximumTrivialSize, maxSize); |
5005
c2ebd3d559f7
fixed probabilities when polymorphic inlining is used
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4993
diff
changeset
|
303 |
5040
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
304 return decideSizeBasedInlining(info, maxSize); |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
305 } |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
306 } |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
307 |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
308 private static class DynamicSizeBasedInliningPolicy implements InliningPolicy { |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
309 @Override |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
310 public boolean isWorthInlining(StructuredGraph callerGraph, InlineInfo info) { |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
311 assert GraalOptions.ProbabilityAnalysis; |
5040
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
312 if (!checkCompiledCodeSize(info)) { |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
313 return false; |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
314 } |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
315 |
4598
6a44a26ed9e6
set default inlining policy to the greedy one
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4594
diff
changeset
|
316 double inlineBoost = Math.min(GraalOptions.ProbabilityCapForInlining, info.invoke.probability()) + Math.log10(Math.max(1, info.invoke.probability() - GraalOptions.ProbabilityCapForInlining + 1)); |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
317 double maxSize = Math.pow(GraalOptions.NestedInliningSizeRatio, info.level) * GraalOptions.MaximumInlineSize; |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
318 maxSize = maxSize + maxSize * inlineBoost; |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
319 maxSize = Math.min(GraalOptions.MaximumGreedyInlineSize, Math.max(GraalOptions.MaximumTrivialSize, maxSize)); |
5005
c2ebd3d559f7
fixed probabilities when polymorphic inlining is used
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4993
diff
changeset
|
320 |
5040
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
321 return decideSizeBasedInlining(info, maxSize); |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
322 } |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
323 } |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
324 |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
325 private static class GreedySizeBasedInliningPolicy implements InliningPolicy { |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
326 @Override |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
327 public boolean isWorthInlining(StructuredGraph callerGraph, InlineInfo info) { |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
328 assert GraalOptions.ProbabilityAnalysis; |
5040
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
329 if (!checkCompiledCodeSize(info)) { |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
330 return false; |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
331 } |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
332 |
5021
a7c079d5dc87
try to reduce MaximumGreedyInlineSize significantly
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5019
diff
changeset
|
333 double maxSize = GraalOptions.MaximumGreedyInlineSize; |
a7c079d5dc87
try to reduce MaximumGreedyInlineSize significantly
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5019
diff
changeset
|
334 if (GraalOptions.InliningBonusPerTransferredValue != 0) { |
6539
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6526
diff
changeset
|
335 Signature signature = info.invoke.methodCallTarget().targetMethod().getSignature(); |
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6526
diff
changeset
|
336 int transferredValues = signature.getParameterCount(!Modifier.isStatic(info.invoke.methodCallTarget().targetMethod().getModifiers())); |
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6526
diff
changeset
|
337 if (signature.getReturnKind() != Kind.Void) { |
5021
a7c079d5dc87
try to reduce MaximumGreedyInlineSize significantly
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5019
diff
changeset
|
338 transferredValues++; |
a7c079d5dc87
try to reduce MaximumGreedyInlineSize significantly
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5019
diff
changeset
|
339 } |
a7c079d5dc87
try to reduce MaximumGreedyInlineSize significantly
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5019
diff
changeset
|
340 maxSize += transferredValues * GraalOptions.InliningBonusPerTransferredValue; |
a7c079d5dc87
try to reduce MaximumGreedyInlineSize significantly
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5019
diff
changeset
|
341 } |
a7c079d5dc87
try to reduce MaximumGreedyInlineSize significantly
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5019
diff
changeset
|
342 |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
343 double inlineRatio = Math.min(GraalOptions.ProbabilityCapForInlining, info.invoke.probability()); |
5021
a7c079d5dc87
try to reduce MaximumGreedyInlineSize significantly
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5019
diff
changeset
|
344 maxSize = Math.pow(GraalOptions.NestedInliningSizeRatio, info.level) * maxSize * inlineRatio; |
4699
83e7065e9c75
adjust inlining policy's maximum trivial size
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4672
diff
changeset
|
345 maxSize = Math.max(maxSize, GraalOptions.MaximumTrivialSize); |
5005
c2ebd3d559f7
fixed probabilities when polymorphic inlining is used
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4993
diff
changeset
|
346 |
5040
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
347 return decideSizeBasedInlining(info, maxSize); |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
348 } |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
349 } |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
350 |
5040
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
351 private static boolean decideSizeBasedInlining(InlineInfo info, double maxSize) { |
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
352 boolean success = info.weight <= maxSize; |
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
353 if (DebugScope.getInstance().isLogEnabled()) { |
5316
8ac40aed34bf
Consistent output of inlining decisions. Make all inlining decisions be printable using -G:Log=InliningDecisions
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5299
diff
changeset
|
354 String formatterString = success ? "inlining %s (size %f <= %f)" : "not inlining %s (too large %f > %f)"; |
8ac40aed34bf
Consistent output of inlining decisions. Make all inlining decisions be printable using -G:Log=InliningDecisions
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5299
diff
changeset
|
355 Debug.log(formatterString, InliningUtil.methodName(info), info.weight, maxSize); |
5040
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
356 } |
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
357 return success; |
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
358 } |
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
359 |
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
360 private static boolean checkCompiledCodeSize(InlineInfo info) { |
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
361 if (GraalOptions.SmallCompiledCodeSize >= 0 && info.compiledCodeSize() > GraalOptions.SmallCompiledCodeSize) { |
5316
8ac40aed34bf
Consistent output of inlining decisions. Make all inlining decisions be printable using -G:Log=InliningDecisions
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5299
diff
changeset
|
362 Debug.log("not inlining %s (CompiledCodeSize %d > %d)", InliningUtil.methodName(info), info.compiledCodeSize(), GraalOptions.SmallCompiledCodeSize); |
5040
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
363 return false; |
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
364 } |
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
365 return true; |
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
366 } |
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
367 |
4d6e5ddf70e5
added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5021
diff
changeset
|
368 |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
369 private interface WeightComputationPolicy { |
5541
b4c406861c33
More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
370 double computeWeight(ResolvedJavaMethod caller, ResolvedJavaMethod method, Invoke invoke, boolean preferredInvoke); |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
371 } |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
372 |
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
373 private static class BytecodeSizeBasedWeightComputationPolicy implements WeightComputationPolicy { |
4569
333ce00358f4
added another inlining policy, added option to disable propagation of loop frequencies
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4564
diff
changeset
|
374 @Override |
5541
b4c406861c33
More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
375 public double computeWeight(ResolvedJavaMethod caller, ResolvedJavaMethod method, Invoke invoke, boolean preferredInvoke) { |
6539
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6526
diff
changeset
|
376 double codeSize = method.getCodeSize(); |
4569
333ce00358f4
added another inlining policy, added option to disable propagation of loop frequencies
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4564
diff
changeset
|
377 if (preferredInvoke) { |
333ce00358f4
added another inlining policy, added option to disable propagation of loop frequencies
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4564
diff
changeset
|
378 codeSize = codeSize / GraalOptions.BoostInliningForEscapeAnalysis; |
333ce00358f4
added another inlining policy, added option to disable propagation of loop frequencies
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4564
diff
changeset
|
379 } |
333ce00358f4
added another inlining policy, added option to disable propagation of loop frequencies
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4564
diff
changeset
|
380 return codeSize; |
333ce00358f4
added another inlining policy, added option to disable propagation of loop frequencies
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4564
diff
changeset
|
381 } |
333ce00358f4
added another inlining policy, added option to disable propagation of loop frequencies
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4564
diff
changeset
|
382 } |
333ce00358f4
added another inlining policy, added option to disable propagation of loop frequencies
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4564
diff
changeset
|
383 |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
384 private static class ComplexityBasedWeightComputationPolicy implements WeightComputationPolicy { |
4528
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4469
diff
changeset
|
385 @Override |
5541
b4c406861c33
More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
386 public double computeWeight(ResolvedJavaMethod caller, ResolvedJavaMethod method, Invoke invoke, boolean preferredInvoke) { |
6539
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6526
diff
changeset
|
387 double complexity = method.getCompilationComplexity(); |
4528
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4469
diff
changeset
|
388 if (preferredInvoke) { |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
389 complexity = complexity / GraalOptions.BoostInliningForEscapeAnalysis; |
4528
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4469
diff
changeset
|
390 } |
4594
eb6df44a1374
bugfixes, added bytecode complexity estimation
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4591
diff
changeset
|
391 return complexity; |
4528
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4469
diff
changeset
|
392 } |
e6e14d25e608
added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4469
diff
changeset
|
393 } |
7063
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
394 |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
395 private static class InliningIterator { |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
396 private final FixedNode start; |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
397 private final Collection<Invoke> invokes; |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
398 private final NodeBitMap processedNodes; |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
399 |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
400 private final Deque<FixedNode> nodeQueue; |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
401 private final NodeBitMap queuedNodes; |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
402 |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
403 public InliningIterator(FixedNode start, Collection<Invoke> invokes, NodeBitMap visitedFixedNodes) { |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
404 this.start = start; |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
405 this.invokes = invokes; |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
406 this.processedNodes = visitedFixedNodes; |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
407 |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
408 this.nodeQueue = new ArrayDeque<>(); |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
409 this.queuedNodes = visitedFixedNodes.copy(); |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
410 |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
411 assert start.isAlive(); |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
412 } |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
413 |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
414 public void apply() { |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
415 FixedNode current = start; |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
416 do { |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
417 assert current.isAlive(); |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
418 processedNodes.mark(current); |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
419 |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
420 if (current instanceof InvokeWithExceptionNode || current instanceof InvokeNode) { |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
421 invoke((Invoke) current); |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
422 queueSuccessors(current); |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
423 current = nextQueuedNode(); |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
424 } else if (current instanceof LoopBeginNode) { |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
425 current = ((LoopBeginNode) current).next(); |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
426 assert current != null; |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
427 } else if (current instanceof LoopEndNode) { |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
428 current = nextQueuedNode(); |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
429 } else if (current instanceof MergeNode) { |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
430 current = ((MergeNode) current).next(); |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
431 assert current != null; |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
432 } else if (current instanceof FixedWithNextNode) { |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
433 queueSuccessors(current); |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
434 current = nextQueuedNode(); |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
435 } else if (current instanceof EndNode) { |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
436 queueMerge((EndNode) current); |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
437 current = nextQueuedNode(); |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
438 } else if (current instanceof DeoptimizeNode) { |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
439 current = nextQueuedNode(); |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
440 } else if (current instanceof ReturnNode) { |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
441 current = nextQueuedNode(); |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
442 } else if (current instanceof UnwindNode) { |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
443 current = nextQueuedNode(); |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
444 } else if (current instanceof ControlSplitNode) { |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
445 queueSuccessors(current); |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
446 current = nextQueuedNode(); |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
447 } else { |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
448 assert false : current; |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
449 } |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
450 } while(current != null); |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
451 } |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
452 |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
453 private void queueSuccessors(FixedNode x) { |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
454 for (Node node : x.successors()) { |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
455 if (node != null && !queuedNodes.isMarked(node)) { |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
456 queuedNodes.mark(node); |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
457 nodeQueue.addFirst((FixedNode) node); |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
458 } |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
459 } |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
460 } |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
461 |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
462 private FixedNode nextQueuedNode() { |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
463 if (nodeQueue.isEmpty()) { |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
464 return null; |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
465 } |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
466 |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
467 FixedNode result = nodeQueue.removeFirst(); |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
468 assert queuedNodes.isMarked(result); |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
469 return result; |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
470 } |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
471 |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
472 private void queueMerge(EndNode end) { |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
473 MergeNode merge = end.merge(); |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
474 if (!queuedNodes.isMarked(merge) && visitedAllEnds(merge)) { |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
475 queuedNodes.mark(merge); |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
476 nodeQueue.add(merge); |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
477 } |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
478 } |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
479 |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
480 private boolean visitedAllEnds(MergeNode merge) { |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
481 for (int i = 0; i < merge.forwardEndCount(); i++) { |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
482 if (!processedNodes.isMarked(merge.forwardEndAt(i))) { |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
483 return false; |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
484 } |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
485 } |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
486 return true; |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
487 } |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
488 |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
489 protected void invoke(Invoke invoke) { |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
490 invokes.add(invoke); |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
491 } |
0d7dfa5b79e8
merged inlining and intrinsification phases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6539
diff
changeset
|
492 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
493 } |