Major maintenance patch of the profile mode.

2014-11-10  François Dumont  <fdumont@gcc.gnu.org>

	Major maintenance patch of the profile mode.
	* include/profile/impl/profiler_container_size.h
	(__container_size_info()): Delete.
	(__container_size_info(const __container_size_info&)): Delete.
	(virtual ~__container_size_info()): Delete.
	(__container_size_info(__stack_t, size_t)): Delete.
	(__container_size_info(__stack_t)): New.
	(__container_size_info::__init(size_t)): New.
	(__container_size_info::__merge): Call __object_info_base::__merge.
	(__trace_container_size::__construct): Delete declaration.
	(__trace_container_size::__insert): Return __container_size_info*,
	call __init.
	* include/profile/impl/profiler_hash_func.h
	(__hashfunc_into()): Delete.
	(__hashfunc_info(const __hashfunc_info&)): Delete.
	(virtual ~__hashfunc_info()): Delete.
	(__hashfunc_info::__merge): Call __object_info_base::__merge.
	(__trace_hash_func::__insert): Delete.
	(__trace_hash_func_free): New.
	(__trace_hash_func_report): Call __trace_report.
	(__trace_hash_func_construct): Return __hashfunc_info*. Add check for
	reentrancy.
	* include/profile/impl/profiler_hashtable_size.h
	(__trace_hashtable_size_free): New.
	(__trace_hashtable_size_report): Call __trace_report.
	(__trace_hashtable_size_construct): Return __container_size_info*. Add
	check for reentrancy.
	* include/profile/impl/profiler_list_to_slist.h
	(__list2slist_info()): Delete.
	(__list2slist_info(const __list2slist_info&)): Delete.
	(virtual ~__list2slist_info()): Delete.
	(__trace_list_to_slist::__merge(const __list2slist_info&)): Delete.
	(__trace_list_to_slist::__opr_rewind(const void*)): Delete.
	(__trace_list_to_slist::__record_operation(const void*)): Delete.
	(__trace_list_to_slist::__insert(const __object_t, __stack_t)): Delete.
	(__trace_list_to_slist::__destruct): Only call __retire_object.
	(__trace_list_to_slist_free()): New.
	(__trace_list_to_slist_report): Call __trace_report.
	(__trace_list_to_slist_construct): Return __list2slist_info*. Add check
	for reentrancy.
	* include/profile/impl/profiler_list_to_vector.h
	(__list2vector_info()): Delete.
	(__list2vector_info(const __list2vector_info&)): Delete.
	(virtual ~__list2vector_info()): Delete.
	(_list2vector_info::__is_valid): Delete.
	(_list2vector_info::__set_invalid): Delete.
	(_list2vector_info::__opr_iterate): Use atomic operation.
	(_list2vector_info::_M_valid): Delete.
	(__trace_list_to_vector::__insert): Delete.
	(__trace_list_to_vector::__find): Delete.
	(__trace_list_to_vector::__opr_insert): Delete.
	(__trace_list_to_vector::__opr_iterate): Delete.
	(__trace_list_to_vector::__invalid_operator): Delete.
	(__trace_list_to_vector::__resize): Delete.
	(__trace_list_to_vector_free): New.
	(__trace_list_to_vector_report): Call __trace_report.
	(__trace_list_to_vector_construct): Return __list2vector_info*. Add
	check for reentrancy.
	* include/profile/impl/profiler_map_to_unordered_map.h
	(__map2umap_info()): Delete.
	(__map2umap_info(const __map2umap_info&)): Delete.
	(virtual ~__map2umap_info()): Delete.
	(__map2umap_info::__record_iterate): Use atomic operation.
	(__map2umap_info::__set_iterate_costs): New.
	(__map2umap_info::__record_invalidate): Delete.
	(__map2umap_info::_M_valid): Delete.
	(__trace_map2umap::__destruct): New.
	(__trace_map_to_unordered_map_free): New.
	(__trace_map_to_unordered_map_report): Call __trace_report.
	(__trace_map_to_unordered_map_construct): Return __map2umap_info*. Add
	check for reentrancy.
	* include/profile/impl/profiler_node.h (__object_t): Delete typedef.
	(__get_stack): Return null stack trace in case of (bad_alloc) exception.
	(__object_info_base()): Delete.
	(__object_info_base(const __object_info_base&)): Delete.
	(virtual ~__object_info_base()): Delete.
	(__object_info_base::__set_invalid): New.
	(__object_info_base::__merge): New.
	(virtual void __write(FILE*)): Delete.
	(class __stack_info_base): Delete.
	* include/profile/impl/profiler_trace.h (__global_lock): Rename into
	__global_mutex.
	(__trace_vector_size_free): New declaration.
	(__trace_hashtable_size_free): Likewise.
	(__trace_hash_func_free): Likewise.
	(__trace_vector_to_list_free): Likewise.
	(__trace_list_to_slist_free): Likewise.
	(__trace_list_to_vector_free): Likewise.
	(__trace_map_to_unordered_map_free): Likewise.
	(__trace_base::~__trace_base()): Not virtual anymore. Delete stored
	backtrace information.
	(__trace_base::__add_object): Return __object_info*, take only a stack
	trace.
	(__trace_base::__get_object_info): Delete.
	(__trace_base::__retire_object): Take __object_info* instead of
	__object_t.
	(__trace_base::__object_table_lock): Delete.
	(__trace_base::__stack_table_lock): Delete.
	(__trace_base::__object_table_t): Delete typedef.
	(__trace_base::__object_table): Delete.
	(__trace_base::__trace_mutex): New.
	(__trace_base::__object_byte_size): New.
	(__trace_report): New.
	(__report): Use __gnu_cxx::__scoped_lock to lock/unlock __global_mutex
	rather than explicitely calling lock() method, exception safe.
	(__report_and_free): New. Call __report and free all profile mode
	resources.
	(__profcxx_init_unconditional): Use __scoped_lock. Register
	__report_and_free with atexit.
	* include/profile/impl/profiler_vector_size.h
	(__trace_vector_size_free): New.
	(__trace_vector_size_report): Call __trace_report.
	(__trace_vector_size_construct): Return __container_size_info*. Add
	check for reentrancy.
	* include/profile/impl/profiler_vector_to_list.h
	(__vector2list_info()): Delete.
	(virtual ~__vector2list_info()): Delete.
	(__vector2list_info(const __vector2list_info&)): Delete.
	(__vector2list_info::__merge): Call __object_info_base::__merge.
	(__vector2list_info::__is_valid): Delete.
	(__vector2list_info::__set_valid): Delete.
	(__vector2list_info::__opr_find): Delete.
	(__vector2list_info::_M_valid): Delete.
	(__trace_vector_to_list::__insert): Delete.
	(__trace_vector_to_list::__find): Delete.
	(__trace_vector_to_list::__opr_insert): Delete.
	(__trace_vector_to_list::__opr_iterate): Delete.
	(__trace_vector_to_list::__invalid_operator): Delete.
	(__trace_vector_to_list::__resize): Delete.
	(__trace_vector_to_list::__opr_find): Delete.
	(__trace_vector_to_list_free): New.
	(__trace_vector_to_list_report): Call __trace_report.
	(__trace_vector_to_list_construct): Return __vector2list_info*. Add
	check for reentrancy.
	* include/profile/iterator_tracker.h
	(__iterator_tracker<>::operator=): Add missing _M_ds assignment.
	(__iterator_tracker<>::_M_find): Delete.
	* include/profile/impl/profiler.h
	([_GLIBCXX_PROFILE_REENTRANCE_GUARD]): Delete.
	(__container_size_info): Add class declaration.
	(__hashfunc_info): Likewise.
	(__map2umap_info): Likewise.
	(__vector2list_info): Likewise.
	(__list2slist_info): Likewise.
	(__list2vector_info): Likewise.
	(__trace_list_to_set_destruct): Delete declaration.
	(__trace_list_to_set_construct): Likewise.
	(__trace_list_to_set_insert): Likewise.
	(__trace_list_to_set_iterate): Likewise.
	(__trace_list_to_set_invalid_operator): Likewise.
	(__trace_list_to_set_find): Likewise.
	([__profcxx_report]): Remove usage of _GLIBCXX_PROFILE_REENTRANCE_GUARD.
	([__profcxx_turn_on]): Likewise.
	([__profcxx_turn_off]): Likewise.
	([__profcxx_is_invalid]): Likewise.
	([__profcxx_is_on]): Likewise.
	([__profcxx_is_off]): Likewise.
	([__profcxx_hashtable_resize]): Likewise.
	([__profcxx_hashtable_destruct]): Likewise.
	([__profcxx_hashtable_construct]): Likewise.
	([__profcxx_vector_size_construct]): Likewise.
	([__profcxx_vector_size_resize]): Likewise.
	([__profcxx_vector_size_destruct]): Likewise.
	([__profcxx_inefficient_hash_is_on]): Delete.
	([__profcxx_hash_func_construct]): Remove usage of
	_GLIBCXX_PROFILE_REENTRANCE_GUARD.
	([__profcxx_hash_func_destruct]): Likewise.
	([__profcxx_vector_construct2]): Rename into...
	([__profcxx_vector2list_construct]): ... this. Remove usage of
	_GLIBCXX_PROFILE_REENTRANCE_GUARD.
	([__profcxx_vector_insert]): Rename into...
	([__profcxx_vector2list_insert]): ... this. Remove usage of
	_GLIBCXX_PROFILE_REENTRANCE_GUARD.
	([__profcxx_vector_iterate]): Rename into...
	([__profcxx_vector2list_iterate]): ... this. Remove usage of
	_GLIBCXX_PROFILE_REENTRANCE_GUARD.
	([__profcxx_vector_invalid_operator]): Rename into...
	([__profcxx_vector2list_invalid_operator]): ... this. Remove usage of
	_GLIBCXX_PROFILE_REENTRANCE_GUARD.
	([__profcxx_vector_resize2]): Rename into...
	([__profcxx_vector2list_resize]): ... this. Remove usage of
	_GLIBCXX_PROFILE_REENTRANCE_GUARD.
	([__profcxx_vector_destruct2]): Rename into...
	([__profcxx_vector2list_destruct]): ... this. Remove usage of
	_GLIBCXX_PROFILE_REENTRANCE_GUARD.
	([__profcxx_vector_find]): Delete.
	([__profcxx_list_construct2]): Rename into...
	([__profcxx_list2vector_construct]): ... this. Remove usage of
	_GLIBCXX_PROFILE_REENTRANCE_GUARD.
	([__profcxx_list_insert]): Rename into...
	([__profcxx_list2vector_insert]): ... this. Remove usage of
	_GLIBCXX_PROFILE_REENTRANCE_GUARD.
	([__profcxx_list_iterate]): Rename into...
	([__profcxx_list2vector_iterate]): ... this. Remove usage of
	_GLIBCXX_PROFILE_REENTRANCE_GUARD.
	([_profcxx_list_invalid_operator]): Rename into...
	([__profcxx_list2vector_invalid_operator]): ... this. Remove usage of
	_GLIBCXX_PROFILE_REENTRANCE_GUARD.
	([__profcxx_list_destruct2]): Rename into...
	([__profcxx_list2vector_destruct]): ... this. Remove usage of
	_GLIBCXX_PROFILE_REENTRANCE_GUARD.
	([__profcxx_list_construct]): Rename into...
	([__profcxx_list2slist_construct]): ... this. Remove usage of
	_GLIBCXX_PROFILE_REENTRANCE_GUARD.
	([__profcxx_list_rewind]): Rename into...
	([__profcxx_list2slist_rewind]): ... this. Remove usage of
	_GLIBCXX_PROFILE_REENTRANCE_GUARD.
	([__profcxx_list_operation]): Rename into...
	([__profcxx_list2slist_operation]): ... this. Remove usage of
	_GLIBCXX_PROFILE_REENTRANCE_GUARD.
	([__profcxx_list_destruct]): Rename into...
	([__profcxx_list2slist_destruct]): ... this. Remove usage of
	_GLIBCXX_PROFILE_REENTRANCE_GUARD.
	([__profcxx_map_to_unordered_map_construct]): Rename into...
	([__profcxx_map2umap_construct]): ... this. Remove usage of
	_GLIBCXX_PROFILE_REENTRANCE_GUARD.
	([__profcxx_map_to_unordered_map_insert]): Rename into...
	([__profcxx_map2umap_insert]): ... this. Remove usage of
	_GLIBCXX_PROFILE_REENTRANCE_GUARD.
	([__profcxx_map_to_unordered_map_erase]): Rename into...
	([__profcxx_map2umap_erase]): ... this. Remove usage of
	_GLIBCXX_PROFILE_REENTRANCE_GUARD.
	([__profcxx_map_to_unordered_map_iterate]): Rename into...
	([__profcxx_map2umap_iterate]): ... this. Remove usage of
	_GLIBCXX_PROFILE_REENTRANCE_GUARD.
	([__profcxx_map_to_unordered_map_invalidate]): Rename into...
	([__profcxx_map2umap_invalidate]): ... this. Remove usage of
	_GLIBCXX_PROFILE_REENTRANCE_GUARD.
	([__profcxx_map_to_unordered_map_find]): Rename into...
	([__profcxx_map2umap_find]): ... this. Remove usage of
	_GLIBCXX_PROFILE_REENTRANCE_GUARD.
	([__profcxx_map_to_unordered_map_destruct]): Rename into...
	([__profcxx_map2umap_destruct]): ... this. Remove usage of
	_GLIBCXX_PROFILE_REENTRANCE_GUARD.
	* include/profile/list
	(_List_profile): Adapt.
	(_List_profile::_M_profile_construct): New.
	(_List_profile()): Call latter.
	(_List_profile::_M_profile_destruct): New.
	(~_List_profile()): Call latter.
	(_List_profile::_M_swap): New.
	(_List_profile(_List_profile&&)): Call latter.
	(_List_profile::operator=(const _List_profile&)): Reinit profile
	structures.
	(_List_profile::operator=(_List_profile&&)): Move profile struct and
	re-init profile structures on moved instance.
	(std::__profile::list<>): Adapt.
	* include/profile/ordered_base.h
	(_Ordered_profile::_M_profile_iterate): New.
	(_Ordered_profile::_M_profile_construct): New.
	(_Ordered_profile()): Call latter.
	(_Ordered_profile::_M_swap): New.
	(_Ordered_profile(_Ordered_profile&&)): Call latter.
	(_Ordered_profile::operator=(const _Ordered_profile&)): Reinit
	profiling.
	(_Ordered_profile::operator=(_Ordered_profile&&)): Swap and reinit
	profiling on the moved instance.
	(_Ordered_profile::_M_profile_destruct): New.
	(~_Ordered_profile()): Call latter.
	* include/profile/map.h (std::__profile::map<>): Add profiling on
	iterators. Adapt.
	* include/profile/multimap.h (std::__profile::multimap<>): Likewise.
	* include/profile/set.h (std::__profile::set<>): Likewise.
	* include/profile/multiset.h (std::__profile::multiset<>): Likewise.
	* include/profile/unordered_base.h
	(_Unordered_profile::_M_profile_construct): New.
	(_Unordered_profile()): Call latter.
	(_Unordered_profile::_M_swap): New.
	(_Unordered_profile(_Unordered_profile&&)): Call latter.
	(_Unordered_profile::operator=(const _Unordered_profile&)): Reinit
	profiling.
	(_Unordered_profile::operator=(_Unordered_profile&&)): Swap and reinit
	profiling on the moved instance.
	(_Unordered_profile::_M_profile_destruct): New.
	(~_Ordered_profile()): Call latter.
	* include/profile/unordered_map
	(std::__profile::unordered_map<>): Adapt.
	(std::__profile::unordered_multimap<>): Adapt.
	* include/profile/unordered_set
	(std::__profile::unordered_set<>): Adapt.
	(std::__profile::unordered_multiset<>): Adapt.
	* include/profile/vector
	(_Vector_profile_pre::_M_profile_destruct): Move...
	(_Vector_profile_post::_M_profile_destruct): ...here.
	(_Vector_profile_post::_M_profile_construct): New.
	(_Vector_profile_post()): Call latter.
	(std::__profile::vector<>): Adapt.
	* testsuite/ext/profile/mh.cc: Rename into...
	* testsuite/ext/profile/replace_new.cc: ... this and fix test.

From-SVN: r217321
This commit is contained in:
François Dumont 2014-11-10 21:51:58 +00:00
parent 6750565c36
commit b12db70880
24 changed files with 1954 additions and 1577 deletions

View File

@ -1,3 +1,295 @@
2014-11-10 François Dumont <fdumont@gcc.gnu.org>
Major maintenance patch of the profile mode.
* include/profile/impl/profiler_container_size.h
(__container_size_info()): Delete.
(__container_size_info(const __container_size_info&)): Delete.
(virtual ~__container_size_info()): Delete.
(__container_size_info(__stack_t, size_t)): Delete.
(__container_size_info(__stack_t)): New.
(__container_size_info::__init(size_t)): New.
(__container_size_info::__merge): Call __object_info_base::__merge.
(__trace_container_size::__construct): Delete declaration.
(__trace_container_size::__insert): Return __container_size_info*,
call __init.
* include/profile/impl/profiler_hash_func.h
(__hashfunc_into()): Delete.
(__hashfunc_info(const __hashfunc_info&)): Delete.
(virtual ~__hashfunc_info()): Delete.
(__hashfunc_info::__merge): Call __object_info_base::__merge.
(__trace_hash_func::__insert): Delete.
(__trace_hash_func_free): New.
(__trace_hash_func_report): Call __trace_report.
(__trace_hash_func_construct): Return __hashfunc_info*. Add check for
reentrancy.
* include/profile/impl/profiler_hashtable_size.h
(__trace_hashtable_size_free): New.
(__trace_hashtable_size_report): Call __trace_report.
(__trace_hashtable_size_construct): Return __container_size_info*. Add
check for reentrancy.
* include/profile/impl/profiler_list_to_slist.h
(__list2slist_info()): Delete.
(__list2slist_info(const __list2slist_info&)): Delete.
(virtual ~__list2slist_info()): Delete.
(__trace_list_to_slist::__merge(const __list2slist_info&)): Delete.
(__trace_list_to_slist::__opr_rewind(const void*)): Delete.
(__trace_list_to_slist::__record_operation(const void*)): Delete.
(__trace_list_to_slist::__insert(const __object_t, __stack_t)): Delete.
(__trace_list_to_slist::__destruct): Only call __retire_object.
(__trace_list_to_slist_free()): New.
(__trace_list_to_slist_report): Call __trace_report.
(__trace_list_to_slist_construct): Return __list2slist_info*. Add check
for reentrancy.
* include/profile/impl/profiler_list_to_vector.h
(__list2vector_info()): Delete.
(__list2vector_info(const __list2vector_info&)): Delete.
(virtual ~__list2vector_info()): Delete.
(_list2vector_info::__is_valid): Delete.
(_list2vector_info::__set_invalid): Delete.
(_list2vector_info::__opr_iterate): Use atomic operation.
(_list2vector_info::_M_valid): Delete.
(__trace_list_to_vector::__insert): Delete.
(__trace_list_to_vector::__find): Delete.
(__trace_list_to_vector::__opr_insert): Delete.
(__trace_list_to_vector::__opr_iterate): Delete.
(__trace_list_to_vector::__invalid_operator): Delete.
(__trace_list_to_vector::__resize): Delete.
(__trace_list_to_vector_free): New.
(__trace_list_to_vector_report): Call __trace_report.
(__trace_list_to_vector_construct): Return __list2vector_info*. Add
check for reentrancy.
* include/profile/impl/profiler_map_to_unordered_map.h
(__map2umap_info()): Delete.
(__map2umap_info(const __map2umap_info&)): Delete.
(virtual ~__map2umap_info()): Delete.
(__map2umap_info::__record_iterate): Use atomic operation.
(__map2umap_info::__set_iterate_costs): New.
(__map2umap_info::__record_invalidate): Delete.
(__map2umap_info::_M_valid): Delete.
(__trace_map2umap::__destruct): New.
(__trace_map_to_unordered_map_free): New.
(__trace_map_to_unordered_map_report): Call __trace_report.
(__trace_map_to_unordered_map_construct): Return __map2umap_info*. Add
check for reentrancy.
* include/profile/impl/profiler_node.h (__object_t): Delete typedef.
(__get_stack): Return null stack trace in case of (bad_alloc) exception.
(__object_info_base()): Delete.
(__object_info_base(const __object_info_base&)): Delete.
(virtual ~__object_info_base()): Delete.
(__object_info_base::__set_invalid): New.
(__object_info_base::__merge): New.
(virtual void __write(FILE*)): Delete.
(class __stack_info_base): Delete.
* include/profile/impl/profiler_trace.h (__global_lock): Rename into
__global_mutex.
(__trace_vector_size_free): New declaration.
(__trace_hashtable_size_free): Likewise.
(__trace_hash_func_free): Likewise.
(__trace_vector_to_list_free): Likewise.
(__trace_list_to_slist_free): Likewise.
(__trace_list_to_vector_free): Likewise.
(__trace_map_to_unordered_map_free): Likewise.
(__trace_base::~__trace_base()): Not virtual anymore. Delete stored
backtrace information.
(__trace_base::__add_object): Return __object_info*, take only a stack
trace.
(__trace_base::__get_object_info): Delete.
(__trace_base::__retire_object): Take __object_info* instead of
__object_t.
(__trace_base::__object_table_lock): Delete.
(__trace_base::__stack_table_lock): Delete.
(__trace_base::__object_table_t): Delete typedef.
(__trace_base::__object_table): Delete.
(__trace_base::__trace_mutex): New.
(__trace_base::__object_byte_size): New.
(__trace_report): New.
(__report): Use __gnu_cxx::__scoped_lock to lock/unlock __global_mutex
rather than explicitely calling lock() method, exception safe.
(__report_and_free): New. Call __report and free all profile mode
resources.
(__profcxx_init_unconditional): Use __scoped_lock. Register
__report_and_free with atexit.
* include/profile/impl/profiler_vector_size.h
(__trace_vector_size_free): New.
(__trace_vector_size_report): Call __trace_report.
(__trace_vector_size_construct): Return __container_size_info*. Add
check for reentrancy.
* include/profile/impl/profiler_vector_to_list.h
(__vector2list_info()): Delete.
(virtual ~__vector2list_info()): Delete.
(__vector2list_info(const __vector2list_info&)): Delete.
(__vector2list_info::__merge): Call __object_info_base::__merge.
(__vector2list_info::__is_valid): Delete.
(__vector2list_info::__set_valid): Delete.
(__vector2list_info::__opr_find): Delete.
(__vector2list_info::_M_valid): Delete.
(__trace_vector_to_list::__insert): Delete.
(__trace_vector_to_list::__find): Delete.
(__trace_vector_to_list::__opr_insert): Delete.
(__trace_vector_to_list::__opr_iterate): Delete.
(__trace_vector_to_list::__invalid_operator): Delete.
(__trace_vector_to_list::__resize): Delete.
(__trace_vector_to_list::__opr_find): Delete.
(__trace_vector_to_list_free): New.
(__trace_vector_to_list_report): Call __trace_report.
(__trace_vector_to_list_construct): Return __vector2list_info*. Add
check for reentrancy.
* include/profile/iterator_tracker.h
(__iterator_tracker<>::operator=): Add missing _M_ds assignment.
(__iterator_tracker<>::_M_find): Delete.
* include/profile/impl/profiler.h
([_GLIBCXX_PROFILE_REENTRANCE_GUARD]): Delete.
(__container_size_info): Add class declaration.
(__hashfunc_info): Likewise.
(__map2umap_info): Likewise.
(__vector2list_info): Likewise.
(__list2slist_info): Likewise.
(__list2vector_info): Likewise.
(__trace_list_to_set_destruct): Delete declaration.
(__trace_list_to_set_construct): Likewise.
(__trace_list_to_set_insert): Likewise.
(__trace_list_to_set_iterate): Likewise.
(__trace_list_to_set_invalid_operator): Likewise.
(__trace_list_to_set_find): Likewise.
([__profcxx_report]): Remove usage of _GLIBCXX_PROFILE_REENTRANCE_GUARD.
([__profcxx_turn_on]): Likewise.
([__profcxx_turn_off]): Likewise.
([__profcxx_is_invalid]): Likewise.
([__profcxx_is_on]): Likewise.
([__profcxx_is_off]): Likewise.
([__profcxx_hashtable_resize]): Likewise.
([__profcxx_hashtable_destruct]): Likewise.
([__profcxx_hashtable_construct]): Likewise.
([__profcxx_vector_size_construct]): Likewise.
([__profcxx_vector_size_resize]): Likewise.
([__profcxx_vector_size_destruct]): Likewise.
([__profcxx_inefficient_hash_is_on]): Delete.
([__profcxx_hash_func_construct]): Remove usage of
_GLIBCXX_PROFILE_REENTRANCE_GUARD.
([__profcxx_hash_func_destruct]): Likewise.
([__profcxx_vector_construct2]): Rename into...
([__profcxx_vector2list_construct]): ... this. Remove usage of
_GLIBCXX_PROFILE_REENTRANCE_GUARD.
([__profcxx_vector_insert]): Rename into...
([__profcxx_vector2list_insert]): ... this. Remove usage of
_GLIBCXX_PROFILE_REENTRANCE_GUARD.
([__profcxx_vector_iterate]): Rename into...
([__profcxx_vector2list_iterate]): ... this. Remove usage of
_GLIBCXX_PROFILE_REENTRANCE_GUARD.
([__profcxx_vector_invalid_operator]): Rename into...
([__profcxx_vector2list_invalid_operator]): ... this. Remove usage of
_GLIBCXX_PROFILE_REENTRANCE_GUARD.
([__profcxx_vector_resize2]): Rename into...
([__profcxx_vector2list_resize]): ... this. Remove usage of
_GLIBCXX_PROFILE_REENTRANCE_GUARD.
([__profcxx_vector_destruct2]): Rename into...
([__profcxx_vector2list_destruct]): ... this. Remove usage of
_GLIBCXX_PROFILE_REENTRANCE_GUARD.
([__profcxx_vector_find]): Delete.
([__profcxx_list_construct2]): Rename into...
([__profcxx_list2vector_construct]): ... this. Remove usage of
_GLIBCXX_PROFILE_REENTRANCE_GUARD.
([__profcxx_list_insert]): Rename into...
([__profcxx_list2vector_insert]): ... this. Remove usage of
_GLIBCXX_PROFILE_REENTRANCE_GUARD.
([__profcxx_list_iterate]): Rename into...
([__profcxx_list2vector_iterate]): ... this. Remove usage of
_GLIBCXX_PROFILE_REENTRANCE_GUARD.
([_profcxx_list_invalid_operator]): Rename into...
([__profcxx_list2vector_invalid_operator]): ... this. Remove usage of
_GLIBCXX_PROFILE_REENTRANCE_GUARD.
([__profcxx_list_destruct2]): Rename into...
([__profcxx_list2vector_destruct]): ... this. Remove usage of
_GLIBCXX_PROFILE_REENTRANCE_GUARD.
([__profcxx_list_construct]): Rename into...
([__profcxx_list2slist_construct]): ... this. Remove usage of
_GLIBCXX_PROFILE_REENTRANCE_GUARD.
([__profcxx_list_rewind]): Rename into...
([__profcxx_list2slist_rewind]): ... this. Remove usage of
_GLIBCXX_PROFILE_REENTRANCE_GUARD.
([__profcxx_list_operation]): Rename into...
([__profcxx_list2slist_operation]): ... this. Remove usage of
_GLIBCXX_PROFILE_REENTRANCE_GUARD.
([__profcxx_list_destruct]): Rename into...
([__profcxx_list2slist_destruct]): ... this. Remove usage of
_GLIBCXX_PROFILE_REENTRANCE_GUARD.
([__profcxx_map_to_unordered_map_construct]): Rename into...
([__profcxx_map2umap_construct]): ... this. Remove usage of
_GLIBCXX_PROFILE_REENTRANCE_GUARD.
([__profcxx_map_to_unordered_map_insert]): Rename into...
([__profcxx_map2umap_insert]): ... this. Remove usage of
_GLIBCXX_PROFILE_REENTRANCE_GUARD.
([__profcxx_map_to_unordered_map_erase]): Rename into...
([__profcxx_map2umap_erase]): ... this. Remove usage of
_GLIBCXX_PROFILE_REENTRANCE_GUARD.
([__profcxx_map_to_unordered_map_iterate]): Rename into...
([__profcxx_map2umap_iterate]): ... this. Remove usage of
_GLIBCXX_PROFILE_REENTRANCE_GUARD.
([__profcxx_map_to_unordered_map_invalidate]): Rename into...
([__profcxx_map2umap_invalidate]): ... this. Remove usage of
_GLIBCXX_PROFILE_REENTRANCE_GUARD.
([__profcxx_map_to_unordered_map_find]): Rename into...
([__profcxx_map2umap_find]): ... this. Remove usage of
_GLIBCXX_PROFILE_REENTRANCE_GUARD.
([__profcxx_map_to_unordered_map_destruct]): Rename into...
([__profcxx_map2umap_destruct]): ... this. Remove usage of
_GLIBCXX_PROFILE_REENTRANCE_GUARD.
* include/profile/list
(_List_profile): Adapt.
(_List_profile::_M_profile_construct): New.
(_List_profile()): Call latter.
(_List_profile::_M_profile_destruct): New.
(~_List_profile()): Call latter.
(_List_profile::_M_swap): New.
(_List_profile(_List_profile&&)): Call latter.
(_List_profile::operator=(const _List_profile&)): Reinit profile
structures.
(_List_profile::operator=(_List_profile&&)): Move profile struct and
re-init profile structures on moved instance.
(std::__profile::list<>): Adapt.
* include/profile/ordered_base.h
(_Ordered_profile::_M_profile_iterate): New.
(_Ordered_profile::_M_profile_construct): New.
(_Ordered_profile()): Call latter.
(_Ordered_profile::_M_swap): New.
(_Ordered_profile(_Ordered_profile&&)): Call latter.
(_Ordered_profile::operator=(const _Ordered_profile&)): Reinit
profiling.
(_Ordered_profile::operator=(_Ordered_profile&&)): Swap and reinit
profiling on the moved instance.
(_Ordered_profile::_M_profile_destruct): New.
(~_Ordered_profile()): Call latter.
* include/profile/map.h (std::__profile::map<>): Add profiling on
iterators. Adapt.
* include/profile/multimap.h (std::__profile::multimap<>): Likewise.
* include/profile/set.h (std::__profile::set<>): Likewise.
* include/profile/multiset.h (std::__profile::multiset<>): Likewise.
* include/profile/unordered_base.h
(_Unordered_profile::_M_profile_construct): New.
(_Unordered_profile()): Call latter.
(_Unordered_profile::_M_swap): New.
(_Unordered_profile(_Unordered_profile&&)): Call latter.
(_Unordered_profile::operator=(const _Unordered_profile&)): Reinit
profiling.
(_Unordered_profile::operator=(_Unordered_profile&&)): Swap and reinit
profiling on the moved instance.
(_Unordered_profile::_M_profile_destruct): New.
(~_Ordered_profile()): Call latter.
* include/profile/unordered_map
(std::__profile::unordered_map<>): Adapt.
(std::__profile::unordered_multimap<>): Adapt.
* include/profile/unordered_set
(std::__profile::unordered_set<>): Adapt.
(std::__profile::unordered_multiset<>): Adapt.
* include/profile/vector
(_Vector_profile_pre::_M_profile_destruct): Move...
(_Vector_profile_post::_M_profile_destruct): ...here.
(_Vector_profile_post::_M_profile_construct): New.
(_Vector_profile_post()): Call latter.
(std::__profile::vector<>): Adapt.
* testsuite/ext/profile/mh.cc: Rename into...
* testsuite/ext/profile/replace_new.cc: ... this and fix test.
2014-11-05 François Dumont <fdumont@gcc.gnu.org>
Jonathan Wakely <jwakely@redhat.com>

