profiler_trace.h (__warning_data:: __warning_message): Change to std::string...

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

	* include/profile/impl/profiler_trace.h (__warning_data::
	__warning_message): Change to std::string; clean-up includes,
	qualify size_t, fprintf, etc, with std everywhere.
	(struct __warn::operator()): Adjust.
	* include/profile/impl/profiler_list_to_slist.h
	(__list2slist_info::__advice): Change to return a std::string;
	clean-up includes, qualify size_t, fprintf, etc, with std.
	* include/profile/impl/profiler_container_size.h
	(__container_size_info::__advice): Likewise.
	* include/profile/impl/profiler_hash_func.h (__hashfunc_info::
	__advice): Likewise.
	* include/profile/impl/profiler_list_to_vector.h
	(__list2vector_info::__advice): Likewise.
	* include/profile/impl/profiler_vector_to_list.h
	(__vector2list_info::__advice): Likewise.
	* include/profile/impl/profiler_map_to_unordered_map.h
	(__map2umap_info::__advice): Likewise.
	* include/profile/impl/profiler.h: Likewise.
	* include/profile/impl/profiler_hashtable_size.h: Likewise.
	* include/profile/impl/profiler_node.h: Likewise.
	* include/profile/impl/profiler_vector_size.h: Likewise.

	* include/profile/iterator_tracker.h: Formatting and stylistic
	tweaks.
	* include/profile/base.h: Likewise.
	* include/profile/map.h: Likewise.

From-SVN: r161325
This commit is contained in:
Paolo Carlini 2010-06-24 16:17:55 +00:00 committed by Paolo Carlini
parent 4f8f9b8fa5
commit c7d42abb94
15 changed files with 522 additions and 587 deletions

View File

@ -1,3 +1,32 @@
2010-06-24 Paolo Carlini <paolo.carlini@oracle.com>
* include/profile/impl/profiler_trace.h (__warning_data::
__warning_message): Change to std::string; clean-up includes,
qualify size_t, fprintf, etc, with std everywhere.
(struct __warn::operator()): Adjust.
* include/profile/impl/profiler_list_to_slist.h
(__list2slist_info::__advice): Change to return a std::string;
clean-up includes, qualify size_t, fprintf, etc, with std.
* include/profile/impl/profiler_container_size.h
(__container_size_info::__advice): Likewise.
* include/profile/impl/profiler_hash_func.h (__hashfunc_info::
__advice): Likewise.
* include/profile/impl/profiler_list_to_vector.h
(__list2vector_info::__advice): Likewise.
* include/profile/impl/profiler_vector_to_list.h
(__vector2list_info::__advice): Likewise.
* include/profile/impl/profiler_map_to_unordered_map.h
(__map2umap_info::__advice): Likewise.
* include/profile/impl/profiler.h: Likewise.
* include/profile/impl/profiler_hashtable_size.h: Likewise.
* include/profile/impl/profiler_node.h: Likewise.
* include/profile/impl/profiler_vector_size.h: Likewise.
* include/profile/iterator_tracker.h: Formatting and stylistic
tweaks.
* include/profile/base.h: Likewise.
* include/profile/map.h: Likewise.
2010-06-23 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/stl_tree.h (erase(iterator), erase(const_iterator)):

View File

@ -38,9 +38,7 @@
#ifndef _GLIBCXX_PROFILE_BASE_H
#define _GLIBCXX_PROFILE_BASE_H 1
#include <cstdio>
#include <functional>
#include <bits/c++config.h>
#include <profile/impl/profiler.h>
// Profiling mode namespaces.

View File

@ -37,11 +37,7 @@
#ifndef _GLIBCXX_PROFILE_PROFILER_H
#define _GLIBCXX_PROFILE_PROFILER_H 1
#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <cstddef>
#else
#include <stddef.h>
#endif
#include <bits/c++config.h>
// Mechanism to define data with inline linkage.
#define _GLIBCXX_PROFILE_DEFINE_UNINIT_DATA(__type, __name) \
@ -109,47 +105,50 @@ namespace __gnu_profile
bool __is_on();
bool __is_off();
void __report(void);
void __trace_hashtable_size_resize(const void*, size_t, size_t);
void __trace_hashtable_size_destruct(const void*, size_t, size_t);
void __trace_hashtable_size_construct(const void*, size_t);
void __trace_vector_size_resize(const void*, size_t, size_t);
void __trace_vector_size_destruct(const void*, size_t, size_t);
void __trace_vector_size_construct(const void*, size_t);
void __trace_hash_func_destruct(const void*, size_t, size_t, size_t);
void __trace_hashtable_size_resize(const void*, std::size_t, std::size_t);
void __trace_hashtable_size_destruct(const void*, std::size_t, std::size_t);
void __trace_hashtable_size_construct(const void*, std::size_t);
void __trace_vector_size_resize(const void*, std::size_t, std::size_t);
void __trace_vector_size_destruct(const void*, std::size_t, std::size_t);
void __trace_vector_size_construct(const void*, std::size_t);
void __trace_hash_func_destruct(const void*, std::size_t, std::size_t,
std::size_t);
void __trace_hash_func_construct(const void*);
void __trace_vector_to_list_destruct(const void*);
void __trace_vector_to_list_construct(const void*);
void __trace_vector_to_list_insert(const void*, size_t, size_t);
void __trace_vector_to_list_iterate(const void*, size_t);
void __trace_vector_to_list_insert(const void*, std::size_t, std::size_t);
void __trace_vector_to_list_iterate(const void*, std::size_t);
void __trace_vector_to_list_invalid_operator(const void*);
void __trace_vector_to_list_resize(const void*, size_t, size_t);
void __trace_vector_to_list_find(const void*, size_t);
void __trace_vector_to_list_resize(const void*, std::size_t, std::size_t);
void __trace_vector_to_list_find(const void*, std::size_t);
void __trace_list_to_slist_destruct(const void*);
void __trace_list_to_slist_construct(const void*);
void __trace_list_to_slist_rewind(const void*);
void __trace_list_to_slist_rewind(const void*);
void __trace_list_to_slist_operation(const void*);
void __trace_list_to_vector_destruct(const void*);
void __trace_list_to_vector_construct(const void*);
void __trace_list_to_vector_insert(const void*, size_t, size_t);
void __trace_list_to_vector_iterate(const void*, size_t);
void __trace_list_to_vector_insert(const void*, std::size_t, std::size_t);
void __trace_list_to_vector_iterate(const void*, std::size_t);
void __trace_list_to_vector_invalid_operator(const void*);
void __trace_list_to_vector_resize(const void*, size_t, size_t);
void __trace_list_to_vector_resize(const void*, std::size_t, std::size_t);
void __trace_list_to_set_destruct(const void*);
void __trace_list_to_set_construct(const void*);
void __trace_list_to_set_insert(const void*, size_t, size_t);
void __trace_list_to_set_iterate(const void*, size_t);
void __trace_list_to_set_insert(const void*, std::size_t, std::size_t);
void __trace_list_to_set_iterate(const void*, std::size_t);
void __trace_list_to_set_invalid_operator(const void*);
void __trace_list_to_set_find(const void*, size_t);
void __trace_list_to_set_find(const void*, std::size_t);
void __trace_map_to_unordered_map_construct(const void*);
void __trace_map_to_unordered_map_invalidate(const void*);
void __trace_map_to_unordered_map_insert(const void*, size_t, size_t);
void __trace_map_to_unordered_map_erase(const void*, size_t, size_t);
void __trace_map_to_unordered_map_iterate(const void*, size_t);
void __trace_map_to_unordered_map_find(const void*, size_t);
void __trace_map_to_unordered_map_insert(const void*, std::size_t,
std::size_t);
void __trace_map_to_unordered_map_erase(const void*, std::size_t,
std::size_t);
void __trace_map_to_unordered_map_iterate(const void*, std::size_t);
void __trace_map_to_unordered_map_find(const void*, std::size_t);
void __trace_map_to_unordered_map_destruct(const void*);
} // namespace __gnu_profile

View File

