Skip to content

Commit

Permalink
Merge upstream-jdk
Browse files Browse the repository at this point in the history
  • Loading branch information
corretto-github-robot committed Nov 2, 2023
2 parents bbf2a26 + 5207443 commit 55d3b7a
Show file tree
Hide file tree
Showing 65 changed files with 1,509 additions and 1,253 deletions.
26 changes: 16 additions & 10 deletions src/hotspot/os/windows/os_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -505,12 +505,17 @@ struct tm* os::gmtime_pd(const time_t* clock, struct tm* res) {
return nullptr;
}

enum Ept { EPT_THREAD, EPT_PROCESS, EPT_PROCESS_DIE };
// Wrapper around _endthreadex(), exit() and _exit()
[[noreturn]]
static void exit_process_or_thread(Ept what, int code);

JNIEXPORT
LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo);

// Thread start routine for all newly created threads.
// Called with the associated Thread* as the argument.
unsigned __stdcall os::win32::thread_native_entry(void* t) {
static unsigned __stdcall thread_native_entry(void* t) {
Thread* thread = static_cast<Thread*>(t);

thread->record_stack_base_and_size();
Expand Down Expand Up @@ -558,7 +563,8 @@ unsigned __stdcall os::win32::thread_native_entry(void* t) {

// Thread must not return from exit_process_or_thread(), but if it does,
// let it proceed to exit normally
return (unsigned)os::win32::exit_process_or_thread(os::win32::EPT_THREAD, res);
exit_process_or_thread(EPT_THREAD, res);
return res;
}

static OSThread* create_os_thread(Thread* thread, HANDLE thread_handle,
Expand Down Expand Up @@ -745,7 +751,7 @@ bool os::create_thread(Thread* thread, ThreadType thr_type,
thread_handle =
(HANDLE)_beginthreadex(nullptr,
(unsigned)stack_size,
&os::win32::thread_native_entry,
&thread_native_entry,
thread,
initflag,
&thread_id);
Expand Down Expand Up @@ -1202,7 +1208,7 @@ void os::abort(bool dump_core, void* siginfo, const void* context) {
if (dumpFile != nullptr) {
CloseHandle(dumpFile);
}
win32::exit_process_or_thread(win32::EPT_PROCESS, 1);
exit_process_or_thread(EPT_PROCESS, 1);
}

dumpType = (MINIDUMP_TYPE)(MiniDumpWithFullMemory | MiniDumpWithHandleData |
Expand All @@ -1226,12 +1232,12 @@ void os::abort(bool dump_core, void* siginfo, const void* context) {
jio_fprintf(stderr, "Call to MiniDumpWriteDump() failed (Error 0x%x)\n", GetLastError());
}
CloseHandle(dumpFile);
win32::exit_process_or_thread(win32::EPT_PROCESS, 1);
exit_process_or_thread(EPT_PROCESS, 1);
}

// Die immediately, no exit hook, no abort hook, no cleanup.
void os::die() {
win32::exit_process_or_thread(win32::EPT_PROCESS_DIE, -1);
exit_process_or_thread(EPT_PROCESS_DIE, -1);
}

void os::dll_unload(void *lib) {
Expand Down Expand Up @@ -4097,7 +4103,7 @@ static BOOL CALLBACK init_crit_sect_call(PINIT_ONCE, PVOID pcrit_sect, PVOID*) {
return TRUE;
}

int os::win32::exit_process_or_thread(Ept what, int exit_code) {
static void exit_process_or_thread(Ept what, int exit_code) {
// Basic approach:
// - Each exiting thread registers its intent to exit and then does so.
// - A thread trying to terminate the process must wait for all
Expand Down Expand Up @@ -4275,7 +4281,7 @@ int os::win32::exit_process_or_thread(Ept what, int exit_code) {
}

// Should not reach here
return exit_code;
os::infinite_sleep();
}

#undef EXIT_TIMEOUT
Expand Down Expand Up @@ -4853,11 +4859,11 @@ ssize_t os::pd_write(int fd, const void *buf, size_t nBytes) {
}

void os::exit(int num) {
win32::exit_process_or_thread(win32::EPT_PROCESS, num);
exit_process_or_thread(EPT_PROCESS, num);
}

void os::_exit(int num) {
win32::exit_process_or_thread(win32::EPT_PROCESS_DIE, num);
exit_process_or_thread(EPT_PROCESS_DIE, num);
}

// Is a (classpath) directory empty?
Expand Down
7 changes: 0 additions & 7 deletions src/hotspot/os/windows/os_windows.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,6 @@ class os::win32 {
static HINSTANCE load_Windows_dll(const char* name, char *ebuf, int ebuflen);

private:
// The handler passed to _beginthreadex().
// Called with the associated Thread* as the argument.
static unsigned __stdcall thread_native_entry(void*);

enum Ept { EPT_THREAD, EPT_PROCESS, EPT_PROCESS_DIE };
// Wrapper around _endthreadex(), exit() and _exit()
static int exit_process_or_thread(Ept what, int exit_code);

static void initialize_performance_counter();

Expand Down
1 change: 1 addition & 0 deletions src/hotspot/os/windows/vmError_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,5 @@ void VMError::raise_fail_fast(void* exrecord, void* context) {
RaiseFailFastException(static_cast<PEXCEPTION_RECORD>(exrecord),
static_cast<PCONTEXT>(context),
flags);
os::infinite_sleep();
}
8 changes: 6 additions & 2 deletions src/hotspot/share/c1/c1_Compilation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ int Compilation::compile_java_method() {
PhaseTraceTime timeit(_t_buildIR);
build_hir();
}
CHECK_BAILOUT_(no_frame_size);
if (BailoutAfterHIR) {
BAILOUT_("Bailing out because of -XX:+BailoutAfterHIR", no_frame_size);
}
Expand Down Expand Up @@ -446,13 +447,13 @@ void Compilation::install_code(int frame_size) {

void Compilation::compile_method() {

CompilationMemoryStatisticMark cmsm(env()->task()->directive());

{
PhaseTraceTime timeit(_t_setup);

// setup compilation
initialize();
CHECK_BAILOUT();

}

if (!method()->can_be_compiled()) {
Expand Down Expand Up @@ -605,6 +606,9 @@ Compilation::Compilation(AbstractCompiler* compiler, ciEnv* env, ciMethod* metho
_cfg_printer_output = new CFGPrinterOutput(this);
}
#endif

CompilationMemoryStatisticMark cmsm(directive);

compile_method();
if (bailed_out()) {
_env->record_method_not_compilable(bailout_msg());
Expand Down
5 changes: 5 additions & 0 deletions src/hotspot/share/c1/c1_Compilation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class Compilation: public StackObj {
bool _has_monitors; // Fastpath monitors detection for Continuations
bool _install_code;
const char* _bailout_msg;
bool _oom;
ExceptionInfoList* _exception_info_list;
ExceptionHandlerTable _exception_handler_table;
ImplicitExceptionTable _implicit_exception_table;
Expand Down Expand Up @@ -203,6 +204,10 @@ class Compilation: public StackObj {
}
#endif // PRODUCT

// MemLimit handling
bool oom() const { return _oom; }
void set_oom() { _oom = true; }

// error handling
void bailout(const char* msg);
bool bailed_out() const { return _bailout_msg != nullptr; }
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/ci/ciEnv.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,10 +319,10 @@ class ciEnv : StackObj {

// This is true if the compilation is not going to produce code.
// (It is reasonable to retry failed compilations.)
bool failing() { return _failure_reason != nullptr; }
bool failing() const { return _failure_reason != nullptr; }

// Reason this compilation is failing, such as "too many basic blocks".
const char* failure_reason() { return _failure_reason; }
const char* failure_reason() const { return _failure_reason; }

// Return state of appropriate compatibility
int compilable() { return _compilable; }
Expand Down
5 changes: 4 additions & 1 deletion src/hotspot/share/classfile/javaClasses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2453,7 +2453,7 @@ void java_lang_Throwable::print_stack_trace(Handle throwable, outputStream* st)
BacktraceElement bte = iter.next(THREAD);
print_stack_element_to_stream(st, bte._mirror, bte._method_id, bte._version, bte._bci, bte._name);
}
{
if (THREAD->can_call_java()) {
// Call getCause() which doesn't necessarily return the _cause field.
ExceptionMark em(THREAD);
JavaValue cause(T_OBJECT);
Expand All @@ -2475,6 +2475,9 @@ void java_lang_Throwable::print_stack_trace(Handle throwable, outputStream* st)
st->cr();
}
}
} else {
st->print_raw_cr("<<cannot call Java to get cause>>");
return;
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/classfile/systemDictionary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ InstanceKlass* SystemDictionary::resolve_instance_class_or_null(Symbol* name,
InstanceKlass* loaded_class = nullptr;
SymbolHandle superclassname; // Keep alive while loading in parallel thread.

assert(THREAD->can_call_java(),
guarantee(THREAD->can_call_java(),
"can not load classes with compiler thread: class=%s, classloader=%s",
name->as_C_string(),
class_loader.is_null() ? "null" : class_loader->klass()->name()->as_C_string());
Expand Down Expand Up @@ -2056,7 +2056,7 @@ Method* SystemDictionary::find_method_handle_invoker(Klass* klass,
Klass* accessing_klass,
Handle* appendix_result,
TRAPS) {
assert(THREAD->can_call_java() ,"");
guarantee(THREAD->can_call_java(), "");
Handle method_type =
SystemDictionary::find_method_handle_type(signature, accessing_klass, CHECK_NULL);

Expand Down
Loading

0 comments on commit 55d3b7a

Please sign in to comment.