View File

@ -80,69 +80,78 @@ namespace __gnu_profile
~__reentrance_guard() { __inside() = false; }
};
#define _GLIBCXX_PROFILE_REENTRANCE_GUARD(__x...) \
{ \
if (__gnu_profile::__reentrance_guard::__get_in()) \
{ \
__gnu_profile::__reentrance_guard __get_out; \
__x; \
} \
}
// Forward declarations of implementation functions.
// Don't use any __gnu_profile:: in user code.
// Instead, use the __profcxx... macros, which offer guarded access.
class __container_size_info;
class __hashfunc_info;
class __map2umap_info;
class __vector2list_info;
class __list2slist_info;
class __list2vector_info;
bool __turn_on();
bool __turn_off();
bool __is_invalid();
bool __is_on();
bool __is_off();
void __report(void);
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*, 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*, std::size_t, std::size_t);
void __trace_vector_to_list_find(const void*, std::size_t);
void __report();
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_operation(const void*);
__container_size_info*
__trace_hashtable_size_construct(std::size_t);
void __trace_hashtable_size_resize(__container_size_info*,
std::size_t, std::size_t);
void __trace_hashtable_size_destruct(__container_size_info*,
std::size_t, std::size_t);
void __trace_list_to_vector_destruct(const void*);
void __trace_list_to_vector_construct(const void*);
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*, std::size_t, std::size_t);
__hashfunc_info*
__trace_hash_func_construct();
void __trace_hash_func_destruct(__hashfunc_info*,
std::size_t, 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*, 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*, std::size_t);
__container_size_info*
__trace_vector_size_construct(std::size_t);
void __trace_vector_size_resize(__container_size_info*,
std::size_t, std::size_t);
void __trace_vector_size_destruct(__container_size_info*,
std::size_t, 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*, std::size_t,
__vector2list_info*
__trace_vector_to_list_construct();
void __trace_vector_to_list_insert(__vector2list_info*,
std::size_t, std::size_t);
void __trace_vector_to_list_iterate(__vector2list_info*, int);
void __trace_vector_to_list_invalid_operator(__vector2list_info*);
void __trace_vector_to_list_resize(__vector2list_info*,
std::size_t, std::size_t);
void __trace_vector_to_list_destruct(__vector2list_info*);
__list2slist_info*
__trace_list_to_slist_construct();
void __trace_list_to_slist_rewind(__list2slist_info*);
void __trace_list_to_slist_operation(__list2slist_info*);
void __trace_list_to_slist_destruct(__list2slist_info*);
__list2vector_info*
__trace_list_to_vector_construct();
void __trace_list_to_vector_insert(__list2vector_info*,
std::size_t, std::size_t);
void __trace_list_to_vector_iterate(__list2vector_info*, int);
void __trace_list_to_vector_invalid_operator(__list2vector_info*);
void __trace_list_to_vector_resize(__list2vector_info*,
std::size_t, std::size_t);
void __trace_list_to_vector_destruct(__list2vector_info*);
__map2umap_info*
__trace_map_to_unordered_map_construct();
void __trace_map_to_unordered_map_invalidate(__map2umap_info*);
void __trace_map_to_unordered_map_insert(__map2umap_info*, std::size_t,
std::size_t);
void __trace_map_to_unordered_map_erase(const void*, std::size_t,
void __trace_map_to_unordered_map_erase(__map2umap_info*, 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*);
void __trace_map_to_unordered_map_iterate(__map2umap_info*, std::size_t);
void __trace_map_to_unordered_map_find(__map2umap_info*, std::size_t);
void __trace_map_to_unordered_map_destruct(__map2umap_info*);
} // namespace __gnu_profile
// Master switch turns on all diagnostics that are not explicitly turned off.
@ -178,18 +187,12 @@ namespace __gnu_profile
// Expose global management routines to user code.
#ifdef _GLIBCXX_PROFILE
#define __profcxx_report() \
_GLIBCXX_PROFILE_REENTRANCE_GUARD(__gnu_profile::__report())
#define __profcxx_turn_on() \
_GLIBCXX_PROFILE_REENTRANCE_GUARD(__gnu_profile::__turn_on())
#define __profcxx_turn_off() \
_GLIBCXX_PROFILE_REENTRANCE_GUARD(__gnu_profile::__turn_off())
#define __profcxx_is_invalid() \
_GLIBCXX_PROFILE_REENTRANCE_GUARD(__gnu_profile::__is_invalid())
#define __profcxx_is_on() \
_GLIBCXX_PROFILE_REENTRANCE_GUARD(__gnu_profile::__is_on())
#define __profcxx_is_off() \
_GLIBCXX_PROFILE_REENTRANCE_GUARD(__gnu_profile::__is_off())
#define __profcxx_report() __gnu_profile::__report()
#define __profcxx_turn_on() __gnu_profile::__turn_on()
#define __profcxx_turn_off() __gnu_profile::__turn_off()
#define __profcxx_is_invalid() __gnu_profile::__is_invalid()
#define __profcxx_is_on() __gnu_profile::__is_on()
#define __profcxx_is_off() __gnu_profile::__is_off()
#else
#define __profcxx_report()
#define __profcxx_turn_on()
@ -202,166 +205,128 @@ namespace __gnu_profile
// Turn on/off instrumentation for HASHTABLE_TOO_SMALL and HASHTABLE_TOO_LARGE.
#if (defined(_GLIBCXX_PROFILE_HASHTABLE_TOO_SMALL) \
|| defined(_GLIBCXX_PROFILE_HASHTABLE_TOO_LARGE))
#define __profcxx_hashtable_resize(__x...) \
_GLIBCXX_PROFILE_REENTRANCE_GUARD( \
__gnu_profile::__trace_hashtable_size_resize(__x))
#define __profcxx_hashtable_destruct(__x...) \
_GLIBCXX_PROFILE_REENTRANCE_GUARD( \
__gnu_profile::__trace_hashtable_size_destruct(__x))
#define __profcxx_hashtable_construct(__x...) \
_GLIBCXX_PROFILE_REENTRANCE_GUARD( \
__gnu_profile::__trace_hashtable_size_construct(__x))
#define __profcxx_hashtable_size_construct(__x...) \
__gnu_profile::__trace_hashtable_size_construct(__x)
#define __profcxx_hashtable_size_resize(__x...) \
__gnu_profile::__trace_hashtable_size_resize(__x)
#define __profcxx_hashtable_size_destruct(__x...) \
__gnu_profile::__trace_hashtable_size_destruct(__x)
#else
#define __profcxx_hashtable_resize(__x...)
#define __profcxx_hashtable_destruct(__x...)
#define __profcxx_hashtable_construct(__x...)
#define __profcxx_hashtable_size_construct(__x...) 0
#define __profcxx_hashtable_size_resize(__x...)
#define __profcxx_hashtable_size_destruct(__x...)
#endif
// Turn on/off instrumentation for VECTOR_TOO_SMALL and VECTOR_TOO_LARGE.
#if (defined(_GLIBCXX_PROFILE_VECTOR_TOO_SMALL) \
|| defined(_GLIBCXX_PROFILE_VECTOR_TOO_LARGE))
#define __profcxx_vector_resize(__x...) \
_GLIBCXX_PROFILE_REENTRANCE_GUARD( \
__gnu_profile::__trace_vector_size_resize(__x))
#define __profcxx_vector_destruct(__x...) \
_GLIBCXX_PROFILE_REENTRANCE_GUARD( \
__gnu_profile::__trace_vector_size_destruct(__x))
#define __profcxx_vector_construct(__x...) \
_GLIBCXX_PROFILE_REENTRANCE_GUARD( \
__gnu_profile::__trace_vector_size_construct(__x))
#define __profcxx_vector_size_construct(__x...) \
__gnu_profile::__trace_vector_size_construct(__x)
#define __profcxx_vector_size_resize(__x...) \
__gnu_profile::__trace_vector_size_resize(__x)
#define __profcxx_vector_size_destruct(__x...) \
__gnu_profile::__trace_vector_size_destruct(__x)
#else
#define __profcxx_vector_resize(__x...)
#define __profcxx_vector_destruct(__x...)
#define __profcxx_vector_construct(__x...)
#define __profcxx_vector_size_construct(__x...) 0
#define __profcxx_vector_size_resize(__x...)
#define __profcxx_vector_size_destruct(__x...)
#endif
// Turn on/off instrumentation for INEFFICIENT_HASH.
#if defined(_GLIBCXX_PROFILE_INEFFICIENT_HASH)
#define __profcxx_inefficient_hash_is_on() \
__gnu_profile::__is_on()
#define __profcxx_hashtable_construct2(__x...) \
_GLIBCXX_PROFILE_REENTRANCE_GUARD( \
__gnu_profile::__trace_hash_func_construct(__x))
#define __profcxx_hashtable_destruct2(__x...) \
_GLIBCXX_PROFILE_REENTRANCE_GUARD( \
__gnu_profile::__trace_hash_func_destruct(__x))
#define __profcxx_hash_func_construct(__x...) \
__gnu_profile::__trace_hash_func_construct(__x)
#define __profcxx_hash_func_destruct(__x...) \
__gnu_profile::__trace_hash_func_destruct(__x)
#else
#define __profcxx_inefficient_hash_is_on() false
#define __profcxx_hashtable_destruct2(__x...)
#define __profcxx_hashtable_construct2(__x...)
#define __profcxx_hash_func_construct(__x...) 0
#define __profcxx_hash_func_destruct(__x...)
#endif
// Turn on/off instrumentation for VECTOR_TO_LIST.
#if defined(_GLIBCXX_PROFILE_VECTOR_TO_LIST)
#define __profcxx_vector_construct2(__x...) \
_GLIBCXX_PROFILE_REENTRANCE_GUARD( \
__gnu_profile::__trace_vector_to_list_construct(__x))
#define __profcxx_vector_destruct2(__x...) \
_GLIBCXX_PROFILE_REENTRANCE_GUARD( \
__gnu_profile::__trace_vector_to_list_destruct(__x))
#define __profcxx_vector_insert(__x...) \
_GLIBCXX_PROFILE_REENTRANCE_GUARD( \
__gnu_profile::__trace_vector_to_list_insert(__x))
#define __profcxx_vector_iterate(__x...) \
_GLIBCXX_PROFILE_REENTRANCE_GUARD( \
__gnu_profile::__trace_vector_to_list_iterate(__x))
#define __profcxx_vector_invalid_operator(__x...) \
_GLIBCXX_PROFILE_REENTRANCE_GUARD( \
__gnu_profile::__trace_vector_to_list_invalid_operator(__x))
#define __profcxx_vector_resize2(__x...) \
_GLIBCXX_PROFILE_REENTRANCE_GUARD( \
__gnu_profile::__trace_vector_to_list_resize(__x))
#define __profcxx_vector_find(__x...) \
_GLIBCXX_PROFILE_REENTRANCE_GUARD( \
__gnu_profile::__trace_vector_to_list_find(__x))
#define __profcxx_vector2list_construct(__x...) \
__gnu_profile::__trace_vector_to_list_construct(__x)
#define __profcxx_vector2list_insert(__x...) \
__gnu_profile::__trace_vector_to_list_insert(__x)
#define __profcxx_vector2list_iterate(__x...) \
__gnu_profile::__trace_vector_to_list_iterate(__x)
#define __profcxx_vector2list_invalid_operator(__x...) \
__gnu_profile::__trace_vector_to_list_invalid_operator(__x)
#define __profcxx_vector2list_resize(__x...) \
__gnu_profile::__trace_vector_to_list_resize(__x)
#define __profcxx_vector2list_destruct(__x...) \
__gnu_profile::__trace_vector_to_list_destruct(__x)
#else
#define __profcxx_vector_destruct2(__x...)
#define __profcxx_vector_construct2(__x...)
#define __profcxx_vector_insert(__x...)
#define __profcxx_vector_iterate(__x...)
#define __profcxx_vector_invalid_operator(__x...)
#define __profcxx_vector_resize2(__x...)
#define __profcxx_vector_find(__x...)
#define __profcxx_vector2list_construct(__x...) 0
#define __profcxx_vector2list_insert(__x...)
#define __profcxx_vector2list_iterate(__x...)
#define __profcxx_vector2list_invalid_operator(__x...)
#define __profcxx_vector2list_resize(__x...)
#define __profcxx_vector2list_destruct(__x...)
#endif
// Turn on/off instrumentation for LIST_TO_VECTOR.
#if defined(_GLIBCXX_PROFILE_LIST_TO_VECTOR)
#define __profcxx_list_construct2(__x...) \
_GLIBCXX_PROFILE_REENTRANCE_GUARD( \
__gnu_profile::__trace_list_to_vector_construct(__x))
#define __profcxx_list_destruct2(__x...) \
_GLIBCXX_PROFILE_REENTRANCE_GUARD( \
__gnu_profile::__trace_list_to_vector_destruct(__x))
#define __profcxx_list_insert(__x...) \
_GLIBCXX_PROFILE_REENTRANCE_GUARD( \
__gnu_profile::__trace_list_to_vector_insert(__x))
#define __profcxx_list_iterate(__x...) \
_GLIBCXX_PROFILE_REENTRANCE_GUARD( \
__gnu_profile::__trace_list_to_vector_iterate(__x))
#define __profcxx_list_invalid_operator(__x...) \
_GLIBCXX_PROFILE_REENTRANCE_GUARD( \
__gnu_profile::__trace_list_to_vector_invalid_operator(__x))
#define __profcxx_list2vector_construct(__x...) \
__gnu_profile::__trace_list_to_vector_construct(__x)
#define __profcxx_list2vector_insert(__x...) \
__gnu_profile::__trace_list_to_vector_insert(__x)
#define __profcxx_list2vector_iterate(__x...) \
__gnu_profile::__trace_list_to_vector_iterate(__x)
#define __profcxx_list2vector_invalid_operator(__x...) \
__gnu_profile::__trace_list_to_vector_invalid_operator(__x)
#define __profcxx_list2vector_destruct(__x...) \
__gnu_profile::__trace_list_to_vector_destruct(__x)
#else
#define __profcxx_list_destruct2(__x...)
#define __profcxx_list_construct2(__x...)
#define __profcxx_list_insert(__x...)
#define __profcxx_list_iterate(__x...)
#define __profcxx_list_invalid_operator(__x...)
#define __profcxx_list2vector_construct(__x...) 0
#define __profcxx_list2vector_insert(__x...)
#define __profcxx_list2vector_iterate(__x...)
#define __profcxx_list2vector_invalid_operator(__x...)
#define __profcxx_list2vector_destruct(__x...)
#endif
// Turn on/off instrumentation for LIST_TO_SLIST.
#if defined(_GLIBCXX_PROFILE_LIST_TO_SLIST)
#define __profcxx_list_rewind(__x...) \
_GLIBCXX_PROFILE_REENTRANCE_GUARD( \
__gnu_profile::__trace_list_to_slist_rewind(__x))
#define __profcxx_list_operation(__x...) \
_GLIBCXX_PROFILE_REENTRANCE_GUARD( \
__gnu_profile::__trace_list_to_slist_operation(__x))
#define __profcxx_list_destruct(__x...) \
_GLIBCXX_PROFILE_REENTRANCE_GUARD( \
__gnu_profile::__trace_list_to_slist_destruct(__x))
#define __profcxx_list_construct(__x...) \
_GLIBCXX_PROFILE_REENTRANCE_GUARD( \
__gnu_profile::__trace_list_to_slist_construct(__x))
#define __profcxx_list2slist_construct(__x...) \
__gnu_profile::__trace_list_to_slist_construct(__x)
#define __profcxx_list2slist_rewind(__x...) \
__gnu_profile::__trace_list_to_slist_rewind(__x)
#define __profcxx_list2slist_operation(__x...) \
__gnu_profile::__trace_list_to_slist_operation(__x)
#define __profcxx_list2slist_destruct(__x...) \
__gnu_profile::__trace_list_to_slist_destruct(__x)
#else
#define __profcxx_list_rewind(__x...)
#define __profcxx_list_operation(__x...)
#define __profcxx_list_destruct(__x...)
#define __profcxx_list_construct(__x...)
#define __profcxx_list2slist_construct(__x...) 0
#define __profcxx_list2slist_rewind(__x...)
#define __profcxx_list2slist_operation(__x...)
#define __profcxx_list2slist_destruct(__x...)
#endif
// Turn on/off instrumentation for MAP_TO_UNORDERED_MAP.
#if defined(_GLIBCXX_PROFILE_MAP_TO_UNORDERED_MAP)
#define __profcxx_map_to_unordered_map_construct(__x...) \
_GLIBCXX_PROFILE_REENTRANCE_GUARD( \
__gnu_profile::__trace_map_to_unordered_map_construct(__x))
#define __profcxx_map_to_unordered_map_destruct(__x...) \
_GLIBCXX_PROFILE_REENTRANCE_GUARD( \
__gnu_profile::__trace_map_to_unordered_map_destruct(__x))
#define __profcxx_map_to_unordered_map_insert(__x...) \
_GLIBCXX_PROFILE_REENTRANCE_GUARD( \
__gnu_profile::__trace_map_to_unordered_map_insert(__x))
#define __profcxx_map_to_unordered_map_erase(__x...) \
_GLIBCXX_PROFILE_REENTRANCE_GUARD( \
__gnu_profile::__trace_map_to_unordered_map_erase(__x))
#define __profcxx_map_to_unordered_map_iterate(__x...) \
_GLIBCXX_PROFILE_REENTRANCE_GUARD( \
__gnu_profile::__trace_map_to_unordered_map_iterate(__x))
#define __profcxx_map_to_unordered_map_invalidate(__x...) \
_GLIBCXX_PROFILE_REENTRANCE_GUARD( \
__gnu_profile::__trace_map_to_unordered_map_invalidate(__x))
#define __profcxx_map_to_unordered_map_find(__x...) \
_GLIBCXX_PROFILE_REENTRANCE_GUARD( \
__gnu_profile::__trace_map_to_unordered_map_find(__x))
#define __profcxx_map2umap_construct(__x...) \
__gnu_profile::__trace_map_to_unordered_map_construct(__x)
#define __profcxx_map2umap_insert(__x...) \
__gnu_profile::__trace_map_to_unordered_map_insert(__x)
#define __profcxx_map2umap_erase(__x...) \
__gnu_profile::__trace_map_to_unordered_map_erase(__x)
#define __profcxx_map2umap_iterate(__x...) \
__gnu_profile::__trace_map_to_unordered_map_iterate(__x)
#define __profcxx_map2umap_invalidate(__x...) \
__gnu_profile::__trace_map_to_unordered_map_invalidate(__x)
#define __profcxx_map2umap_find(__x...) \
__gnu_profile::__trace_map_to_unordered_map_find(__x)
#define __profcxx_map2umap_destruct(__x...) \
__gnu_profile::__trace_map_to_unordered_map_destruct(__x)
#else
#define __profcxx_map_to_unordered_map_construct(__x...) \
#define __profcxx_map_to_unordered_map_destruct(__x...)
#define __profcxx_map_to_unordered_map_insert(__x...)
#define __profcxx_map_to_unordered_map_erase(__x...)
#define __profcxx_map_to_unordered_map_iterate(__x...)
#define __profcxx_map_to_unordered_map_invalidate(__x...)
#define __profcxx_map_to_unordered_map_find(__x...)
#define __profcxx_map2umap_construct(__x...) 0
#define __profcxx_map2umap_insert(__x...)
#define __profcxx_map2umap_erase(__x...)
#define __profcxx_map2umap_iterate(__x...)
#define __profcxx_map2umap_invalidate(__x...)
#define __profcxx_map2umap_find(__x...)
#define __profcxx_map2umap_destruct(__x...)
#endif
// Set default values for compile-time customizable variables.

View File

