Skip to content

Commit 0e0b018

Browse files
committed
Merge
2 parents 0f59d5c + 43cb875 commit 0e0b018

File tree

17 files changed

+244
-175
lines changed

17 files changed

+244
-175
lines changed

hotspot/src/cpu/aarch64/vm/c1_LIRGenerator_aarch64.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright (c) 2013, Red Hat Inc.
3-
* Copyright (c) 2005, 2019, Oracle and/or its affiliates.
3+
* Copyright (c) 2005, 2024, Oracle and/or its affiliates.
44
* All rights reserved.
55
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
66
*
@@ -150,8 +150,10 @@ LIR_Address* LIRGenerator::generate_address(LIR_Opr base, LIR_Opr index,
150150
if (index->is_register()) {
151151
// apply the shift and accumulate the displacement
152152
if (shift > 0) {
153-
LIR_Opr tmp = new_pointer_register();
154-
__ shift_left(index, shift, tmp);
153+
// Use long register to avoid overflow when shifting large index values left.
154+
LIR_Opr tmp = new_register(T_LONG);
155+
__ convert(Bytecodes::_i2l, index, tmp);
156+
__ shift_left(tmp, shift, tmp);
155157
index = tmp;
156158
}
157159
if (disp != 0) {

hotspot/src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2005, 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
@@ -156,8 +156,10 @@ LIR_Address* LIRGenerator::generate_address(LIR_Opr base, LIR_Opr index,
156156
if (index->is_register()) {
157157
// apply the shift and accumulate the displacement
158158
if (shift > 0) {
159-
LIR_Opr tmp = new_pointer_register();
160-
__ shift_left(index, shift, tmp);
159+
// Use long register to avoid overflow when shifting large index values left.
160+
LIR_Opr tmp = new_register(T_LONG);
161+
__ convert(Bytecodes::_i2l, index, tmp);
162+
__ shift_left(tmp, shift, tmp);
161163
index = tmp;
162164
}
163165
if (disp != 0) {

hotspot/src/share/vm/classfile/javaClasses.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,14 +1235,13 @@ oop java_lang_Throwable::message(Handle throwable) {
12351235
}
12361236

12371237

1238-
// Return Symbol for detailed_message or NULL
1239-
Symbol* java_lang_Throwable::detail_message(oop throwable) {
1240-
PRESERVE_EXCEPTION_MARK; // Keep original exception
1241-
oop detailed_message = java_lang_Throwable::message(throwable);
1242-
if (detailed_message != NULL) {
1243-
return java_lang_String::as_symbol(detailed_message, THREAD);
1238+
const char* java_lang_Throwable::message_as_utf8(oop throwable) {
1239+
oop msg = java_lang_Throwable::message(throwable);
1240+
const char* msg_utf8 = NULL;
1241+
if (msg != NULL) {
1242+
msg_utf8 = java_lang_String::as_utf8_string(msg);
12441243
}
1245-
return NULL;
1244+
return msg_utf8;
12461245
}
12471246

12481247
void java_lang_Throwable::set_message(oop throwable, oop value) {

hotspot/src/share/vm/classfile/javaClasses.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -523,12 +523,12 @@ class java_lang_Throwable: AllStatic {
523523
static void set_backtrace(oop throwable, oop value);
524524
// Needed by JVMTI to filter out this internal field.
525525
static int get_backtrace_offset() { return backtrace_offset;}
526-
static int get_detailMessage_offset() { return detailMessage_offset;}
527526
// Message
527+
static int get_detailMessage_offset() { return detailMessage_offset;}
528528
static oop message(oop throwable);
529529
static oop message(Handle throwable);
530+
static const char* message_as_utf8(oop throwable);
530531
static void set_message(oop throwable, oop value);
531-
static Symbol* detail_message(oop throwable);
532532
static void print_stack_element(outputStream *st, Handle mirror, int method,
533533
int version, int bci, int cpref);
534534
static void print_stack_element(outputStream *st, methodHandle method, int bci);

hotspot/src/share/vm/classfile/resolutionErrors.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
// add new entry to the table
3434
void ResolutionErrorTable::add_entry(int index, unsigned int hash,
3535
constantPoolHandle pool, int cp_index,
36-
Symbol* error, Symbol* message)
36+
Symbol* error, const char* message)
3737
{
3838
assert_locked_or_safepoint(SystemDictionary_lock);
3939
assert(!pool.is_null() && error != NULL, "adding NULL obj");
@@ -64,16 +64,14 @@ void ResolutionErrorEntry::set_error(Symbol* e) {
6464
_error->increment_refcount();
6565
}
6666

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

7371
// create new error entry
7472
ResolutionErrorEntry* ResolutionErrorTable::new_entry(int hash, ConstantPool* pool,
7573
int cp_index, Symbol* error,
76-
Symbol* message)
74+
const char* message)
7775
{
7876
ResolutionErrorEntry* entry = (ResolutionErrorEntry*)Hashtable<ConstantPool*, mtClass>::new_entry(hash, pool);
7977
entry->set_cp_index(cp_index);
@@ -87,7 +85,9 @@ void ResolutionErrorTable::free_entry(ResolutionErrorEntry *entry) {
8785
// decrement error refcount
8886
assert(entry->error() != NULL, "error should be set");
8987
entry->error()->decrement_refcount();
90-
entry->message()->decrement_refcount();
88+
if (entry->message() != NULL) {
89+
FREE_C_HEAP_ARRAY(char, entry->message(), mtInternal);
90+
}
9191
Hashtable<ConstantPool*, mtClass>::free_entry(entry);
9292
}
9393

hotspot/src/share/vm/classfile/resolutionErrors.hpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class ResolutionErrorTable : public Hashtable<ConstantPool*, mtClass> {
3939
ResolutionErrorTable(int table_size);
4040

4141
ResolutionErrorEntry* new_entry(int hash, ConstantPool* pool, int cp_index,
42-
Symbol* error, Symbol* message);
42+
Symbol* error, const char* message);
4343
void free_entry(ResolutionErrorEntry *entry);
4444

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

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

6161

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

8585
public:
8686
ConstantPool* pool() const { return literal(); }
@@ -91,8 +91,9 @@ class ResolutionErrorEntry : public HashtableEntry<ConstantPool*, mtClass> {
9191
Symbol* error() const { return _error; }
9292
void set_error(Symbol* e);
9393

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

9798
ResolutionErrorEntry* next() const {
9899
return (ResolutionErrorEntry*)HashtableEntry<ConstantPool*, mtClass>::next();

hotspot/src/share/vm/classfile/systemDictionary.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2280,7 +2280,7 @@ bool SystemDictionary::add_loader_constraint(Symbol* class_name,
22802280
// Add entry to resolution error table to record the error when the first
22812281
// attempt to resolve a reference to a class has failed.
22822282
void SystemDictionary::add_resolution_error(constantPoolHandle pool, int which,
2283-
Symbol* error, Symbol* message) {
2283+
Symbol* error, const char* message) {
22842284
unsigned int hash = resolution_errors()->compute_hash(pool, which);
22852285
int index = resolution_errors()->hash_to_index(hash);
22862286
{
@@ -2296,7 +2296,7 @@ void SystemDictionary::delete_resolution_error(ConstantPool* pool) {
22962296

22972297
// Lookup resolution error table. Returns error if found, otherwise NULL.
22982298
Symbol* SystemDictionary::find_resolution_error(constantPoolHandle pool, int which,
2299-
Symbol** message) {
2299+
const char** message) {
23002300
unsigned int hash = resolution_errors()->compute_hash(pool, which);
23012301
int index = resolution_errors()->hash_to_index(hash);
23022302
{

hotspot/src/share/vm/classfile/systemDictionary.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -549,10 +549,10 @@ class SystemDictionary : AllStatic {
549549
// Record the error when the first attempt to resolve a reference from a constant
550550
// pool entry to a class fails.
551551
static void add_resolution_error(constantPoolHandle pool, int which, Symbol* error,
552-
Symbol* message);
552+
const char* message);
553553
static void delete_resolution_error(ConstantPool* pool);
554554
static Symbol* find_resolution_error(constantPoolHandle pool, int which,
555-
Symbol** message);
555+
const char** message);
556556

557557
protected:
558558

hotspot/src/share/vm/interpreter/interpreterRuntime.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -451,11 +451,11 @@ IRT_ENTRY(address, InterpreterRuntime::exception_handler_for_exception(JavaThrea
451451
// tracing
452452
if (TraceExceptions) {
453453
ResourceMark rm(thread);
454-
Symbol* message = java_lang_Throwable::detail_message(h_exception());
454+
const char* detail_message = java_lang_Throwable::message_as_utf8(h_exception());
455455
ttyLocker ttyl; // Lock after getting the detail message
456-
if (message != NULL) {
456+
if (detail_message != NULL) {
457457
tty->print_cr("Exception <%s: %s> (" INTPTR_FORMAT ")",
458-
h_exception->print_value_string(), message->as_C_string(),
458+
h_exception->print_value_string(), detail_message,
459459
(address)h_exception());
460460
} else {
461461
tty->print_cr("Exception <%s> (" INTPTR_FORMAT ")",

hotspot/src/share/vm/oops/constantPool.cpp

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -569,13 +569,16 @@ bool ConstantPool::resolve_class_constants(TRAPS) {
569569
return true;
570570
}
571571

572-
Symbol* ConstantPool::exception_message(constantPoolHandle this_oop, int which, constantTag tag, oop pending_exception) {
572+
const char* ConstantPool::exception_message(constantPoolHandle this_oop, int which, constantTag tag, oop pending_exception) {
573+
// Note: caller needs ResourceMark
574+
573575
// Dig out the detailed message to reuse if possible
574-
Symbol* message = java_lang_Throwable::detail_message(pending_exception);
575-
if (message != NULL) {
576-
return message;
576+
const char* msg = java_lang_Throwable::message_as_utf8(pending_exception);
577+
if (msg != NULL) {
578+
return msg;
577579
}
578580

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

597-
return message;
600+
return message != NULL ? message->as_C_string() : NULL;
598601
}
599602

600603
void ConstantPool::throw_resolution_error(constantPoolHandle this_oop, int which, TRAPS) {
601-
Symbol* message = NULL;
604+
ResourceMark rm(THREAD);
605+
const char* message = NULL;
602606
Symbol* error = SystemDictionary::find_resolution_error(this_oop, which, &message);
603607
assert(error != NULL && message != NULL, "checking");
604608
CLEAR_PENDING_EXCEPTION;
605-
ResourceMark rm;
606-
THROW_MSG(error, message->as_C_string());
609+
THROW_MSG(error, message);
607610
}
608611

609612
// If resolution for Class, MethodHandle or MethodType fails, save the exception
@@ -622,7 +625,9 @@ void ConstantPool::save_and_throw_exception(constantPoolHandle this_oop, int whi
622625
// and OutOfMemoryError, etc, or if the thread was hit by stop()
623626
// Needs clarification to section 5.4.3 of the VM spec (see 6308271)
624627
} else if (this_oop->tag_at(which).value() != error_tag) {
625-
Symbol* message = exception_message(this_oop, which, tag, PENDING_EXCEPTION);
628+
ResourceMark rm(THREAD);
629+
630+
const char* message = exception_message(this_oop, which, tag, PENDING_EXCEPTION);
626631
SystemDictionary::add_resolution_error(this_oop, which, error, message);
627632
this_oop->tag_at_put(which, error_tag);
628633
} else {

0 commit comments

Comments
 (0)