Bug Summary

File:jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp
Warning:line 159, column 9
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 shenandoahSupport.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/gc/shenandoah/c2/shenandoahSupport.cpp

/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp

1/*
2 * Copyright (c) 2015, 2021, Red Hat, Inc. 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
27#include "classfile/javaClasses.hpp"
28#include "gc/shenandoah/c2/shenandoahSupport.hpp"
29#include "gc/shenandoah/c2/shenandoahBarrierSetC2.hpp"
30#include "gc/shenandoah/shenandoahBarrierSetAssembler.hpp"
31#include "gc/shenandoah/shenandoahForwarding.hpp"
32#include "gc/shenandoah/shenandoahHeap.hpp"
33#include "gc/shenandoah/shenandoahHeapRegion.hpp"
34#include "gc/shenandoah/shenandoahRuntime.hpp"
35#include "gc/shenandoah/shenandoahThreadLocalData.hpp"
36#include "opto/arraycopynode.hpp"
37#include "opto/block.hpp"
38#include "opto/callnode.hpp"
39#include "opto/castnode.hpp"
40#include "opto/movenode.hpp"
41#include "opto/phaseX.hpp"
42#include "opto/rootnode.hpp"
43#include "opto/runtime.hpp"
44#include "opto/subnode.hpp"
45
46bool ShenandoahBarrierC2Support::expand(Compile* C, PhaseIterGVN& igvn) {
47 ShenandoahBarrierSetC2State* state = ShenandoahBarrierSetC2::bsc2()->state();
48 if ((state->iu_barriers_count() +
49 state->load_reference_barriers_count()) > 0) {
50 assert(C->post_loop_opts_phase(), "no loop opts allowed")do { if (!(C->post_loop_opts_phase())) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 50, "assert(" "C->post_loop_opts_phase()" ") failed", "no loop opts allowed"
); ::breakpoint(); } } while (0)
;
51 C->reset_post_loop_opts_phase(); // ... but we know what we are doing
52 bool attempt_more_loopopts = ShenandoahLoopOptsAfterExpansion;
53 C->clear_major_progress();
54 PhaseIdealLoop::optimize(igvn, LoopOptsShenandoahExpand);
55 if (C->failing()) return false;
56 PhaseIdealLoop::verify(igvn);
57 if (attempt_more_loopopts) {
58 C->set_major_progress();
59 if (!C->optimize_loops(igvn, LoopOptsShenandoahPostExpand)) {
60 return false;
61 }
62 C->clear_major_progress();
63
64 C->process_for_post_loop_opts_igvn(igvn);
65 }
66 C->set_post_loop_opts_phase(); // now for real!
67 }
68 return true;
69}
70
71bool ShenandoahBarrierC2Support::is_gc_state_test(Node* iff, int mask) {
72 if (!UseShenandoahGC) {
73 return false;
74 }
75 assert(iff->is_If(), "bad input")do { if (!(iff->is_If())) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 75, "assert(" "iff->is_If()" ") failed", "bad input"); ::
breakpoint(); } } while (0)
;
76 if (iff->Opcode() != Op_If) {
77 return false;
78 }
79 Node* bol = iff->in(1);
80 if (!bol->is_Bool() || bol->as_Bool()->_test._test != BoolTest::ne) {
81 return false;
82 }
83 Node* cmp = bol->in(1);
84 if (cmp->Opcode() != Op_CmpI) {
85 return false;
86 }
87 Node* in1 = cmp->in(1);
88 Node* in2 = cmp->in(2);
89 if (in2->find_int_con(-1) != 0) {
90 return false;
91 }
92 if (in1->Opcode() != Op_AndI) {
93 return false;
94 }
95 in2 = in1->in(2);
96 if (in2->find_int_con(-1) != mask) {
97 return false;
98 }
99 in1 = in1->in(1);
100
101 return is_gc_state_load(in1);
102}
103
104bool ShenandoahBarrierC2Support::is_heap_stable_test(Node* iff) {
105 return is_gc_state_test(iff, ShenandoahHeap::HAS_FORWARDED);
106}
107
108bool ShenandoahBarrierC2Support::is_gc_state_load(Node *n) {
109 if (!UseShenandoahGC) {
110 return false;
111 }
112 if (n->Opcode() != Op_LoadB && n->Opcode() != Op_LoadUB) {
113 return false;
114 }
115 Node* addp = n->in(MemNode::Address);
116 if (!addp->is_AddP()) {
117 return false;
118 }
119 Node* base = addp->in(AddPNode::Address);
120 Node* off = addp->in(AddPNode::Offset);
121 if (base->Opcode() != Op_ThreadLocal) {
122 return false;
123 }
124 if (off->find_intptr_t_confind_long_con(-1) != in_bytes(ShenandoahThreadLocalData::gc_state_offset())) {
125 return false;
126 }
127 return true;
128}
129
130bool ShenandoahBarrierC2Support::has_safepoint_between(Node* start, Node* stop, PhaseIdealLoop *phase) {
131 assert(phase->is_dominator(stop, start), "bad inputs")do { if (!(phase->is_dominator(stop, start))) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 131, "assert(" "phase->is_dominator(stop, start)" ") failed"
, "bad inputs"); ::breakpoint(); } } while (0)
;
132 ResourceMark rm;
133 Unique_Node_List wq;
134 wq.push(start);
135 for (uint next = 0; next < wq.size(); next++) {
136 Node *m = wq.at(next);
137 if (m == stop) {
138 continue;
139 }
140 if (m->is_SafePoint() && !m->is_CallLeaf()) {
141 return true;
142 }
143 if (m->is_Region()) {
144 for (uint i = 1; i < m->req(); i++) {
145 wq.push(m->in(i));
146 }
147 } else {
148 wq.push(m->in(0));
149 }
150 }
151 return false;
152}
153
154#ifdef ASSERT1
155bool ShenandoahBarrierC2Support::verify_helper(Node* in, Node_Stack& phis, VectorSet& visited, verify_type t, bool trace, Unique_Node_List& barriers_used) {
156 assert(phis.size() == 0, "")do { if (!(phis.size() == 0)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 156, "assert(" "phis.size() == 0" ") failed", ""); ::breakpoint
(); } } while (0)
;
29
Taking false branch
30
Loop condition is false. Exiting loop
42
Taking false branch
43
Loop condition is false. Exiting loop
157
158 while (true) {
31
Loop condition is true. Entering loop body
44
Loop condition is true. Entering loop body
159 if (in->bottom_type() == TypePtr::NULL_PTR) {
32
Assuming the condition is true
33
Taking true branch
45
Called C++ object pointer is null
160 if (trace
33.1
'trace' is false
33.1
'trace' is false
) {tty->print_cr("NULL");}
34
Taking false branch
161 } else if (!in->bottom_type()->make_ptr()->make_oopptr()) {
162 if (trace) {tty->print_cr("Non oop");}
163 } else {
164 if (in->is_ConstraintCast()) {
165 in = in->in(1);
166 continue;
167 } else if (in->is_AddP()) {
168 assert(!in->in(AddPNode::Address)->is_top(), "no raw memory access")do { if (!(!in->in(AddPNode::Address)->is_top())) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 168, "assert(" "!in->in(AddPNode::Address)->is_top()"
") failed", "no raw memory access"); ::breakpoint(); } } while
(0)
;
169 in = in->in(AddPNode::Address);
170 continue;
171 } else if (in->is_Con()) {
172 if (trace) {
173 tty->print("Found constant");
174 in->dump();
175 }
176 } else if (in->Opcode() == Op_Parm) {
177 if (trace) {
178 tty->print("Found argument");
179 }
180 } else if (in->Opcode() == Op_CreateEx) {
181 if (trace) {
182 tty->print("Found create-exception");
183 }
184 } else if (in->Opcode() == Op_LoadP && in->adr_type() == TypeRawPtr::BOTTOM) {
185 if (trace) {
186 tty->print("Found raw LoadP (OSR argument?)");
187 }
188 } else if (in->Opcode() == Op_ShenandoahLoadReferenceBarrier) {
189 if (t == ShenandoahOopStore) {
190 uint i = 0;
191 for (; i < phis.size(); i++) {
192 Node* n = phis.node_at(i);
193 if (n->Opcode() == Op_ShenandoahIUBarrier) {
194 break;
195 }
196 }
197 if (i == phis.size()) {
198 return false;
199 }
200 }
201 barriers_used.push(in);
202 if (trace) {tty->print("Found barrier"); in->dump();}
203 } else if (in->Opcode() == Op_ShenandoahIUBarrier) {
204 if (t != ShenandoahOopStore) {
205 in = in->in(1);
206 continue;
207 }
208 if (trace) {tty->print("Found enqueue barrier"); in->dump();}
209 phis.push(in, in->req());
210 in = in->in(1);
211 continue;
212 } else if (in->is_Proj() && in->in(0)->is_Allocate()) {
213 if (trace) {
214 tty->print("Found alloc");
215 in->in(0)->dump();
216 }
217 } else if (in->is_Proj() && (in->in(0)->Opcode() == Op_CallStaticJava || in->in(0)->Opcode() == Op_CallDynamicJava)) {
218 if (trace) {
219 tty->print("Found Java call");
220 }
221 } else if (in->is_Phi()) {
222 if (!visited.test_set(in->_idx)) {
223 if (trace) {tty->print("Pushed phi:"); in->dump();}
224 phis.push(in, 2);
225 in = in->in(1);
226 continue;
227 }
228 if (trace) {tty->print("Already seen phi:"); in->dump();}
229 } else if (in->Opcode() == Op_CMoveP || in->Opcode() == Op_CMoveN) {
230 if (!visited.test_set(in->_idx)) {
231 if (trace) {tty->print("Pushed cmovep:"); in->dump();}
232 phis.push(in, CMoveNode::IfTrue);
233 in = in->in(CMoveNode::IfFalse);
234 continue;
235 }
236 if (trace) {tty->print("Already seen cmovep:"); in->dump();}
237 } else if (in->Opcode() == Op_EncodeP || in->Opcode() == Op_DecodeN) {
238 in = in->in(1);
239 continue;
240 } else {
241 return false;
242 }
243 }
244 bool cont = false;
245 while (phis.is_nonempty()) {
35
Loop condition is false. Execution continues on line 259
246 uint idx = phis.index();
247 Node* phi = phis.node();
248 if (idx >= phi->req()) {
249 if (trace) {tty->print("Popped phi:"); phi->dump();}
250 phis.pop();
251 continue;
252 }
253 if (trace) {tty->print("Next entry(%d) for phi:", idx); phi->dump();}
254 in = phi->in(idx);
255 phis.set_index(idx+1);
256 cont = true;
257 break;
258 }
259 if (!cont
35.1
'cont' is false
35.1
'cont' is false
) {
36
Taking true branch
260 break;
37
Execution continues on line 263
261 }
262 }
263 return true;
38
Returning the value 1, which participates in a condition later
264}
265
266void ShenandoahBarrierC2Support::report_verify_failure(const char* msg, Node* n1, Node* n2) {
267 if (n1 != NULL__null) {
268 n1->dump(+10);
269 }
270 if (n2 != NULL__null) {
271 n2->dump(+10);
272 }
273 fatal("%s", msg)do { (*g_assert_poison) = 'X';; report_fatal(INTERNAL_ERROR, "/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 273, "%s", msg); ::breakpoint(); } while (0)
;
274}
275
276void ShenandoahBarrierC2Support::verify(RootNode* root) {
277 ResourceMark rm;
278 Unique_Node_List wq;
279 GrowableArray<Node*> barriers;
280 Unique_Node_List barriers_used;
281 Node_Stack phis(0);
282 VectorSet visited;
283 const bool trace = false;
284 const bool verify_no_useless_barrier = false;
285
286 wq.push(root);
287 for (uint next = 0; next < wq.size(); next++) {
1
Assuming the condition is true
2
Loop condition is true. Entering loop body
288 Node *n = wq.at(next);
289 if (n->is_Load()) {
3
Calling 'Node::is_Load'
6
Returning from 'Node::is_Load'
7
Taking false branch
290 const bool trace = false;
291 if (trace) {tty->print("Verifying"); n->dump();}
292 if (n->Opcode() == Op_LoadRange || n->Opcode() == Op_LoadKlass || n->Opcode() == Op_LoadNKlass) {
293 if (trace) {tty->print_cr("Load range/klass");}
294 } else {
295 const TypePtr* adr_type = n->as_Load()->adr_type();
296
297 if (adr_type->isa_oopptr() && adr_type->is_oopptr()->offset() == oopDesc::mark_offset_in_bytes()) {
298 if (trace) {tty->print_cr("Mark load");}
299 } else if (adr_type->isa_instptr() &&
300 adr_type->is_instptr()->klass()->is_subtype_of(Compile::current()->env()->Reference_klass()) &&
301 adr_type->is_instptr()->offset() == java_lang_ref_Reference::referent_offset()) {
302 if (trace) {tty->print_cr("Reference.get()");}
303 } else if (!verify_helper(n->in(MemNode::Address), phis, visited, ShenandoahLoad, trace, barriers_used)) {
304 report_verify_failure("Shenandoah verification: Load should have barriers", n);
305 }
306 }
307 } else if (n->is_Store()) {
8
Calling 'Node::is_Store'
11
Returning from 'Node::is_Store'
12
Taking false branch
308 const bool trace = false;
309
310 if (trace) {tty->print("Verifying"); n->dump();}
311 if (n->in(MemNode::ValueIn)->bottom_type()->make_oopptr()) {
312 Node* adr = n->in(MemNode::Address);
313 bool verify = true;
314
315 if (adr->is_AddP() && adr->in(AddPNode::Base)->is_top()) {
316 adr = adr->in(AddPNode::Address);
317 if (adr->is_AddP()) {
318 assert(adr->in(AddPNode::Base)->is_top(), "")do { if (!(adr->in(AddPNode::Base)->is_top())) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 318, "assert(" "adr->in(AddPNode::Base)->is_top()" ") failed"
, ""); ::breakpoint(); } } while (0)
;
319 adr = adr->in(AddPNode::Address);
320 if (adr->Opcode() == Op_LoadP &&
321 adr->in(MemNode::Address)->in(AddPNode::Base)->is_top() &&
322 adr->in(MemNode::Address)->in(AddPNode::Address)->Opcode() == Op_ThreadLocal &&
323 adr->in(MemNode::Address)->in(AddPNode::Offset)->find_intptr_t_confind_long_con(-1) == in_bytes(ShenandoahThreadLocalData::satb_mark_queue_buffer_offset())) {
324 if (trace) {tty->print_cr("SATB prebarrier");}
325 verify = false;
326 }
327 }
328 }
329
330 if (verify && !verify_helper(n->in(MemNode::ValueIn), phis, visited, ShenandoahIUBarrier ? ShenandoahOopStore : ShenandoahValue, trace, barriers_used)) {
331 report_verify_failure("Shenandoah verification: Store should have barriers", n);
332 }
333 }
334 if (!verify_helper(n->in(MemNode::Address), phis, visited, ShenandoahStore, trace, barriers_used)) {
335 report_verify_failure("Shenandoah verification: Store (address) should have barriers", n);
336 }
337 } else if (n->Opcode() == Op_CmpP) {
13
Assuming the condition is false
14
Taking false branch
338 const bool trace = false;
339
340 Node* in1 = n->in(1);
341 Node* in2 = n->in(2);
342 if (in1->bottom_type()->isa_oopptr()) {
343 if (trace) {tty->print("Verifying"); n->dump();}
344
345 bool mark_inputs = false;
346 if (in1->bottom_type() == TypePtr::NULL_PTR || in2->bottom_type() == TypePtr::NULL_PTR ||
347 (in1->is_Con() || in2->is_Con())) {
348 if (trace) {tty->print_cr("Comparison against a constant");}
349 mark_inputs = true;
350 } else if ((in1->is_CheckCastPP() && in1->in(1)->is_Proj() && in1->in(1)->in(0)->is_Allocate()) ||
351 (in2->is_CheckCastPP() && in2->in(1)->is_Proj() && in2->in(1)->in(0)->is_Allocate())) {
352 if (trace) {tty->print_cr("Comparison with newly alloc'ed object");}
353 mark_inputs = true;
354 } else {
355 assert(in2->bottom_type()->isa_oopptr(), "")do { if (!(in2->bottom_type()->isa_oopptr())) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 355, "assert(" "in2->bottom_type()->isa_oopptr()" ") failed"
, ""); ::breakpoint(); } } while (0)
;
356
357 if (!verify_helper(in1, phis, visited, ShenandoahStore, trace, barriers_used) ||
358 !verify_helper(in2, phis, visited, ShenandoahStore, trace, barriers_used)) {
359 report_verify_failure("Shenandoah verification: Cmp should have barriers", n);
360 }
361 }
362 if (verify_no_useless_barrier &&
363 mark_inputs &&
364 (!verify_helper(in1, phis, visited, ShenandoahValue, trace, barriers_used) ||
365 !verify_helper(in2, phis, visited, ShenandoahValue, trace, barriers_used))) {
366 phis.clear();
367 visited.reset();
368 }
369 }
370 } else if (n->is_LoadStore()) {
15
Calling 'Node::is_LoadStore'
18
Returning from 'Node::is_LoadStore'
19
Taking false branch
371 if (n->in(MemNode::ValueIn)->bottom_type()->make_ptr() &&
372 !verify_helper(n->in(MemNode::ValueIn), phis, visited, ShenandoahIUBarrier ? ShenandoahOopStore : ShenandoahValue, trace, barriers_used)) {
373 report_verify_failure("Shenandoah verification: LoadStore (value) should have barriers", n);
374 }
375
376 if (n->in(MemNode::Address)->bottom_type()->make_oopptr() && !verify_helper(n->in(MemNode::Address), phis, visited, ShenandoahStore, trace, barriers_used)) {
377 report_verify_failure("Shenandoah verification: LoadStore (address) should have barriers", n);
378 }
379 } else if (n->Opcode() == Op_CallLeafNoFP || n->Opcode() == Op_CallLeaf) {
20
Assuming the condition is false
21
Assuming the condition is true
22
Taking true branch
380 CallNode* call = n->as_Call();
381
382 static struct {
383 const char* name;
384 struct {
385 int pos;
386 verify_type t;
387 } args[6];
388 } calls[] = {
389 "aescrypt_encryptBlock",
390 { { TypeFunc::Parms, ShenandoahLoad }, { TypeFunc::Parms+1, ShenandoahStore }, { TypeFunc::Parms+2, ShenandoahLoad },
391 { -1, ShenandoahNone}, { -1, ShenandoahNone}, { -1, ShenandoahNone} },
392 "aescrypt_decryptBlock",
393 { { TypeFunc::Parms, ShenandoahLoad }, { TypeFunc::Parms+1, ShenandoahStore }, { TypeFunc::Parms+2, ShenandoahLoad },
394 { -1, ShenandoahNone}, { -1, ShenandoahNone}, { -1, ShenandoahNone} },
395 "multiplyToLen",
396 { { TypeFunc::Parms, ShenandoahLoad }, { TypeFunc::Parms+2, ShenandoahLoad }, { TypeFunc::Parms+4, ShenandoahStore },
397 { -1, ShenandoahNone}, { -1, ShenandoahNone}, { -1, ShenandoahNone} },
398 "squareToLen",
399 { { TypeFunc::Parms, ShenandoahLoad }, { TypeFunc::Parms+2, ShenandoahLoad }, { -1, ShenandoahNone},
400 { -1, ShenandoahNone}, { -1, ShenandoahNone}, { -1, ShenandoahNone} },
401 "montgomery_multiply",
402 { { TypeFunc::Parms, ShenandoahLoad }, { TypeFunc::Parms+1, ShenandoahLoad }, { TypeFunc::Parms+2, ShenandoahLoad },
403 { TypeFunc::Parms+6, ShenandoahStore }, { -1, ShenandoahNone}, { -1, ShenandoahNone} },
404 "montgomery_square",
405 { { TypeFunc::Parms, ShenandoahLoad }, { TypeFunc::Parms+1, ShenandoahLoad }, { TypeFunc::Parms+5, ShenandoahStore },
406 { -1, ShenandoahNone}, { -1, ShenandoahNone}, { -1, ShenandoahNone} },
407 "mulAdd",
408 { { TypeFunc::Parms, ShenandoahStore }, { TypeFunc::Parms+1, ShenandoahLoad }, { -1, ShenandoahNone},
409 { -1, ShenandoahNone}, { -1, ShenandoahNone}, { -1, ShenandoahNone} },
410 "vectorizedMismatch",
411 { { TypeFunc::Parms, ShenandoahLoad }, { TypeFunc::Parms+1, ShenandoahLoad }, { -1, ShenandoahNone},
412 { -1, ShenandoahNone}, { -1, ShenandoahNone}, { -1, ShenandoahNone} },
413 "updateBytesCRC32",
414 { { TypeFunc::Parms+1, ShenandoahLoad }, { -1, ShenandoahNone}, { -1, ShenandoahNone},
415 { -1, ShenandoahNone}, { -1, ShenandoahNone}, { -1, ShenandoahNone} },
416 "updateBytesAdler32",
417 { { TypeFunc::Parms+1, ShenandoahLoad }, { -1, ShenandoahNone}, { -1, ShenandoahNone},
418 { -1, ShenandoahNone}, { -1, ShenandoahNone}, { -1, ShenandoahNone} },
419 "updateBytesCRC32C",
420 { { TypeFunc::Parms+1, ShenandoahLoad }, { TypeFunc::Parms+3, ShenandoahLoad}, { -1, ShenandoahNone},
421 { -1, ShenandoahNone}, { -1, ShenandoahNone}, { -1, ShenandoahNone} },
422 "counterMode_AESCrypt",
423 { { TypeFunc::Parms, ShenandoahLoad }, { TypeFunc::Parms+1, ShenandoahStore }, { TypeFunc::Parms+2, ShenandoahLoad },
424 { TypeFunc::Parms+3, ShenandoahStore }, { TypeFunc::Parms+5, ShenandoahStore }, { TypeFunc::Parms+6, ShenandoahStore } },
425 "cipherBlockChaining_encryptAESCrypt",
426 { { TypeFunc::Parms, ShenandoahLoad }, { TypeFunc::Parms+1, ShenandoahStore }, { TypeFunc::Parms+2, ShenandoahLoad },
427 { TypeFunc::Parms+3, ShenandoahLoad }, { -1, ShenandoahNone}, { -1, ShenandoahNone} },
428 "cipherBlockChaining_decryptAESCrypt",
429 { { TypeFunc::Parms, ShenandoahLoad }, { TypeFunc::Parms+1, ShenandoahStore }, { TypeFunc::Parms+2, ShenandoahLoad },
430 { TypeFunc::Parms+3, ShenandoahLoad }, { -1, ShenandoahNone}, { -1, ShenandoahNone} },
431 "shenandoah_clone_barrier",
432 { { TypeFunc::Parms, ShenandoahLoad }, { -1, ShenandoahNone}, { -1, ShenandoahNone},
433 { -1, ShenandoahNone}, { -1, ShenandoahNone}, { -1, ShenandoahNone} },
434 "ghash_processBlocks",
435 { { TypeFunc::Parms, ShenandoahStore }, { TypeFunc::Parms+1, ShenandoahLoad }, { TypeFunc::Parms+2, ShenandoahLoad },
436 { -1, ShenandoahNone}, { -1, ShenandoahNone}, { -1, ShenandoahNone} },
437 "sha1_implCompress",
438 { { TypeFunc::Parms, ShenandoahLoad }, { TypeFunc::Parms+1, ShenandoahStore }, { -1, ShenandoahNone },
439 { -1, ShenandoahNone}, { -1, ShenandoahNone}, { -1, ShenandoahNone} },
440 "sha256_implCompress",
441 { { TypeFunc::Parms, ShenandoahLoad }, { TypeFunc::Parms+1, ShenandoahStore }, { -1, ShenandoahNone },
442 { -1, ShenandoahNone}, { -1, ShenandoahNone}, { -1, ShenandoahNone} },
443 "sha512_implCompress",
444 { { TypeFunc::Parms, ShenandoahLoad }, { TypeFunc::Parms+1, ShenandoahStore }, { -1, ShenandoahNone },
445 { -1, ShenandoahNone}, { -1, ShenandoahNone}, { -1, ShenandoahNone} },
446 "sha1_implCompressMB",
447 { { TypeFunc::Parms, ShenandoahLoad }, { TypeFunc::Parms+1, ShenandoahStore }, { -1, ShenandoahNone },
448 { -1, ShenandoahNone}, { -1, ShenandoahNone}, { -1, ShenandoahNone} },
449 "sha256_implCompressMB",
450 { { TypeFunc::Parms, ShenandoahLoad }, { TypeFunc::Parms+1, ShenandoahStore }, { -1, ShenandoahNone },
451 { -1, ShenandoahNone}, { -1, ShenandoahNone}, { -1, ShenandoahNone} },
452 "sha512_implCompressMB",
453 { { TypeFunc::Parms, ShenandoahLoad }, { TypeFunc::Parms+1, ShenandoahStore }, { -1, ShenandoahNone },
454 { -1, ShenandoahNone}, { -1, ShenandoahNone}, { -1, ShenandoahNone} },
455 "encodeBlock",
456 { { TypeFunc::Parms, ShenandoahLoad }, { TypeFunc::Parms+3, ShenandoahStore }, { -1, ShenandoahNone },
457 { -1, ShenandoahNone}, { -1, ShenandoahNone}, { -1, ShenandoahNone} },
458 "decodeBlock",
459 { { TypeFunc::Parms, ShenandoahLoad }, { TypeFunc::Parms+3, ShenandoahStore }, { -1, ShenandoahNone },
460 { -1, ShenandoahNone}, { -1, ShenandoahNone}, { -1, ShenandoahNone} },
461 };
462
463 if (call->is_call_to_arraycopystub()) {
23
Assuming the condition is true
24
Taking true branch
464 Node* dest = NULL__null;
25
'dest' initialized to a null pointer value
465 const TypeTuple* args = n->as_Call()->_tf->domain();
466 for (uint i = TypeFunc::Parms, j = 0; i < args->cnt(); i++) {
26
Assuming the condition is false
27
Loop condition is false. Execution continues on line 475
467 if (args->field_at(i)->isa_ptr()) {
468 j++;
469 if (j == 2) {
470 dest = n->in(i);
471 break;
472 }
473 }
474 }
475 if (!verify_helper(n->in(TypeFunc::Parms), phis, visited, ShenandoahLoad, trace, barriers_used) ||
28
Calling 'ShenandoahBarrierC2Support::verify_helper'
39
Returning from 'ShenandoahBarrierC2Support::verify_helper'
476 !verify_helper(dest, phis, visited, ShenandoahStore, trace, barriers_used)) {
40
Passing null pointer value via 1st parameter 'in'
41
Calling 'ShenandoahBarrierC2Support::verify_helper'
477 report_verify_failure("Shenandoah verification: ArrayCopy should have barriers", n);
478 }
479 } else if (strlen(call->_name) > 5 &&
480 !strcmp(call->_name + strlen(call->_name) - 5, "_fill")) {
481 if (!verify_helper(n->in(TypeFunc::Parms), phis, visited, ShenandoahStore, trace, barriers_used)) {
482 report_verify_failure("Shenandoah verification: _fill should have barriers", n);
483 }
484 } else if (!strcmp(call->_name, "shenandoah_wb_pre")) {
485 // skip
486 } else {
487 const int calls_len = sizeof(calls) / sizeof(calls[0]);
488 int i = 0;
489 for (; i < calls_len; i++) {
490 if (!strcmp(calls[i].name, call->_name)) {
491 break;
492 }
493 }
494 if (i != calls_len) {
495 const uint args_len = sizeof(calls[0].args) / sizeof(calls[0].args[0]);
496 for (uint j = 0; j < args_len; j++) {
497 int pos = calls[i].args[j].pos;
498 if (pos == -1) {
499 break;
500 }
501 if (!verify_helper(call->in(pos), phis, visited, calls[i].args[j].t, trace, barriers_used)) {
502 report_verify_failure("Shenandoah verification: intrinsic calls should have barriers", n);
503 }
504 }
505 for (uint j = TypeFunc::Parms; j < call->req(); j++) {
506 if (call->in(j)->bottom_type()->make_ptr() &&
507 call->in(j)->bottom_type()->make_ptr()->isa_oopptr()) {
508 uint k = 0;
509 for (; k < args_len && calls[i].args[k].pos != (int)j; k++);
510 if (k == args_len) {
511 fatal("arg %d for call %s not covered", j, call->_name)do { (*g_assert_poison) = 'X';; report_fatal(INTERNAL_ERROR, "/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 511, "arg %d for call %s not covered", j, call->_name); ::
breakpoint(); } while (0)
;
512 }
513 }
514 }
515 } else {
516 for (uint j = TypeFunc::Parms; j < call->req(); j++) {
517 if (call->in(j)->bottom_type()->make_ptr() &&
518 call->in(j)->bottom_type()->make_ptr()->isa_oopptr()) {
519 fatal("%s not covered", call->_name)do { (*g_assert_poison) = 'X';; report_fatal(INTERNAL_ERROR, "/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 519, "%s not covered", call->_name); ::breakpoint(); } while
(0)
;
520 }
521 }
522 }
523 }
524 } else if (n->Opcode() == Op_ShenandoahIUBarrier || n->Opcode() == Op_ShenandoahLoadReferenceBarrier) {
525 // skip
526 } else if (n->is_AddP()
527 || n->is_Phi()
528 || n->is_ConstraintCast()
529 || n->Opcode() == Op_Return
530 || n->Opcode() == Op_CMoveP
531 || n->Opcode() == Op_CMoveN
532 || n->Opcode() == Op_Rethrow
533 || n->is_MemBar()
534 || n->Opcode() == Op_Conv2B
535 || n->Opcode() == Op_SafePoint
536 || n->is_CallJava()
537 || n->Opcode() == Op_Unlock
538 || n->Opcode() == Op_EncodeP
539 || n->Opcode() == Op_DecodeN) {
540 // nothing to do
541 } else {
542 static struct {
543 int opcode;
544 struct {
545 int pos;
546 verify_type t;
547 } inputs[2];
548 } others[] = {
549 Op_FastLock,
550 { { 1, ShenandoahLoad }, { -1, ShenandoahNone} },
551 Op_Lock,
552 { { TypeFunc::Parms, ShenandoahLoad }, { -1, ShenandoahNone} },
553 Op_ArrayCopy,
554 { { ArrayCopyNode::Src, ShenandoahLoad }, { ArrayCopyNode::Dest, ShenandoahStore } },
555 Op_StrCompressedCopy,
556 { { 2, ShenandoahLoad }, { 3, ShenandoahStore } },
557 Op_StrInflatedCopy,
558 { { 2, ShenandoahLoad }, { 3, ShenandoahStore } },
559 Op_AryEq,
560 { { 2, ShenandoahLoad }, { 3, ShenandoahLoad } },
561 Op_StrIndexOf,
562 { { 2, ShenandoahLoad }, { 4, ShenandoahLoad } },
563 Op_StrComp,
564 { { 2, ShenandoahLoad }, { 4, ShenandoahLoad } },
565 Op_StrEquals,
566 { { 2, ShenandoahLoad }, { 3, ShenandoahLoad } },
567 Op_EncodeISOArray,
568 { { 2, ShenandoahLoad }, { 3, ShenandoahStore } },
569 Op_HasNegatives,
570 { { 2, ShenandoahLoad }, { -1, ShenandoahNone} },
571 Op_CastP2X,
572 { { 1, ShenandoahLoad }, { -1, ShenandoahNone} },
573 Op_StrIndexOfChar,
574 { { 2, ShenandoahLoad }, { -1, ShenandoahNone } },
575 };
576
577 const int others_len = sizeof(others) / sizeof(others[0]);
578 int i = 0;
579 for (; i < others_len; i++) {
580 if (others[i].opcode == n->Opcode()) {
581 break;
582 }
583 }
584 uint stop = n->is_Call() ? n->as_Call()->tf()->domain()->cnt() : n->req();
585 if (i != others_len) {
586 const uint inputs_len = sizeof(others[0].inputs) / sizeof(others[0].inputs[0]);
587 for (uint j = 0; j < inputs_len; j++) {
588 int pos = others[i].inputs[j].pos;
589 if (pos == -1) {
590 break;
591 }
592 if (!verify_helper(n->in(pos), phis, visited, others[i].inputs[j].t, trace, barriers_used)) {
593 report_verify_failure("Shenandoah verification: intrinsic calls should have barriers", n);
594 }
595 }
596 for (uint j = 1; j < stop; j++) {
597 if (n->in(j) != NULL__null && n->in(j)->bottom_type()->make_ptr() &&
598 n->in(j)->bottom_type()->make_ptr()->make_oopptr()) {
599 uint k = 0;
600 for (; k < inputs_len && others[i].inputs[k].pos != (int)j; k++);
601 if (k == inputs_len) {
602 fatal("arg %d for node %s not covered", j, n->Name())do { (*g_assert_poison) = 'X';; report_fatal(INTERNAL_ERROR, "/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 602, "arg %d for node %s not covered", j, n->Name()); ::
breakpoint(); } while (0)
;
603 }
604 }
605 }
606 } else {
607 for (uint j = 1; j < stop; j++) {
608 if (n->in(j) != NULL__null && n->in(j)->bottom_type()->make_ptr() &&
609 n->in(j)->bottom_type()->make_ptr()->make_oopptr()) {
610 fatal("%s not covered", n->Name())do { (*g_assert_poison) = 'X';; report_fatal(INTERNAL_ERROR, "/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 610, "%s not covered", n->Name()); ::breakpoint(); } while
(0)
;
611 }
612 }
613 }
614 }
615
616 if (n->is_SafePoint()) {
617 SafePointNode* sfpt = n->as_SafePoint();
618 if (verify_no_useless_barrier && sfpt->jvms() != NULL__null) {
619 for (uint i = sfpt->jvms()->scloff(); i < sfpt->jvms()->endoff(); i++) {
620 if (!verify_helper(sfpt->in(i), phis, visited, ShenandoahLoad, trace, barriers_used)) {
621 phis.clear();
622 visited.reset();
623 }
624 }
625 }
626 }
627 }
628
629 if (verify_no_useless_barrier) {
630 for (int i = 0; i < barriers.length(); i++) {
631 Node* n = barriers.at(i);
632 if (!barriers_used.member(n)) {
633 tty->print("XXX useless barrier"); n->dump(-2);
634 ShouldNotReachHere()do { (*g_assert_poison) = 'X';; report_should_not_reach_here(
"/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 634); ::breakpoint(); } while (0)
;
635 }
636 }
637 }
638}
639#endif
640
641bool ShenandoahBarrierC2Support::is_dominator_same_ctrl(Node* c, Node* d, Node* n, PhaseIdealLoop* phase) {
642 // That both nodes have the same control is not sufficient to prove
643 // domination, verify that there's no path from d to n
644 ResourceMark rm;
645 Unique_Node_List wq;
646 wq.push(d);
647 for (uint next = 0; next < wq.size(); next++) {
648 Node *m = wq.at(next);
649 if (m == n) {
650 return false;
651 }
652 if (m->is_Phi() && m->in(0)->is_Loop()) {
653 assert(phase->ctrl_or_self(m->in(LoopNode::EntryControl)) != c, "following loop entry should lead to new control")do { if (!(phase->ctrl_or_self(m->in(LoopNode::EntryControl
)) != c)) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 653, "assert(" "phase->ctrl_or_self(m->in(LoopNode::EntryControl)) != c"
") failed", "following loop entry should lead to new control"
); ::breakpoint(); } } while (0)
;
654 } else {
655 if (m->is_Store() || m->is_LoadStore()) {
656 // Take anti-dependencies into account
657 Node* mem = m->in(MemNode::Memory);
658 for (DUIterator_Fast imax, i = mem->fast_outs(imax); i < imax; i++) {
659 Node* u = mem->fast_out(i);
660 if (u->is_Load() && phase->C->can_alias(m->adr_type(), phase->C->get_alias_index(u->adr_type())) &&
661 phase->ctrl_or_self(u) == c) {
662 wq.push(u);
663 }
664 }
665 }
666 for (uint i = 0; i < m->req(); i++) {
667 if (m->in(i) != NULL__null && phase->ctrl_or_self(m->in(i)) == c) {
668 wq.push(m->in(i));
669 }
670 }
671 }
672 }
673 return true;
674}
675
676bool ShenandoahBarrierC2Support::is_dominator(Node* d_c, Node* n_c, Node* d, Node* n, PhaseIdealLoop* phase) {
677 if (d_c != n_c) {
678 return phase->is_dominator(d_c, n_c);
679 }
680 return is_dominator_same_ctrl(d_c, d, n, phase);
681}
682
683Node* next_mem(Node* mem, int alias) {
684 Node* res = NULL__null;
685 if (mem->is_Proj()) {
686 res = mem->in(0);
687 } else if (mem->is_SafePoint() || mem->is_MemBar()) {
688 res = mem->in(TypeFunc::Memory);
689 } else if (mem->is_Phi()) {
690 res = mem->in(1);
691 } else if (mem->is_MergeMem()) {
692 res = mem->as_MergeMem()->memory_at(alias);
693 } else if (mem->is_Store() || mem->is_LoadStore() || mem->is_ClearArray()) {
694 assert(alias == Compile::AliasIdxRaw, "following raw memory can't lead to a barrier")do { if (!(alias == Compile::AliasIdxRaw)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 694, "assert(" "alias == Compile::AliasIdxRaw" ") failed", "following raw memory can't lead to a barrier"
); ::breakpoint(); } } while (0)
;
695 res = mem->in(MemNode::Memory);
696 } else {
697#ifdef ASSERT1
698 mem->dump();
699#endif
700 ShouldNotReachHere()do { (*g_assert_poison) = 'X';; report_should_not_reach_here(
"/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 700); ::breakpoint(); } while (0)
;
701 }
702 return res;
703}
704
705Node* ShenandoahBarrierC2Support::no_branches(Node* c, Node* dom, bool allow_one_proj, PhaseIdealLoop* phase) {
706 Node* iffproj = NULL__null;
707 while (c != dom) {
708 Node* next = phase->idom(c);
709 assert(next->unique_ctrl_out() == c || c->is_Proj() || c->is_Region(), "multiple control flow out but no proj or region?")do { if (!(next->unique_ctrl_out() == c || c->is_Proj()
|| c->is_Region())) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 709, "assert(" "next->unique_ctrl_out() == c || c->is_Proj() || c->is_Region()"
") failed", "multiple control flow out but no proj or region?"
); ::breakpoint(); } } while (0)
;
710 if (c->is_Region()) {
711 ResourceMark rm;
712 Unique_Node_List wq;
713 wq.push(c);
714 for (uint i = 0; i < wq.size(); i++) {
715 Node *n = wq.at(i);
716 if (n == next) {
717 continue;
718 }
719 if (n->is_Region()) {
720 for (uint j = 1; j < n->req(); j++) {
721 wq.push(n->in(j));
722 }
723 } else {
724 wq.push(n->in(0));
725 }
726 }
727 for (uint i = 0; i < wq.size(); i++) {
728 Node *n = wq.at(i);
729 assert(n->is_CFG(), "")do { if (!(n->is_CFG())) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 729, "assert(" "n->is_CFG()" ") failed", ""); ::breakpoint
(); } } while (0)
;
730 if (n->is_Multi()) {
731 for (DUIterator_Fast jmax, j = n->fast_outs(jmax); j < jmax; j++) {
732 Node* u = n->fast_out(j);
733 if (u->is_CFG()) {
734 if (!wq.member(u) && !u->as_Proj()->is_uncommon_trap_proj(Deoptimization::Reason_none)) {
735 return NodeSentinel(Node*)-1;
736 }
737 }
738 }
739 }
740 }
741 } else if (c->is_Proj()) {
742 if (c->is_IfProj()) {
743 if (c->as_Proj()->is_uncommon_trap_if_pattern(Deoptimization::Reason_none) != NULL__null) {
744 // continue;
745 } else {
746 if (!allow_one_proj) {
747 return NodeSentinel(Node*)-1;
748 }
749 if (iffproj == NULL__null) {
750 iffproj = c;
751 } else {
752 return NodeSentinel(Node*)-1;
753 }
754 }
755 } else if (c->Opcode() == Op_JumpProj) {
756 return NodeSentinel(Node*)-1; // unsupported
757 } else if (c->Opcode() == Op_CatchProj) {
758 return NodeSentinel(Node*)-1; // unsupported
759 } else if (c->Opcode() == Op_CProj && next->Opcode() == Op_NeverBranch) {
760 return NodeSentinel(Node*)-1; // unsupported
761 } else {
762 assert(next->unique_ctrl_out() == c, "unsupported branch pattern")do { if (!(next->unique_ctrl_out() == c)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 762, "assert(" "next->unique_ctrl_out() == c" ") failed"
, "unsupported branch pattern"); ::breakpoint(); } } while (0
)
;
763 }
764 }
765 c = next;
766 }
767 return iffproj;
768}
769
770Node* ShenandoahBarrierC2Support::dom_mem(Node* mem, Node* ctrl, int alias, Node*& mem_ctrl, PhaseIdealLoop* phase) {
771 ResourceMark rm;
772 VectorSet wq;
773 wq.set(mem->_idx);
774 mem_ctrl = phase->ctrl_or_self(mem);
775 while (!phase->is_dominator(mem_ctrl, ctrl) || mem_ctrl == ctrl) {
776 mem = next_mem(mem, alias);
777 if (wq.test_set(mem->_idx)) {
778 return NULL__null;
779 }
780 mem_ctrl = phase->ctrl_or_self(mem);
781 }
782 if (mem->is_MergeMem()) {
783 mem = mem->as_MergeMem()->memory_at(alias);
784 mem_ctrl = phase->ctrl_or_self(mem);
785 }
786 return mem;
787}
788
789Node* ShenandoahBarrierC2Support::find_bottom_mem(Node* ctrl, PhaseIdealLoop* phase) {
790 Node* mem = NULL__null;
791 Node* c = ctrl;
792 do {
793 if (c->is_Region()) {
794 for (DUIterator_Fast imax, i = c->fast_outs(imax); i < imax && mem == NULL__null; i++) {
795 Node* u = c->fast_out(i);
796 if (u->is_Phi() && u->bottom_type() == Type::MEMORY) {
797 if (u->adr_type() == TypePtr::BOTTOM) {
798 mem = u;
799 }
800 }
801 }
802 } else {
803 if (c->is_Call() && c->as_Call()->adr_type() != NULL__null) {
804 CallProjections projs;
805 c->as_Call()->extract_projections(&projs, true, false);
806 if (projs.fallthrough_memproj != NULL__null) {
807 if (projs.fallthrough_memproj->adr_type() == TypePtr::BOTTOM) {
808 if (projs.catchall_memproj == NULL__null) {
809 mem = projs.fallthrough_memproj;
810 } else {
811 if (phase->is_dominator(projs.fallthrough_catchproj, ctrl)) {
812 mem = projs.fallthrough_memproj;
813 } else {
814 assert(phase->is_dominator(projs.catchall_catchproj, ctrl), "one proj must dominate barrier")do { if (!(phase->is_dominator(projs.catchall_catchproj, ctrl
))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 814, "assert(" "phase->is_dominator(projs.catchall_catchproj, ctrl)"
") failed", "one proj must dominate barrier"); ::breakpoint(
); } } while (0)
;
815 mem = projs.catchall_memproj;
816 }
817 }
818 }
819 } else {
820 Node* proj = c->as_Call()->proj_out(TypeFunc::Memory);
821 if (proj != NULL__null &&
822 proj->adr_type() == TypePtr::BOTTOM) {
823 mem = proj;
824 }
825 }
826 } else {
827 for (DUIterator_Fast imax, i = c->fast_outs(imax); i < imax; i++) {
828 Node* u = c->fast_out(i);
829 if (u->is_Proj() &&
830 u->bottom_type() == Type::MEMORY &&
831 u->adr_type() == TypePtr::BOTTOM) {
832 assert(c->is_SafePoint() || c->is_MemBar() || c->is_Start(), "")do { if (!(c->is_SafePoint() || c->is_MemBar() || c->
is_Start())) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 832, "assert(" "c->is_SafePoint() || c->is_MemBar() || c->is_Start()"
") failed", ""); ::breakpoint(); } } while (0)
;
833 assert(mem == NULL, "only one proj")do { if (!(mem == __null)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 833, "assert(" "mem == __null" ") failed", "only one proj")
; ::breakpoint(); } } while (0)
;
834 mem = u;
835 }
836 }
837 assert(!c->is_Call() || c->as_Call()->adr_type() != NULL || mem == NULL, "no mem projection expected")do { if (!(!c->is_Call() || c->as_Call()->adr_type()
!= __null || mem == __null)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 837, "assert(" "!c->is_Call() || c->as_Call()->adr_type() != __null || mem == __null"
") failed", "no mem projection expected"); ::breakpoint(); }
} while (0)
;
838 }
839 }
840 c = phase->idom(c);
841 } while (mem == NULL__null);
842 return mem;
843}
844
845void ShenandoahBarrierC2Support::follow_barrier_uses(Node* n, Node* ctrl, Unique_Node_List& uses, PhaseIdealLoop* phase) {
846 for (DUIterator_Fast imax, i = n->fast_outs(imax); i < imax; i++) {
847 Node* u = n->fast_out(i);
848 if (!u->is_CFG() && phase->get_ctrl(u) == ctrl && (!u->is_Phi() || !u->in(0)->is_Loop() || u->in(LoopNode::LoopBackControl) != n)) {
849 uses.push(u);
850 }
851 }
852}
853
854static void hide_strip_mined_loop(OuterStripMinedLoopNode* outer, CountedLoopNode* inner, PhaseIdealLoop* phase) {
855 OuterStripMinedLoopEndNode* le = inner->outer_loop_end();
856 Node* new_outer = new LoopNode(outer->in(LoopNode::EntryControl), outer->in(LoopNode::LoopBackControl));
857 phase->register_control(new_outer, phase->get_loop(outer), outer->in(LoopNode::EntryControl));
858 Node* new_le = new IfNode(le->in(0), le->in(1), le->_prob, le->_fcnt);
859 phase->register_control(new_le, phase->get_loop(le), le->in(0));
860 phase->lazy_replace(outer, new_outer);
861 phase->lazy_replace(le, new_le);
862 inner->clear_strip_mined();
863}
864
865void ShenandoahBarrierC2Support::test_gc_state(Node*& ctrl, Node* raw_mem, Node*& test_fail_ctrl,
866 PhaseIdealLoop* phase, int flags) {
867 PhaseIterGVN& igvn = phase->igvn();
868 Node* old_ctrl = ctrl;
869
870 Node* thread = new ThreadLocalNode();
871 Node* gc_state_offset = igvn.MakeConXlongcon(in_bytes(ShenandoahThreadLocalData::gc_state_offset()));
872 Node* gc_state_addr = new AddPNode(phase->C->top(), thread, gc_state_offset);
873 Node* gc_state = new LoadBNode(old_ctrl, raw_mem, gc_state_addr,
874 DEBUG_ONLY(phase->C->get_adr_type(Compile::AliasIdxRaw))phase->C->get_adr_type(Compile::AliasIdxRaw) NOT_DEBUG(NULL),
875 TypeInt::BYTE, MemNode::unordered);
876 Node* gc_state_and = new AndINode(gc_state, igvn.intcon(flags));
877 Node* gc_state_cmp = new CmpINode(gc_state_and, igvn.zerocon(T_INT));
878 Node* gc_state_bool = new BoolNode(gc_state_cmp, BoolTest::ne);
879
880 IfNode* gc_state_iff = new IfNode(old_ctrl, gc_state_bool, PROB_UNLIKELY(0.999)(1.0f - (float)(0.999)), COUNT_UNKNOWN(-1.0f));
881 ctrl = new IfTrueNode(gc_state_iff);
882 test_fail_ctrl = new IfFalseNode(gc_state_iff);
883
884 IdealLoopTree* loop = phase->get_loop(old_ctrl);
885 phase->register_control(gc_state_iff, loop, old_ctrl);
886 phase->register_control(ctrl, loop, gc_state_iff);
887 phase->register_control(test_fail_ctrl, loop, gc_state_iff);
888
889 phase->register_new_node(thread, old_ctrl);
890 phase->register_new_node(gc_state_addr, old_ctrl);
891 phase->register_new_node(gc_state, old_ctrl);
892 phase->register_new_node(gc_state_and, old_ctrl);
893 phase->register_new_node(gc_state_cmp, old_ctrl);
894 phase->register_new_node(gc_state_bool, old_ctrl);
895
896 phase->set_ctrl(gc_state_offset, phase->C->root());
897
898 assert(is_gc_state_test(gc_state_iff, flags), "Should match the shape")do { if (!(is_gc_state_test(gc_state_iff, flags))) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 898, "assert(" "is_gc_state_test(gc_state_iff, flags)" ") failed"
, "Should match the shape"); ::breakpoint(); } } while (0)
;
899}
900
901void ShenandoahBarrierC2Support::test_null(Node*& ctrl, Node* val, Node*& null_ctrl, PhaseIdealLoop* phase) {
902 Node* old_ctrl = ctrl;
903 PhaseIterGVN& igvn = phase->igvn();
904
905 const Type* val_t = igvn.type(val);
906 if (val_t->meet(TypePtr::NULL_PTR) == val_t) {
907 Node* null_cmp = new CmpPNode(val, igvn.zerocon(T_OBJECT));
908 Node* null_test = new BoolNode(null_cmp, BoolTest::ne);
909
910 IfNode* null_iff = new IfNode(old_ctrl, null_test, PROB_LIKELY(0.999)((float) (0.999)), COUNT_UNKNOWN(-1.0f));
911 ctrl = new IfTrueNode(null_iff);
912 null_ctrl = new IfFalseNode(null_iff);
913
914 IdealLoopTree* loop = phase->get_loop(old_ctrl);
915 phase->register_control(null_iff, loop, old_ctrl);
916 phase->register_control(ctrl, loop, null_iff);
917 phase->register_control(null_ctrl, loop, null_iff);
918
919 phase->register_new_node(null_cmp, old_ctrl);
920 phase->register_new_node(null_test, old_ctrl);
921 }
922}
923
924void ShenandoahBarrierC2Support::test_in_cset(Node*& ctrl, Node*& not_cset_ctrl, Node* val, Node* raw_mem, PhaseIdealLoop* phase) {
925 Node* old_ctrl = ctrl;
926 PhaseIterGVN& igvn = phase->igvn();
927
928 Node* raw_val = new CastP2XNode(old_ctrl, val);
929 Node* cset_idx = new URShiftXNodeURShiftLNode(raw_val, igvn.intcon(ShenandoahHeapRegion::region_size_bytes_shift_jint()));
930
931 // Figure out the target cset address with raw pointer math.
932 // This avoids matching AddP+LoadB that would emit inefficient code.
933 // See JDK-8245465.
934 Node* cset_addr_ptr = igvn.makecon(TypeRawPtr::make(ShenandoahHeap::in_cset_fast_test_addr()));
935 Node* cset_addr = new CastP2XNode(old_ctrl, cset_addr_ptr);
936 Node* cset_load_addr = new AddXNodeAddLNode(cset_addr, cset_idx);
937 Node* cset_load_ptr = new CastX2PNode(cset_load_addr);
938
939 Node* cset_load = new LoadBNode(old_ctrl, raw_mem, cset_load_ptr,
940 DEBUG_ONLY(phase->C->get_adr_type(Compile::AliasIdxRaw))phase->C->get_adr_type(Compile::AliasIdxRaw) NOT_DEBUG(NULL),
941 TypeInt::BYTE, MemNode::unordered);
942 Node* cset_cmp = new CmpINode(cset_load, igvn.zerocon(T_INT));
943 Node* cset_bool = new BoolNode(cset_cmp, BoolTest::ne);
944
945 IfNode* cset_iff = new IfNode(old_ctrl, cset_bool, PROB_UNLIKELY(0.999)(1.0f - (float)(0.999)), COUNT_UNKNOWN(-1.0f));
946 ctrl = new IfTrueNode(cset_iff);
947 not_cset_ctrl = new IfFalseNode(cset_iff);
948
949 IdealLoopTree *loop = phase->get_loop(old_ctrl);
950 phase->register_control(cset_iff, loop, old_ctrl);
951 phase->register_control(ctrl, loop, cset_iff);
952 phase->register_control(not_cset_ctrl, loop, cset_iff);
953
954 phase->set_ctrl(cset_addr_ptr, phase->C->root());
955
956 phase->register_new_node(raw_val, old_ctrl);
957 phase->register_new_node(cset_idx, old_ctrl);
958 phase->register_new_node(cset_addr, old_ctrl);
959 phase->register_new_node(cset_load_addr, old_ctrl);
960 phase->register_new_node(cset_load_ptr, old_ctrl);
961 phase->register_new_node(cset_load, old_ctrl);
962 phase->register_new_node(cset_cmp, old_ctrl);
963 phase->register_new_node(cset_bool, old_ctrl);
964}
965
966void ShenandoahBarrierC2Support::call_lrb_stub(Node*& ctrl, Node*& val, Node* load_addr,
967 DecoratorSet decorators, PhaseIdealLoop* phase) {
968 IdealLoopTree*loop = phase->get_loop(ctrl);
969 const TypePtr* obj_type = phase->igvn().type(val)->is_oopptr();
970
971 address calladdr = NULL__null;
972 const char* name = NULL__null;
973 bool is_strong = ShenandoahBarrierSet::is_strong_access(decorators);
974 bool is_weak = ShenandoahBarrierSet::is_weak_access(decorators);
975 bool is_phantom = ShenandoahBarrierSet::is_phantom_access(decorators);
976 bool is_native = ShenandoahBarrierSet::is_native_access(decorators);
977 bool is_narrow = UseCompressedOops && !is_native;
978 if (is_strong) {
979 if (is_narrow) {
980 calladdr = CAST_FROM_FN_PTR(address, ShenandoahRuntime::load_reference_barrier_strong_narrow)((address)((address_word)(ShenandoahRuntime::load_reference_barrier_strong_narrow
)))
;
981 name = "load_reference_barrier_strong_narrow";
982 } else {
983 calladdr = CAST_FROM_FN_PTR(address, ShenandoahRuntime::load_reference_barrier_strong)((address)((address_word)(ShenandoahRuntime::load_reference_barrier_strong
)))
;
984 name = "load_reference_barrier_strong";
985 }
986 } else if (is_weak) {
987 if (is_narrow) {
988 calladdr = CAST_FROM_FN_PTR(address, ShenandoahRuntime::load_reference_barrier_weak_narrow)((address)((address_word)(ShenandoahRuntime::load_reference_barrier_weak_narrow
)))
;
989 name = "load_reference_barrier_weak_narrow";
990 } else {
991 calladdr = CAST_FROM_FN_PTR(address, ShenandoahRuntime::load_reference_barrier_weak)((address)((address_word)(ShenandoahRuntime::load_reference_barrier_weak
)))
;
992 name = "load_reference_barrier_weak";
993 }
994 } else {
995 assert(is_phantom, "only remaining strength")do { if (!(is_phantom)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 995, "assert(" "is_phantom" ") failed", "only remaining strength"
); ::breakpoint(); } } while (0)
;
996 if (is_narrow) {
997 calladdr = CAST_FROM_FN_PTR(address, ShenandoahRuntime::load_reference_barrier_phantom_narrow)((address)((address_word)(ShenandoahRuntime::load_reference_barrier_phantom_narrow
)))
;
998 name = "load_reference_barrier_phantom_narrow";
999 } else {
1000 calladdr = CAST_FROM_FN_PTR(address, ShenandoahRuntime::load_reference_barrier_phantom)((address)((address_word)(ShenandoahRuntime::load_reference_barrier_phantom
)))
;
1001 name = "load_reference_barrier_phantom";
1002 }
1003 }
1004 Node* call = new CallLeafNode(ShenandoahBarrierSetC2::shenandoah_load_reference_barrier_Type(), calladdr, name, TypeRawPtr::BOTTOM);
1005
1006 call->init_req(TypeFunc::Control, ctrl);
1007 call->init_req(TypeFunc::I_O, phase->C->top());
1008 call->init_req(TypeFunc::Memory, phase->C->top());
1009 call->init_req(TypeFunc::FramePtr, phase->C->top());
1010 call->init_req(TypeFunc::ReturnAdr, phase->C->top());
1011 call->init_req(TypeFunc::Parms, val);
1012 call->init_req(TypeFunc::Parms+1, load_addr);
1013 phase->register_control(call, loop, ctrl);
1014 ctrl = new ProjNode(call, TypeFunc::Control);
1015 phase->register_control(ctrl, loop, call);
1016 val = new ProjNode(call, TypeFunc::Parms);
1017 phase->register_new_node(val, call);
1018 val = new CheckCastPPNode(ctrl, val, obj_type);
1019 phase->register_new_node(val, ctrl);
1020}
1021
1022void ShenandoahBarrierC2Support::fix_ctrl(Node* barrier, Node* region, const MemoryGraphFixer& fixer, Unique_Node_List& uses, Unique_Node_List& uses_to_ignore, uint last, PhaseIdealLoop* phase) {
1023 Node* ctrl = phase->get_ctrl(barrier);
1024 Node* init_raw_mem = fixer.find_mem(ctrl, barrier);
1025
1026 // Update the control of all nodes that should be after the
1027 // barrier control flow
1028 uses.clear();
1029 // Every node that is control dependent on the barrier's input
1030 // control will be after the expanded barrier. The raw memory (if
1031 // its memory is control dependent on the barrier's input control)
1032 // must stay above the barrier.
1033 uses_to_ignore.clear();
1034 if (phase->has_ctrl(init_raw_mem) && phase->get_ctrl(init_raw_mem) == ctrl && !init_raw_mem->is_Phi()) {
1035 uses_to_ignore.push(init_raw_mem);
1036 }
1037 for (uint next = 0; next < uses_to_ignore.size(); next++) {
1038 Node *n = uses_to_ignore.at(next);
1039 for (uint i = 0; i < n->req(); i++) {
1040 Node* in = n->in(i);
1041 if (in != NULL__null && phase->has_ctrl(in) && phase->get_ctrl(in) == ctrl) {
1042 uses_to_ignore.push(in);
1043 }
1044 }
1045 }
1046 for (DUIterator_Fast imax, i = ctrl->fast_outs(imax); i < imax; i++) {
1047 Node* u = ctrl->fast_out(i);
1048 if (u->_idx < last &&
1049 u != barrier &&
1050 !uses_to_ignore.member(u) &&
1051 (u->in(0) != ctrl || (!u->is_Region() && !u->is_Phi())) &&
1052 (ctrl->Opcode() != Op_CatchProj || u->Opcode() != Op_CreateEx)) {
1053 Node* old_c = phase->ctrl_or_self(u);
1054 Node* c = old_c;
1055 if (c != ctrl ||
1056 is_dominator_same_ctrl(old_c, barrier, u, phase) ||
1057 ShenandoahBarrierSetC2::is_shenandoah_state_load(u)) {
1058 phase->igvn().rehash_node_delayed(u);
1059 int nb = u->replace_edge(ctrl, region, &phase->igvn());
1060 if (u->is_CFG()) {
1061 if (phase->idom(u) == ctrl) {
1062 phase->set_idom(u, region, phase->dom_depth(region));
1063 }
1064 } else if (phase->get_ctrl(u) == ctrl) {
1065 assert(u != init_raw_mem, "should leave input raw mem above the barrier")do { if (!(u != init_raw_mem)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 1065, "assert(" "u != init_raw_mem" ") failed", "should leave input raw mem above the barrier"
); ::breakpoint(); } } while (0)
;
1066 uses.push(u);
1067 }
1068 assert(nb == 1, "more than 1 ctrl input?")do { if (!(nb == 1)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 1068, "assert(" "nb == 1" ") failed", "more than 1 ctrl input?"
); ::breakpoint(); } } while (0)
;
1069 --i, imax -= nb;
1070 }
1071 }
1072 }
1073}
1074
1075static Node* create_phis_on_call_return(Node* ctrl, Node* c, Node* n, Node* n_clone, const CallProjections& projs, PhaseIdealLoop* phase) {
1076 Node* region = NULL__null;
1077 while (c != ctrl) {
1078 if (c->is_Region()) {
1079 region = c;
1080 }
1081 c = phase->idom(c);
1082 }
1083 assert(region != NULL, "")do { if (!(region != __null)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 1083, "assert(" "region != __null" ") failed", ""); ::breakpoint
(); } } while (0)
;
1084 Node* phi = new PhiNode(region, n->bottom_type());
1085 for (uint j = 1; j < region->req(); j++) {
1086 Node* in = region->in(j);
1087 if (phase->is_dominator(projs.fallthrough_catchproj, in)) {
1088 phi->init_req(j, n);
1089 } else if (phase->is_dominator(projs.catchall_catchproj, in)) {
1090 phi->init_req(j, n_clone);
1091 } else {
1092 phi->init_req(j, create_phis_on_call_return(ctrl, in, n, n_clone, projs, phase));
1093 }
1094 }
1095 phase->register_new_node(phi, region);
1096 return phi;
1097}
1098
1099void ShenandoahBarrierC2Support::pin_and_expand(PhaseIdealLoop* phase) {
1100 ShenandoahBarrierSetC2State* state = ShenandoahBarrierSetC2::bsc2()->state();
1101
1102 Unique_Node_List uses;
1103 for (int i = 0; i < state->iu_barriers_count(); i++) {
1104 Node* barrier = state->iu_barrier(i);
1105 Node* ctrl = phase->get_ctrl(barrier);
1106 IdealLoopTree* loop = phase->get_loop(ctrl);
1107 Node* head = loop->head();
1108 if (head->is_OuterStripMinedLoop()) {
1109 // Expanding a barrier here will break loop strip mining
1110 // verification. Transform the loop so the loop nest doesn't
1111 // appear as strip mined.
1112 OuterStripMinedLoopNode* outer = head->as_OuterStripMinedLoop();
1113 hide_strip_mined_loop(outer, outer->unique_ctrl_out()->as_CountedLoop(), phase);
1114 }
1115 }
1116
1117 Node_Stack stack(0);
1118 Node_List clones;
1119 for (int i = state->load_reference_barriers_count() - 1; i >= 0; i--) {
1120 ShenandoahLoadReferenceBarrierNode* lrb = state->load_reference_barrier(i);
1121
1122 Node* ctrl = phase->get_ctrl(lrb);
1123 Node* val = lrb->in(ShenandoahLoadReferenceBarrierNode::ValueIn);
1124
1125 CallStaticJavaNode* unc = NULL__null;
1126 Node* unc_ctrl = NULL__null;
1127 Node* uncasted_val = val;
1128
1129 for (DUIterator_Fast imax, i = lrb->fast_outs(imax); i < imax; i++) {
1130 Node* u = lrb->fast_out(i);
1131 if (u->Opcode() == Op_CastPP &&
1132 u->in(0) != NULL__null &&
1133 phase->is_dominator(u->in(0), ctrl)) {
1134 const Type* u_t = phase->igvn().type(u);
1135
1136 if (u_t->meet(TypePtr::NULL_PTR) != u_t &&
1137 u->in(0)->Opcode() == Op_IfTrue &&
1138 u->in(0)->as_Proj()->is_uncommon_trap_if_pattern(Deoptimization::Reason_none) &&
1139 u->in(0)->in(0)->is_If() &&
1140 u->in(0)->in(0)->in(1)->Opcode() == Op_Bool &&
1141 u->in(0)->in(0)->in(1)->as_Bool()->_test._test == BoolTest::ne &&
1142 u->in(0)->in(0)->in(1)->in(1)->Opcode() == Op_CmpP &&
1143 u->in(0)->in(0)->in(1)->in(1)->in(1) == val &&
1144 u->in(0)->in(0)->in(1)->in(1)->in(2)->bottom_type() == TypePtr::NULL_PTR) {
1145 IdealLoopTree* loop = phase->get_loop(ctrl);
1146 IdealLoopTree* unc_loop = phase->get_loop(u->in(0));
1147
1148 if (!unc_loop->is_member(loop)) {
1149 continue;
1150 }
1151
1152 Node* branch = no_branches(ctrl, u->in(0), false, phase);
1153 assert(branch == NULL || branch == NodeSentinel, "was not looking for a branch")do { if (!(branch == __null || branch == (Node*)-1)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 1153, "assert(" "branch == __null || branch == (Node*)-1" ") failed"
, "was not looking for a branch"); ::breakpoint(); } } while (
0)
;
1154 if (branch == NodeSentinel(Node*)-1) {
1155 continue;
1156 }
1157
1158 Node* iff = u->in(0)->in(0);
1159 Node* bol = iff->in(1)->clone();
1160 Node* cmp = bol->in(1)->clone();
1161 cmp->set_req(1, lrb);
1162 bol->set_req(1, cmp);
1163 phase->igvn().replace_input_of(iff, 1, bol);
1164 phase->set_ctrl(lrb, iff->in(0));
1165 phase->register_new_node(cmp, iff->in(0));
1166 phase->register_new_node(bol, iff->in(0));
1167 break;
1168 }
1169 }
1170 }
1171 if ((ctrl->is_Proj() && ctrl->in(0)->is_CallJava()) || ctrl->is_CallJava()) {
1172 CallNode* call = ctrl->is_Proj() ? ctrl->in(0)->as_CallJava() : ctrl->as_CallJava();
1173 if (call->entry_point() == OptoRuntime::rethrow_stub()) {
1174 // The rethrow call may have too many projections to be
1175 // properly handled here. Given there's no reason for a
1176 // barrier to depend on the call, move it above the call
1177 stack.push(lrb, 0);
1178 do {
1179 Node* n = stack.node();
1180 uint idx = stack.index();
1181 if (idx < n->req()) {
1182 Node* in = n->in(idx);
1183 stack.set_index(idx+1);
1184 if (in != NULL__null) {
1185 if (phase->has_ctrl(in)) {
1186 if (phase->is_dominator(call, phase->get_ctrl(in))) {
1187#ifdef ASSERT1
1188 for (uint i = 0; i < stack.size(); i++) {
1189 assert(stack.node_at(i) != in, "node shouldn't have been seen yet")do { if (!(stack.node_at(i) != in)) { (*g_assert_poison) = 'X'
;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 1189, "assert(" "stack.node_at(i) != in" ") failed", "node shouldn't have been seen yet"
); ::breakpoint(); } } while (0)
;
1190 }
1191#endif
1192 stack.push(in, 0);
1193 }
1194 } else {
1195 assert(phase->is_dominator(in, call->in(0)), "no dependency on the call")do { if (!(phase->is_dominator(in, call->in(0)))) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 1195, "assert(" "phase->is_dominator(in, call->in(0))"
") failed", "no dependency on the call"); ::breakpoint(); } }
while (0)
;
1196 }
1197 }
1198 } else {
1199 phase->set_ctrl(n, call->in(0));
1200 stack.pop();
1201 }
1202 } while(stack.size() > 0);
1203 continue;
1204 }
1205 CallProjections projs;
1206 call->extract_projections(&projs, false, false);
1207
1208#ifdef ASSERT1
1209 VectorSet cloned;
1210#endif
1211 Node* lrb_clone = lrb->clone();
1212 phase->register_new_node(lrb_clone, projs.catchall_catchproj);
1213 phase->set_ctrl(lrb, projs.fallthrough_catchproj);
1214
1215 stack.push(lrb, 0);
1216 clones.push(lrb_clone);
1217
1218 do {
1219 assert(stack.size() == clones.size(), "")do { if (!(stack.size() == clones.size())) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 1219, "assert(" "stack.size() == clones.size()" ") failed",
""); ::breakpoint(); } } while (0)
;
1220 Node* n = stack.node();
1221#ifdef ASSERT1
1222 if (n->is_Load()) {
1223 Node* mem = n->in(MemNode::Memory);
1224 for (DUIterator_Fast jmax, j = mem->fast_outs(jmax); j < jmax; j++) {
1225 Node* u = mem->fast_out(j);
1226 assert(!u->is_Store() || !u->is_LoadStore() || phase->get_ctrl(u) != ctrl, "anti dependent store?")do { if (!(!u->is_Store() || !u->is_LoadStore() || phase
->get_ctrl(u) != ctrl)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 1226, "assert(" "!u->is_Store() || !u->is_LoadStore() || phase->get_ctrl(u) != ctrl"
") failed", "anti dependent store?"); ::breakpoint(); } } while
(0)
;
1227 }
1228 }
1229#endif
1230 uint idx = stack.index();
1231 Node* n_clone = clones.at(clones.size()-1);
1232 if (idx < n->outcnt()) {
1233 Node* u = n->raw_out(idx);
1234 Node* c = phase->ctrl_or_self(u);
1235 if (phase->is_dominator(call, c) && phase->is_dominator(c, projs.fallthrough_proj)) {
1236 stack.set_index(idx+1);
1237 assert(!u->is_CFG(), "")do { if (!(!u->is_CFG())) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 1237, "assert(" "!u->is_CFG()" ") failed", ""); ::breakpoint
(); } } while (0)
;
1238 stack.push(u, 0);
1239 assert(!cloned.test_set(u->_idx), "only one clone")do { if (!(!cloned.test_set(u->_idx))) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 1239, "assert(" "!cloned.test_set(u->_idx)" ") failed", "only one clone"
); ::breakpoint(); } } while (0)
;
1240 Node* u_clone = u->clone();
1241 int nb = u_clone->replace_edge(n, n_clone, &phase->igvn());
1242 assert(nb > 0, "should have replaced some uses")do { if (!(nb > 0)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 1242, "assert(" "nb > 0" ") failed", "should have replaced some uses"
); ::breakpoint(); } } while (0)
;
1243 phase->register_new_node(u_clone, projs.catchall_catchproj);
1244 clones.push(u_clone);
1245 phase->set_ctrl(u, projs.fallthrough_catchproj);
1246 } else {
1247 bool replaced = false;
1248 if (u->is_Phi()) {
1249 for (uint k = 1; k < u->req(); k++) {
1250 if (u->in(k) == n) {
1251 if (phase->is_dominator(projs.catchall_catchproj, u->in(0)->in(k))) {
1252 phase->igvn().replace_input_of(u, k, n_clone);
1253 replaced = true;
1254 } else if (!phase->is_dominator(projs.fallthrough_catchproj, u->in(0)->in(k))) {
1255 phase->igvn().replace_input_of(u, k, create_phis_on_call_return(ctrl, u->in(0)->in(k), n, n_clone, projs, phase));
1256 replaced = true;
1257 }
1258 }
1259 }
1260 } else {
1261 if (phase->is_dominator(projs.catchall_catchproj, c)) {
1262 phase->igvn().rehash_node_delayed(u);
1263 int nb = u->replace_edge(n, n_clone, &phase->igvn());
1264 assert(nb > 0, "should have replaced some uses")do { if (!(nb > 0)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 1264, "assert(" "nb > 0" ") failed", "should have replaced some uses"
); ::breakpoint(); } } while (0)
;
1265 replaced = true;
1266 } else if (!phase->is_dominator(projs.fallthrough_catchproj, c)) {
1267 if (u->is_If()) {
1268 // Can't break If/Bool/Cmp chain
1269 assert(n->is_Bool(), "unexpected If shape")do { if (!(n->is_Bool())) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 1269, "assert(" "n->is_Bool()" ") failed", "unexpected If shape"
); ::breakpoint(); } } while (0)
;
1270 assert(stack.node_at(stack.size()-2)->is_Cmp(), "unexpected If shape")do { if (!(stack.node_at(stack.size()-2)->is_Cmp())) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 1270, "assert(" "stack.node_at(stack.size()-2)->is_Cmp()"
") failed", "unexpected If shape"); ::breakpoint(); } } while
(0)
;
1271 assert(n_clone->is_Bool(), "unexpected clone")do { if (!(n_clone->is_Bool())) { (*g_assert_poison) = 'X'
;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 1271, "assert(" "n_clone->is_Bool()" ") failed", "unexpected clone"
); ::breakpoint(); } } while (0)
;
1272 assert(clones.at(clones.size()-2)->is_Cmp(), "unexpected clone")do { if (!(clones.at(clones.size()-2)->is_Cmp())) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 1272, "assert(" "clones.at(clones.size()-2)->is_Cmp()" ") failed"
, "unexpected clone"); ::breakpoint(); } } while (0)
;
1273 Node* bol_clone = n->clone();
1274 Node* cmp_clone = stack.node_at(stack.size()-2)->clone();
1275 bol_clone->set_req(1, cmp_clone);
1276
1277 Node* nn = stack.node_at(stack.size()-3);
1278 Node* nn_clone = clones.at(clones.size()-3);
1279 assert(nn->Opcode() == nn_clone->Opcode(), "mismatch")do { if (!(nn->Opcode() == nn_clone->Opcode())) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 1279, "assert(" "nn->Opcode() == nn_clone->Opcode()" ") failed"
, "mismatch"); ::breakpoint(); } } while (0)
;
1280
1281 int nb = cmp_clone->replace_edge(nn, create_phis_on_call_return(ctrl, c, nn, nn_clone, projs, phase),
1282 &phase->igvn());
1283 assert(nb > 0, "should have replaced some uses")do { if (!(nb > 0)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 1283, "assert(" "nb > 0" ") failed", "should have replaced some uses"
); ::breakpoint(); } } while (0)
;
1284
1285 phase->register_new_node(bol_clone, u->in(0));
1286 phase->register_new_node(cmp_clone, u->in(0));
1287
1288 phase->igvn().replace_input_of(u, 1, bol_clone);
1289
1290 } else {
1291 phase->igvn().rehash_node_delayed(u);
1292 int nb = u->replace_edge(n, create_phis_on_call_return(ctrl, c, n, n_clone, projs, phase), &phase->igvn());
1293 assert(nb > 0, "should have replaced some uses")do { if (!(nb > 0)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 1293, "assert(" "nb > 0" ") failed", "should have replaced some uses"
); ::breakpoint(); } } while (0)
;
1294 }
1295 replaced = true;
1296 }
1297 }
1298 if (!replaced) {
1299 stack.set_index(idx+1);
1300 }
1301 }
1302 } else {
1303 stack.pop();
1304 clones.pop();
1305 }
1306 } while (stack.size() > 0);
1307 assert(stack.size() == 0 && clones.size() == 0, "")do { if (!(stack.size() == 0 && clones.size() == 0)) {
(*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 1307, "assert(" "stack.size() == 0 && clones.size() == 0"
") failed", ""); ::breakpoint(); } } while (0)
;
1308 }
1309 }
1310
1311 for (int i = 0; i < state->load_reference_barriers_count(); i++) {
1312 ShenandoahLoadReferenceBarrierNode* lrb = state->load_reference_barrier(i);
1313 Node* ctrl = phase->get_ctrl(lrb);
1314 IdealLoopTree* loop = phase->get_loop(ctrl);
1315 Node* head = loop->head();
1316 if (head->is_OuterStripMinedLoop()) {
1317 // Expanding a barrier here will break loop strip mining
1318 // verification. Transform the loop so the loop nest doesn't
1319 // appear as strip mined.
1320 OuterStripMinedLoopNode* outer = head->as_OuterStripMinedLoop();
1321 hide_strip_mined_loop(outer, outer->unique_ctrl_out()->as_CountedLoop(), phase);
1322 }
1323 }
1324
1325 // Expand load-reference-barriers
1326 MemoryGraphFixer fixer(Compile::AliasIdxRaw, true, phase);
1327 Unique_Node_List uses_to_ignore;
1328 for (int i = state->load_reference_barriers_count() - 1; i >= 0; i--) {
1329 ShenandoahLoadReferenceBarrierNode* lrb = state->load_reference_barrier(i);
1330 uint last = phase->C->unique();
1331 Node* ctrl = phase->get_ctrl(lrb);
1332 Node* val = lrb->in(ShenandoahLoadReferenceBarrierNode::ValueIn);
1333
1334 Node* orig_ctrl = ctrl;
1335
1336 Node* raw_mem = fixer.find_mem(ctrl, lrb);
1337
1338 IdealLoopTree *loop = phase->get_loop(ctrl);
1339
1340 Node* heap_stable_ctrl = NULL__null;
1341 Node* null_ctrl = NULL__null;
1342
1343 assert(val->bottom_type()->make_oopptr(), "need oop")do { if (!(val->bottom_type()->make_oopptr())) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 1343, "assert(" "val->bottom_type()->make_oopptr()" ") failed"
, "need oop"); ::breakpoint(); } } while (0)
;
1344 assert(val->bottom_type()->make_oopptr()->const_oop() == NULL, "expect non-constant")do { if (!(val->bottom_type()->make_oopptr()->const_oop
() == __null)) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 1344, "assert(" "val->bottom_type()->make_oopptr()->const_oop() == __null"
") failed", "expect non-constant"); ::breakpoint(); } } while
(0)
;
1345
1346 enum { _heap_stable = 1, _evac_path, _not_cset, PATH_LIMIT };
1347 Node* region = new RegionNode(PATH_LIMIT);
1348 Node* val_phi = new PhiNode(region, val->bottom_type()->is_oopptr());
1349
1350 // Stable path.
1351 int flags = ShenandoahHeap::HAS_FORWARDED;
1352 if (!ShenandoahBarrierSet::is_strong_access(lrb->decorators())) {
1353 flags |= ShenandoahHeap::WEAK_ROOTS;
1354 }
1355 test_gc_state(ctrl, raw_mem, heap_stable_ctrl, phase, flags);
1356 IfNode* heap_stable_iff = heap_stable_ctrl->in(0)->as_If();
1357
1358 // Heap stable case
1359 region->init_req(_heap_stable, heap_stable_ctrl);
1360 val_phi->init_req(_heap_stable, val);
1361
1362 // Test for in-cset, unless it's a native-LRB. Native LRBs need to return NULL
1363 // even for non-cset objects to prevent ressurrection of such objects.
1364 // Wires !in_cset(obj) to slot 2 of region and phis
1365 Node* not_cset_ctrl = NULL__null;
1366 if (ShenandoahBarrierSet::is_strong_access(lrb->decorators())) {
1367 test_in_cset(ctrl, not_cset_ctrl, val, raw_mem, phase);
1368 }
1369 if (not_cset_ctrl != NULL__null) {
1370 region->init_req(_not_cset, not_cset_ctrl);
1371 val_phi->init_req(_not_cset, val);
1372 } else {
1373 region->del_req(_not_cset);
1374 val_phi->del_req(_not_cset);
1375 }
1376
1377 // Resolve object when orig-value is in cset.
1378 // Make the unconditional resolve for fwdptr.
1379
1380 // Call lrb-stub and wire up that path in slots 4
1381 Node* result_mem = NULL__null;
1382
1383 Node* addr;
1384 if (ShenandoahSelfFixing) {
1385 VectorSet visited;
1386 addr = get_load_addr(phase, visited, lrb);
1387 } else {
1388 addr = phase->igvn().zerocon(T_OBJECT);
1389 }
1390 if (addr->Opcode() == Op_AddP) {
1391 Node* orig_base = addr->in(AddPNode::Base);
1392 Node* base = new CheckCastPPNode(ctrl, orig_base, orig_base->bottom_type(), ConstraintCastNode::StrongDependency);
1393 phase->register_new_node(base, ctrl);
1394 if (addr->in(AddPNode::Base) == addr->in((AddPNode::Address))) {
1395 // Field access
1396 addr = addr->clone();
1397 addr->set_req(AddPNode::Base, base);
1398 addr->set_req(AddPNode::Address, base);
1399 phase->register_new_node(addr, ctrl);
1400 } else {
1401 Node* addr2 = addr->in(AddPNode::Address);
1402 if (addr2->Opcode() == Op_AddP && addr2->in(AddPNode::Base) == addr2->in(AddPNode::Address) &&
1403 addr2->in(AddPNode::Base) == orig_base) {
1404 addr2 = addr2->clone();
1405 addr2->set_req(AddPNode::Base, base);
1406 addr2->set_req(AddPNode::Address, base);
1407 phase->register_new_node(addr2, ctrl);
1408 addr = addr->clone();
1409 addr->set_req(AddPNode::Base, base);
1410 addr->set_req(AddPNode::Address, addr2);
1411 phase->register_new_node(addr, ctrl);
1412 }
1413 }
1414 }
1415 call_lrb_stub(ctrl, val, addr, lrb->decorators(), phase);
1416 region->init_req(_evac_path, ctrl);
1417 val_phi->init_req(_evac_path, val);
1418
1419 phase->register_control(region, loop, heap_stable_iff);
1420 Node* out_val = val_phi;
1421 phase->register_new_node(val_phi, region);
1422
1423 fix_ctrl(lrb, region, fixer, uses, uses_to_ignore, last, phase);
1424
1425 ctrl = orig_ctrl;
1426
1427 phase->igvn().replace_node(lrb, out_val);
1428
1429 follow_barrier_uses(out_val, ctrl, uses, phase);
1430
1431 for(uint next = 0; next < uses.size(); next++ ) {
1432 Node *n = uses.at(next);
1433 assert(phase->get_ctrl(n) == ctrl, "bad control")do { if (!(phase->get_ctrl(n) == ctrl)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 1433, "assert(" "phase->get_ctrl(n) == ctrl" ") failed",
"bad control"); ::breakpoint(); } } while (0)
;
1434 assert(n != raw_mem, "should leave input raw mem above the barrier")do { if (!(n != raw_mem)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 1434, "assert(" "n != raw_mem" ") failed", "should leave input raw mem above the barrier"
); ::breakpoint(); } } while (0)
;
1435 phase->set_ctrl(n, region);
1436 follow_barrier_uses(n, ctrl, uses, phase);
1437 }
1438 }
1439 // Done expanding load-reference-barriers.
1440 assert(ShenandoahBarrierSetC2::bsc2()->state()->load_reference_barriers_count() == 0, "all load reference barrier nodes should have been replaced")do { if (!(ShenandoahBarrierSetC2::bsc2()->state()->load_reference_barriers_count
() == 0)) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 1440, "assert(" "ShenandoahBarrierSetC2::bsc2()->state()->load_reference_barriers_count() == 0"
") failed", "all load reference barrier nodes should have been replaced"
); ::breakpoint(); } } while (0)
;
1441
1442 for (int i = state->iu_barriers_count() - 1; i >= 0; i--) {
1443 Node* barrier = state->iu_barrier(i);
1444 Node* pre_val = barrier->in(1);
1445
1446 if (phase->igvn().type(pre_val)->higher_equal(TypePtr::NULL_PTR)) {
1447 ShouldNotReachHere()do { (*g_assert_poison) = 'X';; report_should_not_reach_here(
"/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 1447); ::breakpoint(); } while (0)
;
1448 continue;
1449 }
1450
1451 Node* ctrl = phase->get_ctrl(barrier);
1452
1453 if (ctrl->is_Proj() && ctrl->in(0)->is_CallJava()) {
1454 assert(is_dominator(phase->get_ctrl(pre_val), ctrl->in(0)->in(0), pre_val, ctrl->in(0), phase), "can't move")do { if (!(is_dominator(phase->get_ctrl(pre_val), ctrl->
in(0)->in(0), pre_val, ctrl->in(0), phase))) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 1454, "assert(" "is_dominator(phase->get_ctrl(pre_val), ctrl->in(0)->in(0), pre_val, ctrl->in(0), phase)"
") failed", "can't move"); ::breakpoint(); } } while (0)
;
1455 ctrl = ctrl->in(0)->in(0);
1456 phase->set_ctrl(barrier, ctrl);
1457 } else if (ctrl->is_CallRuntime()) {
1458 assert(is_dominator(phase->get_ctrl(pre_val), ctrl->in(0), pre_val, ctrl, phase), "can't move")do { if (!(is_dominator(phase->get_ctrl(pre_val), ctrl->
in(0), pre_val, ctrl, phase))) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 1458, "assert(" "is_dominator(phase->get_ctrl(pre_val), ctrl->in(0), pre_val, ctrl, phase)"
") failed", "can't move"); ::breakpoint(); } } while (0)
;
1459 ctrl = ctrl->in(0);
1460 phase->set_ctrl(barrier, ctrl);
1461 }
1462
1463 Node* init_ctrl = ctrl;
1464 IdealLoopTree* loop = phase->get_loop(ctrl);
1465 Node* raw_mem = fixer.find_mem(ctrl, barrier);
1466 Node* init_raw_mem = raw_mem;
1467 Node* raw_mem_for_ctrl = fixer.find_mem(ctrl, NULL__null);
1468 Node* heap_stable_ctrl = NULL__null;
1469 Node* null_ctrl = NULL__null;
1470 uint last = phase->C->unique();
1471
1472 enum { _heap_stable = 1, _heap_unstable, PATH_LIMIT };
1473 Node* region = new RegionNode(PATH_LIMIT);
1474 Node* phi = PhiNode::make(region, raw_mem, Type::MEMORY, TypeRawPtr::BOTTOM);
1475
1476 enum { _fast_path = 1, _slow_path, _null_path, PATH_LIMIT2 };
1477 Node* region2 = new RegionNode(PATH_LIMIT2);
1478 Node* phi2 = PhiNode::make(region2, raw_mem, Type::MEMORY, TypeRawPtr::BOTTOM);
1479
1480 // Stable path.
1481 test_gc_state(ctrl, raw_mem, heap_stable_ctrl, phase, ShenandoahHeap::MARKING);
1482 region->init_req(_heap_stable, heap_stable_ctrl);
1483 phi->init_req(_heap_stable, raw_mem);
1484
1485 // Null path
1486 Node* reg2_ctrl = NULL__null;
1487 test_null(ctrl, pre_val, null_ctrl, phase);
1488 if (null_ctrl != NULL__null) {
1489 reg2_ctrl = null_ctrl->in(0);
1490 region2->init_req(_null_path, null_ctrl);
1491 phi2->init_req(_null_path, raw_mem);
1492 } else {
1493 region2->del_req(_null_path);
1494 phi2->del_req(_null_path);
1495 }
1496
1497 const int index_offset = in_bytes(ShenandoahThreadLocalData::satb_mark_queue_index_offset());
1498 const int buffer_offset = in_bytes(ShenandoahThreadLocalData::satb_mark_queue_buffer_offset());
1499 Node* thread = new ThreadLocalNode();
1500 phase->register_new_node(thread, ctrl);
1501 Node* buffer_adr = new AddPNode(phase->C->top(), thread, phase->igvn().MakeConXlongcon(buffer_offset));
1502 phase->register_new_node(buffer_adr, ctrl);
1503 Node* index_adr = new AddPNode(phase->C->top(), thread, phase->igvn().MakeConXlongcon(index_offset));
1504 phase->register_new_node(index_adr, ctrl);
1505
1506 BasicType index_bt = TypeX_XTypeLong::LONG->basic_type();
1507 assert(sizeof(size_t) == type2aelembytes(index_bt), "Loading Shenandoah SATBMarkQueue::_index with wrong size.")do { if (!(sizeof(size_t) == type2aelembytes(index_bt))) { (*
g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 1507, "assert(" "sizeof(size_t) == type2aelembytes(index_bt)"
") failed", "Loading Shenandoah SATBMarkQueue::_index with wrong size."
); ::breakpoint(); } } while (0)
;
1508 const TypePtr* adr_type = TypeRawPtr::BOTTOM;
1509 Node* index = new LoadXNodeLoadLNode(ctrl, raw_mem, index_adr, adr_type, TypeX_XTypeLong::LONG, MemNode::unordered);
1510 phase->register_new_node(index, ctrl);
1511 Node* index_cmp = new CmpXNodeCmpLNode(index, phase->igvn().MakeConXlongcon(0));
1512 phase->register_new_node(index_cmp, ctrl);
1513 Node* index_test = new BoolNode(index_cmp, BoolTest::ne);
1514 phase->register_new_node(index_test, ctrl);
1515 IfNode* queue_full_iff = new IfNode(ctrl, index_test, PROB_LIKELY(0.999)((float) (0.999)), COUNT_UNKNOWN(-1.0f));
1516 if (reg2_ctrl == NULL__null) reg2_ctrl = queue_full_iff;
1517 phase->register_control(queue_full_iff, loop, ctrl);
1518 Node* not_full = new IfTrueNode(queue_full_iff);
1519 phase->register_control(not_full, loop, queue_full_iff);
1520 Node* full = new IfFalseNode(queue_full_iff);
1521 phase->register_control(full, loop, queue_full_iff);
1522
1523 ctrl = not_full;
1524
1525 Node* next_index = new SubXNodeSubLNode(index, phase->igvn().MakeConXlongcon(sizeof(intptr_t)));
1526 phase->register_new_node(next_index, ctrl);
1527
1528 Node* buffer = new LoadPNode(ctrl, raw_mem, buffer_adr, adr_type, TypeRawPtr::NOTNULL, MemNode::unordered);
1529 phase->register_new_node(buffer, ctrl);
1530 Node *log_addr = new AddPNode(phase->C->top(), buffer, next_index);
1531 phase->register_new_node(log_addr, ctrl);
1532 Node* log_store = new StorePNode(ctrl, raw_mem, log_addr, adr_type, pre_val, MemNode::unordered);
1533 phase->register_new_node(log_store, ctrl);
1534 // update the index
1535 Node* index_update = new StoreXNodeStoreLNode(ctrl, log_store, index_adr, adr_type, next_index, MemNode::unordered);
1536 phase->register_new_node(index_update, ctrl);
1537
1538 // Fast-path case
1539 region2->init_req(_fast_path, ctrl);
1540 phi2->init_req(_fast_path, index_update);
1541
1542 ctrl = full;
1543
1544 Node* base = find_bottom_mem(ctrl, phase);
1545
1546 MergeMemNode* mm = MergeMemNode::make(base);
1547 mm->set_memory_at(Compile::AliasIdxRaw, raw_mem);
1548 phase->register_new_node(mm, ctrl);
1549
1550 Node* call = new CallLeafNode(ShenandoahBarrierSetC2::write_ref_field_pre_entry_Type(), CAST_FROM_FN_PTR(address, ShenandoahRuntime::write_ref_field_pre_entry)((address)((address_word)(ShenandoahRuntime::write_ref_field_pre_entry
)))
, "shenandoah_wb_pre", TypeRawPtr::BOTTOM);
1551 call->init_req(TypeFunc::Control, ctrl);
1552 call->init_req(TypeFunc::I_O, phase->C->top());
1553 call->init_req(TypeFunc::Memory, mm);
1554 call->init_req(TypeFunc::FramePtr, phase->C->top());
1555 call->init_req(TypeFunc::ReturnAdr, phase->C->top());
1556 call->init_req(TypeFunc::Parms, pre_val);
1557 call->init_req(TypeFunc::Parms+1, thread);
1558 phase->register_control(call, loop, ctrl);
1559
1560 Node* ctrl_proj = new ProjNode(call, TypeFunc::Control);
1561 phase->register_control(ctrl_proj, loop, call);
1562 Node* mem_proj = new ProjNode(call, TypeFunc::Memory);
1563 phase->register_new_node(mem_proj, call);
1564
1565 // Slow-path case
1566 region2->init_req(_slow_path, ctrl_proj);
1567 phi2->init_req(_slow_path, mem_proj);
1568
1569 phase->register_control(region2, loop, reg2_ctrl);
1570 phase->register_new_node(phi2, region2);
1571
1572 region->init_req(_heap_unstable, region2);
1573 phi->init_req(_heap_unstable, phi2);
1574
1575 phase->register_control(region, loop, heap_stable_ctrl->in(0));
1576 phase->register_new_node(phi, region);
1577
1578 fix_ctrl(barrier, region, fixer, uses, uses_to_ignore, last, phase);
1579 for(uint next = 0; next < uses.size(); next++ ) {
1580 Node *n = uses.at(next);
1581 assert(phase->get_ctrl(n) == init_ctrl, "bad control")do { if (!(phase->get_ctrl(n) == init_ctrl)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 1581, "assert(" "phase->get_ctrl(n) == init_ctrl" ") failed"
, "bad control"); ::breakpoint(); } } while (0)
;
1582 assert(n != init_raw_mem, "should leave input raw mem above the barrier")do { if (!(n != init_raw_mem)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 1582, "assert(" "n != init_raw_mem" ") failed", "should leave input raw mem above the barrier"
); ::breakpoint(); } } while (0)
;
1583 phase->set_ctrl(n, region);
1584 follow_barrier_uses(n, init_ctrl, uses, phase);
1585 }
1586 fixer.fix_mem(init_ctrl, region, init_raw_mem, raw_mem_for_ctrl, phi, uses);
1587
1588 phase->igvn().replace_node(barrier, pre_val);
1589 }
1590 assert(state->iu_barriers_count() == 0, "all enqueue barrier nodes should have been replaced")do { if (!(state->iu_barriers_count() == 0)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 1590, "assert(" "state->iu_barriers_count() == 0" ") failed"
, "all enqueue barrier nodes should have been replaced"); ::breakpoint
(); } } while (0)
;
1591
1592}
1593
1594Node* ShenandoahBarrierC2Support::get_load_addr(PhaseIdealLoop* phase, VectorSet& visited, Node* in) {
1595 if (visited.test_set(in->_idx)) {
1596 return NULL__null;
1597 }
1598 switch (in->Opcode()) {
1599 case Op_Proj:
1600 return get_load_addr(phase, visited, in->in(0));
1601 case Op_CastPP:
1602 case Op_CheckCastPP:
1603 case Op_DecodeN:
1604 case Op_EncodeP:
1605 return get_load_addr(phase, visited, in->in(1));
1606 case Op_LoadN:
1607 case Op_LoadP:
1608 return in->in(MemNode::Address);
1609 case Op_CompareAndExchangeN:
1610 case Op_CompareAndExchangeP:
1611 case Op_GetAndSetN:
1612 case Op_GetAndSetP:
1613 case Op_ShenandoahCompareAndExchangeP:
1614 case Op_ShenandoahCompareAndExchangeN:
1615 // Those instructions would just have stored a different
1616 // value into the field. No use to attempt to fix it at this point.
1617 return phase->igvn().zerocon(T_OBJECT);
1618 case Op_CMoveP:
1619 case Op_CMoveN: {
1620 Node* t = get_load_addr(phase, visited, in->in(CMoveNode::IfTrue));
1621 Node* f = get_load_addr(phase, visited, in->in(CMoveNode::IfFalse));
1622 // Handle unambiguous cases: single address reported on both branches.
1623 if (t != NULL__null && f == NULL__null) return t;
1624 if (t == NULL__null && f != NULL__null) return f;
1625 if (t != NULL__null && t == f) return t;
1626 // Ambiguity.
1627 return phase->igvn().zerocon(T_OBJECT);
1628 }
1629 case Op_Phi: {
1630 Node* addr = NULL__null;
1631 for (uint i = 1; i < in->req(); i++) {
1632 Node* addr1 = get_load_addr(phase, visited, in->in(i));
1633 if (addr == NULL__null) {
1634 addr = addr1;
1635 }
1636 if (addr != addr1) {
1637 return phase->igvn().zerocon(T_OBJECT);
1638 }
1639 }
1640 return addr;
1641 }
1642 case Op_ShenandoahLoadReferenceBarrier:
1643 return get_load_addr(phase, visited, in->in(ShenandoahLoadReferenceBarrierNode::ValueIn));
1644 case Op_ShenandoahIUBarrier:
1645 return get_load_addr(phase, visited, in->in(1));
1646 case Op_CallDynamicJava:
1647 case Op_CallLeaf:
1648 case Op_CallStaticJava:
1649 case Op_ConN:
1650 case Op_ConP:
1651 case Op_Parm:
1652 case Op_CreateEx:
1653 return phase->igvn().zerocon(T_OBJECT);
1654 default:
1655#ifdef ASSERT1
1656 fatal("Unknown node in get_load_addr: %s", NodeClassNames[in->Opcode()])do { (*g_assert_poison) = 'X';; report_fatal(INTERNAL_ERROR, "/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 1656, "Unknown node in get_load_addr: %s", NodeClassNames[in
->Opcode()]); ::breakpoint(); } while (0)
;
1657#endif
1658 return phase->igvn().zerocon(T_OBJECT);
1659 }
1660
1661}
1662
1663void ShenandoahBarrierC2Support::move_gc_state_test_out_of_loop(IfNode* iff, PhaseIdealLoop* phase) {
1664 IdealLoopTree *loop = phase->get_loop(iff);
1665 Node* loop_head = loop->_head;
1666 Node* entry_c = loop_head->in(LoopNode::EntryControl);
1667
1668 Node* bol = iff->in(1);
1669 Node* cmp = bol->in(1);
1670 Node* andi = cmp->in(1);
1671 Node* load = andi->in(1);
1672
1673 assert(is_gc_state_load(load), "broken")do { if (!(is_gc_state_load(load))) { (*g_assert_poison) = 'X'
;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 1673, "assert(" "is_gc_state_load(load)" ") failed", "broken"
); ::breakpoint(); } } while (0)
;
1674 if (!phase->is_dominator(load->in(0), entry_c)) {
1675 Node* mem_ctrl = NULL__null;
1676 Node* mem = dom_mem(load->in(MemNode::Memory), loop_head, Compile::AliasIdxRaw, mem_ctrl, phase);
1677 load = load->clone();
1678 load->set_req(MemNode::Memory, mem);
1679 load->set_req(0, entry_c);
1680 phase->register_new_node(load, entry_c);
1681 andi = andi->clone();
1682 andi->set_req(1, load);
1683 phase->register_new_node(andi, entry_c);
1684 cmp = cmp->clone();
1685 cmp->set_req(1, andi);
1686 phase->register_new_node(cmp, entry_c);
1687 bol = bol->clone();
1688 bol->set_req(1, cmp);
1689 phase->register_new_node(bol, entry_c);
1690
1691 phase->igvn().replace_input_of(iff, 1, bol);
1692 }
1693}
1694
1695bool ShenandoahBarrierC2Support::identical_backtoback_ifs(Node* n, PhaseIdealLoop* phase) {
1696 if (!n->is_If() || n->is_CountedLoopEnd()) {
1697 return false;
1698 }
1699 Node* region = n->in(0);
1700
1701 if (!region->is_Region()) {
1702 return false;
1703 }
1704 Node* dom = phase->idom(region);
1705 if (!dom->is_If()) {
1706 return false;
1707 }
1708
1709 if (!is_heap_stable_test(n) || !is_heap_stable_test(dom)) {
1710 return false;
1711 }
1712
1713 IfNode* dom_if = dom->as_If();
1714 Node* proj_true = dom_if->proj_out(1);
1715 Node* proj_false = dom_if->proj_out(0);
1716
1717 for (uint i = 1; i < region->req(); i++) {
1718 if (phase->is_dominator(proj_true, region->in(i))) {
1719 continue;
1720 }
1721 if (phase->is_dominator(proj_false, region->in(i))) {
1722 continue;
1723 }
1724 return false;
1725 }
1726
1727 return true;
1728}
1729
1730void ShenandoahBarrierC2Support::merge_back_to_back_tests(Node* n, PhaseIdealLoop* phase) {
1731 assert(is_heap_stable_test(n), "no other tests")do { if (!(is_heap_stable_test(n))) { (*g_assert_poison) = 'X'
;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 1731, "assert(" "is_heap_stable_test(n)" ") failed", "no other tests"
); ::breakpoint(); } } while (0)
;
1732 if (identical_backtoback_ifs(n, phase)) {
1733 Node* n_ctrl = n->in(0);
1734 if (phase->can_split_if(n_ctrl)) {
1735 IfNode* dom_if = phase->idom(n_ctrl)->as_If();
1736 if (is_heap_stable_test(n)) {
1737 Node* gc_state_load = n->in(1)->in(1)->in(1)->in(1);
1738 assert(is_gc_state_load(gc_state_load), "broken")do { if (!(is_gc_state_load(gc_state_load))) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 1738, "assert(" "is_gc_state_load(gc_state_load)" ") failed"
, "broken"); ::breakpoint(); } } while (0)
;
1739 Node* dom_gc_state_load = dom_if->in(1)->in(1)->in(1)->in(1);
1740 assert(is_gc_state_load(dom_gc_state_load), "broken")do { if (!(is_gc_state_load(dom_gc_state_load))) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 1740, "assert(" "is_gc_state_load(dom_gc_state_load)" ") failed"
, "broken"); ::breakpoint(); } } while (0)
;
1741 if (gc_state_load != dom_gc_state_load) {
1742 phase->igvn().replace_node(gc_state_load, dom_gc_state_load);
1743 }
1744 }
1745 PhiNode* bolphi = PhiNode::make_blank(n_ctrl, n->in(1));
1746 Node* proj_true = dom_if->proj_out(1);
1747 Node* proj_false = dom_if->proj_out(0);
1748 Node* con_true = phase->igvn().makecon(TypeInt::ONE);
1749 Node* con_false = phase->igvn().makecon(TypeInt::ZERO);
1750
1751 for (uint i = 1; i < n_ctrl->req(); i++) {
1752 if (phase->is_dominator(proj_true, n_ctrl->in(i))) {
1753 bolphi->init_req(i, con_true);
1754 } else {
1755 assert(phase->is_dominator(proj_false, n_ctrl->in(i)), "bad if")do { if (!(phase->is_dominator(proj_false, n_ctrl->in(i
)))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 1755, "assert(" "phase->is_dominator(proj_false, n_ctrl->in(i))"
") failed", "bad if"); ::breakpoint(); } } while (0)
;
1756 bolphi->init_req(i, con_false);
1757 }
1758 }
1759 phase->register_new_node(bolphi, n_ctrl);
1760 phase->igvn().replace_input_of(n, 1, bolphi);
1761 phase->do_split_if(n);
1762 }
1763 }
1764}
1765
1766IfNode* ShenandoahBarrierC2Support::find_unswitching_candidate(const IdealLoopTree* loop, PhaseIdealLoop* phase) {
1767 // Find first invariant test that doesn't exit the loop
1768 LoopNode *head = loop->_head->as_Loop();
1769 IfNode* unswitch_iff = NULL__null;
1770 Node* n = head->in(LoopNode::LoopBackControl);
1771 int loop_has_sfpts = -1;
1772 while (n != head) {
1773 Node* n_dom = phase->idom(n);
1774 if (n->is_Region()) {
1775 if (n_dom->is_If()) {
1776 IfNode* iff = n_dom->as_If();
1777 if (iff->in(1)->is_Bool()) {
1778 BoolNode* bol = iff->in(1)->as_Bool();
1779 if (bol->in(1)->is_Cmp()) {
1780 // If condition is invariant and not a loop exit,
1781 // then found reason to unswitch.
1782 if (is_heap_stable_test(iff) &&
1783 (loop_has_sfpts == -1 || loop_has_sfpts == 0)) {
1784 assert(!loop->is_loop_exit(iff), "both branches should be in the loop")do { if (!(!loop->is_loop_exit(iff))) { (*g_assert_poison)
= 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 1784, "assert(" "!loop->is_loop_exit(iff)" ") failed", "both branches should be in the loop"
); ::breakpoint(); } } while (0)
;
1785 if (loop_has_sfpts == -1) {
1786 for(uint i = 0; i < loop->_body.size(); i++) {
1787 Node *m = loop->_body[i];
1788 if (m->is_SafePoint() && !m->is_CallLeaf()) {
1789 loop_has_sfpts = 1;
1790 break;
1791 }
1792 }
1793 if (loop_has_sfpts == -1) {
1794 loop_has_sfpts = 0;
1795 }
1796 }
1797 if (!loop_has_sfpts) {
1798 unswitch_iff = iff;
1799 }
1800 }
1801 }
1802 }
1803 }
1804 }
1805 n = n_dom;
1806 }
1807 return unswitch_iff;
1808}
1809
1810
1811void ShenandoahBarrierC2Support::optimize_after_expansion(VectorSet &visited, Node_Stack &stack, Node_List &old_new, PhaseIdealLoop* phase) {
1812 Node_List heap_stable_tests;
1813 stack.push(phase->C->start(), 0);
1814 do {
1815 Node* n = stack.node();
1816 uint i = stack.index();
1817
1818 if (i < n->outcnt()) {
1819 Node* u = n->raw_out(i);
1820 stack.set_index(i+1);
1821 if (!visited.test_set(u->_idx)) {
1822 stack.push(u, 0);
1823 }
1824 } else {
1825 stack.pop();
1826 if (n->is_If() && is_heap_stable_test(n)) {
1827 heap_stable_tests.push(n);
1828 }
1829 }
1830 } while (stack.size() > 0);
1831
1832 for (uint i = 0; i < heap_stable_tests.size(); i++) {
1833 Node* n = heap_stable_tests.at(i);
1834 assert(is_heap_stable_test(n), "only evacuation test")do { if (!(is_heap_stable_test(n))) { (*g_assert_poison) = 'X'
;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 1834, "assert(" "is_heap_stable_test(n)" ") failed", "only evacuation test"
); ::breakpoint(); } } while (0)
;
1835 merge_back_to_back_tests(n, phase);
1836 }
1837
1838 if (!phase->C->major_progress()) {
1839 VectorSet seen;
1840 for (uint i = 0; i < heap_stable_tests.size(); i++) {
1841 Node* n = heap_stable_tests.at(i);
1842 IdealLoopTree* loop = phase->get_loop(n);
1843 if (loop != phase->ltree_root() &&
1844 loop->_child == NULL__null &&
1845 !loop->_irreducible) {
1846 Node* head = loop->_head;
1847 if (head->is_Loop() &&
1848 (!head->is_CountedLoop() || head->as_CountedLoop()->is_main_loop() || head->as_CountedLoop()->is_normal_loop()) &&
1849 !seen.test_set(head->_idx)) {
1850 IfNode* iff = find_unswitching_candidate(loop, phase);
1851 if (iff != NULL__null) {
1852 Node* bol = iff->in(1);
1853 if (head->as_Loop()->is_strip_mined()) {
1854 head->as_Loop()->verify_strip_mined(0);
1855 }
1856 move_gc_state_test_out_of_loop(iff, phase);
1857
1858 AutoNodeBudget node_budget(phase);
1859
1860 if (loop->policy_unswitching(phase)) {
1861 if (head->as_Loop()->is_strip_mined()) {
1862 OuterStripMinedLoopNode* outer = head->as_CountedLoop()->outer_loop();
1863 hide_strip_mined_loop(outer, head->as_CountedLoop(), phase);
1864 }
1865 phase->do_unswitching(loop, old_new);
1866 } else {
1867 // Not proceeding with unswitching. Move load back in
1868 // the loop.
1869 phase->igvn().replace_input_of(iff, 1, bol);
1870 }
1871 }
1872 }
1873 }
1874 }
1875 }
1876}
1877
1878ShenandoahIUBarrierNode::ShenandoahIUBarrierNode(Node* val) : Node(NULL__null, val) {
1879 ShenandoahBarrierSetC2::bsc2()->state()->add_iu_barrier(this);
1880}
1881
1882const Type* ShenandoahIUBarrierNode::bottom_type() const {
1883 if (in(1) == NULL__null || in(1)->is_top()) {
1884 return Type::TOP;
1885 }
1886 const Type* t = in(1)->bottom_type();
1887 if (t == TypePtr::NULL_PTR) {
1888 return t;
1889 }
1890 return t->is_oopptr();
1891}
1892
1893const Type* ShenandoahIUBarrierNode::Value(PhaseGVN* phase) const {
1894 if (in(1) == NULL__null) {
1895 return Type::TOP;
1896 }
1897 const Type* t = phase->type(in(1));
1898 if (t == Type::TOP) {
1899 return Type::TOP;
1900 }
1901 if (t == TypePtr::NULL_PTR) {
1902 return t;
1903 }
1904 return t->is_oopptr();
1905}
1906
1907int ShenandoahIUBarrierNode::needed(Node* n) {
1908 if (n == NULL__null ||
1909 n->is_Allocate() ||
1910 n->Opcode() == Op_ShenandoahIUBarrier ||
1911 n->bottom_type() == TypePtr::NULL_PTR ||
1912 (n->bottom_type()->make_oopptr() != NULL__null && n->bottom_type()->make_oopptr()->const_oop() != NULL__null)) {
1913 return NotNeeded;
1914 }
1915 if (n->is_Phi() ||
1916 n->is_CMove()) {
1917 return MaybeNeeded;
1918 }
1919 return Needed;
1920}
1921
1922Node* ShenandoahIUBarrierNode::next(Node* n) {
1923 for (;;) {
1924 if (n == NULL__null) {
1925 return n;
1926 } else if (n->bottom_type() == TypePtr::NULL_PTR) {
1927 return n;
1928 } else if (n->bottom_type()->make_oopptr() != NULL__null && n->bottom_type()->make_oopptr()->const_oop() != NULL__null) {
1929 return n;
1930 } else if (n->is_ConstraintCast() ||
1931 n->Opcode() == Op_DecodeN ||
1932 n->Opcode() == Op_EncodeP) {
1933 n = n->in(1);
1934 } else if (n->is_Proj()) {
1935 n = n->in(0);
1936 } else {
1937 return n;
1938 }
1939 }
1940 ShouldNotReachHere()do { (*g_assert_poison) = 'X';; report_should_not_reach_here(
"/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 1940); ::breakpoint(); } while (0)
;
1941 return NULL__null;
1942}
1943
1944Node* ShenandoahIUBarrierNode::Identity(PhaseGVN* phase) {
1945 PhaseIterGVN* igvn = phase->is_IterGVN();
1946
1947 Node* n = next(in(1));
1948
1949 int cont = needed(n);
1950
1951 if (cont == NotNeeded) {
1952 return in(1);
1953 } else if (cont == MaybeNeeded) {
1954 if (igvn == NULL__null) {
1955 phase->record_for_igvn(this);
1956 return this;
1957 } else {
1958 ResourceMark rm;
1959 Unique_Node_List wq;
1960 uint wq_i = 0;
1961
1962 for (;;) {
1963 if (n->is_Phi()) {
1964 for (uint i = 1; i < n->req(); i++) {
1965 Node* m = n->in(i);
1966 if (m != NULL__null) {
1967 wq.push(m);
1968 }
1969 }
1970 } else {
1971 assert(n->is_CMove(), "nothing else here")do { if (!(n->is_CMove())) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 1971, "assert(" "n->is_CMove()" ") failed", "nothing else here"
); ::breakpoint(); } } while (0)
;
1972 Node* m = n->in(CMoveNode::IfFalse);
1973 wq.push(m);
1974 m = n->in(CMoveNode::IfTrue);
1975 wq.push(m);
1976 }
1977 Node* orig_n = NULL__null;
1978 do {
1979 if (wq_i >= wq.size()) {
1980 return in(1);
1981 }
1982 n = wq.at(wq_i);
1983 wq_i++;
1984 orig_n = n;
1985 n = next(n);
1986 cont = needed(n);
1987 if (cont == Needed) {
1988 return this;
1989 }
1990 } while (cont != MaybeNeeded || (orig_n != n && wq.member(n)));
1991 }
1992 }
1993 }
1994
1995 return this;
1996}
1997
1998#ifdef ASSERT1
1999static bool has_never_branch(Node* root) {
2000 for (uint i = 1; i < root->req(); i++) {
2001 Node* in = root->in(i);
2002 if (in != NULL__null && in->Opcode() == Op_Halt && in->in(0)->is_Proj() && in->in(0)->in(0)->Opcode() == Op_NeverBranch) {
2003 return true;
2004 }
2005 }
2006 return false;
2007}
2008#endif
2009
2010void MemoryGraphFixer::collect_memory_nodes() {
2011 Node_Stack stack(0);
2012 VectorSet visited;
2013 Node_List regions;
2014
2015 // Walk the raw memory graph and create a mapping from CFG node to
2016 // memory node. Exclude phis for now.
2017 stack.push(_phase->C->root(), 1);
2018 do {
2019 Node* n = stack.node();
2020 int opc = n->Opcode();
2021 uint i = stack.index();
2022 if (i < n->req()) {
2023 Node* mem = NULL__null;
2024 if (opc == Op_Root) {
2025 Node* in = n->in(i);
2026 int in_opc = in->Opcode();
2027 if (in_opc == Op_Return || in_opc == Op_Rethrow) {
2028 mem = in->in(TypeFunc::Memory);
2029 } else if (in_opc == Op_Halt) {
2030 if (in->in(0)->is_Region()) {
2031 Node* r = in->in(0);
2032 for (uint j = 1; j < r->req(); j++) {
2033 assert(r->in(j)->Opcode() != Op_NeverBranch, "")do { if (!(r->in(j)->Opcode() != Op_NeverBranch)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2033, "assert(" "r->in(j)->Opcode() != Op_NeverBranch"
") failed", ""); ::breakpoint(); } } while (0)
;
2034 }
2035 } else {
2036 Node* proj = in->in(0);
2037 assert(proj->is_Proj(), "")do { if (!(proj->is_Proj())) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2037, "assert(" "proj->is_Proj()" ") failed", ""); ::breakpoint
(); } } while (0)
;
2038 Node* in = proj->in(0);
2039 assert(in->is_CallStaticJava() || in->Opcode() == Op_NeverBranch || in->Opcode() == Op_Catch || proj->is_IfProj(), "")do { if (!(in->is_CallStaticJava() || in->Opcode() == Op_NeverBranch
|| in->Opcode() == Op_Catch || proj->is_IfProj())) { (
*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2039, "assert(" "in->is_CallStaticJava() || in->Opcode() == Op_NeverBranch || in->Opcode() == Op_Catch || proj->is_IfProj()"
") failed", ""); ::breakpoint(); } } while (0)
;
2040 if (in->is_CallStaticJava()) {
2041 mem = in->in(TypeFunc::Memory);
2042 } else if (in->Opcode() == Op_Catch) {
2043 Node* call = in->in(0)->in(0);
2044 assert(call->is_Call(), "")do { if (!(call->is_Call())) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2044, "assert(" "call->is_Call()" ") failed", ""); ::breakpoint
(); } } while (0)
;
2045 mem = call->in(TypeFunc::Memory);
2046 } else if (in->Opcode() == Op_NeverBranch) {
2047 mem = collect_memory_for_infinite_loop(in);
2048 }
2049 }
2050 } else {
2051#ifdef ASSERT1
2052 n->dump();
2053 in->dump();
2054#endif
2055 ShouldNotReachHere()do { (*g_assert_poison) = 'X';; report_should_not_reach_here(
"/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2055); ::breakpoint(); } while (0)
;
2056 }
2057 } else {
2058 assert(n->is_Phi() && n->bottom_type() == Type::MEMORY, "")do { if (!(n->is_Phi() && n->bottom_type() == Type
::MEMORY)) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2058, "assert(" "n->is_Phi() && n->bottom_type() == Type::MEMORY"
") failed", ""); ::breakpoint(); } } while (0)
;
2059 assert(n->adr_type() == TypePtr::BOTTOM || _phase->C->get_alias_index(n->adr_type()) == _alias, "")do { if (!(n->adr_type() == TypePtr::BOTTOM || _phase->
C->get_alias_index(n->adr_type()) == _alias)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2059, "assert(" "n->adr_type() == TypePtr::BOTTOM || _phase->C->get_alias_index(n->adr_type()) == _alias"
") failed", ""); ::breakpoint(); } } while (0)
;
2060 mem = n->in(i);
2061 }
2062 i++;
2063 stack.set_index(i);
2064 if (mem == NULL__null) {
2065 continue;
2066 }
2067 for (;;) {
2068 if (visited.test_set(mem->_idx) || mem->is_Start()) {
2069 break;
2070 }
2071 if (mem->is_Phi()) {
2072 stack.push(mem, 2);
2073 mem = mem->in(1);
2074 } else if (mem->is_Proj()) {
2075 stack.push(mem, mem->req());
2076 mem = mem->in(0);
2077 } else if (mem->is_SafePoint() || mem->is_MemBar()) {
2078 mem = mem->in(TypeFunc::Memory);
2079 } else if (mem->is_MergeMem()) {
2080 MergeMemNode* mm = mem->as_MergeMem();
2081 mem = mm->memory_at(_alias);
2082 } else if (mem->is_Store() || mem->is_LoadStore() || mem->is_ClearArray()) {
2083 assert(_alias == Compile::AliasIdxRaw, "")do { if (!(_alias == Compile::AliasIdxRaw)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2083, "assert(" "_alias == Compile::AliasIdxRaw" ") failed"
, ""); ::breakpoint(); } } while (0)
;
2084 stack.push(mem, mem->req());
2085 mem = mem->in(MemNode::Memory);
2086 } else {
2087#ifdef ASSERT1
2088 mem->dump();
2089#endif
2090 ShouldNotReachHere()do { (*g_assert_poison) = 'X';; report_should_not_reach_here(
"/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2090); ::breakpoint(); } while (0)
;
2091 }
2092 }
2093 } else {
2094 if (n->is_Phi()) {
2095 // Nothing
2096 } else if (!n->is_Root()) {
2097 Node* c = get_ctrl(n);
2098 _memory_nodes.map(c->_idx, n);
2099 }
2100 stack.pop();
2101 }
2102 } while(stack.is_nonempty());
2103
2104 // Iterate over CFG nodes in rpo and propagate memory state to
2105 // compute memory state at regions, creating new phis if needed.
2106 Node_List rpo_list;
2107 visited.clear();
2108 _phase->rpo(_phase->C->root(), stack, visited, rpo_list);
2109 Node* root = rpo_list.pop();
2110 assert(root == _phase->C->root(), "")do { if (!(root == _phase->C->root())) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2110, "assert(" "root == _phase->C->root()" ") failed"
, ""); ::breakpoint(); } } while (0)
;
2111
2112 const bool trace = false;
2113#ifdef ASSERT1
2114 if (trace) {
2115 for (int i = rpo_list.size() - 1; i >= 0; i--) {
2116 Node* c = rpo_list.at(i);
2117 if (_memory_nodes[c->_idx] != NULL__null) {
2118 tty->print("X %d", c->_idx); _memory_nodes[c->_idx]->dump();
2119 }
2120 }
2121 }
2122#endif
2123 uint last = _phase->C->unique();
2124
2125#ifdef ASSERT1
2126 uint16_t max_depth = 0;
2127 for (LoopTreeIterator iter(_phase->ltree_root()); !iter.done(); iter.next()) {
2128 IdealLoopTree* lpt = iter.current();
2129 max_depth = MAX2(max_depth, lpt->_nest);
2130 }
2131#endif
2132
2133 bool progress = true;
2134 int iteration = 0;
2135 Node_List dead_phis;
2136 while (progress) {
2137 progress = false;
2138 iteration++;
2139 assert(iteration <= 2+max_depth || _phase->C->has_irreducible_loop() || has_never_branch(_phase->C->root()), "")do { if (!(iteration <= 2+max_depth || _phase->C->has_irreducible_loop
() || has_never_branch(_phase->C->root()))) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2139, "assert(" "iteration <= 2+max_depth || _phase->C->has_irreducible_loop() || has_never_branch(_phase->C->root())"
") failed", ""); ::breakpoint(); } } while (0)
;
2140 if (trace) { tty->print_cr("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); }
2141
2142 for (int i = rpo_list.size() - 1; i >= 0; i--) {
2143 Node* c = rpo_list.at(i);
2144
2145 Node* prev_mem = _memory_nodes[c->_idx];
2146 if (c->is_Region() && (_include_lsm || !c->is_OuterStripMinedLoop())) {
2147 Node* prev_region = regions[c->_idx];
2148 Node* unique = NULL__null;
2149 for (uint j = 1; j < c->req() && unique != NodeSentinel(Node*)-1; j++) {
2150 Node* m = _memory_nodes[c->in(j)->_idx];
2151 assert(m != NULL || (c->is_Loop() && j == LoopNode::LoopBackControl && iteration == 1) || _phase->C->has_irreducible_loop() || has_never_branch(_phase->C->root()), "expect memory state")do { if (!(m != __null || (c->is_Loop() && j == LoopNode
::LoopBackControl && iteration == 1) || _phase->C->
has_irreducible_loop() || has_never_branch(_phase->C->root
()))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2151, "assert(" "m != __null || (c->is_Loop() && j == LoopNode::LoopBackControl && iteration == 1) || _phase->C->has_irreducible_loop() || has_never_branch(_phase->C->root())"
") failed", "expect memory state"); ::breakpoint(); } } while
(0)
;
2152 if (m != NULL__null) {
2153 if (m == prev_region && ((c->is_Loop() && j == LoopNode::LoopBackControl) || (prev_region->is_Phi() && prev_region->in(0) == c))) {
2154 assert(c->is_Loop() && j == LoopNode::LoopBackControl || _phase->C->has_irreducible_loop() || has_never_branch(_phase->C->root()), "")do { if (!(c->is_Loop() && j == LoopNode::LoopBackControl
|| _phase->C->has_irreducible_loop() || has_never_branch
(_phase->C->root()))) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2154, "assert(" "c->is_Loop() && j == LoopNode::LoopBackControl || _phase->C->has_irreducible_loop() || has_never_branch(_phase->C->root())"
") failed", ""); ::breakpoint(); } } while (0)
;
2155 // continue
2156 } else if (unique == NULL__null) {
2157 unique = m;
2158 } else if (m == unique) {
2159 // continue
2160 } else {
2161 unique = NodeSentinel(Node*)-1;
2162 }
2163 }
2164 }
2165 assert(unique != NULL, "empty phi???")do { if (!(unique != __null)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2165, "assert(" "unique != __null" ") failed", "empty phi???"
); ::breakpoint(); } } while (0)
;
2166 if (unique != NodeSentinel(Node*)-1) {
2167 if (prev_region != NULL__null && prev_region->is_Phi() && prev_region->in(0) == c) {
2168 dead_phis.push(prev_region);
2169 }
2170 regions.map(c->_idx, unique);
2171 } else {
2172 Node* phi = NULL__null;
2173 if (prev_region != NULL__null && prev_region->is_Phi() && prev_region->in(0) == c && prev_region->_idx >= last) {
2174 phi = prev_region;
2175 for (uint k = 1; k < c->req(); k++) {
2176 Node* m = _memory_nodes[c->in(k)->_idx];
2177 assert(m != NULL, "expect memory state")do { if (!(m != __null)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2177, "assert(" "m != __null" ") failed", "expect memory state"
); ::breakpoint(); } } while (0)
;
2178 phi->set_req(k, m);
2179 }
2180 } else {
2181 for (DUIterator_Fast jmax, j = c->fast_outs(jmax); j < jmax && phi == NULL__null; j++) {
2182 Node* u = c->fast_out(j);
2183 if (u->is_Phi() && u->bottom_type() == Type::MEMORY &&
2184 (u->adr_type() == TypePtr::BOTTOM || _phase->C->get_alias_index(u->adr_type()) == _alias)) {
2185 phi = u;
2186 for (uint k = 1; k < c->req() && phi != NULL__null; k++) {
2187 Node* m = _memory_nodes[c->in(k)->_idx];
2188 assert(m != NULL, "expect memory state")do { if (!(m != __null)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2188, "assert(" "m != __null" ") failed", "expect memory state"
); ::breakpoint(); } } while (0)
;
2189 if (u->in(k) != m) {
2190 phi = NodeSentinel(Node*)-1;
2191 }
2192 }
2193 }
2194 }
2195 if (phi == NodeSentinel(Node*)-1) {
2196 phi = new PhiNode(c, Type::MEMORY, _phase->C->get_adr_type(_alias));
2197 for (uint k = 1; k < c->req(); k++) {
2198 Node* m = _memory_nodes[c->in(k)->_idx];
2199 assert(m != NULL, "expect memory state")do { if (!(m != __null)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2199, "assert(" "m != __null" ") failed", "expect memory state"
); ::breakpoint(); } } while (0)
;
2200 phi->init_req(k, m);
2201 }
2202 }
2203 }
2204 if (phi != NULL__null) {
2205 regions.map(c->_idx, phi);
2206 } else {
2207 assert(c->unique_ctrl_out()->Opcode() == Op_Halt, "expected memory state")do { if (!(c->unique_ctrl_out()->Opcode() == Op_Halt)) {
(*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2207, "assert(" "c->unique_ctrl_out()->Opcode() == Op_Halt"
") failed", "expected memory state"); ::breakpoint(); } } while
(0)
;
2208 }
2209 }
2210 Node* current_region = regions[c->_idx];
2211 if (current_region != prev_region) {
2212 progress = true;
2213 if (prev_region == prev_mem) {
2214 _memory_nodes.map(c->_idx, current_region);
2215 }
2216 }
2217 } else if (prev_mem == NULL__null || prev_mem->is_Phi() || ctrl_or_self(prev_mem) != c) {
2218 Node* m = _memory_nodes[_phase->idom(c)->_idx];
2219 assert(m != NULL || c->Opcode() == Op_Halt, "expect memory state")do { if (!(m != __null || c->Opcode() == Op_Halt)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2219, "assert(" "m != __null || c->Opcode() == Op_Halt" ") failed"
, "expect memory state"); ::breakpoint(); } } while (0)
;
2220 if (m != prev_mem) {
2221 _memory_nodes.map(c->_idx, m);
2222 progress = true;
2223 }
2224 }
2225#ifdef ASSERT1
2226 if (trace) { tty->print("X %d", c->_idx); _memory_nodes[c->_idx]->dump(); }
2227#endif
2228 }
2229 }
2230
2231 // Replace existing phi with computed memory state for that region
2232 // if different (could be a new phi or a dominating memory node if
2233 // that phi was found to be useless).
2234 while (dead_phis.size() > 0) {
2235 Node* n = dead_phis.pop();
2236 n->replace_by(_phase->C->top());
2237 n->destruct(&_phase->igvn());
2238 }
2239 for (int i = rpo_list.size() - 1; i >= 0; i--) {
2240 Node* c = rpo_list.at(i);
2241 if (c->is_Region() && (_include_lsm || !c->is_OuterStripMinedLoop())) {
2242 Node* n = regions[c->_idx];
2243 assert(n != NULL || c->unique_ctrl_out()->Opcode() == Op_Halt, "expected memory state")do { if (!(n != __null || c->unique_ctrl_out()->Opcode(
) == Op_Halt)) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2243, "assert(" "n != __null || c->unique_ctrl_out()->Opcode() == Op_Halt"
") failed", "expected memory state"); ::breakpoint(); } } while
(0)
;
2244 if (n != NULL__null && n->is_Phi() && n->_idx >= last && n->in(0) == c) {
2245 _phase->register_new_node(n, c);
2246 }
2247 }
2248 }
2249 for (int i = rpo_list.size() - 1; i >= 0; i--) {
2250 Node* c = rpo_list.at(i);
2251 if (c->is_Region() && (_include_lsm || !c->is_OuterStripMinedLoop())) {
2252 Node* n = regions[c->_idx];
2253 assert(n != NULL || c->unique_ctrl_out()->Opcode() == Op_Halt, "expected memory state")do { if (!(n != __null || c->unique_ctrl_out()->Opcode(
) == Op_Halt)) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2253, "assert(" "n != __null || c->unique_ctrl_out()->Opcode() == Op_Halt"
") failed", "expected memory state"); ::breakpoint(); } } while
(0)
;
2254 for (DUIterator_Fast imax, i = c->fast_outs(imax); i < imax; i++) {
2255 Node* u = c->fast_out(i);
2256 if (u->is_Phi() && u->bottom_type() == Type::MEMORY &&
2257 u != n) {
2258 assert(c->unique_ctrl_out()->Opcode() != Op_Halt, "expected memory state")do { if (!(c->unique_ctrl_out()->Opcode() != Op_Halt)) {
(*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2258, "assert(" "c->unique_ctrl_out()->Opcode() != Op_Halt"
") failed", "expected memory state"); ::breakpoint(); } } while
(0)
;
2259 if (u->adr_type() == TypePtr::BOTTOM) {
2260 fix_memory_uses(u, n, n, c);
2261 } else if (_phase->C->get_alias_index(u->adr_type()) == _alias) {
2262 _phase->lazy_replace(u, n);
2263 --i; --imax;
2264 }
2265 }
2266 }
2267 }
2268 }
2269}
2270
2271Node* MemoryGraphFixer::collect_memory_for_infinite_loop(const Node* in) {
2272 Node* mem = NULL__null;
2273 Node* head = in->in(0);
2274 assert(head->is_Region(), "unexpected infinite loop graph shape")do { if (!(head->is_Region())) { (*g_assert_poison) = 'X';
; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2274, "assert(" "head->is_Region()" ") failed", "unexpected infinite loop graph shape"
); ::breakpoint(); } } while (0)
;
2275
2276 Node* phi_mem = NULL__null;
2277 for (DUIterator_Fast jmax, j = head->fast_outs(jmax); j < jmax; j++) {
2278 Node* u = head->fast_out(j);
2279 if (u->is_Phi() && u->bottom_type() == Type::MEMORY) {
2280 if (_phase->C->get_alias_index(u->adr_type()) == _alias) {
2281 assert(phi_mem == NULL || phi_mem->adr_type() == TypePtr::BOTTOM, "")do { if (!(phi_mem == __null || phi_mem->adr_type() == TypePtr
::BOTTOM)) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2281, "assert(" "phi_mem == __null || phi_mem->adr_type() == TypePtr::BOTTOM"
") failed", ""); ::breakpoint(); } } while (0)
;
2282 phi_mem = u;
2283 } else if (u->adr_type() == TypePtr::BOTTOM) {
2284 assert(phi_mem == NULL || _phase->C->get_alias_index(phi_mem->adr_type()) == _alias, "")do { if (!(phi_mem == __null || _phase->C->get_alias_index
(phi_mem->adr_type()) == _alias)) { (*g_assert_poison) = 'X'
;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2284, "assert(" "phi_mem == __null || _phase->C->get_alias_index(phi_mem->adr_type()) == _alias"
") failed", ""); ::breakpoint(); } } while (0)
;
2285 if (phi_mem == NULL__null) {
2286 phi_mem = u;
2287 }
2288 }
2289 }
2290 }
2291 if (phi_mem == NULL__null) {
2292 ResourceMark rm;
2293 Node_Stack stack(0);
2294 stack.push(head, 1);
2295 do {
2296 Node* n = stack.node();
2297 uint i = stack.index();
2298 if (i >= n->req()) {
2299 stack.pop();
2300 } else {
2301 stack.set_index(i + 1);
2302 Node* c = n->in(i);
2303 assert(c != head, "should have found a safepoint on the way")do { if (!(c != head)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2303, "assert(" "c != head" ") failed", "should have found a safepoint on the way"
); ::breakpoint(); } } while (0)
;
2304 if (stack.size() != 1 || _phase->is_dominator(head, c)) {
2305 for (;;) {
2306 if (c->is_Region()) {
2307 stack.push(c, 1);
2308 break;
2309 } else if (c->is_SafePoint() && !c->is_CallLeaf()) {
2310 Node* m = c->in(TypeFunc::Memory);
2311 if (m->is_MergeMem()) {
2312 m = m->as_MergeMem()->memory_at(_alias);
2313 }
2314 assert(mem == NULL || mem == m, "several memory states")do { if (!(mem == __null || mem == m)) { (*g_assert_poison) =
'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2314, "assert(" "mem == __null || mem == m" ") failed", "several memory states"
); ::breakpoint(); } } while (0)
;
2315 mem = m;
2316 break;
2317 } else {
2318 assert(c != c->in(0), "")do { if (!(c != c->in(0))) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2318, "assert(" "c != c->in(0)" ") failed", ""); ::breakpoint
(); } } while (0)
;
2319 c = c->in(0);
2320 }
2321 }
2322 }
2323 }
2324 } while (stack.size() > 0);
2325 assert(mem != NULL, "should have found safepoint")do { if (!(mem != __null)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2325, "assert(" "mem != __null" ") failed", "should have found safepoint"
); ::breakpoint(); } } while (0)
;
2326 } else {
2327 mem = phi_mem;
2328 }
2329 return mem;
2330}
2331
2332Node* MemoryGraphFixer::get_ctrl(Node* n) const {
2333 Node* c = _phase->get_ctrl(n);
2334 if (n->is_Proj() && n->in(0) != NULL__null && n->in(0)->is_Call()) {
2335 assert(c == n->in(0), "")do { if (!(c == n->in(0))) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2335, "assert(" "c == n->in(0)" ") failed", ""); ::breakpoint
(); } } while (0)
;
2336 CallNode* call = c->as_Call();
2337 CallProjections projs;
2338 call->extract_projections(&projs, true, false);
2339 if (projs.catchall_memproj != NULL__null) {
2340 if (projs.fallthrough_memproj == n) {
2341 c = projs.fallthrough_catchproj;
2342 } else {
2343 assert(projs.catchall_memproj == n, "")do { if (!(projs.catchall_memproj == n)) { (*g_assert_poison)
= 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2343, "assert(" "projs.catchall_memproj == n" ") failed", ""
); ::breakpoint(); } } while (0)
;
2344 c = projs.catchall_catchproj;
2345 }
2346 }
2347 }
2348 return c;
2349}
2350
2351Node* MemoryGraphFixer::ctrl_or_self(Node* n) const {
2352 if (_phase->has_ctrl(n))
2353 return get_ctrl(n);
2354 else {
2355 assert (n->is_CFG(), "must be a CFG node")do { if (!(n->is_CFG())) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2355, "assert(" "n->is_CFG()" ") failed", "must be a CFG node"
); ::breakpoint(); } } while (0)
;
2356 return n;
2357 }
2358}
2359
2360bool MemoryGraphFixer::mem_is_valid(Node* m, Node* c) const {
2361 return m != NULL__null && get_ctrl(m) == c;
2362}
2363
2364Node* MemoryGraphFixer::find_mem(Node* ctrl, Node* n) const {
2365 assert(n == NULL || _phase->ctrl_or_self(n) == ctrl, "")do { if (!(n == __null || _phase->ctrl_or_self(n) == ctrl)
) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2365, "assert(" "n == __null || _phase->ctrl_or_self(n) == ctrl"
") failed", ""); ::breakpoint(); } } while (0)
;
2366 assert(!ctrl->is_Call() || ctrl == n, "projection expected")do { if (!(!ctrl->is_Call() || ctrl == n)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2366, "assert(" "!ctrl->is_Call() || ctrl == n" ") failed"
, "projection expected"); ::breakpoint(); } } while (0)
;
2367#ifdef ASSERT1
2368 if ((ctrl->is_Proj() && ctrl->in(0)->is_Call()) ||
2369 (ctrl->is_Catch() && ctrl->in(0)->in(0)->is_Call())) {
2370 CallNode* call = ctrl->is_Proj() ? ctrl->in(0)->as_Call() : ctrl->in(0)->in(0)->as_Call();
2371 int mems = 0;
2372 for (DUIterator_Fast imax, i = call->fast_outs(imax); i < imax; i++) {
2373 Node* u = call->fast_out(i);
2374 if (u->bottom_type() == Type::MEMORY) {
2375 mems++;
2376 }
2377 }
2378 assert(mems <= 1, "No node right after call if multiple mem projections")do { if (!(mems <= 1)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2378, "assert(" "mems <= 1" ") failed", "No node right after call if multiple mem projections"
); ::breakpoint(); } } while (0)
;
2379 }
2380#endif
2381 Node* mem = _memory_nodes[ctrl->_idx];
2382 Node* c = ctrl;
2383 while (!mem_is_valid(mem, c) &&
2384 (!c->is_CatchProj() || mem == NULL__null || c->in(0)->in(0)->in(0) != get_ctrl(mem))) {
2385 c = _phase->idom(c);
2386 mem = _memory_nodes[c->_idx];
2387 }
2388 if (n != NULL__null && mem_is_valid(mem, c)) {
2389 while (!ShenandoahBarrierC2Support::is_dominator_same_ctrl(c, mem, n, _phase) && _phase->ctrl_or_self(mem) == ctrl) {
2390 mem = next_mem(mem, _alias);
2391 }
2392 if (mem->is_MergeMem()) {
2393 mem = mem->as_MergeMem()->memory_at(_alias);
2394 }
2395 if (!mem_is_valid(mem, c)) {
2396 do {
2397 c = _phase->idom(c);
2398 mem = _memory_nodes[c->_idx];
2399 } while (!mem_is_valid(mem, c) &&
2400 (!c->is_CatchProj() || mem == NULL__null || c->in(0)->in(0)->in(0) != get_ctrl(mem)));
2401 }
2402 }
2403 assert(mem->bottom_type() == Type::MEMORY, "")do { if (!(mem->bottom_type() == Type::MEMORY)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2403, "assert(" "mem->bottom_type() == Type::MEMORY" ") failed"
, ""); ::breakpoint(); } } while (0)
;
2404 return mem;
2405}
2406
2407bool MemoryGraphFixer::has_mem_phi(Node* region) const {
2408 for (DUIterator_Fast imax, i = region->fast_outs(imax); i < imax; i++) {
2409 Node* use = region->fast_out(i);
2410 if (use->is_Phi() && use->bottom_type() == Type::MEMORY &&
2411 (_phase->C->get_alias_index(use->adr_type()) == _alias)) {
2412 return true;
2413 }
2414 }
2415 return false;
2416}
2417
2418void MemoryGraphFixer::fix_mem(Node* ctrl, Node* new_ctrl, Node* mem, Node* mem_for_ctrl, Node* new_mem, Unique_Node_List& uses) {
2419 assert(_phase->ctrl_or_self(new_mem) == new_ctrl, "")do { if (!(_phase->ctrl_or_self(new_mem) == new_ctrl)) { (
*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2419, "assert(" "_phase->ctrl_or_self(new_mem) == new_ctrl"
") failed", ""); ::breakpoint(); } } while (0)
;
2420 const bool trace = false;
2421 DEBUG_ONLY(if (trace) { tty->print("ZZZ control is"); ctrl->dump(); })if (trace) { tty->print("ZZZ control is"); ctrl->dump()
; }
;
2422 DEBUG_ONLY(if (trace) { tty->print("ZZZ mem is"); mem->dump(); })if (trace) { tty->print("ZZZ mem is"); mem->dump(); };
2423 GrowableArray<Node*> phis;
2424 if (mem_for_ctrl != mem) {
2425 Node* old = mem_for_ctrl;
2426 Node* prev = NULL__null;
2427 while (old != mem) {
2428 prev = old;
2429 if (old->is_Store() || old->is_ClearArray() || old->is_LoadStore()) {
2430 assert(_alias == Compile::AliasIdxRaw, "")do { if (!(_alias == Compile::AliasIdxRaw)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2430, "assert(" "_alias == Compile::AliasIdxRaw" ") failed"
, ""); ::breakpoint(); } } while (0)
;
2431 old = old->in(MemNode::Memory);
2432 } else if (old->Opcode() == Op_SCMemProj) {
2433 assert(_alias == Compile::AliasIdxRaw, "")do { if (!(_alias == Compile::AliasIdxRaw)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2433, "assert(" "_alias == Compile::AliasIdxRaw" ") failed"
, ""); ::breakpoint(); } } while (0)
;
2434 old = old->in(0);
2435 } else {
2436 ShouldNotReachHere()do { (*g_assert_poison) = 'X';; report_should_not_reach_here(
"/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2436); ::breakpoint(); } while (0)
;
2437 }
2438 }
2439 assert(prev != NULL, "")do { if (!(prev != __null)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2439, "assert(" "prev != __null" ") failed", ""); ::breakpoint
(); } } while (0)
;
2440 if (new_ctrl != ctrl) {
2441 _memory_nodes.map(ctrl->_idx, mem);
2442 _memory_nodes.map(new_ctrl->_idx, mem_for_ctrl);
2443 }
2444 uint input = (uint)MemNode::Memory;
2445 _phase->igvn().replace_input_of(prev, input, new_mem);
2446 } else {
2447 uses.clear();
2448 _memory_nodes.map(new_ctrl->_idx, new_mem);
2449 uses.push(new_ctrl);
2450 for(uint next = 0; next < uses.size(); next++ ) {
2451 Node *n = uses.at(next);
2452 assert(n->is_CFG(), "")do { if (!(n->is_CFG())) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2452, "assert(" "n->is_CFG()" ") failed", ""); ::breakpoint
(); } } while (0)
;
2453 DEBUG_ONLY(if (trace) { tty->print("ZZZ ctrl"); n->dump(); })if (trace) { tty->print("ZZZ ctrl"); n->dump(); };
2454 for (DUIterator_Fast imax, i = n->fast_outs(imax); i < imax; i++) {
2455 Node* u = n->fast_out(i);
2456 if (!u->is_Root() && u->is_CFG() && u != n) {
2457 Node* m = _memory_nodes[u->_idx];
2458 if (u->is_Region() && (!u->is_OuterStripMinedLoop() || _include_lsm) &&
2459 !has_mem_phi(u) &&
2460 u->unique_ctrl_out()->Opcode() != Op_Halt) {
2461 DEBUG_ONLY(if (trace) { tty->print("ZZZ region"); u->dump(); })if (trace) { tty->print("ZZZ region"); u->dump(); };
2462 DEBUG_ONLY(if (trace && m != NULL) { tty->print("ZZZ mem"); m->dump(); })if (trace && m != __null) { tty->print("ZZZ mem");
m->dump(); }
;
2463
2464 if (!mem_is_valid(m, u) || !m->is_Phi()) {
2465 bool push = true;
2466 bool create_phi = true;
2467 if (_phase->is_dominator(new_ctrl, u)) {
2468 create_phi = false;
2469 }
2470 if (create_phi) {
2471 Node* phi = new PhiNode(u, Type::MEMORY, _phase->C->get_adr_type(_alias));
2472 _phase->register_new_node(phi, u);
2473 phis.push(phi);
2474 DEBUG_ONLY(if (trace) { tty->print("ZZZ new phi"); phi->dump(); })if (trace) { tty->print("ZZZ new phi"); phi->dump(); };
2475 if (!mem_is_valid(m, u)) {
2476 DEBUG_ONLY(if (trace) { tty->print("ZZZ setting mem"); phi->dump(); })if (trace) { tty->print("ZZZ setting mem"); phi->dump()
; }
;
2477 _memory_nodes.map(u->_idx, phi);
2478 } else {
2479 DEBUG_ONLY(if (trace) { tty->print("ZZZ NOT setting mem"); m->dump(); })if (trace) { tty->print("ZZZ NOT setting mem"); m->dump
(); }
;
2480 for (;;) {
2481 assert(m->is_Mem() || m->is_LoadStore() || m->is_Proj(), "")do { if (!(m->is_Mem() || m->is_LoadStore() || m->is_Proj
())) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2481, "assert(" "m->is_Mem() || m->is_LoadStore() || m->is_Proj()"
") failed", ""); ::breakpoint(); } } while (0)
;
2482 Node* next = NULL__null;
2483 if (m->is_Proj()) {
2484 next = m->in(0);
2485 } else {
2486 assert(m->is_Mem() || m->is_LoadStore(), "")do { if (!(m->is_Mem() || m->is_LoadStore())) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2486, "assert(" "m->is_Mem() || m->is_LoadStore()" ") failed"
, ""); ::breakpoint(); } } while (0)
;
2487 assert(_alias == Compile::AliasIdxRaw, "")do { if (!(_alias == Compile::AliasIdxRaw)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2487, "assert(" "_alias == Compile::AliasIdxRaw" ") failed"
, ""); ::breakpoint(); } } while (0)
;
2488 next = m->in(MemNode::Memory);
2489 }
2490 if (_phase->get_ctrl(next) != u) {
2491 break;
2492 }
2493 if (next->is_MergeMem()) {
2494 assert(_phase->get_ctrl(next->as_MergeMem()->memory_at(_alias)) != u, "")do { if (!(_phase->get_ctrl(next->as_MergeMem()->memory_at
(_alias)) != u)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2494, "assert(" "_phase->get_ctrl(next->as_MergeMem()->memory_at(_alias)) != u"
") failed", ""); ::breakpoint(); } } while (0)
;
2495 break;
2496 }
2497 if (next->is_Phi()) {
2498 assert(next->adr_type() == TypePtr::BOTTOM && next->in(0) == u, "")do { if (!(next->adr_type() == TypePtr::BOTTOM && next
->in(0) == u)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2498, "assert(" "next->adr_type() == TypePtr::BOTTOM && next->in(0) == u"
") failed", ""); ::breakpoint(); } } while (0)
;
2499 break;
2500 }
2501 m = next;
2502 }
2503
2504 DEBUG_ONLY(if (trace) { tty->print("ZZZ setting to phi"); m->dump(); })if (trace) { tty->print("ZZZ setting to phi"); m->dump(
); }
;
2505 assert(m->is_Mem() || m->is_LoadStore(), "")do { if (!(m->is_Mem() || m->is_LoadStore())) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2505, "assert(" "m->is_Mem() || m->is_LoadStore()" ") failed"
, ""); ::breakpoint(); } } while (0)
;
2506 uint input = (uint)MemNode::Memory;
2507 _phase->igvn().replace_input_of(m, input, phi);
2508 push = false;
2509 }
2510 } else {
2511 DEBUG_ONLY(if (trace) { tty->print("ZZZ skipping region"); u->dump(); })if (trace) { tty->print("ZZZ skipping region"); u->dump
(); }
;
2512 }
2513 if (push) {
2514 uses.push(u);
2515 }
2516 }
2517 } else if (!mem_is_valid(m, u) &&
2518 !(u->Opcode() == Op_CProj && u->in(0)->Opcode() == Op_NeverBranch && u->as_Proj()->_con == 1)) {
2519 uses.push(u);
2520 }
2521 }
2522 }
2523 }
2524 for (int i = 0; i < phis.length(); i++) {
2525 Node* n = phis.at(i);
2526 Node* r = n->in(0);
2527 DEBUG_ONLY(if (trace) { tty->print("ZZZ fixing new phi"); n->dump(); })if (trace) { tty->print("ZZZ fixing new phi"); n->dump(
); }
;
2528 for (uint j = 1; j < n->req(); j++) {
2529 Node* m = find_mem(r->in(j), NULL__null);
2530 _phase->igvn().replace_input_of(n, j, m);
2531 DEBUG_ONLY(if (trace) { tty->print("ZZZ fixing new phi: %d", j); m->dump(); })if (trace) { tty->print("ZZZ fixing new phi: %d", j); m->
dump(); }
;
2532 }
2533 }
2534 }
2535 uint last = _phase->C->unique();
2536 MergeMemNode* mm = NULL__null;
2537 int alias = _alias;
2538 DEBUG_ONLY(if (trace) { tty->print("ZZZ raw mem is"); mem->dump(); })if (trace) { tty->print("ZZZ raw mem is"); mem->dump();
}
;
2539 // Process loads first to not miss an anti-dependency: if the memory
2540 // edge of a store is updated before a load is processed then an
2541 // anti-dependency may be missed.
2542 for (DUIterator i = mem->outs(); mem->has_out(i); i++) {
2543 Node* u = mem->out(i);
2544 if (u->_idx < last && u->is_Load() && _phase->C->get_alias_index(u->adr_type()) == alias) {
2545 Node* m = find_mem(_phase->get_ctrl(u), u);
2546 if (m != mem) {
2547 DEBUG_ONLY(if (trace) { tty->print("ZZZ setting memory of use"); u->dump(); })if (trace) { tty->print("ZZZ setting memory of use"); u->
dump(); }
;
2548 _phase->igvn().replace_input_of(u, MemNode::Memory, m);
2549 --i;
2550 }
2551 }
2552 }
2553 for (DUIterator i = mem->outs(); mem->has_out(i); i++) {
2554 Node* u = mem->out(i);
2555 if (u->_idx < last) {
2556 if (u->is_Mem()) {
2557 if (_phase->C->get_alias_index(u->adr_type()) == alias) {
2558 Node* m = find_mem(_phase->get_ctrl(u), u);
2559 if (m != mem) {
2560 DEBUG_ONLY(if (trace) { tty->print("ZZZ setting memory of use"); u->dump(); })if (trace) { tty->print("ZZZ setting memory of use"); u->
dump(); }
;
2561 _phase->igvn().replace_input_of(u, MemNode::Memory, m);
2562 --i;
2563 }
2564 }
2565 } else if (u->is_MergeMem()) {
2566 MergeMemNode* u_mm = u->as_MergeMem();
2567 if (u_mm->memory_at(alias) == mem) {
2568 MergeMemNode* newmm = NULL__null;
2569 for (DUIterator_Fast jmax, j = u->fast_outs(jmax); j < jmax; j++) {
2570 Node* uu = u->fast_out(j);
2571 assert(!uu->is_MergeMem(), "chain of MergeMems?")do { if (!(!uu->is_MergeMem())) { (*g_assert_poison) = 'X'
;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2571, "assert(" "!uu->is_MergeMem()" ") failed", "chain of MergeMems?"
); ::breakpoint(); } } while (0)
;
2572 if (uu->is_Phi()) {
2573 assert(uu->adr_type() == TypePtr::BOTTOM, "")do { if (!(uu->adr_type() == TypePtr::BOTTOM)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2573, "assert(" "uu->adr_type() == TypePtr::BOTTOM" ") failed"
, ""); ::breakpoint(); } } while (0)
;
2574 Node* region = uu->in(0);
2575 int nb = 0;
2576 for (uint k = 1; k < uu->req(); k++) {
2577 if (uu->in(k) == u) {
2578 Node* m = find_mem(region->in(k), NULL__null);
2579 if (m != mem) {
2580 DEBUG_ONLY(if (trace) { tty->print("ZZZ setting memory of phi %d", k); uu->dump(); })if (trace) { tty->print("ZZZ setting memory of phi %d", k)
; uu->dump(); }
;
2581 newmm = clone_merge_mem(u, mem, m, _phase->ctrl_or_self(m), i);
2582 if (newmm != u) {
2583 _phase->igvn().replace_input_of(uu, k, newmm);
2584 nb++;
2585 --jmax;
2586 }
2587 }
2588 }
2589 }
2590 if (nb > 0) {
2591 --j;
2592 }
2593 } else {
2594 Node* m = find_mem(_phase->ctrl_or_self(uu), uu);
2595 if (m != mem) {
2596 DEBUG_ONLY(if (trace) { tty->print("ZZZ setting memory of use"); uu->dump(); })if (trace) { tty->print("ZZZ setting memory of use"); uu->
dump(); }
;
2597 newmm = clone_merge_mem(u, mem, m, _phase->ctrl_or_self(m), i);
2598 if (newmm != u) {
2599 _phase->igvn().replace_input_of(uu, uu->find_edge(u), newmm);
2600 --j, --jmax;
2601 }
2602 }
2603 }
2604 }
2605 }
2606 } else if (u->is_Phi()) {
2607 assert(u->bottom_type() == Type::MEMORY, "what else?")do { if (!(u->bottom_type() == Type::MEMORY)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2607, "assert(" "u->bottom_type() == Type::MEMORY" ") failed"
, "what else?"); ::breakpoint(); } } while (0)
;
2608 if (_phase->C->get_alias_index(u->adr_type()) == alias || u->adr_type() == TypePtr::BOTTOM) {
2609 Node* region = u->in(0);
2610 bool replaced = false;
2611 for (uint j = 1; j < u->req(); j++) {
2612 if (u->in(j) == mem) {
2613 Node* m = find_mem(region->in(j), NULL__null);
2614 Node* nnew = m;
2615 if (m != mem) {
2616 if (u->adr_type() == TypePtr::BOTTOM) {
2617 mm = allocate_merge_mem(mem, m, _phase->ctrl_or_self(m));
2618 nnew = mm;
2619 }
2620 DEBUG_ONLY(if (trace) { tty->print("ZZZ setting memory of phi %d", j); u->dump(); })if (trace) { tty->print("ZZZ setting memory of phi %d", j)
; u->dump(); }
;
2621 _phase->igvn().replace_input_of(u, j, nnew);
2622 replaced = true;
2623 }
2624 }
2625 }
2626 if (replaced) {
2627 --i;
2628 }
2629 }
2630 } else if ((u->adr_type() == TypePtr::BOTTOM && u->Opcode() != Op_StrInflatedCopy) ||
2631 u->adr_type() == NULL__null) {
2632 assert(u->adr_type() != NULL ||do { if (!(u->adr_type() != __null || u->Opcode() == Op_Rethrow
|| u->Opcode() == Op_Return || u->Opcode() == Op_SafePoint
|| (u->is_CallStaticJava() && u->as_CallStaticJava
()->uncommon_trap_request() != 0) || (u->is_CallStaticJava
() && u->as_CallStaticJava()->_entry_point == OptoRuntime
::rethrow_stub()) || u->Opcode() == Op_CallLeaf)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2638, "assert(" "u->adr_type() != __null || u->Opcode() == Op_Rethrow || u->Opcode() == Op_Return || u->Opcode() == Op_SafePoint || (u->is_CallStaticJava() && u->as_CallStaticJava()->uncommon_trap_request() != 0) || (u->is_CallStaticJava() && u->as_CallStaticJava()->_entry_point == OptoRuntime::rethrow_stub()) || u->Opcode() == Op_CallLeaf"
") failed", ""); ::breakpoint(); } } while (0)
2633 u->Opcode() == Op_Rethrow ||do { if (!(u->adr_type() != __null || u->Opcode() == Op_Rethrow
|| u->Opcode() == Op_Return || u->Opcode() == Op_SafePoint
|| (u->is_CallStaticJava() && u->as_CallStaticJava
()->uncommon_trap_request() != 0) || (u->is_CallStaticJava
() && u->as_CallStaticJava()->_entry_point == OptoRuntime
::rethrow_stub()) || u->Opcode() == Op_CallLeaf)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2638, "assert(" "u->adr_type() != __null || u->Opcode() == Op_Rethrow || u->Opcode() == Op_Return || u->Opcode() == Op_SafePoint || (u->is_CallStaticJava() && u->as_CallStaticJava()->uncommon_trap_request() != 0) || (u->is_CallStaticJava() && u->as_CallStaticJava()->_entry_point == OptoRuntime::rethrow_stub()) || u->Opcode() == Op_CallLeaf"
") failed", ""); ::breakpoint(); } } while (0)
2634 u->Opcode() == Op_Return ||do { if (!(u->adr_type() != __null || u->Opcode() == Op_Rethrow
|| u->Opcode() == Op_Return || u->Opcode() == Op_SafePoint
|| (u->is_CallStaticJava() && u->as_CallStaticJava
()->uncommon_trap_request() != 0) || (u->is_CallStaticJava
() && u->as_CallStaticJava()->_entry_point == OptoRuntime
::rethrow_stub()) || u->Opcode() == Op_CallLeaf)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2638, "assert(" "u->adr_type() != __null || u->Opcode() == Op_Rethrow || u->Opcode() == Op_Return || u->Opcode() == Op_SafePoint || (u->is_CallStaticJava() && u->as_CallStaticJava()->uncommon_trap_request() != 0) || (u->is_CallStaticJava() && u->as_CallStaticJava()->_entry_point == OptoRuntime::rethrow_stub()) || u->Opcode() == Op_CallLeaf"
") failed", ""); ::breakpoint(); } } while (0)
2635 u->Opcode() == Op_SafePoint ||do { if (!(u->adr_type() != __null || u->Opcode() == Op_Rethrow
|| u->Opcode() == Op_Return || u->Opcode() == Op_SafePoint
|| (u->is_CallStaticJava() && u->as_CallStaticJava
()->uncommon_trap_request() != 0) || (u->is_CallStaticJava
() && u->as_CallStaticJava()->_entry_point == OptoRuntime
::rethrow_stub()) || u->Opcode() == Op_CallLeaf)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2638, "assert(" "u->adr_type() != __null || u->Opcode() == Op_Rethrow || u->Opcode() == Op_Return || u->Opcode() == Op_SafePoint || (u->is_CallStaticJava() && u->as_CallStaticJava()->uncommon_trap_request() != 0) || (u->is_CallStaticJava() && u->as_CallStaticJava()->_entry_point == OptoRuntime::rethrow_stub()) || u->Opcode() == Op_CallLeaf"
") failed", ""); ::breakpoint(); } } while (0)
2636 (u->is_CallStaticJava() && u->as_CallStaticJava()->uncommon_trap_request() != 0) ||do { if (!(u->adr_type() != __null || u->Opcode() == Op_Rethrow
|| u->Opcode() == Op_Return || u->Opcode() == Op_SafePoint
|| (u->is_CallStaticJava() && u->as_CallStaticJava
()->uncommon_trap_request() != 0) || (u->is_CallStaticJava
() && u->as_CallStaticJava()->_entry_point == OptoRuntime
::rethrow_stub()) || u->Opcode() == Op_CallLeaf)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2638, "assert(" "u->adr_type() != __null || u->Opcode() == Op_Rethrow || u->Opcode() == Op_Return || u->Opcode() == Op_SafePoint || (u->is_CallStaticJava() && u->as_CallStaticJava()->uncommon_trap_request() != 0) || (u->is_CallStaticJava() && u->as_CallStaticJava()->_entry_point == OptoRuntime::rethrow_stub()) || u->Opcode() == Op_CallLeaf"
") failed", ""); ::breakpoint(); } } while (0)
2637 (u->is_CallStaticJava() && u->as_CallStaticJava()->_entry_point == OptoRuntime::rethrow_stub()) ||do { if (!(u->adr_type() != __null || u->Opcode() == Op_Rethrow
|| u->Opcode() == Op_Return || u->Opcode() == Op_SafePoint
|| (u->is_CallStaticJava() && u->as_CallStaticJava
()->uncommon_trap_request() != 0) || (u->is_CallStaticJava
() && u->as_CallStaticJava()->_entry_point == OptoRuntime
::rethrow_stub()) || u->Opcode() == Op_CallLeaf)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2638, "assert(" "u->adr_type() != __null || u->Opcode() == Op_Rethrow || u->Opcode() == Op_Return || u->Opcode() == Op_SafePoint || (u->is_CallStaticJava() && u->as_CallStaticJava()->uncommon_trap_request() != 0) || (u->is_CallStaticJava() && u->as_CallStaticJava()->_entry_point == OptoRuntime::rethrow_stub()) || u->Opcode() == Op_CallLeaf"
") failed", ""); ::breakpoint(); } } while (0)
2638 u->Opcode() == Op_CallLeaf, "")do { if (!(u->adr_type() != __null || u->Opcode() == Op_Rethrow
|| u->Opcode() == Op_Return || u->Opcode() == Op_SafePoint
|| (u->is_CallStaticJava() && u->as_CallStaticJava
()->uncommon_trap_request() != 0) || (u->is_CallStaticJava
() && u->as_CallStaticJava()->_entry_point == OptoRuntime
::rethrow_stub()) || u->Opcode() == Op_CallLeaf)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2638, "assert(" "u->adr_type() != __null || u->Opcode() == Op_Rethrow || u->Opcode() == Op_Return || u->Opcode() == Op_SafePoint || (u->is_CallStaticJava() && u->as_CallStaticJava()->uncommon_trap_request() != 0) || (u->is_CallStaticJava() && u->as_CallStaticJava()->_entry_point == OptoRuntime::rethrow_stub()) || u->Opcode() == Op_CallLeaf"
") failed", ""); ::breakpoint(); } } while (0)
;
2639 Node* m = find_mem(_phase->ctrl_or_self(u), u);
2640 if (m != mem) {
2641 mm = allocate_merge_mem(mem, m, _phase->get_ctrl(m));
2642 _phase->igvn().replace_input_of(u, u->find_edge(mem), mm);
2643 --i;
2644 }
2645 } else if (_phase->C->get_alias_index(u->adr_type()) == alias) {
2646 Node* m = find_mem(_phase->ctrl_or_self(u), u);
2647 if (m != mem) {
2648 DEBUG_ONLY(if (trace) { tty->print("ZZZ setting memory of use"); u->dump(); })if (trace) { tty->print("ZZZ setting memory of use"); u->
dump(); }
;
2649 _phase->igvn().replace_input_of(u, u->find_edge(mem), m);
2650 --i;
2651 }
2652 } else if (u->adr_type() != TypePtr::BOTTOM &&
2653 _memory_nodes[_phase->ctrl_or_self(u)->_idx] == u) {
2654 Node* m = find_mem(_phase->ctrl_or_self(u), u);
2655 assert(m != mem, "")do { if (!(m != mem)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2655, "assert(" "m != mem" ") failed", ""); ::breakpoint();
} } while (0)
;
2656 // u is on the wrong slice...
2657 assert(u->is_ClearArray(), "")do { if (!(u->is_ClearArray())) { (*g_assert_poison) = 'X'
;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2657, "assert(" "u->is_ClearArray()" ") failed", ""); ::
breakpoint(); } } while (0)
;
2658 DEBUG_ONLY(if (trace) { tty->print("ZZZ setting memory of use"); u->dump(); })if (trace) { tty->print("ZZZ setting memory of use"); u->
dump(); }
;
2659 _phase->igvn().replace_input_of(u, u->find_edge(mem), m);
2660 --i;
2661 }
2662 }
2663 }
2664#ifdef ASSERT1
2665 assert(new_mem->outcnt() > 0, "")do { if (!(new_mem->outcnt() > 0)) { (*g_assert_poison)
= 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2665, "assert(" "new_mem->outcnt() > 0" ") failed", ""
); ::breakpoint(); } } while (0)
;
2666 for (int i = 0; i < phis.length(); i++) {
2667 Node* n = phis.at(i);
2668 assert(n->outcnt() > 0, "new phi must have uses now")do { if (!(n->outcnt() > 0)) { (*g_assert_poison) = 'X'
;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2668, "assert(" "n->outcnt() > 0" ") failed", "new phi must have uses now"
); ::breakpoint(); } } while (0)
;
2669 }
2670#endif
2671}
2672
2673MergeMemNode* MemoryGraphFixer::allocate_merge_mem(Node* mem, Node* rep_proj, Node* rep_ctrl) const {
2674 MergeMemNode* mm = MergeMemNode::make(mem);
2675 mm->set_memory_at(_alias, rep_proj);
2676 _phase->register_new_node(mm, rep_ctrl);
2677 return mm;
2678}
2679
2680MergeMemNode* MemoryGraphFixer::clone_merge_mem(Node* u, Node* mem, Node* rep_proj, Node* rep_ctrl, DUIterator& i) const {
2681 MergeMemNode* newmm = NULL__null;
2682 MergeMemNode* u_mm = u->as_MergeMem();
2683 Node* c = _phase->get_ctrl(u);
2684 if (_phase->is_dominator(c, rep_ctrl)) {
2685 c = rep_ctrl;
2686 } else {
2687 assert(_phase->is_dominator(rep_ctrl, c), "one must dominate the other")do { if (!(_phase->is_dominator(rep_ctrl, c))) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2687, "assert(" "_phase->is_dominator(rep_ctrl, c)" ") failed"
, "one must dominate the other"); ::breakpoint(); } } while (
0)
;
2688 }
2689 if (u->outcnt() == 1) {
2690 if (u->req() > (uint)_alias && u->in(_alias) == mem) {
2691 _phase->igvn().replace_input_of(u, _alias, rep_proj);
2692 --i;
2693 } else {
2694 _phase->igvn().rehash_node_delayed(u);
2695 u_mm->set_memory_at(_alias, rep_proj);
2696 }
2697 newmm = u_mm;
2698 _phase->set_ctrl_and_loop(u, c);
2699 } else {
2700 // can't simply clone u and then change one of its input because
2701 // it adds and then removes an edge which messes with the
2702 // DUIterator
2703 newmm = MergeMemNode::make(u_mm->base_memory());
2704 for (uint j = 0; j < u->req(); j++) {
2705 if (j < newmm->req()) {
2706 if (j == (uint)_alias) {
2707 newmm->set_req(j, rep_proj);
2708 } else if (newmm->in(j) != u->in(j)) {
2709 newmm->set_req(j, u->in(j));
2710 }
2711 } else if (j == (uint)_alias) {
2712 newmm->add_req(rep_proj);
2713 } else {
2714 newmm->add_req(u->in(j));
2715 }
2716 }
2717 if ((uint)_alias >= u->req()) {
2718 newmm->set_memory_at(_alias, rep_proj);
2719 }
2720 _phase->register_new_node(newmm, c);
2721 }
2722 return newmm;
2723}
2724
2725bool MemoryGraphFixer::should_process_phi(Node* phi) const {
2726 if (phi->adr_type() == TypePtr::BOTTOM) {
2727 Node* region = phi->in(0);
2728 for (DUIterator_Fast jmax, j = region->fast_outs(jmax); j < jmax; j++) {
2729 Node* uu = region->fast_out(j);
2730 if (uu->is_Phi() && uu != phi && uu->bottom_type() == Type::MEMORY && _phase->C->get_alias_index(uu->adr_type()) == _alias) {
2731 return false;
2732 }
2733 }
2734 return true;
2735 }
2736 return _phase->C->get_alias_index(phi->adr_type()) == _alias;
2737}
2738
2739void MemoryGraphFixer::fix_memory_uses(Node* mem, Node* replacement, Node* rep_proj, Node* rep_ctrl) const {
2740 uint last = _phase-> C->unique();
2741 MergeMemNode* mm = NULL__null;
2742 assert(mem->bottom_type() == Type::MEMORY, "")do { if (!(mem->bottom_type() == Type::MEMORY)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2742, "assert(" "mem->bottom_type() == Type::MEMORY" ") failed"
, ""); ::breakpoint(); } } while (0)
;
2743 for (DUIterator i = mem->outs(); mem->has_out(i); i++) {
2744 Node* u = mem->out(i);
2745 if (u != replacement && u->_idx < last) {
2746 if (u->is_MergeMem()) {
2747 MergeMemNode* u_mm = u->as_MergeMem();
2748 if (u_mm->memory_at(_alias) == mem) {
2749 MergeMemNode* newmm = NULL__null;
2750 for (DUIterator_Fast jmax, j = u->fast_outs(jmax); j < jmax; j++) {
2751 Node* uu = u->fast_out(j);
2752 assert(!uu->is_MergeMem(), "chain of MergeMems?")do { if (!(!uu->is_MergeMem())) { (*g_assert_poison) = 'X'
;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2752, "assert(" "!uu->is_MergeMem()" ") failed", "chain of MergeMems?"
); ::breakpoint(); } } while (0)
;
2753 if (uu->is_Phi()) {
2754 if (should_process_phi(uu)) {
2755 Node* region = uu->in(0);
2756 int nb = 0;
2757 for (uint k = 1; k < uu->req(); k++) {
2758 if (uu->in(k) == u && _phase->is_dominator(rep_ctrl, region->in(k))) {
2759 if (newmm == NULL__null) {
2760 newmm = clone_merge_mem(u, mem, rep_proj, rep_ctrl, i);
2761 }
2762 if (newmm != u) {
2763 _phase->igvn().replace_input_of(uu, k, newmm);
2764 nb++;
2765 --jmax;
2766 }
2767 }
2768 }
2769 if (nb > 0) {
2770 --j;
2771 }
2772 }
2773 } else {
2774 if (rep_ctrl != uu && ShenandoahBarrierC2Support::is_dominator(rep_ctrl, _phase->ctrl_or_self(uu), replacement, uu, _phase)) {
2775 if (newmm == NULL__null) {
2776 newmm = clone_merge_mem(u, mem, rep_proj, rep_ctrl, i);
2777 }
2778 if (newmm != u) {
2779 _phase->igvn().replace_input_of(uu, uu->find_edge(u), newmm);
2780 --j, --jmax;
2781 }
2782 }
2783 }
2784 }
2785 }
2786 } else if (u->is_Phi()) {
2787 assert(u->bottom_type() == Type::MEMORY, "what else?")do { if (!(u->bottom_type() == Type::MEMORY)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2787, "assert(" "u->bottom_type() == Type::MEMORY" ") failed"
, "what else?"); ::breakpoint(); } } while (0)
;
2788 Node* region = u->in(0);
2789 if (should_process_phi(u)) {
2790 bool replaced = false;
2791 for (uint j = 1; j < u->req(); j++) {
2792 if (u->in(j) == mem && _phase->is_dominator(rep_ctrl, region->in(j))) {
2793 Node* nnew = rep_proj;
2794 if (u->adr_type() == TypePtr::BOTTOM) {
2795 if (mm == NULL__null) {
2796 mm = allocate_merge_mem(mem, rep_proj, rep_ctrl);
2797 }
2798 nnew = mm;
2799 }
2800 _phase->igvn().replace_input_of(u, j, nnew);
2801 replaced = true;
2802 }
2803 }
2804 if (replaced) {
2805 --i;
2806 }
2807
2808 }
2809 } else if ((u->adr_type() == TypePtr::BOTTOM && u->Opcode() != Op_StrInflatedCopy) ||
2810 u->adr_type() == NULL__null) {
2811 assert(u->adr_type() != NULL ||do { if (!(u->adr_type() != __null || u->Opcode() == Op_Rethrow
|| u->Opcode() == Op_Return || u->Opcode() == Op_SafePoint
|| u->Opcode() == Op_StoreIConditional || u->Opcode() ==
Op_StoreLConditional || (u->is_CallStaticJava() &&
u->as_CallStaticJava()->uncommon_trap_request() != 0) ||
(u->is_CallStaticJava() && u->as_CallStaticJava
()->_entry_point == OptoRuntime::rethrow_stub()) || u->
Opcode() == Op_CallLeaf)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2819, "assert(" "u->adr_type() != __null || u->Opcode() == Op_Rethrow || u->Opcode() == Op_Return || u->Opcode() == Op_SafePoint || u->Opcode() == Op_StoreIConditional || u->Opcode() == Op_StoreLConditional || (u->is_CallStaticJava() && u->as_CallStaticJava()->uncommon_trap_request() != 0) || (u->is_CallStaticJava() && u->as_CallStaticJava()->_entry_point == OptoRuntime::rethrow_stub()) || u->Opcode() == Op_CallLeaf"
") failed", "%s", u->Name()); ::breakpoint(); } } while (
0)
2812 u->Opcode() == Op_Rethrow ||do { if (!(u->adr_type() != __null || u->Opcode() == Op_Rethrow
|| u->Opcode() == Op_Return || u->Opcode() == Op_SafePoint
|| u->Opcode() == Op_StoreIConditional || u->Opcode() ==
Op_StoreLConditional || (u->is_CallStaticJava() &&
u->as_CallStaticJava()->uncommon_trap_request() != 0) ||
(u->is_CallStaticJava() && u->as_CallStaticJava
()->_entry_point == OptoRuntime::rethrow_stub()) || u->
Opcode() == Op_CallLeaf)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2819, "assert(" "u->adr_type() != __null || u->Opcode() == Op_Rethrow || u->Opcode() == Op_Return || u->Opcode() == Op_SafePoint || u->Opcode() == Op_StoreIConditional || u->Opcode() == Op_StoreLConditional || (u->is_CallStaticJava() && u->as_CallStaticJava()->uncommon_trap_request() != 0) || (u->is_CallStaticJava() && u->as_CallStaticJava()->_entry_point == OptoRuntime::rethrow_stub()) || u->Opcode() == Op_CallLeaf"
") failed", "%s", u->Name()); ::breakpoint(); } } while (
0)
2813 u->Opcode() == Op_Return ||do { if (!(u->adr_type() != __null || u->Opcode() == Op_Rethrow
|| u->Opcode() == Op_Return || u->Opcode() == Op_SafePoint
|| u->Opcode() == Op_StoreIConditional || u->Opcode() ==
Op_StoreLConditional || (u->is_CallStaticJava() &&
u->as_CallStaticJava()->uncommon_trap_request() != 0) ||
(u->is_CallStaticJava() && u->as_CallStaticJava
()->_entry_point == OptoRuntime::rethrow_stub()) || u->
Opcode() == Op_CallLeaf)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2819, "assert(" "u->adr_type() != __null || u->Opcode() == Op_Rethrow || u->Opcode() == Op_Return || u->Opcode() == Op_SafePoint || u->Opcode() == Op_StoreIConditional || u->Opcode() == Op_StoreLConditional || (u->is_CallStaticJava() && u->as_CallStaticJava()->uncommon_trap_request() != 0) || (u->is_CallStaticJava() && u->as_CallStaticJava()->_entry_point == OptoRuntime::rethrow_stub()) || u->Opcode() == Op_CallLeaf"
") failed", "%s", u->Name()); ::breakpoint(); } } while (
0)
2814 u->Opcode() == Op_SafePoint ||do { if (!(u->adr_type() != __null || u->Opcode() == Op_Rethrow
|| u->Opcode() == Op_Return || u->Opcode() == Op_SafePoint
|| u->Opcode() == Op_StoreIConditional || u->Opcode() ==
Op_StoreLConditional || (u->is_CallStaticJava() &&
u->as_CallStaticJava()->uncommon_trap_request() != 0) ||
(u->is_CallStaticJava() && u->as_CallStaticJava
()->_entry_point == OptoRuntime::rethrow_stub()) || u->
Opcode() == Op_CallLeaf)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2819, "assert(" "u->adr_type() != __null || u->Opcode() == Op_Rethrow || u->Opcode() == Op_Return || u->Opcode() == Op_SafePoint || u->Opcode() == Op_StoreIConditional || u->Opcode() == Op_StoreLConditional || (u->is_CallStaticJava() && u->as_CallStaticJava()->uncommon_trap_request() != 0) || (u->is_CallStaticJava() && u->as_CallStaticJava()->_entry_point == OptoRuntime::rethrow_stub()) || u->Opcode() == Op_CallLeaf"
") failed", "%s", u->Name()); ::breakpoint(); } } while (
0)
2815 u->Opcode() == Op_StoreIConditional ||do { if (!(u->adr_type() != __null || u->Opcode() == Op_Rethrow
|| u->Opcode() == Op_Return || u->Opcode() == Op_SafePoint
|| u->Opcode() == Op_StoreIConditional || u->Opcode() ==
Op_StoreLConditional || (u->is_CallStaticJava() &&
u->as_CallStaticJava()->uncommon_trap_request() != 0) ||
(u->is_CallStaticJava() && u->as_CallStaticJava
()->_entry_point == OptoRuntime::rethrow_stub()) || u->
Opcode() == Op_CallLeaf)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2819, "assert(" "u->adr_type() != __null || u->Opcode() == Op_Rethrow || u->Opcode() == Op_Return || u->Opcode() == Op_SafePoint || u->Opcode() == Op_StoreIConditional || u->Opcode() == Op_StoreLConditional || (u->is_CallStaticJava() && u->as_CallStaticJava()->uncommon_trap_request() != 0) || (u->is_CallStaticJava() && u->as_CallStaticJava()->_entry_point == OptoRuntime::rethrow_stub()) || u->Opcode() == Op_CallLeaf"
") failed", "%s", u->Name()); ::breakpoint(); } } while (
0)
2816 u->Opcode() == Op_StoreLConditional ||do { if (!(u->adr_type() != __null || u->Opcode() == Op_Rethrow
|| u->Opcode() == Op_Return || u->Opcode() == Op_SafePoint
|| u->Opcode() == Op_StoreIConditional || u->Opcode() ==
Op_StoreLConditional || (u->is_CallStaticJava() &&
u->as_CallStaticJava()->uncommon_trap_request() != 0) ||
(u->is_CallStaticJava() && u->as_CallStaticJava
()->_entry_point == OptoRuntime::rethrow_stub()) || u->
Opcode() == Op_CallLeaf)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2819, "assert(" "u->adr_type() != __null || u->Opcode() == Op_Rethrow || u->Opcode() == Op_Return || u->Opcode() == Op_SafePoint || u->Opcode() == Op_StoreIConditional || u->Opcode() == Op_StoreLConditional || (u->is_CallStaticJava() && u->as_CallStaticJava()->uncommon_trap_request() != 0) || (u->is_CallStaticJava() && u->as_CallStaticJava()->_entry_point == OptoRuntime::rethrow_stub()) || u->Opcode() == Op_CallLeaf"
") failed", "%s", u->Name()); ::breakpoint(); } } while (
0)
2817 (u->is_CallStaticJava() && u->as_CallStaticJava()->uncommon_trap_request() != 0) ||do { if (!(u->adr_type() != __null || u->Opcode() == Op_Rethrow
|| u->Opcode() == Op_Return || u->Opcode() == Op_SafePoint
|| u->Opcode() == Op_StoreIConditional || u->Opcode() ==
Op_StoreLConditional || (u->is_CallStaticJava() &&
u->as_CallStaticJava()->uncommon_trap_request() != 0) ||
(u->is_CallStaticJava() && u->as_CallStaticJava
()->_entry_point == OptoRuntime::rethrow_stub()) || u->
Opcode() == Op_CallLeaf)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2819, "assert(" "u->adr_type() != __null || u->Opcode() == Op_Rethrow || u->Opcode() == Op_Return || u->Opcode() == Op_SafePoint || u->Opcode() == Op_StoreIConditional || u->Opcode() == Op_StoreLConditional || (u->is_CallStaticJava() && u->as_CallStaticJava()->uncommon_trap_request() != 0) || (u->is_CallStaticJava() && u->as_CallStaticJava()->_entry_point == OptoRuntime::rethrow_stub()) || u->Opcode() == Op_CallLeaf"
") failed", "%s", u->Name()); ::breakpoint(); } } while (
0)
2818 (u->is_CallStaticJava() && u->as_CallStaticJava()->_entry_point == OptoRuntime::rethrow_stub()) ||do { if (!(u->adr_type() != __null || u->Opcode() == Op_Rethrow
|| u->Opcode() == Op_Return || u->Opcode() == Op_SafePoint
|| u->Opcode() == Op_StoreIConditional || u->Opcode() ==
Op_StoreLConditional || (u->is_CallStaticJava() &&
u->as_CallStaticJava()->uncommon_trap_request() != 0) ||
(u->is_CallStaticJava() && u->as_CallStaticJava
()->_entry_point == OptoRuntime::rethrow_stub()) || u->
Opcode() == Op_CallLeaf)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2819, "assert(" "u->adr_type() != __null || u->Opcode() == Op_Rethrow || u->Opcode() == Op_Return || u->Opcode() == Op_SafePoint || u->Opcode() == Op_StoreIConditional || u->Opcode() == Op_StoreLConditional || (u->is_CallStaticJava() && u->as_CallStaticJava()->uncommon_trap_request() != 0) || (u->is_CallStaticJava() && u->as_CallStaticJava()->_entry_point == OptoRuntime::rethrow_stub()) || u->Opcode() == Op_CallLeaf"
") failed", "%s", u->Name()); ::breakpoint(); } } while (
0)
2819 u->Opcode() == Op_CallLeaf, "%s", u->Name())do { if (!(u->adr_type() != __null || u->Opcode() == Op_Rethrow
|| u->Opcode() == Op_Return || u->Opcode() == Op_SafePoint
|| u->Opcode() == Op_StoreIConditional || u->Opcode() ==
Op_StoreLConditional || (u->is_CallStaticJava() &&
u->as_CallStaticJava()->uncommon_trap_request() != 0) ||
(u->is_CallStaticJava() && u->as_CallStaticJava
()->_entry_point == OptoRuntime::rethrow_stub()) || u->
Opcode() == Op_CallLeaf)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2819, "assert(" "u->adr_type() != __null || u->Opcode() == Op_Rethrow || u->Opcode() == Op_Return || u->Opcode() == Op_SafePoint || u->Opcode() == Op_StoreIConditional || u->Opcode() == Op_StoreLConditional || (u->is_CallStaticJava() && u->as_CallStaticJava()->uncommon_trap_request() != 0) || (u->is_CallStaticJava() && u->as_CallStaticJava()->_entry_point == OptoRuntime::rethrow_stub()) || u->Opcode() == Op_CallLeaf"
") failed", "%s", u->Name()); ::breakpoint(); } } while (
0)
;
2820 if (ShenandoahBarrierC2Support::is_dominator(rep_ctrl, _phase->ctrl_or_self(u), replacement, u, _phase)) {
2821 if (mm == NULL__null) {
2822 mm = allocate_merge_mem(mem, rep_proj, rep_ctrl);
2823 }
2824 _phase->igvn().replace_input_of(u, u->find_edge(mem), mm);
2825 --i;
2826 }
2827 } else if (_phase->C->get_alias_index(u->adr_type()) == _alias) {
2828 if (ShenandoahBarrierC2Support::is_dominator(rep_ctrl, _phase->ctrl_or_self(u), replacement, u, _phase)) {
2829 _phase->igvn().replace_input_of(u, u->find_edge(mem), rep_proj);
2830 --i;
2831 }
2832 }
2833 }
2834 }
2835}
2836
2837ShenandoahLoadReferenceBarrierNode::ShenandoahLoadReferenceBarrierNode(Node* ctrl, Node* obj, DecoratorSet decorators)
2838: Node(ctrl, obj), _decorators(decorators) {
2839 ShenandoahBarrierSetC2::bsc2()->state()->add_load_reference_barrier(this);
2840}
2841
2842DecoratorSet ShenandoahLoadReferenceBarrierNode::decorators() const {
2843 return _decorators;
2844}
2845
2846uint ShenandoahLoadReferenceBarrierNode::size_of() const {
2847 return sizeof(*this);
2848}
2849
2850static DecoratorSet mask_decorators(DecoratorSet decorators) {
2851 return decorators & (ON_STRONG_OOP_REF | ON_WEAK_OOP_REF | ON_PHANTOM_OOP_REF | ON_UNKNOWN_OOP_REF | IN_NATIVE);
2852}
2853
2854uint ShenandoahLoadReferenceBarrierNode::hash() const {
2855 uint hash = Node::hash();
2856 hash += mask_decorators(_decorators);
2857 return hash;
2858}
2859
2860bool ShenandoahLoadReferenceBarrierNode::cmp( const Node &n ) const {
2861 return Node::cmp(n) && n.Opcode() == Op_ShenandoahLoadReferenceBarrier &&
2862 mask_decorators(_decorators) == mask_decorators(((const ShenandoahLoadReferenceBarrierNode&)n)._decorators);
2863}
2864
2865const Type* ShenandoahLoadReferenceBarrierNode::bottom_type() const {
2866 if (in(ValueIn) == NULL__null || in(ValueIn)->is_top()) {
2867 return Type::TOP;
2868 }
2869 const Type* t = in(ValueIn)->bottom_type();
2870 if (t == TypePtr::NULL_PTR) {
2871 return t;
2872 }
2873
2874 if (ShenandoahBarrierSet::is_strong_access(decorators())) {
2875 return t;
2876 }
2877
2878 return t->meet(TypePtr::NULL_PTR);
2879}
2880
2881const Type* ShenandoahLoadReferenceBarrierNode::Value(PhaseGVN* phase) const {
2882 // Either input is TOP ==> the result is TOP
2883 const Type *t2 = phase->type(in(ValueIn));
2884 if( t2 == Type::TOP ) return Type::TOP;
2885
2886 if (t2 == TypePtr::NULL_PTR) {
2887 return t2;
2888 }
2889
2890 if (ShenandoahBarrierSet::is_strong_access(decorators())) {
2891 return t2;
2892 }
2893
2894 return t2->meet(TypePtr::NULL_PTR);
2895}
2896
2897Node* ShenandoahLoadReferenceBarrierNode::Identity(PhaseGVN* phase) {
2898 Node* value = in(ValueIn);
2899 if (!needs_barrier(phase, value)) {
2900 return value;
2901 }
2902 return this;
2903}
2904
2905bool ShenandoahLoadReferenceBarrierNode::needs_barrier(PhaseGVN* phase, Node* n) {
2906 Unique_Node_List visited;
2907 return needs_barrier_impl(phase, n, visited);
2908}
2909
2910bool ShenandoahLoadReferenceBarrierNode::needs_barrier_impl(PhaseGVN* phase, Node* n, Unique_Node_List &visited) {
2911 if (n == NULL__null) return false;
2912 if (visited.member(n)) {
2913 return false; // Been there.
2914 }
2915 visited.push(n);
2916
2917 if (n->is_Allocate()) {
2918 // tty->print_cr("optimize barrier on alloc");
2919 return false;
2920 }
2921 if (n->is_Call()) {
2922 // tty->print_cr("optimize barrier on call");
2923 return false;
2924 }
2925
2926 const Type* type = phase->type(n);
2927 if (type == Type::TOP) {
2928 return false;
2929 }
2930 if (type->make_ptr()->higher_equal(TypePtr::NULL_PTR)) {
2931 // tty->print_cr("optimize barrier on null");
2932 return false;
2933 }
2934 if (type->make_oopptr() && type->make_oopptr()->const_oop() != NULL__null) {
2935 // tty->print_cr("optimize barrier on constant");
2936 return false;
2937 }
2938
2939 switch (n->Opcode()) {
2940 case Op_AddP:
2941 return true; // TODO: Can refine?
2942 case Op_LoadP:
2943 case Op_ShenandoahCompareAndExchangeN:
2944 case Op_ShenandoahCompareAndExchangeP:
2945 case Op_CompareAndExchangeN:
2946 case Op_CompareAndExchangeP:
2947 case Op_GetAndSetN:
2948 case Op_GetAndSetP:
2949 return true;
2950 case Op_Phi: {
2951 for (uint i = 1; i < n->req(); i++) {
2952 if (needs_barrier_impl(phase, n->in(i), visited)) return true;
2953 }
2954 return false;
2955 }
2956 case Op_CheckCastPP:
2957 case Op_CastPP:
2958 return needs_barrier_impl(phase, n->in(1), visited);
2959 case Op_Proj:
2960 return needs_barrier_impl(phase, n->in(0), visited);
2961 case Op_ShenandoahLoadReferenceBarrier:
2962 // tty->print_cr("optimize barrier on barrier");
2963 return false;
2964 case Op_Parm:
2965 // tty->print_cr("optimize barrier on input arg");
2966 return false;
2967 case Op_DecodeN:
2968 case Op_EncodeP:
2969 return needs_barrier_impl(phase, n->in(1), visited);
2970 case Op_LoadN:
2971 return true;
2972 case Op_CMoveN:
2973 case Op_CMoveP:
2974 return needs_barrier_impl(phase, n->in(2), visited) ||
2975 needs_barrier_impl(phase, n->in(3), visited);
2976 case Op_ShenandoahIUBarrier:
2977 return needs_barrier_impl(phase, n->in(1), visited);
2978 case Op_CreateEx:
2979 return false;
2980 default:
2981 break;
2982 }
2983#ifdef ASSERT1
2984 tty->print("need barrier on?: ");
2985 tty->print_cr("ins:");
2986 n->dump(2);
2987 tty->print_cr("outs:");
2988 n->dump(-2);
2989 ShouldNotReachHere()do { (*g_assert_poison) = 'X';; report_should_not_reach_here(
"/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp"
, 2989); ::breakpoint(); } while (0)
;
2990#endif
2991 return true;
2992}

/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)
;
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)
4
Assuming the condition is false
5
Returning zero, which participates in a condition later
891 DEFINE_CLASS_QUERY(LoadStore)
16
Assuming the condition is false
17
Returning zero, which participates in a condition later
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)
9
Assuming the condition is false
10
Returning zero, which participates in a condition later
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.
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