@ -43,27 +43,12 @@ namespace __gnu_profile
: public __object_info_base
{
public:
__container_size_info()
: _M_init(0), _M_max(0), _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)
{ }
__container_size_info(const __container_size_info& __o)
: __object_info_base(__o), _M_init(__o._M_init), _M_max(__o._M_max),
_M_min(__o._M_min), _M_total(__o._M_total),
_M_item_min(__o._M_item_min), _M_item_max(__o._M_item_max),
_M_item_total(__o._M_item_total), _M_count(__o._M_count),
_M_resize(__o._M_resize), _M_cost(__o._M_cost)
{ }
__container_size_info(__stack_t __stack, std::size_t __num)
: __object_info_base(__stack), _M_init(__num), _M_max(__num),
__container_size_info(__stack_t __stack)
: __object_info_base(__stack), _M_init(0), _M_max(0),
_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)
{ }
virtual ~__container_size_info() { }
void
__write(FILE* __f) const
{
@ -86,9 +71,17 @@ namespace __gnu_profile
return __message.str();
}
void
__init(std::size_t __num)
{
_M_init = __num;
_M_max = __num;
}
void
__merge(const __container_size_info& __o)
{
__object_info_base::__merge(__o);
_M_init = std::max(_M_init, __o._M_init);
_M_max = std::max(_M_max, __o._M_max);
_M_item_max = std::max(_M_item_max, __o._M_item_max);
@ -117,6 +110,7 @@ namespace __gnu_profile
_M_min = std::min(_M_min, __num);
_M_item_min = std::min(_M_item_min, __inum);
}
_M_total += __num;
_M_item_total += __inum;
_M_count += 1;
@ -149,7 +143,6 @@ namespace __gnu_profile
std::size_t _M_cost;
};
/** @brief A container size instrumentation line in the stack table. */
class __container_size_stack_info
: public __container_size_info
@ -158,7 +151,6 @@ namespace __gnu_profile
__container_size_stack_info(const __container_size_info& __o)
: __container_size_info(__o) { }
};
/** @brief Container size instrumentation trace producer. */
class __trace_container_size
@ -171,43 +163,22 @@ namespace __gnu_profile
: __trace_base<__container_size_info, __container_size_stack_info>() { };
// Insert a new node at construct with object, callstack and initial size.
void
__insert(const __object_t __obj, __stack_t __stack, std::size_t __num)
{ __add_object(__obj, __container_size_info(__stack, __num)); }
// XXX Undefined?
void
__construct(const void* __obj, std::size_t __inum);
// Call at destruction/clean to set container final size.
void
__destruct(const void* __obj, std::size_t __num, std::size_t __inum)
__container_size_info*
__insert(__stack_t __stack, std::size_t __num)
{
if (!__is_on())
return;
__object_t __obj_handle = static_cast<__object_t>(__obj);
__container_size_info* __object_info = __get_object_info(__obj_handle);
if (!__object_info)
return;
__object_info->__destruct(__num, __inum);
__retire_object(__obj_handle);
__container_size_info* __ret = __add_object(__stack);
if (__ret)
__ret->__init(__num);
return __ret;
}
// Call at resize to set resize/cost information.
// Call at destruction/clean to set container final size.
void
__resize(const void* __obj, int __from, int __to)
__destruct(__container_size_info* __obj_info,
std::size_t __num, std::size_t __inum)
{
if (!__is_on())
return;
__container_size_info* __object_info = __get_object_info(__obj);
if (!__object_info)
return;
__object_info->__resize(__from, __to);
__obj_info->__destruct(__num, __inum);
__retire_object(__obj_info);
}
};

View File

@ -41,22 +41,14 @@ namespace __gnu_profile
: public __object_info_base
{
public:
__hashfunc_info()
: _M_longest_chain(0), _M_accesses(0), _M_hops(0) { }
__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) { }
__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)
{
__object_info_base::__merge(__o);
_M_longest_chain = std::max(_M_longest_chain, __o._M_longest_chain);
_M_accesses += __o._M_accesses;
_M_hops += __o._M_hops;
@ -90,7 +82,6 @@ namespace __gnu_profile
std::size_t _M_hops;
};
/** @brief A hash performance instrumentation line in the stack table. */
class __hashfunc_stack_info
: public __hashfunc_info
@ -100,7 +91,6 @@ namespace __gnu_profile
: __hashfunc_info(__o) { }
};
/** @brief Hash performance instrumentation producer. */
class __trace_hash_func
: public __trace_base<__hashfunc_info, __hashfunc_stack_info>
@ -112,61 +102,50 @@ namespace __gnu_profile
~__trace_hash_func() {}
// Insert a new node at construct with object, callstack and initial size.
void
__insert(__object_t __obj, __stack_t __stack)
{ __add_object(__obj, __hashfunc_info(__stack)); }
// Call at destruction/clean to set container final size.
void
__destruct(const void* __obj, std::size_t __chain,
std::size_t __accesses, std::size_t __hops)
__destruct(__hashfunc_info* __obj_info,
std::size_t __chain, std::size_t __accesses, std::size_t __hops)
{
if (!__is_on())
if (!__obj_info)
return;
// First find the item from the live objects and update the information.
__hashfunc_info* __objs = __get_object_info(__obj);
if (!__objs)
return;
__objs->__destruct(__chain, __accesses, __hops);
__retire_object(__obj);
__obj_info->__destruct(__chain, __accesses, __hops);
__retire_object(__obj_info);
}
};
inline void
__trace_hash_func_init()
{ _GLIBCXX_PROFILE_DATA(_S_hash_func) = new __trace_hash_func(); }
inline void
__trace_hash_func_free()
{ delete _GLIBCXX_PROFILE_DATA(_S_hash_func); }
inline void
__trace_hash_func_report(FILE* __f, __warning_vector_t& __warnings)
{ __trace_report(_GLIBCXX_PROFILE_DATA(_S_hash_func), __f, __warnings); }
inline __hashfunc_info*
__trace_hash_func_construct()
{
if (_GLIBCXX_PROFILE_DATA(_S_hash_func))
{
_GLIBCXX_PROFILE_DATA(_S_hash_func)->__collect_warnings(__warnings);
_GLIBCXX_PROFILE_DATA(_S_hash_func)->__write(__f);
}
if (!__profcxx_init())
return 0;
if (!__reentrance_guard::__get_in())
return 0;
__reentrance_guard __get_out;
return _GLIBCXX_PROFILE_DATA(_S_hash_func)->__add_object(__get_stack());
}
inline void
__trace_hash_func_construct(const void* __obj)
__trace_hash_func_destruct(__hashfunc_info* __obj_info,
std::size_t __chain, std::size_t __accesses,
std::size_t __hops)
{
if (!__profcxx_init())
return;
_GLIBCXX_PROFILE_DATA(_S_hash_func)->__insert(__obj, __get_stack());
}
inline void
__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,
_GLIBCXX_PROFILE_DATA(_S_hash_func)->__destruct(__obj_info, __chain,
__accesses, __hops);
}

View File

@ -52,45 +52,47 @@ namespace __gnu_profile
__trace_hashtable_size_init()
{ _GLIBCXX_PROFILE_DATA(_S_hashtable_size) = new __trace_hashtable_size(); }
inline void
__trace_hashtable_size_free()
{ delete _GLIBCXX_PROFILE_DATA(_S_hashtable_size); }
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);
_GLIBCXX_PROFILE_DATA(_S_hashtable_size)->__write(__f);
}
}
{ __trace_report(_GLIBCXX_PROFILE_DATA(_S_hashtable_size), __f, __warnings); }
inline void
__trace_hashtable_size_construct(const void* __obj, std::size_t __num)
inline __container_size_info*
__trace_hashtable_size_construct(std::size_t __num)
{
if (!__profcxx_init())
return;
return 0;
_GLIBCXX_PROFILE_DATA(_S_hashtable_size)->__insert(__obj, __get_stack(),
__num);
if (!__reentrance_guard::__get_in())
return 0;
__reentrance_guard __get_out;
return _GLIBCXX_PROFILE_DATA(_S_hashtable_size)->
__insert(__get_stack(), __num);
}
inline void
__trace_hashtable_size_destruct(const void* __obj, std::size_t __num,
std::size_t __inum)
__trace_hashtable_size_resize(__container_size_info* __obj_info,
std::size_t __from, std::size_t __to)
{
if (!__profcxx_init())
if (!__obj_info)
return;
_GLIBCXX_PROFILE_DATA(_S_hashtable_size)->__destruct(__obj, __num, __inum);
__obj_info->__resize(__from, __to);
}
inline void
__trace_hashtable_size_resize(const void* __obj, std::size_t __from,
std::size_t __to)
__trace_hashtable_size_destruct(__container_size_info* __obj_info,
std::size_t __num, std::size_t __inum)
{
if (!__profcxx_init())
if (!__obj_info)
return;
_GLIBCXX_PROFILE_DATA(_S_hashtable_size)->__resize(__obj, __from, __to);
_GLIBCXX_PROFILE_DATA(_S_hashtable_size)->
__destruct(__obj_info, __num, __inum);
}
} // namespace __gnu_profile

View File

@ -40,18 +40,9 @@ namespace __gnu_profile
: public __object_info_base
{
public:
__list2slist_info()
: _M_rewind(false), _M_operations(0) { }
__list2slist_info(__stack_t __stack)
: __object_info_base(__stack), _M_rewind(false), _M_operations(0) { }
virtual ~__list2slist_info() { }
__list2slist_info(const __list2slist_info& __o)
: __object_info_base(__o), _M_rewind(__o._M_rewind),
_M_operations(__o._M_operations) { }
// XXX: the magnitude should be multiplied with a constant factor F,
// 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
@ -69,9 +60,6 @@ namespace __gnu_profile
return 0;
}
void
__merge(const __list2slist_info&) { }
void
__write(FILE* __f) const
{ std::fprintf(__f, "%s\n", _M_rewind ? "invalid" : "valid"); }
@ -84,7 +72,7 @@ namespace __gnu_profile
__opr_rewind()
{
_M_rewind = true;
_M_valid = false;
__set_invalid();
}
void
@ -119,37 +107,8 @@ namespace __gnu_profile
{ __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);
}
__destruct(__list2slist_info* __obj_info)
{ __retire_object(__obj_info); }
};
@ -157,51 +116,52 @@ namespace __gnu_profile
__trace_list_to_slist_init()
{ _GLIBCXX_PROFILE_DATA(_S_list_to_slist) = new __trace_list_to_slist(); }
inline void
__trace_list_to_slist_free()
{ delete _GLIBCXX_PROFILE_DATA(_S_list_to_slist); }
inline void
__trace_list_to_slist_report(FILE* __f, __warning_vector_t& __warnings)
{ __trace_report(_GLIBCXX_PROFILE_DATA(_S_list_to_slist), __f, __warnings); }
inline __list2slist_info*
__trace_list_to_slist_construct()
{
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);
}
if (!__profcxx_init())
return 0;
if (!__reentrance_guard::__get_in())
return 0;
__reentrance_guard __get_out;
return _GLIBCXX_PROFILE_DATA(_S_list_to_slist)->__add_object(__get_stack());
}
inline void
__trace_list_to_slist_rewind(const void* __obj)
__trace_list_to_slist_rewind(__list2slist_info* __obj_info)
{
if (!__profcxx_init())
if (!__obj_info)
return;
_GLIBCXX_PROFILE_DATA(_S_list_to_slist)->__opr_rewind(__obj);
__obj_info->__opr_rewind();
}
inline void
__trace_list_to_slist_operation(const void* __obj)
__trace_list_to_slist_operation(__list2slist_info* __obj_info)
{
if (!__profcxx_init())
if (!__obj_info)
return;
_GLIBCXX_PROFILE_DATA(_S_list_to_slist)->__record_operation(__obj);
__obj_info->__record_operation();
}
inline void
__trace_list_to_slist_construct(const void* __obj)
__trace_list_to_slist_destruct(__list2slist_info* __obj_info)
{
if (!__profcxx_init())
if (!__obj_info)
return;
_GLIBCXX_PROFILE_DATA(_S_list_to_slist)->__insert(__obj, __get_stack());
}
inline void
__trace_list_to_slist_destruct(const void* __obj)
{
if (!__profcxx_init())
return;
_GLIBCXX_PROFILE_DATA(_S_list_to_slist)->__destruct(__obj);
_GLIBCXX_PROFILE_DATA(_S_list_to_slist)->__destruct(__obj_info);
}
} // namespace __gnu_profile

View File

