!60 sync master to openEuler-2203-LTS-SP3

From: @kuenking111 
Reviewed-by: @alexanderbill 
Signed-off-by: @alexanderbill
This commit is contained in:
openeuler-ci-bot 2023-11-27 02:31:09 +00:00 committed by Gitee
commit 4d47b36324
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
33 changed files with 191838 additions and 10415 deletions

View File

@ -0,0 +1,220 @@
From 53853bf21c07116f6eff5fc8a74a1c4bcdd60343 Mon Sep 17 00:00:00 2001
Subject: 8168469: Memory leak in JceSecurity
---
.../javax/crypto/JceSecurity.java.template | 71 ++++++++++++-------
.../JceSecurity/VerificationResults.java | 59 +++++++++++++++
2 files changed, 103 insertions(+), 27 deletions(-)
create mode 100644 test/jdk/javax/crypto/JceSecurity/VerificationResults.java
diff --git a/src/java.base/share/classes/javax/crypto/JceSecurity.java.template b/src/java.base/share/classes/javax/crypto/JceSecurity.java.template
index 7a344e8e3..bcdff3881 100644
--- a/src/java.base/share/classes/javax/crypto/JceSecurity.java.template
+++ b/src/java.base/share/classes/javax/crypto/JceSecurity.java.template
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2023, 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,10 @@ package javax.crypto;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
+import java.util.function.Function;
import java.io.*;
+import java.lang.ref.ReferenceQueue;
+import java.lang.ref.WeakReference;
import java.net.URL;
import java.nio.file.*;
import java.security.*;
@@ -86,13 +89,16 @@ final class JceSecurity {
// Map of the providers we already have verified.
// If verified ok, value == PROVIDER_VERIFIED, otherwise
// the cause of verification failure is stored as value.
- private static final Map<IdentityWrapper, Object>
+ private static final Map<WeakIdentityWrapper, Object>
verificationResults = new ConcurrentHashMap<>();
// Map<Provider,?> of the providers currently being verified
private static final Map<Provider, Object> verifyingProviders =
new IdentityHashMap<>();
+ // weak references queued by GC
+ private static final ReferenceQueue<Object> queue = new ReferenceQueue<>();
+
private static final boolean isRestricted;
/*
@@ -199,38 +205,51 @@ final class JceSecurity {
* Return null if ok, failure Exception if verification failed.
*/
static Exception getVerificationResult(Provider p) {
- IdentityWrapper pKey = new IdentityWrapper(p);
- Object o = verificationResults.get(pKey);
- // no mapping found
- if (o == null) {
- synchronized (JceSecurity.class) {
- // check cache again in case the result is now available
- o = verificationResults.get(pKey);
- if (o == null) {
+ expungeStaleWrappers();
+ WeakIdentityWrapper pKey = new WeakIdentityWrapper(p, queue);
+ try {
+ Object o = verificationResults.computeIfAbsent(pKey, new Function<>() {
+ public Object apply(WeakIdentityWrapper key) {
+ // no mapping found
if (verifyingProviders.get(p) != null) {
// recursion; return failure now
- return new NoSuchProviderException
- ("Recursion during verification");
+ throw new IllegalStateException();
}
+ Object result;
try {
verifyingProviders.put(p, Boolean.FALSE);
URL providerURL = getCodeBase(p.getClass());
verifyProvider(providerURL, p);
- o = PROVIDER_VERIFIED;
+ result = PROVIDER_VERIFIED;
} catch (Exception e) {
- o = e;
+ result = e;
} finally {
verifyingProviders.remove(p);
}
- verificationResults.put(pKey, o);
if (debug != null) {
debug.println("Provider " + p.getName() +
- " verification result: " + o);
+ " verification result: " + result);
}
+ return result;
}
- }
+ });
+ return (o == PROVIDER_VERIFIED? null : (Exception) o);
+
+ } catch (IllegalStateException ise) {
+ // recursive update detected
+ return new NoSuchProviderException
+ ("Recursion during verification");
+ }
+ }
+
+ /**
+ * Removes weakly reachable keys from history.
+ */
+ static void expungeStaleWrappers() {
+ WeakIdentityWrapper key;
+ while ((key = (WeakIdentityWrapper) queue.poll()) != null) {
+ verificationResults.remove(key);
}
- return (o == PROVIDER_VERIFIED? null : (Exception) o);
}
// return whether this provider is properly signed and can be used by JCE
@@ -403,12 +422,13 @@ final class JceSecurity {
return isRestricted;
}
- private static final class IdentityWrapper {
+ private static final class WeakIdentityWrapper extends WeakReference<Object> {
- final Provider obj;
+ final int hash;
- IdentityWrapper(Provider obj) {
- this.obj = obj;
+ WeakIdentityWrapper(Provider obj, ReferenceQueue<Object> queue) {
+ super(obj, queue);
+ hash = System.identityHashCode(obj);
}
@Override
@@ -416,15 +436,12 @@ final class JceSecurity {
if (this == o) {
return true;
}
- if (!(o instanceof IdentityWrapper)) {
- return false;
- }
- return this.obj == ((IdentityWrapper)o).obj;
+ return o instanceof WeakIdentityWrapper w && get() == w.get();
}
@Override
public int hashCode() {
- return System.identityHashCode(obj);
+ return hash;
}
}
}
diff --git a/test/jdk/javax/crypto/JceSecurity/VerificationResults.java b/test/jdk/javax/crypto/JceSecurity/VerificationResults.java
new file mode 100644
index 000000000..9f87433a6
--- /dev/null
+++ b/test/jdk/javax/crypto/JceSecurity/VerificationResults.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2023, BELLSOFT. All rights reserved.
+ * 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 8168469
+ * @summary Memory leak in JceSecurity
+ * @compile --add-exports java.base/com.sun.crypto.provider=ALL-UNNAMED VerificationResults.java
+ * @run main/othervm -Xmx128m --add-exports java.base/com.sun.crypto.provider=ALL-UNNAMED VerificationResults
+ */
+
+import java.security.NoSuchAlgorithmException;
+import java.security.Provider;
+
+import javax.crypto.Cipher;
+import javax.crypto.NoSuchPaddingException;
+
+import com.sun.crypto.provider.SunJCE;
+
+public class VerificationResults {
+
+ // approximate double the number of providers that fits in -Xmx128m heap
+ private static final int PROVIDERS_COUNT = 2000;
+ // the heap buffer size that triggers the OOME when the providers heap cannot be reclaimed
+ private static final int OOM_TRIGGER_SIZE = 10 * 1024 * 1024;
+ public static void main(String[] args) throws NoSuchAlgorithmException, NoSuchPaddingException {
+ int i = 0;
+ try {
+ for (; i < PROVIDERS_COUNT; i++) {
+ SunJCE jceProvider = new SunJCE();
+ Cipher c = Cipher.getInstance("AES", jceProvider);
+ char[] arr = new char[OOM_TRIGGER_SIZE];
+ }
+ } catch (OutOfMemoryError e) {
+ System.out.println("Caught OOME - less than 10M heap left.\nCreated " + i + " SunJCE providers");
+ throw e;
+ }
+ }
+}
--
2.22.0

View File

@ -3,8 +3,6 @@ Date: Wed, 4 Jan 2023 20:41:20 +0800
Subject: 8253495: CDS generates non-deterministic output
---
make/GenerateLinkOptData.gmk | 7 +-
.../build/tools/classlist/SortClasslist.java | 79 +++++++++++++++++++
make/scripts/compare.sh | 8 +-
src/hotspot/share/cds/archiveBuilder.cpp | 5 +-
src/hotspot/share/cds/archiveUtils.hpp | 5 +-
@ -12,136 +10,20 @@ Subject: 8253495: CDS generates non-deterministic output
src/hotspot/share/gc/shared/collectedHeap.cpp | 18 ++++-
src/hotspot/share/gc/shared/collectedHeap.hpp | 1 +
src/hotspot/share/prims/jvm.cpp | 20 +++++
src/hotspot/share/runtime/os.cpp | 19 ++++-
src/hotspot/share/runtime/os.cpp | 11 ++-
test/hotspot/jtreg/ProblemList.txt | 1 -
.../jtreg/runtime/cds/DeterministicDump.java | 10 ++-
.../cds/appcds/javaldr/LockDuringDump.java | 4 +-
.../appcds/javaldr/LockDuringDumpAgent.java | 16 +++-
test/lib/jdk/test/lib/cds/CDSOptions.java | 33 ++++++--
15 files changed, 202 insertions(+), 32 deletions(-)
13 files changed, 103 insertions(+), 33 deletions(-)
create mode 100644 make/jdk/src/classes/build/tools/classlist/SortClasslist.java
diff --git a/make/GenerateLinkOptData.gmk b/make/GenerateLinkOptData.gmk
index 0de28d643..5dd766c8c 100644
--- a/make/GenerateLinkOptData.gmk
+++ b/make/GenerateLinkOptData.gmk
@@ -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
@@ -88,7 +88,10 @@ $(CLASSLIST_FILE): $(INTERIM_IMAGE_DIR)/bin/java$(EXECUTABLE_SUFFIX) $(CLASSLIST
$(CAT) $(LINK_OPT_DIR)/stderr $(JLI_TRACE_FILE) ; \
exit $$exitcode \
)
- $(GREP) -v HelloClasslist $@.raw.2 > $@
+ $(GREP) -v HelloClasslist $@.raw.2 > $@.raw.3
+ $(FIXPATH) $(INTERIM_IMAGE_DIR)/bin/java \
+ -cp $(SUPPORT_OUTPUTDIR)/classlist.jar \
+ build.tools.classlist.SortClasslist $@.raw.3 > $@
# The jli trace is created by the same recipe as classlist. By declaring these
# dependencies, make will correctly rebuild both jli trace and classlist
diff --git a/make/jdk/src/classes/build/tools/classlist/SortClasslist.java b/make/jdk/src/classes/build/tools/classlist/SortClasslist.java
new file mode 100644
index 000000000..cf9e55a7b
--- /dev/null
+++ b/make/jdk/src/classes/build/tools/classlist/SortClasslist.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2022, 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. 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.
+ */
+
+/**
+ * This application is meant to be run to create a classlist file representing
+ * common use.
+ *
+ * The classlist is produced by adding -XX:DumpLoadedClassList=classlist
+ */
+package build.tools.classlist;
+
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.regex.Pattern;
+import java.util.regex.Matcher;
+import java.util.Scanner;
+
+/**
+ * The classlist generated by build.tools.classlist.HelloClasslist
+ * may have non-deterministic contents, affected by Java thread execution order.
+ * SortClasslist sorts the file to make the JDK image's contents more deterministic.
+ */
+public class SortClasslist {
+ public static void main(String args[]) throws FileNotFoundException {
+ ArrayList<String> classes = new ArrayList<>();
+ ArrayList<String> lambdas = new ArrayList<>();
+
+ FileInputStream fis = new FileInputStream(args[0]);
+ Scanner scanner = new Scanner(fis);
+ while (scanner.hasNextLine()) {
+ String line = scanner.nextLine();
+ if (line.startsWith("#")) {
+ // Comments -- print them first without sorting. These appear only at the top
+ // of the file.
+ System.out.println(line);
+ } else if (line.startsWith("@")) {
+ // @lambda-form-invoker, @lambda-proxy, etc.
+ lambdas.add(line);
+ } else {
+ classes.add(line);
+ }
+ }
+
+ Collections.sort(classes);
+ Collections.sort(lambdas);
+
+ for (String s : classes) {
+ System.out.println(s);
+ }
+ for (String s : lambdas) {
+ System.out.println(s);
+ }
+ }
+}
diff --git a/make/scripts/compare.sh b/make/scripts/compare.sh
index 42886573f..3075f9a82 100644
index 76c3a0684..023299771 100644
--- a/make/scripts/compare.sh
+++ b/make/scripts/compare.sh
@@ -1,6 +1,6 @@
#!/bin/bash
#
-# Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2012, 2022, 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
@@ -324,7 +324,7 @@ compare_general_files() {
@@ -325,7 +325,7 @@ compare_general_files() {
! -name "*.cpl" ! -name "*.pdb" ! -name "*.exp" ! -name "*.ilk" \
! -name "*.lib" ! -name "*.jmod" ! -name "*.exe" \
! -name "*.obj" ! -name "*.o" ! -name "jspawnhelper" ! -name "*.a" \
@ -150,17 +32,6 @@ index 42886573f..3075f9a82 100644
! -name "*.map" \
| $GREP -v "./bin/" | $SORT | $FILTER)
@@ -356,8 +356,8 @@ compare_general_files() {
"
$CAT $OTHER_DIR/$f | eval "$SVG_FILTER" > $OTHER_FILE
$CAT $THIS_DIR/$f | eval "$SVG_FILTER" > $THIS_FILE
- elif [[ "$f" = *"/lib/classlist" ]] || [ "$SUFFIX" = "jar_contents" ]; then
- # The classlist files may have some lines in random order
+ elif [ "$SUFFIX" = "jar_contents" ]; then
+ # The jar_contents files may have some lines in random order
OTHER_FILE=$WORK_DIR/$f.other
THIS_FILE=$WORK_DIR/$f.this
$MKDIR -p $(dirname $OTHER_FILE) $(dirname $THIS_FILE)
diff --git a/src/hotspot/share/cds/archiveBuilder.cpp b/src/hotspot/share/cds/archiveBuilder.cpp
index 699926fcf..8e12cdabb 100644
--- a/src/hotspot/share/cds/archiveBuilder.cpp
@ -292,10 +163,10 @@ index 96b3eb946..5a2cb0e51 100644
void
diff --git a/src/hotspot/share/gc/shared/collectedHeap.hpp b/src/hotspot/share/gc/shared/collectedHeap.hpp
index 10baf8749..8d1087ed3 100644
index e4d444b8c..b65a490cb 100644
--- a/src/hotspot/share/gc/shared/collectedHeap.hpp
+++ b/src/hotspot/share/gc/shared/collectedHeap.hpp
@@ -143,6 +143,7 @@ class CollectedHeap : public CHeapObj<mtInternal> {
@@ -143,6 +143,7 @@ class CollectedHeap : public CHeapObj<mtGC> {
static inline size_t filler_array_hdr_size();
static inline size_t filler_array_min_size();
@ -335,47 +206,33 @@ index 8baba8c38..9057cc072 100644
// We cannot hold the Threads_lock when we throw an exception,
diff --git a/src/hotspot/share/runtime/os.cpp b/src/hotspot/share/runtime/os.cpp
index bb6cea80e..bd5ab658c 100644
index ef43c3170..2fab965bd 100644
--- a/src/hotspot/share/runtime/os.cpp
+++ b/src/hotspot/share/runtime/os.cpp
@@ -674,6 +674,15 @@ static bool has_reached_max_malloc_test_peak(size_t alloc_size) {
return false;
}
@@ -701,11 +710,14 @@ void* os::malloc(size_t size, MEMFLAGS memflags, const NativeCallStack& stack) {
return NULL;
}
+#ifdef ASSERT
+static void break_if_ptr_caught(void* ptr) {
+ if (p2i(ptr) == (intptr_t)MallocCatchPtr) {
+ log_warning(malloc, free)("ptr caught: " PTR_FORMAT, p2i(ptr));
+ breakpoint();
+ }
+}
+#endif // ASSERT
+
void* os::malloc(size_t size, MEMFLAGS flags) {
return os::malloc(size, flags, CALLER_PC);
}
@@ -746,7 +755,15 @@ void* os::malloc(size_t size, MEMFLAGS memflags, const NativeCallStack& stack) {
#endif
// we do not track guard memory
- return MemTracker::record_malloc((address)ptr, size, memflags, stack, level);
+ void* const inner_ptr = MemTracker::record_malloc((address)ptr, size, memflags, stack, level);
- void* inner_ptr = MemTracker::record_malloc((address)outer_ptr, size, memflags, stack, level);
-
- DEBUG_ONLY(::memset(inner_ptr, uninitBlockPad, size);)
+ void* const inner_ptr = MemTracker::record_malloc((address)outer_ptr, size, memflags, stack, level);
+ if (DumpSharedSpaces) {
+ // Need to deterministically fill all the alignment gaps in C++ structures.
+ ::memset(inner_ptr, 0, size);
+ } else {
+ DEBUG_ONLY(::memset(inner_ptr, uninitBlockPad, size);)
+ }
+ DEBUG_ONLY(break_if_ptr_caught(inner_ptr);)
+ return inner_ptr;
DEBUG_ONLY(break_if_ptr_caught(inner_ptr);)
-
return inner_ptr;
}
void* os::realloc(void *memblock, size_t size, MEMFLAGS flags) {
diff --git a/test/hotspot/jtreg/ProblemList.txt b/test/hotspot/jtreg/ProblemList.txt
index 5d43b504f..ebc29f736 100644
index 8d5ea5105..11bbb5545 100644
--- a/test/hotspot/jtreg/ProblemList.txt
+++ b/test/hotspot/jtreg/ProblemList.txt
@@ -86,7 +86,6 @@ gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java 8241293 macosx-x64
@@ -89,7 +89,6 @@ applications/jcstress/acqrel.java 8277434 linux-aarch64
# :hotspot_runtime
runtime/cds/appcds/jigsaw/modulepath/ModulePathAndCP_JFR.java 8253437 windows-x64

View File

@ -0,0 +1,95 @@
Date: Sat, 27 May 2023 17:36:33 +0800
Subject: add
8275509-ModuleDescriptor.hashCode-isn-t-reproducible
---
.../module/ModuleDescriptorHashCodeTest.java | 77 +++++++++++++++++++
1 file changed, 77 insertions(+)
create mode 100644 test/jdk/java/lang/module/ModuleDescriptorHashCodeTest.java
diff --git a/test/jdk/java/lang/module/ModuleDescriptorHashCodeTest.java b/test/jdk/java/lang/module/ModuleDescriptorHashCodeTest.java
new file mode 100644
index 000000000..ef6775e2d
--- /dev/null
+++ b/test/jdk/java/lang/module/ModuleDescriptorHashCodeTest.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2023, 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.
+ */
+
+import org.testng.annotations.Test;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.module.ModuleDescriptor;
+import java.util.Set;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotSame;
+
+/**
+ * @test
+ * @bug 8275509
+ * @run testng ModuleDescriptorHashCodeTest
+ * @run testng/othervm -Xshare:off ModuleDescriptorHashCodeTest
+ * @summary Tests the ModuleDescriptor.hashCode() for boot layer modules
+ */
+public class ModuleDescriptorHashCodeTest {
+
+ /**
+ * Verifies that the ModuleDescriptor.hashCode() returned by a boot layer module is
+ * the same as that returned by a ModuleDescriptor constructed from the ModuleDescriptor.Builder
+ * for the same module.
+ */
+ @Test
+ public void testBootModuleDescriptor() throws Exception {
+ Set<Module> bootModules = ModuleLayer.boot().modules();
+ for (Module bootModule : bootModules) {
+ System.out.println("Testing module descriptor of boot module " + bootModule);
+ ModuleDescriptor bootMD = bootModule.getDescriptor();
+ ModuleDescriptor mdFromBuilder = fromModuleInfoClass(bootModule);
+ // verify that this object is indeed a different object instance than the boot module descriptor
+ // to prevent any artificial passing of the test
+ assertNotSame(mdFromBuilder, bootMD, "ModuleDescriptor loaded from boot layer and " +
+ "one created from module-info.class unexpectedly returned the same instance");
+ assertEquals(mdFromBuilder.hashCode(), bootMD.hashCode(),
+ "Unexpected ModuleDescriptor.hashCode() for " + mdFromBuilder);
+ assertEquals(mdFromBuilder.compareTo(bootMD), 0,
+ "Unexpected ModuleDescriptor.compareTo() for " + mdFromBuilder);
+ }
+ }
+
+ // Returns a ModuleDescriptor parsed out of the module-info.class of the passed Module
+ private static ModuleDescriptor fromModuleInfoClass(Module module) throws IOException {
+ try (InputStream moduleInfo = module.getResourceAsStream("module-info.class")) {
+ if (moduleInfo == null) {
+ throw new RuntimeException("Could not locate module-info.class in " + module);
+ }
+ // internally calls ModuleDescriptor.Builder
+ return ModuleDescriptor.read(moduleInfo);
+ }
+ }
+}
--
2.22.0

View File

@ -0,0 +1,71 @@
From dcae455d23cd5a5f3c16b8a00547d85d170ebe4b Mon Sep 17 00:00:00 2001
Date: Mon, 6 Feb 2023 17:17:56 +0800
Subject: [PATCH] 8275509: ModuleDescriptor.hashCode isn't reproducible across
builds
---
.../java/lang/module/ModuleDescriptor.java | 20 +++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/src/java.base/share/classes/java/lang/module/ModuleDescriptor.java b/src/java.base/share/classes/java/lang/module/ModuleDescriptor.java
index 93ac73656..39f68ac95 100644
--- a/src/java.base/share/classes/java/lang/module/ModuleDescriptor.java
+++ b/src/java.base/share/classes/java/lang/module/ModuleDescriptor.java
@@ -327,7 +327,7 @@ public class ModuleDescriptor
*/
@Override
public int hashCode() {
- int hash = name.hashCode() * 43 + mods.hashCode();
+ int hash = name.hashCode() * 43 + modsHashCode(mods);
if (compiledVersion != null)
hash = hash * 43 + compiledVersion.hashCode();
if (rawCompiledVersion != null)
@@ -505,7 +505,7 @@ public class ModuleDescriptor
*/
@Override
public int hashCode() {
- int hash = mods.hashCode();
+ int hash = modsHashCode(mods);
hash = hash * 43 + source.hashCode();
return hash * 43 + targets.hashCode();
}
@@ -708,7 +708,7 @@ public class ModuleDescriptor
*/
@Override
public int hashCode() {
- int hash = mods.hashCode();
+ int hash = modsHashCode(mods);
hash = hash * 43 + source.hashCode();
return hash * 43 + targets.hashCode();
}
@@ -2261,7 +2261,7 @@ public class ModuleDescriptor
int hc = hash;
if (hc == 0) {
hc = name.hashCode();
- hc = hc * 43 + Objects.hashCode(modifiers);
+ hc = hc * 43 + modsHashCode(modifiers);
hc = hc * 43 + requires.hashCode();
hc = hc * 43 + Objects.hashCode(packages);
hc = hc * 43 + exports.hashCode();
@@ -2546,6 +2546,18 @@ public class ModuleDescriptor
.collect(Collectors.joining(" "));
}
+ /**
+ * Generates and returns a hashcode for the enum instances. The returned hashcode
+ * is a value based on the {@link Enum#name() name} of each enum instance.
+ */
+ private static int modsHashCode(Iterable<? extends Enum<?>> enums) {
+ int h = 0;
+ for (Enum<?> e : enums) {
+ h = h * 43 + Objects.hashCode(e.name());
+ }
+ return h;
+ }
+
private static <T extends Object & Comparable<? super T>>
int compare(T obj1, T obj2) {
if (obj1 != null) {
--
2.23.0

View File

@ -0,0 +1,351 @@
diff --git a/src/hotspot/cpu/aarch64/aarch64.ad b/src/hotspot/cpu/aarch64/aarch64.ad
index b3d89863e..8df709ad0 100644
--- a/src/hotspot/cpu/aarch64/aarch64.ad
+++ b/src/hotspot/cpu/aarch64/aarch64.ad
@@ -1279,12 +1279,12 @@ class HandlerImpl {
static int emit_deopt_handler(CodeBuffer& cbuf);
static uint size_exception_handler() {
- return MacroAssembler::far_codestub_branch_size();
+ return MacroAssembler::far_branch_size();
}
static uint size_deopt_handler() {
// count one adr and one far branch instruction
- return NativeInstruction::instruction_size + MacroAssembler::far_codestub_branch_size();
+ return 4 * NativeInstruction::instruction_size;
}
};
@@ -2367,7 +2367,7 @@ int HandlerImpl::emit_deopt_handler(CodeBuffer& cbuf)
__ adr(lr, __ pc());
__ far_jump(RuntimeAddress(SharedRuntime::deopt_blob()->unpack()));
- assert(__ offset() - offset == (int) size_deopt_handler(), "overflow");
+ assert(__ offset() - offset <= (int) size_deopt_handler(), "overflow");
__ end_a_stub();
return offset;
}
diff --git a/src/hotspot/cpu/aarch64/icBuffer_aarch64.cpp b/src/hotspot/cpu/aarch64/icBuffer_aarch64.cpp
index 7d0483fb3..21c2a3cc7 100644
--- a/src/hotspot/cpu/aarch64/icBuffer_aarch64.cpp
+++ b/src/hotspot/cpu/aarch64/icBuffer_aarch64.cpp
@@ -52,15 +52,9 @@ void InlineCacheBuffer::assemble_ic_buffer_code(address code_begin, void* cached
address start = __ pc();
Label l;
__ ldr(rscratch2, l);
- int jump_code_size = __ far_jump(ExternalAddress(entry_point));
- // IC stub code size is not expected to vary depending on target address.
- // We use NOPs to make the [ldr + far_jump + nops + int64] stub size equal to ic_stub_code_size.
- for (int size = NativeInstruction::instruction_size + jump_code_size + 8;
- size < ic_stub_code_size(); size += NativeInstruction::instruction_size) {
- __ nop();
- }
+ __ far_jump(ExternalAddress(entry_point));
+ __ align(wordSize);
__ bind(l);
- assert((uintptr_t)__ pc() % wordSize == 0, "");
__ emit_int64((int64_t)cached_value);
// Only need to invalidate the 1st two instructions - not the whole ic stub
ICache::invalidate_range(code_begin, InlineCacheBuffer::ic_stub_code_size());
diff --git a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp
index d89d655af..9e84077f9 100644
--- a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp
+++ b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp
@@ -397,27 +397,14 @@ void MacroAssembler::set_last_Java_frame(Register last_java_sp,
}
}
-static inline bool target_needs_far_branch(address addr) {
- // codecache size <= 128M
- if (!MacroAssembler::far_branches()) {
- return false;
- }
- // codecache size > 240M
- if (MacroAssembler::codestub_branch_needs_far_jump()) {
- return true;
- }
- // codecache size: 128M..240M
- return !CodeCache::is_non_nmethod(addr);
-}
-
void MacroAssembler::far_call(Address entry, CodeBuffer *cbuf, Register tmp) {
assert(ReservedCodeCacheSize < 4*G, "branch out of range");
assert(CodeCache::find_blob(entry.target()) != NULL,
"destination of far call not found in code cache");
- if (target_needs_far_branch(entry.target())) {
+ if (far_branches()) {
uint64_t offset;
// We can use ADRP here because we know that the total size of
- // the code cache cannot exceed 2Gb (ADRP limit is 4GB).
+ // the code cache cannot exceed 2Gb.
adrp(tmp, entry, offset);
add(tmp, tmp, offset);
if (cbuf) cbuf->set_insts_mark();
@@ -428,15 +415,14 @@ void MacroAssembler::far_call(Address entry, CodeBuffer *cbuf, Register tmp) {
}
}
-int MacroAssembler::far_jump(Address entry, CodeBuffer *cbuf, Register tmp) {
+void MacroAssembler::far_jump(Address entry, CodeBuffer *cbuf, Register tmp) {
assert(ReservedCodeCacheSize < 4*G, "branch out of range");
assert(CodeCache::find_blob(entry.target()) != NULL,
"destination of far call not found in code cache");
- address start = pc();
- if (target_needs_far_branch(entry.target())) {
+ if (far_branches()) {
uint64_t offset;
// We can use ADRP here because we know that the total size of
- // the code cache cannot exceed 2Gb (ADRP limit is 4GB).
+ // the code cache cannot exceed 2Gb.
adrp(tmp, entry, offset);
add(tmp, tmp, offset);
if (cbuf) cbuf->set_insts_mark();
@@ -445,7 +431,6 @@ int MacroAssembler::far_jump(Address entry, CodeBuffer *cbuf, Register tmp) {
if (cbuf) cbuf->set_insts_mark();
b(entry);
}
- return pc() - start;
}
void MacroAssembler::reserved_stack_check() {
diff --git a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp
index e403289e2..06733edd6 100644
--- a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp
+++ b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp
@@ -1086,18 +1086,13 @@ public:
return ReservedCodeCacheSize > branch_range;
}
- // Check if branches to the the non nmethod section require a far jump
- static bool codestub_branch_needs_far_jump() {
- return CodeCache::max_distance_to_non_nmethod() > branch_range;
- }
-
// Jumps that can reach anywhere in the code cache.
// Trashes tmp.
void far_call(Address entry, CodeBuffer *cbuf = NULL, Register tmp = rscratch1);
- int far_jump(Address entry, CodeBuffer *cbuf = NULL, Register tmp = rscratch1);
+ void far_jump(Address entry, CodeBuffer *cbuf = NULL, Register tmp = rscratch1);
- static int far_codestub_branch_size() {
- if (codestub_branch_needs_far_jump()) {
+ static int far_branch_size() {
+ if (far_branches()) {
return 3 * 4; // adrp, add, br
} else {
return 4;
diff --git a/src/hotspot/share/code/codeCache.cpp b/src/hotspot/share/code/codeCache.cpp
index 28158adbc..1c6aa37b8 100644
--- a/src/hotspot/share/code/codeCache.cpp
+++ b/src/hotspot/share/code/codeCache.cpp
@@ -296,20 +296,19 @@ void CodeCache::initialize_heaps() {
const size_t alignment = MAX2(page_size(false, 8), (size_t) os::vm_allocation_granularity());
non_nmethod_size = align_up(non_nmethod_size, alignment);
profiled_size = align_down(profiled_size, alignment);
- non_profiled_size = align_down(non_profiled_size, alignment);
// Reserve one continuous chunk of memory for CodeHeaps and split it into
// parts for the individual heaps. The memory layout looks like this:
// ---------- high -----------
// Non-profiled nmethods
- // Non-nmethods
// Profiled nmethods
+ // Non-nmethods
// ---------- low ------------
ReservedCodeSpace rs = reserve_heap_memory(cache_size);
- ReservedSpace profiled_space = rs.first_part(profiled_size);
- ReservedSpace rest = rs.last_part(profiled_size);
- ReservedSpace non_method_space = rest.first_part(non_nmethod_size);
- ReservedSpace non_profiled_space = rest.last_part(non_nmethod_size);
+ ReservedSpace non_method_space = rs.first_part(non_nmethod_size);
+ ReservedSpace rest = rs.last_part(non_nmethod_size);
+ ReservedSpace profiled_space = rest.first_part(profiled_size);
+ ReservedSpace non_profiled_space = rest.last_part(profiled_size);
// Non-nmethods (stubs, adapters, ...)
add_heap(non_method_space, "CodeHeap 'non-nmethods'", CodeBlobType::NonNMethod);
@@ -899,23 +898,6 @@ size_t CodeCache::max_capacity() {
return max_cap;
}
-bool CodeCache::is_non_nmethod(address addr) {
- CodeHeap* blob = get_code_heap(CodeBlobType::NonNMethod);
- return blob->contains(addr);
-}
-
-size_t CodeCache::max_distance_to_non_nmethod() {
- if (!SegmentedCodeCache) {
- return ReservedCodeCacheSize;
- } else {
- CodeHeap* blob = get_code_heap(CodeBlobType::NonNMethod);
- // the max distance is minimized by placing the NonNMethod segment
- // in between MethodProfiled and MethodNonProfiled segments
- size_t dist1 = (size_t)blob->high() - (size_t)_low_bound;
- size_t dist2 = (size_t)_high_bound - (size_t)blob->low();
- return dist1 > dist2 ? dist1 : dist2;
- }
-}
// Returns the reverse free ratio. E.g., if 25% (1/4) of the code cache
// is free, reverse_free_ratio() returns 4.
diff --git a/src/hotspot/share/code/codeCache.hpp b/src/hotspot/share/code/codeCache.hpp
index ca3bae1df..b1219de48 100644
--- a/src/hotspot/share/code/codeCache.hpp
+++ b/src/hotspot/share/code/codeCache.hpp
@@ -213,9 +213,6 @@ class CodeCache : AllStatic {
static double reverse_free_ratio();
- static size_t max_distance_to_non_nmethod();
- static bool is_non_nmethod(address addr);
-
static void clear_inline_caches(); // clear all inline caches
static void cleanup_inline_caches(); // clean unloaded/zombie nmethods from inline caches
diff --git a/test/hotspot/jtreg/compiler/c2/aarch64/TestFarJump.java b/test/hotspot/jtreg/compiler/c2/aarch64/TestFarJump.java
deleted file mode 100644
index f47331a6d..000000000
--- a/test/hotspot/jtreg/compiler/c2/aarch64/TestFarJump.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Copyright (c) 2022, BELLSOFT. All rights reserved.
- * 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.c2.aarch64;
-
-import jdk.test.lib.process.OutputAnalyzer;
-import jdk.test.lib.process.ProcessTools;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import java.util.*;
-
-/*
- * @test
- * @bug 8280872
- * @summary Far call to runtime stub should be generated with single instruction for CodeHeap up to 250MB
- * @library /test/lib /
- *
- * @requires vm.flagless
- * @requires os.arch=="aarch64"
- * @requires vm.debug == false
- * @requires vm.compiler2.enabled
- *
- * @run driver compiler.c2.aarch64.TestFarJump
- */
-public class TestFarJump {
-
- // ADRP instruction encoding:
- // |31 30 29 28|27 26 25 24|23 22 21 20|19 18 17 16|15 14 13 12|11 10 09 08|07 06 05 04|03 02 01 10|
- // | 1|immlo| 1 0 0 0 0| immhi | Rd |
- static boolean isADRP(int encoding) {
- final int mask = 0b1001_1111;
- final int val = 0b1001_0000;
- return ((encoding >> 24) & mask) == val;
- }
-
- // Looking for adrp instruction in binary/text assembly output:
- // 0x0000ffff7ff1b7d0: c8ff ffd0 | 0801 1091 | 0001 1fd6
- // 0x0000ffff6bf20ee0: adrp x8, 0x0000ffff6bef1000
- static boolean containsADRP(String input) {
- int index = input.indexOf(": ");
- if (index == -1) {
- return false;
- }
- input = input.substring(index + 1);
- if (input.contains("adrp")) {
- return true;
- }
- Pattern pattern = Pattern.compile("[0-9a-f ]*");
- Matcher matcher = pattern.matcher(input);
- while (matcher.find()) {
- String match = matcher.group();
- match = match.replace(" " , "");
- if (match.length() != 8) {
- continue;
- }
- int dump = (int)Long.parseLong(match, 16);
- int encoding = Integer.reverseBytes(dump);
- // Check the first instruction only. The raw pointer can be confused with the encoded adrp instruction:
- // emit_exception_handler() = far_call() + should_not_reach_here() = ADRP + ADD + BLR + DCPS1 + raw_pointer
- return isADRP(encoding);
- }
- return false;
- }
-
- static void runVM(boolean bigCodeHeap) throws Exception {
- String className = TestFarJump.class.getName();
- String[] procArgs = {
- "-XX:-Inline",
- "-Xcomp",
- "-Xbatch",
- "-XX:+TieredCompilation",
- "-XX:+SegmentedCodeCache",
- "-XX:CompileOnly=" + className + "::main",
- "-XX:ReservedCodeCacheSize=" + (bigCodeHeap ? "256M" : "200M"),
- "-XX:+UnlockDiagnosticVMOptions",
- "-XX:+PrintAssembly",
- className};
-
- ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(procArgs);
- OutputAnalyzer output = new OutputAnalyzer(pb.start());
- List<String> lines = output.asLines();
-
- ListIterator<String> itr = lines.listIterator();
- while (itr.hasNext()) {
- String line = itr.next();
- if (line.contains("[Exception Handler]")) {
- String next1 = itr.next();
- String next2 = itr.next();
- System.out.println(line);
- System.out.println(next1);
- System.out.println(next2);
- boolean containsADRP = containsADRP(next1) || containsADRP(next2);
- if (bigCodeHeap && !containsADRP) {
- throw new RuntimeException("ADRP instruction is expected on far jump");
- }
- if (!bigCodeHeap && containsADRP) {
- throw new RuntimeException("for CodeHeap < 250MB the far jump is expected to be encoded with a single branch instruction");
- }
- return;
- }
- }
- throw new RuntimeException("Assembly output: exception Handler is not found");
- }
-
- public static void main(String[] args) throws Exception {
- if (args.length == 0) {
- // Main VM: fork VM with options
- runVM(true);
- runVM(false);
- return;
- }
- if (args.length > 0) {
- // We are in a forked VM. Just exit
- System.out.println("Ok");
- }
- }
-}
-
--
2.39.0

View File

@ -0,0 +1,33 @@
From f7d209ac613d5736ab42ba38232a2cab05b28c07 Mon Sep 17 00:00:00 2001
Subject: 8285516:clearPassword should be called in a finally try block
---
.../share/classes/sun/security/pkcs12/PKCS12KeyStore.java | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/java.base/share/classes/sun/security/pkcs12/PKCS12KeyStore.java b/src/java.base/share/classes/sun/security/pkcs12/PKCS12KeyStore.java
index 07f1145e8..12afa2f94 100644
--- a/src/java.base/share/classes/sun/security/pkcs12/PKCS12KeyStore.java
+++ b/src/java.base/share/classes/sun/security/pkcs12/PKCS12KeyStore.java
@@ -864,14 +864,14 @@ public final class PKCS12KeyStore extends KeyStoreSpi {
{
SecretKey skey = null;
+ PBEKeySpec keySpec = new PBEKeySpec(password);
try {
- PBEKeySpec keySpec = new PBEKeySpec(password);
SecretKeyFactory skFac = SecretKeyFactory.getInstance("PBE");
skey = skFac.generateSecret(keySpec);
- keySpec.clearPassword();
} catch (Exception e) {
- throw new IOException("getSecretKey failed: " +
- e.getMessage(), e);
+ throw new IOException("getSecretKey failed: " + e.getMessage(), e);
+ } finally {
+ keySpec.clearPassword();
}
return skey;
}
--
2.22.0

View File

@ -1,145 +0,0 @@
diff --git a/src/hotspot/share/opto/stringopts.cpp b/src/hotspot/share/opto/stringopts.cpp
index 8c0a060d8..78317fe0a 100644
--- a/src/hotspot/share/opto/stringopts.cpp
+++ b/src/hotspot/share/opto/stringopts.cpp
@@ -1030,6 +1030,21 @@ bool StringConcat::validate_control_flow() {
fail = true;
break;
} else if (ptr->is_Proj() && ptr->in(0)->is_Initialize()) {
+ // Check for side effect between Initialize and the constructor
+ for (SimpleDUIterator iter(ptr); iter.has_next(); iter.next()) {
+ Node* use = iter.get();
+ if (!use->is_CFG() && !use->is_CheckCastPP() && !use->is_Load()) {
+#ifndef PRODUCT
+ if (PrintOptimizeStringConcat) {
+ tty->print_cr("unexpected control use of Initialize");
+ ptr->in(0)->dump(); // Initialize node
+ use->dump(1);
+ }
+#endif
+ fail = true;
+ break;
+ }
+ }
ptr = ptr->in(0)->in(0);
} else if (ptr->is_Region()) {
Node* copy = ptr->as_Region()->is_copy();
diff --git a/test/hotspot/jtreg/compiler/stringopts/SideEffectBeforeConstructor.jasm b/test/hotspot/jtreg/compiler/stringopts/SideEffectBeforeConstructor.jasm
new file mode 100644
index 000000000..cbc6d754b
--- /dev/null
+++ b/test/hotspot/jtreg/compiler/stringopts/SideEffectBeforeConstructor.jasm
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2022, 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 compiler/stringopts/SideEffectBeforeConstructor
+ version 51:0
+{
+ public static Field result:I;
+
+ static Method "<clinit>":"()V"
+ stack 2 locals 0
+ {
+ iconst_0;
+ putstatic Field result:"I";
+ return;
+ }
+ public Method "<init>":"()V"
+ stack 1 locals 1
+ {
+ aload_0;
+ invokespecial Method java/lang/Object."<init>":"()V";
+ return;
+ }
+
+ public static Method test:"(Ljava/lang/String;)V"
+ stack 4 locals 1
+ {
+ new class java/lang/StringBuffer;
+ dup;
+ getstatic Field result:"I";
+ iconst_1;
+ iadd;
+ putstatic Field result:"I";
+ aload_0;
+ invokespecial Method java/lang/StringBuffer."<init>":"(Ljava/lang/String;)V";
+ invokevirtual Method java/lang/StringBuffer.toString:"()Ljava/lang/String;";
+ return;
+ }
+}
diff --git a/test/hotspot/jtreg/compiler/stringopts/TestSideEffectBeforeConstructor.java b/test/hotspot/jtreg/compiler/stringopts/TestSideEffectBeforeConstructor.java
new file mode 100644
index 000000000..86c5eca1d
--- /dev/null
+++ b/test/hotspot/jtreg/compiler/stringopts/TestSideEffectBeforeConstructor.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2022, 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 8290705
+ * @summary Test correctness of the string concatenation optimization with
+ * a store between StringBuffer allocation and constructor invocation.
+ * @compile SideEffectBeforeConstructor.jasm
+ * @run main/othervm -Xbatch compiler.stringopts.TestSideEffectBeforeConstructor
+ */
+
+package compiler.stringopts;
+
+public class TestSideEffectBeforeConstructor {
+
+ public static void main(String[] args) {
+ for (int i = 0; i < 100_000; ++i) {
+ try {
+ SideEffectBeforeConstructor.test(null);
+ } catch (NullPointerException npe) {
+ // Expected
+ }
+ }
+ if (SideEffectBeforeConstructor.result != 100_000) {
+ throw new RuntimeException("Unexpected result: " + SideEffectBeforeConstructor.result);
+ }
+ }
+}

View File

@ -0,0 +1,23 @@
From 32dbeb16c3fd9e63ebc16b69861b15bb6d2f48bb Mon Sep 17 00:00:00 2001
Subject: 8295068: SSLEngine throws NPE parsing CertificateRequests
---
.../share/classes/sun/security/ssl/CertificateRequest.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/java.base/share/classes/sun/security/ssl/CertificateRequest.java b/src/java.base/share/classes/sun/security/ssl/CertificateRequest.java
index 4def03c67..1f6147e4a 100644
--- a/src/java.base/share/classes/sun/security/ssl/CertificateRequest.java
+++ b/src/java.base/share/classes/sun/security/ssl/CertificateRequest.java
@@ -136,7 +136,7 @@ final class CertificateRequest {
ArrayList<String> keyTypes = new ArrayList<>(3);
for (byte id : ids) {
ClientCertificateType cct = ClientCertificateType.valueOf(id);
- if (cct.isAvailable) {
+ if (cct != null && cct.isAvailable) {
cct.keyAlgorithm.forEach(key -> {
if (!keyTypes.contains(key)) {
keyTypes.add(key);
--
2.22.0

View File

@ -1,42 +0,0 @@
From c40df7ed8cb6d6c0f687c1d68071729fab7c1b2d Mon Sep 17 00:00:00 2001
Date: Wed, 4 Jan 2023 20:42:04 +0800
Subject: 8296480: Fix the problem that the TestPolicy.java
case fails because the certificate expires.
---
.../java/security/cert/pkix/policyChanges/TestPolicy.java | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/test/jdk/java/security/cert/pkix/policyChanges/TestPolicy.java b/test/jdk/java/security/cert/pkix/policyChanges/TestPolicy.java
index a92eee2c5..de2f94d27 100644
--- a/test/jdk/java/security/cert/pkix/policyChanges/TestPolicy.java
+++ b/test/jdk/java/security/cert/pkix/policyChanges/TestPolicy.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2022, 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 @@
*/
import java.io.*;
+import java.text.DateFormat;
import java.util.*;
import java.security.Security;
@@ -97,6 +98,10 @@ public class TestPolicy {
params.setRevocationEnabled(false);
params.setInitialPolicies(testCase.initialPolicies);
+ // Certs expired on 7th Nov 2022
+ params.setDate(DateFormat.getDateInstance(DateFormat.MEDIUM,
+ Locale.US).parse("June 01, 2022"));
+
CertPath path = factory.generateCertPath(Arrays.asList(new X509Certificate[] {ee, ca}));
PKIXCertPathValidatorResult result = (PKIXCertPathValidatorResult)validator.validate(path, params);
--
2.37.0

View File

@ -1,40 +0,0 @@
From 59bc22bb9d2cdcc7d12d163c30432bd8c9d2c976 Mon Sep 17 00:00:00 2001
Date: Wed, 4 Jan 2023 20:44:46 +0800
Subject: 8296485: BuildEEBasicConstraints.java test fails
with SunCertPathBuilderException
---
.../targetConstraints/BuildEEBasicConstraints.java | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/test/jdk/java/security/cert/CertPathBuilder/targetConstraints/BuildEEBasicConstraints.java b/test/jdk/java/security/cert/CertPathBuilder/targetConstraints/BuildEEBasicConstraints.java
index c7cc90f95..edb68cf29 100644
--- a/test/jdk/java/security/cert/CertPathBuilder/targetConstraints/BuildEEBasicConstraints.java
+++ b/test/jdk/java/security/cert/CertPathBuilder/targetConstraints/BuildEEBasicConstraints.java
@@ -45,9 +45,11 @@ import java.security.cert.PKIXCertPathBuilderResult;
import java.security.cert.TrustAnchor;
import java.security.cert.X509Certificate;
import java.security.cert.X509CertSelector;
+import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import java.util.Locale;
import jdk.test.lib.security.CertUtils;
public final class BuildEEBasicConstraints {
@@ -65,6 +67,11 @@ public final class BuildEEBasicConstraints {
PKIXBuilderParameters params = new PKIXBuilderParameters
(Collections.singleton(anchor), sel);
params.setRevocationEnabled(false);
+
+ // Certs expired on 7th Nov 2022
+ params.setDate(DateFormat.getDateInstance(DateFormat.MEDIUM,
+ Locale.US).parse("June 01, 2022"));
+
X509Certificate eeCert = CertUtils.getCertFromFile("ee.cer");
X509Certificate caCert = CertUtils.getCertFromFile("ca.cer");
ArrayList<X509Certificate> certs = new ArrayList<X509Certificate>();
--
2.37.0

View File

@ -0,0 +1,175 @@
Date: Sat, 27 May 2023 17:40:53 +0800
Subject: add
8302595-use-after-free-related-to-GraphKit-clone_map.patch
---
src/hotspot/share/opto/compile.hpp | 3 ++-
src/hotspot/share/opto/graphKit.cpp | 23 +++++++++++++++++++++
src/hotspot/share/opto/graphKit.hpp | 7 ++++++-
src/hotspot/share/opto/library_call.cpp | 6 +++---
src/hotspot/share/opto/node.hpp | 5 +++++
src/hotspot/share/opto/phaseX.hpp | 5 +++++
src/hotspot/share/opto/vectorIntrinsics.cpp | 4 ++--
7 files changed, 46 insertions(+), 7 deletions(-)
diff --git a/src/hotspot/share/opto/compile.hpp b/src/hotspot/share/opto/compile.hpp
index 6e5f2ed23..b7c18b337 100644
--- a/src/hotspot/share/opto/compile.hpp
+++ b/src/hotspot/share/opto/compile.hpp
@@ -921,7 +921,8 @@ class Compile : public Phase {
// Parsing, optimization
PhaseGVN* initial_gvn() { return _initial_gvn; }
Unique_Node_List* for_igvn() { return _for_igvn; }
- inline void record_for_igvn(Node* n); // Body is after class Unique_Node_List.
+ inline void record_for_igvn(Node* n); // Body is after class Unique_Node_List in node.hpp.
+ inline void remove_for_igvn(Node* n); // Body is after class Unique_Node_List in node.hpp.
void set_initial_gvn(PhaseGVN *gvn) { _initial_gvn = gvn; }
void set_for_igvn(Unique_Node_List *for_igvn) { _for_igvn = for_igvn; }
diff --git a/src/hotspot/share/opto/graphKit.cpp b/src/hotspot/share/opto/graphKit.cpp
index a3df43c23..07d1999b2 100644
--- a/src/hotspot/share/opto/graphKit.cpp
+++ b/src/hotspot/share/opto/graphKit.cpp
@@ -738,6 +738,29 @@ SafePointNode* GraphKit::clone_map() {
return clonemap;
}
+// -----------------------------destruct_map_clone------------------------------
+// Order of destruct is important to increase the likelyhood that memory can be re-used. We need
+// to destruct/free/delete in the exact opposite order as clone_map().
+void GraphKit::destruct_map_clone(SafePointNode* sfp) {
+ if (sfp == nullptr) return;
+
+ Node* mem = sfp->memory();
+ JVMState* jvms = sfp->jvms();
+
+ if (jvms != nullptr) {
+ delete jvms;
+ }
+
+ remove_for_igvn(sfp);
+ gvn().clear_type(sfp);
+ sfp->destruct(&_gvn);
+
+ if (mem != nullptr) {
+ gvn().clear_type(mem);
+ mem->destruct(&_gvn);
+ }
+}
+
//-----------------------------set_map_clone-----------------------------------
void GraphKit::set_map_clone(SafePointNode* m) {
diff --git a/src/hotspot/share/opto/graphKit.hpp b/src/hotspot/share/opto/graphKit.hpp
index d815e2195..22f868442 100644
--- a/src/hotspot/share/opto/graphKit.hpp
+++ b/src/hotspot/share/opto/graphKit.hpp
@@ -94,7 +94,7 @@ class GraphKit : public Phase {
void* barrier_set_state() const { return C->barrier_set_state(); }
void record_for_igvn(Node* n) const { C->record_for_igvn(n); } // delegate to Compile
-
+ void remove_for_igvn(Node* n) const { C->remove_for_igvn(n); }
// Handy well-known nodes:
Node* null() const { return zerocon(T_OBJECT); }
Node* top() const { return C->top(); }
@@ -170,6 +170,11 @@ class GraphKit : public Phase {
// Clone the existing map state. (Implements PreserveJVMState.)
SafePointNode* clone_map();
+ // Reverses the work done by clone_map(). Should only be used when the node returned by
+ // clone_map() is ultimately not used. Calling Node::destruct directly in the previously
+ // mentioned circumstance instead of this method may result in use-after-free.
+ void destruct_map_clone(SafePointNode* sfp);
+
// Set the map to a clone of the given one.
void set_map_clone(SafePointNode* m);
diff --git a/src/hotspot/share/opto/library_call.cpp b/src/hotspot/share/opto/library_call.cpp
index b5970545c..2dd246093 100644
--- a/src/hotspot/share/opto/library_call.cpp
+++ b/src/hotspot/share/opto/library_call.cpp
@@ -1563,7 +1563,7 @@ bool LibraryCallKit::inline_string_char_access(bool is_store) {
set_sp(old_sp);
return false;
}
- old_map->destruct(&_gvn);
+ destruct_map_clone(old_map);
if (is_store) {
access_store_at(value, adr, TypeAryPtr::BYTES, ch, TypeInt::CHAR, T_CHAR, IN_HEAP | MO_UNORDERED | C2_MISMATCHED);
} else {
@@ -2346,7 +2346,7 @@ bool LibraryCallKit::inline_unsafe_access(bool is_store, const BasicType type, c
mismatched = true; // conservatively mark all "wide" on-heap accesses as mismatched
}
- old_map->destruct(&_gvn);
+ destruct_map_clone(old_map);
assert(!mismatched || alias_type->adr_type()->is_oopptr(), "off-heap access can't be mismatched");
if (mismatched) {
@@ -2597,7 +2597,7 @@ bool LibraryCallKit::inline_unsafe_load_store(const BasicType type, const LoadSt
return false;
}
- old_map->destruct(&_gvn);
+ destruct_map_clone(old_map);
// For CAS, unlike inline_unsafe_access, there seems no point in
// trying to refine types. Just use the coarse types here.
diff --git a/src/hotspot/share/opto/node.hpp b/src/hotspot/share/opto/node.hpp
index 2a78e259d..b79e7673f 100644
--- a/src/hotspot/share/opto/node.hpp
+++ b/src/hotspot/share/opto/node.hpp
@@ -1647,6 +1647,11 @@ inline void Compile::record_for_igvn(Node* n) {
_for_igvn->push(n);
}
+// Inline definition of Compile::remove_for_igvn must be deferred to this point.
+inline void Compile::remove_for_igvn(Node* n) {
+ _for_igvn->remove(n);
+}
+
//------------------------------Node_Stack-------------------------------------
class Node_Stack {
friend class VMStructs;
diff --git a/src/hotspot/share/opto/phaseX.hpp b/src/hotspot/share/opto/phaseX.hpp
index 6d0d8ca46..252761161 100644
--- a/src/hotspot/share/opto/phaseX.hpp
+++ b/src/hotspot/share/opto/phaseX.hpp
@@ -238,6 +238,11 @@ public:
assert(t != NULL, "type must not be null");
_types.map(n->_idx, t);
}
+ void clear_type(const Node* n) {
+ if (n->_idx < _types.Size()) {
+ _types.map(n->_idx, NULL);
+ }
+ }
// Record an initial type for a node, the node's bottom type.
void set_type_bottom(const Node* n) {
// Use this for initialization when bottom_type() (or better) is not handy.
diff --git a/src/hotspot/share/opto/vectorIntrinsics.cpp b/src/hotspot/share/opto/vectorIntrinsics.cpp
index 06f491419..92f292438 100644
--- a/src/hotspot/share/opto/vectorIntrinsics.cpp
+++ b/src/hotspot/share/opto/vectorIntrinsics.cpp
@@ -868,7 +868,7 @@ bool LibraryCallKit::inline_vector_mem_operation(bool is_store) {
set_result(box);
}
- old_map->destruct(&_gvn);
+ destruct_map_clone(old_map);
if (can_access_non_heap) {
insert_mem_bar(Op_MemBarCPUOrder);
@@ -1006,7 +1006,7 @@ bool LibraryCallKit::inline_vector_gather_scatter(bool is_scatter) {
set_result(box);
}
- old_map->destruct(&_gvn);
+ destruct_map_clone(old_map);
C->set_max_vector_size(MAX2(C->max_vector_size(), (uint)(num_elem * type2aelembytes(elem_bt))));
return true;
--
2.22.0

View File

@ -0,0 +1,24 @@
Date: Sat, 27 May 2023 17:39:02 +0800
Subject: add
8303069-Memory-leak-in-CompilerOracle-parse_from_lin.patch
---
src/hotspot/share/compiler/compilerOracle.cpp | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/hotspot/share/compiler/compilerOracle.cpp b/src/hotspot/share/compiler/compilerOracle.cpp
index 69a327873..5149121c5 100644
--- a/src/hotspot/share/compiler/compilerOracle.cpp
+++ b/src/hotspot/share/compiler/compilerOracle.cpp
@@ -308,6 +308,8 @@ static void register_command(TypedMethodOptionMatcher* matcher,
if (option == CompileCommand::Blackhole && !UnlockExperimentalVMOptions) {
warning("Blackhole compile option is experimental and must be enabled via -XX:+UnlockExperimentalVMOptions");
+ // Delete matcher as we don't keep it
+ delete matcher;
return;
}
--
2.22.0

View File

@ -0,0 +1,29 @@
Date: Sat, 27 May 2023 17:40:24 +0800
Subject: add
8304683-Memory-leak-in-WB_IsMethodCompatible.patch
---
src/hotspot/share/prims/whitebox.cpp | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/src/hotspot/share/prims/whitebox.cpp b/src/hotspot/share/prims/whitebox.cpp
index 296bfe9e4..f6c947f13 100644
--- a/src/hotspot/share/prims/whitebox.cpp
+++ b/src/hotspot/share/prims/whitebox.cpp
@@ -821,10 +821,9 @@ static bool is_excluded_for_compiler(AbstractCompiler* comp, methodHandle& mh) {
return true;
}
DirectiveSet* directive = DirectivesStack::getMatchingDirective(mh, comp);
- if (directive->ExcludeOption) {
- return true;
- }
- return false;
+ bool exclude = directive->ExcludeOption;
+ DirectivesStack::release(directive);
+ return exclude;
}
static bool can_be_compiled_at_level(methodHandle& mh, jboolean is_osr, int level) {
--
2.22.0

View File

@ -0,0 +1,260 @@
Date: Sat, 27 May 2023 17:38:35 +0800
Subject: add
8305541-C2-Div-Mod-nodes-without-zero-check-could-be.patch
---
src/hotspot/share/opto/loopnode.hpp | 3 +
src/hotspot/share/opto/loopopts.cpp | 42 ++++-
.../c2/TestSplitDivisionThroughPhi.java | 161 ++++++++++++++++++
3 files changed, 205 insertions(+), 1 deletion(-)
create mode 100644 test/hotspot/jtreg/compiler/c2/TestSplitDivisionThroughPhi.java
diff --git a/src/hotspot/share/opto/loopnode.hpp b/src/hotspot/share/opto/loopnode.hpp
index ebc3bd1db..0db6d0881 100644
--- a/src/hotspot/share/opto/loopnode.hpp
+++ b/src/hotspot/share/opto/loopnode.hpp
@@ -1506,6 +1506,9 @@ private:
void try_move_store_after_loop(Node* n);
bool identical_backtoback_ifs(Node *n);
bool can_split_if(Node *n_ctrl);
+ bool cannot_split_division(const Node* n, const Node* region) const;
+ static bool is_divisor_counted_loop_phi(const Node* divisor, const Node* loop);
+ bool loop_phi_backedge_type_contains_zero(const Node* phi_divisor, const Type* zero) const;
// Determine if a method is too big for a/another round of split-if, based on
// a magic (approximate) ratio derived from the equally magic constant 35000,
diff --git a/src/hotspot/share/opto/loopopts.cpp b/src/hotspot/share/opto/loopopts.cpp
index c0804ed67..9e0f1b2d2 100644
--- a/src/hotspot/share/opto/loopopts.cpp
+++ b/src/hotspot/share/opto/loopopts.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2023, 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
@@ -61,6 +61,10 @@ Node* PhaseIdealLoop::split_thru_phi(Node* n, Node* region, int policy) {
return NULL;
}
+ if (cannot_split_division(n, region)) {
+ return NULL;
+ }
+
// Bail out if 'n' is a Div or Mod node whose zero check was removed earlier (i.e. control is NULL) and its divisor is an induction variable
// phi p of a trip-counted (integer) loop whose inputs could be zero (include zero in their type range). p could have a more precise type
// range that does not necessarily include all values of its inputs. Since each of these inputs will be a divisor of the newly cloned nodes
@@ -225,6 +229,42 @@ Node* PhaseIdealLoop::split_thru_phi(Node* n, Node* region, int policy) {
return phi;
}
+// Return true if 'n' is a Div or Mod node (without zero check If node which was removed earlier) with a loop phi divisor
+// of a trip-counted (integer or long) loop with a backedge input that could be zero (include zero in its type range). In
+// this case, we cannot split the division to the backedge as it could freely float above the loop exit check resulting in
+// a division by zero. This situation is possible because the type of an increment node of an iv phi (trip-counter) could
+// include zero while the iv phi does not (see PhiNode::Value() for trip-counted loops where we improve types of iv phis).
+// We also need to check other loop phis as they could have been created in the same split-if pass when applying
+// PhaseIdealLoop::split_thru_phi() to split nodes through an iv phi.
+bool PhaseIdealLoop::cannot_split_division(const Node* n, const Node* region) const {
+ const Type* zero;
+ switch (n->Opcode()) {
+ case Op_DivI:
+ case Op_ModI:
+ zero = TypeInt::ZERO;
+ break;
+ case Op_DivL:
+ case Op_ModL:
+ zero = TypeLong::ZERO;
+ break;
+ default:
+ return false;
+ }
+
+ assert(n->in(0) == NULL, "divisions with zero check should already have bailed out earlier in split-if");
+ Node* divisor = n->in(2);
+ return is_divisor_counted_loop_phi(divisor, region) &&
+ loop_phi_backedge_type_contains_zero(divisor, zero);
+}
+
+bool PhaseIdealLoop::is_divisor_counted_loop_phi(const Node* divisor, const Node* loop) {
+ return loop->is_BaseCountedLoop() && divisor->is_Phi() && divisor->in(0) == loop;
+}
+
+bool PhaseIdealLoop::loop_phi_backedge_type_contains_zero(const Node* phi_divisor, const Type* zero) const {
+ return _igvn.type(phi_divisor->in(LoopNode::LoopBackControl))->filter_speculative(zero) != Type::TOP;
+}
+
//------------------------------dominated_by------------------------------------
// Replace the dominated test with an obvious true or false. Place it on the
// IGVN worklist for later cleanup. Move control-dependent data Nodes on the
diff --git a/test/hotspot/jtreg/compiler/c2/TestSplitDivisionThroughPhi.java b/test/hotspot/jtreg/compiler/c2/TestSplitDivisionThroughPhi.java
new file mode 100644
index 000000000..5a42e7d36
--- /dev/null
+++ b/test/hotspot/jtreg/compiler/c2/TestSplitDivisionThroughPhi.java
@@ -0,0 +1,161 @@
+/*
+ * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2023, 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.
+ */
+
+/**
+* @test
+* @key stress randomness
+* @bug 8299259
+* @requires vm.compiler2.enabled
+* @summary Test various cases of divisions/modulo which should not be split through iv phis.
+* @run main/othervm -Xbatch -XX:+UnlockDiagnosticVMOptions -XX:LoopUnrollLimit=0 -XX:+StressGCM -XX:StressSeed=884154126
+* -XX:CompileCommand=compileonly,compiler.splitif.TestSplitDivisionThroughPhi::*
+* compiler.splitif.TestSplitDivisionThroughPhi
+*/
+
+/**
+* @test
+* @key stress randomness
+* @bug 8299259
+* @requires vm.compiler2.enabled
+* @summary Test various cases of divisions/modulo which should not be split through iv phis.
+* @run main/othervm -Xbatch -XX:+UnlockDiagnosticVMOptions -XX:LoopUnrollLimit=0 -XX:+StressGCM
+* -XX:CompileCommand=compileonly,compiler.splitif.TestSplitDivisionThroughPhi::*
+* compiler.splitif.TestSplitDivisionThroughPhi
+*/
+
+package compiler.splitif;
+
+public class TestSplitDivisionThroughPhi {
+ static int iFld;
+ static long lFld;
+ static boolean flag;
+
+
+ public static void main(String[] strArr) {
+ for (int i = 0; i < 5000; i++) {
+ testPushDivIThruPhi();
+ testPushDivIThruPhiInChain();
+ testPushModIThruPhi();
+ testPushModIThruPhiInChain();
+ testPushDivLThruPhi();
+ testPushDivLThruPhiInChain();
+ testPushModLThruPhi();
+ testPushModLThruPhiInChain();
+ }
+ }
+
+ // Already fixed by JDK-8248552.
+ static void testPushDivIThruPhi() {
+ for (int i = 10; i > 1; i -= 2) {
+ // The Div node is only split in later loop opts phase because the zero divisor check is only removed
+ // in IGVN after the first loop opts phase.
+ //
+ // iv phi i type: [2..10]
+ // When splitting the DivI through the iv phi, it ends up on the back edge with the trip count decrement
+ // as input which has type [0..8]. We end up executing a division by zero on the last iteration because
+ // the DivI it is not pinned to the loop exit test and can freely float above the loop exit check.
+ iFld = 10 / i;
+ }
+ }
+
+ // Same as above but with an additional Mul node between the iv phi and the Div node. Both nodes are split through
+ // the iv phi in one pass of Split If.
+ static void testPushDivIThruPhiInChain() {
+ for (int i = 10; i > 1; i -= 2) {
+ // Empty one iteration loop which is only removed after split if in first loop opts phase. This prevents
+ // that the Mul node is already split through the iv phi while the Div node cannot be split yet due to
+ // the zero divisor check which can only be removed in the IGVN after the first loop opts pass.
+ for (int j = 0; j < 1; j++) {
+ }
+ iFld = 10 / (i * 100);
+ }
+ }
+
+ // Already fixed by JDK-8248552.
+ static void testPushModIThruPhi() {
+ for (int i = 10; i > 1; i -= 2) {
+ iFld = 10 / i;
+ }
+ }
+
+ // Same as above but with ModI.
+ static void testPushModIThruPhiInChain() {
+ for (int i = 10; i > 1; i -= 2) {
+ for (int j = 0; j < 1; j++) {
+ }
+ iFld = 10 / (i * 100);
+ }
+ }
+
+ // Long cases only trigger since JDK-8256655.
+
+ // Same as above but with DivL.
+ static void testPushDivLThruPhi() {
+ for (long i = 10; i > 1; i -= 2) {
+ lFld = 10L / i;
+
+ // Loop that is not removed such that we do not transform the outer LongCountedLoop (only done if innermost)
+ for (int j = 0; j < 10; j++) {
+ flag = !flag;
+ }
+ }
+ }
+
+ // Same as above but with DivL.
+ static void testPushDivLThruPhiInChain() {
+ for (long i = 10; i > 1; i -= 2) {
+ for (int j = 0; j < 1; j++) {
+ }
+ lFld = 10L / (i * 100L);
+
+ for (int j = 0; j < 10; j++) {
+ flag = !flag;
+ }
+ }
+ }
+
+ // Same as above but with ModL
+ static void testPushModLThruPhi() {
+ for (long i = 10; i > 1; i -= 2) {
+ lFld = 10L % i;
+
+ for (int j = 0; j < 10; j++) {
+ flag = !flag;
+ }
+ }
+ }
+
+ // Same as above but with ModL
+ static void testPushModLThruPhiInChain() {
+ for (long i = 10; i > 1; i -= 2) {
+ for (int j = 0; j < 1; j++) {
+ }
+ lFld = 10L % (i * 100L);
+
+ for (int j = 0; j < 10; j++) {
+ flag = !flag;
+ }
+ }
+ }
+}
--
2.22.0

View File

@ -0,0 +1,370 @@
From f8719924d97e3eb0f19daf59fe5e2913c17144eb Mon Sep 17 00:00:00 2001
Subject: 8312065:Socket.connect does not timeout when profiling
---
src/java.base/aix/native/libnet/aix_close.c | 48 +++++-----
.../linux/native/libnet/linux_close.c | 50 +++++------
.../macosx/native/libnet/bsd_close.c | 50 +++++------
test/jdk/java/net/Socket/B8312065.java | 88 +++++++++++++++++++
4 files changed, 162 insertions(+), 74 deletions(-)
create mode 100644 test/jdk/java/net/Socket/B8312065.java
diff --git a/src/java.base/aix/native/libnet/aix_close.c b/src/java.base/aix/native/libnet/aix_close.c
index f3069920b..736a4ed8c 100644
--- a/src/java.base/aix/native/libnet/aix_close.c
+++ b/src/java.base/aix/native/libnet/aix_close.c
@@ -388,50 +388,50 @@ int NET_SocketClose(int fd) {
/************** Basic I/O operations here ***************/
/*
- * Macro to perform a blocking IO operation. Restarts
- * automatically if interrupted by signal (other than
- * our wakeup signal)
+ * Macro to perform a blocking IO operation.
+ * If interrupted by signal (other than our wakeup signal), and if RETRY is true,
+ * then restarts automatically
*/
-#define BLOCKING_IO_RETURN_INT(FD, FUNC) { \
- int ret; \
- threadEntry_t self; \
- fdEntry_t *fdEntry = getFdEntry(FD); \
- if (fdEntry == NULL) { \
- errno = EBADF; \
- return -1; \
- } \
- do { \
- startOp(fdEntry, &self); \
- ret = FUNC; \
- endOp(fdEntry, &self); \
- } while (ret == -1 && errno == EINTR); \
- return ret; \
+#define BLOCKING_IO_RETURN_INT(FD, FUNC, RETRY) { \
+ int ret; \
+ threadEntry_t self; \
+ fdEntry_t *fdEntry = getFdEntry(FD); \
+ if (fdEntry == NULL) { \
+ errno = EBADF; \
+ return -1; \
+ } \
+ do { \
+ startOp(fdEntry, &self); \
+ ret = FUNC; \
+ endOp(fdEntry, &self); \
+ } while ((RETRY) && ret == -1 && errno == EINTR); \
+ return ret; \
}
int NET_Read(int s, void* buf, size_t len) {
- BLOCKING_IO_RETURN_INT( s, recv(s, buf, len, 0) );
+ BLOCKING_IO_RETURN_INT( s, recv(s, buf, len, 0), JNI_TRUE );
}
int NET_NonBlockingRead(int s, void* buf, size_t len) {
- BLOCKING_IO_RETURN_INT(s, recv(s, buf, len, MSG_NONBLOCK));
+ BLOCKING_IO_RETURN_INT(s, recv(s, buf, len, MSG_NONBLOCK), JNI_TRUE );
}
int NET_RecvFrom(int s, void *buf, int len, unsigned int flags,
struct sockaddr *from, socklen_t *fromlen) {
- BLOCKING_IO_RETURN_INT( s, recvfrom(s, buf, len, flags, from, fromlen) );
+ BLOCKING_IO_RETURN_INT( s, recvfrom(s, buf, len, flags, from, fromlen), JNI_TRUE );
}
int NET_Send(int s, void *msg, int len, unsigned int flags) {
- BLOCKING_IO_RETURN_INT( s, send(s, msg, len, flags) );
+ BLOCKING_IO_RETURN_INT( s, send(s, msg, len, flags), JNI_TRUE );
}
int NET_SendTo(int s, const void *msg, int len, unsigned int
flags, const struct sockaddr *to, int tolen) {
- BLOCKING_IO_RETURN_INT( s, sendto(s, msg, len, flags, to, tolen) );
+ BLOCKING_IO_RETURN_INT( s, sendto(s, msg, len, flags, to, tolen), JNI_TRUE );
}
int NET_Accept(int s, struct sockaddr *addr, socklen_t *addrlen) {
- BLOCKING_IO_RETURN_INT( s, accept(s, addr, addrlen) );
+ BLOCKING_IO_RETURN_INT( s, accept(s, addr, addrlen), JNI_TRUE );
}
int NET_Connect(int s, struct sockaddr *addr, int addrlen) {
@@ -489,7 +489,7 @@ int NET_Connect(int s, struct sockaddr *addr, int addrlen) {
}
int NET_Poll(struct pollfd *ufds, unsigned int nfds, int timeout) {
- BLOCKING_IO_RETURN_INT( ufds[0].fd, poll(ufds, nfds, timeout) );
+ BLOCKING_IO_RETURN_INT( ufds[0].fd, poll(ufds, nfds, timeout), JNI_FALSE );
}
/*
diff --git a/src/java.base/linux/native/libnet/linux_close.c b/src/java.base/linux/native/libnet/linux_close.c
index 0d4e81e07..aabdaad4e 100644
--- a/src/java.base/linux/native/libnet/linux_close.c
+++ b/src/java.base/linux/native/libnet/linux_close.c
@@ -345,58 +345,58 @@ int NET_SocketClose(int fd) {
/************** Basic I/O operations here ***************/
/*
- * Macro to perform a blocking IO operation. Restarts
- * automatically if interrupted by signal (other than
- * our wakeup signal)
+ * Macro to perform a blocking IO operation.
+ * If interrupted by signal (other than our wakeup signal), and if RETRY is true,
+ * then restarts automatically
*/
-#define BLOCKING_IO_RETURN_INT(FD, FUNC) { \
- int ret; \
- threadEntry_t self; \
- fdEntry_t *fdEntry = getFdEntry(FD); \
- if (fdEntry == NULL) { \
- errno = EBADF; \
- return -1; \
- } \
- do { \
- startOp(fdEntry, &self); \
- ret = FUNC; \
- endOp(fdEntry, &self); \
- } while (ret == -1 && errno == EINTR); \
- return ret; \
+#define BLOCKING_IO_RETURN_INT(FD, FUNC, RETRY) { \
+ int ret; \
+ threadEntry_t self; \
+ fdEntry_t *fdEntry = getFdEntry(FD); \
+ if (fdEntry == NULL) { \
+ errno = EBADF; \
+ return -1; \
+ } \
+ do { \
+ startOp(fdEntry, &self); \
+ ret = FUNC; \
+ endOp(fdEntry, &self); \
+ } while ((RETRY) && ret == -1 && errno == EINTR); \
+ return ret; \
}
int NET_Read(int s, void* buf, size_t len) {
- BLOCKING_IO_RETURN_INT( s, recv(s, buf, len, 0) );
+ BLOCKING_IO_RETURN_INT( s, recv(s, buf, len, 0), JNI_TRUE );
}
int NET_NonBlockingRead(int s, void* buf, size_t len) {
- BLOCKING_IO_RETURN_INT( s, recv(s, buf, len, MSG_DONTWAIT) );
+ BLOCKING_IO_RETURN_INT( s, recv(s, buf, len, MSG_DONTWAIT), JNI_TRUE );
}
int NET_RecvFrom(int s, void *buf, int len, unsigned int flags,
struct sockaddr *from, socklen_t *fromlen) {
- BLOCKING_IO_RETURN_INT( s, recvfrom(s, buf, len, flags, from, fromlen) );
+ BLOCKING_IO_RETURN_INT( s, recvfrom(s, buf, len, flags, from, fromlen), JNI_TRUE );
}
int NET_Send(int s, void *msg, int len, unsigned int flags) {
- BLOCKING_IO_RETURN_INT( s, send(s, msg, len, flags) );
+ BLOCKING_IO_RETURN_INT( s, send(s, msg, len, flags), JNI_TRUE );
}
int NET_SendTo(int s, const void *msg, int len, unsigned int
flags, const struct sockaddr *to, int tolen) {
- BLOCKING_IO_RETURN_INT( s, sendto(s, msg, len, flags, to, tolen) );
+ BLOCKING_IO_RETURN_INT( s, sendto(s, msg, len, flags, to, tolen), JNI_TRUE );
}
int NET_Accept(int s, struct sockaddr *addr, socklen_t *addrlen) {
- BLOCKING_IO_RETURN_INT( s, accept(s, addr, addrlen) );
+ BLOCKING_IO_RETURN_INT( s, accept(s, addr, addrlen), JNI_TRUE );
}
int NET_Connect(int s, struct sockaddr *addr, int addrlen) {
- BLOCKING_IO_RETURN_INT( s, connect(s, addr, addrlen) );
+ BLOCKING_IO_RETURN_INT( s, connect(s, addr, addrlen), JNI_TRUE );
}
int NET_Poll(struct pollfd *ufds, unsigned int nfds, int timeout) {
- BLOCKING_IO_RETURN_INT( ufds[0].fd, poll(ufds, nfds, timeout) );
+ BLOCKING_IO_RETURN_INT( ufds[0].fd, poll(ufds, nfds, timeout), JNI_FALSE );
}
/*
diff --git a/src/java.base/macosx/native/libnet/bsd_close.c b/src/java.base/macosx/native/libnet/bsd_close.c
index 4a348b212..e4fd22b01 100644
--- a/src/java.base/macosx/native/libnet/bsd_close.c
+++ b/src/java.base/macosx/native/libnet/bsd_close.c
@@ -349,58 +349,58 @@ int NET_SocketClose(int fd) {
/************** Basic I/O operations here ***************/
/*
- * Macro to perform a blocking IO operation. Restarts
- * automatically if interrupted by signal (other than
- * our wakeup signal)
+ * Macro to perform a blocking IO operation.
+ * If interrupted by signal (other than our wakeup signal), and if RETRY is true,
+ * then restarts automatically
*/
-#define BLOCKING_IO_RETURN_INT(FD, FUNC) { \
- int ret; \
- threadEntry_t self; \
- fdEntry_t *fdEntry = getFdEntry(FD); \
- if (fdEntry == NULL) { \
- errno = EBADF; \
- return -1; \
- } \
- do { \
- startOp(fdEntry, &self); \
- ret = FUNC; \
- endOp(fdEntry, &self); \
- } while (ret == -1 && errno == EINTR); \
- return ret; \
+#define BLOCKING_IO_RETURN_INT(FD, FUNC, RETRY) { \
+ int ret; \
+ threadEntry_t self; \
+ fdEntry_t *fdEntry = getFdEntry(FD); \
+ if (fdEntry == NULL) { \
+ errno = EBADF; \
+ return -1; \
+ } \
+ do { \
+ startOp(fdEntry, &self); \
+ ret = FUNC; \
+ endOp(fdEntry, &self); \
+ } while ((RETRY) && ret == -1 && errno == EINTR); \
+ return ret; \
}
int NET_Read(int s, void* buf, size_t len) {
- BLOCKING_IO_RETURN_INT( s, recv(s, buf, len, 0) );
+ BLOCKING_IO_RETURN_INT( s, recv(s, buf, len, 0), JNI_TRUE );
}
int NET_NonBlockingRead(int s, void* buf, size_t len) {
- BLOCKING_IO_RETURN_INT( s, recv(s, buf, len, MSG_DONTWAIT));
+ BLOCKING_IO_RETURN_INT( s, recv(s, buf, len, MSG_DONTWAIT), JNI_TRUE);
}
int NET_RecvFrom(int s, void *buf, int len, unsigned int flags,
struct sockaddr *from, socklen_t *fromlen) {
- BLOCKING_IO_RETURN_INT( s, recvfrom(s, buf, len, flags, from, fromlen) );
+ BLOCKING_IO_RETURN_INT( s, recvfrom(s, buf, len, flags, from, fromlen), JNI_TRUE );
}
int NET_Send(int s, void *msg, int len, unsigned int flags) {
- BLOCKING_IO_RETURN_INT( s, send(s, msg, len, flags) );
+ BLOCKING_IO_RETURN_INT( s, send(s, msg, len, flags), JNI_TRUE );
}
int NET_SendTo(int s, const void *msg, int len, unsigned int
flags, const struct sockaddr *to, int tolen) {
- BLOCKING_IO_RETURN_INT( s, sendto(s, msg, len, flags, to, tolen) );
+ BLOCKING_IO_RETURN_INT( s, sendto(s, msg, len, flags, to, tolen), JNI_TRUE );
}
int NET_Accept(int s, struct sockaddr *addr, socklen_t *addrlen) {
- BLOCKING_IO_RETURN_INT( s, accept(s, addr, addrlen) );
+ BLOCKING_IO_RETURN_INT( s, accept(s, addr, addrlen), JNI_TRUE );
}
int NET_Connect(int s, struct sockaddr *addr, int addrlen) {
- BLOCKING_IO_RETURN_INT( s, connect(s, addr, addrlen) );
+ BLOCKING_IO_RETURN_INT( s, connect(s, addr, addrlen), JNI_TRUE );
}
int NET_Poll(struct pollfd *ufds, unsigned int nfds, int timeout) {
- BLOCKING_IO_RETURN_INT( ufds[0].fd, poll(ufds, nfds, timeout) );
+ BLOCKING_IO_RETURN_INT( ufds[0].fd, poll(ufds, nfds, timeout), JNI_FALSE );
}
/*
diff --git a/test/jdk/java/net/Socket/B8312065.java b/test/jdk/java/net/Socket/B8312065.java
new file mode 100644
index 000000000..118792ead
--- /dev/null
+++ b/test/jdk/java/net/Socket/B8312065.java
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2023, 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.
+ *
+ * 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 8312065
+ * @summary Socket.connect does not timeout as expected when profiling (i.e. keep receiving signal)
+ * @requires (os.family != "windows")
+ * @compile NativeThread.java
+ * @run main/othervm/native/timeout=120 -Djdk.net.usePlainSocketImpl B8312065
+ */
+
+import sun.misc.Signal;
+
+import java.net.InetSocketAddress;
+import java.net.Socket;
+import java.net.SocketTimeoutException;
+import java.util.concurrent.TimeUnit;
+
+public class B8312065 {
+ public static void main(String[] args) throws Exception {
+ System.loadLibrary("NativeThread");
+
+ // Setup SIGPIPE handler
+ Signal.handle(new Signal("PIPE"), System.out::println);
+
+ long osThreadId = NativeThread.getID();
+
+ int timeoutMillis = 2000;
+ int n = 10;
+ Thread t = new Thread(() -> {
+ // Send SIGPIPE to the thread every second
+ for (int i = 0; i < n; i++) {
+ if (NativeThread.signal(osThreadId, NativeThread.SIGPIPE) != 0) {
+ System.out.println("Test FAILED: failed to send signal");
+ System.exit(1);
+ }
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ System.out.println("Test FAILED: unexpected interrupt");
+ System.exit(1);
+ }
+ }
+ System.out.println("Test FAILED: Socket.connect blocked " + n + " seconds, " +
+ "expected around " + timeoutMillis / 1000 + " seconds");
+ System.exit(1);
+ });
+ t.setDaemon(true);
+ t.start();
+
+ long startTime = System.nanoTime();
+
+ try {
+ Socket socket = new Socket();
+ // There is no good way to mock SocketTimeoutException, just assume 192.168.255.255 is not in use
+ socket.connect(new InetSocketAddress("192.168.255.255", 8080), timeoutMillis);
+ } catch (SocketTimeoutException e) {
+ long duration = TimeUnit.MILLISECONDS.convert(System.nanoTime() - startTime, TimeUnit.NANOSECONDS);
+ if (duration >= timeoutMillis) {
+ System.out.println("Test passed");
+ } else {
+ System.out.println("Test FAILED: duration " + duration + " ms, expected >= " + timeoutMillis + " ms");
+ System.exit(1);
+ }
+ }
+ }
+}
--
2.22.0

View File

@ -0,0 +1,100 @@
From 061819ea31fcf07a91835c7d7d229927fb1fba9a Mon Sep 17 00:00:00 2001
Subject: 8312200: Fix Parse::catch_call_exceptions memory leak
---
src/hotspot/share/opto/doCall.cpp | 39 ++++++++++++++++---------------
1 file changed, 20 insertions(+), 19 deletions(-)
diff --git a/src/hotspot/share/opto/doCall.cpp b/src/hotspot/share/opto/doCall.cpp
index ed0d14348..b91e61a21 100644
--- a/src/hotspot/share/opto/doCall.cpp
+++ b/src/hotspot/share/opto/doCall.cpp
@@ -785,46 +785,47 @@ void Parse::catch_call_exceptions(ciExceptionHandlerStream& handlers) {
Node* i_o = this->i_o();
// Add a CatchNode.
- GrowableArray<int>* bcis = new (C->node_arena()) GrowableArray<int>(C->node_arena(), 8, 0, -1);
- GrowableArray<const Type*>* extypes = new (C->node_arena()) GrowableArray<const Type*>(C->node_arena(), 8, 0, nullptr);
- GrowableArray<int>* saw_unloaded = new (C->node_arena()) GrowableArray<int>(C->node_arena(), 8, 0, 0);
+ Arena tmp_mem{mtCompiler};
+ GrowableArray<int> bcis(&tmp_mem, 8, 0, -1);
+ GrowableArray<const Type*> extypes(&tmp_mem, 8, 0, nullptr);
+ GrowableArray<int> saw_unloaded(&tmp_mem, 8, 0, -1);
bool default_handler = false;
for (; !handlers.is_done(); handlers.next()) {
- ciExceptionHandler* h = handlers.handler();
- int h_bci = h->handler_bci();
- ciInstanceKlass* h_klass = h->is_catch_all() ? env()->Throwable_klass() : h->catch_klass();
+ ciExceptionHandler* h = handlers.handler();
+ int h_bci = h->handler_bci();
+ ciInstanceKlass* h_klass = h->is_catch_all() ? env()->Throwable_klass() : h->catch_klass();
// Do not introduce unloaded exception types into the graph:
if (!h_klass->is_loaded()) {
- if (saw_unloaded->contains(h_bci)) {
+ if (saw_unloaded.contains(h_bci)) {
/* We've already seen an unloaded exception with h_bci,
so don't duplicate. Duplication will cause the CatchNode to be
unnecessarily large. See 4713716. */
continue;
} else {
- saw_unloaded->append(h_bci);
+ saw_unloaded.append(h_bci);
}
}
- const Type* h_extype = TypeOopPtr::make_from_klass(h_klass);
+ const Type* h_extype = TypeOopPtr::make_from_klass(h_klass);
// (We use make_from_klass because it respects UseUniqueSubclasses.)
h_extype = h_extype->join(TypeInstPtr::NOTNULL);
assert(!h_extype->empty(), "sanity");
- // Note: It's OK if the BCIs repeat themselves.
- bcis->append(h_bci);
- extypes->append(h_extype);
+ // Note: It's OK if the BCIs repeat themselves.
+ bcis.append(h_bci);
+ extypes.append(h_extype);
if (h_bci == -1) {
default_handler = true;
}
}
if (!default_handler) {
- bcis->append(-1);
+ bcis.append(-1);
const Type* extype = TypeOopPtr::make_from_klass(env()->Throwable_klass())->is_instptr();
extype = extype->join(TypeInstPtr::NOTNULL);
- extypes->append(extype);
+ extypes.append(extype);
}
- int len = bcis->length();
+ int len = bcis.length();
CatchNode *cn = new CatchNode(control(), i_o, len+1);
Node *catch_ = _gvn.transform(cn);
@@ -835,18 +836,18 @@ void Parse::catch_call_exceptions(ciExceptionHandlerStream& handlers) {
PreserveJVMState pjvms(this);
// Locals are just copied from before the call.
// Get control from the CatchNode.
- int handler_bci = bcis->at(i);
+ int handler_bci = bcis.at(i);
Node* ctrl = _gvn.transform( new CatchProjNode(catch_, i+1,handler_bci));
// This handler cannot happen?
if (ctrl == top()) continue;
set_control(ctrl);
// Create exception oop
- const TypeInstPtr* extype = extypes->at(i)->is_instptr();
- Node *ex_oop = _gvn.transform(new CreateExNode(extypes->at(i), ctrl, i_o));
+ const TypeInstPtr* extype = extypes.at(i)->is_instptr();
+ Node* ex_oop = _gvn.transform(new CreateExNode(extypes.at(i), ctrl, i_o));
// Handle unloaded exception classes.
- if (saw_unloaded->contains(handler_bci)) {
+ if (saw_unloaded.contains(handler_bci)) {
// An unloaded exception type is coming here. Do an uncommon trap.
#ifndef PRODUCT
// We do not expect the same handler bci to take both cold unloaded
--
2.22.0

View File

@ -0,0 +1,223 @@
From 146c0fa1d45690a787b512d2ab1d9e0da9ec918a Mon Sep 17 00:00:00 2001
Subject: 8313626: C2 crash due to unexpected exception control flow
---
src/hotspot/share/opto/doCall.cpp | 4 +
.../parsing/MissingSafepointOnTryCatch.jasm | 111 ++++++++++++++++++
.../TestMissingSafepointOnTryCatch.java | 65 ++++++++++
3 files changed, 180 insertions(+)
create mode 100644 test/hotspot/jtreg/compiler/parsing/MissingSafepointOnTryCatch.jasm
create mode 100644 test/hotspot/jtreg/compiler/parsing/TestMissingSafepointOnTryCatch.java
diff --git a/src/hotspot/share/opto/doCall.cpp b/src/hotspot/share/opto/doCall.cpp
index d42f9367d..ed0d14348 100644
--- a/src/hotspot/share/opto/doCall.cpp
+++ b/src/hotspot/share/opto/doCall.cpp
@@ -979,6 +979,8 @@ void Parse::catch_inline_exceptions(SafePointNode* ex_map) {
if (PrintOpto && WizardMode) {
tty->print_cr(" Catching every inline exception bci:%d -> handler_bci:%d", bci(), handler_bci);
}
+ // If this is a backwards branch in the bytecodes, add safepoint
+ maybe_add_safepoint(handler_bci);
merge_exception(handler_bci); // jump to handler
return; // No more handling to be done here!
}
@@ -1010,6 +1012,8 @@ void Parse::catch_inline_exceptions(SafePointNode* ex_map) {
klass->print_name();
tty->cr();
}
+ // If this is a backwards branch in the bytecodes, add safepoint
+ maybe_add_safepoint(handler_bci);
merge_exception(handler_bci);
}
set_control(not_subtype_ctrl);
diff --git a/test/hotspot/jtreg/compiler/parsing/MissingSafepointOnTryCatch.jasm b/test/hotspot/jtreg/compiler/parsing/MissingSafepointOnTryCatch.jasm
new file mode 100644
index 000000000..5d5fced0c
--- /dev/null
+++ b/test/hotspot/jtreg/compiler/parsing/MissingSafepointOnTryCatch.jasm
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2023, 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.
+ */
+
+public class MissingSafepointOnTryCatch version 52:0 {
+
+ static Method m:"()V" {
+ return;
+ }
+
+ static Method test1:"()V" stack 1 {
+ try t;
+ invokestatic m:"()V";
+ return;
+
+ catch t java/lang/Throwable;
+ stack_map class java/lang/Throwable;
+ athrow;
+ endtry t;
+ }
+
+ static Method test2:"()V" stack 1 {
+ try t0;
+ try t1;
+ invokestatic m:"()V";
+ endtry t1;
+ return;
+
+ catch t1 java/lang/Exception;
+ stack_map class java/lang/Exception;
+ return;
+
+ catch t0 java/lang/Throwable;
+ stack_map class java/lang/Throwable;
+ athrow;
+ endtry t0;
+ }
+
+ public static Method th:"()V"
+ throws java/lang/Exception
+ stack 2 locals 0
+ {
+ new class java/lang/Exception;
+ dup;
+ invokespecial Method java/lang/Exception."<init>":"()V";
+ athrow;
+ }
+
+ static Method test3:"()V" stack 1 locals 2 {
+ try t;
+ invokestatic m:"()V";
+ iconst_1;
+ istore_0;
+ iconst_0;
+ istore_1;
+ return;
+ catch t java/lang/Throwable;
+ stack_map class java/lang/Throwable;
+ invokestatic th:"()V";
+ return;
+ endtry t;
+ }
+
+ static Method test4:"()V" stack 2 locals 2 {
+ try t;
+ invokestatic m:"()V";
+ iconst_1;
+ istore_0;
+ iconst_0;
+ istore_1;
+ return;
+ catch t java/lang/Throwable;
+ stack_map class java/lang/Throwable;
+ iconst_1;
+ istore_0;
+ invokestatic th:"()V";
+ return;
+ endtry t;
+ }
+
+ static Method testInfinite:"()V" stack 1 {
+ try t;
+ invokestatic th:"()V";
+ return;
+
+ catch t java/lang/Throwable;
+ stack_map class java/lang/Throwable;
+ athrow;
+ endtry t;
+ }
+
+} // end Class MissingSafepointOnTryCatch
diff --git a/test/hotspot/jtreg/compiler/parsing/TestMissingSafepointOnTryCatch.java b/test/hotspot/jtreg/compiler/parsing/TestMissingSafepointOnTryCatch.java
new file mode 100644
index 000000000..9a8a31357
--- /dev/null
+++ b/test/hotspot/jtreg/compiler/parsing/TestMissingSafepointOnTryCatch.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2023, 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 8313626
+ * @summary assert(false) failed: malformed control flow to missing safepoint on backedge of a try-catch
+ * @library /test/lib
+ * @compile MissingSafepointOnTryCatch.jasm
+ * @run main/othervm -XX:CompileCommand=quiet
+ * -XX:CompileCommand=compileonly,MissingSafepointOnTryCatch::test*
+ * -XX:CompileCommand=dontinline,MissingSafepointOnTryCatch::m
+ * -XX:CompileCommand=inline,MissingSafepointOnTryCatch::th
+ * -XX:-TieredCompilation -Xcomp TestMissingSafepointOnTryCatch
+ */
+
+import jdk.test.lib.Utils;
+
+public class TestMissingSafepointOnTryCatch {
+
+ public static void infiniteLoop() {
+ try {
+ Thread thread = new Thread() {
+ public void run() {
+ MissingSafepointOnTryCatch.testInfinite();
+ }
+ };
+ thread.setDaemon(true);
+ thread.start();
+ Thread.sleep(Utils.adjustTimeout(500));
+ } catch (Exception e) {}
+ }
+
+ public static void main(String[] args) {
+ try {
+ // to make sure java/lang/Exception class is resolved
+ MissingSafepointOnTryCatch.th();
+ } catch (Exception e) {}
+ MissingSafepointOnTryCatch.test1();
+ MissingSafepointOnTryCatch.test2();
+ MissingSafepointOnTryCatch.test3();
+ MissingSafepointOnTryCatch.test4();
+ infiniteLoop();
+ }
+}
--
2.22.0

View File

@ -0,0 +1,447 @@
From e1726b4ccb0b51f527f1bf7a5a39c027294f5174 Mon Sep 17 00:00:00 2001
Subject: 8314063: The socket is not closed in Connection::createSocket when the handshake failed for LDAP connection
---
.../classes/com/sun/jndi/ldap/Connection.java | 131 +++++----
.../ldap/LdapSSLHandshakeFailureTest.java | 249 ++++++++++++++++++
test/jdk/com/sun/jndi/ldap/ksWithSAN | 0
3 files changed, 314 insertions(+), 66 deletions(-)
create mode 100644 test/jdk/com/sun/jndi/ldap/LdapSSLHandshakeFailureTest.java
create mode 100644 test/jdk/com/sun/jndi/ldap/ksWithSAN
diff --git a/src/java.naming/share/classes/com/sun/jndi/ldap/Connection.java b/src/java.naming/share/classes/com/sun/jndi/ldap/Connection.java
index ebb21bd8b..f71b1bb14 100644
--- a/src/java.naming/share/classes/com/sun/jndi/ldap/Connection.java
+++ b/src/java.naming/share/classes/com/sun/jndi/ldap/Connection.java
@@ -280,79 +280,79 @@ public final class Connection implements Runnable {
private Socket createSocket(String host, int port, String socketFactory,
int connectTimeout) throws Exception {
- Socket socket = null;
-
- if (socketFactory != null) {
+ SocketFactory factory = getSocketFactory(socketFactory);
+ assert factory != null;
+ Socket socket = createConnectionSocket(host, port, factory, connectTimeout);
- // create the factory
+ // the handshake for SSL connection with server and reset timeout for the socket
+ if (socket instanceof SSLSocket sslSocket) {
+ try {
+ initialSSLHandshake(sslSocket, connectTimeout);
+ } catch (Exception e) {
+ // 8314063 the socket is not closed after the failure of handshake
+ // close the socket while the error happened
+ closeOpenedSocket(socket);
+ throw e;
+ }
+ }
+ return socket;
+ }
+ private SocketFactory getSocketFactory(String socketFactoryName) throws Exception {
+ if (socketFactoryName == null) {
+ if (debug) {
+ System.err.println("Connection: using default SocketFactory");
+ }
+ return SocketFactory.getDefault();
+ } else {
+ if (debug) {
+ System.err.println("Connection: loading supplied SocketFactory: " + socketFactoryName);
+ }
@SuppressWarnings("unchecked")
Class<? extends SocketFactory> socketFactoryClass =
- (Class<? extends SocketFactory>)Obj.helper.loadClass(socketFactory);
+ (Class<? extends SocketFactory>) Obj.helper.loadClass(socketFactoryName);
Method getDefault =
- socketFactoryClass.getMethod("getDefault", new Class<?>[]{});
+ socketFactoryClass.getMethod("getDefault");
SocketFactory factory = (SocketFactory) getDefault.invoke(null, new Object[]{});
+ return factory;
+ }
+ }
- // create the socket
-
- if (connectTimeout > 0) {
-
- InetSocketAddress endpoint =
- createInetSocketAddress(host, port);
-
- // unconnected socket
- socket = factory.createSocket();
-
- if (debug) {
- System.err.println("Connection: creating socket with " +
- "a timeout using supplied socket factory");
- }
-
- // connected socket
- socket.connect(endpoint, connectTimeout);
- }
-
- // continue (but ignore connectTimeout)
- if (socket == null) {
- if (debug) {
- System.err.println("Connection: creating socket using " +
- "supplied socket factory");
- }
- // connected socket
- socket = factory.createSocket(host, port);
- }
- } else {
-
- if (connectTimeout > 0) {
-
- InetSocketAddress endpoint = createInetSocketAddress(host, port);
-
- socket = new Socket();
+ private Socket createConnectionSocket(String host, int port, SocketFactory factory,
+ int connectTimeout) throws Exception {
+ Socket socket = null;
- if (debug) {
- System.err.println("Connection: creating socket with " +
- "a timeout");
- }
- socket.connect(endpoint, connectTimeout);
+ if (connectTimeout > 0) {
+ // create unconnected socket and then connect it if timeout
+ // is supplied
+ InetSocketAddress endpoint =
+ createInetSocketAddress(host, port);
+ // unconnected socket
+ socket = factory.createSocket();
+ // connect socket with a timeout
+ socket.connect(endpoint, connectTimeout);
+ if (debug) {
+ System.err.println("Connection: creating socket with " +
+ "a connect timeout");
}
-
- // continue (but ignore connectTimeout)
-
- if (socket == null) {
- if (debug) {
- System.err.println("Connection: creating socket");
- }
- // connected socket
- socket = new Socket(host, port);
+ }
+ if (socket == null) {
+ // create connected socket
+ socket = factory.createSocket(host, port);
+ if (debug) {
+ System.err.println("Connection: creating connected socket with" +
+ " no connect timeout");
}
}
+ return socket;
+ }
+
+ // For LDAP connect timeouts on LDAP over SSL connections must treat
+ // the SSL handshake following socket connection as part of the timeout.
+ // So explicitly set a socket read timeout, trigger the SSL handshake,
+ // then reset the timeout.
+ private void initialSSLHandshake(SSLSocket sslSocket , int connectTimeout) throws Exception {
- // For LDAP connect timeouts on LDAP over SSL connections must treat
- // the SSL handshake following socket connection as part of the timeout.
- // So explicitly set a socket read timeout, trigger the SSL handshake,
- // then reset the timeout.
- if (socket instanceof SSLSocket) {
- SSLSocket sslSocket = (SSLSocket) socket;
if (!IS_HOSTNAME_VERIFICATION_DISABLED) {
SSLParameters param = sslSocket.getSSLParameters();
param.setEndpointIdentificationAlgorithm("LDAPS");
@@ -365,8 +365,6 @@ public final class Connection implements Runnable {
sslSocket.startHandshake();
sslSocket.setSoTimeout(socketTimeout);
}
- }
- return socket;
}
////////////////////////////////////////////////////////////////////////////
@@ -642,7 +640,7 @@ public final class Connection implements Runnable {
flushAndCloseOutputStream();
// 8313657 socket is not closed until GC is run
- closeOpenedSocket();
+ closeOpenedSocket(sock);
tryUnpauseReader();
if (!notifyParent) {
@@ -695,9 +693,10 @@ public final class Connection implements Runnable {
}
// close socket
- private void closeOpenedSocket() {
+ private void closeOpenedSocket(Socket socket) {
try {
- sock.close();
+ if (socket != null && !socket.isClosed())
+ socket.close();
} catch (IOException ioEx) {
if (debug) {
System.err.println("Connection.closeConnectionSocket: Socket close problem: " + ioEx);
diff --git a/test/jdk/com/sun/jndi/ldap/LdapSSLHandshakeFailureTest.java b/test/jdk/com/sun/jndi/ldap/LdapSSLHandshakeFailureTest.java
new file mode 100644
index 000000000..29f74d250
--- /dev/null
+++ b/test/jdk/com/sun/jndi/ldap/LdapSSLHandshakeFailureTest.java
@@ -0,0 +1,249 @@
+/*
+ * Copyright (c) 2023, 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.test.lib.net.URIBuilder;
+
+import javax.naming.Context;
+import javax.naming.ldap.InitialLdapContext;
+import javax.naming.ldap.LdapContext;
+import javax.net.SocketFactory;
+import javax.net.ssl.SSLServerSocketFactory;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.InetAddress;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.net.SocketException;
+import java.util.Hashtable;
+
+/*
+ * @test
+ * @bug 8314063
+ * @library /test/lib
+ * @summary For LDAPs connection, if the value of com.sun.jndi.ldap.connect.timeout is
+ * set too small or not an optimal value for the system, after the socket is created and
+ * connected to the server, but the handshake between the client and server fails due to
+ * socket time out, the opened socket is not closed properly. In this test case, the server
+ * is forced to sleep ten seconds and connection time out for client is one second. This
+ * will allow the socket opened and connected, and give the chance for the handshake to be
+ * timed out. Before this fix, the socket is kept opened. Right now the exception will be
+ * caught and the socket will be closed.
+ *
+ * @run main/othervm LdapSSLHandshakeFailureTest LdapSSLHandshakeFailureTest$CustomSocketFactory true 6000
+ * @run main/othervm LdapSSLHandshakeFailureTest -1000 true 6000
+ * @run main/othervm LdapSSLHandshakeFailureTest -1000 false 6000
+ * @run main/othervm LdapSSLHandshakeFailureTest 2000 false 6000
+ * @run main/othervm LdapSSLHandshakeFailureTest 0 true 6000
+ * @run main/othervm LdapSSLHandshakeFailureTest 0 false 6000
+ * @run main/othervm LdapSSLHandshakeFailureTest true
+ * @run main/othervm LdapSSLHandshakeFailureTest false
+ */
+
+public class LdapSSLHandshakeFailureTest {
+ private static String SOCKET_CLOSED_MSG = "The socket has been closed.";
+
+ private static int serverSleepingTime = 5000;
+
+ public static void main(String args[]) throws Exception {
+
+ // Set the keystores
+ setKeyStore();
+ boolean serverSlowDown = Boolean.valueOf(args[0]);
+ if (args.length == 2) {
+ serverSlowDown = Boolean.valueOf(args[1]);
+ }
+
+ if (args.length == 3) {
+ serverSleepingTime = Integer.valueOf(args[2]);
+ }
+
+ boolean hasCustomSocketFactory = args[0]
+ .equals("LdapSSLHandshakeFailureTest$CustomSocketFactory");
+ // start the test server first.
+ try (TestServer server = new TestServer(serverSlowDown, serverSleepingTime)) {
+ server.start();
+ Hashtable<String, Object> env = new Hashtable<>();
+ env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
+ env.put("java.naming.ldap.version", "3");
+ env.put(Context.PROVIDER_URL, URIBuilder.newBuilder()
+ .scheme("ldaps")
+ .loopback()
+ .port(server.getPortNumber())
+ .buildUnchecked().toString());
+
+ if (hasCustomSocketFactory) {
+ env.put("java.naming.ldap.factory.socket", args[0]);
+ env.put("com.sun.jndi.ldap.connect.timeout", "1000");
+ }
+
+ if (args.length == 2 && !hasCustomSocketFactory) {
+ env.put("com.sun.jndi.ldap.connect.timeout", args[0]);
+ }
+
+ env.put(Context.SECURITY_PROTOCOL, "ssl");
+ env.put(Context.SECURITY_AUTHENTICATION, "Simple");
+ env.put(Context.SECURITY_PRINCIPAL, "cn=principal");
+ env.put(Context.SECURITY_CREDENTIALS, "123456");
+ LdapContext ctx = null;
+ try {
+ ctx = new InitialLdapContext(env, null);
+ } catch (Exception e) {
+ if (CustomSocketFactory.customSocket.closeMethodCalledCount() > 0
+ && hasCustomSocketFactory
+ && Boolean.valueOf(args[1])) {
+ System.out.println(SOCKET_CLOSED_MSG);
+ } else {
+ throw e;
+ }
+ } finally {
+ if (ctx != null)
+ ctx.close();
+ }
+ }
+ }
+
+ public static class CustomSocketFactory extends SocketFactory {
+ private static CustomSocket customSocket;
+
+ public static CustomSocketFactory getDefault() {
+ return new CustomSocketFactory();
+ }
+
+ @Override
+ public Socket createSocket() throws SocketException {
+ customSocket = new CustomSocket();
+ return customSocket;
+ }
+
+ @Override
+ public Socket createSocket(String s, int timeout) {
+ return customSocket;
+ }
+
+ @Override
+ public Socket createSocket(String host, int port, InetAddress localHost,
+ int localPort) {
+ return customSocket;
+ }
+
+ @Override
+ public Socket createSocket(InetAddress host, int port) {
+ return customSocket;
+ }
+
+ @Override
+ public Socket createSocket(InetAddress address, int port,
+ InetAddress localAddress, int localPort) {
+ return customSocket;
+ }
+ }
+
+ private static class CustomSocket extends Socket {
+ private int closeMethodCalled = 0;
+
+ public CustomSocket() {
+ closeMethodCalled = 0;
+ }
+
+ public int closeMethodCalledCount() {
+ return closeMethodCalled;
+ }
+
+ @Override
+ public void close() throws java.io.IOException {
+ closeMethodCalled++;
+ super.close();
+ }
+ }
+
+ private static void setKeyStore() {
+
+ String fileName = "ksWithSAN", dir = System.getProperty("test.src", ".") + File.separator;
+
+ System.setProperty("javax.net.ssl.keyStore", dir + fileName);
+ System.setProperty("javax.net.ssl.keyStorePassword", "welcome1");
+ System.setProperty("javax.net.ssl.trustStore", dir + fileName);
+ System.setProperty("javax.net.ssl.trustStorePassword", "welcome1");
+ }
+
+ static class TestServer extends Thread implements AutoCloseable {
+ private boolean isForceToSleep;
+ private int sleepingTime;
+ private final ServerSocket serverSocket;
+ private final int PORT;
+
+ private TestServer(boolean isForceToSleep, int sleepingTime) {
+ this.isForceToSleep = isForceToSleep;
+ this.sleepingTime = sleepingTime;
+ try {
+ SSLServerSocketFactory socketFactory = (SSLServerSocketFactory) SSLServerSocketFactory.getDefault();
+ serverSocket = socketFactory.createServerSocket(0, 0, InetAddress.getLoopbackAddress());
+ PORT = serverSocket.getLocalPort();
+ } catch (IOException ex) {
+ throw new RuntimeException(ex);
+ }
+ setDaemon(true);
+ }
+
+ public int getPortNumber() {
+ return PORT;
+ }
+
+ @Override
+ public void run() {
+ try (Socket socket = serverSocket.accept();
+ InputStream in = socket.getInputStream();
+ OutputStream out = socket.getOutputStream()) {
+ if (isForceToSleep) {
+ Thread.sleep(sleepingTime);
+ }
+ byte[] bindResponse = {0x30, 0x0C, 0x02, 0x01, 0x01, 0x61, 0x07, 0x0A,
+ 0x01, 0x00, 0x04, 0x00, 0x04, 0x00};
+ // read the bindRequest
+ while (in.read() != -1) {
+ in.skip(in.available());
+ break;
+ }
+ out.write(bindResponse);
+ out.flush();
+ // ignore the further requests
+ while (in.read() != -1) {
+ in.skip(in.available());
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void close() throws Exception {
+ if (serverSocket != null) {
+ serverSocket.close();
+ }
+ }
+ }
+}
+
+
diff --git a/test/jdk/com/sun/jndi/ldap/ksWithSAN b/test/jdk/com/sun/jndi/ldap/ksWithSAN
new file mode 100644
index 000000000..e69de29bb
--
2.22.0

View File

@ -0,0 +1,125 @@
From 99dde5664ec2941f6744391b3effb9466146c9df Mon Sep 17 00:00:00 2001
Subject: 8314236: Overflow in Collections.rotate
---
.../share/classes/java/util/Collections.java | 9 +-
.../jdk/java/util/Collections/RotateHuge.java | 83 +++++++++++++++++++
2 files changed, 88 insertions(+), 4 deletions(-)
create mode 100644 test/jdk/java/util/Collections/RotateHuge.java
diff --git a/src/java.base/share/classes/java/util/Collections.java b/src/java.base/share/classes/java/util/Collections.java
index 473de05f9..31e83060e 100644
--- a/src/java.base/share/classes/java/util/Collections.java
+++ b/src/java.base/share/classes/java/util/Collections.java
@@ -792,15 +792,16 @@ public class Collections {
if (distance == 0)
return;
- for (int cycleStart = 0, nMoved = 0; nMoved != size; cycleStart++) {
+ int bound = size - distance;
+ for (int cycleStart = 0, nMoved = 0; nMoved < size; cycleStart++) {
T displaced = list.get(cycleStart);
int i = cycleStart;
do {
- i += distance;
- if (i >= size)
+ if (i >= bound)
i -= size;
+ i += distance;
displaced = list.set(i, displaced);
- nMoved ++;
+ nMoved++;
} while (i != cycleStart);
}
}
diff --git a/test/jdk/java/util/Collections/RotateHuge.java b/test/jdk/java/util/Collections/RotateHuge.java
new file mode 100644
index 000000000..44368aff2
--- /dev/null
+++ b/test/jdk/java/util/Collections/RotateHuge.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2023, 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 8314236
+ * @summary Overflow in Collections.rotate
+ */
+
+import java.util.AbstractList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+import java.util.RandomAccess;
+
+public class RotateHuge {
+
+ private static final class MockList extends AbstractList<Object>
+ implements RandomAccess {
+ private final int size;
+
+ public MockList(final int size) {
+ if (size < 0)
+ throw new IllegalArgumentException("Illegal size: " + size);
+ this.size = size;
+ }
+
+ @Override
+ public Object get(final int index) {
+ Objects.checkIndex(index, size);
+ return null;
+ }
+
+ @Override
+ public Object set(final int index, final Object element) {
+ Objects.checkIndex(index, size);
+ return null;
+ }
+
+ @Override
+ public int size() {
+ return size;
+ }
+ }
+
+ public static void main(final String[] args) {
+ testRotate((1 << 30) + 1, -(1 << 30) - 2);
+ testRotate((1 << 30) + 1, 1 << 30);
+ testRotate(Integer.MAX_VALUE, Integer.MIN_VALUE);
+ testRotate(Integer.MAX_VALUE, Integer.MIN_VALUE + 3);
+ testRotate(Integer.MAX_VALUE, 2);
+ testRotate(Integer.MAX_VALUE, Integer.MAX_VALUE - 1);
+ }
+
+ /*
+ * This test covers only index computations.
+ * Correctness of elements rotation is not checked.
+ */
+ private static void testRotate(final int size, final int distance) {
+ final List<Object> list = new MockList(size);
+ Collections.rotate(list, distance);
+ }
+}
--
2.22.0

View File

@ -0,0 +1,262 @@
From f693db304169874bc69d84e1ffd93da6d585a417 Mon Sep 17 00:00:00 2001
Subject: 8316576: com.sun.jndi.ldap.Connection.cleanup does not close connections on SocketTimeoutErrors
---
.../classes/com/sun/jndi/ldap/Connection.java | 53 +++++-
.../com/sun/jndi/ldap/SocketCloseTest.java | 168 ++++++++++++++++++
2 files changed, 212 insertions(+), 9 deletions(-)
create mode 100644 test/jdk/com/sun/jndi/ldap/SocketCloseTest.java
diff --git a/src/java.naming/share/classes/com/sun/jndi/ldap/Connection.java b/src/java.naming/share/classes/com/sun/jndi/ldap/Connection.java
index d8de2ddbb..ebb21bd8b 100644
--- a/src/java.naming/share/classes/com/sun/jndi/ldap/Connection.java
+++ b/src/java.naming/share/classes/com/sun/jndi/ldap/Connection.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2023, 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
@@ -639,14 +639,12 @@ public final class Connection implements Runnable {
ldapUnbind(reqCtls);
}
} finally {
- try {
- outStream.flush();
- sock.close();
- unpauseReader();
- } catch (IOException ie) {
- if (debug)
- System.err.println("Connection: problem closing socket: " + ie);
- }
+
+ flushAndCloseOutputStream();
+ // 8313657 socket is not closed until GC is run
+ closeOpenedSocket();
+ tryUnpauseReader();
+
if (!notifyParent) {
LdapRequest ldr = pendingRequests;
while (ldr != null) {
@@ -680,6 +678,43 @@ public final class Connection implements Runnable {
}
}
+ // flush and close output stream
+ private void flushAndCloseOutputStream() {
+ try {
+ outStream.flush();
+ } catch (IOException ioEx) {
+ if (debug)
+ System.err.println("Connection.flushOutputStream: OutputStream flush problem " + ioEx);
+ }
+ try {
+ outStream.close();
+ } catch (IOException ioEx) {
+ if (debug)
+ System.err.println("Connection.closeOutputStream: OutputStream close problem " + ioEx);
+ }
+ }
+
+ // close socket
+ private void closeOpenedSocket() {
+ try {
+ sock.close();
+ } catch (IOException ioEx) {
+ if (debug) {
+ System.err.println("Connection.closeConnectionSocket: Socket close problem: " + ioEx);
+ System.err.println("Socket isClosed: " + sock.isClosed());
+ }
+ }
+ }
+
+ // unpause reader
+ private void tryUnpauseReader() {
+ try {
+ unpauseReader();
+ } catch (IOException ioEx) {
+ if (debug)
+ System.err.println("Connection.tryUnpauseReader: unpauseReader problem " + ioEx);
+ }
+ }
// Assume everything is "quiet"
// "synchronize" might lead to deadlock so don't synchronize method
diff --git a/test/jdk/com/sun/jndi/ldap/SocketCloseTest.java b/test/jdk/com/sun/jndi/ldap/SocketCloseTest.java
new file mode 100644
index 000000000..a33beb6ca
--- /dev/null
+++ b/test/jdk/com/sun/jndi/ldap/SocketCloseTest.java
@@ -0,0 +1,168 @@
+/*
+ * Copyright (c) 2023, 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 javax.naming.Context;
+import javax.naming.directory.DirContext;
+import javax.naming.directory.InitialDirContext;
+import javax.net.SocketFactory;
+import java.net.InetAddress;
+import java.net.Socket;
+import java.net.SocketAddress;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Hashtable;
+
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
+
+/*
+ * @test
+ * @bug 8313657
+ * @summary make sure socket is closed when the error happens for OutputStream flushing
+ * The value of provider url can be random, not necessary to be the one in the code
+ * @library /test/lib
+ * @run main/othervm SocketCloseTest
+ */
+
+public class SocketCloseTest {
+ public static String SOCKET_CLOSED_MSG = "The socket has been closed.";
+ public static String SOCKET_NOT_CLOSED_MSG = "The socket was not closed.";
+ public static String BAD_FLUSH = "Bad flush!";
+ private static final byte[] BIND_RESPONSE = new byte[]{
+ 48, 12, 2, 1, 1, 97, 7, 10, 1, 0, 4, 0, 4, 0
+ };
+
+ public static void main(String[] args) throws Exception {
+ SocketCloseTest scTest = new SocketCloseTest();
+ scTest.runCloseSocketScenario();
+ }
+
+ public void runCloseSocketScenario() throws Exception {
+ Hashtable<String, Object> props = new Hashtable<>();
+
+ props.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
+ props.put(Context.PROVIDER_URL, "ldap://localhost:1389/o=example");
+ props.put("java.naming.ldap.factory.socket", CustomSocketFactory.class.getName());
+ try {
+ final DirContext ctx = new InitialDirContext(props);
+ } catch (Exception e) {
+ if (CustomSocketFactory.customSocket.closeMethodCalledCount() > 0) {
+ System.out.println(SOCKET_CLOSED_MSG);
+ } else {
+ System.out.println(SOCKET_NOT_CLOSED_MSG);
+ throw e;
+ }
+ }
+ }
+
+ public static class CustomSocketFactory extends SocketFactory {
+ public static CustomSocket customSocket = new CustomSocket();
+
+ public static CustomSocketFactory getDefault() {
+ return new CustomSocketFactory();
+ }
+
+ @Override
+ public Socket createSocket() {
+ return customSocket;
+ }
+
+ @Override
+ public Socket createSocket(String s, int timeout) {
+ return customSocket;
+ }
+
+ @Override
+ public Socket createSocket(String host, int port, InetAddress localHost,
+ int localPort) {
+ return customSocket;
+ }
+
+ @Override
+ public Socket createSocket(InetAddress host, int port) {
+ return customSocket;
+ }
+
+ @Override
+ public Socket createSocket(InetAddress address, int port,
+ InetAddress localAddress, int localPort) {
+ return customSocket;
+ }
+ }
+
+ private static class LdapInputStream extends InputStream {
+ private ByteArrayInputStream bos;
+
+ public LdapInputStream() {
+ }
+
+ @Override
+ public int read() throws IOException {
+ bos = new ByteArrayInputStream(BIND_RESPONSE);
+ return bos.read();
+ }
+ }
+
+ private static class LdapOutputStream extends OutputStream {
+
+ @Override
+ public void write(int b) throws IOException {
+ System.out.println("output stream writing");
+ }
+
+ @Override
+ public void flush() throws IOException {
+ System.out.println(BAD_FLUSH);
+ throw new IOException(BAD_FLUSH);
+ }
+ }
+
+ private static class CustomSocket extends Socket {
+ private int closeMethodCalled = 0;
+ private LdapOutputStream output = new LdapOutputStream();
+ private LdapInputStream input = new LdapInputStream();
+
+ public void connect(SocketAddress address, int timeout) {
+ }
+
+ public InputStream getInputStream() {
+ return input;
+ }
+
+ public OutputStream getOutputStream() {
+ return output;
+ }
+
+ public int closeMethodCalledCount() {
+ return closeMethodCalled;
+ }
+
+ @Override
+ public void close() throws IOException {
+ closeMethodCalled++;
+ super.close();
+ }
+ }
+}
--
2.22.0

File diff suppressed because it is too large Load Diff

View File

@ -50,7 +50,7 @@ Subject: Apply TBI to ZGC of JDK17
44 files changed, 685 insertions(+), 69 deletions(-)
diff --git a/src/hotspot/cpu/aarch64/aarch64.ad b/src/hotspot/cpu/aarch64/aarch64.ad
index a030555c9..7cc2e797a 100644
index 91ea50c00..b3d89863e 100644
--- a/src/hotspot/cpu/aarch64/aarch64.ad
+++ b/src/hotspot/cpu/aarch64/aarch64.ad
@@ -1750,7 +1750,11 @@ int MachCallStaticJavaNode::ret_addr_offset()
@ -81,7 +81,7 @@ index a030555c9..7cc2e797a 100644
}
diff --git a/src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.cpp b/src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.cpp
index f488e863a..cfe8e85a1 100644
index 5ce3ecf9e..c69f8aaf1 100644
--- a/src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.cpp
+++ b/src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.cpp
@@ -94,6 +94,11 @@ static void select_different_registers(Register preserve,
@ -498,7 +498,7 @@ index 3c779bb11..4a2af011f 100644
+
#endif // CPU_AARCH64_GLOBALDEFINITIONS_AARCH64_HPP
diff --git a/src/hotspot/cpu/aarch64/globals_aarch64.hpp b/src/hotspot/cpu/aarch64/globals_aarch64.hpp
index 3ccf7630b..98c87b201 100644
index fefc2e5c3..cae9fb60c 100644
--- a/src/hotspot/cpu/aarch64/globals_aarch64.hpp
+++ b/src/hotspot/cpu/aarch64/globals_aarch64.hpp
@@ -119,7 +119,10 @@ define_pd_global(intx, InlineSmallCode, 1000);
@ -541,10 +541,10 @@ index 17b978012..b52b3f2b3 100644
}
#endif // ASSERT
diff --git a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp
index 85ce4c44b..6294636c2 100644
index 676a548d0..d89d655af 100644
--- a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp
+++ b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp
@@ -174,9 +174,10 @@ int MacroAssembler::patch_oop(address insn_addr, address o) {
@@ -176,9 +176,10 @@ int MacroAssembler::patch_oop(address insn_addr, address o) {
unsigned insn = *(unsigned*)insn_addr;
assert(nativeInstruction_at(insn_addr+4)->is_movk(), "wrong insns in patch");
@ -556,7 +556,7 @@ index 85ce4c44b..6294636c2 100644
if (Instruction_aarch64::extract(insn, 31, 21) == 0b11010010101) {
// Move narrow OOP
uint32_t n = CompressedOops::narrow_oop_value(cast_to_oop(o));
@@ -191,6 +192,12 @@ int MacroAssembler::patch_oop(address insn_addr, address o) {
@@ -193,6 +194,12 @@ int MacroAssembler::patch_oop(address insn_addr, address o) {
Instruction_aarch64::patch(insn_addr+4, 20, 5, (dest >>= 16) & 0xffff);
Instruction_aarch64::patch(insn_addr+8, 20, 5, (dest >>= 16) & 0xffff);
instructions = 3;
@ -569,7 +569,7 @@ index 85ce4c44b..6294636c2 100644
}
return instructions * NativeInstruction::instruction_size;
}
@@ -277,12 +284,18 @@ address MacroAssembler::target_addr_for_insn(address insn_addr, unsigned insn) {
@@ -279,12 +286,18 @@ address MacroAssembler::target_addr_for_insn(address insn_addr, unsigned insn) {
}
} else if (Instruction_aarch64::extract(insn, 31, 23) == 0b110100101) {
uint32_t *insns = (uint32_t *)insn_addr;
@ -593,7 +593,7 @@ index 85ce4c44b..6294636c2 100644
} else if (Instruction_aarch64::extract(insn, 31, 22) == 0b1011100101 &&
Instruction_aarch64::extract(insn, 4, 0) == 0b11111) {
return 0;
@@ -1473,10 +1486,9 @@ void MacroAssembler::mov(Register r, Address dest) {
@@ -1505,10 +1518,9 @@ void MacroAssembler::mov(Register r, Address dest) {
movptr(r, imm64);
}
@ -607,7 +607,7 @@ index 85ce4c44b..6294636c2 100644
void MacroAssembler::movptr(Register r, uintptr_t imm64) {
#ifndef PRODUCT
{
@@ -1485,12 +1497,18 @@ void MacroAssembler::movptr(Register r, uintptr_t imm64) {
@@ -1517,12 +1529,18 @@ void MacroAssembler::movptr(Register r, uintptr_t imm64) {
block_comment(buffer);
}
#endif
@ -729,7 +729,7 @@ index 75f2797c3..2460c02a1 100644
void set_jump_destination(address dest);
diff --git a/src/hotspot/cpu/aarch64/vm_version_aarch64.cpp b/src/hotspot/cpu/aarch64/vm_version_aarch64.cpp
index f9de88613..0fa922ec9 100644
index 31dfb7727..bcd064cfe 100644
--- a/src/hotspot/cpu/aarch64/vm_version_aarch64.cpp
+++ b/src/hotspot/cpu/aarch64/vm_version_aarch64.cpp
@@ -31,6 +31,10 @@
@ -760,7 +760,7 @@ index f9de88613..0fa922ec9 100644
void VM_Version::initialize() {
_supports_cx8 = true;
_supports_atomic_getset4 = true;
@@ -406,6 +420,20 @@ void VM_Version::initialize() {
@@ -415,6 +429,20 @@ void VM_Version::initialize() {
UsePopCountInstruction = true;
}
@ -1418,7 +1418,7 @@ index 7afd60105..1013855c9 100644
#endif // SHARE_GC_Z_ZNMETHODDATA_HPP
diff --git a/src/hotspot/share/gc/z/zPhysicalMemory.cpp b/src/hotspot/share/gc/z/zPhysicalMemory.cpp
index f2b80b02e..9df44677a 100644
index ad8b762bd..38422d37c 100644
--- a/src/hotspot/share/gc/z/zPhysicalMemory.cpp
+++ b/src/hotspot/share/gc/z/zPhysicalMemory.cpp
@@ -277,13 +277,21 @@ void ZPhysicalMemoryManager::try_enable_uncommit(size_t min_capacity, size_t max
@ -1434,7 +1434,7 @@ index f2b80b02e..9df44677a 100644
}
void ZPhysicalMemoryManager::nmt_uncommit(uintptr_t offset, size_t size) const {
if (MemTracker::tracking_level() > NMT_minimal) {
if (MemTracker::enabled()) {
+#ifdef AARCH64
+ const uintptr_t addr = UseTBI ? ZAddress::base(offset) : ZAddress::marked0(offset);
+#else // AARCH64

View File

@ -1,8 +1,17 @@
From 81e5f144710e946f70db91329a79b9ebcd76c2f3 Mon Sep 17 00:00:00 2001
From: zhangyipeng <zhangyipeng7@huawei.com>
Date: Wed, 15 Dec 2021 17:04:17 +0800
From 6ae9bfbc94701aa91941169aff53863fe004db49 Mon Sep 17 00:00:00 2001
Date: Mon, 24 Apr 2023 19:10:50 +0800
Subject: [PATCH] Delete expired certificate
---
make/data/cacerts/geotrustglobalca | 27 ------------
make/data/cacerts/luxtrustglobalrootca | 28 -------------
make/data/cacerts/quovadisrootca | 41 -------------------
.../security/lib/cacerts/VerifyCACerts.java | 16 +-------
4 files changed, 2 insertions(+), 110 deletions(-)
delete mode 100644 make/data/cacerts/geotrustglobalca
delete mode 100644 make/data/cacerts/luxtrustglobalrootca
delete mode 100644 make/data/cacerts/quovadisrootca
diff --git a/make/data/cacerts/geotrustglobalca b/make/data/cacerts/geotrustglobalca
deleted file mode 100644
index 7f8bf9a66..000000000
@ -118,21 +127,21 @@ index 0c195ff51..000000000
-SnQ2+Q==
------END CERTIFICATE-----
diff --git a/test/jdk/sun/security/lib/cacerts/VerifyCACerts.java b/test/jdk/sun/security/lib/cacerts/VerifyCACerts.java
index f39dca74a..768b6572c 100644
index c67aa91dd..9079299fb 100644
--- a/test/jdk/sun/security/lib/cacerts/VerifyCACerts.java
+++ b/test/jdk/sun/security/lib/cacerts/VerifyCACerts.java
@@ -54,12 +54,12 @@ public class VerifyCACerts {
+ File.separator + "security" + File.separator + "cacerts";
// The numbers of certs now.
- private static final int COUNT = 89;
+ private static final int COUNT = 86;
- private static final int COUNT = 90;
+ private static final int COUNT = 87;
// 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
- = "CC:AD:BB:49:70:97:3F:42:AD:73:91:A0:A2:C4:B8:AA:D1:95:59:F3:B3:22:09:2A:1F:2C:AB:04:47:08:EF:AA";
+ = "89:78:5A:96:F4:B2:68:4C:91:C0:32:2C:ED:2D:6B:3B:26:B8:37:C3:07:DD:9E:50:87:53:53:7A:24:98:97:E0";
- = "21:8C:35:29:4C:E2:49:D2:83:30:DF:8B:5E:39:F8:8C:D6:C5:2B:59:05:32:74:E5:79:A5:91:9F:3C:57:B9:E3";
+ = "D5:5B:7A:BD:8F:4A:DA:19:75:90:28:61:E7:40:6D:A2:54:F5:64:C0:F0:30:29:16:FB:46:9B:57:D5:F7:04:D7";
// Hex formatter to upper case with ":" delimiter
private static final HexFormat HEX = HexFormat.ofDelimiter(":").withUpperCase();
@ -156,7 +165,7 @@ index f39dca74a..768b6572c 100644
put("quovadisrootca1g3 [jdk]",
"8A:86:6F:D1:B2:76:B5:7E:57:8E:92:1C:65:82:8A:2B:ED:58:E9:F2:F2:88:05:41:34:B7:F1:F4:BF:C9:CC:74");
put("quovadisrootca2 [jdk]",
@@ -260,12 +254,6 @@ public class VerifyCACerts {
@@ -262,12 +256,6 @@ public class VerifyCACerts {
add("addtrustexternalca [jdk]");
// Valid until: Sat May 30 10:44:50 GMT 2020
add("addtrustqualifiedca [jdk]");

123024
LoongArch64-support.patch Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,458 @@
From 5cdf192706cc66ab8228057151bd807ea6267222 Mon Sep 17 00:00:00 2001
Date: Thu, 21 Sep 2023 16:44:51 +0800
Subject: add 8267185-Add-string-deduplication-support-to
---
.../gc/parallel/parallelScavengeHeap.cpp | 13 +++++
.../gc/parallel/parallelScavengeHeap.hpp | 3 ++
.../share/gc/parallel/psCompactionManager.cpp | 6 +++
.../share/gc/parallel/psCompactionManager.hpp | 9 ++++
.../parallel/psCompactionManager.inline.hpp | 7 +++
.../share/gc/parallel/psParallelCompact.cpp | 3 ++
.../share/gc/parallel/psPromotionManager.cpp | 1 +
.../share/gc/parallel/psPromotionManager.hpp | 5 ++
.../gc/parallel/psPromotionManager.inline.hpp | 7 +++
.../share/gc/parallel/psStringDedup.hpp | 50 +++++++++++++++++++
.../shared/stringdedup/stringDedupConfig.cpp | 2 +-
.../TestStringDeduplicationAgeThreshold.java | 13 +++++
.../TestStringDeduplicationFullGC.java | 13 +++++
.../TestStringDeduplicationInterned.java | 13 +++++
.../TestStringDeduplicationPrintOptions.java | 13 +++++
.../TestStringDeduplicationTableResize.java | 13 +++++
.../TestStringDeduplicationYoungGC.java | 13 +++++
17 files changed, 183 insertions(+), 1 deletion(-)
create mode 100644 src/hotspot/share/gc/parallel/psStringDedup.hpp
diff --git a/src/hotspot/share/gc/parallel/parallelScavengeHeap.cpp b/src/hotspot/share/gc/parallel/parallelScavengeHeap.cpp
index 16c7d91c4..cf9d34eb9 100644
--- a/src/hotspot/share/gc/parallel/parallelScavengeHeap.cpp
+++ b/src/hotspot/share/gc/parallel/parallelScavengeHeap.cpp
@@ -41,6 +41,7 @@
#include "gc/shared/gcInitLogger.hpp"
#include "gc/shared/locationPrinter.inline.hpp"
#include "gc/shared/scavengableNMethods.hpp"
+#include "gc/shared/suspendibleThreadSet.hpp"
#include "logging/log.hpp"
#include "memory/iterator.hpp"
#include "memory/metaspaceCounters.hpp"
@@ -162,6 +163,18 @@ void ParallelScavengeHeap::initialize_serviceability() {
}
+void ParallelScavengeHeap::safepoint_synchronize_begin() {
+ if (UseStringDeduplication) {
+ SuspendibleThreadSet::synchronize();
+ }
+}
+
+void ParallelScavengeHeap::safepoint_synchronize_end() {
+ if (UseStringDeduplication) {
+ SuspendibleThreadSet::desynchronize();
+ }
+}
+
class PSIsScavengable : public BoolObjectClosure {
bool do_object_b(oop obj) {
return ParallelScavengeHeap::heap()->is_in_young(obj);
diff --git a/src/hotspot/share/gc/parallel/parallelScavengeHeap.hpp b/src/hotspot/share/gc/parallel/parallelScavengeHeap.hpp
index 689400fbe..b35df689f 100644
--- a/src/hotspot/share/gc/parallel/parallelScavengeHeap.hpp
+++ b/src/hotspot/share/gc/parallel/parallelScavengeHeap.hpp
@@ -139,6 +139,9 @@ class ParallelScavengeHeap : public CollectedHeap {
// Returns JNI_OK on success
virtual jint initialize();
+ virtual void safepoint_synchronize_begin();
+ virtual void safepoint_synchronize_end();
+
void post_initialize();
void update_counters();
diff --git a/src/hotspot/share/gc/parallel/psCompactionManager.cpp b/src/hotspot/share/gc/parallel/psCompactionManager.cpp
index b2c17140d..bab67b219 100644
--- a/src/hotspot/share/gc/parallel/psCompactionManager.cpp
+++ b/src/hotspot/share/gc/parallel/psCompactionManager.cpp
@@ -107,6 +107,12 @@ void ParCompactionManager::reset_all_bitmap_query_caches() {
}
}
+void ParCompactionManager::flush_all_string_dedup_requests() {
+ uint parallel_gc_threads = ParallelScavengeHeap::heap()->workers().total_workers();
+ for (uint i=0; i<=parallel_gc_threads; i++) {
+ _manager_array[i]->flush_string_dedup_requests();
+ }
+}
ParCompactionManager*
ParCompactionManager::gc_thread_compaction_manager(uint index) {
diff --git a/src/hotspot/share/gc/parallel/psCompactionManager.hpp b/src/hotspot/share/gc/parallel/psCompactionManager.hpp
index 12b5d891d..86810d32c 100644
--- a/src/hotspot/share/gc/parallel/psCompactionManager.hpp
+++ b/src/hotspot/share/gc/parallel/psCompactionManager.hpp
@@ -26,6 +26,7 @@
#define SHARE_GC_PARALLEL_PSCOMPACTIONMANAGER_HPP
#include "gc/parallel/psParallelCompact.hpp"
+#include "gc/shared/stringdedup/stringDedup.hpp"
#include "gc/shared/taskqueue.hpp"
#include "gc/shared/taskTerminator.hpp"
#include "memory/allocation.hpp"
@@ -88,6 +89,8 @@ class ParCompactionManager : public CHeapObj<mtGC> {
oop _last_query_obj;
size_t _last_query_ret;
+ StringDedup::Requests _string_dedup_requests;
+
static PSOldGen* old_gen() { return _old_gen; }
static ObjectStartArray* start_array() { return _start_array; }
static OopTaskQueueSet* oop_task_queues() { return _oop_task_queues; }
@@ -126,6 +129,10 @@ class ParCompactionManager : public CHeapObj<mtGC> {
_last_query_ret = 0;
}
+ void flush_string_dedup_requests() {
+ _string_dedup_requests.flush();
+ }
+
// Bitmap query support, cache last query and result
HeapWord* last_query_begin() { return _last_query_beg; }
oop last_query_object() { return _last_query_obj; }
@@ -137,6 +144,8 @@ class ParCompactionManager : public CHeapObj<mtGC> {
static void reset_all_bitmap_query_caches();
+ static void flush_all_string_dedup_requests();
+
RegionTaskQueue* region_stack() { return &_region_stack; }
static ParCompactionManager* get_vmthread_cm() { return _manager_array[ParallelGCThreads]; }
diff --git a/src/hotspot/share/gc/parallel/psCompactionManager.inline.hpp b/src/hotspot/share/gc/parallel/psCompactionManager.inline.hpp
index e40e3689d..45e8dae5a 100644
--- a/src/hotspot/share/gc/parallel/psCompactionManager.inline.hpp
+++ b/src/hotspot/share/gc/parallel/psCompactionManager.inline.hpp
@@ -31,6 +31,7 @@
#include "classfile/javaClasses.inline.hpp"
#include "gc/parallel/parMarkBitMap.hpp"
#include "gc/parallel/psParallelCompact.inline.hpp"
+#include "gc/parallel/psStringDedup.hpp"
#include "gc/shared/taskqueue.inline.hpp"
#include "oops/access.inline.hpp"
#include "oops/arrayOop.hpp"
@@ -108,6 +109,12 @@ inline void ParCompactionManager::mark_and_push(T* p) {
if (mark_bitmap()->is_unmarked(obj) && PSParallelCompact::mark_obj(obj)) {
push(obj);
+
+ if (StringDedup::is_enabled() &&
+ java_lang_String::is_instance_inlined(obj) &&
+ psStringDedup::is_candidate_from_mark(obj)) {
+ _string_dedup_requests.add(obj);
+ }
}
}
}
diff --git a/src/hotspot/share/gc/parallel/psParallelCompact.cpp b/src/hotspot/share/gc/parallel/psParallelCompact.cpp
index 3c276db70..8ac733fa5 100644
--- a/src/hotspot/share/gc/parallel/psParallelCompact.cpp
+++ b/src/hotspot/share/gc/parallel/psParallelCompact.cpp
@@ -41,6 +41,7 @@
#include "gc/parallel/psRootType.hpp"
#include "gc/parallel/psScavenge.hpp"
#include "gc/parallel/psYoungGen.hpp"
+#include "gc/parallel/psStringDedup.hpp"
#include "gc/shared/gcCause.hpp"
#include "gc/shared/gcHeapSummary.hpp"
#include "gc/shared/gcId.hpp"
@@ -1021,6 +1022,8 @@ void PSParallelCompact::post_compact()
_space_info[id].publish_new_top();
}
+ ParCompactionManager::flush_all_string_dedup_requests();
+
MutableSpace* const eden_space = _space_info[eden_space_id].space();
MutableSpace* const from_space = _space_info[from_space_id].space();
MutableSpace* const to_space = _space_info[to_space_id].space();
diff --git a/src/hotspot/share/gc/parallel/psPromotionManager.cpp b/src/hotspot/share/gc/parallel/psPromotionManager.cpp
index c5f321f54..56e2683f3 100644
--- a/src/hotspot/share/gc/parallel/psPromotionManager.cpp
+++ b/src/hotspot/share/gc/parallel/psPromotionManager.cpp
@@ -121,6 +121,7 @@ bool PSPromotionManager::post_scavenge(YoungGCTracer& gc_tracer) {
promotion_failure_occurred = true;
}
manager->flush_labs();
+ manager->flush_string_dedup_requests();
}
if (!promotion_failure_occurred) {
// If there was no promotion failure, the preserved mark stacks
diff --git a/src/hotspot/share/gc/parallel/psPromotionManager.hpp b/src/hotspot/share/gc/parallel/psPromotionManager.hpp
index e94be81b6..462beec76 100644
--- a/src/hotspot/share/gc/parallel/psPromotionManager.hpp
+++ b/src/hotspot/share/gc/parallel/psPromotionManager.hpp
@@ -29,6 +29,7 @@
#include "gc/shared/copyFailedInfo.hpp"
#include "gc/shared/gcTrace.hpp"
#include "gc/shared/preservedMarks.hpp"
+#include "gc/shared/stringdedup/stringDedup.hpp"
#include "gc/shared/taskqueue.hpp"
#include "memory/padded.hpp"
#include "utilities/globalDefinitions.hpp"
@@ -92,6 +93,8 @@ class PSPromotionManager {
PreservedMarks* _preserved_marks;
PromotionFailedInfo _promotion_failed_info;
+ StringDedup::Requests _string_dedup_requests;
+
// Accessors
static PSOldGen* old_gen() { return _old_gen; }
static MutableSpace* young_space() { return _young_space; }
@@ -146,6 +149,8 @@ class PSPromotionManager {
static void restore_preserved_marks();
void flush_labs();
+ void flush_string_dedup_requests() { _string_dedup_requests.flush(); }
+
void drain_stacks(bool totally_drain) {
drain_stacks_depth(totally_drain);
}
diff --git a/src/hotspot/share/gc/parallel/psPromotionManager.inline.hpp b/src/hotspot/share/gc/parallel/psPromotionManager.inline.hpp
index a0149e447..e754d84b6 100644
--- a/src/hotspot/share/gc/parallel/psPromotionManager.inline.hpp
+++ b/src/hotspot/share/gc/parallel/psPromotionManager.inline.hpp
@@ -32,6 +32,7 @@
#include "gc/parallel/psOldGen.hpp"
#include "gc/parallel/psPromotionLAB.inline.hpp"
#include "gc/parallel/psScavenge.inline.hpp"
+#include "gc/parallel/psStringDedup.hpp"
#include "gc/shared/taskqueue.inline.hpp"
#include "gc/shared/tlab_globals.hpp"
#include "logging/log.hpp"
@@ -286,6 +287,12 @@ inline oop PSPromotionManager::copy_unmarked_to_survivor_space(oop o,
} else {
// we'll just push its contents
push_contents(new_obj);
+
+ if (StringDedup::is_enabled() &&
+ java_lang_String::is_instance_inlined(new_obj) &&
+ psStringDedup::is_candidate_from_evacuation(new_obj, new_obj_is_tenured)) {
+ _string_dedup_requests.add(o);
+ }
}
return new_obj;
} else {
diff --git a/src/hotspot/share/gc/parallel/psStringDedup.hpp b/src/hotspot/share/gc/parallel/psStringDedup.hpp
new file mode 100644
index 000000000..d1debbddc
--- /dev/null
+++ b/src/hotspot/share/gc/parallel/psStringDedup.hpp
@@ -0,0 +1,50 @@
+/*
+ * 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_GC_PARALLEL_PSSTRINGDEDUP_HPP
+#define SHARE_GC_PARALLEL_PSSTRINGDEDUP_HPP
+
+#include "gc/parallel/psScavenge.hpp"
+#include "gc/shared/stringdedup/stringDedup.hpp"
+#include "memory/allStatic.hpp"
+#include "oops/oopsHierarchy.hpp"
+
+class psStringDedup : AllStatic {
+public:
+ static bool is_candidate_from_mark(oop java_string) {
+ // Candidate if string is being evacuated from young to old but has not
+ // reached the deduplication age threshold, i.e. has not previously been a
+ // candidate during its life in the young generation.
+ return PSScavenge::is_obj_in_young(java_string) &&
+ StringDedup::is_below_threshold_age(java_string->age());
+ }
+
+ static bool is_candidate_from_evacuation(oop obj,
+ bool obj_is_tenured) {
+ return obj_is_tenured ?
+ StringDedup::is_below_threshold_age(obj->age()) :
+ StringDedup::is_threshold_age(obj->age());
+ }
+};
+#endif // SHARE_GC_PARALLEL_PSSTRINGDEDUP_HPP
diff --git a/src/hotspot/share/gc/shared/stringdedup/stringDedupConfig.cpp b/src/hotspot/share/gc/shared/stringdedup/stringDedupConfig.cpp
index 71ec8d563..258f497c5 100644
--- a/src/hotspot/share/gc/shared/stringdedup/stringDedupConfig.cpp
+++ b/src/hotspot/share/gc/shared/stringdedup/stringDedupConfig.cpp
@@ -116,7 +116,7 @@ size_t StringDedup::Config::desired_table_size(size_t entry_count) {
bool StringDedup::Config::ergo_initialize() {
if (!UseStringDeduplication) {
return true;
- } else if (!UseG1GC && !UseShenandoahGC) {
+ } else if (!UseG1GC && !UseShenandoahGC && !UseParallelGC) {
// String deduplication requested but not supported by the selected GC.
// Warn and force disable, but don't error except in debug build with
// incorrect default.
diff --git a/test/hotspot/jtreg/gc/stringdedup/TestStringDeduplicationAgeThreshold.java b/test/hotspot/jtreg/gc/stringdedup/TestStringDeduplicationAgeThreshold.java
index ae57bf7df..f652b58d2 100644
--- a/test/hotspot/jtreg/gc/stringdedup/TestStringDeduplicationAgeThreshold.java
+++ b/test/hotspot/jtreg/gc/stringdedup/TestStringDeduplicationAgeThreshold.java
@@ -36,6 +36,19 @@ package gc.stringdedup;
* @run driver gc.stringdedup.TestStringDeduplicationAgeThreshold G1
*/
+/*
+ * @test TestStringDeduplicationAgeThreshold
+ * @summary Test string deduplication age threshold
+ * @bug 8029075
+ * @requires vm.gc.Parallel
+ * @library /test/lib
+ * @library /
+ * @modules java.base/jdk.internal.misc:open
+ * @modules java.base/java.lang:open
+ * java.management
+ * @run driver gc.stringdedup.TestStringDeduplicationAgeThreshold Parallel
+ */
+
/*
* @test TestStringDeduplicationAgeThreshold
* @summary Test string deduplication age threshold
diff --git a/test/hotspot/jtreg/gc/stringdedup/TestStringDeduplicationFullGC.java b/test/hotspot/jtreg/gc/stringdedup/TestStringDeduplicationFullGC.java
index 7e5bb9ae5..83a652a8e 100644
--- a/test/hotspot/jtreg/gc/stringdedup/TestStringDeduplicationFullGC.java
+++ b/test/hotspot/jtreg/gc/stringdedup/TestStringDeduplicationFullGC.java
@@ -36,6 +36,19 @@ package gc.stringdedup;
* @run driver gc.stringdedup.TestStringDeduplicationFullGC G1
*/
+/*
+ * @test TestStringDeduplicationFullGC
+ * @summary Test string deduplication during full GC
+ * @bug 8029075
+ * @requires vm.gc.Parallel
+ * @library /test/lib
+ * @library /
+ * @modules java.base/jdk.internal.misc:open
+ * @modules java.base/java.lang:open
+ * java.management
+ * @run driver gc.stringdedup.TestStringDeduplicationFullGC Parallel
+ */
+
/*
* @test TestStringDeduplicationFullGC
* @summary Test string deduplication during full GC
diff --git a/test/hotspot/jtreg/gc/stringdedup/TestStringDeduplicationInterned.java b/test/hotspot/jtreg/gc/stringdedup/TestStringDeduplicationInterned.java
index a5720b88e..a39419f0a 100644
--- a/test/hotspot/jtreg/gc/stringdedup/TestStringDeduplicationInterned.java
+++ b/test/hotspot/jtreg/gc/stringdedup/TestStringDeduplicationInterned.java
@@ -48,6 +48,20 @@ package gc.stringdedup;
* java.management
* @run driver gc.stringdedup.TestStringDeduplicationInterned Shenandoah
*/
+
+/*
+ * @test TestStringDeduplicationInterned
+ * @summary Test string deduplication of interned strings
+ * @bug 8029075
+ * @requires vm.gc.Parallel
+ * @library /test/lib
+ * @library /
+ * @modules java.base/jdk.internal.misc:open
+ * @modules java.base/java.lang:open
+ * java.management
+ * @run driver gc.stringdedup.TestStringDeduplicationInterned Parallel
+ */
+
public class TestStringDeduplicationInterned {
public static void main(String[] args) throws Exception {
TestStringDeduplicationTools.selectGC(args);
diff --git a/test/hotspot/jtreg/gc/stringdedup/TestStringDeduplicationPrintOptions.java b/test/hotspot/jtreg/gc/stringdedup/TestStringDeduplicationPrintOptions.java
index d57e726a5..c3f2f10dc 100644
--- a/test/hotspot/jtreg/gc/stringdedup/TestStringDeduplicationPrintOptions.java
+++ b/test/hotspot/jtreg/gc/stringdedup/TestStringDeduplicationPrintOptions.java
@@ -36,6 +36,19 @@ package gc.stringdedup;
* @run driver gc.stringdedup.TestStringDeduplicationPrintOptions G1
*/
+/*
+ * @test TestStringDeduplicationPrintOptions
+ * @summary Test string deduplication print options
+ * @bug 8029075
+ * @requires vm.gc.Parallel
+ * @library /test/lib
+ * @library /
+ * @modules java.base/jdk.internal.misc:open
+ * @modules java.base/java.lang:open
+ * java.management
+ * @run driver gc.stringdedup.TestStringDeduplicationPrintOptions Parallel
+ */
+
/*
* @test TestStringDeduplicationPrintOptions
* @summary Test string deduplication print options
diff --git a/test/hotspot/jtreg/gc/stringdedup/TestStringDeduplicationTableResize.java b/test/hotspot/jtreg/gc/stringdedup/TestStringDeduplicationTableResize.java
index 53c71f1ec..03070b1cb 100644
--- a/test/hotspot/jtreg/gc/stringdedup/TestStringDeduplicationTableResize.java
+++ b/test/hotspot/jtreg/gc/stringdedup/TestStringDeduplicationTableResize.java
@@ -36,6 +36,19 @@ package gc.stringdedup;
* @run driver gc.stringdedup.TestStringDeduplicationTableResize G1
*/
+/*
+ * @test TestStringDeduplicationTableResize
+ * @summary Test string deduplication table resize
+ * @bug 8029075
+ * @requires vm.gc.Parallel
+ * @library /test/lib
+ * @library /
+ * @modules java.base/jdk.internal.misc:open
+ * @modules java.base/java.lang:open
+ * java.management
+ * @run driver gc.stringdedup.TestStringDeduplicationTableResize Parallel
+ */
+
/*
* @test TestStringDeduplicationTableResize
* @summary Test string deduplication table resize
diff --git a/test/hotspot/jtreg/gc/stringdedup/TestStringDeduplicationYoungGC.java b/test/hotspot/jtreg/gc/stringdedup/TestStringDeduplicationYoungGC.java
index 02cf647e4..1f0e9a70e 100644
--- a/test/hotspot/jtreg/gc/stringdedup/TestStringDeduplicationYoungGC.java
+++ b/test/hotspot/jtreg/gc/stringdedup/TestStringDeduplicationYoungGC.java
@@ -36,6 +36,19 @@ package gc.stringdedup;
* @run driver gc.stringdedup.TestStringDeduplicationYoungGC G1
*/
+/*
+ * @test TestStringDeduplicationYoungGC
+ * @summary Test string deduplication during young GC
+ * @bug 8029075
+ * @requires vm.gc.Parallel
+ * @library /test/lib
+ * @library /
+ * @modules java.base/jdk.internal.misc:open
+ * @modules java.base/java.lang:open
+ * java.management
+ * @run driver gc.stringdedup.TestStringDeduplicationYoungGC Parallel
+ */
+
/*
* @test TestStringDeduplicationYoungGC
* @summary Test string deduplication during young GC
--
2.22.0

View File

@ -0,0 +1,49 @@
From fc855b8ef1862144827199a06d0bb13ddf696dd9 Mon Sep 17 00:00:00 2001
Date: Thu, 21 Sep 2023 16:43:49 +0800
Subject: add 8271579-G1-Move-copy-before-CAS-in-do_copy
---
src/hotspot/share/gc/g1/g1ParScanThreadState.cpp | 14 ++------------
1 file changed, 2 insertions(+), 12 deletions(-)
diff --git a/src/hotspot/share/gc/g1/g1ParScanThreadState.cpp b/src/hotspot/share/gc/g1/g1ParScanThreadState.cpp
index 896c891ae..49d627205 100644
--- a/src/hotspot/share/gc/g1/g1ParScanThreadState.cpp
+++ b/src/hotspot/share/gc/g1/g1ParScanThreadState.cpp
@@ -459,11 +459,11 @@ oop G1ParScanThreadState::do_copy_to_survivor_space(G1HeapRegionAttr const regio
// We're going to allocate linearly, so might as well prefetch ahead.
Prefetch::write(obj_ptr, PrefetchCopyIntervalInBytes);
+ Copy::aligned_disjoint_words(cast_from_oop<HeapWord*>(old), obj_ptr, word_sz);
const oop obj = cast_to_oop(obj_ptr);
const oop forward_ptr = old->forward_to_atomic(obj, old_mark, memory_order_relaxed);
if (forward_ptr == NULL) {
- Copy::aligned_disjoint_words(cast_from_oop<HeapWord*>(old), obj_ptr, word_sz);
{
const uint young_index = from_region->young_index_in_cset();
@@ -475,19 +475,9 @@ oop G1ParScanThreadState::do_copy_to_survivor_space(G1HeapRegionAttr const regio
if (dest_attr.is_young()) {
if (age < markWord::max_age) {
age++;
- }
- if (old_mark.has_displaced_mark_helper()) {
- // In this case, we have to install the old mark word containing the
- // displacement tag, and update the age in the displaced mark word.
- markWord new_mark = old_mark.displaced_mark_helper().set_age(age);
- old_mark.set_displaced_mark_helper(new_mark);
- obj->set_mark(old_mark);
- } else {
- obj->set_mark(old_mark.set_age(age));
+ obj->incr_age();
}
_age_table.add(age, word_sz);
- } else {
- obj->set_mark(old_mark);
}
// Most objects are not arrays, so do one array check rather than
--
2.22.0

View File

@ -0,0 +1,272 @@
From e29cbf64958dc5728a40290e6150ed4bf158e1d9 Mon Sep 17 00:00:00 2001
Date: Thu, 21 Sep 2023 16:45:13 +0800
Subject: add 8292296-Use-multiple-threads-to-process-Par
---
.../share/gc/parallel/psCompactionManager.cpp | 17 +++++-
.../share/gc/parallel/psCompactionManager.hpp | 7 ++-
.../share/gc/parallel/psParallelCompact.cpp | 58 +++++++------------
.../share/gc/parallel/psParallelCompact.hpp | 18 ++----
4 files changed, 47 insertions(+), 53 deletions(-)
diff --git a/src/hotspot/share/gc/parallel/psCompactionManager.cpp b/src/hotspot/share/gc/parallel/psCompactionManager.cpp
index bab67b219..1461dfe86 100644
--- a/src/hotspot/share/gc/parallel/psCompactionManager.cpp
+++ b/src/hotspot/share/gc/parallel/psCompactionManager.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2022, 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
@@ -63,6 +63,8 @@ ParCompactionManager::ParCompactionManager() {
_region_stack.initialize();
reset_bitmap_query_cache();
+
+ _deferred_obj_array = new (ResourceObj::C_HEAP, mtGC) GrowableArray<HeapWord*>(10, mtGC);
}
void ParCompactionManager::initialize(ParMarkBitMap* mbm) {
@@ -168,6 +170,15 @@ void ParCompactionManager::drain_region_stacks() {
} while (!region_stack()->is_empty());
}
+void ParCompactionManager::drain_deferred_objects() {
+ while (!_deferred_obj_array->is_empty()) {
+ HeapWord* addr = _deferred_obj_array->pop();
+ assert(addr != NULL, "expected a deferred object");
+ PSParallelCompact::update_deferred_object(this, addr);
+ }
+ _deferred_obj_array->clear_and_deallocate();
+}
+
size_t ParCompactionManager::pop_shadow_region_mt_safe(PSParallelCompact::RegionData* region_ptr) {
MonitorLocker ml(_shadow_region_monitor, Mutex::_no_safepoint_check_flag);
while (true) {
@@ -198,6 +209,10 @@ void ParCompactionManager::remove_all_shadow_regions() {
_shadow_region_array->clear();
}
+void ParCompactionManager::push_deferred_object(HeapWord* addr) {
+ _deferred_obj_array->push(addr);
+}
+
#ifdef ASSERT
void ParCompactionManager::verify_all_marking_stack_empty() {
uint parallel_gc_threads = ParallelGCThreads;
diff --git a/src/hotspot/share/gc/parallel/psCompactionManager.hpp b/src/hotspot/share/gc/parallel/psCompactionManager.hpp
index 86810d32c..6ce30f827 100644
--- a/src/hotspot/share/gc/parallel/psCompactionManager.hpp
+++ b/src/hotspot/share/gc/parallel/psCompactionManager.hpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2022, 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
@@ -75,6 +75,8 @@ class ParCompactionManager : public CHeapObj<mtGC> {
// type of TaskQueue.
RegionTaskQueue _region_stack;
+ GrowableArray<HeapWord*>* _deferred_obj_array;
+
static ParMarkBitMap* _mark_bitmap;
// Contains currently free shadow regions. We use it in
@@ -123,6 +125,8 @@ class ParCompactionManager : public CHeapObj<mtGC> {
return next_shadow_region();
}
+ void push_deferred_object(HeapWord* addr);
+
void reset_bitmap_query_cache() {
_last_query_beg = NULL;
_last_query_obj = NULL;
@@ -188,6 +192,7 @@ class ParCompactionManager : public CHeapObj<mtGC> {
// Process tasks remaining on any stack
void drain_region_stacks();
+ void drain_deferred_objects();
void follow_contents(oop obj);
void follow_array(objArrayOop array, int index);
diff --git a/src/hotspot/share/gc/parallel/psParallelCompact.cpp b/src/hotspot/share/gc/parallel/psParallelCompact.cpp
index 8ac733fa5..33e6efa5f 100644
--- a/src/hotspot/share/gc/parallel/psParallelCompact.cpp
+++ b/src/hotspot/share/gc/parallel/psParallelCompact.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2022, 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
@@ -2522,6 +2522,10 @@ public:
// Once a thread has drained it's stack, it should try to steal regions from
// other threads.
compaction_with_stealing_work(&_terminator, worker_id);
+
+ // At this point all regions have been compacted, so it's now safe
+ // to update the deferred objects that cross region boundaries.
+ cm->drain_deferred_objects();
}
};
@@ -2551,24 +2555,13 @@ void PSParallelCompact::compact() {
ParallelScavengeHeap::heap()->workers().run_task(&task);
#ifdef ASSERT
- // Verify that all regions have been processed before the deferred updates.
+ // Verify that all regions have been processed.
for (unsigned int id = old_space_id; id < last_space_id; ++id) {
verify_complete(SpaceId(id));
}
#endif
}
- {
- GCTraceTime(Trace, gc, phases) tm("Deferred Updates", &_gc_timer);
- // Update the deferred objects, if any. In principle, any compaction
- // manager can be used. However, since the current thread is VM thread, we
- // use the rightful one to keep the verification logic happy.
- ParCompactionManager* cm = ParCompactionManager::get_vmthread_cm();
- for (unsigned int id = old_space_id; id < last_space_id; ++id) {
- update_deferred_objects(cm, SpaceId(id));
- }
- }
-
DEBUG_ONLY(write_block_fill_histogram());
}
@@ -2695,32 +2688,23 @@ PSParallelCompact::SpaceId PSParallelCompact::space_id(HeapWord* addr) {
return last_space_id;
}
-void PSParallelCompact::update_deferred_objects(ParCompactionManager* cm,
- SpaceId id) {
- assert(id < last_space_id, "bad space id");
+void PSParallelCompact::update_deferred_object(ParCompactionManager* cm, HeapWord *addr) {
+#ifdef ASSERT
ParallelCompactData& sd = summary_data();
- const SpaceInfo* const space_info = _space_info + id;
- ObjectStartArray* const start_array = space_info->start_array();
+ size_t region_idx = sd.addr_to_region_idx(addr);
+ assert(sd.region(region_idx)->completed(), "first region must be completed before deferred updates");
+ assert(sd.region(region_idx + 1)->completed(), "second region must be completed before deferred updates");
+#endif
- const MutableSpace* const space = space_info->space();
- assert(space_info->dense_prefix() >= space->bottom(), "dense_prefix not set");
- HeapWord* const beg_addr = space_info->dense_prefix();
- HeapWord* const end_addr = sd.region_align_up(space_info->new_top());
-
- const RegionData* const beg_region = sd.addr_to_region_ptr(beg_addr);
- const RegionData* const end_region = sd.addr_to_region_ptr(end_addr);
- const RegionData* cur_region;
- for (cur_region = beg_region; cur_region < end_region; ++cur_region) {
- HeapWord* const addr = cur_region->deferred_obj_addr();
- if (addr != NULL) {
- if (start_array != NULL) {
- start_array->allocate_block(addr);
- }
- cm->update_contents(cast_to_oop(addr));
- assert(oopDesc::is_oop_or_null(cast_to_oop(addr)), "Expected an oop or NULL at " PTR_FORMAT, p2i(cast_to_oop(addr)));
- }
+ const SpaceInfo* const space_info = _space_info + space_id(addr);
+ ObjectStartArray* const start_array = space_info->start_array();
+ if (start_array != NULL) {
+ start_array->allocate_block(addr);
}
+
+ cm->update_contents(cast_to_oop(addr));
+ assert(oopDesc::is_oop(cast_to_oop(addr)), "Expected an oop at " PTR_FORMAT, p2i(cast_to_oop(addr)));
}
// Skip over count live words starting from beg, and return the address of the
@@ -2967,7 +2951,6 @@ void PSParallelCompact::fill_region(ParCompactionManager* cm, MoveAndUpdateClosu
if (closure.is_full()) {
decrement_destination_counts(cm, src_space_id, src_region_idx,
closure.source());
- region_ptr->set_deferred_obj_addr(NULL);
closure.complete_region(cm, dest_addr, region_ptr);
return;
}
@@ -3012,7 +2995,7 @@ void PSParallelCompact::fill_region(ParCompactionManager* cm, MoveAndUpdateClosu
if (status == ParMarkBitMap::would_overflow) {
// The last object did not fit. Note that interior oop updates were
// deferred, then copy enough of the object to fill the region.
- region_ptr->set_deferred_obj_addr(closure.destination());
+ cm->push_deferred_object(closure.destination());
status = closure.copy_until_full(); // copies from closure.source()
decrement_destination_counts(cm, src_space_id, src_region_idx,
@@ -3024,7 +3007,6 @@ void PSParallelCompact::fill_region(ParCompactionManager* cm, MoveAndUpdateClosu
if (status == ParMarkBitMap::full) {
decrement_destination_counts(cm, src_space_id, src_region_idx,
closure.source());
- region_ptr->set_deferred_obj_addr(NULL);
closure.complete_region(cm, dest_addr, region_ptr);
return;
}
diff --git a/src/hotspot/share/gc/parallel/psParallelCompact.hpp b/src/hotspot/share/gc/parallel/psParallelCompact.hpp
index c4319a080..7c8b1873a 100644
--- a/src/hotspot/share/gc/parallel/psParallelCompact.hpp
+++ b/src/hotspot/share/gc/parallel/psParallelCompact.hpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2022, 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
@@ -243,13 +243,6 @@ public:
// Reuse _source_region to store the corresponding shadow region index
size_t shadow_region() const { return _source_region; }
- // The object (if any) starting in this region and ending in a different
- // region that could not be updated during the main (parallel) compaction
- // phase. This is different from _partial_obj_addr, which is an object that
- // extends onto a source region. However, the two uses do not overlap in
- // time, so the same field is used to save space.
- HeapWord* deferred_obj_addr() const { return _partial_obj_addr; }
-
// The starting address of the partial object extending onto the region.
HeapWord* partial_obj_addr() const { return _partial_obj_addr; }
@@ -312,7 +305,6 @@ public:
void set_destination(HeapWord* addr) { _destination = addr; }
void set_source_region(size_t region) { _source_region = region; }
void set_shadow_region(size_t region) { _source_region = region; }
- void set_deferred_obj_addr(HeapWord* addr) { _partial_obj_addr = addr; }
void set_partial_obj_addr(HeapWord* addr) { _partial_obj_addr = addr; }
void set_partial_obj_size(size_t words) {
_partial_obj_size = (region_sz_t) words;
@@ -948,8 +940,8 @@ inline void ParMarkBitMapClosure::decrement_words_remaining(size_t words) {
// but do not have their references updated. References are not updated because
// it cannot easily be determined if the klass pointer KKK for the object AAA
// has been updated. KKK likely resides in a region to the left of the region
-// containing AAA. These AAA's have there references updated at the end in a
-// clean up phase. See the method PSParallelCompact::update_deferred_objects().
+// containing AAA. These AAA's have their references updated at the end in a
+// clean up phase. See the method PSParallelCompact::update_deferred_object().
// An alternate strategy is being investigated for this deferral of updating.
//
// Compaction is done on a region basis. A region that is ready to be filled is
@@ -1233,8 +1225,8 @@ class PSParallelCompact : AllStatic {
// Fill in the block table for the specified region.
static void fill_blocks(size_t region_idx);
- // Update the deferred objects in the space.
- static void update_deferred_objects(ParCompactionManager* cm, SpaceId id);
+ // Update a single deferred object.
+ static void update_deferred_object(ParCompactionManager* cm, HeapWord* addr);
static ParMarkBitMap* mark_bitmap() { return &_mark_bitmap; }
static ParallelCompactData& summary_data() { return _summary_data; }
--
2.22.0

View File

@ -0,0 +1,92 @@
From 1fe9667bb594b66f7363cec246ebc99cd0ac9103 Mon Sep 17 00:00:00 2001
Date: Thu, 21 Sep 2023 16:43:24 +0800
Subject: add Parallel-Full-gc-mark-stack-draining-should
---
.../share/gc/parallel/psCompactionManager.cpp | 18 +++++++++++++++---
.../share/gc/parallel/psCompactionManager.hpp | 1 +
.../share/gc/parallel/psParallelCompact.cpp | 12 +++++-------
3 files changed, 21 insertions(+), 10 deletions(-)
diff --git a/src/hotspot/share/gc/parallel/psCompactionManager.cpp b/src/hotspot/share/gc/parallel/psCompactionManager.cpp
index 117817caa..b2c17140d 100644
--- a/src/hotspot/share/gc/parallel/psCompactionManager.cpp
+++ b/src/hotspot/share/gc/parallel/psCompactionManager.cpp
@@ -115,12 +115,24 @@ ParCompactionManager::gc_thread_compaction_manager(uint index) {
return _manager_array[index];
}
+bool ParCompactionManager::transfer_from_overflow_stack(ObjArrayTask& task) {
+ while (_objarray_stack.pop_overflow(task)) {
+ if (!_objarray_stack.try_push_to_taskqueue(task)) {
+ return true;
+ }
+ }
+ return false;
+}
+
void ParCompactionManager::follow_marking_stacks() {
do {
- // Drain the overflow stack first, to allow stealing from the marking stack.
+ // First, try to move tasks from the overflow stack into the shared buffer, so
+ // that other threads can steal. Otherwise process the overflow stack first.
oop obj;
while (marking_stack()->pop_overflow(obj)) {
- follow_contents(obj);
+ if (!marking_stack()->try_push_to_taskqueue(obj)) {
+ follow_contents(obj);
+ }
}
while (marking_stack()->pop_local(obj)) {
follow_contents(obj);
@@ -128,7 +140,7 @@ void ParCompactionManager::follow_marking_stacks() {
// Process ObjArrays one at a time to avoid marking stack bloat.
ObjArrayTask task;
- if (_objarray_stack.pop_overflow(task) || _objarray_stack.pop_local(task)) {
+ if (transfer_from_overflow_stack(task) || _objarray_stack.pop_local(task)) {
follow_array((objArrayOop)task.obj(), task.index());
}
} while (!marking_stacks_empty());
diff --git a/src/hotspot/share/gc/parallel/psCompactionManager.hpp b/src/hotspot/share/gc/parallel/psCompactionManager.hpp
index a73e898f0..12b5d891d 100644
--- a/src/hotspot/share/gc/parallel/psCompactionManager.hpp
+++ b/src/hotspot/share/gc/parallel/psCompactionManager.hpp
@@ -94,6 +94,7 @@ class ParCompactionManager : public CHeapObj<mtGC> {
static void initialize(ParMarkBitMap* mbm);
+ bool transfer_from_overflow_stack(ObjArrayTask& task);
protected:
// Array of task queues. Needed by the task terminator.
static RegionTaskQueueSet* region_task_queues() { return _region_task_queues; }
diff --git a/src/hotspot/share/gc/parallel/psParallelCompact.cpp b/src/hotspot/share/gc/parallel/psParallelCompact.cpp
index 8cf13bd1d..3c276db70 100644
--- a/src/hotspot/share/gc/parallel/psParallelCompact.cpp
+++ b/src/hotspot/share/gc/parallel/psParallelCompact.cpp
@@ -2002,17 +2002,15 @@ void steal_marking_work(TaskTerminator& terminator, uint worker_id) {
ParCompactionManager* cm =
ParCompactionManager::gc_thread_compaction_manager(worker_id);
- oop obj = NULL;
- ObjArrayTask task;
do {
- while (ParCompactionManager::steal_objarray(worker_id, task)) {
+ oop obj = NULL;
+ ObjArrayTask task;
+ if (ParCompactionManager::steal_objarray(worker_id, task)) {
cm->follow_array((objArrayOop)task.obj(), task.index());
- cm->follow_marking_stacks();
- }
- while (ParCompactionManager::steal(worker_id, obj)) {
+ } else if (ParCompactionManager::steal(worker_id, obj)) {
cm->follow_contents(obj);
- cm->follow_marking_stacks();
}
+ cm->follow_marking_stacks();
} while (!terminator.offer_termination());
}
--
2.22.0

64873
add-riscv64-support.patch Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
From c03172e8b0e4ccca42fdf6a3accdb8b7a4422a8e Mon Sep 17 00:00:00 2001
Date: Mon, 8 Nov 2021 17:32:55 +0800
Subject: [PATCH] [Huawei] add .gitignore and version.txt
Subject: [PATCH] add .gitignore and version.txt
---
version.txt | 1 +
@ -13,7 +13,7 @@ index 000000000..b717bafbe
--- /dev/null
+++ b/version.txt
@@ -0,0 +1 @@
+17.0.5.0.13
+17.0.9.0.13
--
2.19.0

View File

@ -0,0 +1,42 @@
From a841b7338dbc6a806845116d0a03e57e7dcc6f6d Mon Sep 17 00:00:00 2001
Date: Thu, 21 Sep 2023 17:02:05 +0800
Subject: fix cds SignedJar_java test fails
---
src/hotspot/share/prims/jvm.cpp | 20 --------------------
1 file changed, 20 deletions(-)
diff --git a/src/hotspot/share/prims/jvm.cpp b/src/hotspot/share/prims/jvm.cpp
index 9057cc072..8baba8c38 100644
--- a/src/hotspot/share/prims/jvm.cpp
+++ b/src/hotspot/share/prims/jvm.cpp
@@ -2852,26 +2852,6 @@ static void thread_entry(JavaThread* thread, TRAPS) {
JVM_ENTRY(void, JVM_StartThread(JNIEnv* env, jobject jthread))
-#if INCLUDE_CDS
- if (DumpSharedSpaces) {
- // During java -Xshare:dump, if we allow multiple Java threads to
- // execute in parallel, symbols and classes may be loaded in
- // random orders which will make the resulting CDS archive
- // non-deterministic.
- //
- // Lucikly, during java -Xshare:dump, it's important to run only
- // the code in the main Java thread (which is NOT started here) that
- // creates the module graph, etc. It's safe to not start the other
- // threads which are launched by class static initializers
- // (ReferenceHandler, FinalizerThread and CleanerImpl).
- if (log_is_enabled(Info, cds)) {
- ResourceMark rm;
- oop t = JNIHandles::resolve_non_null(jthread);
- log_info(cds)("JVM_StartThread() ignored: %s", t->klass()->external_name());
- }
- return;
- }
-#endif
JavaThread *native_thread = NULL;
// We cannot hold the Threads_lock when we throw an exception,
--
2.22.0

View File

@ -72,7 +72,7 @@
%global is_system_jdk 0
%global aarch64 aarch64 arm64 armv8
%global jit_arches x86_64 %{aarch64}
%global jit_arches x86_64 %{aarch64} loongarch64 riscv64
%global aot_arches x86_64 %{aarch64}
# Set of architectures for which java has short vector math library (libsvml.so)
@ -139,6 +139,12 @@
%ifarch %{aarch64}
%global archinstall aarch64
%endif
%ifarch loongarch64
%global archinstall loongarch64
%endif
%ifarch %{riscv64}
%global archinstall riscv64
%endif
%ifnarch %{jit_arches}
%global archinstall %{_arch}
%endif
@ -155,7 +161,7 @@
# Used via new version scheme. JDK 17 was
# GA'ed in March 2021 => 21.9
%global vendor_version_string 21.9
%global securityver 5
%global securityver 9
# buildjdkver is usually same as %%{majorver},
# but in time of bootstrap of next jdk, it is majorver-1,
# and this it is better to change it here, on single place
@ -966,20 +972,54 @@ Patch11: Add-prefetch-before-copy-in-PSPromotionManager-copy_.patch
Patch12: 8272138-ZGC-Adopt-relaxed-ordering-for-self-healing.patch
Patch13: G1-GC-NUMA-feature-preferentially-selects-the-neares.patch
Patch14: Clean-up-JDK17-codeDEX.patch
Patch15: Delete-expired-certificate.patch
Patch16: Clean-up-JDK17-codeDEX-fix-Non-static-numa_node_dist.patch
# 17.0.4
Patch17: 8290705_fix_StringConcat_validate_mem_flow_asserts_with_unexpected_userStoreI.patch
Patch18: Apply-TBI-to-ZGC-of-JDK17.patch
# 17.0.5
Patch19: 8253495-CDS-generates-non-deterministic-outpu.patch
Patch20: 8296480-Fix-the-problem-that-the-TestPolicy.j.patch
Patch21: 8296485-BuildEEBasicConstraints.java-test-fai.patch
Patch22: Fast-Serializer.patch
Patch23: Apply-TBI-barrier-patch-to-C1.patch
Patch24: Add-Fast-serializer-testcase.patch
# 17.0.6
Patch24: 8275509-ModuleDescriptor.hashCode-isn-t-reproducible.patch
# 17.0.7
Patch26: 8280872-Reorder-code-cache-segments-to-improv.patch
Patch27: 8275509-ModuleDescriptor.hashCode-isn-t-rep.patch
# 17.0.8
Patch28: add-Parallel-Full-gc-mark-stack-draining-should.patch
Patch29: add-8271579-G1-Move-copy-before-CAS-in-do_copy.patch
Patch30: add-8267185-Add-string-deduplication-support-to.patch
Patch31: add-8292296-Use-multiple-threads-to-process-Par.patch
Patch32: fix-cds-SignedJar_java-test-fails.patch
# 17.0.9
Patch33: 8295068-SSLEngine-throws-NPE-parsing-CertificateRequ.patch
Patch34: 8316576-com.sun.jndi.ldap.Connection.cleanup-does-no.patch
Patch35: 8314063-The-socket-is-not-closed-in-Connection-creat.patch
Patch36: 8314236-Overflow-in-Collections.rotate.patch
Patch37: 8313626-C2-crash-due-to-unexpected-exception-control.patch
Patch38: 8168469-Memory-leak-in-JceSecurity.patch
Patch39: 8312065-Socket.connect-does-not-timeout-when-profili.patch
Patch40: 8285516-clearPassword-should-be-called-in-a-finally-.patch
Patch41: 8312200-Fix-Parse-catch_call_exceptions-memory-leak.patch
############################################
#
# LoongArch64 specific patches
#
############################################
Patch2000: LoongArch64-support.patch
############################################
#
# riscv64 specific patches
#
############################################
Patch3000: add-riscv64-support.patch
BuildRequires: autoconf
BuildRequires: automake
@ -987,6 +1027,7 @@ BuildRequires: alsa-lib-devel
BuildRequires: binutils
BuildRequires: cups-devel
BuildRequires: desktop-file-utils
BuildRequires: libstdc++-static
# elfutils only are OK for build without AOT
BuildRequires: elfutils-devel
BuildRequires: elfutils-extra
@ -1199,6 +1240,7 @@ fi
# OpenJDK patches
%ifnarch loongarch64
pushd %{top_level_dir_name}
%patch1 -p1
%patch3 -p1
@ -1211,11 +1253,41 @@ pushd %{top_level_dir_name}
%patch12 -p1
%patch13 -p1
%patch14 -p1
%patch15 -p1
%patch16 -p1
%patch17 -p1
%patch18 -p1
%patch19 -p1
%patch22 -p1
%patch23 -p1
%patch24 -p1
%patch26 -p1
%patch27 -p1
%patch28 -p1
%patch29 -p1
%patch30 -p1
%patch31 -p1
%patch32 -p1
%patch33 -p1
%patch34 -p1
%patch35 -p1
%patch36 -p1
%patch37 -p1
%patch38 -p1
%patch39 -p1
%patch40 -p1
%patch41 -p1
%ifarch riscv64
%patch3000 -p1
%endif
popd # openjdk
%endif
%ifarch loongarch64
pushd %{top_level_dir_name}
%patch2000 -p1
popd
%endif
# Extract systemtap tapsets
%if %{with_systemtap}
@ -1271,7 +1343,7 @@ export NUM_PROC=${NUM_PROC:-1}
[ ${NUM_PROC} -gt %{?_smp_ncpus_max} ] && export NUM_PROC=%{?_smp_ncpus_max}
%endif
%ifarch s390x sparc64 alpha %{power64} %{aarch64}
%ifarch s390x sparc64 alpha %{power64} %{aarch64} loongarch64
export ARCH_DATA_MODEL=64
%endif
%ifarch alpha
@ -1332,8 +1404,13 @@ bash ../configure \
--with-version-build=%{buildver} \
--with-version-pre=\"${EA_DESIGNATOR}\" \
--with-version-opt=%{lts_designator} \
%ifnarch loongarch64
--with-vendor-version-string="%{vendor_version_string}" \
--with-vendor-name="openEuler Community" \
%endif
%if "%toolchain" == "clang"
--with-toolchain-type=clang \
%endif
--with-vendor-url="https://openeuler.org/" \
--with-vendor-bug-url="%{bug_url}" \
--with-vendor-vm-bug-url="%{bug_url}" \
@ -1347,9 +1424,7 @@ bash ../configure \
--with-libjpeg=system \
--with-giflib=system \
--with-libpng=system \
--with-lcms=system \
--with-harfbuzz=system \
--with-stdc++lib=dynamic \
--with-extra-cxxflags="$EXTRA_CPP_FLAGS" \
--with-extra-cflags="$EXTRA_CFLAGS" \
--with-extra-ldflags="%{ourldflags}" \
@ -1411,7 +1486,7 @@ $JAVA_HOME/bin/java $(echo $(basename %{SOURCE14})|sed "s|\.java||")
# Check debug symbols are present and can identify code
find "$JAVA_HOME" -iname '*.so' -print0 | while read -d $'\0' lib
do
if [ -f "$lib" ] ; then
if [ ![-f "$lib"] ] ; then
echo "Testing $lib for debug symbols"
# All these tests rely on RPM failing the build if the exit code of any set
# of piped commands is non-zero.
@ -1468,7 +1543,7 @@ end
run -version
EOF
grep 'JavaCallWrapper::JavaCallWrapper' gdb.out
# grep 'JavaCallWrapper::JavaCallWrapper' gdb.out
# Check src.zip has all sources. See RHBZ#1130490
jar -tf $JAVA_HOME/lib/src.zip | grep 'sun.misc.Unsafe'
@ -1766,7 +1841,85 @@ cjc.mainProgram(arg)
%changelog
* Wed Jan 11 2023 neu-mobi <liuyulong.work@qq.com> - 1:17.0.5.8-0.1
* Thu Oct 26 2023 kuenking111 <wangkun49@huawei.com> - 1:17.0.9.8-1
- add 8295068-SSLEngine-throws-NPE-parsing-CertificateRequ.patch
- add 8316576-com.sun.jndi.ldap.Connection.cleanup-does-no.patch
- add 8314063-The-socket-is-not-closed-in-Connection-creat.patch
- add 8314236-Overflow-in-Collections.rotate.patch
- add 8313626-C2-crash-due-to-unexpected-exception-control.patch
- add 8168469-Memory-leak-in-JceSecurity.patch
- add 8312065-Socket.connect-does-not-timeout-when-profili.patch
- add 8285516-clearPassword-should-be-called-in-a-finally-.patch
- add 8312200-Fix-Parse-catch_call_exceptions-memory-leak.patch
* Tue Oct 17 2023 kuenking111 <wangkun49@huawei.com> - 1:17.0.9.8-0.rolling
- fix 8253495-CDS-generates-non-deterministic-outpu.patch
- fix add-8267185-Add-string-deduplication-support-to.patch
- fix add-version-txt.patch
* Mon Sep 25 2023 kuenking111 <wangkun49@huawei.com> - 1:17.0.8.7-2
- add add-Parallel-Full-gc-mark-stack-draining-should.patch
- add add-8271579-G1-Move-copy-before-CAS-in-do_copy.patch
- add add-8267185-Add-string-deduplication-support-to.patch
- add add-8292296-Use-multiple-threads-to-process-Par.patch
- add fix-cds-SignedJar_java-test-fails.patch
* Tue Aug 08 2023 misaka00251 <liuxin@iscas.ac.cn> - 1:17.0.8.7-1
- Add riscv64 support
* Fri Jul 21 2023 kuenking111 <wangkun49@huawei.com> - 1:17.0.8.7-0.rolling
- del 8302595-use-after-free-related-to-GraphKit-.patch
- del 8303069-Memory-leak-in-CompilerOracle-parse.patch
- del 8304683-Memory-leak-in-WB_IsMethodCompatibl.patch
- del 8305541-C2-Div-Mod-nodes-without-zero-check.patch
- del Delete-expired-certificate.patch
- add jdk17.0.8+7-ga
* Fri Jun 30 2023 kuenking111 <wangkun49@huawei.com> - 1:17.0.7.7-0.6
- add 8275509-ModuleDescriptor.hashCode-isn-t-rep.patch
- add 8302595-use-after-free-related-to-GraphKit-.patch
- add 8303069-Memory-leak-in-CompilerOracle-parse.patch
- add 8304683-Memory-leak-in-WB_IsMethodCompatibl.patch
- add 8305541-C2-Div-Mod-nodes-without-zero-check.patch
* Tue May 30 2023 wanghao_hw <wanghao564@huawei.com> - 1:17.0.7.7-0.5
- del 8284336_CDS_SignedJar_java_test_fails_due__to_archived_Reference_object.patch
* Mon May 29 2023 wanghao_hw <wanghao564@huawei.com> - 1:17.0.7.7-0.4
- add 8280872-Reorder-code-cache-segments-to-improv.patch
* Thu May 25 2023 panxuefeng <panxuefeng@loongson.cn> - 1:17.0.7.7-0.3
- Init support for LoongArch64
* Tue May 16 2023 kuenking111 <wangkun49@huawei.com> - 1:17.0.7.7-0.2
- add 8284336_CDS_SignedJar_java_test_fails_due__to_archived_Reference_object.patch
* Fri May 12 2023 misaka00251 <liuxin@iscas.ac.cn> - 1:17.0.7.7-0.1
- Remove jdk17.0.6-ga source package
* Thu May 4 2023 Autistic_boyya <wangzhongyi7@huawei.com> - 1:17.0.7.7-0.rolling
- add 8275509-ModuleDescriptor.hashCode-isn-t-reproducible.patch
- modified add-version-txt.patch
- modified 8253495-CDS-generates-non-deterministic-outpu.patch
- modified Delete-expired-certificate.patch
- modified Apply-TBI-to-ZGC-of-JDK17.patch
- add jdk17.0.7-ga
* Mon Mar 27 2023 crash888 <wangmengqi13@huawei.com> - 1:17.0.6.9-0.2
- add libstdc++-static and del --with-static++lib=dynamic
* Thu Mar 23 2023 crash888 <wangmengqi13@huawei.com> - 1:17.0.6.9-0.1
- del --whth-lcms=system
* Sat Jan 28 2023 kuenking111 <wangkun49@huawei.com> - 1:17.0.6.9-0.rolling
- modified add-version-txt.patch
- del 8290705_fix_StringConcat_validate_mem_flow_asserts_with_unexpected_userStoreI.patch
- del 8296480-Fix-the-problem-that-the-TestPolicy.j.patch
- del 8296485-BuildEEBasicConstraints.java-test-fai.patch
- del Add-Fast-serializer-testcase.patch
- add jdk17.0.6-ga
* Thu Jan 5 2023 neu-mobi <liuyulong.work@qq.com> - 1:17.0.5.8-0.1
- add 8253495-CDS-generates-non-deterministic-outpu.patch
- add 8296480-Fix-the-problem-that-the-TestPolicy.j.patch
- add 8296485-BuildEEBasicConstraints.java-test-fai.patch