Skip to content

Commit 53833ff

Browse files
committed
Merge master HEAD into openj9-staging
Signed-off-by: J9 Build <[email protected]>
2 parents 485e097 + a31571c commit 53833ff

File tree

13 files changed

+291
-138
lines changed

13 files changed

+291
-138
lines changed

make/hotspot/gensrc/GensrcAdlc.gmk

+3-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved.
2+
# Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved.
33
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
#
55
# This code is free software; you can redistribute it and/or modify it
@@ -37,13 +37,8 @@ ifeq ($(call check-jvm-feature, compiler2), true)
3737
ifeq ($(call isBuildOs, linux), true)
3838
ADLC_CFLAGS := -fno-exceptions -DLINUX
3939
else ifeq ($(call isBuildOs, aix), true)
40-
ifeq ($(TOOLCHAIN_TYPE), clang)
41-
ADLC_LDFLAGS += -m64
42-
ADLC_CFLAGS := -fno-rtti -fexceptions -ffunction-sections -m64 -DAIX -mcpu=pwr8
43-
else
44-
ADLC_LDFLAGS += -q64
45-
ADLC_CFLAGS := -qnortti -qeh -q64 -DAIX
46-
endif
40+
ADLC_LDFLAGS += -m64
41+
ADLC_CFLAGS := -fno-rtti -fexceptions -ffunction-sections -m64 -DAIX -mcpu=pwr8
4742
else ifeq ($(call isBuildOs, windows), true)
4843
ADLC_CFLAGS := -nologo -EHsc
4944
ADLC_CFLAGS_WARNINGS := -W3 -D_CRT_SECURE_NO_WARNINGS

make/hotspot/lib/JvmFlags.gmk

-5
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,6 @@ JVM_CFLAGS += \
9292
$(EXTRA_CFLAGS) \
9393
#
9494

95-
# -DDONT_USE_PRECOMPILED_HEADER will exclude all includes in precompiled.hpp.
96-
ifeq ($(USE_PRECOMPILED_HEADER), false)
97-
JVM_CFLAGS += -DDONT_USE_PRECOMPILED_HEADER
98-
endif
99-
10095
ifneq ($(HOTSPOT_OVERRIDE_LIBPATH), )
10196
JVM_CFLAGS += -DOVERRIDE_LIBPATH='"$(HOTSPOT_OVERRIDE_LIBPATH)"'
10297
endif

src/java.base/windows/classes/java/lang/ProcessImpl.java

