annotate src/share/vm/opto/output.hpp @ 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 /*
22851
ddce0b7cee93 8072383: resolve conflicts between open and closed ports
dlong
parents: 14456
diff changeset
2 * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #ifndef SHARE_VM_OPTO_OUTPUT_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #define SHARE_VM_OPTO_OUTPUT_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "opto/block.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29 #include "opto/node.hpp"
22851
ddce0b7cee93 8072383: resolve conflicts between open and closed ports
dlong
parents: 14456
diff changeset
30 #if defined AD_MD_HPP
ddce0b7cee93 8072383: resolve conflicts between open and closed ports
dlong
parents: 14456
diff changeset
31 # include AD_MD_HPP
ddce0b7cee93 8072383: resolve conflicts between open and closed ports
dlong
parents: 14456
diff changeset
32 #elif defined TARGET_ARCH_MODEL_x86_32
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
33 # include "adfiles/ad_x86_32.hpp"
22851
ddce0b7cee93 8072383: resolve conflicts between open and closed ports
dlong
parents: 14456
diff changeset
34 #elif defined TARGET_ARCH_MODEL_x86_64
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
35 # include "adfiles/ad_x86_64.hpp"
22851
ddce0b7cee93 8072383: resolve conflicts between open and closed ports
dlong
parents: 14456
diff changeset
36 #elif defined TARGET_ARCH_MODEL_sparc
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
37 # include "adfiles/ad_sparc.hpp"
22851
ddce0b7cee93 8072383: resolve conflicts between open and closed ports
dlong
parents: 14456
diff changeset
38 #elif defined TARGET_ARCH_MODEL_zero
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
39 # include "adfiles/ad_zero.hpp"
22851
ddce0b7cee93 8072383: resolve conflicts between open and closed ports
dlong
parents: 14456
diff changeset
40 #elif defined TARGET_ARCH_MODEL_ppc_64
14391
d2907f74462e 8016586: PPC64 (part 3): basic changes for PPC64
goetz
parents: 2426
diff changeset
41 # include "adfiles/ad_ppc_64.hpp"
2192
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 1972
diff changeset
42 #endif
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
43
0
a61af66fc99e Initial load
duke
parents:
diff changeset
44 class Arena;
a61af66fc99e Initial load
duke
parents:
diff changeset
45 class Bundle;
a61af66fc99e Initial load
duke
parents:
diff changeset
46 class Block;
a61af66fc99e Initial load
duke
parents:
diff changeset
47 class Block_Array;
a61af66fc99e Initial load
duke
parents:
diff changeset
48 class Node;
a61af66fc99e Initial load
duke
parents:
diff changeset
49 class Node_Array;
a61af66fc99e Initial load
duke
parents:
diff changeset
50 class Node_List;
a61af66fc99e Initial load
duke
parents:
diff changeset
51 class PhaseCFG;
a61af66fc99e Initial load
duke
parents:
diff changeset
52 class PhaseChaitin;
a61af66fc99e Initial load
duke
parents:
diff changeset
53 class Pipeline_Use_Element;
a61af66fc99e Initial load
duke
parents:
diff changeset
54 class Pipeline_Use;
a61af66fc99e Initial load
duke
parents:
diff changeset
55
a61af66fc99e Initial load
duke
parents:
diff changeset
56 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
57 #define DEBUG_ARG(x) , x
a61af66fc99e Initial load
duke
parents:
diff changeset
58 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
59 #define DEBUG_ARG(x)
a61af66fc99e Initial load
duke
parents:
diff changeset
60 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
61
a61af66fc99e Initial load
duke
parents:
diff changeset
62 // Define the initial sizes for allocation of the resizable code buffer
a61af66fc99e Initial load
duke
parents:
diff changeset
63 enum {
a61af66fc99e Initial load
duke
parents:
diff changeset
64 initial_code_capacity = 16 * 1024,
a61af66fc99e Initial load
duke
parents:
diff changeset
65 initial_stub_capacity = 4 * 1024,
a61af66fc99e Initial load
duke
parents:
diff changeset
66 initial_const_capacity = 4 * 1024,
a61af66fc99e Initial load
duke
parents:
diff changeset
67 initial_locs_capacity = 3 * 1024
a61af66fc99e Initial load
duke
parents:
diff changeset
68 };
a61af66fc99e Initial load
duke
parents:
diff changeset
69
a61af66fc99e Initial load
duke
parents:
diff changeset
70 //------------------------------Scheduling----------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
71 // This class contains all the information necessary to implement instruction
a61af66fc99e Initial load
duke
parents:
diff changeset
72 // scheduling and bundling.
a61af66fc99e Initial load
duke
parents:
diff changeset
73 class Scheduling {
a61af66fc99e Initial load
duke
parents:
diff changeset
74
a61af66fc99e Initial load
duke
parents:
diff changeset
75 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
76 // Arena to use
a61af66fc99e Initial load
duke
parents:
diff changeset
77 Arena *_arena;
a61af66fc99e Initial load
duke
parents:
diff changeset
78
a61af66fc99e Initial load
duke
parents:
diff changeset
79 // Control-Flow Graph info
a61af66fc99e Initial load
duke
parents:
diff changeset
80 PhaseCFG *_cfg;
a61af66fc99e Initial load
duke
parents:
diff changeset
81
a61af66fc99e Initial load
duke
parents:
diff changeset
82 // Register Allocation info
a61af66fc99e Initial load
duke
parents:
diff changeset
83 PhaseRegAlloc *_regalloc;
a61af66fc99e Initial load
duke
parents:
diff changeset
84
a61af66fc99e Initial load
duke
parents:
diff changeset
85 // Number of nodes in the method
a61af66fc99e Initial load
duke
parents:
diff changeset
86 uint _node_bundling_limit;
a61af66fc99e Initial load
duke
parents:
diff changeset
87
a61af66fc99e Initial load
duke
parents:
diff changeset
88 // List of scheduled nodes. Generated in reverse order
a61af66fc99e Initial load
duke
parents:
diff changeset
89 Node_List _scheduled;
a61af66fc99e Initial load
duke
parents:
diff changeset
90
a61af66fc99e Initial load
duke
parents:
diff changeset
91 // List of nodes currently available for choosing for scheduling
a61af66fc99e Initial load
duke
parents:
diff changeset
92 Node_List _available;
a61af66fc99e Initial load
duke
parents:
diff changeset
93
a61af66fc99e Initial load
duke
parents:
diff changeset
94 // For each instruction beginning a bundle, the number of following
a61af66fc99e Initial load
duke
parents:
diff changeset
95 // nodes to be bundled with it.
a61af66fc99e Initial load
duke
parents:
diff changeset
96 Bundle *_node_bundling_base;
a61af66fc99e Initial load
duke
parents:
diff changeset
97
a61af66fc99e Initial load
duke
parents:
diff changeset
98 // Mapping from register to Node
a61af66fc99e Initial load
duke
parents:
diff changeset
99 Node_List _reg_node;
a61af66fc99e Initial load
duke
parents:
diff changeset
100
a61af66fc99e Initial load
duke
parents:
diff changeset
101 // Free list for pinch nodes.
a61af66fc99e Initial load
duke
parents:
diff changeset
102 Node_List _pinch_free_list;
a61af66fc99e Initial load
duke
parents:
diff changeset
103
a61af66fc99e Initial load
duke
parents:
diff changeset
104 // Latency from the beginning of the containing basic block (base 1)
a61af66fc99e Initial load
duke
parents:
diff changeset
105 // for each node.
a61af66fc99e Initial load
duke
parents:
diff changeset
106 unsigned short *_node_latency;
a61af66fc99e Initial load
duke
parents:
diff changeset
107
a61af66fc99e Initial load
duke
parents:
diff changeset
108 // Number of uses of this node within the containing basic block.
a61af66fc99e Initial load
duke
parents:
diff changeset
109 short *_uses;
a61af66fc99e Initial load
duke
parents:
diff changeset
110
a61af66fc99e Initial load
duke
parents:
diff changeset
111 // Schedulable portion of current block. Skips Region/Phi/CreateEx up
a61af66fc99e Initial load
duke
parents:
diff changeset
112 // front, branch+proj at end. Also skips Catch/CProj (same as
a61af66fc99e Initial load
duke
parents:
diff changeset
113 // branch-at-end), plus just-prior exception-throwing call.
a61af66fc99e Initial load
duke
parents:
diff changeset
114 uint _bb_start, _bb_end;
a61af66fc99e Initial load
duke
parents:
diff changeset
115
a61af66fc99e Initial load
duke
parents:
diff changeset
116 // Latency from the end of the basic block as scheduled
a61af66fc99e Initial load
duke
parents:
diff changeset
117 unsigned short *_current_latency;
a61af66fc99e Initial load
duke
parents:
diff changeset
118
a61af66fc99e Initial load
duke
parents:
diff changeset
119 // Remember the next node
a61af66fc99e Initial load
duke
parents:
diff changeset
120 Node *_next_node;
a61af66fc99e Initial load
duke
parents:
diff changeset
121
a61af66fc99e Initial load
duke
parents:
diff changeset
122 // Use this for an unconditional branch delay slot
a61af66fc99e Initial load
duke
parents:
diff changeset
123 Node *_unconditional_delay_slot;
a61af66fc99e Initial load
duke
parents:
diff changeset
124
a61af66fc99e Initial load
duke
parents:
diff changeset
125 // Pointer to a Nop
a61af66fc99e Initial load
duke
parents:
diff changeset
126 MachNopNode *_nop;
a61af66fc99e Initial load
duke
parents:
diff changeset
127
a61af66fc99e Initial load
duke
parents:
diff changeset
128 // Length of the current bundle, in instructions
a61af66fc99e Initial load
duke
parents:
diff changeset
129 uint _bundle_instr_count;
a61af66fc99e Initial load
duke
parents:
diff changeset
130
a61af66fc99e Initial load
duke
parents:
diff changeset
131 // Current Cycle number, for computing latencies and bundling
a61af66fc99e Initial load
duke
parents:
diff changeset
132 uint _bundle_cycle_number;
a61af66fc99e Initial load
duke
parents:
diff changeset
133
a61af66fc99e Initial load
duke
parents:
diff changeset
134 // Bundle information
a61af66fc99e Initial load
duke
parents:
diff changeset
135 Pipeline_Use_Element _bundle_use_elements[resource_count];
a61af66fc99e Initial load
duke
parents:
diff changeset
136 Pipeline_Use _bundle_use;
a61af66fc99e Initial load
duke
parents:
diff changeset
137
a61af66fc99e Initial load
duke
parents:
diff changeset
138 // Dump the available list
a61af66fc99e Initial load
duke
parents:
diff changeset
139 void dump_available() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
140
a61af66fc99e Initial load
duke
parents:
diff changeset
141 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
142 Scheduling(Arena *arena, Compile &compile);
a61af66fc99e Initial load
duke
parents:
diff changeset
143
a61af66fc99e Initial load
duke
parents:
diff changeset
144 // Destructor
a61af66fc99e Initial load
duke
parents:
diff changeset
145 NOT_PRODUCT( ~Scheduling(); )
a61af66fc99e Initial load
duke
parents:
diff changeset
146
a61af66fc99e Initial load
duke
parents:
diff changeset
147 // Step ahead "i" cycles
a61af66fc99e Initial load
duke
parents:
diff changeset
148 void step(uint i);
a61af66fc99e Initial load
duke
parents:
diff changeset
149
a61af66fc99e Initial load
duke
parents:
diff changeset
150 // Step ahead 1 cycle, and clear the bundle state (for example,
a61af66fc99e Initial load
duke
parents:
diff changeset
151 // at a branch target)
a61af66fc99e Initial load
duke
parents:
diff changeset
152 void step_and_clear();
a61af66fc99e Initial load
duke
parents:
diff changeset
153
a61af66fc99e Initial load
duke
parents:
diff changeset
154 Bundle* node_bundling(const Node *n) {
a61af66fc99e Initial load
duke
parents:
diff changeset
155 assert(valid_bundle_info(n), "oob");
a61af66fc99e Initial load
duke
parents:
diff changeset
156 return (&_node_bundling_base[n->_idx]);
a61af66fc99e Initial load
duke
parents:
diff changeset
157 }
a61af66fc99e Initial load
duke
parents:
diff changeset
158
a61af66fc99e Initial load
duke
parents:
diff changeset
159 bool valid_bundle_info(const Node *n) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
160 return (_node_bundling_limit > n->_idx);
a61af66fc99e Initial load
duke
parents:
diff changeset
161 }
a61af66fc99e Initial load
duke
parents:
diff changeset
162
a61af66fc99e Initial load
duke
parents:
diff changeset
163 bool starts_bundle(const Node *n) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
164 return (_node_bundling_limit > n->_idx && _node_bundling_base[n->_idx].starts_bundle());
a61af66fc99e Initial load
duke
parents:
diff changeset
165 }
a61af66fc99e Initial load
duke
parents:
diff changeset
166
a61af66fc99e Initial load
duke
parents:
diff changeset
167 // Do the scheduling
a61af66fc99e Initial load
duke
parents:
diff changeset
168 void DoScheduling();
a61af66fc99e Initial load
duke
parents:
diff changeset
169
a61af66fc99e Initial load
duke
parents:
diff changeset
170 // Compute the local latencies walking forward over the list of
a61af66fc99e Initial load
duke
parents:
diff changeset
171 // nodes for a basic block
a61af66fc99e Initial load
duke
parents:
diff changeset
172 void ComputeLocalLatenciesForward(const Block *bb);
a61af66fc99e Initial load
duke
parents:
diff changeset
173
a61af66fc99e Initial load
duke
parents:
diff changeset
174 // Compute the register antidependencies within a basic block
a61af66fc99e Initial load
duke
parents:
diff changeset
175 void ComputeRegisterAntidependencies(Block *bb);
a61af66fc99e Initial load
duke
parents:
diff changeset
176 void verify_do_def( Node *n, OptoReg::Name def, const char *msg );
a61af66fc99e Initial load
duke
parents:
diff changeset
177 void verify_good_schedule( Block *b, const char *msg );
a61af66fc99e Initial load
duke
parents:
diff changeset
178 void anti_do_def( Block *b, Node *def, OptoReg::Name def_reg, int is_def );
a61af66fc99e Initial load
duke
parents:
diff changeset
179 void anti_do_use( Block *b, Node *use, OptoReg::Name use_reg );
a61af66fc99e Initial load
duke
parents:
diff changeset
180
a61af66fc99e Initial load
duke
parents:
diff changeset
181 // Add a node to the current bundle
a61af66fc99e Initial load
duke
parents:
diff changeset
182 void AddNodeToBundle(Node *n, const Block *bb);
a61af66fc99e Initial load
duke
parents:
diff changeset
183
a61af66fc99e Initial load
duke
parents:
diff changeset
184 // Add a node to the list of available nodes
a61af66fc99e Initial load
duke
parents:
diff changeset
185 void AddNodeToAvailableList(Node *n);
a61af66fc99e Initial load
duke
parents:
diff changeset
186
a61af66fc99e Initial load
duke
parents:
diff changeset
187 // Compute the local use count for the nodes in a block, and compute
a61af66fc99e Initial load
duke
parents:
diff changeset
188 // the list of instructions with no uses in the block as available
a61af66fc99e Initial load
duke
parents:
diff changeset
189 void ComputeUseCount(const Block *bb);
a61af66fc99e Initial load
duke
parents:
diff changeset
190
a61af66fc99e Initial load
duke
parents:
diff changeset
191 // Choose an instruction from the available list to add to the bundle
a61af66fc99e Initial load
duke
parents:
diff changeset
192 Node * ChooseNodeToBundle();
a61af66fc99e Initial load
duke
parents:
diff changeset
193
a61af66fc99e Initial load
duke
parents:
diff changeset
194 // See if this Node fits into the currently accumulating bundle
a61af66fc99e Initial load
duke
parents:
diff changeset
195 bool NodeFitsInBundle(Node *n);
a61af66fc99e Initial load
duke
parents:
diff changeset
196
a61af66fc99e Initial load
duke
parents:
diff changeset
197 // Decrement the use count for a node
a61af66fc99e Initial load
duke
parents:
diff changeset
198 void DecrementUseCounts(Node *n, const Block *bb);
a61af66fc99e Initial load
duke
parents:
diff changeset
199
a61af66fc99e Initial load
duke
parents:
diff changeset
200 // Garbage collect pinch nodes for reuse by other blocks.
a61af66fc99e Initial load
duke
parents:
diff changeset
201 void garbage_collect_pinch_nodes();
a61af66fc99e Initial load
duke
parents:
diff changeset
202 // Clean up a pinch node for reuse (helper for above).
a61af66fc99e Initial load
duke
parents:
diff changeset
203 void cleanup_pinch( Node *pinch );
a61af66fc99e Initial load
duke
parents:
diff changeset
204
a61af66fc99e Initial load
duke
parents:
diff changeset
205 // Information for statistics gathering
a61af66fc99e Initial load
duke
parents:
diff changeset
206 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
207 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
208 // Gather information on size of nops relative to total
a61af66fc99e Initial load
duke
parents:
diff changeset
209 uint _branches, _unconditional_delays;
a61af66fc99e Initial load
duke
parents:
diff changeset
210
a61af66fc99e Initial load
duke
parents:
diff changeset
211 static uint _total_nop_size, _total_method_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
212 static uint _total_branches, _total_unconditional_delays;
a61af66fc99e Initial load
duke
parents:
diff changeset
213 static uint _total_instructions_per_bundle[Pipeline::_max_instrs_per_cycle+1];
a61af66fc99e Initial load
duke
parents:
diff changeset
214
a61af66fc99e Initial load
duke
parents:
diff changeset
215 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
216 static void print_statistics();
a61af66fc99e Initial load
duke
parents:
diff changeset
217
a61af66fc99e Initial load
duke
parents:
diff changeset
218 static void increment_instructions_per_bundle(uint i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
219 _total_instructions_per_bundle[i]++;
a61af66fc99e Initial load
duke
parents:
diff changeset
220 }
a61af66fc99e Initial load
duke
parents:
diff changeset
221
a61af66fc99e Initial load
duke
parents:
diff changeset
222 static void increment_nop_size(uint s) {
a61af66fc99e Initial load
duke
parents:
diff changeset
223 _total_nop_size += s;
a61af66fc99e Initial load
duke
parents:
diff changeset
224 }
a61af66fc99e Initial load
duke
parents:
diff changeset
225
a61af66fc99e Initial load
duke
parents:
diff changeset
226 static void increment_method_size(uint s) {
a61af66fc99e Initial load
duke
parents:
diff changeset
227 _total_method_size += s;
a61af66fc99e Initial load
duke
parents:
diff changeset
228 }
a61af66fc99e Initial load
duke
parents:
diff changeset
229 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
230
a61af66fc99e Initial load
duke
parents:
diff changeset
231 };
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
232
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
233 #endif // SHARE_VM_OPTO_OUTPUT_HPP