src/share/vm/opto/output.hpp

changeset 0
f90c822e73f8
child 1
2d8a650513c2
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/vm/opto/output.hpp	Wed Apr 27 01:25:04 2016 +0800
     1.3 @@ -0,0 +1,241 @@
     1.4 +/*
     1.5 + * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.
    1.11 + *
    1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 + * version 2 for more details (a copy is included in the LICENSE file that
    1.16 + * accompanied this code).
    1.17 + *
    1.18 + * You should have received a copy of the GNU General Public License version
    1.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 + *
    1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.23 + * or visit www.oracle.com if you need additional information or have any
    1.24 + * questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +#ifndef SHARE_VM_OPTO_OUTPUT_HPP
    1.29 +#define SHARE_VM_OPTO_OUTPUT_HPP
    1.30 +
    1.31 +#include "opto/block.hpp"
    1.32 +#include "opto/node.hpp"
    1.33 +#ifdef TARGET_ARCH_MODEL_x86_32
    1.34 +# include "adfiles/ad_x86_32.hpp"
    1.35 +#endif
    1.36 +#ifdef TARGET_ARCH_MODEL_x86_64
    1.37 +# include "adfiles/ad_x86_64.hpp"
    1.38 +#endif
    1.39 +#ifdef TARGET_ARCH_MODEL_sparc
    1.40 +# include "adfiles/ad_sparc.hpp"
    1.41 +#endif
    1.42 +#ifdef TARGET_ARCH_MODEL_zero
    1.43 +# include "adfiles/ad_zero.hpp"
    1.44 +#endif
    1.45 +#ifdef TARGET_ARCH_MODEL_arm
    1.46 +# include "adfiles/ad_arm.hpp"
    1.47 +#endif
    1.48 +#ifdef TARGET_ARCH_MODEL_ppc_32
    1.49 +# include "adfiles/ad_ppc_32.hpp"
    1.50 +#endif
    1.51 +#ifdef TARGET_ARCH_MODEL_ppc_64
    1.52 +# include "adfiles/ad_ppc_64.hpp"
    1.53 +#endif
    1.54 +
    1.55 +class Arena;
    1.56 +class Bundle;
    1.57 +class Block;
    1.58 +class Block_Array;
    1.59 +class Node;
    1.60 +class Node_Array;
    1.61 +class Node_List;
    1.62 +class PhaseCFG;
    1.63 +class PhaseChaitin;
    1.64 +class Pipeline_Use_Element;
    1.65 +class Pipeline_Use;
    1.66 +
    1.67 +#ifndef PRODUCT
    1.68 +#define DEBUG_ARG(x) , x
    1.69 +#else
    1.70 +#define DEBUG_ARG(x)
    1.71 +#endif
    1.72 +
    1.73 +// Define the initial sizes for allocation of the resizable code buffer
    1.74 +enum {
    1.75 +  initial_code_capacity  =  16 * 1024,
    1.76 +  initial_stub_capacity  =   4 * 1024,
    1.77 +  initial_const_capacity =   4 * 1024,
    1.78 +  initial_locs_capacity  =   3 * 1024
    1.79 +};
    1.80 +
    1.81 +//------------------------------Scheduling----------------------------------
    1.82 +// This class contains all the information necessary to implement instruction
    1.83 +// scheduling and bundling.
    1.84 +class Scheduling {
    1.85 +
    1.86 +private:
    1.87 +  // Arena to use
    1.88 +  Arena *_arena;
    1.89 +
    1.90 +  // Control-Flow Graph info
    1.91 +  PhaseCFG *_cfg;
    1.92 +
    1.93 +  // Register Allocation info
    1.94 +  PhaseRegAlloc *_regalloc;
    1.95 +
    1.96 +  // Number of nodes in the method
    1.97 +  uint _node_bundling_limit;
    1.98 +
    1.99 +  // List of scheduled nodes. Generated in reverse order
   1.100 +  Node_List _scheduled;
   1.101 +
   1.102 +  // List of nodes currently available for choosing for scheduling
   1.103 +  Node_List _available;
   1.104 +
   1.105 +  // For each instruction beginning a bundle, the number of following
   1.106 +  // nodes to be bundled with it.
   1.107 +  Bundle *_node_bundling_base;
   1.108 +
   1.109 +  // Mapping from register to Node
   1.110 +  Node_List _reg_node;
   1.111 +
   1.112 +  // Free list for pinch nodes.
   1.113 +  Node_List _pinch_free_list;
   1.114 +
   1.115 +  // Latency from the beginning of the containing basic block (base 1)
   1.116 +  // for each node.
   1.117 +  unsigned short *_node_latency;
   1.118 +
   1.119 +  // Number of uses of this node within the containing basic block.
   1.120 +  short *_uses;
   1.121 +
   1.122 +  // Schedulable portion of current block.  Skips Region/Phi/CreateEx up
   1.123 +  // front, branch+proj at end.  Also skips Catch/CProj (same as
   1.124 +  // branch-at-end), plus just-prior exception-throwing call.
   1.125 +  uint _bb_start, _bb_end;
   1.126 +
   1.127 +  // Latency from the end of the basic block as scheduled
   1.128 +  unsigned short *_current_latency;
   1.129 +
   1.130 +  // Remember the next node
   1.131 +  Node *_next_node;
   1.132 +
   1.133 +  // Use this for an unconditional branch delay slot
   1.134 +  Node *_unconditional_delay_slot;
   1.135 +
   1.136 +  // Pointer to a Nop
   1.137 +  MachNopNode *_nop;
   1.138 +
   1.139 +  // Length of the current bundle, in instructions
   1.140 +  uint _bundle_instr_count;
   1.141 +
   1.142 +  // Current Cycle number, for computing latencies and bundling
   1.143 +  uint _bundle_cycle_number;
   1.144 +
   1.145 +  // Bundle information
   1.146 +  Pipeline_Use_Element _bundle_use_elements[resource_count];
   1.147 +  Pipeline_Use         _bundle_use;
   1.148 +
   1.149 +  // Dump the available list
   1.150 +  void dump_available() const;
   1.151 +
   1.152 +public:
   1.153 +  Scheduling(Arena *arena, Compile &compile);
   1.154 +
   1.155 +  // Destructor
   1.156 +  NOT_PRODUCT( ~Scheduling(); )
   1.157 +
   1.158 +  // Step ahead "i" cycles
   1.159 +  void step(uint i);
   1.160 +
   1.161 +  // Step ahead 1 cycle, and clear the bundle state (for example,
   1.162 +  // at a branch target)
   1.163 +  void step_and_clear();
   1.164 +
   1.165 +  Bundle* node_bundling(const Node *n) {
   1.166 +    assert(valid_bundle_info(n), "oob");
   1.167 +    return (&_node_bundling_base[n->_idx]);
   1.168 +  }
   1.169 +
   1.170 +  bool valid_bundle_info(const Node *n) const {
   1.171 +    return (_node_bundling_limit > n->_idx);
   1.172 +  }
   1.173 +
   1.174 +  bool starts_bundle(const Node *n) const {
   1.175 +    return (_node_bundling_limit > n->_idx && _node_bundling_base[n->_idx].starts_bundle());
   1.176 +  }
   1.177 +
   1.178 +  // Do the scheduling
   1.179 +  void DoScheduling();
   1.180 +
   1.181 +  // Compute the local latencies walking forward over the list of
   1.182 +  // nodes for a basic block
   1.183 +  void ComputeLocalLatenciesForward(const Block *bb);
   1.184 +
   1.185 +  // Compute the register antidependencies within a basic block
   1.186 +  void ComputeRegisterAntidependencies(Block *bb);
   1.187 +  void verify_do_def( Node *n, OptoReg::Name def, const char *msg );
   1.188 +  void verify_good_schedule( Block *b, const char *msg );
   1.189 +  void anti_do_def( Block *b, Node *def, OptoReg::Name def_reg, int is_def );
   1.190 +  void anti_do_use( Block *b, Node *use, OptoReg::Name use_reg );
   1.191 +
   1.192 +  // Add a node to the current bundle
   1.193 +  void AddNodeToBundle(Node *n, const Block *bb);
   1.194 +
   1.195 +  // Add a node to the list of available nodes
   1.196 +  void AddNodeToAvailableList(Node *n);
   1.197 +
   1.198 +  // Compute the local use count for the nodes in a block, and compute
   1.199 +  // the list of instructions with no uses in the block as available
   1.200 +  void ComputeUseCount(const Block *bb);
   1.201 +
   1.202 +  // Choose an instruction from the available list to add to the bundle
   1.203 +  Node * ChooseNodeToBundle();
   1.204 +
   1.205 +  // See if this Node fits into the currently accumulating bundle
   1.206 +  bool NodeFitsInBundle(Node *n);
   1.207 +
   1.208 +  // Decrement the use count for a node
   1.209 + void DecrementUseCounts(Node *n, const Block *bb);
   1.210 +
   1.211 +  // Garbage collect pinch nodes for reuse by other blocks.
   1.212 +  void garbage_collect_pinch_nodes();
   1.213 +  // Clean up a pinch node for reuse (helper for above).
   1.214 +  void cleanup_pinch( Node *pinch );
   1.215 +
   1.216 +  // Information for statistics gathering
   1.217 +#ifndef PRODUCT
   1.218 +private:
   1.219 +  // Gather information on size of nops relative to total
   1.220 +  uint _branches, _unconditional_delays;
   1.221 +
   1.222 +  static uint _total_nop_size, _total_method_size;
   1.223 +  static uint _total_branches, _total_unconditional_delays;
   1.224 +  static uint _total_instructions_per_bundle[Pipeline::_max_instrs_per_cycle+1];
   1.225 +
   1.226 +public:
   1.227 +  static void print_statistics();
   1.228 +
   1.229 +  static void increment_instructions_per_bundle(uint i) {
   1.230 +    _total_instructions_per_bundle[i]++;
   1.231 +  }
   1.232 +
   1.233 +  static void increment_nop_size(uint s) {
   1.234 +    _total_nop_size += s;
   1.235 +  }
   1.236 +
   1.237 +  static void increment_method_size(uint s) {
   1.238 +    _total_method_size += s;
   1.239 +  }
   1.240 +#endif
   1.241 +
   1.242 +};
   1.243 +
   1.244 +#endif // SHARE_VM_OPTO_OUTPUT_HPP

mercurial