+14-8
Original file line numberDiff line numberDiff line change
@@ -204,13 +204,14 @@ private static String[] getTokensFromCommand(String command) {
204204
private static final int VERIFICATION_LEGACY = 3;
205205
// See Command shell overview for documentation of special characters.
206206
// https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-xp/bb490954(v=technet.10)
207-
private static final char ESCAPE_VERIFICATION[][] = {
207+
private static final String ESCAPE_VERIFICATION[] = {
208208
// We guarantee the only command file execution for implicit [cmd.exe] run.
209209
// http://technet.microsoft.com/en-us/library/bb490954.aspx
210-
{' ', '\t', '\"', '<', '>', '&', '|', '^'},
211-
{' ', '\t', '\"', '<', '>'},
212-
{' ', '\t', '\"', '<', '>'},
213-
{' ', '\t'}
210+
// All space characters require quoting are checked in needsEscaping().
211+
"\"<>&|^",
212+
"\"<>",
213+
"\"<>",
214+
""
214215
};
215216

216217
private static String createCommandLine(int verificationType,
@@ -325,9 +326,14 @@ private static boolean needsEscaping(int verificationType, String arg) {
325326
}
326327

327328
if (!argIsQuoted) {
328-
char testEscape[] = ESCAPE_VERIFICATION[verificationType];
329-
for (int i = 0; i < testEscape.length; ++i) {
330-
if (arg.indexOf(testEscape[i]) >= 0) {
329+
for (int i = 0; i < arg.length(); i++) {
330+
char ch = arg.charAt(i);
331+
if (Character.isLetterOrDigit(ch))
332+
continue; // skip over common characters
333+
// All space chars require quotes and other mode specific characters
334+
if (Character.isSpaceChar(ch) ||
335+
Character.isWhitespace(ch) ||
336+
ESCAPE_VERIFICATION[verificationType].indexOf(ch) >= 0) {
331337
return true;
332338
}
333339
}

src/java.desktop/share/native/libawt/java2d/SurfaceData.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ typedef struct {
6060

6161
#define UNSAFE_TO_SUB(a, b) \
6262
(((b >= 0) && (a < 0) && (a < (INT_MIN + b))) || \
63-
((b < 0) && (a >= 0) && (-b > (INT_MAX - a)))) \
63+
((b < 0) && (a >= 0) && (a > (INT_MAX + b)))) \
6464

6565
/*
6666
* The SurfaceDataRasInfo structure is used to pass in and return various

src/java.desktop/windows/native/libawt/windows/awt_Toolkit.cpp

+20-27
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1996, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1996, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -102,17 +102,36 @@ extern void DWMResetCompositionEnabled();
102102
first loaded */
103103
JavaVM *jvm = NULL;
104104

105+
/* Return a handle to the module containing this method, either a DLL in case
106+
* of a dynamic library build, or the .EXE in case of a static build.
107+
*/
108+
static HMODULE GetAwtModuleHandle() {
109+
HMODULE hModule = NULL;
110+
GetModuleHandleEx(
111+
GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
112+
(LPCTSTR) &GetAwtModuleHandle,
113+
&hModule
114+
);
115+
return hModule;
116+
}
117+
118+
extern "C" {
119+
105120
JNIEXPORT jint JNICALL
106121
DEF_JNI_OnLoad(JavaVM *vm, void *reserved)
107122
{
108123
TRY;
109124

125+
AwtToolkit::GetInstance().SetModuleHandle(GetAwtModuleHandle());
126+
110127
jvm = vm;
111128
return JNI_VERSION_1_2;
112129

113130
CATCH_BAD_ALLOC_RET(0);
114131
}
115132

133+
}
134+
116135
extern "C" JNIEXPORT jboolean JNICALL AWTIsHeadless() {
117136
static JNIEnv *env = NULL;
118137
static jboolean isHeadless;
@@ -246,32 +265,6 @@ BOOL AwtToolkit::activateKeyboardLayout(HKL hkl) {
246265
return (prev != 0);
247266
}
248267

249-
/************************************************************************
250-
* Exported functions
251-
*/
252-
253-
extern "C" BOOL APIENTRY DllMain(HANDLE hInstance, DWORD ul_reason_for_call,
254-
LPVOID)
255-
{
256-
// Don't use the TRY and CATCH_BAD_ALLOC_RET macros if we're detaching
257-
// the library. Doing so causes awt.dll to call back into the VM during
258-
// shutdown. This crashes the HotSpot VM.
259-
switch (ul_reason_for_call) {
260-
case DLL_PROCESS_ATTACH:
261-
TRY;
262-
AwtToolkit::GetInstance().SetModuleHandle((HMODULE)hInstance);
263-
CATCH_BAD_ALLOC_RET(FALSE);
264-
break;
265-
case DLL_PROCESS_DETACH:
266-
#ifdef DEBUG
267-
DTrace_DisableMutex();
268-
DMem_DisableMutex();
269-
#endif // DEBUG
270-
break;
271-
}
272-
return TRUE;
273-
}
274-
275268
/************************************************************************
276269
* AwtToolkit fields
277270
*/

src/java.net.http/share/classes/jdk/internal/net/http/RequestPublishers.java

+80-29
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -537,12 +537,20 @@ private static final class AggregateSubscription
537537

538538
@Override
539539
public void request(long n) {
540-
if (cancelled || publisher == null && bodies.isEmpty()) {
541-
return;
540+
synchronized (this) {
541+
// We are finished when publisher is null and bodies
542+
// is empty. This means that the data from the last
543+
// publisher in the list has been consumed.
544+
// If we are finished or cancelled, do nothing.
545+
if (cancelled || (publisher == null && bodies.isEmpty())) {
546+
return;
547+
}
542548
}
543549
try {
544550
demand.increase(n);
545551
} catch (IllegalArgumentException x) {
552+
// request() should not throw - the scheduler will
553+
// invoke onError on the subscriber.
546554
illegalRequest = x;
547555
}
548556
scheduler.runOrSchedule();
@@ -554,46 +562,68 @@ public void cancel() {
554562
scheduler.runOrSchedule();
555563
}
556564

557-
private boolean cancelSubscription() {
558-
Flow.Subscription subscription = this.subscription;
565+
private boolean cancelSubscription(Flow.Subscription subscription) {
559566
if (subscription != null) {
560-
this.subscription = null;
561-
this.publisher = null;
567+
synchronized (this) {
568+
if (this.subscription == subscription) {
569+
this.subscription = null;
570+
this.publisher = null;
571+
}
572+
}
562573
subscription.cancel();
563574
}
575+
// This method is called when cancel is true, so
576+
// we should always stop the scheduler here
564577
scheduler.stop();
565578
return subscription != null;
566579
}
567580

568581
public void run() {
569582
try {
583+
BodyPublisher publisher;
584+
Flow.Subscription subscription = null;
570585
while (error.get() == null
571586
&& (!demand.isFulfilled()
572-
|| (publisher == null && !bodies.isEmpty()))) {
587+
|| (this.publisher == null && !bodies.isEmpty()))) {
573588
boolean cancelled = this.cancelled;
574-
BodyPublisher publisher = this.publisher;
575-
Flow.Subscription subscription = this.subscription;
589+
// make sure we see a consistent state.
590+
synchronized (this) {
591+
publisher = this.publisher;
592+
subscription = this.subscription;
593+
}
576594
Throwable illegalRequest = this.illegalRequest;
577595
if (cancelled) {
578596
bodies.clear();
579-
cancelSubscription();
597+
cancelSubscription(subscription);
580598
return;
581599
}
582600
if (publisher == null && !bodies.isEmpty()) {
583-
this.publisher = publisher = bodies.poll();
601+
// synchronize here to avoid race condition with
602+
// request(long) which could otherwise observe a
603+
// null publisher and an empty bodies list when
604+
// polling the last publisher.
605+
synchronized (this) {
606+
this.publisher = publisher = bodies.poll();
607+
}
584608
publisher.subscribe(this);
585-
subscription = this.subscription;
586609
} else if (publisher == null) {
587610
return;
588611
}
589612
if (illegalRequest != null) {
590613
onError(illegalRequest);
591614
return;
592615
}
593-
if (subscription == null) return;
594-
if (!demand.isFulfilled()) {
595-
long n = demand.decreaseAndGet(demand.get());
596-
demanded.increase(n);
616+
long n = 0;
617+
// synchronize to avoid race condition with
618+
// publisherDone()
619+
synchronized (this) {
620+
if ((subscription = this.subscription) == null) return;
621+
if (!demand.isFulfilled()) {
622+
n = demand.decreaseAndGet(demand.get());
623+
demanded.increase(n);
624+
}
625+
}
626+
if (n > 0 && !cancelled) {
597627
subscription.request(n);
598628
}
599629
}
@@ -602,20 +632,35 @@ public void run() {
602632
}
603633
}
604634

635+
// It is important to synchronize when setting
636+
// publisher to null to avoid race conditions
637+
// with request(long)
638+
private synchronized void publisherDone() {
639+
publisher = null;
640+
subscription = null;
641+
}
642+
605643

606644
@Override
607645
public void onSubscribe(Flow.Subscription subscription) {
608-
this.subscription = subscription;
646+
// synchronize for asserting in a consistent state.
647+
synchronized (this) {
648+
// we shouldn't be able to observe a null publisher
649+
// when onSubscribe is called, unless - possibly - if
650+
// there was some error...
651+
assert publisher != null || error.get() != null;
652+
this.subscription = subscription;
653+
}
609654
scheduler.runOrSchedule();
610655
}
611656

612657
@Override
613658
public void onNext(ByteBuffer item) {
614-
// make sure to cancel the subscription if we receive
615-
// an item after the subscription was cancelled or
659+
// make sure to cancel the downstream subscription if we receive
660+
// an item after the aggregate subscription was cancelled or
616661
// an error was reported.
617662
if (cancelled || error.get() != null) {
618-
cancelSubscription();
663+
cancelSubscription(this.subscription);
619664
return;
620665
}
621666
demanded.tryDecrement();
@@ -625,30 +670,36 @@ public void onNext(ByteBuffer item) {
625670
@Override
626671
public void onError(Throwable throwable) {
627672
if (error.compareAndSet(null, throwable)) {
628-
publisher = null;
629-
subscription = null;
673+
publisherDone();
630674
subscriber.onError(throwable);
631675
scheduler.stop();
632676
}
633677
}
634678

635-
@Override
636-
public void onComplete() {
679+
private synchronized boolean completeAndContinue() {
637680
if (publisher != null && !bodies.isEmpty()) {
638681
while (!demanded.isFulfilled()) {
639682
demand.increase(demanded.decreaseAndGet(demanded.get()));
640683
}
641-
publisher = null;
642-
subscription = null;
684+
publisherDone();
685+
return true; // continue
686+
} else {
687+
publisherDone();
688+
return false; // stop
689+
}
690+
}
691+
692+
@Override
693+
public void onComplete() {
694+
if (completeAndContinue()) {
643695
scheduler.runOrSchedule();
644696
} else {
645-
publisher = null;
646-
subscription = null;
647697
if (!cancelled) {
648698
subscriber.onComplete();
649699
}
650700
scheduler.stop();
651701
}
652702
}
653703
}
704+
654705
}

test/hotspot/gtest/nmt/test_nmt_treap.cpp

+23
Original file line numberDiff line numberDiff line change
@@ -325,5 +325,28 @@ TEST_VM_F(NMTTreapTest, VerifyItThroughStressTest) {
325325
verify_it(treap);
326326
}
327327
}
328+
struct NTD {
329+
static bool has_run_destructor;
330+
~NTD() {
331+
has_run_destructor = true;
332+
}
333+
};
334+
335+
bool NTD::has_run_destructor = false;
336+
337+
TEST_VM_F(NMTTreapTest, ValueDestructorsAreRun) {
338+
TreapCHeap<int, NTD, Cmp> treap;
339+
NTD ntd;
340+
treap.upsert(0, ntd);
341+
treap.remove(0);
342+
EXPECT_TRUE(NTD::has_run_destructor);
343+
NTD::has_run_destructor = false;
344+
{
345+
TreapCHeap<int, NTD, Cmp> treap;
346+
NTD ntd;
347+
treap.upsert(0, ntd);
348+
}
349+
EXPECT_TRUE(NTD::has_run_destructor);
350+
}
328351

329352
#endif // ASSERT

test/hotspot/jtreg/ProblemList-Virtual.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,9 @@ gc/g1/TestMixedGCLiveThreshold.java#25percent 8334759 windows-x64
104104

105105
gc/arguments/TestNewSizeThreadIncrease.java 0000000 generic-all
106106
gc/g1/TestSkipRebuildRemsetPhase.java 0000000 generic-all
107-
runtime/classFileParserBug/TestEmptyBootstrapMethodsAttr.java JDK-8346442 generic-all
107+
runtime/classFileParserBug/TestEmptyBootstrapMethodsAttr.java 8346442 generic-all
108108
runtime/ErrorHandling/MachCodeFramesInErrorFile.java 0000000 generic-all
109-
runtime/logging/LoaderConstraintsTest.java JDK-8346442 generic-all
109+
runtime/logging/LoaderConstraintsTest.java 8346442 generic-all
110110
runtime/Thread/AsyncExceptionOnMonitorEnter.java 0000000 generic-all
111111
runtime/Thread/StopAtExit.java 0000000 generic-all
112112
runtime/handshake/HandshakeWalkStackTest.java 0000000 generic-all

0 commit comments

Comments
 (0)