8087202: Add support for PATCH field and remove unused fields of new version string

Reviewed-by: dholmes, alanb
This commit is contained in:
Alejandro Murillo 2015-06-19 10:34:38 -07:00
parent 23dd2e12b1
commit ab8dd89e95
18 changed files with 65 additions and 189 deletions
hotspot

@ -55,6 +55,7 @@
# VERSION_MAJOR Major number for version (e.g. 9)
# VERSION_MINOR Minor number for version (e.g. 0)
# VERSION_SECURITY Security number for version (e.g. 0)
# VERSION_PATCH Patch number for version (e.g. 0)
#
# Default is build both product fastdebug and create export area

@ -77,6 +77,7 @@ endif
JDK_VER_DEFS = -DVERSION_MAJOR=$(VERSION_MAJOR) \
-DVERSION_MINOR=$(VERSION_MINOR) \
-DVERSION_SECURITY=$(VERSION_SECURITY) \
-DVERSION_PATCH=$(VERSION_PATCH) \
-DVERSION_BUILD=$(VERSION_BUILD)
VM_VER_DEFS = -DHOTSPOT_VERSION_STRING="\"$(HOTSPOT_VERSION_STRING)\"" \
-DVERSION_STRING="\"$(VERSION_STRING)\"" \

@ -76,6 +76,7 @@ endif
JDK_VER_DEFS = -DVERSION_MAJOR=$(VERSION_MAJOR) \
-DVERSION_MINOR=$(VERSION_MINOR) \
-DVERSION_SECURITY=$(VERSION_SECURITY) \
-DVERSION_PATCH=$(VERSION_PATCH) \
-DVERSION_BUILD=$(VERSION_BUILD)
VM_VER_DEFS = -DHOTSPOT_VERSION_STRING="\"$(HOTSPOT_VERSION_STRING)\"" \
-DVERSION_STRING="\"$(VERSION_STRING)\"" \

@ -78,6 +78,7 @@ endif
JDK_VER_DEFS = -DVERSION_MAJOR=$(VERSION_MAJOR) \
-DVERSION_MINOR=$(VERSION_MINOR) \
-DVERSION_SECURITY=$(VERSION_SECURITY) \
-DVERSION_PATCH=$(VERSION_PATCH) \
-DVERSION_BUILD=$(VERSION_BUILD)
VM_VER_DEFS = -DHOTSPOT_VERSION_STRING="\"$(HOTSPOT_VERSION_STRING)\"" \
-DVERSION_STRING="\"$(VERSION_STRING)\"" \

@ -72,6 +72,7 @@ endif
JDK_VER_DEFS = -DVERSION_MAJOR=$(VERSION_MAJOR) \
-DVERSION_MINOR=$(VERSION_MINOR) \
-DVERSION_SECURITY=$(VERSION_SECURITY) \
-DVERSION_PATCH=$(VERSION_PATCH) \
-DVERSION_BUILD=$(VERSION_BUILD)
VM_VER_DEFS = -DHOTSPOT_VERSION_STRING="\"$(HOTSPOT_VERSION_STRING)\"" \
-DVERSION_STRING="\"$(VERSION_STRING)\"" \

@ -182,6 +182,7 @@ MAKE_ARGS += VERSION_SHORT=$(VERSION_SHORT)
MAKE_ARGS += VERSION_MAJOR=$(VERSION_MAJOR)
MAKE_ARGS += VERSION_MINOR=$(VERSION_MINOR)
MAKE_ARGS += VERSION_SECURITY=$(VERSION_SECURITY)
MAKE_ARGS += VERSION_PATCH=$(VERSION_PATCH)
MAKE_ARGS += VERSION_BUILD=$(VERSION_BUILD)
# JDK_DOTVER and JDK_VER are needed in Windows RC files

