From e68eac9c36ac6afaf711f7fd60dab4be5a31bf86 Mon Sep 17 00:00:00 2001 From: Per Liden Date: Thu, 28 Jan 2021 07:58:50 +0000 Subject: [PATCH 01/77] 8259765: ZGC: Handle incorrect processor id reported by the operating system Reviewed-by: ayang, eosterlund --- src/hotspot/os/linux/os_linux.cpp | 43 +++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp index 78ad6492c0594..f1bd6135b6421 100644 --- a/src/hotspot/os/linux/os_linux.cpp +++ b/src/hotspot/os/linux/os_linux.cpp @@ -4746,19 +4746,46 @@ int os::active_processor_count() { return active_cpus; } +static bool should_warn_invalid_processor_id() { + if (os::processor_count() == 1) { + // Don't warn if we only have one processor + return false; + } + + static volatile int warn_once = 1; + + if (Atomic::load(&warn_once) == 0 || + Atomic::xchg(&warn_once, 0) == 0) { + // Don't warn more than once + return false; + } + + return true; +} + uint os::processor_id() { const int id = Linux::sched_getcpu(); -#ifndef PRODUCT - if (UseDebuggerErgo1 && id >= _processor_count) { - // Some debuggers limit the processor count without limiting - // the returned processor ids. Fake the processor id. - return 0; + if (id < processor_count()) { + return (uint)id; + } + + // Some environments (e.g. openvz containers and the rr debugger) incorrectly + // report a processor id that is higher than the number of processors available. + // This is problematic, for example, when implementing CPU-local data structures, + // where the processor id is used to index into an array of length processor_count(). + // If this happens we return 0 here. This is is safe since we always have at least + // one processor, but it's not optimal for performance if we're actually executing + // in an environment with more than one processor. + if (should_warn_invalid_processor_id()) { + log_warning(os)("Invalid processor id reported by the operating system " + "(got processor id %d, valid processor id range is 0-%d)", + id, processor_count() - 1); + log_warning(os)("Falling back to assuming processor id is 0. " + "This could have a negative impact on performance."); } -#endif - assert(id >= 0 && id < _processor_count, "Invalid processor id [%d]", id); - return (uint)id; + return 0; } void os::set_native_thread_name(const char *name) { From 1926765f5e79bfc8db762823c412cf9769ae28eb Mon Sep 17 00:00:00 2001 From: Vladimir Kozlov Date: Thu, 28 Jan 2021 16:16:51 +0000 Subject: [PATCH 02/77] 8253353: Crash in C2: guarantee(n != NULL) failed: No Node Co-authored-by: Fei Yang Reviewed-by: vlivanov, neliasso --- src/hotspot/share/opto/loopnode.cpp | 2 + src/hotspot/share/opto/loopnode.hpp | 2 +- .../loopopts/TestNestedIrreducibleLoops.jasm | 1939 +++++++++++++++++ .../TestNestedIrreducibleLoopsMain.java | 45 + 4 files changed, 1987 insertions(+), 1 deletion(-) create mode 100644 test/hotspot/jtreg/compiler/loopopts/TestNestedIrreducibleLoops.jasm create mode 100644 test/hotspot/jtreg/compiler/loopopts/TestNestedIrreducibleLoopsMain.java diff --git a/src/hotspot/share/opto/loopnode.cpp b/src/hotspot/share/opto/loopnode.cpp index 47e4986d4997b..f582bc831ca8c 100644 --- a/src/hotspot/share/opto/loopnode.cpp +++ b/src/hotspot/share/opto/loopnode.cpp @@ -291,6 +291,7 @@ IdealLoopTree* PhaseIdealLoop::insert_outer_loop(IdealLoopTree* loop, LoopNode* loop->_parent = outer_ilt; loop->_next = NULL; loop->_nest++; + assert(loop->_nest <= SHRT_MAX, "sanity"); return outer_ilt; } @@ -2614,6 +2615,7 @@ bool IdealLoopTree::is_member(const IdealLoopTree *l) const { //------------------------------set_nest--------------------------------------- // Set loop tree nesting depth. Accumulate _has_call bits. int IdealLoopTree::set_nest( uint depth ) { + assert(depth <= SHRT_MAX, "sanity"); _nest = depth; int bits = _has_call; if( _child ) bits |= _child->set_nest(depth+1); diff --git a/src/hotspot/share/opto/loopnode.hpp b/src/hotspot/share/opto/loopnode.hpp index 68903e4b97d7b..b352282bf06ca 100644 --- a/src/hotspot/share/opto/loopnode.hpp +++ b/src/hotspot/share/opto/loopnode.hpp @@ -611,7 +611,7 @@ class IdealLoopTree : public ResourceObj { Node_List _body; // Loop body for inner loops - uint8_t _nest; // Nesting depth + uint16_t _nest; // Nesting depth uint8_t _irreducible:1, // True if irreducible _has_call:1, // True if has call safepoint _has_sfpt:1, // True if has non-call safepoint diff --git a/test/hotspot/jtreg/compiler/loopopts/TestNestedIrreducibleLoops.jasm b/test/hotspot/jtreg/compiler/loopopts/TestNestedIrreducibleLoops.jasm new file mode 100644 index 0000000000000..ad79289ded4ac --- /dev/null +++ b/test/hotspot/jtreg/compiler/loopopts/TestNestedIrreducibleLoops.jasm @@ -0,0 +1,1939 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +super public class TestNestedIrreducibleLoops + version 45:3 +{ + Field loopCounter:I; + Field start:I; + + public Method "":"()V" + stack 1 locals 1 + { + aload_0; + invokespecial Method java/lang/Object."":"()V"; + return; + } + static Method addi:"(I)I" + stack 2 locals 1 + { + iload_0; + iconst_1; + iadd; + ireturn; + } + Method test:"()I" + stack 2 locals 8 + { + iconst_0; + istore_1; + iconst_0; + istore_2; + iconst_0; + istore_3; + iconst_m1; + istore 5; + iconst_2; + istore 6; + aload_0; + getfield Field start:"I"; + ifne L3135; + goto L31; + L22: iinc 2, 1; + iload_2; + iload 6; + if_icmpgt L3135; + L31: iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpeq L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmplt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iload_1; + iconst_3; + if_icmpgt L3135; + iconst_0; + istore 7; + L3084: iload 7; + iload 6; + if_icmpge L3104; + iload_1; + invokestatic Method addi:"(I)I"; + ifeq L3104; + iinc 7, 1; + goto L3084; + L3104: iload_1; + iload 6; + if_icmpge L3135; + iload_1; + invokestatic Method addi:"(I)I"; + bipush 84; + if_icmpne L3135; + iload_1; + bipush 88; + iadd; + iload 6; + if_icmpge L3135; + iconst_1; + ireturn; + L3130: iload 5; + iflt L3153; + L3135: iload_1; + invokestatic Method addi:"(I)I"; + istore_1; + iinc 3, 1; + iload_3; + aload_0; + getfield Field loopCounter:"I"; + if_icmplt L3130; + iconst_0; + ireturn; + L3153: iload 5; + iflt L22; + iconst_0; + ireturn; + } + +} // end Class TestNestedIrreducibleLoops diff --git a/test/hotspot/jtreg/compiler/loopopts/TestNestedIrreducibleLoopsMain.java b/test/hotspot/jtreg/compiler/loopopts/TestNestedIrreducibleLoopsMain.java new file mode 100644 index 0000000000000..65b26bf76c193 --- /dev/null +++ b/test/hotspot/jtreg/compiler/loopopts/TestNestedIrreducibleLoopsMain.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8253353 + * @summary Tests custom bytecode with deep nested irreducible loops. + * + * @compile TestNestedIrreducibleLoops.jasm + * @run main/othervm -Xbatch -XX:CompileCommand=dontinline,TestNestedIrreducibleLoops::* + * -XX:CompileCommand=exclude,TestNestedIrreducibleLoopsMain::main + * TestNestedIrreducibleLoopsMain + */ + +public class TestNestedIrreducibleLoopsMain { + public static void main(String[] args) { + TestNestedIrreducibleLoops t = new TestNestedIrreducibleLoops(); + t.loopCounter = 3; + int j; + for (int i = 0; i < 11000; i++) { + t.start = i & 0x3ff; + j = t.test(); // Produces deep nested irreducible loops + } + } +} From 8ffdbcebad6c001933a90f88241c4933e449b849 Mon Sep 17 00:00:00 2001 From: Igor Ignatyev Date: Fri, 29 Jan 2021 04:04:23 +0000 Subject: [PATCH 03/77] 8260608: add a regression test for 8260370 Reviewed-by: kvn --- .../TestLoopLimitNodeElimination.java | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 test/hotspot/jtreg/compiler/loopopts/TestLoopLimitNodeElimination.java diff --git a/test/hotspot/jtreg/compiler/loopopts/TestLoopLimitNodeElimination.java b/test/hotspot/jtreg/compiler/loopopts/TestLoopLimitNodeElimination.java new file mode 100644 index 0000000000000..930d38a4e1909 --- /dev/null +++ b/test/hotspot/jtreg/compiler/loopopts/TestLoopLimitNodeElimination.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8260370 + * @summary C2: LoopLimit node is not eliminated + * + * @run main/othervm + * -Xcomp + * -XX:CompileOnly=compiler/loopopts/TestLoopLimitNodeElimination + * compiler.loopopts.TestLoopLimitNodeElimination + */ + +package compiler.loopopts; + +// the test code is derived from a randomly generated test +public class TestLoopLimitNodeElimination { + private static class MyException extends RuntimeException { } + private static final int ITERATIONS = 100000; + private static final int SIZE = 400; + + private static int counter = 0; + + int[] array1 = new int[SIZE]; + + void test() { + int[] array2 = new int[SIZE]; + array1[2] = 0; + array1 = array1; + for (long i = 301; i > 2; i -= 2) { + int j = 1; + do { + for (int k = (int) i; k < 1; k++) { } + } while (++j < 4); + } + + counter++; + if (counter == ITERATIONS) { + throw new MyException(); + } + } + + public static void main(String[] args) { + try { + var test = new TestLoopLimitNodeElimination(); + while (true) { + test.test(); + } + } catch (MyException e) { + // expected + } + } +} + From a117e11524b0ca12ff1fc80ffc99be1749156b18 Mon Sep 17 00:00:00 2001 From: Wang Huang Date: Fri, 29 Jan 2021 08:07:21 +0000 Subject: [PATCH 04/77] 8260339: JVM crashes when executing PhaseIdealLoop::match_fill_loop Co-authored-by: He Xuejin Reviewed-by: neliasso, kvn, iignatyev --- src/hotspot/share/runtime/stubRoutines.cpp | 1 + .../vectorapi/TestLoopStoreVector.java | 81 +++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 test/hotspot/jtreg/compiler/vectorapi/TestLoopStoreVector.java diff --git a/src/hotspot/share/runtime/stubRoutines.cpp b/src/hotspot/share/runtime/stubRoutines.cpp index 40e3b522d7cbb..0dd0288207a8d 100644 --- a/src/hotspot/share/runtime/stubRoutines.cpp +++ b/src/hotspot/share/runtime/stubRoutines.cpp @@ -524,6 +524,7 @@ address StubRoutines::select_fill_function(BasicType t, bool aligned, const char case T_NARROWOOP: case T_NARROWKLASS: case T_ADDRESS: + case T_VOID: // Currently unsupported return NULL; diff --git a/test/hotspot/jtreg/compiler/vectorapi/TestLoopStoreVector.java b/test/hotspot/jtreg/compiler/vectorapi/TestLoopStoreVector.java new file mode 100644 index 0000000000000..02ae56848695e --- /dev/null +++ b/test/hotspot/jtreg/compiler/vectorapi/TestLoopStoreVector.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2021, Huawei Technologies Co. Ltd. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package compiler.vectorapi; + +import jdk.incubator.vector.IntVector; +import jdk.incubator.vector.LongVector; +import jdk.incubator.vector.VectorSpecies; + +/* + * @test + * @bug 8260339 + * @summary StoreVectorNode is not considered with -XX:+OptimizeFill + * @modules jdk.incubator.vector + * + * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+OptimizeFill compiler.vectorapi.TestLoopStoreVector + */ + +public class TestLoopStoreVector { + static final VectorSpecies SPECIESi = IntVector.SPECIES_PREFERRED; + static final VectorSpecies SPECIESl = LongVector.SPECIES_PREFERRED; + + static final int INVOC_COUNT = 5000; + static final int size = 64; + + static int[] ai = {20, 21, 02, 14, 83, 119, 101, 101, 116, 121, 44, 32, + 73, 32, 76, 79, 86, 69, 32, 89, 79, 85, 32, 102, 111, + 114, 101, 118, 101, 114, 33, 32, 32, 32, 45, 45, 32, + 32, 32, 66, 121, 32, 87, 97, 110, 103, 72, 117, 97, + 110, 103,46, 76, 105, 102, 101, 32, 105, 115, 32, 116, + 104, 101, 32}; + static long[] al = {102, 108, 111, 119, 101, 114, 32, 102, 111, 114, 32, + 119, 104, 105, 99, 104, 32, 108, 111, 118, 101, 32, + 105, 115, 32, 116, 104, 101, 32, 104, 111, 110, 101, + 121, 46, 32, 87, 101, 32, 119, 105, 108, 108, 32, 115, + 116, 105, 99, 107, 32, 116, 111, 103, 101, 116, 104, + 101, 114, 32, 33, 33, 33, 33, 32}; + + public static void testVectorCastL2I(long[] input, int[] output, VectorSpecies speciesl, VectorSpecies speciesi) { + LongVector av = LongVector.fromArray(speciesl, input, 0); + IntVector bv = (IntVector) av.castShape(speciesi, 0); + bv.intoArray(output, 0); + } + + public static int test0() { + for (int i = 0; i < 1000; i++) { + testVectorCastL2I(al, ai, SPECIESl, SPECIESi); + } + return 0; + } + + public static void main(String[] args) { + for (int i = 0; i < INVOC_COUNT; i++) { + test0(); + } + for (int i = 0; i < 64; i++) { + System.out.print(ai[i] + " "); + } + System.out.println(""); + } +} From bc41bb10c77860bcd35b66006c063b4ba865df3d Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Fri, 29 Jan 2021 17:48:11 +0000 Subject: [PATCH 05/77] 8260632: Build failures after JDK-8253353 Reviewed-by: stuefe, thartmann, kvn --- src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp b/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp index 81ae22fef88a9..ef95f16610e24 100644 --- a/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp +++ b/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp @@ -2285,7 +2285,7 @@ void MemoryGraphFixer::collect_memory_nodes() { uint last = _phase->C->unique(); #ifdef ASSERT - uint8_t max_depth = 0; + uint16_t max_depth = 0; for (LoopTreeIterator iter(_phase->ltree_root()); !iter.done(); iter.next()) { IdealLoopTree* lpt = iter.current(); max_depth = MAX2(max_depth, lpt->_nest); From 0fdf9cdd3a234d363468d71f6493fbc5b687b0e4 Mon Sep 17 00:00:00 2001 From: casparcwang Date: Mon, 1 Feb 2021 01:28:31 +0000 Subject: [PATCH 06/77] 8260473: [vector] ZGC: VectorReshape test produces incorrect results with ZGC enabled Co-authored-by: Stuart Monteith Co-authored-by: Wang Chao Reviewed-by: vlivanov, neliasso --- src/hotspot/share/opto/vector.cpp | 21 ++- .../vectorapi/VectorRebracket128Test.java | 162 ++++++++++++++++++ 2 files changed, 174 insertions(+), 9 deletions(-) create mode 100644 test/hotspot/jtreg/compiler/vectorapi/VectorRebracket128Test.java diff --git a/src/hotspot/share/opto/vector.cpp b/src/hotspot/share/opto/vector.cpp index 5ccf70c2228f7..2e812b6fffa16 100644 --- a/src/hotspot/share/opto/vector.cpp +++ b/src/hotspot/share/opto/vector.cpp @@ -23,6 +23,7 @@ */ #include "precompiled.hpp" +#include "gc/shared/barrierSet.hpp" #include "opto/castnode.hpp" #include "opto/graphKit.hpp" #include "opto/phaseX.hpp" @@ -412,15 +413,17 @@ void PhaseVector::expand_vunbox_node(VectorUnboxNode* vec_unbox) { Node* mem = vec_unbox->mem(); Node* ctrl = vec_unbox->in(0); - Node* vec_field_ld = LoadNode::make(gvn, - ctrl, - mem, - vec_adr, - vec_adr->bottom_type()->is_ptr(), - TypeOopPtr::make_from_klass(field->type()->as_klass()), - T_OBJECT, - MemNode::unordered); - vec_field_ld = gvn.transform(vec_field_ld); + Node* vec_field_ld; + { + DecoratorSet decorators = MO_UNORDERED | IN_HEAP; + C2AccessValuePtr addr(vec_adr, vec_adr->bottom_type()->is_ptr()); + MergeMemNode* local_mem = MergeMemNode::make(mem); + gvn.record_for_igvn(local_mem); + BarrierSetC2* bs = BarrierSet::barrier_set()->barrier_set_c2(); + C2OptAccess access(gvn, ctrl, local_mem, decorators, T_OBJECT, obj, addr); + const Type* type = TypeOopPtr::make_from_klass(field->type()->as_klass()); + vec_field_ld = bs->load_at(access, type); + } // For proper aliasing, attach concrete payload type. ciKlass* payload_klass = ciTypeArrayKlass::make(bt); diff --git a/test/hotspot/jtreg/compiler/vectorapi/VectorRebracket128Test.java b/test/hotspot/jtreg/compiler/vectorapi/VectorRebracket128Test.java new file mode 100644 index 0000000000000..6b266db08b664 --- /dev/null +++ b/test/hotspot/jtreg/compiler/vectorapi/VectorRebracket128Test.java @@ -0,0 +1,162 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +import jdk.incubator.vector.*; +import jdk.internal.vm.annotation.ForceInline; +import org.testng.Assert; +import org.testng.annotations.Test; +import org.testng.annotations.DataProvider; + +import java.lang.invoke.MethodHandles; +import java.lang.invoke.VarHandle; +import java.nio.ByteOrder; +import java.util.Arrays; +import java.util.List; +import java.util.function.IntFunction; +import java.util.function.IntUnaryOperator; +import jdk.incubator.vector.VectorShape; +import jdk.incubator.vector.VectorSpecies; +import jdk.internal.vm.annotation.ForceInline; + +/* + * @test + * @bug 8260473 + * @requires vm.gc.Z + * @modules jdk.incubator.vector + * @modules java.base/jdk.internal.vm.annotation + * @run testng/othervm -XX:CompileCommand=compileonly,jdk/incubator/vector/ByteVector.fromByteBuffer + * -XX:-TieredCompilation -XX:CICompilerCount=1 -XX:+UseZGC -Xbatch -Xmx256m VectorRebracket128Test + */ + +@Test +public class VectorRebracket128Test { + static final int INVOC_COUNT = Integer.getInteger("jtreg.compiler.vectorapi.vectorrebracket128test.loop-iterations", 1000); + static final int NUM_ITER = 200 * INVOC_COUNT; + + static final VectorSpecies ispec128 = IntVector.SPECIES_128; + static final VectorSpecies fspec128 = FloatVector.SPECIES_128; + static final VectorSpecies lspec128 = LongVector.SPECIES_128; + static final VectorSpecies dspec128 = DoubleVector.SPECIES_128; + static final VectorSpecies bspec128 = ByteVector.SPECIES_128; + static final VectorSpecies sspec128 = ShortVector.SPECIES_128; + + static IntFunction withToString(String s, IntFunction f) { + return new IntFunction() { + @Override + public T apply(int v) { + return f.apply(v); + } + + @Override + public String toString() { + return s; + } + }; + } + + interface ToByteF { + byte apply(int i); + } + + static byte[] fill_byte(int s , ToByteF f) { + return fill_byte(new byte[s], f); + } + + static byte[] fill_byte(byte[] a, ToByteF f) { + for (int i = 0; i < a.length; i++) { + a[i] = f.apply(i); + } + return a; + } + + static final List> BYTE_GENERATORS = List.of( + withToString("byte(i)", (int s) -> { + return fill_byte(s, i -> (byte)(i+1)); + }) + ); + + @DataProvider + public Object[][] byteUnaryOpProvider() { + return BYTE_GENERATORS.stream(). + map(f -> new Object[]{f}). + toArray(Object[][]::new); + } + + static + void checkPartialResult(VectorSpecies a, VectorSpecies b, + byte[] input, byte[] output, byte[] expected, + int part, int origin) { + if (Arrays.equals(expected, output)) { + return; + } + int block; + block = Math.min(a.vectorByteSize(), b.vectorByteSize()); + + System.out.println("input: "+Arrays.toString(input)); + System.out.println("Failing with "+a+"->"+b+ + " (reinterpret)"+ + ", block=" + block + + ", part=" + part + + ", origin=" + origin); + System.out.println("expect: "+Arrays.toString(expected)); + System.out.println("output: "+Arrays.toString(output)); + Assert.assertEquals(expected, output); + } + + @ForceInline + static + void testVectorRebracket(VectorSpecies a, VectorSpecies b, byte[] input, byte[] output) { + Vector av = a.fromByteArray(input, 0, ByteOrder.nativeOrder()); + int block; + assert(input.length == output.length); + + block = Math.min(a.vectorByteSize(), b.vectorByteSize()); + if (false) + System.out.println("testing "+a+"->"+b+ + (false?" (lanewise)":" (reinterpret)")+ + ", block=" + block); + byte[] expected; + int origin; + + int part = 0; + Vector bv = av.reinterpretShape(b, part); + bv.intoByteArray(output, 0, ByteOrder.nativeOrder()); + // in-place copy, no resize + expected = input; + origin = 0; + checkPartialResult(a, b, input, output, expected, + part, origin); + + } + + @Test(dataProvider = "byteUnaryOpProvider") + static void testRebracket128(IntFunction fa) { + byte[] barr = fa.apply(128/Byte.SIZE); + byte[] bout = new byte[barr.length]; + for (int i = 0; i < NUM_ITER; i++) { + testVectorRebracket(bspec128, bspec128, barr, bout); + testVectorRebracket(bspec128, sspec128, barr, bout); + testVectorRebracket(bspec128, ispec128, barr, bout); + } + } + +} From 21f8bf4411afeb965511987bd168e2ac735f768f Mon Sep 17 00:00:00 2001 From: Erik Gahlin Date: Mon, 1 Feb 2021 05:57:08 +0000 Subject: [PATCH 07/77] 8257215: JFR: Events dropped when streaming over a chunk rotation Reviewed-by: mgronlun --- .../jdk/jfr/internal/PlatformRecording.java | 17 +++- .../classes/jdk/jfr/internal/Repository.java | 12 ++- .../jdk/jfr/internal/RepositoryChunk.java | 25 +----- .../jdk/jfr/internal/SecuritySupport.java | 7 +- .../share/classes/jdk/jfr/internal/Utils.java | 4 +- .../jdk/jfr/internal/consumer/FileAccess.java | 9 +- .../jfr/internal/consumer/OngoingStream.java | 5 +- .../internal/management/ChunkFilename.java | 90 +++++++++++++++++++ .../management/ManagementSupport.java | 8 +- .../jdk/management/jfr/DiskRepository.java | 58 +++--------- .../jdk/management/jfr/DownLoadThread.java | 7 +- .../management/jfr/RemoteRecordingStream.java | 7 +- test/jdk/ProblemList.txt | 1 - .../jdk/jdk/jfr/jmx/streaming/TestRotate.java | 2 +- 14 files changed, 167 insertions(+), 85 deletions(-) create mode 100644 src/jdk.jfr/share/classes/jdk/jfr/internal/management/ChunkFilename.java diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecording.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecording.java index 1c27a85b812a2..def3545b7461a 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecording.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecording.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,6 +41,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.Date; +import java.util.Iterator; import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; @@ -851,4 +852,18 @@ public void removeBefore(Instant timestamp) { } } + + public void removePath(SafePath path) { + synchronized (recorder) { + Iterator it = chunks.iterator(); + while (it.hasNext()) { + RepositoryChunk c = it.next(); + if (c.getFile().equals(path)) { + it.remove(); + removed(c); + return; + } + } + } + } } diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/Repository.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/Repository.java index 258b5bf52fa51..06a1748940050 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/Repository.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/Repository.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,6 +33,7 @@ import java.util.Set; import jdk.jfr.internal.SecuritySupport.SafePath; +import jdk.jfr.internal.management.ChunkFilename; public final class Repository { @@ -45,6 +46,7 @@ public final class Repository { private final Set cleanupDirectories = new HashSet<>(); private SafePath baseLocation; private SafePath repository; + private ChunkFilename chunkFilename; private Repository() { } @@ -61,6 +63,7 @@ public synchronized void setBasePath(SafePath baseLocation) throws IOException { // Probe to see if repository can be created, needed for fail fast // during JVM startup or JFR.configure this.repository = createRepository(baseLocation); + this.chunkFilename = null; try { // Remove so we don't "leak" repositories, if JFR is never started // and shutdown hook not added. @@ -84,8 +87,13 @@ synchronized RepositoryChunk newChunk(ZonedDateTime timestamp) { jvm.setRepositoryLocation(repository.toString()); SecuritySupport.setProperty(JFR_REPOSITORY_LOCATION_PROPERTY, repository.toString()); cleanupDirectories.add(repository); + chunkFilename = null; } - return new RepositoryChunk(repository, timestamp); + if (chunkFilename == null) { + chunkFilename = ChunkFilename.newPriviliged(repository.toPath()); + } + String filename = chunkFilename.next(timestamp.toLocalDateTime()); + return new RepositoryChunk(new SafePath(filename), timestamp.toInstant()); } catch (Exception e) { String errorMsg = String.format("Could not create chunk in repository %s, %s: %s", repository, e.getClass(), e.getMessage()); Logger.log(LogTag.JFR, LogLevel.ERROR, errorMsg); diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/RepositoryChunk.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/RepositoryChunk.java index 27513ef1f9f61..8ccd536a228cc 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/RepositoryChunk.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/RepositoryChunk.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,7 +47,6 @@ public int compare(RepositoryChunk c1, RepositoryChunk c2) { } }; - private final SafePath repositoryPath; private final SafePath chunkFile; private final Instant startTime; private final RandomAccessFile unFinishedRAF; @@ -56,28 +55,12 @@ public int compare(RepositoryChunk c1, RepositoryChunk c2) { private int refCount = 0; private long size; - RepositoryChunk(SafePath path, ZonedDateTime timestamp) throws Exception { - this.startTime = timestamp.toInstant(); - this.repositoryPath = path; - this.chunkFile = findFileName(repositoryPath, timestamp.toLocalDateTime()); + RepositoryChunk(SafePath path, Instant startTime) throws Exception { + this.startTime = startTime; + this.chunkFile = path; this.unFinishedRAF = SecuritySupport.createRandomAccessFile(chunkFile); } - private static SafePath findFileName(SafePath directory, LocalDateTime time) throws Exception { - String filename = Utils.formatDateTime(time); - Path p = directory.toPath().resolve(filename + FILE_EXTENSION); - for (int i = 1; i < MAX_CHUNK_NAMES; i++) { - SafePath s = new SafePath(p); - if (!SecuritySupport.exists(s)) { - return s; - } - String extendedName = String.format("%s_%02d%s", filename, i, FILE_EXTENSION); - p = directory.toPath().resolve(extendedName); - } - p = directory.toPath().resolve(filename + "_" + System.currentTimeMillis() + FILE_EXTENSION); - return new SafePath(p); - } - void finish(Instant endTime) { try { finishWithException(endTime); diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/SecuritySupport.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/SecuritySupport.java index 73b9a9fed8ceb..661d3a5b516e9 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/SecuritySupport.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/SecuritySupport.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -500,6 +500,11 @@ public long length(File f) throws IOException { public long fileSize(Path p) throws IOException { return doPrivilegedIOWithReturn( () -> Files.size(p)); } + + @Override + public boolean exists(Path p) throws IOException { + return doPrivilegedIOWithReturn( () -> Files.exists(p)); + } } diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/Utils.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/Utils.java index 49953c3ba5bee..81fa5519dfa8d 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/Utils.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/Utils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -184,7 +184,7 @@ public static String formatTimespan(Duration dValue, String separation) { // This method reduces the number of loaded classes // compared to DateTimeFormatter - static String formatDateTime(LocalDateTime time) { + public static String formatDateTime(LocalDateTime time) { StringBuilder sb = new StringBuilder(19); sb.append(time.getYear() / 100); appendPadded(sb, time.getYear() % 100, true); diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/FileAccess.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/FileAccess.java index 925725482604f..198131b61aa75 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/FileAccess.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/FileAccess.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,6 +46,8 @@ public abstract class FileAccess { public abstract long fileSize(Path p) throws IOException; + public abstract boolean exists(Path s) throws IOException; + private static class UnPrivileged extends FileAccess { @Override public RandomAccessFile openRAF(File f, String mode) throws IOException { @@ -71,5 +73,10 @@ public long length(File f) throws IOException { public long fileSize(Path p) throws IOException { return Files.size(p); } + + @Override + public boolean exists(Path p) { + return Files.exists(p); + } } } diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/OngoingStream.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/OngoingStream.java index a462bde64da1e..040bcf587b3f3 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/OngoingStream.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/OngoingStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -119,8 +119,7 @@ private byte[] readBytes() throws IOException { throw new IOException("No progress"); } startTimeNanos += header.getDurationNanos(); - Instant timestamp = Utils.epochNanosToInstant(startTimeNanos); - ManagementSupport.removeBefore(recording, timestamp); + ManagementSupport.removePath(recording, path); closeInput(); } else { header.refresh(); diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/management/ChunkFilename.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/management/ChunkFilename.java new file mode 100644 index 0000000000000..3be5b69c61b43 --- /dev/null +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/management/ChunkFilename.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.jfr.internal.management; + +import java.nio.file.Paths; +import java.nio.file.Path; +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.io.IOException; +import java.util.HashSet; +import java.util.Set; + +import jdk.jfr.internal.SecuritySupport; +import jdk.jfr.internal.SecuritySupport.SafePath; +import jdk.jfr.internal.Utils; +import jdk.jfr.internal.consumer.FileAccess; + +// Allows a remote streaming client to create chunk files +// with same naming scheme as the JVM. +public final class ChunkFilename { + private static final int MAX_CHUNK_NAMES = 100_000; + private static final String FILE_EXTENSION = ".jfr"; + + private final Path directory; + private final FileAccess fileAcess; + + private Path lastPath; + private int counter; + + public static ChunkFilename newUnpriviliged(Path directory) { + return new ChunkFilename(directory, FileAccess.UNPRIVILEGED); + } + + public static ChunkFilename newPriviliged(Path directory) { + return new ChunkFilename(directory, SecuritySupport.PRIVILEGED); + } + + private ChunkFilename(Path directory, FileAccess fileAccess) { + // Avoid malicious implementations of Path interface + this.directory = Paths.get(directory.toString()); + this.fileAcess = fileAccess; + } + + public String next(LocalDateTime time) throws IOException { + String filename = Utils.formatDateTime(time); + Path p = directory.resolve(filename + FILE_EXTENSION); + + // If less than one file per second (typically case) + if (lastPath == null || !p.equals(lastPath)) { + if (!fileAcess.exists(p)) { + counter = 1; // reset counter + lastPath = p; + return p.toString(); + } + } + + // If more than one file per second + while (counter < MAX_CHUNK_NAMES) { + String extendedName = String.format("%s_%02d%s", filename, counter, FILE_EXTENSION); + p = directory.resolve(extendedName); + counter++; + if (!fileAcess.exists(p)) { + return p.toString(); + } + } + throw new IOException("Unable to find unused filename after " + counter + " attempts"); + } +} diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/management/ManagementSupport.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/management/ManagementSupport.java index 6505364dd93fd..43e2b046b53f8 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/management/ManagementSupport.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/management/ManagementSupport.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -49,6 +49,7 @@ import jdk.jfr.internal.MetadataRepository; import jdk.jfr.internal.PlatformRecording; import jdk.jfr.internal.PrivateAccess; +import jdk.jfr.internal.SecuritySupport.SafePath; import jdk.jfr.internal.Utils; import jdk.jfr.internal.WriteableUserPath; import jdk.jfr.internal.consumer.EventDirectoryStream; @@ -141,7 +142,12 @@ public static EventSettings newEventSettings(EventSettingsModifier esm) { public static void removeBefore(Recording recording, Instant timestamp) { PlatformRecording pr = PrivateAccess.getInstance().getPlatformRecording(recording); pr.removeBefore(timestamp); + } + // Needed callback to detect when a chunk has been parsed. + public static void removePath(Recording recording, Path path) { + PlatformRecording pr = PrivateAccess.getInstance().getPlatformRecording(recording); + pr.removePath(new SafePath(path)); } // Needed callback to detect when a chunk has been parsed. diff --git a/src/jdk.management.jfr/share/classes/jdk/management/jfr/DiskRepository.java b/src/jdk.management.jfr/share/classes/jdk/management/jfr/DiskRepository.java index 0bf2a145b23f6..b6408a122cae4 100644 --- a/src/jdk.management.jfr/share/classes/jdk/management/jfr/DiskRepository.java +++ b/src/jdk.management.jfr/share/classes/jdk/management/jfr/DiskRepository.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,6 +30,7 @@ import java.nio.ByteBuffer; import java.nio.file.Files; import java.nio.file.Path; +import java.nio.file.Paths; import java.time.Duration; import java.time.Instant; import java.time.LocalDateTime; @@ -40,19 +41,20 @@ import java.util.Iterator; import java.util.Objects; +import jdk.jfr.internal.management.ChunkFilename; import jdk.jfr.internal.management.ManagementSupport; final class DiskRepository implements Closeable { final static class DiskChunk { final Path path; - final Instant startTime; + final long startTimeNanos; Instant endTime; long size; DiskChunk(Path path, long startNanos) { this.path = path; - this.startTime = ManagementSupport.epochNanosToInstant(startNanos); + this.startTimeNanos = startNanos; } } @@ -80,6 +82,7 @@ public State next() { private final boolean deleteDirectory; private final ByteBuffer buffer = ByteBuffer.allocate(256); private final Path directory; + private final ChunkFilename chunkFilename; private RandomAccessFile raf; private RandomAccessFile previousRAF; @@ -103,6 +106,7 @@ public State next() { public DiskRepository(Path path, boolean deleteDirectory) throws IOException { this.directory = path; this.deleteDirectory = deleteDirectory; + this.chunkFilename = ChunkFilename.newUnpriviliged(path); } public synchronized void write(byte[] bytes) throws IOException { @@ -295,8 +299,8 @@ private void writeCheckPointHeader() throws IOException { previousRAFstate = state; currentChunk.size = Files.size(currentChunk.path); long durationNanos = buffer.getLong(HEADER_FILE_DURATION); - Duration d = Duration.ofNanos(durationNanos); - currentChunk.endTime = currentChunk.startTime.plus(d); + long endTimeNanos = currentChunk.startTimeNanos + durationNanos; + currentChunk.endTime = ManagementSupport.epochNanosToInstant(endTimeNanos); } raf.seek(position); } @@ -325,44 +329,8 @@ private DiskChunk nextChunk() throws IOException { int nanoOfSecond = (int) (nanos % 1_000_000_000); ZoneOffset z = OffsetDateTime.now().getOffset(); LocalDateTime d = LocalDateTime.ofEpochSecond(epochSecond, nanoOfSecond, z); - String filename = formatDateTime(d); - Path p1 = directory.resolve(filename + ".jfr"); - if (!Files.exists(p1)) { - return new DiskChunk(p1, nanos); - } - for (int i = 1; i < 100; i++) { - String s = Integer.toString(i); - if (i < 10) { - s = "0" + s; - } - Path p2 = directory.resolve(filename + "_" + s + ".jfr"); - if (!Files.exists(p2)) { - return new DiskChunk(p2, nanos); - } - } - throw new IOException("Could not create chunk for path " + p1); - } - - static String formatDateTime(LocalDateTime time) { - StringBuilder sb = new StringBuilder(19); - sb.append(time.getYear() / 100); - appendPadded(sb, time.getYear() % 100, true); - appendPadded(sb, time.getMonth().getValue(), true); - appendPadded(sb, time.getDayOfMonth(), true); - appendPadded(sb, time.getHour(), true); - appendPadded(sb, time.getMinute(), true); - appendPadded(sb, time.getSecond(), false); - return sb.toString(); - } - - private static void appendPadded(StringBuilder text, int number, boolean separator) { - if (number < 10) { - text.append('0'); - } - text.append(number); - if (separator) { - text.append('_'); - } + String filename = chunkFilename.next(d); + return new DiskChunk(Paths.get(filename), nanos); } @Override @@ -423,11 +391,11 @@ private void trimToAge(Instant oldest) { cleanUpDeadChunk(count + 10); } - public synchronized void onChunkComplete(Instant timestamp) { + public synchronized void onChunkComplete(long endTimeNanos) { int count = 0; while (!activeChunks.isEmpty()) { DiskChunk oldestChunk = activeChunks.peek(); - if (oldestChunk.startTime.isBefore(timestamp)) { + if (oldestChunk.startTimeNanos < endTimeNanos) { removeOldestChunk(); count++; } else { diff --git a/src/jdk.management.jfr/share/classes/jdk/management/jfr/DownLoadThread.java b/src/jdk.management.jfr/share/classes/jdk/management/jfr/DownLoadThread.java index 68d2fc5f6c84e..5ce66692537cb 100644 --- a/src/jdk.management.jfr/share/classes/jdk/management/jfr/DownLoadThread.java +++ b/src/jdk.management.jfr/share/classes/jdk/management/jfr/DownLoadThread.java @@ -29,13 +29,16 @@ import java.util.HashMap; import java.util.Map; +import jdk.jfr.internal.management.ManagementSupport; + final class DownLoadThread extends Thread { private final RemoteRecordingStream stream; private final Instant startTime; private final Instant endTime; private final DiskRepository diskRepository; - DownLoadThread(RemoteRecordingStream stream) { + DownLoadThread(RemoteRecordingStream stream, String name) { + super(name); this.stream = stream; this.startTime = stream.startTime; this.endTime = stream.endTime; @@ -65,7 +68,7 @@ public void run() { } } } catch (IOException ioe) { - // ignore + ManagementSupport.logDebug(ioe.getMessage()); } finally { diskRepository.complete(); } diff --git a/src/jdk.management.jfr/share/classes/jdk/management/jfr/RemoteRecordingStream.java b/src/jdk.management.jfr/share/classes/jdk/management/jfr/RemoteRecordingStream.java index c5af59d1776a1..c35a66b7913ee 100644 --- a/src/jdk.management.jfr/share/classes/jdk/management/jfr/RemoteRecordingStream.java +++ b/src/jdk.management.jfr/share/classes/jdk/management/jfr/RemoteRecordingStream.java @@ -133,8 +133,7 @@ final static class ChunkConsumer implements Consumer { @Override public void accept(Long endNanos) { - Instant t = ManagementSupport.epochNanosToInstant(endNanos); - repository.onChunkComplete(t); + repository.onChunkComplete(endNanos); } } @@ -552,8 +551,8 @@ private static Path makeTempDirectory() throws IOException { } private void startDownload() { - Thread downLoadThread = new DownLoadThread(this); - downLoadThread.setName("JFR: Download Thread " + creationTime); + String name = "JFR: Download Thread " + creationTime; + Thread downLoadThread = new DownLoadThread(this, name); downLoadThread.start(); } diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index d78668256a58a..d0191d6333883 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -849,7 +849,6 @@ javax/script/Test7.java 8239361 generic- jdk/jfr/event/runtime/TestNetworkUtilizationEvent.java 8228990,8229370 generic-all jdk/jfr/event/compiler/TestCodeSweeper.java 8225209 generic-all jdk/jfr/event/os/TestThreadContextSwitches.java 8247776 windows-all -jdk/jfr/jmx/streaming/TestRotate.java 8257215 generic-all jdk/jfr/startupargs/TestStartName.java 8214685 windows-x64 jdk/jfr/startupargs/TestStartDuration.java 8214685 windows-x64 diff --git a/test/jdk/jdk/jfr/jmx/streaming/TestRotate.java b/test/jdk/jdk/jfr/jmx/streaming/TestRotate.java index 05a0bab74da2e..d7ec6398ecf9e 100644 --- a/test/jdk/jdk/jfr/jmx/streaming/TestRotate.java +++ b/test/jdk/jdk/jfr/jmx/streaming/TestRotate.java @@ -44,7 +44,7 @@ * @summary Tests that streaming can work over chunk rotations * @requires vm.hasJFR * @library /test/lib /test/jdk - * @run main/othervm jdk.jfr.jmx.streaming.TestRotate + * @run main/othervm -Xlog:jfr=debug jdk.jfr.jmx.streaming.TestRotate */ public class TestRotate { From b6a736738ae025604d86924298fdd04a7851b85f Mon Sep 17 00:00:00 2001 From: David Holmes Date: Mon, 1 Feb 2021 21:31:25 +0000 Subject: [PATCH 08/77] 8260349: Cannot programmatically retrieve Metaspace max set via JAVA_TOOL_OPTIONS Reviewed-by: shade, stuefe --- src/hotspot/share/services/memoryPool.cpp | 6 +- .../Metaspace/MaxMetaspaceSizeEnvVarTest.java | 120 ++++++++++++++++++ 2 files changed, 123 insertions(+), 3 deletions(-) create mode 100644 test/hotspot/jtreg/runtime/Metaspace/MaxMetaspaceSizeEnvVarTest.java diff --git a/src/hotspot/share/services/memoryPool.cpp b/src/hotspot/share/services/memoryPool.cpp index f7ed91ba19f9f..2462bcb50be77 100644 --- a/src/hotspot/share/services/memoryPool.cpp +++ b/src/hotspot/share/services/memoryPool.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -197,8 +197,8 @@ size_t MetaspacePool::used_in_bytes() { } size_t MetaspacePool::calculate_max_size() const { - return FLAG_IS_CMDLINE(MaxMetaspaceSize) ? MaxMetaspaceSize : - MemoryUsage::undefined_size(); + return !FLAG_IS_DEFAULT(MaxMetaspaceSize) ? MaxMetaspaceSize : + MemoryUsage::undefined_size(); } CompressedKlassSpacePool::CompressedKlassSpacePool() : diff --git a/test/hotspot/jtreg/runtime/Metaspace/MaxMetaspaceSizeEnvVarTest.java b/test/hotspot/jtreg/runtime/Metaspace/MaxMetaspaceSizeEnvVarTest.java new file mode 100644 index 0000000000000..1ee578755880d --- /dev/null +++ b/test/hotspot/jtreg/runtime/Metaspace/MaxMetaspaceSizeEnvVarTest.java @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8260349 + * @summary test that setting via the env-var and options file shows up as expected + * @library /test/lib + * @run driver MaxMetaspaceSizeEnvVarTest + */ + +import java.io.PrintWriter; +import java.lang.management.ManagementFactory; +import java.lang.management.MemoryPoolMXBean; + +import jdk.test.lib.process.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; + +public class MaxMetaspaceSizeEnvVarTest { + + // This is the test class we exec, passing the MaxMetaspaceSize flag + // by different mechanisms. + static class Main { + public static void main(String[] args) throws Exception { + long expected = Long.parseLong(args[0]); + MemoryPoolMXBean metaspaceMemoryPool = + ManagementFactory.getPlatformMXBeans(MemoryPoolMXBean.class) + .stream() + .filter(pool -> "Metaspace".equals(pool.getName())) + .findFirst() + .orElseThrow(); + long max = metaspaceMemoryPool.getUsage().getMax(); + System.out.println("Metaspace max usage is " + max); + if (max != expected) { + throw new RuntimeException("Metaspace max " + max + + " != " + expected); + } + } + } + + static void report(String msg) { + System.out.println(msg); + System.err.println(msg); + } + + public static void main(String... args) throws Exception { + final String max = String.valueOf(9 * 1024 * 1024); // 9 MB + final String flagRaw = "MaxMetaspaceSize=" + max; + final String flag = "-XX:" + flagRaw; + final String main = "MaxMetaspaceSizeEnvVarTest$Main"; + + ProcessBuilder pb = null; + OutputAnalyzer output = null; + + int test = 1; + report("Test " + test + ": flag not set"); + + Main.main(new String[] { "-1" }); // -1 == undefined size + report("------ end Test " + test); + test++; + + report("Test " + test + ": normal command-line flag"); + pb = ProcessTools.createJavaProcessBuilder(flag, main, max); + output = new OutputAnalyzer(pb.start()); + output.shouldHaveExitValue(0); + output.reportDiagnosticSummary(); + report("------ end Test " + test); + test++; + + String[] envVars = { + "JDK_JAVA_OPTIONS", + "_JAVA_OPTIONS", + "JAVA_TOOL_OPTIONS" + }; + + for (String envVar : envVars) { + report("Test " + test + ": " + envVar + " env-var"); + pb = ProcessTools.createJavaProcessBuilder(main, max); + pb.environment().put(envVar, flag); + output = new OutputAnalyzer(pb.start()); + output.shouldHaveExitValue(0); + output.reportDiagnosticSummary(); + report("------ end Test " + test); + test++; + } + + report("Test " + test + ": .hotspotrc file"); + final String rcFile = ".hotspotrc"; + final String rcFileFlag = "-XX:Flags=" + rcFile; + + PrintWriter pw = new PrintWriter(rcFile); + pw.println(flagRaw); + pw.close(); + pb = ProcessTools.createJavaProcessBuilder(rcFileFlag, main, max); + output = new OutputAnalyzer(pb.start()); + output.shouldHaveExitValue(0); + output.reportDiagnosticSummary(); + report("------ end Test " + test); + } +} From 55d62a53380a0583397dacd4bd1b12f0c6be46bf Mon Sep 17 00:00:00 2001 From: Calvin Cheung Date: Mon, 1 Feb 2021 22:17:57 +0000 Subject: [PATCH 09/77] 8213226: [TESTBUG] Reduce the usage of CDSTestUtils.executeAndLog() Reviewed-by: iklam, minqi --- .../cds/CdsDifferentCompactStrings.java | 7 ++- .../jtreg/runtime/cds/DeterministicDump.java | 20 +++---- .../runtime/cds/DumpSharedDictionary.java | 28 +++++----- .../cds/PrintSharedArchiveAndExit.java | 6 +-- .../jtreg/runtime/cds/SharedArchiveFile.java | 32 +++++------ .../jtreg/runtime/cds/SharedStringsDedup.java | 9 ++-- .../runtime/cds/SharedStringsRunAuto.java | 9 ++-- .../cds/SharedSymbolTableBucketSize.java | 7 ++- .../runtime/cds/SpaceUtilizationCheck.java | 5 +- .../cds/appcds/BootClassPathMismatch.java | 6 +-- .../runtime/cds/appcds/DumpClassList.java | 43 ++++++++------- .../cds/appcds/GraalWithLimitedMetaspace.java | 54 +++++++++---------- .../cds/appcds/LambdaWithOldClass.java | 10 +--- .../runtime/cds/appcds/LotsOfClasses.java | 6 +-- .../cds/appcds/StaticArchiveWithLambda.java | 11 ++-- .../LambdaForClassInBaseArchive.java | 12 ++--- .../dynamicArchive/LambdaInBaseArchive.java | 11 +--- .../dynamicArchive/NoClassToArchive.java | 15 +++--- .../appcds/jigsaw/NewModuleFinderTest.java | 24 +++++---- .../appcds/jvmti/ClassFileLoadHookTest.java | 26 ++++----- .../cds/appcds/jvmti/InstrumentationTest.java | 27 +++++----- .../methodHandles/CDSMHTest_generate.sh | 14 ++--- .../MethodHandlesAsCollectorTest.java | 12 ++--- .../MethodHandlesCastFailureTest.java | 12 ++--- .../MethodHandlesGeneralTest.java | 12 ++--- .../MethodHandlesInvokersTest.java | 12 ++--- .../MethodHandlesPermuteArgumentsTest.java | 12 ++--- .../MethodHandlesSpreadArgumentsTest.java | 12 ++--- .../sharedStrings/SharedStringsBasic.java | 34 ++++++------ .../appcds/sharedStrings/SysDictCrash.java | 41 +++++++------- test/lib/jdk/test/lib/cds/CDSOptions.java | 13 ++++- test/lib/jdk/test/lib/cds/CDSTestUtils.java | 14 ++++- 32 files changed, 252 insertions(+), 304 deletions(-) diff --git a/test/hotspot/jtreg/runtime/cds/CdsDifferentCompactStrings.java b/test/hotspot/jtreg/runtime/cds/CdsDifferentCompactStrings.java index d0115403c91b4..8ab823dfd31d4 100644 --- a/test/hotspot/jtreg/runtime/cds/CdsDifferentCompactStrings.java +++ b/test/hotspot/jtreg/runtime/cds/CdsDifferentCompactStrings.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,10 +46,9 @@ private static void createAndLoadSharedArchive(String create, String load) String createCompactStringsArgument = "-XX:" + create + "CompactStrings"; String loadCompactStringsArgument = "-XX:" + load + "CompactStrings"; - OutputAnalyzer out = CDSTestUtils.createArchive(createCompactStringsArgument); - CDSTestUtils.checkDump(out); + CDSTestUtils.createArchiveAndCheck(createCompactStringsArgument); - out = CDSTestUtils.runWithArchive(loadCompactStringsArgument); + OutputAnalyzer out = CDSTestUtils.runWithArchive(loadCompactStringsArgument); CDSTestUtils.checkMappingFailure(out); out.shouldMatch("The shared archive file's CompactStrings " + diff --git a/test/hotspot/jtreg/runtime/cds/DeterministicDump.java b/test/hotspot/jtreg/runtime/cds/DeterministicDump.java index eaa5477d1e915..9cdba1fa92207 100644 --- a/test/hotspot/jtreg/runtime/cds/DeterministicDump.java +++ b/test/hotspot/jtreg/runtime/cds/DeterministicDump.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,10 +30,9 @@ * @run driver DeterministicDump */ +import jdk.test.lib.cds.CDSOptions; import jdk.test.lib.cds.CDSTestUtils; import jdk.test.lib.Platform; -import jdk.test.lib.process.ProcessTools; -import jdk.test.lib.process.OutputAnalyzer; import java.io.FileInputStream; import java.io.IOException; import java.util.ArrayList; @@ -79,16 +78,11 @@ public static void doTest(boolean compressed) throws Exception { static String dump(ArrayList args, String... more) throws Exception { String logName = "SharedArchiveFile" + (id++); String archiveName = logName + ".jsa"; - args = (ArrayList)args.clone(); - args.add("-XX:SharedArchiveFile=" + archiveName); - args.add("-Xshare:dump"); - args.add("-Xlog:cds=debug"); - for (String m : more) { - args.add(m); - } - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(args); - OutputAnalyzer out = CDSTestUtils.executeAndLog(pb, logName); - CDSTestUtils.checkDump(out); + CDSOptions opts = (new CDSOptions()) + .addPrefix("-Xlog:cds=debug") + .setArchiveName(archiveName) + .addSuffix(more); + CDSTestUtils.createArchiveAndCheck(opts); return archiveName; } diff --git a/test/hotspot/jtreg/runtime/cds/DumpSharedDictionary.java b/test/hotspot/jtreg/runtime/cds/DumpSharedDictionary.java index a270957b599f5..66522c11adbb6 100644 --- a/test/hotspot/jtreg/runtime/cds/DumpSharedDictionary.java +++ b/test/hotspot/jtreg/runtime/cds/DumpSharedDictionary.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,6 +30,7 @@ * @run driver DumpSharedDictionary */ +import jdk.test.lib.cds.CDSOptions; import jdk.test.lib.cds.CDSTestUtils; import jdk.test.lib.process.ProcessTools; import jdk.test.lib.process.OutputAnalyzer; @@ -40,24 +41,19 @@ public class DumpSharedDictionary { public static void main(String[] args) throws Exception { if (args.length == 0) { // Start this process - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( - "-XX:SharedArchiveFile=./DumpSharedDictionary.jsa", - "-Xshare:dump"); - - OutputAnalyzer out = CDSTestUtils.executeAndLog(pb, "dump"); - out.shouldHaveExitValue(0); + CDSOptions opts = (new CDSOptions()) + .setArchiveName("./DumpSharedDictionary.jsa"); + CDSTestUtils.createArchiveAndCheck(opts); String testjdkPath = System.getProperty("test.jdk"); - pb = ProcessTools.createJavaProcessBuilder( - "-XX:SharedArchiveFile=./DumpSharedDictionary.jsa", - "-Dtest.jdk=" + testjdkPath, - "-Xshare:on", "DumpSharedDictionary", "test"); - - out = CDSTestUtils.executeAndLog(pb, "exec"); - if (!CDSTestUtils.isUnableToMap(out)) { - out.shouldHaveExitValue(0); - } + opts = (new CDSOptions()) + .setUseVersion(false) + .addSuffix("-XX:SharedArchiveFile=./DumpSharedDictionary.jsa", + "-Dtest.jdk=" + testjdkPath, + "DumpSharedDictionary", "test"); + CDSTestUtils.run(opts) + .assertNormalExit(); } else { // Grab my own PID String pid = Long.toString(ProcessTools.getProcessId()); diff --git a/test/hotspot/jtreg/runtime/cds/PrintSharedArchiveAndExit.java b/test/hotspot/jtreg/runtime/cds/PrintSharedArchiveAndExit.java index e6d82dea5077d..e193354835974 100644 --- a/test/hotspot/jtreg/runtime/cds/PrintSharedArchiveAndExit.java +++ b/test/hotspot/jtreg/runtime/cds/PrintSharedArchiveAndExit.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,14 +33,12 @@ import jdk.test.lib.cds.CDSOptions; import jdk.test.lib.cds.CDSTestUtils; -import jdk.test.lib.process.OutputAnalyzer; public class PrintSharedArchiveAndExit { public static void main(String[] args) throws Exception { String archiveName = "PrintSharedArchiveAndExit.jsa"; CDSOptions opts = (new CDSOptions()).setArchiveName(archiveName); - OutputAnalyzer out = CDSTestUtils.createArchive(opts); - CDSTestUtils.checkDump(out); + CDSTestUtils.createArchiveAndCheck(opts); // (1) With a valid archive opts = (new CDSOptions()) diff --git a/test/hotspot/jtreg/runtime/cds/SharedArchiveFile.java b/test/hotspot/jtreg/runtime/cds/SharedArchiveFile.java index afee4a4d36101..d58bc0e888d00 100644 --- a/test/hotspot/jtreg/runtime/cds/SharedArchiveFile.java +++ b/test/hotspot/jtreg/runtime/cds/SharedArchiveFile.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,9 +31,8 @@ * java.management */ +import jdk.test.lib.cds.CDSOptions; import jdk.test.lib.cds.CDSTestUtils; -import jdk.test.lib.process.ProcessTools; -import jdk.test.lib.process.OutputAnalyzer; // NOTE: This test serves as a sanity test and also as an example for simple @@ -41,23 +40,20 @@ // methods to form command line to create/use shared archive. public class SharedArchiveFile { public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createTestJvm( - "-XX:SharedArchiveFile=./SharedArchiveFile.jsa", - "-Xshare:dump", "-Xlog:cds"); - OutputAnalyzer out = CDSTestUtils.executeAndLog(pb, "SharedArchiveFile"); - CDSTestUtils.checkDump(out); + CDSOptions opts = (new CDSOptions()) + .addPrefix("-Xlog:cds") + .setArchiveName("./SharedArchiveFile.jsa"); + CDSTestUtils.createArchiveAndCheck(opts); // -XX:+DumpSharedSpaces should behave the same as -Xshare:dump - pb = ProcessTools.createTestJvm( - "-XX:SharedArchiveFile=./SharedArchiveFile.jsa", - "-XX:+DumpSharedSpaces", "-Xlog:cds"); - out = CDSTestUtils.executeAndLog(pb, "SharedArchiveFile"); - CDSTestUtils.checkDump(out); + opts = (new CDSOptions()) + .addPrefix("-XX:+DumpSharedSpaces", "-Xlog:cds") + .setArchiveName("./SharedArchiveFile.jsa"); + CDSTestUtils.createArchiveAndCheck(opts); - pb = ProcessTools.createTestJvm( - "-XX:SharedArchiveFile=./SharedArchiveFile.jsa", - "-Xshare:on", "-version"); - out = CDSTestUtils.executeAndLog(pb, "SharedArchiveFile"); - CDSTestUtils.checkExec(out); + opts = (new CDSOptions()) + .setArchiveName("./SharedArchiveFile.jsa"); + CDSTestUtils.run(opts) + .assertNormalExit(); } } diff --git a/test/hotspot/jtreg/runtime/cds/SharedStringsDedup.java b/test/hotspot/jtreg/runtime/cds/SharedStringsDedup.java index 7db5e9f9073c3..434cee789377e 100644 --- a/test/hotspot/jtreg/runtime/cds/SharedStringsDedup.java +++ b/test/hotspot/jtreg/runtime/cds/SharedStringsDedup.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,8 +30,6 @@ */ import jdk.test.lib.cds.CDSTestUtils; -import jdk.test.lib.process.OutputAnalyzer; -import java.io.File; // The main purpose is to test the interaction between shared strings // and -XX:+UseStringDeduplication. We run in -Xshare:auto mode so @@ -39,9 +37,8 @@ // doesn't happen often so it won't impact coverage). public class SharedStringsDedup { public static void main(String[] args) throws Exception { - OutputAnalyzer out = - CDSTestUtils.createArchive(); - CDSTestUtils.checkDump(out, "Shared string table stats"); + CDSTestUtils.createArchiveAndCheck() + .shouldContain("Shared string table stats"); CDSTestUtils.runWithArchiveAndCheck("-XX:+UseStringDeduplication"); } } diff --git a/test/hotspot/jtreg/runtime/cds/SharedStringsRunAuto.java b/test/hotspot/jtreg/runtime/cds/SharedStringsRunAuto.java index bc6c3fc2e34bd..a2437a0231ddc 100644 --- a/test/hotspot/jtreg/runtime/cds/SharedStringsRunAuto.java +++ b/test/hotspot/jtreg/runtime/cds/SharedStringsRunAuto.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,14 +30,11 @@ */ import jdk.test.lib.cds.CDSTestUtils; -import jdk.test.lib.process.OutputAnalyzer; -import java.io.File; public class SharedStringsRunAuto { public static void main(String[] args) throws Exception { - OutputAnalyzer out = - CDSTestUtils.createArchive(); - CDSTestUtils.checkDump(out, "Shared string table stats"); + CDSTestUtils.createArchiveAndCheck() + .shouldContain( "Shared string table stats"); CDSTestUtils.runWithArchiveAndCheck(); } } diff --git a/test/hotspot/jtreg/runtime/cds/SharedSymbolTableBucketSize.java b/test/hotspot/jtreg/runtime/cds/SharedSymbolTableBucketSize.java index 56db1f2e738c3..e29bf18eb9640 100644 --- a/test/hotspot/jtreg/runtime/cds/SharedSymbolTableBucketSize.java +++ b/test/hotspot/jtreg/runtime/cds/SharedSymbolTableBucketSize.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,9 +39,8 @@ public static void main(String[] args) throws Exception { int bucket_size = 8; OutputAnalyzer output = - CDSTestUtils.createArchive("-XX:SharedSymbolTableBucketSize=" - + Integer.valueOf(bucket_size)); - CDSTestUtils.checkDump(output); + CDSTestUtils.createArchiveAndCheck("-XX:SharedSymbolTableBucketSize=" + + Integer.valueOf(bucket_size)); CDSTestUtils.checkMappingFailure(output); String s = output.firstMatch("Average bucket size : .*"); diff --git a/test/hotspot/jtreg/runtime/cds/SpaceUtilizationCheck.java b/test/hotspot/jtreg/runtime/cds/SpaceUtilizationCheck.java index 0ffaa48d0b868..f30852938a76d 100644 --- a/test/hotspot/jtreg/runtime/cds/SpaceUtilizationCheck.java +++ b/test/hotspot/jtreg/runtime/cds/SpaceUtilizationCheck.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -55,8 +55,7 @@ public static void main(String[] args) throws Exception { static void test(String... extra_options) throws Exception { CDSOptions opts = new CDSOptions(); opts.addSuffix(extra_options); - OutputAnalyzer output = CDSTestUtils.createArchive(opts); - CDSTestUtils.checkDump(output); + OutputAnalyzer output = CDSTestUtils.createArchiveAndCheck(opts); Pattern pattern = Pattern.compile("(..) space: *([0-9]+).* out of *([0-9]+) bytes .* at 0x([0-9a0-f]+)"); WhiteBox wb = WhiteBox.getWhiteBox(); long reserve_alignment = wb.metaspaceReserveAlignment(); diff --git a/test/hotspot/jtreg/runtime/cds/appcds/BootClassPathMismatch.java b/test/hotspot/jtreg/runtime/cds/appcds/BootClassPathMismatch.java index 279c3286ca19b..a71e71012eb80 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/BootClassPathMismatch.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/BootClassPathMismatch.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,7 +35,6 @@ import jdk.test.lib.Platform; import jdk.test.lib.cds.CDSOptions; import jdk.test.lib.cds.CDSTestUtils; -import jdk.test.lib.process.OutputAnalyzer; import java.io.File; import java.nio.file.Files; import java.nio.file.FileAlreadyExistsException; @@ -187,8 +186,7 @@ public void testBootClassPathMatch() throws Exception { */ public void testBootClassPathMatchWithAppend() throws Exception { CDSOptions opts = new CDSOptions().setUseVersion(false); - OutputAnalyzer out = CDSTestUtils.createArchive(opts); - CDSTestUtils.checkDump(out); + CDSTestUtils.createArchiveAndCheck(opts); String appJar = JarBuilder.getOrCreateHelloJar(); opts.addPrefix("-Xbootclasspath/a:" + appJar, "-showversion").addSuffix("Hello"); diff --git a/test/hotspot/jtreg/runtime/cds/appcds/DumpClassList.java b/test/hotspot/jtreg/runtime/cds/appcds/DumpClassList.java index 07101416f38c1..68662f505b87d 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/DumpClassList.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/DumpClassList.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,9 +32,9 @@ * @run driver DumpClassList */ +import jdk.test.lib.cds.CDSOptions; +import jdk.test.lib.cds.CDSTestUtils; import jdk.test.lib.compiler.InMemoryJavaCompiler; -import jdk.test.lib.process.OutputAnalyzer; -import jdk.test.lib.process.ProcessTools; public class DumpClassList { public static void main(String[] args) throws Exception { @@ -74,24 +74,27 @@ public static void main(String[] args) throws Exception { String appendJar = JarBuilder.build("bootappend", "boot/append/Foo"); // dump class list - ProcessBuilder pb = ProcessTools.createTestJvm( - "-XX:DumpLoadedClassList=" + classList, - "--patch-module=java.base=" + patchJar, - "-Xbootclasspath/a:" + appendJar, - "-cp", - appJar, - appClass[0]); - OutputAnalyzer output = TestCommon.executeAndLog(pb, "dumpClassList"); - TestCommon.checkExecReturn(output, 0, true, - "hello world", - "skip writing class java/lang/NewClass") // skip classes outside of jrt image - .shouldNotContain("skip writing class boot/append/Foo"); // but classes on -Xbootclasspath/a should not be skipped + CDSTestUtils.dumpClassList(classList, + "--patch-module=java.base=" + patchJar, + "-Xbootclasspath/a:" + appendJar, + "-cp", + appJar, + appClass[0]) + .assertNormalExit(output -> { + output.shouldContain("hello world"); + // skip classes outside of jrt image + output.shouldContain("skip writing class java/lang/NewClass"); + // but classes on -Xbootclasspath/a should not be skipped + output.shouldNotContain("skip writing class boot/append/Foo"); + }); - output = TestCommon.createArchive(appJar, appClass, - "-Xbootclasspath/a:" + appendJar, - "-Xlog:class+load", - "-XX:SharedClassListFile=" + classList); - TestCommon.checkDump(output) + CDSOptions opts = (new CDSOptions()) + .setClassList(appClass) + .addPrefix("-cp", appJar, + "-Xbootclasspath/a:" + appendJar, + "-Xlog:class+load", + "-XX:SharedClassListFile=" + classList); + CDSTestUtils.createArchiveAndCheck(opts) .shouldNotContain("Preload Warning: Cannot find java/lang/invoke/LambdaForm") .shouldNotContain("Preload Warning: Cannot find boot/append/Foo") .shouldContain("[info][class,load] boot.append.Foo"); diff --git a/test/hotspot/jtreg/runtime/cds/appcds/GraalWithLimitedMetaspace.java b/test/hotspot/jtreg/runtime/cds/appcds/GraalWithLimitedMetaspace.java index 2abe40054b3f1..4dc49aa88eb2c 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/GraalWithLimitedMetaspace.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/GraalWithLimitedMetaspace.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,9 +35,9 @@ * GraalWithLimitedMetaspace */ +import jdk.test.lib.cds.CDSOptions; import jdk.test.lib.cds.CDSTestUtils; import jdk.test.lib.process.OutputAnalyzer; -import jdk.test.lib.process.ProcessTools; import java.util.ArrayList; import java.util.List; @@ -83,21 +83,20 @@ public static List toClassNames(String filename) throws IOException { } static void dumpLoadedClasses(String[] expectedClasses) throws Exception { - ProcessBuilder pb = ProcessTools.createTestJvm( - "-XX:DumpLoadedClassList=" + CLASSLIST_FILE, - // trigger JVMCI runtime init so that JVMCI classes will be - // included in the classlist - "-XX:+UnlockExperimentalVMOptions", - "-XX:+EnableJVMCI", - "-XX:+EagerJVMCI", - "-cp", - TESTJAR, - TESTNAME, - TEST_OUT); - - OutputAnalyzer output = TestCommon.executeAndLog(pb, "dump-loaded-classes") - .shouldHaveExitValue(0) - .shouldContain(TEST_OUT); + CDSTestUtils.dumpClassList( + CLASSLIST_FILE, + // trigger JVMCI runtime init so that JVMCI classes will be + // included in the classlist + "-XX:+UnlockExperimentalVMOptions", + "-XX:+EnableJVMCI", + "-XX:+EagerJVMCI", + "-cp", + TESTJAR, + TESTNAME, + TEST_OUT) + .assertNormalExit(output -> { + output.shouldContain(TEST_OUT); + }); List dumpedClasses = toClassNames(CLASSLIST_FILE); @@ -110,17 +109,16 @@ static void dumpLoadedClasses(String[] expectedClasses) throws Exception { } static void dumpArchive() throws Exception { - ProcessBuilder pb = ProcessTools.createTestJvm( - "-cp", - TESTJAR, - "-XX:SharedClassListFile=" + CLASSLIST_FILE, - "-XX:SharedArchiveFile=" + ARCHIVE_FILE, - "-Xlog:cds", - "-Xshare:dump", - "-XX:MetaspaceSize=12M", - "-XX:MaxMetaspaceSize=12M"); - - OutputAnalyzer output = TestCommon.executeAndLog(pb, "dump-archive"); + CDSOptions opts = (new CDSOptions()) + .addPrefix("-cp", + TESTJAR, + "-XX:SharedClassListFile=" + CLASSLIST_FILE, + "-Xlog:cds", + "-Xshare:dump", + "-XX:MetaspaceSize=12M", + "-XX:MaxMetaspaceSize=12M") + .setArchiveName(ARCHIVE_FILE); + OutputAnalyzer output = CDSTestUtils.createArchive(opts); int exitValue = output.getExitValue(); if (exitValue == 1) { output.shouldContain("Failed allocating metaspace object type"); diff --git a/test/hotspot/jtreg/runtime/cds/appcds/LambdaWithOldClass.java b/test/hotspot/jtreg/runtime/cds/appcds/LambdaWithOldClass.java index 5410348dc2ba3..bb5f883974065 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/LambdaWithOldClass.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/LambdaWithOldClass.java @@ -37,7 +37,6 @@ import jdk.test.lib.cds.CDSOptions; import jdk.test.lib.cds.CDSTestUtils; import jdk.test.lib.process.OutputAnalyzer; -import jdk.test.lib.process.ProcessTools; public class LambdaWithOldClass { @@ -51,12 +50,7 @@ public static void main(String[] args) throws Exception { String archiveName = namePrefix + ".jsa"; // dump class list - ProcessBuilder pb = ProcessTools.createTestJvm( - "-XX:DumpLoadedClassList=" + classList, - "-cp", appJar, - mainClass); - OutputAnalyzer output = TestCommon.executeAndLog(pb, namePrefix); - output.shouldHaveExitValue(0); + CDSTestUtils.dumpClassList(classList, "-cp", appJar, mainClass); // create archive with the class list CDSOptions opts = (new CDSOptions()) @@ -72,7 +66,7 @@ public static void main(String[] args) throws Exception { .setArchiveName(archiveName) .setUseVersion(false) .addSuffix(mainClass); - output = CDSTestUtils.runWithArchive(runOpts); + OutputAnalyzer output = CDSTestUtils.runWithArchive(runOpts); output.shouldContain("[class,load] LambdaWithOldClassApp source: shared objects file") .shouldMatch(".class.load. LambdaWithOldClassApp[$][$]Lambda[$].*/0x.*source:.*LambdaWithOldClassApp") .shouldHaveExitValue(0); diff --git a/test/hotspot/jtreg/runtime/cds/appcds/LotsOfClasses.java b/test/hotspot/jtreg/runtime/cds/appcds/LotsOfClasses.java index 2129757791110..9372e7aeed1be 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/LotsOfClasses.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/LotsOfClasses.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,6 @@ import jdk.test.lib.cds.CDSTestUtils; import jdk.test.lib.cds.CDSOptions; -import jdk.test.lib.process.OutputAnalyzer; /* * @test @@ -52,7 +51,6 @@ public static void main(String[] args) throws Exception { opts.addSuffix("-Xlog:gc+region+cds"); opts.addSuffix("-Xlog:gc+region=trace"); - OutputAnalyzer out = CDSTestUtils.createArchive(opts); - CDSTestUtils.checkDump(out); + CDSTestUtils.createArchiveAndCheck(opts); } } diff --git a/test/hotspot/jtreg/runtime/cds/appcds/StaticArchiveWithLambda.java b/test/hotspot/jtreg/runtime/cds/appcds/StaticArchiveWithLambda.java index 6e2aa6d9800eb..10ded84d6c4e2 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/StaticArchiveWithLambda.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/StaticArchiveWithLambda.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,6 @@ import jdk.test.lib.cds.CDSOptions; import jdk.test.lib.cds.CDSTestUtils; import jdk.test.lib.process.OutputAnalyzer; -import jdk.test.lib.process.ProcessTools; public class StaticArchiveWithLambda { public static void main(String[] args) throws Exception { @@ -45,11 +44,7 @@ public static void main(String[] args) throws Exception { String archiveName = "StaticArchiveWithLambda.jsa"; // dump class list - ProcessBuilder pb = ProcessTools.createTestJvm( - "-XX:DumpLoadedClassList=" + classList, - "-cp", appJar, - appClass); - OutputAnalyzer output = TestCommon.executeAndLog(pb, "dumpClassList"); + CDSTestUtils.dumpClassList(classList, "-cp", appJar, appClass); // create archive with the class list CDSOptions opts = (new CDSOptions()) @@ -65,7 +60,7 @@ public static void main(String[] args) throws Exception { .setArchiveName(archiveName) .setUseVersion(false) .addSuffix(appClass); - output = CDSTestUtils.runWithArchive(runOpts); + OutputAnalyzer output = CDSTestUtils.runWithArchive(runOpts); output.shouldContain("LambHello source: shared objects file") .shouldMatch("class.load.*LambHello[$][$]Lambda[$].*0x.*source:.shared.objects.file") .shouldHaveExitValue(0); diff --git a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/LambdaForClassInBaseArchive.java b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/LambdaForClassInBaseArchive.java index 4de1f4a188b42..6d9be5fcdfad0 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/LambdaForClassInBaseArchive.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/LambdaForClassInBaseArchive.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,9 +37,9 @@ */ import java.io.File; +import jdk.test.lib.cds.CDSOptions; import jdk.test.lib.cds.CDSTestUtils; import jdk.test.lib.process.OutputAnalyzer; -import jdk.test.lib.process.ProcessTools; public class LambdaForClassInBaseArchive extends DynamicArchiveTestBase { static final String classList = CDSTestUtils.getOutputFileName("classlist"); @@ -58,13 +58,7 @@ static void testCustomBase() throws Exception { private static void doTestCustomBase(String baseArchiveName, String topArchiveName) throws Exception { String appJar = ClassFileInstaller.getJarPath("simpleApp.jar"); // dump class list by running the SimpleApp - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( - "-XX:DumpLoadedClassList=" + classList, - "-cp", - appJar, - appClass); - OutputAnalyzer output = TestCommon.executeAndLog(pb, "dumpClassList"); - TestCommon.checkExecReturn(output, 0, true); + CDSTestUtils.dumpClassList(classList, "-cp", appJar, appClass); // create a custom base archive based on the class list TestCommon.dumpBaseArchive(baseArchiveName, diff --git a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/LambdaInBaseArchive.java b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/LambdaInBaseArchive.java index 787737edc427a..8abab036d51d2 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/LambdaInBaseArchive.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/LambdaInBaseArchive.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,8 +38,6 @@ import jdk.test.lib.cds.CDSOptions; import jdk.test.lib.cds.CDSTestUtils; -import jdk.test.lib.process.OutputAnalyzer; -import jdk.test.lib.process.ProcessTools; public class LambdaInBaseArchive extends DynamicArchiveTestBase { public static void main(String[] args) throws Exception { @@ -54,12 +52,7 @@ public static void main(String[] args) throws Exception { static void createBaseArchive() throws Exception { // dump class list - ProcessBuilder pb = ProcessTools.createTestJvm( - "-XX:DumpLoadedClassList=" + classList, - "-cp", appJar, - mainClass); - OutputAnalyzer output = TestCommon.executeAndLog(pb, "dumpClassList"); - output.shouldHaveExitValue(0); + CDSTestUtils.dumpClassList(classList, "-cp", appJar, mainClass); // create archive with the class list CDSOptions opts = (new CDSOptions()) diff --git a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/NoClassToArchive.java b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/NoClassToArchive.java index 947b1444c10f8..9986a8ee570e6 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/NoClassToArchive.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/NoClassToArchive.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -45,9 +45,9 @@ */ import java.io.File; +import jdk.test.lib.cds.CDSOptions; import jdk.test.lib.cds.CDSTestUtils; import jdk.test.lib.process.OutputAnalyzer; -import jdk.test.lib.process.ProcessTools; public class NoClassToArchive extends DynamicArchiveTestBase { static final String warningMessage = @@ -107,13 +107,10 @@ private static void doTest(String topArchiveName) throws Exception { private static void doTestCustomBase(String baseArchiveName, String topArchiveName) throws Exception { String appJar = ClassFileInstaller.getJarPath("strConcatApp.jar"); // dump class list by running the StrConcatApp - ProcessBuilder pb = ProcessTools.createTestJvm( - "-XX:DumpLoadedClassList=" + classList, - "-cp", - appJar, - appClass); - OutputAnalyzer output = TestCommon.executeAndLog(pb, "dumpClassList"); - TestCommon.checkExecReturn(output, 0, true, "length = 0"); + CDSTestUtils.dumpClassList(classList, "-cp", appJar, appClass) + .assertNormalExit(output -> { + output.shouldContain("length = 0"); + }); // create a custom base archive based on the class list TestCommon.dumpBaseArchive(baseArchiveName, "-XX:SharedClassListFile=" + classList); diff --git a/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/NewModuleFinderTest.java b/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/NewModuleFinderTest.java index 49b79ac48f531..52108def58716 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/NewModuleFinderTest.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/NewModuleFinderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,9 +37,8 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.Set; +import jdk.test.lib.cds.CDSOptions; import jdk.test.lib.cds.CDSTestUtils; -import jdk.test.lib.process.ProcessTools; -import jdk.test.lib.process.OutputAnalyzer; public class NewModuleFinderTest { @@ -67,14 +66,17 @@ public static void main(String... args) throws Exception { // compile the modules and create the modular jar files buildTestModule(); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( - "-Xlog:cds", - "-Xlog:module=debug", - "-Dtest.src=" + TEST_SRC, - "NewModuleFinderTest$Helper"); - OutputAnalyzer out = CDSTestUtils.executeAndLog(pb, "exec"); - out.shouldHaveExitValue(0); - out.shouldContain("define_module(): creation of module: com.simple,"); + CDSOptions opts = (new CDSOptions()) + .setUseVersion(false) + .setXShareMode("auto") + .addSuffix("-Xlog:cds", + "-Xlog:module=debug", + "-Dtest.src=" + TEST_SRC, + "NewModuleFinderTest$Helper"); + CDSTestUtils.run(opts) + .assertNormalExit(output -> { + output.shouldContain("define_module(): creation of module: com.simple,"); + }); } static class Helper { diff --git a/test/hotspot/jtreg/runtime/cds/appcds/jvmti/ClassFileLoadHookTest.java b/test/hotspot/jtreg/runtime/cds/appcds/jvmti/ClassFileLoadHookTest.java index 8bbec56cb9eb5..e382b873b9c10 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/jvmti/ClassFileLoadHookTest.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/jvmti/ClassFileLoadHookTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,9 +34,8 @@ import jdk.test.lib.cds.CDSOptions; +import jdk.test.lib.cds.CDSTestUtils; import jdk.test.lib.process.OutputAnalyzer; -import jdk.test.lib.process.ProcessTools; - public class ClassFileLoadHookTest { public static String sharedClasses[] = { @@ -55,14 +54,17 @@ public static void main(String[] args) throws Exception { String useWb = "-Xbootclasspath/a:" + wbJar; // First, run the test class directly, w/o sharing, as a baseline reference - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( - "-XX:+UnlockDiagnosticVMOptions", - "-XX:+WhiteBoxAPI", - useWb, - "-agentlib:SimpleClassFileLoadHook=LoadMe,beforeHook,after_Hook", - "ClassFileLoadHook", - "" + ClassFileLoadHook.TestCaseId.SHARING_OFF_CFLH_ON); - TestCommon.executeAndLog(pb, "no-sharing").shouldHaveExitValue(0); + CDSOptions opts = (new CDSOptions()) + .setUseVersion(false) + .setXShareMode("off") + .addSuffix("-XX:+UnlockDiagnosticVMOptions", + "-XX:+WhiteBoxAPI", + useWb, + "-agentlib:SimpleClassFileLoadHook=LoadMe,beforeHook,after_Hook", + "ClassFileLoadHook", + "" + ClassFileLoadHook.TestCaseId.SHARING_OFF_CFLH_ON); + CDSTestUtils.run(opts) + .assertNormalExit(); // Run with AppCDS, but w/o CFLH - second baseline TestCommon.testDump(appJar, sharedClasses, useWb); @@ -83,7 +85,7 @@ public static void main(String[] args) throws Exception { "ClassFileLoadHook", "" + ClassFileLoadHook.TestCaseId.SHARING_AUTO_CFLH_ON); - CDSOptions opts = (new CDSOptions()).setXShareMode("auto"); + opts = (new CDSOptions()).setXShareMode("auto"); TestCommon.checkExec(out, opts); // Now, run with AppCDS -Xshare:on and CFLH diff --git a/test/hotspot/jtreg/runtime/cds/appcds/jvmti/InstrumentationTest.java b/test/hotspot/jtreg/runtime/cds/appcds/jvmti/InstrumentationTest.java index 0837811a03369..1b539d188f700 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/jvmti/InstrumentationTest.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/jvmti/InstrumentationTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -45,8 +45,8 @@ import java.util.Scanner; import jdk.test.lib.Asserts; import jdk.test.lib.cds.CDSOptions; +import jdk.test.lib.cds.CDSTestUtils; import jdk.test.lib.process.OutputAnalyzer; -import jdk.test.lib.process.ProcessTools; public class InstrumentationTest { public static String bootClasses[] = { @@ -109,15 +109,18 @@ public static void runTest(boolean attachAgent) throws Throwable { // First, run the test class directly, w/o sharing, as a baseline reference flagFile = getFlagFile(attachAgent); AgentAttachThread t = doAttach(attachAgent, flagFile, agentJar); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( - bootCP, - "-cp", appJar, - "-XX:+UnlockDiagnosticVMOptions", - "-XX:+WhiteBoxAPI", - "-Xshare:off", - agentCmdArg, - "InstrumentationApp", flagFile, bootJar, appJar, custJar); - TestCommon.executeAndLog(pb, "no-sharing").shouldHaveExitValue(0); + CDSOptions opts = (new CDSOptions()) + .setUseVersion(false) + .setXShareMode("off") + .addSuffix(bootCP, + "-cp", appJar, + "-XX:+UnlockDiagnosticVMOptions", + "-XX:+WhiteBoxAPI", + "-Xshare:off", + agentCmdArg, + "InstrumentationApp", flagFile, bootJar, appJar, custJar); + CDSTestUtils.run(opts) + .assertNormalExit(); checkAttach(t); // Dump the AppCDS archive. On some platforms AppCDSv2 may not be enabled, so we @@ -153,7 +156,7 @@ public static void runTest(boolean attachAgent) throws Throwable { agentCmdArg, "InstrumentationApp", flagFile, bootJar, appJar, custJar); - CDSOptions opts = (new CDSOptions()).setXShareMode("auto"); + opts = (new CDSOptions()).setXShareMode("auto"); TestCommon.checkExec(out, opts); checkAttach(t); } diff --git a/test/hotspot/jtreg/runtime/cds/appcds/methodHandles/CDSMHTest_generate.sh b/test/hotspot/jtreg/runtime/cds/appcds/methodHandles/CDSMHTest_generate.sh index 72529fe1fe977..9f93929f67ce7 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/methodHandles/CDSMHTest_generate.sh +++ b/test/hotspot/jtreg/runtime/cds/appcds/methodHandles/CDSMHTest_generate.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -31,7 +31,7 @@ do fname="$i$name_suffix" cat << EOF > $fname /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -82,7 +82,6 @@ import java.io.File; import jdk.test.lib.cds.CDSOptions; import jdk.test.lib.cds.CDSTestUtils; import jdk.test.lib.process.OutputAnalyzer; -import jdk.test.lib.process.ProcessTools; public class $i { @Test @@ -114,11 +113,8 @@ public class $i { String jars = appJar + ps + junitJar; // dump class list - ProcessBuilder pb = ProcessTools.createTestJvm( - "-XX:DumpLoadedClassList=" + classList, - "-cp", jars, - mainClass, testPackageName + "." + testClassName); - OutputAnalyzer output = TestCommon.executeAndLog(pb, "dumpClassList"); + CDSTestUtils.dumpClassList(classList, "-cp", jars, mainClass, + testPackageName + "." + testClassName); // create archive with the class list CDSOptions opts = (new CDSOptions()) @@ -134,7 +130,7 @@ public class $i { .setArchiveName(archiveName) .setUseVersion(false) .addSuffix(mainClass, testPackageName + "." + testClassName); - output = CDSTestUtils.runWithArchive(runOpts); + OutputAnalyzer output = CDSTestUtils.runWithArchive(runOpts); output.shouldMatch(".class.load. test.java.lang.invoke.$i[$][$]Lambda[$].*/0x.*source:.*shared.*objects.*file") .shouldHaveExitValue(0); } diff --git a/test/hotspot/jtreg/runtime/cds/appcds/methodHandles/MethodHandlesAsCollectorTest.java b/test/hotspot/jtreg/runtime/cds/appcds/methodHandles/MethodHandlesAsCollectorTest.java index 84851a9e463a0..4f48d2d225cf8 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/methodHandles/MethodHandlesAsCollectorTest.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/methodHandles/MethodHandlesAsCollectorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -50,7 +50,6 @@ import jdk.test.lib.cds.CDSOptions; import jdk.test.lib.cds.CDSTestUtils; import jdk.test.lib.process.OutputAnalyzer; -import jdk.test.lib.process.ProcessTools; public class MethodHandlesAsCollectorTest { @Test @@ -82,11 +81,8 @@ static void testImpl() throws Exception { String jars = appJar + ps + junitJar; // dump class list - ProcessBuilder pb = ProcessTools.createTestJvm( - "-XX:DumpLoadedClassList=" + classList, - "-cp", jars, - mainClass, testPackageName + "." + testClassName); - OutputAnalyzer output = TestCommon.executeAndLog(pb, "dumpClassList"); + CDSTestUtils.dumpClassList(classList, "-cp", jars, mainClass, + testPackageName + "." + testClassName); // create archive with the class list CDSOptions opts = (new CDSOptions()) @@ -102,7 +98,7 @@ static void testImpl() throws Exception { .setArchiveName(archiveName) .setUseVersion(false) .addSuffix(mainClass, testPackageName + "." + testClassName); - output = CDSTestUtils.runWithArchive(runOpts); + OutputAnalyzer output = CDSTestUtils.runWithArchive(runOpts); output.shouldMatch(".class.load. test.java.lang.invoke.MethodHandlesAsCollectorTest[$][$]Lambda[$].*/0x.*source:.*shared.*objects.*file") .shouldHaveExitValue(0); } diff --git a/test/hotspot/jtreg/runtime/cds/appcds/methodHandles/MethodHandlesCastFailureTest.java b/test/hotspot/jtreg/runtime/cds/appcds/methodHandles/MethodHandlesCastFailureTest.java index a20aa110ef514..6ba3559d1c8f5 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/methodHandles/MethodHandlesCastFailureTest.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/methodHandles/MethodHandlesCastFailureTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -50,7 +50,6 @@ import jdk.test.lib.cds.CDSOptions; import jdk.test.lib.cds.CDSTestUtils; import jdk.test.lib.process.OutputAnalyzer; -import jdk.test.lib.process.ProcessTools; public class MethodHandlesCastFailureTest { @Test @@ -82,11 +81,8 @@ static void testImpl() throws Exception { String jars = appJar + ps + junitJar; // dump class list - ProcessBuilder pb = ProcessTools.createTestJvm( - "-XX:DumpLoadedClassList=" + classList, - "-cp", jars, - mainClass, testPackageName + "." + testClassName); - OutputAnalyzer output = TestCommon.executeAndLog(pb, "dumpClassList"); + CDSTestUtils.dumpClassList(classList, "-cp", jars, mainClass, + testPackageName + "." + testClassName); // create archive with the class list CDSOptions opts = (new CDSOptions()) @@ -102,7 +98,7 @@ static void testImpl() throws Exception { .setArchiveName(archiveName) .setUseVersion(false) .addSuffix(mainClass, testPackageName + "." + testClassName); - output = CDSTestUtils.runWithArchive(runOpts); + OutputAnalyzer output = CDSTestUtils.runWithArchive(runOpts); output.shouldMatch(".class.load. test.java.lang.invoke.MethodHandlesCastFailureTest[$][$]Lambda[$].*/0x.*source:.*shared.*objects.*file") .shouldHaveExitValue(0); } diff --git a/test/hotspot/jtreg/runtime/cds/appcds/methodHandles/MethodHandlesGeneralTest.java b/test/hotspot/jtreg/runtime/cds/appcds/methodHandles/MethodHandlesGeneralTest.java index a3f402daaac5e..affdd04572766 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/methodHandles/MethodHandlesGeneralTest.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/methodHandles/MethodHandlesGeneralTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -50,7 +50,6 @@ import jdk.test.lib.cds.CDSOptions; import jdk.test.lib.cds.CDSTestUtils; import jdk.test.lib.process.OutputAnalyzer; -import jdk.test.lib.process.ProcessTools; public class MethodHandlesGeneralTest { @Test @@ -82,11 +81,8 @@ static void testImpl() throws Exception { String jars = appJar + ps + junitJar; // dump class list - ProcessBuilder pb = ProcessTools.createTestJvm( - "-XX:DumpLoadedClassList=" + classList, - "-cp", jars, - mainClass, testPackageName + "." + testClassName); - OutputAnalyzer output = TestCommon.executeAndLog(pb, "dumpClassList"); + CDSTestUtils.dumpClassList(classList, "-cp", jars, mainClass, + testPackageName + "." + testClassName); // create archive with the class list CDSOptions opts = (new CDSOptions()) @@ -102,7 +98,7 @@ static void testImpl() throws Exception { .setArchiveName(archiveName) .setUseVersion(false) .addSuffix(mainClass, testPackageName + "." + testClassName); - output = CDSTestUtils.runWithArchive(runOpts); + OutputAnalyzer output = CDSTestUtils.runWithArchive(runOpts); output.shouldMatch(".class.load. test.java.lang.invoke.MethodHandlesGeneralTest[$][$]Lambda[$].*/0x.*source:.*shared.*objects.*file") .shouldHaveExitValue(0); } diff --git a/test/hotspot/jtreg/runtime/cds/appcds/methodHandles/MethodHandlesInvokersTest.java b/test/hotspot/jtreg/runtime/cds/appcds/methodHandles/MethodHandlesInvokersTest.java index fb1b857bdcdec..5640327f56e2c 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/methodHandles/MethodHandlesInvokersTest.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/methodHandles/MethodHandlesInvokersTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -50,7 +50,6 @@ import jdk.test.lib.cds.CDSOptions; import jdk.test.lib.cds.CDSTestUtils; import jdk.test.lib.process.OutputAnalyzer; -import jdk.test.lib.process.ProcessTools; public class MethodHandlesInvokersTest { @Test @@ -82,11 +81,8 @@ static void testImpl() throws Exception { String jars = appJar + ps + junitJar; // dump class list - ProcessBuilder pb = ProcessTools.createTestJvm( - "-XX:DumpLoadedClassList=" + classList, - "-cp", jars, - mainClass, testPackageName + "." + testClassName); - OutputAnalyzer output = TestCommon.executeAndLog(pb, "dumpClassList"); + CDSTestUtils.dumpClassList(classList, "-cp", jars, mainClass, + testPackageName + "." + testClassName); // create archive with the class list CDSOptions opts = (new CDSOptions()) @@ -102,7 +98,7 @@ static void testImpl() throws Exception { .setArchiveName(archiveName) .setUseVersion(false) .addSuffix(mainClass, testPackageName + "." + testClassName); - output = CDSTestUtils.runWithArchive(runOpts); + OutputAnalyzer output = CDSTestUtils.runWithArchive(runOpts); output.shouldMatch(".class.load. test.java.lang.invoke.MethodHandlesInvokersTest[$][$]Lambda[$].*/0x.*source:.*shared.*objects.*file") .shouldHaveExitValue(0); } diff --git a/test/hotspot/jtreg/runtime/cds/appcds/methodHandles/MethodHandlesPermuteArgumentsTest.java b/test/hotspot/jtreg/runtime/cds/appcds/methodHandles/MethodHandlesPermuteArgumentsTest.java index d810af3f42bbb..73165428543f7 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/methodHandles/MethodHandlesPermuteArgumentsTest.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/methodHandles/MethodHandlesPermuteArgumentsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -50,7 +50,6 @@ import jdk.test.lib.cds.CDSOptions; import jdk.test.lib.cds.CDSTestUtils; import jdk.test.lib.process.OutputAnalyzer; -import jdk.test.lib.process.ProcessTools; public class MethodHandlesPermuteArgumentsTest { @Test @@ -82,11 +81,8 @@ static void testImpl() throws Exception { String jars = appJar + ps + junitJar; // dump class list - ProcessBuilder pb = ProcessTools.createTestJvm( - "-XX:DumpLoadedClassList=" + classList, - "-cp", jars, - mainClass, testPackageName + "." + testClassName); - OutputAnalyzer output = TestCommon.executeAndLog(pb, "dumpClassList"); + CDSTestUtils.dumpClassList(classList, "-cp", jars, mainClass, + testPackageName + "." + testClassName); // create archive with the class list CDSOptions opts = (new CDSOptions()) @@ -102,7 +98,7 @@ static void testImpl() throws Exception { .setArchiveName(archiveName) .setUseVersion(false) .addSuffix(mainClass, testPackageName + "." + testClassName); - output = CDSTestUtils.runWithArchive(runOpts); + OutputAnalyzer output = CDSTestUtils.runWithArchive(runOpts); output.shouldMatch(".class.load. test.java.lang.invoke.MethodHandlesPermuteArgumentsTest[$][$]Lambda[$].*/0x.*source:.*shared.*objects.*file") .shouldHaveExitValue(0); } diff --git a/test/hotspot/jtreg/runtime/cds/appcds/methodHandles/MethodHandlesSpreadArgumentsTest.java b/test/hotspot/jtreg/runtime/cds/appcds/methodHandles/MethodHandlesSpreadArgumentsTest.java index fd618cb409360..738113a156219 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/methodHandles/MethodHandlesSpreadArgumentsTest.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/methodHandles/MethodHandlesSpreadArgumentsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -50,7 +50,6 @@ import jdk.test.lib.cds.CDSOptions; import jdk.test.lib.cds.CDSTestUtils; import jdk.test.lib.process.OutputAnalyzer; -import jdk.test.lib.process.ProcessTools; public class MethodHandlesSpreadArgumentsTest { @Test @@ -82,11 +81,8 @@ static void testImpl() throws Exception { String jars = appJar + ps + junitJar; // dump class list - ProcessBuilder pb = ProcessTools.createTestJvm( - "-XX:DumpLoadedClassList=" + classList, - "-cp", jars, - mainClass, testPackageName + "." + testClassName); - OutputAnalyzer output = TestCommon.executeAndLog(pb, "dumpClassList"); + CDSTestUtils.dumpClassList(classList, "-cp", jars, mainClass, + testPackageName + "." + testClassName); // create archive with the class list CDSOptions opts = (new CDSOptions()) @@ -102,7 +98,7 @@ static void testImpl() throws Exception { .setArchiveName(archiveName) .setUseVersion(false) .addSuffix(mainClass, testPackageName + "." + testClassName); - output = CDSTestUtils.runWithArchive(runOpts); + OutputAnalyzer output = CDSTestUtils.runWithArchive(runOpts); output.shouldMatch(".class.load. test.java.lang.invoke.MethodHandlesSpreadArgumentsTest[$][$]Lambda[$].*/0x.*source:.*shared.*objects.*file") .shouldHaveExitValue(0); } diff --git a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/SharedStringsBasic.java b/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/SharedStringsBasic.java index d18ed40dfef67..f116690ac0106 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/SharedStringsBasic.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/SharedStringsBasic.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,8 +30,8 @@ * @build HelloString * @run driver SharedStringsBasic */ -import jdk.test.lib.process.OutputAnalyzer; -import jdk.test.lib.process.ProcessTools; +import jdk.test.lib.cds.CDSOptions; +import jdk.test.lib.cds.CDSTestUtils; // This test does not use SharedStringsUtils.dumpXXX() // and SharedStringsUtils.runWithXXX() intentionally: @@ -50,26 +50,24 @@ public static void test(String[] args) throws Exception { String sharedArchiveConfigFile = TestCommon.getSourceFile("SharedStringsBasic.txt").toString(); - ProcessBuilder dumpPb = ProcessTools.createTestJvm( - TestCommon.concat(vmOptionsPrefix, + CDSOptions opts = (new CDSOptions()) + .addPrefix(vmOptionsPrefix, "-cp", appJar, "-XX:SharedArchiveConfigFile=" + sharedArchiveConfigFile, - "-XX:SharedArchiveFile=./SharedStringsBasic.jsa", - "-Xshare:dump", - "-Xlog:cds,cds+hashtables")); - - TestCommon.executeAndLog(dumpPb, "dump") - .shouldContain("Shared string table stats") - .shouldHaveExitValue(0); + "-Xlog:cds,cds+hashtables") + .setArchiveName("./SharedStringsBasic.jsa"); + CDSTestUtils.createArchiveAndCheck(opts) + .shouldContain("Shared string table stats"); - ProcessBuilder runPb = ProcessTools.createTestJvm( - TestCommon.concat(vmOptionsPrefix, + opts = (new CDSOptions()) + .setUseVersion(false) + .setXShareMode("auto") + .addSuffix(vmOptionsPrefix, "-cp", appJar, "-XX:SharedArchiveFile=./SharedStringsBasic.jsa", - "-Xshare:auto", "-showversion", - "HelloString")); - - TestCommon.executeAndLog(runPb, "run").shouldHaveExitValue(0); + "HelloString"); + CDSTestUtils.run(opts) + .assertNormalExit(); } } diff --git a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/SysDictCrash.java b/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/SysDictCrash.java index dbb1a64a1c0b6..ab3473777f467 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/SysDictCrash.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/SysDictCrash.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,8 +31,9 @@ * @run driver SysDictCrash */ +import jdk.test.lib.cds.CDSOptions; +import jdk.test.lib.cds.CDSTestUtils; import jdk.test.lib.process.OutputAnalyzer; -import jdk.test.lib.process.ProcessTools; public class SysDictCrash { public static void main(String[] args) throws Exception { @@ -43,16 +44,16 @@ public static void test(String[] args) throws Exception { String vmOptionsPrefix[] = SharedStringsUtils.getChildVMOptionsPrefix(); // SharedBaseAddress=0 puts the archive at a very high address, which provokes the crash. - ProcessBuilder dumpPb = ProcessTools.createTestJvm( - TestCommon.concat(vmOptionsPrefix, - "-XX:+UseG1GC", "-XX:MaxRAMPercentage=12.5", - "-cp", ".", - "-XX:SharedBaseAddress=0", "-XX:SharedArchiveFile=./SysDictCrash.jsa", - "-Xshare:dump", - "-showversion", "-Xlog:cds,cds+hashtables")); - boolean continueTest = true; - OutputAnalyzer output = TestCommon.executeAndLog(dumpPb, "dump"); + + CDSOptions opts = (new CDSOptions()) + .addPrefix(vmOptionsPrefix, + "-XX:+UseG1GC", "-XX:MaxRAMPercentage=12.5", + "-cp", ".", + "-XX:SharedBaseAddress=0", + "-showversion", "-Xlog:cds,cds+hashtables") + .setArchiveName("./SysDictCrash.jsa"); + OutputAnalyzer output = CDSTestUtils.createArchive(opts); try { TestCommon.checkDump(output); } catch (java.lang.RuntimeException re) { @@ -68,13 +69,15 @@ public static void test(String[] args) throws Exception { return; } - ProcessBuilder runPb = ProcessTools.createTestJvm( - TestCommon.concat(vmOptionsPrefix, - "-XX:+UseG1GC", "-XX:MaxRAMPercentage=12.5", - "-XX:SharedArchiveFile=./SysDictCrash.jsa", - "-Xshare:on", - "-version")); - - TestCommon.checkExec(TestCommon.executeAndLog(runPb, "exec")); + opts = (new CDSOptions()) + .setArchiveName("./SysDictCrash.jsa") // prevents the assignment of a default archive name + .setUseVersion(false) // the -version must be the last arg for this test to work + .addSuffix(vmOptionsPrefix, + "-Xlog:cds", + "-XX:+UseG1GC", "-XX:MaxRAMPercentage=12.5", + "-XX:SharedArchiveFile=./SysDictCrash.jsa", + "-version"); + CDSTestUtils.run(opts) + .assertNormalExit(); } } diff --git a/test/lib/jdk/test/lib/cds/CDSOptions.java b/test/lib/jdk/test/lib/cds/CDSOptions.java index c6667c576d923..2fa949dc4ccc7 100644 --- a/test/lib/jdk/test/lib/cds/CDSOptions.java +++ b/test/lib/jdk/test/lib/cds/CDSOptions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -50,12 +50,23 @@ public CDSOptions addPrefix(String... prefix) { return this; } + public CDSOptions addPrefix(String prefix[], String... extra) { + for (String s : prefix) this.prefix.add(s); + for (String s : extra) this.prefix.add(s); + return this; + } public CDSOptions addSuffix(String... suffix) { for (String s : suffix) this.suffix.add(s); return this; } + public CDSOptions addSuffix(String suffix[], String... extra) { + for (String s : suffix) this.suffix.add(s); + for (String s : extra) this.suffix.add(s); + return this; + } + public CDSOptions setXShareMode(String mode) { this.xShareMode = mode; return this; diff --git a/test/lib/jdk/test/lib/cds/CDSTestUtils.java b/test/lib/jdk/test/lib/cds/CDSTestUtils.java index aa3a13e7172c6..75beb44739640 100644 --- a/test/lib/jdk/test/lib/cds/CDSTestUtils.java +++ b/test/lib/jdk/test/lib/cds/CDSTestUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -387,6 +387,18 @@ public static Result run(CDSOptions opts) throws Exception { return new Result(opts, runWithArchive(opts)); } + // Dump a classlist using the -XX:DumpLoadedClassList option. + public static Result dumpClassList(String classListName, String... cli) + throws Exception { + CDSOptions opts = (new CDSOptions()) + .setUseVersion(false) + .setXShareMode("auto") + .addPrefix("-XX:DumpLoadedClassList=" + classListName) + .addSuffix(cli); + Result res = run(opts).assertNormalExit(); + return res; + } + // Execute JVM with CDS archive, specify command line args suffix public static OutputAnalyzer runWithArchive(String... cliPrefix) throws Exception { From 9880c4cd175b647b0fe813d3d2bae0c3ebfc838b Mon Sep 17 00:00:00 2001 From: "Daniel D. Daugherty" Date: Mon, 1 Feb 2021 22:52:09 +0000 Subject: [PATCH 10/77] 8260860: ProblemList tools/jlink/plugins/CompressorPluginTest.java Reviewed-by: dholmes --- test/jdk/ProblemList.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index 7a30581069245..79fa2ee98a1c7 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -776,6 +776,7 @@ sanity/client/SwingSet/src/ScrollPaneDemoTest.java 8225013 linux-all tools/jlink/JLinkReproducibleTest.java 8217166 windows-all,linux-aarch64 tools/jlink/JLinkReproducible3Test.java 8253688 linux-aarch64 +tools/jlink/plugins/CompressorPluginTest.java 8247407 generic-all ############################################################################ From a6d950587bc68f81495660f59169b7f1970076e7 Mon Sep 17 00:00:00 2001 From: "Daniel D. Daugherty" Date: Mon, 1 Feb 2021 22:53:27 +0000 Subject: [PATCH 11/77] 8260864: ProblemList two security/krb5 tests on Linux Reviewed-by: dholmes --- test/jdk/ProblemList.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index 79fa2ee98a1c7..a1c2a0d204730 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -698,6 +698,8 @@ javax/security/auth/kerberos/KerberosTixDateTest.java 8039280 generic- sun/security/provider/PolicyFile/GrantAllPermToExtWhenNoPolicy.java 8039280 generic-all sun/security/provider/PolicyParser/ExtDirsChange.java 8039280 generic-all sun/security/provider/PolicyParser/PrincipalExpansionError.java 8039280 generic-all +sun/security/krb5/auto/ReplayCacheTestProcWithMD5.java 8258855 linux-all +sun/security/krb5/auto/ReplayCacheTestProc.java 8258855 linux-all ############################################################################ From 54e7a642bba492198ffaca1bf7f39b890801825e Mon Sep 17 00:00:00 2001 From: bobpengxie Date: Tue, 2 Feb 2021 02:16:46 +0000 Subject: [PATCH 12/77] 8260576: Typo in compiler/runtime/safepoints/TestRegisterRestoring.java Reviewed-by: thartmann, jiefu --- .../compiler/runtime/safepoints/TestRegisterRestoring.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/hotspot/jtreg/compiler/runtime/safepoints/TestRegisterRestoring.java b/test/hotspot/jtreg/compiler/runtime/safepoints/TestRegisterRestoring.java index 0a6a308c12637..32c3bda940995 100644 --- a/test/hotspot/jtreg/compiler/runtime/safepoints/TestRegisterRestoring.java +++ b/test/hotspot/jtreg/compiler/runtime/safepoints/TestRegisterRestoring.java @@ -47,7 +47,7 @@ public static void main(String args[]) throws Exception { // Check result for (int i = 0; i < array.length; i++) { if (array[i] != 10_000) { - throw new RuntimeException("Test failed: array[" + i + "] = " + array[i] + " but should be 10.000"); + throw new RuntimeException("Test failed: array[" + i + "] = " + array[i] + " but should be 10,000"); } array[i] = 0; } From 474dba2d8b93b5969a11635820b07c0ceff1836a Mon Sep 17 00:00:00 2001 From: Joe Darcy Date: Tue, 2 Feb 2021 02:33:56 +0000 Subject: [PATCH 13/77] 8257086: Clarify differences between {Float, Double}.equals and == Reviewed-by: smarks, bpb --- .../share/classes/java/lang/Double.java | 173 +++++++++++++----- .../share/classes/java/lang/Float.java | 82 +++++---- 2 files changed, 174 insertions(+), 81 deletions(-) diff --git a/src/java.base/share/classes/java/lang/Double.java b/src/java.base/share/classes/java/lang/Double.java index 36e9086e1c4a1..9d57960d0c7c6 100644 --- a/src/java.base/share/classes/java/lang/Double.java +++ b/src/java.base/share/classes/java/lang/Double.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1994, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1994, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -52,6 +52,101 @@ * use instances for synchronization, or unpredictable behavior may * occur. For example, in a future release, synchronization may fail. * + *

Floating-point Equality, Equivalence, + * and Comparison

+ * + * IEEE 754 floating-point values include finite nonzero values, + * signed zeros ({@code +0.0} and {@code -0.0}), signed infinities + * {@linkplain Double#POSITIVE_INFINITY positive infinity} and + * {@linkplain Double#NEGATIVE_INFINITY negative infinity}), and + * {@linkplain Double#NaN NaN} (not-a-number). + * + *

An equivalence relation on a set of values is a boolean + * relation on pairs of values that is reflexive, symmetric, and + * transitive. For more discussion of equivalence relations and object + * equality, see the {@link Object#equals Object.equals} + * specification. An equivalence relation partitions the values it + * operates over into sets called equivalence classes. All the + * members of the equivalence class are equal to each other under the + * relation. An equivalence class may contain only a single member. At + * least for some purposes, all the members of an equivalence class + * are substitutable for each other. In particular, in a numeric + * expression equivalent values can be substituted for one + * another without changing the result of the expression, meaning + * changing the equivalence class of the result of the expression. + * + *

Notably, the built-in {@code ==} operation on floating-point + * values is not an equivalence relation. Despite not + * defining an equivalence relation, the semantics of the IEEE 754 + * {@code ==} operator were deliberately designed to meet other needs + * of numerical computation. There are two exceptions where the + * properties of an equivalence relation are not satisfied by {@code + * ==} on floating-point values: + * + *

    + * + *
  • If {@code v1} and {@code v2} are both NaN, then {@code v1 + * == v2} has the value {@code false}. Therefore, for two NaN + * arguments the reflexive property of an equivalence + * relation is not satisfied by the {@code ==} operator. + * + *
  • If {@code v1} represents {@code +0.0} while {@code v2} + * represents {@code -0.0}, or vice versa, then {@code v1 == v2} has + * the value {@code true} even though {@code +0.0} and {@code -0.0} + * are distinguishable under various floating-point operations. For + * example, {@code 1.0/+0.0} evaluates to positive infinity while + * {@code 1.0/-0.0} evaluates to negative infinity and + * positive infinity and negative infinity are neither equal to each + * other nor equivalent to each other. Thus, while a signed zero input + * most commonly determines the sign of a zero result, because of + * dividing by zero, {@code +0.0} and {@code -0.0} may not be + * substituted for each other in general. The sign of a zero input + * also has a non-substitutable effect on the result of some math + * library methods. + * + *
+ * + *

For ordered comparisons using the built-in comparison operators + * ({@code <}, {@code <=}, etc.), NaN values have another anomalous + * situation: a NaN is neither less than, nor greater than, nor equal + * to any value, including itself. This means the trichotomy of + * comparison does not hold. + * + *

To provide the appropriate semantics for {@code equals} and + * {@code compareTo} methods, those methods cannot simply be wrappers + * around {@code ==} or ordered comparison operations. Instead, {@link + * Double#equals equals} defines NaN arguments to be equal to each + * other and defines {@code +0.0} to not be equal to {@code + * -0.0}, restoring reflexivity. For comparisons, {@link + * Double#compareTo compareTo} defines a total order where {@code + * -0.0} is less than {@code +0.0} and where a NaN is equal to itself + * and considered greater than positive infinity. + * + *

The operational semantics of {@code equals} and {@code + * compareTo} are expressed in terms of {@linkplain #doubleToLongBits + * bit-wise converting} the floating-point values to integral values. + * + *

The natural ordering implemented by {@link #compareTo + * compareTo} is {@linkplain Comparable consistent with equals}. That + * is, two objects are reported as equal by {@code equals} if and only + * if {@code compareTo} on those objects returns zero. + * + *

The adjusted behaviors defined for {@code equals} and {@code + * compareTo} allow instances of wrapper classes to work properly with + * conventional data structures. For example, defining NaN + * values to be {@code equals} to one another allows NaN to be used as + * an element of a {@link java.util.HashSet HashSet} or as the key of + * a {@link java.util.HashMap HashMap}. Similarly, defining {@code + * compareTo} as a total ordering, including {@code +0.0}, {@code + * -0.0}, and NaN, allows instances of wrapper classes to be used as + * elements of a {@link java.util.SortedSet SortedSet} or as keys of a + * {@link java.util.SortedMap SortedMap}. + * + * @jls 4.2.3 Floating-Point Types, Formats, and Values + * @jls 4.2.4. Floating-Point Operations + * @jls 15.21.1 Numerical Equality Operators == and != + * @jls 15.20.1 Numerical Comparison Operators {@code <}, {@code <=}, {@code >}, and {@code >=} + * * @author Lee Boynton * @author Arthur van Hoff * @author Joseph D. Darcy @@ -797,33 +892,18 @@ public static int hashCode(double value) { * #doubleToLongBits(double)} returns the identical * {@code long} value when applied to each. * - *

Note that in most cases, for two instances of class - * {@code Double}, {@code d1} and {@code d2}, the - * value of {@code d1.equals(d2)} is {@code true} if and - * only if - * - *

- * {@code d1.doubleValue() == d2.doubleValue()} - *
+ * @apiNote + * This method is defined in terms of {@link + * #doubleToLongBits(double)} rather than the {@code ==} operator + * on {@code double} values since the {@code ==} operator does + * not define an equivalence relation and to satisfy the + * {@linkplain Object#equals equals contract} an equivalence + * relation must be implemented; see this discussion for details of + * floating-point equality and equivalence. * - *

also has the value {@code true}. However, there are two - * exceptions: - *

    - *
  • If {@code d1} and {@code d2} both represent - * {@code Double.NaN}, then the {@code equals} method - * returns {@code true}, even though - * {@code Double.NaN==Double.NaN} has the value - * {@code false}. - *
  • If {@code d1} represents {@code +0.0} while - * {@code d2} represents {@code -0.0}, or vice versa, - * the {@code equal} test has the value {@code false}, - * even though {@code +0.0==-0.0} has the value {@code true}. - *
- * This definition allows hash tables to operate properly. - * @param obj the object to compare with. - * @return {@code true} if the objects are the same; - * {@code false} otherwise. * @see java.lang.Double#doubleToLongBits(double) + * @jls 15.21.1 Numerical Equality Operators == and != */ public boolean equals(Object obj) { return (obj instanceof Double) @@ -975,23 +1055,31 @@ public static long doubleToLongBits(double value) { public static native double longBitsToDouble(long bits); /** - * Compares two {@code Double} objects numerically. There - * are two ways in which comparisons performed by this method - * differ from those performed by the Java language numerical - * comparison operators ({@code <, <=, ==, >=, >}) - * when applied to primitive {@code double} values: - *
  • - * {@code Double.NaN} is considered by this method - * to be equal to itself and greater than all other - * {@code double} values (including - * {@code Double.POSITIVE_INFINITY}). - *
  • - * {@code 0.0d} is considered by this method to be greater - * than {@code -0.0d}. + * Compares two {@code Double} objects numerically. + * + * This method imposes a total order on {@code Double} objects + * with two differences compared to the incomplete order defined by + * the Java language numerical comparison operators ({@code <, <=, + * ==, >=, >}) on {@code double} values. + * + *
    • A NaN is unordered with respect to other + * values and unequal to itself under the comparison + * operators. This method chooses to define {@code + * Double.NaN} to be equal to itself and greater than all + * other {@code double} values (including {@code + * Double.POSITIVE_INFINITY}). + * + *
    • Positive zero and negative zero compare equal + * numerically, but are distinct and distinguishable values. + * This method chooses to define positive zero ({@code +0.0d}), + * to be greater than negative zero ({@code -0.0d}). *
    - * This ensures that the natural ordering of - * {@code Double} objects imposed by this method is consistent - * with equals. + + * This ensures that the natural ordering of {@code Double} + * objects imposed by this method is consistent with + * equals; see this + * discussion for details of floating-point comparison and + * ordering. * * @param anotherDouble the {@code Double} to be compared. * @return the value {@code 0} if {@code anotherDouble} is @@ -1002,6 +1090,7 @@ public static long doubleToLongBits(double value) { * {@code Double} is numerically greater than * {@code anotherDouble}. * + * @jls 15.20.1 Numerical Comparison Operators {@code <}, {@code <=}, {@code >}, and {@code >=} * @since 1.2 */ public int compareTo(Double anotherDouble) { diff --git a/src/java.base/share/classes/java/lang/Float.java b/src/java.base/share/classes/java/lang/Float.java index 478b5a27a7b1c..eef80b1c46dd5 100644 --- a/src/java.base/share/classes/java/lang/Float.java +++ b/src/java.base/share/classes/java/lang/Float.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1994, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1994, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -51,6 +51,14 @@ * use instances for synchronization, or unpredictable behavior may * occur. For example, in a future release, synchronization may fail. * + *

    Floating-point Equality, Equivalence, + * and Comparison

    + * + * The class {@code java.lang.Double} has a discussion of equality, + * equivalence, and comparison of floating-point values that is + * equality applicable to {@code float} values. + * * @author Lee Boynton * @author Arthur van Hoff * @author Joseph D. Darcy @@ -711,33 +719,21 @@ public static int hashCode(float value) { * returns the identical {@code int} value when applied to * each. * - *

    Note that in most cases, for two instances of class - * {@code Float}, {@code f1} and {@code f2}, the value - * of {@code f1.equals(f2)} is {@code true} if and only if - * - *

    -     *   f1.floatValue() == f2.floatValue()
    -     * 
    - * - *

    also has the value {@code true}. However, there are two exceptions: - *

      - *
    • If {@code f1} and {@code f2} both represent - * {@code Float.NaN}, then the {@code equals} method returns - * {@code true}, even though {@code Float.NaN==Float.NaN} - * has the value {@code false}. - *
    • If {@code f1} represents {@code +0.0f} while - * {@code f2} represents {@code -0.0f}, or vice - * versa, the {@code equal} test has the value - * {@code false}, even though {@code 0.0f==-0.0f} - * has the value {@code true}. - *
    - * - * This definition allows hash tables to operate properly. + * @apiNote + * This method is defined in terms of {@link + * #floatToIntBits(float)} rather than the {@code ==} operator on + * {@code float} values since the {@code ==} operator does + * not define an equivalence relation and to satisfy the + * {@linkplain Object#equals equals contract} an equivalence + * relation must be implemented; see this discussion for + * details of floating-point equality and equivalence. * * @param obj the object to be compared * @return {@code true} if the objects are the same; * {@code false} otherwise. * @see java.lang.Float#floatToIntBits(float) + * @jls 15.21.1 Numerical Equality Operators == and != */ public boolean equals(Object obj) { return (obj instanceof Float) @@ -884,24 +880,32 @@ public static int floatToIntBits(float value) { public static native float intBitsToFloat(int bits); /** - * Compares two {@code Float} objects numerically. There are - * two ways in which comparisons performed by this method differ - * from those performed by the Java language numerical comparison - * operators ({@code <, <=, ==, >=, >}) when - * applied to primitive {@code float} values: - * - *
    • - * {@code Float.NaN} is considered by this method to - * be equal to itself and greater than all other - * {@code float} values - * (including {@code Float.POSITIVE_INFINITY}). - *
    • - * {@code 0.0f} is considered by this method to be greater - * than {@code -0.0f}. + * Compares two {@code Float} objects numerically. + * + * This method imposes a total order on {@code Float} objects + * with two differences compared to the incomplete order defined by + * the Java language numerical comparison operators ({@code <, <=, + * ==, >=, >}) on {@code float} values. + * + *
      • A NaN is unordered with respect to other + * values and unequal to itself under the comparison + * operators. This method chooses to define {@code + * Float.NaN} to be equal to itself and greater than all + * other {@code double} values (including {@code + * Float.POSITIVE_INFINITY}). + * + *
      • Positive zero and negative zero compare equal + * numerically, but are distinct and distinguishable values. + * This method chooses to define positive zero ({@code +0.0f}), + * to be greater than negative zero ({@code -0.0f}). *
      * * This ensures that the natural ordering of {@code Float} - * objects imposed by this method is consistent with equals. + * objects imposed by this method is consistent with + * equals; see this + * discussion for details of floating-point comparison and + * ordering. + * * * @param anotherFloat the {@code Float} to be compared. * @return the value {@code 0} if {@code anotherFloat} is @@ -912,8 +916,8 @@ public static int floatToIntBits(float value) { * {@code Float} is numerically greater than * {@code anotherFloat}. * + * @jls 15.20.1 Numerical Comparison Operators {@code <}, {@code <=}, {@code >}, and {@code >=} * @since 1.2 - * @see Comparable#compareTo(Object) */ public int compareTo(Float anotherFloat) { return Float.compare(value, anotherFloat.value); From fe407cf1b617cc748d098cbb4685ec7261a3e8a8 Mon Sep 17 00:00:00 2001 From: Tobias Hartmann Date: Tue, 2 Feb 2021 07:23:55 +0000 Subject: [PATCH 14/77] 8260420: C2 compilation fails with assert(found_sfpt) failed: no node in loop that's not input to safepoint Reviewed-by: kvn, roland, chagedorn --- src/hotspot/share/opto/loopopts.cpp | 33 ++++++--- ...TestSplitIfPinnedLoadInStripMinedLoop.java | 73 ++++++++++++++++++- 2 files changed, 90 insertions(+), 16 deletions(-) diff --git a/src/hotspot/share/opto/loopopts.cpp b/src/hotspot/share/opto/loopopts.cpp index cc1f955b335c8..8f2ee6a85dd1d 100644 --- a/src/hotspot/share/opto/loopopts.cpp +++ b/src/hotspot/share/opto/loopopts.cpp @@ -1430,6 +1430,7 @@ void PhaseIdealLoop::split_if_with_blocks_post(Node *n) { // control, then the cloning of n is a pointless exercise, because // GVN will ensure that we end up where we started. if (!n->is_Load() || late_load_ctrl != n_ctrl) { + Node* outer_loop_clone = NULL; for (DUIterator_Last jmin, j = n->last_outs(jmin); j >= jmin; ) { Node *u = n->last_out(j); // Clone private computation per use _igvn.rehash_node_delayed(u); @@ -1477,16 +1478,25 @@ void PhaseIdealLoop::split_if_with_blocks_post(Node *n) { IdealLoopTree* x_loop = get_loop(x_ctrl); Node* x_head = x_loop->_head; - if (x_head->is_Loop() && (x_head->is_OuterStripMinedLoop() || x_head->as_Loop()->is_strip_mined()) && is_dominator(n_ctrl, x_head)) { - // Anti dependence analysis is sometimes too - // conservative: a store in the outer strip mined loop - // can prevent a load from floating out of the outer - // strip mined loop but the load may not be referenced - // from the safepoint: loop strip mining verification - // code reports a problem in that case. Make sure the - // load is not moved in the outer strip mined loop in - // that case. - x_ctrl = x_head->as_Loop()->skip_strip_mined()->in(LoopNode::EntryControl); + if (x_head->is_Loop() && (x_head->is_OuterStripMinedLoop() || x_head->as_Loop()->is_strip_mined())) { + if (is_dominator(n_ctrl, x_head)) { + // Anti dependence analysis is sometimes too + // conservative: a store in the outer strip mined loop + // can prevent a load from floating out of the outer + // strip mined loop but the load may not be referenced + // from the safepoint: loop strip mining verification + // code reports a problem in that case. Make sure the + // load is not moved in the outer strip mined loop in + // that case. + x_ctrl = x_head->as_Loop()->skip_strip_mined()->in(LoopNode::EntryControl); + } else if (x_head->is_OuterStripMinedLoop()) { + // Do not add duplicate LoadNodes to the outer strip mined loop + if (outer_loop_clone != NULL) { + _igvn.replace_node(x, outer_loop_clone); + continue; + } + outer_loop_clone = x; + } } assert(dom_depth(n_ctrl) <= dom_depth(x_ctrl), "n is later than its clone"); @@ -1503,8 +1513,7 @@ void PhaseIdealLoop::split_if_with_blocks_post(Node *n) { // to fold a StoreP and an AddP together (as part of an // address expression) and the AddP and StoreP have // different controls. - BarrierSetC2* bs = BarrierSet::barrier_set()->barrier_set_c2(); - if (!x->is_Load() && !x->is_DecodeNarrowPtr() && !x->is_AddP() && !bs->is_gc_barrier_node(x)) { + if (!x->is_Load() && !x->is_DecodeNarrowPtr()) { _igvn._worklist.yank(x); } } diff --git a/test/hotspot/jtreg/compiler/loopopts/TestSplitIfPinnedLoadInStripMinedLoop.java b/test/hotspot/jtreg/compiler/loopopts/TestSplitIfPinnedLoadInStripMinedLoop.java index fb6a2996edbc1..839413fe13557 100644 --- a/test/hotspot/jtreg/compiler/loopopts/TestSplitIfPinnedLoadInStripMinedLoop.java +++ b/test/hotspot/jtreg/compiler/loopopts/TestSplitIfPinnedLoadInStripMinedLoop.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,8 @@ /* * @test - * @bug 8249607 + * @bug 8249607 8260420 + * @library /test/lib * @summary A LoadNode is pinned in split_if_with_blocks_post() on a loop exit node x that is part of a strip mined loop. It has a late control y outside the outer strip mined loop. After pre-main-post, the dominator chain of y does not include x anymore resulting in an assertion failure. * @run main/othervm -Xbatch -XX:CompileCommand=compileonly,compiler.loopopts.TestSplitIfPinnedLoadInStripMinedLoop::* @@ -31,6 +32,8 @@ */ package compiler.loopopts; +import jdk.test.lib.Asserts; + public class TestSplitIfPinnedLoadInStripMinedLoop { public boolean bFld = false; @@ -39,7 +42,7 @@ public class TestSplitIfPinnedLoadInStripMinedLoop { public static float fFld= 6.0f; public static int iArrFld[] = new int[400]; - public void test() { + public void test1() { int x = 7; int y = 8; int a = 9; @@ -97,10 +100,72 @@ public void test() { } } } + + static class MyClass { + int x = 42; + } + + int res = 0; + + // The obj1.x load has two uses: The 'res' store and the return. After cloning, both loads end up in the + // OuterStripMinedLoop which triggers an assert in LoopNode::verify_strip_mined: + // assert(found_sfpt) failed: no node in loop that's not input to safepoint + int test2(MyClass obj1, MyClass obj2) { + for (int i = 0; i < 10; ++i) { + for (int j = 0; j < 10; ++j) { + obj2.x = 42; // Prevents obj1.x load from floating up because obj2 could alias obj1 + res = obj1.x; + } + for (int j = 0; j < 10_000; ++j) { + } + } + return res; + } + + // Same as test2 but with reference to outer loop induction variable 'i' and different order of instructions. + // Triggers an assert in PhaseIdealLoop::build_loop_late_post_work if loop strip mining verification is disabled: + // assert(false) failed: Bad graph detected in build_loop_late + int test3(MyClass obj1, MyClass obj2) { + for (int i = 0; i < 10; ++i) { + for (int j = 0; j < 10; ++j) { + res = obj1.x + i; + obj2.x = 42; + } + for (int j = 0; j < 10_000; ++j) { + } + } + return res; + } + + // Same as test2 but with reference to inner loop induction variable 'j' and different order of instructions. + // Triggers an assert in PhaseCFG::insert_anti_dependences if loop strip mining verification is disabled: + // assert(!LCA_orig->dominates(pred_block) || early->dominates(pred_block)) failed: early is high enough + int test4(MyClass obj1, MyClass obj2) { + for (int i = 0; i < 10; ++i) { + for (int j = 0; j < 10; ++j) { + res = obj1.x + j; + obj2.x = 42; + } + for (int j = 0; j < 10_000; ++j) { + } + } + return res; + } + public static void main(String[] strArr) { TestSplitIfPinnedLoadInStripMinedLoop t = new TestSplitIfPinnedLoadInStripMinedLoop(); + MyClass obj = new MyClass(); for (int i = 0; i < 10; i++) { - t.test(); + t.test1(); + int res = t.test2(obj, obj); + Asserts.assertEquals(res, t.res); + Asserts.assertEquals(res, 42); + res = t.test3(obj, obj); + Asserts.assertEquals(res, t.res); + Asserts.assertEquals(res, 51); + res = t.test4(obj, obj); + Asserts.assertEquals(res, t.res); + Asserts.assertEquals(res, 51); } } } From ddd2951ba91fe3860b92d2f9bad4e0d900f1d650 Mon Sep 17 00:00:00 2001 From: Thomas Stuefe Date: Tue, 2 Feb 2021 07:36:09 +0000 Subject: [PATCH 15/77] 8260571: Add PrintMetaspaceStatistics to print metaspace statistics upon VM exit Reviewed-by: iklam --- src/hotspot/share/runtime/globals.hpp | 3 +++ src/hotspot/share/runtime/java.cpp | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/src/hotspot/share/runtime/globals.hpp b/src/hotspot/share/runtime/globals.hpp index efeb7359b0343..f3a8fa00a355f 100644 --- a/src/hotspot/share/runtime/globals.hpp +++ b/src/hotspot/share/runtime/globals.hpp @@ -1490,6 +1490,9 @@ const intx ObjectAlignmentInBytes = 8; product(ccstr, MetaspaceReclaimPolicy, "balanced", \ "options: balanced, aggressive, none") \ \ + product(bool, PrintMetaspaceStatisticsAtExit, false, DIAGNOSTIC, \ + "Print metaspace statistics upon VM exit.") \ + \ product(bool, MetaspaceGuardAllocations, false, DIAGNOSTIC, \ "Metapace allocations are guarded.") \ \ diff --git a/src/hotspot/share/runtime/java.cpp b/src/hotspot/share/runtime/java.cpp index 40b1d993cddde..bc372c0bcafbc 100644 --- a/src/hotspot/share/runtime/java.cpp +++ b/src/hotspot/share/runtime/java.cpp @@ -328,6 +328,10 @@ void print_statistics() { MemTracker::final_report(tty); } + if (PrintMetaspaceStatisticsAtExit) { + MetaspaceUtils::print_basic_report(tty, 0); + } + ThreadsSMRSupport::log_statistics(); } @@ -370,6 +374,10 @@ void print_statistics() { MemTracker::final_report(tty); } + if (PrintMetaspaceStatisticsAtExit) { + MetaspaceUtils::print_basic_report(tty, 0); + } + if (LogTouchedMethods && PrintTouchedMethodsAtExit) { Method::print_touched_methods(tty); } From ed1a7755c3cf3bc58a7e7a0a2aed52cc0ae75023 Mon Sep 17 00:00:00 2001 From: Magnus Ihse Bursie Date: Tue, 2 Feb 2021 07:41:48 +0000 Subject: [PATCH 16/77] 8258378: Final nroff manpage update for JDK 16 Reviewed-by: erikj, dholmes --- src/java.base/share/man/java.1 | 204 +++++++++++----------- src/java.base/share/man/keytool.1 | 2 +- src/java.rmi/share/man/rmid.1 | 2 +- src/java.rmi/share/man/rmiregistry.1 | 2 +- src/java.scripting/share/man/jrunscript.1 | 2 +- src/jdk.compiler/share/man/javac.1 | 2 +- src/jdk.compiler/share/man/serialver.1 | 2 +- src/jdk.hotspot.agent/share/man/jhsdb.1 | 2 +- src/jdk.jartool/share/man/jar.1 | 2 +- src/jdk.jartool/share/man/jarsigner.1 | 11 +- src/jdk.javadoc/share/man/javadoc.1 | 4 +- src/jdk.jcmd/share/man/jcmd.1 | 2 +- src/jdk.jcmd/share/man/jinfo.1 | 2 +- src/jdk.jcmd/share/man/jmap.1 | 2 +- src/jdk.jcmd/share/man/jps.1 | 2 +- src/jdk.jcmd/share/man/jstack.1 | 2 +- src/jdk.jcmd/share/man/jstat.1 | 2 +- src/jdk.jconsole/share/man/jconsole.1 | 2 +- src/jdk.jdeps/share/man/javap.1 | 2 +- src/jdk.jdeps/share/man/jdeprscan.1 | 2 +- src/jdk.jdeps/share/man/jdeps.1 | 2 +- src/jdk.jdi/share/man/jdb.1 | 2 +- src/jdk.jfr/share/man/jfr.1 | 2 +- src/jdk.jlink/share/man/jlink.1 | 2 +- src/jdk.jlink/share/man/jmod.1 | 2 +- src/jdk.jshell/share/man/jshell.1 | 2 +- src/jdk.jstatd/share/man/jstatd.1 | 2 +- 27 files changed, 127 insertions(+), 140 deletions(-) diff --git a/src/java.base/share/man/java.1 b/src/java.base/share/man/java.1 index fd78f50e1567d..9d8cfd79fe557 100644 --- a/src/java.base/share/man/java.1 +++ b/src/java.base/share/man/java.1 @@ -22,7 +22,7 @@ .\"t .\" Automatically generated by Pandoc 2.3.1 .\" -.TH "JAVA" "1" "2020" "JDK 16" "JDK Commands" +.TH "JAVA" "1" "2021" "JDK 16" "JDK Commands" .hy .SH NAME .PP @@ -1120,72 +1120,6 @@ Updates \f[I]module\f[R] to open \f[I]package\f[R] to .RS .RE .TP -.B \f[CB]\-\-illegal\-access=\f[R]\f[I]parameter\f[R] -When present at run time, \f[CB]\-\-illegal\-access=\f[R] takes a keyword -\f[I]parameter\f[R] to specify a mode of operation: -.RS -.RS -.PP -\f[B]Note:\f[R] This option will be removed in a future release. -.RE -.IP \[bu] 2 -\f[CB]permit\f[R]: This mode opens each package in each module in the -run\-time image to code in all unnamed modules ( such as code on the -class path), if that package existed in JDK 8. -This enables both static access, (for example, by compiled bytecode, and -deep reflective access) through the platform\[aq]s various reflection -APIs. -The first reflective\-access operation to any such package causes a -warning to be issued. -However, no warnings are issued after the first occurrence. -This single warning describes how to enable further warnings. -This mode is the default for the current JDK but will change in a future -release. -.IP \[bu] 2 -\f[CB]warn\f[R]: This mode is identical to \f[CB]permit\f[R] except that a -warning message is issued for each illegal reflective\-access operation. -.IP \[bu] 2 -\f[CB]debug\f[R]: This mode is identical to \f[CB]warn\f[R] except that both -a warning message and a stack trace are issued for each illegal -reflective\-access operation. -.IP \[bu] 2 -\f[CB]deny\f[R]: This mode disables all illegal\-access operations except -for those enabled by other command\-line options, such as -\f[CB]\-\-add\-opens\f[R]. -This mode will become the default in a future release. -.PP -The default mode, \f[CB]\-\-illegal\-access=permit\f[R], is intended to -make you aware of code on the class path that reflectively accesses any -JDK\-internal APIs at least once. -To learn about all such accesses, you can use the \f[CB]warn\f[R] or the -\f[CB]debug\f[R] modes. -For each library or framework on the class path that requires illegal -access, you have two options: -.IP \[bu] 2 -If the component\[aq]s maintainers have already released a fixed version -that no longer uses JDK\-internal APIs then you can consider upgrading -to that version. -.IP \[bu] 2 -If the component still needs to be fixed, then you can contact its -maintainers and ask them to replace their use of JDK\-internal APIs with -the proper exported APIs. -.PP -If you must continue to use a component that requires illegal access, -then you can eliminate the warning messages by using one or more -\f[CB]\-\-add\-opens\f[R] options to open only those internal packages to -which access is required. -.PP -To verify that your application is ready for a future version of the -JDK, run it with \f[CB]\-\-illegal\-access=deny\f[R] along with any -necessary \f[CB]\-\-add\-opens\f[R] options. -Any remaining illegal\-access errors will most likely be due to static -references from compiled code to JDK\-internal APIs. -You can identify those by running the \f[B]jdeps\f[R] tool with the -\f[CB]\-\-jdk\-internals\f[R] option. -For performance reasons, the current JDK does not issue warnings for -illegal static\-access operations. -.RE -.TP .B \f[CB]\-\-limit\-modules\f[R] \f[I]module\f[R][\f[CB],\f[R]\f[I]module\f[R]...] Specifies the limit of the universe of observable modules. .RS @@ -3937,6 +3871,68 @@ future JDK release. They\[aq]re still accepted and acted upon, but a warning is issued when they\[aq]re used. .TP +.B \f[CB]\-\-illegal\-access=\f[R]\f[I]parameter\f[R] +When present at run time, \f[CB]\-\-illegal\-access=\f[R] takes a keyword +\f[I]parameter\f[R] to specify a mode of operation: +.RS +.RS +.PP +\f[B]Note:\f[R] This option will be removed in a future release. +.RE +.IP \[bu] 2 +\f[CB]permit\f[R]: This mode opens each package in each module in the +run\-time image to code in all unnamed modules ( such as code on the +class path), if that package existed in JDK 8. +This enables both static access, (for example, by compiled bytecode, and +deep reflective access) through the platform\[aq]s various reflection +APIs. +The first reflective\-access operation to any such package causes a +warning to be issued. +However, no warnings are issued after the first occurrence. +This single warning describes how to enable further warnings. +.IP \[bu] 2 +\f[CB]warn\f[R]: This mode is identical to \f[CB]permit\f[R] except that a +warning message is issued for each illegal reflective\-access operation. +.IP \[bu] 2 +\f[CB]debug\f[R]: This mode is identical to \f[CB]warn\f[R] except that both +a warning message and a stack trace are issued for each illegal +reflective\-access operation. +.IP \[bu] 2 +\f[CB]deny\f[R]: This mode disables all illegal\-access operations except +for those enabled by other command\-line options, such as +\f[CB]\-\-add\-opens\f[R]. +This mode is the default. +.PP +If your application does not work with the default mode of +\f[CB]\-\-illegal\-access=deny\f[R] then you can learn more about what is +going on with the \f[CB]warn\f[R] and \f[CB]debug\f[R] modes. +For each library or framework on the class path that requires illegal +access, you have two options: +.IP \[bu] 2 +If the component\[aq]s maintainers have already released a fixed version +that no longer uses JDK\-internal APIs then you can consider upgrading +to that version. +.IP \[bu] 2 +If the component still needs to be fixed, then you can contact its +maintainers and ask them to replace their use of JDK\-internal APIs with +the proper exported APIs. +.PP +If you must continue to use a component that requires illegal access, +then you can eliminate the warning messages by using one or more +\f[CB]\-\-add\-opens\f[R] options to open only those internal packages to +which access is required. +.PP +To verify that your application is ready for a future version of the +JDK, run it with \f[CB]\-\-illegal\-access=deny\f[R] along with any +necessary \f[CB]\-\-add\-opens\f[R] options. +Any remaining illegal\-access errors will most likely be due to static +references from compiled code to JDK\-internal APIs. +You can identify those by running the \f[B]jdeps\f[R] tool with the +\f[CB]\-\-jdk\-internals\f[R] option. +For performance reasons, the current JDK does not issue warnings for +illegal static\-access operations. +.RE +.TP .B \f[CB]\-Xfuture\f[R] Enables strict class\-file format checks that enforce close conformance to the class\-file format specification. @@ -4006,6 +4002,42 @@ The default value is 2. Use the option \f[CB]\-XX:MinRAMPercentage\f[R] instead. .RE .TP +.B \f[CB]\-XX:+UseBiasedLocking\f[R] +Enables the use of biased locking. +Some applications with significant amounts of uncontended +synchronization may attain significant speedups with this flag enabled, +but applications with certain patterns of locking may see slowdowns. +.RS +.PP +By default, this option is disabled. +.RE +.SH OBSOLETE JAVA OPTIONS +.PP +These \f[CB]java\f[R] options are still accepted but ignored, and a +warning is issued when they\[aq]re used. +.TP +.B \f[CB]\-XX:+UseMembar\f[R] +Enabled issuing membars on thread\-state transitions. +This option was disabled by default on all platforms except ARM servers, +where it was enabled. +.RS +.RE +.TP +.B \f[CB]\-XX:MaxPermSize=\f[R]\f[I]size\f[R] +Sets the maximum permanent generation space size (in bytes). +This option was deprecated in JDK 8 and superseded by the +\f[CB]\-XX:MaxMetaspaceSize\f[R] option. +.RS +.RE +.TP +.B \f[CB]\-XX:PermSize=\f[R]\f[I]size\f[R] +Sets the space (in bytes) allocated to the permanent generation that +triggers a garbage collection if it\[aq]s exceeded. +This option was deprecated in JDK 8 and superseded by the +\f[CB]\-XX:MetaspaceSize\f[R] option. +.RS +.RE +.TP .B \f[CB]\-XX:+TraceClassLoading\f[R] Enables tracing of classes as they are loaded. By default, this option is disabled and classes aren\[aq]t traced. @@ -4053,45 +4085,9 @@ The replacement Unified Logging syntax is \f[CB]\-Xlog:class+loader+constraints=info\f[R]. See \f[B]Enable Logging with the JVM Unified Logging Framework\f[R]. .RE -.TP -.B \f[CB]\-XX:+UseBiasedLocking\f[R] -Enables the use of biased locking. -Some applications with significant amounts of uncontended -synchronization may attain significant speedups with this flag enabled, -but applications with certain patterns of locking may see slowdowns. -.RS -.PP -By default, this option is disabled. -.RE -.SH OBSOLETE JAVA OPTIONS -.PP -These \f[CB]java\f[R] options are still accepted but ignored, and a -warning is issued when they\[aq]re used. -.TP -.B \f[CB]\-XX:+UseMembar\f[R] -Enabled issuing membars on thread\-state transitions. -This option was disabled by default on all platforms except ARM servers, -where it was enabled. -.RS -.RE -.TP -.B \f[CB]\-XX:MaxPermSize=\f[R]\f[I]size\f[R] -Sets the maximum permanent generation space size (in bytes). -This option was deprecated in JDK 8 and superseded by the -\f[CB]\-XX:MaxMetaspaceSize\f[R] option. -.RS -.RE -.TP -.B \f[CB]\-XX:PermSize=\f[R]\f[I]size\f[R] -Sets the space (in bytes) allocated to the permanent generation that -triggers a garbage collection if it\[aq]s exceeded. -This option was deprecated in JDK 8 and superseded by the -\f[CB]\-XX:MetaspaceSize\f[R] option. -.RS -.RE .SH REMOVED JAVA OPTIONS .PP -These \f[CB]java\f[R] options have been removed in JDK 15 and using them +These \f[CB]java\f[R] options have been removed in JDK 16 and using them results in an error of: .RS .PP diff --git a/src/java.base/share/man/keytool.1 b/src/java.base/share/man/keytool.1 index 8067f45fdd290..26fa9a4483b31 100644 --- a/src/java.base/share/man/keytool.1 +++ b/src/java.base/share/man/keytool.1 @@ -22,7 +22,7 @@ .\"t .\" Automatically generated by Pandoc 2.3.1 .\" -.TH "KEYTOOL" "1" "2020" "JDK 16" "JDK Commands" +.TH "KEYTOOL" "1" "2021" "JDK 16" "JDK Commands" .hy .SH NAME .PP diff --git a/src/java.rmi/share/man/rmid.1 b/src/java.rmi/share/man/rmid.1 index 45e75ef4a7ff3..a2e90aa33ba81 100644 --- a/src/java.rmi/share/man/rmid.1 +++ b/src/java.rmi/share/man/rmid.1 @@ -21,7 +21,7 @@ .\" .\" Automatically generated by Pandoc 2.3.1 .\" -.TH "RMID" "1" "2020" "JDK 16" "JDK Commands" +.TH "RMID" "1" "2021" "JDK 16" "JDK Commands" .hy .SH NAME .PP diff --git a/src/java.rmi/share/man/rmiregistry.1 b/src/java.rmi/share/man/rmiregistry.1 index 9e33a66e5c51f..9bb958cedc191 100644 --- a/src/java.rmi/share/man/rmiregistry.1 +++ b/src/java.rmi/share/man/rmiregistry.1 @@ -21,7 +21,7 @@ .\" .\" Automatically generated by Pandoc 2.3.1 .\" -.TH "RMIREGISTRY" "1" "2020" "JDK 16" "JDK Commands" +.TH "RMIREGISTRY" "1" "2021" "JDK 16" "JDK Commands" .hy .SH NAME .PP diff --git a/src/java.scripting/share/man/jrunscript.1 b/src/java.scripting/share/man/jrunscript.1 index 627555c93cef2..9bc5e4bfb63d2 100644 --- a/src/java.scripting/share/man/jrunscript.1 +++ b/src/java.scripting/share/man/jrunscript.1 @@ -21,7 +21,7 @@ .\" .\" Automatically generated by Pandoc 2.3.1 .\" -.TH "JRUNSCRIPT" "1" "2020" "JDK 16" "JDK Commands" +.TH "JRUNSCRIPT" "1" "2021" "JDK 16" "JDK Commands" .hy .SH NAME .PP diff --git a/src/jdk.compiler/share/man/javac.1 b/src/jdk.compiler/share/man/javac.1 index 1e2b536b35a1e..b6316aba28a88 100644 --- a/src/jdk.compiler/share/man/javac.1 +++ b/src/jdk.compiler/share/man/javac.1 @@ -21,7 +21,7 @@ .\" .\" Automatically generated by Pandoc 2.3.1 .\" -.TH "JAVAC" "1" "2020" "JDK 16" "JDK Commands" +.TH "JAVAC" "1" "2021" "JDK 16" "JDK Commands" .hy .SH NAME .PP diff --git a/src/jdk.compiler/share/man/serialver.1 b/src/jdk.compiler/share/man/serialver.1 index 140b940aad653..c051ec84abeab 100644 --- a/src/jdk.compiler/share/man/serialver.1 +++ b/src/jdk.compiler/share/man/serialver.1 @@ -21,7 +21,7 @@ .\" .\" Automatically generated by Pandoc 2.3.1 .\" -.TH "SERIALVER" "1" "2020" "JDK 16" "JDK Commands" +.TH "SERIALVER" "1" "2021" "JDK 16" "JDK Commands" .hy .SH NAME .PP diff --git a/src/jdk.hotspot.agent/share/man/jhsdb.1 b/src/jdk.hotspot.agent/share/man/jhsdb.1 index c589196466860..5e6700ec25ce2 100644 --- a/src/jdk.hotspot.agent/share/man/jhsdb.1 +++ b/src/jdk.hotspot.agent/share/man/jhsdb.1 @@ -21,7 +21,7 @@ .\" .\" Automatically generated by Pandoc 2.3.1 .\" -.TH "JHSDB" "1" "2020" "JDK 16" "JDK Commands" +.TH "JHSDB" "1" "2021" "JDK 16" "JDK Commands" .hy .SH NAME .PP diff --git a/src/jdk.jartool/share/man/jar.1 b/src/jdk.jartool/share/man/jar.1 index b1861c59330b9..a8077290fc6f7 100644 --- a/src/jdk.jartool/share/man/jar.1 +++ b/src/jdk.jartool/share/man/jar.1 @@ -21,7 +21,7 @@ .\" .\" Automatically generated by Pandoc 2.3.1 .\" -.TH "JAR" "1" "2020" "JDK 16" "JDK Commands" +.TH "JAR" "1" "2021" "JDK 16" "JDK Commands" .hy .SH NAME .PP diff --git a/src/jdk.jartool/share/man/jarsigner.1 b/src/jdk.jartool/share/man/jarsigner.1 index 74001244a9f92..661c62368468f 100644 --- a/src/jdk.jartool/share/man/jarsigner.1 +++ b/src/jdk.jartool/share/man/jarsigner.1 @@ -22,7 +22,7 @@ .\"t .\" Automatically generated by Pandoc 2.3.1 .\" -.TH "JARSIGNER" "1" "2020" "JDK 16" "JDK Commands" +.TH "JARSIGNER" "1" "2021" "JDK 16" "JDK Commands" .hy .SH NAME .PP @@ -960,15 +960,6 @@ incurs higher overhead. .RS .RE .TP -.B \f[CB]\-directsign\f[R] -By default, jarsigner stores the hash of the \f[CB]\&.SF\f[R] file and -possibly other information in a SignerInfo signedAttributes field, and -then calculates the signature on this field. -If this option is set, no SignerInfo signedAttributes field is generated -and the signature is calculated on the \f[CB]\&.SF\f[R] file directly. -.RS -.RE -.TP .B \f[CB]\-sectionsonly\f[R] If the \f[CB]\-sectionsonly\f[R] option appears on the command line, then the \f[CB]\&.SF\f[R] file (signature file) generated when a JAR file is diff --git a/src/jdk.javadoc/share/man/javadoc.1 b/src/jdk.javadoc/share/man/javadoc.1 index 14139d20ef2f1..bdeed2067ee40 100644 --- a/src/jdk.javadoc/share/man/javadoc.1 +++ b/src/jdk.javadoc/share/man/javadoc.1 @@ -21,7 +21,7 @@ .\" .\" Automatically generated by Pandoc 2.3.1 .\" -.TH "JAVADOC" "1" "2020" "JDK 16" "JDK Commands" +.TH "JAVADOC" "1" "2021" "JDK 16" "JDK Commands" .hy .SH NAME .PP @@ -596,7 +596,7 @@ it does, you must enclose the title in quotation marks. Additional quotation marks within the \f[CB]title\f[R] tag must be escaped. For example, -\f[CB]javadoc\ \-header\ "My\ Library
      v1.0"\ com.mypackage.\f[R] +\f[CB]javadoc\ \-doctitle\ "My\ Library
      v1.0"\ com.mypackage.\f[R] .RS .RE .TP diff --git a/src/jdk.jcmd/share/man/jcmd.1 b/src/jdk.jcmd/share/man/jcmd.1 index 5ab057c1453aa..a5773391e82ed 100644 --- a/src/jdk.jcmd/share/man/jcmd.1 +++ b/src/jdk.jcmd/share/man/jcmd.1 @@ -21,7 +21,7 @@ .\" .\" Automatically generated by Pandoc 2.3.1 .\" -.TH "JCMD" "1" "2020" "JDK 16" "JDK Commands" +.TH "JCMD" "1" "2021" "JDK 16" "JDK Commands" .hy .SH NAME .PP diff --git a/src/jdk.jcmd/share/man/jinfo.1 b/src/jdk.jcmd/share/man/jinfo.1 index f7f79ab296ee9..cfbe379b4c656 100644 --- a/src/jdk.jcmd/share/man/jinfo.1 +++ b/src/jdk.jcmd/share/man/jinfo.1 @@ -21,7 +21,7 @@ .\" .\" Automatically generated by Pandoc 2.3.1 .\" -.TH "JINFO" "1" "2020" "JDK 16" "JDK Commands" +.TH "JINFO" "1" "2021" "JDK 16" "JDK Commands" .hy .SH NAME .PP diff --git a/src/jdk.jcmd/share/man/jmap.1 b/src/jdk.jcmd/share/man/jmap.1 index b5284e0f9e03e..4a0dc53d66fe4 100644 --- a/src/jdk.jcmd/share/man/jmap.1 +++ b/src/jdk.jcmd/share/man/jmap.1 @@ -21,7 +21,7 @@ .\" .\" Automatically generated by Pandoc 2.3.1 .\" -.TH "JMAP" "1" "2020" "JDK 16" "JDK Commands" +.TH "JMAP" "1" "2021" "JDK 16" "JDK Commands" .hy .SH NAME .PP diff --git a/src/jdk.jcmd/share/man/jps.1 b/src/jdk.jcmd/share/man/jps.1 index 75acc38ced047..0812a58603b33 100644 --- a/src/jdk.jcmd/share/man/jps.1 +++ b/src/jdk.jcmd/share/man/jps.1 @@ -21,7 +21,7 @@ .\" .\" Automatically generated by Pandoc 2.3.1 .\" -.TH "JPS" "1" "2020" "JDK 16" "JDK Commands" +.TH "JPS" "1" "2021" "JDK 16" "JDK Commands" .hy .SH NAME .PP diff --git a/src/jdk.jcmd/share/man/jstack.1 b/src/jdk.jcmd/share/man/jstack.1 index 98269bcaf8c60..0885ddccfe017 100644 --- a/src/jdk.jcmd/share/man/jstack.1 +++ b/src/jdk.jcmd/share/man/jstack.1 @@ -21,7 +21,7 @@ .\" .\" Automatically generated by Pandoc 2.3.1 .\" -.TH "JSTACK" "1" "2020" "JDK 16" "JDK Commands" +.TH "JSTACK" "1" "2021" "JDK 16" "JDK Commands" .hy .SH NAME .PP diff --git a/src/jdk.jcmd/share/man/jstat.1 b/src/jdk.jcmd/share/man/jstat.1 index 143d3ce8d4ff3..62b1fc98e72ab 100644 --- a/src/jdk.jcmd/share/man/jstat.1 +++ b/src/jdk.jcmd/share/man/jstat.1 @@ -21,7 +21,7 @@ .\" .\" Automatically generated by Pandoc 2.3.1 .\" -.TH "JSTAT" "1" "2020" "JDK 16" "JDK Commands" +.TH "JSTAT" "1" "2021" "JDK 16" "JDK Commands" .hy .SH NAME .PP diff --git a/src/jdk.jconsole/share/man/jconsole.1 b/src/jdk.jconsole/share/man/jconsole.1 index 277cf03443336..940a9d0547100 100644 --- a/src/jdk.jconsole/share/man/jconsole.1 +++ b/src/jdk.jconsole/share/man/jconsole.1 @@ -21,7 +21,7 @@ .\" .\" Automatically generated by Pandoc 2.3.1 .\" -.TH "JCONSOLE" "1" "2020" "JDK 16" "JDK Commands" +.TH "JCONSOLE" "1" "2021" "JDK 16" "JDK Commands" .hy .SH NAME .PP diff --git a/src/jdk.jdeps/share/man/javap.1 b/src/jdk.jdeps/share/man/javap.1 index 3bef06a924e1f..153448b8c6322 100644 --- a/src/jdk.jdeps/share/man/javap.1 +++ b/src/jdk.jdeps/share/man/javap.1 @@ -21,7 +21,7 @@ .\" .\" Automatically generated by Pandoc 2.3.1 .\" -.TH "JAVAP" "1" "2020" "JDK 16" "JDK Commands" +.TH "JAVAP" "1" "2021" "JDK 16" "JDK Commands" .hy .SH NAME .PP diff --git a/src/jdk.jdeps/share/man/jdeprscan.1 b/src/jdk.jdeps/share/man/jdeprscan.1 index 3dd4cd9097e7e..67f46c9edfe1e 100644 --- a/src/jdk.jdeps/share/man/jdeprscan.1 +++ b/src/jdk.jdeps/share/man/jdeprscan.1 @@ -21,7 +21,7 @@ .\" .\" Automatically generated by Pandoc 2.3.1 .\" -.TH "JDEPRSCAN" "1" "2020" "JDK 16" "JDK Commands" +.TH "JDEPRSCAN" "1" "2021" "JDK 16" "JDK Commands" .hy .SH NAME .PP diff --git a/src/jdk.jdeps/share/man/jdeps.1 b/src/jdk.jdeps/share/man/jdeps.1 index 3dd37bd715075..1ca6c7e155bf8 100644 --- a/src/jdk.jdeps/share/man/jdeps.1 +++ b/src/jdk.jdeps/share/man/jdeps.1 @@ -21,7 +21,7 @@ .\" .\" Automatically generated by Pandoc 2.3.1 .\" -.TH "JDEPS" "1" "2020" "JDK 16" "JDK Commands" +.TH "JDEPS" "1" "2021" "JDK 16" "JDK Commands" .hy .SH NAME .PP diff --git a/src/jdk.jdi/share/man/jdb.1 b/src/jdk.jdi/share/man/jdb.1 index 00969b55e4504..eb8cf1bab793e 100644 --- a/src/jdk.jdi/share/man/jdb.1 +++ b/src/jdk.jdi/share/man/jdb.1 @@ -21,7 +21,7 @@ .\" .\" Automatically generated by Pandoc 2.3.1 .\" -.TH "JDB" "1" "2020" "JDK 16" "JDK Commands" +.TH "JDB" "1" "2021" "JDK 16" "JDK Commands" .hy .SH NAME .PP diff --git a/src/jdk.jfr/share/man/jfr.1 b/src/jdk.jfr/share/man/jfr.1 index 0fb8912b6714c..588a3bd45f17a 100644 --- a/src/jdk.jfr/share/man/jfr.1 +++ b/src/jdk.jfr/share/man/jfr.1 @@ -21,7 +21,7 @@ .\" .\" Automatically generated by Pandoc 2.3.1 .\" -.TH "JFR" "1" "2020" "JDK 16" "JDK Commands" +.TH "JFR" "1" "2021" "JDK 16" "JDK Commands" .hy .SH NAME .PP diff --git a/src/jdk.jlink/share/man/jlink.1 b/src/jdk.jlink/share/man/jlink.1 index a782d558b438c..2f4b37d740d91 100644 --- a/src/jdk.jlink/share/man/jlink.1 +++ b/src/jdk.jlink/share/man/jlink.1 @@ -21,7 +21,7 @@ .\" .\" Automatically generated by Pandoc 2.3.1 .\" -.TH "JLINK" "1" "2020" "JDK 16" "JDK Commands" +.TH "JLINK" "1" "2021" "JDK 16" "JDK Commands" .hy .SH NAME .PP diff --git a/src/jdk.jlink/share/man/jmod.1 b/src/jdk.jlink/share/man/jmod.1 index d46f870847850..bfc290f6b7209 100644 --- a/src/jdk.jlink/share/man/jmod.1 +++ b/src/jdk.jlink/share/man/jmod.1 @@ -21,7 +21,7 @@ .\" .\" Automatically generated by Pandoc 2.3.1 .\" -.TH "JMOD" "1" "2020" "JDK 16" "JDK Commands" +.TH "JMOD" "1" "2021" "JDK 16" "JDK Commands" .hy .SH NAME .PP diff --git a/src/jdk.jshell/share/man/jshell.1 b/src/jdk.jshell/share/man/jshell.1 index 01d6a24b30aa9..72b5a5ea12990 100644 --- a/src/jdk.jshell/share/man/jshell.1 +++ b/src/jdk.jshell/share/man/jshell.1 @@ -22,7 +22,7 @@ .\"t .\" Automatically generated by Pandoc 2.3.1 .\" -.TH "JSHELL" "1" "2020" "JDK 16" "JDK Commands" +.TH "JSHELL" "1" "2021" "JDK 16" "JDK Commands" .hy .SH NAME .PP diff --git a/src/jdk.jstatd/share/man/jstatd.1 b/src/jdk.jstatd/share/man/jstatd.1 index 88d3222c36474..4299af9228311 100644 --- a/src/jdk.jstatd/share/man/jstatd.1 +++ b/src/jdk.jstatd/share/man/jstatd.1 @@ -21,7 +21,7 @@ .\" .\" Automatically generated by Pandoc 2.3.1 .\" -.TH "JSTATD" "1" "2020" "JDK 16" "JDK Commands" +.TH "JSTATD" "1" "2021" "JDK 16" "JDK Commands" .hy .SH NAME .PP From 288a4fed3f495e5bb83839564eda7d0c78751d21 Mon Sep 17 00:00:00 2001 From: Thomas Schatzl Date: Tue, 2 Feb 2021 11:01:48 +0000 Subject: [PATCH 17/77] 8260643: Remove parallel version handling in CardTableRS::younger_refs_in_space_iterate() Reviewed-by: ayang, sjohanss --- src/hotspot/share/gc/serial/serialHeap.cpp | 2 +- .../share/gc/shared/cardGeneration.cpp | 4 +- .../share/gc/shared/cardGeneration.hpp | 2 +- src/hotspot/share/gc/shared/cardTableRS.cpp | 92 ++++--------------- src/hotspot/share/gc/shared/cardTableRS.hpp | 19 ++-- src/hotspot/share/gc/shared/space.cpp | 6 +- src/hotspot/share/gc/shared/space.hpp | 6 +- 7 files changed, 31 insertions(+), 100 deletions(-) diff --git a/src/hotspot/share/gc/serial/serialHeap.cpp b/src/hotspot/share/gc/serial/serialHeap.cpp index fb079e1c931f9..2eb39ca3612d0 100644 --- a/src/hotspot/share/gc/serial/serialHeap.cpp +++ b/src/hotspot/share/gc/serial/serialHeap.cpp @@ -98,5 +98,5 @@ void SerialHeap::young_process_roots(OopIterateClosure* root_closure, cld_closure, cld_closure, &mark_code_closure); rem_set()->at_younger_refs_iterate(); - old_gen()->younger_refs_iterate(old_gen_closure, 0); + old_gen()->younger_refs_iterate(old_gen_closure); } diff --git a/src/hotspot/share/gc/shared/cardGeneration.cpp b/src/hotspot/share/gc/shared/cardGeneration.cpp index 4d5cef6f75350..f676b84fcb3cc 100644 --- a/src/hotspot/share/gc/shared/cardGeneration.cpp +++ b/src/hotspot/share/gc/shared/cardGeneration.cpp @@ -307,7 +307,7 @@ void CardGeneration::space_iterate(SpaceClosure* blk, blk->do_space(space()); } -void CardGeneration::younger_refs_iterate(OopIterateClosure* blk, uint n_threads) { +void CardGeneration::younger_refs_iterate(OopIterateClosure* blk) { // Apply "cl->do_oop" to (the address of) (exactly) all the ref fields in // "sp" that point into younger generations. // The iteration is only over objects allocated at the start of the @@ -315,5 +315,5 @@ void CardGeneration::younger_refs_iterate(OopIterateClosure* blk, uint n_threads // not included. HeapWord* gen_boundary = reserved().start(); - _rs->younger_refs_in_space_iterate(space(), gen_boundary, blk, n_threads); + _rs->younger_refs_in_space_iterate(space(), gen_boundary, blk); } diff --git a/src/hotspot/share/gc/shared/cardGeneration.hpp b/src/hotspot/share/gc/shared/cardGeneration.hpp index 97db787ae17c6..7ad58cf2b699c 100644 --- a/src/hotspot/share/gc/shared/cardGeneration.hpp +++ b/src/hotspot/share/gc/shared/cardGeneration.hpp @@ -89,7 +89,7 @@ class CardGeneration: public Generation { void space_iterate(SpaceClosure* blk, bool usedOnly = false); - void younger_refs_iterate(OopIterateClosure* blk, uint n_threads); + void younger_refs_iterate(OopIterateClosure* blk); bool is_in(const void* p) const; diff --git a/src/hotspot/share/gc/shared/cardTableRS.cpp b/src/hotspot/share/gc/shared/cardTableRS.cpp index 952e7afb26844..164ad47fe5173 100644 --- a/src/hotspot/share/gc/shared/cardTableRS.cpp +++ b/src/hotspot/share/gc/shared/cardTableRS.cpp @@ -79,51 +79,6 @@ void CardTableRS::at_younger_refs_iterate() { } inline bool ClearNoncleanCardWrapper::clear_card(CardValue* entry) { - if (_is_par) { - return clear_card_parallel(entry); - } else { - return clear_card_serial(entry); - } -} - -inline bool ClearNoncleanCardWrapper::clear_card_parallel(CardValue* entry) { - while (true) { - // In the parallel case, we may have to do this several times. - CardValue entry_val = *entry; - assert(entry_val != CardTableRS::clean_card_val(), - "We shouldn't be looking at clean cards, and this should " - "be the only place they get cleaned."); - if (CardTableRS::card_is_dirty_wrt_gen_iter(entry_val) - || _ct->is_prev_youngergen_card_val(entry_val)) { - CardValue res = - Atomic::cmpxchg(entry, entry_val, CardTableRS::clean_card_val()); - if (res == entry_val) { - break; - } else { - assert(res == CardTableRS::cur_youngergen_and_prev_nonclean_card, - "The CAS above should only fail if another thread did " - "a GC write barrier."); - } - } else if (entry_val == - CardTableRS::cur_youngergen_and_prev_nonclean_card) { - // Parallelism shouldn't matter in this case. Only the thread - // assigned to scan the card should change this value. - *entry = _ct->cur_youngergen_card_val(); - break; - } else { - assert(entry_val == _ct->cur_youngergen_card_val(), - "Should be the only possibility."); - // In this case, the card was clean before, and become - // cur_youngergen only because of processing of a promoted object. - // We don't have to look at the card. - return false; - } - } - return true; -} - - -inline bool ClearNoncleanCardWrapper::clear_card_serial(CardValue* entry) { CardValue entry_val = *entry; assert(entry_val != CardTableRS::clean_card_val(), "We shouldn't be looking at clean cards, and this should " @@ -135,8 +90,8 @@ inline bool ClearNoncleanCardWrapper::clear_card_serial(CardValue* entry) { } ClearNoncleanCardWrapper::ClearNoncleanCardWrapper( - DirtyCardToOopClosure* dirty_card_closure, CardTableRS* ct, bool is_par) : - _dirty_card_closure(dirty_card_closure), _ct(ct), _is_par(is_par) { + DirtyCardToOopClosure* dirty_card_closure, CardTableRS* ct) : + _dirty_card_closure(dirty_card_closure), _ct(ct) { } bool ClearNoncleanCardWrapper::is_word_aligned(CardTable::CardValue* entry) { @@ -203,12 +158,11 @@ void ClearNoncleanCardWrapper::do_MemRegion(MemRegion mr) { void CardTableRS::younger_refs_in_space_iterate(Space* sp, HeapWord* gen_boundary, - OopIterateClosure* cl, - uint n_threads) { + OopIterateClosure* cl) { verify_used_region_at_save_marks(sp); const MemRegion urasm = sp->used_region_at_save_marks(); - non_clean_card_iterate_possibly_parallel(sp, gen_boundary, urasm, cl, this, n_threads); + non_clean_card_iterate(sp, gen_boundary, urasm, cl, this); } #ifdef ASSERT @@ -580,35 +534,21 @@ bool CardTableRS::card_may_have_been_dirty(CardValue cv) { CardTableRS::youngergen_may_have_been_dirty(cv)); } -void CardTableRS::non_clean_card_iterate_possibly_parallel( - Space* sp, - HeapWord* gen_boundary, - MemRegion mr, - OopIterateClosure* cl, - CardTableRS* ct, - uint n_threads) +void CardTableRS::non_clean_card_iterate(Space* sp, + HeapWord* gen_boundary, + MemRegion mr, + OopIterateClosure* cl, + CardTableRS* ct) { - if (!mr.is_empty()) { - if (n_threads > 0) { - non_clean_card_iterate_parallel_work(sp, mr, cl, ct, n_threads); - } else { - // clear_cl finds contiguous dirty ranges of cards to process and clear. - - // This is the single-threaded version used by DefNew. - const bool parallel = false; - - DirtyCardToOopClosure* dcto_cl = sp->new_dcto_cl(cl, precision(), gen_boundary, parallel); - ClearNoncleanCardWrapper clear_cl(dcto_cl, ct, parallel); - - clear_cl.do_MemRegion(mr); - } + if (mr.is_empty()) { + return; } -} + // clear_cl finds contiguous dirty ranges of cards to process and clear. + + DirtyCardToOopClosure* dcto_cl = sp->new_dcto_cl(cl, precision(), gen_boundary); + ClearNoncleanCardWrapper clear_cl(dcto_cl, ct); -void CardTableRS::non_clean_card_iterate_parallel_work(Space* sp, MemRegion mr, - OopIterateClosure* cl, CardTableRS* ct, - uint n_threads) { - fatal("Parallel gc not supported here."); + clear_cl.do_MemRegion(mr); } bool CardTableRS::is_in_young(oop obj) const { diff --git a/src/hotspot/share/gc/shared/cardTableRS.hpp b/src/hotspot/share/gc/shared/cardTableRS.hpp index 6a15fb56942d6..b7aa07188bd16 100644 --- a/src/hotspot/share/gc/shared/cardTableRS.hpp +++ b/src/hotspot/share/gc/shared/cardTableRS.hpp @@ -88,7 +88,7 @@ class CardTableRS: public CardTable { CardTableRS(MemRegion whole_heap, bool scanned_concurrently); ~CardTableRS(); - void younger_refs_in_space_iterate(Space* sp, HeapWord* gen_boundary, OopIterateClosure* cl, uint n_threads); + void younger_refs_in_space_iterate(Space* sp, HeapWord* gen_boundary, OopIterateClosure* cl); virtual void verify_used_region_at_save_marks(Space* sp) const NOT_DEBUG_RETURN; @@ -147,15 +147,11 @@ class CardTableRS: public CardTable { // Iterate over the portion of the card-table which covers the given // region mr in the given space and apply cl to any dirty sub-regions // of mr. Clears the dirty cards as they are processed. - void non_clean_card_iterate_possibly_parallel(Space* sp, HeapWord* gen_boundary, - MemRegion mr, OopIterateClosure* cl, - CardTableRS* ct, uint n_threads); - - // Work method used to implement non_clean_card_iterate_possibly_parallel() - // above in the parallel case. - virtual void non_clean_card_iterate_parallel_work(Space* sp, MemRegion mr, - OopIterateClosure* cl, CardTableRS* ct, - uint n_threads); + void non_clean_card_iterate(Space* sp, + HeapWord* gen_boundary, + MemRegion mr, + OopIterateClosure* cl, + CardTableRS* ct); // This is an array, one element per covered region of the card table. // Each entry is itself an array, with one element per chunk in the @@ -175,7 +171,6 @@ class CardTableRS: public CardTable { class ClearNoncleanCardWrapper: public MemRegionClosure { DirtyCardToOopClosure* _dirty_card_closure; CardTableRS* _ct; - bool _is_par; public: @@ -191,7 +186,7 @@ class ClearNoncleanCardWrapper: public MemRegionClosure { bool is_word_aligned(CardValue* entry); public: - ClearNoncleanCardWrapper(DirtyCardToOopClosure* dirty_card_closure, CardTableRS* ct, bool is_par); + ClearNoncleanCardWrapper(DirtyCardToOopClosure* dirty_card_closure, CardTableRS* ct); void do_MemRegion(MemRegion mr); }; diff --git a/src/hotspot/share/gc/shared/space.cpp b/src/hotspot/share/gc/shared/space.cpp index 7b099a7d01aa2..b59f5b196e1c1 100644 --- a/src/hotspot/share/gc/shared/space.cpp +++ b/src/hotspot/share/gc/shared/space.cpp @@ -163,8 +163,7 @@ void DirtyCardToOopClosure::do_MemRegion(MemRegion mr) { DirtyCardToOopClosure* Space::new_dcto_cl(OopIterateClosure* cl, CardTable::PrecisionStyle precision, - HeapWord* boundary, - bool parallel) { + HeapWord* boundary) { return new DirtyCardToOopClosure(this, cl, precision, boundary); } @@ -243,8 +242,7 @@ ContiguousSpaceDCTOC__walk_mem_region_with_cl_DEFN(FilteringClosure) DirtyCardToOopClosure* ContiguousSpace::new_dcto_cl(OopIterateClosure* cl, CardTable::PrecisionStyle precision, - HeapWord* boundary, - bool parallel) { + HeapWord* boundary) { return new ContiguousSpaceDCTOC(this, cl, precision, boundary); } diff --git a/src/hotspot/share/gc/shared/space.hpp b/src/hotspot/share/gc/shared/space.hpp index 48eadafaf8049..4de1658bd2e70 100644 --- a/src/hotspot/share/gc/shared/space.hpp +++ b/src/hotspot/share/gc/shared/space.hpp @@ -173,8 +173,7 @@ class Space: public CHeapObj { // operate. ResourceArea allocated. virtual DirtyCardToOopClosure* new_dcto_cl(OopIterateClosure* cl, CardTable::PrecisionStyle precision, - HeapWord* boundary, - bool parallel); + HeapWord* boundary); // If "p" is in the space, returns the address of the start of the // "block" that contains "p". We say "block" instead of "object" since @@ -588,8 +587,7 @@ class ContiguousSpace: public CompactibleSpace { // Override. DirtyCardToOopClosure* new_dcto_cl(OopIterateClosure* cl, CardTable::PrecisionStyle precision, - HeapWord* boundary, - bool parallel); + HeapWord* boundary); // Apply "blk->do_oop" to the addresses of all reference fields in objects // starting with the _saved_mark_word, which was noted during a generation's From 189b65b2caac8fa5423fbe772b67850e7df6fc6f Mon Sep 17 00:00:00 2001 From: Harold Seigel Date: Tue, 2 Feb 2021 13:10:34 +0000 Subject: [PATCH 18/77] 8260264: Move common os_ inline methods to a common posix source file Reviewed-by: iklam, dholmes, coleenp, stuefe --- src/hotspot/os/aix/os_aix.inline.hpp | 66 ------------------------ src/hotspot/os/bsd/os_bsd.inline.hpp | 64 ----------------------- src/hotspot/os/linux/os_linux.inline.hpp | 64 ----------------------- src/hotspot/os/posix/os_posix.inline.hpp | 60 +++++++++++++++++++++ 4 files changed, 60 insertions(+), 194 deletions(-) diff --git a/src/hotspot/os/aix/os_aix.inline.hpp b/src/hotspot/os/aix/os_aix.inline.hpp index b235c273192b8..e53bdd74bf6a6 100644 --- a/src/hotspot/os/aix/os_aix.inline.hpp +++ b/src/hotspot/os/aix/os_aix.inline.hpp @@ -29,14 +29,6 @@ #include "runtime/os.hpp" #include "os_posix.inline.hpp" -// System includes - -#include -#include -#include -#include -#include - inline bool os::uses_stack_guard_pages() { return true; } @@ -53,62 +45,4 @@ inline bool os::must_commit_stack_guard_pages() { inline void os::map_stack_shadow_pages(address sp) { } -inline void os::dll_unload(void *lib) { - ::dlclose(lib); -} - -inline jlong os::lseek(int fd, jlong offset, int whence) { - return (jlong) ::lseek64(fd, offset, whence); -} - -inline int os::fsync(int fd) { - return ::fsync(fd); -} - -inline int os::ftruncate(int fd, jlong length) { - return ::ftruncate64(fd, length); -} - -// We don't have NUMA support on Aix, but we need this for compilation. -inline bool os::numa_has_static_binding() { ShouldNotReachHere(); return true; } -inline bool os::numa_has_group_homing() { ShouldNotReachHere(); return false; } - -inline size_t os::write(int fd, const void *buf, unsigned int nBytes) { - size_t res; - RESTARTABLE((size_t) ::write(fd, buf, (size_t) nBytes), res); - return res; -} - -inline int os::socket_close(int fd) { - return ::close(fd); -} - -inline int os::socket(int domain, int type, int protocol) { - return ::socket(domain, type, protocol); -} - -inline int os::recv(int fd, char* buf, size_t nBytes, uint flags) { - RESTARTABLE_RETURN_INT(::recv(fd, buf, nBytes, flags)); -} - -inline int os::send(int fd, char* buf, size_t nBytes, uint flags) { - RESTARTABLE_RETURN_INT(::send(fd, buf, nBytes, flags)); -} - -inline int os::raw_send(int fd, char *buf, size_t nBytes, uint flags) { - return os::send(fd, buf, nBytes, flags); -} - -inline int os::connect(int fd, struct sockaddr *him, socklen_t len) { - RESTARTABLE_RETURN_INT(::connect(fd, him, len)); -} - -inline struct hostent* os::get_host_by_name(char* name) { - return ::gethostbyname(name); -} - -inline void os::exit(int num) { - ::exit(num); -} - #endif // OS_AIX_OS_AIX_INLINE_HPP diff --git a/src/hotspot/os/bsd/os_bsd.inline.hpp b/src/hotspot/os/bsd/os_bsd.inline.hpp index 2dde4950b61a2..32921602ee8e2 100644 --- a/src/hotspot/os/bsd/os_bsd.inline.hpp +++ b/src/hotspot/os/bsd/os_bsd.inline.hpp @@ -28,13 +28,6 @@ #include "runtime/os.hpp" #include "os_posix.inline.hpp" -// System includes - -#include -#include -#include -#include - inline bool os::uses_stack_guard_pages() { return true; } @@ -56,61 +49,4 @@ inline bool os::must_commit_stack_guard_pages() { inline void os::map_stack_shadow_pages(address sp) { } -inline void os::dll_unload(void *lib) { - ::dlclose(lib); -} - -inline jlong os::lseek(int fd, jlong offset, int whence) { - return (jlong) ::lseek(fd, offset, whence); -} - -inline int os::fsync(int fd) { - return ::fsync(fd); -} - -inline int os::ftruncate(int fd, jlong length) { - return ::ftruncate(fd, length); -} - -inline bool os::numa_has_static_binding() { return true; } -inline bool os::numa_has_group_homing() { return false; } - -inline size_t os::write(int fd, const void *buf, unsigned int nBytes) { - size_t res; - RESTARTABLE((size_t) ::write(fd, buf, (size_t) nBytes), res); - return res; -} - -inline int os::socket_close(int fd) { - return ::close(fd); -} - -inline int os::socket(int domain, int type, int protocol) { - return ::socket(domain, type, protocol); -} - -inline int os::recv(int fd, char* buf, size_t nBytes, uint flags) { - RESTARTABLE_RETURN_INT(::recv(fd, buf, nBytes, flags)); -} - -inline int os::send(int fd, char* buf, size_t nBytes, uint flags) { - RESTARTABLE_RETURN_INT(::send(fd, buf, nBytes, flags)); -} - -inline int os::raw_send(int fd, char* buf, size_t nBytes, uint flags) { - return os::send(fd, buf, nBytes, flags); -} - -inline int os::connect(int fd, struct sockaddr* him, socklen_t len) { - RESTARTABLE_RETURN_INT(::connect(fd, him, len)); -} - -inline struct hostent* os::get_host_by_name(char* name) { - return ::gethostbyname(name); -} - -inline void os::exit(int num) { - ::exit(num); -} - #endif // OS_BSD_OS_BSD_INLINE_HPP diff --git a/src/hotspot/os/linux/os_linux.inline.hpp b/src/hotspot/os/linux/os_linux.inline.hpp index 3bff16988305b..4b038c9c72c89 100644 --- a/src/hotspot/os/linux/os_linux.inline.hpp +++ b/src/hotspot/os/linux/os_linux.inline.hpp @@ -28,13 +28,6 @@ #include "runtime/os.hpp" #include "os_posix.inline.hpp" -// System includes - -#include -#include -#include -#include - inline bool os::uses_stack_guard_pages() { return true; } @@ -48,61 +41,4 @@ inline bool os::must_commit_stack_guard_pages() { inline void os::map_stack_shadow_pages(address sp) { } -inline void os::dll_unload(void *lib) { - ::dlclose(lib); -} - -inline jlong os::lseek(int fd, jlong offset, int whence) { - return (jlong) ::lseek64(fd, offset, whence); -} - -inline int os::fsync(int fd) { - return ::fsync(fd); -} - -inline int os::ftruncate(int fd, jlong length) { - return ::ftruncate64(fd, length); -} - -inline bool os::numa_has_static_binding() { return true; } -inline bool os::numa_has_group_homing() { return false; } - -inline size_t os::write(int fd, const void *buf, unsigned int nBytes) { - size_t res; - RESTARTABLE((size_t) ::write(fd, buf, (size_t) nBytes), res); - return res; -} - -inline int os::socket_close(int fd) { - return ::close(fd); -} - -inline int os::socket(int domain, int type, int protocol) { - return ::socket(domain, type, protocol); -} - -inline int os::recv(int fd, char* buf, size_t nBytes, uint flags) { - RESTARTABLE_RETURN_INT(::recv(fd, buf, nBytes, flags)); -} - -inline int os::send(int fd, char* buf, size_t nBytes, uint flags) { - RESTARTABLE_RETURN_INT(::send(fd, buf, nBytes, flags)); -} - -inline int os::raw_send(int fd, char* buf, size_t nBytes, uint flags) { - return os::send(fd, buf, nBytes, flags); -} - -inline int os::connect(int fd, struct sockaddr* him, socklen_t len) { - RESTARTABLE_RETURN_INT(::connect(fd, him, len)); -} - -inline struct hostent* os::get_host_by_name(char* name) { - return ::gethostbyname(name); -} - -inline void os::exit(int num) { - ::exit(num); -} - #endif // OS_LINUX_OS_LINUX_INLINE_HPP diff --git a/src/hotspot/os/posix/os_posix.inline.hpp b/src/hotspot/os/posix/os_posix.inline.hpp index 67e3c11c5c260..600ade67032bc 100644 --- a/src/hotspot/os/posix/os_posix.inline.hpp +++ b/src/hotspot/os/posix/os_posix.inline.hpp @@ -28,6 +28,8 @@ #include "runtime/os.hpp" #include +#include +#include // macros for restartable system calls @@ -42,10 +44,68 @@ } while(false) +inline void os::dll_unload(void *lib) { + ::dlclose(lib); +} + +inline jlong os::lseek(int fd, jlong offset, int whence) { + return (jlong) BSD_ONLY(::lseek) NOT_BSD(::lseek64)(fd, offset, whence); +} + +inline int os::fsync(int fd) { + return ::fsync(fd); +} + +inline int os::ftruncate(int fd, jlong length) { + return BSD_ONLY(::ftruncate) NOT_BSD(::ftruncate64)(fd, length); +} + +// Aix does not have NUMA support but need these for compilation. +inline bool os::numa_has_static_binding() { AIX_ONLY(ShouldNotReachHere();) return true; } +inline bool os::numa_has_group_homing() { AIX_ONLY(ShouldNotReachHere();) return false; } + +inline size_t os::write(int fd, const void *buf, unsigned int nBytes) { + size_t res; + RESTARTABLE((size_t) ::write(fd, buf, (size_t) nBytes), res); + return res; +} + inline int os::close(int fd) { return ::close(fd); } +inline int os::socket_close(int fd) { + return ::close(fd); +} + +inline int os::socket(int domain, int type, int protocol) { + return ::socket(domain, type, protocol); +} + +inline int os::recv(int fd, char* buf, size_t nBytes, uint flags) { + RESTARTABLE_RETURN_INT(::recv(fd, buf, nBytes, flags)); +} + +inline int os::send(int fd, char* buf, size_t nBytes, uint flags) { + RESTARTABLE_RETURN_INT(::send(fd, buf, nBytes, flags)); +} + +inline int os::raw_send(int fd, char* buf, size_t nBytes, uint flags) { + return os::send(fd, buf, nBytes, flags); +} + +inline int os::connect(int fd, struct sockaddr* him, socklen_t len) { + RESTARTABLE_RETURN_INT(::connect(fd, him, len)); +} + +inline struct hostent* os::get_host_by_name(char* name) { + return ::gethostbyname(name); +} + +inline void os::exit(int num) { + ::exit(num); +} + // Platform Mutex/Monitor implementation inline void os::PlatformMutex::lock() { From a421bfad285584430c8bd2f035ccc35b62598b17 Mon Sep 17 00:00:00 2001 From: Coleen Phillimore Date: Tue, 2 Feb 2021 13:29:16 +0000 Subject: [PATCH 19/77] 8259839: SystemDictionary exports too much implementation Reviewed-by: iklam, dholmes --- .../share/classfile/classFileParser.cpp | 4 +- .../share/classfile/systemDictionary.cpp | 314 ++++++++---------- .../share/classfile/systemDictionary.hpp | 116 +++---- .../classfile/systemDictionaryShared.cpp | 14 +- .../classfile/systemDictionaryShared.hpp | 4 +- src/hotspot/share/memory/metaspaceShared.cpp | 2 - 6 files changed, 197 insertions(+), 257 deletions(-) diff --git a/src/hotspot/share/classfile/classFileParser.cpp b/src/hotspot/share/classfile/classFileParser.cpp index 8cdc93ccb098f..addc109d639f2 100644 --- a/src/hotspot/share/classfile/classFileParser.cpp +++ b/src/hotspot/share/classfile/classFileParser.cpp @@ -966,7 +966,7 @@ void ClassFileParser::parse_interfaces(const ClassFileStream* const stream, guarantee_property(unresolved_klass->char_at(0) != JVM_SIGNATURE_ARRAY, "Bad interface name in class file %s", CHECK); - // Call resolve_super so classcircularity is checked + // Call resolve_super so class circularity is checked interf = SystemDictionary::resolve_super_or_fail( _class_name, unresolved_klass, @@ -6206,7 +6206,7 @@ void ClassFileParser::post_process_parsed_stream(const ClassFileStream* const st CHECK); } // We check super class after class file is parsed and format is checked - if (_super_class_index > 0 && NULL ==_super_klass) { + if (_super_class_index > 0 && NULL == _super_klass) { Symbol* const super_class_name = cp->klass_name_at(_super_class_index); if (_access_flags.is_interface()) { // Before attempting to resolve the superclass, check for class format diff --git a/src/hotspot/share/classfile/systemDictionary.cpp b/src/hotspot/share/classfile/systemDictionary.cpp index dcf34a30b8cf9..5360a82990c58 100644 --- a/src/hotspot/share/classfile/systemDictionary.cpp +++ b/src/hotspot/share/classfile/systemDictionary.cpp @@ -88,7 +88,6 @@ #include "jfr/jfr.hpp" #endif -PlaceholderTable* SystemDictionary::_placeholders = NULL; LoaderConstraintTable* SystemDictionary::_loader_constraints = NULL; ResolutionErrorTable* SystemDictionary::_resolution_errors = NULL; SymbolPropertyTable* SystemDictionary::_invoke_method_table = NULL; @@ -98,9 +97,17 @@ OopHandle SystemDictionary::_java_system_loader; OopHandle SystemDictionary::_java_platform_loader; // Default ProtectionDomainCacheSize value - const int defaultProtectionDomainCacheSize = 1009; +const int _loader_constraint_size = 107; // number of entries in constraint table +const int _resolution_error_size = 107; // number of entries in resolution error table +const int _invoke_method_size = 139; // number of entries in invoke method table + +// Hashtable holding placeholders for classes being loaded. +const int _placeholder_table_size = 1009; +PlaceholderTable* _placeholders = NULL; +static PlaceholderTable* placeholders() { return _placeholders; } + // ---------------------------------------------------------------------------- // Java-level SystemLoader and PlatformLoader oop SystemDictionary::java_system_loader() { @@ -211,55 +218,55 @@ Symbol* SystemDictionary::class_name_symbol(const char* name, Symbol* exception, return SymbolTable::new_symbol(name); } -// Forwards to resolve_or_null - -Klass* SystemDictionary::resolve_or_fail(Symbol* class_name, Handle class_loader, Handle protection_domain, bool throw_error, TRAPS) { - Klass* klass = resolve_or_null(class_name, class_loader, protection_domain, THREAD); - if (HAS_PENDING_EXCEPTION || klass == NULL) { - // can return a null klass - klass = handle_resolution_exception(class_name, throw_error, klass, THREAD); - } - return klass; +#ifdef ASSERT +// Used to verify that class loading succeeded in adding k to the dictionary. +void verify_dictionary_entry(Symbol* class_name, InstanceKlass* k) { + MutexLocker mu(SystemDictionary_lock); + ClassLoaderData* loader_data = k->class_loader_data(); + Dictionary* dictionary = loader_data->dictionary(); + assert(class_name == k->name(), "Must be the same"); + unsigned int name_hash = dictionary->compute_hash(class_name); + InstanceKlass* kk = dictionary->find_class(name_hash, class_name); + assert(kk == k, "should be present in dictionary"); } +#endif -Klass* SystemDictionary::handle_resolution_exception(Symbol* class_name, - bool throw_error, - Klass* klass, TRAPS) { +static void handle_resolution_exception(Symbol* class_name, bool throw_error, TRAPS) { if (HAS_PENDING_EXCEPTION) { // If we have a pending exception we forward it to the caller, unless throw_error is true, // in which case we have to check whether the pending exception is a ClassNotFoundException, - // and if so convert it to a NoClassDefFoundError - // And chain the original ClassNotFoundException + // and convert it to a NoClassDefFoundError and chain the original ClassNotFoundException. if (throw_error && PENDING_EXCEPTION->is_a(SystemDictionary::ClassNotFoundException_klass())) { ResourceMark rm(THREAD); - assert(klass == NULL, "Should not have result with exception pending"); Handle e(THREAD, PENDING_EXCEPTION); CLEAR_PENDING_EXCEPTION; - THROW_MSG_CAUSE_NULL(vmSymbols::java_lang_NoClassDefFoundError(), class_name->as_C_string(), e); + THROW_MSG_CAUSE(vmSymbols::java_lang_NoClassDefFoundError(), class_name->as_C_string(), e); } else { - return NULL; + return; // the caller will throw the incoming exception } } - // Class not found, throw appropriate error or exception depending on value of throw_error - if (klass == NULL) { - ResourceMark rm(THREAD); - if (throw_error) { - THROW_MSG_NULL(vmSymbols::java_lang_NoClassDefFoundError(), class_name->as_C_string()); - } else { - THROW_MSG_NULL(vmSymbols::java_lang_ClassNotFoundException(), class_name->as_C_string()); - } + // If the class is not found, ie, caller has checked that klass is NULL, throw the appropriate + // error or exception depending on the value of throw_error. + ResourceMark rm(THREAD); + if (throw_error) { + THROW_MSG(vmSymbols::java_lang_NoClassDefFoundError(), class_name->as_C_string()); + } else { + THROW_MSG(vmSymbols::java_lang_ClassNotFoundException(), class_name->as_C_string()); } - return klass; } +// Forwards to resolve_or_null -Klass* SystemDictionary::resolve_or_fail(Symbol* class_name, - bool throw_error, TRAPS) -{ - return resolve_or_fail(class_name, Handle(), Handle(), throw_error, THREAD); +Klass* SystemDictionary::resolve_or_fail(Symbol* class_name, Handle class_loader, Handle protection_domain, + bool throw_error, TRAPS) { + Klass* klass = resolve_or_null(class_name, class_loader, protection_domain, THREAD); + // Check for pending exception or null klass, and throw exception + if (HAS_PENDING_EXCEPTION || klass == NULL) { + handle_resolution_exception(class_name, throw_error, CHECK_NULL); + } + return klass; } - // Forwards to resolve_array_class_or_null or resolve_instance_class_or_null Klass* SystemDictionary::resolve_or_null(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS) { @@ -287,10 +294,6 @@ InstanceKlass* SystemDictionary::resolve_instance_class_or_null_helper(Symbol* c } } -Klass* SystemDictionary::resolve_or_null(Symbol* class_name, TRAPS) { - return resolve_or_null(class_name, Handle(), Handle(), THREAD); -} - // Forwards to resolve_instance_class_or_null Klass* SystemDictionary::resolve_array_class_or_null(Symbol* class_name, @@ -323,9 +326,9 @@ Klass* SystemDictionary::resolve_array_class_or_null(Symbol* class_name, // Must be called for any super-class or super-interface resolution // during class definition to allow class circularity checking // super-interface callers: -// parse_interfaces - for defineClass & jvmtiRedefineClasses +// parse_interfaces - for defineClass // super-class callers: -// ClassFileParser - for defineClass & jvmtiRedefineClasses +// ClassFileParser - for defineClass // load_shared_class - while loading a class from shared archive // resolve_instance_class_or_null: // via: handle_parallel_super_load @@ -352,14 +355,11 @@ Klass* SystemDictionary::resolve_array_class_or_null(Symbol* class_name, // 4.2 resolve_instance_class_or_null Base, finds placeholder for Base (super Super) // 4.3 calls resolve_super_or_fail Super in parallel on own thread T2 // 4.4 finds T2, Super -> throws class circularity -// Must be called, even if superclass is null, since this is -// where the placeholder entry is created which claims this -// thread is loading this class/classloader. // Be careful when modifying this code: once you have run // placeholders()->find_and_add(PlaceholderTable::LOAD_SUPER), // you need to find_and_remove it before returning. -// So be careful to not exit with a CHECK_ macro betweeen these calls. -InstanceKlass* SystemDictionary::resolve_super_or_fail(Symbol* child_name, +// So be careful to not exit with a CHECK_ macro between these calls. +InstanceKlass* SystemDictionary::resolve_super_or_fail(Symbol* class_name, Symbol* super_name, Handle class_loader, Handle protection_domain, @@ -369,7 +369,7 @@ InstanceKlass* SystemDictionary::resolve_super_or_fail(Symbol* child_name, #if INCLUDE_CDS if (DumpSharedSpaces) { // Special processing for handling UNREGISTERED shared classes. - InstanceKlass* k = SystemDictionaryShared::dump_time_resolve_super_or_fail(child_name, + InstanceKlass* k = SystemDictionaryShared::dump_time_resolve_super_or_fail(class_name, super_name, class_loader, protection_domain, is_superclass, CHECK_NULL); if (k) { return k; @@ -377,16 +377,16 @@ InstanceKlass* SystemDictionary::resolve_super_or_fail(Symbol* child_name, } #endif // INCLUDE_CDS - // Double-check, if child class is already loaded, just return super-class,interface + // Double-check, if klass is already loaded, just return super-class,interface // Don't add a placedholder if already loaded, i.e. already in appropriate class loader // dictionary. - // Make sure there's a placeholder for the *child* before resolving. + // Make sure there's a placeholder for the *klass* before resolving. // Used as a claim that this thread is currently loading superclass/classloader // Used here for ClassCircularity checks and also for heap verification // (every InstanceKlass needs to be in its class loader dictionary or have a placeholder). // Must check ClassCircularity before checking if super class is already loaded. // - // We might not already have a placeholder if this child_name was + // We might not already have a placeholder if this class_name was // first seen via resolve_from_stream (jni_DefineClass or JVM_DefineClass); // the name of the class might not be known until the stream is actually // parsed. @@ -394,39 +394,36 @@ InstanceKlass* SystemDictionary::resolve_super_or_fail(Symbol* child_name, ClassLoaderData* loader_data = class_loader_data(class_loader); Dictionary* dictionary = loader_data->dictionary(); - unsigned int name_hash = dictionary->compute_hash(child_name); - assert(placeholders()->compute_hash(child_name) == name_hash, "they're the same hashcode"); + unsigned int name_hash = dictionary->compute_hash(class_name); + assert(placeholders()->compute_hash(class_name) == name_hash, "they're the same hashcode"); // can't throw error holding a lock bool throw_circularity_error = false; { MutexLocker mu(THREAD, SystemDictionary_lock); - InstanceKlass* childk = dictionary->find_class(name_hash, child_name); + InstanceKlass* klassk = dictionary->find_class(name_hash, class_name); InstanceKlass* quicksuperk; - // to support // loading: if child done loading, just return superclass - // if super_name, & class_loader don't match: - // if initial define, SD update will give LinkageError - // if redefine: compare_class_versions will give HIERARCHY_CHANGED - // so we don't throw an exception here. - // see: nsk redefclass014 & java.lang.instrument Instrument032 - if ((childk != NULL ) && (is_superclass) && - ((quicksuperk = childk->java_super()) != NULL) && + // To support parallel loading: if class is done loading, just return the superclass + // if the super_name matches class->super()->name() and if the class loaders match. + // Otherwise, a LinkageError will be thrown later. + if (klassk != NULL && is_superclass && + ((quicksuperk = klassk->java_super()) != NULL) && ((quicksuperk->name() == super_name) && (quicksuperk->class_loader() == class_loader()))) { return quicksuperk; } else { - PlaceholderEntry* probe = placeholders()->get_entry(name_hash, child_name, loader_data); + PlaceholderEntry* probe = placeholders()->get_entry(name_hash, class_name, loader_data); if (probe && probe->check_seen_thread(THREAD, PlaceholderTable::LOAD_SUPER)) { throw_circularity_error = true; } } if (!throw_circularity_error) { - // Be careful not to exit resolve_super - PlaceholderEntry* newprobe = placeholders()->find_and_add(name_hash, child_name, loader_data, PlaceholderTable::LOAD_SUPER, super_name, THREAD); + // Be careful not to exit resolve_super without removing this placeholder. + PlaceholderEntry* newprobe = placeholders()->find_and_add(name_hash, class_name, loader_data, PlaceholderTable::LOAD_SUPER, super_name, THREAD); } } if (throw_circularity_error) { ResourceMark rm(THREAD); - THROW_MSG_NULL(vmSymbols::java_lang_ClassCircularityError(), child_name->as_C_string()); + THROW_MSG_NULL(vmSymbols::java_lang_ClassCircularityError(), class_name->as_C_string()); } // java.lang.Object should have been found above @@ -446,16 +443,13 @@ InstanceKlass* SystemDictionary::resolve_super_or_fail(Symbol* child_name, // the loader_data. parseClassFile adds the instanceKlass to loader_data. { MutexLocker mu(THREAD, SystemDictionary_lock); - placeholders()->find_and_remove(name_hash, child_name, loader_data, PlaceholderTable::LOAD_SUPER, THREAD); + placeholders()->find_and_remove(name_hash, class_name, loader_data, PlaceholderTable::LOAD_SUPER, THREAD); SystemDictionary_lock->notify_all(); } + + // Check for pending exception or null superk, and throw exception if (HAS_PENDING_EXCEPTION || superk == NULL) { - // can null superk - Klass* k = handle_resolution_exception(super_name, true, superk, THREAD); - assert(k == NULL || k == superk, "must be"); - if (k == NULL) { - superk = NULL; - } + handle_resolution_exception(super_name, true, CHECK_NULL); } return superk; @@ -758,28 +752,25 @@ InstanceKlass* SystemDictionary::resolve_instance_class_or_null(Symbol* name, if (!class_has_been_loaded) { bool load_instance_added = false; - // add placeholder entry to record loading instance class - // Five cases: - // All cases need to prevent modifying bootclasssearchpath - // in parallel with a classload of same classname - // Redefineclasses uses existence of the placeholder for the duration - // of the class load to prevent concurrent redefinition of not completely - // defined classes. - // case 1. traditional classloaders that rely on the classloader object lock - // - no other need for LOAD_INSTANCE - // case 2. traditional classloaders that break the classloader object lock - // as a deadlock workaround. Detection of this case requires that + // Add placeholder entry to record loading instance class + // Three cases: + // case 1. Bootstrap classloader + // This classloader supports parallelism at the classloader level + // but only allows a single thread to load a class/classloader pair. + // The LOAD_INSTANCE placeholder is the mechanism for mutual exclusion. + // case 2. parallelCapable user level classloaders + // These class loaders don't lock the object until load_instance_class is + // called after this placeholder is added. + // Allow parallel classloading of a class/classloader pair where mutual + // exclusion is provided by this lock in the class loader Java code. + // case 3. traditional classloaders that rely on the classloader object lock + // There should be no need for need for LOAD_INSTANCE, except: + // case 4. traditional class loaders that break the classloader object lock + // as a legacy deadlock workaround. Detection of this case requires that // this check is done while holding the classloader object lock, // and that lock is still held when calling classloader's loadClass. // For these classloaders, we ensure that the first requestor // completes the load and other requestors wait for completion. - // case 3. Bootstrap classloader - don't own objectLocker - // This classloader supports parallelism at the classloader level, - // but only allows a single load of a class/classloader pair. - // No performance benefit and no deadlock issues. - // case 4. parallelCapable user level classloaders - without objectLocker - // Allow parallel classloading of a class/classloader pair - { MutexLocker mu(THREAD, SystemDictionary_lock); if (class_loader.is_null() || !is_parallelCapable(class_loader)) { @@ -790,15 +781,15 @@ InstanceKlass* SystemDictionary::resolve_instance_class_or_null(Symbol* name, if (oldprobe->check_seen_thread(THREAD, PlaceholderTable::LOAD_INSTANCE)) { throw_circularity_error = true; } else { - // case 1: traditional: should never see load_in_progress. + // case 3: traditional: should never see load_in_progress. while (!class_has_been_loaded && oldprobe != NULL && oldprobe->instance_load_in_progress()) { - // case 3: bootstrap classloader: prevent futile classloading, + // case 1: bootstrap classloader: prevent futile classloading, // wait on first requestor if (class_loader.is_null()) { SystemDictionary_lock->wait(); } else { - // case 2: traditional with broken classloader lock. wait on first + // case 4: traditional with broken classloader lock. wait on first // requestor. double_lock_wait(THREAD, lockObject); } @@ -815,10 +806,8 @@ InstanceKlass* SystemDictionary::resolve_instance_class_or_null(Symbol* name, } } } - // All cases: add LOAD_INSTANCE holding SystemDictionary_lock - // case 4: parallelCapable: allow competing threads to try - // LOAD_INSTANCE in parallel + // All cases: add LOAD_INSTANCE while holding the SystemDictionary_lock if (!throw_circularity_error && !class_has_been_loaded) { PlaceholderEntry* newprobe = placeholders()->find_and_add(name_hash, name, loader_data, PlaceholderTable::LOAD_INSTANCE, NULL, THREAD); @@ -896,14 +885,9 @@ InstanceKlass* SystemDictionary::resolve_instance_class_or_null(Symbol* name, if (class_load_start_event.should_commit()) { post_class_load_event(&class_load_start_event, loaded_class, loader_data); } -#ifdef ASSERT - { - ClassLoaderData* loader_data = loaded_class->class_loader_data(); - MutexLocker mu(THREAD, SystemDictionary_lock); - InstanceKlass* kk = find_class(name, loader_data); - assert(kk == loaded_class, "should be present in dictionary"); - } -#endif + + // Make sure we have the right class in the dictionary + DEBUG_ONLY(verify_dictionary_entry(name, loaded_class)); // return if the protection domain in NULL if (protection_domain() == NULL) return loaded_class; @@ -1118,33 +1102,23 @@ InstanceKlass* SystemDictionary::resolve_from_stream(Symbol* class_name, // Add class just loaded // If a class loader supports parallel classloading, handle parallel define requests. - // find_or_define_instance_class may return a different InstanceKlass + // find_or_define_instance_class may return a different InstanceKlass, + // in which case the old k would be deallocated if (is_parallelCapable(class_loader)) { - InstanceKlass* defined_k = find_or_define_instance_class(h_name, class_loader, k, THREAD); - if (!HAS_PENDING_EXCEPTION && defined_k != k) { - // If a parallel capable class loader already defined this class, register 'k' for cleanup. - assert(defined_k != NULL, "Should have a klass if there's no exception"); - loader_data->add_to_deallocate_list(k); - k = defined_k; - } + k = find_or_define_instance_class(h_name, class_loader, k, CHECK_NULL); } else { define_instance_class(k, class_loader, THREAD); - } - // If defining the class throws an exception register 'k' for cleanup. - if (HAS_PENDING_EXCEPTION) { - assert(k != NULL, "Must have an instance klass here!"); - loader_data->add_to_deallocate_list(k); - return NULL; + // If defining the class throws an exception register 'k' for cleanup. + if (HAS_PENDING_EXCEPTION) { + assert(k != NULL, "Must have an instance klass here!"); + loader_data->add_to_deallocate_list(k); + return NULL; + } } // Make sure we have an entry in the SystemDictionary on success - debug_only( { - MutexLocker mu(THREAD, SystemDictionary_lock); - - Klass* check = find_class(h_name, k->class_loader_data()); - assert(check == k, "should be present in the dictionary"); - } ); + DEBUG_ONLY(verify_dictionary_entry(h_name, k)); return k; } @@ -1251,18 +1225,18 @@ bool SystemDictionary::is_shared_class_visible_impl(Symbol* class_name, return visible; } -bool SystemDictionary::check_shared_class_super_type(InstanceKlass* child, InstanceKlass* super_type, +bool SystemDictionary::check_shared_class_super_type(InstanceKlass* klass, InstanceKlass* super_type, Handle class_loader, Handle protection_domain, bool is_superclass, TRAPS) { assert(super_type->is_shared(), "must be"); - Klass *found = resolve_super_or_fail(child->name(), super_type->name(), + Klass *found = resolve_super_or_fail(klass->name(), super_type->name(), class_loader, protection_domain, is_superclass, CHECK_0); if (found == super_type) { return true; } else { // The dynamically resolved super type is not the same as the one we used during dump time, - // so we cannot use the child class. + // so we cannot use the class. return false; } } @@ -1499,17 +1473,7 @@ InstanceKlass* SystemDictionary::load_instance_class(Symbol* class_name, Handle // find_or_define_instance_class may return a different InstanceKlass if (k != NULL) { - InstanceKlass* defined_k = - find_or_define_instance_class(class_name, class_loader, k, THREAD); - if (!HAS_PENDING_EXCEPTION && defined_k != k) { - // If a parallel capable class loader already defined this class, register 'k' for cleanup. - assert(defined_k != NULL, "Should have a klass if there's no exception"); - loader_data->add_to_deallocate_list(k); - k = defined_k; - } else if (HAS_PENDING_EXCEPTION) { - loader_data->add_to_deallocate_list(k); - return NULL; - } + k = find_or_define_instance_class(class_name, class_loader, k, CHECK_NULL); } return k; } else { @@ -1578,8 +1542,8 @@ void SystemDictionary::define_instance_class(InstanceKlass* k, Handle class_load ClassLoaderData* loader_data = k->class_loader_data(); assert(loader_data->class_loader() == class_loader(), "they must be the same"); - // Bootstrap and other parallel classloaders don't acquire lock, - // they use a placeholder token instead. + // Bootstrap and other parallel classloaders don't acquire a lock, + // they use placeholder token. // If a parallelCapable class loader calls define_instance_class instead of // find_or_define_instance_class to get here, we have a timing // hole with systemDictionary updates and check_constraints @@ -1656,8 +1620,8 @@ void SystemDictionary::define_instance_class(InstanceKlass* k, Handle class_load // placeholders()->find_and_add(PlaceholderTable::DEFINE_CLASS), // you need to find_and_remove it before returning. // So be careful to not exit with a CHECK_ macro between these calls. -InstanceKlass* SystemDictionary::find_or_define_instance_class(Symbol* class_name, Handle class_loader, - InstanceKlass* k, TRAPS) { +InstanceKlass* SystemDictionary::find_or_define_helper(Symbol* class_name, Handle class_loader, + InstanceKlass* k, TRAPS) { Symbol* name_h = k->name(); // passed in class_name may be null ClassLoaderData* loader_data = class_loader_data(class_loader); @@ -1719,38 +1683,24 @@ InstanceKlass* SystemDictionary::find_or_define_instance_class(Symbol* class_nam SystemDictionary_lock->notify_all(); } - return k; + return HAS_PENDING_EXCEPTION ? NULL : k; } - -// ---------------------------------------------------------------------------- -// Lookup - -// Basic find on classes in the midst of being loaded -Symbol* SystemDictionary::find_placeholder(Symbol* class_name, - ClassLoaderData* loader_data) { - assert_locked_or_safepoint(SystemDictionary_lock); - unsigned int name_hash = placeholders()->compute_hash(class_name); - return placeholders()->find_entry(name_hash, class_name, loader_data); -} - - -// Used for assertions and verification only -// Precalculating the hash and index is an optimization because there are many lookups -// before adding the class. -InstanceKlass* SystemDictionary::find_class(Symbol* class_name, ClassLoaderData* loader_data) { - assert_locked_or_safepoint(SystemDictionary_lock); - #ifndef ASSERT - guarantee(VerifyBeforeGC || - VerifyDuringGC || - VerifyBeforeExit || - VerifyDuringStartup || - VerifyAfterGC, "too expensive"); - #endif - - Dictionary* dictionary = loader_data->dictionary(); - unsigned int name_hash = dictionary->compute_hash(class_name); - return dictionary->find_class(name_hash, class_name); +// If a class loader supports parallel classloading handle parallel define requests. +// find_or_define_instance_class may return a different InstanceKlass +InstanceKlass* SystemDictionary::find_or_define_instance_class(Symbol* class_name, Handle class_loader, + InstanceKlass* k, TRAPS) { + InstanceKlass* defined_k = find_or_define_helper(class_name, class_loader, k, THREAD); + // Clean up original InstanceKlass if duplicate or error + if (!HAS_PENDING_EXCEPTION && defined_k != k) { + // If a parallel capable class loader already defined this class, register 'k' for cleanup. + assert(defined_k != NULL, "Should have a klass if there's no exception"); + k->class_loader_data()->add_to_deallocate_list(k); + } else if (HAS_PENDING_EXCEPTION) { + assert(defined_k == NULL, "Should not have a klass if there's an exception"); + k->class_loader_data()->add_to_deallocate_list(k); + } + return defined_k; } @@ -1849,6 +1799,17 @@ void SystemDictionary::initialize(TRAPS) { } } +#ifdef ASSERT +// Verify that this placeholder exists since this class is in the middle of loading. +void verify_placeholder(Symbol* class_name, ClassLoaderData* loader_data) { + // Only parallel capable class loaders use placeholder table for define class. + assert_locked_or_safepoint(SystemDictionary_lock); + unsigned int name_hash = placeholders()->compute_hash(class_name); + Symbol* ph_check = placeholders()->find_entry(name_hash, class_name, loader_data); + assert(ph_check != NULL, "This placeholder should exist"); +} +#endif // ASSERT + // Constraints on class loaders. The details of the algorithm can be // found in the OOPSLA'98 paper "Dynamic Class Loading in the Java // Virtual Machine" by Sheng Liang and Gilad Bracha. The basic idea is @@ -1877,8 +1838,6 @@ void SystemDictionary::check_constraints(unsigned int name_hash, // If different InstanceKlass - duplicate class definition, // else - ok, class loaded by a different thread in parallel. // We should only have found it if it was done loading and ok to use. - // The dictionary only holds instance classes, placeholders - // also hold array classes. if ((defining == true) || (k != check)) { throwException = true; @@ -1890,10 +1849,7 @@ void SystemDictionary::check_constraints(unsigned int name_hash, } } -#ifdef ASSERT - Symbol* ph_check = find_placeholder(name, loader_data); - assert(ph_check == NULL || ph_check == name, "invalid symbol"); -#endif + DEBUG_ONLY(if (is_parallelCapable(class_loader)) verify_placeholder(name, loader_data)); if (throwException == false) { if (constraints()->check_or_update(k, class_loader, name) == false) { @@ -1940,12 +1896,6 @@ void SystemDictionary::update_dictionary(unsigned int hash, if (sd_check == NULL) { dictionary->add_klass(hash, name, k); } - #ifdef ASSERT - sd_check = dictionary->find_class(hash, name); - assert (sd_check != NULL, "should have entry in dictionary"); - // Note: there may be a placeholder entry: for circularity testing - // or for parallel defines - #endif SystemDictionary_lock->notify_all(); } } diff --git a/src/hotspot/share/classfile/systemDictionary.hpp b/src/hotspot/share/classfile/systemDictionary.hpp index 813f2eed794b1..ba600d7362ec6 100644 --- a/src/hotspot/share/classfile/systemDictionary.hpp +++ b/src/hotspot/share/classfile/systemDictionary.hpp @@ -74,7 +74,6 @@ class BootstrapInfo; class ClassFileStream; class ClassLoadInfo; class Dictionary; -class PlaceholderTable; class LoaderConstraintTable; template class HashtableBucket; class ResolutionErrorTable; @@ -105,24 +104,23 @@ class SystemDictionary : public vmClasses { static Klass* resolve_or_fail(Symbol* class_name, Handle class_loader, Handle protection_domain, bool throw_error, TRAPS); // Convenient call for null loader and protection domain. - static Klass* resolve_or_fail(Symbol* class_name, bool throw_error, TRAPS); -protected: - // handle error translation for resolve_or_null results - static Klass* handle_resolution_exception(Symbol* class_name, bool throw_error, Klass* klass, TRAPS); - -public: + static Klass* resolve_or_fail(Symbol* class_name, bool throw_error, TRAPS) { + return resolve_or_fail(class_name, Handle(), Handle(), throw_error, THREAD); + } // Returns a class with a given class name and class loader. // Loads the class if needed. If not found NULL is returned. static Klass* resolve_or_null(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS); // Version with null loader and protection domain - static Klass* resolve_or_null(Symbol* class_name, TRAPS); + static Klass* resolve_or_null(Symbol* class_name, TRAPS) { + return resolve_or_null(class_name, Handle(), Handle(), THREAD); + } // Resolve a superclass or superinterface. Called from ClassFileParser, // parse_interfaces, resolve_instance_class_or_null, load_shared_class - // "child_name" is the class whose super class or interface is being resolved. - static InstanceKlass* resolve_super_or_fail(Symbol* child_name, - Symbol* class_name, + // "class_name" is the class whose super class or interface is being resolved. + static InstanceKlass* resolve_super_or_fail(Symbol* class_name, + Symbol* super_name, Handle class_loader, Handle protection_domain, bool is_superclass, @@ -151,9 +149,9 @@ class SystemDictionary : public vmClasses { // Do not make any queries to class loaders; consult only the cache. // If not found NULL is returned. static Klass* find_instance_or_array_klass(Symbol* class_name, - Handle class_loader, - Handle protection_domain, - TRAPS); + Handle class_loader, + Handle protection_domain, + TRAPS); // Lookup an instance or array class that has already been loaded // either into the given class loader, or else into another class @@ -191,13 +189,9 @@ class SystemDictionary : public vmClasses { // loaders. Returns "true" iff something was unloaded. static bool do_unloading(GCTimer* gc_timer); - // System loader lock - static oop system_loader_lock(); - // Protection Domain Table static ProtectionDomainCacheTable* pd_cache_table() { return _pd_cache_table; } -public: // Printing static void print(); static void print_on(outputStream* st); @@ -226,19 +220,8 @@ class SystemDictionary : public vmClasses { // Register a new class loader static ClassLoaderData* register_loader(Handle class_loader, bool create_mirror_cld = false); -protected: - // Mirrors for primitive classes (created eagerly) - static oop check_mirror(oop m) { - assert(m != NULL, "mirror not initialized"); - return m; - } public: - // Note: java_lang_Class::primitive_type is the inverse of java_mirror - - // Check class loader constraints - static bool add_loader_constraint(Symbol* name, Klass* klass_being_linked, Handle loader1, - Handle loader2, TRAPS); static Symbol* check_signature_loaders(Symbol* signature, Klass* klass_being_linked, Handle loader1, Handle loader2, bool is_method, TRAPS); @@ -312,21 +295,9 @@ class SystemDictionary : public vmClasses { static ProtectionDomainCacheEntry* cache_get(Handle protection_domain); - protected: - - enum Constants { - _loader_constraint_size = 107, // number of entries in constraint table - _resolution_error_size = 107, // number of entries in resolution error table - _invoke_method_size = 139, // number of entries in invoke method table - _placeholder_table_size = 1009 // number of entries in hash table for placeholders - }; - - + private: // Static tables owned by the SystemDictionary - // Hashtable holding placeholders for classes being loaded. - static PlaceholderTable* _placeholders; - // Constraints on class loaders static LoaderConstraintTable* _loader_constraints; @@ -340,35 +311,55 @@ class SystemDictionary : public vmClasses { static ProtectionDomainCacheTable* _pd_cache_table; protected: + static InstanceKlass* _well_known_klasses[]; + +private: + // table of box klasses (int_klass, etc.) + static InstanceKlass* _box_klasses[T_VOID+1]; + + static OopHandle _java_system_loader; + static OopHandle _java_platform_loader; + static void validate_protection_domain(InstanceKlass* klass, Handle class_loader, Handle protection_domain, TRAPS); friend class VM_PopulateDumpSharedSpace; - friend class TraversePlaceholdersClosure; - static PlaceholderTable* placeholders() { return _placeholders; } static LoaderConstraintTable* constraints() { return _loader_constraints; } static ResolutionErrorTable* resolution_errors() { return _resolution_errors; } static SymbolPropertyTable* invoke_method_table() { return _invoke_method_table; } - static void post_class_load_event(EventClassLoad* event, const InstanceKlass* k, const ClassLoaderData* init_cld); +private: // Basic loading operations static InstanceKlass* resolve_instance_class_or_null_helper(Symbol* name, Handle class_loader, Handle protection_domain, TRAPS); - static InstanceKlass* resolve_instance_class_or_null(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS); - static Klass* resolve_array_class_or_null(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS); - static InstanceKlass* handle_parallel_super_load(Symbol* class_name, Symbol* supername, Handle class_loader, Handle protection_domain, Handle lockObject, TRAPS); + static InstanceKlass* resolve_instance_class_or_null(Symbol* class_name, + Handle class_loader, + Handle protection_domain, TRAPS); + static Klass* resolve_array_class_or_null(Symbol* class_name, + Handle class_loader, + Handle protection_domain, TRAPS); + static InstanceKlass* handle_parallel_super_load(Symbol* class_name, + Symbol* supername, + Handle class_loader, + Handle protection_domain, + Handle lockObject, TRAPS); // Wait on SystemDictionary_lock; unlocks lockObject before // waiting; relocks lockObject with correct recursion count // after waiting, but before reentering SystemDictionary_lock // to preserve lock order semantics. static void double_lock_wait(Thread* thread, Handle lockObject); static void define_instance_class(InstanceKlass* k, Handle class_loader, TRAPS); - static InstanceKlass* find_or_define_instance_class(Symbol* class_name, - Handle class_loader, - InstanceKlass* k, TRAPS); + static InstanceKlass* find_or_define_helper(Symbol* class_name, + Handle class_loader, + InstanceKlass* k, TRAPS); + static InstanceKlass* load_instance_class(Symbol* class_name, Handle class_loader, TRAPS); + static bool is_parallelDefine(Handle class_loader); + static Handle compute_loader_lock_object(Thread* thread, Handle class_loader); + static void check_loader_lock_contention(Thread* thread, Handle loader_lock); + static bool is_shared_class_visible(Symbol* class_name, InstanceKlass* ik, PackageEntry* pkg_entry, Handle class_loader, TRAPS); @@ -376,11 +367,19 @@ class SystemDictionary : public vmClasses { InstanceKlass* ik, PackageEntry* pkg_entry, Handle class_loader, TRAPS); - static bool check_shared_class_super_type(InstanceKlass* child, InstanceKlass* super, + static bool check_shared_class_super_type(InstanceKlass* klass, InstanceKlass* super, Handle class_loader, Handle protection_domain, bool is_superclass, TRAPS); static bool check_shared_class_super_types(InstanceKlass* ik, Handle class_loader, Handle protection_domain, TRAPS); + // Second part of load_shared_class + static void load_shared_class_misc(InstanceKlass* ik, ClassLoaderData* loader_data, TRAPS) NOT_CDS_RETURN; +protected: + // Used by SystemDictionaryShared + + static bool add_loader_constraint(Symbol* name, Klass* klass_being_linked, Handle loader1, + Handle loader2, TRAPS); + static void post_class_load_event(EventClassLoad* event, const InstanceKlass* k, const ClassLoaderData* init_cld); static InstanceKlass* load_shared_lambda_proxy_class(InstanceKlass* ik, Handle class_loader, Handle protection_domain, @@ -392,16 +391,13 @@ class SystemDictionary : public vmClasses { const ClassFileStream *cfs, PackageEntry* pkg_entry, TRAPS); - // Second part of load_shared_class - static void load_shared_class_misc(InstanceKlass* ik, ClassLoaderData* loader_data, TRAPS) NOT_CDS_RETURN; static InstanceKlass* load_shared_boot_class(Symbol* class_name, PackageEntry* pkg_entry, TRAPS); - static InstanceKlass* load_instance_class(Symbol* class_name, Handle class_loader, TRAPS); - static Handle compute_loader_lock_object(Thread* thread, Handle class_loader); static bool is_parallelCapable(Handle class_loader); - static bool is_parallelDefine(Handle class_loader); - + static InstanceKlass* find_or_define_instance_class(Symbol* class_name, + Handle class_loader, + InstanceKlass* k, TRAPS); public: static bool is_system_class_loader(oop class_loader); static bool is_platform_class_loader(oop class_loader); @@ -434,10 +430,6 @@ class SystemDictionary : public vmClasses { static void update_dictionary(unsigned int hash, InstanceKlass* k, Handle loader); -private: - static OopHandle _java_system_loader; - static OopHandle _java_platform_loader; - public: static TableStatistics placeholders_statistics(); static TableStatistics loader_constraints_statistics(); diff --git a/src/hotspot/share/classfile/systemDictionaryShared.cpp b/src/hotspot/share/classfile/systemDictionaryShared.cpp index 0d38c98cff3f6..ef76d893b2601 100644 --- a/src/hotspot/share/classfile/systemDictionaryShared.cpp +++ b/src/hotspot/share/classfile/systemDictionaryShared.cpp @@ -1046,7 +1046,7 @@ InstanceKlass* SystemDictionaryShared::find_or_load_shared_class( k = load_shared_class_for_builtin_loader(name, class_loader, THREAD); if (k != NULL) { - define_instance_class(k, class_loader, CHECK_NULL); + k = find_or_define_instance_class(name, class_loader, k, CHECK_NULL); } } } @@ -1219,14 +1219,14 @@ bool SystemDictionaryShared::add_unregistered_class(InstanceKlass* k, TRAPS) { } // This function is called to resolve the super/interfaces of shared classes for -// non-built-in loaders. E.g., ChildClass in the below example +// non-built-in loaders. E.g., SharedClass in the below example // where "super:" (and optionally "interface:") have been specified. // // java/lang/Object id: 0 // Interface id: 2 super: 0 source: cust.jar -// ChildClass id: 4 super: 0 interfaces: 2 source: cust.jar +// SharedClass id: 4 super: 0 interfaces: 2 source: cust.jar InstanceKlass* SystemDictionaryShared::dump_time_resolve_super_or_fail( - Symbol* child_name, Symbol* class_name, Handle class_loader, + Symbol* class_name, Symbol* super_name, Handle class_loader, Handle protection_domain, bool is_superclass, TRAPS) { assert(DumpSharedSpaces, "only when dumping"); @@ -1236,13 +1236,13 @@ InstanceKlass* SystemDictionaryShared::dump_time_resolve_super_or_fail( // We're still loading the well-known classes, before the ClassListParser is created. return NULL; } - if (child_name->equals(parser->current_class_name())) { + if (class_name->equals(parser->current_class_name())) { // When this function is called, all the numbered super and interface types // must have already been loaded. Hence this function is never recursively called. if (is_superclass) { - return parser->lookup_super_for_current_class(class_name); + return parser->lookup_super_for_current_class(super_name); } else { - return parser->lookup_interface_for_current_class(class_name); + return parser->lookup_interface_for_current_class(super_name); } } else { // The VM is not trying to resolve a super type of parser->current_class_name(). diff --git a/src/hotspot/share/classfile/systemDictionaryShared.hpp b/src/hotspot/share/classfile/systemDictionaryShared.hpp index 318bb0c15dfeb..a0b7043077b76 100644 --- a/src/hotspot/share/classfile/systemDictionaryShared.hpp +++ b/src/hotspot/share/classfile/systemDictionaryShared.hpp @@ -246,8 +246,8 @@ class SystemDictionaryShared: public SystemDictionary { static bool is_sharing_possible(ClassLoaderData* loader_data); static bool add_unregistered_class(InstanceKlass* k, TRAPS); - static InstanceKlass* dump_time_resolve_super_or_fail(Symbol* child_name, - Symbol* class_name, + static InstanceKlass* dump_time_resolve_super_or_fail(Symbol* class_name, + Symbol* super_name, Handle class_loader, Handle protection_domain, bool is_superclass, diff --git a/src/hotspot/share/memory/metaspaceShared.cpp b/src/hotspot/share/memory/metaspaceShared.cpp index 0d80cfccd0a37..02cb6a92adb2c 100644 --- a/src/hotspot/share/memory/metaspaceShared.cpp +++ b/src/hotspot/share/memory/metaspaceShared.cpp @@ -726,8 +726,6 @@ void VM_PopulateDumpSharedSpace::doit() { // shared classes at runtime, where constraints were previously created. guarantee(SystemDictionary::constraints()->number_of_entries() == 0, "loader constraints are not saved"); - guarantee(SystemDictionary::placeholders()->number_of_entries() == 0, - "placeholders are not saved"); // At this point, many classes have been loaded. // Gather systemDictionary classes in a global array and do everything to From defcb042707b344ff892b78c7360f1c8478e408f Mon Sep 17 00:00:00 2001 From: "Daniel D. Daugherty" Date: Tue, 2 Feb 2021 15:36:31 +0000 Subject: [PATCH 20/77] 8260867: ProblemList java/awt/FullScreen/TranslucentWindow/TranslucentWindow.java on linux Reviewed-by: psadhukhan, jdv, pbansal --- test/jdk/ProblemList.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index a1c2a0d204730..29cecce6c9879 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -876,6 +876,7 @@ java/awt/print/PageFormat/Orient.java 8016055 macosx-all java/awt/TextArea/TextAreaCursorTest/HoveringAndDraggingTest.java 8024986 macosx-all,linux-all java/awt/event/MouseEvent/SpuriousExitEnter/SpuriousExitEnter.java 8254841 macosx-all java/awt/Focus/AppletInitialFocusTest/AppletInitialFocusTest1.java 8256289 windows-x64 +java/awt/FullScreen/TranslucentWindow/TranslucentWindow.java 8258103 linux-all ############################################################################ From 0093183b33601c13600c78f406f479c4f65dfe0a Mon Sep 17 00:00:00 2001 From: Quaffel Date: Tue, 2 Feb 2021 15:53:56 +0000 Subject: [PATCH 21/77] 8260368: [PPC64] GC interface needs enhancement to support GCs with load barriers Reviewed-by: mdoerr, rkennke, goetz --- src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp | 14 ++- .../ppc/gc/g1/g1BarrierSetAssembler_ppc.cpp | 64 ++++++++--- .../ppc/gc/g1/g1BarrierSetAssembler_ppc.hpp | 34 ++++-- .../ppc/gc/shared/barrierSetAssembler_ppc.cpp | 13 ++- .../ppc/gc/shared/barrierSetAssembler_ppc.hpp | 14 ++- .../cardTableBarrierSetAssembler_ppc.cpp | 12 +- .../cardTableBarrierSetAssembler_ppc.hpp | 7 +- .../shared/modRefBarrierSetAssembler_ppc.cpp | 21 +++- .../shared/modRefBarrierSetAssembler_ppc.hpp | 22 ++-- src/hotspot/cpu/ppc/interp_masm_ppc.hpp | 4 +- src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp | 20 ++-- src/hotspot/cpu/ppc/macroAssembler_ppc.cpp | 103 ++++++++++++------ src/hotspot/cpu/ppc/macroAssembler_ppc.hpp | 49 +++++++-- .../cpu/ppc/macroAssembler_ppc.inline.hpp | 28 +++-- src/hotspot/cpu/ppc/methodHandles_ppc.cpp | 88 +++++++-------- src/hotspot/cpu/ppc/sharedRuntime_ppc.cpp | 6 +- src/hotspot/cpu/ppc/stubGenerator_ppc.cpp | 7 +- .../ppc/templateInterpreterGenerator_ppc.cpp | 8 +- src/hotspot/cpu/ppc/templateTable_ppc_64.cpp | 56 +++++----- 19 files changed, 363 insertions(+), 207 deletions(-) diff --git a/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp b/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp index 14c18b587551e..67d986002dfea 100644 --- a/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp +++ b/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012, 2019 SAP SE. All rights reserved. + * Copyright (c) 2012, 2021 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -2926,12 +2926,20 @@ void LIR_Assembler::on_spin_wait() { } void LIR_Assembler::leal(LIR_Opr addr_opr, LIR_Opr dest, LIR_PatchCode patch_code, CodeEmitInfo* info) { - assert(patch_code == lir_patch_none, "Patch code not supported"); LIR_Address* addr = addr_opr->as_address_ptr(); assert(addr->scale() == LIR_Address::times_1, "no scaling on this platform"); + if (addr->index()->is_illegal()) { - __ add_const_optimized(dest->as_pointer_register(), addr->base()->as_pointer_register(), addr->disp()); + if (patch_code != lir_patch_none) { + PatchingStub* patch = new PatchingStub(_masm, PatchingStub::access_field_id); + __ load_const32(R0, 0); // patchable int + __ add(dest->as_pointer_register(), addr->base()->as_pointer_register(), R0); + patching_epilog(patch, patch_code, addr->base()->as_register(), info); + } else { + __ add_const_optimized(dest->as_pointer_register(), addr->base()->as_pointer_register(), addr->disp()); + } } else { + assert(patch_code == lir_patch_none, "Patch code not supported"); assert(addr->disp() == 0, "can't have both: index and disp"); __ add(dest->as_pointer_register(), addr->index()->as_pointer_register(), addr->base()->as_pointer_register()); } diff --git a/src/hotspot/cpu/ppc/gc/g1/g1BarrierSetAssembler_ppc.cpp b/src/hotspot/cpu/ppc/gc/g1/g1BarrierSetAssembler_ppc.cpp index baff8a700f7b9..28ff01fa01785 100644 --- a/src/hotspot/cpu/ppc/gc/g1/g1BarrierSetAssembler_ppc.cpp +++ b/src/hotspot/cpu/ppc/gc/g1/g1BarrierSetAssembler_ppc.cpp @@ -1,6 +1,6 @@ /* - * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2018, 2019 SAP SE. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -107,8 +107,10 @@ void G1BarrierSetAssembler::gen_write_ref_array_post_barrier(MacroAssembler* mas __ restore_LR_CR(R0); } -void G1BarrierSetAssembler::g1_write_barrier_pre(MacroAssembler* masm, DecoratorSet decorators, Register obj, RegisterOrConstant ind_or_offs, Register pre_val, - Register tmp1, Register tmp2, bool needs_frame) { +void G1BarrierSetAssembler::g1_write_barrier_pre(MacroAssembler* masm, DecoratorSet decorators, + Register obj, RegisterOrConstant ind_or_offs, Register pre_val, + Register tmp1, Register tmp2, + MacroAssembler::PreservationLevel preservation_level) { bool not_null = (decorators & IS_NOT_NULL) != 0, preloaded = obj == noreg; Register nv_save = noreg; @@ -187,6 +189,11 @@ void G1BarrierSetAssembler::g1_write_barrier_pre(MacroAssembler* masm, Decorator __ bind(runtime); + // Determine necessary runtime invocation preservation measures + const bool needs_frame = preservation_level >= MacroAssembler::PRESERVATION_FRAME_LR; + assert(preservation_level <= MacroAssembler::PRESERVATION_FRAME_LR, + "g1_write_barrier_pre doesn't support preservation levels higher than PRESERVATION_FRAME_LR"); + // May need to preserve LR. Also needed if current frame is not compatible with C calling convention. if (needs_frame) { __ save_LR_CR(tmp1); @@ -205,8 +212,10 @@ void G1BarrierSetAssembler::g1_write_barrier_pre(MacroAssembler* masm, Decorator __ bind(filtered); } -void G1BarrierSetAssembler::g1_write_barrier_post(MacroAssembler* masm, DecoratorSet decorators, Register store_addr, Register new_val, - Register tmp1, Register tmp2, Register tmp3) { +void G1BarrierSetAssembler::g1_write_barrier_post(MacroAssembler* masm, DecoratorSet decorators, + Register store_addr, Register new_val, + Register tmp1, Register tmp2, Register tmp3, + MacroAssembler::PreservationLevel preservation_level) { bool not_null = (decorators & IS_NOT_NULL) != 0; Label runtime, filtered; @@ -271,6 +280,9 @@ void G1BarrierSetAssembler::g1_write_barrier_post(MacroAssembler* masm, Decorato __ bind(runtime); + assert(preservation_level == MacroAssembler::PRESERVATION_NONE, + "g1_write_barrier_post doesn't support preservation levels higher than PRESERVATION_NONE"); + // Save the live input values. __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_field_post_entry), Rcard_addr, R16_thread); @@ -279,15 +291,21 @@ void G1BarrierSetAssembler::g1_write_barrier_post(MacroAssembler* masm, Decorato void G1BarrierSetAssembler::oop_store_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type, Register base, RegisterOrConstant ind_or_offs, Register val, - Register tmp1, Register tmp2, Register tmp3, bool needs_frame) { + Register tmp1, Register tmp2, Register tmp3, + MacroAssembler::PreservationLevel preservation_level) { bool is_array = (decorators & IS_ARRAY) != 0; bool on_anonymous = (decorators & ON_UNKNOWN_OOP_REF) != 0; bool precise = is_array || on_anonymous; // Load and record the previous value. - g1_write_barrier_pre(masm, decorators, base, ind_or_offs, - tmp1, tmp2, tmp3, needs_frame); + g1_write_barrier_pre(masm, decorators, + base, ind_or_offs, + tmp1, tmp2, tmp3, + preservation_level); - BarrierSetAssembler::store_at(masm, decorators, type, base, ind_or_offs, val, tmp1, tmp2, tmp3, needs_frame); + BarrierSetAssembler::store_at(masm, decorators, + type, base, ind_or_offs, val, + tmp1, tmp2, tmp3, + preservation_level); // No need for post barrier if storing NULL if (val != noreg) { @@ -298,13 +316,17 @@ void G1BarrierSetAssembler::oop_store_at(MacroAssembler* masm, DecoratorSet deco __ add(base, ind_or_offs.as_register(), base); } } - g1_write_barrier_post(masm, decorators, base, val, tmp1, tmp2, tmp3); + g1_write_barrier_post(masm, decorators, + base, val, + tmp1, tmp2, tmp3, + preservation_level); } } void G1BarrierSetAssembler::load_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type, Register base, RegisterOrConstant ind_or_offs, Register dst, - Register tmp1, Register tmp2, bool needs_frame, Label *L_handle_null) { + Register tmp1, Register tmp2, + MacroAssembler::PreservationLevel preservation_level, Label *L_handle_null) { bool on_oop = is_reference_type(type); bool on_weak = (decorators & ON_WEAK_OOP_REF) != 0; bool on_phantom = (decorators & ON_PHANTOM_OOP_REF) != 0; @@ -312,20 +334,27 @@ void G1BarrierSetAssembler::load_at(MacroAssembler* masm, DecoratorSet decorator Label done; if (on_oop && on_reference && L_handle_null == NULL) { L_handle_null = &done; } // Load the value of the referent field. - ModRefBarrierSetAssembler::load_at(masm, decorators, type, base, ind_or_offs, dst, tmp1, tmp2, needs_frame, L_handle_null); + ModRefBarrierSetAssembler::load_at(masm, decorators, type, + base, ind_or_offs, dst, + tmp1, tmp2, + preservation_level, L_handle_null); if (on_oop && on_reference) { // Generate the G1 pre-barrier code to log the value of // the referent field in an SATB buffer. Note with // these parameters the pre-barrier does not generate // the load of the previous value // We only reach here if value is not null. - g1_write_barrier_pre(masm, decorators | IS_NOT_NULL, noreg /* obj */, (intptr_t)0, dst /* pre_val */, - tmp1, tmp2, needs_frame); + g1_write_barrier_pre(masm, decorators | IS_NOT_NULL, + noreg /* obj */, (intptr_t)0, dst /* pre_val */, + tmp1, tmp2, + preservation_level); } __ bind(done); } -void G1BarrierSetAssembler::resolve_jobject(MacroAssembler* masm, Register value, Register tmp1, Register tmp2, bool needs_frame) { +void G1BarrierSetAssembler::resolve_jobject(MacroAssembler* masm, Register value, + Register tmp1, Register tmp2, + MacroAssembler::PreservationLevel preservation_level) { Label done, not_weak; __ cmpdi(CCR0, value, 0); __ beq(CCR0, done); // Use NULL as-is. @@ -338,7 +367,8 @@ void G1BarrierSetAssembler::resolve_jobject(MacroAssembler* masm, Register value __ verify_oop(value, FILE_AND_LINE); g1_write_barrier_pre(masm, IN_NATIVE | ON_PHANTOM_OOP_REF, noreg, noreg, value, - tmp1, tmp2, needs_frame); + tmp1, tmp2, + preservation_level); __ bind(not_weak); __ verify_oop(value, FILE_AND_LINE); __ bind(done); diff --git a/src/hotspot/cpu/ppc/gc/g1/g1BarrierSetAssembler_ppc.hpp b/src/hotspot/cpu/ppc/gc/g1/g1BarrierSetAssembler_ppc.hpp index 2638059f2d39b..1d522c9e2231d 100644 --- a/src/hotspot/cpu/ppc/gc/g1/g1BarrierSetAssembler_ppc.hpp +++ b/src/hotspot/cpu/ppc/gc/g1/g1BarrierSetAssembler_ppc.hpp @@ -1,6 +1,6 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2018 SAP SE. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,18 +37,26 @@ class G1PostBarrierStub; class G1BarrierSetAssembler: public ModRefBarrierSetAssembler { protected: - virtual void gen_write_ref_array_pre_barrier(MacroAssembler* masm, DecoratorSet decorators, Register from, Register to, Register count, + virtual void gen_write_ref_array_pre_barrier(MacroAssembler* masm, DecoratorSet decorators, + Register from, Register to, Register count, Register preserve1, Register preserve2); - virtual void gen_write_ref_array_post_barrier(MacroAssembler* masm, DecoratorSet decorators, Register addr, Register count, Register preserve); + virtual void gen_write_ref_array_post_barrier(MacroAssembler* masm, DecoratorSet decorators, + Register addr, Register count, + Register preserve); - void g1_write_barrier_pre(MacroAssembler* masm, DecoratorSet decorators, Register obj, RegisterOrConstant ind_or_offs, Register pre_val, - Register tmp1, Register tmp2, bool needs_frame); - void g1_write_barrier_post(MacroAssembler* masm, DecoratorSet decorators, Register store_addr, Register new_val, - Register tmp1, Register tmp2, Register tmp3); + void g1_write_barrier_pre(MacroAssembler* masm, DecoratorSet decorators, + Register obj, RegisterOrConstant ind_or_offs, Register pre_val, + Register tmp1, Register tmp2, + MacroAssembler::PreservationLevel preservation_level); + void g1_write_barrier_post(MacroAssembler* masm, DecoratorSet decorators, + Register store_addr, Register new_val, + Register tmp1, Register tmp2, Register tmp3, + MacroAssembler::PreservationLevel preservation_level); virtual void oop_store_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type, Register base, RegisterOrConstant ind_or_offs, Register val, - Register tmp1, Register tmp2, Register tmp3, bool needs_frame); + Register tmp1, Register tmp2, Register tmp3, + MacroAssembler::PreservationLevel preservation_level); public: #ifdef COMPILER1 @@ -61,9 +69,13 @@ class G1BarrierSetAssembler: public ModRefBarrierSetAssembler { virtual void load_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type, Register base, RegisterOrConstant ind_or_offs, Register dst, - Register tmp1, Register tmp2, bool needs_frame, Label *L_handle_null = NULL); + Register tmp1, Register tmp2, + MacroAssembler::PreservationLevel preservation_level, + Label *L_handle_null = NULL); - virtual void resolve_jobject(MacroAssembler* masm, Register value, Register tmp1, Register tmp2, bool needs_frame); + virtual void resolve_jobject(MacroAssembler* masm, Register value, + Register tmp1, Register tmp2, + MacroAssembler::PreservationLevel preservation_level); }; #endif // CPU_PPC_GC_G1_G1BARRIERSETASSEMBLER_PPC_HPP diff --git a/src/hotspot/cpu/ppc/gc/shared/barrierSetAssembler_ppc.cpp b/src/hotspot/cpu/ppc/gc/shared/barrierSetAssembler_ppc.cpp index 1c4595addfc1f..5a092ae8af63f 100644 --- a/src/hotspot/cpu/ppc/gc/shared/barrierSetAssembler_ppc.cpp +++ b/src/hotspot/cpu/ppc/gc/shared/barrierSetAssembler_ppc.cpp @@ -1,6 +1,6 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2018 SAP SE. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,8 @@ void BarrierSetAssembler::store_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type, Register base, RegisterOrConstant ind_or_offs, Register val, - Register tmp1, Register tmp2, Register tmp3, bool needs_frame) { + Register tmp1, Register tmp2, Register tmp3, + MacroAssembler::PreservationLevel preservation_level) { bool in_heap = (decorators & IN_HEAP) != 0; bool in_native = (decorators & IN_NATIVE) != 0; bool not_null = (decorators & IS_NOT_NULL) != 0; @@ -67,7 +68,8 @@ void BarrierSetAssembler::store_at(MacroAssembler* masm, DecoratorSet decorators void BarrierSetAssembler::load_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type, Register base, RegisterOrConstant ind_or_offs, Register dst, - Register tmp1, Register tmp2, bool needs_frame, Label *L_handle_null) { + Register tmp1, Register tmp2, + MacroAssembler::PreservationLevel preservation_level, Label *L_handle_null) { bool in_heap = (decorators & IN_HEAP) != 0; bool in_native = (decorators & IN_NATIVE) != 0; bool not_null = (decorators & IS_NOT_NULL) != 0; @@ -105,7 +107,8 @@ void BarrierSetAssembler::load_at(MacroAssembler* masm, DecoratorSet decorators, } void BarrierSetAssembler::resolve_jobject(MacroAssembler* masm, Register value, - Register tmp1, Register tmp2, bool needs_frame) { + Register tmp1, Register tmp2, + MacroAssembler::PreservationLevel preservation_level) { Label done; __ cmpdi(CCR0, value, 0); __ beq(CCR0, done); // Use NULL as-is. diff --git a/src/hotspot/cpu/ppc/gc/shared/barrierSetAssembler_ppc.hpp b/src/hotspot/cpu/ppc/gc/shared/barrierSetAssembler_ppc.hpp index 61902390e2754..a3e6c7eeddfa0 100644 --- a/src/hotspot/cpu/ppc/gc/shared/barrierSetAssembler_ppc.hpp +++ b/src/hotspot/cpu/ppc/gc/shared/barrierSetAssembler_ppc.hpp @@ -1,6 +1,6 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2018 SAP SE. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,13 +41,17 @@ class BarrierSetAssembler: public CHeapObj { virtual void store_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type, Register base, RegisterOrConstant ind_or_offs, Register val, - Register tmp1, Register tmp2, Register tmp3, bool needs_frame); + Register tmp1, Register tmp2, Register tmp3, + MacroAssembler::PreservationLevel preservation_level); virtual void load_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type, Register base, RegisterOrConstant ind_or_offs, Register dst, - Register tmp1, Register tmp2, bool needs_frame, Label *L_handle_null = NULL); + Register tmp1, Register tmp2, + MacroAssembler::PreservationLevel preservation_level, Label *L_handle_null = NULL); - virtual void resolve_jobject(MacroAssembler* masm, Register value, Register tmp1, Register tmp2, bool needs_frame); + virtual void resolve_jobject(MacroAssembler* masm, Register value, + Register tmp1, Register tmp2, + MacroAssembler::PreservationLevel preservation_level); virtual void try_resolve_jobject_in_native(MacroAssembler* masm, Register dst, Register jni_env, Register obj, Register tmp, Label& slowpath); diff --git a/src/hotspot/cpu/ppc/gc/shared/cardTableBarrierSetAssembler_ppc.cpp b/src/hotspot/cpu/ppc/gc/shared/cardTableBarrierSetAssembler_ppc.cpp index 257505a4e8030..fd0c4c6a54087 100644 --- a/src/hotspot/cpu/ppc/gc/shared/cardTableBarrierSetAssembler_ppc.cpp +++ b/src/hotspot/cpu/ppc/gc/shared/cardTableBarrierSetAssembler_ppc.cpp @@ -1,6 +1,6 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2018 SAP SE. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -91,12 +91,16 @@ void CardTableBarrierSetAssembler::card_write_barrier_post(MacroAssembler* masm, void CardTableBarrierSetAssembler::oop_store_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type, Register base, RegisterOrConstant ind_or_offs, Register val, - Register tmp1, Register tmp2, Register tmp3, bool needs_frame) { + Register tmp1, Register tmp2, Register tmp3, + MacroAssembler::PreservationLevel preservation_level) { bool is_array = (decorators & IS_ARRAY) != 0; bool on_anonymous = (decorators & ON_UNKNOWN_OOP_REF) != 0; bool precise = is_array || on_anonymous; - BarrierSetAssembler::store_at(masm, decorators, type, base, ind_or_offs, val, tmp1, tmp2, tmp3, needs_frame); + BarrierSetAssembler::store_at(masm, decorators, type, + base, ind_or_offs, val, + tmp1, tmp2, tmp3, + preservation_level); // No need for post barrier if storing NULL if (val != noreg) { diff --git a/src/hotspot/cpu/ppc/gc/shared/cardTableBarrierSetAssembler_ppc.hpp b/src/hotspot/cpu/ppc/gc/shared/cardTableBarrierSetAssembler_ppc.hpp index cf5f33e339681..7d8e59e2c985c 100644 --- a/src/hotspot/cpu/ppc/gc/shared/cardTableBarrierSetAssembler_ppc.hpp +++ b/src/hotspot/cpu/ppc/gc/shared/cardTableBarrierSetAssembler_ppc.hpp @@ -1,6 +1,6 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2018 SAP SE. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,7 +40,8 @@ class CardTableBarrierSetAssembler: public ModRefBarrierSetAssembler { virtual void oop_store_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type, Register base, RegisterOrConstant ind_or_offs, Register val, - Register tmp1, Register tmp2, Register tmp3, bool needs_frame); + Register tmp1, Register tmp2, Register tmp3, + MacroAssembler::PreservationLevel preservation_level); }; #endif // CPU_PPC_GC_SHARED_CARDTABLEBARRIERSETASSEMBLER_PPC_HPP diff --git a/src/hotspot/cpu/ppc/gc/shared/modRefBarrierSetAssembler_ppc.cpp b/src/hotspot/cpu/ppc/gc/shared/modRefBarrierSetAssembler_ppc.cpp index c6e14802de270..ed66c5f892918 100644 --- a/src/hotspot/cpu/ppc/gc/shared/modRefBarrierSetAssembler_ppc.cpp +++ b/src/hotspot/cpu/ppc/gc/shared/modRefBarrierSetAssembler_ppc.cpp @@ -1,6 +1,6 @@ /* - * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2018, 2019 SAP SE. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,9 @@ void ModRefBarrierSetAssembler::arraycopy_prologue(MacroAssembler* masm, DecoratorSet decorators, BasicType type, Register src, Register dst, Register count, Register preserve1, Register preserve2) { if (type == T_OBJECT) { - gen_write_ref_array_pre_barrier(masm, decorators, src, dst, count, preserve1, preserve2); + gen_write_ref_array_pre_barrier(masm, decorators, + src, dst, count, + preserve1, preserve2); bool checkcast = (decorators & ARRAYCOPY_CHECKCAST) != 0; if (!checkcast) { @@ -58,10 +60,17 @@ void ModRefBarrierSetAssembler::arraycopy_epilogue(MacroAssembler* masm, Decorat void ModRefBarrierSetAssembler::store_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type, Register base, RegisterOrConstant ind_or_offs, Register val, - Register tmp1, Register tmp2, Register tmp3, bool needs_frame) { + Register tmp1, Register tmp2, Register tmp3, + MacroAssembler::PreservationLevel preservation_level) { if (is_reference_type(type)) { - oop_store_at(masm, decorators, type, base, ind_or_offs, val, tmp1, tmp2, tmp3, needs_frame); + oop_store_at(masm, decorators, type, + base, ind_or_offs, val, + tmp1, tmp2, tmp3, + preservation_level); } else { - BarrierSetAssembler::store_at(masm, decorators, type, base, ind_or_offs, val, tmp1, tmp2, tmp3, needs_frame); + BarrierSetAssembler::store_at(masm, decorators, type, + base, ind_or_offs, val, + tmp1, tmp2, tmp3, + preservation_level); } } diff --git a/src/hotspot/cpu/ppc/gc/shared/modRefBarrierSetAssembler_ppc.hpp b/src/hotspot/cpu/ppc/gc/shared/modRefBarrierSetAssembler_ppc.hpp index 774c9a355be9e..eec826212803c 100644 --- a/src/hotspot/cpu/ppc/gc/shared/modRefBarrierSetAssembler_ppc.hpp +++ b/src/hotspot/cpu/ppc/gc/shared/modRefBarrierSetAssembler_ppc.hpp @@ -1,6 +1,6 @@ /* - * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2018, 2019 SAP SE. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,22 +35,28 @@ class ModRefBarrierSetAssembler: public BarrierSetAssembler { protected: - virtual void gen_write_ref_array_pre_barrier(MacroAssembler* masm, DecoratorSet decorators, Register from, Register to, Register count, + virtual void gen_write_ref_array_pre_barrier(MacroAssembler* masm, DecoratorSet decorators, + Register from, Register to, Register count, Register preserve1, Register preserve2) {} - virtual void gen_write_ref_array_post_barrier(MacroAssembler* masm, DecoratorSet decorators, Register addr, Register count, Register preserve) {} + virtual void gen_write_ref_array_post_barrier(MacroAssembler* masm, DecoratorSet decorators, + Register addr, Register count, Register preserve) {} virtual void oop_store_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type, Register base, RegisterOrConstant ind_or_offs, Register val, - Register tmp1, Register tmp2, Register tmp3, bool needs_frame) = 0; + Register tmp1, Register tmp2, Register tmp3, + MacroAssembler::PreservationLevel preservation_level) = 0; public: virtual void arraycopy_prologue(MacroAssembler* masm, DecoratorSet decorators, BasicType type, - Register src, Register dst, Register count, Register preserve1, Register preserve2); + Register src, Register dst, Register count, + Register preserve1, Register preserve2); virtual void arraycopy_epilogue(MacroAssembler* masm, DecoratorSet decorators, BasicType type, - Register dst, Register count, Register preserve); + Register dst, Register count, + Register preserve); virtual void store_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type, Register base, RegisterOrConstant ind_or_offs, Register val, - Register tmp1, Register tmp2, Register tmp3, bool needs_frame); + Register tmp1, Register tmp2, Register tmp3, + MacroAssembler::PreservationLevel preservation_level); }; #endif // CPU_PPC_GC_SHARED_MODREFBARRIERSETASSEMBLER_PPC_HPP diff --git a/src/hotspot/cpu/ppc/interp_masm_ppc.hpp b/src/hotspot/cpu/ppc/interp_masm_ppc.hpp index 72132c8a04851..fa896a2918d1e 100644 --- a/src/hotspot/cpu/ppc/interp_masm_ppc.hpp +++ b/src/hotspot/cpu/ppc/interp_masm_ppc.hpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012, 2017 SAP SE. All rights reserved. + * Copyright (c) 2012, 2021 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -77,7 +77,7 @@ class InterpreterMacroAssembler: public MacroAssembler { Register tmp1, Register tmp2, Register tmp3, Label &ok_is_subtype); // Load object from cpool->resolved_references(index). - void load_resolved_reference_at_index(Register result, Register index, Label *L_handle_null = NULL); + void load_resolved_reference_at_index(Register result, Register index, Register tmp1, Label *L_handle_null = NULL); // load cpool->resolved_klass_at(index) void load_resolved_klass_at_offset(Register Rcpool, Register Roffset, Register Rklass); diff --git a/src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp b/src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp index c63ad7ca9010e..de1e41d9b9297 100644 --- a/src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp +++ b/src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012, 2020 SAP SE. All rights reserved. + * Copyright (c) 2012, 2021 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -475,14 +475,17 @@ void InterpreterMacroAssembler::get_u4(Register Rdst, Register Rsrc, int offset, } // Load object from cpool->resolved_references(index). -void InterpreterMacroAssembler::load_resolved_reference_at_index(Register result, Register index, Label *L_handle_null) { +// Kills: +// - index +void InterpreterMacroAssembler::load_resolved_reference_at_index(Register result, Register index, Register tmp1, + Label *L_handle_null) { assert_different_registers(result, index); get_constant_pool(result); // Convert from field index to resolved_references() index and from // word index to byte offset. Since this is a java object, it can be compressed. - Register tmp = index; // reuse - sldi(tmp, index, LogBytesPerHeapOop); + Register tmp2 = index; // reuse + sldi(tmp1, index, LogBytesPerHeapOop); // Load pointer for resolved_references[] objArray. ld(result, ConstantPool::cache_offset_in_bytes(), result); ld(result, ConstantPoolCache::resolved_references_offset_in_bytes(), result); @@ -491,14 +494,17 @@ void InterpreterMacroAssembler::load_resolved_reference_at_index(Register result Label index_ok; lwa(R0, arrayOopDesc::length_offset_in_bytes(), result); sldi(R0, R0, LogBytesPerHeapOop); - cmpd(CCR0, tmp, R0); + cmpd(CCR0, tmp1, R0); blt(CCR0, index_ok); stop("resolved reference index out of bounds"); bind(index_ok); #endif // Add in the index. - add(result, tmp, result); - load_heap_oop(result, arrayOopDesc::base_offset_in_bytes(T_OBJECT), result, tmp, R0, false, 0, L_handle_null); + add(result, tmp1, result); + load_heap_oop(result, arrayOopDesc::base_offset_in_bytes(T_OBJECT), result, + tmp1, tmp2, + MacroAssembler::PRESERVATION_FRAME_LR, + 0, L_handle_null); } // load cpool->resolved_klass_at(index) diff --git a/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp b/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp index 0d280e7b91e7b..8ced76f08a0c4 100644 --- a/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp +++ b/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp @@ -1,6 +1,6 @@ /* * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012, 2019 SAP SE. All rights reserved. + * Copyright (c) 2012, 2021 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -707,6 +707,30 @@ address MacroAssembler::get_dest_of_bxx64_patchable_at(address instruction_addr, } } +void MacroAssembler::clobber_volatile_gprs(Register excluded_register) { + const int magic_number = 0x42; + + // Preserve stack pointer register (R1_SP) and system thread id register (R13); + // although they're technically volatile + for (int i = 2; i < 13; i++) { + Register reg = as_Register(i); + if (reg == excluded_register) { + continue; + } + + li(reg, magic_number); + } +} + +void MacroAssembler::clobber_carg_stack_slots(Register tmp) { + const int magic_number = 0x43; + + li(tmp, magic_number); + for (int m = 0; m <= 7; m++) { + std(tmp, frame::abi_minframe_size + m * 8, R1_SP); + } +} + // Uses ordering which corresponds to ABI: // _savegpr0_14: std r14,-144(r1) // _savegpr0_15: std r15,-136(r1) @@ -797,9 +821,11 @@ void MacroAssembler::restore_nonvolatile_gprs(Register src, int offset) { } // For verify_oops. -void MacroAssembler::save_volatile_gprs(Register dst, int offset) { +void MacroAssembler::save_volatile_gprs(Register dst, int offset, bool include_fp_regs, bool include_R3_RET_reg) { std(R2, offset, dst); offset += 8; - std(R3, offset, dst); offset += 8; + if (include_R3_RET_reg) { + std(R3, offset, dst); offset += 8; + } std(R4, offset, dst); offset += 8; std(R5, offset, dst); offset += 8; std(R6, offset, dst); offset += 8; @@ -810,26 +836,30 @@ void MacroAssembler::save_volatile_gprs(Register dst, int offset) { std(R11, offset, dst); offset += 8; std(R12, offset, dst); offset += 8; - stfd(F0, offset, dst); offset += 8; - stfd(F1, offset, dst); offset += 8; - stfd(F2, offset, dst); offset += 8; - stfd(F3, offset, dst); offset += 8; - stfd(F4, offset, dst); offset += 8; - stfd(F5, offset, dst); offset += 8; - stfd(F6, offset, dst); offset += 8; - stfd(F7, offset, dst); offset += 8; - stfd(F8, offset, dst); offset += 8; - stfd(F9, offset, dst); offset += 8; - stfd(F10, offset, dst); offset += 8; - stfd(F11, offset, dst); offset += 8; - stfd(F12, offset, dst); offset += 8; - stfd(F13, offset, dst); + if (include_fp_regs) { + stfd(F0, offset, dst); offset += 8; + stfd(F1, offset, dst); offset += 8; + stfd(F2, offset, dst); offset += 8; + stfd(F3, offset, dst); offset += 8; + stfd(F4, offset, dst); offset += 8; + stfd(F5, offset, dst); offset += 8; + stfd(F6, offset, dst); offset += 8; + stfd(F7, offset, dst); offset += 8; + stfd(F8, offset, dst); offset += 8; + stfd(F9, offset, dst); offset += 8; + stfd(F10, offset, dst); offset += 8; + stfd(F11, offset, dst); offset += 8; + stfd(F12, offset, dst); offset += 8; + stfd(F13, offset, dst); + } } // For verify_oops. -void MacroAssembler::restore_volatile_gprs(Register src, int offset) { +void MacroAssembler::restore_volatile_gprs(Register src, int offset, bool include_fp_regs, bool include_R3_RET_reg) { ld(R2, offset, src); offset += 8; - ld(R3, offset, src); offset += 8; + if (include_R3_RET_reg) { + ld(R3, offset, src); offset += 8; + } ld(R4, offset, src); offset += 8; ld(R5, offset, src); offset += 8; ld(R6, offset, src); offset += 8; @@ -840,20 +870,22 @@ void MacroAssembler::restore_volatile_gprs(Register src, int offset) { ld(R11, offset, src); offset += 8; ld(R12, offset, src); offset += 8; - lfd(F0, offset, src); offset += 8; - lfd(F1, offset, src); offset += 8; - lfd(F2, offset, src); offset += 8; - lfd(F3, offset, src); offset += 8; - lfd(F4, offset, src); offset += 8; - lfd(F5, offset, src); offset += 8; - lfd(F6, offset, src); offset += 8; - lfd(F7, offset, src); offset += 8; - lfd(F8, offset, src); offset += 8; - lfd(F9, offset, src); offset += 8; - lfd(F10, offset, src); offset += 8; - lfd(F11, offset, src); offset += 8; - lfd(F12, offset, src); offset += 8; - lfd(F13, offset, src); + if (include_fp_regs) { + lfd(F0, offset, src); offset += 8; + lfd(F1, offset, src); offset += 8; + lfd(F2, offset, src); offset += 8; + lfd(F3, offset, src); offset += 8; + lfd(F4, offset, src); offset += 8; + lfd(F5, offset, src); offset += 8; + lfd(F6, offset, src); offset += 8; + lfd(F7, offset, src); offset += 8; + lfd(F8, offset, src); offset += 8; + lfd(F9, offset, src); offset += 8; + lfd(F10, offset, src); offset += 8; + lfd(F11, offset, src); offset += 8; + lfd(F12, offset, src); offset += 8; + lfd(F13, offset, src); + } } void MacroAssembler::save_LR_CR(Register tmp) { @@ -3032,9 +3064,10 @@ void MacroAssembler::safepoint_poll(Label& slow_path, Register temp_reg) { bne(CCR0, slow_path); } -void MacroAssembler::resolve_jobject(Register value, Register tmp1, Register tmp2, bool needs_frame) { +void MacroAssembler::resolve_jobject(Register value, Register tmp1, Register tmp2, + MacroAssembler::PreservationLevel preservation_level) { BarrierSetAssembler* bs = BarrierSet::barrier_set()->barrier_set_assembler(); - bs->resolve_jobject(this, value, tmp1, tmp2, needs_frame); + bs->resolve_jobject(this, value, tmp1, tmp2, preservation_level); } // Values for last_Java_pc, and last_Java_sp must comply to the rules diff --git a/src/hotspot/cpu/ppc/macroAssembler_ppc.hpp b/src/hotspot/cpu/ppc/macroAssembler_ppc.hpp index 1fee5ac1708a7..4dd0ba6c34d91 100644 --- a/src/hotspot/cpu/ppc/macroAssembler_ppc.hpp +++ b/src/hotspot/cpu/ppc/macroAssembler_ppc.hpp @@ -1,6 +1,6 @@ /* - * Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012, 2019 SAP SE. All rights reserved. + * Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2021 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,6 +39,14 @@ class MacroAssembler: public Assembler { public: MacroAssembler(CodeBuffer* code) : Assembler(code) {} + // Indicates whether and, if so, which registers must be preserved when calling runtime code. + enum PreservationLevel { + PRESERVATION_NONE, + PRESERVATION_FRAME_LR, + PRESERVATION_FRAME_LR_GP_REGS, + PRESERVATION_FRAME_LR_GP_FP_REGS + }; + // // Optimized instruction emitters // @@ -260,11 +268,26 @@ class MacroAssembler: public Assembler { // // some ABI-related functions + + // Clobbers all volatile, (non-floating-point) general-purpose registers for debugging purposes. + // This is especially useful for making calls to the JRT in places in which this hasn't been done before; + // e.g. with the introduction of LRBs (load reference barriers) for concurrent garbage collection. + void clobber_volatile_gprs(Register excluded_register = noreg); + void clobber_carg_stack_slots(Register tmp); + void save_nonvolatile_gprs( Register dst_base, int offset); void restore_nonvolatile_gprs(Register src_base, int offset); - enum { num_volatile_regs = 11 + 14 }; // GPR + FPR - void save_volatile_gprs( Register dst_base, int offset); - void restore_volatile_gprs(Register src_base, int offset); + + enum { + num_volatile_gp_regs = 11, + num_volatile_fp_regs = 14, + num_volatile_regs = num_volatile_gp_regs + num_volatile_fp_regs + }; + + void save_volatile_gprs( Register dst_base, int offset, + bool include_fp_regs = true, bool include_R3_RET_reg = true); + void restore_volatile_gprs(Register src_base, int offset, + bool include_fp_regs = true, bool include_R3_RET_reg = true); void save_LR_CR( Register tmp); // tmp contains LR on return. void restore_LR_CR(Register tmp); @@ -645,7 +668,8 @@ class MacroAssembler: public Assembler { // Check if safepoint requested and if so branch void safepoint_poll(Label& slow_path, Register temp_reg); - void resolve_jobject(Register value, Register tmp1, Register tmp2, bool needs_frame); + void resolve_jobject(Register value, Register tmp1, Register tmp2, + MacroAssembler::PreservationLevel preservation_level); // Support for managing the JavaThread pointer (i.e.; the reference to // thread-local information). @@ -686,21 +710,24 @@ class MacroAssembler: public Assembler { private: inline void access_store_at(BasicType type, DecoratorSet decorators, Register base, RegisterOrConstant ind_or_offs, Register val, - Register tmp1, Register tmp2, Register tmp3, bool needs_frame); + Register tmp1, Register tmp2, Register tmp3, + MacroAssembler::PreservationLevel preservation_level); inline void access_load_at(BasicType type, DecoratorSet decorators, Register base, RegisterOrConstant ind_or_offs, Register dst, - Register tmp1, Register tmp2, bool needs_frame, Label *L_handle_null = NULL); + Register tmp1, Register tmp2, + MacroAssembler::PreservationLevel preservation_level, Label *L_handle_null = NULL); public: // Specify tmp1 for better code in certain compressed oops cases. Specify Label to bail out on null oop. // tmp1, tmp2 and needs_frame are used with decorators ON_PHANTOM_OOP_REF or ON_WEAK_OOP_REF. inline void load_heap_oop(Register d, RegisterOrConstant offs, Register s1, - Register tmp1, Register tmp2, bool needs_frame, + Register tmp1, Register tmp2, + MacroAssembler::PreservationLevel preservation_level, DecoratorSet decorators = 0, Label *L_handle_null = NULL); inline void store_heap_oop(Register d, RegisterOrConstant offs, Register s1, - Register tmp1, Register tmp2, Register tmp3, bool needs_frame, - DecoratorSet decorators = 0); + Register tmp1, Register tmp2, Register tmp3, + MacroAssembler::PreservationLevel preservation_level, DecoratorSet decorators = 0); // Encode/decode heap oop. Oop may not be null, else en/decoding goes wrong. // src == d allowed. diff --git a/src/hotspot/cpu/ppc/macroAssembler_ppc.inline.hpp b/src/hotspot/cpu/ppc/macroAssembler_ppc.inline.hpp index 356a01b61a437..8c578e82509a5 100644 --- a/src/hotspot/cpu/ppc/macroAssembler_ppc.inline.hpp +++ b/src/hotspot/cpu/ppc/macroAssembler_ppc.inline.hpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012, 2015 SAP SE. All rights reserved. + * Copyright (c) 2012, 2021 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -350,7 +350,8 @@ inline void MacroAssembler::null_check(Register a, int offset, Label *Lis_null) inline void MacroAssembler::access_store_at(BasicType type, DecoratorSet decorators, Register base, RegisterOrConstant ind_or_offs, Register val, - Register tmp1, Register tmp2, Register tmp3, bool needs_frame) { + Register tmp1, Register tmp2, Register tmp3, + MacroAssembler::PreservationLevel preservation_level) { assert((decorators & ~(AS_RAW | IN_HEAP | IN_NATIVE | IS_ARRAY | IS_NOT_NULL | ON_UNKNOWN_OOP_REF)) == 0, "unsupported decorator"); BarrierSetAssembler* bs = BarrierSet::barrier_set()->barrier_set_assembler(); @@ -359,17 +360,19 @@ inline void MacroAssembler::access_store_at(BasicType type, DecoratorSet decorat if (as_raw) { bs->BarrierSetAssembler::store_at(this, decorators, type, base, ind_or_offs, val, - tmp1, tmp2, tmp3, needs_frame); + tmp1, tmp2, tmp3, preservation_level); } else { bs->store_at(this, decorators, type, base, ind_or_offs, val, - tmp1, tmp2, tmp3, needs_frame); + tmp1, tmp2, tmp3, preservation_level); } } inline void MacroAssembler::access_load_at(BasicType type, DecoratorSet decorators, Register base, RegisterOrConstant ind_or_offs, Register dst, - Register tmp1, Register tmp2, bool needs_frame, Label *L_handle_null) { + Register tmp1, Register tmp2, + MacroAssembler::PreservationLevel preservation_level, + Label *L_handle_null) { assert((decorators & ~(AS_RAW | IN_HEAP | IN_NATIVE | IS_ARRAY | IS_NOT_NULL | ON_PHANTOM_OOP_REF | ON_WEAK_OOP_REF)) == 0, "unsupported decorator"); BarrierSetAssembler* bs = BarrierSet::barrier_set()->barrier_set_assembler(); @@ -378,24 +381,27 @@ inline void MacroAssembler::access_load_at(BasicType type, DecoratorSet decorato if (as_raw) { bs->BarrierSetAssembler::load_at(this, decorators, type, base, ind_or_offs, dst, - tmp1, tmp2, needs_frame, L_handle_null); + tmp1, tmp2, preservation_level, L_handle_null); } else { bs->load_at(this, decorators, type, base, ind_or_offs, dst, - tmp1, tmp2, needs_frame, L_handle_null); + tmp1, tmp2, preservation_level, L_handle_null); } } inline void MacroAssembler::load_heap_oop(Register d, RegisterOrConstant offs, Register s1, Register tmp1, Register tmp2, - bool needs_frame, DecoratorSet decorators, Label *L_handle_null) { - access_load_at(T_OBJECT, IN_HEAP | decorators, s1, offs, d, tmp1, tmp2, needs_frame, L_handle_null); + MacroAssembler::PreservationLevel preservation_level, + DecoratorSet decorators, Label *L_handle_null) { + access_load_at(T_OBJECT, decorators | IN_HEAP, s1, offs, d, tmp1, tmp2, + preservation_level, L_handle_null); } inline void MacroAssembler::store_heap_oop(Register d, RegisterOrConstant offs, Register s1, Register tmp1, Register tmp2, Register tmp3, - bool needs_frame, DecoratorSet decorators) { - access_store_at(T_OBJECT, IN_HEAP | decorators, s1, offs, d, tmp1, tmp2, tmp3, needs_frame); + MacroAssembler::PreservationLevel preservation_level, + DecoratorSet decorators) { + access_store_at(T_OBJECT, decorators | IN_HEAP, s1, offs, d, tmp1, tmp2, tmp3, preservation_level); } inline Register MacroAssembler::encode_heap_oop_not_null(Register d, Register src) { diff --git a/src/hotspot/cpu/ppc/methodHandles_ppc.cpp b/src/hotspot/cpu/ppc/methodHandles_ppc.cpp index ac354c2361049..b6309a07392fa 100644 --- a/src/hotspot/cpu/ppc/methodHandles_ppc.cpp +++ b/src/hotspot/cpu/ppc/methodHandles_ppc.cpp @@ -1,6 +1,6 @@ /* * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012, 2017 SAP SE. All rights reserved. + * Copyright (c) 2012, 2021 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -173,19 +173,24 @@ void MethodHandles::jump_to_lambda_form(MacroAssembler* _masm, BLOCK_COMMENT("jump_to_lambda_form {"); // This is the initial entry point of a lazy method handle. // After type checking, it picks up the invoker from the LambdaForm. - assert_different_registers(recv, method_temp, temp2); // temp3 is only passed on + assert_different_registers(recv, method_temp, temp2, temp3); assert(method_temp == R19_method, "required register for loading method"); // Load the invoker, as MH -> MH.form -> LF.vmentry __ verify_oop(recv, FILE_AND_LINE); + + const MacroAssembler::PreservationLevel preservation_level = for_compiler_entry + ? MacroAssembler::PRESERVATION_FRAME_LR_GP_FP_REGS + : MacroAssembler::PRESERVATION_FRAME_LR; + __ load_heap_oop(method_temp, NONZERO(java_lang_invoke_MethodHandle::form_offset()), recv, - temp2, noreg, false, IS_NOT_NULL); + temp2, temp3, preservation_level, IS_NOT_NULL); __ verify_oop(method_temp, FILE_AND_LINE); __ load_heap_oop(method_temp, NONZERO(java_lang_invoke_LambdaForm::vmentry_offset()), method_temp, - temp2, noreg, false, IS_NOT_NULL); + temp2, temp3, preservation_level, IS_NOT_NULL); __ verify_oop(method_temp, FILE_AND_LINE); __ load_heap_oop(method_temp, NONZERO(java_lang_invoke_MemberName::method_offset()), method_temp, - temp2, noreg, false, IS_NOT_NULL); + temp2, temp3, preservation_level, IS_NOT_NULL); __ verify_oop(method_temp, FILE_AND_LINE); __ ld(method_temp, NONZERO(java_lang_invoke_ResolvedMethodName::vmtarget_offset()), method_temp); @@ -230,10 +235,9 @@ address MethodHandles::generate_method_handle_interpreter_entry(MacroAssembler* return NULL; } - Register argbase = R15_esp; // parameter (preserved) - Register argslot = R3; - Register temp1 = R6; - Register param_size = R7; + Register R15_argbase = R15_esp; // parameter (preserved) + Register R30_tmp1 = R30; + Register R7_param_size = R7; // here's where control starts out: __ align(CodeEntryAlignment); @@ -244,9 +248,9 @@ address MethodHandles::generate_method_handle_interpreter_entry(MacroAssembler* Label L; BLOCK_COMMENT("verify_intrinsic_id {"); - __ load_sized_value(temp1, Method::intrinsic_id_offset_in_bytes(), R19_method, + __ load_sized_value(R30_tmp1, Method::intrinsic_id_offset_in_bytes(), R19_method, sizeof(u2), /*is_signed*/ false); - __ cmpwi(CCR1, temp1, (int) iid); + __ cmpwi(CCR1, R30_tmp1, (int) iid); __ beq(CCR1, L); if (iid == vmIntrinsics::_linkToVirtual || iid == vmIntrinsics::_linkToSpecial) { @@ -262,18 +266,18 @@ address MethodHandles::generate_method_handle_interpreter_entry(MacroAssembler* int ref_kind = signature_polymorphic_intrinsic_ref_kind(iid); assert(ref_kind != 0 || iid == vmIntrinsics::_invokeBasic, "must be _invokeBasic or a linkTo intrinsic"); if (ref_kind == 0 || MethodHandles::ref_kind_has_receiver(ref_kind)) { - __ ld(param_size, in_bytes(Method::const_offset()), R19_method); - __ load_sized_value(param_size, in_bytes(ConstMethod::size_of_parameters_offset()), param_size, + __ ld(R7_param_size, in_bytes(Method::const_offset()), R19_method); + __ load_sized_value(R7_param_size, in_bytes(ConstMethod::size_of_parameters_offset()), R7_param_size, sizeof(u2), /*is_signed*/ false); // assert(sizeof(u2) == sizeof(ConstMethod::_size_of_parameters), ""); } else { - DEBUG_ONLY(param_size = noreg); + DEBUG_ONLY(R7_param_size = noreg); } Register tmp_mh = noreg; if (!is_signature_polymorphic_static(iid)) { - __ ld(tmp_mh = temp1, __ argument_offset(param_size, param_size, 0), argbase); - DEBUG_ONLY(param_size = noreg); + __ ld(tmp_mh = R30_tmp1, __ argument_offset(R7_param_size, R7_param_size, 0), R15_argbase); + DEBUG_ONLY(R7_param_size = noreg); } if (log_is_enabled(Info, methodhandles)) { @@ -291,12 +295,12 @@ address MethodHandles::generate_method_handle_interpreter_entry(MacroAssembler* Register tmp_recv = noreg; if (MethodHandles::ref_kind_has_receiver(ref_kind)) { // Load the receiver (not the MH; the actual MemberName's receiver) up from the interpreter stack. - __ ld(tmp_recv = temp1, __ argument_offset(param_size, param_size, 0), argbase); - DEBUG_ONLY(param_size = noreg); + __ ld(tmp_recv = R30_tmp1, __ argument_offset(R7_param_size, R7_param_size, 0), R15_argbase); + DEBUG_ONLY(R7_param_size = noreg); } Register R19_member = R19_method; // MemberName ptr; incoming method ptr is dead now - __ ld(R19_member, RegisterOrConstant((intptr_t)8), argbase); - __ add(argbase, Interpreter::stackElementSize, argbase); + __ ld(R19_member, RegisterOrConstant((intptr_t)8), R15_argbase); + __ add(R15_argbase, Interpreter::stackElementSize, R15_argbase); generate_method_handle_dispatch(_masm, iid, tmp_recv, R19_member, not_for_compiler_entry); } @@ -309,13 +313,17 @@ void MethodHandles::generate_method_handle_dispatch(MacroAssembler* _masm, Register member_reg, bool for_compiler_entry) { assert(is_signature_polymorphic(iid), "expected invoke iid"); - Register temp1 = (for_compiler_entry ? R25_tmp5 : R7); + Register temp1 = (for_compiler_entry ? R25_tmp5 : R31); // must be non-volatile due to runtime calls Register temp2 = (for_compiler_entry ? R22_tmp2 : R8); Register temp3 = (for_compiler_entry ? R23_tmp3 : R9); Register temp4 = (for_compiler_entry ? R24_tmp4 : R10); if (receiver_reg != noreg) assert_different_registers(temp1, temp2, temp3, temp4, receiver_reg); if (member_reg != noreg) assert_different_registers(temp1, temp2, temp3, temp4, member_reg); + const MacroAssembler::PreservationLevel preservation_level = for_compiler_entry + ? MacroAssembler::PRESERVATION_FRAME_LR_GP_FP_REGS + : MacroAssembler::PRESERVATION_FRAME_LR; + if (iid == vmIntrinsics::_invokeBasic || iid == vmIntrinsics::_linkToNative) { if (iid == vmIntrinsics::_linkToNative) { assert(for_compiler_entry, "only compiler entry is supported"); @@ -333,31 +341,26 @@ void MethodHandles::generate_method_handle_dispatch(MacroAssembler* _masm, Register temp1_recv_klass = temp1; if (iid != vmIntrinsics::_linkToStatic) { - __ verify_oop(receiver_reg, FILE_AND_LINE); - if (iid == vmIntrinsics::_linkToSpecial) { - // Don't actually load the klass; just null-check the receiver. - __ null_check_throw(receiver_reg, -1, temp1, - Interpreter::throw_NullPointerException_entry()); - } else { - // load receiver klass itself - __ null_check_throw(receiver_reg, oopDesc::klass_offset_in_bytes(), temp1, - Interpreter::throw_NullPointerException_entry()); - __ load_klass(temp1_recv_klass, receiver_reg); - __ verify_klass_ptr(temp1_recv_klass); - } BLOCK_COMMENT("check_receiver {"); - // The receiver for the MemberName must be in receiver_reg. - // Check the receiver against the MemberName.clazz - if (VerifyMethodHandles && iid == vmIntrinsics::_linkToSpecial) { - // Did not load it above... + __ verify_oop(receiver_reg, FILE_AND_LINE); + + const int klass_offset = iid == vmIntrinsics::_linkToSpecial + ? -1 // enforce receiver null check + : oopDesc::klass_offset_in_bytes(); // regular null-checking behavior + + __ null_check_throw(receiver_reg, klass_offset, temp1, Interpreter::throw_NullPointerException_entry()); + + if (iid != vmIntrinsics::_linkToSpecial || VerifyMethodHandles) { __ load_klass(temp1_recv_klass, receiver_reg); __ verify_klass_ptr(temp1_recv_klass); } + if (VerifyMethodHandles && iid != vmIntrinsics::_linkToInterface) { Label L_ok; Register temp2_defc = temp2; + __ load_heap_oop(temp2_defc, NONZERO(java_lang_invoke_MemberName::clazz_offset()), member_reg, - temp3, noreg, false, IS_NOT_NULL); + temp3, temp4, preservation_level, IS_NOT_NULL); load_klass_from_Class(_masm, temp2_defc, temp3, temp4); __ verify_klass_ptr(temp2_defc); __ check_klass_subtype(temp1_recv_klass, temp2_defc, temp3, temp4, L_ok); @@ -375,8 +378,6 @@ void MethodHandles::generate_method_handle_dispatch(MacroAssembler* _masm, // Live registers at this point: // member_reg - MemberName that was the trailing argument // temp1_recv_klass - klass of stacked receiver, if needed - // O5_savedSP - interpreter linkage (if interpreted) - // O0..O5 - compiler arguments (if compiled) Label L_incompatible_class_change_error; switch (iid) { @@ -385,7 +386,7 @@ void MethodHandles::generate_method_handle_dispatch(MacroAssembler* _masm, verify_ref_kind(_masm, JVM_REF_invokeSpecial, member_reg, temp2); } __ load_heap_oop(R19_method, NONZERO(java_lang_invoke_MemberName::method_offset()), member_reg, - temp3, noreg, false, IS_NOT_NULL); + temp3, temp4, preservation_level, IS_NOT_NULL); __ ld(R19_method, NONZERO(java_lang_invoke_ResolvedMethodName::vmtarget_offset()), R19_method); break; @@ -394,7 +395,7 @@ void MethodHandles::generate_method_handle_dispatch(MacroAssembler* _masm, verify_ref_kind(_masm, JVM_REF_invokeStatic, member_reg, temp2); } __ load_heap_oop(R19_method, NONZERO(java_lang_invoke_MemberName::method_offset()), member_reg, - temp3, noreg, false, IS_NOT_NULL); + temp3, temp4, preservation_level, IS_NOT_NULL); __ ld(R19_method, NONZERO(java_lang_invoke_ResolvedMethodName::vmtarget_offset()), R19_method); break; @@ -437,7 +438,7 @@ void MethodHandles::generate_method_handle_dispatch(MacroAssembler* _masm, Register temp2_intf = temp2; __ load_heap_oop(temp2_intf, NONZERO(java_lang_invoke_MemberName::clazz_offset()), member_reg, - temp3, noreg, false, IS_NOT_NULL); + temp3, temp4, preservation_level, IS_NOT_NULL); load_klass_from_Class(_masm, temp2_intf, temp3, temp4); __ verify_klass_ptr(temp2_intf); @@ -467,7 +468,6 @@ void MethodHandles::generate_method_handle_dispatch(MacroAssembler* _masm, // Live at this point: // R19_method - // O5_savedSP (if interpreted) // After figuring out which concrete method to call, jump into it. // Note that this works in the interpreter with no data motion. diff --git a/src/hotspot/cpu/ppc/sharedRuntime_ppc.cpp b/src/hotspot/cpu/ppc/sharedRuntime_ppc.cpp index f9b95f00c42d5..f9b52195b056d 100644 --- a/src/hotspot/cpu/ppc/sharedRuntime_ppc.cpp +++ b/src/hotspot/cpu/ppc/sharedRuntime_ppc.cpp @@ -1,6 +1,6 @@ /* - * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012, 2020 SAP SE. All rights reserved. + * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2021 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -2430,7 +2430,7 @@ nmethod *SharedRuntime::generate_native_wrapper(MacroAssembler *masm, // -------------------------------------------------------------------------- if (is_reference_type(ret_type)) { - __ resolve_jobject(R3_RET, r_temp_1, r_temp_2, /* needs_frame */ false); + __ resolve_jobject(R3_RET, r_temp_1, r_temp_2, MacroAssembler::PRESERVATION_NONE); } if (CheckJNICalls) { diff --git a/src/hotspot/cpu/ppc/stubGenerator_ppc.cpp b/src/hotspot/cpu/ppc/stubGenerator_ppc.cpp index 815136b8e3f43..f38e02d46e2e4 100644 --- a/src/hotspot/cpu/ppc/stubGenerator_ppc.cpp +++ b/src/hotspot/cpu/ppc/stubGenerator_ppc.cpp @@ -1,6 +1,6 @@ /* * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012, 2020 SAP SE. All rights reserved. + * Copyright (c) 2012, 2021 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -2226,7 +2226,10 @@ class StubGenerator: public StubCodeGenerator { // ======== loop entry is here ======== __ bind(load_element); - __ load_heap_oop(R10_oop, R8_offset, R3_from, R12_tmp, noreg, false, AS_RAW, &store_null); + __ load_heap_oop(R10_oop, R8_offset, R3_from, + R11_scratch1, R12_tmp, + MacroAssembler::PRESERVATION_FRAME_LR_GP_REGS, + AS_RAW, &store_null); __ load_klass(R11_klass, R10_oop); // Query the object klass. diff --git a/src/hotspot/cpu/ppc/templateInterpreterGenerator_ppc.cpp b/src/hotspot/cpu/ppc/templateInterpreterGenerator_ppc.cpp index 59f93fabee6a9..ed95650255cea 100644 --- a/src/hotspot/cpu/ppc/templateInterpreterGenerator_ppc.cpp +++ b/src/hotspot/cpu/ppc/templateInterpreterGenerator_ppc.cpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2015, 2019 SAP SE. All rights reserved. + * Copyright (c) 2015, 2021 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -405,7 +405,7 @@ address TemplateInterpreterGenerator::generate_result_handler_for(BasicType type break; case T_OBJECT: // JNIHandles::resolve result. - __ resolve_jobject(R3_RET, R11_scratch1, R31, /* needs_frame */ true); // kills R31 + __ resolve_jobject(R3_RET, R11_scratch1, R31, MacroAssembler::PRESERVATION_FRAME_LR); // kills R31 break; case T_FLOAT: break; @@ -526,7 +526,9 @@ address TemplateInterpreterGenerator::generate_Reference_get_entry(void) { __ beq(CCR0, slow_path); __ load_heap_oop(R3_RET, referent_offset, R3_RET, - /* non-volatile temp */ R31, R11_scratch1, true, ON_WEAK_OOP_REF); + /* non-volatile temp */ R31, R11_scratch1, + MacroAssembler::PRESERVATION_FRAME_LR, + ON_WEAK_OOP_REF); // Generate the G1 pre-barrier code to log the value of // the referent field in an SATB buffer. Note with diff --git a/src/hotspot/cpu/ppc/templateTable_ppc_64.cpp b/src/hotspot/cpu/ppc/templateTable_ppc_64.cpp index 9dded963d15ba..d5916eb0a730b 100644 --- a/src/hotspot/cpu/ppc/templateTable_ppc_64.cpp +++ b/src/hotspot/cpu/ppc/templateTable_ppc_64.cpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2013, 2020 SAP SE. All rights reserved. + * Copyright (c) 2013, 2021 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -68,7 +68,7 @@ static void do_oop_store(InterpreterMacroAssembler* _masm, Register tmp3, DecoratorSet decorators) { assert_different_registers(tmp1, tmp2, tmp3, val, base); - __ store_heap_oop(val, offset, base, tmp1, tmp2, tmp3, false, decorators); + __ store_heap_oop(val, offset, base, tmp1, tmp2, tmp3, MacroAssembler::PRESERVATION_NONE, decorators); } static void do_oop_load(InterpreterMacroAssembler* _masm, @@ -80,7 +80,7 @@ static void do_oop_load(InterpreterMacroAssembler* _masm, DecoratorSet decorators) { assert_different_registers(base, tmp1, tmp2); assert_different_registers(dst, tmp1, tmp2); - __ load_heap_oop(dst, offset, base, tmp1, tmp2, false, decorators); + __ load_heap_oop(dst, offset, base, tmp1, tmp2, MacroAssembler::PRESERVATION_NONE, decorators); } Address TemplateTable::at_bcp(int offset) { @@ -305,19 +305,18 @@ void TemplateTable::fast_aldc(bool wide) { transition(vtos, atos); int index_size = wide ? sizeof(u2) : sizeof(u1); - const Register Rscratch = R11_scratch1; Label is_null; // We are resolved if the resolved reference cache entry contains a // non-null object (CallSite, etc.) - __ get_cache_index_at_bcp(Rscratch, 1, index_size); // Load index. - __ load_resolved_reference_at_index(R17_tos, Rscratch, &is_null); + __ get_cache_index_at_bcp(R11_scratch1, 1, index_size); // Load index. + __ load_resolved_reference_at_index(R17_tos, R11_scratch1, R12_scratch2, &is_null); // Convert null sentinel to NULL - int simm16_rest = __ load_const_optimized(Rscratch, Universe::the_null_sentinel_addr(), R0, true); - __ ld(Rscratch, simm16_rest, Rscratch); - __ resolve_oop_handle(Rscratch); - __ cmpld(CCR0, R17_tos, Rscratch); + int simm16_rest = __ load_const_optimized(R11_scratch1, Universe::the_null_sentinel_addr(), R0, true); + __ ld(R11_scratch1, simm16_rest, R11_scratch1); + __ resolve_oop_handle(R11_scratch1); + __ cmpld(CCR0, R17_tos, R11_scratch1); if (VM_Version::has_isel()) { __ isel_0(R17_tos, CCR0, Assembler::equal); } else { @@ -2427,7 +2426,7 @@ void TemplateTable::getfield_or_static(int byte_no, bool is_static, RewriteContr Roffset = R23_tmp3, Rflags = R31, Rbtable = R5_ARG3, - Rbc = R6_ARG4, + Rbc = R30, Rscratch = R12_scratch2; static address field_branch_table[number_of_states], @@ -2462,7 +2461,7 @@ void TemplateTable::getfield_or_static(int byte_no, bool is_static, RewriteContr // Load from branch table and dispatch (volatile case: one instruction ahead). __ sldi(Rflags, Rflags, LogBytesPerWord); - __ cmpwi(CCR6, Rscratch, 1); // Volatile? + __ cmpwi(CCR2, Rscratch, 1); // Volatile? if (support_IRIW_for_not_multiple_copy_atomic_cpu) { __ sldi(Rscratch, Rscratch, exact_log2(BytesPerInstWord)); // Volatile ? size of 1 instruction : 0. } @@ -2513,7 +2512,7 @@ void TemplateTable::getfield_or_static(int byte_no, bool is_static, RewriteContr } { Label acquire_double; - __ beq(CCR6, acquire_double); // Volatile? + __ beq(CCR2, acquire_double); // Volatile? __ dispatch_epilog(vtos, Bytecodes::length_for(bytecode())); __ bind(acquire_double); @@ -2534,7 +2533,7 @@ void TemplateTable::getfield_or_static(int byte_no, bool is_static, RewriteContr } { Label acquire_float; - __ beq(CCR6, acquire_float); // Volatile? + __ beq(CCR2, acquire_float); // Volatile? __ dispatch_epilog(vtos, Bytecodes::length_for(bytecode())); __ bind(acquire_float); @@ -2553,7 +2552,7 @@ void TemplateTable::getfield_or_static(int byte_no, bool is_static, RewriteContr if (!is_static && rc == may_rewrite) { patch_bytecode(Bytecodes::_fast_igetfield, Rbc, Rscratch); } - __ beq(CCR6, Lacquire); // Volatile? + __ beq(CCR2, Lacquire); // Volatile? __ dispatch_epilog(vtos, Bytecodes::length_for(bytecode())); __ align(32, 28, 28); // Align load. @@ -2566,7 +2565,7 @@ void TemplateTable::getfield_or_static(int byte_no, bool is_static, RewriteContr if (!is_static && rc == may_rewrite) { patch_bytecode(Bytecodes::_fast_lgetfield, Rbc, Rscratch); } - __ beq(CCR6, Lacquire); // Volatile? + __ beq(CCR2, Lacquire); // Volatile? __ dispatch_epilog(vtos, Bytecodes::length_for(bytecode())); __ align(32, 28, 28); // Align load. @@ -2580,7 +2579,7 @@ void TemplateTable::getfield_or_static(int byte_no, bool is_static, RewriteContr if (!is_static && rc == may_rewrite) { patch_bytecode(Bytecodes::_fast_bgetfield, Rbc, Rscratch); } - __ beq(CCR6, Lacquire); // Volatile? + __ beq(CCR2, Lacquire); // Volatile? __ dispatch_epilog(vtos, Bytecodes::length_for(bytecode())); __ align(32, 28, 28); // Align load. @@ -2594,7 +2593,7 @@ void TemplateTable::getfield_or_static(int byte_no, bool is_static, RewriteContr // use btos rewriting, no truncating to t/f bit is needed for getfield. patch_bytecode(Bytecodes::_fast_bgetfield, Rbc, Rscratch); } - __ beq(CCR6, Lacquire); // Volatile? + __ beq(CCR2, Lacquire); // Volatile? __ dispatch_epilog(vtos, Bytecodes::length_for(bytecode())); __ align(32, 28, 28); // Align load. @@ -2607,7 +2606,7 @@ void TemplateTable::getfield_or_static(int byte_no, bool is_static, RewriteContr if (!is_static && rc == may_rewrite) { patch_bytecode(Bytecodes::_fast_cgetfield, Rbc, Rscratch); } - __ beq(CCR6, Lacquire); // Volatile? + __ beq(CCR2, Lacquire); // Volatile? __ dispatch_epilog(vtos, Bytecodes::length_for(bytecode())); __ align(32, 28, 28); // Align load. @@ -2620,7 +2619,7 @@ void TemplateTable::getfield_or_static(int byte_no, bool is_static, RewriteContr if (!is_static && rc == may_rewrite) { patch_bytecode(Bytecodes::_fast_sgetfield, Rbc, Rscratch); } - __ beq(CCR6, Lacquire); // Volatile? + __ beq(CCR2, Lacquire); // Volatile? __ dispatch_epilog(vtos, Bytecodes::length_for(bytecode())); __ align(32, 28, 28); // Align load. @@ -2635,7 +2634,7 @@ void TemplateTable::getfield_or_static(int byte_no, bool is_static, RewriteContr if (!is_static && rc == may_rewrite) { patch_bytecode(Bytecodes::_fast_agetfield, Rbc, Rscratch); } - __ beq(CCR6, Lacquire); // Volatile? + __ beq(CCR2, Lacquire); // Volatile? __ dispatch_epilog(vtos, Bytecodes::length_for(bytecode())); __ align(32, 12); @@ -3332,7 +3331,8 @@ void TemplateTable::prepare_invoke(int byte_no, assert_different_registers(Rmethod, Rindex, Rflags, Rscratch); assert_different_registers(Rmethod, Rrecv, Rflags, Rscratch); - assert_different_registers(Rret_addr, Rscratch); + // Rret_addr and Rindex have to be distinct as Rret_addr is used as a second temp register + assert_different_registers(Rret_addr, Rindex, Rscratch); load_invoke_cp_cache_entry(byte_no, Rmethod, Rindex, Rflags, is_invokevirtual, false, is_invokedynamic); @@ -3341,14 +3341,16 @@ void TemplateTable::prepare_invoke(int byte_no, // Maybe push "appendix" to arguments. if (is_invokedynamic || is_invokehandle) { Label Ldone; + Register reference = Rret_addr; // safe to use here; first use comes later + __ rldicl_(R0, Rflags, 64-ConstantPoolCacheEntry::has_appendix_shift, 63); __ beq(CCR0, Ldone); // Push "appendix" (MethodType, CallSite, etc.). // This must be done before we get the receiver, // since the parameter_size includes it. - __ load_resolved_reference_at_index(Rscratch, Rindex); - __ verify_oop(Rscratch); - __ push_ptr(Rscratch); + __ load_resolved_reference_at_index(reference, Rindex, Rscratch); + __ verify_oop(reference); + __ push_ptr(reference); __ bind(Ldone); } @@ -3649,7 +3651,7 @@ void TemplateTable::invokedynamic(int byte_no) { transition(vtos, vtos); const Register Rret_addr = R3_ARG1, - Rflags = R4_ARG2, + Rflags = R31, Rmethod = R22_tmp2, Rscratch1 = R11_scratch1, Rscratch2 = R12_scratch2; @@ -3673,7 +3675,7 @@ void TemplateTable::invokehandle(int byte_no) { transition(vtos, vtos); const Register Rret_addr = R3_ARG1, - Rflags = R4_ARG2, + Rflags = R31, Rrecv = R5_ARG3, Rmethod = R22_tmp2, Rscratch1 = R11_scratch1, From d7b1fc59a51ef2d0f2d9106d9241be44cbe02ee8 Mon Sep 17 00:00:00 2001 From: Thomas Stuefe Date: Tue, 2 Feb 2021 17:56:38 +0000 Subject: [PATCH 22/77] 8260707: java/lang/instrument/PremainClass/InheritAgent0100.java times out Co-authored-by: Arno Zeller Reviewed-by: dholmes, sspitsyn, dcubed --- test/jdk/java/lang/instrument/NegativeAgentRunner.java | 2 +- .../jdk/java/lang/instrument/PremainClass/NoPremainAgent.java | 4 ++-- .../lang/instrument/PremainClass/ZeroArgPremainAgent.java | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/jdk/java/lang/instrument/NegativeAgentRunner.java b/test/jdk/java/lang/instrument/NegativeAgentRunner.java index 4b76965ce3aeb..1b7ff2f73359d 100644 --- a/test/jdk/java/lang/instrument/NegativeAgentRunner.java +++ b/test/jdk/java/lang/instrument/NegativeAgentRunner.java @@ -36,7 +36,7 @@ public static void main(String argv[]) throws Exception { String agentClassName = argv[0]; String excepClassName = argv[1]; ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( - "-javaagent:" + agentClassName + ".jar", + "-javaagent:" + agentClassName + ".jar", "-Xmx128m", "-XX:-CreateCoredumpOnCrash", agentClassName); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldContain(excepClassName); diff --git a/test/jdk/java/lang/instrument/PremainClass/NoPremainAgent.java b/test/jdk/java/lang/instrument/PremainClass/NoPremainAgent.java index d906540d4b4eb..87687459e468f 100644 --- a/test/jdk/java/lang/instrument/PremainClass/NoPremainAgent.java +++ b/test/jdk/java/lang/instrument/PremainClass/NoPremainAgent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,7 +31,7 @@ * @build jdk.java.lang.instrument.PremainClass.NoPremainAgent * @run driver jdk.test.lib.util.JavaAgentBuilder * NoPremainAgent NoPremainAgent.jar - * @run main/othervm -XX:-CreateCoredumpOnCrash jdk.java.lang.instrument.NegativeAgentRunner NoPremainAgent NoSuchMethodException + * @run main/othervm jdk.java.lang.instrument.NegativeAgentRunner NoPremainAgent NoSuchMethodException */ public class NoPremainAgent { diff --git a/test/jdk/java/lang/instrument/PremainClass/ZeroArgPremainAgent.java b/test/jdk/java/lang/instrument/PremainClass/ZeroArgPremainAgent.java index 9dc800b29e5eb..05cd23ad1a12c 100644 --- a/test/jdk/java/lang/instrument/PremainClass/ZeroArgPremainAgent.java +++ b/test/jdk/java/lang/instrument/PremainClass/ZeroArgPremainAgent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ * @build jdk.java.lang.instrument.PremainClass.ZeroArgPremainAgent * @run driver jdk.test.lib.util.JavaAgentBuilder * ZeroArgPremainAgent ZeroArgPremainAgent.jar - * @run main/othervm -XX:-CreateCoredumpOnCrash jdk.java.lang.instrument.NegativeAgentRunner ZeroArgPremainAgent NoSuchMethodException + * @run main/othervm jdk.java.lang.instrument.NegativeAgentRunner ZeroArgPremainAgent NoSuchMethodException */ public class ZeroArgPremainAgent { From 081fa3e7154db433b10b940ff223fd3d50099521 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Tue, 2 Feb 2021 18:00:43 +0000 Subject: [PATCH 23/77] 8260927: StringBuilder::insert is incorrect without Compact Strings Reviewed-by: redestad, alanb, rriggs, jlaskey --- src/java.base/share/classes/java/lang/String.java | 2 +- test/jdk/java/lang/StringBuilder/Insert.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/java.base/share/classes/java/lang/String.java b/src/java.base/share/classes/java/lang/String.java index e96943ffe1327..0892c37b22674 100644 --- a/src/java.base/share/classes/java/lang/String.java +++ b/src/java.base/share/classes/java/lang/String.java @@ -3621,7 +3621,7 @@ void getBytes(byte[] dst, int dstBegin, byte coder) { */ void getBytes(byte[] dst, int srcPos, int dstBegin, byte coder, int length) { if (coder() == coder) { - System.arraycopy(value, srcPos, dst, dstBegin << coder, length << coder()); + System.arraycopy(value, srcPos << coder, dst, dstBegin << coder, length << coder); } else { // this.coder == LATIN && coder == UTF16 StringLatin1.inflate(value, srcPos, dst, dstBegin, length); } diff --git a/test/jdk/java/lang/StringBuilder/Insert.java b/test/jdk/java/lang/StringBuilder/Insert.java index d4b1ef28d866f..ad1c7df20e20f 100644 --- a/test/jdk/java/lang/StringBuilder/Insert.java +++ b/test/jdk/java/lang/StringBuilder/Insert.java @@ -27,9 +27,10 @@ /** * @test - * @run testng Insert * @bug 4914802 8257511 * @summary Test StringBuilder.insert sanity tests + * @run testng/othervm -XX:-CompactStrings Insert + * @run testng/othervm -XX:+CompactStrings Insert */ @Test public class Insert { From f546fd00978373d1c596ee4151696add58569274 Mon Sep 17 00:00:00 2001 From: Thomas Stuefe Date: Tue, 2 Feb 2021 18:21:53 +0000 Subject: [PATCH 24/77] 8260902: CDS mapping errors should not lead to unconditional output Reviewed-by: iklam --- src/hotspot/share/memory/filemap.cpp | 2 +- src/hotspot/share/memory/metaspaceShared.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/hotspot/share/memory/filemap.cpp b/src/hotspot/share/memory/filemap.cpp index cf65243fdc05a..db4ce1208bbd8 100644 --- a/src/hotspot/share/memory/filemap.cpp +++ b/src/hotspot/share/memory/filemap.cpp @@ -1667,7 +1667,7 @@ char* FileMapInfo::map_bitmap_region() { char* bitmap_base = os::map_memory(_fd, _full_path, si->file_offset(), requested_addr, si->used_aligned(), read_only, allow_exec, mtClassShared); if (bitmap_base == NULL) { - log_error(cds)("failed to map relocation bitmap"); + log_info(cds)("failed to map relocation bitmap"); return NULL; } diff --git a/src/hotspot/share/memory/metaspaceShared.cpp b/src/hotspot/share/memory/metaspaceShared.cpp index 02cb6a92adb2c..bc9dc6948f8b0 100644 --- a/src/hotspot/share/memory/metaspaceShared.cpp +++ b/src/hotspot/share/memory/metaspaceShared.cpp @@ -1723,8 +1723,8 @@ MapArchiveResult MetaspaceShared::map_archive(FileMapInfo* mapinfo, char* mapped mapinfo->set_is_mapped(false); if (mapinfo->alignment() != (size_t)os::vm_allocation_granularity()) { - log_error(cds)("Unable to map CDS archive -- os::vm_allocation_granularity() expected: " SIZE_FORMAT - " actual: %d", mapinfo->alignment(), os::vm_allocation_granularity()); + log_info(cds)("Unable to map CDS archive -- os::vm_allocation_granularity() expected: " SIZE_FORMAT + " actual: %d", mapinfo->alignment(), os::vm_allocation_granularity()); return MAP_ARCHIVE_OTHER_FAILURE; } From 69189f8820fa5e016f8dc651b6dcb77b4dd1bbdd Mon Sep 17 00:00:00 2001 From: Rajan Halade Date: Tue, 2 Feb 2021 18:26:34 +0000 Subject: [PATCH 25/77] 8256421: Add 2 HARICA roots to cacerts truststore Reviewed-by: hchao, mullan --- make/data/cacerts/haricaeccrootca2015 | 24 ++ make/data/cacerts/haricarootca2015 | 42 +++ .../certification/HaricaCA.java | 320 ++++++++++++++++++ .../security/lib/cacerts/VerifyCACerts.java | 10 +- 4 files changed, 393 insertions(+), 3 deletions(-) create mode 100644 make/data/cacerts/haricaeccrootca2015 create mode 100644 make/data/cacerts/haricarootca2015 create mode 100644 test/jdk/security/infra/java/security/cert/CertPathValidator/certification/HaricaCA.java diff --git a/make/data/cacerts/haricaeccrootca2015 b/make/data/cacerts/haricaeccrootca2015 new file mode 100644 index 0000000000000..4337f68c64356 --- /dev/null +++ b/make/data/cacerts/haricaeccrootca2015 @@ -0,0 +1,24 @@ +Owner: CN=Hellenic Academic and Research Institutions ECC RootCA 2015, O=Hellenic Academic and Research Institutions Cert. Authority, L=Athens, C=GR +Issuer: CN=Hellenic Academic and Research Institutions ECC RootCA 2015, O=Hellenic Academic and Research Institutions Cert. Authority, L=Athens, C=GR +Serial number: 0 +Valid from: Tue Jul 07 10:37:12 GMT 2015 until: Sat Jun 30 10:37:12 GMT 2040 +Signature algorithm name: SHA256withECDSA +Subject Public Key Algorithm: 384-bit EC key +Version: 3 +-----BEGIN CERTIFICATE----- +MIICwzCCAkqgAwIBAgIBADAKBggqhkjOPQQDAjCBqjELMAkGA1UEBhMCR1IxDzAN +BgNVBAcTBkF0aGVuczFEMEIGA1UEChM7SGVsbGVuaWMgQWNhZGVtaWMgYW5kIFJl +c2VhcmNoIEluc3RpdHV0aW9ucyBDZXJ0LiBBdXRob3JpdHkxRDBCBgNVBAMTO0hl +bGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgRUNDIFJv +b3RDQSAyMDE1MB4XDTE1MDcwNzEwMzcxMloXDTQwMDYzMDEwMzcxMlowgaoxCzAJ +BgNVBAYTAkdSMQ8wDQYDVQQHEwZBdGhlbnMxRDBCBgNVBAoTO0hlbGxlbmljIEFj +YWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgQ2VydC4gQXV0aG9yaXR5 +MUQwQgYDVQQDEztIZWxsZW5pYyBBY2FkZW1pYyBhbmQgUmVzZWFyY2ggSW5zdGl0 +dXRpb25zIEVDQyBSb290Q0EgMjAxNTB2MBAGByqGSM49AgEGBSuBBAAiA2IABJKg +QehLgoRc4vgxEZmGZE4JJS+dQS8KrjVPdJWyUWRrjWvmP3CV8AVER6ZyOFB2lQJa +jq4onvktTpnvLEhvTCUp6NFxW98dwXU3tNf6e3pCnGoKVlp8aQuqgAkkbH7BRqNC +MEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFLQi +C4KZJAEOnLvkDv2/+5cgk5kqMAoGCCqGSM49BAMCA2cAMGQCMGfOFmI4oqxiRaep +lSTAGiecMjvAwNW6qef4BENThe5SId6d9SWDPp5YSy/XZxMOIQIwBeF1Ad5o7Sof +TUwJCA3sS61kFyjndc5FZXIhF8siQQ6ME5g4mlRtm8rifOoCWCKR +-----END CERTIFICATE----- diff --git a/make/data/cacerts/haricarootca2015 b/make/data/cacerts/haricarootca2015 new file mode 100644 index 0000000000000..239ecf7d0a3ff --- /dev/null +++ b/make/data/cacerts/haricarootca2015 @@ -0,0 +1,42 @@ +Owner: CN=Hellenic Academic and Research Institutions RootCA 2015, O=Hellenic Academic and Research Institutions Cert. Authority, L=Athens, C=GR +Issuer: CN=Hellenic Academic and Research Institutions RootCA 2015, O=Hellenic Academic and Research Institutions Cert. Authority, L=Athens, C=GR +Serial number: 0 +Valid from: Tue Jul 07 10:11:21 GMT 2015 until: Sat Jun 30 10:11:21 GMT 2040 +Signature algorithm name: SHA256withRSA +Subject Public Key Algorithm: 4096-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIGCzCCA/OgAwIBAgIBADANBgkqhkiG9w0BAQsFADCBpjELMAkGA1UEBhMCR1Ix +DzANBgNVBAcTBkF0aGVuczFEMEIGA1UEChM7SGVsbGVuaWMgQWNhZGVtaWMgYW5k +IFJlc2VhcmNoIEluc3RpdHV0aW9ucyBDZXJ0LiBBdXRob3JpdHkxQDA+BgNVBAMT +N0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgUm9v +dENBIDIwMTUwHhcNMTUwNzA3MTAxMTIxWhcNNDAwNjMwMTAxMTIxWjCBpjELMAkG +A1UEBhMCR1IxDzANBgNVBAcTBkF0aGVuczFEMEIGA1UEChM7SGVsbGVuaWMgQWNh +ZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0aW9ucyBDZXJ0LiBBdXRob3JpdHkx +QDA+BgNVBAMTN0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1 +dGlvbnMgUm9vdENBIDIwMTUwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoIC +AQDC+Kk/G4n8PDwEXT2QNrCROnk8ZlrvbTkBSRq0t89/TSNTt5AA4xMqKKYx8ZEA +4yjsriFBzh/a/X0SWwGDD7mwX5nh8hKDgE0GPt+sr+ehiGsxr/CL0BgzuNtFajT0 +AoAkKAoCFZVedioNmToUW/bLy1O8E00BiDeUJRtCvCLYjqOWXjrZMts+6PAQZe10 +4S+nfK8nNLspfZu2zwnI5dMK/IhlZXQK3HMcXM1AsRzUtoSMTFDPaI6oWa7CJ06C +ojXdFPQf/7J31Ycvqm59JCfnxssm5uX+Zwdj2EUN3TpZZTlYepKZcj2chF6IIbjV +9Cz82XBST3i4vTwri5WY9bPRaM8gFH5MXF/ni+X1NYEZN9cRCLdmvtNKzoNXADrD +gfgXy5I2XdGj2HUb4Ysn6npIQf1FGQatJ5lOwXBH3bWfgVMS5bGMSF0xQxfjjMZ6 +Y5ZLKTBOhE5iGV48zpeQpX8B653g+IuJ3SWYPZK2fu/Z8VFRfS0myGlZYeCsargq +NhEEelC9MoS+L9xy1dcdFkfkR2YgP/SWxa+OAXqlD3pk9Q0Yh9muiNX6hME6wGko +LfINaFGq46V3xqSQDqE3izEjR8EJCOtu93ib14L8hCCZSRm2Ekax+0VVFqmjZayc +Bw/qa9wfLgZy7IaIEuQt218FL+TwA9MmM+eAws1CoRc0CwIDAQABo0IwQDAPBgNV +HRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUcRVnyMjJvXVd +ctA4GGqd83EkVAswDQYJKoZIhvcNAQELBQADggIBAHW7bVRLqhBYRjTyYtcWNl0I +XtVsyIe9tC5G8jH4fOpCtZMWVdyhDBKg2mF+D1hYc2Ryx+hFjtyp8iY/xnmMsVMI +M4GwVhO+5lFc2JsKT0ucVlMC6U/2DWDqTUJV6HwbISHTGzrMd/K4kPFox/la/vot +9L/J9UUbzjgQKjeKeaO04wlshYaT/4mWJ3iBj2fjRnRUjtkNaeJK9E10A/+yd+2V +Z5fkscWrv2oj6NSU4kQoYsRL4vDY4ilrGnB+JGGTe08DMiUNRSQrlrRGar9KC/ea +j8GsGsVn82800vpzY4zvFrCopEYq+OsS7HK07/grfoxSwIuEVPkvPuNVqNxmsdnh +X9izjFk0WaSrT2y7HxjbdavYy5LNlDhhDgcGH0tGEPEVvo2FXDtKK4F5D7Rpn0lQ +l033DlZdwJVqwjbDG2jJ9SrcR5q+ss7FJej6A7na+RZukYT1HCjI/CbM1xyQVqdf +bzoEvM14iQuODy+jqk+iGxI9FghAD/FGTNeqewjBCvVtJ94Cj8rDtSvK6evIIVM4 +pcw72Hc3MKJP2W/R8kCtQXoXxdZKNYm3QdV8hn9VTYNKpXMgwDqvkPGaJI7ZjnHK +e7iG2rKPmT4dEw0SEe7Uq/DpFXYC5ODfqiAeW2GFZECpkJcNrVPSWh2HagCXZWK0 +vm9qp/UsQu0yrbYhnr68 +-----END CERTIFICATE----- diff --git a/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/HaricaCA.java b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/HaricaCA.java new file mode 100644 index 0000000000000..247502e6e6cfe --- /dev/null +++ b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/HaricaCA.java @@ -0,0 +1,320 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8256421 + * @summary Interoperability tests with Harica CAs + * @build ValidatePathWithParams + * @run main/othervm -Djava.security.debug=certpath HaricaCA OCSP + * @run main/othervm -Djava.security.debug=certpath HaricaCA CRL + */ + +/* + * Obtain test artifacts for Harica CA from: + * + * CA has no published test sites so we will need to communicate with CA for test. + */ +public class HaricaCA { + + public static void main(String[] args) throws Exception { + + ValidatePathWithParams pathValidator = new ValidatePathWithParams(null); + boolean ocspEnabled = false; + + if (args.length >= 1 && "CRL".equalsIgnoreCase(args[0])) { + pathValidator.enableCRLCheck(); + } else { + // OCSP check by default + pathValidator.enableOCSPCheck(); + ocspEnabled = true; + } + + new Harica_CA().runTest(pathValidator, ocspEnabled); + new Harica_ECC().runTest(pathValidator, ocspEnabled); + } +} + +class Harica_CA { + + // Owner: CN=Hellenic Academic and Research Institutions Code Signing CA R1, + // O=Hellenic Academic and Research Institutions Cert. Authority, L=Athens, C=GR + // Issuer: CN=Hellenic Academic and Research Institutions RootCA 2015, + // O=Hellenic Academic and Research Institutions Cert. Authority, L=Athens, C=GR + // Serial number: 1bc8b59e0cea0b7c + // Valid from: Fri Apr 08 00:37:41 PDT 2016 until: Sat Apr 06 00:37:41 PDT 2024 + private static final String INT = "-----BEGIN CERTIFICATE-----\n" + + "MIIHnjCCBYagAwIBAgIIG8i1ngzqC3wwDQYJKoZIhvcNAQELBQAwgaYxCzAJBgNV\n" + + "BAYTAkdSMQ8wDQYDVQQHEwZBdGhlbnMxRDBCBgNVBAoTO0hlbGxlbmljIEFjYWRl\n" + + "bWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgQ2VydC4gQXV0aG9yaXR5MUAw\n" + + "PgYDVQQDEzdIZWxsZW5pYyBBY2FkZW1pYyBhbmQgUmVzZWFyY2ggSW5zdGl0dXRp\n" + + "b25zIFJvb3RDQSAyMDE1MB4XDTE2MDQwODA3Mzc0MVoXDTI0MDQwNjA3Mzc0MVow\n" + + "ga0xCzAJBgNVBAYTAkdSMQ8wDQYDVQQHEwZBdGhlbnMxRDBCBgNVBAoTO0hlbGxl\n" + + "bmljIEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgQ2VydC4gQXV0\n" + + "aG9yaXR5MUcwRQYDVQQDEz5IZWxsZW5pYyBBY2FkZW1pYyBhbmQgUmVzZWFyY2gg\n" + + "SW5zdGl0dXRpb25zIENvZGUgU2lnbmluZyBDQSBSMTCCAiIwDQYJKoZIhvcNAQEB\n" + + "BQADggIPADCCAgoCggIBAJYQhJz8QjfP1wOc1sHxTKe9wy7d3oBScTslX5Yn1IE8\n" + + "j5SzsKilvbu9rp8bd8IKHnPrl1Vnjpvna/Vx/XKlXDxnIxgfLINfmbjJRoEbzj1t\n" + + "fxdTnZSN5c6vHYr5112/XCr2VQ7gIL+2jujXlJQYs/aUzAb9RR35dy4z2tQJQwtA\n" + + "gG/paNGgnOU2ROrcaEYfvG4YQWaHAwqjJ53ZY5HVD7NmLp5SZTA5Q3eHAYae99fq\n" + + "iEgMti3zMejzrAM1h+iVpLUxA7iMFh5nwCOvYJWVYqN3YOEmksxh7HOWlpe1PgDT\n" + + "5SezPCHmOilNizMSRsdW7fE8apYVq/O0yStFW32kS9RQzYiBsdgPvNzDGec7Jj8X\n" + + "SozhS6to+A6RdgfpHccHc2jhIRkFocA63OEde3Eo/NPf/WbFX2tpgDIv+HF/YZV3\n" + + "iaMeKeOKDIxa4c3t3qBsZNtFEGOQyDouVH4g2Y8gHhUCcR7gQrHEYy/9FbtUDviu\n" + + "abBVPFnNbEwT0uKS20aLgldkJ4/b3UzeTVzXVwLB8ruBfZX/e60YFaUJAZbbYRbE\n" + + "mD6KmDOCTfalpBRhXar6U1wf+GRp1wv01Vw88EJ6VEBxXAYrfQ28ER9IuLqVQRlN\n" + + "xpZCP71DRCvWljkXAKvWrs3JAw926n5K7sL+fv6mn+6iGBHrSEcyX8g8EZv6XuLP\n" + + "AgMBAAGjggHFMIIBwTAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAT\n" + + "BgNVHSUEDDAKBggrBgEFBQcDAzAdBgNVHQ4EFgQUDyz8Ez5xsy3SqelOr4FBCaaY\n" + + "3UgwRgYDVR0fBD8wPTA7oDmgN4Y1aHR0cDovL2NybHYxLmhhcmljYS5nci9IYXJp\n" + + "Y2FSb290Q0EyMDE1L2NybHYxLmRlci5jcmwwHwYDVR0jBBgwFoAUcRVnyMjJvXVd\n" + + "ctA4GGqd83EkVAswbgYIKwYBBQUHAQEEYjBgMCEGCCsGAQUFBzABhhVodHRwOi8v\n" + + "b2NzcC5oYXJpY2EuZ3IwOwYIKwYBBQUHMAKGL2h0dHA6Ly93d3cuaGFyaWNhLmdy\n" + + "L2NlcnRzL0hhcmljYVJvb3RDQTIwMTUuY3J0MIGQBgNVHSAEgYgwgYUwgYIGBFUd\n" + + "IAAwejAyBggrBgEFBQcCARYmaHR0cDovL3d3dy5oYXJpY2EuZ3IvZG9jdW1lbnRz\n" + + "L0NQUy5waHAwRAYIKwYBBQUHAgIwOAw2VGhpcyBjZXJ0aWZpY2F0ZSBpcyBzdWJq\n" + + "ZWN0IHRvIEdyZWVrIGxhd3MgYW5kIG91ciBDUFMuMA0GCSqGSIb3DQEBCwUAA4IC\n" + + "AQA2t84B3ImFaWsnaYoPxwYu9njKaDc/QsaxT4AKP8env/Zr+fjD5s0Bjd1gZijC\n" + + "9LRTzIovpldc/yADy7SVboIH0uNEiBC0kc0DaCq0ceCGIe6dw92Mu9DJ3UpMGAuF\n" + + "fLpyearmfX9qzi0KhPGhjTxSTD4vWw3E0nvDVMBG54Im0OUGeVzZ9SpvRRhRnPOk\n" + + "1eplEYRRDVTGYQJ84GdVC4H4U3TjlbO9gppeSnBoVHyCqDDpyd8HhTuY3P5VRWaf\n" + + "dvAkwrW2Vv53zIYpDtcwG7mf4UXKbfYGtOIg/xaqHV82J6MYZHW1RNIlSh7F+1S5\n" + + "XamkPCQZZI87CMt/OZH+RaO87Vr2V02wkYwEeAvjOwq9l7LtOJaOznKS+BlMi009\n" + + "ljgHWUQcA2wk25hOAS3YtvhI1l2UrRHSqmHd7Jah4clskIjURt3b2Ez9nuZh1dC8\n" + + "NfaoPCkpK3leLBezubtq48MRe5jkAgen5UXvxq9zOZSen4pYeBK72ugNyLjzOhY8\n" + + "GrSeE1voLnvyZIguM2hrI8nEjI4rSXL6lsqXyG/ODzDMMdKq4FrjoW3y9KnV/n8t\n" + + "BvKTAlDcXQTqfdTykDWnxwNTp6dU+MOom9LGy6ZNFbei7XuvjrREiXUEJ/I2dGSD\n" + + "3zeNek32BS2BBZNN8jeP4szLs85G5HWql59OyePZfARA6Q==\n" + + "-----END CERTIFICATE-----"; + + // Owner: OID.1.3.6.1.4.1.311.60.2.1.3=GR, OID.2.5.4.15=Private Organization, + // CN=Greek Universities Network (GUnet), SERIALNUMBER=VATGR-099028220, + // OU=Class A - Private Key created and stored in hardware CSP, O=Greek Universities Network, L=Athens, C=GR + // Issuer: CN=Hellenic Academic and Research Institutions Code Signing CA R1, + // O=Hellenic Academic and Research Institutions Cert. Authority, L=Athens, C=GR + // Serial number: 2c9a7af519251c645c1bed40b9d1aeca + // Valid from: Mon Sep 09 01:15:13 PDT 2019 until: Wed Sep 08 01:15:13 PDT 2021 + private static final String VALID = "-----BEGIN CERTIFICATE-----\n" + + "MIIGyzCCBLOgAwIBAgIQLJp69RklHGRcG+1AudGuyjANBgkqhkiG9w0BAQsFADCB\n" + + "rTELMAkGA1UEBhMCR1IxDzANBgNVBAcTBkF0aGVuczFEMEIGA1UEChM7SGVsbGVu\n" + + "aWMgQWNhZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0aW9ucyBDZXJ0LiBBdXRo\n" + + "b3JpdHkxRzBFBgNVBAMTPkhlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJ\n" + + "bnN0aXR1dGlvbnMgQ29kZSBTaWduaW5nIENBIFIxMB4XDTE5MDkwOTA4MTUxM1oX\n" + + "DTIxMDkwODA4MTUxM1owggEBMQswCQYDVQQGEwJHUjEPMA0GA1UEBwwGQXRoZW5z\n" + + "MSMwIQYDVQQKDBpHcmVlayBVbml2ZXJzaXRpZXMgTmV0d29yazFBMD8GA1UECww4\n" + + "Q2xhc3MgQSAtIFByaXZhdGUgS2V5IGNyZWF0ZWQgYW5kIHN0b3JlZCBpbiBoYXJk\n" + + "d2FyZSBDU1AxGDAWBgNVBAUTD1ZBVEdSLTA5OTAyODIyMDErMCkGA1UEAwwiR3Jl\n" + + "ZWsgVW5pdmVyc2l0aWVzIE5ldHdvcmsgKEdVbmV0KTEdMBsGA1UEDwwUUHJpdmF0\n" + + "ZSBPcmdhbml6YXRpb24xEzARBgsrBgEEAYI3PAIBAxMCR1IwggEiMA0GCSqGSIb3\n" + + "DQEBAQUAA4IBDwAwggEKAoIBAQDdkvuJzgjD3Hr1RoDtPZPp5ZelMl6Xh5vnKVuG\n" + + "KX9gwHbDaXpLkp2bF2497R3olBaeYcEgappsWLPvLMEA75BSRopFQmhX3PAsjfAG\n" + + "JZGM3A53n4NAQscCmtD6echJi4P6RThRcpfqObfe0vqZUVzSWRC8fU1P4lt/KzJj\n" + + "DGSJtOP/SJfgp3M7hEp54fn+15DlYp+0e4aa5HF2HpGIy2ghPbRvkMJWbHmp3KZG\n" + + "NOXViQdr/ogpqRsbdP7kN78WLhwrLu+xRUmf9A845jxyNO7269jOQHztfPAcgvDw\n" + + "NbZouGtN3IIWoXWMLipNgzC9CYdqgLsLI9lXV9oQrXaICQ27AgMBAAGjggGOMIIB\n" + + "ijAfBgNVHSMEGDAWgBQPLPwTPnGzLdKp6U6vgUEJppjdSDB0BggrBgEFBQcBAQRo\n" + + "MGYwQQYIKwYBBQUHMAKGNWh0dHA6Ly9yZXBvLmhhcmljYS5nci9jZXJ0cy9IYXJp\n" + + "Y2FDb2RlU2lnbmluZ0NBUjEuY3J0MCEGCCsGAQUFBzABhhVodHRwOi8vb2NzcC5o\n" + + "YXJpY2EuZ3IwYAYDVR0gBFkwVzAHBgVngQwBAzAIBgYEAI96AQIwQgYMKwYBBAGB\n" + + "zxEBAQMDMDIwMAYIKwYBBQUHAgEWJGh0dHBzOi8vcmVwby5oYXJpY2EuZ3IvZG9j\n" + + "dW1lbnRzL0NQUzATBgNVHSUEDDAKBggrBgEFBQcDAzBLBgNVHR8ERDBCMECgPqA8\n" + + "hjpodHRwOi8vY3JsdjEuaGFyaWNhLmdyL0hhcmljYUNvZGVTaWduaW5nQ0FSMS9j\n" + + "cmx2MS5kZXIuY3JsMB0GA1UdDgQWBBR0K0c/UEGkfRtqAEwoONenOUa0WTAOBgNV\n" + + "HQ8BAf8EBAMCB4AwDQYJKoZIhvcNAQELBQADggIBAHXVdzMwKeZSWmXZu/MyoyH8\n" + + "yTHYi/yvaPpR88/Q/j5wxzuceECZJgH74xgePCIXx74IKTADUyIj7eWuTkzEnZF9\n" + + "yqJyG+tArrIH7zdnjC0OgbJVFeUUY45rS24u8n/+46LnXy4A+bRa0qX/QikHxMvj\n" + + "0I0/RTZpdQFjhnmhZyZzUWReFlAEG1fUz9TNwcCfGrv3z6YHCNAh/HWFtM7te6H7\n" + + "LNjoRw0fC5edqI16ca2VrOLObbg64zdk7Ll/fu3Ll5UcAthve/PTez6R1wm47ETT\n" + + "ItjinmQI3vRhIls/UwvF4ey5Linz80rnzIlrrMgn3G2gRpfJ55CxsXOZDGS9iy8C\n" + + "jU8EiKkjbdDH6mOdQO11+FlwhBwSxVbr004RDPJJqKHKtKTWx6mEbW+ZrMXaEUNZ\n" + + "mSPwDCUgDzrFfSspYJL0UW7zV+SbK9u5nf09m6qOpkZ5OE91IEpkotTWqMe/yOJu\n" + + "Yey5wvAmEqQM6fcQCTfV5JBtzU5LOsm5Uwg728DcHfal21dJWtY3fi7+CgDRutU3\n" + + "Ee8uZUmCd/KCSQgP8B/QTu7wLXHd4IQz2EP2tmN9Zrv/MsDjpSHgRrU6Hwi49bPQ\n" + + "R43rmXHC7e2GZpBdPsfG0VDnpzgCx5Kogi5nJwwUevbvC2CT11AAlaOmTQPflqQj\n" + + "w2LPatMDMTAga/l+CE8j\n" + + "-----END CERTIFICATE-----"; + + // Owner: CN=Greek Universities Network (GUnet), SERIALNUMBER=VATGR-099028220, + // OU=Class B - Private Key created and stored in software CSP, O=Greek Universities Network, L=Athens, C=GR + // Issuer: CN=Hellenic Academic and Research Institutions Code Signing CA R1, + // O=Hellenic Academic and Research Institutions Cert. Authority, L=Athens, C=GR + // Serial number: 29c4a7abf35bd0acb1638abbf22da1d3 + // Valid from: Mon Feb 17 01:47:19 PST 2020 until: Mon Feb 15 16:00:00 PST 2021 + private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" + + "MIIGmDCCBICgAwIBAgIQKcSnq/Nb0KyxY4q78i2h0zANBgkqhkiG9w0BAQsFADCB\n" + + "rTELMAkGA1UEBhMCR1IxDzANBgNVBAcTBkF0aGVuczFEMEIGA1UEChM7SGVsbGVu\n" + + "aWMgQWNhZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0aW9ucyBDZXJ0LiBBdXRo\n" + + "b3JpdHkxRzBFBgNVBAMTPkhlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJ\n" + + "bnN0aXR1dGlvbnMgQ29kZSBTaWduaW5nIENBIFIxMB4XDTIwMDIxNzA5NDcxOVoX\n" + + "DTIxMDIxNjAwMDAwMFowgc0xCzAJBgNVBAYTAkdSMQ8wDQYDVQQHDAZBdGhlbnMx\n" + + "IzAhBgNVBAoMGkdyZWVrIFVuaXZlcnNpdGllcyBOZXR3b3JrMUEwPwYDVQQLDDhD\n" + + "bGFzcyBCIC0gUHJpdmF0ZSBLZXkgY3JlYXRlZCBhbmQgc3RvcmVkIGluIHNvZnR3\n" + + "YXJlIENTUDEYMBYGA1UEBRMPVkFUR1ItMDk5MDI4MjIwMSswKQYDVQQDDCJHcmVl\n" + + "ayBVbml2ZXJzaXRpZXMgTmV0d29yayAoR1VuZXQpMIIBIjANBgkqhkiG9w0BAQEF\n" + + "AAOCAQ8AMIIBCgKCAQEArSBfy0xwIHpFxFrAHiYpMOkILjOvlhRCBmfzrJFSILou\n" + + "8vc1wxZw/olBa38khtIybE0GJnzZqoFTsalAcLg0CzfqucDoWL+uVLURmEmYZExj\n" + + "ngYfjrpB7ypjWqxfBVqqLgxugY1XV3oaQRNWgFEn/mrQhv+0azySJdRSiW0BH4rP\n" + + "wXp9LHgzHc7oxVOHsOKApwRN7TRVKz0/EoPhyUzdk5xoRTQMRalwZ0/E24v+CyoF\n" + + "bPl/v+dlRK5n9It8yjCtqOMZ1z7l8sKmJ7q9iLvzAF58a8B5lPueC+opHPEy4VD0\n" + + "7xZHYgdHliDsVIcWDXAzfcfo7l9EUX17onEXKMWKDwIDAQABo4IBkDCCAYwwHwYD\n" + + "VR0jBBgwFoAUDyz8Ez5xsy3SqelOr4FBCaaY3UgwdAYIKwYBBQUHAQEEaDBmMEEG\n" + + "CCsGAQUFBzAChjVodHRwOi8vcmVwby5oYXJpY2EuZ3IvY2VydHMvSGFyaWNhQ29k\n" + + "ZVNpZ25pbmdDQVIxLmNydDAhBggrBgEFBQcwAYYVaHR0cDovL29jc3AuaGFyaWNh\n" + + "LmdyMGIGA1UdIARbMFkwCAYGZ4EMAQQBMAgGBgQAj3oBATBDBg0rBgEEAYHPEQEB\n" + + "AwEBMDIwMAYIKwYBBQUHAgEWJGh0dHBzOi8vcmVwby5oYXJpY2EuZ3IvZG9jdW1l\n" + + "bnRzL0NQUzATBgNVHSUEDDAKBggrBgEFBQcDAzBLBgNVHR8ERDBCMECgPqA8hjpo\n" + + "dHRwOi8vY3JsdjEuaGFyaWNhLmdyL0hhcmljYUNvZGVTaWduaW5nQ0FSMS9jcmx2\n" + + "MS5kZXIuY3JsMB0GA1UdDgQWBBTj6v8Qkmosm+VNGsd/prwylbsM7TAOBgNVHQ8B\n" + + "Af8EBAMCB4AwDQYJKoZIhvcNAQELBQADggIBADYBQvc68KwX28UFeE/nXcowBTSd\n" + + "z+tQexloeBa4Z5G0yRr9URPc95H1R4SJiGQxb/KKqX2LqZtowc5rOXFBchI3da24\n" + + "kn8pmoi4/U2o8iS+DSlAMsn4ZW2lyDd0jyNeRiuZXvkdpqxa9u/x0TyXJ6qUxSYM\n" + + "oUC/H7RI1rxA+NgQ+otLHVs4ye53qzO44mXJv5Qq4dQ+GEdD+dShrYs69WMC0mV0\n" + + "mVs//R1qp8G3tThAiJJF55kV8w1JH2+yv8RXAdQ2cRpN2W6wsnm2DxldHKM4Kel4\n" + + "ON0TXlARGjoGqfEjFyZYtvpjzIPGoj3MHgCdiVb+zQJavYZJfLymlnIXajVb80Hh\n" + + "9xSar/uZ0NwtZgX8EwOrBiDUuCjyvlYrcbpSN26Q4fuUfPdIJQXMQDLTFMQLQ/o4\n" + + "5dn9FLLaJF7CA8VFeyJYi9pWEiIIpmPzIibd2+CAEQ43Q87GAvLpC09Rf6yggRh5\n" + + "by/FAOOzfbEQMhvJfGcJrPeG8JdzG95N5ycAeeyb/iboYptRwsLWwurASmUEKn0y\n" + + "BHlQPhut0mqNJQsoxvW6yIipFAQPBxfRHeLG71UO1kRxCleDTMsb3Zzt8hv1G4+m\n" + + "Nsm3ZMOV8TMdlBxYO/xA9dqwAxMuPvShx6LdiiyQhdeEmIFvKZeTD22cIOVLDsrd\n" + + "D2GbhbvPInvh21Qz\n" + + "-----END CERTIFICATE-----"; + + public void runTest(ValidatePathWithParams pathValidator, boolean ocspEnabled) throws Exception { + // Validate valid + pathValidator.validate(new String[]{VALID, INT}, + ValidatePathWithParams.Status.GOOD, null, System.out); + + // Validate Revoked + pathValidator.validate(new String[]{REVOKED, INT}, + ValidatePathWithParams.Status.REVOKED, + "Mon Feb 17 02:00:10 PST 2020", System.out); + } +} + +class Harica_ECC { + + // Owner: CN=HARICA Code Signing ECC SubCA R2, + // O=Hellenic Academic and Research Institutions Cert. Authority, L=Athens, C=GR + // Issuer: CN=Hellenic Academic and Research Institutions ECC RootCA 2015, + // O=Hellenic Academic and Research Institutions Cert. Authority, L=Athens, C=GR + // Serial number: 1f6ea9c2f4d7f80ee6a046d8b822dd3f + // Valid from: Wed Mar 06 02:49:26 PST 2019 until: Thu Mar 02 02:49:26 PST 2034 + private static final String INT = "-----BEGIN CERTIFICATE-----\n" + + "MIIDxzCCA02gAwIBAgIQH26pwvTX+A7moEbYuCLdPzAKBggqhkjOPQQDAzCBqjEL\n" + + "MAkGA1UEBhMCR1IxDzANBgNVBAcTBkF0aGVuczFEMEIGA1UEChM7SGVsbGVuaWMg\n" + + "QWNhZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0aW9ucyBDZXJ0LiBBdXRob3Jp\n" + + "dHkxRDBCBgNVBAMTO0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0\n" + + "aXR1dGlvbnMgRUNDIFJvb3RDQSAyMDE1MB4XDTE5MDMwNjEwNDkyNloXDTM0MDMw\n" + + "MjEwNDkyNlowgY8xCzAJBgNVBAYTAkdSMQ8wDQYDVQQHDAZBdGhlbnMxRDBCBgNV\n" + + "BAoMO0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMg\n" + + "Q2VydC4gQXV0aG9yaXR5MSkwJwYDVQQDDCBIQVJJQ0EgQ29kZSBTaWduaW5nIEVD\n" + + "QyBTdWJDQSBSMjB2MBAGByqGSM49AgEGBSuBBAAiA2IABKPWDfLT76KnCZ7dujms\n" + + "bFYFLTvCWTyk8l0JqdhvZ+Tk6dWYAViIX90fc8+3HPAdHvkofNWvI/PW0qlZoRn3\n" + + "De/Nrp+ZCWjg7UrUrmKH2z/N3A7lgZFqrwlWPxHSPSYVkqOCAU8wggFLMBIGA1Ud\n" + + "EwEB/wQIMAYBAf8CAQAwHwYDVR0jBBgwFoAUtCILgpkkAQ6cu+QO/b/7lyCTmSow\n" + + "cgYIKwYBBQUHAQEEZjBkMD8GCCsGAQUFBzAChjNodHRwOi8vcmVwby5oYXJpY2Eu\n" + + "Z3IvY2VydHMvSGFyaWNhRUNDUm9vdENBMjAxNS5jcnQwIQYIKwYBBQUHMAGGFWh0\n" + + "dHA6Ly9vY3NwLmhhcmljYS5ncjARBgNVHSAECjAIMAYGBFUdIAAwEwYDVR0lBAww\n" + + "CgYIKwYBBQUHAwMwSQYDVR0fBEIwQDA+oDygOoY4aHR0cDovL2NybHYxLmhhcmlj\n" + + "YS5nci9IYXJpY2FFQ0NSb290Q0EyMDE1L2NybHYxLmRlci5jcmwwHQYDVR0OBBYE\n" + + "FMdgA8SpJhybKTZTnW4Xu3NWRKZeMA4GA1UdDwEB/wQEAwIBhjAKBggqhkjOPQQD\n" + + "AwNoADBlAjAcJj7q9ujC+87/b81QowGo87VJhn9XWzRtpwjQFbIilqEfO3ot1d5F\n" + + "MWT1Xn2Qg3sCMQCoM+eV2KkQluHn2N6+GMImJqVObVUyZv0E+BvvszdJubo1cAM0\n" + + "SUImVT1t2wZpJKg=\n" + + "-----END CERTIFICATE-----"; + + // Owner: CN=Dimitrios Zacharopoulos, GIVENNAME=Dimitrios, SURNAME=Zacharopoulos, + // OU=Class B - Private Key created and stored in software CSP, + // O=Hellenic Academic and Research Institutions Cert. Authority, L=Athens, C=GR + // Issuer: CN=HARICA Code Signing ECC SubCA R2, O=Hellenic Academic and Research Institutions Cert. Authority, + // L=Athens, C=GR + // Serial number: 11a187e3b5b0eabea4ba4987e76cd09d + // Valid from: Fri Jul 31 02:11:08 PDT 2020 until: Sun Jul 31 02:11:08 PDT 2022 + private static final String VALID = "-----BEGIN CERTIFICATE-----\n" + + "MIIENTCCA7ugAwIBAgIQEaGH47Ww6r6kukmH52zQnTAKBggqhkjOPQQDAzCBjzEL\n" + + "MAkGA1UEBhMCR1IxDzANBgNVBAcMBkF0aGVuczFEMEIGA1UECgw7SGVsbGVuaWMg\n" + + "QWNhZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0aW9ucyBDZXJ0LiBBdXRob3Jp\n" + + "dHkxKTAnBgNVBAMMIEhBUklDQSBDb2RlIFNpZ25pbmcgRUNDIFN1YkNBIFIyMB4X\n" + + "DTIwMDczMTA5MTEwOFoXDTIyMDczMTA5MTEwOFowgfUxCzAJBgNVBAYTAkdSMQ8w\n" + + "DQYDVQQHDAZBdGhlbnMxRDBCBgNVBAoMO0hlbGxlbmljIEFjYWRlbWljIGFuZCBS\n" + + "ZXNlYXJjaCBJbnN0aXR1dGlvbnMgQ2VydC4gQXV0aG9yaXR5MUEwPwYDVQQLDDhD\n" + + "bGFzcyBCIC0gUHJpdmF0ZSBLZXkgY3JlYXRlZCBhbmQgc3RvcmVkIGluIHNvZnR3\n" + + "YXJlIENTUDEWMBQGA1UEBAwNWmFjaGFyb3BvdWxvczESMBAGA1UEKgwJRGltaXRy\n" + + "aW9zMSAwHgYDVQQDDBdEaW1pdHJpb3MgWmFjaGFyb3BvdWxvczBZMBMGByqGSM49\n" + + "AgEGCCqGSM49AwEHA0IABOzRSqoI9HoxXjWerBBw8Croi1bJlUzoFXGjdszJIThf\n" + + "UG3YOiR1whG7wY5H5v8v4IIB5pJanArJk4CzxBLKob6jggGPMIIBizAfBgNVHSME\n" + + "GDAWgBTHYAPEqSYcmyk2U51uF7tzVkSmXjB6BggrBgEFBQcBAQRuMGwwRwYIKwYB\n" + + "BQUHMAKGO2h0dHA6Ly9yZXBvLmhhcmljYS5nci9jZXJ0cy9IYXJpY2FFQ0NDb2Rl\n" + + "U2lnbmluZ1N1YkNBUjIuY3J0MCEGCCsGAQUFBzABhhVodHRwOi8vb2NzcC5oYXJp\n" + + "Y2EuZ3IwYQYDVR0gBFowWDAIBgZngQwBBAEwCAYGBACPegEBMEIGDCsGAQQBgc8R\n" + + "AQMCATAyMDAGCCsGAQUFBwIBFiRodHRwczovL3JlcG8uaGFyaWNhLmdyL2RvY3Vt\n" + + "ZW50cy9DUFMwEwYDVR0lBAwwCgYIKwYBBQUHAwMwRQYDVR0fBD4wPDA6oDigNoY0\n" + + "aHR0cDovL2NybC5oYXJpY2EuZ3IvSGFyaWNhRUNDQ29kZVNpZ25pbmdTdWJDQVIy\n" + + "LmNybDAdBgNVHQ4EFgQUpNjChUi9LGgwz7E18N1EwXooEFcwDgYDVR0PAQH/BAQD\n" + + "AgeAMAoGCCqGSM49BAMDA2gAMGUCMQCDvQIjqgssTRHqp+gu7l21XmAQ4EMqr4+B\n" + + "05iU/edLxxV+z5roTswxnPnr43+EbvkCMHq4aFW1u1+RvPBQJNRnYmdXCnj0lUw4\n" + + "Ug7JnsEYMffLakDudzgsNv5ByJf9SO84Lw==\n" + + "-----END CERTIFICATE-----"; + + // Owner: CN=Greek Universities Network (GUnet), SERIALNUMBER=VATGR-099028220, + // OU=Class B - Private Key created and stored in software CSP, O=Greek Universities Network, L=Athens, C=GR + // Issuer: CN=HARICA Code Signing ECC SubCA R2, O=Hellenic Academic and Research Institutions Cert. Authority, + // L=Athens, C=GR + // Serial number: 4b14719c7195c96de8a5663724454205 + // Valid from: Mon Feb 17 01:48:32 PST 2020 until: Mon Feb 15 16:00:00 PST 2021 + private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" + + "MIIEDjCCA5SgAwIBAgIQSxRxnHGVyW3opWY3JEVCBTAKBggqhkjOPQQDAzCBjzEL\n" + + "MAkGA1UEBhMCR1IxDzANBgNVBAcMBkF0aGVuczFEMEIGA1UECgw7SGVsbGVuaWMg\n" + + "QWNhZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0aW9ucyBDZXJ0LiBBdXRob3Jp\n" + + "dHkxKTAnBgNVBAMMIEhBUklDQSBDb2RlIFNpZ25pbmcgRUNDIFN1YkNBIFIyMB4X\n" + + "DTIwMDIxNzA5NDgzMloXDTIxMDIxNjAwMDAwMFowgc0xCzAJBgNVBAYTAkdSMQ8w\n" + + "DQYDVQQHDAZBdGhlbnMxIzAhBgNVBAoMGkdyZWVrIFVuaXZlcnNpdGllcyBOZXR3\n" + + "b3JrMUEwPwYDVQQLDDhDbGFzcyBCIC0gUHJpdmF0ZSBLZXkgY3JlYXRlZCBhbmQg\n" + + "c3RvcmVkIGluIHNvZnR3YXJlIENTUDEYMBYGA1UEBRMPVkFUR1ItMDk5MDI4MjIw\n" + + "MSswKQYDVQQDDCJHcmVlayBVbml2ZXJzaXRpZXMgTmV0d29yayAoR1VuZXQpMFkw\n" + + "EwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAECC+lD6hphUDLSGs/Vw4Tvj8RAuCQAyi+\n" + + "MUiXXXzGSp5e6ksBVlRlawluNR+BUtY93BRCjjNr3OuvSVALyrH7HKOCAZAwggGM\n" + + "MB8GA1UdIwQYMBaAFMdgA8SpJhybKTZTnW4Xu3NWRKZeMHoGCCsGAQUFBwEBBG4w\n" + + "bDBHBggrBgEFBQcwAoY7aHR0cDovL3JlcG8uaGFyaWNhLmdyL2NlcnRzL0hhcmlj\n" + + "YUVDQ0NvZGVTaWduaW5nU3ViQ0FSMi5jcnQwIQYIKwYBBQUHMAGGFWh0dHA6Ly9v\n" + + "Y3NwLmhhcmljYS5ncjBiBgNVHSAEWzBZMAgGBmeBDAEEATAIBgYEAI96AQEwQwYN\n" + + "KwYBBAGBzxEBAQMBATAyMDAGCCsGAQUFBwIBFiRodHRwczovL3JlcG8uaGFyaWNh\n" + + "LmdyL2RvY3VtZW50cy9DUFMwEwYDVR0lBAwwCgYIKwYBBQUHAwMwRQYDVR0fBD4w\n" + + "PDA6oDigNoY0aHR0cDovL2NybC5oYXJpY2EuZ3IvSGFyaWNhRUNDQ29kZVNpZ25p\n" + + "bmdTdWJDQVIyLmNybDAdBgNVHQ4EFgQUT4+WfQu125tLqla60vhK7ijBBWkwDgYD\n" + + "VR0PAQH/BAQDAgeAMAoGCCqGSM49BAMDA2gAMGUCMQDADGDAxKpUkyEKBLzpX+88\n" + + "ONLYDgFSie5W2ULWk02sDRO/k5xcSSjTf0FFa4+l6E8CME/b27e7NUGHPVYTLTWL\n" + + "5yPiboyNsT8QpV+hZiWh/Qqiw1E/bR2SPIGEwYUrOV61fA==\n" + + "-----END CERTIFICATE-----"; + + public void runTest(ValidatePathWithParams pathValidator, boolean ocspEnabled) throws Exception { + // Validate valid + pathValidator.validate(new String[]{VALID, INT}, + ValidatePathWithParams.Status.GOOD, null, System.out); + + // Validate Revoked + pathValidator.validate(new String[]{REVOKED, INT}, + ValidatePathWithParams.Status.REVOKED, + "Mon Feb 17 02:00:57 PST 2020", System.out); + } +} diff --git a/test/jdk/sun/security/lib/cacerts/VerifyCACerts.java b/test/jdk/sun/security/lib/cacerts/VerifyCACerts.java index 126e8b5b7aa2a..328c4a972bccd 100644 --- a/test/jdk/sun/security/lib/cacerts/VerifyCACerts.java +++ b/test/jdk/sun/security/lib/cacerts/VerifyCACerts.java @@ -27,7 +27,7 @@ * @bug 8189131 8198240 8191844 8189949 8191031 8196141 8204923 8195774 8199779 * 8209452 8209506 8210432 8195793 8216577 8222089 8222133 8222137 8222136 * 8223499 8225392 8232019 8234245 8233223 8225068 8225069 8243321 8243320 - * 8243559 8225072 8258630 8259312 + * 8243559 8225072 8258630 8259312 8256421 * @summary Check root CA entries in cacerts file */ import java.io.ByteArrayInputStream; @@ -54,12 +54,12 @@ public class VerifyCACerts { + File.separator + "security" + File.separator + "cacerts"; // The numbers of certs now. - private static final int COUNT = 90; + private static final int COUNT = 92; // SHA-256 of cacerts, can be generated with // shasum -a 256 cacerts | sed -e 's/../&:/g' | tr '[:lower:]' '[:upper:]' | cut -c1-95 private static final String CHECKSUM - = "50:97:53:06:1B:40:32:71:D6:CD:3B:29:89:7C:BF:BF:41:6F:56:B1:0D:E9:B8:2A:8C:7C:C2:CD:CD:9F:10:EF"; + = "02:AE:2C:37:34:B1:B1:3D:74:CB:99:8B:31:4F:C9:BB:23:51:BB:B3:90:59:47:72:C1:4A:36:DA:97:98:06:01"; // Hex formatter to upper case with ":" delimiter private static final HexFormat HEX = HexFormat.ofDelimiter(":").withUpperCase(); @@ -248,6 +248,10 @@ public class VerifyCACerts { "2E:7B:F1:6C:C2:24:85:A7:BB:E2:AA:86:96:75:07:61:B0:AE:39:BE:3B:2F:E9:D0:CC:6D:4E:F7:34:91:42:5C"); put("sslrooteccca [jdk]", "34:17:BB:06:CC:60:07:DA:1B:96:1C:92:0B:8A:B4:CE:3F:AD:82:0E:4A:A3:0B:9A:CB:C4:A7:4E:BD:CE:BC:65"); + put("haricarootca2015 [jdk]", + "A0:40:92:9A:02:CE:53:B4:AC:F4:F2:FF:C6:98:1C:E4:49:6F:75:5E:6D:45:FE:0B:2A:69:2B:CD:52:52:3F:36"); + put("haricaeccrootca2015 [jdk]", + "44:B5:45:AA:8A:25:E6:5A:73:CA:15:DC:27:FC:36:D2:4C:1C:B9:95:3A:06:65:39:B1:15:82:DC:48:7B:48:33"); } }; From afd5eefdae388a53a0d6bffc2cf94b878ac1881e Mon Sep 17 00:00:00 2001 From: Kim Barrett Date: Tue, 2 Feb 2021 19:20:19 +0000 Subject: [PATCH 26/77] 8260704: ParallelGC: oldgen expansion needs release-store for _end Move JDK-8257999 barrier to correct location. Reviewed-by: tschatzl, sjohanss --- src/hotspot/share/gc/parallel/mutableSpace.cpp | 8 ++++++-- src/hotspot/share/gc/parallel/psOldGen.cpp | 9 ++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/hotspot/share/gc/parallel/mutableSpace.cpp b/src/hotspot/share/gc/parallel/mutableSpace.cpp index 82c82fb94ece6..97d459c5deb22 100644 --- a/src/hotspot/share/gc/parallel/mutableSpace.cpp +++ b/src/hotspot/share/gc/parallel/mutableSpace.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -126,7 +126,11 @@ void MutableSpace::initialize(MemRegion mr, } set_bottom(mr.start()); - set_end(mr.end()); + // When expanding concurrently with callers of cas_allocate, setting end + // makes the new space available for allocation by other threads. So this + // assignment must follow all other configuration and initialization that + // might be done for expansion. + Atomic::release_store(end_addr(), mr.end()); if (clear_space) { clear(mangle_space); diff --git a/src/hotspot/share/gc/parallel/psOldGen.cpp b/src/hotspot/share/gc/parallel/psOldGen.cpp index 5d23956d466d9..63c0ddf5f6cf4 100644 --- a/src/hotspot/share/gc/parallel/psOldGen.cpp +++ b/src/hotspot/share/gc/parallel/psOldGen.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,7 +35,6 @@ #include "logging/log.hpp" #include "oops/oop.inline.hpp" #include "runtime/java.hpp" -#include "runtime/orderAccess.hpp" #include "utilities/align.hpp" PSOldGen::PSOldGen(ReservedSpace rs, size_t initial_size, size_t min_size, @@ -381,9 +380,9 @@ void PSOldGen::post_resize() { WorkGang* workers = Thread::current()->is_VM_thread() ? &ParallelScavengeHeap::heap()->workers() : NULL; - // Ensure the space bounds are updated and made visible to other - // threads after the other data structures have been resized. - OrderAccess::storestore(); + // The update of the space's end is done by this call. As that + // makes the new space available for concurrent allocation, this + // must be the last step when expanding. object_space()->initialize(new_memregion, SpaceDecorator::DontClear, SpaceDecorator::DontMangle, From 1a7040e5b92dff15708651c33c9a7cb29b292a49 Mon Sep 17 00:00:00 2001 From: Jesper Wilhelmsson Date: Tue, 2 Feb 2021 19:45:37 +0000 Subject: [PATCH 27/77] 8259794: Remove EA from JDK 16 version string starting with Initial RC promotion on Feb 04, 2021(B35) Reviewed-by: iignatyev, mikael --- make/autoconf/version-numbers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/make/autoconf/version-numbers b/make/autoconf/version-numbers index ca9a577244555..9e07a4e64a2af 100644 --- a/make/autoconf/version-numbers +++ b/make/autoconf/version-numbers @@ -38,7 +38,7 @@ DEFAULT_VERSION_CLASSFILE_MAJOR=60 # "`$EXPR $DEFAULT_VERSION_FEATURE + 44`" DEFAULT_VERSION_CLASSFILE_MINOR=0 DEFAULT_ACCEPTABLE_BOOT_VERSIONS="15 16" DEFAULT_JDK_SOURCE_TARGET_VERSION=16 -DEFAULT_PROMOTED_VERSION_PRE=ea +DEFAULT_PROMOTED_VERSION_PRE= LAUNCHER_NAME=openjdk PRODUCT_NAME=OpenJDK From 105d3e8f406545a5fe4609dcdcdb8e743a1163fe Mon Sep 17 00:00:00 2001 From: Davin Kevin Date: Tue, 2 Feb 2021 20:54:10 +0000 Subject: [PATCH 28/77] 8260861: TrustStoreDescriptor log the same value Reviewed-by: xuelei --- .../share/classes/sun/security/ssl/TrustStoreManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/java.base/share/classes/sun/security/ssl/TrustStoreManager.java b/src/java.base/share/classes/sun/security/ssl/TrustStoreManager.java index 2b00c3c93b136..573dde55c60c6 100644 --- a/src/java.base/share/classes/sun/security/ssl/TrustStoreManager.java +++ b/src/java.base/share/classes/sun/security/ssl/TrustStoreManager.java @@ -161,7 +161,7 @@ public TrustStoreDescriptor run() { SSLLogger.isOn("trustmanager")) { SSLLogger.fine( "Inaccessible trust store: " + - storePropName); + fileName); } } } else { From 6dc3c6dcddcbcb3a1a93415d66f1d9595b217519 Mon Sep 17 00:00:00 2001 From: Mahendra Chhipa Date: Tue, 2 Feb 2021 21:11:41 +0000 Subject: [PATCH 29/77] 8183372: Refactor java/lang/Class shell tests to java Reviewed-by: bchristi, mchung --- .../java/lang/Class/forName/NonJavaNames.java | 130 +++++++++++++----- .../java/lang/Class/forName/NonJavaNames.sh | 108 --------------- .../getEnclosingClass/EnclosingClassTest.java | 121 ++++++++++++---- .../lang/Class/getEnclosingClass/build.sh | 42 ------ .../lang/Class/getEnclosingClass/make_src.sh | 40 ------ 5 files changed, 190 insertions(+), 251 deletions(-) delete mode 100644 test/jdk/java/lang/Class/forName/NonJavaNames.sh delete mode 100644 test/jdk/java/lang/Class/getEnclosingClass/build.sh delete mode 100644 test/jdk/java/lang/Class/getEnclosingClass/make_src.sh diff --git a/test/jdk/java/lang/Class/forName/NonJavaNames.java b/test/jdk/java/lang/Class/forName/NonJavaNames.java index 0d5c9ad13bf55..587d6cdfa9025 100644 --- a/test/jdk/java/lang/Class/forName/NonJavaNames.java +++ b/test/jdk/java/lang/Class/forName/NonJavaNames.java @@ -21,9 +21,21 @@ * questions. */ +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; + +import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + /* - * Used by NonJavaNames.sh; needs to be run with a classpath including - * test/java/lang/Class/forName/classes + * @test + * @bug 4952558 + * @library /test/lib + * @run testng/othervm NonJavaNames + * @summary Verify names that aren't legal Java names are accepted by forName. */ public class NonJavaNames { @@ -34,19 +46,59 @@ public Baz(){} public static interface myInterface { } - NonJavaNames.myInterface create(){ + NonJavaNames.myInterface create() { // With target 1.5, this class's name will include a '+' // instead of a '$'. class Baz2 implements NonJavaNames.myInterface { - public Baz2(){} + public Baz2() { } } return new Baz2(); } - public static void main(String[] args) throws Exception { - NonJavaNames.Baz bz = new NonJavaNames.Baz(); + private static final String SRC_DIR = System.getProperty("test.src"); + private static final Path TEST_SRC = Path.of(SRC_DIR, "classes"); + private static final Path TEST_CLASSES = Path.of(System.getProperty("test.classes", ".")); + + @BeforeClass + public void createInvalidNameClasses() throws IOException { + Path hyphenPath = TEST_SRC.resolve("hyphen.class"); + Path commaPath = TEST_SRC.resolve("comma.class"); + Path periodPath = TEST_SRC.resolve("period.class"); + Path leftsquarePath = TEST_SRC.resolve("left-square.class"); + Path rightsquarePath = TEST_SRC.resolve("right-square.class"); + Path plusPath = TEST_SRC.resolve("plus.class"); + Path semicolonPath = TEST_SRC.resolve("semicolon.class"); + Path zeroPath = TEST_SRC.resolve("0.class"); + Path threePath = TEST_SRC.resolve("3.class"); + Path zadePath = TEST_SRC.resolve("Z.class"); + Path dhyphenPath = TEST_CLASSES.resolve("-.class"); + Path dcommaPath = TEST_CLASSES.resolve(",.class"); + Path dperiodPath = TEST_CLASSES.resolve("..class"); + Path dleftsquarePath = TEST_CLASSES.resolve("[.class"); + Path drightsquarePath = TEST_CLASSES.resolve("].class"); + Path dplusPath = TEST_CLASSES.resolve("+.class"); + Path dsemicolonPath = TEST_CLASSES.resolve(";.class"); + Path dzeroPath = TEST_CLASSES.resolve("0.class"); + Path dthreePath = TEST_CLASSES.resolve("3.class"); + Path dzadePath = TEST_CLASSES.resolve("Z.class"); + + Files.copy(hyphenPath, dhyphenPath, REPLACE_EXISTING); + Files.copy(commaPath, dcommaPath, REPLACE_EXISTING); + Files.copy(periodPath, dperiodPath, REPLACE_EXISTING); + Files.copy(leftsquarePath, dleftsquarePath, REPLACE_EXISTING); + Files.copy(rightsquarePath, drightsquarePath, REPLACE_EXISTING); + Files.copy(plusPath, dplusPath, REPLACE_EXISTING); + Files.copy(semicolonPath, dsemicolonPath, REPLACE_EXISTING); + Files.copy(zeroPath, dzeroPath, REPLACE_EXISTING); + Files.copy(threePath, dthreePath, REPLACE_EXISTING); + Files.copy(zadePath, dzadePath, REPLACE_EXISTING); + } + + @Test + public void testForNameReturnsSameClass() throws ClassNotFoundException { + NonJavaNames.Baz bz = new NonJavaNames.Baz(); String name; if (Class.forName(name=bz.getClass().getName()) != NonJavaNames.Baz.class) { @@ -61,40 +113,48 @@ public static void main(String[] args) throws Exception { System.err.println("Failures for class ``" + name + "''."); throw new RuntimeException(); } + } - String goodNonJavaClassNames [] = { - ",", - "+", - "-", - "0", - "3", - // ":", These names won't work under windows. - // "<", - // ">", - "Z", - "]" - }; + @Test(dataProvider = "goodNonJavaClassNames") + public void testGoodNonJavaClassNames(String name) throws ClassNotFoundException { + System.out.println("Testing good class name ``" + name + "''"); + Class.forName(name); + } - for(String s : goodNonJavaClassNames) { - System.out.println("Testing good class name ``" + s + "''"); - Class.forName(s); + @Test(dataProvider = "badNonJavaClassNames") + public void testBadNonJavaClassNames(String name) { + System.out.println("Testing bad class name ``" + name + "''"); + try { + Class.forName(name); + } catch (ClassNotFoundException e) { + // Expected behavior + return; } + throw new RuntimeException("Bad class name ``" + name + "'' accepted."); + } - String badNonJavaClassNames [] = { - ";", - "[", - "." + @DataProvider(name = "goodNonJavaClassNames") + Object[][] getGoodNonJavaClassNames() { + return new Object[][] { + {","}, + {"+"}, + {"-"}, + {"0"}, + {"3"}, + // ":", These names won't work under windows. + // "<", + // ">", + {"Z"}, + {"]"} }; + } - for(String s : badNonJavaClassNames) { - System.out.println("Testing bad class name ``" + s + "''"); - try { - Class.forName(s); - } catch (Exception e) { - // Expected behavior - continue; - } - throw new RuntimeException("Bad class name ``" + s + "'' accepted."); - } + @DataProvider(name = "badNonJavaClassNames") + Object[][] getBadNonJavaClassNames() { + return new Object[][] { + {";"}, + {"["}, + {"."} + }; } } diff --git a/test/jdk/java/lang/Class/forName/NonJavaNames.sh b/test/jdk/java/lang/Class/forName/NonJavaNames.sh deleted file mode 100644 index f7114e4612b8d..0000000000000 --- a/test/jdk/java/lang/Class/forName/NonJavaNames.sh +++ /dev/null @@ -1,108 +0,0 @@ -# -# Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -# @test -# @bug 4952558 -# @summary Verify names that aren't legal Java names are accepted by forName. -# @author Joseph D. Darcy -# @compile NonJavaNames.java -# @run shell NonJavaNames.sh - -# This test uses hand-generated class files stored in the ./classes -# directory. After the renaming done below, those class files have -# single character names that are legal class names under in the class -# file but *not* legal Java language identifiers; e.g. "3" and "+". -# First, Z.java is compiled to Z.class. Next, to create a test class -# file, the appropriate name structures within the class files are -# updated, as is the "Hello world" string the class's main method -# prints out. - -# Verify directory context variables are set -if [ "${TESTJAVA}" = "" ] -then - echo "TESTJAVA not set. Test cannot execute. Failed." - exit 1 -fi - -if [ "${TESTSRC}" = "" ] -then - echo "TESTSRC not set. Test cannot execute. Failed." - exit 1 -fi - -if [ "${TESTCLASSES}" = "" ] -then - echo "TESTCLASSES not set. Test cannot execute. Failed." - exit 1 -fi - -# All preconditions are met; run the tests - -OS=`uname -s`; -# Set classpath separator -case "$OS" in - Windows* | CYGWIN* ) - SEP=";" - ;; - - * ) - SEP=":" -esac - -# Copy "hyphen.class" to "-.class" - -COPYHYPHEN="cp ${TESTSRC}/classes/hyphen.class ${TESTCLASSES}/-.class" -$COPYHYPHEN - -COPYCOMMA="cp ${TESTSRC}/classes/comma.class ${TESTCLASSES}/,.class" -$COPYCOMMA - -COPYPERIOD="cp ${TESTSRC}/classes/period.class ${TESTCLASSES}/..class" -$COPYPERIOD - -COPYLEFTSQUARE="cp ${TESTSRC}/classes/left-square.class ${TESTCLASSES}/[.class" -$COPYLEFTSQUARE - -COPYRIGHTSQUARE="cp ${TESTSRC}/classes/right-square.class ${TESTCLASSES}/].class" -$COPYRIGHTSQUARE - -COPYPLUS="cp ${TESTSRC}/classes/plus.class ${TESTCLASSES}/+.class" -$COPYPLUS - -COPYSEMICOLON="cp ${TESTSRC}/classes/semicolon.class ${TESTCLASSES}/;.class" -$COPYSEMICOLON - -JAVA="$TESTJAVA/bin/java ${TESTVMOPTS} -classpath ${TESTSRC}/classes${SEP}${TESTCLASSES}" - -$JAVA NonJavaNames -RESULT=$? - -case "$RESULT" in - 0 ) - exit 0; - ;; - - * ) - exit 1 -esac - diff --git a/test/jdk/java/lang/Class/getEnclosingClass/EnclosingClassTest.java b/test/jdk/java/lang/Class/getEnclosingClass/EnclosingClassTest.java index 929040287a3b2..9144e9b16e3bd 100644 --- a/test/jdk/java/lang/Class/getEnclosingClass/EnclosingClassTest.java +++ b/test/jdk/java/lang/Class/getEnclosingClass/EnclosingClassTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2021 Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,15 +24,30 @@ /* * @test * @bug 4992173 4992170 - * - * @run shell make_src.sh - * @run shell build.sh - * @run main/othervm -esa -ea EnclosingClassTest - * + * @library /test/lib + * @modules jdk.compiler + * @run testng/othervm EnclosingClassTest * @summary Check getEnclosingClass and other methods * @author Peter von der Ah\u00e9 */ +import java.io.BufferedReader; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintWriter; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.nio.file.Files; +import java.nio.file.Path; + +import common.TestMe; +import jdk.test.lib.compiler.CompilerUtils; +import jdk.test.lib.util.FileUtils; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + /* * We have five kinds of classes: * a) Top level classes @@ -59,15 +74,73 @@ * e o x x x */ -import java.util.List; -import java.util.LinkedList; -import java.lang.reflect.Field; -import common.TestMe; - public class EnclosingClassTest { - static void info(Class c, Class encClass, String desc) { - if (!"".equals(desc)) + private static final String SRC_DIR = System.getProperty("test.src"); + private static final Path ENCLOSING_CLASS_SRC = Path.of(SRC_DIR, "EnclosingClass.java"); + private static final String GEN_SRC_DIR = "gensrc"; + + @BeforeClass + public void createEnclosingClasses() throws IOException { + Path pkg1Dir = Path.of(GEN_SRC_DIR, "pkg1"); + Path pkg2Dir = Path.of(GEN_SRC_DIR, "pkg1", "pkg2"); + Path pkg1File = pkg1Dir.resolve("EnclosingClass.java"); + Path pkg2File = pkg2Dir.resolve("EnclosingClass.java"); + + if (!Files.notExists(pkg1Dir)) { + FileUtils.deleteFileTreeWithRetry(pkg1Dir); + } + Files.createDirectories(pkg2Dir); + createAndWriteEnclosingClasses(ENCLOSING_CLASS_SRC, pkg1File, "pkg1"); + createAndWriteEnclosingClasses(ENCLOSING_CLASS_SRC, pkg2File, "pkg1.pkg2"); + + Assert.assertTrue(CompilerUtils.compile(ENCLOSING_CLASS_SRC, Path.of(System.getProperty("test.classes")), + "--source-path", SRC_DIR)); + Assert.assertTrue(CompilerUtils.compile(pkg1File, Path.of(System.getProperty("test.classes")), + "-classpath", System.getProperty("test.class.path"))); + Assert.assertTrue(CompilerUtils.compile(pkg2File, Path.of(System.getProperty("test.classes")), + "-classpath", System.getProperty("test.class.path"))); + } + + @Test + public void testEnclosingClasses() throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, + InvocationTargetException, InstantiationException { + test(Class.forName("EnclosingClass").getDeclaredConstructor().newInstance()); + } + + @Test + public void testEnclosingClassesInPackage() throws ClassNotFoundException, NoSuchMethodException, + IllegalAccessException, InvocationTargetException, InstantiationException { + test(Class.forName("pkg1.EnclosingClass").getDeclaredConstructor().newInstance()); + } + + @Test + public void testEnclosingClassesInNestedPackage() throws ClassNotFoundException, NoSuchMethodException, + IllegalAccessException, InvocationTargetException, InstantiationException { + test(Class.forName("pkg1.pkg2.EnclosingClass").getDeclaredConstructor().newInstance()); + } + + private void createAndWriteEnclosingClasses(Path source, Path target, String packageName) throws IOException { + String className = packageName + ".EnclosingClass"; + try (BufferedReader br = new BufferedReader(new FileReader(source.toFile())); + PrintWriter bw = new PrintWriter(new FileWriter(target.toFile()))) { + String line; + while ((line = br.readLine()) != null) { + if (line.contains("canonical=\"EnclosingClass")) { + line = line.replaceAll("canonical=\"EnclosingClass", "canonical=\"" + className); + } else if (line.contains("\"class EnclosingClass")) { + line = line.replaceAll("\"class EnclosingClass", "\"class " + className); + } else if (line.contains("//package")) { + line = line.replaceAll("//package", "package " + packageName + ";"); + } + bw.println(line); + } + } + } + + private void info(Class c, Class encClass, String desc) { + if (!"".equals(desc)) { System.out.println(desc + ":"); + } System.out.println(c); System.out.println("\tis enclosed by:\t\t" + encClass); System.out.println("\thas simple name:\t`" + @@ -76,23 +149,23 @@ static void info(Class c, Class encClass, String desc) { c.getCanonicalName() + "'"); } - static void match(String actual, String expected) { - assert((actual == null && expected == null) || actual.equals(expected)); + private void match(String actual, String expected) { + Assert.assertTrue((actual == null && expected == null) || actual.equals(expected)); System.out.println("\t`" + actual + "' matches expected `" + expected + "'"); } - static void check(Class c, Class enc, - String encName, String encNameExpected, - String simpleName, String simpleNameExpected, - String canonicalName, String canonicalNameExpected) { + private void check(Class c, Class enc, + String encName, String encNameExpected, + String simpleName, String simpleNameExpected, + String canonicalName, String canonicalNameExpected) { match(encName, encNameExpected); match(simpleName, simpleNameExpected); match(canonicalName, canonicalNameExpected); } - static void testClass(Class c, TestMe annotation, Field f) { + private void testClass(Class c, TestMe annotation, Field f) { if (Void.class.equals(c)) return; Class encClass = c.getEnclosingClass(); @@ -114,7 +187,7 @@ static void testClass(Class c, TestMe annotation, Field f) { annotation.hasCanonical() ? annotation.canonical()+"[]" : null); } - static void test(Object tests) { + private void test(Object tests) { for (Field f : tests.getClass().getFields()) { TestMe annotation = f.getAnnotation(TestMe.class); if (annotation != null) { @@ -132,9 +205,5 @@ static void test(Object tests) { } } } - public static void main(String[] args) { - test(new EnclosingClass()); - test(new pkg1.EnclosingClass()); - test(new pkg1.pkg2.EnclosingClass()); - } } + diff --git a/test/jdk/java/lang/Class/getEnclosingClass/build.sh b/test/jdk/java/lang/Class/getEnclosingClass/build.sh deleted file mode 100644 index 72c34910f23e0..0000000000000 --- a/test/jdk/java/lang/Class/getEnclosingClass/build.sh +++ /dev/null @@ -1,42 +0,0 @@ -# -# Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -# -*- shell-script -*- -# -# @summary Check getEnclosingClass and other methods -# @author Peter von der Ahé - -OS=`uname -s`; -case "${OS}" in - Windows* | CYGWIN* ) - SEP=";" - ;; - - * ) - SEP=":" - ;; -esac - -JAVAC=${COMPILEJAVA}/bin/javac -${JAVAC} ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d ${TESTCLASSES} -sourcepath ${TESTSRC}${SEP}. \ - ${TESTSRC}/EnclosingClassTest.java diff --git a/test/jdk/java/lang/Class/getEnclosingClass/make_src.sh b/test/jdk/java/lang/Class/getEnclosingClass/make_src.sh deleted file mode 100644 index 442749879d1a9..0000000000000 --- a/test/jdk/java/lang/Class/getEnclosingClass/make_src.sh +++ /dev/null @@ -1,40 +0,0 @@ -# -# Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -# -*- shell-script -*- -# @summary Check getEnclosingClass and other methods -# @author Peter von der Ahé - -rm -rf pkg1 -mkdir pkg1 -mkdir -p pkg1/pkg2 - -sed ' -s/canonical="EnclosingClass/canonical="pkg1.EnclosingClass/g; -s/"class EnclosingClass/"class pkg1.EnclosingClass/g; -s/\/\/package/package pkg1;/g' < ${TESTSRC}/EnclosingClass.java > pkg1/EnclosingClass.java - -sed ' -s/canonical="EnclosingClass/canonical="pkg1.pkg2.EnclosingClass/g; -s/"class EnclosingClass/"class pkg1.pkg2.EnclosingClass/g; -s/\/\/package/package pkg1.pkg2;/g' < ${TESTSRC}/EnclosingClass.java > pkg1/pkg2/EnclosingClass.java From 9af333923baf759c660a2d79e21f6a09ba6da494 Mon Sep 17 00:00:00 2001 From: Mahendra Chhipa Date: Tue, 2 Feb 2021 22:14:07 +0000 Subject: [PATCH 30/77] 8261003: Bad Copyright header format after JDK-8183372 Reviewed-by: bchristi --- .../java/lang/Class/getEnclosingClass/EnclosingClassTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/jdk/java/lang/Class/getEnclosingClass/EnclosingClassTest.java b/test/jdk/java/lang/Class/getEnclosingClass/EnclosingClassTest.java index 9144e9b16e3bd..d4c87817ef88e 100644 --- a/test/jdk/java/lang/Class/getEnclosingClass/EnclosingClassTest.java +++ b/test/jdk/java/lang/Class/getEnclosingClass/EnclosingClassTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it From ffbcf1b0a7d9484e95a82f667fcbabd290449711 Mon Sep 17 00:00:00 2001 From: Ioi Lam Date: Tue, 2 Feb 2021 23:40:29 +0000 Subject: [PATCH 31/77] 8260471: Change SystemDictionary::X_klass calls to vmClasses::X_klass Reviewed-by: lfoltan, hseigel, dholmes, stuefe --- .../cpu/aarch64/c1_MacroAssembler_aarch64.cpp | 1 - .../cpu/aarch64/methodHandles_aarch64.cpp | 2 +- .../cpu/aarch64/methodHandles_aarch64.hpp | 2 +- src/hotspot/cpu/aarch64/runtime_aarch64.cpp | 3 +- .../cpu/aarch64/sharedRuntime_aarch64.cpp | 1 + src/hotspot/cpu/arm/c1_MacroAssembler_arm.cpp | 1 - src/hotspot/cpu/arm/methodHandles_arm.cpp | 2 +- src/hotspot/cpu/arm/methodHandles_arm.hpp | 2 +- src/hotspot/cpu/arm/runtime_arm.cpp | 3 +- src/hotspot/cpu/ppc/c1_MacroAssembler_ppc.cpp | 1 - src/hotspot/cpu/ppc/methodHandles_ppc.cpp | 2 +- src/hotspot/cpu/ppc/methodHandles_ppc.hpp | 2 +- src/hotspot/cpu/ppc/runtime_ppc.cpp | 3 +- src/hotspot/cpu/ppc/sharedRuntime_ppc.cpp | 1 + .../cpu/s390/c1_MacroAssembler_s390.cpp | 1 - src/hotspot/cpu/s390/methodHandles_s390.cpp | 2 +- src/hotspot/cpu/s390/methodHandles_s390.hpp | 2 +- src/hotspot/cpu/s390/runtime_s390.cpp | 3 +- src/hotspot/cpu/s390/sharedRuntime_s390.cpp | 3 +- src/hotspot/cpu/x86/c1_MacroAssembler_x86.cpp | 1 - src/hotspot/cpu/x86/methodHandles_x86.cpp | 2 +- src/hotspot/cpu/x86/methodHandles_x86.hpp | 2 +- src/hotspot/cpu/x86/runtime_x86_32.cpp | 3 +- src/hotspot/cpu/x86/runtime_x86_64.cpp | 3 +- src/hotspot/cpu/x86/sharedRuntime_x86_32.cpp | 1 + src/hotspot/cpu/x86/sharedRuntime_x86_64.cpp | 1 + src/hotspot/cpu/zero/compiledIC_zero.cpp | 3 +- src/hotspot/os/aix/os_aix.cpp | 1 - src/hotspot/os/bsd/os_bsd.cpp | 1 - src/hotspot/os/linux/os_linux.cpp | 1 - src/hotspot/os/windows/os_windows.cpp | 1 - src/hotspot/os_cpu/aix_ppc/os_aix_ppc.cpp | 3 +- src/hotspot/os_cpu/bsd_x86/os_bsd_x86.cpp | 3 +- src/hotspot/os_cpu/bsd_zero/os_bsd_zero.cpp | 3 +- .../os_cpu/linux_aarch64/os_linux_aarch64.cpp | 3 +- src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp | 3 +- src/hotspot/os_cpu/linux_ppc/os_linux_ppc.cpp | 1 - .../os_cpu/linux_s390/os_linux_s390.cpp | 3 +- src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp | 3 +- .../os_cpu/linux_zero/os_linux_zero.cpp | 3 +- .../windows_aarch64/os_windows_aarch64.cpp | 1 - .../os_cpu/windows_x86/os_windows_x86.cpp | 3 +- src/hotspot/share/aot/aotCodeHeap.cpp | 4 +- src/hotspot/share/c1/c1_Runtime1.cpp | 6 +- src/hotspot/share/ci/ciEnv.cpp | 3 +- src/hotspot/share/ci/ciField.cpp | 12 +- src/hotspot/share/ci/ciInstance.cpp | 6 +- src/hotspot/share/ci/ciInstanceKlass.cpp | 10 +- src/hotspot/share/ci/ciMethod.cpp | 1 - src/hotspot/share/ci/ciObjArrayKlass.cpp | 2 +- src/hotspot/share/ci/ciObjectFactory.cpp | 7 +- src/hotspot/share/ci/ciReplay.cpp | 1 + src/hotspot/share/ci/ciType.cpp | 3 +- src/hotspot/share/classfile/altHashing.cpp | 8 +- .../share/classfile/classFileParser.cpp | 11 +- .../share/classfile/classListParser.cpp | 3 +- src/hotspot/share/classfile/classLoader.cpp | 3 +- .../share/classfile/classLoaderData.cpp | 9 +- .../share/classfile/classLoaderDataShared.cpp | 1 + .../share/classfile/classLoaderExt.cpp | 3 +- .../share/classfile/defaultMethods.cpp | 7 +- .../share/classfile/javaAssertions.cpp | 7 +- src/hotspot/share/classfile/javaClasses.cpp | 159 +++++++++--------- src/hotspot/share/classfile/javaClasses.hpp | 27 ++- .../share/classfile/javaClasses.inline.hpp | 15 +- .../share/classfile/lambdaFormInvokers.cpp | 5 +- src/hotspot/share/classfile/modules.cpp | 7 +- .../share/classfile/protectionDomainCache.cpp | 3 +- src/hotspot/share/classfile/stringTable.cpp | 6 +- .../share/classfile/systemDictionary.cpp | 34 ++-- .../share/classfile/systemDictionary.hpp | 6 +- .../classfile/systemDictionaryShared.cpp | 27 +-- .../share/classfile/verificationType.cpp | 8 +- .../share/classfile/verificationType.hpp | 3 +- src/hotspot/share/classfile/verifier.cpp | 5 +- src/hotspot/share/classfile/vmClassID.hpp | 4 +- src/hotspot/share/classfile/vmClassMacros.hpp | 6 +- src/hotspot/share/classfile/vmClasses.cpp | 22 +-- src/hotspot/share/classfile/vmClasses.hpp | 20 +-- src/hotspot/share/code/compiledIC.cpp | 3 +- src/hotspot/share/code/dependencies.cpp | 7 +- src/hotspot/share/code/nmethod.cpp | 1 + src/hotspot/share/compiler/compileBroker.cpp | 8 +- src/hotspot/share/gc/g1/g1ConcurrentMark.cpp | 1 + src/hotspot/share/gc/g1/g1FullCollector.cpp | 3 +- .../share/gc/g1/g1ParScanThreadState.cpp | 6 +- .../share/gc/parallel/psCompactionManager.cpp | 3 +- src/hotspot/share/gc/shared/collectedHeap.cpp | 4 +- .../share/gc/shared/referenceProcessor.cpp | 1 - src/hotspot/share/gc/shared/space.cpp | 6 +- .../shenandoah/shenandoahConcurrentMark.cpp | 1 - .../share/gc/shenandoah/shenandoahHeap.cpp | 1 + .../share/interpreter/bootstrapInfo.cpp | 6 +- .../share/interpreter/bytecodeUtils.cpp | 6 +- .../share/interpreter/interpreterRuntime.cpp | 18 +- .../share/interpreter/linkResolver.cpp | 31 ++-- src/hotspot/share/interpreter/rewriter.cpp | 7 +- .../jfrEventClassTransformer.cpp | 3 +- src/hotspot/share/jfr/jni/jfrJavaSupport.cpp | 14 +- .../checkpoint/objectSampleDescription.cpp | 14 +- .../recorder/checkpoint/types/jfrTypeSet.cpp | 11 +- .../recorder/service/jfrRecorderThread.cpp | 3 +- .../share/jfr/support/jfrJdkJfrEvent.cpp | 3 +- src/hotspot/share/jvmci/compilerRuntime.cpp | 1 + src/hotspot/share/jvmci/jvmciCompiler.cpp | 3 +- src/hotspot/share/jvmci/jvmciCompilerToVM.cpp | 20 ++- src/hotspot/share/jvmci/jvmciEnv.cpp | 3 +- src/hotspot/share/jvmci/jvmciJavaClasses.cpp | 6 +- src/hotspot/share/jvmci/jvmciRuntime.cpp | 10 +- src/hotspot/share/memory/archiveUtils.cpp | 5 +- src/hotspot/share/memory/heapInspection.cpp | 6 +- src/hotspot/share/memory/heapShared.cpp | 9 +- src/hotspot/share/memory/oopFactory.cpp | 3 +- src/hotspot/share/memory/universe.cpp | 39 ++--- src/hotspot/share/oops/arrayKlass.cpp | 8 +- src/hotspot/share/oops/arrayKlass.hpp | 4 +- src/hotspot/share/oops/constantPool.cpp | 9 +- src/hotspot/share/oops/cpCache.cpp | 8 +- src/hotspot/share/oops/instanceKlass.cpp | 35 ++-- .../share/oops/instanceMirrorKlass.cpp | 3 +- .../share/oops/instanceMirrorKlass.hpp | 6 +- src/hotspot/share/oops/instanceRefKlass.cpp | 6 +- src/hotspot/share/oops/klass.cpp | 9 +- src/hotspot/share/oops/method.cpp | 13 +- src/hotspot/share/oops/methodData.cpp | 2 +- src/hotspot/share/oops/objArrayKlass.cpp | 12 +- .../reflectionAccessorImplKlassHelper.cpp | 11 +- src/hotspot/share/oops/typeArrayKlass.cpp | 3 +- src/hotspot/share/opto/bytecodeInfo.cpp | 3 +- src/hotspot/share/opto/c2compiler.cpp | 4 +- src/hotspot/share/opto/cfgnode.cpp | 3 +- src/hotspot/share/opto/library_call.cpp | 1 - src/hotspot/share/opto/parse2.cpp | 1 - src/hotspot/share/opto/parseHelper.cpp | 3 +- src/hotspot/share/opto/runtime.cpp | 8 +- src/hotspot/share/prims/jni.cpp | 13 +- src/hotspot/share/prims/jniCheck.cpp | 6 +- src/hotspot/share/prims/jvm.cpp | 77 ++++----- src/hotspot/share/prims/jvmtiEnter.xsl | 3 +- src/hotspot/share/prims/jvmtiEnv.cpp | 7 +- src/hotspot/share/prims/jvmtiEnvBase.cpp | 1 - .../share/prims/jvmtiEnvThreadState.cpp | 3 +- src/hotspot/share/prims/jvmtiExport.cpp | 22 +-- .../share/prims/jvmtiGetLoadedClasses.cpp | 3 +- src/hotspot/share/prims/jvmtiImpl.cpp | 3 +- src/hotspot/share/prims/jvmtiImpl.hpp | 3 +- .../share/prims/jvmtiRedefineClasses.cpp | 7 +- src/hotspot/share/prims/jvmtiTagMap.cpp | 22 +-- src/hotspot/share/prims/jvmtiTrace.hpp | 3 +- src/hotspot/share/prims/methodHandles.cpp | 29 ++-- src/hotspot/share/prims/methodHandles.hpp | 6 +- src/hotspot/share/prims/nativeLookup.cpp | 3 +- src/hotspot/share/prims/stackwalk.cpp | 13 +- src/hotspot/share/prims/unsafe.cpp | 3 +- src/hotspot/share/prims/vectorSupport.cpp | 11 +- .../share/prims/wbtestmethods/parserTests.cpp | 5 +- src/hotspot/share/prims/whitebox.cpp | 1 + src/hotspot/share/runtime/deoptimization.cpp | 5 +- src/hotspot/share/runtime/fieldDescriptor.cpp | 3 +- .../share/runtime/fieldDescriptor.inline.hpp | 3 +- src/hotspot/share/runtime/frame.inline.hpp | 3 +- src/hotspot/share/runtime/javaCalls.cpp | 3 +- src/hotspot/share/runtime/memprofiler.cpp | 3 +- .../share/runtime/monitorDeflationThread.cpp | 5 +- .../share/runtime/notificationThread.cpp | 7 +- src/hotspot/share/runtime/os.cpp | 5 +- src/hotspot/share/runtime/reflection.cpp | 12 +- src/hotspot/share/runtime/reflectionUtils.cpp | 7 +- src/hotspot/share/runtime/safepoint.cpp | 1 - src/hotspot/share/runtime/serviceThread.cpp | 3 +- src/hotspot/share/runtime/sharedRuntime.cpp | 6 +- src/hotspot/share/runtime/statSampler.cpp | 6 +- src/hotspot/share/runtime/thread.cpp | 27 +-- src/hotspot/share/runtime/vframe.cpp | 8 +- src/hotspot/share/services/attachListener.cpp | 9 +- .../share/services/classLoadingService.cpp | 5 +- .../share/services/diagnosticCommand.cpp | 6 +- src/hotspot/share/services/gcNotifier.cpp | 8 +- src/hotspot/share/services/heapDumper.cpp | 6 +- .../share/services/lowMemoryDetector.cpp | 8 +- src/hotspot/share/services/management.cpp | 21 +-- src/hotspot/share/services/memoryManager.cpp | 3 +- src/hotspot/share/services/memoryPool.cpp | 1 - src/hotspot/share/services/memoryService.cpp | 3 +- src/hotspot/share/services/threadService.cpp | 13 +- src/hotspot/share/utilities/exceptions.cpp | 21 +-- src/hotspot/share/utilities/hashtable.cpp | 5 +- src/hotspot/share/utilities/vmEnums.hpp | 2 +- .../jvm/hotspot/memory/SystemDictionary.java | 6 +- .../hotspot/gtest/oops/test_instanceKlass.cpp | 8 +- test/hotspot/gtest/oops/test_markWord.cpp | 7 +- 191 files changed, 739 insertions(+), 712 deletions(-) diff --git a/src/hotspot/cpu/aarch64/c1_MacroAssembler_aarch64.cpp b/src/hotspot/cpu/aarch64/c1_MacroAssembler_aarch64.cpp index 535312a94f162..0616ecc1eb913 100644 --- a/src/hotspot/cpu/aarch64/c1_MacroAssembler_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/c1_MacroAssembler_aarch64.cpp @@ -26,7 +26,6 @@ #include "precompiled.hpp" #include "c1/c1_MacroAssembler.hpp" #include "c1/c1_Runtime1.hpp" -#include "classfile/systemDictionary.hpp" #include "gc/shared/barrierSetAssembler.hpp" #include "gc/shared/collectedHeap.hpp" #include "gc/shared/tlab_globals.hpp" diff --git a/src/hotspot/cpu/aarch64/methodHandles_aarch64.cpp b/src/hotspot/cpu/aarch64/methodHandles_aarch64.cpp index ee3ac821b8876..750ce1877156e 100644 --- a/src/hotspot/cpu/aarch64/methodHandles_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/methodHandles_aarch64.cpp @@ -65,7 +65,7 @@ static int check_nonzero(const char* xname, int x) { #ifdef ASSERT void MethodHandles::verify_klass(MacroAssembler* _masm, - Register obj, VMClassID klass_id, + Register obj, vmClassID klass_id, const char* error_message) { InstanceKlass** klass_addr = vmClasses::klass_addr_at(klass_id); Klass* klass = vmClasses::klass_at(klass_id); diff --git a/src/hotspot/cpu/aarch64/methodHandles_aarch64.hpp b/src/hotspot/cpu/aarch64/methodHandles_aarch64.hpp index bdfc9852d7076..553f1263d6009 100644 --- a/src/hotspot/cpu/aarch64/methodHandles_aarch64.hpp +++ b/src/hotspot/cpu/aarch64/methodHandles_aarch64.hpp @@ -36,7 +36,7 @@ enum /* platform_dependent_constants */ { static void load_klass_from_Class(MacroAssembler* _masm, Register klass_reg); static void verify_klass(MacroAssembler* _masm, - Register obj, VMClassID klass_id, + Register obj, vmClassID klass_id, const char* error_message = "wrong klass") NOT_DEBUG_RETURN; static void verify_method_handle(MacroAssembler* _masm, Register mh_reg) { diff --git a/src/hotspot/cpu/aarch64/runtime_aarch64.cpp b/src/hotspot/cpu/aarch64/runtime_aarch64.cpp index ed30c16ed8686..61d27e3224248 100644 --- a/src/hotspot/cpu/aarch64/runtime_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/runtime_aarch64.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -27,7 +27,6 @@ #ifdef COMPILER2 #include "asm/macroAssembler.hpp" #include "asm/macroAssembler.inline.hpp" -#include "classfile/systemDictionary.hpp" #include "code/vmreg.hpp" #include "interpreter/interpreter.hpp" #include "opto/runtime.hpp" diff --git a/src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp b/src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp index 704031ee9b39a..6a8530c0c008f 100644 --- a/src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp @@ -41,6 +41,7 @@ #include "prims/methodHandles.hpp" #include "runtime/safepointMechanism.hpp" #include "runtime/sharedRuntime.hpp" +#include "runtime/signature.hpp" #include "runtime/stubRoutines.hpp" #include "runtime/vframeArray.hpp" #include "utilities/align.hpp" diff --git a/src/hotspot/cpu/arm/c1_MacroAssembler_arm.cpp b/src/hotspot/cpu/arm/c1_MacroAssembler_arm.cpp index 40956f09dc7ae..a41f36360c160 100644 --- a/src/hotspot/cpu/arm/c1_MacroAssembler_arm.cpp +++ b/src/hotspot/cpu/arm/c1_MacroAssembler_arm.cpp @@ -25,7 +25,6 @@ #include "precompiled.hpp" #include "c1/c1_MacroAssembler.hpp" #include "c1/c1_Runtime1.hpp" -#include "classfile/systemDictionary.hpp" #include "gc/shared/collectedHeap.hpp" #include "gc/shared/tlab_globals.hpp" #include "interpreter/interpreter.hpp" diff --git a/src/hotspot/cpu/arm/methodHandles_arm.cpp b/src/hotspot/cpu/arm/methodHandles_arm.cpp index d6a594774db07..f259200261054 100644 --- a/src/hotspot/cpu/arm/methodHandles_arm.cpp +++ b/src/hotspot/cpu/arm/methodHandles_arm.cpp @@ -72,7 +72,7 @@ static int check_nonzero(const char* xname, int x) { #ifdef ASSERT void MethodHandles::verify_klass(MacroAssembler* _masm, - Register obj, Register temp1, Register temp2, VMClassID klass_id, + Register obj, Register temp1, Register temp2, vmClassID klass_id, const char* error_message) { InstanceKlass** klass_addr = vmClasses::klass_addr_at(klass_id); Klass* klass = vmClasses::klass_at(klass_id); diff --git a/src/hotspot/cpu/arm/methodHandles_arm.hpp b/src/hotspot/cpu/arm/methodHandles_arm.hpp index 37e002d84d0c9..9d20b68a80311 100644 --- a/src/hotspot/cpu/arm/methodHandles_arm.hpp +++ b/src/hotspot/cpu/arm/methodHandles_arm.hpp @@ -35,7 +35,7 @@ enum /* platform_dependent_constants */ { static void load_klass_from_Class(MacroAssembler* _masm, Register klass_reg, Register temp1, Register temp2); static void verify_klass(MacroAssembler* _masm, - Register obj, Register temp1, Register temp2, VMClassID klass_id, + Register obj, Register temp1, Register temp2, vmClassID klass_id, const char* error_message = "wrong klass") NOT_DEBUG_RETURN; static void verify_ref_kind(MacroAssembler* _masm, int ref_kind, Register member_reg, Register temp) NOT_DEBUG_RETURN; diff --git a/src/hotspot/cpu/arm/runtime_arm.cpp b/src/hotspot/cpu/arm/runtime_arm.cpp index 9aa8c11407d99..3aeea292d333e 100644 --- a/src/hotspot/cpu/arm/runtime_arm.cpp +++ b/src/hotspot/cpu/arm/runtime_arm.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,6 @@ #ifdef COMPILER2 #include "asm/assembler.hpp" #include "assembler_arm.inline.hpp" -#include "classfile/systemDictionary.hpp" #include "code/vmreg.hpp" #include "interpreter/interpreter.hpp" #include "memory/resourceArea.hpp" diff --git a/src/hotspot/cpu/ppc/c1_MacroAssembler_ppc.cpp b/src/hotspot/cpu/ppc/c1_MacroAssembler_ppc.cpp index aa31a26d7b3ea..ba227011ce1a9 100644 --- a/src/hotspot/cpu/ppc/c1_MacroAssembler_ppc.cpp +++ b/src/hotspot/cpu/ppc/c1_MacroAssembler_ppc.cpp @@ -27,7 +27,6 @@ #include "asm/macroAssembler.inline.hpp" #include "c1/c1_MacroAssembler.hpp" #include "c1/c1_Runtime1.hpp" -#include "classfile/systemDictionary.hpp" #include "gc/shared/collectedHeap.hpp" #include "gc/shared/tlab_globals.hpp" #include "interpreter/interpreter.hpp" diff --git a/src/hotspot/cpu/ppc/methodHandles_ppc.cpp b/src/hotspot/cpu/ppc/methodHandles_ppc.cpp index b6309a07392fa..28b2ea9da45f4 100644 --- a/src/hotspot/cpu/ppc/methodHandles_ppc.cpp +++ b/src/hotspot/cpu/ppc/methodHandles_ppc.cpp @@ -75,7 +75,7 @@ static int check_nonzero(const char* xname, int x) { #ifdef ASSERT void MethodHandles::verify_klass(MacroAssembler* _masm, - Register obj_reg, VMClassID klass_id, + Register obj_reg, vmClassID klass_id, Register temp_reg, Register temp2_reg, const char* error_message) { InstanceKlass** klass_addr = vmClasses::klass_addr_at(klass_id); diff --git a/src/hotspot/cpu/ppc/methodHandles_ppc.hpp b/src/hotspot/cpu/ppc/methodHandles_ppc.hpp index d90df83787550..252b3211d6a9f 100644 --- a/src/hotspot/cpu/ppc/methodHandles_ppc.hpp +++ b/src/hotspot/cpu/ppc/methodHandles_ppc.hpp @@ -36,7 +36,7 @@ enum /* platform_dependent_constants */ { static void load_klass_from_Class(MacroAssembler* _masm, Register klass_reg, Register temp_reg, Register temp2_reg); static void verify_klass(MacroAssembler* _masm, - Register obj_reg, VMClassID klass_id, + Register obj_reg, vmClassID klass_id, Register temp_reg, Register temp2_reg, const char* error_message = "wrong klass") NOT_DEBUG_RETURN; diff --git a/src/hotspot/cpu/ppc/runtime_ppc.cpp b/src/hotspot/cpu/ppc/runtime_ppc.cpp index e1954de1b5953..effa4df01e78b 100644 --- a/src/hotspot/cpu/ppc/runtime_ppc.cpp +++ b/src/hotspot/cpu/ppc/runtime_ppc.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, 2018 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -26,7 +26,6 @@ #include "precompiled.hpp" #ifdef COMPILER2 #include "asm/macroAssembler.inline.hpp" -#include "classfile/systemDictionary.hpp" #include "code/vmreg.hpp" #include "interpreter/interpreter.hpp" #include "interpreter/interp_masm.hpp" diff --git a/src/hotspot/cpu/ppc/sharedRuntime_ppc.cpp b/src/hotspot/cpu/ppc/sharedRuntime_ppc.cpp index f9b52195b056d..3379d679fb7fc 100644 --- a/src/hotspot/cpu/ppc/sharedRuntime_ppc.cpp +++ b/src/hotspot/cpu/ppc/sharedRuntime_ppc.cpp @@ -38,6 +38,7 @@ #include "prims/methodHandles.hpp" #include "runtime/safepointMechanism.hpp" #include "runtime/sharedRuntime.hpp" +#include "runtime/signature.hpp" #include "runtime/stubRoutines.hpp" #include "runtime/vframeArray.hpp" #include "utilities/align.hpp" diff --git a/src/hotspot/cpu/s390/c1_MacroAssembler_s390.cpp b/src/hotspot/cpu/s390/c1_MacroAssembler_s390.cpp index 003ee3c376fcb..89cea9598a4fd 100644 --- a/src/hotspot/cpu/s390/c1_MacroAssembler_s390.cpp +++ b/src/hotspot/cpu/s390/c1_MacroAssembler_s390.cpp @@ -27,7 +27,6 @@ #include "asm/macroAssembler.inline.hpp" #include "c1/c1_MacroAssembler.hpp" #include "c1/c1_Runtime1.hpp" -#include "classfile/systemDictionary.hpp" #include "gc/shared/collectedHeap.hpp" #include "gc/shared/tlab_globals.hpp" #include "interpreter/interpreter.hpp" diff --git a/src/hotspot/cpu/s390/methodHandles_s390.cpp b/src/hotspot/cpu/s390/methodHandles_s390.cpp index bf9d2e01ea9ac..1bae203f75a8a 100644 --- a/src/hotspot/cpu/s390/methodHandles_s390.cpp +++ b/src/hotspot/cpu/s390/methodHandles_s390.cpp @@ -76,7 +76,7 @@ static int check_nonzero(const char* xname, int x) { #ifdef ASSERT void MethodHandles::verify_klass(MacroAssembler* _masm, - Register obj_reg, VMClassID klass_id, + Register obj_reg, vmClassID klass_id, Register temp_reg, Register temp2_reg, const char* error_message) { diff --git a/src/hotspot/cpu/s390/methodHandles_s390.hpp b/src/hotspot/cpu/s390/methodHandles_s390.hpp index ffa794386c736..6ea9ffada054a 100644 --- a/src/hotspot/cpu/s390/methodHandles_s390.hpp +++ b/src/hotspot/cpu/s390/methodHandles_s390.hpp @@ -36,7 +36,7 @@ static void load_klass_from_Class(MacroAssembler* _masm, Register klass_reg, Register temp_reg, Register temp2_reg); static void verify_klass(MacroAssembler* _masm, - Register obj_reg, VMClassID klass_id, + Register obj_reg, vmClassID klass_id, Register temp_reg, Register temp2_reg, const char* error_message = "wrong klass") NOT_DEBUG_RETURN; diff --git a/src/hotspot/cpu/s390/runtime_s390.cpp b/src/hotspot/cpu/s390/runtime_s390.cpp index fe0c4291336a3..392a7d7dadcef 100644 --- a/src/hotspot/cpu/s390/runtime_s390.cpp +++ b/src/hotspot/cpu/s390/runtime_s390.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -26,7 +26,6 @@ #include "precompiled.hpp" #ifdef COMPILER2 #include "asm/macroAssembler.inline.hpp" -#include "classfile/systemDictionary.hpp" #include "code/vmreg.hpp" #include "interpreter/interpreter.hpp" #include "memory/resourceArea.hpp" diff --git a/src/hotspot/cpu/s390/sharedRuntime_s390.cpp b/src/hotspot/cpu/s390/sharedRuntime_s390.cpp index f5d5a6d84015c..e91c749275893 100644 --- a/src/hotspot/cpu/s390/sharedRuntime_s390.cpp +++ b/src/hotspot/cpu/s390/sharedRuntime_s390.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016, 2019 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -39,6 +39,7 @@ #include "registerSaver_s390.hpp" #include "runtime/safepointMechanism.hpp" #include "runtime/sharedRuntime.hpp" +#include "runtime/signature.hpp" #include "runtime/stubRoutines.hpp" #include "runtime/vframeArray.hpp" #include "utilities/align.hpp" diff --git a/src/hotspot/cpu/x86/c1_MacroAssembler_x86.cpp b/src/hotspot/cpu/x86/c1_MacroAssembler_x86.cpp index e05df794a9910..069d3b208be18 100644 --- a/src/hotspot/cpu/x86/c1_MacroAssembler_x86.cpp +++ b/src/hotspot/cpu/x86/c1_MacroAssembler_x86.cpp @@ -25,7 +25,6 @@ #include "precompiled.hpp" #include "c1/c1_MacroAssembler.hpp" #include "c1/c1_Runtime1.hpp" -#include "classfile/systemDictionary.hpp" #include "gc/shared/barrierSet.hpp" #include "gc/shared/barrierSetAssembler.hpp" #include "gc/shared/collectedHeap.hpp" diff --git a/src/hotspot/cpu/x86/methodHandles_x86.cpp b/src/hotspot/cpu/x86/methodHandles_x86.cpp index 0ab59f934f39d..fc2ba34709fa9 100644 --- a/src/hotspot/cpu/x86/methodHandles_x86.cpp +++ b/src/hotspot/cpu/x86/methodHandles_x86.cpp @@ -72,7 +72,7 @@ static int check_nonzero(const char* xname, int x) { #ifdef ASSERT void MethodHandles::verify_klass(MacroAssembler* _masm, - Register obj, VMClassID klass_id, + Register obj, vmClassID klass_id, const char* error_message) { InstanceKlass** klass_addr = vmClasses::klass_addr_at(klass_id); Klass* klass = vmClasses::klass_at(klass_id); diff --git a/src/hotspot/cpu/x86/methodHandles_x86.hpp b/src/hotspot/cpu/x86/methodHandles_x86.hpp index 97bd2911a22b9..b19ec0c5fd926 100644 --- a/src/hotspot/cpu/x86/methodHandles_x86.hpp +++ b/src/hotspot/cpu/x86/methodHandles_x86.hpp @@ -35,7 +35,7 @@ enum /* platform_dependent_constants */ { static void load_klass_from_Class(MacroAssembler* _masm, Register klass_reg); static void verify_klass(MacroAssembler* _masm, - Register obj, VMClassID klass_id, + Register obj, vmClassID klass_id, const char* error_message = "wrong klass") NOT_DEBUG_RETURN; static void verify_method_handle(MacroAssembler* _masm, Register mh_reg) { diff --git a/src/hotspot/cpu/x86/runtime_x86_32.cpp b/src/hotspot/cpu/x86/runtime_x86_32.cpp index b4f2529f6c143..8d1a16b2bba7b 100644 --- a/src/hotspot/cpu/x86/runtime_x86_32.cpp +++ b/src/hotspot/cpu/x86/runtime_x86_32.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,6 @@ #ifdef COMPILER2 #include "asm/macroAssembler.hpp" #include "asm/macroAssembler.inline.hpp" -#include "classfile/systemDictionary.hpp" #include "code/vmreg.hpp" #include "interpreter/interpreter.hpp" #include "memory/resourceArea.hpp" diff --git a/src/hotspot/cpu/x86/runtime_x86_64.cpp b/src/hotspot/cpu/x86/runtime_x86_64.cpp index a5b4e12f28efa..e08550715b495 100644 --- a/src/hotspot/cpu/x86/runtime_x86_64.cpp +++ b/src/hotspot/cpu/x86/runtime_x86_64.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,6 @@ #ifdef COMPILER2 #include "asm/macroAssembler.hpp" #include "asm/macroAssembler.inline.hpp" -#include "classfile/systemDictionary.hpp" #include "code/vmreg.hpp" #include "interpreter/interpreter.hpp" #include "opto/runtime.hpp" diff --git a/src/hotspot/cpu/x86/sharedRuntime_x86_32.cpp b/src/hotspot/cpu/x86/sharedRuntime_x86_32.cpp index 4aef8041ad2d7..b23e251cef9d9 100644 --- a/src/hotspot/cpu/x86/sharedRuntime_x86_32.cpp +++ b/src/hotspot/cpu/x86/sharedRuntime_x86_32.cpp @@ -40,6 +40,7 @@ #include "prims/methodHandles.hpp" #include "runtime/safepointMechanism.hpp" #include "runtime/sharedRuntime.hpp" +#include "runtime/signature.hpp" #include "runtime/stubRoutines.hpp" #include "runtime/vframeArray.hpp" #include "runtime/vm_version.hpp" diff --git a/src/hotspot/cpu/x86/sharedRuntime_x86_64.cpp b/src/hotspot/cpu/x86/sharedRuntime_x86_64.cpp index ab9d5988c2170..48cbee6e45b7b 100644 --- a/src/hotspot/cpu/x86/sharedRuntime_x86_64.cpp +++ b/src/hotspot/cpu/x86/sharedRuntime_x86_64.cpp @@ -45,6 +45,7 @@ #include "prims/methodHandles.hpp" #include "runtime/safepointMechanism.hpp" #include "runtime/sharedRuntime.hpp" +#include "runtime/signature.hpp" #include "runtime/stubRoutines.hpp" #include "runtime/vframeArray.hpp" #include "runtime/vm_version.hpp" diff --git a/src/hotspot/cpu/zero/compiledIC_zero.cpp b/src/hotspot/cpu/zero/compiledIC_zero.cpp index 1dbe95222ba12..5a3bfb028e39c 100644 --- a/src/hotspot/cpu/zero/compiledIC_zero.cpp +++ b/src/hotspot/cpu/zero/compiledIC_zero.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,6 @@ */ #include "precompiled.hpp" -#include "classfile/systemDictionary.hpp" #include "code/codeCache.hpp" #include "code/compiledIC.hpp" #include "code/icBuffer.hpp" diff --git a/src/hotspot/os/aix/os_aix.cpp b/src/hotspot/os/aix/os_aix.cpp index 8afab67a29d89..a976e4f6b9400 100644 --- a/src/hotspot/os/aix/os_aix.cpp +++ b/src/hotspot/os/aix/os_aix.cpp @@ -30,7 +30,6 @@ // no precompiled headers #include "jvm.h" #include "classfile/classLoader.hpp" -#include "classfile/systemDictionary.hpp" #include "classfile/vmSymbols.hpp" #include "code/icBuffer.hpp" #include "code/vtableStubs.hpp" diff --git a/src/hotspot/os/bsd/os_bsd.cpp b/src/hotspot/os/bsd/os_bsd.cpp index 4ebd201545363..627b995dfedaa 100644 --- a/src/hotspot/os/bsd/os_bsd.cpp +++ b/src/hotspot/os/bsd/os_bsd.cpp @@ -25,7 +25,6 @@ // no precompiled headers #include "jvm.h" #include "classfile/classLoader.hpp" -#include "classfile/systemDictionary.hpp" #include "classfile/vmSymbols.hpp" #include "code/icBuffer.hpp" #include "code/vtableStubs.hpp" diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp index 3e647591c9fe0..32b6bcb23f4f3 100644 --- a/src/hotspot/os/linux/os_linux.cpp +++ b/src/hotspot/os/linux/os_linux.cpp @@ -25,7 +25,6 @@ // no precompiled headers #include "jvm.h" #include "classfile/classLoader.hpp" -#include "classfile/systemDictionary.hpp" #include "classfile/vmSymbols.hpp" #include "code/icBuffer.hpp" #include "code/vtableStubs.hpp" diff --git a/src/hotspot/os/windows/os_windows.cpp b/src/hotspot/os/windows/os_windows.cpp index a64397e29e4f2..53dd2d99f157c 100644 --- a/src/hotspot/os/windows/os_windows.cpp +++ b/src/hotspot/os/windows/os_windows.cpp @@ -28,7 +28,6 @@ // no precompiled headers #include "jvm.h" #include "classfile/classLoader.hpp" -#include "classfile/systemDictionary.hpp" #include "classfile/vmSymbols.hpp" #include "code/codeCache.hpp" #include "code/icBuffer.hpp" diff --git a/src/hotspot/os_cpu/aix_ppc/os_aix_ppc.cpp b/src/hotspot/os_cpu/aix_ppc/os_aix_ppc.cpp index 0e291cfddfa29..07f1f8be755fd 100644 --- a/src/hotspot/os_cpu/aix_ppc/os_aix_ppc.cpp +++ b/src/hotspot/os_cpu/aix_ppc/os_aix_ppc.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, 2020 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -28,7 +28,6 @@ #include "assembler_ppc.hpp" #include "asm/assembler.inline.hpp" #include "classfile/classLoader.hpp" -#include "classfile/systemDictionary.hpp" #include "classfile/vmSymbols.hpp" #include "code/codeCache.hpp" #include "code/icBuffer.hpp" diff --git a/src/hotspot/os_cpu/bsd_x86/os_bsd_x86.cpp b/src/hotspot/os_cpu/bsd_x86/os_bsd_x86.cpp index d17927f188144..d1462df5fce3e 100644 --- a/src/hotspot/os_cpu/bsd_x86/os_bsd_x86.cpp +++ b/src/hotspot/os_cpu/bsd_x86/os_bsd_x86.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,6 @@ #include "jvm.h" #include "asm/macroAssembler.hpp" #include "classfile/classLoader.hpp" -#include "classfile/systemDictionary.hpp" #include "classfile/vmSymbols.hpp" #include "code/codeCache.hpp" #include "code/icBuffer.hpp" diff --git a/src/hotspot/os_cpu/bsd_zero/os_bsd_zero.cpp b/src/hotspot/os_cpu/bsd_zero/os_bsd_zero.cpp index b0c3c9b7d5473..8bca69035b7c9 100644 --- a/src/hotspot/os_cpu/bsd_zero/os_bsd_zero.cpp +++ b/src/hotspot/os_cpu/bsd_zero/os_bsd_zero.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. * Copyright 2007, 2008, 2009, 2010 Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -32,7 +32,6 @@ #include "jvm.h" #include "assembler_zero.inline.hpp" #include "classfile/classLoader.hpp" -#include "classfile/systemDictionary.hpp" #include "classfile/vmSymbols.hpp" #include "code/icBuffer.hpp" #include "code/vtableStubs.hpp" diff --git a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp index 2acf685a2aa7a..a785369a8ddca 100644 --- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp +++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -27,7 +27,6 @@ #include "jvm.h" #include "asm/macroAssembler.hpp" #include "classfile/classLoader.hpp" -#include "classfile/systemDictionary.hpp" #include "classfile/vmSymbols.hpp" #include "code/codeCache.hpp" #include "code/icBuffer.hpp" diff --git a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp index 695ea3d33db19..12eb0f543cefe 100644 --- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp +++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,6 @@ #include "jvm.h" #include "assembler_arm.inline.hpp" #include "classfile/classLoader.hpp" -#include "classfile/systemDictionary.hpp" #include "classfile/vmSymbols.hpp" #include "code/icBuffer.hpp" #include "code/vtableStubs.hpp" diff --git a/src/hotspot/os_cpu/linux_ppc/os_linux_ppc.cpp b/src/hotspot/os_cpu/linux_ppc/os_linux_ppc.cpp index 743f199d1debe..0e390ab3f2809 100644 --- a/src/hotspot/os_cpu/linux_ppc/os_linux_ppc.cpp +++ b/src/hotspot/os_cpu/linux_ppc/os_linux_ppc.cpp @@ -28,7 +28,6 @@ #include "assembler_ppc.hpp" #include "asm/assembler.inline.hpp" #include "classfile/classLoader.hpp" -#include "classfile/systemDictionary.hpp" #include "classfile/vmSymbols.hpp" #include "code/codeCache.hpp" #include "code/icBuffer.hpp" diff --git a/src/hotspot/os_cpu/linux_s390/os_linux_s390.cpp b/src/hotspot/os_cpu/linux_s390/os_linux_s390.cpp index 7db5f2cbfba51..cd370d2f7a318 100644 --- a/src/hotspot/os_cpu/linux_s390/os_linux_s390.cpp +++ b/src/hotspot/os_cpu/linux_s390/os_linux_s390.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016, 2019 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -29,7 +29,6 @@ #include "jvm.h" #include "asm/assembler.inline.hpp" #include "classfile/classLoader.hpp" -#include "classfile/systemDictionary.hpp" #include "classfile/vmSymbols.hpp" #include "code/icBuffer.hpp" #include "code/nativeInst.hpp" diff --git a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp index af205c03e234d..ed603aa641e28 100644 --- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp +++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,6 @@ #include "jvm.h" #include "asm/macroAssembler.hpp" #include "classfile/classLoader.hpp" -#include "classfile/systemDictionary.hpp" #include "classfile/vmSymbols.hpp" #include "code/codeCache.hpp" #include "code/icBuffer.hpp" diff --git a/src/hotspot/os_cpu/linux_zero/os_linux_zero.cpp b/src/hotspot/os_cpu/linux_zero/os_linux_zero.cpp index 2ef3dfc7181e4..e38b7d351aec3 100644 --- a/src/hotspot/os_cpu/linux_zero/os_linux_zero.cpp +++ b/src/hotspot/os_cpu/linux_zero/os_linux_zero.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. * Copyright 2007, 2008, 2009, 2010 Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -27,7 +27,6 @@ #include "jvm.h" #include "assembler_zero.inline.hpp" #include "classfile/classLoader.hpp" -#include "classfile/systemDictionary.hpp" #include "classfile/vmSymbols.hpp" #include "code/icBuffer.hpp" #include "code/vtableStubs.hpp" diff --git a/src/hotspot/os_cpu/windows_aarch64/os_windows_aarch64.cpp b/src/hotspot/os_cpu/windows_aarch64/os_windows_aarch64.cpp index d94ca5d4707bb..6422eb406e05a 100644 --- a/src/hotspot/os_cpu/windows_aarch64/os_windows_aarch64.cpp +++ b/src/hotspot/os_cpu/windows_aarch64/os_windows_aarch64.cpp @@ -26,7 +26,6 @@ #include "jvm.h" #include "asm/macroAssembler.hpp" #include "classfile/classLoader.hpp" -#include "classfile/systemDictionary.hpp" #include "classfile/vmSymbols.hpp" #include "code/codeCache.hpp" #include "code/icBuffer.hpp" diff --git a/src/hotspot/os_cpu/windows_x86/os_windows_x86.cpp b/src/hotspot/os_cpu/windows_x86/os_windows_x86.cpp index a87d45a5f6d1e..2e18762cf634d 100644 --- a/src/hotspot/os_cpu/windows_x86/os_windows_x86.cpp +++ b/src/hotspot/os_cpu/windows_x86/os_windows_x86.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,6 @@ #include "jvm.h" #include "asm/macroAssembler.hpp" #include "classfile/classLoader.hpp" -#include "classfile/systemDictionary.hpp" #include "classfile/vmSymbols.hpp" #include "code/icBuffer.hpp" #include "code/vtableStubs.hpp" diff --git a/src/hotspot/share/aot/aotCodeHeap.cpp b/src/hotspot/share/aot/aotCodeHeap.cpp index 99cb7eda94ef1..a84138d64c8a8 100644 --- a/src/hotspot/share/aot/aotCodeHeap.cpp +++ b/src/hotspot/share/aot/aotCodeHeap.cpp @@ -27,6 +27,8 @@ #include "aot/aotLoader.hpp" #include "ci/ciUtilities.inline.hpp" #include "classfile/javaAssertions.hpp" +#include "classfile/systemDictionary.hpp" +#include "classfile/vmClasses.hpp" #include "classfile/vmSymbols.hpp" #include "gc/shared/cardTable.hpp" #include "gc/shared/cardTableBarrierSet.hpp" @@ -389,7 +391,7 @@ void AOTCodeHeap::link_known_klasses() { link_klass(arr_klass); } } - link_klass(SystemDictionary::Reference_klass()); + link_klass(vmClasses::Reference_klass()); } void AOTCodeHeap::register_stubs() { diff --git a/src/hotspot/share/c1/c1_Runtime1.cpp b/src/hotspot/share/c1/c1_Runtime1.cpp index 403ef7ea722a8..bdb9576ccab45 100644 --- a/src/hotspot/share/c1/c1_Runtime1.cpp +++ b/src/hotspot/share/c1/c1_Runtime1.cpp @@ -31,7 +31,7 @@ #include "c1/c1_MacroAssembler.hpp" #include "c1/c1_Runtime1.hpp" #include "classfile/javaClasses.inline.hpp" -#include "classfile/systemDictionary.hpp" +#include "classfile/vmClasses.hpp" #include "classfile/vmSymbols.hpp" #include "code/codeBlob.hpp" #include "code/compiledIC.hpp" @@ -532,7 +532,7 @@ JRT_ENTRY_NO_ASYNC(static address, exception_handler_for_pc_helper(JavaThread* t } assert(exception.not_null(), "NULL exceptions should be handled by throw_exception"); // Check that exception is a subclass of Throwable - assert(exception->is_a(SystemDictionary::Throwable_klass()), + assert(exception->is_a(vmClasses::Throwable_klass()), "Exception not subclass of Throwable"); // debugging support @@ -1419,7 +1419,7 @@ JRT_ENTRY(void, Runtime1::predicate_failed_trap(JavaThread* thread)) Method::build_interpreter_method_data(m, THREAD); if (HAS_PENDING_EXCEPTION) { // Only metaspace OOM is expected. No Java code executed. - assert((PENDING_EXCEPTION->is_a(SystemDictionary::OutOfMemoryError_klass())), "we expect only an OOM error here"); + assert((PENDING_EXCEPTION->is_a(vmClasses::OutOfMemoryError_klass())), "we expect only an OOM error here"); CLEAR_PENDING_EXCEPTION; } mdo = m->method_data(); diff --git a/src/hotspot/share/ci/ciEnv.cpp b/src/hotspot/share/ci/ciEnv.cpp index 7a16405e9771a..3df467216ba93 100644 --- a/src/hotspot/share/ci/ciEnv.cpp +++ b/src/hotspot/share/ci/ciEnv.cpp @@ -37,6 +37,7 @@ #include "classfile/javaClasses.hpp" #include "classfile/symbolTable.hpp" #include "classfile/systemDictionary.hpp" +#include "classfile/vmClasses.hpp" #include "classfile/vmSymbols.hpp" #include "code/codeCache.hpp" #include "code/scopeDesc.hpp" @@ -799,7 +800,7 @@ ciMethod* ciEnv::get_method_by_index_impl(const constantPoolHandle& cpool, } // Fake a method that is equivalent to a declared method. - ciInstanceKlass* holder = get_instance_klass(SystemDictionary::MethodHandle_klass()); + ciInstanceKlass* holder = get_instance_klass(vmClasses::MethodHandle_klass()); ciSymbol* name = ciSymbols::invokeBasic_name(); ciSymbol* signature = get_symbol(cpool->signature_ref_at(index)); return get_unloaded_method(holder, name, signature, accessor); diff --git a/src/hotspot/share/ci/ciField.cpp b/src/hotspot/share/ci/ciField.cpp index fcdece72fc2ad..75e35c88406bb 100644 --- a/src/hotspot/share/ci/ciField.cpp +++ b/src/hotspot/share/ci/ciField.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,7 +28,7 @@ #include "ci/ciSymbols.hpp" #include "ci/ciUtilities.inline.hpp" #include "classfile/javaClasses.hpp" -#include "classfile/systemDictionary.hpp" +#include "classfile/vmClasses.hpp" #include "gc/shared/collectedHeap.inline.hpp" #include "interpreter/linkResolver.hpp" #include "oops/klass.inline.hpp" @@ -270,8 +270,8 @@ void ciField::initialize_from(fieldDescriptor* fd) { // not be constant is when the field is a *special* static & final field // whose value may change. The three examples are java.lang.System.in, // java.lang.System.out, and java.lang.System.err. - assert(SystemDictionary::System_klass() != NULL, "Check once per vm"); - if (k == SystemDictionary::System_klass()) { + assert(vmClasses::System_klass() != NULL, "Check once per vm"); + if (k == vmClasses::System_klass()) { // Check offsets for case 2: System.in, System.out, or System.err if (_offset == java_lang_System::in_offset() || _offset == java_lang_System::out_offset() || @@ -289,8 +289,8 @@ void ciField::initialize_from(fieldDescriptor* fd) { } } else { // For CallSite objects treat the target field as a compile time constant. - assert(SystemDictionary::CallSite_klass() != NULL, "should be already initialized"); - if (k == SystemDictionary::CallSite_klass() && + assert(vmClasses::CallSite_klass() != NULL, "should be already initialized"); + if (k == vmClasses::CallSite_klass() && _offset == java_lang_invoke_CallSite::target_offset()) { assert(!has_initialized_final_update(), "CallSite is not supposed to have writes to final fields outside initializers"); _is_constant = true; diff --git a/src/hotspot/share/ci/ciInstance.cpp b/src/hotspot/share/ci/ciInstance.cpp index 5bfbf7fa5effc..cb014ea00f019 100644 --- a/src/hotspot/share/ci/ciInstance.cpp +++ b/src/hotspot/share/ci/ciInstance.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,7 +29,7 @@ #include "ci/ciInstance.hpp" #include "ci/ciInstanceKlass.hpp" #include "ci/ciUtilities.inline.hpp" -#include "classfile/systemDictionary.hpp" +#include "classfile/vmClasses.hpp" #include "oops/oop.inline.hpp" // ciInstance @@ -43,7 +43,7 @@ ciType* ciInstance::java_mirror_type() { VM_ENTRY_MARK; oop m = get_oop(); // Return NULL if it is not java.lang.Class. - if (m == NULL || m->klass() != SystemDictionary::Class_klass()) { + if (m == NULL || m->klass() != vmClasses::Class_klass()) { return NULL; } // Return either a primitive type or a klass. diff --git a/src/hotspot/share/ci/ciInstanceKlass.cpp b/src/hotspot/share/ci/ciInstanceKlass.cpp index 85ab8d353401f..8baa34d19e631 100644 --- a/src/hotspot/share/ci/ciInstanceKlass.cpp +++ b/src/hotspot/share/ci/ciInstanceKlass.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,8 +27,8 @@ #include "ci/ciInstance.hpp" #include "ci/ciInstanceKlass.hpp" #include "ci/ciUtilities.inline.hpp" -#include "classfile/systemDictionary.hpp" #include "classfile/javaClasses.hpp" +#include "classfile/vmClasses.hpp" #include "memory/allocation.hpp" #include "memory/allocation.inline.hpp" #include "memory/resourceArea.hpp" @@ -107,7 +107,7 @@ ciInstanceKlass::ciInstanceKlass(Klass* k) : _java_mirror = NULL; if (is_shared()) { - if (k != SystemDictionary::Object_klass()) { + if (k != vmClasses::Object_klass()) { super(); } //compute_nonstatic_fields(); // done outside of constructor @@ -260,7 +260,7 @@ bool ciInstanceKlass::uses_default_loader() const { */ BasicType ciInstanceKlass::box_klass_type() const { if (uses_default_loader() && is_loaded()) { - return SystemDictionary::box_klass_type(get_Klass()); + return vmClasses::box_klass_type(get_Klass()); } else { return T_OBJECT; } @@ -689,7 +689,7 @@ class StaticFinalFieldPrinter : public FieldClosure { _out->print_cr("null"); } else if (value->is_instance()) { assert(fd->field_type() == T_OBJECT, ""); - if (value->is_a(SystemDictionary::String_klass())) { + if (value->is_a(vmClasses::String_klass())) { const char* ascii_value = java_lang_String::as_quoted_ascii(value); _out->print("\"%s\"", (ascii_value != NULL) ? ascii_value : ""); } else { diff --git a/src/hotspot/share/ci/ciMethod.cpp b/src/hotspot/share/ci/ciMethod.cpp index 586d245924780..23cb305e104a1 100644 --- a/src/hotspot/share/ci/ciMethod.cpp +++ b/src/hotspot/share/ci/ciMethod.cpp @@ -34,7 +34,6 @@ #include "ci/ciReplay.hpp" #include "ci/ciSymbols.hpp" #include "ci/ciUtilities.inline.hpp" -#include "classfile/systemDictionary.hpp" #include "compiler/abstractCompiler.hpp" #include "compiler/methodLiveness.hpp" #include "interpreter/interpreter.hpp" diff --git a/src/hotspot/share/ci/ciObjArrayKlass.cpp b/src/hotspot/share/ci/ciObjArrayKlass.cpp index 791f06d3bc516..54ed5ceba1025 100644 --- a/src/hotspot/share/ci/ciObjArrayKlass.cpp +++ b/src/hotspot/share/ci/ciObjArrayKlass.cpp @@ -27,8 +27,8 @@ #include "ci/ciObjArrayKlass.hpp" #include "ci/ciSymbol.hpp" #include "ci/ciUtilities.inline.hpp" -#include "classfile/systemDictionary.hpp" #include "oops/objArrayKlass.hpp" +#include "runtime/signature.hpp" // ciObjArrayKlass // diff --git a/src/hotspot/share/ci/ciObjectFactory.cpp b/src/hotspot/share/ci/ciObjectFactory.cpp index e4acf6adad9bf..979136316e957 100644 --- a/src/hotspot/share/ci/ciObjectFactory.cpp +++ b/src/hotspot/share/ci/ciObjectFactory.cpp @@ -43,13 +43,14 @@ #include "ci/ciTypeArrayKlass.hpp" #include "ci/ciUtilities.inline.hpp" #include "classfile/javaClasses.inline.hpp" -#include "classfile/systemDictionary.hpp" +#include "classfile/vmClasses.hpp" #include "compiler/compiler_globals.hpp" #include "gc/shared/collectedHeap.inline.hpp" #include "memory/allocation.inline.hpp" #include "memory/universe.hpp" #include "oops/oop.inline.hpp" #include "runtime/handles.inline.hpp" +#include "runtime/signature.hpp" #include "utilities/macros.hpp" // ciObjectFactory @@ -153,8 +154,8 @@ void ciObjectFactory::init_shared_objects() { init_ident_of(ciEnv::_null_object_instance); #define VM_CLASS_DEFN(name, ignore_s) \ - if (SystemDictionary::name##_is_loaded()) \ - ciEnv::_##name = get_metadata(SystemDictionary::name())->as_instance_klass(); + if (vmClasses::name##_is_loaded()) \ + ciEnv::_##name = get_metadata(vmClasses::name())->as_instance_klass(); VM_CLASSES_DO(VM_CLASS_DEFN) #undef VM_CLASS_DEFN diff --git a/src/hotspot/share/ci/ciReplay.cpp b/src/hotspot/share/ci/ciReplay.cpp index b0a7fc35e0eda..c5e95626b88c9 100644 --- a/src/hotspot/share/ci/ciReplay.cpp +++ b/src/hotspot/share/ci/ciReplay.cpp @@ -31,6 +31,7 @@ #include "ci/ciUtilities.inline.hpp" #include "classfile/javaClasses.hpp" #include "classfile/symbolTable.hpp" +#include "classfile/systemDictionary.hpp" #include "compiler/compilationPolicy.hpp" #include "compiler/compileBroker.hpp" #include "memory/allocation.inline.hpp" diff --git a/src/hotspot/share/ci/ciType.cpp b/src/hotspot/share/ci/ciType.cpp index fbfd3bc835302..d445f56b213a5 100644 --- a/src/hotspot/share/ci/ciType.cpp +++ b/src/hotspot/share/ci/ciType.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,6 @@ #include "ci/ciEnv.hpp" #include "ci/ciType.hpp" #include "ci/ciUtilities.inline.hpp" -#include "classfile/systemDictionary.hpp" #include "memory/resourceArea.hpp" #include "memory/universe.hpp" #include "oops/oop.inline.hpp" diff --git a/src/hotspot/share/classfile/altHashing.cpp b/src/hotspot/share/classfile/altHashing.cpp index cf9b9cffcd7ae..d0672138668f9 100644 --- a/src/hotspot/share/classfile/altHashing.cpp +++ b/src/hotspot/share/classfile/altHashing.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,7 @@ #include "precompiled.hpp" #include "classfile/altHashing.hpp" -#include "classfile/systemDictionary.hpp" +#include "classfile/vmClasses.hpp" #include "oops/klass.inline.hpp" #include "oops/markWord.hpp" #include "oops/oop.inline.hpp" @@ -62,8 +62,8 @@ uint64_t AltHashing::compute_seed() { uint64_t nanos = os::javaTimeNanos(); uint64_t now = os::javaTimeMillis(); uint32_t SEED_MATERIAL[8] = { - (uint32_t) object_hash(SystemDictionary::String_klass()), - (uint32_t) object_hash(SystemDictionary::System_klass()), + (uint32_t) object_hash(vmClasses::String_klass()), + (uint32_t) object_hash(vmClasses::System_klass()), (uint32_t) os::random(), // current thread isn't a java thread (uint32_t) (((uint64_t)nanos) >> 32), (uint32_t) nanos, diff --git a/src/hotspot/share/classfile/classFileParser.cpp b/src/hotspot/share/classfile/classFileParser.cpp index addc109d639f2..6aa20958fb753 100644 --- a/src/hotspot/share/classfile/classFileParser.cpp +++ b/src/hotspot/share/classfile/classFileParser.cpp @@ -39,6 +39,7 @@ #include "classfile/systemDictionary.hpp" #include "classfile/verificationType.hpp" #include "classfile/verifier.hpp" +#include "classfile/vmClasses.hpp" #include "classfile/vmSymbols.hpp" #include "logging/log.hpp" #include "logging/logStream.hpp" @@ -2684,7 +2685,7 @@ Method* ClassFileParser::parse_method(const ClassFileStream* const cfs, cfs->skip_u2_fast(method_parameters_length); cfs->skip_u2_fast(method_parameters_length); // ignore this attribute if it cannot be reflected - if (!SystemDictionary::Parameter_klass_loaded()) + if (!vmClasses::Parameter_klass_loaded()) method_parameters_length = -1; } else if (method_attribute_name == vmSymbols::tag_synthetic()) { if (method_attribute_length != 0) { @@ -4306,8 +4307,8 @@ void ClassFileParser::set_precomputed_flags(InstanceKlass* ik) { #endif // Check if this klass supports the java.lang.Cloneable interface - if (SystemDictionary::Cloneable_klass_loaded()) { - if (ik->is_subtype_of(SystemDictionary::Cloneable_klass())) { + if (vmClasses::Cloneable_klass_loaded()) { + if (ik->is_subtype_of(vmClasses::Cloneable_klass())) { ik->set_is_cloneable(); } } @@ -4952,7 +4953,7 @@ static const char* skip_over_field_name(const char* const name, if (not_first_ch) { // public static boolean isJavaIdentifierPart(char ch); JavaCalls::call_static(&result, - SystemDictionary::Character_klass(), + vmClasses::Character_klass(), vmSymbols::isJavaIdentifierPart_name(), vmSymbols::int_bool_signature(), &args, @@ -4960,7 +4961,7 @@ static const char* skip_over_field_name(const char* const name, } else { // public static boolean isJavaIdentifierStart(char ch); JavaCalls::call_static(&result, - SystemDictionary::Character_klass(), + vmClasses::Character_klass(), vmSymbols::isJavaIdentifierStart_name(), vmSymbols::int_bool_signature(), &args, diff --git a/src/hotspot/share/classfile/classListParser.cpp b/src/hotspot/share/classfile/classListParser.cpp index 2236c077fac6c..e5e8f2cd243cf 100644 --- a/src/hotspot/share/classfile/classListParser.cpp +++ b/src/hotspot/share/classfile/classListParser.cpp @@ -32,6 +32,7 @@ #include "classfile/symbolTable.hpp" #include "classfile/systemDictionary.hpp" #include "classfile/systemDictionaryShared.hpp" +#include "classfile/vmClasses.hpp" #include "classfile/vmSymbols.hpp" #include "interpreter/bytecode.hpp" #include "interpreter/bytecodeStream.hpp" @@ -564,7 +565,7 @@ Klass* ClassListParser::load_current_class(TRAPS) { JavaCalls::call_virtual(&result, loader, //SystemDictionary::java_system_loader(), - SystemDictionary::ClassLoader_klass(), + vmClasses::ClassLoader_klass(), vmSymbols::loadClass_name(), vmSymbols::string_class_signature(), ext_class_name, diff --git a/src/hotspot/share/classfile/classLoader.cpp b/src/hotspot/share/classfile/classLoader.cpp index 24561cbf4a2c4..d80fe19bd3574 100644 --- a/src/hotspot/share/classfile/classLoader.cpp +++ b/src/hotspot/share/classfile/classLoader.cpp @@ -38,6 +38,7 @@ #include "classfile/symbolTable.hpp" #include "classfile/systemDictionary.hpp" #include "classfile/systemDictionaryShared.hpp" +#include "classfile/vmClasses.hpp" #include "classfile/vmSymbols.hpp" #include "compiler/compileBroker.hpp" #include "interpreter/bytecodeStream.hpp" @@ -1076,7 +1077,7 @@ objArrayOop ClassLoader::get_system_packages(TRAPS) { // Allocate objArray and fill with java.lang.String - objArrayOop r = oopFactory::new_objArray(SystemDictionary::String_klass(), + objArrayOop r = oopFactory::new_objArray(vmClasses::String_klass(), loaded_class_pkgs->length(), CHECK_NULL); objArrayHandle result(THREAD, r); for (int x = 0; x < loaded_class_pkgs->length(); x++) { diff --git a/src/hotspot/share/classfile/classLoaderData.cpp b/src/hotspot/share/classfile/classLoaderData.cpp index 35e6bad112a05..2a640731de698 100644 --- a/src/hotspot/share/classfile/classLoaderData.cpp +++ b/src/hotspot/share/classfile/classLoaderData.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -55,6 +55,7 @@ #include "classfile/packageEntry.hpp" #include "classfile/symbolTable.hpp" #include "classfile/systemDictionary.hpp" +#include "classfile/vmClasses.hpp" #include "logging/log.hpp" #include "logging/logStream.hpp" #include "memory/allocation.inline.hpp" @@ -363,7 +364,7 @@ void ClassLoaderData::loaded_classes_do(KlassClosure* klass_closure) { #ifdef ASSERT oop m = k->java_mirror(); assert(m != NULL, "NULL mirror"); - assert(m->is_a(SystemDictionary::Class_klass()), "invalid mirror"); + assert(m->is_a(vmClasses::Class_klass()), "invalid mirror"); #endif klass_closure->do_klass(k); } @@ -585,7 +586,7 @@ Dictionary* ClassLoaderData::create_dictionary() { if (_the_null_class_loader_data == NULL) { size = _boot_loader_dictionary_size; resizable = true; - } else if (class_loader()->is_a(SystemDictionary::reflect_DelegatingClassLoader_klass())) { + } else if (class_loader()->is_a(vmClasses::reflect_DelegatingClassLoader_klass())) { size = 1; // there's only one class in relection class loader and no initiated classes } else if (is_system_class_loader_data()) { size = _boot_loader_dictionary_size; @@ -768,7 +769,7 @@ ClassLoaderMetaspace* ClassLoaderData::metaspace_non_null() { metaspace = new ClassLoaderMetaspace(_metaspace_lock, Metaspace::BootMetaspaceType); } else if (has_class_mirror_holder()) { metaspace = new ClassLoaderMetaspace(_metaspace_lock, Metaspace::ClassMirrorHolderMetaspaceType); - } else if (class_loader()->is_a(SystemDictionary::reflect_DelegatingClassLoader_klass())) { + } else if (class_loader()->is_a(vmClasses::reflect_DelegatingClassLoader_klass())) { metaspace = new ClassLoaderMetaspace(_metaspace_lock, Metaspace::ReflectionMetaspaceType); } else { metaspace = new ClassLoaderMetaspace(_metaspace_lock, Metaspace::StandardMetaspaceType); diff --git a/src/hotspot/share/classfile/classLoaderDataShared.cpp b/src/hotspot/share/classfile/classLoaderDataShared.cpp index 3d4a44220dd55..f9840e566dd3c 100644 --- a/src/hotspot/share/classfile/classLoaderDataShared.cpp +++ b/src/hotspot/share/classfile/classLoaderDataShared.cpp @@ -27,6 +27,7 @@ #include "classfile/classLoaderDataShared.hpp" #include "classfile/moduleEntry.hpp" #include "classfile/packageEntry.hpp" +#include "classfile/systemDictionary.hpp" #include "logging/log.hpp" #include "memory/metaspaceShared.hpp" #include "runtime/handles.inline.hpp" diff --git a/src/hotspot/share/classfile/classLoaderExt.cpp b/src/hotspot/share/classfile/classLoaderExt.cpp index 04a8923060e89..8709498b56c87 100644 --- a/src/hotspot/share/classfile/classLoaderExt.cpp +++ b/src/hotspot/share/classfile/classLoaderExt.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,6 +31,7 @@ #include "classfile/classLoadInfo.hpp" #include "classfile/klassFactory.hpp" #include "classfile/modules.hpp" +#include "classfile/systemDictionary.hpp" #include "classfile/systemDictionaryShared.hpp" #include "classfile/vmSymbols.hpp" #include "logging/log.hpp" diff --git a/src/hotspot/share/classfile/defaultMethods.cpp b/src/hotspot/share/classfile/defaultMethods.cpp index 581f9d539aefc..063772e14d2b9 100644 --- a/src/hotspot/share/classfile/defaultMethods.cpp +++ b/src/hotspot/share/classfile/defaultMethods.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,7 @@ #include "classfile/defaultMethods.hpp" #include "classfile/symbolTable.hpp" #include "classfile/systemDictionary.hpp" +#include "classfile/vmClasses.hpp" #include "classfile/vmSymbols.hpp" #include "logging/log.hpp" #include "logging/logStream.hpp" @@ -140,7 +141,7 @@ class HierarchyVisitor : StackObj { bool has_more_nodes() const { return _path.length() > 0; } void push(InstanceKlass* cls, ALGO* algo) { assert(cls != NULL, "Requires a valid instance class"); - if (cls == SystemDictionary::Object_klass()) { + if (cls == vmClasses::Object_klass()) { _visited_Object = true; } void* data = algo->new_node_data(); @@ -817,7 +818,7 @@ static void create_default_methods( InstanceKlass* klass, void DefaultMethods::generate_default_methods( InstanceKlass* klass, const GrowableArray* mirandas, TRAPS) { assert(klass != NULL, "invariant"); - assert(klass != SystemDictionary::Object_klass(), "Shouldn't be called for Object"); + assert(klass != vmClasses::Object_klass(), "Shouldn't be called for Object"); // This resource mark is the bound for all memory allocation that takes // place during default method processing. After this goes out of scope, diff --git a/src/hotspot/share/classfile/javaAssertions.cpp b/src/hotspot/share/classfile/javaAssertions.cpp index 606440542eb41..d5430ade39a78 100644 --- a/src/hotspot/share/classfile/javaAssertions.cpp +++ b/src/hotspot/share/classfile/javaAssertions.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ #include "classfile/javaAssertions.hpp" #include "classfile/javaClasses.hpp" #include "classfile/systemDictionary.hpp" +#include "classfile/vmClasses.hpp" #include "classfile/vmSymbols.hpp" #include "memory/allocation.inline.hpp" #include "memory/oopFactory.hpp" @@ -104,14 +105,14 @@ oop JavaAssertions::createAssertionStatusDirectives(TRAPS) { int len; typeArrayOop t; len = OptionList::count(_packages); - objArrayOop pn = oopFactory::new_objArray(SystemDictionary::String_klass(), len, CHECK_NULL); + objArrayOop pn = oopFactory::new_objArray(vmClasses::String_klass(), len, CHECK_NULL); objArrayHandle pkgNames (THREAD, pn); t = oopFactory::new_typeArray(T_BOOLEAN, len, CHECK_NULL); typeArrayHandle pkgEnabled(THREAD, t); fillJavaArrays(_packages, len, pkgNames, pkgEnabled, CHECK_NULL); len = OptionList::count(_classes); - objArrayOop cn = oopFactory::new_objArray(SystemDictionary::String_klass(), len, CHECK_NULL); + objArrayOop cn = oopFactory::new_objArray(vmClasses::String_klass(), len, CHECK_NULL); objArrayHandle classNames (THREAD, cn); t = oopFactory::new_typeArray(T_BOOLEAN, len, CHECK_NULL); typeArrayHandle classEnabled(THREAD, t); diff --git a/src/hotspot/share/classfile/javaClasses.cpp b/src/hotspot/share/classfile/javaClasses.cpp index c9895eda993bd..95aea1ab97642 100644 --- a/src/hotspot/share/classfile/javaClasses.cpp +++ b/src/hotspot/share/classfile/javaClasses.cpp @@ -31,6 +31,7 @@ #include "classfile/moduleEntry.hpp" #include "classfile/stringTable.hpp" #include "classfile/symbolTable.hpp" +#include "classfile/systemDictionary.hpp" #include "classfile/vmClasses.hpp" #include "classfile/vmSymbols.hpp" #include "code/debugInfo.hpp" @@ -97,7 +98,7 @@ InjectedField JavaClasses::_injected_fields[] = { // Register native methods of Object void java_lang_Object::register_natives(TRAPS) { - InstanceKlass* obj = SystemDictionary::Object_klass(); + InstanceKlass* obj = vmClasses::Object_klass(); Method::register_native(obj, vmSymbols::hashCode_name(), vmSymbols::void_int_signature(), (address) &JVM_IHashCode, CHECK); Method::register_native(obj, vmSymbols::wait_name(), @@ -217,7 +218,7 @@ void java_lang_String::compute_offsets() { return; } - InstanceKlass* k = SystemDictionary::String_klass(); + InstanceKlass* k = vmClasses::String_klass(); STRING_FIELDS_DO(FIELD_COMPUTE_OFFSET); _initialized = true; @@ -240,7 +241,7 @@ class CompactStringsFixup : public FieldClosure { void do_field(fieldDescriptor* fd) { if (fd->name() == vmSymbols::compact_strings_name()) { oop mirror = fd->field_holder()->java_mirror(); - assert(fd->field_holder() == SystemDictionary::String_klass(), "Should be String"); + assert(fd->field_holder() == vmClasses::String_klass(), "Should be String"); assert(mirror != NULL, "String must have mirror already"); mirror->bool_field_put(fd->offset(), _value); } @@ -249,7 +250,7 @@ class CompactStringsFixup : public FieldClosure { void java_lang_String::set_compact_strings(bool value) { CompactStringsFixup fix(value); - SystemDictionary::String_klass()->do_local_static_fields(&fix); + vmClasses::String_klass()->do_local_static_fields(&fix); } Handle java_lang_String::basic_create(int length, bool is_latin1, TRAPS) { @@ -259,7 +260,7 @@ Handle java_lang_String::basic_create(int length, bool is_latin1, TRAPS) { // Create the String object first, so there's a chance that the String // and the char array it points to end up in the same cache line. oop obj; - obj = SystemDictionary::String_klass()->allocate_instance(CHECK_NH); + obj = vmClasses::String_klass()->allocate_instance(CHECK_NH); // Create the char array. The String object must be handlized here // because GC can happen as a result of the allocation attempt. @@ -739,7 +740,7 @@ char* java_lang_String::as_utf8_string(oop java_string, typeArrayOop value, int } bool java_lang_String::equals(oop java_string, const jchar* chars, int len) { - assert(java_string->klass() == SystemDictionary::String_klass(), + assert(java_string->klass() == vmClasses::String_klass(), "must be java_string"); typeArrayOop value = java_lang_String::value_no_keepalive(java_string); int length = java_lang_String::length(java_string, value); @@ -764,9 +765,9 @@ bool java_lang_String::equals(oop java_string, const jchar* chars, int len) { } bool java_lang_String::equals(oop str1, oop str2) { - assert(str1->klass() == SystemDictionary::String_klass(), + assert(str1->klass() == vmClasses::String_klass(), "must be java String"); - assert(str2->klass() == SystemDictionary::String_klass(), + assert(str2->klass() == vmClasses::String_klass(), "must be java String"); typeArrayOop value1 = java_lang_String::value_no_keepalive(str1); bool is_latin1 = java_lang_String::is_latin1(str1); @@ -781,7 +782,7 @@ bool java_lang_String::equals(oop str1, oop str2) { } void java_lang_String::print(oop java_string, outputStream* st) { - assert(java_string->klass() == SystemDictionary::String_klass(), "must be java_string"); + assert(java_string->klass() == vmClasses::String_klass(), "must be java_string"); typeArrayOop value = java_lang_String::value_no_keepalive(java_string); if (value == NULL) { @@ -991,9 +992,9 @@ void java_lang_Class::create_mirror(Klass* k, Handle class_loader, k->set_modifier_flags(computed_modifiers); // Class_klass has to be loaded because it is used to allocate // the mirror. - if (SystemDictionary::Class_klass_loaded()) { + if (vmClasses::Class_klass_loaded()) { // Allocate mirror (java.lang.Class instance) - oop mirror_oop = InstanceMirrorKlass::cast(SystemDictionary::Class_klass())->allocate_instance(k, CHECK); + oop mirror_oop = InstanceMirrorKlass::cast(vmClasses::Class_klass())->allocate_instance(k, CHECK); Handle mirror(THREAD, mirror_oop); Handle comp_mirror; @@ -1312,7 +1313,7 @@ bool java_lang_Class::restore_archived_mirror(Klass *k, Handle protection_domain, TRAPS) { // Postpone restoring archived mirror until java.lang.Class is loaded. Please // see more details in vmClasses::resolve_all(). - if (!SystemDictionary::Class_klass_loaded()) { + if (!vmClasses::Class_klass_loaded()) { assert(fixup_mirror_list() != NULL, "fixup_mirror_list not initialized"); fixup_mirror_list()->push(k); return true; @@ -1483,14 +1484,14 @@ void java_lang_Class::set_source_file(oop java_class, oop source_file) { oop java_lang_Class::create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS) { // This should be improved by adding a field at the Java level or by // introducing a new VM klass (see comment in ClassFileParser) - oop java_class = InstanceMirrorKlass::cast(SystemDictionary::Class_klass())->allocate_instance(NULL, CHECK_NULL); + oop java_class = InstanceMirrorKlass::cast(vmClasses::Class_klass())->allocate_instance(NULL, CHECK_NULL); if (type != T_VOID) { Klass* aklass = Universe::typeArrayKlassObj(type); assert(aklass != NULL, "correct bootstrap"); release_set_array_klass(java_class, aklass); } #ifdef ASSERT - InstanceMirrorKlass* mk = InstanceMirrorKlass::cast(SystemDictionary::Class_klass()); + InstanceMirrorKlass* mk = InstanceMirrorKlass::cast(vmClasses::Class_klass()); assert(java_lang_Class::static_oop_field_count(java_class) == 0, "should have been zeroed by allocation"); #endif return java_class; @@ -1620,7 +1621,7 @@ BasicType java_lang_Class::as_BasicType(oop java_class, Klass** reference_klass) oop java_lang_Class::primitive_mirror(BasicType t) { oop mirror = Universe::java_mirror(t); - assert(mirror != NULL && mirror->is_a(SystemDictionary::Class_klass()), "must be a Class"); + assert(mirror != NULL && mirror->is_a(vmClasses::Class_klass()), "must be a Class"); assert(java_lang_Class::is_primitive(mirror), "must be primitive"); return mirror; } @@ -1640,7 +1641,7 @@ void java_lang_Class::compute_offsets() { _offsets_computed = true; - InstanceKlass* k = SystemDictionary::Class_klass(); + InstanceKlass* k = vmClasses::Class_klass(); CLASS_FIELDS_DO(FIELD_COMPUTE_OFFSET); // Init lock is a C union with component_mirror. Only instanceKlass mirrors have @@ -1713,7 +1714,7 @@ int java_lang_Thread::_park_blocker_offset; void java_lang_Thread::compute_offsets() { assert(_group_offset == 0, "offsets should be initialized only once"); - InstanceKlass* k = SystemDictionary::Thread_klass(); + InstanceKlass* k = vmClasses::Thread_klass(); THREAD_FIELDS_DO(FIELD_COMPUTE_OFFSET); } @@ -1933,7 +1934,7 @@ bool java_lang_ThreadGroup::is_daemon(oop java_thread_group) { void java_lang_ThreadGroup::compute_offsets() { assert(_parent_offset == 0, "offsets should be initialized only once"); - InstanceKlass* k = SystemDictionary::ThreadGroup_klass(); + InstanceKlass* k = vmClasses::ThreadGroup_klass(); THREADGROUP_FIELDS_DO(FIELD_COMPUTE_OFFSET); } @@ -1959,7 +1960,7 @@ int java_lang_Throwable::_static_unassigned_stacktrace_offset; macro(_static_unassigned_stacktrace_offset, k, "UNASSIGNED_STACK", java_lang_StackTraceElement_array, true) void java_lang_Throwable::compute_offsets() { - InstanceKlass* k = SystemDictionary::Throwable_klass(); + InstanceKlass* k = vmClasses::Throwable_klass(); THROWABLE_FIELDS_DO(FIELD_COMPUTE_OFFSET); } @@ -1970,7 +1971,7 @@ void java_lang_Throwable::serialize_offsets(SerializeClosure* f) { #endif oop java_lang_Throwable::unassigned_stacktrace() { - InstanceKlass* ik = SystemDictionary::Throwable_klass(); + InstanceKlass* ik = vmClasses::Throwable_klass(); oop base = ik->static_field_base_raw(); return base->obj_field(_static_unassigned_stacktrace_offset); } @@ -2396,11 +2397,11 @@ void java_lang_Throwable::print_stack_trace(Handle throwable, outputStream* st) * Print the throwable stack trace by calling the Java method java.lang.Throwable.printStackTrace(). */ void java_lang_Throwable::java_printStackTrace(Handle throwable, TRAPS) { - assert(throwable->is_a(SystemDictionary::Throwable_klass()), "Throwable instance expected"); + assert(throwable->is_a(vmClasses::Throwable_klass()), "Throwable instance expected"); JavaValue result(T_VOID); JavaCalls::call_virtual(&result, throwable, - SystemDictionary::Throwable_klass(), + vmClasses::Throwable_klass(), vmSymbols::printStackTrace_name(), vmSymbols::void_method_signature(), THREAD); @@ -2579,7 +2580,7 @@ void java_lang_Throwable::fill_in_stack_trace_of_preallocated_backtrace(Handle t // No-op if stack trace is disabled if (!StackTraceInThrowable) return; - assert(throwable->is_a(SystemDictionary::Throwable_klass()), "sanity check"); + assert(throwable->is_a(vmClasses::Throwable_klass()), "sanity check"); JavaThread* THREAD = JavaThread::current(); @@ -2681,7 +2682,7 @@ bool java_lang_Throwable::get_top_method_and_bci(oop throwable, Method** method, oop java_lang_StackTraceElement::create(const methodHandle& method, int bci, TRAPS) { // Allocate java.lang.StackTraceElement instance - InstanceKlass* k = SystemDictionary::StackTraceElement_klass(); + InstanceKlass* k = vmClasses::StackTraceElement_klass(); assert(k != NULL, "must be loaded in 1.4+"); if (k->should_be_initialized()) { k->initialize(CHECK_NULL); @@ -2697,7 +2698,7 @@ oop java_lang_StackTraceElement::create(const methodHandle& method, int bci, TRA void java_lang_StackTraceElement::fill_in(Handle element, InstanceKlass* holder, const methodHandle& method, int version, int bci, Symbol* name, TRAPS) { - assert(element->is_a(SystemDictionary::StackTraceElement_klass()), "sanity check"); + assert(element->is_a(vmClasses::StackTraceElement_klass()), "sanity check"); ResourceMark rm(THREAD); HandleMark hm(THREAD); @@ -2804,7 +2805,7 @@ int java_lang_StackFrameInfo::_version_offset; macro(_bci_offset, k, "bci", int_signature, false) void java_lang_StackFrameInfo::compute_offsets() { - InstanceKlass* k = SystemDictionary::StackFrameInfo_klass(); + InstanceKlass* k = vmClasses::StackFrameInfo_klass(); STACKFRAMEINFO_FIELDS_DO(FIELD_COMPUTE_OFFSET); STACKFRAMEINFO_INJECTED_FIELDS(INJECTED_FIELD_COMPUTE_OFFSET); } @@ -2876,7 +2877,7 @@ int java_lang_LiveStackFrameInfo::_mode_offset; macro(_mode_offset, k, "mode", int_signature, false) void java_lang_LiveStackFrameInfo::compute_offsets() { - InstanceKlass* k = SystemDictionary::LiveStackFrameInfo_klass(); + InstanceKlass* k = vmClasses::LiveStackFrameInfo_klass(); LIVESTACKFRAMEINFO_FIELDS_DO(FIELD_COMPUTE_OFFSET); } @@ -2911,7 +2912,7 @@ int java_lang_reflect_AccessibleObject::_override_offset; macro(_override_offset, k, "override", bool_signature, false) void java_lang_reflect_AccessibleObject::compute_offsets() { - InstanceKlass* k = SystemDictionary::reflect_AccessibleObject_klass(); + InstanceKlass* k = vmClasses::reflect_AccessibleObject_klass(); ACCESSIBLEOBJECT_FIELDS_DO(FIELD_COMPUTE_OFFSET); } @@ -2957,7 +2958,7 @@ int java_lang_reflect_Method::_annotation_default_offset; macro(_annotation_default_offset, k, vmSymbols::annotation_default_name(), byte_array_signature, false); void java_lang_reflect_Method::compute_offsets() { - InstanceKlass* k = SystemDictionary::reflect_Method_klass(); + InstanceKlass* k = vmClasses::reflect_Method_klass(); METHOD_FIELDS_DO(FIELD_COMPUTE_OFFSET); } @@ -2969,7 +2970,7 @@ void java_lang_reflect_Method::serialize_offsets(SerializeClosure* f) { Handle java_lang_reflect_Method::create(TRAPS) { assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); - Klass* klass = SystemDictionary::reflect_Method_klass(); + Klass* klass = vmClasses::reflect_Method_klass(); // This class is eagerly initialized during VM initialization, since we keep a refence // to one of the methods assert(InstanceKlass::cast(klass)->is_initialized(), "must be initialized"); @@ -3056,7 +3057,7 @@ int java_lang_reflect_Constructor::_parameter_annotations_offset; macro(_parameter_annotations_offset, k, vmSymbols::parameter_annotations_name(), byte_array_signature, false); void java_lang_reflect_Constructor::compute_offsets() { - InstanceKlass* k = SystemDictionary::reflect_Constructor_klass(); + InstanceKlass* k = vmClasses::reflect_Constructor_klass(); CONSTRUCTOR_FIELDS_DO(FIELD_COMPUTE_OFFSET); } @@ -3140,7 +3141,7 @@ int java_lang_reflect_Field::_annotations_offset; macro(_annotations_offset, k, vmSymbols::annotations_name(), byte_array_signature, false); void java_lang_reflect_Field::compute_offsets() { - InstanceKlass* k = SystemDictionary::reflect_Field_klass(); + InstanceKlass* k = vmClasses::reflect_Field_klass(); FIELD_FIELDS_DO(FIELD_COMPUTE_OFFSET); } @@ -3215,7 +3216,7 @@ void java_lang_reflect_Field::set_annotations(oop field, oop value) { oop java_lang_reflect_RecordComponent::create(InstanceKlass* holder, RecordComponent* component, TRAPS) { // Allocate java.lang.reflect.RecordComponent instance HandleMark hm(THREAD); - InstanceKlass* ik = SystemDictionary::RecordComponent_klass(); + InstanceKlass* ik = vmClasses::RecordComponent_klass(); assert(ik != NULL, "must be loaded"); ik->initialize(CHECK_NULL); @@ -3276,7 +3277,7 @@ int reflect_ConstantPool::_oop_offset; macro(_oop_offset, k, "constantPoolOop", object_signature, false) void reflect_ConstantPool::compute_offsets() { - InstanceKlass* k = SystemDictionary::reflect_ConstantPool_klass(); + InstanceKlass* k = vmClasses::reflect_ConstantPool_klass(); // The field is called ConstantPool* in the sun.reflect.ConstantPool class. CONSTANTPOOL_FIELDS_DO(FIELD_COMPUTE_OFFSET); } @@ -3299,7 +3300,7 @@ int java_lang_reflect_Parameter::_executable_offset; macro(_executable_offset, k, vmSymbols::executable_name(), executable_signature, false) void java_lang_reflect_Parameter::compute_offsets() { - InstanceKlass* k = SystemDictionary::reflect_Parameter_klass(); + InstanceKlass* k = vmClasses::reflect_Parameter_klass(); PARAMETER_FIELDS_DO(FIELD_COMPUTE_OFFSET); } @@ -3359,7 +3360,7 @@ int java_lang_Module::_module_entry_offset; Handle java_lang_Module::create(Handle loader, Handle module_name, TRAPS) { assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); - return JavaCalls::construct_new_instance(SystemDictionary::Module_klass(), + return JavaCalls::construct_new_instance(vmClasses::Module_klass(), vmSymbols::java_lang_module_init_signature(), loader, module_name, CHECK_NH); } @@ -3369,7 +3370,7 @@ Handle java_lang_Module::create(Handle loader, Handle module_name, TRAPS) { macro(_name_offset, k, vmSymbols::name_name(), string_signature, false) void java_lang_Module::compute_offsets() { - InstanceKlass* k = SystemDictionary::Module_klass(); + InstanceKlass* k = vmClasses::Module_klass(); MODULE_FIELDS_DO(FIELD_COMPUTE_OFFSET); MODULE_INJECTED_FIELDS(INJECTED_FIELD_COMPUTE_OFFSET); } @@ -3428,7 +3429,7 @@ void java_lang_Module::set_module_entry(oop module, ModuleEntry* module_entry) { Handle reflect_ConstantPool::create(TRAPS) { assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); - InstanceKlass* k = SystemDictionary::reflect_ConstantPool_klass(); + InstanceKlass* k = vmClasses::reflect_ConstantPool_klass(); // Ensure it is initialized k->initialize(CHECK_NH); return k->allocate_instance_handle(THREAD); @@ -3461,7 +3462,7 @@ int reflect_UnsafeStaticFieldAccessorImpl::_base_offset; macro(_base_offset, k, "base", object_signature, false) void reflect_UnsafeStaticFieldAccessorImpl::compute_offsets() { - InstanceKlass* k = SystemDictionary::reflect_UnsafeStaticFieldAccessorImpl_klass(); + InstanceKlass* k = vmClasses::reflect_UnsafeStaticFieldAccessorImpl_klass(); UNSAFESTATICFIELDACCESSORIMPL_FIELDS_DO(FIELD_COMPUTE_OFFSET); } @@ -3491,7 +3492,7 @@ void java_lang_ref_Reference::compute_offsets() { return; } _offsets_initialized = true; - InstanceKlass* k = SystemDictionary::Reference_klass(); + InstanceKlass* k = vmClasses::Reference_klass(); REFERENCE_FIELDS_DO(FIELD_COMPUTE_OFFSET); } @@ -3515,7 +3516,7 @@ bool java_lang_ref_Reference::is_referent_field(oop obj, ptrdiff_t offset) { InstanceKlass* ik = InstanceKlass::cast(obj->klass()); bool is_reference = ik->reference_type() != REF_NONE; - assert(!is_reference || ik->is_subclass_of(SystemDictionary::Reference_klass()), "sanity"); + assert(!is_reference || ik->is_subclass_of(vmClasses::Reference_klass()), "sanity"); return is_reference; } @@ -3527,8 +3528,8 @@ int java_lang_boxing_object::_long_value_offset; macro(_long_value_offset, longKlass, "value", long_signature, false); void java_lang_boxing_object::compute_offsets() { - InstanceKlass* integerKlass = SystemDictionary::Integer_klass(); - InstanceKlass* longKlass = SystemDictionary::Long_klass(); + InstanceKlass* integerKlass = vmClasses::Integer_klass(); + InstanceKlass* longKlass = vmClasses::Long_klass(); BOXING_FIELDS_DO(FIELD_COMPUTE_OFFSET); } @@ -3539,7 +3540,7 @@ void java_lang_boxing_object::serialize_offsets(SerializeClosure* f) { #endif oop java_lang_boxing_object::initialize_and_allocate(BasicType type, TRAPS) { - Klass* k = SystemDictionary::box_klass(type); + Klass* k = vmClasses::box_klass(type); if (k == NULL) return NULL; InstanceKlass* ik = InstanceKlass::cast(k); if (!ik->is_initialized()) ik->initialize(CHECK_NULL); @@ -3584,7 +3585,7 @@ oop java_lang_boxing_object::create(BasicType type, jvalue* value, TRAPS) { BasicType java_lang_boxing_object::basic_type(oop box) { if (box == NULL) return T_ILLEGAL; - BasicType type = SystemDictionary::box_klass_type(box->klass()); + BasicType type = vmClasses::box_klass_type(box->klass()); if (type == T_OBJECT) // 'unknown' value returned by SD::bkt return T_ILLEGAL; return type; @@ -3592,7 +3593,7 @@ BasicType java_lang_boxing_object::basic_type(oop box) { BasicType java_lang_boxing_object::get_value(oop box, jvalue* value) { - BasicType type = SystemDictionary::box_klass_type(box->klass()); + BasicType type = vmClasses::box_klass_type(box->klass()); switch (type) { case T_BOOLEAN: value->z = box->bool_field(_value_offset); @@ -3626,7 +3627,7 @@ BasicType java_lang_boxing_object::get_value(oop box, jvalue* value) { BasicType java_lang_boxing_object::set_value(oop box, jvalue* value) { - BasicType type = SystemDictionary::box_klass_type(box->klass()); + BasicType type = vmClasses::box_klass_type(box->klass()); switch (type) { case T_BOOLEAN: box->bool_field_put(_value_offset, value->z); @@ -3685,7 +3686,7 @@ int java_lang_ref_SoftReference::_static_clock_offset; macro(_static_clock_offset, k, "clock", long_signature, true) void java_lang_ref_SoftReference::compute_offsets() { - InstanceKlass* k = SystemDictionary::SoftReference_klass(); + InstanceKlass* k = vmClasses::SoftReference_klass(); SOFTREFERENCE_FIELDS_DO(FIELD_COMPUTE_OFFSET); } @@ -3700,13 +3701,13 @@ jlong java_lang_ref_SoftReference::timestamp(oop ref) { } jlong java_lang_ref_SoftReference::clock() { - InstanceKlass* ik = SystemDictionary::SoftReference_klass(); + InstanceKlass* ik = vmClasses::SoftReference_klass(); oop base = ik->static_field_base_raw(); return base->long_field(_static_clock_offset); } void java_lang_ref_SoftReference::set_clock(jlong value) { - InstanceKlass* ik = SystemDictionary::SoftReference_klass(); + InstanceKlass* ik = vmClasses::SoftReference_klass(); oop base = ik->static_field_base_raw(); base->long_field_put(_static_clock_offset, value); } @@ -3726,7 +3727,7 @@ oop java_lang_invoke_DirectMethodHandle::member(oop dmh) { macro(_member_offset, k, "member", java_lang_invoke_MemberName_signature, false) void java_lang_invoke_DirectMethodHandle::compute_offsets() { - InstanceKlass* k = SystemDictionary::DirectMethodHandle_klass(); + InstanceKlass* k = vmClasses::DirectMethodHandle_klass(); DIRECTMETHODHANDLE_FIELDS_DO(FIELD_COMPUTE_OFFSET); } @@ -3758,7 +3759,7 @@ int java_lang_invoke_LambdaForm::_vmentry_offset; macro(_form_offset, k, "form", java_lang_invoke_LambdaForm_signature, false) void java_lang_invoke_MethodHandle::compute_offsets() { - InstanceKlass* k = SystemDictionary::MethodHandle_klass(); + InstanceKlass* k = vmClasses::MethodHandle_klass(); METHODHANDLE_FIELDS_DO(FIELD_COMPUTE_OFFSET); } @@ -3776,7 +3777,7 @@ void java_lang_invoke_MethodHandle::serialize_offsets(SerializeClosure* f) { macro(_method_offset, k, vmSymbols::method_name(), java_lang_invoke_ResolvedMethodName_signature, false) void java_lang_invoke_MemberName::compute_offsets() { - InstanceKlass* k = SystemDictionary::MemberName_klass(); + InstanceKlass* k = vmClasses::MemberName_klass(); MEMBERNAME_FIELDS_DO(FIELD_COMPUTE_OFFSET); MEMBERNAME_INJECTED_FIELDS(INJECTED_FIELD_COMPUTE_OFFSET); } @@ -3789,7 +3790,7 @@ void java_lang_invoke_MemberName::serialize_offsets(SerializeClosure* f) { #endif void java_lang_invoke_ResolvedMethodName::compute_offsets() { - InstanceKlass* k = SystemDictionary::ResolvedMethodName_klass(); + InstanceKlass* k = vmClasses::ResolvedMethodName_klass(); assert(k != NULL, "jdk mismatch"); RESOLVEDMETHOD_INJECTED_FIELDS(INJECTED_FIELD_COMPUTE_OFFSET); } @@ -3804,7 +3805,7 @@ void java_lang_invoke_ResolvedMethodName::serialize_offsets(SerializeClosure* f) macro(_vmentry_offset, k, "vmentry", java_lang_invoke_MemberName_signature, false) void java_lang_invoke_LambdaForm::compute_offsets() { - InstanceKlass* k = SystemDictionary::LambdaForm_klass(); + InstanceKlass* k = vmClasses::LambdaForm_klass(); assert (k != NULL, "jdk mismatch"); LAMBDAFORM_FIELDS_DO(FIELD_COMPUTE_OFFSET); } @@ -3841,7 +3842,7 @@ bool jdk_internal_invoke_NativeEntryPoint::is_instance(oop obj) { } void jdk_internal_invoke_NativeEntryPoint::compute_offsets() { - InstanceKlass* k = SystemDictionary::NativeEntryPoint_klass(); + InstanceKlass* k = vmClasses::NativeEntryPoint_klass(); NEP_FIELDS_DO(FIELD_COMPUTE_OFFSET); } @@ -3995,7 +3996,7 @@ oop java_lang_invoke_ResolvedMethodName::find_resolved_method(const methodHandle return resolved_method; } - InstanceKlass* k = SystemDictionary::ResolvedMethodName_klass(); + InstanceKlass* k = vmClasses::ResolvedMethodName_klass(); if (!k->is_initialized()) { k->initialize(CHECK_NULL); } @@ -4041,7 +4042,7 @@ int java_lang_invoke_MethodType::_ptypes_offset; macro(_ptypes_offset, k, "ptypes", class_array_signature, false) void java_lang_invoke_MethodType::compute_offsets() { - InstanceKlass* k = SystemDictionary::MethodType_klass(); + InstanceKlass* k = vmClasses::MethodType_klass(); METHODTYPE_FIELDS_DO(FIELD_COMPUTE_OFFSET); } @@ -4135,7 +4136,7 @@ int java_lang_invoke_CallSite::_context_offset; macro(_context_offset, k, "context", java_lang_invoke_MethodHandleNatives_CallSiteContext_signature, false) void java_lang_invoke_CallSite::compute_offsets() { - InstanceKlass* k = SystemDictionary::CallSite_klass(); + InstanceKlass* k = vmClasses::CallSite_klass(); CALLSITE_FIELDS_DO(FIELD_COMPUTE_OFFSET); } @@ -4160,7 +4161,7 @@ int java_lang_invoke_ConstantCallSite::_is_frozen_offset; macro(_is_frozen_offset, k, "isFrozen", bool_signature, false) void java_lang_invoke_ConstantCallSite::compute_offsets() { - InstanceKlass* k = SystemDictionary::ConstantCallSite_klass(); + InstanceKlass* k = vmClasses::ConstantCallSite_klass(); CONSTANTCALLSITE_FIELDS_DO(FIELD_COMPUTE_OFFSET); } @@ -4176,7 +4177,7 @@ int java_lang_invoke_MethodHandleNatives_CallSiteContext::_vmdependencies_offset int java_lang_invoke_MethodHandleNatives_CallSiteContext::_last_cleanup_offset; void java_lang_invoke_MethodHandleNatives_CallSiteContext::compute_offsets() { - InstanceKlass* k = SystemDictionary::Context_klass(); + InstanceKlass* k = vmClasses::Context_klass(); CALLSITECONTEXT_INJECTED_FIELDS(INJECTED_FIELD_COMPUTE_OFFSET); } @@ -4209,7 +4210,7 @@ int java_security_AccessControlContext::_isAuthorized_offset; void java_security_AccessControlContext::compute_offsets() { assert(_isPrivileged_offset == 0, "offsets should be initialized only once"); - InstanceKlass* k = SystemDictionary::AccessControlContext_klass(); + InstanceKlass* k = vmClasses::AccessControlContext_klass(); ACCESSCONTROLCONTEXT_FIELDS_DO(FIELD_COMPUTE_OFFSET); } @@ -4223,9 +4224,9 @@ oop java_security_AccessControlContext::create(objArrayHandle context, bool isPr assert(_isPrivileged_offset != 0, "offsets should have been initialized"); assert(_isAuthorized_offset != 0, "offsets should have been initialized"); // Ensure klass is initialized - SystemDictionary::AccessControlContext_klass()->initialize(CHECK_NULL); + vmClasses::AccessControlContext_klass()->initialize(CHECK_NULL); // Allocate result - oop result = SystemDictionary::AccessControlContext_klass()->allocate_instance(CHECK_NULL); + oop result = vmClasses::AccessControlContext_klass()->allocate_instance(CHECK_NULL); // Fill in values result->obj_field_put(_context_offset, context()); result->obj_field_put(_privilegedContext_offset, privileged_context()); @@ -4270,7 +4271,7 @@ void java_lang_ClassLoader::release_set_loader_data(oop loader, ClassLoaderData* macro(_parent_offset, k1, "parent", classloader_signature, false) void java_lang_ClassLoader::compute_offsets() { - InstanceKlass* k1 = SystemDictionary::ClassLoader_klass(); + InstanceKlass* k1 = vmClasses::ClassLoader_klass(); CLASSLOADER_FIELDS_DO(FIELD_COMPUTE_OFFSET); CLASSLOADER_INJECTED_FIELDS(INJECTED_FIELD_COMPUTE_OFFSET); @@ -4351,7 +4352,7 @@ bool java_lang_ClassLoader::is_trusted_loader(oop loader) { // the generated bytecodes for reflection. bool java_lang_ClassLoader::is_reflection_class_loader(oop loader) { if (loader != NULL) { - Klass* delegating_cl_class = SystemDictionary::reflect_DelegatingClassLoader_klass(); + Klass* delegating_cl_class = vmClasses::reflect_DelegatingClassLoader_klass(); // This might be null in non-1.4 JDKs return (delegating_cl_class != NULL && loader->is_a(delegating_cl_class)); } @@ -4389,7 +4390,7 @@ int java_lang_System::_static_security_offset; macro(_static_security_offset, k, "security", security_manager_signature, true) void java_lang_System::compute_offsets() { - InstanceKlass* k = SystemDictionary::System_klass(); + InstanceKlass* k = vmClasses::System_klass(); SYSTEM_FIELDS_DO(FIELD_COMPUTE_OFFSET); } @@ -4421,7 +4422,7 @@ class UnsafeConstantsFixup : public FieldClosure { void do_field(fieldDescriptor* fd) { oop mirror = fd->field_holder()->java_mirror(); assert(mirror != NULL, "UnsafeConstants must have mirror already"); - assert(fd->field_holder() == SystemDictionary::UnsafeConstants_klass(), "Should be UnsafeConstants"); + assert(fd->field_holder() == vmClasses::UnsafeConstants_klass(), "Should be UnsafeConstants"); assert(fd->is_final(), "fields of UnsafeConstants must be final"); assert(fd->is_static(), "fields of UnsafeConstants must be static"); if (fd->name() == vmSymbols::address_size_name()) { @@ -4442,7 +4443,7 @@ class UnsafeConstantsFixup : public FieldClosure { void jdk_internal_misc_UnsafeConstants::set_unsafe_constants() { UnsafeConstantsFixup fixup; - SystemDictionary::UnsafeConstants_klass()->do_local_static_fields(&fixup); + vmClasses::UnsafeConstants_klass()->do_local_static_fields(&fixup); } @@ -4469,7 +4470,7 @@ int java_lang_StackTraceElement::_declaringClassObject_offset; // Support for java_lang_StackTraceElement void java_lang_StackTraceElement::compute_offsets() { - InstanceKlass* k = SystemDictionary::StackTraceElement_klass(); + InstanceKlass* k = vmClasses::StackTraceElement_klass(); STACKTRACEELEMENT_FIELDS_DO(FIELD_COMPUTE_OFFSET); } @@ -4529,7 +4530,7 @@ int java_lang_AssertionStatusDirectives::_deflt_offset; macro(_deflt_offset, k, "deflt", bool_signature, false) void java_lang_AssertionStatusDirectives::compute_offsets() { - InstanceKlass* k = SystemDictionary::AssertionStatusDirectives_klass(); + InstanceKlass* k = vmClasses::AssertionStatusDirectives_klass(); ASSERTIONSTATUSDIRECTIVES_FIELDS_DO(FIELD_COMPUTE_OFFSET); } @@ -4568,7 +4569,7 @@ int java_nio_Buffer::_limit_offset; macro(_limit_offset, k, "limit", int_signature, false) void java_nio_Buffer::compute_offsets() { - InstanceKlass* k = SystemDictionary::nio_Buffer_klass(); + InstanceKlass* k = vmClasses::nio_Buffer_klass(); assert(k != NULL, "must be loaded in 1.4+"); BUFFER_FIELDS_DO(FIELD_COMPUTE_OFFSET); } @@ -4585,7 +4586,7 @@ int java_util_concurrent_locks_AbstractOwnableSynchronizer::_owner_offset; macro(_owner_offset, k, "exclusiveOwnerThread", thread_signature, false) void java_util_concurrent_locks_AbstractOwnableSynchronizer::compute_offsets() { - InstanceKlass* k = SystemDictionary::java_util_concurrent_locks_AbstractOwnableSynchronizer_klass(); + InstanceKlass* k = vmClasses::java_util_concurrent_locks_AbstractOwnableSynchronizer_klass(); AOS_FIELDS_DO(FIELD_COMPUTE_OFFSET); } @@ -4606,7 +4607,7 @@ int vector_VectorPayload::_payload_offset; macro(_payload_offset, k, "payload", object_signature, false) void vector_VectorPayload::compute_offsets() { - InstanceKlass* k = SystemDictionary::vector_VectorPayload_klass(); + InstanceKlass* k = vmClasses::vector_VectorPayload_klass(); VECTORPAYLOAD_FIELDS_DO(FIELD_COMPUTE_OFFSET); } @@ -4841,7 +4842,7 @@ int java_lang_reflect_RecordComponent::_typeAnnotations_offset; // Support for java_lang_reflect_RecordComponent void java_lang_reflect_RecordComponent::compute_offsets() { - InstanceKlass* k = SystemDictionary::RecordComponent_klass(); + InstanceKlass* k = vmClasses::RecordComponent_klass(); RECORDCOMPONENT_FIELDS_DO(FIELD_COMPUTE_OFFSET); } @@ -4933,7 +4934,7 @@ void JavaClasses::serialize_offsets(SerializeClosure* soc) { bool JavaClasses::is_supported_for_archiving(oop obj) { Klass* klass = obj->klass(); - if (klass == SystemDictionary::ClassLoader_klass() || // ClassLoader::loader_data is malloc'ed. + if (klass == vmClasses::ClassLoader_klass() || // ClassLoader::loader_data is malloc'ed. // The next 3 classes are used to implement java.lang.invoke, and are not used directly in // regular Java code. The implementation of java.lang.invoke uses generated anonymous classes // (e.g., as referenced by ResolvedMethodName::vmholder) that are not yet supported by CDS. @@ -4941,9 +4942,9 @@ bool JavaClasses::is_supported_for_archiving(oop obj) { // // These objects typically are not referenced by static fields, but rather by resolved // constant pool entries, so excluding them shouldn't affect the archiving of static fields. - klass == SystemDictionary::ResolvedMethodName_klass() || - klass == SystemDictionary::MemberName_klass() || - klass == SystemDictionary::Context_klass()) { + klass == vmClasses::ResolvedMethodName_klass() || + klass == vmClasses::MemberName_klass() || + klass == vmClasses::Context_klass()) { return false; } diff --git a/src/hotspot/share/classfile/javaClasses.hpp b/src/hotspot/share/classfile/javaClasses.hpp index 29793575d96cb..d58a1420636d9 100644 --- a/src/hotspot/share/classfile/javaClasses.hpp +++ b/src/hotspot/share/classfile/javaClasses.hpp @@ -25,7 +25,6 @@ #ifndef SHARE_CLASSFILE_JAVACLASSES_HPP #define SHARE_CLASSFILE_JAVACLASSES_HPP -#include "classfile/systemDictionary.hpp" #include "classfile/vmClasses.hpp" #include "oops/oop.hpp" #include "oops/instanceKlass.hpp" @@ -946,7 +945,7 @@ class java_lang_invoke_MethodHandle: AllStatic { // Testers static bool is_subclass(Klass* klass) { - return klass->is_subclass_of(SystemDictionary::MethodHandle_klass()); + return klass->is_subclass_of(vmClasses::MethodHandle_klass()); } static bool is_instance(oop obj); @@ -973,7 +972,7 @@ class java_lang_invoke_DirectMethodHandle: AllStatic { // Testers static bool is_subclass(Klass* klass) { - return klass->is_subclass_of(SystemDictionary::DirectMethodHandle_klass()); + return klass->is_subclass_of(vmClasses::DirectMethodHandle_klass()); } static bool is_instance(oop obj); @@ -1001,8 +1000,8 @@ class java_lang_invoke_LambdaForm: AllStatic { // Testers static bool is_subclass(Klass* klass) { - return SystemDictionary::LambdaForm_klass() != NULL && - klass->is_subclass_of(SystemDictionary::LambdaForm_klass()); + return vmClasses::LambdaForm_klass() != NULL && + klass->is_subclass_of(vmClasses::LambdaForm_klass()); } static bool is_instance(oop obj); @@ -1041,8 +1040,8 @@ class jdk_internal_invoke_NativeEntryPoint: AllStatic { // Testers static bool is_subclass(Klass* klass) { - return SystemDictionary::NativeEntryPoint_klass() != NULL && - klass->is_subclass_of(SystemDictionary::NativeEntryPoint_klass()); + return vmClasses::NativeEntryPoint_klass() != NULL && + klass->is_subclass_of(vmClasses::NativeEntryPoint_klass()); } static bool is_instance(oop obj); @@ -1135,7 +1134,7 @@ class java_lang_invoke_MemberName: AllStatic { // Testers static bool is_subclass(Klass* klass) { - return klass->is_subclass_of(SystemDictionary::MemberName_klass()); + return klass->is_subclass_of(vmClasses::MemberName_klass()); } static bool is_instance(oop obj); @@ -1231,7 +1230,7 @@ class java_lang_invoke_CallSite: AllStatic { // Testers static bool is_subclass(Klass* klass) { - return klass->is_subclass_of(SystemDictionary::CallSite_klass()); + return klass->is_subclass_of(vmClasses::CallSite_klass()); } static bool is_instance(oop obj); @@ -1257,7 +1256,7 @@ class java_lang_invoke_ConstantCallSite: AllStatic { // Testers static bool is_subclass(Klass* klass) { - return klass->is_subclass_of(SystemDictionary::ConstantCallSite_klass()); + return klass->is_subclass_of(vmClasses::ConstantCallSite_klass()); } static bool is_instance(oop obj); }; @@ -1286,7 +1285,7 @@ class java_lang_invoke_MethodHandleNatives_CallSiteContext : AllStatic { // Testers static bool is_subclass(Klass* klass) { - return klass->is_subclass_of(SystemDictionary::Context_klass()); + return klass->is_subclass_of(vmClasses::Context_klass()); } static bool is_instance(oop obj); }; @@ -1354,7 +1353,7 @@ class java_lang_ClassLoader : AllStatic { // Testers static bool is_subclass(Klass* klass) { - return klass->is_subclass_of(SystemDictionary::ClassLoader_klass()); + return klass->is_subclass_of(vmClasses::ClassLoader_klass()); } static bool is_instance(oop obj); @@ -1598,7 +1597,7 @@ class vector_VectorPayload : AllStatic { // Testers static bool is_subclass(Klass* klass) { - return klass->is_subclass_of(SystemDictionary::vector_VectorPayload_klass()); + return klass->is_subclass_of(vmClasses::vector_VectorPayload_klass()); } static bool is_instance(oop obj); }; @@ -1718,7 +1717,7 @@ class java_lang_InternalError : AllStatic { class InjectedField { public: - const VMClassID klass_id; + const vmClassID klass_id; const vmSymbolID name_index; const vmSymbolID signature_index; const bool may_be_java; diff --git a/src/hotspot/share/classfile/javaClasses.inline.hpp b/src/hotspot/share/classfile/javaClasses.inline.hpp index d4a093a47be53..5cf6c0dc93790 100644 --- a/src/hotspot/share/classfile/javaClasses.inline.hpp +++ b/src/hotspot/share/classfile/javaClasses.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,7 @@ #include "classfile/javaClasses.hpp" #include "oops/access.inline.hpp" +#include "oops/method.hpp" #include "oops/oop.inline.hpp" #include "oops/oopsHierarchy.hpp" @@ -96,7 +97,7 @@ int java_lang_String::length(oop java_string) { } bool java_lang_String::is_instance_inlined(oop obj) { - return obj != NULL && obj->klass() == SystemDictionary::String_klass(); + return obj != NULL && obj->klass() == vmClasses::String_klass(); } // Accessors @@ -190,15 +191,15 @@ inline bool java_lang_invoke_MethodHandleNatives_CallSiteContext::is_instance(oo } inline bool java_lang_invoke_MemberName::is_instance(oop obj) { - return obj != NULL && obj->klass() == SystemDictionary::MemberName_klass(); + return obj != NULL && obj->klass() == vmClasses::MemberName_klass(); } inline bool java_lang_invoke_ResolvedMethodName::is_instance(oop obj) { - return obj != NULL && obj->klass() == SystemDictionary::ResolvedMethodName_klass(); + return obj != NULL && obj->klass() == vmClasses::ResolvedMethodName_klass(); } inline bool java_lang_invoke_MethodType::is_instance(oop obj) { - return obj != NULL && obj->klass() == SystemDictionary::MethodType_klass(); + return obj != NULL && obj->klass() == vmClasses::MethodType_klass(); } inline bool java_lang_invoke_MethodHandle::is_instance(oop obj) { @@ -206,7 +207,7 @@ inline bool java_lang_invoke_MethodHandle::is_instance(oop obj) { } inline bool java_lang_Class::is_instance(oop obj) { - return obj != NULL && obj->klass() == SystemDictionary::Class_klass(); + return obj != NULL && obj->klass() == vmClasses::Class_klass(); } inline Klass* java_lang_Class::as_Klass(oop java_class) { @@ -245,7 +246,7 @@ inline bool java_lang_invoke_DirectMethodHandle::is_instance(oop obj) { } inline bool java_lang_Module::is_instance(oop obj) { - return obj != NULL && obj->klass() == SystemDictionary::Module_klass(); + return obj != NULL && obj->klass() == vmClasses::Module_klass(); } inline int Backtrace::merge_bci_and_version(int bci, int version) { diff --git a/src/hotspot/share/classfile/lambdaFormInvokers.cpp b/src/hotspot/share/classfile/lambdaFormInvokers.cpp index fc2cb62694cc6..7db1062d44a6b 100644 --- a/src/hotspot/share/classfile/lambdaFormInvokers.cpp +++ b/src/hotspot/share/classfile/lambdaFormInvokers.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,6 +32,7 @@ #include "classfile/symbolTable.hpp" #include "classfile/systemDictionary.hpp" #include "classfile/systemDictionaryShared.hpp" +#include "classfile/vmClasses.hpp" #include "classfile/vmSymbols.hpp" #include "logging/log.hpp" #include "memory/oopFactory.hpp" @@ -64,7 +65,7 @@ void LambdaFormInvokers::regenerate_holder_classes(TRAPS) { guarantee(cds_klass != NULL, "jdk/internal/misc/CDS must exist!"); int len = _lambdaform_lines->length(); - objArrayHandle list_lines = oopFactory::new_objArray_handle(SystemDictionary::String_klass(), len, CHECK); + objArrayHandle list_lines = oopFactory::new_objArray_handle(vmClasses::String_klass(), len, CHECK); for (int i = 0; i < len; i++) { Handle h_line = java_lang_String::create_from_str(_lambdaform_lines->at(i), CHECK); list_lines->obj_at_put(i, h_line()); diff --git a/src/hotspot/share/classfile/modules.cpp b/src/hotspot/share/classfile/modules.cpp index 9751d1d68fbac..e4de916b47131 100644 --- a/src/hotspot/share/classfile/modules.cpp +++ b/src/hotspot/share/classfile/modules.cpp @@ -1,5 +1,5 @@ /* -* Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. +* Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,6 +37,7 @@ #include "classfile/stringTable.hpp" #include "classfile/symbolTable.hpp" #include "classfile/systemDictionary.hpp" +#include "classfile/vmClasses.hpp" #include "classfile/vmSymbols.hpp" #include "logging/log.hpp" #include "logging/logStream.hpp" @@ -168,7 +169,7 @@ static void define_javabase_module(Handle module_handle, jstring version, jstrin for (int x = 0; x < num_packages; x++) { oop pkg_str = pkgs->obj_at(x); - if (pkg_str == NULL || pkg_str->klass() != SystemDictionary::String_klass()) { + if (pkg_str == NULL || pkg_str->klass() != vmClasses::String_klass()) { THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), err_msg("Bad package name")); } @@ -325,7 +326,7 @@ void Modules::define_module(jobject module, jboolean is_open, jstring version, GrowableArray* pkg_list = new GrowableArray(num_packages); for (int x = 0; x < num_packages; x++) { oop pkg_str = packages_h->obj_at(x); - if (pkg_str == NULL || pkg_str->klass() != SystemDictionary::String_klass()) { + if (pkg_str == NULL || pkg_str->klass() != vmClasses::String_klass()) { THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), err_msg("Bad package name")); } diff --git a/src/hotspot/share/classfile/protectionDomainCache.cpp b/src/hotspot/share/classfile/protectionDomainCache.cpp index af1fd5614d896..b02ec1a860235 100644 --- a/src/hotspot/share/classfile/protectionDomainCache.cpp +++ b/src/hotspot/share/classfile/protectionDomainCache.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,6 @@ #include "classfile/classLoaderDataGraph.hpp" #include "classfile/dictionary.hpp" #include "classfile/protectionDomainCache.hpp" -#include "classfile/systemDictionary.hpp" #include "logging/log.hpp" #include "logging/logStream.hpp" #include "memory/iterator.hpp" diff --git a/src/hotspot/share/classfile/stringTable.cpp b/src/hotspot/share/classfile/stringTable.cpp index de8335efacd4d..52b357563e601 100644 --- a/src/hotspot/share/classfile/stringTable.cpp +++ b/src/hotspot/share/classfile/stringTable.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,7 +27,7 @@ #include "classfile/compactHashtable.hpp" #include "classfile/javaClasses.inline.hpp" #include "classfile/stringTable.hpp" -#include "classfile/systemDictionary.hpp" +#include "classfile/vmClasses.hpp" #include "gc/shared/collectedHeap.hpp" #include "gc/shared/oopStorage.inline.hpp" #include "gc/shared/oopStorageSet.hpp" @@ -542,7 +542,7 @@ static int literal_size(oop obj) { // array is not shared anymore. if (obj == NULL) { return 0; - } else if (obj->klass() == SystemDictionary::String_klass()) { + } else if (obj->klass() == vmClasses::String_klass()) { return (obj->size() + java_lang_String::value(obj)->size()) * HeapWordSize; } else { return obj->size(); diff --git a/src/hotspot/share/classfile/systemDictionary.cpp b/src/hotspot/share/classfile/systemDictionary.cpp index 5360a82990c58..c6c7d31fa747b 100644 --- a/src/hotspot/share/classfile/systemDictionary.cpp +++ b/src/hotspot/share/classfile/systemDictionary.cpp @@ -120,7 +120,7 @@ oop SystemDictionary::java_platform_loader() { void SystemDictionary::compute_java_loaders(TRAPS) { JavaValue result(T_OBJECT); - InstanceKlass* class_loader_klass = SystemDictionary::ClassLoader_klass(); + InstanceKlass* class_loader_klass = vmClasses::ClassLoader_klass(); JavaCalls::call_static(&result, class_loader_klass, vmSymbols::getSystemClassLoader_name(), @@ -173,7 +173,7 @@ bool SystemDictionary::is_system_class_loader(oop class_loader) { if (class_loader == NULL) { return false; } - return (class_loader->klass() == SystemDictionary::jdk_internal_loader_ClassLoaders_AppClassLoader_klass() || + return (class_loader->klass() == vmClasses::jdk_internal_loader_ClassLoaders_AppClassLoader_klass() || class_loader == _java_system_loader.peek()); } @@ -182,7 +182,7 @@ bool SystemDictionary::is_platform_class_loader(oop class_loader) { if (class_loader == NULL) { return false; } - return (class_loader->klass() == SystemDictionary::jdk_internal_loader_ClassLoaders_PlatformClassLoader_klass()); + return (class_loader->klass() == vmClasses::jdk_internal_loader_ClassLoaders_PlatformClassLoader_klass()); } Handle SystemDictionary::compute_loader_lock_object(Thread* thread, Handle class_loader) { @@ -236,7 +236,7 @@ static void handle_resolution_exception(Symbol* class_name, bool throw_error, TR // If we have a pending exception we forward it to the caller, unless throw_error is true, // in which case we have to check whether the pending exception is a ClassNotFoundException, // and convert it to a NoClassDefFoundError and chain the original ClassNotFoundException. - if (throw_error && PENDING_EXCEPTION->is_a(SystemDictionary::ClassNotFoundException_klass())) { + if (throw_error && PENDING_EXCEPTION->is_a(vmClasses::ClassNotFoundException_klass())) { ResourceMark rm(THREAD); Handle e(THREAD, PENDING_EXCEPTION); CLEAR_PENDING_EXCEPTION; @@ -488,7 +488,7 @@ void SystemDictionary::validate_protection_domain(InstanceKlass* klass, // The class_loader handle passed in is the initiating loader. Handle mirror(THREAD, klass->java_mirror()); - InstanceKlass* system_loader = SystemDictionary::ClassLoader_klass(); + InstanceKlass* system_loader = vmClasses::ClassLoader_klass(); JavaCalls::call_special(&result, class_loader, system_loader, @@ -1495,7 +1495,7 @@ InstanceKlass* SystemDictionary::load_instance_class(Symbol* class_name, Handle JavaValue result(T_OBJECT); - InstanceKlass* spec_klass = SystemDictionary::ClassLoader_klass(); + InstanceKlass* spec_klass = vmClasses::ClassLoader_klass(); // Call public unsynchronized loadClass(String) directly for all class loaders. // For parallelCapable class loaders, JDK >=7, loadClass(String, boolean) will @@ -2233,7 +2233,7 @@ Method* SystemDictionary::find_method_handle_invoker(Klass* klass, int ref_kind = JVM_REF_invokeVirtual; oop name_oop = StringTable::intern(name, CHECK_NULL); Handle name_str (THREAD, name_oop); - objArrayHandle appendix_box = oopFactory::new_objArray_handle(SystemDictionary::Object_klass(), 1, CHECK_NULL); + objArrayHandle appendix_box = oopFactory::new_objArray_handle(vmClasses::Object_klass(), 1, CHECK_NULL); assert(appendix_box->obj_at(0) == NULL, ""); // This should not happen. JDK code should take care of that. @@ -2251,7 +2251,7 @@ Method* SystemDictionary::find_method_handle_invoker(Klass* klass, args.push_oop(appendix_box); JavaValue result(T_OBJECT); JavaCalls::call_static(&result, - SystemDictionary::MethodHandleNatives_klass(), + vmClasses::MethodHandleNatives_klass(), vmSymbols::linkMethod_name(), vmSymbols::linkMethod_signature(), &args, CHECK_NULL); @@ -2274,8 +2274,8 @@ static bool is_always_visible_class(oop mirror) { } assert(klass->is_instance_klass(), "%s", klass->external_name()); return klass->is_public() && - (InstanceKlass::cast(klass)->is_same_class_package(SystemDictionary::Object_klass()) || // java.lang - InstanceKlass::cast(klass)->is_same_class_package(SystemDictionary::MethodHandle_klass())); // java.lang.invoke + (InstanceKlass::cast(klass)->is_same_class_package(vmClasses::Object_klass()) || // java.lang + InstanceKlass::cast(klass)->is_same_class_package(vmClasses::MethodHandle_klass())); // java.lang.invoke } // Find or construct the Java mirror (java.lang.Class instance) for @@ -2344,7 +2344,7 @@ Handle SystemDictionary::find_method_handle_type(Symbol* signature, } bool can_be_cached = true; int npts = ArgumentCount(signature).size(); - objArrayHandle pts = oopFactory::new_objArray_handle(SystemDictionary::Class_klass(), npts, CHECK_(empty)); + objArrayHandle pts = oopFactory::new_objArray_handle(vmClasses::Class_klass(), npts, CHECK_(empty)); int arg = 0; Handle rt; // the return type from the signature ResourceMark rm(THREAD); @@ -2385,7 +2385,7 @@ Handle SystemDictionary::find_method_handle_type(Symbol* signature, args.push_oop(pts); JavaValue result(T_OBJECT); JavaCalls::call_static(&result, - SystemDictionary::MethodHandleNatives_klass(), + vmClasses::MethodHandleNatives_klass(), vmSymbols::findMethodHandleType_name(), vmSymbols::findMethodHandleType_signature(), &args, CHECK_(empty)); @@ -2442,7 +2442,7 @@ Handle SystemDictionary::link_method_handle_constant(Klass* caller, Handle signature_str = java_lang_String::create_from_symbol(signature, CHECK_(empty)); // Put symbolic info from the MH constant into freshly created MemberName and resolve it. - Handle mname = MemberName_klass()->allocate_instance_handle(CHECK_(empty)); + Handle mname = vmClasses::MemberName_klass()->allocate_instance_handle(CHECK_(empty)); java_lang_invoke_MemberName::set_clazz(mname(), callee->java_mirror()); java_lang_invoke_MemberName::set_name (mname(), name_str()); java_lang_invoke_MemberName::set_type (mname(), signature_str()); @@ -2471,7 +2471,7 @@ Handle SystemDictionary::link_method_handle_constant(Klass* caller, args.push_oop(type); JavaValue result(T_OBJECT); JavaCalls::call_static(&result, - SystemDictionary::MethodHandleNatives_klass(), + vmClasses::MethodHandleNatives_klass(), vmSymbols::linkMethodHandleConstant_name(), vmSymbols::linkMethodHandleConstant_signature(), &args, CHECK_(empty)); @@ -2494,7 +2494,7 @@ void SystemDictionary::invoke_bootstrap_method(BootstrapInfo& bootstrap_specifie objArrayHandle appendix_box; if (is_indy) { // Some method calls may require an appendix argument. Arrange to receive it. - appendix_box = oopFactory::new_objArray_handle(SystemDictionary::Object_klass(), 1, CHECK); + appendix_box = oopFactory::new_objArray_handle(vmClasses::Object_klass(), 1, CHECK); assert(appendix_box->obj_at(0) == NULL, ""); } @@ -2512,7 +2512,7 @@ void SystemDictionary::invoke_bootstrap_method(BootstrapInfo& bootstrap_specifie } JavaValue result(T_OBJECT); JavaCalls::call_static(&result, - SystemDictionary::MethodHandleNatives_klass(), + vmClasses::MethodHandleNatives_klass(), is_indy ? vmSymbols::linkCallSite_name() : vmSymbols::linkDynamicConstant_name(), is_indy ? vmSymbols::linkCallSite_signature() : vmSymbols::linkDynamicConstant_signature(), &args, CHECK); @@ -2548,7 +2548,7 @@ ClassLoaderData* SystemDictionary::class_loader_data(Handle class_loader) { bool SystemDictionary::is_nonpublic_Object_method(Method* m) { assert(m != NULL, "Unexpected NULL Method*"); - return !m->is_public() && m->method_holder() == SystemDictionary::Object_klass(); + return !m->is_public() && m->method_holder() == vmClasses::Object_klass(); } // ---------------------------------------------------------------------------- diff --git a/src/hotspot/share/classfile/systemDictionary.hpp b/src/hotspot/share/classfile/systemDictionary.hpp index ba600d7362ec6..00b19be29aef7 100644 --- a/src/hotspot/share/classfile/systemDictionary.hpp +++ b/src/hotspot/share/classfile/systemDictionary.hpp @@ -25,7 +25,6 @@ #ifndef SHARE_CLASSFILE_SYSTEMDICTIONARY_HPP #define SHARE_CLASSFILE_SYSTEMDICTIONARY_HPP -#include "classfile/vmClasses.hpp" #include "oops/oopHandle.hpp" #include "runtime/handles.hpp" #include "runtime/signature.hpp" @@ -86,10 +85,7 @@ class EventClassLoad; class Symbol; class TableStatistics; -// TMP: subclass from vmClasses so that we can still access the VM classes like -// SystemDictionary::Object_klass(). This will be fixed when we replace all SystemDictionary::*_klass() -// calls with vmClasses::*_klass(). -class SystemDictionary : public vmClasses { +class SystemDictionary : AllStatic { friend class BootstrapInfo; friend class vmClasses; friend class VMStructs; diff --git a/src/hotspot/share/classfile/systemDictionaryShared.cpp b/src/hotspot/share/classfile/systemDictionaryShared.cpp index ef76d893b2601..4c2dfc3aa2ebc 100644 --- a/src/hotspot/share/classfile/systemDictionaryShared.cpp +++ b/src/hotspot/share/classfile/systemDictionaryShared.cpp @@ -36,6 +36,7 @@ #include "classfile/systemDictionary.hpp" #include "classfile/systemDictionaryShared.hpp" #include "classfile/verificationType.hpp" +#include "classfile/vmClasses.hpp" #include "classfile/vmSymbols.hpp" #include "interpreter/bootstrapInfo.hpp" #include "jfr/jfrEvents.hpp" @@ -724,11 +725,11 @@ Handle SystemDictionaryShared::create_jar_manifest(const char* manifest_chars, s typeArrayHandle bufhandle(THREAD, buf); ArrayAccess<>::arraycopy_from_native(reinterpret_cast(manifest_chars), buf, typeArrayOopDesc::element_offset(0), size); - Handle bais = JavaCalls::construct_new_instance(SystemDictionary::ByteArrayInputStream_klass(), + Handle bais = JavaCalls::construct_new_instance(vmClasses::ByteArrayInputStream_klass(), vmSymbols::byte_array_void_signature(), bufhandle, CHECK_NH); // manifest = new Manifest(ByteArrayInputStream) - Handle manifest = JavaCalls::construct_new_instance(SystemDictionary::Jar_Manifest_klass(), + Handle manifest = JavaCalls::construct_new_instance(vmClasses::Jar_Manifest_klass(), vmSymbols::input_stream_void_signature(), bais, CHECK_NH); return manifest; @@ -773,7 +774,7 @@ Handle SystemDictionaryShared::get_shared_jar_url(int shared_path_index, TRAPS) const char* path = FileMapInfo::shared_path_name(shared_path_index); Handle path_string = java_lang_String::create_from_str(path, CHECK_(url_h)); Klass* classLoaders_klass = - SystemDictionary::jdk_internal_loader_ClassLoaders_klass(); + vmClasses::jdk_internal_loader_ClassLoaders_klass(); JavaCalls::call_static(&result, classLoaders_klass, vmSymbols::toFileURL_name(), vmSymbols::toFileURL_signature(), @@ -811,7 +812,7 @@ void SystemDictionaryShared::define_shared_package(Symbol* class_name, // get_package_name() returns a NULL handle if the class is in unnamed package Handle pkgname_string = get_package_name(class_name, CHECK); if (pkgname_string.not_null()) { - Klass* app_classLoader_klass = SystemDictionary::jdk_internal_loader_ClassLoaders_AppClassLoader_klass(); + Klass* app_classLoader_klass = vmClasses::jdk_internal_loader_ClassLoaders_AppClassLoader_klass(); JavaValue result(T_OBJECT); JavaCallArguments args(3); args.set_receiver(class_loader); @@ -830,12 +831,12 @@ void SystemDictionaryShared::define_shared_package(Symbol* class_name, Handle SystemDictionaryShared::get_protection_domain_from_classloader(Handle class_loader, Handle url, TRAPS) { // CodeSource cs = new CodeSource(url, null); - Handle cs = JavaCalls::construct_new_instance(SystemDictionary::CodeSource_klass(), + Handle cs = JavaCalls::construct_new_instance(vmClasses::CodeSource_klass(), vmSymbols::url_code_signer_array_void_signature(), url, Handle(), CHECK_NH); // protection_domain = SecureClassLoader.getProtectionDomain(cs); - Klass* secureClassLoader_klass = SystemDictionary::SecureClassLoader_klass(); + Klass* secureClassLoader_klass = vmClasses::SecureClassLoader_klass(); JavaValue obj_result(T_OBJECT); JavaCalls::call_virtual(&obj_result, class_loader, secureClassLoader_klass, vmSymbols::getProtectionDomain_name(), @@ -875,12 +876,12 @@ Handle SystemDictionaryShared::get_shared_protection_domain(Handle class_loader, Handle url; JavaValue result(T_OBJECT); if (location->starts_with("jrt:/")) { - url = JavaCalls::construct_new_instance(SystemDictionary::URL_klass(), + url = JavaCalls::construct_new_instance(vmClasses::URL_klass(), vmSymbols::string_void_signature(), location_string, CHECK_NH); } else { Klass* classLoaders_klass = - SystemDictionary::jdk_internal_loader_ClassLoaders_klass(); + vmClasses::jdk_internal_loader_ClassLoaders_klass(); JavaCalls::call_static(&result, classLoaders_klass, vmSymbols::toFileURL_name(), vmSymbols::toFileURL_signature(), location_string, CHECK_NH); @@ -1092,7 +1093,7 @@ InstanceKlass* SystemDictionaryShared::load_shared_class_for_builtin_loader( void SystemDictionaryShared::allocate_shared_protection_domain_array(int size, TRAPS) { if (_shared_protection_domains.resolve() == NULL) { oop spd = oopFactory::new_objArray( - SystemDictionary::ProtectionDomain_klass(), size, CHECK); + vmClasses::ProtectionDomain_klass(), size, CHECK); _shared_protection_domains = OopHandle(Universe::vm_global(), spd); } } @@ -1100,7 +1101,7 @@ void SystemDictionaryShared::allocate_shared_protection_domain_array(int size, T void SystemDictionaryShared::allocate_shared_jar_url_array(int size, TRAPS) { if (_shared_jar_urls.resolve() == NULL) { oop sju = oopFactory::new_objArray( - SystemDictionary::URL_klass(), size, CHECK); + vmClasses::URL_klass(), size, CHECK); _shared_jar_urls = OopHandle(Universe::vm_global(), sju); } } @@ -1108,7 +1109,7 @@ void SystemDictionaryShared::allocate_shared_jar_url_array(int size, TRAPS) { void SystemDictionaryShared::allocate_shared_jar_manifest_array(int size, TRAPS) { if (_shared_jar_manifests.resolve() == NULL) { oop sjm = oopFactory::new_objArray( - SystemDictionary::Jar_Manifest_klass(), size, CHECK); + vmClasses::Jar_Manifest_klass(), size, CHECK); _shared_jar_manifests = OopHandle(Universe::vm_global(), sjm); } } @@ -2187,8 +2188,8 @@ void SystemDictionaryShared::serialize_dictionary_headers(SerializeClosure* soc, } void SystemDictionaryShared::serialize_vm_classes(SerializeClosure* soc) { - for (auto id : EnumRange{}) { - soc->do_ptr((void**)klass_addr_at(id)); + for (auto id : EnumRange{}) { + soc->do_ptr((void**)vmClasses::klass_addr_at(id)); } } diff --git a/src/hotspot/share/classfile/verificationType.cpp b/src/hotspot/share/classfile/verificationType.cpp index 8087398d21f1d..505080319c063 100644 --- a/src/hotspot/share/classfile/verificationType.cpp +++ b/src/hotspot/share/classfile/verificationType.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,9 +24,11 @@ #include "precompiled.hpp" #include "classfile/symbolTable.hpp" +#include "classfile/systemDictionary.hpp" #include "classfile/systemDictionaryShared.hpp" #include "classfile/verificationType.hpp" #include "classfile/verifier.hpp" +#include "classfile/vmClasses.hpp" #include "classfile/vmSymbols.hpp" #include "logging/log.hpp" #include "oops/klass.inline.hpp" @@ -69,8 +71,8 @@ bool VerificationType::resolve_and_check_assignability(InstanceKlass* klass, Sym // to interfaces java.lang.Cloneable and java.io.Serializable. // Otherwise, we treat interfaces as java.lang.Object. return !from_is_array || - this_class == SystemDictionary::Cloneable_klass() || - this_class == SystemDictionary::Serializable_klass(); + this_class == vmClasses::Cloneable_klass() || + this_class == vmClasses::Serializable_klass(); } else if (from_is_object) { Klass* from_class; if (klass->is_hidden() && klass->name() == from_name) { diff --git a/src/hotspot/share/classfile/verificationType.hpp b/src/hotspot/share/classfile/verificationType.hpp index 83366551054ba..5f272bdfba1a4 100644 --- a/src/hotspot/share/classfile/verificationType.hpp +++ b/src/hotspot/share/classfile/verificationType.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,6 @@ #ifndef SHARE_CLASSFILE_VERIFICATIONTYPE_HPP #define SHARE_CLASSFILE_VERIFICATIONTYPE_HPP -#include "classfile/systemDictionary.hpp" #include "oops/instanceKlass.hpp" #include "oops/oop.hpp" #include "oops/symbol.hpp" diff --git a/src/hotspot/share/classfile/verifier.cpp b/src/hotspot/share/classfile/verifier.cpp index 6ea7440291adc..03c716b2362e7 100644 --- a/src/hotspot/share/classfile/verifier.cpp +++ b/src/hotspot/share/classfile/verifier.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,6 +33,7 @@ #include "classfile/symbolTable.hpp" #include "classfile/systemDictionary.hpp" #include "classfile/verifier.hpp" +#include "classfile/vmClasses.hpp" #include "classfile/vmSymbols.hpp" #include "interpreter/bytecodes.hpp" #include "interpreter/bytecodeStream.hpp" @@ -266,7 +267,7 @@ bool Verifier::verify(InstanceKlass* klass, bool should_verify_class, TRAPS) { bool Verifier::is_eligible_for_verification(InstanceKlass* klass, bool should_verify_class) { Symbol* name = klass->name(); - Klass* refl_magic_klass = SystemDictionary::reflect_MagicAccessorImpl_klass(); + Klass* refl_magic_klass = vmClasses::reflect_MagicAccessorImpl_klass(); bool is_reflect = refl_magic_klass != NULL && klass->is_subtype_of(refl_magic_klass); diff --git a/src/hotspot/share/classfile/vmClassID.hpp b/src/hotspot/share/classfile/vmClassID.hpp index 3ed421195d487..87b997510a9f7 100644 --- a/src/hotspot/share/classfile/vmClassID.hpp +++ b/src/hotspot/share/classfile/vmClassID.hpp @@ -28,7 +28,7 @@ #include "classfile/vmClassMacros.hpp" #include "utilities/enumIterator.hpp" -enum class VMClassID : int { +enum class vmClassID : int { #define DECLARE_VM_CLASS(name, symbol) _VM_CLASS_ENUM(name), _VM_CLASS_ENUM(symbol) = _VM_CLASS_ENUM(name), VM_CLASSES_DO(DECLARE_VM_CLASS) #undef DECLARE_VM_CLASS @@ -38,6 +38,6 @@ enum class VMClassID : int { LAST = LIMIT - 1 // inclusive upper limit }; -ENUMERATOR_RANGE(VMClassID, VMClassID::FIRST, VMClassID::LAST) // (inclusive start, inclusive end) +ENUMERATOR_RANGE(vmClassID, vmClassID::FIRST, vmClassID::LAST) // (inclusive start, inclusive end) #endif // SHARE_CLASSFILE_VMCLASSID_HPP diff --git a/src/hotspot/share/classfile/vmClassMacros.hpp b/src/hotspot/share/classfile/vmClassMacros.hpp index 03d21bed02f06..a4f55641b51cf 100644 --- a/src/hotspot/share/classfile/vmClassMacros.hpp +++ b/src/hotspot/share/classfile/vmClassMacros.hpp @@ -25,10 +25,10 @@ #ifndef SHARE_CLASSFILE_VMCLASSMACROS_HPP #define SHARE_CLASSFILE_VMCLASSMACROS_HPP -// _VM_CLASS_ENUM - internal: should be used only by VMClass*.{hpp,cpp} +// _VM_CLASS_ENUM - internal: should be used only by vmClass*.{hpp,cpp} #define _VM_CLASS_ENUM(kname) kname##_knum -#define VM_CLASS_ID(kname) VMClassID::_VM_CLASS_ENUM(kname) +#define VM_CLASS_ID(kname) vmClassID::_VM_CLASS_ENUM(kname) // VM_CLASSES_DO iterates the classes that are directly referenced // by the VM, suhch as java.lang.Object and java.lang.String. These @@ -37,7 +37,7 @@ // // Each VM class has a short klass name (like Object_klass), // and a vmSymbol name (like java_lang_Object). Both of these can -// be used to find the VMClassID for this class. The following two +// be used to find the vmClassID for this class. The following two // macros will evaluate to the same value: // // VM_CLASS_ID(Object_klass) diff --git a/src/hotspot/share/classfile/vmClasses.cpp b/src/hotspot/share/classfile/vmClasses.cpp index a7736961cde5e..ff7b8f755a044 100644 --- a/src/hotspot/share/classfile/vmClasses.cpp +++ b/src/hotspot/share/classfile/vmClasses.cpp @@ -37,14 +37,14 @@ #include "prims/jvmtiExport.hpp" #include "runtime/globals.hpp" -InstanceKlass* vmClasses::_klasses[static_cast(VMClassID::LIMIT)] +InstanceKlass* vmClasses::_klasses[static_cast(vmClassID::LIMIT)] = { NULL /*, NULL...*/ }; InstanceKlass* vmClasses::_box_klasses[T_VOID+1] = { NULL /*, NULL...*/ }; // CDS: scan and relocate all classes referenced by _klasses[]. void vmClasses::metaspace_pointers_do(MetaspaceClosure* it) { - for (auto id : EnumRange{}) { + for (auto id : EnumRange{}) { it->push(klass_addr_at(id)); } } @@ -79,7 +79,7 @@ bool vmClasses::contain(Klass* k) { } #endif -bool vmClasses::resolve(VMClassID id, TRAPS) { +bool vmClasses::resolve(vmClassID id, TRAPS) { InstanceKlass** klassp = &_klasses[as_int(id)]; #if INCLUDE_CDS @@ -102,9 +102,9 @@ bool vmClasses::resolve(VMClassID id, TRAPS) { return ((*klassp) != NULL); } -void vmClasses::resolve_until(VMClassID limit_id, VMClassID &start_id, TRAPS) { +void vmClasses::resolve_until(vmClassID limit_id, vmClassID &start_id, TRAPS) { assert((int)start_id <= (int)limit_id, "IDs are out of order!"); - for (auto id : EnumRange{start_id, limit_id}) { // (inclusive start, exclusive end) + for (auto id : EnumRange{start_id, limit_id}) { // (inclusive start, exclusive end) resolve(id, CHECK); } @@ -120,7 +120,7 @@ void vmClasses::resolve_all(TRAPS) { ClassLoader::classLoader_init2(CHECK); // Preload commonly used klasses - VMClassID scan = VMClassID::FIRST; + vmClassID scan = vmClassID::FIRST; // first do Object, then String, Class #if INCLUDE_CDS if (UseSharedSpaces) { @@ -135,7 +135,7 @@ void vmClasses::resolve_all(TRAPS) { // // HeapShared::fixup_mapped_heap_regions() fills the empty // spaces in the archived heap regions and may use - // SystemDictionary::Object_klass(), so we can do this only after + // vmClasses::Object_klass(), so we can do this only after // Object_klass is resolved. See the above resolve_through() // call. No mirror objects are accessed/restored in the above call. // Mirrors are restored after java.lang.Class is loaded. @@ -185,11 +185,11 @@ void vmClasses::resolve_all(TRAPS) { vmClasses::PhantomReference_klass()->set_reference_type(REF_PHANTOM); // JSR 292 classes - VMClassID jsr292_group_start = VM_CLASS_ID(MethodHandle_klass); - VMClassID jsr292_group_end = VM_CLASS_ID(VolatileCallSite_klass); + vmClassID jsr292_group_start = VM_CLASS_ID(MethodHandle_klass); + vmClassID jsr292_group_end = VM_CLASS_ID(VolatileCallSite_klass); resolve_until(jsr292_group_start, scan, CHECK); resolve_through(jsr292_group_end, scan, CHECK); - resolve_until(VMClassID::LIMIT, scan, CHECK); + resolve_until(vmClassID::LIMIT, scan, CHECK); _box_klasses[T_BOOLEAN] = vmClasses::Boolean_klass(); _box_klasses[T_CHAR] = vmClasses::Character_klass(); @@ -206,7 +206,7 @@ void vmClasses::resolve_all(TRAPS) { if (UseSharedSpaces) { JVMTI_ONLY(assert(JvmtiExport::is_early_phase(), "All well known classes must be resolved in JVMTI early phase")); - for (auto id : EnumRange{}) { + for (auto id : EnumRange{}) { InstanceKlass* k = _klasses[as_int(id)]; assert(k->is_shared(), "must not be replaced by JVMTI class file load hook"); } diff --git a/src/hotspot/share/classfile/vmClasses.hpp b/src/hotspot/share/classfile/vmClasses.hpp index 805c7439dd2f4..364014a2514f3 100644 --- a/src/hotspot/share/classfile/vmClasses.hpp +++ b/src/hotspot/share/classfile/vmClasses.hpp @@ -37,17 +37,17 @@ class MetaspaceClosure; class vmClasses : AllStatic { friend class VMStructs; - static VMClassID check_id(VMClassID id) { - assert((int)id >= (int)VMClassID::FIRST && (int)id < (int)VMClassID::LIMIT, "oob"); + static vmClassID check_id(vmClassID id) { + assert((int)id >= (int)vmClassID::FIRST && (int)id < (int)vmClassID::LIMIT, "oob"); return id; } - static int as_int(VMClassID id) { + static int as_int(vmClassID id) { return static_cast(check_id(id)); } - static VMClassID as_id(int i) { - VMClassID id = static_cast(i); + static vmClassID as_id(int i) { + vmClassID id = static_cast(i); return check_id(id); } @@ -57,9 +57,9 @@ class vmClasses : AllStatic { } static bool is_loaded(InstanceKlass* klass); - static bool resolve(VMClassID id, TRAPS); - static void resolve_until(VMClassID limit_id, VMClassID &start_id, TRAPS); - static void resolve_through(VMClassID last_id, VMClassID &start_id, TRAPS) { + static bool resolve(vmClassID id, TRAPS); + static void resolve_until(vmClassID limit_id, vmClassID &start_id, TRAPS); + static void resolve_through(vmClassID last_id, vmClassID &start_id, TRAPS) { int limit = as_int(last_id) + 1; resolve_until(as_id(limit), start_id, THREAD); } @@ -87,11 +87,11 @@ class vmClasses : AllStatic { VM_CLASSES_DO(_VM_CLASS_DECLARE); #undef _VM_CLASS_DECLARE - static InstanceKlass* klass_at(VMClassID id) { + static InstanceKlass* klass_at(vmClassID id) { return _klasses[as_int(id)]; } - static InstanceKlass** klass_addr_at(VMClassID id) { + static InstanceKlass** klass_addr_at(vmClassID id) { return &_klasses[as_int(id)]; } diff --git a/src/hotspot/share/code/compiledIC.cpp b/src/hotspot/share/code/compiledIC.cpp index 9f8e5b573498b..2d2ede574a672 100644 --- a/src/hotspot/share/code/compiledIC.cpp +++ b/src/hotspot/share/code/compiledIC.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,6 @@ */ #include "precompiled.hpp" -#include "classfile/systemDictionary.hpp" #include "code/codeBehaviours.hpp" #include "code/codeCache.hpp" #include "code/compiledIC.hpp" diff --git a/src/hotspot/share/code/dependencies.cpp b/src/hotspot/share/code/dependencies.cpp index 9fc912635e36f..862e673fc5db9 100644 --- a/src/hotspot/share/code/dependencies.cpp +++ b/src/hotspot/share/code/dependencies.cpp @@ -28,6 +28,7 @@ #include "ci/ciKlass.hpp" #include "ci/ciMethod.hpp" #include "classfile/javaClasses.inline.hpp" +#include "classfile/vmClasses.hpp" #include "code/dependencies.hpp" #include "compiler/compileLog.hpp" #include "compiler/compileBroker.hpp" @@ -1811,7 +1812,7 @@ Klass* Dependencies::check_has_no_finalizable_subclasses(Klass* ctxk, KlassDepCh Klass* Dependencies::check_call_site_target_value(oop call_site, oop method_handle, CallSiteDepChange* changes) { assert(call_site != NULL, "sanity"); assert(method_handle != NULL, "sanity"); - assert(call_site->is_a(SystemDictionary::CallSite_klass()), "sanity"); + assert(call_site->is_a(vmClasses::CallSite_klass()), "sanity"); if (changes == NULL) { // Validate all CallSites @@ -2034,6 +2035,6 @@ void Dependencies::print_statistics() { CallSiteDepChange::CallSiteDepChange(Handle call_site, Handle method_handle) : _call_site(call_site), _method_handle(method_handle) { - assert(_call_site()->is_a(SystemDictionary::CallSite_klass()), "must be"); - assert(_method_handle.is_null() || _method_handle()->is_a(SystemDictionary::MethodHandle_klass()), "must be"); + assert(_call_site()->is_a(vmClasses::CallSite_klass()), "must be"); + assert(_method_handle.is_null() || _method_handle()->is_a(vmClasses::MethodHandle_klass()), "must be"); } diff --git a/src/hotspot/share/code/nmethod.cpp b/src/hotspot/share/code/nmethod.cpp index b05ef488ba2c2..8f1df0c4184c8 100644 --- a/src/hotspot/share/code/nmethod.cpp +++ b/src/hotspot/share/code/nmethod.cpp @@ -62,6 +62,7 @@ #include "runtime/safepointVerifiers.hpp" #include "runtime/serviceThread.hpp" #include "runtime/sharedRuntime.hpp" +#include "runtime/signature.hpp" #include "runtime/sweeper.hpp" #include "runtime/vmThread.hpp" #include "utilities/align.hpp" diff --git a/src/hotspot/share/compiler/compileBroker.cpp b/src/hotspot/share/compiler/compileBroker.cpp index cb9e63bd0b844..3e88c915236ef 100644 --- a/src/hotspot/share/compiler/compileBroker.cpp +++ b/src/hotspot/share/compiler/compileBroker.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,7 @@ #include "jvm.h" #include "classfile/javaClasses.hpp" #include "classfile/symbolTable.hpp" -#include "classfile/systemDictionary.hpp" +#include "classfile/vmClasses.hpp" #include "classfile/vmSymbols.hpp" #include "code/codeCache.hpp" #include "code/codeHeapState.hpp" @@ -795,7 +795,7 @@ Handle CompileBroker::create_thread_oop(const char* name, TRAPS) { Handle string = java_lang_String::create_from_str(name, CHECK_NH); Handle thread_group(THREAD, Universe::system_thread_group()); return JavaCalls::construct_new_instance( - SystemDictionary::Thread_klass(), + vmClasses::Thread_klass(), vmSymbols::threadgroup_string_void_signature(), thread_group, string, @@ -1272,7 +1272,7 @@ void CompileBroker::compile_method_base(const methodHandle& method, vframeStream vfst(thread->as_Java_thread()); for (; !vfst.at_end(); vfst.next()) { if (vfst.method()->is_static_initializer() || - (vfst.method()->method_holder()->is_subclass_of(SystemDictionary::ClassLoader_klass()) && + (vfst.method()->method_holder()->is_subclass_of(vmClasses::ClassLoader_klass()) && vfst.method()->name() == vmSymbols::loadClass_name())) { blocking = false; break; diff --git a/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp b/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp index ecfe988a7ca9e..53b31b22577b8 100644 --- a/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp +++ b/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp @@ -24,6 +24,7 @@ #include "precompiled.hpp" #include "classfile/classLoaderDataGraph.hpp" +#include "classfile/systemDictionary.hpp" #include "code/codeCache.hpp" #include "gc/g1/g1BarrierSet.hpp" #include "gc/g1/g1CollectedHeap.inline.hpp" diff --git a/src/hotspot/share/gc/g1/g1FullCollector.cpp b/src/hotspot/share/gc/g1/g1FullCollector.cpp index 33cd49fff3d5e..089b6ff04aed4 100644 --- a/src/hotspot/share/gc/g1/g1FullCollector.cpp +++ b/src/hotspot/share/gc/g1/g1FullCollector.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,6 +23,7 @@ */ #include "precompiled.hpp" +#include "classfile/systemDictionary.hpp" #include "code/codeCache.hpp" #include "gc/g1/g1CollectedHeap.hpp" #include "gc/g1/g1FullCollector.inline.hpp" diff --git a/src/hotspot/share/gc/g1/g1ParScanThreadState.cpp b/src/hotspot/share/gc/g1/g1ParScanThreadState.cpp index c9981acf0b154..c152342cc4ae9 100644 --- a/src/hotspot/share/gc/g1/g1ParScanThreadState.cpp +++ b/src/hotspot/share/gc/g1/g1ParScanThreadState.cpp @@ -23,7 +23,7 @@ */ #include "precompiled.hpp" -#include "classfile/systemDictionary.hpp" +#include "classfile/vmClasses.hpp" #include "gc/g1/g1Allocator.inline.hpp" #include "gc/g1/g1CollectedHeap.inline.hpp" #include "gc/g1/g1CollectionSet.hpp" @@ -78,7 +78,7 @@ G1ParScanThreadState::G1ParScanThreadState(G1CollectedHeap* g1h, _partial_objarray_chunk_size(ParGCArrayScanChunk), _partial_array_stepper(n_workers), _string_klass_or_null(G1StringDedup::is_enabled() - ? SystemDictionary::String_klass() + ? vmClasses::String_klass() : nullptr), _num_optional_regions(optional_cset_length), _numa(g1h->numa()), @@ -86,7 +86,7 @@ G1ParScanThreadState::G1ParScanThreadState(G1CollectedHeap* g1h, { // Verify klass comparison with _string_klass_or_null is sufficient // to determine whether dedup is enabled and the object is a String. - assert(SystemDictionary::String_klass()->is_final(), "precondition"); + assert(vmClasses::String_klass()->is_final(), "precondition"); // We allocate number of young gen regions in the collection set plus one // entries, since entry 0 keeps track of surviving bytes for non-young regions. diff --git a/src/hotspot/share/gc/parallel/psCompactionManager.cpp b/src/hotspot/share/gc/parallel/psCompactionManager.cpp index b38b9891c22cd..fecb67317f1d6 100644 --- a/src/hotspot/share/gc/parallel/psCompactionManager.cpp +++ b/src/hotspot/share/gc/parallel/psCompactionManager.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,6 @@ */ #include "precompiled.hpp" -#include "classfile/systemDictionary.hpp" #include "gc/parallel/objectStartArray.hpp" #include "gc/parallel/parMarkBitMap.inline.hpp" #include "gc/parallel/parallelScavengeHeap.hpp" diff --git a/src/hotspot/share/gc/shared/collectedHeap.cpp b/src/hotspot/share/gc/shared/collectedHeap.cpp index 14882026a94de..105d64ba2f17c 100644 --- a/src/hotspot/share/gc/shared/collectedHeap.cpp +++ b/src/hotspot/share/gc/shared/collectedHeap.cpp @@ -23,7 +23,7 @@ */ #include "precompiled.hpp" -#include "classfile/systemDictionary.hpp" +#include "classfile/vmClasses.hpp" #include "gc/shared/allocTracer.hpp" #include "gc/shared/barrierSet.hpp" #include "gc/shared/collectedHeap.hpp" @@ -455,7 +455,7 @@ CollectedHeap::fill_with_object_impl(HeapWord* start, size_t words, bool zap) fill_with_array(start, words, zap); } else if (words > 0) { assert(words == min_fill_size(), "unaligned size"); - ObjAllocator allocator(SystemDictionary::Object_klass(), words); + ObjAllocator allocator(vmClasses::Object_klass(), words); allocator.initialize(start); } } diff --git a/src/hotspot/share/gc/shared/referenceProcessor.cpp b/src/hotspot/share/gc/shared/referenceProcessor.cpp index 484c67cc783e3..42bc3500b86f3 100644 --- a/src/hotspot/share/gc/shared/referenceProcessor.cpp +++ b/src/hotspot/share/gc/shared/referenceProcessor.cpp @@ -24,7 +24,6 @@ #include "precompiled.hpp" #include "classfile/javaClasses.inline.hpp" -#include "classfile/systemDictionary.hpp" #include "gc/shared/collectedHeap.hpp" #include "gc/shared/collectedHeap.inline.hpp" #include "gc/shared/gcTimer.hpp" diff --git a/src/hotspot/share/gc/shared/space.cpp b/src/hotspot/share/gc/shared/space.cpp index b59f5b196e1c1..516e789b3ff72 100644 --- a/src/hotspot/share/gc/shared/space.cpp +++ b/src/hotspot/share/gc/shared/space.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ */ #include "precompiled.hpp" -#include "classfile/systemDictionary.hpp" +#include "classfile/vmClasses.hpp" #include "classfile/vmSymbols.hpp" #include "gc/shared/blockOffsetTable.inline.hpp" #include "gc/shared/collectedHeap.inline.hpp" @@ -603,7 +603,7 @@ void ContiguousSpace::allocate_temporary_filler(int factor) { instanceOop obj = (instanceOop) allocate(size); obj->set_mark(markWord::prototype()); obj->set_klass_gap(0); - obj->set_klass(SystemDictionary::Object_klass()); + obj->set_klass(vmClasses::Object_klass()); } } diff --git a/src/hotspot/share/gc/shenandoah/shenandoahConcurrentMark.cpp b/src/hotspot/share/gc/shenandoah/shenandoahConcurrentMark.cpp index d0f282d0f3ffe..4f1c3c31d6ba6 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahConcurrentMark.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahConcurrentMark.cpp @@ -25,7 +25,6 @@ #include "precompiled.hpp" #include "classfile/symbolTable.hpp" -#include "classfile/systemDictionary.hpp" #include "code/codeCache.hpp" #include "gc/shared/weakProcessor.inline.hpp" diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp index a811f2004b868..375bbd441b68d 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp @@ -71,6 +71,7 @@ #include "gc/shenandoah/shenandoahJfrSupport.hpp" #endif +#include "classfile/systemDictionary.hpp" #include "memory/classLoaderMetaspace.hpp" #include "oops/compressedOops.inline.hpp" #include "prims/jvmtiTagMap.hpp" diff --git a/src/hotspot/share/interpreter/bootstrapInfo.cpp b/src/hotspot/share/interpreter/bootstrapInfo.cpp index cae8ff4947554..4f52b19fcc639 100644 --- a/src/hotspot/share/interpreter/bootstrapInfo.cpp +++ b/src/hotspot/share/interpreter/bootstrapInfo.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,8 @@ #include "jvm.h" #include "classfile/javaClasses.inline.hpp" #include "classfile/resolutionErrors.hpp" +#include "classfile/systemDictionary.hpp" +#include "classfile/vmClasses.hpp" #include "interpreter/bootstrapInfo.hpp" #include "interpreter/linkResolver.hpp" #include "logging/log.hpp" @@ -183,7 +185,7 @@ void BootstrapInfo::resolve_args(TRAPS) { if (!use_BSCI) { // return {arg...}; resolution of arguments is done immediately, before JDK code is called - objArrayOop args_oop = oopFactory::new_objArray(SystemDictionary::Object_klass(), _argc, CHECK); + objArrayOop args_oop = oopFactory::new_objArray(vmClasses::Object_klass(), _argc, CHECK); objArrayHandle args(THREAD, args_oop); _pool->copy_bootstrap_arguments_at(_bss_index, 0, _argc, args, 0, true, Handle(), CHECK); oop arg_oop = ((_argc == 1) ? args->obj_at(0) : (oop)NULL); diff --git a/src/hotspot/share/interpreter/bytecodeUtils.cpp b/src/hotspot/share/interpreter/bytecodeUtils.cpp index a1e94a6cc3183..9473e87dec14b 100644 --- a/src/hotspot/share/interpreter/bytecodeUtils.cpp +++ b/src/hotspot/share/interpreter/bytecodeUtils.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2019 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -24,7 +24,7 @@ */ #include "precompiled.hpp" -#include "classfile/systemDictionary.hpp" +#include "classfile/vmClasses.hpp" #include "classfile/vmSymbols.hpp" #include "gc/shared/gcLocker.hpp" #include "interpreter/bytecodeUtils.hpp" @@ -1448,7 +1448,7 @@ bool BytecodeUtils::get_NPE_message_at(outputStream* ss, Method* method, int bci // If this NPE was created via reflection, we have no real NPE. if (method->method_holder() == - SystemDictionary::reflect_NativeConstructorAccessorImpl_klass()) { + vmClasses::reflect_NativeConstructorAccessorImpl_klass()) { return false; } diff --git a/src/hotspot/share/interpreter/interpreterRuntime.cpp b/src/hotspot/share/interpreter/interpreterRuntime.cpp index 8286e4383c889..d9ad157cf50d3 100644 --- a/src/hotspot/share/interpreter/interpreterRuntime.cpp +++ b/src/hotspot/share/interpreter/interpreterRuntime.cpp @@ -26,7 +26,7 @@ #include "jvm_io.h" #include "classfile/javaClasses.inline.hpp" #include "classfile/symbolTable.hpp" -#include "classfile/systemDictionary.hpp" +#include "classfile/vmClasses.hpp" #include "classfile/vmSymbols.hpp" #include "code/codeCache.hpp" #include "compiler/compilationPolicy.hpp" @@ -318,7 +318,7 @@ void InterpreterRuntime::note_trap_inner(JavaThread* thread, int reason, Method::build_interpreter_method_data(trap_method, THREAD); if (HAS_PENDING_EXCEPTION) { // Only metaspace OOM is expected. No Java code executed. - assert((PENDING_EXCEPTION->is_a(SystemDictionary::OutOfMemoryError_klass())), + assert((PENDING_EXCEPTION->is_a(vmClasses::OutOfMemoryError_klass())), "we expect only an OOM error here"); CLEAR_PENDING_EXCEPTION; } @@ -365,7 +365,7 @@ static Handle get_preinitialized_exception(Klass* k, TRAPS) { // constructor for the same reason (it is empty, anyway). JRT_ENTRY(void, InterpreterRuntime::throw_StackOverflowError(JavaThread* thread)) Handle exception = get_preinitialized_exception( - SystemDictionary::StackOverflowError_klass(), + vmClasses::StackOverflowError_klass(), CHECK); // Increment counter for hs_err file reporting Atomic::inc(&Exceptions::_stack_overflow_errors); @@ -374,7 +374,7 @@ JRT_END JRT_ENTRY(void, InterpreterRuntime::throw_delayed_StackOverflowError(JavaThread* thread)) Handle exception = get_preinitialized_exception( - SystemDictionary::StackOverflowError_klass(), + vmClasses::StackOverflowError_klass(), CHECK); java_lang_Throwable::set_message(exception(), Universe::delayed_stack_overflow_error_message()); @@ -493,7 +493,7 @@ JRT_ENTRY(address, InterpreterRuntime::exception_handler_for_exception(JavaThrea // assertions assert(h_exception.not_null(), "NULL exceptions should be handled by athrow"); // Check that exception is a subclass of Throwable. - assert(h_exception->is_a(SystemDictionary::Throwable_klass()), + assert(h_exception->is_a(vmClasses::Throwable_klass()), "Exception not subclass of Throwable"); // tracing @@ -774,9 +774,9 @@ JRT_ENTRY(void, InterpreterRuntime::new_illegal_monitor_state_exception(JavaThre Handle exception(thread, thread->vm_result()); assert(exception() != NULL, "vm result should be set"); thread->set_vm_result(NULL); // clear vm result before continuing (may cause memory leaks and assert failures) - if (!exception->is_a(SystemDictionary::ThreadDeath_klass())) { + if (!exception->is_a(vmClasses::ThreadDeath_klass())) { exception = get_preinitialized_exception( - SystemDictionary::IllegalMonitorStateException_klass(), + vmClasses::IllegalMonitorStateException_klass(), CATCH); } thread->set_vm_result(exception()); @@ -842,7 +842,7 @@ void InterpreterRuntime::resolve_invoke(JavaThread* thread, Bytecodes::Code byte #ifdef ASSERT if (bytecode == Bytecodes::_invokeinterface) { - if (resolved_method->method_holder() == SystemDictionary::Object_klass()) { + if (resolved_method->method_holder() == vmClasses::Object_klass()) { // NOTE: THIS IS A FIX FOR A CORNER CASE in the JVM spec // (see also CallInfo::set_interface for details) assert(info.call_kind() == CallInfo::vtable_call || @@ -1116,7 +1116,7 @@ JRT_ENTRY(MethodCounters*, InterpreterRuntime::build_method_counters(JavaThread* MethodCounters* mcs = Method::build_method_counters(m, thread); if (HAS_PENDING_EXCEPTION) { // Only metaspace OOM is expected. No Java code executed. - assert((PENDING_EXCEPTION->is_a(SystemDictionary::OutOfMemoryError_klass())), "we expect only an OOM error here"); + assert((PENDING_EXCEPTION->is_a(vmClasses::OutOfMemoryError_klass())), "we expect only an OOM error here"); CLEAR_PENDING_EXCEPTION; } return mcs; diff --git a/src/hotspot/share/interpreter/linkResolver.cpp b/src/hotspot/share/interpreter/linkResolver.cpp index bba22a037f776..a3316c7b84663 100644 --- a/src/hotspot/share/interpreter/linkResolver.cpp +++ b/src/hotspot/share/interpreter/linkResolver.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,6 +29,7 @@ #include "classfile/resolutionErrors.hpp" #include "classfile/symbolTable.hpp" #include "classfile/systemDictionary.hpp" +#include "classfile/vmClasses.hpp" #include "classfile/vmSymbols.hpp" #include "compiler/compilationPolicy.hpp" #include "compiler/compileBroker.hpp" @@ -96,7 +97,7 @@ void CallInfo::set_virtual(Klass* resolved_klass, void CallInfo::set_handle(const methodHandle& resolved_method, Handle resolved_appendix, TRAPS) { - set_handle(SystemDictionary::MethodHandle_klass(), resolved_method, resolved_appendix, CHECK); + set_handle(vmClasses::MethodHandle_klass(), resolved_method, resolved_appendix, CHECK); } void CallInfo::set_handle(Klass* resolved_klass, @@ -159,7 +160,7 @@ CallInfo::CallInfo(Method* resolved_method, Klass* resolved_klass, TRAPS) { #ifdef ASSERT // Ensure that this is really the case. - Klass* object_klass = SystemDictionary::Object_klass(); + Klass* object_klass = vmClasses::Object_klass(); Method * object_resolved_method = object_klass->vtable().method_at(index); assert(object_resolved_method->name() == resolved_method->name(), "Object and interface method names should match at vtable index %d, %s != %s", @@ -350,7 +351,7 @@ Method* LinkResolver::lookup_method_in_klasses(const LinkInfo& link_info, result != NULL && ik->is_interface() && (result->is_static() || !result->is_public()) && - result->method_holder() == SystemDictionary::Object_klass()) { + result->method_holder() == vmClasses::Object_klass()) { result = NULL; } @@ -454,8 +455,8 @@ Method* LinkResolver::lookup_polymorphic_method(const LinkInfo& link_info, log_info(methodhandles)("lookup_polymorphic_method iid=%s %s.%s%s", vmIntrinsics::name_at(iid), klass->external_name(), name->as_C_string(), full_signature->as_C_string()); - if ((klass == SystemDictionary::MethodHandle_klass() || - klass == SystemDictionary::VarHandle_klass()) && + if ((klass == vmClasses::MethodHandle_klass() || + klass == vmClasses::VarHandle_klass()) && iid != vmIntrinsics::_none) { if (MethodHandles::is_signature_polymorphic_intrinsic(iid)) { // Most of these do not need an up-call to Java to resolve, so can be done anywhere. @@ -488,7 +489,7 @@ Method* LinkResolver::lookup_polymorphic_method(const LinkInfo& link_info, // We will ask Java code to spin an adapter method for it. if (!MethodHandles::enabled()) { // Make sure the Java part of the runtime has been booted up. - Klass* natives = SystemDictionary::MethodHandleNatives_klass(); + Klass* natives = vmClasses::MethodHandleNatives_klass(); if (natives == NULL || InstanceKlass::cast(natives)->is_not_initialized()) { SystemDictionary::resolve_or_fail(vmSymbols::java_lang_invoke_MethodHandleNatives(), Handle(), @@ -574,7 +575,7 @@ void LinkResolver::check_method_accessability(Klass* ref_klass, // We'll check for the method name first, as that's most likely // to be false (so we'll short-circuit out of these tests). if (sel_method->name() == vmSymbols::clone_name() && - sel_klass == SystemDictionary::Object_klass() && + sel_klass == vmClasses::Object_klass() && resolved_klass->is_array_klass()) { // We need to change "protected" to "public". assert(flags.is_protected(), "clone not protected?"); @@ -632,7 +633,7 @@ Method* LinkResolver::resolve_method_statically(Bytecodes::Code code, // FIXME: Remove this method and ciMethod::check_call; refactor to use the other LinkResolver entry points. // resolve klass if (code == Bytecodes::_invokedynamic) { - Klass* resolved_klass = SystemDictionary::MethodHandle_klass(); + Klass* resolved_klass = vmClasses::MethodHandle_klass(); Symbol* method_name = vmSymbols::invoke_name(); Symbol* method_signature = pool->signature_ref_at(index); Klass* current_klass = pool->pool_holder(); @@ -644,7 +645,7 @@ Method* LinkResolver::resolve_method_statically(Bytecodes::Code code, Klass* resolved_klass = link_info.resolved_klass(); if (pool->has_preresolution() - || (resolved_klass == SystemDictionary::MethodHandle_klass() && + || (resolved_klass == vmClasses::MethodHandle_klass() && MethodHandles::is_signature_polymorphic_name(resolved_klass, link_info.name()))) { Method* result = ConstantPool::method_at_if_loaded(pool, index); if (result != NULL) { @@ -1184,7 +1185,7 @@ Method* LinkResolver::linktime_resolve_special_method(const LinkInfo& link_info, ck->unsafe_anonymous_host(); // Disable verification for the dynamically-generated reflection bytecodes. bool is_reflect = klass_to_check->is_subclass_of( - SystemDictionary::reflect_MagicAccessorImpl_klass()); + vmClasses::reflect_MagicAccessorImpl_klass()); if (!is_reflect && !klass_to_check->is_same_or_direct_interface(resolved_klass)) { @@ -1538,7 +1539,7 @@ void LinkResolver::runtime_resolve_interface_method(CallInfo& result, log_develop_trace(itables)(" -- non itable/vtable index: %d", index); assert(index == Method::nonvirtual_vtable_index, "Oops hit another case!"); assert(resolved_method()->is_private() || - (resolved_method()->is_final() && resolved_method->method_holder() == SystemDictionary::Object_klass()), + (resolved_method()->is_final() && resolved_method->method_holder() == vmClasses::Object_klass()), "Should only have non-virtual invokeinterface for private or final-Object methods!"); assert(resolved_method()->can_be_statically_bound(), "Should only have non-virtual invokeinterface for statically bound methods!"); // This sets up the nonvirtual form of "virtual" call (as needed for final and private methods) @@ -1724,8 +1725,8 @@ void LinkResolver::resolve_handle_call(CallInfo& result, TRAPS) { // JSR 292: this must be an implicitly generated method MethodHandle.invokeExact(*...) or similar Klass* resolved_klass = link_info.resolved_klass(); - assert(resolved_klass == SystemDictionary::MethodHandle_klass() || - resolved_klass == SystemDictionary::VarHandle_klass(), ""); + assert(resolved_klass == vmClasses::MethodHandle_klass() || + resolved_klass == vmClasses::VarHandle_klass(), ""); assert(MethodHandles::is_signature_polymorphic_name(link_info.name()), ""); Handle resolved_appendix; Method* resolved_method = lookup_polymorphic_method(link_info, &resolved_appendix, CHECK); @@ -1785,7 +1786,7 @@ void LinkResolver::resolve_dynamic_call(CallInfo& result, Exceptions::wrap_dynamic_exception(/* is_indy */ true, THREAD); if (HAS_PENDING_EXCEPTION) { - if (!PENDING_EXCEPTION->is_a(SystemDictionary::LinkageError_klass())) { + if (!PENDING_EXCEPTION->is_a(vmClasses::LinkageError_klass())) { // Let any random low-level IE or SOE or OOME just bleed through. // Basically we pretend that the bootstrap method was never called, // if it fails this way: We neither record a successful linkage, diff --git a/src/hotspot/share/interpreter/rewriter.cpp b/src/hotspot/share/interpreter/rewriter.cpp index c2474fd775491..67bb9c6caea5a 100644 --- a/src/hotspot/share/interpreter/rewriter.cpp +++ b/src/hotspot/share/interpreter/rewriter.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,6 +23,7 @@ */ #include "precompiled.hpp" +#include "classfile/vmClasses.hpp" #include "interpreter/bytecodes.hpp" #include "interpreter/interpreter.hpp" #include "interpreter/rewriter.hpp" @@ -219,13 +220,13 @@ void Rewriter::maybe_rewrite_invokehandle(address opc, int cp_index, int cache_i assert(status >= -1 && status <= 1, "oob tri-state"); if (status == 0) { if (_pool->klass_ref_at_noresolve(cp_index) == vmSymbols::java_lang_invoke_MethodHandle() && - MethodHandles::is_signature_polymorphic_name(SystemDictionary::MethodHandle_klass(), + MethodHandles::is_signature_polymorphic_name(vmClasses::MethodHandle_klass(), _pool->name_ref_at(cp_index))) { // we may need a resolved_refs entry for the appendix add_invokedynamic_resolved_references_entry(cp_index, cache_index); status = +1; } else if (_pool->klass_ref_at_noresolve(cp_index) == vmSymbols::java_lang_invoke_VarHandle() && - MethodHandles::is_signature_polymorphic_name(SystemDictionary::VarHandle_klass(), + MethodHandles::is_signature_polymorphic_name(vmClasses::VarHandle_klass(), _pool->name_ref_at(cp_index))) { // we may need a resolved_refs entry for the appendix add_invokedynamic_resolved_references_entry(cp_index, cache_index); diff --git a/src/hotspot/share/jfr/instrumentation/jfrEventClassTransformer.cpp b/src/hotspot/share/jfr/instrumentation/jfrEventClassTransformer.cpp index 72963943a12cb..d8c9acc8e8ed2 100644 --- a/src/hotspot/share/jfr/instrumentation/jfrEventClassTransformer.cpp +++ b/src/hotspot/share/jfr/instrumentation/jfrEventClassTransformer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,6 +32,7 @@ #include "classfile/modules.hpp" #include "classfile/stackMapTable.hpp" #include "classfile/symbolTable.hpp" +#include "classfile/systemDictionary.hpp" #include "classfile/verificationType.hpp" #include "interpreter/bytecodes.hpp" #include "jfr/instrumentation/jfrEventClassTransformer.hpp" diff --git a/src/hotspot/share/jfr/jni/jfrJavaSupport.cpp b/src/hotspot/share/jfr/jni/jfrJavaSupport.cpp index 7c03bbe5214ee..a97cac0c1150c 100644 --- a/src/hotspot/share/jfr/jni/jfrJavaSupport.cpp +++ b/src/hotspot/share/jfr/jni/jfrJavaSupport.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,7 @@ #include "classfile/javaClasses.inline.hpp" #include "classfile/modules.hpp" #include "classfile/symbolTable.hpp" -#include "classfile/systemDictionary.hpp" +#include "classfile/vmClasses.hpp" #include "classfile/vmSymbols.hpp" #include "jfr/jni/jfrJavaCall.hpp" #include "jfr/jni/jfrJavaSupport.hpp" @@ -566,23 +566,23 @@ void JfrJavaSupport::set_cause(jthrowable throwable, Thread* t) { return; } - if (ex->is_a(SystemDictionary::OutOfMemoryError_klass())) { + if (ex->is_a(vmClasses::OutOfMemoryError_klass())) { _cause = OUT_OF_MEMORY; return; } - if (ex->is_a(SystemDictionary::StackOverflowError_klass())) { + if (ex->is_a(vmClasses::StackOverflowError_klass())) { _cause = STACK_OVERFLOW; return; } - if (ex->is_a(SystemDictionary::Error_klass())) { + if (ex->is_a(vmClasses::Error_klass())) { _cause = VM_ERROR; return; } - if (ex->is_a(SystemDictionary::RuntimeException_klass())) { + if (ex->is_a(vmClasses::RuntimeException_klass())) { _cause = RUNTIME_EXCEPTION; return; } - if (ex->is_a(SystemDictionary::Exception_klass())) { + if (ex->is_a(vmClasses::Exception_klass())) { _cause = UNKNOWN; return; } diff --git a/src/hotspot/share/jfr/leakprofiler/checkpoint/objectSampleDescription.cpp b/src/hotspot/share/jfr/leakprofiler/checkpoint/objectSampleDescription.cpp index 3ed268c122efb..1cc69e6943f1f 100644 --- a/src/hotspot/share/jfr/leakprofiler/checkpoint/objectSampleDescription.cpp +++ b/src/hotspot/share/jfr/leakprofiler/checkpoint/objectSampleDescription.cpp @@ -26,7 +26,7 @@ #include "jvm_io.h" #include "classfile/javaClasses.inline.hpp" #include "classfile/symbolTable.hpp" -#include "classfile/systemDictionary.hpp" +#include "classfile/vmClasses.hpp" #include "classfile/vmSymbols.hpp" #include "jfr/leakprofiler/checkpoint/objectSampleDescription.hpp" #include "jfr/recorder/checkpoint/jfrCheckpointWriter.hpp" @@ -126,17 +126,17 @@ void ObjectSampleDescription::write_object_details() { Symbol* class_name = klass->name(); jint size; - if (_object->is_a(SystemDictionary::Class_klass())) { + if (_object->is_a(vmClasses::Class_klass())) { write_class_name(); return; } - if (_object->is_a(SystemDictionary::Thread_klass())) { + if (_object->is_a(vmClasses::Thread_klass())) { write_thread_name(); return; } - if (_object->is_a(SystemDictionary::ThreadGroup_klass())) { + if (_object->is_a(vmClasses::ThreadGroup_klass())) { write_thread_group_name(); return; } @@ -148,7 +148,7 @@ void ObjectSampleDescription::write_object_details() { } void ObjectSampleDescription::write_class_name() { - assert(_object->is_a(SystemDictionary::Class_klass()), "invariant"); + assert(_object->is_a(vmClasses::Class_klass()), "invariant"); const Klass* const k = java_lang_Class::as_Klass(_object); if (k == NULL) { // might represent a primitive @@ -176,7 +176,7 @@ void ObjectSampleDescription::write_class_name() { } void ObjectSampleDescription::write_thread_group_name() { - assert(_object->is_a(SystemDictionary::ThreadGroup_klass()), "invariant"); + assert(_object->is_a(vmClasses::ThreadGroup_klass()), "invariant"); const char* tg_name = java_lang_ThreadGroup::name(_object); if (tg_name != NULL) { write_text("Thread Group: "); @@ -185,7 +185,7 @@ void ObjectSampleDescription::write_thread_group_name() { } void ObjectSampleDescription::write_thread_name() { - assert(_object->is_a(SystemDictionary::Thread_klass()), "invariant"); + assert(_object->is_a(vmClasses::Thread_klass()), "invariant"); oop name = java_lang_Thread::name(_object); if (name != NULL) { char* p = java_lang_String::as_utf8_string(name); diff --git a/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeSet.cpp b/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeSet.cpp index 46083e1f26e11..3ce08fb5eb8e2 100644 --- a/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeSet.cpp +++ b/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeSet.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,6 +28,7 @@ #include "classfile/moduleEntry.hpp" #include "classfile/packageEntry.hpp" #include "classfile/symbolTable.hpp" +#include "classfile/vmClasses.hpp" #include "jfr/leakprofiler/checkpoint/objectSampleCheckpoint.hpp" #include "jfr/recorder/checkpoint/types/jfrTypeSet.hpp" #include "jfr/recorder/checkpoint/types/jfrTypeSetUtils.hpp" @@ -214,7 +215,7 @@ int write__klass__leakp(JfrCheckpointWriter* writer, const void* k) { static bool is_implied(const Klass* klass) { assert(klass != NULL, "invariant"); - return klass->is_subclass_of(SystemDictionary::ClassLoader_klass()) || klass == SystemDictionary::Object_klass(); + return klass->is_subclass_of(vmClasses::ClassLoader_klass()) || klass == vmClasses::Object_klass(); } static void do_klass(Klass* klass) { @@ -270,7 +271,7 @@ static bool is_classloader_klass_allowed(const Klass* k) { static void do_classloaders() { Stack mark_stack; - mark_stack.push(SystemDictionary::ClassLoader_klass()->subklass()); + mark_stack.push(vmClasses::ClassLoader_klass()->subklass()); while (!mark_stack.is_empty()) { const Klass* const current = mark_stack.pop(); @@ -295,8 +296,8 @@ static void do_classloaders() { } static void do_object() { - SET_TRANSIENT(SystemDictionary::Object_klass()); - do_klass(SystemDictionary::Object_klass()); + SET_TRANSIENT(vmClasses::Object_klass()); + do_klass(vmClasses::Object_klass()); } static void do_klasses() { diff --git a/src/hotspot/share/jfr/recorder/service/jfrRecorderThread.cpp b/src/hotspot/share/jfr/recorder/service/jfrRecorderThread.cpp index 6f44021abc181..c37b349e149bd 100644 --- a/src/hotspot/share/jfr/recorder/service/jfrRecorderThread.cpp +++ b/src/hotspot/share/jfr/recorder/service/jfrRecorderThread.cpp @@ -27,6 +27,7 @@ #include "classfile/javaClasses.hpp" #include "classfile/symbolTable.hpp" #include "classfile/systemDictionary.hpp" +#include "classfile/vmClasses.hpp" #include "classfile/vmSymbols.hpp" #include "jfr/jfr.hpp" #include "jfr/jni/jfrJavaSupport.hpp" @@ -108,7 +109,7 @@ bool JfrRecorderThread::start(JfrCheckpointManager* cp_manager, JfrPostBox* post // Start failed, remove the thread from the system thread group JavaValue void_result(T_VOID); JfrJavaArguments remove_thread_args(&void_result); - remove_thread_args.set_klass(SystemDictionary::ThreadGroup_klass()); + remove_thread_args.set_klass(vmClasses::ThreadGroup_klass()); remove_thread_args.set_name(vmSymbols::remove_method_name()); remove_thread_args.set_signature(vmSymbols::thread_void_signature()); remove_thread_args.set_receiver(Universe::system_thread_group()); diff --git a/src/hotspot/share/jfr/support/jfrJdkJfrEvent.cpp b/src/hotspot/share/jfr/support/jfrJdkJfrEvent.cpp index 400dc87fceda5..5f151ab9883e3 100644 --- a/src/hotspot/share/jfr/support/jfrJdkJfrEvent.cpp +++ b/src/hotspot/share/jfr/support/jfrJdkJfrEvent.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ #include "precompiled.hpp" #include "classfile/javaClasses.inline.hpp" #include "classfile/symbolTable.hpp" +#include "classfile/systemDictionary.hpp" #include "jfr/jni/jfrJavaSupport.hpp" #include "jfr/recorder/checkpoint/types/traceid/jfrTraceId.inline.hpp" #include "jfr/support/jfrJdkJfrEvent.hpp" diff --git a/src/hotspot/share/jvmci/compilerRuntime.cpp b/src/hotspot/share/jvmci/compilerRuntime.cpp index fdb0315b5decc..02b0a716351ee 100644 --- a/src/hotspot/share/jvmci/compilerRuntime.cpp +++ b/src/hotspot/share/jvmci/compilerRuntime.cpp @@ -25,6 +25,7 @@ #include "aot/aotLoader.hpp" #include "classfile/stringTable.hpp" #include "classfile/symbolTable.hpp" +#include "classfile/systemDictionary.hpp" #include "classfile/vmSymbols.hpp" #include "compiler/compilationPolicy.hpp" #include "interpreter/linkResolver.hpp" diff --git a/src/hotspot/share/jvmci/jvmciCompiler.cpp b/src/hotspot/share/jvmci/jvmciCompiler.cpp index 7a37199cae7f4..f438f5c518887 100644 --- a/src/hotspot/share/jvmci/jvmciCompiler.cpp +++ b/src/hotspot/share/jvmci/jvmciCompiler.cpp @@ -22,6 +22,7 @@ */ #include "precompiled.hpp" +#include "classfile/vmClasses.hpp" #include "compiler/compileBroker.hpp" #include "classfile/moduleEntry.hpp" #include "classfile/vmSymbols.hpp" @@ -78,7 +79,7 @@ void JVMCICompiler::bootstrap(TRAPS) { } jlong start = os::javaTimeNanos(); - Array* objectMethods = SystemDictionary::Object_klass()->methods(); + Array* objectMethods = vmClasses::Object_klass()->methods(); // Initialize compile queue with a selected set of methods. int len = objectMethods->length(); for (int i = 0; i < len; i++) { diff --git a/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp b/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp index 50424f7e77ab9..90e7df47ecc9a 100644 --- a/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp +++ b/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp @@ -26,6 +26,8 @@ #include "classfile/javaClasses.inline.hpp" #include "classfile/stringTable.hpp" #include "classfile/symbolTable.hpp" +#include "classfile/systemDictionary.hpp" +#include "classfile/vmClasses.hpp" #include "code/scopeDesc.hpp" #include "compiler/compileBroker.hpp" #include "compiler/compilerEvent.hpp" @@ -353,11 +355,11 @@ C2V_VMENTRY_NULL(jobject, asResolvedJavaMethod, (JNIEnv* env, jobject, jobject e oop mirror = NULL; int slot = 0; - if (executable->klass() == SystemDictionary::reflect_Constructor_klass()) { + if (executable->klass() == vmClasses::reflect_Constructor_klass()) { mirror = java_lang_reflect_Constructor::clazz(executable); slot = java_lang_reflect_Constructor::slot(executable); } else { - assert(executable->klass() == SystemDictionary::reflect_Method_klass(), "wrong type"); + assert(executable->klass() == vmClasses::reflect_Method_klass(), "wrong type"); mirror = java_lang_reflect_Method::clazz(executable); slot = java_lang_reflect_Method::slot(executable); } @@ -374,7 +376,7 @@ C2V_VMENTRY_NULL(jobject, getResolvedJavaMethod, (JNIEnv* env, jobject, jobject method = *((Method**)(offset)); } else if (JVMCIENV->isa_HotSpotObjectConstantImpl(base_object)) { Handle obj = JVMCIENV->asConstant(base_object, JVMCI_CHECK_NULL); - if (obj->is_a(SystemDictionary::ResolvedMethodName_klass())) { + if (obj->is_a(vmClasses::ResolvedMethodName_klass())) { method = (Method*) (intptr_t) obj->long_field(offset); } else { JVMCI_THROW_MSG_NULL(IllegalArgumentException, err_msg("Unexpected type: %s", obj->klass()->external_name())); @@ -432,7 +434,7 @@ C2V_VMENTRY_NULL(jobject, getResolvedJavaType0, (JNIEnv* env, jobject, jobject b base_address = (intptr_t) JVMCIENV->asKlass(base_object); } else if (JVMCIENV->isa_HotSpotObjectConstantImpl(base_object)) { Handle base_oop = JVMCIENV->asConstant(base_object, JVMCI_CHECK_NULL); - if (base_oop->is_a(SystemDictionary::Class_klass())) { + if (base_oop->is_a(vmClasses::Class_klass())) { base_address = cast_from_oop(base_oop()); } } @@ -753,7 +755,7 @@ C2V_VMENTRY_NULL(jobject, resolveMethod, (JNIEnv* env, jobject, jobject receiver } if (method->name() == vmSymbols::clone_name() && - resolved == SystemDictionary::Object_klass() && + resolved == vmClasses::Object_klass() && recv_klass->is_array_klass()) { // Resolution of the clone method on arrays always returns Object.clone even though that method // has protected access. There's some trickery in the access checking to make this all work out @@ -1817,10 +1819,10 @@ C2V_END C2V_VMENTRY(void, compileToBytecode, (JNIEnv* env, jobject, jobject lambda_form_handle)) Handle lambda_form = JVMCIENV->asConstant(JVMCIENV->wrap(lambda_form_handle), JVMCI_CHECK); - if (lambda_form->is_a(SystemDictionary::LambdaForm_klass())) { + if (lambda_form->is_a(vmClasses::LambdaForm_klass())) { TempNewSymbol compileToBytecode = SymbolTable::new_symbol("compileToBytecode"); JavaValue result(T_VOID); - JavaCalls::call_special(&result, lambda_form, SystemDictionary::LambdaForm_klass(), compileToBytecode, vmSymbols::void_method_signature(), CHECK); + JavaCalls::call_special(&result, lambda_form, vmClasses::LambdaForm_klass(), compileToBytecode, vmSymbols::void_method_signature(), CHECK); } else { JVMCI_THROW_MSG(IllegalArgumentException, err_msg("Unexpected type: %s", lambda_form->klass()->external_name())) @@ -1874,7 +1876,7 @@ C2V_VMENTRY_NULL(jobject, boxPrimitive, (JNIEnv* env, jobject, jobject object)) #define BOX_CASE(bt, v, argtype, name) \ case bt: \ jargs.push_##argtype(value.v); \ - box_klass = SystemDictionary::name##_klass(); \ + box_klass = vmClasses::name##_klass(); \ box_signature = vmSymbols::name##_valueOf_signature(); \ break @@ -2659,7 +2661,7 @@ C2V_VMENTRY(void, callSystemExit, (JNIEnv* env, jobject, jint status)) JavaCallArguments jargs(1); jargs.push_int(status); JavaCalls::call_static(&result, - SystemDictionary::System_klass(), + vmClasses::System_klass(), vmSymbols::exit_method_name(), vmSymbols::int_void_signature(), &jargs, diff --git a/src/hotspot/share/jvmci/jvmciEnv.cpp b/src/hotspot/share/jvmci/jvmciEnv.cpp index 6e9470a1f6799..29c178a7fa4ab 100644 --- a/src/hotspot/share/jvmci/jvmciEnv.cpp +++ b/src/hotspot/share/jvmci/jvmciEnv.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ #include "jvm_io.h" #include "classfile/stringTable.hpp" #include "classfile/symbolTable.hpp" +#include "classfile/systemDictionary.hpp" #include "code/codeCache.hpp" #include "compiler/compileTask.hpp" #include "memory/oopFactory.hpp" diff --git a/src/hotspot/share/jvmci/jvmciJavaClasses.cpp b/src/hotspot/share/jvmci/jvmciJavaClasses.cpp index 0e75127da3b68..58ac9ad2a3d8f 100644 --- a/src/hotspot/share/jvmci/jvmciJavaClasses.cpp +++ b/src/hotspot/share/jvmci/jvmciJavaClasses.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,6 +23,8 @@ #include "precompiled.hpp" #include "classfile/symbolTable.hpp" +#include "classfile/systemDictionary.hpp" +#include "classfile/vmClasses.hpp" #include "interpreter/linkResolver.hpp" #include "jvmci/jniAccessMark.inline.hpp" #include "jvmci/jvmciJavaClasses.hpp" @@ -385,7 +387,7 @@ class ThrowableInitDumper : public SymbolClosure { Klass* k = SystemDictionary::resolve_or_null(name, CHECK_EXIT); if (k != NULL && k->is_instance_klass()) { InstanceKlass* iklass = InstanceKlass::cast(k); - if (iklass->is_subclass_of(SystemDictionary::Throwable_klass()) && iklass->is_public() && !iklass->is_abstract()) { + if (iklass->is_subclass_of(vmClasses::Throwable_klass()) && iklass->is_public() && !iklass->is_abstract()) { const char* class_name = NULL; Array* methods = iklass->methods(); for (int i = 0; i < methods->length(); i++) { diff --git a/src/hotspot/share/jvmci/jvmciRuntime.cpp b/src/hotspot/share/jvmci/jvmciRuntime.cpp index 37d5990b34e29..2d0c5b6881b5f 100644 --- a/src/hotspot/share/jvmci/jvmciRuntime.cpp +++ b/src/hotspot/share/jvmci/jvmciRuntime.cpp @@ -24,6 +24,8 @@ #include "precompiled.hpp" #include "classfile/javaClasses.inline.hpp" #include "classfile/symbolTable.hpp" +#include "classfile/systemDictionary.hpp" +#include "classfile/vmClasses.hpp" #include "compiler/compileBroker.hpp" #include "gc/shared/oopStorage.inline.hpp" #include "jvmci/jniAccessMark.inline.hpp" @@ -260,7 +262,7 @@ JRT_ENTRY_NO_ASYNC(static address, exception_handler_for_pc_helper(JavaThread* t assert(exception.not_null(), "NULL exceptions should be handled by throw_exception"); assert(oopDesc::is_oop(exception()), "just checking"); // Check that exception is a subclass of Throwable - assert(exception->is_a(SystemDictionary::Throwable_klass()), + assert(exception->is_a(vmClasses::Throwable_klass()), "Exception not subclass of Throwable"); // debugging support @@ -1071,7 +1073,7 @@ void JVMCIRuntime::describe_pending_hotspot_exception(JavaThread* THREAD, bool c const char* exception_file = THREAD->exception_file(); int exception_line = THREAD->exception_line(); CLEAR_PENDING_EXCEPTION; - if (exception->is_a(SystemDictionary::ThreadDeath_klass())) { + if (exception->is_a(vmClasses::ThreadDeath_klass())) { // Don't print anything if we are being killed. } else { java_lang_Throwable::print_stack_trace(exception, tty); @@ -1376,7 +1378,7 @@ Method* JVMCIRuntime::get_method_by_index_impl(const constantPoolHandle& cpool, Symbol* sig_sym = cpool->signature_ref_at(index); if (cpool->has_preresolution() - || ((holder == SystemDictionary::MethodHandle_klass() || holder == SystemDictionary::VarHandle_klass()) && + || ((holder == vmClasses::MethodHandle_klass() || holder == vmClasses::VarHandle_klass()) && MethodHandles::is_signature_polymorphic_name(holder, name_sym))) { // Short-circuit lookups for JSR 292-related call sites. // That is, do not rely only on name-based lookups, because they may fail @@ -1421,7 +1423,7 @@ InstanceKlass* JVMCIRuntime::get_instance_klass_for_declared_method_holder(Klass if (method_holder->is_instance_klass()) { return InstanceKlass::cast(method_holder); } else if (method_holder->is_array_klass()) { - return SystemDictionary::Object_klass(); + return vmClasses::Object_klass(); } else { ShouldNotReachHere(); } diff --git a/src/hotspot/share/memory/archiveUtils.cpp b/src/hotspot/share/memory/archiveUtils.cpp index 4474519fd7203..3f1d59f1aeda9 100644 --- a/src/hotspot/share/memory/archiveUtils.cpp +++ b/src/hotspot/share/memory/archiveUtils.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ #include "classfile/classListParser.hpp" #include "classfile/classListWriter.hpp" #include "classfile/systemDictionaryShared.hpp" +#include "classfile/vmClasses.hpp" #include "interpreter/bootstrapInfo.hpp" #include "memory/archiveUtils.hpp" #include "memory/dynamicArchive.hpp" @@ -322,7 +323,7 @@ void ArchiveUtils::log_to_classlist(BootstrapInfo* bootstrap_specifier, TRAPS) { void ArchiveUtils::check_for_oom(oop exception) { assert(exception != nullptr, "Sanity check"); - if (exception->is_a(SystemDictionary::OutOfMemoryError_klass())) { + if (exception->is_a(vmClasses::OutOfMemoryError_klass())) { vm_direct_exit(-1, err_msg("Out of memory. Please run with a larger Java heap, current MaxHeapSize = " SIZE_FORMAT "M", MaxHeapSize/M)); diff --git a/src/hotspot/share/memory/heapInspection.cpp b/src/hotspot/share/memory/heapInspection.cpp index d2f71c4cdd00c..6a21a3c417c49 100644 --- a/src/hotspot/share/memory/heapInspection.cpp +++ b/src/hotspot/share/memory/heapInspection.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,7 @@ #include "classfile/classLoaderData.inline.hpp" #include "classfile/classLoaderDataGraph.hpp" #include "classfile/moduleEntry.hpp" -#include "classfile/systemDictionary.hpp" +#include "classfile/vmClasses.hpp" #include "gc/shared/collectedHeap.hpp" #include "logging/log.hpp" #include "logging/logTag.hpp" @@ -374,7 +374,7 @@ void KlassHierarchy::print_class_hierarchy(outputStream* st, bool print_interfac // Now we do a depth first traversal of the class hierachry. The class_stack will // maintain the list of classes we still need to process. Start things off // by priming it with java.lang.Object. - KlassInfoEntry* jlo_cie = cit.lookup(SystemDictionary::Object_klass()); + KlassInfoEntry* jlo_cie = cit.lookup(vmClasses::Object_klass()); assert(jlo_cie != NULL, "could not lookup java.lang.Object"); class_stack.push(jlo_cie); diff --git a/src/hotspot/share/memory/heapShared.cpp b/src/hotspot/share/memory/heapShared.cpp index 3477190dffb57..7edaa489225de 100644 --- a/src/hotspot/share/memory/heapShared.cpp +++ b/src/hotspot/share/memory/heapShared.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,6 +31,7 @@ #include "classfile/symbolTable.hpp" #include "classfile/systemDictionary.hpp" #include "classfile/systemDictionaryShared.hpp" +#include "classfile/vmClasses.hpp" #include "classfile/vmSymbols.hpp" #include "gc/shared/gcLocker.hpp" #include "gc/shared/gcVMOperations.hpp" @@ -504,10 +505,10 @@ void KlassSubGraphInfo::add_subgraph_object_klass(Klass* orig_k, Klass* relocate if (relocated_k->is_instance_klass()) { assert(InstanceKlass::cast(relocated_k)->is_shared_boot_class(), "must be boot class"); - // SystemDictionary::xxx_klass() are not updated, need to check + // vmClasses::xxx_klass() are not updated, need to check // the original Klass* - if (orig_k == SystemDictionary::String_klass() || - orig_k == SystemDictionary::Object_klass()) { + if (orig_k == vmClasses::String_klass() || + orig_k == vmClasses::Object_klass()) { // Initialized early during VM initialization. No need to be added // to the sub-graph object class list. return; diff --git a/src/hotspot/share/memory/oopFactory.cpp b/src/hotspot/share/memory/oopFactory.cpp index 384f40c07cfd7..89f1a215b56de 100644 --- a/src/hotspot/share/memory/oopFactory.cpp +++ b/src/hotspot/share/memory/oopFactory.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,6 @@ #include "precompiled.hpp" #include "classfile/javaClasses.hpp" #include "classfile/symbolTable.hpp" -#include "classfile/systemDictionary.hpp" #include "classfile/vmSymbols.hpp" #include "gc/shared/collectedHeap.inline.hpp" #include "memory/oopFactory.hpp" diff --git a/src/hotspot/share/memory/universe.cpp b/src/hotspot/share/memory/universe.cpp index e69d34ef94acc..80bc2c2aa6462 100644 --- a/src/hotspot/share/memory/universe.cpp +++ b/src/hotspot/share/memory/universe.cpp @@ -30,6 +30,7 @@ #include "classfile/stringTable.hpp" #include "classfile/symbolTable.hpp" #include "classfile/systemDictionary.hpp" +#include "classfile/vmClasses.hpp" #include "classfile/vmSymbols.hpp" #include "code/codeBehaviours.hpp" #include "code/codeCache.hpp" @@ -279,7 +280,7 @@ void Universe::check_alignment(uintx size, uintx alignment, const char* name) { } void initialize_basic_type_klass(Klass* k, TRAPS) { - Klass* ok = SystemDictionary::Object_klass(); + Klass* ok = vmClasses::Object_klass(); #if INCLUDE_CDS if (UseSharedSpaces) { ClassLoaderData* loader_data = ClassLoaderData::the_null_class_loader_data(); @@ -341,15 +342,15 @@ void Universe::genesis(TRAPS) { if (UseSharedSpaces) { // Verify shared interfaces array. assert(_the_array_interfaces_array->at(0) == - SystemDictionary::Cloneable_klass(), "u3"); + vmClasses::Cloneable_klass(), "u3"); assert(_the_array_interfaces_array->at(1) == - SystemDictionary::Serializable_klass(), "u3"); + vmClasses::Serializable_klass(), "u3"); } else #endif { // Set up shared interfaces array. (Do this before supers are set up.) - _the_array_interfaces_array->at_put(0, SystemDictionary::Cloneable_klass()); - _the_array_interfaces_array->at_put(1, SystemDictionary::Serializable_klass()); + _the_array_interfaces_array->at_put(0, vmClasses::Cloneable_klass()); + _the_array_interfaces_array->at_put(1, vmClasses::Serializable_klass()); } initialize_basic_type_klass(boolArrayKlassObj(), CHECK); @@ -383,7 +384,7 @@ void Universe::genesis(TRAPS) { // SystemDictionary::initialize(CHECK); is run. See the extra check // for Object_klass_loaded in objArrayKlassKlass::allocate_objArray_klass_impl. _objectArrayKlassObj = InstanceKlass:: - cast(SystemDictionary::Object_klass())->array_klass(1, CHECK); + cast(vmClasses::Object_klass())->array_klass(1, CHECK); // OLD // Add the class to the class hierarchy manually to make sure that // its vtable is initialized after core bootstrapping is completed. @@ -404,12 +405,12 @@ void Universe::genesis(TRAPS) { // moves these objects to the bottom of the old generation. int size = FullGCALotDummies * 2; - objArrayOop naked_array = oopFactory::new_objArray(SystemDictionary::Object_klass(), size, CHECK); + objArrayOop naked_array = oopFactory::new_objArray(vmClasses::Object_klass(), size, CHECK); objArrayHandle dummy_array(THREAD, naked_array); int i = 0; while (i < size) { // Allocate dummy in old generation - oop dummy = SystemDictionary::Object_klass()->allocate_instance(CHECK); + oop dummy = vmClasses::Object_klass()->allocate_instance(CHECK); dummy_array->obj_at_put(i++, dummy); } { @@ -459,7 +460,7 @@ void Universe::fixup_mirrors(TRAPS) { // but we cannot do that for classes created before java.lang.Class is loaded. Here we simply // walk over permanent objects created so far (mostly classes) and fixup their mirrors. Note // that the number of objects allocated at this point is very small. - assert(SystemDictionary::Class_klass_loaded(), "java.lang.Class should be loaded"); + assert(vmClasses::Class_klass_loaded(), "java.lang.Class should be loaded"); HandleMark hm(THREAD); if (!UseSharedSpaces) { @@ -527,7 +528,7 @@ void Universe::reinitialize_vtables(TRAPS) { // The vtables are initialized by starting at java.lang.Object and // initializing through the subclass links, so that the super // classes are always initialized first. - Klass* ok = SystemDictionary::Object_klass(); + Klass* ok = vmClasses::Object_klass(); Universe::reinitialize_vtable_of(ok, THREAD); } @@ -612,7 +613,7 @@ oop Universe::gen_out_of_memory_error(oop default_err) { // - otherwise, return the default error, without a stack trace. int next; if ((_preallocated_out_of_memory_error_avail_count > 0) && - SystemDictionary::Throwable_klass()->is_initialized()) { + vmClasses::Throwable_klass()->is_initialized()) { next = (int)Atomic::add(&_preallocated_out_of_memory_error_avail_count, -1); assert(next < (int)PreallocatedOutOfMemoryErrorCount, "avail count is corrupt"); } else { @@ -644,7 +645,7 @@ oop Universe::gen_out_of_memory_error(oop default_err) { // Setup preallocated OutOfMemoryError errors void Universe::create_preallocated_out_of_memory_errors(TRAPS) { - InstanceKlass* ik = SystemDictionary::OutOfMemoryError_klass(); + InstanceKlass* ik = vmClasses::OutOfMemoryError_klass(); objArrayOop oa = oopFactory::new_objArray(ik, _oom_count, CHECK); objArrayHandle oom_array(THREAD, oa); @@ -898,29 +899,29 @@ void initialize_known_method(LatestMethodCache* method_cache, void Universe::initialize_known_methods(TRAPS) { // Set up static method for registering finalizers initialize_known_method(_finalizer_register_cache, - SystemDictionary::Finalizer_klass(), + vmClasses::Finalizer_klass(), "register", vmSymbols::object_void_signature(), true, CHECK); initialize_known_method(_throw_illegal_access_error_cache, - SystemDictionary::internal_Unsafe_klass(), + vmClasses::internal_Unsafe_klass(), "throwIllegalAccessError", vmSymbols::void_method_signature(), true, CHECK); initialize_known_method(_throw_no_such_method_error_cache, - SystemDictionary::internal_Unsafe_klass(), + vmClasses::internal_Unsafe_klass(), "throwNoSuchMethodError", vmSymbols::void_method_signature(), true, CHECK); // Set up method for registering loaded classes in class loader vector initialize_known_method(_loader_addClass_cache, - SystemDictionary::ClassLoader_klass(), + vmClasses::ClassLoader_klass(), "addClass", vmSymbols::class_void_signature(), false, CHECK); // Set up method for stack walking initialize_known_method(_do_stack_walk_cache, - SystemDictionary::AbstractStackWalker_klass(), + vmClasses::AbstractStackWalker_klass(), "doStackWalk", vmSymbols::doStackWalk_signature(), false, CHECK); } @@ -948,7 +949,7 @@ bool universe_post_init() { HandleMark hm(THREAD); // Setup preallocated empty java.lang.Class array for Method reflection. - objArrayOop the_empty_class_array = oopFactory::new_objArray(SystemDictionary::Class_klass(), 0, CHECK_false); + objArrayOop the_empty_class_array = oopFactory::new_objArray(vmClasses::Class_klass(), 0, CHECK_false); Universe::_the_empty_class_array = OopHandle(Universe::vm_global(), the_empty_class_array); // Setup preallocated OutOfMemoryError errors @@ -974,7 +975,7 @@ bool universe_post_init() { Universe::_arithmetic_exception_instance = OopHandle(Universe::vm_global(), instance); // Virtual Machine Error for when we get into a situation we can't resolve - k = SystemDictionary::VirtualMachineError_klass(); + k = vmClasses::VirtualMachineError_klass(); bool linked = InstanceKlass::cast(k)->link_class_or_fail(CHECK_false); if (!linked) { tty->print_cr("Unable to link/verify VirtualMachineError class"); diff --git a/src/hotspot/share/oops/arrayKlass.cpp b/src/hotspot/share/oops/arrayKlass.cpp index c86f5c097d23f..1ff6e02701eb6 100644 --- a/src/hotspot/share/oops/arrayKlass.cpp +++ b/src/hotspot/share/oops/arrayKlass.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,7 @@ #include "precompiled.hpp" #include "classfile/javaClasses.hpp" #include "classfile/moduleEntry.hpp" -#include "classfile/systemDictionary.hpp" +#include "classfile/vmClasses.hpp" #include "classfile/vmSymbols.hpp" #include "gc/shared/collectedHeap.inline.hpp" #include "jvmtifiles/jvmti.h" @@ -55,7 +55,7 @@ InstanceKlass* ArrayKlass::java_super() const { if (super() == NULL) return NULL; // bootstrap case // Array klasses have primary supertypes which are not reported to Java. // Example super chain: String[][] -> Object[][] -> Object[] -> Object - return SystemDictionary::Object_klass(); + return vmClasses::Object_klass(); } @@ -92,7 +92,7 @@ ArrayKlass::ArrayKlass(Symbol* name, KlassID id) : // the vtable of klass Object. set_vtable_length(Universe::base_vtable_size()); set_name(name); - set_super(Universe::is_bootstrapping() ? NULL : SystemDictionary::Object_klass()); + set_super(Universe::is_bootstrapping() ? NULL : vmClasses::Object_klass()); set_layout_helper(Klass::_lh_neutral_value); set_is_cloneable(); // All arrays are considered to be cloneable (See JLS 20.1.5) JFR_ONLY(INIT_ID(this);) diff --git a/src/hotspot/share/oops/arrayKlass.hpp b/src/hotspot/share/oops/arrayKlass.hpp index 913d2174b0f63..76cbc5e4bd5c5 100644 --- a/src/hotspot/share/oops/arrayKlass.hpp +++ b/src/hotspot/share/oops/arrayKlass.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -70,7 +70,7 @@ class ArrayKlass: public Klass { // type of elements (T_OBJECT for both oop arrays and array-arrays) BasicType element_type() const { return layout_helper_element_type(layout_helper()); } - virtual InstanceKlass* java_super() const;//{ return SystemDictionary::Object_klass(); } + virtual InstanceKlass* java_super() const; // Allocation // Sizes points to the first dimension of the array, subsequent dimensions diff --git a/src/hotspot/share/oops/constantPool.cpp b/src/hotspot/share/oops/constantPool.cpp index a33e8e37228ab..2becf0d8ad834 100644 --- a/src/hotspot/share/oops/constantPool.cpp +++ b/src/hotspot/share/oops/constantPool.cpp @@ -29,6 +29,7 @@ #include "classfile/metadataOnStackMark.hpp" #include "classfile/stringTable.hpp" #include "classfile/systemDictionary.hpp" +#include "classfile/vmClasses.hpp" #include "classfile/vmSymbols.hpp" #include "interpreter/bootstrapInfo.hpp" #include "interpreter/linkResolver.hpp" @@ -196,7 +197,7 @@ void ConstantPool::initialize_resolved_references(ClassLoaderData* loader_data, // Create Java array for holding resolved strings, methodHandles, // methodTypes, invokedynamic and invokehandle appendix objects, etc. - objArrayOop stom = oopFactory::new_objArray(SystemDictionary::Object_klass(), map_length, CHECK); + objArrayOop stom = oopFactory::new_objArray(vmClasses::Object_klass(), map_length, CHECK); Handle refs_handle (THREAD, (oop)stom); // must handleize. set_resolved_references(loader_data->add_handle(refs_handle)); } @@ -364,7 +365,7 @@ void ConstantPool::restore_unshareable_info(TRAPS) { // restore the C++ vtable from the shared archive restore_vtable(); - if (SystemDictionary::Object_klass_loaded()) { + if (vmClasses::Object_klass_loaded()) { ClassLoaderData* loader_data = pool_holder()->class_loader_data(); #if INCLUDE_CDS_JAVA_HEAP if (HeapShared::open_archive_heap_region_mapped() && @@ -381,7 +382,7 @@ void ConstantPool::restore_unshareable_info(TRAPS) { // Recreate the object array and add to ClassLoaderData. int map_length = resolved_reference_length(); if (map_length > 0) { - objArrayOop stom = oopFactory::new_objArray(SystemDictionary::Object_klass(), map_length, CHECK); + objArrayOop stom = oopFactory::new_objArray(vmClasses::Object_klass(), map_length, CHECK); Handle refs_handle(THREAD, (oop)stom); // must handleize. set_resolved_references(loader_data->add_handle(refs_handle)); } @@ -821,7 +822,7 @@ void ConstantPool::save_and_throw_exception(const constantPoolHandle& this_cp, i int error_tag = tag.error_value(); if (!PENDING_EXCEPTION-> - is_a(SystemDictionary::LinkageError_klass())) { + is_a(vmClasses::LinkageError_klass())) { // Just throw the exception and don't prevent these classes from // being loaded due to virtual machine errors like StackOverflow // and OutOfMemoryError, etc, or if the thread was hit by stop() diff --git a/src/hotspot/share/oops/cpCache.cpp b/src/hotspot/share/oops/cpCache.cpp index 7e478d5a65550..35a159919ce0c 100644 --- a/src/hotspot/share/oops/cpCache.cpp +++ b/src/hotspot/share/oops/cpCache.cpp @@ -24,6 +24,8 @@ #include "precompiled.hpp" #include "classfile/resolutionErrors.hpp" +#include "classfile/systemDictionary.hpp" +#include "classfile/vmClasses.hpp" #include "interpreter/bytecodeStream.hpp" #include "interpreter/bytecodes.hpp" #include "interpreter/interpreter.hpp" @@ -202,7 +204,7 @@ void ConstantPoolCacheEntry::set_direct_or_vtable_call(Bytecodes::Code invoke_co // or when invokeinterface is used explicitly. // In that case, the method has no itable index and must be invoked as a virtual. // Set a flag to keep track of this corner case. - assert(holder->is_interface() || holder == SystemDictionary::Object_klass(), "unexpected holder class"); + assert(holder->is_interface() || holder == vmClasses::Object_klass(), "unexpected holder class"); assert(method->is_public(), "Calling non-public method in Object with invokeinterface"); change_to_virtual = true; @@ -304,7 +306,7 @@ void ConstantPoolCacheEntry::set_direct_or_vtable_call(Bytecodes::Code invoke_co assert(invoke_code == Bytecodes::_invokevirtual || (invoke_code == Bytecodes::_invokeinterface && ((method->is_private() || - (method->is_final() && method->method_holder() == SystemDictionary::Object_klass())))), + (method->is_final() && method->method_holder() == vmClasses::Object_klass())))), "unexpected invocation mode"); if (invoke_code == Bytecodes::_invokeinterface && (method->is_private() || method->is_final())) { @@ -475,7 +477,7 @@ bool ConstantPoolCacheEntry::save_and_throw_indy_exc( const constantPoolHandle& cpool, int cpool_index, int index, constantTag tag, TRAPS) { assert(HAS_PENDING_EXCEPTION, "No exception got thrown!"); - assert(PENDING_EXCEPTION->is_a(SystemDictionary::LinkageError_klass()), + assert(PENDING_EXCEPTION->is_a(vmClasses::LinkageError_klass()), "No LinkageError exception"); // Use the resolved_references() lock for this cpCache entry. diff --git a/src/hotspot/share/oops/instanceKlass.cpp b/src/hotspot/share/oops/instanceKlass.cpp index 9fd1d2070d45d..38aed251bf712 100644 --- a/src/hotspot/share/oops/instanceKlass.cpp +++ b/src/hotspot/share/oops/instanceKlass.cpp @@ -37,6 +37,7 @@ #include "classfile/systemDictionary.hpp" #include "classfile/systemDictionaryShared.hpp" #include "classfile/verifier.hpp" +#include "classfile/vmClasses.hpp" #include "classfile/vmSymbols.hpp" #include "code/dependencyContext.hpp" #include "compiler/compilationPolicy.hpp" @@ -149,10 +150,10 @@ static inline bool is_class_loader(const Symbol* class_name, return true; } - if (SystemDictionary::ClassLoader_klass_loaded()) { + if (vmClasses::ClassLoader_klass_loaded()) { const Klass* const super_klass = parser.super_klass(); if (super_klass != NULL) { - if (super_klass->is_subtype_of(SystemDictionary::ClassLoader_klass())) { + if (super_klass->is_subtype_of(vmClasses::ClassLoader_klass())) { return true; } } @@ -186,7 +187,7 @@ bool InstanceKlass::has_nest_member(InstanceKlass* k, TRAPS) const { int cp_index = _nest_members->at(i); if (_constants->tag_at(cp_index).is_klass()) { Klass* k2 = _constants->klass_at(cp_index, THREAD); - assert(!HAS_PENDING_EXCEPTION || PENDING_EXCEPTION->is_a(SystemDictionary::VirtualMachineError_klass()), + assert(!HAS_PENDING_EXCEPTION || PENDING_EXCEPTION->is_a(vmClasses::VirtualMachineError_klass()), "Exceptions should not be possible here"); if (k2 == k) { log_trace(class, nestmates)("- class is listed at nest_members[%d] => cp[%d]", i, cp_index); @@ -204,7 +205,7 @@ bool InstanceKlass::has_nest_member(InstanceKlass* k, TRAPS) const { // able to perform that loading but we can't exclude the compiler threads from // executing this logic. But it should actually be impossible to trigger loading here. Klass* k2 = _constants->klass_at(cp_index, THREAD); - assert(!HAS_PENDING_EXCEPTION || PENDING_EXCEPTION->is_a(SystemDictionary::VirtualMachineError_klass()), + assert(!HAS_PENDING_EXCEPTION || PENDING_EXCEPTION->is_a(vmClasses::VirtualMachineError_klass()), "Exceptions should not be possible here"); if (k2 == k) { log_trace(class, nestmates)("- class is listed as a nest member"); @@ -299,7 +300,7 @@ InstanceKlass* InstanceKlass::nest_host(TRAPS) { Klass* k = _constants->klass_at(_nest_host_index, THREAD); if (HAS_PENDING_EXCEPTION) { - if (PENDING_EXCEPTION->is_a(SystemDictionary::VirtualMachineError_klass())) { + if (PENDING_EXCEPTION->is_a(vmClasses::VirtualMachineError_klass())) { return NULL; // propagate VMEs } stringStream ss; @@ -338,7 +339,7 @@ InstanceKlass* InstanceKlass::nest_host(TRAPS) { error = "current type is not listed as a nest member"; } } else { - if (PENDING_EXCEPTION->is_a(SystemDictionary::VirtualMachineError_klass())) { + if (PENDING_EXCEPTION->is_a(vmClasses::VirtualMachineError_klass())) { return NULL; // propagate VMEs } stringStream ss; @@ -732,7 +733,7 @@ void InstanceKlass::deallocate_contents(ClassLoaderData* loader_data) { bool InstanceKlass::is_record() const { return _record_components != NULL && is_final() && - java_super() == SystemDictionary::Record_klass(); + java_super() == vmClasses::Record_klass(); } bool InstanceKlass::is_sealed() const { @@ -1194,7 +1195,7 @@ void InstanceKlass::initialize_impl(TRAPS) { JvmtiExport::clear_detected_exception(jt); } DTRACE_CLASSINIT_PROBE_WAIT(error, -1, wait); - if (e->is_a(SystemDictionary::Error_klass())) { + if (e->is_a(vmClasses::Error_klass())) { THROW_OOP(e()); } else { JavaCallArguments args(e); @@ -1424,7 +1425,7 @@ void InstanceKlass::check_valid_for_instantiation(bool throwError, TRAPS) { THROW_MSG(throwError ? vmSymbols::java_lang_InstantiationError() : vmSymbols::java_lang_InstantiationException(), external_name()); } - if (this == SystemDictionary::Class_klass()) { + if (this == vmClasses::Class_klass()) { ResourceMark rm(THREAD); THROW_MSG(throwError ? vmSymbols::java_lang_IllegalAccessError() : vmSymbols::java_lang_IllegalAccessException(), external_name()); @@ -3522,7 +3523,7 @@ void FieldPrinter::do_field(fieldDescriptor* fd) { void InstanceKlass::oop_print_on(oop obj, outputStream* st) { Klass::oop_print_on(obj, st); - if (this == SystemDictionary::String_klass()) { + if (this == vmClasses::String_klass()) { typeArrayOop value = java_lang_String::value(obj); juint length = java_lang_String::length(obj); if (value != NULL && @@ -3539,7 +3540,7 @@ void InstanceKlass::oop_print_on(oop obj, outputStream* st) { FieldPrinter print_field(st, obj); do_nonstatic_fields(&print_field); - if (this == SystemDictionary::Class_klass()) { + if (this == vmClasses::Class_klass()) { st->print(BULLET"signature: "); java_lang_Class::print_signature(obj, st); st->cr(); @@ -3557,7 +3558,7 @@ void InstanceKlass::oop_print_on(oop obj, outputStream* st) { if (real_klass != NULL && real_klass->is_instance_klass()) { InstanceKlass::cast(real_klass)->do_local_static_fields(&print_field); } - } else if (this == SystemDictionary::MethodType_klass()) { + } else if (this == vmClasses::MethodType_klass()) { st->print(BULLET"signature: "); java_lang_invoke_MethodType::print_signature(obj, st); st->cr(); @@ -3576,7 +3577,7 @@ void InstanceKlass::oop_print_value_on(oop obj, outputStream* st) { st->print("a "); name()->print_value_on(st); obj->print_address_on(st); - if (this == SystemDictionary::String_klass() + if (this == vmClasses::String_klass() && java_lang_String::value(obj) != NULL) { ResourceMark rm; int len = java_lang_String::length(obj); @@ -3585,7 +3586,7 @@ void InstanceKlass::oop_print_value_on(oop obj, outputStream* st) { st->print(" = \"%s\"", str); if (len > plen) st->print("...[%d]", len); - } else if (this == SystemDictionary::Class_klass()) { + } else if (this == vmClasses::Class_klass()) { Klass* k = java_lang_Class::as_Klass(obj); st->print(" = "); if (k != NULL) { @@ -3594,19 +3595,19 @@ void InstanceKlass::oop_print_value_on(oop obj, outputStream* st) { const char* tname = type2name(java_lang_Class::primitive_type(obj)); st->print("%s", tname ? tname : "type?"); } - } else if (this == SystemDictionary::MethodType_klass()) { + } else if (this == vmClasses::MethodType_klass()) { st->print(" = "); java_lang_invoke_MethodType::print_signature(obj, st); } else if (java_lang_boxing_object::is_instance(obj)) { st->print(" = "); java_lang_boxing_object::print(obj, st); - } else if (this == SystemDictionary::LambdaForm_klass()) { + } else if (this == vmClasses::LambdaForm_klass()) { oop vmentry = java_lang_invoke_LambdaForm::vmentry(obj); if (vmentry != NULL) { st->print(" => "); vmentry->print_value_on(st); } - } else if (this == SystemDictionary::MemberName_klass()) { + } else if (this == vmClasses::MemberName_klass()) { Metadata* vmtarget = java_lang_invoke_MemberName::vmtarget(obj); if (vmtarget != NULL) { st->print(" = "); diff --git a/src/hotspot/share/oops/instanceMirrorKlass.cpp b/src/hotspot/share/oops/instanceMirrorKlass.cpp index 80281678fa998..3e267eaf95bc4 100644 --- a/src/hotspot/share/oops/instanceMirrorKlass.cpp +++ b/src/hotspot/share/oops/instanceMirrorKlass.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,6 @@ #include "precompiled.hpp" #include "classfile/javaClasses.inline.hpp" -#include "classfile/systemDictionary.hpp" #include "gc/shared/collectedHeap.inline.hpp" #include "memory/iterator.inline.hpp" #include "memory/oopFactory.hpp" diff --git a/src/hotspot/share/oops/instanceMirrorKlass.hpp b/src/hotspot/share/oops/instanceMirrorKlass.hpp index 9657ad43f858e..d5a7be454a158 100644 --- a/src/hotspot/share/oops/instanceMirrorKlass.hpp +++ b/src/hotspot/share/oops/instanceMirrorKlass.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,7 @@ #ifndef SHARE_OOPS_INSTANCEMIRRORKLASS_HPP #define SHARE_OOPS_INSTANCEMIRRORKLASS_HPP -#include "classfile/systemDictionary.hpp" +#include "classfile/vmClasses.hpp" #include "oops/instanceKlass.hpp" #include "runtime/handles.hpp" #include "utilities/macros.hpp" @@ -76,7 +76,7 @@ class InstanceMirrorKlass: public InstanceKlass { static void init_offset_of_static_fields() { // Cache the offset of the static fields in the Class instance assert(_offset_of_static_fields == 0, "once"); - _offset_of_static_fields = InstanceMirrorKlass::cast(SystemDictionary::Class_klass())->size_helper() << LogHeapWordSize; + _offset_of_static_fields = InstanceMirrorKlass::cast(vmClasses::Class_klass())->size_helper() << LogHeapWordSize; } static int offset_of_static_fields() { diff --git a/src/hotspot/share/oops/instanceRefKlass.cpp b/src/hotspot/share/oops/instanceRefKlass.cpp index 4b30a8edfe6a0..aab23761e274b 100644 --- a/src/hotspot/share/oops/instanceRefKlass.cpp +++ b/src/hotspot/share/oops/instanceRefKlass.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ #include "precompiled.hpp" #include "classfile/javaClasses.hpp" -#include "classfile/systemDictionary.hpp" +#include "classfile/vmClasses.hpp" #include "oops/instanceRefKlass.inline.hpp" #include "oops/oop.inline.hpp" @@ -36,7 +36,7 @@ void InstanceRefKlass::update_nonstatic_oop_maps(Klass* k) { // Check that we have the right class debug_only(static bool first_time = true); - assert(k == SystemDictionary::Reference_klass() && first_time, + assert(k == vmClasses::Reference_klass() && first_time, "Invalid update of maps"); debug_only(first_time = false); assert(ik->nonstatic_oop_map_count() == 1, "just checking"); diff --git a/src/hotspot/share/oops/klass.cpp b/src/hotspot/share/oops/klass.cpp index ba067aed4708b..143172dfa247f 100644 --- a/src/hotspot/share/oops/klass.cpp +++ b/src/hotspot/share/oops/klass.cpp @@ -31,6 +31,7 @@ #include "classfile/moduleEntry.hpp" #include "classfile/systemDictionary.hpp" #include "classfile/systemDictionaryShared.hpp" +#include "classfile/vmClasses.hpp" #include "classfile/vmSymbols.hpp" #include "gc/shared/collectedHeap.inline.hpp" #include "logging/log.hpp" @@ -70,7 +71,7 @@ void Klass::replace_java_mirror(oop mirror) { bool Klass::is_cloneable() const { return _access_flags.is_cloneable_fast() || - is_subtype_of(SystemDictionary::Cloneable_klass()); + is_subtype_of(vmClasses::Cloneable_klass()); } void Klass::set_is_cloneable() { @@ -245,8 +246,8 @@ void Klass::initialize_supers(Klass* k, Array* transitive_interf set_super(NULL); _primary_supers[0] = this; assert(super_depth() == 0, "Object must already be initialized properly"); - } else if (k != super() || k == SystemDictionary::Object_klass()) { - assert(super() == NULL || super() == SystemDictionary::Object_klass(), + } else if (k != super() || k == vmClasses::Object_klass()) { + assert(super() == NULL || super() == vmClasses::Object_klass(), "initialize this only once to a non-trivial value"); set_super(k); Klass* sup = k; @@ -474,7 +475,7 @@ void Klass::clean_weak_klass_links(bool unloading_occurred, bool clean_alive_kla return; } - Klass* root = SystemDictionary::Object_klass(); + Klass* root = vmClasses::Object_klass(); Stack stack; stack.push(root); diff --git a/src/hotspot/share/oops/method.cpp b/src/hotspot/share/oops/method.cpp index f183dadcdc701..d785c8d34acb9 100644 --- a/src/hotspot/share/oops/method.cpp +++ b/src/hotspot/share/oops/method.cpp @@ -27,6 +27,7 @@ #include "classfile/metadataOnStackMark.hpp" #include "classfile/symbolTable.hpp" #include "classfile/systemDictionary.hpp" +#include "classfile/vmClasses.hpp" #include "code/codeCache.hpp" #include "code/debugInfoRec.hpp" #include "compiler/compilationPolicy.hpp" @@ -840,13 +841,13 @@ objArrayHandle Method::resolved_checked_exceptions_impl(Method* method, TRAPS) { return objArrayHandle(THREAD, Universe::the_empty_class_array()); } else { methodHandle h_this(THREAD, method); - objArrayOop m_oop = oopFactory::new_objArray(SystemDictionary::Class_klass(), length, CHECK_(objArrayHandle())); + objArrayOop m_oop = oopFactory::new_objArray(vmClasses::Class_klass(), length, CHECK_(objArrayHandle())); objArrayHandle mirrors (THREAD, m_oop); for (int i = 0; i < length; i++) { CheckedExceptionElement* table = h_this->checked_exceptions_start(); // recompute on each iteration, not gc safe Klass* k = h_this->constants()->klass_at(table[i].class_cp_index, CHECK_(objArrayHandle())); if (log_is_enabled(Warning, exceptions) && - !k->is_subclass_of(SystemDictionary::Throwable_klass())) { + !k->is_subclass_of(vmClasses::Throwable_klass())) { ResourceMark rm(THREAD); log_warning(exceptions)( "Class %s in throws clause of method %s is not a subtype of class java.lang.Throwable", @@ -1391,7 +1392,7 @@ bool Method::is_ignored_by_security_stack_walk() const { // This is Method.invoke() -- ignore it return true; } - if (method_holder()->is_subclass_of(SystemDictionary::reflect_MethodAccessorImpl_klass())) { + if (method_holder()->is_subclass_of(vmClasses::reflect_MethodAccessorImpl_klass())) { // This is an auxilary frame -- ignore it return true; } @@ -1436,7 +1437,7 @@ methodHandle Method::make_method_handle_intrinsic(vmIntrinsics::ID iid, ResourceMark rm(THREAD); methodHandle empty; - InstanceKlass* holder = SystemDictionary::MethodHandle_klass(); + InstanceKlass* holder = vmClasses::MethodHandle_klass(); Symbol* name = MethodHandles::signature_polymorphic_intrinsic_name(iid); assert(iid == MethodHandles::signature_polymorphic_name_id(name), ""); @@ -1724,8 +1725,8 @@ bool Method::load_signature_classes(const methodHandle& m, TRAPS) { // We are loading classes eagerly. If a ClassNotFoundException or // a LinkageError was generated, be sure to ignore it. if (HAS_PENDING_EXCEPTION) { - if (PENDING_EXCEPTION->is_a(SystemDictionary::ClassNotFoundException_klass()) || - PENDING_EXCEPTION->is_a(SystemDictionary::LinkageError_klass())) { + if (PENDING_EXCEPTION->is_a(vmClasses::ClassNotFoundException_klass()) || + PENDING_EXCEPTION->is_a(vmClasses::LinkageError_klass())) { CLEAR_PENDING_EXCEPTION; } else { return false; diff --git a/src/hotspot/share/oops/methodData.cpp b/src/hotspot/share/oops/methodData.cpp index 778487770d4c2..b97bd2168829d 100644 --- a/src/hotspot/share/oops/methodData.cpp +++ b/src/hotspot/share/oops/methodData.cpp @@ -24,7 +24,6 @@ #include "precompiled.hpp" #include "ci/ciMethodData.hpp" -#include "classfile/systemDictionary.hpp" #include "classfile/vmSymbols.hpp" #include "compiler/compilationPolicy.hpp" #include "compiler/compilerOracle.hpp" @@ -41,6 +40,7 @@ #include "runtime/handles.inline.hpp" #include "runtime/orderAccess.hpp" #include "runtime/safepointVerifiers.hpp" +#include "runtime/signature.hpp" #include "utilities/align.hpp" #include "utilities/copy.hpp" diff --git a/src/hotspot/share/oops/objArrayKlass.cpp b/src/hotspot/share/oops/objArrayKlass.cpp index 6c218d98e95fe..5feffa4924aa4 100644 --- a/src/hotspot/share/oops/objArrayKlass.cpp +++ b/src/hotspot/share/oops/objArrayKlass.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,7 @@ #include "classfile/moduleEntry.hpp" #include "classfile/packageEntry.hpp" #include "classfile/symbolTable.hpp" -#include "classfile/systemDictionary.hpp" +#include "classfile/vmClasses.hpp" #include "classfile/vmSymbols.hpp" #include "gc/shared/collectedHeap.inline.hpp" #include "memory/iterator.inline.hpp" @@ -59,7 +59,7 @@ ObjArrayKlass* ObjArrayKlass::allocate_objArray_klass(ClassLoaderData* loader_da // Eagerly allocate the direct array supertype. Klass* super_klass = NULL; - if (!Universe::is_bootstrapping() || SystemDictionary::Object_klass_loaded()) { + if (!Universe::is_bootstrapping() || vmClasses::Object_klass_loaded()) { Klass* element_super = element_klass->super(); if (element_super != NULL) { // The element type has a direct super. E.g., String[] has direct super of Object[]. @@ -92,7 +92,7 @@ ObjArrayKlass* ObjArrayKlass::allocate_objArray_klass(ClassLoaderData* loader_da } } else { // The element type is already Object. Object[] has direct super of Object. - super_klass = SystemDictionary::Object_klass(); + super_klass = vmClasses::Object_klass(); } } @@ -374,8 +374,8 @@ GrowableArray* ObjArrayKlass::compute_secondary_supers(int num_extra_slo return NULL; } else { GrowableArray* secondaries = new GrowableArray(num_elem_supers+2); - secondaries->push(SystemDictionary::Cloneable_klass()); - secondaries->push(SystemDictionary::Serializable_klass()); + secondaries->push(vmClasses::Cloneable_klass()); + secondaries->push(vmClasses::Serializable_klass()); for (int i = 0; i < num_elem_supers; i++) { Klass* elem_super = elem_supers->at(i); Klass* array_super = elem_super->array_klass_or_null(); diff --git a/src/hotspot/share/oops/reflectionAccessorImplKlassHelper.cpp b/src/hotspot/share/oops/reflectionAccessorImplKlassHelper.cpp index 41f5b297e304e..64e4e39208635 100644 --- a/src/hotspot/share/oops/reflectionAccessorImplKlassHelper.cpp +++ b/src/hotspot/share/oops/reflectionAccessorImplKlassHelper.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2018 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -24,8 +24,9 @@ */ #include "precompiled.hpp" -#include "classfile/systemDictionary.hpp" +#include "classfile/vmClasses.hpp" #include "memory/resourceArea.hpp" +#include "oops/instanceKlass.hpp" #include "oops/constantPool.hpp" #include "oops/reflectionAccessorImplKlassHelper.hpp" #include "utilities/constantTag.hpp" @@ -100,13 +101,13 @@ static bool classname_matches_prefix(const Klass* k, const char* prefix) { // Returns true if k is of type jdk/internal/reflect/GeneratedMethodAccessorXXX. bool ReflectionAccessorImplKlassHelper::is_generated_method_accessor(const InstanceKlass* k) { - return k->super() == SystemDictionary::reflect_MethodAccessorImpl_klass() && + return k->super() == vmClasses::reflect_MethodAccessorImpl_klass() && classname_matches_prefix(k, "jdk.internal.reflect.GeneratedMethodAccessor"); } // Returns true if k is of type jdk/internal/reflect/GeneratedConstructorAccessorXXX. bool ReflectionAccessorImplKlassHelper::is_generated_constructor_accessor(const InstanceKlass* k) { - return k->super() == SystemDictionary::reflect_ConstructorAccessorImpl_klass() && + return k->super() == vmClasses::reflect_ConstructorAccessorImpl_klass() && classname_matches_prefix(k, "jdk.internal.reflect.GeneratedConstructorAccessor"); } @@ -114,7 +115,7 @@ bool ReflectionAccessorImplKlassHelper::is_generated_constructor_accessor(const bool ReflectionAccessorImplKlassHelper::is_generated_method_serialization_constructor_accessor(const InstanceKlass* k) { // GeneratedSerializationConstructorAccessor is not a direct subclass of ConstructorAccessorImpl const Klass* sk = k->super(); - if (sk != NULL && sk->super() == SystemDictionary::reflect_ConstructorAccessorImpl_klass() && + if (sk != NULL && sk->super() == vmClasses::reflect_ConstructorAccessorImpl_klass() && classname_matches_prefix(k, "jdk.internal.reflect.GeneratedSerializationConstructorAccessor")) { return true; } diff --git a/src/hotspot/share/oops/typeArrayKlass.cpp b/src/hotspot/share/oops/typeArrayKlass.cpp index 3c3ea73087648..777de41a1219d 100644 --- a/src/hotspot/share/oops/typeArrayKlass.cpp +++ b/src/hotspot/share/oops/typeArrayKlass.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,6 @@ #include "classfile/moduleEntry.hpp" #include "classfile/packageEntry.hpp" #include "classfile/symbolTable.hpp" -#include "classfile/systemDictionary.hpp" #include "classfile/vmSymbols.hpp" #include "gc/shared/collectedHeap.hpp" #include "gc/shared/collectedHeap.inline.hpp" diff --git a/src/hotspot/share/opto/bytecodeInfo.cpp b/src/hotspot/share/opto/bytecodeInfo.cpp index 10ff5860d3334..b934bf2b1f8aa 100644 --- a/src/hotspot/share/opto/bytecodeInfo.cpp +++ b/src/hotspot/share/opto/bytecodeInfo.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,6 @@ #include "precompiled.hpp" #include "ci/ciReplay.hpp" -#include "classfile/systemDictionary.hpp" #include "classfile/vmSymbols.hpp" #include "compiler/compileBroker.hpp" #include "compiler/compilerEvent.hpp" diff --git a/src/hotspot/share/opto/c2compiler.cpp b/src/hotspot/share/opto/c2compiler.cpp index ce3327509a38e..89b0270ab722e 100644 --- a/src/hotspot/share/opto/c2compiler.cpp +++ b/src/hotspot/share/opto/c2compiler.cpp @@ -23,7 +23,7 @@ */ #include "precompiled.hpp" -#include "classfile/systemDictionary.hpp" +#include "classfile/vmClasses.hpp" #include "runtime/handles.inline.hpp" #include "jfr/support/jfrIntrinsics.hpp" #include "opto/c2compiler.hpp" @@ -410,7 +410,7 @@ bool C2Compiler::is_intrinsic_supported(const methodHandle& method, bool is_virt if (!Matcher::match_rule_supported(Op_MulHiL)) return false; break; case vmIntrinsics::_getCallerClass: - if (SystemDictionary::reflect_CallerSensitive_klass() == NULL) return false; + if (vmClasses::reflect_CallerSensitive_klass() == NULL) return false; break; case vmIntrinsics::_onSpinWait: if (!Matcher::match_rule_supported(Op_OnSpinWait)) return false; diff --git a/src/hotspot/share/opto/cfgnode.cpp b/src/hotspot/share/opto/cfgnode.cpp index 67f02bc9ee71e..a7a8fa0fe1385 100644 --- a/src/hotspot/share/opto/cfgnode.cpp +++ b/src/hotspot/share/opto/cfgnode.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,6 @@ */ #include "precompiled.hpp" -#include "classfile/systemDictionary.hpp" #include "gc/shared/barrierSet.hpp" #include "gc/shared/c2/barrierSetC2.hpp" #include "memory/allocation.inline.hpp" diff --git a/src/hotspot/share/opto/library_call.cpp b/src/hotspot/share/opto/library_call.cpp index a1bab02f40c2c..c147e0ffbb785 100644 --- a/src/hotspot/share/opto/library_call.cpp +++ b/src/hotspot/share/opto/library_call.cpp @@ -25,7 +25,6 @@ #include "precompiled.hpp" #include "asm/macroAssembler.hpp" #include "ci/ciUtilities.inline.hpp" -#include "classfile/systemDictionary.hpp" #include "classfile/vmIntrinsics.hpp" #include "compiler/compileBroker.hpp" #include "compiler/compileLog.hpp" diff --git a/src/hotspot/share/opto/parse2.cpp b/src/hotspot/share/opto/parse2.cpp index 6777927a98a4d..31f816cb68510 100644 --- a/src/hotspot/share/opto/parse2.cpp +++ b/src/hotspot/share/opto/parse2.cpp @@ -25,7 +25,6 @@ #include "precompiled.hpp" #include "jvm_io.h" #include "ci/ciMethodData.hpp" -#include "classfile/systemDictionary.hpp" #include "classfile/vmSymbols.hpp" #include "compiler/compileLog.hpp" #include "interpreter/linkResolver.hpp" diff --git a/src/hotspot/share/opto/parseHelper.cpp b/src/hotspot/share/opto/parseHelper.cpp index cd1104ca2f03d..957a6f7ea46d1 100644 --- a/src/hotspot/share/opto/parseHelper.cpp +++ b/src/hotspot/share/opto/parseHelper.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,6 @@ #include "precompiled.hpp" #include "ci/ciSymbols.hpp" -#include "classfile/systemDictionary.hpp" #include "compiler/compileLog.hpp" #include "oops/objArrayKlass.hpp" #include "opto/addnode.hpp" diff --git a/src/hotspot/share/opto/runtime.cpp b/src/hotspot/share/opto/runtime.cpp index b5943bde690d9..f5cec6b7d05ab 100644 --- a/src/hotspot/share/opto/runtime.cpp +++ b/src/hotspot/share/opto/runtime.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ */ #include "precompiled.hpp" -#include "classfile/systemDictionary.hpp" +#include "classfile/vmClasses.hpp" #include "classfile/vmSymbols.hpp" #include "code/codeCache.hpp" #include "code/compiledMethod.inline.hpp" @@ -1260,7 +1260,7 @@ JRT_ENTRY_NO_ASYNC(address, OptoRuntime::handle_exception_C_helper(JavaThread* t Exceptions::debug_check_abort(exception); #ifdef ASSERT - if (!(exception->is_a(SystemDictionary::Throwable_klass()))) { + if (!(exception->is_a(vmClasses::Throwable_klass()))) { // should throw an exception here ShouldNotReachHere(); } @@ -1420,7 +1420,7 @@ address OptoRuntime::rethrow_C(oopDesc* exception, JavaThread* thread, address r #endif assert (exception != NULL, "should have thrown a NULLPointerException"); #ifdef ASSERT - if (!(exception->is_a(SystemDictionary::Throwable_klass()))) { + if (!(exception->is_a(vmClasses::Throwable_klass()))) { // should throw an exception here ShouldNotReachHere(); } diff --git a/src/hotspot/share/prims/jni.cpp b/src/hotspot/share/prims/jni.cpp index 9c4ecd8ceb9d2..0901a1bbcbd99 100644 --- a/src/hotspot/share/prims/jni.cpp +++ b/src/hotspot/share/prims/jni.cpp @@ -37,6 +37,7 @@ #include "classfile/modules.hpp" #include "classfile/symbolTable.hpp" #include "classfile/systemDictionary.hpp" +#include "classfile/vmClasses.hpp" #include "classfile/vmSymbols.hpp" #include "compiler/compiler_globals.hpp" #include "gc/shared/gcLocker.inline.hpp" @@ -365,11 +366,11 @@ JNI_ENTRY(jmethodID, jni_FromReflectedMethod(JNIEnv *env, jobject method)) oop mirror = NULL; int slot = 0; - if (reflected->klass() == SystemDictionary::reflect_Constructor_klass()) { + if (reflected->klass() == vmClasses::reflect_Constructor_klass()) { mirror = java_lang_reflect_Constructor::clazz(reflected); slot = java_lang_reflect_Constructor::slot(reflected); } else { - assert(reflected->klass() == SystemDictionary::reflect_Method_klass(), "wrong type"); + assert(reflected->klass() == vmClasses::reflect_Method_klass(), "wrong type"); mirror = java_lang_reflect_Method::clazz(reflected); slot = java_lang_reflect_Method::slot(reflected); } @@ -467,7 +468,7 @@ JNI_ENTRY(jclass, jni_GetSuperclass(JNIEnv *env, jclass sub)) Klass* super = k->java_super(); // super2 is the value computed by the compiler's getSuperClass intrinsic: debug_only(Klass* super2 = ( k->is_array_klass() - ? SystemDictionary::Object_klass() + ? vmClasses::Object_klass() : k->super() ) ); assert(super == super2, "java_super computation depends on interface, array, other super"); @@ -564,7 +565,7 @@ JNI_ENTRY_NO_PRESERVE(void, jni_ExceptionDescribe(JNIEnv *env)) if (thread->has_pending_exception()) { Handle ex(thread, thread->pending_exception()); thread->clear_pending_exception(); - if (ex->is_a(SystemDictionary::ThreadDeath_klass())) { + if (ex->is_a(vmClasses::ThreadDeath_klass())) { // Don't print anything if we are being killed. } else { jio_fprintf(defaultStream::error_stream(), "Exception "); @@ -573,11 +574,11 @@ JNI_ENTRY_NO_PRESERVE(void, jni_ExceptionDescribe(JNIEnv *env)) jio_fprintf(defaultStream::error_stream(), "in thread \"%s\" ", thread->get_thread_name()); } - if (ex->is_a(SystemDictionary::Throwable_klass())) { + if (ex->is_a(vmClasses::Throwable_klass())) { JavaValue result(T_VOID); JavaCalls::call_virtual(&result, ex, - SystemDictionary::Throwable_klass(), + vmClasses::Throwable_klass(), vmSymbols::printStackTrace_name(), vmSymbols::void_method_signature(), THREAD); diff --git a/src/hotspot/share/prims/jniCheck.cpp b/src/hotspot/share/prims/jniCheck.cpp index 5bd6fe043b611..20529ab946993 100644 --- a/src/hotspot/share/prims/jniCheck.cpp +++ b/src/hotspot/share/prims/jniCheck.cpp @@ -26,7 +26,7 @@ #include "jni.h" #include "jvm.h" #include "classfile/javaClasses.inline.hpp" -#include "classfile/systemDictionary.hpp" +#include "classfile/vmClasses.hpp" #include "classfile/vmSymbols.hpp" #include "logging/log.hpp" #include "logging/logTag.hpp" @@ -513,7 +513,7 @@ Klass* jniCheck::validate_class(JavaThread* thr, jclass clazz, bool allow_primit ReportJNIFatalError(thr, fatal_received_null_class); } - if (mirror->klass() != SystemDictionary::Class_klass()) { + if (mirror->klass() != vmClasses::Class_klass()) { ReportJNIFatalError(thr, fatal_class_not_a_class); } @@ -530,7 +530,7 @@ void jniCheck::validate_throwable_klass(JavaThread* thr, Klass* klass) { assert(klass != NULL, "klass argument must have a value"); if (!klass->is_instance_klass() || - !klass->is_subclass_of(SystemDictionary::Throwable_klass())) { + !klass->is_subclass_of(vmClasses::Throwable_klass())) { ReportJNIFatalError(thr, fatal_class_not_a_throwable_class); } } diff --git a/src/hotspot/share/prims/jvm.cpp b/src/hotspot/share/prims/jvm.cpp index 636e284997d45..8e7743bca96ea 100644 --- a/src/hotspot/share/prims/jvm.cpp +++ b/src/hotspot/share/prims/jvm.cpp @@ -39,6 +39,7 @@ #include "classfile/stringTable.hpp" #include "classfile/symbolTable.hpp" #include "classfile/systemDictionary.hpp" +#include "classfile/vmClasses.hpp" #include "classfile/vmSymbols.hpp" #include "gc/shared/collectedHeap.inline.hpp" #include "interpreter/bytecode.hpp" @@ -158,7 +159,7 @@ static void trace_class_resolution_impl(Klass* to_class, TRAPS) { while (!vfst.at_end()) { Method* m = vfst.method(); - if (!vfst.method()->method_holder()->is_subclass_of(SystemDictionary::ClassLoader_klass())&& + if (!vfst.method()->method_holder()->is_subclass_of(vmClasses::ClassLoader_klass())&& !vfst.method()->method_holder()->is_subclass_of(access_controller_klass) && !vfst.method()->method_holder()->is_subclass_of(privileged_action_klass)) { break; @@ -312,7 +313,7 @@ static void set_property(Handle props, const char* key, const char* value, TRAPS Handle value_str = java_lang_String::create_from_platform_dependent_str((value != NULL ? value : ""), CHECK); JavaCalls::call_virtual(&r, props, - SystemDictionary::Properties_klass(), + vmClasses::Properties_klass(), vmSymbols::put_name(), vmSymbols::object_object_object_signature(), key_str, @@ -338,7 +339,7 @@ JVM_ENTRY(jobjectArray, JVM_GetProperties(JNIEnv *env)) int count = Arguments::PropertyList_count(p); // Allocate result String array - InstanceKlass* ik = SystemDictionary::String_klass(); + InstanceKlass* ik = vmClasses::String_klass(); objArrayOop r = oopFactory::new_objArray(ik, (count + fixedCount) * 2, CHECK_NULL); objArrayHandle result_h(THREAD, r); @@ -644,7 +645,7 @@ JVM_ENTRY(jobject, JVM_Clone(JNIEnv* env, jobject handle)) guarantee(klass->is_cloneable(), "all arrays are cloneable"); } else { guarantee(obj->is_instance(), "should be instanceOop"); - bool cloneable = klass->is_subtype_of(SystemDictionary::Cloneable_klass()); + bool cloneable = klass->is_subtype_of(vmClasses::Cloneable_klass()); guarantee(cloneable == klass->is_cloneable(), "incorrect cloneable flag"); } #endif @@ -1143,7 +1144,7 @@ JVM_ENTRY(jobjectArray, JVM_GetClassInterfaces(JNIEnv *env, jclass cls)) // Special handling for primitive objects if (java_lang_Class::is_primitive(mirror)) { // Primitive objects does not have any interfaces - objArrayOop r = oopFactory::new_objArray(SystemDictionary::Class_klass(), 0, CHECK_NULL); + objArrayOop r = oopFactory::new_objArray(vmClasses::Class_klass(), 0, CHECK_NULL); return (jobjectArray) JNIHandles::make_local(THREAD, r); } @@ -1158,7 +1159,7 @@ JVM_ENTRY(jobjectArray, JVM_GetClassInterfaces(JNIEnv *env, jclass cls)) } // Allocate result array - objArrayOop r = oopFactory::new_objArray(SystemDictionary::Class_klass(), size, CHECK_NULL); + objArrayOop r = oopFactory::new_objArray(vmClasses::Class_klass(), size, CHECK_NULL); objArrayHandle result (THREAD, r); // Fill in result if (klass->is_instance_klass()) { @@ -1169,8 +1170,8 @@ JVM_ENTRY(jobjectArray, JVM_GetClassInterfaces(JNIEnv *env, jclass cls)) } } else { // All arrays implement java.lang.Cloneable and java.io.Serializable - result->obj_at_put(0, SystemDictionary::Cloneable_klass()->java_mirror()); - result->obj_at_put(1, SystemDictionary::Serializable_klass()->java_mirror()); + result->obj_at_put(0, vmClasses::Cloneable_klass()->java_mirror()); + result->obj_at_put(1, vmClasses::Serializable_klass()->java_mirror()); } return (jobjectArray) JNIHandles::make_local(THREAD, result()); JVM_END @@ -1284,7 +1285,7 @@ JVM_ENTRY(jobject, JVM_GetStackAccessControlContext(JNIEnv *env, jclass cls)) Method* method = vfst.method(); // stop at the first privileged frame - if (method->method_holder() == SystemDictionary::AccessController_klass() && + if (method->method_holder() == vmClasses::AccessController_klass() && method->name() == vmSymbols::executePrivileged_name()) { // this frame is privileged @@ -1324,7 +1325,7 @@ JVM_ENTRY(jobject, JVM_GetStackAccessControlContext(JNIEnv *env, jclass cls)) return JNIHandles::make_local(THREAD, result); } - objArrayOop context = oopFactory::new_objArray(SystemDictionary::ProtectionDomain_klass(), + objArrayOop context = oopFactory::new_objArray(vmClasses::ProtectionDomain_klass(), local_array->length(), CHECK_NULL); objArrayHandle h_context(thread, context); for (int index = 0; index < local_array->length(); index++) { @@ -1372,7 +1373,7 @@ JVM_ENTRY(jobjectArray, JVM_GetDeclaredClasses(JNIEnv *env, jclass ofClass)) oop ofMirror = JNIHandles::resolve_non_null(ofClass); if (java_lang_Class::is_primitive(ofMirror) || ! java_lang_Class::as_Klass(ofMirror)->is_instance_klass()) { - oop result = oopFactory::new_objArray(SystemDictionary::Class_klass(), 0, CHECK_NULL); + oop result = oopFactory::new_objArray(vmClasses::Class_klass(), 0, CHECK_NULL); return (jobjectArray)JNIHandles::make_local(THREAD, result); } @@ -1381,7 +1382,7 @@ JVM_ENTRY(jobjectArray, JVM_GetDeclaredClasses(JNIEnv *env, jclass ofClass)) if (iter.length() == 0) { // Neither an inner nor outer class - oop result = oopFactory::new_objArray(SystemDictionary::Class_klass(), 0, CHECK_NULL); + oop result = oopFactory::new_objArray(vmClasses::Class_klass(), 0, CHECK_NULL); return (jobjectArray)JNIHandles::make_local(THREAD, result); } @@ -1390,7 +1391,7 @@ JVM_ENTRY(jobjectArray, JVM_GetDeclaredClasses(JNIEnv *env, jclass ofClass)) int length = iter.length(); // Allocate temp. result array - objArrayOop r = oopFactory::new_objArray(SystemDictionary::Class_klass(), length/4, CHECK_NULL); + objArrayOop r = oopFactory::new_objArray(vmClasses::Class_klass(), length/4, CHECK_NULL); objArrayHandle result (THREAD, r); int members = 0; @@ -1420,7 +1421,7 @@ JVM_ENTRY(jobjectArray, JVM_GetDeclaredClasses(JNIEnv *env, jclass ofClass)) if (members != length) { // Return array of right length - objArrayOop res = oopFactory::new_objArray(SystemDictionary::Class_klass(), members, CHECK_NULL); + objArrayOop res = oopFactory::new_objArray(vmClasses::Class_klass(), members, CHECK_NULL); for(int i = 0; i < members; i++) { res->obj_at_put(i, result->obj_at(i)); } @@ -1546,11 +1547,11 @@ static Method* jvm_get_method_common(jobject method) { oop mirror = NULL; int slot = 0; - if (reflected->klass() == SystemDictionary::reflect_Constructor_klass()) { + if (reflected->klass() == vmClasses::reflect_Constructor_klass()) { mirror = java_lang_reflect_Constructor::clazz(reflected); slot = java_lang_reflect_Constructor::slot(reflected); } else { - assert(reflected->klass() == SystemDictionary::reflect_Method_klass(), + assert(reflected->klass() == vmClasses::reflect_Method_klass(), "wrong type"); mirror = java_lang_reflect_Method::clazz(reflected); slot = java_lang_reflect_Method::slot(reflected); @@ -1648,7 +1649,7 @@ JVM_ENTRY(jobjectArray, JVM_GetMethodParameters(JNIEnv *env, jobject method)) } - objArrayOop result_oop = oopFactory::new_objArray(SystemDictionary::reflect_Parameter_klass(), num_params, CHECK_NULL); + objArrayOop result_oop = oopFactory::new_objArray(vmClasses::reflect_Parameter_klass(), num_params, CHECK_NULL); objArrayHandle result (THREAD, result_oop); for (int i = 0; i < num_params; i++) { @@ -1677,7 +1678,7 @@ JVM_ENTRY(jobjectArray, JVM_GetClassDeclaredFields(JNIEnv *env, jclass ofClass, if (java_lang_Class::is_primitive(ofMirror) || java_lang_Class::as_Klass(ofMirror)->is_array_klass()) { // Return empty array - oop res = oopFactory::new_objArray(SystemDictionary::reflect_Field_klass(), 0, CHECK_NULL); + oop res = oopFactory::new_objArray(vmClasses::reflect_Field_klass(), 0, CHECK_NULL); return (jobjectArray) JNIHandles::make_local(THREAD, res); } @@ -1699,7 +1700,7 @@ JVM_ENTRY(jobjectArray, JVM_GetClassDeclaredFields(JNIEnv *env, jclass ofClass, num_fields = k->java_fields_count(); } - objArrayOop r = oopFactory::new_objArray(SystemDictionary::reflect_Field_klass(), num_fields, CHECK_NULL); + objArrayOop r = oopFactory::new_objArray(vmClasses::reflect_Field_klass(), num_fields, CHECK_NULL); objArrayHandle result (THREAD, r); int out_idx = 0; @@ -1749,7 +1750,7 @@ JVM_ENTRY(jobjectArray, JVM_GetRecordComponents(JNIEnv* env, jclass ofClass)) int length = components->length(); assert(length >= 0, "unexpected record_components length"); objArrayOop record_components = - oopFactory::new_objArray(SystemDictionary::RecordComponent_klass(), length, CHECK_NULL); + oopFactory::new_objArray(vmClasses::RecordComponent_klass(), length, CHECK_NULL); objArrayHandle components_h (THREAD, record_components); for (int x = 0; x < length; x++) { @@ -1847,7 +1848,7 @@ JVM_ENTRY(jobjectArray, JVM_GetClassDeclaredMethods(JNIEnv *env, jclass ofClass, { return get_class_declared_methods_helper(env, ofClass, publicOnly, /*want_constructor*/ false, - SystemDictionary::reflect_Method_klass(), THREAD); + vmClasses::reflect_Method_klass(), THREAD); } JVM_END @@ -1855,7 +1856,7 @@ JVM_ENTRY(jobjectArray, JVM_GetClassDeclaredConstructors(JNIEnv *env, jclass ofC { return get_class_declared_methods_helper(env, ofClass, publicOnly, /*want_constructor*/ true, - SystemDictionary::reflect_Constructor_klass(), THREAD); + vmClasses::reflect_Constructor_klass(), THREAD); } JVM_END @@ -1915,7 +1916,7 @@ JVM_ENTRY(jobjectArray, JVM_GetNestMembers(JNIEnv* env, jclass current)) log_trace(class, nestmates)(" - host has %d listed nest members", length); // nest host is first in the array so make it one bigger - objArrayOop r = oopFactory::new_objArray(SystemDictionary::Class_klass(), + objArrayOop r = oopFactory::new_objArray(vmClasses::Class_klass(), length + 1, CHECK_NULL); objArrayHandle result(THREAD, r); result->obj_at_put(0, host->java_mirror()); @@ -1925,7 +1926,7 @@ JVM_ENTRY(jobjectArray, JVM_GetNestMembers(JNIEnv* env, jclass current)) int cp_index = members->at(i); Klass* k = host->constants()->klass_at(cp_index, THREAD); if (HAS_PENDING_EXCEPTION) { - if (PENDING_EXCEPTION->is_a(SystemDictionary::VirtualMachineError_klass())) { + if (PENDING_EXCEPTION->is_a(vmClasses::VirtualMachineError_klass())) { return NULL; // propagate VMEs } if (log_is_enabled(Trace, class, nestmates)) { @@ -1959,7 +1960,7 @@ JVM_ENTRY(jobjectArray, JVM_GetNestMembers(JNIEnv* env, jclass current)) log_trace(class, nestmates)(" - compacting array from length %d to %d", length + 1, count + 1); - objArrayOop r2 = oopFactory::new_objArray(SystemDictionary::Class_klass(), + objArrayOop r2 = oopFactory::new_objArray(vmClasses::Class_klass(), count + 1, CHECK_NULL); objArrayHandle result2(THREAD, r2); for (int i = 0; i < count + 1; i++) { @@ -1993,7 +1994,7 @@ JVM_ENTRY(jobjectArray, JVM_GetPermittedSubclasses(JNIEnv* env, jclass current)) log_trace(class, sealed)(" - sealed class has %d permitted subclasses", length); - objArrayOop r = oopFactory::new_objArray(SystemDictionary::Class_klass(), + objArrayOop r = oopFactory::new_objArray(vmClasses::Class_klass(), length, CHECK_NULL); objArrayHandle result(THREAD, r); int count = 0; @@ -2001,7 +2002,7 @@ JVM_ENTRY(jobjectArray, JVM_GetPermittedSubclasses(JNIEnv* env, jclass current)) int cp_index = subclasses->at(i); Klass* k = ik->constants()->klass_at(cp_index, THREAD); if (HAS_PENDING_EXCEPTION) { - if (PENDING_EXCEPTION->is_a(SystemDictionary::VirtualMachineError_klass())) { + if (PENDING_EXCEPTION->is_a(vmClasses::VirtualMachineError_klass())) { return NULL; // propagate VMEs } if (log_is_enabled(Trace, class, sealed)) { @@ -2022,7 +2023,7 @@ JVM_ENTRY(jobjectArray, JVM_GetPermittedSubclasses(JNIEnv* env, jclass current)) } if (count < length) { // we had invalid entries so we need to compact the array - objArrayOop r2 = oopFactory::new_objArray(SystemDictionary::Class_klass(), + objArrayOop r2 = oopFactory::new_objArray(vmClasses::Class_klass(), count, CHECK_NULL); objArrayHandle result2(THREAD, r2); for (int i = 0; i < count; i++) { @@ -2200,7 +2201,7 @@ JVM_ENTRY(jobjectArray, JVM_ConstantPoolGetMemberRefInfoAt(JNIEnv *env, jobject Symbol* klass_name = cp->klass_name_at(klass_ref); Symbol* member_name = cp->uncached_name_ref_at(index); Symbol* member_sig = cp->uncached_signature_ref_at(index); - objArrayOop dest_o = oopFactory::new_objArray(SystemDictionary::String_klass(), 3, CHECK_NULL); + objArrayOop dest_o = oopFactory::new_objArray(vmClasses::String_klass(), 3, CHECK_NULL); objArrayHandle dest(THREAD, dest_o); Handle str = java_lang_String::create_from_symbol(klass_name, CHECK_NULL); dest->obj_at_put(0, str()); @@ -2249,7 +2250,7 @@ JVM_ENTRY(jobjectArray, JVM_ConstantPoolGetNameAndTypeRefInfoAt(JNIEnv *env, job } Symbol* member_name = cp->symbol_at(cp->name_ref_index_at(index)); Symbol* member_sig = cp->symbol_at(cp->signature_ref_index_at(index)); - objArrayOop dest_o = oopFactory::new_objArray(SystemDictionary::String_klass(), 2, CHECK_NULL); + objArrayOop dest_o = oopFactory::new_objArray(vmClasses::String_klass(), 2, CHECK_NULL); objArrayHandle dest(THREAD, dest_o); Handle str = java_lang_String::create_from_symbol(member_name, CHECK_NULL); dest->obj_at_put(0, str()); @@ -2848,7 +2849,7 @@ static void thread_entry(JavaThread* thread, TRAPS) { JavaValue result(T_VOID); JavaCalls::call_virtual(&result, obj, - SystemDictionary::Thread_klass(), + vmClasses::Thread_klass(), vmSymbols::run_method_name(), vmSymbols::void_method_signature(), THREAD); @@ -3178,10 +3179,10 @@ JVM_ENTRY(jobjectArray, JVM_GetClassContext(JNIEnv *env)) JvmtiVMObjectAllocEventCollector oam; vframeStream vfst(thread); - if (SystemDictionary::reflect_CallerSensitive_klass() != NULL) { + if (vmClasses::reflect_CallerSensitive_klass() != NULL) { // This must only be called from SecurityManager.getClassContext Method* m = vfst.method(); - if (!(m->method_holder() == SystemDictionary::SecurityManager_klass() && + if (!(m->method_holder() == vmClasses::SecurityManager_klass() && m->name() == vmSymbols::getClassContext_name() && m->signature() == vmSymbols::void_class_array_signature())) { THROW_MSG_NULL(vmSymbols::java_lang_InternalError(), "JVM_GetClassContext must only be called from SecurityManager.getClassContext"); @@ -3201,7 +3202,7 @@ JVM_ENTRY(jobjectArray, JVM_GetClassContext(JNIEnv *env)) } // Create result array of type [Ljava/lang/Class; - objArrayOop result = oopFactory::new_objArray(SystemDictionary::Class_klass(), klass_array->length(), CHECK_NULL); + objArrayOop result = oopFactory::new_objArray(vmClasses::Class_klass(), klass_array->length(), CHECK_NULL); // Fill in mirrors corresponding to method holders for (int i = 0; i < klass_array->length(); i++) { result->obj_at_put(i, klass_array->at(i)->java_mirror()); @@ -3718,7 +3719,7 @@ JVM_ENTRY(jobjectArray, JVM_GetAllThreads(JNIEnv *env, jclass dummy)) JvmtiVMObjectAllocEventCollector oam; int num_threads = tle.num_threads(); - objArrayOop r = oopFactory::new_objArray(SystemDictionary::Thread_klass(), num_threads, CHECK_NULL); + objArrayOop r = oopFactory::new_objArray(vmClasses::Thread_klass(), num_threads, CHECK_NULL); objArrayHandle threads_ah(THREAD, r); for (int i = 0; i < num_threads; i++) { @@ -3751,7 +3752,7 @@ JVM_ENTRY(jobjectArray, JVM_DumpThreads(JNIEnv *env, jclass threadClass, jobject // check if threads is not an array of objects of Thread class Klass* k = ObjArrayKlass::cast(ah->klass())->element_klass(); - if (k != SystemDictionary::Thread_klass()) { + if (k != vmClasses::Thread_klass()) { THROW_(vmSymbols::java_lang_IllegalArgumentException(), 0); } @@ -3811,7 +3812,7 @@ JVM_ENTRY(jobjectArray, JVM_GetEnclosingMethodInfo(JNIEnv *env, jclass ofClass)) if (encl_method_class_idx == 0) { return NULL; } - objArrayOop dest_o = oopFactory::new_objArray(SystemDictionary::Object_klass(), 3, CHECK_NULL); + objArrayOop dest_o = oopFactory::new_objArray(vmClasses::Object_klass(), 3, CHECK_NULL); objArrayHandle dest(THREAD, dest_o); Klass* enc_k = ik->constants()->klass_at(encl_method_class_idx, CHECK_NULL); dest->obj_at_put(0, enc_k->java_mirror()); @@ -3845,7 +3846,7 @@ JVM_ENTRY(jobjectArray, JVM_GetVmArguments(JNIEnv *env)) int num_flags = Arguments::num_jvm_flags(); int num_args = Arguments::num_jvm_args(); - InstanceKlass* ik = SystemDictionary::String_klass(); + InstanceKlass* ik = vmClasses::String_klass(); objArrayOop r = oopFactory::new_objArray(ik, num_args + num_flags, CHECK_NULL); objArrayHandle result_h(THREAD, r); diff --git a/src/hotspot/share/prims/jvmtiEnter.xsl b/src/hotspot/share/prims/jvmtiEnter.xsl index d45e705cc8122..fb2a8e93a21bf 100644 --- a/src/hotspot/share/prims/jvmtiEnter.xsl +++ b/src/hotspot/share/prims/jvmtiEnter.xsl @@ -38,6 +38,7 @@ # include "precompiled.hpp" # include "classfile/javaClasses.inline.hpp" +# include "classfile/vmClasses.hpp" # include "memory/resourceArea.hpp" # include "utilities/macros.hpp" #if INCLUDE_JVMTI @@ -848,7 +849,7 @@ static jvmtiError JNICALL } - if (!k_mirror->is_a(SystemDictionary::Class_klass())) { + if (!k_mirror->is_a(vmClasses::Class_klass())) { JVMTI_ERROR_INVALID_CLASS diff --git a/src/hotspot/share/prims/jvmtiEnv.cpp b/src/hotspot/share/prims/jvmtiEnv.cpp index 0bcfb0c10fd87..96615a6ceacfe 100644 --- a/src/hotspot/share/prims/jvmtiEnv.cpp +++ b/src/hotspot/share/prims/jvmtiEnv.cpp @@ -28,6 +28,7 @@ #include "classfile/stringTable.hpp" #include "classfile/modules.hpp" #include "classfile/systemDictionary.hpp" +#include "classfile/vmClasses.hpp" #include "classfile/vmSymbols.hpp" #include "interpreter/bytecodeStream.hpp" #include "interpreter/interpreter.hpp" @@ -411,7 +412,7 @@ JvmtiEnv::RetransformClasses(jint class_count, const jclass* classes) { if (k_mirror == NULL) { return JVMTI_ERROR_INVALID_CLASS; } - if (!k_mirror->is_a(SystemDictionary::Class_klass())) { + if (!k_mirror->is_a(vmClasses::Class_klass())) { return JVMTI_ERROR_INVALID_CLASS; } @@ -854,7 +855,7 @@ JvmtiEnv::GetThreadState(jthread thread, jint* thread_state_ptr) { java_thread = current_thread; thread_oop = java_thread->threadObj(); - if (thread_oop == NULL || !thread_oop->is_a(SystemDictionary::Thread_klass())) { + if (thread_oop == NULL || !thread_oop->is_a(vmClasses::Thread_klass())) { return JVMTI_ERROR_INVALID_THREAD; } } else { @@ -1129,7 +1130,7 @@ JvmtiEnv::GetThreadInfo(jthread thread, jvmtiThreadInfo* info_ptr) { oop thread_oop = NULL; if (thread == NULL) { thread_oop = current_thread->threadObj(); - if (thread_oop == NULL || !thread_oop->is_a(SystemDictionary::Thread_klass())) { + if (thread_oop == NULL || !thread_oop->is_a(vmClasses::Thread_klass())) { return JVMTI_ERROR_INVALID_THREAD; } } else { diff --git a/src/hotspot/share/prims/jvmtiEnvBase.cpp b/src/hotspot/share/prims/jvmtiEnvBase.cpp index e1363faa08bae..2f47dc3034071 100644 --- a/src/hotspot/share/prims/jvmtiEnvBase.cpp +++ b/src/hotspot/share/prims/jvmtiEnvBase.cpp @@ -26,7 +26,6 @@ #include "classfile/classLoaderDataGraph.hpp" #include "classfile/javaClasses.hpp" #include "classfile/moduleEntry.hpp" -#include "classfile/systemDictionary.hpp" #include "jvmtifiles/jvmtiEnv.hpp" #include "memory/iterator.hpp" #include "memory/resourceArea.hpp" diff --git a/src/hotspot/share/prims/jvmtiEnvThreadState.cpp b/src/hotspot/share/prims/jvmtiEnvThreadState.cpp index a154f82a810ff..3abeee08f6282 100644 --- a/src/hotspot/share/prims/jvmtiEnvThreadState.cpp +++ b/src/hotspot/share/prims/jvmtiEnvThreadState.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,6 @@ */ #include "precompiled.hpp" -#include "classfile/systemDictionary.hpp" #include "interpreter/interpreter.hpp" #include "jvmtifiles/jvmtiEnv.hpp" #include "memory/resourceArea.hpp" diff --git a/src/hotspot/share/prims/jvmtiExport.cpp b/src/hotspot/share/prims/jvmtiExport.cpp index bafc3d1e8820f..c2bb3d589b40c 100644 --- a/src/hotspot/share/prims/jvmtiExport.cpp +++ b/src/hotspot/share/prims/jvmtiExport.cpp @@ -25,7 +25,7 @@ #include "precompiled.hpp" #include "classfile/javaClasses.inline.hpp" #include "classfile/moduleEntry.hpp" -#include "classfile/systemDictionary.hpp" +#include "classfile/vmClasses.hpp" #include "classfile/vmSymbols.hpp" #include "code/nmethod.hpp" #include "code/pcDesc.hpp" @@ -430,7 +430,7 @@ JvmtiExport::add_default_read_edges(Handle h_module, TRAPS) { // Invoke the transformedByAgent method JavaValue result(T_VOID); JavaCalls::call_static(&result, - SystemDictionary::module_Modules_klass(), + vmClasses::module_Modules_klass(), vmSymbols::transformedByAgent_name(), vmSymbols::transformedByAgent_signature(), h_module, @@ -457,7 +457,7 @@ JvmtiExport::add_module_reads(Handle module, Handle to_module, TRAPS) { // Invoke the addReads method JavaValue result(T_VOID); JavaCalls::call_static(&result, - SystemDictionary::module_Modules_klass(), + vmClasses::module_Modules_klass(), vmSymbols::addReads_name(), vmSymbols::addReads_signature(), module, @@ -487,7 +487,7 @@ JvmtiExport::add_module_exports(Handle module, Handle pkg_name, Handle to_module // Invoke the addExports method JavaValue result(T_VOID); JavaCalls::call_static(&result, - SystemDictionary::module_Modules_klass(), + vmClasses::module_Modules_klass(), vmSymbols::addExports_name(), vmSymbols::addExports_signature(), module, @@ -522,7 +522,7 @@ JvmtiExport::add_module_opens(Handle module, Handle pkg_name, Handle to_module, // Invoke the addOpens method JavaValue result(T_VOID); JavaCalls::call_static(&result, - SystemDictionary::module_Modules_klass(), + vmClasses::module_Modules_klass(), vmSymbols::addOpens_name(), vmSymbols::addExports_signature(), module, @@ -556,7 +556,7 @@ JvmtiExport::add_module_uses(Handle module, Handle service, TRAPS) { // Invoke the addUses method JavaValue result(T_VOID); JavaCalls::call_static(&result, - SystemDictionary::module_Modules_klass(), + vmClasses::module_Modules_klass(), vmSymbols::addUses_name(), vmSymbols::addUses_signature(), module, @@ -586,7 +586,7 @@ JvmtiExport::add_module_provides(Handle module, Handle service, Handle impl_clas // Invoke the addProvides method JavaValue result(T_VOID); JavaCalls::call_static(&result, - SystemDictionary::module_Modules_klass(), + vmClasses::module_Modules_klass(), vmSymbols::addProvides_name(), vmSymbols::addProvides_signature(), module, @@ -786,7 +786,7 @@ JvmtiExport::cv_external_thread_to_JavaThread(ThreadsList * t_list, } // Looks like an oop at this point. - if (!thread_oop->is_a(SystemDictionary::Thread_klass())) { + if (!thread_oop->is_a(vmClasses::Thread_klass())) { // The oop is not a java.lang.Thread. return JVMTI_ERROR_INVALID_THREAD; } @@ -835,7 +835,7 @@ JvmtiExport::cv_oop_to_JavaThread(ThreadsList * t_list, oop thread_oop, assert(thread_oop != NULL, "must have an oop"); assert(jt_pp != NULL, "must have a return JavaThread pointer"); - if (!thread_oop->is_a(SystemDictionary::Thread_klass())) { + if (!thread_oop->is_a(vmClasses::Thread_klass())) { // The oop is not a java.lang.Thread. return JVMTI_ERROR_INVALID_THREAD; } @@ -1075,7 +1075,7 @@ static inline Klass* oop_to_klass(oop obj) { Klass* k = obj->klass(); // if the object is a java.lang.Class then return the java mirror - if (k == SystemDictionary::Class_klass()) { + if (k == vmClasses::Class_klass()) { if (!java_lang_Class::is_primitive(obj)) { k = java_lang_Class::as_Klass(obj); assert(k != NULL, "class for non-primitive mirror must exist"); @@ -2310,7 +2310,7 @@ void JvmtiExport::record_vm_internal_object_allocation(oop obj) { if (collector != NULL && collector->is_enabled()) { // Don't record classes as these will be notified via the ClassLoad // event. - if (obj->klass() != SystemDictionary::Class_klass()) { + if (obj->klass() != vmClasses::Class_klass()) { collector->record_allocation(obj); } } diff --git a/src/hotspot/share/prims/jvmtiGetLoadedClasses.cpp b/src/hotspot/share/prims/jvmtiGetLoadedClasses.cpp index e05877a6d9f2e..a12b1f9718165 100644 --- a/src/hotspot/share/prims/jvmtiGetLoadedClasses.cpp +++ b/src/hotspot/share/prims/jvmtiGetLoadedClasses.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,6 @@ #include "classfile/classLoaderDataGraph.hpp" #include "classfile/dictionary.hpp" #include "classfile/javaClasses.hpp" -#include "classfile/systemDictionary.hpp" #include "gc/shared/collectedHeap.hpp" #include "memory/universe.hpp" #include "oops/klass.inline.hpp" diff --git a/src/hotspot/share/prims/jvmtiImpl.cpp b/src/hotspot/share/prims/jvmtiImpl.cpp index d7b31721f3f07..287594edd0ab2 100644 --- a/src/hotspot/share/prims/jvmtiImpl.cpp +++ b/src/hotspot/share/prims/jvmtiImpl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,6 @@ #include "precompiled.hpp" #include "classfile/javaClasses.hpp" #include "classfile/symbolTable.hpp" -#include "classfile/systemDictionary.hpp" #include "code/nmethod.hpp" #include "interpreter/interpreter.hpp" #include "interpreter/oopMapCache.hpp" diff --git a/src/hotspot/share/prims/jvmtiImpl.hpp b/src/hotspot/share/prims/jvmtiImpl.hpp index 1895f9ab8e644..b1c8ee102bf18 100644 --- a/src/hotspot/share/prims/jvmtiImpl.hpp +++ b/src/hotspot/share/prims/jvmtiImpl.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,6 @@ #ifndef SHARE_PRIMS_JVMTIIMPL_HPP #define SHARE_PRIMS_JVMTIIMPL_HPP -#include "classfile/systemDictionary.hpp" #include "jvmtifiles/jvmti.h" #include "oops/objArrayOop.hpp" #include "prims/jvmtiEnvThreadState.hpp" diff --git a/src/hotspot/share/prims/jvmtiRedefineClasses.cpp b/src/hotspot/share/prims/jvmtiRedefineClasses.cpp index eeb371593226e..dfbb2182f63ab 100644 --- a/src/hotspot/share/prims/jvmtiRedefineClasses.cpp +++ b/src/hotspot/share/prims/jvmtiRedefineClasses.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,6 +32,7 @@ #include "classfile/symbolTable.hpp" #include "classfile/systemDictionary.hpp" #include "classfile/verifier.hpp" +#include "classfile/vmClasses.hpp" #include "classfile/vmSymbols.hpp" #include "code/codeCache.hpp" #include "compiler/compileBroker.hpp" @@ -4234,7 +4235,7 @@ void VM_RedefineClasses::redefine_single_class(jclass the_jclass, InstanceKlass* the_class = get_ik(the_jclass); // Set a flag to control and optimize adjusting method entries - _has_redefined_Object |= the_class == SystemDictionary::Object_klass(); + _has_redefined_Object |= the_class == vmClasses::Object_klass(); // Remove all breakpoints in methods of this class JvmtiBreakpoints& jvmti_breakpoints = JvmtiCurrentBreakpoints::get_jvmti_breakpoints(); @@ -4390,7 +4391,7 @@ void VM_RedefineClasses::redefine_single_class(jclass the_jclass, // - all instanceKlasses for redefined classes reused & contents updated the_class->vtable().initialize_vtable(false, THREAD); the_class->itable().initialize_itable(false, THREAD); - assert(!HAS_PENDING_EXCEPTION || (THREAD->pending_exception()->is_a(SystemDictionary::ThreadDeath_klass())), "redefine exception"); + assert(!HAS_PENDING_EXCEPTION || (THREAD->pending_exception()->is_a(vmClasses::ThreadDeath_klass())), "redefine exception"); // Leave arrays of jmethodIDs and itable index cache unchanged diff --git a/src/hotspot/share/prims/jvmtiTagMap.cpp b/src/hotspot/share/prims/jvmtiTagMap.cpp index 763765d506097..e0ca6e7b2494b 100644 --- a/src/hotspot/share/prims/jvmtiTagMap.cpp +++ b/src/hotspot/share/prims/jvmtiTagMap.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,7 @@ #include "classfile/classLoaderDataGraph.hpp" #include "classfile/javaClasses.inline.hpp" #include "classfile/symbolTable.hpp" -#include "classfile/systemDictionary.hpp" +#include "classfile/vmClasses.hpp" #include "classfile/vmSymbols.hpp" #include "jvmtifiles/jvmtiEnv.hpp" #include "logging/log.hpp" @@ -236,7 +236,7 @@ class CallbackWrapper : public StackObj { _obj_tag = (_entry == NULL) ? 0 : _entry->tag(); // get the class and the class's tag value - assert(SystemDictionary::Class_klass()->is_mirror_instance_klass(), "Is not?"); + assert(vmClasses::Class_klass()->is_mirror_instance_klass(), "Is not?"); _klass_tag = tag_for(tag_map, _o->klass()->java_mirror()); } @@ -691,7 +691,7 @@ static jint invoke_string_value_callback(jvmtiStringPrimitiveValueCallback cb, oop str, void* user_data) { - assert(str->klass() == SystemDictionary::String_klass(), "not a string"); + assert(str->klass() == vmClasses::String_klass(), "not a string"); typeArrayOop s_value = java_lang_String::value(str); @@ -772,7 +772,7 @@ static jint invoke_primitive_field_callback_for_static_fields // for static fields only the index will be set static jvmtiHeapReferenceInfo reference_info = { 0 }; - assert(obj->klass() == SystemDictionary::Class_klass(), "not a class"); + assert(obj->klass() == vmClasses::Class_klass(), "not a class"); if (java_lang_Class::is_primitive(obj)) { return 0; } @@ -1083,7 +1083,7 @@ void IterateThroughHeapObjectClosure::do_object(oop obj) { if (callbacks()->primitive_field_callback != NULL && obj->is_instance()) { jint res; jvmtiPrimitiveFieldCallback cb = callbacks()->primitive_field_callback; - if (obj->klass() == SystemDictionary::Class_klass()) { + if (obj->klass() == vmClasses::Class_klass()) { res = invoke_primitive_field_callback_for_static_fields(&wrapper, obj, cb, @@ -1100,7 +1100,7 @@ void IterateThroughHeapObjectClosure::do_object(oop obj) { // string callback if (!is_array && callbacks()->string_primitive_value_callback != NULL && - obj->klass() == SystemDictionary::String_klass()) { + obj->klass() == vmClasses::String_klass()) { jint res = invoke_string_value_callback( callbacks()->string_primitive_value_callback, &wrapper, @@ -2030,7 +2030,7 @@ inline bool CallbackInvoker::report_primitive_array_values(oop obj) { // invoke the string value callback inline bool CallbackInvoker::report_string_value(oop str) { - assert(str->klass() == SystemDictionary::String_klass(), "not a string"); + assert(str->klass() == vmClasses::String_klass(), "not a string"); AdvancedHeapWalkContext* context = advanced_context(); assert(context->string_primitive_value_callback() != NULL, "no callback"); @@ -2552,7 +2552,7 @@ inline bool VM_HeapWalkOperation::iterate_over_class(oop java_class) { // super (only if something more interesting than java.lang.Object) InstanceKlass* java_super = ik->java_super(); - if (java_super != NULL && java_super != SystemDictionary::Object_klass()) { + if (java_super != NULL && java_super != vmClasses::Object_klass()) { oop super = java_super->java_mirror(); if (!CallbackInvoker::report_superclass_reference(mirror, super)) { return false; @@ -2704,7 +2704,7 @@ inline bool VM_HeapWalkOperation::iterate_over_object(oop o) { // if the object is a java.lang.String if (is_reporting_string_values() && - o->klass() == SystemDictionary::String_klass()) { + o->klass() == vmClasses::String_klass()) { if (!CallbackInvoker::report_string_value(o)) { return false; } @@ -2902,7 +2902,7 @@ bool VM_HeapWalkOperation::visit(oop o) { // instance if (o->is_instance()) { - if (o->klass() == SystemDictionary::Class_klass()) { + if (o->klass() == vmClasses::Class_klass()) { if (!java_lang_Class::is_primitive(o)) { // a java.lang.Class return iterate_over_class(o); diff --git a/src/hotspot/share/prims/jvmtiTrace.hpp b/src/hotspot/share/prims/jvmtiTrace.hpp index 657ac627c7bb5..61e657f6ef151 100644 --- a/src/hotspot/share/prims/jvmtiTrace.hpp +++ b/src/hotspot/share/prims/jvmtiTrace.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,6 @@ #ifndef SHARE_PRIMS_JVMTITRACE_HPP #define SHARE_PRIMS_JVMTITRACE_HPP -#include "classfile/systemDictionary.hpp" #include "jvmtifiles/jvmti.h" #include "oops/objArrayOop.hpp" #include "prims/jvmtiEnvThreadState.hpp" diff --git a/src/hotspot/share/prims/methodHandles.cpp b/src/hotspot/share/prims/methodHandles.cpp index d68baefe1d1ef..430fbf14f03a0 100644 --- a/src/hotspot/share/prims/methodHandles.cpp +++ b/src/hotspot/share/prims/methodHandles.cpp @@ -27,6 +27,7 @@ #include "classfile/javaClasses.inline.hpp" #include "classfile/stringTable.hpp" #include "classfile/symbolTable.hpp" +#include "classfile/systemDictionary.hpp" #include "classfile/vmClasses.hpp" #include "code/codeCache.hpp" #include "code/dependencyContext.hpp" @@ -83,7 +84,7 @@ MethodHandlesAdapterBlob* MethodHandles::_adapter_code = NULL; * failed and true otherwise. */ void MethodHandles::generate_adapters() { - assert(SystemDictionary::MethodHandle_klass() != NULL, "should be present"); + assert(vmClasses::MethodHandle_klass() != NULL, "should be present"); assert(_adapter_code == NULL, "generate only once"); ResourceMark rm; @@ -188,7 +189,7 @@ oop MethodHandles::init_MemberName(Handle mname, Handle target, TRAPS) { // It fills in the new MemberName from a java.lang.reflect.Member. oop target_oop = target(); Klass* target_klass = target_oop->klass(); - if (target_klass == SystemDictionary::reflect_Field_klass()) { + if (target_klass == vmClasses::reflect_Field_klass()) { oop clazz = java_lang_reflect_Field::clazz(target_oop); // fd.field_holder() int slot = java_lang_reflect_Field::slot(target_oop); // fd.index() Klass* k = java_lang_Class::as_Klass(clazz); @@ -204,7 +205,7 @@ oop MethodHandles::init_MemberName(Handle mname, Handle target, TRAPS) { } return mname2; } - } else if (target_klass == SystemDictionary::reflect_Method_klass()) { + } else if (target_klass == vmClasses::reflect_Method_klass()) { oop clazz = java_lang_reflect_Method::clazz(target_oop); int slot = java_lang_reflect_Method::slot(target_oop); Klass* k = java_lang_Class::as_Klass(clazz); @@ -215,7 +216,7 @@ oop MethodHandles::init_MemberName(Handle mname, Handle target, TRAPS) { CallInfo info(m, k, CHECK_NULL); return init_method_MemberName(mname, info, THREAD); } - } else if (target_klass == SystemDictionary::reflect_Constructor_klass()) { + } else if (target_klass == vmClasses::reflect_Constructor_klass()) { oop clazz = java_lang_reflect_Constructor::clazz(target_oop); int slot = java_lang_reflect_Constructor::slot(target_oop); Klass* k = java_lang_Class::as_Klass(clazz); @@ -275,7 +276,7 @@ oop MethodHandles::init_method_MemberName(Handle mname, CallInfo& info, TRAPS) { assert(info.resolved_klass()->is_instance_klass(), "subtype of interface must be an instance klass"); InstanceKlass* m_klass_non_interface = InstanceKlass::cast(info.resolved_klass()); if (m_klass_non_interface->is_interface()) { - m_klass_non_interface = SystemDictionary::Object_klass(); + m_klass_non_interface = vmClasses::Object_klass(); #ifdef ASSERT { ResourceMark rm; Method* m2 = m_klass_non_interface->vtable().method_at(vmindex); @@ -386,7 +387,7 @@ bool MethodHandles::is_method_handle_invoke_name(Klass* klass, Symbol* name) { if (klass == NULL) return false; // The following test will fail spuriously during bootstrap of MethodHandle itself: - // if (klass != SystemDictionary::MethodHandle_klass()) + // if (klass != vmClasses::MethodHandle_klass()) // Test the name instead: if (klass->name() != vmSymbols::java_lang_invoke_MethodHandle() && klass->name() != vmSymbols::java_lang_invoke_VarHandle()) { @@ -650,7 +651,7 @@ void MethodHandles::print_as_basic_type_signature_on(outputStream* st, static oop object_java_mirror() { - return SystemDictionary::Object_klass()->java_mirror(); + return vmClasses::Object_klass()->java_mirror(); } oop MethodHandles::field_name_or_null(Symbol* s) { @@ -671,9 +672,9 @@ oop MethodHandles::field_signature_type_or_null(Symbol* s) { if (s == vmSymbols::object_signature()) { return object_java_mirror(); } else if (s == vmSymbols::class_signature()) { - return SystemDictionary::Class_klass()->java_mirror(); + return vmClasses::Class_klass()->java_mirror(); } else if (s == vmSymbols::string_signature()) { - return SystemDictionary::String_klass()->java_mirror(); + return vmClasses::String_klass()->java_mirror(); } } return NULL; @@ -716,7 +717,7 @@ Handle MethodHandles::resolve_MemberName(Handle mname, Klass* caller, int lookup if (defc_klass == NULL) return empty; // a primitive; no resolution possible if (!defc_klass->is_instance_klass()) { if (!defc_klass->is_array_klass()) return empty; - defc_klass = SystemDictionary::Object_klass(); + defc_klass = vmClasses::Object_klass(); } defc = InstanceKlass::cast(defc_klass); } @@ -733,7 +734,7 @@ Handle MethodHandles::resolve_MemberName(Handle mname, Klass* caller, int lookup vmIntrinsics::ID mh_invoke_id = vmIntrinsics::_none; if ((flags & ALL_KINDS) == IS_METHOD && - (defc == SystemDictionary::MethodHandle_klass() || defc == SystemDictionary::VarHandle_klass()) && + (defc == vmClasses::MethodHandle_klass() || defc == vmClasses::VarHandle_klass()) && (ref_kind == JVM_REF_invokeVirtual || ref_kind == JVM_REF_invokeSpecial || // static invocation mode is required for _linkToVirtual, etc.: @@ -1311,7 +1312,7 @@ JVM_ENTRY(jobject, MHN_getMemberVMInfo(JNIEnv *env, jobject igcls, jobject mname if (mname_jh == NULL) return NULL; Handle mname(THREAD, JNIHandles::resolve_non_null(mname_jh)); intptr_t vmindex = java_lang_invoke_MemberName::vmindex(mname()); - objArrayHandle result = oopFactory::new_objArray_handle(SystemDictionary::Object_klass(), 2, CHECK_NULL); + objArrayHandle result = oopFactory::new_objArray_handle(vmClasses::Object_klass(), 2, CHECK_NULL); jvalue vmindex_value; vmindex_value.j = (long)vmindex; oop x = java_lang_boxing_object::create(T_LONG, &vmindex_value, CHECK_NULL); result->obj_at_put(0, x); @@ -1570,9 +1571,9 @@ static JNINativeMethod MH_methods[] = { */ JVM_ENTRY(void, JVM_RegisterMethodHandleMethods(JNIEnv *env, jclass MHN_class)) { assert(!MethodHandles::enabled(), "must not be enabled"); - assert(SystemDictionary::MethodHandle_klass() != NULL, "should be present"); + assert(vmClasses::MethodHandle_klass() != NULL, "should be present"); - oop mirror = SystemDictionary::MethodHandle_klass()->java_mirror(); + oop mirror = vmClasses::MethodHandle_klass()->java_mirror(); jclass MH_class = (jclass) JNIHandles::make_local(THREAD, mirror); { diff --git a/src/hotspot/share/prims/methodHandles.hpp b/src/hotspot/share/prims/methodHandles.hpp index e0bcb56e1a6f0..754733fc744b2 100644 --- a/src/hotspot/share/prims/methodHandles.hpp +++ b/src/hotspot/share/prims/methodHandles.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,9 +25,11 @@ #ifndef SHARE_PRIMS_METHODHANDLES_HPP #define SHARE_PRIMS_METHODHANDLES_HPP -#include "classfile/systemDictionary.hpp" +#include "classfile/vmClasses.hpp" #include "classfile/vmSymbols.hpp" +#include "oops/method.hpp" #include "runtime/frame.hpp" +#include "runtime/fieldDescriptor.hpp" #include "runtime/globals.hpp" #include "runtime/stubCodeGenerator.hpp" #include "utilities/macros.hpp" diff --git a/src/hotspot/share/prims/nativeLookup.cpp b/src/hotspot/share/prims/nativeLookup.cpp index bbc92260b94e7..4a5dcd0591618 100644 --- a/src/hotspot/share/prims/nativeLookup.cpp +++ b/src/hotspot/share/prims/nativeLookup.cpp @@ -26,6 +26,7 @@ #include "classfile/javaClasses.hpp" #include "classfile/symbolTable.hpp" #include "classfile/systemDictionary.hpp" +#include "classfile/vmClasses.hpp" #include "classfile/vmSymbols.hpp" #include "logging/log.hpp" #include "logging/logTag.hpp" @@ -288,7 +289,7 @@ address NativeLookup::lookup_style(const methodHandle& method, char* pure_name, } // Otherwise call static method findNative in ClassLoader - Klass* klass = SystemDictionary::ClassLoader_klass(); + Klass* klass = vmClasses::ClassLoader_klass(); Handle name_arg = java_lang_String::create_from_str(jni_name, CHECK_NULL); JavaValue result(T_LONG); diff --git a/src/hotspot/share/prims/stackwalk.cpp b/src/hotspot/share/prims/stackwalk.cpp index 45a1af82a9a35..a45d564efbd4b 100644 --- a/src/hotspot/share/prims/stackwalk.cpp +++ b/src/hotspot/share/prims/stackwalk.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ #include "precompiled.hpp" #include "classfile/javaClasses.hpp" #include "classfile/javaClasses.inline.hpp" +#include "classfile/vmClasses.hpp" #include "classfile/vmSymbols.hpp" #include "logging/log.hpp" #include "logging/logStream.hpp" @@ -188,7 +189,7 @@ void JavaFrameStream::fill_frame(int index, objArrayHandle frames_array, // T_OBJECT, or T_CONFLICT. oop LiveFrameStream::create_primitive_slot_instance(StackValueCollection* values, int i, BasicType type, TRAPS) { - Klass* k = SystemDictionary::LiveStackFrameInfo_klass(); + Klass* k = vmClasses::LiveStackFrameInfo_klass(); InstanceKlass* ik = InstanceKlass::cast(k); JavaValue result(T_OBJECT); @@ -245,7 +246,7 @@ oop LiveFrameStream::create_primitive_slot_instance(StackValueCollection* values objArrayHandle LiveFrameStream::values_to_object_array(StackValueCollection* values, TRAPS) { objArrayHandle empty; int length = values->size(); - objArrayOop array_oop = oopFactory::new_objArray(SystemDictionary::Object_klass(), + objArrayOop array_oop = oopFactory::new_objArray(vmClasses::Object_klass(), length, CHECK_(empty)); objArrayHandle array_h(THREAD, array_oop); for (int i = 0; i < values->size(); i++) { @@ -269,7 +270,7 @@ objArrayHandle LiveFrameStream::values_to_object_array(StackValueCollection* val objArrayHandle LiveFrameStream::monitors_to_object_array(GrowableArray* monitors, TRAPS) { int length = monitors->length(); - objArrayOop array_oop = oopFactory::new_objArray(SystemDictionary::Object_klass(), + objArrayOop array_oop = oopFactory::new_objArray(vmClasses::Object_klass(), length, CHECK_(objArrayHandle())); objArrayHandle array_h(THREAD, array_oop); for (int i = 0; i < length; i++) { @@ -367,8 +368,8 @@ oop StackWalk::fetchFirstBatch(BaseFrameStream& stream, Handle stackStream, methodHandle m_doStackWalk(THREAD, Universe::do_stack_walk_method()); { - Klass* stackWalker_klass = SystemDictionary::StackWalker_klass(); - Klass* abstractStackWalker_klass = SystemDictionary::AbstractStackWalker_klass(); + Klass* stackWalker_klass = vmClasses::StackWalker_klass(); + Klass* abstractStackWalker_klass = vmClasses::AbstractStackWalker_klass(); while (!stream.at_end()) { InstanceKlass* ik = stream.method()->method_holder(); if (ik != stackWalker_klass && diff --git a/src/hotspot/share/prims/unsafe.cpp b/src/hotspot/share/prims/unsafe.cpp index eb2931c3be19b..1448a0b5b19a0 100644 --- a/src/hotspot/share/prims/unsafe.cpp +++ b/src/hotspot/share/prims/unsafe.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,6 +29,7 @@ #include "classfile/classLoader.hpp" #include "classfile/classLoadInfo.hpp" #include "classfile/javaClasses.inline.hpp" +#include "classfile/systemDictionary.hpp" #include "classfile/vmSymbols.hpp" #include "jfr/jfrEvents.hpp" #include "memory/allocation.inline.hpp" diff --git a/src/hotspot/share/prims/vectorSupport.cpp b/src/hotspot/share/prims/vectorSupport.cpp index be3bb27177e77..9a12e98649687 100644 --- a/src/hotspot/share/prims/vectorSupport.cpp +++ b/src/hotspot/share/prims/vectorSupport.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ #include "jni.h" #include "jvm.h" #include "classfile/javaClasses.inline.hpp" +#include "classfile/vmClasses.hpp" #include "classfile/vmSymbols.hpp" #include "code/location.hpp" #include "oops/klass.inline.hpp" @@ -41,19 +42,19 @@ #endif // COMPILER2 bool VectorSupport::is_vector(Klass* klass) { - return klass->is_subclass_of(SystemDictionary::vector_VectorPayload_klass()); + return klass->is_subclass_of(vmClasses::vector_VectorPayload_klass()); } bool VectorSupport::is_vector_mask(Klass* klass) { - return klass->is_subclass_of(SystemDictionary::vector_VectorMask_klass()); + return klass->is_subclass_of(vmClasses::vector_VectorMask_klass()); } bool VectorSupport::is_vector_shuffle(Klass* klass) { - return klass->is_subclass_of(SystemDictionary::vector_VectorShuffle_klass()); + return klass->is_subclass_of(vmClasses::vector_VectorShuffle_klass()); } BasicType VectorSupport::klass2bt(InstanceKlass* ik) { - assert(ik->is_subclass_of(SystemDictionary::vector_VectorPayload_klass()), "%s not a VectorPayload", ik->name()->as_C_string()); + assert(ik->is_subclass_of(vmClasses::vector_VectorPayload_klass()), "%s not a VectorPayload", ik->name()->as_C_string()); fieldDescriptor fd; // find_field initializes fd if found // static final Class ETYPE; Klass* holder = ik->find_field(vmSymbols::ETYPE_name(), vmSymbols::class_signature(), &fd); diff --git a/src/hotspot/share/prims/wbtestmethods/parserTests.cpp b/src/hotspot/share/prims/wbtestmethods/parserTests.cpp index 19b70f7a634c6..3e5c21a269004 100644 --- a/src/hotspot/share/prims/wbtestmethods/parserTests.cpp +++ b/src/hotspot/share/prims/wbtestmethods/parserTests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ #include "jni.h" #include "classfile/javaClasses.inline.hpp" #include "classfile/symbolTable.hpp" +#include "classfile/vmClasses.hpp" #include "memory/oopFactory.hpp" #include "memory/resourceArea.hpp" #include "oops/objArrayOop.inline.hpp" @@ -155,7 +156,7 @@ WB_ENTRY(jobjectArray, WB_ParseCommandLine(JNIEnv* env, jobject o, jstring j_cmd CmdLine cmdline(c_cmdline, strlen(c_cmdline), true); parser.parse(&cmdline,c_delim,CHECK_NULL); - Klass* k = SystemDictionary::Object_klass(); + Klass* k = vmClasses::Object_klass(); objArrayOop returnvalue_array = oopFactory::new_objArray(k, parser.num_arguments() * 2, CHECK_NULL); objArrayHandle returnvalue_array_ah(THREAD, returnvalue_array); diff --git a/src/hotspot/share/prims/whitebox.cpp b/src/hotspot/share/prims/whitebox.cpp index f81d386fd25d7..04cde722febbd 100644 --- a/src/hotspot/share/prims/whitebox.cpp +++ b/src/hotspot/share/prims/whitebox.cpp @@ -32,6 +32,7 @@ #include "classfile/protectionDomainCache.hpp" #include "classfile/stringTable.hpp" #include "classfile/symbolTable.hpp" +#include "classfile/systemDictionary.hpp" #include "classfile/vmSymbols.hpp" #include "code/codeCache.hpp" #include "compiler/compilationPolicy.hpp" diff --git a/src/hotspot/share/runtime/deoptimization.cpp b/src/hotspot/share/runtime/deoptimization.cpp index 669bc0b4388bd..b9e6e24803041 100644 --- a/src/hotspot/share/runtime/deoptimization.cpp +++ b/src/hotspot/share/runtime/deoptimization.cpp @@ -27,6 +27,7 @@ #include "classfile/javaClasses.inline.hpp" #include "classfile/symbolTable.hpp" #include "classfile/systemDictionary.hpp" +#include "classfile/vmClasses.hpp" #include "code/codeCache.hpp" #include "code/debugInfoRec.hpp" #include "code/nmethod.hpp" @@ -1010,7 +1011,7 @@ BooleanBoxCache* BooleanBoxCache::_singleton = NULL; oop Deoptimization::get_cached_box(AutoBoxObjectValue* bv, frame* fr, RegisterMap* reg_map, TRAPS) { Klass* k = java_lang_Class::as_Klass(bv->klass()->as_ConstantOopReadValue()->value()()); - BasicType box_type = SystemDictionary::box_klass_type(k); + BasicType box_type = vmClasses::box_klass_type(k); if (box_type != T_OBJECT) { StackValue* value = StackValue::create_stack_value(fr, reg_map, bv->field_at(box_type == T_LONG ? 1 : 0)); switch(box_type) { @@ -1800,7 +1801,7 @@ Deoptimization::get_method_data(JavaThread* thread, const methodHandle& m, Method::build_interpreter_method_data(m, THREAD); if (HAS_PENDING_EXCEPTION) { // Only metaspace OOM is expected. No Java code executed. - assert((PENDING_EXCEPTION->is_a(SystemDictionary::OutOfMemoryError_klass())), "we expect only an OOM error here"); + assert((PENDING_EXCEPTION->is_a(vmClasses::OutOfMemoryError_klass())), "we expect only an OOM error here"); CLEAR_PENDING_EXCEPTION; } mdo = m()->method_data(); diff --git a/src/hotspot/share/runtime/fieldDescriptor.cpp b/src/hotspot/share/runtime/fieldDescriptor.cpp index d1a913a28dfd9..13630d1f590c0 100644 --- a/src/hotspot/share/runtime/fieldDescriptor.cpp +++ b/src/hotspot/share/runtime/fieldDescriptor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,6 @@ */ #include "precompiled.hpp" -#include "classfile/systemDictionary.hpp" #include "classfile/vmSymbols.hpp" #include "memory/resourceArea.hpp" #include "oops/annotations.hpp" diff --git a/src/hotspot/share/runtime/fieldDescriptor.inline.hpp b/src/hotspot/share/runtime/fieldDescriptor.inline.hpp index 114dd9fa7d8aa..6d650e56c58ab 100644 --- a/src/hotspot/share/runtime/fieldDescriptor.inline.hpp +++ b/src/hotspot/share/runtime/fieldDescriptor.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,7 @@ #include "runtime/fieldDescriptor.hpp" #include "runtime/handles.inline.hpp" +#include "runtime/signature.hpp" // All fieldDescriptor inline functions that (directly or indirectly) use "_cp()" or "_cp->" // must be put in this file, as they require runtime/handles.inline.hpp. diff --git a/src/hotspot/share/runtime/frame.inline.hpp b/src/hotspot/share/runtime/frame.inline.hpp index d207d33a74299..7c79268985710 100644 --- a/src/hotspot/share/runtime/frame.inline.hpp +++ b/src/hotspot/share/runtime/frame.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,7 +29,6 @@ #include "interpreter/interpreter.hpp" #include "oops/method.hpp" #include "runtime/frame.hpp" -#include "runtime/signature.hpp" #include "runtime/stubRoutines.hpp" #include "utilities/macros.hpp" #ifdef ZERO diff --git a/src/hotspot/share/runtime/javaCalls.cpp b/src/hotspot/share/runtime/javaCalls.cpp index c150cf78f601a..64e8f487afcf5 100644 --- a/src/hotspot/share/runtime/javaCalls.cpp +++ b/src/hotspot/share/runtime/javaCalls.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,6 @@ */ #include "precompiled.hpp" -#include "classfile/systemDictionary.hpp" #include "classfile/vmSymbols.hpp" #include "code/nmethod.hpp" #include "compiler/compilationPolicy.hpp" diff --git a/src/hotspot/share/runtime/memprofiler.cpp b/src/hotspot/share/runtime/memprofiler.cpp index a7d74b9e927ff..e281fe6c22db3 100644 --- a/src/hotspot/share/runtime/memprofiler.cpp +++ b/src/hotspot/share/runtime/memprofiler.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,6 @@ #include "precompiled.hpp" #include "classfile/classLoaderDataGraph.inline.hpp" -#include "classfile/systemDictionary.hpp" #include "code/codeCache.hpp" #include "gc/shared/collectedHeap.inline.hpp" #include "interpreter/oopMapCache.hpp" diff --git a/src/hotspot/share/runtime/monitorDeflationThread.cpp b/src/hotspot/share/runtime/monitorDeflationThread.cpp index 350852dc241eb..86805c1b67fa8 100644 --- a/src/hotspot/share/runtime/monitorDeflationThread.cpp +++ b/src/hotspot/share/runtime/monitorDeflationThread.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,7 @@ #include "precompiled.hpp" #include "classfile/javaClasses.hpp" +#include "classfile/vmClasses.hpp" #include "classfile/vmSymbols.hpp" #include "memory/universe.hpp" #include "runtime/interfaceSupport.inline.hpp" @@ -43,7 +44,7 @@ void MonitorDeflationThread::initialize() { // Initialize thread_oop to put it into the system threadGroup Handle thread_group (THREAD, Universe::system_thread_group()); Handle thread_oop = JavaCalls::construct_new_instance( - SystemDictionary::Thread_klass(), + vmClasses::Thread_klass(), vmSymbols::threadgroup_string_void_signature(), thread_group, string, diff --git a/src/hotspot/share/runtime/notificationThread.cpp b/src/hotspot/share/runtime/notificationThread.cpp index 7b996b1aa2987..927357a3b841c 100644 --- a/src/hotspot/share/runtime/notificationThread.cpp +++ b/src/hotspot/share/runtime/notificationThread.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,7 @@ #include "precompiled.hpp" #include "classfile/javaClasses.hpp" +#include "classfile/vmClasses.hpp" #include "memory/universe.hpp" #include "runtime/interfaceSupport.inline.hpp" #include "runtime/javaCalls.hpp" @@ -44,13 +45,13 @@ void NotificationThread::initialize() { // Initialize thread_oop to put it into the system threadGroup Handle thread_group (THREAD, Universe::system_thread_group()); Handle thread_oop = JavaCalls::construct_new_instance( - SystemDictionary::Thread_klass(), + vmClasses::Thread_klass(), vmSymbols::threadgroup_string_void_signature(), thread_group, string, CHECK); - Klass* group = SystemDictionary::ThreadGroup_klass(); + Klass* group = vmClasses::ThreadGroup_klass(); JavaValue result(T_VOID); JavaCalls::call_special(&result, thread_group, diff --git a/src/hotspot/share/runtime/os.cpp b/src/hotspot/share/runtime/os.cpp index 3accbee260075..c32c7764cf497 100644 --- a/src/hotspot/share/runtime/os.cpp +++ b/src/hotspot/share/runtime/os.cpp @@ -28,6 +28,7 @@ #include "classfile/javaClasses.hpp" #include "classfile/moduleEntry.hpp" #include "classfile/systemDictionary.hpp" +#include "classfile/vmClasses.hpp" #include "classfile/vmSymbols.hpp" #include "code/codeCache.hpp" #include "code/icBuffer.hpp" @@ -472,13 +473,13 @@ void os::initialize_jdk_signal_support(TRAPS) { // Initialize thread_oop to put it into the system threadGroup Handle thread_group (THREAD, Universe::system_thread_group()); - Handle thread_oop = JavaCalls::construct_new_instance(SystemDictionary::Thread_klass(), + Handle thread_oop = JavaCalls::construct_new_instance(vmClasses::Thread_klass(), vmSymbols::threadgroup_string_void_signature(), thread_group, string, CHECK); - Klass* group = SystemDictionary::ThreadGroup_klass(); + Klass* group = vmClasses::ThreadGroup_klass(); JavaValue result(T_VOID); JavaCalls::call_special(&result, thread_group, diff --git a/src/hotspot/share/runtime/reflection.cpp b/src/hotspot/share/runtime/reflection.cpp index fd5451089c743..5f8f3ba6f3c5e 100644 --- a/src/hotspot/share/runtime/reflection.cpp +++ b/src/hotspot/share/runtime/reflection.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,8 +28,8 @@ #include "classfile/moduleEntry.hpp" #include "classfile/packageEntry.hpp" #include "classfile/stringTable.hpp" -#include "classfile/systemDictionary.hpp" #include "classfile/verifier.hpp" +#include "classfile/vmClasses.hpp" #include "classfile/vmSymbols.hpp" #include "interpreter/linkResolver.hpp" #include "logging/log.hpp" @@ -471,8 +471,8 @@ Reflection::VerifyClassAccessResults Reflection::verify_class_access( } // Allow all accesses from jdk/internal/reflect/MagicAccessorImpl subclasses to // succeed trivially. - if (SystemDictionary::reflect_MagicAccessorImpl_klass_is_loaded() && - current_class->is_subclass_of(SystemDictionary::reflect_MagicAccessorImpl_klass())) { + if (vmClasses::reflect_MagicAccessorImpl_klass_is_loaded() && + current_class->is_subclass_of(vmClasses::reflect_MagicAccessorImpl_klass())) { return ACCESS_OK; } @@ -697,7 +697,7 @@ bool Reflection::verify_member_access(const Klass* current_class, // Allow all accesses from jdk/internal/reflect/MagicAccessorImpl subclasses to // succeed trivially. - if (current_class->is_subclass_of(SystemDictionary::reflect_MagicAccessorImpl_klass())) { + if (current_class->is_subclass_of(vmClasses::reflect_MagicAccessorImpl_klass())) { return true; } @@ -760,7 +760,7 @@ static objArrayHandle get_parameter_types(const methodHandle& method, oop* return_type, TRAPS) { // Allocate array holding parameter types (java.lang.Class instances) - objArrayOop m = oopFactory::new_objArray(SystemDictionary::Class_klass(), parameter_count, CHECK_(objArrayHandle())); + objArrayOop m = oopFactory::new_objArray(vmClasses::Class_klass(), parameter_count, CHECK_(objArrayHandle())); objArrayHandle mirrors(THREAD, m); int index = 0; // Collect parameter types diff --git a/src/hotspot/share/runtime/reflectionUtils.cpp b/src/hotspot/share/runtime/reflectionUtils.cpp index 77274e05a8dad..150cb06c1254c 100644 --- a/src/hotspot/share/runtime/reflectionUtils.cpp +++ b/src/hotspot/share/runtime/reflectionUtils.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,7 @@ #include "precompiled.hpp" #include "classfile/javaClasses.hpp" +#include "classfile/vmClasses.hpp" #include "memory/universe.hpp" #include "runtime/reflectionUtils.hpp" @@ -74,9 +75,9 @@ GrowableArray *FilteredFieldsMap::_filtered_fields = void FilteredFieldsMap::initialize() { int offset = reflect_ConstantPool::oop_offset(); - _filtered_fields->append(new FilteredField(SystemDictionary::reflect_ConstantPool_klass(), offset)); + _filtered_fields->append(new FilteredField(vmClasses::reflect_ConstantPool_klass(), offset)); offset = reflect_UnsafeStaticFieldAccessorImpl::base_offset(); - _filtered_fields->append(new FilteredField(SystemDictionary::reflect_UnsafeStaticFieldAccessorImpl_klass(), offset)); + _filtered_fields->append(new FilteredField(vmClasses::reflect_UnsafeStaticFieldAccessorImpl_klass(), offset)); } int FilteredFieldStream::field_count() { diff --git a/src/hotspot/share/runtime/safepoint.cpp b/src/hotspot/share/runtime/safepoint.cpp index 436ce93d18d60..92cb498412c8d 100644 --- a/src/hotspot/share/runtime/safepoint.cpp +++ b/src/hotspot/share/runtime/safepoint.cpp @@ -27,7 +27,6 @@ #include "classfile/dictionary.hpp" #include "classfile/stringTable.hpp" #include "classfile/symbolTable.hpp" -#include "classfile/systemDictionary.hpp" #include "code/codeCache.hpp" #include "code/icBuffer.hpp" #include "code/nmethod.hpp" diff --git a/src/hotspot/share/runtime/serviceThread.cpp b/src/hotspot/share/runtime/serviceThread.cpp index b19abc3e54299..ece227e72011d 100644 --- a/src/hotspot/share/runtime/serviceThread.cpp +++ b/src/hotspot/share/runtime/serviceThread.cpp @@ -29,6 +29,7 @@ #include "classfile/stringTable.hpp" #include "classfile/symbolTable.hpp" #include "classfile/systemDictionary.hpp" +#include "classfile/vmClasses.hpp" #include "gc/shared/oopStorage.hpp" #include "gc/shared/oopStorageSet.hpp" #include "memory/universe.hpp" @@ -95,7 +96,7 @@ void ServiceThread::initialize() { // Initialize thread_oop to put it into the system threadGroup Handle thread_group (THREAD, Universe::system_thread_group()); Handle thread_oop = JavaCalls::construct_new_instance( - SystemDictionary::Thread_klass(), + vmClasses::Thread_klass(), vmSymbols::threadgroup_string_void_signature(), thread_group, string, diff --git a/src/hotspot/share/runtime/sharedRuntime.cpp b/src/hotspot/share/runtime/sharedRuntime.cpp index c3b5a27a1f386..ff2b0057f256e 100644 --- a/src/hotspot/share/runtime/sharedRuntime.cpp +++ b/src/hotspot/share/runtime/sharedRuntime.cpp @@ -27,7 +27,7 @@ #include "jvm.h" #include "aot/aotLoader.hpp" #include "classfile/stringTable.hpp" -#include "classfile/systemDictionary.hpp" +#include "classfile/vmClasses.hpp" #include "classfile/vmSymbols.hpp" #include "code/codeCache.hpp" #include "code/compiledIC.hpp" @@ -788,7 +788,7 @@ void SharedRuntime::throw_StackOverflowError_common(JavaThread* thread, bool del // We avoid using the normal exception construction in this case because // it performs an upcall to Java, and we're already out of stack space. Thread* THREAD = thread; - Klass* k = SystemDictionary::StackOverflowError_klass(); + Klass* k = vmClasses::StackOverflowError_klass(); oop exception_oop = InstanceKlass::cast(k)->allocate_instance(CHECK); if (delayed) { java_lang_Throwable::set_message(exception_oop, @@ -1231,7 +1231,7 @@ methodHandle SharedRuntime::resolve_helper(JavaThread *thread, if (JvmtiExport::can_hotswap_or_post_breakpoint()) { int retry_count = 0; while (!HAS_PENDING_EXCEPTION && callee_method->is_old() && - callee_method->method_holder() != SystemDictionary::Object_klass()) { + callee_method->method_holder() != vmClasses::Object_klass()) { // If has a pending exception then there is no need to re-try to // resolve this method. // If the method has been redefined, we need to try again. diff --git a/src/hotspot/share/runtime/statSampler.cpp b/src/hotspot/share/runtime/statSampler.cpp index ed0060a09652c..1e669a9c6b358 100644 --- a/src/hotspot/share/runtime/statSampler.cpp +++ b/src/hotspot/share/runtime/statSampler.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ #include "precompiled.hpp" #include "classfile/javaClasses.hpp" -#include "classfile/systemDictionary.hpp" +#include "classfile/vmClasses.hpp" #include "classfile/vmSymbols.hpp" #include "memory/allocation.inline.hpp" #include "memory/resourceArea.hpp" @@ -189,7 +189,7 @@ void StatSampler::assert_system_property(const char* name, const char* value, TR // public static String getProperty(String key, String def); JavaCalls::call_static(&result, - SystemDictionary::System_klass(), + vmClasses::System_klass(), vmSymbols::getProperty_name(), vmSymbols::string_string_signature(), key_str, diff --git a/src/hotspot/share/runtime/thread.cpp b/src/hotspot/share/runtime/thread.cpp index f5bd4f09d2837..159f802bd0828 100644 --- a/src/hotspot/share/runtime/thread.cpp +++ b/src/hotspot/share/runtime/thread.cpp @@ -30,6 +30,7 @@ #include "classfile/javaThreadStatus.hpp" #include "classfile/moduleEntry.hpp" #include "classfile/systemDictionary.hpp" +#include "classfile/vmClasses.hpp" #include "classfile/vmSymbols.hpp" #include "code/codeCache.hpp" #include "code/scopeDesc.hpp" @@ -851,14 +852,14 @@ static void initialize_class(Symbol* class_name, TRAPS) { // Creates the initial ThreadGroup static Handle create_initial_thread_group(TRAPS) { Handle system_instance = JavaCalls::construct_new_instance( - SystemDictionary::ThreadGroup_klass(), + vmClasses::ThreadGroup_klass(), vmSymbols::void_method_signature(), CHECK_NH); Universe::set_system_thread_group(system_instance()); Handle string = java_lang_String::create_from_str("main", CHECK_NH); Handle main_instance = JavaCalls::construct_new_instance( - SystemDictionary::ThreadGroup_klass(), + vmClasses::ThreadGroup_klass(), vmSymbols::threadgroup_string_void_signature(), system_instance, string, @@ -869,7 +870,7 @@ static Handle create_initial_thread_group(TRAPS) { // Creates the initial Thread, and sets it to running. static void create_initial_thread(Handle thread_group, JavaThread* thread, TRAPS) { - InstanceKlass* ik = SystemDictionary::Thread_klass(); + InstanceKlass* ik = vmClasses::Thread_klass(); assert(ik->is_initialized(), "must be"); instanceHandle thread_oop = ik->allocate_instance_handle(CHECK); @@ -1047,7 +1048,7 @@ void JavaThread::allocate_threadObj(Handle thread_group, const char* thread_name assert(thread_group.not_null(), "thread group should be specified"); assert(threadObj() == NULL, "should only create Java thread object once"); - InstanceKlass* ik = SystemDictionary::Thread_klass(); + InstanceKlass* ik = vmClasses::Thread_klass(); assert(ik->is_initialized(), "must be"); instanceHandle thread_oop = ik->allocate_instance_handle(CHECK); @@ -1092,7 +1093,7 @@ void JavaThread::allocate_threadObj(Handle thread_group, const char* thread_name return; } - Klass* group = SystemDictionary::ThreadGroup_klass(); + Klass* group = vmClasses::ThreadGroup_klass(); Handle threadObj(THREAD, this->threadObj()); JavaCalls::call_special(&result, @@ -1862,7 +1863,7 @@ void JavaThread::exit(bool destroy_vm, ExitType exit_type) { if (uncaught_exception.not_null()) { EXCEPTION_MARK; // Call method Thread.dispatchUncaughtException(). - Klass* thread_klass = SystemDictionary::Thread_klass(); + Klass* thread_klass = vmClasses::Thread_klass(); JavaValue result(T_VOID); JavaCalls::call_virtual(&result, threadObj, thread_klass, @@ -1889,7 +1890,7 @@ void JavaThread::exit(bool destroy_vm, ExitType exit_type) { while (java_lang_Thread::threadGroup(threadObj()) != NULL && (count-- > 0)) { EXCEPTION_MARK; JavaValue result(T_VOID); - Klass* thread_klass = SystemDictionary::Thread_klass(); + Klass* thread_klass = vmClasses::Thread_klass(); JavaCalls::call_virtual(&result, threadObj, thread_klass, vmSymbols::exit_method_name(), @@ -2147,7 +2148,7 @@ void JavaThread::check_and_handle_async_exceptions(bool check_unsafe_error) { // Check for pending async. exception if (_pending_async_exception != NULL) { // Only overwrite an already pending exception, if it is not a threadDeath. - if (!has_pending_exception() || !pending_exception()->is_a(SystemDictionary::ThreadDeath_klass())) { + if (!has_pending_exception() || !pending_exception()->is_a(vmClasses::ThreadDeath_klass())) { // We cannot call Exceptions::_throw(...) here because we cannot block set_pending_exception(_pending_async_exception, __FILE__, __LINE__); @@ -2235,7 +2236,7 @@ void JavaThread::send_thread_stop(oop java_throwable) { { // Actually throw the Throwable against the target Thread - however // only if there is no thread death exception installed already. - if (_pending_async_exception == NULL || !_pending_async_exception->is_a(SystemDictionary::ThreadDeath_klass())) { + if (_pending_async_exception == NULL || !_pending_async_exception->is_a(vmClasses::ThreadDeath_klass())) { // If the topmost frame is a runtime stub, then we are calling into // OptoRuntime from compiled code. Some runtime stubs (new, monitor_exit..) // must deoptimize the caller before continuing, as the compiled exception handler table @@ -3302,7 +3303,7 @@ void Threads::possibly_parallel_threads_do(bool is_par, ThreadClosure* tc) { // fields in, out, and err. Set up java signal handlers, OS-specific // system settings, and thread group of the main thread. static void call_initPhase1(TRAPS) { - Klass* klass = SystemDictionary::System_klass(); + Klass* klass = vmClasses::System_klass(); JavaValue result(T_VOID); JavaCalls::call_static(&result, klass, vmSymbols::initPhase1_name(), vmSymbols::void_method_signature(), CHECK); @@ -3322,7 +3323,7 @@ static void call_initPhase1(TRAPS) { static void call_initPhase2(TRAPS) { TraceTime timer("Initialize module system", TRACETIME_LOG(Info, startuptime)); - Klass* klass = SystemDictionary::System_klass(); + Klass* klass = vmClasses::System_klass(); JavaValue result(T_INT); JavaCallArguments args; @@ -3344,7 +3345,7 @@ static void call_initPhase2(TRAPS) { // and system class loader may be a custom class loaded from -Xbootclasspath/a, // other modules or the application's classpath. static void call_initPhase3(TRAPS) { - Klass* klass = SystemDictionary::System_klass(); + Klass* klass = vmClasses::System_klass(); JavaValue result(T_VOID); JavaCalls::call_static(&result, klass, vmSymbols::initPhase3_name(), vmSymbols::void_method_signature(), CHECK); @@ -3376,7 +3377,7 @@ void Threads::initialize_java_lang_classes(JavaThread* main_thread, TRAPS) { initialize_class(vmSymbols::java_lang_Module(), CHECK); #ifdef ASSERT - InstanceKlass *k = SystemDictionary::UnsafeConstants_klass(); + InstanceKlass *k = vmClasses::UnsafeConstants_klass(); assert(k->is_not_initialized(), "UnsafeConstants should not already be initialized"); #endif diff --git a/src/hotspot/share/runtime/vframe.cpp b/src/hotspot/share/runtime/vframe.cpp index 6ed8efce415d5..5fa4e13e11ab8 100644 --- a/src/hotspot/share/runtime/vframe.cpp +++ b/src/hotspot/share/runtime/vframe.cpp @@ -25,7 +25,7 @@ #include "precompiled.hpp" #include "classfile/javaClasses.inline.hpp" #include "classfile/javaThreadStatus.hpp" -#include "classfile/systemDictionary.hpp" +#include "classfile/vmClasses.hpp" #include "classfile/vmSymbols.hpp" #include "code/codeCache.hpp" #include "code/debugInfoRec.hpp" @@ -161,7 +161,7 @@ GrowableArray* javaVFrame::locked_monitors() { void javaVFrame::print_locked_object_class_name(outputStream* st, Handle obj, const char* lock_state) { if (obj.not_null()) { st->print("\t- %s <" INTPTR_FORMAT "> ", lock_state, p2i(obj())); - if (obj->klass() == SystemDictionary::Class_klass()) { + if (obj->klass() == vmClasses::Class_klass()) { st->print_cr("(a java.lang.Class for %s)", java_lang_Class::as_external_name(obj())); } else { Klass* k = obj->klass(); @@ -565,8 +565,8 @@ void vframeStreamCommon::skip_prefixed_method_and_wrappers() { void vframeStreamCommon::skip_reflection_related_frames() { while (!at_end() && - (method()->method_holder()->is_subclass_of(SystemDictionary::reflect_MethodAccessorImpl_klass()) || - method()->method_holder()->is_subclass_of(SystemDictionary::reflect_ConstructorAccessorImpl_klass()))) { + (method()->method_holder()->is_subclass_of(vmClasses::reflect_MethodAccessorImpl_klass()) || + method()->method_holder()->is_subclass_of(vmClasses::reflect_ConstructorAccessorImpl_klass()))) { next(); } } diff --git a/src/hotspot/share/services/attachListener.cpp b/src/hotspot/share/services/attachListener.cpp index 4a2ef52abc9a0..6abbc9161745d 100644 --- a/src/hotspot/share/services/attachListener.cpp +++ b/src/hotspot/share/services/attachListener.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ #include "precompiled.hpp" #include "classfile/javaClasses.hpp" #include "classfile/systemDictionary.hpp" +#include "classfile/vmClasses.hpp" #include "gc/shared/gcVMOperations.hpp" #include "memory/resourceArea.hpp" #include "memory/universe.hpp" @@ -120,7 +121,7 @@ static jint load_agent(AttachOperation* op, outputStream* out) { JavaValue result(T_OBJECT); Handle h_module_name = java_lang_String::create_from_str("java.instrument", THREAD); JavaCalls::call_static(&result, - SystemDictionary::module_Modules_klass(), + vmClasses::module_Modules_klass(), vmSymbols::loadModule_name(), vmSymbols::loadModule_signature(), h_module_name, @@ -462,7 +463,7 @@ void AttachListener::init() { // Initialize thread_oop to put it into the system threadGroup Handle thread_group (THREAD, Universe::system_thread_group()); - Handle thread_oop = JavaCalls::construct_new_instance(SystemDictionary::Thread_klass(), + Handle thread_oop = JavaCalls::construct_new_instance(vmClasses::Thread_klass(), vmSymbols::threadgroup_string_void_signature(), thread_group, string, @@ -472,7 +473,7 @@ void AttachListener::init() { return; } - Klass* group = SystemDictionary::ThreadGroup_klass(); + Klass* group = vmClasses::ThreadGroup_klass(); JavaValue result(T_VOID); JavaCalls::call_special(&result, thread_group, diff --git a/src/hotspot/share/services/classLoadingService.cpp b/src/hotspot/share/services/classLoadingService.cpp index 0be073b4b0907..9da4496971c7e 100644 --- a/src/hotspot/share/services/classLoadingService.cpp +++ b/src/hotspot/share/services/classLoadingService.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,10 +23,11 @@ */ #include "precompiled.hpp" -#include "classfile/systemDictionary.hpp" #include "memory/allocation.hpp" #include "memory/resourceArea.hpp" #include "oops/oop.inline.hpp" +#include "oops/instanceKlass.hpp" +#include "oops/method.hpp" #include "runtime/mutexLocker.hpp" #include "services/classLoadingService.hpp" #include "services/memoryService.hpp" diff --git a/src/hotspot/share/services/diagnosticCommand.cpp b/src/hotspot/share/services/diagnosticCommand.cpp index e68ea46b8066c..7b1329898ee5f 100644 --- a/src/hotspot/share/services/diagnosticCommand.cpp +++ b/src/hotspot/share/services/diagnosticCommand.cpp @@ -27,6 +27,8 @@ #include "classfile/classLoaderHierarchyDCmd.hpp" #include "classfile/classLoaderStats.hpp" #include "classfile/javaClasses.hpp" +#include "classfile/systemDictionary.hpp" +#include "classfile/vmClasses.hpp" #include "code/codeCache.hpp" #include "compiler/compileBroker.hpp" #include "compiler/directivesParser.hpp" @@ -63,7 +65,7 @@ static void loadAgentModule(TRAPS) { JavaValue result(T_OBJECT); Handle h_module_name = java_lang_String::create_from_str("jdk.management.agent", CHECK); JavaCalls::call_static(&result, - SystemDictionary::module_Modules_klass(), + vmClasses::module_Modules_klass(), vmSymbols::loadModule_name(), vmSymbols::loadModule_signature(), h_module_name, @@ -448,7 +450,7 @@ void SystemGCDCmd::execute(DCmdSource source, TRAPS) { } void RunFinalizationDCmd::execute(DCmdSource source, TRAPS) { - Klass* k = SystemDictionary::System_klass(); + Klass* k = vmClasses::System_klass(); JavaValue result(T_VOID); JavaCalls::call_static(&result, k, vmSymbols::run_finalization_name(), diff --git a/src/hotspot/share/services/gcNotifier.cpp b/src/hotspot/share/services/gcNotifier.cpp index dd50fc8b0711e..c707ade8d484c 100644 --- a/src/hotspot/share/services/gcNotifier.cpp +++ b/src/hotspot/share/services/gcNotifier.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ #include "precompiled.hpp" #include "classfile/javaClasses.hpp" -#include "classfile/systemDictionary.hpp" +#include "classfile/vmClasses.hpp" #include "classfile/vmSymbols.hpp" #include "oops/objArrayOop.inline.hpp" #include "oops/oop.inline.hpp" @@ -133,13 +133,13 @@ static Handle createGcInfo(GCMemoryManager *gcManager, GCStatInfo *gcStatInfo,TR // Current implementation only has 1 attribute (number of GC threads) // The type is 'I' - objArrayOop extra_args_array = oopFactory::new_objArray(SystemDictionary::Integer_klass(), 1, CHECK_NH); + objArrayOop extra_args_array = oopFactory::new_objArray(vmClasses::Integer_klass(), 1, CHECK_NH); objArrayHandle extra_array (THREAD, extra_args_array); JavaCallArguments argsInt; argsInt.push_int(gcManager->num_gc_threads()); Handle extra_arg_val = JavaCalls::construct_new_instance( - SystemDictionary::Integer_klass(), + vmClasses::Integer_klass(), vmSymbols::int_void_signature(), &argsInt, CHECK_NH); diff --git a/src/hotspot/share/services/heapDumper.cpp b/src/hotspot/share/services/heapDumper.cpp index 322f9499c3a30..8d72853cab609 100644 --- a/src/hotspot/share/services/heapDumper.cpp +++ b/src/hotspot/share/services/heapDumper.cpp @@ -28,7 +28,7 @@ #include "classfile/classLoaderDataGraph.hpp" #include "classfile/javaClasses.inline.hpp" #include "classfile/symbolTable.hpp" -#include "classfile/systemDictionary.hpp" +#include "classfile/vmClasses.hpp" #include "classfile/vmSymbols.hpp" #include "gc/shared/gcLocker.hpp" #include "gc/shared/gcVMOperations.hpp" @@ -1423,7 +1423,7 @@ class HeapObjectDumper : public ObjectClosure { void HeapObjectDumper::do_object(oop o) { // skip classes as these emitted as HPROF_GC_CLASS_DUMP records - if (o->klass() == SystemDictionary::Class_klass()) { + if (o->klass() == vmClasses::Class_klass()) { if (!java_lang_Class::is_primitive(o)) { return; } @@ -1513,7 +1513,7 @@ class VM_HeapDumper : public VM_GC_Operation, public AbstractGangTask { if (oome) { assert(!Thread::current()->is_VM_thread(), "Dump from OutOfMemoryError cannot be called by the VMThread"); // get OutOfMemoryError zero-parameter constructor - InstanceKlass* oome_ik = SystemDictionary::OutOfMemoryError_klass(); + InstanceKlass* oome_ik = vmClasses::OutOfMemoryError_klass(); _oome_constructor = oome_ik->find_method(vmSymbols::object_initializer_name(), vmSymbols::void_method_signature()); // get thread throwing OOME when generating the heap dump at OOME diff --git a/src/hotspot/share/services/lowMemoryDetector.cpp b/src/hotspot/share/services/lowMemoryDetector.cpp index 58fe18d6e90fb..9e42bb2f01220 100644 --- a/src/hotspot/share/services/lowMemoryDetector.cpp +++ b/src/hotspot/share/services/lowMemoryDetector.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ */ #include "precompiled.hpp" -#include "classfile/systemDictionary.hpp" +#include "classfile/vmClasses.hpp" #include "classfile/vmSymbols.hpp" #include "memory/resourceArea.hpp" #include "memory/universe.hpp" @@ -311,7 +311,7 @@ void SensorInfo::trigger(int count, TRAPS) { // Sensor::trigger(int) instead. The pending request will be processed // but no notification will be sent. if (HAS_PENDING_EXCEPTION) { - assert((PENDING_EXCEPTION->is_a(SystemDictionary::OutOfMemoryError_klass())), "we expect only an OOME here"); + assert((PENDING_EXCEPTION->is_a(vmClasses::OutOfMemoryError_klass())), "we expect only an OOME here"); CLEAR_PENDING_EXCEPTION; trigger_method_signature = vmSymbols::int_void_signature(); } else { @@ -330,7 +330,7 @@ void SensorInfo::trigger(int count, TRAPS) { // We just clear the OOM pending exception that we might have encountered // in Java's tiggerAction(), and continue with updating the counters since // the Java counters have been updated too. - assert((PENDING_EXCEPTION->is_a(SystemDictionary::OutOfMemoryError_klass())), "we expect only an OOME here"); + assert((PENDING_EXCEPTION->is_a(vmClasses::OutOfMemoryError_klass())), "we expect only an OOME here"); CLEAR_PENDING_EXCEPTION; } } diff --git a/src/hotspot/share/services/management.cpp b/src/hotspot/share/services/management.cpp index e5fed2c7c2448..b62874f999e81 100644 --- a/src/hotspot/share/services/management.cpp +++ b/src/hotspot/share/services/management.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ #include "jmm.h" #include "classfile/classLoader.hpp" #include "classfile/systemDictionary.hpp" +#include "classfile/vmClasses.hpp" #include "compiler/compileBroker.hpp" #include "memory/allocation.inline.hpp" #include "memory/iterator.hpp" @@ -1216,7 +1217,7 @@ JVM_ENTRY(jobjectArray, jmm_DumpThreads(JNIEnv *env, jlongArray thread_ids, jboo if (locked_monitors) { // Constructs Object[] and int[] to contain the object monitor and the stack depth // where the thread locked it - objArrayOop array = oopFactory::new_objArray(SystemDictionary::Object_klass(), num_locked_monitors, CHECK_NULL); + objArrayOop array = oopFactory::new_objArray(vmClasses::Object_klass(), num_locked_monitors, CHECK_NULL); objArrayHandle mh(THREAD, array); monitors_array = mh; @@ -1258,7 +1259,7 @@ JVM_ENTRY(jobjectArray, jmm_DumpThreads(JNIEnv *env, jlongArray thread_ids, jboo GrowableArray* locks = (tcl != NULL ? tcl->owned_locks() : NULL); int num_locked_synchronizers = (locks != NULL ? locks->length() : 0); - objArrayOop array = oopFactory::new_objArray(SystemDictionary::Object_klass(), num_locked_synchronizers, CHECK_NULL); + objArrayOop array = oopFactory::new_objArray(vmClasses::Object_klass(), num_locked_synchronizers, CHECK_NULL); objArrayHandle sh(THREAD, array); synchronizers_array = sh; @@ -1398,7 +1399,7 @@ JVM_ENTRY(jobjectArray, jmm_GetVMGlobalNames(JNIEnv *env)) // last flag entry is always NULL, so subtract 1 int nFlags = (int) JVMFlag::numFlags - 1; // allocate a temp array - objArrayOop r = oopFactory::new_objArray(SystemDictionary::String_klass(), + objArrayOop r = oopFactory::new_objArray(vmClasses::String_klass(), nFlags, CHECK_NULL); objArrayHandle flags_ah(THREAD, r); int num_entries = 0; @@ -1418,7 +1419,7 @@ JVM_ENTRY(jobjectArray, jmm_GetVMGlobalNames(JNIEnv *env)) if (num_entries < nFlags) { // Return array of right length - objArrayOop res = oopFactory::new_objArray(SystemDictionary::String_klass(), num_entries, CHECK_NULL); + objArrayOop res = oopFactory::new_objArray(vmClasses::String_klass(), num_entries, CHECK_NULL); for(int i = 0; i < num_entries; i++) { res->obj_at_put(i, flags_ah->obj_at(i)); } @@ -1528,7 +1529,7 @@ JVM_ENTRY(jint, jmm_GetVMGlobals(JNIEnv *env, objArrayHandle names_ah(THREAD, ta); // Make sure we have a String array Klass* element_klass = ObjArrayKlass::cast(names_ah->klass())->element_klass(); - if (element_klass != SystemDictionary::String_klass()) { + if (element_klass != vmClasses::String_klass()) { THROW_MSG_(vmSymbols::java_lang_IllegalArgumentException(), "Array element type is not String class", 0); } @@ -1692,7 +1693,7 @@ JVM_ENTRY(jint, jmm_GetInternalThreadTimes(JNIEnv *env, // Make sure we have a String array Klass* element_klass = ObjArrayKlass::cast(names_ah->klass())->element_klass(); - if (element_klass != SystemDictionary::String_klass()) { + if (element_klass != vmClasses::String_klass()) { THROW_MSG_(vmSymbols::java_lang_IllegalArgumentException(), "Array element type is not String class", 0); } @@ -1727,7 +1728,7 @@ static Handle find_deadlocks(bool object_monitors_only, TRAPS) { num_threads += cycle->num_threads(); } - objArrayOop r = oopFactory::new_objArray(SystemDictionary::Thread_klass(), num_threads, CHECK_NH); + objArrayOop r = oopFactory::new_objArray(vmClasses::Thread_klass(), num_threads, CHECK_NH); objArrayHandle threads_ah(THREAD, r); int index = 0; @@ -1935,7 +1936,7 @@ JVM_END JVM_ENTRY(jobjectArray, jmm_GetDiagnosticCommands(JNIEnv *env)) ResourceMark rm(THREAD); GrowableArray* dcmd_list = DCmdFactory::DCmd_list(DCmd_Source_MBean); - objArrayOop cmd_array_oop = oopFactory::new_objArray(SystemDictionary::String_klass(), + objArrayOop cmd_array_oop = oopFactory::new_objArray(vmClasses::String_klass(), dcmd_list->length(), CHECK_NULL); objArrayHandle cmd_array(THREAD, cmd_array_oop); for (int i = 0; i < dcmd_list->length(); i++) { @@ -1958,7 +1959,7 @@ JVM_ENTRY(void, jmm_GetDiagnosticCommandInfo(JNIEnv *env, jobjectArray cmds, // Make sure we have a String array Klass* element_klass = ObjArrayKlass::cast(cmds_ah->klass())->element_klass(); - if (element_klass != SystemDictionary::String_klass()) { + if (element_klass != vmClasses::String_klass()) { THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), "Array element type is not String class"); } diff --git a/src/hotspot/share/services/memoryManager.cpp b/src/hotspot/share/services/memoryManager.cpp index 36d298dac9edb..e1594feb6e5bd 100644 --- a/src/hotspot/share/services/memoryManager.cpp +++ b/src/hotspot/share/services/memoryManager.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,6 @@ #include "precompiled.hpp" #include "classfile/javaClasses.hpp" -#include "classfile/systemDictionary.hpp" #include "classfile/vmSymbols.hpp" #include "memory/allocation.inline.hpp" #include "memory/universe.hpp" diff --git a/src/hotspot/share/services/memoryPool.cpp b/src/hotspot/share/services/memoryPool.cpp index 2462bcb50be77..3cdd5275b7b26 100644 --- a/src/hotspot/share/services/memoryPool.cpp +++ b/src/hotspot/share/services/memoryPool.cpp @@ -24,7 +24,6 @@ #include "precompiled.hpp" #include "classfile/javaClasses.hpp" -#include "classfile/systemDictionary.hpp" #include "classfile/vmSymbols.hpp" #include "memory/metaspace.hpp" #include "memory/universe.hpp" diff --git a/src/hotspot/share/services/memoryService.cpp b/src/hotspot/share/services/memoryService.cpp index 681bf5d7d5bda..bb74092b15c18 100644 --- a/src/hotspot/share/services/memoryService.cpp +++ b/src/hotspot/share/services/memoryService.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,6 @@ */ #include "precompiled.hpp" -#include "classfile/systemDictionary.hpp" #include "classfile/vmSymbols.hpp" #include "gc/shared/collectedHeap.hpp" #include "logging/logConfiguration.hpp" diff --git a/src/hotspot/share/services/threadService.cpp b/src/hotspot/share/services/threadService.cpp index ead65098d8a2d..ee08ac4160696 100644 --- a/src/hotspot/share/services/threadService.cpp +++ b/src/hotspot/share/services/threadService.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,7 @@ #include "precompiled.hpp" #include "classfile/systemDictionary.hpp" +#include "classfile/vmClasses.hpp" #include "classfile/vmSymbols.hpp" #include "gc/shared/oopStorageSet.hpp" #include "memory/allocation.hpp" @@ -453,7 +454,7 @@ DeadlockCycle* ThreadService::find_deadlocks_at_safepoint(ThreadsList * t_list, } } else { if (concurrent_locks) { - if (waitingToLockBlocker->is_a(SystemDictionary::java_util_concurrent_locks_AbstractOwnableSynchronizer_klass())) { + if (waitingToLockBlocker->is_a(vmClasses::java_util_concurrent_locks_AbstractOwnableSynchronizer_klass())) { oop threadObj = java_util_concurrent_locks_AbstractOwnableSynchronizer::get_owner_threadObj(waitingToLockBlocker); // This JavaThread (if there is one) is protected by the // ThreadsListSetter in VM_FindDeadlocks::doit(). @@ -717,7 +718,7 @@ bool ThreadStackTrace::is_owned_monitor_on_stack(oop object) { } Handle ThreadStackTrace::allocate_fill_stack_trace_element_array(TRAPS) { - InstanceKlass* ik = SystemDictionary::StackTraceElement_klass(); + InstanceKlass* ik = vmClasses::StackTraceElement_klass(); assert(ik != NULL, "must be loaded in 1.4+"); // Allocate an array of java/lang/StackTraceElement object @@ -765,7 +766,7 @@ void ConcurrentLocksDump::dump_at_safepoint() { GrowableArray* aos_objects = new (ResourceObj::C_HEAP, mtServiceability) GrowableArray(INITIAL_ARRAY_SIZE, mtServiceability); // Find all instances of AbstractOwnableSynchronizer - HeapInspection::find_instances_at_safepoint(SystemDictionary::java_util_concurrent_locks_AbstractOwnableSynchronizer_klass(), + HeapInspection::find_instances_at_safepoint(vmClasses::java_util_concurrent_locks_AbstractOwnableSynchronizer_klass(), aos_objects); // Build a map of thread to its owned AQS locks build_map(aos_objects); @@ -913,7 +914,7 @@ void ThreadSnapshot::initialize(ThreadsList * t_list, JavaThread* thread) { // Support for JSR-166 locks if (_thread_status == JavaThreadStatus::PARKED || _thread_status == JavaThreadStatus::PARKED_TIMED) { blocker_object = thread->current_park_blocker(); - if (blocker_object != NULL && blocker_object->is_a(SystemDictionary::java_util_concurrent_locks_AbstractOwnableSynchronizer_klass())) { + if (blocker_object != NULL && blocker_object->is_a(vmClasses::java_util_concurrent_locks_AbstractOwnableSynchronizer_klass())) { blocker_object_owner = java_util_concurrent_locks_AbstractOwnableSynchronizer::get_owner_threadObj(blocker_object); } } @@ -1022,7 +1023,7 @@ void DeadlockCycle::print_on_with(ThreadsList * t_list, outputStream* st) const st->print(" waiting for ownable synchronizer " INTPTR_FORMAT ", (a %s)", p2i(waitingToLockBlocker), waitingToLockBlocker->klass()->external_name()); - assert(waitingToLockBlocker->is_a(SystemDictionary::java_util_concurrent_locks_AbstractOwnableSynchronizer_klass()), + assert(waitingToLockBlocker->is_a(vmClasses::java_util_concurrent_locks_AbstractOwnableSynchronizer_klass()), "Must be an AbstractOwnableSynchronizer"); oop ownerObj = java_util_concurrent_locks_AbstractOwnableSynchronizer::get_owner_threadObj(waitingToLockBlocker); currentThread = java_lang_Thread::thread(ownerObj); diff --git a/src/hotspot/share/utilities/exceptions.cpp b/src/hotspot/share/utilities/exceptions.cpp index 735e7ed84b655..3887bcd35270a 100644 --- a/src/hotspot/share/utilities/exceptions.cpp +++ b/src/hotspot/share/utilities/exceptions.cpp @@ -25,6 +25,7 @@ #include "precompiled.hpp" #include "classfile/javaClasses.hpp" #include "classfile/systemDictionary.hpp" +#include "classfile/vmClasses.hpp" #include "classfile/vmSymbols.hpp" #include "compiler/compileBroker.hpp" #include "logging/log.hpp" @@ -73,8 +74,8 @@ void ThreadShadow::clear_pending_exception() { void ThreadShadow::clear_pending_nonasync_exception() { // Do not clear probable async exceptions. - if (!_pending_exception->is_a(SystemDictionary::ThreadDeath_klass()) && - (_pending_exception->klass() != SystemDictionary::InternalError_klass() || + if (!_pending_exception->is_a(vmClasses::ThreadDeath_klass()) && + (_pending_exception->klass() != vmClasses::InternalError_klass() || java_lang_InternalError::during_unsafe_access(_pending_exception) != JNI_TRUE)) { clear_pending_exception(); } @@ -94,7 +95,7 @@ bool Exceptions::special_exception(Thread* thread, const char* file, int line, H // to prevent infinite recursion trying to initialize stack overflow without // adequate stack space. // This can happen with stress testing a large value of StackShadowPages - if (h_exception()->klass() == SystemDictionary::StackOverflowError_klass()) { + if (h_exception()->klass() == vmClasses::StackOverflowError_klass()) { InstanceKlass* ik = InstanceKlass::cast(h_exception->klass()); assert(ik->is_initialized(), "need to increase java_thread_min_stack_allowed calculation"); @@ -162,15 +163,15 @@ void Exceptions::_throw(Thread* thread, const char* file, int line, Handle h_exc return; } - if (h_exception->is_a(SystemDictionary::OutOfMemoryError_klass())) { + if (h_exception->is_a(vmClasses::OutOfMemoryError_klass())) { count_out_of_memory_exceptions(h_exception); } - if (h_exception->is_a(SystemDictionary::LinkageError_klass())) { + if (h_exception->is_a(vmClasses::LinkageError_klass())) { Atomic::inc(&_linkage_errors); } - assert(h_exception->is_a(SystemDictionary::Throwable_klass()), "exception is not a subclass of java/lang/Throwable"); + assert(h_exception->is_a(vmClasses::Throwable_klass()), "exception is not a subclass of java/lang/Throwable"); // set the pending exception thread->set_pending_exception(h_exception(), file, line); @@ -235,7 +236,7 @@ void Exceptions::_throw_cause(Thread* thread, const char* file, int line, Symbol void Exceptions::throw_stack_overflow_exception(Thread* THREAD, const char* file, int line, const methodHandle& method) { Handle exception; if (!THREAD->has_pending_exception()) { - InstanceKlass* k = SystemDictionary::StackOverflowError_klass(); + InstanceKlass* k = vmClasses::StackOverflowError_klass(); oop e = k->allocate_instance(CHECK); exception = Handle(THREAD, e); // fill_in_stack trace does gc assert(k->is_initialized(), "need to increase java_thread_min_stack_allowed calculation"); @@ -310,7 +311,7 @@ Handle Exceptions::new_exception(Thread *thread, Symbol* name, // Future: object initializer should take a cause argument if (h_cause.not_null()) { - assert(h_cause->is_a(SystemDictionary::Throwable_klass()), + assert(h_cause->is_a(vmClasses::Throwable_klass()), "exception cause is not a subclass of java/lang/Throwable"); JavaValue result1(T_OBJECT); JavaCallArguments args1; @@ -434,7 +435,7 @@ void Exceptions::wrap_dynamic_exception(bool is_indy, Thread* THREAD) { // See the "Linking Exceptions" section for the invokedynamic instruction // in JVMS 6.5. - if (exception->is_a(SystemDictionary::Error_klass())) { + if (exception->is_a(vmClasses::Error_klass())) { // Pass through an Error, including BootstrapMethodError, any other form // of linkage error, or say ThreadDeath/OutOfMemoryError if (ls != NULL) { @@ -544,7 +545,7 @@ void Exceptions::debug_check_abort(Handle exception, const char* message) { void Exceptions::debug_check_abort_helper(Handle exception, const char* message) { ResourceMark rm; - if (message == NULL && exception->is_a(SystemDictionary::Throwable_klass())) { + if (message == NULL && exception->is_a(vmClasses::Throwable_klass())) { oop msg = java_lang_Throwable::message(exception()); if (msg != NULL) { message = java_lang_String::as_utf8_string(msg); diff --git a/src/hotspot/share/utilities/hashtable.cpp b/src/hotspot/share/utilities/hashtable.cpp index f456047c0f98d..902fd76440b30 100644 --- a/src/hotspot/share/utilities/hashtable.cpp +++ b/src/hotspot/share/utilities/hashtable.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,6 +31,7 @@ #include "classfile/placeholders.hpp" #include "classfile/protectionDomainCache.hpp" #include "classfile/stringTable.hpp" +#include "classfile/vmClasses.hpp" #include "code/nmethod.hpp" #include "logging/log.hpp" #include "memory/allocation.inline.hpp" @@ -120,7 +121,7 @@ static int literal_size(Symbol *symbol) { static int literal_size(oop obj) { if (obj == NULL) { return 0; - } else if (obj->klass() == SystemDictionary::String_klass()) { + } else if (obj->klass() == vmClasses::String_klass()) { // This may overcount if String.value arrays are shared. return (obj->size() + java_lang_String::value(obj)->size()) * HeapWordSize; } else { diff --git a/src/hotspot/share/utilities/vmEnums.hpp b/src/hotspot/share/utilities/vmEnums.hpp index 5bca318087f6b..e3d298f24bc0c 100644 --- a/src/hotspot/share/utilities/vmEnums.hpp +++ b/src/hotspot/share/utilities/vmEnums.hpp @@ -32,7 +32,7 @@ enum class JavaThreadStatus : int; enum class JVMFlagOrigin : int; enum JVMFlagsEnum : int; -enum class VMClassID : int; +enum class vmClassID : int; enum class vmIntrinsicID : int; enum class vmSymbolID : int; diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/memory/SystemDictionary.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/memory/SystemDictionary.java index 7910b8a39e4a5..cb3d21f3ab020 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/memory/SystemDictionary.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/memory/SystemDictionary.java @@ -54,7 +54,7 @@ public void update(Observable o, Object data) { private static synchronized void initialize(TypeDataBase db) { Type type = db.lookupType("vmClasses"); - // Note, vmStructs contains a field with the name "_klasses[static_cast(VMClassID::Object_klass_knum)]" + // Note, vmStructs contains a field with the name "_klasses[static_cast(vmClassID::Object_klass_knum)]" objectKlassField = type.getAddressField(VM_CLASS_AT("Object_klass")); classLoaderKlassField = type.getAddressField(VM_CLASS_AT("ClassLoader_klass")); stringKlassField = type.getAddressField(VM_CLASS_AT("String_klass")); @@ -71,8 +71,8 @@ private static String _VM_CLASS_ENUM(String kname) { } private static String VM_CLASS_ID(String kname) { - // #define VM_CLASS_ID(kname) VMClassID::_VM_CLASS_ENUM(kname) - return "VMClassID::" + _VM_CLASS_ENUM(kname); + // #define VM_CLASS_ID(kname) vmClassID::_VM_CLASS_ENUM(kname) + return "vmClassID::" + _VM_CLASS_ENUM(kname); } private static String VM_CLASS_AT(String name) { diff --git a/test/hotspot/gtest/oops/test_instanceKlass.cpp b/test/hotspot/gtest/oops/test_instanceKlass.cpp index 711a8fd8af829..9b170b5d72311 100644 --- a/test/hotspot/gtest/oops/test_instanceKlass.cpp +++ b/test/hotspot/gtest/oops/test_instanceKlass.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,18 +22,18 @@ */ #include "precompiled.hpp" -#include "classfile/systemDictionary.hpp" +#include "classfile/vmClasses.hpp" #include "memory/resourceArea.hpp" #include "oops/instanceKlass.hpp" #include "unittest.hpp" // Tests for InstanceKlass::is_class_loader_instance_klass() function TEST_VM(InstanceKlass, class_loader_class) { - InstanceKlass* klass = SystemDictionary::ClassLoader_klass(); + InstanceKlass* klass = vmClasses::ClassLoader_klass(); ASSERT_TRUE(klass->is_class_loader_instance_klass()); } TEST_VM(InstanceKlass, string_klass) { - InstanceKlass* klass = SystemDictionary::String_klass(); + InstanceKlass* klass = vmClasses::String_klass(); ASSERT_TRUE(!klass->is_class_loader_instance_klass()); } diff --git a/test/hotspot/gtest/oops/test_markWord.cpp b/test/hotspot/gtest/oops/test_markWord.cpp index 75b74ac165861..06d0434086c49 100644 --- a/test/hotspot/gtest/oops/test_markWord.cpp +++ b/test/hotspot/gtest/oops/test_markWord.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,9 +22,10 @@ */ #include "precompiled.hpp" -#include "classfile/systemDictionary.hpp" +#include "classfile/vmClasses.hpp" #include "memory/resourceArea.hpp" #include "memory/universe.hpp" +#include "oops/instanceKlass.hpp" #include "oops/oop.inline.hpp" #include "runtime/atomic.hpp" #include "runtime/biasedLocking.hpp" @@ -85,7 +86,7 @@ TEST_VM(markWord, printing) { ThreadInVMfromNative invm(THREAD); ResourceMark rm(THREAD); - oop obj = SystemDictionary::Byte_klass()->allocate_instance(THREAD); + oop obj = vmClasses::Byte_klass()->allocate_instance(THREAD); FlagSetting fs(WizardMode, true); From bec60432ecbdc5e68b80b6cf0dc33934ee2eb2d1 Mon Sep 17 00:00:00 2001 From: Alexander Matveev Date: Wed, 3 Feb 2021 00:29:08 +0000 Subject: [PATCH 32/77] 8259570: (macos) tools/jpackage tests fails with 'hdiutil: couldn't eject "disk2" - Resource busy' Reviewed-by: herrick, asemenyuk --- .../jdk/jpackage/internal/MacDmgBundler.java | 37 +++++++++++++++--- .../jdk/jpackage/internal/RetryExecutor.java | 18 ++++----- .../helpers/jdk/jpackage/test/MacHelper.java | 38 ++++++++++++++++--- 3 files changed, 73 insertions(+), 20 deletions(-) diff --git a/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacDmgBundler.java b/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacDmgBundler.java index 26c3bd30f8797..8e1afe17619ee 100644 --- a/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacDmgBundler.java +++ b/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacDmgBundler.java @@ -437,7 +437,6 @@ private Path buildDMG( Map params, pb = new ProcessBuilder( hdiutil, "detach", - "-force", hdiUtilVerbosityFlag, mountedRoot.toAbsolutePath().toString()); // "hdiutil detach" might not work right away due to resource busy error, so @@ -451,12 +450,21 @@ private Path buildDMG( Map params, } }); try { - // 10 times with 3 second delays. - retryExecutor.setMaxAttemptsCount(10).setAttemptTimeoutMillis(3000) + // 10 times with 6 second delays. + retryExecutor.setMaxAttemptsCount(10).setAttemptTimeoutMillis(6000) .execute(pb); } catch (IOException ex) { if (!retryExecutor.isAborted()) { - throw ex; + // Now force to detach if it still attached + if (Files.exists(mountedRoot)) { + pb = new ProcessBuilder( + hdiutil, + "detach", + "-force", + hdiUtilVerbosityFlag, + mountedRoot.toAbsolutePath().toString()); + IOUtils.exec(pb); + } } } } @@ -469,10 +477,29 @@ private Path buildDMG( Map params, hdiUtilVerbosityFlag, "-format", "UDZO", "-o", finalDMG.toAbsolutePath().toString()); - new RetryExecutor() + try { + new RetryExecutor() .setMaxAttemptsCount(10) .setAttemptTimeoutMillis(3000) .execute(pb); + } catch (Exception ex) { + // Convert might failed if something holds file. Try to convert copy. + Path protoDMG2 = imagesRoot + .resolve(APP_NAME.fetchFrom(params) + "-tmp2.dmg"); + Files.copy(protoDMG, protoDMG2); + try { + pb = new ProcessBuilder( + hdiutil, + "convert", + protoDMG2.toAbsolutePath().toString(), + hdiUtilVerbosityFlag, + "-format", "UDZO", + "-o", finalDMG.toAbsolutePath().toString()); + IOUtils.exec(pb); + } finally { + Files.deleteIfExists(protoDMG2); + } + } //add license if needed if (Files.exists(getConfig_LicenseFile(params))) { diff --git a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/RetryExecutor.java b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/RetryExecutor.java index dfa75b217afce..6043fc7b1876f 100644 --- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/RetryExecutor.java +++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/RetryExecutor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,31 +29,31 @@ import java.util.function.Supplier; public final class RetryExecutor { - RetryExecutor() { + public RetryExecutor() { setMaxAttemptsCount(5); setAttemptTimeoutMillis(2 * 1000); } - RetryExecutor setMaxAttemptsCount(int v) { + public RetryExecutor setMaxAttemptsCount(int v) { attempts = v; return this; } - RetryExecutor setAttemptTimeoutMillis(int v) { + public RetryExecutor setAttemptTimeoutMillis(int v) { timeoutMillis = v; return this; } - RetryExecutor setExecutorInitializer(Consumer v) { + public RetryExecutor setExecutorInitializer(Consumer v) { executorInitializer = v; return this; } - void abort() { + public void abort() { aborted = true; } - boolean isAborted() { + public boolean isAborted() { return aborted; } @@ -68,11 +68,11 @@ static RetryExecutor retryOnKnownErrorMessage(String v) { }); } - void execute(String cmdline[]) throws IOException { + public void execute(String cmdline[]) throws IOException { executeLoop(() -> Executor.of(cmdline)); } - void execute(ProcessBuilder pb) throws IOException { + public void execute(ProcessBuilder pb) throws IOException { executeLoop(() -> Executor.of(pb)); } diff --git a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/MacHelper.java b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/MacHelper.java index f10e01fc52e4f..d4d251e70d8ca 100644 --- a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/MacHelper.java +++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/MacHelper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,6 +42,7 @@ import jdk.jpackage.test.Functional.ThrowingConsumer; import jdk.jpackage.test.Functional.ThrowingSupplier; import jdk.jpackage.test.PackageTest.PackageHandlers; +import jdk.jpackage.internal.RetryExecutor; import org.xml.sax.SAXException; import org.w3c.dom.NodeList; @@ -66,11 +67,36 @@ public static void withExplodedDmg(JPackageCommand cmd, cmd.outputBundle(), dmgImage)); ThrowingConsumer.toConsumer(consumer).accept(dmgImage); } finally { - // detach might not work right away due to resource busy error, so - // repeat detach several times or fail. Try 10 times with 3 seconds - // delay. - Executor.of("/usr/bin/hdiutil", "detach").addArgument(mountPoint). - executeAndRepeatUntilExitCode(0, 10, 3); + String cmdline[] = { + "/usr/bin/hdiutil", + "detach", + "-verbose", + mountPoint.toAbsolutePath().toString()}; + // "hdiutil detach" might not work right away due to resource busy error, so + // repeat detach several times. + RetryExecutor retryExecutor = new RetryExecutor(); + // Image can get detach even if we got resource busy error, so stop + // trying to detach it if it is no longer attached. + retryExecutor.setExecutorInitializer(exec -> { + if (!Files.exists(mountPoint)) { + retryExecutor.abort(); + } + }); + try { + // 10 times with 6 second delays. + retryExecutor.setMaxAttemptsCount(10) + .setAttemptTimeoutMillis(6000) + .execute(cmdline); + } catch (IOException ex) { + if (!retryExecutor.isAborted()) { + // Now force to detach if it still attached + if (Files.exists(mountPoint)) { + Executor.of("/usr/bin/hdiutil", "detach", + "-force", "-verbose") + .addArgument(mountPoint).execute(); + } + } + } } } From d423d368e79e4c7da7d165d827d6ba90bd113450 Mon Sep 17 00:00:00 2001 From: Kim Barrett Date: Wed, 3 Feb 2021 00:52:09 +0000 Subject: [PATCH 33/77] 8258508: Merge G1RedirtyCardsQueue into qset Reviewed-by: tschatzl, iwalulya --- src/hotspot/share/gc/g1/g1EvacFailure.cpp | 12 ++----- .../share/gc/g1/g1ParScanThreadState.cpp | 2 -- .../share/gc/g1/g1ParScanThreadState.hpp | 3 +- .../share/gc/g1/g1RedirtyCardsQueue.cpp | 22 ++++++------- .../share/gc/g1/g1RedirtyCardsQueue.hpp | 33 +++++++++---------- 5 files changed, 29 insertions(+), 43 deletions(-) diff --git a/src/hotspot/share/gc/g1/g1EvacFailure.cpp b/src/hotspot/share/gc/g1/g1EvacFailure.cpp index 382f8f92248df..1a018269419ef 100644 --- a/src/hotspot/share/gc/g1/g1EvacFailure.cpp +++ b/src/hotspot/share/gc/g1/g1EvacFailure.cpp @@ -41,7 +41,6 @@ class UpdateLogBuffersDeferred : public BasicOopIterateClosure { private: G1CollectedHeap* _g1h; G1RedirtyCardsLocalQueueSet* _rdc_local_qset; - G1RedirtyCardsQueue* _rdcq; G1CardTable* _ct; // Remember the last enqueued card to avoid enqueuing the same card over and over; @@ -49,11 +48,9 @@ class UpdateLogBuffersDeferred : public BasicOopIterateClosure { size_t _last_enqueued_card; public: - UpdateLogBuffersDeferred(G1RedirtyCardsLocalQueueSet* rdc_local_qset, - G1RedirtyCardsQueue* rdcq) : + UpdateLogBuffersDeferred(G1RedirtyCardsLocalQueueSet* rdc_local_qset) : _g1h(G1CollectedHeap::heap()), _rdc_local_qset(rdc_local_qset), - _rdcq(rdcq), _ct(_g1h->card_table()), _last_enqueued_card(SIZE_MAX) {} @@ -73,7 +70,7 @@ class UpdateLogBuffersDeferred : public BasicOopIterateClosure { } size_t card_index = _ct->index_for(p); if (card_index != _last_enqueued_card) { - _rdc_local_qset->enqueue(*_rdcq, _ct->byte_for_index(card_index)); + _rdc_local_qset->enqueue(_ct->byte_for_index(card_index)); _last_enqueued_card = card_index; } } @@ -206,7 +203,6 @@ class RemoveSelfForwardPtrHRClosure: public HeapRegionClosure { uint _worker_id; G1RedirtyCardsLocalQueueSet _rdc_local_qset; - G1RedirtyCardsQueue _rdcq; UpdateLogBuffersDeferred _log_buffer_cl; public: @@ -214,12 +210,10 @@ class RemoveSelfForwardPtrHRClosure: public HeapRegionClosure { _g1h(G1CollectedHeap::heap()), _worker_id(worker_id), _rdc_local_qset(rdcqs), - _rdcq(&_rdc_local_qset), - _log_buffer_cl(&_rdc_local_qset, &_rdcq) { + _log_buffer_cl(&_rdc_local_qset) { } ~RemoveSelfForwardPtrHRClosure() { - _rdc_local_qset.flush_queue(_rdcq); _rdc_local_qset.flush(); } diff --git a/src/hotspot/share/gc/g1/g1ParScanThreadState.cpp b/src/hotspot/share/gc/g1/g1ParScanThreadState.cpp index c152342cc4ae9..ce1eb33a543b5 100644 --- a/src/hotspot/share/gc/g1/g1ParScanThreadState.cpp +++ b/src/hotspot/share/gc/g1/g1ParScanThreadState.cpp @@ -59,7 +59,6 @@ G1ParScanThreadState::G1ParScanThreadState(G1CollectedHeap* g1h, : _g1h(g1h), _task_queue(g1h->task_queue(worker_id)), _rdc_local_qset(rdcqs), - _rdcq(&_rdc_local_qset), _ct(g1h->card_table()), _closures(NULL), _plab_allocator(NULL), @@ -114,7 +113,6 @@ G1ParScanThreadState::G1ParScanThreadState(G1CollectedHeap* g1h, } size_t G1ParScanThreadState::flush(size_t* surviving_young_words) { - _rdc_local_qset.flush_queue(_rdcq); _rdc_local_qset.flush(); flush_numa_stats(); // Update allocation statistics. diff --git a/src/hotspot/share/gc/g1/g1ParScanThreadState.hpp b/src/hotspot/share/gc/g1/g1ParScanThreadState.hpp index 1f1617793e63c..a6fb60ece9453 100644 --- a/src/hotspot/share/gc/g1/g1ParScanThreadState.hpp +++ b/src/hotspot/share/gc/g1/g1ParScanThreadState.hpp @@ -49,7 +49,6 @@ class G1ParScanThreadState : public CHeapObj { G1CollectedHeap* _g1h; G1ScannerTasksQueue* _task_queue; G1RedirtyCardsLocalQueueSet _rdc_local_qset; - G1RedirtyCardsQueue _rdcq; G1CardTable* _ct; G1EvacuationRootClosures* _closures; @@ -148,7 +147,7 @@ class G1ParScanThreadState : public CHeapObj { size_t card_index = ct()->index_for(p); // If the card hasn't been added to the buffer, do it. if (_last_enqueued_card != card_index) { - _rdc_local_qset.enqueue(_rdcq, ct()->byte_for_index(card_index)); + _rdc_local_qset.enqueue(ct()->byte_for_index(card_index)); _last_enqueued_card = card_index; } } diff --git a/src/hotspot/share/gc/g1/g1RedirtyCardsQueue.cpp b/src/hotspot/share/gc/g1/g1RedirtyCardsQueue.cpp index b9a65ba3629a3..a1802e01821fe 100644 --- a/src/hotspot/share/gc/g1/g1RedirtyCardsQueue.cpp +++ b/src/hotspot/share/gc/g1/g1RedirtyCardsQueue.cpp @@ -33,7 +33,8 @@ G1RedirtyCardsLocalQueueSet::G1RedirtyCardsLocalQueueSet(G1RedirtyCardsQueueSet* shared_qset) : PtrQueueSet(shared_qset->allocator()), _shared_qset(shared_qset), - _buffers() + _buffers(), + _queue(this) {} #ifdef ASSERT @@ -53,33 +54,30 @@ void G1RedirtyCardsLocalQueueSet::enqueue_completed_buffer(BufferNode* node) { } } -void G1RedirtyCardsLocalQueueSet::enqueue(G1RedirtyCardsQueue& queue, void* value) { - if (!try_enqueue(queue, value)) { - BufferNode* old_node = exchange_buffer_with_new(queue); +void G1RedirtyCardsLocalQueueSet::enqueue(void* value) { + if (!try_enqueue(_queue, value)) { + BufferNode* old_node = exchange_buffer_with_new(_queue); if (old_node != nullptr) { enqueue_completed_buffer(old_node); } - retry_enqueue(queue, value); + retry_enqueue(_queue, value); } } void G1RedirtyCardsLocalQueueSet::flush() { + flush_queue(_queue); _shared_qset->add_bufferlist(_buffers); _buffers = G1BufferNodeList(); } -void G1RedirtyCardsLocalQueueSet::flush_queue(G1RedirtyCardsQueue& queue) { - PtrQueueSet::flush_queue(queue); -} - -// G1RedirtyCardsQueue +// G1RedirtyCardsLocalQueueSet::Queue -G1RedirtyCardsQueue::G1RedirtyCardsQueue(G1RedirtyCardsLocalQueueSet* qset) : +G1RedirtyCardsLocalQueueSet::Queue::Queue(G1RedirtyCardsLocalQueueSet* qset) : PtrQueue(qset) {} #ifdef ASSERT -G1RedirtyCardsQueue::~G1RedirtyCardsQueue() { +G1RedirtyCardsLocalQueueSet::Queue::~Queue() { assert(buffer() == nullptr, "unflushed queue"); } #endif // ASSERT diff --git a/src/hotspot/share/gc/g1/g1RedirtyCardsQueue.hpp b/src/hotspot/share/gc/g1/g1RedirtyCardsQueue.hpp index d91288aca9f67..26bb78c4096e5 100644 --- a/src/hotspot/share/gc/g1/g1RedirtyCardsQueue.hpp +++ b/src/hotspot/share/gc/g1/g1RedirtyCardsQueue.hpp @@ -28,37 +28,34 @@ #include "gc/g1/g1BufferNodeList.hpp" #include "gc/shared/ptrQueue.hpp" #include "memory/padded.hpp" +#include "utilities/macros.hpp" -class G1RedirtyCardsQueue; class G1RedirtyCardsQueueSet; -// Provide G1RedirtyCardsQueue with a thread-local qset. It provides an -// uncontended staging area for completed buffers, to be flushed to the -// shared qset en masse. -class G1RedirtyCardsLocalQueueSet : public PtrQueueSet { +// A thread-local qset and queue. It provides an uncontended staging +// area for completed buffers, to be flushed to the shared qset en masse. +class G1RedirtyCardsLocalQueueSet : private PtrQueueSet { + class Queue : public PtrQueue { + public: + Queue(G1RedirtyCardsLocalQueueSet* qset); + ~Queue() NOT_DEBUG(= default); + }; + G1RedirtyCardsQueueSet* _shared_qset; G1BufferNodeList _buffers; + Queue _queue; + + // Add the buffer to the local list. + virtual void enqueue_completed_buffer(BufferNode* node); public: G1RedirtyCardsLocalQueueSet(G1RedirtyCardsQueueSet* shared_qset); ~G1RedirtyCardsLocalQueueSet() NOT_DEBUG(= default); - void enqueue(G1RedirtyCardsQueue& queue, void* value); - - // Add the buffer to the local list. - virtual void enqueue_completed_buffer(BufferNode* node); + void enqueue(void* value); // Transfer all completed buffers to the shared qset. void flush(); - - void flush_queue(G1RedirtyCardsQueue& queue); -}; - -// Worker-local queues of card table entries. -class G1RedirtyCardsQueue : public PtrQueue { -public: - G1RedirtyCardsQueue(G1RedirtyCardsLocalQueueSet* qset); - ~G1RedirtyCardsQueue() NOT_DEBUG(= default); }; // Card table entries to be redirtied and the cards reprocessed later. From a47befc86fe673110de88f898eb6751625d144d7 Mon Sep 17 00:00:00 2001 From: Jie Fu Date: Wed, 3 Feb 2021 01:18:11 +0000 Subject: [PATCH 34/77] 8260878: com/sun/jdi/JdbOptions.java fails without jfr Reviewed-by: amenkov, cjplummer --- test/jdk/com/sun/jdi/JdbOptions.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/jdk/com/sun/jdi/JdbOptions.java b/test/jdk/com/sun/jdi/JdbOptions.java index 0ba8e4bd612e6..b6fb965e319c6 100644 --- a/test/jdk/com/sun/jdi/JdbOptions.java +++ b/test/jdk/com/sun/jdi/JdbOptions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -96,6 +96,7 @@ public static void main(String[] args) throws Exception { // 'options' contains commas - values are quoted (double quotes) test("-connect", "com.sun.jdi.CommandLineLaunch:vmexec=java,options=\"-client\" \"-XX:+PrintVMOptions\"" + + " -XX:+IgnoreUnrecognizedVMOptions" + " \"-XX:StartFlightRecording=dumponexit=true,maxsize=500M\" \"-XX:FlightRecorderOptions=repository=jfrrep\"" + ",main=" + targ) .expectedArg("-XX:StartFlightRecording=dumponexit=true,maxsize=500M") @@ -104,6 +105,7 @@ public static void main(String[] args) throws Exception { // 'options' contains commas - values are quoted (single quotes) test("-connect", "com.sun.jdi.CommandLineLaunch:vmexec=java,options='-client' '-XX:+PrintVMOptions'" + + " -XX:+IgnoreUnrecognizedVMOptions" + " '-XX:StartFlightRecording=dumponexit=true,maxsize=500M' '-XX:FlightRecorderOptions=repository=jfrrep'" + ",main=" + targ) .expectedArg("-XX:StartFlightRecording=dumponexit=true,maxsize=500M") @@ -115,6 +117,7 @@ public static void main(String[] args) throws Exception { "-Dprop2=val 2", "-connect", "com.sun.jdi.CommandLineLaunch:vmexec=java,options=-Dprop3=val3 '-Dprop4=val 4'" + + " -XX:+IgnoreUnrecognizedVMOptions" + " \"-XX:StartFlightRecording=dumponexit=true,maxsize=500M\"" + " '-XX:FlightRecorderOptions=repository=jfrrep'" + ",main=" + targ + " prop1 prop2 prop3 prop4") From 98a76921ec782b720fe13f25f0e247b12fcbc638 Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Wed, 3 Feb 2021 03:41:53 +0000 Subject: [PATCH 35/77] 8076313: GraphicsEnvironment does not detect changes in count of monitors on Linux OS Reviewed-by: kizune --- .../unix/classes/sun/awt/X11/XToolkit.java | 5 +- .../classes/sun/awt/X11GraphicsConfig.java | 15 +- .../classes/sun/awt/X11GraphicsDevice.java | 37 +++- .../sun/awt/X11GraphicsEnvironment.java | 120 ++++++++--- .../native/libawt_xawt/awt/awt_GraphicsEnv.c | 202 +++++++++--------- .../unix/native/libawt_xawt/xawt/XToolkit.c | 5 +- 6 files changed, 242 insertions(+), 142 deletions(-) diff --git a/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java b/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java index 687f7dbf395c5..3327b5ef8a716 100644 --- a/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java +++ b/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -351,8 +351,7 @@ public void dispatchEvent(XEvent ev) { awtUnlock(); try { ((X11GraphicsEnvironment)GraphicsEnvironment. - getLocalGraphicsEnvironment()). - displayChanged(); + getLocalGraphicsEnvironment()).rebuildDevices(); } finally { awtLock(); } diff --git a/src/java.desktop/unix/classes/sun/awt/X11GraphicsConfig.java b/src/java.desktop/unix/classes/sun/awt/X11GraphicsConfig.java index 2954d1dbbc1c0..4ac6a304f03a4 100644 --- a/src/java.desktop/unix/classes/sun/awt/X11GraphicsConfig.java +++ b/src/java.desktop/unix/classes/sun/awt/X11GraphicsConfig.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -329,19 +329,10 @@ public String toString() { } @Override - public Rectangle getBounds() { - Rectangle rect = pGetBounds(device.getScreen()); - if (getScale() != 1) { - rect.x = scaleDown(rect.x); - rect.y = scaleDown(rect.y); - rect.width = scaleDown(rect.width); - rect.height = scaleDown(rect.height); - } - return rect; + public final Rectangle getBounds() { + return device.getBounds(); } - private native Rectangle pGetBounds(int screenNum); - private static class XDBECapabilities extends BufferCapabilities { public XDBECapabilities() { super(imageCaps, imageCaps, FlipContents.UNDEFINED); diff --git a/src/java.desktop/unix/classes/sun/awt/X11GraphicsDevice.java b/src/java.desktop/unix/classes/sun/awt/X11GraphicsDevice.java index b342c3dd0c402..51dd5a4e66908 100644 --- a/src/java.desktop/unix/classes/sun/awt/X11GraphicsDevice.java +++ b/src/java.desktop/unix/classes/sun/awt/X11GraphicsDevice.java @@ -42,6 +42,7 @@ import sun.java2d.SunGraphicsEnvironment; import sun.java2d.loops.SurfaceType; import sun.java2d.opengl.GLXGraphicsConfig; +import sun.java2d.pipe.Region; import sun.java2d.xr.XRGraphicsConfig; /** @@ -53,7 +54,11 @@ */ public final class X11GraphicsDevice extends GraphicsDevice implements DisplayChangedListener { - int screen; + /** + * X11 screen number. This identifier can become non-valid at any time + * therefore methods, which is using this id should be ready to it. + */ + private volatile int screen; HashMap x11ProxyKeyMap = new HashMap<>(); private static AWTPermission fullScreenExclusivePermission; @@ -105,6 +110,25 @@ public int getType() { return TYPE_RASTER_SCREEN; } + public int scaleUp(int x) { + return Region.clipRound(x * (double)getScaleFactor()); + } + + public int scaleDown(int x) { + return Region.clipRound(x / (double)getScaleFactor()); + } + + public Rectangle getBounds() { + Rectangle rect = pGetBounds(getScreen()); + if (getScaleFactor() != 1) { + rect.x = scaleDown(rect.x); + rect.y = scaleDown(rect.y); + rect.width = scaleDown(rect.width); + rect.height = scaleDown(rect.height); + } + return rect; + } + /** * Returns the identification string associated with this graphics * device. @@ -165,8 +189,8 @@ private void makeConfigurations() { doubleBufferVisuals.contains(Integer.valueOf(visNum))); if (xrenderSupported) { - ret[i] = XRGraphicsConfig.getConfig(this, visNum, depth, getConfigColormap(i, screen), - doubleBuffer); + ret[i] = XRGraphicsConfig.getConfig(this, visNum, depth, + getConfigColormap(i, screen), doubleBuffer); } else { ret[i] = X11GraphicsConfig.getConfig(this, visNum, depth, getConfigColormap(i, screen), @@ -271,8 +295,8 @@ private static native void enumDisplayModes(int screen, private static native void configDisplayMode(int screen, int width, int height, int displayMode); - private static native void resetNativeData(int screen); private static native double getNativeScaleFactor(int screen); + private native Rectangle pGetBounds(int screenNum); /** * Returns true only if: @@ -514,7 +538,6 @@ public int getScaleFactor() { } public int getNativeScale() { - isXrandrExtensionSupported(); return (int)Math.round(getNativeScaleFactor(screen)); } @@ -544,4 +567,8 @@ public void removeDisplayChangedListener(DisplayChangedListener client) { public String toString() { return ("X11GraphicsDevice[screen="+screen+"]"); } + + public void invalidate(X11GraphicsDevice device) { + screen = device.screen; + } } diff --git a/src/java.desktop/unix/classes/sun/awt/X11GraphicsEnvironment.java b/src/java.desktop/unix/classes/sun/awt/X11GraphicsEnvironment.java index 42984519f734d..ce85c2db53761 100644 --- a/src/java.desktop/unix/classes/sun/awt/X11GraphicsEnvironment.java +++ b/src/java.desktop/unix/classes/sun/awt/X11GraphicsEnvironment.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,17 +27,23 @@ import java.awt.AWTError; import java.awt.GraphicsDevice; +import java.lang.ref.WeakReference; import java.net.InetAddress; import java.net.NetworkInterface; import java.net.SocketException; import java.net.UnknownHostException; +import java.util.ArrayList; import java.util.Enumeration; +import java.util.HashMap; +import java.util.List; +import java.util.ListIterator; +import java.util.Map; +import sun.awt.X11.XToolkit; import sun.java2d.SunGraphicsEnvironment; import sun.java2d.SurfaceManagerFactory; import sun.java2d.UnixSurfaceManagerFactory; import sun.java2d.xr.XRSurfaceData; -import sun.util.logging.PlatformLogger; /** * This is an implementation of a GraphicsEnvironment object for the @@ -49,11 +55,6 @@ */ public final class X11GraphicsEnvironment extends SunGraphicsEnvironment { - private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.X11GraphicsEnvironment"); - private static final PlatformLogger screenLog = PlatformLogger.getLogger("sun.awt.screen.X11GraphicsEnvironment"); - - private static Boolean xinerState; - static { java.security.AccessController.doPrivileged( new java.security.PrivilegedAction() { @@ -169,32 +170,109 @@ public static boolean isXRenderVerbose() { private static native String getDisplayString(); private Boolean isDisplayLocal; + /** Available X11 screens. */ + private final Map devices = new HashMap<>(5); + + /** + * The key in the {@link #devices} for the main screen. + */ + private int mainScreen; + + // list of invalidated graphics devices (those which were removed) + private List> oldDevices = new ArrayList<>(); + /** * This should only be called from the static initializer, so no need for * the synchronized keyword. */ private static native void initDisplay(boolean glxRequested); + protected native int getNumScreens(); + + private native int getDefaultScreenNum(); + public X11GraphicsEnvironment() { + if (isHeadless()) { + return; + } + + /* Populate the device table */ + rebuildDevices(); } - protected native int getNumScreens(); + /** + * Initialize the native list of devices. + */ + private static native void initNativeData(); - protected GraphicsDevice makeScreenDevice(int screennum) { - return new X11GraphicsDevice(screennum); + /** + * Updates the list of devices and notify listeners. + */ + public void rebuildDevices() { + XToolkit.awtLock(); + try { + initNativeData(); + initDevices(); + } finally { + XToolkit.awtUnlock(); + } + displayChanged(); } - private native int getDefaultScreenNum(); /** - * Returns the default screen graphics device. + * (Re)create all X11GraphicsDevices, reuses a devices if it is possible. */ - public GraphicsDevice getDefaultScreenDevice() { - GraphicsDevice[] screens = getScreenDevices(); - if (screens.length == 0) { + private synchronized void initDevices() { + Map old = new HashMap<>(devices); + devices.clear(); + + int numScreens = getNumScreens(); + if (numScreens == 0) { throw new AWTError("no screen devices"); } int index = getDefaultScreenNum(); - return screens[0 < index && index < screens.length ? index : 0]; + mainScreen = 0 < index && index < screens.length ? index : 0; + + for (int id = 0; id < numScreens; ++id) { + devices.put(id, old.containsKey(id) ? old.remove(id) : + new X11GraphicsDevice(id)); + } + // if a device was not reused it should be invalidated + for (X11GraphicsDevice gd : old.values()) { + oldDevices.add(new WeakReference<>(gd)); + } + // Need to notify old devices, in case the user hold the reference to it + for (ListIterator> it = + oldDevices.listIterator(); it.hasNext(); ) { + X11GraphicsDevice gd = it.next().get(); + if (gd != null) { + gd.invalidate(devices.get(mainScreen)); + gd.displayChanged(); + } else { + // no more references to this device, remove it + it.remove(); + } + } + } + + @Override + public synchronized GraphicsDevice getDefaultScreenDevice() { + return devices.get(mainScreen); + } + + @Override + public synchronized GraphicsDevice[] getScreenDevices() { + return devices.values().toArray(new X11GraphicsDevice[0]); + } + + public synchronized GraphicsDevice getScreenDevice(int screen) { + return devices.get(screen); + } + + @Override + protected GraphicsDevice makeScreenDevice(int screennum) { + throw new UnsupportedOperationException("This method is unused and" + + "should not be called in this implementation"); } public boolean isDisplayLocal() { @@ -289,15 +367,7 @@ public String getDefaultFontFaceName() { private static native boolean pRunningXinerama(); public boolean runningXinerama() { - if (xinerState == null) { - // pRunningXinerama() simply returns a global boolean variable, - // so there is no need to synchronize here - xinerState = Boolean.valueOf(pRunningXinerama()); - if (screenLog.isLoggable(PlatformLogger.Level.FINER)) { - screenLog.finer("Running Xinerama: " + xinerState); - } - } - return xinerState.booleanValue(); + return pRunningXinerama(); } /** diff --git a/src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c b/src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c index 74f6d5f10127c..815289b7c8f75 100644 --- a/src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c +++ b/src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c @@ -58,7 +58,7 @@ int awt_numScreens; /* Xinerama-aware number of screens */ -AwtScreenDataPtr x11Screens; +AwtScreenDataPtr x11Screens; // should be guarded by AWT_LOCK()/AWT_UNLOCK() /* * Set in initDisplay() to indicate whether we should attempt to initialize @@ -591,8 +591,6 @@ static void xineramaInit(void) { int32_t major_opcode, first_event, first_error; Bool gotXinExt = False; void* libHandle = NULL; - int32_t locNumScr = 0; - XineramaScreenInfo *xinInfo; char* XineramaQueryScreensName = "XineramaQueryScreens"; gotXinExt = XQueryExtension(awt_display, XinExtName, &major_opcode, @@ -622,29 +620,92 @@ static void xineramaInit(void) { if (XineramaQueryScreens == NULL) { DTRACE_PRINTLN("couldn't load XineramaQueryScreens symbol"); dlclose(libHandle); - } else { - DTRACE_PRINTLN("calling XineramaQueryScreens func"); - xinInfo = (*XineramaQueryScreens)(awt_display, &locNumScr); - if (xinInfo != NULL) { - if (locNumScr > XScreenCount(awt_display)) { - DTRACE_PRINTLN("Enabling Xinerama support"); - usingXinerama = True; - /* set global number of screens */ - DTRACE_PRINTLN1(" num screens = %i\n", locNumScr); - awt_numScreens = locNumScr; - } else { - DTRACE_PRINTLN("XineramaQueryScreens <= XScreenCount"); - } - XFree(xinInfo); - } else { - DTRACE_PRINTLN("calling XineramaQueryScreens didn't work"); - } } } else { DTRACE_PRINTLN1("\ncouldn't open shared library: %s\n", dlerror()); } } +static void resetNativeData(int screen) { + /* + * Reset references to the various configs; the actual native config data + * will be free'd later by the Disposer mechanism when the Java-level + * X11GraphicsConfig objects go away. By setting these values to NULL, + * we ensure that they will be reinitialized as necessary (for example, + * see the getNumConfigs() method). + */ + if (x11Screens[screen].configs) { + free(x11Screens[screen].configs); + x11Screens[screen].configs = NULL; + } + x11Screens[screen].defaultConfig = NULL; + x11Screens[screen].numConfigs = 0; +} + +/* + * Class: sun_awt_X11GraphicsEnvironment + * Method: initDevices + * Signature: (Z)V + */ +JNIEXPORT void JNICALL +Java_sun_awt_X11GraphicsEnvironment_initNativeData(JNIEnv *env, jobject this) { + usingXinerama = False; + if (x11Screens) { + for (int i = 0; i < awt_numScreens; ++i) { + resetNativeData(i); + } + free((void *)x11Screens); + x11Screens = NULL; + awt_numScreens = 0; + } + + // will try xinerama first + if (XineramaQueryScreens) { + int32_t locNumScr = 0; + XineramaScreenInfo *xinInfo; + DTRACE_PRINTLN("calling XineramaQueryScreens func"); + xinInfo = (*XineramaQueryScreens)(awt_display, &locNumScr); + if (xinInfo != NULL) { + if (locNumScr > XScreenCount(awt_display)) { + DTRACE_PRINTLN("Enabling Xinerama support"); + usingXinerama = True; + /* set global number of screens */ + DTRACE_PRINTLN1(" num screens = %i\n", locNumScr); + awt_numScreens = locNumScr; + } else { + DTRACE_PRINTLN("XineramaQueryScreens <= XScreenCount"); + } + XFree(xinInfo); + } else { + DTRACE_PRINTLN("calling XineramaQueryScreens didn't work"); + } + } + // if xinerama is not enabled or does not work will use X11 + if (!usingXinerama) { + awt_numScreens = XScreenCount(awt_display); + } + DTRACE_PRINTLN1("allocating %i screens\n", awt_numScreens); + /* Allocate screen data structure array */ + x11Screens = calloc(awt_numScreens, sizeof(AwtScreenData)); + if (x11Screens == NULL) { + JNU_ThrowOutOfMemoryError((JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2), + NULL); + return; + } + + for (int i = 0; i < awt_numScreens; i++) { + if (usingXinerama) { + /* All Xinerama screens use the same X11 root for now */ + x11Screens[i].root = RootWindow(awt_display, 0); + } + else { + x11Screens[i].root = RootWindow(awt_display, i); + } + x11Screens[i].defaultConfig = makeDefaultConfig(env, i); + JNU_CHECK_EXCEPTION(env); + } +} + Display * awt_init_Display(JNIEnv *env, jobject this) { @@ -692,32 +753,6 @@ awt_init_Display(JNIEnv *env, jobject this) /* set awt_numScreens, and whether or not we're using Xinerama */ xineramaInit(); - - if (!usingXinerama) { - awt_numScreens = XScreenCount(awt_display); - } - - DTRACE_PRINTLN1("allocating %i screens\n", awt_numScreens); - /* Allocate screen data structure array */ - x11Screens = calloc(awt_numScreens, sizeof(AwtScreenData)); - if (x11Screens == NULL) { - JNU_ThrowOutOfMemoryError((JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2), - NULL); - return NULL; - } - - for (i = 0; i < awt_numScreens; i++) { - if (usingXinerama) { - /* All Xinerama screens use the same X11 root for now */ - x11Screens[i].root = RootWindow(awt_display, 0); - } - else { - x11Screens[i].root = RootWindow(awt_display, i); - } - x11Screens[i].defaultConfig = makeDefaultConfig(env, i); - JNU_CHECK_EXCEPTION_RETURN(env, NULL); - } - return dpy; } @@ -937,8 +972,11 @@ JNIEXPORT jint JNICALL Java_sun_awt_X11GraphicsDevice_getNumConfigs( JNIEnv *env, jobject this, jint screen) { + AWT_LOCK(); ensureConfigsInited(env, screen); - return x11Screens[screen].numConfigs; + int configs = x11Screens[screen].numConfigs; + AWT_UNLOCK(); + return configs; } /* @@ -951,13 +989,12 @@ Java_sun_awt_X11GraphicsDevice_getConfigVisualId( JNIEnv *env, jobject this, jint index, jint screen) { int visNum; - + AWT_LOCK(); ensureConfigsInited(env, screen); - if (index == 0) { - return ((jint)x11Screens[screen].defaultConfig->awt_visInfo.visualid); - } else { - return ((jint)x11Screens[screen].configs[index]->awt_visInfo.visualid); - } + jint id = (jint) (index == 0 ? x11Screens[screen].defaultConfig + : x11Screens[screen].configs[index])->awt_visInfo.visualid; + AWT_UNLOCK(); + return id; } /* @@ -970,13 +1007,12 @@ Java_sun_awt_X11GraphicsDevice_getConfigDepth( JNIEnv *env, jobject this, jint index, jint screen) { int visNum; - + AWT_LOCK(); ensureConfigsInited(env, screen); - if (index == 0) { - return ((jint)x11Screens[screen].defaultConfig->awt_visInfo.depth); - } else { - return ((jint)x11Screens[screen].configs[index]->awt_visInfo.depth); - } + jint depth = (jint) (index == 0 ? x11Screens[screen].defaultConfig + : x11Screens[screen].configs[index])->awt_visInfo.depth; + AWT_UNLOCK(); + return depth; } /* @@ -989,38 +1025,14 @@ Java_sun_awt_X11GraphicsDevice_getConfigColormap( JNIEnv *env, jobject this, jint index, jint screen) { int visNum; - + AWT_LOCK(); ensureConfigsInited(env, screen); - if (index == 0) { - return ((jint)x11Screens[screen].defaultConfig->awt_cmap); - } else { - return ((jint)x11Screens[screen].configs[index]->awt_cmap); - } + jint colormap = (jint) (index == 0 ? x11Screens[screen].defaultConfig + : x11Screens[screen].configs[index])->awt_cmap; + AWT_UNLOCK(); + return colormap; } -/* - * Class: sun_awt_X11GraphicsDevice - * Method: resetNativeData - * Signature: (I)V - */ -JNIEXPORT void JNICALL -Java_sun_awt_X11GraphicsDevice_resetNativeData - (JNIEnv *env, jclass x11gd, jint screen) -{ - /* - * Reset references to the various configs; the actual native config data - * will be free'd later by the Disposer mechanism when the Java-level - * X11GraphicsConfig objects go away. By setting these values to NULL, - * we ensure that they will be reinitialized as necessary (for example, - * see the getNumConfigs() method). - */ - if (x11Screens[screen].configs) { - free(x11Screens[screen].configs); - x11Screens[screen].configs = NULL; - } - x11Screens[screen].defaultConfig = NULL; - x11Screens[screen].numConfigs = 0; -} /* * Class: sun_awt_X11GraphicsConfig @@ -1128,6 +1140,7 @@ Java_sun_awt_X11GraphicsConfig_init( JNIEnv *env, jobject this, jint visualNum, jint screen) { AwtGraphicsConfigData *adata = NULL; + AWT_LOCK(); AwtScreenData asd = x11Screens[screen]; int i, n; int depth; @@ -1149,6 +1162,7 @@ JNIEnv *env, jobject this, jint visualNum, jint screen) /* If didn't find the visual, throw an exception... */ if (adata == (AwtGraphicsConfigData *) NULL) { + AWT_UNLOCK(); JNU_ThrowIllegalArgumentException(env, "Unknown Visual Specified"); return; } @@ -1167,6 +1181,7 @@ JNIEnv *env, jobject this, jint visualNum, jint screen) (*env)->SetIntField(env, this, x11GraphicsConfigIDs.bitsPerPixel, (jint)tempImage->bits_per_pixel); XDestroyImage(tempImage); + AWT_UNLOCK(); } /* @@ -1210,23 +1225,19 @@ JNIEnv *env, jobject this) /* - * Class: sun_awt_X11GraphicsConfig + * Class: sun_awt_X11GraphicsDevice * Method: getBounds * Signature: ()Ljava/awt/Rectangle */ JNIEXPORT jobject JNICALL -Java_sun_awt_X11GraphicsConfig_pGetBounds(JNIEnv *env, jobject this, jint screen) +Java_sun_awt_X11GraphicsDevice_pGetBounds(JNIEnv *env, jobject this, jint screen) { jclass clazz; jmethodID mid; jobject bounds = NULL; - AwtGraphicsConfigDataPtr adata; int32_t locNumScr = 0; XineramaScreenInfo *xinInfo; - adata = (AwtGraphicsConfigDataPtr) - JNU_GetLongFieldAsPtr(env, this, x11GraphicsConfigIDs.aData); - clazz = (*env)->FindClass(env, "java/awt/Rectangle"); CHECK_NULL_RETURN(clazz, NULL); mid = (*env)->GetMethodID(env, clazz, "", "(IIII)V"); @@ -1261,8 +1272,7 @@ Java_sun_awt_X11GraphicsConfig_pGetBounds(JNIEnv *env, jobject this, jint screen memset(&xwa, 0, sizeof(xwa)); AWT_LOCK (); - XGetWindowAttributes(awt_display, - RootWindow(awt_display, adata->awt_visInfo.screen), + XGetWindowAttributes(awt_display, RootWindow(awt_display, screen), &xwa); AWT_UNLOCK (); diff --git a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c index 0196b39f9eca5..3fbe016d71bd4 100644 --- a/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c +++ b/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c @@ -120,9 +120,10 @@ JNIEXPORT jlong JNICALL Java_sun_awt_X11_XToolkit_getTrayIconDisplayTimeout JNIEXPORT jlong JNICALL Java_sun_awt_X11_XToolkit_getDefaultXColormap (JNIEnv *env, jclass clazz) { + AWT_LOCK(); AwtGraphicsConfigDataPtr defaultConfig = getDefaultConfig(DefaultScreen(awt_display)); - + AWT_UNLOCK(); return (jlong) defaultConfig->awt_cmap; } @@ -145,9 +146,11 @@ DEF_JNI_OnLoad(JavaVM *vm, void *reserved) JNIEXPORT void JNICALL Java_sun_awt_X11_XToolkit_nativeLoadSystemColors (JNIEnv *env, jobject this, jintArray systemColors) { + AWT_LOCK(); AwtGraphicsConfigDataPtr defaultConfig = getDefaultConfig(DefaultScreen(awt_display)); awtJNI_CreateColorData(env, defaultConfig, 1); + AWT_UNLOCK(); } JNIEXPORT void JNICALL From b9d4211bc1aa92e257ddfe86c7a2b4e4e60598a0 Mon Sep 17 00:00:00 2001 From: Ioi Lam Date: Wed, 3 Feb 2021 03:56:35 +0000 Subject: [PATCH 36/77] 8260193: Remove JVM_GetInterfaceVersion() and JVM_DTraceXXX Reviewed-by: alanb, lfoltan, gziemski, ihse --- make/data/hotspot-symbols/symbols-unix | 3 +- src/hotspot/share/include/jvm.h | 88 ------------------- src/hotspot/share/prims/jvm.cpp | 10 --- .../share/native/libjava/check_version.c | 13 +-- 4 files changed, 2 insertions(+), 112 deletions(-) diff --git a/make/data/hotspot-symbols/symbols-unix b/make/data/hotspot-symbols/symbols-unix index 055e4062c7060..c82551815aeff 100644 --- a/make/data/hotspot-symbols/symbols-unix +++ b/make/data/hotspot-symbols/symbols-unix @@ -1,5 +1,5 @@ # -# Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -100,7 +100,6 @@ JVM_GetExtendedNPEMessage JVM_GetFieldIxModifiers JVM_GetFieldTypeAnnotations JVM_GetInheritedAccessControlContext -JVM_GetInterfaceVersion JVM_GetManagement JVM_GetMethodIxArgsSize JVM_GetMethodIxByteCode diff --git a/src/hotspot/share/include/jvm.h b/src/hotspot/share/include/jvm.h index db17484e4cadf..aaf14f38b99a0 100644 --- a/src/hotspot/share/include/jvm.h +++ b/src/hotspot/share/include/jvm.h @@ -56,20 +56,6 @@ extern "C" { * namely the jio_xxxprintf functions, are included from jvm_io.h. */ -/* - * Bump the version number when either of the following happens: - * - * 1. There is a change in JVM_* functions. - * - * 2. There is a change in the contract between VM and Java classes. - * For example, if the VM relies on a new private field in Thread - * class. - */ - -#define JVM_INTERFACE_VERSION 6 - -JNIEXPORT jint JNICALL -JVM_GetInterfaceVersion(void); /************************************************************************* PART 1: Functions for Native Libraries @@ -761,80 +747,6 @@ JVM_AssertionStatusDirectives(JNIEnv *env, jclass unused); JNIEXPORT jboolean JNICALL JVM_SupportsCX8(void); -/* - * com.sun.dtrace.jsdt support - */ - -#define JVM_TRACING_DTRACE_VERSION 1 - -/* - * Structure to pass one probe description to JVM - */ -typedef struct { - jmethodID method; - jstring function; - jstring name; - void* reserved[4]; // for future use -} JVM_DTraceProbe; - -/** - * Encapsulates the stability ratings for a DTrace provider field - */ -typedef struct { - jint nameStability; - jint dataStability; - jint dependencyClass; -} JVM_DTraceInterfaceAttributes; - -/* - * Structure to pass one provider description to JVM - */ -typedef struct { - jstring name; - JVM_DTraceProbe* probes; - jint probe_count; - JVM_DTraceInterfaceAttributes providerAttributes; - JVM_DTraceInterfaceAttributes moduleAttributes; - JVM_DTraceInterfaceAttributes functionAttributes; - JVM_DTraceInterfaceAttributes nameAttributes; - JVM_DTraceInterfaceAttributes argsAttributes; - void* reserved[4]; // for future use -} JVM_DTraceProvider; - -/* - * Get the version number the JVM was built with - */ -JNIEXPORT jint JNICALL -JVM_DTraceGetVersion(JNIEnv* env); - -/* - * Register new probe with given signature, return global handle - * - * The version passed in is the version that the library code was - * built with. - */ -JNIEXPORT jlong JNICALL -JVM_DTraceActivate(JNIEnv* env, jint version, jstring module_name, - jint providers_count, JVM_DTraceProvider* providers); - -/* - * Check JSDT probe - */ -JNIEXPORT jboolean JNICALL -JVM_DTraceIsProbeEnabled(JNIEnv* env, jmethodID method); - -/* - * Destroy custom DOF - */ -JNIEXPORT void JNICALL -JVM_DTraceDispose(JNIEnv* env, jlong activation_handle); - -/* - * Check to see if DTrace is supported by OS - */ -JNIEXPORT jboolean JNICALL -JVM_DTraceIsSupported(JNIEnv* env); - /************************************************************************* PART 2: Support for the Verifier and Class File Format Checker ************************************************************************/ diff --git a/src/hotspot/share/prims/jvm.cpp b/src/hotspot/share/prims/jvm.cpp index 8e7743bca96ea..53ffb2cef3ed2 100644 --- a/src/hotspot/share/prims/jvm.cpp +++ b/src/hotspot/share/prims/jvm.cpp @@ -94,7 +94,6 @@ #include "services/threadService.hpp" #include "utilities/copy.hpp" #include "utilities/defaultStream.hpp" -#include "utilities/dtrace.hpp" #include "utilities/events.hpp" #include "utilities/macros.hpp" #include "utilities/utf8.hpp" @@ -228,15 +227,6 @@ void trace_class_resolution(Klass* to_class) { } } - -// Interface version ///////////////////////////////////////////////////////////////////// - - -JVM_LEAF(jint, JVM_GetInterfaceVersion()) - return JVM_INTERFACE_VERSION; -JVM_END - - // java.lang.System ////////////////////////////////////////////////////////////////////// diff --git a/src/java.base/share/native/libjava/check_version.c b/src/java.base/share/native/libjava/check_version.c index 6d757a0b5f279..17a590fea1456 100644 --- a/src/java.base/share/native/libjava/check_version.c +++ b/src/java.base/share/native/libjava/check_version.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,16 +30,5 @@ JNIEXPORT jint JNICALL DEF_JNI_OnLoad(JavaVM *vm, void *reserved) { - jint vm_version = JVM_GetInterfaceVersion(); - if (vm_version != JVM_INTERFACE_VERSION) { - JNIEnv *env; - char buf[128]; - sprintf(buf, "JVM interface version mismatch: expecting %d, got %d.", - JVM_INTERFACE_VERSION, (int)vm_version); - (*vm)->GetEnv(vm, (void **)&env, JNI_VERSION_1_2); - if (env) { - (*env)->FatalError(env, buf); - } - } return JNI_VERSION_1_2; } From c0084100bc335676a277881f99e138a4abfc5362 Mon Sep 17 00:00:00 2001 From: Prasanta Sadhukhan Date: Wed, 3 Feb 2021 04:33:42 +0000 Subject: [PATCH 37/77] 8197825: [Test] Intermittent timeout with javax/swing JColorChooser Test Reviewed-by: trebari, aivanov --- test/jdk/ProblemList.txt | 1 - .../swing/JColorChooser/Test6827032.java | 66 +++++++++++-------- 2 files changed, 38 insertions(+), 29 deletions(-) diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index 29cecce6c9879..875739d378a86 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -734,7 +734,6 @@ javax/swing/JWindow/ShapedAndTranslucentWindows/SetShapeAndClickSwing.java 80134 javax/swing/JWindow/ShapedAndTranslucentWindows/TranslucentJComboBox.java 8024627 macosx-all # The next test below is an intermittent failure javax/swing/JComboBox/8033069/bug8033069ScrollBar.java 8163367 generic-all -javax/swing/JColorChooser/Test6827032.java 8197825 windows-all javax/swing/JTree/DnD/LastNodeLowerHalfDrop.java 8159131 linux-all javax/swing/JTree/4633594/JTreeFocusTest.java 8173125 macosx-all javax/swing/AbstractButton/6711682/bug6711682.java 8060765 windows-all,macosx-all diff --git a/test/jdk/javax/swing/JColorChooser/Test6827032.java b/test/jdk/javax/swing/JColorChooser/Test6827032.java index fff9834d6871c..096d6b1eeba17 100644 --- a/test/jdk/javax/swing/JColorChooser/Test6827032.java +++ b/test/jdk/javax/swing/JColorChooser/Test6827032.java @@ -24,7 +24,7 @@ /* * @test * @key headful - * @bug 6827032 + * @bug 6827032 8197825 * @summary Color chooser with drag enabled shouldn't throw NPE * @author Peter Zhelezniakov * @library ../regtesthelpers @@ -38,47 +38,57 @@ public class Test6827032 { - private static volatile Point point; + private static JFrame frame; private static JColorChooser cc; public static void main(String[] args) throws Exception { - UIManager.setLookAndFeel(new NimbusLookAndFeel()); - - Robot robot = new Robot(); - robot.setAutoDelay(50); - - - SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - createAndShowGUI(); + try { + UIManager.setLookAndFeel(new NimbusLookAndFeel()); + + Robot robot = new Robot(); + robot.setAutoDelay(100); + + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + createAndShowGUI(); + } + }); + + robot.waitForIdle(); + robot.delay(1000); + + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + Component previewPanel = Util.findSubComponent(cc, "javax.swing.colorchooser.DefaultPreviewPanel"); + point = previewPanel.getLocationOnScreen(); + } + }); + + point.translate(5, 5); + + robot.mouseMove(point.x, point.y); + robot.waitForIdle(); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.waitForIdle(); + robot.delay(1000); + } finally { + if (frame != null) { + SwingUtilities.invokeAndWait(() -> frame.dispose()); } - }); - - robot.waitForIdle(); - - SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - Component previewPanel = Util.findSubComponent(cc, "javax.swing.colorchooser.DefaultPreviewPanel"); - point = previewPanel.getLocationOnScreen(); - } - }); - - point.translate(5, 5); - - robot.mouseMove(point.x, point.y); - robot.mousePress(InputEvent.BUTTON1_MASK); - robot.mouseRelease(InputEvent.BUTTON1_MASK); + } } private static void createAndShowGUI() { - JFrame frame = new JFrame(Test6827032.class.getName()); + frame = new JFrame(Test6827032.class.getName()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); cc = new JColorChooser(); cc.setDragEnabled(true); frame.add(cc); frame.pack(); + frame.setLocationRelativeTo(null); frame.setVisible(true); } } From cb127a4bb5d95d19eb1f5e625b600311a2490135 Mon Sep 17 00:00:00 2001 From: Prasanta Sadhukhan Date: Wed, 3 Feb 2021 06:49:32 +0000 Subject: [PATCH 38/77] 8198343: Test java/awt/print/PrinterJob/TestPgfmtSetMPA.java may fail w/o printer Reviewed-by: jdv, trebari --- test/jdk/ProblemList.txt | 1 - test/jdk/java/awt/print/PrinterJob/TestPgfmtSetMPA.java | 5 +++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index 875739d378a86..95a89dbe4971a 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -254,7 +254,6 @@ java/awt/image/DrawImage/IncorrectAlphaSurface2SW.java 8056077 linux-all java/awt/image/DrawImage/BlitRotateClippedArea.java 8255724 linux-all java/awt/image/multiresolution/MultiresolutionIconTest.java 8169187 macosx-all,windows-all java/awt/print/Headless/HeadlessPrinterJob.java 8196088 windows-all -java/awt/print/PrinterJob/TestPgfmtSetMPA.java 8198343 generic-all sun/awt/datatransfer/SuplementaryCharactersTransferTest.java 8011371 generic-all sun/awt/shell/ShellFolderMemoryLeak.java 8197794 windows-all sun/java2d/DirectX/OnScreenRenderingResizeTest/OnScreenRenderingResizeTest.java 8022403 generic-all diff --git a/test/jdk/java/awt/print/PrinterJob/TestPgfmtSetMPA.java b/test/jdk/java/awt/print/PrinterJob/TestPgfmtSetMPA.java index 8e09acf78868c..0e143973f9e6d 100644 --- a/test/jdk/java/awt/print/PrinterJob/TestPgfmtSetMPA.java +++ b/test/jdk/java/awt/print/PrinterJob/TestPgfmtSetMPA.java @@ -23,6 +23,7 @@ /* * @test * @bug 6789262 + * @key printer * @summary Verifies if getPageFormat returns correct mediaprintable value * @run main TestPgfmtSetMPA */ @@ -38,6 +39,10 @@ public static void main(String args[]) { PrinterJob job; job = PrinterJob.getPrinterJob(); + if (job.getPrintService() == null) { + System.out.println("No printers. Test cannot continue"); + return; + } PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet(); From 91e6c755f32dada6c62bad4ff4221aed75a0ccc2 Mon Sep 17 00:00:00 2001 From: Tobias Hartmann Date: Wed, 3 Feb 2021 08:10:21 +0000 Subject: [PATCH 39/77] 8260928: InitArrayShortSize constraint func should print a helpful error message Reviewed-by: shade, chagedorn --- src/hotspot/share/runtime/flags/jvmFlagConstraintsCompiler.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/hotspot/share/runtime/flags/jvmFlagConstraintsCompiler.cpp b/src/hotspot/share/runtime/flags/jvmFlagConstraintsCompiler.cpp index 96c8f6008040b..5b24e062b188f 100644 --- a/src/hotspot/share/runtime/flags/jvmFlagConstraintsCompiler.cpp +++ b/src/hotspot/share/runtime/flags/jvmFlagConstraintsCompiler.cpp @@ -302,6 +302,9 @@ JVMFlag::Error TypeProfileLevelConstraintFunc(uintx value, bool verbose) { JVMFlag::Error InitArrayShortSizeConstraintFunc(intx value, bool verbose) { if (value % BytesPerLong != 0) { + JVMFlag::printError(verbose, + "InitArrayShortSize (" INTX_FORMAT ") must be " + "a multiple of %d\n", value, BytesPerLong); return JVMFlag::VIOLATES_CONSTRAINT; } else { return JVMFlag::SUCCESS; From 90376156be1a2d93dac612ef77d1c0f267e72c60 Mon Sep 17 00:00:00 2001 From: Jan Lahoda Date: Wed, 3 Feb 2021 09:21:43 +0000 Subject: [PATCH 40/77] 8222850: jshell tool: Misleading cascade compiler error in switch expression with undefined vars Reviewed-by: vromero --- .../com/sun/tools/javac/comp/Attr.java | 14 +++++++++- .../com/sun/tools/javac/comp/Flow.java | 5 ++-- .../com/sun/tools/javac/comp/Resolve.java | 9 +++++++ .../com/sun/tools/javac/tree/TreeInfo.java | 7 ++++- .../recovery/SwitchUndefinedSelector.java | 26 +++++++++++++++++++ .../recovery/SwitchUndefinedSelector.out | 6 +++++ 6 files changed, 63 insertions(+), 4 deletions(-) create mode 100644 test/langtools/tools/javac/recovery/SwitchUndefinedSelector.java create mode 100644 test/langtools/tools/javac/recovery/SwitchUndefinedSelector.out diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java index e2f85a45d46c5..3df027e861fca 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java @@ -1650,6 +1650,7 @@ private void handleSwitch(JCTree switchTree, try { boolean enumSwitch = (seltype.tsym.flags() & Flags.ENUM) != 0; boolean stringSwitch = types.isSameType(seltype, syms.stringType); + boolean errorEnumSwitch = TreeInfo.isErrorEnumSwitch(selector, cases); if (!enumSwitch && !stringSwitch) seltype = chk.checkType(selector.pos(), seltype, syms.intType); @@ -1680,6 +1681,17 @@ private void handleSwitch(JCTree switchTree, } else if (!labels.add(sym)) { log.error(c.pos(), Errors.DuplicateCaseLabel); } + } else if (errorEnumSwitch) { + //error recovery: the selector is erroneous, and all the case labels + //are identifiers. This could be an enum switch - don't report resolve + //error for the case label: + var prevResolveHelper = rs.basicLogResolveHelper; + try { + rs.basicLogResolveHelper = rs.silentLogResolveHelper; + attribExpr(pat, switchEnv, seltype); + } finally { + rs.basicLogResolveHelper = prevResolveHelper; + } } else { Type pattype = attribExpr(pat, switchEnv, seltype); if (!pattype.hasTag(ERROR)) { @@ -3796,7 +3808,7 @@ public void visitParens(JCParens tree) { Type owntype = attribTree(tree.expr, env, resultInfo); result = check(tree, owntype, pkind(), resultInfo); Symbol sym = TreeInfo.symbol(tree); - if (sym != null && sym.kind.matches(KindSelector.TYP_PCK)) + if (sym != null && sym.kind.matches(KindSelector.TYP_PCK) && sym.kind != Kind.ERR) log.error(tree.pos(), Errors.IllegalParenthesizedExpression); } diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java index a425170c0f3b8..7fd20b393a69f 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -736,7 +736,8 @@ public void visitSwitchExpression(JCSwitchExpression tree) { } c.completesNormally = alive != Liveness.DEAD; } - if ((constants == null || !constants.isEmpty()) && !hasDefault) { + if ((constants == null || !constants.isEmpty()) && !hasDefault && + !TreeInfo.isErrorEnumSwitch(tree.selector, tree.cases)) { log.error(tree, Errors.NotExhaustive); } alive = prevAlive; diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java index 377b4eb0bd6f7..3054d97d97f95 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java @@ -2629,6 +2629,15 @@ public List getArgumentTypes(ResolveError errSym, Symbol accessedSym, Name } }; + LogResolveHelper silentLogResolveHelper = new LogResolveHelper() { + public boolean resolveDiagnosticNeeded(Type site, List argtypes, List typeargtypes) { + return false; + } + public List getArgumentTypes(ResolveError errSym, Symbol accessedSym, Name name, List argtypes) { + return argtypes; + } + }; + LogResolveHelper methodLogResolveHelper = new LogResolveHelper() { public boolean resolveDiagnosticNeeded(Type site, List argtypes, List typeargtypes) { return !site.isErroneous() && diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeInfo.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeInfo.java index a392d7be22f08..3ddba888b93b1 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeInfo.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1324,4 +1324,9 @@ public static boolean isPackageInfo(JCCompilationUnit tree) { return tree.sourcefile.isNameCompatible("package-info", JavaFileObject.Kind.SOURCE); } + public static boolean isErrorEnumSwitch(JCExpression selector, List cases) { + return selector.type.tsym.kind == Kinds.Kind.ERR && + cases.stream().flatMap(c -> c.pats.stream()) + .allMatch(p -> p.hasTag(IDENT)); + } } diff --git a/test/langtools/tools/javac/recovery/SwitchUndefinedSelector.java b/test/langtools/tools/javac/recovery/SwitchUndefinedSelector.java new file mode 100644 index 0000000000000..b875eee61b1c6 --- /dev/null +++ b/test/langtools/tools/javac/recovery/SwitchUndefinedSelector.java @@ -0,0 +1,26 @@ +/** + * @test /nodynamiccopyright/ + * @bug 8222850 + * @summary Check error recovery for switch over undefined variables. + * @compile/fail/ref=SwitchUndefinedSelector.out -XDrawDiagnostics --should-stop=at=FLOW SwitchUndefinedSelector.java + */ + +public class SwitchUndefinedSelector { + private static final Object D = null; + public void switchTest() { + switch (undefined) { + case A -> {} + case B, C -> {} + case D -> {} + } + var v = switch (undefined) { + case A -> 0; + case B, C -> 0; + case D -> 0; + }; + switch (undefined) { + case SwitchUndefinedSelector.D -> {} + case SwitchUndefinedSelector.UNDEF -> {} + } + } +} diff --git a/test/langtools/tools/javac/recovery/SwitchUndefinedSelector.out b/test/langtools/tools/javac/recovery/SwitchUndefinedSelector.out new file mode 100644 index 0000000000000..f59d2771c5ee2 --- /dev/null +++ b/test/langtools/tools/javac/recovery/SwitchUndefinedSelector.out @@ -0,0 +1,6 @@ +SwitchUndefinedSelector.java:11:17: compiler.err.cant.resolve.location: kindname.variable, undefined, , , (compiler.misc.location: kindname.class, SwitchUndefinedSelector, null) +SwitchUndefinedSelector.java:16:25: compiler.err.cant.resolve.location: kindname.variable, undefined, , , (compiler.misc.location: kindname.class, SwitchUndefinedSelector, null) +SwitchUndefinedSelector.java:21:17: compiler.err.cant.resolve.location: kindname.variable, undefined, , , (compiler.misc.location: kindname.class, SwitchUndefinedSelector, null) +SwitchUndefinedSelector.java:22:41: compiler.err.string.const.req +SwitchUndefinedSelector.java:23:41: compiler.err.cant.resolve.location: kindname.variable, UNDEF, , , (compiler.misc.location: kindname.class, SwitchUndefinedSelector, null) +5 errors From ae2c5f07ced22ef871085d565b714342ae5a9d56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roberto=20Casta=C3=B1eda=20Lozano?= Date: Wed, 3 Feb 2021 11:11:57 +0000 Subject: [PATCH 41/77] 8260581: IGV: enhance node search Allow users to search by node id or name by default, show partial matches when searching for a specific property, show 'All N matching nodes' entry only if relevant, and rank results by level of matching. Co-authored-by: Christian Hagedorn Reviewed-by: chagedorn, vlivanov, xliu --- .../src/com/sun/hotspot/igv/graph/Figure.java | 9 +- .../View/nbproject/project.properties | 2 +- .../sun/hotspot/igv/view/NodeQuickSearch.java | 108 ++++++++++++++---- 3 files changed, 95 insertions(+), 24 deletions(-) diff --git a/src/utils/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Figure.java b/src/utils/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Figure.java index 1f1f735318c8c..49c5d57348a4e 100644 --- a/src/utils/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Figure.java +++ b/src/utils/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Figure.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -274,6 +274,13 @@ void removeOutputSlot(OutputSlot s) { public String[] getLines() { if (lines == null) { updateLines(); + // Set the "label" property of each input node, so that by default + // search is done on the node label (without line breaks). See also + // class NodeQuickSearch in the View module. + for (InputNode n : getSource().getSourceNodes()) { + String label = resolveString(diagram.getNodeText(), n.getProperties()); + n.getProperties().setProperty("label", label); + } } return lines; } diff --git a/src/utils/IdealGraphVisualizer/View/nbproject/project.properties b/src/utils/IdealGraphVisualizer/View/nbproject/project.properties index b0194c4977654..b45e3b401e890 100644 --- a/src/utils/IdealGraphVisualizer/View/nbproject/project.properties +++ b/src/utils/IdealGraphVisualizer/View/nbproject/project.properties @@ -1,2 +1,2 @@ -javac.source=1.7 +javac.source=1.8 javac.compilerargs=-Xlint -Xlint:-serial diff --git a/src/utils/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/NodeQuickSearch.java b/src/utils/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/NodeQuickSearch.java index 23b23ed15d05c..9312a16a1ce0e 100644 --- a/src/utils/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/NodeQuickSearch.java +++ b/src/utils/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/NodeQuickSearch.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,6 +29,7 @@ import com.sun.hotspot.igv.data.Properties.RegexpPropertyMatcher; import com.sun.hotspot.igv.data.services.InputGraphProvider; import com.sun.hotspot.igv.util.LookupHistory; +import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -46,7 +47,7 @@ */ public class NodeQuickSearch implements SearchProvider { - private static final String DEFAULT_PROPERTY = "name"; + private static final String DEFAULT_PROPERTY = "label"; /** * Method is called by infrastructure when search operation was requested. @@ -66,18 +67,17 @@ public void evaluate(SearchRequest request, SearchResponse response) { final String[] parts = query.split("=", 2); String name; + String rawValue; String value; if (parts.length == 1) { name = DEFAULT_PROPERTY; - value = ".*" + Pattern.quote(parts[0]) + ".*"; + rawValue = parts[0]; + value = ".*" + Pattern.quote(rawValue) + ".*"; } else { name = parts[0]; - value = parts[1]; - } - - if (value.isEmpty()) { - value = ".*"; + rawValue = parts[1]; + value = (rawValue.isEmpty() ? "" : Pattern.quote(rawValue)) + ".*"; } final InputGraphProvider p = LookupHistory.getLast(InputGraphProvider.class); @@ -109,25 +109,40 @@ public void evaluate(SearchRequest request, SearchResponse response) { if (matches != null) { final Set set = new HashSet<>(matches); final InputGraph theGraph = p.getGraph() != matchGraph ? matchGraph : null; - response.addResult(new Runnable() { - @Override - public void run() { - final EditorTopComponent comp = EditorTopComponent.getActive(); - if (comp != null) { - if (theGraph != null) { - comp.getDiagramModel().selectGraph(theGraph); + // Show "All N matching nodes" entry only if 1) there are + // multiple matches and 2) the query does not only contain + // digits (it is rare to select all nodes whose id contains a + // certain subsequence of digits). + if (matches.size() > 1 && !rawValue.matches("\\d+")) { + if (!response.addResult(new Runnable() { + @Override + public void run() { + final EditorTopComponent comp = EditorTopComponent.getActive(); + if (comp != null) { + if (theGraph != null) { + comp.getDiagramModel().selectGraph(theGraph); + } + comp.setSelectedNodes(set); + comp.requestActive(); } - comp.setSelectedNodes(set); - comp.requestActive(); } + }, + "All " + matches.size() + " matching nodes (" + name + "=" + value + ")" + (theGraph != null ? " in " + theGraph.getName() : "") + )) { + return; } - }, - "All " + matches.size() + " matching nodes (" + name + "=" + value + ")" + (theGraph != null ? " in " + theGraph.getName() : "") - ); + } + + // Rank the matches. + Collections.sort(matches, + (InputNode a, InputNode b) -> + compareByRankThenNumVal(rawValue, + a.getProperties().get(name), + b.getProperties().get(name))); // Single matches for (final InputNode n : matches) { - response.addResult(new Runnable() { + if (!response.addResult(new Runnable() { @Override public void run() { final EditorTopComponent comp = EditorTopComponent.getActive(); @@ -143,7 +158,9 @@ public void run() { } }, n.getProperties().get(name) + " (" + n.getId() + " " + n.getProperties().get("name") + ")" + (theGraph != null ? " in " + theGraph.getName() : "") - ); + )) { + return; + } } } } else { @@ -173,4 +190,51 @@ public void run() { } return null; } + + /** + * Compare two matches for a given query, first by rank (see rankMatch() + * below) and then by numeric value, if applicable. + */ + private int compareByRankThenNumVal(String qry, String prop1, String prop2) { + int key1 = rankMatch(qry, prop1); + int key2 = rankMatch(qry, prop2); + if (key1 == key2) { + // If the matches have the same rank, compare the numeric values of + // their first words, if applicable. + try { + key1 = Integer.parseInt(prop1.split("\\W+")[0]); + key2 = Integer.parseInt(prop2.split("\\W+")[0]); + } catch (Exception e) { + // Not applicable, return equality value. + return 0; + } + } + return Integer.compare(key1, key2); + } + + /** + * Rank a match by splitting the property into words. Full matches of a word + * rank highest, followed by partial matches at the word start, followed by + * the rest of matches in increasing size of the partially matched word, for + * example: + * + * rank("5", "5 AddI") = 1 (full match of first word) + * rank("5", "554 MulI") = 2 (start match of first word) + * rank("5", "25 AddL") = 3 (middle match of first word with excess 1) + * rank("5", "253 AddL") = 4 (middle match of first word with excess 2) + */ + private int rankMatch(String qry, String prop) { + String query = qry.toLowerCase(); + String property = prop.toLowerCase(); + for (String component : property.split("\\W+")) { + if (component.equals(query)) { + return 1; + } else if (component.startsWith(query)) { + return 2; + } else if (component.contains(query)) { + return component.length() - query.length() + 2; + } + } + return Integer.MAX_VALUE; + } } From c8de943c1fc3491f6be92ad6b6d959050bbddd44 Mon Sep 17 00:00:00 2001 From: Claes Redestad Date: Wed, 3 Feb 2021 11:43:17 +0000 Subject: [PATCH 42/77] 8260617: Merge ZipFile encoding check with the initial hash calculation Reviewed-by: lancea --- .../share/classes/java/util/zip/ZipCoder.java | 99 ++++--------- .../share/classes/java/util/zip/ZipFile.java | 135 ++++++++++-------- 2 files changed, 109 insertions(+), 125 deletions(-) diff --git a/src/java.base/share/classes/java/util/zip/ZipCoder.java b/src/java.base/share/classes/java/util/zip/ZipCoder.java index 818cd8d206dcb..621b0b0bc8b81 100644 --- a/src/java.base/share/classes/java/util/zip/ZipCoder.java +++ b/src/java.base/share/classes/java/util/zip/ZipCoder.java @@ -54,14 +54,6 @@ public static ZipCoder get(Charset charset) { return new ZipCoder(charset); } - void checkEncoding(byte[] a, int pos, int nlen) throws ZipException { - try { - toString(a, pos, nlen); - } catch(Exception e) { - throw new ZipException("invalid CEN header (bad entry name)"); - } - } - String toString(byte[] ba, int off, int length) { try { return decoder().decode(ByteBuffer.wrap(ba, off, length)).toString(); @@ -98,10 +90,6 @@ static String toStringUTF8(byte[] ba, int len) { return UTF8.toString(ba, 0, len); } - static String toStringUTF8(byte[] ba, int off, int len) { - return UTF8.toString(ba, off, len); - } - boolean isUTF8() { return false; } @@ -110,15 +98,33 @@ boolean isUTF8() { // we first decoded the byte sequence to a String, then appended '/' if no // trailing slash was found, then called String.hashCode(). This // normalization ensures we can simplify and speed up lookups. - int normalizedHash(byte[] a, int off, int len) { + // + // Does encoding error checking and hashing in a single pass for efficiency. + // On an error, this function will throw CharacterCodingException while the + // UTF8ZipCoder override will throw IllegalArgumentException, so we declare + // throws Exception to keep things simple. + int checkedHash(byte[] a, int off, int len) throws Exception { if (len == 0) { return 0; } - return normalizedHashDecode(0, a, off, off + len); + + int h = 0; + // cb will be a newly allocated CharBuffer with pos == 0, + // arrayOffset == 0, backed by an array. + CharBuffer cb = decoder().decode(ByteBuffer.wrap(a, off, len)); + int limit = cb.limit(); + char[] decoded = cb.array(); + for (int i = 0; i < limit; i++) { + h = 31 * h + decoded[i]; + } + if (limit > 0 && decoded[limit - 1] != '/') { + h = 31 * h + '/'; + } + return h; } - // Matching normalized hash code function for Strings - static int normalizedHash(String name) { + // Hash function equivalent of checkedHash for String inputs + static int hash(String name) { int hsh = name.hashCode(); int len = name.length(); if (len > 0 && name.charAt(len - 1) != '/') { @@ -133,29 +139,6 @@ boolean hasTrailingSlash(byte[] a, int end) { Arrays.mismatch(a, end - slashBytes.length, end, slashBytes, 0, slashBytes.length) == -1; } - // Implements normalizedHash by decoding byte[] to char[] and then computing - // the hash. This is a slow-path used for non-UTF8 charsets and also when - // aborting the ASCII fast-path in the UTF8 implementation, so {@code h} - // might be a partially calculated hash code - int normalizedHashDecode(int h, byte[] a, int off, int end) { - try { - // cb will be a newly allocated CharBuffer with pos == 0, - // arrayOffset == 0, backed by an array. - CharBuffer cb = decoder().decode(ByteBuffer.wrap(a, off, end - off)); - int limit = cb.limit(); - char[] decoded = cb.array(); - for (int i = 0; i < limit; i++) { - h = 31 * h + decoded[i]; - } - if (limit > 0 && decoded[limit - 1] != '/') { - h = 31 * h + '/'; - } - } catch (CharacterCodingException cce) { - // Ignore - return the hash code generated so far. - } - return h; - } - private byte[] slashBytes; private final Charset cs; protected CharsetDecoder dec; @@ -211,25 +194,6 @@ boolean isUTF8() { return true; } - @Override - void checkEncoding(byte[] a, int pos, int len) throws ZipException { - try { - int end = pos + len; - while (pos < end) { - // ASCII fast-path: When checking that a range of bytes is - // valid UTF-8, we can avoid some allocation by skipping - // past bytes in the 0-127 range - if (a[pos] < 0) { - ZipCoder.toStringUTF8(a, pos, end - pos); - break; - } - pos++; - } - } catch(Exception e) { - throw new ZipException("invalid CEN header (bad entry name)"); - } - } - @Override String toString(byte[] ba, int off, int length) { return JLA.newStringUTF8NoRepl(ba, off, length); @@ -241,7 +205,7 @@ byte[] getBytes(String s) { } @Override - int normalizedHash(byte[] a, int off, int len) { + int checkedHash(byte[] a, int off, int len) throws Exception { if (len == 0) { return 0; } @@ -250,18 +214,17 @@ int normalizedHash(byte[] a, int off, int len) { int h = 0; while (off < end) { byte b = a[off]; - if (b < 0) { + if (b >= 0) { + // ASCII, keep going + h = 31 * h + b; + off++; + } else { // Non-ASCII, fall back to decoding a String // We avoid using decoder() here since the UTF8ZipCoder is // shared and that decoder is not thread safe. - // We also avoid the JLA.newStringUTF8NoRepl variant at - // this point to avoid throwing exceptions eagerly when - // opening ZipFiles (exceptions are expected when accessing - // malformed entries.) - return normalizedHash(new String(a, end - len, len, UTF_8.INSTANCE)); - } else { - h = 31 * h + b; - off++; + // We use the JLA.newStringUTF8NoRepl variant to throw + // exceptions eagerly when opening ZipFiles + return hash(JLA.newStringUTF8NoRepl(a, end - len, len)); } } diff --git a/src/java.base/share/classes/java/util/zip/ZipFile.java b/src/java.base/share/classes/java/util/zip/ZipFile.java index 07edc06999bba..2e7eea4b7e340 100644 --- a/src/java.base/share/classes/java/util/zip/ZipFile.java +++ b/src/java.base/share/classes/java/util/zip/ZipFile.java @@ -33,6 +33,7 @@ import java.io.RandomAccessFile; import java.io.UncheckedIOException; import java.lang.ref.Cleaner.Cleanable; +import java.nio.charset.CharacterCodingException; import java.nio.charset.Charset; import java.nio.file.InvalidPathException; import java.nio.file.attribute.BasicFileAttributes; @@ -1115,7 +1116,7 @@ private static class Source { // a bootstrap cycle that would leave this initialized as null private static final JavaUtilJarAccess JUJA = SharedSecrets.javaUtilJarAccess(); // "META-INF/".length() - private static final int META_INF_LENGTH = 9; + private static final int META_INF_LEN = 9; private static final int[] EMPTY_META_VERSIONS = new int[0]; private final Key key; // the key in files @@ -1148,16 +1149,49 @@ private static class Source { // private Entry[] entries; // array of hashed cen entry // // To reduce the total size of entries further, we use a int[] here to store 3 "int" - // {@code hash}, {@code next and {@code "pos for each entry. The entry can then be + // {@code hash}, {@code next} and {@code pos} for each entry. The entry can then be // referred by their index of their positions in the {@code entries}. // private int[] entries; // array of hashed cen entry - private int addEntry(int index, int hash, int next, int pos) { - entries[index++] = hash; - entries[index++] = next; - entries[index++] = pos; - return index; + + // Checks the entry at offset pos in the CEN, calculates the Entry values as per above, + // then returns the length of the entry name. + private int checkAndAddEntry(int pos, int index) + throws ZipException + { + byte[] cen = this.cen; + if (CENSIG(cen, pos) != CENSIG) { + zerror("invalid CEN header (bad signature)"); + } + int method = CENHOW(cen, pos); + int flag = CENFLG(cen, pos); + if ((flag & 1) != 0) { + zerror("invalid CEN header (encrypted entry)"); + } + if (method != STORED && method != DEFLATED) { + zerror("invalid CEN header (bad compression method: " + method + ")"); + } + int entryPos = pos + CENHDR; + int nlen = CENNAM(cen, pos); + if (entryPos + nlen > cen.length - ENDHDR) { + zerror("invalid CEN header (bad header size)"); + } + try { + ZipCoder zcp = zipCoderForPos(pos); + int hash = zcp.checkedHash(cen, entryPos, nlen); + int hsh = (hash & 0x7fffffff) % tablelen; + int next = table[hsh]; + table[hsh] = index; + // Record the CEN offset and the name hash in our hash cell. + entries[index++] = hash; + entries[index++] = next; + entries[index ] = pos; + } catch (Exception e) { + zerror("invalid CEN header (bad entry name)"); + } + return nlen; } + private int getEntryHash(int index) { return entries[index]; } private int getEntryNext(int index) { return entries[index + 1]; } private int getEntryPos(int index) { return entries[index + 2]; } @@ -1413,8 +1447,7 @@ private End findEND() throws IOException { } } } - zerror("zip END header not found"); - return null; //make compiler happy + throw new ZipException("zip END header not found"); } // Reads zip file central directory. @@ -1444,24 +1477,22 @@ private void initCEN(int knownTotal) throws IOException { if (readFullyAt(cen, 0, cen.length, cenpos) != end.cenlen + ENDHDR) { zerror("read CEN tables failed"); } - total = end.centot; + this.total = end.centot; } else { cen = this.cen; - total = knownTotal; + this.total = knownTotal; } // hash table for entries - entries = new int[total * 3]; + int entriesLength = this.total * 3; + entries = new int[entriesLength]; - this.tablelen = ((total/2) | 1); // Odd -> fewer collisions - int tablelen = this.tablelen; + int tablelen = ((total/2) | 1); // Odd -> fewer collisions + this.tablelen = tablelen; - this.table = new int[tablelen]; - int[] table = this.table; + int[] table = new int[tablelen]; + this.table = table; Arrays.fill(table, ZIP_ENDCHAIN); - int idx = 0; - int hash; - int next; // list for all meta entries ArrayList signatureNames = null; @@ -1469,48 +1500,30 @@ private void initCEN(int knownTotal) throws IOException { Set metaVersionsSet = null; // Iterate through the entries in the central directory - int i = 0; - int hsh; + int idx = 0; // Index into the entries array int pos = 0; int entryPos = CENHDR; int limit = cen.length - ENDHDR; while (entryPos <= limit) { - if (i >= total) { + if (idx >= entriesLength) { // This will only happen if the zip file has an incorrect // ENDTOT field, which usually means it contains more than // 65535 entries. initCEN(countCENHeaders(cen, limit)); return; } - if (CENSIG(cen, pos) != CENSIG) - zerror("invalid CEN header (bad signature)"); - int method = CENHOW(cen, pos); - int nlen = CENNAM(cen, pos); - int elen = CENEXT(cen, pos); - int clen = CENCOM(cen, pos); - int flag = CENFLG(cen, pos); - if ((flag & 1) != 0) - zerror("invalid CEN header (encrypted entry)"); - if (method != STORED && method != DEFLATED) - zerror("invalid CEN header (bad compression method: " + method + ")"); - if (entryPos + nlen > limit) - zerror("invalid CEN header (bad header size)"); - ZipCoder zcp = zipCoderForPos(pos); - zcp.checkEncoding(cen, pos + CENHDR, nlen); - // Record the CEN offset and the name hash in our hash cell. - hash = zcp.normalizedHash(cen, entryPos, nlen); - hsh = (hash & 0x7fffffff) % tablelen; - next = table[hsh]; - table[hsh] = idx; - idx = addEntry(idx, hash, next, pos); + + // Checks the entry and adds values to entries[idx ... idx+2] + int nlen = checkAndAddEntry(pos, idx); + idx += 3; + // Adds name to metanames. if (isMetaName(cen, entryPos, nlen)) { // nlen is at least META_INF_LENGTH - if (isManifestName(cen, entryPos + META_INF_LENGTH, - nlen - META_INF_LENGTH)) { + if (isManifestName(entryPos + META_INF_LEN, nlen - META_INF_LEN)) { manifestPos = pos; } else { - if (isSignatureRelated(cen, entryPos, nlen)) { + if (isSignatureRelated(entryPos, nlen)) { if (signatureNames == null) signatureNames = new ArrayList<>(4); signatureNames.add(pos); @@ -1519,8 +1532,7 @@ private void initCEN(int knownTotal) throws IOException { // If this is a versioned entry, parse the version // and store it for later. This optimizes lookup // performance in multi-release jar files - int version = getMetaVersion(cen, - entryPos + META_INF_LENGTH, nlen - META_INF_LENGTH); + int version = getMetaVersion(entryPos + META_INF_LEN, nlen - META_INF_LEN); if (version > 0) { if (metaVersionsSet == null) metaVersionsSet = new TreeSet<>(); @@ -1528,12 +1540,14 @@ private void initCEN(int knownTotal) throws IOException { } } } - // skip ext and comment - pos = entryPos + nlen + elen + clen; + // skip to the start of the next entry + pos = nextEntryPos(pos, entryPos, nlen); entryPos = pos + CENHDR; - i++; } - total = i; + + // Adjust the total entries + this.total = idx / 3; + if (signatureNames != null) { int len = signatureNames.size(); signatureMetaNames = new int[len]; @@ -1555,6 +1569,10 @@ private void initCEN(int knownTotal) throws IOException { } } + private int nextEntryPos(int pos, int entryPos, int nlen) { + return entryPos + nlen + CENCOM(cen, pos) + CENEXT(cen, pos); + } + private static void zerror(String msg) throws ZipException { throw new ZipException(msg); } @@ -1568,7 +1586,7 @@ private int getEntryPos(String name, boolean addSlash) { return -1; } - int hsh = ZipCoder.normalizedHash(name); + int hsh = ZipCoder.hash(name); int idx = table[(hsh & 0x7fffffff) % tablelen]; // Search down the target hash chain for a entry whose @@ -1620,7 +1638,7 @@ private ZipCoder zipCoderForPos(int pos) { private static boolean isMetaName(byte[] name, int off, int len) { // Use the "oldest ASCII trick in the book": // ch | 0x20 == Character.toLowerCase(ch) - return len > META_INF_LENGTH // "META-INF/".length() + return len > META_INF_LEN // "META-INF/".length() && name[off + len - 1] != '/' // non-directory && (name[off++] | 0x20) == 'm' && (name[off++] | 0x20) == 'e' @@ -1636,7 +1654,8 @@ private static boolean isMetaName(byte[] name, int off, int len) { /* * Check if the bytes represents a name equals to MANIFEST.MF */ - private static boolean isManifestName(byte[] name, int off, int len) { + private boolean isManifestName(int off, int len) { + byte[] name = cen; return (len == 11 // "MANIFEST.MF".length() && (name[off++] | 0x20) == 'm' && (name[off++] | 0x20) == 'a' @@ -1651,11 +1670,12 @@ private static boolean isManifestName(byte[] name, int off, int len) { && (name[off] | 0x20) == 'f'); } - private static boolean isSignatureRelated(byte[] name, int off, int len) { + private boolean isSignatureRelated(int off, int len) { // Only called when isMetaName(name, off, len) is true, which means // len is at least META_INF_LENGTH // assert isMetaName(name, off, len) boolean signatureRelated = false; + byte[] name = cen; if (name[off + len - 3] == '.') { // Check if entry ends with .EC and .SF int b1 = name[off + len - 2] | 0x20; @@ -1685,7 +1705,8 @@ private static boolean isSignatureRelated(byte[] name, int off, int len) { * followed by a '/', then return that integer value. * Otherwise, return 0 */ - private static int getMetaVersion(byte[] name, int off, int len) { + private int getMetaVersion(int off, int len) { + byte[] name = cen; int nend = off + len; if (!(len > 10 // "versions//".length() && name[off + len - 1] != '/' // non-directory From 5324b5c582325b1703000fc9dbf8a2a1002bd2fc Mon Sep 17 00:00:00 2001 From: Zhengyu Gu Date: Wed, 3 Feb 2021 13:15:59 +0000 Subject: [PATCH 43/77] 8260998: Shenandoah: Restore reference processing statistics reporting Reviewed-by: shade --- .../gc/shenandoah/shenandoahReferenceProcessor.cpp | 10 +++++++++- .../gc/shenandoah/shenandoahReferenceProcessor.hpp | 6 ++++++ src/hotspot/share/gc/shenandoah/shenandoahUtils.cpp | 5 ++++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/hotspot/share/gc/shenandoah/shenandoahReferenceProcessor.cpp b/src/hotspot/share/gc/shenandoah/shenandoahReferenceProcessor.cpp index b9ef5d410a761..787774824eccb 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahReferenceProcessor.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahReferenceProcessor.cpp @@ -200,7 +200,8 @@ ShenandoahReferenceProcessor::ShenandoahReferenceProcessor(uint max_workers) : _ref_proc_thread_locals(NEW_C_HEAP_ARRAY(ShenandoahRefProcThreadLocal, max_workers, mtGC)), _pending_list(NULL), _pending_list_tail(&_pending_list), - _iterate_discovered_list_id(0U) { + _iterate_discovered_list_id(0U), + _stats() { for (size_t i = 0; i < max_workers; i++) { _ref_proc_thread_locals[i].reset(); } @@ -595,6 +596,12 @@ void ShenandoahReferenceProcessor::collect_statistics() { enqueued[type] += _ref_proc_thread_locals[i].enqueued((ReferenceType)type); } } + + _stats = ReferenceProcessorStats(discovered[REF_SOFT], + discovered[REF_WEAK], + discovered[REF_FINAL], + discovered[REF_PHANTOM]); + log_info(gc,ref)("Encountered references: Soft: " SIZE_FORMAT ", Weak: " SIZE_FORMAT ", Final: " SIZE_FORMAT ", Phantom: " SIZE_FORMAT, encountered[REF_SOFT], encountered[REF_WEAK], encountered[REF_FINAL], encountered[REF_PHANTOM]); log_info(gc,ref)("Discovered references: Soft: " SIZE_FORMAT ", Weak: " SIZE_FORMAT ", Final: " SIZE_FORMAT ", Phantom: " SIZE_FORMAT, @@ -602,3 +609,4 @@ void ShenandoahReferenceProcessor::collect_statistics() { log_info(gc,ref)("Enqueued references: Soft: " SIZE_FORMAT ", Weak: " SIZE_FORMAT ", Final: " SIZE_FORMAT ", Phantom: " SIZE_FORMAT, enqueued[REF_SOFT], enqueued[REF_WEAK], enqueued[REF_FINAL], enqueued[REF_PHANTOM]); } + diff --git a/src/hotspot/share/gc/shenandoah/shenandoahReferenceProcessor.hpp b/src/hotspot/share/gc/shenandoah/shenandoahReferenceProcessor.hpp index b03b7a5b0e82c..e88d710ab7984 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahReferenceProcessor.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahReferenceProcessor.hpp @@ -27,6 +27,8 @@ #define SHARE_VM_GC_SHENANDOAH_SHENANDOAHREFERENCEPROCESSOR_HPP #include "gc/shared/referenceDiscoverer.hpp" +#include "gc/shared/referencePolicy.hpp" +#include "gc/shared/referenceProcessorStats.hpp" #include "gc/shenandoah/shenandoahPhaseTimings.hpp" #include "memory/allocation.hpp" @@ -136,6 +138,8 @@ class ShenandoahReferenceProcessor : public ReferenceDiscoverer { volatile uint _iterate_discovered_list_id; + ReferenceProcessorStats _stats; + template bool is_inactive(oop reference, oop referent, ReferenceType type) const; bool is_strongly_live(oop referent) const; @@ -179,6 +183,8 @@ class ShenandoahReferenceProcessor : public ReferenceDiscoverer { void process_references(ShenandoahPhaseTimings::Phase phase, WorkGang* workers, bool concurrent); + const ReferenceProcessorStats& reference_process_stats() { return _stats; } + void work(); void abandon_partial_discovery(); diff --git a/src/hotspot/share/gc/shenandoah/shenandoahUtils.cpp b/src/hotspot/share/gc/shenandoah/shenandoahUtils.cpp index 677dc1ee418e9..9a7213241b764 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahUtils.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahUtils.cpp @@ -28,10 +28,12 @@ #include "gc/shared/gcCause.hpp" #include "gc/shared/gcTrace.hpp" #include "gc/shared/gcWhen.hpp" +#include "gc/shared/referenceProcessorStats.hpp" +#include "gc/shenandoah/heuristics/shenandoahHeuristics.hpp" #include "gc/shenandoah/shenandoahCollectorPolicy.hpp" #include "gc/shenandoah/shenandoahHeap.inline.hpp" +#include "gc/shenandoah/shenandoahReferenceProcessor.hpp" #include "gc/shenandoah/shenandoahUtils.hpp" -#include "gc/shenandoah/heuristics/shenandoahHeuristics.hpp" #include "utilities/debug.hpp" ShenandoahPhaseTimings::Phase ShenandoahTimingsTracker::_current_phase = ShenandoahPhaseTimings::_invalid_phase; @@ -65,6 +67,7 @@ ShenandoahGCSession::~ShenandoahGCSession() { _heap->heuristics()->record_cycle_end(); _timer->register_gc_end(); _heap->trace_heap_after_gc(_tracer); + _tracer->report_gc_reference_stats(_heap->ref_processor()->reference_process_stats()); _tracer->report_gc_end(_timer->gc_end(), _timer->time_partitions()); assert(!ShenandoahGCPhase::is_current_phase_valid(), "No current GC phase"); _heap->set_gc_cause(GCCause::_no_gc); From 0ef93feb43eb3f3cb855ed35b1c2e81493924dc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20=C5=A0ipka?= Date: Wed, 3 Feb 2021 14:08:29 +0000 Subject: [PATCH 44/77] 8259265: Refactor UncaughtExceptions shell test as java test. Reviewed-by: rriggs --- .../java/lang/Thread/UncaughtExceptions.sh | 205 ----------------- .../lang/Thread/UncaughtExceptionsTest.java | 206 ++++++++++++++++++ 2 files changed, 206 insertions(+), 205 deletions(-) delete mode 100644 test/jdk/java/lang/Thread/UncaughtExceptions.sh create mode 100644 test/jdk/java/lang/Thread/UncaughtExceptionsTest.java diff --git a/test/jdk/java/lang/Thread/UncaughtExceptions.sh b/test/jdk/java/lang/Thread/UncaughtExceptions.sh deleted file mode 100644 index 7ed96672a23b2..0000000000000 --- a/test/jdk/java/lang/Thread/UncaughtExceptions.sh +++ /dev/null @@ -1,205 +0,0 @@ -#!/bin/sh - -# -# Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -# -# @test -# @bug 4833089 4992454 -# @summary Check for proper handling of uncaught exceptions -# @author Martin Buchholz -# -# @run shell UncaughtExceptions.sh - -# To run this test manually, simply do ./UncaughtExceptions.sh - - java="${TESTJAVA+${TESTJAVA}/bin/}java" -javac="${COMPILEJAVA+${COMPILEJAVA}/bin/}javac" - -failed="" -Fail() { echo "FAIL: $1"; failed="${failed}."; } - -Die() { printf "%s\n" "$*"; exit 1; } - -Sys() { - "$@"; rc="$?"; - test "$rc" -eq 0 || Die "Command \"$*\" failed with exitValue $rc"; -} - -HorizontalRule() { - echo "-----------------------------------------------------------------" -} - -Bottom() { - test "$#" = 1 -a "$1" = "Line" || Die "Usage: Bottom Line" - - HorizontalRule - if test -n "$failed"; then - count=`printf "%s" "$failed" | wc -c | tr -d ' '` - echo "FAIL: $count tests failed" - exit 1 - else - echo "PASS: all tests gave expected results" - exit 0 - fi -} - -Cleanup() { Sys rm -f Seppuku* OK.class; } - -set -u - -checkOutput() { - name="$1" expected="$2" got="$3" - printf "$name:\n"; cat "$got" - if test -z "$expected"; then - test "`cat $got`" != "" && \ - Fail "Unexpected $name: `cat $got`" - else - grep "$expected" "$got" >/dev/null || \ - Fail "Expected \"$expected\", got `cat $got`" - fi -} - -CheckCommandResults() { - expectedRC="$1" expectedOut="$2" expectedErr="$3"; shift 3 - saveFailed="${failed}" - "$@" >TmpTest.Out 2>TmpTest.Err; rc="$?"; - printf "==> %s (rc=%d)\n" "$*" "$rc" - checkOutput "stdout" "$expectedOut" "TmpTest.Out" - checkOutput "stderr" "$expectedErr" "TmpTest.Err" - test "${saveFailed}" = "${failed}" && \ - echo "PASS: command completed as expected" - Sys rm -f TmpTest.Out TmpTest.Err -} - -Run() { - expectedRC="$1" expectedOut="$2" expectedErr="$3" mainBody="$4" - cat > Seppuku.java < Date: Wed, 3 Feb 2021 14:15:00 +0000 Subject: [PATCH 45/77] 8241995: Clarify InetSocketAddress::toString specification Reviewed-by: michaelm, chegar --- .../classes/java/net/InetSocketAddress.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/java.base/share/classes/java/net/InetSocketAddress.java b/src/java.base/share/classes/java/net/InetSocketAddress.java index 7eb0273448a76..56635cbe929cb 100644 --- a/src/java.base/share/classes/java/net/InetSocketAddress.java +++ b/src/java.base/share/classes/java/net/InetSocketAddress.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -373,11 +373,18 @@ public final boolean isUnresolved() { /** * Constructs a string representation of this InetSocketAddress. - * This String is constructed by calling toString() on the InetAddress - * and concatenating the port number (with a colon). If the address - * is an IPv6 address, the IPv6 literal is enclosed in square brackets. + * This string is constructed by calling {@link InetAddress#toString()} + * on the InetAddress and concatenating the port number (with a colon). + *

      + * If the address is an IPv6 address, the IPv6 literal is enclosed in + * square brackets, for example: {@code "localhost/[0:0:0:0:0:0:0:1]:80"}. * If the address is {@linkplain #isUnresolved() unresolved}, - * {@code } is displayed in place of the address literal. + * {@code } is displayed in place of the address literal, for + * example {@code "foo/:80"}. + *

      + * To retrieve a string representation of the hostname or the address, use + * {@link #getHostString()}, rather than parsing the string returned by this + * {@link #toString()} method. * * @return a string representation of this object. */ From 472bf629cd94dc08d5de6f0b69d2c88861cb0a4b Mon Sep 17 00:00:00 2001 From: Nils Eliasson Date: Wed, 3 Feb 2021 16:01:59 +0000 Subject: [PATCH 46/77] 8258799: [Testbug] RandomCommandsTest must check if tested directive is added via jcmd Reviewed-by: kvn, iignatyev --- .../share/scenario/JcmdStateBuilder.java | 2 +- .../share/scenario/Scenario.java | 20 +++++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/test/hotspot/jtreg/compiler/compilercontrol/share/scenario/JcmdStateBuilder.java b/test/hotspot/jtreg/compiler/compilercontrol/share/scenario/JcmdStateBuilder.java index f36d5fb7f71e6..ba9557966b90f 100644 --- a/test/hotspot/jtreg/compiler/compilercontrol/share/scenario/JcmdStateBuilder.java +++ b/test/hotspot/jtreg/compiler/compilercontrol/share/scenario/JcmdStateBuilder.java @@ -46,7 +46,7 @@ public class JcmdStateBuilder implements StateBuilder { private final Map> matchBlocks = new LinkedHashMap<>(); private final List inlines = new ArrayList<>(); - private boolean isFileValid = true; + public boolean isFileValid = true; public JcmdStateBuilder(String fileName) { directiveBuilder = new DirectiveBuilder(fileName); diff --git a/test/hotspot/jtreg/compiler/compilercontrol/share/scenario/Scenario.java b/test/hotspot/jtreg/compiler/compilercontrol/share/scenario/Scenario.java index 785ee5aa17178..89928678ae598 100644 --- a/test/hotspot/jtreg/compiler/compilercontrol/share/scenario/Scenario.java +++ b/test/hotspot/jtreg/compiler/compilercontrol/share/scenario/Scenario.java @@ -49,18 +49,21 @@ */ public final class Scenario { private final boolean isValid; + private final boolean isJcmdValid; private final Map states; private final List> processors; private final Executor executor; private final Consumer> jcmdProcessor; private Scenario(boolean isValid, + boolean isJcmdValid, List vmopts, Map states, List compileCommands, List jcmdCommands, List directives) { this.isValid = isValid; + this.isJcmdValid = isJcmdValid; this.states = states; processors = new ArrayList<>(); processors.add(new LogProcessor(states)); @@ -121,7 +124,18 @@ public void execute() { } else { // two cases for invalid inputs. if (mainOutput.getExitValue() == 0) { - mainOutput.shouldContain("CompileCommand: An error occurred during parsing"); + if (!isJcmdValid) { + boolean parse_error_found = false; + for(OutputAnalyzer out : outputList) { + if (out.getOutput().contains("Parsing of compiler directives failed")) { + parse_error_found = true; + break; + } + } + Asserts.assertTrue(parse_error_found, "'Parsing of compiler directives failed' missing from output"); + } else { + mainOutput.shouldContain("CompileCommand: An error occurred during parsing"); + } } else { Asserts.assertNE(mainOutput.getExitValue(), 0, "VM should exit with " + "error for incorrect directives"); @@ -253,6 +267,7 @@ public void add(CompileCommand compileCommand) { public Scenario build() { boolean isValid = true; + boolean isJcmdValid = true; // Get states from each of the state builders Map commandFileStates @@ -315,6 +330,7 @@ public Scenario build() { options.addAll(builder.getOptions()); isValid &= builder.isValid(); } + isJcmdValid = jcmdStateBuilder.isFileValid; options.addAll(jcmdStateBuilder.getOptions()); /* @@ -328,7 +344,7 @@ public Scenario build() { .forEach(entry -> entry.getValue().setLog(true)); } - return new Scenario(isValid, options, finalStates, ccList, + return new Scenario(isValid, isJcmdValid, options, finalStates, ccList, jcmdCommands, directives); } From 4a8b5c1602789e95457cbb080a64c56edaf81051 Mon Sep 17 00:00:00 2001 From: Weijun Wang Date: Wed, 3 Feb 2021 16:20:16 +0000 Subject: [PATCH 47/77] 8257858: [macOS]: Remove JNF dependency from libosxsecurity/KeystoreImpl.m 8257860: [macOS]: Remove JNF dependency from libosxkrb5/SCDynamicStoreConfig.m Reviewed-by: erikj, prr, ihse, valeriep --- make/common/TestFilesCompilation.gmk | 2 +- make/modules/java.base/Lib.gmk | 4 +- make/modules/java.security.jgss/Lib.gmk | 6 +- make/test/JtregNativeJdk.gmk | 8 +- .../classes/apple/security/KeychainStore.java | 6 +- .../native/libosxsecurity/KeystoreImpl.m | 181 +++++++----- .../native/libosxkrb5/SCDynamicStoreConfig.m | 274 +++++++----------- .../security/krb5/SCDynamicStoreConfig.java | 140 ++++----- ...MainKeyWindow.c => libTestMainKeyWindow.m} | 0 .../krb5/config/SCDynamicConfigTest.java | 103 ------- .../krb5/config/native/TestDynamicStore.java | 89 ++++++ .../krb5/config/native/libTestDynamicStore.m | 111 +++++++ 12 files changed, 488 insertions(+), 436 deletions(-) rename test/jdk/java/awt/Window/MainKeyWindowTest/{libTestMainKeyWindow.c => libTestMainKeyWindow.m} (100%) delete mode 100644 test/jdk/sun/security/krb5/config/SCDynamicConfigTest.java create mode 100644 test/jdk/sun/security/krb5/config/native/TestDynamicStore.java create mode 100644 test/jdk/sun/security/krb5/config/native/libTestDynamicStore.m diff --git a/make/common/TestFilesCompilation.gmk b/make/common/TestFilesCompilation.gmk index ce06a76c27c3c..01dc181d2c2ab 100644 --- a/make/common/TestFilesCompilation.gmk +++ b/make/common/TestFilesCompilation.gmk @@ -81,7 +81,7 @@ define SetupTestFilesCompilationBody # Locate all files with the matching prefix $1_FILE_LIST := \ - $$(call FindFiles, $$($1_SOURCE_DIRS), $$($1_PREFIX)*.c $$($1_PREFIX)*.cpp) + $$(call FindFiles, $$($1_SOURCE_DIRS), $$($1_PREFIX)*.c $$($1_PREFIX)*.cpp $$($1_PREFIX)*.m) $1_EXCLUDE_PATTERN := $$(addprefix %/, $$($1_EXCLUDE)) $1_FILTERED_FILE_LIST := $$(filter-out $$($1_EXCLUDE_PATTERN), $$($1_FILE_LIST)) diff --git a/make/modules/java.base/Lib.gmk b/make/modules/java.base/Lib.gmk index c48f327420a6a..0eff999a01196 100644 --- a/make/modules/java.base/Lib.gmk +++ b/make/modules/java.base/Lib.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -110,9 +110,9 @@ ifeq ($(call isTargetOs, macosx), true) $(call SET_SHARED_LIBRARY_ORIGIN), \ LIBS := \ -lobjc \ - -framework JavaNativeFoundation \ -framework CoreServices \ -framework Security \ + -framework Foundation \ $(JDKLIB_LIBS), \ )) diff --git a/make/modules/java.security.jgss/Lib.gmk b/make/modules/java.security.jgss/Lib.gmk index e75c45f193a9c..93acd8f87312a 100644 --- a/make/modules/java.security.jgss/Lib.gmk +++ b/make/modules/java.security.jgss/Lib.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -80,8 +80,8 @@ ifneq ($(BUILD_CRYPTO), false) DISABLED_WARNINGS_clang := deprecated-declarations, \ LDFLAGS := $(LDFLAGS_JDKLIB) \ $(call SET_SHARED_LIBRARY_ORIGIN), \ - LIBS := -framework JavaNativeFoundation -framework Cocoa \ - -framework SystemConfiguration -framework Kerberos, \ + LIBS := -framework Cocoa -framework SystemConfiguration \ + -framework Kerberos, \ )) TARGETS += $(BUILD_LIBOSXKRB5) diff --git a/make/test/JtregNativeJdk.gmk b/make/test/JtregNativeJdk.gmk index 57c5bf4035e22..8560ef060a251 100644 --- a/make/test/JtregNativeJdk.gmk +++ b/make/test/JtregNativeJdk.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -77,13 +77,15 @@ endif ifeq ($(call isTargetOs, macosx), true) BUILD_JDK_JTREG_EXCLUDE += exelauncher.c - BUILD_JDK_JTREG_LIBRARIES_CFLAGS_libTestMainKeyWindow := -ObjC BUILD_JDK_JTREG_LIBRARIES_LIBS_libTestMainKeyWindow := \ -framework Cocoa -framework JavaNativeFoundation BUILD_JDK_JTREG_EXECUTABLES_LIBS_exeJniInvocationTest := -ljli + BUILD_JDK_JTREG_LIBRARIES_LIBS_libTestDynamicStore := \ + -framework Cocoa -framework SystemConfiguration else - BUILD_JDK_JTREG_EXCLUDE += libTestMainKeyWindow.c + BUILD_JDK_JTREG_EXCLUDE += libTestMainKeyWindow.m BUILD_JDK_JTREG_EXCLUDE += exeJniInvocationTest.c + BUILD_JDK_JTREG_EXCLUDE += libTestDynamicStore.m endif ifeq ($(call isTargetOs, linux), true) diff --git a/src/java.base/macosx/classes/apple/security/KeychainStore.java b/src/java.base/macosx/classes/apple/security/KeychainStore.java index 27805dbbe61dd..72945f9b667eb 100644 --- a/src/java.base/macosx/classes/apple/security/KeychainStore.java +++ b/src/java.base/macosx/classes/apple/security/KeychainStore.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -815,8 +815,8 @@ private void createTrustedCertEntry(String alias, long keychainItemRef, long cre * Callback method from _scanKeychain. If an identity is found, this method will be called to create Java certificate * and private key objects from the keychain data. */ - private void createKeyEntry(String alias, long creationDate, long secKeyRef, long[] secCertificateRefs, byte[][] rawCertData) - throws IOException, NoSuchAlgorithmException, UnrecoverableKeyException { + private void createKeyEntry(String alias, long creationDate, long secKeyRef, + long[] secCertificateRefs, byte[][] rawCertData) { KeyEntry ke = new KeyEntry(); // First, store off the private key information. This is the easy part. diff --git a/src/java.base/macosx/native/libosxsecurity/KeystoreImpl.m b/src/java.base/macosx/native/libosxsecurity/KeystoreImpl.m index 6c35dbf2b10ff..f427737b9a811 100644 --- a/src/java.base/macosx/native/libosxsecurity/KeystoreImpl.m +++ b/src/java.base/macosx/native/libosxsecurity/KeystoreImpl.m @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,16 +25,10 @@ #import "apple_security_KeychainStore.h" #import "jni_util.h" - #import #import #import // (for require() macros) -#import - - -static JNF_CLASS_CACHE(jc_KeychainStore, "apple/security/KeychainStore"); -static JNF_MEMBER_CACHE(jm_createTrustedCertEntry, jc_KeychainStore, "createTrustedCertEntry", "(Ljava/lang/String;JJ[B)V"); -static JNF_MEMBER_CACHE(jm_createKeyEntry, jc_KeychainStore, "createKeyEntry", "(Ljava/lang/String;JJ[J[[B)V"); +#import static jstring getLabelFromItem(JNIEnv *env, SecKeychainItemRef inItem) { @@ -290,6 +284,10 @@ static void addIdentitiesToKeystore(JNIEnv *env, jobject keyStore) SecIdentityRef theIdentity = NULL; OSErr searchResult = noErr; + jclass jc_KeychainStore = (*env)->FindClass(env, "apple/security/KeychainStore"); + CHECK_NULL(jc_KeychainStore); + jmethodID jm_createKeyEntry = (*env)->GetMethodID(env, jc_KeychainStore, "createKeyEntry", "(Ljava/lang/String;JJ[J[[B)V"); + CHECK_NULL(jm_createKeyEntry); do { searchResult = SecIdentitySearchCopyNext(identitySearch, &theIdentity); @@ -359,7 +357,8 @@ static void addIdentitiesToKeystore(JNIEnv *env, jobject keyStore) // Call back to the Java object to create Java objects corresponding to this security object. jlong nativeKeyRef = ptr_to_jlong(privateKeyRef); - JNFCallVoidMethod(env, keyStore, jm_createKeyEntry, alias, creationDate, nativeKeyRef, certRefArray, javaCertArray); + (*env)->CallVoidMethod(env, keyStore, jm_createKeyEntry, alias, creationDate, nativeKeyRef, certRefArray, javaCertArray); + JNU_CHECK_EXCEPTION(env); } } while (searchResult == noErr); @@ -377,6 +376,11 @@ static void addCertificatesToKeystore(JNIEnv *env, jobject keyStore) SecKeychainItemRef theItem = NULL; OSErr searchResult = noErr; + jclass jc_KeychainStore = (*env)->FindClass(env, "apple/security/KeychainStore"); + CHECK_NULL(jc_KeychainStore); + jmethodID jm_createTrustedCertEntry = (*env)->GetMethodID( + env, jc_KeychainStore, "createTrustedCertEntry", "(Ljava/lang/String;JJ[B)V"); + CHECK_NULL(jm_createTrustedCertEntry); do { searchResult = SecKeychainSearchCopyNext(keychainItemSearch, &theItem); @@ -402,7 +406,8 @@ static void addCertificatesToKeystore(JNIEnv *env, jobject keyStore) // Call back to the Java object to create Java objects corresponding to this security object. jlong nativeRef = ptr_to_jlong(certRef); - JNFCallVoidMethod(env, keyStore, jm_createTrustedCertEntry, alias, nativeRef, creationDate, certData); + (*env)->CallVoidMethod(env, keyStore, jm_createTrustedCertEntry, alias, nativeRef, creationDate, certData); + JNU_CHECK_EXCEPTION(env); } } while (searchResult == noErr); @@ -500,6 +505,20 @@ static void addCertificatesToKeystore(JNIEnv *env, jobject keyStore) } +NSString* JavaStringToNSString(JNIEnv *env, jstring jstr) { + if (jstr == NULL) { + return NULL; + } + jsize len = (*env)->GetStringLength(env, jstr); + const jchar *chars = (*env)->GetStringChars(env, jstr, NULL); + if (chars == NULL) { + return NULL; + } + NSString *result = [NSString stringWithCharacters:(UniChar *)chars length:len]; + (*env)->ReleaseStringChars(env, jstr, chars); + return result; +} + /* * Class: apple_security_KeychainStore * Method: _addItemToKeychain @@ -511,95 +530,97 @@ static void addCertificatesToKeystore(JNIEnv *env, jobject keyStore) OSStatus err; jlong returnValue = 0; -JNF_COCOA_ENTER(env); + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; \ + @try { + jsize dataSize = (*env)->GetArrayLength(env, rawDataObj); + jbyte *rawData = (*env)->GetByteArrayElements(env, rawDataObj, NULL); + if (rawData == NULL) { + goto errOut; + } - jsize dataSize = (*env)->GetArrayLength(env, rawDataObj); - jbyte *rawData = (*env)->GetByteArrayElements(env, rawDataObj, NULL); - if (rawData == NULL) { - goto errOut; - } + CFDataRef cfDataToImport = CFDataCreate(kCFAllocatorDefault, (UInt8 *)rawData, dataSize); + CFArrayRef createdItems = NULL; - CFDataRef cfDataToImport = CFDataCreate(kCFAllocatorDefault, (UInt8 *)rawData, dataSize); - CFArrayRef createdItems = NULL; + SecKeychainRef defaultKeychain = NULL; + SecKeychainCopyDefault(&defaultKeychain); - SecKeychainRef defaultKeychain = NULL; - SecKeychainCopyDefault(&defaultKeychain); + SecExternalFormat dataFormat = (isCertificate == JNI_TRUE ? kSecFormatX509Cert : kSecFormatWrappedPKCS8); - SecExternalFormat dataFormat = (isCertificate == JNI_TRUE ? kSecFormatX509Cert : kSecFormatWrappedPKCS8); + // Convert the password obj into a CFStringRef that the keychain importer can use for encryption. + SecKeyImportExportParameters paramBlock; + CFStringRef passwordStrRef = NULL; - // Convert the password obj into a CFStringRef that the keychain importer can use for encryption. - SecKeyImportExportParameters paramBlock; - CFStringRef passwordStrRef = NULL; + jsize passwordLen = 0; + jchar *passwordChars = NULL; - jsize passwordLen = 0; - jchar *passwordChars = NULL; + if (passwordObj) { + passwordLen = (*env)->GetArrayLength(env, passwordObj); - if (passwordObj) { - passwordLen = (*env)->GetArrayLength(env, passwordObj); - - if (passwordLen > 0) { - passwordChars = (*env)->GetCharArrayElements(env, passwordObj, NULL); - if (passwordChars == NULL) { - goto errOut; - } + if (passwordLen > 0) { + passwordChars = (*env)->GetCharArrayElements(env, passwordObj, NULL); + if (passwordChars == NULL) { + goto errOut; + } - passwordStrRef = CFStringCreateWithCharactersNoCopy(NULL, passwordChars, passwordLen, kCFAllocatorNull); - if (passwordStrRef == NULL) { - goto errOut; + passwordStrRef = CFStringCreateWithCharactersNoCopy(NULL, passwordChars, passwordLen, kCFAllocatorNull); + if (passwordStrRef == NULL) { + goto errOut; + } } } - } - paramBlock.version = SEC_KEY_IMPORT_EXPORT_PARAMS_VERSION; - // Note that setting the flags field **requires** you to pass in a password of some kind. The keychain will not prompt you. - paramBlock.flags = 0; - paramBlock.passphrase = passwordStrRef; - paramBlock.alertTitle = NULL; - paramBlock.alertPrompt = NULL; - paramBlock.accessRef = NULL; - paramBlock.keyUsage = CSSM_KEYUSE_ANY; - paramBlock.keyAttributes = CSSM_KEYATTR_RETURN_DEFAULT; + paramBlock.version = SEC_KEY_IMPORT_EXPORT_PARAMS_VERSION; + // Note that setting the flags field **requires** you to pass in a password of some kind. The keychain will not prompt you. + paramBlock.flags = 0; + paramBlock.passphrase = passwordStrRef; + paramBlock.alertTitle = NULL; + paramBlock.alertPrompt = NULL; + paramBlock.accessRef = NULL; + paramBlock.keyUsage = CSSM_KEYUSE_ANY; + paramBlock.keyAttributes = CSSM_KEYATTR_RETURN_DEFAULT; + + err = SecKeychainItemImport(cfDataToImport, NULL, &dataFormat, NULL, + 0, ¶mBlock, defaultKeychain, &createdItems); + if (cfDataToImport != NULL) { + CFRelease(cfDataToImport); + } - err = SecKeychainItemImport(cfDataToImport, NULL, &dataFormat, NULL, - 0, ¶mBlock, defaultKeychain, &createdItems); - if (cfDataToImport != NULL) { - CFRelease(cfDataToImport); - } + if (err == noErr) { + SecKeychainItemRef anItem = (SecKeychainItemRef)CFArrayGetValueAtIndex(createdItems, 0); - if (err == noErr) { - SecKeychainItemRef anItem = (SecKeychainItemRef)CFArrayGetValueAtIndex(createdItems, 0); + // Don't bother labeling keys. They become part of an identity, and are not an accessible part of the keychain. + if (CFGetTypeID(anItem) == SecCertificateGetTypeID()) { + setLabelForItem(JavaStringToNSString(env, alias), anItem); + } - // Don't bother labeling keys. They become part of an identity, and are not an accessible part of the keychain. - if (CFGetTypeID(anItem) == SecCertificateGetTypeID()) { - setLabelForItem(JNFJavaToNSString(env, alias), anItem); + // Retain the item, since it will be released once when the array holding it gets released. + CFRetain(anItem); + returnValue = ptr_to_jlong(anItem); + } else { + cssmPerror("_addItemToKeychain: SecKeychainItemImport", err); } - // Retain the item, since it will be released once when the array holding it gets released. - CFRetain(anItem); - returnValue = ptr_to_jlong(anItem); - } else { - cssmPerror("_addItemToKeychain: SecKeychainItemImport", err); - } - - if (createdItems != NULL) { - CFRelease(createdItems); - } + if (createdItems != NULL) { + CFRelease(createdItems); + } -errOut: - if (rawData) { - (*env)->ReleaseByteArrayElements(env, rawDataObj, rawData, JNI_ABORT); - } + errOut: + if (rawData) { + (*env)->ReleaseByteArrayElements(env, rawDataObj, rawData, JNI_ABORT); + } - if (passwordStrRef) CFRelease(passwordStrRef); - if (passwordChars) { - // clear the password and release - memset(passwordChars, 0, passwordLen); - (*env)->ReleaseCharArrayElements(env, passwordObj, passwordChars, - JNI_ABORT); + if (passwordStrRef) CFRelease(passwordStrRef); + if (passwordChars) { + // clear the password and release + memset(passwordChars, 0, passwordLen); + (*env)->ReleaseCharArrayElements(env, passwordObj, passwordChars, + JNI_ABORT); + } + } @catch (NSException *e) { + NSLog(@"%@", [e callStackSymbols]); + } @finally { + [pool drain]; } - -JNF_COCOA_EXIT(env); - return returnValue; } diff --git a/src/java.security.jgss/macosx/native/libosxkrb5/SCDynamicStoreConfig.m b/src/java.security.jgss/macosx/native/libosxkrb5/SCDynamicStoreConfig.m index 4ea43635d46e8..11645d152cdfa 100644 --- a/src/java.security.jgss/macosx/native/libosxkrb5/SCDynamicStoreConfig.m +++ b/src/java.security.jgss/macosx/native/libosxkrb5/SCDynamicStoreConfig.m @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,110 +24,40 @@ */ #import -#import #import - - -@interface JNFVectorCoercion : NSObject { } -@end - -@implementation JNFVectorCoercion - -- (jobject) coerceNSObject:(id)obj withEnv:(JNIEnv *)env usingCoercer:(JNFTypeCoercion *)coercer { - static JNF_CLASS_CACHE(jc_Vector, "java/util/Vector"); - static JNF_CTOR_CACHE(jm_Vector_ctor, jc_Vector, "(I)V"); - static JNF_MEMBER_CACHE(jm_Vector_add, jc_Vector, "add", "(Ljava/lang/Object;)Z"); - - NSArray *nsArray = (NSArray *)obj; - jobject javaArray = JNFNewObject(env, jm_Vector_ctor, (jint)[nsArray count]); - - for (id obj in nsArray) { - jobject jobj = [coercer coerceNSObject:obj withEnv:env usingCoercer:coercer]; - JNFCallBooleanMethod(env, javaArray, jm_Vector_add, jobj); - if (jobj != NULL) (*env)->DeleteLocalRef(env, jobj); - } - - return javaArray; -} - -- (id) coerceJavaObject:(jobject)obj withEnv:(JNIEnv *)env usingCoercer:(JNFTypeCoercion *)coercer { - return nil; -} - -@end - - -@interface JNFHashtableCoercion : NSObject { } -@end - -@implementation JNFHashtableCoercion - -- (jobject) coerceNSObject:(id)obj withEnv:(JNIEnv *)env usingCoercer:(JNFTypeCoercion *)coercer { - static JNF_CLASS_CACHE(jc_Hashtable, "java/util/Hashtable"); - static JNF_CTOR_CACHE(jm_Hashtable_ctor, jc_Hashtable, "()V"); - static JNF_MEMBER_CACHE(jm_Hashtable_put, jc_Hashtable, "put", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"); - - NSDictionary *nsDict = (NSDictionary *)obj; - NSEnumerator *keyEnum = [nsDict keyEnumerator]; - - jobject jHashTable = JNFNewObject(env, jm_Hashtable_ctor); - - id key = nil; - while ((key = [keyEnum nextObject]) != nil) { - jobject jkey = [coercer coerceNSObject:key withEnv:env usingCoercer:coercer]; - - id value = [nsDict objectForKey:key]; - jobject jvalue = [coercer coerceNSObject:value withEnv:env usingCoercer:coercer]; - - JNFCallObjectMethod(env, jHashTable, jm_Hashtable_put, jkey, jvalue); - - if (jkey != NULL) (*env)->DeleteLocalRef(env, jkey); - if (jvalue != NULL) (*env)->DeleteLocalRef(env, jvalue); - } - - return jHashTable; -} - -- (id) coerceJavaObject:(jobject)obj withEnv:(JNIEnv *)env usingCoercer:(JNFTypeCoercion *)coercer { - return nil; -} - -@end - - - -NSDictionary *realmConfigsForRealms(SCDynamicStoreRef store, NSArray *realms) { - NSMutableDictionary *dict = [NSMutableDictionary dictionary]; - - for (NSString *realm in realms) { - CFTypeRef realmInfo = SCDynamicStoreCopyValue(store, (CFStringRef) [NSString stringWithFormat:@"Kerberos:%@", realm]); - - if (realmInfo == NULL || CFGetTypeID(realmInfo) != CFDictionaryGetTypeID()) { - if (realmInfo) CFRelease(realmInfo); - return nil; - } - - [dict setObject:(NSArray *)realmInfo forKey:realm]; - CFRelease(realmInfo); - } - - return dict; -} - +#import "jni_util.h" #define KERBEROS_DEFAULT_REALMS @"Kerberos-Default-Realms" #define KERBEROS_DEFAULT_REALM_MAPPINGS @"Kerberos-Domain-Realm-Mappings" +#define KERBEROS_REALM_INFO @"Kerberos:%@" + +JavaVM *localVM; void _SCDynamicStoreCallBack(SCDynamicStoreRef store, CFArrayRef changedKeys, void *info) { - NSArray *keys = (NSArray *)changedKeys; + NSArray *keys = (NSArray *)changedKeys; if ([keys count] == 0) return; if (![keys containsObject:KERBEROS_DEFAULT_REALMS] && ![keys containsObject:KERBEROS_DEFAULT_REALM_MAPPINGS]) return; - JNFPerformEnvBlock(JNFThreadDetachOnThreadDeath | JNFThreadSetSystemClassLoaderOnAttach | JNFThreadAttachAsDaemon, ^(JNIEnv *env) { - static JNF_CLASS_CACHE(jc_Config, "sun/security/krb5/Config"); - static JNF_STATIC_MEMBER_CACHE(jm_Config_refresh, jc_Config, "refresh", "()V"); - JNFCallStaticVoidMethod(env, jm_Config_refresh); - }); + JNIEnv *env; + bool createdFromAttach = FALSE; + jint status = (*localVM)->GetEnv(localVM, (void**)&env, JNI_VERSION_1_2); + if (status == JNI_EDETACHED) { + status = (*localVM)->AttachCurrentThreadAsDaemon(localVM, (void**)&env, NULL); + createdFromAttach = TRUE; + } + if (status == 0) { + jclass jc_Config = (*env)->FindClass(env, "sun/security/krb5/Config"); + CHECK_NULL(jc_Config); + jmethodID jm_Config_refresh = (*env)->GetStaticMethodID(env, jc_Config, "refresh", "()V"); + CHECK_NULL(jm_Config_refresh); + (*env)->CallStaticVoidMethod(env, jc_Config, jm_Config_refresh); + if ((*env)->ExceptionOccurred(env) != NULL) { + (*env)->ExceptionClear(env); + } + if (createdFromAttach) { + (*localVM)->DetachCurrentThread(localVM); + } + } } /* @@ -135,89 +65,109 @@ void _SCDynamicStoreCallBack(SCDynamicStoreRef store, CFArrayRef changedKeys, vo * Method: installNotificationCallback */ JNIEXPORT void JNICALL Java_sun_security_krb5_SCDynamicStoreConfig_installNotificationCallback(JNIEnv *env, jclass klass) { + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; \ + @try { + (*env)->GetJavaVM(env, &localVM); + SCDynamicStoreRef store = SCDynamicStoreCreate(NULL, CFSTR("java"), _SCDynamicStoreCallBack, NULL); + if (store == NULL) { + return; + } -JNF_COCOA_ENTER(env); - - SCDynamicStoreRef store = SCDynamicStoreCreate(NULL, CFSTR("java"), _SCDynamicStoreCallBack, NULL); - if (store == NULL) { - return; - } + NSArray *keys = [NSArray arrayWithObjects:KERBEROS_DEFAULT_REALMS, KERBEROS_DEFAULT_REALM_MAPPINGS, nil]; + SCDynamicStoreSetNotificationKeys(store, (CFArrayRef) keys, NULL); - NSArray *keys = [NSArray arrayWithObjects:KERBEROS_DEFAULT_REALMS, KERBEROS_DEFAULT_REALM_MAPPINGS, nil]; - SCDynamicStoreSetNotificationKeys(store, (CFArrayRef) keys, NULL); + CFRunLoopSourceRef rls = SCDynamicStoreCreateRunLoopSource(NULL, store, 0); + if (rls != NULL) { + CFRunLoopAddSource(CFRunLoopGetMain(), rls, kCFRunLoopDefaultMode); + CFRelease(rls); + } - CFRunLoopSourceRef rls = SCDynamicStoreCreateRunLoopSource(NULL, store, 0); - if (rls != NULL) { - CFRunLoopAddSource(CFRunLoopGetMain(), rls, kCFRunLoopDefaultMode); - CFRelease(rls); + CFRelease(store); + } @catch (NSException *e) { + NSLog(@"%@", [e callStackSymbols]); + } @finally { + [pool drain]; } +} - CFRelease(store); - -JNF_COCOA_EXIT(env); - +#define ADD(list, str) { \ + jobject localeObj = (*env)->NewStringUTF(env, [str UTF8String]); \ + (*env)->CallBooleanMethod(env, list, jm_listAdd, localeObj); \ + (*env)->DeleteLocalRef(env, localeObj); \ } +#define ADDNULL(list) (*env)->CallBooleanMethod(env, list, jm_listAdd, NULL) + /* * Class: sun_security_krb5_SCDynamicStoreConfig * Method: getKerberosConfig - * Signature: ()Ljava/util/Hashtable; + * Signature: ()Ljava/util/List; */ JNIEXPORT jobject JNICALL Java_sun_security_krb5_SCDynamicStoreConfig_getKerberosConfig(JNIEnv *env, jclass klass) { - jobject jHashTable = NULL; -JNF_COCOA_ENTER(env); + jobject newList = 0; - SCDynamicStoreRef store = SCDynamicStoreCreate(NULL, CFSTR("java-kerberos"), NULL, NULL); - if (store == NULL) { - return NULL; - } + SCDynamicStoreRef store = NULL; + CFTypeRef realms = NULL; + CFTypeRef realmMappings = NULL; + CFTypeRef realmInfo = NULL; - CFTypeRef realms = SCDynamicStoreCopyValue(store, (CFStringRef) KERBEROS_DEFAULT_REALMS); - if (realms == NULL || CFGetTypeID(realms) != CFArrayGetTypeID()) { - if (realms) CFRelease(realms); - CFRelease(store); - return NULL; - } + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; \ + @try { + SCDynamicStoreRef store = SCDynamicStoreCreate(NULL, CFSTR("java-kerberos"), NULL, NULL); + if (store == NULL) { + return NULL; + } - CFTypeRef realmMappings = SCDynamicStoreCopyValue(store, (CFStringRef) KERBEROS_DEFAULT_REALM_MAPPINGS); + CFTypeRef realms = SCDynamicStoreCopyValue(store, (CFStringRef) KERBEROS_DEFAULT_REALMS); + if (realms == NULL || CFGetTypeID(realms) != CFArrayGetTypeID()) { + return NULL; + } - if (realmMappings == NULL || CFGetTypeID(realmMappings) != CFArrayGetTypeID()) { + // This methods returns a ArrayList: + // (realm kdc* null) null (mapping-domain mapping-realm)* + jclass jc_arrayListClass = (*env)->FindClass(env, "java/util/ArrayList"); + CHECK_NULL_RETURN(jc_arrayListClass, NULL); + jmethodID jm_arrayListCons = (*env)->GetMethodID(env, jc_arrayListClass, "", "()V"); + CHECK_NULL_RETURN(jm_arrayListCons, NULL); + jmethodID jm_listAdd = (*env)->GetMethodID(env, jc_arrayListClass, "add", "(Ljava/lang/Object;)Z"); + CHECK_NULL_RETURN(jm_listAdd, NULL); + newList = (*env)->NewObject(env, jc_arrayListClass, jm_arrayListCons); + CHECK_NULL_RETURN(newList, NULL); + + for (NSString *realm in (NSArray*)realms) { + if (realmInfo) CFRelease(realmInfo); // for the previous realm + realmInfo = SCDynamicStoreCopyValue(store, (CFStringRef) [NSString stringWithFormat:KERBEROS_REALM_INFO, realm]); + if (realmInfo == NULL || CFGetTypeID(realmInfo) != CFDictionaryGetTypeID()) { + continue; + } + + ADD(newList, realm); + NSDictionary* ri = (NSDictionary*)realmInfo; + for (NSDictionary* k in (NSArray*)ri[@"kdc"]) { + ADD(newList, k[@"host"]); + } + ADDNULL(newList); + } + ADDNULL(newList); + + CFTypeRef realmMappings = SCDynamicStoreCopyValue(store, (CFStringRef) KERBEROS_DEFAULT_REALM_MAPPINGS); + if (realmMappings != NULL && CFGetTypeID(realmMappings) == CFArrayGetTypeID()) { + for (NSDictionary* d in (NSArray *)realmMappings) { + for (NSString* s in d) { + ADD(newList, s); + ADD(newList, d[s]); + } + } + } + } @catch (NSException *e) { + NSLog(@"%@", [e callStackSymbols]); + } @finally { + [pool drain]; + if (realmInfo) CFRelease(realmInfo); if (realmMappings) CFRelease(realmMappings); - CFRelease(realms); - CFRelease(store); - return NULL; - } - - NSMutableDictionary *dict = [NSMutableDictionary dictionary]; - - if (CFArrayGetCount(realms) > 0) { - NSDictionary *defaultRealmsDict = [NSDictionary dictionaryWithObject:[(NSArray *)realms objectAtIndex:0] forKey:@"default_realm"]; - [dict setObject:defaultRealmsDict forKey:@"libdefaults"]; - - NSDictionary *realmConfigs = realmConfigsForRealms(store, (NSArray *)realms); - [dict setObject:realmConfigs forKey:@"realms"]; - } - CFRelease(realms); - CFRelease(store); - - if (CFArrayGetCount(realmMappings) > 0) { - [dict setObject:[(NSArray *)realmMappings objectAtIndex:0] forKey:@"domain_realm"]; + if (realms) CFRelease(realms); + if (store) CFRelease(store); } - CFRelease(realmMappings); - - - // create and load a coercer with all of the different coercions to convert each type of object - JNFTypeCoercer *coercer = [[[JNFTypeCoercer alloc] init] autorelease]; - [JNFDefaultCoercions addStringCoercionTo:coercer]; - [JNFDefaultCoercions addNumberCoercionTo:coercer]; - [coercer addCoercion:[[[JNFHashtableCoercion alloc] init] autorelease] forNSClass:[NSDictionary class] javaClass:@"java/util/Map"]; - [coercer addCoercion:[[[JNFVectorCoercion alloc] init] autorelease] forNSClass:[NSArray class] javaClass:@"java/util/List"]; - - // convert Cocoa graph to Java graph - jHashTable = [coercer coerceNSObject:dict withEnv:env]; - -JNF_COCOA_EXIT(env); - - return jHashTable; + return newList; } diff --git a/src/java.security.jgss/share/classes/sun/security/krb5/SCDynamicStoreConfig.java b/src/java.security.jgss/share/classes/sun/security/krb5/SCDynamicStoreConfig.java index 422e9ffbe61e7..a5cefb501fe59 100644 --- a/src/java.security.jgss/share/classes/sun/security/krb5/SCDynamicStoreConfig.java +++ b/src/java.security.jgss/share/classes/sun/security/krb5/SCDynamicStoreConfig.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,14 +26,20 @@ package sun.security.krb5; import java.io.IOException; -import java.util.Collection; import java.util.Hashtable; +import java.util.Iterator; +import java.util.List; import java.util.Vector; public class SCDynamicStoreConfig { private static native void installNotificationCallback(); - private static native Hashtable getKerberosConfig(); + + /** + * Returns the dynamic store setting for kerberos in a string array. + * (realm kdc* null) null (mapping-domain mapping-realm)* + */ + private static native List getKerberosConfig(); private static boolean DEBUG = sun.security.krb5.internal.Krb5.DEBUG; static { @@ -51,49 +57,6 @@ public Boolean run() { if (isMac) installNotificationCallback(); } - private static Vector unwrapHost( - Collection> c) { - Vector vector = new Vector(); - for (Hashtable m : c) { - vector.add(m.get("host")); - } - return vector; - } - - /** - * convertRealmConfigs: Maps the Object graph that we get from JNI to the - * object graph that Config expects. Also the items inside the kdc array - * are wrapped inside Hashtables - */ - @SuppressWarnings("unchecked") - private static Hashtable - convertRealmConfigs(Hashtable configs) { - Hashtable realmsTable = new Hashtable(); - - for (String realm : configs.keySet()) { - // get the kdc - Hashtable> map = - (Hashtable>) configs.get(realm); - Hashtable> realmMap = - new Hashtable>(); - - // put the kdc into the realmMap - Collection> kdc = - (Collection>) map.get("kdc"); - if (kdc != null) realmMap.put("kdc", unwrapHost(kdc)); - - // put the admin server into the realmMap - Collection> kadmin = - (Collection>) map.get("kadmin"); - if (kadmin != null) realmMap.put("admin_server", unwrapHost(kadmin)); - - // add the full entry to the realmTable - realmsTable.put(realm, realmMap); - } - - return realmsTable; - } - /** * Calls down to JNI to get the raw Kerberos Config and maps the object * graph to the one that Kerberos Config in Java expects @@ -102,45 +65,64 @@ private static Vector unwrapHost( * @throws IOException */ public static Hashtable getConfig() throws IOException { - Hashtable stanzaTable = getKerberosConfig(); - if (stanzaTable == null) { + List list = getKerberosConfig(); + if (list == null) { throw new IOException( "Could not load configuration from SCDynamicStore"); } - if (DEBUG) System.out.println("Raw map from JNI: " + stanzaTable); - return convertNativeConfig(stanzaTable); - } + if (DEBUG) System.out.println("Raw map from JNI: " + list); - @SuppressWarnings("unchecked") - private static Hashtable convertNativeConfig( - Hashtable stanzaTable) throws IOException { - // convert SCDynamicStore realm structure to Java realm structure - Hashtable realms = - (Hashtable) stanzaTable.get("realms"); - if (realms == null || realms.isEmpty()) { - throw new IOException( - "SCDynamicStore contains an empty Kerberos setting"); - } - stanzaTable.remove("realms"); - Hashtable realmsTable = convertRealmConfigs(realms); - stanzaTable.put("realms", realmsTable); - WrapAllStringInVector(stanzaTable); - if (DEBUG) System.out.println("stanzaTable : " + stanzaTable); - return stanzaTable; - } + Hashtable v = new Hashtable<>(); + Hashtable realms = new Hashtable<>(); + Iterator iterator = list.iterator(); + String defaultRealm = null; - @SuppressWarnings("unchecked") - private static void WrapAllStringInVector( - Hashtable stanzaTable) { - for (String s: stanzaTable.keySet()) { - Object v = stanzaTable.get(s); - if (v instanceof Hashtable) { - WrapAllStringInVector((Hashtable)v); - } else if (v instanceof String) { - Vector vec = new Vector<>(); - vec.add((String)v); - stanzaTable.put(s, vec); + while (true) { + String nextRealm = iterator.next(); + if (nextRealm == null) { + break; + } + if (defaultRealm == null) { + defaultRealm = nextRealm; + Hashtable dr = new Hashtable<>(); + dr.put("default_realm", v1(defaultRealm)); + v.put("libdefaults", dr); + } + Vector kdcs = new Vector<>(); + while (true) { + String nextKdc = iterator.next(); + if (nextKdc == null) { + break; + } + kdcs.add(nextKdc); } + if (!kdcs.isEmpty()) { + Hashtable ri = new Hashtable<>(); + ri.put("kdc", kdcs); + realms.put(nextRealm, ri); + } + } + if (!realms.isEmpty()) { + v.put("realms", realms); + } + Hashtable mapping = new Hashtable<>(); + while (true) { + if (!iterator.hasNext()) { + break; + } + mapping.put(iterator.next(), v1(iterator.next())); } + if (!mapping.isEmpty()) { + v.put("domain_realm", mapping); + } + return v; + } + + // Make a single value Vector. Config's stanzaTable always + // use Vector as end values. + private static Vector v1(String s) { + Vector out = new Vector<>(); + out.add(s); + return out; } } diff --git a/test/jdk/java/awt/Window/MainKeyWindowTest/libTestMainKeyWindow.c b/test/jdk/java/awt/Window/MainKeyWindowTest/libTestMainKeyWindow.m similarity index 100% rename from test/jdk/java/awt/Window/MainKeyWindowTest/libTestMainKeyWindow.c rename to test/jdk/java/awt/Window/MainKeyWindowTest/libTestMainKeyWindow.m diff --git a/test/jdk/sun/security/krb5/config/SCDynamicConfigTest.java b/test/jdk/sun/security/krb5/config/SCDynamicConfigTest.java deleted file mode 100644 index c8dd06427b97c..0000000000000 --- a/test/jdk/sun/security/krb5/config/SCDynamicConfigTest.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @bug 7184246 - * @summary Simplify Config.get() of krb5 - * @modules java.security.jgss/sun.security.krb5:+open - */ -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.Hashtable; -import java.util.Vector; -import sun.security.krb5.Config; -import sun.security.krb5.SCDynamicStoreConfig; - -public class SCDynamicConfigTest { - - static Vector>hosts() { - Vector > result = new Vector<>(); - Hashtable pair = new Hashtable<>(); - pair.put("host", "127.0.0.1"); - result.add(pair); - pair = new Hashtable<>(); - pair.put("host", "127.0.0.2"); - result.add(pair); - return result; - } - - public static void main(String[] args) throws Exception { - // Reconstruct a typical SCDynamicConfig.getKerberosConfig() output - Hashtable conf = new Hashtable<>(); - - Hashtable libdefaults = new Hashtable<>(); - libdefaults.put("default_realm", "REALM.COM"); - conf.put("libdefaults", libdefaults); - - Hashtable realms = new Hashtable<>(); - Hashtable thisRealm = new Hashtable<>(); - realms.put("REALM.COM", thisRealm); - thisRealm.put("kpasswd", hosts()); - thisRealm.put("kadmin", hosts()); - thisRealm.put("kdc", hosts()); - conf.put("realms", realms); - - Hashtable domain_realm = new Hashtable<>(); - domain_realm.put(".realm.com", "REALM.COM"); - domain_realm.put("realm.com", "REALM.COM"); - conf.put("domain_realm", domain_realm); - - System.out.println("SCDynamicConfig:\n"); - System.out.println(conf); - - // Simulate SCDynamicConfig.getConfig() output - Method m = SCDynamicStoreConfig.class.getDeclaredMethod( - "convertNativeConfig", Hashtable.class); - m.setAccessible(true); - conf = (Hashtable)m.invoke(null, conf); - - System.out.println("\nkrb5.conf:\n"); - System.out.println(conf); - - // Feed it into a Config object - System.setProperty("java.security.krb5.conf", "not-a-file"); - Config cf = Config.getInstance(); - Field f = Config.class.getDeclaredField("stanzaTable"); - f.setAccessible(true); - f.set(cf, conf); - - System.out.println("\nConfig:\n"); - System.out.println(cf); - - if (!cf.getDefaultRealm().equals("REALM.COM")) { - throw new Exception(); - } - if (!cf.getKDCList("REALM.COM").equals("127.0.0.1 127.0.0.2")) { - throw new Exception(); - } - if (!cf.get("domain_realm", ".realm.com").equals("REALM.COM")) { - throw new Exception(); - } - } -} diff --git a/test/jdk/sun/security/krb5/config/native/TestDynamicStore.java b/test/jdk/sun/security/krb5/config/native/TestDynamicStore.java new file mode 100644 index 0000000000000..19500899878ce --- /dev/null +++ b/test/jdk/sun/security/krb5/config/native/TestDynamicStore.java @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8257860 + * @summary SCDynamicStoreConfig works + * @modules java.security.jgss/sun.security.krb5 + * @library /test/lib + * @run main/manual/native TestDynamicStore + * @requires (os.family == "mac") + */ + +import jdk.test.lib.Asserts; +import sun.security.krb5.Config; + +public class TestDynamicStore { + + native static int actionInternal(char what, char whom); + + // what: 'a' for add, 'r' for remove + // whom: 'a' for all, 'r' for realm, 'm' for mapping + static int action(char what, char whom) throws Exception { + int out = actionInternal(what, whom); + System.out.println("Run " + what + whom + " " + out); + Thread.sleep(1000); // wait for callback called + return out; + } + + public static void main(String[] args) throws Exception { + + System.loadLibrary("TestDynamicStore"); + + Config cfg = Config.getInstance(); + if (cfg.exists("libdefaults") || cfg.exists("realms")) { + System.out.println("Already have krb5 config. Will not touch"); + return; + } + + try { + System.out.println("Fill in dynamic store"); + action('a', 'a'); + Asserts.assertTrue(Config.getInstance().get("libdefaults", "default_realm").equals("A.COM")); + Asserts.assertTrue(Config.getInstance().exists("domain_realm")); + + System.out.println("Remove mapping"); + action('r', 'm'); + Asserts.assertTrue(!Config.getInstance().exists("domain_realm")); + + System.out.println("Re-add mapping"); + action('a', 'm'); + Asserts.assertTrue(Config.getInstance().exists("domain_realm")); + + System.out.println("Remove realm info"); + action('r', 'r'); + // Realm info is not watched, so no change detected + Asserts.assertTrue(Config.getInstance().get("libdefaults", "default_realm").equals("A.COM")); + + System.out.println("Remove mapping"); + action('r', 'm'); + // But mapping is watched, so realm info is not re-read + Asserts.assertTrue(Config.getInstance().get("libdefaults", "default_realm").equals("B.COM")); + } finally { + System.out.println("Remove everything"); + action('r', 'a'); + Asserts.assertTrue(!Config.getInstance().exists("libdefault")); + } + } +} diff --git a/test/jdk/sun/security/krb5/config/native/libTestDynamicStore.m b/test/jdk/sun/security/krb5/config/native/libTestDynamicStore.m new file mode 100644 index 0000000000000..30ed2eb113fcc --- /dev/null +++ b/test/jdk/sun/security/krb5/config/native/libTestDynamicStore.m @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +#import +#import +#import + +#define KERBEROS_DEFAULT_REALMS @"Kerberos-Default-Realms" +#define KERBEROS_DEFAULT_REALM_MAPPINGS @"Kerberos-Domain-Realm-Mappings" +#define KERBEROS_REALM_INFO @"Kerberos:%@" + +int removeAll(SCDynamicStoreRef store) { + fprintf(stderr, "%d\n", SCDynamicStoreRemoveValue(store, (CFStringRef) KERBEROS_DEFAULT_REALMS)); + fprintf(stderr, "%d\n", SCDynamicStoreRemoveValue(store, (CFStringRef) [NSString stringWithFormat:KERBEROS_REALM_INFO, @"A.COM"])); + fprintf(stderr, "%d\n", SCDynamicStoreRemoveValue(store, (CFStringRef) [NSString stringWithFormat:KERBEROS_REALM_INFO, @"B.COM"])); + fprintf(stderr, "%d\n", SCDynamicStoreRemoveValue(store, (CFStringRef) KERBEROS_DEFAULT_REALM_MAPPINGS)); + return 1; +} + +int removeRealm(SCDynamicStoreRef store) { + fprintf(stderr, "%d\n", SCDynamicStoreRemoveValue(store, (CFStringRef) [NSString stringWithFormat:KERBEROS_REALM_INFO, @"A.COM"])); + return 1; +} + +int removeMapping(SCDynamicStoreRef store) { + fprintf(stderr, "%d\n", SCDynamicStoreRemoveValue(store, (CFStringRef) KERBEROS_DEFAULT_REALM_MAPPINGS)); + return 1; +} + +int addMapping(SCDynamicStoreRef store) { + NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys: + @"a", @"A", + @"b", @"B", + @"c", @"C", + @"d", @"D", + nil]; + fprintf(stderr, "%d\n", SCDynamicStoreSetValue(store, (CFStringRef) KERBEROS_DEFAULT_REALM_MAPPINGS, [NSArray arrayWithObjects: dict, nil])); + return 1; +} + +int addAll(SCDynamicStoreRef store) { + NSArray *keys = [NSArray arrayWithObjects:@"A.COM", @"B.COM", nil]; + fprintf(stderr, "%d\n", SCDynamicStoreSetValue(store, (CFStringRef) KERBEROS_DEFAULT_REALMS, keys)); + + NSDictionary *k1 = [NSDictionary dictionaryWithObjectsAndKeys: + @"kdc1.a.com", @"host", nil]; + NSDictionary *k2 = [NSDictionary dictionaryWithObjectsAndKeys: + @"kdc2.a.com", @"host", nil]; + NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys: + [NSArray arrayWithObjects: k1, k2, nil], @"kdc", + nil]; + fprintf(stderr, "%d\n", SCDynamicStoreSetValue(store, (CFStringRef) [NSString stringWithFormat:KERBEROS_REALM_INFO, @"A.COM"], dict)); + + k1 = [NSDictionary dictionaryWithObjectsAndKeys: + @"kdc1.b.com", @"host", nil]; + k2 = [NSDictionary dictionaryWithObjectsAndKeys: + @"kdc2.b.com", @"host", nil]; + dict = [NSDictionary dictionaryWithObjectsAndKeys: + [NSArray arrayWithObjects: k1, k2, nil], @"kdc", + nil]; + fprintf(stderr, "%d\n", SCDynamicStoreSetValue(store, (CFStringRef) [NSString stringWithFormat:KERBEROS_REALM_INFO, @"B.COM"], dict)); + addMapping(store); + return 1; +} + +JNIEXPORT jint JNICALL Java_TestDynamicStore_actionInternal(JNIEnv *env, jclass clazz, jchar what, jchar whom) { + SCDynamicStoreRef store = SCDynamicStoreCreate(NULL, CFSTR("java-kerberos"), NULL, NULL); + fprintf(stderr, ">>> action: %c %c\n", what, whom); + @try { + switch (what) { + case 'a': + switch (whom) { + case 'a': return addAll(store); + case 'm': return addMapping(store); + } + break; + case 'r': + switch (whom) { + case 'a': return removeAll(store); + case 'r': return removeRealm(store); + case 'm': return removeMapping(store); + } + break; + } + return 0; + } @finally { + CFRelease(store); + } +} From f025bc1d5d81532a3bdb87665537de4aaf15b7ea Mon Sep 17 00:00:00 2001 From: Vladimir Kozlov Date: Wed, 3 Feb 2021 18:05:52 +0000 Subject: [PATCH 48/77] 8260301: misc gc/g1/unloading tests fails with "RuntimeException: Method could not be enqueued for compilation at level N" Reviewed-by: dlong, iignatyev --- src/hotspot/share/prims/whitebox.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/hotspot/share/prims/whitebox.cpp b/src/hotspot/share/prims/whitebox.cpp index 04cde722febbd..ab4bff412d7ba 100644 --- a/src/hotspot/share/prims/whitebox.cpp +++ b/src/hotspot/share/prims/whitebox.cpp @@ -992,6 +992,15 @@ bool WhiteBox::compile_method(Method* method, int comp_level, int bci, Thread* T if ((!is_blocking && is_queued) || nm != NULL) { return true; } + // Check code again because compilation may be finished before Compile_lock is acquired. + if (bci == InvocationEntryBci) { + CompiledMethod* code = mh->code(); + if (code != NULL && code->as_nmethod_or_null() != NULL) { + return true; + } + } else if (mh->lookup_osr_nmethod_for(bci, comp_level, false) != NULL) { + return true; + } tty->print("WB error: failed to %s compile at level %d method ", is_blocking ? "blocking" : "", comp_level); mh->print_short_name(tty); tty->cr(); From 2be60e37e0e433141b2e3d3e32f8e638a4888e3a Mon Sep 17 00:00:00 2001 From: Phil Race Date: Wed, 3 Feb 2021 21:58:02 +0000 Subject: [PATCH 49/77] 8257988: Remove JNF dependency from libsaproc/MacosxDebuggerLocal.m Reviewed-by: ihse, cjplummer --- make/modules/jdk.hotspot.agent/Lib.gmk | 2 +- .../native/libsaproc/MacosxDebuggerLocal.m | 51 +++++++++++++++---- 2 files changed, 43 insertions(+), 10 deletions(-) diff --git a/make/modules/jdk.hotspot.agent/Lib.gmk b/make/modules/jdk.hotspot.agent/Lib.gmk index 871dffeeb9e05..4c4f88792de8b 100644 --- a/make/modules/jdk.hotspot.agent/Lib.gmk +++ b/make/modules/jdk.hotspot.agent/Lib.gmk @@ -69,7 +69,7 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBSA, \ LIBS := $(LIBCXX), \ LIBS_unix := -ljava, \ LIBS_linux := $(LIBDL), \ - LIBS_macosx := -framework Foundation -framework JavaNativeFoundation \ + LIBS_macosx := -framework Foundation \ -framework JavaRuntimeSupport -framework Security -framework CoreFoundation, \ LIBS_windows := dbgeng.lib $(WIN_JAVA_LIB), \ )) diff --git a/src/jdk.hotspot.agent/macosx/native/libsaproc/MacosxDebuggerLocal.m b/src/jdk.hotspot.agent/macosx/native/libsaproc/MacosxDebuggerLocal.m index cfbf7f9b787d4..0099a83ebd7b8 100644 --- a/src/jdk.hotspot.agent/macosx/native/libsaproc/MacosxDebuggerLocal.m +++ b/src/jdk.hotspot.agent/macosx/native/libsaproc/MacosxDebuggerLocal.m @@ -24,8 +24,6 @@ #include #import -#import -#import #include @@ -260,6 +258,39 @@ jlong lookupByNameIncore( return addr; } +/* Create a pool and initiate a try block to catch any exception */ +#define JNI_COCOA_ENTER(env) \ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; \ + @try { + +/* Don't allow NSExceptions to escape to Java. + * If there is a Java exception that has been thrown that should escape. + * And ensure we drain the auto-release pool. + */ +#define JNI_COCOA_EXIT(env) \ + } \ + @catch (NSException *e) { \ + NSLog(@"%@", [e callStackSymbols]); \ + } \ + @finally { \ + [pool drain]; \ + }; + +static NSString* JavaStringToNSString(JNIEnv *env, jstring jstr) { + + if (jstr == NULL) { + return NULL; + } + jsize len = (*env)->GetStringLength(env, jstr); + const jchar *chars = (*env)->GetStringChars(env, jstr, NULL); + if (chars == NULL) { + return NULL; + } + NSString *result = [NSString stringWithCharacters:(UniChar *)chars length:len]; + (*env)->ReleaseStringChars(env, jstr, chars); + return result; +} + /* * Class: sun_jvm_hotspot_debugger_bsd_BsdDebuggerLocal * Method: lookupByName0 @@ -277,8 +308,9 @@ jlong lookupByNameIncore( jlong address = 0; -JNF_COCOA_ENTER(env); - NSString *symbolNameString = JNFJavaToNSString(env, symbolName); + JNI_COCOA_ENTER(env); + + NSString *symbolNameString = JavaStringToNSString(env, symbolName); print_debug("lookupInProcess called for %s\n", [symbolNameString UTF8String]); @@ -289,7 +321,7 @@ jlong lookupByNameIncore( } print_debug("address of symbol %s = %llx\n", [symbolNameString UTF8String], address); -JNF_COCOA_EXIT(env); + JNI_COCOA_EXIT(env); return address; } @@ -812,7 +844,7 @@ static bool wait_for_exception() { { print_debug("attach0 called for jpid=%d\n", (int)jpid); -JNF_COCOA_ENTER(env); + JNI_COCOA_ENTER(env); kern_return_t result; task_t gTask = 0; @@ -926,7 +958,7 @@ static bool wait_for_exception() { THROW_NEW_DEBUGGER_EXCEPTION("Can't attach symbolicator to the process"); } -JNF_COCOA_EXIT(env); + JNI_COCOA_EXIT(env); } /** For core file, @@ -1020,7 +1052,8 @@ static void detach_cleanup(task_t gTask, JNIEnv *env, jobject this_obj, bool thr Prelease(ph); return; } -JNF_COCOA_ENTER(env); + + JNI_COCOA_ENTER(env); task_t gTask = getTask(env, this_obj); kern_return_t k_res = 0; @@ -1071,5 +1104,5 @@ static void detach_cleanup(task_t gTask, JNIEnv *env, jobject this_obj, bool thr detach_cleanup(gTask, env, this_obj, false); -JNF_COCOA_EXIT(env); + JNI_COCOA_EXIT(env); } From f279ff9d2f82cec9a83390d9f09b1fec245722d5 Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Wed, 3 Feb 2021 23:13:12 +0000 Subject: [PATCH 50/77] 8261010: Delete the Netbeans "default" license header Reviewed-by: iris, psadhukhan --- .../unix/classes/sun/java2d/xr/XRGraphicsConfig.java | 5 ----- test/micro/org/openjdk/bench/java/math/BigIntegers.java | 4 ---- test/micro/org/openjdk/bench/vm/compiler/WriteBarrier.java | 5 ----- 3 files changed, 14 deletions(-) diff --git a/src/java.desktop/unix/classes/sun/java2d/xr/XRGraphicsConfig.java b/src/java.desktop/unix/classes/sun/java2d/xr/XRGraphicsConfig.java index 1f53e77624071..680e634cce85a 100644 --- a/src/java.desktop/unix/classes/sun/java2d/xr/XRGraphicsConfig.java +++ b/src/java.desktop/unix/classes/sun/java2d/xr/XRGraphicsConfig.java @@ -23,11 +23,6 @@ * questions. */ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ - package sun.java2d.xr; import java.awt.Transparency; diff --git a/test/micro/org/openjdk/bench/java/math/BigIntegers.java b/test/micro/org/openjdk/bench/java/math/BigIntegers.java index d3a20a3ee5e26..e2d563d830655 100644 --- a/test/micro/org/openjdk/bench/java/math/BigIntegers.java +++ b/test/micro/org/openjdk/bench/java/math/BigIntegers.java @@ -20,10 +20,6 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ package org.openjdk.bench.java.math; import org.openjdk.jmh.annotations.Benchmark; diff --git a/test/micro/org/openjdk/bench/vm/compiler/WriteBarrier.java b/test/micro/org/openjdk/bench/vm/compiler/WriteBarrier.java index 98b4c33afeb04..f464ce8f5c016 100644 --- a/test/micro/org/openjdk/bench/vm/compiler/WriteBarrier.java +++ b/test/micro/org/openjdk/bench/vm/compiler/WriteBarrier.java @@ -20,11 +20,6 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ - package org.openjdk.bench.vm.compiler; import org.openjdk.jmh.annotations.Benchmark; From e2516e41de72fa7b09fcf9d99e492ec7716ec4be Mon Sep 17 00:00:00 2001 From: Jie Fu Date: Thu, 4 Feb 2021 00:05:40 +0000 Subject: [PATCH 51/77] 8261028: ZGC: SIGFPE when MaxVirtMemFraction=0 Reviewed-by: stefank, pliden --- src/hotspot/share/gc/shared/gc_globals.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/hotspot/share/gc/shared/gc_globals.hpp b/src/hotspot/share/gc/shared/gc_globals.hpp index 402409161a8ea..d557c2218e560 100644 --- a/src/hotspot/share/gc/shared/gc_globals.hpp +++ b/src/hotspot/share/gc/shared/gc_globals.hpp @@ -344,6 +344,7 @@ develop(uintx, MaxVirtMemFraction, 2, \ "Maximum fraction (1/n) of virtual memory used for ergonomically "\ "determining maximum heap size") \ + range(1, max_uintx) \ \ product(bool, UseAdaptiveSizePolicy, true, \ "Use adaptive generation sizing policies") \ From 8760688d213865eaf1bd675056eb809cdae67048 Mon Sep 17 00:00:00 2001 From: Phil Race Date: Thu, 4 Feb 2021 01:36:19 +0000 Subject: [PATCH 52/77] 8260616: Removing remaining JNF dependencies in the java.desktop module Reviewed-by: gziemski, ihse, serb --- make/modules/java.desktop/Lib.gmk | 2 - .../java.desktop/lib/Awt2dLibraries.gmk | 6 +- make/test/JtregNativeJdk.gmk | 2 +- .../macosx/native/libawt_lwawt/awt/AWTEvent.m | 1 - .../libawt_lwawt/awt/AWTSurfaceLayers.m | 1 - .../macosx/native/libawt_lwawt/awt/AWTView.m | 40 +++---- .../native/libawt_lwawt/awt/AWTWindow.m | 5 +- .../libawt_lwawt/awt/ApplicationDelegate.m | 20 ++-- .../native/libawt_lwawt/awt/CClipboard.m | 3 +- .../native/libawt_lwawt/awt/CCursorManager.m | 3 +- .../native/libawt_lwawt/awt/CDataTransferer.m | 9 +- .../native/libawt_lwawt/awt/CDesktopPeer.m | 5 +- .../native/libawt_lwawt/awt/CDragSource.m | 15 ++- .../libawt_lwawt/awt/CDragSourceContextPeer.m | 1 - .../native/libawt_lwawt/awt/CDropTarget.m | 1 - .../libawt_lwawt/awt/CDropTargetContextPeer.m | 2 - .../libawt_lwawt/awt/CFRetainedResource.m | 4 +- .../native/libawt_lwawt/awt/CFileDialog.h | 1 - .../native/libawt_lwawt/awt/CFileDialog.m | 17 ++- .../native/libawt_lwawt/awt/CGraphicsDevice.m | 2 - .../native/libawt_lwawt/awt/CGraphicsEnv.m | 27 ++--- .../macosx/native/libawt_lwawt/awt/CImage.m | 7 +- .../native/libawt_lwawt/awt/CInputMethod.m | 5 +- .../macosx/native/libawt_lwawt/awt/CMenu.m | 3 +- .../macosx/native/libawt_lwawt/awt/CMenuBar.m | 1 - .../native/libawt_lwawt/awt/CMenuComponent.m | 1 - .../native/libawt_lwawt/awt/CMenuItem.m | 5 +- .../native/libawt_lwawt/awt/CPopupMenu.m | 1 - .../native/libawt_lwawt/awt/CPrinterJob.m | 15 ++- .../macosx/native/libawt_lwawt/awt/CRobot.m | 1 - .../native/libawt_lwawt/awt/CSystemColors.m | 1 - .../native/libawt_lwawt/awt/CTextPipe.m | 19 +-- .../native/libawt_lwawt/awt/CTrayIcon.m | 7 +- .../macosx/native/libawt_lwawt/awt/CWrapper.m | 3 +- .../native/libawt_lwawt/awt/GeomUtilities.m | 6 +- .../libawt_lwawt/awt/ImageSurfaceData.m | 1 - .../awt/JavaAccessibilityAction.m | 4 +- .../awt/JavaAccessibilityUtilities.h | 2 +- .../awt/JavaAccessibilityUtilities.m | 26 ++--- .../awt/JavaComponentAccessibility.m | 87 +++++++++----- .../libawt_lwawt/awt/JavaTextAccessibility.m | 44 +++---- .../native/libawt_lwawt/awt/LWCToolkit.m | 12 +- .../native/libawt_lwawt/awt/PrintModel.m | 6 +- .../libawt_lwawt/awt/PrinterSurfaceData.m | 2 - .../native/libawt_lwawt/awt/PrinterView.m | 12 +- .../native/libawt_lwawt/awt/QuartzRenderer.m | 1 - .../libawt_lwawt/awt/QuartzSurfaceData.m | 2 - .../awt/a11y/CommonTextAccessibility.m | 10 +- .../macosx/native/libawt_lwawt/font/AWTFont.m | 12 +- .../native/libawt_lwawt/font/AWTStrike.m | 1 - .../libawt_lwawt/font/CCharToGlyphMapper.m | 2 - .../native/libawt_lwawt/font/CGGlyphImages.m | 2 +- .../java2d/opengl/CGLGraphicsConfig.m | 3 +- .../libawt_lwawt/java2d/opengl/CGLLayer.h | 2 - .../java2d/opengl/CGLSurfaceData.m | 2 +- .../macosx/native/libosx/CFileManager.m | 39 +++---- .../macosx/native/libosxapp/JNIUtilities.h | 12 +- .../macosx/native/libosxapp/JNIUtilities.m | 108 ++++++++++++++++++ .../native/libosxapp/NSApplicationAWT.h | 8 +- .../native/libosxapp/NSApplicationAWT.m | 9 +- .../native/libosxapp/PropertiesUtilities.h | 4 - .../native/libosxapp/PropertiesUtilities.m | 4 +- .../macosx/native/libosxapp/ThreadUtilities.h | 4 +- .../macosx/native/libosxapp/ThreadUtilities.m | 43 ++++++- .../macosx/native/libosxui/AquaFileView.m | 9 +- .../macosx/native/libosxui/AquaLookAndFeel.m | 3 - .../native/libosxui/AquaNativeResources.m | 1 - .../native/libosxui/JRSUIConstantSync.m | 2 +- .../macosx/native/libosxui/JRSUIController.m | 2 +- .../macosx/native/libosxui/JRSUIFocus.m | 2 +- .../macosx/native/libosxui/ScreenMenu.h | 1 - .../macosx/native/libosxui/ScreenMenu.m | 25 ++-- .../native/libsplashscreen/splashscreen_sys.m | 13 +-- .../MainKeyWindowTest/libTestMainKeyWindow.m | 54 +++++++-- 74 files changed, 481 insertions(+), 337 deletions(-) create mode 100644 src/java.desktop/macosx/native/libosxapp/JNIUtilities.m diff --git a/make/modules/java.desktop/Lib.gmk b/make/modules/java.desktop/Lib.gmk index 54b96f56c60d2..bc0c349da6a37 100644 --- a/make/modules/java.desktop/Lib.gmk +++ b/make/modules/java.desktop/Lib.gmk @@ -101,7 +101,6 @@ ifeq ($(call isTargetOs, macosx), true) -framework Cocoa \ -framework Security \ -framework ExceptionHandling \ - -framework JavaNativeFoundation \ -framework JavaRuntimeSupport \ -framework OpenGL \ -framework IOSurface \ @@ -127,7 +126,6 @@ ifeq ($(call isTargetOs, macosx), true) -losxapp \ -framework Cocoa \ -framework ApplicationServices \ - -framework JavaNativeFoundation \ -framework JavaRuntimeSupport \ -framework SystemConfiguration \ $(JDKLIB_LIBS), \ diff --git a/make/modules/java.desktop/lib/Awt2dLibraries.gmk b/make/modules/java.desktop/lib/Awt2dLibraries.gmk index d1e6cc298163d..bc862c45bf493 100644 --- a/make/modules/java.desktop/lib/Awt2dLibraries.gmk +++ b/make/modules/java.desktop/lib/Awt2dLibraries.gmk @@ -160,7 +160,6 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBAWT, \ LIBS_macosx := -lmlib_image \ -framework Cocoa \ -framework OpenGL \ - -framework JavaNativeFoundation \ -framework JavaRuntimeSupport \ -framework ApplicationServices \ -framework AudioToolbox, \ @@ -767,8 +766,7 @@ ifeq ($(ENABLE_HEADLESS_ONLY), false) -framework ApplicationServices \ -framework Foundation \ -framework Security \ - -framework Cocoa \ - -framework JavaNativeFoundation + -framework Cocoa else ifeq ($(call isTargetOs, windows), true) LIBSPLASHSCREEN_LIBS += kernel32.lib user32.lib gdi32.lib delayimp.lib $(WIN_JAVA_LIB) jvm.lib else @@ -866,7 +864,6 @@ ifeq ($(call isTargetOs, macosx), true) -framework Cocoa \ -framework Security \ -framework ExceptionHandling \ - -framework JavaNativeFoundation \ -framework JavaRuntimeSupport \ -framework OpenGL \ -framework QuartzCore -ljava, \ @@ -904,7 +901,6 @@ ifeq ($(call isTargetOs, macosx), true) -framework Cocoa \ -framework Carbon \ -framework ApplicationServices \ - -framework JavaNativeFoundation \ -framework JavaRuntimeSupport \ -ljava -ljvm, \ )) diff --git a/make/test/JtregNativeJdk.gmk b/make/test/JtregNativeJdk.gmk index 8560ef060a251..3342710bcd28b 100644 --- a/make/test/JtregNativeJdk.gmk +++ b/make/test/JtregNativeJdk.gmk @@ -78,7 +78,7 @@ endif ifeq ($(call isTargetOs, macosx), true) BUILD_JDK_JTREG_EXCLUDE += exelauncher.c BUILD_JDK_JTREG_LIBRARIES_LIBS_libTestMainKeyWindow := \ - -framework Cocoa -framework JavaNativeFoundation + -framework Cocoa BUILD_JDK_JTREG_EXECUTABLES_LIBS_exeJniInvocationTest := -ljli BUILD_JDK_JTREG_LIBRARIES_LIBS_libTestDynamicStore := \ -framework Cocoa -framework SystemConfiguration diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTEvent.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTEvent.m index 716c86527f0ca..8333ff489720f 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTEvent.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTEvent.m @@ -29,7 +29,6 @@ #import "JNIUtilities.h" -#import #import #import diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTSurfaceLayers.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTSurfaceLayers.m index c397dbf1f38fd..1a5dcb03b9962 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTSurfaceLayers.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTSurfaceLayers.m @@ -28,7 +28,6 @@ #import "LWCToolkit.h" #import "JNIUtilities.h" -#import #import @implementation AWTSurfaceLayers diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTView.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTView.m index eb5dae3c272d3..3afe59f697bc0 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTView.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTView.m @@ -35,7 +35,6 @@ #import "JNIUtilities.h" #import -#import // keyboard layout static NSString *kbdLayout; @@ -135,7 +134,7 @@ - (void) viewDidMoveToWindow { [AWTToolkit eventCountPlusPlus]; - [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^() { + [ThreadUtilities performOnMainThreadWaiting:NO block:^() { [[self window] makeFirstResponder: self]; }]; if ([self window] != NULL) { @@ -461,8 +460,8 @@ -(void) deliverJavaKeyEventHelper: (NSEvent *) event { jstring characters = NULL; jstring charactersIgnoringModifiers = NULL; if ([event type] != NSFlagsChanged) { - characters = JNFNSToJavaString(env, [event characters]); - charactersIgnoringModifiers = JNFNSToJavaString(env, [event charactersIgnoringModifiers]); + characters = NSStringToJavaString(env, [event characters]); + charactersIgnoringModifiers = NSStringToJavaString(env, [event charactersIgnoringModifiers]); } DECLARE_CLASS(jc_NSEvent, "sun/lwawt/macosx/NSEvent"); @@ -575,10 +574,7 @@ - (jobject)awtComponent:(JNIEnv*)env DECLARE_FIELD_RETURN(jf_Peer, jc_CPlatformView, "peer", "Lsun/lwawt/LWWindowPeer;", NULL); if ((env == NULL) || (m_cPlatformView == NULL)) { NSLog(@"Apple AWT : Error AWTView:awtComponent given bad parameters."); - if (env != NULL) - { - JNFDumpJavaStack(env); - } + NSLog(@"%@",[NSThread callStackSymbols]); return NULL; } @@ -592,7 +588,7 @@ - (jobject)awtComponent:(JNIEnv*)env DECLARE_FIELD_RETURN(jf_Target, jc_LWWindowPeer, "target", "Ljava/awt/Component;", NULL); if (peer == NULL) { NSLog(@"Apple AWT : Error AWTView:awtComponent got null peer from CPlatformView"); - JNFDumpJavaStack(env); + NSLog(@"%@",[NSThread callStackSymbols]); return NULL; } jobject comp = (*env)->GetObjectField(env, peer, jf_Target); @@ -989,8 +985,8 @@ - (void) insertText:(id)aString replacementRange:(NSRange)replacementRange } DECLARE_METHOD(jm_insertText, jc_CInputMethod, "insertText", "(Ljava/lang/String;)V"); - jstring insertedText = JNFNSToJavaString(env, useString); - (*env)->CallVoidMethod(env, fInputMethodLOCKABLE, jm_insertText, insertedText); // AWT_THREADING Safe (AWTRunLoopMode) + jstring insertedText = NSStringToJavaString(env, useString); + (*env)->CallVoidMethod(env, fInputMethodLOCKABLE, jm_insertText, insertedText); CHECK_EXCEPTION(); (*env)->DeleteLocalRef(env, insertedText); @@ -1055,8 +1051,8 @@ - (void) setMarkedText:(id)aString selectedRange:(NSRange)selectionRange replace // NSInputContext already did the analysis of the TSM event and created attributes indicating // the underlining and color that should be done to the string. We need to look at the underline // style and color to determine what kind of Java hilighting needs to be done. - jstring inProcessText = JNFNSToJavaString(env, incomingString); - (*env)->CallVoidMethod(env, fInputMethodLOCKABLE, jm_startIMUpdate, inProcessText); // AWT_THREADING Safe (AWTRunLoopMode) + jstring inProcessText = NSStringToJavaString(env, incomingString); + (*env)->CallVoidMethod(env, fInputMethodLOCKABLE, jm_startIMUpdate, inProcessText); CHECK_EXCEPTION(); (*env)->DeleteLocalRef(env, inProcessText); @@ -1081,7 +1077,7 @@ - (void) setMarkedText:(id)aString selectedRange:(NSRange)selectionRange replace isGray = !([underlineColorObj isEqual:[NSColor blackColor]]); (*env)->CallVoidMethod(env, fInputMethodLOCKABLE, jm_addAttribute, isThickUnderline, - isGray, effectiveRange.location, effectiveRange.length); // AWT_THREADING Safe (AWTRunLoopMode) + isGray, effectiveRange.location, effectiveRange.length); CHECK_EXCEPTION(); } } @@ -1096,7 +1092,7 @@ - (void) setMarkedText:(id)aString selectedRange:(NSRange)selectionRange replace } (*env)->CallVoidMethod(env, fInputMethodLOCKABLE, jm_dispatchText, - selectionRange.location, selectionRange.length, JNI_FALSE); // AWT_THREADING Safe (AWTRunLoopMode) + selectionRange.location, selectionRange.length, JNI_FALSE); CHECK_EXCEPTION(); // If the marked text is being cleared (zero-length string) don't handle the key event. if ([incomingString length] == 0) { @@ -1118,7 +1114,7 @@ - (void) unmarkText JNIEnv *env = [ThreadUtilities getJNIEnv]; GET_CIM_CLASS(); DECLARE_METHOD(jm_unmarkText, jc_CInputMethod, "unmarkText", "()V"); - (*env)->CallVoidMethod(env, fInputMethodLOCKABLE, jm_unmarkText); // AWT_THREADING Safe (AWTRunLoopMode) + (*env)->CallVoidMethod(env, fInputMethodLOCKABLE, jm_unmarkText); CHECK_EXCEPTION(); } @@ -1171,10 +1167,10 @@ - (NSAttributedString *) attributedSubstringForProposedRange:(NSRange)theRange a JNIEnv *env = [ThreadUtilities getJNIEnv]; DECLARE_METHOD_RETURN(jm_substringFromRange, jc_CInputMethod, "attributedSubstringFromRange", "(II)Ljava/lang/String;", nil); - jobject theString = (*env)->CallObjectMethod(env, fInputMethodLOCKABLE, jm_substringFromRange, theRange.location, theRange.length); // AWT_THREADING Safe (AWTRunLoopMode) + jobject theString = (*env)->CallObjectMethod(env, fInputMethodLOCKABLE, jm_substringFromRange, theRange.location, theRange.length); CHECK_EXCEPTION_NULL_RETURN(theString, nil); - id result = [[[NSAttributedString alloc] initWithString:JNFJavaToNSString(env, theString)] autorelease]; + id result = [[[NSAttributedString alloc] initWithString:JavaStringToNSString(env, theString)] autorelease]; #ifdef IM_DEBUG NSLog(@"attributedSubstringFromRange returning \"%@\"", result); #endif // IM_DEBUG @@ -1205,7 +1201,7 @@ - (NSRange) markedRange GET_CIM_CLASS_RETURN(range); DECLARE_METHOD_RETURN(jm_markedRange, jc_CInputMethod, "markedRange", "()[I", range); - array = (*env)->CallObjectMethod(env, fInputMethodLOCKABLE, jm_markedRange); // AWT_THREADING Safe (AWTRunLoopMode) + array = (*env)->CallObjectMethod(env, fInputMethodLOCKABLE, jm_markedRange); CHECK_EXCEPTION(); if (array) { @@ -1246,7 +1242,7 @@ - (NSRange) selectedRange fprintf(stderr, "AWTView InputMethod Selector Called : [selectedRange]\n"); #endif // IM_DEBUG - array = (*env)->CallObjectMethod(env, fInputMethodLOCKABLE, jm_selectedRange); // AWT_THREADING Safe (AWTRunLoopMode) + array = (*env)->CallObjectMethod(env, fInputMethodLOCKABLE, jm_selectedRange); CHECK_EXCEPTION(); if (array) { _array = (*env)->GetIntArrayElements(env, array, &isCopy); @@ -1285,7 +1281,7 @@ - (NSRect) firstRectForCharacterRange:(NSRange)theRange actualRange:(NSRangePoin #endif // IM_DEBUG array = (*env)->CallObjectMethod(env, fInputMethodLOCKABLE, jm_firstRectForCharacterRange, - theRange.location); // AWT_THREADING Safe (AWTRunLoopMode) + theRange.location); CHECK_EXCEPTION(); _array = (*env)->GetIntArrayElements(env, array, &isCopy); @@ -1326,7 +1322,7 @@ - (NSUInteger)characterIndexForPoint:(NSPoint)thePoint #endif // IM_DEBUG jint index = (*env)->CallIntMethod(env, fInputMethodLOCKABLE, jm_characterIndexForPoint, - (jint)flippedLocation.x, (jint)flippedLocation.y); // AWT_THREADING Safe (AWTRunLoopMode) + (jint)flippedLocation.x, (jint)flippedLocation.y); CHECK_EXCEPTION(); #ifdef IM_DEBUG diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m index bc682ed7ef6bf..33fde46c3fe62 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m @@ -24,7 +24,6 @@ */ #import -#import #import "sun_lwawt_macosx_CPlatformWindow.h" #import "com_apple_eawt_event_GestureHandler.h" @@ -1444,7 +1443,7 @@ + (AWTWindow *) lastKeyWindow { NSWindow *nsWindow = OBJC(windowPtr); [nsWindow performSelectorOnMainThread:@selector(setTitle:) - withObject:JNFJavaToNSString(env, jtitle) + withObject:JavaStringToNSString(env, jtitle) waitUntilDone:NO]; JNI_COCOA_EXIT(env); @@ -1520,7 +1519,7 @@ + (AWTWindow *) lastKeyWindow { JNI_COCOA_ENTER(env); NSWindow *nsWindow = OBJC(windowPtr); - NSURL *url = (filename == NULL) ? nil : [NSURL fileURLWithPath:JNFNormalizedNSStringForPath(env, filename)]; + NSURL *url = (filename == NULL) ? nil : [NSURL fileURLWithPath:NormalizedPathNSStringFromJavaString(env, filename)]; [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ [nsWindow setRepresentedURL:url]; }]; diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/ApplicationDelegate.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/ApplicationDelegate.m index 539f04dd090be..590ed56e0c6de 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/ApplicationDelegate.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/ApplicationDelegate.m @@ -32,8 +32,6 @@ #import "com_apple_eawt__AppMenuBarHandler.h" #import "com_apple_eawt__AppMiscHandlers.h" -#import - #import "CPopupMenu.h" #import "CMenuBar.h" #import "ThreadUtilities.h" @@ -290,10 +288,10 @@ - (void)_handleOpenURLEvent:(NSAppleEventDescriptor *)openURLEvent withReplyEven //fprintf(stderr,"jm_handleOpenURL\n"); JNIEnv *env = [ThreadUtilities getJNIEnv]; - jstring jURL = JNFNSToJavaString(env, url); + jstring jURL = NSStringToJavaString(env, url); GET_APPEVENTHANDLER_CLASS(); DECLARE_STATIC_METHOD(jm_handleOpenURI, sjc_AppEventHandler, "handleOpenURI", "(Ljava/lang/String;)V"); - (*env)->CallStaticVoidMethod(env, sjc_AppEventHandler, jm_handleOpenURI, jURL); // AWT_THREADING Safe (event) + (*env)->CallStaticVoidMethod(env, sjc_AppEventHandler, jm_handleOpenURI, jURL); CHECK_EXCEPTION(); (*env)->DeleteLocalRef(env, jURL); @@ -312,11 +310,11 @@ - (jobject)_createFilePathArrayFrom:(NSArray *)filenames withEnv:(JNIEnv *)env { DECLARE_METHOD_RETURN(jm_ArrayList_ctor, sjc_ArrayList, "", "(I)V", NULL); DECLARE_METHOD_RETURN(jm_ArrayList_add, sjc_ArrayList, "add", "(Ljava/lang/Object;)Z", NULL); - jobject jFileNamesArray = (*env)->NewObject(env, sjc_ArrayList, jm_ArrayList_ctor, (jint)[filenames count]); // AWT_THREADING Safe (known object) + jobject jFileNamesArray = (*env)->NewObject(env, sjc_ArrayList, jm_ArrayList_ctor, (jint)[filenames count]); CHECK_EXCEPTION_NULL_RETURN(jFileNamesArray, NULL); for (NSString *filename in filenames) { - jstring jFileName = JNFNormalizedJavaStringForPath(env, filename); + jstring jFileName = NormalizedPathJavaStringFromNSString(env, filename); (*env)->CallVoidMethod(env, jFileNamesArray, jm_ArrayList_add, jFileName); CHECK_EXCEPTION(); } @@ -338,7 +336,7 @@ - (void)application:(NSApplication *)theApplication openFiles:(NSArray *)fileNam // if these files were opened from a Spotlight query, try to get the search text from the current AppleEvent NSAppleEventDescriptor *currentEvent = [[NSAppleEventManager sharedAppleEventManager] currentAppleEvent]; NSString *searchString = [[currentEvent paramDescriptorForKeyword:keyAESearchText] stringValue]; - jstring jSearchString = JNFNSToJavaString(env, searchString); + jstring jSearchString = NSStringToJavaString(env, searchString); // convert the file names array jobject jFileNamesArray = [self _createFilePathArrayFrom:fileNames withEnv:env]; @@ -365,7 +363,7 @@ - (NSApplicationPrintReply)application:(NSApplication *)application printFiles:( GET_APPEVENTHANDLER_CLASS_RETURN(NSPrintingCancelled); DECLARE_STATIC_METHOD_RETURN(jm_handlePrintFile, sjc_AppEventHandler, "handlePrintFiles", "(Ljava/util/List;)V", NSPrintingCancelled); - (*env)->CallStaticVoidMethod(env, sjc_AppEventHandler, jm_handlePrintFile, jFileNamesArray); // AWT_THREADING Safe (event) + (*env)->CallStaticVoidMethod(env, sjc_AppEventHandler, jm_handlePrintFile, jFileNamesArray); CHECK_EXCEPTION(); (*env)->DeleteLocalRef(env, jFileNamesArray); @@ -380,7 +378,7 @@ + (void)_notifyJava:(jint)notificationType { JNIEnv *env = [ThreadUtilities getJNIEnv]; GET_APPEVENTHANDLER_CLASS(); DECLARE_STATIC_METHOD(jm_handleNativeNotification, sjc_AppEventHandler, "handleNativeNotification", "(I)V"); - (*env)->CallStaticVoidMethod(env, sjc_AppEventHandler, jm_handleNativeNotification, notificationType); // AWT_THREADING Safe (event) + (*env)->CallStaticVoidMethod(env, sjc_AppEventHandler, jm_handleNativeNotification, notificationType); CHECK_EXCEPTION(); } @@ -624,7 +622,7 @@ + (NSImage *)_dockIconImage { [ThreadUtilities performOnMainThread:@selector(_registerForNotification:) on:[ApplicationDelegate class] withObject:[NSNumber numberWithInt:notificationType] - waitUntilDone:NO]; // AWT_THREADING Safe (non-blocking) + waitUntilDone:NO]; JNI_COCOA_EXIT(env); } @@ -714,7 +712,7 @@ + (NSImage *)_dockIconImage { { JNI_COCOA_ENTER(env); - NSString *badgeString = JNFJavaToNSString(env, badge); + NSString *badgeString = JavaStringToNSString(env, badge); [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ NSDockTile *dockTile = [NSApp dockTile]; [dockTile setBadgeLabel:badgeString]; diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/CClipboard.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/CClipboard.m index 3a6d573579c12..896e11cf568e2 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/CClipboard.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/CClipboard.m @@ -27,7 +27,6 @@ #import "ThreadUtilities.h" #import "JNIUtilities.h" #import -#import @interface CClipboard : NSObject { } @property NSInteger changeCount; @@ -99,7 +98,7 @@ - (void)checkPasteboard:(id)sender { DECLARE_METHOD(jm_lostOwnership, jc_CClipboard, "notifyLostOwnership", "()V"); @synchronized(self) { if (self.clipboardOwner) { - (*env)->CallVoidMethod(env, self.clipboardOwner, jm_lostOwnership); // AWT_THREADING Safe (event) + (*env)->CallVoidMethod(env, self.clipboardOwner, jm_lostOwnership); CHECK_EXCEPTION(); (*env)->DeleteGlobalRef(env, self.clipboardOwner); self.clipboardOwner = NULL; diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/CCursorManager.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/CCursorManager.m index e3d054296cd17..99727a3f9fd28 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/CCursorManager.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/CCursorManager.m @@ -26,7 +26,6 @@ #include "sun_lwawt_macosx_CCursorManager.h" #include -#include #include "GeomUtilities.h" #include "ThreadUtilities.h" @@ -75,7 +74,7 @@ static void setCursorOnAppKitThread(NSCursor *cursor) { { JNI_COCOA_ENTER(env); - NSString *cursorName = JNFJavaToNSString(env, name); + NSString *cursorName = JavaStringToNSString(env, name); SEL cursorSelector = (type == sun_lwawt_macosx_CCursorManager_NAMED_CURSOR) ? lookupCursorSelectorForName(cursorName) : lookupCursorSelectorForType(type); if (cursorSelector == nil) { NSString *reason = [NSString stringWithFormat:@"unimplemented built-in cursor type: %d / %@", type, cursorName]; diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/CDataTransferer.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/CDataTransferer.m index 80812bf4be44e..f0bc347197f66 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/CDataTransferer.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/CDataTransferer.m @@ -28,9 +28,6 @@ #import "JNIUtilities.h" -#import - - // ***** NOTE ***** This dictionary corresponds to the static array predefinedClipboardNames // in CDataTransferer.java. NSMutableDictionary *sStandardMappings = nil; @@ -110,7 +107,7 @@ jlong registerFormatWithPasteboard(NSString *format) { { jlong returnValue = -1; JNI_COCOA_ENTER(env); - returnValue = registerFormatWithPasteboard(JNFJavaToNSString(env, newformat)); + returnValue = registerFormatWithPasteboard(JavaStringToNSString(env, newformat)); JNI_COCOA_EXIT(env); return returnValue; } @@ -125,7 +122,7 @@ jlong registerFormatWithPasteboard(NSString *format) { { jstring returnValue = NULL; JNI_COCOA_ENTER(env); - returnValue = JNFNSToJavaString(env, formatForIndex(index)); + returnValue = NSStringToJavaString(env, formatForIndex(index)); JNI_COCOA_EXIT(env); return returnValue; } @@ -138,7 +135,7 @@ static jobjectArray CreateJavaFilenameArray(JNIEnv *env, NSArray *filenameArray) // Get the java.lang.String class object: jclass stringClazz = (*env)->FindClass(env, "java/lang/String"); CHECK_NULL_RETURN(stringClazz, nil); - jobject jfilenameArray = (*env)->NewObjectArray(env, filenameCount, stringClazz, NULL); // AWT_THREADING Safe (known object) + jobject jfilenameArray = (*env)->NewObjectArray(env, filenameCount, stringClazz, NULL); if ((*env)->ExceptionOccurred(env)) { (*env)->ExceptionDescribe(env); (*env)->ExceptionClear(env); diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/CDesktopPeer.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/CDesktopPeer.m index 63ef7e4af8f04..94d3e4efe54d4 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/CDesktopPeer.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/CDesktopPeer.m @@ -27,7 +27,6 @@ #import "JNIUtilities.h" #import #import -#import /* * Class: sun_lwawt_macosx_CDesktopPeer @@ -43,7 +42,7 @@ // I would love to use NSWorkspace here, but it's not thread safe. Why? I don't know. // So we use LaunchServices directly. - NSURL *url = [NSURL URLWithString:JNFJavaToNSString(env, uri)]; + NSURL *url = [NSURL URLWithString:JavaStringToNSString(env, uri)]; LSLaunchFlags flags = kLSLaunchDefaults; @@ -68,7 +67,7 @@ // I would love to use NSWorkspace here, but it's not thread safe. Why? I don't know. // So we use LaunchServices directly. - NSString *path = JNFNormalizedNSStringForPath(env, jpath); + NSString *path = NormalizedPathNSStringFromJavaString(env, jpath); NSURL *url = [NSURL fileURLWithPath:(NSString *)path]; diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/CDragSource.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/CDragSource.m index fc9d855e08692..fde95fc9d7fad 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/CDragSource.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/CDragSource.m @@ -28,7 +28,6 @@ #import "java_awt_dnd_DnDConstants.h" #import -#import #import "AWTEvent.h" #import "AWTView.h" @@ -572,7 +571,7 @@ - (void)doDrag GET_DSCP_CLASS(); DECLARE_METHOD(dragDropFinishedMethod, CDragSourceContextPeerClass, "dragDropFinished", "(ZIII)V"); DLog3(@" -> posting dragDropFinished, point %f, %f", point.x, point.y); - (*env)->CallVoidMethod(env, fDragSourceContextPeer, dragDropFinishedMethod, success, dragOp, (jint) point.x, (jint) point.y); // AWT_THREADING Safe (event) + (*env)->CallVoidMethod(env, fDragSourceContextPeer, dragDropFinishedMethod, success, dragOp, (jint) point.x, (jint) point.y); CHECK_EXCEPTION(); DECLARE_METHOD(resetHoveringMethod, CDragSourceContextPeerClass, "resetHovering", "()V"); (*env)->CallVoidMethod(env, fDragSourceContextPeer, resetHoveringMethod); // Hust reset static variable @@ -594,7 +593,7 @@ - (void)drag { AWT_ASSERT_NOT_APPKIT_THREAD; - [self performSelectorOnMainThread:@selector(doDrag) withObject:nil waitUntilDone:YES]; // AWT_THREADING Safe (called from unique asynchronous thread) + [self performSelectorOnMainThread:@selector(doDrag) withObject:nil waitUntilDone:YES]; } /******************************** BEGIN NSDraggingSource Interface ********************************/ @@ -613,7 +612,7 @@ - (void)draggingOperationChanged:(NSDragOperation)dragOp { GET_DSCP_CLASS(); DECLARE_METHOD(operationChangedMethod, CDragSourceContextPeerClass, "operationChanged", "(IIII)V"); - (*env)->CallVoidMethod(env, fDragSourceContextPeer, operationChangedMethod, targetActions, modifiedModifiers, (jint) point.x, (jint) point.y); // AWT_THREADING Safe (event) + (*env)->CallVoidMethod(env, fDragSourceContextPeer, operationChangedMethod, targetActions, modifiedModifiers, (jint) point.x, (jint) point.y); CHECK_EXCEPTION(); } @@ -688,11 +687,11 @@ - (void)draggedImage:(NSImage *)image movedTo:(NSPoint)screenPoint { DLog3(@" -> posting dragMotion, point %f, %f", point.x, point.y); GET_DSCP_CLASS(); DECLARE_METHOD(dragMotionMethod, CDragSourceContextPeerClass, "dragMotion", "(IIII)V"); - (*env)->CallVoidMethod(env, fDragSourceContextPeer, dragMotionMethod, targetActions, (jint) fModifiers, (jint) point.x, (jint) point.y); // AWT_THREADING Safe (event) + (*env)->CallVoidMethod(env, fDragSourceContextPeer, dragMotionMethod, targetActions, (jint) fModifiers, (jint) point.x, (jint) point.y); CHECK_EXCEPTION(); DLog3(@" -> posting dragMouseMoved, point %f, %f", point.x, point.y); DECLARE_METHOD(dragMouseMovedMethod, CDragSourceContextPeerClass, "dragMouseMoved", "(IIII)V"); - (*env)->CallVoidMethod(env, fDragSourceContextPeer, dragMouseMovedMethod, targetActions, (jint) fModifiers, (jint) point.x, (jint) point.y); // AWT_THREADING Safe (event) + (*env)->CallVoidMethod(env, fDragSourceContextPeer, dragMouseMovedMethod, targetActions, (jint) fModifiers, (jint) point.x, (jint) point.y); CHECK_EXCEPTION(); } JNI_COCOA_EXIT(env); @@ -719,7 +718,7 @@ - (void) postDragEnter { DLog3(@" -> posting dragEnter, point %f, %f", point.x, point.y); GET_DSCP_CLASS(); DECLARE_METHOD(dragEnterMethod, CDragSourceContextPeerClass, "dragEnter", "(IIII)V"); - (*env)->CallVoidMethod(env, fDragSourceContextPeer, dragEnterMethod, targetActions, (jint) fModifiers, (jint) point.x, (jint) point.y); // AWT_THREADING Safe (event) + (*env)->CallVoidMethod(env, fDragSourceContextPeer, dragEnterMethod, targetActions, (jint) fModifiers, (jint) point.x, (jint) point.y); CHECK_EXCEPTION(); } @@ -731,7 +730,7 @@ - (void) postDragExit { DLog3(@" -> posting dragExit, point %f, %f", point.x, point.y); GET_DSCP_CLASS(); DECLARE_METHOD(dragExitMethod, CDragSourceContextPeerClass, "dragExit", "(II)V"); - (*env)->CallVoidMethod(env, fDragSourceContextPeer, dragExitMethod, (jint) point.x, (jint) point.y); // AWT_THREADING Safe (event) + (*env)->CallVoidMethod(env, fDragSourceContextPeer, dragExitMethod, (jint) point.x, (jint) point.y); CHECK_EXCEPTION(); } diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/CDragSourceContextPeer.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/CDragSourceContextPeer.m index 4b86ec6818d3a..0366f2b6d1eef 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/CDragSourceContextPeer.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/CDragSourceContextPeer.m @@ -26,7 +26,6 @@ #import "sun_lwawt_macosx_CDragSourceContextPeer.h" #import "JNIUtilities.h" -#import #import "CDragSource.h" #import "ThreadUtilities.h" diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/CDropTarget.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/CDropTarget.m index a5540406411eb..e5f44b4a711c4 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/CDropTarget.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/CDropTarget.m @@ -31,7 +31,6 @@ #import "sun_lwawt_macosx_CDropTarget.h" #import "java_awt_dnd_DnDConstants.h" -#import #import #include diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/CDropTargetContextPeer.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/CDropTargetContextPeer.m index 8020706ae3b7e..2e590369508f9 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/CDropTargetContextPeer.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/CDropTargetContextPeer.m @@ -25,8 +25,6 @@ #import "sun_lwawt_macosx_CDropTargetContextPeer.h" -#import - #import "CDataTransferer.h" #import "CDropTarget.h" #import "DnDUtilities.h" diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/CFRetainedResource.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/CFRetainedResource.m index c0ee841eb419e..2759719888fe7 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/CFRetainedResource.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/CFRetainedResource.m @@ -24,9 +24,9 @@ */ #import "JNIUtilities.h" +#import "ThreadUtilities.h" #import -#import #import "sun_lwawt_macosx_CFRetainedResource.h" @@ -49,7 +49,7 @@ }]; } else { // could happen if we are embedded inside SWT/FX application, - [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^() { + [ThreadUtilities performOnMainThreadWaiting:NO block:^() { CFRelease(jlong_to_ptr(ptr)); }]; } diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/CFileDialog.h b/src/java.desktop/macosx/native/libawt_lwawt/awt/CFileDialog.h index ba435113eec01..677c9715679ee 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/CFileDialog.h +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/CFileDialog.h @@ -24,7 +24,6 @@ */ #import -#import @interface CFileDialog : NSObject { // Should we query back to Java for a file filter? diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/CFileDialog.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/CFileDialog.m index 4b09d07114bbe..3b895be8094fc 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/CFileDialog.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/CFileDialog.m @@ -25,11 +25,10 @@ #import #import -#import -#import "CFileDialog.h" #import "ThreadUtilities.h" #import "JNIUtilities.h" +#import "CFileDialog.h" #import "java_awt_FileDialog.h" #import "sun_lwawt_macosx_CFileDialog.h" @@ -143,11 +142,11 @@ - (void)safeSaveOrLoad { - (BOOL) askFilenameFilter:(NSString *)filename { JNIEnv *env = [ThreadUtilities getJNIEnv]; - jstring jString = JNFNormalizedJavaStringForPath(env, filename); + jstring jString = NormalizedPathJavaStringFromNSString(env, filename); DECLARE_CLASS_RETURN(jc_CFileDialog, "sun/lwawt/macosx/CFileDialog", NO); DECLARE_METHOD_RETURN(jm_queryFF, jc_CFileDialog, "queryFilenameFilter", "(Ljava/lang/String;)Z", NO); - BOOL returnValue = (*env)->CallBooleanMethod(env, fFileDialog, jm_queryFF, jString); // AWT_THREADING Safe (AWTRunLoopMode) + BOOL returnValue = (*env)->CallBooleanMethod(env, fFileDialog, jm_queryFF, jString); CHECK_EXCEPTION(); (*env)->DeleteLocalRef(env, jString); @@ -199,7 +198,7 @@ - (NSArray *)URLs { jobjectArray returnValue = NULL; JNI_COCOA_ENTER(env); - NSString *dialogTitle = JNFJavaToNSString(env, title); + NSString *dialogTitle = JavaStringToNSString(env, title); if ([dialogTitle length] == 0) { dialogTitle = @" "; } @@ -207,15 +206,15 @@ - (NSArray *)URLs { CFileDialog *dialogDelegate = [[CFileDialog alloc] initWithFilter:hasFilter fileDialog:peer title:dialogTitle - directory:JNFJavaToNSString(env, directory) - file:JNFJavaToNSString(env, file) + directory:JavaStringToNSString(env, directory) + file:JavaStringToNSString(env, file) mode:mode multipleMode:multipleMode shouldNavigate:navigateApps canChooseDirectories:chooseDirectories withEnv:env]; - [JNFRunLoop performOnMainThread:@selector(safeSaveOrLoad) + [ThreadUtilities performOnMainThread:@selector(safeSaveOrLoad) on:dialogDelegate withObject:nil waitUntilDone:YES]; @@ -228,7 +227,7 @@ - (NSArray *)URLs { returnValue = (*env)->NewObjectArray(env, count, jc_String, NULL); [urls enumerateObjectsUsingBlock:^(id url, NSUInteger index, BOOL *stop) { - jstring filename = JNFNormalizedJavaStringForPath(env, [url path]); + jstring filename = NormalizedPathJavaStringFromNSString(env, [url path]); (*env)->SetObjectArrayElement(env, returnValue, index, filename); (*env)->DeleteLocalRef(env, filename); }]; diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/CGraphicsDevice.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/CGraphicsDevice.m index e82a20105dc94..4ac03def23076 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/CGraphicsDevice.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/CGraphicsDevice.m @@ -28,8 +28,6 @@ #include "GeomUtilities.h" #include "JNIUtilities.h" -#import - /** * Some default values for invalid CoreGraphics display ID. */ diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/CGraphicsEnv.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/CGraphicsEnv.m index 76dc31fa10154..58338cbc6c130 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/CGraphicsEnv.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/CGraphicsEnv.m @@ -28,8 +28,6 @@ #import "JNIUtilities.h" #import "ThreadUtilities.h" -#import - #define MAX_DISPLAYS 64 /* @@ -114,19 +112,18 @@ [ThreadUtilities performOnMainThreadWaiting:NO block:^() { - JNFPerformEnvBlock(JNFThreadDetachImmediately, ^(JNIEnv *env) { - jobject cgeRef = (jobject)userInfo; - - jobject graphicsEnv = (*env)->NewLocalRef(env, cgeRef); - if (graphicsEnv == NULL) return; // ref already GC'd - DECLARE_CLASS(jc_CGraphicsEnvironment, "sun/awt/CGraphicsEnvironment"); - DECLARE_METHOD(jm_displayReconfiguration, - jc_CGraphicsEnvironment, "_displayReconfiguration","(IZ)V"); - (*env)->CallVoidMethod(env, graphicsEnv, jm_displayReconfiguration, - (jint) display, (jboolean) flags & kCGDisplayRemoveFlag); - (*env)->DeleteLocalRef(env, graphicsEnv); - CHECK_EXCEPTION(); - }); + JNIEnv *env = [ThreadUtilities getJNIEnvUncached]; + jobject cgeRef = (jobject)userInfo; + + jobject graphicsEnv = (*env)->NewLocalRef(env, cgeRef); + if (graphicsEnv == NULL) return; // ref already GC'd + DECLARE_CLASS(jc_CGraphicsEnvironment, "sun/awt/CGraphicsEnvironment"); + DECLARE_METHOD(jm_displayReconfiguration, + jc_CGraphicsEnvironment, "_displayReconfiguration","(IZ)V"); + (*env)->CallVoidMethod(env, graphicsEnv, jm_displayReconfiguration, + (jint) display, (jboolean) flags & kCGDisplayRemoveFlag); + (*env)->DeleteLocalRef(env, graphicsEnv); + CHECK_EXCEPTION(); }]; } diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/CImage.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/CImage.m index 23daa3528a884..051588f95bf51 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/CImage.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/CImage.m @@ -25,7 +25,6 @@ #import "jni_util.h" #import -#import #import "GeomUtilities.h" #import "ThreadUtilities.h" @@ -204,7 +203,7 @@ JNI_COCOA_ENTER(env); - NSString *path = JNFNormalizedNSStringForPath(env, file); + NSString *path = NormalizedPathNSStringFromJavaString(env, file); image = [[NSImage alloc] initByReferencingFile:path]; JNI_COCOA_EXIT(env); @@ -224,7 +223,7 @@ JNI_COCOA_ENTER(env); - NSString *path = JNFNormalizedNSStringForPath(env, file); + NSString *path = NormalizedPathNSStringFromJavaString(env, file); [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ image = [[[NSWorkspace sharedWorkspace] iconForFile:path] retain]; [image setScalesWhenResized:TRUE]; @@ -247,7 +246,7 @@ JNI_COCOA_ENTER(env); - image = [[NSImage imageNamed:JNFJavaToNSString(env, name)] retain]; + image = [[NSImage imageNamed:JavaStringToNSString(env, name)] retain]; JNI_COCOA_EXIT(env); diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/CInputMethod.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/CInputMethod.m index 3c5b18c52699c..88585a6cbf7d7 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/CInputMethod.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/CInputMethod.m @@ -32,7 +32,6 @@ #import "AWTView.h" #import "JNIUtilities.h" -#import #import #define JAVA_LIST @"JAVA_LIST" @@ -160,7 +159,7 @@ + (void) _nativeEndComposition:(AWTView *)view { }]; if (keyboardInfo == nil) return NULL; - returnValue = JNFNSToJavaString(env, keyboardInfo); + returnValue = NSStringToJavaString(env, keyboardInfo); [keyboardInfo release]; JNI_COCOA_EXIT(env); @@ -259,7 +258,7 @@ + (void) _nativeEndComposition:(AWTView *)view { (JNIEnv *env, jobject this, jstring locale, jboolean isActivating) { JNI_COCOA_ENTER(env); - NSString *localeStr = JNFJavaToNSString(env, locale); + NSString *localeStr = JavaStringToNSString(env, locale); [localeStr retain]; [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenu.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenu.m index 59223045aa480..103176b9ca013 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenu.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenu.m @@ -23,7 +23,6 @@ * questions. */ -#import #import @@ -216,7 +215,7 @@ - (NSString *)description { { JNI_COCOA_ENTER(env); // Set the menu's title. - [((CMenu *)jlong_to_ptr(menuObject)) setJavaMenuTitle:JNFJavaToNSString(env, label)]; + [((CMenu *)jlong_to_ptr(menuObject)) setJavaMenuTitle:JavaStringToNSString(env, label)]; JNI_COCOA_EXIT(env); } diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenuBar.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenuBar.m index 6c430f167f575..49a6a80da213c 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenuBar.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenuBar.m @@ -26,7 +26,6 @@ #import "JNIUtilities.h" #import -#import #import diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenuComponent.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenuComponent.m index d49edec879e3a..ba802f801b8f7 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenuComponent.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenuComponent.m @@ -24,7 +24,6 @@ */ #import "CMenuComponent.h" -#import #import "ThreadUtilities.h" diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenuItem.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenuItem.m index e0e4f4b169ae4..8e86dd46a79da 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenuItem.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenuItem.m @@ -23,7 +23,6 @@ * questions. */ -#import #include #import "CMenuItem.h" #import "CMenu.h" @@ -313,7 +312,7 @@ static unichar AWTKeyToMacShortcut(jint awtKey, BOOL doShift) { jchar shortcutKey, jint shortcutKeyCode, jint mods) { JNI_COCOA_ENTER(env); - NSString *theLabel = JNFJavaToNSString(env, label); + NSString *theLabel = JavaStringToNSString(env, label); NSString *theKeyEquivalent = nil; unichar macKey = shortcutKey; @@ -342,7 +341,7 @@ static unichar AWTKeyToMacShortcut(jint awtKey, BOOL doShift) { (JNIEnv *env, jobject peer, jlong menuItemObj, jstring tooltip) { JNI_COCOA_ENTER(env); - NSString *theTooltip = JNFJavaToNSString(env, tooltip); + NSString *theTooltip = JavaStringToNSString(env, tooltip); [((CMenuItem *)jlong_to_ptr(menuItemObj)) setJavaToolTipText:theTooltip]; JNI_COCOA_EXIT(env); } diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/CPopupMenu.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/CPopupMenu.m index b77756dfaa4c9..11b9172707a8e 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/CPopupMenu.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/CPopupMenu.m @@ -24,7 +24,6 @@ */ #import -#import #import "AWTWindow.h" #import "AWTView.h" diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/CPrinterJob.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/CPrinterJob.m index 51aa9a79e2ca2..db5c192c6c813 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/CPrinterJob.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/CPrinterJob.m @@ -30,7 +30,6 @@ #import "sun_lwawt_macosx_CPrinterPageDialog.h" #import -#import #import "PrinterView.h" #import "PrintModel.h" @@ -87,7 +86,7 @@ NSPrintInfo* defaultPrintInfo = [[NSPrintInfo sharedPrintInfo] copy]; if (printer != NULL) { - NSPrinter* nsPrinter = [NSPrinter printerWithName:JNFJavaToNSString(env, printer)]; + NSPrinter* nsPrinter = [NSPrinter printerWithName:JavaStringToNSString(env, printer)]; if (nsPrinter != nil) { [defaultPrintInfo setPrinter:nsPrinter]; @@ -345,7 +344,7 @@ static void javaPageFormatToNSPrintInfo(JNIEnv* env, jobject srcPrintJob, jobjec jobject printerNameObj = (*env)->CallObjectMethod(env, srcPrintJob, jm_getPrinterName); CHECK_EXCEPTION(); if (printerNameObj == NULL) return; - NSString *printerName = JNFJavaToNSString(env, printerNameObj); + NSString *printerName = JavaStringToNSString(env, printerNameObj); if (printerName == nil) return; NSPrinter *printer = [NSPrinter printerWithName:printerName]; if (printer == nil) return; @@ -364,7 +363,7 @@ static void nsPrintInfoToJavaPrinterJob(JNIEnv* env, NSPrintInfo* src, jobject d // get the selected printer's name, and set the appropriate PrintService on the Java side NSString *name = [[src printer] name]; - jstring printerName = JNFNSToJavaString(env, name); + jstring printerName = NSStringToJavaString(env, name); (*env)->CallVoidMethod(env, dstPrinterJob, jm_setService, printerName); CHECK_EXCEPTION(); @@ -375,7 +374,7 @@ static void nsPrintInfoToJavaPrinterJob(JNIEnv* env, NSPrintInfo* src, jobject d CHECK_EXCEPTION(); NSURL *url = [printingDictionary objectForKey:NSPrintJobSavingURL]; NSString *nsStr = [url absoluteString]; - jstring str = JNFNSToJavaString(env, nsStr); + jstring str = NSStringToJavaString(env, nsStr); (*env)->CallVoidMethod(env, dstPrinterJob, jm_setDestinationFile, str); CHECK_EXCEPTION(); } else { @@ -491,7 +490,7 @@ static void javaPrinterJobToNSPrintInfo(JNIEnv* env, jobject srcPrinterJob, jobj CHECK_EXCEPTION(); if (dest != NULL) { [dst setJobDisposition:NSPrintSaveJob]; - NSString *nsDestStr = JNFJavaToNSString(env, dest); + NSString *nsDestStr = JavaStringToNSString(env, dest); NSURL *nsURL = [NSURL fileURLWithPath:nsDestStr isDirectory:NO]; [printingDictionary setObject:nsURL forKey:NSPrintJobSavingURL]; } else { @@ -628,7 +627,7 @@ static void javaPrinterJobToNSPrintInfo(JNIEnv* env, jobject srcPrinterJob, jobj jobject printerTrayObj = (*env)->CallObjectMethod(env, jthis, jm_getPrinterTray); CHECK_EXCEPTION(); if (printerTrayObj != NULL) { - NSString *printerTray = JNFJavaToNSString(env, printerTrayObj); + NSString *printerTray = JavaStringToNSString(env, printerTrayObj); if (printerTray != nil) { [[printInfo printSettings] setObject:printerTray forKey:@"InputSlot"]; } @@ -642,7 +641,7 @@ static void javaPrinterJobToNSPrintInfo(JNIEnv* env, jobject srcPrinterJob, jobj jobject printerNameObj = (*env)->CallObjectMethod(env, jthis, jm_getPrinterName); CHECK_EXCEPTION(); if (printerNameObj != NULL) { - NSString *printerName = JNFJavaToNSString(env, printerNameObj); + NSString *printerName = JavaStringToNSString(env, printerNameObj); if (printerName != nil) { NSPrinter *printer = [NSPrinter printerWithName:printerName]; if (printer != nil) [printInfo setPrinter:printer]; diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/CRobot.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/CRobot.m index 501d0f1886fd9..9d90086677d81 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/CRobot.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/CRobot.m @@ -25,7 +25,6 @@ #import "JNIUtilities.h" -#import #import #import "CRobotKeyCode.h" diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/CSystemColors.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/CSystemColors.m index 2cfec9048057c..ca61907a868ba 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/CSystemColors.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/CSystemColors.m @@ -28,7 +28,6 @@ #import "java_awt_SystemColor.h" #import "sun_lwawt_macosx_LWCToolkit.h" -#import #import #import "ThreadUtilities.h" diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/CTextPipe.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/CTextPipe.m index 7c963d46e4ea9..c95ea3822d236 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/CTextPipe.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/CTextPipe.m @@ -30,8 +30,6 @@ #import "sun_lwawt_macosx_CTextPipe.h" #import "sun_java2d_OSXSurfaceData.h" -#import - #import "CoreTextSupport.h" #import "QuartzSurfaceData.h" #include "AWTStrike.h" @@ -586,6 +584,9 @@ render using the right font (see bug 7183516) when attribString is not JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CTextPipe_doDrawString (JNIEnv *env, jobject jthis, jobject jsurfacedata, jlong awtStrikePtr, jstring str, jdouble x, jdouble y) { + if (str == NULL) { + return; + } QuartzSDOps *qsdo = (QuartzSDOps *)SurfaceData_GetOps(env, jsurfacedata); AWTStrike *awtStrike = (AWTStrike *)jlong_to_ptr(awtStrikePtr); @@ -597,7 +598,7 @@ render using the right font (see bug 7183516) when attribString is not { jchar unichars[len]; (*env)->GetStringRegion(env, str, 0, len, unichars); - JNF_CHECK_AND_RETHROW_EXCEPTION(env); + CHECK_EXCEPTION(); // Draw the text context DrawTextContext(env, qsdo, awtStrike, unichars, len, x, y); @@ -605,12 +606,16 @@ render using the right font (see bug 7183516) when attribString is not else { // Get string to draw and the length - const jchar *unichars = JNFGetStringUTF16UniChars(env, str); + const jchar *unichars = (*env)->GetStringChars(env, str, NULL); + if (unichars == NULL) { + JNU_ThrowOutOfMemoryError(env, "Could not get string chars"); + return; + } // Draw the text context DrawTextContext(env, qsdo, awtStrike, unichars, len, x, y); - JNFReleaseStringUTF16UniChars(env, str, unichars); + (*env)->ReleaseStringChars(env, str, unichars); } JNI_COCOA_RENDERER_EXIT(env); @@ -635,7 +640,7 @@ render using the right font (see bug 7183516) when attribString is not { jchar copyUnichars[length]; (*env)->GetCharArrayRegion(env, unicodes, offset, length, copyUnichars); - JNF_CHECK_AND_RETHROW_EXCEPTION(env); + CHECK_EXCEPTION(); DrawTextContext(env, qsdo, awtStrike, copyUnichars, length, x, y); } else @@ -648,7 +653,7 @@ render using the right font (see bug 7183516) when attribString is not @try { (*env)->GetCharArrayRegion(env, unicodes, offset, length, copyUnichars); - JNF_CHECK_AND_RETHROW_EXCEPTION(env); + CHECK_EXCEPTION(); DrawTextContext(env, qsdo, awtStrike, copyUnichars, length, x, y); } @finally { free(copyUnichars); diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/CTrayIcon.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/CTrayIcon.m index 9bd18de2eeefd..6d160ab0dbb13 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/CTrayIcon.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/CTrayIcon.m @@ -26,7 +26,6 @@ #import "jni_util.h" #import -#import #import "CTrayIcon.h" #import "ThreadUtilities.h" @@ -342,7 +341,7 @@ - (void) otherMouseDragged:(NSEvent *)event { JNI_COCOA_ENTER(env); AWTTrayIcon *icon = jlong_to_ptr(model); - NSString *tooltip = JNFJavaToNSString(env, jtooltip); + NSString *tooltip = JavaStringToNSString(env, jtooltip); [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ [icon setTooltip:tooltip]; }]; @@ -395,8 +394,8 @@ - (void) otherMouseDragged:(NSEvent *)event { JNI_COCOA_ENTER(env); AWTTrayIcon *icon = jlong_to_ptr(model); - NSString *caption = JNFJavaToNSString(env, jcaption); - NSString *text = JNFJavaToNSString(env, jtext); + NSString *caption = JavaStringToNSString(env, jcaption); + NSString *text = JavaStringToNSString(env, jtext); NSImage * contentImage = jlong_to_ptr(nsimage); [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/CWrapper.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/CWrapper.m index ca6580b2b0c4b..3244438bc1bcf 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/CWrapper.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/CWrapper.m @@ -25,7 +25,6 @@ #import "JNIUtilities.h" -#import #import "ThreadUtilities.h" #import "sun_lwawt_macosx_CWrapper_NSWindow.h" @@ -592,7 +591,7 @@ static void initLevels() JNI_COCOA_ENTER(env); NSView *view = (NSView *)jlong_to_ptr(viewPtr); - NSString* s = JNFJavaToNSString(env, msg); + NSString* s = JavaStringToNSString(env, msg); [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ [view setToolTip: s]; }]; diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/GeomUtilities.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/GeomUtilities.m index 7f806ccef650d..13ad3d7db6e4e 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/GeomUtilities.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/GeomUtilities.m @@ -24,7 +24,6 @@ */ #import "GeomUtilities.h" -#import static jobject NewJavaRect(JNIEnv *env, jdouble x, jdouble y, jdouble w, jdouble h) { DECLARE_CLASS_RETURN(sjc_Rectangle2DDouble, "java/awt/geom/Rectangle2D$Double", NULL); @@ -100,7 +99,10 @@ NSSize JavaToNSSize(JNIEnv *env, jobject dimension) { static NSScreen *primaryScreen(JNIEnv *env) { NSScreen *primaryScreen = [[NSScreen screens] objectAtIndex:0]; if (primaryScreen != nil) return primaryScreen; - if (env != NULL) [JNFException raise:env as:kRuntimeException reason:"Failed to convert, no screen."]; + if ((env != NULL) && ([NSThread isMainThread] == NO)) { + JNU_ThrowByName(env, "java/lang/RuntimeException", "Failed to convert, no screen."); + } + [NSException raise:NSGenericException format:@"Failed to convert, no screen."]; return nil; } diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/ImageSurfaceData.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/ImageSurfaceData.m index bac3fbfa78e83..47dcd3d5b2c18 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/ImageSurfaceData.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/ImageSurfaceData.m @@ -32,7 +32,6 @@ #import "ThreadUtilities.h" #import "JNIUtilities.h" -#import #import "BufImgSurfaceData.h" diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaAccessibilityAction.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaAccessibilityAction.m index 5fb8eeb8a69a7..03a5630b608a2 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaAccessibilityAction.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaAccessibilityAction.m @@ -84,7 +84,7 @@ - (NSString *)getDescription fCompLocal ); CHECK_EXCEPTION(); if (jstr != NULL) { - str = JNFJavaToNSString(env, jstr); // AWT_THREADING Safe (AWTRunLoopMode) + str = JavaStringToNSString(env, jstr); (*env)->DeleteLocalRef(env, jstr); } (*env)->DeleteLocalRef(env, fCompLocal); @@ -100,7 +100,7 @@ - (void)perform "(Ljavax/accessibility/AccessibleAction;ILjava/awt/Component;)V"); (*env)->CallStaticVoidMethod(env, sjc_CAccessibility, jm_doAccessibleAction, - fAccessibleAction, fIndex, fComponent); // AWT_THREADING Safe (AWTRunLoopMode) + fAccessibleAction, fIndex, fComponent); CHECK_EXCEPTION(); } diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaAccessibilityUtilities.h b/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaAccessibilityUtilities.h index d1b692399df2f..f3dfe247ede90 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaAccessibilityUtilities.h +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaAccessibilityUtilities.h @@ -23,7 +23,7 @@ * questions. */ -#import +#import "JNIUtilities.h" extern NSString *const JavaAccessibilityIgnore; diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaAccessibilityUtilities.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaAccessibilityUtilities.m index c22d7bf1e4617..12817e63ecd31 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaAccessibilityUtilities.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaAccessibilityUtilities.m @@ -27,8 +27,6 @@ #import "JNIUtilities.h" #import -#import - static BOOL JavaAccessibilityIsSupportedAttribute(id element, NSString *attribute); static void JavaAccessibilityLogError(NSString *message); @@ -58,7 +56,7 @@ NSSize getAxComponentSize(JNIEnv *env, jobject axComponent, jobject component) DECLARE_STATIC_METHOD_RETURN(jm_getSize, sjc_CAccessibility, "getSize", "(Ljavax/accessibility/AccessibleComponent;Ljava/awt/Component;)Ljava/awt/Dimension;", NSZeroSize); - jobject dimension = (*env)->CallStaticObjectMethod(env, jc_Dimension, jm_getSize, axComponent, component); // AWT_THREADING Safe (AWTRunLoopMode) + jobject dimension = (*env)->CallStaticObjectMethod(env, jc_Dimension, jm_getSize, axComponent, component); CHECK_EXCEPTION(); if (dimension == NULL) return NSZeroSize; @@ -71,11 +69,11 @@ NSSize getAxComponentSize(JNIEnv *env, jobject axComponent, jobject component) DECLARE_STATIC_METHOD_RETURN(sjm_getAccessibleRole, sjc_CAccessibility, "getAccessibleRole", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljava/lang/String;", nil); jobject axRole = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility, sjm_getAccessibleRole, - axComponent, component); // AWT_THREADING Safe (AWTRunLoopMode) + axComponent, component); CHECK_EXCEPTION(); if (axRole == NULL) return @"unknown"; - NSString* str = JNFJavaToNSString(env, axRole); + NSString* str = JavaStringToNSString(env, axRole); (*env)->DeleteLocalRef(env, axRole); return str; } @@ -86,7 +84,7 @@ jobject getAxSelection(JNIEnv *env, jobject axContext, jobject component) DECLARE_STATIC_METHOD_RETURN(jm_getAccessibleSelection, sjc_CAccessibility, "getAccessibleSelection", "(Ljavax/accessibility/AccessibleContext;Ljava/awt/Component;)Ljavax/accessibility/AccessibleSelection;", nil); jobject o = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility, jm_getAccessibleSelection, - axContext, component); // AWT_THREADING Safe (AWTRunLoopMode) + axContext, component); CHECK_EXCEPTION(); return o; } @@ -97,7 +95,7 @@ jobject getAxContextSelection(JNIEnv *env, jobject axContext, jint index, jobjec DECLARE_STATIC_METHOD_RETURN(jm_ax_getAccessibleSelection, sjc_CAccessibility, "ax_getAccessibleSelection", "(Ljavax/accessibility/AccessibleContext;ILjava/awt/Component;)Ljavax/accessibility/Accessible;", nil); return (*env)->CallStaticObjectMethod(env, sjc_CAccessibility, jm_ax_getAccessibleSelection, - axContext, index, component); // AWT_THREADING Safe (AWTRunLoopMode) + axContext, index, component); CHECK_EXCEPTION(); } @@ -107,7 +105,7 @@ void setAxContextSelection(JNIEnv *env, jobject axContext, jint index, jobject c DECLARE_STATIC_METHOD(jm_addAccessibleSelection, sjc_CAccessibility, "addAccessibleSelection", "(Ljavax/accessibility/AccessibleContext;ILjava/awt/Component;)V"); (*env)->CallStaticVoidMethod(env, sjc_CAccessibility, jm_addAccessibleSelection, - axContext, index, component); // AWT_THREADING Safe (AWTRunLoopMode) + axContext, index, component); CHECK_EXCEPTION(); } @@ -117,7 +115,7 @@ jobject getAxContext(JNIEnv *env, jobject accessible, jobject component) DECLARE_STATIC_METHOD_RETURN(jm_getAccessibleContext, sjc_CAccessibility, "getAccessibleContext", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljavax/accessibility/AccessibleContext;", nil); jobject o = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility, jm_getAccessibleContext, - accessible, component); // AWT_THREADING Safe (AWTRunLoopMode) + accessible, component); CHECK_EXCEPTION(); return o; } @@ -128,7 +126,7 @@ BOOL isChildSelected(JNIEnv *env, jobject accessible, jint index, jobject compon DECLARE_STATIC_METHOD_RETURN(jm_isAccessibleChildSelected, sjc_CAccessibility, "isAccessibleChildSelected", "(Ljavax/accessibility/Accessible;ILjava/awt/Component;)Z", NO); jboolean b = (*env)->CallStaticBooleanMethod(env, sjc_CAccessibility, jm_isAccessibleChildSelected, - accessible, index, component); // AWT_THREADING Safe (AWTRunLoopMode) + accessible, index, component); CHECK_EXCEPTION(); return b; } @@ -139,7 +137,7 @@ jobject getAxStateSet(JNIEnv *env, jobject axContext, jobject component) DECLARE_STATIC_METHOD_RETURN(jm_getAccessibleStateSet, sjc_CAccessibility, "getAccessibleStateSet", "(Ljavax/accessibility/AccessibleContext;Ljava/awt/Component;)Ljavax/accessibility/AccessibleStateSet;", nil); jobject o = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility, jm_getAccessibleStateSet, - axContext, component); // AWT_THREADING Safe (AWTRunLoopMode) + axContext, component); CHECK_EXCEPTION(); return o; } @@ -149,7 +147,7 @@ BOOL containsAxState(JNIEnv *env, jobject axContext, jobject axState, jobject co GET_CACCESSIBILITY_CLASS_RETURN(NO); DECLARE_STATIC_METHOD_RETURN(jm_contains, sjc_CAccessibility, "contains", "(Ljavax/accessibility/AccessibleContext;Ljavax/accessibility/AccessibleState;Ljava/awt/Component;)Z", NO); - jboolean b = (*env)->CallStaticBooleanMethod(env, sjc_CAccessibility, jm_contains, axContext, axState, component); // AWT_THREADING Safe (AWTRunLoopMode) + jboolean b = (*env)->CallStaticBooleanMethod(env, sjc_CAccessibility, jm_contains, axContext, axState, component); CHECK_EXCEPTION(); return b; } @@ -210,7 +208,7 @@ NSPoint getAxComponentLocationOnScreen(JNIEnv *env, jobject axComponent, jobject DECLARE_FIELD_RETURN(sjf_X, sjc_Point, "x", "I", NSZeroPoint); DECLARE_FIELD_RETURN(sjf_Y, sjc_Point, "y", "I", NSZeroPoint); jobject jpoint = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility, jm_getLocationOnScreen, - axComponent, component); // AWT_THREADING Safe (AWTRunLoopMode) + axComponent, component); CHECK_EXCEPTION(); if (jpoint == NULL) return NSZeroPoint; return NSMakePoint((*env)->GetIntField(env, jpoint, sjf_X), (*env)->GetIntField(env, jpoint, sjf_Y)); @@ -221,7 +219,7 @@ jint getAxTextCharCount(JNIEnv *env, jobject axText, jobject component) GET_CACCESSIBILITY_CLASS_RETURN(0); DECLARE_STATIC_METHOD_RETURN(jm_getCharCount, sjc_CAccessibility, "getCharCount", "(Ljavax/accessibility/AccessibleText;Ljava/awt/Component;)I", 0); - int i = (*env)->CallStaticIntMethod(env, sjc_CAccessibility, jm_getCharCount, axText, component); // AWT_THREADING Safe (AWTRunLoopMode) + int i = (*env)->CallStaticIntMethod(env, sjc_CAccessibility, jm_getCharCount, axText, component); CHECK_EXCEPTION(); return i; } diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaComponentAccessibility.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaComponentAccessibility.m index 558e1cfccc80d..6c8ede565024d 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaComponentAccessibility.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaComponentAccessibility.m @@ -35,7 +35,6 @@ #import -#import #import #import @@ -312,7 +311,7 @@ + (void)initialize NSInteger i; for (i = 0; i < count; i++) { - jstring jString = JNFNSToJavaString(env, [ignoredKeys objectAtIndex:i]); + jstring jString = NSStringToJavaString(env, [ignoredKeys objectAtIndex:i]); (*env)->SetObjectArrayElement(env, result, i, jString); (*env)->DeleteLocalRef(env, jString); } @@ -348,7 +347,7 @@ + (NSArray *)childrenOfParent:(JavaComponentAccessibility *)parent withEnv:(JNIE if (parent->fAccessible == NULL) return nil; GET_CHILDRENANDROLES_METHOD_RETURN(nil); jobjectArray jchildrenAndRoles = (jobjectArray)(*env)->CallStaticObjectMethod(env, sjc_CAccessibility, jm_getChildrenAndRoles, - parent->fAccessible, parent->fComponent, whichChildren, allowIgnored); // AWT_THREADING Safe (AWTRunLoop) + parent->fAccessible, parent->fComponent, whichChildren, allowIgnored); CHECK_EXCEPTION(); if (jchildrenAndRoles == NULL) return nil; @@ -368,7 +367,7 @@ + (NSArray *)childrenOfParent:(JavaComponentAccessibility *)parent withEnv:(JNIE DECLARE_FIELD_RETURN(sjf_key, sjc_AccessibleRole, "key", "Ljava/lang/String;", nil); jobject jkey = (*env)->GetObjectField(env, jchildJavaRole, sjf_key); CHECK_EXCEPTION(); - childJavaRole = JNFJavaToNSString(env, jkey); + childJavaRole = JavaStringToNSString(env, jkey); (*env)->DeleteLocalRef(env, jkey); } @@ -490,7 +489,7 @@ - (NSArray *)initializeAttributeNamesWithEnv:(JNIEnv *)env // Get all the other accessibility attributes states we need in one swell foop. // javaRole isn't pulled in because we need protected access to AccessibleRole.key jbooleanArray attributeStates = (jbooleanArray)(*env)->CallStaticObjectMethod(env, sjc_CAccessibility, - jm_getInitialAttributeStates, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop) + jm_getInitialAttributeStates, fAccessible, fComponent); CHECK_EXCEPTION(); if (attributeStates == NULL) return nil; jboolean *attributeStatesArray = (*env)->GetBooleanArrayElements(env, attributeStates, 0); @@ -589,7 +588,7 @@ - (void)getActionsWithEnv:(JNIEnv *)env // On MacOSX, text doesn't have actions, in java it does. // cmcnote: NOT TRUE - Editable text has AXShowMenu. Textfields have AXConfirm. Static text has no actions. - jobject axAction = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility, jm_getAccessibleAction, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop) + jobject axAction = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility, jm_getAccessibleAction, fAccessible, fComponent); CHECK_EXCEPTION(); if (axAction != NULL) { //+++gdb NOTE: In MacOSX, there is just a single Action, not multiple. In java, @@ -866,7 +865,7 @@ - (NSNumber *)accessibilityEnabledAttribute GET_CACCESSIBILITY_CLASS_RETURN(nil); DECLARE_STATIC_METHOD_RETURN(jm_isEnabled, sjc_CAccessibility, "isEnabled", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Z", nil); - NSNumber *value = [NSNumber numberWithBool:(*env)->CallStaticBooleanMethod(env, sjc_CAccessibility, jm_isEnabled, fAccessible, fComponent)]; // AWT_THREADING Safe (AWTRunLoop) + NSNumber *value = [NSNumber numberWithBool:(*env)->CallStaticBooleanMethod(env, sjc_CAccessibility, jm_isEnabled, fAccessible, fComponent)]; CHECK_EXCEPTION(); if (value == nil) { NSLog(@"WARNING: %s called on component that has no accessible component: %@", __FUNCTION__, self); @@ -898,7 +897,7 @@ - (BOOL)accessibilityIsFocusedAttributeSettable // as well as having AccessibleState.FOCUSABLE in its AccessibleStateSet. // We use the former heuristic; if the component focus-traversable, add a focused attribute // See also initializeAttributeNamesWithEnv: - if ((*env)->CallStaticBooleanMethod(env, sjc_CAccessibility, sjm_isFocusTraversable, fAccessible, fComponent)) { // AWT_THREADING Safe (AWTRunLoop) + if ((*env)->CallStaticBooleanMethod(env, sjc_CAccessibility, sjm_isFocusTraversable, fAccessible, fComponent)) { return YES; } CHECK_EXCEPTION(); @@ -915,7 +914,7 @@ - (void)accessibilitySetFocusedAttribute:(id)value if ([(NSNumber*)value boolValue]) { - (*env)->CallStaticVoidMethod(env, sjc_CAccessibility, jm_requestFocus, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop) + (*env)->CallStaticVoidMethod(env, sjc_CAccessibility, jm_requestFocus, fAccessible, fComponent); CHECK_EXCEPTION(); } } @@ -929,12 +928,12 @@ - (NSString *)accessibilityHelpAttribute DECLARE_STATIC_METHOD_RETURN(sjm_getAccessibleDescription, sjc_CAccessibility, "getAccessibleDescription", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljava/lang/String;", nil); jobject val = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility, - sjm_getAccessibleDescription, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop) + sjm_getAccessibleDescription, fAccessible, fComponent); CHECK_EXCEPTION(); if (val == NULL) { return nil; } - NSString* str = JNFJavaToNSString(env, val); + NSString* str = JavaStringToNSString(env, val); (*env)->DeleteLocalRef(env, val); return str; } @@ -956,6 +955,32 @@ - (BOOL)accessibilityIsIndexAttributeSettable return NO; } +/* + * The java/lang/Number concrete class could be for any of the Java primitive + * numerical types or some other subclass. + * All existing A11Y code uses Integer so that is what we look for first + * But all must be able to return a double and NSNumber accepts a double, + * so that's the fall back. + */ +static NSNumber* JavaNumberToNSNumber(JNIEnv *env, jobject jnumber) { + if (jnumber == NULL) { + return nil; + } + DECLARE_CLASS_RETURN(jnumber_Class, "java/lang/Number", nil); + DECLARE_CLASS_RETURN(jinteger_Class, "java/lang/Integer", nil); + DECLARE_METHOD_RETURN(jm_intValue, jnumber_Class, "intValue", "()D", nil); + DECLARE_METHOD_RETURN(jm_doubleValue, jnumber_Class, "doubleValue", "()D", nil); + if ((*env)->IsInstanceOf(env, jnumber, jinteger_Class)) { + jint i = (*env)->CallIntMethod(env, jnumber_Class, jm_intValue); + CHECK_EXCEPTION(); + return [NSNumber numberWithInteger:i]; + } else { + jdouble d = (*env)->CallDoubleMethod(env, jnumber_Class, jm_doubleValue); + CHECK_EXCEPTION(); + return [NSNumber numberWithDouble:d]; + } +} + // Element's maximum value (id) - (id)accessibilityMaxValueAttribute { @@ -964,12 +989,12 @@ - (id)accessibilityMaxValueAttribute DECLARE_STATIC_METHOD_RETURN(jm_getMaximumAccessibleValue, sjc_CAccessibility, "getMaximumAccessibleValue", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljava/lang/Number;", nil); - jobject axValue = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility, jm_getMaximumAccessibleValue, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop) + jobject axValue = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility, jm_getMaximumAccessibleValue, fAccessible, fComponent); CHECK_EXCEPTION(); if (axValue == NULL) { return [NSNumber numberWithInt:0]; } - NSNumber* num = JNFJavaToNSNumber(env, axValue); + NSNumber* num = JavaNumberToNSNumber(env, axValue); (*env)->DeleteLocalRef(env, axValue); return num; } @@ -987,12 +1012,12 @@ - (id)accessibilityMinValueAttribute DECLARE_STATIC_METHOD_RETURN(jm_getMinimumAccessibleValue, sjc_CAccessibility, "getMinimumAccessibleValue", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljava/lang/Number;", nil); - jobject axValue = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility, jm_getMinimumAccessibleValue, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop) + jobject axValue = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility, jm_getMinimumAccessibleValue, fAccessible, fComponent); CHECK_EXCEPTION(); if (axValue == NULL) { return [NSNumber numberWithInt:0]; } - NSNumber* num = JNFJavaToNSNumber(env, axValue); + NSNumber* num = JavaNumberToNSNumber(env, axValue); (*env)->DeleteLocalRef(env, axValue); return num; } @@ -1044,7 +1069,7 @@ - (NSValue *)accessibilityPositionAttribute JNIEnv* env = [ThreadUtilities getJNIEnv]; GET_ACCESSIBLECOMPONENT_STATIC_METHOD_RETURN(nil); jobject axComponent = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility, sjm_getAccessibleComponent, - fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop) + fAccessible, fComponent); CHECK_EXCEPTION(); // NSAccessibility wants the bottom left point of the object in @@ -1115,7 +1140,7 @@ - (NSString *)accessibilityRoleDescriptionAttribute jobject axRole = (*env)->CallStaticObjectMethod(env, jm_getAccessibleRoleDisplayString, fAccessible, fComponent); CHECK_EXCEPTION(); if (axRole != NULL) { - value = JNFJavaToNSString(env, axRole); + value = JavaStringToNSString(env, axRole); (*env)->DeleteLocalRef(env, axRole); } else { value = @"unknown"; @@ -1171,7 +1196,7 @@ - (void)accessibilitySetSelectedAttribute:(id)value "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)V"); if ([(NSNumber*)value boolValue]) { - (*env)->CallStaticVoidMethod(env, sjc_CAccessibility, jm_requestSelection, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop) + (*env)->CallStaticVoidMethod(env, sjc_CAccessibility, jm_requestSelection, fAccessible, fComponent); CHECK_EXCEPTION(); } } @@ -1181,7 +1206,7 @@ - (NSValue *)accessibilitySizeAttribute { JNIEnv* env = [ThreadUtilities getJNIEnv]; GET_ACCESSIBLECOMPONENT_STATIC_METHOD_RETURN(nil); jobject axComponent = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility, - sjm_getAccessibleComponent, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop) + sjm_getAccessibleComponent, fAccessible, fComponent); CHECK_EXCEPTION(); NSValue* size = [NSValue valueWithSize:getAxComponentSize(env, axComponent, fComponent)]; (*env)->DeleteLocalRef(env, axComponent); @@ -1243,12 +1268,12 @@ - (NSString *)accessibilityTitleAttribute JNIEnv* env = [ThreadUtilities getJNIEnv]; GET_ACCESSIBLENAME_METHOD_RETURN(nil); - jobject val = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility, sjm_getAccessibleName, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop) + jobject val = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility, sjm_getAccessibleName, fAccessible, fComponent); CHECK_EXCEPTION(); if (val == NULL) { return nil; } - NSString* str = JNFJavaToNSString(env, val); + NSString* str = JavaStringToNSString(env, val); (*env)->DeleteLocalRef(env, val); return str; } @@ -1304,12 +1329,12 @@ - (id)accessibilityValueAttribute (*env)->CallStaticObjectMethod( env, sjm_getAccessibleName, selectedMenuItem->fAccessible, - selectedMenuItem->fComponent ); // AWT_THREADING Safe (AWTRunLoop) + selectedMenuItem->fComponent ); CHECK_EXCEPTION(); if (itemValue == NULL) { return nil; } - NSString* itemString = JNFJavaToNSString(env, itemValue); + NSString* itemString = JavaStringToNSString(env, itemValue); (*env)->DeleteLocalRef(env, itemValue); return itemString; } else { @@ -1326,7 +1351,7 @@ - (id)accessibilityValueAttribute GET_CACCESSIBILITY_CLASS_RETURN(nil); DECLARE_STATIC_METHOD_RETURN(sjm_getAccessibleValue, sjc_CAccessibility, "getAccessibleValue", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljavax/accessibility/AccessibleValue;", nil); - jobject axValue = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility, sjm_getAccessibleValue, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop) + jobject axValue = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility, sjm_getAccessibleValue, fAccessible, fComponent); CHECK_EXCEPTION(); if (axValue != NULL) { DECLARE_STATIC_METHOD_RETURN(jm_getCurrentAccessibleValue, sjc_CAccessibility, "getCurrentAccessibleValue", @@ -1334,7 +1359,7 @@ - (id)accessibilityValueAttribute jobject str = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility, jm_getCurrentAccessibleValue, axValue, fComponent); CHECK_EXCEPTION(); if (str != NULL) { - num = JNFJavaToNSNumber(env, str); // AWT_THREADING Safe (AWTRunLoop) + num = JavaNumberToNSNumber(env, str); (*env)->DeleteLocalRef(env, str); } (*env)->DeleteLocalRef(env, axValue); @@ -1442,7 +1467,7 @@ - (id)accessibilityHitTest:(NSPoint)point withEnv:(JNIEnv *)env id value = nil; if ((*env)->IsInstanceOf(env, jparent, jc_Container)) { jobject jaccessible = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility, jm_accessibilityHitTest, - jparent, (jfloat)point.x, (jfloat)point.y); // AWT_THREADING Safe (AWTRunLoop) + jparent, (jfloat)point.x, (jfloat)point.y); CHECK_EXCEPTION(); if (jaccessible != NULL) { value = [JavaComponentAccessibility createWithAccessible:jaccessible withEnv:env withView:fView]; @@ -1472,7 +1497,7 @@ - (id)accessibilityFocusedUIElement id value = nil; NSWindow* hostWindow = [[self->fView window] retain]; - jobject focused = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility, jm_getFocusOwner, fComponent); // AWT_THREADING Safe (AWTRunLoop) + jobject focused = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility, jm_getFocusOwner, fComponent); [hostWindow release]; CHECK_EXCEPTION(); @@ -1674,7 +1699,7 @@ - (NSArray *)tabControlsWithEnv:(JNIEnv *)env withTabGroupAxContext:(jobject)axC { GET_CHILDRENANDROLES_METHOD_RETURN(nil); jobjectArray jtabsAndRoles = (jobjectArray)(*env)->CallStaticObjectMethod(env, sjc_CAccessibility, jm_getChildrenAndRoles, - fAccessible, fComponent, whichTabs, allowIgnored); // AWT_THREADING Safe (AWTRunLoop) + fAccessible, fComponent, whichTabs, allowIgnored); CHECK_EXCEPTION(); if(jtabsAndRoles == NULL) return nil; @@ -1695,7 +1720,7 @@ - (NSArray *)tabControlsWithEnv:(JNIEnv *)env withTabGroupAxContext:(jobject)axC DECLARE_FIELD_RETURN(sjf_key, sjc_AccessibleRole, "key", "Ljava/lang/String;", nil); jobject jkey = (*env)->GetObjectField(env, jtabJavaRole, sjf_key); CHECK_EXCEPTION(); - NSString *tabJavaRole = JNFJavaToNSString(env, jkey); + NSString *tabJavaRole = JavaStringToNSString(env, jkey); (*env)->DeleteLocalRef(env, jkey); NSInteger i; @@ -2050,11 +2075,11 @@ static BOOL ObjectEquals(JNIEnv *env, jobject a, jobject b, jobject component) DECLARE_CLASS_RETURN(sjc_LWCToolkit, "sun/lwawt/macosx/LWCToolkit", NO); DECLARE_STATIC_METHOD_RETURN(jm_doEquals, sjc_LWCToolkit, "doEquals", "(Ljava/lang/Object;Ljava/lang/Object;Ljava/awt/Component;)Z", NO); - return (*env)->CallStaticBooleanMethod(env, sjc_LWCToolkit, jm_doEquals, a, b, component); // AWT_THREADING Safe (AWTRunLoopMode) + return (*env)->CallStaticBooleanMethod(env, sjc_LWCToolkit, jm_doEquals, a, b, component); CHECK_EXCEPTION(); } - jboolean jb = (*env)->CallBooleanMethod(env, a, jm_equals, b); // AWT_THREADING Safe (!appKit) + jboolean jb = (*env)->CallBooleanMethod(env, a, jm_equals, b); CHECK_EXCEPTION(); return jb; } diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaTextAccessibility.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaTextAccessibility.m index d662aaef5f734..730e98e414703 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaTextAccessibility.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaTextAccessibility.m @@ -134,10 +134,10 @@ - (NSString *)accessibilityValueAttribute if ([[self accessibilityRoleAttribute] isEqualToString:NSAccessibilityStaticTextRole]) { // if it's static text, the AppKit AXValue is the java accessibleName jobject axName = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility, - sjm_getAccessibleName, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop) + sjm_getAccessibleName, fAccessible, fComponent); CHECK_EXCEPTION(); if (axName != NULL) { - NSString* str = JNFJavaToNSString(env, axName); + NSString* str = JavaStringToNSString(env, axName); (*env)->DeleteLocalRef(env, axName); return str; } @@ -147,14 +147,14 @@ - (NSString *)accessibilityValueAttribute // cmcnote: inefficient to make three distinct JNI calls. Coalesce. radr://3951923 GET_ACCESSIBLETEXT_METHOD_RETURN(@""); jobject axText = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility, - sjm_getAccessibleText, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop) + sjm_getAccessibleText, fAccessible, fComponent); CHECK_EXCEPTION(); if (axText == NULL) return nil; (*env)->DeleteLocalRef(env, axText); GET_ACCESSIBLEEDITABLETEXT_METHOD_RETURN(nil); jobject axEditableText = (*env)->CallStaticObjectMethod(env, sjc_CAccessibleText, - sjm_getAccessibleEditableText, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop) + sjm_getAccessibleEditableText, fAccessible, fComponent); CHECK_EXCEPTION(); if (axEditableText == NULL) return nil; @@ -163,7 +163,7 @@ - (NSString *)accessibilityValueAttribute jobject jrange = (*env)->CallStaticObjectMethod(env, sjc_CAccessibleText, jm_getTextRange, axEditableText, 0, getAxTextCharCount(env, axEditableText, fComponent), fComponent); CHECK_EXCEPTION(); - NSString *string = JNFJavaToNSString(env, jrange); // AWT_THREADING Safe (AWTRunLoop) + NSString *string = JavaStringToNSString(env, jrange); (*env)->DeleteLocalRef(env, jrange); (*env)->DeleteLocalRef(env, axEditableText); @@ -181,7 +181,7 @@ - (BOOL)accessibilityIsValueAttributeSettable JNIEnv* env = [ThreadUtilities getJNIEnv]; GET_ACCESSIBLEEDITABLETEXT_METHOD_RETURN(NO); jobject axEditableText = (*env)->CallStaticObjectMethod(env, sjc_CAccessibleText, - sjm_getAccessibleEditableText, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop) + sjm_getAccessibleEditableText, fAccessible, fComponent); CHECK_EXCEPTION(); if (axEditableText == NULL) return NO; (*env)->DeleteLocalRef(env, axEditableText); @@ -204,10 +204,10 @@ - (NSString *)accessibilitySelectedTextAttribute DECLARE_STATIC_METHOD_RETURN(jm_getSelectedText, sjc_CAccessibleText, "getSelectedText", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljava/lang/String;", nil); jobject axText = (*env)->CallStaticObjectMethod(env, sjc_CAccessibleText, jm_getSelectedText, - fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop) + fAccessible, fComponent); CHECK_EXCEPTION(); if (axText == NULL) return @""; - NSString* str = JNFJavaToNSString(env, axText); + NSString* str = JavaStringToNSString(env, axText); (*env)->DeleteLocalRef(env, axText); return str; } @@ -227,12 +227,12 @@ - (void)accessibilitySetSelectedTextAttribute:(id)value #endif JNIEnv *env = [ThreadUtilities getJNIEnv]; - jstring jstringValue = JNFNSToJavaString(env, (NSString *)value); + jstring jstringValue = NSStringToJavaString(env, (NSString *)value); GET_CACCESSIBLETEXT_CLASS(); DECLARE_STATIC_METHOD(jm_setSelectedText, sjc_CAccessibleText, "setSelectedText", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;Ljava/lang/String;)V"); (*env)->CallStaticVoidMethod(env, sjc_CAccessibleText, jm_setSelectedText, - fAccessible, fComponent, jstringValue); // AWT_THREADING Safe (AWTRunLoop) + fAccessible, fComponent, jstringValue); CHECK_EXCEPTION(); } @@ -244,7 +244,7 @@ - (NSValue *)accessibilitySelectedTextRangeAttribute DECLARE_STATIC_METHOD_RETURN(jm_getSelectedTextRange, sjc_CAccessibleText, "getSelectedTextRange", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)[I", nil); jintArray axTextRange = (*env)->CallStaticObjectMethod(env, sjc_CAccessibleText, - jm_getSelectedTextRange, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop) + jm_getSelectedTextRange, fAccessible, fComponent); CHECK_EXCEPTION(); if (axTextRange == NULL) return nil; @@ -274,7 +274,7 @@ - (void)accessibilitySetSelectedTextRangeAttribute:(id)value DECLARE_STATIC_METHOD(jm_setSelectedTextRange, sjc_CAccessibleText, "setSelectedTextRange", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;II)V"); (*env)->CallStaticVoidMethod(env, sjc_CAccessibleText, jm_setSelectedTextRange, - fAccessible, fComponent, startIndex, endIndex); // AWT_THREADING Safe (AWTRunLoop) + fAccessible, fComponent, startIndex, endIndex); CHECK_EXCEPTION(); } @@ -285,7 +285,7 @@ - (NSNumber *)accessibilityNumberOfCharactersAttribute JNIEnv *env = [ThreadUtilities getJNIEnv]; GET_ACCESSIBLETEXT_METHOD_RETURN(nil); jobject axText = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility, - sjm_getAccessibleText, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop) + sjm_getAccessibleText, fAccessible, fComponent); CHECK_EXCEPTION(); NSNumber* num = [NSNumber numberWithInt:getAxTextCharCount(env, axText, fComponent)]; (*env)->DeleteLocalRef(env, axText); @@ -304,7 +304,7 @@ - (NSValue *)accessibilityVisibleCharacterRangeAttribute DECLARE_STATIC_METHOD_RETURN(jm_getVisibleCharacterRange, sjc_CAccessibleText, "getVisibleCharacterRange", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)[I", nil); jintArray axTextRange = (*env)->CallStaticObjectMethod(env, sjc_CAccessibleText, - jm_getVisibleCharacterRange, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop) + jm_getVisibleCharacterRange, fAccessible, fComponent); CHECK_EXCEPTION(); if (axTextRange == NULL) return nil; @@ -326,7 +326,7 @@ - (NSValue *)accessibilityInsertionPointLineNumberAttribute DECLARE_STATIC_METHOD_RETURN(jm_getLineNumberForInsertionPoint, sjc_CAccessibleText, "getLineNumberForInsertionPoint", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)I", nil); jint row = (*env)->CallStaticIntMethod(env, sjc_CAccessibleText, - jm_getLineNumberForInsertionPoint, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop) + jm_getLineNumberForInsertionPoint, fAccessible, fComponent); CHECK_EXCEPTION(); if (row < 0) return nil; return [NSNumber numberWithInt:row]; @@ -365,7 +365,7 @@ - (NSValue *)accessibilityBoundsForRangeAttributeForParameter:(id)parameter DECLARE_STATIC_METHOD_RETURN(jm_getBoundsForRange, sjc_CAccessibleText, "getBoundsForRange", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;II)[D", nil); jdoubleArray axBounds = (jdoubleArray)(*env)->CallStaticObjectMethod(env, sjc_CAccessibleText, jm_getBoundsForRange, - fAccessible, fComponent, range.location, range.length); // AWT_THREADING Safe (AWTRunLoop) + fAccessible, fComponent, range.location, range.length); CHECK_EXCEPTION(); if (axBounds == NULL) return nil; @@ -397,7 +397,7 @@ - (NSNumber *)accessibilityLineForIndexAttributeForParameter:(id)parameter DECLARE_STATIC_METHOD_RETURN(jm_getLineNumberForIndex, sjc_CAccessibleText, "getLineNumberForIndex", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;I)I", nil); jint row = (*env)->CallStaticIntMethod(env, sjc_CAccessibleText, jm_getLineNumberForIndex, - fAccessible, fComponent, [line intValue]); // AWT_THREADING Safe (AWTRunLoop) + fAccessible, fComponent, [line intValue]); CHECK_EXCEPTION(); if (row < 0) return nil; return [NSNumber numberWithInt:row]; @@ -413,7 +413,7 @@ - (NSValue *)accessibilityRangeForLineAttributeForParameter:(id)parameter DECLARE_STATIC_METHOD_RETURN(jm_getRangeForLine, sjc_CAccessibleText, "getRangeForLine", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;I)[I", nil); jintArray axTextRange = (jintArray)(*env)->CallStaticObjectMethod(env, sjc_CAccessibleText, - jm_getRangeForLine, fAccessible, fComponent, [line intValue]); // AWT_THREADING Safe (AWTRunLoop) + jm_getRangeForLine, fAccessible, fComponent, [line intValue]); CHECK_EXCEPTION(); if (axTextRange == NULL) return nil; @@ -443,10 +443,10 @@ - (NSString *)accessibilityStringForRangeAttributeForParameter:(id)parameter DECLARE_STATIC_METHOD_RETURN(jm_getStringForRange, sjc_CAccessibleText, "getStringForRange", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;II)Ljava/lang/String;", nil); jstring jstringForRange = (jstring)(*env)->CallStaticObjectMethod(env, sjc_CAccessibleText, jm_getStringForRange, - fAccessible, fComponent, range.location, range.length); // AWT_THREADING Safe (AWTRunLoop) + fAccessible, fComponent, range.location, range.length); CHECK_EXCEPTION(); if (jstringForRange == NULL) return @""; - NSString* str = JNFJavaToNSString(env, jstringForRange); + NSString* str = JavaStringToNSString(env, jstringForRange); (*env)->DeleteLocalRef(env, jstringForRange); return str; } @@ -475,7 +475,7 @@ - (NSValue *)accessibilityRangeForPositionAttributeForParameter:(id)parameter DECLARE_STATIC_METHOD_RETURN(jm_getCharacterIndexAtPosition, sjc_CAccessibleText, "getCharacterIndexAtPosition", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;II)I", nil); jint charIndex = (*env)->CallStaticIntMethod(env, sjc_CAccessibleText, jm_getCharacterIndexAtPosition, - fAccessible, fComponent, point.x, point.y); // AWT_THREADING Safe (AWTRunLoop) + fAccessible, fComponent, point.x, point.y); CHECK_EXCEPTION(); if (charIndex == -1) return nil; @@ -508,7 +508,7 @@ - (NSValue *)accessibilityRangeForIndexAttributeForParameter:(id)parameter DECLARE_STATIC_METHOD_RETURN(jm_getRangeForIndex, sjc_CAccessibleText, "getRangeForIndex", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;I)[I", nil); jintArray axTextRange = (jintArray)(*env)->CallStaticObjectMethod(env, sjc_CAccessibleText, jm_getRangeForIndex, - fAccessible, fComponent, index); // AWT_THREADING Safe (AWTRunLoop) + fAccessible, fComponent, index); CHECK_EXCEPTION(); if (axTextRange == NULL) return nil; diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/LWCToolkit.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/LWCToolkit.m index 982935ce69e63..1c3fd329c59ed 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/LWCToolkit.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/LWCToolkit.m @@ -456,7 +456,7 @@ + (void)starter:(BOOL)wasOnMainThread headless:(BOOL)headless { // could happen if we are embedded inside SWT application, // in this case just spin a single empty block through // the event loop to give it a chance to process pending events - [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){}]; + [ThreadUtilities performOnMainThreadWaiting:YES block:^(){}]; } if (([AWTToolkit getEventCount] - currentEventNum) != 0) { @@ -517,7 +517,7 @@ BOOL doLoadNativeColors(JNIEnv *env, jintArray jColors, BOOL useAppleColors) { UInt32 colorsArray[len]; UInt32 *colors = colorsArray; - [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ + [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ NSUInteger i; for (i = 0; i < len; i++) { colors[i] = RGB([CSystemColors getColor:i useAppleColor:useAppleColors]); @@ -587,7 +587,7 @@ BOOL doLoadNativeColors(JNIEnv *env, jintArray jColors, BOOL useAppleColors) { // Don't use acceptInputForMode because that doesn't setup autorelease pools properly BOOL isRunning = true; while (![mediatorObject shouldEndRunLoop] && isRunning) { - isRunning = [[NSRunLoop currentRunLoop] runMode:(inAWT ? [JNFRunLoop javaRunLoopMode] : NSDefaultRunLoopMode) + isRunning = [[NSRunLoop currentRunLoop] runMode:(inAWT ? [ThreadUtilities javaRunLoopMode] : NSDefaultRunLoopMode) beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.010]]; if (processEvents) { //We do not spin a runloop here as date is nil, so does not matter which mode to use @@ -654,7 +654,7 @@ BOOL doLoadNativeColors(JNIEnv *env, jintArray jColors, BOOL useAppleColors) { (JNIEnv *env, jobject self) { __block jboolean isOn = JNI_FALSE; - [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ + [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ NSUInteger modifiers = [NSEvent modifierFlags]; isOn = (modifiers & NSAlphaShiftKeyMask) != 0; }]; @@ -727,7 +727,7 @@ BOOL doLoadNativeColors(JNIEnv *env, jintArray jColors, BOOL useAppleColors) { Java_sun_font_FontManager_getFontPath (JNIEnv *env, jclass obj, jboolean noType1) { - return JNFNSToJavaString(env, @"/Library/Fonts"); + return NSStringToJavaString(env, @"/Library/Fonts"); } // This isn't yet used on unix, the implementation is added since shared @@ -869,7 +869,7 @@ JNIEXPORT jint JNICALL DEF_JNI_OnLoad(JavaVM *vm, void *reserved) { Java_sun_lwawt_macosx_LWCToolkit_getMultiClickTime(JNIEnv *env, jclass klass) { __block jint multiClickTime = 0; JNI_COCOA_ENTER(env); - [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ + [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ multiClickTime = (jint)([NSEvent doubleClickInterval] * 1000); }]; JNI_COCOA_EXIT(env); diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/PrintModel.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/PrintModel.m index 84e03dc7d6e3c..d25fbd8cae548 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/PrintModel.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/PrintModel.m @@ -26,8 +26,6 @@ #import "PrintModel.h" -#import - #import "PrinterView.h" #import "ThreadUtilities.h" #import "JNIUtilities.h" @@ -53,7 +51,7 @@ - (void)dealloc { - (BOOL)runPageSetup { __block BOOL fResult = NO; - [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ + [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ NSPageLayout* pageLayout = [NSPageLayout pageLayout]; fResult = ([pageLayout runModalWithPrintInfo:fPrintInfo] == NSOKButton); }]; @@ -64,7 +62,7 @@ - (BOOL)runPageSetup { - (BOOL)runJobSetup { __block BOOL fResult = NO; - [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ + [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ NSPrintPanel* printPanel = [NSPrintPanel printPanel]; fResult = ([printPanel runModalWithPrintInfo:fPrintInfo] == NSOKButton); }]; diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/PrinterSurfaceData.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/PrinterSurfaceData.m index 5a2916a38f275..8bcda8d485bc7 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/PrinterSurfaceData.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/PrinterSurfaceData.m @@ -26,8 +26,6 @@ #import "PrinterSurfaceData.h" #import "jni_util.h" -#import - //#define DEBUG 1 #if defined DEBUG diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/PrinterView.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/PrinterView.m index a64fba4eac319..17feca9fd7e31 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/PrinterView.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/PrinterView.m @@ -28,8 +28,6 @@ #import "java_awt_print_Pageable.h" #import "java_awt_print_PageFormat.h" -#import - #import "ThreadUtilities.h" #import "GeomUtilities.h" #import "JNIUtilities.h" @@ -106,7 +104,7 @@ - (void)drawRect:(NSRect)aRect CGContextSaveGState(cgRef); //04/28/2004: state needs to be saved here due to addition of lazy state management (*env)->CallVoidMethod(env, fPrinterJob, jm_printToPathGraphics, fCurPeekGraphics, fPrinterJob, - fCurPainter, fCurPageFormat, jPageIndex, context); // AWT_THREADING Safe (AWTRunLoop) + fCurPainter, fCurPageFormat, jPageIndex, context); CHECK_EXCEPTION(); CGContextRestoreGState(cgRef); @@ -122,9 +120,9 @@ - (NSString*)printJobTitle GET_CPRINTERJOB_CLASS_RETURN(nil); DECLARE_METHOD_RETURN(jm_getJobName, sjc_CPrinterJob, "getJobName", "()Ljava/lang/String;", nil); - jobject o = (*env)->CallObjectMethod(env, fPrinterJob, jm_getJobName); // AWT_THREADING Safe (known object) + jobject o = (*env)->CallObjectMethod(env, fPrinterJob, jm_getJobName); CHECK_EXCEPTION(); - id result = JNFJavaToNSString(env, o); + id result = JavaStringToNSString(env, o); (*env)->DeleteLocalRef(env, o); return result; } @@ -195,7 +193,7 @@ - (NSRect)rectForPage:(NSInteger)pageNumber } jobjectArray objectArray = (*env)->CallObjectMethod(env, fPrinterJob, - jm_getPageformatPrintablePeekgraphics, jPageNumber); // AWT_THREADING Safe (AWTRunLoopMode) + jm_getPageformatPrintablePeekgraphics, jPageNumber); CHECK_EXCEPTION(); if (objectArray != NULL) { // Get references to the return objects -> PageFormat, Printable, PeekGraphics @@ -214,7 +212,7 @@ - (NSRect)rectForPage:(NSInteger)pageNumber // Actually print and get the PageFormatArea jobject pageFormatArea = (*env)->CallObjectMethod(env, fPrinterJob, jm_printAndGetPageFormatArea, fCurPainter, - fCurPeekGraphics, fCurPageFormat, jPageNumber); // AWT_THREADING Safe (AWTRunLoopMode) + fCurPeekGraphics, fCurPageFormat, jPageNumber); CHECK_EXCEPTION(); if (pageFormatArea != NULL) { NSPrintingOrientation currentOrientation = diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/QuartzRenderer.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/QuartzRenderer.m index 242caf9c4e296..f97a7384fc759 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/QuartzRenderer.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/QuartzRenderer.m @@ -28,7 +28,6 @@ #import "sun_java2d_OSXSurfaceData.h" #import -#import #import "ImageSurfaceData.h" diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/QuartzSurfaceData.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/QuartzSurfaceData.m index b8299a9053bf6..b53863bad2d2c 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/QuartzSurfaceData.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/QuartzSurfaceData.m @@ -35,8 +35,6 @@ #import "sun_lwawt_macosx_CPrinterSurfaceData.h" #import "ImageSurfaceData.h" -#import - #import #import "ThreadUtilities.h" diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/CommonTextAccessibility.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/CommonTextAccessibility.m index 69791fd569dd0..007cbe9de8c54 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/CommonTextAccessibility.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/CommonTextAccessibility.m @@ -75,7 +75,7 @@ - (nullable NSString *)accessibilityValueAttribute sjm_getAccessibleName, fAccessible, fComponent); CHECK_EXCEPTION(); if (axName != NULL) { - NSString* str = JNFJavaToNSString(env, axName); + NSString* str = JavaStringToNSString(env, axName); (*env)->DeleteLocalRef(env, axName); return str; } @@ -100,7 +100,7 @@ - (nullable NSString *)accessibilityValueAttribute jobject jrange = (*env)->CallStaticObjectMethod(env, sjc_CAccessibleText, jm_getTextRange, axEditableText, 0, getAxTextCharCount(env, axEditableText, fComponent), fComponent); CHECK_EXCEPTION(); - NSString *string = JNFJavaToNSString(env, jrange); // AWT_THREADING Safe (AWTRunLoop) + NSString *string = JavaStringToNSString(env, jrange); (*env)->DeleteLocalRef(env, jrange); (*env)->DeleteLocalRef(env, axEditableText); @@ -116,7 +116,7 @@ - (NSRange)accessibilityVisibleCharacterRangeAttribute DECLARE_STATIC_METHOD_RETURN(jm_getVisibleCharacterRange, sjc_CAccessibleText, "getVisibleCharacterRange", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)[I", DEFAULT_RANGE); jintArray axTextRange = (*env)->CallStaticObjectMethod(env, sjc_CAccessibleText, - jm_getVisibleCharacterRange, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop) + jm_getVisibleCharacterRange, fAccessible, fComponent); CHECK_EXCEPTION(); if (axTextRange == NULL) return DEFAULT_RANGE; @@ -130,10 +130,10 @@ - (nullable NSString *)accessibilityStringForRangeAttribute:(NSRange)range DECLARE_STATIC_METHOD_RETURN(jm_getStringForRange, sjc_CAccessibleText, "getStringForRange", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;II)Ljava/lang/String;", nil); jstring jstringForRange = (jstring)(*env)->CallStaticObjectMethod(env, sjc_CAccessibleText, jm_getStringForRange, - fAccessible, fComponent, range.location, range.length); // AWT_THREADING Safe (AWTRunLoop) + fAccessible, fComponent, range.location, range.length); CHECK_EXCEPTION(); if (jstringForRange == NULL) return @""; - NSString* str = JNFJavaToNSString(env, jstringForRange); + NSString* str = JavaStringToNSString(env, jstringForRange); (*env)->DeleteLocalRef(env, jstringForRange); return str; } diff --git a/src/java.desktop/macosx/native/libawt_lwawt/font/AWTFont.m b/src/java.desktop/macosx/native/libawt_lwawt/font/AWTFont.m index 2772c91a89c9b..8ca4183ffd906 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/font/AWTFont.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/font/AWTFont.m @@ -23,8 +23,6 @@ * questions. */ -#import - #import "java_awt_Font.h" #import "sun_awt_PlatformFont.h" #import "sun_awt_FontDescriptor.h" @@ -310,9 +308,9 @@ static OSStatus CreateFSRef(FSRef *myFSRefPtr, NSString *inPath) jint i; for (i = 0; i < num; i++) { NSString *fontname = [filteredFonts objectAtIndex:i]; - jobject jFontName = JNFNSToJavaString(env, fontname); + jobject jFontName = NSStringToJavaString(env, fontname); jobject jFontFamilyName = - JNFNSToJavaString(env, GetFamilyNameForFontName(fontname)); + NSStringToJavaString(env, GetFamilyNameForFontName(fontname)); (*env)->CallVoidMethod(env, jthis, jm_registerFont, jFontName, jFontFamilyName); CHECK_EXCEPTION(); @@ -334,7 +332,7 @@ static OSStatus CreateFSRef(FSRef *myFSRefPtr, NSString *inPath) { JNI_COCOA_ENTER(env); - NSString *path = JNFJavaToNSString(env, filename); + NSString *path = JavaStringToNSString(env, filename); NSURL *url = [NSURL fileURLWithPath:(NSString *)path]; bool res = CTFontManagerRegisterFontsForURL((CFURLRef)url, kCTFontManagerScopeProcess, nil); #ifdef DEBUG @@ -434,7 +432,7 @@ static OSStatus CreateFSRef(FSRef *myFSRefPtr, NSString *inPath) JNI_COCOA_ENTER(env); awtFont = - [AWTFont awtFontForName:JNFJavaToNSString(env, nativeFontName) + [AWTFont awtFontForName:JavaStringToNSString(env, nativeFontName) style:style]; // autoreleased if (awtFont) { @@ -570,7 +568,7 @@ static OSStatus CreateFSRef(FSRef *myFSRefPtr, NSString *inPath) #ifdef DEBUG NSLog(@"Font is : %@", (NSString*)fontname); #endif - jstring jFontName = (jstring)JNFNSToJavaString(env, fontname); + jstring jFontName = (jstring)NSStringToJavaString(env, fontname); (*env)->CallBooleanMethod(env, arrayListOfString, addMID, jFontName); if ((*env)->ExceptionOccurred(env)) { return; diff --git a/src/java.desktop/macosx/native/libawt_lwawt/font/AWTStrike.m b/src/java.desktop/macosx/native/libawt_lwawt/font/AWTStrike.m index 5b1ec30936d87..2c991a2fc2ffd 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/font/AWTStrike.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/font/AWTStrike.m @@ -23,7 +23,6 @@ * questions. */ -#import #import "java_awt_geom_PathIterator.h" #import "sun_font_CStrike.h" #import "sun_font_CStrikeDisposer.h" diff --git a/src/java.desktop/macosx/native/libawt_lwawt/font/CCharToGlyphMapper.m b/src/java.desktop/macosx/native/libawt_lwawt/font/CCharToGlyphMapper.m index a2a150c2be5ed..393d33bdbe6ee 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/font/CCharToGlyphMapper.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/font/CCharToGlyphMapper.m @@ -25,8 +25,6 @@ #import "JNIUtilities.h" -#import - #import "AWTFont.h" #import "CoreTextSupport.h" diff --git a/src/java.desktop/macosx/native/libawt_lwawt/font/CGGlyphImages.m b/src/java.desktop/macosx/native/libawt_lwawt/font/CGGlyphImages.m index d6940ed6f728c..d8deec3b28355 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/font/CGGlyphImages.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/font/CGGlyphImages.m @@ -24,8 +24,8 @@ */ #import // for vImage_Buffer -#import +#import "JNIUtilities.h" #import "CGGlyphImages.h" #import "CoreTextSupport.h" #import "fontscalerdefs.h" // contains the definition of GlyphInfo struct diff --git a/src/java.desktop/macosx/native/libawt_lwawt/java2d/opengl/CGLGraphicsConfig.m b/src/java.desktop/macosx/native/libawt_lwawt/java2d/opengl/CGLGraphicsConfig.m index 507290c0895c9..ca8717bc81993 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/java2d/opengl/CGLGraphicsConfig.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/java2d/opengl/CGLGraphicsConfig.m @@ -33,7 +33,6 @@ #import #import #import -#import /** * Disposes all memory and resources associated with the given @@ -123,6 +122,7 @@ __block jlong ret = 0L; JNI_COCOA_ENTER(env); [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ + JNIEnv *env = [ThreadUtilities getJNIEnvUncached]; J2dRlsTraceLn(J2D_TRACE_INFO, "CGLGraphicsConfig_getCGLConfigInfo"); @@ -288,6 +288,7 @@ [NSOpenGLContext clearCurrentContext]; ret = ptr_to_jlong(cglinfo); [pool drain]; + }]; JNI_COCOA_EXIT(env); return ret; diff --git a/src/java.desktop/macosx/native/libawt_lwawt/java2d/opengl/CGLLayer.h b/src/java.desktop/macosx/native/libawt_lwawt/java2d/opengl/CGLLayer.h index b5428a7ff1fe6..b4fc62fbbaaba 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/java2d/opengl/CGLLayer.h +++ b/src/java.desktop/macosx/native/libawt_lwawt/java2d/opengl/CGLLayer.h @@ -26,8 +26,6 @@ #ifndef CGLLayer_h_Included #define CGLLayer_h_Included -#import - @interface CGLLayer : CAOpenGLLayer { @private diff --git a/src/java.desktop/macosx/native/libawt_lwawt/java2d/opengl/CGLSurfaceData.m b/src/java.desktop/macosx/native/libawt_lwawt/java2d/opengl/CGLSurfaceData.m index fe4ffc4504d92..b90d4ff00eacb 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/java2d/opengl/CGLSurfaceData.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/java2d/opengl/CGLSurfaceData.m @@ -315,7 +315,7 @@ extern CGLError CGLTexImageIOSurface2D( CGLSDOps *dstCGLOps = (CGLSDOps *)dstOps->privOps; CGLLayer *layer = (CGLLayer*)dstCGLOps->layer; if (layer != NULL) { - [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ + [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ AWT_ASSERT_APPKIT_THREAD; [layer setNeedsDisplay]; }]; diff --git a/src/java.desktop/macosx/native/libosx/CFileManager.m b/src/java.desktop/macosx/native/libosx/CFileManager.m index e89847966cfb6..9106e8241321a 100644 --- a/src/java.desktop/macosx/native/libosx/CFileManager.m +++ b/src/java.desktop/macosx/native/libosx/CFileManager.m @@ -26,12 +26,9 @@ #import "com_apple_eio_FileManager.h" #import "JNIUtilities.h" - -#import -#import - #import "ThreadUtilities.h" +#import /* * Class: com_apple_eio_FileManager @@ -42,7 +39,7 @@ (JNIEnv *env, jclass clz, jstring javaFilename, jint type, jint creator) { JNI_COCOA_ENTER(env); - NSString *filename = JNFNormalizedNSStringForPath(env, javaFilename); + NSString *filename = NormalizedPathNSStringFromJavaString(env, javaFilename); NSDictionary *attr = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithInt:type], NSFileHFSTypeCode, [NSNumber numberWithInt:creator], NSFileHFSCreatorCode, nil]; @@ -59,7 +56,7 @@ (JNIEnv *env, jclass ckz, jstring javaFilename, jint type) { JNI_COCOA_ENTER(env); - NSString *filename = JNFNormalizedNSStringForPath(env, javaFilename); + NSString *filename = NormalizedPathNSStringFromJavaString(env, javaFilename); NSDictionary *attr = [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:type] forKey:NSFileHFSTypeCode]; [[NSFileManager defaultManager] changeFileAttributes:attr atPath:filename]; JNI_COCOA_EXIT(env); @@ -74,7 +71,7 @@ (JNIEnv *env, jclass clz, jstring javaFilename, jint creator) { JNI_COCOA_ENTER(env); - NSString *filename = JNFNormalizedNSStringForPath(env, javaFilename); + NSString *filename = NormalizedPathNSStringFromJavaString(env, javaFilename); NSDictionary *attr = [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:creator] forKey:NSFileHFSCreatorCode]; [[NSFileManager defaultManager] changeFileAttributes:attr atPath:filename]; JNI_COCOA_EXIT(env); @@ -90,7 +87,7 @@ { jint type = 0; JNI_COCOA_ENTER(env); - NSString *filename = JNFNormalizedNSStringForPath(env, javaFilename); + NSString *filename = NormalizedPathNSStringFromJavaString(env, javaFilename); NSDictionary *attributes = [[NSFileManager defaultManager] fileAttributesAtPath:filename traverseLink:YES]; NSNumber *val = [attributes objectForKey:NSFileHFSTypeCode]; type = [val intValue]; @@ -108,7 +105,7 @@ { jint creator = 0; JNI_COCOA_ENTER(env); - NSString *filename = JNFNormalizedNSStringForPath(env, javaFilename); + NSString *filename = NormalizedPathNSStringFromJavaString(env, javaFilename); NSDictionary *attributes = [[NSFileManager defaultManager] fileAttributesAtPath:filename traverseLink:YES]; NSNumber *val = [attributes objectForKey:NSFileHFSCreatorCode]; creator = [val intValue]; @@ -133,7 +130,7 @@ char path[PATH_MAX]; if (FSRefMakePath(&foundRef, (UInt8 *)path, sizeof(path)) == noErr) { NSString *filenameString = [[NSFileManager defaultManager] stringWithFileSystemRepresentation:path length:strlen(path)]; - filename = JNFNormalizedJavaStringForPath(env, filenameString); + filename = NormalizedPathJavaStringFromNSString(env, filenameString); } } @@ -152,10 +149,10 @@ { JNI_COCOA_ENTER(env); - NSURL *url = [NSURL URLWithString:JNFNormalizedNSStringForPath(env, urlString)]; + NSURL *url = [NSURL URLWithString:NormalizedPathNSStringFromJavaString(env, urlString)]; // Radar 3208005: Run this on the main thread; file:// style URLs will hang otherwise. - [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ + [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ [[NSWorkspace sharedWorkspace] openURL:url]; }]; @@ -174,15 +171,15 @@ jstring filename = NULL; JNI_COCOA_ENTER(env); - NSString *resourceName = JNFNormalizedNSStringForPath(env, javaResourceName); - NSString *subDirectory = JNFNormalizedNSStringForPath(env, javaSubDirName); - NSString *typeName = JNFNormalizedNSStringForPath(env, javaTypeName); + NSString *resourceName = NormalizedPathNSStringFromJavaString(env, javaResourceName); + NSString *subDirectory = NormalizedPathNSStringFromJavaString(env, javaSubDirName); + NSString *typeName = NormalizedPathNSStringFromJavaString(env, javaTypeName); NSString *path = [[NSBundle mainBundle] pathForResource:resourceName ofType:typeName inDirectory:subDirectory]; - filename = JNFNormalizedJavaStringForPath(env, path); + filename = NormalizedPathJavaStringFromNSString(env, path); JNI_COCOA_EXIT(env); return filename; @@ -201,7 +198,7 @@ JNI_COCOA_ENTER(env); NSBundle *mainBundle = [NSBundle mainBundle]; - filename = JNFNormalizedJavaStringForPath(env, [mainBundle bundlePath]); + filename = NormalizedPathJavaStringFromNSString(env, [mainBundle bundlePath]); JNI_COCOA_EXIT(env); return filename; @@ -220,9 +217,9 @@ __block BOOL returnValue = NO; JNI_COCOA_ENTER(env); - NSString * path = JNFNormalizedNSStringForPath(env, fileName); + NSString * path = NormalizedPathNSStringFromJavaString(env, fileName); NSURL *url = [NSURL fileURLWithPath:path]; - [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ + [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ returnValue = [[NSFileManager defaultManager] trashItemAtURL:url resultingItemURL:nil @@ -246,8 +243,8 @@ __block jboolean returnValue = JNI_FALSE; JNI_COCOA_ENTER(env); - NSString *path = JNFNormalizedNSStringForPath(env, url); - [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ + NSString *path = NormalizedPathNSStringFromJavaString(env, url); + [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ returnValue = [[NSWorkspace sharedWorkspace] selectFile:path inFileViewerRootedAtPath:@""]; }]; diff --git a/src/java.desktop/macosx/native/libosxapp/JNIUtilities.h b/src/java.desktop/macosx/native/libosxapp/JNIUtilities.h index 475602334065b..41dd4c48b75c9 100644 --- a/src/java.desktop/macosx/native/libosxapp/JNIUtilities.h +++ b/src/java.desktop/macosx/native/libosxapp/JNIUtilities.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -237,4 +237,14 @@ [pool drain]; \ }; +/******** STRING CONVERSION SUPPORT *********/ + +JNIEXPORT NSString* JavaStringToNSString(JNIEnv *env, jstring jstr); + +JNIEXPORT jstring NSStringToJavaString(JNIEnv* env, NSString *str); + +JNIEXPORT NSString* NormalizedPathNSStringFromJavaString(JNIEnv *env, jstring pathStr); + +JNIEXPORT jstring NormalizedPathJavaStringFromNSString(JNIEnv* env, NSString *str); + #endif /* __JNIUTILITIES_H */ diff --git a/src/java.desktop/macosx/native/libosxapp/JNIUtilities.m b/src/java.desktop/macosx/native/libosxapp/JNIUtilities.m new file mode 100644 index 0000000000000..75d1780328225 --- /dev/null +++ b/src/java.desktop/macosx/native/libosxapp/JNIUtilities.m @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +#include "JNIUtilities.h" + +NSString* JavaStringToNSString(JNIEnv *env, jstring jstr) { + if (jstr == NULL) { + return NULL; + } + jsize len = (*env)->GetStringLength(env, jstr); + const jchar *chars = (*env)->GetStringChars(env, jstr, NULL); + if (chars == NULL) { + return NULL; + } + NSString *result = [NSString stringWithCharacters:(UniChar *)chars length:len]; + (*env)->ReleaseStringChars(env, jstr, chars); + return result; +} + +jstring NSStringToJavaString(JNIEnv* env, NSString *str) { + + if (str == NULL) { + return NULL; + } + jstring jStr = (*env)->NewStringUTF(env, [str UTF8String]); + CHECK_EXCEPTION(); + return jStr; +} + +/* + * These next conversion functions are for file system paths. + * The NSString needs to be in de-composed UTF-16 format for the Apple file system + * The Java String needs to be in pre-composed UTF-16 format for display by Java. + * https://developer.apple.com/library/archive/qa/qa1235/_index.html + * has some information on this. + */ + +/* + * Returns an NSString in decomposed UTF16 format that is compatible with HFS's + * expectation of the UTF16 format for file system paths. + * + * Example string: "/Users/Amélie/" + * + * Java's UTF16 string is "/ U s e r s / A m \351 l i e /" + * macOS UTF16 string suitable for HFS is "/ U s e r s / A m e \314 \201 l i e /" + * + * There is no direct API that takes in NSString UTF16 encoded by Java + * and produces NSString UTF16 for HFS, so we first need to decompose it + * into chars (suitable for low level C file APIs), and only then + * create NSString representation of this decomposition back into UTF16 string. + * + * https://developer.apple.com/documentation/foundation/nsstring/1414559-filesystemrepresentation?language=objc + * describes how to get a file system representation as a char* from an NSString + * and then using FileManager (!) convert it to an NSString. + * But we want an NSString. + * So the steps are + * 1) Convert to NSString + * 2) call [NSString fileSystemRepresentation] which gives us a char* + * 3) Convert the returned char* to an NSString using FileManager (is there a better way?) + */ +NSString* NormalizedPathNSStringFromJavaString(JNIEnv *env, jstring pathStr) { + if (pathStr == NULL) { + return nil; + } + NSString *nsStr = JavaStringToNSString(env, pathStr); + if (nsStr == NULL) { + return nil; + } + const char* chs = [nsStr fileSystemRepresentation]; + int len = strlen(chs); + NSString* result = [[NSFileManager defaultManager] + stringWithFileSystemRepresentation:chs length:len]; + return result; +} + +/* + * Given what is (potentially) a de-composed NSString, convert it to pre-composed + * Then convert it into a Java String. + */ +jstring NormalizedPathJavaStringFromNSString(JNIEnv* env, NSString *str) { + if (str == nil) { + return NULL; + } + NSString *normStr = [str precomposedStringWithCanonicalMapping]; + return NSStringToJavaString(env, normStr); +} diff --git a/src/java.desktop/macosx/native/libosxapp/NSApplicationAWT.h b/src/java.desktop/macosx/native/libosxapp/NSApplicationAWT.h index 888621604f3d8..0bf8cf75aff13 100644 --- a/src/java.desktop/macosx/native/libosxapp/NSApplicationAWT.h +++ b/src/java.desktop/macosx/native/libosxapp/NSApplicationAWT.h @@ -23,14 +23,8 @@ * questions. */ -/* - * Must include this before JavaNativeFoundation.h to get jni.h from build - */ -#include "jni.h" -#include "jni_util.h" - +#import "JNIUtilities.h" #import -#import JNIEXPORT @interface NSApplicationAWT : NSApplication { NSString *fApplicationName; diff --git a/src/java.desktop/macosx/native/libosxapp/NSApplicationAWT.m b/src/java.desktop/macosx/native/libosxapp/NSApplicationAWT.m index 4cb5bc0ca57a0..808814612c5a8 100644 --- a/src/java.desktop/macosx/native/libosxapp/NSApplicationAWT.m +++ b/src/java.desktop/macosx/native/libosxapp/NSApplicationAWT.m @@ -160,9 +160,6 @@ - (void)finishLaunching [super finishLaunching]; [[NSUserNotificationCenter defaultUserNotificationCenter] setDelegate:self]; - - // inform any interested parties that the AWT has arrived and is pumping - [[NSNotificationCenter defaultCenter] postNotificationName:JNFRunLoopDidStartNotification object:self]; } - (BOOL)userNotificationCenter:(NSUserNotificationCenter *)center @@ -271,7 +268,7 @@ - (void) registerWithProcessManager // HACK BEGIN // The following is necessary to make the java process behave like a // proper foreground application... - [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ + [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ ProcessSerialNumber psn; GetCurrentProcess(&psn); TransformProcessType(&psn, kProcessTransformToForegroundApplication); @@ -326,8 +323,8 @@ - (void) setDockIconWithEnv:(JNIEnv *)env { + (void) runAWTLoopWithApp:(NSApplication*)app { NSAutoreleasePool *pool = [NSAutoreleasePool new]; - // Make sure that when we run in AWTRunLoopMode we don't exit randomly - [[NSRunLoop currentRunLoop] addPort:[NSPort port] forMode:[JNFRunLoop javaRunLoopMode]]; + // Make sure that when we run in javaRunLoopMode we don't exit randomly + [[NSRunLoop currentRunLoop] addPort:[NSPort port] forMode:[ThreadUtilities javaRunLoopMode]]; do { @try { diff --git a/src/java.desktop/macosx/native/libosxapp/PropertiesUtilities.h b/src/java.desktop/macosx/native/libosxapp/PropertiesUtilities.h index ecf810de8c986..39af308b4e414 100644 --- a/src/java.desktop/macosx/native/libosxapp/PropertiesUtilities.h +++ b/src/java.desktop/macosx/native/libosxapp/PropertiesUtilities.h @@ -23,14 +23,10 @@ * questions. */ -/* - * Must include this before JavaNativeFoundation.h to get jni.h from build - */ #include "jni.h" #include "jni_util.h" #import -#import JNIEXPORT @interface PropertiesUtilities : NSObject diff --git a/src/java.desktop/macosx/native/libosxapp/PropertiesUtilities.m b/src/java.desktop/macosx/native/libosxapp/PropertiesUtilities.m index f727e2e22b92d..10b0e00ed3961 100644 --- a/src/java.desktop/macosx/native/libosxapp/PropertiesUtilities.m +++ b/src/java.desktop/macosx/native/libosxapp/PropertiesUtilities.m @@ -33,12 +33,12 @@ + (NSString *) javaSystemPropertyForKey:(NSString *)key withEnv:(JNIEnv *)env { DECLARE_STATIC_METHOD_RETURN(jm_getProperty, jc_System, "getProperty", "(Ljava/lang/String;)Ljava/lang/String;", nil); - jstring jKey = JNFNSToJavaString(env, key); + jstring jKey = NSStringToJavaString(env, key); jstring jValue = (*env)->CallStaticObjectMethod(env, jc_System, jm_getProperty, jKey); (*env)->DeleteLocalRef(env, jKey); CHECK_EXCEPTION_NULL_RETURN(jValue, nil); - NSString *value = JNFJavaToNSString(env, jValue); + NSString *value = JavaStringToNSString(env, jValue); (*env)->DeleteLocalRef(env, jValue); return value; } diff --git a/src/java.desktop/macosx/native/libosxapp/ThreadUtilities.h b/src/java.desktop/macosx/native/libosxapp/ThreadUtilities.h index 4e99274578fda..24fb2f61d8625 100644 --- a/src/java.desktop/macosx/native/libosxapp/ThreadUtilities.h +++ b/src/java.desktop/macosx/native/libosxapp/ThreadUtilities.h @@ -125,16 +125,16 @@ do { \ // -------------------------------------------------------------------------- __attribute__((visibility("default"))) -@interface ThreadUtilities { } +@interface ThreadUtilities : NSObject { } /* Extend NSObject so can call performSelectorOnMainThread */ + (JNIEnv*)getJNIEnv; + (JNIEnv*)getJNIEnvUncached; + (void)detachCurrentThread; + (void)setAppkitThreadGroup:(jobject)group; -//Wrappers for the corresponding JNFRunLoop methods with a check for main thread + (void)performOnMainThreadWaiting:(BOOL)wait block:(void (^)())block; + (void)performOnMainThread:(SEL)aSelector on:(id)target withObject:(id)arg waitUntilDone:(BOOL)wait; ++ (NSString*)javaRunLoopMode; @end JNIEXPORT void OSXAPP_SetJavaVM(JavaVM *vm); diff --git a/src/java.desktop/macosx/native/libosxapp/ThreadUtilities.m b/src/java.desktop/macosx/native/libosxapp/ThreadUtilities.m index 95443bcc73d8e..74be17039c3f5 100644 --- a/src/java.desktop/macosx/native/libosxapp/ThreadUtilities.m +++ b/src/java.desktop/macosx/native/libosxapp/ThreadUtilities.m @@ -24,7 +24,6 @@ */ #import -#import #import #import "ThreadUtilities.h" @@ -34,6 +33,8 @@ JavaVM *jvm = NULL; static JNIEnv *appKitEnv = NULL; static jobject appkitThreadGroup = NULL; +static NSString* JavaRunLoopMode = @"javaRunLoopMode"; +static NSArray *javaModes = nil; static inline void attachCurrentThread(void** env) { if ([NSThread isMainThread]) { @@ -49,6 +50,15 @@ static inline void attachCurrentThread(void** env) { @implementation ThreadUtilities ++ (void)initialize { + /* All the standard modes plus ours */ + javaModes = [[NSArray alloc] initWithObjects:NSDefaultRunLoopMode, + NSModalPanelRunLoopMode, + NSEventTrackingRunLoopMode, + JavaRunLoopMode, + nil]; +} + + (JNIEnv*)getJNIEnv { AWT_ASSERT_APPKIT_THREAD; if (appKitEnv == NULL) { @@ -71,11 +81,34 @@ + (void)setAppkitThreadGroup:(jobject)group { appkitThreadGroup = group; } +/* This is needed because we can't directly pass a block to + * performSelectorOnMainThreadWaiting .. since it expects a selector + */ ++ (void)invokeBlock:(void (^)())block { + block(); +} + +/* + * When running a block where either we don't wait, or it needs to run on another thread + * we need to copy it from stack to heap, use the copy in the call and release after use. + * Do this only when we must because it could be expensive. + * Note : if waiting cross-thread, possibly the stack allocated copy is accessible ? + */ ++ (void)invokeBlockCopy:(void (^)(void))blockCopy { + blockCopy(); + Block_release(blockCopy); +} + + (void)performOnMainThreadWaiting:(BOOL)wait block:(void (^)())block { if ([NSThread isMainThread] && wait == YES) { block(); } else { - [JNFRunLoop performOnMainThreadWaiting:wait withBlock:block]; + if (wait == YES) { + [self performOnMainThread:@selector(invokeBlock:) on:self withObject:block waitUntilDone:YES]; + } else { + void (^blockCopy)(void) = Block_copy(block); + [self performOnMainThread:@selector(invokeBlockCopy:) on:self withObject:blockCopy waitUntilDone:NO]; + } } } @@ -83,10 +116,14 @@ + (void)performOnMainThread:(SEL)aSelector on:(id)target withObject:(id)arg wait if ([NSThread isMainThread] && wait == YES) { [target performSelector:aSelector withObject:arg]; } else { - [JNFRunLoop performOnMainThread:aSelector on:target withObject:arg waitUntilDone:wait]; + [target performSelectorOnMainThread:aSelector withObject:arg waitUntilDone:wait modes:javaModes]; } } ++ (NSString*)javaRunLoopMode { + return JavaRunLoopMode; +} + @end diff --git a/src/java.desktop/macosx/native/libosxui/AquaFileView.m b/src/java.desktop/macosx/native/libosxui/AquaFileView.m index b8e8c7f734faa..479d0cacb54b5 100644 --- a/src/java.desktop/macosx/native/libosxui/AquaFileView.m +++ b/src/java.desktop/macosx/native/libosxui/AquaFileView.m @@ -30,7 +30,6 @@ #import // for MAXPATHLEN #import -#import /* * Class: com_apple_laf_AquaFileView @@ -44,7 +43,7 @@ jstring returnValue = NULL; JNI_COCOA_ENTER(env); - returnValue = JNFNSToJavaString(env, getRunningJavaBundle()); + returnValue = NSStringToJavaString(env, getRunningJavaBundle()); JNI_COCOA_EXIT(env); return returnValue; @@ -61,7 +60,7 @@ jstring returnValue = NULL; JNI_COCOA_ENTER(env); - returnValue = JNFNSToJavaString(env, [[NSBundle bundleWithIdentifier:@"com.apple.JavaVM"] bundlePath]); + returnValue = NSStringToJavaString(env, [[NSBundle bundleWithIdentifier:@"com.apple.JavaVM"] bundlePath]); JNI_COCOA_EXIT(env); return returnValue; @@ -79,7 +78,7 @@ JNI_COCOA_ENTER(env); CFStringRef machineName = CSCopyMachineName(); - returnValue = JNFNSToJavaString(env, (NSString*)machineName); + returnValue = NSStringToJavaString(env, (NSString*)machineName); if (machineName != NULL) { CFRelease(machineName); @@ -169,7 +168,7 @@ if (theErr == noErr) { CFMutableStringRef mutableDisplayName = CFStringCreateMutableCopy(NULL, 0, displayName); CFStringNormalize(mutableDisplayName, kCFStringNormalizationFormC); - returnValue = JNFNSToJavaString(env, (NSString *)mutableDisplayName); + returnValue = NSStringToJavaString(env, (NSString *)mutableDisplayName); CFRelease(mutableDisplayName); } diff --git a/src/java.desktop/macosx/native/libosxui/AquaLookAndFeel.m b/src/java.desktop/macosx/native/libosxui/AquaLookAndFeel.m index 50ac4ba51e222..2cfd5b7118acd 100644 --- a/src/java.desktop/macosx/native/libosxui/AquaLookAndFeel.m +++ b/src/java.desktop/macosx/native/libosxui/AquaLookAndFeel.m @@ -23,12 +23,9 @@ * questions. */ -// Must include this before JavaNativeFoundation.h to get jni.h from build #include "jni.h" #include "jni_util.h" -#import - /* * Empty JNI_OnLoad - needed to prevent: * AWT's JNI_OnLoad called multiple times diff --git a/src/java.desktop/macosx/native/libosxui/AquaNativeResources.m b/src/java.desktop/macosx/native/libosxui/AquaNativeResources.m index 474e57f7fc4be..27128ea43fa88 100644 --- a/src/java.desktop/macosx/native/libosxui/AquaNativeResources.m +++ b/src/java.desktop/macosx/native/libosxui/AquaNativeResources.m @@ -26,7 +26,6 @@ #import "com_apple_laf_AquaNativeResources.h" #import -#import /* * Class: com_apple_laf_AquaNativeResources diff --git a/src/java.desktop/macosx/native/libosxui/JRSUIConstantSync.m b/src/java.desktop/macosx/native/libosxui/JRSUIConstantSync.m index b3fc9f1e3e378..de5e8b26a7616 100644 --- a/src/java.desktop/macosx/native/libosxui/JRSUIConstantSync.m +++ b/src/java.desktop/macosx/native/libosxui/JRSUIConstantSync.m @@ -23,7 +23,7 @@ * questions. */ -#import +#import "JNIUtilities.h" #import #import "apple_laf_JRSUIConstants.h" diff --git a/src/java.desktop/macosx/native/libosxui/JRSUIController.m b/src/java.desktop/macosx/native/libosxui/JRSUIController.m index 0f92f43fe8af5..b484319b06ecd 100644 --- a/src/java.desktop/macosx/native/libosxui/JRSUIController.m +++ b/src/java.desktop/macosx/native/libosxui/JRSUIController.m @@ -23,7 +23,7 @@ * questions. */ -#import +#import "JNIUtilities.h" #import #import "apple_laf_JRSUIControl.h" diff --git a/src/java.desktop/macosx/native/libosxui/JRSUIFocus.m b/src/java.desktop/macosx/native/libosxui/JRSUIFocus.m index c5dca665d17db..89741dfe332d8 100644 --- a/src/java.desktop/macosx/native/libosxui/JRSUIFocus.m +++ b/src/java.desktop/macosx/native/libosxui/JRSUIFocus.m @@ -23,7 +23,7 @@ * questions. */ -#import +#import "JNIUtilities.h" #import "apple_laf_JRSUIFocus.h" #import "apple_laf_JRSUIControl.h" diff --git a/src/java.desktop/macosx/native/libosxui/ScreenMenu.h b/src/java.desktop/macosx/native/libosxui/ScreenMenu.h index 65f3d85bc2397..21402d68315e7 100644 --- a/src/java.desktop/macosx/native/libosxui/ScreenMenu.h +++ b/src/java.desktop/macosx/native/libosxui/ScreenMenu.h @@ -25,4 +25,3 @@ #import #import -#import diff --git a/src/java.desktop/macosx/native/libosxui/ScreenMenu.m b/src/java.desktop/macosx/native/libosxui/ScreenMenu.m index 1a19f03fce57e..752f424c3d113 100644 --- a/src/java.desktop/macosx/native/libosxui/ScreenMenu.m +++ b/src/java.desktop/macosx/native/libosxui/ScreenMenu.m @@ -31,7 +31,6 @@ #import "java_awt_event_InputEvent.h" #import "java_awt_event_MouseEvent.h" -#import #import #import "ThreadUtilities.h" @@ -109,7 +108,7 @@ - (void)menuWillOpen:(NSMenu *)menu //NSLog(@"menuWillOpen %@", [menu title]); GET_SCREENMENU_CLASS(); DECLARE_METHOD(jm_ScreenMenu_invokeOpenLater, sjc_ScreenMenu, "invokeOpenLater", "()V"); - (*env)->CallVoidMethod(env, self.javaObject, jm_ScreenMenu_invokeOpenLater); // AWT_THREADING Safe (AWTRunLoopMode) + (*env)->CallVoidMethod(env, self.javaObject, jm_ScreenMenu_invokeOpenLater); CHECK_EXCEPTION(); JNI_COCOA_EXIT(env); @@ -129,7 +128,7 @@ - (void)menuDidClose:(NSMenu *)menu //NSLog(@"menuDidClose %@", [menu title]); GET_SCREENMENU_CLASS(); DECLARE_METHOD(jm_ScreenMenu_invokeMenuClosing, sjc_ScreenMenu, "invokeMenuClosing", "()V"); - (*env)->CallVoidMethod(env, self.javaObject, jm_ScreenMenu_invokeMenuClosing); // AWT_THREADING Safe (AWTRunLoopMode) + (*env)->CallVoidMethod(env, self.javaObject, jm_ScreenMenu_invokeMenuClosing); CHECK_EXCEPTION(); JNI_COCOA_EXIT(env); } @@ -150,12 +149,22 @@ - (void)handleJavaMenuItemTargetedAtIndex:(NSUInteger)menuIndex rect:(NSRect)rec GET_SCREENMENU_CLASS(); DECLARE_METHOD(jm_ScreenMenu_updateSelectedItem, sjc_ScreenMenu, "handleItemTargeted", "(IIIII)V"); (*env)->CallVoidMethod(env, self.javaObject, jm_ScreenMenu_updateSelectedItem, menuIndex, - NSMinY(rect), NSMinX(rect), NSMaxY(rect), NSMaxX(rect)); // AWT_THREADING Safe (AWTRunLoopMode) + NSMinY(rect), NSMinX(rect), NSMaxY(rect), NSMaxX(rect)); CHECK_EXCEPTION(); JNI_COCOA_EXIT(env); } +/* + * The input is an NSTimeInterval (a double representing seconds and fractions of seconds) + * 0.0 means midnight Jan 1, 2001. + * The output is a Java long representing time in milliseconds since midnight Jan 1st 1970. + * There is a Cocoa constant representing that difference : NSTimeIntervalSince1970 + */ +static jlong NSTimeIntervalToJavaMilliseconds(NSTimeInterval interval) { + NSTimeInterval interval1970 = interval + NSTimeIntervalSince1970; + return (jlong)(interval1970 * 1000); +} // Called from event handler callback - (void)handleJavaMouseEvent:(NSEvent *)event @@ -187,7 +196,7 @@ - (void)handleJavaMouseEvent:(NSEvent *)event jint javaModifiers = ns2awtModifiers([event modifierFlags]) | ns2awtMouseButton([event buttonNumber]); // Get the event time - jlong javaWhen = JNFNSTimeIntervalToJavaMillis([event timestamp]); + jlong javaWhen = NSTimeIntervalToJavaMilliseconds([event timestamp]); // Call the mouse event handler, which will generate Java mouse events. JNIEnv *env = [ThreadUtilities getJNIEnv]; @@ -195,7 +204,7 @@ - (void)handleJavaMouseEvent:(NSEvent *)event GET_SCREENMENU_CLASS(); DECLARE_METHOD(jm_ScreenMenu_handleMouseEvent, sjc_ScreenMenu, "handleMouseEvent", "(IIIIJ)V"); (*env)->CallVoidMethod(env, self.javaObject, jm_ScreenMenu_handleMouseEvent, - javaKind, javaX, javaY, javaModifiers, javaWhen); // AWT_THREADING Safe (AWTRunLoopMode) + javaKind, javaX, javaY, javaModifiers, javaWhen); CHECK_EXCEPTION(); JNI_COCOA_EXIT(env); } @@ -221,7 +230,7 @@ - (void)handleJavaMouseEvent:(NSEvent *)event delegate = [[[NativeToJavaDelegate alloc] initFromMenu:menu javaObj:listenerRef] autorelease]; CFRetain(delegate); // GC - [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^{ + [ThreadUtilities performOnMainThreadWaiting:YES block:^{ NSMenu *menu = delegate.nsmenu; if ([menu isJavaMenu]) { [menu setDelegate:delegate]; @@ -248,7 +257,7 @@ - (void)handleJavaMouseEvent:(NSEvent *)event NativeToJavaDelegate *delegate = (NativeToJavaDelegate *)jlong_to_ptr(fModelPtr); - [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^{ + [ThreadUtilities performOnMainThreadWaiting:YES block:^{ NSMenu *menu = delegate.nsmenu; [menu setJavaMenuDelegate:nil]; [menu setDelegate:nil]; diff --git a/src/java.desktop/macosx/native/libsplashscreen/splashscreen_sys.m b/src/java.desktop/macosx/native/libsplashscreen/splashscreen_sys.m index 8750786b53971..c28fe904102dd 100644 --- a/src/java.desktop/macosx/native/libsplashscreen/splashscreen_sys.m +++ b/src/java.desktop/macosx/native/libsplashscreen/splashscreen_sys.m @@ -29,7 +29,6 @@ #import #include -#import #import "NSApplicationAWT.h" #include @@ -226,7 +225,7 @@ static int isInAquaSession() { // If we are running SWT we should not start a runLoop if (!isSWTRunning()) { - [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^() { + [ThreadUtilities performOnMainThreadWaiting:NO block:^() { [NSApplicationAWT runAWTLoopWithApp:[NSApplicationAWT sharedApplication]]; }]; } @@ -243,7 +242,7 @@ static int isInAquaSession() { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; pthread_mutex_destroy(&splash->lock); - [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ + [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ if (splash->window) { [splash->window orderOut:nil]; [splash->window release]; @@ -282,7 +281,7 @@ static int isInAquaSession() { SplashRedrawWindow(Splash * splash) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ + [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ // drop the reference to the old view and image [splash->window setContentView: nil]; SplashUpdateScreenData(splash); @@ -341,7 +340,7 @@ static int isInAquaSession() { void SplashReconfigureNow(Splash * splash) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ + [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ SplashCenter(splash); if (!splash->window) { @@ -430,7 +429,7 @@ void SplashReconfigureNow(Splash * splash) { fcntl(splash->controlpipe[0], F_GETFL, 0) | O_NONBLOCK); splash->time = SplashTime(); splash->currentFrame = 0; - [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ + [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ SplashCenter(splash); splash->window = (void*) [[NSWindow alloc] @@ -445,7 +444,7 @@ void SplashReconfigureNow(Splash * splash) { }]; fflush(stdout); if (splash->window) { - [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ + [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ [splash->window orderFrontRegardless]; }]; SplashRedrawWindow(splash); diff --git a/test/jdk/java/awt/Window/MainKeyWindowTest/libTestMainKeyWindow.m b/test/jdk/java/awt/Window/MainKeyWindowTest/libTestMainKeyWindow.m index ea585a79514fc..11f329757a7b0 100644 --- a/test/jdk/java/awt/Window/MainKeyWindowTest/libTestMainKeyWindow.m +++ b/test/jdk/java/awt/Window/MainKeyWindowTest/libTestMainKeyWindow.m @@ -24,11 +24,45 @@ */ #import -#import +#import static NSWindow *testWindow; static NSColorPanel *colorPanel; +#define JNI_COCOA_ENTER(env) \ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; \ + @try { + +#define JNI_COCOA_EXIT(env) \ + } \ + @catch (NSException *e) { \ + NSLog(@"%@", [e callStackSymbols]); \ + } \ + @finally { \ + [pool drain]; \ + }; + +/* + * Pass the block to a selector of a class that extends NSObject + * There is no need to copy the block since this class always waits. + */ +@interface BlockRunner : NSObject { } + ++ (void)invokeBlock:(void (^)())block; +@end + +@implementation BlockRunner + ++ (void)invokeBlock:(void (^)())block{ + block(); +} + ++ (void)performBlock:(void (^)())block { + [self performSelectorOnMainThread:@selector(invokeBlock:) withObject:block waitUntilDone:YES]; +} + +@end + /* * Class: TestMainKeyWindow * Method: setup @@ -36,7 +70,7 @@ */ JNIEXPORT void JNICALL Java_TestMainKeyWindow_setup(JNIEnv *env, jclass cl) { - JNF_COCOA_ENTER(env); + JNI_COCOA_ENTER(env); void (^block)() = ^(){ NSScreen *mainScreen = [[NSScreen screens] objectAtIndex:0]; @@ -68,10 +102,10 @@ JNIEXPORT void JNICALL Java_TestMainKeyWindow_setup(JNIEnv *env, jclass cl) if ([NSThread isMainThread]) { block(); } else { - [JNFRunLoop performOnMainThreadWaiting:YES withBlock:block]; + [BlockRunner performBlock:block]; } - JNF_COCOA_EXIT(env); + JNI_COCOA_EXIT(env); } /* @@ -81,7 +115,7 @@ JNIEXPORT void JNICALL Java_TestMainKeyWindow_setup(JNIEnv *env, jclass cl) */ JNIEXPORT void JNICALL Java_TestMainKeyWindow_takedown(JNIEnv *env, jclass cl) { - JNF_COCOA_ENTER(env); + JNI_COCOA_ENTER(env); void (^block)() = ^(){ if (testWindow != nil) { @@ -97,10 +131,10 @@ JNIEXPORT void JNICALL Java_TestMainKeyWindow_takedown(JNIEnv *env, jclass cl) if ([NSThread isMainThread]) { block(); } else { - [JNFRunLoop performOnMainThreadWaiting:YES withBlock:block]; + [BlockRunner performBlock:block]; } - JNF_COCOA_EXIT(env); + JNI_COCOA_EXIT(env); } /* @@ -111,13 +145,13 @@ JNIEXPORT void JNICALL Java_TestMainKeyWindow_takedown(JNIEnv *env, jclass cl) JNIEXPORT void JNICALL Java_TestMainKeyWindow_activateApplication (JNIEnv *env, jclass cl) { - JNF_COCOA_ENTER(env); + JNI_COCOA_ENTER(env); void (^block)() = ^(){ [NSApp activateIgnoringOtherApps:YES]; }; - [JNFRunLoop performOnMainThreadWaiting:YES withBlock:block]; + [BlockRunner performBlock:block]; - JNF_COCOA_EXIT(env); + JNI_COCOA_EXIT(env); } From 82028e70d1e7f1ba3edd05b082f9a478dc7b0359 Mon Sep 17 00:00:00 2001 From: Ioi Lam Date: Thu, 4 Feb 2021 04:05:33 +0000 Subject: [PATCH 53/77] 8260012: Reduce inclusion of collectedHeap.hpp and heapInspection.hpp Reviewed-by: stefank, tschatzl --- src/hotspot/cpu/aarch64/c1_Runtime1_aarch64.cpp | 1 + src/hotspot/cpu/aarch64/frame_aarch64.cpp | 4 ++-- src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp | 3 ++- src/hotspot/cpu/aarch64/nativeInst_aarch64.cpp | 3 ++- src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp | 1 + src/hotspot/cpu/aarch64/templateTable_aarch64.cpp | 1 + src/hotspot/cpu/arm/c1_Runtime1_arm.cpp | 1 + src/hotspot/cpu/arm/frame_arm.cpp | 4 ++-- src/hotspot/cpu/arm/templateTable_arm.cpp | 1 + src/hotspot/cpu/ppc/frame_ppc.cpp | 4 ++-- src/hotspot/cpu/ppc/nativeInst_ppc.cpp | 3 ++- src/hotspot/cpu/s390/frame_s390.cpp | 4 ++-- src/hotspot/cpu/x86/c1_Runtime1_x86.cpp | 1 + src/hotspot/cpu/x86/frame_x86.cpp | 5 +++-- src/hotspot/cpu/x86/methodHandles_x86.cpp | 1 + src/hotspot/cpu/x86/nativeInst_x86.cpp | 3 ++- src/hotspot/cpu/x86/templateTable_x86.cpp | 1 + src/hotspot/cpu/zero/frame_zero.cpp | 3 ++- src/hotspot/os/windows/perfMemory_windows.cpp | 3 ++- src/hotspot/share/asm/codeBuffer.cpp | 3 ++- src/hotspot/share/classfile/classFileParser.cpp | 1 + src/hotspot/share/classfile/classLoaderExt.cpp | 1 + src/hotspot/share/classfile/modules.cpp | 1 + src/hotspot/share/code/codeCache.cpp | 1 + src/hotspot/share/code/compiledIC.cpp | 1 + src/hotspot/share/code/debugInfo.cpp | 3 ++- src/hotspot/share/code/nmethod.cpp | 1 + src/hotspot/share/code/oopRecorder.cpp | 3 ++- src/hotspot/share/gc/shared/collectedHeap.hpp | 1 - src/hotspot/share/gc/shared/gcVMOperations.cpp | 1 + src/hotspot/share/gc/shared/gcVMOperations.hpp | 3 +-- src/hotspot/share/gc/shared/memAllocator.hpp | 5 +++-- .../share/gc/shared/stringdedup/stringDedupTable.cpp | 1 + src/hotspot/share/interpreter/oopMapCache.cpp | 3 ++- .../share/jfr/leakprofiler/sampling/objectSampler.cpp | 3 ++- src/hotspot/share/jvmci/jvmciRuntime.cpp | 1 + src/hotspot/share/jvmci/jvmci_globals.cpp | 1 + src/hotspot/share/memory/dynamicArchive.cpp | 1 + src/hotspot/share/memory/heap.cpp | 3 ++- src/hotspot/share/memory/universe.cpp | 9 ++++++++- src/hotspot/share/memory/universe.hpp | 4 ++++ src/hotspot/share/memory/virtualspace.cpp | 3 ++- src/hotspot/share/oops/accessBackend.inline.hpp | 3 ++- src/hotspot/share/oops/compressedOops.inline.hpp | 10 +++++----- src/hotspot/share/oops/oop.inline.hpp | 7 +++++-- src/hotspot/share/prims/jni.cpp | 1 + src/hotspot/share/prims/jvmtiEnv.cpp | 1 + src/hotspot/share/prims/jvmtiTagMap.cpp | 1 + src/hotspot/share/prims/jvmtiTagMapTable.cpp | 3 ++- src/hotspot/share/prims/stackwalk.cpp | 1 + src/hotspot/share/runtime/deoptimization.cpp | 1 + src/hotspot/share/runtime/java.cpp | 1 + src/hotspot/share/runtime/jniHandles.cpp | 3 ++- src/hotspot/share/runtime/reflection.cpp | 1 + src/hotspot/share/runtime/sharedRuntime.cpp | 1 + src/hotspot/share/runtime/thread.cpp | 1 + src/hotspot/share/runtime/vmThread.cpp | 1 + src/hotspot/share/services/management.cpp | 1 + src/hotspot/share/utilities/ostream.cpp | 3 ++- .../gtest/gc/shared/test_oopStorage_parperf.cpp | 3 ++- 60 files changed, 103 insertions(+), 41 deletions(-) diff --git a/src/hotspot/cpu/aarch64/c1_Runtime1_aarch64.cpp b/src/hotspot/cpu/aarch64/c1_Runtime1_aarch64.cpp index 0ef3fddbf410b..d4d74ac1f4fbc 100644 --- a/src/hotspot/cpu/aarch64/c1_Runtime1_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/c1_Runtime1_aarch64.cpp @@ -32,6 +32,7 @@ #include "compiler/disassembler.hpp" #include "gc/shared/cardTable.hpp" #include "gc/shared/cardTableBarrierSet.hpp" +#include "gc/shared/collectedHeap.hpp" #include "gc/shared/tlab_globals.hpp" #include "interpreter/interpreter.hpp" #include "memory/universe.hpp" diff --git a/src/hotspot/cpu/aarch64/frame_aarch64.cpp b/src/hotspot/cpu/aarch64/frame_aarch64.cpp index e8ba2d180435d..255477f6a49b5 100644 --- a/src/hotspot/cpu/aarch64/frame_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/frame_aarch64.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, 2020, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -599,7 +599,7 @@ BasicType frame::interpreter_frame_result(oop* oop_result, jvalue* value_result) oop* obj_p = (oop*)tos_addr; obj = (obj_p == NULL) ? (oop)NULL : *obj_p; } - assert(obj == NULL || Universe::heap()->is_in(obj), "sanity check"); + assert(Universe::is_in_heap_or_null(obj), "sanity check"); *oop_result = obj; break; } diff --git a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp index f295ae35dfee0..b742edb47dcef 100644 --- a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp @@ -30,9 +30,10 @@ #include "asm/assembler.hpp" #include "asm/assembler.inline.hpp" #include "gc/shared/barrierSet.hpp" -#include "gc/shared/cardTable.hpp" #include "gc/shared/barrierSetAssembler.hpp" #include "gc/shared/cardTableBarrierSet.hpp" +#include "gc/shared/cardTable.hpp" +#include "gc/shared/collectedHeap.hpp" #include "gc/shared/tlab_globals.hpp" #include "interpreter/interpreter.hpp" #include "compiler/disassembler.hpp" diff --git a/src/hotspot/cpu/aarch64/nativeInst_aarch64.cpp b/src/hotspot/cpu/aarch64/nativeInst_aarch64.cpp index 898f098d8cb7f..734963145c5dd 100644 --- a/src/hotspot/cpu/aarch64/nativeInst_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/nativeInst_aarch64.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, 2020, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -27,6 +27,7 @@ #include "asm/macroAssembler.hpp" #include "code/codeCache.hpp" #include "code/compiledIC.hpp" +#include "gc/shared/collectedHeap.hpp" #include "memory/resourceArea.hpp" #include "nativeInst_aarch64.hpp" #include "oops/oop.inline.hpp" diff --git a/src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp b/src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp index 6a8530c0c008f..74e6fda8e8af5 100644 --- a/src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp @@ -45,6 +45,7 @@ #include "runtime/stubRoutines.hpp" #include "runtime/vframeArray.hpp" #include "utilities/align.hpp" +#include "utilities/formatBuffer.hpp" #include "vmreg_aarch64.inline.hpp" #ifdef COMPILER1 #include "c1/c1_Runtime1.hpp" diff --git a/src/hotspot/cpu/aarch64/templateTable_aarch64.cpp b/src/hotspot/cpu/aarch64/templateTable_aarch64.cpp index 1e69860978007..32a4aed4c75b2 100644 --- a/src/hotspot/cpu/aarch64/templateTable_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/templateTable_aarch64.cpp @@ -26,6 +26,7 @@ #include "precompiled.hpp" #include "asm/macroAssembler.inline.hpp" #include "gc/shared/barrierSetAssembler.hpp" +#include "gc/shared/collectedHeap.hpp" #include "gc/shared/tlab_globals.hpp" #include "interpreter/interpreter.hpp" #include "interpreter/interpreterRuntime.hpp" diff --git a/src/hotspot/cpu/arm/c1_Runtime1_arm.cpp b/src/hotspot/cpu/arm/c1_Runtime1_arm.cpp index ce928e9bcfdbf..6719c5507fe41 100644 --- a/src/hotspot/cpu/arm/c1_Runtime1_arm.cpp +++ b/src/hotspot/cpu/arm/c1_Runtime1_arm.cpp @@ -31,6 +31,7 @@ #include "ci/ciUtilities.hpp" #include "gc/shared/cardTable.hpp" #include "gc/shared/cardTableBarrierSet.hpp" +#include "gc/shared/collectedHeap.hpp" #include "gc/shared/tlab_globals.hpp" #include "interpreter/interpreter.hpp" #include "memory/universe.hpp" diff --git a/src/hotspot/cpu/arm/frame_arm.cpp b/src/hotspot/cpu/arm/frame_arm.cpp index 7c7f0ca867db0..31cf981c346c7 100644 --- a/src/hotspot/cpu/arm/frame_arm.cpp +++ b/src/hotspot/cpu/arm/frame_arm.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -515,7 +515,7 @@ BasicType frame::interpreter_frame_result(oop* oop_result, jvalue* value_result) } else { obj = *(oop*)res_addr; } - assert(obj == NULL || Universe::heap()->is_in(obj), "sanity check"); + assert(Universe::is_in_heap_or_null(obj), "sanity check"); *oop_result = obj; break; } diff --git a/src/hotspot/cpu/arm/templateTable_arm.cpp b/src/hotspot/cpu/arm/templateTable_arm.cpp index c4963f30bfe50..a95842ebb29bd 100644 --- a/src/hotspot/cpu/arm/templateTable_arm.cpp +++ b/src/hotspot/cpu/arm/templateTable_arm.cpp @@ -25,6 +25,7 @@ #include "precompiled.hpp" #include "asm/macroAssembler.inline.hpp" #include "gc/shared/barrierSetAssembler.hpp" +#include "gc/shared/collectedHeap.hpp" #include "gc/shared/tlab_globals.hpp" #include "interpreter/interp_masm.hpp" #include "interpreter/interpreter.hpp" diff --git a/src/hotspot/cpu/ppc/frame_ppc.cpp b/src/hotspot/cpu/ppc/frame_ppc.cpp index 3df8c1a2e517b..81814d37be1e6 100644 --- a/src/hotspot/cpu/ppc/frame_ppc.cpp +++ b/src/hotspot/cpu/ppc/frame_ppc.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, 2017 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -305,7 +305,7 @@ BasicType frame::interpreter_frame_result(oop* oop_result, jvalue* value_result) case T_OBJECT: case T_ARRAY: { oop obj = *(oop*)tos_addr; - assert(obj == NULL || Universe::heap()->is_in(obj), "sanity check"); + assert(Universe::is_in_heap_or_null(obj), "sanity check"); *oop_result = obj; } case T_BOOLEAN : value_result->z = (jboolean) *(jint*)tos_addr; break; diff --git a/src/hotspot/cpu/ppc/nativeInst_ppc.cpp b/src/hotspot/cpu/ppc/nativeInst_ppc.cpp index 1d53968f9f749..eece5739d5b0f 100644 --- a/src/hotspot/cpu/ppc/nativeInst_ppc.cpp +++ b/src/hotspot/cpu/ppc/nativeInst_ppc.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, 2020 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -32,6 +32,7 @@ #include "oops/oop.hpp" #include "runtime/handles.hpp" #include "runtime/orderAccess.hpp" +#include "runtime/safepoint.hpp" #include "runtime/sharedRuntime.hpp" #include "runtime/stubRoutines.hpp" #include "utilities/ostream.hpp" diff --git a/src/hotspot/cpu/s390/frame_s390.cpp b/src/hotspot/cpu/s390/frame_s390.cpp index fa0e81673d3b7..3f232c2ef21d5 100644 --- a/src/hotspot/cpu/s390/frame_s390.cpp +++ b/src/hotspot/cpu/s390/frame_s390.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016, 2019 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -318,7 +318,7 @@ BasicType frame::interpreter_frame_result(oop* oop_result, jvalue* value_result) case T_OBJECT: case T_ARRAY: { oop obj = *(oop*)tos_addr; - assert(obj == NULL || Universe::heap()->is_in(obj), "sanity check"); + assert(Universe::is_in_heap_or_null(obj), "sanity check"); *oop_result = obj; break; } diff --git a/src/hotspot/cpu/x86/c1_Runtime1_x86.cpp b/src/hotspot/cpu/x86/c1_Runtime1_x86.cpp index 84d4e38e3ce4e..43360f832e99e 100644 --- a/src/hotspot/cpu/x86/c1_Runtime1_x86.cpp +++ b/src/hotspot/cpu/x86/c1_Runtime1_x86.cpp @@ -30,6 +30,7 @@ #include "ci/ciUtilities.hpp" #include "gc/shared/cardTable.hpp" #include "gc/shared/cardTableBarrierSet.hpp" +#include "gc/shared/collectedHeap.hpp" #include "gc/shared/tlab_globals.hpp" #include "interpreter/interpreter.hpp" #include "memory/universe.hpp" diff --git a/src/hotspot/cpu/x86/frame_x86.cpp b/src/hotspot/cpu/x86/frame_x86.cpp index db54b729f80b5..1234bc88dbcc7 100644 --- a/src/hotspot/cpu/x86/frame_x86.cpp +++ b/src/hotspot/cpu/x86/frame_x86.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,6 +40,7 @@ #include "runtime/stubCodeGenerator.hpp" #include "runtime/stubRoutines.hpp" #include "vmreg_x86.inline.hpp" +#include "utilities/formatBuffer.hpp" #ifdef COMPILER1 #include "c1/c1_Runtime1.hpp" #include "runtime/vframeArray.hpp" @@ -590,7 +591,7 @@ BasicType frame::interpreter_frame_result(oop* oop_result, jvalue* value_result) oop* obj_p = (oop*)tos_addr; obj = (obj_p == NULL) ? (oop)NULL : *obj_p; } - assert(obj == NULL || Universe::heap()->is_in(obj), "sanity check"); + assert(Universe::is_in_heap_or_null(obj), "sanity check"); *oop_result = obj; break; } diff --git a/src/hotspot/cpu/x86/methodHandles_x86.cpp b/src/hotspot/cpu/x86/methodHandles_x86.cpp index fc2ba34709fa9..b0326ead7eef5 100644 --- a/src/hotspot/cpu/x86/methodHandles_x86.cpp +++ b/src/hotspot/cpu/x86/methodHandles_x86.cpp @@ -39,6 +39,7 @@ #include "runtime/flags/flagSetting.hpp" #include "runtime/frame.inline.hpp" #include "runtime/stubRoutines.hpp" +#include "utilities/formatBuffer.hpp" #include "utilities/preserveException.hpp" #define __ Disassembler::hook(__FILE__, __LINE__, _masm)-> diff --git a/src/hotspot/cpu/x86/nativeInst_x86.cpp b/src/hotspot/cpu/x86/nativeInst_x86.cpp index 1ac15489562b4..fb00defc99e61 100644 --- a/src/hotspot/cpu/x86/nativeInst_x86.cpp +++ b/src/hotspot/cpu/x86/nativeInst_x86.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,6 +29,7 @@ #include "nativeInst_x86.hpp" #include "oops/oop.inline.hpp" #include "runtime/handles.hpp" +#include "runtime/safepoint.hpp" #include "runtime/sharedRuntime.hpp" #include "runtime/stubRoutines.hpp" #include "utilities/ostream.hpp" diff --git a/src/hotspot/cpu/x86/templateTable_x86.cpp b/src/hotspot/cpu/x86/templateTable_x86.cpp index ba16f7fa8a84e..1be6b375a1fb0 100644 --- a/src/hotspot/cpu/x86/templateTable_x86.cpp +++ b/src/hotspot/cpu/x86/templateTable_x86.cpp @@ -25,6 +25,7 @@ #include "precompiled.hpp" #include "asm/macroAssembler.hpp" #include "compiler/disassembler.hpp" +#include "gc/shared/collectedHeap.hpp" #include "gc/shared/tlab_globals.hpp" #include "interpreter/interpreter.hpp" #include "interpreter/interpreterRuntime.hpp" diff --git a/src/hotspot/cpu/zero/frame_zero.cpp b/src/hotspot/cpu/zero/frame_zero.cpp index bd900de57415d..70d6a5e855c1d 100644 --- a/src/hotspot/cpu/zero/frame_zero.cpp +++ b/src/hotspot/cpu/zero/frame_zero.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. * Copyright 2007, 2008, 2009, 2010, 2011 Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -24,6 +24,7 @@ */ #include "precompiled.hpp" +#include "gc/shared/collectedHeap.hpp" #include "interpreter/interpreter.hpp" #include "interpreter/interpreterRuntime.hpp" #include "memory/resourceArea.hpp" diff --git a/src/hotspot/os/windows/perfMemory_windows.cpp b/src/hotspot/os/windows/perfMemory_windows.cpp index 2e29f8af2b978..6db33729040e9 100644 --- a/src/hotspot/os/windows/perfMemory_windows.cpp +++ b/src/hotspot/os/windows/perfMemory_windows.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,6 +34,7 @@ #include "runtime/perfMemory.hpp" #include "services/memTracker.hpp" #include "utilities/exceptions.hpp" +#include "utilities/formatBuffer.hpp" #include #include diff --git a/src/hotspot/share/asm/codeBuffer.cpp b/src/hotspot/share/asm/codeBuffer.cpp index af42bb92b5334..7558c9c857262 100644 --- a/src/hotspot/share/asm/codeBuffer.cpp +++ b/src/hotspot/share/asm/codeBuffer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ #include "asm/codeBuffer.hpp" #include "code/oopRecorder.inline.hpp" #include "compiler/disassembler.hpp" +#include "logging/log.hpp" #include "oops/methodData.hpp" #include "oops/oop.inline.hpp" #include "runtime/icache.hpp" diff --git a/src/hotspot/share/classfile/classFileParser.cpp b/src/hotspot/share/classfile/classFileParser.cpp index 6aa20958fb753..d7e35baa45d8e 100644 --- a/src/hotspot/share/classfile/classFileParser.cpp +++ b/src/hotspot/share/classfile/classFileParser.cpp @@ -77,6 +77,7 @@ #include "utilities/align.hpp" #include "utilities/bitMap.inline.hpp" #include "utilities/copy.hpp" +#include "utilities/formatBuffer.hpp" #include "utilities/exceptions.hpp" #include "utilities/globalDefinitions.hpp" #include "utilities/growableArray.hpp" diff --git a/src/hotspot/share/classfile/classLoaderExt.cpp b/src/hotspot/share/classfile/classLoaderExt.cpp index 8709498b56c87..bd39fc071e5df 100644 --- a/src/hotspot/share/classfile/classLoaderExt.cpp +++ b/src/hotspot/share/classfile/classLoaderExt.cpp @@ -34,6 +34,7 @@ #include "classfile/systemDictionary.hpp" #include "classfile/systemDictionaryShared.hpp" #include "classfile/vmSymbols.hpp" +#include "gc/shared/collectedHeap.hpp" #include "logging/log.hpp" #include "memory/allocation.inline.hpp" #include "memory/filemap.hpp" diff --git a/src/hotspot/share/classfile/modules.cpp b/src/hotspot/share/classfile/modules.cpp index e4de916b47131..e8b107e34ded7 100644 --- a/src/hotspot/share/classfile/modules.cpp +++ b/src/hotspot/share/classfile/modules.cpp @@ -48,6 +48,7 @@ #include "runtime/handles.inline.hpp" #include "runtime/javaCalls.hpp" #include "runtime/jniHandles.inline.hpp" +#include "utilities/formatBuffer.hpp" #include "utilities/stringUtils.hpp" #include "utilities/utf8.hpp" diff --git a/src/hotspot/share/code/codeCache.cpp b/src/hotspot/share/code/codeCache.cpp index 9ab389d99fd1d..3d402292fa311 100644 --- a/src/hotspot/share/code/codeCache.cpp +++ b/src/hotspot/share/code/codeCache.cpp @@ -36,6 +36,7 @@ #include "code/pcDesc.hpp" #include "compiler/compilationPolicy.hpp" #include "compiler/compileBroker.hpp" +#include "gc/shared/collectedHeap.hpp" #include "jfr/jfrEvents.hpp" #include "logging/log.hpp" #include "logging/logStream.hpp" diff --git a/src/hotspot/share/code/compiledIC.cpp b/src/hotspot/share/code/compiledIC.cpp index 2d2ede574a672..848cc98a4c2cb 100644 --- a/src/hotspot/share/code/compiledIC.cpp +++ b/src/hotspot/share/code/compiledIC.cpp @@ -40,6 +40,7 @@ #include "oops/symbol.hpp" #include "runtime/handles.inline.hpp" #include "runtime/icache.hpp" +#include "runtime/safepoint.hpp" #include "runtime/sharedRuntime.hpp" #include "runtime/stubRoutines.hpp" #include "utilities/events.hpp" diff --git a/src/hotspot/share/code/debugInfo.cpp b/src/hotspot/share/code/debugInfo.cpp index 8d8b640b843b8..aeed7f4d937d6 100644 --- a/src/hotspot/share/code/debugInfo.cpp +++ b/src/hotspot/share/code/debugInfo.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ #include "code/debugInfo.hpp" #include "code/debugInfoRec.hpp" #include "code/nmethod.hpp" +#include "gc/shared/collectedHeap.hpp" #include "memory/universe.hpp" #include "oops/oop.inline.hpp" #include "runtime/handles.inline.hpp" diff --git a/src/hotspot/share/code/nmethod.cpp b/src/hotspot/share/code/nmethod.cpp index 8f1df0c4184c8..0711c399e82d4 100644 --- a/src/hotspot/share/code/nmethod.cpp +++ b/src/hotspot/share/code/nmethod.cpp @@ -38,6 +38,7 @@ #include "compiler/compilerDirectives.hpp" #include "compiler/directivesParser.hpp" #include "compiler/disassembler.hpp" +#include "gc/shared/collectedHeap.hpp" #include "interpreter/bytecode.hpp" #include "logging/log.hpp" #include "logging/logStream.hpp" diff --git a/src/hotspot/share/code/oopRecorder.cpp b/src/hotspot/share/code/oopRecorder.cpp index 11154e0b3a205..6e2dbbb24383f 100644 --- a/src/hotspot/share/code/oopRecorder.cpp +++ b/src/hotspot/share/code/oopRecorder.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,7 @@ #include "ci/ciInstance.hpp" #include "ci/ciMetadata.hpp" #include "code/oopRecorder.inline.hpp" +#include "gc/shared/collectedHeap.hpp" #include "memory/allocation.inline.hpp" #include "oops/oop.inline.hpp" #include "runtime/jniHandles.inline.hpp" diff --git a/src/hotspot/share/gc/shared/collectedHeap.hpp b/src/hotspot/share/gc/shared/collectedHeap.hpp index 05821b7e11000..ef532f148faaa 100644 --- a/src/hotspot/share/gc/shared/collectedHeap.hpp +++ b/src/hotspot/share/gc/shared/collectedHeap.hpp @@ -29,7 +29,6 @@ #include "gc/shared/gcWhen.hpp" #include "gc/shared/verifyOption.hpp" #include "memory/allocation.hpp" -#include "memory/heapInspection.hpp" #include "memory/universe.hpp" #include "runtime/handles.hpp" #include "runtime/perfDataTypes.hpp" diff --git a/src/hotspot/share/gc/shared/gcVMOperations.cpp b/src/hotspot/share/gc/shared/gcVMOperations.cpp index cee546b267bb4..a8a4084990ecc 100644 --- a/src/hotspot/share/gc/shared/gcVMOperations.cpp +++ b/src/hotspot/share/gc/shared/gcVMOperations.cpp @@ -34,6 +34,7 @@ #include "interpreter/oopMapCache.hpp" #include "logging/log.hpp" #include "memory/classLoaderMetaspace.hpp" +#include "memory/heapInspection.hpp" #include "memory/oopFactory.hpp" #include "memory/universe.hpp" #include "runtime/handles.inline.hpp" diff --git a/src/hotspot/share/gc/shared/gcVMOperations.hpp b/src/hotspot/share/gc/shared/gcVMOperations.hpp index 8b16d3336a24f..b383234317881 100644 --- a/src/hotspot/share/gc/shared/gcVMOperations.hpp +++ b/src/hotspot/share/gc/shared/gcVMOperations.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,7 +27,6 @@ #include "gc/shared/collectedHeap.hpp" #include "gc/shared/genCollectedHeap.hpp" -#include "memory/heapInspection.hpp" #include "memory/metaspace.hpp" #include "prims/jvmtiExport.hpp" #include "runtime/handles.hpp" diff --git a/src/hotspot/share/gc/shared/memAllocator.hpp b/src/hotspot/share/gc/shared/memAllocator.hpp index e3e5b299b31f5..6df76dca2ff15 100644 --- a/src/hotspot/share/gc/shared/memAllocator.hpp +++ b/src/hotspot/share/gc/shared/memAllocator.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,10 +25,11 @@ #ifndef SHARE_GC_SHARED_MEMALLOCATOR_HPP #define SHARE_GC_SHARED_MEMALLOCATOR_HPP -#include "gc/shared/collectedHeap.hpp" #include "memory/memRegion.hpp" #include "oops/oopsHierarchy.hpp" +#include "runtime/thread.hpp" #include "utilities/exceptions.hpp" +#include "utilities/globalDefinitions.hpp" #include "utilities/macros.hpp" // These fascilities are used for allocating, and initializing newly allocated objects. diff --git a/src/hotspot/share/gc/shared/stringdedup/stringDedupTable.cpp b/src/hotspot/share/gc/shared/stringdedup/stringDedupTable.cpp index b1b6a7a15197b..63760bc563fc7 100644 --- a/src/hotspot/share/gc/shared/stringdedup/stringDedupTable.cpp +++ b/src/hotspot/share/gc/shared/stringdedup/stringDedupTable.cpp @@ -25,6 +25,7 @@ #include "precompiled.hpp" #include "classfile/altHashing.hpp" #include "classfile/javaClasses.inline.hpp" +#include "gc/shared/collectedHeap.hpp" #include "gc/shared/gc_globals.hpp" #include "gc/shared/stringdedup/stringDedup.hpp" #include "gc/shared/stringdedup/stringDedupTable.hpp" diff --git a/src/hotspot/share/interpreter/oopMapCache.cpp b/src/hotspot/share/interpreter/oopMapCache.cpp index 5ba1500257f83..bd75884e247b6 100644 --- a/src/hotspot/share/interpreter/oopMapCache.cpp +++ b/src/hotspot/share/interpreter/oopMapCache.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,6 +31,7 @@ #include "oops/oop.inline.hpp" #include "runtime/atomic.hpp" #include "runtime/handles.inline.hpp" +#include "runtime/safepoint.hpp" #include "runtime/signature.hpp" class OopMapCacheEntry: private InterpreterOopMap { diff --git a/src/hotspot/share/jfr/leakprofiler/sampling/objectSampler.cpp b/src/hotspot/share/jfr/leakprofiler/sampling/objectSampler.cpp index c5ba05ce3d5e6..ff6d87c97ba6b 100644 --- a/src/hotspot/share/jfr/leakprofiler/sampling/objectSampler.cpp +++ b/src/hotspot/share/jfr/leakprofiler/sampling/objectSampler.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,6 +23,7 @@ */ #include "precompiled.hpp" +#include "gc/shared/collectedHeap.hpp" #include "gc/shared/oopStorage.hpp" #include "gc/shared/oopStorageSet.hpp" #include "jfr/jfrEvents.hpp" diff --git a/src/hotspot/share/jvmci/jvmciRuntime.cpp b/src/hotspot/share/jvmci/jvmciRuntime.cpp index 2d0c5b6881b5f..c4278a9f231a6 100644 --- a/src/hotspot/share/jvmci/jvmciRuntime.cpp +++ b/src/hotspot/share/jvmci/jvmciRuntime.cpp @@ -27,6 +27,7 @@ #include "classfile/systemDictionary.hpp" #include "classfile/vmClasses.hpp" #include "compiler/compileBroker.hpp" +#include "gc/shared/collectedHeap.hpp" #include "gc/shared/oopStorage.inline.hpp" #include "jvmci/jniAccessMark.inline.hpp" #include "jvmci/jvmciCompilerToVM.hpp" diff --git a/src/hotspot/share/jvmci/jvmci_globals.cpp b/src/hotspot/share/jvmci/jvmci_globals.cpp index 4cfab9e9c60b8..cf213e5469270 100644 --- a/src/hotspot/share/jvmci/jvmci_globals.cpp +++ b/src/hotspot/share/jvmci/jvmci_globals.cpp @@ -27,6 +27,7 @@ #include "gc/shared/gcConfig.hpp" #include "jvm.h" #include "jvmci/jvmci_globals.hpp" +#include "logging/log.hpp" #include "runtime/arguments.hpp" #include "runtime/flags/jvmFlagAccess.hpp" #include "runtime/globals_extension.hpp" diff --git a/src/hotspot/share/memory/dynamicArchive.cpp b/src/hotspot/share/memory/dynamicArchive.cpp index 1c828f74faa31..1d1d3adf41bee 100644 --- a/src/hotspot/share/memory/dynamicArchive.cpp +++ b/src/hotspot/share/memory/dynamicArchive.cpp @@ -27,6 +27,7 @@ #include "classfile/classLoaderData.inline.hpp" #include "classfile/symbolTable.hpp" #include "classfile/systemDictionaryShared.hpp" +#include "gc/shared/collectedHeap.hpp" #include "gc/shared/gcVMOperations.hpp" #include "gc/shared/gc_globals.hpp" #include "logging/log.hpp" diff --git a/src/hotspot/share/memory/heap.cpp b/src/hotspot/share/memory/heap.cpp index d55bc07e2c0be..098095fb29353 100644 --- a/src/hotspot/share/memory/heap.cpp +++ b/src/hotspot/share/memory/heap.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ #include "memory/heap.hpp" #include "oops/oop.inline.hpp" #include "runtime/os.hpp" +#include "runtime/mutexLocker.hpp" #include "services/memTracker.hpp" #include "utilities/align.hpp" #include "utilities/powerOfTwo.hpp" diff --git a/src/hotspot/share/memory/universe.cpp b/src/hotspot/share/memory/universe.cpp index 80bc2c2aa6462..8122d4cd6027d 100644 --- a/src/hotspot/share/memory/universe.cpp +++ b/src/hotspot/share/memory/universe.cpp @@ -1227,7 +1227,6 @@ Method* LatestMethodCache::get_method() { return m; } - #ifdef ASSERT // Release dummy object(s) at bottom of heap bool Universe::release_fullgc_alot_dummy() { @@ -1246,4 +1245,12 @@ bool Universe::release_fullgc_alot_dummy() { return true; } +bool Universe::is_gc_active() { + return heap()->is_gc_active(); +} + +bool Universe::is_in_heap(const void* p) { + return heap()->is_in(p); +} + #endif // ASSERT diff --git a/src/hotspot/share/memory/universe.hpp b/src/hotspot/share/memory/universe.hpp index 08f24eb129382..70fc2269ec474 100644 --- a/src/hotspot/share/memory/universe.hpp +++ b/src/hotspot/share/memory/universe.hpp @@ -302,6 +302,10 @@ class Universe: AllStatic { // The particular choice of collected heap. static CollectedHeap* heap() { return _collectedHeap; } + DEBUG_ONLY(static bool is_gc_active();) + DEBUG_ONLY(static bool is_in_heap(const void* p);) + DEBUG_ONLY(static bool is_in_heap_or_null(const void* p) { return p == NULL || is_in_heap(p); }) + // Reserve Java heap and determine CompressedOops mode static ReservedHeapSpace reserve_heap(size_t heap_size, size_t alignment); diff --git a/src/hotspot/share/memory/virtualspace.cpp b/src/hotspot/share/memory/virtualspace.cpp index db8bb8146e4aa..0d16ffcd37d41 100644 --- a/src/hotspot/share/memory/virtualspace.cpp +++ b/src/hotspot/share/memory/virtualspace.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,6 +34,7 @@ #include "runtime/os.inline.hpp" #include "services/memTracker.hpp" #include "utilities/align.hpp" +#include "utilities/formatBuffer.hpp" #include "utilities/powerOfTwo.hpp" // ReservedSpace diff --git a/src/hotspot/share/oops/accessBackend.inline.hpp b/src/hotspot/share/oops/accessBackend.inline.hpp index e28b4c228120e..40d3010be555b 100644 --- a/src/hotspot/share/oops/accessBackend.inline.hpp +++ b/src/hotspot/share/oops/accessBackend.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,7 @@ #include "oops/access.hpp" #include "oops/accessBackend.hpp" +#include "oops/arrayOop.hpp" #include "oops/compressedOops.inline.hpp" #include "oops/oopsHierarchy.hpp" #include "runtime/atomic.hpp" diff --git a/src/hotspot/share/oops/compressedOops.inline.hpp b/src/hotspot/share/oops/compressedOops.inline.hpp index 920e87703b454..8448034620028 100644 --- a/src/hotspot/share/oops/compressedOops.inline.hpp +++ b/src/hotspot/share/oops/compressedOops.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,11 +25,11 @@ #ifndef SHARE_OOPS_COMPRESSEDOOPS_INLINE_HPP #define SHARE_OOPS_COMPRESSEDOOPS_INLINE_HPP -#include "gc/shared/collectedHeap.hpp" #include "memory/universe.hpp" #include "oops/compressedOops.hpp" #include "oops/oop.hpp" #include "utilities/align.hpp" +#include "utilities/globalDefinitions.hpp" // Functions for encoding and decoding compressed oops. // If the oops are compressed, the type passed to these overloaded functions @@ -54,7 +54,7 @@ inline oop CompressedOops::decode_not_null(narrowOop v) { assert(!is_null(v), "narrow oop value can never be zero"); oop result = decode_raw(v); assert(is_object_aligned(result), "address not aligned: " INTPTR_FORMAT, p2i((void*) result)); - assert(Universe::heap()->is_in(result), "object not in heap " PTR_FORMAT, p2i((void*) result)); + assert(Universe::is_in_heap(result), "object not in heap " PTR_FORMAT, p2i((void*) result)); return result; } @@ -78,12 +78,12 @@ inline narrowOop CompressedOops::encode(oop v) { } inline oop CompressedOops::decode_not_null(oop v) { - assert(Universe::heap()->is_in(v), "object not in heap " PTR_FORMAT, p2i((void*) v)); + assert(Universe::is_in_heap(v), "object not in heap " PTR_FORMAT, p2i((void*) v)); return v; } inline oop CompressedOops::decode(oop v) { - assert(Universe::heap()->is_in_or_null(v), "object not in heap " PTR_FORMAT, p2i((void*) v)); + assert(Universe::is_in_heap_or_null(v), "object not in heap " PTR_FORMAT, p2i((void*) v)); return v; } diff --git a/src/hotspot/share/oops/oop.inline.hpp b/src/hotspot/share/oops/oop.inline.hpp index cab2264309b49..0ca29f42848eb 100644 --- a/src/hotspot/share/oops/oop.inline.hpp +++ b/src/hotspot/share/oops/oop.inline.hpp @@ -25,7 +25,6 @@ #ifndef SHARE_OOPS_OOP_INLINE_HPP #define SHARE_OOPS_OOP_INLINE_HPP -#include "gc/shared/collectedHeap.hpp" #include "memory/universe.hpp" #include "oops/access.inline.hpp" #include "oops/arrayKlass.hpp" @@ -33,10 +32,14 @@ #include "oops/compressedOops.inline.hpp" #include "oops/markWord.inline.hpp" #include "oops/oop.hpp" +#include "oops/oopsHierarchy.hpp" #include "runtime/atomic.hpp" #include "runtime/os.hpp" +#include "runtime/globals.hpp" #include "utilities/align.hpp" +#include "utilities/debug.hpp" #include "utilities/macros.hpp" +#include "utilities/globalDefinitions.hpp" // Implementation of all inlined member functions defined in oop.hpp // We need a separate file to avoid circular references @@ -185,7 +188,7 @@ int oopDesc::size_given_klass(Klass* klass) { // disjunct below to fail if the two comparands are computed across such // a concurrent change. assert((s == klass->oop_size(this)) || - (Universe::heap()->is_gc_active() && is_objArray() && is_forwarded() && (get_UseParallelGC() || get_UseG1GC())), + (Universe::is_gc_active() && is_objArray() && is_forwarded() && (get_UseParallelGC() || get_UseG1GC())), "wrong array object size"); } else { // Must be zero, so bite the bullet and take the virtual call. diff --git a/src/hotspot/share/prims/jni.cpp b/src/hotspot/share/prims/jni.cpp index 0901a1bbcbd99..917e0bff389e8 100644 --- a/src/hotspot/share/prims/jni.cpp +++ b/src/hotspot/share/prims/jni.cpp @@ -40,6 +40,7 @@ #include "classfile/vmClasses.hpp" #include "classfile/vmSymbols.hpp" #include "compiler/compiler_globals.hpp" +#include "gc/shared/collectedHeap.hpp" #include "gc/shared/gcLocker.inline.hpp" #include "interpreter/linkResolver.hpp" #include "jfr/jfrEvents.hpp" diff --git a/src/hotspot/share/prims/jvmtiEnv.cpp b/src/hotspot/share/prims/jvmtiEnv.cpp index 96615a6ceacfe..6fe59ac269741 100644 --- a/src/hotspot/share/prims/jvmtiEnv.cpp +++ b/src/hotspot/share/prims/jvmtiEnv.cpp @@ -30,6 +30,7 @@ #include "classfile/systemDictionary.hpp" #include "classfile/vmClasses.hpp" #include "classfile/vmSymbols.hpp" +#include "gc/shared/collectedHeap.hpp" #include "interpreter/bytecodeStream.hpp" #include "interpreter/interpreter.hpp" #include "jfr/jfrEvents.hpp" diff --git a/src/hotspot/share/prims/jvmtiTagMap.cpp b/src/hotspot/share/prims/jvmtiTagMap.cpp index e0ca6e7b2494b..082f4aa5ec476 100644 --- a/src/hotspot/share/prims/jvmtiTagMap.cpp +++ b/src/hotspot/share/prims/jvmtiTagMap.cpp @@ -28,6 +28,7 @@ #include "classfile/symbolTable.hpp" #include "classfile/vmClasses.hpp" #include "classfile/vmSymbols.hpp" +#include "gc/shared/collectedHeap.hpp" #include "jvmtifiles/jvmtiEnv.hpp" #include "logging/log.hpp" #include "memory/allocation.inline.hpp" diff --git a/src/hotspot/share/prims/jvmtiTagMapTable.cpp b/src/hotspot/share/prims/jvmtiTagMapTable.cpp index 90879a63cd9f2..6bfca1371025a 100644 --- a/src/hotspot/share/prims/jvmtiTagMapTable.cpp +++ b/src/hotspot/share/prims/jvmtiTagMapTable.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,6 +23,7 @@ */ #include "precompiled.hpp" +#include "gc/shared/collectedHeap.hpp" #include "gc/shared/oopStorage.hpp" #include "jvmtifiles/jvmtiEnv.hpp" #include "logging/log.hpp" diff --git a/src/hotspot/share/prims/stackwalk.cpp b/src/hotspot/share/prims/stackwalk.cpp index a45d564efbd4b..039058f064ec0 100644 --- a/src/hotspot/share/prims/stackwalk.cpp +++ b/src/hotspot/share/prims/stackwalk.cpp @@ -41,6 +41,7 @@ #include "runtime/stackWatermarkSet.hpp" #include "runtime/thread.inline.hpp" #include "runtime/vframe.inline.hpp" +#include "utilities/formatBuffer.hpp" #include "utilities/globalDefinitions.hpp" // setup and cleanup actions diff --git a/src/hotspot/share/runtime/deoptimization.cpp b/src/hotspot/share/runtime/deoptimization.cpp index b9e6e24803041..470d41ff69460 100644 --- a/src/hotspot/share/runtime/deoptimization.cpp +++ b/src/hotspot/share/runtime/deoptimization.cpp @@ -34,6 +34,7 @@ #include "code/pcDesc.hpp" #include "code/scopeDesc.hpp" #include "compiler/compilationPolicy.hpp" +#include "gc/shared/collectedHeap.hpp" #include "interpreter/bytecode.hpp" #include "interpreter/interpreter.hpp" #include "interpreter/oopMapCache.hpp" diff --git a/src/hotspot/share/runtime/java.cpp b/src/hotspot/share/runtime/java.cpp index bc372c0bcafbc..cd32288701765 100644 --- a/src/hotspot/share/runtime/java.cpp +++ b/src/hotspot/share/runtime/java.cpp @@ -34,6 +34,7 @@ #include "code/codeCache.hpp" #include "compiler/compileBroker.hpp" #include "compiler/compilerOracle.hpp" +#include "gc/shared/collectedHeap.hpp" #include "interpreter/bytecodeHistogram.hpp" #include "jfr/jfrEvents.hpp" #include "jfr/support/jfrThreadId.hpp" diff --git a/src/hotspot/share/runtime/jniHandles.cpp b/src/hotspot/share/runtime/jniHandles.cpp index a77d50500ae37..4d7be6b46763f 100644 --- a/src/hotspot/share/runtime/jniHandles.cpp +++ b/src/hotspot/share/runtime/jniHandles.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,6 +23,7 @@ */ #include "precompiled.hpp" +#include "gc/shared/collectedHeap.hpp" #include "gc/shared/oopStorage.inline.hpp" #include "gc/shared/oopStorageSet.hpp" #include "logging/log.hpp" diff --git a/src/hotspot/share/runtime/reflection.cpp b/src/hotspot/share/runtime/reflection.cpp index 5f8f3ba6f3c5e..c093446974f82 100644 --- a/src/hotspot/share/runtime/reflection.cpp +++ b/src/hotspot/share/runtime/reflection.cpp @@ -52,6 +52,7 @@ #include "runtime/signature.hpp" #include "runtime/thread.inline.hpp" #include "runtime/vframe.inline.hpp" +#include "utilities/formatBuffer.hpp" static void trace_class_resolution(oop mirror) { if (mirror == NULL || java_lang_Class::is_primitive(mirror)) { diff --git a/src/hotspot/share/runtime/sharedRuntime.cpp b/src/hotspot/share/runtime/sharedRuntime.cpp index ff2b0057f256e..5b6950f015282 100644 --- a/src/hotspot/share/runtime/sharedRuntime.cpp +++ b/src/hotspot/share/runtime/sharedRuntime.cpp @@ -39,6 +39,7 @@ #include "compiler/compileBroker.hpp" #include "compiler/disassembler.hpp" #include "gc/shared/barrierSet.hpp" +#include "gc/shared/collectedHeap.hpp" #include "gc/shared/gcLocker.inline.hpp" #include "interpreter/interpreter.hpp" #include "interpreter/interpreterRuntime.hpp" diff --git a/src/hotspot/share/runtime/thread.cpp b/src/hotspot/share/runtime/thread.cpp index 159f802bd0828..ac6ef9a303262 100644 --- a/src/hotspot/share/runtime/thread.cpp +++ b/src/hotspot/share/runtime/thread.cpp @@ -37,6 +37,7 @@ #include "compiler/compileBroker.hpp" #include "compiler/compileTask.hpp" #include "gc/shared/barrierSet.hpp" +#include "gc/shared/collectedHeap.hpp" #include "gc/shared/gcId.hpp" #include "gc/shared/gcLocker.inline.hpp" #include "gc/shared/gcVMOperations.hpp" diff --git a/src/hotspot/share/runtime/vmThread.cpp b/src/hotspot/share/runtime/vmThread.cpp index 9f7988aa6e72a..8068616ab23bb 100644 --- a/src/hotspot/share/runtime/vmThread.cpp +++ b/src/hotspot/share/runtime/vmThread.cpp @@ -24,6 +24,7 @@ #include "precompiled.hpp" #include "compiler/compileBroker.hpp" +#include "gc/shared/collectedHeap.hpp" #include "jfr/jfrEvents.hpp" #include "jfr/support/jfrThreadId.hpp" #include "logging/log.hpp" diff --git a/src/hotspot/share/services/management.cpp b/src/hotspot/share/services/management.cpp index b62874f999e81..9070f26bc01d8 100644 --- a/src/hotspot/share/services/management.cpp +++ b/src/hotspot/share/services/management.cpp @@ -28,6 +28,7 @@ #include "classfile/systemDictionary.hpp" #include "classfile/vmClasses.hpp" #include "compiler/compileBroker.hpp" +#include "gc/shared/collectedHeap.hpp" #include "memory/allocation.inline.hpp" #include "memory/iterator.hpp" #include "memory/oopFactory.hpp" diff --git a/src/hotspot/share/utilities/ostream.cpp b/src/hotspot/share/utilities/ostream.cpp index 148390e93da89..61ff92be830c2 100644 --- a/src/hotspot/share/utilities/ostream.cpp +++ b/src/hotspot/share/utilities/ostream.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,6 +31,7 @@ #include "runtime/arguments.hpp" #include "runtime/os.inline.hpp" #include "runtime/orderAccess.hpp" +#include "runtime/safepoint.hpp" #include "runtime/vm_version.hpp" #include "utilities/defaultStream.hpp" #include "utilities/macros.hpp" diff --git a/test/hotspot/gtest/gc/shared/test_oopStorage_parperf.cpp b/test/hotspot/gtest/gc/shared/test_oopStorage_parperf.cpp index dea8fe7903a78..31d0c4fcc809f 100644 --- a/test/hotspot/gtest/gc/shared/test_oopStorage_parperf.cpp +++ b/test/hotspot/gtest/gc/shared/test_oopStorage_parperf.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,6 +35,7 @@ #include "runtime/vmOperations.hpp" #include "runtime/vmThread.hpp" #include "utilities/debug.hpp" +#include "utilities/formatBuffer.hpp" #include "utilities/ostream.hpp" #include "utilities/ticks.hpp" From 60f440deb9df271796414842214bc8d60f941d92 Mon Sep 17 00:00:00 2001 From: Prasanta Sadhukhan Date: Thu, 4 Feb 2021 04:13:05 +0000 Subject: [PATCH 54/77] 6436374: Graphics.setColor(null) is not documented Reviewed-by: serb, pbansal --- .../share/classes/java/awt/Graphics.java | 1 + test/jdk/java/awt/color/TestNullSetColor.java | 47 +++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 test/jdk/java/awt/color/TestNullSetColor.java diff --git a/src/java.desktop/share/classes/java/awt/Graphics.java b/src/java.desktop/share/classes/java/awt/Graphics.java index fe8437f029e7a..234b474764e52 100644 --- a/src/java.desktop/share/classes/java/awt/Graphics.java +++ b/src/java.desktop/share/classes/java/awt/Graphics.java @@ -193,6 +193,7 @@ public Graphics create(int x, int y, int width, int height) { * Sets this graphics context's current color to the specified * color. All subsequent graphics operations using this graphics * context use this specified color. + * A null argument is silently ignored. * @param c the new rendering color. * @see java.awt.Color * @see java.awt.Graphics#getColor diff --git a/test/jdk/java/awt/color/TestNullSetColor.java b/test/jdk/java/awt/color/TestNullSetColor.java new file mode 100644 index 0000000000000..57183218d6529 --- /dev/null +++ b/test/jdk/java/awt/color/TestNullSetColor.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + + +import java.awt.Graphics; +import java.awt.Color; +import java.awt.image.BufferedImage; + +/** + * @test + * @bug 6436374 + * @summary Verifies that passing null to setColor() will be ignored. + */ +public class TestNullSetColor { + + public static void main(String[] argv) { + BufferedImage bi = new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB); + Graphics g = bi.getGraphics(); + + g.setColor(Color.RED); + g.setColor(null); + + if (g.getColor() != Color.RED) { + throw new RuntimeException("Setting setColor(null) is not ignored"); + } + } +} From 06b33a0ad78d1577711af22020cf5fdf25112523 Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Thu, 4 Feb 2021 07:28:27 +0000 Subject: [PATCH 55/77] 8261107: ArrayIndexOutOfBoundsException in the ICC_Profile.getInstance(InputStream) Reviewed-by: azvegint, psadhukhan --- .../classes/java/awt/color/ICC_Profile.java | 4 +- .../ICC_Profile/GetInstanceBrokenStream.java | 54 +++++++++++++++++++ 2 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 test/jdk/java/awt/color/ICC_Profile/GetInstanceBrokenStream.java diff --git a/src/java.desktop/share/classes/java/awt/color/ICC_Profile.java b/src/java.desktop/share/classes/java/awt/color/ICC_Profile.java index 967d96861f46f..32a02590d9c73 100644 --- a/src/java.desktop/share/classes/java/awt/color/ICC_Profile.java +++ b/src/java.desktop/share/classes/java/awt/color/ICC_Profile.java @@ -975,10 +975,10 @@ public static ICC_Profile getInstance(InputStream s) throws IOException { static byte[] getProfileDataFromStream(InputStream s) throws IOException { BufferedInputStream bis = new BufferedInputStream(s); - bis.mark(128); + bis.mark(128); // 128 is the length of the ICC profile header byte[] header = bis.readNBytes(128); - if (header[36] != 0x61 || header[37] != 0x63 || + if (header.length < 128 || header[36] != 0x61 || header[37] != 0x63 || header[38] != 0x73 || header[39] != 0x70) { return null; /* not a valid profile */ } diff --git a/test/jdk/java/awt/color/ICC_Profile/GetInstanceBrokenStream.java b/test/jdk/java/awt/color/ICC_Profile/GetInstanceBrokenStream.java new file mode 100644 index 0000000000000..b98cae0cdca28 --- /dev/null +++ b/test/jdk/java/awt/color/ICC_Profile/GetInstanceBrokenStream.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.color.ICC_Profile; +import java.io.ByteArrayInputStream; +import java.io.IOException; + +/** + * @test + * @bug 8261107 + * @summary Short and broken streams should be reported as unsupported + */ +public final class GetInstanceBrokenStream { + + public static void main(String[] args) throws IOException { + // Empty header + testHeader(new byte[]{}); + // Short header + testHeader(new byte[]{-12, 3, 45}); + // Broken header + testHeader(new byte[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 34, 35, 0x61, 0x63, 0x73, 0x70}); + } + + private static void testHeader(byte[] data) throws IOException { + ByteArrayInputStream bais = new ByteArrayInputStream(data); + try { + ICC_Profile.getInstance(bais); + } catch (IllegalArgumentException e) { + // expected + } + } +} From e8ad8b35043d62fbefce473f35092d178d0fc20c Mon Sep 17 00:00:00 2001 From: Denghui Dong Date: Thu, 4 Feb 2021 09:22:01 +0000 Subject: [PATCH 56/77] 8259956: jdk.jfr.internal.ChunkInputStream#available should return the sum of remaining available bytes Reviewed-by: egahlin --- .../jdk/jfr/internal/ChunkInputStream.java | 10 +++- .../TestChunkInputStreamAvailable.java | 57 +++++++++++++++++++ 2 files changed, 64 insertions(+), 3 deletions(-) create mode 100644 test/jdk/jdk/jfr/api/consumer/TestChunkInputStreamAvailable.java diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/ChunkInputStream.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/ChunkInputStream.java index 1a27170c6b91e..a5e1d01783f2a 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/ChunkInputStream.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/ChunkInputStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,6 +34,7 @@ final class ChunkInputStream extends InputStream { private final Iterator chunks; + private long unstreamedSize = 0; private RepositoryChunk currentChunk; private InputStream stream; @@ -42,6 +43,7 @@ final class ChunkInputStream extends InputStream { for (RepositoryChunk c : chunks) { c.use(); // keep alive while we're reading. l.add(c); + unstreamedSize += c.getSize(); } this.chunks = l.iterator(); @@ -50,10 +52,11 @@ final class ChunkInputStream extends InputStream { @Override public int available() throws IOException { + long total = unstreamedSize; if (stream != null) { - return stream.available(); + total += stream.available(); } - return 0; + return total <= Integer.MAX_VALUE ? (int) total : Integer.MAX_VALUE; } private boolean nextStream() throws IOException { @@ -62,6 +65,7 @@ private boolean nextStream() throws IOException { } stream = new BufferedInputStream(SecuritySupport.newFileInputStream(currentChunk.getFile())); + unstreamedSize -= currentChunk.getSize(); return true; } diff --git a/test/jdk/jdk/jfr/api/consumer/TestChunkInputStreamAvailable.java b/test/jdk/jdk/jfr/api/consumer/TestChunkInputStreamAvailable.java new file mode 100644 index 0000000000000..c59160a912375 --- /dev/null +++ b/test/jdk/jdk/jfr/api/consumer/TestChunkInputStreamAvailable.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2021, Alibaba Group Holding Limited. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Alibaba designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +/** + * @test TestChunkInputStreamAvailable + * @key jfr + * @requires vm.hasJFR + * @library /test/lib + * @run main/othervm jdk.jfr.api.consumer.TestChunkInputStreamAvailable + */ +package jdk.jfr.api.consumer; + +import java.io.InputStream; + +import jdk.jfr.Recording; +import jdk.test.lib.Asserts; + +public class TestChunkInputStreamAvailable { + + public static void main(String[] args) throws Exception { + try (Recording r = new Recording()) { + r.start(); + try (Recording s = new Recording()) { + s.start(); + s.stop(); + } + r.stop(); + try (InputStream stream = r.getStream(null, null)) { + int left = stream.available(); + Asserts.assertEquals(r.getSize(), (long) left); + while (stream.read() != -1) { + left--; + Asserts.assertEquals(left, stream.available()); + } + Asserts.assertEquals(0, left); + } + } + } +} From 992b50087d2ec8878dfcbbd1820a00b6b6bdf644 Mon Sep 17 00:00:00 2001 From: Claes Redestad Date: Thu, 4 Feb 2021 10:46:10 +0000 Subject: [PATCH 57/77] 8261036: Reduce classes loaded by CleanerFactory initialization Reviewed-by: rriggs --- .../jdk/internal/misc/InnocuousThread.java | 61 ++++++++++++++----- .../jdk/internal/ref/CleanerFactory.java | 14 +---- .../classes/jdk/internal/ref/CleanerImpl.java | 11 +--- 3 files changed, 51 insertions(+), 35 deletions(-) diff --git a/src/java.base/share/classes/jdk/internal/misc/InnocuousThread.java b/src/java.base/share/classes/jdk/internal/misc/InnocuousThread.java index 4c50d6f174678..dae3b8f3c2029 100644 --- a/src/java.base/share/classes/jdk/internal/misc/InnocuousThread.java +++ b/src/java.base/share/classes/jdk/internal/misc/InnocuousThread.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -50,7 +50,7 @@ private static String newName() { } /** - * Returns a new InnocuousThread with an auto-generated thread name + * Returns a new InnocuousThread with an auto-generated thread name, * and its context class loader is set to the system class loader. */ public static Thread newThread(Runnable target) { @@ -62,14 +62,22 @@ public static Thread newThread(Runnable target) { * set to the system class loader. */ public static Thread newThread(String name, Runnable target) { + return newThread(name, target, -1); + } + /** + * Returns a new InnocuousThread with its context class loader + * set to the system class loader. The thread priority will be + * set to the given priority. + */ + public static Thread newThread(String name, Runnable target, int priority) { + if (System.getSecurityManager() == null) { + return createThread(name, target, ClassLoader.getSystemClassLoader(), priority); + } return AccessController.doPrivileged( new PrivilegedAction() { @Override public Thread run() { - return new InnocuousThread(INNOCUOUSTHREADGROUP, - target, - name, - ClassLoader.getSystemClassLoader()); + return createThread(name, target, ClassLoader.getSystemClassLoader(), priority); } }); } @@ -86,16 +94,35 @@ public static Thread newSystemThread(Runnable target) { * Returns a new InnocuousThread with null context class loader. */ public static Thread newSystemThread(String name, Runnable target) { + return newSystemThread(name, target, -1); + } + + /** + * Returns a new InnocuousThread with null context class loader. + * Thread priority is set to the given priority. + */ + public static Thread newSystemThread(String name, Runnable target, int priority) { + if (System.getSecurityManager() == null) { + return createThread(name, target, null, priority); + } return AccessController.doPrivileged( new PrivilegedAction() { @Override public Thread run() { - return new InnocuousThread(INNOCUOUSTHREADGROUP, - target, name, null); + return createThread(name, target, null, priority); } }); } + private static Thread createThread(String name, Runnable target, ClassLoader loader, int priority) { + Thread t = new InnocuousThread(INNOCUOUSTHREADGROUP, + target, name, loader); + if (priority >= 0) { + t.setPriority(priority); + } + return t; + } + private InnocuousThread(ThreadGroup group, Runnable target, String name, ClassLoader tccl) { super(group, target, name, 0L, false); UNSAFE.putReferenceRelease(this, INHERITEDACCESSCONTROLCONTEXT, ACC); @@ -167,13 +194,17 @@ public void run() { group = parent; } final ThreadGroup root = group; - INNOCUOUSTHREADGROUP = AccessController.doPrivileged( - new PrivilegedAction() { - @Override - public ThreadGroup run() { - return new ThreadGroup(root, "InnocuousThreadGroup"); - } - }); + if (System.getSecurityManager() == null) { + INNOCUOUSTHREADGROUP = new ThreadGroup(root, "InnocuousThreadGroup"); + } else { + INNOCUOUSTHREADGROUP = AccessController.doPrivileged( + new PrivilegedAction() { + @Override + public ThreadGroup run() { + return new ThreadGroup(root, "InnocuousThreadGroup"); + } + }); + } } catch (Exception e) { throw new Error(e); } diff --git a/src/java.base/share/classes/jdk/internal/ref/CleanerFactory.java b/src/java.base/share/classes/jdk/internal/ref/CleanerFactory.java index e55e9d6378e7a..ab5f042de9728 100644 --- a/src/java.base/share/classes/jdk/internal/ref/CleanerFactory.java +++ b/src/java.base/share/classes/jdk/internal/ref/CleanerFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,8 +28,6 @@ import jdk.internal.misc.InnocuousThread; import java.lang.ref.Cleaner; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.util.concurrent.ThreadFactory; /** @@ -42,14 +40,8 @@ public final class CleanerFactory { private final static Cleaner commonCleaner = Cleaner.create(new ThreadFactory() { @Override public Thread newThread(Runnable r) { - return AccessController.doPrivileged(new PrivilegedAction<>() { - @Override - public Thread run() { - Thread t = InnocuousThread.newSystemThread("Common-Cleaner", r); - t.setPriority(Thread.MAX_PRIORITY - 2); - return t; - } - }); + return InnocuousThread.newSystemThread("Common-Cleaner", + r, Thread.MAX_PRIORITY - 2); } }); diff --git a/src/java.base/share/classes/jdk/internal/ref/CleanerImpl.java b/src/java.base/share/classes/jdk/internal/ref/CleanerImpl.java index 60924e19774d0..535e1cdcca4be 100644 --- a/src/java.base/share/classes/jdk/internal/ref/CleanerImpl.java +++ b/src/java.base/share/classes/jdk/internal/ref/CleanerImpl.java @@ -213,15 +213,8 @@ static ThreadFactory factory() { final AtomicInteger cleanerThreadNumber = new AtomicInteger(); public Thread newThread(Runnable r) { - return AccessController.doPrivileged(new PrivilegedAction<>() { - @Override - public Thread run() { - Thread t = InnocuousThread.newThread(r); - t.setPriority(Thread.MAX_PRIORITY - 2); - t.setName("Cleaner-" + cleanerThreadNumber.getAndIncrement()); - return t; - } - }); + return InnocuousThread.newThread("Cleaner-" + cleanerThreadNumber.getAndIncrement(), + r, Thread.MIN_PRIORITY - 2); } } From 83357b11967c30df42ca802a560cc163e8945689 Mon Sep 17 00:00:00 2001 From: Claes Redestad Date: Thu, 4 Feb 2021 10:47:03 +0000 Subject: [PATCH 58/77] 8261030: Avoid loading GenerateJLIClassesHelper at runtime Reviewed-by: mchung --- .../java/lang/invoke/ClassSpecializer.java | 8 ++--- .../lang/invoke/GenerateJLIClassesHelper.java | 33 ++--------------- .../lang/invoke/InvokerBytecodeGenerator.java | 3 +- .../java/lang/invoke/MethodHandleStatics.java | 35 ++++++++++++++++++- 4 files changed, 42 insertions(+), 37 deletions(-) diff --git a/src/java.base/share/classes/java/lang/invoke/ClassSpecializer.java b/src/java.base/share/classes/java/lang/invoke/ClassSpecializer.java index f05f2b10349c3..df588feb3bc32 100644 --- a/src/java.base/share/classes/java/lang/invoke/ClassSpecializer.java +++ b/src/java.base/share/classes/java/lang/invoke/ClassSpecializer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,7 +46,6 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.function.Function; -import static java.lang.invoke.GenerateJLIClassesHelper.traceSpeciesType; import static java.lang.invoke.LambdaForm.*; import static java.lang.invoke.MethodHandleNatives.Constants.REF_getStatic; import static java.lang.invoke.MethodHandleNatives.Constants.REF_putStatic; @@ -476,8 +475,10 @@ S loadSpecies(S speciesData) { Class salvage = null; try { salvage = BootLoader.loadClassOrNull(className); - traceSpeciesType(className, salvage); } catch (Error ex) { + // ignore + } finally { + traceSpeciesType(className, salvage); } final Class speciesCode; if (salvage != null) { @@ -488,7 +489,6 @@ S loadSpecies(S speciesData) { // Not pregenerated, generate the class try { speciesCode = generateConcreteSpeciesCode(className, speciesData); - traceSpeciesType(className, salvage); // This operation causes a lot of churn: linkSpeciesDataToCode(speciesData, speciesCode); // This operation commits the relation, but causes little churn: diff --git a/src/java.base/share/classes/java/lang/invoke/GenerateJLIClassesHelper.java b/src/java.base/share/classes/java/lang/invoke/GenerateJLIClassesHelper.java index 6e50118f20e70..33e1cec373c97 100644 --- a/src/java.base/share/classes/java/lang/invoke/GenerateJLIClassesHelper.java +++ b/src/java.base/share/classes/java/lang/invoke/GenerateJLIClassesHelper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,6 @@ package java.lang.invoke; -import jdk.internal.misc.CDS; import jdk.internal.org.objectweb.asm.ClassWriter; import jdk.internal.org.objectweb.asm.Opcodes; import sun.invoke.util.Wrapper; @@ -39,10 +38,7 @@ import java.util.TreeSet; import java.util.stream.Stream; -import static java.lang.invoke.LambdaForm.basicTypeSignature; -import static java.lang.invoke.LambdaForm.shortenSignature; import static java.lang.invoke.LambdaForm.BasicType.*; -import static java.lang.invoke.MethodHandleStatics.TRACE_RESOLVE; import static java.lang.invoke.MethodTypeForm.*; import static java.lang.invoke.LambdaForm.Kind.*; @@ -51,29 +47,6 @@ * generate classes ahead of time. */ class GenerateJLIClassesHelper { - private static final String LF_RESOLVE = "[LF_RESOLVE]"; - private static final String SPECIES_RESOLVE = "[SPECIES_RESOLVE]"; - - static void traceLambdaForm(String name, MethodType type, Class holder, MemberName resolvedMember) { - if (TRACE_RESOLVE) { - System.out.println(LF_RESOLVE + " " + holder.getName() + " " + name + " " + - shortenSignature(basicTypeSignature(type)) + - (resolvedMember != null ? " (success)" : " (fail)")); - } - if (CDS.isDumpingClassList()) { - CDS.traceLambdaFormInvoker(LF_RESOLVE, holder.getName(), name, shortenSignature(basicTypeSignature(type))); - } - } - - static void traceSpeciesType(String cn, Class salvage) { - if (TRACE_RESOLVE) { - System.out.println(SPECIES_RESOLVE + " " + cn + (salvage != null ? " (salvaged)" : " (generated)")); - } - if (CDS.isDumpingClassList()) { - CDS.traceSpeciesType(SPECIES_RESOLVE, cn); - } - } - // Map from DirectMethodHandle method type name to index to LambdForms static final Map DMH_METHOD_TYPE_MAP = Map.of( @@ -323,7 +296,7 @@ static Map generateHolderClasses(Stream traces) { traces.map(line -> line.split(" ")) .forEach(parts -> { switch (parts[0]) { - case SPECIES_RESOLVE: + case "[SPECIES_RESOLVE]": // Allow for new types of species data classes being resolved here assert parts.length >= 2; if (parts[1].startsWith(BMH_SPECIES_PREFIX)) { @@ -333,7 +306,7 @@ static Map generateHolderClasses(Stream traces) { } } break; - case LF_RESOLVE: + case "[LF_RESOLVE]": assert parts.length > 3; String methodType = parts[3]; if (parts[1].equals(INVOKERS_HOLDER_CLASS_NAME)) { diff --git a/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java b/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java index e4190012b39d7..7c4859b347e76 100644 --- a/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java +++ b/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,7 +46,6 @@ import java.util.List; import java.util.stream.Stream; -import static java.lang.invoke.GenerateJLIClassesHelper.traceLambdaForm; import static java.lang.invoke.LambdaForm.BasicType; import static java.lang.invoke.LambdaForm.BasicType.*; import static java.lang.invoke.LambdaForm.*; diff --git a/src/java.base/share/classes/java/lang/invoke/MethodHandleStatics.java b/src/java.base/share/classes/java/lang/invoke/MethodHandleStatics.java index 942d3b457e6ee..f926ddf5116ce 100644 --- a/src/java.base/share/classes/java/lang/invoke/MethodHandleStatics.java +++ b/src/java.base/share/classes/java/lang/invoke/MethodHandleStatics.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,11 +25,15 @@ package java.lang.invoke; +import jdk.internal.misc.CDS; import jdk.internal.misc.Unsafe; import sun.security.action.GetPropertyAction; import java.util.Properties; +import static java.lang.invoke.LambdaForm.basicTypeSignature; +import static java.lang.invoke.LambdaForm.shortenSignature; + /** * This class consists exclusively of static names internal to the * method handle implementation. @@ -108,6 +112,35 @@ static boolean debugEnabled() { LOG_LF_COMPILATION_FAILURE); } + /** + * If requested, logs the result of resolving the LambdaForm to stdout + * and informs the CDS subsystem about it. + */ + /*non-public*/ + static void traceLambdaForm(String name, MethodType type, Class holder, MemberName resolvedMember) { + if (TRACE_RESOLVE) { + System.out.println("[LF_RESOLVE] " + holder.getName() + " " + name + " " + + shortenSignature(basicTypeSignature(type)) + + (resolvedMember != null ? " (success)" : " (fail)")); + } + if (CDS.isDumpingClassList()) { + CDS.traceLambdaFormInvoker("[LF_RESOLVE]", holder.getName(), name, shortenSignature(basicTypeSignature(type))); + } + } + + /** + * If requested, logs the result of resolving the species type to stdout + * and the CDS subsystem. + */ + /*non-public*/ + static void traceSpeciesType(String cn, Class salvage) { + if (TRACE_RESOLVE) { + System.out.println("[SPECIES_RESOLVE] " + cn + (salvage != null ? " (salvaged)" : " (generated)")); + } + if (CDS.isDumpingClassList()) { + CDS.traceSpeciesType("[SPECIES_RESOLVE]", cn); + } + } // handy shared exception makers (they simplify the common case code) /*non-public*/ static InternalError newInternalError(String message) { From be772ffaf3263b9505f051a88b4a9e965fb98fe7 Mon Sep 17 00:00:00 2001 From: Thomas Schatzl Date: Thu, 4 Feb 2021 13:47:51 +0000 Subject: [PATCH 59/77] 8261023: Document why memory pretouch must be a store Reviewed-by: shade, iwalulya --- src/hotspot/share/runtime/os.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/hotspot/share/runtime/os.cpp b/src/hotspot/share/runtime/os.cpp index c32c7764cf497..48eb6354a1abf 100644 --- a/src/hotspot/share/runtime/os.cpp +++ b/src/hotspot/share/runtime/os.cpp @@ -1814,6 +1814,10 @@ void os::print_memory_mappings(outputStream* st) { void os::pretouch_memory(void* start, void* end, size_t page_size) { for (volatile char *p = (char*)start; p < (char*)end; p += page_size) { + // Note: this must be a store, not a load. On many OSes loads from fresh + // memory would be satisfied from a single mapped page containing all zeros. + // We need to store something to each page to get them backed by their own + // memory, which is the effect we want here. *p = 0; } } From f7a6cff98320e51530456a026c5cbb1501e7aa5c Mon Sep 17 00:00:00 2001 From: Magnus Ihse Bursie Date: Thu, 4 Feb 2021 14:37:33 +0000 Subject: [PATCH 60/77] 8261149: Initial nroff manpage update for JDK 17 Reviewed-by: dholmes, erikj --- src/java.base/share/man/java.1 | 18 +----------------- src/java.base/share/man/keytool.1 | 2 +- src/java.rmi/share/man/rmid.1 | 2 +- src/java.rmi/share/man/rmiregistry.1 | 2 +- src/java.scripting/share/man/jrunscript.1 | 2 +- src/jdk.compiler/share/man/javac.1 | 7 +------ src/jdk.compiler/share/man/serialver.1 | 2 +- src/jdk.hotspot.agent/share/man/jhsdb.1 | 2 +- src/jdk.jartool/share/man/jar.1 | 2 +- src/jdk.jartool/share/man/jarsigner.1 | 2 +- src/jdk.javadoc/share/man/javadoc.1 | 2 +- src/jdk.jcmd/share/man/jcmd.1 | 2 +- src/jdk.jcmd/share/man/jinfo.1 | 2 +- src/jdk.jcmd/share/man/jmap.1 | 2 +- src/jdk.jcmd/share/man/jps.1 | 2 +- src/jdk.jcmd/share/man/jstack.1 | 2 +- src/jdk.jcmd/share/man/jstat.1 | 2 +- src/jdk.jconsole/share/man/jconsole.1 | 2 +- src/jdk.jdeps/share/man/javap.1 | 2 +- src/jdk.jdeps/share/man/jdeprscan.1 | 2 +- src/jdk.jdeps/share/man/jdeps.1 | 2 +- src/jdk.jdi/share/man/jdb.1 | 2 +- src/jdk.jfr/share/man/jfr.1 | 2 +- src/jdk.jlink/share/man/jlink.1 | 2 +- src/jdk.jlink/share/man/jmod.1 | 2 +- src/jdk.jpackage/share/man/jpackage.1 | 2 +- src/jdk.jshell/share/man/jshell.1 | 2 +- src/jdk.jstatd/share/man/jstatd.1 | 2 +- 28 files changed, 28 insertions(+), 49 deletions(-) diff --git a/src/java.base/share/man/java.1 b/src/java.base/share/man/java.1 index e815315ec1513..070ba40d8e0dc 100644 --- a/src/java.base/share/man/java.1 +++ b/src/java.base/share/man/java.1 @@ -22,7 +22,7 @@ .\"t .\" Automatically generated by Pandoc 2.3.1 .\" -.TH "JAVA" "1" "2021" "JDK 17" "JDK Commands" +.TH "JAVA" "1" "2021" "JDK 17\-ea" "JDK Commands" .hy .SH NAME .PP @@ -4095,22 +4095,6 @@ The replacement Unified Logging syntax is \f[CB]\-Xlog:class+loader+constraints=info\f[R]. See \f[B]Enable Logging with the JVM Unified Logging Framework\f[R]. .RE -.SH REMOVED JAVA OPTIONS -.PP -These \f[CB]java\f[R] options have been removed in JDK 16 and using them -results in an error of: -.RS -.PP -\f[CB]Unrecognized\ VM\ option\f[R] \f[I]option\-name\f[R] -.RE -.TP -.B \f[CB]\-XX:+UseParallelOldGC\f[R] -Enables the use of the parallel garbage collector for full GCs. -By default, this option is disabled. -Enabling it automatically enables the \f[CB]\-XX:+UseParallelGC\f[R] -option. -.RS -.RE .PP For the lists and descriptions of options removed in previous releases see the \f[I]Removed Java Options\f[R] section in: diff --git a/src/java.base/share/man/keytool.1 b/src/java.base/share/man/keytool.1 index 26fa9a4483b31..70659fa119a46 100644 --- a/src/java.base/share/man/keytool.1 +++ b/src/java.base/share/man/keytool.1 @@ -22,7 +22,7 @@ .\"t .\" Automatically generated by Pandoc 2.3.1 .\" -.TH "KEYTOOL" "1" "2021" "JDK 16" "JDK Commands" +.TH "KEYTOOL" "1" "2021" "JDK 17\-ea" "JDK Commands" .hy .SH NAME .PP diff --git a/src/java.rmi/share/man/rmid.1 b/src/java.rmi/share/man/rmid.1 index a2e90aa33ba81..576fba5004289 100644 --- a/src/java.rmi/share/man/rmid.1 +++ b/src/java.rmi/share/man/rmid.1 @@ -21,7 +21,7 @@ .\" .\" Automatically generated by Pandoc 2.3.1 .\" -.TH "RMID" "1" "2021" "JDK 16" "JDK Commands" +.TH "RMID" "1" "2021" "JDK 17\-ea" "JDK Commands" .hy .SH NAME .PP diff --git a/src/java.rmi/share/man/rmiregistry.1 b/src/java.rmi/share/man/rmiregistry.1 index 9bb958cedc191..c683afa8ff979 100644 --- a/src/java.rmi/share/man/rmiregistry.1 +++ b/src/java.rmi/share/man/rmiregistry.1 @@ -21,7 +21,7 @@ .\" .\" Automatically generated by Pandoc 2.3.1 .\" -.TH "RMIREGISTRY" "1" "2021" "JDK 16" "JDK Commands" +.TH "RMIREGISTRY" "1" "2021" "JDK 17\-ea" "JDK Commands" .hy .SH NAME .PP diff --git a/src/java.scripting/share/man/jrunscript.1 b/src/java.scripting/share/man/jrunscript.1 index 9bc5e4bfb63d2..dfe15f0fcb236 100644 --- a/src/java.scripting/share/man/jrunscript.1 +++ b/src/java.scripting/share/man/jrunscript.1 @@ -21,7 +21,7 @@ .\" .\" Automatically generated by Pandoc 2.3.1 .\" -.TH "JRUNSCRIPT" "1" "2021" "JDK 16" "JDK Commands" +.TH "JRUNSCRIPT" "1" "2021" "JDK 17\-ea" "JDK Commands" .hy .SH NAME .PP diff --git a/src/jdk.compiler/share/man/javac.1 b/src/jdk.compiler/share/man/javac.1 index b6316aba28a88..8782020547a66 100644 --- a/src/jdk.compiler/share/man/javac.1 +++ b/src/jdk.compiler/share/man/javac.1 @@ -21,7 +21,7 @@ .\" .\" Automatically generated by Pandoc 2.3.1 .\" -.TH "JAVAC" "1" "2021" "JDK 16" "JDK Commands" +.TH "JAVAC" "1" "2021" "JDK 17\-ea" "JDK Commands" .hy .SH NAME .PP @@ -631,11 +631,6 @@ As applicable, see the descriptions in \f[B]\f[BC]\-\-release\f[B]\f[R], details. .RE .TP -.B \f[CB]\-\-doclint\-format\f[R] [\f[CB]html4\f[R]|\f[CB]html5\f[R]] -Specifies the format for documentation comments. -.RS -.RE -.TP .B \f[CB]\-\-patch\-module\f[R] \f[I]module\f[R]\f[CB]=\f[R]\f[I]path\f[R] Overrides or augments a module with classes and resources in JAR files or directories. diff --git a/src/jdk.compiler/share/man/serialver.1 b/src/jdk.compiler/share/man/serialver.1 index c051ec84abeab..c1ec3ebcee65f 100644 --- a/src/jdk.compiler/share/man/serialver.1 +++ b/src/jdk.compiler/share/man/serialver.1 @@ -21,7 +21,7 @@ .\" .\" Automatically generated by Pandoc 2.3.1 .\" -.TH "SERIALVER" "1" "2021" "JDK 16" "JDK Commands" +.TH "SERIALVER" "1" "2021" "JDK 17\-ea" "JDK Commands" .hy .SH NAME .PP diff --git a/src/jdk.hotspot.agent/share/man/jhsdb.1 b/src/jdk.hotspot.agent/share/man/jhsdb.1 index 5e6700ec25ce2..8c6267c19ed65 100644 --- a/src/jdk.hotspot.agent/share/man/jhsdb.1 +++ b/src/jdk.hotspot.agent/share/man/jhsdb.1 @@ -21,7 +21,7 @@ .\" .\" Automatically generated by Pandoc 2.3.1 .\" -.TH "JHSDB" "1" "2021" "JDK 16" "JDK Commands" +.TH "JHSDB" "1" "2021" "JDK 17\-ea" "JDK Commands" .hy .SH NAME .PP diff --git a/src/jdk.jartool/share/man/jar.1 b/src/jdk.jartool/share/man/jar.1 index a8077290fc6f7..9bbc314f9df6c 100644 --- a/src/jdk.jartool/share/man/jar.1 +++ b/src/jdk.jartool/share/man/jar.1 @@ -21,7 +21,7 @@ .\" .\" Automatically generated by Pandoc 2.3.1 .\" -.TH "JAR" "1" "2021" "JDK 16" "JDK Commands" +.TH "JAR" "1" "2021" "JDK 17\-ea" "JDK Commands" .hy .SH NAME .PP diff --git a/src/jdk.jartool/share/man/jarsigner.1 b/src/jdk.jartool/share/man/jarsigner.1 index 661c62368468f..842a9a1fb9297 100644 --- a/src/jdk.jartool/share/man/jarsigner.1 +++ b/src/jdk.jartool/share/man/jarsigner.1 @@ -22,7 +22,7 @@ .\"t .\" Automatically generated by Pandoc 2.3.1 .\" -.TH "JARSIGNER" "1" "2021" "JDK 16" "JDK Commands" +.TH "JARSIGNER" "1" "2021" "JDK 17\-ea" "JDK Commands" .hy .SH NAME .PP diff --git a/src/jdk.javadoc/share/man/javadoc.1 b/src/jdk.javadoc/share/man/javadoc.1 index bdeed2067ee40..f3a9f50a5a158 100644 --- a/src/jdk.javadoc/share/man/javadoc.1 +++ b/src/jdk.javadoc/share/man/javadoc.1 @@ -21,7 +21,7 @@ .\" .\" Automatically generated by Pandoc 2.3.1 .\" -.TH "JAVADOC" "1" "2021" "JDK 16" "JDK Commands" +.TH "JAVADOC" "1" "2021" "JDK 17\-ea" "JDK Commands" .hy .SH NAME .PP diff --git a/src/jdk.jcmd/share/man/jcmd.1 b/src/jdk.jcmd/share/man/jcmd.1 index a5773391e82ed..1a3a9d7192b68 100644 --- a/src/jdk.jcmd/share/man/jcmd.1 +++ b/src/jdk.jcmd/share/man/jcmd.1 @@ -21,7 +21,7 @@ .\" .\" Automatically generated by Pandoc 2.3.1 .\" -.TH "JCMD" "1" "2021" "JDK 16" "JDK Commands" +.TH "JCMD" "1" "2021" "JDK 17\-ea" "JDK Commands" .hy .SH NAME .PP diff --git a/src/jdk.jcmd/share/man/jinfo.1 b/src/jdk.jcmd/share/man/jinfo.1 index cfbe379b4c656..3f2797c498f4a 100644 --- a/src/jdk.jcmd/share/man/jinfo.1 +++ b/src/jdk.jcmd/share/man/jinfo.1 @@ -21,7 +21,7 @@ .\" .\" Automatically generated by Pandoc 2.3.1 .\" -.TH "JINFO" "1" "2021" "JDK 16" "JDK Commands" +.TH "JINFO" "1" "2021" "JDK 17\-ea" "JDK Commands" .hy .SH NAME .PP diff --git a/src/jdk.jcmd/share/man/jmap.1 b/src/jdk.jcmd/share/man/jmap.1 index 4a0dc53d66fe4..1e0d4ac82f6a1 100644 --- a/src/jdk.jcmd/share/man/jmap.1 +++ b/src/jdk.jcmd/share/man/jmap.1 @@ -21,7 +21,7 @@ .\" .\" Automatically generated by Pandoc 2.3.1 .\" -.TH "JMAP" "1" "2021" "JDK 16" "JDK Commands" +.TH "JMAP" "1" "2021" "JDK 17\-ea" "JDK Commands" .hy .SH NAME .PP diff --git a/src/jdk.jcmd/share/man/jps.1 b/src/jdk.jcmd/share/man/jps.1 index 0812a58603b33..48a503e532187 100644 --- a/src/jdk.jcmd/share/man/jps.1 +++ b/src/jdk.jcmd/share/man/jps.1 @@ -21,7 +21,7 @@ .\" .\" Automatically generated by Pandoc 2.3.1 .\" -.TH "JPS" "1" "2021" "JDK 16" "JDK Commands" +.TH "JPS" "1" "2021" "JDK 17\-ea" "JDK Commands" .hy .SH NAME .PP diff --git a/src/jdk.jcmd/share/man/jstack.1 b/src/jdk.jcmd/share/man/jstack.1 index 0885ddccfe017..578fdc7dd2646 100644 --- a/src/jdk.jcmd/share/man/jstack.1 +++ b/src/jdk.jcmd/share/man/jstack.1 @@ -21,7 +21,7 @@ .\" .\" Automatically generated by Pandoc 2.3.1 .\" -.TH "JSTACK" "1" "2021" "JDK 16" "JDK Commands" +.TH "JSTACK" "1" "2021" "JDK 17\-ea" "JDK Commands" .hy .SH NAME .PP diff --git a/src/jdk.jcmd/share/man/jstat.1 b/src/jdk.jcmd/share/man/jstat.1 index 62b1fc98e72ab..00adb8dcb2c40 100644 --- a/src/jdk.jcmd/share/man/jstat.1 +++ b/src/jdk.jcmd/share/man/jstat.1 @@ -21,7 +21,7 @@ .\" .\" Automatically generated by Pandoc 2.3.1 .\" -.TH "JSTAT" "1" "2021" "JDK 16" "JDK Commands" +.TH "JSTAT" "1" "2021" "JDK 17\-ea" "JDK Commands" .hy .SH NAME .PP diff --git a/src/jdk.jconsole/share/man/jconsole.1 b/src/jdk.jconsole/share/man/jconsole.1 index 940a9d0547100..de03996008898 100644 --- a/src/jdk.jconsole/share/man/jconsole.1 +++ b/src/jdk.jconsole/share/man/jconsole.1 @@ -21,7 +21,7 @@ .\" .\" Automatically generated by Pandoc 2.3.1 .\" -.TH "JCONSOLE" "1" "2021" "JDK 16" "JDK Commands" +.TH "JCONSOLE" "1" "2021" "JDK 17\-ea" "JDK Commands" .hy .SH NAME .PP diff --git a/src/jdk.jdeps/share/man/javap.1 b/src/jdk.jdeps/share/man/javap.1 index 153448b8c6322..e1982398c38f0 100644 --- a/src/jdk.jdeps/share/man/javap.1 +++ b/src/jdk.jdeps/share/man/javap.1 @@ -21,7 +21,7 @@ .\" .\" Automatically generated by Pandoc 2.3.1 .\" -.TH "JAVAP" "1" "2021" "JDK 16" "JDK Commands" +.TH "JAVAP" "1" "2021" "JDK 17\-ea" "JDK Commands" .hy .SH NAME .PP diff --git a/src/jdk.jdeps/share/man/jdeprscan.1 b/src/jdk.jdeps/share/man/jdeprscan.1 index 67f46c9edfe1e..53db8583a54b4 100644 --- a/src/jdk.jdeps/share/man/jdeprscan.1 +++ b/src/jdk.jdeps/share/man/jdeprscan.1 @@ -21,7 +21,7 @@ .\" .\" Automatically generated by Pandoc 2.3.1 .\" -.TH "JDEPRSCAN" "1" "2021" "JDK 16" "JDK Commands" +.TH "JDEPRSCAN" "1" "2021" "JDK 17\-ea" "JDK Commands" .hy .SH NAME .PP diff --git a/src/jdk.jdeps/share/man/jdeps.1 b/src/jdk.jdeps/share/man/jdeps.1 index 1ca6c7e155bf8..46056c7899e30 100644 --- a/src/jdk.jdeps/share/man/jdeps.1 +++ b/src/jdk.jdeps/share/man/jdeps.1 @@ -21,7 +21,7 @@ .\" .\" Automatically generated by Pandoc 2.3.1 .\" -.TH "JDEPS" "1" "2021" "JDK 16" "JDK Commands" +.TH "JDEPS" "1" "2021" "JDK 17\-ea" "JDK Commands" .hy .SH NAME .PP diff --git a/src/jdk.jdi/share/man/jdb.1 b/src/jdk.jdi/share/man/jdb.1 index eb8cf1bab793e..edf0ac6b4af2c 100644 --- a/src/jdk.jdi/share/man/jdb.1 +++ b/src/jdk.jdi/share/man/jdb.1 @@ -21,7 +21,7 @@ .\" .\" Automatically generated by Pandoc 2.3.1 .\" -.TH "JDB" "1" "2021" "JDK 16" "JDK Commands" +.TH "JDB" "1" "2021" "JDK 17\-ea" "JDK Commands" .hy .SH NAME .PP diff --git a/src/jdk.jfr/share/man/jfr.1 b/src/jdk.jfr/share/man/jfr.1 index 588a3bd45f17a..cb63d227d6a38 100644 --- a/src/jdk.jfr/share/man/jfr.1 +++ b/src/jdk.jfr/share/man/jfr.1 @@ -21,7 +21,7 @@ .\" .\" Automatically generated by Pandoc 2.3.1 .\" -.TH "JFR" "1" "2021" "JDK 16" "JDK Commands" +.TH "JFR" "1" "2021" "JDK 17\-ea" "JDK Commands" .hy .SH NAME .PP diff --git a/src/jdk.jlink/share/man/jlink.1 b/src/jdk.jlink/share/man/jlink.1 index 2f4b37d740d91..9fa2785fef692 100644 --- a/src/jdk.jlink/share/man/jlink.1 +++ b/src/jdk.jlink/share/man/jlink.1 @@ -21,7 +21,7 @@ .\" .\" Automatically generated by Pandoc 2.3.1 .\" -.TH "JLINK" "1" "2021" "JDK 16" "JDK Commands" +.TH "JLINK" "1" "2021" "JDK 17\-ea" "JDK Commands" .hy .SH NAME .PP diff --git a/src/jdk.jlink/share/man/jmod.1 b/src/jdk.jlink/share/man/jmod.1 index bfc290f6b7209..b512895990b4d 100644 --- a/src/jdk.jlink/share/man/jmod.1 +++ b/src/jdk.jlink/share/man/jmod.1 @@ -21,7 +21,7 @@ .\" .\" Automatically generated by Pandoc 2.3.1 .\" -.TH "JMOD" "1" "2021" "JDK 16" "JDK Commands" +.TH "JMOD" "1" "2021" "JDK 17\-ea" "JDK Commands" .hy .SH NAME .PP diff --git a/src/jdk.jpackage/share/man/jpackage.1 b/src/jdk.jpackage/share/man/jpackage.1 index 8fa4a24005b68..b8ea1ae09d483 100644 --- a/src/jdk.jpackage/share/man/jpackage.1 +++ b/src/jdk.jpackage/share/man/jpackage.1 @@ -21,7 +21,7 @@ .\" .\" Automatically generated by Pandoc 2.3.1 .\" -.TH "JPACKAGE" "1" "2019" "JDK 16" "JDK Commands" +.TH "JPACKAGE" "1" "2019" "JDK 17\-ea" "JDK Commands" .hy .SH NAME .PP diff --git a/src/jdk.jshell/share/man/jshell.1 b/src/jdk.jshell/share/man/jshell.1 index 72b5a5ea12990..39d18e197ef33 100644 --- a/src/jdk.jshell/share/man/jshell.1 +++ b/src/jdk.jshell/share/man/jshell.1 @@ -22,7 +22,7 @@ .\"t .\" Automatically generated by Pandoc 2.3.1 .\" -.TH "JSHELL" "1" "2021" "JDK 16" "JDK Commands" +.TH "JSHELL" "1" "2021" "JDK 17\-ea" "JDK Commands" .hy .SH NAME .PP diff --git a/src/jdk.jstatd/share/man/jstatd.1 b/src/jdk.jstatd/share/man/jstatd.1 index 4299af9228311..21388eb527a39 100644 --- a/src/jdk.jstatd/share/man/jstatd.1 +++ b/src/jdk.jstatd/share/man/jstatd.1 @@ -21,7 +21,7 @@ .\" .\" Automatically generated by Pandoc 2.3.1 .\" -.TH "JSTATD" "1" "2021" "JDK 16" "JDK Commands" +.TH "JSTATD" "1" "2021" "JDK 17\-ea" "JDK Commands" .hy .SH NAME .PP From c1dea39d08e3a9af03430b603e24192a02cde223 Mon Sep 17 00:00:00 2001 From: Andy Herrick Date: Thu, 4 Feb 2021 14:50:54 +0000 Subject: [PATCH 61/77] 8260335: [macos] Running app using relative path causes problems Reviewed-by: almatvee, kizune --- src/jdk.jpackage/share/native/common/FileUtils.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/jdk.jpackage/share/native/common/FileUtils.cpp b/src/jdk.jpackage/share/native/common/FileUtils.cpp index 07a19ed888736..59bbd83fe7d2c 100644 --- a/src/jdk.jpackage/share/native/common/FileUtils.cpp +++ b/src/jdk.jpackage/share/native/common/FileUtils.cpp @@ -28,7 +28,6 @@ #include "FileUtils.h" - namespace FileUtils { #ifdef _WIN32 @@ -54,7 +53,15 @@ bool isDirSeparator(const tstring::value_type c) { tstring dirname(const tstring &path) { - tstring::size_type pos = path.find_last_of(_T("\\/")); + tstring::size_type pos; + if (tstrings::endsWith(path, _T("/.")) || tstrings::endsWith(path, _T("\\."))) { + // this method is really getparent dirname - if the path ends with "/.", + // we need to ignore that when looking for the last "/" to find parent + pos = (path.substr(0, path.length() - 2)).find_last_of(_T("\\/")); + } else { + pos = path.find_last_of(_T("\\/")); + } + if (pos != tstring::npos) { pos = path.find_last_not_of(_T("\\/"), pos); // skip trailing slashes } From e93e1e1c7b89101977c618253f01f3599547c280 Mon Sep 17 00:00:00 2001 From: Erik Gahlin Date: Thu, 4 Feb 2021 17:01:45 +0000 Subject: [PATCH 62/77] 8261157: Incorrect GPL header after JDK-8259956 Reviewed-by: mgronlun --- .../api/consumer/TestChunkInputStreamAvailable.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/test/jdk/jdk/jfr/api/consumer/TestChunkInputStreamAvailable.java b/test/jdk/jdk/jfr/api/consumer/TestChunkInputStreamAvailable.java index c59160a912375..e0b37dd365c92 100644 --- a/test/jdk/jdk/jfr/api/consumer/TestChunkInputStreamAvailable.java +++ b/test/jdk/jdk/jfr/api/consumer/TestChunkInputStreamAvailable.java @@ -1,22 +1,24 @@ /* - * Copyright (c) 2021, Alibaba Group Holding Limited. All Rights Reserved. + * Copyright (c) 2021, Alibaba Group Holding Limited. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Alibaba designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. + * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. */ /** From bdcbfa10cee058ad01dd594ec1c907eb35f4d130 Mon Sep 17 00:00:00 2001 From: Andy Herrick Date: Thu, 4 Feb 2021 17:48:36 +0000 Subject: [PATCH 63/77] 8259927: Windows jpackage installer issues Reviewed-by: asemenyuk, almatvee, kizune --- .../classes/jdk/jpackage/internal/WixSourcesBuilder.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WixSourcesBuilder.java b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WixSourcesBuilder.java index 3f94150b9ace1..6c2dd9c577318 100644 --- a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WixSourcesBuilder.java +++ b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WixSourcesBuilder.java @@ -551,9 +551,6 @@ private List addRootBranch(XMLStreamWriter xml, Path path) } List componentIds = new ArrayList<>(); - while (!SYSTEM_DIRS.contains(path = path.getParent())) { - componentIds.add(addRemoveDirectoryComponent(xml, path)); - } return componentIds; } From d9aefa36ac1d4b711a3082e3ce6c442d4cb8e718 Mon Sep 17 00:00:00 2001 From: Kiran Sidhartha Ravikumar Date: Thu, 4 Feb 2021 17:49:07 +0000 Subject: [PATCH 64/77] 8260356: (tz) Upgrade time-zone data to tzdata2021a Reviewed-by: naoto --- make/data/tzdata/VERSION | 2 +- make/data/tzdata/africa | 8 +++++++- make/data/tzdata/leapseconds | 8 ++++---- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/make/data/tzdata/VERSION b/make/data/tzdata/VERSION index d946a9fd9fed9..71632a7bb6131 100644 --- a/make/data/tzdata/VERSION +++ b/make/data/tzdata/VERSION @@ -21,4 +21,4 @@ # or visit www.oracle.com if you need additional information or have any # questions. # -tzdata2020f +tzdata2021a diff --git a/make/data/tzdata/africa b/make/data/tzdata/africa index 4b5c9d8aa774e..5de2e5f4ab1b0 100644 --- a/make/data/tzdata/africa +++ b/make/data/tzdata/africa @@ -1550,11 +1550,17 @@ Zone Africa/Khartoum 2:10:08 - LMT 1931 3:00 - EAT 2017 Nov 1 2:00 - CAT +# From Steffen Thorsen (2021-01-18): +# "South Sudan will change its time zone by setting the clock back 1 +# hour on February 1, 2021...." +# from https://eyeradio.org/south-sudan-adopts-new-time-zone-makuei/ + # South Sudan # Zone NAME STDOFF RULES FORMAT [UNTIL] Zone Africa/Juba 2:06:28 - LMT 1931 2:00 Sudan CA%sT 2000 Jan 15 12:00 - 3:00 - EAT + 3:00 - EAT 2021 Feb 1 00:00 + 2:00 - CAT # Tanzania # See Africa/Nairobi. diff --git a/make/data/tzdata/leapseconds b/make/data/tzdata/leapseconds index d5f74194ade02..6f1941601d3b9 100644 --- a/make/data/tzdata/leapseconds +++ b/make/data/tzdata/leapseconds @@ -95,11 +95,11 @@ Leap 2016 Dec 31 23:59:60 + S # Any additional leap seconds will come after this. # This Expires line is commented out for now, # so that pre-2020a zic implementations do not reject this file. -#Expires 2021 Jun 28 00:00:00 +#Expires 2021 Dec 28 00:00:00 # POSIX timestamps for the data in this file: #updated 1467936000 (2016-07-08 00:00:00 UTC) -#expires 1624838400 (2021-06-28 00:00:00 UTC) +#expires 1640649600 (2021-12-28 00:00:00 UTC) -# Updated through IERS Bulletin C60 -# File expires on: 28 June 2021 +# Updated through IERS Bulletin C61 +# File expires on: 28 December 2021 From c59e4b66bb85471314cf469ca56213207a2ba62e Mon Sep 17 00:00:00 2001 From: Ioi Lam Date: Thu, 4 Feb 2021 19:05:38 +0000 Subject: [PATCH 65/77] 8261106: Reduce inclusion of jniHandles.hpp Reviewed-by: coleenp, hseigel --- src/hotspot/cpu/aarch64/jvmciCodeInstaller_aarch64.cpp | 1 + src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp | 1 + .../cpu/aarch64/templateInterpreterGenerator_aarch64.cpp | 1 + src/hotspot/cpu/arm/jniFastGetField_arm.cpp | 1 + src/hotspot/cpu/arm/macroAssembler_arm.cpp | 1 + src/hotspot/cpu/arm/sharedRuntime_arm.cpp | 1 + src/hotspot/cpu/arm/templateInterpreterGenerator_arm.cpp | 1 + src/hotspot/cpu/ppc/gc/g1/g1BarrierSetAssembler_ppc.cpp | 1 + src/hotspot/cpu/ppc/sharedRuntime_ppc.cpp | 1 + src/hotspot/cpu/ppc/templateInterpreterGenerator_ppc.cpp | 1 + src/hotspot/cpu/s390/gc/g1/g1BarrierSetAssembler_s390.cpp | 1 + src/hotspot/cpu/s390/gc/shared/barrierSetAssembler_s390.cpp | 1 + src/hotspot/cpu/s390/sharedRuntime_s390.cpp | 1 + src/hotspot/cpu/s390/templateInterpreterGenerator_s390.cpp | 1 + src/hotspot/cpu/x86/jvmciCodeInstaller_x86.cpp | 1 + src/hotspot/cpu/x86/macroAssembler_x86.cpp | 1 + src/hotspot/cpu/x86/sharedRuntime_x86_32.cpp | 1 + src/hotspot/cpu/x86/sharedRuntime_x86_64.cpp | 1 + src/hotspot/cpu/x86/templateInterpreterGenerator_x86.cpp | 1 + src/hotspot/share/ci/ciBaseObject.hpp | 1 - src/hotspot/share/ci/ciMetadata.hpp | 1 - src/hotspot/share/ci/ciObject.hpp | 1 - src/hotspot/share/classfile/moduleEntry.hpp | 1 - src/hotspot/share/compiler/compileTask.cpp | 1 + src/hotspot/share/gc/shared/concurrentGCThread.cpp | 1 + src/hotspot/share/gc/shared/gcVMOperations.hpp | 1 - src/hotspot/share/gc/shenandoah/shenandoahRootVerifier.cpp | 1 + src/hotspot/share/jfr/dcmd/jfrDcmds.cpp | 1 + .../share/jfr/instrumentation/jfrEventClassTransformer.cpp | 1 + src/hotspot/share/jfr/leakprofiler/checkpoint/rootResolver.cpp | 1 + src/hotspot/share/jfr/writers/jfrWriterHost.inline.hpp | 1 + src/hotspot/share/jvmci/jvmciEnv.hpp | 1 + src/hotspot/share/jvmci/jvmciJavaClasses.hpp | 1 - src/hotspot/share/memory/universe.cpp | 1 + src/hotspot/share/prims/jvmtiEnter.xsl | 1 + src/hotspot/share/prims/jvmtiImpl.cpp | 1 + src/hotspot/share/runtime/os.cpp | 1 + src/hotspot/share/runtime/thread.hpp | 2 +- src/hotspot/share/runtime/vmOperations.cpp | 1 + src/hotspot/share/runtime/vmStructs.cpp | 1 + src/hotspot/share/runtime/vmThread.cpp | 1 + src/hotspot/share/services/diagnosticCommand.cpp | 1 + src/hotspot/share/services/threadService.hpp | 1 - 43 files changed, 36 insertions(+), 8 deletions(-) diff --git a/src/hotspot/cpu/aarch64/jvmciCodeInstaller_aarch64.cpp b/src/hotspot/cpu/aarch64/jvmciCodeInstaller_aarch64.cpp index cbe58e692dc4f..17b9780129db0 100644 --- a/src/hotspot/cpu/aarch64/jvmciCodeInstaller_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/jvmciCodeInstaller_aarch64.cpp @@ -30,6 +30,7 @@ #include "jvmci/jvmciJavaClasses.hpp" #include "oops/oop.inline.hpp" #include "runtime/handles.inline.hpp" +#include "runtime/jniHandles.hpp" #include "runtime/sharedRuntime.hpp" #include "vmreg_aarch64.inline.hpp" diff --git a/src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp b/src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp index 74e6fda8e8af5..310a92400c609 100644 --- a/src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp @@ -39,6 +39,7 @@ #include "oops/compiledICHolder.hpp" #include "oops/klass.inline.hpp" #include "prims/methodHandles.hpp" +#include "runtime/jniHandles.hpp" #include "runtime/safepointMechanism.hpp" #include "runtime/sharedRuntime.hpp" #include "runtime/signature.hpp" diff --git a/src/hotspot/cpu/aarch64/templateInterpreterGenerator_aarch64.cpp b/src/hotspot/cpu/aarch64/templateInterpreterGenerator_aarch64.cpp index 1c0796bf60b41..f94aebce3d4e2 100644 --- a/src/hotspot/cpu/aarch64/templateInterpreterGenerator_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/templateInterpreterGenerator_aarch64.cpp @@ -45,6 +45,7 @@ #include "runtime/arguments.hpp" #include "runtime/deoptimization.hpp" #include "runtime/frame.inline.hpp" +#include "runtime/jniHandles.hpp" #include "runtime/sharedRuntime.hpp" #include "runtime/stubRoutines.hpp" #include "runtime/synchronizer.hpp" diff --git a/src/hotspot/cpu/arm/jniFastGetField_arm.cpp b/src/hotspot/cpu/arm/jniFastGetField_arm.cpp index 85d27f61f2665..f333df579026f 100644 --- a/src/hotspot/cpu/arm/jniFastGetField_arm.cpp +++ b/src/hotspot/cpu/arm/jniFastGetField_arm.cpp @@ -30,6 +30,7 @@ #include "prims/jniFastGetField.hpp" #include "prims/jvm_misc.hpp" #include "prims/jvmtiExport.hpp" +#include "runtime/jniHandles.hpp" #include "runtime/safepoint.hpp" #define __ masm-> diff --git a/src/hotspot/cpu/arm/macroAssembler_arm.cpp b/src/hotspot/cpu/arm/macroAssembler_arm.cpp index 1f8f62fe1dc15..5843d9b956e8f 100644 --- a/src/hotspot/cpu/arm/macroAssembler_arm.cpp +++ b/src/hotspot/cpu/arm/macroAssembler_arm.cpp @@ -41,6 +41,7 @@ #include "prims/methodHandles.hpp" #include "runtime/biasedLocking.hpp" #include "runtime/interfaceSupport.inline.hpp" +#include "runtime/jniHandles.hpp" #include "runtime/objectMonitor.hpp" #include "runtime/os.hpp" #include "runtime/sharedRuntime.hpp" diff --git a/src/hotspot/cpu/arm/sharedRuntime_arm.cpp b/src/hotspot/cpu/arm/sharedRuntime_arm.cpp index 77385a9536dbc..b19bea1b2a126 100644 --- a/src/hotspot/cpu/arm/sharedRuntime_arm.cpp +++ b/src/hotspot/cpu/arm/sharedRuntime_arm.cpp @@ -34,6 +34,7 @@ #include "oops/compiledICHolder.hpp" #include "oops/klass.inline.hpp" #include "prims/methodHandles.hpp" +#include "runtime/jniHandles.hpp" #include "runtime/sharedRuntime.hpp" #include "runtime/safepointMechanism.hpp" #include "runtime/stubRoutines.hpp" diff --git a/src/hotspot/cpu/arm/templateInterpreterGenerator_arm.cpp b/src/hotspot/cpu/arm/templateInterpreterGenerator_arm.cpp index d0186b591fdd4..f38fe198c95fc 100644 --- a/src/hotspot/cpu/arm/templateInterpreterGenerator_arm.cpp +++ b/src/hotspot/cpu/arm/templateInterpreterGenerator_arm.cpp @@ -42,6 +42,7 @@ #include "runtime/arguments.hpp" #include "runtime/deoptimization.hpp" #include "runtime/frame.inline.hpp" +#include "runtime/jniHandles.hpp" #include "runtime/sharedRuntime.hpp" #include "runtime/stubRoutines.hpp" #include "runtime/synchronizer.hpp" diff --git a/src/hotspot/cpu/ppc/gc/g1/g1BarrierSetAssembler_ppc.cpp b/src/hotspot/cpu/ppc/gc/g1/g1BarrierSetAssembler_ppc.cpp index 28ff01fa01785..a95197aeed772 100644 --- a/src/hotspot/cpu/ppc/gc/g1/g1BarrierSetAssembler_ppc.cpp +++ b/src/hotspot/cpu/ppc/gc/g1/g1BarrierSetAssembler_ppc.cpp @@ -34,6 +34,7 @@ #include "gc/g1/g1ThreadLocalData.hpp" #include "gc/g1/heapRegion.hpp" #include "interpreter/interp_masm.hpp" +#include "runtime/jniHandles.hpp" #include "runtime/sharedRuntime.hpp" #ifdef COMPILER1 #include "c1/c1_LIRAssembler.hpp" diff --git a/src/hotspot/cpu/ppc/sharedRuntime_ppc.cpp b/src/hotspot/cpu/ppc/sharedRuntime_ppc.cpp index 3379d679fb7fc..191fadef42907 100644 --- a/src/hotspot/cpu/ppc/sharedRuntime_ppc.cpp +++ b/src/hotspot/cpu/ppc/sharedRuntime_ppc.cpp @@ -36,6 +36,7 @@ #include "oops/compiledICHolder.hpp" #include "oops/klass.inline.hpp" #include "prims/methodHandles.hpp" +#include "runtime/jniHandles.hpp" #include "runtime/safepointMechanism.hpp" #include "runtime/sharedRuntime.hpp" #include "runtime/signature.hpp" diff --git a/src/hotspot/cpu/ppc/templateInterpreterGenerator_ppc.cpp b/src/hotspot/cpu/ppc/templateInterpreterGenerator_ppc.cpp index ed95650255cea..515831bf58a22 100644 --- a/src/hotspot/cpu/ppc/templateInterpreterGenerator_ppc.cpp +++ b/src/hotspot/cpu/ppc/templateInterpreterGenerator_ppc.cpp @@ -42,6 +42,7 @@ #include "runtime/arguments.hpp" #include "runtime/deoptimization.hpp" #include "runtime/frame.inline.hpp" +#include "runtime/jniHandles.hpp" #include "runtime/sharedRuntime.hpp" #include "runtime/stubRoutines.hpp" #include "runtime/synchronizer.hpp" diff --git a/src/hotspot/cpu/s390/gc/g1/g1BarrierSetAssembler_s390.cpp b/src/hotspot/cpu/s390/gc/g1/g1BarrierSetAssembler_s390.cpp index 2735aa24e728c..ba4bfdc986449 100644 --- a/src/hotspot/cpu/s390/gc/g1/g1BarrierSetAssembler_s390.cpp +++ b/src/hotspot/cpu/s390/gc/g1/g1BarrierSetAssembler_s390.cpp @@ -35,6 +35,7 @@ #include "gc/g1/g1ThreadLocalData.hpp" #include "gc/g1/heapRegion.hpp" #include "interpreter/interp_masm.hpp" +#include "runtime/jniHandles.hpp" #include "runtime/sharedRuntime.hpp" #ifdef COMPILER1 #include "c1/c1_LIRAssembler.hpp" diff --git a/src/hotspot/cpu/s390/gc/shared/barrierSetAssembler_s390.cpp b/src/hotspot/cpu/s390/gc/shared/barrierSetAssembler_s390.cpp index 99cafd8bbdd18..a6dc2f90e5313 100644 --- a/src/hotspot/cpu/s390/gc/shared/barrierSetAssembler_s390.cpp +++ b/src/hotspot/cpu/s390/gc/shared/barrierSetAssembler_s390.cpp @@ -28,6 +28,7 @@ #include "gc/shared/barrierSetAssembler.hpp" #include "interpreter/interp_masm.hpp" #include "oops/compressedOops.hpp" +#include "runtime/jniHandles.hpp" #define __ masm-> diff --git a/src/hotspot/cpu/s390/sharedRuntime_s390.cpp b/src/hotspot/cpu/s390/sharedRuntime_s390.cpp index e91c749275893..79980aeb670a5 100644 --- a/src/hotspot/cpu/s390/sharedRuntime_s390.cpp +++ b/src/hotspot/cpu/s390/sharedRuntime_s390.cpp @@ -37,6 +37,7 @@ #include "oops/klass.inline.hpp" #include "prims/methodHandles.hpp" #include "registerSaver_s390.hpp" +#include "runtime/jniHandles.hpp" #include "runtime/safepointMechanism.hpp" #include "runtime/sharedRuntime.hpp" #include "runtime/signature.hpp" diff --git a/src/hotspot/cpu/s390/templateInterpreterGenerator_s390.cpp b/src/hotspot/cpu/s390/templateInterpreterGenerator_s390.cpp index 77753e495be33..bcceabb410556 100644 --- a/src/hotspot/cpu/s390/templateInterpreterGenerator_s390.cpp +++ b/src/hotspot/cpu/s390/templateInterpreterGenerator_s390.cpp @@ -42,6 +42,7 @@ #include "runtime/arguments.hpp" #include "runtime/deoptimization.hpp" #include "runtime/frame.inline.hpp" +#include "runtime/jniHandles.hpp" #include "runtime/sharedRuntime.hpp" #include "runtime/stubRoutines.hpp" #include "runtime/synchronizer.hpp" diff --git a/src/hotspot/cpu/x86/jvmciCodeInstaller_x86.cpp b/src/hotspot/cpu/x86/jvmciCodeInstaller_x86.cpp index 56c1bbdc34a00..7728d32e55867 100644 --- a/src/hotspot/cpu/x86/jvmciCodeInstaller_x86.cpp +++ b/src/hotspot/cpu/x86/jvmciCodeInstaller_x86.cpp @@ -26,6 +26,7 @@ #include "oops/oop.inline.hpp" #include "runtime/handles.inline.hpp" #include "runtime/javaCalls.hpp" +#include "runtime/jniHandles.hpp" #include "runtime/sharedRuntime.hpp" #include "jvmci/jvmci.hpp" #include "jvmci/jvmciEnv.hpp" diff --git a/src/hotspot/cpu/x86/macroAssembler_x86.cpp b/src/hotspot/cpu/x86/macroAssembler_x86.cpp index 066b82c90aeac..d6e7783bee171 100644 --- a/src/hotspot/cpu/x86/macroAssembler_x86.cpp +++ b/src/hotspot/cpu/x86/macroAssembler_x86.cpp @@ -42,6 +42,7 @@ #include "runtime/biasedLocking.hpp" #include "runtime/flags/flagSetting.hpp" #include "runtime/interfaceSupport.inline.hpp" +#include "runtime/jniHandles.hpp" #include "runtime/objectMonitor.hpp" #include "runtime/os.hpp" #include "runtime/safepoint.hpp" diff --git a/src/hotspot/cpu/x86/sharedRuntime_x86_32.cpp b/src/hotspot/cpu/x86/sharedRuntime_x86_32.cpp index b23e251cef9d9..b807541f71c52 100644 --- a/src/hotspot/cpu/x86/sharedRuntime_x86_32.cpp +++ b/src/hotspot/cpu/x86/sharedRuntime_x86_32.cpp @@ -38,6 +38,7 @@ #include "oops/compiledICHolder.hpp" #include "oops/klass.inline.hpp" #include "prims/methodHandles.hpp" +#include "runtime/jniHandles.hpp" #include "runtime/safepointMechanism.hpp" #include "runtime/sharedRuntime.hpp" #include "runtime/signature.hpp" diff --git a/src/hotspot/cpu/x86/sharedRuntime_x86_64.cpp b/src/hotspot/cpu/x86/sharedRuntime_x86_64.cpp index 48cbee6e45b7b..837b59d44fe2e 100644 --- a/src/hotspot/cpu/x86/sharedRuntime_x86_64.cpp +++ b/src/hotspot/cpu/x86/sharedRuntime_x86_64.cpp @@ -43,6 +43,7 @@ #include "oops/compiledICHolder.hpp" #include "oops/klass.inline.hpp" #include "prims/methodHandles.hpp" +#include "runtime/jniHandles.hpp" #include "runtime/safepointMechanism.hpp" #include "runtime/sharedRuntime.hpp" #include "runtime/signature.hpp" diff --git a/src/hotspot/cpu/x86/templateInterpreterGenerator_x86.cpp b/src/hotspot/cpu/x86/templateInterpreterGenerator_x86.cpp index 5033687bf77cc..98d156ea86b4a 100644 --- a/src/hotspot/cpu/x86/templateInterpreterGenerator_x86.cpp +++ b/src/hotspot/cpu/x86/templateInterpreterGenerator_x86.cpp @@ -43,6 +43,7 @@ #include "runtime/arguments.hpp" #include "runtime/deoptimization.hpp" #include "runtime/frame.inline.hpp" +#include "runtime/jniHandles.hpp" #include "runtime/sharedRuntime.hpp" #include "runtime/stubRoutines.hpp" #include "runtime/synchronizer.hpp" diff --git a/src/hotspot/share/ci/ciBaseObject.hpp b/src/hotspot/share/ci/ciBaseObject.hpp index 00b842156c46f..9c204cb70ed1e 100644 --- a/src/hotspot/share/ci/ciBaseObject.hpp +++ b/src/hotspot/share/ci/ciBaseObject.hpp @@ -27,7 +27,6 @@ #include "ci/ciClassList.hpp" #include "memory/allocation.hpp" -#include "runtime/jniHandles.hpp" // ciBaseObject // diff --git a/src/hotspot/share/ci/ciMetadata.hpp b/src/hotspot/share/ci/ciMetadata.hpp index 7db2e036e6117..a0b7b38cd72e4 100644 --- a/src/hotspot/share/ci/ciMetadata.hpp +++ b/src/hotspot/share/ci/ciMetadata.hpp @@ -28,7 +28,6 @@ #include "ci/ciBaseObject.hpp" #include "ci/ciClassList.hpp" #include "runtime/handles.hpp" -#include "runtime/jniHandles.hpp" // ciMetadata // diff --git a/src/hotspot/share/ci/ciObject.hpp b/src/hotspot/share/ci/ciObject.hpp index 8e3ffe64ef56f..0587df338c576 100644 --- a/src/hotspot/share/ci/ciObject.hpp +++ b/src/hotspot/share/ci/ciObject.hpp @@ -28,7 +28,6 @@ #include "ci/ciBaseObject.hpp" #include "ci/ciClassList.hpp" #include "runtime/handles.hpp" -#include "runtime/jniHandles.hpp" // ciObject // diff --git a/src/hotspot/share/classfile/moduleEntry.hpp b/src/hotspot/share/classfile/moduleEntry.hpp index e2bae48948fe7..c86904bc823a4 100644 --- a/src/hotspot/share/classfile/moduleEntry.hpp +++ b/src/hotspot/share/classfile/moduleEntry.hpp @@ -29,7 +29,6 @@ #include "classfile/classLoaderData.hpp" #include "oops/oopHandle.hpp" #include "oops/symbol.hpp" -#include "runtime/jniHandles.hpp" #include "runtime/mutexLocker.hpp" #include "utilities/growableArray.hpp" #include "utilities/hashtable.hpp" diff --git a/src/hotspot/share/compiler/compileTask.cpp b/src/hotspot/share/compiler/compileTask.cpp index d5de61fbf8c4b..c56ebdb888b5d 100644 --- a/src/hotspot/share/compiler/compileTask.cpp +++ b/src/hotspot/share/compiler/compileTask.cpp @@ -32,6 +32,7 @@ #include "logging/logStream.hpp" #include "memory/resourceArea.hpp" #include "runtime/handles.inline.hpp" +#include "runtime/jniHandles.hpp" CompileTask* CompileTask::_task_free_list = NULL; diff --git a/src/hotspot/share/gc/shared/concurrentGCThread.cpp b/src/hotspot/share/gc/shared/concurrentGCThread.cpp index c669bae986021..cd14039a8f1a4 100644 --- a/src/hotspot/share/gc/shared/concurrentGCThread.cpp +++ b/src/hotspot/share/gc/shared/concurrentGCThread.cpp @@ -26,6 +26,7 @@ #include "gc/shared/concurrentGCThread.hpp" #include "runtime/atomic.hpp" #include "runtime/init.hpp" +#include "runtime/jniHandles.hpp" #include "runtime/mutexLocker.hpp" #include "runtime/os.hpp" diff --git a/src/hotspot/share/gc/shared/gcVMOperations.hpp b/src/hotspot/share/gc/shared/gcVMOperations.hpp index b383234317881..aa8e0e9314640 100644 --- a/src/hotspot/share/gc/shared/gcVMOperations.hpp +++ b/src/hotspot/share/gc/shared/gcVMOperations.hpp @@ -30,7 +30,6 @@ #include "memory/metaspace.hpp" #include "prims/jvmtiExport.hpp" #include "runtime/handles.hpp" -#include "runtime/jniHandles.hpp" #include "runtime/synchronizer.hpp" #include "runtime/vmOperations.hpp" diff --git a/src/hotspot/share/gc/shenandoah/shenandoahRootVerifier.cpp b/src/hotspot/share/gc/shenandoah/shenandoahRootVerifier.cpp index c273b6eea805d..6992279c41e09 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahRootVerifier.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahRootVerifier.cpp @@ -36,6 +36,7 @@ #include "gc/shenandoah/shenandoahUtils.hpp" #include "gc/shared/oopStorage.inline.hpp" #include "gc/shared/oopStorageSet.hpp" +#include "runtime/jniHandles.hpp" #include "runtime/thread.hpp" #include "utilities/debug.hpp" #include "utilities/enumIterator.hpp" diff --git a/src/hotspot/share/jfr/dcmd/jfrDcmds.cpp b/src/hotspot/share/jfr/dcmd/jfrDcmds.cpp index 98ee0800cf6e3..becff8788054e 100644 --- a/src/hotspot/share/jfr/dcmd/jfrDcmds.cpp +++ b/src/hotspot/share/jfr/dcmd/jfrDcmds.cpp @@ -34,6 +34,7 @@ #include "oops/oop.inline.hpp" #include "oops/symbol.hpp" #include "runtime/handles.inline.hpp" +#include "runtime/jniHandles.hpp" #include "services/diagnosticArgument.hpp" #include "services/diagnosticFramework.hpp" #include "utilities/globalDefinitions.hpp" diff --git a/src/hotspot/share/jfr/instrumentation/jfrEventClassTransformer.cpp b/src/hotspot/share/jfr/instrumentation/jfrEventClassTransformer.cpp index d8c9acc8e8ed2..3bf90ccacbf84 100644 --- a/src/hotspot/share/jfr/instrumentation/jfrEventClassTransformer.cpp +++ b/src/hotspot/share/jfr/instrumentation/jfrEventClassTransformer.cpp @@ -52,6 +52,7 @@ #include "oops/method.hpp" #include "prims/jvmtiRedefineClasses.hpp" #include "runtime/handles.inline.hpp" +#include "runtime/jniHandles.hpp" #include "runtime/os.hpp" #include "runtime/thread.inline.hpp" #include "utilities/exceptions.hpp" diff --git a/src/hotspot/share/jfr/leakprofiler/checkpoint/rootResolver.cpp b/src/hotspot/share/jfr/leakprofiler/checkpoint/rootResolver.cpp index 3ec449a6b95f0..6564cff136f9d 100644 --- a/src/hotspot/share/jfr/leakprofiler/checkpoint/rootResolver.cpp +++ b/src/hotspot/share/jfr/leakprofiler/checkpoint/rootResolver.cpp @@ -38,6 +38,7 @@ #include "oops/oop.hpp" #include "prims/jvmtiThreadState.hpp" #include "runtime/frame.inline.hpp" +#include "runtime/jniHandles.hpp" #include "runtime/mutexLocker.hpp" #include "runtime/vframe_hp.hpp" #include "services/management.hpp" diff --git a/src/hotspot/share/jfr/writers/jfrWriterHost.inline.hpp b/src/hotspot/share/jfr/writers/jfrWriterHost.inline.hpp index 1f71b842946b4..57dc412280710 100644 --- a/src/hotspot/share/jfr/writers/jfrWriterHost.inline.hpp +++ b/src/hotspot/share/jfr/writers/jfrWriterHost.inline.hpp @@ -34,6 +34,7 @@ #include "oops/oop.hpp" #include "oops/symbol.hpp" #include "oops/typeArrayOop.inline.hpp" +#include "runtime/jniHandles.hpp" inline bool compressed_integers() { static const bool comp_integers = JfrOptionSet::compressed_integers(); diff --git a/src/hotspot/share/jvmci/jvmciEnv.hpp b/src/hotspot/share/jvmci/jvmciEnv.hpp index 3f5658a19ada0..9a509f5f94add 100644 --- a/src/hotspot/share/jvmci/jvmciEnv.hpp +++ b/src/hotspot/share/jvmci/jvmciEnv.hpp @@ -27,6 +27,7 @@ #include "classfile/javaClasses.hpp" #include "jvmci/jvmciJavaClasses.hpp" +#include "runtime/jniHandles.hpp" #include "runtime/thread.hpp" class CompileTask; diff --git a/src/hotspot/share/jvmci/jvmciJavaClasses.hpp b/src/hotspot/share/jvmci/jvmciJavaClasses.hpp index 25d0a109e7e64..4db609d18d1b8 100644 --- a/src/hotspot/share/jvmci/jvmciJavaClasses.hpp +++ b/src/hotspot/share/jvmci/jvmciJavaClasses.hpp @@ -27,7 +27,6 @@ #include "classfile/vmSymbols.hpp" #include "jvmci/jvmciExceptions.hpp" #include "jvmci/jvmciObject.hpp" -#include "runtime/jniHandles.hpp" /* * This macro defines the structure of the JVMCI classes accessed from VM code. It is used to diff --git a/src/hotspot/share/memory/universe.cpp b/src/hotspot/share/memory/universe.cpp index 8122d4cd6027d..06a33bdf86a56 100644 --- a/src/hotspot/share/memory/universe.cpp +++ b/src/hotspot/share/memory/universe.cpp @@ -66,6 +66,7 @@ #include "runtime/handles.inline.hpp" #include "runtime/init.hpp" #include "runtime/java.hpp" +#include "runtime/jniHandles.hpp" #include "runtime/thread.inline.hpp" #include "runtime/timerTrace.hpp" #include "services/memoryService.hpp" diff --git a/src/hotspot/share/prims/jvmtiEnter.xsl b/src/hotspot/share/prims/jvmtiEnter.xsl index fb2a8e93a21bf..48d1b58a4654f 100644 --- a/src/hotspot/share/prims/jvmtiEnter.xsl +++ b/src/hotspot/share/prims/jvmtiEnter.xsl @@ -48,6 +48,7 @@ # include "prims/jvmtiRawMonitor.hpp" # include "prims/jvmtiUtil.hpp" # include "runtime/fieldDescriptor.inline.hpp" +# include "runtime/jniHandles.hpp" # include "runtime/threadSMR.hpp" diff --git a/src/hotspot/share/prims/jvmtiImpl.cpp b/src/hotspot/share/prims/jvmtiImpl.cpp index 287594edd0ab2..a034eac3a1708 100644 --- a/src/hotspot/share/prims/jvmtiImpl.cpp +++ b/src/hotspot/share/prims/jvmtiImpl.cpp @@ -45,6 +45,7 @@ #include "runtime/handles.inline.hpp" #include "runtime/interfaceSupport.inline.hpp" #include "runtime/javaCalls.hpp" +#include "runtime/jniHandles.hpp" #include "runtime/os.hpp" #include "runtime/serviceThread.hpp" #include "runtime/signature.hpp" diff --git a/src/hotspot/share/runtime/os.cpp b/src/hotspot/share/runtime/os.cpp index 48eb6354a1abf..798d36f0981e9 100644 --- a/src/hotspot/share/runtime/os.cpp +++ b/src/hotspot/share/runtime/os.cpp @@ -52,6 +52,7 @@ #include "runtime/interfaceSupport.inline.hpp" #include "runtime/java.hpp" #include "runtime/javaCalls.hpp" +#include "runtime/jniHandles.hpp" #include "runtime/mutexLocker.hpp" #include "runtime/os.inline.hpp" #include "runtime/osThread.hpp" diff --git a/src/hotspot/share/runtime/thread.hpp b/src/hotspot/share/runtime/thread.hpp index 0fb403f185e61..029c5a5e9013c 100644 --- a/src/hotspot/share/runtime/thread.hpp +++ b/src/hotspot/share/runtime/thread.hpp @@ -35,7 +35,6 @@ #include "runtime/globals.hpp" #include "runtime/handshake.hpp" #include "runtime/javaFrameAnchor.hpp" -#include "runtime/jniHandles.hpp" #include "runtime/mutexLocker.hpp" #include "runtime/os.hpp" #include "runtime/park.hpp" @@ -60,6 +59,7 @@ class ThreadSafepointState; class ThreadsList; class ThreadsSMRSupport; +class JNIHandleBlock; class JvmtiRawMonitor; class JvmtiSampledObjectAllocEventCollector; class JvmtiThreadState; diff --git a/src/hotspot/share/runtime/vmOperations.cpp b/src/hotspot/share/runtime/vmOperations.cpp index 0cf1b4eb40431..c6ecf5ea1a933 100644 --- a/src/hotspot/share/runtime/vmOperations.cpp +++ b/src/hotspot/share/runtime/vmOperations.cpp @@ -41,6 +41,7 @@ #include "runtime/deoptimization.hpp" #include "runtime/frame.inline.hpp" #include "runtime/interfaceSupport.inline.hpp" +#include "runtime/jniHandles.hpp" #include "runtime/synchronizer.hpp" #include "runtime/thread.inline.hpp" #include "runtime/threadSMR.inline.hpp" diff --git a/src/hotspot/share/runtime/vmStructs.cpp b/src/hotspot/share/runtime/vmStructs.cpp index 193f4f43905ba..46c4811dd5042 100644 --- a/src/hotspot/share/runtime/vmStructs.cpp +++ b/src/hotspot/share/runtime/vmStructs.cpp @@ -89,6 +89,7 @@ #include "runtime/globals.hpp" #include "runtime/java.hpp" #include "runtime/javaCalls.hpp" +#include "runtime/jniHandles.hpp" #include "runtime/monitorDeflationThread.hpp" #include "runtime/notificationThread.hpp" #include "runtime/os.hpp" diff --git a/src/hotspot/share/runtime/vmThread.cpp b/src/hotspot/share/runtime/vmThread.cpp index 8068616ab23bb..d4285da0a95c2 100644 --- a/src/hotspot/share/runtime/vmThread.cpp +++ b/src/hotspot/share/runtime/vmThread.cpp @@ -37,6 +37,7 @@ #include "runtime/atomic.hpp" #include "runtime/handles.inline.hpp" #include "runtime/interfaceSupport.inline.hpp" +#include "runtime/jniHandles.hpp" #include "runtime/mutexLocker.hpp" #include "runtime/os.hpp" #include "runtime/perfData.hpp" diff --git a/src/hotspot/share/services/diagnosticCommand.cpp b/src/hotspot/share/services/diagnosticCommand.cpp index 7b1329898ee5f..999ee48ddcf97 100644 --- a/src/hotspot/share/services/diagnosticCommand.cpp +++ b/src/hotspot/share/services/diagnosticCommand.cpp @@ -44,6 +44,7 @@ #include "runtime/handles.inline.hpp" #include "runtime/interfaceSupport.inline.hpp" #include "runtime/javaCalls.hpp" +#include "runtime/jniHandles.hpp" #include "runtime/os.hpp" #include "runtime/vm_version.hpp" #include "services/diagnosticArgument.hpp" diff --git a/src/hotspot/share/services/threadService.hpp b/src/hotspot/share/services/threadService.hpp index 470bead25a603..6784fbc5c03fc 100644 --- a/src/hotspot/share/services/threadService.hpp +++ b/src/hotspot/share/services/threadService.hpp @@ -30,7 +30,6 @@ #include "classfile/javaThreadStatus.hpp" #include "runtime/handles.hpp" #include "runtime/init.hpp" -#include "runtime/jniHandles.hpp" #include "runtime/objectMonitor.hpp" #include "runtime/perfData.hpp" #include "runtime/safepoint.hpp" From 3bb6a3d2ab96373baa4e18f4e61173f11225fd4e Mon Sep 17 00:00:00 2001 From: Phil Race Date: Thu, 4 Feb 2021 21:00:18 +0000 Subject: [PATCH 66/77] 8261109: [macOS] Remove disabled warning for JNF in make/autoconf/flags-cflags.m4 Reviewed-by: serb, ihse, erikj --- make/autoconf/flags-cflags.m4 | 5 ----- make/modules/java.base/Lib.gmk | 3 --- 2 files changed, 8 deletions(-) diff --git a/make/autoconf/flags-cflags.m4 b/make/autoconf/flags-cflags.m4 index 7a6dfb74168b3..29b08cf98376f 100644 --- a/make/autoconf/flags-cflags.m4 +++ b/make/autoconf/flags-cflags.m4 @@ -168,11 +168,6 @@ AC_DEFUN([FLAGS_SETUP_WARNINGS], DISABLED_WARNINGS="unknown-warning-option unused-parameter unused" - if test "x$OPENJDK_TARGET_OS" = xmacosx; then - # missing-method-return-type triggers in JavaNativeFoundation framework - DISABLED_WARNINGS="$DISABLED_WARNINGS missing-method-return-type" - fi - ;; xlc) diff --git a/make/modules/java.base/Lib.gmk b/make/modules/java.base/Lib.gmk index 0eff999a01196..5658ff342e53c 100644 --- a/make/modules/java.base/Lib.gmk +++ b/make/modules/java.base/Lib.gmk @@ -96,8 +96,6 @@ $(BUILD_LIBNIO): $(BUILD_LIBNET) # Create the macosx security library ifeq ($(call isTargetOs, macosx), true) - # JavaNativeFoundation framework not supported in static builds - ifneq ($(STATIC_BUILD), true) $(eval $(call SetupJdkLibrary, BUILD_LIBOSXSECURITY, \ NAME := osxsecurity, \ @@ -120,7 +118,6 @@ ifeq ($(call isTargetOs, macosx), true) TARGETS += $(BUILD_LIBOSXSECURITY) - endif endif ################################################################################ From 08f7454fa961e00f9f5ec370a339ae89134dcbf6 Mon Sep 17 00:00:00 2001 From: "Daniel D. Daugherty" Date: Thu, 4 Feb 2021 23:08:15 +0000 Subject: [PATCH 67/77] 8261190: restore original Alibaba copyright line in two files Reviewed-by: dholmes --- .../jdk/jdk/jfr/api/consumer/TestChunkInputStreamAvailable.java | 2 +- test/jdk/jdk/jfr/event/gc/detailed/TestGCLockerEvent.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/jdk/jdk/jfr/api/consumer/TestChunkInputStreamAvailable.java b/test/jdk/jdk/jfr/api/consumer/TestChunkInputStreamAvailable.java index e0b37dd365c92..07f796d47d329 100644 --- a/test/jdk/jdk/jfr/api/consumer/TestChunkInputStreamAvailable.java +++ b/test/jdk/jdk/jfr/api/consumer/TestChunkInputStreamAvailable.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Alibaba Group Holding Limited. All rights reserved. + * Copyright (c) 2021, Alibaba Group Holding Limited. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/test/jdk/jdk/jfr/event/gc/detailed/TestGCLockerEvent.java b/test/jdk/jdk/jfr/event/gc/detailed/TestGCLockerEvent.java index 3fb5ba27bc216..d79b3f298a84d 100644 --- a/test/jdk/jdk/jfr/event/gc/detailed/TestGCLockerEvent.java +++ b/test/jdk/jdk/jfr/event/gc/detailed/TestGCLockerEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Alibaba Group Holding Limited. All rights reserved. + * Copyright (c) 2021, Alibaba Group Holding Limited. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it From c5bb1092725005b1cf0cb98fbdd3bcec8d5a59c3 Mon Sep 17 00:00:00 2001 From: Ioi Lam Date: Fri, 5 Feb 2021 03:02:11 +0000 Subject: [PATCH 68/77] 8260019: Move some Thread subtypes out of thread.hpp Reviewed-by: dholmes, coleenp --- src/hotspot/share/ci/ciEnv.hpp | 1 + src/hotspot/share/code/dependencies.hpp | 3 +- .../share/compiler/compilerDirectives.hpp | 3 +- src/hotspot/share/compiler/compilerThread.cpp | 95 +++++ src/hotspot/share/compiler/compilerThread.hpp | 146 +++++++ .../share/gc/shared/concurrentGCThread.hpp | 3 +- src/hotspot/share/gc/shared/gcId.cpp | 3 +- .../share/gc/shared/referenceProcessor.cpp | 1 + src/hotspot/share/gc/shared/workgroup.hpp | 1 + src/hotspot/share/gc/z/zThread.cpp | 3 +- .../share/interpreter/interpreterRuntime.hpp | 1 + .../share/jfr/utilities/jfrThreadIterator.hpp | 3 +- src/hotspot/share/jvmci/jvmci.cpp | 3 +- src/hotspot/share/runtime/nonJavaThread.cpp | 342 ++++++++++++++++ src/hotspot/share/runtime/nonJavaThread.hpp | 164 ++++++++ src/hotspot/share/runtime/task.cpp | 3 +- src/hotspot/share/runtime/thread.cpp | 380 +----------------- src/hotspot/share/runtime/thread.hpp | 246 ------------ src/hotspot/share/runtime/vmThread.hpp | 1 + 19 files changed, 772 insertions(+), 630 deletions(-) create mode 100644 src/hotspot/share/compiler/compilerThread.cpp create mode 100644 src/hotspot/share/compiler/compilerThread.hpp create mode 100644 src/hotspot/share/runtime/nonJavaThread.cpp create mode 100644 src/hotspot/share/runtime/nonJavaThread.hpp diff --git a/src/hotspot/share/ci/ciEnv.hpp b/src/hotspot/share/ci/ciEnv.hpp index a438f78201719..5baf280764e12 100644 --- a/src/hotspot/share/ci/ciEnv.hpp +++ b/src/hotspot/share/ci/ciEnv.hpp @@ -31,6 +31,7 @@ #include "code/debugInfoRec.hpp" #include "code/dependencies.hpp" #include "code/exceptionHandlerTable.hpp" +#include "compiler/compilerThread.hpp" #include "compiler/oopMap.hpp" #include "oops/methodData.hpp" #include "runtime/thread.hpp" diff --git a/src/hotspot/share/code/dependencies.hpp b/src/hotspot/share/code/dependencies.hpp index 960be1c3c71c2..4366201ef19e0 100644 --- a/src/hotspot/share/code/dependencies.hpp +++ b/src/hotspot/share/code/dependencies.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -57,6 +57,7 @@ class nmethod; class OopRecorder; class xmlStream; class CompileLog; +class CompileTask; class DepChange; class KlassDepChange; class CallSiteDepChange; diff --git a/src/hotspot/share/compiler/compilerDirectives.hpp b/src/hotspot/share/compiler/compilerDirectives.hpp index 539635a382333..d51aa28e28cc6 100644 --- a/src/hotspot/share/compiler/compilerDirectives.hpp +++ b/src/hotspot/share/compiler/compilerDirectives.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -78,6 +78,7 @@ NOT_PRODUCT(cflags(IGVPrintLevel, intx, PrintIdealGraphLevel, IGVPrintLeve #define compilerdirectives_c2_flags(cflags) #endif +class AbstractCompiler; class CompilerDirectives; class DirectiveSet; diff --git a/src/hotspot/share/compiler/compilerThread.cpp b/src/hotspot/share/compiler/compilerThread.cpp new file mode 100644 index 0000000000000..94e00083de09d --- /dev/null +++ b/src/hotspot/share/compiler/compilerThread.cpp @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#include "precompiled.hpp" +#include "compiler/compileBroker.hpp" +#include "compiler/compileTask.hpp" +#include "compiler/compilerThread.hpp" +#include "runtime/sweeper.hpp" +#include "runtime/thread.inline.hpp" + +// Create a CompilerThread +CompilerThread::CompilerThread(CompileQueue* queue, + CompilerCounters* counters) + : JavaThread(&CompilerThread::thread_entry) { + _env = NULL; + _log = NULL; + _task = NULL; + _queue = queue; + _counters = counters; + _buffer_blob = NULL; + _compiler = NULL; + + // Compiler uses resource area for compilation, let's bias it to mtCompiler + resource_area()->bias_to(mtCompiler); + +#ifndef PRODUCT + _ideal_graph_printer = NULL; +#endif +} + +CompilerThread::~CompilerThread() { + // Delete objects which were allocated on heap. + delete _counters; +} + +void CompilerThread::thread_entry(JavaThread* thread, TRAPS) { + assert(thread->is_Compiler_thread(), "must be compiler thread"); + CompileBroker::compiler_thread_loop(); +} + +bool CompilerThread::can_call_java() const { + return _compiler != NULL && _compiler->is_jvmci(); +} + +// Create sweeper thread +CodeCacheSweeperThread::CodeCacheSweeperThread() +: JavaThread(&CodeCacheSweeperThread::thread_entry) { + _scanned_compiled_method = NULL; +} + +void CodeCacheSweeperThread::thread_entry(JavaThread* thread, TRAPS) { + NMethodSweeper::sweeper_loop(); +} + +void CodeCacheSweeperThread::oops_do_no_frames(OopClosure* f, CodeBlobClosure* cf) { + JavaThread::oops_do_no_frames(f, cf); + if (_scanned_compiled_method != NULL && cf != NULL) { + // Safepoints can occur when the sweeper is scanning an nmethod so + // process it here to make sure it isn't unloaded in the middle of + // a scan. + cf->do_code_blob(_scanned_compiled_method); + } +} + +void CodeCacheSweeperThread::nmethods_do(CodeBlobClosure* cf) { + JavaThread::nmethods_do(cf); + if (_scanned_compiled_method != NULL && cf != NULL) { + // Safepoints can occur when the sweeper is scanning an nmethod so + // process it here to make sure it isn't unloaded in the middle of + // a scan. + cf->do_code_blob(_scanned_compiled_method); + } +} + diff --git a/src/hotspot/share/compiler/compilerThread.hpp b/src/hotspot/share/compiler/compilerThread.hpp new file mode 100644 index 0000000000000..3e0147d28be6e --- /dev/null +++ b/src/hotspot/share/compiler/compilerThread.hpp @@ -0,0 +1,146 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_COMPILER_COMPILERTHREAD_HPP +#define SHARE_COMPILER_COMPILERTHREAD_HPP + +#include "runtime/thread.hpp" + +class BufferBlob; +class AbstractCompiler; +class ciEnv; +class CompileThread; +class CompileLog; +class CompileTask; +class CompileQueue; +class CompilerCounters; +class IdealGraphPrinter; +class JVMCIEnv; +class JVMCIPrimitiveArray; + +// A thread used for Compilation. +class CompilerThread : public JavaThread { + friend class VMStructs; + private: + CompilerCounters* _counters; + + ciEnv* _env; + CompileLog* _log; + CompileTask* volatile _task; // print_threads_compiling can read this concurrently. + CompileQueue* _queue; + BufferBlob* _buffer_blob; + + AbstractCompiler* _compiler; + TimeStamp _idle_time; + + public: + + static CompilerThread* current(); + + CompilerThread(CompileQueue* queue, CompilerCounters* counters); + ~CompilerThread(); + + bool is_Compiler_thread() const { return true; } + + virtual bool can_call_java() const; + + // Hide native compiler threads from external view. + bool is_hidden_from_external_view() const { return !can_call_java(); } + + void set_compiler(AbstractCompiler* c) { _compiler = c; } + AbstractCompiler* compiler() const { return _compiler; } + + CompileQueue* queue() const { return _queue; } + CompilerCounters* counters() const { return _counters; } + + // Get/set the thread's compilation environment. + ciEnv* env() { return _env; } + void set_env(ciEnv* env) { _env = env; } + + BufferBlob* get_buffer_blob() const { return _buffer_blob; } + void set_buffer_blob(BufferBlob* b) { _buffer_blob = b; } + + // Get/set the thread's logging information + CompileLog* log() { return _log; } + void init_log(CompileLog* log) { + // Set once, for good. + assert(_log == NULL, "set only once"); + _log = log; + } + + void start_idle_timer() { _idle_time.update(); } + jlong idle_time_millis() { + return TimeHelper::counter_to_millis(_idle_time.ticks_since_update()); + } + +#ifndef PRODUCT + private: + IdealGraphPrinter *_ideal_graph_printer; + public: + IdealGraphPrinter *ideal_graph_printer() { return _ideal_graph_printer; } + void set_ideal_graph_printer(IdealGraphPrinter *n) { _ideal_graph_printer = n; } +#endif + + // Get/set the thread's current task + CompileTask* task() { return _task; } + void set_task(CompileTask* task) { _task = task; } + + static void thread_entry(JavaThread* thread, TRAPS); +}; + +inline CompilerThread* JavaThread::as_CompilerThread() { + assert(is_Compiler_thread(), "just checking"); + return (CompilerThread*)this; +} + +inline CompilerThread* CompilerThread::current() { + return JavaThread::current()->as_CompilerThread(); +} + +// Dedicated thread to sweep the code cache +class CodeCacheSweeperThread : public JavaThread { + CompiledMethod* _scanned_compiled_method; // nmethod being scanned by the sweeper + + static void thread_entry(JavaThread* thread, TRAPS); + + public: + CodeCacheSweeperThread(); + // Track the nmethod currently being scanned by the sweeper + void set_scanned_compiled_method(CompiledMethod* cm) { + assert(_scanned_compiled_method == NULL || cm == NULL, "should reset to NULL before writing a new value"); + _scanned_compiled_method = cm; + } + + // Hide sweeper thread from external view. + bool is_hidden_from_external_view() const { return true; } + + bool is_Code_cache_sweeper_thread() const { return true; } + + // Prevent GC from unloading _scanned_compiled_method + void oops_do_no_frames(OopClosure* f, CodeBlobClosure* cf); + void nmethods_do(CodeBlobClosure* cf); +}; + + +#endif // SHARE_COMPILER_COMPILERTHREAD_HPP diff --git a/src/hotspot/share/gc/shared/concurrentGCThread.hpp b/src/hotspot/share/gc/shared/concurrentGCThread.hpp index 021fdd7649886..34c4717c9f3f1 100644 --- a/src/hotspot/share/gc/shared/concurrentGCThread.hpp +++ b/src/hotspot/share/gc/shared/concurrentGCThread.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ #ifndef SHARE_GC_SHARED_CONCURRENTGCTHREAD_HPP #define SHARE_GC_SHARED_CONCURRENTGCTHREAD_HPP +#include "runtime/nonJavaThread.hpp" #include "runtime/thread.hpp" class ConcurrentGCThread: public NamedThread { diff --git a/src/hotspot/share/gc/shared/gcId.cpp b/src/hotspot/share/gc/shared/gcId.cpp index f48812c677080..acc25f84c37ee 100644 --- a/src/hotspot/share/gc/shared/gcId.cpp +++ b/src/hotspot/share/gc/shared/gcId.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ #include "precompiled.hpp" #include "jvm.h" #include "gc/shared/gcId.hpp" +#include "runtime/nonJavaThread.hpp" #include "runtime/safepoint.hpp" #include "runtime/thread.inline.hpp" diff --git a/src/hotspot/share/gc/shared/referenceProcessor.cpp b/src/hotspot/share/gc/shared/referenceProcessor.cpp index 42bc3500b86f3..e2fed87ffb365 100644 --- a/src/hotspot/share/gc/shared/referenceProcessor.cpp +++ b/src/hotspot/share/gc/shared/referenceProcessor.cpp @@ -39,6 +39,7 @@ #include "oops/access.inline.hpp" #include "oops/oop.inline.hpp" #include "runtime/java.hpp" +#include "runtime/nonJavaThread.hpp" ReferencePolicy* ReferenceProcessor::_always_clear_soft_ref_policy = NULL; ReferencePolicy* ReferenceProcessor::_default_soft_ref_policy = NULL; diff --git a/src/hotspot/share/gc/shared/workgroup.hpp b/src/hotspot/share/gc/shared/workgroup.hpp index 542e86226dcba..a499451333e9a 100644 --- a/src/hotspot/share/gc/shared/workgroup.hpp +++ b/src/hotspot/share/gc/shared/workgroup.hpp @@ -29,6 +29,7 @@ #include "metaprogramming/enableIf.hpp" #include "metaprogramming/logical.hpp" #include "runtime/globals.hpp" +#include "runtime/nonJavaThread.hpp" #include "runtime/thread.hpp" #include "gc/shared/gcId.hpp" #include "logging/log.hpp" diff --git a/src/hotspot/share/gc/z/zThread.cpp b/src/hotspot/share/gc/z/zThread.cpp index 37fb595a34344..7dc539f4b355d 100644 --- a/src/hotspot/share/gc/z/zThread.cpp +++ b/src/hotspot/share/gc/z/zThread.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,6 +23,7 @@ #include "precompiled.hpp" #include "gc/z/zThread.inline.hpp" +#include "runtime/nonJavaThread.hpp" #include "runtime/thread.hpp" #include "utilities/debug.hpp" diff --git a/src/hotspot/share/interpreter/interpreterRuntime.hpp b/src/hotspot/share/interpreter/interpreterRuntime.hpp index a6d504c8053d1..2069ace8d5ff4 100644 --- a/src/hotspot/share/interpreter/interpreterRuntime.hpp +++ b/src/hotspot/share/interpreter/interpreterRuntime.hpp @@ -33,6 +33,7 @@ #include "runtime/thread.hpp" #include "utilities/macros.hpp" +class BufferBlob; class CodeBuffer; // The InterpreterRuntime is called by the interpreter for everything diff --git a/src/hotspot/share/jfr/utilities/jfrThreadIterator.hpp b/src/hotspot/share/jfr/utilities/jfrThreadIterator.hpp index 59fa255d75938..f45ed6bf4e36d 100644 --- a/src/hotspot/share/jfr/utilities/jfrThreadIterator.hpp +++ b/src/hotspot/share/jfr/utilities/jfrThreadIterator.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ #define SHARE_VM_JFR_UTILITIES_JFRTHREADITERATOR_HPP #include "memory/allocation.hpp" +#include "runtime/nonJavaThread.hpp" #include "runtime/thread.hpp" #include "runtime/threadSMR.hpp" diff --git a/src/hotspot/share/jvmci/jvmci.cpp b/src/hotspot/share/jvmci/jvmci.cpp index 7ab4ae20e08d9..6c8a4ed16ed83 100644 --- a/src/hotspot/share/jvmci/jvmci.cpp +++ b/src/hotspot/share/jvmci/jvmci.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,7 @@ #include "precompiled.hpp" #include "classfile/systemDictionary.hpp" #include "compiler/compileTask.hpp" +#include "compiler/compilerThread.hpp" #include "gc/shared/collectedHeap.hpp" #include "jvmci/jvmci.hpp" #include "jvmci/jvmciJavaClasses.hpp" diff --git a/src/hotspot/share/runtime/nonJavaThread.cpp b/src/hotspot/share/runtime/nonJavaThread.cpp new file mode 100644 index 0000000000000..7332e59fe0f6e --- /dev/null +++ b/src/hotspot/share/runtime/nonJavaThread.cpp @@ -0,0 +1,342 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#include "precompiled.hpp" +#include "jvm_io.h" +#include "gc/shared/barrierSet.hpp" +#include "gc/shared/gcId.hpp" +#include "runtime/atomic.hpp" +#include "runtime/jniHandles.hpp" +#include "runtime/nonJavaThread.hpp" +#include "runtime/osThread.hpp" +#include "runtime/task.hpp" +#include "runtime/thread.inline.hpp" +#include "utilities/defaultStream.hpp" +#include "utilities/singleWriterSynchronizer.hpp" +#include "utilities/vmError.hpp" + +#if INCLUDE_JFR +#include "jfr/jfr.hpp" +#endif + +// List of all NonJavaThreads and safe iteration over that list. + +class NonJavaThread::List { +public: + NonJavaThread* volatile _head; + SingleWriterSynchronizer _protect; + + List() : _head(NULL), _protect() {} +}; + +NonJavaThread::List NonJavaThread::_the_list; + +NonJavaThread::Iterator::Iterator() : + _protect_enter(_the_list._protect.enter()), + _current(Atomic::load_acquire(&_the_list._head)) +{} + +NonJavaThread::Iterator::~Iterator() { + _the_list._protect.exit(_protect_enter); +} + +void NonJavaThread::Iterator::step() { + assert(!end(), "precondition"); + _current = Atomic::load_acquire(&_current->_next); +} + +NonJavaThread::NonJavaThread() : Thread(), _next(NULL) { + assert(BarrierSet::barrier_set() != NULL, "NonJavaThread created too soon!"); +} + +NonJavaThread::~NonJavaThread() { } + +void NonJavaThread::add_to_the_list() { + MutexLocker ml(NonJavaThreadsList_lock, Mutex::_no_safepoint_check_flag); + // Initialize BarrierSet-related data before adding to list. + BarrierSet::barrier_set()->on_thread_attach(this); + Atomic::release_store(&_next, _the_list._head); + Atomic::release_store(&_the_list._head, this); +} + +void NonJavaThread::remove_from_the_list() { + { + MutexLocker ml(NonJavaThreadsList_lock, Mutex::_no_safepoint_check_flag); + // Cleanup BarrierSet-related data before removing from list. + BarrierSet::barrier_set()->on_thread_detach(this); + NonJavaThread* volatile* p = &_the_list._head; + for (NonJavaThread* t = *p; t != NULL; p = &t->_next, t = *p) { + if (t == this) { + *p = _next; + break; + } + } + } + // Wait for any in-progress iterators. Concurrent synchronize is not + // allowed, so do it while holding a dedicated lock. Outside and distinct + // from NJTList_lock in case an iteration attempts to lock it. + MutexLocker ml(NonJavaThreadsListSync_lock, Mutex::_no_safepoint_check_flag); + _the_list._protect.synchronize(); + _next = NULL; // Safe to drop the link now. +} + +void NonJavaThread::pre_run() { + add_to_the_list(); + + // This is slightly odd in that NamedThread is a subclass, but + // in fact name() is defined in Thread + assert(this->name() != NULL, "thread name was not set before it was started"); + this->set_native_thread_name(this->name()); +} + +void NonJavaThread::post_run() { + JFR_ONLY(Jfr::on_thread_exit(this);) + remove_from_the_list(); + unregister_thread_stack_with_NMT(); + // Ensure thread-local-storage is cleared before termination. + Thread::clear_thread_current(); + osthread()->set_state(ZOMBIE); +} + +// NamedThread -- non-JavaThread subclasses with multiple +// uniquely named instances should derive from this. +NamedThread::NamedThread() : + NonJavaThread(), + _name(NULL), + _processed_thread(NULL), + _gc_id(GCId::undefined()) +{} + +NamedThread::~NamedThread() { + FREE_C_HEAP_ARRAY(char, _name); +} + +void NamedThread::set_name(const char* format, ...) { + guarantee(_name == NULL, "Only get to set name once."); + _name = NEW_C_HEAP_ARRAY(char, max_name_len, mtThread); + va_list ap; + va_start(ap, format); + jio_vsnprintf(_name, max_name_len, format, ap); + va_end(ap); +} + +void NamedThread::print_on(outputStream* st) const { + st->print("\"%s\" ", name()); + Thread::print_on(st); + st->cr(); +} + + +// ======= WatcherThread ======== + +// The watcher thread exists to simulate timer interrupts. It should +// be replaced by an abstraction over whatever native support for +// timer interrupts exists on the platform. + +WatcherThread* WatcherThread::_watcher_thread = NULL; +bool WatcherThread::_startable = false; +volatile bool WatcherThread::_should_terminate = false; + +WatcherThread::WatcherThread() : NonJavaThread() { + assert(watcher_thread() == NULL, "we can only allocate one WatcherThread"); + if (os::create_thread(this, os::watcher_thread)) { + _watcher_thread = this; + + // Set the watcher thread to the highest OS priority which should not be + // used, unless a Java thread with priority java.lang.Thread.MAX_PRIORITY + // is created. The only normal thread using this priority is the reference + // handler thread, which runs for very short intervals only. + // If the VMThread's priority is not lower than the WatcherThread profiling + // will be inaccurate. + os::set_priority(this, MaxPriority); + os::start_thread(this); + } +} + +int WatcherThread::sleep() const { + // The WatcherThread does not participate in the safepoint protocol + // for the PeriodicTask_lock because it is not a JavaThread. + MonitorLocker ml(PeriodicTask_lock, Mutex::_no_safepoint_check_flag); + + if (_should_terminate) { + // check for termination before we do any housekeeping or wait + return 0; // we did not sleep. + } + + // remaining will be zero if there are no tasks, + // causing the WatcherThread to sleep until a task is + // enrolled + int remaining = PeriodicTask::time_to_wait(); + int time_slept = 0; + + // we expect this to timeout - we only ever get unparked when + // we should terminate or when a new task has been enrolled + OSThreadWaitState osts(this->osthread(), false /* not Object.wait() */); + + jlong time_before_loop = os::javaTimeNanos(); + + while (true) { + bool timedout = ml.wait(remaining); + jlong now = os::javaTimeNanos(); + + if (remaining == 0) { + // if we didn't have any tasks we could have waited for a long time + // consider the time_slept zero and reset time_before_loop + time_slept = 0; + time_before_loop = now; + } else { + // need to recalculate since we might have new tasks in _tasks + time_slept = (int) ((now - time_before_loop) / 1000000); + } + + // Change to task list or spurious wakeup of some kind + if (timedout || _should_terminate) { + break; + } + + remaining = PeriodicTask::time_to_wait(); + if (remaining == 0) { + // Last task was just disenrolled so loop around and wait until + // another task gets enrolled + continue; + } + + remaining -= time_slept; + if (remaining <= 0) { + break; + } + } + + return time_slept; +} + +void WatcherThread::run() { + assert(this == watcher_thread(), "just checking"); + + this->set_active_handles(JNIHandleBlock::allocate_block()); + while (true) { + assert(watcher_thread() == Thread::current(), "thread consistency check"); + assert(watcher_thread() == this, "thread consistency check"); + + // Calculate how long it'll be until the next PeriodicTask work + // should be done, and sleep that amount of time. + int time_waited = sleep(); + + if (VMError::is_error_reported()) { + // A fatal error has happened, the error handler(VMError::report_and_die) + // should abort JVM after creating an error log file. However in some + // rare cases, the error handler itself might deadlock. Here periodically + // check for error reporting timeouts, and if it happens, just proceed to + // abort the VM. + + // This code is in WatcherThread because WatcherThread wakes up + // periodically so the fatal error handler doesn't need to do anything; + // also because the WatcherThread is less likely to crash than other + // threads. + + for (;;) { + // Note: we use naked sleep in this loop because we want to avoid using + // any kind of VM infrastructure which may be broken at this point. + if (VMError::check_timeout()) { + // We hit error reporting timeout. Error reporting was interrupted and + // will be wrapping things up now (closing files etc). Give it some more + // time, then quit the VM. + os::naked_short_sleep(200); + // Print a message to stderr. + fdStream err(defaultStream::output_fd()); + err.print_raw_cr("# [ timer expired, abort... ]"); + // skip atexit/vm_exit/vm_abort hooks + os::die(); + } + + // Wait a second, then recheck for timeout. + os::naked_short_sleep(999); + } + } + + if (_should_terminate) { + // check for termination before posting the next tick + break; + } + + PeriodicTask::real_time_tick(time_waited); + } + + // Signal that it is terminated + { + MutexLocker mu(Terminator_lock, Mutex::_no_safepoint_check_flag); + _watcher_thread = NULL; + Terminator_lock->notify_all(); + } +} + +void WatcherThread::start() { + assert(PeriodicTask_lock->owned_by_self(), "PeriodicTask_lock required"); + + if (watcher_thread() == NULL && _startable) { + _should_terminate = false; + // Create the single instance of WatcherThread + new WatcherThread(); + } +} + +void WatcherThread::make_startable() { + assert(PeriodicTask_lock->owned_by_self(), "PeriodicTask_lock required"); + _startable = true; +} + +void WatcherThread::stop() { + { + // Follow normal safepoint aware lock enter protocol since the + // WatcherThread is stopped by another JavaThread. + MutexLocker ml(PeriodicTask_lock); + _should_terminate = true; + + WatcherThread* watcher = watcher_thread(); + if (watcher != NULL) { + // unpark the WatcherThread so it can see that it should terminate + watcher->unpark(); + } + } + + MonitorLocker mu(Terminator_lock); + + while (watcher_thread() != NULL) { + // This wait should make safepoint checks, wait without a timeout, + // and wait as a suspend-equivalent condition. + mu.wait(0, Mutex::_as_suspend_equivalent_flag); + } +} + +void WatcherThread::unpark() { + assert(PeriodicTask_lock->owned_by_self(), "PeriodicTask_lock required"); + PeriodicTask_lock->notify(); +} + +void WatcherThread::print_on(outputStream* st) const { + st->print("\"%s\" ", name()); + Thread::print_on(st); + st->cr(); +} + diff --git a/src/hotspot/share/runtime/nonJavaThread.hpp b/src/hotspot/share/runtime/nonJavaThread.hpp new file mode 100644 index 0000000000000..c35234015a76c --- /dev/null +++ b/src/hotspot/share/runtime/nonJavaThread.hpp @@ -0,0 +1,164 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_RUNTIME_NONJAVATHREAD_HPP +#define SHARE_RUNTIME_NONJAVATHREAD_HPP + +#include "runtime/thread.hpp" + +class NonJavaThread: public Thread { + friend class VMStructs; + + NonJavaThread* volatile _next; + + class List; + static List _the_list; + + void add_to_the_list(); + void remove_from_the_list(); + + protected: + virtual void pre_run(); + virtual void post_run(); + + public: + NonJavaThread(); + ~NonJavaThread(); + + class Iterator; +}; + +// Provides iteration over the list of NonJavaThreads. +// List addition occurs in pre_run(), and removal occurs in post_run(), +// so that only live fully-initialized threads can be found in the list. +// Threads created after an iterator is constructed will not be visited +// by the iterator. The scope of an iterator is a critical section; there +// must be no safepoint checks in that scope. +class NonJavaThread::Iterator : public StackObj { + uint _protect_enter; + NonJavaThread* _current; + + NONCOPYABLE(Iterator); + +public: + Iterator(); + ~Iterator(); + + bool end() const { return _current == NULL; } + NonJavaThread* current() const { return _current; } + void step(); +}; + +// Name support for threads. non-JavaThread subclasses with multiple +// uniquely named instances should derive from this. +class NamedThread: public NonJavaThread { + friend class VMStructs; + enum { + max_name_len = 64 + }; + private: + char* _name; + // log Thread being processed by oops_do + Thread* _processed_thread; + uint _gc_id; // The current GC id when a thread takes part in GC + + public: + NamedThread(); + ~NamedThread(); + // May only be called once per thread. + void set_name(const char* format, ...) ATTRIBUTE_PRINTF(2, 3); + virtual bool is_Named_thread() const { return true; } + virtual char* name() const { return _name == NULL ? (char*)"Unknown Thread" : _name; } + Thread *processed_thread() { return _processed_thread; } + void set_processed_thread(Thread *thread) { _processed_thread = thread; } + virtual void print_on(outputStream* st) const; + + void set_gc_id(uint gc_id) { _gc_id = gc_id; } + uint gc_id() { return _gc_id; } +}; + +// Worker threads are named and have an id of an assigned work. +class WorkerThread: public NamedThread { + private: + uint _id; + public: + WorkerThread() : _id(0) { } + virtual bool is_Worker_thread() const { return true; } + + virtual WorkerThread* as_Worker_thread() const { + assert(is_Worker_thread(), "Dubious cast to WorkerThread*?"); + return (WorkerThread*) this; + } + + void set_id(uint work_id) { _id = work_id; } + uint id() const { return _id; } +}; + +// A single WatcherThread is used for simulating timer interrupts. +class WatcherThread: public NonJavaThread { + friend class VMStructs; + protected: + virtual void run(); + + private: + static WatcherThread* _watcher_thread; + + static bool _startable; + // volatile due to at least one lock-free read + volatile static bool _should_terminate; + public: + enum SomeConstants { + delay_interval = 10 // interrupt delay in milliseconds + }; + + // Constructor + WatcherThread(); + + // No destruction allowed + ~WatcherThread() { + guarantee(false, "WatcherThread deletion must fix the race with VM termination"); + } + + // Tester + bool is_Watcher_thread() const { return true; } + + // Printing + char* name() const { return (char*)"VM Periodic Task Thread"; } + void print_on(outputStream* st) const; + void unpark(); + + // Returns the single instance of WatcherThread + static WatcherThread* watcher_thread() { return _watcher_thread; } + + // Create and start the single instance of WatcherThread, or stop it on shutdown + static void start(); + static void stop(); + // Only allow start once the VM is sufficiently initialized + // Otherwise the first task to enroll will trigger the start + static void make_startable(); + private: + int sleep() const; +}; + +#endif // SHARE_RUNTIME_NONJAVATHREAD_HPP diff --git a/src/hotspot/share/runtime/task.cpp b/src/hotspot/share/runtime/task.cpp index bc019daba5708..fa74e8a3a2e36 100644 --- a/src/hotspot/share/runtime/task.cpp +++ b/src/hotspot/share/runtime/task.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ #include "precompiled.hpp" #include "memory/allocation.hpp" #include "runtime/init.hpp" +#include "runtime/nonJavaThread.hpp" #include "runtime/task.hpp" #include "runtime/thread.inline.hpp" #include "runtime/timer.hpp" diff --git a/src/hotspot/share/runtime/thread.cpp b/src/hotspot/share/runtime/thread.cpp index ac6ef9a303262..45c4896c5e302 100644 --- a/src/hotspot/share/runtime/thread.cpp +++ b/src/hotspot/share/runtime/thread.cpp @@ -28,7 +28,6 @@ #include "classfile/classLoader.hpp" #include "classfile/javaClasses.hpp" #include "classfile/javaThreadStatus.hpp" -#include "classfile/moduleEntry.hpp" #include "classfile/systemDictionary.hpp" #include "classfile/vmClasses.hpp" #include "classfile/vmSymbols.hpp" @@ -36,6 +35,7 @@ #include "code/scopeDesc.hpp" #include "compiler/compileBroker.hpp" #include "compiler/compileTask.hpp" +#include "compiler/compilerThread.hpp" #include "gc/shared/barrierSet.hpp" #include "gc/shared/collectedHeap.hpp" #include "gc/shared/gcId.hpp" @@ -44,7 +44,6 @@ #include "gc/shared/oopStorage.hpp" #include "gc/shared/oopStorageSet.hpp" #include "gc/shared/tlab_globals.hpp" -#include "gc/shared/workgroup.hpp" #include "interpreter/interpreter.hpp" #include "interpreter/linkResolver.hpp" #include "interpreter/oopMapCache.hpp" @@ -90,6 +89,7 @@ #include "runtime/memprofiler.hpp" #include "runtime/monitorDeflationThread.hpp" #include "runtime/mutexLocker.hpp" +#include "runtime/nonJavaThread.hpp" #include "runtime/objectMonitor.hpp" #include "runtime/orderAccess.hpp" #include "runtime/osThread.hpp" @@ -101,8 +101,6 @@ #include "runtime/sharedRuntime.hpp" #include "runtime/stackWatermarkSet.hpp" #include "runtime/statSampler.hpp" -#include "runtime/stubRoutines.hpp" -#include "runtime/sweeper.hpp" #include "runtime/task.hpp" #include "runtime/thread.inline.hpp" #include "runtime/threadCritical.hpp" @@ -127,7 +125,6 @@ #include "utilities/events.hpp" #include "utilities/macros.hpp" #include "utilities/preserveException.hpp" -#include "utilities/singleWriterSynchronizer.hpp" #include "utilities/spinYield.hpp" #include "utilities/vmError.hpp" #if INCLUDE_JVMCI @@ -1106,306 +1103,6 @@ void JavaThread::allocate_threadObj(Handle thread_group, const char* thread_name THREAD); } -// List of all NonJavaThreads and safe iteration over that list. - -class NonJavaThread::List { -public: - NonJavaThread* volatile _head; - SingleWriterSynchronizer _protect; - - List() : _head(NULL), _protect() {} -}; - -NonJavaThread::List NonJavaThread::_the_list; - -NonJavaThread::Iterator::Iterator() : - _protect_enter(_the_list._protect.enter()), - _current(Atomic::load_acquire(&_the_list._head)) -{} - -NonJavaThread::Iterator::~Iterator() { - _the_list._protect.exit(_protect_enter); -} - -void NonJavaThread::Iterator::step() { - assert(!end(), "precondition"); - _current = Atomic::load_acquire(&_current->_next); -} - -NonJavaThread::NonJavaThread() : Thread(), _next(NULL) { - assert(BarrierSet::barrier_set() != NULL, "NonJavaThread created too soon!"); -} - -NonJavaThread::~NonJavaThread() { } - -void NonJavaThread::add_to_the_list() { - MutexLocker ml(NonJavaThreadsList_lock, Mutex::_no_safepoint_check_flag); - // Initialize BarrierSet-related data before adding to list. - BarrierSet::barrier_set()->on_thread_attach(this); - Atomic::release_store(&_next, _the_list._head); - Atomic::release_store(&_the_list._head, this); -} - -void NonJavaThread::remove_from_the_list() { - { - MutexLocker ml(NonJavaThreadsList_lock, Mutex::_no_safepoint_check_flag); - // Cleanup BarrierSet-related data before removing from list. - BarrierSet::barrier_set()->on_thread_detach(this); - NonJavaThread* volatile* p = &_the_list._head; - for (NonJavaThread* t = *p; t != NULL; p = &t->_next, t = *p) { - if (t == this) { - *p = _next; - break; - } - } - } - // Wait for any in-progress iterators. Concurrent synchronize is not - // allowed, so do it while holding a dedicated lock. Outside and distinct - // from NJTList_lock in case an iteration attempts to lock it. - MutexLocker ml(NonJavaThreadsListSync_lock, Mutex::_no_safepoint_check_flag); - _the_list._protect.synchronize(); - _next = NULL; // Safe to drop the link now. -} - -void NonJavaThread::pre_run() { - add_to_the_list(); - - // This is slightly odd in that NamedThread is a subclass, but - // in fact name() is defined in Thread - assert(this->name() != NULL, "thread name was not set before it was started"); - this->set_native_thread_name(this->name()); -} - -void NonJavaThread::post_run() { - JFR_ONLY(Jfr::on_thread_exit(this);) - remove_from_the_list(); - unregister_thread_stack_with_NMT(); - // Ensure thread-local-storage is cleared before termination. - Thread::clear_thread_current(); - osthread()->set_state(ZOMBIE); -} - -// NamedThread -- non-JavaThread subclasses with multiple -// uniquely named instances should derive from this. -NamedThread::NamedThread() : - NonJavaThread(), - _name(NULL), - _processed_thread(NULL), - _gc_id(GCId::undefined()) -{} - -NamedThread::~NamedThread() { - FREE_C_HEAP_ARRAY(char, _name); -} - -void NamedThread::set_name(const char* format, ...) { - guarantee(_name == NULL, "Only get to set name once."); - _name = NEW_C_HEAP_ARRAY(char, max_name_len, mtThread); - va_list ap; - va_start(ap, format); - jio_vsnprintf(_name, max_name_len, format, ap); - va_end(ap); -} - -void NamedThread::print_on(outputStream* st) const { - st->print("\"%s\" ", name()); - Thread::print_on(st); - st->cr(); -} - - -// ======= WatcherThread ======== - -// The watcher thread exists to simulate timer interrupts. It should -// be replaced by an abstraction over whatever native support for -// timer interrupts exists on the platform. - -WatcherThread* WatcherThread::_watcher_thread = NULL; -bool WatcherThread::_startable = false; -volatile bool WatcherThread::_should_terminate = false; - -WatcherThread::WatcherThread() : NonJavaThread() { - assert(watcher_thread() == NULL, "we can only allocate one WatcherThread"); - if (os::create_thread(this, os::watcher_thread)) { - _watcher_thread = this; - - // Set the watcher thread to the highest OS priority which should not be - // used, unless a Java thread with priority java.lang.Thread.MAX_PRIORITY - // is created. The only normal thread using this priority is the reference - // handler thread, which runs for very short intervals only. - // If the VMThread's priority is not lower than the WatcherThread profiling - // will be inaccurate. - os::set_priority(this, MaxPriority); - os::start_thread(this); - } -} - -int WatcherThread::sleep() const { - // The WatcherThread does not participate in the safepoint protocol - // for the PeriodicTask_lock because it is not a JavaThread. - MonitorLocker ml(PeriodicTask_lock, Mutex::_no_safepoint_check_flag); - - if (_should_terminate) { - // check for termination before we do any housekeeping or wait - return 0; // we did not sleep. - } - - // remaining will be zero if there are no tasks, - // causing the WatcherThread to sleep until a task is - // enrolled - int remaining = PeriodicTask::time_to_wait(); - int time_slept = 0; - - // we expect this to timeout - we only ever get unparked when - // we should terminate or when a new task has been enrolled - OSThreadWaitState osts(this->osthread(), false /* not Object.wait() */); - - jlong time_before_loop = os::javaTimeNanos(); - - while (true) { - bool timedout = ml.wait(remaining); - jlong now = os::javaTimeNanos(); - - if (remaining == 0) { - // if we didn't have any tasks we could have waited for a long time - // consider the time_slept zero and reset time_before_loop - time_slept = 0; - time_before_loop = now; - } else { - // need to recalculate since we might have new tasks in _tasks - time_slept = (int) ((now - time_before_loop) / 1000000); - } - - // Change to task list or spurious wakeup of some kind - if (timedout || _should_terminate) { - break; - } - - remaining = PeriodicTask::time_to_wait(); - if (remaining == 0) { - // Last task was just disenrolled so loop around and wait until - // another task gets enrolled - continue; - } - - remaining -= time_slept; - if (remaining <= 0) { - break; - } - } - - return time_slept; -} - -void WatcherThread::run() { - assert(this == watcher_thread(), "just checking"); - - this->set_active_handles(JNIHandleBlock::allocate_block()); - while (true) { - assert(watcher_thread() == Thread::current(), "thread consistency check"); - assert(watcher_thread() == this, "thread consistency check"); - - // Calculate how long it'll be until the next PeriodicTask work - // should be done, and sleep that amount of time. - int time_waited = sleep(); - - if (VMError::is_error_reported()) { - // A fatal error has happened, the error handler(VMError::report_and_die) - // should abort JVM after creating an error log file. However in some - // rare cases, the error handler itself might deadlock. Here periodically - // check for error reporting timeouts, and if it happens, just proceed to - // abort the VM. - - // This code is in WatcherThread because WatcherThread wakes up - // periodically so the fatal error handler doesn't need to do anything; - // also because the WatcherThread is less likely to crash than other - // threads. - - for (;;) { - // Note: we use naked sleep in this loop because we want to avoid using - // any kind of VM infrastructure which may be broken at this point. - if (VMError::check_timeout()) { - // We hit error reporting timeout. Error reporting was interrupted and - // will be wrapping things up now (closing files etc). Give it some more - // time, then quit the VM. - os::naked_short_sleep(200); - // Print a message to stderr. - fdStream err(defaultStream::output_fd()); - err.print_raw_cr("# [ timer expired, abort... ]"); - // skip atexit/vm_exit/vm_abort hooks - os::die(); - } - - // Wait a second, then recheck for timeout. - os::naked_short_sleep(999); - } - } - - if (_should_terminate) { - // check for termination before posting the next tick - break; - } - - PeriodicTask::real_time_tick(time_waited); - } - - // Signal that it is terminated - { - MutexLocker mu(Terminator_lock, Mutex::_no_safepoint_check_flag); - _watcher_thread = NULL; - Terminator_lock->notify_all(); - } -} - -void WatcherThread::start() { - assert(PeriodicTask_lock->owned_by_self(), "PeriodicTask_lock required"); - - if (watcher_thread() == NULL && _startable) { - _should_terminate = false; - // Create the single instance of WatcherThread - new WatcherThread(); - } -} - -void WatcherThread::make_startable() { - assert(PeriodicTask_lock->owned_by_self(), "PeriodicTask_lock required"); - _startable = true; -} - -void WatcherThread::stop() { - { - // Follow normal safepoint aware lock enter protocol since the - // WatcherThread is stopped by another JavaThread. - MutexLocker ml(PeriodicTask_lock); - _should_terminate = true; - - WatcherThread* watcher = watcher_thread(); - if (watcher != NULL) { - // unpark the WatcherThread so it can see that it should terminate - watcher->unpark(); - } - } - - MonitorLocker mu(Terminator_lock); - - while (watcher_thread() != NULL) { - // This wait should make safepoint checks, wait without a timeout, - // and wait as a suspend-equivalent condition. - mu.wait(0, Mutex::_as_suspend_equivalent_flag); - } -} - -void WatcherThread::unpark() { - assert(PeriodicTask_lock->owned_by_self(), "PeriodicTask_lock required"); - PeriodicTask_lock->notify(); -} - -void WatcherThread::print_on(outputStream* st) const { - st->print("\"%s\" ", name()); - Thread::print_on(st); - st->cr(); -} - // ======= JavaThread ======== #if INCLUDE_JVMCI @@ -1674,19 +1371,14 @@ void JavaThread::block_if_vm_exited() { } } - -// Remove this ifdef when C1 is ported to the compiler interface. -static void compiler_thread_entry(JavaThread* thread, TRAPS); -static void sweeper_thread_entry(JavaThread* thread, TRAPS); - JavaThread::JavaThread(ThreadFunction entry_point, size_t stack_sz) : JavaThread() { _jni_attach_state = _not_attaching_via_jni; set_entry_point(entry_point); // Create the native thread itself. // %note runtime_23 os::ThreadType thr_type = os::java_thread; - thr_type = entry_point == &compiler_thread_entry ? os::compiler_thread : - os::java_thread; + thr_type = entry_point == &CompilerThread::thread_entry ? os::compiler_thread : + os::java_thread; os::create_thread(this, thr_type, stack_sz); // The _osthread may be NULL here because we ran out of memory (too many threads active). // We need to throw and OutOfMemoryError - however we cannot do this here because the caller @@ -3139,70 +2831,6 @@ bool JavaThread::sleep(jlong millis) { } } -static void compiler_thread_entry(JavaThread* thread, TRAPS) { - assert(thread->is_Compiler_thread(), "must be compiler thread"); - CompileBroker::compiler_thread_loop(); -} - -static void sweeper_thread_entry(JavaThread* thread, TRAPS) { - NMethodSweeper::sweeper_loop(); -} - -// Create a CompilerThread -CompilerThread::CompilerThread(CompileQueue* queue, - CompilerCounters* counters) - : JavaThread(&compiler_thread_entry) { - _env = NULL; - _log = NULL; - _task = NULL; - _queue = queue; - _counters = counters; - _buffer_blob = NULL; - _compiler = NULL; - - // Compiler uses resource area for compilation, let's bias it to mtCompiler - resource_area()->bias_to(mtCompiler); - -#ifndef PRODUCT - _ideal_graph_printer = NULL; -#endif -} - -CompilerThread::~CompilerThread() { - // Delete objects which were allocated on heap. - delete _counters; -} - -bool CompilerThread::can_call_java() const { - return _compiler != NULL && _compiler->is_jvmci(); -} - -// Create sweeper thread -CodeCacheSweeperThread::CodeCacheSweeperThread() -: JavaThread(&sweeper_thread_entry) { - _scanned_compiled_method = NULL; -} - -void CodeCacheSweeperThread::oops_do_no_frames(OopClosure* f, CodeBlobClosure* cf) { - JavaThread::oops_do_no_frames(f, cf); - if (_scanned_compiled_method != NULL && cf != NULL) { - // Safepoints can occur when the sweeper is scanning an nmethod so - // process it here to make sure it isn't unloaded in the middle of - // a scan. - cf->do_code_blob(_scanned_compiled_method); - } -} - -void CodeCacheSweeperThread::nmethods_do(CodeBlobClosure* cf) { - JavaThread::nmethods_do(cf); - if (_scanned_compiled_method != NULL && cf != NULL) { - // Safepoints can occur when the sweeper is scanning an nmethod so - // process it here to make sure it isn't unloaded in the middle of - // a scan. - cf->do_code_blob(_scanned_compiled_method); - } -} - // ======= Threads ======== diff --git a/src/hotspot/share/runtime/thread.hpp b/src/hotspot/share/runtime/thread.hpp index 029c5a5e9013c..d0125dcbc2928 100644 --- a/src/hotspot/share/runtime/thread.hpp +++ b/src/hotspot/share/runtime/thread.hpp @@ -69,15 +69,6 @@ class ThreadStatistics; class ConcurrentLocksDump; class MonitorInfo; -class BufferBlob; -class AbstractCompiler; -class ciEnv; -class CompileThread; -class CompileLog; -class CompileTask; -class CompileQueue; -class CompilerCounters; - class vframeArray; class vframe; class javaVFrame; @@ -87,10 +78,6 @@ class JvmtiDeferredUpdates; class ThreadClosure; class ICRefillVerifier; -class IdealGraphPrinter; - -class JVMCIEnv; -class JVMCIPrimitiveArray; class Metadata; class ResourceArea; @@ -864,141 +851,6 @@ inline Thread* Thread::current_or_null_safe() { return NULL; } -class NonJavaThread: public Thread { - friend class VMStructs; - - NonJavaThread* volatile _next; - - class List; - static List _the_list; - - void add_to_the_list(); - void remove_from_the_list(); - - protected: - virtual void pre_run(); - virtual void post_run(); - - public: - NonJavaThread(); - ~NonJavaThread(); - - class Iterator; -}; - -// Provides iteration over the list of NonJavaThreads. -// List addition occurs in pre_run(), and removal occurs in post_run(), -// so that only live fully-initialized threads can be found in the list. -// Threads created after an iterator is constructed will not be visited -// by the iterator. The scope of an iterator is a critical section; there -// must be no safepoint checks in that scope. -class NonJavaThread::Iterator : public StackObj { - uint _protect_enter; - NonJavaThread* _current; - - NONCOPYABLE(Iterator); - -public: - Iterator(); - ~Iterator(); - - bool end() const { return _current == NULL; } - NonJavaThread* current() const { return _current; } - void step(); -}; - -// Name support for threads. non-JavaThread subclasses with multiple -// uniquely named instances should derive from this. -class NamedThread: public NonJavaThread { - friend class VMStructs; - enum { - max_name_len = 64 - }; - private: - char* _name; - // log Thread being processed by oops_do - Thread* _processed_thread; - uint _gc_id; // The current GC id when a thread takes part in GC - - public: - NamedThread(); - ~NamedThread(); - // May only be called once per thread. - void set_name(const char* format, ...) ATTRIBUTE_PRINTF(2, 3); - virtual bool is_Named_thread() const { return true; } - virtual char* name() const { return _name == NULL ? (char*)"Unknown Thread" : _name; } - Thread *processed_thread() { return _processed_thread; } - void set_processed_thread(Thread *thread) { _processed_thread = thread; } - virtual void print_on(outputStream* st) const; - - void set_gc_id(uint gc_id) { _gc_id = gc_id; } - uint gc_id() { return _gc_id; } -}; - -// Worker threads are named and have an id of an assigned work. -class WorkerThread: public NamedThread { - private: - uint _id; - public: - WorkerThread() : _id(0) { } - virtual bool is_Worker_thread() const { return true; } - - virtual WorkerThread* as_Worker_thread() const { - assert(is_Worker_thread(), "Dubious cast to WorkerThread*?"); - return (WorkerThread*) this; - } - - void set_id(uint work_id) { _id = work_id; } - uint id() const { return _id; } -}; - -// A single WatcherThread is used for simulating timer interrupts. -class WatcherThread: public NonJavaThread { - friend class VMStructs; - protected: - virtual void run(); - - private: - static WatcherThread* _watcher_thread; - - static bool _startable; - // volatile due to at least one lock-free read - volatile static bool _should_terminate; - public: - enum SomeConstants { - delay_interval = 10 // interrupt delay in milliseconds - }; - - // Constructor - WatcherThread(); - - // No destruction allowed - ~WatcherThread() { - guarantee(false, "WatcherThread deletion must fix the race with VM termination"); - } - - // Tester - bool is_Watcher_thread() const { return true; } - - // Printing - char* name() const { return (char*)"VM Periodic Task Thread"; } - void print_on(outputStream* st) const; - void unpark(); - - // Returns the single instance of WatcherThread - static WatcherThread* watcher_thread() { return _watcher_thread; } - - // Create and start the single instance of WatcherThread, or stop it on shutdown - static void start(); - static void stop(); - // Only allow start once the VM is sufficiently initialized - // Otherwise the first task to enroll will trigger the start - static void make_startable(); - private: - int sleep() const; -}; - - class CompilerThread; typedef void (*ThreadFunction)(JavaThread*, TRAPS); @@ -1897,100 +1749,6 @@ inline JavaThread* JavaThread::current() { return Thread::current()->as_Java_thread(); } -inline CompilerThread* JavaThread::as_CompilerThread() { - assert(is_Compiler_thread(), "just checking"); - return (CompilerThread*)this; -} - -// Dedicated thread to sweep the code cache -class CodeCacheSweeperThread : public JavaThread { - CompiledMethod* _scanned_compiled_method; // nmethod being scanned by the sweeper - public: - CodeCacheSweeperThread(); - // Track the nmethod currently being scanned by the sweeper - void set_scanned_compiled_method(CompiledMethod* cm) { - assert(_scanned_compiled_method == NULL || cm == NULL, "should reset to NULL before writing a new value"); - _scanned_compiled_method = cm; - } - - // Hide sweeper thread from external view. - bool is_hidden_from_external_view() const { return true; } - - bool is_Code_cache_sweeper_thread() const { return true; } - - // Prevent GC from unloading _scanned_compiled_method - void oops_do_no_frames(OopClosure* f, CodeBlobClosure* cf); - void nmethods_do(CodeBlobClosure* cf); -}; - -// A thread used for Compilation. -class CompilerThread : public JavaThread { - friend class VMStructs; - private: - CompilerCounters* _counters; - - ciEnv* _env; - CompileLog* _log; - CompileTask* volatile _task; // print_threads_compiling can read this concurrently. - CompileQueue* _queue; - BufferBlob* _buffer_blob; - - AbstractCompiler* _compiler; - TimeStamp _idle_time; - - public: - - static CompilerThread* current(); - - CompilerThread(CompileQueue* queue, CompilerCounters* counters); - ~CompilerThread(); - - bool is_Compiler_thread() const { return true; } - - virtual bool can_call_java() const; - - // Hide native compiler threads from external view. - bool is_hidden_from_external_view() const { return !can_call_java(); } - - void set_compiler(AbstractCompiler* c) { _compiler = c; } - AbstractCompiler* compiler() const { return _compiler; } - - CompileQueue* queue() const { return _queue; } - CompilerCounters* counters() const { return _counters; } - - // Get/set the thread's compilation environment. - ciEnv* env() { return _env; } - void set_env(ciEnv* env) { _env = env; } - - BufferBlob* get_buffer_blob() const { return _buffer_blob; } - void set_buffer_blob(BufferBlob* b) { _buffer_blob = b; } - - // Get/set the thread's logging information - CompileLog* log() { return _log; } - void init_log(CompileLog* log) { - // Set once, for good. - assert(_log == NULL, "set only once"); - _log = log; - } - - void start_idle_timer() { _idle_time.update(); } - jlong idle_time_millis() { - return TimeHelper::counter_to_millis(_idle_time.ticks_since_update()); - } - -#ifndef PRODUCT - private: - IdealGraphPrinter *_ideal_graph_printer; - public: - IdealGraphPrinter *ideal_graph_printer() { return _ideal_graph_printer; } - void set_ideal_graph_printer(IdealGraphPrinter *n) { _ideal_graph_printer = n; } -#endif - - // Get/set the thread's current task - CompileTask* task() { return _task; } - void set_task(CompileTask* task) { _task = task; } -}; - inline JavaThread* Thread::as_Java_thread() { assert(is_Java_thread(), "incorrect cast to JavaThread"); return static_cast(this); @@ -2001,10 +1759,6 @@ inline const JavaThread* Thread::as_Java_thread() const { return static_cast(this); } -inline CompilerThread* CompilerThread::current() { - return JavaThread::current()->as_CompilerThread(); -} - // The active thread queue. It also keeps track of the current used // thread priorities. class Threads: AllStatic { diff --git a/src/hotspot/share/runtime/vmThread.hpp b/src/hotspot/share/runtime/vmThread.hpp index b0928a5b28b4a..915f8926e2909 100644 --- a/src/hotspot/share/runtime/vmThread.hpp +++ b/src/hotspot/share/runtime/vmThread.hpp @@ -26,6 +26,7 @@ #define SHARE_RUNTIME_VMTHREAD_HPP #include "runtime/perfDataTypes.hpp" +#include "runtime/nonJavaThread.hpp" #include "runtime/thread.hpp" #include "runtime/task.hpp" #include "runtime/vmOperations.hpp" From d2bd499222382e44d849b4884e72d2c9117895ed Mon Sep 17 00:00:00 2001 From: Fernando Guallini Date: Fri, 5 Feb 2021 05:22:51 +0000 Subject: [PATCH 69/77] 8163498: Many long-running security libs tests Reviewed-by: rhalade, weijun --- .../KeyAgreement/SupportedDHParamGens.java | 8 +- .../SupportedDHParamGensLongKey.java | 32 ++++++ .../provider/DSA/SupportedDSAParamGen.java | 8 +- .../DSA/SupportedDSAParamGenLongKey.java | 32 ++++++ .../NSASuiteB/TestDSAGenParameterSpec.java | 9 +- .../TestDSAGenParameterSpecLongKey.java | 36 +++++++ test/jdk/sun/security/rsa/SignatureTest.java | 75 ++++++++++--- .../sun/security/rsa/RSAKeyPairGenerator.java | 102 +++++++++++++++++- 8 files changed, 276 insertions(+), 26 deletions(-) create mode 100644 test/jdk/com/sun/crypto/provider/KeyAgreement/SupportedDHParamGensLongKey.java create mode 100644 test/jdk/sun/security/provider/DSA/SupportedDSAParamGenLongKey.java create mode 100644 test/jdk/sun/security/provider/NSASuiteB/TestDSAGenParameterSpecLongKey.java diff --git a/test/jdk/com/sun/crypto/provider/KeyAgreement/SupportedDHParamGens.java b/test/jdk/com/sun/crypto/provider/KeyAgreement/SupportedDHParamGens.java index ac3f384bcf2af..27f010dd1419d 100644 --- a/test/jdk/com/sun/crypto/provider/KeyAgreement/SupportedDHParamGens.java +++ b/test/jdk/com/sun/crypto/provider/KeyAgreement/SupportedDHParamGens.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,14 +23,16 @@ /** * @test - * @bug 8072452 + * @bug 8072452 8163498 * @summary Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits + * This test has been split based on lower/higher key sizes in order to + * reduce individual execution times and run in parallel + * (see SupportedDHParamGensLongKey.java) * @run main/timeout=300 SupportedDHParamGens 512 * @run main/timeout=300 SupportedDHParamGens 768 * @run main/timeout=300 SupportedDHParamGens 832 * @run main/timeout=300 SupportedDHParamGens 1024 * @run main/timeout=600 SupportedDHParamGens 2048 - * @run main/timeout=700 SupportedDHParamGens 3072 */ import java.math.BigInteger; diff --git a/test/jdk/com/sun/crypto/provider/KeyAgreement/SupportedDHParamGensLongKey.java b/test/jdk/com/sun/crypto/provider/KeyAgreement/SupportedDHParamGensLongKey.java new file mode 100644 index 0000000000000..740486e06cf92 --- /dev/null +++ b/test/jdk/com/sun/crypto/provider/KeyAgreement/SupportedDHParamGensLongKey.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8072452 8163498 + * @summary Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits + * This test has been split based on lower/higher key sizes in order to + * reduce individual execution times and run in parallel + * (see SupportedDHParamGens.java) + * @run main/timeout=700 SupportedDHParamGens 3072 + */ diff --git a/test/jdk/sun/security/provider/DSA/SupportedDSAParamGen.java b/test/jdk/sun/security/provider/DSA/SupportedDSAParamGen.java index 7b770a993cf5e..52a97b34a3e93 100644 --- a/test/jdk/sun/security/provider/DSA/SupportedDSAParamGen.java +++ b/test/jdk/sun/security/provider/DSA/SupportedDSAParamGen.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,12 +23,14 @@ /* * @test - * @bug 8072452 + * @bug 8072452 8163498 * @summary Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits + * This test has been split based on lower/higher key sizes in order to + * reduce individual execution times and run in parallel + * (see SupportedDSAParamGenLongKey.java) * @run main/timeout=300 SupportedDSAParamGen 1024 160 * @run main/timeout=300 SupportedDSAParamGen 2048 224 * @run main/timeout=300 SupportedDSAParamGen 2048 256 - * @run main/timeout=700 SupportedDSAParamGen 3072 256 */ import java.security.*; import java.security.spec.*; diff --git a/test/jdk/sun/security/provider/DSA/SupportedDSAParamGenLongKey.java b/test/jdk/sun/security/provider/DSA/SupportedDSAParamGenLongKey.java new file mode 100644 index 0000000000000..c6704231c7e11 --- /dev/null +++ b/test/jdk/sun/security/provider/DSA/SupportedDSAParamGenLongKey.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8072452 8163498 + * @summary Support DHE sizes up to 8192-bits and DSA sizes up to 3072-bits + * This test has been split based on lower/higher key sizes in order to + * reduce individual execution times and run in parallel + * (see SupportedDSAParamGen.java) + * @run main/timeout=700 SupportedDSAParamGen 3072 256 + */ diff --git a/test/jdk/sun/security/provider/NSASuiteB/TestDSAGenParameterSpec.java b/test/jdk/sun/security/provider/NSASuiteB/TestDSAGenParameterSpec.java index 0ba2a0c5d611e..51bc45f19fe54 100644 --- a/test/jdk/sun/security/provider/NSASuiteB/TestDSAGenParameterSpec.java +++ b/test/jdk/sun/security/provider/NSASuiteB/TestDSAGenParameterSpec.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,11 +34,14 @@ /* * @test - * @bug 8075286 + * @bug 8075286 8163498 * @summary Verify that DSAGenParameterSpec can and can only be used to generate * DSA within some certain range of key sizes as described in the class * specification (L, N) as (1024, 160), (2048, 224), (2048, 256) and * (3072, 256) should be OK for DSAGenParameterSpec. + * This test has been split based on lower/higher key sizes in order to + * reduce individual execution times and run in parallel + * (see TestDSAGenParameterSpecLongKey.java) * @run main TestDSAGenParameterSpec 512 160 * @run main TestDSAGenParameterSpec 1024 160 true * @run main TestDSAGenParameterSpec 1024 224 @@ -46,8 +49,6 @@ * @run main/timeout=300 TestDSAGenParameterSpec 2048 224 true * @run main/timeout=300 TestDSAGenParameterSpec 2048 256 true * @run main TestDSAGenParameterSpec 3072 224 - * @run main/timeout=700 TestDSAGenParameterSpec 3072 256 true - * @run main TestDSAGenParameterSpec 4096 256 */ public class TestDSAGenParameterSpec { diff --git a/test/jdk/sun/security/provider/NSASuiteB/TestDSAGenParameterSpecLongKey.java b/test/jdk/sun/security/provider/NSASuiteB/TestDSAGenParameterSpecLongKey.java new file mode 100644 index 0000000000000..58653def0dde6 --- /dev/null +++ b/test/jdk/sun/security/provider/NSASuiteB/TestDSAGenParameterSpecLongKey.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8075286 8163498 + * @summary Verify that DSAGenParameterSpec can and can only be used to generate + * DSA within some certain range of key sizes as described in the class + * specification (L, N) as (1024, 160), (2048, 224), (2048, 256) and + * (3072, 256) should be OK for DSAGenParameterSpec. + * This test has been split based on lower/higher key sizes in order to + * reduce individual execution times and run in parallel + * (see TestDSAGenParameterSpec.java) + * @run main/timeout=700 TestDSAGenParameterSpec 3072 256 true + * @run main TestDSAGenParameterSpec 4096 256 + */ \ No newline at end of file diff --git a/test/jdk/sun/security/rsa/SignatureTest.java b/test/jdk/sun/security/rsa/SignatureTest.java index d52ed67cb59d1..15df96354b38e 100644 --- a/test/jdk/sun/security/rsa/SignatureTest.java +++ b/test/jdk/sun/security/rsa/SignatureTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,17 +29,21 @@ import static javax.crypto.Cipher.PRIVATE_KEY; import static javax.crypto.Cipher.PUBLIC_KEY; +import jdk.test.lib.Asserts; import jdk.test.lib.SigTestUtil; import static jdk.test.lib.SigTestUtil.SignatureType; /** * @test - * @bug 8044199 8146293 - * @summary Create a signature for RSA and get its signed data. re-initiate + * @bug 8044199 8146293 8163498 + * @summary Ensure keys created from KeyFactory::getKeySpec and from constructors + * are equal. + * Create a signature for RSA and get its signed data. re-initiate * the signature with the public key. The signature can be verified * by acquired signed data. - * @library /test/lib + * @library /test/lib ../tools/keytool/fakegen * @build jdk.test.lib.SigTestUtil + * @build java.base/sun.security.rsa.RSAKeyPairGenerator * @run main SignatureTest 512 * @run main SignatureTest 768 * @run main SignatureTest 1024 @@ -133,12 +137,24 @@ private static Key[] manipulateKey(int type, Key key) } catch (InvalidKeySpecException expected) { } + RSAPublicKeySpec pubKeySpec1 = kf.getKeySpec(key, RSAPublicKeySpec.class); + RSAPublicKeySpec pubKeySpec2 = new RSAPublicKeySpec( + ((RSAPublicKey) key).getModulus(), + ((RSAPublicKey) key).getPublicExponent()); + + Asserts.assertTrue(keySpecEquals(pubKeySpec1, pubKeySpec2), + "Both RSAPublicKeySpec should be equal"); + + X509EncodedKeySpec x509KeySpec1 = kf.getKeySpec(key, X509EncodedKeySpec.class); + X509EncodedKeySpec x509KeySpec2 = new X509EncodedKeySpec(key.getEncoded()); + + Asserts.assertTrue(encodedKeySpecEquals(x509KeySpec1, x509KeySpec2), + "Both X509EncodedKeySpec should be equal"); + return new Key[]{ - kf.generatePublic(kf.getKeySpec(key, RSAPublicKeySpec.class)), - kf.generatePublic(new X509EncodedKeySpec(key.getEncoded())), - kf.generatePublic(new RSAPublicKeySpec( - ((RSAPublicKey) key).getModulus(), - ((RSAPublicKey) key).getPublicExponent())) + key, + kf.generatePublic(pubKeySpec1), + kf.generatePublic(x509KeySpec1) }; case PRIVATE_KEY: try { @@ -147,13 +163,24 @@ private static Key[] manipulateKey(int type, Key key) + " not thrown"); } catch (InvalidKeySpecException expected) { } + RSAPrivateKeySpec privKeySpec1 = kf.getKeySpec(key, RSAPrivateKeySpec.class); + RSAPrivateKeySpec privKeySpec2 = new RSAPrivateKeySpec( + ((RSAPrivateKey) key).getModulus(), + ((RSAPrivateKey) key).getPrivateExponent()); + + Asserts.assertTrue(keySpecEquals(privKeySpec1, privKeySpec2), + "Both RSAPrivateKeySpec should be equal"); + + PKCS8EncodedKeySpec pkcsKeySpec1 = kf.getKeySpec(key, PKCS8EncodedKeySpec.class); + PKCS8EncodedKeySpec pkcsKeySpec2 = new PKCS8EncodedKeySpec(key.getEncoded()); + + Asserts.assertTrue(encodedKeySpecEquals(pkcsKeySpec1, pkcsKeySpec2), + "Both PKCS8EncodedKeySpec should be equal"); + return new Key[]{ - kf.generatePrivate(kf.getKeySpec(key, - RSAPrivateKeySpec.class)), - kf.generatePrivate(new PKCS8EncodedKeySpec( - key.getEncoded())), - kf.generatePrivate(new RSAPrivateKeySpec(((RSAPrivateKey) key).getModulus(), - ((RSAPrivateKey) key).getPrivateExponent())) + key, + kf.generatePrivate(privKeySpec1), + kf.generatePrivate(pkcsKeySpec1) }; } throw new RuntimeException("We shouldn't reach here"); @@ -197,4 +224,22 @@ private static void checkSignature(byte[] data, PublicKey pub, + " signature"); } } + + private static boolean keySpecEquals(RSAPublicKeySpec spec1, RSAPublicKeySpec spec2) { + return spec1.getModulus().equals(spec2.getModulus()) + && spec1.getPublicExponent().equals(spec2.getPublicExponent()) + && Objects.equals(spec1.getParams(), spec2.getParams()); + } + + private static boolean keySpecEquals(RSAPrivateKeySpec spec1, RSAPrivateKeySpec spec2) { + return spec1.getModulus().equals(spec2.getModulus()) + && spec1.getPrivateExponent().equals(spec2.getPrivateExponent()) + && Objects.equals(spec1.getParams(), spec2.getParams()); + } + + private static boolean encodedKeySpecEquals(EncodedKeySpec spec1, EncodedKeySpec spec2) { + return Objects.equals(spec1.getAlgorithm(), spec2.getAlgorithm()) + && spec1.getFormat().equals(spec2.getFormat()) + && Arrays.equals(spec1.getEncoded(), spec2.getEncoded()); + } } diff --git a/test/jdk/sun/security/tools/keytool/fakegen/java.base/sun/security/rsa/RSAKeyPairGenerator.java b/test/jdk/sun/security/tools/keytool/fakegen/java.base/sun/security/rsa/RSAKeyPairGenerator.java index 4fc8272ae532d..70e977f86c7fc 100644 --- a/test/jdk/sun/security/tools/keytool/fakegen/java.base/sun/security/rsa/RSAKeyPairGenerator.java +++ b/test/jdk/sun/security/tools/keytool/fakegen/java.base/sun/security/rsa/RSAKeyPairGenerator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -119,6 +119,22 @@ public KeyPair generateKeyPair() { // Pre-calculated p and q for e == RSAKeyGenParameterSpec.F4 switch (keySize) { + case 512: + p = new BigInteger("8020197120481219323433199611941970" + + "7343202627066030554371666273840736868057027"); + + q = new BigInteger("1034972075609195648369724560234440" + + "70295399787770567842730763283716564384306019"); + break; + case 768: + p = new BigInteger("3014340057405340213534944319905083" + + "307463736669377067548946180566257416015519309" + + "4284652308891881268862122066025991763"); + + q = new BigInteger("2296482383752927761663381890127318" + + "246354728737890494883686642246681037847109357" + + "2243186228256258231783150577032535521"); + break; case 1024: p = new BigInteger("1220491537800192366196661816910427" + "2375185130493819649338056226264568132442590" @@ -230,6 +246,90 @@ public KeyPair generateKeyPair() { + "5341584429803583589276956979963609078497238" + "760757619468018224491053"); break; + case 5120: + p = new BigInteger("3832424741858359087085019371467455" + + "477820253497664907405863412466091484202728975" + + "073716151647542449749677812957312366114168136" + + "601126462176029012452318767677007998900979141" + + "998941420505000455608776648534383479255437038" + + "823585008944551642245975099397794466252853815" + + "203014018988068346182132859181656248769392421" + + "674329339264774434516306264105498304974256178" + + "026250495864309250770172644263271598862641423" + + "631834585580910907527816840629665632700476957" + + "043059773597106256672930878739201142231424811" + + "069114153595397879660681041405350927706894635" + + "213653200929550087449740488813888141436925212" + + "442118365403614623169477625363286007075561882" + + "667104018888315477880055907473210438614579462" + + "496680112778003198202297772073923181825706950" + + "337756420826065243712623977225389265073815099" + + "11493486387569031"); + + q = new BigInteger("4146920568848191633539637174274014" + + "273474016268898436739861681496795368277264211" + + "347843247126933726314115942365962498640261418" + + "205807625467516350689984100345264883329988411" + + "779552170850267866351632396757500932855514738" + + "069918613980688598735820287717773558232108195" + + "582003010318600589422737510968348435291394630" + + "302856598706075108993749783272560317909096664" + + "669346475063020551195971583247945204761628694" + + "928169578936651221139603528255637489949563762" + + "679333707194876390341639312682559633604823162" + + "011775857712214779083777623361101169846144970" + + "895460110829130520744350827300192454548398367" + + "308247776459836067815323028595970305077016546" + + "572729562552659889374473339319508744706500295" + + "871005194700994677334996554312946263536447080" + + "506480369599180714418422948431890690584559846" + + "74443760221378817"); + break; + case 6144: + p = new BigInteger("4116778174071734089881578561570208" + + "284278483208207611885263908178511953898663059" + + "734920127853932340647715543357847246656399270" + + "584421304381161243387321196180504266791989629" + + "037762533723859313828066684108658077147663308" + + "349610753424620992228874944364889251603796733" + + "651690820777521473807836887101380451450340893" + + "342182241046213770274098088066973392388380321" + + "597140066726105421813589290486721393630060991" + + "762786515266517210263824648882183969111257670" + + "482546599227987866663009035297583354975557124" + + "885067375690161316321537733738836231124022045" + + "342294989201664821765828714777945420537586846" + + "048441021936371397157175119512813296245432265" + + "178387966306100222317125784086707249132094899" + + "996583841504000177878867233453992573758531314" + + "930995997084778704191508142386227640558575022" + + "133615865313158902645671060856578407704407774" + + "541333134066077091323113676552873589627627108" + + "360212137049807676300972916221155242551418611" + + "845736012720292530472299883528545969"); + + q = new BigInteger("4309839393870191337347865939376524" + + "576203152274153819273872971875048034824772989" + + "396672731779116057590220960038178464518939532" + + "420543642549157490693480032819877624270041000" + + "978557189754354533164374250973267430850549095" + + "826504764380972668230808804187197733712467810" + + "336183971273199424298548393174475795085431856" + + "013835093176229700961388036392126193800974224" + + "471901942503594710577458613014825799700253747" + + "894059557606488589338390076087557449706202211" + + "490152794976124198853288767811370937925352946" + + "840084185059748423462857292189804953877120675" + + "812342626896129968757865091819031550949977046" + + "088481307609680346652447103811683263607048407" + + "341877388569162602224005230757828237769174382" + + "379831366827054223659952996908127997873168014" + + "060581963520521443425267958786876837371303659" + + "489061589736155453144095545148190985660891326" + + "576261326549991792303912873247304434509759694" + + "274088584815015779154382635174538158301861164" + + "439921681110768794043391613853281233"); + break; case 7680: p = new BigInteger("7034022146817764608206409206476311" + "1371065855827199565170055133179419153145313" From 1e0a1013efcb3983d277134f04f5e38f687e88c5 Mon Sep 17 00:00:00 2001 From: Kim Barrett Date: Fri, 5 Feb 2021 07:24:09 +0000 Subject: [PATCH 70/77] 8259862: MutableSpace's end should be atomic Make _end volatile and use atomic access Reviewed-by: ayang, tschatzl --- .../share/gc/parallel/mutableSpace.hpp | 27 ++++++++++--------- .../gc/parallel/parallelScavengeHeap.hpp | 3 --- src/hotspot/share/gc/parallel/psYoungGen.hpp | 3 --- .../gc/parallel/vmStructs_parallelgc.hpp | 2 +- 4 files changed, 15 insertions(+), 20 deletions(-) diff --git a/src/hotspot/share/gc/parallel/mutableSpace.hpp b/src/hotspot/share/gc/parallel/mutableSpace.hpp index 3e9b0a1514c82..33253642983a4 100644 --- a/src/hotspot/share/gc/parallel/mutableSpace.hpp +++ b/src/hotspot/share/gc/parallel/mutableSpace.hpp @@ -28,6 +28,7 @@ #include "memory/allocation.hpp" #include "memory/iterator.hpp" #include "memory/memRegion.hpp" +#include "runtime/atomic.hpp" #include "utilities/copy.hpp" #include "utilities/globalDefinitions.hpp" #include "utilities/macros.hpp" @@ -42,9 +43,6 @@ class WorkGang; // page allocation time by having the memory pretouched (with // AlwaysPretouch) and for optimizing page placement on NUMA systems // by make the underlying region interleaved (with UseNUMA). -// -// Invariant: bottom() <= top() <= end() -// top() and end() are exclusive. class MutableSpaceMangler; @@ -56,9 +54,11 @@ class MutableSpace: public CHeapObj { // The last region which page had been setup to be interleaved. MemRegion _last_setup_region; size_t _alignment; - HeapWord* _bottom; - HeapWord* volatile _top; - HeapWord* _end; + // Supports CAS-based allocation. + // Invariant: bottom() <= top() <= end() + HeapWord* _bottom; // Start of the region. + HeapWord* volatile _top; // Current allocation pointer. + HeapWord* volatile _end; // Current allocation limit. expand() advances. MutableSpaceMangler* mangler() { return _mangler; } @@ -67,21 +67,22 @@ class MutableSpace: public CHeapObj { void set_last_setup_region(MemRegion mr) { _last_setup_region = mr; } MemRegion last_setup_region() const { return _last_setup_region; } + protected: + HeapWord* volatile* top_addr() { return &_top; } + HeapWord* volatile* end_addr() { return &_end; } + public: virtual ~MutableSpace(); MutableSpace(size_t page_size); // Accessors HeapWord* bottom() const { return _bottom; } - HeapWord* top() const { return _top; } - HeapWord* end() const { return _end; } + HeapWord* top() const { return Atomic::load(&_top); } + HeapWord* end() const { return Atomic::load(&_end); } void set_bottom(HeapWord* value) { _bottom = value; } - virtual void set_top(HeapWord* value) { _top = value; } - void set_end(HeapWord* value) { _end = value; } - - HeapWord* volatile* top_addr() { return &_top; } - HeapWord** end_addr() { return &_end; } + virtual void set_top(HeapWord* value) { Atomic::store(&_top, value); } + void set_end(HeapWord* value) { Atomic::store(&_end, value); } size_t alignment() { return _alignment; } diff --git a/src/hotspot/share/gc/parallel/parallelScavengeHeap.hpp b/src/hotspot/share/gc/parallel/parallelScavengeHeap.hpp index e4cdb776453e4..53a69196b6c8f 100644 --- a/src/hotspot/share/gc/parallel/parallelScavengeHeap.hpp +++ b/src/hotspot/share/gc/parallel/parallelScavengeHeap.hpp @@ -200,9 +200,6 @@ class ParallelScavengeHeap : public CollectedHeap { bool supports_inline_contig_alloc() const { return !UseNUMA; } - HeapWord* volatile* top_addr() const { return !UseNUMA ? young_gen()->top_addr() : (HeapWord* volatile*)-1; } - HeapWord** end_addr() const { return !UseNUMA ? young_gen()->end_addr() : (HeapWord**)-1; } - void ensure_parsability(bool retire_tlabs); void resize_all_tlabs(); diff --git a/src/hotspot/share/gc/parallel/psYoungGen.hpp b/src/hotspot/share/gc/parallel/psYoungGen.hpp index 0da0592a98616..ee6dc298cf4a4 100644 --- a/src/hotspot/share/gc/parallel/psYoungGen.hpp +++ b/src/hotspot/share/gc/parallel/psYoungGen.hpp @@ -133,9 +133,6 @@ class PSYoungGen : public CHeapObj { return result; } - HeapWord* volatile* top_addr() const { return eden_space()->top_addr(); } - HeapWord** end_addr() const { return eden_space()->end_addr(); } - // Iteration. void oop_iterate(OopIterateClosure* cl); void object_iterate(ObjectClosure* cl); diff --git a/src/hotspot/share/gc/parallel/vmStructs_parallelgc.hpp b/src/hotspot/share/gc/parallel/vmStructs_parallelgc.hpp index 0f131687f5b18..3b6f3f87c6504 100644 --- a/src/hotspot/share/gc/parallel/vmStructs_parallelgc.hpp +++ b/src/hotspot/share/gc/parallel/vmStructs_parallelgc.hpp @@ -46,7 +46,7 @@ nonstatic_field(PSVirtualSpace, _committed_high_addr, char*) \ \ nonstatic_field(MutableSpace, _bottom, HeapWord*) \ - nonstatic_field(MutableSpace, _end, HeapWord*) \ + volatile_nonstatic_field(MutableSpace, _end, HeapWord*) \ volatile_nonstatic_field(MutableSpace, _top, HeapWord*) \ \ nonstatic_field(PSYoungGen, _reserved, MemRegion) \ From ee2f2055298152090b980e4b46053a720bae316f Mon Sep 17 00:00:00 2001 From: Thomas Stuefe Date: Fri, 5 Feb 2021 07:31:06 +0000 Subject: [PATCH 71/77] 8260926: Trace resource exhausted events unconditionally Reviewed-by: dholmes, coleenp --- src/hotspot/share/prims/jvmtiExport.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/hotspot/share/prims/jvmtiExport.cpp b/src/hotspot/share/prims/jvmtiExport.cpp index c2bb3d589b40c..eca6c57388800 100644 --- a/src/hotspot/share/prims/jvmtiExport.cpp +++ b/src/hotspot/share/prims/jvmtiExport.cpp @@ -1506,6 +1506,9 @@ void JvmtiExport::post_resource_exhausted(jint resource_exhausted_flags, const c JavaThread *thread = JavaThread::current(); + log_error(jvmti)("Posting Resource Exhausted event: %s", + description != nullptr ? description : "unknown"); + // JDK-8213834: handlers of ResourceExhausted may attempt some analysis // which often requires running java. // This will cause problems on threads not able to run java, e.g. compiler From 78b0d3274200df6ad1063f26ce637c163dbd6ac8 Mon Sep 17 00:00:00 2001 From: Thomas Schatzl Date: Fri, 5 Feb 2021 08:33:32 +0000 Subject: [PATCH 72/77] 8234534: Simplify CardTable code after CMS removal Reviewed-by: ayang, kbarrett --- .../share/gc/serial/defNewGeneration.cpp | 2 - .../gc/serial/defNewGeneration.inline.hpp | 5 +- src/hotspot/share/gc/serial/serialHeap.cpp | 3 +- .../gc/shared/c2/cardTableBarrierSetC2.cpp | 2 +- .../share/gc/shared/cardGeneration.cpp | 4 +- src/hotspot/share/gc/shared/cardTableRS.cpp | 99 +---------------- src/hotspot/share/gc/shared/cardTableRS.hpp | 100 +----------------- .../share/gc/shared/genOopClosures.inline.hpp | 2 +- src/hotspot/share/gc/shared/vmStructs_gc.hpp | 2 - 9 files changed, 14 insertions(+), 205 deletions(-) diff --git a/src/hotspot/share/gc/serial/defNewGeneration.cpp b/src/hotspot/share/gc/serial/defNewGeneration.cpp index 06163a79b70eb..b606e7080cf11 100644 --- a/src/hotspot/share/gc/serial/defNewGeneration.cpp +++ b/src/hotspot/share/gc/serial/defNewGeneration.cpp @@ -556,8 +556,6 @@ void DefNewGeneration::collect(bool full, // The preserved marks should be empty at the start of the GC. _preserved_marks_set.init(1); - heap->rem_set()->prepare_for_younger_refs_iterate(false); - assert(heap->no_allocs_since_save_marks(), "save marks have not been newly set."); diff --git a/src/hotspot/share/gc/serial/defNewGeneration.inline.hpp b/src/hotspot/share/gc/serial/defNewGeneration.inline.hpp index 67dce43e7b646..f3a3079f068c2 100644 --- a/src/hotspot/share/gc/serial/defNewGeneration.inline.hpp +++ b/src/hotspot/share/gc/serial/defNewGeneration.inline.hpp @@ -61,8 +61,7 @@ inline void DefNewGeneration::KeepAliveClosure::do_oop_work(T* p) { // dirty cards in the young gen are never scanned, so the // extra check probably isn't worthwhile. if (GenCollectedHeap::heap()->is_in_reserved(p)) { - oop obj = RawAccess::oop_load(p); - _rs->inline_write_ref_field_gc(p, obj); + _rs->inline_write_ref_field_gc(p); } } @@ -84,7 +83,7 @@ inline void DefNewGeneration::FastKeepAliveClosure::do_oop_work(T* p) { // generation pointer. oop obj = RawAccess::oop_load(p); if ((cast_from_oop(obj) < _boundary) && GenCollectedHeap::heap()->is_in_reserved(p)) { - _rs->inline_write_ref_field_gc(p, obj); + _rs->inline_write_ref_field_gc(p); } } diff --git a/src/hotspot/share/gc/serial/serialHeap.cpp b/src/hotspot/share/gc/serial/serialHeap.cpp index 2eb39ca3612d0..d9a8812d580ed 100644 --- a/src/hotspot/share/gc/serial/serialHeap.cpp +++ b/src/hotspot/share/gc/serial/serialHeap.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -97,6 +97,5 @@ void SerialHeap::young_process_roots(OopIterateClosure* root_closure, process_roots(SO_ScavengeCodeCache, root_closure, cld_closure, cld_closure, &mark_code_closure); - rem_set()->at_younger_refs_iterate(); old_gen()->younger_refs_iterate(old_gen_closure); } diff --git a/src/hotspot/share/gc/shared/c2/cardTableBarrierSetC2.cpp b/src/hotspot/share/gc/shared/c2/cardTableBarrierSetC2.cpp index b39bec32ecd84..be20fbc12ddd6 100644 --- a/src/hotspot/share/gc/shared/c2/cardTableBarrierSetC2.cpp +++ b/src/hotspot/share/gc/shared/c2/cardTableBarrierSetC2.cpp @@ -121,7 +121,7 @@ void CardTableBarrierSetC2::post_barrier(GraphKit* kit, } // Smash zero into card - if(!ct->scanned_concurrently()) { + if (!ct->scanned_concurrently()) { __ store(__ ctrl(), card_adr, zero, T_BYTE, adr_type, MemNode::unordered); } else { // Specialized path for CM store barrier diff --git a/src/hotspot/share/gc/shared/cardGeneration.cpp b/src/hotspot/share/gc/shared/cardGeneration.cpp index f676b84fcb3cc..6bc6e93809e6e 100644 --- a/src/hotspot/share/gc/shared/cardGeneration.cpp +++ b/src/hotspot/share/gc/shared/cardGeneration.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -309,7 +309,7 @@ void CardGeneration::space_iterate(SpaceClosure* blk, void CardGeneration::younger_refs_iterate(OopIterateClosure* blk) { // Apply "cl->do_oop" to (the address of) (exactly) all the ref fields in - // "sp" that point into younger generations. + // "sp" that point into the young generation. // The iteration is only over objects allocated at the start of the // iterations; objects allocated as a result of applying the closure are // not included. diff --git a/src/hotspot/share/gc/shared/cardTableRS.cpp b/src/hotspot/share/gc/shared/cardTableRS.cpp index 164ad47fe5173..cc232960a05ee 100644 --- a/src/hotspot/share/gc/shared/cardTableRS.cpp +++ b/src/hotspot/share/gc/shared/cardTableRS.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,53 +38,8 @@ #include "runtime/os.hpp" #include "utilities/macros.hpp" -CardTable::CardValue CardTableRS::find_unused_youngergenP_card_value() { - for (CardValue v = youngergenP1_card; - v < cur_youngergen_and_prev_nonclean_card; - v++) { - bool seen = false; - for (int g = 0; g < _regions_to_iterate; g++) { - if (_last_cur_val_in_gen[g] == v) { - seen = true; - break; - } - } - if (!seen) { - return v; - } - } - ShouldNotReachHere(); - return 0; -} - -void CardTableRS::prepare_for_younger_refs_iterate(bool parallel) { - // Parallel or sequential, we must always set the prev to equal the - // last one written. - if (parallel) { - // Find a parallel value to be used next. - jbyte next_val = find_unused_youngergenP_card_value(); - set_cur_youngergen_card_val(next_val); - - } else { - // In an sequential traversal we will always write youngergen, so that - // the inline barrier is correct. - set_cur_youngergen_card_val(youngergen_card); - } -} - -void CardTableRS::at_younger_refs_iterate() { - // The indexing in this array is slightly odd. We want to access - // the old generation record here, which is at index 2. - _last_cur_val_in_gen[2] = cur_youngergen_card_val(); -} - inline bool ClearNoncleanCardWrapper::clear_card(CardValue* entry) { - CardValue entry_val = *entry; - assert(entry_val != CardTableRS::clean_card_val(), - "We shouldn't be looking at clean cards, and this should " - "be the only place they get cleaned."); - assert(entry_val != CardTableRS::cur_youngergen_and_prev_nonclean_card, - "This should be possible in the sequential case."); + assert(*entry == CardTableRS::dirty_card_val(), "Only look at dirty cards."); *entry = CardTableRS::clean_card_val(); return true; } @@ -480,58 +435,10 @@ void CardTableRS::verify() { } CardTableRS::CardTableRS(MemRegion whole_heap, bool scanned_concurrently) : - CardTable(whole_heap, scanned_concurrently), - _cur_youngergen_card_val(youngergenP1_card), - // LNC functionality - _lowest_non_clean(NULL), - _lowest_non_clean_chunk_size(NULL), - _lowest_non_clean_base_chunk_index(NULL), - _last_LNC_resizing_collection(NULL) -{ - // max_gens is really GenCollectedHeap::heap()->gen_policy()->number_of_generations() - // (which is always 2, young & old), but GenCollectedHeap has not been initialized yet. - uint max_gens = 2; - _last_cur_val_in_gen = NEW_C_HEAP_ARRAY(CardValue, max_gens + 1, mtGC); - for (uint i = 0; i < max_gens + 1; i++) { - _last_cur_val_in_gen[i] = clean_card_val(); - } -} - -CardTableRS::~CardTableRS() { - FREE_C_HEAP_ARRAY(CardValue, _last_cur_val_in_gen); - FREE_C_HEAP_ARRAY(CardArr, _lowest_non_clean); - FREE_C_HEAP_ARRAY(size_t, _lowest_non_clean_chunk_size); - FREE_C_HEAP_ARRAY(uintptr_t, _lowest_non_clean_base_chunk_index); - FREE_C_HEAP_ARRAY(int, _last_LNC_resizing_collection); -} + CardTable(whole_heap, scanned_concurrently) { } void CardTableRS::initialize() { CardTable::initialize(); - _lowest_non_clean = - NEW_C_HEAP_ARRAY(CardArr, _max_covered_regions, mtGC); - _lowest_non_clean_chunk_size = - NEW_C_HEAP_ARRAY(size_t, _max_covered_regions, mtGC); - _lowest_non_clean_base_chunk_index = - NEW_C_HEAP_ARRAY(uintptr_t, _max_covered_regions, mtGC); - _last_LNC_resizing_collection = - NEW_C_HEAP_ARRAY(int, _max_covered_regions, mtGC); - - for (int i = 0; i < _max_covered_regions; i++) { - _lowest_non_clean[i] = NULL; - _lowest_non_clean_chunk_size[i] = 0; - _last_LNC_resizing_collection[i] = -1; - } -} - -bool CardTableRS::card_will_be_scanned(CardValue cv) { - return card_is_dirty_wrt_gen_iter(cv) || is_prev_nonclean_card_val(cv); -} - -bool CardTableRS::card_may_have_been_dirty(CardValue cv) { - return - cv != clean_card && - (card_is_dirty_wrt_gen_iter(cv) || - CardTableRS::youngergen_may_have_been_dirty(cv)); } void CardTableRS::non_clean_card_iterate(Space* sp, diff --git a/src/hotspot/share/gc/shared/cardTableRS.hpp b/src/hotspot/share/gc/shared/cardTableRS.hpp index b7aa07188bd16..e90ab9e313444 100644 --- a/src/hotspot/share/gc/shared/cardTableRS.hpp +++ b/src/hotspot/share/gc/shared/cardTableRS.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,7 +36,7 @@ class Space; // This RemSet uses a card table both as shared data structure // for a mod ref barrier set and for the rem set information. -class CardTableRS: public CardTable { +class CardTableRS : public CardTable { friend class VMStructs; // Below are private classes used in impl. friend class VerifyCTSpaceClosure; @@ -44,66 +44,16 @@ class CardTableRS: public CardTable { void verify_space(Space* s, HeapWord* gen_start); - enum ExtendedCardValue { - youngergen_card = CT_MR_BS_last_reserved + 1, - // These are for parallel collection. - // There are three P (parallel) youngergen card values. In general, this - // needs to be more than the number of generations (including the perm - // gen) that might have younger_refs_do invoked on them separately. So - // if we add more gens, we have to add more values. - youngergenP1_card = CT_MR_BS_last_reserved + 2, - youngergenP2_card = CT_MR_BS_last_reserved + 3, - youngergenP3_card = CT_MR_BS_last_reserved + 4, - cur_youngergen_and_prev_nonclean_card = - CT_MR_BS_last_reserved + 5 - }; - - // An array that contains, for each generation, the card table value last - // used as the current value for a younger_refs_do iteration of that - // portion of the table. The perm gen is index 0. The young gen is index 1, - // but will always have the value "clean_card". The old gen is index 2. - CardValue* _last_cur_val_in_gen; - - CardValue _cur_youngergen_card_val; - - // Number of generations, plus one for lingering PermGen issues in CardTableRS. - static const int _regions_to_iterate = 3; - - CardValue cur_youngergen_card_val() { - return _cur_youngergen_card_val; - } - void set_cur_youngergen_card_val(CardValue v) { - _cur_youngergen_card_val = v; - } - bool is_prev_youngergen_card_val(CardValue v) { - return - youngergen_card <= v && - v < cur_youngergen_and_prev_nonclean_card && - v != _cur_youngergen_card_val; - } - // Return a youngergen_card_value that is not currently in use. - CardValue find_unused_youngergenP_card_value(); - public: CardTableRS(MemRegion whole_heap, bool scanned_concurrently); - ~CardTableRS(); void younger_refs_in_space_iterate(Space* sp, HeapWord* gen_boundary, OopIterateClosure* cl); virtual void verify_used_region_at_save_marks(Space* sp) const NOT_DEBUG_RETURN; - // Override. - void prepare_for_younger_refs_iterate(bool parallel); - - // Card table entries are cleared before application; - void at_younger_refs_iterate(); - - void inline_write_ref_field_gc(void* field, oop new_val) { + void inline_write_ref_field_gc(void* field) { CardValue* byte = byte_for(field); - *byte = youngergen_card; - } - void write_ref_field_gc_work(void* field, oop new_val) { - inline_write_ref_field_gc(field, new_val); + *byte = dirty_card_val(); } bool is_aligned(HeapWord* addr) { @@ -117,33 +67,6 @@ class CardTableRS: public CardTable { void invalidate_or_clear(Generation* old_gen); - bool is_prev_nonclean_card_val(CardValue v) { - return - youngergen_card <= v && - v <= cur_youngergen_and_prev_nonclean_card && - v != _cur_youngergen_card_val; - } - - static bool youngergen_may_have_been_dirty(CardValue cv) { - return cv == CardTableRS::cur_youngergen_and_prev_nonclean_card; - } - - // *** Support for parallel card scanning. - - // dirty and precleaned are equivalent wrt younger_refs_iter. - static bool card_is_dirty_wrt_gen_iter(CardValue cv) { - return cv == dirty_card; - } - - // Returns "true" iff the value "cv" will cause the card containing it - // to be scanned in the current traversal. May be overridden by - // subtypes. - bool card_will_be_scanned(CardValue cv); - - // Returns "true" iff the value "cv" may have represented a dirty card at - // some point. - bool card_may_have_been_dirty(CardValue cv); - // Iterate over the portion of the card-table which covers the given // region mr in the given space and apply cl to any dirty sub-regions // of mr. Clears the dirty cards as they are processed. @@ -153,18 +76,6 @@ class CardTableRS: public CardTable { OopIterateClosure* cl, CardTableRS* ct); - // This is an array, one element per covered region of the card table. - // Each entry is itself an array, with one element per chunk in the - // covered region. Each entry of these arrays is the lowest non-clean - // card of the corresponding chunk containing part of an object from the - // previous chunk, or else NULL. - typedef CardValue* CardPtr; - typedef CardPtr* CardArr; - CardArr* _lowest_non_clean; - size_t* _lowest_non_clean_chunk_size; - uintptr_t* _lowest_non_clean_base_chunk_index; - volatile int* _last_LNC_resizing_collection; - virtual bool is_in_young(oop obj) const; }; @@ -179,9 +90,6 @@ class ClearNoncleanCardWrapper: public MemRegionClosure { // Clears the given card, return true if the corresponding card should be // processed. inline bool clear_card(CardValue* entry); - // Work methods called by the clear_card() - inline bool clear_card_serial(CardValue* entry); - inline bool clear_card_parallel(CardValue* entry); // check alignment of pointer bool is_word_aligned(CardValue* entry); diff --git a/src/hotspot/share/gc/shared/genOopClosures.inline.hpp b/src/hotspot/share/gc/shared/genOopClosures.inline.hpp index 231ffe37770b7..da85dd1db4225 100644 --- a/src/hotspot/share/gc/shared/genOopClosures.inline.hpp +++ b/src/hotspot/share/gc/shared/genOopClosures.inline.hpp @@ -82,7 +82,7 @@ void DefNewYoungerGenClosure::barrier(T* p) { oop obj = CompressedOops::decode_not_null(heap_oop); // If p points to a younger generation, mark the card. if (cast_from_oop(obj) < _old_gen_start) { - _rs->inline_write_ref_field_gc(p, obj); + _rs->inline_write_ref_field_gc(p); } } diff --git a/src/hotspot/share/gc/shared/vmStructs_gc.hpp b/src/hotspot/share/gc/shared/vmStructs_gc.hpp index 85741a05f6158..3fda88c4b4eaa 100644 --- a/src/hotspot/share/gc/shared/vmStructs_gc.hpp +++ b/src/hotspot/share/gc/shared/vmStructs_gc.hpp @@ -279,8 +279,6 @@ declare_constant(CardTable::card_size) \ declare_constant(CardTable::card_size_in_words) \ \ - declare_constant(CardTableRS::youngergen_card) \ - \ declare_constant(CollectedHeap::Serial) \ declare_constant(CollectedHeap::Parallel) \ declare_constant(CollectedHeap::G1) \ From 07918995da1d21e0c3458b0fe318a95b9ff77104 Mon Sep 17 00:00:00 2001 From: Claes Redestad Date: Fri, 5 Feb 2021 08:58:32 +0000 Subject: [PATCH 73/77] 8261154: Memory leak in Java_java_lang_ClassLoader_defineClass0 with long class names Reviewed-by: stuefe, chegar, mchung --- .../share/native/libjava/ClassLoader.c | 3 + .../java/lang/invoke/LookupDefineClass.java | 76 +++++++++++++++++++ 2 files changed, 79 insertions(+) diff --git a/src/java.base/share/native/libjava/ClassLoader.c b/src/java.base/share/native/libjava/ClassLoader.c index 021a5a191eb13..5f556ff902c04 100644 --- a/src/java.base/share/native/libjava/ClassLoader.c +++ b/src/java.base/share/native/libjava/ClassLoader.c @@ -262,6 +262,9 @@ Java_java_lang_ClassLoader_defineClass0(JNIEnv *env, result = JVM_LookupDefineClass(env, lookup, utfName, body, length, pd, initialize, flags, classData); + if (utfName && utfName != buf) + free(utfName); + free_body: free(body); return result; diff --git a/test/micro/org/openjdk/bench/java/lang/invoke/LookupDefineClass.java b/test/micro/org/openjdk/bench/java/lang/invoke/LookupDefineClass.java index 5ae02aa204d27..3b9cbaa0b0762 100644 --- a/test/micro/org/openjdk/bench/java/lang/invoke/LookupDefineClass.java +++ b/test/micro/org/openjdk/bench/java/lang/invoke/LookupDefineClass.java @@ -37,6 +37,9 @@ import static java.lang.invoke.MethodHandles.Lookup.ClassOption.*; public class LookupDefineClass { + /** + * foo.Foo + */ private static final byte[] X_BYTECODE = new byte[]{ (byte)0xCA, (byte)0xFE, (byte)0xBA, (byte)0xBE, 0x00, 0x00, 0x00, 0x38, 0x00, 0x10, 0x0A, 0x00, 0x03, 0x00, 0x0C, 0x07, 0x00, 0x0D, 0x07, 0x00, 0x0E, 0x07, 0x00, 0x0F, @@ -62,6 +65,61 @@ public class LookupDefineClass { 0x02, 0x00, 0x0B }; + /** + * A variant of X_BYTECODE, with the class name rewritten to trigger malloc in ClassLoader.c + * + * ClassReader reader = new ClassReader(X_BYTECODE); + * ClassWriter writer = new ClassWriter(reader, 0); + * reader.accept(new ClassVisitor(Opcodes.ASM5, writer) { + * @Override + * public void visit(int version, int access, String name, + * String signature, String superName, String[] interfaces) { + * super.visit(version, access, + * "foo/AReallyReallyLongClassNameThatWillSurelyNotFitInACharBufferOfLength128ToTestThatWeDontLeakMemoryWhenTheClassNameIsTooLongForTheStackAllocatedBuffer", + * signature, superName, interfaces); + * } + * }, 0); + * byte[] code = writer.toByteArray(); + * System.out.println(HexFormat.ofDelimiter(", ").withPrefix("0x").formatHex(code)); + */ + private static final byte[] X_LONG_NAME_BYTECODE = new byte[]{ + (byte)0xca, (byte)0xfe, (byte)0xba, (byte)0xbe, 0x00, 0x00, 0x00, 0x38, 0x00, 0x12, 0x0a, 0x00, + 0x03, 0x00, 0x0c, 0x07, 0x00, 0x0d, 0x07, 0x00, 0x0e, 0x07, 0x00, 0x0f, + 0x01, 0x00, 0x06, 0x3c, 0x69, 0x6e, 0x69, 0x74, 0x3e, 0x01, 0x00, 0x03, + 0x28, 0x29, 0x56, 0x01, 0x00, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x01, 0x00, + 0x0f, 0x4c, 0x69, 0x6e, 0x65, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x54, + 0x61, 0x62, 0x6c, 0x65, 0x01, 0x00, 0x03, 0x72, 0x75, 0x6e, 0x01, 0x00, + 0x0a, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x46, 0x69, 0x6c, 0x65, 0x01, + 0x00, 0x08, 0x46, 0x6f, 0x6f, 0x2e, 0x6a, 0x61, 0x76, 0x61, 0x0c, 0x00, + 0x05, 0x00, 0x06, 0x01, 0x00, 0x07, 0x66, 0x6f, 0x6f, 0x2f, 0x46, 0x6f, + 0x6f, 0x01, 0x00, 0x10, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, + 0x67, 0x2f, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x01, 0x00, 0x12, 0x6a, + 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x52, 0x75, 0x6e, + 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x01, 0x00, (byte)0x97, 0x66, 0x6f, 0x6f, 0x2f, + 0x41, 0x52, 0x65, 0x61, 0x6c, 0x6c, 0x79, 0x52, 0x65, 0x61, 0x6c, 0x6c, + 0x79, 0x4c, 0x6f, 0x6e, 0x67, 0x43, 0x6c, 0x61, 0x73, 0x73, 0x4e, 0x61, + 0x6d, 0x65, 0x54, 0x68, 0x61, 0x74, 0x57, 0x69, 0x6c, 0x6c, 0x53, 0x75, + 0x72, 0x65, 0x6c, 0x79, 0x4e, 0x6f, 0x74, 0x46, 0x69, 0x74, 0x49, 0x6e, + 0x41, 0x43, 0x68, 0x61, 0x72, 0x42, 0x75, 0x66, 0x66, 0x65, 0x72, 0x4f, + 0x66, 0x4c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x31, 0x32, 0x38, 0x54, 0x6f, + 0x54, 0x65, 0x73, 0x74, 0x54, 0x68, 0x61, 0x74, 0x57, 0x65, 0x44, 0x6f, + 0x6e, 0x74, 0x4c, 0x65, 0x61, 0x6b, 0x4d, 0x65, 0x6d, 0x6f, 0x72, 0x79, + 0x57, 0x68, 0x65, 0x6e, 0x54, 0x68, 0x65, 0x43, 0x6c, 0x61, 0x73, 0x73, + 0x4e, 0x61, 0x6d, 0x65, 0x49, 0x73, 0x54, 0x6f, 0x6f, 0x4c, 0x6f, 0x6e, + 0x67, 0x46, 0x6f, 0x72, 0x54, 0x68, 0x65, 0x53, 0x74, 0x61, 0x63, 0x6b, + 0x41, 0x6c, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x65, 0x64, 0x42, 0x75, 0x66, + 0x66, 0x65, 0x72, 0x07, 0x00, 0x10, 0x00, 0x21, 0x00, 0x11, 0x00, 0x03, + 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x01, 0x00, 0x05, + 0x00, 0x06, 0x00, 0x01, 0x00, 0x07, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x01, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x05, 0x2a, (byte)0xb7, 0x00, 0x01, (byte)0xb1, 0x00, + 0x00, 0x00, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x01, 0x00, + 0x00, 0x00, 0x03, 0x00, 0x01, 0x00, 0x09, 0x00, 0x06, 0x00, 0x01, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x01, (byte)0xb1, 0x00, 0x00, 0x00, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, 0x06, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x01, 0x00, 0x0a, 0x00, 0x00, + 0x00, 0x02, 0x00, 0x0b + }; + /** * Our own crippled classloader, that can only load a simple class over and over again. */ @@ -207,6 +265,15 @@ public Class load() throws ClassNotFoundException { } } + @Benchmark + public Class loadLongName() throws ClassNotFoundException { + try { + return HOST_LOOKUP.defineHiddenClass(X_LONG_NAME_BYTECODE, false).lookupClass(); + } catch (IllegalAccessException e) { + throw new InternalError(e); + } + } + public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(LookupDefineClass.WeakClass.class.getSimpleName()) @@ -276,6 +343,15 @@ public Class load() throws ClassNotFoundException { } } + @Benchmark + public Class loadLongName() throws ClassNotFoundException { + try { + return HOST_LOOKUP.defineHiddenClass(X_LONG_NAME_BYTECODE, false, STRONG).lookupClass(); + } catch (IllegalAccessException e) { + throw new InternalError(e); + } + } + public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(LookupDefineClass.HiddenClass.class.getSimpleName()) From 3495febf51d91236b1795e1088181ad91a3d9b9f Mon Sep 17 00:00:00 2001 From: Roland Westrelin Date: Fri, 5 Feb 2021 09:33:54 +0000 Subject: [PATCH 74/77] 8260296: SA's dumpreplaydata fails Reviewed-by: kvn, cjplummer, iignatyev --- src/hotspot/share/ci/ciMetadata.cpp | 5 +- src/hotspot/share/ci/ciMetadata.hpp | 4 +- src/hotspot/share/oops/methodData.cpp | 2 +- src/hotspot/share/runtime/vmStructs.cpp | 2 +- .../sun/jvm/hotspot/ci/ciMethodData.java | 16 ++-- .../sun/jvm/hotspot/oops/DataLayout.java | 7 +- .../sun/jvm/hotspot/oops/MethodData.java | 6 +- .../sun/jvm/hotspot/oops/ProfileData.java | 4 +- .../sun/jvm/hotspot/oops/TypeEntries.java | 8 +- .../jtreg/compiler/ciReplay/CiReplayBase.java | 88 ++++++------------- .../jtreg/compiler/ciReplay/SABase.java | 63 ++++++++++--- .../jtreg/compiler/ciReplay/VMBase.java | 4 +- .../serviceability/sa/ClhsdbCDSCore.java | 4 +- .../jtreg/serviceability/sa/ClhsdbFindPC.java | 4 +- .../jtreg/serviceability/sa/ClhsdbPmap.java | 4 +- .../jtreg/serviceability/sa/ClhsdbPstack.java | 4 +- .../jtreg/serviceability/sa/TestJmapCore.java | 6 +- .../jdk/test/lib/process/OutputAnalyzer.java | 11 ++- .../jdk/test/lib/process/OutputBuffer.java | 19 +++- test/lib/jdk/test/lib/util/CoreUtils.java | 31 ++++++- 20 files changed, 173 insertions(+), 119 deletions(-) diff --git a/src/hotspot/share/ci/ciMetadata.cpp b/src/hotspot/share/ci/ciMetadata.cpp index 9bffeadf9e875..f0d1fcf4357e0 100644 --- a/src/hotspot/share/ci/ciMetadata.cpp +++ b/src/hotspot/share/ci/ciMetadata.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,9 @@ #include "ci/ciUtilities.inline.hpp" #include "gc/shared/collectedHeap.inline.hpp" +// Not inlined to preserve visibility of ciMetaData vtable symbol. Required by SA. +bool ciMetadata::is_classless() const { return false; } + // ------------------------------------------------------------------ // ciMetadata::print // diff --git a/src/hotspot/share/ci/ciMetadata.hpp b/src/hotspot/share/ci/ciMetadata.hpp index a0b7b38cd72e4..dcf01b692dd6e 100644 --- a/src/hotspot/share/ci/ciMetadata.hpp +++ b/src/hotspot/share/ci/ciMetadata.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -43,7 +43,7 @@ class ciMetadata: public ciBaseObject { ciMetadata(): _metadata(NULL) {} ciMetadata(Metadata* o): _metadata(o) {} - virtual bool is_classless() const { return false; } + virtual bool is_classless() const; public: bool is_loaded() const { return _metadata != NULL || is_classless(); } diff --git a/src/hotspot/share/oops/methodData.cpp b/src/hotspot/share/oops/methodData.cpp index b97bd2168829d..54aa8ec0a4edb 100644 --- a/src/hotspot/share/oops/methodData.cpp +++ b/src/hotspot/share/oops/methodData.cpp @@ -1256,7 +1256,7 @@ void MethodData::initialize() { object_size += extra_size + arg_data_size; int parms_cell = ParametersTypeData::compute_cell_count(method()); - // If we are profiling parameters, we reserver an area near the end + // If we are profiling parameters, we reserved an area near the end // of the MDO after the slots for bytecodes (because there's no bci // for method entry so they don't fit with the framework for the // profiling of bytecodes). We store the offset within the MDO of diff --git a/src/hotspot/share/runtime/vmStructs.cpp b/src/hotspot/share/runtime/vmStructs.cpp index 46c4811dd5042..f4741b1fae134 100644 --- a/src/hotspot/share/runtime/vmStructs.cpp +++ b/src/hotspot/share/runtime/vmStructs.cpp @@ -261,7 +261,7 @@ typedef HashtableEntry KlassHashtableEntry; nonstatic_field(Klass, _java_mirror, OopHandle) \ nonstatic_field(Klass, _modifier_flags, jint) \ nonstatic_field(Klass, _super, Klass*) \ - volatile_nonstatic_field(Klass, _subklass, Klass*) \ + volatile_nonstatic_field(Klass, _subklass, Klass*) \ nonstatic_field(Klass, _layout_helper, jint) \ nonstatic_field(Klass, _name, Symbol*) \ nonstatic_field(Klass, _access_flags, AccessFlags) \ diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ci/ciMethodData.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ci/ciMethodData.java index 873d7f4f7e63b..2bad7f97a3e67 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ci/ciMethodData.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ci/ciMethodData.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,6 +30,7 @@ import sun.jvm.hotspot.runtime.*; import sun.jvm.hotspot.oops.*; import sun.jvm.hotspot.types.*; +import sun.jvm.hotspot.types.Field; import sun.jvm.hotspot.utilities.Observable; import sun.jvm.hotspot.utilities.Observer; @@ -44,7 +45,7 @@ public void update(Observable o, Object data) { private static synchronized void initialize(TypeDataBase db) throws WrongTypeException { Type type = db.lookupType("ciMethodData"); - origField = type.getAddressField("_orig"); + origField = type.getField("_orig"); currentMileageField = new CIntField(type.getCIntegerField("_current_mileage"), 0); argReturnedField = new CIntField(type.getCIntegerField("_arg_returned"), 0); argStackField = new CIntField(type.getCIntegerField("_arg_stack"), 0); @@ -61,7 +62,7 @@ private static synchronized void initialize(TypeDataBase db) throws WrongTypeExc parametersTypeDataDi = new CIntField(typeMethodData.getCIntegerField("_parameters_type_data_di"), 0); } - private static AddressField origField; + private static Field origField; private static CIntField currentMileageField; private static CIntField argReturnedField; private static CIntField argStackField; @@ -106,8 +107,8 @@ private byte[] fetchDataAt(Address base, long size) { public byte[] orig() { // fetch the orig MethodData data between header and dataSize Address base = getAddress().addOffsetTo(origField.getOffset()); - byte[] result = new byte[MethodData.sizeofMethodDataOopDesc]; - for (int i = 0; i < MethodData.sizeofMethodDataOopDesc; i++) { + byte[] result = new byte[(int)origField.getType().getSize()]; + for (int i = 0; i < result.length; i++) { result[i] = base.getJByteAt(i); } return result; @@ -116,7 +117,7 @@ public byte[] orig() { public long[] data() { // Read the data as an array of intptr_t elements Address base = dataField.getValue(getAddress()); - int elements = dataSize() / MethodData.cellSize; + int elements = (dataSize() + extraDataSize()) / MethodData.cellSize; long[] result = new long[elements]; for (int i = 0; i < elements; i++) { Address value = base.getAddressAt(i * MethodData.cellSize); @@ -148,8 +149,7 @@ boolean outOfBounds(int dataIndex) { } ParametersTypeData parametersTypeData() { - Address base = getAddress().addOffsetTo(origField.getOffset()); - int di = (int)parametersTypeDataDi.getValue(base); + int di = (int)parametersTypeDataDi.getValue(getMetadata().getAddress()); if (di == -1 || di == -2) { return null; } diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/DataLayout.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/DataLayout.java index d55fdbc402caf..3c3630cb0e68d 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/DataLayout.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/DataLayout.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -81,9 +81,8 @@ private int getU22(int at) { return data.getJShortAt(offset + at) & 0xffff; } - int cellAt(int index) { - // Cells are intptr_t sized but only contain ints as raw values - return (int)data.getCIntegerAt(offset + cellOffset(index), MethodData.cellSize, false); + long cellAt(int index) { + return data.getCIntegerAt(offset + cellOffset(index), MethodData.cellSize, false); } public Address addressAt(int index) { diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/MethodData.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/MethodData.java index ea92fa56973f3..68d7808c196dd 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/MethodData.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/MethodData.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -234,8 +234,8 @@ public void printValueOn(PrintStream tty) { public void iterateFields(MetadataVisitor visitor) { super.iterateFields(visitor); visitor.doMetadata(method, true); - visitor.doCInt(size, true); - } + visitor.doCInt(size, true); + } int dataSize() { if (dataSize == null) { diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ProfileData.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ProfileData.java index dce1b839d1c21..29a127b6a495b 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ProfileData.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ProfileData.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -51,7 +51,7 @@ public int dp() { } // Low-level accessors for underlying data - int intptrAt(int index) { + long intptrAt(int index) { //assert(0 <= index && index < cellCount(), "oob"); return data().cellAt(index); } diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/TypeEntries.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/TypeEntries.java index 8b791b5f938e5..16ba553a83838 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/TypeEntries.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/TypeEntries.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -48,17 +48,17 @@ public abstract class TypeEntries { final MethodDataInterface methodData; boolean wasNullSeen(int index) { - int v = pd.intptrAt(index); + long v = pd.intptrAt(index); return (v & nullSeen) != 0; } boolean isTypeUnknown(int index) { - int v = pd.intptrAt(index); + long v = pd.intptrAt(index); return (v & typeUnknown) != 0; } boolean isTypeNone(int index) { - int v = pd.intptrAt(index); + long v = pd.intptrAt(index); return (v & typeMask) == 0; } diff --git a/test/hotspot/jtreg/compiler/ciReplay/CiReplayBase.java b/test/hotspot/jtreg/compiler/ciReplay/CiReplayBase.java index 7d39496831abb..68313ca2cacfc 100644 --- a/test/hotspot/jtreg/compiler/ciReplay/CiReplayBase.java +++ b/test/hotspot/jtreg/compiler/ciReplay/CiReplayBase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -43,6 +43,7 @@ import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.Asserts; import jdk.test.lib.Utils; +import jdk.test.lib.util.CoreUtils; public abstract class CiReplayBase { public static final String REPLAY_FILE_NAME = "test_replay.txt"; @@ -65,17 +66,27 @@ public abstract class CiReplayBase { "-XX:MetaspaceSize=4m", "-XX:MaxMetaspaceSize=16m", "-XX:InitialCodeCacheSize=512k", "-XX:ReservedCodeCacheSize=4m", "-XX:ThreadStackSize=512", "-XX:VMThreadStackSize=512", "-XX:CompilerThreadStackSize=512", "-XX:ParallelGCThreads=1", "-XX:CICompilerCount=2", - "-Xcomp", "-XX:CICrashAt=1", "-XX:+DumpReplayDataOnError", - "-XX:+PreferInterpreterNativeStubs", "-XX:+PrintCompilation", REPLAY_FILE_OPTION}; + "-XX:-BackgroundCompilation", "-XX:CompileCommand=inline,java.io.PrintStream::*", + "-XX:+IgnoreUnrecognizedVMOptions", "-XX:TypeProfileLevel=222", // extra profile data as a stress test + "-XX:CICrashAt=1", "-XX:+DumpReplayDataOnError", + "-XX:+PreferInterpreterNativeStubs", REPLAY_FILE_OPTION}; private static final String[] REPLAY_OPTIONS = new String[]{DISABLE_COREDUMP_ON_CRASH, + "-XX:+IgnoreUnrecognizedVMOptions", "-XX:TypeProfileLevel=222", "-XX:+ReplayCompiles", REPLAY_FILE_OPTION}; protected final Optional runServer; private static int dummy; public static class TestMain { public static void main(String[] args) { - // Do something because empty methods might not be called/compiled. - dummy = 42; + for (int i = 0; i < 20_000; i++) { + test(i); + } + } + + static void test(int i) { + if ((i % 1000) == 0) { + System.out.println("Hello World!"); + } } } @@ -103,7 +114,7 @@ public CiReplayBase(String args[]) { public void runTest(boolean needCoreDump, String... args) { cleanup(); - if (generateReplay(needCoreDump)) { + if (generateReplay(needCoreDump, args)) { testAction(); cleanup(); } else { @@ -143,11 +154,16 @@ public boolean generateReplay(boolean needCoreDump, String... vmopts) { options.addAll(Arrays.asList(REPLAY_GENERATION_OPTIONS)); options.addAll(Arrays.asList(vmopts)); options.add(needCoreDump ? ENABLE_COREDUMP_ON_CRASH : DISABLE_COREDUMP_ON_CRASH); - options.add(TestMain.class.getName()); if (needCoreDump) { - crashOut = ProcessTools.executeProcess(getTestJvmCommandlineWithPrefix( - RUN_SHELL_NO_LIMIT, options.toArray(new String[0]))); + // CiReplayBase$TestMain needs to be quoted because of shell eval + options.add("-XX:CompileOnly='" + TestMain.class.getName() + "::test'"); + options.add("'" + TestMain.class.getName() + "'"); + crashOut = ProcessTools.executeProcess( + CoreUtils.addCoreUlimitCommand( + ProcessTools.createTestJvm(options.toArray(new String[0])))); } else { + options.add("-XX:CompileOnly=" + TestMain.class.getName() + "::test"); + options.add(TestMain.class.getName()); crashOut = ProcessTools.executeProcess(ProcessTools.createTestJvm(options)); } crashOutputString = crashOut.getOutput(); @@ -159,18 +175,8 @@ public boolean generateReplay(boolean needCoreDump, String... vmopts) { throw new Error("Can't create replay: " + t, t); } if (needCoreDump) { - String coreFileLocation = getCoreFileLocation(crashOutputString); - if (coreFileLocation == null) { - if (Platform.isOSX()) { - File coresDir = new File("/cores"); - if (!coresDir.isDirectory() || !coresDir.canWrite()) { - return false; - } - } - throw new Error("Couldn't find core file location in: '" + crashOutputString + "'"); - } try { - Asserts.assertGT(new File(coreFileLocation).length(), 0L, "Unexpected core size"); + String coreFileLocation = CoreUtils.getCoreFileLocation(crashOutputString, crashOut.pid()); Files.move(Paths.get(coreFileLocation), Paths.get(TEST_CORE_FILE_NAME)); } catch (IOException ioe) { throw new Error("Can't move core file: " + ioe, ioe); @@ -250,48 +256,6 @@ public void nonTieredTests(int compLevel) { } } - // lets search few possible locations using process output and return existing location - private String getCoreFileLocation(String crashOutputString) { - Asserts.assertTrue(crashOutputString.contains(LOCATIONS_STRING), - "Output doesn't contain the location of core file, see crash.out"); - String stringWithLocation = Arrays.stream(crashOutputString.split("\\r?\\n")) - .filter(str -> str.contains(LOCATIONS_STRING)) - .findFirst() - .get(); - stringWithLocation = stringWithLocation.substring(stringWithLocation - .indexOf(LOCATIONS_STRING) + LOCATIONS_STRING.length()); - String coreWithPid; - if (stringWithLocation.contains("or ") && !Platform.isWindows()) { - Matcher m = Pattern.compile("or.* ([^ ]+[^\\)])\\)?").matcher(stringWithLocation); - if (!m.find()) { - throw new Error("Couldn't find path to core inside location string"); - } - coreWithPid = m.group(1); - } else { - coreWithPid = stringWithLocation.trim(); - } - if (new File(coreWithPid).exists()) { - return coreWithPid; - } - String justCore = Paths.get("core").toString(); - if (new File(justCore).exists()) { - return justCore; - } - Path coreWithPidPath = Paths.get(coreWithPid); - String justFile = coreWithPidPath.getFileName().toString(); - if (new File(justFile).exists()) { - return justFile; - } - Path parent = coreWithPidPath.getParent(); - if (parent != null) { - String coreWithoutPid = parent.resolve("core").toString(); - if (new File(coreWithoutPid).exists()) { - return coreWithoutPid; - } - } - return null; - } - private String[] getTestJvmCommandlineWithPrefix(String prefix, String... args) { try { String cmd = ProcessTools.getCommandLine(ProcessTools.createTestJvm(args)); diff --git a/test/hotspot/jtreg/compiler/ciReplay/SABase.java b/test/hotspot/jtreg/compiler/ciReplay/SABase.java index 405b9f104d14c..db576d73631d9 100644 --- a/test/hotspot/jtreg/compiler/ciReplay/SABase.java +++ b/test/hotspot/jtreg/compiler/ciReplay/SABase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,8 @@ import java.nio.file.Files; import java.nio.file.Paths; +import java.io.BufferedReader; +import java.io.FileReader; import java.io.IOException; import java.io.File; import java.io.FileInputStream; @@ -41,7 +43,19 @@ public class SABase extends CiReplayBase { public static void main(String args[]) throws Exception { checkSetLimits(); - new SABase(args).runTest(/* needCoreDump = */ true, args); + SABase base = new SABase(args); + boolean c2 = base.runServer.orElseThrow(() -> new Error("runServer must be set")); + String[] extra = {}; + if (Platform.isTieredSupported()) { + if (c2) { + // Replay produced on first compilation. We want that + // compilation delayed so profile data is produced. + extra = new String[] {"-XX:-TieredCompilation"}; + } else { + extra = new String[] {"-XX:TieredStopAtLevel=1"}; + } + } + base.runTest(/* needCoreDump = */ true, extra); } public SABase(String[] args) { @@ -96,19 +110,42 @@ public void testAction() { File replay = new File(REPLAY_FILE_NAME); Asserts.assertTrue(replay.exists() && replay.isFile() && replay.length() > 0, "Replay data wasn't generated by SA"); + // other than comment lines, content of 2 files should be identical try { - FileInputStream rep = new FileInputStream(replay); - FileInputStream repCopy = new FileInputStream(REPLAY_FILE_COPY); - byte repBuffer[] = new byte[512]; - byte repCopyBuffer[] = new byte[512]; - boolean filesNotEqual = false; - while(rep.available() > 0 && !filesNotEqual) { - int count = rep.read(repBuffer); - int count2 = repCopy.read(repCopyBuffer); - filesNotEqual = count != count2 || Arrays.equals(repBuffer, repCopyBuffer); + BufferedReader rep = new BufferedReader(new FileReader(replay)); + BufferedReader repCopy = new BufferedReader(new FileReader(REPLAY_FILE_COPY)); + boolean failure = false; + while (true) { + String l1; + while ((l1 = rep.readLine()) != null) { + if (!l1.startsWith("#")) { + break; + } + } + String l2; + while ((l2 = repCopy.readLine()) != null) { + if (!l2.startsWith("#")) { + break; + } + } + if (l1 == null || l2 == null) { + if (l1 != null || l2 != null) { + System.out.println("Warning: replay files are not equal"); + System.out.println("1: " + l1); + System.out.println("2: " + l2); + failure = true; + } + break; + } + if (!l1.equals(l2)) { + System.out.println("Warning: replay files are not equal"); + System.out.println("1: " + l1); + System.out.println("2: " + l2); + failure = true; + } } - if (filesNotEqual) { - System.out.println("Warning: replay files are not equal"); + if (failure) { + throw new RuntimeException("Warning: replay files are not equal"); } } catch (IOException ioe) { throw new Error("Can't read replay files: " + ioe, ioe); diff --git a/test/hotspot/jtreg/compiler/ciReplay/VMBase.java b/test/hotspot/jtreg/compiler/ciReplay/VMBase.java index c8ca9d0846968..a4271fada1583 100644 --- a/test/hotspot/jtreg/compiler/ciReplay/VMBase.java +++ b/test/hotspot/jtreg/compiler/ciReplay/VMBase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,7 +30,7 @@ public class VMBase extends CiReplayBase { public static void main(String args[]) { - new VMBase(args).runTest(/* needCoreDump = */ false, args); + new VMBase(args).runTest(/* needCoreDump = */ false); } public VMBase(String[] args) { diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbCDSCore.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbCDSCore.java index 2d0013250b61d..f16228cf15b65 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbCDSCore.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbCDSCore.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -98,7 +98,7 @@ public static void main(String[] args) throws Exception { } try { - coreFileName = CoreUtils.getCoreFileLocation(crashOutput.getStdout()); + coreFileName = CoreUtils.getCoreFileLocation(crashOutput.getStdout(), crashOutput.pid()); } catch (Exception e) { cleanup(); throw e; diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbFindPC.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbFindPC.java index 0a333e753d3ae..6b10d800a8ca9 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbFindPC.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbFindPC.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -99,7 +99,7 @@ private static void testFindPC(boolean withXcomp, boolean withCore) throws Excep // Get the core file name if we are debugging a core instead of live process if (withCore) { - coreFileName = CoreUtils.getCoreFileLocation(theApp.getOutput().getStdout()); + coreFileName = CoreUtils.getCoreFileLocation(theApp.getOutput().getStdout(), theApp.getPid()); } // Run 'jstack -v' command to get the findpc address diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbPmap.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbPmap.java index 54e732af76c09..6f0023a21e96d 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbPmap.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbPmap.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -65,7 +65,7 @@ public static void main(String[] args) throws Exception { if (withCore) { String crashOutput = theApp.getOutput().getStdout(); - coreFileName = CoreUtils.getCoreFileLocation(crashOutput); + coreFileName = CoreUtils.getCoreFileLocation(crashOutput, theApp.getPid()); } List cmds = List.of("pmap"); diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbPstack.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbPstack.java index 5eb162f958509..e4101a8c372f6 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbPstack.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbPstack.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -65,7 +65,7 @@ public static void main(String[] args) throws Exception { if (withCore) { String crashOutput = theApp.getOutput().getStdout(); - coreFileName = CoreUtils.getCoreFileLocation(crashOutput); + coreFileName = CoreUtils.getCoreFileLocation(crashOutput, theApp.getPid()); } List cmds = List.of("pstack -v"); diff --git a/test/hotspot/jtreg/serviceability/sa/TestJmapCore.java b/test/hotspot/jtreg/serviceability/sa/TestJmapCore.java index 662d55a7421b2..1c861f8c6015d 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestJmapCore.java +++ b/test/hotspot/jtreg/serviceability/sa/TestJmapCore.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -77,9 +77,9 @@ static void test(String type) throws Throwable { // If we are going to force a core dump, apply "ulimit -c unlimited" if we can. pb = CoreUtils.addCoreUlimitCommand(pb); - OutputAnalyzer output = ProcessTools.executeProcess(pb); + OutputAnalyzer output = ProcessTools.executeProcess(pb); - String coreFileName = CoreUtils.getCoreFileLocation(output.getStdout()); + String coreFileName = CoreUtils.getCoreFileLocation(output.getStdout(), output.pid()); File core = new File(coreFileName); File dumpFile = new File("heap.hprof"); JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jhsdb"); diff --git a/test/lib/jdk/test/lib/process/OutputAnalyzer.java b/test/lib/jdk/test/lib/process/OutputAnalyzer.java index 9860eb83b0379..59a30533eafa3 100644 --- a/test/lib/jdk/test/lib/process/OutputAnalyzer.java +++ b/test/lib/jdk/test/lib/process/OutputAnalyzer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -566,6 +566,15 @@ public int getExitValue() { return buffer.getExitValue(); } + /** + * Get the process' pid + * + * @return pid + */ + public long pid() { + return buffer.pid(); + } + /** * Get the contents of the output buffer (stdout and stderr) as list of strings. * Output will be split by newlines. diff --git a/test/lib/jdk/test/lib/process/OutputBuffer.java b/test/lib/jdk/test/lib/process/OutputBuffer.java index 7adee6561bc75..3741ccbe2ff62 100644 --- a/test/lib/jdk/test/lib/process/OutputBuffer.java +++ b/test/lib/jdk/test/lib/process/OutputBuffer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -69,6 +69,13 @@ default public List getStdoutAsList() { public String getStderr(); public int getExitValue(); + /** + * Returns the pid if available + * + * @return pid + */ + public long pid(); + public static OutputBuffer of(Process p, Charset cs) { return new LazyOutputBuffer(p, cs); } @@ -157,6 +164,11 @@ public int getExitValue() { throw new OutputBufferException(e); } } + + @Override + public long pid() { + return p.pid(); + } } class EagerOutputBuffer implements OutputBuffer { @@ -184,5 +196,10 @@ public String getStderr() { public int getExitValue() { return exitValue; } + + @Override + public long pid() { + throw new RuntimeException("no process"); + } } } diff --git a/test/lib/jdk/test/lib/util/CoreUtils.java b/test/lib/jdk/test/lib/util/CoreUtils.java index cfff57bfd52c1..d7e68e82f427e 100644 --- a/test/lib/jdk/test/lib/util/CoreUtils.java +++ b/test/lib/jdk/test/lib/util/CoreUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -101,7 +101,7 @@ public static ProcessBuilder addCoreUlimitCommand(ProcessBuilder pb) { * @param crashOutputString {@code String} to search in for the core file path * @return Location of core file if found in the output, otherwise {@code null}. */ - public static String getCoreFileLocation(String crashOutputString) throws IOException { + public static String getCoreFileLocation(String crashOutputString, long pid) throws IOException { unzipCores(new File(".")); // Find the core file @@ -124,7 +124,8 @@ public static String getCoreFileLocation(String crashOutputString) throws IOExce return coreFileLocation; // success! } - // See if we can figure out the likely reason the core file was not found. + // See if we can figure out the likely reason the core file was not found. Recover from + // failure if possible. // Throw SkippedException if appropriate. if (Platform.isOSX()) { File coresDir = new File("/cores"); @@ -152,6 +153,30 @@ public static String getCoreFileLocation(String crashOutputString) throws IOExce line = line.trim(); System.out.println(line); if (line.startsWith("|")) { + if (line.split("\s", 2)[0].endsWith("systemd-coredump")) { + // A systemd linux system. Try to retrieve core + // file. It can take a few seconds for the system to + // process the just produced core file so we may need to + // retry a few times. + System.out.println("Running systemd-coredump: trying coredumpctl command"); + String core = "core"; + try { + for (int i = 0; i < 10; i++) { + Thread.sleep(5000); + OutputAnalyzer out = ProcessTools.executeProcess("coredumpctl", "dump", "-1", "-o", core, String.valueOf(pid)); + if (!out.getOutput().contains("output may be incomplete")) { + break; + } + } + } catch(Throwable t) { + } + final File coreFile = new File(core); + if (coreFile.exists()) { + Asserts.assertGT(coreFile.length(), 0L, "Unexpected core size"); + System.out.println("coredumpctl succeeded"); + return core; + } + } System.out.println( "\nThis system uses a crash report tool ($cat /proc/sys/kernel/core_pattern).\n" + "Core files might not be generated. Please reset /proc/sys/kernel/core_pattern\n" + From 224c166c308c4e24a16a21e11729fec0f0aa51a0 Mon Sep 17 00:00:00 2001 From: Kim Barrett Date: Fri, 5 Feb 2021 10:18:51 +0000 Subject: [PATCH 75/77] 8261213: [BACKOUT] MutableSpace's end should be atomic Reviewed-by: tschatzl, ayang --- .../share/gc/parallel/mutableSpace.hpp | 27 +++++++++---------- .../gc/parallel/parallelScavengeHeap.hpp | 3 +++ src/hotspot/share/gc/parallel/psYoungGen.hpp | 3 +++ .../gc/parallel/vmStructs_parallelgc.hpp | 2 +- 4 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/hotspot/share/gc/parallel/mutableSpace.hpp b/src/hotspot/share/gc/parallel/mutableSpace.hpp index 33253642983a4..3e9b0a1514c82 100644 --- a/src/hotspot/share/gc/parallel/mutableSpace.hpp +++ b/src/hotspot/share/gc/parallel/mutableSpace.hpp @@ -28,7 +28,6 @@ #include "memory/allocation.hpp" #include "memory/iterator.hpp" #include "memory/memRegion.hpp" -#include "runtime/atomic.hpp" #include "utilities/copy.hpp" #include "utilities/globalDefinitions.hpp" #include "utilities/macros.hpp" @@ -43,6 +42,9 @@ class WorkGang; // page allocation time by having the memory pretouched (with // AlwaysPretouch) and for optimizing page placement on NUMA systems // by make the underlying region interleaved (with UseNUMA). +// +// Invariant: bottom() <= top() <= end() +// top() and end() are exclusive. class MutableSpaceMangler; @@ -54,11 +56,9 @@ class MutableSpace: public CHeapObj { // The last region which page had been setup to be interleaved. MemRegion _last_setup_region; size_t _alignment; - // Supports CAS-based allocation. - // Invariant: bottom() <= top() <= end() - HeapWord* _bottom; // Start of the region. - HeapWord* volatile _top; // Current allocation pointer. - HeapWord* volatile _end; // Current allocation limit. expand() advances. + HeapWord* _bottom; + HeapWord* volatile _top; + HeapWord* _end; MutableSpaceMangler* mangler() { return _mangler; } @@ -67,22 +67,21 @@ class MutableSpace: public CHeapObj { void set_last_setup_region(MemRegion mr) { _last_setup_region = mr; } MemRegion last_setup_region() const { return _last_setup_region; } - protected: - HeapWord* volatile* top_addr() { return &_top; } - HeapWord* volatile* end_addr() { return &_end; } - public: virtual ~MutableSpace(); MutableSpace(size_t page_size); // Accessors HeapWord* bottom() const { return _bottom; } - HeapWord* top() const { return Atomic::load(&_top); } - HeapWord* end() const { return Atomic::load(&_end); } + HeapWord* top() const { return _top; } + HeapWord* end() const { return _end; } void set_bottom(HeapWord* value) { _bottom = value; } - virtual void set_top(HeapWord* value) { Atomic::store(&_top, value); } - void set_end(HeapWord* value) { Atomic::store(&_end, value); } + virtual void set_top(HeapWord* value) { _top = value; } + void set_end(HeapWord* value) { _end = value; } + + HeapWord* volatile* top_addr() { return &_top; } + HeapWord** end_addr() { return &_end; } size_t alignment() { return _alignment; } diff --git a/src/hotspot/share/gc/parallel/parallelScavengeHeap.hpp b/src/hotspot/share/gc/parallel/parallelScavengeHeap.hpp index 53a69196b6c8f..e4cdb776453e4 100644 --- a/src/hotspot/share/gc/parallel/parallelScavengeHeap.hpp +++ b/src/hotspot/share/gc/parallel/parallelScavengeHeap.hpp @@ -200,6 +200,9 @@ class ParallelScavengeHeap : public CollectedHeap { bool supports_inline_contig_alloc() const { return !UseNUMA; } + HeapWord* volatile* top_addr() const { return !UseNUMA ? young_gen()->top_addr() : (HeapWord* volatile*)-1; } + HeapWord** end_addr() const { return !UseNUMA ? young_gen()->end_addr() : (HeapWord**)-1; } + void ensure_parsability(bool retire_tlabs); void resize_all_tlabs(); diff --git a/src/hotspot/share/gc/parallel/psYoungGen.hpp b/src/hotspot/share/gc/parallel/psYoungGen.hpp index ee6dc298cf4a4..0da0592a98616 100644 --- a/src/hotspot/share/gc/parallel/psYoungGen.hpp +++ b/src/hotspot/share/gc/parallel/psYoungGen.hpp @@ -133,6 +133,9 @@ class PSYoungGen : public CHeapObj { return result; } + HeapWord* volatile* top_addr() const { return eden_space()->top_addr(); } + HeapWord** end_addr() const { return eden_space()->end_addr(); } + // Iteration. void oop_iterate(OopIterateClosure* cl); void object_iterate(ObjectClosure* cl); diff --git a/src/hotspot/share/gc/parallel/vmStructs_parallelgc.hpp b/src/hotspot/share/gc/parallel/vmStructs_parallelgc.hpp index 3b6f3f87c6504..0f131687f5b18 100644 --- a/src/hotspot/share/gc/parallel/vmStructs_parallelgc.hpp +++ b/src/hotspot/share/gc/parallel/vmStructs_parallelgc.hpp @@ -46,7 +46,7 @@ nonstatic_field(PSVirtualSpace, _committed_high_addr, char*) \ \ nonstatic_field(MutableSpace, _bottom, HeapWord*) \ - volatile_nonstatic_field(MutableSpace, _end, HeapWord*) \ + nonstatic_field(MutableSpace, _end, HeapWord*) \ volatile_nonstatic_field(MutableSpace, _top, HeapWord*) \ \ nonstatic_field(PSYoungGen, _reserved, MemRegion) \ From 48f5220c8018f9c166df8d49ce1eb2070695d961 Mon Sep 17 00:00:00 2001 From: Martin Doerr Date: Fri, 5 Feb 2021 12:58:23 +0000 Subject: [PATCH 76/77] 8260369: [PPC64] Add support for JDK-8200555 Reviewed-by: lucy --- src/hotspot/cpu/ppc/interp_masm_ppc.hpp | 3 +- src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp | 17 ++-- src/hotspot/cpu/ppc/macroAssembler_ppc.cpp | 22 +++-- src/hotspot/cpu/ppc/macroAssembler_ppc.hpp | 6 +- .../ppc/templateInterpreterGenerator_ppc.cpp | 59 +++++++------ src/hotspot/cpu/ppc/templateTable_ppc.hpp | 3 +- src/hotspot/cpu/ppc/templateTable_ppc_64.cpp | 88 ++++++++++--------- 7 files changed, 111 insertions(+), 87 deletions(-) diff --git a/src/hotspot/cpu/ppc/interp_masm_ppc.hpp b/src/hotspot/cpu/ppc/interp_masm_ppc.hpp index fa896a2918d1e..f289b80815033 100644 --- a/src/hotspot/cpu/ppc/interp_masm_ppc.hpp +++ b/src/hotspot/cpu/ppc/interp_masm_ppc.hpp @@ -77,7 +77,8 @@ class InterpreterMacroAssembler: public MacroAssembler { Register tmp1, Register tmp2, Register tmp3, Label &ok_is_subtype); // Load object from cpool->resolved_references(index). - void load_resolved_reference_at_index(Register result, Register index, Register tmp1, Label *L_handle_null = NULL); + void load_resolved_reference_at_index(Register result, Register index, Register tmp1, Register tmp2, + Label *L_handle_null = NULL); // load cpool->resolved_klass_at(index) void load_resolved_klass_at_offset(Register Rcpool, Register Roffset, Register Rklass); diff --git a/src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp b/src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp index de1e41d9b9297..11e4cc2a3f799 100644 --- a/src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp +++ b/src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp @@ -477,33 +477,34 @@ void InterpreterMacroAssembler::get_u4(Register Rdst, Register Rsrc, int offset, // Load object from cpool->resolved_references(index). // Kills: // - index -void InterpreterMacroAssembler::load_resolved_reference_at_index(Register result, Register index, Register tmp1, +void InterpreterMacroAssembler::load_resolved_reference_at_index(Register result, Register index, + Register tmp1, Register tmp2, Label *L_handle_null) { - assert_different_registers(result, index); + assert_different_registers(result, index, tmp1, tmp2); + assert(index->is_nonvolatile(), "needs to survive C-call in resolve_oop_handle"); get_constant_pool(result); // Convert from field index to resolved_references() index and from // word index to byte offset. Since this is a java object, it can be compressed. - Register tmp2 = index; // reuse - sldi(tmp1, index, LogBytesPerHeapOop); + sldi(index, index, LogBytesPerHeapOop); // Load pointer for resolved_references[] objArray. ld(result, ConstantPool::cache_offset_in_bytes(), result); ld(result, ConstantPoolCache::resolved_references_offset_in_bytes(), result); - resolve_oop_handle(result); + resolve_oop_handle(result, tmp1, tmp2, MacroAssembler::PRESERVATION_NONE); #ifdef ASSERT Label index_ok; lwa(R0, arrayOopDesc::length_offset_in_bytes(), result); sldi(R0, R0, LogBytesPerHeapOop); - cmpd(CCR0, tmp1, R0); + cmpd(CCR0, index, R0); blt(CCR0, index_ok); stop("resolved reference index out of bounds"); bind(index_ok); #endif // Add in the index. - add(result, tmp1, result); + add(result, index, result); load_heap_oop(result, arrayOopDesc::base_offset_in_bytes(T_OBJECT), result, tmp1, tmp2, - MacroAssembler::PRESERVATION_FRAME_LR, + MacroAssembler::PRESERVATION_NONE, 0, L_handle_null); } diff --git a/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp b/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp index 8ced76f08a0c4..4fdd764c74397 100644 --- a/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp +++ b/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp @@ -3233,16 +3233,22 @@ void MacroAssembler::load_klass(Register dst, Register src) { } // ((OopHandle)result).resolve(); -void MacroAssembler::resolve_oop_handle(Register result) { - // OopHandle::resolve is an indirection. - ld(result, 0, result); +void MacroAssembler::resolve_oop_handle(Register result, Register tmp1, Register tmp2, + MacroAssembler::PreservationLevel preservation_level) { + access_load_at(T_OBJECT, IN_NATIVE, result, noreg, result, tmp1, tmp2, preservation_level); } -void MacroAssembler::load_mirror_from_const_method(Register mirror, Register const_method) { - ld(mirror, in_bytes(ConstMethod::constants_offset()), const_method); - ld(mirror, ConstantPool::pool_holder_offset_in_bytes(), mirror); - ld(mirror, in_bytes(Klass::java_mirror_offset()), mirror); - resolve_oop_handle(mirror); +void MacroAssembler::resolve_weak_handle(Register result, Register tmp1, Register tmp2, + MacroAssembler::PreservationLevel preservation_level) { + Label resolved; + + // A null weak handle resolves to null. + cmpdi(CCR0, result, 0); + beq(CCR0, resolved); + + access_load_at(T_OBJECT, IN_NATIVE | ON_PHANTOM_OOP_REF, result, noreg, result, tmp1, tmp2, + preservation_level); + bind(resolved); } void MacroAssembler::load_method_holder(Register holder, Register method) { diff --git a/src/hotspot/cpu/ppc/macroAssembler_ppc.hpp b/src/hotspot/cpu/ppc/macroAssembler_ppc.hpp index 4dd0ba6c34d91..439d045c13fca 100644 --- a/src/hotspot/cpu/ppc/macroAssembler_ppc.hpp +++ b/src/hotspot/cpu/ppc/macroAssembler_ppc.hpp @@ -743,8 +743,10 @@ class MacroAssembler: public Assembler { void store_klass(Register dst_oop, Register klass, Register tmp = R0); void store_klass_gap(Register dst_oop, Register val = noreg); // Will store 0 if val not specified. - void resolve_oop_handle(Register result); - void load_mirror_from_const_method(Register mirror, Register const_method); + void resolve_oop_handle(Register result, Register tmp1, Register tmp2, + MacroAssembler::PreservationLevel preservation_level); + void resolve_weak_handle(Register result, Register tmp1, Register tmp2, + MacroAssembler::PreservationLevel preservation_level); void load_method_holder(Register holder, Register method); static int instr_size_for_decode_klass_not_null(); diff --git a/src/hotspot/cpu/ppc/templateInterpreterGenerator_ppc.cpp b/src/hotspot/cpu/ppc/templateInterpreterGenerator_ppc.cpp index 515831bf58a22..5a74b8ca1b038 100644 --- a/src/hotspot/cpu/ppc/templateInterpreterGenerator_ppc.cpp +++ b/src/hotspot/cpu/ppc/templateInterpreterGenerator_ppc.cpp @@ -933,11 +933,14 @@ void TemplateInterpreterGenerator::lock_method(Register Rflags, Register Rscratc // state_size: We save the current state of the interpreter to this area. // void TemplateInterpreterGenerator::generate_fixed_frame(bool native_call, Register Rsize_of_parameters, Register Rsize_of_locals) { - Register parent_frame_resize = R6_ARG4, // Frame will grow by this number of bytes. - top_frame_size = R7_ARG5, - Rconst_method = R8_ARG6; + Register Rparent_frame_resize = R6_ARG4, // Frame will grow by this number of bytes. + Rtop_frame_size = R7_ARG5, + Rconst_method = R8_ARG6, + Rconst_pool = R9_ARG7, + Rmirror = R10_ARG8; - assert_different_registers(Rsize_of_parameters, Rsize_of_locals, parent_frame_resize, top_frame_size); + assert_different_registers(Rsize_of_parameters, Rsize_of_locals, Rparent_frame_resize, Rtop_frame_size, + Rconst_method, Rconst_pool); __ ld(Rconst_method, method_(const)); __ lhz(Rsize_of_parameters /* number of params */, @@ -948,35 +951,35 @@ void TemplateInterpreterGenerator::generate_fixed_frame(bool native_call, Regist // We add two slots to the parameter_count, one for the jni // environment and one for a possible native mirror. Label skip_native_calculate_max_stack; - __ addi(top_frame_size, Rsize_of_parameters, 2); - __ cmpwi(CCR0, top_frame_size, Argument::n_register_parameters); + __ addi(Rtop_frame_size, Rsize_of_parameters, 2); + __ cmpwi(CCR0, Rtop_frame_size, Argument::n_register_parameters); __ bge(CCR0, skip_native_calculate_max_stack); - __ li(top_frame_size, Argument::n_register_parameters); + __ li(Rtop_frame_size, Argument::n_register_parameters); __ bind(skip_native_calculate_max_stack); __ sldi(Rsize_of_parameters, Rsize_of_parameters, Interpreter::logStackElementSize); - __ sldi(top_frame_size, top_frame_size, Interpreter::logStackElementSize); - __ sub(parent_frame_resize, R1_SP, R15_esp); // <0, off by Interpreter::stackElementSize! + __ sldi(Rtop_frame_size, Rtop_frame_size, Interpreter::logStackElementSize); + __ sub(Rparent_frame_resize, R1_SP, R15_esp); // <0, off by Interpreter::stackElementSize! assert(Rsize_of_locals == noreg, "Rsize_of_locals not initialized"); // Only relevant value is Rsize_of_parameters. } else { __ lhz(Rsize_of_locals /* number of params */, in_bytes(ConstMethod::size_of_locals_offset()), Rconst_method); __ sldi(Rsize_of_parameters, Rsize_of_parameters, Interpreter::logStackElementSize); __ sldi(Rsize_of_locals, Rsize_of_locals, Interpreter::logStackElementSize); - __ lhz(top_frame_size, in_bytes(ConstMethod::max_stack_offset()), Rconst_method); + __ lhz(Rtop_frame_size, in_bytes(ConstMethod::max_stack_offset()), Rconst_method); __ sub(R11_scratch1, Rsize_of_locals, Rsize_of_parameters); // >=0 - __ sub(parent_frame_resize, R1_SP, R15_esp); // <0, off by Interpreter::stackElementSize! - __ sldi(top_frame_size, top_frame_size, Interpreter::logStackElementSize); - __ add(parent_frame_resize, parent_frame_resize, R11_scratch1); + __ sub(Rparent_frame_resize, R1_SP, R15_esp); // <0, off by Interpreter::stackElementSize! + __ sldi(Rtop_frame_size, Rtop_frame_size, Interpreter::logStackElementSize); + __ add(Rparent_frame_resize, Rparent_frame_resize, R11_scratch1); } // Compute top frame size. - __ addi(top_frame_size, top_frame_size, frame::abi_reg_args_size + frame::ijava_state_size); + __ addi(Rtop_frame_size, Rtop_frame_size, frame::abi_reg_args_size + frame::ijava_state_size); // Cut back area between esp and max_stack. - __ addi(parent_frame_resize, parent_frame_resize, frame::abi_minframe_size - Interpreter::stackElementSize); + __ addi(Rparent_frame_resize, Rparent_frame_resize, frame::abi_minframe_size - Interpreter::stackElementSize); - __ round_to(top_frame_size, frame::alignment_in_bytes); - __ round_to(parent_frame_resize, frame::alignment_in_bytes); - // parent_frame_resize = (locals-parameters) - (ESP-SP-ABI48) Rounded to frame alignment size. + __ round_to(Rtop_frame_size, frame::alignment_in_bytes); + __ round_to(Rparent_frame_resize, frame::alignment_in_bytes); + // Rparent_frame_resize = (locals-parameters) - (ESP-SP-ABI48) Rounded to frame alignment size. // Enlarge by locals-parameters (not in case of native_call), shrink by ESP-SP-ABI48. if (!native_call) { @@ -984,15 +987,15 @@ void TemplateInterpreterGenerator::generate_fixed_frame(bool native_call, Regist // Native calls don't need the stack size check since they have no // expression stack and the arguments are already on the stack and // we only add a handful of words to the stack. - __ add(R11_scratch1, parent_frame_resize, top_frame_size); + __ add(R11_scratch1, Rparent_frame_resize, Rtop_frame_size); generate_stack_overflow_check(R11_scratch1, R12_scratch2); } // Set up interpreter state registers. __ add(R18_locals, R15_esp, Rsize_of_parameters); - __ ld(R27_constPoolCache, in_bytes(ConstMethod::constants_offset()), Rconst_method); - __ ld(R27_constPoolCache, ConstantPool::cache_offset_in_bytes(), R27_constPoolCache); + __ ld(Rconst_pool, in_bytes(ConstMethod::constants_offset()), Rconst_method); + __ ld(R27_constPoolCache, ConstantPool::cache_offset_in_bytes(), Rconst_pool); // Set method data pointer. if (ProfileInterpreter) { @@ -1012,19 +1015,21 @@ void TemplateInterpreterGenerator::generate_fixed_frame(bool native_call, Regist // Resize parent frame. __ mflr(R12_scratch2); - __ neg(parent_frame_resize, parent_frame_resize); - __ resize_frame(parent_frame_resize, R11_scratch1); + __ neg(Rparent_frame_resize, Rparent_frame_resize); + __ resize_frame(Rparent_frame_resize, R11_scratch1); __ std(R12_scratch2, _abi0(lr), R1_SP); // Get mirror and store it in the frame as GC root for this Method*. - __ load_mirror_from_const_method(R12_scratch2, Rconst_method); + __ ld(Rmirror, ConstantPool::pool_holder_offset_in_bytes(), Rconst_pool); + __ ld(Rmirror, in_bytes(Klass::java_mirror_offset()), Rmirror); + __ resolve_oop_handle(Rmirror, R11_scratch1, R12_scratch2, MacroAssembler::PRESERVATION_FRAME_LR_GP_REGS); __ addi(R26_monitor, R1_SP, -frame::ijava_state_size); __ addi(R15_esp, R26_monitor, -Interpreter::stackElementSize); // Store values. __ std(R19_method, _ijava_state_neg(method), R1_SP); - __ std(R12_scratch2, _ijava_state_neg(mirror), R1_SP); + __ std(Rmirror, _ijava_state_neg(mirror), R1_SP); __ std(R18_locals, _ijava_state_neg(locals), R1_SP); __ std(R27_constPoolCache, _ijava_state_neg(cpoolCache), R1_SP); @@ -1046,12 +1051,12 @@ void TemplateInterpreterGenerator::generate_fixed_frame(bool native_call, Regist __ std(R0, _ijava_state_neg(oop_tmp), R1_SP); // only used for native_call // Store sender's SP and this frame's top SP. - __ subf(R12_scratch2, top_frame_size, R1_SP); + __ subf(R12_scratch2, Rtop_frame_size, R1_SP); __ std(R21_sender_SP, _ijava_state_neg(sender_sp), R1_SP); __ std(R12_scratch2, _ijava_state_neg(top_frame_sp), R1_SP); // Push top frame. - __ push_frame(top_frame_size, R11_scratch1); + __ push_frame(Rtop_frame_size, R11_scratch1); } // End of helpers diff --git a/src/hotspot/cpu/ppc/templateTable_ppc.hpp b/src/hotspot/cpu/ppc/templateTable_ppc.hpp index 0ab9814ebae97..afe10c2d6fda1 100644 --- a/src/hotspot/cpu/ppc/templateTable_ppc.hpp +++ b/src/hotspot/cpu/ppc/templateTable_ppc.hpp @@ -26,7 +26,8 @@ #ifndef CPU_PPC_TEMPLATETABLE_PPC_HPP #define CPU_PPC_TEMPLATETABLE_PPC_HPP - static void prepare_invoke(int byte_no, Register Rmethod, Register Rret_addr, Register Rindex, Register Rrecv, Register Rflags, Register Rscratch); + static void prepare_invoke(int byte_no, Register Rmethod, Register Rret_addr, Register Rindex, Register Rrecv, Register Rflags, + Register Rscratch1, Register Rscratch2); static void invokevfinal_helper(Register Rmethod, Register Rflags, Register Rscratch1, Register Rscratch2); static void generate_vtable_call(Register Rrecv_klass, Register Rindex, Register Rret, Register Rtemp); static void invokeinterface_object_method(Register Rrecv_klass, Register Rret, Register Rflags, Register Rindex, Register Rtemp, Register Rtemp2); diff --git a/src/hotspot/cpu/ppc/templateTable_ppc_64.cpp b/src/hotspot/cpu/ppc/templateTable_ppc_64.cpp index d5916eb0a730b..70a805d3484c5 100644 --- a/src/hotspot/cpu/ppc/templateTable_ppc_64.cpp +++ b/src/hotspot/cpu/ppc/templateTable_ppc_64.cpp @@ -309,14 +309,14 @@ void TemplateTable::fast_aldc(bool wide) { // We are resolved if the resolved reference cache entry contains a // non-null object (CallSite, etc.) - __ get_cache_index_at_bcp(R11_scratch1, 1, index_size); // Load index. - __ load_resolved_reference_at_index(R17_tos, R11_scratch1, R12_scratch2, &is_null); + __ get_cache_index_at_bcp(R31, 1, index_size); // Load index. + __ load_resolved_reference_at_index(R17_tos, R31, R11_scratch1, R12_scratch2, &is_null); // Convert null sentinel to NULL int simm16_rest = __ load_const_optimized(R11_scratch1, Universe::the_null_sentinel_addr(), R0, true); - __ ld(R11_scratch1, simm16_rest, R11_scratch1); - __ resolve_oop_handle(R11_scratch1); - __ cmpld(CCR0, R17_tos, R11_scratch1); + __ ld(R31, simm16_rest, R11_scratch1); + __ resolve_oop_handle(R31, R11_scratch1, R12_scratch2, MacroAssembler::PRESERVATION_NONE); + __ cmpld(CCR0, R17_tos, R31); if (VM_Version::has_isel()) { __ isel_0(R17_tos, CCR0, Assembler::equal); } else { @@ -2252,14 +2252,16 @@ void TemplateTable::resolve_cache_and_index(int byte_no, Register Rcache, Regist // - Rcache, Rindex // Output: // - Robj, Roffset, Rflags +// Kills: +// - R11, R12 void TemplateTable::load_field_cp_cache_entry(Register Robj, Register Rcache, Register Rindex /* unused on PPC64 */, Register Roffset, Register Rflags, - bool is_static = false) { - assert_different_registers(Rcache, Rflags, Roffset); - // assert(Rindex == noreg, "parameter not used on PPC64"); + bool is_static) { + assert_different_registers(Rcache, Rflags, Roffset, R11_scratch1, R12_scratch2); + assert(Rindex == noreg, "parameter not used on PPC64"); ByteSize cp_base_offset = ConstantPoolCache::base_offset(); __ ld(Rflags, in_bytes(cp_base_offset) + in_bytes(ConstantPoolCacheEntry::flags_offset()), Rcache); @@ -2267,7 +2269,7 @@ void TemplateTable::load_field_cp_cache_entry(Register Robj, if (is_static) { __ ld(Robj, in_bytes(cp_base_offset) + in_bytes(ConstantPoolCacheEntry::f1_offset()), Rcache); __ ld(Robj, in_bytes(Klass::java_mirror_offset()), Robj); - __ resolve_oop_handle(Robj); + __ resolve_oop_handle(Robj, R11_scratch1, R12_scratch2, MacroAssembler::PRESERVATION_NONE); // Acquire not needed here. Following access has an address dependency on this value. } } @@ -2427,7 +2429,8 @@ void TemplateTable::getfield_or_static(int byte_no, bool is_static, RewriteContr Rflags = R31, Rbtable = R5_ARG3, Rbc = R30, - Rscratch = R12_scratch2; + Rscratch = R11_scratch1; // used by load_field_cp_cache_entry + // R12_scratch2 used by load_field_cp_cache_entry static address field_branch_table[number_of_states], static_branch_table[number_of_states]; @@ -2441,7 +2444,7 @@ void TemplateTable::getfield_or_static(int byte_no, bool is_static, RewriteContr jvmti_post_field_access(Rcache, Rscratch, is_static, false); // Load after possible GC. - load_field_cp_cache_entry(Rclass_or_obj, Rcache, noreg, Roffset, Rflags, is_static); + load_field_cp_cache_entry(Rclass_or_obj, Rcache, noreg, Roffset, Rflags, is_static); // Uses R11, R12 // Load pointer to branch table. __ load_const_optimized(Rbtable, (address)branch_table, Rscratch); @@ -2758,10 +2761,10 @@ void TemplateTable::putfield_or_static(int byte_no, bool is_static, RewriteContr const Register Rcache = R5_ARG3, // Do not use ARG1/2 (causes trouble in jvmti_post_field_mod). Rclass_or_obj = R31, // Needs to survive C call. Roffset = R22_tmp2, // Needs to survive C call. - Rflags = R3_ARG1, + Rflags = R30, Rbtable = R4_ARG2, - Rscratch = R11_scratch1, - Rscratch2 = R12_scratch2, + Rscratch = R11_scratch1, // used by load_field_cp_cache_entry + Rscratch2 = R12_scratch2, // used by load_field_cp_cache_entry Rscratch3 = R6_ARG4, Rbc = Rscratch3; const ConditionRegister CR_is_vol = CCR2; // Non-volatile condition register (survives runtime call in do_oop_store). @@ -2780,7 +2783,7 @@ void TemplateTable::putfield_or_static(int byte_no, bool is_static, RewriteContr // Load the field offset. resolve_cache_and_index(byte_no, Rcache, Rscratch, sizeof(u2)); jvmti_post_field_mod(Rcache, Rscratch, is_static); - load_field_cp_cache_entry(Rclass_or_obj, Rcache, noreg, Roffset, Rflags, is_static); + load_field_cp_cache_entry(Rclass_or_obj, Rcache, noreg, Roffset, Rflags, is_static); // Uses R11, R12 // Load pointer to branch table. __ load_const_optimized(Rbtable, (address)branch_table, Rscratch); @@ -3007,15 +3010,15 @@ void TemplateTable::fast_storefield(TosState state) { Rclass_or_obj = R31, // Needs to survive C call. Roffset = R22_tmp2, // Needs to survive C call. Rflags = R3_ARG1, - Rscratch = R11_scratch1, - Rscratch2 = R12_scratch2, + Rscratch = R11_scratch1, // used by load_field_cp_cache_entry + Rscratch2 = R12_scratch2, // used by load_field_cp_cache_entry Rscratch3 = R4_ARG2; const ConditionRegister CR_is_vol = CCR2; // Non-volatile condition register (survives runtime call in do_oop_store). // Constant pool already resolved => Load flags and offset of field. __ get_cache_and_index_at_bcp(Rcache, 1); jvmti_post_field_mod(Rcache, Rscratch, false /* not static */); - load_field_cp_cache_entry(noreg, Rcache, noreg, Roffset, Rflags, false); + load_field_cp_cache_entry(noreg, Rcache, noreg, Roffset, Rflags, false); // Uses R11, R12 // Get the obj and the final store addr. pop_and_check_object(Rclass_or_obj); // Kills R11_scratch1. @@ -3090,11 +3093,12 @@ void TemplateTable::fast_accessfield(TosState state) { Rclass_or_obj = R17_tos, Roffset = R22_tmp2, Rflags = R23_tmp3, - Rscratch = R12_scratch2; + Rscratch = R11_scratch1; // used by load_field_cp_cache_entry + // R12_scratch2 used by load_field_cp_cache_entry // Constant pool already resolved. Get the field offset. __ get_cache_and_index_at_bcp(Rcache, 1); - load_field_cp_cache_entry(noreg, Rcache, noreg, Roffset, Rflags, false); + load_field_cp_cache_entry(noreg, Rcache, noreg, Roffset, Rflags, false); // Uses R11, R12 // JVMTI support jvmti_post_field_access(Rcache, Rscratch, false, true); @@ -3226,13 +3230,14 @@ void TemplateTable::fast_xaccess(TosState state) { Rclass_or_obj = R17_tos, Roffset = R22_tmp2, Rflags = R23_tmp3, - Rscratch = R12_scratch2; + Rscratch = R11_scratch1; + // R12_scratch2 used by load_field_cp_cache_entry __ ld(Rclass_or_obj, 0, R18_locals); // Constant pool already resolved. Get the field offset. __ get_cache_and_index_at_bcp(Rcache, 2); - load_field_cp_cache_entry(noreg, Rcache, noreg, Roffset, Rflags, false); + load_field_cp_cache_entry(noreg, Rcache, noreg, Roffset, Rflags, false); // Uses R11, R12 // JVMTI support not needed, since we switch back to single bytecode as soon as debugger attaches. @@ -3317,7 +3322,8 @@ void TemplateTable::prepare_invoke(int byte_no, Register Rindex, // itable index, MethodType, Method, etc. Register Rrecv, // If caller wants to see it. Register Rflags, // If caller wants to test it. - Register Rscratch + Register Rscratch1, + Register Rscratch2 ) { // Determine flags. const Bytecodes::Code code = bytecode(); @@ -3329,10 +3335,9 @@ void TemplateTable::prepare_invoke(int byte_no, const bool load_receiver = (Rrecv != noreg); assert(load_receiver == (code != Bytecodes::_invokestatic && code != Bytecodes::_invokedynamic), ""); - assert_different_registers(Rmethod, Rindex, Rflags, Rscratch); - assert_different_registers(Rmethod, Rrecv, Rflags, Rscratch); - // Rret_addr and Rindex have to be distinct as Rret_addr is used as a second temp register - assert_different_registers(Rret_addr, Rindex, Rscratch); + assert_different_registers(Rmethod, Rindex, Rflags, Rscratch1); + assert_different_registers(Rmethod, Rrecv, Rflags, Rscratch1); + assert_different_registers(Rret_addr, Rscratch1); load_invoke_cp_cache_entry(byte_no, Rmethod, Rindex, Rflags, is_invokevirtual, false, is_invokedynamic); @@ -3341,22 +3346,23 @@ void TemplateTable::prepare_invoke(int byte_no, // Maybe push "appendix" to arguments. if (is_invokedynamic || is_invokehandle) { Label Ldone; - Register reference = Rret_addr; // safe to use here; first use comes later + Register reference = Rscratch1; __ rldicl_(R0, Rflags, 64-ConstantPoolCacheEntry::has_appendix_shift, 63); __ beq(CCR0, Ldone); // Push "appendix" (MethodType, CallSite, etc.). // This must be done before we get the receiver, // since the parameter_size includes it. - __ load_resolved_reference_at_index(reference, Rindex, Rscratch); + __ load_resolved_reference_at_index(reference, Rindex, /* temp */ Rret_addr, Rscratch2); __ verify_oop(reference); __ push_ptr(reference); + __ bind(Ldone); } // Load receiver if needed (after appendix is pushed so parameter size is correct). if (load_receiver) { - const Register Rparam_count = Rscratch; + Register Rparam_count = Rscratch1; __ andi(Rparam_count, Rflags, ConstantPoolCacheEntry::parameter_size_mask); __ load_receiver(Rparam_count, Rrecv); __ verify_oop(Rrecv); @@ -3364,7 +3370,7 @@ void TemplateTable::prepare_invoke(int byte_no, // Get return address. { - Register Rtable_addr = Rscratch; + Register Rtable_addr = Rscratch1; Register Rret_type = Rret_addr; address table_addr = (address) Interpreter::invoke_return_entry_table_for(code); @@ -3495,7 +3501,7 @@ void TemplateTable::invokespecial(int byte_no) { Rreceiver = R6_ARG4, Rmethod = R31; - prepare_invoke(byte_no, Rmethod, Rret_addr, noreg, Rreceiver, Rflags, R11_scratch1); + prepare_invoke(byte_no, Rmethod, Rret_addr, noreg, Rreceiver, Rflags, R11_scratch1, R12_scratch2); // Receiver NULL check. __ null_check_throw(Rreceiver, -1, R11_scratch1); @@ -3514,7 +3520,7 @@ void TemplateTable::invokestatic(int byte_no) { Rret_addr = R4_ARG2, Rflags = R5_ARG3; - prepare_invoke(byte_no, R19_method, Rret_addr, noreg, noreg, Rflags, R11_scratch1); + prepare_invoke(byte_no, R19_method, Rret_addr, noreg, noreg, Rflags, R11_scratch1, R12_scratch2); __ profile_call(R11_scratch1, R12_scratch2); // Argument and return type profiling. @@ -3566,7 +3572,7 @@ void TemplateTable::invokeinterface(int byte_no) { Rrecv_klass = R4_ARG2, Rflags = R7_ARG5; - prepare_invoke(byte_no, Rinterface_klass, Rret_addr, Rmethod, Rreceiver, Rflags, Rscratch1); + prepare_invoke(byte_no, Rinterface_klass, Rret_addr, Rmethod, Rreceiver, Rflags, Rscratch1, /* temp */ Rrecv_klass); // First check for Object case, then private interface method, // then regular interface method. @@ -3653,10 +3659,11 @@ void TemplateTable::invokedynamic(int byte_no) { const Register Rret_addr = R3_ARG1, Rflags = R31, Rmethod = R22_tmp2, - Rscratch1 = R11_scratch1, - Rscratch2 = R12_scratch2; + Rscratch1 = R30, + Rscratch2 = R11_scratch1, + Rscratch3 = R12_scratch2; - prepare_invoke(byte_no, Rmethod, Rret_addr, Rscratch1, noreg, Rflags, Rscratch2); + prepare_invoke(byte_no, Rmethod, Rret_addr, Rscratch1, noreg, Rflags, Rscratch2, Rscratch3); // Profile this call. __ profile_call(Rscratch1, Rscratch2); @@ -3678,10 +3685,11 @@ void TemplateTable::invokehandle(int byte_no) { Rflags = R31, Rrecv = R5_ARG3, Rmethod = R22_tmp2, - Rscratch1 = R11_scratch1, - Rscratch2 = R12_scratch2; + Rscratch1 = R30, + Rscratch2 = R11_scratch1, + Rscratch3 = R12_scratch2; - prepare_invoke(byte_no, Rmethod, Rret_addr, Rscratch1, Rrecv, Rflags, Rscratch2); + prepare_invoke(byte_no, Rmethod, Rret_addr, Rscratch1, Rrecv, Rflags, Rscratch2, Rscratch3); __ verify_method_ptr(Rmethod); __ null_check_throw(Rrecv, -1, Rscratch2); From 43ae0cf878548ba56b88459290145a776839bcf5 Mon Sep 17 00:00:00 2001 From: Matthias Baesken Date: Fri, 5 Feb 2021 13:37:44 +0000 Subject: [PATCH 77/77] 8261167: print_process_memory_info add a close call after fopen Reviewed-by: stuefe, dholmes --- src/hotspot/os/linux/os_linux.cpp | 50 +++++++++++++++++-------------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp index 1a582c9d4447e..3b9556d688d79 100644 --- a/src/hotspot/os/linux/os_linux.cpp +++ b/src/hotspot/os/linux/os_linux.cpp @@ -2195,29 +2195,35 @@ void os::Linux::print_process_memory_info(outputStream* st) { int num_found = 0; FILE* f = ::fopen("/proc/self/status", "r"); char buf[256]; - while (::fgets(buf, sizeof(buf), f) != NULL && num_found < num_values) { - if ( (vmsize == -1 && sscanf(buf, "VmSize: " SSIZE_FORMAT " kB", &vmsize) == 1) || - (vmpeak == -1 && sscanf(buf, "VmPeak: " SSIZE_FORMAT " kB", &vmpeak) == 1) || - (vmswap == -1 && sscanf(buf, "VmSwap: " SSIZE_FORMAT " kB", &vmswap) == 1) || - (vmhwm == -1 && sscanf(buf, "VmHWM: " SSIZE_FORMAT " kB", &vmhwm) == 1) || - (vmrss == -1 && sscanf(buf, "VmRSS: " SSIZE_FORMAT " kB", &vmrss) == 1) || - (rssanon == -1 && sscanf(buf, "RssAnon: " SSIZE_FORMAT " kB", &rssanon) == 1) || - (rssfile == -1 && sscanf(buf, "RssFile: " SSIZE_FORMAT " kB", &rssfile) == 1) || - (rssshmem == -1 && sscanf(buf, "RssShmem: " SSIZE_FORMAT " kB", &rssshmem) == 1) - ) - { - num_found ++; + if (f != NULL) { + while (::fgets(buf, sizeof(buf), f) != NULL && num_found < num_values) { + if ( (vmsize == -1 && sscanf(buf, "VmSize: " SSIZE_FORMAT " kB", &vmsize) == 1) || + (vmpeak == -1 && sscanf(buf, "VmPeak: " SSIZE_FORMAT " kB", &vmpeak) == 1) || + (vmswap == -1 && sscanf(buf, "VmSwap: " SSIZE_FORMAT " kB", &vmswap) == 1) || + (vmhwm == -1 && sscanf(buf, "VmHWM: " SSIZE_FORMAT " kB", &vmhwm) == 1) || + (vmrss == -1 && sscanf(buf, "VmRSS: " SSIZE_FORMAT " kB", &vmrss) == 1) || + (rssanon == -1 && sscanf(buf, "RssAnon: " SSIZE_FORMAT " kB", &rssanon) == 1) || + (rssfile == -1 && sscanf(buf, "RssFile: " SSIZE_FORMAT " kB", &rssfile) == 1) || + (rssshmem == -1 && sscanf(buf, "RssShmem: " SSIZE_FORMAT " kB", &rssshmem) == 1) + ) + { + num_found ++; + } } - } - st->print_cr("Virtual Size: " SSIZE_FORMAT "K (peak: " SSIZE_FORMAT "K)", vmsize, vmpeak); - st->print("Resident Set Size: " SSIZE_FORMAT "K (peak: " SSIZE_FORMAT "K)", vmrss, vmhwm); - if (rssanon != -1) { // requires kernel >= 4.5 - st->print(" (anon: " SSIZE_FORMAT "K, file: " SSIZE_FORMAT "K, shmem: " SSIZE_FORMAT "K)", - rssanon, rssfile, rssshmem); - } - st->cr(); - if (vmswap != -1) { // requires kernel >= 2.6.34 - st->print_cr("Swapped out: " SSIZE_FORMAT "K", vmswap); + fclose(f); + + st->print_cr("Virtual Size: " SSIZE_FORMAT "K (peak: " SSIZE_FORMAT "K)", vmsize, vmpeak); + st->print("Resident Set Size: " SSIZE_FORMAT "K (peak: " SSIZE_FORMAT "K)", vmrss, vmhwm); + if (rssanon != -1) { // requires kernel >= 4.5 + st->print(" (anon: " SSIZE_FORMAT "K, file: " SSIZE_FORMAT "K, shmem: " SSIZE_FORMAT "K)", + rssanon, rssfile, rssshmem); + } + st->cr(); + if (vmswap != -1) { // requires kernel >= 2.6.34 + st->print_cr("Swapped out: " SSIZE_FORMAT "K", vmswap); + } + } else { + st->print_cr("Could not open /proc/self/status to get process memory related information"); } // Print glibc outstanding allocations.