Skip to content

Commit 63ce96e

Browse files
author
Datadog Syncup Service
committed
Merge branch 'upstream-master'
2 parents 8f39f42 + 25e8929 commit 63ce96e

File tree

51 files changed

+908
-136
lines changed

Some content is hidden

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

51 files changed

+908
-136
lines changed

make/jdk/src/classes/build/tools/tzdb/TzdbZoneRulesCompiler.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2012, 2024, 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
@@ -273,16 +273,16 @@ private void outputFile(Path dstFile, String version,
273273
// link version-region-rules
274274
out.writeShort(builtZones.size());
275275
for (Map.Entry<String, ZoneRules> entry : builtZones.entrySet()) {
276-
int regionIndex = Arrays.binarySearch(regionArray, entry.getKey());
276+
int regionIndex = findRegionIndex(regionArray, entry.getKey());
277277
int rulesIndex = rulesList.indexOf(entry.getValue());
278278
out.writeShort(regionIndex);
279279
out.writeShort(rulesIndex);
280280
}
281281
// alias-region
282282
out.writeShort(links.size());
283283
for (Map.Entry<String, String> entry : links.entrySet()) {
284-
int aliasIndex = Arrays.binarySearch(regionArray, entry.getKey());
285-
int regionIndex = Arrays.binarySearch(regionArray, entry.getValue());
284+
int aliasIndex = findRegionIndex(regionArray, entry.getKey());
285+
int regionIndex = findRegionIndex(regionArray, entry.getValue());
286286
out.writeShort(aliasIndex);
287287
out.writeShort(regionIndex);
288288
}
@@ -294,6 +294,14 @@ private void outputFile(Path dstFile, String version,
294294
}
295295
}
296296

297+
private static int findRegionIndex(String[] regionArray, String region) {
298+
int index = Arrays.binarySearch(regionArray, region);
299+
if (index < 0) {
300+
throw new IllegalArgumentException("Unknown region: " + region);
301+
}
302+
return index;
303+
}
304+
297305
/** Whether to output verbose messages. */
298306
private boolean verbose;
299307

