Skip to content

Commit

Permalink
Merge latest openj9 into openj9-staging
Browse files Browse the repository at this point in the history
Signed-off-by: Jason Feng <[email protected]>
  • Loading branch information
JasonFengJ9 committed Nov 20, 2024
2 parents 6ed2d4e + 9387ac3 commit efd3e0e
Show file tree
Hide file tree
Showing 407 changed files with 4,882 additions and 5,780 deletions.
2 changes: 1 addition & 1 deletion closed/openjdk-tag.gmk
Original file line number Diff line number Diff line change
@@ -1 +1 @@
OPENJDK_TAG := jdk-24+23
OPENJDK_TAG := jdk-24+24
72 changes: 69 additions & 3 deletions make/RunTests.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ ifneq ($(TEST_VM_OPTS), )
endif

$(eval $(call ParseKeywordVariable, TEST_OPTS, \
SINGLE_KEYWORDS := JOBS TIMEOUT_FACTOR JCOV JCOV_DIFF_CHANGESET, \
SINGLE_KEYWORDS := JOBS TIMEOUT_FACTOR JCOV JCOV_DIFF_CHANGESET AOT_JDK, \
STRING_KEYWORDS := VM_OPTIONS JAVA_OPTIONS, \
))

Expand Down Expand Up @@ -202,11 +202,12 @@ $(eval $(call SetTestOpt,JOBS,JTREG))
$(eval $(call SetTestOpt,TIMEOUT_FACTOR,JTREG))
$(eval $(call SetTestOpt,FAILURE_HANDLER_TIMEOUT,JTREG))
$(eval $(call SetTestOpt,REPORT,JTREG))
$(eval $(call SetTestOpt,AOT_JDK,JTREG))

