Bug Summary

File:jdk/src/hotspot/share/opto/node.cpp
Warning:line 1813, column 14
Called C++ object pointer is null

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name node.cpp -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -mthread-model posix -fno-delete-null-pointer-checks -mframe-pointer=all -relaxed-aliasing -fmath-errno -fno-rounding-math -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -dwarf-column-info -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib/llvm-10/lib/clang/10.0.0 -I /home/daniel/Projects/java/jdk/build/linux-x86_64-server-fastdebug/hotspot/variant-server/libjvm/objs/precompiled -D __STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -D __STDC_CONSTANT_MACROS -D _GNU_SOURCE -D _REENTRANT -D LIBC=gnu -D LINUX -D VM_LITTLE_ENDIAN -D _LP64=1 -D ASSERT -D CHECK_UNHANDLED_OOPS -D TARGET_ARCH_x86 -D INCLUDE_SUFFIX_OS=_linux -D INCLUDE_SUFFIX_CPU=_x86 -D INCLUDE_SUFFIX_COMPILER=_gcc -D TARGET_COMPILER_gcc -D AMD64 -D HOTSPOT_LIB_ARCH="amd64" -D COMPILER1 -D COMPILER2 -I /home/daniel/Projects/java/jdk/build/linux-x86_64-server-fastdebug/hotspot/variant-server/gensrc/adfiles -I /home/daniel/Projects/java/jdk/src/hotspot/share -I /home/daniel/Projects/java/jdk/src/hotspot/os/linux -I /home/daniel/Projects/java/jdk/src/hotspot/os/posix -I /home/daniel/Projects/java/jdk/src/hotspot/cpu/x86 -I /home/daniel/Projects/java/jdk/src/hotspot/os_cpu/linux_x86 -I /home/daniel/Projects/java/jdk/build/linux-x86_64-server-fastdebug/hotspot/variant-server/gensrc -I /home/daniel/Projects/java/jdk/src/hotspot/share/precompiled -I /home/daniel/Projects/java/jdk/src/hotspot/share/include -I /home/daniel/Projects/java/jdk/src/hotspot/os/posix/include -I /home/daniel/Projects/java/jdk/build/linux-x86_64-server-fastdebug/support/modules_include/java.base -I /home/daniel/Projects/java/jdk/build/linux-x86_64-server-fastdebug/support/modules_include/java.base/linux -I /home/daniel/Projects/java/jdk/src/java.base/share/native/libjimage -I /home/daniel/Projects/java/jdk/build/linux-x86_64-server-fastdebug/hotspot/variant-server/gensrc/adfiles -I /home/daniel/Projects/java/jdk/src/hotspot/share -I /home/daniel/Projects/java/jdk/src/hotspot/os/linux -I /home/daniel/Projects/java/jdk/src/hotspot/os/posix -I /home/daniel/Projects/java/jdk/src/hotspot/cpu/x86 -I /home/daniel/Projects/java/jdk/src/hotspot/os_cpu/linux_x86 -I /home/daniel/Projects/java/jdk/build/linux-x86_64-server-fastdebug/hotspot/variant-server/gensrc -D _FORTIFY_SOURCE=2 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/x86_64-linux-gnu/c++/7.5.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/x86_64-linux-gnu/c++/7.5.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/backward -internal-isystem /usr/local/include -internal-isystem /usr/lib/llvm-10/lib/clang/10.0.0/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O3 -Wno-format-zero-length -Wno-unused-parameter -Wno-unused -Wno-parentheses -Wno-comment -Wno-unknown-pragmas -Wno-address -Wno-delete-non-virtual-dtor -Wno-char-subscripts -Wno-array-bounds -Wno-int-in-bool-context -Wno-ignored-qualifiers -Wno-missing-field-initializers -Wno-implicit-fallthrough -Wno-empty-body -Wno-strict-overflow -Wno-sequence-point -Wno-maybe-uninitialized -Wno-misleading-indentation -Wno-cast-function-type -Wno-shift-negative-value -std=c++14 -fdeprecated-macro -fdebug-compilation-dir /home/daniel/Projects/java/jdk/make/hotspot -ferror-limit 19 -fmessage-length 0 -fvisibility hidden -stack-protector 1 -fno-rtti -fgnuc-version=4.2.1 -fobjc-runtime=gcc -fdiagnostics-show-option -vectorize-loops -vectorize-slp -analyzer-output=html -faddrsig -o /home/daniel/Projects/java/scan/2021-12-21-193737-8510-1 -x c++ /home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp

/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp

1/*
2 * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25#include "precompiled.hpp"
26#include "gc/shared/barrierSet.hpp"
27#include "gc/shared/c2/barrierSetC2.hpp"
28#include "libadt/vectset.hpp"
29#include "memory/allocation.inline.hpp"
30#include "memory/resourceArea.hpp"
31#include "opto/ad.hpp"
32#include "opto/callGenerator.hpp"
33#include "opto/castnode.hpp"
34#include "opto/cfgnode.hpp"
35#include "opto/connode.hpp"
36#include "opto/loopnode.hpp"
37#include "opto/machnode.hpp"
38#include "opto/matcher.hpp"
39#include "opto/node.hpp"
40#include "opto/opcodes.hpp"
41#include "opto/regmask.hpp"
42#include "opto/rootnode.hpp"
43#include "opto/type.hpp"
44#include "utilities/copy.hpp"
45#include "utilities/macros.hpp"
46#include "utilities/powerOfTwo.hpp"
47
48class RegMask;
49// #include "phase.hpp"
50class PhaseTransform;
51class PhaseGVN;
52
53// Arena we are currently building Nodes in
54const uint Node::NotAMachineReg = 0xffff0000;
55
56#ifndef PRODUCT
57extern int nodes_created;
58#endif
59#ifdef __clang__1
60#pragma clang diagnostic push
61#pragma GCC diagnostic ignored "-Wuninitialized"
62#endif
63
64#ifdef ASSERT1
65
66//-------------------------- construct_node------------------------------------
67// Set a breakpoint here to identify where a particular node index is built.
68void Node::verify_construction() {
69 _debug_orig = NULL__null;
70 int old_debug_idx = Compile::debug_idx();
71 int new_debug_idx = old_debug_idx + 1;
72 if (new_debug_idx > 0) {
73 // Arrange that the lowest five decimal digits of _debug_idx
74 // will repeat those of _idx. In case this is somehow pathological,
75 // we continue to assign negative numbers (!) consecutively.
76 const int mod = 100000;
77 int bump = (int)(_idx - new_debug_idx) % mod;
78 if (bump < 0) {
79 bump += mod;
80 }
81 assert(bump >= 0 && bump < mod, "")do { if (!(bump >= 0 && bump < mod)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 81, "assert(" "bump >= 0 && bump < mod" ") failed"
, ""); ::breakpoint(); } } while (0)
;
82 new_debug_idx += bump;
83 }
84 Compile::set_debug_idx(new_debug_idx);
85 set_debug_idx(new_debug_idx);
86 Compile* C = Compile::current();
87 assert(C->unique() < (INT_MAX - 1), "Node limit exceeded INT_MAX")do { if (!(C->unique() < (2147483647 - 1))) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 87, "assert(" "C->unique() < (2147483647 - 1)" ") failed"
, "Node limit exceeded INT_MAX"); ::breakpoint(); } } while (
0)
;
88 if (!C->phase_optimize_finished()) {
89 // Only check assert during parsing and optimization phase. Skip it while generating code.
90 assert(C->live_nodes() <= C->max_node_limit(), "Live Node limit exceeded limit")do { if (!(C->live_nodes() <= C->max_node_limit())) {
(*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 90, "assert(" "C->live_nodes() <= C->max_node_limit()"
") failed", "Live Node limit exceeded limit"); ::breakpoint(
); } } while (0)
;
91 }
92 if (BreakAtNode != 0 && (_debug_idx == BreakAtNode || (int)_idx == BreakAtNode)) {
93 tty->print_cr("BreakAtNode: _idx=%d _debug_idx=%d", _idx, _debug_idx);
94 BREAKPOINT::breakpoint();
95 }
96#if OPTO_DU_ITERATOR_ASSERT1
97 _last_del = NULL__null;
98 _del_tick = 0;
99#endif
100 _hash_lock = 0;
101}
102
103
104// #ifdef ASSERT ...
105
106#if OPTO_DU_ITERATOR_ASSERT1
107void DUIterator_Common::sample(const Node* node) {
108 _vdui = VerifyDUIterators;
109 _node = node;
110 _outcnt = node->_outcnt;
111 _del_tick = node->_del_tick;
112 _last = NULL__null;
113}
114
115void DUIterator_Common::verify(const Node* node, bool at_end_ok) {
116 assert(_node == node, "consistent iterator source")do { if (!(_node == node)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 116, "assert(" "_node == node" ") failed", "consistent iterator source"
); ::breakpoint(); } } while (0)
;
117 assert(_del_tick == node->_del_tick, "no unexpected deletions allowed")do { if (!(_del_tick == node->_del_tick)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 117, "assert(" "_del_tick == node->_del_tick" ") failed"
, "no unexpected deletions allowed"); ::breakpoint(); } } while
(0)
;
118}
119
120void DUIterator_Common::verify_resync() {
121 // Ensure that the loop body has just deleted the last guy produced.
122 const Node* node = _node;
123 // Ensure that at least one copy of the last-seen edge was deleted.
124 // Note: It is OK to delete multiple copies of the last-seen edge.
125 // Unfortunately, we have no way to verify that all the deletions delete
126 // that same edge. On this point we must use the Honor System.
127 assert(node->_del_tick >= _del_tick+1, "must have deleted an edge")do { if (!(node->_del_tick >= _del_tick+1)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 127, "assert(" "node->_del_tick >= _del_tick+1" ") failed"
, "must have deleted an edge"); ::breakpoint(); } } while (0)
;
128 assert(node->_last_del == _last, "must have deleted the edge just produced")do { if (!(node->_last_del == _last)) { (*g_assert_poison)
= 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 128, "assert(" "node->_last_del == _last" ") failed", "must have deleted the edge just produced"
); ::breakpoint(); } } while (0)
;
129 // We liked this deletion, so accept the resulting outcnt and tick.
130 _outcnt = node->_outcnt;
131 _del_tick = node->_del_tick;
132}
133
134void DUIterator_Common::reset(const DUIterator_Common& that) {
135 if (this == &that) return; // ignore assignment to self
136 if (!_vdui) {
137 // We need to initialize everything, overwriting garbage values.
138 _last = that._last;
139 _vdui = that._vdui;
140 }
141 // Note: It is legal (though odd) for an iterator over some node x
142 // to be reassigned to iterate over another node y. Some doubly-nested
143 // progress loops depend on being able to do this.
144 const Node* node = that._node;
145 // Re-initialize everything, except _last.
146 _node = node;
147 _outcnt = node->_outcnt;
148 _del_tick = node->_del_tick;
149}
150
151void DUIterator::sample(const Node* node) {
152 DUIterator_Common::sample(node); // Initialize the assertion data.
153 _refresh_tick = 0; // No refreshes have happened, as yet.
154}
155
156void DUIterator::verify(const Node* node, bool at_end_ok) {
157 DUIterator_Common::verify(node, at_end_ok);
158 assert(_idx < node->_outcnt + (uint)at_end_ok, "idx in range")do { if (!(_idx < node->_outcnt + (uint)at_end_ok)) { (
*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 158, "assert(" "_idx < node->_outcnt + (uint)at_end_ok"
") failed", "idx in range"); ::breakpoint(); } } while (0)
;
159}
160
161void DUIterator::verify_increment() {
162 if (_refresh_tick & 1) {
163 // We have refreshed the index during this loop.
164 // Fix up _idx to meet asserts.
165 if (_idx > _outcnt) _idx = _outcnt;
166 }
167 verify(_node, true);
168}
169
170void DUIterator::verify_resync() {
171 // Note: We do not assert on _outcnt, because insertions are OK here.
172 DUIterator_Common::verify_resync();
173 // Make sure we are still in sync, possibly with no more out-edges:
174 verify(_node, true);
175}
176
177void DUIterator::reset(const DUIterator& that) {
178 if (this == &that) return; // self assignment is always a no-op
179 assert(that._refresh_tick == 0, "assign only the result of Node::outs()")do { if (!(that._refresh_tick == 0)) { (*g_assert_poison) = 'X'
;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 179, "assert(" "that._refresh_tick == 0" ") failed", "assign only the result of Node::outs()"
); ::breakpoint(); } } while (0)
;
180 assert(that._idx == 0, "assign only the result of Node::outs()")do { if (!(that._idx == 0)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 180, "assert(" "that._idx == 0" ") failed", "assign only the result of Node::outs()"
); ::breakpoint(); } } while (0)
;
181 assert(_idx == that._idx, "already assigned _idx")do { if (!(_idx == that._idx)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 181, "assert(" "_idx == that._idx" ") failed", "already assigned _idx"
); ::breakpoint(); } } while (0)
;
182 if (!_vdui) {
183 // We need to initialize everything, overwriting garbage values.
184 sample(that._node);
185 } else {
186 DUIterator_Common::reset(that);
187 if (_refresh_tick & 1) {
188 _refresh_tick++; // Clear the "was refreshed" flag.
189 }
190 assert(_refresh_tick < 2*100000, "DU iteration must converge quickly")do { if (!(_refresh_tick < 2*100000)) { (*g_assert_poison)
= 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 190, "assert(" "_refresh_tick < 2*100000" ") failed", "DU iteration must converge quickly"
); ::breakpoint(); } } while (0)
;
191 }
192}
193
194void DUIterator::refresh() {
195 DUIterator_Common::sample(_node); // Re-fetch assertion data.
196 _refresh_tick |= 1; // Set the "was refreshed" flag.
197}
198
199void DUIterator::verify_finish() {
200 // If the loop has killed the node, do not require it to re-run.
201 if (_node->_outcnt == 0) _refresh_tick &= ~1;
202 // If this assert triggers, it means that a loop used refresh_out_pos
203 // to re-synch an iteration index, but the loop did not correctly
204 // re-run itself, using a "while (progress)" construct.
205 // This iterator enforces the rule that you must keep trying the loop
206 // until it "runs clean" without any need for refreshing.
207 assert(!(_refresh_tick & 1), "the loop must run once with no refreshing")do { if (!(!(_refresh_tick & 1))) { (*g_assert_poison) = 'X'
;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 207, "assert(" "!(_refresh_tick & 1)" ") failed", "the loop must run once with no refreshing"
); ::breakpoint(); } } while (0)
;
208}
209
210
211void DUIterator_Fast::verify(const Node* node, bool at_end_ok) {
212 DUIterator_Common::verify(node, at_end_ok);
213 Node** out = node->_out;
214 uint cnt = node->_outcnt;
215 assert(cnt == _outcnt, "no insertions allowed")do { if (!(cnt == _outcnt)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 215, "assert(" "cnt == _outcnt" ") failed", "no insertions allowed"
); ::breakpoint(); } } while (0)
;
216 assert(_outp >= out && _outp <= out + cnt - !at_end_ok, "outp in range")do { if (!(_outp >= out && _outp <= out + cnt -
!at_end_ok)) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 216, "assert(" "_outp >= out && _outp <= out + cnt - !at_end_ok"
") failed", "outp in range"); ::breakpoint(); } } while (0)
;
217 // This last check is carefully designed to work for NO_OUT_ARRAY.
218}
219
220void DUIterator_Fast::verify_limit() {
221 const Node* node = _node;
222 verify(node, true);
223 assert(_outp == node->_out + node->_outcnt, "limit still correct")do { if (!(_outp == node->_out + node->_outcnt)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 223, "assert(" "_outp == node->_out + node->_outcnt" ") failed"
, "limit still correct"); ::breakpoint(); } } while (0)
;
224}
225
226void DUIterator_Fast::verify_resync() {
227 const Node* node = _node;
228 if (_outp == node->_out + _outcnt) {
229 // Note that the limit imax, not the pointer i, gets updated with the
230 // exact count of deletions. (For the pointer it's always "--i".)
231 assert(node->_outcnt+node->_del_tick == _outcnt+_del_tick, "no insertions allowed with deletion(s)")do { if (!(node->_outcnt+node->_del_tick == _outcnt+_del_tick
)) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 231, "assert(" "node->_outcnt+node->_del_tick == _outcnt+_del_tick"
") failed", "no insertions allowed with deletion(s)"); ::breakpoint
(); } } while (0)
;
232 // This is a limit pointer, with a name like "imax".
233 // Fudge the _last field so that the common assert will be happy.
234 _last = (Node*) node->_last_del;
235 DUIterator_Common::verify_resync();
236 } else {
237 assert(node->_outcnt < _outcnt, "no insertions allowed with deletion(s)")do { if (!(node->_outcnt < _outcnt)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 237, "assert(" "node->_outcnt < _outcnt" ") failed", "no insertions allowed with deletion(s)"
); ::breakpoint(); } } while (0)
;
238 // A normal internal pointer.
239 DUIterator_Common::verify_resync();
240 // Make sure we are still in sync, possibly with no more out-edges:
241 verify(node, true);
242 }
243}
244
245void DUIterator_Fast::verify_relimit(uint n) {
246 const Node* node = _node;
247 assert((int)n > 0, "use imax -= n only with a positive count")do { if (!((int)n > 0)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 247, "assert(" "(int)n > 0" ") failed", "use imax -= n only with a positive count"
); ::breakpoint(); } } while (0)
;
248 // This must be a limit pointer, with a name like "imax".
249 assert(_outp == node->_out + node->_outcnt, "apply -= only to a limit (imax)")do { if (!(_outp == node->_out + node->_outcnt)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 249, "assert(" "_outp == node->_out + node->_outcnt" ") failed"
, "apply -= only to a limit (imax)"); ::breakpoint(); } } while
(0)
;
250 // The reported number of deletions must match what the node saw.
251 assert(node->_del_tick == _del_tick + n, "must have deleted n edges")do { if (!(node->_del_tick == _del_tick + n)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 251, "assert(" "node->_del_tick == _del_tick + n" ") failed"
, "must have deleted n edges"); ::breakpoint(); } } while (0)
;
252 // Fudge the _last field so that the common assert will be happy.
253 _last = (Node*) node->_last_del;
254 DUIterator_Common::verify_resync();
255}
256
257void DUIterator_Fast::reset(const DUIterator_Fast& that) {
258 assert(_outp == that._outp, "already assigned _outp")do { if (!(_outp == that._outp)) { (*g_assert_poison) = 'X';;
report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 258, "assert(" "_outp == that._outp" ") failed", "already assigned _outp"
); ::breakpoint(); } } while (0)
;
259 DUIterator_Common::reset(that);
260}
261
262void DUIterator_Last::verify(const Node* node, bool at_end_ok) {
263 // at_end_ok means the _outp is allowed to underflow by 1
264 _outp += at_end_ok;
265 DUIterator_Fast::verify(node, at_end_ok); // check _del_tick, etc.
266 _outp -= at_end_ok;
267 assert(_outp == (node->_out + node->_outcnt) - 1, "pointer must point to end of nodes")do { if (!(_outp == (node->_out + node->_outcnt) - 1)) {
(*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 267, "assert(" "_outp == (node->_out + node->_outcnt) - 1"
") failed", "pointer must point to end of nodes"); ::breakpoint
(); } } while (0)
;
268}
269
270void DUIterator_Last::verify_limit() {
271 // Do not require the limit address to be resynched.
272 //verify(node, true);
273 assert(_outp == _node->_out, "limit still correct")do { if (!(_outp == _node->_out)) { (*g_assert_poison) = 'X'
;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 273, "assert(" "_outp == _node->_out" ") failed", "limit still correct"
); ::breakpoint(); } } while (0)
;
274}
275
276void DUIterator_Last::verify_step(uint num_edges) {
277 assert((int)num_edges > 0, "need non-zero edge count for loop progress")do { if (!((int)num_edges > 0)) { (*g_assert_poison) = 'X'
;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 277, "assert(" "(int)num_edges > 0" ") failed", "need non-zero edge count for loop progress"
); ::breakpoint(); } } while (0)
;
278 _outcnt -= num_edges;
279 _del_tick += num_edges;
280 // Make sure we are still in sync, possibly with no more out-edges:
281 const Node* node = _node;
282 verify(node, true);
283 assert(node->_last_del == _last, "must have deleted the edge just produced")do { if (!(node->_last_del == _last)) { (*g_assert_poison)
= 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 283, "assert(" "node->_last_del == _last" ") failed", "must have deleted the edge just produced"
); ::breakpoint(); } } while (0)
;
284}
285
286#endif //OPTO_DU_ITERATOR_ASSERT
287
288
289#endif //ASSERT
290
291
292// This constant used to initialize _out may be any non-null value.
293// The value NULL is reserved for the top node only.
294#define NO_OUT_ARRAY((Node**)-1) ((Node**)-1)
295
296// Out-of-line code from node constructors.
297// Executed only when extra debug info. is being passed around.
298static void init_node_notes(Compile* C, int idx, Node_Notes* nn) {
299 C->set_node_notes_at(idx, nn);
300}
301
302// Shared initialization code.
303inline int Node::Init(int req) {
304 Compile* C = Compile::current();
305 int idx = C->next_unique();
306 NOT_PRODUCT(_igv_idx = C->next_igv_idx())_igv_idx = C->next_igv_idx();
307
308 // Allocate memory for the necessary number of edges.
309 if (req > 0) {
310 // Allocate space for _in array to have double alignment.
311 _in = (Node **) ((char *) (C->node_arena()->AmallocWords(req * sizeof(void*))));
312 }
313 // If there are default notes floating around, capture them:
314 Node_Notes* nn = C->default_node_notes();
315 if (nn != NULL__null) init_node_notes(C, idx, nn);
316
317 // Note: At this point, C is dead,
318 // and we begin to initialize the new Node.
319
320 _cnt = _max = req;
321 _outcnt = _outmax = 0;
322 _class_id = Class_Node;
323 _flags = 0;
324 _out = NO_OUT_ARRAY((Node**)-1);
325 return idx;
326}
327
328//------------------------------Node-------------------------------------------
329// Create a Node, with a given number of required edges.
330Node::Node(uint req)
331 : _idx(Init(req))
332#ifdef ASSERT1
333 , _parse_idx(_idx)
334 , _indent(0)
335#endif
336{
337 assert( req < Compile::current()->max_node_limit() - NodeLimitFudgeFactor, "Input limit exceeded" )do { if (!(req < Compile::current()->max_node_limit() -
NodeLimitFudgeFactor)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 337, "assert(" "req < Compile::current()->max_node_limit() - NodeLimitFudgeFactor"
") failed", "Input limit exceeded"); ::breakpoint(); } } while
(0)
;
338 debug_only( verify_construction() )verify_construction();
339 NOT_PRODUCT(nodes_created++)nodes_created++;
340 if (req == 0) {
341 _in = NULL__null;
342 } else {
343 Node** to = _in;
344 for(uint i = 0; i < req; i++) {
345 to[i] = NULL__null;
346 }
347 }
348}
349
350//------------------------------Node-------------------------------------------
351Node::Node(Node *n0)
352 : _idx(Init(1))
353#ifdef ASSERT1
354 , _parse_idx(_idx)
355 , _indent(0)
356#endif
357{
358 debug_only( verify_construction() )verify_construction();
359 NOT_PRODUCT(nodes_created++)nodes_created++;
360 assert( is_not_dead(n0), "can not use dead node")do { if (!(((n0) == __null || !VerifyIterativeGVN || !((n0)->
is_dead())))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 360, "assert(" "((n0) == __null || !VerifyIterativeGVN || !((n0)->is_dead()))"
") failed", "can not use dead node"); ::breakpoint(); } } while
(0)
;
361 _in[0] = n0; if (n0 != NULL__null) n0->add_out((Node *)this);
362}
363
364//------------------------------Node-------------------------------------------
365Node::Node(Node *n0, Node *n1)
366 : _idx(Init(2))
367#ifdef ASSERT1
368 , _parse_idx(_idx)
369 , _indent(0)
370#endif
371{
372 debug_only( verify_construction() )verify_construction();
373 NOT_PRODUCT(nodes_created++)nodes_created++;
374 assert( is_not_dead(n0), "can not use dead node")do { if (!(((n0) == __null || !VerifyIterativeGVN || !((n0)->
is_dead())))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 374, "assert(" "((n0) == __null || !VerifyIterativeGVN || !((n0)->is_dead()))"
") failed", "can not use dead node"); ::breakpoint(); } } while
(0)
;
375 assert( is_not_dead(n1), "can not use dead node")do { if (!(((n1) == __null || !VerifyIterativeGVN || !((n1)->
is_dead())))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 375, "assert(" "((n1) == __null || !VerifyIterativeGVN || !((n1)->is_dead()))"
") failed", "can not use dead node"); ::breakpoint(); } } while
(0)
;
376 _in[0] = n0; if (n0 != NULL__null) n0->add_out((Node *)this);
377 _in[1] = n1; if (n1 != NULL__null) n1->add_out((Node *)this);
378}
379
380//------------------------------Node-------------------------------------------
381Node::Node(Node *n0, Node *n1, Node *n2)
382 : _idx(Init(3))
383#ifdef ASSERT1
384 , _parse_idx(_idx)
385 , _indent(0)
386#endif
387{
388 debug_only( verify_construction() )verify_construction();
389 NOT_PRODUCT(nodes_created++)nodes_created++;
390 assert( is_not_dead(n0), "can not use dead node")do { if (!(((n0) == __null || !VerifyIterativeGVN || !((n0)->
is_dead())))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 390, "assert(" "((n0) == __null || !VerifyIterativeGVN || !((n0)->is_dead()))"
") failed", "can not use dead node"); ::breakpoint(); } } while
(0)
;
391 assert( is_not_dead(n1), "can not use dead node")do { if (!(((n1) == __null || !VerifyIterativeGVN || !((n1)->
is_dead())))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 391, "assert(" "((n1) == __null || !VerifyIterativeGVN || !((n1)->is_dead()))"
") failed", "can not use dead node"); ::breakpoint(); } } while
(0)
;
392 assert( is_not_dead(n2), "can not use dead node")do { if (!(((n2) == __null || !VerifyIterativeGVN || !((n2)->
is_dead())))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 392, "assert(" "((n2) == __null || !VerifyIterativeGVN || !((n2)->is_dead()))"
") failed", "can not use dead node"); ::breakpoint(); } } while
(0)
;
393 _in[0] = n0; if (n0 != NULL__null) n0->add_out((Node *)this);
394 _in[1] = n1; if (n1 != NULL__null) n1->add_out((Node *)this);
395 _in[2] = n2; if (n2 != NULL__null) n2->add_out((Node *)this);
396}
397
398//------------------------------Node-------------------------------------------
399Node::Node(Node *n0, Node *n1, Node *n2, Node *n3)
400 : _idx(Init(4))
401#ifdef ASSERT1
402 , _parse_idx(_idx)
403 , _indent(0)
404#endif
405{
406 debug_only( verify_construction() )verify_construction();
407 NOT_PRODUCT(nodes_created++)nodes_created++;
408 assert( is_not_dead(n0), "can not use dead node")do { if (!(((n0) == __null || !VerifyIterativeGVN || !((n0)->
is_dead())))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 408, "assert(" "((n0) == __null || !VerifyIterativeGVN || !((n0)->is_dead()))"
") failed", "can not use dead node"); ::breakpoint(); } } while
(0)
;
409 assert( is_not_dead(n1), "can not use dead node")do { if (!(((n1) == __null || !VerifyIterativeGVN || !((n1)->
is_dead())))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 409, "assert(" "((n1) == __null || !VerifyIterativeGVN || !((n1)->is_dead()))"
") failed", "can not use dead node"); ::breakpoint(); } } while
(0)
;
410 assert( is_not_dead(n2), "can not use dead node")do { if (!(((n2) == __null || !VerifyIterativeGVN || !((n2)->
is_dead())))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 410, "assert(" "((n2) == __null || !VerifyIterativeGVN || !((n2)->is_dead()))"
") failed", "can not use dead node"); ::breakpoint(); } } while
(0)
;
411 assert( is_not_dead(n3), "can not use dead node")do { if (!(((n3) == __null || !VerifyIterativeGVN || !((n3)->
is_dead())))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 411, "assert(" "((n3) == __null || !VerifyIterativeGVN || !((n3)->is_dead()))"
") failed", "can not use dead node"); ::breakpoint(); } } while
(0)
;
412 _in[0] = n0; if (n0 != NULL__null) n0->add_out((Node *)this);
413 _in[1] = n1; if (n1 != NULL__null) n1->add_out((Node *)this);
414 _in[2] = n2; if (n2 != NULL__null) n2->add_out((Node *)this);
415 _in[3] = n3; if (n3 != NULL__null) n3->add_out((Node *)this);
416}
417
418//------------------------------Node-------------------------------------------
419Node::Node(Node *n0, Node *n1, Node *n2, Node *n3, Node *n4)
420 : _idx(Init(5))
421#ifdef ASSERT1
422 , _parse_idx(_idx)
423 , _indent(0)
424#endif
425{
426 debug_only( verify_construction() )verify_construction();
427 NOT_PRODUCT(nodes_created++)nodes_created++;
428 assert( is_not_dead(n0), "can not use dead node")do { if (!(((n0) == __null || !VerifyIterativeGVN || !((n0)->
is_dead())))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 428, "assert(" "((n0) == __null || !VerifyIterativeGVN || !((n0)->is_dead()))"
") failed", "can not use dead node"); ::breakpoint(); } } while
(0)
;
429 assert( is_not_dead(n1), "can not use dead node")do { if (!(((n1) == __null || !VerifyIterativeGVN || !((n1)->
is_dead())))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 429, "assert(" "((n1) == __null || !VerifyIterativeGVN || !((n1)->is_dead()))"
") failed", "can not use dead node"); ::breakpoint(); } } while
(0)
;
430 assert( is_not_dead(n2), "can not use dead node")do { if (!(((n2) == __null || !VerifyIterativeGVN || !((n2)->
is_dead())))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 430, "assert(" "((n2) == __null || !VerifyIterativeGVN || !((n2)->is_dead()))"
") failed", "can not use dead node"); ::breakpoint(); } } while
(0)
;
431 assert( is_not_dead(n3), "can not use dead node")do { if (!(((n3) == __null || !VerifyIterativeGVN || !((n3)->
is_dead())))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 431, "assert(" "((n3) == __null || !VerifyIterativeGVN || !((n3)->is_dead()))"
") failed", "can not use dead node"); ::breakpoint(); } } while
(0)
;
432 assert( is_not_dead(n4), "can not use dead node")do { if (!(((n4) == __null || !VerifyIterativeGVN || !((n4)->
is_dead())))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 432, "assert(" "((n4) == __null || !VerifyIterativeGVN || !((n4)->is_dead()))"
") failed", "can not use dead node"); ::breakpoint(); } } while
(0)
;
433 _in[0] = n0; if (n0 != NULL__null) n0->add_out((Node *)this);
434 _in[1] = n1; if (n1 != NULL__null) n1->add_out((Node *)this);
435 _in[2] = n2; if (n2 != NULL__null) n2->add_out((Node *)this);
436 _in[3] = n3; if (n3 != NULL__null) n3->add_out((Node *)this);
437 _in[4] = n4; if (n4 != NULL__null) n4->add_out((Node *)this);
438}
439
440//------------------------------Node-------------------------------------------
441Node::Node(Node *n0, Node *n1, Node *n2, Node *n3,
442 Node *n4, Node *n5)
443 : _idx(Init(6))
444#ifdef ASSERT1
445 , _parse_idx(_idx)
446 , _indent(0)
447#endif
448{
449 debug_only( verify_construction() )verify_construction();
450 NOT_PRODUCT(nodes_created++)nodes_created++;
451 assert( is_not_dead(n0), "can not use dead node")do { if (!(((n0) == __null || !VerifyIterativeGVN || !((n0)->
is_dead())))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 451, "assert(" "((n0) == __null || !VerifyIterativeGVN || !((n0)->is_dead()))"
") failed", "can not use dead node"); ::breakpoint(); } } while
(0)
;
452 assert( is_not_dead(n1), "can not use dead node")do { if (!(((n1) == __null || !VerifyIterativeGVN || !((n1)->
is_dead())))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 452, "assert(" "((n1) == __null || !VerifyIterativeGVN || !((n1)->is_dead()))"
") failed", "can not use dead node"); ::breakpoint(); } } while
(0)
;
453 assert( is_not_dead(n2), "can not use dead node")do { if (!(((n2) == __null || !VerifyIterativeGVN || !((n2)->
is_dead())))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 453, "assert(" "((n2) == __null || !VerifyIterativeGVN || !((n2)->is_dead()))"
") failed", "can not use dead node"); ::breakpoint(); } } while
(0)
;
454 assert( is_not_dead(n3), "can not use dead node")do { if (!(((n3) == __null || !VerifyIterativeGVN || !((n3)->
is_dead())))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 454, "assert(" "((n3) == __null || !VerifyIterativeGVN || !((n3)->is_dead()))"
") failed", "can not use dead node"); ::breakpoint(); } } while
(0)
;
455 assert( is_not_dead(n4), "can not use dead node")do { if (!(((n4) == __null || !VerifyIterativeGVN || !((n4)->
is_dead())))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 455, "assert(" "((n4) == __null || !VerifyIterativeGVN || !((n4)->is_dead()))"
") failed", "can not use dead node"); ::breakpoint(); } } while
(0)
;
456 assert( is_not_dead(n5), "can not use dead node")do { if (!(((n5) == __null || !VerifyIterativeGVN || !((n5)->
is_dead())))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 456, "assert(" "((n5) == __null || !VerifyIterativeGVN || !((n5)->is_dead()))"
") failed", "can not use dead node"); ::breakpoint(); } } while
(0)
;
457 _in[0] = n0; if (n0 != NULL__null) n0->add_out((Node *)this);
458 _in[1] = n1; if (n1 != NULL__null) n1->add_out((Node *)this);
459 _in[2] = n2; if (n2 != NULL__null) n2->add_out((Node *)this);
460 _in[3] = n3; if (n3 != NULL__null) n3->add_out((Node *)this);
461 _in[4] = n4; if (n4 != NULL__null) n4->add_out((Node *)this);
462 _in[5] = n5; if (n5 != NULL__null) n5->add_out((Node *)this);
463}
464
465//------------------------------Node-------------------------------------------
466Node::Node(Node *n0, Node *n1, Node *n2, Node *n3,
467 Node *n4, Node *n5, Node *n6)
468 : _idx(Init(7))
469#ifdef ASSERT1
470 , _parse_idx(_idx)
471 , _indent(0)
472#endif
473{
474 debug_only( verify_construction() )verify_construction();
475 NOT_PRODUCT(nodes_created++)nodes_created++;
476 assert( is_not_dead(n0), "can not use dead node")do { if (!(((n0) == __null || !VerifyIterativeGVN || !((n0)->
is_dead())))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 476, "assert(" "((n0) == __null || !VerifyIterativeGVN || !((n0)->is_dead()))"
") failed", "can not use dead node"); ::breakpoint(); } } while
(0)
;
477 assert( is_not_dead(n1), "can not use dead node")do { if (!(((n1) == __null || !VerifyIterativeGVN || !((n1)->
is_dead())))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 477, "assert(" "((n1) == __null || !VerifyIterativeGVN || !((n1)->is_dead()))"
") failed", "can not use dead node"); ::breakpoint(); } } while
(0)
;
478 assert( is_not_dead(n2), "can not use dead node")do { if (!(((n2) == __null || !VerifyIterativeGVN || !((n2)->
is_dead())))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 478, "assert(" "((n2) == __null || !VerifyIterativeGVN || !((n2)->is_dead()))"
") failed", "can not use dead node"); ::breakpoint(); } } while
(0)
;
479 assert( is_not_dead(n3), "can not use dead node")do { if (!(((n3) == __null || !VerifyIterativeGVN || !((n3)->
is_dead())))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 479, "assert(" "((n3) == __null || !VerifyIterativeGVN || !((n3)->is_dead()))"
") failed", "can not use dead node"); ::breakpoint(); } } while
(0)
;
480 assert( is_not_dead(n4), "can not use dead node")do { if (!(((n4) == __null || !VerifyIterativeGVN || !((n4)->
is_dead())))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 480, "assert(" "((n4) == __null || !VerifyIterativeGVN || !((n4)->is_dead()))"
") failed", "can not use dead node"); ::breakpoint(); } } while
(0)
;
481 assert( is_not_dead(n5), "can not use dead node")do { if (!(((n5) == __null || !VerifyIterativeGVN || !((n5)->
is_dead())))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 481, "assert(" "((n5) == __null || !VerifyIterativeGVN || !((n5)->is_dead()))"
") failed", "can not use dead node"); ::breakpoint(); } } while
(0)
;
482 assert( is_not_dead(n6), "can not use dead node")do { if (!(((n6) == __null || !VerifyIterativeGVN || !((n6)->
is_dead())))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 482, "assert(" "((n6) == __null || !VerifyIterativeGVN || !((n6)->is_dead()))"
") failed", "can not use dead node"); ::breakpoint(); } } while
(0)
;
483 _in[0] = n0; if (n0 != NULL__null) n0->add_out((Node *)this);
484 _in[1] = n1; if (n1 != NULL__null) n1->add_out((Node *)this);
485 _in[2] = n2; if (n2 != NULL__null) n2->add_out((Node *)this);
486 _in[3] = n3; if (n3 != NULL__null) n3->add_out((Node *)this);
487 _in[4] = n4; if (n4 != NULL__null) n4->add_out((Node *)this);
488 _in[5] = n5; if (n5 != NULL__null) n5->add_out((Node *)this);
489 _in[6] = n6; if (n6 != NULL__null) n6->add_out((Node *)this);
490}
491
492#ifdef __clang__1
493#pragma clang diagnostic pop
494#endif
495
496
497//------------------------------clone------------------------------------------
498// Clone a Node.
499Node *Node::clone() const {
500 Compile* C = Compile::current();
501 uint s = size_of(); // Size of inherited Node
502 Node *n = (Node*)C->node_arena()->AmallocWords(size_of() + _max*sizeof(Node*));
503 Copy::conjoint_words_to_lower((HeapWord*)this, (HeapWord*)n, s);
504 // Set the new input pointer array
505 n->_in = (Node**)(((char*)n)+s);
506 // Cannot share the old output pointer array, so kill it
507 n->_out = NO_OUT_ARRAY((Node**)-1);
508 // And reset the counters to 0
509 n->_outcnt = 0;
510 n->_outmax = 0;
511 // Unlock this guy, since he is not in any hash table.
512 debug_only(n->_hash_lock = 0)n->_hash_lock = 0;
513 // Walk the old node's input list to duplicate its edges
514 uint i;
515 for( i = 0; i < len(); i++ ) {
516 Node *x = in(i);
517 n->_in[i] = x;
518 if (x != NULL__null) x->add_out(n);
519 }
520 if (is_macro()) {
521 C->add_macro_node(n);
522 }
523 if (is_expensive()) {
524 C->add_expensive_node(n);
525 }
526 if (for_post_loop_opts_igvn()) {
527 // Don't add cloned node to Compile::_for_post_loop_opts_igvn list automatically.
528 // If it is applicable, it will happen anyway when the cloned node is registered with IGVN.
529 n->remove_flag(Node::NodeFlags::Flag_for_post_loop_opts_igvn);
530 }
531 if (n->is_reduction()) {
532 // Do not copy reduction information. This must be explicitly set by the calling code.
533 n->remove_flag(Node::Flag_is_reduction);
534 }
535 BarrierSetC2* bs = BarrierSet::barrier_set()->barrier_set_c2();
536 bs->register_potential_barrier_node(n);
537
538 n->set_idx(C->next_unique()); // Get new unique index as well
539 NOT_PRODUCT(n->_igv_idx = C->next_igv_idx())n->_igv_idx = C->next_igv_idx();
540 debug_only( n->verify_construction() )n->verify_construction();
541 NOT_PRODUCT(nodes_created++)nodes_created++;
542 // Do not patch over the debug_idx of a clone, because it makes it
543 // impossible to break on the clone's moment of creation.
544 //debug_only( n->set_debug_idx( debug_idx() ) );
545
546 C->copy_node_notes_to(n, (Node*) this);
547
548 // MachNode clone
549 uint nopnds;
550 if (this->is_Mach() && (nopnds = this->as_Mach()->num_opnds()) > 0) {
551 MachNode *mach = n->as_Mach();
552 MachNode *mthis = this->as_Mach();
553 // Get address of _opnd_array.
554 // It should be the same offset since it is the clone of this node.
555 MachOper **from = mthis->_opnds;
556 MachOper **to = (MachOper **)((size_t)(&mach->_opnds) +
557 pointer_delta((const void*)from,
558 (const void*)(&mthis->_opnds), 1));
559 mach->_opnds = to;
560 for ( uint i = 0; i < nopnds; ++i ) {
561 to[i] = from[i]->clone();
562 }
563 }
564 if (n->is_Call()) {
565 // CallGenerator is linked to the original node.
566 CallGenerator* cg = n->as_Call()->generator();
567 if (cg != NULL__null) {
568 CallGenerator* cloned_cg = cg->with_call_node(n->as_Call());
569 n->as_Call()->set_generator(cloned_cg);
570
571 C->print_inlining_assert_ready();
572 C->print_inlining_move_to(cg);
573 C->print_inlining_update(cloned_cg);
574 }
575 }
576 if (n->is_SafePoint()) {
577 // Scalar replacement and macro expansion might modify the JVMState.
578 // Clone it to make sure it's not shared between SafePointNodes.
579 n->as_SafePoint()->clone_jvms(C);
580 n->as_SafePoint()->clone_replaced_nodes();
581 }
582 return n; // Return the clone
583}
584
585//---------------------------setup_is_top--------------------------------------
586// Call this when changing the top node, to reassert the invariants
587// required by Node::is_top. See Compile::set_cached_top_node.
588void Node::setup_is_top() {
589 if (this == (Node*)Compile::current()->top()) {
590 // This node has just become top. Kill its out array.
591 _outcnt = _outmax = 0;
592 _out = NULL__null; // marker value for top
593 assert(is_top(), "must be top")do { if (!(is_top())) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 593, "assert(" "is_top()" ") failed", "must be top"); ::breakpoint
(); } } while (0)
;
594 } else {
595 if (_out == NULL__null) _out = NO_OUT_ARRAY((Node**)-1);
596 assert(!is_top(), "must not be top")do { if (!(!is_top())) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 596, "assert(" "!is_top()" ") failed", "must not be top"); ::
breakpoint(); } } while (0)
;
597 }
598}
599
600//------------------------------~Node------------------------------------------
601// Fancy destructor; eagerly attempt to reclaim Node numberings and storage
602void Node::destruct(PhaseValues* phase) {
603 Compile* compile = (phase != NULL__null) ? phase->C : Compile::current();
604 if (phase != NULL__null && phase->is_IterGVN()) {
605 phase->is_IterGVN()->_worklist.remove(this);
606 }
607 // If this is the most recently created node, reclaim its index. Otherwise,
608 // record the node as dead to keep liveness information accurate.
609 if ((uint)_idx+1 == compile->unique()) {
610 compile->set_unique(compile->unique()-1);
611 } else {
612 compile->record_dead_node(_idx);
613 }
614 // Clear debug info:
615 Node_Notes* nn = compile->node_notes_at(_idx);
616 if (nn != NULL__null) nn->clear();
617 // Walk the input array, freeing the corresponding output edges
618 _cnt = _max; // forget req/prec distinction
619 uint i;
620 for( i = 0; i < _max; i++ ) {
621 set_req(i, NULL__null);
622 //assert(def->out(def->outcnt()-1) == (Node *)this,"bad def-use hacking in reclaim");
623 }
624 assert(outcnt() == 0, "deleting a node must not leave a dangling use")do { if (!(outcnt() == 0)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 624, "assert(" "outcnt() == 0" ") failed", "deleting a node must not leave a dangling use"
); ::breakpoint(); } } while (0)
;
625 // See if the input array was allocated just prior to the object
626 int edge_size = _max*sizeof(void*);
627 int out_edge_size = _outmax*sizeof(void*);
628 char *edge_end = ((char*)_in) + edge_size;
629 char *out_array = (char*)(_out == NO_OUT_ARRAY((Node**)-1)? NULL__null: _out);
630 int node_size = size_of();
631
632 // Free the output edge array
633 if (out_edge_size > 0) {
634 compile->node_arena()->Afree(out_array, out_edge_size);
635 }
636
637 // Free the input edge array and the node itself
638 if( edge_end == (char*)this ) {
639 // It was; free the input array and object all in one hit
640#ifndef ASSERT1
641 compile->node_arena()->Afree(_in,edge_size+node_size);
642#endif
643 } else {
644 // Free just the input array
645 compile->node_arena()->Afree(_in,edge_size);
646
647 // Free just the object
648#ifndef ASSERT1
649 compile->node_arena()->Afree(this,node_size);
650#endif
651 }
652 if (is_macro()) {
653 compile->remove_macro_node(this);
654 }
655 if (is_expensive()) {
656 compile->remove_expensive_node(this);
657 }
658 if (Opcode() == Op_Opaque4) {
659 compile->remove_skeleton_predicate_opaq(this);
660 }
661 if (for_post_loop_opts_igvn()) {
662 compile->remove_from_post_loop_opts_igvn(this);
663 }
664
665 if (is_SafePoint()) {
666 as_SafePoint()->delete_replaced_nodes();
667 }
668 BarrierSetC2* bs = BarrierSet::barrier_set()->barrier_set_c2();
669 bs->unregister_potential_barrier_node(this);
670#ifdef ASSERT1
671 // We will not actually delete the storage, but we'll make the node unusable.
672 *(address*)this = badAddress((address)::badAddressVal); // smash the C++ vtbl, probably
673 _in = _out = (Node**) badAddress((address)::badAddressVal);
674 _max = _cnt = _outmax = _outcnt = 0;
675 compile->remove_modified_node(this);
676#endif
677}
678
679//------------------------------grow-------------------------------------------
680// Grow the input array, making space for more edges
681void Node::grow(uint len) {
682 Arena* arena = Compile::current()->node_arena();
683 uint new_max = _max;
684 if( new_max == 0 ) {
685 _max = 4;
686 _in = (Node**)arena->Amalloc(4*sizeof(Node*));
687 Node** to = _in;
688 to[0] = NULL__null;
689 to[1] = NULL__null;
690 to[2] = NULL__null;
691 to[3] = NULL__null;
692 return;
693 }
694 new_max = next_power_of_2(len);
695 // Trimming to limit allows a uint8 to handle up to 255 edges.
696 // Previously I was using only powers-of-2 which peaked at 128 edges.
697 //if( new_max >= limit ) new_max = limit-1;
698 _in = (Node**)arena->Arealloc(_in, _max*sizeof(Node*), new_max*sizeof(Node*));
699 Copy::zero_to_bytes(&_in[_max], (new_max-_max)*sizeof(Node*)); // NULL all new space
700 _max = new_max; // Record new max length
701 // This assertion makes sure that Node::_max is wide enough to
702 // represent the numerical value of new_max.
703 assert(_max == new_max && _max > len, "int width of _max is too small")do { if (!(_max == new_max && _max > len)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 703, "assert(" "_max == new_max && _max > len" ") failed"
, "int width of _max is too small"); ::breakpoint(); } } while
(0)
;
704}
705
706//-----------------------------out_grow----------------------------------------
707// Grow the input array, making space for more edges
708void Node::out_grow( uint len ) {
709 assert(!is_top(), "cannot grow a top node's out array")do { if (!(!is_top())) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 709, "assert(" "!is_top()" ") failed", "cannot grow a top node's out array"
); ::breakpoint(); } } while (0)
;
710 Arena* arena = Compile::current()->node_arena();
711 uint new_max = _outmax;
712 if( new_max == 0 ) {
713 _outmax = 4;
714 _out = (Node **)arena->Amalloc(4*sizeof(Node*));
715 return;
716 }
717 new_max = next_power_of_2(len);
718 // Trimming to limit allows a uint8 to handle up to 255 edges.
719 // Previously I was using only powers-of-2 which peaked at 128 edges.
720 //if( new_max >= limit ) new_max = limit-1;
721 assert(_out != NULL && _out != NO_OUT_ARRAY, "out must have sensible value")do { if (!(_out != __null && _out != ((Node**)-1))) {
(*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 721, "assert(" "_out != __null && _out != ((Node**)-1)"
") failed", "out must have sensible value"); ::breakpoint();
} } while (0)
;
722 _out = (Node**)arena->Arealloc(_out,_outmax*sizeof(Node*),new_max*sizeof(Node*));
723 //Copy::zero_to_bytes(&_out[_outmax], (new_max-_outmax)*sizeof(Node*)); // NULL all new space
724 _outmax = new_max; // Record new max length
725 // This assertion makes sure that Node::_max is wide enough to
726 // represent the numerical value of new_max.
727 assert(_outmax == new_max && _outmax > len, "int width of _outmax is too small")do { if (!(_outmax == new_max && _outmax > len)) {
(*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 727, "assert(" "_outmax == new_max && _outmax > len"
") failed", "int width of _outmax is too small"); ::breakpoint
(); } } while (0)
;
728}
729
730#ifdef ASSERT1
731//------------------------------is_dead----------------------------------------
732bool Node::is_dead() const {
733 // Mach and pinch point nodes may look like dead.
734 if( is_top() || is_Mach() || (Opcode() == Op_Node && _outcnt > 0) )
7
Assuming the condition is false
735 return false;
736 for( uint i = 0; i < _max; i++ )
8
Assuming 'i' is >= field '_max'
9
Loop condition is false. Execution continues on line 739
737 if( _in[i] != NULL__null )
738 return false;
739 dump();
10
Calling 'Node::dump'
740 return true;
741}
742
743bool Node::is_reachable_from_root() const {
744 ResourceMark rm;
745 Unique_Node_List wq;
746 wq.push((Node*)this);
747 RootNode* root = Compile::current()->root();
748 for (uint i = 0; i < wq.size(); i++) {
749 Node* m = wq.at(i);
750 if (m == root) {
751 return true;
752 }
753 for (DUIterator_Fast jmax, j = m->fast_outs(jmax); j < jmax; j++) {
754 Node* u = m->fast_out(j);
755 wq.push(u);
756 }
757 }
758 return false;
759}
760#endif
761
762//------------------------------is_unreachable---------------------------------
763bool Node::is_unreachable(PhaseIterGVN &igvn) const {
764 assert(!is_Mach(), "doesn't work with MachNodes")do { if (!(!is_Mach())) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 764, "assert(" "!is_Mach()" ") failed", "doesn't work with MachNodes"
); ::breakpoint(); } } while (0)
;
765 return outcnt() == 0 || igvn.type(this) == Type::TOP || (in(0) != NULL__null && in(0)->is_top());
766}
767
768//------------------------------add_req----------------------------------------
769// Add a new required input at the end
770void Node::add_req( Node *n ) {
771 assert( is_not_dead(n), "can not use dead node")do { if (!(((n) == __null || !VerifyIterativeGVN || !((n)->
is_dead())))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 771, "assert(" "((n) == __null || !VerifyIterativeGVN || !((n)->is_dead()))"
") failed", "can not use dead node"); ::breakpoint(); } } while
(0)
;
772
773 // Look to see if I can move precedence down one without reallocating
774 if( (_cnt >= _max) || (in(_max-1) != NULL__null) )
775 grow( _max+1 );
776
777 // Find a precedence edge to move
778 if( in(_cnt) != NULL__null ) { // Next precedence edge is busy?
779 uint i;
780 for( i=_cnt; i<_max; i++ )
781 if( in(i) == NULL__null ) // Find the NULL at end of prec edge list
782 break; // There must be one, since we grew the array
783 _in[i] = in(_cnt); // Move prec over, making space for req edge
784 }
785 _in[_cnt++] = n; // Stuff over old prec edge
786 if (n != NULL__null) n->add_out((Node *)this);
787}
788
789//---------------------------add_req_batch-------------------------------------
790// Add a new required input at the end
791void Node::add_req_batch( Node *n, uint m ) {
792 assert( is_not_dead(n), "can not use dead node")do { if (!(((n) == __null || !VerifyIterativeGVN || !((n)->
is_dead())))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 792, "assert(" "((n) == __null || !VerifyIterativeGVN || !((n)->is_dead()))"
") failed", "can not use dead node"); ::breakpoint(); } } while
(0)
;
793 // check various edge cases
794 if ((int)m <= 1) {
795 assert((int)m >= 0, "oob")do { if (!((int)m >= 0)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 795, "assert(" "(int)m >= 0" ") failed", "oob"); ::breakpoint
(); } } while (0)
;
796 if (m != 0) add_req(n);
797 return;
798 }
799
800 // Look to see if I can move precedence down one without reallocating
801 if( (_cnt+m) > _max || _in[_max-m] )
802 grow( _max+m );
803
804 // Find a precedence edge to move
805 if( _in[_cnt] != NULL__null ) { // Next precedence edge is busy?
806 uint i;
807 for( i=_cnt; i<_max; i++ )
808 if( _in[i] == NULL__null ) // Find the NULL at end of prec edge list
809 break; // There must be one, since we grew the array
810 // Slide all the precs over by m positions (assume #prec << m).
811 Copy::conjoint_words_to_higher((HeapWord*)&_in[_cnt], (HeapWord*)&_in[_cnt+m], ((i-_cnt)*sizeof(Node*)));
812 }
813
814 // Stuff over the old prec edges
815 for(uint i=0; i<m; i++ ) {
816 _in[_cnt++] = n;
817 }
818
819 // Insert multiple out edges on the node.
820 if (n != NULL__null && !n->is_top()) {
821 for(uint i=0; i<m; i++ ) {
822 n->add_out((Node *)this);
823 }
824 }
825}
826
827//------------------------------del_req----------------------------------------
828// Delete the required edge and compact the edge array
829void Node::del_req( uint idx ) {
830 assert( idx < _cnt, "oob")do { if (!(idx < _cnt)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 830, "assert(" "idx < _cnt" ") failed", "oob"); ::breakpoint
(); } } while (0)
;
831 assert( !VerifyHashTableKeys || _hash_lock == 0,do { if (!(!VerifyHashTableKeys || _hash_lock == 0)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 832, "assert(" "!VerifyHashTableKeys || _hash_lock == 0" ") failed"
, "remove node from hash table before modifying it"); ::breakpoint
(); } } while (0)
832 "remove node from hash table before modifying it")do { if (!(!VerifyHashTableKeys || _hash_lock == 0)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 832, "assert(" "!VerifyHashTableKeys || _hash_lock == 0" ") failed"
, "remove node from hash table before modifying it"); ::breakpoint
(); } } while (0)
;
833 // First remove corresponding def-use edge
834 Node *n = in(idx);
835 if (n != NULL__null) n->del_out((Node *)this);
836 _in[idx] = in(--_cnt); // Compact the array
837 // Avoid spec violation: Gap in prec edges.
838 close_prec_gap_at(_cnt);
839 Compile::current()->record_modified_node(this);
840}
841
842//------------------------------del_req_ordered--------------------------------
843// Delete the required edge and compact the edge array with preserved order
844void Node::del_req_ordered( uint idx ) {
845 assert( idx < _cnt, "oob")do { if (!(idx < _cnt)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 845, "assert(" "idx < _cnt" ") failed", "oob"); ::breakpoint
(); } } while (0)
;
846 assert( !VerifyHashTableKeys || _hash_lock == 0,do { if (!(!VerifyHashTableKeys || _hash_lock == 0)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 847, "assert(" "!VerifyHashTableKeys || _hash_lock == 0" ") failed"
, "remove node from hash table before modifying it"); ::breakpoint
(); } } while (0)
847 "remove node from hash table before modifying it")do { if (!(!VerifyHashTableKeys || _hash_lock == 0)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 847, "assert(" "!VerifyHashTableKeys || _hash_lock == 0" ") failed"
, "remove node from hash table before modifying it"); ::breakpoint
(); } } while (0)
;
848 // First remove corresponding def-use edge
849 Node *n = in(idx);
850 if (n != NULL__null) n->del_out((Node *)this);
851 if (idx < --_cnt) { // Not last edge ?
852 Copy::conjoint_words_to_lower((HeapWord*)&_in[idx+1], (HeapWord*)&_in[idx], ((_cnt-idx)*sizeof(Node*)));
853 }
854 // Avoid spec violation: Gap in prec edges.
855 close_prec_gap_at(_cnt);
856 Compile::current()->record_modified_node(this);
857}
858
859//------------------------------ins_req----------------------------------------
860// Insert a new required input at the end
861void Node::ins_req( uint idx, Node *n ) {
862 assert( is_not_dead(n), "can not use dead node")do { if (!(((n) == __null || !VerifyIterativeGVN || !((n)->
is_dead())))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 862, "assert(" "((n) == __null || !VerifyIterativeGVN || !((n)->is_dead()))"
") failed", "can not use dead node"); ::breakpoint(); } } while
(0)
;
863 add_req(NULL__null); // Make space
864 assert( idx < _max, "Must have allocated enough space")do { if (!(idx < _max)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 864, "assert(" "idx < _max" ") failed", "Must have allocated enough space"
); ::breakpoint(); } } while (0)
;
865 // Slide over
866 if(_cnt-idx-1 > 0) {
867 Copy::conjoint_words_to_higher((HeapWord*)&_in[idx], (HeapWord*)&_in[idx+1], ((_cnt-idx-1)*sizeof(Node*)));
868 }
869 _in[idx] = n; // Stuff over old required edge
870 if (n != NULL__null) n->add_out((Node *)this); // Add reciprocal def-use edge
871}
872
873//-----------------------------find_edge---------------------------------------
874int Node::find_edge(Node* n) {
875 for (uint i = 0; i < len(); i++) {
876 if (_in[i] == n) return i;
877 }
878 return -1;
879}
880
881//----------------------------replace_edge-------------------------------------
882int Node::replace_edge(Node* old, Node* neww, PhaseGVN* gvn) {
883 if (old == neww) return 0; // nothing to do
884 uint nrep = 0;
885 for (uint i = 0; i < len(); i++) {
886 if (in(i) == old) {
887 if (i < req()) {
888 if (gvn != NULL__null) {
889 set_req_X(i, neww, gvn);
890 } else {
891 set_req(i, neww);
892 }
893 } else {
894 assert(gvn == NULL || gvn->is_IterGVN() == NULL, "no support for igvn here")do { if (!(gvn == __null || gvn->is_IterGVN() == __null)) {
(*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 894, "assert(" "gvn == __null || gvn->is_IterGVN() == __null"
") failed", "no support for igvn here"); ::breakpoint(); } }
while (0)
;
895 assert(find_prec_edge(neww) == -1, "spec violation: duplicated prec edge (node %d -> %d)", _idx, neww->_idx)do { if (!(find_prec_edge(neww) == -1)) { (*g_assert_poison) =
'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 895, "assert(" "find_prec_edge(neww) == -1" ") failed", "spec violation: duplicated prec edge (node %d -> %d)"
, _idx, neww->_idx); ::breakpoint(); } } while (0)
;
896 set_prec(i, neww);
897 }
898 nrep++;
899 }
900 }
901 return nrep;
902}
903
904/**
905 * Replace input edges in the range pointing to 'old' node.
906 */
907int Node::replace_edges_in_range(Node* old, Node* neww, int start, int end, PhaseGVN* gvn) {
908 if (old == neww) return 0; // nothing to do
909 uint nrep = 0;
910 for (int i = start; i < end; i++) {
911 if (in(i) == old) {
912 set_req_X(i, neww, gvn);
913 nrep++;
914 }
915 }
916 return nrep;
917}
918
919//-------------------------disconnect_inputs-----------------------------------
920// NULL out all inputs to eliminate incoming Def-Use edges.
921void Node::disconnect_inputs(Compile* C) {
922 // the layout of Node::_in
923 // r: a required input, null is allowed
924 // p: a precedence, null values are all at the end
925 // -----------------------------------
926 // |r|...|r|p|...|p|null|...|null|
927 // | |
928 // req() len()
929 // -----------------------------------
930 for (uint i = 0; i < req(); ++i) {
931 if (in(i) != nullptr) {
932 set_req(i, nullptr);
933 }
934 }
935
936 // Remove precedence edges if any exist
937 // Note: Safepoints may have precedence edges, even during parsing
938 for (uint i = len(); i > req(); ) {
939 rm_prec(--i); // no-op if _in[i] is nullptr
940 }
941
942#ifdef ASSERT1
943 // sanity check
944 for (uint i = 0; i < len(); ++i) {
945 assert(_in[i] == nullptr, "disconnect_inputs() failed!")do { if (!(_in[i] == nullptr)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 945, "assert(" "_in[i] == nullptr" ") failed", "disconnect_inputs() failed!"
); ::breakpoint(); } } while (0)
;
946 }
947#endif
948
949 // Node::destruct requires all out edges be deleted first
950 // debug_only(destruct();) // no reuse benefit expected
951 C->record_dead_node(_idx);
952}
953
954//-----------------------------uncast---------------------------------------
955// %%% Temporary, until we sort out CheckCastPP vs. CastPP.
956// Strip away casting. (It is depth-limited.)
957// Optionally, keep casts with dependencies.
958Node* Node::uncast(bool keep_deps) const {
959 // Should be inline:
960 //return is_ConstraintCast() ? uncast_helper(this) : (Node*) this;
961 if (is_ConstraintCast()) {
962 return uncast_helper(this, keep_deps);
963 } else {
964 return (Node*) this;
965 }
966}
967
968// Find out of current node that matches opcode.
969Node* Node::find_out_with(int opcode) {
970 for (DUIterator_Fast imax, i = fast_outs(imax); i < imax; i++) {
971 Node* use = fast_out(i);
972 if (use->Opcode() == opcode) {
973 return use;
974 }
975 }
976 return NULL__null;
977}
978
979// Return true if the current node has an out that matches opcode.
980bool Node::has_out_with(int opcode) {
981 return (find_out_with(opcode) != NULL__null);
982}
983
984// Return true if the current node has an out that matches any of the opcodes.
985bool Node::has_out_with(int opcode1, int opcode2, int opcode3, int opcode4) {
986 for (DUIterator_Fast imax, i = fast_outs(imax); i < imax; i++) {
987 int opcode = fast_out(i)->Opcode();
988 if (opcode == opcode1 || opcode == opcode2 || opcode == opcode3 || opcode == opcode4) {
989 return true;
990 }
991 }
992 return false;
993}
994
995
996//---------------------------uncast_helper-------------------------------------
997Node* Node::uncast_helper(const Node* p, bool keep_deps) {
998#ifdef ASSERT1
999 uint depth_count = 0;
1000 const Node* orig_p = p;
1001#endif
1002
1003 while (true) {
1004#ifdef ASSERT1
1005 if (depth_count >= K) {
1006 orig_p->dump(4);
1007 if (p != orig_p)
1008 p->dump(1);
1009 }
1010 assert(depth_count++ < K, "infinite loop in Node::uncast_helper")do { if (!(depth_count++ < K)) { (*g_assert_poison) = 'X';
; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 1010, "assert(" "depth_count++ < K" ") failed", "infinite loop in Node::uncast_helper"
); ::breakpoint(); } } while (0)
;
1011#endif
1012 if (p == NULL__null || p->req() != 2) {
1013 break;
1014 } else if (p->is_ConstraintCast()) {
1015 if (keep_deps && p->as_ConstraintCast()->carry_dependency()) {
1016 break; // stop at casts with dependencies
1017 }
1018 p = p->in(1);
1019 } else {
1020 break;
1021 }
1022 }
1023 return (Node*) p;
1024}
1025
1026//------------------------------add_prec---------------------------------------
1027// Add a new precedence input. Precedence inputs are unordered, with
1028// duplicates removed and NULLs packed down at the end.
1029void Node::add_prec( Node *n ) {
1030 assert( is_not_dead(n), "can not use dead node")do { if (!(((n) == __null || !VerifyIterativeGVN || !((n)->
is_dead())))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 1030, "assert(" "((n) == __null || !VerifyIterativeGVN || !((n)->is_dead()))"
") failed", "can not use dead node"); ::breakpoint(); } } while
(0)
;
1031
1032 // Check for NULL at end
1033 if( _cnt >= _max || in(_max-1) )
1034 grow( _max+1 );
1035
1036 // Find a precedence edge to move
1037 uint i = _cnt;
1038 while( in(i) != NULL__null ) {
1039 if (in(i) == n) return; // Avoid spec violation: duplicated prec edge.
1040 i++;
1041 }
1042 _in[i] = n; // Stuff prec edge over NULL
1043 if ( n != NULL__null) n->add_out((Node *)this); // Add mirror edge
1044
1045#ifdef ASSERT1
1046 while ((++i)<_max) { assert(_in[i] == NULL, "spec violation: Gap in prec edges (node %d)", _idx)do { if (!(_in[i] == __null)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 1046, "assert(" "_in[i] == __null" ") failed", "spec violation: Gap in prec edges (node %d)"
, _idx); ::breakpoint(); } } while (0)
; }
1047#endif
1048}
1049
1050//------------------------------rm_prec----------------------------------------
1051// Remove a precedence input. Precedence inputs are unordered, with
1052// duplicates removed and NULLs packed down at the end.
1053void Node::rm_prec( uint j ) {
1054 assert(j < _max, "oob: i=%d, _max=%d", j, _max)do { if (!(j < _max)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 1054, "assert(" "j < _max" ") failed", "oob: i=%d, _max=%d"
, j, _max); ::breakpoint(); } } while (0)
;
1055 assert(j >= _cnt, "not a precedence edge")do { if (!(j >= _cnt)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 1055, "assert(" "j >= _cnt" ") failed", "not a precedence edge"
); ::breakpoint(); } } while (0)
;
1056 if (_in[j] == NULL__null) return; // Avoid spec violation: Gap in prec edges.
1057 _in[j]->del_out((Node *)this);
1058 close_prec_gap_at(j);
1059}
1060
1061//------------------------------size_of----------------------------------------
1062uint Node::size_of() const { return sizeof(*this); }
1063
1064//------------------------------ideal_reg--------------------------------------
1065uint Node::ideal_reg() const { return 0; }
1066
1067//------------------------------jvms-------------------------------------------
1068JVMState* Node::jvms() const { return NULL__null; }
1069
1070#ifdef ASSERT1
1071//------------------------------jvms-------------------------------------------
1072bool Node::verify_jvms(const JVMState* using_jvms) const {
1073 for (JVMState* jvms = this->jvms(); jvms != NULL__null; jvms = jvms->caller()) {
1074 if (jvms == using_jvms) return true;
1075 }
1076 return false;
1077}
1078
1079//------------------------------init_NodeProperty------------------------------
1080void Node::init_NodeProperty() {
1081 assert(_max_classes <= max_juint, "too many NodeProperty classes")do { if (!(_max_classes <= max_juint)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 1081, "assert(" "_max_classes <= max_juint" ") failed", "too many NodeProperty classes"
); ::breakpoint(); } } while (0)
;
1082 assert(max_flags() <= max_juint, "too many NodeProperty flags")do { if (!(max_flags() <= max_juint)) { (*g_assert_poison)
= 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 1082, "assert(" "max_flags() <= max_juint" ") failed", "too many NodeProperty flags"
); ::breakpoint(); } } while (0)
;
1083}
1084
1085//-----------------------------max_flags---------------------------------------
1086juint Node::max_flags() {
1087 return (PD::_last_flag << 1) - 1; // allow flags combination
1088}
1089#endif
1090
1091//------------------------------format-----------------------------------------
1092// Print as assembly
1093void Node::format( PhaseRegAlloc *, outputStream *st ) const {}
1094//------------------------------emit-------------------------------------------
1095// Emit bytes starting at parameter 'ptr'.
1096void Node::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const {}
1097//------------------------------size-------------------------------------------
1098// Size of instruction in bytes
1099uint Node::size(PhaseRegAlloc *ra_) const { return 0; }
1100
1101//------------------------------CFG Construction-------------------------------
1102// Nodes that end basic blocks, e.g. IfTrue/IfFalse, JumpProjNode, Root,
1103// Goto and Return.
1104const Node *Node::is_block_proj() const { return 0; }
1105
1106// Minimum guaranteed type
1107const Type *Node::bottom_type() const { return Type::BOTTOM; }
1108
1109
1110//------------------------------raise_bottom_type------------------------------
1111// Get the worst-case Type output for this Node.
1112void Node::raise_bottom_type(const Type* new_type) {
1113 if (is_Type()) {
1114 TypeNode *n = this->as_Type();
1115 if (VerifyAliases) {
1116 assert(new_type->higher_equal_speculative(n->type()), "new type must refine old type")do { if (!(new_type->higher_equal_speculative(n->type()
))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 1116, "assert(" "new_type->higher_equal_speculative(n->type())"
") failed", "new type must refine old type"); ::breakpoint()
; } } while (0)
;
1117 }
1118 n->set_type(new_type);
1119 } else if (is_Load()) {
1120 LoadNode *n = this->as_Load();
1121 if (VerifyAliases) {
1122 assert(new_type->higher_equal_speculative(n->type()), "new type must refine old type")do { if (!(new_type->higher_equal_speculative(n->type()
))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 1122, "assert(" "new_type->higher_equal_speculative(n->type())"
") failed", "new type must refine old type"); ::breakpoint()
; } } while (0)
;
1123 }
1124 n->set_type(new_type);
1125 }
1126}
1127
1128//------------------------------Identity---------------------------------------
1129// Return a node that the given node is equivalent to.
1130Node* Node::Identity(PhaseGVN* phase) {
1131 return this; // Default to no identities
1132}
1133
1134//------------------------------Value------------------------------------------
1135// Compute a new Type for a node using the Type of the inputs.
1136const Type* Node::Value(PhaseGVN* phase) const {
1137 return bottom_type(); // Default to worst-case Type
1138}
1139
1140//------------------------------Ideal------------------------------------------
1141//
1142// 'Idealize' the graph rooted at this Node.
1143//
1144// In order to be efficient and flexible there are some subtle invariants
1145// these Ideal calls need to hold. Running with '+VerifyIterativeGVN' checks
1146// these invariants, although its too slow to have on by default. If you are
1147// hacking an Ideal call, be sure to test with +VerifyIterativeGVN!
1148//
1149// The Ideal call almost arbitrarily reshape the graph rooted at the 'this'
1150// pointer. If ANY change is made, it must return the root of the reshaped
1151// graph - even if the root is the same Node. Example: swapping the inputs
1152// to an AddINode gives the same answer and same root, but you still have to
1153// return the 'this' pointer instead of NULL.
1154//
1155// You cannot return an OLD Node, except for the 'this' pointer. Use the
1156// Identity call to return an old Node; basically if Identity can find
1157// another Node have the Ideal call make no change and return NULL.
1158// Example: AddINode::Ideal must check for add of zero; in this case it
1159// returns NULL instead of doing any graph reshaping.
1160//
1161// You cannot modify any old Nodes except for the 'this' pointer. Due to
1162// sharing there may be other users of the old Nodes relying on their current
1163// semantics. Modifying them will break the other users.
1164// Example: when reshape "(X+3)+4" into "X+7" you must leave the Node for
1165// "X+3" unchanged in case it is shared.
1166//
1167// If you modify the 'this' pointer's inputs, you should use
1168// 'set_req'. If you are making a new Node (either as the new root or
1169// some new internal piece) you may use 'init_req' to set the initial
1170// value. You can make a new Node with either 'new' or 'clone'. In
1171// either case, def-use info is correctly maintained.
1172//
1173// Example: reshape "(X+3)+4" into "X+7":
1174// set_req(1, in(1)->in(1));
1175// set_req(2, phase->intcon(7));
1176// return this;
1177// Example: reshape "X*4" into "X<<2"
1178// return new LShiftINode(in(1), phase->intcon(2));
1179//
1180// You must call 'phase->transform(X)' on any new Nodes X you make, except
1181// for the returned root node. Example: reshape "X*31" with "(X<<5)-X".
1182// Node *shift=phase->transform(new LShiftINode(in(1),phase->intcon(5)));
1183// return new AddINode(shift, in(1));
1184//
1185// When making a Node for a constant use 'phase->makecon' or 'phase->intcon'.
1186// These forms are faster than 'phase->transform(new ConNode())' and Do
1187// The Right Thing with def-use info.
1188//
1189// You cannot bury the 'this' Node inside of a graph reshape. If the reshaped
1190// graph uses the 'this' Node it must be the root. If you want a Node with
1191// the same Opcode as the 'this' pointer use 'clone'.
1192//
1193Node *Node::Ideal(PhaseGVN *phase, bool can_reshape) {
1194 return NULL__null; // Default to being Ideal already
1195}
1196
1197// Some nodes have specific Ideal subgraph transformations only if they are
1198// unique users of specific nodes. Such nodes should be put on IGVN worklist
1199// for the transformations to happen.
1200bool Node::has_special_unique_user() const {
1201 assert(outcnt() == 1, "match only for unique out")do { if (!(outcnt() == 1)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 1201, "assert(" "outcnt() == 1" ") failed", "match only for unique out"
); ::breakpoint(); } } while (0)
;
1202 Node* n = unique_out();
1203 int op = Opcode();
1204 if (this->is_Store()) {
1205 // Condition for back-to-back stores folding.
1206 return n->Opcode() == op && n->in(MemNode::Memory) == this;
1207 } else if (this->is_Load() || this->is_DecodeN() || this->is_Phi()) {
1208 // Condition for removing an unused LoadNode or DecodeNNode from the MemBarAcquire precedence input
1209 return n->Opcode() == Op_MemBarAcquire;
1210 } else if (op == Op_AddL) {
1211 // Condition for convL2I(addL(x,y)) ==> addI(convL2I(x),convL2I(y))
1212 return n->Opcode() == Op_ConvL2I && n->in(1) == this;
1213 } else if (op == Op_SubI || op == Op_SubL) {
1214 // Condition for subI(x,subI(y,z)) ==> subI(addI(x,z),y)
1215 return n->Opcode() == op && n->in(2) == this;
1216 } else if (is_If() && (n->is_IfFalse() || n->is_IfTrue())) {
1217 // See IfProjNode::Identity()
1218 return true;
1219 } else {
1220 return false;
1221 }
1222};
1223
1224//--------------------------find_exact_control---------------------------------
1225// Skip Proj and CatchProj nodes chains. Check for Null and Top.
1226Node* Node::find_exact_control(Node* ctrl) {
1227 if (ctrl == NULL__null && this->is_Region())
1228 ctrl = this->as_Region()->is_copy();
1229
1230 if (ctrl != NULL__null && ctrl->is_CatchProj()) {
1231 if (ctrl->as_CatchProj()->_con == CatchProjNode::fall_through_index)
1232 ctrl = ctrl->in(0);
1233 if (ctrl != NULL__null && !ctrl->is_top())
1234 ctrl = ctrl->in(0);
1235 }
1236
1237 if (ctrl != NULL__null && ctrl->is_Proj())
1238 ctrl = ctrl->in(0);
1239
1240 return ctrl;
1241}
1242
1243//--------------------------dominates------------------------------------------
1244// Helper function for MemNode::all_controls_dominate().
1245// Check if 'this' control node dominates or equal to 'sub' control node.
1246// We already know that if any path back to Root or Start reaches 'this',
1247// then all paths so, so this is a simple search for one example,
1248// not an exhaustive search for a counterexample.
1249bool Node::dominates(Node* sub, Node_List &nlist) {
1250 assert(this->is_CFG(), "expecting control")do { if (!(this->is_CFG())) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 1250, "assert(" "this->is_CFG()" ") failed", "expecting control"
); ::breakpoint(); } } while (0)
;
1251 assert(sub != NULL && sub->is_CFG(), "expecting control")do { if (!(sub != __null && sub->is_CFG())) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 1251, "assert(" "sub != __null && sub->is_CFG()"
") failed", "expecting control"); ::breakpoint(); } } while (
0)
;
1252
1253 // detect dead cycle without regions
1254 int iterations_without_region_limit = DominatorSearchLimit;
1255
1256 Node* orig_sub = sub;
1257 Node* dom = this;
1258 bool met_dom = false;
1259 nlist.clear();
1260
1261 // Walk 'sub' backward up the chain to 'dom', watching for regions.
1262 // After seeing 'dom', continue up to Root or Start.
1263 // If we hit a region (backward split point), it may be a loop head.
1264 // Keep going through one of the region's inputs. If we reach the
1265 // same region again, go through a different input. Eventually we
1266 // will either exit through the loop head, or give up.
1267 // (If we get confused, break out and return a conservative 'false'.)
1268 while (sub != NULL__null) {
1269 if (sub->is_top()) break; // Conservative answer for dead code.
1270 if (sub == dom) {
1271 if (nlist.size() == 0) {
1272 // No Region nodes except loops were visited before and the EntryControl
1273 // path was taken for loops: it did not walk in a cycle.
1274 return true;
1275 } else if (met_dom) {
1276 break; // already met before: walk in a cycle
1277 } else {
1278 // Region nodes were visited. Continue walk up to Start or Root
1279 // to make sure that it did not walk in a cycle.
1280 met_dom = true; // first time meet
1281 iterations_without_region_limit = DominatorSearchLimit; // Reset
1282 }
1283 }
1284 if (sub->is_Start() || sub->is_Root()) {
1285 // Success if we met 'dom' along a path to Start or Root.
1286 // We assume there are no alternative paths that avoid 'dom'.
1287 // (This assumption is up to the caller to ensure!)
1288 return met_dom;
1289 }
1290 Node* up = sub->in(0);
1291 // Normalize simple pass-through regions and projections:
1292 up = sub->find_exact_control(up);
1293 // If sub == up, we found a self-loop. Try to push past it.
1294 if (sub == up && sub->is_Loop()) {
1295 // Take loop entry path on the way up to 'dom'.
1296 up = sub->in(1); // in(LoopNode::EntryControl);
1297 } else if (sub == up && sub->is_Region() && sub->req() == 2) {
1298 // Take in(1) path on the way up to 'dom' for regions with only one input
1299 up = sub->in(1);
1300 } else if (sub == up && sub->is_Region() && sub->req() == 3) {
1301 // Try both paths for Regions with 2 input paths (it may be a loop head).
1302 // It could give conservative 'false' answer without information
1303 // which region's input is the entry path.
1304 iterations_without_region_limit = DominatorSearchLimit; // Reset
1305
1306 bool region_was_visited_before = false;
1307 // Was this Region node visited before?
1308 // If so, we have reached it because we accidentally took a
1309 // loop-back edge from 'sub' back into the body of the loop,
1310 // and worked our way up again to the loop header 'sub'.
1311 // So, take the first unexplored path on the way up to 'dom'.
1312 for (int j = nlist.size() - 1; j >= 0; j--) {
1313 intptr_t ni = (intptr_t)nlist.at(j);
1314 Node* visited = (Node*)(ni & ~1);
1315 bool visited_twice_already = ((ni & 1) != 0);
1316 if (visited == sub) {
1317 if (visited_twice_already) {
1318 // Visited 2 paths, but still stuck in loop body. Give up.
1319 return false;
1320 }
1321 // The Region node was visited before only once.
1322 // (We will repush with the low bit set, below.)
1323 nlist.remove(j);
1324 // We will find a new edge and re-insert.
1325 region_was_visited_before = true;
1326 break;
1327 }
1328 }
1329
1330 // Find an incoming edge which has not been seen yet; walk through it.
1331 assert(up == sub, "")do { if (!(up == sub)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 1331, "assert(" "up == sub" ") failed", ""); ::breakpoint()
; } } while (0)
;
1332 uint skip = region_was_visited_before ? 1 : 0;
1333 for (uint i = 1; i < sub->req(); i++) {
1334 Node* in = sub->in(i);
1335 if (in != NULL__null && !in->is_top() && in != sub) {
1336 if (skip == 0) {
1337 up = in;
1338 break;
1339 }
1340 --skip; // skip this nontrivial input
1341 }
1342 }
1343
1344 // Set 0 bit to indicate that both paths were taken.
1345 nlist.push((Node*)((intptr_t)sub + (region_was_visited_before ? 1 : 0)));
1346 }
1347
1348 if (up == sub) {
1349 break; // some kind of tight cycle
1350 }
1351 if (up == orig_sub && met_dom) {
1352 // returned back after visiting 'dom'
1353 break; // some kind of cycle
1354 }
1355 if (--iterations_without_region_limit < 0) {
1356 break; // dead cycle
1357 }
1358 sub = up;
1359 }
1360
1361 // Did not meet Root or Start node in pred. chain.
1362 // Conservative answer for dead code.
1363 return false;
1364}
1365
1366//------------------------------remove_dead_region-----------------------------
1367// This control node is dead. Follow the subgraph below it making everything
1368// using it dead as well. This will happen normally via the usual IterGVN
1369// worklist but this call is more efficient. Do not update use-def info
1370// inside the dead region, just at the borders.
1371static void kill_dead_code( Node *dead, PhaseIterGVN *igvn ) {
1372 // Con's are a popular node to re-hit in the hash table again.
1373 if( dead->is_Con() ) return;
1374
1375 ResourceMark rm;
1376 Node_List nstack;
1377
1378 Node *top = igvn->C->top();
1379 nstack.push(dead);
1380 bool has_irreducible_loop = igvn->C->has_irreducible_loop();
1381
1382 while (nstack.size() > 0) {
1383 dead = nstack.pop();
1384 if (dead->Opcode() == Op_SafePoint) {
1385 dead->as_SafePoint()->disconnect_from_root(igvn);
1386 }
1387 if (dead->outcnt() > 0) {
1388 // Keep dead node on stack until all uses are processed.
1389 nstack.push(dead);
1390 // For all Users of the Dead... ;-)
1391 for (DUIterator_Last kmin, k = dead->last_outs(kmin); k >= kmin; ) {
1392 Node* use = dead->last_out(k);
1393 igvn->hash_delete(use); // Yank from hash table prior to mod
1394 if (use->in(0) == dead) { // Found another dead node
1395 assert (!use->is_Con(), "Control for Con node should be Root node.")do { if (!(!use->is_Con())) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 1395, "assert(" "!use->is_Con()" ") failed", "Control for Con node should be Root node."
); ::breakpoint(); } } while (0)
;
1396 use->set_req(0, top); // Cut dead edge to prevent processing
1397 nstack.push(use); // the dead node again.
1398 } else if (!has_irreducible_loop && // Backedge could be alive in irreducible loop
1399 use->is_Loop() && !use->is_Root() && // Don't kill Root (RootNode extends LoopNode)
1400 use->in(LoopNode::EntryControl) == dead) { // Dead loop if its entry is dead
1401 use->set_req(LoopNode::EntryControl, top); // Cut dead edge to prevent processing
1402 use->set_req(0, top); // Cut self edge
1403 nstack.push(use);
1404 } else { // Else found a not-dead user
1405 // Dead if all inputs are top or null
1406 bool dead_use = !use->is_Root(); // Keep empty graph alive
1407 for (uint j = 1; j < use->req(); j++) {
1408 Node* in = use->in(j);
1409 if (in == dead) { // Turn all dead inputs into TOP
1410 use->set_req(j, top);
1411 } else if (in != NULL__null && !in->is_top()) {
1412 dead_use = false;
1413 }
1414 }
1415 if (dead_use) {
1416 if (use->is_Region()) {
1417 use->set_req(0, top); // Cut self edge
1418 }
1419 nstack.push(use);
1420 } else {
1421 igvn->_worklist.push(use);
1422 }
1423 }
1424 // Refresh the iterator, since any number of kills might have happened.
1425 k = dead->last_outs(kmin);
1426 }
1427 } else { // (dead->outcnt() == 0)
1428 // Done with outputs.
1429 igvn->hash_delete(dead);
1430 igvn->_worklist.remove(dead);
1431 igvn->set_type(dead, Type::TOP);
1432 // Kill all inputs to the dead guy
1433 for (uint i=0; i < dead->req(); i++) {
1434 Node *n = dead->in(i); // Get input to dead guy
1435 if (n != NULL__null && !n->is_top()) { // Input is valid?
1436 dead->set_req(i, top); // Smash input away
1437 if (n->outcnt() == 0) { // Input also goes dead?
1438 if (!n->is_Con())
1439 nstack.push(n); // Clear it out as well
1440 } else if (n->outcnt() == 1 &&
1441 n->has_special_unique_user()) {
1442 igvn->add_users_to_worklist( n );
1443 } else if (n->outcnt() <= 2 && n->is_Store()) {
1444 // Push store's uses on worklist to enable folding optimization for
1445 // store/store and store/load to the same address.
1446 // The restriction (outcnt() <= 2) is the same as in set_req_X()
1447 // and remove_globally_dead_node().
1448 igvn->add_users_to_worklist( n );
1449 } else {
1450 BarrierSet::barrier_set()->barrier_set_c2()->enqueue_useful_gc_barrier(igvn, n);
1451 }
1452 }
1453 }
1454 igvn->C->remove_useless_node(dead);
1455 } // (dead->outcnt() == 0)
1456 } // while (nstack.size() > 0) for outputs
1457 return;
1458}
1459
1460//------------------------------remove_dead_region-----------------------------
1461bool Node::remove_dead_region(PhaseGVN *phase, bool can_reshape) {
1462 Node *n = in(0);
1463 if( !n ) return false;
1464 // Lost control into this guy? I.e., it became unreachable?
1465 // Aggressively kill all unreachable code.
1466 if (can_reshape && n->is_top()) {
1467 kill_dead_code(this, phase->is_IterGVN());
1468 return false; // Node is dead.
1469 }
1470
1471 if( n->is_Region() && n->as_Region()->is_copy() ) {
1472 Node *m = n->nonnull_req();
1473 set_req(0, m);
1474 return true;
1475 }
1476 return false;
1477}
1478
1479//------------------------------hash-------------------------------------------
1480// Hash function over Nodes.
1481uint Node::hash() const {
1482 uint sum = 0;
1483 for( uint i=0; i<_cnt; i++ ) // Add in all inputs
1484 sum = (sum<<1)-(uintptr_t)in(i); // Ignore embedded NULLs
1485 return (sum>>2) + _cnt + Opcode();
1486}
1487
1488//------------------------------cmp--------------------------------------------
1489// Compare special parts of simple Nodes
1490bool Node::cmp( const Node &n ) const {
1491 return true; // Must be same
1492}
1493
1494//------------------------------rematerialize-----------------------------------
1495// Should we clone rather than spill this instruction?
1496bool Node::rematerialize() const {
1497 if ( is_Mach() )
1498 return this->as_Mach()->rematerialize();
1499 else
1500 return (_flags & Flag_rematerialize) != 0;
1501}
1502
1503//------------------------------needs_anti_dependence_check---------------------
1504// Nodes which use memory without consuming it, hence need antidependences.
1505bool Node::needs_anti_dependence_check() const {
1506 if (req() < 2 || (_flags & Flag_needs_anti_dependence_check) == 0) {
1507 return false;
1508 }
1509 return in(1)->bottom_type()->has_memory();
1510}
1511
1512// Get an integer constant from a ConNode (or CastIINode).
1513// Return a default value if there is no apparent constant here.
1514const TypeInt* Node::find_int_type() const {
1515 if (this->is_Type()) {
1516 return this->as_Type()->type()->isa_int();
1517 } else if (this->is_Con()) {
1518 assert(is_Mach(), "should be ConNode(TypeNode) or else a MachNode")do { if (!(is_Mach())) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 1518, "assert(" "is_Mach()" ") failed", "should be ConNode(TypeNode) or else a MachNode"
); ::breakpoint(); } } while (0)
;
1519 return this->bottom_type()->isa_int();
1520 }
1521 return NULL__null;
1522}
1523
1524const TypeInteger* Node::find_integer_type(BasicType bt) const {
1525 if (this->is_Type()) {
1526 return this->as_Type()->type()->isa_integer(bt);
1527 } else if (this->is_Con()) {
1528 assert(is_Mach(), "should be ConNode(TypeNode) or else a MachNode")do { if (!(is_Mach())) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 1528, "assert(" "is_Mach()" ") failed", "should be ConNode(TypeNode) or else a MachNode"
); ::breakpoint(); } } while (0)
;
1529 return this->bottom_type()->isa_integer(bt);
1530 }
1531 return NULL__null;
1532}
1533
1534// Get a pointer constant from a ConstNode.
1535// Returns the constant if it is a pointer ConstNode
1536intptr_t Node::get_ptr() const {
1537 assert( Opcode() == Op_ConP, "" )do { if (!(Opcode() == Op_ConP)) { (*g_assert_poison) = 'X';;
report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 1537, "assert(" "Opcode() == Op_ConP" ") failed", ""); ::breakpoint
(); } } while (0)
;
1538 return ((ConPNode*)this)->type()->is_ptr()->get_con();
1539}
1540
1541// Get a narrow oop constant from a ConNNode.
1542intptr_t Node::get_narrowcon() const {
1543 assert( Opcode() == Op_ConN, "" )do { if (!(Opcode() == Op_ConN)) { (*g_assert_poison) = 'X';;
report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 1543, "assert(" "Opcode() == Op_ConN" ") failed", ""); ::breakpoint
(); } } while (0)
;
1544 return ((ConNNode*)this)->type()->is_narrowoop()->get_con();
1545}
1546
1547// Get a long constant from a ConNode.
1548// Return a default value if there is no apparent constant here.
1549const TypeLong* Node::find_long_type() const {
1550 if (this->is_Type()) {
1551 return this->as_Type()->type()->isa_long();
1552 } else if (this->is_Con()) {
1553 assert(is_Mach(), "should be ConNode(TypeNode) or else a MachNode")do { if (!(is_Mach())) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 1553, "assert(" "is_Mach()" ") failed", "should be ConNode(TypeNode) or else a MachNode"
); ::breakpoint(); } } while (0)
;
1554 return this->bottom_type()->isa_long();
1555 }
1556 return NULL__null;
1557}
1558
1559
1560/**
1561 * Return a ptr type for nodes which should have it.
1562 */
1563const TypePtr* Node::get_ptr_type() const {
1564 const TypePtr* tp = this->bottom_type()->make_ptr();
1565#ifdef ASSERT1
1566 if (tp == NULL__null) {
1567 this->dump(1);
1568 assert((tp != NULL), "unexpected node type")do { if (!((tp != __null))) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 1568, "assert(" "(tp != __null)" ") failed", "unexpected node type"
); ::breakpoint(); } } while (0)
;
1569 }
1570#endif
1571 return tp;
1572}
1573
1574// Get a double constant from a ConstNode.
1575// Returns the constant if it is a double ConstNode
1576jdouble Node::getd() const {
1577 assert( Opcode() == Op_ConD, "" )do { if (!(Opcode() == Op_ConD)) { (*g_assert_poison) = 'X';;
report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 1577, "assert(" "Opcode() == Op_ConD" ") failed", ""); ::breakpoint
(); } } while (0)
;
1578 return ((ConDNode*)this)->type()->is_double_constant()->getd();
1579}
1580
1581// Get a float constant from a ConstNode.
1582// Returns the constant if it is a float ConstNode
1583jfloat Node::getf() const {
1584 assert( Opcode() == Op_ConF, "" )do { if (!(Opcode() == Op_ConF)) { (*g_assert_poison) = 'X';;
report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 1584, "assert(" "Opcode() == Op_ConF" ") failed", ""); ::breakpoint
(); } } while (0)
;
1585 return ((ConFNode*)this)->type()->is_float_constant()->getf();
1586}
1587
1588#ifndef PRODUCT
1589
1590// Call this from debugger:
1591Node* find_node(Node* n, const int idx) {
1592 return n->find(idx);
1593}
1594
1595// Call this from debugger with root node as default:
1596Node* find_node(const int idx) {
1597 return Compile::current()->root()->find(idx);
1598}
1599
1600// Call this from debugger:
1601Node* find_ctrl(Node* n, const int idx) {
1602 return n->find_ctrl(idx);
1603}
1604
1605// Call this from debugger with root node as default:
1606Node* find_ctrl(const int idx) {
1607 return Compile::current()->root()->find_ctrl(idx);
1608}
1609
1610//------------------------------find_ctrl--------------------------------------
1611// Find an ancestor to this node in the control history with given _idx
1612Node* Node::find_ctrl(int idx) {
1613 return find(idx, true);
1614}
1615
1616//------------------------------find-------------------------------------------
1617// Tries to find the node with the index |idx| starting from this node. If idx is negative,
1618// the search also includes forward (out) edges. Returns NULL if not found.
1619// If only_ctrl is set, the search will only be done on control nodes. Returns NULL if
1620// not found or if the node to be found is not a control node (search will not find it).
1621Node* Node::find(const int idx, bool only_ctrl) {
1622 ResourceMark rm;
1623 VectorSet old_space;
1624 VectorSet new_space;
1625 Node_List worklist;
1626 Arena* old_arena = Compile::current()->old_arena();
1627 add_to_worklist(this, &worklist, old_arena, &old_space, &new_space);
1628 Node* result = NULL__null;
1629 int node_idx = (idx >= 0) ? idx : -idx;
1630
1631 for (uint list_index = 0; list_index < worklist.size(); list_index++) {
1632 Node* n = worklist[list_index];
1633
1634 if ((int)n->_idx == node_idx debug_only(|| n->debug_idx() == node_idx)|| n->debug_idx() == node_idx) {
1635 if (result != NULL__null) {
1636 tty->print("find: " INTPTR_FORMAT"0x%016" "l" "x" " and " INTPTR_FORMAT"0x%016" "l" "x" " both have idx==%d\n",
1637 (uintptr_t)result, (uintptr_t)n, node_idx);
1638 }
1639 result = n;
1640 }
1641
1642 for (uint i = 0; i < n->len(); i++) {
1643 if (!only_ctrl || n->is_Region() || (n->Opcode() == Op_Root) || (i == TypeFunc::Control)) {
1644 // If only_ctrl is set: Add regions, the root node, or control inputs only
1645 add_to_worklist(n->in(i), &worklist, old_arena, &old_space, &new_space);
1646 }
1647 }
1648
1649 // Also search along forward edges if idx is negative and the search is not done on control nodes only
1650 if (idx < 0 && !only_ctrl) {
1651 for (uint i = 0; i < n->outcnt(); i++) {
1652 add_to_worklist(n->raw_out(i), &worklist, old_arena, &old_space, &new_space);
1653 }
1654 }
1655#ifdef ASSERT1
1656 // Search along debug_orig edges last
1657 Node* orig = n->debug_orig();
1658 while (orig != NULL__null && add_to_worklist(orig, &worklist, old_arena, &old_space, &new_space)) {
1659 orig = orig->debug_orig();
1660 }
1661#endif // ASSERT
1662 }
1663 return result;
1664}
1665
1666bool Node::add_to_worklist(Node* n, Node_List* worklist, Arena* old_arena, VectorSet* old_space, VectorSet* new_space) {
1667 if (not_a_node(n)) {
1668 return false; // Gracefully handle NULL, -1, 0xabababab, etc.
1669 }
1670
1671 // Contained in new_space or old_space? Check old_arena first since it's mostly empty.
1672 VectorSet* v = old_arena->contains(n) ? old_space : new_space;
1673 if (!v->test_set(n->_idx)) {
1674 worklist->push(n);
1675 return true;
1676 }
1677 return false;
1678}
1679
1680// -----------------------------Name-------------------------------------------
1681extern const char *NodeClassNames[];
1682const char *Node::Name() const { return NodeClassNames[Opcode()]; }
1683
1684static bool is_disconnected(const Node* n) {
1685 for (uint i = 0; i < n->req(); i++) {
1686 if (n->in(i) != NULL__null) return false;
1687 }
1688 return true;
1689}
1690
1691#ifdef ASSERT1
1692void Node::dump_orig(outputStream *st, bool print_key) const {
1693 Compile* C = Compile::current();
1694 Node* orig = _debug_orig;
1695 if (not_a_node(orig)) orig = NULL__null;
1696 if (orig != NULL__null && !C->node_arena()->contains(orig)) orig = NULL__null;
1697 if (orig == NULL__null) return;
1698 if (print_key) {
1699 st->print(" !orig=");
1700 }
1701 Node* fast = orig->debug_orig(); // tortoise & hare algorithm to detect loops
1702 if (not_a_node(fast)) fast = NULL__null;
1703 while (orig != NULL__null) {
1704 bool discon = is_disconnected(orig); // if discon, print [123] else 123
1705 if (discon) st->print("[");
1706 if (!Compile::current()->node_arena()->contains(orig))
1707 st->print("o");
1708 st->print("%d", orig->_idx);
1709 if (discon) st->print("]");
1710 orig = orig->debug_orig();
1711 if (not_a_node(orig)) orig = NULL__null;
1712 if (orig != NULL__null && !C->node_arena()->contains(orig)) orig = NULL__null;
1713 if (orig != NULL__null) st->print(",");
1714 if (fast != NULL__null) {
1715 // Step fast twice for each single step of orig:
1716 fast = fast->debug_orig();
1717 if (not_a_node(fast)) fast = NULL__null;
1718 if (fast != NULL__null && fast != orig) {
1719 fast = fast->debug_orig();
1720 if (not_a_node(fast)) fast = NULL__null;
1721 }
1722 if (fast == orig) {
1723 st->print("...");
1724 break;
1725 }
1726 }
1727 }
1728}
1729
1730void Node::set_debug_orig(Node* orig) {
1731 _debug_orig = orig;
1732 if (BreakAtNode == 0) return;
1733 if (not_a_node(orig)) orig = NULL__null;
1734 int trip = 10;
1735 while (orig != NULL__null) {
1736 if (orig->debug_idx() == BreakAtNode || (int)orig->_idx == BreakAtNode) {
1737 tty->print_cr("BreakAtNode: _idx=%d _debug_idx=%d orig._idx=%d orig._debug_idx=%d",
1738 this->_idx, this->debug_idx(), orig->_idx, orig->debug_idx());
1739 BREAKPOINT::breakpoint();
1740 }
1741 orig = orig->debug_orig();
1742 if (not_a_node(orig)) orig = NULL__null;
1743 if (trip-- <= 0) break;
1744 }
1745}
1746#endif //ASSERT
1747
1748//------------------------------dump------------------------------------------
1749// Dump a Node
1750void Node::dump(const char* suffix, bool mark, outputStream *st) const {
1751 Compile* C = Compile::current();
1752 bool is_new = C->node_arena()->contains(this);
1753 C->_in_dump_cnt++;
1754
1755 if (_indent > 0) {
12
Assuming field '_indent' is <= 0
13
Taking false branch
1756 st->print("%*s", (_indent << 1), " ");
1757 }
1758
1759 st->print("%c%d%s%s === ", is_new ? ' ' : 'o', _idx, mark
15.1
'mark' is false
15.1
'mark' is false
? " >" : " ", Name());
14
Assuming 'is_new' is false
15
'?' condition is false
16
'?' condition is false
1760
1761 // Dump the required and precedence inputs
1762 dump_req(st);
1763 dump_prec(st);
1764 // Dump the outputs
1765 dump_out(st);
1766
1767 if (is_disconnected(this)) {
17
Assuming the condition is false
18
Taking false branch
1768#ifdef ASSERT1
1769 st->print(" [%d]",debug_idx());
1770 dump_orig(st);
1771#endif
1772 st->cr();
1773 C->_in_dump_cnt--;
1774 return; // don't process dead nodes
1775 }
1776
1777 if (C->clone_map().value(_idx) != 0) {
19
Assuming the condition is false
20
Taking false branch
1778 C->clone_map().dump(_idx);
1779 }
1780 // Dump node-specific info
1781 dump_spec(st);
1782#ifdef ASSERT1
1783 // Dump the non-reset _debug_idx
1784 if (Verbose && WizardMode) {
21
Assuming 'Verbose' is false
1785 st->print(" [%d]",debug_idx());
1786 }
1787#endif
1788
1789 const Type *t = bottom_type();
22
't' initialized here
1790
1791 if (t != NULL__null && (t->isa_instptr() || t->isa_klassptr())) {
23
Assuming 't' is equal to NULL
24
Assuming pointer value is null
1792 const TypeInstPtr *toop = t->isa_instptr();
1793 const TypeKlassPtr *tkls = t->isa_klassptr();
1794 ciKlass* klass = toop ? toop->klass() : (tkls ? tkls->klass() : NULL__null );
1795 if (klass && klass->is_loaded() && klass->is_interface()) {
1796 st->print(" Interface:");
1797 } else if (toop) {
1798 st->print(" Oop:");
1799 } else if (tkls) {
1800 st->print(" Klass:");
1801 }
1802 t->dump_on(st);
1803 } else if (t == Type::MEMORY) {
25
Assuming 't' is not equal to 'MEMORY'
26
Taking false branch
1804 st->print(" Memory:");
1805 MemNode::dump_adr_type(this, adr_type(), st);
1806 } else if (Verbose || WizardMode) {
27
Assuming 'Verbose' is false
28
Assuming 'WizardMode' is false
29
Taking false branch
1807 st->print(" Type:");
1808 if (t) {
1809 t->dump_on(st);
1810 } else {
1811 st->print("no type");
1812 }
1813 } else if (t->isa_vect() && this->is_MachSpillCopy()) {
30
Called C++ object pointer is null
1814 // Dump MachSpillcopy vector type.
1815 t->dump_on(st);
1816 }
1817 if (is_new) {
1818 DEBUG_ONLY(dump_orig(st))dump_orig(st);
1819 Node_Notes* nn = C->node_notes_at(_idx);
1820 if (nn != NULL__null && !nn->is_clear()) {
1821 if (nn->jvms() != NULL__null) {
1822 st->print(" !jvms:");
1823 nn->jvms()->dump_spec(st);
1824 }
1825 }
1826 }
1827 if (suffix) st->print("%s", suffix);
1828 C->_in_dump_cnt--;
1829}
1830
1831//------------------------------dump_req--------------------------------------
1832void Node::dump_req(outputStream *st) const {
1833 // Dump the required input edges
1834 for (uint i = 0; i < req(); i++) { // For all required inputs
1835 Node* d = in(i);
1836 if (d == NULL__null) {
1837 st->print("_ ");
1838 } else if (not_a_node(d)) {
1839 st->print("not_a_node "); // uninitialized, sentinel, garbage, etc.
1840 } else {
1841 st->print("%c%d ", Compile::current()->node_arena()->contains(d) ? ' ' : 'o', d->_idx);
1842 }
1843 }
1844}
1845
1846
1847//------------------------------dump_prec-------------------------------------
1848void Node::dump_prec(outputStream *st) const {
1849 // Dump the precedence edges
1850 int any_prec = 0;
1851 for (uint i = req(); i < len(); i++) { // For all precedence inputs
1852 Node* p = in(i);
1853 if (p != NULL__null) {
1854 if (!any_prec++) st->print(" |");
1855 if (not_a_node(p)) { st->print("not_a_node "); continue; }
1856 st->print("%c%d ", Compile::current()->node_arena()->contains(in(i)) ? ' ' : 'o', in(i)->_idx);
1857 }
1858 }
1859}
1860
1861//------------------------------dump_out--------------------------------------
1862void Node::dump_out(outputStream *st) const {
1863 // Delimit the output edges
1864 st->print(" [[");
1865 // Dump the output edges
1866 for (uint i = 0; i < _outcnt; i++) { // For all outputs
1867 Node* u = _out[i];
1868 if (u == NULL__null) {
1869 st->print("_ ");
1870 } else if (not_a_node(u)) {
1871 st->print("not_a_node ");
1872 } else {
1873 st->print("%c%d ", Compile::current()->node_arena()->contains(u) ? ' ' : 'o', u->_idx);
1874 }
1875 }
1876 st->print("]] ");
1877}
1878
1879//----------------------------collect_nodes_i----------------------------------
1880// Collects nodes from an Ideal graph, starting from a given start node and
1881// moving in a given direction until a certain depth (distance from the start
1882// node) is reached. Duplicates are ignored.
1883// Arguments:
1884// queue: the nodes are collected into this array.
1885// start: the node at which to start collecting.
1886// direction: if this is a positive number, collect input nodes; if it is
1887// a negative number, collect output nodes.
1888// depth: collect nodes up to this distance from the start node.
1889// include_start: whether to include the start node in the result collection.
1890// only_ctrl: whether to regard control edges only during traversal.
1891// only_data: whether to regard data edges only during traversal.
1892static void collect_nodes_i(GrowableArray<Node*>* queue, const Node* start, int direction, uint depth, bool include_start, bool only_ctrl, bool only_data) {
1893 bool indent = depth <= PrintIdealIndentThreshold;
1894 Node* s = (Node*) start; // remove const
1895 queue->append(s);
1896 int begin = 0;
1897 int end = 0;
1898
1899 s->set_indent(0);
1900 for(uint i = 0; i < depth; i++) {
1901 end = queue->length();
1902 for(int j = begin; j < end; j++) {
1903 Node* tp = queue->at(j);
1904 uint limit = direction > 0 ? tp->len() : tp->outcnt();
1905 for(uint k = 0; k < limit; k++) {
1906 Node* n = direction > 0 ? tp->in(k) : tp->raw_out(k);
1907
1908 if (not_a_node(n)) continue;
1909 // do not recurse through top or the root (would reach unrelated stuff)
1910 if (n->is_Root() || n->is_top()) continue;
1911 if (only_ctrl && !n->is_CFG()) continue;
1912 if (only_data && n->is_CFG()) continue;
1913 bool in_queue = queue->contains(n);
1914 if (!in_queue) {
1915 queue->append(n);
1916 n->set_indent(indent ? (i + 1) : 0);
1917 }
1918 }
1919 }
1920 begin = end;
1921 }
1922 if (!include_start) {
1923 queue->remove(s);
1924 }
1925}
1926
1927//------------------------------dump_nodes-------------------------------------
1928static void dump_nodes(const Node* start, int d, bool only_ctrl) {
1929 if (not_a_node(start)) return;
1930
1931 GrowableArray <Node *> queue(Compile::current()->live_nodes());
1932 collect_nodes_i(&queue, start, d, (uint) ABS(d), true, only_ctrl, false);
1933
1934 int end = queue.length();
1935 if (d > 0) {
1936 for(int j = end-1; j >= 0; j--) {
1937 queue.at(j)->dump();
1938 }
1939 } else {
1940 for(int j = 0; j < end; j++) {
1941 queue.at(j)->dump();
1942 }
1943 }
1944}
1945
1946//------------------------------dump-------------------------------------------
1947void Node::dump(int d) const {
1948 dump_nodes(this, d, false);
1949}
1950
1951//------------------------------dump_ctrl--------------------------------------
1952// Dump a Node's control history to depth
1953void Node::dump_ctrl(int d) const {
1954 dump_nodes(this, d, true);
1955}
1956
1957//-----------------------------dump_compact------------------------------------
1958void Node::dump_comp() const {
1959 this->dump_comp("\n");
1960}
1961
1962//-----------------------------dump_compact------------------------------------
1963// Dump a Node in compact representation, i.e., just print its name and index.
1964// Nodes can specify additional specifics to print in compact representation by
1965// implementing dump_compact_spec.
1966void Node::dump_comp(const char* suffix, outputStream *st) const {
1967 Compile* C = Compile::current();
1968 C->_in_dump_cnt++;
1969 st->print("%s(%d)", Name(), _idx);
1970 this->dump_compact_spec(st);
1971 if (suffix) {
1972 st->print("%s", suffix);
1973 }
1974 C->_in_dump_cnt--;
1975}
1976
1977//----------------------------dump_related-------------------------------------
1978// Dump a Node's related nodes - the notion of "related" depends on the Node at
1979// hand and is determined by the implementation of the virtual method rel.
1980void Node::dump_related() const {
1981 Compile* C = Compile::current();
1982 GrowableArray <Node *> in_rel(C->unique());
1983 GrowableArray <Node *> out_rel(C->unique());
1984 this->related(&in_rel, &out_rel, false);
1985 for (int i = in_rel.length() - 1; i >= 0; i--) {
1986 in_rel.at(i)->dump();
1987 }
1988 this->dump("\n", true);
1989 for (int i = 0; i < out_rel.length(); i++) {
1990 out_rel.at(i)->dump();
1991 }
1992}
1993
1994//----------------------------dump_related-------------------------------------
1995// Dump a Node's related nodes up to a given depth (distance from the start
1996// node).
1997// Arguments:
1998// d_in: depth for input nodes.
1999// d_out: depth for output nodes (note: this also is a positive number).
2000void Node::dump_related(uint d_in, uint d_out) const {
2001 Compile* C = Compile::current();
2002 GrowableArray <Node *> in_rel(C->unique());
2003 GrowableArray <Node *> out_rel(C->unique());
2004
2005 // call collect_nodes_i directly
2006 collect_nodes_i(&in_rel, this, 1, d_in, false, false, false);
2007 collect_nodes_i(&out_rel, this, -1, d_out, false, false, false);
2008
2009 for (int i = in_rel.length() - 1; i >= 0; i--) {
2010 in_rel.at(i)->dump();
2011 }
2012 this->dump("\n", true);
2013 for (int i = 0; i < out_rel.length(); i++) {
2014 out_rel.at(i)->dump();
2015 }
2016}
2017
2018//------------------------dump_related_compact---------------------------------
2019// Dump a Node's related nodes in compact representation. The notion of
2020// "related" depends on the Node at hand and is determined by the implementation
2021// of the virtual method rel.
2022void Node::dump_related_compact() const {
2023 Compile* C = Compile::current();
2024 GrowableArray <Node *> in_rel(C->unique());
2025 GrowableArray <Node *> out_rel(C->unique());
2026 this->related(&in_rel, &out_rel, true);
2027 int n_in = in_rel.length();
2028 int n_out = out_rel.length();
2029
2030 this->dump_comp(n_in == 0 ? "\n" : " ");
2031 for (int i = 0; i < n_in; i++) {
2032 in_rel.at(i)->dump_comp(i == n_in - 1 ? "\n" : " ");
2033 }
2034 for (int i = 0; i < n_out; i++) {
2035 out_rel.at(i)->dump_comp(i == n_out - 1 ? "\n" : " ");
2036 }
2037}
2038
2039//------------------------------related----------------------------------------
2040// Collect a Node's related nodes. The default behaviour just collects the
2041// inputs and outputs at depth 1, including both control and data flow edges,
2042// regardless of whether the presentation is compact or not. For data nodes,
2043// the default is to collect all data inputs (till level 1 if compact), and
2044// outputs till level 1.
2045void Node::related(GrowableArray<Node*> *in_rel, GrowableArray<Node*> *out_rel, bool compact) const {
2046 if (this->is_CFG()) {
2047 collect_nodes_i(in_rel, this, 1, 1, false, false, false);
2048 collect_nodes_i(out_rel, this, -1, 1, false, false, false);
2049 } else {
2050 if (compact) {
2051 this->collect_nodes(in_rel, 1, false, true);
2052 } else {
2053 this->collect_nodes_in_all_data(in_rel, false);
2054 }
2055 this->collect_nodes(out_rel, -1, false, false);
2056 }
2057}
2058
2059//---------------------------collect_nodes-------------------------------------
2060// An entry point to the low-level node collection facility, to start from a
2061// given node in the graph. The start node is by default not included in the
2062// result.
2063// Arguments:
2064// ns: collect the nodes into this data structure.
2065// d: the depth (distance from start node) to which nodes should be
2066// collected. A value >0 indicates input nodes, a value <0, output
2067// nodes.
2068// ctrl: include only control nodes.
2069// data: include only data nodes.
2070void Node::collect_nodes(GrowableArray<Node*> *ns, int d, bool ctrl, bool data) const {
2071 if (ctrl && data) {
2072 // ignore nonsensical combination
2073 return;
2074 }
2075 collect_nodes_i(ns, this, d, (uint) ABS(d), false, ctrl, data);
2076}
2077
2078//--------------------------collect_nodes_in-----------------------------------
2079static void collect_nodes_in(Node* start, GrowableArray<Node*> *ns, bool primary_is_data, bool collect_secondary) {
2080 // The maximum depth is determined using a BFS that visits all primary (data
2081 // or control) inputs and increments the depth at each level.
2082 uint d_in = 0;
2083 GrowableArray<Node*> nodes(Compile::current()->unique());
2084 nodes.push(start);
2085 int nodes_at_current_level = 1;
2086 int n_idx = 0;
2087 while (nodes_at_current_level > 0) {
2088 // Add all primary inputs reachable from the current level to the list, and
2089 // increase the depth if there were any.
2090 int nodes_at_next_level = 0;
2091 bool nodes_added = false;
2092 while (nodes_at_current_level > 0) {
2093 nodes_at_current_level--;
2094 Node* current = nodes.at(n_idx++);
2095 for (uint i = 0; i < current->len(); i++) {
2096 Node* n = current->in(i);
2097 if (not_a_node(n)) {
2098 continue;
2099 }
2100 if ((primary_is_data && n->is_CFG()) || (!primary_is_data && !n->is_CFG())) {
2101 continue;
2102 }
2103 if (!nodes.contains(n)) {
2104 nodes.push(n);
2105 nodes_added = true;
2106 nodes_at_next_level++;
2107 }
2108 }
2109 }
2110 if (nodes_added) {
2111 d_in++;
2112 }
2113 nodes_at_current_level = nodes_at_next_level;
2114 }
2115 start->collect_nodes(ns, d_in, !primary_is_data, primary_is_data);
2116 if (collect_secondary) {
2117 // Now, iterate over the secondary nodes in ns and add the respective
2118 // boundary reachable from them.
2119 GrowableArray<Node*> sns(Compile::current()->unique());
2120 for (GrowableArrayIterator<Node*> it = ns->begin(); it != ns->end(); ++it) {
2121 Node* n = *it;
2122 n->collect_nodes(&sns, 1, primary_is_data, !primary_is_data);
2123 for (GrowableArrayIterator<Node*> d = sns.begin(); d != sns.end(); ++d) {
2124 ns->append_if_missing(*d);
2125 }
2126 sns.clear();
2127 }
2128 }
2129}
2130
2131//---------------------collect_nodes_in_all_data-------------------------------
2132// Collect the entire data input graph. Include the control boundary if
2133// requested.
2134// Arguments:
2135// ns: collect the nodes into this data structure.
2136// ctrl: if true, include the control boundary.
2137void Node::collect_nodes_in_all_data(GrowableArray<Node*> *ns, bool ctrl) const {
2138 collect_nodes_in((Node*) this, ns, true, ctrl);
2139}
2140
2141//--------------------------collect_nodes_in_all_ctrl--------------------------
2142// Collect the entire control input graph. Include the data boundary if
2143// requested.
2144// ns: collect the nodes into this data structure.
2145// data: if true, include the control boundary.
2146void Node::collect_nodes_in_all_ctrl(GrowableArray<Node*> *ns, bool data) const {
2147 collect_nodes_in((Node*) this, ns, false, data);
2148}
2149
2150//------------------collect_nodes_out_all_ctrl_boundary------------------------
2151// Collect the entire output graph until hitting control node boundaries, and
2152// include those.
2153void Node::collect_nodes_out_all_ctrl_boundary(GrowableArray<Node*> *ns) const {
2154 // Perform a BFS and stop at control nodes.
2155 GrowableArray<Node*> nodes(Compile::current()->unique());
2156 nodes.push((Node*) this);
2157 while (nodes.length() > 0) {
2158 Node* current = nodes.pop();
2159 if (not_a_node(current)) {
2160 continue;
2161 }
2162 ns->append_if_missing(current);
2163 if (!current->is_CFG()) {
2164 for (DUIterator i = current->outs(); current->has_out(i); i++) {
2165 nodes.push(current->out(i));
2166 }
2167 }
2168 }
2169 ns->remove((Node*) this);
2170}
2171
2172// VERIFICATION CODE
2173// For each input edge to a node (ie - for each Use-Def edge), verify that
2174// there is a corresponding Def-Use edge.
2175//------------------------------verify_edges-----------------------------------
2176void Node::verify_edges(Unique_Node_List &visited) {
2177 uint i, j, idx;
2178 int cnt;
2179 Node *n;
2180
2181 // Recursive termination test
2182 if (visited.member(this)) return;
2183 visited.push(this);
2184
2185 // Walk over all input edges, checking for correspondence
2186 for( i = 0; i < len(); i++ ) {
2187 n = in(i);
2188 if (n != NULL__null && !n->is_top()) {
2189 // Count instances of (Node *)this
2190 cnt = 0;
2191 for (idx = 0; idx < n->_outcnt; idx++ ) {
2192 if (n->_out[idx] == (Node *)this) cnt++;
2193 }
2194 assert( cnt > 0,"Failed to find Def-Use edge." )do { if (!(cnt > 0)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 2194, "assert(" "cnt > 0" ") failed", "Failed to find Def-Use edge."
); ::breakpoint(); } } while (0)
;
2195 // Check for duplicate edges
2196 // walk the input array downcounting the input edges to n
2197 for( j = 0; j < len(); j++ ) {
2198 if( in(j) == n ) cnt--;
2199 }
2200 assert( cnt == 0,"Mismatched edge count.")do { if (!(cnt == 0)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 2200, "assert(" "cnt == 0" ") failed", "Mismatched edge count."
); ::breakpoint(); } } while (0)
;
2201 } else if (n == NULL__null) {
2202 assert(i >= req() || i == 0 || is_Region() || is_Phi() || is_ArrayCopy() || (is_Unlock() && i == req()-1)do { if (!(i >= req() || i == 0 || is_Region() || is_Phi()
|| is_ArrayCopy() || (is_Unlock() && i == req()-1) ||
(is_MemBar() && i == 5))) { (*g_assert_poison) = 'X'
;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 2204, "assert(" "i >= req() || i == 0 || is_Region() || is_Phi() || is_ArrayCopy() || (is_Unlock() && i == req()-1) || (is_MemBar() && i == 5)"
") failed", "only region, phi, arraycopy, unlock or membar nodes have null data edges"
); ::breakpoint(); } } while (0)
2203 || (is_MemBar() && i == 5), // the precedence edge to a membar can be removed during macro node expansiondo { if (!(i >= req() || i == 0 || is_Region() || is_Phi()
|| is_ArrayCopy() || (is_Unlock() && i == req()-1) ||
(is_MemBar() && i == 5))) { (*g_assert_poison) = 'X'
;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 2204, "assert(" "i >= req() || i == 0 || is_Region() || is_Phi() || is_ArrayCopy() || (is_Unlock() && i == req()-1) || (is_MemBar() && i == 5)"
") failed", "only region, phi, arraycopy, unlock or membar nodes have null data edges"
); ::breakpoint(); } } while (0)
2204 "only region, phi, arraycopy, unlock or membar nodes have null data edges")do { if (!(i >= req() || i == 0 || is_Region() || is_Phi()
|| is_ArrayCopy() || (is_Unlock() && i == req()-1) ||
(is_MemBar() && i == 5))) { (*g_assert_poison) = 'X'
;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 2204, "assert(" "i >= req() || i == 0 || is_Region() || is_Phi() || is_ArrayCopy() || (is_Unlock() && i == req()-1) || (is_MemBar() && i == 5)"
") failed", "only region, phi, arraycopy, unlock or membar nodes have null data edges"
); ::breakpoint(); } } while (0)
;
2205 } else {
2206 assert(n->is_top(), "sanity")do { if (!(n->is_top())) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 2206, "assert(" "n->is_top()" ") failed", "sanity"); ::breakpoint
(); } } while (0)
;
2207 // Nothing to check.
2208 }
2209 }
2210 // Recursive walk over all input edges
2211 for( i = 0; i < len(); i++ ) {
2212 n = in(i);
2213 if( n != NULL__null )
2214 in(i)->verify_edges(visited);
2215 }
2216}
2217
2218// Verify all nodes if verify_depth is negative
2219void Node::verify(int verify_depth, VectorSet& visited, Node_List& worklist) {
2220 assert(verify_depth != 0, "depth should not be 0")do { if (!(verify_depth != 0)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 2220, "assert(" "verify_depth != 0" ") failed", "depth should not be 0"
); ::breakpoint(); } } while (0)
;
2221 Compile* C = Compile::current();
2222 uint last_index_on_current_depth = worklist.size() - 1;
2223 verify_depth--; // Visiting the first node on depth 1
2224 // Only add nodes to worklist if verify_depth is negative (visit all nodes) or greater than 0
2225 bool add_to_worklist = verify_depth != 0;
2226
2227 for (uint list_index = 0; list_index < worklist.size(); list_index++) {
2228 Node* n = worklist[list_index];
2229
2230 if (n->is_Con() && n->bottom_type() == Type::TOP) {
2231 if (C->cached_top_node() == NULL__null) {
2232 C->set_cached_top_node((Node*)n);
2233 }
2234 assert(C->cached_top_node() == n, "TOP node must be unique")do { if (!(C->cached_top_node() == n)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 2234, "assert(" "C->cached_top_node() == n" ") failed", "TOP node must be unique"
); ::breakpoint(); } } while (0)
;
2235 }
2236
2237 uint in_len = n->len();
2238 for (uint i = 0; i < in_len; i++) {
2239 Node* x = n->_in[i];
2240 if (!x || x->is_top()) {
2241 continue;
2242 }
2243
2244 // Verify my input has a def-use edge to me
2245 // Count use-def edges from n to x
2246 int cnt = 1;
2247 for (uint j = 0; j < i; j++) {
2248 if (n->_in[j] == x) {
2249 cnt++;
2250 break;
2251 }
2252 }
2253 if (cnt == 2) {
2254 // x is already checked as n's previous input, skip its duplicated def-use count checking
2255 continue;
2256 }
2257 for (uint j = i + 1; j < in_len; j++) {
2258 if (n->_in[j] == x) {
2259 cnt++;
2260 }
2261 }
2262
2263 // Count def-use edges from x to n
2264 uint max = x->_outcnt;
2265 for (uint k = 0; k < max; k++) {
2266 if (x->_out[k] == n) {
2267 cnt--;
2268 }
2269 }
2270 assert(cnt == 0, "mismatched def-use edge counts")do { if (!(cnt == 0)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 2270, "assert(" "cnt == 0" ") failed", "mismatched def-use edge counts"
); ::breakpoint(); } } while (0)
;
2271
2272 if (add_to_worklist && !visited.test_set(x->_idx)) {
2273 worklist.push(x);
2274 }
2275 }
2276
2277 if (verify_depth > 0 && list_index == last_index_on_current_depth) {
2278 // All nodes on this depth were processed and its inputs are on the worklist. Decrement verify_depth and
2279 // store the current last list index which is the last node in the list with the new depth. All nodes
2280 // added afterwards will have a new depth again. Stop adding new nodes if depth limit is reached (=0).
2281 verify_depth--;
2282 if (verify_depth == 0) {
2283 add_to_worklist = false;
2284 }
2285 last_index_on_current_depth = worklist.size() - 1;
2286 }
2287 }
2288}
2289#endif // not PRODUCT
2290
2291//------------------------------Registers--------------------------------------
2292// Do we Match on this edge index or not? Generally false for Control
2293// and true for everything else. Weird for calls & returns.
2294uint Node::match_edge(uint idx) const {
2295 return idx; // True for other than index 0 (control)
2296}
2297
2298// Register classes are defined for specific machines
2299const RegMask &Node::out_RegMask() const {
2300 ShouldNotCallThis()do { (*g_assert_poison) = 'X';; report_should_not_call("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 2300); ::breakpoint(); } while (0)
;
2301 return RegMask::Empty;
2302}
2303
2304const RegMask &Node::in_RegMask(uint) const {
2305 ShouldNotCallThis()do { (*g_assert_poison) = 'X';; report_should_not_call("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 2305); ::breakpoint(); } while (0)
;
2306 return RegMask::Empty;
2307}
2308
2309void Node_Array::grow(uint i) {
2310 assert(_max > 0, "invariant")do { if (!(_max > 0)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 2310, "assert(" "_max > 0" ") failed", "invariant"); ::breakpoint
(); } } while (0)
;
2311 uint old = _max;
2312 _max = next_power_of_2(i);
2313 _nodes = (Node**)_a->Arealloc( _nodes, old*sizeof(Node*),_max*sizeof(Node*));
2314 Copy::zero_to_bytes( &_nodes[old], (_max-old)*sizeof(Node*) );
2315}
2316
2317void Node_Array::insert(uint i, Node* n) {
2318 if (_nodes[_max - 1]) {
2319 grow(_max);
2320 }
2321 Copy::conjoint_words_to_higher((HeapWord*)&_nodes[i], (HeapWord*)&_nodes[i + 1], ((_max - i - 1) * sizeof(Node*)));
2322 _nodes[i] = n;
2323}
2324
2325void Node_Array::remove(uint i) {
2326 Copy::conjoint_words_to_lower((HeapWord*)&_nodes[i + 1], (HeapWord*)&_nodes[i], ((_max - i - 1) * sizeof(Node*)));
2327 _nodes[_max - 1] = NULL__null;
2328}
2329
2330void Node_Array::dump() const {
2331#ifndef PRODUCT
2332 for (uint i = 0; i < _max; i++) {
2333 Node* nn = _nodes[i];
2334 if (nn != NULL__null) {
2335 tty->print("%5d--> ",i); nn->dump();
2336 }
2337 }
2338#endif
2339}
2340
2341//--------------------------is_iteratively_computed------------------------------
2342// Operation appears to be iteratively computed (such as an induction variable)
2343// It is possible for this operation to return false for a loop-varying
2344// value, if it appears (by local graph inspection) to be computed by a simple conditional.
2345bool Node::is_iteratively_computed() {
2346 if (ideal_reg()) { // does operation have a result register?
2347 for (uint i = 1; i < req(); i++) {
2348 Node* n = in(i);
2349 if (n != NULL__null && n->is_Phi()) {
2350 for (uint j = 1; j < n->req(); j++) {
2351 if (n->in(j) == this) {
2352 return true;
2353 }
2354 }
2355 }
2356 }
2357 }
2358 return false;
2359}
2360
2361//--------------------------find_similar------------------------------
2362// Return a node with opcode "opc" and same inputs as "this" if one can
2363// be found; Otherwise return NULL;
2364Node* Node::find_similar(int opc) {
2365 if (req() >= 2) {
2366 Node* def = in(1);
2367 if (def && def->outcnt() >= 2) {
2368 for (DUIterator_Fast dmax, i = def->fast_outs(dmax); i < dmax; i++) {
2369 Node* use = def->fast_out(i);
2370 if (use != this &&
2371 use->Opcode() == opc &&
2372 use->req() == req()) {
2373 uint j;
2374 for (j = 0; j < use->req(); j++) {
2375 if (use->in(j) != in(j)) {
2376 break;
2377 }
2378 }
2379 if (j == use->req()) {
2380 return use;
2381 }
2382 }
2383 }
2384 }
2385 }
2386 return NULL__null;
2387}
2388
2389
2390//--------------------------unique_ctrl_out------------------------------
2391// Return the unique control out if only one. Null if none or more than one.
2392Node* Node::unique_ctrl_out() const {
2393 Node* found = NULL__null;
2394 for (uint i = 0; i < outcnt(); i++) {
2395 Node* use = raw_out(i);
2396 if (use->is_CFG() && use != this) {
2397 if (found != NULL__null) {
2398 return NULL__null;
2399 }
2400 found = use;
2401 }
2402 }
2403 return found;
2404}
2405
2406void Node::ensure_control_or_add_prec(Node* c) {
2407 if (in(0) == NULL__null) {
1
Assuming the condition is true
2
Taking true branch
2408 set_req(0, c);
3
Calling 'Node::set_req'
2409 } else if (in(0) != c) {
2410 add_prec(c);
2411 }
2412}
2413
2414bool Node::is_dead_loop_safe() const {
2415 if (is_Phi()) {
2416 return true;
2417 }
2418 if (is_Proj() && in(0) == NULL__null) {
2419 return true;
2420 }
2421 if ((_flags & (Flag_is_dead_loop_safe | Flag_is_Con)) != 0) {
2422 if (!is_Proj()) {
2423 return true;
2424 }
2425 if (in(0)->is_Allocate()) {
2426 return false;
2427 }
2428 // MemNode::can_see_stored_value() peeks through the boxing call
2429 if (in(0)->is_CallStaticJava() && in(0)->as_CallStaticJava()->is_boxing_method()) {
2430 return false;
2431 }
2432 return true;
2433 }
2434 return false;
2435}
2436
2437//=============================================================================
2438//------------------------------yank-------------------------------------------
2439// Find and remove
2440void Node_List::yank( Node *n ) {
2441 uint i;
2442 for (i = 0; i < _cnt; i++) {
2443 if (_nodes[i] == n) {
2444 break;
2445 }
2446 }
2447
2448 if (i < _cnt) {
2449 _nodes[i] = _nodes[--_cnt];
2450 }
2451}
2452
2453//------------------------------dump-------------------------------------------
2454void Node_List::dump() const {
2455#ifndef PRODUCT
2456 for (uint i = 0; i < _cnt; i++) {
2457 if (_nodes[i]) {
2458 tty->print("%5d--> ", i);
2459 _nodes[i]->dump();
2460 }
2461 }
2462#endif
2463}
2464
2465void Node_List::dump_simple() const {
2466#ifndef PRODUCT
2467 for (uint i = 0; i < _cnt; i++) {
2468 if( _nodes[i] ) {
2469 tty->print(" %d", _nodes[i]->_idx);
2470 } else {
2471 tty->print(" NULL");
2472 }
2473 }
2474#endif
2475}
2476
2477//=============================================================================
2478//------------------------------remove-----------------------------------------
2479void Unique_Node_List::remove(Node* n) {
2480 if (_in_worklist.test(n->_idx)) {
2481 for (uint i = 0; i < size(); i++) {
2482 if (_nodes[i] == n) {
2483 map(i, Node_List::pop());
2484 _in_worklist.remove(n->_idx);
2485 return;
2486 }
2487 }
2488 ShouldNotReachHere()do { (*g_assert_poison) = 'X';; report_should_not_reach_here(
"/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 2488); ::breakpoint(); } while (0)
;
2489 }
2490}
2491
2492//-----------------------remove_useless_nodes----------------------------------
2493// Remove useless nodes from worklist
2494void Unique_Node_List::remove_useless_nodes(VectorSet &useful) {
2495 for (uint i = 0; i < size(); ++i) {
2496 Node *n = at(i);
2497 assert( n != NULL, "Did not expect null entries in worklist")do { if (!(n != __null)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.cpp"
, 2497, "assert(" "n != __null" ") failed", "Did not expect null entries in worklist"
); ::breakpoint(); } } while (0)
;
2498 if (!useful.test(n->_idx)) {
2499 _in_worklist.remove(n->_idx);
2500 map(i, Node_List::pop());
2501 --i; // Visit popped node
2502 // If it was last entry, loop terminates since size() was also reduced
2503 }
2504 }
2505}
2506
2507//=============================================================================
2508void Node_Stack::grow() {
2509 size_t old_top = pointer_delta(_inode_top,_inodes,sizeof(INode)); // save _top
2510 size_t old_max = pointer_delta(_inode_max,_inodes,sizeof(INode));
2511 size_t max = old_max << 1; // max * 2
2512 _inodes = REALLOC_ARENA_ARRAY(_a, INode, _inodes, old_max, max)(INode*) (_a)->Arealloc((char*)(_inodes), (old_max) * sizeof
(INode), (max) * sizeof(INode) )
;
2513 _inode_max = _inodes + max;
2514 _inode_top = _inodes + old_top; // restore _top
2515}
2516
2517// Node_Stack is used to map nodes.
2518Node* Node_Stack::find(uint idx) const {
2519 uint sz = size();
2520 for (uint i = 0; i < sz; i++) {
2521 if (idx == index_at(i)) {
2522 return node_at(i);
2523 }
2524 }
2525 return NULL__null;
2526}
2527
2528//=============================================================================
2529uint TypeNode::size_of() const { return sizeof(*this); }
2530#ifndef PRODUCT
2531void TypeNode::dump_spec(outputStream *st) const {
2532 if (!Verbose && !WizardMode) {
2533 // standard dump does this in Verbose and WizardMode
2534 st->print(" #"); _type->dump_on(st);
2535 }
2536}
2537
2538void TypeNode::dump_compact_spec(outputStream *st) const {
2539 st->print("#");
2540 _type->dump_on(st);
2541}
2542#endif
2543uint TypeNode::hash() const {
2544 return Node::hash() + _type->hash();
2545}
2546bool TypeNode::cmp(const Node& n) const {
2547 return !Type::cmp(_type, ((TypeNode&)n)._type);
2548}
2549const Type* TypeNode::bottom_type() const { return _type; }
2550const Type* TypeNode::Value(PhaseGVN* phase) const { return _type; }
2551
2552//------------------------------ideal_reg--------------------------------------
2553uint TypeNode::ideal_reg() const {
2554 return _type->ideal_reg();
2555}

/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.hpp

1/*
2 * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25#ifndef SHARE_OPTO_NODE_HPP
26#define SHARE_OPTO_NODE_HPP
27
28#include "libadt/vectset.hpp"
29#include "opto/compile.hpp"
30#include "opto/type.hpp"
31#include "utilities/copy.hpp"
32
33// Portions of code courtesy of Clifford Click
34
35// Optimization - Graph Style
36
37
38class AbstractLockNode;
39class AddNode;
40class AddPNode;
41class AliasInfo;
42class AllocateArrayNode;
43class AllocateNode;
44class ArrayCopyNode;
45class BaseCountedLoopNode;
46class BaseCountedLoopEndNode;
47class BlackholeNode;
48class Block;
49class BoolNode;
50class BoxLockNode;
51class CMoveNode;
52class CallDynamicJavaNode;
53class CallJavaNode;
54class CallLeafNode;
55class CallLeafNoFPNode;
56class CallNode;
57class CallRuntimeNode;
58class CallNativeNode;
59class CallStaticJavaNode;
60class CastFFNode;
61class CastDDNode;
62class CastVVNode;
63class CastIINode;
64class CastLLNode;
65class CatchNode;
66class CatchProjNode;
67class CheckCastPPNode;
68class ClearArrayNode;
69class CmpNode;
70class CodeBuffer;
71class ConstraintCastNode;
72class ConNode;
73class CompareAndSwapNode;
74class CompareAndExchangeNode;
75class CountedLoopNode;
76class CountedLoopEndNode;
77class DecodeNarrowPtrNode;
78class DecodeNNode;
79class DecodeNKlassNode;
80class EncodeNarrowPtrNode;
81class EncodePNode;
82class EncodePKlassNode;
83class FastLockNode;
84class FastUnlockNode;
85class HaltNode;
86class IfNode;
87class IfProjNode;
88class IfFalseNode;
89class IfTrueNode;
90class InitializeNode;
91class JVMState;
92class JumpNode;
93class JumpProjNode;
94class LoadNode;
95class LoadStoreNode;
96class LoadStoreConditionalNode;
97class LockNode;
98class LongCountedLoopNode;
99class LongCountedLoopEndNode;
100class LoopNode;
101class LShiftNode;
102class MachBranchNode;
103class MachCallDynamicJavaNode;
104class MachCallJavaNode;
105class MachCallLeafNode;
106class MachCallNode;
107class MachCallNativeNode;
108class MachCallRuntimeNode;
109class MachCallStaticJavaNode;
110class MachConstantBaseNode;
111class MachConstantNode;
112class MachGotoNode;
113class MachIfNode;
114class MachJumpNode;
115class MachNode;
116class MachNullCheckNode;
117class MachProjNode;
118class MachReturnNode;
119class MachSafePointNode;
120class MachSpillCopyNode;
121class MachTempNode;
122class MachMergeNode;
123class MachMemBarNode;
124class Matcher;
125class MemBarNode;
126class MemBarStoreStoreNode;
127class MemNode;
128class MergeMemNode;
129class MoveNode;
130class MulNode;
131class MultiNode;
132class MultiBranchNode;
133class NeverBranchNode;
134class Opaque1Node;
135class OuterStripMinedLoopNode;
136class OuterStripMinedLoopEndNode;
137class Node;
138class Node_Array;
139class Node_List;
140class Node_Stack;
141class OopMap;
142class ParmNode;
143class PCTableNode;
144class PhaseCCP;
145class PhaseGVN;
146class PhaseIterGVN;
147class PhaseRegAlloc;
148class PhaseTransform;
149class PhaseValues;
150class PhiNode;
151class Pipeline;
152class ProjNode;
153class RangeCheckNode;
154class RegMask;
155class RegionNode;
156class RootNode;
157class SafePointNode;
158class SafePointScalarObjectNode;
159class StartNode;
160class State;
161class StoreNode;
162class SubNode;
163class SubTypeCheckNode;
164class Type;
165class TypeNode;
166class UnlockNode;
167class VectorNode;
168class LoadVectorNode;
169class LoadVectorMaskedNode;
170class StoreVectorMaskedNode;
171class LoadVectorGatherNode;
172class StoreVectorNode;
173class StoreVectorScatterNode;
174class VectorMaskCmpNode;
175class VectorUnboxNode;
176class VectorSet;
177class VectorReinterpretNode;
178class ShiftVNode;
179
180// The type of all node counts and indexes.
181// It must hold at least 16 bits, but must also be fast to load and store.
182// This type, if less than 32 bits, could limit the number of possible nodes.
183// (To make this type platform-specific, move to globalDefinitions_xxx.hpp.)
184typedef unsigned int node_idx_t;
185
186
187#ifndef OPTO_DU_ITERATOR_ASSERT1
188#ifdef ASSERT1
189#define OPTO_DU_ITERATOR_ASSERT1 1
190#else
191#define OPTO_DU_ITERATOR_ASSERT1 0
192#endif
193#endif //OPTO_DU_ITERATOR_ASSERT
194
195#if OPTO_DU_ITERATOR_ASSERT1
196class DUIterator;
197class DUIterator_Fast;
198class DUIterator_Last;
199#else
200typedef uint DUIterator;
201typedef Node** DUIterator_Fast;
202typedef Node** DUIterator_Last;
203#endif
204
205// Node Sentinel
206#define NodeSentinel(Node*)-1 (Node*)-1
207
208// Unknown count frequency
209#define COUNT_UNKNOWN(-1.0f) (-1.0f)
210
211//------------------------------Node-------------------------------------------
212// Nodes define actions in the program. They create values, which have types.
213// They are both vertices in a directed graph and program primitives. Nodes
214// are labeled; the label is the "opcode", the primitive function in the lambda
215// calculus sense that gives meaning to the Node. Node inputs are ordered (so
216// that "a-b" is different from "b-a"). The inputs to a Node are the inputs to
217// the Node's function. These inputs also define a Type equation for the Node.
218// Solving these Type equations amounts to doing dataflow analysis.
219// Control and data are uniformly represented in the graph. Finally, Nodes
220// have a unique dense integer index which is used to index into side arrays
221// whenever I have phase-specific information.
222
223class Node {
224 friend class VMStructs;
225
226 // Lots of restrictions on cloning Nodes
227 NONCOPYABLE(Node)Node(Node const&) = delete; Node& operator=(Node const
&) = delete
;
228
229public:
230 friend class Compile;
231 #if OPTO_DU_ITERATOR_ASSERT1
232 friend class DUIterator_Common;
233 friend class DUIterator;
234 friend class DUIterator_Fast;
235 friend class DUIterator_Last;
236 #endif
237
238 // Because Nodes come and go, I define an Arena of Node structures to pull
239 // from. This should allow fast access to node creation & deletion. This
240 // field is a local cache of a value defined in some "program fragment" for
241 // which these Nodes are just a part of.
242
243 inline void* operator new(size_t x) throw() {
244 Compile* C = Compile::current();
245 Node* n = (Node*)C->node_arena()->AmallocWords(x);
246 return (void*)n;
247 }
248
249 // Delete is a NOP
250 void operator delete( void *ptr ) {}
251 // Fancy destructor; eagerly attempt to reclaim Node numberings and storage
252 void destruct(PhaseValues* phase);
253
254 // Create a new Node. Required is the number is of inputs required for
255 // semantic correctness.
256 Node( uint required );
257
258 // Create a new Node with given input edges.
259 // This version requires use of the "edge-count" new.
260 // E.g. new (C,3) FooNode( C, NULL, left, right );
261 Node( Node *n0 );
262 Node( Node *n0, Node *n1 );
263 Node( Node *n0, Node *n1, Node *n2 );
264 Node( Node *n0, Node *n1, Node *n2, Node *n3 );
265 Node( Node *n0, Node *n1, Node *n2, Node *n3, Node *n4 );
266 Node( Node *n0, Node *n1, Node *n2, Node *n3, Node *n4, Node *n5 );
267 Node( Node *n0, Node *n1, Node *n2, Node *n3,
268 Node *n4, Node *n5, Node *n6 );
269
270 // Clone an inherited Node given only the base Node type.
271 Node* clone() const;
272
273 // Clone a Node, immediately supplying one or two new edges.
274 // The first and second arguments, if non-null, replace in(1) and in(2),
275 // respectively.
276 Node* clone_with_data_edge(Node* in1, Node* in2 = NULL__null) const {
277 Node* nn = clone();
278 if (in1 != NULL__null) nn->set_req(1, in1);
279 if (in2 != NULL__null) nn->set_req(2, in2);
280 return nn;
281 }
282
283private:
284 // Shared setup for the above constructors.
285 // Handles all interactions with Compile::current.
286 // Puts initial values in all Node fields except _idx.
287 // Returns the initial value for _idx, which cannot
288 // be initialized by assignment.
289 inline int Init(int req);
290
291//----------------- input edge handling
292protected:
293 friend class PhaseCFG; // Access to address of _in array elements
294 Node **_in; // Array of use-def references to Nodes
295 Node **_out; // Array of def-use references to Nodes
296
297 // Input edges are split into two categories. Required edges are required
298 // for semantic correctness; order is important and NULLs are allowed.
299 // Precedence edges are used to help determine execution order and are
300 // added, e.g., for scheduling purposes. They are unordered and not
301 // duplicated; they have no embedded NULLs. Edges from 0 to _cnt-1
302 // are required, from _cnt to _max-1 are precedence edges.
303 node_idx_t _cnt; // Total number of required Node inputs.
304
305 node_idx_t _max; // Actual length of input array.
306
307 // Output edges are an unordered list of def-use edges which exactly
308 // correspond to required input edges which point from other nodes
309 // to this one. Thus the count of the output edges is the number of
310 // users of this node.
311 node_idx_t _outcnt; // Total number of Node outputs.
312
313 node_idx_t _outmax; // Actual length of output array.
314
315 // Grow the actual input array to the next larger power-of-2 bigger than len.
316 void grow( uint len );
317 // Grow the output array to the next larger power-of-2 bigger than len.
318 void out_grow( uint len );
319
320 public:
321 // Each Node is assigned a unique small/dense number. This number is used
322 // to index into auxiliary arrays of data and bit vectors.
323 // The field _idx is declared constant to defend against inadvertent assignments,
324 // since it is used by clients as a naked field. However, the field's value can be
325 // changed using the set_idx() method.
326 //
327 // The PhaseRenumberLive phase renumbers nodes based on liveness information.
328 // Therefore, it updates the value of the _idx field. The parse-time _idx is
329 // preserved in _parse_idx.
330 const node_idx_t _idx;
331 DEBUG_ONLY(const node_idx_t _parse_idx;)const node_idx_t _parse_idx;
332 // IGV node identifier. Two nodes, possibly in different compilation phases,
333 // have the same IGV identifier if (and only if) they are the very same node
334 // (same memory address) or one is "derived" from the other (by e.g.
335 // renumbering or matching). This identifier makes it possible to follow the
336 // entire lifetime of a node in IGV even if its C2 identifier (_idx) changes.
337 NOT_PRODUCT(node_idx_t _igv_idx;)node_idx_t _igv_idx;
338
339 // Get the (read-only) number of input edges
340 uint req() const { return _cnt; }
341 uint len() const { return _max; }
342 // Get the (read-only) number of output edges
343 uint outcnt() const { return _outcnt; }
344
345#if OPTO_DU_ITERATOR_ASSERT1
346 // Iterate over the out-edges of this node. Deletions are illegal.
347 inline DUIterator outs() const;
348 // Use this when the out array might have changed to suppress asserts.
349 inline DUIterator& refresh_out_pos(DUIterator& i) const;
350 // Does the node have an out at this position? (Used for iteration.)
351 inline bool has_out(DUIterator& i) const;
352 inline Node* out(DUIterator& i) const;
353 // Iterate over the out-edges of this node. All changes are illegal.
354 inline DUIterator_Fast fast_outs(DUIterator_Fast& max) const;
355 inline Node* fast_out(DUIterator_Fast& i) const;
356 // Iterate over the out-edges of this node, deleting one at a time.
357 inline DUIterator_Last last_outs(DUIterator_Last& min) const;
358 inline Node* last_out(DUIterator_Last& i) const;
359 // The inline bodies of all these methods are after the iterator definitions.
360#else
361 // Iterate over the out-edges of this node. Deletions are illegal.
362 // This iteration uses integral indexes, to decouple from array reallocations.
363 DUIterator outs() const { return 0; }
364 // Use this when the out array might have changed to suppress asserts.
365 DUIterator refresh_out_pos(DUIterator i) const { return i; }
366
367 // Reference to the i'th output Node. Error if out of bounds.
368 Node* out(DUIterator i) const { assert(i < _outcnt, "oob")do { if (!(i < _outcnt)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.hpp"
, 368, "assert(" "i < _outcnt" ") failed", "oob"); ::breakpoint
(); } } while (0)
; return _out[i]; }
369 // Does the node have an out at this position? (Used for iteration.)
370 bool has_out(DUIterator i) const { return i < _outcnt; }
371
372 // Iterate over the out-edges of this node. All changes are illegal.
373 // This iteration uses a pointer internal to the out array.
374 DUIterator_Fast fast_outs(DUIterator_Fast& max) const {
375 Node** out = _out;
376 // Assign a limit pointer to the reference argument:
377 max = out + (ptrdiff_t)_outcnt;
378 // Return the base pointer:
379 return out;
380 }
381 Node* fast_out(DUIterator_Fast i) const { return *i; }
382 // Iterate over the out-edges of this node, deleting one at a time.
383 // This iteration uses a pointer internal to the out array.
384 DUIterator_Last last_outs(DUIterator_Last& min) const {
385 Node** out = _out;
386 // Assign a limit pointer to the reference argument:
387 min = out;
388 // Return the pointer to the start of the iteration:
389 return out + (ptrdiff_t)_outcnt - 1;
390 }
391 Node* last_out(DUIterator_Last i) const { return *i; }
392#endif
393
394 // Reference to the i'th input Node. Error if out of bounds.
395 Node* in(uint i) const { assert(i < _max, "oob: i=%d, _max=%d", i, _max)do { if (!(i < _max)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.hpp"
, 395, "assert(" "i < _max" ") failed", "oob: i=%d, _max=%d"
, i, _max); ::breakpoint(); } } while (0)
; return _in[i]; }
396 // Reference to the i'th input Node. NULL if out of bounds.
397 Node* lookup(uint i) const { return ((i < _max) ? _in[i] : NULL__null); }
398 // Reference to the i'th output Node. Error if out of bounds.
399 // Use this accessor sparingly. We are going trying to use iterators instead.
400 Node* raw_out(uint i) const { assert(i < _outcnt,"oob")do { if (!(i < _outcnt)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.hpp"
, 400, "assert(" "i < _outcnt" ") failed", "oob"); ::breakpoint
(); } } while (0)
; return _out[i]; }
401 // Return the unique out edge.
402 Node* unique_out() const { assert(_outcnt==1,"not unique")do { if (!(_outcnt==1)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.hpp"
, 402, "assert(" "_outcnt==1" ") failed", "not unique"); ::breakpoint
(); } } while (0)
; return _out[0]; }
403 // Delete out edge at position 'i' by moving last out edge to position 'i'
404 void raw_del_out(uint i) {
405 assert(i < _outcnt,"oob")do { if (!(i < _outcnt)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.hpp"
, 405, "assert(" "i < _outcnt" ") failed", "oob"); ::breakpoint
(); } } while (0)
;
406 assert(_outcnt > 0,"oob")do { if (!(_outcnt > 0)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.hpp"
, 406, "assert(" "_outcnt > 0" ") failed", "oob"); ::breakpoint
(); } } while (0)
;
407 #if OPTO_DU_ITERATOR_ASSERT1
408 // Record that a change happened here.
409 debug_only(_last_del = _out[i]; ++_del_tick)_last_del = _out[i]; ++_del_tick;
410 #endif
411 _out[i] = _out[--_outcnt];
412 // Smash the old edge so it can't be used accidentally.
413 debug_only(_out[_outcnt] = (Node *)(uintptr_t)0xdeadbeef)_out[_outcnt] = (Node *)(uintptr_t)0xdeadbeef;
414 }
415
416#ifdef ASSERT1
417 bool is_dead() const;
418#define is_not_dead(n)((n) == __null || !VerifyIterativeGVN || !((n)->is_dead())
)
((n) == NULL__null || !VerifyIterativeGVN || !((n)->is_dead()))
419 bool is_reachable_from_root() const;
420#endif
421 // Check whether node has become unreachable
422 bool is_unreachable(PhaseIterGVN &igvn) const;
423
424 // Set a required input edge, also updates corresponding output edge
425 void add_req( Node *n ); // Append a NEW required input
426 void add_req( Node *n0, Node *n1 ) {
427 add_req(n0); add_req(n1); }
428 void add_req( Node *n0, Node *n1, Node *n2 ) {
429 add_req(n0); add_req(n1); add_req(n2); }
430 void add_req_batch( Node* n, uint m ); // Append m NEW required inputs (all n).
431 void del_req( uint idx ); // Delete required edge & compact
432 void del_req_ordered( uint idx ); // Delete required edge & compact with preserved order
433 void ins_req( uint i, Node *n ); // Insert a NEW required input
434 void set_req( uint i, Node *n ) {
435 assert( is_not_dead(n), "can not use dead node")do { if (!(((n) == __null || !VerifyIterativeGVN || !((n)->
is_dead())))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.hpp"
, 435, "assert(" "((n) == __null || !VerifyIterativeGVN || !((n)->is_dead()))"
") failed", "can not use dead node"); ::breakpoint(); } } while
(0)
;
4
Assuming the condition is false
5
Assuming 'VerifyIterativeGVN' is true
6
Calling 'Node::is_dead'
436 assert( i < _cnt, "oob: i=%d, _cnt=%d", i, _cnt)do { if (!(i < _cnt)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.hpp"
, 436, "assert(" "i < _cnt" ") failed", "oob: i=%d, _cnt=%d"
, i, _cnt); ::breakpoint(); } } while (0)
;
437 assert( !VerifyHashTableKeys || _hash_lock == 0,do { if (!(!VerifyHashTableKeys || _hash_lock == 0)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.hpp"
, 438, "assert(" "!VerifyHashTableKeys || _hash_lock == 0" ") failed"
, "remove node from hash table before modifying it"); ::breakpoint
(); } } while (0)
438 "remove node from hash table before modifying it")do { if (!(!VerifyHashTableKeys || _hash_lock == 0)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.hpp"
, 438, "assert(" "!VerifyHashTableKeys || _hash_lock == 0" ") failed"
, "remove node from hash table before modifying it"); ::breakpoint
(); } } while (0)
;
439 Node** p = &_in[i]; // cache this._in, across the del_out call
440 if (*p != NULL__null) (*p)->del_out((Node *)this);
441 (*p) = n;
442 if (n != NULL__null) n->add_out((Node *)this);
443 Compile::current()->record_modified_node(this);
444 }
445 // Light version of set_req() to init inputs after node creation.
446 void init_req( uint i, Node *n ) {
447 assert( i == 0 && this == n ||do { if (!(i == 0 && this == n || ((n) == __null || !
VerifyIterativeGVN || !((n)->is_dead())))) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.hpp"
, 448, "assert(" "i == 0 && this == n || ((n) == __null || !VerifyIterativeGVN || !((n)->is_dead()))"
") failed", "can not use dead node"); ::breakpoint(); } } while
(0)
448 is_not_dead(n), "can not use dead node")do { if (!(i == 0 && this == n || ((n) == __null || !
VerifyIterativeGVN || !((n)->is_dead())))) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.hpp"
, 448, "assert(" "i == 0 && this == n || ((n) == __null || !VerifyIterativeGVN || !((n)->is_dead()))"
") failed", "can not use dead node"); ::breakpoint(); } } while
(0)
;
449 assert( i < _cnt, "oob")do { if (!(i < _cnt)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.hpp"
, 449, "assert(" "i < _cnt" ") failed", "oob"); ::breakpoint
(); } } while (0)
;
450 assert( !VerifyHashTableKeys || _hash_lock == 0,do { if (!(!VerifyHashTableKeys || _hash_lock == 0)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.hpp"
, 451, "assert(" "!VerifyHashTableKeys || _hash_lock == 0" ") failed"
, "remove node from hash table before modifying it"); ::breakpoint
(); } } while (0)
451 "remove node from hash table before modifying it")do { if (!(!VerifyHashTableKeys || _hash_lock == 0)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.hpp"
, 451, "assert(" "!VerifyHashTableKeys || _hash_lock == 0" ") failed"
, "remove node from hash table before modifying it"); ::breakpoint
(); } } while (0)
;
452 assert( _in[i] == NULL, "sanity")do { if (!(_in[i] == __null)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.hpp"
, 452, "assert(" "_in[i] == __null" ") failed", "sanity"); ::
breakpoint(); } } while (0)
;
453 _in[i] = n;
454 if (n != NULL__null) n->add_out((Node *)this);
455 Compile::current()->record_modified_node(this);
456 }
457 // Find first occurrence of n among my edges:
458 int find_edge(Node* n);
459 int find_prec_edge(Node* n) {
460 for (uint i = req(); i < len(); i++) {
461 if (_in[i] == n) return i;
462 if (_in[i] == NULL__null) {
463 DEBUG_ONLY( while ((++i) < len()) assert(_in[i] == NULL, "Gap in prec edges!"); )while ((++i) < len()) do { if (!(_in[i] == __null)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.hpp"
, 463, "assert(" "_in[i] == __null" ") failed", "Gap in prec edges!"
); ::breakpoint(); } } while (0);
464 break;
465 }
466 }
467 return -1;
468 }
469 int replace_edge(Node* old, Node* neww, PhaseGVN* gvn = NULL__null);
470 int replace_edges_in_range(Node* old, Node* neww, int start, int end, PhaseGVN* gvn);
471 // NULL out all inputs to eliminate incoming Def-Use edges.
472 void disconnect_inputs(Compile* C);
473
474 // Quickly, return true if and only if I am Compile::current()->top().
475 bool is_top() const {
476 assert((this == (Node*) Compile::current()->top()) == (_out == NULL), "")do { if (!((this == (Node*) Compile::current()->top()) == (
_out == __null))) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.hpp"
, 476, "assert(" "(this == (Node*) Compile::current()->top()) == (_out == __null)"
") failed", ""); ::breakpoint(); } } while (0)
;
477 return (_out == NULL__null);
478 }
479 // Reaffirm invariants for is_top. (Only from Compile::set_cached_top_node.)
480 void setup_is_top();
481
482 // Strip away casting. (It is depth-limited.)
483 Node* uncast(bool keep_deps = false) const;
484 // Return whether two Nodes are equivalent, after stripping casting.
485 bool eqv_uncast(const Node* n, bool keep_deps = false) const {
486 return (this->uncast(keep_deps) == n->uncast(keep_deps));
487 }
488
489 // Find out of current node that matches opcode.
490 Node* find_out_with(int opcode);
491 // Return true if the current node has an out that matches opcode.
492 bool has_out_with(int opcode);
493 // Return true if the current node has an out that matches any of the opcodes.
494 bool has_out_with(int opcode1, int opcode2, int opcode3, int opcode4);
495
496private:
497 static Node* uncast_helper(const Node* n, bool keep_deps);
498
499 // Add an output edge to the end of the list
500 void add_out( Node *n ) {
501 if (is_top()) return;
502 if( _outcnt == _outmax ) out_grow(_outcnt);
503 _out[_outcnt++] = n;
504 }
505 // Delete an output edge
506 void del_out( Node *n ) {
507 if (is_top()) return;
508 Node** outp = &_out[_outcnt];
509 // Find and remove n
510 do {
511 assert(outp > _out, "Missing Def-Use edge")do { if (!(outp > _out)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.hpp"
, 511, "assert(" "outp > _out" ") failed", "Missing Def-Use edge"
); ::breakpoint(); } } while (0)
;
512 } while (*--outp != n);
513 *outp = _out[--_outcnt];
514 // Smash the old edge so it can't be used accidentally.
515 debug_only(_out[_outcnt] = (Node *)(uintptr_t)0xdeadbeef)_out[_outcnt] = (Node *)(uintptr_t)0xdeadbeef;
516 // Record that a change happened here.
517 #if OPTO_DU_ITERATOR_ASSERT1
518 debug_only(_last_del = n; ++_del_tick)_last_del = n; ++_del_tick;
519 #endif
520 }
521 // Close gap after removing edge.
522 void close_prec_gap_at(uint gap) {
523 assert(_cnt <= gap && gap < _max, "no valid prec edge")do { if (!(_cnt <= gap && gap < _max)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.hpp"
, 523, "assert(" "_cnt <= gap && gap < _max" ") failed"
, "no valid prec edge"); ::breakpoint(); } } while (0)
;
524 uint i = gap;
525 Node *last = NULL__null;
526 for (; i < _max-1; ++i) {
527 Node *next = _in[i+1];
528 if (next == NULL__null) break;
529 last = next;
530 }
531 _in[gap] = last; // Move last slot to empty one.
532 _in[i] = NULL__null; // NULL out last slot.
533 }
534
535public:
536 // Globally replace this node by a given new node, updating all uses.
537 void replace_by(Node* new_node);
538 // Globally replace this node by a given new node, updating all uses
539 // and cutting input edges of old node.
540 void subsume_by(Node* new_node, Compile* c) {
541 replace_by(new_node);
542 disconnect_inputs(c);
543 }
544 void set_req_X(uint i, Node *n, PhaseIterGVN *igvn);
545 void set_req_X(uint i, Node *n, PhaseGVN *gvn);
546 // Find the one non-null required input. RegionNode only
547 Node *nonnull_req() const;
548 // Add or remove precedence edges
549 void add_prec( Node *n );
550 void rm_prec( uint i );
551
552 // Note: prec(i) will not necessarily point to n if edge already exists.
553 void set_prec( uint i, Node *n ) {
554 assert(i < _max, "oob: i=%d, _max=%d", i, _max)do { if (!(i < _max)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.hpp"
, 554, "assert(" "i < _max" ") failed", "oob: i=%d, _max=%d"
, i, _max); ::breakpoint(); } } while (0)
;
555 assert(is_not_dead(n), "can not use dead node")do { if (!(((n) == __null || !VerifyIterativeGVN || !((n)->
is_dead())))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.hpp"
, 555, "assert(" "((n) == __null || !VerifyIterativeGVN || !((n)->is_dead()))"
") failed", "can not use dead node"); ::breakpoint(); } } while
(0)
;
556 assert(i >= _cnt, "not a precedence edge")do { if (!(i >= _cnt)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.hpp"
, 556, "assert(" "i >= _cnt" ") failed", "not a precedence edge"
); ::breakpoint(); } } while (0)
;
557 // Avoid spec violation: duplicated prec edge.
558 if (_in[i] == n) return;
559 if (n == NULL__null || find_prec_edge(n) != -1) {
560 rm_prec(i);
561 return;
562 }
563 if (_in[i] != NULL__null) _in[i]->del_out((Node *)this);
564 _in[i] = n;
565 n->add_out((Node *)this);
566 }
567
568 // Set this node's index, used by cisc_version to replace current node
569 void set_idx(uint new_idx) {
570 const node_idx_t* ref = &_idx;
571 *(node_idx_t*)ref = new_idx;
572 }
573 // Swap input edge order. (Edge indexes i1 and i2 are usually 1 and 2.)
574 void swap_edges(uint i1, uint i2) {
575 debug_only(uint check_hash = (VerifyHashTableKeys && _hash_lock) ? hash() : NO_HASH)uint check_hash = (VerifyHashTableKeys && _hash_lock)
? hash() : NO_HASH
;
576 // Def-Use info is unchanged
577 Node* n1 = in(i1);
578 Node* n2 = in(i2);
579 _in[i1] = n2;
580 _in[i2] = n1;
581 // If this node is in the hash table, make sure it doesn't need a rehash.
582 assert(check_hash == NO_HASH || check_hash == hash(), "edge swap must preserve hash code")do { if (!(check_hash == NO_HASH || check_hash == hash())) { (
*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.hpp"
, 582, "assert(" "check_hash == NO_HASH || check_hash == hash()"
") failed", "edge swap must preserve hash code"); ::breakpoint
(); } } while (0)
;
583 }
584
585 // Iterators over input Nodes for a Node X are written as:
586 // for( i = 0; i < X.req(); i++ ) ... X[i] ...
587 // NOTE: Required edges can contain embedded NULL pointers.
588
589//----------------- Other Node Properties
590
591 // Generate class IDs for (some) ideal nodes so that it is possible to determine
592 // the type of a node using a non-virtual method call (the method is_<Node>() below).
593 //
594 // A class ID of an ideal node is a set of bits. In a class ID, a single bit determines
595 // the type of the node the ID represents; another subset of an ID's bits are reserved
596 // for the superclasses of the node represented by the ID.
597 //
598 // By design, if A is a supertype of B, A.is_B() returns true and B.is_A()
599 // returns false. A.is_A() returns true.
600 //
601 // If two classes, A and B, have the same superclass, a different bit of A's class id
602 // is reserved for A's type than for B's type. That bit is specified by the third
603 // parameter in the macro DEFINE_CLASS_ID.
604 //
605 // By convention, classes with deeper hierarchy are declared first. Moreover,
606 // classes with the same hierarchy depth are sorted by usage frequency.
607 //
608 // The query method masks the bits to cut off bits of subclasses and then compares
609 // the result with the class id (see the macro DEFINE_CLASS_QUERY below).
610 //
611 // Class_MachCall=30, ClassMask_MachCall=31
612 // 12 8 4 0
613 // 0 0 0 0 0 0 0 0 1 1 1 1 0
614 // | | | |
615 // | | | Bit_Mach=2
616 // | | Bit_MachReturn=4
617 // | Bit_MachSafePoint=8
618 // Bit_MachCall=16
619 //
620 // Class_CountedLoop=56, ClassMask_CountedLoop=63
621 // 12 8 4 0
622 // 0 0 0 0 0 0 0 1 1 1 0 0 0
623 // | | |
624 // | | Bit_Region=8
625 // | Bit_Loop=16
626 // Bit_CountedLoop=32
627
628 #define DEFINE_CLASS_ID(cl, supcl, subn) \
629 Bit_##cl = (Class_##supcl == 0) ? 1 << subn : (Bit_##supcl) << (1 + subn) , \
630 Class_##cl = Class_##supcl + Bit_##cl , \
631 ClassMask_##cl = ((Bit_##cl << 1) - 1) ,
632
633 // This enum is used only for C2 ideal and mach nodes with is_<node>() methods
634 // so that its values fit into 32 bits.
635 enum NodeClasses {
636 Bit_Node = 0x00000000,
637 Class_Node = 0x00000000,
638 ClassMask_Node = 0xFFFFFFFF,
639
640 DEFINE_CLASS_ID(Multi, Node, 0)
641 DEFINE_CLASS_ID(SafePoint, Multi, 0)
642 DEFINE_CLASS_ID(Call, SafePoint, 0)
643 DEFINE_CLASS_ID(CallJava, Call, 0)
644 DEFINE_CLASS_ID(CallStaticJava, CallJava, 0)
645 DEFINE_CLASS_ID(CallDynamicJava, CallJava, 1)
646 DEFINE_CLASS_ID(CallRuntime, Call, 1)
647 DEFINE_CLASS_ID(CallLeaf, CallRuntime, 0)
648 DEFINE_CLASS_ID(CallLeafNoFP, CallLeaf, 0)
649 DEFINE_CLASS_ID(Allocate, Call, 2)
650 DEFINE_CLASS_ID(AllocateArray, Allocate, 0)
651 DEFINE_CLASS_ID(AbstractLock, Call, 3)
652 DEFINE_CLASS_ID(Lock, AbstractLock, 0)
653 DEFINE_CLASS_ID(Unlock, AbstractLock, 1)
654 DEFINE_CLASS_ID(ArrayCopy, Call, 4)
655 DEFINE_CLASS_ID(CallNative, Call, 5)
656 DEFINE_CLASS_ID(MultiBranch, Multi, 1)
657 DEFINE_CLASS_ID(PCTable, MultiBranch, 0)
658 DEFINE_CLASS_ID(Catch, PCTable, 0)
659 DEFINE_CLASS_ID(Jump, PCTable, 1)
660 DEFINE_CLASS_ID(If, MultiBranch, 1)
661 DEFINE_CLASS_ID(BaseCountedLoopEnd, If, 0)
662 DEFINE_CLASS_ID(CountedLoopEnd, BaseCountedLoopEnd, 0)
663 DEFINE_CLASS_ID(LongCountedLoopEnd, BaseCountedLoopEnd, 1)
664 DEFINE_CLASS_ID(RangeCheck, If, 1)
665 DEFINE_CLASS_ID(OuterStripMinedLoopEnd, If, 2)
666 DEFINE_CLASS_ID(NeverBranch, MultiBranch, 2)
667 DEFINE_CLASS_ID(Start, Multi, 2)
668 DEFINE_CLASS_ID(MemBar, Multi, 3)
669 DEFINE_CLASS_ID(Initialize, MemBar, 0)
670 DEFINE_CLASS_ID(MemBarStoreStore, MemBar, 1)
671
672 DEFINE_CLASS_ID(Mach, Node, 1)
673 DEFINE_CLASS_ID(MachReturn, Mach, 0)
674 DEFINE_CLASS_ID(MachSafePoint, MachReturn, 0)
675 DEFINE_CLASS_ID(MachCall, MachSafePoint, 0)
676 DEFINE_CLASS_ID(MachCallJava, MachCall, 0)
677 DEFINE_CLASS_ID(MachCallStaticJava, MachCallJava, 0)
678 DEFINE_CLASS_ID(MachCallDynamicJava, MachCallJava, 1)
679 DEFINE_CLASS_ID(MachCallRuntime, MachCall, 1)
680 DEFINE_CLASS_ID(MachCallLeaf, MachCallRuntime, 0)
681 DEFINE_CLASS_ID(MachCallNative, MachCall, 2)
682 DEFINE_CLASS_ID(MachBranch, Mach, 1)
683 DEFINE_CLASS_ID(MachIf, MachBranch, 0)
684 DEFINE_CLASS_ID(MachGoto, MachBranch, 1)
685 DEFINE_CLASS_ID(MachNullCheck, MachBranch, 2)
686 DEFINE_CLASS_ID(MachSpillCopy, Mach, 2)
687 DEFINE_CLASS_ID(MachTemp, Mach, 3)
688 DEFINE_CLASS_ID(MachConstantBase, Mach, 4)
689 DEFINE_CLASS_ID(MachConstant, Mach, 5)
690 DEFINE_CLASS_ID(MachJump, MachConstant, 0)
691 DEFINE_CLASS_ID(MachMerge, Mach, 6)
692 DEFINE_CLASS_ID(MachMemBar, Mach, 7)
693
694 DEFINE_CLASS_ID(Type, Node, 2)
695 DEFINE_CLASS_ID(Phi, Type, 0)
696 DEFINE_CLASS_ID(ConstraintCast, Type, 1)
697 DEFINE_CLASS_ID(CastII, ConstraintCast, 0)
698 DEFINE_CLASS_ID(CheckCastPP, ConstraintCast, 1)
699 DEFINE_CLASS_ID(CastLL, ConstraintCast, 2)
700 DEFINE_CLASS_ID(CastFF, ConstraintCast, 3)
701 DEFINE_CLASS_ID(CastDD, ConstraintCast, 4)
702 DEFINE_CLASS_ID(CastVV, ConstraintCast, 5)
703 DEFINE_CLASS_ID(CMove, Type, 3)
704 DEFINE_CLASS_ID(SafePointScalarObject, Type, 4)
705 DEFINE_CLASS_ID(DecodeNarrowPtr, Type, 5)
706 DEFINE_CLASS_ID(DecodeN, DecodeNarrowPtr, 0)
707 DEFINE_CLASS_ID(DecodeNKlass, DecodeNarrowPtr, 1)
708 DEFINE_CLASS_ID(EncodeNarrowPtr, Type, 6)
709 DEFINE_CLASS_ID(EncodeP, EncodeNarrowPtr, 0)
710 DEFINE_CLASS_ID(EncodePKlass, EncodeNarrowPtr, 1)
711 DEFINE_CLASS_ID(Vector, Type, 7)
712 DEFINE_CLASS_ID(VectorMaskCmp, Vector, 0)
713 DEFINE_CLASS_ID(VectorUnbox, Vector, 1)
714 DEFINE_CLASS_ID(VectorReinterpret, Vector, 2)
715 DEFINE_CLASS_ID(ShiftV, Vector, 3)
716
717 DEFINE_CLASS_ID(Proj, Node, 3)
718 DEFINE_CLASS_ID(CatchProj, Proj, 0)
719 DEFINE_CLASS_ID(JumpProj, Proj, 1)
720 DEFINE_CLASS_ID(IfProj, Proj, 2)
721 DEFINE_CLASS_ID(IfTrue, IfProj, 0)
722 DEFINE_CLASS_ID(IfFalse, IfProj, 1)
723 DEFINE_CLASS_ID(Parm, Proj, 4)
724 DEFINE_CLASS_ID(MachProj, Proj, 5)
725
726 DEFINE_CLASS_ID(Mem, Node, 4)
727 DEFINE_CLASS_ID(Load, Mem, 0)
728 DEFINE_CLASS_ID(LoadVector, Load, 0)
729 DEFINE_CLASS_ID(LoadVectorGather, LoadVector, 0)
730 DEFINE_CLASS_ID(LoadVectorMasked, LoadVector, 1)
731 DEFINE_CLASS_ID(Store, Mem, 1)
732 DEFINE_CLASS_ID(StoreVector, Store, 0)
733 DEFINE_CLASS_ID(StoreVectorScatter, StoreVector, 0)
734 DEFINE_CLASS_ID(StoreVectorMasked, StoreVector, 1)
735 DEFINE_CLASS_ID(LoadStore, Mem, 2)
736 DEFINE_CLASS_ID(LoadStoreConditional, LoadStore, 0)
737 DEFINE_CLASS_ID(CompareAndSwap, LoadStoreConditional, 0)
738 DEFINE_CLASS_ID(CompareAndExchangeNode, LoadStore, 1)
739
740 DEFINE_CLASS_ID(Region, Node, 5)
741 DEFINE_CLASS_ID(Loop, Region, 0)
742 DEFINE_CLASS_ID(Root, Loop, 0)
743 DEFINE_CLASS_ID(BaseCountedLoop, Loop, 1)
744 DEFINE_CLASS_ID(CountedLoop, BaseCountedLoop, 0)
745 DEFINE_CLASS_ID(LongCountedLoop, BaseCountedLoop, 1)
746 DEFINE_CLASS_ID(OuterStripMinedLoop, Loop, 2)
747
748 DEFINE_CLASS_ID(Sub, Node, 6)
749 DEFINE_CLASS_ID(Cmp, Sub, 0)
750 DEFINE_CLASS_ID(FastLock, Cmp, 0)
751 DEFINE_CLASS_ID(FastUnlock, Cmp, 1)
752 DEFINE_CLASS_ID(SubTypeCheck,Cmp, 2)
753
754 DEFINE_CLASS_ID(MergeMem, Node, 7)
755 DEFINE_CLASS_ID(Bool, Node, 8)
756 DEFINE_CLASS_ID(AddP, Node, 9)
757 DEFINE_CLASS_ID(BoxLock, Node, 10)
758 DEFINE_CLASS_ID(Add, Node, 11)
759 DEFINE_CLASS_ID(Mul, Node, 12)
760 DEFINE_CLASS_ID(ClearArray, Node, 14)
761 DEFINE_CLASS_ID(Halt, Node, 15)
762 DEFINE_CLASS_ID(Opaque1, Node, 16)
763 DEFINE_CLASS_ID(Move, Node, 17)
764 DEFINE_CLASS_ID(LShift, Node, 18)
765
766 _max_classes = ClassMask_Move
767 };
768 #undef DEFINE_CLASS_ID
769
770 // Flags are sorted by usage frequency.
771 enum NodeFlags {
772 Flag_is_Copy = 1 << 0, // should be first bit to avoid shift
773 Flag_rematerialize = 1 << 1,
774 Flag_needs_anti_dependence_check = 1 << 2,
775 Flag_is_macro = 1 << 3,
776 Flag_is_Con = 1 << 4,
777 Flag_is_cisc_alternate = 1 << 5,
778 Flag_is_dead_loop_safe = 1 << 6,
779 Flag_may_be_short_branch = 1 << 7,
780 Flag_avoid_back_to_back_before = 1 << 8,
781 Flag_avoid_back_to_back_after = 1 << 9,
782 Flag_has_call = 1 << 10,
783 Flag_is_reduction = 1 << 11,
784 Flag_is_scheduled = 1 << 12,
785 Flag_has_vector_mask_set = 1 << 13,
786 Flag_is_expensive = 1 << 14,
787 Flag_is_predicated_vector = 1 << 15,
788 Flag_for_post_loop_opts_igvn = 1 << 16,
789 _last_flag = Flag_for_post_loop_opts_igvn
790 };
791
792 class PD;
793
794private:
795 juint _class_id;
796 juint _flags;
797
798 static juint max_flags();
799
800protected:
801 // These methods should be called from constructors only.
802 void init_class_id(juint c) {
803 _class_id = c; // cast out const
804 }
805 void init_flags(uint fl) {
806 assert(fl <= max_flags(), "invalid node flag")do { if (!(fl <= max_flags())) { (*g_assert_poison) = 'X';
; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.hpp"
, 806, "assert(" "fl <= max_flags()" ") failed", "invalid node flag"
); ::breakpoint(); } } while (0)
;
807 _flags |= fl;
808 }
809 void clear_flag(uint fl) {
810 assert(fl <= max_flags(), "invalid node flag")do { if (!(fl <= max_flags())) { (*g_assert_poison) = 'X';
; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.hpp"
, 810, "assert(" "fl <= max_flags()" ") failed", "invalid node flag"
); ::breakpoint(); } } while (0)
;
811 _flags &= ~fl;
812 }
813
814public:
815 const juint class_id() const { return _class_id; }
816
817 const juint flags() const { return _flags; }
818
819 void add_flag(juint fl) { init_flags(fl); }
820
821 void remove_flag(juint fl) { clear_flag(fl); }
822
823 // Return a dense integer opcode number
824 virtual int Opcode() const;
825
826 // Virtual inherited Node size
827 virtual uint size_of() const;
828
829 // Other interesting Node properties
830 #define DEFINE_CLASS_QUERY(type) \
831 bool is_##type() const { \
832 return ((_class_id & ClassMask_##type) == Class_##type); \
833 } \
834 type##Node *as_##type() const { \
835 assert(is_##type(), "invalid node class: %s", Name())do { if (!(is_##type())) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.hpp"
, 835, "assert(" "is_##type()" ") failed", "invalid node class: %s"
, Name()); ::breakpoint(); } } while (0)
; \
836 return (type##Node*)this; \
837 } \
838 type##Node* isa_##type() const { \
839 return (is_##type()) ? as_##type() : NULL__null; \
840 }
841
842 DEFINE_CLASS_QUERY(AbstractLock)
843 DEFINE_CLASS_QUERY(Add)
844 DEFINE_CLASS_QUERY(AddP)
845 DEFINE_CLASS_QUERY(Allocate)
846 DEFINE_CLASS_QUERY(AllocateArray)
847 DEFINE_CLASS_QUERY(ArrayCopy)
848 DEFINE_CLASS_QUERY(BaseCountedLoop)
849 DEFINE_CLASS_QUERY(BaseCountedLoopEnd)
850 DEFINE_CLASS_QUERY(Bool)
851 DEFINE_CLASS_QUERY(BoxLock)
852 DEFINE_CLASS_QUERY(Call)
853 DEFINE_CLASS_QUERY(CallNative)
854 DEFINE_CLASS_QUERY(CallDynamicJava)
855 DEFINE_CLASS_QUERY(CallJava)
856 DEFINE_CLASS_QUERY(CallLeaf)
857 DEFINE_CLASS_QUERY(CallLeafNoFP)
858 DEFINE_CLASS_QUERY(CallRuntime)
859 DEFINE_CLASS_QUERY(CallStaticJava)
860 DEFINE_CLASS_QUERY(Catch)
861 DEFINE_CLASS_QUERY(CatchProj)
862 DEFINE_CLASS_QUERY(CheckCastPP)
863 DEFINE_CLASS_QUERY(CastII)
864 DEFINE_CLASS_QUERY(CastLL)
865 DEFINE_CLASS_QUERY(ConstraintCast)
866 DEFINE_CLASS_QUERY(ClearArray)
867 DEFINE_CLASS_QUERY(CMove)
868 DEFINE_CLASS_QUERY(Cmp)
869 DEFINE_CLASS_QUERY(CountedLoop)
870 DEFINE_CLASS_QUERY(CountedLoopEnd)
871 DEFINE_CLASS_QUERY(DecodeNarrowPtr)
872 DEFINE_CLASS_QUERY(DecodeN)
873 DEFINE_CLASS_QUERY(DecodeNKlass)
874 DEFINE_CLASS_QUERY(EncodeNarrowPtr)
875 DEFINE_CLASS_QUERY(EncodeP)
876 DEFINE_CLASS_QUERY(EncodePKlass)
877 DEFINE_CLASS_QUERY(FastLock)
878 DEFINE_CLASS_QUERY(FastUnlock)
879 DEFINE_CLASS_QUERY(Halt)
880 DEFINE_CLASS_QUERY(If)
881 DEFINE_CLASS_QUERY(RangeCheck)
882 DEFINE_CLASS_QUERY(IfProj)
883 DEFINE_CLASS_QUERY(IfFalse)
884 DEFINE_CLASS_QUERY(IfTrue)
885 DEFINE_CLASS_QUERY(Initialize)
886 DEFINE_CLASS_QUERY(Jump)
887 DEFINE_CLASS_QUERY(JumpProj)
888 DEFINE_CLASS_QUERY(LongCountedLoop)
889 DEFINE_CLASS_QUERY(LongCountedLoopEnd)
890 DEFINE_CLASS_QUERY(Load)
891 DEFINE_CLASS_QUERY(LoadStore)
892 DEFINE_CLASS_QUERY(LoadStoreConditional)
893 DEFINE_CLASS_QUERY(Lock)
894 DEFINE_CLASS_QUERY(Loop)
895 DEFINE_CLASS_QUERY(LShift)
896 DEFINE_CLASS_QUERY(Mach)
897 DEFINE_CLASS_QUERY(MachBranch)
898 DEFINE_CLASS_QUERY(MachCall)
899 DEFINE_CLASS_QUERY(MachCallNative)
900 DEFINE_CLASS_QUERY(MachCallDynamicJava)
901 DEFINE_CLASS_QUERY(MachCallJava)
902 DEFINE_CLASS_QUERY(MachCallLeaf)
903 DEFINE_CLASS_QUERY(MachCallRuntime)
904 DEFINE_CLASS_QUERY(MachCallStaticJava)
905 DEFINE_CLASS_QUERY(MachConstantBase)
906 DEFINE_CLASS_QUERY(MachConstant)
907 DEFINE_CLASS_QUERY(MachGoto)
908 DEFINE_CLASS_QUERY(MachIf)
909 DEFINE_CLASS_QUERY(MachJump)
910 DEFINE_CLASS_QUERY(MachNullCheck)
911 DEFINE_CLASS_QUERY(MachProj)
912 DEFINE_CLASS_QUERY(MachReturn)
913 DEFINE_CLASS_QUERY(MachSafePoint)
914 DEFINE_CLASS_QUERY(MachSpillCopy)
915 DEFINE_CLASS_QUERY(MachTemp)
916 DEFINE_CLASS_QUERY(MachMemBar)
917 DEFINE_CLASS_QUERY(MachMerge)
918 DEFINE_CLASS_QUERY(Mem)
919 DEFINE_CLASS_QUERY(MemBar)
920 DEFINE_CLASS_QUERY(MemBarStoreStore)
921 DEFINE_CLASS_QUERY(MergeMem)
922 DEFINE_CLASS_QUERY(Move)
923 DEFINE_CLASS_QUERY(Mul)
924 DEFINE_CLASS_QUERY(Multi)
925 DEFINE_CLASS_QUERY(MultiBranch)
926 DEFINE_CLASS_QUERY(Opaque1)
927 DEFINE_CLASS_QUERY(OuterStripMinedLoop)
928 DEFINE_CLASS_QUERY(OuterStripMinedLoopEnd)
929 DEFINE_CLASS_QUERY(Parm)
930 DEFINE_CLASS_QUERY(PCTable)
931 DEFINE_CLASS_QUERY(Phi)
932 DEFINE_CLASS_QUERY(Proj)
933 DEFINE_CLASS_QUERY(Region)
934 DEFINE_CLASS_QUERY(Root)
935 DEFINE_CLASS_QUERY(SafePoint)
936 DEFINE_CLASS_QUERY(SafePointScalarObject)
937 DEFINE_CLASS_QUERY(Start)
938 DEFINE_CLASS_QUERY(Store)
939 DEFINE_CLASS_QUERY(Sub)
940 DEFINE_CLASS_QUERY(SubTypeCheck)
941 DEFINE_CLASS_QUERY(Type)
942 DEFINE_CLASS_QUERY(Vector)
943 DEFINE_CLASS_QUERY(VectorMaskCmp)
944 DEFINE_CLASS_QUERY(VectorUnbox)
945 DEFINE_CLASS_QUERY(VectorReinterpret);
946 DEFINE_CLASS_QUERY(LoadVector)
947 DEFINE_CLASS_QUERY(LoadVectorGather)
948 DEFINE_CLASS_QUERY(StoreVector)
949 DEFINE_CLASS_QUERY(StoreVectorScatter)
950 DEFINE_CLASS_QUERY(ShiftV)
951 DEFINE_CLASS_QUERY(Unlock)
952
953 #undef DEFINE_CLASS_QUERY
954
955 // duplicate of is_MachSpillCopy()
956 bool is_SpillCopy () const {
957 return ((_class_id & ClassMask_MachSpillCopy) == Class_MachSpillCopy);
958 }
959
960 bool is_Con () const { return (_flags & Flag_is_Con) != 0; }
961 // The data node which is safe to leave in dead loop during IGVN optimization.
962 bool is_dead_loop_safe() const;
963
964 // is_Copy() returns copied edge index (0 or 1)
965 uint is_Copy() const { return (_flags & Flag_is_Copy); }
966
967 virtual bool is_CFG() const { return false; }
968
969 // If this node is control-dependent on a test, can it be
970 // rerouted to a dominating equivalent test? This is usually
971 // true of non-CFG nodes, but can be false for operations which
972 // depend for their correct sequencing on more than one test.
973 // (In that case, hoisting to a dominating test may silently
974 // skip some other important test.)
975 virtual bool depends_only_on_test() const { assert(!is_CFG(), "")do { if (!(!is_CFG())) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.hpp"
, 975, "assert(" "!is_CFG()" ") failed", ""); ::breakpoint();
} } while (0)
; return true; };
976
977 // When building basic blocks, I need to have a notion of block beginning
978 // Nodes, next block selector Nodes (block enders), and next block
979 // projections. These calls need to work on their machine equivalents. The
980 // Ideal beginning Nodes are RootNode, RegionNode and StartNode.
981 bool is_block_start() const {
982 if ( is_Region() )
983 return this == (const Node*)in(0);
984 else
985 return is_Start();
986 }
987
988 // The Ideal control projection Nodes are IfTrue/IfFalse, JumpProjNode, Root,
989 // Goto and Return. This call also returns the block ending Node.
990 virtual const Node *is_block_proj() const;
991
992 // The node is a "macro" node which needs to be expanded before matching
993 bool is_macro() const { return (_flags & Flag_is_macro) != 0; }
994 // The node is expensive: the best control is set during loop opts
995 bool is_expensive() const { return (_flags & Flag_is_expensive) != 0 && in(0) != NULL__null; }
996
997 // An arithmetic node which accumulates a data in a loop.
998 // It must have the loop's phi as input and provide a def to the phi.
999 bool is_reduction() const { return (_flags & Flag_is_reduction) != 0; }
1000
1001 bool is_predicated_vector() const { return (_flags & Flag_is_predicated_vector) != 0; }
1002
1003 // The node is a CountedLoopEnd with a mask annotation so as to emit a restore context
1004 bool has_vector_mask_set() const { return (_flags & Flag_has_vector_mask_set) != 0; }
1005
1006 // Used in lcm to mark nodes that have scheduled
1007 bool is_scheduled() const { return (_flags & Flag_is_scheduled) != 0; }
1008
1009 bool for_post_loop_opts_igvn() const { return (_flags & Flag_for_post_loop_opts_igvn) != 0; }
1010
1011//----------------- Optimization
1012
1013 // Get the worst-case Type output for this Node.
1014 virtual const class Type *bottom_type() const;
1015
1016 // If we find a better type for a node, try to record it permanently.
1017 // Return true if this node actually changed.
1018 // Be sure to do the hash_delete game in the "rehash" variant.
1019 void raise_bottom_type(const Type* new_type);
1020
1021 // Get the address type with which this node uses and/or defs memory,
1022 // or NULL if none. The address type is conservatively wide.
1023 // Returns non-null for calls, membars, loads, stores, etc.
1024 // Returns TypePtr::BOTTOM if the node touches memory "broadly".
1025 virtual const class TypePtr *adr_type() const { return NULL__null; }
1026
1027 // Return an existing node which computes the same function as this node.
1028 // The optimistic combined algorithm requires this to return a Node which
1029 // is a small number of steps away (e.g., one of my inputs).
1030 virtual Node* Identity(PhaseGVN* phase);
1031
1032 // Return the set of values this Node can take on at runtime.
1033 virtual const Type* Value(PhaseGVN* phase) const;
1034
1035 // Return a node which is more "ideal" than the current node.
1036 // The invariants on this call are subtle. If in doubt, read the
1037 // treatise in node.cpp above the default implemention AND TEST WITH
1038 // +VerifyIterativeGVN!
1039 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
1040
1041 // Some nodes have specific Ideal subgraph transformations only if they are
1042 // unique users of specific nodes. Such nodes should be put on IGVN worklist
1043 // for the transformations to happen.
1044 bool has_special_unique_user() const;
1045
1046 // Skip Proj and CatchProj nodes chains. Check for Null and Top.
1047 Node* find_exact_control(Node* ctrl);
1048
1049 // Check if 'this' node dominates or equal to 'sub'.
1050 bool dominates(Node* sub, Node_List &nlist);
1051
1052protected:
1053 bool remove_dead_region(PhaseGVN *phase, bool can_reshape);
1054public:
1055
1056 // See if there is valid pipeline info
1057 static const Pipeline *pipeline_class();
1058 virtual const Pipeline *pipeline() const;
1059
1060 // Compute the latency from the def to this instruction of the ith input node
1061 uint latency(uint i);
1062
1063 // Hash & compare functions, for pessimistic value numbering
1064
1065 // If the hash function returns the special sentinel value NO_HASH,
1066 // the node is guaranteed never to compare equal to any other node.
1067 // If we accidentally generate a hash with value NO_HASH the node
1068 // won't go into the table and we'll lose a little optimization.
1069 static const uint NO_HASH = 0;
1070 virtual uint hash() const;
1071 virtual bool cmp( const Node &n ) const;
1072
1073 // Operation appears to be iteratively computed (such as an induction variable)
1074 // It is possible for this operation to return false for a loop-varying
1075 // value, if it appears (by local graph inspection) to be computed by a simple conditional.
1076 bool is_iteratively_computed();
1077
1078 // Determine if a node is a counted loop induction variable.
1079 // NOTE: The method is defined in "loopnode.cpp".
1080 bool is_cloop_ind_var() const;
1081
1082 // Return a node with opcode "opc" and same inputs as "this" if one can
1083 // be found; Otherwise return NULL;
1084 Node* find_similar(int opc);
1085
1086 // Return the unique control out if only one. Null if none or more than one.
1087 Node* unique_ctrl_out() const;
1088
1089 // Set control or add control as precedence edge
1090 void ensure_control_or_add_prec(Node* c);
1091
1092//----------------- Code Generation
1093
1094 // Ideal register class for Matching. Zero means unmatched instruction
1095 // (these are cloned instead of converted to machine nodes).
1096 virtual uint ideal_reg() const;
1097
1098 static const uint NotAMachineReg; // must be > max. machine register
1099
1100 // Do we Match on this edge index or not? Generally false for Control
1101 // and true for everything else. Weird for calls & returns.
1102 virtual uint match_edge(uint idx) const;
1103
1104 // Register class output is returned in
1105 virtual const RegMask &out_RegMask() const;
1106 // Register class input is expected in
1107 virtual const RegMask &in_RegMask(uint) const;
1108 // Should we clone rather than spill this instruction?
1109 bool rematerialize() const;
1110
1111 // Return JVM State Object if this Node carries debug info, or NULL otherwise
1112 virtual JVMState* jvms() const;
1113
1114 // Print as assembly
1115 virtual void format( PhaseRegAlloc *, outputStream* st = tty ) const;
1116 // Emit bytes starting at parameter 'ptr'
1117 // Bump 'ptr' by the number of output bytes
1118 virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const;
1119 // Size of instruction in bytes
1120 virtual uint size(PhaseRegAlloc *ra_) const;
1121
1122 // Convenience function to extract an integer constant from a node.
1123 // If it is not an integer constant (either Con, CastII, or Mach),
1124 // return value_if_unknown.
1125 jint find_int_con(jint value_if_unknown) const {
1126 const TypeInt* t = find_int_type();
1127 return (t != NULL__null && t->is_con()) ? t->get_con() : value_if_unknown;
1128 }
1129 // Return the constant, knowing it is an integer constant already
1130 jint get_int() const {
1131 const TypeInt* t = find_int_type();
1132 guarantee(t != NULL, "must be con")do { if (!(t != __null)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.hpp"
, 1132, "guarantee(" "t != NULL" ") failed", "must be con"); ::
breakpoint(); } } while (0)
;
1133 return t->get_con();
1134 }
1135 // Here's where the work is done. Can produce non-constant int types too.
1136 const TypeInt* find_int_type() const;
1137 const TypeInteger* find_integer_type(BasicType bt) const;
1138
1139 // Same thing for long (and intptr_t, via type.hpp):
1140 jlong get_long() const {
1141 const TypeLong* t = find_long_type();
1142 guarantee(t != NULL, "must be con")do { if (!(t != __null)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.hpp"
, 1142, "guarantee(" "t != NULL" ") failed", "must be con"); ::
breakpoint(); } } while (0)
;
1143 return t->get_con();
1144 }
1145 jlong find_long_con(jint value_if_unknown) const {
1146 const TypeLong* t = find_long_type();
1147 return (t != NULL__null && t->is_con()) ? t->get_con() : value_if_unknown;
1148 }
1149 const TypeLong* find_long_type() const;
1150
1151 jlong get_integer_as_long(BasicType bt) const {
1152 const TypeInteger* t = find_integer_type(bt);
1153 guarantee(t != NULL, "must be con")do { if (!(t != __null)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.hpp"
, 1153, "guarantee(" "t != NULL" ") failed", "must be con"); ::
breakpoint(); } } while (0)
;
1154 return t->get_con_as_long(bt);
1155 }
1156 const TypePtr* get_ptr_type() const;
1157
1158 // These guys are called by code generated by ADLC:
1159 intptr_t get_ptr() const;
1160 intptr_t get_narrowcon() const;
1161 jdouble getd() const;
1162 jfloat getf() const;
1163
1164 // Nodes which are pinned into basic blocks
1165 virtual bool pinned() const { return false; }
1166
1167 // Nodes which use memory without consuming it, hence need antidependences
1168 // More specifically, needs_anti_dependence_check returns true iff the node
1169 // (a) does a load, and (b) does not perform a store (except perhaps to a
1170 // stack slot or some other unaliased location).
1171 bool needs_anti_dependence_check() const;
1172
1173 // Return which operand this instruction may cisc-spill. In other words,
1174 // return operand position that can convert from reg to memory access
1175 virtual int cisc_operand() const { return AdlcVMDeps::Not_cisc_spillable; }
1176 bool is_cisc_alternate() const { return (_flags & Flag_is_cisc_alternate) != 0; }
1177
1178 // Whether this is a memory-writing machine node.
1179 bool is_memory_writer() const { return is_Mach() && bottom_type()->has_memory(); }
1180
1181//----------------- Printing, etc
1182#ifndef PRODUCT
1183 private:
1184 int _indent;
1185
1186 public:
1187 void set_indent(int indent) { _indent = indent; }
1188
1189 private:
1190 static bool add_to_worklist(Node* n, Node_List* worklist, Arena* old_arena, VectorSet* old_space, VectorSet* new_space);
1191public:
1192 Node* find(int idx, bool only_ctrl = false); // Search the graph for the given idx.
1193 Node* find_ctrl(int idx); // Search control ancestors for the given idx.
1194 void dump() const { dump("\n"); } // Print this node.
11
Calling 'Node::dump'
1195 void dump(const char* suffix, bool mark = false, outputStream *st = tty) const; // Print this node.
1196 void dump(int depth) const; // Print this node, recursively to depth d
1197 void dump_ctrl(int depth) const; // Print control nodes, to depth d
1198 void dump_comp() const; // Print this node in compact representation.
1199 // Print this node in compact representation.
1200 void dump_comp(const char* suffix, outputStream *st = tty) const;
1201 virtual void dump_req(outputStream *st = tty) const; // Print required-edge info
1202 virtual void dump_prec(outputStream *st = tty) const; // Print precedence-edge info
1203 virtual void dump_out(outputStream *st = tty) const; // Print the output edge info
1204 virtual void dump_spec(outputStream *st) const {}; // Print per-node info
1205 // Print compact per-node info
1206 virtual void dump_compact_spec(outputStream *st) const { dump_spec(st); }
1207 void dump_related() const; // Print related nodes (depends on node at hand).
1208 // Print related nodes up to given depths for input and output nodes.
1209 void dump_related(uint d_in, uint d_out) const;
1210 void dump_related_compact() const; // Print related nodes in compact representation.
1211 // Collect related nodes.
1212 virtual void related(GrowableArray<Node*> *in_rel, GrowableArray<Node*> *out_rel, bool compact) const;
1213 // Collect nodes starting from this node, explicitly including/excluding control and data links.
1214 void collect_nodes(GrowableArray<Node*> *ns, int d, bool ctrl, bool data) const;
1215
1216 // Node collectors, to be used in implementations of Node::rel().
1217 // Collect the entire data input graph. Include control inputs if requested.
1218 void collect_nodes_in_all_data(GrowableArray<Node*> *ns, bool ctrl) const;
1219 // Collect the entire control input graph. Include data inputs if requested.
1220 void collect_nodes_in_all_ctrl(GrowableArray<Node*> *ns, bool data) const;
1221 // Collect the entire output graph until hitting and including control nodes.
1222 void collect_nodes_out_all_ctrl_boundary(GrowableArray<Node*> *ns) const;
1223
1224 void verify_edges(Unique_Node_List &visited); // Verify bi-directional edges
1225 static void verify(int verify_depth, VectorSet& visited, Node_List& worklist);
1226
1227 // This call defines a class-unique string used to identify class instances
1228 virtual const char *Name() const;
1229
1230 void dump_format(PhaseRegAlloc *ra) const; // debug access to MachNode::format(...)
1231 // RegMask Print Functions
1232 void dump_in_regmask(int idx) { in_RegMask(idx).dump(); }
1233 void dump_out_regmask() { out_RegMask().dump(); }
1234 static bool in_dump() { return Compile::current()->_in_dump_cnt > 0; }
1235 void fast_dump() const {
1236 tty->print("%4d: %-17s", _idx, Name());
1237 for (uint i = 0; i < len(); i++)
1238 if (in(i))
1239 tty->print(" %4d", in(i)->_idx);
1240 else
1241 tty->print(" NULL");
1242 tty->print("\n");
1243 }
1244#endif
1245#ifdef ASSERT1
1246 void verify_construction();
1247 bool verify_jvms(const JVMState* jvms) const;
1248 int _debug_idx; // Unique value assigned to every node.
1249 int debug_idx() const { return _debug_idx; }
1250 void set_debug_idx( int debug_idx ) { _debug_idx = debug_idx; }
1251
1252 Node* _debug_orig; // Original version of this, if any.
1253 Node* debug_orig() const { return _debug_orig; }
1254 void set_debug_orig(Node* orig); // _debug_orig = orig
1255 void dump_orig(outputStream *st, bool print_key = true) const;
1256
1257 int _hash_lock; // Barrier to modifications of nodes in the hash table
1258 void enter_hash_lock() { ++_hash_lock; assert(_hash_lock < 99, "in too many hash tables?")do { if (!(_hash_lock < 99)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.hpp"
, 1258, "assert(" "_hash_lock < 99" ") failed", "in too many hash tables?"
); ::breakpoint(); } } while (0)
; }
1259 void exit_hash_lock() { --_hash_lock; assert(_hash_lock >= 0, "mispaired hash locks")do { if (!(_hash_lock >= 0)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.hpp"
, 1259, "assert(" "_hash_lock >= 0" ") failed", "mispaired hash locks"
); ::breakpoint(); } } while (0)
; }
1260
1261 static void init_NodeProperty();
1262
1263 #if OPTO_DU_ITERATOR_ASSERT1
1264 const Node* _last_del; // The last deleted node.
1265 uint _del_tick; // Bumped when a deletion happens..
1266 #endif
1267#endif
1268};
1269
1270inline bool not_a_node(const Node* n) {
1271 if (n == NULL__null) return true;
1272 if (((intptr_t)n & 1) != 0) return true; // uninitialized, etc.
1273 if (*(address*)n == badAddress((address)::badAddressVal)) return true; // kill by Node::destruct
1274 return false;
1275}
1276
1277//-----------------------------------------------------------------------------
1278// Iterators over DU info, and associated Node functions.
1279
1280#if OPTO_DU_ITERATOR_ASSERT1
1281
1282// Common code for assertion checking on DU iterators.
1283class DUIterator_Common {
1284#ifdef ASSERT1
1285 protected:
1286 bool _vdui; // cached value of VerifyDUIterators
1287 const Node* _node; // the node containing the _out array
1288 uint _outcnt; // cached node->_outcnt
1289 uint _del_tick; // cached node->_del_tick
1290 Node* _last; // last value produced by the iterator
1291
1292 void sample(const Node* node); // used by c'tor to set up for verifies
1293 void verify(const Node* node, bool at_end_ok = false);
1294 void verify_resync();
1295 void reset(const DUIterator_Common& that);
1296
1297// The VDUI_ONLY macro protects code conditionalized on VerifyDUIterators
1298 #define I_VDUI_ONLY(i,x) { if ((i)._vdui) { x; } }
1299#else
1300 #define I_VDUI_ONLY(i,x) { }
1301#endif //ASSERT
1302};
1303
1304#define VDUI_ONLY(x) I_VDUI_ONLY(*this, x)
1305
1306// Default DU iterator. Allows appends onto the out array.
1307// Allows deletion from the out array only at the current point.
1308// Usage:
1309// for (DUIterator i = x->outs(); x->has_out(i); i++) {
1310// Node* y = x->out(i);
1311// ...
1312// }
1313// Compiles in product mode to a unsigned integer index, which indexes
1314// onto a repeatedly reloaded base pointer of x->_out. The loop predicate
1315// also reloads x->_outcnt. If you delete, you must perform "--i" just
1316// before continuing the loop. You must delete only the last-produced
1317// edge. You must delete only a single copy of the last-produced edge,
1318// or else you must delete all copies at once (the first time the edge
1319// is produced by the iterator).
1320class DUIterator : public DUIterator_Common {
1321 friend class Node;
1322
1323 // This is the index which provides the product-mode behavior.
1324 // Whatever the product-mode version of the system does to the
1325 // DUI index is done to this index. All other fields in
1326 // this class are used only for assertion checking.
1327 uint _idx;
1328
1329 #ifdef ASSERT1
1330 uint _refresh_tick; // Records the refresh activity.
1331
1332 void sample(const Node* node); // Initialize _refresh_tick etc.
1333 void verify(const Node* node, bool at_end_ok = false);
1334 void verify_increment(); // Verify an increment operation.
1335 void verify_resync(); // Verify that we can back up over a deletion.
1336 void verify_finish(); // Verify that the loop terminated properly.
1337 void refresh(); // Resample verification info.
1338 void reset(const DUIterator& that); // Resample after assignment.
1339 #endif
1340
1341 DUIterator(const Node* node, int dummy_to_avoid_conversion)
1342 { _idx = 0; debug_only(sample(node))sample(node); }
1343
1344 public:
1345 // initialize to garbage; clear _vdui to disable asserts
1346 DUIterator()
1347 { /*initialize to garbage*/ debug_only(_vdui = false)_vdui = false; }
1348
1349 DUIterator(const DUIterator& that)
1350 { _idx = that._idx; debug_only(_vdui = false; reset(that))_vdui = false; reset(that); }
1351
1352 void operator++(int dummy_to_specify_postfix_op)
1353 { _idx++; VDUI_ONLY(verify_increment()); }
1354
1355 void operator--()
1356 { VDUI_ONLY(verify_resync()); --_idx; }
1357
1358 ~DUIterator()
1359 { VDUI_ONLY(verify_finish()); }
1360
1361 void operator=(const DUIterator& that)
1362 { _idx = that._idx; debug_only(reset(that))reset(that); }
1363};
1364
1365DUIterator Node::outs() const
1366 { return DUIterator(this, 0); }
1367DUIterator& Node::refresh_out_pos(DUIterator& i) const
1368 { I_VDUI_ONLY(i, i.refresh()); return i; }
1369bool Node::has_out(DUIterator& i) const
1370 { I_VDUI_ONLY(i, i.verify(this,true));return i._idx < _outcnt; }
1371Node* Node::out(DUIterator& i) const
1372 { I_VDUI_ONLY(i, i.verify(this)); return debug_only(i._last=)i._last= _out[i._idx]; }
1373
1374
1375// Faster DU iterator. Disallows insertions into the out array.
1376// Allows deletion from the out array only at the current point.
1377// Usage:
1378// for (DUIterator_Fast imax, i = x->fast_outs(imax); i < imax; i++) {
1379// Node* y = x->fast_out(i);
1380// ...
1381// }
1382// Compiles in product mode to raw Node** pointer arithmetic, with
1383// no reloading of pointers from the original node x. If you delete,
1384// you must perform "--i; --imax" just before continuing the loop.
1385// If you delete multiple copies of the same edge, you must decrement
1386// imax, but not i, multiple times: "--i, imax -= num_edges".
1387class DUIterator_Fast : public DUIterator_Common {
1388 friend class Node;
1389 friend class DUIterator_Last;
1390
1391 // This is the pointer which provides the product-mode behavior.
1392 // Whatever the product-mode version of the system does to the
1393 // DUI pointer is done to this pointer. All other fields in
1394 // this class are used only for assertion checking.
1395 Node** _outp;
1396
1397 #ifdef ASSERT1
1398 void verify(const Node* node, bool at_end_ok = false);
1399 void verify_limit();
1400 void verify_resync();
1401 void verify_relimit(uint n);
1402 void reset(const DUIterator_Fast& that);
1403 #endif
1404
1405 // Note: offset must be signed, since -1 is sometimes passed
1406 DUIterator_Fast(const Node* node, ptrdiff_t offset)
1407 { _outp = node->_out + offset; debug_only(sample(node))sample(node); }
1408
1409 public:
1410 // initialize to garbage; clear _vdui to disable asserts
1411 DUIterator_Fast()
1412 { /*initialize to garbage*/ debug_only(_vdui = false)_vdui = false; }
1413
1414 DUIterator_Fast(const DUIterator_Fast& that)
1415 { _outp = that._outp; debug_only(_vdui = false; reset(that))_vdui = false; reset(that); }
1416
1417 void operator++(int dummy_to_specify_postfix_op)
1418 { _outp++; VDUI_ONLY(verify(_node, true)); }
1419
1420 void operator--()
1421 { VDUI_ONLY(verify_resync()); --_outp; }
1422
1423 void operator-=(uint n) // applied to the limit only
1424 { _outp -= n; VDUI_ONLY(verify_relimit(n)); }
1425
1426 bool operator<(DUIterator_Fast& limit) {
1427 I_VDUI_ONLY(*this, this->verify(_node, true));
1428 I_VDUI_ONLY(limit, limit.verify_limit());
1429 return _outp < limit._outp;
1430 }
1431
1432 void operator=(const DUIterator_Fast& that)
1433 { _outp = that._outp; debug_only(reset(that))reset(that); }
1434};
1435
1436DUIterator_Fast Node::fast_outs(DUIterator_Fast& imax) const {
1437 // Assign a limit pointer to the reference argument:
1438 imax = DUIterator_Fast(this, (ptrdiff_t)_outcnt);
1439 // Return the base pointer:
1440 return DUIterator_Fast(this, 0);
1441}
1442Node* Node::fast_out(DUIterator_Fast& i) const {
1443 I_VDUI_ONLY(i, i.verify(this));
1444 return debug_only(i._last=)i._last= *i._outp;
1445}
1446
1447
1448// Faster DU iterator. Requires each successive edge to be removed.
1449// Does not allow insertion of any edges.
1450// Usage:
1451// for (DUIterator_Last imin, i = x->last_outs(imin); i >= imin; i -= num_edges) {
1452// Node* y = x->last_out(i);
1453// ...
1454// }
1455// Compiles in product mode to raw Node** pointer arithmetic, with
1456// no reloading of pointers from the original node x.
1457class DUIterator_Last : private DUIterator_Fast {
1458 friend class Node;
1459
1460 #ifdef ASSERT1
1461 void verify(const Node* node, bool at_end_ok = false);
1462 void verify_limit();
1463 void verify_step(uint num_edges);
1464 #endif
1465
1466 // Note: offset must be signed, since -1 is sometimes passed
1467 DUIterator_Last(const Node* node, ptrdiff_t offset)
1468 : DUIterator_Fast(node, offset) { }
1469
1470 void operator++(int dummy_to_specify_postfix_op) {} // do not use
1471 void operator<(int) {} // do not use
1472
1473 public:
1474 DUIterator_Last() { }
1475 // initialize to garbage
1476
1477 DUIterator_Last(const DUIterator_Last& that) = default;
1478
1479 void operator--()
1480 { _outp--; VDUI_ONLY(verify_step(1)); }
1481
1482 void operator-=(uint n)
1483 { _outp -= n; VDUI_ONLY(verify_step(n)); }
1484
1485 bool operator>=(DUIterator_Last& limit) {
1486 I_VDUI_ONLY(*this, this->verify(_node, true));
1487 I_VDUI_ONLY(limit, limit.verify_limit());
1488 return _outp >= limit._outp;
1489 }
1490
1491 DUIterator_Last& operator=(const DUIterator_Last& that) = default;
1492};
1493
1494DUIterator_Last Node::last_outs(DUIterator_Last& imin) const {
1495 // Assign a limit pointer to the reference argument:
1496 imin = DUIterator_Last(this, 0);
1497 // Return the initial pointer:
1498 return DUIterator_Last(this, (ptrdiff_t)_outcnt - 1);
1499}
1500Node* Node::last_out(DUIterator_Last& i) const {
1501 I_VDUI_ONLY(i, i.verify(this));
1502 return debug_only(i._last=)i._last= *i._outp;
1503}
1504
1505#endif //OPTO_DU_ITERATOR_ASSERT
1506
1507#undef I_VDUI_ONLY
1508#undef VDUI_ONLY
1509
1510// An Iterator that truly follows the iterator pattern. Doesn't
1511// support deletion but could be made to.
1512//
1513// for (SimpleDUIterator i(n); i.has_next(); i.next()) {
1514// Node* m = i.get();
1515//
1516class SimpleDUIterator : public StackObj {
1517 private:
1518 Node* node;
1519 DUIterator_Fast i;
1520 DUIterator_Fast imax;
1521 public:
1522 SimpleDUIterator(Node* n): node(n), i(n->fast_outs(imax)) {}
1523 bool has_next() { return i < imax; }
1524 void next() { i++; }
1525 Node* get() { return node->fast_out(i); }
1526};
1527
1528
1529//-----------------------------------------------------------------------------
1530// Map dense integer indices to Nodes. Uses classic doubling-array trick.
1531// Abstractly provides an infinite array of Node*'s, initialized to NULL.
1532// Note that the constructor just zeros things, and since I use Arena
1533// allocation I do not need a destructor to reclaim storage.
1534class Node_Array : public ResourceObj {
1535 friend class VMStructs;
1536protected:
1537 Arena* _a; // Arena to allocate in
1538 uint _max;
1539 Node** _nodes;
1540 void grow( uint i ); // Grow array node to fit
1541public:
1542 Node_Array(Arena* a, uint max = OptoNodeListSize) : _a(a), _max(max) {
1543 _nodes = NEW_ARENA_ARRAY(a, Node*, max)(Node**) (a)->Amalloc((max) * sizeof(Node*));
1544 clear();
1545 }
1546
1547 Node_Array(Node_Array* na) : _a(na->_a), _max(na->_max), _nodes(na->_nodes) {}
1548 Node *operator[] ( uint i ) const // Lookup, or NULL for not mapped
1549 { return (i<_max) ? _nodes[i] : (Node*)NULL__null; }
1550 Node* at(uint i) const { assert(i<_max,"oob")do { if (!(i<_max)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.hpp"
, 1550, "assert(" "i<_max" ") failed", "oob"); ::breakpoint
(); } } while (0)
; return _nodes[i]; }
1551 Node** adr() { return _nodes; }
1552 // Extend the mapping: index i maps to Node *n.
1553 void map( uint i, Node *n ) { if( i>=_max ) grow(i); _nodes[i] = n; }
1554 void insert( uint i, Node *n );
1555 void remove( uint i ); // Remove, preserving order
1556 // Clear all entries in _nodes to NULL but keep storage
1557 void clear() {
1558 Copy::zero_to_bytes(_nodes, _max * sizeof(Node*));
1559 }
1560
1561 uint Size() const { return _max; }
1562 void dump() const;
1563};
1564
1565class Node_List : public Node_Array {
1566 friend class VMStructs;
1567 uint _cnt;
1568public:
1569 Node_List(uint max = OptoNodeListSize) : Node_Array(Thread::current()->resource_area(), max), _cnt(0) {}
1570 Node_List(Arena *a, uint max = OptoNodeListSize) : Node_Array(a, max), _cnt(0) {}
1571 bool contains(const Node* n) const {
1572 for (uint e = 0; e < size(); e++) {
1573 if (at(e) == n) return true;
1574 }
1575 return false;
1576 }
1577 void insert( uint i, Node *n ) { Node_Array::insert(i,n); _cnt++; }
1578 void remove( uint i ) { Node_Array::remove(i); _cnt--; }
1579 void push( Node *b ) { map(_cnt++,b); }
1580 void yank( Node *n ); // Find and remove
1581 Node *pop() { return _nodes[--_cnt]; }
1582 void clear() { _cnt = 0; Node_Array::clear(); } // retain storage
1583 void copy(const Node_List& from) {
1584 if (from._max > _max) {
1585 grow(from._max);
1586 }
1587 _cnt = from._cnt;
1588 Copy::conjoint_words_to_higher((HeapWord*)&from._nodes[0], (HeapWord*)&_nodes[0], from._max * sizeof(Node*));
1589 }
1590
1591 uint size() const { return _cnt; }
1592 void dump() const;
1593 void dump_simple() const;
1594};
1595
1596//------------------------------Unique_Node_List-------------------------------
1597class Unique_Node_List : public Node_List {
1598 friend class VMStructs;
1599 VectorSet _in_worklist;
1600 uint _clock_index; // Index in list where to pop from next
1601public:
1602 Unique_Node_List() : Node_List(), _clock_index(0) {}
1603 Unique_Node_List(Arena *a) : Node_List(a), _in_worklist(a), _clock_index(0) {}
1604
1605 void remove( Node *n );
1606 bool member( Node *n ) { return _in_worklist.test(n->_idx) != 0; }
1607 VectorSet& member_set(){ return _in_worklist; }
1608
1609 void push(Node* b) {
1610 if( !_in_worklist.test_set(b->_idx) )
1611 Node_List::push(b);
1612 }
1613 Node *pop() {
1614 if( _clock_index >= size() ) _clock_index = 0;
1615 Node *b = at(_clock_index);
1616 map( _clock_index, Node_List::pop());
1617 if (size() != 0) _clock_index++; // Always start from 0
1618 _in_worklist.remove(b->_idx);
1619 return b;
1620 }
1621 Node *remove(uint i) {
1622 Node *b = Node_List::at(i);
1623 _in_worklist.remove(b->_idx);
1624 map(i,Node_List::pop());
1625 return b;
1626 }
1627 void yank(Node *n) {
1628 _in_worklist.remove(n->_idx);
1629 Node_List::yank(n);
1630 }
1631 void clear() {
1632 _in_worklist.clear(); // Discards storage but grows automatically
1633 Node_List::clear();
1634 _clock_index = 0;
1635 }
1636
1637 // Used after parsing to remove useless nodes before Iterative GVN
1638 void remove_useless_nodes(VectorSet& useful);
1639
1640 bool contains(const Node* n) const {
1641 fatal("use faster member() instead")do { (*g_assert_poison) = 'X';; report_fatal(INTERNAL_ERROR, "/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.hpp"
, 1641, "use faster member() instead"); ::breakpoint(); } while
(0)
;
1642 return false;
1643 }
1644
1645#ifndef PRODUCT
1646 void print_set() const { _in_worklist.print(); }
1647#endif
1648};
1649
1650// Inline definition of Compile::record_for_igvn must be deferred to this point.
1651inline void Compile::record_for_igvn(Node* n) {
1652 _for_igvn->push(n);
1653}
1654
1655//------------------------------Node_Stack-------------------------------------
1656class Node_Stack {
1657 friend class VMStructs;
1658protected:
1659 struct INode {
1660 Node *node; // Processed node
1661 uint indx; // Index of next node's child
1662 };
1663 INode *_inode_top; // tos, stack grows up
1664 INode *_inode_max; // End of _inodes == _inodes + _max
1665 INode *_inodes; // Array storage for the stack
1666 Arena *_a; // Arena to allocate in
1667 void grow();
1668public:
1669 Node_Stack(int size) {
1670 size_t max = (size > OptoNodeListSize) ? size : OptoNodeListSize;
1671 _a = Thread::current()->resource_area();
1672 _inodes = NEW_ARENA_ARRAY( _a, INode, max )(INode*) (_a)->Amalloc((max) * sizeof(INode));
1673 _inode_max = _inodes + max;
1674 _inode_top = _inodes - 1; // stack is empty
1675 }
1676
1677 Node_Stack(Arena *a, int size) : _a(a) {
1678 size_t max = (size > OptoNodeListSize) ? size : OptoNodeListSize;
1679 _inodes = NEW_ARENA_ARRAY( _a, INode, max )(INode*) (_a)->Amalloc((max) * sizeof(INode));
1680 _inode_max = _inodes + max;
1681 _inode_top = _inodes - 1; // stack is empty
1682 }
1683
1684 void pop() {
1685 assert(_inode_top >= _inodes, "node stack underflow")do { if (!(_inode_top >= _inodes)) { (*g_assert_poison) = 'X'
;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.hpp"
, 1685, "assert(" "_inode_top >= _inodes" ") failed", "node stack underflow"
); ::breakpoint(); } } while (0)
;
1686 --_inode_top;
1687 }
1688 void push(Node *n, uint i) {
1689 ++_inode_top;
1690 if (_inode_top >= _inode_max) grow();
1691 INode *top = _inode_top; // optimization
1692 top->node = n;
1693 top->indx = i;
1694 }
1695 Node *node() const {
1696 return _inode_top->node;
1697 }
1698 Node* node_at(uint i) const {
1699 assert(_inodes + i <= _inode_top, "in range")do { if (!(_inodes + i <= _inode_top)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.hpp"
, 1699, "assert(" "_inodes + i <= _inode_top" ") failed", "in range"
); ::breakpoint(); } } while (0)
;
1700 return _inodes[i].node;
1701 }
1702 uint index() const {
1703 return _inode_top->indx;
1704 }
1705 uint index_at(uint i) const {
1706 assert(_inodes + i <= _inode_top, "in range")do { if (!(_inodes + i <= _inode_top)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.hpp"
, 1706, "assert(" "_inodes + i <= _inode_top" ") failed", "in range"
); ::breakpoint(); } } while (0)
;
1707 return _inodes[i].indx;
1708 }
1709 void set_node(Node *n) {
1710 _inode_top->node = n;
1711 }
1712 void set_index(uint i) {
1713 _inode_top->indx = i;
1714 }
1715 uint size_max() const { return (uint)pointer_delta(_inode_max, _inodes, sizeof(INode)); } // Max size
1716 uint size() const { return (uint)pointer_delta((_inode_top+1), _inodes, sizeof(INode)); } // Current size
1717 bool is_nonempty() const { return (_inode_top >= _inodes); }
1718 bool is_empty() const { return (_inode_top < _inodes); }
1719 void clear() { _inode_top = _inodes - 1; } // retain storage
1720
1721 // Node_Stack is used to map nodes.
1722 Node* find(uint idx) const;
1723};
1724
1725
1726//-----------------------------Node_Notes--------------------------------------
1727// Debugging or profiling annotations loosely and sparsely associated
1728// with some nodes. See Compile::node_notes_at for the accessor.
1729class Node_Notes {
1730 friend class VMStructs;
1731 JVMState* _jvms;
1732
1733public:
1734 Node_Notes(JVMState* jvms = NULL__null) {
1735 _jvms = jvms;
1736 }
1737
1738 JVMState* jvms() { return _jvms; }
1739 void set_jvms(JVMState* x) { _jvms = x; }
1740
1741 // True if there is nothing here.
1742 bool is_clear() {
1743 return (_jvms == NULL__null);
1744 }
1745
1746 // Make there be nothing here.
1747 void clear() {
1748 _jvms = NULL__null;
1749 }
1750
1751 // Make a new, clean node notes.
1752 static Node_Notes* make(Compile* C) {
1753 Node_Notes* nn = NEW_ARENA_ARRAY(C->comp_arena(), Node_Notes, 1)(Node_Notes*) (C->comp_arena())->Amalloc((1) * sizeof(Node_Notes
))
;
1754 nn->clear();
1755 return nn;
1756 }
1757
1758 Node_Notes* clone(Compile* C) {
1759 Node_Notes* nn = NEW_ARENA_ARRAY(C->comp_arena(), Node_Notes, 1)(Node_Notes*) (C->comp_arena())->Amalloc((1) * sizeof(Node_Notes
))
;
1760 (*nn) = (*this);
1761 return nn;
1762 }
1763
1764 // Absorb any information from source.
1765 bool update_from(Node_Notes* source) {
1766 bool changed = false;
1767 if (source != NULL__null) {
1768 if (source->jvms() != NULL__null) {
1769 set_jvms(source->jvms());
1770 changed = true;
1771 }
1772 }
1773 return changed;
1774 }
1775};
1776
1777// Inlined accessors for Compile::node_nodes that require the preceding class:
1778inline Node_Notes*
1779Compile::locate_node_notes(GrowableArray<Node_Notes*>* arr,
1780 int idx, bool can_grow) {
1781 assert(idx >= 0, "oob")do { if (!(idx >= 0)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.hpp"
, 1781, "assert(" "idx >= 0" ") failed", "oob"); ::breakpoint
(); } } while (0)
;
1782 int block_idx = (idx >> _log2_node_notes_block_size);
1783 int grow_by = (block_idx - (arr == NULL__null? 0: arr->length()));
1784 if (grow_by >= 0) {
1785 if (!can_grow) return NULL__null;
1786 grow_node_notes(arr, grow_by + 1);
1787 }
1788 if (arr == NULL__null) return NULL__null;
1789 // (Every element of arr is a sub-array of length _node_notes_block_size.)
1790 return arr->at(block_idx) + (idx & (_node_notes_block_size-1));
1791}
1792
1793inline bool
1794Compile::set_node_notes_at(int idx, Node_Notes* value) {
1795 if (value == NULL__null || value->is_clear())
1796 return false; // nothing to write => write nothing
1797 Node_Notes* loc = locate_node_notes(_node_note_array, idx, true);
1798 assert(loc != NULL, "")do { if (!(loc != __null)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.hpp"
, 1798, "assert(" "loc != __null" ") failed", ""); ::breakpoint
(); } } while (0)
;
1799 return loc->update_from(value);
1800}
1801
1802
1803//------------------------------TypeNode---------------------------------------
1804// Node with a Type constant.
1805class TypeNode : public Node {
1806protected:
1807 virtual uint hash() const; // Check the type
1808 virtual bool cmp( const Node &n ) const;
1809 virtual uint size_of() const; // Size is bigger
1810 const Type* const _type;
1811public:
1812 void set_type(const Type* t) {
1813 assert(t != NULL, "sanity")do { if (!(t != __null)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.hpp"
, 1813, "assert(" "t != __null" ") failed", "sanity"); ::breakpoint
(); } } while (0)
;
1814 debug_only(uint check_hash = (VerifyHashTableKeys && _hash_lock) ? hash() : NO_HASH)uint check_hash = (VerifyHashTableKeys && _hash_lock)
? hash() : NO_HASH
;
1815 *(const Type**)&_type = t; // cast away const-ness
1816 // If this node is in the hash table, make sure it doesn't need a rehash.
1817 assert(check_hash == NO_HASH || check_hash == hash(), "type change must preserve hash code")do { if (!(check_hash == NO_HASH || check_hash == hash())) { (
*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.hpp"
, 1817, "assert(" "check_hash == NO_HASH || check_hash == hash()"
") failed", "type change must preserve hash code"); ::breakpoint
(); } } while (0)
;
1818 }
1819 const Type* type() const { assert(_type != NULL, "sanity")do { if (!(_type != __null)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.hpp"
, 1819, "assert(" "_type != __null" ") failed", "sanity"); ::
breakpoint(); } } while (0)
; return _type; };
1820 TypeNode( const Type *t, uint required ) : Node(required), _type(t) {
1821 init_class_id(Class_Type);
1822 }
1823 virtual const Type* Value(PhaseGVN* phase) const;
1824 virtual const Type *bottom_type() const;
1825 virtual uint ideal_reg() const;
1826#ifndef PRODUCT
1827 virtual void dump_spec(outputStream *st) const;
1828 virtual void dump_compact_spec(outputStream *st) const;
1829#endif
1830};
1831
1832#include "opto/opcodes.hpp"
1833
1834#define Op_IL(op)inline int Op_op(BasicType bt) { do { if (!(bt == T_INT || bt
== T_LONG)) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.hpp"
, 1834, "assert(" "bt == T_INT || bt == T_LONG" ") failed", "only for int or longs"
); ::breakpoint(); } } while (0); if (bt == T_INT) { return Op_opI
; } return Op_opL; }
\
1835 inline int Op_ ## op(BasicType bt) { \
1836 assert(bt == T_INT || bt == T_LONG, "only for int or longs")do { if (!(bt == T_INT || bt == T_LONG)) { (*g_assert_poison)
= 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.hpp"
, 1836, "assert(" "bt == T_INT || bt == T_LONG" ") failed", "only for int or longs"
); ::breakpoint(); } } while (0)
; \
1837 if (bt == T_INT) { \
1838 return Op_## op ## I; \
1839 } \
1840 return Op_## op ## L; \
1841}
1842
1843Op_IL(Add)inline int Op_Add(BasicType bt) { do { if (!(bt == T_INT || bt
== T_LONG)) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.hpp"
, 1843, "assert(" "bt == T_INT || bt == T_LONG" ") failed", "only for int or longs"
); ::breakpoint(); } } while (0); if (bt == T_INT) { return Op_AddI
; } return Op_AddL; }
1844Op_IL(Sub)inline int Op_Sub(BasicType bt) { do { if (!(bt == T_INT || bt
== T_LONG)) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.hpp"
, 1844, "assert(" "bt == T_INT || bt == T_LONG" ") failed", "only for int or longs"
); ::breakpoint(); } } while (0); if (bt == T_INT) { return Op_SubI
; } return Op_SubL; }
1845Op_IL(Mul)inline int Op_Mul(BasicType bt) { do { if (!(bt == T_INT || bt
== T_LONG)) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.hpp"
, 1845, "assert(" "bt == T_INT || bt == T_LONG" ") failed", "only for int or longs"
); ::breakpoint(); } } while (0); if (bt == T_INT) { return Op_MulI
; } return Op_MulL; }
1846Op_IL(URShift)inline int Op_URShift(BasicType bt) { do { if (!(bt == T_INT ||
bt == T_LONG)) { (*g_assert_poison) = 'X';; report_vm_error(
"/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.hpp"
, 1846, "assert(" "bt == T_INT || bt == T_LONG" ") failed", "only for int or longs"
); ::breakpoint(); } } while (0); if (bt == T_INT) { return Op_URShiftI
; } return Op_URShiftL; }
1847Op_IL(LShift)inline int Op_LShift(BasicType bt) { do { if (!(bt == T_INT ||
bt == T_LONG)) { (*g_assert_poison) = 'X';; report_vm_error(
"/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.hpp"
, 1847, "assert(" "bt == T_INT || bt == T_LONG" ") failed", "only for int or longs"
); ::breakpoint(); } } while (0); if (bt == T_INT) { return Op_LShiftI
; } return Op_LShiftL; }
1848Op_IL(Xor)inline int Op_Xor(BasicType bt) { do { if (!(bt == T_INT || bt
== T_LONG)) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.hpp"
, 1848, "assert(" "bt == T_INT || bt == T_LONG" ") failed", "only for int or longs"
); ::breakpoint(); } } while (0); if (bt == T_INT) { return Op_XorI
; } return Op_XorL; }
1849Op_IL(Cmp)inline int Op_Cmp(BasicType bt) { do { if (!(bt == T_INT || bt
== T_LONG)) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.hpp"
, 1849, "assert(" "bt == T_INT || bt == T_LONG" ") failed", "only for int or longs"
); ::breakpoint(); } } while (0); if (bt == T_INT) { return Op_CmpI
; } return Op_CmpL; }
1850
1851inline int Op_Cmp_unsigned(BasicType bt) {
1852 assert(bt == T_INT || bt == T_LONG, "only for int or longs")do { if (!(bt == T_INT || bt == T_LONG)) { (*g_assert_poison)
= 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.hpp"
, 1852, "assert(" "bt == T_INT || bt == T_LONG" ") failed", "only for int or longs"
); ::breakpoint(); } } while (0)
;
1853 if (bt == T_INT) {
1854 return Op_CmpU;
1855 }
1856 return Op_CmpUL;
1857}
1858
1859inline int Op_Cast(BasicType bt) {
1860 assert(bt == T_INT || bt == T_LONG, "only for int or longs")do { if (!(bt == T_INT || bt == T_LONG)) { (*g_assert_poison)
= 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/node.hpp"
, 1860, "assert(" "bt == T_INT || bt == T_LONG" ") failed", "only for int or longs"
); ::breakpoint(); } } while (0)
;
1861 if (bt == T_INT) {
1862 return Op_CastII;
1863 }
1864 return Op_CastLL;
1865}
1866
1867#endif // SHARE_OPTO_NODE_HPP