File: | jdk/src/hotspot/share/opto/graphKit.hpp |
Warning: | line 141, column 49 Called C++ object pointer is null |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* | |||
2 | * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. | |||
3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |||
4 | * | |||
5 | * This code is free software; you can redistribute it and/or modify it | |||
6 | * under the terms of the GNU General Public License version 2 only, as | |||
7 | * published by the Free Software Foundation. | |||
8 | * | |||
9 | * This code is distributed in the hope that it will be useful, but WITHOUT | |||
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |||
11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |||
12 | * version 2 for more details (a copy is included in the LICENSE file that | |||
13 | * accompanied this code). | |||
14 | * | |||
15 | * You should have received a copy of the GNU General Public License version | |||
16 | * 2 along with this work; if not, write to the Free Software Foundation, | |||
17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |||
18 | * | |||
19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |||
20 | * or visit www.oracle.com if you need additional information or have any | |||
21 | * questions. | |||
22 | * | |||
23 | */ | |||
24 | ||||
25 | #include "precompiled.hpp" | |||
26 | #include "ci/bcEscapeAnalyzer.hpp" | |||
27 | #include "ci/ciCallSite.hpp" | |||
28 | #include "ci/ciObjArray.hpp" | |||
29 | #include "ci/ciMemberName.hpp" | |||
30 | #include "ci/ciMethodHandle.hpp" | |||
31 | #include "classfile/javaClasses.hpp" | |||
32 | #include "compiler/compileLog.hpp" | |||
33 | #include "opto/addnode.hpp" | |||
34 | #include "opto/callGenerator.hpp" | |||
35 | #include "opto/callnode.hpp" | |||
36 | #include "opto/castnode.hpp" | |||
37 | #include "opto/cfgnode.hpp" | |||
38 | #include "opto/parse.hpp" | |||
39 | #include "opto/rootnode.hpp" | |||
40 | #include "opto/runtime.hpp" | |||
41 | #include "opto/subnode.hpp" | |||
42 | #include "runtime/sharedRuntime.hpp" | |||
43 | #include "ci/ciNativeEntryPoint.hpp" | |||
44 | #include "utilities/debug.hpp" | |||
45 | ||||
46 | // Utility function. | |||
47 | const TypeFunc* CallGenerator::tf() const { | |||
48 | return TypeFunc::make(method()); | |||
49 | } | |||
50 | ||||
51 | bool CallGenerator::is_inlined_method_handle_intrinsic(JVMState* jvms, ciMethod* m) { | |||
52 | return is_inlined_method_handle_intrinsic(jvms->method(), jvms->bci(), m); | |||
53 | } | |||
54 | ||||
55 | bool CallGenerator::is_inlined_method_handle_intrinsic(ciMethod* caller, int bci, ciMethod* m) { | |||
56 | ciMethod* symbolic_info = caller->get_method_at_bci(bci); | |||
57 | return is_inlined_method_handle_intrinsic(symbolic_info, m); | |||
58 | } | |||
59 | ||||
60 | bool CallGenerator::is_inlined_method_handle_intrinsic(ciMethod* symbolic_info, ciMethod* m) { | |||
61 | return symbolic_info->is_method_handle_intrinsic() && !m->is_method_handle_intrinsic(); | |||
62 | } | |||
63 | ||||
64 | //-----------------------------ParseGenerator--------------------------------- | |||
65 | // Internal class which handles all direct bytecode traversal. | |||
66 | class ParseGenerator : public InlineCallGenerator { | |||
67 | private: | |||
68 | bool _is_osr; | |||
69 | float _expected_uses; | |||
70 | ||||
71 | public: | |||
72 | ParseGenerator(ciMethod* method, float expected_uses, bool is_osr = false) | |||
73 | : InlineCallGenerator(method) | |||
74 | { | |||
75 | _is_osr = is_osr; | |||
76 | _expected_uses = expected_uses; | |||
77 | assert(InlineTree::check_can_parse(method) == NULL, "parse must be possible")do { if (!(InlineTree::check_can_parse(method) == __null)) { ( *g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/callGenerator.cpp" , 77, "assert(" "InlineTree::check_can_parse(method) == __null" ") failed", "parse must be possible"); ::breakpoint(); } } while (0); | |||
78 | } | |||
79 | ||||
80 | virtual bool is_parse() const { return true; } | |||
81 | virtual JVMState* generate(JVMState* jvms); | |||
82 | int is_osr() { return _is_osr; } | |||
83 | ||||
84 | }; | |||
85 | ||||
86 | JVMState* ParseGenerator::generate(JVMState* jvms) { | |||
87 | Compile* C = Compile::current(); | |||
88 | C->print_inlining_update(this); | |||
89 | ||||
90 | if (is_osr()) { | |||
91 | // The JVMS for a OSR has a single argument (see its TypeFunc). | |||
92 | assert(jvms->depth() == 1, "no inline OSR")do { if (!(jvms->depth() == 1)) { (*g_assert_poison) = 'X' ;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/callGenerator.cpp" , 92, "assert(" "jvms->depth() == 1" ") failed", "no inline OSR" ); ::breakpoint(); } } while (0); | |||
93 | } | |||
94 | ||||
95 | if (C->failing()) { | |||
96 | return NULL__null; // bailing out of the compile; do not try to parse | |||
97 | } | |||
98 | ||||
99 | Parse parser(jvms, method(), _expected_uses); | |||
100 | // Grab signature for matching/allocation | |||
101 | GraphKit& exits = parser.exits(); | |||
102 | ||||
103 | if (C->failing()) { | |||
104 | while (exits.pop_exception_state() != NULL__null) ; | |||
105 | return NULL__null; | |||
106 | } | |||
107 | ||||
108 | assert(exits.jvms()->same_calls_as(jvms), "sanity")do { if (!(exits.jvms()->same_calls_as(jvms))) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/callGenerator.cpp" , 108, "assert(" "exits.jvms()->same_calls_as(jvms)" ") failed" , "sanity"); ::breakpoint(); } } while (0); | |||
109 | ||||
110 | // Simply return the exit state of the parser, | |||
111 | // augmented by any exceptional states. | |||
112 | return exits.transfer_exceptions_into_jvms(); | |||
113 | } | |||
114 | ||||
115 | //---------------------------DirectCallGenerator------------------------------ | |||
116 | // Internal class which handles all out-of-line calls w/o receiver type checks. | |||
117 | class DirectCallGenerator : public CallGenerator { | |||
118 | private: | |||
119 | CallStaticJavaNode* _call_node; | |||
120 | // Force separate memory and I/O projections for the exceptional | |||
121 | // paths to facilitate late inlinig. | |||
122 | bool _separate_io_proj; | |||
123 | ||||
124 | protected: | |||
125 | void set_call_node(CallStaticJavaNode* call) { _call_node = call; } | |||
126 | ||||
127 | public: | |||
128 | DirectCallGenerator(ciMethod* method, bool separate_io_proj) | |||
129 | : CallGenerator(method), | |||
130 | _separate_io_proj(separate_io_proj) | |||
131 | { | |||
132 | } | |||
133 | virtual JVMState* generate(JVMState* jvms); | |||
134 | ||||
135 | virtual CallNode* call_node() const { return _call_node; } | |||
136 | virtual CallGenerator* with_call_node(CallNode* call) { | |||
137 | DirectCallGenerator* dcg = new DirectCallGenerator(method(), _separate_io_proj); | |||
138 | dcg->set_call_node(call->as_CallStaticJava()); | |||
139 | return dcg; | |||
140 | } | |||
141 | }; | |||
142 | ||||
143 | JVMState* DirectCallGenerator::generate(JVMState* jvms) { | |||
144 | GraphKit kit(jvms); | |||
145 | kit.C->print_inlining_update(this); | |||
146 | bool is_static = method()->is_static(); | |||
147 | address target = is_static ? SharedRuntime::get_resolve_static_call_stub() | |||
148 | : SharedRuntime::get_resolve_opt_virtual_call_stub(); | |||
149 | ||||
150 | if (kit.C->log() != NULL__null) { | |||
151 | kit.C->log()->elem("direct_call bci='%d'", jvms->bci()); | |||
152 | } | |||
153 | ||||
154 | CallStaticJavaNode* call = new CallStaticJavaNode(kit.C, tf(), target, method()); | |||
155 | if (is_inlined_method_handle_intrinsic(jvms, method())) { | |||
156 | // To be able to issue a direct call and skip a call to MH.linkTo*/invokeBasic adapter, | |||
157 | // additional information about the method being invoked should be attached | |||
158 | // to the call site to make resolution logic work | |||
159 | // (see SharedRuntime::resolve_static_call_C). | |||
160 | call->set_override_symbolic_info(true); | |||
161 | } | |||
162 | _call_node = call; // Save the call node in case we need it later | |||
163 | if (!is_static) { | |||
164 | // Make an explicit receiver null_check as part of this call. | |||
165 | // Since we share a map with the caller, his JVMS gets adjusted. | |||
166 | kit.null_check_receiver_before_call(method()); | |||
167 | if (kit.stopped()) { | |||
168 | // And dump it back to the caller, decorated with any exceptions: | |||
169 | return kit.transfer_exceptions_into_jvms(); | |||
170 | } | |||
171 | // Mark the call node as virtual, sort of: | |||
172 | call->set_optimized_virtual(true); | |||
173 | if (method()->is_method_handle_intrinsic() || | |||
174 | method()->is_compiled_lambda_form()) { | |||
175 | call->set_method_handle_invoke(true); | |||
176 | } | |||
177 | } | |||
178 | kit.set_arguments_for_java_call(call); | |||
179 | kit.set_edges_for_java_call(call, false, _separate_io_proj); | |||
180 | Node* ret = kit.set_results_for_java_call(call, _separate_io_proj); | |||
181 | kit.push_node(method()->return_type()->basic_type(), ret); | |||
182 | return kit.transfer_exceptions_into_jvms(); | |||
183 | } | |||
184 | ||||
185 | //--------------------------VirtualCallGenerator------------------------------ | |||
186 | // Internal class which handles all out-of-line calls checking receiver type. | |||
187 | class VirtualCallGenerator : public CallGenerator { | |||
188 | private: | |||
189 | int _vtable_index; | |||
190 | bool _separate_io_proj; | |||
191 | CallDynamicJavaNode* _call_node; | |||
192 | ||||
193 | protected: | |||
194 | void set_call_node(CallDynamicJavaNode* call) { _call_node = call; } | |||
195 | ||||
196 | public: | |||
197 | VirtualCallGenerator(ciMethod* method, int vtable_index, bool separate_io_proj) | |||
198 | : CallGenerator(method), _vtable_index(vtable_index), _separate_io_proj(separate_io_proj), _call_node(NULL__null) | |||
199 | { | |||
200 | assert(vtable_index == Method::invalid_vtable_index ||do { if (!(vtable_index == Method::invalid_vtable_index || vtable_index >= 0)) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/callGenerator.cpp" , 201, "assert(" "vtable_index == Method::invalid_vtable_index || vtable_index >= 0" ") failed", "either invalid or usable"); ::breakpoint(); } } while (0) | |||
201 | vtable_index >= 0, "either invalid or usable")do { if (!(vtable_index == Method::invalid_vtable_index || vtable_index >= 0)) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/callGenerator.cpp" , 201, "assert(" "vtable_index == Method::invalid_vtable_index || vtable_index >= 0" ") failed", "either invalid or usable"); ::breakpoint(); } } while (0); | |||
202 | } | |||
203 | virtual bool is_virtual() const { return true; } | |||
204 | virtual JVMState* generate(JVMState* jvms); | |||
205 | ||||
206 | virtual CallNode* call_node() const { return _call_node; } | |||
207 | int vtable_index() const { return _vtable_index; } | |||
208 | ||||
209 | virtual CallGenerator* with_call_node(CallNode* call) { | |||
210 | VirtualCallGenerator* cg = new VirtualCallGenerator(method(), _vtable_index, _separate_io_proj); | |||
211 | cg->set_call_node(call->as_CallDynamicJava()); | |||
212 | return cg; | |||
213 | } | |||
214 | }; | |||
215 | ||||
216 | JVMState* VirtualCallGenerator::generate(JVMState* jvms) { | |||
217 | GraphKit kit(jvms); | |||
218 | Node* receiver = kit.argument(0); | |||
219 | ||||
220 | kit.C->print_inlining_update(this); | |||
221 | ||||
222 | if (kit.C->log() != NULL__null) { | |||
223 | kit.C->log()->elem("virtual_call bci='%d'", jvms->bci()); | |||
224 | } | |||
225 | ||||
226 | // If the receiver is a constant null, do not torture the system | |||
227 | // by attempting to call through it. The compile will proceed | |||
228 | // correctly, but may bail out in final_graph_reshaping, because | |||
229 | // the call instruction will have a seemingly deficient out-count. | |||
230 | // (The bailout says something misleading about an "infinite loop".) | |||
231 | if (kit.gvn().type(receiver)->higher_equal(TypePtr::NULL_PTR)) { | |||
232 | assert(Bytecodes::is_invoke(kit.java_bc()), "%d: %s", kit.java_bc(), Bytecodes::name(kit.java_bc()))do { if (!(Bytecodes::is_invoke(kit.java_bc()))) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/callGenerator.cpp" , 232, "assert(" "Bytecodes::is_invoke(kit.java_bc())" ") failed" , "%d: %s", kit.java_bc(), Bytecodes::name(kit.java_bc())); :: breakpoint(); } } while (0); | |||
233 | ciMethod* declared_method = kit.method()->get_method_at_bci(kit.bci()); | |||
234 | int arg_size = declared_method->signature()->arg_size_for_bc(kit.java_bc()); | |||
235 | kit.inc_sp(arg_size); // restore arguments | |||
236 | kit.uncommon_trap(Deoptimization::Reason_null_check, | |||
237 | Deoptimization::Action_none, | |||
238 | NULL__null, "null receiver"); | |||
239 | return kit.transfer_exceptions_into_jvms(); | |||
240 | } | |||
241 | ||||
242 | // Ideally we would unconditionally do a null check here and let it | |||
243 | // be converted to an implicit check based on profile information. | |||
244 | // However currently the conversion to implicit null checks in | |||
245 | // Block::implicit_null_check() only looks for loads and stores, not calls. | |||
246 | ciMethod *caller = kit.method(); | |||
247 | ciMethodData *caller_md = (caller == NULL__null) ? NULL__null : caller->method_data(); | |||
248 | if (!UseInlineCaches || !ImplicitNullChecks || !os::zero_page_read_protected() || | |||
249 | ((ImplicitNullCheckThreshold > 0) && caller_md && | |||
250 | (caller_md->trap_count(Deoptimization::Reason_null_check) | |||
251 | >= (uint)ImplicitNullCheckThreshold))) { | |||
252 | // Make an explicit receiver null_check as part of this call. | |||
253 | // Since we share a map with the caller, his JVMS gets adjusted. | |||
254 | receiver = kit.null_check_receiver_before_call(method()); | |||
255 | if (kit.stopped()) { | |||
256 | // And dump it back to the caller, decorated with any exceptions: | |||
257 | return kit.transfer_exceptions_into_jvms(); | |||
258 | } | |||
259 | } | |||
260 | ||||
261 | assert(!method()->is_static(), "virtual call must not be to static")do { if (!(!method()->is_static())) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/callGenerator.cpp" , 261, "assert(" "!method()->is_static()" ") failed", "virtual call must not be to static" ); ::breakpoint(); } } while (0); | |||
262 | assert(!method()->is_final(), "virtual call should not be to final")do { if (!(!method()->is_final())) { (*g_assert_poison) = 'X' ;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/callGenerator.cpp" , 262, "assert(" "!method()->is_final()" ") failed", "virtual call should not be to final" ); ::breakpoint(); } } while (0); | |||
263 | assert(!method()->is_private(), "virtual call should not be to private")do { if (!(!method()->is_private())) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/callGenerator.cpp" , 263, "assert(" "!method()->is_private()" ") failed", "virtual call should not be to private" ); ::breakpoint(); } } while (0); | |||
264 | assert(_vtable_index == Method::invalid_vtable_index || !UseInlineCaches,do { if (!(_vtable_index == Method::invalid_vtable_index || ! UseInlineCaches)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/callGenerator.cpp" , 265, "assert(" "_vtable_index == Method::invalid_vtable_index || !UseInlineCaches" ") failed", "no vtable calls if +UseInlineCaches "); ::breakpoint (); } } while (0) | |||
265 | "no vtable calls if +UseInlineCaches ")do { if (!(_vtable_index == Method::invalid_vtable_index || ! UseInlineCaches)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/callGenerator.cpp" , 265, "assert(" "_vtable_index == Method::invalid_vtable_index || !UseInlineCaches" ") failed", "no vtable calls if +UseInlineCaches "); ::breakpoint (); } } while (0); | |||
266 | address target = SharedRuntime::get_resolve_virtual_call_stub(); | |||
267 | // Normal inline cache used for call | |||
268 | CallDynamicJavaNode* call = new CallDynamicJavaNode(tf(), target, method(), _vtable_index); | |||
269 | if (is_inlined_method_handle_intrinsic(jvms, method())) { | |||
270 | // To be able to issue a direct call (optimized virtual or virtual) | |||
271 | // and skip a call to MH.linkTo*/invokeBasic adapter, additional information | |||
272 | // about the method being invoked should be attached to the call site to | |||
273 | // make resolution logic work (see SharedRuntime::resolve_{virtual,opt_virtual}_call_C). | |||
274 | call->set_override_symbolic_info(true); | |||
275 | } | |||
276 | _call_node = call; // Save the call node in case we need it later | |||
277 | ||||
278 | kit.set_arguments_for_java_call(call); | |||
279 | kit.set_edges_for_java_call(call, false /*must_throw*/, _separate_io_proj); | |||
280 | Node* ret = kit.set_results_for_java_call(call, _separate_io_proj); | |||
281 | kit.push_node(method()->return_type()->basic_type(), ret); | |||
282 | ||||
283 | // Represent the effect of an implicit receiver null_check | |||
284 | // as part of this call. Since we share a map with the caller, | |||
285 | // his JVMS gets adjusted. | |||
286 | kit.cast_not_null(receiver); | |||
287 | return kit.transfer_exceptions_into_jvms(); | |||
288 | } | |||
289 | ||||
290 | CallGenerator* CallGenerator::for_inline(ciMethod* m, float expected_uses) { | |||
291 | if (InlineTree::check_can_parse(m) != NULL__null) return NULL__null; | |||
292 | return new ParseGenerator(m, expected_uses); | |||
293 | } | |||
294 | ||||
295 | // As a special case, the JVMS passed to this CallGenerator is | |||
296 | // for the method execution already in progress, not just the JVMS | |||
297 | // of the caller. Thus, this CallGenerator cannot be mixed with others! | |||
298 | CallGenerator* CallGenerator::for_osr(ciMethod* m, int osr_bci) { | |||
299 | if (InlineTree::check_can_parse(m) != NULL__null) return NULL__null; | |||
300 | float past_uses = m->interpreter_invocation_count(); | |||
301 | float expected_uses = past_uses; | |||
302 | return new ParseGenerator(m, expected_uses, true); | |||
303 | } | |||
304 | ||||
305 | CallGenerator* CallGenerator::for_direct_call(ciMethod* m, bool separate_io_proj) { | |||
306 | assert(!m->is_abstract(), "for_direct_call mismatch")do { if (!(!m->is_abstract())) { (*g_assert_poison) = 'X'; ; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/callGenerator.cpp" , 306, "assert(" "!m->is_abstract()" ") failed", "for_direct_call mismatch" ); ::breakpoint(); } } while (0); | |||
307 | return new DirectCallGenerator(m, separate_io_proj); | |||
308 | } | |||
309 | ||||
310 | CallGenerator* CallGenerator::for_virtual_call(ciMethod* m, int vtable_index) { | |||
311 | assert(!m->is_static(), "for_virtual_call mismatch")do { if (!(!m->is_static())) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/callGenerator.cpp" , 311, "assert(" "!m->is_static()" ") failed", "for_virtual_call mismatch" ); ::breakpoint(); } } while (0); | |||
312 | assert(!m->is_method_handle_intrinsic(), "should be a direct call")do { if (!(!m->is_method_handle_intrinsic())) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/callGenerator.cpp" , 312, "assert(" "!m->is_method_handle_intrinsic()" ") failed" , "should be a direct call"); ::breakpoint(); } } while (0); | |||
313 | return new VirtualCallGenerator(m, vtable_index, false /*separate_io_projs*/); | |||
314 | } | |||
315 | ||||
316 | // Allow inlining decisions to be delayed | |||
317 | class LateInlineCallGenerator : public DirectCallGenerator { | |||
318 | private: | |||
319 | jlong _unique_id; // unique id for log compilation | |||
320 | bool _is_pure_call; // a hint that the call doesn't have important side effects to care about | |||
321 | ||||
322 | protected: | |||
323 | CallGenerator* _inline_cg; | |||
324 | virtual bool do_late_inline_check(Compile* C, JVMState* jvms) { return true; } | |||
325 | virtual CallGenerator* inline_cg() const { return _inline_cg; } | |||
326 | virtual bool is_pure_call() const { return _is_pure_call; } | |||
327 | ||||
328 | public: | |||
329 | LateInlineCallGenerator(ciMethod* method, CallGenerator* inline_cg, bool is_pure_call = false) : | |||
330 | DirectCallGenerator(method, true), _unique_id(0), _is_pure_call(is_pure_call), _inline_cg(inline_cg) {} | |||
331 | ||||
332 | virtual bool is_late_inline() const { return true; } | |||
333 | ||||
334 | // Convert the CallStaticJava into an inline | |||
335 | virtual void do_late_inline(); | |||
336 | ||||
337 | virtual JVMState* generate(JVMState* jvms) { | |||
338 | Compile *C = Compile::current(); | |||
339 | ||||
340 | C->log_inline_id(this); | |||
341 | ||||
342 | // Record that this call site should be revisited once the main | |||
343 | // parse is finished. | |||
344 | if (!is_mh_late_inline()) { | |||
345 | C->add_late_inline(this); | |||
346 | } | |||
347 | ||||
348 | // Emit the CallStaticJava and request separate projections so | |||
349 | // that the late inlining logic can distinguish between fall | |||
350 | // through and exceptional uses of the memory and io projections | |||
351 | // as is done for allocations and macro expansion. | |||
352 | return DirectCallGenerator::generate(jvms); | |||
353 | } | |||
354 | ||||
355 | virtual void print_inlining_late(const char* msg) { | |||
356 | CallNode* call = call_node(); | |||
357 | Compile* C = Compile::current(); | |||
358 | C->print_inlining_assert_ready(); | |||
359 | C->print_inlining(method(), call->jvms()->depth()-1, call->jvms()->bci(), msg); | |||
360 | C->print_inlining_move_to(this); | |||
361 | C->print_inlining_update_delayed(this); | |||
362 | } | |||
363 | ||||
364 | virtual void set_unique_id(jlong id) { | |||
365 | _unique_id = id; | |||
366 | } | |||
367 | ||||
368 | virtual jlong unique_id() const { | |||
369 | return _unique_id; | |||
370 | } | |||
371 | ||||
372 | virtual CallGenerator* with_call_node(CallNode* call) { | |||
373 | LateInlineCallGenerator* cg = new LateInlineCallGenerator(method(), _inline_cg, _is_pure_call); | |||
374 | cg->set_call_node(call->as_CallStaticJava()); | |||
375 | return cg; | |||
376 | } | |||
377 | }; | |||
378 | ||||
379 | CallGenerator* CallGenerator::for_late_inline(ciMethod* method, CallGenerator* inline_cg) { | |||
380 | return new LateInlineCallGenerator(method, inline_cg); | |||
381 | } | |||
382 | ||||
383 | class LateInlineMHCallGenerator : public LateInlineCallGenerator { | |||
384 | ciMethod* _caller; | |||
385 | bool _input_not_const; | |||
386 | ||||
387 | virtual bool do_late_inline_check(Compile* C, JVMState* jvms); | |||
388 | ||||
389 | public: | |||
390 | LateInlineMHCallGenerator(ciMethod* caller, ciMethod* callee, bool input_not_const) : | |||
391 | LateInlineCallGenerator(callee, NULL__null), _caller(caller), _input_not_const(input_not_const) {} | |||
392 | ||||
393 | virtual bool is_mh_late_inline() const { return true; } | |||
394 | ||||
395 | // Convert the CallStaticJava into an inline | |||
396 | virtual void do_late_inline(); | |||
397 | ||||
398 | virtual JVMState* generate(JVMState* jvms) { | |||
399 | JVMState* new_jvms = LateInlineCallGenerator::generate(jvms); | |||
400 | ||||
401 | Compile* C = Compile::current(); | |||
402 | if (_input_not_const) { | |||
403 | // inlining won't be possible so no need to enqueue right now. | |||
404 | call_node()->set_generator(this); | |||
405 | } else { | |||
406 | C->add_late_inline(this); | |||
407 | } | |||
408 | return new_jvms; | |||
409 | } | |||
410 | ||||
411 | virtual CallGenerator* with_call_node(CallNode* call) { | |||
412 | LateInlineMHCallGenerator* cg = new LateInlineMHCallGenerator(_caller, method(), _input_not_const); | |||
413 | cg->set_call_node(call->as_CallStaticJava()); | |||
414 | return cg; | |||
415 | } | |||
416 | }; | |||
417 | ||||
418 | bool LateInlineMHCallGenerator::do_late_inline_check(Compile* C, JVMState* jvms) { | |||
419 | // Even if inlining is not allowed, a virtual call can be strength-reduced to a direct call. | |||
420 | bool allow_inline = C->inlining_incrementally(); | |||
421 | bool input_not_const = true; | |||
422 | CallGenerator* cg = for_method_handle_inline(jvms, _caller, method(), allow_inline, input_not_const); | |||
423 | assert(!input_not_const, "sanity")do { if (!(!input_not_const)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/callGenerator.cpp" , 423, "assert(" "!input_not_const" ") failed", "sanity"); :: breakpoint(); } } while (0); // shouldn't have been scheduled for inlining in the first place | |||
424 | ||||
425 | if (cg != NULL__null) { | |||
426 | assert(!cg->is_late_inline() || cg->is_mh_late_inline() || AlwaysIncrementalInline, "we're doing late inlining")do { if (!(!cg->is_late_inline() || cg->is_mh_late_inline () || AlwaysIncrementalInline)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/callGenerator.cpp" , 426, "assert(" "!cg->is_late_inline() || cg->is_mh_late_inline() || AlwaysIncrementalInline" ") failed", "we're doing late inlining"); ::breakpoint(); } } while (0); | |||
427 | _inline_cg = cg; | |||
428 | C->dec_number_of_mh_late_inlines(); | |||
429 | return true; | |||
430 | } else { | |||
431 | // Method handle call which has a constant appendix argument should be either inlined or replaced with a direct call | |||
432 | // unless there's a signature mismatch between caller and callee. If the failure occurs, there's not much to be improved later, | |||
433 | // so don't reinstall the generator to avoid pushing the generator between IGVN and incremental inlining indefinitely. | |||
434 | return false; | |||
435 | } | |||
436 | } | |||
437 | ||||
438 | CallGenerator* CallGenerator::for_mh_late_inline(ciMethod* caller, ciMethod* callee, bool input_not_const) { | |||
439 | assert(IncrementalInlineMH, "required")do { if (!(IncrementalInlineMH)) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/callGenerator.cpp" , 439, "assert(" "IncrementalInlineMH" ") failed", "required" ); ::breakpoint(); } } while (0); | |||
440 | Compile::current()->inc_number_of_mh_late_inlines(); | |||
441 | CallGenerator* cg = new LateInlineMHCallGenerator(caller, callee, input_not_const); | |||
442 | return cg; | |||
443 | } | |||
444 | ||||
445 | // Allow inlining decisions to be delayed | |||
446 | class LateInlineVirtualCallGenerator : public VirtualCallGenerator { | |||
447 | private: | |||
448 | jlong _unique_id; // unique id for log compilation | |||
449 | CallGenerator* _inline_cg; | |||
450 | ciMethod* _callee; | |||
451 | bool _is_pure_call; | |||
452 | float _prof_factor; | |||
453 | ||||
454 | protected: | |||
455 | virtual bool do_late_inline_check(Compile* C, JVMState* jvms); | |||
456 | virtual CallGenerator* inline_cg() const { return _inline_cg; } | |||
457 | virtual bool is_pure_call() const { return _is_pure_call; } | |||
458 | ||||
459 | public: | |||
460 | LateInlineVirtualCallGenerator(ciMethod* method, int vtable_index, float prof_factor) | |||
461 | : VirtualCallGenerator(method, vtable_index, true /*separate_io_projs*/), | |||
462 | _unique_id(0), _inline_cg(NULL__null), _callee(NULL__null), _is_pure_call(false), _prof_factor(prof_factor) { | |||
463 | assert(IncrementalInlineVirtual, "required")do { if (!(IncrementalInlineVirtual)) { (*g_assert_poison) = 'X' ;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/callGenerator.cpp" , 463, "assert(" "IncrementalInlineVirtual" ") failed", "required" ); ::breakpoint(); } } while (0); | |||
464 | } | |||
465 | ||||
466 | virtual bool is_late_inline() const { return true; } | |||
467 | ||||
468 | virtual bool is_virtual_late_inline() const { return true; } | |||
469 | ||||
470 | // Convert the CallDynamicJava into an inline | |||
471 | virtual void do_late_inline(); | |||
472 | ||||
473 | virtual void set_callee_method(ciMethod* m) { | |||
474 | assert(_callee == NULL, "repeated inlining attempt")do { if (!(_callee == __null)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/callGenerator.cpp" , 474, "assert(" "_callee == __null" ") failed", "repeated inlining attempt" ); ::breakpoint(); } } while (0); | |||
475 | _callee = m; | |||
476 | } | |||
477 | ||||
478 | virtual JVMState* generate(JVMState* jvms) { | |||
479 | // Emit the CallDynamicJava and request separate projections so | |||
480 | // that the late inlining logic can distinguish between fall | |||
481 | // through and exceptional uses of the memory and io projections | |||
482 | // as is done for allocations and macro expansion. | |||
483 | JVMState* new_jvms = VirtualCallGenerator::generate(jvms); | |||
484 | if (call_node() != NULL__null) { | |||
485 | call_node()->set_generator(this); | |||
486 | } | |||
487 | return new_jvms; | |||
488 | } | |||
489 | ||||
490 | virtual void print_inlining_late(const char* msg) { | |||
491 | CallNode* call = call_node(); | |||
492 | Compile* C = Compile::current(); | |||
493 | C->print_inlining_assert_ready(); | |||
494 | C->print_inlining(method(), call->jvms()->depth()-1, call->jvms()->bci(), msg); | |||
495 | C->print_inlining_move_to(this); | |||
496 | C->print_inlining_update_delayed(this); | |||
497 | } | |||
498 | ||||
499 | virtual void set_unique_id(jlong id) { | |||
500 | _unique_id = id; | |||
501 | } | |||
502 | ||||
503 | virtual jlong unique_id() const { | |||
504 | return _unique_id; | |||
505 | } | |||
506 | ||||
507 | virtual CallGenerator* with_call_node(CallNode* call) { | |||
508 | LateInlineVirtualCallGenerator* cg = new LateInlineVirtualCallGenerator(method(), vtable_index(), _prof_factor); | |||
509 | cg->set_call_node(call->as_CallDynamicJava()); | |||
510 | return cg; | |||
511 | } | |||
512 | }; | |||
513 | ||||
514 | bool LateInlineVirtualCallGenerator::do_late_inline_check(Compile* C, JVMState* jvms) { | |||
515 | // Method handle linker case is handled in CallDynamicJavaNode::Ideal(). | |||
516 | // Unless inlining is performed, _override_symbolic_info bit will be set in DirectCallGenerator::generate(). | |||
517 | ||||
518 | // Implicit receiver null checks introduce problems when exception states are combined. | |||
519 | Node* receiver = jvms->map()->argument(jvms, 0); | |||
520 | const Type* recv_type = C->initial_gvn()->type(receiver); | |||
521 | if (recv_type->maybe_null()) { | |||
522 | return false; | |||
523 | } | |||
524 | // Even if inlining is not allowed, a virtual call can be strength-reduced to a direct call. | |||
525 | bool allow_inline = C->inlining_incrementally(); | |||
526 | if (!allow_inline && _callee->holder()->is_interface()) { | |||
527 | // Don't convert the interface call to a direct call guarded by an interface subtype check. | |||
528 | return false; | |||
529 | } | |||
530 | CallGenerator* cg = C->call_generator(_callee, | |||
531 | vtable_index(), | |||
532 | false /*call_does_dispatch*/, | |||
533 | jvms, | |||
534 | allow_inline, | |||
535 | _prof_factor, | |||
536 | NULL__null /*speculative_receiver_type*/, | |||
537 | true /*allow_intrinsics*/); | |||
538 | ||||
539 | if (cg != NULL__null) { | |||
540 | assert(!cg->is_late_inline() || cg->is_mh_late_inline() || AlwaysIncrementalInline, "we're doing late inlining")do { if (!(!cg->is_late_inline() || cg->is_mh_late_inline () || AlwaysIncrementalInline)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/callGenerator.cpp" , 540, "assert(" "!cg->is_late_inline() || cg->is_mh_late_inline() || AlwaysIncrementalInline" ") failed", "we're doing late inlining"); ::breakpoint(); } } while (0); | |||
541 | _inline_cg = cg; | |||
542 | return true; | |||
543 | } else { | |||
544 | // Virtual call which provably doesn't dispatch should be either inlined or replaced with a direct call. | |||
545 | assert(false, "no progress")do { if (!(false)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/callGenerator.cpp" , 545, "assert(" "false" ") failed", "no progress"); ::breakpoint (); } } while (0); | |||
546 | return false; | |||
547 | } | |||
548 | } | |||
549 | ||||
550 | CallGenerator* CallGenerator::for_late_inline_virtual(ciMethod* m, int vtable_index, float prof_factor) { | |||
551 | assert(IncrementalInlineVirtual, "required")do { if (!(IncrementalInlineVirtual)) { (*g_assert_poison) = 'X' ;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/callGenerator.cpp" , 551, "assert(" "IncrementalInlineVirtual" ") failed", "required" ); ::breakpoint(); } } while (0); | |||
552 | assert(!m->is_static(), "for_virtual_call mismatch")do { if (!(!m->is_static())) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/callGenerator.cpp" , 552, "assert(" "!m->is_static()" ") failed", "for_virtual_call mismatch" ); ::breakpoint(); } } while (0); | |||
553 | assert(!m->is_method_handle_intrinsic(), "should be a direct call")do { if (!(!m->is_method_handle_intrinsic())) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/callGenerator.cpp" , 553, "assert(" "!m->is_method_handle_intrinsic()" ") failed" , "should be a direct call"); ::breakpoint(); } } while (0); | |||
554 | return new LateInlineVirtualCallGenerator(m, vtable_index, prof_factor); | |||
555 | } | |||
556 | ||||
557 | void LateInlineCallGenerator::do_late_inline() { | |||
558 | CallGenerator::do_late_inline_helper(); | |||
559 | } | |||
560 | ||||
561 | void LateInlineMHCallGenerator::do_late_inline() { | |||
562 | CallGenerator::do_late_inline_helper(); | |||
563 | } | |||
564 | ||||
565 | void LateInlineVirtualCallGenerator::do_late_inline() { | |||
566 | assert(_callee != NULL, "required")do { if (!(_callee != __null)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/callGenerator.cpp" , 566, "assert(" "_callee != __null" ") failed", "required"); ::breakpoint(); } } while (0); // set up in CallDynamicJavaNode::Ideal | |||
567 | CallGenerator::do_late_inline_helper(); | |||
568 | } | |||
569 | ||||
570 | static bool has_non_debug_usages(Node* n) { | |||
571 | for (DUIterator_Fast imax, i = n->fast_outs(imax); i < imax; i++) { | |||
572 | Node* m = n->fast_out(i); | |||
573 | if (!m->is_SafePoint() | |||
574 | || (m->is_Call() && m->as_Call()->has_non_debug_use(n))) { | |||
575 | return true; | |||
576 | } | |||
577 | } | |||
578 | return false; | |||
579 | } | |||
580 | ||||
581 | static bool is_box_cache_valid(CallNode* call) { | |||
582 | ciInstanceKlass* klass = call->as_CallStaticJava()->method()->holder(); | |||
583 | return klass->is_box_cache_valid(); | |||
584 | } | |||
585 | ||||
586 | // delay box in runtime, treat box as a scalarized object | |||
587 | static void scalarize_debug_usages(CallNode* call, Node* resproj) { | |||
588 | GraphKit kit(call->jvms()); | |||
589 | PhaseGVN& gvn = kit.gvn(); | |||
590 | ||||
591 | ProjNode* res = resproj->as_Proj(); | |||
592 | ciInstanceKlass* klass = call->as_CallStaticJava()->method()->holder(); | |||
593 | int n_fields = klass->nof_nonstatic_fields(); | |||
594 | assert(n_fields == 1, "the klass must be an auto-boxing klass")do { if (!(n_fields == 1)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/callGenerator.cpp" , 594, "assert(" "n_fields == 1" ") failed", "the klass must be an auto-boxing klass" ); ::breakpoint(); } } while (0); | |||
595 | ||||
596 | for (DUIterator_Last imin, i = res->last_outs(imin); i >= imin;) { | |||
597 | SafePointNode* sfpt = res->last_out(i)->as_SafePoint(); | |||
598 | uint first_ind = sfpt->req() - sfpt->jvms()->scloff(); | |||
599 | Node* sobj = new SafePointScalarObjectNode(gvn.type(res)->isa_oopptr(), | |||
600 | #ifdef ASSERT1 | |||
601 | call, | |||
602 | #endif // ASSERT | |||
603 | first_ind, n_fields, true); | |||
604 | sobj->init_req(0, kit.root()); | |||
605 | sfpt->add_req(call->in(TypeFunc::Parms)); | |||
606 | sobj = gvn.transform(sobj); | |||
607 | JVMState* jvms = sfpt->jvms(); | |||
608 | jvms->set_endoff(sfpt->req()); | |||
609 | int start = jvms->debug_start(); | |||
610 | int end = jvms->debug_end(); | |||
611 | int num_edges = sfpt->replace_edges_in_range(res, sobj, start, end, &gvn); | |||
612 | i -= num_edges; | |||
613 | } | |||
614 | ||||
615 | assert(res->outcnt() == 0, "the box must have no use after replace")do { if (!(res->outcnt() == 0)) { (*g_assert_poison) = 'X' ;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/callGenerator.cpp" , 615, "assert(" "res->outcnt() == 0" ") failed", "the box must have no use after replace" ); ::breakpoint(); } } while (0); | |||
616 | ||||
617 | #ifndef PRODUCT | |||
618 | if (PrintEliminateAllocations) { | |||
619 | tty->print("++++ Eliminated: %d ", call->_idx); | |||
620 | call->as_CallStaticJava()->method()->print_short_name(tty); | |||
621 | tty->cr(); | |||
622 | } | |||
623 | #endif | |||
624 | } | |||
625 | ||||
626 | void CallGenerator::do_late_inline_helper() { | |||
627 | assert(is_late_inline(), "only late inline allowed")do { if (!(is_late_inline())) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/callGenerator.cpp" , 627, "assert(" "is_late_inline()" ") failed", "only late inline allowed" ); ::breakpoint(); } } while (0); | |||
628 | ||||
629 | // Can't inline it | |||
630 | CallNode* call = call_node(); | |||
631 | if (call == NULL__null || call->outcnt() == 0 || | |||
632 | call->in(0) == NULL__null || call->in(0)->is_top()) { | |||
633 | return; | |||
634 | } | |||
635 | ||||
636 | const TypeTuple *r = call->tf()->domain(); | |||
637 | for (int i1 = 0; i1 < method()->arg_size(); i1++) { | |||
638 | if (call->in(TypeFunc::Parms + i1)->is_top() && r->field_at(TypeFunc::Parms + i1) != Type::HALF) { | |||
639 | assert(Compile::current()->inlining_incrementally(), "shouldn't happen during parsing")do { if (!(Compile::current()->inlining_incrementally())) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/callGenerator.cpp" , 639, "assert(" "Compile::current()->inlining_incrementally()" ") failed", "shouldn't happen during parsing"); ::breakpoint (); } } while (0); | |||
640 | return; | |||
641 | } | |||
642 | } | |||
643 | ||||
644 | if (call->in(TypeFunc::Memory)->is_top()) { | |||
645 | assert(Compile::current()->inlining_incrementally(), "shouldn't happen during parsing")do { if (!(Compile::current()->inlining_incrementally())) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/callGenerator.cpp" , 645, "assert(" "Compile::current()->inlining_incrementally()" ") failed", "shouldn't happen during parsing"); ::breakpoint (); } } while (0); | |||
646 | return; | |||
647 | } | |||
648 | if (call->in(TypeFunc::Memory)->is_MergeMem()) { | |||
649 | MergeMemNode* merge_mem = call->in(TypeFunc::Memory)->as_MergeMem(); | |||
650 | if (merge_mem->base_memory() == merge_mem->empty_memory()) { | |||
651 | return; // dead path | |||
652 | } | |||
653 | } | |||
654 | ||||
655 | // check for unreachable loop | |||
656 | CallProjections callprojs; | |||
657 | call->extract_projections(&callprojs, true); | |||
658 | if ((callprojs.fallthrough_catchproj == call->in(0)) || | |||
659 | (callprojs.catchall_catchproj == call->in(0)) || | |||
660 | (callprojs.fallthrough_memproj == call->in(TypeFunc::Memory)) || | |||
661 | (callprojs.catchall_memproj == call->in(TypeFunc::Memory)) || | |||
662 | (callprojs.fallthrough_ioproj == call->in(TypeFunc::I_O)) || | |||
663 | (callprojs.catchall_ioproj == call->in(TypeFunc::I_O)) || | |||
664 | (callprojs.resproj != NULL__null && call->find_edge(callprojs.resproj) != -1) || | |||
665 | (callprojs.exobj != NULL__null && call->find_edge(callprojs.exobj) != -1)) { | |||
666 | return; | |||
667 | } | |||
668 | ||||
669 | Compile* C = Compile::current(); | |||
670 | // Remove inlined methods from Compiler's lists. | |||
671 | if (call->is_macro()) { | |||
672 | C->remove_macro_node(call); | |||
673 | } | |||
674 | ||||
675 | bool result_not_used = false; | |||
676 | ||||
677 | if (is_pure_call()) { | |||
678 | // Disabled due to JDK-8276112 | |||
679 | if (false && is_boxing_late_inline() && callprojs.resproj != nullptr) { | |||
680 | // replace box node to scalar node only in case it is directly referenced by debug info | |||
681 | assert(call->as_CallStaticJava()->is_boxing_method(), "sanity")do { if (!(call->as_CallStaticJava()->is_boxing_method( ))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/callGenerator.cpp" , 681, "assert(" "call->as_CallStaticJava()->is_boxing_method()" ") failed", "sanity"); ::breakpoint(); } } while (0); | |||
682 | if (!has_non_debug_usages(callprojs.resproj) && is_box_cache_valid(call)) { | |||
683 | scalarize_debug_usages(call, callprojs.resproj); | |||
684 | } | |||
685 | } | |||
686 | ||||
687 | // The call is marked as pure (no important side effects), but result isn't used. | |||
688 | // It's safe to remove the call. | |||
689 | result_not_used = (callprojs.resproj == NULL__null || callprojs.resproj->outcnt() == 0); | |||
690 | } | |||
691 | ||||
692 | if (result_not_used) { | |||
693 | GraphKit kit(call->jvms()); | |||
694 | kit.replace_call(call, C->top(), true); | |||
695 | } else { | |||
696 | // Make a clone of the JVMState that appropriate to use for driving a parse | |||
697 | JVMState* old_jvms = call->jvms(); | |||
698 | JVMState* jvms = old_jvms->clone_shallow(C); | |||
699 | uint size = call->req(); | |||
700 | SafePointNode* map = new SafePointNode(size, jvms); | |||
701 | for (uint i1 = 0; i1 < size; i1++) { | |||
702 | map->init_req(i1, call->in(i1)); | |||
703 | } | |||
704 | ||||
705 | // Make sure the state is a MergeMem for parsing. | |||
706 | if (!map->in(TypeFunc::Memory)->is_MergeMem()) { | |||
707 | Node* mem = MergeMemNode::make(map->in(TypeFunc::Memory)); | |||
708 | C->initial_gvn()->set_type_bottom(mem); | |||
709 | map->set_req(TypeFunc::Memory, mem); | |||
710 | } | |||
711 | ||||
712 | uint nargs = method()->arg_size(); | |||
713 | // blow away old call arguments | |||
714 | Node* top = C->top(); | |||
715 | for (uint i1 = 0; i1 < nargs; i1++) { | |||
716 | map->set_req(TypeFunc::Parms + i1, top); | |||
717 | } | |||
718 | jvms->set_map(map); | |||
719 | ||||
720 | // Make enough space in the expression stack to transfer | |||
721 | // the incoming arguments and return value. | |||
722 | map->ensure_stack(jvms, jvms->method()->max_stack()); | |||
723 | for (uint i1 = 0; i1 < nargs; i1++) { | |||
724 | map->set_argument(jvms, i1, call->in(TypeFunc::Parms + i1)); | |||
725 | } | |||
726 | ||||
727 | C->print_inlining_assert_ready(); | |||
728 | ||||
729 | C->print_inlining_move_to(this); | |||
730 | ||||
731 | C->log_late_inline(this); | |||
732 | ||||
733 | // JVMState is ready, so time to perform some checks and prepare for inlining attempt. | |||
734 | if (!do_late_inline_check(C, jvms)) { | |||
735 | map->disconnect_inputs(C); | |||
736 | C->print_inlining_update_delayed(this); | |||
737 | return; | |||
738 | } | |||
739 | ||||
740 | // Setup default node notes to be picked up by the inlining | |||
741 | Node_Notes* old_nn = C->node_notes_at(call->_idx); | |||
742 | if (old_nn != NULL__null) { | |||
743 | Node_Notes* entry_nn = old_nn->clone(C); | |||
744 | entry_nn->set_jvms(jvms); | |||
745 | C->set_default_node_notes(entry_nn); | |||
746 | } | |||
747 | ||||
748 | // Now perform the inlining using the synthesized JVMState | |||
749 | JVMState* new_jvms = inline_cg()->generate(jvms); | |||
750 | if (new_jvms == NULL__null) return; // no change | |||
751 | if (C->failing()) return; | |||
752 | ||||
753 | // Capture any exceptional control flow | |||
754 | GraphKit kit(new_jvms); | |||
755 | ||||
756 | // Find the result object | |||
757 | Node* result = C->top(); | |||
758 | int result_size = method()->return_type()->size(); | |||
759 | if (result_size != 0 && !kit.stopped()) { | |||
760 | result = (result_size == 1) ? kit.pop() : kit.pop_pair(); | |||
761 | } | |||
762 | ||||
763 | if (inline_cg()->is_inline()) { | |||
764 | C->set_has_loops(C->has_loops() || inline_cg()->method()->has_loops()); | |||
765 | C->env()->notice_inlined_method(inline_cg()->method()); | |||
766 | } | |||
767 | C->set_inlining_progress(true); | |||
768 | C->set_do_cleanup(kit.stopped()); // path is dead; needs cleanup | |||
769 | kit.replace_call(call, result, true); | |||
770 | } | |||
771 | } | |||
772 | ||||
773 | class LateInlineStringCallGenerator : public LateInlineCallGenerator { | |||
774 | ||||
775 | public: | |||
776 | LateInlineStringCallGenerator(ciMethod* method, CallGenerator* inline_cg) : | |||
777 | LateInlineCallGenerator(method, inline_cg) {} | |||
778 | ||||
779 | virtual JVMState* generate(JVMState* jvms) { | |||
780 | Compile *C = Compile::current(); | |||
781 | ||||
782 | C->log_inline_id(this); | |||
783 | ||||
784 | C->add_string_late_inline(this); | |||
785 | ||||
786 | JVMState* new_jvms = DirectCallGenerator::generate(jvms); | |||
787 | return new_jvms; | |||
788 | } | |||
789 | ||||
790 | virtual bool is_string_late_inline() const { return true; } | |||
791 | ||||
792 | virtual CallGenerator* with_call_node(CallNode* call) { | |||
793 | LateInlineStringCallGenerator* cg = new LateInlineStringCallGenerator(method(), _inline_cg); | |||
794 | cg->set_call_node(call->as_CallStaticJava()); | |||
795 | return cg; | |||
796 | } | |||
797 | }; | |||
798 | ||||
799 | CallGenerator* CallGenerator::for_string_late_inline(ciMethod* method, CallGenerator* inline_cg) { | |||
800 | return new LateInlineStringCallGenerator(method, inline_cg); | |||
801 | } | |||
802 | ||||
803 | class LateInlineBoxingCallGenerator : public LateInlineCallGenerator { | |||
804 | ||||
805 | public: | |||
806 | LateInlineBoxingCallGenerator(ciMethod* method, CallGenerator* inline_cg) : | |||
807 | LateInlineCallGenerator(method, inline_cg, /*is_pure=*/true) {} | |||
808 | ||||
809 | virtual JVMState* generate(JVMState* jvms) { | |||
810 | Compile *C = Compile::current(); | |||
811 | ||||
812 | C->log_inline_id(this); | |||
813 | ||||
814 | C->add_boxing_late_inline(this); | |||
815 | ||||
816 | JVMState* new_jvms = DirectCallGenerator::generate(jvms); | |||
817 | return new_jvms; | |||
818 | } | |||
819 | ||||
820 | virtual bool is_boxing_late_inline() const { return true; } | |||
821 | ||||
822 | virtual CallGenerator* with_call_node(CallNode* call) { | |||
823 | LateInlineBoxingCallGenerator* cg = new LateInlineBoxingCallGenerator(method(), _inline_cg); | |||
824 | cg->set_call_node(call->as_CallStaticJava()); | |||
825 | return cg; | |||
826 | } | |||
827 | }; | |||
828 | ||||
829 | CallGenerator* CallGenerator::for_boxing_late_inline(ciMethod* method, CallGenerator* inline_cg) { | |||
830 | return new LateInlineBoxingCallGenerator(method, inline_cg); | |||
831 | } | |||
832 | ||||
833 | class LateInlineVectorReboxingCallGenerator : public LateInlineCallGenerator { | |||
834 | ||||
835 | public: | |||
836 | LateInlineVectorReboxingCallGenerator(ciMethod* method, CallGenerator* inline_cg) : | |||
837 | LateInlineCallGenerator(method, inline_cg, /*is_pure=*/true) {} | |||
838 | ||||
839 | virtual JVMState* generate(JVMState* jvms) { | |||
840 | Compile *C = Compile::current(); | |||
841 | ||||
842 | C->log_inline_id(this); | |||
843 | ||||
844 | C->add_vector_reboxing_late_inline(this); | |||
845 | ||||
846 | JVMState* new_jvms = DirectCallGenerator::generate(jvms); | |||
847 | return new_jvms; | |||
848 | } | |||
849 | ||||
850 | virtual CallGenerator* with_call_node(CallNode* call) { | |||
851 | LateInlineVectorReboxingCallGenerator* cg = new LateInlineVectorReboxingCallGenerator(method(), _inline_cg); | |||
852 | cg->set_call_node(call->as_CallStaticJava()); | |||
853 | return cg; | |||
854 | } | |||
855 | }; | |||
856 | ||||
857 | // static CallGenerator* for_vector_reboxing_late_inline(ciMethod* m, CallGenerator* inline_cg); | |||
858 | CallGenerator* CallGenerator::for_vector_reboxing_late_inline(ciMethod* method, CallGenerator* inline_cg) { | |||
859 | return new LateInlineVectorReboxingCallGenerator(method, inline_cg); | |||
860 | } | |||
861 | ||||
862 | //------------------------PredictedCallGenerator------------------------------ | |||
863 | // Internal class which handles all out-of-line calls checking receiver type. | |||
864 | class PredictedCallGenerator : public CallGenerator { | |||
865 | ciKlass* _predicted_receiver; | |||
866 | CallGenerator* _if_missed; | |||
867 | CallGenerator* _if_hit; | |||
868 | float _hit_prob; | |||
869 | bool _exact_check; | |||
870 | ||||
871 | public: | |||
872 | PredictedCallGenerator(ciKlass* predicted_receiver, | |||
873 | CallGenerator* if_missed, | |||
874 | CallGenerator* if_hit, bool exact_check, | |||
875 | float hit_prob) | |||
876 | : CallGenerator(if_missed->method()) | |||
877 | { | |||
878 | // The call profile data may predict the hit_prob as extreme as 0 or 1. | |||
879 | // Remove the extremes values from the range. | |||
880 | if (hit_prob > PROB_MAX(1.0f-(1e-6f))) hit_prob = PROB_MAX(1.0f-(1e-6f)); | |||
881 | if (hit_prob < PROB_MIN(1e-6f)) hit_prob = PROB_MIN(1e-6f); | |||
882 | ||||
883 | _predicted_receiver = predicted_receiver; | |||
884 | _if_missed = if_missed; | |||
885 | _if_hit = if_hit; | |||
886 | _hit_prob = hit_prob; | |||
887 | _exact_check = exact_check; | |||
888 | } | |||
889 | ||||
890 | virtual bool is_virtual() const { return true; } | |||
891 | virtual bool is_inline() const { return _if_hit->is_inline(); } | |||
892 | virtual bool is_deferred() const { return _if_hit->is_deferred(); } | |||
893 | ||||
894 | virtual JVMState* generate(JVMState* jvms); | |||
895 | }; | |||
896 | ||||
897 | ||||
898 | CallGenerator* CallGenerator::for_predicted_call(ciKlass* predicted_receiver, | |||
899 | CallGenerator* if_missed, | |||
900 | CallGenerator* if_hit, | |||
901 | float hit_prob) { | |||
902 | return new PredictedCallGenerator(predicted_receiver, if_missed, if_hit, | |||
903 | /*exact_check=*/true, hit_prob); | |||
904 | } | |||
905 | ||||
906 | CallGenerator* CallGenerator::for_guarded_call(ciKlass* guarded_receiver, | |||
907 | CallGenerator* if_missed, | |||
908 | CallGenerator* if_hit) { | |||
909 | return new PredictedCallGenerator(guarded_receiver, if_missed, if_hit, | |||
910 | /*exact_check=*/false, PROB_ALWAYS(1.0f-(1e-6f))); | |||
911 | } | |||
912 | ||||
913 | JVMState* PredictedCallGenerator::generate(JVMState* jvms) { | |||
914 | GraphKit kit(jvms); | |||
915 | kit.C->print_inlining_update(this); | |||
916 | PhaseGVN& gvn = kit.gvn(); | |||
917 | // We need an explicit receiver null_check before checking its type. | |||
918 | // We share a map with the caller, so his JVMS gets adjusted. | |||
919 | Node* receiver = kit.argument(0); | |||
920 | CompileLog* log = kit.C->log(); | |||
921 | if (log != NULL__null) { | |||
| ||||
922 | log->elem("predicted_call bci='%d' exact='%d' klass='%d'", | |||
923 | jvms->bci(), (_exact_check ? 1 : 0), log->identify(_predicted_receiver)); | |||
924 | } | |||
925 | ||||
926 | receiver = kit.null_check_receiver_before_call(method()); | |||
927 | if (kit.stopped()) { | |||
928 | return kit.transfer_exceptions_into_jvms(); | |||
929 | } | |||
930 | ||||
931 | // Make a copy of the replaced nodes in case we need to restore them | |||
932 | ReplacedNodes replaced_nodes = kit.map()->replaced_nodes(); | |||
933 | replaced_nodes.clone(); | |||
934 | ||||
935 | Node* casted_receiver = receiver; // will get updated in place... | |||
936 | Node* slow_ctl = NULL__null; | |||
937 | if (_exact_check) { | |||
938 | slow_ctl = kit.type_check_receiver(receiver, _predicted_receiver, _hit_prob, | |||
939 | &casted_receiver); | |||
940 | } else { | |||
941 | slow_ctl = kit.subtype_check_receiver(receiver, _predicted_receiver, | |||
942 | &casted_receiver); | |||
943 | } | |||
944 | ||||
945 | SafePointNode* slow_map = NULL__null; | |||
946 | JVMState* slow_jvms = NULL__null; | |||
947 | { PreserveJVMState pjvms(&kit); | |||
948 | kit.set_control(slow_ctl); | |||
949 | if (!kit.stopped()) { | |||
950 | slow_jvms = _if_missed->generate(kit.sync_jvms()); | |||
951 | if (kit.failing()) | |||
952 | return NULL__null; // might happen because of NodeCountInliningCutoff | |||
953 | assert(slow_jvms != NULL, "must be")do { if (!(slow_jvms != __null)) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/callGenerator.cpp" , 953, "assert(" "slow_jvms != __null" ") failed", "must be") ; ::breakpoint(); } } while (0); | |||
954 | kit.add_exception_states_from(slow_jvms); | |||
955 | kit.set_map(slow_jvms->map()); | |||
956 | if (!kit.stopped()) | |||
957 | slow_map = kit.stop(); | |||
958 | } | |||
959 | } | |||
960 | ||||
961 | if (kit.stopped()) { | |||
962 | // Instance does not match the predicted type. | |||
963 | kit.set_jvms(slow_jvms); | |||
964 | return kit.transfer_exceptions_into_jvms(); | |||
965 | } | |||
966 | ||||
967 | // Fall through if the instance matches the desired type. | |||
968 | kit.replace_in_map(receiver, casted_receiver); | |||
969 | ||||
970 | // Make the hot call: | |||
971 | JVMState* new_jvms = _if_hit->generate(kit.sync_jvms()); | |||
972 | if (new_jvms == NULL__null) { | |||
973 | // Inline failed, so make a direct call. | |||
974 | assert(_if_hit->is_inline(), "must have been a failed inline")do { if (!(_if_hit->is_inline())) { (*g_assert_poison) = 'X' ;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/callGenerator.cpp" , 974, "assert(" "_if_hit->is_inline()" ") failed", "must have been a failed inline" ); ::breakpoint(); } } while (0); | |||
975 | CallGenerator* cg = CallGenerator::for_direct_call(_if_hit->method()); | |||
976 | new_jvms = cg->generate(kit.sync_jvms()); | |||
977 | } | |||
978 | kit.add_exception_states_from(new_jvms); | |||
979 | kit.set_jvms(new_jvms); | |||
980 | ||||
981 | // Need to merge slow and fast? | |||
982 | if (slow_map == NULL__null) { | |||
983 | // The fast path is the only path remaining. | |||
984 | return kit.transfer_exceptions_into_jvms(); | |||
985 | } | |||
986 | ||||
987 | if (kit.stopped()) { | |||
988 | // Inlined method threw an exception, so it's just the slow path after all. | |||
989 | kit.set_jvms(slow_jvms); | |||
990 | return kit.transfer_exceptions_into_jvms(); | |||
991 | } | |||
992 | ||||
993 | // There are 2 branches and the replaced nodes are only valid on | |||
994 | // one: restore the replaced nodes to what they were before the | |||
995 | // branch. | |||
996 | kit.map()->set_replaced_nodes(replaced_nodes); | |||
997 | ||||
998 | // Finish the diamond. | |||
999 | kit.C->set_has_split_ifs(true); // Has chance for split-if optimization | |||
1000 | RegionNode* region = new RegionNode(3); | |||
1001 | region->init_req(1, kit.control()); | |||
1002 | region->init_req(2, slow_map->control()); | |||
1003 | kit.set_control(gvn.transform(region)); | |||
1004 | Node* iophi = PhiNode::make(region, kit.i_o(), Type::ABIO); | |||
1005 | iophi->set_req(2, slow_map->i_o()); | |||
1006 | kit.set_i_o(gvn.transform(iophi)); | |||
1007 | // Merge memory | |||
1008 | kit.merge_memory(slow_map->merged_memory(), region, 2); | |||
1009 | // Transform new memory Phis. | |||
1010 | for (MergeMemStream mms(kit.merged_memory()); mms.next_non_empty();) { | |||
1011 | Node* phi = mms.memory(); | |||
1012 | if (phi->is_Phi() && phi->in(0) == region) { | |||
1013 | mms.set_memory(gvn.transform(phi)); | |||
1014 | } | |||
1015 | } | |||
1016 | uint tos = kit.jvms()->stkoff() + kit.sp(); | |||
1017 | uint limit = slow_map->req(); | |||
1018 | for (uint i = TypeFunc::Parms; i < limit; i++) { | |||
1019 | // Skip unused stack slots; fast forward to monoff(); | |||
1020 | if (i == tos) { | |||
1021 | i = kit.jvms()->monoff(); | |||
1022 | if( i >= limit ) break; | |||
1023 | } | |||
1024 | Node* m = kit.map()->in(i); | |||
1025 | Node* n = slow_map->in(i); | |||
1026 | if (m != n) { | |||
1027 | const Type* t = gvn.type(m)->meet_speculative(gvn.type(n)); | |||
1028 | Node* phi = PhiNode::make(region, m, t); | |||
1029 | phi->set_req(2, n); | |||
1030 | kit.map()->set_req(i, gvn.transform(phi)); | |||
1031 | } | |||
1032 | } | |||
1033 | return kit.transfer_exceptions_into_jvms(); | |||
1034 | } | |||
1035 | ||||
1036 | ||||
1037 | CallGenerator* CallGenerator::for_method_handle_call(JVMState* jvms, ciMethod* caller, ciMethod* callee, bool allow_inline) { | |||
1038 | assert(callee->is_method_handle_intrinsic(), "for_method_handle_call mismatch")do { if (!(callee->is_method_handle_intrinsic())) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/callGenerator.cpp" , 1038, "assert(" "callee->is_method_handle_intrinsic()" ") failed" , "for_method_handle_call mismatch"); ::breakpoint(); } } while (0); | |||
1039 | bool input_not_const; | |||
1040 | CallGenerator* cg = CallGenerator::for_method_handle_inline(jvms, caller, callee, allow_inline, input_not_const); | |||
1041 | Compile* C = Compile::current(); | |||
1042 | if (cg != NULL__null) { | |||
1043 | if (AlwaysIncrementalInline) { | |||
1044 | return CallGenerator::for_late_inline(callee, cg); | |||
1045 | } else { | |||
1046 | return cg; | |||
1047 | } | |||
1048 | } | |||
1049 | int bci = jvms->bci(); | |||
1050 | ciCallProfile profile = caller->call_profile_at_bci(bci); | |||
1051 | int call_site_count = caller->scale_count(profile.count()); | |||
1052 | ||||
1053 | if (IncrementalInlineMH && call_site_count > 0 && | |||
1054 | (input_not_const || !C->inlining_incrementally() || C->over_inlining_cutoff())) { | |||
1055 | return CallGenerator::for_mh_late_inline(caller, callee, input_not_const); | |||
1056 | } else { | |||
1057 | // Out-of-line call. | |||
1058 | return CallGenerator::for_direct_call(callee); | |||
1059 | } | |||
1060 | } | |||
1061 | ||||
1062 | class NativeCallGenerator : public CallGenerator { | |||
1063 | private: | |||
1064 | address _call_addr; | |||
1065 | ciNativeEntryPoint* _nep; | |||
1066 | public: | |||
1067 | NativeCallGenerator(ciMethod* m, address call_addr, ciNativeEntryPoint* nep) | |||
1068 | : CallGenerator(m), _call_addr(call_addr), _nep(nep) {} | |||
1069 | ||||
1070 | virtual JVMState* generate(JVMState* jvms); | |||
1071 | }; | |||
1072 | ||||
1073 | JVMState* NativeCallGenerator::generate(JVMState* jvms) { | |||
1074 | GraphKit kit(jvms); | |||
1075 | ||||
1076 | Node* call = kit.make_native_call(_call_addr, tf(), method()->arg_size(), _nep); // -fallback, - nep | |||
1077 | if (call == NULL__null) return NULL__null; | |||
1078 | ||||
1079 | kit.C->print_inlining_update(this); | |||
1080 | if (kit.C->log() != NULL__null) { | |||
1081 | kit.C->log()->elem("l2n_intrinsification_success bci='%d' entry_point='" INTPTR_FORMAT"0x%016" "l" "x" "'", jvms->bci(), p2i(_call_addr)); | |||
1082 | } | |||
1083 | ||||
1084 | return kit.transfer_exceptions_into_jvms(); | |||
1085 | } | |||
1086 | ||||
1087 | CallGenerator* CallGenerator::for_method_handle_inline(JVMState* jvms, ciMethod* caller, ciMethod* callee, bool allow_inline, bool& input_not_const) { | |||
1088 | GraphKit kit(jvms); | |||
1089 | PhaseGVN& gvn = kit.gvn(); | |||
1090 | Compile* C = kit.C; | |||
1091 | vmIntrinsics::ID iid = callee->intrinsic_id(); | |||
1092 | input_not_const = true; | |||
1093 | if (StressMethodHandleLinkerInlining) { | |||
1094 | allow_inline = false; | |||
1095 | } | |||
1096 | switch (iid) { | |||
1097 | case vmIntrinsics::_invokeBasic: | |||
1098 | { | |||
1099 | // Get MethodHandle receiver: | |||
1100 | Node* receiver = kit.argument(0); | |||
1101 | if (receiver->Opcode() == Op_ConP) { | |||
1102 | input_not_const = false; | |||
1103 | const TypeOopPtr* oop_ptr = receiver->bottom_type()->is_oopptr(); | |||
1104 | ciMethod* target = oop_ptr->const_oop()->as_method_handle()->get_vmtarget(); | |||
1105 | const int vtable_index = Method::invalid_vtable_index; | |||
1106 | ||||
1107 | if (!ciMethod::is_consistent_info(callee, target)) { | |||
1108 | print_inlining_failure(C, callee, jvms->depth() - 1, jvms->bci(), | |||
1109 | "signatures mismatch"); | |||
1110 | return NULL__null; | |||
1111 | } | |||
1112 | ||||
1113 | CallGenerator* cg = C->call_generator(target, vtable_index, | |||
1114 | false /* call_does_dispatch */, | |||
1115 | jvms, | |||
1116 | allow_inline, | |||
1117 | PROB_ALWAYS(1.0f-(1e-6f))); | |||
1118 | return cg; | |||
1119 | } else { | |||
1120 | print_inlining_failure(C, callee, jvms->depth() - 1, jvms->bci(), | |||
1121 | "receiver not constant"); | |||
1122 | } | |||
1123 | } | |||
1124 | break; | |||
1125 | ||||
1126 | case vmIntrinsics::_linkToVirtual: | |||
1127 | case vmIntrinsics::_linkToStatic: | |||
1128 | case vmIntrinsics::_linkToSpecial: | |||
1129 | case vmIntrinsics::_linkToInterface: | |||
1130 | { | |||
1131 | // Get MemberName argument: | |||
1132 | Node* member_name = kit.argument(callee->arg_size() - 1); | |||
1133 | if (member_name->Opcode() == Op_ConP) { | |||
1134 | input_not_const = false; | |||
1135 | const TypeOopPtr* oop_ptr = member_name->bottom_type()->is_oopptr(); | |||
1136 | ciMethod* target = oop_ptr->const_oop()->as_member_name()->get_vmtarget(); | |||
1137 | ||||
1138 | if (!ciMethod::is_consistent_info(callee, target)) { | |||
1139 | print_inlining_failure(C, callee, jvms->depth() - 1, jvms->bci(), | |||
1140 | "signatures mismatch"); | |||
1141 | return NULL__null; | |||
1142 | } | |||
1143 | ||||
1144 | // In lambda forms we erase signature types to avoid resolving issues | |||
1145 | // involving class loaders. When we optimize a method handle invoke | |||
1146 | // to a direct call we must cast the receiver and arguments to its | |||
1147 | // actual types. | |||
1148 | ciSignature* signature = target->signature(); | |||
1149 | const int receiver_skip = target->is_static() ? 0 : 1; | |||
1150 | // Cast receiver to its type. | |||
1151 | if (!target->is_static()) { | |||
1152 | Node* arg = kit.argument(0); | |||
1153 | const TypeOopPtr* arg_type = arg->bottom_type()->isa_oopptr(); | |||
1154 | const Type* sig_type = TypeOopPtr::make_from_klass(signature->accessing_klass()); | |||
1155 | if (arg_type != NULL__null && !arg_type->higher_equal(sig_type)) { | |||
1156 | const Type* recv_type = arg_type->filter_speculative(sig_type); // keep speculative part | |||
1157 | Node* cast_obj = gvn.transform(new CheckCastPPNode(kit.control(), arg, recv_type)); | |||
1158 | kit.set_argument(0, cast_obj); | |||
1159 | } | |||
1160 | } | |||
1161 | // Cast reference arguments to its type. | |||
1162 | for (int i = 0, j = 0; i < signature->count(); i++) { | |||
1163 | ciType* t = signature->type_at(i); | |||
1164 | if (t->is_klass()) { | |||
1165 | Node* arg = kit.argument(receiver_skip + j); | |||
1166 | const TypeOopPtr* arg_type = arg->bottom_type()->isa_oopptr(); | |||
1167 | const Type* sig_type = TypeOopPtr::make_from_klass(t->as_klass()); | |||
1168 | if (arg_type != NULL__null && !arg_type->higher_equal(sig_type)) { | |||
1169 | const Type* narrowed_arg_type = arg_type->filter_speculative(sig_type); // keep speculative part | |||
1170 | Node* cast_obj = gvn.transform(new CheckCastPPNode(kit.control(), arg, narrowed_arg_type)); | |||
1171 | kit.set_argument(receiver_skip + j, cast_obj); | |||
1172 | } | |||
1173 | } | |||
1174 | j += t->size(); // long and double take two slots | |||
1175 | } | |||
1176 | ||||
1177 | // Try to get the most accurate receiver type | |||
1178 | const bool is_virtual = (iid == vmIntrinsics::_linkToVirtual); | |||
1179 | const bool is_virtual_or_interface = (is_virtual || iid == vmIntrinsics::_linkToInterface); | |||
1180 | int vtable_index = Method::invalid_vtable_index; | |||
1181 | bool call_does_dispatch = false; | |||
1182 | ||||
1183 | ciKlass* speculative_receiver_type = NULL__null; | |||
1184 | if (is_virtual_or_interface) { | |||
1185 | ciInstanceKlass* klass = target->holder(); | |||
1186 | Node* receiver_node = kit.argument(0); | |||
1187 | const TypeOopPtr* receiver_type = gvn.type(receiver_node)->isa_oopptr(); | |||
1188 | // call_does_dispatch and vtable_index are out-parameters. They might be changed. | |||
1189 | // optimize_virtual_call() takes 2 different holder | |||
1190 | // arguments for a corner case that doesn't apply here (see | |||
1191 | // Parse::do_call()) | |||
1192 | target = C->optimize_virtual_call(caller, klass, klass, | |||
1193 | target, receiver_type, is_virtual, | |||
1194 | call_does_dispatch, vtable_index, // out-parameters | |||
1195 | false /* check_access */); | |||
1196 | // We lack profiling at this call but type speculation may | |||
1197 | // provide us with a type | |||
1198 | speculative_receiver_type = (receiver_type != NULL__null) ? receiver_type->speculative_type() : NULL__null; | |||
1199 | } | |||
1200 | CallGenerator* cg = C->call_generator(target, vtable_index, call_does_dispatch, jvms, | |||
1201 | allow_inline, | |||
1202 | PROB_ALWAYS(1.0f-(1e-6f)), | |||
1203 | speculative_receiver_type); | |||
1204 | return cg; | |||
1205 | } else { | |||
1206 | print_inlining_failure(C, callee, jvms->depth() - 1, jvms->bci(), | |||
1207 | "member_name not constant"); | |||
1208 | } | |||
1209 | } | |||
1210 | break; | |||
1211 | ||||
1212 | case vmIntrinsics::_linkToNative: | |||
1213 | { | |||
1214 | Node* addr_n = kit.argument(1); // target address | |||
1215 | Node* nep_n = kit.argument(callee->arg_size() - 1); // NativeEntryPoint | |||
1216 | // This check needs to be kept in sync with the one in CallStaticJavaNode::Ideal | |||
1217 | if (addr_n->Opcode() == Op_ConL && nep_n->Opcode() == Op_ConP) { | |||
1218 | input_not_const = false; | |||
1219 | const TypeLong* addr_t = addr_n->bottom_type()->is_long(); | |||
1220 | const TypeOopPtr* nep_t = nep_n->bottom_type()->is_oopptr(); | |||
1221 | address addr = (address) addr_t->get_con(); | |||
1222 | ciNativeEntryPoint* nep = nep_t->const_oop()->as_native_entry_point(); | |||
1223 | return new NativeCallGenerator(callee, addr, nep); | |||
1224 | } else { | |||
1225 | print_inlining_failure(C, callee, jvms->depth() - 1, jvms->bci(), | |||
1226 | "NativeEntryPoint not constant"); | |||
1227 | } | |||
1228 | } | |||
1229 | break; | |||
1230 | ||||
1231 | default: | |||
1232 | fatal("unexpected intrinsic %d: %s", vmIntrinsics::as_int(iid), vmIntrinsics::name_at(iid))do { (*g_assert_poison) = 'X';; report_fatal(INTERNAL_ERROR, "/home/daniel/Projects/java/jdk/src/hotspot/share/opto/callGenerator.cpp" , 1232, "unexpected intrinsic %d: %s", vmIntrinsics::as_int(iid ), vmIntrinsics::name_at(iid)); ::breakpoint(); } while (0); | |||
1233 | break; | |||
1234 | } | |||
1235 | return NULL__null; | |||
1236 | } | |||
1237 | ||||
1238 | ||||
1239 | //------------------------PredicatedIntrinsicGenerator------------------------------ | |||
1240 | // Internal class which handles all predicated Intrinsic calls. | |||
1241 | class PredicatedIntrinsicGenerator : public CallGenerator { | |||
1242 | CallGenerator* _intrinsic; | |||
1243 | CallGenerator* _cg; | |||
1244 | ||||
1245 | public: | |||
1246 | PredicatedIntrinsicGenerator(CallGenerator* intrinsic, | |||
1247 | CallGenerator* cg) | |||
1248 | : CallGenerator(cg->method()) | |||
1249 | { | |||
1250 | _intrinsic = intrinsic; | |||
1251 | _cg = cg; | |||
1252 | } | |||
1253 | ||||
1254 | virtual bool is_virtual() const { return true; } | |||
1255 | virtual bool is_inline() const { return true; } | |||
1256 | virtual bool is_intrinsic() const { return true; } | |||
1257 | ||||
1258 | virtual JVMState* generate(JVMState* jvms); | |||
1259 | }; | |||
1260 | ||||
1261 | ||||
1262 | CallGenerator* CallGenerator::for_predicated_intrinsic(CallGenerator* intrinsic, | |||
1263 | CallGenerator* cg) { | |||
1264 | return new PredicatedIntrinsicGenerator(intrinsic, cg); | |||
1265 | } | |||
1266 | ||||
1267 | ||||
1268 | JVMState* PredicatedIntrinsicGenerator::generate(JVMState* jvms) { | |||
1269 | // The code we want to generate here is: | |||
1270 | // if (receiver == NULL) | |||
1271 | // uncommon_Trap | |||
1272 | // if (predicate(0)) | |||
1273 | // do_intrinsic(0) | |||
1274 | // else | |||
1275 | // if (predicate(1)) | |||
1276 | // do_intrinsic(1) | |||
1277 | // ... | |||
1278 | // else | |||
1279 | // do_java_comp | |||
1280 | ||||
1281 | GraphKit kit(jvms); | |||
1282 | PhaseGVN& gvn = kit.gvn(); | |||
1283 | ||||
1284 | CompileLog* log = kit.C->log(); | |||
1285 | if (log != NULL__null) { | |||
1286 | log->elem("predicated_intrinsic bci='%d' method='%d'", | |||
1287 | jvms->bci(), log->identify(method())); | |||
1288 | } | |||
1289 | ||||
1290 | if (!method()->is_static()) { | |||
1291 | // We need an explicit receiver null_check before checking its type in predicate. | |||
1292 | // We share a map with the caller, so his JVMS gets adjusted. | |||
1293 | Node* receiver = kit.null_check_receiver_before_call(method()); | |||
1294 | if (kit.stopped()) { | |||
1295 | return kit.transfer_exceptions_into_jvms(); | |||
1296 | } | |||
1297 | } | |||
1298 | ||||
1299 | int n_predicates = _intrinsic->predicates_count(); | |||
1300 | assert(n_predicates > 0, "sanity")do { if (!(n_predicates > 0)) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/callGenerator.cpp" , 1300, "assert(" "n_predicates > 0" ") failed", "sanity") ; ::breakpoint(); } } while (0); | |||
1301 | ||||
1302 | JVMState** result_jvms = NEW_RESOURCE_ARRAY(JVMState*, (n_predicates+1))(JVMState**) resource_allocate_bytes(((n_predicates+1)) * sizeof (JVMState*)); | |||
1303 | ||||
1304 | // Region for normal compilation code if intrinsic failed. | |||
1305 | Node* slow_region = new RegionNode(1); | |||
1306 | ||||
1307 | int results = 0; | |||
1308 | for (int predicate = 0; (predicate < n_predicates) && !kit.stopped(); predicate++) { | |||
1309 | #ifdef ASSERT1 | |||
1310 | JVMState* old_jvms = kit.jvms(); | |||
1311 | SafePointNode* old_map = kit.map(); | |||
1312 | Node* old_io = old_map->i_o(); | |||
1313 | Node* old_mem = old_map->memory(); | |||
1314 | Node* old_exc = old_map->next_exception(); | |||
1315 | #endif | |||
1316 | Node* else_ctrl = _intrinsic->generate_predicate(kit.sync_jvms(), predicate); | |||
1317 | #ifdef ASSERT1 | |||
1318 | // Assert(no_new_memory && no_new_io && no_new_exceptions) after generate_predicate. | |||
1319 | assert(old_jvms == kit.jvms(), "generate_predicate should not change jvm state")do { if (!(old_jvms == kit.jvms())) { (*g_assert_poison) = 'X' ;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/callGenerator.cpp" , 1319, "assert(" "old_jvms == kit.jvms()" ") failed", "generate_predicate should not change jvm state" ); ::breakpoint(); } } while (0); | |||
1320 | SafePointNode* new_map = kit.map(); | |||
1321 | assert(old_io == new_map->i_o(), "generate_predicate should not change i_o")do { if (!(old_io == new_map->i_o())) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/callGenerator.cpp" , 1321, "assert(" "old_io == new_map->i_o()" ") failed", "generate_predicate should not change i_o" ); ::breakpoint(); } } while (0); | |||
1322 | assert(old_mem == new_map->memory(), "generate_predicate should not change memory")do { if (!(old_mem == new_map->memory())) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/callGenerator.cpp" , 1322, "assert(" "old_mem == new_map->memory()" ") failed" , "generate_predicate should not change memory"); ::breakpoint (); } } while (0); | |||
1323 | assert(old_exc == new_map->next_exception(), "generate_predicate should not add exceptions")do { if (!(old_exc == new_map->next_exception())) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/callGenerator.cpp" , 1323, "assert(" "old_exc == new_map->next_exception()" ") failed" , "generate_predicate should not add exceptions"); ::breakpoint (); } } while (0); | |||
1324 | #endif | |||
1325 | if (!kit.stopped()) { | |||
1326 | PreserveJVMState pjvms(&kit); | |||
1327 | // Generate intrinsic code: | |||
1328 | JVMState* new_jvms = _intrinsic->generate(kit.sync_jvms()); | |||
1329 | if (new_jvms == NULL__null) { | |||
1330 | // Intrinsic failed, use normal compilation path for this predicate. | |||
1331 | slow_region->add_req(kit.control()); | |||
1332 | } else { | |||
1333 | kit.add_exception_states_from(new_jvms); | |||
1334 | kit.set_jvms(new_jvms); | |||
1335 | if (!kit.stopped()) { | |||
1336 | result_jvms[results++] = kit.jvms(); | |||
1337 | } | |||
1338 | } | |||
1339 | } | |||
1340 | if (else_ctrl == NULL__null) { | |||
1341 | else_ctrl = kit.C->top(); | |||
1342 | } | |||
1343 | kit.set_control(else_ctrl); | |||
1344 | } | |||
1345 | if (!kit.stopped()) { | |||
1346 | // Final 'else' after predicates. | |||
1347 | slow_region->add_req(kit.control()); | |||
1348 | } | |||
1349 | if (slow_region->req() > 1) { | |||
1350 | PreserveJVMState pjvms(&kit); | |||
1351 | // Generate normal compilation code: | |||
1352 | kit.set_control(gvn.transform(slow_region)); | |||
1353 | JVMState* new_jvms = _cg->generate(kit.sync_jvms()); | |||
1354 | if (kit.failing()) | |||
1355 | return NULL__null; // might happen because of NodeCountInliningCutoff | |||
1356 | assert(new_jvms != NULL, "must be")do { if (!(new_jvms != __null)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/callGenerator.cpp" , 1356, "assert(" "new_jvms != __null" ") failed", "must be") ; ::breakpoint(); } } while (0); | |||
1357 | kit.add_exception_states_from(new_jvms); | |||
1358 | kit.set_jvms(new_jvms); | |||
1359 | if (!kit.stopped()) { | |||
1360 | result_jvms[results++] = kit.jvms(); | |||
1361 | } | |||
1362 | } | |||
1363 | ||||
1364 | if (results == 0) { | |||
1365 | // All paths ended in uncommon traps. | |||
1366 | (void) kit.stop(); | |||
1367 | return kit.transfer_exceptions_into_jvms(); | |||
1368 | } | |||
1369 | ||||
1370 | if (results == 1) { // Only one path | |||
1371 | kit.set_jvms(result_jvms[0]); | |||
1372 | return kit.transfer_exceptions_into_jvms(); | |||
1373 | } | |||
1374 | ||||
1375 | // Merge all paths. | |||
1376 | kit.C->set_has_split_ifs(true); // Has chance for split-if optimization | |||
1377 | RegionNode* region = new RegionNode(results + 1); | |||
1378 | Node* iophi = PhiNode::make(region, kit.i_o(), Type::ABIO); | |||
1379 | for (int i = 0; i < results; i++) { | |||
1380 | JVMState* jvms = result_jvms[i]; | |||
1381 | int path = i + 1; | |||
1382 | SafePointNode* map = jvms->map(); | |||
1383 | region->init_req(path, map->control()); | |||
1384 | iophi->set_req(path, map->i_o()); | |||
1385 | if (i == 0) { | |||
1386 | kit.set_jvms(jvms); | |||
1387 | } else { | |||
1388 | kit.merge_memory(map->merged_memory(), region, path); | |||
1389 | } | |||
1390 | } | |||
1391 | kit.set_control(gvn.transform(region)); | |||
1392 | kit.set_i_o(gvn.transform(iophi)); | |||
1393 | // Transform new memory Phis. | |||
1394 | for (MergeMemStream mms(kit.merged_memory()); mms.next_non_empty();) { | |||
1395 | Node* phi = mms.memory(); | |||
1396 | if (phi->is_Phi() && phi->in(0) == region) { | |||
1397 | mms.set_memory(gvn.transform(phi)); | |||
1398 | } | |||
1399 | } | |||
1400 | ||||
1401 | // Merge debug info. | |||
1402 | Node** ins = NEW_RESOURCE_ARRAY(Node*, results)(Node**) resource_allocate_bytes((results) * sizeof(Node*)); | |||
1403 | uint tos = kit.jvms()->stkoff() + kit.sp(); | |||
1404 | Node* map = kit.map(); | |||
1405 | uint limit = map->req(); | |||
1406 | for (uint i = TypeFunc::Parms; i < limit; i++) { | |||
1407 | // Skip unused stack slots; fast forward to monoff(); | |||
1408 | if (i == tos) { | |||
1409 | i = kit.jvms()->monoff(); | |||
1410 | if( i >= limit ) break; | |||
1411 | } | |||
1412 | Node* n = map->in(i); | |||
1413 | ins[0] = n; | |||
1414 | const Type* t = gvn.type(n); | |||
1415 | bool needs_phi = false; | |||
1416 | for (int j = 1; j < results; j++) { | |||
1417 | JVMState* jvms = result_jvms[j]; | |||
1418 | Node* jmap = jvms->map(); | |||
1419 | Node* m = NULL__null; | |||
1420 | if (jmap->req() > i) { | |||
1421 | m = jmap->in(i); | |||
1422 | if (m != n) { | |||
1423 | needs_phi = true; | |||
1424 | t = t->meet_speculative(gvn.type(m)); | |||
1425 | } | |||
1426 | } | |||
1427 | ins[j] = m; | |||
1428 | } | |||
1429 | if (needs_phi) { | |||
1430 | Node* phi = PhiNode::make(region, n, t); | |||
1431 | for (int j = 1; j < results; j++) { | |||
1432 | phi->set_req(j + 1, ins[j]); | |||
1433 | } | |||
1434 | map->set_req(i, gvn.transform(phi)); | |||
1435 | } | |||
1436 | } | |||
1437 | ||||
1438 | return kit.transfer_exceptions_into_jvms(); | |||
1439 | } | |||
1440 | ||||
1441 | //-------------------------UncommonTrapCallGenerator----------------------------- | |||
1442 | // Internal class which handles all out-of-line calls checking receiver type. | |||
1443 | class UncommonTrapCallGenerator : public CallGenerator { | |||
1444 | Deoptimization::DeoptReason _reason; | |||
1445 | Deoptimization::DeoptAction _action; | |||
1446 | ||||
1447 | public: | |||
1448 | UncommonTrapCallGenerator(ciMethod* m, | |||
1449 | Deoptimization::DeoptReason reason, | |||
1450 | Deoptimization::DeoptAction action) | |||
1451 | : CallGenerator(m) | |||
1452 | { | |||
1453 | _reason = reason; | |||
1454 | _action = action; | |||
1455 | } | |||
1456 | ||||
1457 | virtual bool is_virtual() const { ShouldNotReachHere()do { (*g_assert_poison) = 'X';; report_should_not_reach_here( "/home/daniel/Projects/java/jdk/src/hotspot/share/opto/callGenerator.cpp" , 1457); ::breakpoint(); } while (0); return false; } | |||
1458 | virtual bool is_trap() const { return true; } | |||
1459 | ||||
1460 | virtual JVMState* generate(JVMState* jvms); | |||
1461 | }; | |||
1462 | ||||
1463 | ||||
1464 | CallGenerator* | |||
1465 | CallGenerator::for_uncommon_trap(ciMethod* m, | |||
1466 | Deoptimization::DeoptReason reason, | |||
1467 | Deoptimization::DeoptAction action) { | |||
1468 | return new UncommonTrapCallGenerator(m, reason, action); | |||
1469 | } | |||
1470 | ||||
1471 | ||||
1472 | JVMState* UncommonTrapCallGenerator::generate(JVMState* jvms) { | |||
1473 | GraphKit kit(jvms); | |||
1474 | kit.C->print_inlining_update(this); | |||
1475 | // Take the trap with arguments pushed on the stack. (Cf. null_check_receiver). | |||
1476 | // Callsite signature can be different from actual method being called (i.e _linkTo* sites). | |||
1477 | // Use callsite signature always. | |||
1478 | ciMethod* declared_method = kit.method()->get_method_at_bci(kit.bci()); | |||
1479 | int nargs = declared_method->arg_size(); | |||
1480 | kit.inc_sp(nargs); | |||
1481 | assert(nargs <= kit.sp() && kit.sp() <= jvms->stk_size(), "sane sp w/ args pushed")do { if (!(nargs <= kit.sp() && kit.sp() <= jvms ->stk_size())) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/callGenerator.cpp" , 1481, "assert(" "nargs <= kit.sp() && kit.sp() <= jvms->stk_size()" ") failed", "sane sp w/ args pushed"); ::breakpoint(); } } while (0); | |||
1482 | if (_reason == Deoptimization::Reason_class_check && | |||
1483 | _action == Deoptimization::Action_maybe_recompile) { | |||
1484 | // Temp fix for 6529811 | |||
1485 | // Don't allow uncommon_trap to override our decision to recompile in the event | |||
1486 | // of a class cast failure for a monomorphic call as it will never let us convert | |||
1487 | // the call to either bi-morphic or megamorphic and can lead to unc-trap loops | |||
1488 | bool keep_exact_action = true; | |||
1489 | kit.uncommon_trap(_reason, _action, NULL__null, "monomorphic vcall checkcast", false, keep_exact_action); | |||
1490 | } else { | |||
1491 | kit.uncommon_trap(_reason, _action); | |||
1492 | } | |||
1493 | return kit.transfer_exceptions_into_jvms(); | |||
1494 | } | |||
1495 | ||||
1496 | // (Note: Moved hook_up_call to GraphKit::set_edges_for_java_call.) | |||
1497 | ||||
1498 | // (Node: Merged hook_up_exits into ParseGenerator::generate.) |
1 | /* | |||
2 | * Copyright (c) 2001, 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_GRAPHKIT_HPP | |||
26 | #define SHARE_OPTO_GRAPHKIT_HPP | |||
27 | ||||
28 | #include "ci/ciEnv.hpp" | |||
29 | #include "ci/ciMethodData.hpp" | |||
30 | #include "gc/shared/c2/barrierSetC2.hpp" | |||
31 | #include "opto/addnode.hpp" | |||
32 | #include "opto/callnode.hpp" | |||
33 | #include "opto/cfgnode.hpp" | |||
34 | #include "opto/compile.hpp" | |||
35 | #include "opto/divnode.hpp" | |||
36 | #include "opto/mulnode.hpp" | |||
37 | #include "opto/phaseX.hpp" | |||
38 | #include "opto/subnode.hpp" | |||
39 | #include "opto/type.hpp" | |||
40 | #include "runtime/deoptimization.hpp" | |||
41 | ||||
42 | class BarrierSetC2; | |||
43 | class FastLockNode; | |||
44 | class FastUnlockNode; | |||
45 | class IdealKit; | |||
46 | class LibraryCallKit; | |||
47 | class Parse; | |||
48 | class RootNode; | |||
49 | ||||
50 | //----------------------------------------------------------------------------- | |||
51 | //----------------------------GraphKit----------------------------------------- | |||
52 | // Toolkit for building the common sorts of subgraphs. | |||
53 | // Does not know about bytecode parsing or type-flow results. | |||
54 | // It is able to create graphs implementing the semantics of most | |||
55 | // or all bytecodes, so that it can expand intrinsics and calls. | |||
56 | // It may depend on JVMState structure, but it must not depend | |||
57 | // on specific bytecode streams. | |||
58 | class GraphKit : public Phase { | |||
59 | friend class PreserveJVMState; | |||
60 | ||||
61 | protected: | |||
62 | ciEnv* _env; // Compilation environment | |||
63 | PhaseGVN &_gvn; // Some optimizations while parsing | |||
64 | SafePointNode* _map; // Parser map from JVM to Nodes | |||
65 | SafePointNode* _exceptions;// Parser map(s) for exception state(s) | |||
66 | int _bci; // JVM Bytecode Pointer | |||
67 | ciMethod* _method; // JVM Current Method | |||
68 | BarrierSetC2* _barrier_set; | |||
69 | ||||
70 | private: | |||
71 | int _sp; // JVM Expression Stack Pointer; don't modify directly! | |||
72 | ||||
73 | private: | |||
74 | SafePointNode* map_not_null() const { | |||
75 | assert(_map != NULL, "must call stopped() to test for reset compiler map")do { if (!(_map != __null)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/graphKit.hpp" , 75, "assert(" "_map != __null" ") failed", "must call stopped() to test for reset compiler map" ); ::breakpoint(); } } while (0); | |||
76 | return _map; | |||
77 | } | |||
78 | ||||
79 | public: | |||
80 | GraphKit(); // empty constructor | |||
81 | GraphKit(JVMState* jvms); // the JVM state on which to operate | |||
82 | ||||
83 | #ifdef ASSERT1 | |||
84 | ~GraphKit() { | |||
85 | assert(!has_exceptions(), "user must call transfer_exceptions_into_jvms")do { if (!(!has_exceptions())) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/graphKit.hpp" , 85, "assert(" "!has_exceptions()" ") failed", "user must call transfer_exceptions_into_jvms" ); ::breakpoint(); } } while (0); | |||
86 | } | |||
87 | #endif | |||
88 | ||||
89 | virtual Parse* is_Parse() const { return NULL__null; } | |||
90 | virtual LibraryCallKit* is_LibraryCallKit() const { return NULL__null; } | |||
91 | ||||
92 | ciEnv* env() const { return _env; } | |||
93 | PhaseGVN& gvn() const { return _gvn; } | |||
94 | void* barrier_set_state() const { return C->barrier_set_state(); } | |||
95 | ||||
96 | void record_for_igvn(Node* n) const { C->record_for_igvn(n); } // delegate to Compile | |||
97 | ||||
98 | // Handy well-known nodes: | |||
99 | Node* null() const { return zerocon(T_OBJECT); } | |||
100 | Node* top() const { return C->top(); } | |||
101 | RootNode* root() const { return C->root(); } | |||
102 | ||||
103 | // Create or find a constant node | |||
104 | Node* intcon(jint con) const { return _gvn.intcon(con); } | |||
105 | Node* longcon(jlong con) const { return _gvn.longcon(con); } | |||
106 | Node* integercon(jlong con, BasicType bt) const { | |||
107 | if (bt == T_INT) { | |||
108 | return intcon(checked_cast<jint>(con)); | |||
109 | } | |||
110 | assert(bt == T_LONG, "basic type not an int or long")do { if (!(bt == T_LONG)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/graphKit.hpp" , 110, "assert(" "bt == T_LONG" ") failed", "basic type not an int or long" ); ::breakpoint(); } } while (0); | |||
111 | return longcon(con); | |||
112 | } | |||
113 | Node* makecon(const Type *t) const { return _gvn.makecon(t); } | |||
114 | Node* zerocon(BasicType bt) const { return _gvn.zerocon(bt); } | |||
115 | // (See also macro MakeConX in type.hpp, which uses intcon or longcon.) | |||
116 | ||||
117 | jint find_int_con(Node* n, jint value_if_unknown) { | |||
118 | return _gvn.find_int_con(n, value_if_unknown); | |||
119 | } | |||
120 | jlong find_long_con(Node* n, jlong value_if_unknown) { | |||
121 | return _gvn.find_long_con(n, value_if_unknown); | |||
122 | } | |||
123 | // (See also macro find_intptr_t_con in type.hpp, which uses one of these.) | |||
124 | ||||
125 | // JVM State accessors: | |||
126 | // Parser mapping from JVM indices into Nodes. | |||
127 | // Low slots are accessed by the StartNode::enum. | |||
128 | // Then come the locals at StartNode::Parms to StartNode::Parms+max_locals(); | |||
129 | // Then come JVM stack slots. | |||
130 | // Finally come the monitors, if any. | |||
131 | // See layout accessors in class JVMState. | |||
132 | ||||
133 | SafePointNode* map() const { return _map; } | |||
134 | bool has_exceptions() const { return _exceptions != NULL__null; } | |||
135 | JVMState* jvms() const { return map_not_null()->_jvms; } | |||
136 | int sp() const { return _sp; } | |||
137 | int bci() const { return _bci; } | |||
138 | Bytecodes::Code java_bc() const; | |||
139 | ciMethod* method() const { return _method; } | |||
140 | ||||
141 | void set_jvms(JVMState* jvms) { set_map(jvms->map()); | |||
| ||||
142 | assert(jvms == this->jvms(), "sanity")do { if (!(jvms == this->jvms())) { (*g_assert_poison) = 'X' ;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/graphKit.hpp" , 142, "assert(" "jvms == this->jvms()" ") failed", "sanity" ); ::breakpoint(); } } while (0); | |||
143 | _sp = jvms->sp(); | |||
144 | _bci = jvms->bci(); | |||
145 | _method = jvms->has_method() ? jvms->method() : NULL__null; } | |||
146 | void set_map(SafePointNode* m) { _map = m; debug_only(verify_map())verify_map(); } | |||
147 | void set_sp(int sp) { assert(sp >= 0, "sp must be non-negative: %d", sp)do { if (!(sp >= 0)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/graphKit.hpp" , 147, "assert(" "sp >= 0" ") failed", "sp must be non-negative: %d" , sp); ::breakpoint(); } } while (0); _sp = sp; } | |||
148 | void clean_stack(int from_sp); // clear garbage beyond from_sp to top | |||
149 | ||||
150 | void inc_sp(int i) { set_sp(sp() + i); } | |||
151 | void dec_sp(int i) { set_sp(sp() - i); } | |||
152 | void set_bci(int bci) { _bci = bci; } | |||
153 | ||||
154 | // Make sure jvms has current bci & sp. | |||
155 | JVMState* sync_jvms() const; | |||
156 | JVMState* sync_jvms_for_reexecute(); | |||
157 | ||||
158 | #ifdef ASSERT1 | |||
159 | // Make sure JVMS has an updated copy of bci and sp. | |||
160 | // Also sanity-check method, depth, and monitor depth. | |||
161 | bool jvms_in_sync() const; | |||
162 | ||||
163 | // Make sure the map looks OK. | |||
164 | void verify_map() const; | |||
165 | ||||
166 | // Make sure a proposed exception state looks OK. | |||
167 | static void verify_exception_state(SafePointNode* ex_map); | |||
168 | #endif | |||
169 | ||||
170 | // Clone the existing map state. (Implements PreserveJVMState.) | |||
171 | SafePointNode* clone_map(); | |||
172 | ||||
173 | // Set the map to a clone of the given one. | |||
174 | void set_map_clone(SafePointNode* m); | |||
175 | ||||
176 | // Tell if the compilation is failing. | |||
177 | bool failing() const { return C->failing(); } | |||
178 | ||||
179 | // Set _map to NULL, signalling a stop to further bytecode execution. | |||
180 | // Preserve the map intact for future use, and return it back to the caller. | |||
181 | SafePointNode* stop() { SafePointNode* m = map(); set_map(NULL__null); return m; } | |||
182 | ||||
183 | // Stop, but first smash the map's inputs to NULL, to mark it dead. | |||
184 | void stop_and_kill_map(); | |||
185 | ||||
186 | // Tell if _map is NULL, or control is top. | |||
187 | bool stopped(); | |||
188 | ||||
189 | // Tell if this method or any caller method has exception handlers. | |||
190 | bool has_ex_handler(); | |||
191 | ||||
192 | // Save an exception without blowing stack contents or other JVM state. | |||
193 | // (The extra pointer is stuck with add_req on the map, beyond the JVMS.) | |||
194 | static void set_saved_ex_oop(SafePointNode* ex_map, Node* ex_oop); | |||
195 | ||||
196 | // Recover a saved exception from its map. | |||
197 | static Node* saved_ex_oop(SafePointNode* ex_map); | |||
198 | ||||
199 | // Recover a saved exception from its map, and remove it from the map. | |||
200 | static Node* clear_saved_ex_oop(SafePointNode* ex_map); | |||
201 | ||||
202 | #ifdef ASSERT1 | |||
203 | // Recover a saved exception from its map, and remove it from the map. | |||
204 | static bool has_saved_ex_oop(SafePointNode* ex_map); | |||
205 | #endif | |||
206 | ||||
207 | // Push an exception in the canonical position for handlers (stack(0)). | |||
208 | void push_ex_oop(Node* ex_oop) { | |||
209 | ensure_stack(1); // ensure room to push the exception | |||
210 | set_stack(0, ex_oop); | |||
211 | set_sp(1); | |||
212 | clean_stack(1); | |||
213 | } | |||
214 | ||||
215 | // Detach and return an exception state. | |||
216 | SafePointNode* pop_exception_state() { | |||
217 | SafePointNode* ex_map = _exceptions; | |||
218 | if (ex_map != NULL__null) { | |||
219 | _exceptions = ex_map->next_exception(); | |||
220 | ex_map->set_next_exception(NULL__null); | |||
221 | debug_only(verify_exception_state(ex_map))verify_exception_state(ex_map); | |||
222 | } | |||
223 | return ex_map; | |||
224 | } | |||
225 | ||||
226 | // Add an exception, using the given JVM state, without commoning. | |||
227 | void push_exception_state(SafePointNode* ex_map) { | |||
228 | debug_only(verify_exception_state(ex_map))verify_exception_state(ex_map); | |||
229 | ex_map->set_next_exception(_exceptions); | |||
230 | _exceptions = ex_map; | |||
231 | } | |||
232 | ||||
233 | // Turn the current JVM state into an exception state, appending the ex_oop. | |||
234 | SafePointNode* make_exception_state(Node* ex_oop); | |||
235 | ||||
236 | // Add an exception, using the given JVM state. | |||
237 | // Combine all exceptions with a common exception type into a single state. | |||
238 | // (This is done via combine_exception_states.) | |||
239 | void add_exception_state(SafePointNode* ex_map); | |||
240 | ||||
241 | // Combine all exceptions of any sort whatever into a single master state. | |||
242 | SafePointNode* combine_and_pop_all_exception_states() { | |||
243 | if (_exceptions == NULL__null) return NULL__null; | |||
244 | SafePointNode* phi_map = pop_exception_state(); | |||
245 | SafePointNode* ex_map; | |||
246 | while ((ex_map = pop_exception_state()) != NULL__null) { | |||
247 | combine_exception_states(ex_map, phi_map); | |||
248 | } | |||
249 | return phi_map; | |||
250 | } | |||
251 | ||||
252 | // Combine the two exception states, building phis as necessary. | |||
253 | // The second argument is updated to include contributions from the first. | |||
254 | void combine_exception_states(SafePointNode* ex_map, SafePointNode* phi_map); | |||
255 | ||||
256 | // Reset the map to the given state. If there are any half-finished phis | |||
257 | // in it (created by combine_exception_states), transform them now. | |||
258 | // Returns the exception oop. (Caller must call push_ex_oop if required.) | |||
259 | Node* use_exception_state(SafePointNode* ex_map); | |||
260 | ||||
261 | // Collect exceptions from a given JVM state into my exception list. | |||
262 | void add_exception_states_from(JVMState* jvms); | |||
263 | ||||
264 | // Collect all raised exceptions into the current JVM state. | |||
265 | // Clear the current exception list and map, returns the combined states. | |||
266 | JVMState* transfer_exceptions_into_jvms(); | |||
267 | ||||
268 | // Helper to throw a built-in exception. | |||
269 | // Range checks take the offending index. | |||
270 | // Cast and array store checks take the offending class. | |||
271 | // Others do not take the optional argument. | |||
272 | // The JVMS must allow the bytecode to be re-executed | |||
273 | // via an uncommon trap. | |||
274 | void builtin_throw(Deoptimization::DeoptReason reason, Node* arg = NULL__null); | |||
275 | ||||
276 | // Helper to check the JavaThread::_should_post_on_exceptions flag | |||
277 | // and branch to an uncommon_trap if it is true (with the specified reason and must_throw) | |||
278 | void uncommon_trap_if_should_post_on_exceptions(Deoptimization::DeoptReason reason, | |||
279 | bool must_throw) ; | |||
280 | ||||
281 | // Helper Functions for adding debug information | |||
282 | void kill_dead_locals(); | |||
283 | #ifdef ASSERT1 | |||
284 | bool dead_locals_are_killed(); | |||
285 | #endif | |||
286 | // The call may deoptimize. Supply required JVM state as debug info. | |||
287 | // If must_throw is true, the call is guaranteed not to return normally. | |||
288 | void add_safepoint_edges(SafePointNode* call, | |||
289 | bool must_throw = false); | |||
290 | ||||
291 | // How many stack inputs does the current BC consume? | |||
292 | // And, how does the stack change after the bytecode? | |||
293 | // Returns false if unknown. | |||
294 | bool compute_stack_effects(int& inputs, int& depth); | |||
295 | ||||
296 | // Add a fixed offset to a pointer | |||
297 | Node* basic_plus_adr(Node* base, Node* ptr, intptr_t offset) { | |||
298 | return basic_plus_adr(base, ptr, MakeConXlongcon(offset)); | |||
299 | } | |||
300 | Node* basic_plus_adr(Node* base, intptr_t offset) { | |||
301 | return basic_plus_adr(base, base, MakeConXlongcon(offset)); | |||
302 | } | |||
303 | // Add a variable offset to a pointer | |||
304 | Node* basic_plus_adr(Node* base, Node* offset) { | |||
305 | return basic_plus_adr(base, base, offset); | |||
306 | } | |||
307 | Node* basic_plus_adr(Node* base, Node* ptr, Node* offset); | |||
308 | ||||
309 | ||||
310 | // Some convenient shortcuts for common nodes | |||
311 | Node* IfTrue(IfNode* iff) { return _gvn.transform(new IfTrueNode(iff)); } | |||
312 | Node* IfFalse(IfNode* iff) { return _gvn.transform(new IfFalseNode(iff)); } | |||
313 | ||||
314 | Node* AddI(Node* l, Node* r) { return _gvn.transform(new AddINode(l, r)); } | |||
315 | Node* SubI(Node* l, Node* r) { return _gvn.transform(new SubINode(l, r)); } | |||
316 | Node* MulI(Node* l, Node* r) { return _gvn.transform(new MulINode(l, r)); } | |||
317 | Node* DivI(Node* ctl, Node* l, Node* r) { return _gvn.transform(new DivINode(ctl, l, r)); } | |||
318 | ||||
319 | Node* AndI(Node* l, Node* r) { return _gvn.transform(new AndINode(l, r)); } | |||
320 | Node* OrI(Node* l, Node* r) { return _gvn.transform(new OrINode(l, r)); } | |||
321 | Node* XorI(Node* l, Node* r) { return _gvn.transform(new XorINode(l, r)); } | |||
322 | ||||
323 | Node* MaxI(Node* l, Node* r) { return _gvn.transform(new MaxINode(l, r)); } | |||
324 | Node* MinI(Node* l, Node* r) { return _gvn.transform(new MinINode(l, r)); } | |||
325 | ||||
326 | Node* LShiftI(Node* l, Node* r) { return _gvn.transform(new LShiftINode(l, r)); } | |||
327 | Node* RShiftI(Node* l, Node* r) { return _gvn.transform(new RShiftINode(l, r)); } | |||
328 | Node* URShiftI(Node* l, Node* r) { return _gvn.transform(new URShiftINode(l, r)); } | |||
329 | ||||
330 | Node* CmpI(Node* l, Node* r) { return _gvn.transform(new CmpINode(l, r)); } | |||
331 | Node* CmpL(Node* l, Node* r) { return _gvn.transform(new CmpLNode(l, r)); } | |||
332 | Node* CmpP(Node* l, Node* r) { return _gvn.transform(new CmpPNode(l, r)); } | |||
333 | Node* Bool(Node* cmp, BoolTest::mask relop) { return _gvn.transform(new BoolNode(cmp, relop)); } | |||
334 | ||||
335 | Node* AddP(Node* b, Node* a, Node* o) { return _gvn.transform(new AddPNode(b, a, o)); } | |||
336 | ||||
337 | // Convert between int and long, and size_t. | |||
338 | // (See macros ConvI2X, etc., in type.hpp for ConvI2X, etc.) | |||
339 | Node* ConvI2L(Node* offset); | |||
340 | Node* ConvI2UL(Node* offset); | |||
341 | Node* ConvL2I(Node* offset); | |||
342 | // Find out the klass of an object. | |||
343 | Node* load_object_klass(Node* object); | |||
344 | // Find out the length of an array. | |||
345 | Node* load_array_length(Node* array); | |||
346 | // Cast array allocation's length as narrow as possible. | |||
347 | // If replace_length_in_map is true, replace length with CastIINode in map. | |||
348 | // This method is invoked after creating/moving ArrayAllocationNode or in load_array_length | |||
349 | Node* array_ideal_length(AllocateArrayNode* alloc, | |||
350 | const TypeOopPtr* oop_type, | |||
351 | bool replace_length_in_map); | |||
352 | ||||
353 | ||||
354 | // Helper function to do a NULL pointer check or ZERO check based on type. | |||
355 | // Throw an exception if a given value is null. | |||
356 | // Return the value cast to not-null. | |||
357 | // Be clever about equivalent dominating null checks. | |||
358 | Node* null_check_common(Node* value, BasicType type, | |||
359 | bool assert_null = false, | |||
360 | Node* *null_control = NULL__null, | |||
361 | bool speculative = false); | |||
362 | Node* null_check(Node* value, BasicType type = T_OBJECT) { | |||
363 | return null_check_common(value, type, false, NULL__null, !_gvn.type(value)->speculative_maybe_null()); | |||
364 | } | |||
365 | Node* null_check_receiver() { | |||
366 | assert(argument(0)->bottom_type()->isa_ptr(), "must be")do { if (!(argument(0)->bottom_type()->isa_ptr())) { (* g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/graphKit.hpp" , 366, "assert(" "argument(0)->bottom_type()->isa_ptr()" ") failed", "must be"); ::breakpoint(); } } while (0); | |||
367 | return null_check(argument(0)); | |||
368 | } | |||
369 | Node* zero_check_int(Node* value) { | |||
370 | assert(value->bottom_type()->basic_type() == T_INT,do { if (!(value->bottom_type()->basic_type() == T_INT) ) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/graphKit.hpp" , 371, "assert(" "value->bottom_type()->basic_type() == T_INT" ") failed", "wrong type: %s", type2name(value->bottom_type ()->basic_type())); ::breakpoint(); } } while (0) | |||
371 | "wrong type: %s", type2name(value->bottom_type()->basic_type()))do { if (!(value->bottom_type()->basic_type() == T_INT) ) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/graphKit.hpp" , 371, "assert(" "value->bottom_type()->basic_type() == T_INT" ") failed", "wrong type: %s", type2name(value->bottom_type ()->basic_type())); ::breakpoint(); } } while (0); | |||
372 | return null_check_common(value, T_INT); | |||
373 | } | |||
374 | Node* zero_check_long(Node* value) { | |||
375 | assert(value->bottom_type()->basic_type() == T_LONG,do { if (!(value->bottom_type()->basic_type() == T_LONG )) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/graphKit.hpp" , 376, "assert(" "value->bottom_type()->basic_type() == T_LONG" ") failed", "wrong type: %s", type2name(value->bottom_type ()->basic_type())); ::breakpoint(); } } while (0) | |||
376 | "wrong type: %s", type2name(value->bottom_type()->basic_type()))do { if (!(value->bottom_type()->basic_type() == T_LONG )) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/graphKit.hpp" , 376, "assert(" "value->bottom_type()->basic_type() == T_LONG" ") failed", "wrong type: %s", type2name(value->bottom_type ()->basic_type())); ::breakpoint(); } } while (0); | |||
377 | return null_check_common(value, T_LONG); | |||
378 | } | |||
379 | // Throw an uncommon trap if a given value is __not__ null. | |||
380 | // Return the value cast to null, and be clever about dominating checks. | |||
381 | Node* null_assert(Node* value, BasicType type = T_OBJECT) { | |||
382 | return null_check_common(value, type, true, NULL__null, _gvn.type(value)->speculative_always_null()); | |||
383 | } | |||
384 | ||||
385 | // Check if value is null and abort if it is | |||
386 | Node* must_be_not_null(Node* value, bool do_replace_in_map); | |||
387 | ||||
388 | // Null check oop. Return null-path control into (*null_control). | |||
389 | // Return a cast-not-null node which depends on the not-null control. | |||
390 | // If never_see_null, use an uncommon trap (*null_control sees a top). | |||
391 | // The cast is not valid along the null path; keep a copy of the original. | |||
392 | // If safe_for_replace, then we can replace the value with the cast | |||
393 | // in the parsing map (the cast is guaranteed to dominate the map) | |||
394 | Node* null_check_oop(Node* value, Node* *null_control, | |||
395 | bool never_see_null = false, | |||
396 | bool safe_for_replace = false, | |||
397 | bool speculative = false); | |||
398 | ||||
399 | // Check the null_seen bit. | |||
400 | bool seems_never_null(Node* obj, ciProfileData* data, bool& speculating); | |||
401 | ||||
402 | void guard_klass_being_initialized(Node* klass); | |||
403 | void guard_init_thread(Node* klass); | |||
404 | ||||
405 | void clinit_barrier(ciInstanceKlass* ik, ciMethod* context); | |||
406 | ||||
407 | // Check for unique class for receiver at call | |||
408 | ciKlass* profile_has_unique_klass() { | |||
409 | ciCallProfile profile = method()->call_profile_at_bci(bci()); | |||
410 | if (profile.count() >= 0 && // no cast failures here | |||
411 | profile.has_receiver(0) && | |||
412 | profile.morphism() == 1) { | |||
413 | return profile.receiver(0); | |||
414 | } | |||
415 | return NULL__null; | |||
416 | } | |||
417 | ||||
418 | // record type from profiling with the type system | |||
419 | Node* record_profile_for_speculation(Node* n, ciKlass* exact_kls, ProfilePtrKind ptr_kind); | |||
420 | void record_profiled_arguments_for_speculation(ciMethod* dest_method, Bytecodes::Code bc); | |||
421 | void record_profiled_parameters_for_speculation(); | |||
422 | void record_profiled_return_for_speculation(); | |||
423 | Node* record_profiled_receiver_for_speculation(Node* n); | |||
424 | ||||
425 | // Use the type profile to narrow an object type. | |||
426 | Node* maybe_cast_profiled_receiver(Node* not_null_obj, | |||
427 | ciKlass* require_klass, | |||
428 | ciKlass* spec, | |||
429 | bool safe_for_replace); | |||
430 | ||||
431 | // Cast obj to type and emit guard unless we had too many traps here already | |||
432 | Node* maybe_cast_profiled_obj(Node* obj, | |||
433 | ciKlass* type, | |||
434 | bool not_null = false); | |||
435 | ||||
436 | // Cast obj to not-null on this path | |||
437 | Node* cast_not_null(Node* obj, bool do_replace_in_map = true); | |||
438 | // Replace all occurrences of one node by another. | |||
439 | void replace_in_map(Node* old, Node* neww); | |||
440 | ||||
441 | void push(Node* n) { map_not_null(); _map->set_stack(_map->_jvms, _sp++ , n); } | |||
442 | Node* pop() { map_not_null(); return _map->stack( _map->_jvms, --_sp ); } | |||
443 | Node* peek(int off = 0) { map_not_null(); return _map->stack( _map->_jvms, _sp - off - 1 ); } | |||
444 | ||||
445 | void push_pair(Node* ldval) { | |||
446 | push(ldval); | |||
447 | push(top()); // the halfword is merely a placeholder | |||
448 | } | |||
449 | void push_pair_local(int i) { | |||
450 | // longs are stored in locals in "push" order | |||
451 | push( local(i+0) ); // the real value | |||
452 | assert(local(i+1) == top(), "")do { if (!(local(i+1) == top())) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/graphKit.hpp" , 452, "assert(" "local(i+1) == top()" ") failed", ""); ::breakpoint (); } } while (0); | |||
453 | push(top()); // halfword placeholder | |||
454 | } | |||
455 | Node* pop_pair() { | |||
456 | // the second half is pushed last & popped first; it contains exactly nothing | |||
457 | Node* halfword = pop(); | |||
458 | assert(halfword == top(), "")do { if (!(halfword == top())) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/graphKit.hpp" , 458, "assert(" "halfword == top()" ") failed", ""); ::breakpoint (); } } while (0); | |||
459 | // the long bits are pushed first & popped last: | |||
460 | return pop(); | |||
461 | } | |||
462 | void set_pair_local(int i, Node* lval) { | |||
463 | // longs are stored in locals as a value/half pair (like doubles) | |||
464 | set_local(i+0, lval); | |||
465 | set_local(i+1, top()); | |||
466 | } | |||
467 | ||||
468 | // Push the node, which may be zero, one, or two words. | |||
469 | void push_node(BasicType n_type, Node* n) { | |||
470 | int n_size = type2size[n_type]; | |||
471 | if (n_size == 1) push( n ); // T_INT, ... | |||
472 | else if (n_size == 2) push_pair( n ); // T_DOUBLE, T_LONG | |||
473 | else { assert(n_size == 0, "must be T_VOID")do { if (!(n_size == 0)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/graphKit.hpp" , 473, "assert(" "n_size == 0" ") failed", "must be T_VOID"); ::breakpoint(); } } while (0); } | |||
474 | } | |||
475 | ||||
476 | Node* pop_node(BasicType n_type) { | |||
477 | int n_size = type2size[n_type]; | |||
478 | if (n_size == 1) return pop(); | |||
479 | else if (n_size == 2) return pop_pair(); | |||
480 | else return NULL__null; | |||
481 | } | |||
482 | ||||
483 | Node* control() const { return map_not_null()->control(); } | |||
484 | Node* i_o() const { return map_not_null()->i_o(); } | |||
485 | Node* returnadr() const { return map_not_null()->returnadr(); } | |||
486 | Node* frameptr() const { return map_not_null()->frameptr(); } | |||
487 | Node* local(uint idx) const { map_not_null(); return _map->local( _map->_jvms, idx); } | |||
488 | Node* stack(uint idx) const { map_not_null(); return _map->stack( _map->_jvms, idx); } | |||
489 | Node* argument(uint idx) const { map_not_null(); return _map->argument( _map->_jvms, idx); } | |||
490 | Node* monitor_box(uint idx) const { map_not_null(); return _map->monitor_box(_map->_jvms, idx); } | |||
491 | Node* monitor_obj(uint idx) const { map_not_null(); return _map->monitor_obj(_map->_jvms, idx); } | |||
492 | ||||
493 | void set_control (Node* c) { map_not_null()->set_control(c); } | |||
494 | void set_i_o (Node* c) { map_not_null()->set_i_o(c); } | |||
495 | void set_local(uint idx, Node* c) { map_not_null(); _map->set_local( _map->_jvms, idx, c); } | |||
496 | void set_stack(uint idx, Node* c) { map_not_null(); _map->set_stack( _map->_jvms, idx, c); } | |||
497 | void set_argument(uint idx, Node* c){ map_not_null(); _map->set_argument(_map->_jvms, idx, c); } | |||
498 | void ensure_stack(uint stk_size) { map_not_null(); _map->ensure_stack(_map->_jvms, stk_size); } | |||
499 | ||||
500 | // Access unaliased memory | |||
501 | Node* memory(uint alias_idx); | |||
502 | Node* memory(const TypePtr *tp) { return memory(C->get_alias_index(tp)); } | |||
503 | Node* memory(Node* adr) { return memory(_gvn.type(adr)->is_ptr()); } | |||
504 | ||||
505 | // Access immutable memory | |||
506 | Node* immutable_memory() { return C->immutable_memory(); } | |||
507 | ||||
508 | // Set unaliased memory | |||
509 | void set_memory(Node* c, uint alias_idx) { merged_memory()->set_memory_at(alias_idx, c); } | |||
510 | void set_memory(Node* c, const TypePtr *tp) { set_memory(c,C->get_alias_index(tp)); } | |||
511 | void set_memory(Node* c, Node* adr) { set_memory(c,_gvn.type(adr)->is_ptr()); } | |||
512 | ||||
513 | // Get the entire memory state (probably a MergeMemNode), and reset it | |||
514 | // (The resetting prevents somebody from using the dangling Node pointer.) | |||
515 | Node* reset_memory(); | |||
516 | ||||
517 | // Get the entire memory state, asserted to be a MergeMemNode. | |||
518 | MergeMemNode* merged_memory() { | |||
519 | Node* mem = map_not_null()->memory(); | |||
520 | assert(mem->is_MergeMem(), "parse memory is always pre-split")do { if (!(mem->is_MergeMem())) { (*g_assert_poison) = 'X' ;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/graphKit.hpp" , 520, "assert(" "mem->is_MergeMem()" ") failed", "parse memory is always pre-split" ); ::breakpoint(); } } while (0); | |||
521 | return mem->as_MergeMem(); | |||
522 | } | |||
523 | ||||
524 | // Set the entire memory state; produce a new MergeMemNode. | |||
525 | void set_all_memory(Node* newmem); | |||
526 | ||||
527 | // Create a memory projection from the call, then set_all_memory. | |||
528 | void set_all_memory_call(Node* call, bool separate_io_proj = false); | |||
529 | ||||
530 | // Create a LoadNode, reading from the parser's memory state. | |||
531 | // (Note: require_atomic_access is useful only with T_LONG.) | |||
532 | // | |||
533 | // We choose the unordered semantics by default because we have | |||
534 | // adapted the `do_put_xxx' and `do_get_xxx' procedures for the case | |||
535 | // of volatile fields. | |||
536 | Node* make_load(Node* ctl, Node* adr, const Type* t, BasicType bt, | |||
537 | MemNode::MemOrd mo, LoadNode::ControlDependency control_dependency = LoadNode::DependsOnlyOnTest, | |||
538 | bool require_atomic_access = false, bool unaligned = false, | |||
539 | bool mismatched = false, bool unsafe = false, uint8_t barrier_data = 0) { | |||
540 | // This version computes alias_index from bottom_type | |||
541 | return make_load(ctl, adr, t, bt, adr->bottom_type()->is_ptr(), | |||
542 | mo, control_dependency, require_atomic_access, | |||
543 | unaligned, mismatched, unsafe, barrier_data); | |||
544 | } | |||
545 | Node* make_load(Node* ctl, Node* adr, const Type* t, BasicType bt, const TypePtr* adr_type, | |||
546 | MemNode::MemOrd mo, LoadNode::ControlDependency control_dependency = LoadNode::DependsOnlyOnTest, | |||
547 | bool require_atomic_access = false, bool unaligned = false, | |||
548 | bool mismatched = false, bool unsafe = false, uint8_t barrier_data = 0) { | |||
549 | // This version computes alias_index from an address type | |||
550 | assert(adr_type != NULL, "use other make_load factory")do { if (!(adr_type != __null)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/graphKit.hpp" , 550, "assert(" "adr_type != __null" ") failed", "use other make_load factory" ); ::breakpoint(); } } while (0); | |||
551 | return make_load(ctl, adr, t, bt, C->get_alias_index(adr_type), | |||
552 | mo, control_dependency, require_atomic_access, | |||
553 | unaligned, mismatched, unsafe, barrier_data); | |||
554 | } | |||
555 | // This is the base version which is given an alias index. | |||
556 | Node* make_load(Node* ctl, Node* adr, const Type* t, BasicType bt, int adr_idx, | |||
557 | MemNode::MemOrd mo, LoadNode::ControlDependency control_dependency = LoadNode::DependsOnlyOnTest, | |||
558 | bool require_atomic_access = false, bool unaligned = false, | |||
559 | bool mismatched = false, bool unsafe = false, uint8_t barrier_data = 0); | |||
560 | ||||
561 | // Create & transform a StoreNode and store the effect into the | |||
562 | // parser's memory state. | |||
563 | // | |||
564 | // We must ensure that stores of object references will be visible | |||
565 | // only after the object's initialization. So the clients of this | |||
566 | // procedure must indicate that the store requires `release' | |||
567 | // semantics, if the stored value is an object reference that might | |||
568 | // point to a new object and may become externally visible. | |||
569 | Node* store_to_memory(Node* ctl, Node* adr, Node* val, BasicType bt, | |||
570 | const TypePtr* adr_type, | |||
571 | MemNode::MemOrd mo, | |||
572 | bool require_atomic_access = false, | |||
573 | bool unaligned = false, | |||
574 | bool mismatched = false, | |||
575 | bool unsafe = false) { | |||
576 | // This version computes alias_index from an address type | |||
577 | assert(adr_type != NULL, "use other store_to_memory factory")do { if (!(adr_type != __null)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/graphKit.hpp" , 577, "assert(" "adr_type != __null" ") failed", "use other store_to_memory factory" ); ::breakpoint(); } } while (0); | |||
578 | return store_to_memory(ctl, adr, val, bt, | |||
579 | C->get_alias_index(adr_type), | |||
580 | mo, require_atomic_access, | |||
581 | unaligned, mismatched, unsafe); | |||
582 | } | |||
583 | // This is the base version which is given alias index | |||
584 | // Return the new StoreXNode | |||
585 | Node* store_to_memory(Node* ctl, Node* adr, Node* val, BasicType bt, | |||
586 | int adr_idx, | |||
587 | MemNode::MemOrd, | |||
588 | bool require_atomic_access = false, | |||
589 | bool unaligned = false, | |||
590 | bool mismatched = false, | |||
591 | bool unsafe = false); | |||
592 | ||||
593 | // Perform decorated accesses | |||
594 | ||||
595 | Node* access_store_at(Node* obj, // containing obj | |||
596 | Node* adr, // actual adress to store val at | |||
597 | const TypePtr* adr_type, | |||
598 | Node* val, | |||
599 | const Type* val_type, | |||
600 | BasicType bt, | |||
601 | DecoratorSet decorators); | |||
602 | ||||
603 | Node* access_load_at(Node* obj, // containing obj | |||
604 | Node* adr, // actual adress to load val at | |||
605 | const TypePtr* adr_type, | |||
606 | const Type* val_type, | |||
607 | BasicType bt, | |||
608 | DecoratorSet decorators); | |||
609 | ||||
610 | Node* access_load(Node* adr, // actual adress to load val at | |||
611 | const Type* val_type, | |||
612 | BasicType bt, | |||
613 | DecoratorSet decorators); | |||
614 | ||||
615 | Node* access_atomic_cmpxchg_val_at(Node* obj, | |||
616 | Node* adr, | |||
617 | const TypePtr* adr_type, | |||
618 | int alias_idx, | |||
619 | Node* expected_val, | |||
620 | Node* new_val, | |||
621 | const Type* value_type, | |||
622 | BasicType bt, | |||
623 | DecoratorSet decorators); | |||
624 | ||||
625 | Node* access_atomic_cmpxchg_bool_at(Node* obj, | |||
626 | Node* adr, | |||
627 | const TypePtr* adr_type, | |||
628 | int alias_idx, | |||
629 | Node* expected_val, | |||
630 | Node* new_val, | |||
631 | const Type* value_type, | |||
632 | BasicType bt, | |||
633 | DecoratorSet decorators); | |||
634 | ||||
635 | Node* access_atomic_xchg_at(Node* obj, | |||
636 | Node* adr, | |||
637 | const TypePtr* adr_type, | |||
638 | int alias_idx, | |||
639 | Node* new_val, | |||
640 | const Type* value_type, | |||
641 | BasicType bt, | |||
642 | DecoratorSet decorators); | |||
643 | ||||
644 | Node* access_atomic_add_at(Node* obj, | |||
645 | Node* adr, | |||
646 | const TypePtr* adr_type, | |||
647 | int alias_idx, | |||
648 | Node* new_val, | |||
649 | const Type* value_type, | |||
650 | BasicType bt, | |||
651 | DecoratorSet decorators); | |||
652 | ||||
653 | void access_clone(Node* src, Node* dst, Node* size, bool is_array); | |||
654 | ||||
655 | // Return addressing for an array element. | |||
656 | Node* array_element_address(Node* ary, Node* idx, BasicType elembt, | |||
657 | // Optional constraint on the array size: | |||
658 | const TypeInt* sizetype = NULL__null, | |||
659 | // Optional control dependency (for example, on range check) | |||
660 | Node* ctrl = NULL__null); | |||
661 | ||||
662 | // Return a load of array element at idx. | |||
663 | Node* load_array_element(Node* ary, Node* idx, const TypeAryPtr* arytype, bool set_ctrl); | |||
664 | ||||
665 | //---------------- Dtrace support -------------------- | |||
666 | void make_dtrace_method_entry_exit(ciMethod* method, bool is_entry); | |||
667 | void make_dtrace_method_entry(ciMethod* method) { | |||
668 | make_dtrace_method_entry_exit(method, true); | |||
669 | } | |||
670 | void make_dtrace_method_exit(ciMethod* method) { | |||
671 | make_dtrace_method_entry_exit(method, false); | |||
672 | } | |||
673 | ||||
674 | //--------------- stub generation ------------------- | |||
675 | public: | |||
676 | void gen_stub(address C_function, | |||
677 | const char *name, | |||
678 | int is_fancy_jump, | |||
679 | bool pass_tls, | |||
680 | bool return_pc); | |||
681 | ||||
682 | //---------- help for generating calls -------------- | |||
683 | ||||
684 | // Do a null check on the receiver as it would happen before the call to | |||
685 | // callee (with all arguments still on the stack). | |||
686 | Node* null_check_receiver_before_call(ciMethod* callee) { | |||
687 | assert(!callee->is_static(), "must be a virtual method")do { if (!(!callee->is_static())) { (*g_assert_poison) = 'X' ;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/opto/graphKit.hpp" , 687, "assert(" "!callee->is_static()" ") failed", "must be a virtual method" ); ::breakpoint(); } } while (0); | |||
688 | // Callsite signature can be different from actual method being called (i.e _linkTo* sites). | |||
689 | // Use callsite signature always. | |||
690 | ciMethod* declared_method = method()->get_method_at_bci(bci()); | |||
691 | const int nargs = declared_method->arg_size(); | |||
692 | inc_sp(nargs); | |||
693 | Node* n = null_check_receiver(); | |||
694 | dec_sp(nargs); | |||
695 | return n; | |||
696 | } | |||
697 | ||||
698 | // Fill in argument edges for the call from argument(0), argument(1), ... | |||
699 | // (The next step is to call set_edges_for_java_call.) | |||
700 | void set_arguments_for_java_call(CallJavaNode* call); | |||
701 | ||||
702 | // Fill in non-argument edges for the call. | |||
703 | // Transform the call, and update the basics: control, i_o, memory. | |||
704 | // (The next step is usually to call set_results_for_java_call.) | |||
705 | void set_edges_for_java_call(CallJavaNode* call, | |||
706 | bool must_throw = false, bool separate_io_proj = false); | |||
707 | ||||
708 | // Finish up a java call that was started by set_edges_for_java_call. | |||
709 | // Call add_exception on any throw arising from the call. | |||
710 | // Return the call result (transformed). | |||
711 | Node* set_results_for_java_call(CallJavaNode* call, bool separate_io_proj = false, bool deoptimize = false); | |||
712 | ||||
713 | // Similar to set_edges_for_java_call, but simplified for runtime calls. | |||
714 | void set_predefined_output_for_runtime_call(Node* call) { | |||
715 | set_predefined_output_for_runtime_call(call, NULL__null, NULL__null); | |||
716 | } | |||
717 | void set_predefined_output_for_runtime_call(Node* call, | |||
718 | Node* keep_mem, | |||
719 | const TypePtr* hook_mem); | |||
720 | Node* set_predefined_input_for_runtime_call(SafePointNode* call, Node* narrow_mem = NULL__null); | |||
721 | ||||
722 | // Replace the call with the current state of the kit. Requires | |||
723 | // that the call was generated with separate io_projs so that | |||
724 | // exceptional control flow can be handled properly. | |||
725 | void replace_call(CallNode* call, Node* result, bool do_replaced_nodes = false); | |||
726 | ||||
727 | // helper functions for statistics | |||
728 | void increment_counter(address counter_addr); // increment a debug counter | |||
729 | void increment_counter(Node* counter_addr); // increment a debug counter | |||
730 | ||||
731 | // Bail out to the interpreter right now | |||
732 | // The optional klass is the one causing the trap. | |||
733 | // The optional reason is debug information written to the compile log. | |||
734 | // Optional must_throw is the same as with add_safepoint_edges. | |||
735 | void uncommon_trap(int trap_request, | |||
736 | ciKlass* klass = NULL__null, const char* reason_string = NULL__null, | |||
737 | bool must_throw = false, bool keep_exact_action = false); | |||
738 | ||||
739 | // Shorthand, to avoid saying "Deoptimization::" so many times. | |||
740 | void uncommon_trap(Deoptimization::DeoptReason reason, | |||
741 | Deoptimization::DeoptAction action, | |||
742 | ciKlass* klass = NULL__null, const char* reason_string = NULL__null, | |||
743 | bool must_throw = false, bool keep_exact_action = false) { | |||
744 | uncommon_trap(Deoptimization::make_trap_request(reason, action), | |||
745 | klass, reason_string, must_throw, keep_exact_action); | |||
746 | } | |||
747 | ||||
748 | // Bail out to the interpreter and keep exact action (avoid switching to Action_none). | |||
749 | void uncommon_trap_exact(Deoptimization::DeoptReason reason, | |||
750 | Deoptimization::DeoptAction action, | |||
751 | ciKlass* klass = NULL__null, const char* reason_string = NULL__null, | |||
752 | bool must_throw = false) { | |||
753 | uncommon_trap(Deoptimization::make_trap_request(reason, action), | |||
754 | klass, reason_string, must_throw, /*keep_exact_action=*/true); | |||
755 | } | |||
756 | ||||
757 | // SP when bytecode needs to be reexecuted. | |||
758 | virtual int reexecute_sp() { return sp(); } | |||
759 | ||||
760 | // Report if there were too many traps at the current method and bci. | |||
761 | // Report if a trap was recorded, and/or PerMethodTrapLimit was exceeded. | |||
762 | // If there is no MDO at all, report no trap unless told to assume it. | |||
763 | bool too_many_traps(Deoptimization::DeoptReason reason) { | |||
764 | return C->too_many_traps(method(), bci(), reason); | |||
765 | } | |||
766 | ||||
767 | // Report if there were too many recompiles at the current method and bci. | |||
768 | bool too_many_recompiles(Deoptimization::DeoptReason reason) { | |||
769 | return C->too_many_recompiles(method(), bci(), reason); | |||
770 | } | |||
771 | ||||
772 | bool too_many_traps_or_recompiles(Deoptimization::DeoptReason reason) { | |||
773 | return C->too_many_traps_or_recompiles(method(), bci(), reason); | |||
774 | } | |||
775 | ||||
776 | // Returns the object (if any) which was created the moment before. | |||
777 | Node* just_allocated_object(Node* current_control); | |||
778 | ||||
779 | // Sync Ideal and Graph kits. | |||
780 | void sync_kit(IdealKit& ideal); | |||
781 | void final_sync(IdealKit& ideal); | |||
782 | ||||
783 | public: | |||
784 | // Helper function to round double arguments before a call | |||
785 | void round_double_arguments(ciMethod* dest_method); | |||
786 | ||||
787 | // rounding for strict float precision conformance | |||
788 | Node* precision_rounding(Node* n); | |||
789 | ||||
790 | // rounding for strict double precision conformance | |||
791 | Node* dprecision_rounding(Node* n); | |||
792 | ||||
793 | // rounding for non-strict double stores | |||
794 | Node* dstore_rounding(Node* n); | |||
795 | ||||
796 | // Helper functions for fast/slow path codes | |||
797 | Node* opt_iff(Node* region, Node* iff); | |||
798 | Node* make_runtime_call(int flags, | |||
799 | const TypeFunc* call_type, address call_addr, | |||
800 | const char* call_name, | |||
801 | const TypePtr* adr_type, // NULL if no memory effects | |||
802 | Node* parm0 = NULL__null, Node* parm1 = NULL__null, | |||
803 | Node* parm2 = NULL__null, Node* parm3 = NULL__null, | |||
804 | Node* parm4 = NULL__null, Node* parm5 = NULL__null, | |||
805 | Node* parm6 = NULL__null, Node* parm7 = NULL__null, | |||
806 | Node* parm8 = NULL__null); | |||
807 | ||||
808 | Node* sign_extend_byte(Node* in); | |||
809 | Node* sign_extend_short(Node* in); | |||
810 | ||||
811 | Node* make_native_call(address call_addr, const TypeFunc* call_type, uint nargs, ciNativeEntryPoint* nep); | |||
812 | ||||
813 | enum { // flag values for make_runtime_call | |||
814 | RC_NO_FP = 1, // CallLeafNoFPNode | |||
815 | RC_NO_IO = 2, // do not hook IO edges | |||
816 | RC_NO_LEAF = 4, // CallStaticJavaNode | |||
817 | RC_MUST_THROW = 8, // flag passed to add_safepoint_edges | |||
818 | RC_NARROW_MEM = 16, // input memory is same as output | |||
819 | RC_UNCOMMON = 32, // freq. expected to be like uncommon trap | |||
820 | RC_VECTOR = 64, // CallLeafVectorNode | |||
821 | RC_LEAF = 0 // null value: no flags set | |||
822 | }; | |||
823 | ||||
824 | // merge in all memory slices from new_mem, along the given path | |||
825 | void merge_memory(Node* new_mem, Node* region, int new_path); | |||
826 | void make_slow_call_ex(Node* call, ciInstanceKlass* ex_klass, bool separate_io_proj, bool deoptimize = false); | |||
827 | ||||
828 | // Helper functions to build synchronizations | |||
829 | int next_monitor(); | |||
830 | Node* insert_mem_bar(int opcode, Node* precedent = NULL__null); | |||
831 | Node* insert_mem_bar_volatile(int opcode, int alias_idx, Node* precedent = NULL__null); | |||
832 | // Optional 'precedent' is appended as an extra edge, to force ordering. | |||
833 | FastLockNode* shared_lock(Node* obj); | |||
834 | void shared_unlock(Node* box, Node* obj); | |||
835 | ||||
836 | // helper functions for the fast path/slow path idioms | |||
837 | Node* fast_and_slow(Node* in, const Type *result_type, Node* null_result, IfNode* fast_test, Node* fast_result, address slow_call, const TypeFunc *slow_call_type, Node* slow_arg, Klass* ex_klass, Node* slow_result); | |||
838 | ||||
839 | // Generate an instance-of idiom. Used by both the instance-of bytecode | |||
840 | // and the reflective instance-of call. | |||
841 | Node* gen_instanceof(Node *subobj, Node* superkls, bool safe_for_replace = false); | |||
842 | ||||
843 | // Generate a check-cast idiom. Used by both the check-cast bytecode | |||
844 | // and the array-store bytecode | |||
845 | Node* gen_checkcast( Node *subobj, Node* superkls, | |||
846 | Node* *failure_control = NULL__null ); | |||
847 | ||||
848 | Node* gen_subtype_check(Node* obj, Node* superklass); | |||
849 | ||||
850 | // Exact type check used for predicted calls and casts. | |||
851 | // Rewrites (*casted_receiver) to be casted to the stronger type. | |||
852 | // (Caller is responsible for doing replace_in_map.) | |||
853 | Node* type_check_receiver(Node* receiver, ciKlass* klass, float prob, | |||
854 | Node* *casted_receiver); | |||
855 | ||||
856 | // Inexact type check used for predicted calls. | |||
857 | Node* subtype_check_receiver(Node* receiver, ciKlass* klass, | |||
858 | Node** casted_receiver); | |||
859 | ||||
860 | // implementation of object creation | |||
861 | Node* set_output_for_allocation(AllocateNode* alloc, | |||
862 | const TypeOopPtr* oop_type, | |||
863 | bool deoptimize_on_exception=false); | |||
864 | Node* get_layout_helper(Node* klass_node, jint& constant_value); | |||
865 | Node* new_instance(Node* klass_node, | |||
866 | Node* slow_test = NULL__null, | |||
867 | Node* *return_size_val = NULL__null, | |||
868 | bool deoptimize_on_exception = false); | |||
869 | Node* new_array(Node* klass_node, Node* count_val, int nargs, | |||
870 | Node* *return_size_val = NULL__null, | |||
871 | bool deoptimize_on_exception = false); | |||
872 | ||||
873 | // java.lang.String helpers | |||
874 | Node* load_String_length(Node* str, bool set_ctrl); | |||
875 | Node* load_String_value(Node* str, bool set_ctrl); | |||
876 | Node* load_String_coder(Node* str, bool set_ctrl); | |||
877 | void store_String_value(Node* str, Node* value); | |||
878 | void store_String_coder(Node* str, Node* value); | |||
879 | Node* capture_memory(const TypePtr* src_type, const TypePtr* dst_type); | |||
880 | Node* compress_string(Node* src, const TypeAryPtr* src_type, Node* dst, Node* count); | |||
881 | void inflate_string(Node* src, Node* dst, const TypeAryPtr* dst_type, Node* count); | |||
882 | void inflate_string_slow(Node* src, Node* dst, Node* start, Node* count); | |||
883 | ||||
884 | // Handy for making control flow | |||
885 | IfNode* create_and_map_if(Node* ctrl, Node* tst, float prob, float cnt) { | |||
886 | IfNode* iff = new IfNode(ctrl, tst, prob, cnt);// New IfNode's | |||
887 | _gvn.set_type(iff, iff->Value(&_gvn)); // Value may be known at parse-time | |||
888 | // Place 'if' on worklist if it will be in graph | |||
889 | if (!tst->is_Con()) record_for_igvn(iff); // Range-check and Null-check removal is later | |||
890 | return iff; | |||
891 | } | |||
892 | ||||
893 | IfNode* create_and_xform_if(Node* ctrl, Node* tst, float prob, float cnt) { | |||
894 | IfNode* iff = new IfNode(ctrl, tst, prob, cnt);// New IfNode's | |||
895 | _gvn.transform(iff); // Value may be known at parse-time | |||
896 | // Place 'if' on worklist if it will be in graph | |||
897 | if (!tst->is_Con()) record_for_igvn(iff); // Range-check and Null-check removal is later | |||
898 | return iff; | |||
899 | } | |||
900 | ||||
901 | void add_empty_predicates(int nargs = 0); | |||
902 | void add_empty_predicate_impl(Deoptimization::DeoptReason reason, int nargs); | |||
903 | ||||
904 | Node* make_constant_from_field(ciField* field, Node* obj); | |||
905 | ||||
906 | // Vector API support (implemented in vectorIntrinsics.cpp) | |||
907 | Node* box_vector(Node* in, const TypeInstPtr* vbox_type, BasicType elem_bt, int num_elem, bool deoptimize_on_exception = false); | |||
908 | Node* unbox_vector(Node* in, const TypeInstPtr* vbox_type, BasicType elem_bt, int num_elem, bool shuffle_to_vector = false); | |||
909 | Node* vector_shift_count(Node* cnt, int shift_op, BasicType bt, int num_elem); | |||
910 | }; | |||
911 | ||||
912 | // Helper class to support building of control flow branches. Upon | |||
913 | // creation the map and sp at bci are cloned and restored upon de- | |||
914 | // struction. Typical use: | |||
915 | // | |||
916 | // { PreserveJVMState pjvms(this); | |||
917 | // // code of new branch | |||
918 | // } | |||
919 | // // here the JVM state at bci is established | |||
920 | ||||
921 | class PreserveJVMState: public StackObj { | |||
922 | protected: | |||
923 | GraphKit* _kit; | |||
924 | #ifdef ASSERT1 | |||
925 | int _block; // PO of current block, if a Parse | |||
926 | int _bci; | |||
927 | #endif | |||
928 | SafePointNode* _map; | |||
929 | uint _sp; | |||
930 | ||||
931 | public: | |||
932 | PreserveJVMState(GraphKit* kit, bool clone_map = true); | |||
933 | ~PreserveJVMState(); | |||
934 | }; | |||
935 | ||||
936 | // Helper class to build cutouts of the form if (p) ; else {x...}. | |||
937 | // The code {x...} must not fall through. | |||
938 | // The kit's main flow of control is set to the "then" continuation of if(p). | |||
939 | class BuildCutout: public PreserveJVMState { | |||
940 | public: | |||
941 | BuildCutout(GraphKit* kit, Node* p, float prob, float cnt = COUNT_UNKNOWN(-1.0f)); | |||
942 | ~BuildCutout(); | |||
943 | }; | |||
944 | ||||
945 | // Helper class to preserve the original _reexecute bit and _sp and restore | |||
946 | // them back | |||
947 | class PreserveReexecuteState: public StackObj { | |||
948 | protected: | |||
949 | GraphKit* _kit; | |||
950 | uint _sp; | |||
951 | JVMState::ReexecuteState _reexecute; | |||
952 | ||||
953 | public: | |||
954 | PreserveReexecuteState(GraphKit* kit); | |||
955 | ~PreserveReexecuteState(); | |||
956 | }; | |||
957 | ||||
958 | #endif // SHARE_OPTO_GRAPHKIT_HPP |