Skip to content

Commit

Permalink
Merge
Browse files Browse the repository at this point in the history
  • Loading branch information
theaoqi committed Apr 26, 2024
2 parents 38b11e8 + 1c40f89 commit af76bcb
Show file tree
Hide file tree
Showing 55 changed files with 749 additions and 370 deletions.
2 changes: 1 addition & 1 deletion make/conf/version-numbers.conf
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ DEFAULT_VERSION_CLASSFILE_MINOR=0
DEFAULT_VERSION_DOCS_API_SINCE=11
DEFAULT_ACCEPTABLE_BOOT_VERSIONS="16 17"
DEFAULT_JDK_SOURCE_TARGET_VERSION=17
DEFAULT_PROMOTED_VERSION_PRE=ea
DEFAULT_PROMOTED_VERSION_PRE=
8 changes: 5 additions & 3 deletions src/hotspot/cpu/aarch64/c1_LIRGenerator_aarch64.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, Red Hat Inc. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
Expand Down Expand Up @@ -167,8 +167,10 @@ LIR_Address* LIRGenerator::generate_address(LIR_Opr base, LIR_Opr index,
if (index->is_register()) {
// apply the shift and accumulate the displacement
if (shift > 0) {
LIR_Opr tmp = new_pointer_register();
__ shift_left(index, shift, tmp);
// Use long register to avoid overflow when shifting large index values left.
LIR_Opr tmp = new_register(T_LONG);
__ convert(Bytecodes::_i2l, index, tmp);
__ shift_left(tmp, shift, tmp);
index = tmp;
}
if (large_disp != 0) {
Expand Down
8 changes: 5 additions & 3 deletions src/hotspot/cpu/ppc/c1_LIRGenerator_ppc.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2019 SAP SE. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
Expand Down Expand Up @@ -164,8 +164,10 @@ LIR_Address* LIRGenerator::generate_address(LIR_Opr base, LIR_Opr index,
if (index->is_register()) {
// Apply the shift and accumulate the displacement.
if (shift > 0) {
LIR_Opr tmp = new_pointer_register();
__ shift_left(index, shift, tmp);
// Use long register to avoid overflow when shifting large index values left.
LIR_Opr tmp = new_register(T_LONG);
__ convert(Bytecodes::_i2l, index, tmp);
__ shift_left(tmp, shift, tmp);
index = tmp;
}
if (large_disp != 0) {
Expand Down
8 changes: 5 additions & 3 deletions src/hotspot/cpu/s390/c1_LIRGenerator_s390.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2017 SAP SE. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
Expand Down Expand Up @@ -157,8 +157,10 @@ LIR_Address* LIRGenerator::generate_address(LIR_Opr base, LIR_Opr index,
return new LIR_Address(base, index, type);
} else {
if (shift > 0) {
LIR_Opr tmp = new_pointer_register();
__ shift_left(index, shift, tmp);
// Use long register to avoid overflow when shifting large index values left.
LIR_Opr tmp = new_register(T_LONG);
__ convert(Bytecodes::_i2l, index, tmp);
__ shift_left(tmp, shift, tmp);
index = tmp;
}
return new LIR_Address(base, index, disp, type);
Expand Down
29 changes: 16 additions & 13 deletions src/hotspot/share/classfile/javaClasses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2076,18 +2076,17 @@ oop java_lang_Throwable::message(oop throwable) {
return throwable->obj_field(_detailMessage_offset);
}

oop java_lang_Throwable::cause(oop throwable) {
return throwable->obj_field(_cause_offset);
const char* java_lang_Throwable::message_as_utf8(oop throwable) {
oop msg = java_lang_Throwable::message(throwable);
const char* msg_utf8 = nullptr;
if (msg != nullptr) {
msg_utf8 = java_lang_String::as_utf8_string(msg);
}
return msg_utf8;
}

// Return Symbol for detailed_message or NULL
Symbol* java_lang_Throwable::detail_message(oop throwable) {
PreserveExceptionMark pm(Thread::current());
oop detailed_message = java_lang_Throwable::message(throwable);
if (detailed_message != NULL) {
return java_lang_String::as_symbol(detailed_message);
}
return NULL;
oop java_lang_Throwable::cause(oop throwable) {
return throwable->obj_field(_cause_offset);
}

void java_lang_Throwable::set_message(oop throwable, oop value) {
Expand Down Expand Up @@ -2739,15 +2738,19 @@ Handle java_lang_Throwable::create_initialization_error(JavaThread* current, Han
assert(throwable.not_null(), "shouldn't be");

// Now create the message from the original exception and thread name.
Symbol* message = java_lang_Throwable::detail_message(throwable());
ResourceMark rm(current);
stringStream st;
const char *message = nullptr;
oop detailed_message = java_lang_Throwable::message(throwable());
if (detailed_message != nullptr) {
message = java_lang_String::as_utf8_string(detailed_message);
}
st.print("Exception %s%s ", throwable()->klass()->name()->as_klass_external_name(),
message == nullptr ? "" : ":");
if (message == NULL) {
if (message == nullptr) {
st.print("[in thread \"%s\"]", current->name());
} else {
st.print("%s [in thread \"%s\"]", message->as_C_string(), current->name());
st.print("%s [in thread \"%s\"]", message, current->name());
}

Symbol* exception_name = vmSymbols::java_lang_ExceptionInInitializerError();
Expand Down
8 changes: 5 additions & 3 deletions src/hotspot/share/classfile/javaClasses.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -549,12 +549,14 @@ class java_lang_Throwable: AllStatic {
static void set_backtrace(oop throwable, oop value);
static int depth(oop throwable);
static void set_depth(oop throwable, int value);
static int get_detailMessage_offset() { CHECK_INIT(_detailMessage_offset); }
// Message
static int get_detailMessage_offset() { CHECK_INIT(_detailMessage_offset); }
static oop message(oop throwable);
static oop cause(oop throwable);
static const char* message_as_utf8(oop throwable);
static void set_message(oop throwable, oop value);
static Symbol* detail_message(oop throwable);

static oop cause(oop throwable);

static void print_stack_element(outputStream *st, Method* method, int bci);

static void compute_offsets();
Expand Down
23 changes: 9 additions & 14 deletions src/hotspot/share/classfile/resolutionErrors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
// create new error entry
void ResolutionErrorTable::add_entry(int index, unsigned int hash,
const constantPoolHandle& pool, int cp_index,
Symbol* error, Symbol* message,
Symbol* cause, Symbol* cause_msg)
Symbol* error, const char* message,
Symbol* cause, const char* cause_msg)
{
assert_locked_or_safepoint(SystemDictionary_lock);
assert(!pool.is_null() && error != NULL, "adding NULL obj");
Expand Down Expand Up @@ -95,11 +95,8 @@ void ResolutionErrorEntry::set_error(Symbol* e) {
}
}

void ResolutionErrorEntry::set_message(Symbol* c) {
_message = c;
if (_message != NULL) {
_message->increment_refcount();
}
void ResolutionErrorEntry::set_message(const char* c) {
_message = c != nullptr ? os::strdup(c) : nullptr;
}

void ResolutionErrorEntry::set_cause(Symbol* c) {
Expand All @@ -109,13 +106,11 @@ void ResolutionErrorEntry::set_cause(Symbol* c) {
}
}

void ResolutionErrorEntry::set_cause_msg(Symbol* c) {
_cause_msg = c;
if (_cause_msg != NULL) {
_cause_msg->increment_refcount();
}
void ResolutionErrorEntry::set_cause_msg(const char* c) {
_cause_msg = c != nullptr ? os::strdup(c) : nullptr;
}

// The incoming nest host error message is already in the C-Heap.
void ResolutionErrorEntry::set_nest_host_error(const char* message) {
_nest_host_error = message;
}
Expand All @@ -126,13 +121,13 @@ void ResolutionErrorTable::free_entry(ResolutionErrorEntry *entry) {
entry->error()->decrement_refcount();
}
if (entry->message() != NULL) {
entry->message()->decrement_refcount();
FREE_C_HEAP_ARRAY(char, entry->message());
}
if (entry->cause() != NULL) {
entry->cause()->decrement_refcount();
}
if (entry->cause_msg() != NULL) {
entry->cause_msg()->decrement_refcount();
FREE_C_HEAP_ARRAY(char, entry->cause_msg());
}
if (entry->nest_host_error() != NULL) {
FREE_C_HEAP_ARRAY(char, entry->nest_host_error());
Expand Down
21 changes: 12 additions & 9 deletions src/hotspot/share/classfile/resolutionErrors.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ class ResolutionErrorTable : public Hashtable<ConstantPool*, mtClass> {
}

void add_entry(int index, unsigned int hash,
const constantPoolHandle& pool, int which, Symbol* error, Symbol* message,
Symbol* cause, Symbol* cause_msg);
const constantPoolHandle& pool, int cp_index, Symbol* error, const char* error_msg,
Symbol* cause, const char* cause_msg);

void add_entry(int index, unsigned int hash,
const constantPoolHandle& pool, int which, const char* message);
const constantPoolHandle& pool, int cp_index, const char* message);

// find error given the constant pool and constant pool index
ResolutionErrorEntry* find_entry(int index, unsigned int hash,
Expand Down Expand Up @@ -96,9 +96,9 @@ class ResolutionErrorEntry : public HashtableEntry<ConstantPool*, mtClass> {
private:
int _cp_index;
Symbol* _error;
Symbol* _message;
const char* _message;
Symbol* _cause;
Symbol* _cause_msg;
const char* _cause_msg;
const char* _nest_host_error;

public:
Expand All @@ -110,16 +110,19 @@ class ResolutionErrorEntry : public HashtableEntry<ConstantPool*, mtClass> {
Symbol* error() const { return _error; }
void set_error(Symbol* e);

Symbol* message() const { return _message; }
void set_message(Symbol* c);
const char* message() const { return _message; }
// The incoming message is copied to the C-Heap.
void set_message(const char* c);

Symbol* cause() const { return _cause; }
void set_cause(Symbol* c);

Symbol* cause_msg() const { return _cause_msg; }
void set_cause_msg(Symbol* c);
const char* cause_msg() const { return _cause_msg; }
// The incoming cause_msg is copied to the C-Heap.
void set_cause_msg(const char* c);

const char* nest_host_error() const { return _nest_host_error; }
// The incoming nest host error message is already in the C-Heap.
void set_nest_host_error(const char* message);

ResolutionErrorEntry* next() const {
Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/share/classfile/systemDictionary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1846,8 +1846,8 @@ bool SystemDictionary::add_loader_constraint(Symbol* class_name,
// Add entry to resolution error table to record the error when the first
// attempt to resolve a reference to a class has failed.
void SystemDictionary::add_resolution_error(const constantPoolHandle& pool, int which,
Symbol* error, Symbol* message,
Symbol* cause, Symbol* cause_msg) {
Symbol* error, const char* message,
Symbol* cause, const char* cause_msg) {
unsigned int hash = resolution_errors()->compute_hash(pool, which);
int index = resolution_errors()->hash_to_index(hash);
{
Expand All @@ -1866,7 +1866,7 @@ void SystemDictionary::delete_resolution_error(ConstantPool* pool) {

// Lookup resolution error table. Returns error if found, otherwise NULL.
Symbol* SystemDictionary::find_resolution_error(const constantPoolHandle& pool, int which,
Symbol** message, Symbol** cause, Symbol** cause_msg) {
const char** message, Symbol** cause, const char** cause_msg) {
unsigned int hash = resolution_errors()->compute_hash(pool, which);
int index = resolution_errors()->hash_to_index(hash);
{
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/classfile/systemDictionary.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,10 +281,10 @@ class SystemDictionary : AllStatic {
// Record the error when the first attempt to resolve a reference from a constant
// pool entry to a class fails.
static void add_resolution_error(const constantPoolHandle& pool, int which, Symbol* error,
Symbol* message, Symbol* cause = NULL, Symbol* cause_msg = NULL);
const char* message, Symbol* cause = NULL, const char* cause_msg = NULL);
static void delete_resolution_error(ConstantPool* pool);
static Symbol* find_resolution_error(const constantPoolHandle& pool, int which,
Symbol** message, Symbol** cause, Symbol** cause_msg);
const char** message, Symbol** cause, const char** cause_msg);


// Record a nest host resolution/validation error
Expand Down
Loading

0 comments on commit af76bcb

Please sign in to comment.