src/hotspot/share/opto/output.hpp
author eosterlund
Wed, 09 Oct 2019 12:30:06 +0000
changeset 58516 d376d86b0a01
parent 53244 9807daeb47c4
permissions -rw-r--r--
8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level Reviewed-by: pliden, stefank, neliasso Contributed-by: erik.osterlund@oracle.com, per.liden@oracle.com, stefan.karlsson@oracle.com, nils.eliasson@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 47216
diff changeset
     2
 * Copyright (c) 2000, 2019, 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
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 47216
diff changeset
    25
#ifndef SHARE_OPTO_OUTPUT_HPP
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 47216
diff changeset
    26
#define SHARE_OPTO_OUTPUT_HPP
7397
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
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
#define DEBUG_ARG(x) , x
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
#define DEBUG_ARG(x)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
// Define the initial sizes for allocation of the resizable code buffer
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
enum {
58516
d376d86b0a01 8230565: ZGC: Redesign C2 load barrier to expand on the MachNode level
eosterlund
parents: 53244
diff changeset
    51
  initial_const_capacity =   4 * 1024
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
//------------------------------Scheduling----------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
// This class contains all the information necessary to implement instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
// scheduling and bundling.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
class Scheduling {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  // Arena to use
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  Arena *_arena;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  // Control-Flow Graph info
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  PhaseCFG *_cfg;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  // Register Allocation info
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  PhaseRegAlloc *_regalloc;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  // Number of nodes in the method
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  uint _node_bundling_limit;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  // List of scheduled nodes. Generated in reverse order
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  Node_List _scheduled;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  // List of nodes currently available for choosing for scheduling
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  Node_List _available;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  // For each instruction beginning a bundle, the number of following
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  // nodes to be bundled with it.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  Bundle *_node_bundling_base;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  // Mapping from register to Node
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  Node_List _reg_node;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  // Free list for pinch nodes.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  Node_List _pinch_free_list;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  // Latency from the beginning of the containing basic block (base 1)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  // for each node.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  unsigned short *_node_latency;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  // Number of uses of this node within the containing basic block.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  short *_uses;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  // Schedulable portion of current block.  Skips Region/Phi/CreateEx up
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  // front, branch+proj at end.  Also skips Catch/CProj (same as
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  // branch-at-end), plus just-prior exception-throwing call.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  uint _bb_start, _bb_end;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  // Latency from the end of the basic block as scheduled
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  unsigned short *_current_latency;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  // Remember the next node
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  Node *_next_node;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  // Use this for an unconditional branch delay slot
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  Node *_unconditional_delay_slot;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  // Pointer to a Nop
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  MachNopNode *_nop;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  // Length of the current bundle, in instructions
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  uint _bundle_instr_count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  // Current Cycle number, for computing latencies and bundling
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  uint _bundle_cycle_number;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  // Bundle information
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  Pipeline_Use_Element _bundle_use_elements[resource_count];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  Pipeline_Use         _bundle_use;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  // Dump the available list
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  void dump_available() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  Scheduling(Arena *arena, Compile &compile);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  // Destructor
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  NOT_PRODUCT( ~Scheduling(); )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  // Step ahead "i" cycles
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  void step(uint i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
  // Step ahead 1 cycle, and clear the bundle state (for example,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  // at a branch target)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  void step_and_clear();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  Bundle* node_bundling(const Node *n) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
    assert(valid_bundle_info(n), "oob");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
    return (&_node_bundling_base[n->_idx]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
  bool valid_bundle_info(const Node *n) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
    return (_node_bundling_limit > 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 starts_bundle(const Node *n) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
    return (_node_bundling_limit > n->_idx && _node_bundling_base[n->_idx].starts_bundle());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  // Do the scheduling
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
  void DoScheduling();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
  // Compute the local latencies walking forward over the list of
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  // nodes for a basic block
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
  void ComputeLocalLatenciesForward(const Block *bb);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
  // Compute the register antidependencies within a basic block
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
  void ComputeRegisterAntidependencies(Block *bb);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
  void verify_do_def( Node *n, OptoReg::Name def, const char *msg );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  void verify_good_schedule( Block *b, const char *msg );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
  void anti_do_def( Block *b, Node *def, OptoReg::Name def_reg, int is_def );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
  void anti_do_use( Block *b, Node *use, OptoReg::Name use_reg );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
  // Add a node to the current bundle
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
  void AddNodeToBundle(Node *n, const Block *bb);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
  // Add a node to the list of available nodes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
  void AddNodeToAvailableList(Node *n);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
  // Compute the local use count for the nodes in a block, and compute
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  // the list of instructions with no uses in the block as available
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
  void ComputeUseCount(const Block *bb);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
  // Choose an instruction from the available list to add to the bundle
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
  Node * ChooseNodeToBundle();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
  // See if this Node fits into the currently accumulating bundle
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
  bool NodeFitsInBundle(Node *n);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
  // Decrement the use count for a node
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
 void DecrementUseCounts(Node *n, const Block *bb);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
  // Garbage collect pinch nodes for reuse by other blocks.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
  void garbage_collect_pinch_nodes();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
  // Clean up a pinch node for reuse (helper for above).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
  void cleanup_pinch( Node *pinch );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
  // Information for statistics gathering
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
  // Gather information on size of nops relative to total
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
  uint _branches, _unconditional_delays;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
  static uint _total_nop_size, _total_method_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
  static uint _total_branches, _total_unconditional_delays;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
  static uint _total_instructions_per_bundle[Pipeline::_max_instrs_per_cycle+1];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
  static void print_statistics();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
  static void increment_instructions_per_bundle(uint i) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
    _total_instructions_per_bundle[i]++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
  static void increment_nop_size(uint s) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
    _total_nop_size += s;
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_method_size(uint s) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
    _total_method_size += s;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
};
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   216
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 47216
diff changeset
   217
#endif // SHARE_OPTO_OUTPUT_HPP