Skip to content

Commit 6bb7f67

Browse files
committed
Merge master jdk-17.0.4+3 into openj9-staging
2 parents aeef729 + 9684819 commit 6bb7f67

File tree

14 files changed

+904
-38
lines changed

14 files changed

+904
-38
lines changed

make/autoconf/basic_tools.m4

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,8 @@ AC_DEFUN([BASIC_CHECK_TAR],
270270
TAR_TYPE="bsd"
271271
elif test "x$($TAR -v | $GREP "bsdtar")" != "x"; then
272272
TAR_TYPE="bsd"
273+
elif test "x$($TAR --version | $GREP "busybox")" != "x"; then
274+
TAR_TYPE="busybox"
273275
elif test "x$OPENJDK_BUILD_OS" = "xaix"; then
274276
TAR_TYPE="aix"
275277
fi
@@ -281,9 +283,12 @@ AC_DEFUN([BASIC_CHECK_TAR],
281283
TAR_SUPPORTS_TRANSFORM="true"
282284
elif test "x$TAR_TYPE" = "aix"; then
283285
# -L InputList of aix tar: name of file listing the files and directories
284-
# that need to be archived or extracted
286+
# that need to be archived or extracted
285287
TAR_INCLUDE_PARAM="L"
286288
TAR_SUPPORTS_TRANSFORM="false"
289+
elif test "x$TAR_TYPE" = "xbusybox"; then
290+
TAR_INCLUDE_PARAM="T"
291+
TAR_SUPPORTS_TRANSFORM="false"
287292
else
288293
TAR_INCLUDE_PARAM="I"
289294
TAR_SUPPORTS_TRANSFORM="false"

make/modules/java.desktop/lib/Awt2dLibraries.gmk

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,6 @@ else
470470

471471
endif
472472

473-
474473
LIBFONTMANAGER_EXTRA_HEADER_DIRS := \
475474
libharfbuzz \
476475
common/awt \
@@ -485,6 +484,14 @@ BUILD_LIBFONTMANAGER_FONTLIB += $(LIBFREETYPE_LIBS)
485484

486485
LIBFONTMANAGER_OPTIMIZATION := HIGHEST
487486

487+
ifneq ($(filter $(TOOLCHAIN_TYPE), gcc clang), )
488+
# gcc (and to an extent clang) is particularly bad at optimizing these files,
489+
# causing a massive spike in compile time. We don't care about these
490+
# particular files anyway, so lower optimization level.
491+
BUILD_LIBFONTMANAGER_hb-subset.cc_OPTIMIZATION := SIZE
492+
BUILD_LIBFONTMANAGER_hb-subset-plan.cc_OPTIMIZATION := SIZE
493+
endif
494+
488495
ifeq ($(call isTargetOs, windows), true)
489496
LIBFONTMANAGER_EXCLUDE_FILES += X11FontScaler.c \
490497
X11TextRenderer.c

src/java.base/share/classes/sun/nio/fs/PollingWatchService.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@
6161
class PollingWatchService
6262
extends AbstractWatchService
6363
{
64+
// Wait between polling thread creation and first poll (seconds)
65+
private static final int POLLING_INIT_DELAY = 1;
66+
// Default time between polls (seconds)
67+
private static final int DEFAULT_POLLING_INTERVAL = 2;
68+
6469
// map of registrations
6570
private final Map<Object, PollingWatchKey> map = new HashMap<>();
6671

@@ -115,7 +120,7 @@ WatchKey register(final Path path,
115120
throw new IllegalArgumentException("No events to register");
116121

117122
// Extended modifiers may be used to specify the sensitivity level
118-
int sensitivity = 10;
123+
int sensitivity = DEFAULT_POLLING_INTERVAL;
119124
if (modifiers.length > 0) {
120125
for (WatchEvent.Modifier modifier: modifiers) {
121126
if (modifier == null)
@@ -247,6 +252,7 @@ void update(long lastModified, int tickCount) {
247252
* directory and queue keys when entries are added, modified, or deleted.
248253
*/
249254
private class PollingWatchKey extends AbstractWatchKey {
255+
250256
private final Object fileKey;
251257

252258
// current event set
@@ -305,10 +311,10 @@ void enable(Set<? extends WatchEvent.Kind<?>> events, long period) {
305311
// update the events
306312
this.events = events;
307313

308-
// create the periodic task
314+
// create the periodic task with initialDelay set to the specified constant
309315
Runnable thunk = new Runnable() { public void run() { poll(); }};
310316
this.poller = scheduledExecutor
311-
.scheduleAtFixedRate(thunk, period, period, TimeUnit.SECONDS);
317+
.scheduleAtFixedRate(thunk, POLLING_INIT_DELAY, period, TimeUnit.SECONDS);
312318
}
313319
}
314320

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

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1995, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1995, 2022, 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
@@ -47,7 +47,6 @@
4747
import jdk.internal.access.JavaIOFileDescriptorAccess;
4848
import jdk.internal.access.SharedSecrets;
4949
import jdk.internal.ref.CleanerFactory;
50-
import sun.security.action.GetBooleanAction;
5150
import sun.security.action.GetPropertyAction;
5251

5352
/* This class is for the exclusive use of ProcessBuilder.start() to
@@ -269,11 +268,22 @@ private static String createCommandLine(int verificationType,
269268
// command line parser. The case of the [""] tail escape
270269
// sequence could not be realized due to the argument validation
271270
// procedure.
272-
int count = countLeadingBackslash(verificationType, s, s.length());
273-
while (count-- > 0) {
274-
cmdbuf.append(BACKSLASH); // double the number of backslashes
271+
if (verificationType == VERIFICATION_WIN32_SAFE ||
272+
verificationType == VERIFICATION_LEGACY) {
273+
int count = countLeadingBackslash(verificationType, s, s.length());
274+
while (count-- > 0) {
275+
cmdbuf.append(BACKSLASH); // double the number of backslashes
276+
}
275277
}
276278
cmdbuf.append('"');
279+
} else if (verificationType == VERIFICATION_WIN32_SAFE &&
280+
(s.startsWith("\"") && s.endsWith("\"") && s.length() > 2)) {
281+
// Check that quoted argument does not escape the final quote
282+
cmdbuf.append(s);
283+
int count = countLeadingBackslash(verificationType, s, s.length() - 1);
284+
while (count-- > 0) {
285+
cmdbuf.insert(cmdbuf.length() - 1, BACKSLASH); // double the number of backslashes
286+
}
277287
} else {
278288
cmdbuf.append(s);
279289
}
@@ -282,19 +292,14 @@ private static String createCommandLine(int verificationType,
282292
}
283293

284294
/**
285-
* Return the argument without quotes (1st and last) if properly quoted, else the arg.
286-
* A properly quoted string has first and last characters as quote and
287-
* the last quote is not escaped.
295+
* Return the argument without quotes (first and last) if quoted, otherwise the arg.
288296
* @param str a string
289297
* @return the string without quotes
290298
*/
291299
private static String unQuote(String str) {
292300
if (!str.startsWith("\"") || !str.endsWith("\"") || str.length() < 2)
293301
return str; // no beginning or ending quote, or too short not quoted
294302

295-
if (str.endsWith("\\\"")) {
296-
return str; // not properly quoted, treat as unquoted
297-
}
298303
// Strip leading and trailing quotes
299304
return str.substring(1, str.length() - 1);
300305
}

src/jdk.jdwp.agent/share/native/libjdwp/threadControl.c

Lines changed: 74 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ typedef struct ThreadNode {
7373
unsigned int popFrameEvent : 1;
7474
unsigned int popFrameProceed : 1;
7575
unsigned int popFrameThread : 1;
76+
unsigned int handlingAppResume : 1;
7677
EventIndex current_ei; /* Used to determine if we are currently handling an event on this thread. */
7778
jobject pendingStop; /* Object we are throwing to stop the thread (ThreadReferenceImpl.stop). */
7879
jint suspendCount;
@@ -655,7 +656,10 @@ pendingAppResume(jboolean includeSuspended)
655656
if (error != JVMTI_ERROR_NONE) {
656657
EXIT_ERROR(error, "getting thread state");
657658
}
658-
if (!(state & JVMTI_THREAD_STATE_SUSPENDED)) {
659+
/* !node->handlingAppResume && resumeFrameDepth > 0
660+
* means the thread has entered Thread.resume() */
661+
if (!(state & JVMTI_THREAD_STATE_SUSPENDED) &&
662+
!node->handlingAppResume) {
659663
return JNI_TRUE;
660664
}
661665
}
@@ -728,6 +732,11 @@ blockOnDebuggerSuspend(jthread thread)
728732
}
729733
}
730734

735+
/*
736+
* The caller is expected to hold threadLock and handlerLock.
737+
* eventHandler_createInternalThreadOnly() can deadlock because of
738+
* wrong lock ordering if the caller does not hold handlerLock.
739+
*/
731740
static void
732741
trackAppResume(jthread thread)
733742
{
@@ -776,28 +785,19 @@ handleAppResumeBreakpoint(JNIEnv *env, EventInfo *evinfo,
776785
struct bag *eventBag)
777786
{
778787
jthread resumer = evinfo->thread;
779-
jthread resumee = getResumee(resumer);
780788

781789
debugMonitorEnter(threadLock);
782-
if (resumee != NULL) {
783-
/*
784-
* Hold up any attempt to resume as long as the debugger
785-
* has suspended the resumee.
786-
*/
787-
blockOnDebuggerSuspend(resumee);
788-
}
789790

791+
/*
792+
* Actual handling has to be deferred. We cannot block right here if the
793+
* target of the resume call is suspended by the debugger since we are
794+
* holding handlerLock which must not be released. See doPendingTasks().
795+
*/
790796
if (resumer != NULL) {
791-
/*
792-
* Track the resuming thread by marking it as being within
793-
* a resume and by setting up for notification on
794-
* a frame pop or exception. We won't allow the debugger
795-
* to suspend threads while any thread is within a
796-
* call to resume. This (along with the block above)
797-
* ensures that when the debugger
798-
* suspends a thread it will remain suspended.
799-
*/
800-
trackAppResume(resumer);
797+
ThreadNode* node = findThread(&runningThreads, resumer);
798+
if (node != NULL) {
799+
node->handlingAppResume = JNI_TRUE;
800+
}
801801
}
802802

803803
debugMonitorExit(threadLock);
@@ -2155,6 +2155,59 @@ threadControl_onEventHandlerEntry(jbyte sessionID, EventInfo *evinfo, jobject cu
21552155
static void
21562156
doPendingTasks(JNIEnv *env, ThreadNode *node)
21572157
{
2158+
/* Deferred breakpoint handling for Thread.resume() */
2159+
if (node->handlingAppResume) {
2160+
jthread resumer = node->thread;
2161+
jthread resumee = getResumee(resumer);
2162+
2163+
if (resumer != NULL) {
2164+
/*
2165+
* trackAppResume indirectly aquires handlerLock. For proper lock
2166+
* ordering handlerLock has to be acquired before threadLock.
2167+
*/
2168+
debugMonitorExit(threadLock);
2169+
eventHandler_lock();
2170+
debugMonitorEnter(threadLock);
2171+
2172+
/*
2173+
* Track the resuming thread by marking it as being within
2174+
* a resume and by setting up for notification on
2175+
* a frame pop or exception. We won't allow the debugger
2176+
* to suspend threads while any thread is within a
2177+
* call to resume. This (along with the block below)
2178+
* ensures that when the debugger
2179+
* suspends a thread it will remain suspended.
2180+
*/
2181+
trackAppResume(resumer);
2182+
2183+
/*
2184+
* handlerLock is not needed anymore. We must release it before calling
2185+
* blockOnDebuggerSuspend() because it is required for resumes done by
2186+
* the debugger. If resumee is currently suspended by the debugger, then
2187+
* blockOnDebuggerSuspend() will block until a debugger resume is done.
2188+
* If it blocks while holding the handlerLock, then the resume will deadlock.
2189+
*/
2190+
eventHandler_unlock();
2191+
}
2192+
2193+
if (resumee != NULL) {
2194+
/*
2195+
* Hold up any attempt to resume as long as the debugger
2196+
* has suspended the resumee.
2197+
*/
2198+
blockOnDebuggerSuspend(resumee);
2199+
}
2200+
2201+
node->handlingAppResume = JNI_FALSE;
2202+
2203+
/*
2204+
* The blocks exit condition: resumee's suspendCount == 0.
2205+
*
2206+
* Debugger suspends are blocked if any thread is executing
2207+
* Thread.resume(), i.e. !handlingAppResume && frameDepth > 0.
2208+
*/
2209+
}
2210+
21582211
/*
21592212
* Take care of any pending interrupts/stops, and clear out
21602213
* info on pending interrupts/stops.
@@ -2455,6 +2508,8 @@ threadControl_reset(void)
24552508
/* Everything should have been resumed */
24562509
JDI_ASSERT(otherThreads.first == NULL);
24572510

2511+
/* Threads could be waiting in blockOnDebuggerSuspend */
2512+
debugMonitorNotifyAll(threadLock);
24582513
debugMonitorExit(threadLock);
24592514
eventHandler_unlock();
24602515
}

test/hotspot/jtreg/compiler/blackhole/BlackholeIntrinsicTest.java

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,15 @@ public class BlackholeIntrinsicTest {
7777
TESTS.put("bh_s_long_2", BlackholeIntrinsicTest::test_long_2);
7878
TESTS.put("bh_s_double_2", BlackholeIntrinsicTest::test_double_2);
7979
TESTS.put("bh_s_Object_2", BlackholeIntrinsicTest::test_Object_2);
80+
81+
// Test calling static methods through instance method to exercise
82+
// unusual intrinsic shapes.
83+
TESTS.put("bh_is_int_0", BlackholeIntrinsicTest::test_is_int_0);
84+
TESTS.put("bh_is_Object_0", BlackholeIntrinsicTest::test_is_Object_0);
85+
TESTS.put("bh_is_int_1", BlackholeIntrinsicTest::test_is_int_1);
86+
TESTS.put("bh_is_Object_1", BlackholeIntrinsicTest::test_is_Object_1);
87+
TESTS.put("bh_is_int_2", BlackholeIntrinsicTest::test_is_int_2);
88+
TESTS.put("bh_is_Object_2", BlackholeIntrinsicTest::test_is_Object_2);
8089
}
8190

8291
private static final int CYCLES = 100_000;
@@ -162,6 +171,13 @@ private static void test_int_0() {
162171
}
163172
}
164173

174+
private static void test_is_int_0() {
175+
BlackholeTarget t = new BlackholeTarget();
176+
for (int c = 0; c < CYCLES; c++) {
177+
t.bh_is_int_0();
178+
}
179+
}
180+
165181
private static void test_float_0() {
166182
for (int c = 0; c < CYCLES; c++) {
167183
BlackholeTarget.bh_s_float_0();
@@ -186,6 +202,13 @@ private static void test_Object_0() {
186202
}
187203
}
188204

205+
private static void test_is_Object_0() {
206+
BlackholeTarget t = new BlackholeTarget();
207+
for (int c = 0; c < CYCLES; c++) {
208+
t.bh_is_Object_0();
209+
}
210+
}
211+
189212
private static void test_boolean_1() {
190213
for (int c = 0; c < CYCLES; c++) {
191214
BlackholeTarget.bh_s_boolean_1((c & 0x1) == 0);
@@ -216,6 +239,13 @@ private static void test_int_1() {
216239
}
217240
}
218241

242+
private static void test_is_int_1() {
243+
BlackholeTarget t = new BlackholeTarget();
244+
for (int c = 0; c < CYCLES; c++) {
245+
t.bh_is_int_1(c);
246+
}
247+
}
248+
219249
private static void test_float_1() {
220250
for (int c = 0; c < CYCLES; c++) {
221251
BlackholeTarget.bh_s_float_1(c);
@@ -241,6 +271,14 @@ private static void test_Object_1() {
241271
}
242272
}
243273

274+
private static void test_is_Object_1() {
275+
BlackholeTarget t = new BlackholeTarget();
276+
for (int c = 0; c < CYCLES; c++) {
277+
Object o = new Object();
278+
t.bh_is_Object_1(o);
279+
}
280+
}
281+
244282
private static void test_boolean_2() {
245283
for (int c = 0; c < CYCLES; c++) {
246284
BlackholeTarget.bh_s_boolean_2((c & 0x1) == 0, (c & 0x2) == 0);
@@ -271,6 +309,13 @@ private static void test_int_2() {
271309
}
272310
}
273311

312+
private static void test_is_int_2() {
313+
BlackholeTarget t = new BlackholeTarget();
314+
for (int c = 0; c < CYCLES; c++) {
315+
t.bh_is_int_2(c, c + 1);
316+
}
317+
}
318+
274319
private static void test_float_2() {
275320
for (int c = 0; c < CYCLES; c++) {
276321
BlackholeTarget.bh_s_float_2(c, c + 1);
@@ -296,4 +341,13 @@ private static void test_Object_2() {
296341
BlackholeTarget.bh_s_Object_2(o1, o2);
297342
}
298343
}
344+
345+
private static void test_is_Object_2() {
346+
BlackholeTarget t = new BlackholeTarget();
347+
for (int c = 0; c < CYCLES; c++) {
348+
Object o1 = new Object();
349+
Object o2 = new Object();
350+
t.bh_is_Object_2(o1, o2);
351+
}
352+
}
299353
}

0 commit comments

Comments
 (0)