Path: blob/master/src/hotspot/share/jvmci/jvmci.hpp
64440 views
/*1* Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223#ifndef SHARE_JVMCI_JVMCI_HPP24#define SHARE_JVMCI_JVMCI_HPP2526#include "compiler/compiler_globals.hpp"27#include "compiler/compilerDefinitions.hpp"28#include "utilities/exceptions.hpp"2930class BoolObjectClosure;31class constantPoolHandle;32class JavaThread;33class JVMCIEnv;34class JVMCIRuntime;35class Metadata;36class MetadataHandleBlock;37class OopClosure;38class OopStorage;3940template <size_t>41class FormatStringEventLog;4243typedef FormatStringEventLog<256> StringEventLog;4445struct _jmetadata;46typedef struct _jmetadata *jmetadata;4748class JVMCI : public AllStatic {49friend class JVMCIRuntime;50friend class JVMCIEnv;5152private:53// Access to the HotSpotJVMCIRuntime used by the CompileBroker.54static JVMCIRuntime* _compiler_runtime;5556// True when at least one JVMCIRuntime::initialize_HotSpotJVMCIRuntime()57// execution has completed successfully.58static volatile bool _is_initialized;5960// True once boxing cache classes are guaranteed to be initialized.61static bool _box_caches_initialized;6263// Handle created when loading the JVMCI shared library with os::dll_load.64// Must hold JVMCI_lock when initializing.65static void* _shared_library_handle;6667// Argument to os::dll_load when loading JVMCI shared library68static char* _shared_library_path;6970// Records whether JVMCI::shutdown has been called.71static volatile bool _in_shutdown;7273// Access to the HotSpot heap based JVMCIRuntime74static JVMCIRuntime* _java_runtime;7576// JVMCI event log (shows up in hs_err crash logs).77static StringEventLog* _events;78static StringEventLog* _verbose_events;79enum {80max_EventLog_level = 481};8283// Gets the Thread* value for the current thread or NULL if it's not available.84static Thread* current_thread_or_null();8586public:87enum CodeInstallResult {88ok,89dependencies_failed,90cache_full,91nmethod_reclaimed, // code cache sweeper reclaimed nmethod in between its creation and being marked "in_use"92code_too_large,93first_permanent_bailout = code_too_large94};9596// Gets the handle to the loaded JVMCI shared library, loading it97// first if not yet loaded and `load` is true. The path from98// which the library is loaded is returned in `path`. If99// `load` is true then JVMCI_lock must be locked.100static void* get_shared_library(char*& path, bool load);101102static void do_unloading(bool unloading_occurred);103104static void metadata_do(void f(Metadata*));105106static void shutdown();107108// Returns whether JVMCI::shutdown has been called.109static bool in_shutdown();110111static bool is_compiler_initialized();112113/**114* Determines if the VM is sufficiently booted to initialize JVMCI.115*/116static bool can_initialize_JVMCI();117118static void initialize_globals();119120static void initialize_compiler(TRAPS);121122// Ensures the boxing cache classes (e.g., java.lang.Integer.IntegerCache) are initialized.123static void ensure_box_caches_initialized(TRAPS);124125// Increments a value indicating some JVMCI compilation activity126// happened on `thread` if it is a CompilerThread.127// Returns `thread`.128static JavaThread* compilation_tick(JavaThread* thread);129130static JVMCIRuntime* compiler_runtime() { return _compiler_runtime; }131// Gets the single runtime for JVMCI on the Java heap. This is the only132// JVMCI runtime available when !UseJVMCINativeLibrary.133static JVMCIRuntime* java_runtime() { return _java_runtime; }134135// Appends an event to the JVMCI event log if JVMCIEventLogLevel >= `level`136static void vlog(int level, const char* format, va_list ap) ATTRIBUTE_PRINTF(2, 0);137138// Traces an event to tty if JVMCITraceLevel >= `level`139static void vtrace(int level, const char* format, va_list ap) ATTRIBUTE_PRINTF(2, 0);140141public:142// Log/trace a JVMCI event143static void event(int level, const char* format, ...) ATTRIBUTE_PRINTF(2, 3);144static void event1(const char* format, ...) ATTRIBUTE_PRINTF(1, 2);145static void event2(const char* format, ...) ATTRIBUTE_PRINTF(1, 2);146static void event3(const char* format, ...) ATTRIBUTE_PRINTF(1, 2);147static void event4(const char* format, ...) ATTRIBUTE_PRINTF(1, 2);148};149150// JVMCI event macros.151#define JVMCI_event_1 if (JVMCITraceLevel < 1 && JVMCIEventLogLevel < 1) ; else ::JVMCI::event1152#define JVMCI_event_2 if (JVMCITraceLevel < 2 && JVMCIEventLogLevel < 2) ; else ::JVMCI::event2153#define JVMCI_event_3 if (JVMCITraceLevel < 3 && JVMCIEventLogLevel < 3) ; else ::JVMCI::event3154#define JVMCI_event_4 if (JVMCITraceLevel < 4 && JVMCIEventLogLevel < 4) ; else ::JVMCI::event4155156#endif // SHARE_JVMCI_JVMCI_HPP157158159