@ -37,16 +37,6 @@
#ifndef _GLIBCXX_PROFILE_PROFILER_CONTAINER_SIZE_H
#define _GLIBCXX_PROFILE_PROFILER_CONTAINER_SIZE_H 1
#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <cstdlib>
#include <cstdio>
#include <cstring>
#else
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#endif
#include <sstream>
#include "profile/impl/profiler.h"
@ -56,7 +46,7 @@
namespace __gnu_profile
{
/** @brief A container size instrumentation line in the object table. */
class __container_size_info
class __container_size_info
: public __object_info_base
{
public:
@ -73,7 +63,7 @@ namespace __gnu_profile
_M_resize(__o._M_resize), _M_cost(__o._M_cost)
{ }
__container_size_info(__stack_t __stack, size_t __num)
__container_size_info(__stack_t __stack, std::size_t __num)
: __object_info_base(__stack), _M_init(__num), _M_max(__num),
_M_min(0), _M_total(0), _M_item_min(0), _M_item_max(0),
_M_item_total(0), _M_count(0), _M_resize(0), _M_cost(0)
@ -84,23 +74,23 @@ namespace __gnu_profile
void
__write(FILE* __f) const
{
fprintf(__f, "%Zu %Zu %Zu %Zu %Zu %Zu %Zu %Zu %Zu %Zu\n",
_M_init, _M_count, _M_cost, _M_resize, _M_min, _M_max, _M_total,
_M_item_min, _M_item_max, _M_item_total);
std::fprintf(__f, "%Zu %Zu %Zu %Zu %Zu %Zu %Zu %Zu %Zu %Zu\n",
_M_init, _M_count, _M_cost, _M_resize, _M_min, _M_max,
_M_total, _M_item_min, _M_item_max, _M_item_total);
}
float
__magnitude() const
{ return static_cast<float>(_M_cost); }
const char*
std::string
__advice() const
{
std::stringstream __message;
if (_M_init < _M_item_max)
__message << "change initial container size from " << _M_init
<< " to " << _M_item_max;
return strdup(__message.str().c_str());
return __message.str();
}
void
@ -120,7 +110,7 @@ namespace __gnu_profile
// Call if a container is destructed or cleaned.
void
__destruct(size_t __num, size_t __inum)
__destruct(std::size_t __num, std::size_t __inum)
{
_M_max = std::max(_M_max, __num);
_M_item_max = std::max(_M_item_max, __inum);
@ -141,12 +131,12 @@ namespace __gnu_profile
// Estimate the cost of resize/rehash.
float
__resize_cost(size_t __from, size_t)
__resize_cost(std::size_t __from, std::size_t)
{ return __from; }
// Call if container is resized.
void
__resize(size_t __from, size_t __to)
__resize(std::size_t __from, std::size_t __to)
{
_M_cost += this->__resize_cost(__from, __to);
_M_resize += 1;
@ -154,16 +144,16 @@ namespace __gnu_profile
}
private:
size_t _M_init;
size_t _M_max; // range of # buckets
size_t _M_min;
size_t _M_total;
size_t _M_item_min; // range of # items
size_t _M_item_max;
size_t _M_item_total;
size_t _M_count;
size_t _M_resize;
size_t _M_cost;
std::size_t _M_init;
std::size_t _M_max; // range of # buckets
std::size_t _M_min;
std::size_t _M_total;
std::size_t _M_item_min; // range of # items
std::size_t _M_item_max;
std::size_t _M_item_total;
std::size_t _M_count;
std::size_t _M_resize;
std::size_t _M_cost;
};

View File

@ -37,15 +37,6 @@
#ifndef _GLIBCXX_PROFILE_PROFILER_HASH_FUNC_H
#define _GLIBCXX_PROFILE_PROFILER_HASH_FUNC_H 1
#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <cstdlib>
#include <cstdio>
#include <cstring>
#else
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#endif
#include "profile/impl/profiler.h"
#include "profile/impl/profiler_node.h"
#include "profile/impl/profiler_trace.h"
@ -53,7 +44,7 @@
namespace __gnu_profile
{
/** @brief A hash performance instrumentation line in the object table. */
class __hashfunc_info
class __hashfunc_info
: public __object_info_base
{
public:
@ -66,9 +57,9 @@ namespace __gnu_profile
__hashfunc_info(__stack_t __stack)
: __object_info_base(__stack),
_M_longest_chain(0), _M_accesses(0), _M_hops(0){ }
_M_longest_chain(0), _M_accesses(0), _M_hops(0) { }
virtual ~__hashfunc_info() {}
virtual ~__hashfunc_info() { }
void
__merge(const __hashfunc_info& __o)
@ -79,7 +70,8 @@ namespace __gnu_profile
}
void
__destruct(size_t __chain, size_t __accesses, size_t __hops)
__destruct(std::size_t __chain, std::size_t __accesses,
std::size_t __hops)
{
_M_longest_chain = std::max(_M_longest_chain, __chain);
_M_accesses += __accesses;
@ -88,20 +80,21 @@ namespace __gnu_profile
void
__write(FILE* __f) const
{ fprintf(__f, "%Zu %Zu %Zu\n", _M_hops, _M_accesses, _M_longest_chain); }
{ std::fprintf(__f, "%Zu %Zu %Zu\n", _M_hops,
_M_accesses, _M_longest_chain); }
float
__magnitude() const
{ return static_cast<float>(_M_hops); }
const char*
std::string
__advice() const
{ return strdup("change hash function"); }
{ return "change hash function"; }
private:
size_t _M_longest_chain;
size_t _M_accesses;
size_t _M_hops;
std::size_t _M_longest_chain;
std::size_t _M_accesses;
std::size_t _M_hops;
};
@ -133,8 +126,8 @@ namespace __gnu_profile
// Call at destruction/clean to set container final size.
void
__destruct(const void* __obj, size_t __chain,
size_t __accesses, size_t __hops)
__destruct(const void* __obj, std::size_t __chain,
std::size_t __accesses, std::size_t __hops)
{
if (!__is_on())
return;
@ -174,14 +167,14 @@ namespace __gnu_profile
}
inline void
__trace_hash_func_destruct(const void* __obj, size_t __chain,
size_t __accesses, size_t __hops)
__trace_hash_func_destruct(const void* __obj, std::size_t __chain,
std::size_t __accesses, std::size_t __hops)
{
if (!__profcxx_init())
return;
_GLIBCXX_PROFILE_DATA(_S_hash_func)->__destruct(__obj, __chain, __accesses,
__hops);
_GLIBCXX_PROFILE_DATA(_S_hash_func)->__destruct(__obj, __chain,
__accesses, __hops);
}
} // namespace __gnu_profile

View File

@ -37,15 +37,6 @@
#ifndef _GLIBCXX_PROFILE_PROFILER_HASHTABLE_SIZE_H
#define _GLIBCXX_PROFILE_PROFILER_HASHTABLE_SIZE_H 1
#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <cstdlib>
#include <cstdio>
#include <cstring>
#else
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#endif
#include "profile/impl/profiler.h"
#include "profile/impl/profiler_node.h"
#include "profile/impl/profiler_trace.h"
@ -80,7 +71,7 @@ namespace __gnu_profile
}
inline void
__trace_hashtable_size_construct(const void* __obj, size_t __num)
__trace_hashtable_size_construct(const void* __obj, std::size_t __num)
{
if (!__profcxx_init())
return;
@ -90,8 +81,8 @@ namespace __gnu_profile
}
inline void
__trace_hashtable_size_destruct(const void* __obj, size_t __num,
size_t __inum)
__trace_hashtable_size_destruct(const void* __obj, std::size_t __num,
std::size_t __inum)
{
if (!__profcxx_init())
return;
@ -100,8 +91,8 @@ namespace __gnu_profile
}
inline void
__trace_hashtable_size_resize(const void* __obj, size_t __from,
size_t __to)
__trace_hashtable_size_resize(const void* __obj, std::size_t __from,
std::size_t __to)
{
if (!__profcxx_init())
return;

View File

@ -37,22 +37,13 @@
#ifndef _GLIBCXX_PROFILE_PROFILER_LIST_TO_SLIST_H
#define _GLIBCXX_PROFILE_PROFILER_LIST_TO_SLIST_H 1
#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <cstdlib>
#include <cstdio>
#include <cstring>
#else
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#endif
#include "profile/impl/profiler.h"
#include "profile/impl/profiler_node.h"
#include "profile/impl/profiler_trace.h"
namespace __gnu_profile
{
class __list2slist_info
class __list2slist_info
: public __object_info_base
{
public:
@ -90,11 +81,11 @@ namespace __gnu_profile
void
__write(FILE* __f) const
{ fprintf(__f, "%s\n", _M_rewind ? "invalid" : "valid"); }
{ std::fprintf(__f, "%s\n", _M_rewind ? "invalid" : "valid"); }
const char*
std::string
__advice() const
{ return strdup("change std::list to std::forward_list"); }
{ return "change std::list to std::forward_list"; }
void
__opr_rewind()
@ -113,7 +104,7 @@ namespace __gnu_profile
private:
bool _M_rewind;
size_t _M_operations;
std::size_t _M_operations;
};
class __list2slist_stack_info

View File

@ -37,17 +37,8 @@
#ifndef _GLIBCXX_PROFILE_PROFILER_LIST_TO_VECTOR_H
#define _GLIBCXX_PROFILE_PROFILER_LIST_TO_VECTOR_H 1
#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <cstdio>
#include <cstdlib>
#include <cstring>
#else
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#endif
#include <string>
#include <sstream>
#include "profile/impl/profiler.h"
#include "profile/impl/profiler_node.h"
#include "profile/impl/profiler_trace.h"
@ -55,7 +46,7 @@
namespace __gnu_profile
{
/** @brief A list-to-vector instrumentation line in the object table. */
class __list2vector_info
class __list2vector_info
: public __object_info_base
{
public:
@ -91,29 +82,29 @@ namespace __gnu_profile
void
__write(FILE* __f) const
{
fprintf(__f, "%Zu %Zu %Zu %.0f %.0f\n", _M_shift_count, _M_resize,
_M_iterate, _M_vector_cost, _M_list_cost);
std::fprintf(__f, "%Zu %Zu %Zu %.0f %.0f\n", _M_shift_count,
_M_resize, _M_iterate, _M_vector_cost, _M_list_cost);
}
float
__magnitude() const
{ return _M_list_cost - _M_vector_cost; }
const char*
std::string
__advice() const
{
std::stringstream __sstream;
__sstream
<< "change std::list to std::vector and its initial size from 0 to "
<< _M_max_size;
return strdup(__sstream.str().c_str());
return __sstream.str();
}
size_t
std::size_t
__shift_count()
{ return _M_shift_count; }
size_t
std::size_t
__iterate()
{ return _M_iterate; }
@ -121,7 +112,7 @@ namespace __gnu_profile
__list_cost()
{ return _M_list_cost; }
size_t
std::size_t
__resize()
{ return _M_resize; }
@ -142,28 +133,28 @@ namespace __gnu_profile
{ _M_valid = false; }
void
__opr_insert(size_t __shift, size_t __size)
__opr_insert(std::size_t __shift, std::size_t __size)
{
_M_shift_count += __shift;
_M_max_size = std::max(_M_max_size, __size);
}
void
__opr_iterate(size_t __num)
__opr_iterate(std::size_t __num)
{ _M_iterate += __num;}
void
__resize(size_t __from, size_t)
__resize(std::size_t __from, std::size_t)
{ _M_resize += __from; }
private:
size_t _M_shift_count;
size_t _M_iterate;
size_t _M_resize;
std::size_t _M_shift_count;
std::size_t _M_iterate;
std::size_t _M_resize;
float _M_list_cost;
float _M_vector_cost;
bool _M_valid;
size_t _M_max_size;
std::size_t _M_max_size;
};
class __list2vector_stack_info
@ -212,7 +203,7 @@ namespace __gnu_profile
// Collect cost of operations.
void
__opr_insert(const void* __obj, size_t __shift, size_t __size)
__opr_insert(const void* __obj, std::size_t __shift, std::size_t __size)
{
__list2vector_info* __res = __get_object_info(__obj);
if (__res)
@ -220,7 +211,7 @@ namespace __gnu_profile
}
void
__opr_iterate(const void* __obj, size_t __num)
__opr_iterate(const void* __obj, std::size_t __num)
{
__list2vector_info* __res = __get_object_info(__obj);
if (__res)
@ -236,7 +227,7 @@ namespace __gnu_profile
}
void
__resize(const void* __obj, size_t __from, size_t __to)
__resize(const void* __obj, std::size_t __from, std::size_t __to)
{
__list2vector_info* __res = __get_object_info(__obj);
if (__res)
@ -244,7 +235,7 @@ namespace __gnu_profile
}
float
__vector_cost(size_t __shift, size_t __iterate)
__vector_cost(std::size_t __shift, std::size_t __iterate)
{
// The resulting vector will use a 'reserve' method.
return (__shift
@ -254,7 +245,7 @@ namespace __gnu_profile
}
float
__list_cost(size_t __shift, size_t __iterate)
__list_cost(std::size_t __shift, std::size_t __iterate)
{
return (__shift
* _GLIBCXX_PROFILE_DATA(__list_shift_cost_factor).__value
@ -299,7 +290,7 @@ namespace __gnu_profile
inline void
__trace_list_to_vector_insert(const void* __obj,
size_t __shift, size_t __size)
std::size_t __shift, std::size_t __size)
{
if (!__profcxx_init())
return;
@ -309,7 +300,7 @@ namespace __gnu_profile
}
inline void
__trace_list_to_vector_iterate(const void* __obj, size_t __num = 1)
__trace_list_to_vector_iterate(const void* __obj, std::size_t __num = 1)
{
if (!__profcxx_init())
return;
@ -328,7 +319,7 @@ namespace __gnu_profile
inline void
__trace_list_to_vector_resize(const void* __obj,
size_t __from, size_t __to)
std::size_t __from, std::size_t __to)
{
if (!__profcxx_init())
return;

View File

@ -37,15 +37,6 @@
#ifndef _GLIBCXX_PROFILE_PROFILER_MAP_TO_UNORDERED_MAP_H
#define _GLIBCXX_PROFILE_PROFILER_MAP_TO_UNORDERED_MAP_H 1
#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <cstdlib>
#include <cstdio>
#include <cstring>
#else
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#endif
#include "profile/impl/profiler.h"
#include "profile/impl/profiler_node.h"
#include "profile/impl/profiler_trace.h"
@ -53,9 +44,9 @@
namespace __gnu_profile
{
inline int
__log2(size_t __size)
__log2(std::size_t __size)
{
for (int __bit_count = sizeof(size_t) - 1; __bit_count >= 0;
for (int __bit_count = sizeof(std::size_t) - 1; __bit_count >= 0;
-- __bit_count)
if ((2 << __bit_count) & __size)
return __bit_count;
@ -63,23 +54,23 @@ namespace __gnu_profile
}
inline float
__map_insert_cost(size_t __size)
__map_insert_cost(std::size_t __size)
{ return (_GLIBCXX_PROFILE_DATA(__map_insert_cost_factor).__value
* static_cast<float>(__log2(__size))); }
inline float
__map_erase_cost(size_t __size)
__map_erase_cost(std::size_t __size)
{ return (_GLIBCXX_PROFILE_DATA(__map_erase_cost_factor).__value
* static_cast<float>(__log2(__size))); }
inline float
__map_find_cost(size_t __size)
__map_find_cost(std::size_t __size)
{ return (_GLIBCXX_PROFILE_DATA(__map_find_cost_factor).__value
* static_cast<float>(__log2(__size))); }
/** @brief A map-to-unordered_map instrumentation line in the
object table. */
class __map2umap_info
class __map2umap_info
: public __object_info_base
{
public:
@ -113,21 +104,21 @@ namespace __gnu_profile
void
__write(FILE* __f) const
{
fprintf(__f, "%Zu %Zu %Zu %Zu %.0f %.0f %s\n",
_M_insert, _M_erase, _M_find, _M_iterate, _M_map_cost,
_M_umap_cost, _M_valid ? "valid" : "invalid");
std::fprintf(__f, "%Zu %Zu %Zu %Zu %.0f %.0f %s\n",
_M_insert, _M_erase, _M_find, _M_iterate, _M_map_cost,
_M_umap_cost, _M_valid ? "valid" : "invalid");
}
float
__magnitude() const
{ return _M_map_cost - _M_umap_cost; }
const char*
std::string
__advice() const
{ return strdup("change std::map to std::unordered_map"); }
{ return "change std::map to std::unordered_map"; }
void
__record_insert(size_t __size, size_t __count)
__record_insert(std::size_t __size, std::size_t __count)
{
_M_insert += __count;
_M_map_cost += __count * __map_insert_cost(__size);
@ -137,7 +128,7 @@ namespace __gnu_profile
}
void
__record_erase(size_t __size, size_t __count)
__record_erase(std::size_t __size, std::size_t __count)
{
_M_erase += __count;
_M_map_cost += __count * __map_erase_cost(__size);
@ -147,7 +138,7 @@ namespace __gnu_profile
}
void
__record_find(size_t __size)
__record_find(std::size_t __size)
{
_M_find += 1;
_M_map_cost += __map_find_cost(__size);
@ -155,7 +146,7 @@ namespace __gnu_profile
}
void
__record_iterate(size_t __count)
__record_iterate(std::size_t __count)
{
_M_iterate += __count;
_M_map_cost
@ -171,10 +162,10 @@ namespace __gnu_profile
{ _M_valid = false; }
private:
size_t _M_insert;
size_t _M_erase;
size_t _M_find;
size_t _M_iterate;
std::size_t _M_insert;
std::size_t _M_erase;
std::size_t _M_find;
std::size_t _M_iterate;
float _M_umap_cost;
float _M_map_cost;
bool _M_valid;
@ -237,7 +228,7 @@ namespace __gnu_profile
inline void
__trace_map_to_unordered_map_insert(const void* __obj,
size_t __size, size_t __count)
std::size_t __size, std::size_t __count)
{
if (!__profcxx_init())
return;
@ -251,7 +242,7 @@ namespace __gnu_profile
inline void
__trace_map_to_unordered_map_erase(const void* __obj,
size_t __size, size_t __count)
std::size_t __size, std::size_t __count)
{
if (!__profcxx_init())
return;
@ -264,7 +255,7 @@ namespace __gnu_profile
}
inline void
__trace_map_to_unordered_map_find(const void* __obj, size_t __size)
__trace_map_to_unordered_map_find(const void* __obj, std::size_t __size)
{
if (!__profcxx_init())
return;
@ -277,7 +268,7 @@ namespace __gnu_profile
}
inline void
__trace_map_to_unordered_map_iterate(const void* __obj, size_t __count)
__trace_map_to_unordered_map_iterate(const void* __obj, std::size_t __count)
{
if (!__profcxx_init())
return;

View File

@ -37,15 +37,8 @@
#ifndef _GLIBCXX_PROFILE_PROFILER_NODE_H
#define _GLIBCXX_PROFILE_PROFILER_NODE_H 1
#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <cstdio>
#include <cstdint>
#include <cstring>
#else
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#endif
#include <cstdio> // FILE, fprintf
#include <vector>
#if defined _GLIBCXX_HAVE_EXECINFO_H
#include <execinfo.h>
@ -58,26 +51,27 @@ namespace __gnu_profile
typedef std::_GLIBCXX_STD_PR::vector<__instruction_address_t> __stack_npt;
typedef __stack_npt* __stack_t;
size_t __stack_max_depth();
std::size_t __stack_max_depth();
inline __stack_t
__get_stack()
{
#if defined _GLIBCXX_HAVE_EXECINFO_H
size_t __max_depth = __stack_max_depth();
std::size_t __max_depth = __stack_max_depth();
if (__max_depth == 0)
return 0;
__stack_npt __buffer(__max_depth);
int __depth = backtrace(&__buffer[0], __max_depth);
__stack_t __stack = new __stack_npt(__depth);
memcpy(&(*__stack)[0], &__buffer[0], __depth * sizeof(__object_t));
__builtin_memcpy(&(*__stack)[0], &__buffer[0],
__depth * sizeof(__object_t));
return __stack;
#else
return 0;
#endif
}
inline size_t
inline std::size_t
__size(__stack_t __stack)
{
if (!__stack)
@ -95,23 +89,23 @@ namespace __gnu_profile
__stack_npt::const_iterator __it;
for (__it = __stack->begin(); __it != __stack->end(); ++__it)
fprintf(__f, "%p ", *__it);
std::fprintf(__f, "%p ", *__it);
}
/** @brief Hash function for summary trace using call stack as index. */
class __stack_hash
{
public:
size_t
std::size_t
operator()(__stack_t __s) const
{
if (!__s)
return 0;
uintptr_t __index = 0;
__UINTPTR_TYPE__ __index = 0;
__stack_npt::const_iterator __it;
for (__it = __s->begin(); __it != __s->end(); ++__it)
__index += reinterpret_cast<uintptr_t>(*__it);
__index += reinterpret_cast<__UINTPTR_TYPE__>(*__it);
return __index;
}
@ -124,8 +118,10 @@ namespace __gnu_profile
if (__stack1->size() != __stack2->size())
return false;
size_t __byte_size = __stack1->size() * sizeof(__stack_npt::value_type);
return memcmp(&(*__stack1)[0], &(*__stack2)[0], __byte_size) == 0;
std::size_t __byte_size
= __stack1->size() * sizeof(__stack_npt::value_type);
return __builtin_memcmp(&(*__stack1)[0], &(*__stack2)[0],
__byte_size) == 0;
}
};

View File

@ -37,18 +37,14 @@
#ifndef _GLIBCXX_PROFILE_PROFILER_TRACE_H
#define _GLIBCXX_PROFILE_PROFILER_TRACE_H 1
#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <cstdio> // fopen, fclose, fprintf, FILE
#include <cerrno>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstdlib> // atof, atoi, strtol, getenv, atexit, abort
#ifdef __GXX_EXPERIMENTAL_CXX0X__
#define _GLIBCXX_IMPL_UNORDERED_MAP std::_GLIBCXX_STD_PR::unordered_map
#include <unordered_map>
#else
#include <errno.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <tr1/unordered_map>
#define _GLIBCXX_IMPL_UNORDERED_MAP std::tr1::unordered_map
#endif
@ -86,18 +82,18 @@ namespace __gnu_profile
float __magnitude;
__stack_t __context;
const char* __warning_id;
const char* __warning_message;
std::string __warning_message;
__warning_data()
: __magnitude(0.0), __context(0), __warning_id(0),
__warning_message(0) { }
: __magnitude(0.0), __context(0), __warning_id(0) { }
__warning_data(float __m, __stack_t __c, const char* __id,
const char* __msg)
const std::string& __msg)
: __magnitude(__m), __context(__c), __warning_id(__id),
__warning_message(__msg) { }
bool
operator<(const struct __warning_data& __other) const
operator<(const __warning_data& __other) const
{ return __magnitude < __other.__magnitude; }
};
@ -174,18 +170,18 @@ namespace __gnu_profile
_GLIBCXX_PROFILE_DEFINE_DATA(const char*, _S_trace_file_name,
_GLIBCXX_PROFILE_TRACE_PATH_ROOT);
_GLIBCXX_PROFILE_DEFINE_DATA(size_t, _S_max_warn_count,
_GLIBCXX_PROFILE_DEFINE_DATA(std::size_t, _S_max_warn_count,
_GLIBCXX_PROFILE_MAX_WARN_COUNT);
_GLIBCXX_PROFILE_DEFINE_DATA(size_t, _S_max_stack_depth,
_GLIBCXX_PROFILE_DEFINE_DATA(std::size_t, _S_max_stack_depth,
_GLIBCXX_PROFILE_MAX_STACK_DEPTH);
_GLIBCXX_PROFILE_DEFINE_DATA(size_t, _S_max_mem,
_GLIBCXX_PROFILE_DEFINE_DATA(std::size_t, _S_max_mem,
_GLIBCXX_PROFILE_MEM_PER_DIAGNOSTIC);
inline size_t
inline std::size_t
__stack_max_depth()
{ return _GLIBCXX_PROFILE_DATA(_S_max_stack_depth); }
inline size_t
inline std::size_t
__max_mem()
{ return _GLIBCXX_PROFILE_DATA(_S_max_mem); }
@ -200,7 +196,7 @@ namespace __gnu_profile
void __add_object(__object_t object, __object_info __info);
__object_info* __get_object_info(__object_t __object);
void __retire_object(__object_t __object);
void __write(FILE* f);
void __write(FILE* __f);
void __collect_warnings(__warning_vector_t& __warnings);
private:
@ -213,7 +209,7 @@ namespace __gnu_profile
__stack_hash> __stack_table_t;
__object_table_t __object_table;
__stack_table_t __stack_table;
size_t __stack_table_byte_size;
std::size_t __stack_table_byte_size;
protected:
const char* __id;
@ -336,30 +332,32 @@ namespace __gnu_profile
{
if (__it->second.__is_valid())
{
fprintf(__f, __id);
fprintf(__f, "|");
std::fprintf(__f, __id);
std::fprintf(__f, "|");
__gnu_profile::__write(__f, __it->first);
fprintf(__f, "|");
std::fprintf(__f, "|");
__it->second.__write(__f);
}
}
}
inline size_t
__env_to_size_t(const char* __env_var, size_t __default_value)
inline std::size_t
__env_to_size_t(const char* __env_var, std::size_t __default_value)
{
char* __env_value = getenv(__env_var);
char* __env_value = std::getenv(__env_var);
if (__env_value)
{
long __converted_value = strtol(__env_value, 0, 10);
errno = 0;
long __converted_value = std::strtol(__env_value, 0, 10);
if (errno || __converted_value < 0)
{
fprintf(stderr, "Bad value for environment variable '%s'.\n",
__env_var);
abort();
std::fprintf(stderr,
"Bad value for environment variable '%s'.\n",
__env_var);
std::abort();
}
else
return static_cast<size_t>(__converted_value);
return static_cast<std::size_t>(__converted_value);
}
else
return __default_value;
@ -406,39 +404,47 @@ namespace __gnu_profile
__open_output_file(const char* __extension)
{
// The path is made of _S_trace_file_name + "." + extension.
size_t __root_len = strlen(_GLIBCXX_PROFILE_DATA(_S_trace_file_name));
size_t __ext_len = strlen(__extension);
std::size_t __root_len
= __builtin_strlen(_GLIBCXX_PROFILE_DATA(_S_trace_file_name));
std::size_t __ext_len = __builtin_strlen(__extension);
char* __file_name = new char[__root_len + 1 + __ext_len + 1];
memcpy(__file_name, _GLIBCXX_PROFILE_DATA(_S_trace_file_name),
__root_len);
__builtin_memcpy(__file_name,
_GLIBCXX_PROFILE_DATA(_S_trace_file_name),
__root_len);
*(__file_name + __root_len) = '.';
memcpy(__file_name + __root_len + 1, __extension, __ext_len + 1);
FILE* __out_file = fopen(__file_name, "w");
if (__out_file)
return __out_file;
__builtin_memcpy(__file_name + __root_len + 1,
__extension, __ext_len + 1);
FILE* __out_file = std::fopen(__file_name, "w");
if (__out_file)
{
delete[] __file_name;
return __out_file;
}
else
{
fprintf(stderr, "Could not open trace file '%s'.\n", __file_name);
abort();
std::fprintf(stderr, "Could not open trace file '%s'.\n",
__file_name);
std::abort();
}
}
struct __warn
{
FILE* __file;
__warn(FILE* __f) { __file = __f; }
__warn(FILE* __f)
{ __file = __f; }
void
operator() (const __warning_data& __info)
operator()(const __warning_data& __info)
{
fprintf(__file, __info.__warning_id);
fprintf(__file, ": improvement = %d",
__log_magnitude(__info.__magnitude));
fprintf(__file, ": call stack = ");
std::fprintf(__file, __info.__warning_id);
std::fprintf(__file, ": improvement = %d",
__log_magnitude(__info.__magnitude));
std::fprintf(__file, ": call stack = ");
__gnu_profile::__write(__file, __info.__context);
fprintf(__file, ": advice = %s\n", __info.__warning_message);
free(const_cast<void*>
(reinterpret_cast<const void*>(__info.__warning_message)));
std::fprintf(__file, ": advice = %s\n",
__info.__warning_message.c_str());
}
};
@ -464,7 +470,7 @@ namespace __gnu_profile
__trace_list_to_slist_report(__raw_file, __warnings);
__trace_list_to_vector_report(__raw_file, __warnings);
__trace_map_to_unordered_map_report(__raw_file, __warnings);
fclose(__raw_file);
std::fclose(__raw_file);
// Sort data by magnitude, keeping just top N.
size_t __cutoff = std::min(_GLIBCXX_PROFILE_DATA(_S_max_warn_count),
@ -474,7 +480,7 @@ namespace __gnu_profile
FILE* __warn_file = __open_output_file("txt");
__for_each(__top_warnings.begin(), __top_warnings.end(),
__warn(__warn_file));
fclose(__warn_file);
std::fclose(__warn_file);
_GLIBCXX_PROFILE_DATA(__global_lock).unlock();
}
@ -482,24 +488,24 @@ namespace __gnu_profile
inline void
__set_trace_path()
{
char* __env_trace_file_name = getenv(_GLIBCXX_PROFILE_TRACE_ENV_VAR);
char* __env_trace_file_name = std::getenv(_GLIBCXX_PROFILE_TRACE_ENV_VAR);
if (__env_trace_file_name)
_GLIBCXX_PROFILE_DATA(_S_trace_file_name) = __env_trace_file_name;
// Make sure early that we can create the trace file.
fclose(__open_output_file("txt"));
std::fclose(__open_output_file("txt"));
}
inline void
__set_max_warn_count()
{
char* __env_max_warn_count_str
= getenv(_GLIBCXX_PROFILE_MAX_WARN_COUNT_ENV_VAR);
= std::getenv(_GLIBCXX_PROFILE_MAX_WARN_COUNT_ENV_VAR);
if (__env_max_warn_count_str)
_GLIBCXX_PROFILE_DATA(_S_max_warn_count)
= static_cast<size_t>(atoi(__env_max_warn_count_str));
= static_cast<std::size_t>(std::atoi(__env_max_warn_count_str));
}
inline void
@ -542,7 +548,8 @@ namespace __gnu_profile
void
operator() (const __cost_factor* __factor)
{ fprintf(__file, "%s = %f\n", __factor->__env_var, __factor->__value); }
{ std::fprintf(__file, "%s = %f\n", __factor->__env_var,
__factor->__value); }
};
inline void
@ -552,7 +559,7 @@ namespace __gnu_profile
__for_each(_GLIBCXX_PROFILE_DATA(__cost_factors)->begin(),
_GLIBCXX_PROFILE_DATA(__cost_factors)->end(),
__cost_factor_writer(__file));
fclose(__file);
std::fclose(__file);
}
struct __cost_factor_setter
@ -561,7 +568,7 @@ namespace __gnu_profile
operator() (__cost_factor* __factor)
{
// Look it up in the process environment first.
const char* __env_value = getenv(__factor->__env_var);
const char* __env_value = std::getenv(__factor->__env_var);
if (!__env_value)
{
@ -573,7 +580,7 @@ namespace __gnu_profile
}
if (__env_value)
__factor->__value = atof(__env_value);
__factor->__value = std::atof(__env_value);
}
};
@ -585,33 +592,33 @@ namespace __gnu_profile
push_back(&_GLIBCXX_PROFILE_DATA(__vector_shift_cost_factor));
_GLIBCXX_PROFILE_DATA(__cost_factors)->
push_back(&_GLIBCXX_PROFILE_DATA(__vector_iterate_cost_factor));
_GLIBCXX_PROFILE_DATA(__cost_factors)->
push_back(&_GLIBCXX_PROFILE_DATA(__vector_resize_cost_factor));
_GLIBCXX_PROFILE_DATA(__cost_factors)->
push_back(&_GLIBCXX_PROFILE_DATA(__list_shift_cost_factor));
_GLIBCXX_PROFILE_DATA(__cost_factors)->
push_back(&_GLIBCXX_PROFILE_DATA(__list_iterate_cost_factor));
_GLIBCXX_PROFILE_DATA(__cost_factors)->
push_back(&_GLIBCXX_PROFILE_DATA(__list_resize_cost_factor));
_GLIBCXX_PROFILE_DATA(__cost_factors)->
push_back(&_GLIBCXX_PROFILE_DATA(__map_insert_cost_factor));
_GLIBCXX_PROFILE_DATA(__cost_factors)->
push_back(&_GLIBCXX_PROFILE_DATA(__map_erase_cost_factor));
_GLIBCXX_PROFILE_DATA(__cost_factors)->
push_back(&_GLIBCXX_PROFILE_DATA(__map_find_cost_factor));
_GLIBCXX_PROFILE_DATA(__cost_factors)->
push_back(&_GLIBCXX_PROFILE_DATA(__map_iterate_cost_factor));
_GLIBCXX_PROFILE_DATA(__cost_factors)->
push_back(&_GLIBCXX_PROFILE_DATA(__umap_insert_cost_factor));
_GLIBCXX_PROFILE_DATA(__cost_factors)->
push_back(&_GLIBCXX_PROFILE_DATA(__umap_erase_cost_factor));
_GLIBCXX_PROFILE_DATA(__cost_factors)->
push_back(&_GLIBCXX_PROFILE_DATA(__umap_find_cost_factor));
_GLIBCXX_PROFILE_DATA(__cost_factors)->
push_back(&_GLIBCXX_PROFILE_DATA(__umap_iterate_cost_factor));
__for_each(_GLIBCXX_PROFILE_DATA(__cost_factors)->begin(),
_GLIBCXX_PROFILE_DATA(__cost_factors)->end(),
__cost_factor_setter());
_GLIBCXX_PROFILE_DATA(__cost_factors)->
push_back(&_GLIBCXX_PROFILE_DATA(__vector_resize_cost_factor));
_GLIBCXX_PROFILE_DATA(__cost_factors)->
push_back(&_GLIBCXX_PROFILE_DATA(__list_shift_cost_factor));
_GLIBCXX_PROFILE_DATA(__cost_factors)->
push_back(&_GLIBCXX_PROFILE_DATA(__list_iterate_cost_factor));
_GLIBCXX_PROFILE_DATA(__cost_factors)->
push_back(&_GLIBCXX_PROFILE_DATA(__list_resize_cost_factor));
_GLIBCXX_PROFILE_DATA(__cost_factors)->
push_back(&_GLIBCXX_PROFILE_DATA(__map_insert_cost_factor));
_GLIBCXX_PROFILE_DATA(__cost_factors)->
push_back(&_GLIBCXX_PROFILE_DATA(__map_erase_cost_factor));
_GLIBCXX_PROFILE_DATA(__cost_factors)->
push_back(&_GLIBCXX_PROFILE_DATA(__map_find_cost_factor));
_GLIBCXX_PROFILE_DATA(__cost_factors)->
push_back(&_GLIBCXX_PROFILE_DATA(__map_iterate_cost_factor));
_GLIBCXX_PROFILE_DATA(__cost_factors)->
push_back(&_GLIBCXX_PROFILE_DATA(__umap_insert_cost_factor));
_GLIBCXX_PROFILE_DATA(__cost_factors)->
push_back(&_GLIBCXX_PROFILE_DATA(__umap_erase_cost_factor));
_GLIBCXX_PROFILE_DATA(__cost_factors)->
push_back(&_GLIBCXX_PROFILE_DATA(__umap_find_cost_factor));
_GLIBCXX_PROFILE_DATA(__cost_factors)->
push_back(&_GLIBCXX_PROFILE_DATA(__umap_iterate_cost_factor));
__for_each(_GLIBCXX_PROFILE_DATA(__cost_factors)->begin(),
_GLIBCXX_PROFILE_DATA(__cost_factors)->end(),
__cost_factor_setter());
}
inline void
@ -642,7 +649,7 @@ namespace __gnu_profile
__trace_list_to_vector_init();
__trace_map_to_unordered_map_init();
atexit(__report);
std::atexit(__report);
__turn_on();
}

View File

@ -37,15 +37,6 @@
#ifndef _GLIBCXX_PROFILE_PROFILER_VECTOR_SIZE_H
#define _GLIBCXX_PROFILE_PROFILER_VECTOR_SIZE_H 1
#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <cstdlib>
#include <cstdio>
#include <cstring>
#else
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#endif
#include "profile/impl/profiler.h"
#include "profile/impl/profiler_node.h"
#include "profile/impl/profiler_trace.h"
@ -79,7 +70,7 @@ namespace __gnu_profile
}
inline void
__trace_vector_size_construct(const void* __obj, size_t __num)
__trace_vector_size_construct(const void* __obj, std::size_t __num)
{
if (!__profcxx_init())
return;
@ -89,7 +80,8 @@ namespace __gnu_profile
}
inline void
__trace_vector_size_destruct(const void* __obj, size_t __num, size_t __inum)
__trace_vector_size_destruct(const void* __obj, std::size_t __num,
std::size_t __inum)
{
if (!__profcxx_init())
return;
@ -98,7 +90,8 @@ namespace __gnu_profile
}
inline void
__trace_vector_size_resize(const void* __obj, size_t __from, size_t __to)
__trace_vector_size_resize(const void* __obj, std::size_t __from,
std::size_t __to)
{
if (!__profcxx_init())
return;

View File

@ -37,15 +37,6 @@
#ifndef _GLIBCXX_PROFILE_PROFILER_VECTOR_TO_LIST_H
#define _GLIBCXX_PROFILE_PROFILER_VECTOR_TO_LIST_H 1
#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <cstdio>
#include <cstdlib>
#include <cstring>
#else
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#endif
#include "profile/impl/profiler.h"
#include "profile/impl/profiler_node.h"
#include "profile/impl/profiler_trace.h"
@ -53,7 +44,7 @@
namespace __gnu_profile
{
/** @brief A vector-to-list instrumentation line in the object table. */
class __vector2list_info
class __vector2list_info
: public __object_info_base
{
public:
@ -87,29 +78,30 @@ namespace __gnu_profile
void
__write(FILE* __f) const
{
fprintf(__f, "%Zu %Zu %Zu %.0f %.0f\n", _M_shift_count, _M_resize,
_M_iterate, _M_vector_cost, _M_list_cost);
std::fprintf(__f, "%Zu %Zu %Zu %.0f %.0f\n", _M_shift_count,
_M_resize, _M_iterate, _M_vector_cost, _M_list_cost);
}
float
__magnitude() const
{ return _M_vector_cost - _M_list_cost; }
const char* __advice() const
{ return strdup("change std::vector to std::list"); }
std::string
__advice() const
{ return "change std::vector to std::list"; }
size_t
std::size_t
__shift_count()
{ return _M_shift_count; }
size_t
std::size_t
__iterate()
{ return _M_iterate; }
float __list_cost()
{ return _M_list_cost; }
size_t
std::size_t
__resize()
{ return _M_resize; }
@ -130,27 +122,28 @@ namespace __gnu_profile
{ _M_valid = false; }
void
__opr_insert(size_t __pos, size_t __num)
__opr_insert(std::size_t __pos, std::size_t __num)
{ _M_shift_count += __num - __pos; }
void
__opr_iterate(size_t __num)
__opr_iterate(std::size_t __num)
{ _M_iterate += __num; }
void
__resize(size_t __from, size_t)
__resize(std::size_t __from, std::size_t)
{ _M_resize += __from; }
void __opr_find(size_t __size)
void
__opr_find(std::size_t __size)
{
// Use average case complexity.
_M_iterate += 3.0 / 4.0 * __size;
}
private:
size_t _M_shift_count;
size_t _M_iterate;
size_t _M_resize;
std::size_t _M_shift_count;
std::size_t _M_iterate;
std::size_t _M_resize;
float _M_list_cost;
float _M_vector_cost;
bool _M_valid;
@ -210,7 +203,7 @@ namespace __gnu_profile
// Collect cost of operations.
void
__opr_insert(const void* __obj, size_t __pos, size_t __num)
__opr_insert(const void* __obj, std::size_t __pos, std::size_t __num)
{
__vector2list_info* __res = __get_object_info(__obj);
if (__res)
@ -218,7 +211,7 @@ namespace __gnu_profile
}
void
__opr_iterate(const void* __obj, size_t __num)
__opr_iterate(const void* __obj, std::size_t __num)
{
__vector2list_info* __res = __get_object_info(__obj);
if (__res)
@ -234,7 +227,7 @@ namespace __gnu_profile
}
void
__resize(const void* __obj, size_t __from, size_t __to)
__resize(const void* __obj, std::size_t __from, std::size_t __to)
{
__vector2list_info* __res = __get_object_info(__obj);
if (__res)
@ -242,7 +235,8 @@ namespace __gnu_profile
}
float
__vector_cost(size_t __shift, size_t __iterate, size_t __resize)
__vector_cost(std::size_t __shift, std::size_t __iterate,
std::size_t __resize)
{
return (__shift
* _GLIBCXX_PROFILE_DATA(__vector_shift_cost_factor).__value
@ -253,7 +247,8 @@ namespace __gnu_profile
}
float
__list_cost(size_t __shift, size_t __iterate, size_t __resize)
__list_cost(std::size_t __shift, std::size_t __iterate,
std::size_t __resize)
{
return (__shift
* _GLIBCXX_PROFILE_DATA(__list_shift_cost_factor).__value
@ -264,7 +259,7 @@ namespace __gnu_profile
}
void
__opr_find(const void* __obj, size_t __size)
__opr_find(const void* __obj, std::size_t __size)
{
__vector2list_info* __res = __get_object_info(__obj);
if (__res)
@ -307,7 +302,8 @@ namespace __gnu_profile
}
inline void
__trace_vector_to_list_insert(const void* __obj, size_t __pos, size_t __num)
__trace_vector_to_list_insert(const void* __obj, std::size_t __pos,
std::size_t __num)
{
if (!__profcxx_init())
return;
@ -317,7 +313,7 @@ namespace __gnu_profile
}
inline void
__trace_vector_to_list_iterate(const void* __obj, size_t __num = 1)
__trace_vector_to_list_iterate(const void* __obj, std::size_t __num = 1)
{
if (!__profcxx_init())
return;
@ -335,7 +331,8 @@ namespace __gnu_profile
}
inline void
__trace_vector_to_list_resize(const void* __obj, size_t __from, size_t __to)
__trace_vector_to_list_resize(const void* __obj, std::size_t __from,
std::size_t __to)
{
if (!__profcxx_init())
return;
@ -344,7 +341,7 @@ namespace __gnu_profile
}
inline void
__trace_vector_to_list_find(const void* __obj, size_t __size)
__trace_vector_to_list_find(const void* __obj, std::size_t __size)
{
if (!__profcxx_init())
return;

View File

@ -36,266 +36,239 @@ namespace std
namespace __profile
{
template<typename _Iterator, typename _Sequence>
class __iterator_tracker
{
typedef __iterator_tracker _Self;
// The underlying iterator
_Iterator _M_current;
// The underlying data structure
const _Sequence* _M_ds;
typedef std::iterator_traits<_Iterator> _Traits;
template<typename _Iterator, typename _Sequence>
class __iterator_tracker
{
typedef __iterator_tracker _Self;
public:
typedef _Iterator _Base_iterator;
typedef typename _Traits::iterator_category iterator_category;
typedef typename _Traits::value_type value_type;
typedef typename _Traits::difference_type difference_type;
typedef typename _Traits::reference reference;
typedef typename _Traits::pointer pointer;
// The underlying iterator
_Iterator _M_current;
__iterator_tracker() : _M_current(), _M_ds(0) { }
__iterator_tracker(const _Iterator& __i, const _Sequence* seq)
: _M_current(__i), _M_ds(seq) { }
__iterator_tracker(const __iterator_tracker& __x)
// The underlying data structure
const _Sequence* _M_ds;
typedef std::iterator_traits<_Iterator> _Traits;
public:
typedef _Iterator _Base_iterator;
typedef typename _Traits::iterator_category iterator_category;
typedef typename _Traits::value_type value_type;
typedef typename _Traits::difference_type difference_type;
typedef typename _Traits::reference reference;
typedef typename _Traits::pointer pointer;
__iterator_tracker()
: _M_current(), _M_ds(0) { }
__iterator_tracker(const _Iterator& __i, const _Sequence* __seq)
: _M_current(__i), _M_ds(__seq) { }
__iterator_tracker(const __iterator_tracker& __x)
: _M_current(__x._M_current), _M_ds(__x._M_ds) { }
template<typename _MutableIterator>
__iterator_tracker(const __iterator_tracker<_MutableIterator, typename __gnu_cxx::__enable_if<(std::__are_same<_MutableIterator, typename _Sequence::iterator::_Base_iterator>::__value), _Sequence>::__type>& __x)
: _M_current(__x.base()), _M_ds(__x._M_get_sequence()) { }
_Iterator
base() const { return _M_current; }
/**
* @brief Conversion to underlying non-debug iterator to allow
* better interaction with non-profile containers.
*/
operator _Iterator() const { return _M_current; }
template<typename _MutableIterator>
__iterator_tracker(const __iterator_tracker<_MutableIterator,
typename __gnu_cxx::__enable_if
<(std::__are_same<_MutableIterator, typename
_Sequence::iterator::_Base_iterator>::__value),
_Sequence>::__type>& __x)
: _M_current(__x.base()), _M_ds(__x._M_get_sequence()) { }
pointer
operator->() const { return &*_M_current; }
_Iterator
base() const { return _M_current; }
/**
* @brief Conversion to underlying non-debug iterator to allow
* better interaction with non-profile containers.
*/
operator _Iterator() const { return _M_current; }
__iterator_tracker&
operator++()
{
_M_ds->_M_profile_iterate();
++_M_current;
return *this;
}
pointer
operator->() const { return &*_M_current; }
__iterator_tracker&
operator++(int)
{
_M_ds->_M_profile_iterate();
__iterator_tracker __tmp(*this);
++_M_current;
return __tmp;
}
__iterator_tracker&
operator++()
{
_M_ds->_M_profile_iterate();
++_M_current;
return *this;
}
__iterator_tracker&
operator--()
{
_M_ds->_M_profile_iterate(1);
--_M_current;
return *this;
}
__iterator_tracker&
operator++(int)
{
_M_ds->_M_profile_iterate();
__iterator_tracker __tmp(*this);
++_M_current;
return __tmp;
}
__iterator_tracker&
operator--(int)
{
_M_ds->_M_profile_iterate(1);
__iterator_tracker __tmp(*this);
--_M_current;
return __tmp;
}
__iterator_tracker&
operator--()
{
_M_ds->_M_profile_iterate(1);
--_M_current;
return *this;
}
__iterator_tracker&
operator=(const __iterator_tracker& __x)
{
_M_current = __x._M_current;
return *this;
}
__iterator_tracker&
operator--(int)
{
_M_ds->_M_profile_iterate(1);
__iterator_tracker __tmp(*this);
--_M_current;
return __tmp;
}
reference
operator*() const
{
return *_M_current;
}
__iterator_tracker&
operator=(const __iterator_tracker& __x)
{
_M_current = __x._M_current;
return *this;
}
// ------ Random access iterator requirements ------
reference
operator[](const difference_type& __n) const
{
return _M_current[__n];
}
reference
operator*() const
{ return *_M_current; }
__iterator_tracker&
operator+=(const difference_type& __n)
{
_M_current += __n;
return *this;
}
// ------ Random access iterator requirements ------
reference
operator[](const difference_type& __n) const
{ return _M_current[__n]; }
__iterator_tracker
operator+(const difference_type& __n) const
{
__iterator_tracker __tmp(*this);
__tmp += __n;
return __tmp;
}
__iterator_tracker&
operator+=(const difference_type& __n)
{
_M_current += __n;
return *this;
}
__iterator_tracker&
operator-=(const difference_type& __n)
{
_M_current += -__n;
return *this;
}
__iterator_tracker
operator+(const difference_type& __n) const
{
__iterator_tracker __tmp(*this);
__tmp += __n;
return __tmp;
}
__iterator_tracker
operator-(const difference_type& __n) const
{
__iterator_tracker __tmp(*this);
__tmp -= __n;
return __tmp;
}
__iterator_tracker&
operator-=(const difference_type& __n)
{
_M_current += -__n;
return *this;
}
void
_M_find()
{
_M_ds->_M_profile_find();
}
__iterator_tracker
operator-(const difference_type& __n) const
{
__iterator_tracker __tmp(*this);
__tmp -= __n;
return __tmp;
}
const _Sequence*
_M_get_sequence() const
{
return static_cast<const _Sequence*>(_M_ds);
}
};
void
_M_find()
{ _M_ds->_M_profile_find(); }
template<typename _IteratorL, typename _IteratorR, typename _Sequence>
inline bool
operator==(const __iterator_tracker<_IteratorL, _Sequence>& __lhs,
const __iterator_tracker<_IteratorR, _Sequence>& __rhs)
{
return __lhs.base() == __rhs.base();
}
const _Sequence*
_M_get_sequence() const
{ return static_cast<const _Sequence*>(_M_ds); }
};
template<typename _Iterator, typename _Sequence>
inline bool
operator==(const __iterator_tracker<_Iterator, _Sequence>& __lhs,
const __iterator_tracker<_Iterator, _Sequence>& __rhs)
{
return __lhs.base() == __rhs.base();
}
template<typename _IteratorL, typename _IteratorR, typename _Sequence>
inline bool
operator!=(const __iterator_tracker<_IteratorL, _Sequence>& __lhs,
const __iterator_tracker<_IteratorR, _Sequence>& __rhs)
{
return __lhs.base() != __rhs.base();
}
template<typename _Iterator, typename _Sequence>
inline bool
operator!=(const __iterator_tracker<_Iterator, _Sequence>& __lhs,
const __iterator_tracker<_Iterator, _Sequence>& __rhs)
{
return __lhs.base() != __rhs.base();
}
template<typename _IteratorL, typename _IteratorR, typename _Sequence>
inline bool
operator<(const __iterator_tracker<_IteratorL, _Sequence>& __lhs,
const __iterator_tracker<_IteratorR, _Sequence>& __rhs)
{
return __lhs.base() < __rhs.base();
}
template<typename _Iterator, typename _Sequence>
inline bool
operator<(const __iterator_tracker<_Iterator, _Sequence>& __lhs,
const __iterator_tracker<_Iterator, _Sequence>& __rhs)
{
return __lhs.base() < __rhs.base();
}
template<typename _IteratorL, typename _IteratorR, typename _Sequence>
inline bool
operator<=(const __iterator_tracker<_IteratorL, _Sequence>& __lhs,
const __iterator_tracker<_IteratorR, _Sequence>& __rhs)
{
return __lhs.base() <= __rhs.base();
}
template<typename _Iterator, typename _Sequence>
inline bool
operator<=(const __iterator_tracker<_Iterator, _Sequence>& __lhs,
const __iterator_tracker<_Iterator, _Sequence>& __rhs)
{
return __lhs.base() <= __rhs.base();
}
template<typename _IteratorL, typename _IteratorR, typename _Sequence>
inline bool
operator>(const __iterator_tracker<_IteratorL, _Sequence>& __lhs,
const __iterator_tracker<_IteratorR, _Sequence>& __rhs)
{
return __lhs.base() > __rhs.base();
}
template<typename _Iterator, typename _Sequence>
inline bool
operator>(const __iterator_tracker<_Iterator, _Sequence>& __lhs,
const __iterator_tracker<_Iterator, _Sequence>& __rhs)
{
return __lhs.base() > __rhs.base();
}
template<typename _IteratorL, typename _IteratorR, typename _Sequence>
inline bool
operator>=(const __iterator_tracker<_IteratorL, _Sequence>& __lhs,
const __iterator_tracker<_IteratorR, _Sequence>& __rhs)
{
return __lhs.base() >= __rhs.base();
}
template<typename _Iterator, typename _Sequence>
inline bool
operator>=(const __iterator_tracker<_Iterator, _Sequence>& __lhs,
const __iterator_tracker<_Iterator, _Sequence>& __rhs)
{
return __lhs.base() >= __rhs.base();
}
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// According to the resolution of DR179 not only the various comparison
// operators but also operator- must accept mixed iterator/const_iterator
// parameters.
template<typename _IteratorL, typename _IteratorR, typename _Sequence>
inline typename __iterator_tracker<_IteratorL, _Sequence>::difference_type
operator-(const __iterator_tracker<_IteratorL, _Sequence>& __lhs,
const __iterator_tracker<_IteratorR, _Sequence>& __rhs)
{
return __lhs.base() - __rhs.base();
}
inline bool
operator==(const __iterator_tracker<_IteratorL, _Sequence>& __lhs,
const __iterator_tracker<_IteratorR, _Sequence>& __rhs)
{ return __lhs.base() == __rhs.base(); }
template<typename _Iterator, typename _Sequence>
inline typename __iterator_tracker<_Iterator, _Sequence>::difference_type
operator-(const __iterator_tracker<_Iterator, _Sequence>& __lhs,
const __iterator_tracker<_Iterator, _Sequence>& __rhs)
{
return __lhs.base() - __rhs.base();
}
template<typename _Iterator, typename _Sequence>
inline bool
operator==(const __iterator_tracker<_Iterator, _Sequence>& __lhs,
const __iterator_tracker<_Iterator, _Sequence>& __rhs)
{ return __lhs.base() == __rhs.base(); }
template<typename _Iterator, typename _Sequence>
inline __iterator_tracker<_Iterator, _Sequence>
operator+(typename __iterator_tracker<_Iterator,_Sequence>::difference_type
__n,
const __iterator_tracker<_Iterator, _Sequence>& __i)
{
return __i + __n;
}
template<typename _IteratorL, typename _IteratorR, typename _Sequence>
inline bool
operator!=(const __iterator_tracker<_IteratorL, _Sequence>& __lhs,
const __iterator_tracker<_IteratorR, _Sequence>& __rhs)
{ return __lhs.base() != __rhs.base(); }
template<typename _Iterator, typename _Sequence>
inline bool
operator!=(const __iterator_tracker<_Iterator, _Sequence>& __lhs,
const __iterator_tracker<_Iterator, _Sequence>& __rhs)
{ return __lhs.base() != __rhs.base(); }
template<typename _IteratorL, typename _IteratorR, typename _Sequence>
inline bool
operator<(const __iterator_tracker<_IteratorL, _Sequence>& __lhs,
const __iterator_tracker<_IteratorR, _Sequence>& __rhs)
{ return __lhs.base() < __rhs.base(); }
template<typename _Iterator, typename _Sequence>
inline bool
operator<(const __iterator_tracker<_Iterator, _Sequence>& __lhs,
const __iterator_tracker<_Iterator, _Sequence>& __rhs)
{ return __lhs.base() < __rhs.base(); }
template<typename _IteratorL, typename _IteratorR, typename _Sequence>
inline bool
operator<=(const __iterator_tracker<_IteratorL, _Sequence>& __lhs,
const __iterator_tracker<_IteratorR, _Sequence>& __rhs)
{ return __lhs.base() <= __rhs.base(); }
template<typename _Iterator, typename _Sequence>
inline bool
operator<=(const __iterator_tracker<_Iterator, _Sequence>& __lhs,
const __iterator_tracker<_Iterator, _Sequence>& __rhs)
{ return __lhs.base() <= __rhs.base(); }
template<typename _IteratorL, typename _IteratorR, typename _Sequence>
inline bool
operator>(const __iterator_tracker<_IteratorL, _Sequence>& __lhs,
const __iterator_tracker<_IteratorR, _Sequence>& __rhs)
{ return __lhs.base() > __rhs.base(); }
template<typename _Iterator, typename _Sequence>
inline bool
operator>(const __iterator_tracker<_Iterator, _Sequence>& __lhs,
const __iterator_tracker<_Iterator, _Sequence>& __rhs)
{ return __lhs.base() > __rhs.base(); }
template<typename _IteratorL, typename _IteratorR, typename _Sequence>
inline bool
operator>=(const __iterator_tracker<_IteratorL, _Sequence>& __lhs,
const __iterator_tracker<_IteratorR, _Sequence>& __rhs)
{ return __lhs.base() >= __rhs.base(); }
template<typename _Iterator, typename _Sequence>
inline bool
operator>=(const __iterator_tracker<_Iterator, _Sequence>& __lhs,
const __iterator_tracker<_Iterator, _Sequence>& __rhs)
{ return __lhs.base() >= __rhs.base(); }
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// According to the resolution of DR179 not only the various comparison
// operators but also operator- must accept mixed iterator/const_iterator
// parameters.
template<typename _IteratorL, typename _IteratorR, typename _Sequence>
inline typename __iterator_tracker<_IteratorL, _Sequence>::difference_type
operator-(const __iterator_tracker<_IteratorL, _Sequence>& __lhs,
const __iterator_tracker<_IteratorR, _Sequence>& __rhs)
{ return __lhs.base() - __rhs.base(); }
template<typename _Iterator, typename _Sequence>
inline typename __iterator_tracker<_Iterator, _Sequence>::difference_type
operator-(const __iterator_tracker<_Iterator, _Sequence>& __lhs,
const __iterator_tracker<_Iterator, _Sequence>& __rhs)
{ return __lhs.base() - __rhs.base(); }
template<typename _Iterator, typename _Sequence>
inline __iterator_tracker<_Iterator, _Sequence>
operator+(typename __iterator_tracker<_Iterator,_Sequence>::difference_type
__n,
const __iterator_tracker<_Iterator, _Sequence>& __i)
{ return __i + __n; }
} // namespace __profile
} // namespace std
#endif

View File

@ -71,29 +71,26 @@ namespace __profile
using _Base::value_compare;
// 23.3.1.1 construct/copy/destroy:
explicit map(const _Compare& __comp = _Compare(),
const _Allocator& __a = _Allocator())
: _Base(__comp, __a) {
__profcxx_map_to_unordered_map_construct(this);
}
explicit
map(const _Compare& __comp = _Compare(),
const _Allocator& __a = _Allocator())
: _Base(__comp, __a)
{ __profcxx_map_to_unordered_map_construct(this); }
template<typename _InputIterator>
map(_InputIterator __first, _InputIterator __last,
const _Compare& __comp = _Compare(),
const _Allocator& __a = _Allocator())
: _Base(__first, __last, __comp, __a) {
__profcxx_map_to_unordered_map_construct(this);
}
: _Base(__first, __last, __comp, __a)
{ __profcxx_map_to_unordered_map_construct(this); }
map(const map& __x)
: _Base(__x) {
__profcxx_map_to_unordered_map_construct(this);
}
: _Base(__x)
{ __profcxx_map_to_unordered_map_construct(this); }
map(const _Base& __x)
: _Base(__x) {
__profcxx_map_to_unordered_map_construct(this);
}
: _Base(__x)
{ __profcxx_map_to_unordered_map_construct(this); }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
map(map&& __x)
@ -106,9 +103,8 @@ namespace __profile
: _Base(__l, __c, __a) { }
#endif
~map() {
__profcxx_map_to_unordered_map_destruct(this);
}
~map()
{ __profcxx_map_to_unordered_map_destruct(this); }
map&
operator=(const map& __x)