Commit b0af13ea by Paolo Carlini Committed by Paolo Carlini

profiler_list_to_slist.h: Fix formatting, other minor stylistic changes.

2010-06-22  Paolo Carlini  <paolo.carlini@oracle.com>

	* include/profile/impl/profiler_list_to_slist.h: Fix formatting,
	other minor stylistic changes.
	* include/profile/impl/profiler_container_size.h: Likewise.
	* include/profile/impl/profiler_vector_size.h: Likewise.
	* include/profile/impl/profiler_hash_func.h: Likewise.
	* include/profile/impl/profiler_trace.h: Likewise.
	* include/profile/impl/profiler_list_to_vector.h: Likewise.
	* include/profile/impl/profiler_vector_to_list.h: Likewise.
	* include/profile/impl/profiler_state.h: Likewise.
	* include/profile/impl/profiler_map_to_unordered_map.h: Likewise.
	* include/profile/impl/profiler_hashtable_size.h: Likewise.
	* include/profile/impl/profiler_node.h: Likewise.

From-SVN: r161236
parent b2e894b5
2010-06-22 Paolo Carlini <paolo.carlini@oracle.com>
* include/profile/impl/profiler_list_to_slist.h: Fix formatting,
other minor stylistic changes.
* include/profile/impl/profiler_container_size.h: Likewise.
* include/profile/impl/profiler_vector_size.h: Likewise.
* include/profile/impl/profiler_hash_func.h: Likewise.
* include/profile/impl/profiler_trace.h: Likewise.
* include/profile/impl/profiler_list_to_vector.h: Likewise.
* include/profile/impl/profiler_vector_to_list.h: Likewise.
* include/profile/impl/profiler_state.h: Likewise.
* include/profile/impl/profiler_map_to_unordered_map.h: Likewise.
* include/profile/impl/profiler_hashtable_size.h: Likewise.
* include/profile/impl/profiler_node.h: Likewise.
2010-06-22 Matthias Klose <doko@ubuntu.com> 2010-06-22 Matthias Klose <doko@ubuntu.com>
* python/libstdcxx/v6/printers.py: Don't use string exceptions. * python/libstdcxx/v6/printers.py: Don't use string exceptions.
......
...@@ -52,134 +52,137 @@ ...@@ -52,134 +52,137 @@
namespace __gnu_profile namespace __gnu_profile
{ {
/** @brief A hash performance instrumentation line in the object table. */
/** @brief A hash performance instrumentation line in the object table. */ class __hashfunc_info
class __hashfunc_info: public __object_info_base : public __object_info_base
{ {
public: public:
__hashfunc_info() __hashfunc_info()
:_M_longest_chain(0), _M_accesses(0), _M_hops(0) {} : _M_longest_chain(0), _M_accesses(0), _M_hops(0) { }
__hashfunc_info(const __hashfunc_info& o);
__hashfunc_info(__stack_t __stack) __hashfunc_info(const __hashfunc_info& __o)
: __object_info_base(__stack), : __object_info_base(__o), _M_longest_chain(__o._M_longest_chain),
_M_longest_chain(0), _M_accesses(0), _M_hops(0){} _M_accesses(__o._M_accesses), _M_hops(__o._M_hops) { }
virtual ~__hashfunc_info() {}
__hashfunc_info(__stack_t __stack)
void __merge(const __hashfunc_info& __o); : __object_info_base(__stack),
void __destruct(size_t __chain, size_t __accesses, size_t __hops); _M_longest_chain(0), _M_accesses(0), _M_hops(0){ }
void __write(FILE* __f) const;
float __magnitude() const { return static_cast<float>(_M_hops); } virtual ~__hashfunc_info() {}
const char* __advice() const { return strdup("change hash function"); }
void
private: __merge(const __hashfunc_info& __o)
size_t _M_longest_chain; {
size_t _M_accesses; _M_longest_chain = std::max(_M_longest_chain, __o._M_longest_chain);
size_t _M_hops; _M_accesses += __o._M_accesses;
}; _M_hops += __o._M_hops;
}
inline __hashfunc_info::__hashfunc_info(const __hashfunc_info& __o)
: __object_info_base(__o) void
{ __destruct(size_t __chain, size_t __accesses, size_t __hops)
_M_longest_chain = __o._M_longest_chain; {
_M_accesses = __o._M_accesses; _M_longest_chain = std::max(_M_longest_chain, __chain);
_M_hops = __o._M_hops; _M_accesses += __accesses;
} _M_hops += __hops;
}
inline void __hashfunc_info::__merge(const __hashfunc_info& __o)
{ void
_M_longest_chain = std::max(_M_longest_chain, __o._M_longest_chain); __write(FILE* __f) const
_M_accesses += __o._M_accesses; { fprintf(__f, "%Zu %Zu %Zu\n", _M_hops, _M_accesses, _M_longest_chain); }
_M_hops += __o._M_hops;
} float
__magnitude() const
inline void __hashfunc_info::__destruct(size_t __chain, size_t __accesses, { return static_cast<float>(_M_hops); }
size_t __hops)
{ const char*
_M_longest_chain = std::max(_M_longest_chain, __chain); __advice() const
_M_accesses += __accesses; { return strdup("change hash function"); }
_M_hops += __hops;
} private:
size_t _M_longest_chain;
/** @brief A hash performance instrumentation line in the stack table. */ size_t _M_accesses;
class __hashfunc_stack_info: public __hashfunc_info { size_t _M_hops;
public: };
__hashfunc_stack_info(const __hashfunc_info& __o) : __hashfunc_info(__o) {}
};
/** @brief A hash performance instrumentation line in the stack table. */
/** @brief Hash performance instrumentation producer. */ class __hashfunc_stack_info
class __trace_hash_func : public __hashfunc_info
: public __trace_base<__hashfunc_info, __hashfunc_stack_info> {
{ public:
public: __hashfunc_stack_info(const __hashfunc_info& __o)
__trace_hash_func(); : __hashfunc_info(__o) { }
~__trace_hash_func() {} };
// Insert a new node at construct with object, callstack and initial size.
void __insert(__object_t __obj, __stack_t __stack); /** @brief Hash performance instrumentation producer. */
// Call at destruction/clean to set container final size. class __trace_hash_func
void __destruct(const void* __obj, size_t __chain, : public __trace_base<__hashfunc_info, __hashfunc_stack_info>
size_t __accesses, size_t __hops); {
}; public:
__trace_hash_func()
inline __trace_hash_func::__trace_hash_func()
: __trace_base<__hashfunc_info, __hashfunc_stack_info>() : __trace_base<__hashfunc_info, __hashfunc_stack_info>()
{ { __id = "hash-distr"; }
__id = "hash-distr";
} ~__trace_hash_func() {}
inline void __trace_hash_func::__insert(__object_t __obj, __stack_t __stack) // Insert a new node at construct with object, callstack and initial size.
{ void
__add_object(__obj, __hashfunc_info(__stack)); __insert(__object_t __obj, __stack_t __stack)
} { __add_object(__obj, __hashfunc_info(__stack)); }
inline void __hashfunc_info::__write(FILE* __f) const // Call at destruction/clean to set container final size.
{ void
fprintf(__f, "%Zu %Zu %Zu\n", _M_hops, _M_accesses, _M_longest_chain); __destruct(const void* __obj, size_t __chain,
} size_t __accesses, size_t __hops)
{
inline void __trace_hash_func::__destruct(const void* __obj, size_t __chain, if (!__is_on())
size_t __accesses, size_t __hops) return;
{
if (!__is_on()) return; // First find the item from the live objects and update the informations.
__hashfunc_info* __objs = __get_object_info(__obj);
// First find the item from the live objects and update the informations. if (!__objs)
__hashfunc_info* __objs = __get_object_info(__obj); return;
if (!__objs)
return; __objs->__destruct(__chain, __accesses, __hops);
__retire_object(__obj);
__objs->__destruct(__chain, __accesses, __hops); }
__retire_object(__obj); };
}
inline void __trace_hash_func_init() inline void
{ __trace_hash_func_init()
_GLIBCXX_PROFILE_DATA(_S_hash_func) = new __trace_hash_func(); { _GLIBCXX_PROFILE_DATA(_S_hash_func) = new __trace_hash_func(); }
}
inline void
inline void __trace_hash_func_report(FILE* __f, __trace_hash_func_report(FILE* __f, __warning_vector_t& __warnings)
__warning_vector_t& __warnings) {
{ if (_GLIBCXX_PROFILE_DATA(_S_hash_func))
if (_GLIBCXX_PROFILE_DATA(_S_hash_func)) { {
_GLIBCXX_PROFILE_DATA(_S_hash_func)->__collect_warnings(__warnings); _GLIBCXX_PROFILE_DATA(_S_hash_func)->__collect_warnings(__warnings);
_GLIBCXX_PROFILE_DATA(_S_hash_func)->__write(__f); _GLIBCXX_PROFILE_DATA(_S_hash_func)->__write(__f);
}
} }
}
inline void __trace_hash_func_construct(const void* __obj) inline void
{ __trace_hash_func_construct(const void* __obj)
if (!__profcxx_init()) return; {
if (!__profcxx_init())
return;
_GLIBCXX_PROFILE_DATA(_S_hash_func)->__insert(__obj, __get_stack()); _GLIBCXX_PROFILE_DATA(_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;
_GLIBCXX_PROFILE_DATA(_S_hash_func)->__destruct(__obj, __chain, __accesses, _GLIBCXX_PROFILE_DATA(_S_hash_func)->__destruct(__obj, __chain, __accesses,
__hops); __hops);
} }
} // namespace __gnu_profile } // namespace __gnu_profile
#endif /* _GLIBCXX_PROFILE_PROFILER_HASH_FUNC_H */ #endif /* _GLIBCXX_PROFILE_PROFILER_HASH_FUNC_H */
// -*- C++ -*- // -*- C++ -*-
// //
// Copyright (C) 2009 Free Software Foundation, Inc. // Copyright (C) 2009, 2010 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -54,54 +54,60 @@ ...@@ -54,54 +54,60 @@
namespace __gnu_profile namespace __gnu_profile
{ {
/** @brief Hashtable size instrumentation trace producer. */
/** @brief Hashtable size instrumentation trace producer. */ class __trace_hashtable_size
class __trace_hashtable_size : public __trace_container_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"; }
inline void __trace_hashtable_size_init() };
{
_GLIBCXX_PROFILE_DATA(_S_hashtable_size) = new __trace_hashtable_size(); inline void
} __trace_hashtable_size_init()
{ _GLIBCXX_PROFILE_DATA(_S_hashtable_size) = new __trace_hashtable_size(); }
inline void __trace_hashtable_size_report(FILE* __f,
__warning_vector_t& __warnings) inline void
{ __trace_hashtable_size_report(FILE* __f, __warning_vector_t& __warnings)
if (_GLIBCXX_PROFILE_DATA(_S_hashtable_size)) { {
_GLIBCXX_PROFILE_DATA(_S_hashtable_size)->__collect_warnings(__warnings); if (_GLIBCXX_PROFILE_DATA(_S_hashtable_size))
_GLIBCXX_PROFILE_DATA(_S_hashtable_size)->__write(__f); {
_GLIBCXX_PROFILE_DATA(_S_hashtable_size)->
__collect_warnings(__warnings);
_GLIBCXX_PROFILE_DATA(_S_hashtable_size)->__write(__f);
}
} }
}
inline void __trace_hashtable_size_construct(const void* __obj, size_t __num) inline void
{ __trace_hashtable_size_construct(const void* __obj, size_t __num)
if (!__profcxx_init()) return; {
if (!__profcxx_init())
return;
_GLIBCXX_PROFILE_DATA(_S_hashtable_size)->__insert(__obj, __get_stack(), _GLIBCXX_PROFILE_DATA(_S_hashtable_size)->__insert(__obj, __get_stack(),
__num); __num);
} }
inline void __trace_hashtable_size_destruct(const void* __obj, size_t __num, inline void
size_t __inum) __trace_hashtable_size_destruct(const void* __obj, size_t __num,
{ size_t __inum)
if (!__profcxx_init()) return; {
if (!__profcxx_init())
return;
_GLIBCXX_PROFILE_DATA(_S_hashtable_size)->__destruct(__obj, __num, __inum); _GLIBCXX_PROFILE_DATA(_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;
_GLIBCXX_PROFILE_DATA(_S_hashtable_size)->__resize(__obj, __from, __to); _GLIBCXX_PROFILE_DATA(_S_hashtable_size)->__resize(__obj, __from, __to);
} }
} // namespace __gnu_profile } // namespace __gnu_profile
......
// -*- C++ -*- // -*- C++ -*-
// //
// Copyright (C) 2009 Free Software Foundation, Inc. // Copyright (C) 2009, 2010 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -52,131 +52,173 @@ ...@@ -52,131 +52,173 @@
namespace __gnu_profile namespace __gnu_profile
{ {
class __list2slist_info
class __list2slist_info: public __object_info_base : public __object_info_base
{ {
public: public:
__list2slist_info() : _M_rewind(false), _M_operations(0) {} __list2slist_info()
__list2slist_info(__stack_t __stack) : _M_rewind(false), _M_operations(0) { }
: _M_rewind(false), _M_operations(0),__object_info_base(__stack) {}
virtual ~__list2slist_info() {} __list2slist_info(__stack_t __stack)
__list2slist_info(const __list2slist_info& __o) : __object_info_base(__o) : __object_info_base(__stack), _M_rewind(false), _M_operations(0) { }
{ _M_rewind = __o._M_rewind; _M_operations = __o._M_operations; }
// XXX: the magnitude should be multiplied with a constant factor F, virtual ~__list2slist_info() { }
// where F is 1 when the malloc size class of list nodes is different
// from the malloc size class of slist nodes. When they fall into the same __list2slist_info(const __list2slist_info& __o)
// class, the only slist benefit is from having to set fewer links, so : __object_info_base(__o), _M_rewind(__o._M_rewind),
// the factor F should be much smaller, closer to 0 than to 1. _M_operations(__o._M_operations) { }
// This could be implemented by passing the size classes in the config file.
// For now, we always assume F to be 1. // XXX: the magnitude should be multiplied with a constant factor F,
float __magnitude() const // where F is 1 when the malloc size class of list nodes is different
{ if (!_M_rewind) return _M_operations; else return 0; } // from the malloc size class of slist nodes. When they fall into the same
void __merge(const __list2slist_info& __o) {}; // class, the only slist benefit is from having to set fewer links, so
void __write(FILE* __f) const; // the factor F should be much smaller, closer to 0 than to 1.
const char* __advice() const // This could be implemented by passing the size classes in the config
{ return strdup("change std::list to std::forward_list"); } // file. For now, we always assume F to be 1.
void __opr_rewind() { _M_rewind = true; _M_valid = false;}
void __record_operation() { _M_operations++; } float
bool __has_rewind() { return _M_rewind; } __magnitude() const
{
private: if (!_M_rewind)
bool _M_rewind; return _M_operations;
size_t _M_operations; else
}; return 0;
}
class __list2slist_stack_info: public __list2slist_info {
public: void
__list2slist_stack_info(const __list2slist_info& __o) __merge(const __list2slist_info&) { };
: __list2slist_info(__o) {}
}; void
__write(FILE* __f) const
class __trace_list_to_slist { fprintf(__f, "%s\n", _M_rewind ? "invalid" : "valid"); }
: public __trace_base<__list2slist_info, __list2slist_stack_info>
{ const char*
public: __advice() const
~__trace_list_to_slist() {} { return strdup("change std::list to std::forward_list"); }
__trace_list_to_slist()
: __trace_base<__list2slist_info, __list2slist_stack_info>() void
{ __id = "list-to-slist"; } __opr_rewind()
void __opr_rewind(const void* __obj); {
void __record_operation(const void* __obj); _M_rewind = true;
void __insert(const __object_t __obj, __stack_t __stack) _M_valid = false;
{ __add_object(__obj, __list2slist_info(__stack)); } }
void __destruct(const void* __obj);
}; void
__record_operation()
inline void __list2slist_info::__write(FILE* __f) const { _M_operations++; }
{
fprintf(__f, "%s\n", _M_rewind ? "invalid" : "valid"); bool
} __has_rewind()
{ return _M_rewind; }
inline void __trace_list_to_slist::__destruct(const void* __obj)
{ private:
if (!__is_on()) bool _M_rewind;
return; size_t _M_operations;
};
__list2slist_info* __res = __get_object_info(__obj);
if (!__res) class __list2slist_stack_info
return; : public __list2slist_info
{
__retire_object(__obj); public:
} __list2slist_stack_info(const __list2slist_info& __o)
: __list2slist_info(__o) { }
inline void __trace_list_to_slist_init() };
{
_GLIBCXX_PROFILE_DATA(_S_list_to_slist) = new __trace_list_to_slist(); class __trace_list_to_slist
} : public __trace_base<__list2slist_info, __list2slist_stack_info>
{
inline void __trace_list_to_slist_report(FILE* __f, public:
__warning_vector_t& __warnings) ~__trace_list_to_slist() { }
{
if (_GLIBCXX_PROFILE_DATA(_S_list_to_slist)) { __trace_list_to_slist()
_GLIBCXX_PROFILE_DATA(_S_list_to_slist)->__collect_warnings(__warnings); : __trace_base<__list2slist_info, __list2slist_stack_info>()
_GLIBCXX_PROFILE_DATA(_S_list_to_slist)->__write(__f); { __id = "list-to-slist"; }
void
__opr_rewind(const void* __obj)
{
__list2slist_info* __res = __get_object_info(__obj);
if (__res)
__res->__opr_rewind();
}
void
__record_operation(const void* __obj)
{
__list2slist_info* __res = __get_object_info(__obj);
if (__res)
__res->__record_operation();
}
void
__insert(const __object_t __obj, __stack_t __stack)
{ __add_object(__obj, __list2slist_info(__stack)); }
void
__destruct(const void* __obj)
{
if (!__is_on())
return;
__list2slist_info* __res = __get_object_info(__obj);
if (!__res)
return;
__retire_object(__obj);
}
};
inline void
__trace_list_to_slist_init()
{ _GLIBCXX_PROFILE_DATA(_S_list_to_slist) = new __trace_list_to_slist(); }
inline void
__trace_list_to_slist_report(FILE* __f, __warning_vector_t& __warnings)
{
if (_GLIBCXX_PROFILE_DATA(_S_list_to_slist))
{
_GLIBCXX_PROFILE_DATA(_S_list_to_slist)->
__collect_warnings(__warnings);
_GLIBCXX_PROFILE_DATA(_S_list_to_slist)->__write(__f);
}
} }
}
inline void __trace_list_to_slist::__opr_rewind(const void* __obj) inline void
{ __trace_list_to_slist_rewind(const void* __obj)
__list2slist_info* __res = __get_object_info(__obj); {
if (__res) if (!__profcxx_init())
__res->__opr_rewind(); return;
}
inline void __trace_list_to_slist::__record_operation(const void* __obj)
{
__list2slist_info* __res = __get_object_info(__obj);
if (__res)
__res->__record_operation();
}
inline void __trace_list_to_slist_rewind(const void* __obj) _GLIBCXX_PROFILE_DATA(_S_list_to_slist)->__opr_rewind(__obj);
{ }
if (!__profcxx_init()) return;
_GLIBCXX_PROFILE_DATA(_S_list_to_slist)->__opr_rewind(__obj);
}
inline void __trace_list_to_slist_operation(const void* __obj) inline void
{ __trace_list_to_slist_operation(const void* __obj)
if (!__profcxx_init()) return; {
if (!__profcxx_init())
return;
_GLIBCXX_PROFILE_DATA(_S_list_to_slist)->__record_operation(__obj); _GLIBCXX_PROFILE_DATA(_S_list_to_slist)->__record_operation(__obj);
} }
inline void __trace_list_to_slist_construct(const void* __obj) inline void
{ __trace_list_to_slist_construct(const void* __obj)
if (!__profcxx_init()) return; {
if (!__profcxx_init())
return;
_GLIBCXX_PROFILE_DATA(_S_list_to_slist)->__insert(__obj, __get_stack()); _GLIBCXX_PROFILE_DATA(_S_list_to_slist)->__insert(__obj, __get_stack());
} }
inline void __trace_list_to_slist_destruct(const void* __obj) inline void
{ __trace_list_to_slist_destruct(const void* __obj)
if (!__profcxx_init()) return; {
if (!__profcxx_init())
return;
_GLIBCXX_PROFILE_DATA(_S_list_to_slist)->__destruct(__obj); _GLIBCXX_PROFILE_DATA(_S_list_to_slist)->__destruct(__obj);
} }
} // namespace __gnu_profile } // namespace __gnu_profile
#endif /* _GLIBCXX_PROFILE_PROFILER_LIST_TO_SLIST_H */ #endif /* _GLIBCXX_PROFILE_PROFILER_LIST_TO_SLIST_H */
...@@ -53,120 +53,125 @@ ...@@ -53,120 +53,125 @@
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 _GLIBCXX_HAVE_EXECINFO_H #if defined _GLIBCXX_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 0; return 0;
__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 0;
#endif
}
inline __size(const __stack_t& __stack)
{
if (!__stack) {
return 0; return 0;
} else { #endif
return __stack->size();
}
}
inline void __write(FILE* __f, const __stack_t __stack)
{
if (!__stack) {
return;
}
__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 size_t
class __stack_hash __size(__stack_t __stack)
{
public:
size_t operator()(const __stack_t __s) const
{ {
if (!__s) { if (!__stack)
return 0; return 0;
} else
return __stack->size();
}
uintptr_t __index = 0; // XXX
inline void
__write(FILE* __f, __stack_t __stack)
{
if (!__stack)
return;
__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
if (__stack1->size() != __stack2->size()) return false; operator()(__stack_t __s) const
{
size_t __byte_size = __stack1->size() * sizeof(__stack_npt::value_type); if (!__s)
return memcmp(&(*__stack1)[0], &(*__stack2)[0], __byte_size) == 0; 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;
}
/** @brief Base class for a line in the object table. */ bool operator() (__stack_t __stack1, __stack_t __stack2) const
class __object_info_base {
{ if (!__stack1 && !__stack2)
public: return true;
__object_info_base() {} if (!__stack1 || !__stack2)
__object_info_base(__stack_t __stack); return false;
__object_info_base(const __object_info_base& o); if (__stack1->size() != __stack2->size())
virtual ~__object_info_base() {} return false;
bool __is_valid() const { return _M_valid; }
__stack_t __stack() const { return _M_stack; } size_t __byte_size = __stack1->size() * sizeof(__stack_npt::value_type);
virtual void __write(FILE* f) const = 0; return memcmp(&(*__stack1)[0], &(*__stack2)[0], __byte_size) == 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)
{
_M_stack = __o._M_stack;
_M_valid = __o._M_valid;
}
/** @brief Base class for a line in the stack table. */ /** @brief Base class for a line in the object table. */
template<typename __object_info> class __object_info_base
class __stack_info_base {
{ public:
public: __object_info_base() { }
__stack_info_base() {}
__stack_info_base(const __object_info& __info) = 0; __object_info_base(__stack_t __stack)
virtual ~__stack_info_base() {} : _M_stack(__stack), _M_valid(true) { }
void __merge(const __object_info& __info) = 0;
virtual float __magnitude() const = 0; __object_info_base(const __object_info_base& __o)
virtual const char* __get_id() const = 0; : _M_stack(__o._M_stack), _M_valid(__o._M_valid) { }
};
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;
};
/** @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 /* _GLIBCXX_PROFILE_PROFILER_NODE_H */ #endif /* _GLIBCXX_PROFILE_PROFILER_NODE_H */
// -*- C++ -*- // -*- C++ -*-
// //
// Copyright (C) 2009 Free Software Foundation, Inc. // Copyright (C) 2009, 2010 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -39,32 +39,35 @@ ...@@ -39,32 +39,35 @@
namespace __gnu_profile namespace __gnu_profile
{ {
enum __state_type { __ON, __OFF, __INVALID };
enum __state_type { __ON, __OFF, __INVALID }; _GLIBCXX_PROFILE_DEFINE_DATA(__state_type, __state, __INVALID);
_GLIBCXX_PROFILE_DEFINE_DATA(__state_type, __state, __INVALID); inline bool
__turn(__state_type __s)
{ return (_GLIBCXX_PROFILE_DATA(__state)
== __sync_val_compare_and_swap(&_GLIBCXX_PROFILE_DATA(__state),
__INVALID, __s)); }
inline bool __turn(__state_type __s) inline bool
{ __turn_on()
return (_GLIBCXX_PROFILE_DATA(__state) { return __turn(__ON); }
== __sync_val_compare_and_swap(&_GLIBCXX_PROFILE_DATA(__state),
__INVALID, __s));
}
inline bool __turn_on()
{ return __turn(__ON); }
inline bool __turn_off() inline bool
{ return __turn(__OFF); } __turn_off()
{ return __turn(__OFF); }
inline bool __is_on() inline bool
{ return _GLIBCXX_PROFILE_DATA(__state) == __ON; } __is_on()
{ return _GLIBCXX_PROFILE_DATA(__state) == __ON; }
inline bool __is_off() inline bool
{ return _GLIBCXX_PROFILE_DATA(__state) == __OFF; } __is_off()
{ return _GLIBCXX_PROFILE_DATA(__state) == __OFF; }
inline bool __is_invalid() inline bool
{ return _GLIBCXX_PROFILE_DATA(__state) == __INVALID; } __is_invalid()
{ return _GLIBCXX_PROFILE_DATA(__state) == __INVALID; }
} // end namespace __gnu_profile } // end namespace __gnu_profile
#endif /* _GLIBCXX_PROFILE_PROFILER_STATE_H */ #endif /* _GLIBCXX_PROFILE_PROFILER_STATE_H */
// -*- C++ -*- // -*- C++ -*-
// //
// Copyright (C) 2009 Free Software Foundation, Inc. // Copyright (C) 2009, 2010 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms // software; you can redistribute it and/or modify it under the terms
...@@ -54,50 +54,57 @@ ...@@ -54,50 +54,57 @@
namespace __gnu_profile namespace __gnu_profile
{ {
/** @brief Hashtable size instrumentation trace producer. */
/** @brief Hashtable size instrumentation trace producer. */ class __trace_vector_size
class __trace_vector_size : public __trace_container_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"; }
inline void __trace_vector_size_init() };
{
_GLIBCXX_PROFILE_DATA(_S_vector_size) = new __trace_vector_size(); inline void
} __trace_vector_size_init()
{ _GLIBCXX_PROFILE_DATA(_S_vector_size) = new __trace_vector_size(); }
inline void __trace_vector_size_report(FILE* __f,
__warning_vector_t& __warnings) inline void
{ __trace_vector_size_report(FILE* __f, __warning_vector_t& __warnings)
if (_GLIBCXX_PROFILE_DATA(_S_vector_size)) { {
_GLIBCXX_PROFILE_DATA(_S_vector_size)->__collect_warnings(__warnings); if (_GLIBCXX_PROFILE_DATA(_S_vector_size))
_GLIBCXX_PROFILE_DATA(_S_vector_size)->__write(__f); {
_GLIBCXX_PROFILE_DATA(_S_vector_size)->__collect_warnings(__warnings);
_GLIBCXX_PROFILE_DATA(_S_vector_size)->__write(__f);
}
} }
}
inline void __trace_vector_size_construct(const void* __obj, size_t __num) inline void
{ __trace_vector_size_construct(const void* __obj, size_t __num)
if (!__profcxx_init()) return; {
if (!__profcxx_init())
return;
_GLIBCXX_PROFILE_DATA(_S_vector_size)->__insert(__obj, __get_stack(), __num); _GLIBCXX_PROFILE_DATA(_S_vector_size)->__insert(__obj, __get_stack(),
} __num);
}
inline void __trace_vector_size_destruct(const void* __obj, size_t __num, inline void
size_t __inum) __trace_vector_size_destruct(const void* __obj, size_t __num, size_t __inum)
{ {
if (!__profcxx_init()) return; if (!__profcxx_init())
return;
_GLIBCXX_PROFILE_DATA(_S_vector_size)->__destruct(__obj, __num, __inum); _GLIBCXX_PROFILE_DATA(_S_vector_size)->__destruct(__obj, __num, __inum);
} }
inline void __trace_vector_size_resize(const void* __obj, size_t __from, inline void
size_t __to) __trace_vector_size_resize(const void* __obj, size_t __from, size_t __to)
{ {
if (!__profcxx_init()) return; if (!__profcxx_init())
return;
_GLIBCXX_PROFILE_DATA(_S_vector_size)->__resize(__obj, __from, __to); _GLIBCXX_PROFILE_DATA(_S_vector_size)->__resize(__obj, __from, __to);
} }
} // namespace __gnu_profile } // namespace __gnu_profile
......
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