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 Sep 27, 2024
2 parents 8f39f42 + 25e8929 commit 63ce96e
Show file tree
Hide file tree
Showing 51 changed files with 908 additions and 136 deletions.
16 changes: 12 additions & 4 deletions make/jdk/src/classes/build/tools/tzdb/TzdbZoneRulesCompiler.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -273,16 +273,16 @@ private void outputFile(Path dstFile, String version,
// link version-region-rules
out.writeShort(builtZones.size());
for (Map.Entry<String, ZoneRules> entry : builtZones.entrySet()) {
int regionIndex = Arrays.binarySearch(regionArray, entry.getKey());
int regionIndex = findRegionIndex(regionArray, entry.getKey());
int rulesIndex = rulesList.indexOf(entry.getValue());
out.writeShort(regionIndex);
out.writeShort(rulesIndex);
}
// alias-region
out.writeShort(links.size());
for (Map.Entry<String, String> entry : links.entrySet()) {
int aliasIndex = Arrays.binarySearch(regionArray, entry.getKey());
int regionIndex = Arrays.binarySearch(regionArray, entry.getValue());
int aliasIndex = findRegionIndex(regionArray, entry.getKey());
int regionIndex = findRegionIndex(regionArray, entry.getValue());
out.writeShort(aliasIndex);
out.writeShort(regionIndex);
}
Expand All @@ -294,6 +294,14 @@ private void outputFile(Path dstFile, String version,
}
}

private static int findRegionIndex(String[] regionArray, String region) {
int index = Arrays.binarySearch(regionArray, region);
if (index < 0) {
throw new IllegalArgumentException("Unknown region: " + region);
}
return index;
}

