Path: blob/master/src/hotspot/share/runtime/abstract_vm_version.hpp
40951 views
/*1* Copyright (c) 1997, 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*22*/2324#ifndef SHARE_RUNTIME_ABSTRACT_VM_VERSION_HPP25#define SHARE_RUNTIME_ABSTRACT_VM_VERSION_HPP2627#include "memory/allocation.hpp" // For declaration of class AllStatic28#include "utilities/globalDefinitions.hpp"2930typedef enum {31NoDetectedVirtualization,32XenHVM,33KVM,34VMWare,35HyperV,36HyperVRole,37PowerVM, // on AIX or Linux ppc64(le)38PowerFullPartitionMode, // on Linux ppc64(le)39PowerKVM40} VirtualizationType;4142class outputStream;4344// Abstract_VM_Version provides information about the VM.4546class Abstract_VM_Version: AllStatic {47friend class VMStructs;48friend class JVMCIVMStructs;4950protected:51static const char* _s_vm_release;52static const char* _s_internal_vm_info_string;5354// CPU feature flags.55static uint64_t _features;56static const char* _features_string;5758// These are set by machine-dependent initializations59static bool _supports_cx8;60static bool _supports_atomic_getset4;61static bool _supports_atomic_getset8;62static bool _supports_atomic_getadd4;63static bool _supports_atomic_getadd8;64static unsigned int _logical_processors_per_package;65static unsigned int _L1_data_cache_line_size;66static int _vm_major_version;67static int _vm_minor_version;68static int _vm_security_version;69static int _vm_patch_version;70static int _vm_build_number;71static unsigned int _data_cache_line_flush_size;7273static VirtualizationType _detected_virtualization;7475public:76// Called as part of the runtime services initialization which is77// called from the management module initialization (via init_globals())78// after argument parsing and attaching of the main thread has79// occurred. Examines a variety of the hardware capabilities of80// the platform to determine which features can be used to execute the81// program.82static void initialize() { }8384// This allows for early initialization of VM_Version information85// that may be needed later in the initialization sequence but before86// full VM_Version initialization is possible. It can not depend on any87// other part of the VM being initialized when called. Platforms that88// need to specialize this define VM_Version::early_initialize().89static void early_initialize() { }9091// Called to initialize VM variables needing initialization92// after command line parsing. Platforms that need to specialize93// this should define VM_Version::init_before_ergo().94static void init_before_ergo() {}9596// Name97static const char* vm_name();98// Vendor99static const char* vm_vendor();100// VM version information string printed by launcher (java -version)101static const char* vm_info_string();102static const char* vm_release();103static const char* vm_platform_string();104static const char* vm_build_user();105106static int vm_major_version() { return _vm_major_version; }107static int vm_minor_version() { return _vm_minor_version; }108static int vm_security_version() { return _vm_security_version; }109static int vm_patch_version() { return _vm_patch_version; }110static int vm_build_number() { return _vm_build_number; }111112// Gets the jvm_version_info.jvm_version113static unsigned int jvm_version();114115// Internal version providing additional build information116static const char* internal_vm_info_string();117static const char* jre_release_version();118static const char* jdk_debug_level();119static const char* printable_jdk_debug_level();120121static uint64_t features() { return _features; }122static const char* features_string() { return _features_string; }123static void insert_features_names(char* buf, size_t buflen, const char* features_names[]);124125static VirtualizationType get_detected_virtualization() {126return _detected_virtualization;127}128129// platforms that need to specialize this130// define VM_Version::print_platform_virtualization_info()131static void print_platform_virtualization_info(outputStream*) { }132133// does HW support an 8-byte compare-exchange operation?134static bool supports_cx8() {135#ifdef SUPPORTS_NATIVE_CX8136return true;137#else138return _supports_cx8;139#endif140}141// does HW support atomic get-and-set or atomic get-and-add? Used142// to guide intrinsification decisions for Unsafe atomic ops143static bool supports_atomic_getset4() {return _supports_atomic_getset4;}144static bool supports_atomic_getset8() {return _supports_atomic_getset8;}145static bool supports_atomic_getadd4() {return _supports_atomic_getadd4;}146static bool supports_atomic_getadd8() {return _supports_atomic_getadd8;}147148static unsigned int logical_processors_per_package() {149return _logical_processors_per_package;150}151152static unsigned int L1_data_cache_line_size() {153return _L1_data_cache_line_size;154}155156// the size in bytes of a data cache line flushed by a flush157// operation which should be a power of two or zero if cache line158// writeback is not supported by the current os_cpu combination159static unsigned int data_cache_line_flush_size() {160return _data_cache_line_flush_size;161}162163// returns true if and only if cache line writeback is supported164static bool supports_data_cache_line_flush() {165return _data_cache_line_flush_size != 0;166}167168// ARCH specific policy for the BiasedLocking169static bool use_biased_locking() { return true; }170171// Number of page sizes efficiently supported by the hardware. Most chips now172// support two sizes, thus this default implementation. Processor-specific173// subclasses should define new versions to hide this one as needed. Note174// that the O/S may support more sizes, but at most this many are used.175static uint page_size_count() { return 2; }176177// Denominator for computing default ParallelGCThreads for machines with178// a large number of cores.179static uint parallel_worker_threads_denominator() { return 8; }180181// Does this CPU support spin wait instruction?182static bool supports_on_spin_wait() { return false; }183184// Does platform support fast class initialization checks for static methods?185static bool supports_fast_class_init_checks() { return false; }186187// Does platform support stack watermark barriers for concurrent stack processing?188constexpr static bool supports_stack_watermark_barrier() { return false; }189190static bool print_matching_lines_from_file(const char* filename, outputStream* st, const char* keywords_to_match[]);191};192193#endif // SHARE_RUNTIME_ABSTRACT_VM_VERSION_HPP194195196