Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions hotspot/src/cpu/aarch64/vm/c1_LIRGenerator_aarch64.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013, Red Hat Inc.
* Copyright (c) 2005, 2019, Oracle and/or its affiliates.
* Copyright (c) 2005, 2024, Oracle and/or its affiliates.
* All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
Expand Down Expand Up @@ -150,8 +150,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 (disp != 0) {
Expand Down
8 changes: 5 additions & 3 deletions hotspot/src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 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 @@ -156,8 +156,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 (disp != 0) {
Expand Down
13 changes: 6 additions & 7 deletions hotspot/src/share/vm/classfile/javaClasses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1235,14 +1235,13 @@ oop java_lang_Throwable::message(Handle throwable) {
}


// Return Symbol for detailed_message or NULL
Symbol* java_lang_Throwable::detail_message(oop throwable) {
PRESERVE_EXCEPTION_MARK; // Keep original exception
oop detailed_message = java_lang_Throwable::message(throwable);
if (detailed_message != NULL) {
return java_lang_String::as_symbol(detailed_message, THREAD);
const char* java_lang_Throwable::message_as_utf8(oop throwable) {
oop msg = java_lang_Throwable::message(throwable);
const char* msg_utf8 = NULL;
if (msg != NULL) {
msg_utf8 = java_lang_String::as_utf8_string(msg);
}
return NULL;
return msg_utf8;
}

void java_lang_Throwable::set_message(oop throwable, oop value) {
Expand Down
4 changes: 2 additions & 2 deletions hotspot/src/share/vm/classfile/javaClasses.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -523,12 +523,12 @@ class java_lang_Throwable: AllStatic {
static void set_backtrace(oop throwable, oop value);
// Needed by JVMTI to filter out this internal field.
static int get_backtrace_offset() { return backtrace_offset;}
static int get_detailMessage_offset() { return detailMessage_offset;}
// Message
static int get_detailMessage_offset() { return detailMessage_offset;}
static oop message(oop throwable);
static oop message(Handle throwable);
static const char* message_as_utf8(oop throwable);
static void set_message(oop throwable, oop value);
static Symbol* detail_message(oop throwable);
static void print_stack_element(outputStream *st, Handle mirror, int method,
int version, int bci, int cpref);
static void print_stack_element(outputStream *st, methodHandle method, int bci);
Expand Down
14 changes: 7 additions & 7 deletions hotspot/src/share/vm/classfile/resolutionErrors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
// add new entry to the table
void ResolutionErrorTable::add_entry(int index, unsigned int hash,
constantPoolHandle pool, int cp_index,
Symbol* error, Symbol* message)
Symbol* error, const char* message)
{
assert_locked_or_safepoint(SystemDictionary_lock);
assert(!pool.is_null() && error != NULL, "adding NULL obj");
Expand Down Expand Up @@ -64,16 +64,14 @@ void ResolutionErrorEntry::set_error(Symbol* e) {
_error->increment_refcount();
}

void ResolutionErrorEntry::set_message(Symbol* c) {
assert(c != NULL, "must set a value");
_message = c;
_message->increment_refcount();
void ResolutionErrorEntry::set_message(const char* c) {
_message = c != NULL ? os::strdup(c) : NULL;
}

// create new error entry
ResolutionErrorEntry* ResolutionErrorTable::new_entry(int hash, ConstantPool* pool,
int cp_index, Symbol* error,
Symbol* message)
const char* message)
{
ResolutionErrorEntry* entry = (ResolutionErrorEntry*)Hashtable<ConstantPool*, mtClass>::new_entry(hash, pool);
entry->set_cp_index(cp_index);
Expand All @@ -87,7 +85,9 @@ void ResolutionErrorTable::free_entry(ResolutionErrorEntry *entry) {
// decrement error refcount
assert(entry->error() != NULL, "error should be set");
entry->error()->decrement_refcount();
entry->message()->decrement_refcount();
if (entry->message() != NULL) {
FREE_C_HEAP_ARRAY(char, entry->message(), mtInternal);
}
Hashtable<ConstantPool*, mtClass>::free_entry(entry);
}

Expand Down
11 changes: 6 additions & 5 deletions hotspot/src/share/vm/classfile/resolutionErrors.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class ResolutionErrorTable : public Hashtable<ConstantPool*, mtClass> {
ResolutionErrorTable(int table_size);

ResolutionErrorEntry* new_entry(int hash, ConstantPool* pool, int cp_index,
Symbol* error, Symbol* message);
Symbol* error, const char* message);
void free_entry(ResolutionErrorEntry *entry);

ResolutionErrorEntry* bucket(int i) {
Expand All @@ -56,7 +56,7 @@ class ResolutionErrorTable : public Hashtable<ConstantPool*, mtClass> {
}

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


// find error given the constant pool and constant pool index
Expand All @@ -80,7 +80,7 @@ class ResolutionErrorEntry : public HashtableEntry<ConstantPool*, mtClass> {
private:
int _cp_index;
Symbol* _error;
Symbol* _message;
const char* _message;

public:
ConstantPool* pool() const { return literal(); }
Expand All @@ -91,8 +91,9 @@ 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);

ResolutionErrorEntry* next() const {
return (ResolutionErrorEntry*)HashtableEntry<ConstantPool*, mtClass>::next();
Expand Down
4 changes: 2 additions & 2 deletions hotspot/src/share/vm/classfile/systemDictionary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2280,7 +2280,7 @@ 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(constantPoolHandle pool, int which,
Symbol* error, Symbol* message) {
Symbol* error, const char* message) {
unsigned int hash = resolution_errors()->compute_hash(pool, which);
int index = resolution_errors()->hash_to_index(hash);
{
Expand All @@ -2296,7 +2296,7 @@ void SystemDictionary::delete_resolution_error(ConstantPool* pool) {

// Lookup resolution error table. Returns error if found, otherwise NULL.
Symbol* SystemDictionary::find_resolution_error(constantPoolHandle pool, int which,
Symbol** message) {
const char** message) {
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 hotspot/src/share/vm/classfile/systemDictionary.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -549,10 +549,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(constantPoolHandle pool, int which, Symbol* error,
Symbol* message);
const char* message);
static void delete_resolution_error(ConstantPool* pool);
static Symbol* find_resolution_error(constantPoolHandle pool, int which,
Symbol** message);
const char** message);

protected:

Expand Down
6 changes: 3 additions & 3 deletions hotspot/src/share/vm/interpreter/interpreterRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,11 +451,11 @@ IRT_ENTRY(address, InterpreterRuntime::exception_handler_for_exception(JavaThrea
// tracing
if (TraceExceptions) {
ResourceMark rm(thread);
Symbol* message = java_lang_Throwable::detail_message(h_exception());
const char* detail_message = java_lang_Throwable::message_as_utf8(h_exception());
ttyLocker ttyl; // Lock after getting the detail message
if (message != NULL) {
if (detail_message != NULL) {
tty->print_cr("Exception <%s: %s> (" INTPTR_FORMAT ")",
h_exception->print_value_string(), message->as_C_string(),
h_exception->print_value_string(), detail_message,
(address)h_exception());
} else {
tty->print_cr("Exception <%s> (" INTPTR_FORMAT ")",
Expand Down
23 changes: 14 additions & 9 deletions hotspot/src/share/vm/oops/constantPool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -569,13 +569,16 @@ bool ConstantPool::resolve_class_constants(TRAPS) {
return true;
}

Symbol* ConstantPool::exception_message(constantPoolHandle this_oop, int which, constantTag tag, oop pending_exception) {
const char* ConstantPool::exception_message(constantPoolHandle this_oop, int which, constantTag tag, oop pending_exception) {
// Note: caller needs ResourceMark

// Dig out the detailed message to reuse if possible
Symbol* message = java_lang_Throwable::detail_message(pending_exception);
if (message != NULL) {
return message;
const char* msg = java_lang_Throwable::message_as_utf8(pending_exception);
if (msg != NULL) {
return msg;
}

Symbol* message = NULL;
// Return specific message for the tag
switch (tag.value()) {
case JVM_CONSTANT_UnresolvedClass:
Expand All @@ -594,16 +597,16 @@ Symbol* ConstantPool::exception_message(constantPoolHandle this_oop, int which,
ShouldNotReachHere();
}

return message;
return message != NULL ? message->as_C_string() : NULL;
}

void ConstantPool::throw_resolution_error(constantPoolHandle this_oop, int which, TRAPS) {
Symbol* message = NULL;
ResourceMark rm(THREAD);
const char* message = NULL;
Symbol* error = SystemDictionary::find_resolution_error(this_oop, which, &message);
assert(error != NULL && message != NULL, "checking");
CLEAR_PENDING_EXCEPTION;
ResourceMark rm;
THROW_MSG(error, message->as_C_string());
THROW_MSG(error, message);
}

// If resolution for Class, MethodHandle or MethodType fails, save the exception
Expand All @@ -622,7 +625,9 @@ void ConstantPool::save_and_throw_exception(constantPoolHandle this_oop, int whi
// and OutOfMemoryError, etc, or if the thread was hit by stop()
// Needs clarification to section 5.4.3 of the VM spec (see 6308271)
} else if (this_oop->tag_at(which).value() != error_tag) {
Symbol* message = exception_message(this_oop, which, tag, PENDING_EXCEPTION);
ResourceMark rm(THREAD);

const char* message = exception_message(this_oop, which, tag, PENDING_EXCEPTION);
SystemDictionary::add_resolution_error(this_oop, which, error, message);
this_oop->tag_at_put(which, error_tag);
} else {
Expand Down
2 changes: 1 addition & 1 deletion hotspot/src/share/vm/oops/constantPool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,7 @@ class ConstantPool : public Metadata {

// Exception handling
static void throw_resolution_error(constantPoolHandle this_oop, int which, TRAPS);
static Symbol* exception_message(constantPoolHandle this_oop, int which, constantTag tag, oop pending_exception);
static const char* exception_message(constantPoolHandle this_oop, int which, constantTag tag, oop pending_exception);
static void save_and_throw_exception(constantPoolHandle this_oop, int which, constantTag tag, TRAPS);

public:
Expand Down
Loading