/** Whether to output verbose messages. */
private boolean verbose;

Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2234,7 +2234,7 @@ void SharedRuntime::generate_deopt_blob() {

int reexecute_offset = __ pc() - start;
#if INCLUDE_JVMCI && !defined(COMPILER1)
if (EnableJVMCI && UseJVMCICompiler) {
if (UseJVMCICompiler) {
// JVMCI does not use this kind of deoptimization
__ should_not_reach_here();
}
Expand Down
8 changes: 4 additions & 4 deletions src/hotspot/cpu/ppc/ppc.ad
Original file line number Diff line number Diff line change
Expand Up @@ -6598,7 +6598,7 @@ instruct encodeP_not_null_Ex(iRegNdst dst, iRegPsrc src) %{
instruct encodeP_not_null_base_null(iRegNdst dst, iRegPsrc src) %{
match(Set dst (EncodeP src));
predicate(CompressedOops::shift() != 0 &&
CompressedOops::base() ==0);
CompressedOops::base() == nullptr);

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

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

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

format %{ "DecodeN $dst, $src \t// $src != nullptr, postalloc expanded" %}
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/cpu/riscv/sharedRuntime_riscv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2110,7 +2110,7 @@ void SharedRuntime::generate_deopt_blob() {

int reexecute_offset = __ pc() - start;
#if INCLUDE_JVMCI && !defined(COMPILER1)
if (EnableJVMCI && UseJVMCICompiler) {
if (UseJVMCICompiler) {
// JVMCI does not use this kind of deoptimization
__ should_not_reach_here();
}
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/cpu/s390/s390.ad
Original file line number Diff line number Diff line change
Expand Up @@ -4628,7 +4628,7 @@ instruct encodeP(iRegN dst, iRegP src, flagsReg cr) %{
match(Set dst (EncodeP src));
effect(KILL cr);
predicate((n->bottom_type()->make_ptr()->ptr() != TypePtr::NotNull) &&
(CompressedOops::base() == 0 ||
(CompressedOops::base() == nullptr ||
CompressedOops::base_disjoint() ||
!ExpandLoadingBaseEncode));
ins_cost(MEMORY_REF_COST+3 * DEFAULT_COST);
Expand All @@ -4651,7 +4651,7 @@ instruct encodeP_NN(iRegN dst, iRegP src, flagsReg cr) %{
match(Set dst (EncodeP src));
effect(KILL cr);
predicate((n->bottom_type()->make_ptr()->ptr() == TypePtr::NotNull) &&
(CompressedOops::base() == 0 ||
(CompressedOops::base() == nullptr ||
CompressedOops::base_disjoint() ||
!ExpandLoadingBaseEncode_NN));
ins_cost(MEMORY_REF_COST+3 * DEFAULT_COST);
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/cpu/x86/sharedRuntime_x86_64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2674,7 +2674,7 @@ void SharedRuntime::generate_deopt_blob() {

int reexecute_offset = __ pc() - start;
#if INCLUDE_JVMCI && !defined(COMPILER1)
if (EnableJVMCI && UseJVMCICompiler) {
if (UseJVMCICompiler) {
// JVMCI does not use this kind of deoptimization
__ should_not_reach_here();
}
Expand Down
4 changes: 3 additions & 1 deletion src/hotspot/share/cds/classListParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,9 @@ InstanceKlass* ClassListParser::load_class_from_source(Symbol* class_name, TRAPS
THROW_NULL(vmSymbols::java_lang_ClassNotFoundException());
}

InstanceKlass* k = UnregisteredClasses::load_class(class_name, _source, CHECK_NULL);
ResourceMark rm;
char * source_path = os::strdup_check_oom(ClassLoader::uri_to_path(_source));
InstanceKlass* k = UnregisteredClasses::load_class(class_name, source_path, CHECK_NULL);
if (k->local_interfaces()->length() != _interfaces->length()) {
print_specified_interfaces();
print_actual_interfaces(k);
Expand Down
2 changes: 2 additions & 0 deletions src/hotspot/share/cds/classListWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ void ClassListWriter::write_to_stream(const InstanceKlass* k, outputStream* stre
}
}

// NB: the string following "source: " is not really a proper file name, but rather
// a truncated URI referring to a file. It must be decoded after reading.
#ifdef _WINDOWS
// "file:/C:/dir/foo.jar" -> "C:/dir/foo.jar"
stream->print(" source: %s", cfs->source() + 6);
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/cds/filemap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ int FileMapInfo::get_module_shared_path_index(Symbol* location) {

// skip_uri_protocol was also called during dump time -- see ClassLoaderExt::process_module_table()
ResourceMark rm;
const char* file = ClassLoader::skip_uri_protocol(location->as_C_string());
const char* file = ClassLoader::uri_to_path(location->as_C_string());
for (int i = ClassLoaderExt::app_module_paths_start_index(); i < get_number_of_shared_paths(); i++) {
SharedClassPathEntry* ent = shared_path(i);
if (!ent->is_non_existent()) {
Expand Down
48 changes: 46 additions & 2 deletions src/hotspot/share/classfile/classLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@
#include "utilities/ostream.hpp"
#include "utilities/utf8.hpp"

#include <stdlib.h>
#include <ctype.h>

// Entry point in java.dll for path canonicalization

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

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

static char decode_percent_encoded(const char *str, size_t& index) {
if (str[index] == '%'
&& isxdigit(str[index + 1])
&& isxdigit(str[index + 2])) {
char hex[3];
hex[0] = str[index + 1];
hex[1] = str[index + 2];
hex[2] = '\0';
index += 2;
return (char) strtol(hex, NULL, 16);
}
return str[index];
}

char* ClassLoader::uri_to_path(const char* uri) {
const size_t len = strlen(uri) + 1;
char* path = NEW_RESOURCE_ARRAY(char, len);

uri = skip_uri_protocol(uri);

if (strncmp(uri, "//", 2) == 0) {
// Skip the empty "authority" part
uri += 2;
}

#ifdef _WINDOWS
if (uri[0] == '/') {
// Absolute path name on Windows does not begin with a slash
uri += 1;
}
#endif

size_t path_index = 0;
for (size_t i = 0; i < strlen(uri); ++i) {
char decoded = decode_percent_encoded(uri, i);
path[path_index++] = decoded;
}
path[path_index] = '\0';
return path;
}

// Record the shared classpath index and loader type for classes loaded
// by the builtin loaders at dump time.
void ClassLoader::record_result(JavaThread* current, InstanceKlass* ik,
Expand Down Expand Up @@ -1261,7 +1305,7 @@ void ClassLoader::record_result(JavaThread* current, InstanceKlass* ik,
// Save the path from the file: protocol or the module name from the jrt: protocol
// if no protocol prefix is found, path is the same as stream->source(). This path
// must be valid since the class has been successfully parsed.
char* path = skip_uri_protocol(src);
const char* path = ClassLoader::uri_to_path(src);
assert(path != nullptr, "sanity");
for (int i = 0; i < FileMapInfo::get_number_of_shared_paths(); i++) {
SharedClassPathEntry* ent = FileMapInfo::shared_path(i);
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/classfile/classLoader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ class ClassLoader: AllStatic {
// entries during shared classpath setup time.
static int num_module_path_entries();
static void exit_with_path_failure(const char* error, const char* message);
static char* skip_uri_protocol(char* source);
static char* uri_to_path(const char* uri);
static void record_result(JavaThread* current, InstanceKlass* ik,
const ClassFileStream* stream, bool redefined);
#endif
Expand Down
10 changes: 4 additions & 6 deletions src/hotspot/share/classfile/classLoaderExt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,10 @@ void ClassLoaderExt::process_module_table(JavaThread* current, ModuleEntryTable*
ModulePathsGatherer(JavaThread* current, GrowableArray<char*>* module_paths) :
_current(current), _module_paths(module_paths) {}
void do_module(ModuleEntry* m) {
char* path = m->location()->as_C_string();
if (strncmp(path, "file:", 5) == 0) {
path = ClassLoader::skip_uri_protocol(path);
char* path_copy = NEW_RESOURCE_ARRAY(char, strlen(path) + 1);
strcpy(path_copy, path);
_module_paths->append(path_copy);
char* uri = m->location()->as_C_string();
if (strncmp(uri, "file:", 5) == 0) {
char* path = ClassLoader::uri_to_path(uri);
_module_paths->append(path);
}
}
};
Expand Down
3 changes: 2 additions & 1 deletion src/hotspot/share/classfile/javaClasses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3052,9 +3052,10 @@ void java_lang_ClassFrameInfo::serialize_offsets(SerializeClosure* f) {

static int get_flags(const methodHandle& m) {
int flags = (jushort)( m->access_flags().as_short() & JVM_RECOGNIZED_METHOD_MODIFIERS );
if (m->is_initializer()) {
if (m->is_object_initializer()) {
flags |= java_lang_invoke_MemberName::MN_IS_CONSTRUCTOR;
} else {
// Note: Static initializers can be here. Record them as plain methods.
flags |= java_lang_invoke_MemberName::MN_IS_METHOD;
}
if (m->caller_sensitive()) {
Expand Down
20 changes: 13 additions & 7 deletions src/hotspot/share/classfile/systemDictionary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1069,7 +1069,7 @@ bool SystemDictionary::check_shared_class_super_type(InstanceKlass* klass, Insta
}

Klass *found = resolve_with_circularity_detection(klass->name(), super_type->name(),
class_loader, protection_domain, is_superclass, CHECK_0);
class_loader, protection_domain, is_superclass, CHECK_false);
if (found == super_type) {
return true;
} else {
Expand All @@ -1088,16 +1088,21 @@ bool SystemDictionary::check_shared_class_super_types(InstanceKlass* ik, Handle
// If unexpected superclass or interfaces are found, we cannot
// load <ik> from the shared archive.

if (ik->super() != nullptr &&
!check_shared_class_super_type(ik, InstanceKlass::cast(ik->super()),
class_loader, protection_domain, true, THREAD)) {
return false;
if (ik->super() != nullptr) {
bool check_super = check_shared_class_super_type(ik, InstanceKlass::cast(ik->super()),
class_loader, protection_domain, true,
CHECK_false);
if (!check_super) {
return false;
}
}

Array<InstanceKlass*>* interfaces = ik->local_interfaces();
int num_interfaces = interfaces->length();
for (int index = 0; index < num_interfaces; index++) {
if (!check_shared_class_super_type(ik, interfaces->at(index), class_loader, protection_domain, false, THREAD)) {
bool check_interface = check_shared_class_super_type(ik, interfaces->at(index), class_loader, protection_domain, false,
CHECK_false);
if (!check_interface) {
return false;
}
}
Expand Down Expand Up @@ -1153,7 +1158,8 @@ InstanceKlass* SystemDictionary::load_shared_class(InstanceKlass* ik,
return nullptr;
}

if (!check_shared_class_super_types(ik, class_loader, protection_domain, THREAD)) {
bool check = check_shared_class_super_types(ik, class_loader, protection_domain, CHECK_NULL);
if (!check) {
ik->set_shared_loading_failed();
return nullptr;
}
Expand Down
6 changes: 2 additions & 4 deletions src/hotspot/share/compiler/oopMap.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,10 @@ void OopMapDo<OopFnT, DerivedOopFnT, ValueFilterT>::iterate_oops_do(const frame
continue;

#ifndef COMPILER2
COMPILER1_PRESENT(ShouldNotReachHere();)
#if INCLUDE_JVMCI
if (UseJVMCICompiler) {
ShouldNotReachHere();
}
if (!EnableJVMCI)
#endif
ShouldNotReachHere();
#endif // !COMPILER2

address loc = fr->oopmapreg_to_location(omv.reg(), reg_map);
Expand Down
4 changes: 3 additions & 1 deletion src/hotspot/share/gc/shared/oopStorageSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ bool OopStorageSet::print_containing(const void* addr, outputStream* st) {
if (addr != nullptr) {
const void* aligned_addr = align_down(addr, alignof(oop));
for (OopStorage* storage : Range<Id>()) {
if (storage->print_containing((oop*) aligned_addr, st)) {
// Check for null for extra safety: might get here while handling error
// before storage initialization.
if ((storage != nullptr) && storage->print_containing((oop*) aligned_addr, st)) {
if (aligned_addr != addr) {
st->print_cr(" (unaligned)");
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/jvmci/jvmci_globals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "compiler/compilerDefinitions.hpp"
#include "gc/shared/gcConfig.hpp"
#include "jvm.h"
#include "jvmci/jvmci.hpp"
#include "jvmci/jvmci_globals.hpp"
#include "logging/log.hpp"
#include "runtime/arguments.hpp"
Expand Down Expand Up @@ -90,8 +91,7 @@ bool JVMCIGlobals::check_jvmci_flags_are_consistent() {

if (EnableJVMCI) {
if (FLAG_IS_DEFAULT(UseJVMCINativeLibrary) && !UseJVMCINativeLibrary) {
char path[JVM_MAXPATHLEN];
if (os::dll_locate_lib(path, sizeof(path), Arguments::get_dll_dir(), JVMCI_SHARED_LIBRARY_NAME)) {
if (JVMCI::shared_library_exists()) {
// If a JVMCI native library is present,
// we enable UseJVMCINativeLibrary by default.
FLAG_SET_DEFAULT(UseJVMCINativeLibrary, true);
Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/share/jvmci/jvmci_globals.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class fileStream;
constraint) \
\
product(bool, EnableJVMCI, false, EXPERIMENTAL, \
"Enable JVMCI") \
"Enable JVMCI. Defaults to true if UseJVMCICompiler is true.") \
\
product(bool, UseGraalJIT, false, EXPERIMENTAL, \
"Select the Graal JVMCI compiler. This is an alias for: " \
Expand Down Expand Up @@ -140,8 +140,8 @@ class fileStream;
product(bool, UseJVMCINativeLibrary, false, EXPERIMENTAL, \
"Execute JVMCI Java code from a shared library (\"libjvmci\") " \
"instead of loading it from class files and executing it " \
"on the HotSpot heap. Defaults to true if EnableJVMCI is " \
"true and a JVMCI native library is available.") \
"on the HotSpot heap. Defaults to true if UseJVMCICompiler or " \
"EnableJVMCI is true and a JVMCI native library is available.") \
\
product(double, JVMCINativeLibraryThreadFraction, 0.33, EXPERIMENTAL, \
"The fraction of compiler threads used by libjvmci. " \
Expand Down
Loading

0 comments on commit 63ce96e

Please sign in to comment.