annotate src/share/vm/opto/output.hpp @ 196:d1605aabd0a1 jdk7-b30

6719955: Update copyright year Summary: Update copyright year for files that have been modified in 2008 Reviewed-by: ohair, tbell
author xdono
date Wed, 02 Jul 2008 12:55:16 -0700
parents a61af66fc99e
children c18cbe5936b8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
2 * Copyright 2000-2005 Sun Microsystems, Inc. All Rights Reserved.
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 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 class Arena;
a61af66fc99e Initial load
duke
parents:
diff changeset
26 class Bundle;
a61af66fc99e Initial load
duke
parents:
diff changeset
27 class Block;
a61af66fc99e Initial load
duke
parents:
diff changeset
28 class Block_Array;
a61af66fc99e Initial load
duke
parents:
diff changeset
29 class Node;
a61af66fc99e Initial load
duke
parents:
diff changeset
30 class Node_Array;
a61af66fc99e Initial load
duke
parents:
diff changeset
31 class Node_List;
a61af66fc99e Initial load
duke
parents:
diff changeset
32 class PhaseCFG;
a61af66fc99e Initial load
duke
parents:
diff changeset
33 class PhaseChaitin;
a61af66fc99e Initial load
duke
parents:
diff changeset
34 class Pipeline_Use_Element;
a61af66fc99e Initial load
duke
parents:
diff changeset
35 class Pipeline_Use;
a61af66fc99e Initial load
duke
parents:
diff changeset
36
a61af66fc99e Initial load
duke
parents:
diff changeset
37 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
38 #define DEBUG_ARG(x) , x
a61af66fc99e Initial load
duke
parents:
diff changeset
39 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
40 #define DEBUG_ARG(x)
a61af66fc99e Initial load
duke
parents:
diff changeset
41 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
42
a61af66fc99e Initial load
duke
parents:
diff changeset
43 // Define the initial sizes for allocation of the resizable code buffer
a61af66fc99e Initial load
duke
parents:
diff changeset
44 enum {
a61af66fc99e Initial load
duke
parents:
diff changeset
45 initial_code_capacity = 16 * 1024,
a61af66fc99e Initial load
duke
parents:
diff changeset
46 initial_stub_capacity = 4 * 1024,
a61af66fc99e Initial load
duke
parents:
diff changeset
47 initial_const_capacity = 4 * 1024,
a61af66fc99e Initial load
duke
parents:
diff changeset
48 initial_locs_capacity = 3 * 1024
a61af66fc99e Initial load
duke
parents:
diff changeset
49 };
a61af66fc99e Initial load
duke
parents:
diff changeset
50
a61af66fc99e Initial load
duke
parents:
diff changeset
51 //------------------------------Scheduling----------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
52 // This class contains all the information necessary to implement instruction
a61af66fc99e Initial load
duke
parents:
diff changeset
53 // scheduling and bundling.
a61af66fc99e Initial load
duke
parents:
diff changeset
54 class Scheduling {
a61af66fc99e Initial load
duke
parents:
diff changeset
55
a61af66fc99e Initial load
duke
parents:
diff changeset
56 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
57 // Arena to use
a61af66fc99e Initial load
duke
parents:
diff changeset
58 Arena *_arena;
a61af66fc99e Initial load
duke
parents:
diff changeset
59
a61af66fc99e Initial load
duke
parents:
diff changeset
60 // Control-Flow Graph info
a61af66fc99e Initial load
duke
parents:
diff changeset
61 PhaseCFG *_cfg;
a61af66fc99e Initial load
duke
parents:
diff changeset
62
a61af66fc99e Initial load
duke
parents:
diff changeset
63 // Register Allocation info
a61af66fc99e Initial load
duke
parents:
diff changeset
64 PhaseRegAlloc *_regalloc;
a61af66fc99e Initial load
duke
parents:
diff changeset
65
a61af66fc99e Initial load
duke
parents:
diff changeset
66 // Number of nodes in the method
a61af66fc99e Initial load
duke
parents:
diff changeset
67 uint _node_bundling_limit;
a61af66fc99e Initial load
duke
parents:
diff changeset
68
a61af66fc99e Initial load
duke
parents:
diff changeset
69 // List of scheduled nodes. Generated in reverse order
a61af66fc99e Initial load
duke
parents:
diff changeset
70 Node_List _scheduled;
a61af66fc99e Initial load
duke
parents:
diff changeset
71
a61af66fc99e Initial load
duke
parents:
diff changeset
72 // List of nodes currently available for choosing for scheduling
a61af66fc99e Initial load
duke
parents:
diff changeset
73 Node_List _available;
a61af66fc99e Initial load
duke
parents:
diff changeset
74
a61af66fc99e Initial load
duke
parents:
diff changeset
75 // Mapping from node (index) to basic block
a61af66fc99e Initial load
duke
parents:
diff changeset
76 Block_Array& _bbs;
a61af66fc99e Initial load
duke
parents:
diff changeset
77
a61af66fc99e Initial load
duke
parents:
diff changeset
78 // For each instruction beginning a bundle, the number of following
a61af66fc99e Initial load
duke
parents:
diff changeset
79 // nodes to be bundled with it.
a61af66fc99e Initial load
duke
parents:
diff changeset
80 Bundle *_node_bundling_base;
a61af66fc99e Initial load
duke
parents:
diff changeset
81
a61af66fc99e Initial load
duke
parents:
diff changeset
82 // Mapping from register to Node
a61af66fc99e Initial load
duke
parents:
diff changeset
83 Node_List _reg_node;
a61af66fc99e Initial load
duke
parents:
diff changeset
84
a61af66fc99e Initial load
duke
parents:
diff changeset
85 // Free list for pinch nodes.
a61af66fc99e Initial load
duke
parents:
diff changeset
86 Node_List _pinch_free_list;
a61af66fc99e Initial load
duke
parents:
diff changeset
87
a61af66fc99e Initial load
duke
parents:
diff changeset
88 // Latency from the beginning of the containing basic block (base 1)
a61af66fc99e Initial load
duke
parents:
diff changeset
89 // for each node.
a61af66fc99e Initial load
duke
parents:
diff changeset
90 unsigned short *_node_latency;
a61af66fc99e Initial load
duke
parents:
diff changeset
91
a61af66fc99e Initial load
duke
parents:
diff changeset
92 // Number of uses of this node within the containing basic block.
a61af66fc99e Initial load
duke
parents:
diff changeset
93 short *_uses;
a61af66fc99e Initial load
duke
parents:
diff changeset
94
a61af66fc99e Initial load
duke
parents:
diff changeset
95 // Schedulable portion of current block. Skips Region/Phi/CreateEx up
a61af66fc99e Initial load
duke
parents:
diff changeset
96 // front, branch+proj at end. Also skips Catch/CProj (same as
a61af66fc99e Initial load
duke
parents:
diff changeset
97 // branch-at-end), plus just-prior exception-throwing call.
a61af66fc99e Initial load
duke
parents:
diff changeset
98 uint _bb_start, _bb_end;
a61af66fc99e Initial load
duke
parents:
diff changeset
99
a61af66fc99e Initial load
duke
parents:
diff changeset
100 // Latency from the end of the basic block as scheduled
a61af66fc99e Initial load
duke
parents:
diff changeset
101 unsigned short *_current_latency;
a61af66fc99e Initial load
duke
parents:
diff changeset
102
a61af66fc99e Initial load
duke
parents:
diff changeset
103 // Remember the next node
a61af66fc99e Initial load
duke
parents:
diff changeset
104 Node *_next_node;
a61af66fc99e Initial load
duke
parents:
diff changeset
105
a61af66fc99e Initial load
duke
parents:
diff changeset
106 // Use this for an unconditional branch delay slot
a61af66fc99e Initial load
duke
parents:
diff changeset
107 Node *_unconditional_delay_slot;
a61af66fc99e Initial load
duke
parents:
diff changeset
108
a61af66fc99e Initial load
duke
parents:
diff changeset
109 // Pointer to a Nop
a61af66fc99e Initial load
duke
parents:
diff changeset
110 MachNopNode *_nop;
a61af66fc99e Initial load
duke
parents:
diff changeset
111
a61af66fc99e Initial load
duke
parents:
diff changeset
112 // Length of the current bundle, in instructions
a61af66fc99e Initial load
duke
parents:
diff changeset
113 uint _bundle_instr_count;
a61af66fc99e Initial load
duke
parents:
diff changeset
114
a61af66fc99e Initial load
duke
parents:
diff changeset
115 // Current Cycle number, for computing latencies and bundling
a61af66fc99e Initial load
duke
parents:
diff changeset
116 uint _bundle_cycle_number;
a61af66fc99e Initial load
duke
parents:
diff changeset
117
a61af66fc99e Initial load
duke
parents:
diff changeset
118 // Bundle information
a61af66fc99e Initial load
duke
parents:
diff changeset
119 Pipeline_Use_Element _bundle_use_elements[resource_count];
a61af66fc99e Initial load
duke
parents:
diff changeset
120 Pipeline_Use _bundle_use;
a61af66fc99e Initial load
duke
parents:
diff changeset
121
a61af66fc99e Initial load
duke
parents:
diff changeset
122 // Dump the available list
a61af66fc99e Initial load
duke
parents:
diff changeset
123 void dump_available() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
124
a61af66fc99e Initial load
duke
parents:
diff changeset
125 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
126 Scheduling(Arena *arena, Compile &compile);
a61af66fc99e Initial load
duke
parents:
diff changeset
127
a61af66fc99e Initial load
duke
parents:
diff changeset
128 // Destructor
a61af66fc99e Initial load
duke
parents:
diff changeset
129 NOT_PRODUCT( ~Scheduling(); )
a61af66fc99e Initial load
duke
parents:
diff changeset
130
a61af66fc99e Initial load
duke
parents:
diff changeset
131 // Step ahead "i" cycles
a61af66fc99e Initial load
duke
parents:
diff changeset
132 void step(uint i);
a61af66fc99e Initial load
duke
parents:
diff changeset
133
a61af66fc99e Initial load
duke
parents:
diff changeset
134 // Step ahead 1 cycle, and clear the bundle state (for example,
a61af66fc99e Initial load
duke
parents:
diff changeset
135 // at a branch target)
a61af66fc99e Initial load
duke
parents:
diff changeset
136 void step_and_clear();
a61af66fc99e Initial load
duke
parents:
diff changeset
137
a61af66fc99e Initial load
duke
parents:
diff changeset
138 Bundle* node_bundling(const Node *n) {
a61af66fc99e Initial load
duke
parents:
diff changeset
139 assert(valid_bundle_info(n), "oob");
a61af66fc99e Initial load
duke
parents:
diff changeset
140 return (&_node_bundling_base[n->_idx]);
a61af66fc99e Initial load
duke
parents:
diff changeset
141 }
a61af66fc99e Initial load
duke
parents:
diff changeset
142
a61af66fc99e Initial load
duke
parents:
diff changeset
143 bool valid_bundle_info(const Node *n) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
144 return (_node_bundling_limit > n->_idx);
a61af66fc99e Initial load
duke
parents:
diff changeset
145 }
a61af66fc99e Initial load
duke
parents:
diff changeset
146
a61af66fc99e Initial load
duke
parents:
diff changeset
147 bool starts_bundle(const Node *n) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
148 return (_node_bundling_limit > n->_idx && _node_bundling_base[n->_idx].starts_bundle());
a61af66fc99e Initial load
duke
parents:
diff changeset
149 }
a61af66fc99e Initial load
duke
parents:
diff changeset
150
a61af66fc99e Initial load
duke
parents:
diff changeset
151 // Do the scheduling
a61af66fc99e Initial load
duke
parents:
diff changeset
152 void DoScheduling();
a61af66fc99e Initial load
duke
parents:
diff changeset
153
a61af66fc99e Initial load
duke
parents:
diff changeset
154 // Compute the local latencies walking forward over the list of
a61af66fc99e Initial load
duke
parents:
diff changeset
155 // nodes for a basic block
a61af66fc99e Initial load
duke
parents:
diff changeset
156 void ComputeLocalLatenciesForward(const Block *bb);
a61af66fc99e Initial load
duke
parents:
diff changeset
157
a61af66fc99e Initial load
duke
parents:
diff changeset
158 // Compute the register antidependencies within a basic block
a61af66fc99e Initial load
duke
parents:
diff changeset
159 void ComputeRegisterAntidependencies(Block *bb);
a61af66fc99e Initial load
duke
parents:
diff changeset
160 void verify_do_def( Node *n, OptoReg::Name def, const char *msg );
a61af66fc99e Initial load
duke
parents:
diff changeset
161 void verify_good_schedule( Block *b, const char *msg );
a61af66fc99e Initial load
duke
parents:
diff changeset
162 void anti_do_def( Block *b, Node *def, OptoReg::Name def_reg, int is_def );
a61af66fc99e Initial load
duke
parents:
diff changeset
163 void anti_do_use( Block *b, Node *use, OptoReg::Name use_reg );
a61af66fc99e Initial load
duke
parents:
diff changeset
164
a61af66fc99e Initial load
duke
parents:
diff changeset
165 // Add a node to the current bundle
a61af66fc99e Initial load
duke
parents:
diff changeset
166 void AddNodeToBundle(Node *n, const Block *bb);
a61af66fc99e Initial load
duke
parents:
diff changeset
167
a61af66fc99e Initial load
duke
parents:
diff changeset
168 // Add a node to the list of available nodes
a61af66fc99e Initial load
duke
parents:
diff changeset
169 void AddNodeToAvailableList(Node *n);
a61af66fc99e Initial load
duke
parents:
diff changeset
170
a61af66fc99e Initial load
duke
parents:
diff changeset
171 // Compute the local use count for the nodes in a block, and compute
a61af66fc99e Initial load
duke
parents:
diff changeset
172 // the list of instructions with no uses in the block as available
a61af66fc99e Initial load
duke
parents:
diff changeset
173 void ComputeUseCount(const Block *bb);
a61af66fc99e Initial load
duke
parents:
diff changeset
174
a61af66fc99e Initial load
duke
parents:
diff changeset
175 // Choose an instruction from the available list to add to the bundle
a61af66fc99e Initial load
duke
parents:
diff changeset
176 Node * ChooseNodeToBundle();
a61af66fc99e Initial load
duke
parents:
diff changeset
177
a61af66fc99e Initial load
duke
parents:
diff changeset
178 // See if this Node fits into the currently accumulating bundle
a61af66fc99e Initial load
duke
parents:
diff changeset
179 bool NodeFitsInBundle(Node *n);
a61af66fc99e Initial load
duke
parents:
diff changeset
180
a61af66fc99e Initial load
duke
parents:
diff changeset
181 // Decrement the use count for a node
a61af66fc99e Initial load
duke
parents:
diff changeset
182 void DecrementUseCounts(Node *n, const Block *bb);
a61af66fc99e Initial load
duke
parents:
diff changeset
183
a61af66fc99e Initial load
duke
parents:
diff changeset
184 // Garbage collect pinch nodes for reuse by other blocks.
a61af66fc99e Initial load
duke
parents:
diff changeset
185 void garbage_collect_pinch_nodes();
a61af66fc99e Initial load
duke
parents:
diff changeset
186 // Clean up a pinch node for reuse (helper for above).
a61af66fc99e Initial load
duke
parents:
diff changeset
187 void cleanup_pinch( Node *pinch );
a61af66fc99e Initial load
duke
parents:
diff changeset
188
a61af66fc99e Initial load
duke
parents:
diff changeset
189 // Information for statistics gathering
a61af66fc99e Initial load
duke
parents:
diff changeset
190 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
191 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
192 // Gather information on size of nops relative to total
a61af66fc99e Initial load
duke
parents:
diff changeset
193 uint _branches, _unconditional_delays;
a61af66fc99e Initial load
duke
parents:
diff changeset
194
a61af66fc99e Initial load
duke
parents:
diff changeset
195 static uint _total_nop_size, _total_method_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
196 static uint _total_branches, _total_unconditional_delays;
a61af66fc99e Initial load
duke
parents:
diff changeset
197 static uint _total_instructions_per_bundle[Pipeline::_max_instrs_per_cycle+1];
a61af66fc99e Initial load
duke
parents:
diff changeset
198
a61af66fc99e Initial load
duke
parents:
diff changeset
199 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
200 static void print_statistics();
a61af66fc99e Initial load
duke
parents:
diff changeset
201
a61af66fc99e Initial load
duke
parents:
diff changeset
202 static void increment_instructions_per_bundle(uint i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
203 _total_instructions_per_bundle[i]++;
a61af66fc99e Initial load
duke
parents:
diff changeset
204 }
a61af66fc99e Initial load
duke
parents:
diff changeset
205
a61af66fc99e Initial load
duke
parents:
diff changeset
206 static void increment_nop_size(uint s) {
a61af66fc99e Initial load
duke
parents:
diff changeset
207 _total_nop_size += s;
a61af66fc99e Initial load
duke
parents:
diff changeset
208 }
a61af66fc99e Initial load
duke
parents:
diff changeset
209
a61af66fc99e Initial load
duke
parents:
diff changeset
210 static void increment_method_size(uint s) {
a61af66fc99e Initial load
duke
parents:
diff changeset
211 _total_method_size += s;
a61af66fc99e Initial load
duke
parents:
diff changeset
212 }
a61af66fc99e Initial load
duke
parents:
diff changeset
213 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
214
a61af66fc99e Initial load
duke
parents:
diff changeset
215 };