hotspot/src/share/vm/opto/replacednodes.hpp
author kvn
Fri, 21 Nov 2014 17:17:41 -0800
changeset 27704 88c9f3b507ff
parent 24946 24b68ccf3fc4
child 43963 6845bb645be5
permissions -rw-r--r--
8065618: C2 RA incorrectly removes kill projections Summary: Don't remove KILL projections if their "defining" nodes have SCMemProj projection (memory side effects). Reviewed-by: iveresov
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
24946
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
     1
/*
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
     2
 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
     4
 *
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
     7
 * published by the Free Software Foundation.
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
     8
 *
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    13
 * accompanied this code).
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    14
 *
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    18
 *
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    21
 * questions.
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    22
 *
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    23
 */
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    24
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    25
#ifndef SHARE_VM_OPTO_REPLACEDNODES_HPP
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    26
#define SHARE_VM_OPTO_REPLACEDNODES_HPP
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    27
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    28
#include "opto/connode.hpp"
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    29
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    30
// During parsing, when a node is "improved",
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    31
// GraphKit::replace_in_map() is called to update the current map so
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    32
// that the improved node is used from that point
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    33
// on. GraphKit::replace_in_map() doesn't operate on the callers maps
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    34
// and so some optimization opportunities may be lost. The
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    35
// ReplacedNodes class addresses that problem.
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    36
//
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    37
// A ReplacedNodes object is a list of pair of nodes. Every
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    38
// SafePointNode carries a ReplacedNodes object. Every time
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    39
// GraphKit::replace_in_map() is called, a new pair of nodes is pushed
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    40
// on the list of replaced nodes. When control flow paths merge, their
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    41
// replaced nodes are also merged. When parsing exits a method to
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    42
// return to a caller, the replaced nodes on the exit path are used to
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    43
// update the caller's map.
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    44
class ReplacedNodes VALUE_OBJ_CLASS_SPEC {
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    45
 private:
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    46
  class ReplacedNode VALUE_OBJ_CLASS_SPEC {
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    47
  private:
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    48
    Node* _initial;
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    49
    Node* _improved;
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    50
  public:
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    51
    ReplacedNode() : _initial(NULL), _improved(NULL) {}
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    52
    ReplacedNode(Node* initial, Node* improved) : _initial(initial), _improved(improved) {}
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    53
    Node* initial() const  { return _initial; }
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    54
    Node* improved() const { return _improved; }
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    55
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    56
    bool operator==(const ReplacedNode& other) {
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    57
      return _initial == other._initial && _improved == other._improved;
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    58
    }
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    59
  };
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    60
  GrowableArray<ReplacedNode>* _replaced_nodes;
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    61
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    62
  void allocate_if_necessary();
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    63
  bool has_node(const ReplacedNode& r) const;
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    64
  bool has_target_node(Node* n) const;
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    65
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    66
 public:
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    67
  ReplacedNodes()
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    68
    : _replaced_nodes(NULL) {}
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    69
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    70
  void clone();
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    71
  void record(Node* initial, Node* improved);
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    72
  void transfer_from(const ReplacedNodes& other, uint idx);
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    73
  void reset();
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    74
  void apply(Node* n);
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    75
  void merge_with(const ReplacedNodes& other);
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    76
  bool is_empty() const;
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    77
  void dump(outputStream *st) const;
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    78
  void apply(Compile* C, Node* ctl);
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    79
};
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    80
24b68ccf3fc4 8026796: Make replace_in_map() on parent maps generic
roland
parents:
diff changeset
    81
#endif // SHARE_VM_OPTO_REPLACEDNODES_HPP