Skip to content

Commit

Permalink
8315818: vmTestbase/nsk/jvmti/Allocate/alloc001/alloc001.java fails o…
Browse files Browse the repository at this point in the history
…n libgraal

Reviewed-by: never
  • Loading branch information
Doug Simon committed Sep 8, 2023
1 parent 4a6bd81 commit ebc718f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 22 deletions.
13 changes: 7 additions & 6 deletions src/hotspot/share/compiler/compileBroker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1320,6 +1320,13 @@ nmethod* CompileBroker::compile_method(const methodHandle& method, int osr_bci,
AbstractCompiler *comp = CompileBroker::compiler(comp_level);
assert(comp != nullptr, "Ensure we have a compiler");

#if INCLUDE_JVMCI
if (comp->is_jvmci() && !JVMCI::can_initialize_JVMCI()) {
// JVMCI compilation is not yet initializable.
return nullptr;
}
#endif

DirectiveSet* directive = DirectivesStack::getMatchingDirective(method, comp);
// CompileBroker::compile_method can trap and can have pending async exception.
nmethod* nm = CompileBroker::compile_method(method, osr_bci, comp_level, hot_method, hot_count, compile_reason, directive, THREAD);
Expand Down Expand Up @@ -1348,12 +1355,6 @@ nmethod* CompileBroker::compile_method(const methodHandle& method, int osr_bci,
return nullptr;
}

#if INCLUDE_JVMCI
if (comp->is_jvmci() && !JVMCI::can_initialize_JVMCI()) {
return nullptr;
}
#endif

if (osr_bci == InvocationEntryBci) {
// standard compilation
CompiledMethod* method_code = method->code();
Expand Down
3 changes: 2 additions & 1 deletion src/hotspot/share/compiler/compileBroker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ class CompileBroker: AllStatic {
int hot_count,
CompileTask::CompileReason compile_reason,
TRAPS);

private:
static nmethod* compile_method(const methodHandle& method,
int osr_bci,
int comp_level,
Expand All @@ -311,6 +311,7 @@ class CompileBroker: AllStatic {
DirectiveSet* directive,
TRAPS);

public:
// Acquire any needed locks and assign a compile id
static int assign_compile_id_unlocked(Thread* thread, const methodHandle& method, int osr_bci);

Expand Down
5 changes: 5 additions & 0 deletions src/hotspot/share/jvmci/jvmci.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ const char* JVMCI::_fatal_log_filename = nullptr;
void jvmci_vmStructs_init() NOT_DEBUG_RETURN;

bool JVMCI::can_initialize_JVMCI() {
if (UseJVMCINativeLibrary) {
// Initializing libjvmci does not execute Java code so
// can be done any time.
return true;
}
// Initializing JVMCI requires the module system to be initialized past phase 3.
// The JVMCI API itself isn't available until phase 2 and ServiceLoader (which
// JVMCI initialization requires) isn't usable until after phase 3. Testing
Expand Down
19 changes: 4 additions & 15 deletions src/hotspot/share/runtime/threads.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -693,25 +693,15 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) {
// initialize compiler(s)
#if defined(COMPILER1) || COMPILER2_OR_JVMCI
#if INCLUDE_JVMCI
bool force_JVMCI_intialization = false;
bool force_JVMCI_initialization = false;
if (EnableJVMCI) {
// Initialize JVMCI eagerly when it is explicitly requested.
// Or when JVMCILibDumpJNIConfig or JVMCIPrintProperties is enabled.
force_JVMCI_intialization = EagerJVMCI || JVMCIPrintProperties || JVMCILibDumpJNIConfig;

if (!force_JVMCI_intialization) {
// 8145270: Force initialization of JVMCI runtime otherwise requests for blocking
// compilations via JVMCI will not actually block until JVMCI is initialized.
force_JVMCI_intialization = UseJVMCICompiler && (!UseInterpreter || !BackgroundCompilation);
}
force_JVMCI_initialization = EagerJVMCI || JVMCIPrintProperties || JVMCILibDumpJNIConfig;
}
#endif
CompileBroker::compilation_init_phase1(CHECK_JNI_ERR);
// Postpone completion of compiler initialization to after JVMCI
// is initialized to avoid timeouts of blocking compilations.
if (JVMCI_ONLY(!force_JVMCI_intialization) NOT_JVMCI(true)) {
CompileBroker::compilation_init_phase2();
}
CompileBroker::compilation_init_phase2();
#endif

// Start string deduplication thread if requested.
Expand Down Expand Up @@ -754,9 +744,8 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) {
#endif

#if INCLUDE_JVMCI
if (force_JVMCI_intialization) {
if (force_JVMCI_initialization) {
JVMCI::initialize_compiler(CHECK_JNI_ERR);
CompileBroker::compilation_init_phase2();
}
#endif

Expand Down

1 comment on commit ebc718f

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.