Skip to content

Commit

Permalink
Merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeybakhtin committed Aug 13, 2024
2 parents cd91517 + 09bab6e commit 6767d51
Show file tree
Hide file tree
Showing 29 changed files with 442 additions and 253 deletions.
171 changes: 88 additions & 83 deletions .github/workflows/submit.yml

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions hotspot/src/os/linux/vm/os_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2008,11 +2008,11 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen)
static Elf32_Half running_arch_code=EM_68K;
#elif (defined AARCH64)
static Elf32_Half running_arch_code=EM_AARCH64;
#elif (defined LOONGARCH)
#elif (defined LOONGARCH64)
static Elf32_Half running_arch_code=EM_LOONGARCH;
#else
#error Method os::dll_load requires that one of following is defined:\
IA32, AMD64, IA64, __sparc, __powerpc__, ARM, S390, ALPHA, MIPS, MIPSEL, PARISC, M68K, AARCH64, LOONGARCH
IA32, AMD64, IA64, __sparc, __powerpc__, ARM, S390, ALPHA, MIPS, MIPSEL, PARISC, M68K, AARCH64, LOONGARCH64
#endif

// Identify compatability class for VM's architecture and library's architecture
Expand Down
14 changes: 7 additions & 7 deletions hotspot/src/share/vm/c1/c1_RangeCheckElimination.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2023, 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 @@ -441,14 +441,14 @@ void RangeCheckEliminator::in_block_motion(BlockBegin *block, AccessIndexedList

if (c) {
jint value = c->type()->as_IntConstant()->value();
if (value != min_jint) {
if (ao->op() == Bytecodes::_isub) {
value = -value;
}
if (ao->op() == Bytecodes::_iadd) {
base = java_add(base, value);
last_integer = base;
last_instruction = other;
} else {
assert(ao->op() == Bytecodes::_isub, "unexpected bytecode");
base = java_subtract(base, value);
}
last_integer = base;
last_instruction = other;
index = other;
} else {
break;
Expand Down
6 changes: 4 additions & 2 deletions hotspot/src/share/vm/c1/c1_Runtime1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
#include "runtime/vframeArray.hpp"
#include "utilities/copy.hpp"
#include "utilities/events.hpp"
#include "utilities/exceptions.hpp"


// Implementation of StubAssembler
Expand Down Expand Up @@ -536,8 +537,9 @@ JRT_ENTRY_NO_ASYNC(static address, exception_handler_for_pc_helper(JavaThread* t
if (TraceExceptions) {
ttyLocker ttyl;
ResourceMark rm;
tty->print_cr("Exception <%s> (" INTPTR_FORMAT ") thrown in compiled method <%s> at PC " INTPTR_FORMAT " for thread " INTPTR_FORMAT "",
exception->print_value_string(), p2i((address)exception()), nm->method()->print_value_string(), p2i(pc), p2i(thread));
tty->print_cr("Exception <%.*s> (" INTPTR_FORMAT ") thrown in compiled method <%s> at PC " INTPTR_FORMAT " for thread " INTPTR_FORMAT "",
MAX_LEN, exception->print_value_string(),
p2i((address)exception()), nm->method()->print_value_string(), p2i(pc), p2i(thread));
}
// for AbortVMOnException flag
NOT_PRODUCT(Exceptions::debug_check_abort(exception));
Expand Down
25 changes: 22 additions & 3 deletions hotspot/src/share/vm/classfile/symbolTable.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 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 @@ -236,7 +236,23 @@ unsigned int SymbolTable::hash_symbol(const char* s, int len) {
// entries in the symbol table during normal execution (only during
// safepoints).

// Symbols should represent entities from the constant pool that are
// limited to <64K in length, but usage errors creep in allowing Symbols
// to be used for arbitrary strings. For debug builds we will assert if
// a string is too long, whereas product builds will truncate it.
static int check_length(const char* name, int len) {
assert(len <= Symbol::max_length(),
"String length exceeds the maximum Symbol length");
if (len > Symbol::max_length()) {
warning("A string \"%.80s ... %.80s\" exceeds the maximum Symbol "
"length of %d and has been truncated", name, (name + len - 80), Symbol::max_length());
len = Symbol::max_length();
}
return len;
}

Symbol* SymbolTable::lookup(const char* name, int len, TRAPS) {
len = check_length(name, len);
unsigned int hashValue = hash_symbol(name, len);
int index = the_table()->hash_to_index(hashValue);

Expand Down Expand Up @@ -367,6 +383,7 @@ void SymbolTable::add(ClassLoaderData* loader_data, constantPoolHandle cp,
for (int i=0; i<names_count; i++) {
int index = table->hash_to_index(hashValues[i]);
bool c_heap = !loader_data->is_the_null_class_loader_data();
assert(lengths[i] <= Symbol::max_length(), "must be - these come from the constant pool");
Symbol* sym = table->basic_add(index, (u1*)names[i], lengths[i], hashValues[i], c_heap, CHECK);
cp->symbol_at_put(cp_indices[i], sym);
}
Expand All @@ -375,7 +392,8 @@ void SymbolTable::add(ClassLoaderData* loader_data, constantPoolHandle cp,

Symbol* SymbolTable::new_permanent_symbol(const char* name, TRAPS) {
unsigned int hash;
Symbol* result = SymbolTable::lookup_only((char*)name, (int)strlen(name), hash);
int len = check_length(name, (int)strlen(name));
Symbol* result = SymbolTable::lookup_only((char*)name, len, hash);
if (result != NULL) {
return result;
}
Expand All @@ -384,13 +402,14 @@ Symbol* SymbolTable::new_permanent_symbol(const char* name, TRAPS) {

SymbolTable* table = the_table();
int index = table->hash_to_index(hash);
return table->basic_add(index, (u1*)name, (int)strlen(name), hash, false, THREAD);
return table->basic_add(index, (u1*)name, len, hash, false, THREAD);
}

Symbol* SymbolTable::basic_add(int index_arg, u1 *name, int len,
unsigned int hashValue_arg, bool c_heap, TRAPS) {
assert(!Universe::heap()->is_in_reserved(name),
"proposed name of symbol must be stable");
assert(len <= Symbol::max_length(), "caller should have ensured this");

// Don't allow symbols to be created which cannot fit in a Symbol*.
if (len > Symbol::max_length()) {
Expand Down
8 changes: 6 additions & 2 deletions hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2854,7 +2854,9 @@ BytecodeInterpreter::run(interpreterState istate) {
if (TraceExceptions) {
ttyLocker ttyl;
ResourceMark rm;
tty->print_cr("Exception <%s> (" INTPTR_FORMAT ")", except_oop->print_value_string(), p2i(except_oop()));
tty->print_cr("Exception <%.*s> (" INTPTR_FORMAT ")",
MAX_LEN, except_oop->print_value_string(),
p2i(except_oop()));
tty->print_cr(" thrown in interpreter method <%s>", METHOD->print_value_string());
tty->print_cr(" at bci %d, continuing at %d for thread " INTPTR_FORMAT,
(int)(istate->bcp() - METHOD->code_base()),
Expand All @@ -2870,7 +2872,9 @@ BytecodeInterpreter::run(interpreterState istate) {
if (TraceExceptions) {
ttyLocker ttyl;
ResourceMark rm;
tty->print_cr("Exception <%s> (" INTPTR_FORMAT ")", except_oop->print_value_string(), p2i(except_oop()));
tty->print_cr("Exception <%.*s> (" INTPTR_FORMAT ")",
MAX_LEN, except_oop->print_value_string(),
p2i(except_oop()));
tty->print_cr(" thrown in interpreter method <%s>", METHOD->print_value_string());
tty->print_cr(" at bci %d, unwinding for thread " INTPTR_FORMAT,
(int)(istate->bcp() - METHOD->code_base()),
Expand Down
7 changes: 4 additions & 3 deletions hotspot/src/share/vm/interpreter/bytecodes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,15 +394,16 @@ class Bytecodes: AllStatic {
static Code non_breakpoint_code_at(const Method* method, address bcp);

// Bytecode attributes
static bool is_defined (int code) { return 0 <= code && code < number_of_codes && flags(code, false) != 0; }
static bool is_valid (int code) { return 0 <= code && code < number_of_codes; }
static bool is_defined (int code) { return is_valid(code) && flags(code, false) != 0; }
static bool wide_is_defined(int code) { return is_defined(code) && flags(code, true) != 0; }
static const char* name (Code code) { check(code); return _name [code]; }
static BasicType result_type (Code code) { check(code); return _result_type [code]; }
static int depth (Code code) { check(code); return _depth [code]; }
// Note: Length functions must return <=0 for invalid bytecodes.
// Calling check(code) in length functions would throw an unwanted assert.
static int length_for (Code code) { /*no check*/ return _lengths [code] & 0xF; }
static int wide_length_for(Code code) { /*no check*/ return _lengths [code] >> 4; }
static int length_for (Code code) { return is_valid(code) ? _lengths[code] & 0xF : -1; }
static int wide_length_for(Code code) { return is_valid(code) ? _lengths[code] >> 4 : -1; }
static bool can_trap (Code code) { check(code); return has_all_flags(code, _bc_can_trap, false); }
static Code java_code (Code code) { check(code); return _java_code [code]; }
static bool can_rewrite (Code code) { check(code); return has_all_flags(code, _bc_can_rewrite, false); }
Expand Down
10 changes: 6 additions & 4 deletions hotspot/src/share/vm/interpreter/interpreterRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
#include "runtime/synchronizer.hpp"
#include "runtime/threadCritical.hpp"
#include "utilities/events.hpp"
#include "utilities/exceptions.hpp"
#ifdef TARGET_ARCH_x86
# include "vm_version_x86.hpp"
#endif
Expand Down Expand Up @@ -454,12 +455,13 @@ IRT_ENTRY(address, InterpreterRuntime::exception_handler_for_exception(JavaThrea
const char* detail_message = java_lang_Throwable::message_as_utf8(h_exception());
ttyLocker ttyl; // Lock after getting the detail message
if (detail_message != NULL) {
tty->print_cr("Exception <%s: %s> (" INTPTR_FORMAT ")",
h_exception->print_value_string(), detail_message,
tty->print_cr("Exception <%.*s: %.*s> (" INTPTR_FORMAT ")",
MAX_LEN, h_exception->print_value_string(),
MAX_LEN, detail_message,
(address)h_exception());
} else {
tty->print_cr("Exception <%s> (" INTPTR_FORMAT ")",
h_exception->print_value_string(),
tty->print_cr("Exception <%.*s> (" INTPTR_FORMAT ")",
MAX_LEN, h_exception->print_value_string(),
(address)h_exception());
}
tty->print_cr(" thrown in interpreter method <%s>", h_method->print_value_string());
Expand Down
3 changes: 2 additions & 1 deletion hotspot/src/share/vm/oops/symbol.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 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 @@ -33,6 +33,7 @@
#include "memory/resourceArea.hpp"

Symbol::Symbol(const u1* name, int length, int refcount) {
assert(length <= max_length(), "SymbolTable should have caught this!");
_refcount = refcount;
_length = length;
_identity_hash = os::random();
Expand Down
3 changes: 2 additions & 1 deletion hotspot/src/share/vm/oops/symbol.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 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 @@ -135,6 +135,7 @@ class Symbol : private SymbolBase {
_body[index] = value;
}

// Constructor is private for use only by SymbolTable.
Symbol(const u1* name, int length, int refcount);
void* operator new(size_t size, int len, TRAPS) throw();
void* operator new(size_t size, int len, Arena* arena, TRAPS) throw();
Expand Down
27 changes: 23 additions & 4 deletions hotspot/src/share/vm/opto/superword.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2187,20 +2187,39 @@ void SuperWord::align_initial_loop_index(MemNode* align_to_ref) {
_igvn.register_new_node_with_optimizer(N);
_phase->set_ctrl(N, pre_ctrl);

// The computation of the new pre-loop limit could overflow or underflow the int range. This is problematic in
// combination with Range Check Elimination (RCE), which determines a "safe" range where a RangeCheck will always
// succeed. RCE adjusts the pre-loop limit such that we only enter the main-loop once we have reached the "safe"
// range, and adjusts the main-loop limit so that we exit the main-loop before we leave the "safe" range. After RCE,
// the range of the main-loop can only be safely narrowed, and should never be widened. Hence, the pre-loop limit
// can only be increased (for stride > 0), but an add overflow might decrease it, or decreased (for stride < 0), but
// a sub underflow might increase it. To prevent that, we perform the Sub / Add and Max / Min with long operations.
lim0 = new (_phase->C) ConvI2LNode(lim0);
N = new (_phase->C) ConvI2LNode(N);
orig_limit = new (_phase->C) ConvI2LNode(orig_limit);
_igvn.register_new_node_with_optimizer(lim0);
_igvn.register_new_node_with_optimizer(N);
_igvn.register_new_node_with_optimizer(orig_limit);

// substitute back into (1), so that new limit
// lim = lim0 + N
Node* lim;
if (stride < 0) {
lim = new (_phase->C) SubINode(lim0, N);
lim = new (_phase->C) SubLNode(lim0, N);
} else {
lim = new (_phase->C) AddINode(lim0, N);
lim = new (_phase->C) AddLNode(lim0, N);
}
_igvn.register_new_node_with_optimizer(lim);
_phase->set_ctrl(lim, pre_ctrl);
Node* constrained =
(stride > 0) ? (Node*) new (_phase->C) MinINode(lim, orig_limit)
: (Node*) new (_phase->C) MaxINode(lim, orig_limit);
(stride > 0) ? (Node*) new (_phase->C) MinLNode(_phase->C, lim, orig_limit)
: (Node*) new (_phase->C) MaxLNode(_phase->C, lim, orig_limit);
_igvn.register_new_node_with_optimizer(constrained);

// We know that the result is in the int range, there is never truncation
constrained = new (_phase->C) ConvL2INode(constrained);
_igvn.register_new_node_with_optimizer(constrained);

_phase->set_ctrl(constrained, pre_ctrl);
_igvn.hash_delete(pre_opaq);
pre_opaq->set_req(1, constrained);
Expand Down
7 changes: 4 additions & 3 deletions hotspot/src/share/vm/utilities/exceptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,11 @@ void Exceptions::_throw(Thread* thread, const char* file, int line, Handle h_exc
// tracing (do this up front - so it works during boot strapping)
if (TraceExceptions) {
ttyLocker ttyl;
tty->print_cr("Exception <%s%s%s> (" INTPTR_FORMAT ") \n"
tty->print_cr("Exception <%.*s%s%.*s> (" INTPTR_FORMAT ") \n"
"thrown [%s, line %d]\nfor thread " INTPTR_FORMAT,
h_exception->print_value_string(),
message ? ": " : "", message ? message : "",
MAX_LEN, h_exception->print_value_string(),
message ? ": " : "",
MAX_LEN, message ? message : "",
(address)h_exception(), file, line, thread);
}
// for AbortVMOnException flag
Expand Down
3 changes: 3 additions & 0 deletions hotspot/src/share/vm/utilities/exceptions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
#include "oops/oopsHierarchy.hpp"
#include "utilities/sizes.hpp"

// Limit exception message components to 64K (the same max as Symbols)
#define MAX_LEN 65535

// This file provides the basic support for exception handling in the VM.
// Note: We do not use C++ exceptions to avoid compiler dependencies and
// unpredictable performance.
Expand Down
12 changes: 7 additions & 5 deletions hotspot/src/share/vm/utilities/utf8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,14 +317,16 @@ int UNICODE::utf8_size(jchar c) {
}

int UNICODE::utf8_length(jchar* base, int length) {
int result = 0;
size_t result = 0;
for (int index = 0; index < length; index++) {
jchar c = base[index];
if ((0x0001 <= c) && (c <= 0x007F)) result += 1;
else if (c <= 0x07FF) result += 2;
else result += 3;
int sz = utf8_size(c);
if (result + sz > INT_MAX-1) {
break;
}
result += sz;
}
return result;
return static_cast<int>(result);
}

char* UNICODE::as_utf8(jchar* base, int length) {
Expand Down
Loading

0 comments on commit 6767d51

Please sign in to comment.