Skip to content

Commit 600ee96

Browse files
committed
Merge
2 parents 69a5579 + 3b374c0 commit 600ee96

File tree

818 files changed

+9276
-6081
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

818 files changed

+9276
-6081
lines changed

doc/hotspot-style.html

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ <h1 class="title">HotSpot Coding Style</h1>
7272
<li><a href="#expression-sfinae" id="toc-expression-sfinae">Expression
7373
SFINAE</a></li>
7474
<li><a href="#enum" id="toc-enum">enum</a></li>
75+
<li><a href="#alignas" id="toc-alignas">alignas</a></li>
7576
<li><a href="#thread_local" id="toc-thread_local">thread_local</a></li>
7677
<li><a href="#nullptr" id="toc-nullptr">nullptr</a></li>
7778
<li><a href="#atomic" id="toc-atomic">&lt;atomic&gt;</a></li>
@@ -598,7 +599,7 @@ <h3 id="c-standard-library">C++ Standard Library</h3>
598599
<code>std::numeric_limits</code>.</li>
599600
<li><code>#include &lt;type_traits&gt;</code>.</li>
600601
<li><code>#include &lt;cstddef&gt;</code> to use
601-
<code>std::nullptr_t</code>.</li>
602+
<code>std::nullptr_t</code> and <code>std::max_align_t</code>.</li>
602603
</ul>
603604
<p>TODO: Rather than directly #including (permitted) Standard Library
604605
headers, use a convention of #including wrapper headers (in some
@@ -670,6 +671,53 @@ <h3 id="enum">enum</h3>
670671
constant members. Compilers having such bugs are no longer supported.
671672
Except where an enum is semantically appropriate, new code should use
672673
integral constants.</p>
674+
<h3 id="alignas">alignas</h3>
675+
<p><em>Alignment-specifiers</em> (<code>alignas</code> <a
676+
href="https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2341.pdf">n2341</a>)
677+
are permitted, with restrictions.</p>
678+
<p><em>Alignment-specifiers</em> are permitted when the requested
679+
alignment is a <em>fundamental alignment</em> (not greater than
680+
<code>alignof(std::max_align_t)</code> <a
681+
href="https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4296.pdf">C++14
682+
3.11/2</a>).</p>
683+
<p><em>Alignment-specifiers</em> with an <em>extended alignment</em>
684+
(greater than <code>alignof(std::max_align_t)</code> <a
685+
href="https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4296.pdf">C++14
686+
3.11/3</a>) may only be used to align variables with static or automatic
687+
storage duration (<a
688+
href="https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4296.pdf">C++14
689+
3.7.1, 3.7.3</a>). As a consequence, <em>over-aligned types</em> are
690+
forbidden; this may change if HotSpot updates to using C++17 or later
691+
(<a
692+
href="https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0035r4.html">p0035r4</a>).</p>
693+
<p>Large <em>extended alignments</em> should be avoided, particularly
694+
for stack allocated objects. What is a large value may depend on the
695+
platform and configuration. There may also be hard limits for some
696+
platforms.</p>
697+
<p>An <em>alignment-specifier</em> must always be applied to a
698+
definition (<a
699+
href="https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4296.pdf">C++14
700+
10.6.2/6</a>). (C++ allows an <em>alignment-specifier</em> to optionally
701+
also be applied to a declaration, so long as the definition has
702+
equivalent alignment. There isn't any known benefit from duplicating the
703+
alignment in a non-definition declaration, so such duplication should be
704+
avoided in HotSpot code.)</p>
705+
<p>Enumerations are forbidden from having <em>alignment-specifiers</em>.
706+
Aligned enumerations were originally permitted but insufficiently
707+
specified, and were later (C++20) removed (<a
708+
href="https://cplusplus.github.io/CWG/issues/2354.html">CWG 2354</a>).
709+
Permitting such usage in HotSpot now would just cause problems in the
710+
future.</p>
711+
<p><em>Alignment-specifiers</em> are forbidden in <code>typedef</code>
712+
and <em>alias-declarations</em>. This may work or may have worked in
713+
some versions of some compilers, but was later (C++14) explicitly
714+
disallowed (<a
715+
href="https://cplusplus.github.io/CWG/issues/1437.html">CWG
716+
1437</a>).</p>
717+
<p>The HotSpot macro <code>ATTRIBUTE_ALIGNED</code> provides similar
718+
capabilities for platforms that define it. This macro predates the use
719+
by HotSpot of C++ versions providing <code>alignas</code>. New code
720+
should use <code>alignas</code>.</p>
673721
<h3 id="thread_local">thread_local</h3>
674722
<p>Avoid use of <code>thread_local</code> (<a
675723
href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2659.htm">n2659</a>);

doc/hotspot-style.md

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ There are a few exceptions to this rule.
573573
* `#include <new>` to use placement `new`, `std::nothrow`, and `std::nothrow_t`.
574574
* `#include <limits>` to use `std::numeric_limits`.
575575
* `#include <type_traits>`.
576-
* `#include <cstddef>` to use `std::nullptr_t`.
576+
* `#include <cstddef>` to use `std::nullptr_t` and `std::max_align_t`.
577577

578578
TODO: Rather than directly \#including (permitted) Standard Library
579579
headers, use a convention of \#including wrapper headers (in some
@@ -651,6 +651,51 @@ constant members. Compilers having such bugs are no longer supported.
651651
Except where an enum is semantically appropriate, new code should use
652652
integral constants.
653653

654+
### alignas
655+
656+
_Alignment-specifiers_ (`alignas`
657+
[n2341](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2341.pdf))
658+
are permitted, with restrictions.
659+
660+
_Alignment-specifiers_ are permitted when the requested alignment is a
661+
_fundamental alignment_ (not greater than `alignof(std::max_align_t)`
662+
[C++14 3.11/2](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4296.pdf)).
663+
664+
_Alignment-specifiers_ with an _extended alignment_ (greater than
665+
`alignof(std::max_align_t)`
666+
[C++14 3.11/3](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4296.pdf))
667+
may only be used to align variables with static or automatic storage duration
668+
([C++14 3.7.1, 3.7.3](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4296.pdf)).
669+
As a consequence, _over-aligned types_ are forbidden; this may change if
670+
HotSpot updates to using C++17 or later
671+
([p0035r4](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0035r4.html)).
672+
673+
Large _extended alignments_ should be avoided, particularly for stack
674+
allocated objects. What is a large value may depend on the platform and
675+
configuration. There may also be hard limits for some platforms.
676+
677+
An _alignment-specifier_ must always be applied to a definition
678+
([C++14 10.6.2/6](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4296.pdf)).
679+
(C++ allows an _alignment-specifier_ to optionally also be applied to a
680+
declaration, so long as the definition has equivalent alignment. There isn't
681+
any known benefit from duplicating the alignment in a non-definition
682+
declaration, so such duplication should be avoided in HotSpot code.)
683+
684+
Enumerations are forbidden from having _alignment-specifiers_. Aligned
685+
enumerations were originally permitted but insufficiently specified, and were
686+
later (C++20) removed
687+
([CWG 2354](https://cplusplus.github.io/CWG/issues/2354.html)).
688+
Permitting such usage in HotSpot now would just cause problems in the future.
689+
690+
_Alignment-specifiers_ are forbidden in `typedef` and _alias-declarations_.
691+
This may work or may have worked in some versions of some compilers, but was
692+
later (C++14) explicitly disallowed
693+
([CWG 1437](https://cplusplus.github.io/CWG/issues/1437.html)).
694+
695+
The HotSpot macro `ATTRIBUTE_ALIGNED` provides similar capabilities for
696+
platforms that define it. This macro predates the use by HotSpot of C++
697+
versions providing `alignas`. New code should use `alignas`.
698+
654699
### thread_local
655700

656701
Avoid use of `thread_local`

make/Docs.gmk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ $(foreach n, 0 1 2, \
619619
$(eval specs_bottom_rel_path := $(specs_bottom_rel_path)../) \
620620
)
621621

622-
SPECS_TOP := $(if $(filter true, $(IS_DRAFT)), <header class="draft-header">$(DRAFT_TEXT)</header>)
622+
SPECS_TOP := $(if $(filter true, $(IS_DRAFT)), <header class="draft-header" role="banner">$(DRAFT_TEXT)</header>)
623623

624624
# For all html files in $module/share/specs directories, copy and add the
625625
# copyright footer.

make/RunTests.gmk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ ExpandJtregPath = \
352352
# with test id: dir/Test.java#selection -> Test.java#selection -> .java#selection -> #selection
353353
# without: dir/Test.java -> Test.java -> .java -> <<empty string>>
354354
TestID = \
355-
$(subst .java,,$(suffix $(notdir $1)))
355+
$(subst .sh,,$(subst .html,,$(subst .java,,$(suffix $(notdir $1)))))
356356

357357
# The test id starting with a hash (#testid) will be stripped by all
358358
# evals in ParseJtregTestSelectionInner and will be reinserted by calling

make/autoconf/build-aux/config.guess

Lines changed: 34 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,40 @@
2929
# and fix the broken property, if needed.
3030

3131
DIR=`dirname $0`
32-
OUT=`. $DIR/autoconf-config.guess`
32+
OUT=`. $DIR/autoconf-config.guess 2> /dev/null`
33+
34+
# Handle some cases that autoconf-config.guess is not capable of
35+
if [ "x$OUT" = x ]; then
36+
if [ `uname -s` = Linux ]; then
37+
# Test and fix little endian MIPS.
38+
if [ `uname -m` = mipsel ]; then
39+
OUT=mipsel-unknown-linux-gnu
40+
elif [ `uname -m` = mips64el ]; then
41+
OUT=mips64el-unknown-linux-gnu
42+
# Test and fix little endian PowerPC64.
43+
elif [ `uname -m` = ppc64le ]; then
44+
OUT=powerpc64le-unknown-linux-gnu
45+
# Test and fix LoongArch64.
46+
elif [ `uname -m` = loongarch64 ]; then
47+
OUT=loongarch64-unknown-linux-gnu
48+
# Test and fix RISC-V.
49+
elif [ `uname -m` = riscv64 ]; then
50+
OUT=riscv64-unknown-linux-gnu
51+
fi
52+
# Test and fix cygwin machine arch .x86_64
53+
elif [[ `uname -s` = CYGWIN* ]]; then
54+
if [ `uname -m` = ".x86_64" ]; then
55+
OUT=x86_64-unknown-cygwin
56+
fi
57+
fi
58+
59+
if [ "x$OUT" = x ]; then
60+
# Run autoconf-config.guess again to get the error message.
61+
. $DIR/autoconf-config.guess > /dev/null
62+
else
63+
printf "guessed by custom config.guess... " >&2
64+
fi
65+
fi
3366

3467
# Detect C library.
3568
# Use '-gnu' suffix on systems that use glibc.
@@ -81,45 +114,6 @@ if test $? = 0; then
81114
OUT=powerpc$KERNEL_BITMODE`echo $OUT | sed -e 's/[^-]*//'`
82115
fi
83116

84-
# Test and fix little endian PowerPC64.
85-
# TODO: should be handled by autoconf-config.guess.
86-
if [ "x$OUT" = x ]; then
87-
if [ `uname -m` = ppc64le ]; then
88-
if [ `uname -s` = Linux ]; then
89-
OUT=powerpc64le-unknown-linux-gnu
90-
fi
91-
fi
92-
fi
93-
94-
# Test and fix little endian MIPS.
95-
if [ "x$OUT" = x ]; then
96-
if [ `uname -s` = Linux ]; then
97-
if [ `uname -m` = mipsel ]; then
98-
OUT=mipsel-unknown-linux-gnu
99-
elif [ `uname -m` = mips64el ]; then
100-
OUT=mips64el-unknown-linux-gnu
101-
fi
102-
fi
103-
fi
104-
105-
# Test and fix LoongArch64.
106-
if [ "x$OUT" = x ]; then
107-
if [ `uname -s` = Linux ]; then
108-
if [ `uname -m` = loongarch64 ]; then
109-
OUT=loongarch64-unknown-linux-gnu
110-
fi
111-
fi
112-
fi
113-
114-
# Test and fix RISC-V.
115-
if [ "x$OUT" = x ]; then
116-
if [ `uname -s` = Linux ]; then
117-
if [ `uname -m` = riscv64 ]; then
118-
OUT=riscv64-unknown-linux-gnu
119-
fi
120-
fi
121-
fi
122-
123117
# Test and fix cpu on macos-aarch64, uname -p reports arm, buildsys expects aarch64
124118
echo $OUT | grep arm-apple-darwin > /dev/null 2> /dev/null
125119
if test $? != 0; then

make/common/modules/LibCommon.gmk

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,12 @@ ifeq ($(TOOLCHAIN_TYPE), gcc)
4141
CFLAGS_JDKLIB += -fvisibility=hidden
4242
CXXFLAGS_JDKLIB += -fvisibility=hidden
4343
LDFLAGS_JDKLIB += -Wl,--exclude-libs,ALL
44-
EXPORT_ALL_SYMBOLS := -fvisibility=default
4544
else ifeq ($(TOOLCHAIN_TYPE), clang)
4645
CFLAGS_JDKLIB += -fvisibility=hidden
4746
CXXFLAGS_JDKLIB += -fvisibility=hidden
48-
EXPORT_ALL_SYMBOLS := -fvisibility=default
4947
else ifeq ($(TOOLCHAIN_TYPE), xlc)
5048
CFLAGS_JDKLIB += -qvisibility=hidden
5149
CXXFLAGS_JDKLIB += -qvisibility=hidden
52-
EXPORT_ALL_SYMBOLS := -qvisibility=default
5350
endif
5451

5552
# Put the libraries here.

make/jdk/src/classes/build/tools/cldrconverter/CLDRConverter.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ static String getLanguageCode(String id) {
633633
/**
634634
* Examine if the id includes the country (territory) code. If it does, it returns
635635
* the country code.
636-
* Otherwise, it returns null. eg. when the id is "zh_Hans_SG", it return "SG".
636+
* Otherwise, it returns null. eg. when the id is "zh_Hans_SG", it returns "SG".
637637
* It does NOT return UN M.49 code, e.g., '001', as those three digit numbers cannot
638638
* be translated into package names.
639639
*/
@@ -645,13 +645,21 @@ static String getCountryCode(String id) {
645645
/**
646646
* Examine if the id includes the region code. If it does, it returns
647647
* the region code.
648-
* Otherwise, it returns null. eg. when the id is "zh_Hans_SG", it return "SG".
648+
* Otherwise, it returns null. eg. when the id is "zh_Hans_SG", it returns "SG".
649649
* It DOES return UN M.49 code, e.g., '001', as well as ISO 3166 two letter country codes.
650650
*/
651651
static String getRegionCode(String id) {
652652
return Locale.forLanguageTag(id.replaceAll("_", "-")).getCountry();
653653
}
654654

655+
/**
656+
* Examine if the id includes the script code. If it does, it returns
657+
* the script code.
658+
*/
659+
static String getScriptCode(String id) {
660+
return Locale.forLanguageTag(id.replaceAll("_", "-")).getScript();
661+
}
662+
655663
private static class KeyComparator implements Comparator<String> {
656664
static KeyComparator INSTANCE = new KeyComparator();
657665

@@ -1020,6 +1028,7 @@ private static String toLocaleName(String tag) {
10201028
private static void setupBaseLocales(String localeList) {
10211029
Arrays.stream(localeList.split(","))
10221030
.map(Locale::forLanguageTag)
1031+
.map(l -> new Locale.Builder().setLocale(l).setScript("Latn").build())
10231032
.map(l -> Control.getControl(Control.FORMAT_DEFAULT)
10241033
.getCandidateLocales("", l))
10251034
.forEach(BASE_LOCALES::addAll);

make/jdk/src/classes/build/tools/cldrconverter/ResourceBundleGenerator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,11 +417,11 @@ public Map<Locale, String[]> parentLocales() {
417417
private static final Locale.Builder LOCALE_BUILDER = new Locale.Builder();
418418
private static boolean isBaseLocale(String localeID) {
419419
localeID = localeID.replaceAll("-", "_");
420-
// ignore script here
421420
Locale locale = LOCALE_BUILDER
422421
.clear()
423422
.setLanguage(CLDRConverter.getLanguageCode(localeID))
424423
.setRegion(CLDRConverter.getRegionCode(localeID))
424+
.setScript(CLDRConverter.getScriptCode(localeID))
425425
.build();
426426
return CLDRConverter.BASE_LOCALES.contains(locale);
427427
}

0 commit comments

Comments
 (0)