@ -43,31 +43,19 @@ namespace __gnu_profile
: public __object_info_base
{
public:
__list2vector_info()
: _M_shift_count(0), _M_iterate(0), _M_resize(0), _M_list_cost(0),
_M_vector_cost(0), _M_valid(true), _M_max_size(0) { }
__list2vector_info(__stack_t __stack)
: __object_info_base(__stack), _M_shift_count(0), _M_iterate(0),
_M_resize(0), _M_list_cost(0), _M_vector_cost(0), _M_valid(true),
_M_resize(0), _M_list_cost(0), _M_vector_cost(0),
_M_max_size(0) { }
virtual ~__list2vector_info() { }
__list2vector_info(const __list2vector_info& __o)
: __object_info_base(__o), _M_shift_count(__o._M_shift_count),
_M_iterate(__o._M_iterate), _M_resize(__o._M_resize),
_M_list_cost(__o._M_list_cost), _M_vector_cost(__o._M_vector_cost),
_M_valid(__o._M_valid), _M_max_size(__o._M_max_size) { }
void
__merge(const __list2vector_info& __o)
{
__object_info_base::__merge(__o);
_M_shift_count += __o._M_shift_count;
_M_iterate += __o._M_iterate;
_M_vector_cost += __o._M_vector_cost;
_M_list_cost += __o._M_list_cost;
_M_valid &= __o._M_valid;
_M_resize += __o._M_resize;
_M_max_size = std::max( _M_max_size, __o._M_max_size);
}
@ -117,14 +105,6 @@ namespace __gnu_profile
__set_vector_cost(float __vc)
{ _M_vector_cost = __vc; }
bool
__is_valid()
{ return _M_valid; }
void
__set_invalid()
{ _M_valid = false; }
void
__opr_insert(std::size_t __shift, std::size_t __size)
{
@ -133,8 +113,8 @@ namespace __gnu_profile
}
void
__opr_iterate(std::size_t __num)
{ _M_iterate += __num;}
__opr_iterate(int __num)
{ __gnu_cxx::__atomic_add(&_M_iterate, __num); }
void
__resize(std::size_t __from, std::size_t)
@ -142,11 +122,10 @@ namespace __gnu_profile
private:
std::size_t _M_shift_count;
std::size_t _M_iterate;
mutable _Atomic_word _M_iterate;
std::size_t _M_resize;
float _M_list_cost;
float _M_vector_cost;
bool _M_valid;
std::size_t _M_max_size;
};
@ -168,65 +147,20 @@ namespace __gnu_profile
~__trace_list_to_vector() { }
// Insert a new node at construct with object, callstack and initial size.
void
__insert(__object_t __obj, __stack_t __stack)
{ __add_object(__obj, __list2vector_info(__stack)); }
// Call at destruction/clean to set container final size.
void
__destruct(const void* __obj)
__destruct(__list2vector_info* __obj_info)
{
if (!__is_on())
return;
__list2vector_info* __res = __get_object_info(__obj);
if (!__res)
return;
float __vc = __vector_cost(__res->__shift_count(), __res->__iterate());
float __lc = __list_cost(__res->__shift_count(), __res->__iterate());
__res->__set_vector_cost(__vc);
__res->__set_list_cost(__lc);
__retire_object(__obj);
float __vc = __vector_cost(__obj_info->__shift_count(),
__obj_info->__iterate());
float __lc = __list_cost(__obj_info->__shift_count(),
__obj_info->__iterate());
__obj_info->__set_vector_cost(__vc);
__obj_info->__set_list_cost(__lc);
__retire_object(__obj_info);
}
// Find the node in the live map.
__list2vector_info* __find(const void* __obj);
// Collect cost of operations.
void
__opr_insert(const void* __obj, std::size_t __shift, std::size_t __size)
{
__list2vector_info* __res = __get_object_info(__obj);
if (__res)
__res->__opr_insert(__shift, __size);
}
void
__opr_iterate(const void* __obj, std::size_t __num)
{
__list2vector_info* __res = __get_object_info(__obj);
if (__res)
__res->__opr_iterate(__num);
}
void
__invalid_operator(const void* __obj)
{
__list2vector_info* __res = __get_object_info(__obj);
if (__res)
__res->__set_invalid();
}
void
__resize(const void* __obj, std::size_t __from, std::size_t __to)
{
__list2vector_info* __res = __get_object_info(__obj);
if (__res)
__res->__resize(__from, __to);
}
float
__vector_cost(std::size_t __shift, std::size_t __iterate)
{
@ -252,72 +186,75 @@ namespace __gnu_profile
__trace_list_to_vector_init()
{ _GLIBCXX_PROFILE_DATA(_S_list_to_vector) = new __trace_list_to_vector(); }
inline void
__trace_list_to_vector_free()
{ delete _GLIBCXX_PROFILE_DATA(_S_list_to_vector); }
inline void
__trace_list_to_vector_report(FILE* __f, __warning_vector_t& __warnings)
{
if (_GLIBCXX_PROFILE_DATA(_S_list_to_vector))
{
_GLIBCXX_PROFILE_DATA(_S_list_to_vector)->
__collect_warnings(__warnings);
_GLIBCXX_PROFILE_DATA(_S_list_to_vector)->__write(__f);
}
}
{ __trace_report(_GLIBCXX_PROFILE_DATA(_S_list_to_vector), __f, __warnings); }
inline void
__trace_list_to_vector_construct(const void* __obj)
inline __list2vector_info*
__trace_list_to_vector_construct()
{
if (!__profcxx_init())
return;
return 0;
_GLIBCXX_PROFILE_DATA(_S_list_to_vector)->__insert(__obj, __get_stack());
if (!__reentrance_guard::__get_in())
return 0;
__reentrance_guard __get_out;
return _GLIBCXX_PROFILE_DATA(_S_list_to_vector)
->__add_object(__get_stack());
}
inline void
__trace_list_to_vector_destruct(const void* __obj)
{
if (!__profcxx_init())
return;
_GLIBCXX_PROFILE_DATA(_S_list_to_vector)->__destruct(__obj);
}
inline void
__trace_list_to_vector_insert(const void* __obj,
__trace_list_to_vector_insert(__list2vector_info* __obj_info,
std::size_t __shift, std::size_t __size)
{
if (!__profcxx_init())
if (!__obj_info)
return;
_GLIBCXX_PROFILE_DATA(_S_list_to_vector)->__opr_insert(__obj, __shift,
__size);
__obj_info->__opr_insert(__shift, __size);
}
inline void
__trace_list_to_vector_iterate(const void* __obj, std::size_t __num = 1)
__trace_list_to_vector_iterate(__list2vector_info* __obj_info,
int)
{
if (!__profcxx_init())
if (!__obj_info)
return;
_GLIBCXX_PROFILE_DATA(_S_list_to_vector)->__opr_iterate(__obj, __num);
// We only collect if an iteration took place no matter in what side.
__obj_info->__opr_iterate(1);
}
inline void
__trace_list_to_vector_invalid_operator(const void* __obj)
__trace_list_to_vector_invalid_operator(__list2vector_info* __obj_info)
{
if (!__profcxx_init())
if (!__obj_info)
return;
_GLIBCXX_PROFILE_DATA(_S_list_to_vector)->__invalid_operator(__obj);
__obj_info->__set_invalid();
}
inline void
__trace_list_to_vector_resize(const void* __obj,
__trace_list_to_vector_resize(__list2vector_info* __obj_info,
std::size_t __from, std::size_t __to)
{
if (!__profcxx_init())
if (!__obj_info)
return;
_GLIBCXX_PROFILE_DATA(_S_list_to_vector)->__resize(__obj, __from, __to);
__obj_info->__resize(__from, __to);
}
inline void
__trace_list_to_vector_destruct(__list2vector_info* __obj_info)
{
if (!__obj_info)
return;
_GLIBCXX_PROFILE_DATA(_S_list_to_vector)->__destruct(__obj_info);
}
} // namespace __gnu_profile

View File

@ -67,39 +67,29 @@ namespace __gnu_profile
: public __object_info_base
{
public:
__map2umap_info()
: _M_insert(0), _M_erase(0), _M_find(0), _M_iterate(0),
_M_umap_cost(0.0), _M_map_cost(0.0), _M_valid(true) { }
__map2umap_info(__stack_t __stack)
: __object_info_base(__stack), _M_insert(0), _M_erase(0), _M_find(0),
_M_iterate(0), _M_umap_cost(0.0), _M_map_cost(0.0), _M_valid(true) { }
virtual ~__map2umap_info() { }
__map2umap_info(const __map2umap_info& __o)
: __object_info_base(__o), _M_insert(__o._M_insert),
_M_erase(__o._M_erase), _M_find(__o._M_find),
_M_iterate(__o._M_iterate), _M_umap_cost(__o._M_umap_cost),
_M_map_cost(__o._M_map_cost), _M_valid(__o._M_valid) { }
_M_iterate(0), _M_umap_cost(0.0), _M_map_cost(0.0)
{ }
void
__merge(const __map2umap_info& __o)
{
_M_insert += __o._M_insert;
_M_erase += __o._M_erase;
_M_find += __o._M_find;
_M_umap_cost += __o._M_umap_cost;
_M_map_cost += __o._M_map_cost;
_M_valid &= __o._M_valid;
__object_info_base::__merge(__o);
_M_insert += __o._M_insert;
_M_erase += __o._M_erase;
_M_find += __o._M_find;
_M_iterate += __o._M_iterate;
_M_umap_cost += __o._M_umap_cost;
_M_map_cost += __o._M_map_cost;
}
void
__write(FILE* __f) const
{
std::fprintf(__f, "%Zu %Zu %Zu %Zu %.0f %.0f %s\n",
std::fprintf(__f, "%Zu %Zu %Zu %Zu %.0f %.0f\n",
_M_insert, _M_erase, _M_find, _M_iterate, _M_map_cost,
_M_umap_cost, _M_valid ? "valid" : "invalid");
_M_umap_cost);
}
float
@ -145,29 +135,27 @@ namespace __gnu_profile
}
void
__record_iterate(std::size_t __count)
{
_M_iterate += __count;
_M_map_cost
+= (__count
* _GLIBCXX_PROFILE_DATA(__map_iterate_cost_factor).__value);
_M_umap_cost
+= (__count
* _GLIBCXX_PROFILE_DATA(__umap_iterate_cost_factor).__value);
}
__record_iterate(int __count)
{ __gnu_cxx::__atomic_add(&_M_iterate, __count); }
void
__record_invalidate()
{ _M_valid = false; }
__set_iterate_costs()
{
_M_umap_cost
+= (_M_iterate
* _GLIBCXX_PROFILE_DATA(__umap_iterate_cost_factor).__value);
_M_map_cost
+= (_M_iterate
* _GLIBCXX_PROFILE_DATA(__map_iterate_cost_factor).__value);
}
private:
std::size_t _M_insert;
std::size_t _M_erase;
std::size_t _M_find;
std::size_t _M_iterate;
mutable _Atomic_word _M_iterate;
float _M_umap_cost;
float _M_map_cost;
bool _M_valid;
};
@ -189,108 +177,99 @@ namespace __gnu_profile
__trace_map2umap()
: __trace_base<__map2umap_info, __map2umap_stack_info>()
{ __id = "ordered-to-unordered"; }
// Call at destruction/clean to set container final size.
void
__destruct(__map2umap_info* __obj_info)
{
__obj_info->__set_iterate_costs();
__retire_object(__obj_info);
}
};
inline void
__trace_map_to_unordered_map_init()
{ _GLIBCXX_PROFILE_DATA(_S_map2umap) = new __trace_map2umap(); }
inline void
__trace_map_to_unordered_map_free()
{ delete _GLIBCXX_PROFILE_DATA(_S_map2umap); }
inline void
__trace_map_to_unordered_map_report(FILE* __f,
__warning_vector_t& __warnings)
{
if (_GLIBCXX_PROFILE_DATA(_S_map2umap))
{
_GLIBCXX_PROFILE_DATA(_S_map2umap)->__collect_warnings(__warnings);
_GLIBCXX_PROFILE_DATA(_S_map2umap)->__write(__f);
}
}
{ __trace_report(_GLIBCXX_PROFILE_DATA(_S_map2umap), __f, __warnings); }
inline void
__trace_map_to_unordered_map_construct(const void* __obj)
inline __map2umap_info*
__trace_map_to_unordered_map_construct()
{
if (!__profcxx_init())
return;
return 0;
_GLIBCXX_PROFILE_DATA(_S_map2umap)->
__add_object(__obj, __map2umap_info(__get_stack()));
if (!__reentrance_guard::__get_in())
return 0;
__reentrance_guard __get_out;
return _GLIBCXX_PROFILE_DATA(_S_map2umap)->__add_object(__get_stack());
}
inline void
__trace_map_to_unordered_map_destruct(const void* __obj)
{
if (!__profcxx_init())
return;
_GLIBCXX_PROFILE_DATA(_S_map2umap)->__retire_object(__obj);
}
inline void
__trace_map_to_unordered_map_insert(const void* __obj,
__trace_map_to_unordered_map_insert(__map2umap_info* __info,
std::size_t __size, std::size_t __count)
{
if (!__profcxx_init())
if (!__info)
return;
__map2umap_info* __info
= _GLIBCXX_PROFILE_DATA(_S_map2umap)->__get_object_info(__obj);
if (__info)
__info->__record_insert(__size, __count);
__info->__record_insert(__size, __count);
}
inline void
__trace_map_to_unordered_map_erase(const void* __obj,
__trace_map_to_unordered_map_erase(__map2umap_info* __info,
std::size_t __size, std::size_t __count)
{
if (!__profcxx_init())
if (!__info)
return;
__map2umap_info* __info
= _GLIBCXX_PROFILE_DATA(_S_map2umap)->__get_object_info(__obj);
if (__info)
__info->__record_erase(__size, __count);
__info->__record_erase(__size, __count);
}
inline void
__trace_map_to_unordered_map_find(const void* __obj, std::size_t __size)
__trace_map_to_unordered_map_find(__map2umap_info* __info,
std::size_t __size)
{
if (!__profcxx_init())
if (!__info)
return;
__map2umap_info* __info
= _GLIBCXX_PROFILE_DATA(_S_map2umap)->__get_object_info(__obj);
if (__info)
__info->__record_find(__size);
__info->__record_find(__size);
}
inline void
__trace_map_to_unordered_map_iterate(const void* __obj, std::size_t __count)
__trace_map_to_unordered_map_iterate(__map2umap_info* __info,
int)
{
if (!__profcxx_init())
if (!__info)
return;
__map2umap_info* __info
= _GLIBCXX_PROFILE_DATA(_S_map2umap)->__get_object_info(__obj);
if (__info)
__info->__record_iterate(__count);
// We only collect if an iteration took place no matter in what side.
__info->__record_iterate(1);
}
inline void
__trace_map_to_unordered_map_invalidate(const void* __obj)
__trace_map_to_unordered_map_invalidate(__map2umap_info* __info)
{
if (!__profcxx_init())
if (!__info)
return;
__map2umap_info* __info
= _GLIBCXX_PROFILE_DATA(_S_map2umap)->__get_object_info(__obj);
if (__info)
__info->__record_invalidate();
__info->__set_invalid();
}
inline void
__trace_map_to_unordered_map_destruct(__map2umap_info* __info)
{
if (!__info)
return;
_GLIBCXX_PROFILE_DATA(_S_map2umap)->__destruct(__info);
}
} // namespace __gnu_profile
#endif /* _GLIBCXX_PROFILE_PROFILER_MAP_TO_UNORDERED_MAP_H */

View File

@ -39,7 +39,6 @@
namespace __gnu_profile
{
typedef const void* __object_t;
typedef void* __instruction_address_t;
typedef std::_GLIBCXX_STD_C::vector<__instruction_address_t> __stack_npt;
typedef __stack_npt* __stack_t;
@ -50,15 +49,20 @@ namespace __gnu_profile
__get_stack()
{
#if defined _GLIBCXX_HAVE_EXECINFO_H
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);
__builtin_memcpy(&(*__stack)[0], &__buffer[0],
__depth * sizeof(__object_t));
return __stack;
__try
{
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);
return new(std::nothrow) __stack_npt(__buffer.begin(),
__buffer.begin() + __depth);
}
__catch(...)
{
return 0;
}
#else
return 0;
#endif
@ -123,44 +127,29 @@ namespace __gnu_profile
class __object_info_base
{
public:
__object_info_base() { }
__object_info_base(__stack_t __stack)
: _M_stack(__stack), _M_valid(true) { }
__object_info_base(const __object_info_base& __o)
: _M_stack(__o._M_stack), _M_valid(__o._M_valid) { }
virtual ~__object_info_base() { }
bool
__is_valid() const
{ return _M_valid; }
void
__set_invalid()
{ _M_valid = false; }
void
__merge(const __object_info_base& __o)
{ _M_valid &= __o._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
#endif /* _GLIBCXX_PROFILE_PROFILER_NODE_H */

View File

@ -35,8 +35,8 @@
#include <cstdlib> // atof, atoi, strtol, getenv, atexit, abort
#if __cplusplus >= 201103L
#define _GLIBCXX_IMPL_UNORDERED_MAP std::_GLIBCXX_STD_C::unordered_map
#include <unordered_map>
#define _GLIBCXX_IMPL_UNORDERED_MAP std::_GLIBCXX_STD_C::unordered_map
#else
#include <tr1/unordered_map>
#define _GLIBCXX_IMPL_UNORDERED_MAP std::tr1::unordered_map
@ -56,10 +56,10 @@ namespace __gnu_profile
{
/** @brief Internal environment. Values can be set one of two ways:
1. In config file "var = value". The default config file path is
libstdcxx-profile.conf.
libstdcxx-profile.conf.
2. By setting process environment variables. For instance, in a Bash
shell you can set the unit cost of iterating through a map like this:
export __map_iterate_cost_factor=5.0.
shell you can set the unit cost of iterating through a map like this:
export __map_iterate_cost_factor=5.0.
If a value is set both in the input file and through an environment
variable, the environment value takes precedence. */
typedef _GLIBCXX_IMPL_UNORDERED_MAP<std::string, std::string> __env_t;
@ -67,7 +67,7 @@ namespace __gnu_profile
_GLIBCXX_PROFILE_DEFINE_UNINIT_DATA(__env_t, __env);
/** @brief Master lock. */
_GLIBCXX_PROFILE_DEFINE_UNINIT_DATA(__gnu_cxx::__mutex, __global_lock);
_GLIBCXX_PROFILE_DEFINE_UNINIT_DATA(__gnu_cxx::__mutex, __global_mutex);
/** @brief Representation of a warning. */
struct __warning_data
@ -114,6 +114,13 @@ namespace __gnu_profile
void __trace_list_to_slist_report(FILE*, __warning_vector_t&);
void __trace_list_to_vector_report(FILE*, __warning_vector_t&);
void __trace_map_to_unordered_map_report(FILE*, __warning_vector_t&);
void __trace_vector_size_free();
void __trace_hashtable_size_free();
void __trace_hash_func_free();
void __trace_vector_to_list_free();
void __trace_list_to_slist_free();
void __trace_list_to_vector_free();
void __trace_map_to_unordered_map_free();
struct __cost_factor
{
@ -186,26 +193,28 @@ namespace __gnu_profile
// Do not pick the initial size too large, as we don't know which
// diagnostics are more active.
__trace_base()
: __object_table(10000), __stack_table(10000),
: __objects_byte_size(0), __stack_table(10000),
__stack_table_byte_size(0), __id(0) { }
virtual ~__trace_base() { }
~__trace_base()
{
for (typename __stack_table_t::iterator __it
= __stack_table.begin(); __it != __stack_table.end(); ++__it)
delete __it->first;
}
void __add_object(__object_t object, __object_info __info);
__object_info* __get_object_info(__object_t __object);
void __retire_object(__object_t __object);
__object_info* __add_object(__stack_t __stack);
void __retire_object(__object_info* __info);
void __write(FILE* __f);
void __collect_warnings(__warning_vector_t& __warnings);
void __free();
private:
__gnu_cxx::__mutex __object_table_lock;
__gnu_cxx::__mutex __stack_table_lock;
typedef _GLIBCXX_IMPL_UNORDERED_MAP<__object_t,
__object_info> __object_table_t;
__gnu_cxx::__mutex __trace_mutex;
typedef _GLIBCXX_IMPL_UNORDERED_MAP<__stack_t, __stack_info,
__stack_hash,
__stack_hash> __stack_table_t;
__object_table_t __object_table;
std::size_t __objects_byte_size;
__stack_table_t __stack_table;
std::size_t __stack_table_byte_size;
@ -213,97 +222,72 @@ namespace __gnu_profile
const char* __id;
};
template<typename __object_info, typename __stack_info>
void
__trace_base<__object_info, __stack_info>::
__collect_warnings(__warning_vector_t& __warnings)
{
for (typename __stack_table_t::iterator __it
= __stack_table.begin(); __it != __stack_table.end(); ++__it)
__warnings.push_back(__warning_data((*__it).second.__magnitude(),
(*__it).first, __id,
(*__it).second.__advice()));
}
template<typename __object_info, typename __stack_info>
void
__trace_base<__object_info, __stack_info>::
__add_object(__object_t __object, __object_info __info)
{
if (__max_mem() == 0
|| __object_table.size() * sizeof(__object_info) <= __max_mem())
{
this->__object_table_lock.lock();
__object_table.insert(typename __object_table_t::
value_type(__object, __info));
this->__object_table_lock.unlock();
}
}
template<typename __object_info, typename __stack_info>
__object_info*
__trace_base<__object_info, __stack_info>::
__get_object_info(__object_t __object)
__add_object(__stack_t __stack)
{
// XXX: Revisit this to see if we can decrease mutex spans.
// Without this mutex, the object table could be rehashed during an
// insertion on another thread, which could result in a segfault.
this->__object_table_lock.lock();
typename __object_table_t::iterator __object_it
= __object_table.find(__object);
// If we have no backtrace information no need to collect data.
if (!__stack)
return 0;
if (__object_it == __object_table.end())
__gnu_cxx::__scoped_lock __lock(this->__trace_mutex);
if (__max_mem() != 0 && __objects_byte_size >= __max_mem())
{
this->__object_table_lock.unlock();
delete __stack;
return 0;
}
__object_info* __ret = new(std::nothrow) __object_info(__stack);
if (!__ret)
{
delete __stack;
return 0;
}
__objects_byte_size += sizeof(__object_info);
return __ret;
}
template<typename __object_info, typename __stack_info>
void
__trace_base<__object_info, __stack_info>::
__retire_object(__object_info* __obj_info)
{
if (!__obj_info)
return;
__gnu_cxx::__scoped_lock __lock(this->__trace_mutex);
const __object_info& __info = *__obj_info;
__stack_t __stack = __info.__stack();
typename __stack_table_t::iterator __stack_it
= __stack_table.find(__stack);
if (__stack_it == __stack_table.end())
{
// First occurrence of this call context.
if (__max_mem() == 0 || __stack_table_byte_size < __max_mem())
{
__stack_table_byte_size
+= (sizeof(__instruction_address_t) * __size(__stack)
+ sizeof(__stack) + sizeof(__stack_info));
__stack_table.insert(make_pair(__stack,
__stack_info(__info)));
}
else
delete __stack;
}
else
{
this->__object_table_lock.unlock();
return &__object_it->second;
}
}
template<typename __object_info, typename __stack_info>
void
__trace_base<__object_info, __stack_info>::
__retire_object(__object_t __object)
{
this->__object_table_lock.lock();
this->__stack_table_lock.lock();
typename __object_table_t::iterator __object_it
= __object_table.find(__object);
if (__object_it != __object_table.end())
{
const __object_info& __info = __object_it->second;
const __stack_t& __stack = __info.__stack();
typename __stack_table_t::iterator __stack_it
= __stack_table.find(__stack);
if (__stack_it == __stack_table.end())
{
// First occurrence of this call context.
if (__max_mem() == 0 || __stack_table_byte_size < __max_mem())
{
__stack_table_byte_size
+= (sizeof(__instruction_address_t) * __size(__stack)
+ sizeof(__stack) + sizeof(__stack_info));
__stack_table.insert(make_pair(__stack,
__stack_info(__info)));
}
}
else
{
// Merge object info into info summary for this call context.
__stack_it->second.__merge(__info);
delete __stack;
}
__object_table.erase(__object);
// Merge object info into info summary for this call context.
__stack_it->second.__merge(__info);
delete __stack;
}
this->__object_table_lock.unlock();
this->__stack_table_lock.unlock();
delete __obj_info;
__objects_byte_size -= sizeof(__object_info);
}
template<typename __object_info, typename __stack_info>
@ -323,6 +307,30 @@ namespace __gnu_profile
}
}
template<typename __object_info, typename __stack_info>
void
__trace_base<__object_info, __stack_info>::
__collect_warnings(__warning_vector_t& __warnings)
{
for (typename __stack_table_t::iterator __it
= __stack_table.begin(); __it != __stack_table.end(); ++__it)
__warnings.push_back(__warning_data(__it->second.__magnitude(),
__it->first, __id,
__it->second.__advice()));
}
template<typename __object_info, typename __stack_info>
inline void
__trace_report(__trace_base<__object_info, __stack_info>* __cont,
FILE* __f, __warning_vector_t& __warnings)
{
if (__cont)
{
__cont->__collect_warnings(__warnings);
__cont->__write(__f);
}
}
inline std::size_t
__env_to_size_t(const char* __env_var, std::size_t __default_value)
{
@ -437,9 +445,9 @@ namespace __gnu_profile
* __gnu_profile (under the guarded zone), no output will be produced.
*/
inline void
__report(void)
__report()
{
_GLIBCXX_PROFILE_DATA(__global_lock).lock();
__gnu_cxx::__scoped_lock __lock(_GLIBCXX_PROFILE_DATA(__global_mutex));
__warning_vector_t __warnings, __top_warnings;
@ -462,8 +470,21 @@ namespace __gnu_profile
__for_each(__top_warnings.begin(), __top_warnings.end(),
__warn(__warn_file));
std::fclose(__warn_file);
}
_GLIBCXX_PROFILE_DATA(__global_lock).unlock();
inline void
__report_and_free()
{
__report();
__trace_map_to_unordered_map_free();
__trace_list_to_vector_free();
__trace_list_to_slist_free();
__trace_vector_to_list_free();
__trace_hash_func_free();
__trace_hashtable_size_free();
__trace_vector_size_free();
delete _GLIBCXX_PROFILE_DATA(__cost_factors);
}
inline void
@ -554,60 +575,45 @@ namespace __gnu_profile
const char* __env_value = std::getenv(__factor->__env_var);
if (!__env_value)
{
// Look it up in the config file.
__env_t::iterator __it
{
// Look it up in the config file.
__env_t::iterator __it
= _GLIBCXX_PROFILE_DATA(__env).find(__factor->__env_var);
if (__it != _GLIBCXX_PROFILE_DATA(__env).end())
__env_value = (*__it).second.c_str();
}
if (__it != _GLIBCXX_PROFILE_DATA(__env).end())
__env_value = __it->second.c_str();
}
if (__env_value)
__factor->__value = std::atof(__env_value);
__factor->__value = std::atof(__env_value);
}
};
inline void
__set_cost_factors()
{
_GLIBCXX_PROFILE_DATA(__cost_factors) = new __cost_factor_vector;
_GLIBCXX_PROFILE_DATA(__cost_factors)->
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());
__cost_factor_vector* __factors = new __cost_factor_vector;
_GLIBCXX_PROFILE_DATA(__cost_factors) = __factors;
__factors->push_back(&_GLIBCXX_PROFILE_DATA(__vector_shift_cost_factor));
__factors->push_back(&_GLIBCXX_PROFILE_DATA(__vector_iterate_cost_factor));
__factors->push_back(&_GLIBCXX_PROFILE_DATA(__vector_resize_cost_factor));
__factors->push_back(&_GLIBCXX_PROFILE_DATA(__list_shift_cost_factor));
__factors->push_back(&_GLIBCXX_PROFILE_DATA(__list_iterate_cost_factor));
__factors->push_back(&_GLIBCXX_PROFILE_DATA(__list_resize_cost_factor));
__factors->push_back(&_GLIBCXX_PROFILE_DATA(__map_insert_cost_factor));
__factors->push_back(&_GLIBCXX_PROFILE_DATA(__map_erase_cost_factor));
__factors->push_back(&_GLIBCXX_PROFILE_DATA(__map_find_cost_factor));
__factors->push_back(&_GLIBCXX_PROFILE_DATA(__map_iterate_cost_factor));
__factors->push_back(&_GLIBCXX_PROFILE_DATA(__umap_insert_cost_factor));
__factors->push_back(&_GLIBCXX_PROFILE_DATA(__umap_erase_cost_factor));
__factors->push_back(&_GLIBCXX_PROFILE_DATA(__umap_find_cost_factor));
__factors->push_back(&_GLIBCXX_PROFILE_DATA(__umap_iterate_cost_factor));
__for_each(__factors->begin(), __factors->end(), __cost_factor_setter());
}
inline void
__profcxx_init_unconditional()
{
_GLIBCXX_PROFILE_DATA(__global_lock).lock();
__gnu_cxx::__scoped_lock __lock(_GLIBCXX_PROFILE_DATA(__global_mutex));
if (__is_invalid())
{
@ -632,13 +638,11 @@ namespace __gnu_profile
__trace_list_to_vector_init();
__trace_map_to_unordered_map_init();
std::atexit(__report);
std::atexit(__report_and_free);
__turn_on();
}
}
_GLIBCXX_PROFILE_DATA(__global_lock).unlock();
}
/** @brief This function must be called by each instrumentation point.

View File

@ -52,44 +52,47 @@ namespace __gnu_profile
__trace_vector_size_init()
{ _GLIBCXX_PROFILE_DATA(_S_vector_size) = new __trace_vector_size(); }
inline void
__trace_vector_size_free()
{ delete _GLIBCXX_PROFILE_DATA(_S_vector_size); }
inline void
__trace_vector_size_report(FILE* __f, __warning_vector_t& __warnings)
{ __trace_report(_GLIBCXX_PROFILE_DATA(_S_vector_size), __f, __warnings); }
inline __container_size_info*
__trace_vector_size_construct(std::size_t __num)
{
if (_GLIBCXX_PROFILE_DATA(_S_vector_size))
{
_GLIBCXX_PROFILE_DATA(_S_vector_size)->__collect_warnings(__warnings);
_GLIBCXX_PROFILE_DATA(_S_vector_size)->__write(__f);
}
if (!__profcxx_init())
return 0;
if (!__reentrance_guard::__get_in())
return 0;
__reentrance_guard __get_out;
return _GLIBCXX_PROFILE_DATA(_S_vector_size)->
__insert(__get_stack(), __num);
}
inline void
__trace_vector_size_construct(const void* __obj, std::size_t __num)
__trace_vector_size_resize(__container_size_info* __obj_info,
std::size_t __from, std::size_t __to)
{
if (!__profcxx_init())
if (!__obj_info)
return;
_GLIBCXX_PROFILE_DATA(_S_vector_size)->__insert(__obj, __get_stack(),
__num);
__obj_info->__resize(__from, __to);
}
inline void
__trace_vector_size_destruct(const void* __obj, std::size_t __num,
std::size_t __inum)
__trace_vector_size_destruct(__container_size_info* __obj_info,
std::size_t __num, std::size_t __inum)
{
if (!__profcxx_init())
if (!__obj_info)
return;
_GLIBCXX_PROFILE_DATA(_S_vector_size)->__destruct(__obj, __num, __inum);
}
inline void
__trace_vector_size_resize(const void* __obj, std::size_t __from,
std::size_t __to)
{
if (!__profcxx_init())
return;
_GLIBCXX_PROFILE_DATA(_S_vector_size)->__resize(__obj, __from, __to);
_GLIBCXX_PROFILE_DATA(_S_vector_size)->
__destruct(__obj_info, __num, __inum);
}
} // namespace __gnu_profile

View File

@ -41,30 +41,19 @@ namespace __gnu_profile
: public __object_info_base
{
public:
__vector2list_info()
: _M_shift_count(0), _M_iterate(0), _M_resize(0), _M_list_cost(0),
_M_vector_cost(0), _M_valid(true) { }
__vector2list_info(__stack_t __stack)
: __object_info_base(__stack), _M_shift_count(0), _M_iterate(0),
_M_resize(0), _M_list_cost(0), _M_vector_cost(0), _M_valid(true) { }
virtual ~__vector2list_info() { }
__vector2list_info(const __vector2list_info& __o)
: __object_info_base(__o), _M_shift_count(__o._M_shift_count),
_M_iterate(__o._M_iterate), _M_resize(__o._M_resize),
_M_list_cost(__o._M_list_cost), _M_vector_cost(__o._M_vector_cost),
_M_valid(__o._M_valid) { }
_M_resize(0), _M_list_cost(0), _M_vector_cost(0)
{ }
void
__merge(const __vector2list_info& __o)
{
__object_info_base::__merge(__o);
_M_shift_count += __o._M_shift_count;
_M_iterate += __o._M_iterate;
_M_vector_cost += __o._M_vector_cost;
_M_list_cost += __o._M_list_cost;
_M_valid &= __o._M_valid;
_M_resize += __o._M_resize;
}
@ -107,40 +96,24 @@ namespace __gnu_profile
__set_vector_cost(float __vc)
{ _M_vector_cost = __vc; }
bool
__is_valid()
{ return _M_valid; }
void
__set_invalid()
{ _M_valid = false; }
void
__opr_insert(std::size_t __pos, std::size_t __num)
{ _M_shift_count += __num - __pos; }
void
__opr_iterate(std::size_t __num)
{ _M_iterate += __num; }
__opr_iterate(int __num)
{ __gnu_cxx::__atomic_add(&_M_iterate, __num); }
void
__resize(std::size_t __from, std::size_t)
{ _M_resize += __from; }
void
__opr_find(std::size_t __size)
{
// Use average case complexity.
_M_iterate += 3.0 / 4.0 * __size;
}
private:
std::size_t _M_shift_count;
std::size_t _M_iterate;
mutable _Atomic_word _M_iterate;
std::size_t _M_resize;
float _M_list_cost;
float _M_vector_cost;
bool _M_valid;
};
@ -165,69 +138,23 @@ namespace __gnu_profile
~__trace_vector_to_list() { }
// Insert a new node at construct with object, callstack and initial size.
void
__insert(__object_t __obj, __stack_t __stack)
{ __add_object(__obj, __vector2list_info(__stack)); }
// Call at destruction/clean to set container final size.
void
__destruct(const void* __obj)
__destruct(__vector2list_info* __obj_info)
{
if (!__is_on())
return;
float __vc = __vector_cost(__obj_info->__shift_count(),
__obj_info->__iterate(),
__obj_info->__resize());
float __lc = __list_cost(__obj_info->__shift_count(),
__obj_info->__iterate(),
__obj_info->__resize());
__obj_info->__set_vector_cost(__vc);
__obj_info->__set_list_cost(__lc);
__vector2list_info* __res = __get_object_info(__obj);
if (!__res)
return;
float __vc = __vector_cost(__res->__shift_count(), __res->__iterate(),
__res->__resize());
float __lc = __list_cost(__res->__shift_count(), __res->__iterate(),
__res->__resize());
__res->__set_vector_cost(__vc);
__res->__set_list_cost(__lc);
__retire_object(__obj);
__retire_object(__obj_info);
}
// Find the node in the live map.
// XXX Undefined?!?
__vector2list_info* __find(const void* __obj);
// Collect cost of operations.
void
__opr_insert(const void* __obj, std::size_t __pos, std::size_t __num)
{
__vector2list_info* __res = __get_object_info(__obj);
if (__res)
__res->__opr_insert(__pos, __num);
}
void
__opr_iterate(const void* __obj, std::size_t __num)
{
__vector2list_info* __res = __get_object_info(__obj);
if (__res)
__res->__opr_iterate(__num);
}
void
__invalid_operator(const void* __obj)
{
__vector2list_info* __res = __get_object_info(__obj);
if (__res)
__res->__set_invalid();
}
void
__resize(const void* __obj, std::size_t __from, std::size_t __to)
{
__vector2list_info* __res = __get_object_info(__obj);
if (__res)
__res->__resize(__from, __to);
}
float
__vector_cost(std::size_t __shift, std::size_t __iterate,
std::size_t __resize)
@ -251,14 +178,6 @@ namespace __gnu_profile
+ __resize
* _GLIBCXX_PROFILE_DATA(__list_resize_cost_factor).__value);
}
void
__opr_find(const void* __obj, std::size_t __size)
{
__vector2list_info* __res = __get_object_info(__obj);
if (__res)
__res->__opr_find(__size);
}
};
@ -266,81 +185,76 @@ namespace __gnu_profile
__trace_vector_to_list_init()
{ _GLIBCXX_PROFILE_DATA(_S_vector_to_list) = new __trace_vector_to_list(); }
inline void
__trace_vector_to_list_free()
{ delete _GLIBCXX_PROFILE_DATA(_S_vector_to_list); }
inline void
__trace_vector_to_list_report(FILE* __f, __warning_vector_t& __warnings)
{
if (_GLIBCXX_PROFILE_DATA(_S_vector_to_list))
{
_GLIBCXX_PROFILE_DATA(_S_vector_to_list)->
__collect_warnings(__warnings);
_GLIBCXX_PROFILE_DATA(_S_vector_to_list)->__write(__f);
}
}
{ __trace_report(_GLIBCXX_PROFILE_DATA(_S_vector_to_list), __f, __warnings); }
inline void
__trace_vector_to_list_construct(const void* __obj)
inline __vector2list_info*
__trace_vector_to_list_construct()
{
if (!__profcxx_init())
return;
return 0;
_GLIBCXX_PROFILE_DATA(_S_vector_to_list)->__insert(__obj, __get_stack());
if (!__reentrance_guard::__get_in())
return 0;
__reentrance_guard __get_out;
return _GLIBCXX_PROFILE_DATA(_S_vector_to_list)
->__add_object(__get_stack());
}
inline void
__trace_vector_to_list_destruct(const void* __obj)
{
if (!__profcxx_init())
return;
_GLIBCXX_PROFILE_DATA(_S_vector_to_list)->__destruct(__obj);
}
inline void
__trace_vector_to_list_insert(const void* __obj, std::size_t __pos,
__trace_vector_to_list_insert(__vector2list_info* __obj_info,
std::size_t __pos,
std::size_t __num)
{
if (!__profcxx_init())
if (!__obj_info)
return;
_GLIBCXX_PROFILE_DATA(_S_vector_to_list)->__opr_insert(__obj, __pos,
__num);
__obj_info->__opr_insert(__pos, __num);
}
inline void
__trace_vector_to_list_iterate(const void* __obj, std::size_t __num = 1)
__trace_vector_to_list_iterate(__vector2list_info* __obj_info, int)
{
if (!__profcxx_init())
if (!__obj_info)
return;
_GLIBCXX_PROFILE_DATA(_S_vector_to_list)->__opr_iterate(__obj, __num);
// We only collect if an iteration took place no matter in what side.
__obj_info->__opr_iterate(1);
}
inline void
__trace_vector_to_list_invalid_operator(const void* __obj)
__trace_vector_to_list_invalid_operator(__vector2list_info* __obj_info)
{
if (!__profcxx_init())
if (!__obj_info)
return;
_GLIBCXX_PROFILE_DATA(_S_vector_to_list)->__invalid_operator(__obj);
__obj_info->__set_invalid();
}
inline void
__trace_vector_to_list_resize(const void* __obj, std::size_t __from,
__trace_vector_to_list_resize(__vector2list_info* __obj_info,
std::size_t __from,
std::size_t __to)
{
if (!__profcxx_init())
if (!__obj_info)
return;
_GLIBCXX_PROFILE_DATA(_S_vector_to_list)->__resize(__obj, __from, __to);
__obj_info->__resize(__from, __to);
}
inline void
__trace_vector_to_list_find(const void* __obj, std::size_t __size)
__trace_vector_to_list_destruct(__vector2list_info* __obj_info)
{
if (!__profcxx_init())
if (!__obj_info)
return;
_GLIBCXX_PROFILE_DATA(_S_vector_to_list)->__opr_find(__obj, __size);
_GLIBCXX_PROFILE_DATA(_S_vector_to_list)->__destruct(__obj_info);
}
} // namespace __gnu_profile

View File

@ -123,6 +123,7 @@ namespace __profile
operator=(const __iterator_tracker& __x) _GLIBCXX_NOEXCEPT
{
_M_current = __x._M_current;
_M_ds = __x._M_ds;
return *this;
}
@ -165,10 +166,6 @@ namespace __profile
return __tmp;
}
void
_M_find()
{ _M_ds->_M_profile_find(); }
const _Sequence*
_M_get_sequence() const
{ return static_cast<const _Sequence*>(_M_ds); }

View File

@ -45,29 +45,60 @@ namespace __profile
{ return *static_cast<_List*>(this); }
public:
__gnu_profile::__list2slist_info* _M_list2slist_info;
__gnu_profile::__list2vector_info* _M_list2vector_info;
_List_profile() _GLIBCXX_NOEXCEPT
{ _M_profile_construct(); }
void
_M_profile_construct() _GLIBCXX_NOEXCEPT
{
__profcxx_list_construct(&_M_conjure()); // list2slist
__profcxx_list_construct2(&_M_conjure()); // list2vector
_M_list2slist_info = __profcxx_list2slist_construct();
_M_list2vector_info = __profcxx_list2vector_construct();
}
void
_M_profile_destruct() _GLIBCXX_NOEXCEPT
{
__profcxx_list2vector_destruct(_M_list2vector_info);
_M_list2vector_info = 0;
__profcxx_list2slist_destruct(_M_list2slist_info);
_M_list2slist_info = 0;
}
void
_M_swap(_List_profile& __other)
{
std::swap(_M_list2slist_info, __other._M_list2slist_info);
std::swap(_M_list2vector_info, __other._M_list2vector_info);
}
#if __cplusplus >= 201103L
_List_profile(const _List_profile&) noexcept
: _List_profile() { }
_List_profile(_List_profile&&) noexcept
: _List_profile() { }
_List_profile(_List_profile&& __other) noexcept
: _List_profile()
{ _M_swap(__other); }
_List_profile&
operator=(const _List_profile&) = default;
operator=(const _List_profile&) noexcept
{
_M_profile_destruct();
_M_profile_construct();
}
_List_profile&
operator=(_List_profile&&) = default;
operator=(_List_profile&& __other) noexcept
{
_M_swap(__other);
__other._M_profile_destruct();
__other._M_profile_construct();
}
#endif
~_List_profile()
{
__profcxx_list_destruct(&_M_conjure());
__profcxx_list_destruct2(&_M_conjure());
}
{ _M_profile_destruct(); }
};
/** @brief List wrapper with performance instrumentation. */
@ -152,7 +183,9 @@ namespace __profile
list&
operator=(const list& __x)
{
this->_M_profile_destruct();
_M_base() = __x;
this->_M_profile_construct();
return *this;
}
#else
@ -165,7 +198,9 @@ namespace __profile
list&
operator=(initializer_list<value_type> __l)
{
this->_M_profile_destruct();
_M_base() = __l;
this->_M_profile_construct();
return *this;
}
#endif
@ -182,28 +217,28 @@ namespace __profile
iterator
end() _GLIBCXX_NOEXCEPT
{
__profcxx_list_rewind(this);
__profcxx_list2slist_rewind(this->_M_list2slist_info);
return iterator(_Base::end(), this);
}
const_iterator
end() const _GLIBCXX_NOEXCEPT
{
__profcxx_list_rewind(this);
__profcxx_list2slist_rewind(this->_M_list2slist_info);
return const_iterator(_Base::end(), this);
}
reverse_iterator
rbegin() _GLIBCXX_NOEXCEPT
{
__profcxx_list_rewind(this);
__profcxx_list2slist_rewind(this->_M_list2slist_info);
return reverse_iterator(end());
}
const_reverse_iterator
rbegin() const _GLIBCXX_NOEXCEPT
{
__profcxx_list_rewind(this);
__profcxx_list2slist_rewind(this->_M_list2slist_info);
return const_reverse_iterator(end());
}
@ -237,14 +272,14 @@ namespace __profile
reference
back() _GLIBCXX_NOEXCEPT
{
__profcxx_list_rewind(this);
__profcxx_list2slist_rewind(this->_M_list2slist_info);
return _Base::back();
}
const_reference
back() const _GLIBCXX_NOEXCEPT
{
__profcxx_list_rewind(this);
__profcxx_list2slist_rewind(this->_M_list2slist_info);
return _Base::back();
}
@ -252,15 +287,15 @@ namespace __profile
void
push_front(const value_type& __x)
{
__profcxx_list_invalid_operator(this);
__profcxx_list_operation(this);
__profcxx_list2vector_invalid_operator(this->_M_list2vector_info);
__profcxx_list2slist_operation(this->_M_list2slist_info);
_Base::push_front(__x);
}
void
pop_front() _GLIBCXX_NOEXCEPT
{
__profcxx_list_operation(this);
__profcxx_list2slist_operation(this->_M_list2slist_info);
_Base::pop_front();
}
@ -268,7 +303,7 @@ namespace __profile
pop_back() _GLIBCXX_NOEXCEPT
{
_Base::pop_back();
__profcxx_list_rewind(this);
__profcxx_list2slist_rewind(this->_M_list2slist_info);
}
#if __cplusplus >= 201103L
@ -284,45 +319,45 @@ namespace __profile
iterator
#if __cplusplus >= 201103L
insert(const_iterator __position, const _Tp& __x)
insert(const_iterator __pos, const _Tp& __x)
#else
insert(iterator __position, const _Tp& __x)
insert(iterator __pos, const _Tp& __x)
#endif
{
_M_profile_insert(this, __position, this->size());
return iterator(_Base::insert(__position.base(), __x), this);
_M_profile_insert(__pos, this->size());
return iterator(_Base::insert(__pos.base(), __x), this);
}
#if __cplusplus >= 201103L
iterator
insert(const_iterator __position, _Tp&& __x)
insert(const_iterator __pos, _Tp&& __x)
{
_M_profile_insert(this, __position, this->size());
return iterator(_Base::emplace(__position.base(), std::move(__x)),
_M_profile_insert(__pos, this->size());
return iterator(_Base::emplace(__pos.base(), std::move(__x)),
this);
}
iterator
insert(const_iterator __position, initializer_list<value_type> __l)
insert(const_iterator __pos, initializer_list<value_type> __l)
{
_M_profile_insert(this, __position, this->size());
return iterator(_Base::insert(__position.base(), __l), this);
_M_profile_insert(__pos, this->size());
return iterator(_Base::insert(__pos.base(), __l), this);
}
#endif
#if __cplusplus >= 201103L
iterator
insert(const_iterator __position, size_type __n, const _Tp& __x)
insert(const_iterator __pos, size_type __n, const _Tp& __x)
{
_M_profile_insert(this, __position, this->size());
return iterator(_Base::insert(__position.base(), __n, __x), this);
_M_profile_insert(__pos, this->size());
return iterator(_Base::insert(__pos.base(), __n, __x), this);
}
#else
void
insert(iterator __position, size_type __n, const _Tp& __x)
insert(iterator __pos, size_type __n, const _Tp& __x)
{
_M_profile_insert(this, __position, this->size());
_Base::insert(__position.base(), __n, __x);
_M_profile_insert(__pos, this->size());
_Base::insert(__pos.base(), __n, __x);
}
#endif
@ -330,42 +365,42 @@ namespace __profile
template<typename _InputIterator,
typename = std::_RequireInputIter<_InputIterator>>
iterator
insert(const_iterator __position, _InputIterator __first,
insert(const_iterator __pos, _InputIterator __first,
_InputIterator __last)
{
_M_profile_insert(this, __position, this->size());
return iterator(_Base::insert(__position.base(), __first, __last),
_M_profile_insert(__pos, this->size());
return iterator(_Base::insert(__pos.base(), __first, __last),
this);
}
#else
template<class _InputIterator>
void
insert(iterator __position, _InputIterator __first,
insert(iterator __pos, _InputIterator __first,
_InputIterator __last)
{
_M_profile_insert(this, __position, this->size());
_Base::insert(__position.base(), __first, __last);
_M_profile_insert(__pos, this->size());
_Base::insert(__pos.base(), __first, __last);
}
#endif
iterator
#if __cplusplus >= 201103L
erase(const_iterator __position) noexcept
erase(const_iterator __pos) noexcept
#else
erase(iterator __position)
erase(iterator __pos)
#endif
{ return iterator(_Base::erase(__position.base()), this); }
{ return iterator(_Base::erase(__pos.base()), this); }
iterator
#if __cplusplus >= 201103L
erase(const_iterator __position, const_iterator __last) noexcept
erase(const_iterator __pos, const_iterator __last) noexcept
#else
erase(iterator __position, iterator __last)
erase(iterator __pos, iterator __last)
#endif
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 151. can't currently clear() empty container
return iterator(_Base::erase(__position.base(), __last.base()), this);
return iterator(_Base::erase(__pos.base(), __last.base()), this);
}
void
@ -373,60 +408,71 @@ namespace __profile
#if __cplusplus >= 201103L
noexcept( noexcept(declval<_Base>().swap(__x)) )
#endif
{ _Base::swap(__x); }
{
_Base::swap(__x);
this->_M_swap(__x);
}
void
clear() _GLIBCXX_NOEXCEPT
{
this->_M_profile_destruct();
_Base::clear();
this->_M_profile_construct();
}
// 23.2.2.4 list operations:
void
#if __cplusplus >= 201103L
splice(const_iterator __position, list&& __x) noexcept
splice(const_iterator __pos, list&& __x) noexcept
#else
splice(iterator __position, list& __x)
splice(iterator __pos, list& __x)
#endif
{ this->splice(__position, _GLIBCXX_MOVE(__x), __x.begin(), __x.end()); }
{ this->splice(__pos, _GLIBCXX_MOVE(__x), __x.begin(), __x.end()); }
#if __cplusplus >= 201103L
void
splice(const_iterator __position, list& __x) noexcept
{ this->splice(__position, std::move(__x)); }
splice(const_iterator __pos, list& __x) noexcept
{ this->splice(__pos, std::move(__x)); }
void
splice(const_iterator __position, list& __x, const_iterator __i)
{ this->splice(__position, std::move(__x), __i); }
splice(const_iterator __pos, list& __x, const_iterator __i)
{ this->splice(__pos, std::move(__x), __i); }
#endif
void
#if __cplusplus >= 201103L
splice(const_iterator __position, list&& __x, const_iterator __i) noexcept
splice(const_iterator __pos, list&& __x, const_iterator __i) noexcept
#else
splice(iterator __position, list& __x, iterator __i)
splice(iterator __pos, list& __x, iterator __i)
#endif
{
// We used to perform the splice_alloc check: not anymore, redundant
// after implementing the relevant bits of N1599.
// _GLIBCXX_RESOLVE_LIB_DEFECTS
_Base::splice(__position.base(), _GLIBCXX_MOVE(__x._M_base()),
_Base::splice(__pos.base(), _GLIBCXX_MOVE(__x._M_base()),
__i.base());
}
void
#if __cplusplus >= 201103L
splice(const_iterator __position, list&& __x, const_iterator __first,
splice(const_iterator __pos, list&& __x, const_iterator __first,
const_iterator __last) noexcept
#else
splice(iterator __position, list& __x, iterator __first,
splice(iterator __pos, list& __x, iterator __first,
iterator __last)
#endif
{
_Base::splice(__position.base(), _GLIBCXX_MOVE(__x._M_base()),
_Base::splice(__pos.base(), _GLIBCXX_MOVE(__x._M_base()),
__first.base(), __last.base());
}
#if __cplusplus >= 201103L
void
splice(const_iterator __position, list& __x,
splice(const_iterator __pos, list& __x,
const_iterator __first, const_iterator __last) noexcept
{ this->splice(__position, std::move(__x), __first, __last); }
{ this->splice(__pos, std::move(__x), __first, __last); }
#endif
void
@ -447,7 +493,7 @@ namespace __profile
{
for (iterator __x = begin(); __x != end(); )
{
__profcxx_list_operation(this);
__profcxx_list2slist_operation(this->_M_list2slist_info);
if (__pred(*__x))
__x = erase(__x);
else
@ -465,7 +511,7 @@ namespace __profile
iterator __next = __first;
while (++__next != __last)
{
__profcxx_list_operation(this);
__profcxx_list2slist_operation(this->_M_list2slist_info);
if (*__first == *__next)
erase(__next);
else
@ -485,7 +531,7 @@ namespace __profile
iterator __next = __first;
while (++__next != __last)
{
__profcxx_list_operation(this);
__profcxx_list2slist_operation(this->_M_list2slist_info);
if (__binary_pred(*__first, *__next))
erase(__next);
else
@ -530,28 +576,25 @@ namespace __profile
const _Base&
_M_base() const _GLIBCXX_NOEXCEPT { return *this; }
void _M_profile_find() const
{ }
void _M_profile_iterate(int __rewind = 0) const
{
__profcxx_list_operation(this);
__profcxx_list_iterate(this);
__profcxx_list2slist_operation(this->_M_list2slist_info);
__profcxx_list2vector_iterate(this->_M_list2vector_info, __rewind);
if (__rewind)
__profcxx_list_rewind(this);
__profcxx_list2slist_rewind(this->_M_list2slist_info);
}
private:
size_type
_M_profile_insert(void* obj, const_iterator __pos, size_type __size)
_M_profile_insert(const_iterator __pos, size_type __size)
{
size_type __shift = 0;
typename _Base::const_iterator __it = __pos.base();
for (; __it != _Base::end(); ++__it)
__shift++;
__profcxx_list_rewind(this);
__profcxx_list_operation(this);
__profcxx_list_insert(this, __shift, __size);
__profcxx_list2slist_rewind(this->_M_list2slist_info);
__profcxx_list2slist_operation(this->_M_list2slist_info);
__profcxx_list2vector_insert(this->_M_list2vector_info, __shift, __size);
}
};

View File

@ -44,6 +44,9 @@ namespace __profile
{
typedef _GLIBCXX_STD_C::map<_Key, _Tp, _Compare, _Allocator> _Base;
typedef typename _Base::iterator _Base_iterator;
typedef typename _Base::const_iterator _Base_const_iterator;
public:
// types:
typedef _Key key_type;
@ -53,12 +56,14 @@ namespace __profile
typedef typename _Base::reference reference;
typedef typename _Base::const_reference const_reference;
typedef typename _Base::iterator iterator;
typedef typename _Base::const_iterator const_iterator;
typedef __iterator_tracker<_Base_iterator, map> iterator;
typedef __iterator_tracker<_Base_const_iterator,
map> const_iterator;
typedef std::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
typedef typename _Base::size_type size_type;
typedef typename _Base::difference_type difference_type;
typedef typename _Base::reverse_iterator reverse_iterator;
typedef typename _Base::const_reverse_iterator const_reverse_iterator;
// 23.3.1.1 construct/copy/destroy:
@ -125,7 +130,9 @@ namespace __profile
map&
operator=(const map& __x)
{
this->_M_profile_destruct();
_M_base() = __x;
this->_M_profile_construct();
return *this;
}
#else
@ -138,52 +145,81 @@ namespace __profile
map&
operator=(initializer_list<value_type> __l)
{
this->_M_profile_destruct();
_M_base() = __l;
this->_M_profile_construct();
return *this;
}
#endif
// iterators
iterator
begin() _GLIBCXX_NOEXCEPT
{ return iterator(_Base::begin(), this); }
const_iterator
begin() const _GLIBCXX_NOEXCEPT
{ return const_iterator(_Base::begin(), this); }
iterator
end() _GLIBCXX_NOEXCEPT
{ return iterator(_Base::end(), this); }
const_iterator
end() const _GLIBCXX_NOEXCEPT
{ return const_iterator(_Base::end(), this); }
#if __cplusplus >= 201103L
const_iterator
cbegin() const noexcept
{ return const_iterator(_Base::cbegin(), this); }
const_iterator
cend() const noexcept
{ return const_iterator(_Base::cend(), this); }
#endif
reverse_iterator
rbegin() _GLIBCXX_NOEXCEPT
{
__profcxx_map_to_unordered_map_invalidate(this);
return _Base::rbegin();
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return reverse_iterator(end());
}
const_reverse_iterator
rbegin() const _GLIBCXX_NOEXCEPT
{
__profcxx_map_to_unordered_map_invalidate(this);
return _Base::rbegin();
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return const_reverse_iterator(end());
}
reverse_iterator
rend() _GLIBCXX_NOEXCEPT
{
__profcxx_map_to_unordered_map_invalidate(this);
return _Base::rend();
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return reverse_iterator(begin());
}
const_reverse_iterator
rend() const _GLIBCXX_NOEXCEPT
{
__profcxx_map_to_unordered_map_invalidate(this);
return _Base::rend();
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return const_reverse_iterator(begin());
}
#if __cplusplus >= 201103L
const_reverse_iterator
crbegin() const noexcept
{
__profcxx_map_to_unordered_map_invalidate(this);
return _Base::crbegin();
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return const_reverse_iterator(cend());
}
const_reverse_iterator
crend() const noexcept
{
__profcxx_map_to_unordered_map_invalidate(this);
return _Base::crend();
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return const_reverse_iterator(cbegin());
}
#endif
@ -191,7 +227,7 @@ namespace __profile
mapped_type&
operator[](const key_type& __k)
{
__profcxx_map_to_unordered_map_find(this, this->size());
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
return _Base::operator[](__k);
}
@ -199,7 +235,7 @@ namespace __profile
mapped_type&
operator[](key_type&& __k)
{
__profcxx_map_to_unordered_map_find(this, this->size());
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
return _Base::operator[](std::move(__k));
}
#endif
@ -207,14 +243,14 @@ namespace __profile
mapped_type&
at(const key_type& __k)
{
__profcxx_map_to_unordered_map_find(this, this->size());
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
return _Base::at(__k);
}
const mapped_type&
at(const key_type& __k) const
{
__profcxx_map_to_unordered_map_find(this, this->size());
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
return _Base::at(__k);
}
@ -226,8 +262,10 @@ namespace __profile
{
// The cost is the same whether or not the element is inserted so we
// always report insertion of 1 element.
__profcxx_map_to_unordered_map_insert(this, this->size(), 1);
return _Base::emplace(std::forward<_Args>(__args)...);
__profcxx_map2umap_insert(this->_M_map2umap_info, this->size(), 1);
auto __base_ret = _Base::emplace(std::forward<_Args>(__args)...);
return std::make_pair(iterator(__base_ret.first, this),
__base_ret.second);
}
template<typename... _Args>
@ -235,18 +273,21 @@ namespace __profile
emplace_hint(const_iterator __pos, _Args&&... __args)
{
auto size_before = this->size();
auto __res = _Base::emplace_hint(__pos, std::forward<_Args>(__args)...);
__profcxx_map_to_unordered_map_insert(this, size_before,
_M_hint_used(__pos, __res) ? 0 : 1);
return __res;
auto __res
= _Base::emplace_hint(__pos.base(), std::forward<_Args>(__args)...);
__profcxx_map2umap_insert(this->_M_map2umap_info,
size_before, _M_hint_used(__pos.base(), __res) ? 0 : 1);
return iterator(__res, this);
}
#endif
std::pair<iterator, bool>
insert(const value_type& __x)
{
__profcxx_map_to_unordered_map_insert(this, this->size(), 1);
return _Base::insert(__x);
__profcxx_map2umap_insert(this->_M_map2umap_info, this->size(), 1);
std::pair<_Base_iterator, bool> __base_ret = _Base::insert(__x);
return std::make_pair(iterator(__base_ret.first, this),
__base_ret.second);
}
#if __cplusplus >= 201103L
@ -256,8 +297,10 @@ namespace __profile
std::pair<iterator, bool>
insert(_Pair&& __x)
{
__profcxx_map_to_unordered_map_insert(this, this->size(), 1);
return _Base::insert(std::forward<_Pair>(__x));
__profcxx_map2umap_insert(this->_M_map2umap_info, this->size(), 1);
auto __base_ret= _Base::insert(std::forward<_Pair>(__x));
return std::make_pair(iterator(__base_ret.first, this),
__base_ret.second);
}
#endif
@ -275,11 +318,11 @@ namespace __profile
#endif
{
size_type size_before = this->size();
iterator __res = _Base::insert(__pos, __x);
_Base_iterator __res = _Base::insert(__pos.base(), __x);
__profcxx_map_to_unordered_map_insert(this, size_before,
_M_hint_used(__pos, __res) ? 0 : 1);
return __res;
__profcxx_map2umap_insert(this->_M_map2umap_info,
size_before, _M_hint_used(__pos.base(), __res) ? 0 : 1);
return iterator(__res, this);
}
#if __cplusplus >= 201103L
@ -290,20 +333,15 @@ namespace __profile
insert(const_iterator __pos, _Pair&& __x)
{
size_type size_before = this->size();
auto __res = _Base::insert(__pos, std::forward<_Pair>(__x));
auto __res = _Base::insert(__pos.base(), std::forward<_Pair>(__x));
__profcxx_map_to_unordered_map_insert(this, size_before,
_M_hint_used(__pos, __res) ? 0 : 1);
return __res;
__profcxx_map2umap_insert(this->_M_map2umap_info,
size_before, _M_hint_used(__pos.base(), __res) ? 0 : 1);
return iterator(__res, this);
}
#endif
#if __cplusplus >= 201103L
template<typename _InputIterator,
typename = std::_RequireInputIter<_InputIterator>>
#else
template<typename _InputIterator>
#endif
void
insert(_InputIterator __first, _InputIterator __last)
{
@ -313,32 +351,32 @@ namespace __profile
#if __cplusplus >= 201103L
iterator
erase(const_iterator __position)
erase(const_iterator __pos)
{
__profcxx_map_to_unordered_map_erase(this, this->size(), 1);
return _Base::erase(__position);
__profcxx_map2umap_erase(this->_M_map2umap_info, this->size(), 1);
return iterator(_Base::erase(__pos.base()), this);
}
iterator
erase(iterator __position)
erase(iterator __pos)
{
__profcxx_map_to_unordered_map_erase(this, this->size(), 1);
return _Base::erase(__position);
__profcxx_map2umap_erase(this->_M_map2umap_info, this->size(), 1);
return iterator(_Base::erase(__pos.base()), this);
}
#else
void
erase(iterator __position)
erase(iterator __pos)
{
__profcxx_map_to_unordered_map_erase(this, this->size(), 1);
_Base::erase(__position);
__profcxx_map2umap_erase(this->_M_map2umap_info, this->size(), 1);
_Base::erase(__pos.base());
}
#endif
size_type
erase(const key_type& __x)
{
__profcxx_map_to_unordered_map_find(this, this->size());
__profcxx_map_to_unordered_map_erase(this, this->size(), 1);
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
__profcxx_map2umap_erase(this->_M_map2umap_info, this->size(), 1);
return _Base::erase(__x);
}
@ -354,7 +392,7 @@ namespace __profile
return __ret;
}
else
return _Base::erase(__first, __last);
return iterator(_Base::erase(__first.base(), __last.base()), this);
}
#else
void
@ -370,74 +408,91 @@ namespace __profile
#if __cplusplus >= 201103L
noexcept( noexcept(declval<_Base>().swap(__x)) )
#endif
{ _Base::swap(__x); }
{
_Base::swap(__x);
this->_M_swap(__x);
}
void
clear() _GLIBCXX_NOEXCEPT
{
this->_M_profile_destruct();
_Base::clear();
this->_M_profile_construct();
}
// 23.3.1.3 map operations:
iterator
find(const key_type& __x)
{
__profcxx_map_to_unordered_map_find(this, this->size());
return _Base::find(__x);
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
return iterator(_Base::find(__x), this);
}
const_iterator
find(const key_type& __x) const
{
__profcxx_map_to_unordered_map_find(this, this->size());
return _Base::find(__x);
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
return const_iterator(_Base::find(__x), this);
}
size_type
count(const key_type& __x) const
{
__profcxx_map_to_unordered_map_find(this, this->size());
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
return _Base::count(__x);
}
iterator
lower_bound(const key_type& __x)
{
__profcxx_map_to_unordered_map_find(this, this->size());
__profcxx_map_to_unordered_map_invalidate(this);
return _Base::lower_bound(__x);
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return iterator(_Base::lower_bound(__x), this);
}
const_iterator
lower_bound(const key_type& __x) const
{
__profcxx_map_to_unordered_map_find(this, this->size());
__profcxx_map_to_unordered_map_invalidate(this);
return _Base::lower_bound(__x);
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return const_iterator(_Base::lower_bound(__x), this);
}
iterator
upper_bound(const key_type& __x)
{
__profcxx_map_to_unordered_map_find(this, this->size());
__profcxx_map_to_unordered_map_invalidate(this);
return _Base::upper_bound(__x);
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return iterator(_Base::upper_bound(__x), this);
}
const_iterator
upper_bound(const key_type& __x) const
{
__profcxx_map_to_unordered_map_find(this, this->size());
__profcxx_map_to_unordered_map_invalidate(this);
return _Base::upper_bound(__x);
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return const_iterator(_Base::upper_bound(__x), this);
}
std::pair<iterator,iterator>
equal_range(const key_type& __x)
{
__profcxx_map_to_unordered_map_find(this, this->size());
return _Base::equal_range(__x);
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
std::pair<_Base_iterator, _Base_iterator> __base_ret
= _Base::equal_range(__x);
return std::make_pair(iterator(__base_ret.first, this),
iterator(__base_ret.second, this));
}
std::pair<const_iterator,const_iterator>
equal_range(const key_type& __x) const
{
__profcxx_map_to_unordered_map_find(this, this->size());
return _Base::equal_range(__x);
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
std::pair<_Base_const_iterator, _Base_const_iterator> __base_ret
= _Base::equal_range(__x);
return std::make_pair(const_iterator(__base_ret.first, this),
const_iterator(__base_ret.second, this));
}
_Base&
@ -454,13 +509,24 @@ namespace __profile
* implementation dependent.
*/
bool
_M_hint_used(const_iterator __hint, iterator __res)
_M_hint_used(_Base_const_iterator __hint, _Base_iterator __res)
{
return (__hint == __res
|| (__hint == this->end() && ++__res == this->end())
|| (__hint != this->end() && (++__hint == __res
|| ++__res == --__hint)));
|| (__hint == _M_base().end() && ++__res == _M_base().end())
|| (__hint != _M_base().end() && (++__hint == __res
|| ++__res == --__hint)));
}
template<typename _K1, typename _T1, typename _C1, typename _A1>
friend bool
operator==(const map<_K1, _T1, _C1, _A1>&,
const map<_K1, _T1, _C1, _A1>&);
template<typename _K1, typename _T1, typename _C1, typename _A1>
friend bool
operator<(const map<_K1, _T1, _C1, _A1>&,
const map<_K1, _T1, _C1, _A1>&);
};
template<typename _Key, typename _Tp,
@ -469,65 +535,49 @@ namespace __profile
operator==(const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
{
__profcxx_map_to_unordered_map_invalidate(&__lhs);
__profcxx_map_to_unordered_map_invalidate(&__rhs);
__profcxx_map2umap_invalidate(__lhs._M_map2umap_info);
__profcxx_map2umap_invalidate(__rhs._M_map2umap_info);
return __lhs._M_base() == __rhs._M_base();
}
template<typename _Key, typename _Tp,
typename _Compare, typename _Allocator>
inline bool
operator!=(const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
{
__profcxx_map_to_unordered_map_invalidate(&__lhs);
__profcxx_map_to_unordered_map_invalidate(&__rhs);
return __lhs._M_base() != __rhs._M_base();
}
template<typename _Key, typename _Tp,
typename _Compare, typename _Allocator>
inline bool
operator<(const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
{
__profcxx_map_to_unordered_map_invalidate(&__lhs);
__profcxx_map_to_unordered_map_invalidate(&__rhs);
__profcxx_map2umap_invalidate(__lhs._M_map2umap_info);
__profcxx_map2umap_invalidate(__rhs._M_map2umap_info);
return __lhs._M_base() < __rhs._M_base();
}
template<typename _Key, typename _Tp,
typename _Compare, typename _Allocator>
inline bool
operator!=(const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
{ return !(__lhs == __rhs); }
template<typename _Key, typename _Tp,
typename _Compare, typename _Allocator>
inline bool
operator<=(const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
{
__profcxx_map_to_unordered_map_invalidate(&__lhs);
__profcxx_map_to_unordered_map_invalidate(&__rhs);
return __lhs._M_base() <= __rhs._M_base();
}
{ return !(__rhs < __lhs); }
template<typename _Key, typename _Tp,
typename _Compare, typename _Allocator>
inline bool
operator>=(const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
{
__profcxx_map_to_unordered_map_invalidate(&__lhs);
__profcxx_map_to_unordered_map_invalidate(&__rhs);
return __lhs._M_base() >= __rhs._M_base();
}
{ return !(__lhs < __rhs); }
template<typename _Key, typename _Tp,
typename _Compare, typename _Allocator>
inline bool
operator>(const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
{
__profcxx_map_to_unordered_map_invalidate(&__lhs);
__profcxx_map_to_unordered_map_invalidate(&__rhs);
return __lhs._M_base() > __rhs._M_base();
}
{ return __rhs < __lhs; }
template<typename _Key, typename _Tp,
typename _Compare, typename _Allocator>

View File

@ -45,6 +45,9 @@ namespace __profile
{
typedef _GLIBCXX_STD_C::multimap<_Key, _Tp, _Compare, _Allocator> _Base;
typedef typename _Base::iterator _Base_iterator;
typedef typename _Base::const_iterator _Base_const_iterator;
public:
// types:
typedef _Key key_type;
@ -54,15 +57,15 @@ namespace __profile
typedef typename _Base::reference reference;
typedef typename _Base::const_reference const_reference;
typedef typename _Base::iterator iterator;
typedef typename _Base::const_iterator const_iterator;
typedef typename _Base::reverse_iterator reverse_iterator;
typedef typename _Base::const_reverse_iterator const_reverse_iterator;
typedef __iterator_tracker<_Base_iterator,
multimap> iterator;
typedef __iterator_tracker<_Base_const_iterator,
multimap> const_iterator;
typedef std::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
typedef typename _Base::size_type size_type;
typedef typename _Base::difference_type difference_type;
typedef typename _Base::pointer pointer;
typedef typename _Base::const_pointer const_pointer;
// 23.3.1.1 construct/copy/destroy:
@ -127,7 +130,9 @@ namespace __profile
multimap&
operator=(const multimap& __x)
{
this->_M_profile_destruct();
_M_base() = __x;
this->_M_profile_construct();
return *this;
}
#else
@ -140,52 +145,81 @@ namespace __profile
multimap&
operator=(initializer_list<value_type> __l)
{
this->_M_profile_destruct();
_M_base() = __l;
this->_M_profile_construct();
return *this;
}
#endif
// iterators
iterator
begin() _GLIBCXX_NOEXCEPT
{ return iterator(_Base::begin(), this); }
const_iterator
begin() const _GLIBCXX_NOEXCEPT
{ return const_iterator(_Base::begin(), this); }
iterator
end() _GLIBCXX_NOEXCEPT
{ return iterator(_Base::end(), this); }
const_iterator
end() const _GLIBCXX_NOEXCEPT
{ return const_iterator(_Base::end(), this); }
#if __cplusplus >= 201103L
const_iterator
cbegin() const noexcept
{ return const_iterator(_Base::cbegin(), this); }
const_iterator
cend() const noexcept
{ return const_iterator(_Base::cend(), this); }
#endif
reverse_iterator
rbegin() _GLIBCXX_NOEXCEPT
{
__profcxx_map_to_unordered_map_invalidate(this);
return _Base::rbegin();
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return reverse_iterator(end());
}
const_reverse_iterator
rbegin() const _GLIBCXX_NOEXCEPT
{
__profcxx_map_to_unordered_map_invalidate(this);
return _Base::rbegin();
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return const_reverse_iterator(end());
}
reverse_iterator
rend() _GLIBCXX_NOEXCEPT
{
__profcxx_map_to_unordered_map_invalidate(this);
return _Base::rend();
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return reverse_iterator(begin());
}
const_reverse_iterator
rend() const _GLIBCXX_NOEXCEPT
{
__profcxx_map_to_unordered_map_invalidate(this);
return _Base::rend();
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return const_reverse_iterator(begin());
}
#if __cplusplus >= 201103L
const_reverse_iterator
crbegin() const noexcept
{
__profcxx_map_to_unordered_map_invalidate(this);
return _Base::crbegin();
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return const_reverse_iterator(cend());
}
const_reverse_iterator
crend() const noexcept
{
__profcxx_map_to_unordered_map_invalidate(this);
return _Base::crend();
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return const_reverse_iterator(cbegin());
}
#endif
@ -195,8 +229,8 @@ namespace __profile
iterator
emplace(_Args&&... __args)
{
__profcxx_map_to_unordered_map_insert(this, this->size(), 1);
return _Base::emplace(std::forward<_Args>(__args)...);
__profcxx_map2umap_insert(this->_M_map2umap_info, this->size(), 1);
return iterator(_Base::emplace(std::forward<_Args>(__args)...), this);
}
template<typename... _Args>
@ -205,18 +239,18 @@ namespace __profile
{
auto size_before = this->size();
auto __res
= _Base::emplace_hint(__pos, std::forward<_Args>(__args)...);
__profcxx_map_to_unordered_map_insert(this, size_before,
_M_hint_used(__pos, __res) ? 0 : 1);
return __res;
= _Base::emplace_hint(__pos.base(), std::forward<_Args>(__args)...);
__profcxx_map2umap_insert(this->_M_map2umap_info,
size_before, _M_hint_used(__pos.base(), __res) ? 0 : 1);
return iterator(__res, this);
}
#endif
iterator
insert(const value_type& __x)
{
__profcxx_map_to_unordered_map_insert(this, this->size(), 1);
return _Base::insert(__x);
__profcxx_map2umap_insert(this->_M_map2umap_info, this->size(), 1);
return iterator(_Base::insert(__x), this);
}
#if __cplusplus >= 201103L
@ -226,8 +260,8 @@ namespace __profile
iterator
insert(_Pair&& __x)
{
__profcxx_map_to_unordered_map_insert(this, this->size(), 1);
return _Base::insert(std::forward<_Pair>(__x));
__profcxx_map2umap_insert(this->_M_map2umap_info, this->size(), 1);
return iterator(_Base::insert(std::forward<_Pair>(__x)), this);
}
#endif
@ -245,10 +279,10 @@ namespace __profile
#endif
{
size_type size_before = this->size();
iterator __res = _Base::insert(__pos, __x);
__profcxx_map_to_unordered_map_insert(this, size_before,
_M_hint_used(__pos, __res) ? 0 : 1);
return __res;
_Base_iterator __res = _Base::insert(__pos.base(), __x);
__profcxx_map2umap_insert(this->_M_map2umap_info,
size_before, _M_hint_used(__pos.base(), __res) ? 0 : 1);
return iterator(__res, this);
}
#if __cplusplus >= 201103L
@ -259,19 +293,14 @@ namespace __profile
insert(const_iterator __pos, _Pair&& __x)
{
size_type size_before = this->size();
auto __res = _Base::insert(__pos, std::forward<_Pair>(__x));
__profcxx_map_to_unordered_map_insert(this, size_before,
_M_hint_used(__pos, __res) ? 0 : 1);
return __res;
auto __res = _Base::insert(__pos.base(), std::forward<_Pair>(__x));
__profcxx_map2umap_insert(this->_M_map2umap_info,
size_before, _M_hint_used(__pos.base(), __res) ? 0 : 1);
return iterator(__res, this);
}
#endif
#if __cplusplus >= 201103L
template<typename _InputIterator,
typename = std::_RequireInputIter<_InputIterator>>
#else
template<typename _InputIterator>
#endif
void
insert(_InputIterator __first, _InputIterator __last)
{
@ -283,30 +312,30 @@ namespace __profile
iterator
erase(const_iterator __pos)
{
__profcxx_map_to_unordered_map_erase(this, this->size(), 1);
return _Base::erase(__pos);
__profcxx_map2umap_erase(this->_M_map2umap_info, this->size(), 1);
return iterator(_Base::erase(__pos.base()), this);
}
iterator
erase(iterator __pos)
{
__profcxx_map_to_unordered_map_erase(this, this->size(), 1);
return _Base::erase(__pos);
__profcxx_map2umap_erase(this->_M_map2umap_info, this->size(), 1);
return iterator(_Base::erase(__pos.base()), this);
}
#else
void
erase(iterator __pos)
{
__profcxx_map_to_unordered_map_erase(this, this->size(), 1);
_Base::erase(__pos);
__profcxx_map2umap_erase(this->_M_map2umap_info, this->size(), 1);
_Base::erase(__pos.base());
}
#endif
size_type
erase(const key_type& __x)
{
__profcxx_map_to_unordered_map_find(this, this->size());
__profcxx_map_to_unordered_map_erase(this, this->size(), 1);
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
__profcxx_map2umap_erase(this->_M_map2umap_info, this->size(), 1);
return _Base::erase(__x);
}
@ -322,7 +351,7 @@ namespace __profile
return __ret;
}
else
return _Base::erase(__first, __last);
return iterator(_Base::erase(__first.base(), __last.base()), this);
}
#else
void
@ -338,74 +367,91 @@ namespace __profile
#if __cplusplus >= 201103L
noexcept( noexcept(declval<_Base>().swap(__x)) )
#endif
{ _Base::swap(__x); }
{
std::swap(this->_M_map2umap_info, __x._M_map2umap_info);
_Base::swap(__x);
}
void
clear() _GLIBCXX_NOEXCEPT
{
this->_M_profile_destruct();
_Base::clear();
this->_M_profile_construct();
}
// 23.3.1.3 multimap operations:
iterator
find(const key_type& __x)
{
__profcxx_map_to_unordered_map_find(this, this->size());
return _Base::find(__x);
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
return iterator(_Base::find(__x), this);
}
const_iterator
find(const key_type& __x) const
{
__profcxx_map_to_unordered_map_find(this, this->size());
return _Base::find(__x);
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
return const_iterator(_Base::find(__x), this);
}
size_type
count(const key_type& __x) const
{
__profcxx_map_to_unordered_map_find(this, this->size());
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
return _Base::count(__x);
}
iterator
lower_bound(const key_type& __x)
{
__profcxx_map_to_unordered_map_find(this, this->size());
__profcxx_map_to_unordered_map_invalidate(this);
return _Base::lower_bound(__x);
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return iterator(_Base::lower_bound(__x), this);
}
const_iterator
lower_bound(const key_type& __x) const
{
__profcxx_map_to_unordered_map_find(this, this->size());
__profcxx_map_to_unordered_map_invalidate(this);
return _Base::lower_bound(__x);
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return const_iterator(_Base::lower_bound(__x), this);
}
iterator
upper_bound(const key_type& __x)
{
__profcxx_map_to_unordered_map_find(this, this->size());
__profcxx_map_to_unordered_map_invalidate(this);
return _Base::upper_bound(__x);
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return iterator(_Base::upper_bound(__x), this);
}
const_iterator
upper_bound(const key_type& __x) const
{
__profcxx_map_to_unordered_map_find(this, this->size());
__profcxx_map_to_unordered_map_invalidate(this);
return _Base::upper_bound(__x);
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return const_iterator(_Base::upper_bound(__x), this);
}
std::pair<iterator,iterator>
equal_range(const key_type& __x)
{
__profcxx_map_to_unordered_map_find(this, this->size());
return _Base::equal_range(__x);
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
std::pair<_Base_iterator, _Base_iterator> __base_ret
= _Base::equal_range(__x);
return std::make_pair(iterator(__base_ret.first, this),
iterator(__base_ret.second, this));
}
std::pair<const_iterator,const_iterator>
equal_range(const key_type& __x) const
{
__profcxx_map_to_unordered_map_find(this, this->size());
return _Base::equal_range(__x);
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
std::pair<_Base_const_iterator, _Base_const_iterator> __base_ret
= _Base::equal_range(__x);
return std::make_pair(const_iterator(__base_ret.first, this),
const_iterator(__base_ret.second, this));
}
_Base&
@ -422,13 +468,23 @@ namespace __profile
* implementation dependent.
*/
bool
_M_hint_used(const_iterator __hint, iterator __res)
_M_hint_used(_Base_const_iterator __hint, _Base_iterator __res)
{
return (__hint == __res
|| (__hint == this->end() && ++__res == this->end())
|| (__hint != this->end() && (++__hint == __res
|| ++__res == --__hint)));
|| (__hint == _M_base().end() && ++__res == _M_base().end())
|| (__hint != _M_base().end() && (++__hint == __res
|| ++__res == --__hint)));
}
template<typename _K1, typename _T1, typename _C1, typename _A1>
friend bool
operator==(const multimap<_K1, _T1, _C1, _A1>&,
const multimap<_K1, _T1, _C1, _A1>&);
template<typename _K1, typename _T1, typename _C1, typename _A1>
friend bool
operator<(const multimap<_K1, _T1, _C1, _A1>&,
const multimap<_K1, _T1, _C1, _A1>&);
};
template<typename _Key, typename _Tp,
@ -436,42 +492,50 @@ namespace __profile
inline bool
operator==(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
{ return __lhs._M_base() == __rhs._M_base(); }
template<typename _Key, typename _Tp,
typename _Compare, typename _Allocator>
inline bool
operator!=(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
{ return __lhs._M_base() != __rhs._M_base(); }
{
__profcxx_map2umap_invalidate(__lhs._M_map2umap_info);
__profcxx_map2umap_invalidate(__rhs._M_map2umap_info);
return __lhs._M_base() == __rhs._M_base();
}
template<typename _Key, typename _Tp,
typename _Compare, typename _Allocator>
inline bool
operator<(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
{ return __lhs._M_base() < __rhs._M_base(); }
{
__profcxx_map2umap_invalidate(__lhs._M_map2umap_info);
__profcxx_map2umap_invalidate(__rhs._M_map2umap_info);
return __lhs._M_base() < __rhs._M_base();
}
template<typename _Key, typename _Tp,
typename _Compare, typename _Allocator>
inline bool
operator!=(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
{ return !(__lhs == __rhs); }
template<typename _Key, typename _Tp,
typename _Compare, typename _Allocator>
inline bool
operator<=(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
{ return __lhs._M_base() <= __rhs._M_base(); }
{ return !(__rhs < __lhs); }
template<typename _Key, typename _Tp,
typename _Compare, typename _Allocator>
inline bool
operator>=(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
{ return __lhs._M_base() >= __rhs._M_base(); }
{ return !(__lhs < __rhs); }
template<typename _Key, typename _Tp,
typename _Compare, typename _Allocator>
inline bool
operator>(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
{ return __lhs._M_base() > __rhs._M_base(); }
{ return __rhs < __lhs; }
template<typename _Key, typename _Tp,
typename _Compare, typename _Allocator>

View File

@ -45,6 +45,9 @@ namespace __profile
{
typedef _GLIBCXX_STD_C::multiset<_Key, _Compare, _Allocator> _Base;
typedef typename _Base::iterator _Base_iterator;
typedef typename _Base::const_iterator _Base_const_iterator;
public:
// types:
typedef _Key key_type;
@ -55,15 +58,15 @@ namespace __profile
typedef typename _Base::reference reference;
typedef typename _Base::const_reference const_reference;
typedef typename _Base::iterator iterator;
typedef typename _Base::const_iterator const_iterator;
typedef typename _Base::reverse_iterator reverse_iterator;
typedef typename _Base::const_reverse_iterator const_reverse_iterator;
typedef __iterator_tracker<_Base_iterator,
multiset> iterator;
typedef __iterator_tracker<_Base_const_iterator,
multiset> const_iterator;
typedef std::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
typedef typename _Base::size_type size_type;
typedef typename _Base::difference_type difference_type;
typedef typename _Base::pointer pointer;
typedef typename _Base::const_pointer const_pointer;
// 23.3.3.1 construct/copy/destroy:
@ -128,7 +131,9 @@ namespace __profile
multiset&
operator=(const multiset& __x)
{
this->_M_profile_destruct();
_M_base() = __x;
this->_M_profile_construct();
return *this;
}
#else
@ -141,56 +146,94 @@ namespace __profile
multiset&
operator=(initializer_list<value_type> __l)
{
this->_M_profile_destruct();
_M_base() = __l;
this->_M_profile_construct();
return *this;
}
#endif
// iterators:
// iterators
iterator
begin() _GLIBCXX_NOEXCEPT
{ return iterator(_Base::begin(), this); }
const_iterator
begin() const _GLIBCXX_NOEXCEPT
{ return const_iterator(_Base::begin(), this); }
iterator
end() _GLIBCXX_NOEXCEPT
{ return iterator(_Base::end(), this); }
const_iterator
end() const _GLIBCXX_NOEXCEPT
{ return const_iterator(_Base::end(), this); }
#if __cplusplus >= 201103L
const_iterator
cbegin() const noexcept
{ return const_iterator(_Base::cbegin(), this); }
const_iterator
cend() const noexcept
{ return const_iterator(_Base::cend(), this); }
#endif
reverse_iterator
rbegin() _GLIBCXX_NOEXCEPT
{
__profcxx_map_to_unordered_map_invalidate(this);
return _Base::rbegin();
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return reverse_iterator(end());
}
const_reverse_iterator
rbegin() const _GLIBCXX_NOEXCEPT
{
__profcxx_map_to_unordered_map_invalidate(this);
return _Base::rbegin();
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return const_reverse_iterator(end());
}
reverse_iterator
rend() _GLIBCXX_NOEXCEPT
{
__profcxx_map_to_unordered_map_invalidate(this);
return _Base::rend();
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return reverse_iterator(begin());
}
const_reverse_iterator
rend() const _GLIBCXX_NOEXCEPT
{
__profcxx_map_to_unordered_map_invalidate(this);
return _Base::rend();
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return const_reverse_iterator(begin());
}
#if __cplusplus >= 201103L
const_reverse_iterator
crbegin() const noexcept
{
__profcxx_map_to_unordered_map_invalidate(this);
return _Base::crbegin();
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return const_reverse_iterator(cend());
}
const_reverse_iterator
crend() const noexcept
{
__profcxx_map_to_unordered_map_invalidate(this);
return _Base::crend();
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return const_reverse_iterator(cbegin());
}
#endif
void
swap(multiset& __x)
#if __cplusplus >= 201103L
noexcept( noexcept(declval<_Base>().swap(__x)) )
#endif
{
_Base::swap(__x);
this->_M_swap(__x);
}
// modifiers:
#if __cplusplus >= 201103L
template<typename... _Args>
@ -199,8 +242,8 @@ namespace __profile
{
// The cost is the same whether or not the element is inserted so we
// always report insertion of 1 element.
__profcxx_map_to_unordered_map_insert(this, this->size(), 1);
return _Base::emplace(std::forward<_Args>(__args)...);
__profcxx_map2umap_insert(this->_M_map2umap_info, this->size(), 1);
return iterator(_Base::emplace(std::forward<_Args>(__args)...), this);
}
template<typename... _Args>
@ -208,26 +251,27 @@ namespace __profile
emplace_hint(const_iterator __pos, _Args&&... __args)
{
auto size_before = this->size();
auto __res = _Base::emplace_hint(__pos, std::forward<_Args>(__args)...);
__profcxx_map_to_unordered_map_insert(this, size_before,
_M_hint_used(__pos, __res) ? 0 : 1);
return __res;
auto __res
= _Base::emplace_hint(__pos.base(), std::forward<_Args>(__args)...);
__profcxx_map2umap_insert(this->_M_map2umap_info,
size_before, _M_hint_used(__pos.base(), __res) ? 0 : 1);
return iterator(__res, this);
}
#endif
iterator
insert(const value_type& __x)
{
__profcxx_map_to_unordered_map_insert(this, this->size(), 1);
return _Base::insert(__x);
__profcxx_map2umap_insert(this->_M_map2umap_info, this->size(), 1);
return iterator(_Base::insert(__x), this);
}
#if __cplusplus >= 201103L
iterator
insert(value_type&& __x)
{
__profcxx_map_to_unordered_map_insert(this, this->size(), 1);
return _Base::insert(std::move(__x));
__profcxx_map2umap_insert(this->_M_map2umap_info, this->size(), 1);
return iterator(_Base::insert(std::move(__x)), this);
}
#endif
@ -235,11 +279,11 @@ namespace __profile
insert(const_iterator __pos, const value_type& __x)
{
size_type size_before = this->size();
iterator __res = _Base::insert(__pos, __x);
_Base_iterator __res = _Base::insert(__pos.base(), __x);
__profcxx_map_to_unordered_map_insert(this, size_before,
_M_hint_used(__pos, __res) ? 0 : 1);
return __res;
__profcxx_map2umap_insert(this->_M_map2umap_info,
size_before, _M_hint_used(__pos.base(), __res) ? 0 : 1);
return iterator(__res, this);
}
#if __cplusplus >= 201103L
@ -247,10 +291,10 @@ namespace __profile
insert(const_iterator __pos, value_type&& __x)
{
auto size_before = this->size();
auto __res = _Base::insert(__pos, std::move(__x));
__profcxx_map_to_unordered_map_insert(this, size_before,
_M_hint_used(__pos, __res) ? 0 : 1);
return __res;
auto __res = _Base::insert(__pos.base(), std::move(__x));
__profcxx_map2umap_insert(this->_M_map2umap_info,
size_before, _M_hint_used(__pos.base(), __res) ? 0 : 1);
return iterator(__res, this);
}
#endif
@ -277,23 +321,23 @@ namespace __profile
iterator
erase(const_iterator __pos)
{
__profcxx_map_to_unordered_map_erase(this, this->size(), 1);
return _Base::erase(__pos);
__profcxx_map2umap_erase(this->_M_map2umap_info, this->size(), 1);
return iterator(_Base::erase(__pos.base()), this);
}
#else
void
erase(iterator __pos)
{
__profcxx_map_to_unordered_map_erase(this, this->size(), 1);
_Base::erase(__pos);
__profcxx_map2umap_erase(this->_M_map2umap_info, this->size(), 1);
_Base::erase(__pos.base());
}
#endif
size_type
erase(const key_type& __x)
{
__profcxx_map_to_unordered_map_find(this, this->size());
__profcxx_map_to_unordered_map_erase(this, this->size(), 1);
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
__profcxx_map2umap_erase(this->_M_map2umap_info, this->size(), 1);
return _Base::erase(__x);
}
@ -309,7 +353,7 @@ namespace __profile
return __ret;
}
else
return _Base::erase(__first, __last);
return iterator(_Base::erase(__first.base(), __last.base()), this);
}
#else
void
@ -321,18 +365,26 @@ namespace __profile
#endif
void
swap(multiset& __x)
#if __cplusplus >= 201103L
noexcept( noexcept(declval<_Base>().swap(__x)) )
#endif
{ _Base::swap(__x); }
clear() _GLIBCXX_NOEXCEPT
{
this->_M_profile_destruct();
_Base::clear();
this->_M_profile_construct();
}
size_type
count(const key_type& __x) const
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
return _Base::count(__x);
}
// multiset operations:
iterator
find(const key_type& __x)
{
__profcxx_map_to_unordered_map_find(this, this->size());
return _Base::find(__x);
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
return iterator(_Base::find(__x), this);
}
// _GLIBCXX_RESOLVE_LIB_DEFECTS
@ -340,22 +392,15 @@ namespace __profile
const_iterator
find(const key_type& __x) const
{
__profcxx_map_to_unordered_map_find(this, this->size());
return _Base::find(__x);
}
size_type
count(const key_type& __x) const
{
__profcxx_map_to_unordered_map_find(this, this->size());
return _Base::count(__x);
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
return const_iterator(_Base::find(__x), this);
}
iterator
lower_bound(const key_type& __x)
{
__profcxx_map_to_unordered_map_find(this, this->size());
return _Base::lower_bound(__x);
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
return iterator(_Base::lower_bound(__x), this);
}
// _GLIBCXX_RESOLVE_LIB_DEFECTS
@ -363,17 +408,17 @@ namespace __profile
const_iterator
lower_bound(const key_type& __x) const
{
__profcxx_map_to_unordered_map_find(this, this->size());
__profcxx_map_to_unordered_map_invalidate(this);
return _Base::lower_bound(__x);
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return const_iterator(_Base::lower_bound(__x), this);
}
iterator
upper_bound(const key_type& __x)
{
__profcxx_map_to_unordered_map_find(this, this->size());
__profcxx_map_to_unordered_map_invalidate(this);
return _Base::upper_bound(__x);
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return iterator(_Base::upper_bound(__x), this);
}
// _GLIBCXX_RESOLVE_LIB_DEFECTS
@ -381,16 +426,19 @@ namespace __profile
const_iterator
upper_bound(const key_type& __x) const
{
__profcxx_map_to_unordered_map_find(this, this->size());
__profcxx_map_to_unordered_map_invalidate(this);
return _Base::upper_bound(__x);
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return const_iterator(_Base::upper_bound(__x), this);
}
std::pair<iterator,iterator>
equal_range(const key_type& __x)
{
__profcxx_map_to_unordered_map_find(this, this->size());
return _Base::equal_range(__x);
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
std::pair<_Base_iterator, _Base_iterator> __base_ret
= _Base::equal_range(__x);
return std::make_pair(iterator(__base_ret.first, this),
iterator(__base_ret.second, this));
}
// _GLIBCXX_RESOLVE_LIB_DEFECTS
@ -398,8 +446,11 @@ namespace __profile
std::pair<const_iterator,const_iterator>
equal_range(const key_type& __x) const
{
__profcxx_map_to_unordered_map_find(this, this->size());
return _Base::equal_range(__x);
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
std::pair<_Base_const_iterator, _Base_const_iterator> __base_ret
= _Base::equal_range(__x);
return std::make_pair(const_iterator(__base_ret.first, this),
const_iterator(__base_ret.second, this));
}
_Base&
@ -416,50 +467,68 @@ namespace __profile
* implementation dependent.
*/
bool
_M_hint_used(const_iterator __hint, iterator __res)
_M_hint_used(_Base_const_iterator __hint, _Base_iterator __res)
{
return (__hint == __res
|| (__hint == this->end() && ++__res == this->end())
|| (__hint != this->end() && (++__hint == __res
|| ++__res == --__hint)));
|| (__hint == _M_base().end() && ++__res == _M_base().end())
|| (__hint != _M_base().end() && (++__hint == __res
|| ++__res == --__hint)));
}
template<typename _K1, typename _C1, typename _A1>
friend bool
operator==(const multiset<_K1, _C1, _A1>&,
const multiset<_K1, _C1, _A1>&);
template<typename _K1, typename _C1, typename _A1>
friend bool
operator< (const multiset<_K1, _C1, _A1>&,
const multiset<_K1, _C1, _A1>&);
};
template<typename _Key, typename _Compare, typename _Allocator>
inline bool
operator==(const multiset<_Key, _Compare, _Allocator>& __lhs,
const multiset<_Key, _Compare, _Allocator>& __rhs)
{ return __lhs._M_base() == __rhs._M_base(); }
template<typename _Key, typename _Compare, typename _Allocator>
inline bool
operator!=(const multiset<_Key, _Compare, _Allocator>& __lhs,
const multiset<_Key, _Compare, _Allocator>& __rhs)
{ return __lhs._M_base() != __rhs._M_base(); }
{
__profcxx_map2umap_invalidate(__lhs._M_map2umap_info);
__profcxx_map2umap_invalidate(__rhs._M_map2umap_info);
return __lhs._M_base() == __rhs._M_base();
}
template<typename _Key, typename _Compare, typename _Allocator>
inline bool
operator<(const multiset<_Key, _Compare, _Allocator>& __lhs,
const multiset<_Key, _Compare, _Allocator>& __rhs)
{ return __lhs._M_base() < __rhs._M_base(); }
{
__profcxx_map2umap_invalidate(__lhs._M_map2umap_info);
__profcxx_map2umap_invalidate(__rhs._M_map2umap_info);
return __lhs._M_base() < __rhs._M_base();
}
template<typename _Key, typename _Compare, typename _Allocator>
inline bool
operator!=(const multiset<_Key, _Compare, _Allocator>& __lhs,
const multiset<_Key, _Compare, _Allocator>& __rhs)
{ return !(__lhs == __rhs); }
template<typename _Key, typename _Compare, typename _Allocator>
inline bool
operator<=(const multiset<_Key, _Compare, _Allocator>& __lhs,
const multiset<_Key, _Compare, _Allocator>& __rhs)
{ return __lhs._M_base() <= __rhs._M_base(); }
{ return !(__rhs < __lhs); }
template<typename _Key, typename _Compare, typename _Allocator>
inline bool
operator>=(const multiset<_Key, _Compare, _Allocator>& __lhs,
const multiset<_Key, _Compare, _Allocator>& __rhs)
{ return __lhs._M_base() >= __rhs._M_base(); }
{ return !(__lhs < __rhs); }
template<typename _Key, typename _Compare, typename _Allocator>
inline bool
operator>(const multiset<_Key, _Compare, _Allocator>& __lhs,
const multiset<_Key, _Compare, _Allocator>& __rhs)
{ return __lhs._M_base() > __rhs._M_base(); }
{ return __rhs < __lhs; }
template<typename _Key, typename _Compare, typename _Allocator>
void

View File

@ -35,28 +35,63 @@ namespace __profile
template<typename _Cont>
class _Ordered_profile
{
_Cont&
_M_conjure()
{ return *static_cast<_Cont*>(this); }
public:
void
_M_profile_iterate(int __rewind = 0) const
{ __profcxx_map2umap_iterate(this->_M_map2umap_info, __rewind); }
protected:
_Ordered_profile() _GLIBCXX_NOEXCEPT
{ __profcxx_map_to_unordered_map_construct(&_M_conjure()); }
{ _M_profile_construct(); }
#if __cplusplus >= 201103L
_Ordered_profile(const _Ordered_profile&) noexcept
: _Ordered_profile() { }
_Ordered_profile(_Ordered_profile&&) noexcept
: _Ordered_profile() { }
_Ordered_profile(_Ordered_profile&& __other) noexcept
: _Ordered_profile()
{ _M_swap(__other); }
_Ordered_profile&
operator=(const _Ordered_profile&) = default;
operator=(const _Ordered_profile&) noexcept
{
_M_profile_destruct();
_M_profile_construct();
}
_Ordered_profile&
operator=(_Ordered_profile&&) = default;
operator=(_Ordered_profile&& __other) noexcept
{
_M_swap(__other);
__other._M_profile_destruct();
__other._M_profile_construct();
}
#endif
~_Ordered_profile()
{ __profcxx_map_to_unordered_map_destruct(&_M_conjure()); }
{ _M_profile_destruct(); }
void
_M_profile_construct() _GLIBCXX_NOEXCEPT
{ _M_map2umap_info = __profcxx_map2umap_construct(); }
void
_M_profile_destruct() _GLIBCXX_NOEXCEPT
{
__profcxx_map2umap_destruct(_M_map2umap_info);
_M_map2umap_info = 0;
}
void
_M_swap(_Ordered_profile& __other)
{ std::swap(_M_map2umap_info, __other._M_map2umap_info); }
__gnu_profile::__map2umap_info* _M_map2umap_info;
private:
_Cont&
_M_conjure()
{ return *static_cast<_Cont*>(this); }
};
} // namespace __profile

View File

@ -45,9 +45,8 @@ namespace __profile
{
typedef _GLIBCXX_STD_C::set<_Key, _Compare, _Allocator> _Base;
#if __cplusplus >= 201103L
typedef __gnu_cxx::__alloc_traits<_Allocator> _Alloc_traits;
#endif
typedef typename _Base::iterator _Base_iterator;
typedef typename _Base::const_iterator _Base_const_iterator;
public:
// types:
@ -58,15 +57,14 @@ namespace __profile
typedef typename _Base::reference reference;
typedef typename _Base::const_reference const_reference;
typedef typename _Base::iterator iterator;
typedef typename _Base::const_iterator const_iterator;
typedef typename _Base::reverse_iterator reverse_iterator;
typedef typename _Base::const_reverse_iterator const_reverse_iterator;
typedef __iterator_tracker<_Base_iterator, set> iterator;
typedef __iterator_tracker<_Base_const_iterator,
set> const_iterator;
typedef std::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
typedef typename _Base::size_type size_type;
typedef typename _Base::difference_type difference_type;
typedef typename _Base::pointer pointer;
typedef typename _Base::const_pointer const_pointer;
// 23.3.3.1 construct/copy/destroy:
#if __cplusplus < 201103L
@ -130,7 +128,9 @@ namespace __profile
set&
operator=(const set& __x)
{
this->_M_profile_destruct();
_M_base() = __x;
this->_M_profile_construct();
return *this;
}
#else
@ -143,63 +143,104 @@ namespace __profile
set&
operator=(initializer_list<value_type> __l)
{
this->_M_profile_destruct();
_M_base() = __l;
this->_M_profile_construct();
return *this;
}
#endif
// iterators
iterator
begin() _GLIBCXX_NOEXCEPT
{ return iterator(_Base::begin(), this); }
const_iterator
begin() const _GLIBCXX_NOEXCEPT
{ return const_iterator(_Base::begin(), this); }
iterator
end() _GLIBCXX_NOEXCEPT
{ return iterator(_Base::end(), this); }
const_iterator
end() const _GLIBCXX_NOEXCEPT
{ return const_iterator(_Base::end(), this); }
#if __cplusplus >= 201103L
const_iterator
cbegin() const noexcept
{ return const_iterator(_Base::cbegin(), this); }
const_iterator
cend() const noexcept
{ return const_iterator(_Base::cend(), this); }
#endif
reverse_iterator
rbegin() _GLIBCXX_NOEXCEPT
{
__profcxx_map_to_unordered_map_invalidate(this);
return _Base::rbegin();
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return reverse_iterator(end());
}
const_reverse_iterator
rbegin() const _GLIBCXX_NOEXCEPT
{
__profcxx_map_to_unordered_map_invalidate(this);
return _Base::rbegin();
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return const_reverse_iterator(end());
}
reverse_iterator
rend() _GLIBCXX_NOEXCEPT
{
__profcxx_map_to_unordered_map_invalidate(this);
return _Base::rend();
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return reverse_iterator(begin());
}
const_reverse_iterator
rend() const _GLIBCXX_NOEXCEPT
{
__profcxx_map_to_unordered_map_invalidate(this);
return _Base::rend();
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return const_reverse_iterator(begin());
}
#if __cplusplus >= 201103L
const_reverse_iterator
crbegin() const noexcept
{
__profcxx_map_to_unordered_map_invalidate(this);
return _Base::crbegin();
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return const_reverse_iterator(cend());
}
const_reverse_iterator
crend() const noexcept
{
__profcxx_map_to_unordered_map_invalidate(this);
return _Base::crend();
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return const_reverse_iterator(cbegin());
}
#endif
void
swap(set& __x)
#if __cplusplus >= 201103L
noexcept( noexcept(declval<_Base>().swap(__x)) )
#endif
{
_Base::swap(__x);
this->_M_swap(__x);
}
// modifiers:
#if __cplusplus >= 201103L
template<typename... _Args>
std::pair<iterator, bool>
emplace(_Args&&... __args)
{
__profcxx_map_to_unordered_map_insert(this, this->size(), 1);
return _Base::emplace(std::forward<_Args>(__args)...);
__profcxx_map2umap_insert(this->_M_map2umap_info, this->size(), 1);
auto __base_ret = _Base::emplace(std::forward<_Args>(__args)...);
return std::make_pair(iterator(__base_ret.first, this),
__base_ret.second);
}
template<typename... _Args>
@ -208,26 +249,31 @@ namespace __profile
{
auto size_before = this->size();
auto __res
= _Base::emplace_hint(__pos, std::forward<_Args>(__args)...);
__profcxx_map_to_unordered_map_insert(this, size_before,
_M_hint_used(__pos, __res) ? 0 : 1);
return __res;
= _Base::emplace_hint(__pos.base(), std::forward<_Args>(__args)...);
__profcxx_map2umap_insert(this->_M_map2umap_info,
size_before, _M_hint_used(__pos.base(), __res) ? 0 : 1);
return iterator(__res, this);
}
#endif
std::pair<iterator, bool>
insert(const value_type& __x)
{
__profcxx_map_to_unordered_map_insert(this, this->size(), 1);
return _Base::insert(__x);
__profcxx_map2umap_insert(this->_M_map2umap_info, this->size(), 1);
std::pair<_Base_iterator, bool> __base_ret = _Base::insert(__x);
return std::make_pair(iterator(__base_ret.first, this),
__base_ret.second);
}
#if __cplusplus >= 201103L
std::pair<iterator, bool>
insert(value_type&& __x)
{
__profcxx_map_to_unordered_map_insert(this, this->size(), 1);
return _Base::insert(std::move(__x));
__profcxx_map2umap_insert(this->_M_map2umap_info, this->size(), 1);
std::pair<_Base_iterator, bool> __base_ret
= _Base::insert(std::move(__x));
return std::make_pair(iterator(__base_ret.first, this),
__base_ret.second);
}
#endif
@ -235,24 +281,19 @@ namespace __profile
insert(const_iterator __pos, const value_type& __x)
{
size_type size_before = this->size();
iterator __res = _Base::insert(__pos, __x);
__profcxx_map_to_unordered_map_insert(this, size_before,
_M_hint_used(__pos, __res) ? 0 : 1);
return __res;
_Base_iterator __res = _Base::insert(__pos.base(), __x);
__profcxx_map2umap_insert(this->_M_map2umap_info,
size_before, _M_hint_used(__pos.base(), __res) ? 0 : 1);
return iterator(__res, this);
}
#if __cplusplus >= 201103L
iterator
insert(const_iterator __position, value_type&& __x)
{ return iterator(_Base::insert(__position, std::move(__x))); }
insert(const_iterator __pos, value_type&& __x)
{ return iterator(_Base::insert(__pos.base(), std::move(__x)), this); }
#endif
#if __cplusplus >= 201103L
template<typename _InputIterator,
typename = std::_RequireInputIter<_InputIterator>>
#else
template<typename _InputIterator>
#endif
void
insert(_InputIterator __first, _InputIterator __last)
{
@ -270,23 +311,23 @@ namespace __profile
iterator
erase(const_iterator __pos)
{
__profcxx_map_to_unordered_map_erase(this, this->size(), 1);
return _Base::erase(__pos);
__profcxx_map2umap_erase(this->_M_map2umap_info, this->size(), 1);
return iterator(_Base::erase(__pos.base()), this);
}
#else
void
erase(iterator __pos)
{
__profcxx_map_to_unordered_map_erase(this, this->size(), 1);
_Base::erase(__pos);
__profcxx_map2umap_erase(this->_M_map2umap_info, this->size(), 1);
_Base::erase(__pos.base());
}
#endif
size_type
erase(const key_type& __x)
{
__profcxx_map_to_unordered_map_find(this, this->size());
__profcxx_map_to_unordered_map_erase(this, this->size(), 1);
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
__profcxx_map2umap_erase(this->_M_map2umap_info, this->size(), 1);
return _Base::erase(__x);
}
@ -302,7 +343,7 @@ namespace __profile
return __ret;
}
return _Base::erase(__first, __last);
return iterator(_Base::erase(__first.base(), __last.base()), this);
}
#else
void
@ -314,78 +355,85 @@ namespace __profile
#endif
void
swap(set& __x)
#if __cplusplus >= 201103L
noexcept( noexcept(declval<_Base>().swap(__x)) )
#endif
{ _Base::swap(__x); }
// set operations:
iterator
find(const key_type& __x)
clear() _GLIBCXX_NOEXCEPT
{
__profcxx_map_to_unordered_map_find(this, this->size());
return _Base::find(__x);
}
const_iterator
find(const key_type& __x) const
{
__profcxx_map_to_unordered_map_find(this, this->size());
return _Base::find(__x);
this->_M_profile_destruct();
_Base::clear();
this->_M_profile_construct();
}
size_type
count(const key_type& __x) const
{
__profcxx_map_to_unordered_map_find(this, this->size());
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
return _Base::count(__x);
}
// set operations:
iterator
find(const key_type& __x)
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
return iterator(_Base::find(__x), this);
}
const_iterator
find(const key_type& __x) const
{
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
return const_iterator(_Base::find(__x), this);
}
iterator
lower_bound(const key_type& __x)
{
__profcxx_map_to_unordered_map_find(this, this->size());
__profcxx_map_to_unordered_map_invalidate(this);
return _Base::lower_bound(__x);
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return iterator(_Base::lower_bound(__x), this);
}
const_iterator
lower_bound(const key_type& __x) const
{
__profcxx_map_to_unordered_map_find(this, this->size());
__profcxx_map_to_unordered_map_invalidate(this);
return _Base::lower_bound(__x);
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return const_iterator(_Base::lower_bound(__x), this);
}
iterator
upper_bound(const key_type& __x)
{
__profcxx_map_to_unordered_map_find(this, this->size());
__profcxx_map_to_unordered_map_invalidate(this);
return _Base::upper_bound(__x);
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return iterator(_Base::upper_bound(__x), this);
}
const_iterator
upper_bound(const key_type& __x) const
{
__profcxx_map_to_unordered_map_find(this, this->size());
__profcxx_map_to_unordered_map_invalidate(this);
return _Base::upper_bound(__x);
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
__profcxx_map2umap_invalidate(this->_M_map2umap_info);
return const_iterator(_Base::upper_bound(__x), this);
}
std::pair<iterator, iterator>
equal_range(const key_type& __x)
{
__profcxx_map_to_unordered_map_find(this, this->size());
return _Base::equal_range(__x);
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
std::pair<_Base_iterator, _Base_iterator> __base_ret
= _Base::equal_range(__x);
return std::make_pair(iterator(__base_ret.first, this),
iterator(__base_ret.second, this));
}
std::pair<const_iterator, const_iterator>
equal_range(const key_type& __x) const
{
__profcxx_map_to_unordered_map_find(this, this->size());
return _Base::equal_range(__x);
__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
std::pair<_Base_const_iterator, _Base_const_iterator> __base_ret
= _Base::equal_range(__x);
return std::make_pair(const_iterator(__base_ret.first, this),
const_iterator(__base_ret.second, this));
}
_Base&
@ -402,50 +450,66 @@ namespace __profile
* implementation dependent.
*/
bool
_M_hint_used(const_iterator __hint, iterator __res)
_M_hint_used(_Base_const_iterator __hint, _Base_iterator __res)
{
return (__hint == __res
|| (__hint == this->end() && ++__res == this->end())
|| (__hint != this->end() && (++__hint == __res
|| ++__res == --__hint)));
|| (__hint == _M_base().end() && ++__res == _M_base().end())
|| (__hint != _M_base().end() && (++__hint == __res
|| ++__res == --__hint)));
}
template<typename _K1, typename _C1, typename _A1>
friend bool
operator==(const set<_K1, _C1, _A1>&, const set<_K1, _C1, _A1>&);
template<typename _K1, typename _C1, typename _A1>
friend bool
operator<(const set<_K1, _C1, _A1>&, const set<_K1, _C1, _A1>&);
};
template<typename _Key, typename _Compare, typename _Allocator>
inline bool
operator==(const set<_Key, _Compare, _Allocator>& __lhs,
const set<_Key, _Compare, _Allocator>& __rhs)
{ return __lhs._M_base() == __rhs._M_base(); }
template<typename _Key, typename _Compare, typename _Allocator>
inline bool
operator!=(const set<_Key, _Compare, _Allocator>& __lhs,
const set<_Key, _Compare, _Allocator>& __rhs)
{ return __lhs._M_base() != __rhs._M_base(); }
{
__profcxx_map2umap_invalidate(__lhs._M_map2umap_info);
__profcxx_map2umap_invalidate(__rhs._M_map2umap_info);
return __lhs._M_base() == __rhs._M_base();
}
template<typename _Key, typename _Compare, typename _Allocator>
inline bool
operator<(const set<_Key, _Compare, _Allocator>& __lhs,
const set<_Key, _Compare, _Allocator>& __rhs)
{ return __lhs._M_base() < __rhs._M_base(); }
{
__profcxx_map2umap_invalidate(__lhs._M_map2umap_info);
__profcxx_map2umap_invalidate(__rhs._M_map2umap_info);
return __lhs._M_base() < __rhs._M_base();
}
template<typename _Key, typename _Compare, typename _Allocator>
inline bool
operator!=(const set<_Key, _Compare, _Allocator>& __lhs,
const set<_Key, _Compare, _Allocator>& __rhs)
{ return !(__lhs == __rhs); }
template<typename _Key, typename _Compare, typename _Allocator>
inline bool
operator<=(const set<_Key, _Compare, _Allocator>& __lhs,
const set<_Key, _Compare, _Allocator>& __rhs)
{ return __lhs._M_base() <= __rhs._M_base(); }
{ return !(__rhs < __lhs); }
template<typename _Key, typename _Compare, typename _Allocator>
inline bool
operator>=(const set<_Key, _Compare, _Allocator>& __lhs,
const set<_Key, _Compare, _Allocator>& __rhs)
{ return __lhs._M_base() >= __rhs._M_base(); }
{ return !(__lhs < __rhs); }
template<typename _Key, typename _Compare, typename _Allocator>
inline bool
operator>(const set<_Key, _Compare, _Allocator>& __lhs,
const set<_Key, _Compare, _Allocator>& __rhs)
{ return __lhs._M_base() > __rhs._M_base(); }
{ return __rhs < __lhs; }
template<typename _Key, typename _Compare, typename _Allocator>
void

View File

@ -154,39 +154,79 @@ namespace __profile
using __unique_keys = std::integral_constant<bool, _Unique_keys>;
protected:
_Unordered_profile()
{
auto& __uc = _M_conjure();
__profcxx_hashtable_construct(&__uc, __uc.bucket_count());
__profcxx_hashtable_construct2(&__uc);
}
_Unordered_profile(const _Unordered_profile&)
: _Unordered_profile() { }
_Unordered_profile(_Unordered_profile&&)
_Unordered_profile() noexcept
{ _M_profile_construct(); }
_Unordered_profile(const _Unordered_profile&) noexcept
: _Unordered_profile() { }
~_Unordered_profile() noexcept
_Unordered_profile(_Unordered_profile&& __other) noexcept
: _Unordered_profile()
{ _M_swap(__other); }
~_Unordered_profile()
{ _M_profile_destruct(); }
_Unordered_profile&
operator=(const _Unordered_profile&) noexcept
{
auto& __uc = _M_conjure();
__profcxx_hashtable_destruct(&__uc, __uc.bucket_count(), __uc.size());
// Assignment just reset profiling.
_M_profile_destruct();
_M_profile_construct();
}
_Unordered_profile&
operator=(const _Unordered_profile&) = default;
operator=(_Unordered_profile&& __other) noexcept
{
// Take profiling of the moved instance...
_M_swap(__other);
_Unordered_profile&
operator=(_Unordered_profile&&) = default;
// ...and then reset other instance profiling.
__other._M_profile_destruct();
__other._M_profile_construct();
}
void
_M_profile_destruct()
_M_profile_construct() noexcept
{
if (!__profcxx_inefficient_hash_is_on())
auto& __uc = _M_conjure();
_M_size_info = __profcxx_hashtable_size_construct(__uc.bucket_count());
_M_hashfunc_info = __profcxx_hash_func_construct();
}
void
_M_profile_destruct() noexcept
{
auto& __uc = _M_conjure();
__profcxx_hashtable_size_destruct(_M_size_info,
__uc.bucket_count(), __uc.size());
_M_size_info = 0;
if (!_M_hashfunc_info)
return;
_M_profile_destruct(__unique_keys());
_M_hashfunc_info = 0;
}
void
_M_swap(_Unordered_profile& __other) noexcept
{
std::swap(_M_size_info, __other._M_size_info);
std::swap(_M_hashfunc_info, __other._M_hashfunc_info);
}
void
_M_profile_resize(std::size_t __old_size)
{
auto __new_size = _M_conjure().bucket_count();
if (__old_size != __new_size)
__profcxx_hashtable_size_resize(_M_size_info, __old_size, __new_size);
}
__gnu_profile::__container_size_info* _M_size_info;
__gnu_profile::__hashfunc_info* _M_hashfunc_info;
private:
void
_M_profile_destruct(std::true_type);
@ -219,7 +259,9 @@ namespace __profile
__chain = 0;
}
}
__profcxx_hashtable_destruct2(&__uc, __lc, __uc.size(), __hops);
__profcxx_hash_func_destruct(_M_hashfunc_info,
__lc, __uc.size(), __hops);
}
template<typename _UnorderedCont, bool _Unique_keys>
@ -255,7 +297,9 @@ namespace __profile
__chain = 0;
}
}
__profcxx_hashtable_destruct2(&__uc, __lc, __unique_size, __hops);
__profcxx_hash_func_destruct(_M_hashfunc_info,
__lc, __unique_size, __hops);
}
} // namespace __profile

View File

@ -76,8 +76,10 @@ namespace __profile
typedef typename _Base::iterator iterator;
typedef typename _Base::const_iterator const_iterator;
unordered_map() = default;
explicit
unordered_map(size_type __n = 10,
unordered_map(size_type __n,
const hasher& __hf = hasher(),
const key_equal& __eql = key_equal(),
const allocator_type& __a = allocator_type())
@ -126,17 +128,18 @@ namespace __profile
unordered_map&
operator=(initializer_list<value_type> __l)
{
this->_M_profile_destruct();
_M_base() = __l;
this->_M_profile_construct();
return *this;
}
void
clear() noexcept
{
__profcxx_hashtable_destruct(this, _Base::bucket_count(),
_Base::size());
this->_M_profile_destruct();
_Base::clear();
this->_M_profile_construct();
}
template<typename... _Args>
@ -146,7 +149,7 @@ namespace __profile
size_type __old_size = _Base::bucket_count();
std::pair<iterator, bool> __res
= _Base::emplace(std::forward<_Args>(__args)...);
_M_profile_resize(__old_size);
this->_M_profile_resize(__old_size);
return __res;
}
@ -157,7 +160,7 @@ namespace __profile
size_type __old_size = _Base::bucket_count();
iterator __res
= _Base::emplace_hint(__it, std::forward<_Args>(__args)...);
_M_profile_resize(__old_size);
this->_M_profile_resize(__old_size);
return __res;
}
@ -166,7 +169,7 @@ namespace __profile
{
size_type __old_size = _Base::bucket_count();
_Base::insert(__l);
_M_profile_resize(__old_size);
this->_M_profile_resize(__old_size);
}
std::pair<iterator, bool>
@ -174,7 +177,7 @@ namespace __profile
{
size_type __old_size = _Base::bucket_count();
std::pair<iterator, bool> __res = _Base::insert(__obj);
_M_profile_resize(__old_size);
this->_M_profile_resize(__old_size);
return __res;
}
@ -183,7 +186,7 @@ namespace __profile
{
size_type __old_size = _Base::bucket_count();
iterator __res = _Base::insert(__iter, __v);
_M_profile_resize(__old_size);
this->_M_profile_resize(__old_size);
return __res;
}
@ -196,7 +199,7 @@ namespace __profile
size_type __old_size = _Base::bucket_count();
std::pair<iterator, bool> __res
= _Base::insert(std::forward<_Pair>(__obj));
_M_profile_resize(__old_size);
this->_M_profile_resize(__old_size);
return __res;
}
@ -208,7 +211,7 @@ namespace __profile
{
size_type __old_size = _Base::bucket_count();
iterator __res = _Base::insert(__iter, std::forward<_Pair>(__v));
_M_profile_resize(__old_size);
this->_M_profile_resize(__old_size);
return __res;
}
@ -218,7 +221,7 @@ namespace __profile
{
size_type __old_size = _Base::bucket_count();
_Base::insert(__first, __last);
_M_profile_resize(__old_size);
this->_M_profile_resize(__old_size);
}
// operator[]
@ -227,7 +230,7 @@ namespace __profile
{
size_type __old_size = _Base::bucket_count();
mapped_type& __res = _M_base()[__k];
_M_profile_resize(__old_size);
this->_M_profile_resize(__old_size);
return __res;
}
@ -236,29 +239,23 @@ namespace __profile
{
size_type __old_size = _Base::bucket_count();
mapped_type& __res = _M_base()[std::move(__k)];
_M_profile_resize(__old_size);
this->_M_profile_resize(__old_size);
return __res;
}
void
swap(unordered_map& __x)
noexcept( noexcept(__x._M_base().swap(__x)) )
{ _Base::swap(__x._M_base()); }
{
_Base::swap(__x._M_base());
this->_M_swap(__x);
}
void rehash(size_type __n)
{
size_type __old_size = _Base::bucket_count();
_Base::rehash(__n);
_M_profile_resize(__old_size);
}
private:
void
_M_profile_resize(size_type __old_size)
{
size_type __new_size = _Base::bucket_count();
if (__old_size != __new_size)
__profcxx_hashtable_resize(this, __old_size, __new_size);
this->_M_profile_resize(__old_size);
}
};
@ -321,8 +318,10 @@ namespace __profile
typedef typename _Base::iterator iterator;
typedef typename _Base::const_iterator const_iterator;
unordered_multimap() = default;
explicit
unordered_multimap(size_type __n = 10,
unordered_multimap(size_type __n,
const hasher& __hf = hasher(),
const key_equal& __eql = key_equal(),
const allocator_type& __a = allocator_type())
@ -371,17 +370,18 @@ namespace __profile
unordered_multimap&
operator=(initializer_list<value_type> __l)
{
this->_M_profile_destruct();
_M_base() = __l;
this->_M_profile_construct();
return *this;
}
void
clear() noexcept
{
__profcxx_hashtable_destruct(this, _Base::bucket_count(),
_Base::size());
this->_M_profile_destruct();
_Base::clear();
this->_M_profile_construct();
}
template<typename... _Args>
@ -391,7 +391,7 @@ namespace __profile
size_type __old_size = _Base::bucket_count();
iterator __res
= _Base::emplace(std::forward<_Args>(__args)...);
_M_profile_resize(__old_size);
this->_M_profile_resize(__old_size);
return __res;
}
@ -402,7 +402,7 @@ namespace __profile
size_type __old_size = _Base::bucket_count();
iterator __res
= _Base::emplace_hint(__it, std::forward<_Args>(__args)...);
_M_profile_resize(__old_size);
this->_M_profile_resize(__old_size);
return __res;
}
@ -411,7 +411,7 @@ namespace __profile
{
size_type __old_size = _Base::bucket_count();
_Base::insert(__l);
_M_profile_resize(__old_size);
this->_M_profile_resize(__old_size);
}
iterator
@ -419,7 +419,7 @@ namespace __profile
{
size_type __old_size = _Base::bucket_count();
iterator __res = _Base::insert(__obj);
_M_profile_resize(__old_size);
this->_M_profile_resize(__old_size);
return __res;
}
@ -428,7 +428,7 @@ namespace __profile
{
size_type __old_size = _Base::bucket_count();
iterator __res = _Base::insert(__iter, __v);
_M_profile_resize(__old_size);
this->_M_profile_resize(__old_size);
return __res;
}
@ -440,7 +440,7 @@ namespace __profile
{
size_type __old_size = _Base::bucket_count();
iterator __res = _Base::insert(std::forward<_Pair>(__obj));
_M_profile_resize(__old_size);
this->_M_profile_resize(__old_size);
return __res;
}
@ -452,7 +452,7 @@ namespace __profile
{
size_type __old_size = _Base::bucket_count();
iterator __res = _Base::insert(__iter, std::forward<_Pair>(__v));
_M_profile_resize(__old_size);
this->_M_profile_resize(__old_size);
return __res;
}
@ -462,29 +462,23 @@ namespace __profile
{
size_type __old_size = _Base::bucket_count();
_Base::insert(__first, __last);
_M_profile_resize(__old_size);
this->_M_profile_resize(__old_size);
}
void
swap(unordered_multimap& __x)
noexcept( noexcept(__x._M_base().swap(__x)) )
{ _Base::swap(__x._M_base()); }
{
_Base::swap(__x._M_base());
this->_M_swap(__x);
}
void
rehash(size_type __n)
{
size_type __old_size = _Base::bucket_count();
_Base::rehash(__n);
_M_profile_resize(__old_size);
}
private:
void
_M_profile_resize(size_type __old_size)
{
size_type __new_size = _Base::bucket_count();
if (__old_size != __new_size)
__profcxx_hashtable_resize(this, __old_size, __new_size);
this->_M_profile_resize(__old_size);
}
};

View File

@ -75,8 +75,10 @@ namespace __profile
typedef typename _Base::iterator iterator;
typedef typename _Base::const_iterator const_iterator;
unordered_set() = default;
explicit
unordered_set(size_type __n = 10,
unordered_set(size_type __n,
const hasher& __hf = hasher(),
const key_equal& __eql = key_equal(),
const allocator_type& __a = allocator_type())
@ -132,22 +134,26 @@ namespace __profile
unordered_set&
operator=(initializer_list<value_type> __l)
{
this->_M_profile_destruct();
_M_base() = __l;
this->_M_profile_construct();
return *this;
}
void
swap(unordered_set& __x)
noexcept( noexcept(__x._M_base().swap(__x)) )
{ _Base::swap(__x); }
{
_Base::swap(__x);
this->_M_swap(__x);
}
void
clear() noexcept
{
__profcxx_hashtable_destruct(this, _Base::bucket_count(),
_Base::size());
this->_M_profile_destruct();
_Base::clear();
this->_M_profile_construct();
}
template<typename... _Args>
@ -157,7 +163,7 @@ namespace __profile
size_type __old_size = _Base::bucket_count();
std::pair<iterator, bool> __res
= _Base::emplace(std::forward<_Args>(__args)...);
_M_profile_resize(__old_size);
this->_M_profile_resize(__old_size);
return __res;
}
@ -168,7 +174,7 @@ namespace __profile
size_type __old_size = _Base::bucket_count();
iterator __res
= _Base::emplace_hint(__it, std::forward<_Args>(__args)...);
_M_profile_resize(__old_size);
this->_M_profile_resize(__old_size);
return __res;
}
@ -177,7 +183,7 @@ namespace __profile
{
size_type __old_size = _Base::bucket_count();
_Base::insert(__l);
_M_profile_resize(__old_size);
this->_M_profile_resize(__old_size);
}
std::pair<iterator, bool>
@ -185,7 +191,7 @@ namespace __profile
{
size_type __old_size = _Base::bucket_count();
std::pair<iterator, bool> __res = _Base::insert(__obj);
_M_profile_resize(__old_size);
this->_M_profile_resize(__old_size);
return __res;
}
@ -194,7 +200,7 @@ namespace __profile
{
size_type __old_size = _Base::bucket_count();
iterator __res = _Base::insert(__iter, __v);
_M_profile_resize(__old_size);
this->_M_profile_resize(__old_size);
return __res;
}
@ -203,7 +209,7 @@ namespace __profile
{
size_type __old_size = _Base::bucket_count();
std::pair<iterator, bool> __res = _Base::insert(std::move(__obj));
_M_profile_resize(__old_size);
this->_M_profile_resize(__old_size);
return __res;
}
@ -212,7 +218,7 @@ namespace __profile
{
size_type __old_size = _Base::bucket_count();
iterator __res = _Base::insert(__iter, std::move(__v));
_M_profile_resize(__old_size);
this->_M_profile_resize(__old_size);
return __res;
}
@ -222,7 +228,7 @@ namespace __profile
{
size_type __old_size = _Base::bucket_count();
_Base::insert(__first, __last);
_M_profile_resize(__old_size);
this->_M_profile_resize(__old_size);
}
void
@ -230,16 +236,7 @@ namespace __profile
{
size_type __old_size = _Base::bucket_count();
_Base::rehash(__n);
_M_profile_resize(__old_size);
}
private:
void
_M_profile_resize(size_type __old_size)
{
size_type __new_size = _Base::bucket_count();
if (__old_size != __new_size)
__profcxx_hashtable_resize(this, __old_size, __new_size);
this->_M_profile_resize(__old_size);
}
};
@ -299,8 +296,10 @@ namespace __profile
typedef typename _Base::iterator iterator;
typedef typename _Base::const_iterator const_iterator;
unordered_multiset() = default;
explicit
unordered_multiset(size_type __n = 10,
unordered_multiset(size_type __n,
const hasher& __hf = hasher(),
const key_equal& __eql = key_equal(),
const allocator_type& __a = allocator_type())
@ -356,22 +355,26 @@ namespace __profile
unordered_multiset&
operator=(initializer_list<value_type> __l)
{
this->_M_profile_destruct();
_M_base() = __l;
this->_M_profile_construct();
return *this;
}
void
swap(unordered_multiset& __x)
noexcept( noexcept(__x._M_base().swap(__x)) )
{ _Base::swap(__x); }
{
_Base::swap(__x);
this->_M_swap(__x);
}
void
clear() noexcept
{
__profcxx_hashtable_destruct(this, _Base::bucket_count(),
_Base::size());
this->_M_profile_destruct();
_Base::clear();
this->_M_profile_construct();
}
template<typename... _Args>
@ -380,7 +383,7 @@ namespace __profile
{
size_type __old_size = _Base::bucket_count();
iterator __res = _Base::emplace(std::forward<_Args>(__args)...);
_M_profile_resize(__old_size);
this->_M_profile_resize(__old_size);
return __res;
}
@ -391,7 +394,7 @@ namespace __profile
size_type __old_size = _Base::bucket_count();
iterator __res
= _Base::emplace_hint(__it, std::forward<_Args>(__args)...);
_M_profile_resize(__old_size);
this->_M_profile_resize(__old_size);
return __res;
}
@ -400,7 +403,7 @@ namespace __profile
{
size_type __old_size = _Base::bucket_count();
_Base::insert(__l);
_M_profile_resize(__old_size);
this->_M_profile_resize(__old_size);
}
iterator
@ -408,7 +411,7 @@ namespace __profile
{
size_type __old_size = _Base::bucket_count();
iterator __res = _Base::insert(__obj);
_M_profile_resize(__old_size);
this->_M_profile_resize(__old_size);
return __res;
}
@ -417,7 +420,7 @@ namespace __profile
{
size_type __old_size = _Base::bucket_count();
iterator __res = _Base::insert(__iter, __v);
_M_profile_resize(__old_size);
this->_M_profile_resize(__old_size);
return __res;
}
@ -426,7 +429,7 @@ namespace __profile
{
size_type __old_size = _Base::bucket_count();
iterator __res = _Base::insert(std::move(__obj));
_M_profile_resize(__old_size);
this->_M_profile_resize(__old_size);
return __res;
}
@ -435,7 +438,7 @@ namespace __profile
{
size_type __old_size = _Base::bucket_count();
iterator __res = _Base::insert(__iter, std::move(__v));
_M_profile_resize(__old_size);
this->_M_profile_resize(__old_size);
return __res;
}
@ -445,7 +448,7 @@ namespace __profile
{
size_type __old_size = _Base::bucket_count();
_Base::insert(__first, __last);
_M_profile_resize(__old_size);
this->_M_profile_resize(__old_size);
}
void
@ -453,16 +456,7 @@ namespace __profile
{
size_type __old_size = _Base::bucket_count();
_Base::rehash(__n);
_M_profile_resize(__old_size);
}
private:
void
_M_profile_resize(size_type __old_size)
{
size_type __new_size = _Base::bucket_count();
if (__old_size != __new_size)
__profcxx_hashtable_resize(this, __old_size, __new_size);
this->_M_profile_resize(__old_size);
}
};

