Commit 6b223191 by Benjamin Kosnik Committed by Benjamin Kosnik

profiler_container_size.h: Fix include guard, formatting fixes.

2009-12-09  Benjamin Kosnik  <bkoz@redhat.com>

	* include/profile/impl/profiler_container_size.h: Fix include
	guard, formatting fixes.
	* include/profile/impl/profiler_vector_size.h: Same.
	* include/profile/impl/profiler_hash_func.h: Same.
	* include/profile/impl/profiler_trace.h: Same.
	* include/profile/impl/profiler_vector_to_list.h: Same.
	* include/profile/impl/profiler.h: Same.
	* include/profile/impl/profiler_state.h: Same.
	* include/profile/impl/profiler_map_to_unordered_map.h: Same.
	* include/profile/impl/profiler_hashtable_size.h: Same.
	* include/profile/impl/profiler_node.h: Same.

From-SVN: r155123
parent 14aa6352
2009-12-09 Benjamin Kosnik <bkoz@redhat.com>
* include/profile/impl/profiler_container_size.h: Fix include
guard, formatting fixes.
* include/profile/impl/profiler_vector_size.h: Same.
* include/profile/impl/profiler_hash_func.h: Same.
* include/profile/impl/profiler_trace.h: Same.
* include/profile/impl/profiler_vector_to_list.h: Same.
* include/profile/impl/profiler.h: Same.
* include/profile/impl/profiler_state.h: Same.
* include/profile/impl/profiler_map_to_unordered_map.h: Same.
* include/profile/impl/profiler_hashtable_size.h: Same.
* include/profile/impl/profiler_node.h: Same.
2009-12-09 Roman Odaisky <to.roma.from.bugcc@qwertty.com> 2009-12-09 Roman Odaisky <to.roma.from.bugcc@qwertty.com>
PR libstdc++/42273 PR libstdc++/42273
......
...@@ -34,8 +34,8 @@ ...@@ -34,8 +34,8 @@
// Written by Lixia Liu and Silvius Rus. // Written by Lixia Liu and Silvius Rus.
#ifndef PROFCXX_PROFILER_H__ #ifndef _GLIBCXX_PROFILE_PROFILER_H
#define PROFCXX_PROFILER_H__ 1 #define _GLIBCXX_PROFILE_PROFILER_H 1
#ifdef __GXX_EXPERIMENTAL_CXX0X__ #ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <cstddef> #include <cstddef>
...@@ -311,4 +311,4 @@ namespace __gnu_profile ...@@ -311,4 +311,4 @@ namespace __gnu_profile
#include "profile/impl/profiler_vector_size.h" #include "profile/impl/profiler_vector_size.h"
#include "profile/impl/profiler_vector_to_list.h" #include "profile/impl/profiler_vector_to_list.h"
#endif // PROFCXX_PROFILER_H__ #endif // _GLIBCXX_PROFILE_PROFILER_H
...@@ -34,8 +34,8 @@ ...@@ -34,8 +34,8 @@
// Written by Lixia Liu and Silvius Rus. // Written by Lixia Liu and Silvius Rus.
#ifndef PROFCXX_PROFILER_HASH_FUNC_H__ #ifndef _GLIBCXX_PROFILE_PROFILER_HASH_FUNC_H
#define PROFCXX_PROFILER_HASH_FUNC_H__ 1 #define _GLIBCXX_PROFILE_PROFILER_HASH_FUNC_H 1
#ifdef __GXX_EXPERIMENTAL_CXX0X__ #ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <cstdlib> #include <cstdlib>
...@@ -52,141 +52,143 @@ ...@@ -52,141 +52,143 @@
namespace __gnu_profile namespace __gnu_profile
{ {
/** @brief A hash performance instrumentation line in the object table. */
class __hashfunc_info: public __object_info_base
{
public:
__hashfunc_info() :_M_longest_chain(0), _M_accesses(0), _M_hops(0) { }
__hashfunc_info(const __hashfunc_info& o);
__hashfunc_info(__stack_t __stack)
: __object_info_base(__stack), _M_longest_chain(0),
_M_accesses(0), _M_hops(0) { }
virtual ~__hashfunc_info() { }
void __merge(const __hashfunc_info& __o);
void __destruct(size_t __chain, size_t __accesses, size_t __hops);
void __write(FILE* __f) const;
float __magnitude() const { return static_cast<float>(_M_hops); }
const char* __advice() const { return "change hash function"; }
private:
size_t _M_longest_chain;
size_t _M_accesses;
size_t _M_hops;
};
inline __hashfunc_info::__hashfunc_info(const __hashfunc_info& __o)
: __object_info_base(__o)
{
_M_longest_chain = __o._M_longest_chain;
_M_accesses = __o._M_accesses;
_M_hops = __o._M_hops;
}
/** @brief A hash performance instrumentation line in the object table. */ inline void
class __hashfunc_info: public __object_info_base __hashfunc_info::__merge(const __hashfunc_info& __o)
{ {
public: _M_longest_chain = __max(_M_longest_chain, __o._M_longest_chain);
__hashfunc_info() _M_accesses += __o._M_accesses;
:_M_longest_chain(0), _M_accesses(0), _M_hops(0) {} _M_hops += __o._M_hops;
__hashfunc_info(const __hashfunc_info& o); }
__hashfunc_info(__stack_t __stack)
: __object_info_base(__stack),
_M_longest_chain(0), _M_accesses(0), _M_hops(0){}
virtual ~__hashfunc_info() {}
void __merge(const __hashfunc_info& __o);
void __destruct(size_t __chain, size_t __accesses, size_t __hops);
void __write(FILE* __f) const;
float __magnitude() const { return static_cast<float>(_M_hops); }
const char* __advice() const { return "change hash function"; }
private:
size_t _M_longest_chain;
size_t _M_accesses;
size_t _M_hops;
};
inline __hashfunc_info::__hashfunc_info(const __hashfunc_info& __o)
: __object_info_base(__o)
{
_M_longest_chain = __o._M_longest_chain;
_M_accesses = __o._M_accesses;
_M_hops = __o._M_hops;
}
inline void __hashfunc_info::__merge(const __hashfunc_info& __o)
{
_M_longest_chain = __max(_M_longest_chain, __o._M_longest_chain);
_M_accesses += __o._M_accesses;
_M_hops += __o._M_hops;
}
inline void __hashfunc_info::__destruct(size_t __chain, size_t __accesses,
size_t __hops)
{
_M_longest_chain = __max(_M_longest_chain, __chain);
_M_accesses += __accesses;
_M_hops += __hops;
}
/** @brief A hash performance instrumentation line in the stack table. */
class __hashfunc_stack_info: public __hashfunc_info {
public:
__hashfunc_stack_info(const __hashfunc_info& __o) : __hashfunc_info(__o) {}
};
/** @brief Hash performance instrumentation producer. */
class __trace_hash_func
: public __trace_base<__hashfunc_info, __hashfunc_stack_info>
{
public:
__trace_hash_func();
~__trace_hash_func() {}
// Insert a new node at construct with object, callstack and initial size.
void __insert(__object_t __obj, __stack_t __stack);
// Call at destruction/clean to set container final size.
void __destruct(const void* __obj, size_t __chain,
size_t __accesses, size_t __hops);
};
inline __trace_hash_func::__trace_hash_func()
: __trace_base<__hashfunc_info, __hashfunc_stack_info>()
{
__id = "hash-distr";
}
inline void __trace_hash_func::__insert(__object_t __obj, __stack_t __stack)
{
__add_object(__obj, __hashfunc_info(__stack));
}
inline void __hashfunc_info::__write(FILE* __f) const
{
fprintf(__f, "%Zu %Zu %Zu\n", _M_hops, _M_accesses, _M_longest_chain);
}
inline void __trace_hash_func::__destruct(const void* __obj, size_t __chain,
size_t __accesses, size_t __hops)
{
if (!__is_on()) return;
// First find the item from the live objects and update the informations. inline void
__hashfunc_info* __objs = __get_object_info(__obj); __hashfunc_info::__destruct(size_t __chain, size_t __accesses, size_t __hops)
if (!__objs) {
return; _M_longest_chain = __max(_M_longest_chain, __chain);
_M_accesses += __accesses;
_M_hops += __hops;
}
__objs->__destruct(__chain, __accesses, __hops); /** @brief A hash performance instrumentation line in the stack table. */
__retire_object(__obj); class __hashfunc_stack_info: public __hashfunc_info
} {
public:
__hashfunc_stack_info(const __hashfunc_info& __o) : __hashfunc_info(__o) { }
};
/** @brief Hash performance instrumentation producer. */
class __trace_hash_func
: public __trace_base<__hashfunc_info, __hashfunc_stack_info>
{
public:
__trace_hash_func();
~__trace_hash_func() { }
// Insert a new node at construct with object, callstack and initial size.
void __insert(__object_t __obj, __stack_t __stack);
// Call at destruction/clean to set container final size.
void __destruct(const void* __obj, size_t __chain, size_t __accesses,
size_t __hops);
};
inline __trace_hash_func::__trace_hash_func()
: __trace_base<__hashfunc_info, __hashfunc_stack_info>()
{ __id = "hash-distr"; }
inline void
__trace_hash_func::__insert(__object_t __obj, __stack_t __stack)
{ __add_object(__obj, __hashfunc_info(__stack)); }
inline void
__hashfunc_info::__write(FILE* __f) const
{ fprintf(__f, "%Zu %Zu %Zu\n", _M_hops, _M_accesses, _M_longest_chain); }
inline void
__trace_hash_func::__destruct(const void* __obj, size_t __chain,
size_t __accesses, size_t __hops)
{
if (!__is_on())
return;
// First find the item from the live objects and update the informations.
__hashfunc_info* __objs = __get_object_info(__obj);
if (!__objs)
return;
__objs->__destruct(__chain, __accesses, __hops);
__retire_object(__obj);
}
//////////////////////////////////////////////////////////////////////////////
// Initialization and report.
//////////////////////////////////////////////////////////////////////////////
inline void __trace_hash_func_init() // Initialization and report.
{ inline void
__tables<0>::_S_hash_func = new __trace_hash_func(); __trace_hash_func_init()
} { __tables<0>::_S_hash_func = new __trace_hash_func(); }
inline void __trace_hash_func_report(FILE* __f, inline void
__warning_vector_t& __warnings) __trace_hash_func_report(FILE* __f, __warning_vector_t& __warnings)
{ {
if (__tables<0>::_S_hash_func) { if (__tables<0>::_S_hash_func)
__tables<0>::_S_hash_func->__collect_warnings(__warnings); {
__tables<0>::_S_hash_func->__write(__f); __tables<0>::_S_hash_func->__collect_warnings(__warnings);
__tables<0>::_S_hash_func->__write(__f);
}
} }
}
//////////////////////////////////////////////////////////////////////////////
// Implementations of instrumentation hooks.
//////////////////////////////////////////////////////////////////////////////
inline void __trace_hash_func_construct(const void* __obj) // Implementations of instrumentation hooks.
{ inline void
if (!__profcxx_init()) return; __trace_hash_func_construct(const void* __obj)
{
if (!__profcxx_init())
return;
__tables<0>::_S_hash_func->__insert(__obj, __get_stack()); __tables<0>::_S_hash_func->__insert(__obj, __get_stack());
} }
inline void __trace_hash_func_destruct(const void* __obj, size_t __chain, inline void
size_t __accesses, size_t __hops) __trace_hash_func_destruct(const void* __obj, size_t __chain,
{ size_t __accesses, size_t __hops)
if (!__profcxx_init()) return; {
if (!__profcxx_init())
return;
__tables<0>::_S_hash_func->__destruct(__obj, __chain, __accesses, __hops); __tables<0>::_S_hash_func->__destruct(__obj, __chain, __accesses, __hops);
} }
} // namespace __gnu_profile } // namespace __gnu_profile
#endif /* PROFCXX_PROFILER_HASH_FUNC_H__ */ #endif /* _GLIBCXX_PROFILE_PROFILER_HASH_FUNC_H */
...@@ -34,8 +34,8 @@ ...@@ -34,8 +34,8 @@
// Written by Lixia Liu and Silvius Rus. // Written by Lixia Liu and Silvius Rus.
#ifndef PROFCXX_PROFILER_HASHTABLE_SIZE_H__ #ifndef _GLIBCXX_PROFILE_PROFILER_HASHTABLE_SIZE_H
#define PROFCXX_PROFILER_HASHTABLE_SIZE_H__ 1 #define _GLIBCXX_PROFILE_PROFILER_HASHTABLE_SIZE_H 1
#ifdef __GXX_EXPERIMENTAL_CXX0X__ #ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <cstdlib> #include <cstdlib>
...@@ -54,62 +54,58 @@ ...@@ -54,62 +54,58 @@
namespace __gnu_profile namespace __gnu_profile
{ {
/** @brief Hashtable size instrumentation trace producer. */
/** @brief Hashtable size instrumentation trace producer. */ class __trace_hashtable_size : public __trace_container_size
class __trace_hashtable_size : public __trace_container_size
{
public:
__trace_hashtable_size() : __trace_container_size()
{ {
__id = "hashtable-size"; public:
__trace_hashtable_size() : __trace_container_size()
{ __id = "hashtable-size"; }
};
// Initialization and report.
inline void
__trace_hashtable_size_init()
{ __tables<0>::_S_hashtable_size = new __trace_hashtable_size(); }
inline void
__trace_hashtable_size_report(FILE* __f, __warning_vector_t& __warnings)
{
if (__tables<0>::_S_hashtable_size)
{
__tables<0>::_S_hashtable_size->__collect_warnings(__warnings);
__tables<0>::_S_hashtable_size->__write(__f);
}
} }
};
//////////////////////////////////////////////////////////////////////////////
// Initialization and report.
//////////////////////////////////////////////////////////////////////////////
inline void __trace_hashtable_size_init() // Implementations of instrumentation hooks.
{ inline void
__tables<0>::_S_hashtable_size = new __trace_hashtable_size(); __trace_hashtable_size_construct(const void* __obj, size_t __num)
} {
if (!__profcxx_init())
return;
inline void __trace_hashtable_size_report(FILE* __f, __tables<0>::_S_hashtable_size->__insert(__obj, __get_stack(), __num);
__warning_vector_t& __warnings)
{
if (__tables<0>::_S_hashtable_size) {
__tables<0>::_S_hashtable_size->__collect_warnings(__warnings);
__tables<0>::_S_hashtable_size->__write(__f);
} }
}
//////////////////////////////////////////////////////////////////////////////
// Implementations of instrumentation hooks.
//////////////////////////////////////////////////////////////////////////////
inline void __trace_hashtable_size_construct(const void* __obj, size_t __num) inline void
{ __trace_hashtable_size_destruct(const void* __obj, size_t __num,
if (!__profcxx_init()) return; size_t __inum)
{
__tables<0>::_S_hashtable_size->__insert(__obj, __get_stack(), __num); if (!__profcxx_init())
} return;
inline void __trace_hashtable_size_destruct(const void* __obj, size_t __num,
size_t __inum)
{
if (!__profcxx_init()) return;
__tables<0>::_S_hashtable_size->__destruct(__obj, __num, __inum); __tables<0>::_S_hashtable_size->__destruct(__obj, __num, __inum);
} }
inline void __trace_hashtable_size_resize(const void* __obj, size_t __from, inline void
size_t __to) __trace_hashtable_size_resize(const void* __obj, size_t __from, size_t __to)
{ {
if (!__profcxx_init()) return; if (!__profcxx_init())
return;
__tables<0>::_S_hashtable_size->__resize(__obj, __from, __to); __tables<0>::_S_hashtable_size->__resize(__obj, __from, __to);
} }
} // namespace __gnu_profile } // namespace __gnu_profile
#endif /* PROFCXX_PROFILER_HASHTABLE_SIZE_H__ */ #endif /* _GLIBCXX_PROFILE_PROFILER_HASHTABLE_SIZE_H */
...@@ -34,8 +34,8 @@ ...@@ -34,8 +34,8 @@
// Written by Lixia Liu and Silvius Rus. // Written by Lixia Liu and Silvius Rus.
#ifndef PROFCXX_PROFILER_NODE_H__ #ifndef _GLIBCXX_PROFILE_PROFILER_NODE_H
#define PROFCXX_PROFILER_NODE_H__ 1 #define _GLIBCXX_PROFILE_PROFILER_NODE_H 1
#ifdef __GXX_EXPERIMENTAL_CXX0X__ #ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <cstdio> #include <cstdio>
...@@ -53,120 +53,116 @@ ...@@ -53,120 +53,116 @@
namespace __gnu_profile namespace __gnu_profile
{ {
typedef const void* __object_t; typedef const void* __object_t;
typedef void* __instruction_address_t; typedef void* __instruction_address_t;
typedef std::_GLIBCXX_STD_PR::vector<__instruction_address_t> __stack_npt; typedef std::_GLIBCXX_STD_PR::vector<__instruction_address_t> __stack_npt;
typedef __stack_npt* __stack_t; typedef __stack_npt* __stack_t;
size_t __stack_max_depth(); size_t __stack_max_depth();
inline __stack_t __get_stack() inline __stack_t __get_stack()
{ {
#if defined HAVE_EXECINFO_H #if defined HAVE_EXECINFO_H
size_t __max_depth = __stack_max_depth(); size_t __max_depth = __stack_max_depth();
if (__max_depth == 0) if (__max_depth == 0)
return NULL; return NULL;
__stack_npt __buffer(__max_depth); __stack_npt __buffer(__max_depth);
int __depth = backtrace(&__buffer[0], __max_depth); int __depth = backtrace(&__buffer[0], __max_depth);
__stack_t __stack = new __stack_npt(__depth); __stack_t __stack = new __stack_npt(__depth);
memcpy(&(*__stack)[0], &__buffer[0], __depth * sizeof(__object_t)); memcpy(&(*__stack)[0], &__buffer[0], __depth * sizeof(__object_t));
return __stack; return __stack;
#else #else
return NULL; return NULL;
#endif #endif
}
inline __size(const __stack_t& __stack)
{
if (!__stack) {
return 0;
} else {
return __stack->size();
} }
}
inline void __write(FILE* __f, const __stack_t __stack) inline __size(const __stack_t& __stack)
{ {
if (!__stack) { if (!__stack)
return; return 0;
} else
return __stack->size();
__stack_npt::const_iterator __it;
for (__it = __stack->begin(); __it != __stack->end(); ++__it) {
fprintf(__f, "%p ", *__it);
} }
}
/** @brief Hash function for summary trace using call stack as index. */ inline void __write(FILE* __f, const __stack_t __stack)
class __stack_hash
{
public:
size_t operator()(const __stack_t __s) const
{ {
if (!__s) { if (!__stack)
return 0; return;
}
uintptr_t __index = 0;
__stack_npt::const_iterator __it; __stack_npt::const_iterator __it;
for (__it = __s->begin(); __it != __s->end(); ++__it) { for (__it = __stack->begin(); __it != __stack->end(); ++__it)
__index += reinterpret_cast<uintptr_t>(*__it); fprintf(__f, "%p ", *__it);
}
return __index;
} }
bool operator() (const __stack_t __stack1, const __stack_t __stack2) const /** @brief Hash function for summary trace using call stack as index. */
class __stack_hash
{ {
if (!__stack1 && !__stack2) return true; public:
if (!__stack1 || !__stack2) return false; size_t operator()(const __stack_t __s) const
if (__stack1->size() != __stack2->size()) return false; {
if (!__s)
return 0;
uintptr_t __index = 0;
__stack_npt::const_iterator __it;
for (__it = __s->begin(); __it != __s->end(); ++__it)
{
__index += reinterpret_cast<uintptr_t>(*__it);
}
return __index;
}
size_t __byte_size = __stack1->size() * sizeof(__stack_npt::value_type); bool operator() (const __stack_t __stack1, const __stack_t __stack2) const
return memcmp(&(*__stack1)[0], &(*__stack2)[0], __byte_size) == 0; {
} if (!__stack1 && !__stack2) return true;
}; if (!__stack1 || !__stack2) return false;
if (__stack1->size() != __stack2->size()) return false;
/** @brief Base class for a line in the object table. */ size_t __byte_size = __stack1->size() * sizeof(__stack_npt::value_type);
class __object_info_base return memcmp(&(*__stack1)[0], &(*__stack2)[0], __byte_size) == 0;
{ }
public: };
__object_info_base() {}
__object_info_base(__stack_t __stack);
__object_info_base(const __object_info_base& o);
virtual ~__object_info_base() {}
bool __is_valid() const { return _M_valid; }
__stack_t __stack() const { return _M_stack; }
virtual void __write(FILE* f) const = 0;
protected:
__stack_t _M_stack;
bool _M_valid;
};
inline __object_info_base::__object_info_base(__stack_t __stack)
{
_M_stack = __stack;
_M_valid = true;
}
inline __object_info_base::__object_info_base(const __object_info_base& __o) /** @brief Base class for a line in the object table. */
{ class __object_info_base
_M_stack = __o._M_stack; {
_M_valid = __o._M_valid; public:
} __object_info_base() { }
__object_info_base(__stack_t __stack);
__object_info_base(const __object_info_base& o);
virtual ~__object_info_base() { }
bool __is_valid() const { return _M_valid; }
__stack_t __stack() const { return _M_stack; }
virtual void __write(FILE* f) const = 0;
protected:
__stack_t _M_stack;
bool _M_valid;
};
inline __object_info_base::__object_info_base(__stack_t __stack)
{
_M_stack = __stack;
_M_valid = true;
}
/** @brief Base class for a line in the stack table. */ inline __object_info_base::__object_info_base(const __object_info_base& __o)
template<typename __object_info> {
class __stack_info_base _M_stack = __o._M_stack;
{ _M_valid = __o._M_valid;
public: }
__stack_info_base() {}
__stack_info_base(const __object_info& __info) = 0;
virtual ~__stack_info_base() {}
void __merge(const __object_info& __info) = 0;
virtual float __magnitude() const = 0;
virtual const char* __get_id() const = 0;
};
/** @brief Base class for a line in the stack table. */
template<typename __object_info>
class __stack_info_base
{
public:
__stack_info_base() { }
__stack_info_base(const __object_info& __info) = 0;
virtual ~__stack_info_base() { }
void __merge(const __object_info& __info) = 0;
virtual float __magnitude() const = 0;
virtual const char* __get_id() const = 0;
};
} // namespace __gnu_profile } // namespace __gnu_profile
#endif /* PROFCXX_PROFILER_NODE_H__ */ #endif /* _GLIBCXX_PROFILE_PROFILER_NODE_H */
...@@ -34,8 +34,8 @@ ...@@ -34,8 +34,8 @@
// Written by Lixia Liu and Silvius Rus. // Written by Lixia Liu and Silvius Rus.
#ifndef PROFCXX_PROFILER_STATE_H__ #ifndef _GLIBCXX_PROFILE_PROFILER_STATE_H
#define PROFCXX_PROFILER_STATE_H__ 1 #define _GLIBCXX_PROFILE_PROFILER_STATE_H 1
#ifdef __GXX_EXPERIMENTAL_CXX0X__ #ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <cstdio> #include <cstdio>
...@@ -45,63 +45,64 @@ ...@@ -45,63 +45,64 @@
namespace __gnu_profile namespace __gnu_profile
{ {
/** @brief Profiling mode on/off state. */
template<int _Unused=0>
class __state
{
private:
enum __state_type { __ON, __OFF, __INVALID };
__state_type _M_state;
public:
static __state<_Unused>* _S_diag_state;
__state() : _M_state(__INVALID) { }
~__state() { }
bool __is_on() { return _M_state == __ON; }
bool __is_off() { return _M_state == __OFF; }
bool __is_invalid() { return _M_state == __INVALID; }
void __turn_on() { _M_state = __ON; }
void __turn_off() { _M_state = __OFF; }
};
template<int _Unused>
__state<_Unused>* __state<_Unused>::_S_diag_state = NULL;
inline bool
__is_on()
{
return __state<0>::_S_diag_state && __state<0>::_S_diag_state->__is_on();
}
/** @brief Profiling mode on/off state. */ inline bool
template <int _Unused=0> __is_off()
class __state {
{ return __state<0>::_S_diag_state && __state<0>::_S_diag_state->__is_off();
public: }
static __state<_Unused>* _S_diag_state;
__state() : _M_state(__INVALID) {}
~__state() {}
bool __is_on() { return _M_state == __ON; }
bool __is_off() { return _M_state == __OFF; }
bool __is_invalid() { return _M_state == __INVALID; }
void __turn_on() { _M_state = __ON; }
void __turn_off() { _M_state = __OFF; }
private:
enum __state_type { __ON, __OFF, __INVALID };
__state_type _M_state;
};
template <int _Unused>
__state<_Unused>* __state<_Unused>::_S_diag_state = NULL;
inline bool __is_on()
{
return __state<0>::_S_diag_state && __state<0>::_S_diag_state->__is_on();
}
inline bool __is_off()
{
return __state<0>::_S_diag_state && __state<0>::_S_diag_state->__is_off();
}
inline bool __is_invalid() inline bool
{ __is_invalid()
return (!__state<0>::_S_diag_state {
|| __state<0>::_S_diag_state->__is_invalid()); return (!__state<0>::_S_diag_state || __state<0>::_S_diag_state->__is_invalid());
} }
inline void __turn_on() inline void
{ __turn_on()
if (!__state<0>::_S_diag_state) { {
__state<0>::_S_diag_state = new __state<0>(); if (!__state<0>::_S_diag_state)
__state<0>::_S_diag_state = new __state<0>();
__state<0>::_S_diag_state->__turn_on();
} }
__state<0>::_S_diag_state->__turn_on();
}
inline void __turn_off() inline void
{ __turn_off()
if (!__state<0>::_S_diag_state) { {
__state<0>::_S_diag_state = new __state<0>(); if (!__state<0>::_S_diag_state)
__state<0>::_S_diag_state = new __state<0>();
__state<0>::_S_diag_state->__turn_off();
} }
__state<0>::_S_diag_state->__turn_off();
}
} // end namespace __gnu_profile } // end namespace __gnu_profile
#endif /* PROFCXX_PROFILER_STATE_H__ */ #endif /* _GLIBCXX_PROFILE_PROFILER_STATE_H */
...@@ -34,8 +34,8 @@ ...@@ -34,8 +34,8 @@
// Written by Lixia Liu and Silvius Rus. // Written by Lixia Liu and Silvius Rus.
#ifndef PROFCXX_PROFILER_VECTOR_SIZE_H__ #ifndef _GLIBCXX_PROFILE_PROFILER_VECTOR_SIZE_H
#define PROFCXX_PROFILER_VECTOR_SIZE_H__ 1 #define _GLIBCXX_PROFILE_PROFILER_VECTOR_SIZE_H 1
#ifdef __GXX_EXPERIMENTAL_CXX0X__ #ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <cstdlib> #include <cstdlib>
...@@ -54,59 +54,49 @@ ...@@ -54,59 +54,49 @@
namespace __gnu_profile namespace __gnu_profile
{ {
/** @brief Hashtable size instrumentation trace producer. */
/** @brief Hashtable size instrumentation trace producer. */ class __trace_vector_size : public __trace_container_size
class __trace_vector_size : public __trace_container_size {
{ public:
public: __trace_vector_size() : __trace_container_size() { __id = "vector-size"; }
__trace_vector_size() : __trace_container_size() { __id = "vector-size"; } };
};
// Initialization and report.
////////////////////////////////////////////////////////////////////////////// inline void
// Initialization and report. __trace_vector_size_init()
////////////////////////////////////////////////////////////////////////////// { __tables<0>::_S_vector_size = new __trace_vector_size(); }
inline void __trace_vector_size_init() inline void
{ __trace_vector_size_report(FILE* __f, __warning_vector_t& __warnings)
__tables<0>::_S_vector_size = new __trace_vector_size(); {
} if (__tables<0>::_S_vector_size)
{
inline void __trace_vector_size_report(FILE* __f, __tables<0>::_S_vector_size->__collect_warnings(__warnings);
__warning_vector_t& __warnings) __tables<0>::_S_vector_size->__write(__f);
{ }
if (__tables<0>::_S_vector_size) {
__tables<0>::_S_vector_size->__collect_warnings(__warnings);
__tables<0>::_S_vector_size->__write(__f);
} }
}
//////////////////////////////////////////////////////////////////////////////
// Implementations of instrumentation hooks.
//////////////////////////////////////////////////////////////////////////////
inline void __trace_vector_size_construct(const void* __obj, size_t __num)
{
if (!__profcxx_init()) return;
__tables<0>::_S_vector_size->__insert(__obj, __get_stack(), __num);
}
inline void __trace_vector_size_destruct(const void* __obj, size_t __num,
size_t __inum)
{
if (!__profcxx_init()) return;
__tables<0>::_S_vector_size->__destruct(__obj, __num, __inum);
}
inline void __trace_vector_size_resize(const void* __obj, size_t __from, // Implementations of instrumentation hooks.
size_t __to) inline void
{ __trace_vector_size_construct(const void* __obj, size_t __num)
if (!__profcxx_init()) return; {
if (!__profcxx_init()) return;
__tables<0>::_S_vector_size->__insert(__obj, __get_stack(), __num);
}
__tables<0>::_S_vector_size->__resize(__obj, __from, __to); inline void
} __trace_vector_size_destruct(const void* __obj, size_t __num, size_t __inum)
{
if (!__profcxx_init()) return;
__tables<0>::_S_vector_size->__destruct(__obj, __num, __inum);
}
inline void
__trace_vector_size_resize(const void* __obj, size_t __from, size_t __to)
{
if (!__profcxx_init()) return;
__tables<0>::_S_vector_size->__resize(__obj, __from, __to);
}
} // namespace __gnu_profile } // namespace __gnu_profile
#endif /* PROFCXX_PROFILER_VECTOR_SIZE_H__ */ #endif /* _GLIBCXX_PROFILE_PROFILER_VECTOR_SIZE_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment