Compare commits

...

6 Commits

Author SHA1 Message Date
Leonid Mesnik
2596608ba1 8370846: Support execution of mlvm testing with test thread factory
Reviewed-by: cjplummer
2025-12-05 21:20:20 +00:00
Chris Plummer
be8cbfa612 8362083: JDI VirtualMachine/dispose/dispose001 failed with FATAL ERROR in native method: JDWP cannot set thread local storage, jvmtiError=JVMTI_ERROR_WRONG_PHASE(112)
Reviewed-by: lmesnik, sspitsyn, amenkov
2025-12-05 20:37:10 +00:00
Brent Christian
f3dd8daaa9 8371748: Remove the (empty) ThreadPoolExecutor.finalize() method
Reviewed-by: vklang, jpai, alanb
2025-12-05 19:30:04 +00:00
Albert Mingkun Yang
4378789029 8373145: [BACKOUT] Remove ThreadLocalAllocBuffer::_reserve_for_allocation_prefetch
Reviewed-by: mdoerr, kvn
2025-12-05 19:17:45 +00:00
Joe Darcy
a20b7eb943 8373125: Add defensive screening of modifiers for Field and Parameter toString() results
Reviewed-by: alanb, liach
2025-12-05 17:35:30 +00:00
Neha Joshi
520c092a65 8362658: sun/security/ssl/SSLEngineImpl/* tests duplicate jvm flags
Co-authored-by: Lei Zhu <korov9.c@gmail.com>
Reviewed-by: myankelevich, rhalade
2025-12-05 16:46:26 +00:00
22 changed files with 169 additions and 78 deletions

View File

@@ -6335,8 +6335,36 @@ instruct loadConD_Ex(regD dst, immD src) %{
// Prefetch instructions.
// Must be safe to execute with invalid address (cannot fault).
// Special prefetch versions which use the dcbz instruction.
instruct prefetch_alloc_zero(indirectMemory mem, iRegLsrc src) %{
match(PrefetchAllocation (AddP mem src));
predicate(AllocatePrefetchStyle == 3);
ins_cost(MEMORY_REF_COST);
format %{ "PREFETCH $mem, 2, $src \t// Prefetch write-many with zero" %}
size(4);
ins_encode %{
__ dcbz($src$$Register, $mem$$base$$Register);
%}
ins_pipe(pipe_class_memory);
%}
instruct prefetch_alloc_zero_no_offset(indirectMemory mem) %{
match(PrefetchAllocation mem);
predicate(AllocatePrefetchStyle == 3);
ins_cost(MEMORY_REF_COST);
format %{ "PREFETCH $mem, 2 \t// Prefetch write-many with zero" %}
size(4);
ins_encode %{
__ dcbz($mem$$base$$Register);
%}
ins_pipe(pipe_class_memory);
%}
instruct prefetch_alloc(indirectMemory mem, iRegLsrc src) %{
match(PrefetchAllocation (AddP mem src));
predicate(AllocatePrefetchStyle != 3);
ins_cost(MEMORY_REF_COST);
format %{ "PREFETCH $mem, 2, $src \t// Prefetch write-many" %}
@@ -6349,6 +6377,7 @@ instruct prefetch_alloc(indirectMemory mem, iRegLsrc src) %{
instruct prefetch_alloc_no_offset(indirectMemory mem) %{
match(PrefetchAllocation mem);
predicate(AllocatePrefetchStyle != 3);
ins_cost(MEMORY_REF_COST);
format %{ "PREFETCH $mem, 2 \t// Prefetch write-many" %}

View File

@@ -37,6 +37,7 @@
#include "utilities/copy.hpp"
size_t ThreadLocalAllocBuffer::_max_size = 0;
int ThreadLocalAllocBuffer::_reserve_for_allocation_prefetch = 0;
unsigned int ThreadLocalAllocBuffer::_target_refills = 0;
ThreadLocalAllocBuffer::ThreadLocalAllocBuffer() :
@@ -224,6 +225,30 @@ void ThreadLocalAllocBuffer::startup_initialization() {
// abort during VM initialization.
_target_refills = MAX2(_target_refills, 2U);
#ifdef COMPILER2
// If the C2 compiler is present, extra space is needed at the end of
// TLABs, otherwise prefetching instructions generated by the C2
// compiler will fault (due to accessing memory outside of heap).
// The amount of space is the max of the number of lines to
// prefetch for array and for instance allocations. (Extra space must be
// reserved to accommodate both types of allocations.)
//
// Only SPARC-specific BIS instructions are known to fault. (Those
// instructions are generated if AllocatePrefetchStyle==3 and
// AllocatePrefetchInstr==1). To be on the safe side, however,
// extra space is reserved for all combinations of
// AllocatePrefetchStyle and AllocatePrefetchInstr.
//
// If the C2 compiler is not present, no space is reserved.
// +1 for rounding up to next cache line, +1 to be safe
if (CompilerConfig::is_c2_or_jvmci_compiler_enabled()) {
int lines = MAX2(AllocatePrefetchLines, AllocateInstancePrefetchLines) + 2;
_reserve_for_allocation_prefetch = (AllocatePrefetchDistance + AllocatePrefetchStepSize * lines) /
(int)HeapWordSize;
}
#endif
// During jvm startup, the main thread is initialized
// before the heap is initialized. So reinitialize it now.
guarantee(Thread::current()->is_Java_thread(), "tlab initialization thread not Java thread");
@@ -429,7 +454,8 @@ void ThreadLocalAllocStats::publish() {
}
size_t ThreadLocalAllocBuffer::end_reserve() {
return CollectedHeap::lab_alignment_reserve();
size_t reserve_size = CollectedHeap::lab_alignment_reserve();
return MAX2(reserve_size, (size_t)_reserve_for_allocation_prefetch);
}
const HeapWord* ThreadLocalAllocBuffer::start_relaxed() const {

View File

@@ -58,6 +58,7 @@ private:
size_t _allocated_before_last_gc; // total bytes allocated up until the last gc
static size_t _max_size; // maximum size of any TLAB
static int _reserve_for_allocation_prefetch; // Reserve at the end of the TLAB
static unsigned _target_refills; // expected number of refills between GCs
unsigned _number_of_refills;

View File

@@ -1914,7 +1914,8 @@ Node* PhaseMacroExpand::prefetch_allocation(Node* i_o, Node*& needgc_false,
transform_later(cache_adr);
cache_adr = new CastP2XNode(needgc_false, cache_adr);
transform_later(cache_adr);
// Address is aligned to execute prefetch to the beginning of cache line size.
// Address is aligned to execute prefetch to the beginning of cache line size
// (it is important when BIS instruction is used on SPARC as prefetch).
Node* mask = _igvn.MakeConX(~(intptr_t)(step_size-1));
cache_adr = new AndXNode(cache_adr, mask);
transform_later(cache_adr);

View File

@@ -353,6 +353,7 @@
nonstatic_field(ThreadLocalAllocBuffer, _pf_top, HeapWord*) \
nonstatic_field(ThreadLocalAllocBuffer, _desired_size, size_t) \
nonstatic_field(ThreadLocalAllocBuffer, _refill_waste_limit, size_t) \
static_field(ThreadLocalAllocBuffer, _reserve_for_allocation_prefetch, int) \
static_field(ThreadLocalAllocBuffer, _target_refills, unsigned) \
nonstatic_field(ThreadLocalAllocBuffer, _number_of_refills, unsigned) \
nonstatic_field(ThreadLocalAllocBuffer, _refill_waste, unsigned) \

View File

@@ -367,7 +367,7 @@ class Field extends AccessibleObject implements Member {
* @jls 8.3.1 Field Modifiers
*/
public String toString() {
int mod = getModifiers();
int mod = getModifiers() & Modifier.fieldModifiers();
return (((mod == 0) ? "" : (Modifier.toString(mod) + " "))
+ getType().getTypeName() + " "
+ getDeclaringClass().getTypeName() + "."
@@ -400,7 +400,7 @@ class Field extends AccessibleObject implements Member {
* @jls 8.3.1 Field Modifiers
*/
public String toGenericString() {
int mod = getModifiers();
int mod = getModifiers() & Modifier.fieldModifiers();
Type fieldType = getGenericType();
return (((mod == 0) ? "" : (Modifier.toString(mod) + " "))
+ fieldType.getTypeName() + " "

View File

@@ -126,7 +126,7 @@ public final class Parameter implements AnnotatedElement {
final Type type = getParameterizedType();
final String typename = type.getTypeName();
sb.append(Modifier.toString(getModifiers()));
sb.append(Modifier.toString(getModifiers() & Modifier.parameterModifiers() ));
if(0 != modifiers)
sb.append(' ');

View File

@@ -1426,23 +1426,6 @@ public class ThreadPoolExecutor extends AbstractExecutorService {
}
}
// Override without "throws Throwable" for compatibility with subclasses
// whose finalize method invokes super.finalize() (as is recommended).
// Before JDK 11, finalize() had a non-empty method body.
/**
* @implNote Previous versions of this class had a finalize method
* that shut down this executor, but in this version, finalize
* does nothing.
*
* @deprecated Finalization has been deprecated for removal. See
* {@link java.lang.Object#finalize} for background information and details
* about migration options.
*/
@Deprecated(since="9", forRemoval=true)
@SuppressWarnings("removal")
protected void finalize() {}
/**
* Sets the thread factory used to create new threads.
*

View File

@@ -76,9 +76,10 @@ public class ThreadLocalAllocBuffer extends VMObject {
private long endReserve() {
long labAlignmentReserve = VM.getVM().getLabAlignmentReserve();
long reserveForAllocationPrefetch = VM.getVM().getReserveForAllocationPrefetch();
long heapWordSize = VM.getVM().getHeapWordSize();
return labAlignmentReserve * heapWordSize;
return Math.max(labAlignmentReserve, reserveForAllocationPrefetch) * heapWordSize;
}
/** Support for iteration over heap -- not sure how this will

View File

@@ -123,6 +123,7 @@ public class VM {
private int invocationEntryBCI;
private ReversePtrs revPtrs;
private VMRegImpl vmregImpl;
private int reserveForAllocationPrefetch;
private int labAlignmentReserve;
// System.getProperties from debuggee VM
@@ -446,6 +447,8 @@ public class VM {
boolType = (CIntegerType) db.lookupType("bool");
Type threadLocalAllocBuffer = db.lookupType("ThreadLocalAllocBuffer");
CIntegerField reserveForAllocationPrefetchField = threadLocalAllocBuffer.getCIntegerField("_reserve_for_allocation_prefetch");
reserveForAllocationPrefetch = (int)reserveForAllocationPrefetchField.getCInteger(intType);
Type collectedHeap = db.lookupType("CollectedHeap");
CIntegerField labAlignmentReserveField = collectedHeap.getCIntegerField("_lab_alignment_reserve");
@@ -912,6 +915,10 @@ public class VM {
return vmInternalInfo;
}
public int getReserveForAllocationPrefetch() {
return reserveForAllocationPrefetch;
}
public int getLabAlignmentReserve() {
return labAlignmentReserve;
}

View File

@@ -170,6 +170,10 @@ setThreadLocalStorage(jthread thread, ThreadNode *node)
return;
}
}
if (error == JVMTI_ERROR_WRONG_PHASE && gdata->vmDead && isVThread(thread)) {
// Just return. This can happen with vthreads when the vm is exiting.
return;
}
if (error != JVMTI_ERROR_NONE) {
// The jthread object must be valid, so this must be a fatal error.
EXIT_ERROR(error, "cannot set thread local storage");

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import jdk.test.lib.thread.TestThreadFactory;
import nsk.share.jdi.Binder;
import nsk.share.jdi.Debugee;
import vm.mlvm.share.Env;
@@ -437,10 +438,22 @@ public abstract class JDIBreakpointTest extends MlvmTest {
for (StackFrame f : frames) {
Location l = f.location();
String sourcePath;
try {
sourcePath = l.sourcePath();
} catch (AbsentInformationException aie) {
// Test Thread Factory support has generated methods in MainWrapper class.
if (TestThreadFactory.isTestThreadFactorySet()) {
sourcePath = "unknown";
} else {
throw aie;
}
}
buf.append(String.format("#%-4d", frameNum))
.append(l.method())
.append("\n source: ")
.append(l.sourcePath())
.append(sourcePath)
.append(":")
.append(l.lineNumber())
.append("; bci=")

View File

@@ -21,22 +21,6 @@
# questions.
#
#############################################################################
#
# List of quarantined tests failing with jvmti stress agent in any mode.
#
#############################################################################
sun/security/ssl/SSLEngineImpl/SSLEngineKeyLimit.java 8362658 generic-all
sun/security/ssl/SSLSessionImpl/MultiNSTClient.java 8362658 generic-all
sun/security/ssl/SSLSessionImpl/MultiNSTNoSessionCreation.java 8362658 generic-all
sun/security/ssl/SSLSessionImpl/MultiNSTParallel.java 8362658 generic-all
sun/security/ssl/SSLSessionImpl/MultiNSTSequence.java 8362658 generic-all
sun/security/ssl/SSLSessionImpl/ResumptionUpdateBoundValues.java 8362658 generic-all
sun/security/ssl/SSLSocketImpl/SSLSocketKeyLimit.java 8362658 generic-all
# List of tests incompatible with jvmti stress agent or requiring more investigation
com/sun/jdi/EATests.java#id0 0000000 generic-all

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,36 +23,71 @@
/**
* @test
* @bug 4394937 8051382
* @bug 4394937 8051382 8373125
* @summary tests the toString method of reflect.Modifier
*/
import java.lang.reflect.Modifier;
import static java.lang.reflect.Modifier.*;
public class toStringTest {
static void testString(int test, String expected) {
if(!Modifier.toString(test).equals(expected))
throw new RuntimeException(test +
" yields incorrect toString result");
String result = Modifier.toString(test);
if(!expected.equals(result)) {
System.err.println("For input 0x" + Integer.toHexString(test));
System.err.println("expected:\t" + expected + "\ngot\t\t" + result);
throw new RuntimeException();
}
}
public static void main(String [] argv) {
int allMods = Modifier.PUBLIC | Modifier.PROTECTED | Modifier.PRIVATE |
Modifier.ABSTRACT | Modifier.STATIC | Modifier.FINAL |
Modifier.TRANSIENT | Modifier.VOLATILE | Modifier.SYNCHRONIZED |
Modifier.NATIVE | Modifier.STRICT | Modifier.INTERFACE;
public static void main(String... argv) {
int allMods = PUBLIC | PROTECTED | PRIVATE |
ABSTRACT | STATIC | FINAL |
TRANSIENT | VOLATILE | SYNCHRONIZED |
NATIVE | STRICT | INTERFACE;
String allModsString = "public protected private abstract static " +
"final transient volatile synchronized native strictfp interface";
/* zero should have an empty string */
final int ALL_ONES = ~0;
// zero should have an empty string
testString(0, "");
/* test to make sure all modifiers print out in the proper order */
// test to make sure all modifiers print out in the proper order
testString(allMods, allModsString);
/* verify no extraneous modifiers are printed */
testString(~0, allModsString);
// verify no extraneous modifiers are printed
testString(ALL_ONES, allModsString);
ModifierKindCase[] kindModifiers = {
new ModifierKindCase(classModifiers(),
"public protected private abstract " +
"static final strictfp"),
new ModifierKindCase(constructorModifiers(),"public protected private"),
new ModifierKindCase(fieldModifiers(),
"public protected private " +
"static final transient volatile"),
new ModifierKindCase(interfaceModifiers(),
"public protected private " +
"abstract static strictfp"),
new ModifierKindCase(methodModifiers(),
"public protected private abstract " +
"static final synchronized native strictfp"),
new ModifierKindCase(parameterModifiers(), "final"),
};
for (var modKindCase : kindModifiers) {
testString(ALL_ONES & modKindCase.mask(), modKindCase.expected());
}
}
private record ModifierKindCase(int mask, String expected){}
}

View File

@@ -60,7 +60,6 @@ import java.util.Arrays;
import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.Utils;
public class SSLEngineKeyLimit extends SSLContextTemplate {
@@ -119,9 +118,7 @@ public class SSLEngineKeyLimit extends SSLContextTemplate {
System.getProperty("test.java.opts"));
ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(
Utils.addTestJavaOpts("SSLEngineKeyLimit", "p", args[1],
args[2]));
"SSLEngineKeyLimit", "p", args[1], args[2]);
OutputAnalyzer output = ProcessTools.executeProcess(pb);
try {
output.shouldContain(String.format(

View File

@@ -37,7 +37,6 @@
* @run main/othervm MultiNSTClient -Djdk.tls.client.protocols=TLSv1.2 -Djdk.tls.server.enableSessionTicketExtension=true -Djdk.tls.client.enableSessionTicketExtension=true
*/
import jdk.test.lib.Utils;
import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.process.ProcessTools;
@@ -77,8 +76,7 @@ public class MultiNSTClient {
System.out.println("test.java.opts: " +
System.getProperty("test.java.opts"));
ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(
Utils.addTestJavaOpts("MultiNSTClient", "p"));
ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder("MultiNSTClient", "p");
OutputAnalyzer output = ProcessTools.executeProcess(pb);
boolean pass = true;

View File

@@ -31,7 +31,6 @@
* @run main/othervm MultiNSTNoSessionCreation -Djdk.tls.client.protocols=TLSv1.2 -Djdk.tls.server.newSessionTicketCount=0
*/
import jdk.test.lib.Utils;
import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.process.ProcessTools;
@@ -61,7 +60,7 @@ public class MultiNSTNoSessionCreation {
System.getProperty("test.java.opts"));
ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(
Utils.addTestJavaOpts("MultiNSTNoSessionCreation", "p"));
"MultiNSTNoSessionCreation", "p");
OutputAnalyzer output = ProcessTools.executeProcess(pb);
try {

View File

@@ -30,7 +30,6 @@
* @run main/othervm MultiNSTParallel 10 -Djdk.tls.client.protocols=TLSv1.3
*/
import jdk.test.lib.Utils;
import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.process.ProcessTools;
@@ -116,8 +115,7 @@ public class MultiNSTParallel {
System.out.println("test.java.opts: " +
System.getProperty("test.java.opts"));
ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(
Utils.addTestJavaOpts("MultiNSTParallel", "p"));
ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder("MultiNSTParallel", "p");
OutputAnalyzer output = ProcessTools.executeProcess(pb);
try {

View File

@@ -30,7 +30,6 @@
* @run main/othervm MultiNSTSequence -Djdk.tls.server.newSessionTicketCount=2
*/
import jdk.test.lib.Utils;
import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.process.ProcessTools;
@@ -69,8 +68,7 @@ public class MultiNSTSequence {
System.out.println("test.java.opts: " +
System.getProperty("test.java.opts"));
ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(
Utils.addTestJavaOpts("MultiNSTSequence", "p"));
ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder("MultiNSTSequence", "p");
OutputAnalyzer output = ProcessTools.executeProcess(pb);
boolean pass = true;

View File

@@ -45,7 +45,6 @@ import javax.net.ssl.SSLSocketFactory;
import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.Utils;
public class ResumptionUpdateBoundValues extends SSLContextTemplate {
@@ -188,7 +187,7 @@ public class ResumptionUpdateBoundValues extends SSLContextTemplate {
System.getProperty("test.java.opts"));
ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(
Utils.addTestJavaOpts("ResumptionUpdateBoundValues", "p"));
"ResumptionUpdateBoundValues", "p");
OutputAnalyzer output = ProcessTools.executeProcess(pb);
try {

View File

@@ -68,7 +68,6 @@ import java.util.Arrays;
import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.Utils;
import jdk.test.lib.hexdump.HexPrinter;
public class SSLSocketKeyLimit {
@@ -135,8 +134,7 @@ public class SSLSocketKeyLimit {
System.getProperty("test.java.opts"));
ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(
Utils.addTestJavaOpts("SSLSocketKeyLimit", "p", args[1],
args[2]));
"SSLSocketKeyLimit", "p", args[1], args[2]);
OutputAnalyzer output = ProcessTools.executeProcess(pb);
try {

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -32,8 +32,27 @@ import java.util.concurrent.ThreadFactory;
public class TestThreadFactory {
private static ThreadFactory threadFactory = "Virtual".equals(System.getProperty("test.thread.factory"))
? virtualThreadFactory() : platformThreadFactory();
public enum TestThreadFactoryType {
NONE, VIRTUAL
}
private final static TestThreadFactoryType testThreadFactoryType =
"Virtual".equals(System.getProperty("test.thread.factory"))
? TestThreadFactoryType.VIRTUAL
: TestThreadFactoryType.NONE;
private final static ThreadFactory threadFactory =
testThreadFactoryType == TestThreadFactoryType.VIRTUAL
? virtualThreadFactory()
: platformThreadFactory();
public static TestThreadFactoryType testThreadFactoryType() {
return testThreadFactoryType;
}
public static boolean isTestThreadFactorySet() {
return !testThreadFactoryType.equals(TestThreadFactoryType.NONE);
}
public static Thread newThread(Runnable task) {
return threadFactory.newThread(task);