View File

@ -51,20 +51,13 @@ namespace __profile
_Vector_profile_pre(_Vector_profile_pre&&) = default;
_Vector_profile_pre&
operator=(const _Vector_profile_pre&) = default;
operator=(const _Vector_profile_pre&)
{ _M_conjure()._M_profile_destruct(); }
_Vector_profile_pre&
operator=(_Vector_profile_pre&&) noexcept
{ _M_profile_destruct(); }
{ _M_conjure()._M_profile_destruct(); }
#endif
void
_M_profile_destruct()
{
__profcxx_vector_destruct2(&_M_conjure());
__profcxx_vector_destruct(&_M_conjure(),
_M_conjure().capacity(), _M_conjure().size());
}
};
template<typename _Vector>
@ -75,26 +68,60 @@ namespace __profile
{ return *static_cast<_Vector*>(this); }
protected:
__gnu_profile::__container_size_info* _M_size_info;
__gnu_profile::__vector2list_info* _M_vect2list_info;
_Vector_profile_post() _GLIBCXX_NOEXCEPT
{
__profcxx_vector_construct(&_M_conjure(), _M_conjure().capacity());
__profcxx_vector_construct2(&_M_conjure());
}
{ _M_profile_construct(); }
#if __cplusplus >= 201103L
_Vector_profile_post(const _Vector_profile_post&) noexcept
: _Vector_profile_post() { }
_Vector_profile_post(_Vector_profile_post&&) noexcept
: _Vector_profile_post() { }
_Vector_profile_post(_Vector_profile_post&& __other) noexcept
: _Vector_profile_post()
{ _M_swap(__other); }
_Vector_profile_post&
operator=(const _Vector_profile_post&) = default;
operator=(const _Vector_profile_post&) noexcept
{ _M_profile_construct(); }
_Vector_profile_post&
operator=(_Vector_profile_post&&) = default;
operator=(_Vector_profile_post&& __other) noexcept
{
_M_swap(__other);
__other._M_profile_construct();
}
#endif
~_Vector_profile_post()
{ _M_conjure()._M_profile_destruct(); }
public:
void
_M_profile_construct() _GLIBCXX_NOEXCEPT
{
_M_size_info =
__profcxx_vector_size_construct(_M_conjure().capacity());
_M_vect2list_info = __profcxx_vector2list_construct();
}
void
_M_profile_destruct() _GLIBCXX_NOEXCEPT
{
__profcxx_vector2list_destruct(_M_vect2list_info);
_M_vect2list_info = 0;
__profcxx_vector_size_destruct(_M_size_info,
_M_conjure().capacity(),
_M_conjure().size());
_M_size_info = 0;
}
void
_M_swap(_Vector_profile_post& __other) _GLIBCXX_NOEXCEPT
{
std::swap(_M_size_info, __other._M_size_info);
std::swap(_M_vect2list_info, __other._M_vect2list_info);
}
};
template<typename _Tp,
@ -197,7 +224,9 @@ namespace __profile
vector&
operator=(const vector& __x)
{
this->_M_profile_destruct();
_M_base() = __x;
this->_M_profile_construct();
return *this;
}
#else
@ -210,7 +239,9 @@ namespace __profile
vector&
operator=(initializer_list<value_type> __l)
{
this->_M_profile_destruct();
_M_base() = __l;
this->_M_profile_construct();
return *this;
}
#endif
@ -272,7 +303,7 @@ namespace __profile
void
resize(size_type __sz)
{
__profcxx_vector_invalid_operator(this);
__profcxx_vector2list_invalid_operator(this->_M_vect2list_info);
_M_profile_resize(this->capacity(), __sz);
_Base::resize(__sz);
}
@ -280,7 +311,7 @@ namespace __profile
void
resize(size_type __sz, const _Tp& __c)
{
__profcxx_vector_invalid_operator(this);
__profcxx_vector2list_invalid_operator(this->_M_vect2list_info);
_M_profile_resize(this->capacity(), __sz);
_Base::resize(__sz, __c);
}
@ -288,7 +319,7 @@ namespace __profile
void
resize(size_type __sz, _Tp __c = _Tp())
{
__profcxx_vector_invalid_operator(this);
__profcxx_vector2list_invalid_operator(this->_M_vect2list_info);
_M_profile_resize(this->capacity(), __sz);
_Base::resize(__sz, __c);
}
@ -298,13 +329,13 @@ namespace __profile
reference
operator[](size_type __n) _GLIBCXX_NOEXCEPT
{
__profcxx_vector_invalid_operator(this);
__profcxx_vector2list_invalid_operator(this->_M_vect2list_info);
return _M_base()[__n];
}
const_reference
operator[](size_type __n) const _GLIBCXX_NOEXCEPT
{
__profcxx_vector_invalid_operator(this);
__profcxx_vector2list_invalid_operator(this->_M_vect2list_info);
return _M_base()[__n];
}
@ -335,8 +366,9 @@ namespace __profile
insert(iterator __pos, const _Tp& __x)
#endif
{
__profcxx_vector_insert(this, __pos.base() - _Base::begin(),
this->size());
__profcxx_vector2list_insert(this->_M_vect2list_info,
__pos.base() - _Base::begin(),
this->size());
size_type __old_size = this->capacity();
_Base_iterator __res = _Base::insert(__pos.base(), __x);
_M_profile_resize(__old_size, this->capacity());
@ -347,8 +379,9 @@ namespace __profile
iterator
insert(const_iterator __pos, _Tp&& __x)
{
__profcxx_vector_insert(this, __pos.base() - _Base::cbegin(),
this->size());
__profcxx_vector2list_insert(this->_M_vect2list_info,
__pos.base() - _Base::cbegin(),
this->size());
size_type __old_size = this->capacity();
_Base_iterator __res = _Base::insert(__pos.base(), __x);
_M_profile_resize(__old_size, this->capacity());
@ -374,14 +407,18 @@ namespace __profile
#if __cplusplus >= 201103L
noexcept( noexcept(declval<_Base>().swap(__x)) )
#endif
{ _Base::swap(__x); }
{
_Base::swap(__x);
this->_M_swap(__x);
}
#if __cplusplus >= 201103L
iterator
insert(const_iterator __pos, size_type __n, const _Tp& __x)
{
__profcxx_vector_insert(this, __pos.base() - _Base::cbegin(),
this->size());
__profcxx_vector2list_insert(this->_M_vect2list_info,
__pos.base() - _Base::cbegin(),
this->size());
size_type __old_size = this->capacity();
_Base_iterator __res = _Base::insert(__pos, __n, __x);
_M_profile_resize(__old_size, this->capacity());
@ -391,8 +428,9 @@ namespace __profile
void
insert(iterator __pos, size_type __n, const _Tp& __x)
{
__profcxx_vector_insert(this, __pos.base() - _Base::begin(),
this->size());
__profcxx_vector2list_insert(this->_M_vect2list_info,
__pos.base() - _Base::begin(),
this->size());
size_type __old_size = this->capacity();
_Base::insert(__pos, __n, __x);
_M_profile_resize(__old_size, this->capacity());
@ -406,8 +444,9 @@ namespace __profile
insert(const_iterator __pos,
_InputIterator __first, _InputIterator __last)
{
__profcxx_vector_insert(this, __pos.base() - _Base::cbegin(),
this->size());
__profcxx_vector2list_insert(this->_M_vect2list_info,
__pos.base() - _Base::cbegin(),
this->size());
size_type __old_size = this->capacity();
_Base_iterator __res = _Base::insert(__pos, __first, __last);
_M_profile_resize(__old_size, this->capacity());
@ -419,8 +458,9 @@ namespace __profile
insert(iterator __pos,
_InputIterator __first, _InputIterator __last)
{
__profcxx_vector_insert(this, __pos.base() - _Base::begin(),
this->size());
__profcxx_vector2list_insert(this->_M_vect2list_info,
__pos.base() - _Base::begin(),
this->size());
size_type __old_size = this->capacity();
_Base::insert(__pos, __first, __last);
_M_profile_resize(__old_size, this->capacity());
@ -448,21 +488,22 @@ namespace __profile
{
this->_M_profile_destruct();
_Base::clear();
this->_M_profile_construct();
}
inline void _M_profile_find() const
{ __profcxx_vector_find(this, this->size()); }
inline void _M_profile_iterate(int __rewind = 0) const
{ __profcxx_vector_iterate(this); }
inline void
_M_profile_iterate(int __rewind = 0) const
{ __profcxx_vector2list_iterate(this->_M_vect2list_info, __rewind); }
private:
void _M_profile_resize(size_type __old_size, size_type __new_size)
{
if (__old_size < __new_size)
{
__profcxx_vector_resize(this, this->size(), __new_size);
__profcxx_vector_resize2(this, this->size(), __new_size);
__profcxx_vector_size_resize(this->_M_size_info,
this->size(), __new_size);
__profcxx_vector2list_resize(this->_M_vect2list_info,
this->size(), __new_size);
}
}
};
@ -531,8 +572,9 @@ namespace __profile
{
size_t
operator()(const __profile::vector<bool, _Alloc>& __b) const noexcept
{ return std::hash<_GLIBCXX_STD_C::vector<bool, _Alloc>>()
(__b._M_base()); }
{
return std::hash<_GLIBCXX_STD_C::vector<bool, _Alloc>>()(__b._M_base());
}
};
#endif

View File

@ -1,7 +1,3 @@
// { dg-do compile { target *-*-linux* *-*-gnu* } }
// { dg-xfail-if "" { uclibc } { "*" } { "" } }
// { dg-require-profile-mode "" }
// -*- C++ -*-
// Copyright (C) 2006-2014 Free Software Foundation, Inc.
@ -21,47 +17,37 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <stdio.h>
#include <malloc.h>
// { dg-require-profile-mode "" }
#include <vector>
using std::vector;
static void my_init_hook (void);
static void *my_malloc_hook (size_t, const void *);
typedef void* (*malloc_hook) (size_t, const void *);
malloc_hook old_malloc_hook;
void (*__malloc_initialize_hook) (void) = my_init_hook;
static void
my_init_hook (void)
void* operator new(std::size_t size) throw(std::bad_alloc)
{
old_malloc_hook = __malloc_hook;
__malloc_hook = my_malloc_hook;
void* p = std::malloc(size);
if (!p)
throw std::bad_alloc();
return p;
}
static void *
my_malloc_hook (size_t size, const void *caller)
void* operator new (std::size_t size, const std::nothrow_t&) throw()
{
void *result;
__malloc_hook = old_malloc_hook;
result = malloc (size);
old_malloc_hook = __malloc_hook;
// With _GLIBCXX_PROFILE, the instrumentation of the vector constructor
// will call back into malloc.
// will call back into this new operator.
vector<int> v;
__malloc_hook = my_malloc_hook;
return result;
return std::malloc(size);
}
int main()
void operator delete(void* p) throw()
{
int* test = (int*) malloc(sizeof(int));
*test = 1;
return *test;
if (p)
std::free(p);
}
int
main()
{
vector<int> v;
return 0;
}