Path: blob/master/src/hotspot/share/jvmci/jvmci.hpp
40949 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,91code_too_large92};9394// Gets the handle to the loaded JVMCI shared library, loading it95// first if not yet loaded and `load` is true. The path from96// which the library is loaded is returned in `path`. If97// `load` is true then JVMCI_lock must be locked.98static void* get_shared_library(char*& path, bool load);99100static void do_unloading(bool unloading_occurred);101102static void metadata_do(void f(Metadata*));103104static void shutdown();105106// Returns whether JVMCI::shutdown has been called.107static bool in_shutdown();108109static bool is_compiler_initialized();110111/**112* Determines if the VM is sufficiently booted to initialize JVMCI.113*/114static bool can_initialize_JVMCI();115116static void initialize_globals();117118static void initialize_compiler(TRAPS);119120// Ensures the boxing cache classes (e.g., java.lang.Integer.IntegerCache) are initialized.121static void ensure_box_caches_initialized(TRAPS);122123// Increments a value indicating some JVMCI compilation activity124// happened on `thread` if it is a CompilerThread.125// Returns `thread`.126static JavaThread* compilation_tick(JavaThread* thread);127128static JVMCIRuntime* compiler_runtime() { return _compiler_runtime; }129// Gets the single runtime for JVMCI on the Java heap. This is the only130// JVMCI runtime available when !UseJVMCINativeLibrary.131static JVMCIRuntime* java_runtime() { return _java_runtime; }132133// Appends an event to the JVMCI event log if JVMCIEventLogLevel >= `level`134static void vlog(int level, const char* format, va_list ap) ATTRIBUTE_PRINTF(2, 0);135136// Traces an event to tty if JVMCITraceLevel >= `level`137static void vtrace(int level, const char* format, va_list ap) ATTRIBUTE_PRINTF(2, 0);138139public:140// Log/trace a JVMCI event141static void event(int level, const char* format, ...) ATTRIBUTE_PRINTF(2, 3);142static void event1(const char* format, ...) ATTRIBUTE_PRINTF(1, 2);143static void event2(const char* format, ...) ATTRIBUTE_PRINTF(1, 2);144static void event3(const char* format, ...) ATTRIBUTE_PRINTF(1, 2);145static void event4(const char* format, ...) ATTRIBUTE_PRINTF(1, 2);146};147148// JVMCI event macros.149#define JVMCI_event_1 if (JVMCITraceLevel < 1 && JVMCIEventLogLevel < 1) ; else ::JVMCI::event1150#define JVMCI_event_2 if (JVMCITraceLevel < 2 && JVMCIEventLogLevel < 2) ; else ::JVMCI::event2151#define JVMCI_event_3 if (JVMCITraceLevel < 3 && JVMCIEventLogLevel < 3) ; else ::JVMCI::event3152#define JVMCI_event_4 if (JVMCITraceLevel < 4 && JVMCIEventLogLevel < 4) ; else ::JVMCI::event4153154#endif // SHARE_JVMCI_JVMCI_HPP155156157