annotate src/share/vm/opto/postaloc.cpp @ 24234:ea6f94ab283b default tip

Added tag jvmci-0.36 for changeset 8128b98d4736
author Gilles Duboscq <gilles.m.duboscq@oracle.com>
date Mon, 18 Sep 2017 18:49:45 +0200
parents dd9cc155639c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
14223
de6a9e811145 8029233: Update copyright year to match last edit in jdk8 hotspot repository for 2013
mikael
parents: 13012
diff changeset
2 * Copyright (c) 1998, 2013, 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: 948
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 948
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: 948
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 #include "precompiled.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #include "memory/allocation.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27 #include "opto/chaitin.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "opto/machnode.hpp"
0
a61af66fc99e Initial load
duke
parents:
diff changeset
29
6179
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 4776
diff changeset
30 // See if this register (or pairs, or vector) already contains the value.
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 4776
diff changeset
31 static bool register_contains_value(Node* val, OptoReg::Name reg, int n_regs,
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 4776
diff changeset
32 Node_List& value) {
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 4776
diff changeset
33 for (int i = 0; i < n_regs; i++) {
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 4776
diff changeset
34 OptoReg::Name nreg = OptoReg::add(reg,-i);
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 4776
diff changeset
35 if (value[nreg] != val)
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 4776
diff changeset
36 return false;
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 4776
diff changeset
37 }
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 4776
diff changeset
38 return true;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
39 }
a61af66fc99e Initial load
duke
parents:
diff changeset
40
400
cc80376deb0c 6667595: Set probability FAIR for pre-, post- loops and ALWAYS for main loop
kvn
parents: 196
diff changeset
41 //---------------------------may_be_copy_of_callee-----------------------------
0
a61af66fc99e Initial load
duke
parents:
diff changeset
42 // Check to see if we can possibly be a copy of a callee-save value.
a61af66fc99e Initial load
duke
parents:
diff changeset
43 bool PhaseChaitin::may_be_copy_of_callee( Node *def ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
44 // Short circuit if there are no callee save registers
a61af66fc99e Initial load
duke
parents:
diff changeset
45 if (_matcher.number_of_saved_registers() == 0) return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
46
a61af66fc99e Initial load
duke
parents:
diff changeset
47 // Expect only a spill-down and reload on exit for callee-save spills.
a61af66fc99e Initial load
duke
parents:
diff changeset
48 // Chains of copies cannot be deep.
a61af66fc99e Initial load
duke
parents:
diff changeset
49 // 5008997 - This is wishful thinking. Register allocator seems to
a61af66fc99e Initial load
duke
parents:
diff changeset
50 // be splitting live ranges for callee save registers to such
a61af66fc99e Initial load
duke
parents:
diff changeset
51 // an extent that in large methods the chains can be very long
a61af66fc99e Initial load
duke
parents:
diff changeset
52 // (50+). The conservative answer is to return true if we don't
605
98cb887364d3 6810672: Comment typos
twisti
parents: 400
diff changeset
53 // know as this prevents optimizations from occurring.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
54
a61af66fc99e Initial load
duke
parents:
diff changeset
55 const int limit = 60;
a61af66fc99e Initial load
duke
parents:
diff changeset
56 int i;
a61af66fc99e Initial load
duke
parents:
diff changeset
57 for( i=0; i < limit; i++ ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
58 if( def->is_Proj() && def->in(0)->is_Start() &&
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
59 _matcher.is_save_on_entry(lrgs(_lrg_map.live_range_id(def)).reg()))
0
a61af66fc99e Initial load
duke
parents:
diff changeset
60 return true; // Direct use of callee-save proj
a61af66fc99e Initial load
duke
parents:
diff changeset
61 if( def->is_Copy() ) // Copies carry value through
a61af66fc99e Initial load
duke
parents:
diff changeset
62 def = def->in(def->is_Copy());
a61af66fc99e Initial load
duke
parents:
diff changeset
63 else if( def->is_Phi() ) // Phis can merge it from any direction
a61af66fc99e Initial load
duke
parents:
diff changeset
64 def = def->in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
65 else
a61af66fc99e Initial load
duke
parents:
diff changeset
66 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
67 guarantee(def != NULL, "must not resurrect dead copy");
a61af66fc99e Initial load
duke
parents:
diff changeset
68 }
a61af66fc99e Initial load
duke
parents:
diff changeset
69 // If we reached the end and didn't find a callee save proj
a61af66fc99e Initial load
duke
parents:
diff changeset
70 // then this may be a callee save proj so we return true
a61af66fc99e Initial load
duke
parents:
diff changeset
71 // as the conservative answer. If we didn't reach then end
a61af66fc99e Initial load
duke
parents:
diff changeset
72 // we must have discovered that it was not a callee save
a61af66fc99e Initial load
duke
parents:
diff changeset
73 // else we would have returned.
a61af66fc99e Initial load
duke
parents:
diff changeset
74 return i == limit;
a61af66fc99e Initial load
duke
parents:
diff changeset
75 }
a61af66fc99e Initial load
duke
parents:
diff changeset
76
3934
8f47d8870d9a 7087453: PhaseChaitin::yank_if_dead() should handle MachTemp inputs
roland
parents: 2008
diff changeset
77 //------------------------------yank-----------------------------------
8f47d8870d9a 7087453: PhaseChaitin::yank_if_dead() should handle MachTemp inputs
roland
parents: 2008
diff changeset
78 // Helper function for yank_if_dead
8f47d8870d9a 7087453: PhaseChaitin::yank_if_dead() should handle MachTemp inputs
roland
parents: 2008
diff changeset
79 int PhaseChaitin::yank( Node *old, Block *current_block, Node_List *value, Node_List *regnd ) {
8f47d8870d9a 7087453: PhaseChaitin::yank_if_dead() should handle MachTemp inputs
roland
parents: 2008
diff changeset
80 int blk_adjust=0;
12023
d1034bd8cefc 8022284: Hide internal data structure in PhaseCFG
adlertz
parents: 10111
diff changeset
81 Block *oldb = _cfg.get_block_for_node(old);
3934
8f47d8870d9a 7087453: PhaseChaitin::yank_if_dead() should handle MachTemp inputs
roland
parents: 2008
diff changeset
82 oldb->find_remove(old);
8f47d8870d9a 7087453: PhaseChaitin::yank_if_dead() should handle MachTemp inputs
roland
parents: 2008
diff changeset
83 // Count 1 if deleting an instruction from the current block
12023
d1034bd8cefc 8022284: Hide internal data structure in PhaseCFG
adlertz
parents: 10111
diff changeset
84 if (oldb == current_block) {
d1034bd8cefc 8022284: Hide internal data structure in PhaseCFG
adlertz
parents: 10111
diff changeset
85 blk_adjust++;
d1034bd8cefc 8022284: Hide internal data structure in PhaseCFG
adlertz
parents: 10111
diff changeset
86 }
d1034bd8cefc 8022284: Hide internal data structure in PhaseCFG
adlertz
parents: 10111
diff changeset
87 _cfg.unmap_node_from_block(old);
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
88 OptoReg::Name old_reg = lrgs(_lrg_map.live_range_id(old)).reg();
3934
8f47d8870d9a 7087453: PhaseChaitin::yank_if_dead() should handle MachTemp inputs
roland
parents: 2008
diff changeset
89 if( regnd && (*regnd)[old_reg]==old ) { // Instruction is currently available?
8f47d8870d9a 7087453: PhaseChaitin::yank_if_dead() should handle MachTemp inputs
roland
parents: 2008
diff changeset
90 value->map(old_reg,NULL); // Yank from value/regnd maps
8f47d8870d9a 7087453: PhaseChaitin::yank_if_dead() should handle MachTemp inputs
roland
parents: 2008
diff changeset
91 regnd->map(old_reg,NULL); // This register's value is now unknown
8f47d8870d9a 7087453: PhaseChaitin::yank_if_dead() should handle MachTemp inputs
roland
parents: 2008
diff changeset
92 }
8f47d8870d9a 7087453: PhaseChaitin::yank_if_dead() should handle MachTemp inputs
roland
parents: 2008
diff changeset
93 return blk_adjust;
8f47d8870d9a 7087453: PhaseChaitin::yank_if_dead() should handle MachTemp inputs
roland
parents: 2008
diff changeset
94 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
95
4776
5da7201222d5 7110824: ctw/jarfiles/GUI3rdParty_jar/ob_mask_DateField crashes VM
kvn
parents: 3941
diff changeset
96 #ifdef ASSERT
5da7201222d5 7110824: ctw/jarfiles/GUI3rdParty_jar/ob_mask_DateField crashes VM
kvn
parents: 3941
diff changeset
97 static bool expected_yanked_node(Node *old, Node *orig_old) {
5da7201222d5 7110824: ctw/jarfiles/GUI3rdParty_jar/ob_mask_DateField crashes VM
kvn
parents: 3941
diff changeset
98 // This code is expected only next original nodes:
5da7201222d5 7110824: ctw/jarfiles/GUI3rdParty_jar/ob_mask_DateField crashes VM
kvn
parents: 3941
diff changeset
99 // - load from constant table node which may have next data input nodes:
13012
f01788f13696 8026940: assert(n->outcnt() != 0 || C->top() == n || n->is_Proj()) failed: No dead instructions after post-alloc
adlertz
parents: 12167
diff changeset
100 // MachConstantBase, MachTemp, MachSpillCopy
f01788f13696 8026940: assert(n->outcnt() != 0 || C->top() == n || n->is_Proj()) failed: No dead instructions after post-alloc
adlertz
parents: 12167
diff changeset
101 // - Phi nodes that are considered Junk
4776
5da7201222d5 7110824: ctw/jarfiles/GUI3rdParty_jar/ob_mask_DateField crashes VM
kvn
parents: 3941
diff changeset
102 // - load constant node which may have next data input nodes:
5da7201222d5 7110824: ctw/jarfiles/GUI3rdParty_jar/ob_mask_DateField crashes VM
kvn
parents: 3941
diff changeset
103 // MachTemp, MachSpillCopy
5da7201222d5 7110824: ctw/jarfiles/GUI3rdParty_jar/ob_mask_DateField crashes VM
kvn
parents: 3941
diff changeset
104 // - MachSpillCopy
5da7201222d5 7110824: ctw/jarfiles/GUI3rdParty_jar/ob_mask_DateField crashes VM
kvn
parents: 3941
diff changeset
105 // - MachProj and Copy dead nodes
5da7201222d5 7110824: ctw/jarfiles/GUI3rdParty_jar/ob_mask_DateField crashes VM
kvn
parents: 3941
diff changeset
106 if (old->is_MachSpillCopy()) {
5da7201222d5 7110824: ctw/jarfiles/GUI3rdParty_jar/ob_mask_DateField crashes VM
kvn
parents: 3941
diff changeset
107 return true;
5da7201222d5 7110824: ctw/jarfiles/GUI3rdParty_jar/ob_mask_DateField crashes VM
kvn
parents: 3941
diff changeset
108 } else if (old->is_Con()) {
5da7201222d5 7110824: ctw/jarfiles/GUI3rdParty_jar/ob_mask_DateField crashes VM
kvn
parents: 3941
diff changeset
109 return true;
5da7201222d5 7110824: ctw/jarfiles/GUI3rdParty_jar/ob_mask_DateField crashes VM
kvn
parents: 3941
diff changeset
110 } else if (old->is_MachProj()) { // Dead kills projection of Con node
5da7201222d5 7110824: ctw/jarfiles/GUI3rdParty_jar/ob_mask_DateField crashes VM
kvn
parents: 3941
diff changeset
111 return (old == orig_old);
5da7201222d5 7110824: ctw/jarfiles/GUI3rdParty_jar/ob_mask_DateField crashes VM
kvn
parents: 3941
diff changeset
112 } else if (old->is_Copy()) { // Dead copy of a callee-save value
5da7201222d5 7110824: ctw/jarfiles/GUI3rdParty_jar/ob_mask_DateField crashes VM
kvn
parents: 3941
diff changeset
113 return (old == orig_old);
5da7201222d5 7110824: ctw/jarfiles/GUI3rdParty_jar/ob_mask_DateField crashes VM
kvn
parents: 3941
diff changeset
114 } else if (old->is_MachTemp()) {
5da7201222d5 7110824: ctw/jarfiles/GUI3rdParty_jar/ob_mask_DateField crashes VM
kvn
parents: 3941
diff changeset
115 return orig_old->is_Con();
13012
f01788f13696 8026940: assert(n->outcnt() != 0 || C->top() == n || n->is_Proj()) failed: No dead instructions after post-alloc
adlertz
parents: 12167
diff changeset
116 } else if (old->is_Phi()) { // Junk phi's
f01788f13696 8026940: assert(n->outcnt() != 0 || C->top() == n || n->is_Proj()) failed: No dead instructions after post-alloc
adlertz
parents: 12167
diff changeset
117 return true;
f01788f13696 8026940: assert(n->outcnt() != 0 || C->top() == n || n->is_Proj()) failed: No dead instructions after post-alloc
adlertz
parents: 12167
diff changeset
118 } else if (old->is_MachConstantBase()) {
4776
5da7201222d5 7110824: ctw/jarfiles/GUI3rdParty_jar/ob_mask_DateField crashes VM
kvn
parents: 3941
diff changeset
119 return (orig_old->is_Con() && orig_old->is_MachConstant());
5da7201222d5 7110824: ctw/jarfiles/GUI3rdParty_jar/ob_mask_DateField crashes VM
kvn
parents: 3941
diff changeset
120 }
5da7201222d5 7110824: ctw/jarfiles/GUI3rdParty_jar/ob_mask_DateField crashes VM
kvn
parents: 3941
diff changeset
121 return false;
5da7201222d5 7110824: ctw/jarfiles/GUI3rdParty_jar/ob_mask_DateField crashes VM
kvn
parents: 3941
diff changeset
122 }
5da7201222d5 7110824: ctw/jarfiles/GUI3rdParty_jar/ob_mask_DateField crashes VM
kvn
parents: 3941
diff changeset
123 #endif
5da7201222d5 7110824: ctw/jarfiles/GUI3rdParty_jar/ob_mask_DateField crashes VM
kvn
parents: 3941
diff changeset
124
0
a61af66fc99e Initial load
duke
parents:
diff changeset
125 //------------------------------yank_if_dead-----------------------------------
4776
5da7201222d5 7110824: ctw/jarfiles/GUI3rdParty_jar/ob_mask_DateField crashes VM
kvn
parents: 3941
diff changeset
126 // Removed edges from 'old'. Yank if dead. Return adjustment counts to
0
a61af66fc99e Initial load
duke
parents:
diff changeset
127 // iterators in the current block.
4776
5da7201222d5 7110824: ctw/jarfiles/GUI3rdParty_jar/ob_mask_DateField crashes VM
kvn
parents: 3941
diff changeset
128 int PhaseChaitin::yank_if_dead_recurse(Node *old, Node *orig_old, Block *current_block,
5da7201222d5 7110824: ctw/jarfiles/GUI3rdParty_jar/ob_mask_DateField crashes VM
kvn
parents: 3941
diff changeset
129 Node_List *value, Node_List *regnd) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
130 int blk_adjust=0;
4776
5da7201222d5 7110824: ctw/jarfiles/GUI3rdParty_jar/ob_mask_DateField crashes VM
kvn
parents: 3941
diff changeset
131 if (old->outcnt() == 0 && old != C->top()) {
5da7201222d5 7110824: ctw/jarfiles/GUI3rdParty_jar/ob_mask_DateField crashes VM
kvn
parents: 3941
diff changeset
132 #ifdef ASSERT
5da7201222d5 7110824: ctw/jarfiles/GUI3rdParty_jar/ob_mask_DateField crashes VM
kvn
parents: 3941
diff changeset
133 if (!expected_yanked_node(old, orig_old)) {
5da7201222d5 7110824: ctw/jarfiles/GUI3rdParty_jar/ob_mask_DateField crashes VM
kvn
parents: 3941
diff changeset
134 tty->print_cr("==============================================");
5da7201222d5 7110824: ctw/jarfiles/GUI3rdParty_jar/ob_mask_DateField crashes VM
kvn
parents: 3941
diff changeset
135 tty->print_cr("orig_old:");
5da7201222d5 7110824: ctw/jarfiles/GUI3rdParty_jar/ob_mask_DateField crashes VM
kvn
parents: 3941
diff changeset
136 orig_old->dump();
5da7201222d5 7110824: ctw/jarfiles/GUI3rdParty_jar/ob_mask_DateField crashes VM
kvn
parents: 3941
diff changeset
137 tty->print_cr("old:");
5da7201222d5 7110824: ctw/jarfiles/GUI3rdParty_jar/ob_mask_DateField crashes VM
kvn
parents: 3941
diff changeset
138 old->dump();
5da7201222d5 7110824: ctw/jarfiles/GUI3rdParty_jar/ob_mask_DateField crashes VM
kvn
parents: 3941
diff changeset
139 assert(false, "unexpected yanked node");
5da7201222d5 7110824: ctw/jarfiles/GUI3rdParty_jar/ob_mask_DateField crashes VM
kvn
parents: 3941
diff changeset
140 }
5da7201222d5 7110824: ctw/jarfiles/GUI3rdParty_jar/ob_mask_DateField crashes VM
kvn
parents: 3941
diff changeset
141 if (old->is_Con())
5da7201222d5 7110824: ctw/jarfiles/GUI3rdParty_jar/ob_mask_DateField crashes VM
kvn
parents: 3941
diff changeset
142 orig_old = old; // Reset to satisfy expected nodes checks.
5da7201222d5 7110824: ctw/jarfiles/GUI3rdParty_jar/ob_mask_DateField crashes VM
kvn
parents: 3941
diff changeset
143 #endif
3934
8f47d8870d9a 7087453: PhaseChaitin::yank_if_dead() should handle MachTemp inputs
roland
parents: 2008
diff changeset
144 blk_adjust += yank(old, current_block, value, regnd);
8f47d8870d9a 7087453: PhaseChaitin::yank_if_dead() should handle MachTemp inputs
roland
parents: 2008
diff changeset
145
8f47d8870d9a 7087453: PhaseChaitin::yank_if_dead() should handle MachTemp inputs
roland
parents: 2008
diff changeset
146 for (uint i = 1; i < old->req(); i++) {
4776
5da7201222d5 7110824: ctw/jarfiles/GUI3rdParty_jar/ob_mask_DateField crashes VM
kvn
parents: 3941
diff changeset
147 Node* n = old->in(i);
5da7201222d5 7110824: ctw/jarfiles/GUI3rdParty_jar/ob_mask_DateField crashes VM
kvn
parents: 3941
diff changeset
148 if (n != NULL) {
5da7201222d5 7110824: ctw/jarfiles/GUI3rdParty_jar/ob_mask_DateField crashes VM
kvn
parents: 3941
diff changeset
149 old->set_req(i, NULL);
5da7201222d5 7110824: ctw/jarfiles/GUI3rdParty_jar/ob_mask_DateField crashes VM
kvn
parents: 3941
diff changeset
150 blk_adjust += yank_if_dead_recurse(n, orig_old, current_block, value, regnd);
3934
8f47d8870d9a 7087453: PhaseChaitin::yank_if_dead() should handle MachTemp inputs
roland
parents: 2008
diff changeset
151 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
152 }
4776
5da7201222d5 7110824: ctw/jarfiles/GUI3rdParty_jar/ob_mask_DateField crashes VM
kvn
parents: 3941
diff changeset
153 // Disconnect control and remove precedence edges if any exist
7196
2aff40cb4703 7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents: 6185
diff changeset
154 old->disconnect_inputs(NULL, C);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
155 }
a61af66fc99e Initial load
duke
parents:
diff changeset
156 return blk_adjust;
a61af66fc99e Initial load
duke
parents:
diff changeset
157 }
a61af66fc99e Initial load
duke
parents:
diff changeset
158
a61af66fc99e Initial load
duke
parents:
diff changeset
159 //------------------------------use_prior_register-----------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
160 // Use the prior value instead of the current value, in an effort to make
a61af66fc99e Initial load
duke
parents:
diff changeset
161 // the current value go dead. Return block iterator adjustment, in case
a61af66fc99e Initial load
duke
parents:
diff changeset
162 // we yank some instructions from this block.
a61af66fc99e Initial load
duke
parents:
diff changeset
163 int PhaseChaitin::use_prior_register( Node *n, uint idx, Node *def, Block *current_block, Node_List &value, Node_List &regnd ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
164 // No effect?
a61af66fc99e Initial load
duke
parents:
diff changeset
165 if( def == n->in(idx) ) return 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
166 // Def is currently dead and can be removed? Do not resurrect
a61af66fc99e Initial load
duke
parents:
diff changeset
167 if( def->outcnt() == 0 ) return 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
168
a61af66fc99e Initial load
duke
parents:
diff changeset
169 // Not every pair of physical registers are assignment compatible,
a61af66fc99e Initial load
duke
parents:
diff changeset
170 // e.g. on sparc floating point registers are not assignable to integer
a61af66fc99e Initial load
duke
parents:
diff changeset
171 // registers.
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
172 const LRG &def_lrg = lrgs(_lrg_map.live_range_id(def));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
173 OptoReg::Name def_reg = def_lrg.reg();
a61af66fc99e Initial load
duke
parents:
diff changeset
174 const RegMask &use_mask = n->in_RegMask(idx);
a61af66fc99e Initial load
duke
parents:
diff changeset
175 bool can_use = ( RegMask::can_represent(def_reg) ? (use_mask.Member(def_reg) != 0)
a61af66fc99e Initial load
duke
parents:
diff changeset
176 : (use_mask.is_AllStack() != 0));
6179
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 4776
diff changeset
177 if (!RegMask::is_vector(def->ideal_reg())) {
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 4776
diff changeset
178 // Check for a copy to or from a misaligned pair.
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 4776
diff changeset
179 // It is workaround for a sparc with misaligned pairs.
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 4776
diff changeset
180 can_use = can_use && !use_mask.is_misaligned_pair() && !def_lrg.mask().is_misaligned_pair();
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 4776
diff changeset
181 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
182 if (!can_use)
a61af66fc99e Initial load
duke
parents:
diff changeset
183 return 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
184
a61af66fc99e Initial load
duke
parents:
diff changeset
185 // Capture the old def in case it goes dead...
a61af66fc99e Initial load
duke
parents:
diff changeset
186 Node *old = n->in(idx);
a61af66fc99e Initial load
duke
parents:
diff changeset
187
a61af66fc99e Initial load
duke
parents:
diff changeset
188 // Save-on-call copies can only be elided if the entire copy chain can go
a61af66fc99e Initial load
duke
parents:
diff changeset
189 // away, lest we get the same callee-save value alive in 2 locations at
a61af66fc99e Initial load
duke
parents:
diff changeset
190 // once. We check for the obvious trivial case here. Although it can
a61af66fc99e Initial load
duke
parents:
diff changeset
191 // sometimes be elided with cooperation outside our scope, here we will just
a61af66fc99e Initial load
duke
parents:
diff changeset
192 // miss the opportunity. :-(
a61af66fc99e Initial load
duke
parents:
diff changeset
193 if( may_be_copy_of_callee(def) ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
194 if( old->outcnt() > 1 ) return 0; // We're the not last user
a61af66fc99e Initial load
duke
parents:
diff changeset
195 int idx = old->is_Copy();
a61af66fc99e Initial load
duke
parents:
diff changeset
196 assert( idx, "chain of copies being removed" );
a61af66fc99e Initial load
duke
parents:
diff changeset
197 Node *old2 = old->in(idx); // Chain of copies
a61af66fc99e Initial load
duke
parents:
diff changeset
198 if( old2->outcnt() > 1 ) return 0; // old is not the last user
a61af66fc99e Initial load
duke
parents:
diff changeset
199 int idx2 = old2->is_Copy();
a61af66fc99e Initial load
duke
parents:
diff changeset
200 if( !idx2 ) return 0; // Not a chain of 2 copies
a61af66fc99e Initial load
duke
parents:
diff changeset
201 if( def != old2->in(idx2) ) return 0; // Chain of exactly 2 copies
a61af66fc99e Initial load
duke
parents:
diff changeset
202 }
a61af66fc99e Initial load
duke
parents:
diff changeset
203
a61af66fc99e Initial load
duke
parents:
diff changeset
204 // Use the new def
a61af66fc99e Initial load
duke
parents:
diff changeset
205 n->set_req(idx,def);
a61af66fc99e Initial load
duke
parents:
diff changeset
206 _post_alloc++;
a61af66fc99e Initial load
duke
parents:
diff changeset
207
a61af66fc99e Initial load
duke
parents:
diff changeset
208 // Is old def now dead? We successfully yanked a copy?
a61af66fc99e Initial load
duke
parents:
diff changeset
209 return yank_if_dead(old,current_block,&value,&regnd);
a61af66fc99e Initial load
duke
parents:
diff changeset
210 }
a61af66fc99e Initial load
duke
parents:
diff changeset
211
a61af66fc99e Initial load
duke
parents:
diff changeset
212
a61af66fc99e Initial load
duke
parents:
diff changeset
213 //------------------------------skip_copies------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
214 // Skip through any number of copies (that don't mod oop-i-ness)
a61af66fc99e Initial load
duke
parents:
diff changeset
215 Node *PhaseChaitin::skip_copies( Node *c ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
216 int idx = c->is_Copy();
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
217 uint is_oop = lrgs(_lrg_map.live_range_id(c))._is_oop;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
218 while (idx != 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
219 guarantee(c->in(idx) != NULL, "must not resurrect dead copy");
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
220 if (lrgs(_lrg_map.live_range_id(c->in(idx)))._is_oop != is_oop) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
221 break; // casting copy, not the same value
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
222 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
223 c = c->in(idx);
a61af66fc99e Initial load
duke
parents:
diff changeset
224 idx = c->is_Copy();
a61af66fc99e Initial load
duke
parents:
diff changeset
225 }
a61af66fc99e Initial load
duke
parents:
diff changeset
226 return c;
a61af66fc99e Initial load
duke
parents:
diff changeset
227 }
a61af66fc99e Initial load
duke
parents:
diff changeset
228
a61af66fc99e Initial load
duke
parents:
diff changeset
229 //------------------------------elide_copy-------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
230 // Remove (bypass) copies along Node n, edge k.
a61af66fc99e Initial load
duke
parents:
diff changeset
231 int PhaseChaitin::elide_copy( Node *n, int k, Block *current_block, Node_List &value, Node_List &regnd, bool can_change_regs ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
232 int blk_adjust = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
233
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
234 uint nk_idx = _lrg_map.live_range_id(n->in(k));
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
235 OptoReg::Name nk_reg = lrgs(nk_idx).reg();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
236
a61af66fc99e Initial load
duke
parents:
diff changeset
237 // Remove obvious same-register copies
a61af66fc99e Initial load
duke
parents:
diff changeset
238 Node *x = n->in(k);
a61af66fc99e Initial load
duke
parents:
diff changeset
239 int idx;
a61af66fc99e Initial load
duke
parents:
diff changeset
240 while( (idx=x->is_Copy()) != 0 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
241 Node *copy = x->in(idx);
a61af66fc99e Initial load
duke
parents:
diff changeset
242 guarantee(copy != NULL, "must not resurrect dead copy");
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
243 if(lrgs(_lrg_map.live_range_id(copy)).reg() != nk_reg) {
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
244 break;
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
245 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
246 blk_adjust += use_prior_register(n,k,copy,current_block,value,regnd);
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
247 if (n->in(k) != copy) {
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
248 break; // Failed for some cutout?
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
249 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
250 x = copy; // Progress, try again
a61af66fc99e Initial load
duke
parents:
diff changeset
251 }
a61af66fc99e Initial load
duke
parents:
diff changeset
252
a61af66fc99e Initial load
duke
parents:
diff changeset
253 // Phis and 2-address instructions cannot change registers so easily - their
a61af66fc99e Initial load
duke
parents:
diff changeset
254 // outputs must match their input.
a61af66fc99e Initial load
duke
parents:
diff changeset
255 if( !can_change_regs )
a61af66fc99e Initial load
duke
parents:
diff changeset
256 return blk_adjust; // Only check stupid copies!
a61af66fc99e Initial load
duke
parents:
diff changeset
257
a61af66fc99e Initial load
duke
parents:
diff changeset
258 // Loop backedges won't have a value-mapping yet
a61af66fc99e Initial load
duke
parents:
diff changeset
259 if( &value == NULL ) return blk_adjust;
a61af66fc99e Initial load
duke
parents:
diff changeset
260
a61af66fc99e Initial load
duke
parents:
diff changeset
261 // Skip through all copies to the _value_ being used. Do not change from
a61af66fc99e Initial load
duke
parents:
diff changeset
262 // int to pointer. This attempts to jump through a chain of copies, where
a61af66fc99e Initial load
duke
parents:
diff changeset
263 // intermediate copies might be illegal, i.e., value is stored down to stack
a61af66fc99e Initial load
duke
parents:
diff changeset
264 // then reloaded BUT survives in a register the whole way.
a61af66fc99e Initial load
duke
parents:
diff changeset
265 Node *val = skip_copies(n->in(k));
6179
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 4776
diff changeset
266 if (val == x) return blk_adjust; // No progress?
0
a61af66fc99e Initial load
duke
parents:
diff changeset
267
6179
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 4776
diff changeset
268 int n_regs = RegMask::num_registers(val->ideal_reg());
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
269 uint val_idx = _lrg_map.live_range_id(val);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
270 OptoReg::Name val_reg = lrgs(val_idx).reg();
a61af66fc99e Initial load
duke
parents:
diff changeset
271
a61af66fc99e Initial load
duke
parents:
diff changeset
272 // See if it happens to already be in the correct register!
a61af66fc99e Initial load
duke
parents:
diff changeset
273 // (either Phi's direct register, or the common case of the name
a61af66fc99e Initial load
duke
parents:
diff changeset
274 // never-clobbered original-def register)
6179
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 4776
diff changeset
275 if (register_contains_value(val, val_reg, n_regs, value)) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
276 blk_adjust += use_prior_register(n,k,regnd[val_reg],current_block,value,regnd);
a61af66fc99e Initial load
duke
parents:
diff changeset
277 if( n->in(k) == regnd[val_reg] ) // Success! Quit trying
a61af66fc99e Initial load
duke
parents:
diff changeset
278 return blk_adjust;
a61af66fc99e Initial load
duke
parents:
diff changeset
279 }
a61af66fc99e Initial load
duke
parents:
diff changeset
280
a61af66fc99e Initial load
duke
parents:
diff changeset
281 // See if we can skip the copy by changing registers. Don't change from
a61af66fc99e Initial load
duke
parents:
diff changeset
282 // using a register to using the stack unless we know we can remove a
a61af66fc99e Initial load
duke
parents:
diff changeset
283 // copy-load. Otherwise we might end up making a pile of Intel cisc-spill
a61af66fc99e Initial load
duke
parents:
diff changeset
284 // ops reading from memory instead of just loading once and using the
a61af66fc99e Initial load
duke
parents:
diff changeset
285 // register.
a61af66fc99e Initial load
duke
parents:
diff changeset
286
a61af66fc99e Initial load
duke
parents:
diff changeset
287 // Also handle duplicate copies here.
a61af66fc99e Initial load
duke
parents:
diff changeset
288 const Type *t = val->is_Con() ? val->bottom_type() : NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
289
a61af66fc99e Initial load
duke
parents:
diff changeset
290 // Scan all registers to see if this value is around already
a61af66fc99e Initial load
duke
parents:
diff changeset
291 for( uint reg = 0; reg < (uint)_max_reg; reg++ ) {
400
cc80376deb0c 6667595: Set probability FAIR for pre-, post- loops and ALWAYS for main loop
kvn
parents: 196
diff changeset
292 if (reg == (uint)nk_reg) {
cc80376deb0c 6667595: Set probability FAIR for pre-, post- loops and ALWAYS for main loop
kvn
parents: 196
diff changeset
293 // Found ourselves so check if there is only one user of this
cc80376deb0c 6667595: Set probability FAIR for pre-, post- loops and ALWAYS for main loop
kvn
parents: 196
diff changeset
294 // copy and keep on searching for a better copy if so.
cc80376deb0c 6667595: Set probability FAIR for pre-, post- loops and ALWAYS for main loop
kvn
parents: 196
diff changeset
295 bool ignore_self = true;
cc80376deb0c 6667595: Set probability FAIR for pre-, post- loops and ALWAYS for main loop
kvn
parents: 196
diff changeset
296 x = n->in(k);
cc80376deb0c 6667595: Set probability FAIR for pre-, post- loops and ALWAYS for main loop
kvn
parents: 196
diff changeset
297 DUIterator_Fast imax, i = x->fast_outs(imax);
cc80376deb0c 6667595: Set probability FAIR for pre-, post- loops and ALWAYS for main loop
kvn
parents: 196
diff changeset
298 Node* first = x->fast_out(i); i++;
cc80376deb0c 6667595: Set probability FAIR for pre-, post- loops and ALWAYS for main loop
kvn
parents: 196
diff changeset
299 while (i < imax && ignore_self) {
cc80376deb0c 6667595: Set probability FAIR for pre-, post- loops and ALWAYS for main loop
kvn
parents: 196
diff changeset
300 Node* use = x->fast_out(i); i++;
cc80376deb0c 6667595: Set probability FAIR for pre-, post- loops and ALWAYS for main loop
kvn
parents: 196
diff changeset
301 if (use != first) ignore_self = false;
cc80376deb0c 6667595: Set probability FAIR for pre-, post- loops and ALWAYS for main loop
kvn
parents: 196
diff changeset
302 }
cc80376deb0c 6667595: Set probability FAIR for pre-, post- loops and ALWAYS for main loop
kvn
parents: 196
diff changeset
303 if (ignore_self) continue;
cc80376deb0c 6667595: Set probability FAIR for pre-, post- loops and ALWAYS for main loop
kvn
parents: 196
diff changeset
304 }
cc80376deb0c 6667595: Set probability FAIR for pre-, post- loops and ALWAYS for main loop
kvn
parents: 196
diff changeset
305
0
a61af66fc99e Initial load
duke
parents:
diff changeset
306 Node *vv = value[reg];
6185
424142833d10 7178280: Failed new vector regression tests
kvn
parents: 6179
diff changeset
307 if (n_regs > 1) { // Doubles and vectors check for aligned-adjacent set
424142833d10 7178280: Failed new vector regression tests
kvn
parents: 6179
diff changeset
308 uint last = (n_regs-1); // Looking for the last part of a set
424142833d10 7178280: Failed new vector regression tests
kvn
parents: 6179
diff changeset
309 if ((reg&last) != last) continue; // Wrong part of a set
424142833d10 7178280: Failed new vector regression tests
kvn
parents: 6179
diff changeset
310 if (!register_contains_value(vv, reg, n_regs, value)) continue; // Different value
0
a61af66fc99e Initial load
duke
parents:
diff changeset
311 }
a61af66fc99e Initial load
duke
parents:
diff changeset
312 if( vv == val || // Got a direct hit?
a61af66fc99e Initial load
duke
parents:
diff changeset
313 (t && vv && vv->bottom_type() == t && vv->is_Mach() &&
a61af66fc99e Initial load
duke
parents:
diff changeset
314 vv->as_Mach()->rule() == val->as_Mach()->rule()) ) { // Or same constant?
a61af66fc99e Initial load
duke
parents:
diff changeset
315 assert( !n->is_Phi(), "cannot change registers at a Phi so easily" );
a61af66fc99e Initial load
duke
parents:
diff changeset
316 if( OptoReg::is_stack(nk_reg) || // CISC-loading from stack OR
a61af66fc99e Initial load
duke
parents:
diff changeset
317 OptoReg::is_reg(reg) || // turning into a register use OR
a61af66fc99e Initial load
duke
parents:
diff changeset
318 regnd[reg]->outcnt()==1 ) { // last use of a spill-load turns into a CISC use
a61af66fc99e Initial load
duke
parents:
diff changeset
319 blk_adjust += use_prior_register(n,k,regnd[reg],current_block,value,regnd);
a61af66fc99e Initial load
duke
parents:
diff changeset
320 if( n->in(k) == regnd[reg] ) // Success! Quit trying
a61af66fc99e Initial load
duke
parents:
diff changeset
321 return blk_adjust;
a61af66fc99e Initial load
duke
parents:
diff changeset
322 } // End of if not degrading to a stack
a61af66fc99e Initial load
duke
parents:
diff changeset
323 } // End of if found value in another register
a61af66fc99e Initial load
duke
parents:
diff changeset
324 } // End of scan all machine registers
a61af66fc99e Initial load
duke
parents:
diff changeset
325 return blk_adjust;
a61af66fc99e Initial load
duke
parents:
diff changeset
326 }
a61af66fc99e Initial load
duke
parents:
diff changeset
327
a61af66fc99e Initial load
duke
parents:
diff changeset
328
a61af66fc99e Initial load
duke
parents:
diff changeset
329 //
a61af66fc99e Initial load
duke
parents:
diff changeset
330 // Check if nreg already contains the constant value val. Normal copy
a61af66fc99e Initial load
duke
parents:
diff changeset
331 // elimination doesn't doesn't work on constants because multiple
a61af66fc99e Initial load
duke
parents:
diff changeset
332 // nodes can represent the same constant so the type and rule of the
a61af66fc99e Initial load
duke
parents:
diff changeset
333 // MachNode must be checked to ensure equivalence.
a61af66fc99e Initial load
duke
parents:
diff changeset
334 //
70
b683f557224b 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents: 0
diff changeset
335 bool PhaseChaitin::eliminate_copy_of_constant(Node* val, Node* n,
b683f557224b 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents: 0
diff changeset
336 Block *current_block,
0
a61af66fc99e Initial load
duke
parents:
diff changeset
337 Node_List& value, Node_List& regnd,
a61af66fc99e Initial load
duke
parents:
diff changeset
338 OptoReg::Name nreg, OptoReg::Name nreg2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
339 if (value[nreg] != val && val->is_Con() &&
a61af66fc99e Initial load
duke
parents:
diff changeset
340 value[nreg] != NULL && value[nreg]->is_Con() &&
a61af66fc99e Initial load
duke
parents:
diff changeset
341 (nreg2 == OptoReg::Bad || value[nreg] == value[nreg2]) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
342 value[nreg]->bottom_type() == val->bottom_type() &&
a61af66fc99e Initial load
duke
parents:
diff changeset
343 value[nreg]->as_Mach()->rule() == val->as_Mach()->rule()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
344 // This code assumes that two MachNodes representing constants
a61af66fc99e Initial load
duke
parents:
diff changeset
345 // which have the same rule and the same bottom type will produce
a61af66fc99e Initial load
duke
parents:
diff changeset
346 // identical effects into a register. This seems like it must be
a61af66fc99e Initial load
duke
parents:
diff changeset
347 // objectively true unless there are hidden inputs to the nodes
a61af66fc99e Initial load
duke
parents:
diff changeset
348 // but if that were to change this code would need to updated.
a61af66fc99e Initial load
duke
parents:
diff changeset
349 // Since they are equivalent the second one if redundant and can
a61af66fc99e Initial load
duke
parents:
diff changeset
350 // be removed.
a61af66fc99e Initial load
duke
parents:
diff changeset
351 //
70
b683f557224b 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents: 0
diff changeset
352 // n will be replaced with the old value but n might have
0
a61af66fc99e Initial load
duke
parents:
diff changeset
353 // kills projections associated with it so remove them now so that
605
98cb887364d3 6810672: Comment typos
twisti
parents: 400
diff changeset
354 // yank_if_dead will be able to eliminate the copy once the uses
0
a61af66fc99e Initial load
duke
parents:
diff changeset
355 // have been transferred to the old[value].
70
b683f557224b 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents: 0
diff changeset
356 for (DUIterator_Fast imax, i = n->fast_outs(imax); i < imax; i++) {
b683f557224b 6661247: Internal bug in 32-bit HotSpot optimizer while bit manipulations
never
parents: 0
diff changeset
357 Node* use = n->fast_out(i);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
358 if (use->is_Proj() && use->outcnt() == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
359 // Kill projections have no users and one input
a61af66fc99e Initial load
duke
parents:
diff changeset
360 use->set_req(0, C->top());
a61af66fc99e Initial load
duke
parents:
diff changeset
361 yank_if_dead(use, current_block, &value, &regnd);
a61af66fc99e Initial load
duke
parents:
diff changeset
362 --i; --imax;
a61af66fc99e Initial load
duke
parents:
diff changeset
363 }
a61af66fc99e Initial load
duke
parents:
diff changeset
364 }
a61af66fc99e Initial load
duke
parents:
diff changeset
365 _post_alloc++;
a61af66fc99e Initial load
duke
parents:
diff changeset
366 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
367 }
a61af66fc99e Initial load
duke
parents:
diff changeset
368 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
369 }
a61af66fc99e Initial load
duke
parents:
diff changeset
370
22815
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
371 // The algorithms works as follows:
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
372 // We traverse the block top to bottom. possibly_merge_multidef() is invoked for every input edge k
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
373 // of the instruction n. We check to see if the input is a multidef lrg. If it is, we record the fact that we've
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
374 // seen a definition (coming as an input) and add that fact to the reg2defuse array. The array maps registers to their
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
375 // current reaching definitions (we track only multidefs though). With each definition we also associate the first
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
376 // instruction we saw use it. If we encounter the situation when we observe an def (an input) that is a part of the
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
377 // same lrg but is different from the previous seen def we merge the two with a MachMerge node and substitute
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
378 // all the uses that we've seen so far to use the merge. After that we keep replacing the new defs in the same lrg
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
379 // as they get encountered with the merge node and keep adding these defs to the merge inputs.
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
380 void PhaseChaitin::merge_multidefs() {
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
381 NOT_PRODUCT( Compile::TracePhase t3("mergeMultidefs", &_t_mergeMultidefs, TimeCompiler); )
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
382 ResourceMark rm;
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
383 // Keep track of the defs seen in registers and collect their uses in the block.
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
384 RegToDefUseMap reg2defuse(_max_reg, _max_reg, RegDefUse());
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
385 for (uint i = 0; i < _cfg.number_of_blocks(); i++) {
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
386 Block* block = _cfg.get_block(i);
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
387 for (uint j = 1; j < block->number_of_nodes(); j++) {
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
388 Node* n = block->get_node(j);
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
389 if (n->is_Phi()) continue;
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
390 for (uint k = 1; k < n->req(); k++) {
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
391 j += possibly_merge_multidef(n, k, block, reg2defuse);
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
392 }
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
393 // Null out the value produced by the instruction itself, since we're only interested in defs
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
394 // implicitly defined by the uses. We are actually interested in tracking only redefinitions
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
395 // of the multidef lrgs in the same register. For that matter it's enough to track changes in
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
396 // the base register only and ignore other effects of multi-register lrgs and fat projections.
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
397 // It is also ok to ignore defs coming from singledefs. After an implicit overwrite by one of
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
398 // those our register is guaranteed to be used by another lrg and we won't attempt to merge it.
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
399 uint lrg = _lrg_map.live_range_id(n);
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
400 if (lrg > 0 && lrgs(lrg).is_multidef()) {
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
401 OptoReg::Name reg = lrgs(lrg).reg();
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
402 reg2defuse.at(reg).clear();
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
403 }
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
404 }
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
405 // Clear reg->def->use tracking for the next block
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
406 for (int j = 0; j < reg2defuse.length(); j++) {
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
407 reg2defuse.at(j).clear();
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
408 }
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
409 }
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
410 }
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
411
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
412 int PhaseChaitin::possibly_merge_multidef(Node *n, uint k, Block *block, RegToDefUseMap& reg2defuse) {
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
413 int blk_adjust = 0;
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
414
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
415 uint lrg = _lrg_map.live_range_id(n->in(k));
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
416 if (lrg > 0 && lrgs(lrg).is_multidef()) {
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
417 OptoReg::Name reg = lrgs(lrg).reg();
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
418
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
419 Node* def = reg2defuse.at(reg).def();
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
420 if (def != NULL && lrg == _lrg_map.live_range_id(def) && def != n->in(k)) {
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
421 // Same lrg but different node, we have to merge.
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
422 MachMergeNode* merge;
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
423 if (def->is_MachMerge()) { // is it already a merge?
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
424 merge = def->as_MachMerge();
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
425 } else {
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
426 merge = new (C) MachMergeNode(def);
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
427
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
428 // Insert the merge node into the block before the first use.
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
429 uint use_index = block->find_node(reg2defuse.at(reg).first_use());
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
430 block->insert_node(merge, use_index++);
22821
93c6b977591b 8071302: assert(!_reg_node[reg_lo] || edge_from_to(_reg_node[reg_lo], def)) failed: after block local
iveresov
parents: 22815
diff changeset
431 _cfg.map_node_to_block(merge, block);
22815
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
432
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
433 // Let the allocator know about the new node, use the same lrg
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
434 _lrg_map.extend(merge->_idx, lrg);
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
435 blk_adjust++;
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
436
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
437 // Fixup all the uses (there is at least one) that happened between the first
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
438 // use and before the current one.
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
439 for (; use_index < block->number_of_nodes(); use_index++) {
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
440 Node* use = block->get_node(use_index);
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
441 if (use == n) {
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
442 break;
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
443 }
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
444 use->replace_edge(def, merge);
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
445 }
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
446 }
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
447 if (merge->find_edge(n->in(k)) == -1) {
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
448 merge->add_req(n->in(k));
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
449 }
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
450 n->set_req(k, merge);
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
451 }
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
452
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
453 // update the uses
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
454 reg2defuse.at(reg).update(n->in(k), n);
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
455 }
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
456
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
457 return blk_adjust;
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
458 }
9df0d8f65fea 8068881: SIGBUS in C2 compiled method weblogic.wsee.jaxws.framework.jaxrpc.EnvironmentFactory$SimulatedWsdlDefinitions.<init>
iveresov
parents: 14223
diff changeset
459
0
a61af66fc99e Initial load
duke
parents:
diff changeset
460
a61af66fc99e Initial load
duke
parents:
diff changeset
461 //------------------------------post_allocate_copy_removal---------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
462 // Post-Allocation peephole copy removal. We do this in 1 pass over the
a61af66fc99e Initial load
duke
parents:
diff changeset
463 // basic blocks. We maintain a mapping of registers to Nodes (an array of
a61af66fc99e Initial load
duke
parents:
diff changeset
464 // Nodes indexed by machine register or stack slot number). NULL means that a
a61af66fc99e Initial load
duke
parents:
diff changeset
465 // register is not mapped to any Node. We can (want to have!) have several
a61af66fc99e Initial load
duke
parents:
diff changeset
466 // registers map to the same Node. We walk forward over the instructions
a61af66fc99e Initial load
duke
parents:
diff changeset
467 // updating the mapping as we go. At merge points we force a NULL if we have
a61af66fc99e Initial load
duke
parents:
diff changeset
468 // to merge 2 different Nodes into the same register. Phi functions will give
a61af66fc99e Initial load
duke
parents:
diff changeset
469 // us a new Node if there is a proper value merging. Since the blocks are
a61af66fc99e Initial load
duke
parents:
diff changeset
470 // arranged in some RPO, we will visit all parent blocks before visiting any
a61af66fc99e Initial load
duke
parents:
diff changeset
471 // successor blocks (except at loops).
a61af66fc99e Initial load
duke
parents:
diff changeset
472 //
a61af66fc99e Initial load
duke
parents:
diff changeset
473 // If we find a Copy we look to see if the Copy's source register is a stack
a61af66fc99e Initial load
duke
parents:
diff changeset
474 // slot and that value has already been loaded into some machine register; if
a61af66fc99e Initial load
duke
parents:
diff changeset
475 // so we use machine register directly. This turns a Load into a reg-reg
a61af66fc99e Initial load
duke
parents:
diff changeset
476 // Move. We also look for reloads of identical constants.
a61af66fc99e Initial load
duke
parents:
diff changeset
477 //
a61af66fc99e Initial load
duke
parents:
diff changeset
478 // When we see a use from a reg-reg Copy, we will attempt to use the copy's
a61af66fc99e Initial load
duke
parents:
diff changeset
479 // source directly and make the copy go dead.
a61af66fc99e Initial load
duke
parents:
diff changeset
480 void PhaseChaitin::post_allocate_copy_removal() {
a61af66fc99e Initial load
duke
parents:
diff changeset
481 NOT_PRODUCT( Compile::TracePhase t3("postAllocCopyRemoval", &_t_postAllocCopyRemoval, TimeCompiler); )
a61af66fc99e Initial load
duke
parents:
diff changeset
482 ResourceMark rm;
a61af66fc99e Initial load
duke
parents:
diff changeset
483
a61af66fc99e Initial load
duke
parents:
diff changeset
484 // Need a mapping from basic block Node_Lists. We need a Node_List to
a61af66fc99e Initial load
duke
parents:
diff changeset
485 // map from register number to value-producing Node.
12071
adb9a7d94cb5 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 12023
diff changeset
486 Node_List **blk2value = NEW_RESOURCE_ARRAY( Node_List *, _cfg.number_of_blocks() + 1);
adb9a7d94cb5 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 12023
diff changeset
487 memset(blk2value, 0, sizeof(Node_List*) * (_cfg.number_of_blocks() + 1));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
488 // Need a mapping from basic block Node_Lists. We need a Node_List to
a61af66fc99e Initial load
duke
parents:
diff changeset
489 // map from register number to register-defining Node.
12071
adb9a7d94cb5 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 12023
diff changeset
490 Node_List **blk2regnd = NEW_RESOURCE_ARRAY( Node_List *, _cfg.number_of_blocks() + 1);
adb9a7d94cb5 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 12023
diff changeset
491 memset(blk2regnd, 0, sizeof(Node_List*) * (_cfg.number_of_blocks() + 1));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
492
a61af66fc99e Initial load
duke
parents:
diff changeset
493 // We keep unused Node_Lists on a free_list to avoid wasting
a61af66fc99e Initial load
duke
parents:
diff changeset
494 // memory.
a61af66fc99e Initial load
duke
parents:
diff changeset
495 GrowableArray<Node_List*> free_list = GrowableArray<Node_List*>(16);
a61af66fc99e Initial load
duke
parents:
diff changeset
496
a61af66fc99e Initial load
duke
parents:
diff changeset
497 // For all blocks
12071
adb9a7d94cb5 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 12023
diff changeset
498 for (uint i = 0; i < _cfg.number_of_blocks(); i++) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
499 uint j;
12071
adb9a7d94cb5 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 12023
diff changeset
500 Block* block = _cfg.get_block(i);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
501
a61af66fc99e Initial load
duke
parents:
diff changeset
502 // Count of Phis in block
a61af66fc99e Initial load
duke
parents:
diff changeset
503 uint phi_dex;
12167
650868c062a9 8023691: Create interface for nodes in class Block
adlertz
parents: 12071
diff changeset
504 for (phi_dex = 1; phi_dex < block->number_of_nodes(); phi_dex++) {
650868c062a9 8023691: Create interface for nodes in class Block
adlertz
parents: 12071
diff changeset
505 Node* phi = block->get_node(phi_dex);
12071
adb9a7d94cb5 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 12023
diff changeset
506 if (!phi->is_Phi()) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
507 break;
12071
adb9a7d94cb5 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 12023
diff changeset
508 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
509 }
a61af66fc99e Initial load
duke
parents:
diff changeset
510
a61af66fc99e Initial load
duke
parents:
diff changeset
511 // If any predecessor has not been visited, we do not know the state
a61af66fc99e Initial load
duke
parents:
diff changeset
512 // of registers at the start. Check for this, while updating copies
a61af66fc99e Initial load
duke
parents:
diff changeset
513 // along Phi input edges
a61af66fc99e Initial load
duke
parents:
diff changeset
514 bool missing_some_inputs = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
515 Block *freed = NULL;
12071
adb9a7d94cb5 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 12023
diff changeset
516 for (j = 1; j < block->num_preds(); j++) {
adb9a7d94cb5 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 12023
diff changeset
517 Block* pb = _cfg.get_block_for_node(block->pred(j));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
518 // Remove copies along phi edges
12071
adb9a7d94cb5 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 12023
diff changeset
519 for (uint k = 1; k < phi_dex; k++) {
12167
650868c062a9 8023691: Create interface for nodes in class Block
adlertz
parents: 12071
diff changeset
520 elide_copy(block->get_node(k), j, block, *blk2value[pb->_pre_order], *blk2regnd[pb->_pre_order], false);
12071
adb9a7d94cb5 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 12023
diff changeset
521 }
adb9a7d94cb5 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 12023
diff changeset
522 if (blk2value[pb->_pre_order]) { // Have a mapping on this edge?
0
a61af66fc99e Initial load
duke
parents:
diff changeset
523 // See if this predecessor's mappings have been used by everybody
a61af66fc99e Initial load
duke
parents:
diff changeset
524 // who wants them. If so, free 'em.
a61af66fc99e Initial load
duke
parents:
diff changeset
525 uint k;
12071
adb9a7d94cb5 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 12023
diff changeset
526 for (k = 0; k < pb->_num_succs; k++) {
adb9a7d94cb5 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 12023
diff changeset
527 Block* pbsucc = pb->_succs[k];
adb9a7d94cb5 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 12023
diff changeset
528 if (!blk2value[pbsucc->_pre_order] && pbsucc != block) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
529 break; // Found a future user
12071
adb9a7d94cb5 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 12023
diff changeset
530 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
531 }
12071
adb9a7d94cb5 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 12023
diff changeset
532 if (k >= pb->_num_succs) { // No more uses, free!
0
a61af66fc99e Initial load
duke
parents:
diff changeset
533 freed = pb; // Record last block freed
a61af66fc99e Initial load
duke
parents:
diff changeset
534 free_list.push(blk2value[pb->_pre_order]);
a61af66fc99e Initial load
duke
parents:
diff changeset
535 free_list.push(blk2regnd[pb->_pre_order]);
a61af66fc99e Initial load
duke
parents:
diff changeset
536 }
a61af66fc99e Initial load
duke
parents:
diff changeset
537 } else { // This block has unvisited (loopback) inputs
a61af66fc99e Initial load
duke
parents:
diff changeset
538 missing_some_inputs = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
539 }
a61af66fc99e Initial load
duke
parents:
diff changeset
540 }
a61af66fc99e Initial load
duke
parents:
diff changeset
541
a61af66fc99e Initial load
duke
parents:
diff changeset
542
a61af66fc99e Initial load
duke
parents:
diff changeset
543 // Extract Node_List mappings. If 'freed' is non-zero, we just popped
a61af66fc99e Initial load
duke
parents:
diff changeset
544 // 'freed's blocks off the list
a61af66fc99e Initial load
duke
parents:
diff changeset
545 Node_List &regnd = *(free_list.is_empty() ? new Node_List() : free_list.pop());
a61af66fc99e Initial load
duke
parents:
diff changeset
546 Node_List &value = *(free_list.is_empty() ? new Node_List() : free_list.pop());
a61af66fc99e Initial load
duke
parents:
diff changeset
547 assert( !freed || blk2value[freed->_pre_order] == &value, "" );
a61af66fc99e Initial load
duke
parents:
diff changeset
548 value.map(_max_reg,NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
549 regnd.map(_max_reg,NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
550 // Set mappings as OUR mappings
12071
adb9a7d94cb5 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 12023
diff changeset
551 blk2value[block->_pre_order] = &value;
adb9a7d94cb5 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 12023
diff changeset
552 blk2regnd[block->_pre_order] = &regnd;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
553
a61af66fc99e Initial load
duke
parents:
diff changeset
554 // Initialize value & regnd for this block
12071
adb9a7d94cb5 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 12023
diff changeset
555 if (missing_some_inputs) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
556 // Some predecessor has not yet been visited; zap map to empty
12071
adb9a7d94cb5 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 12023
diff changeset
557 for (uint k = 0; k < (uint)_max_reg; k++) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
558 value.map(k,NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
559 regnd.map(k,NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
560 }
a61af66fc99e Initial load
duke
parents:
diff changeset
561 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
562 if( !freed ) { // Didn't get a freebie prior block
a61af66fc99e Initial load
duke
parents:
diff changeset
563 // Must clone some data
12071
adb9a7d94cb5 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 12023
diff changeset
564 freed = _cfg.get_block_for_node(block->pred(1));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
565 Node_List &f_value = *blk2value[freed->_pre_order];
a61af66fc99e Initial load
duke
parents:
diff changeset
566 Node_List &f_regnd = *blk2regnd[freed->_pre_order];
a61af66fc99e Initial load
duke
parents:
diff changeset
567 for( uint k = 0; k < (uint)_max_reg; k++ ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
568 value.map(k,f_value[k]);
a61af66fc99e Initial load
duke
parents:
diff changeset
569 regnd.map(k,f_regnd[k]);
a61af66fc99e Initial load
duke
parents:
diff changeset
570 }
a61af66fc99e Initial load
duke
parents:
diff changeset
571 }
a61af66fc99e Initial load
duke
parents:
diff changeset
572 // Merge all inputs together, setting to NULL any conflicts.
12071
adb9a7d94cb5 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 12023
diff changeset
573 for (j = 1; j < block->num_preds(); j++) {
adb9a7d94cb5 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 12023
diff changeset
574 Block* pb = _cfg.get_block_for_node(block->pred(j));
adb9a7d94cb5 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 12023
diff changeset
575 if (pb == freed) {
adb9a7d94cb5 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 12023
diff changeset
576 continue; // Did self already via freelist
adb9a7d94cb5 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 12023
diff changeset
577 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
578 Node_List &p_regnd = *blk2regnd[pb->_pre_order];
a61af66fc99e Initial load
duke
parents:
diff changeset
579 for( uint k = 0; k < (uint)_max_reg; k++ ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
580 if( regnd[k] != p_regnd[k] ) { // Conflict on reaching defs?
a61af66fc99e Initial load
duke
parents:
diff changeset
581 value.map(k,NULL); // Then no value handy
a61af66fc99e Initial load
duke
parents:
diff changeset
582 regnd.map(k,NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
583 }
a61af66fc99e Initial load
duke
parents:
diff changeset
584 }
a61af66fc99e Initial load
duke
parents:
diff changeset
585 }
a61af66fc99e Initial load
duke
parents:
diff changeset
586 }
a61af66fc99e Initial load
duke
parents:
diff changeset
587
a61af66fc99e Initial load
duke
parents:
diff changeset
588 // For all Phi's
12071
adb9a7d94cb5 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 12023
diff changeset
589 for (j = 1; j < phi_dex; j++) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
590 uint k;
12167
650868c062a9 8023691: Create interface for nodes in class Block
adlertz
parents: 12071
diff changeset
591 Node *phi = block->get_node(j);
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
592 uint pidx = _lrg_map.live_range_id(phi);
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
593 OptoReg::Name preg = lrgs(_lrg_map.live_range_id(phi)).reg();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
594
a61af66fc99e Initial load
duke
parents:
diff changeset
595 // Remove copies remaining on edges. Check for junk phi.
a61af66fc99e Initial load
duke
parents:
diff changeset
596 Node *u = NULL;
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
597 for (k = 1; k < phi->req(); k++) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
598 Node *x = phi->in(k);
a61af66fc99e Initial load
duke
parents:
diff changeset
599 if( phi != x && u != x ) // Found a different input
a61af66fc99e Initial load
duke
parents:
diff changeset
600 u = u ? NodeSentinel : x; // Capture unique input, or NodeSentinel for 2nd input
a61af66fc99e Initial load
duke
parents:
diff changeset
601 }
12071
adb9a7d94cb5 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 12023
diff changeset
602 if (u != NodeSentinel) { // Junk Phi. Remove
13012
f01788f13696 8026940: assert(n->outcnt() != 0 || C->top() == n || n->is_Proj()) failed: No dead instructions after post-alloc
adlertz
parents: 12167
diff changeset
603 phi->replace_by(u);
f01788f13696 8026940: assert(n->outcnt() != 0 || C->top() == n || n->is_Proj()) failed: No dead instructions after post-alloc
adlertz
parents: 12167
diff changeset
604 j -= yank_if_dead(phi, block, &value, &regnd);
12023
d1034bd8cefc 8022284: Hide internal data structure in PhaseCFG
adlertz
parents: 10111
diff changeset
605 phi_dex--;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
606 continue;
a61af66fc99e Initial load
duke
parents:
diff changeset
607 }
a61af66fc99e Initial load
duke
parents:
diff changeset
608 // Note that if value[pidx] exists, then we merged no new values here
a61af66fc99e Initial load
duke
parents:
diff changeset
609 // and the phi is useless. This can happen even with the above phi
a61af66fc99e Initial load
duke
parents:
diff changeset
610 // removal for complex flows. I cannot keep the better known value here
a61af66fc99e Initial load
duke
parents:
diff changeset
611 // because locally the phi appears to define a new merged value. If I
a61af66fc99e Initial load
duke
parents:
diff changeset
612 // keep the better value then a copy of the phi, being unable to use the
a61af66fc99e Initial load
duke
parents:
diff changeset
613 // global flow analysis, can't "peek through" the phi to the original
a61af66fc99e Initial load
duke
parents:
diff changeset
614 // reaching value and so will act like it's defining a new value. This
a61af66fc99e Initial load
duke
parents:
diff changeset
615 // can lead to situations where some uses are from the old and some from
a61af66fc99e Initial load
duke
parents:
diff changeset
616 // the new values. Not illegal by itself but throws the over-strong
a61af66fc99e Initial load
duke
parents:
diff changeset
617 // assert in scheduling.
a61af66fc99e Initial load
duke
parents:
diff changeset
618 if( pidx ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
619 value.map(preg,phi);
a61af66fc99e Initial load
duke
parents:
diff changeset
620 regnd.map(preg,phi);
6179
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 4776
diff changeset
621 int n_regs = RegMask::num_registers(phi->ideal_reg());
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 4776
diff changeset
622 for (int l = 1; l < n_regs; l++) {
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 4776
diff changeset
623 OptoReg::Name preg_lo = OptoReg::add(preg,-l);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
624 value.map(preg_lo,phi);
a61af66fc99e Initial load
duke
parents:
diff changeset
625 regnd.map(preg_lo,phi);
a61af66fc99e Initial load
duke
parents:
diff changeset
626 }
a61af66fc99e Initial load
duke
parents:
diff changeset
627 }
a61af66fc99e Initial load
duke
parents:
diff changeset
628 }
a61af66fc99e Initial load
duke
parents:
diff changeset
629
a61af66fc99e Initial load
duke
parents:
diff changeset
630 // For all remaining instructions
12167
650868c062a9 8023691: Create interface for nodes in class Block
adlertz
parents: 12071
diff changeset
631 for (j = phi_dex; j < block->number_of_nodes(); j++) {
650868c062a9 8023691: Create interface for nodes in class Block
adlertz
parents: 12071
diff changeset
632 Node* n = block->get_node(j);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
633
12071
adb9a7d94cb5 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 12023
diff changeset
634 if(n->outcnt() == 0 && // Dead?
adb9a7d94cb5 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 12023
diff changeset
635 n != C->top() && // (ignore TOP, it has no du info)
adb9a7d94cb5 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 12023
diff changeset
636 !n->is_Proj() ) { // fat-proj kills
adb9a7d94cb5 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 12023
diff changeset
637 j -= yank_if_dead(n, block, &value, &regnd);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
638 continue;
a61af66fc99e Initial load
duke
parents:
diff changeset
639 }
a61af66fc99e Initial load
duke
parents:
diff changeset
640
a61af66fc99e Initial load
duke
parents:
diff changeset
641 // Improve reaching-def info. Occasionally post-alloc's liveness gives
a61af66fc99e Initial load
duke
parents:
diff changeset
642 // up (at loop backedges, because we aren't doing a full flow pass).
a61af66fc99e Initial load
duke
parents:
diff changeset
643 // The presence of a live use essentially asserts that the use's def is
a61af66fc99e Initial load
duke
parents:
diff changeset
644 // alive and well at the use (or else the allocator fubar'd). Take
a61af66fc99e Initial load
duke
parents:
diff changeset
645 // advantage of this info to set a reaching def for the use-reg.
a61af66fc99e Initial load
duke
parents:
diff changeset
646 uint k;
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
647 for (k = 1; k < n->req(); k++) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
648 Node *def = n->in(k); // n->in(k) is a USE; def is the DEF for this USE
a61af66fc99e Initial load
duke
parents:
diff changeset
649 guarantee(def != NULL, "no disconnected nodes at this point");
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
650 uint useidx = _lrg_map.live_range_id(def); // useidx is the live range index for this USE
0
a61af66fc99e Initial load
duke
parents:
diff changeset
651
a61af66fc99e Initial load
duke
parents:
diff changeset
652 if( useidx ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
653 OptoReg::Name ureg = lrgs(useidx).reg();
a61af66fc99e Initial load
duke
parents:
diff changeset
654 if( !value[ureg] ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
655 int idx; // Skip occasional useless copy
a61af66fc99e Initial load
duke
parents:
diff changeset
656 while( (idx=def->is_Copy()) != 0 &&
a61af66fc99e Initial load
duke
parents:
diff changeset
657 def->in(idx) != NULL && // NULL should not happen
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
658 ureg == lrgs(_lrg_map.live_range_id(def->in(idx))).reg())
0
a61af66fc99e Initial load
duke
parents:
diff changeset
659 def = def->in(idx);
a61af66fc99e Initial load
duke
parents:
diff changeset
660 Node *valdef = skip_copies(def); // tighten up val through non-useless copies
a61af66fc99e Initial load
duke
parents:
diff changeset
661 value.map(ureg,valdef); // record improved reaching-def info
a61af66fc99e Initial load
duke
parents:
diff changeset
662 regnd.map(ureg, def);
a61af66fc99e Initial load
duke
parents:
diff changeset
663 // Record other half of doubles
6179
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 4776
diff changeset
664 uint def_ideal_reg = def->ideal_reg();
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 4776
diff changeset
665 int n_regs = RegMask::num_registers(def_ideal_reg);
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 4776
diff changeset
666 for (int l = 1; l < n_regs; l++) {
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 4776
diff changeset
667 OptoReg::Name ureg_lo = OptoReg::add(ureg,-l);
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 4776
diff changeset
668 if (!value[ureg_lo] &&
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 4776
diff changeset
669 (!RegMask::can_represent(ureg_lo) ||
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 4776
diff changeset
670 lrgs(useidx).mask().Member(ureg_lo))) { // Nearly always adjacent
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 4776
diff changeset
671 value.map(ureg_lo,valdef); // record improved reaching-def info
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 4776
diff changeset
672 regnd.map(ureg_lo, def);
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 4776
diff changeset
673 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
674 }
a61af66fc99e Initial load
duke
parents:
diff changeset
675 }
a61af66fc99e Initial load
duke
parents:
diff changeset
676 }
a61af66fc99e Initial load
duke
parents:
diff changeset
677 }
a61af66fc99e Initial load
duke
parents:
diff changeset
678
a61af66fc99e Initial load
duke
parents:
diff changeset
679 const uint two_adr = n->is_Mach() ? n->as_Mach()->two_adr() : 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
680
a61af66fc99e Initial load
duke
parents:
diff changeset
681 // Remove copies along input edges
12071
adb9a7d94cb5 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 12023
diff changeset
682 for (k = 1; k < n->req(); k++) {
adb9a7d94cb5 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 12023
diff changeset
683 j -= elide_copy(n, k, block, value, regnd, two_adr != k);
adb9a7d94cb5 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 12023
diff changeset
684 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
685
a61af66fc99e Initial load
duke
parents:
diff changeset
686 // Unallocated Nodes define no registers
10111
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
687 uint lidx = _lrg_map.live_range_id(n);
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
688 if (!lidx) {
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
689 continue;
8373c19be854 8011621: live_ranges_in_separate_class.patch
neliasso
parents: 7196
diff changeset
690 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
691
a61af66fc99e Initial load
duke
parents:
diff changeset
692 // Update the register defined by this instruction
a61af66fc99e Initial load
duke
parents:
diff changeset
693 OptoReg::Name nreg = lrgs(lidx).reg();
a61af66fc99e Initial load
duke
parents:
diff changeset
694 // Skip through all copies to the _value_ being defined.
a61af66fc99e Initial load
duke
parents:
diff changeset
695 // Do not change from int to pointer
a61af66fc99e Initial load
duke
parents:
diff changeset
696 Node *val = skip_copies(n);
a61af66fc99e Initial load
duke
parents:
diff changeset
697
923
a70508bb21c3 6862863: C2 compiler fails in elide_copy()
never
parents: 605
diff changeset
698 // Clear out a dead definition before starting so that the
a70508bb21c3 6862863: C2 compiler fails in elide_copy()
never
parents: 605
diff changeset
699 // elimination code doesn't have to guard against it. The
a70508bb21c3 6862863: C2 compiler fails in elide_copy()
never
parents: 605
diff changeset
700 // definition could in fact be a kill projection with a count of
a70508bb21c3 6862863: C2 compiler fails in elide_copy()
never
parents: 605
diff changeset
701 // 0 which is safe but since those are uninteresting for copy
a70508bb21c3 6862863: C2 compiler fails in elide_copy()
never
parents: 605
diff changeset
702 // elimination just delete them as well.
a70508bb21c3 6862863: C2 compiler fails in elide_copy()
never
parents: 605
diff changeset
703 if (regnd[nreg] != NULL && regnd[nreg]->outcnt() == 0) {
a70508bb21c3 6862863: C2 compiler fails in elide_copy()
never
parents: 605
diff changeset
704 regnd.map(nreg, NULL);
a70508bb21c3 6862863: C2 compiler fails in elide_copy()
never
parents: 605
diff changeset
705 value.map(nreg, NULL);
a70508bb21c3 6862863: C2 compiler fails in elide_copy()
never
parents: 605
diff changeset
706 }
a70508bb21c3 6862863: C2 compiler fails in elide_copy()
never
parents: 605
diff changeset
707
0
a61af66fc99e Initial load
duke
parents:
diff changeset
708 uint n_ideal_reg = n->ideal_reg();
6179
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 4776
diff changeset
709 int n_regs = RegMask::num_registers(n_ideal_reg);
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 4776
diff changeset
710 if (n_regs == 1) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
711 // If Node 'n' does not change the value mapped by the register,
a61af66fc99e Initial load
duke
parents:
diff changeset
712 // then 'n' is a useless copy. Do not update the register->node
a61af66fc99e Initial load
duke
parents:
diff changeset
713 // mapping so 'n' will go dead.
a61af66fc99e Initial load
duke
parents:
diff changeset
714 if( value[nreg] != val ) {
12071
adb9a7d94cb5 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 12023
diff changeset
715 if (eliminate_copy_of_constant(val, n, block, value, regnd, nreg, OptoReg::Bad)) {
adb9a7d94cb5 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 12023
diff changeset
716 j -= replace_and_yank_if_dead(n, nreg, block, value, regnd);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
717 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
718 // Update the mapping: record new Node defined by the register
a61af66fc99e Initial load
duke
parents:
diff changeset
719 regnd.map(nreg,n);
a61af66fc99e Initial load
duke
parents:
diff changeset
720 // Update mapping for defined *value*, which is the defined
a61af66fc99e Initial load
duke
parents:
diff changeset
721 // Node after skipping all copies.
a61af66fc99e Initial load
duke
parents:
diff changeset
722 value.map(nreg,val);
a61af66fc99e Initial load
duke
parents:
diff changeset
723 }
923
a70508bb21c3 6862863: C2 compiler fails in elide_copy()
never
parents: 605
diff changeset
724 } else if( !may_be_copy_of_callee(n) ) {
12071
adb9a7d94cb5 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 12023
diff changeset
725 assert(n->is_Copy(), "");
adb9a7d94cb5 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 12023
diff changeset
726 j -= replace_and_yank_if_dead(n, nreg, block, value, regnd);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
727 }
6179
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 4776
diff changeset
728 } else if (RegMask::is_vector(n_ideal_reg)) {
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 4776
diff changeset
729 // If Node 'n' does not change the value mapped by the register,
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 4776
diff changeset
730 // then 'n' is a useless copy. Do not update the register->node
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 4776
diff changeset
731 // mapping so 'n' will go dead.
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 4776
diff changeset
732 if (!register_contains_value(val, nreg, n_regs, value)) {
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 4776
diff changeset
733 // Update the mapping: record new Node defined by the register
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 4776
diff changeset
734 regnd.map(nreg,n);
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 4776
diff changeset
735 // Update mapping for defined *value*, which is the defined
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 4776
diff changeset
736 // Node after skipping all copies.
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 4776
diff changeset
737 value.map(nreg,val);
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 4776
diff changeset
738 for (int l = 1; l < n_regs; l++) {
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 4776
diff changeset
739 OptoReg::Name nreg_lo = OptoReg::add(nreg,-l);
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 4776
diff changeset
740 regnd.map(nreg_lo, n );
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 4776
diff changeset
741 value.map(nreg_lo,val);
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 4776
diff changeset
742 }
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 4776
diff changeset
743 } else if (n->is_Copy()) {
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 4776
diff changeset
744 // Note: vector can't be constant and can't be copy of calee.
12071
adb9a7d94cb5 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 12023
diff changeset
745 j -= replace_and_yank_if_dead(n, nreg, block, value, regnd);
6179
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 4776
diff changeset
746 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
747 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
748 // If the value occupies a register pair, record same info
a61af66fc99e Initial load
duke
parents:
diff changeset
749 // in both registers.
a61af66fc99e Initial load
duke
parents:
diff changeset
750 OptoReg::Name nreg_lo = OptoReg::add(nreg,-1);
a61af66fc99e Initial load
duke
parents:
diff changeset
751 if( RegMask::can_represent(nreg_lo) && // Either a spill slot, or
a61af66fc99e Initial load
duke
parents:
diff changeset
752 !lrgs(lidx).mask().Member(nreg_lo) ) { // Nearly always adjacent
a61af66fc99e Initial load
duke
parents:
diff changeset
753 // Sparc occasionally has non-adjacent pairs.
a61af66fc99e Initial load
duke
parents:
diff changeset
754 // Find the actual other value
a61af66fc99e Initial load
duke
parents:
diff changeset
755 RegMask tmp = lrgs(lidx).mask();
a61af66fc99e Initial load
duke
parents:
diff changeset
756 tmp.Remove(nreg);
a61af66fc99e Initial load
duke
parents:
diff changeset
757 nreg_lo = tmp.find_first_elem();
a61af66fc99e Initial load
duke
parents:
diff changeset
758 }
12071
adb9a7d94cb5 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 12023
diff changeset
759 if (value[nreg] != val || value[nreg_lo] != val) {
adb9a7d94cb5 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 12023
diff changeset
760 if (eliminate_copy_of_constant(val, n, block, value, regnd, nreg, nreg_lo)) {
adb9a7d94cb5 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 12023
diff changeset
761 j -= replace_and_yank_if_dead(n, nreg, block, value, regnd);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
762 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
763 regnd.map(nreg , n );
a61af66fc99e Initial load
duke
parents:
diff changeset
764 regnd.map(nreg_lo, n );
a61af66fc99e Initial load
duke
parents:
diff changeset
765 value.map(nreg ,val);
a61af66fc99e Initial load
duke
parents:
diff changeset
766 value.map(nreg_lo,val);
a61af66fc99e Initial load
duke
parents:
diff changeset
767 }
12071
adb9a7d94cb5 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 12023
diff changeset
768 } else if (!may_be_copy_of_callee(n)) {
adb9a7d94cb5 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 12023
diff changeset
769 assert(n->is_Copy(), "");
adb9a7d94cb5 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 12023
diff changeset
770 j -= replace_and_yank_if_dead(n, nreg, block, value, regnd);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
771 }
a61af66fc99e Initial load
duke
parents:
diff changeset
772 }
a61af66fc99e Initial load
duke
parents:
diff changeset
773
a61af66fc99e Initial load
duke
parents:
diff changeset
774 // Fat projections kill many registers
a61af66fc99e Initial load
duke
parents:
diff changeset
775 if( n_ideal_reg == MachProjNode::fat_proj ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
776 RegMask rm = n->out_RegMask();
a61af66fc99e Initial load
duke
parents:
diff changeset
777 // wow, what an expensive iterator...
a61af66fc99e Initial load
duke
parents:
diff changeset
778 nreg = rm.find_first_elem();
a61af66fc99e Initial load
duke
parents:
diff changeset
779 while( OptoReg::is_valid(nreg)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
780 rm.Remove(nreg);
a61af66fc99e Initial load
duke
parents:
diff changeset
781 value.map(nreg,n);
a61af66fc99e Initial load
duke
parents:
diff changeset
782 regnd.map(nreg,n);
a61af66fc99e Initial load
duke
parents:
diff changeset
783 nreg = rm.find_first_elem();
a61af66fc99e Initial load
duke
parents:
diff changeset
784 }
a61af66fc99e Initial load
duke
parents:
diff changeset
785 }
a61af66fc99e Initial load
duke
parents:
diff changeset
786
a61af66fc99e Initial load
duke
parents:
diff changeset
787 } // End of for all instructions in the block
a61af66fc99e Initial load
duke
parents:
diff changeset
788
a61af66fc99e Initial load
duke
parents:
diff changeset
789 } // End for all blocks
a61af66fc99e Initial load
duke
parents:
diff changeset
790 }