This commit is contained in:
Daniel D. Daugherty 2015-06-18 13:18:12 -07:00
commit 6bb2203891
17 changed files with 320 additions and 9 deletions

View File

@ -121,6 +121,8 @@ public class VM {
private Flag[] commandLineFlags; private Flag[] commandLineFlags;
private Map flagsMap; private Map flagsMap;
private static Type intType;
private static Type uintType;
private static Type intxType; private static Type intxType;
private static Type uintxType; private static Type uintxType;
private static Type sizetType; private static Type sizetType;
@ -170,6 +172,28 @@ public class VM {
return addr.getCIntegerAt(0, boolType.getSize(), boolType.isUnsigned()) != 0; return addr.getCIntegerAt(0, boolType.getSize(), boolType.isUnsigned()) != 0;
} }
public boolean isInt() {
return type.equals("int");
}
public long getInt() {
if (Assert.ASSERTS_ENABLED) {
Assert.that(isInt(), "not an int flag!");
}
return addr.getCIntegerAt(0, intType.getSize(), false);
}
public boolean isUInt() {
return type.equals("uint");
}
public long getUInt() {
if (Assert.ASSERTS_ENABLED) {
Assert.that(isUInt(), "not a uint flag!");
}
return addr.getCIntegerAt(0, uintType.getSize(), false);
}
public boolean isIntx() { public boolean isIntx() {
return type.equals("intx"); return type.equals("intx");
} }
@ -206,6 +230,10 @@ public class VM {
public String getValue() { public String getValue() {
if (isBool()) { if (isBool()) {
return new Boolean(getBool()).toString(); return new Boolean(getBool()).toString();
} else if (isInt()) {
return new Long(getInt()).toString();
} else if (isUInt()) {
return new Long(getUInt()).toString();
} else if (isIntx()) { } else if (isIntx()) {
return new Long(getIntx()).toString(); return new Long(getIntx()).toString();
} else if (isUIntx()) { } else if (isUIntx()) {
@ -334,6 +362,8 @@ public class VM {
heapWordSize = db.lookupIntConstant("HeapWordSize").intValue(); heapWordSize = db.lookupIntConstant("HeapWordSize").intValue();
oopSize = db.lookupIntConstant("oopSize").intValue(); oopSize = db.lookupIntConstant("oopSize").intValue();
intType = db.lookupType("int");
uintType = db.lookupType("uint");
intxType = db.lookupType("intx"); intxType = db.lookupType("intx");
uintxType = db.lookupType("uintx"); uintxType = db.lookupType("uintx");
sizetType = db.lookupType("size_t"); sizetType = db.lookupType("size_t");

View File

@ -96,7 +96,7 @@ void PSMarkSweep::invoke(bool maximum_heap_compaction) {
heap->collector_policy()->should_clear_all_soft_refs(); heap->collector_policy()->should_clear_all_soft_refs();
uint count = maximum_heap_compaction ? 1 : MarkSweepAlwaysCompactCount; uint count = maximum_heap_compaction ? 1 : MarkSweepAlwaysCompactCount;
UIntFlagSetting flag_setting(MarkSweepAlwaysCompactCount, count); UIntXFlagSetting flag_setting(MarkSweepAlwaysCompactCount, count);
PSMarkSweep::invoke_no_policy(clear_all_soft_refs || maximum_heap_compaction); PSMarkSweep::invoke_no_policy(clear_all_soft_refs || maximum_heap_compaction);
} }

View File

@ -785,7 +785,7 @@ HeapWord* GenCollectorPolicy::satisfy_failed_allocation(size_t size,
// free memory should be here, especially if they are expensive. If this // free memory should be here, especially if they are expensive. If this
// attempt fails, an OOM exception will be thrown. // attempt fails, an OOM exception will be thrown.
{ {
UIntFlagSetting flag_change(MarkSweepAlwaysCompactCount, 1); // Make sure the heap is fully compacted UIntXFlagSetting flag_change(MarkSweepAlwaysCompactCount, 1); // Make sure the heap is fully compacted
gch->do_collection(true /* full */, gch->do_collection(true /* full */,
true /* clear_all_soft_refs */, true /* clear_all_soft_refs */,

View File

@ -43,6 +43,7 @@
#include "runtime/deoptimization.hpp" #include "runtime/deoptimization.hpp"
#include "runtime/relocator.hpp" #include "runtime/relocator.hpp"
#include "utilities/bitMap.inline.hpp" #include "utilities/bitMap.inline.hpp"
#include "utilities/events.hpp"
PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
@ -174,6 +175,9 @@ void VM_RedefineClasses::doit_epilogue() {
// Free os::malloc allocated memory. // Free os::malloc allocated memory.
os::free(_scratch_classes); os::free(_scratch_classes);
// Reset the_class_oop to null for error printing.
_the_class_oop = NULL;
if (RC_TRACE_ENABLED(0x00000004)) { if (RC_TRACE_ENABLED(0x00000004)) {
// Used to have separate timers for "doit" and "all", but the timer // Used to have separate timers for "doit" and "all", but the timer
// overhead skewed the measurements. // overhead skewed the measurements.
@ -4105,6 +4109,13 @@ void VM_RedefineClasses::redefine_single_class(jclass the_jclass,
java_lang_Class::classRedefinedCount(the_class_mirror), java_lang_Class::classRedefinedCount(the_class_mirror),
os::available_memory() >> 10)); os::available_memory() >> 10));
{
ResourceMark rm(THREAD);
Events::log_redefinition(THREAD, "redefined class name=%s, count=%d",
the_class->external_name(),
java_lang_Class::classRedefinedCount(the_class_mirror));
}
RC_TIMER_STOP(_timer_rsc_phase2); RC_TIMER_STOP(_timer_rsc_phase2);
} // end redefine_single_class() } // end redefine_single_class()
@ -4249,3 +4260,11 @@ void VM_RedefineClasses::dump_methods() {
tty->cr(); tty->cr();
} }
} }
void VM_RedefineClasses::print_on_error(outputStream* st) const {
VM_Operation::print_on_error(st);
if (_the_class_oop != NULL) {
ResourceMark rm;
st->print_cr(", redefining class %s", _the_class_oop->external_name());
}
}

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -539,5 +539,8 @@ class VM_RedefineClasses: public VM_Operation {
static unsigned char * get_cached_class_file_bytes(JvmtiCachedClassFileData *cache) { static unsigned char * get_cached_class_file_bytes(JvmtiCachedClassFileData *cache) {
return cache == NULL ? NULL : cache->data; return cache == NULL ? NULL : cache->data;
} }
// Error printing
void print_on_error(outputStream* st) const;
}; };
#endif // SHARE_VM_PRIMS_JVMTIREDEFINECLASSES_HPP #endif // SHARE_VM_PRIMS_JVMTIREDEFINECLASSES_HPP

View File

@ -710,6 +710,24 @@ WB_ENTRY(jobject, WB_GetBooleanVMFlag(JNIEnv* env, jobject o, jstring name))
return NULL; return NULL;
WB_END WB_END
WB_ENTRY(jobject, WB_GetIntVMFlag(JNIEnv* env, jobject o, jstring name))
int result;
if (GetVMFlag <int> (thread, env, name, &result, &CommandLineFlags::intAt)) {
ThreadToNativeFromVM ttnfv(thread); // can't be in VM when we call JNI
return longBox(thread, env, result);
}
return NULL;
WB_END
WB_ENTRY(jobject, WB_GetUintVMFlag(JNIEnv* env, jobject o, jstring name))
uint result;
if (GetVMFlag <uint> (thread, env, name, &result, &CommandLineFlags::uintAt)) {
ThreadToNativeFromVM ttnfv(thread); // can't be in VM when we call JNI
return longBox(thread, env, result);
}
return NULL;
WB_END
WB_ENTRY(jobject, WB_GetIntxVMFlag(JNIEnv* env, jobject o, jstring name)) WB_ENTRY(jobject, WB_GetIntxVMFlag(JNIEnv* env, jobject o, jstring name))
intx result; intx result;
if (GetVMFlag <intx> (thread, env, name, &result, &CommandLineFlags::intxAt)) { if (GetVMFlag <intx> (thread, env, name, &result, &CommandLineFlags::intxAt)) {
@ -771,6 +789,16 @@ WB_ENTRY(void, WB_SetBooleanVMFlag(JNIEnv* env, jobject o, jstring name, jboolea
SetVMFlag <bool> (thread, env, name, &result, &CommandLineFlags::boolAtPut); SetVMFlag <bool> (thread, env, name, &result, &CommandLineFlags::boolAtPut);
WB_END WB_END
WB_ENTRY(void, WB_SetIntVMFlag(JNIEnv* env, jobject o, jstring name, jlong value))
int result = value;
SetVMFlag <int> (thread, env, name, &result, &CommandLineFlags::intAtPut);
WB_END
WB_ENTRY(void, WB_SetUintVMFlag(JNIEnv* env, jobject o, jstring name, jlong value))
uint result = value;
SetVMFlag <uint> (thread, env, name, &result, &CommandLineFlags::uintAtPut);
WB_END
WB_ENTRY(void, WB_SetIntxVMFlag(JNIEnv* env, jobject o, jstring name, jlong value)) WB_ENTRY(void, WB_SetIntxVMFlag(JNIEnv* env, jobject o, jstring name, jlong value))
intx result = value; intx result = value;
SetVMFlag <intx> (thread, env, name, &result, &CommandLineFlags::intxAtPut); SetVMFlag <intx> (thread, env, name, &result, &CommandLineFlags::intxAtPut);
@ -1336,6 +1364,8 @@ static JNINativeMethod methods[] = {
{CC"isConstantVMFlag", CC"(Ljava/lang/String;)Z", (void*)&WB_IsConstantVMFlag}, {CC"isConstantVMFlag", CC"(Ljava/lang/String;)Z", (void*)&WB_IsConstantVMFlag},
{CC"isLockedVMFlag", CC"(Ljava/lang/String;)Z", (void*)&WB_IsLockedVMFlag}, {CC"isLockedVMFlag", CC"(Ljava/lang/String;)Z", (void*)&WB_IsLockedVMFlag},
{CC"setBooleanVMFlag", CC"(Ljava/lang/String;Z)V",(void*)&WB_SetBooleanVMFlag}, {CC"setBooleanVMFlag", CC"(Ljava/lang/String;Z)V",(void*)&WB_SetBooleanVMFlag},
{CC"setIntVMFlag", CC"(Ljava/lang/String;J)V",(void*)&WB_SetIntVMFlag},
{CC"setUintVMFlag", CC"(Ljava/lang/String;J)V",(void*)&WB_SetUintVMFlag},
{CC"setIntxVMFlag", CC"(Ljava/lang/String;J)V",(void*)&WB_SetIntxVMFlag}, {CC"setIntxVMFlag", CC"(Ljava/lang/String;J)V",(void*)&WB_SetIntxVMFlag},
{CC"setUintxVMFlag", CC"(Ljava/lang/String;J)V",(void*)&WB_SetUintxVMFlag}, {CC"setUintxVMFlag", CC"(Ljava/lang/String;J)V",(void*)&WB_SetUintxVMFlag},
{CC"setUint64VMFlag", CC"(Ljava/lang/String;J)V",(void*)&WB_SetUint64VMFlag}, {CC"setUint64VMFlag", CC"(Ljava/lang/String;J)V",(void*)&WB_SetUint64VMFlag},
@ -1345,6 +1375,10 @@ static JNINativeMethod methods[] = {
(void*)&WB_SetStringVMFlag}, (void*)&WB_SetStringVMFlag},
{CC"getBooleanVMFlag", CC"(Ljava/lang/String;)Ljava/lang/Boolean;", {CC"getBooleanVMFlag", CC"(Ljava/lang/String;)Ljava/lang/Boolean;",
(void*)&WB_GetBooleanVMFlag}, (void*)&WB_GetBooleanVMFlag},
{CC"getIntVMFlag", CC"(Ljava/lang/String;)Ljava/lang/Long;",
(void*)&WB_GetIntVMFlag},
{CC"getUintVMFlag", CC"(Ljava/lang/String;)Ljava/lang/Long;",
(void*)&WB_GetUintVMFlag},
{CC"getIntxVMFlag", CC"(Ljava/lang/String;)Ljava/lang/Long;", {CC"getIntxVMFlag", CC"(Ljava/lang/String;)Ljava/lang/Long;",
(void*)&WB_GetIntxVMFlag}, (void*)&WB_GetIntxVMFlag},
{CC"getUintxVMFlag", CC"(Ljava/lang/String;)Ljava/lang/Long;", {CC"getUintxVMFlag", CC"(Ljava/lang/String;)Ljava/lang/Long;",

View File

@ -586,11 +586,12 @@ static bool set_fp_numeric_flag(char* name, char* value, Flag::Flags origin) {
static bool set_numeric_flag(char* name, char* value, Flag::Flags origin) { static bool set_numeric_flag(char* name, char* value, Flag::Flags origin) {
julong v; julong v;
int int_v;
intx intx_v; intx intx_v;
bool is_neg = false; bool is_neg = false;
// Check the sign first since atomull() parses only unsigned values. // Check the sign first since atomull() parses only unsigned values.
if (*value == '-') { if (*value == '-') {
if (!CommandLineFlags::intxAt(name, &intx_v)) { if (!CommandLineFlags::intxAt(name, &intx_v) && !CommandLineFlags::intAt(name, &int_v)) {
return false; return false;
} }
value++; value++;
@ -599,6 +600,17 @@ static bool set_numeric_flag(char* name, char* value, Flag::Flags origin) {
if (!atomull(value, &v)) { if (!atomull(value, &v)) {
return false; return false;
} }
int_v = (int) v;
if (is_neg) {
int_v = -int_v;
}
if (CommandLineFlags::intAtPut(name, &int_v, origin)) {
return true;
}
uint uint_v = (uint) v;
if (!is_neg && CommandLineFlags::uintAtPut(name, &uint_v, origin)) {
return true;
}
intx_v = (intx) v; intx_v = (intx) v;
if (is_neg) { if (is_neg) {
intx_v = -intx_v; intx_v = -intx_v;

View File

@ -93,6 +93,32 @@ void Flag::set_bool(bool value) {
*((bool*) _addr) = value; *((bool*) _addr) = value;
} }
bool Flag::is_int() const {
return strcmp(_type, "int") == 0;
}
int Flag::get_int() const {
return *((int*) _addr);
}
void Flag::set_int(int value) {
check_writable();
*((int*) _addr) = value;
}
bool Flag::is_uint() const {
return strcmp(_type, "uint") == 0;
}
uint Flag::get_uint() const {
return *((uint*) _addr);
}
void Flag::set_uint(uint value) {
check_writable();
*((uint*) _addr) = value;
}
bool Flag::is_intx() const { bool Flag::is_intx() const {
return strcmp(_type, "intx") == 0; return strcmp(_type, "intx") == 0;
} }
@ -316,6 +342,12 @@ void Flag::print_on(outputStream* st, bool withComments) {
if (is_bool()) { if (is_bool()) {
st->print("%-16s", get_bool() ? "true" : "false"); st->print("%-16s", get_bool() ? "true" : "false");
} }
if (is_int()) {
st->print("%-16d", get_int());
}
if (is_uint()) {
st->print("%-16u", get_uint());
}
if (is_intx()) { if (is_intx()) {
st->print("%-16ld", get_intx()); st->print("%-16ld", get_intx());
} }
@ -411,6 +443,10 @@ void Flag::print_kind(outputStream* st) {
void Flag::print_as_flag(outputStream* st) { void Flag::print_as_flag(outputStream* st) {
if (is_bool()) { if (is_bool()) {
st->print("-XX:%s%s", get_bool() ? "+" : "-", _name); st->print("-XX:%s%s", get_bool() ? "+" : "-", _name);
} else if (is_int()) {
st->print("-XX:%s=%d", _name, get_int());
} else if (is_uint()) {
st->print("-XX:%s=%u", _name, get_uint());
} else if (is_intx()) { } else if (is_intx()) {
st->print("-XX:%s=" INTX_FORMAT, _name, get_intx()); st->print("-XX:%s=" INTX_FORMAT, _name, get_intx());
} else if (is_uintx()) { } else if (is_uintx()) {
@ -663,6 +699,62 @@ void CommandLineFlagsEx::boolAtPut(CommandLineFlagWithType flag, bool value, Fla
faddr->set_origin(origin); faddr->set_origin(origin);
} }
bool CommandLineFlags::intAt(const char* name, size_t len, int* value, bool allow_locked, bool return_flag) {
Flag* result = Flag::find_flag(name, len, allow_locked, return_flag);
if (result == NULL) return false;
if (!result->is_int()) return false;
*value = result->get_int();
return true;
}
bool CommandLineFlags::intAtPut(const char* name, size_t len, int* value, Flag::Flags origin) {
Flag* result = Flag::find_flag(name, len);
if (result == NULL) return false;
if (!result->is_int()) return false;
int old_value = result->get_int();
trace_flag_changed<EventIntFlagChanged, s4>(name, old_value, *value, origin);
result->set_int(*value);
*value = old_value;
result->set_origin(origin);
return true;
}
void CommandLineFlagsEx::intAtPut(CommandLineFlagWithType flag, int value, Flag::Flags origin) {
Flag* faddr = address_of_flag(flag);
guarantee(faddr != NULL && faddr->is_int(), "wrong flag type");
trace_flag_changed<EventIntFlagChanged, s4>(faddr->_name, faddr->get_int(), value, origin);
faddr->set_int(value);
faddr->set_origin(origin);
}
bool CommandLineFlags::uintAt(const char* name, size_t len, uint* value, bool allow_locked, bool return_flag) {
Flag* result = Flag::find_flag(name, len, allow_locked, return_flag);
if (result == NULL) return false;
if (!result->is_uint()) return false;
*value = result->get_uint();
return true;
}
bool CommandLineFlags::uintAtPut(const char* name, size_t len, uint* value, Flag::Flags origin) {
Flag* result = Flag::find_flag(name, len);
if (result == NULL) return false;
if (!result->is_uint()) return false;
uint old_value = result->get_uint();
trace_flag_changed<EventUnsignedIntFlagChanged, u4>(name, old_value, *value, origin);
result->set_uint(*value);
*value = old_value;
result->set_origin(origin);
return true;
}
void CommandLineFlagsEx::uintAtPut(CommandLineFlagWithType flag, uint value, Flag::Flags origin) {
Flag* faddr = address_of_flag(flag);
guarantee(faddr != NULL && faddr->is_uint(), "wrong flag type");
trace_flag_changed<EventUnsignedIntFlagChanged, u4>(faddr->_name, faddr->get_uint(), value, origin);
faddr->set_uint(value);
faddr->set_origin(origin);
}
bool CommandLineFlags::intxAt(const char* name, size_t len, intx* value, bool allow_locked, bool return_flag) { bool CommandLineFlags::intxAt(const char* name, size_t len, intx* value, bool allow_locked, bool return_flag) {
Flag* result = Flag::find_flag(name, len, allow_locked, return_flag); Flag* result = Flag::find_flag(name, len, allow_locked, return_flag);
if (result == NULL) return false; if (result == NULL) return false;

View File

@ -279,6 +279,14 @@ struct Flag {
bool get_bool() const; bool get_bool() const;
void set_bool(bool value); void set_bool(bool value);
bool is_int() const;
int get_int() const;
void set_int(int value);
bool is_uint() const;
uint get_uint() const;
void set_uint(uint value);
bool is_intx() const; bool is_intx() const;
intx get_intx() const; intx get_intx() const;
void set_intx(intx value); void set_intx(intx value);
@ -363,13 +371,28 @@ class CounterSetting {
~CounterSetting() { (*counter)--; } ~CounterSetting() { (*counter)--; }
}; };
class IntFlagSetting {
int val;
int* flag;
public:
IntFlagSetting(int& fl, int newValue) { flag = &fl; val = fl; fl = newValue; }
~IntFlagSetting() { *flag = val; }
};
class UIntFlagSetting { class UIntFlagSetting {
uint val;
uint* flag;
public:
UIntFlagSetting(uint& fl, uint newValue) { flag = &fl; val = fl; fl = newValue; }
~UIntFlagSetting() { *flag = val; }
};
class UIntXFlagSetting {
uintx val; uintx val;
uintx* flag; uintx* flag;
public: public:
UIntFlagSetting(uintx& fl, uintx newValue) { flag = &fl; val = fl; fl = newValue; } UIntXFlagSetting(uintx& fl, uintx newValue) { flag = &fl; val = fl; fl = newValue; }
~UIntFlagSetting() { *flag = val; } ~UIntXFlagSetting() { *flag = val; }
}; };
class DoubleFlagSetting { class DoubleFlagSetting {
@ -396,6 +419,16 @@ class CommandLineFlags {
static bool boolAtPut(const char* name, size_t len, bool* value, Flag::Flags origin); static bool boolAtPut(const char* name, size_t len, bool* value, Flag::Flags origin);
static bool boolAtPut(const char* name, bool* value, Flag::Flags origin) { return boolAtPut(name, strlen(name), value, origin); } static bool boolAtPut(const char* name, bool* value, Flag::Flags origin) { return boolAtPut(name, strlen(name), value, origin); }
static bool intAt(const char* name, size_t len, int* value, bool allow_locked = false, bool return_flag = false);
static bool intAt(const char* name, int* value, bool allow_locked = false, bool return_flag = false) { return intAt(name, strlen(name), value, allow_locked, return_flag); }
static bool intAtPut(const char* name, size_t len, int* value, Flag::Flags origin);
static bool intAtPut(const char* name, int* value, Flag::Flags origin) { return intAtPut(name, strlen(name), value, origin); }
static bool uintAt(const char* name, size_t len, uint* value, bool allow_locked = false, bool return_flag = false);
static bool uintAt(const char* name, uint* value, bool allow_locked = false, bool return_flag = false) { return uintAt(name, strlen(name), value, allow_locked, return_flag); }
static bool uintAtPut(const char* name, size_t len, uint* value, Flag::Flags origin);
static bool uintAtPut(const char* name, uint* value, Flag::Flags origin) { return uintAtPut(name, strlen(name), value, origin); }
static bool intxAt(const char* name, size_t len, intx* value, bool allow_locked = false, bool return_flag = false); static bool intxAt(const char* name, size_t len, intx* value, bool allow_locked = false, bool return_flag = false);
static bool intxAt(const char* name, intx* value, bool allow_locked = false, bool return_flag = false) { return intxAt(name, strlen(name), value, allow_locked, return_flag); } static bool intxAt(const char* name, intx* value, bool allow_locked = false, bool return_flag = false) { return intxAt(name, strlen(name), value, allow_locked, return_flag); }
static bool intxAtPut(const char* name, size_t len, intx* value, Flag::Flags origin); static bool intxAtPut(const char* name, size_t len, intx* value, Flag::Flags origin);

View File

@ -197,6 +197,8 @@ typedef enum {
class CommandLineFlagsEx : CommandLineFlags { class CommandLineFlagsEx : CommandLineFlags {
public: public:
static void boolAtPut(CommandLineFlagWithType flag, bool value, Flag::Flags origin); static void boolAtPut(CommandLineFlagWithType flag, bool value, Flag::Flags origin);
static void intAtPut(CommandLineFlagWithType flag, int value, Flag::Flags origin);
static void uintAtPut(CommandLineFlagWithType flag, uint value, Flag::Flags origin);
static void intxAtPut(CommandLineFlagWithType flag, intx value, Flag::Flags origin); static void intxAtPut(CommandLineFlagWithType flag, intx value, Flag::Flags origin);
static void uintxAtPut(CommandLineFlagWithType flag, uintx value, Flag::Flags origin); static void uintxAtPut(CommandLineFlagWithType flag, uintx value, Flag::Flags origin);
static void uint64_tAtPut(CommandLineFlagWithType flag, uint64_t value, Flag::Flags origin); static void uint64_tAtPut(CommandLineFlagWithType flag, uint64_t value, Flag::Flags origin);

View File

@ -192,7 +192,7 @@ class VM_Operation: public CHeapObj<mtInternal> {
static const char* mode_to_string(Mode mode); static const char* mode_to_string(Mode mode);
// Debugging // Debugging
void print_on_error(outputStream* st) const; virtual void print_on_error(outputStream* st) const;
const char* name() const { return _names[type()]; } const char* name() const { return _names[type()]; }
static const char* name(int type) { static const char* name(int type) {
assert(type >= 0 && type < VMOp_Terminating, "invalid VM operation type"); assert(type >= 0 && type < VMOp_Terminating, "invalid VM operation type");

View File

@ -1558,6 +1558,12 @@ bool add_global_entry(JNIEnv* env, Handle name, jmmVMGlobal *global, Flag *flag,
if (flag->is_bool()) { if (flag->is_bool()) {
global->value.z = flag->get_bool() ? JNI_TRUE : JNI_FALSE; global->value.z = flag->get_bool() ? JNI_TRUE : JNI_FALSE;
global->type = JMM_VMGLOBAL_TYPE_JBOOLEAN; global->type = JMM_VMGLOBAL_TYPE_JBOOLEAN;
} else if (flag->is_int()) {
global->value.j = (jlong)flag->get_int();
global->type = JMM_VMGLOBAL_TYPE_JLONG;
} else if (flag->is_uint()) {
global->value.j = (jlong)flag->get_uint();
global->type = JMM_VMGLOBAL_TYPE_JLONG;
} else if (flag->is_intx()) { } else if (flag->is_intx()) {
global->value.j = (jlong)flag->get_intx(); global->value.j = (jlong)flag->get_intx();
global->type = JMM_VMGLOBAL_TYPE_JLONG; global->type = JMM_VMGLOBAL_TYPE_JLONG;

View File

@ -44,6 +44,36 @@ int WriteableFlags::set_bool_flag(const char* name, bool value, Flag::Flags orig
return CommandLineFlags::boolAtPut((char*)name, &value, origin) ? SUCCESS : ERR_OTHER; return CommandLineFlags::boolAtPut((char*)name, &value, origin) ? SUCCESS : ERR_OTHER;
} }
// set a int global flag
int WriteableFlags::set_int_flag(const char* name, const char* arg, Flag::Flags origin, FormatBuffer<80>& err_msg) {
int value;
if (sscanf(arg, "%d", &value)) {
return set_int_flag(name, value, origin, err_msg);
}
err_msg.print("flag value must be an integer");
return WRONG_FORMAT;
}
int WriteableFlags::set_int_flag(const char* name, int value, Flag::Flags origin, FormatBuffer<80>& err_msg) {
return CommandLineFlags::intAtPut((char*)name, &value, origin) ? SUCCESS : ERR_OTHER;
}
// set a uint global flag
int WriteableFlags::set_uint_flag(const char* name, const char* arg, Flag::Flags origin, FormatBuffer<80>& err_msg) {
uint value;
if (sscanf(arg, "%u", &value)) {
return set_uint_flag(name, value, origin, err_msg);
}
err_msg.print("flag value must be an unsigned integer");
return WRONG_FORMAT;
}
int WriteableFlags::set_uint_flag(const char* name, uint value, Flag::Flags origin, FormatBuffer<80>& err_msg) {
return CommandLineFlags::uintAtPut((char*)name, &value, origin) ? SUCCESS : ERR_OTHER;
}
// set a intx global flag // set a intx global flag
int WriteableFlags::set_intx_flag(const char* name, const char* arg, Flag::Flags origin, FormatBuffer<80>& err_msg) { int WriteableFlags::set_intx_flag(const char* name, const char* arg, Flag::Flags origin, FormatBuffer<80>& err_msg) {
intx value; intx value;
@ -173,6 +203,10 @@ int WriteableFlags::set_flag_from_char(Flag* f, const void* value, Flag::Flags o
} }
if (f->is_bool()) { if (f->is_bool()) {
return set_bool_flag(f->_name, flag_value, origin, err_msg); return set_bool_flag(f->_name, flag_value, origin, err_msg);
} else if (f->is_int()) {
return set_int_flag(f->_name, flag_value, origin, err_msg);
} else if (f->is_uint()) {
return set_uint_flag(f->_name, flag_value, origin, err_msg);
} else if (f->is_intx()) { } else if (f->is_intx()) {
return set_intx_flag(f->_name, flag_value, origin, err_msg); return set_intx_flag(f->_name, flag_value, origin, err_msg);
} else if (f->is_uintx()) { } else if (f->is_uintx()) {
@ -195,6 +229,12 @@ int WriteableFlags::set_flag_from_jvalue(Flag* f, const void* value, Flag::Flags
if (f->is_bool()) { if (f->is_bool()) {
bool bvalue = (new_value.z == JNI_TRUE ? true : false); bool bvalue = (new_value.z == JNI_TRUE ? true : false);
return set_bool_flag(f->_name, bvalue, origin, err_msg); return set_bool_flag(f->_name, bvalue, origin, err_msg);
} else if (f->is_int()) {
int ivalue = (int)new_value.j;
return set_int_flag(f->_name, ivalue, origin, err_msg);
} else if (f->is_uint()) {
uint uvalue = (uint)new_value.j;
return set_uint_flag(f->_name, uvalue, origin, err_msg);
} else if (f->is_intx()) { } else if (f->is_intx()) {
intx ivalue = (intx)new_value.j; intx ivalue = (intx)new_value.j;
return set_intx_flag(f->_name, ivalue, origin, err_msg); return set_intx_flag(f->_name, ivalue, origin, err_msg);

View File

@ -56,6 +56,10 @@ private:
// set a boolean global flag // set a boolean global flag
static int set_bool_flag(const char* name, const char* value, Flag::Flags origin, FormatBuffer<80>& err_msg); static int set_bool_flag(const char* name, const char* value, Flag::Flags origin, FormatBuffer<80>& err_msg);
// set a int global flag
static int set_int_flag(const char* name, const char* value, Flag::Flags origin, FormatBuffer<80>& err_msg);
// set a uint global flag
static int set_uint_flag(const char* name, const char* value, Flag::Flags origin, FormatBuffer<80>& err_msg);
// set a intx global flag // set a intx global flag
static int set_intx_flag(const char* name, const char* value, Flag::Flags origin, FormatBuffer<80>& err_msg); static int set_intx_flag(const char* name, const char* value, Flag::Flags origin, FormatBuffer<80>& err_msg);
// set a uintx global flag // set a uintx global flag
@ -66,6 +70,10 @@ private:
static int set_size_t_flag(const char* name, const char* value, Flag::Flags origin, FormatBuffer<80>& err_msg); static int set_size_t_flag(const char* name, const char* value, Flag::Flags origin, FormatBuffer<80>& err_msg);
// set a boolean global flag // set a boolean global flag
static int set_bool_flag(const char* name, bool value, Flag::Flags origin, FormatBuffer<80>& err_msg); static int set_bool_flag(const char* name, bool value, Flag::Flags origin, FormatBuffer<80>& err_msg);
// set a int global flag
static int set_int_flag(const char* name, int value, Flag::Flags origin, FormatBuffer<80>& err_msg);
// set a uint global flag
static int set_uint_flag(const char* name, uint value, Flag::Flags origin, FormatBuffer<80>& err_msg);
// set a intx global flag // set a intx global flag
static int set_intx_flag(const char* name, intx value, Flag::Flags origin, FormatBuffer<80>& err_msg); static int set_intx_flag(const char* name, intx value, Flag::Flags origin, FormatBuffer<80>& err_msg);
// set a uintx global flag // set a uintx global flag

View File

@ -122,6 +122,22 @@ Declares a structure type that can be used in other events.
<value type="CLASS" field="definingClassLoader" label="Defining Class Loader"/> <value type="CLASS" field="definingClassLoader" label="Defining Class Loader"/>
</event> </event>
<event id="IntFlagChanged" path="vm/flag/int_changed" label="Int Flag Changed"
is_instant="true">
<value type="UTF8" field="name" label="Name" />
<value type="INTEGER" field="old_value" label="Old Value" />
<value type="INTEGER" field="new_value" label="New Value" />
<value type="FLAGVALUEORIGIN" field="origin" label="Origin" />
</event>
<event id="UnsignedIntFlagChanged" path="vm/flag/uint_changed" label="Unsigned Int Flag Changed"
is_instant="true">
<value type="UTF8" field="name" label="Name" />
<value type="UINT" field="old_value" label="Old Value" />
<value type="UINT" field="new_value" label="New Value" />
<value type="FLAGVALUEORIGIN" field="origin" label="Origin" />
</event>
<event id="LongFlagChanged" path="vm/flag/long_changed" label="Long Flag Changed" <event id="LongFlagChanged" path="vm/flag/long_changed" label="Long Flag Changed"
is_instant="true"> is_instant="true">
<value type="UTF8" field="name" label="Name" /> <value type="UTF8" field="name" label="Name" />

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -37,6 +37,7 @@
EventLog* Events::_logs = NULL; EventLog* Events::_logs = NULL;
StringEventLog* Events::_messages = NULL; StringEventLog* Events::_messages = NULL;
StringEventLog* Events::_exceptions = NULL; StringEventLog* Events::_exceptions = NULL;
StringEventLog* Events::_redefinitions = NULL;
StringEventLog* Events::_deopt_messages = NULL; StringEventLog* Events::_deopt_messages = NULL;
EventLog::EventLog() { EventLog::EventLog() {
@ -66,6 +67,7 @@ void Events::init() {
if (LogEvents) { if (LogEvents) {
_messages = new StringEventLog("Events"); _messages = new StringEventLog("Events");
_exceptions = new StringEventLog("Internal exceptions"); _exceptions = new StringEventLog("Internal exceptions");
_redefinitions = new StringEventLog("Classes redefined");
_deopt_messages = new StringEventLog("Deoptimization events"); _deopt_messages = new StringEventLog("Deoptimization events");
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -186,6 +186,9 @@ class Events : AllStatic {
// Deoptization related messages // Deoptization related messages
static StringEventLog* _deopt_messages; static StringEventLog* _deopt_messages;
// Redefinition related messages
static StringEventLog* _redefinitions;
public: public:
static void print_all(outputStream* out); static void print_all(outputStream* out);
@ -198,6 +201,8 @@ class Events : AllStatic {
// Log exception related message // Log exception related message
static void log_exception(Thread* thread, const char* format, ...) ATTRIBUTE_PRINTF(2, 3); static void log_exception(Thread* thread, const char* format, ...) ATTRIBUTE_PRINTF(2, 3);
static void log_redefinition(Thread* thread, const char* format, ...) ATTRIBUTE_PRINTF(2, 3);
static void log_deopt_message(Thread* thread, const char* format, ...) ATTRIBUTE_PRINTF(2, 3); static void log_deopt_message(Thread* thread, const char* format, ...) ATTRIBUTE_PRINTF(2, 3);
// Register default loggers // Register default loggers
@ -222,6 +227,15 @@ inline void Events::log_exception(Thread* thread, const char* format, ...) {
} }
} }
inline void Events::log_redefinition(Thread* thread, const char* format, ...) {
if (LogEvents) {
va_list ap;
va_start(ap, format);
_redefinitions->logv(thread, format, ap);
va_end(ap);
}
}
inline void Events::log_deopt_message(Thread* thread, const char* format, ...) { inline void Events::log_deopt_message(Thread* thread, const char* format, ...) {
if (LogEvents) { if (LogEvents) {
va_list ap; va_list ap;