@ -62,6 +62,7 @@ CXX_FLAGS=$(CXX_FLAGS) /D "HOTSPOT_VERSION_STRING=\"$(HOTSPOT_VERSION_STRING)\""
CXX_FLAGS=$(CXX_FLAGS) /D "VERSION_MAJOR=$(VERSION_MAJOR)"
CXX_FLAGS=$(CXX_FLAGS) /D "VERSION_MINOR=$(VERSION_MINOR)"
CXX_FLAGS=$(CXX_FLAGS) /D "VERSION_SECURITY=$(VERSION_SECURITY)"
CXX_FLAGS=$(CXX_FLAGS) /D "VERSION_PATCH=$(VERSION_PATCH)"
CXX_FLAGS=$(CXX_FLAGS) /D "VERSION_BUILD=$(VERSION_BUILD)"
CXX_FLAGS=$(CXX_FLAGS) /D "VERSION_STRING=\"$(VERSION_STRING)\""
CXX_FLAGS=$(CXX_FLAGS) /D "HOTSPOT_LIB_ARCH=\"$(HOTSPOT_LIB_ARCH)\""

@ -349,37 +349,6 @@ void Universe::genesis(TRAPS) {
// Have already been initialized.
_objectArrayKlassObj->append_to_sibling_list();
// Compute is_jdk version flags.
// Only 1.3 or later has the java.lang.Shutdown class.
// Only 1.4 or later has the java.lang.CharSequence interface.
// Only 1.5 or later has the java.lang.management.MemoryUsage class.
if (JDK_Version::is_partially_initialized()) {
uint8_t jdk_version;
Klass* k = SystemDictionary::resolve_or_null(
vmSymbols::java_lang_management_MemoryUsage(), THREAD);
CLEAR_PENDING_EXCEPTION; // ignore exceptions
if (k == NULL) {
k = SystemDictionary::resolve_or_null(
vmSymbols::java_lang_CharSequence(), THREAD);
CLEAR_PENDING_EXCEPTION; // ignore exceptions
if (k == NULL) {
k = SystemDictionary::resolve_or_null(
vmSymbols::java_lang_Shutdown(), THREAD);
CLEAR_PENDING_EXCEPTION; // ignore exceptions
if (k == NULL) {
jdk_version = 2;
} else {
jdk_version = 3;
}
} else {
jdk_version = 4;
}
} else {
jdk_version = 5;
}
JDK_Version::fully_initialize(jdk_version);
}
#ifdef ASSERT
if (FullGCALot) {
// Allocate an array of dummy objects.

@ -3656,8 +3656,7 @@ JVM_ENTRY(void, JVM_GetVersionInfo(JNIEnv* env, jvm_version_info* info, size_t i
memset(info, 0, info_size);
info->jvm_version = Abstract_VM_Version::jvm_version();
info->update_version = 0; /* 0 in HotSpot Express VM */
info->special_update_version = 0; /* 0 in HotSpot Express VM */
info->patch_version = Abstract_VM_Version::vm_patch_version();
// when we add a new capability in the jvm_version_info struct, we should also
// consider to expose this new capability in the sun.rt.jvmCapabilities jvmstat

@ -1184,10 +1184,9 @@ JVM_GetEnclosingMethodInfo(JNIEnv* env, jclass ofClass);
* ==========================================================================
*/
typedef struct {
/* VM version string: follows the JDK release version naming convention */
unsigned int jvm_version;
unsigned int update_version : 8;
unsigned int special_update_version : 8;
unsigned int jvm_version; /* Encoded $VNUM as defined by JEP-223 */
unsigned int patch_version : 8; /* JEP-223 patch version */
unsigned int reserved3 : 8;
unsigned int reserved1 : 16;
unsigned int reserved2;
@ -1213,11 +1212,9 @@ JNIEXPORT void JNICALL
JVM_GetVersionInfo(JNIEnv* env, jvm_version_info* info, size_t info_size);
typedef struct {
// Naming convention of RE build version string: n.n.n[_uu[c]][-<identifier>]-bxx
unsigned int jdk_version; /* Consists of major, minor, security (n.n.n) */
/* and build number (xx) */
unsigned int update_version : 8; /* Update release version (uu) */
unsigned int special_update_version : 8; /* Special update release version (c)*/
unsigned int jdk_version; /* Encoded $VNUM as defined by JEP-223 */
unsigned int patch_version : 8; /* JEP-223 patch version */
unsigned int reserved3 : 8;
unsigned int reserved1 : 16;
unsigned int reserved2;
@ -1239,10 +1236,6 @@ typedef struct {
#define JDK_VERSION_MAJOR(version) ((version & 0xFF000000) >> 24)
#define JDK_VERSION_MINOR(version) ((version & 0x00FF0000) >> 16)
#define JDK_VERSION_SECURITY(version) ((version & 0x0000FF00) >> 8)
/* Build number is available only for RE build.
* It will be zero for internal builds.
*/
#define JDK_VERSION_BUILD(version) ((version & 0x000000FF))
/*

@ -635,42 +635,23 @@ void JDK_Version::initialize() {
jdk_version_info_fn_t func = CAST_TO_FN_PTR(jdk_version_info_fn_t,
os::dll_lookup(lib_handle, "JDK_GetVersionInfo0"));
if (func == NULL) {
// JDK older than 1.6
_current._partially_initialized = true;
} else {
(*func)(&info, sizeof(info));
assert(func != NULL, "Support for JDK 1.5 or older has been removed after JEP-223");
int major = JDK_VERSION_MAJOR(info.jdk_version);
int minor = JDK_VERSION_MINOR(info.jdk_version);
int security = JDK_VERSION_SECURITY(info.jdk_version);
int build = JDK_VERSION_BUILD(info.jdk_version);
(*func)(&info, sizeof(info));
// Incompatible with pre-4243978 JDK.
if (info.pending_list_uses_discovered_field == 0) {
vm_exit_during_initialization(
"Incompatible JDK is not using Reference.discovered field for pending list");
}
_current = JDK_Version(major, minor, security, info.update_version,
info.special_update_version, build,
info.thread_park_blocker == 1,
info.post_vm_init_hook_enabled == 1);
int major = JDK_VERSION_MAJOR(info.jdk_version);
int minor = JDK_VERSION_MINOR(info.jdk_version);
int security = JDK_VERSION_SECURITY(info.jdk_version);
int build = JDK_VERSION_BUILD(info.jdk_version);
// Incompatible with pre-4243978 JDK.
if (info.pending_list_uses_discovered_field == 0) {
vm_exit_during_initialization(
"Incompatible JDK is not using Reference.discovered field for pending list");
}
}
void JDK_Version::fully_initialize(
uint8_t major, uint8_t minor, uint8_t security, uint8_t update) {
// This is only called when current is less than 1.6 and we've gotten
// far enough in the initialization to determine the exact version.
assert(major < 6, "not needed for JDK version >= 6");
assert(is_partially_initialized(), "must not initialize");
if (major < 5) {
// JDK verison sequence: 1.2.x, 1.3.x, 1.4.x, 5.0.x, 6.0.x, etc.
security = minor;
minor = major;
major = 1;
}
_current = JDK_Version(major, minor, security, update);
_current = JDK_Version(major, minor, security, info.patch_version, build,
info.thread_park_blocker == 1,
info.post_vm_init_hook_enabled == 1);
}
void JDK_Version_init() {
@ -679,29 +660,18 @@ void JDK_Version_init() {
static int64_t encode_jdk_version(const JDK_Version& v) {
return
((int64_t)v.major_version() << (BitsPerByte * 5)) |
((int64_t)v.minor_version() << (BitsPerByte * 4)) |
((int64_t)v.security_version() << (BitsPerByte * 3)) |
((int64_t)v.update_version() << (BitsPerByte * 2)) |
((int64_t)v.special_update_version() << (BitsPerByte * 1)) |
((int64_t)v.major_version() << (BitsPerByte * 4)) |
((int64_t)v.minor_version() << (BitsPerByte * 3)) |
((int64_t)v.security_version() << (BitsPerByte * 2)) |
((int64_t)v.patch_version() << (BitsPerByte * 1)) |
((int64_t)v.build_number() << (BitsPerByte * 0));
}
int JDK_Version::compare(const JDK_Version& other) const {
assert(is_valid() && other.is_valid(), "Invalid version (uninitialized?)");
if (!is_partially_initialized() && other.is_partially_initialized()) {
return -(other.compare(*this)); // flip the comparators
}
assert(!other.is_partially_initialized(), "Not initialized yet");
if (is_partially_initialized()) {
assert(other.major_version() >= 6,
"Invalid JDK version comparison during initialization");
return -1;
} else {
uint64_t e = encode_jdk_version(*this);
uint64_t o = encode_jdk_version(other);
return (e > o) ? 1 : ((e == o) ? 0 : -1);
}
uint64_t e = encode_jdk_version(*this);
uint64_t o = encode_jdk_version(other);
return (e > o) ? 1 : ((e == o) ? 0 : -1);
}
void JDK_Version::to_string(char* buffer, size_t buflen) const {
@ -710,8 +680,6 @@ void JDK_Version::to_string(char* buffer, size_t buflen) const {
if (!is_valid()) {
jio_snprintf(buffer, buflen, "%s", "(uninitialized)");
} else if (is_partially_initialized()) {
jio_snprintf(buffer, buflen, "%s", "(uninitialized) pre-1.6.0");
} else {
int rc = jio_snprintf(
&buffer[index], buflen - index, "%d.%d", _major, _minor);
@ -720,18 +688,13 @@ void JDK_Version::to_string(char* buffer, size_t buflen) const {
if (_security > 0) {
rc = jio_snprintf(&buffer[index], buflen - index, ".%d", _security);
}
if (_update > 0) {
rc = jio_snprintf(&buffer[index], buflen - index, "_%02d", _update);
if (rc == -1) return;
index += rc;
}
if (_special > 0) {
rc = jio_snprintf(&buffer[index], buflen - index, "%c", _special);
if (_patch > 0) {
rc = jio_snprintf(&buffer[index], buflen - index, ".%d", _patch);
if (rc == -1) return;
index += rc;
}
if (_build > 0) {
rc = jio_snprintf(&buffer[index], buflen - index, "-b%02d", _build);
rc = jio_snprintf(&buffer[index], buflen - index, "+%d", _build);
if (rc == -1) return;
index += rc;
}

@ -51,18 +51,9 @@ extern void vm_exit_during_initialization(const char* error, const char* message
extern void vm_shutdown_during_initialization(const char* error, const char* message = NULL);
/**
* Discovering the JDK_Version during initialization is tricky when the
* running JDK is less than JDK6. For JDK6 and greater, a "GetVersion"
* function exists in libjava.so and we simply call it during the
* 'initialize()' call to find the version. For JDKs with version < 6, no
* such call exists and we have to probe the JDK in order to determine
* the exact version. This probing cannot happen during late in
* the VM initialization process so there's a period of time during
* initialization when we don't know anything about the JDK version other than
* that it less than version 6. This is the "partially initialized" time,
* when we can answer only certain version queries (such as, is the JDK
* version greater than 5? Answer: no). Once the JDK probing occurs, we
* know the version and are considered fully initialized.
* With the integration of the changes to handle the version string
* as defined by JEP-223, most of the code related to handle the version
* string prior to JDK 1.6 was removed (partial initialization)
*/
class JDK_Version VALUE_OBJ_CLASS_SPEC {
friend class VMStructs;
@ -74,53 +65,32 @@ class JDK_Version VALUE_OBJ_CLASS_SPEC {
static const char* _runtime_name;
static const char* _runtime_version;
// In this class, we promote the minor version of release to be the
// major version for releases >= 5 in anticipation of the JDK doing the
// same thing. For example, we represent "1.5.0" as major version 5 (we
// drop the leading 1 and use 5 as the 'major').
uint8_t _major;
uint8_t _minor;
uint8_t _security;
uint8_t _update;
uint8_t _special;
uint8_t _patch;
uint8_t _build;
// If partially initialized, the above fields are invalid and we know
// that we're less than major version 6.
bool _partially_initialized;
bool _thread_park_blocker;
bool _post_vm_init_hook_enabled;
bool is_valid() const {
return (_major != 0 || _partially_initialized);
return (_major != 0);
}
// initializes or partially initializes the _current static field
static void initialize();
// Completes initialization for a pre-JDK6 version.
static void fully_initialize(uint8_t major, uint8_t minor = 0,
uint8_t security = 0, uint8_t update = 0);
public:
// Returns true if the the current version has only been partially initialized
static bool is_partially_initialized() {
return _current._partially_initialized;
}
JDK_Version() : _major(0), _minor(0), _security(0), _update(0),
_special(0), _build(0), _partially_initialized(false),
JDK_Version() : _major(0), _minor(0), _security(0), _patch(0), _build(0),
_thread_park_blocker(false), _post_vm_init_hook_enabled(false)
{}
JDK_Version(uint8_t major, uint8_t minor = 0, uint8_t security = 0,
uint8_t update = 0, uint8_t special = 0, uint8_t build = 0,
uint8_t patch = 0, uint8_t build = 0,
bool thread_park_blocker = false, bool post_vm_init_hook_enabled = false) :
_major(major), _minor(minor), _security(security), _update(update),
_special(special), _build(build), _partially_initialized(false),
_major(major), _minor(minor), _security(security), _patch(patch), _build(build),
_thread_park_blocker(thread_park_blocker),
_post_vm_init_hook_enabled(post_vm_init_hook_enabled)
{}
@ -133,15 +103,10 @@ class JDK_Version VALUE_OBJ_CLASS_SPEC {
return JDK_Version(m);
}
static JDK_Version jdk_update(uint8_t major, uint8_t update_number) {
return JDK_Version(major, 0, 0, update_number);
}
uint8_t major_version() const { return _major; }
uint8_t minor_version() const { return _minor; }
uint8_t security_version() const { return _security; }
uint8_t update_version() const { return _update; }
uint8_t special_update_version() const { return _special; }
uint8_t security_version() const { return _security; }
uint8_t patch_version() const { return _patch; }
uint8_t build_number() const { return _build; }
bool supports_thread_park_blocker() const {
@ -151,7 +116,7 @@ class JDK_Version VALUE_OBJ_CLASS_SPEC {
return _post_vm_init_hook_enabled;
}
// Performs a full ordering comparison using all fields (update, build, etc.)
// Performs a full ordering comparison using all fields (patch, build, etc.)
int compare(const JDK_Version& other) const;
/**
@ -160,16 +125,7 @@ class JDK_Version VALUE_OBJ_CLASS_SPEC {
* equal, and a positive value if it is greater.
*/
int compare_major(int version) const {
if (_partially_initialized) {
if (version >= 6) {
return -1;
} else {
assert(false, "Can't make this comparison during init time");
return -1; // conservative
}
} else {
return major_version() - version;
}
}
void to_string(char* buffer, size_t buflen) const;

@ -1242,7 +1242,6 @@ typedef CompactHashtable<Symbol*, char> SymbolCompactHashTable;
static_field(Abstract_VM_Version, _reserve_for_allocation_prefetch, int) \
\
static_field(JDK_Version, _current, JDK_Version) \
nonstatic_field(JDK_Version, _partially_initialized, bool) \
nonstatic_field(JDK_Version, _major, unsigned char) \
\
/*************************/ \

@ -52,6 +52,9 @@ int Abstract_VM_Version::_reserve_for_allocation_prefetch = 0;
#ifndef VERSION_SECURITY
#error VERSION_SECURITY must be defined
#endif
#ifndef VERSION_PATCH
#error VERSION_PATCH must be defined
#endif
#ifndef VERSION_BUILD
#error VERSION_BUILD must be defined
#endif
@ -76,20 +79,11 @@ int Abstract_VM_Version::_reserve_for_allocation_prefetch = 0;
int Abstract_VM_Version::_vm_major_version = VERSION_MAJOR;
int Abstract_VM_Version::_vm_minor_version = VERSION_MINOR;
int Abstract_VM_Version::_vm_security_version = VERSION_SECURITY;
int Abstract_VM_Version::_vm_patch_version = VERSION_PATCH;
int Abstract_VM_Version::_vm_build_number = VERSION_BUILD;
bool Abstract_VM_Version::_initialized = false;
unsigned int Abstract_VM_Version::_parallel_worker_threads = 0;
bool Abstract_VM_Version::_parallel_worker_threads_initialized = false;
void Abstract_VM_Version::initialize() {
// FIXME: Initialization can probably be removed now.
if (_initialized) {
return;
}
_initialized = true;
}
#if defined(_LP64)
#define VMLP "64-Bit "
#else

@ -46,8 +46,8 @@ class Abstract_VM_Version: AllStatic {
static int _vm_major_version;
static int _vm_minor_version;
static int _vm_security_version;
static int _vm_patch_version;
static int _vm_build_number;
static bool _initialized;
static unsigned int _parallel_worker_threads;
static bool _parallel_worker_threads_initialized;
static int _reserve_for_allocation_prefetch;
@ -68,10 +68,11 @@ class Abstract_VM_Version: AllStatic {
static const char* vm_platform_string();
static const char* vm_build_user();
static int vm_major_version() { assert(_initialized, "not initialized"); return _vm_major_version; }
static int vm_minor_version() { assert(_initialized, "not initialized"); return _vm_minor_version; }
static int vm_security_version() { assert(_initialized, "not initialized"); return _vm_security_version; }
static int vm_build_number() { assert(_initialized, "not initialized"); return _vm_build_number; }
static int vm_major_version() { return _vm_major_version; }
static int vm_minor_version() { return _vm_minor_version; }
static int vm_security_version() { return _vm_security_version; }
static int vm_patch_version() { return _vm_patch_version; }
static int vm_build_number() { return _vm_build_number; }
// Gets the jvm_version_info.jvm_version defined in jvm.h
static unsigned int jvm_version();

@ -169,12 +169,13 @@ void VersionDCmd::execute(DCmdSource source, TRAPS) {
output()->print_cr("%s version %s", Abstract_VM_Version::vm_name(),
Abstract_VM_Version::vm_release());
JDK_Version jdk_version = JDK_Version::current();
if (jdk_version.update_version() > 0) {
output()->print_cr("JDK %d.%d_%02d", jdk_version.major_version(),
jdk_version.minor_version(), jdk_version.update_version());
if (jdk_version.patch_version() > 0) {
output()->print_cr("JDK %d.%d.%d.%d", jdk_version.major_version(),
jdk_version.minor_version(), jdk_version.security_version(),
jdk_version.patch_version());
} else {
output()->print_cr("JDK %d.%d", jdk_version.major_version(),
jdk_version.minor_version());
output()->print_cr("JDK %d.%d.%d", jdk_version.major_version(),
jdk_version.minor_version(), jdk_version.security_version());
}
}

@ -86,10 +86,6 @@ void management_init() {
ClassLoadingService::init();
#else
ThreadService::init();
// Make sure the VM version is initialized
// This is normally called by RuntimeService::init().
// Since that is conditionalized out, we need to call it here.
Abstract_VM_Version::initialize();
#endif // INCLUDE_MANAGEMENT
}

@ -42,8 +42,6 @@ PerfCounter* RuntimeService::_application_time_ticks = NULL;
double RuntimeService::_last_safepoint_sync_time_sec = 0.0;
void RuntimeService::init() {
// Make sure the VM version is initialized
Abstract_VM_Version::initialize();
if (UsePerfData) {
EXCEPTION_MARK;