$(eval $(call ParseKeywordVariable, JTREG, \
SINGLE_KEYWORDS := JOBS TIMEOUT_FACTOR FAILURE_HANDLER_TIMEOUT \
TEST_MODE ASSERT VERBOSE RETAIN TEST_THREAD_FACTORY MAX_MEM RUN_PROBLEM_LISTS \
RETRY_COUNT REPEAT_COUNT MAX_OUTPUT REPORT $(CUSTOM_JTREG_SINGLE_KEYWORDS), \
RETRY_COUNT REPEAT_COUNT MAX_OUTPUT REPORT AOT_JDK $(CUSTOM_JTREG_SINGLE_KEYWORDS), \
STRING_KEYWORDS := OPTIONS JAVA_OPTIONS VM_OPTIONS KEYWORDS \
EXTRA_PROBLEM_LISTS LAUNCHER_OPTIONS \
$(CUSTOM_JTREG_STRING_KEYWORDS), \
Expand Down Expand Up @@ -702,6 +703,58 @@ define SetJtregValue
endif
endef


# Parameter 1 is the name of the rule.
#
# Remaining parameters are named arguments.
# VM_OPTIONS List of JVM arguments to use when creating AOT cache
#
# After calling this, the following variables are defined
# $1_AOT_TARGETS List of all targets that the test rule will need to depend on
# $1_AOT_JDK_CACHE The AOT cache file to be used to run the test with
#
SetupAot = $(NamedParamsMacroTemplate)
define SetupAotBody
$1_AOT_JDK_CONF := $$($1_TEST_SUPPORT_DIR)/aot/jdk.aotconf
$1_AOT_JDK_CACHE := $$($1_TEST_SUPPORT_DIR)/aot/jdk.aotcache

$1_JAVA_TOOL_OPTS := $$(addprefix -J, $$($1_VM_OPTIONS))

$$($1_AOT_JDK_CACHE): $$(JDK_IMAGE_DIR)/release
$$(call MakeDir, $$($1_TEST_SUPPORT_DIR)/aot)

$(foreach jtool, javac javap jlink jar, \
$(info AOT: Create cache configuration for $(jtool)) \
$$(call ExecuteWithLog, $$($1_TEST_SUPPORT_DIR)/aot.$(jtool), ( \
$$(FIXPATH) $(JDK_UNDER_TEST)/bin/$(jtool) $$($1_JAVA_TOOL_OPTS) \
-J-XX:AOTMode=record -J-XX:AOTConfiguration=$$($1_AOT_JDK_CONF).$(jtool) --help \
))
)

$$(info AOT: Copy $(JDK_UNDER_TEST)/lib/classlist to $$($1_AOT_JDK_CONF).jdk )
$$(call ExecuteWithLog, $$($1_TEST_SUPPORT_DIR)/aot, ( \
$$(FIXPATH) $(CP) $(JDK_UNDER_TEST)/lib/classlist $$($1_AOT_JDK_CONF).jdk \
))

$$(FIXPATH) $$(CAT) $$($1_AOT_JDK_CONF).* > $$($1_AOT_JDK_CONF).temp
$$(FIXPATH) $$(CAT) $$($1_AOT_JDK_CONF).temp | $(GREP) -v '#' | $(GREP) -v '@' | $(SORT) | \
$(SED) -e 's/id:.*//g' | uniq \
> $$($1_AOT_JDK_CONF)
$$(FIXPATH) $$(CAT) $$($1_AOT_JDK_CONF).temp | $(GREP) '@cp' | $(SORT) \
>> $$($1_AOT_JDK_CONF)

$$(info AOT: Generate AOT cache $$($1_AOT_JDK_CACHE) with flags: $$($1_VM_OPTIONS))
$$(call ExecuteWithLog, $$($1_TEST_SUPPORT_DIR)/aot, ( \
$$(FIXPATH) $(JDK_UNDER_TEST)/bin/java \
$$($1_VM_OPTIONS) -Xlog:cds,cds+class=debug:file=$$($1_AOT_JDK_CACHE).log \
-XX:AOTMode=create -XX:AOTConfiguration=$$($1_AOT_JDK_CONF) -XX:AOTCache=$$($1_AOT_JDK_CACHE) \
))

$1_AOT_TARGETS += $$($1_AOT_JDK_CACHE)

endef


SetupRunJtregTest = $(NamedParamsMacroTemplate)
define SetupRunJtregTestBody
$1_TEST_RESULTS_DIR := $$(TEST_RESULTS_DIR)/$1
Expand Down Expand Up @@ -762,6 +815,7 @@ define SetupRunJtregTestBody
JTREG_RETRY_COUNT ?= 0
JTREG_REPEAT_COUNT ?= 0
JTREG_REPORT ?= files
JTREG_AOT_JDK ?= false

ifneq ($$(JTREG_RETRY_COUNT), 0)
ifneq ($$(JTREG_REPEAT_COUNT), 0)
Expand Down Expand Up @@ -891,6 +945,17 @@ define SetupRunJtregTestBody
endif
endif

ifeq ($$(JTREG_AOT_JDK), true)
$$(info Add AOT target for $1)
$$(eval $$(call SetupAot, $1, VM_OPTIONS := $$(JTREG_ALL_OPTIONS) ))

$$(info AOT_TARGETS=$$($1_AOT_TARGETS))
$$(info AOT_JDK_CACHE=$$($1_AOT_JDK_CACHE))

$1_JTREG_BASIC_OPTIONS += -vmoption:-XX:AOTCache="$$($1_AOT_JDK_CACHE)"
endif


$$(eval $$(call SetupRunJtregTestCustom, $1))

# SetupRunJtregTestCustom might also adjust JTREG_AUTO_ variables
Expand All @@ -906,6 +971,7 @@ define SetupRunJtregTestBody
JTREG_TIMEOUT_FACTOR ?= $$(JTREG_AUTO_TIMEOUT_FACTOR)

clean-outputdirs-$1:
$$(call LogWarn, Clean up dirs for $1)
$$(RM) -r $$($1_TEST_SUPPORT_DIR)
$$(RM) -r $$($1_TEST_RESULTS_DIR)

Expand Down Expand Up @@ -953,7 +1019,7 @@ define SetupRunJtregTestBody
done
endif

run-test-$1: pre-run-test clean-outputdirs-$1
run-test-$1: clean-outputdirs-$1 pre-run-test $$($1_AOT_TARGETS)
$$(call LogWarn)
$$(call LogWarn, Running test '$$($1_TEST)')
$$(call MakeDir, $$($1_TEST_RESULTS_DIR) $$($1_TEST_SUPPORT_DIR) \
Expand Down
130 changes: 9 additions & 121 deletions src/java.base/share/classes/java/io/BufferedInputStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import java.util.Arrays;
import java.util.Objects;

import jdk.internal.misc.InternalLock;
import jdk.internal.misc.Unsafe;
import jdk.internal.util.ArraysSupport;

Expand Down Expand Up @@ -74,9 +73,6 @@ public class BufferedInputStream extends FilterInputStream {
private static final long BUF_OFFSET
= U.objectFieldOffset(BufferedInputStream.class, "buf");

// initialized to null when BufferedInputStream is sub-classed
private final InternalLock lock;

// initial buffer size (DEFAULT_BUFFER_SIZE or size specified to constructor)
private final int initialSize;

Expand Down Expand Up @@ -243,20 +239,17 @@ public BufferedInputStream(InputStream in, int size) {
}
initialSize = size;
if (getClass() == BufferedInputStream.class) {
// use internal lock and lazily create buffer when not subclassed
lock = InternalLock.newLockOrNull();
// lazily create buffer when not subclassed
buf = EMPTY;
} else {
// use monitors and eagerly create buffer when subclassed
lock = null;
buf = new byte[size];
}
}

/**
* Fills the buffer with more data, taking into account
* shuffling and other tricks for dealing with marks.
* Assumes that it is being called by a locked method.
* Assumes that it is being called by a synchronized method.
* This method also assumes that all data has already been read in,
* hence pos > count.
*/
Expand Down Expand Up @@ -310,22 +303,7 @@ else if (pos >= buffer.length) { /* no room left in buffer */
* or an I/O error occurs.
* @see java.io.FilterInputStream#in
*/
public int read() throws IOException {
if (lock != null) {
lock.lock();
try {
return implRead();
} finally {
lock.unlock();
}
} else {
synchronized (this) {
return implRead();
}
}
}

private int implRead() throws IOException {
public synchronized int read() throws IOException {
if (pos >= count) {
fill();
if (pos >= count)
Expand Down Expand Up @@ -397,22 +375,7 @@ private int read1(byte[] b, int off, int len) throws IOException {
* or an I/O error occurs.
* @throws IndexOutOfBoundsException {@inheritDoc}
*/
public int read(byte[] b, int off, int len) throws IOException {
if (lock != null) {
lock.lock();
try {
return implRead(b, off, len);
} finally {
lock.unlock();
}
} else {
synchronized (this) {
return implRead(b, off, len);
}
}
}

private int implRead(byte[] b, int off, int len) throws IOException {
public synchronized int read(byte[] b, int off, int len) throws IOException {
ensureOpen();
if ((off | len | (off + len) | (b.length - (off + len))) < 0) {
throw new IndexOutOfBoundsException();
Expand Down Expand Up @@ -444,22 +407,7 @@ private int implRead(byte[] b, int off, int len) throws IOException {
* {@code in.skip(n)} throws an IOException,
* or an I/O error occurs.
*/
public long skip(long n) throws IOException {
if (lock != null) {
lock.lock();
try {
return implSkip(n);
} finally {
lock.unlock();
}
} else {
synchronized (this) {
return implSkip(n);
}
}
}

private long implSkip(long n) throws IOException {
public synchronized long skip(long n) throws IOException {
ensureOpen();
if (n <= 0) {
return 0;
Expand Down Expand Up @@ -500,22 +448,7 @@ private long implSkip(long n) throws IOException {
* invoking its {@link #close()} method,
* or an I/O error occurs.
*/
public int available() throws IOException {
if (lock != null) {
lock.lock();
try {
return implAvailable();
} finally {
lock.unlock();
}
} else {
synchronized (this) {
return implAvailable();
}
}
}

private int implAvailable() throws IOException {
public synchronized int available() throws IOException {
int n = count - pos;
int avail = getInIfOpen().available();
return n > (Integer.MAX_VALUE - avail)
Expand All @@ -531,22 +464,7 @@ private int implAvailable() throws IOException {
* the mark position becomes invalid.
* @see java.io.BufferedInputStream#reset()
*/
public void mark(int readlimit) {
if (lock != null) {
lock.lock();
try {
implMark(readlimit);
} finally {
lock.unlock();
}
} else {
synchronized (this) {
implMark(readlimit);
}
}
}

private void implMark(int readlimit) {
public synchronized void mark(int readlimit) {
marklimit = readlimit;
markpos = pos;
}
Expand All @@ -567,22 +485,7 @@ private void implMark(int readlimit) {
* method, or an I/O error occurs.
* @see java.io.BufferedInputStream#mark(int)
*/
public void reset() throws IOException {
if (lock != null) {
lock.lock();
try {
implReset();
} finally {
lock.unlock();
}
} else {
synchronized (this) {
implReset();
}
}
}

private void implReset() throws IOException {
public synchronized void reset() throws IOException {
ensureOpen();
if (markpos < 0)
throw new IOException("Resetting to invalid mark");
Expand Down Expand Up @@ -628,23 +531,8 @@ public void close() throws IOException {
}

@Override
public long transferTo(OutputStream out) throws IOException {
public synchronized long transferTo(OutputStream out) throws IOException {
Objects.requireNonNull(out, "out");
if (lock != null) {
lock.lock();
try {
return implTransferTo(out);
} finally {
lock.unlock();
}
} else {
synchronized (this) {
return implTransferTo(out);
}
}
}

private long implTransferTo(OutputStream out) throws IOException {
if (getClass() == BufferedInputStream.class && markpos == -1) {
int avail = count - pos;
if (avail > 0) {
Expand Down
Loading

0 comments on commit efd3e0e

Please sign in to comment.