src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2234,7 +2234,7 @@ void SharedRuntime::generate_deopt_blob() {
22342234

22352235
int reexecute_offset = __ pc() - start;
22362236
#if INCLUDE_JVMCI && !defined(COMPILER1)
2237-
if (EnableJVMCI && UseJVMCICompiler) {
2237+
if (UseJVMCICompiler) {
22382238
// JVMCI does not use this kind of deoptimization
22392239
__ should_not_reach_here();
22402240
}

src/hotspot/cpu/ppc/ppc.ad

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6598,7 +6598,7 @@ instruct encodeP_not_null_Ex(iRegNdst dst, iRegPsrc src) %{
65986598
instruct encodeP_not_null_base_null(iRegNdst dst, iRegPsrc src) %{
65996599
match(Set dst (EncodeP src));
66006600
predicate(CompressedOops::shift() != 0 &&
6601-
CompressedOops::base() ==0);
6601+
CompressedOops::base() == nullptr);
66026602

66036603
format %{ "SRDI $dst, $src, #3 \t// encodeP, $src != nullptr" %}
66046604
size(4);
@@ -6695,7 +6695,7 @@ instruct decodeN_Ex(iRegPdst dst, iRegNsrc src, flagsReg crx) %{
66956695
predicate((n->bottom_type()->is_oopptr()->ptr() != TypePtr::NotNull &&
66966696
n->bottom_type()->is_oopptr()->ptr() != TypePtr::Constant) &&
66976697
CompressedOops::shift() != 0 &&
6698-
CompressedOops::base() != 0);
6698+
CompressedOops::base() != nullptr);
66996699
ins_cost(4 * DEFAULT_COST); // Should be more expensive than decodeN_Disjoint_isel_Ex.
67006700
effect(TEMP crx);
67016701

@@ -6707,7 +6707,7 @@ instruct decodeN_Ex(iRegPdst dst, iRegNsrc src, flagsReg crx) %{
67076707
instruct decodeN_nullBase(iRegPdst dst, iRegNsrc src) %{
67086708
match(Set dst (DecodeN src));
67096709
predicate(CompressedOops::shift() != 0 &&
6710-
CompressedOops::base() == 0);
6710+
CompressedOops::base() == nullptr);
67116711

67126712
format %{ "SLDI $dst, $src, #3 \t// DecodeN (zerobased)" %}
67136713
size(4);
@@ -6825,7 +6825,7 @@ instruct decodeN_notNull_addBase_Ex(iRegPdst dst, iRegNsrc src) %{
68256825
predicate((n->bottom_type()->is_oopptr()->ptr() == TypePtr::NotNull ||
68266826
n->bottom_type()->is_oopptr()->ptr() == TypePtr::Constant) &&
68276827
CompressedOops::shift() != 0 &&
6828-
CompressedOops::base() != 0);
6828+
CompressedOops::base() != nullptr);
68296829
ins_cost(2 * DEFAULT_COST);
68306830

68316831
format %{ "DecodeN $dst, $src \t// $src != nullptr, postalloc expanded" %}

src/hotspot/cpu/riscv/sharedRuntime_riscv.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2110,7 +2110,7 @@ void SharedRuntime::generate_deopt_blob() {
21102110

21112111
int reexecute_offset = __ pc() - start;
21122112
#if INCLUDE_JVMCI && !defined(COMPILER1)
2113-
if (EnableJVMCI && UseJVMCICompiler) {
2113+
if (UseJVMCICompiler) {
21142114
// JVMCI does not use this kind of deoptimization
21152115
__ should_not_reach_here();
21162116
}

src/hotspot/cpu/s390/s390.ad

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4628,7 +4628,7 @@ instruct encodeP(iRegN dst, iRegP src, flagsReg cr) %{
46284628
match(Set dst (EncodeP src));
46294629
effect(KILL cr);
46304630
predicate((n->bottom_type()->make_ptr()->ptr() != TypePtr::NotNull) &&
4631-
(CompressedOops::base() == 0 ||
4631+
(CompressedOops::base() == nullptr ||
46324632
CompressedOops::base_disjoint() ||
46334633
!ExpandLoadingBaseEncode));
46344634
ins_cost(MEMORY_REF_COST+3 * DEFAULT_COST);
@@ -4651,7 +4651,7 @@ instruct encodeP_NN(iRegN dst, iRegP src, flagsReg cr) %{
46514651
match(Set dst (EncodeP src));
46524652
effect(KILL cr);
46534653
predicate((n->bottom_type()->make_ptr()->ptr() == TypePtr::NotNull) &&
4654-
(CompressedOops::base() == 0 ||
4654+
(CompressedOops::base() == nullptr ||
46554655
CompressedOops::base_disjoint() ||
46564656
!ExpandLoadingBaseEncode_NN));
46574657
ins_cost(MEMORY_REF_COST+3 * DEFAULT_COST);

src/hotspot/cpu/x86/sharedRuntime_x86_64.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2674,7 +2674,7 @@ void SharedRuntime::generate_deopt_blob() {
26742674

26752675
int reexecute_offset = __ pc() - start;
26762676
#if INCLUDE_JVMCI && !defined(COMPILER1)
2677-
if (EnableJVMCI && UseJVMCICompiler) {
2677+
if (UseJVMCICompiler) {
26782678
// JVMCI does not use this kind of deoptimization
26792679
__ should_not_reach_here();
26802680
}

src/hotspot/share/cds/classListParser.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,9 @@ InstanceKlass* ClassListParser::load_class_from_source(Symbol* class_name, TRAPS
508508
THROW_NULL(vmSymbols::java_lang_ClassNotFoundException());
509509
}
510510

511-
InstanceKlass* k = UnregisteredClasses::load_class(class_name, _source, CHECK_NULL);
511+
ResourceMark rm;
512+
char * source_path = os::strdup_check_oom(ClassLoader::uri_to_path(_source));
513+
InstanceKlass* k = UnregisteredClasses::load_class(class_name, source_path, CHECK_NULL);
512514
if (k->local_interfaces()->length() != _interfaces->length()) {
513515
print_specified_interfaces();
514516
print_actual_interfaces(k);

src/hotspot/share/cds/classListWriter.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ void ClassListWriter::write_to_stream(const InstanceKlass* k, outputStream* stre
174174
}
175175
}
176176

177+
// NB: the string following "source: " is not really a proper file name, but rather
178+
// a truncated URI referring to a file. It must be decoded after reading.
177179
#ifdef _WINDOWS
178180
// "file:/C:/dir/foo.jar" -> "C:/dir/foo.jar"
179181
stream->print(" source: %s", cfs->source() + 6);

src/hotspot/share/cds/filemap.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ int FileMapInfo::get_module_shared_path_index(Symbol* location) {
581581

582582
// skip_uri_protocol was also called during dump time -- see ClassLoaderExt::process_module_table()
583583
ResourceMark rm;
584-
const char* file = ClassLoader::skip_uri_protocol(location->as_C_string());
584+
const char* file = ClassLoader::uri_to_path(location->as_C_string());
585585
for (int i = ClassLoaderExt::app_module_paths_start_index(); i < get_number_of_shared_paths(); i++) {
586586
SharedClassPathEntry* ent = shared_path(i);
587587
if (!ent->is_non_existent()) {

src/hotspot/share/classfile/classLoader.cpp

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@
8181
#include "utilities/ostream.hpp"
8282
#include "utilities/utf8.hpp"
8383

84+
#include <stdlib.h>
85+
#include <ctype.h>
86+
8487
// Entry point in java.dll for path canonicalization
8588

8689
typedef int (*canonicalize_fn_t)(const char *orig, char *out, int len);
@@ -1209,7 +1212,7 @@ InstanceKlass* ClassLoader::load_class(Symbol* name, PackageEntry* pkg_entry, bo
12091212
}
12101213

12111214
#if INCLUDE_CDS
1212-
char* ClassLoader::skip_uri_protocol(char* source) {
1215+
static const char* skip_uri_protocol(const char* source) {
12131216
if (strncmp(source, "file:", 5) == 0) {
12141217
// file: protocol path could start with file:/ or file:///
12151218
// locate the char after all the forward slashes
@@ -1228,6 +1231,47 @@ char* ClassLoader::skip_uri_protocol(char* source) {
12281231
return source;
12291232
}
12301233

1234+
static char decode_percent_encoded(const char *str, size_t& index) {
1235+
if (str[index] == '%'
1236+
&& isxdigit(str[index + 1])
1237+
&& isxdigit(str[index + 2])) {
1238+
char hex[3];
1239+
hex[0] = str[index + 1];
1240+
hex[1] = str[index + 2];
1241+
hex[2] = '\0';
1242+
index += 2;
1243+
return (char) strtol(hex, NULL, 16);
1244+
}
1245+
return str[index];
1246+
}
1247+
1248+
char* ClassLoader::uri_to_path(const char* uri) {
1249+
const size_t len = strlen(uri) + 1;
1250+
char* path = NEW_RESOURCE_ARRAY(char, len);
1251+
1252+
uri = skip_uri_protocol(uri);
1253+
1254+
if (strncmp(uri, "//", 2) == 0) {
1255+
// Skip the empty "authority" part
1256+
uri += 2;
1257+
}
1258+
1259+
#ifdef _WINDOWS
1260+
if (uri[0] == '/') {
1261+
// Absolute path name on Windows does not begin with a slash
1262+
uri += 1;
1263+
}
1264+
#endif
1265+
1266+
size_t path_index = 0;
1267+
for (size_t i = 0; i < strlen(uri); ++i) {
1268+
char decoded = decode_percent_encoded(uri, i);
1269+
path[path_index++] = decoded;
1270+
}
1271+
path[path_index] = '\0';
1272+
return path;
1273+
}
1274+
12311275
// Record the shared classpath index and loader type for classes loaded
12321276
// by the builtin loaders at dump time.
12331277
void ClassLoader::record_result(JavaThread* current, InstanceKlass* ik,
@@ -1261,7 +1305,7 @@ void ClassLoader::record_result(JavaThread* current, InstanceKlass* ik,
12611305
// Save the path from the file: protocol or the module name from the jrt: protocol
12621306
// if no protocol prefix is found, path is the same as stream->source(). This path
12631307
// must be valid since the class has been successfully parsed.
1264-
char* path = skip_uri_protocol(src);
1308+
const char* path = ClassLoader::uri_to_path(src);
12651309
assert(path != nullptr, "sanity");
12661310
for (int i = 0; i < FileMapInfo::get_number_of_shared_paths(); i++) {
12671311
SharedClassPathEntry* ent = FileMapInfo::shared_path(i);

0 commit comments

Comments
 (0)