vm_version.hpp revision 5776:de6a9e811145
12606Sdfr/*
22606Sdfr * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
331603Syokota * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
42606Sdfr *
52606Sdfr * This code is free software; you can redistribute it and/or modify it
62606Sdfr * under the terms of the GNU General Public License version 2 only, as
72606Sdfr * published by the Free Software Foundation.
82606Sdfr *
92606Sdfr * This code is distributed in the hope that it will be useful, but WITHOUT
102606Sdfr * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
112606Sdfr * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
122606Sdfr * version 2 for more details (a copy is included in the LICENSE file that
132606Sdfr * accompanied this code).
142606Sdfr *
152606Sdfr * You should have received a copy of the GNU General Public License version
162606Sdfr * 2 along with this work; if not, write to the Free Software Foundation,
172606Sdfr * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
182606Sdfr *
192606Sdfr * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202606Sdfr * or visit www.oracle.com if you need additional information or have any
212606Sdfr * questions.
222606Sdfr *
2349964Syokota */
242606Sdfr
252606Sdfr#ifndef SHARE_VM_RUNTIME_VM_VERSION_HPP
2619753Ssos#define SHARE_VM_RUNTIME_VM_VERSION_HPP
2719753Ssos
2819753Ssos#include "memory/allocation.hpp"
2919753Ssos#include "utilities/ostream.hpp"
3019753Ssos
3119753Ssos// VM_Version provides information about the VM.
3231603Syokota
3331603Syokotaclass Abstract_VM_Version: AllStatic {
3431603Syokota protected:
3531603Syokota  friend class VMStructs;
3631603Syokota  static const char*  _s_vm_release;
3731603Syokota  static const char*  _s_internal_vm_info_string;
3831603Syokota  // These are set by machine-dependent initializations
3931603Syokota  static bool         _supports_cx8;
4031603Syokota  static bool         _supports_atomic_getset4;
4131603Syokota  static bool         _supports_atomic_getset8;
4231603Syokota  static bool         _supports_atomic_getadd4;
4319753Ssos  static bool         _supports_atomic_getadd8;
4431603Syokota  static unsigned int _logical_processors_per_package;
4531603Syokota  static int          _vm_major_version;
4631603Syokota  static int          _vm_minor_version;
4731603Syokota  static int          _vm_build_number;
4831603Syokota  static bool         _initialized;
4931603Syokota  static int          _parallel_worker_threads;
5019753Ssos  static bool         _parallel_worker_threads_initialized;
5120073Ssos  static int          _reserve_for_allocation_prefetch;
5220073Ssos
5331603Syokota  static unsigned int nof_parallel_worker_threads(unsigned int num,
5420073Ssos                                                  unsigned int dem,
5520073Ssos                                                  unsigned int switch_pt);
5620073Ssos public:
5720073Ssos  static void initialize();
5831603Syokota
5920073Ssos  // Name
6021327Snate  static const char* vm_name();
6120073Ssos  // Vendor
6220073Ssos  static const char* vm_vendor();
6320073Ssos  // VM version information string printed by launcher (java -version)
6420073Ssos  static const char* vm_info_string();
6520073Ssos  static const char* vm_release();
6620073Ssos  static const char* vm_platform_string();
6720073Ssos  static const char* vm_build_user();
6820073Ssos
6920073Ssos  static int vm_major_version()               { assert(_initialized, "not initialized"); return _vm_major_version; }
7031603Syokota  static int vm_minor_version()               { assert(_initialized, "not initialized"); return _vm_minor_version; }
7131603Syokota  static int vm_build_number()                { assert(_initialized, "not initialized"); return _vm_build_number; }
7231603Syokota
7331603Syokota  // Gets the jvm_version_info.jvm_version defined in jvm.h
7420073Ssos  static unsigned int jvm_version();
7531603Syokota
7631603Syokota  // Internal version providing additional build information
7731603Syokota  static const char* internal_vm_info_string();
7831603Syokota  static const char* jre_release_version();
7931603Syokota
8031603Syokota  // does HW support an 8-byte compare-exchange operation?
8119753Ssos  static bool supports_cx8()  {
8231603Syokota#ifdef SUPPORTS_NATIVE_CX8
8319753Ssos    return true;
8419753Ssos#else
8531603Syokota    return _supports_cx8;
8619753Ssos#endif
8721327Snate  }
8821327Snate  // does HW support atomic get-and-set or atomic get-and-add?  Used
8919753Ssos  // to guide intrinsification decisions for Unsafe atomic ops
9021327Snate  static bool supports_atomic_getset4()  {return _supports_atomic_getset4;}
9119753Ssos  static bool supports_atomic_getset8()  {return _supports_atomic_getset8;}
9231603Syokota  static bool supports_atomic_getadd4()  {return _supports_atomic_getadd4;}
9319753Ssos  static bool supports_atomic_getadd8()  {return _supports_atomic_getadd8;}
9419753Ssos
9519753Ssos  static unsigned int logical_processors_per_package() {
9619753Ssos    return _logical_processors_per_package;
9731603Syokota  }
9844186Sn_hibma
9921327Snate  // Need a space at the end of TLAB for prefetch instructions
10019753Ssos  // which may fault when accessing memory outside of heap.
10119753Ssos  static int reserve_for_allocation_prefetch() {
10219753Ssos    return _reserve_for_allocation_prefetch;
10319753Ssos  }
10419753Ssos
10519753Ssos  // ARCH specific policy for the BiasedLocking
1062606Sdfr  static bool use_biased_locking()  { return true; }
10731603Syokota
10831603Syokota  // Number of page sizes efficiently supported by the hardware.  Most chips now
10931603Syokota  // support two sizes, thus this default implementation.  Processor-specific
11031603Syokota  // subclasses should define new versions to hide this one as needed.  Note
11131603Syokota  // that the O/S may support more sizes, but at most this many are used.
11231603Syokota  static uint page_size_count() { return 2; }
11331603Syokota
11431603Syokota  // Returns the number of parallel threads to be used for VM
11531603Syokota  // work.  If that number has not been calculated, do so and
11631603Syokota  // save it.  Returns ParallelGCThreads if it is set on the
11741271Syokota  // command line.
11849964Syokota  static unsigned int parallel_worker_threads();
11931603Syokota  // Calculates and returns the number of parallel threads.  May
12019753Ssos  // be VM version specific.
12119753Ssos  static unsigned int calc_parallel_worker_threads();
12219753Ssos};
12331603Syokota
12419753Ssos#endif // SHARE_VM_RUNTIME_VM_VERSION_HPP
12531603Syokota