annotate graal/com.oracle.graal.graph/src/com/oracle/graal/graph/TypedGraphNodeIterator.java @ 18157:95f8dd398214

Call LIRGenerationResult.buildFrameMap() for targets that do not need register allocation.
author Josef Eisl <josef.eisl@jku.at>
date Wed, 22 Oct 2014 19:59:52 +0200
parents 3bf348ff55e5
children 61d3cb8e1280
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16972
3bf348ff55e5 copyright fix
Michael Haupt <michael.haupt@oracle.com>
parents: 16970
diff changeset
1 /*
3bf348ff55e5 copyright fix
Michael Haupt <michael.haupt@oracle.com>
parents: 16970
diff changeset
2 * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
3bf348ff55e5 copyright fix
Michael Haupt <michael.haupt@oracle.com>
parents: 16970
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3bf348ff55e5 copyright fix
Michael Haupt <michael.haupt@oracle.com>
parents: 16970
diff changeset
4 *
3bf348ff55e5 copyright fix
Michael Haupt <michael.haupt@oracle.com>
parents: 16970
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
3bf348ff55e5 copyright fix
Michael Haupt <michael.haupt@oracle.com>
parents: 16970
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
3bf348ff55e5 copyright fix
Michael Haupt <michael.haupt@oracle.com>
parents: 16970
diff changeset
7 * published by the Free Software Foundation.
3bf348ff55e5 copyright fix
Michael Haupt <michael.haupt@oracle.com>
parents: 16970
diff changeset
8 *
3bf348ff55e5 copyright fix
Michael Haupt <michael.haupt@oracle.com>
parents: 16970
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
3bf348ff55e5 copyright fix
Michael Haupt <michael.haupt@oracle.com>
parents: 16970
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3bf348ff55e5 copyright fix
Michael Haupt <michael.haupt@oracle.com>
parents: 16970
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3bf348ff55e5 copyright fix
Michael Haupt <michael.haupt@oracle.com>
parents: 16970
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
3bf348ff55e5 copyright fix
Michael Haupt <michael.haupt@oracle.com>
parents: 16970
diff changeset
13 * accompanied this code).
3bf348ff55e5 copyright fix
Michael Haupt <michael.haupt@oracle.com>
parents: 16970
diff changeset
14 *
3bf348ff55e5 copyright fix
Michael Haupt <michael.haupt@oracle.com>
parents: 16970
diff changeset
15 * You should have received a copy of the GNU General Public License version
3bf348ff55e5 copyright fix
Michael Haupt <michael.haupt@oracle.com>
parents: 16970
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
3bf348ff55e5 copyright fix
Michael Haupt <michael.haupt@oracle.com>
parents: 16970
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
3bf348ff55e5 copyright fix
Michael Haupt <michael.haupt@oracle.com>
parents: 16970
diff changeset
18 *
3bf348ff55e5 copyright fix
Michael Haupt <michael.haupt@oracle.com>
parents: 16970
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
3bf348ff55e5 copyright fix
Michael Haupt <michael.haupt@oracle.com>
parents: 16970
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
3bf348ff55e5 copyright fix
Michael Haupt <michael.haupt@oracle.com>
parents: 16970
diff changeset
21 * questions.
3bf348ff55e5 copyright fix
Michael Haupt <michael.haupt@oracle.com>
parents: 16970
diff changeset
22 */
16970
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
23 package com.oracle.graal.graph;
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
24
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
25 import java.util.*;
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
26
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
27 class TypedGraphNodeIterator<T extends IterableNodeType> implements Iterator<T> {
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
28
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
29 private final Graph graph;
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
30 private final int[] ids;
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
31 private final Node[] current;
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
32
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
33 private int currentIdIndex;
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
34 private boolean needsForward;
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
35
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
36 public TypedGraphNodeIterator(NodeClass clazz, Graph graph) {
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
37 this.graph = graph;
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
38 ids = clazz.iterableIds();
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
39 currentIdIndex = 0;
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
40 current = new Node[ids.length];
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
41 Arrays.fill(current, Graph.PLACE_HOLDER);
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
42 needsForward = true;
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
43 }
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
44
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
45 private Node findNext() {
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
46 if (needsForward) {
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
47 forward();
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
48 } else {
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
49 Node c = current();
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
50 Node afterDeleted = skipDeleted(c);
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
51 if (afterDeleted == null) {
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
52 needsForward = true;
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
53 } else if (c != afterDeleted) {
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
54 setCurrent(afterDeleted);
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
55 }
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
56 }
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
57 if (needsForward) {
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
58 return null;
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
59 }
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
60 return current();
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
61 }
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
62
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
63 private static Node skipDeleted(Node node) {
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
64 Node n = node;
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
65 while (n != null && n.isDeleted()) {
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
66 n = n.typeCacheNext;
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
67 }
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
68 return n;
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
69 }
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
70
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
71 private void forward() {
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
72 needsForward = false;
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
73 int startIdx = currentIdIndex;
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
74 while (true) {
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
75 Node next;
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
76 if (current() == Graph.PLACE_HOLDER) {
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
77 next = graph.getStartNode(ids[currentIdIndex]);
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
78 } else {
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
79 next = current().typeCacheNext;
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
80 }
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
81 next = skipDeleted(next);
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
82 if (next == null) {
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
83 currentIdIndex++;
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
84 if (currentIdIndex >= ids.length) {
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
85 currentIdIndex = 0;
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
86 }
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
87 if (currentIdIndex == startIdx) {
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
88 needsForward = true;
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
89 return;
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
90 }
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
91 } else {
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
92 setCurrent(next);
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
93 break;
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
94 }
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
95 }
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
96 }
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
97
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
98 private Node current() {
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
99 return current[currentIdIndex];
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
100 }
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
101
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
102 private void setCurrent(Node n) {
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
103 current[currentIdIndex] = n;
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
104 }
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
105
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
106 @Override
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
107 public boolean hasNext() {
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
108 return findNext() != null;
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
109 }
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
110
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
111 @Override
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
112 @SuppressWarnings("unchecked")
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
113 public T next() {
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
114 Node result = findNext();
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
115 if (result == null) {
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
116 throw new NoSuchElementException();
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
117 }
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
118 needsForward = true;
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
119 return (T) result;
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
120 }
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
121
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
122 @Override
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
123 public void remove() {
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
124 throw new UnsupportedOperationException();
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents:
diff changeset
125 }
16972
3bf348ff55e5 copyright fix
Michael Haupt <michael.haupt@oracle.com>
parents: 16970
diff changeset
126 }