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