Skip to content

Commit

Permalink
Merge master 2020/11/18
Browse files Browse the repository at this point in the history
Change-Id: I256b857ca275a8806febc1b9dc5412aac6d862a7
CustomizedGitHooks: yes
  • Loading branch information
a74nh committed Nov 18, 2020
2 parents 3d68fde + f7f3447 commit 499d706
Show file tree
Hide file tree
Showing 422 changed files with 14,259 additions and 8,247 deletions.
583 changes: 578 additions & 5 deletions .github/workflows/submit.yml

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions doc/hotspot-style.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ <h1 class="title">HotSpot Coding Style</h1>
<li><a href="#thread_local">thread_local</a></li>
<li><a href="#nullptr">nullptr</a></li>
<li><a href="#atomic">&lt;atomic&gt;</a></li>
<li><a href="#uniform-initialization">Uniform Initialization</a></li>
<li><a href="#additional-permitted-features">Additional Permitted Features</a></li>
<li><a href="#excluded-features">Excluded Features</a></li>
<li><a href="#undecided-features">Undecided Features</a></li>
Expand Down Expand Up @@ -275,6 +276,17 @@ <h3 id="atomic">&lt;atomic&gt;</h3>
<p>Do not use facilities provided by the <code>&lt;atomic&gt;</code> header (<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2427.html">n2427</a>), (<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2752.htm">n2752</a>); instead, use the HotSpot <code>Atomic</code> class and related facilities.</p>
<p>Atomic operations in HotSpot code must have semantics which are consistent with those provided by the JDK's compilers for Java. There are platform-specific implementation choices that a C++ compiler might make or change that are outside the scope of the C++ Standard, and might differ from what the Java compilers implement.</p>
<p>In addition, HotSpot <code>Atomic</code> has a concept of &quot;conservative&quot; memory ordering, which may differ from (may be stronger than) sequentially consistent. There are algorithms in HotSpot that are believed to rely on that ordering.</p>
<h3 id="uniform-initialization">Uniform Initialization</h3>
<p>The use of <em>uniform initialization</em> (<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2672.htm">n2672</a>), also known as <em>brace initialization</em>, is permitted.</p>
<p>Some relevant sections from cppreference.com:</p>
<ul>
<li><a href="https://en.cppreference.com/w/cpp/language/initialization">initialization</a></li>
<li><a href="https://en.cppreference.com/w/cpp/language/value_initialization">value initialization</a></li>
<li><a href="https://en.cppreference.com/w/cpp/language/direct_initialization">direct initialization</a></li>
<li><a href="https://en.cppreference.com/w/cpp/language/list_initialization">list initialization</a></li>
<li><a href="https://en.cppreference.com/w/cpp/language/aggregate_initialization">aggregate initialization</a></li>
</ul>
<p>Although related, the use of <code>std::initializer_list</code> remains forbidden, as part of the avoidance of the C++ Standard Library in HotSpot code.</p>
<h3 id="additional-permitted-features">Additional Permitted Features</h3>
<ul>
<li><p><code>constexpr</code> (<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2235.pdf">n2235</a>) (<a href="https://isocpp.org/files/papers/N3652.html">n3652</a>)</p></li>
Expand Down
17 changes: 17 additions & 0 deletions doc/hotspot-style.md
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,23 @@ ordering, which may differ from (may be stronger than) sequentially
consistent. There are algorithms in HotSpot that are believed to rely
on that ordering.

### Uniform Initialization

The use of _uniform initialization_
([n2672](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2672.htm)),
also known as _brace initialization_, is permitted.

Some relevant sections from cppreference.com:

* [initialization](https://en.cppreference.com/w/cpp/language/initialization)
* [value initialization](https://en.cppreference.com/w/cpp/language/value_initialization)
* [direct initialization](https://en.cppreference.com/w/cpp/language/direct_initialization)
* [list initialization](https://en.cppreference.com/w/cpp/language/list_initialization)
* [aggregate initialization](https://en.cppreference.com/w/cpp/language/aggregate_initialization)

Although related, the use of `std::initializer_list` remains forbidden, as
part of the avoidance of the C++ Standard Library in HotSpot code.

### Additional Permitted Features

* `constexpr`
Expand Down
27 changes: 27 additions & 0 deletions make/conf/jib-profiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,13 @@ var getJibProfilesCommon = function (input, data) {
"--disable-jvm-feature-shenandoahgc",
versionArgs(input, common))
};
// Extra settings for release profiles
common.release_profile_base = {
configure_args: [
"--enable-reproducible-build",
"--with-source-date=current",
],
};
// Extra settings for debug profiles
common.debug_suffix = "-debug";
common.debug_profile_base = {
Expand All @@ -268,6 +275,12 @@ var getJibProfilesCommon = function (input, data) {
configure_args: ["--with-debug-level=slowdebug"],
labels: "slowdebug"
};
// Extra settings for optimized profiles
common.optimized_suffix = "-optimized";
common.optimized_profile_base = {
configure_args: ["--with-debug-level=optimized"],
labels: "optimized",
};
// Extra settings for openjdk only profiles
common.open_suffix = "-open";
common.open_profile_base = {
Expand Down Expand Up @@ -510,6 +523,13 @@ var getJibProfilesProfiles = function (input, common, data) {
profiles[debugName] = concatObjects(profiles[name],
common.slowdebug_profile_base);
});
// Generate optimized versions of all the main profiles
common.main_profile_names.forEach(function (name) {
var optName = name + common.optimized_suffix;
profiles[optName] = concatObjects(profiles[name],
common.optimized_profile_base);
profiles[optName].default_make_targets = [ "hotspot" ];
});
// Generate testmake profiles for the main profile of each build host
// platform. This profile only runs the makefile tests.
// Ant is needed to run the idea project generator test.
Expand Down Expand Up @@ -797,6 +817,13 @@ var getJibProfilesProfiles = function (input, common, data) {
});
});

// After creating all derived profiles, we can add the release profile base
// to the main profiles
common.main_profile_names.forEach(function (name) {
profiles[name] = concatObjects(profiles[name],
common.release_profile_base);
});

// Artifacts of JCov profiles
[ "linux-aarch64", "linux-x64", "macosx-x64", "windows-x64" ]
.forEach(function (name) {
Expand Down
34 changes: 21 additions & 13 deletions make/jdk/src/classes/build/tools/cldrconverter/Bundle.java
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,16 @@ Map<String, Object> getTargetMap() throws Exception {
}
}

// rules
String rule = CLDRConverter.pluralRules.get(id);
if (rule != null) {
myMap.put("PluralRules", rule);
}
rule = CLDRConverter.dayPeriodRules.get(id);
if (rule != null) {
myMap.put("DayPeriodRules", rule);
}

// Remove all duplicates
if (Objects.nonNull(parentsMap)) {
for (Iterator<String> it = myMap.keySet().iterator(); it.hasNext();) {
Expand Down Expand Up @@ -522,8 +532,6 @@ private void handleDateTimeFormatPatterns(String[] patternKeys, Map<String, Obje
if (pattern != null) {
// Perform date-time format pattern conversion which is
// applicable to both SimpleDateFormat and j.t.f.DateTimeFormatter.
// For example, character 'B' is mapped with 'a', as 'B' is not
// supported in either SimpleDateFormat or j.t.f.DateTimeFormatter
String transPattern = translateDateFormatLetters(calendarType, pattern, this::convertDateTimePatternLetter);
dateTimePatterns.add(i, transPattern);
// Additionally, perform SDF specific date-time format pattern conversion
Expand Down Expand Up @@ -653,17 +661,6 @@ private void convertDateTimePatternLetter(CalendarType calendarType, char cldrLe
// as the best approximation
appendN('y', count, sb);
break;
case 'B':
// 'B' character (day period) is not supported by
// SimpleDateFormat and j.t.f.DateTimeFormatter,
// this is a workaround in which 'B' character
// appearing in CLDR date-time pattern is replaced
// with 'a' character and hence resolved with am/pm strings.
// This workaround is based on the the fallback mechanism
// specified in LDML spec for 'B' character, when a locale
// does not have data for day period ('B')
appendN('a', count, sb);
break;
default:
appendN(cldrLetter, count, sb);
break;
Expand Down Expand Up @@ -720,6 +717,17 @@ private void convertSDFLetter(CalendarType calendarType, char cldrLetter, int co
}
break;

case 'B':
// 'B' character (day period) is not supported by SimpleDateFormat,
// this is a workaround in which 'B' character
// appearing in CLDR date-time pattern is replaced
// with 'a' character and hence resolved with am/pm strings.
// This workaround is based on the the fallback mechanism
// specified in LDML spec for 'B' character, when a locale
// does not have data for day period ('B')
appendN('a', count, sb);
break;

default:
appendN(cldrLetter, count, sb);
break;
Expand Down
77 changes: 31 additions & 46 deletions make/jdk/src/classes/build/tools/cldrconverter/CLDRConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public class CLDRConverter {
private static String TIMEZONE_SOURCE_FILE;
private static String WINZONES_SOURCE_FILE;
private static String PLURALS_SOURCE_FILE;
private static String DAYPERIODRULE_SOURCE_FILE;
static String DESTINATION_DIR = "build/gensrc";

static final String LOCALE_NAME_PREFIX = "locale.displayname.";
Expand Down Expand Up @@ -100,6 +101,7 @@ public class CLDRConverter {
static NumberingSystemsParseHandler handlerNumbering;
static MetaZonesParseHandler handlerMetaZones;
static TimeZoneParseHandler handlerTimeZone;
static DayPeriodRuleParseHandler handlerDayPeriodRule;
private static BundleGenerator bundleGenerator;

// java.base module related
Expand All @@ -116,6 +118,10 @@ public class CLDRConverter {
private static String tzDataDir;
private static final Map<String, String> canonicalTZMap = new HashMap<>();

// rules maps
static Map<String, String> pluralRules;
static Map<String, String> dayPeriodRules;

static enum DraftType {
UNCONFIRMED,
PROVISIONAL,
Expand Down Expand Up @@ -248,6 +254,7 @@ public static void main(String[] args) throws Exception {
SPPL_META_SOURCE_FILE = CLDR_BASE + "/supplemental/supplementalMetadata.xml";
WINZONES_SOURCE_FILE = CLDR_BASE + "/supplemental/windowsZones.xml";
PLURALS_SOURCE_FILE = CLDR_BASE + "/supplemental/plurals.xml";
DAYPERIODRULE_SOURCE_FILE = CLDR_BASE + "/supplemental/dayPeriods.xml";

if (BASE_LOCALES.isEmpty()) {
setupBaseLocales("en-US");
Expand All @@ -259,6 +266,10 @@ public static void main(String[] args) throws Exception {
parseSupplemental();
parseBCP47();

// rules maps
pluralRules = generateRules(handlerPlurals);
dayPeriodRules = generateRules(handlerDayPeriodRule);

List<Bundle> bundles = readBundleList();
convertBundles(bundles);

Expand All @@ -268,9 +279,6 @@ public static void main(String[] args) throws Exception {

// Generate Windows tzmappings
generateWindowsTZMappings();

// Generate Plural rules
generatePluralRules();
}
}

Expand Down Expand Up @@ -462,6 +470,10 @@ private static void parseSupplemental() throws Exception {
// Parse plurals
handlerPlurals = new PluralsParseHandler();
parseLDMLFile(new File(PLURALS_SOURCE_FILE), handlerPlurals);

// Parse day period rules
handlerDayPeriodRule = new DayPeriodRuleParseHandler();
parseLDMLFile(new File(DAYPERIODRULE_SOURCE_FILE), handlerDayPeriodRule);
}

// Parsers for data in "bcp47" directory
Expand Down Expand Up @@ -809,7 +821,9 @@ private static Map<String, Object> extractCalendarData(Map<String, Object> map,
"TimePatterns",
"DatePatterns",
"DateTimePatterns",
"DateTimePatternChars"
"DateTimePatternChars",
"PluralRules",
"DayPeriodRules",
};

private static Map<String, Object> extractFormatData(Map<String, Object> map, String id) {
Expand Down Expand Up @@ -1125,49 +1139,21 @@ public int compare(String t1, String t2) {
}

/**
* Generate ResourceBundle source file for plural rules. The generated
* class is {@code sun.text.resources.PluralRules} which has one public
* two dimensional array {@code rulesArray}. Each array element consists
* of two elements that designate the locale and the locale's plural rules
* string. The latter has the syntax from Unicode Consortium's
* <a href="http://unicode.org/reports/tr35/tr35-numbers.html#Plural_rules_syntax">
* Plural rules syntax</a>. {@code samples} and {@code "other"} are being ommited.
*
* @throws Exception
* Generates rules map for Plural rules and DayPeriod rules. The key is the locale id,
* and the value is rules, defined by the LDML spec. Each rule consists of {@code type:rule}
* notation, concatenated with a ";" as a delimiter.
* @param handler handler containing rules
* @return the map
*/
private static void generatePluralRules() throws Exception {
Files.createDirectories(Paths.get(DESTINATION_DIR, "sun", "text", "resources"));
Files.write(Paths.get(DESTINATION_DIR, "sun", "text", "resources", "PluralRules.java"),
Stream.concat(
Stream.concat(
Stream.of(
"package sun.text.resources;",
"public final class PluralRules {",
" public static final String[][] rulesArray = {"
),
pluralRulesStream().sorted()
),
Stream.of(
" };",
"}"
)
)
.collect(Collectors.toList()),
StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);
}

private static Stream<String> pluralRulesStream() {
return handlerPlurals.getData().entrySet().stream()
.filter(e -> !(e.getValue()).isEmpty())
.map(e -> {
String loc = e.getKey();
private static Map<String, String> generateRules(AbstractLDMLHandler<Map<String, String>> handler) {
return handler.getData().entrySet().stream()
.collect(Collectors.toMap(Map.Entry::getKey, e -> {
Map<String, String> rules = e.getValue();
return " {\"" + loc + "\", \"" +
rules.entrySet().stream()
.map(rule -> rule.getKey() + ":" + rule.getValue().replaceFirst("@.*", ""))
.map(String::trim)
.collect(Collectors.joining(";")) + "\"},";
});
return rules.entrySet().stream()
.map(rule -> rule.getKey() + ":" + rule.getValue().replaceFirst("@.*", ""))
.map(String::trim)
.collect(Collectors.joining(";"));
}));
}

// for debug
Expand All @@ -1188,4 +1174,3 @@ static void dumpMap(Map<String, Object> map) {
.forEach(System.out::println);
}
}

Loading

0 comments on commit 499d706

Please sign in to comment.