Skip to content

Commit

Permalink
Merge branch 'upstream-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Datadog Syncup Service committed Oct 25, 2023
2 parents 8292c8b + b026d0b commit 7a1b294
Show file tree
Hide file tree
Showing 60 changed files with 2,252 additions and 693 deletions.
112 changes: 73 additions & 39 deletions doc/building.html
Original file line number Diff line number Diff line change
Expand Up @@ -819,11 +819,11 @@ <h2 id="running-configure">Running Configure</h2>
<p>Some command line examples:</p>
<ul>
<li><p>Create a 32-bit build for Windows with FreeType2 in
<code>C:\freetype-i586</code>:
<code>bash configure --with-freetype=/cygdrive/c/freetype-i586 --with-target-bits=32</code></p></li>
<code>C:\freetype-i586</code>:</p>
<pre><code>bash configure --with-freetype=/cygdrive/c/freetype-i586 --with-target-bits=32</code></pre></li>
<li><p>Create a debug build with the <code>server</code> JVM and DTrace
enabled:
<code>bash configure --enable-debug --with-jvm-variants=server --enable-dtrace</code></p></li>
enabled:</p>
<pre><code>bash configure --enable-debug --with-jvm-variants=server --enable-dtrace</code></pre></li>
</ul>
<h3 id="common-configure-arguments">Common Configure Arguments</h3>
<p>Here follows some of the most common and important
Expand Down Expand Up @@ -1331,14 +1331,12 @@ <h4 id="alsa-1">ALSA</h4>
<code>libasound2-dev</code> packages for your <em>target</em> system.
Download them to /tmp.</p></li>
<li><p>Install the libraries into the cross-compilation toolchain. For
instance:</p></li>
</ul>
instance:</p>
<pre><code>cd /tools/gcc-linaro-arm-linux-gnueabihf-raspbian-2012.09-20120921_linux/arm-linux-gnueabihf/libc
dpkg-deb -x /tmp/libasound2_1.0.25-4_armhf.deb .
dpkg-deb -x /tmp/libasound2-dev_1.0.25-4_armhf.deb .</code></pre>
<ul>
<li>If alsa is not properly detected by <code>configure</code>, you can
point it out by <code>--with-alsa</code>.</li>
dpkg-deb -x /tmp/libasound2-dev_1.0.25-4_armhf.deb .</code></pre></li>
<li><p>If alsa is not properly detected by <code>configure</code>, you
can point it out by <code>--with-alsa</code>.</p></li>
</ul>
<h4 id="x11-1">X11</h4>
<p>You will need X11 libraries suitable for your <em>target</em> system.
Expand Down Expand Up @@ -1372,21 +1370,18 @@ <h4 id="x11-1">X11</h4>
</ul></li>
<li><p>Install the libraries into the cross-compilation toolchain. For
instance:</p>
<pre><code> cd /tools/gcc-linaro-arm-linux-gnueabihf-raspbian-2012.09-20120921_linux/arm-linux-gnueabihf/libc/usr
mkdir X11R6
cd X11R6
for deb in /tmp/target-x11/*.deb ; do dpkg-deb -x $deb . ; done
mv usr/* .
cd lib
cp arm-linux-gnueabihf/* .
```

You can ignore the following messages. These libraries are not needed to
successfully complete a full JDK build.</code></pre>
<p>cp: cannot stat
<code>arm-linux-gnueabihf/libICE.so': No such file or directory cp: cannot stat</code>arm-linux-gnueabihf/libSM.so':
No such file or directory cp: cannot stat
`arm-linux-gnueabihf/libXt.so': No such file or directory ```</p></li>
<pre><code>cd /tools/gcc-linaro-arm-linux-gnueabihf-raspbian-2012.09-20120921_linux/arm-linux-gnueabihf/libc/usr
mkdir X11R6
cd X11R6
for deb in /tmp/target-x11/*.deb ; do dpkg-deb -x $deb . ; done
mv usr/* .
cd lib
cp arm-linux-gnueabihf/* .</code></pre>
<p>You can ignore the following messages. These libraries are not needed
to successfully complete a full JDK build.</p>
<pre><code>cp: cannot stat `arm-linux-gnueabihf/libICE.so&#39;: No such file or directory
cp: cannot stat `arm-linux-gnueabihf/libSM.so&#39;: No such file or directory
cp: cannot stat `arm-linux-gnueabihf/libXt.so&#39;: No such file or directory</code></pre></li>
<li><p>If the X11 libraries are not properly detected by
<code>configure</code>, you can point them out by
<code>--with-x</code>.</p></li>
Expand All @@ -1404,17 +1399,41 @@ <h3 id="cross-compiling-with-debian-sysroots">Cross compiling with
<p>For example, cross-compiling to AArch64 from x86_64 could be done
like this:</p>
<ul>
<li><p>Install cross-compiler on the <em>build</em> system:
<code>apt install g++-aarch64-linux-gnu gcc-aarch64-linux-gnu</code></p></li>
<li><p>Install cross-compiler on the <em>build</em> system:</p>
<pre><code>apt install g++-aarch64-linux-gnu gcc-aarch64-linux-gnu</code></pre></li>
<li><p>Create chroot on the <em>build</em> system, configuring it for
<em>target</em> system:
<code>sudo debootstrap \ --arch=arm64 \ --verbose \ --include=fakeroot,symlinks,build-essential,libx11-dev,libxext-dev,libxrender-dev,libxrandr-dev,libxtst-dev,libxt-dev,libcups2-dev,libfontconfig1-dev,libasound2-dev,libfreetype6-dev,libpng-dev,libffi-dev \ --resolve-deps \ buster \ ~/sysroot-arm64 \ http://httpredir.debian.org/debian/ # If the target architecture is `riscv64`, # the path should be `debian-ports` instead of `debian`.</code></p></li>
<em>target</em> system:</p>
<pre><code>sudo debootstrap \
--arch=arm64 \
--verbose \
--include=fakeroot,symlinks,build-essential,libx11-dev,libxext-dev,libxrender-dev,libxrandr-dev,libxtst-dev,libxt-dev,libcups2-dev,libfontconfig1-dev,libasound2-dev,libfreetype6-dev,libpng-dev,libffi-dev \
--resolve-deps \
buster \
~/sysroot-arm64 \
http://httpredir.debian.org/debian/
# If the target architecture is `riscv64`,
# the path should be `debian-ports` instead of `debian`.</code></pre></li>
<li><p>To create a Ubuntu-based chroot:</p>
<pre><code>sudo debootstrap \
--arch=arm64 \
--verbose \
--components=main,universe \
--include=fakeroot,symlinks,build-essential,libx11-dev,libxext-dev,libxrender-dev,libxrandr-dev,libxtst-dev,libxt-dev,libcups2-dev,libfontconfig1-dev,libasound2-dev,libfreetype6-dev,libpng-dev,libffi-dev \
--resolve-deps \
jammy \
~/sysroot-arm64 \
http://ports.ubuntu.com/ubuntu-ports/
# symlinks is in the universe repository</code></pre></li>
<li><p>Make sure the symlinks inside the newly created chroot point to
proper locations:
<code>sudo chroot ~/sysroot-arm64 symlinks -cr .</code></p></li>
proper locations:</p>
<pre><code>sudo chroot ~/sysroot-arm64 symlinks -cr .</code></pre></li>
<li><p>Configure and build with newly created chroot as
sysroot/toolchain-path:
<code>sh ./configure \ --openjdk-target=aarch64-linux-gnu \ --with-sysroot=~/sysroot-arm64 make images ls build/linux-aarch64-server-release/</code></p></li>
sysroot/toolchain-path:</p>
<pre><code>sh ./configure \
--openjdk-target=aarch64-linux-gnu \
--with-sysroot=~/sysroot-arm64
make images
ls build/linux-aarch64-server-release/</code></pre></li>
</ul>
<p>The build does not create new files in that chroot, so it can be
reused for multiple builds without additional cleanup.</p>
Expand Down Expand Up @@ -1566,12 +1585,27 @@ <h3 id="building-for-risc-v">Building for RISC-V</h3>
placeholder <code>&lt;toolchain-installed-path&gt;</code> shown below is
the path where you want to install the toolchain.</p>
<ul>
<li><p>Install the RISC-V GNU compiler toolchain:
<code>git clone --recursive https://github.com/riscv-collab/riscv-gnu-toolchain cd riscv-gnu-toolchain ./configure --prefix=&lt;toolchain-installed-path&gt; make linux export PATH=&lt;toolchain-installed-path&gt;/bin:$PATH</code></p></li>
<li><p>Cross-compile all the required libraries:
<code># An example for libffi git clone https://github.com/libffi/libffi cd libffi ./configure --host=riscv64-unknown-linux-gnu --prefix=&lt;toolchain-installed-path&gt;/sysroot/usr make make install</code></p></li>
<li><p>Configure and build OpenJDK:
<code>bash configure \ --with-boot-jdk=$BOOT_JDK \ --openjdk-target=riscv64-linux-gnu \ --with-sysroot=&lt;toolchain-installed-path&gt;/sysroot \ --with-toolchain-path=&lt;toolchain-installed-path&gt;/bin \ --with-extra-path=&lt;toolchain-installed-path&gt;/bin make images</code></p></li>
<li><p>Install the RISC-V GNU compiler toolchain:</p>
<pre><code>git clone --recursive https://github.com/riscv-collab/riscv-gnu-toolchain
cd riscv-gnu-toolchain
./configure --prefix=&lt;toolchain-installed-path&gt;
make linux
export PATH=&lt;toolchain-installed-path&gt;/bin:$PATH</code></pre></li>
<li><p>Cross-compile all the required libraries:</p>
<pre><code># An example for libffi
git clone https://github.com/libffi/libffi
cd libffi
./configure --host=riscv64-unknown-linux-gnu --prefix=&lt;toolchain-installed-path&gt;/sysroot/usr
make
make install</code></pre></li>
<li><p>Configure and build OpenJDK:</p>
<pre><code>bash configure \
--with-boot-jdk=$BOOT_JDK \
--openjdk-target=riscv64-linux-gnu \
--with-sysroot=&lt;toolchain-installed-path&gt;/sysroot \
--with-toolchain-path=&lt;toolchain-installed-path&gt;/bin \
--with-extra-path=&lt;toolchain-installed-path&gt;/bin
make images</code></pre></li>
</ul>
<h3 id="building-for-musl">Building for musl</h3>
<p>Just like it's possible to cross-compile for a different CPU, it's
Expand Down
36 changes: 31 additions & 5 deletions doc/building.md
Original file line number Diff line number Diff line change
Expand Up @@ -626,11 +626,13 @@ automatically, it will exit and inform you about the problem.
Some command line examples:

* Create a 32-bit build for Windows with FreeType2 in `C:\freetype-i586`:

```
bash configure --with-freetype=/cygdrive/c/freetype-i586 --with-target-bits=32
```
* Create a debug build with the `server` JVM and DTrace enabled:
```
bash configure --enable-debug --with-jvm-variants=server --enable-dtrace
```
Expand Down Expand Up @@ -1100,11 +1102,12 @@ Note that alsa is needed even if you only want to build a headless JDK.
system. Download them to /tmp.
* Install the libraries into the cross-compilation toolchain. For instance:
```
cd /tools/gcc-linaro-arm-linux-gnueabihf-raspbian-2012.09-20120921_linux/arm-linux-gnueabihf/libc
dpkg-deb -x /tmp/libasound2_1.0.25-4_armhf.deb .
dpkg-deb -x /tmp/libasound2-dev_1.0.25-4_armhf.deb .
```
```
cd /tools/gcc-linaro-arm-linux-gnueabihf-raspbian-2012.09-20120921_linux/arm-linux-gnueabihf/libc
dpkg-deb -x /tmp/libasound2_1.0.25-4_armhf.deb .
dpkg-deb -x /tmp/libasound2-dev_1.0.25-4_armhf.deb .
```
* If alsa is not properly detected by `configure`, you can point it out by
`--with-alsa`.
Expand Down Expand Up @@ -1140,6 +1143,7 @@ Note that X11 is needed even if you only want to build a headless JDK.
* libxext-dev
* Install the libraries into the cross-compilation toolchain. For instance:
```
cd /tools/gcc-linaro-arm-linux-gnueabihf-raspbian-2012.09-20120921_linux/arm-linux-gnueabihf/libc/usr
mkdir X11R6
Expand Down Expand Up @@ -1173,11 +1177,13 @@ for foreign architectures with native compilation speed.
For example, cross-compiling to AArch64 from x86_64 could be done like this:
* Install cross-compiler on the *build* system:
```
apt install g++-aarch64-linux-gnu gcc-aarch64-linux-gnu
```
* Create chroot on the *build* system, configuring it for *target* system:
```
sudo debootstrap \
--arch=arm64 \
Expand All @@ -1191,12 +1197,29 @@ For example, cross-compiling to AArch64 from x86_64 could be done like this:
# the path should be `debian-ports` instead of `debian`.
```
* To create a Ubuntu-based chroot:
```
sudo debootstrap \
--arch=arm64 \
--verbose \
--components=main,universe \
--include=fakeroot,symlinks,build-essential,libx11-dev,libxext-dev,libxrender-dev,libxrandr-dev,libxtst-dev,libxt-dev,libcups2-dev,libfontconfig1-dev,libasound2-dev,libfreetype6-dev,libpng-dev,libffi-dev \
--resolve-deps \
jammy \
~/sysroot-arm64 \
http://ports.ubuntu.com/ubuntu-ports/
# symlinks is in the universe repository
```
* Make sure the symlinks inside the newly created chroot point to proper locations:
```
sudo chroot ~/sysroot-arm64 symlinks -cr .
```
* Configure and build with newly created chroot as sysroot/toolchain-path:
```
sh ./configure \
--openjdk-target=aarch64-linux-gnu \
Expand Down Expand Up @@ -1255,6 +1278,7 @@ complicate the building process. The placeholder `<toolchain-installed-path>`
shown below is the path where you want to install the toolchain.
* Install the RISC-V GNU compiler toolchain:
```
git clone --recursive https://github.com/riscv-collab/riscv-gnu-toolchain
cd riscv-gnu-toolchain
Expand All @@ -1264,6 +1288,7 @@ shown below is the path where you want to install the toolchain.
```
* Cross-compile all the required libraries:
```
# An example for libffi
git clone https://github.com/libffi/libffi
Expand All @@ -1274,6 +1299,7 @@ shown below is the path where you want to install the toolchain.
```
* Configure and build OpenJDK:
```
bash configure \
--with-boot-jdk=$BOOT_JDK \
Expand Down
7 changes: 7 additions & 0 deletions make/RunTestsPrebuilt.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ ifeq ($(UNAME_OS), CYGWIN)
OPENJDK_TARGET_OS := windows
OPENJDK_TARGET_OS_TYPE := windows
OPENJDK_TARGET_OS_ENV := windows.cygwin
else ifeq ($(UNAME_OS), MINGW64)
OPENJDK_TARGET_OS := windows
OPENJDK_TARGET_OS_TYPE := windows
OPENJDK_TARGET_OS_ENV := windows.msys2
else
OPENJDK_TARGET_OS_TYPE:=unix
ifeq ($(UNAME_OS), Linux)
Expand All @@ -170,6 +174,9 @@ else
OPENJDK_TARGET_OS_ENV := $(OPENJDK_TARGET_OS)
endif

# Sanity check env detection
$(info Detected target OS, type and env: [$(OPENJDK_TARGET_OS)] [$(OPENJDK_TARGET_OS_TYPE)] [$(OPENJDK_TARGET_OS_ENV)])

# Assume little endian unless otherwise specified
OPENJDK_TARGET_CPU_ENDIAN := little

Expand Down
8 changes: 8 additions & 0 deletions src/hotspot/os_cpu/bsd_x86/atomic_bsd_x86.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,14 @@ inline T Atomic::PlatformCmpxchg<8>::operator()(T volatile* dest,
return cmpxchg_using_helper<int64_t>(_Atomic_cmpxchg_long, dest, compare_value, exchange_value);
}

// No direct support for 8-byte xchg; emulate using cmpxchg.
template<>
struct Atomic::PlatformXchg<8> : Atomic::XchgUsingCmpxchg<8> {};

// No direct support for 8-byte add; emulate using cmpxchg.
template<>
struct Atomic::PlatformAdd<8> : Atomic::AddUsingCmpxchg<8> {};

template<>
template<typename T>
inline T Atomic::PlatformLoad<8>::operator()(T const volatile* src) const {
Expand Down
7 changes: 7 additions & 0 deletions src/hotspot/os_cpu/linux_arm/atomic_linux_arm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,13 @@ inline T Atomic::PlatformXchg<4>::operator()(T volatile* dest,
return xchg_using_helper<int32_t>(ARMAtomicFuncs::_xchg_func, dest, exchange_value);
}

// No direct support for 8-byte xchg; emulate using cmpxchg.
template<>
struct Atomic::PlatformXchg<8> : Atomic::XchgUsingCmpxchg<8> {};

// No direct support for 8-byte add; emulate using cmpxchg.
template<>
struct Atomic::PlatformAdd<8> : Atomic::AddUsingCmpxchg<8> {};

// The memory_order parameter is ignored - we always provide the strongest/most-conservative ordering

Expand Down
8 changes: 8 additions & 0 deletions src/hotspot/os_cpu/linux_x86/atomic_linux_x86.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,14 @@ inline T Atomic::PlatformCmpxchg<8>::operator()(T volatile* dest,
return cmpxchg_using_helper<int64_t>(_Atomic_cmpxchg_long, dest, compare_value, exchange_value);
}

// No direct support for 8-byte xchg; emulate using cmpxchg.
template<>
struct Atomic::PlatformXchg<8> : Atomic::XchgUsingCmpxchg<8> {};

// No direct support for 8-byte add; emulate using cmpxchg.
template<>
struct Atomic::PlatformAdd<8> : Atomic::AddUsingCmpxchg<8> {};

template<>
template<typename T>
inline T Atomic::PlatformLoad<8>::operator()(T const volatile* src) const {
Expand Down
12 changes: 6 additions & 6 deletions src/hotspot/share/gc/g1/g1HeapTransition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,11 @@ void G1HeapTransition::print() {
usage = blk._usage;
assert(usage._eden_region_count == 0, "Expected no eden regions, but got " SIZE_FORMAT, usage._eden_region_count);
assert(usage._survivor_region_count == after._survivor_length, "Expected survivors to be " SIZE_FORMAT " but was " SIZE_FORMAT,
after._survivor_length, usage._survivor_region_count);
after._survivor_length, usage._survivor_region_count);
assert(usage._old_region_count == after._old_length, "Expected old to be " SIZE_FORMAT " but was " SIZE_FORMAT,
after._old_length, usage._old_region_count);
after._old_length, usage._old_region_count);
assert(usage._humongous_region_count == after._humongous_length, "Expected humongous to be " SIZE_FORMAT " but was " SIZE_FORMAT,
after._humongous_length, usage._humongous_region_count);
after._humongous_length, usage._humongous_region_count);
}

log_regions("Eden", _before._eden_length, after._eden_length, eden_capacity_length_after_gc,
Expand All @@ -157,17 +157,17 @@ void G1HeapTransition::print() {
log_regions("Survivor", _before._survivor_length, after._survivor_length, survivor_capacity_length_before_gc,
_before._survivor_length_per_node, after._survivor_length_per_node);
log_trace(gc, heap)(" Used: " SIZE_FORMAT "K, Waste: " SIZE_FORMAT "K",
usage._survivor_used / K, ((after._survivor_length * HeapRegion::GrainBytes) - usage._survivor_used) / K);
usage._survivor_used / K, ((after._survivor_length * HeapRegion::GrainBytes) - usage._survivor_used) / K);

log_info(gc, heap)("Old regions: " SIZE_FORMAT "->" SIZE_FORMAT,
_before._old_length, after._old_length);
log_trace(gc, heap)(" Used: " SIZE_FORMAT "K, Waste: " SIZE_FORMAT "K",
usage._old_used / K, ((after._old_length * HeapRegion::GrainBytes) - usage._old_used) / K);
usage._old_used / K, ((after._old_length * HeapRegion::GrainBytes) - usage._old_used) / K);

log_info(gc, heap)("Humongous regions: " SIZE_FORMAT "->" SIZE_FORMAT,
_before._humongous_length, after._humongous_length);
log_trace(gc, heap)(" Used: " SIZE_FORMAT "K, Waste: " SIZE_FORMAT "K",
usage._humongous_used / K, ((after._humongous_length * HeapRegion::GrainBytes) - usage._humongous_used) / K);
usage._humongous_used / K, ((after._humongous_length * HeapRegion::GrainBytes) - usage._humongous_used) / K);

MetaspaceUtils::print_metaspace_change(_before._meta_sizes);
}
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/g1/g1Policy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1099,7 +1099,7 @@ double G1Policy::predict_eden_copy_time_ms(uint count, size_t* bytes_to_copy) co
if (count == 0) {
return 0.0;
}
size_t const expected_bytes = _eden_surv_rate_group->accum_surv_rate_pred(count) * HeapRegion::GrainBytes;
size_t const expected_bytes = _eden_surv_rate_group->accum_surv_rate_pred(count - 1) * HeapRegion::GrainBytes;
if (bytes_to_copy != nullptr) {
*bytes_to_copy = expected_bytes;
}
Expand Down
Loading

0 comments on commit 7a1b294

Please sign in to comment.