/* jvmstat global and subsystem counter name space - enumeration value *serveasanindexintothePerfDataManager::_name_space[]array *containingthecorrespondingnamespacestring.Onlythetoplevel *subsystemnamespacesarerepresentedhere.
*/ enum CounterNS { // top level name spaces
JAVA_NS,
COM_NS,
SUN_NS, // subsystem name spaces
JAVA_GC, // Garbage Collection name spaces
COM_GC,
SUN_GC,
JAVA_CI, // Compiler name spaces
COM_CI,
SUN_CI,
JAVA_CLS, // Class Loader name spaces
COM_CLS,
SUN_CLS,
JAVA_RT, // Runtime name spaces
COM_RT,
SUN_RT,
JAVA_OS, // Operating System name spaces
COM_OS,
SUN_OS,
JAVA_THREADS, // Threads System name spaces
COM_THREADS,
SUN_THREADS,
JAVA_PROPERTY, // Java Property name spaces
COM_PROPERTY,
SUN_PROPERTY,
NULL_NS,
COUNTERNS_LAST = NULL_NS
};
friendclass StatSampler; // for access to protected void sample() friendclass PerfDataManager; // for access to protected destructor friendclass VMStructs;
public:
// the Variability enum must be kept in synchronization with the // the com.sun.hotspot.perfdata.Variability class enum Variability {
V_Constant = 1,
V_Monotonic = 2,
V_Variable = 3,
V_last = V_Variable
};
// the Units enum must be kept in synchronization with the // the com.sun.hotspot.perfdata.Units class enum Units {
U_None = 1,
U_Bytes = 2,
U_Ticks = 3,
U_Events = 4,
U_String = 5,
U_Hertz = 6,
U_Last = U_Hertz
};
PerfData(CounterNS ns, constchar* name, Units u, Variability v); virtual ~PerfData();
// create the entry for the PerfData item in the PerfData memory region. // this region is maintained separately from the PerfData objects to // facilitate its use by external processes. void create_entry(BasicType dtype, size_t dsize, size_t dlen = 0);
// sample the data item given at creation time and write its value // into the its corresponding PerfMemory location. virtualvoid sample() = 0;
public:
// returns a boolean indicating the validity of this object. // the object is valid if and only if memory in PerfMemory // region was successfully allocated. inlinebool is_valid() { return _valuep != NULL; }
// returns a boolean indicating whether the underlying object // was allocated in the PerfMemory region or on the C heap. inlinebool is_on_c_heap() { return _on_c_heap; }
// returns a pointer to a char* containing the name of the item. // The pointer returned is the pointer to a copy of the name // passed to the constructor, not the pointer to the name in the // PerfData memory region. This redundancy is maintained for // security reasons as the PerfMemory region may be in shared // memory. constchar* name() { return _name; }
// returns the variability classification associated with this item
Variability variability() { return _v; }
// returns the units associated with this item.
Units units() { return _u; }
// returns the flags associated with this item.
Flags flags() { return _flags; }
// returns the address of the data portion of the item in the // PerfData memory region. inlinevoid* get_address() { return _valuep; }
};
/* *PerfLongSampleHelper,anditsaliasPerfSamplerHelper,isabaseclass *forhelperclassesthatrelyupontheStatSamplerperiodictaskto *invokethetake_sample()methodandwritethevaluereturnedtoits *appropriatelocationinthePerfDatamemoryregion.
*/ class PerfLongSampleHelper : public CHeapObj<mtInternal> { public: virtual jlong take_sample() = 0;
};
/* *PerfLongisthebaseclassforthevariousLongPerfDatasubtypes. *itcontainsimplementationdetailsthatarecommonamongitsderived *types.
*/ class PerfLong : public PerfData {
protected:
PerfLong(CounterNS ns, constchar* namep, Units u, Variability v);
public: // returns the value of the data portion of the item in the // PerfData memory region. inline jlong get_value() { return *(jlong*)_valuep; }
};
/* *ThePerfLongConstantclass,anditsaliasPerfConstant,implement *aPerfDatasubtypethatholdsajlongdatavaluethatissetupon *creationofaninstanceofthisclass.Thisclassprovidesno *methodsforchangingthedatavaluestoredinPerfDatamemoryregion.
*/ class PerfLongConstant : public PerfLong {
friendclass PerfDataManager; // for access to protected constructor
private: // hide sample() - no need to sample constants void sample() { }
protected:
PerfLongConstant(CounterNS ns, constchar* namep, Units u,
jlong initial_value=0)
: PerfLong(ns, namep, u, V_Constant) {
if (is_valid()) *(jlong*)_valuep = initial_value;
}
};
/* *ThePerfLongVariantclass,anditsaliasPerfVariant,implement *aPerfDatasubtypethatholdsajlongdatavaluethatcanbemodified *inanunrestrictedmanner.Thisclassprovidestheimplementationdetails *forcommonfunctionalityamongitsderivedtypes.
*/ class PerfLongVariant : public PerfLong {
/* *ThePerfStringConstantclassprovidesaPerfDatasubclassthat *allowsanullterminatedstringofsinglebytecharacterstobe *storedinthePerfDatamemoryregion.
*/ class PerfStringConstant : public PerfString {
friendclass PerfDataManager; // for access to protected constructor
private:
// hide sample() - no need to sample constants void sample() { }
protected:
// Restrict string constant lengths to be <= PerfMaxStringConstLength. // This prevents long string constants, as can occur with very // long classpaths or java command lines, from consuming too much // PerfData memory.
PerfStringConstant(CounterNS ns, constchar* namep, constchar* initial_value);
};
/* *ThePerfStringVariableclassprovidesaPerfDatasubclassthat *allowsanullterminatedstringofsinglebytecharacterdata *tobestoredinPerfDatamemoryregion.Thestringvaluecanbereset *afterinitialization.Ifthestringvalueis>=max_length,then *itwillbetruncatedtomax_lengthcharacters.Thecopiedstring *isalwaysnullterminated.
*/ class PerfStringVariable : public PerfString {
friendclass PerfDataManager; // for access to protected constructor
protected:
// sampling of string variables are not yet supported void sample() { }
// method to search for a instrumentation object by name staticbool by_name(void* name, PerfData* pd);
protected: // we expose the implementation here to facilitate the clone // method.
PerfDataArray* get_impl() { return _set; }
public:
// create a PerfDataList with the given initial length
PerfDataList(int length);
// create a PerfDataList as a shallow copy of the given PerfDataList
PerfDataList(PerfDataList* p);
~PerfDataList();
// return the PerfData item indicated by name, // or NULL if it doesn't exist.
PerfData* find_by_name(constchar* name);
// return true if a PerfData item with the name specified in the // argument exists, otherwise return false. bool contains(constchar* name) { return find_by_name(name) != NULL; }
// return the number of PerfData items in this list inlineint length();
// add a PerfData item to this list inlinevoid append(PerfData *p);
// create a new PerfDataList from this list. The new list is // a shallow copy of the original list and care should be taken // with respect to delete operations on the elements of the list // as the are likely in use by another copy of the list.
PerfDataList* clone();
// for backward compatibility with GrowableArray - need to implement // some form of iterator to provide a cleaner abstraction for // iteration over the container. inline PerfData* at(int index);
};
/* *ThePerfDataManagerclassisresponsibleforcreatingPerfData *subtypesviaasetafactorymethodsandformanaginglists *ofthevariousPerfDatatypes.
*/ class PerfDataManager : AllStatic {
friendclass StatSampler; // for access to protected PerfDataList methods
// add a PerfData item to the list(s) of know PerfData objects staticvoid add_item(PerfData* p, bool sampled);
protected:
// return the list of all known PerfData items that are to be // sampled by the StatSampler. static PerfDataList* sampled();
public:
// method to check for the existence of a PerfData item with // the given name. staticinlinebool exists(constchar* name);
// method to map a CounterNS enumeration to a namespace string staticconstchar* ns_to_string(CounterNS ns) { return _name_spaces[ns];
}
// methods to test the interface stability of a given counter namespace // staticbool is_stable_supported(CounterNS ns) { return (ns != NULL_NS) && ((ns % 3) == JAVA_NS);
} staticbool is_unstable_supported(CounterNS ns) { return (ns != NULL_NS) && ((ns % 3) == COM_NS);
}
// methods to test the interface stability of a given counter name // staticbool is_stable_supported(constchar* name) { constchar* javadot = "java."; return strncmp(name, javadot, strlen(javadot)) == 0;
} staticbool is_unstable_supported(constchar* name) { constchar* comdot = "com.sun."; return strncmp(name, comdot, strlen(comdot)) == 0;
}
// method to construct counter name strings in a given name space. // The string object is allocated from the Resource Area and calls // to this method must be made within a ResourceMark. // staticchar* counter_name(constchar* name_space, constchar* name);
// method to construct name space strings in a given name space. // The string object is allocated from the Resource Area and calls // to this method must be made within a ResourceMark. // staticchar* name_space(constchar* name_space, constchar* sub_space) { return counter_name(name_space, sub_space);
}
// same as above, but appends the instance number to the name space // staticchar* name_space(constchar* name_space, constchar* sub_space, int instance); staticchar* name_space(constchar* name_space, int instance);
// these methods provide the general interface for creating // performance data resources. The types of performance data // resources can be extended by adding additional create<type> // methods.
/* The PerfTraceTimedEvent class is responsible for counting the *occurrenceofsomeeventandmeasuringtheelapsedtimeof *theeventintwoseparatePerfCounterinstances. * *Example: * *staticPerfCounter*my_time_counter=PerfDataManager::create_counter("my.time.counter",PerfData::U_Ticks,CHECK); *staticPerfCounter*my_event_counter=PerfDataManager::create_counter("my.event.counter",PerfData::U_Events,CHECK); * *{ *PerfTraceTimedEventptte(my_time_counter,my_event_counter); *// perform the operation you want to count and measure *} * *Note:useofthisclassdoesnotneedtooccurwithinaguarded *block.TheUsePerfDataguardisusedwiththeimplementation *ofthisclass. *
*/ class PerfTraceTimedEvent : public PerfTraceTime {
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.