src/share/vm/runtime/vm_version.cpp

Tue, 24 Jul 2012 10:51:00 -0700

author
twisti
date
Tue, 24 Jul 2012 10:51:00 -0700
changeset 3969
1d7922586cf6
parent 3517
c77d473e71f7
child 4106
7eca5de9e0b6
permissions
-rw-r--r--

7023639: JSR 292 method handle invocation needs a fast path for compiled code
6984705: JSR 292 method handle creation should not go through JNI
Summary: remove assembly code for JDK 7 chained method handles
Reviewed-by: jrose, twisti, kvn, mhaupt
Contributed-by: John Rose <john.r.rose@oracle.com>, Christian Thalinger <christian.thalinger@oracle.com>, Michael Haupt <michael.haupt@oracle.com>

duke@435 1 /*
trims@2708 2 * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
stefank@2314 25 #include "precompiled.hpp"
stefank@2314 26 #include "memory/universe.hpp"
stefank@2314 27 #include "oops/oop.inline.hpp"
stefank@2314 28 #include "runtime/arguments.hpp"
stefank@2314 29 #ifdef TARGET_ARCH_x86
stefank@2314 30 # include "vm_version_x86.hpp"
stefank@2314 31 #endif
stefank@2314 32 #ifdef TARGET_ARCH_sparc
stefank@2314 33 # include "vm_version_sparc.hpp"
stefank@2314 34 #endif
stefank@2314 35 #ifdef TARGET_ARCH_zero
stefank@2314 36 # include "vm_version_zero.hpp"
stefank@2314 37 #endif
bobv@2508 38 #ifdef TARGET_ARCH_arm
bobv@2508 39 # include "vm_version_arm.hpp"
bobv@2508 40 #endif
bobv@2508 41 #ifdef TARGET_ARCH_ppc
bobv@2508 42 # include "vm_version_ppc.hpp"
bobv@2508 43 #endif
duke@435 44
duke@435 45 const char* Abstract_VM_Version::_s_vm_release = Abstract_VM_Version::vm_release();
duke@435 46 const char* Abstract_VM_Version::_s_internal_vm_info_string = Abstract_VM_Version::internal_vm_info_string();
duke@435 47 bool Abstract_VM_Version::_supports_cx8 = false;
duke@435 48 unsigned int Abstract_VM_Version::_logical_processors_per_package = 1U;
kvn@3052 49 int Abstract_VM_Version::_reserve_for_allocation_prefetch = 0;
duke@435 50
duke@435 51 #ifndef HOTSPOT_RELEASE_VERSION
duke@435 52 #error HOTSPOT_RELEASE_VERSION must be defined
duke@435 53 #endif
duke@435 54 #ifndef JRE_RELEASE_VERSION
duke@435 55 #error JRE_RELEASE_VERSION must be defined
duke@435 56 #endif
duke@435 57 #ifndef HOTSPOT_BUILD_TARGET
duke@435 58 #error HOTSPOT_BUILD_TARGET must be defined
duke@435 59 #endif
duke@435 60
duke@435 61 #ifdef PRODUCT
duke@435 62 #define VM_RELEASE HOTSPOT_RELEASE_VERSION
duke@435 63 #else
duke@435 64 #define VM_RELEASE HOTSPOT_RELEASE_VERSION "-" HOTSPOT_BUILD_TARGET
duke@435 65 #endif
duke@435 66
duke@435 67 // HOTSPOT_RELEASE_VERSION must follow the release version naming convention
duke@435 68 // <major_ver>.<minor_ver>-b<nn>[-<identifier>][-<debug_target>]
duke@435 69 int Abstract_VM_Version::_vm_major_version = 0;
duke@435 70 int Abstract_VM_Version::_vm_minor_version = 0;
duke@435 71 int Abstract_VM_Version::_vm_build_number = 0;
duke@435 72 bool Abstract_VM_Version::_initialized = false;
jmasa@445 73 int Abstract_VM_Version::_parallel_worker_threads = 0;
jmasa@445 74 bool Abstract_VM_Version::_parallel_worker_threads_initialized = false;
duke@435 75
duke@435 76 void Abstract_VM_Version::initialize() {
duke@435 77 if (_initialized) {
duke@435 78 return;
duke@435 79 }
duke@435 80 char* vm_version = os::strdup(HOTSPOT_RELEASE_VERSION);
duke@435 81
duke@435 82 // Expecting the next vm_version format:
duke@435 83 // <major_ver>.<minor_ver>-b<nn>[-<identifier>]
duke@435 84 char* vm_major_ver = vm_version;
duke@435 85 assert(isdigit(vm_major_ver[0]),"wrong vm major version number");
duke@435 86 char* vm_minor_ver = strchr(vm_major_ver, '.');
duke@435 87 assert(vm_minor_ver != NULL && isdigit(vm_minor_ver[1]),"wrong vm minor version number");
duke@435 88 vm_minor_ver[0] = '\0'; // terminate vm_major_ver
duke@435 89 vm_minor_ver += 1;
duke@435 90 char* vm_build_num = strchr(vm_minor_ver, '-');
duke@435 91 assert(vm_build_num != NULL && vm_build_num[1] == 'b' && isdigit(vm_build_num[2]),"wrong vm build number");
duke@435 92 vm_build_num[0] = '\0'; // terminate vm_minor_ver
duke@435 93 vm_build_num += 2;
duke@435 94
duke@435 95 _vm_major_version = atoi(vm_major_ver);
duke@435 96 _vm_minor_version = atoi(vm_minor_ver);
duke@435 97 _vm_build_number = atoi(vm_build_num);
duke@435 98
duke@435 99 os::free(vm_version);
duke@435 100 _initialized = true;
duke@435 101 }
duke@435 102
duke@435 103 #if defined(_LP64)
duke@435 104 #define VMLP "64-Bit "
duke@435 105 #else
duke@435 106 #define VMLP ""
duke@435 107 #endif
duke@435 108
duke@435 109 #ifdef KERNEL
duke@435 110 #define VMTYPE "Kernel"
duke@435 111 #else // KERNEL
duke@435 112 #ifdef TIERED
duke@435 113 #define VMTYPE "Server"
never@1445 114 #else // TIERED
never@1445 115 #ifdef ZERO
twisti@2047 116 #ifdef SHARK
twisti@2047 117 #define VMTYPE "Shark"
twisti@2047 118 #else // SHARK
never@1445 119 #define VMTYPE "Zero"
twisti@2047 120 #endif // SHARK
never@1445 121 #else // ZERO
never@1445 122 #define VMTYPE COMPILER1_PRESENT("Client") \
never@1445 123 COMPILER2_PRESENT("Server")
never@1445 124 #endif // ZERO
duke@435 125 #endif // TIERED
duke@435 126 #endif // KERNEL
duke@435 127
duke@435 128 #ifndef HOTSPOT_VM_DISTRO
duke@435 129 #error HOTSPOT_VM_DISTRO must be defined
duke@435 130 #endif
dholmes@3201 131 #define VMNAME HOTSPOT_VM_DISTRO " " VMLP EMBEDDED_ONLY("Embedded ") VMTYPE " VM"
duke@435 132
duke@435 133 const char* Abstract_VM_Version::vm_name() {
duke@435 134 return VMNAME;
duke@435 135 }
duke@435 136
duke@435 137
duke@435 138 const char* Abstract_VM_Version::vm_vendor() {
duke@435 139 #ifdef VENDOR
duke@435 140 return XSTR(VENDOR);
duke@435 141 #else
zgu@2155 142 return JDK_Version::is_gte_jdk17x_version() ?
zgu@2155 143 "Oracle Corporation" : "Sun Microsystems Inc.";
duke@435 144 #endif
duke@435 145 }
duke@435 146
duke@435 147
duke@435 148 const char* Abstract_VM_Version::vm_info_string() {
duke@435 149 switch (Arguments::mode()) {
duke@435 150 case Arguments::_int:
duke@435 151 return UseSharedSpaces ? "interpreted mode, sharing" : "interpreted mode";
duke@435 152 case Arguments::_mixed:
duke@435 153 return UseSharedSpaces ? "mixed mode, sharing" : "mixed mode";
duke@435 154 case Arguments::_comp:
duke@435 155 return UseSharedSpaces ? "compiled mode, sharing" : "compiled mode";
duke@435 156 };
duke@435 157 ShouldNotReachHere();
duke@435 158 return "";
duke@435 159 }
duke@435 160
duke@435 161 // NOTE: do *not* use stringStream. this function is called by
duke@435 162 // fatal error handler. if the crash is in native thread,
duke@435 163 // stringStream cannot get resource allocated and will SEGV.
duke@435 164 const char* Abstract_VM_Version::vm_release() {
duke@435 165 return VM_RELEASE;
duke@435 166 }
duke@435 167
ohrstrom@3517 168 // NOTE: do *not* use stringStream. this function is called by
ohrstrom@3517 169 // fatal error handlers. if the crash is in native thread,
ohrstrom@3517 170 // stringStream cannot get resource allocated and will SEGV.
ohrstrom@3517 171 const char* Abstract_VM_Version::jre_release_version() {
ohrstrom@3517 172 return JRE_RELEASE_VERSION;
ohrstrom@3517 173 }
ohrstrom@3517 174
duke@435 175 #define OS LINUX_ONLY("linux") \
duke@435 176 WINDOWS_ONLY("windows") \
never@3156 177 SOLARIS_ONLY("solaris") \
never@3156 178 BSD_ONLY("bsd")
duke@435 179
never@1445 180 #ifdef ZERO
never@1445 181 #define CPU ZERO_LIBARCH
never@1445 182 #else
duke@435 183 #define CPU IA32_ONLY("x86") \
duke@435 184 IA64_ONLY("ia64") \
duke@435 185 AMD64_ONLY("amd64") \
bobv@2036 186 ARM_ONLY("arm") \
bobv@2036 187 PPC_ONLY("ppc") \
duke@435 188 SPARC_ONLY("sparc")
never@1445 189 #endif // ZERO
duke@435 190
duke@435 191 const char *Abstract_VM_Version::vm_platform_string() {
duke@435 192 return OS "-" CPU;
duke@435 193 }
duke@435 194
duke@435 195 const char* Abstract_VM_Version::internal_vm_info_string() {
duke@435 196 #ifndef HOTSPOT_BUILD_USER
duke@435 197 #define HOTSPOT_BUILD_USER unknown
duke@435 198 #endif
duke@435 199
duke@435 200 #ifndef HOTSPOT_BUILD_COMPILER
duke@435 201 #ifdef _MSC_VER
duke@435 202 #if _MSC_VER == 1100
duke@435 203 #define HOTSPOT_BUILD_COMPILER "MS VC++ 5.0"
duke@435 204 #elif _MSC_VER == 1200
duke@435 205 #define HOTSPOT_BUILD_COMPILER "MS VC++ 6.0"
duke@435 206 #elif _MSC_VER == 1310
kvn@1080 207 #define HOTSPOT_BUILD_COMPILER "MS VC++ 7.1 (VS2003)"
duke@435 208 #elif _MSC_VER == 1400
kvn@1080 209 #define HOTSPOT_BUILD_COMPILER "MS VC++ 8.0 (VS2005)"
kvn@1080 210 #elif _MSC_VER == 1500
kvn@1080 211 #define HOTSPOT_BUILD_COMPILER "MS VC++ 9.0 (VS2008)"
duke@435 212 #else
duke@435 213 #define HOTSPOT_BUILD_COMPILER "unknown MS VC++:" XSTR(_MSC_VER)
duke@435 214 #endif
duke@435 215 #elif defined(__SUNPRO_CC)
duke@435 216 #if __SUNPRO_CC == 0x420
duke@435 217 #define HOTSPOT_BUILD_COMPILER "Workshop 4.2"
duke@435 218 #elif __SUNPRO_CC == 0x500
duke@435 219 #define HOTSPOT_BUILD_COMPILER "Workshop 5.0 compat=" XSTR(__SUNPRO_CC_COMPAT)
duke@435 220 #elif __SUNPRO_CC == 0x520
duke@435 221 #define HOTSPOT_BUILD_COMPILER "Workshop 5.2 compat=" XSTR(__SUNPRO_CC_COMPAT)
duke@435 222 #elif __SUNPRO_CC == 0x580
duke@435 223 #define HOTSPOT_BUILD_COMPILER "Workshop 5.8"
duke@435 224 #elif __SUNPRO_CC == 0x590
duke@435 225 #define HOTSPOT_BUILD_COMPILER "Workshop 5.9"
jcoomes@1902 226 #elif __SUNPRO_CC == 0x5100
jcoomes@1902 227 #define HOTSPOT_BUILD_COMPILER "Sun Studio 12u1"
duke@435 228 #else
duke@435 229 #define HOTSPOT_BUILD_COMPILER "unknown Workshop:" XSTR(__SUNPRO_CC)
duke@435 230 #endif
duke@435 231 #elif defined(__GNUC__)
duke@435 232 #define HOTSPOT_BUILD_COMPILER "gcc " __VERSION__
duke@435 233 #else
duke@435 234 #define HOTSPOT_BUILD_COMPILER "unknown compiler"
duke@435 235 #endif
duke@435 236 #endif
duke@435 237
bobv@2508 238 #ifndef FLOAT_ARCH
bobv@2508 239 #if defined(__SOFTFP__)
bobv@2508 240 #define FLOAT_ARCH "-sflt"
bobv@2508 241 #elif defined(E500V2)
bobv@2508 242 #define FLOAT_ARCH "-e500v2"
bobv@2508 243 #elif defined(ARM)
bobv@2508 244 #define FLOAT_ARCH "-vfp"
bobv@2508 245 #elif defined(PPC)
bobv@2508 246 #define FLOAT_ARCH "-hflt"
bobv@2508 247 #else
bobv@2508 248 #define FLOAT_ARCH ""
bobv@2508 249 #endif
bobv@2508 250 #endif
duke@435 251
bobv@2508 252 return VMNAME " (" VM_RELEASE ") for " OS "-" CPU FLOAT_ARCH
duke@435 253 " JRE (" JRE_RELEASE_VERSION "), built on " __DATE__ " " __TIME__
duke@435 254 " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER;
duke@435 255 }
duke@435 256
kamg@2515 257 const char *Abstract_VM_Version::vm_build_user() {
kamg@2515 258 return HOTSPOT_BUILD_USER;
kamg@2515 259 }
kamg@2515 260
duke@435 261 unsigned int Abstract_VM_Version::jvm_version() {
duke@435 262 return ((Abstract_VM_Version::vm_major_version() & 0xFF) << 24) |
duke@435 263 ((Abstract_VM_Version::vm_minor_version() & 0xFF) << 16) |
duke@435 264 (Abstract_VM_Version::vm_build_number() & 0xFF);
duke@435 265 }
duke@435 266
duke@435 267
duke@435 268 void VM_Version_init() {
duke@435 269 VM_Version::initialize();
duke@435 270
duke@435 271 #ifndef PRODUCT
duke@435 272 if (PrintMiscellaneous && Verbose) {
duke@435 273 os::print_cpu_info(tty);
duke@435 274 }
duke@435 275 #endif
duke@435 276 }
jmasa@445 277
jmasa@445 278 unsigned int Abstract_VM_Version::nof_parallel_worker_threads(
jmasa@445 279 unsigned int num,
jmasa@445 280 unsigned int den,
jmasa@445 281 unsigned int switch_pt) {
jmasa@445 282 if (FLAG_IS_DEFAULT(ParallelGCThreads)) {
jmasa@445 283 assert(ParallelGCThreads == 0, "Default ParallelGCThreads is not 0");
jmasa@445 284 // For very large machines, there are diminishing returns
jmasa@445 285 // for large numbers of worker threads. Instead of
jmasa@445 286 // hogging the whole system, use a fraction of the workers for every
jmasa@445 287 // processor after the first 8. For example, on a 72 cpu machine
jmasa@445 288 // and a chosen fraction of 5/8
jmasa@445 289 // use 8 + (72 - 8) * (5/8) == 48 worker threads.
jmasa@445 290 unsigned int ncpus = (unsigned int) os::active_processor_count();
jmasa@445 291 return (ncpus <= switch_pt) ?
jmasa@445 292 ncpus :
jmasa@445 293 (switch_pt + ((ncpus - switch_pt) * num) / den);
jmasa@445 294 } else {
jmasa@445 295 return ParallelGCThreads;
jmasa@445 296 }
jmasa@445 297 }
jmasa@445 298
jmasa@445 299 unsigned int Abstract_VM_Version::calc_parallel_worker_threads() {
jmasa@445 300 return nof_parallel_worker_threads(5, 8, 8);
jmasa@445 301 }
jmasa@445 302
jmasa@445 303
jmasa@445 304 // Does not set the _initialized flag since it is
jmasa@445 305 // a global flag.
jmasa@445 306 unsigned int Abstract_VM_Version::parallel_worker_threads() {
jmasa@445 307 if (!_parallel_worker_threads_initialized) {
jmasa@445 308 if (FLAG_IS_DEFAULT(ParallelGCThreads)) {
jmasa@445 309 _parallel_worker_threads = VM_Version::calc_parallel_worker_threads();
jmasa@445 310 } else {
jmasa@445 311 _parallel_worker_threads = ParallelGCThreads;
jmasa@445 312 }
jmasa@445 313 _parallel_worker_threads_initialized = true;
jmasa@445 314 }
jmasa@445 315 return _parallel_worker_threads;
jmasa@445 316 }

mercurial