hotspot/agent/src/share/classes/sun/jvm/hotspot/opto/Node.java
author katleman
Thu, 20 Dec 2012 16:24:51 -0800
changeset 14847 92a59a418262
parent 10547 ea4a2ec31ae2
permissions -rw-r--r--
8004982: JDK8 source with GPL header errors Reviewed-by: ohair
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10547
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
     1
/*
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
     2
 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
     4
 *
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
     7
 * published by the Free Software Foundation.
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
     8
 *
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    13
 * accompanied this code).
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    14
 *
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    18
 *
14847
92a59a418262 8004982: JDK8 source with GPL header errors
katleman
parents: 10547
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
92a59a418262 8004982: JDK8 source with GPL header errors
katleman
parents: 10547
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
92a59a418262 8004982: JDK8 source with GPL header errors
katleman
parents: 10547
diff changeset
    21
 * questions.
10547
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    22
 *
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    23
 */
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    24
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    25
package sun.jvm.hotspot.opto;
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    26
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    27
import java.io.*;
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    28
import java.lang.reflect.Constructor;
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    29
import java.util.*;
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    30
import sun.jvm.hotspot.debugger.*;
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    31
import sun.jvm.hotspot.runtime.*;
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    32
import sun.jvm.hotspot.oops.*;
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    33
import sun.jvm.hotspot.types.*;
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    34
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    35
public class Node extends VMObject {
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    36
  static {
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    37
    VM.registerVMInitializedObserver(new Observer() {
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    38
        public void update(Observable o, Object data) {
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    39
          initialize(VM.getVM().getTypeDataBase());
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    40
        }
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    41
      });
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    42
  }
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    43
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    44
  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    45
    Type type      = db.lookupType("Node");
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    46
    outmaxField = new CIntField(type.getCIntegerField("_outmax"), 0);
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    47
    outcntField = new CIntField(type.getCIntegerField("_outcnt"), 0);
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    48
    maxField = new CIntField(type.getCIntegerField("_max"), 0);
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    49
    cntField = new CIntField(type.getCIntegerField("_cnt"), 0);
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    50
    idxField = new CIntField(type.getCIntegerField("_idx"), 0);
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    51
    outField = type.getAddressField("_out");
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    52
    inField = type.getAddressField("_in");
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    53
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    54
    nodeType = db.lookupType("Node");
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    55
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    56
    virtualConstructor = new VirtualBaseConstructor(db, nodeType, "sun.jvm.hotspot.opto", Node.class);
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    57
  }
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    58
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    59
  private static CIntField outmaxField;
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    60
  private static CIntField outcntField;
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    61
  private static CIntField maxField;
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    62
  private static CIntField cntField;
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    63
  private static CIntField idxField;
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    64
  private static AddressField outField;
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    65
  private static AddressField inField;
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    66
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    67
  private static VirtualBaseConstructor virtualConstructor;
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    68
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    69
  private static Type nodeType;
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    70
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    71
  static HashMap nodes = new HashMap();
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    72
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    73
  static HashMap constructors = new HashMap();
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    74
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    75
  static abstract class Instantiator {
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    76
    abstract Node create(Address addr);
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    77
  }
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    78
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    79
  static public Node create(Address addr) {
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    80
    if (addr == null) return null;
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    81
    Node result = (Node)nodes.get(addr);
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    82
    if (result == null) {
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    83
      result = (Node)virtualConstructor.instantiateWrapperFor(addr);
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    84
      nodes.put(addr, result);
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    85
    }
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    86
    return result;
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    87
  }
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    88
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    89
  public Node(Address addr) {
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    90
    super(addr);
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    91
  }
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    92
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    93
  public int outcnt() {
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    94
    return (int)outcntField.getValue(this.getAddress());
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    95
  }
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    96
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    97
  public int req() {
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    98
    return (int)cntField.getValue(this.getAddress());
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
    99
  }
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   100
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   101
  public int len() {
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   102
    return (int)maxField.getValue(this.getAddress());
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   103
  }
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   104
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   105
  public int idx() {
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   106
    return (int)idxField.getValue(this.getAddress());
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   107
  }
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   108
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   109
  private Node[] _out;
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   110
  private Node[] _in;
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   111
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   112
  public Node rawOut(int i) {
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   113
    if (_out == null) {
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   114
      int addressSize = (int)VM.getVM().getAddressSize();
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   115
      _out = new Node[outcnt()];
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   116
      Address ptr = outField.getValue(this.getAddress());
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   117
      for (int j = 0; j < outcnt(); j++) {
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   118
        _out[j] = Node.create(ptr.getAddressAt(j * addressSize));
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   119
      }
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   120
    }
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   121
    return _out[i];
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   122
  }
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   123
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   124
  public Node in(int i) {
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   125
    if (_in == null) {
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   126
      int addressSize = (int)VM.getVM().getAddressSize();
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   127
      _in = new Node[len()];
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   128
      Address ptr = inField.getValue(this.getAddress());
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   129
      for (int j = 0; j < len(); j++) {
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   130
        _in[j] = Node.create(ptr.getAddressAt(j * addressSize));
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   131
      }
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   132
    }
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   133
    return _in[i];
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   134
  }
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   135
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   136
  public ArrayList collect(int d, boolean onlyCtrl) {
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   137
    int depth = Math.abs(d);
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   138
    ArrayList nstack = new ArrayList();
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   139
    BitSet set = new BitSet();
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   140
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   141
    nstack.add(this);
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   142
    set.set(idx());
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   143
    int begin = 0;
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   144
    int end = 0;
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   145
    for (int i = 0; i < depth; i++) {
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   146
      end = nstack.size();
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   147
      for(int j = begin; j < end; j++) {
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   148
        Node tp  = (Node)nstack.get(j);
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   149
        int limit = d > 0 ? tp.len() : tp.outcnt();
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   150
        for(int k = 0; k < limit; k++) {
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   151
          Node n = d > 0 ? tp.in(k) : tp.rawOut(k);
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   152
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   153
          // if (NotANode(n))  continue;
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   154
          if (n == null) continue;
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   155
          // do not recurse through top or the root (would reach unrelated stuff)
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   156
          // if (n.isRoot() || n.isTop())  continue;
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   157
          // if (onlyCtrl && !n.isCfg()) continue;
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   158
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   159
          if (!set.get(n.idx())) {
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   160
            nstack.add(n);
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   161
            set.set(n.idx());
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   162
          }
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   163
        }
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   164
      }
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   165
      begin = end;
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   166
    }
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   167
    return nstack;
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   168
  }
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   169
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   170
  protected void dumpNodes(Node s, int d, boolean onlyCtrl, PrintStream out) {
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   171
    if (s == null) return;
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   172
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   173
    ArrayList nstack = s.collect(d, onlyCtrl);
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   174
    int end = nstack.size();
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   175
    if (d > 0) {
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   176
      for(int j = end-1; j >= 0; j--) {
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   177
        ((Node)nstack.get(j)).dump(out);
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   178
      }
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   179
    } else {
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   180
      for(int j = 0; j < end; j++) {
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   181
        ((Node)nstack.get(j)).dump(out);
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   182
      }
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   183
    }
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   184
  }
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   185
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   186
  public void dump(int depth, PrintStream out) {
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   187
    dumpNodes(this, depth, false, out);
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   188
  }
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   189
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   190
  public String Name() {
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   191
    Type t = VM.getVM().getTypeDataBase().findDynamicTypeForAddress(getAddress(), nodeType);
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   192
    String name = null;
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   193
    if (t != null) {
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   194
        name = t.toString();
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   195
    } else {
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   196
        Class c = getClass();
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   197
        if (c == Node.class) {
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   198
            // couldn't identify class type
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   199
            return "UnknownNode<" + getAddress().getAddressAt(0) + ">";
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   200
        }
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   201
        name = getClass().getName();
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   202
        if (name.startsWith("sun.jvm.hotspot.opto.")) {
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   203
            name = name.substring("sun.jvm.hotspot.opto.".length());
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   204
        }
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   205
    }
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   206
    if (name.endsWith("Node")) {
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   207
        return name.substring(0, name.length() - 4);
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   208
    }
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   209
    return name;
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   210
  }
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   211
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   212
  public void dump(PrintStream out) {
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   213
    out.print(" ");
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   214
    out.print(idx());
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   215
    out.print("\t");
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   216
    out.print(Name());
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   217
    out.print("\t=== ");
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   218
    int i = 0;
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   219
    for (i = 0; i < req(); i++) {
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   220
      Node n = in(i);
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   221
      if (n != null) {
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   222
        out.print(' ');
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   223
        out.print(in(i).idx());
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   224
      } else {
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   225
        out.print("_");
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   226
      }
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   227
      out.print(" ");
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   228
    }
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   229
    if (len() != req()) {
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   230
      int prec = 0;
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   231
      for (; i < len(); i++) {
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   232
        Node n = in(i);
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   233
        if (n != null) {
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   234
          if (prec++ == 0) {
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   235
            out.print("| ");
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   236
          }
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   237
          out.print(in(i).idx());
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   238
        }
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   239
        out.print(" ");
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   240
      }
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   241
    }
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   242
    dumpOut(out);
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   243
    dumpSpec(out);
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   244
    out.println();
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   245
  }
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   246
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   247
  void dumpOut(PrintStream out) {
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   248
    // Delimit the output edges
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   249
    out.print(" [[");
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   250
    // Dump the output edges
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   251
    for (int i = 0; i < outcnt(); i++) {    // For all outputs
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   252
      Node u = rawOut(i);
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   253
      if (u == null) {
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   254
        out.print("_ ");
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   255
      // } else if (NotANode(u)) {
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   256
      //   out.print("NotANode ");
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   257
      } else {
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   258
        // out.print("%c%d ", Compile::current()->nodeArena()->contains(u) ? ' ' : 'o', u->_idx);
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   259
        out.print(' ');
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   260
        out.print(u.idx());
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   261
        out.print(' ');
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   262
      }
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   263
    }
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   264
    out.print("]] ");
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   265
  }
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   266
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   267
  public void dumpSpec(PrintStream out) {
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   268
  }
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents:
diff changeset
   269
}