annotate src/share/vm/opto/coalesce.hpp @ 10111:8373c19be854

8011621: live_ranges_in_separate_class.patch Reviewed-by: kvn, roland Contributed-by: niclas.adlertz@oracle.com
author neliasso
date Tue, 16 Apr 2013 10:08:41 +0200
parents f95d63e2154a
children 8c83625e3a53
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #ifndef SHARE_VM_OPTO_COALESCE_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #define SHARE_VM_OPTO_COALESCE_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "opto/phase.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29
0
a61af66fc99e Initial load
duke
parents:
diff changeset
30 class LoopTree;
a61af66fc99e Initial load
duke
parents:
diff changeset
31 class LRG;
a61af66fc99e Initial load
duke
parents:
diff changeset
32 class LRG_List;
a61af66fc99e Initial load
duke
parents:
diff changeset
33 class Matcher;
a61af66fc99e Initial load
duke
parents:
diff changeset
34 class PhaseIFG;
a61af66fc99e Initial load
duke
parents:
diff changeset
35 class PhaseCFG;
a61af66fc99e Initial load
duke
parents:
diff changeset
36
a61af66fc99e Initial load
duke
parents:
diff changeset
37 //------------------------------PhaseCoalesce----------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
38 class PhaseCoalesce : public Phase {
a61af66fc99e Initial load
duke
parents:
diff changeset
39 protected:
a61af66fc99e Initial load
duke
parents:
diff changeset
40 PhaseChaitin &_phc;
a61af66fc99e Initial load
duke
parents:
diff changeset
41
a61af66fc99e Initial load
duke
parents:
diff changeset
42 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
43 // Coalesce copies
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 1972
diff changeset
44 PhaseCoalesce(PhaseChaitin &phc)
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 1972
diff changeset
45 : Phase(Coalesce)
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 1972
diff changeset
46 , _phc(phc) {}
0
a61af66fc99e Initial load
duke
parents:
diff changeset
47
a61af66fc99e Initial load
duke
parents:
diff changeset
48 virtual void verify() = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
49
a61af66fc99e Initial load
duke
parents:
diff changeset
50 // Coalesce copies
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 1972
diff changeset
51 void coalesce_driver();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
52
a61af66fc99e Initial load
duke
parents:
diff changeset
53 // Coalesce copies in this block
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 1972
diff changeset
54 virtual void coalesce(Block *b) = 0;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
55
a61af66fc99e Initial load
duke
parents:
diff changeset
56 // Attempt to coalesce live ranges defined by these 2
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 1972
diff changeset
57 void combine_these_two(Node *n1, Node *n2);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
58
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 1972
diff changeset
59 LRG &lrgs(uint lidx) { return _phc.lrgs(lidx); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
60 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
61 // Dump internally name
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 1972
diff changeset
62 void dump(Node *n) const;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
63 // Dump whole shebang
a61af66fc99e Initial load
duke
parents:
diff changeset
64 void dump() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
65 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
66 };
a61af66fc99e Initial load
duke
parents:
diff changeset
67
a61af66fc99e Initial load
duke
parents:
diff changeset
68 //------------------------------PhaseAggressiveCoalesce------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
69 // Aggressively, pessimistic coalesce copies. Aggressive means ignore graph
a61af66fc99e Initial load
duke
parents:
diff changeset
70 // colorability; perhaps coalescing to the point of forcing a spill.
a61af66fc99e Initial load
duke
parents:
diff changeset
71 // Pessimistic means we cannot coalesce if 2 live ranges interfere. This
a61af66fc99e Initial load
duke
parents:
diff changeset
72 // implies we do not hit a fixed point right away.
a61af66fc99e Initial load
duke
parents:
diff changeset
73 class PhaseAggressiveCoalesce : public PhaseCoalesce {
a61af66fc99e Initial load
duke
parents:
diff changeset
74 uint _unique;
a61af66fc99e Initial load
duke
parents:
diff changeset
75 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
76 // Coalesce copies
a61af66fc99e Initial load
duke
parents:
diff changeset
77 PhaseAggressiveCoalesce( PhaseChaitin &chaitin ) : PhaseCoalesce(chaitin) {}
a61af66fc99e Initial load
duke
parents:
diff changeset
78
a61af66fc99e Initial load
duke
parents:
diff changeset
79 virtual void verify() { };
a61af66fc99e Initial load
duke
parents:
diff changeset
80
a61af66fc99e Initial load
duke
parents:
diff changeset
81 // Aggressively coalesce copies in this block
a61af66fc99e Initial load
duke
parents:
diff changeset
82 virtual void coalesce( Block *b );
a61af66fc99e Initial load
duke
parents:
diff changeset
83
a61af66fc99e Initial load
duke
parents:
diff changeset
84 // Where I fail to coalesce, manifest virtual copies as the Real Thing
a61af66fc99e Initial load
duke
parents:
diff changeset
85 void insert_copies( Matcher &matcher );
a61af66fc99e Initial load
duke
parents:
diff changeset
86
a61af66fc99e Initial load
duke
parents:
diff changeset
87 // Copy insertion needs some smarts in case live ranges overlap
a61af66fc99e Initial load
duke
parents:
diff changeset
88 void insert_copy_with_overlap( Block *b, Node *copy, uint dst_name, uint src_name );
a61af66fc99e Initial load
duke
parents:
diff changeset
89 };
a61af66fc99e Initial load
duke
parents:
diff changeset
90
a61af66fc99e Initial load
duke
parents:
diff changeset
91
a61af66fc99e Initial load
duke
parents:
diff changeset
92 //------------------------------PhaseConservativeCoalesce----------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
93 // Conservatively, pessimistic coalesce copies. Conservative means do not
a61af66fc99e Initial load
duke
parents:
diff changeset
94 // coalesce if the resultant live range will be uncolorable. Pessimistic
a61af66fc99e Initial load
duke
parents:
diff changeset
95 // means we cannot coalesce if 2 live ranges interfere. This implies we do
a61af66fc99e Initial load
duke
parents:
diff changeset
96 // not hit a fixed point right away.
a61af66fc99e Initial load
duke
parents:
diff changeset
97 class PhaseConservativeCoalesce : public PhaseCoalesce {
a61af66fc99e Initial load
duke
parents:
diff changeset
98 IndexSet _ulr; // Union live range interferences
a61af66fc99e Initial load
duke
parents:
diff changeset
99 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
100 // Coalesce copies
a61af66fc99e Initial load
duke
parents:
diff changeset
101 PhaseConservativeCoalesce( PhaseChaitin &chaitin );
a61af66fc99e Initial load
duke
parents:
diff changeset
102
a61af66fc99e Initial load
duke
parents:
diff changeset
103 virtual void verify();
a61af66fc99e Initial load
duke
parents:
diff changeset
104
a61af66fc99e Initial load
duke
parents:
diff changeset
105 // Conservatively coalesce copies in this block
a61af66fc99e Initial load
duke
parents:
diff changeset
106 virtual void coalesce( Block *b );
a61af66fc99e Initial load
duke
parents:
diff changeset
107
a61af66fc99e Initial load
duke
parents:
diff changeset
108 // Coalesce this chain of copies away
a61af66fc99e Initial load
duke
parents:
diff changeset
109 bool copy_copy( Node *dst_copy, Node *src_copy, Block *b, uint bindex );
a61af66fc99e Initial load
duke
parents:
diff changeset
110
a61af66fc99e Initial load
duke
parents:
diff changeset
111 void union_helper( Node *lr1_node, Node *lr2_node, uint lr1, uint lr2, Node *src_def, Node *dst_copy, Node *src_copy, Block *b, uint bindex );
a61af66fc99e Initial load
duke
parents:
diff changeset
112
a61af66fc99e Initial load
duke
parents:
diff changeset
113 uint compute_separating_interferences(Node *dst_copy, Node *src_copy, Block *b, uint bindex, RegMask &rm, uint rm_size, uint reg_degree, uint lr1, uint lr2);
a61af66fc99e Initial load
duke
parents:
diff changeset
114
a61af66fc99e Initial load
duke
parents:
diff changeset
115 void update_ifg(uint lr1, uint lr2, IndexSet *n_lr1, IndexSet *n_lr2);
a61af66fc99e Initial load
duke
parents:
diff changeset
116 };
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
117
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
118 #endif // SHARE_VM_OPTO_COALESCE_HPP