1 /*
2 * Copyright (c) 1997, 2019, 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 *
1359 assert(caller_nm->is_alive() && !caller_nm->is_unloading(), "It should be alive");
1360
1361 #ifndef PRODUCT
1362 // tracing/debugging/statistics
1363 int *addr = (is_optimized) ? (&_resolve_opt_virtual_ctr) :
1364 (is_virtual) ? (&_resolve_virtual_ctr) :
1365 (&_resolve_static_ctr);
1366 Atomic::inc(addr);
1367
1368 if (TraceCallFixup) {
1369 ResourceMark rm(thread);
1370 tty->print("resolving %s%s (%s) call to",
1371 (is_optimized) ? "optimized " : "", (is_virtual) ? "virtual" : "static",
1372 Bytecodes::name(invoke_code));
1373 callee_method->print_short_name(tty);
1374 tty->print_cr(" at pc: " INTPTR_FORMAT " to code: " INTPTR_FORMAT,
1375 p2i(caller_frame.pc()), p2i(callee_method->code()));
1376 }
1377 #endif
1378
1379 // Do not patch call site for static call to another class
1380 // when the class is not fully initialized.
1381 if (invoke_code == Bytecodes::_invokestatic) {
1382 if (!callee_method->method_holder()->is_initialized() &&
1383 callee_method->method_holder() != caller_nm->method()->method_holder()) {
1384 assert(callee_method->method_holder()->is_linked(), "must be");
1385 return callee_method;
1386 } else {
1387 assert(callee_method->method_holder()->is_initialized() ||
1388 callee_method->method_holder()->is_reentrant_initialization(thread),
1389 "invalid class initialization state for invoke_static");
1390 }
1391 }
1392
1393 // JSR 292 key invariant:
1394 // If the resolved method is a MethodHandle invoke target, the call
1395 // site must be a MethodHandle call site, because the lambda form might tail-call
1396 // leaving the stack in a state unknown to either caller or callee
1397 // TODO detune for now but we might need it again
1398 // assert(!callee_method->is_compiled_lambda_form() ||
1399 // caller_nm->is_method_handle_return(caller_frame.pc()), "must be MH call site");
1400
1401 // Compute entry points. This might require generation of C2I converter
1402 // frames, so we cannot be holding any locks here. Furthermore, the
1403 // computation of the entry points is independent of patching the call. We
1404 // always return the entry-point, but we only patch the stub if the call has
1405 // not been deoptimized. Return values: For a virtual call this is an
1406 // (cached_oop, destination address) pair. For a static call/optimized
1407 // virtual this is just a destination address.
1408
1409 // Patching IC caches may fail if we run out if transition stubs.
1410 // We refill the ic stubs then and try again.
|
1 /*
2 * Copyright (c) 1997, 2018, 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 *
1359 assert(caller_nm->is_alive() && !caller_nm->is_unloading(), "It should be alive");
1360
1361 #ifndef PRODUCT
1362 // tracing/debugging/statistics
1363 int *addr = (is_optimized) ? (&_resolve_opt_virtual_ctr) :
1364 (is_virtual) ? (&_resolve_virtual_ctr) :
1365 (&_resolve_static_ctr);
1366 Atomic::inc(addr);
1367
1368 if (TraceCallFixup) {
1369 ResourceMark rm(thread);
1370 tty->print("resolving %s%s (%s) call to",
1371 (is_optimized) ? "optimized " : "", (is_virtual) ? "virtual" : "static",
1372 Bytecodes::name(invoke_code));
1373 callee_method->print_short_name(tty);
1374 tty->print_cr(" at pc: " INTPTR_FORMAT " to code: " INTPTR_FORMAT,
1375 p2i(caller_frame.pc()), p2i(callee_method->code()));
1376 }
1377 #endif
1378
1379 // Do not patch call site for static call when the class is not
1380 // fully initialized.
1381 if (invoke_code == Bytecodes::_invokestatic &&
1382 !callee_method->method_holder()->is_initialized()) {
1383 assert(callee_method->method_holder()->is_linked(), "must be");
1384 return callee_method;
1385 }
1386
1387 // JSR 292 key invariant:
1388 // If the resolved method is a MethodHandle invoke target, the call
1389 // site must be a MethodHandle call site, because the lambda form might tail-call
1390 // leaving the stack in a state unknown to either caller or callee
1391 // TODO detune for now but we might need it again
1392 // assert(!callee_method->is_compiled_lambda_form() ||
1393 // caller_nm->is_method_handle_return(caller_frame.pc()), "must be MH call site");
1394
1395 // Compute entry points. This might require generation of C2I converter
1396 // frames, so we cannot be holding any locks here. Furthermore, the
1397 // computation of the entry points is independent of patching the call. We
1398 // always return the entry-point, but we only patch the stub if the call has
1399 // not been deoptimized. Return values: For a virtual call this is an
1400 // (cached_oop, destination address) pair. For a static call/optimized
1401 // virtual this is just a destination address.
1402
1403 // Patching IC caches may fail if we run out if transition stubs.
1404 // We refill the ic stubs then and try again.
|