src/share/vm/opto/output.hpp

Wed, 27 Apr 2016 01:25:04 +0800

author
aoqi
date
Wed, 27 Apr 2016 01:25:04 +0800
changeset 0
f90c822e73f8
child 1
2d8a650513c2
permissions
-rw-r--r--

Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/hotspot/
changeset: 6782:28b50d07f6f8
tag: jdk8u25-b17

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

mercurial