Commit 1218d701 by Silvius Rus Committed by Silvius Rus

merge branch profile-stdlib

From-SVN: r152431
parent 3930dbe9
2009-10-02 Silvius Rus <silvius.rus@gmail.com>
* configure: Add check for execinfo.h.
* config.h.in: Add undef for HAVE_EXECINFO_H.
* include/Makefile.am: Add build support for profile mode.
* include/Makefile.in: Same.
* include/profile/base.h: New file.
* include/profile/bitset: Same.
* include/profile/deque: Same.
* include/profile/hashtable.h: Same.
* include/profile/list: Same.
* include/profile/map: Same.
* include/profile/map.h: Same.
* include/profile/multimap.h: Same.
* include/profile/multiset.h: Same.
* include/profile/set: Same.
* include/profile/set.h: Same.
* include/profile/unordered_map: Same.
* include/profile/unordered_set: Same.
* include/profile/vector: Same.
* include/profile/impl/profiler.h: Same.
* include/profile/impl/profiler_container_size.h: Same.
* include/profile/impl/profiler_hash_func.h: Same.
* include/profile/impl/profiler_hashtable_size.h: Same.
* include/profile/impl/profiler_map_to_unordered_map.h: Same.
* include/profile/impl/profiler_node.h: Same.
* include/profile/impl/profiler_state.h: Same.
* include/profile/impl/profiler_trace.h: Same.
* include/profile/impl/profiler_vector_size.h: Same.
* include/profile/impl/profiler_vector_to_list.h: Same.
* include/std/vector: Include corresponding profile header guarded by
_GLIBCXX_PROFILE.
* include/std/deque: Same.
* include/std/list: Same.
* include/std/map: Same.
* include/std/unordered_map: Same.
* include/std/bitset: Same.
* include/std/set: Same.
* include/std/unordered_set: Same.
* include/backward/hash_map: Same.
* include/backward/hash_set: Same.
* include/tr1_impl/hashtable (_Hashtable): Expose insert_return_type.
* include/bits/c++config: Define profile namespace.
* testsuite/Makefile.in: Add check-profile.
* testsuite/Makefile.am: Same.
* testsuite/ext/profile/all.cc: New file.
* testsuite/ext/profile/mh.cc: Same.
* testsuite/ext/profile/mutex_extensions.cc: Same.
* testsuite/23_containers/unordered_map/profile/hash_map.cc: Same.
* testsuite/23_containers/unordered_map/profile/unordered.cc: Same.
* testsuite/23_containers/vector/profile/vector.cc: Same.
* testsuite/23_containers/vector/resize/moveable.cc: Make it pass
in profile mode.
* testsuite/23_containers/deque/capacity/moveable.cc: Same.
* testsuite/23_containers/list/capacity/29134.cc: Same.
* doc/Makefile.in: Add reference to profile_mode.xml.
* doc/Makefile.am: Same.
* doc/xml/manual/profile_mode.xml: New file.
* doc/xml/manual/debug.xml: Add link to profile mode section.
* doc/xml/manual/extensions.xml: Add profile mode. Update numbering.
* doc/doxygen/user.cfg.in: Add profile mode files.
2009-10-02 Johannes Singler <singler@ira.uka.de>
* include/parallel/base.h: Take integer types from <tr1/cstdint>.
......
......@@ -262,6 +262,9 @@
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define to 1 if you have the <execinfo.h> header file. */
#undef HAVE_EXECINFO_H
/* Define to 1 if you have the `modf' function. */
#undef HAVE_MODF
......
......@@ -7926,7 +7926,7 @@ fi
# On IRIX 5.3, sys/types and inttypes.h are conflicting.
for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
inttypes.h stdint.h unistd.h
inttypes.h stdint.h unistd.h execinfo.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
......@@ -100,6 +100,7 @@ xml_sources = \
${xml_srcdir}/manual/numerics.xml \
${xml_srcdir}/manual/parallel_mode.xml \
${xml_srcdir}/manual/prerequisites.xml \
${xml_srcdir}/manual/profile_mode.xml \
${xml_srcdir}/manual/internals.xml \
${xml_srcdir}/manual/shared_ptr.xml \
${xml_srcdir}/manual/spine.xml \
......
......@@ -312,6 +312,7 @@ xml_sources = \
${xml_srcdir}/manual/numerics.xml \
${xml_srcdir}/manual/parallel_mode.xml \
${xml_srcdir}/manual/prerequisites.xml \
${xml_srcdir}/manual/profile_mode.xml \
${xml_srcdir}/manual/internals.xml \
${xml_srcdir}/manual/shared_ptr.xml \
${xml_srcdir}/manual/spine.xml \
......
......@@ -661,6 +661,25 @@ INPUT = @srcdir@/doc/doxygen/doxygroups.cc \
include/debug/unordered_map \
include/debug/unordered_set \
include/debug/vector \
include/profile/bitset \
include/profile/deque \
include/profile/list \
include/profile/map \
include/profile/set \
include/profile/unordered_map \
include/profile/unordered_set \
include/profile/vector \
include/profile/base.h \
include/profile/impl/profiler.h \
include/profile/impl/profiler_container_size.h \
include/profile/impl/profiler_hash_func.h \
include/profile/impl/profiler_hashtable_size.h \
include/profile/impl/profiler_map_to_unordered_map.h \
include/profile/impl/profiler_node.h \
include/profile/impl/profiler_state.h \
include/profile/impl/profiler_trace.h \
include/profile/impl/profiler_vector_size.h \
include/profile/impl/profiler_vector_to_list.h \
include/ext/algorithm \
include/ext/functional \
include/ext/iterator \
......@@ -715,6 +734,7 @@ INPUT = @srcdir@/doc/doxygen/doxygroups.cc \
include/bits/shared_ptr.h \
include/debug \
include/parallel \
include/profile \
include/ext \
include/ext/pb_ds \
include/ext/pb_ds/detail
......
......@@ -243,4 +243,12 @@
</para>
</sect2>
<sect2 id="debug.profile_mode" xreflabel="debug.profile_mode">
<title>Profile-based Performance Analysis</title>
<para> The <link linkend="manual.ext.profile_mode">Profile-based
Performance Analysis</link> Extension has performance checks for many
algorithms.
</para>
</sect2>
</sect1>
......@@ -113,7 +113,13 @@ extensions, be aware of two things:
parse="xml" href="parallel_mode.xml">
</xi:include>
<!-- Chapter 04 : Allocators -->
<!-- Chapter 04 : Profile Mode -->
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
parse="xml" href="profile_mode.xml">
</xi:include>
<!-- Chapter 05 : Allocators -->
<chapter id="manual.ext.allocator" xreflabel="Allocators">
<?dbhtml filename="ext_allocators.html"?>
<title>Allocators</title>
......@@ -130,7 +136,7 @@ extensions, be aware of two things:
</chapter>
<!-- Chapter 05 : Containers -->
<!-- Chapter 06 : Containers -->
<chapter id="manual.ext.containers" xreflabel="Containers">
<?dbhtml filename="ext_containers.html"?>
<title>Containers</title>
......@@ -266,7 +272,7 @@ extensions, be aware of two things:
</sect1>
</chapter>
<!-- Chapter 06 : Utilities -->
<!-- Chapter 07 : Utilities -->
<chapter id="manual.ext.util" xreflabel="Utilities">
<?dbhtml filename="ext_utilities.html"?>
<title>Utilities</title>
......@@ -336,7 +342,7 @@ get_temporary_buffer(5, (int*)0);
</chapter>
<!-- Chapter 07 : Algorithms -->
<!-- Chapter 08 : Algorithms -->
<chapter id="manual.ext.algorithms" xreflabel="Algorithms">
<?dbhtml filename="ext_algorithms.html"?>
<title>Algorithms</title>
......@@ -374,7 +380,7 @@ get_temporary_buffer(5, (int*)0);
</chapter>
<!-- Chapter 08 : Numerics -->
<!-- Chapter 09 : Numerics -->
<chapter id="manual.ext.numerics" xreflabel="Numerics">
<?dbhtml filename="ext_numerics.html"?>
<title>Numerics</title>
......@@ -399,7 +405,7 @@ get_temporary_buffer(5, (int*)0);
void iota(_ForwardIter first, _ForwardIter last, _Tp value);</programlisting>
</chapter>
<!-- Chapter 09 : Iterators -->
<!-- Chapter 10 : Iterators -->
<chapter id="manual.ext.iterators" xreflabel="Iterators">
<?dbhtml filename="ext_iterators.html"?>
<title>Iterators</title>
......@@ -423,7 +429,7 @@ get_temporary_buffer(5, (int*)0);
</chapter>
<!-- Chapter 08 : IO -->
<!-- Chapter 11 : IO -->
<chapter id="manual.ext.io" xreflabel="IO">
<?dbhtml filename="ext_io.html"?>
<title>Input and Output</title>
......@@ -493,7 +499,7 @@ get_temporary_buffer(5, (int*)0);
</sect1>
</chapter>
<!-- Chapter 09 : Demangling -->
<!-- Chapter 12 : Demangling -->
<chapter id="manual.ext.demangle" xreflabel="Demangling">
<?dbhtml filename="ext_demangling.html"?>
<title>Demangling</title>
......@@ -579,7 +585,7 @@ int main()
</para>
</chapter>
<!-- Chapter 10 : Concurrency -->
<!-- Chapter 13 : Concurrency -->
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
parse="xml" href="concurrency.xml">
</xi:include>
......
## Makefile for the include subdirectory of the GNU C++ Standard library.
#o# Makefile for the include subdirectory of the GNU C++ Standard library.
##
## Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
## Free Software Foundation, Inc.
......@@ -771,6 +771,37 @@ else
parallel_headers =
endif
# Profile mode headers
profile_srcdir = ${glibcxx_srcdir}/include/profile
profile_builddir = ./profile
profile_headers = \
${profile_srcdir}/base.h \
${profile_srcdir}/unordered_map \
${profile_srcdir}/unordered_set \
${profile_srcdir}/vector \
${profile_srcdir}/bitset \
${profile_srcdir}/deque \
${profile_srcdir}/list \
${profile_srcdir}/map \
${profile_srcdir}/map.h \
${profile_srcdir}/multimap.h \
${profile_srcdir}/multiset.h \
${profile_srcdir}/set \
${profile_srcdir}/set.h \
${profile_srcdir}/hashtable.h
profile_impl_srcdir = ${glibcxx_srcdir}/include/profile/impl
profile_impl_builddir = ./profile/impl
profile_impl_headers = \
${profile_impl_srcdir}/profiler.h \
${profile_impl_srcdir}/profiler_container_size.h \
${profile_impl_srcdir}/profiler_hash_func.h \
${profile_impl_srcdir}/profiler_hashtable_size.h \
${profile_impl_srcdir}/profiler_map_to_unordered_map.h \
${profile_impl_srcdir}/profiler_node.h \
${profile_impl_srcdir}/profiler_state.h \
${profile_impl_srcdir}/profiler_trace.h \
${profile_impl_srcdir}/profiler_vector_size.h \
${profile_impl_srcdir}/profiler_vector_to_list.h
# Some of the different "C" header models need extra files.
# Some "C" header schemes require the "C" compatibility headers.
......@@ -865,7 +896,8 @@ endif
allstamped = \
stamp-std stamp-bits stamp-c_base stamp-c_base_extra \
stamp-c_compatibility stamp-backward stamp-ext stamp-pb \
stamp-tr1 stamp-tr1-impl stamp-debug stamp-parallel stamp-host
stamp-tr1 stamp-tr1-impl stamp-debug stamp-parallel stamp-host \
stamp-profile stamp-profile-impl
# List of all files that are created by explicit building, editing, or
# catenation.
......@@ -989,6 +1021,16 @@ stamp-parallel: ${parallel_headers}
@-cd ${parallel_builddir} && $(LN_S) $? . 2>/dev/null
@$(STAMP) stamp-parallel
stamp-profile: ${profile_headers}
@-mkdir -p ${profile_builddir}
@-cd ${profile_builddir} && $(LN_S) $? . 2>/dev/null
@$(STAMP) stamp-profile
stamp-profile-impl: ${profile_impl_headers}
@-mkdir -p ${profile_impl_builddir}
@-cd ${profile_impl_builddir} && $(LN_S) $? . 2>/dev/null
@$(STAMP) stamp-profile-impl
stamp-${host_alias}:
@-mkdir -p ${host_builddir}
@$(STAMP) stamp-${host_alias}
......@@ -1217,6 +1259,12 @@ install-headers:
$(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${parallel_builddir};\
for file in $$parallel_headers_install; do \
$(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${parallel_builddir}; done
$(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${profile_builddir}
for file in ${profile_headers}; do \
$(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${profile_builddir}; done
$(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${profile_impl_builddir}
for file in ${profile_impl_headers}; do \
$(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${profile_impl_builddir}; done
$(mkinstalldirs) $(DESTDIR)${host_installdir}
for file in ${host_headers} ${host_headers_extra} \
${thread_host_headers}; do \
......
......@@ -1001,6 +1001,39 @@ parallel_builddir = ./parallel
@ENABLE_PARALLEL_TRUE@ ${parallel_srcdir}/unique_copy.h \
@ENABLE_PARALLEL_TRUE@ ${parallel_srcdir}/workstealing.h
# Profile mode headers
profile_srcdir = ${glibcxx_srcdir}/include/profile
profile_builddir = ./profile
profile_headers = \
${profile_srcdir}/base.h \
${profile_srcdir}/unordered_map \
${profile_srcdir}/unordered_set \
${profile_srcdir}/vector \
${profile_srcdir}/bitset \
${profile_srcdir}/deque \
${profile_srcdir}/list \
${profile_srcdir}/map \
${profile_srcdir}/map.h \
${profile_srcdir}/multimap.h \
${profile_srcdir}/multiset.h \
${profile_srcdir}/set \
${profile_srcdir}/set.h \
${profile_srcdir}/hashtable.h
profile_impl_srcdir = ${glibcxx_srcdir}/include/profile/impl
profile_impl_builddir = ./profile/impl
profile_impl_headers = \
${profile_impl_srcdir}/profiler.h \
${profile_impl_srcdir}/profiler_container_size.h \
${profile_impl_srcdir}/profiler_hash_func.h \
${profile_impl_srcdir}/profiler_hashtable_size.h \
${profile_impl_srcdir}/profiler_map_to_unordered_map.h \
${profile_impl_srcdir}/profiler_node.h \
${profile_impl_srcdir}/profiler_state.h \
${profile_impl_srcdir}/profiler_trace.h \
${profile_impl_srcdir}/profiler_vector_size.h \
${profile_impl_srcdir}/profiler_vector_to_list.h
@GLIBCXX_C_HEADERS_EXTRA_FALSE@c_base_headers_extra =
# Some of the different "C" header models need extra files.
......@@ -1083,7 +1116,8 @@ PCHFLAGS = -x c++-header $(CXXFLAGS)
allstamped = \
stamp-std stamp-bits stamp-c_base stamp-c_base_extra \
stamp-c_compatibility stamp-backward stamp-ext stamp-pb \
stamp-tr1 stamp-tr1-impl stamp-debug stamp-parallel stamp-host
stamp-tr1 stamp-tr1-impl stamp-debug stamp-parallel stamp-host \
stamp-profile stamp-profile-impl
# List of all files that are created by explicit building, editing, or
......@@ -1400,6 +1434,16 @@ stamp-parallel: ${parallel_headers}
@-cd ${parallel_builddir} && $(LN_S) $? . 2>/dev/null
@$(STAMP) stamp-parallel
stamp-profile: ${profile_headers}
@-mkdir -p ${profile_builddir}
@-cd ${profile_builddir} && $(LN_S) $? . 2>/dev/null
@$(STAMP) stamp-profile
stamp-profile-impl: ${profile_impl_headers}
@-mkdir -p ${profile_impl_builddir}
@-cd ${profile_impl_builddir} && $(LN_S) $? . 2>/dev/null
@$(STAMP) stamp-profile-impl
stamp-${host_alias}:
@-mkdir -p ${host_builddir}
@$(STAMP) stamp-${host_alias}
......@@ -1616,6 +1660,13 @@ install-headers:
$(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${parallel_builddir};\
for file in $$parallel_headers_install; do \
$(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${parallel_builddir}; done
$(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${profile_builddir} \
$(DESTDIR)${gxx_include_dir}/${profile_builddir}/impl
for file in ${profile_headers}; do \
$(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${profile_builddir}; done
$(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${profile_impl_builddir}
for file in ${profile_impl_headers}; do \
$(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${profile_impl_builddir}; done
$(mkinstalldirs) $(DESTDIR)${host_installdir}
for file in ${host_headers} ${host_headers_extra} \
${thread_host_headers}; do \
......
......@@ -58,7 +58,11 @@
#include "backward_warning.h"
#include <bits/c++config.h>
#ifdef _GLIBCXX_PROFILE
#include <profile/hashtable.h>
#else
#include <backward/hashtable.h>
#endif
#include <bits/concept_check.h>
_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
......
......@@ -58,7 +58,11 @@
#include "backward_warning.h"
#include <bits/c++config.h>
#ifdef _GLIBCXX_PROFILE
#include <profile/hashtable.h>
#else
#include <backward/hashtable.h>
#endif
#include <bits/concept_check.h>
_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
......
......@@ -85,11 +85,17 @@
# define _GLIBCXX_NAMESPACE_ASSOCIATION_PARALLEL 1
#endif
// Namespace association for profile
#ifdef _GLIBCXX_PROFILE
# define _GLIBCXX_NAMESPACE_ASSOCIATION_PROFILE 1
#endif
#define _GLIBCXX_NAMESPACE_ASSOCIATION_VERSION
// Defined if any namespace association modes are active.
#if _GLIBCXX_NAMESPACE_ASSOCIATION_DEBUG \
|| _GLIBCXX_NAMESPACE_ASSOCIATION_PARALLEL \
|| _GLIBCXX_NAMESPACE_ASSOCIATION_PROFILE \
|| _GLIBCXX_NAMESPACE_ASSOCIATION_VERSION
# define _GLIBCXX_USE_NAMESPACE_ASSOCIATION 1
#endif
......@@ -108,6 +114,7 @@
#ifndef _GLIBCXX_USE_NAMESPACE_ASSOCIATION
# define _GLIBCXX_STD_D _GLIBCXX_STD
# define _GLIBCXX_STD_P _GLIBCXX_STD
# define _GLIBCXX_STD_PR _GLIBCXX_STD
# define _GLIBCXX_STD std
# define _GLIBCXX_BEGIN_NESTED_NAMESPACE(X, Y) _GLIBCXX_BEGIN_NAMESPACE(X)
# define _GLIBCXX_END_NESTED_NAMESPACE _GLIBCXX_END_NAMESPACE
......@@ -124,7 +131,7 @@
# endif
// debug
# if _GLIBCXX_NAMESPACE_ASSOCIATION_DEBUG && !_GLIBCXX_NAMESPACE_ASSOCIATION_PARALLEL
# if _GLIBCXX_NAMESPACE_ASSOCIATION_DEBUG && !_GLIBCXX_NAMESPACE_ASSOCIATION_PARALLEL && !_GLIBCXX_NAMESPACE_ASSOCIATION_PROFILE
# define _GLIBCXX_STD_D __norm
# define _GLIBCXX_STD_P _GLIBCXX_STD
# define _GLIBCXX_STD __cxx1998
......@@ -134,7 +141,7 @@
# endif
// parallel
# if _GLIBCXX_NAMESPACE_ASSOCIATION_PARALLEL && !_GLIBCXX_NAMESPACE_ASSOCIATION_DEBUG
# if _GLIBCXX_NAMESPACE_ASSOCIATION_PARALLEL && !_GLIBCXX_NAMESPACE_ASSOCIATION_DEBUG && !_GLIBCXX_NAMESPACE_ASSOCIATION_PROFILE
# define _GLIBCXX_STD_D _GLIBCXX_STD
# define _GLIBCXX_STD_P __norm
# define _GLIBCXX_STD __cxx1998
......@@ -144,7 +151,7 @@
# endif
// debug + parallel
# if _GLIBCXX_NAMESPACE_ASSOCIATION_PARALLEL && _GLIBCXX_NAMESPACE_ASSOCIATION_DEBUG
# if _GLIBCXX_NAMESPACE_ASSOCIATION_PARALLEL && _GLIBCXX_NAMESPACE_ASSOCIATION_DEBUG && !_GLIBCXX_NAMESPACE_ASSOCIATION_PROFILE
# define _GLIBCXX_STD_D __norm
# define _GLIBCXX_STD_P __norm
# define _GLIBCXX_STD __cxx1998
......@@ -153,6 +160,21 @@
# define _GLIBCXX_EXTERN_TEMPLATE -1
# endif
// profile
# if _GLIBCXX_NAMESPACE_ASSOCIATION_PROFILE
# if _GLIBCXX_NAMESPACE_ASSOCIATION_PARALLEL || _GLIBCXX_NAMESPACE_ASSOCIATION_DEBUG
# error Cannot use -D_GLIBCXX_PROFILE with -D_GLIBCXX_DEBUG or \
-D_GLIBCXX_PARALLEL
# endif
# define _GLIBCXX_STD_D __norm
# define _GLIBCXX_STD_P _GLIBCXX_STD
# define _GLIBCXX_STD_PR __norm
# define _GLIBCXX_STD __cxx1998
# define _GLIBCXX_BEGIN_NAMESPACE(X) namespace X _GLIBCXX_VISIBILITY_ATTR(default) {
# define _GLIBCXX_END_NAMESPACE }
# define _GLIBCXX_EXTERN_TEMPLATE -1
# endif
# if __NO_INLINE__ && !__GXX_WEAK__
# warning currently using namespace associated mode which may fail \
without inlining due to lack of weak symbols
......@@ -163,7 +185,7 @@
#endif
// Namespace associations for debug mode.
#if _GLIBCXX_NAMESPACE_ASSOCIATION_DEBUG
#if _GLIBCXX_NAMESPACE_ASSOCIATION_DEBUG && !_GLIBCXX_NAMESPACE_ASSOCIATION_PROFILE
namespace std
{
namespace __norm { }
......@@ -182,6 +204,16 @@ namespace std
}
#endif
// Namespace associations for profile mode
#if _GLIBCXX_NAMESPACE_ASSOCIATION_PROFILE
namespace std
{
namespace __norm { }
inline namespace __profile { }
inline namespace __cxx1998 { }
}
#endif
// Namespace associations for versioning mode.
#if _GLIBCXX_NAMESPACE_ASSOCIATION_VERSION
namespace std
......
// -*- C++ -*-
// Copyright (C) 2009 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 2, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this library; see the file COPYING. If not, write to
// the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
// MA 02111-1307, USA.
// As a special exception, you may use this file as part of a free
// software library without restriction. Specifically, if other files
// instantiate templates or use macros or inline functions from this
// file, or you compile this file and link it with other files to
// produce an executable, this file does not by itself cause the
// resulting executable to be covered by the GNU General Public
// License. This exception does not however invalidate any other
// reasons why the executable file might be covered by the GNU General
// Public License.
/** @file profile/base.h
* @brief Sequential helper functions.
* This file is a GNU profile extension to the Standard C++ Library.
*/
// Written by Lixia Liu
#ifndef _GLIBCXX_PROFILE_BASE_H
#define _GLIBCXX_PROFILE_BASE_H 1
#include <cstdio>
#include <functional>
#include <bits/c++config.h>
#include <profile/impl/profiler.h>
// Profiling mode namespaces.
/**
* @namespace std::__profile
* @brief GNU profile code, replaces standard behavior with profile behavior.
*/
namespace std
{
namespace __profile { }
}
/**
* @namespace __gnu_profile
* @brief GNU profile code for public use.
*/
namespace __gnu_profile
{
// Import all the profile versions of components in namespace std.
using namespace std::__profile;
}
#endif /* _GLIBCXX_PROFILE_BASE_H */
// Profiling bitset implementation -*- C++ -*-
// Copyright (C) 2009 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file profile/bitset
* This file is a GNU profile extension to the Standard C++ Library.
*/
#ifndef _GLIBCXX_PROFILE_BITSET
#define _GLIBCXX_PROFILE_BITSET
#include <bitset>
namespace std
{
namespace __profile
{
/** @brief Bitset wrapper with performance instrumentation. */
template<size_t _Nb>
class bitset
: public _GLIBCXX_STD_D::bitset<_Nb>
{
typedef _GLIBCXX_STD_D::bitset<_Nb> _Base;
public:
// bit reference:
class reference
: private _Base::reference
{
typedef typename _Base::reference _Base_ref;
friend class bitset;
reference();
reference(const _Base_ref& __base, bitset* __seq)
: _Base_ref(__base)
{ }
public:
reference(const reference& __x)
: _Base_ref(__x)
{ }
reference&
operator=(bool __x)
{
*static_cast<_Base_ref*>(this) = __x;
return *this;
}
reference&
operator=(const reference& __x)
{
*static_cast<_Base_ref*>(this) = __x;
return *this;
}
bool
operator~() const
{
return ~(*static_cast<const _Base_ref*>(this));
}
operator bool() const
{
return *static_cast<const _Base_ref*>(this);
}
reference&
flip()
{
_Base_ref::flip();
return *this;
}
};
// 23.3.5.1 constructors:
bitset() : _Base() { }
bitset(unsigned long __val) : _Base(__val) { }
template<typename _CharT, typename _Traits, typename _Alloc>
explicit
bitset(const std::basic_string<_CharT, _Traits, _Alloc>& __str,
typename std::basic_string<_CharT, _Traits, _Alloc>::size_type
__pos = 0,
typename std::basic_string<_CharT, _Traits, _Alloc>::size_type
__n = (std::basic_string<_CharT, _Traits, _Alloc>::npos))
: _Base(__str, __pos, __n) { }
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 396. what are characters zero and one.
template<class _CharT, class _Traits, class _Alloc>
bitset(const std::basic_string<_CharT, _Traits, _Alloc>& __str,
typename std::basic_string<_CharT, _Traits, _Alloc>::size_type
__pos,
typename std::basic_string<_CharT, _Traits, _Alloc>::size_type
__n,
_CharT __zero, _CharT __one = _CharT('1'))
: _Base(__str, __pos, __n, __zero, __one) { }
bitset(const _Base& __x) : _Base(__x) { }
// 23.3.5.2 bitset operations:
bitset<_Nb>&
operator&=(const bitset<_Nb>& __rhs)
{
_M_base() &= __rhs;
return *this;
}
bitset<_Nb>&
operator|=(const bitset<_Nb>& __rhs)
{
_M_base() |= __rhs;
return *this;
}
bitset<_Nb>&
operator^=(const bitset<_Nb>& __rhs)
{
_M_base() ^= __rhs;
return *this;
}
bitset<_Nb>&
operator<<=(size_t __pos)
{
_M_base() <<= __pos;
return *this;
}
bitset<_Nb>&
operator>>=(size_t __pos)
{
_M_base() >>= __pos;
return *this;
}
bitset<_Nb>&
set()
{
_Base::set();
return *this;
}
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 186. bitset::set() second parameter should be bool
bitset<_Nb>&
set(size_t __pos, bool __val = true)
{
_Base::set(__pos, __val);
return *this;
}
bitset<_Nb>&
reset()
{
_Base::reset();
return *this;
}
bitset<_Nb>&
reset(size_t __pos)
{
_Base::reset(__pos);
return *this;
}
bitset<_Nb> operator~() const { return bitset(~_M_base()); }
bitset<_Nb>&
flip()
{
_Base::flip();
return *this;
}
bitset<_Nb>&
flip(size_t __pos)
{
_Base::flip(__pos);
return *this;
}
// element access:
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 11. Bitset minor problems
reference
operator[](size_t __pos)
{
return reference(_M_base()[__pos], this);
}
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 11. Bitset minor problems
bool
operator[](size_t __pos) const
{
return _M_base()[__pos];
}
using _Base::to_ulong;
template <typename _CharT, typename _Traits, typename _Alloc>
std::basic_string<_CharT, _Traits, _Alloc>
to_string() const
{ return _M_base().template to_string<_CharT, _Traits, _Alloc>(); }
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 396. what are characters zero and one.
template<class _CharT, class _Traits, class _Alloc>
std::basic_string<_CharT, _Traits, _Alloc>
to_string(_CharT __zero, _CharT __one = _CharT('1')) const
{
return _M_base().template
to_string<_CharT, _Traits, _Alloc>(__zero, __one);
}
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 434. bitset::to_string() hard to use.
template<typename _CharT, typename _Traits>
std::basic_string<_CharT, _Traits, std::allocator<_CharT> >
to_string() const
{ return to_string<_CharT, _Traits, std::allocator<_CharT> >(); }
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 853. to_string needs updating with zero and one.
template<class _CharT, class _Traits>
std::basic_string<_CharT, _Traits, std::allocator<_CharT> >
to_string(_CharT __zero, _CharT __one = _CharT('1')) const
{ return to_string<_CharT, _Traits,
std::allocator<_CharT> >(__zero, __one); }
template<typename _CharT>
std::basic_string<_CharT, std::char_traits<_CharT>,
std::allocator<_CharT> >
to_string() const
{
return to_string<_CharT, std::char_traits<_CharT>,
std::allocator<_CharT> >();
}
template<class _CharT>
std::basic_string<_CharT, std::char_traits<_CharT>,
std::allocator<_CharT> >
to_string(_CharT __zero, _CharT __one = _CharT('1')) const
{
return to_string<_CharT, std::char_traits<_CharT>,
std::allocator<_CharT> >(__zero, __one);
}
std::basic_string<char, std::char_traits<char>, std::allocator<char> >
to_string() const
{
return to_string<char,std::char_traits<char>,std::allocator<char> >();
}
std::basic_string<char, std::char_traits<char>, std::allocator<char> >
to_string(char __zero, char __one = '1') const
{
return to_string<char, std::char_traits<char>,
std::allocator<char> >(__zero, __one);
}
using _Base::count;
using _Base::size;
bool
operator==(const bitset<_Nb>& __rhs) const
{ return _M_base() == __rhs; }
bool
operator!=(const bitset<_Nb>& __rhs) const
{ return _M_base() != __rhs; }
using _Base::test;
using _Base::all;
using _Base::any;
using _Base::none;
bitset<_Nb>
operator<<(size_t __pos) const
{ return bitset<_Nb>(_M_base() << __pos); }
bitset<_Nb>
operator>>(size_t __pos) const
{ return bitset<_Nb>(_M_base() >> __pos); }
_Base&
_M_base() { return *this; }
const _Base&
_M_base() const { return *this; }
};
template<size_t _Nb>
bitset<_Nb>
operator&(const bitset<_Nb>& __x, const bitset<_Nb>& __y)
{ return bitset<_Nb>(__x) &= __y; }
template<size_t _Nb>
bitset<_Nb>
operator|(const bitset<_Nb>& __x, const bitset<_Nb>& __y)
{ return bitset<_Nb>(__x) |= __y; }
template<size_t _Nb>
bitset<_Nb>
operator^(const bitset<_Nb>& __x, const bitset<_Nb>& __y)
{ return bitset<_Nb>(__x) ^= __y; }
template<typename _CharT, typename _Traits, size_t _Nb>
std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is, bitset<_Nb>& __x)
{ return __is >> __x._M_base(); }
template<typename _CharT, typename _Traits, size_t _Nb>
std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const bitset<_Nb>& __x)
{ return __os << __x._M_base(); }
} // namespace __profile
} // namespace std
#endif
// -*- C++ -*-
//
// Copyright (C) 2009 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 2, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this library; see the file COPYING. If not, write to
// the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
// MA 02111-1307, USA.
// As a special exception, you may use this file as part of a free
// software library without restriction. Specifically, if other files
// instantiate templates or use macros or inline functions from this
// file, or you compile this file and link it with other files to
// produce an executable, this file does not by itself cause the
// resulting executable to be covered by the GNU General Public
// License. This exception does not however invalidate any other
// reasons why the executable file might be covered by the GNU General
// Public License.
/** @file profile/impl/profiler_trace.h
* @brief Diagnostics for container sizes.
*/
// Written by Lixia Liu and Silvius Rus.
#ifndef PROFCXX_PROFILER_CONTAINER_SIZE_H__
#define PROFCXX_PROFILER_CONTAINER_SIZE_H__ 1
#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <cstdlib>
#include <cstdio>
#include <cstring>
#else
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#endif
#include "profile/impl/profiler.h"
#include "profile/impl/profiler_node.h"
#include "profile/impl/profiler_trace.h"
namespace __cxxprof_impl
{
/** @brief A container size instrumentation line in the object table. */
class __container_size_info: public __object_info_base
{
public:
__container_size_info();
__container_size_info(const __container_size_info& __o);
__container_size_info(__stack_t __stack, size_t __num);
virtual ~__container_size_info() {}
void __write(FILE* f) const;
float __magnitude() const { return static_cast<float>(_M_cost); }
const char* __advice() const;
void __merge(const __container_size_info& __o);
// Call if a container is destructed or cleaned.
void __destruct(size_t __num, size_t __inum);
// Estimate the cost of resize/rehash.
float __resize_cost(size_t __from, size_t __to) { return __from; }
// Call if container is resized.
void __resize(size_t __from, size_t __to);
private:
size_t _M_init;
size_t _M_max; // range of # buckets
size_t _M_min;
size_t _M_total;
size_t _M_item_min; // range of # items
size_t _M_item_max;
size_t _M_item_total;
size_t _M_count;
size_t _M_resize;
size_t _M_cost;
};
inline const char* __container_size_info::__advice() const
{
const size_t __max_chars_size_t_printed = 20;
const char* __message_pattern =
"change initial container size from %d to %d";
size_t __message_size = (strlen(__message_pattern)
+ 2 * __max_chars_size_t_printed
- 2 * 2);
char* __message = new char[__message_size + 1];
if (_M_init < _M_item_max)
snprintf(__message, __message_size, __message_pattern, _M_init,
_M_item_max);
else
snprintf(__message, __message_size, __message_pattern, _M_init,
_M_item_max);
return __message;
}
inline void __container_size_info::__destruct(size_t __num, size_t __inum)
{
_M_max = __max(_M_max, __num);
_M_item_max = __max(_M_item_max, __inum);
if (_M_min == 0) {
_M_min = __num;
_M_item_min = __inum;
} else {
_M_min = __min(_M_min, __num);
_M_item_min = __min(_M_item_min, __inum);
}
_M_total += __num;
_M_item_total += __inum;
_M_count += 1;
}
inline void __container_size_info::__resize(size_t __from, size_t __to)
{
_M_cost += this->__resize_cost(__from, __to);
_M_resize += 1;
_M_max = __max(_M_max, __to);
}
inline __container_size_info::__container_size_info(__stack_t __stack,
size_t __num)
: __object_info_base(__stack), _M_init(0), _M_max(0), _M_item_max(0),
_M_min(0), _M_item_min(0), _M_total(0), _M_item_total(0), _M_cost(0),
_M_count(0), _M_resize(0)
{
_M_init = _M_max = __num;
_M_item_min = _M_item_max = _M_item_total = _M_total = 0;
_M_min = 0;
_M_count = 0;
_M_resize = 0;
}
inline void __container_size_info::__merge(const __container_size_info& __o)
{
_M_init = __max(_M_init, __o._M_init);
_M_max = __max(_M_max, __o._M_max);
_M_item_max = __max(_M_item_max, __o._M_item_max);
_M_min = __min(_M_min, __o._M_min);
_M_item_min = __min(_M_item_min, __o._M_item_min);
_M_total += __o._M_total;
_M_item_total += __o._M_item_total;
_M_count += __o._M_count;
_M_cost += __o._M_cost;
_M_resize += __o._M_resize;
}
inline __container_size_info::__container_size_info()
: _M_init(0), _M_max(0), _M_item_max(0), _M_min(0), _M_item_min(0),
_M_total(0), _M_item_total(0), _M_cost(0), _M_count(0), _M_resize(0)
{
}
inline __container_size_info::__container_size_info(
const __container_size_info& __o)
: __object_info_base(__o)
{
_M_init = __o._M_init;
_M_max = __o._M_max;
_M_item_max = __o._M_item_max;
_M_min = __o._M_min;
_M_item_min = __o._M_item_min;
_M_total = __o._M_total;
_M_item_total = __o._M_item_total;
_M_cost = __o._M_cost;
_M_count = __o._M_count;
_M_resize = __o._M_resize;
}
/** @brief A container size instrumentation line in the stack table. */
class __container_size_stack_info: public __container_size_info
{
public:
__container_size_stack_info(const __container_size_info& __o)
: __container_size_info(__o) {}
};
/** @brief Container size instrumentation trace producer. */
class __trace_container_size
: public __trace_base<__container_size_info, __container_size_stack_info>
{
public:
~__trace_container_size() {}
__trace_container_size()
: __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, size_t __num);
// Call at destruction/clean to set container final size.
void __destruct(const void* __obj, size_t __num, size_t __inum);
void __construct(const void* __obj, size_t __inum);
// Call at resize to set resize/cost information.
void __resize(const void* __obj, int __from, int __to);
};
inline void __trace_container_size::__insert(const __object_t __obj,
__stack_t __stack, size_t __num)
{
__add_object(__obj, __container_size_info(__stack, __num));
}
inline void __container_size_info::__write(FILE* __f) const
{
fprintf(__f, "%Zu %Zu %Zu %Zu %Zu %Zu %Zu %Zu %Zu %Zu\n",
_M_init, _M_count, _M_cost, _M_resize, _M_min, _M_max, _M_total,
_M_item_min, _M_item_max, _M_item_total);
}
inline void __trace_container_size::__destruct(const void* __obj,
size_t __num, size_t __inum)
{
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);
}
inline void __trace_container_size::__resize(const void* __obj, int __from,
int __to)
{
if (!__is_on()) return;
__container_size_info* __object_info = __get_object_info(__obj);
if (!__object_info)
return;
__object_info->__resize(__from, __to);
}
} // namespace __cxxprof_impl
#endif /* PROFCXX_PROFILER_CONTAINER_SIZE_H__ */
// -*- C++ -*-
//
// Copyright (C) 2009 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 2, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this library; see the file COPYING. If not, write to
// the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
// MA 02111-1307, USA.
// As a special exception, you may use this file as part of a free
// software library without restriction. Specifically, if other files
// instantiate templates or use macros or inline functions from this
// file, or you compile this file and link it with other files to
// produce an executable, this file does not by itself cause the
// resulting executable to be covered by the GNU General Public
// License. This exception does not however invalidate any other
// reasons why the executable file might be covered by the GNU General
// Public License.
/** @file profile/impl/profiler_trace.h
* @brief Data structures to represent profiling traces.
*/
// Written by Lixia Liu and Silvius Rus.
#ifndef PROFCXX_PROFILER_HASH_FUNC_H__
#define PROFCXX_PROFILER_HASH_FUNC_H__ 1
#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <cstdlib>
#include <cstdio>
#include <cstring>
#else
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#endif
#include "profile/impl/profiler.h"
#include "profile/impl/profiler_node.h"
#include "profile/impl/profiler_trace.h"
namespace __cxxprof_impl
{
/** @brief A hash performance instrumentation line in the object table. */
class __hashfunc_info: public __object_info_base
{
public:
__hashfunc_info()
:_M_longest_chain(0), _M_accesses(0), _M_hops(0) {}
__hashfunc_info(const __hashfunc_info& o);
__hashfunc_info(__stack_t __stack)
: __object_info_base(__stack),
_M_longest_chain(0), _M_accesses(0), _M_hops(0){}
virtual ~__hashfunc_info() {}
void __merge(const __hashfunc_info& __o);
void __destruct(size_t __chain, size_t __accesses, size_t __hops);
void __write(FILE* __f) const;
float __magnitude() const { return static_cast<float>(_M_hops); }
const char* __advice() const { return "change hash function"; }
private:
size_t _M_longest_chain;
size_t _M_accesses;
size_t _M_hops;
};
inline __hashfunc_info::__hashfunc_info(const __hashfunc_info& __o)
: __object_info_base(__o)
{
_M_longest_chain = __o._M_longest_chain;
_M_accesses = __o._M_accesses;
_M_hops = __o._M_hops;
}
inline void __hashfunc_info::__merge(const __hashfunc_info& __o)
{
_M_longest_chain = __max(_M_longest_chain, __o._M_longest_chain);
_M_accesses += __o._M_accesses;
_M_hops += __o._M_hops;
}
inline void __hashfunc_info::__destruct(size_t __chain, size_t __accesses,
size_t __hops)
{
_M_longest_chain = __max(_M_longest_chain, __chain);
_M_accesses += __accesses;
_M_hops += __hops;
}
/** @brief A hash performance instrumentation line in the stack table. */
class __hashfunc_stack_info: public __hashfunc_info {
public:
__hashfunc_stack_info(const __hashfunc_info& __o) : __hashfunc_info(__o) {}
};
/** @brief Hash performance instrumentation producer. */
class __trace_hash_func
: public __trace_base<__hashfunc_info, __hashfunc_stack_info>
{
public:
__trace_hash_func();
~__trace_hash_func() {}
// Insert a new node at construct with object, callstack and initial size.
void __insert(__object_t __obj, __stack_t __stack);
// Call at destruction/clean to set container final size.
void __destruct(const void* __obj, size_t __chain,
size_t __accesses, size_t __hops);
};
inline __trace_hash_func::__trace_hash_func()
: __trace_base<__hashfunc_info, __hashfunc_stack_info>()
{
__id = "hash-distr";
}
inline void __trace_hash_func::__insert(__object_t __obj, __stack_t __stack)
{
__add_object(__obj, __hashfunc_info(__stack));
}
inline void __hashfunc_info::__write(FILE* __f) const
{
fprintf(__f, "%Zu %Zu %Zu\n", _M_hops, _M_accesses, _M_longest_chain);
}
inline void __trace_hash_func::__destruct(const void* __obj, size_t __chain,
size_t __accesses, size_t __hops)
{
if (!__is_on()) return;
// First find the item from the live objects and update the informations.
__hashfunc_info* __objs = __get_object_info(__obj);
if (!__objs)
return;
__objs->__destruct(__chain, __accesses, __hops);
__retire_object(__obj);
}
//////////////////////////////////////////////////////////////////////////////
// Initialization and report.
//////////////////////////////////////////////////////////////////////////////
inline void __trace_hash_func_init()
{
__tables<0>::_S_hash_func = new __trace_hash_func();
}
inline void __trace_hash_func_report(FILE* __f,
__warning_vector_t& __warnings)
{
if (__tables<0>::_S_hash_func) {
__tables<0>::_S_hash_func->__collect_warnings(__warnings);
__tables<0>::_S_hash_func->__write(__f);
}
}
//////////////////////////////////////////////////////////////////////////////
// Implementations of instrumentation hooks.
//////////////////////////////////////////////////////////////////////////////
inline void __trace_hash_func_construct(const void* __obj)
{
if (!__profcxx_init()) return;
__tables<0>::_S_hash_func->__insert(__obj, __get_stack());
}
inline void __trace_hash_func_destruct(const void* __obj, size_t __chain,
size_t __accesses, size_t __hops)
{
if (!__profcxx_init()) return;
__tables<0>::_S_hash_func->__destruct(__obj, __chain, __accesses, __hops);
}
} // namespace __cxxprof_impl
#endif /* PROFCXX_PROFILER_HASH_FUNC_H__ */
// -*- C++ -*-
//
// Copyright (C) 2009 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 2, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this library; see the file COPYING. If not, write to
// the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
// MA 02111-1307, USA.
// As a special exception, you may use this file as part of a free
// software library without restriction. Specifically, if other files
// instantiate templates or use macros or inline functions from this
// file, or you compile this file and link it with other files to
// produce an executable, this file does not by itself cause the
// resulting executable to be covered by the GNU General Public
// License. This exception does not however invalidate any other
// reasons why the executable file might be covered by the GNU General
// Public License.
/** @file profile/impl/profiler_hashtable_size.cc
* @brief Collection of hashtable size traces.
*/
// Written by Lixia Liu and Silvius Rus.
#ifndef PROFCXX_PROFILER_HASHTABLE_SIZE_H__
#define PROFCXX_PROFILER_HASHTABLE_SIZE_H__ 1
#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <cstdlib>
#include <cstdio>
#include <cstring>
#else
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#endif
#include "profile/impl/profiler.h"
#include "profile/impl/profiler_node.h"
#include "profile/impl/profiler_trace.h"
#include "profile/impl/profiler_state.h"
#include "profile/impl/profiler_container_size.h"
namespace __cxxprof_impl
{
/** @brief Hashtable size instrumentation trace producer. */
class __trace_hashtable_size : public __trace_container_size
{
public:
__trace_hashtable_size() : __trace_container_size()
{
__id = "hashtable-size";
}
};
//////////////////////////////////////////////////////////////////////////////
// Initialization and report.
//////////////////////////////////////////////////////////////////////////////
inline void __trace_hashtable_size_init()
{
__tables<0>::_S_hashtable_size = new __trace_hashtable_size();
}
inline void __trace_hashtable_size_report(FILE* __f,
__warning_vector_t& __warnings)
{
if (__tables<0>::_S_hashtable_size) {
__tables<0>::_S_hashtable_size->__collect_warnings(__warnings);
__tables<0>::_S_hashtable_size->__write(__f);
}
}
//////////////////////////////////////////////////////////////////////////////
// Implementations of instrumentation hooks.
//////////////////////////////////////////////////////////////////////////////
inline void __trace_hashtable_size_construct(const void* __obj, size_t __num)
{
if (!__profcxx_init()) return;
__tables<0>::_S_hashtable_size->__insert(__obj, __get_stack(), __num);
}
inline void __trace_hashtable_size_destruct(const void* __obj, size_t __num,
size_t __inum)
{
if (!__profcxx_init()) return;
__tables<0>::_S_hashtable_size->__destruct(__obj, __num, __inum);
}
inline void __trace_hashtable_size_resize(const void* __obj, size_t __from,
size_t __to)
{
if (!__profcxx_init()) return;
__tables<0>::_S_hashtable_size->__resize(__obj, __from, __to);
}
} // namespace __cxxprof_impl
#endif /* PROFCXX_PROFILER_HASHTABLE_SIZE_H__ */
// -*- C++ -*-
//
// Copyright (C) 2009 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 2, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this library; see the file COPYING. If not, write to
// the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
// MA 02111-1307, USA.
// As a special exception, you may use this file as part of a free
// software library without restriction. Specifically, if other files
// instantiate templates or use macros or inline functions from this
// file, or you compile this file and link it with other files to
// produce an executable, this file does not by itself cause the
// resulting executable to be covered by the GNU General Public
// License. This exception does not however invalidate any other
// reasons why the executable file might be covered by the GNU General
// Public License.
/** @file profile/impl/profiler_map_to_unordered_map.h
* @brief Diagnostics for map to unordered_map.
*/
// Written by Silvius Rus.
#ifndef PROFCXX_PROFILER_MAP_TO_UNORDERED_MAP_H__
#define PROFCXX_PROFILER_MAP_TO_UNORDERED_MAP_H__ 1
#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <cstdlib>
#include <cstdio>
#include <cstring>
#else
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#endif
#include "profile/impl/profiler.h"
#include "profile/impl/profiler_node.h"
#include "profile/impl/profiler_trace.h"
namespace __cxxprof_impl
{
// Cost model. XXX: this must be taken from the machine model instead.
// Map operations:
// - insert: 1.5 * log(size)
// - erase: 1.5 * log(size)
// - find: log(size)
// - iterate: 2.3
// Unordered map operations:
// - insert: 12
// - erase: 12
// - find: 10
// - iterate: 1.7
const float __map_insert_cost_factor = 1.5;
const float __map_erase_cost_factor = 1.5;
const float __map_find_cost_factor = 1;
const float __map_iterate_cost = 2.3;
const float __umap_insert_cost = 12.0;
const float __umap_erase_cost = 12.0;
const float __umap_find_cost = 10.0;
const float __umap_iterate_cost = 1.7;
inline int __log2(size_t __size)
{
for (int __bit_count = sizeof(size_t) - 1; __bit_count >= 0; --__bit_count) {
if ((2 << __bit_count) & __size) {
return __bit_count;
}
}
return 0;
}
inline float __map_insert_cost(size_t __size)
{
return __map_insert_cost_factor * static_cast<float>(__log2(__size));
}
inline float __map_erase_cost(size_t __size)
{
return __map_erase_cost_factor * static_cast<float>(__log2(__size));
}
inline float __map_find_cost(size_t __size)
{
return __map_find_cost_factor * static_cast<float>(__log2(__size));
}
/** @brief A map-to-unordered_map instrumentation line in the object table. */
class __map2umap_info: public __object_info_base
{
public:
__map2umap_info()
: _M_insert(0), _M_erase(0), _M_find(0), _M_iterate(0),
_M_map_cost(0.0), _M_umap_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_map_cost(0.0), _M_umap_cost(0.0), _M_valid(true) {}
virtual ~__map2umap_info() {}
__map2umap_info(const __map2umap_info& o);
void __merge(const __map2umap_info& o);
void __write(FILE* __f) const;
float __magnitude() const { return _M_map_cost - _M_umap_cost; }
const char* __advice() const;
void __record_insert(size_t __size, size_t __count);
void __record_erase(size_t __size, size_t __count);
void __record_find(size_t __size);
void __record_iterate(size_t __count);
void __record_invalidate();
private:
size_t _M_insert;
size_t _M_erase;
size_t _M_find;
size_t _M_iterate;
float _M_umap_cost;
float _M_map_cost;
bool _M_valid;
};
inline const char* __map2umap_info::__advice() const
{
return "change std::map to std::unordered_map";
}
inline __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_map_cost(__o._M_map_cost),
_M_umap_cost(__o._M_umap_cost),
_M_valid(__o._M_valid)
{}
inline void __map2umap_info::__merge(const __map2umap_info& __o)
{
_M_insert += __o._M_insert;
_M_erase += __o._M_erase;
_M_find += __o._M_find;
_M_map_cost += __o._M_map_cost;
_M_umap_cost += __o._M_umap_cost;
_M_valid &= __o._M_valid;
}
inline void __map2umap_info:: __record_insert(size_t __size, size_t __count)
{
_M_insert += __count;
_M_map_cost += __count * __map_insert_cost(__size);
_M_umap_cost += __count * __umap_insert_cost;
}
inline void __map2umap_info:: __record_erase(size_t __size, size_t __count)
{
_M_erase += __count;
_M_map_cost += __count * __map_erase_cost(__size);
_M_umap_cost += __count * __umap_erase_cost;
}
inline void __map2umap_info:: __record_find(size_t __size)
{
_M_find += 1;
_M_map_cost += __map_find_cost(__size);
_M_umap_cost += __umap_find_cost;
}
inline void __map2umap_info:: __record_iterate(size_t __count)
{
_M_iterate += __count;
_M_map_cost += __count * __map_iterate_cost;
_M_umap_cost += __count * __umap_iterate_cost;
}
inline void __map2umap_info:: __record_invalidate()
{
_M_valid = false;
}
inline void __map2umap_info::__write(FILE* __f) const
{
fprintf(__f, "%Zu %Zu %Zu %Zu %.0f %.0f %s\n",
_M_insert, _M_erase, _M_find, _M_iterate, _M_map_cost, _M_umap_cost,
_M_valid ? "valid" : "invalid");
}
/** @brief A map-to-unordered_map instrumentation line in the stack table. */
class __map2umap_stack_info: public __map2umap_info
{
public:
__map2umap_stack_info(const __map2umap_info& o) : __map2umap_info(o) {}
};
/** @brief Map-to-unordered_map instrumentation producer. */
class __trace_map2umap
: public __trace_base<__map2umap_info, __map2umap_stack_info>
{
public:
__trace_map2umap();
};
inline __trace_map2umap::__trace_map2umap()
: __trace_base<__map2umap_info, __map2umap_stack_info>()
{
__id = "map-to-unordered-map";
}
inline void __trace_map_to_unordered_map_init()
{
__tables<0>::_S_map2umap = new __trace_map2umap();
}
inline void __trace_map_to_unordered_map_report(
FILE* __f, __warning_vector_t& __warnings)
{
if (__tables<0>::_S_map2umap) {
__tables<0>::_S_map2umap->__collect_warnings(__warnings);
__tables<0>::_S_map2umap->__write(__f);
}
}
//////////////////////////////////////////////////////////////////////////////
// Implementations of instrumentation hooks.
//////////////////////////////////////////////////////////////////////////////
inline void __trace_map_to_unordered_map_construct(const void* __obj)
{
if (!__profcxx_init()) return;
__tables<0>::_S_map2umap->__add_object(__obj,
__map2umap_info(__get_stack()));
}
inline void __trace_map_to_unordered_map_destruct(const void* __obj)
{
if (!__profcxx_init()) return;
__tables<0>::_S_map2umap->__retire_object(__obj);
}
inline void __trace_map_to_unordered_map_insert(const void* __obj,
size_t __size, size_t __count)
{
if (!__profcxx_init()) return;
__map2umap_info* __info = __tables<0>::_S_map2umap->__get_object_info(__obj);
if (__info) __info->__record_insert(__size, __count);
}
inline void __trace_map_to_unordered_map_erase(const void* __obj,
size_t __size, size_t __count)
{
if (!__profcxx_init()) return;
__map2umap_info* __info = __tables<0>::_S_map2umap->__get_object_info(__obj);
if (__info) __info->__record_erase(__size, __count);
}
inline void __trace_map_to_unordered_map_find(const void* __obj, size_t __size)
{
if (!__profcxx_init()) return;
__map2umap_info* __info = __tables<0>::_S_map2umap->__get_object_info(__obj);
if (__info) __info->__record_find(__size);
}
inline void __trace_map_to_unordered_map_iterate(const void* __obj,
size_t __count)
{
if (!__profcxx_init()) return;
__map2umap_info* __info = __tables<0>::_S_map2umap->__get_object_info(__obj);
if (__info) __info->__record_iterate(__count);
}
inline void __trace_map_to_unordered_map_invalidate(const void* __obj)
{
if (!__profcxx_init()) return;
__map2umap_info* __info = __tables<0>::_S_map2umap->__get_object_info(__obj);
if (__info) __info->__record_invalidate();
}
} // namespace __cxxprof_impl
#endif /* PROFCXX_PROFILER_MAP_TO_UNORDERED_MAP_H__ */
// -*- C++ -*-
//
// Copyright (C) 2009 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 2, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this library; see the file COPYING. If not, write to
// the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
// MA 02111-1307, USA.
// As a special exception, you may use this file as part of a free
// software library without restriction. Specifically, if other files
// instantiate templates or use macros or inline functions from this
// file, or you compile this file and link it with other files to
// produce an executable, this file does not by itself cause the
// resulting executable to be covered by the GNU General Public
// License. This exception does not however invalidate any other
// reasons why the executable file might be covered by the GNU General
// Public License.
/** @file profile/impl/profiler_node.h
* @brief Data structures to represent a single profiling event.
*/
// Written by Lixia Liu and Silvius Rus.
#ifndef PROFCXX_PROFILER_NODE_H__
#define PROFCXX_PROFILER_NODE_H__ 1
#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <cstdio>
#include <cstdint>
#include <cstring>
#else
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#endif
#include <vector>
#if defined HAVE_EXECINFO_H
#include <execinfo.h>
#endif
namespace __cxxprof_impl
{
typedef const void* __object_t;
typedef void* __instruction_address_t;
typedef std::_GLIBCXX_STD_PR::vector<__instruction_address_t> __stack_npt;
typedef __stack_npt* __stack_t;
size_t __stack_max_depth();
inline __stack_t __get_stack()
{
#if defined HAVE_EXECINFO_H
size_t __max_depth = __stack_max_depth();
if (__max_depth == 0)
return NULL;
__stack_npt __buffer(__max_depth);
int __depth = backtrace(&__buffer[0], __max_depth);
__stack_t __stack = new __stack_npt(__depth);
memcpy(&(*__stack)[0], &__buffer[0], __depth * sizeof(__object_t));
return __stack;
#else
return NULL;
#endif
}
inline __size(const __stack_t& __stack)
{
if (!__stack) {
return 0;
} else {
return __stack->size();
}
}
inline void __write(FILE* __f, const __stack_t __stack)
{
if (!__stack) {
return;
}
__stack_npt::const_iterator __it;
for (__it = __stack->begin(); __it != __stack->end(); ++__it) {
fprintf(__f, "%p ", *__it);
}
}
/** @brief Hash function for summary trace using call stack as index. */
class __stack_hash
{
public:
size_t operator()(const __stack_t __s) const
{
if (!__s) {
return 0;
}
uintptr_t __index = 0;
__stack_npt::const_iterator __it;
for (__it = __s->begin(); __it != __s->end(); ++__it) {
__index += reinterpret_cast<uintptr_t>(*__it);
}
return __index;
}
bool operator() (const __stack_t __stack1, const __stack_t __stack2) const
{
if (!__stack1 && !__stack2) return true;
if (!__stack1 || !__stack2) return false;
if (__stack1->size() != __stack2->size()) return false;
size_t __byte_size = __stack1->size() * sizeof(__stack_npt::value_type);
return memcmp(&(*__stack1)[0], &(*__stack2)[0], __byte_size) == 0;
}
};
/** @brief Base class for a line in the object table. */
class __object_info_base
{
public:
__object_info_base() {}
__object_info_base(__stack_t __stack);
__object_info_base(const __object_info_base& o);
virtual ~__object_info_base() {}
bool __is_valid() const { return _M_valid; }
__stack_t __stack() const { return _M_stack; }
virtual void __write(FILE* f) const = 0;
protected:
__stack_t _M_stack;
bool _M_valid;
};
inline __object_info_base::__object_info_base(__stack_t __stack)
{
_M_stack = __stack;
_M_valid = true;
}
inline __object_info_base::__object_info_base(const __object_info_base& __o)
{
_M_stack = __o._M_stack;
_M_valid = __o._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 __cxxprof_impl
#endif /* PROFCXX_PROFILER_NODE_H__ */
// -*- C++ -*-
//
// Copyright (C) 2009 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 2, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this library; see the file COPYING. If not, write to
// the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
// MA 02111-1307, USA.
// As a special exception, you may use this file as part of a free
// software library without restriction. Specifically, if other files
// instantiate templates or use macros or inline functions from this
// file, or you compile this file and link it with other files to
// produce an executable, this file does not by itself cause the
// resulting executable to be covered by the GNU General Public
// License. This exception does not however invalidate any other
// reasons why the executable file might be covered by the GNU General
// Public License.
/** @file profile/impl/profiler_state.cc
* @brief Global profiler state.
*/
// Written by Lixia Liu and Silvius Rus.
#ifndef PROFCXX_PROFILER_STATE_H__
#define PROFCXX_PROFILER_STATE_H__ 1
#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <cstdio>
#else
#include <stdio.h>
#endif
namespace __cxxprof_impl
{
/** @brief Profiling mode on/off state. */
template <int _Unused=0>
class __state
{
public:
static __state<_Unused>* _S_diag_state;
__state() : _M_state(__INVALID) {}
~__state() {}
bool __is_on() { return _M_state == __ON; }
bool __is_off() { return _M_state == __OFF; }
bool __is_invalid() { return _M_state == __INVALID; }
void __turn_on() { _M_state = __ON; }
void __turn_off() { _M_state = __OFF; }
private:
enum __state_type { __ON, __OFF, __INVALID };
__state_type _M_state;
};
template <int _Unused>
__state<_Unused>* __state<_Unused>::_S_diag_state = NULL;
inline bool __is_on()
{
return __state<0>::_S_diag_state && __state<0>::_S_diag_state->__is_on();
}
inline bool __is_off()
{
return __state<0>::_S_diag_state && __state<0>::_S_diag_state->__is_off();
}
inline bool __is_invalid()
{
return (!__state<0>::_S_diag_state
|| __state<0>::_S_diag_state->__is_invalid());
}
inline void __turn_on()
{
if (!__state<0>::_S_diag_state) {
__state<0>::_S_diag_state = new __state<0>();
}
__state<0>::_S_diag_state->__turn_on();
}
inline void __turn_off()
{
if (!__state<0>::_S_diag_state) {
__state<0>::_S_diag_state = new __state<0>();
}
__state<0>::_S_diag_state->__turn_off();
}
} // end namespace __cxxprof_impl
#endif /* PROFCXX_PROFILER_STATE_H__ */
// -*- C++ -*-
//
// Copyright (C) 2009 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
// Foundation; either version 2, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this library; see the file COPYING. If not, write to
// the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
// MA 02111-1307, USA.
// As a special exception, you may use this file as part of a free
// software library without restriction. Specifically, if other files
// instantiate templates or use macros or inline functions from this
// file, or you compile this file and link it with other files to
// produce an executable, this file does not by itself cause the
// resulting executable to be covered by the GNU General Public
// License. This exception does not however invalidate any other
// reasons why the executable file might be covered by the GNU General
// Public License.
/** @file profile/impl/profiler_vector_size.h
* @brief Collection of vector size traces.
*/
// Written by Lixia Liu and Silvius Rus.
#ifndef PROFCXX_PROFILER_VECTOR_SIZE_H__
#define PROFCXX_PROFILER_VECTOR_SIZE_H__ 1
#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <cstdlib>
#include <cstdio>
#include <cstring>
#else
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#endif
#include "profile/impl/profiler.h"
#include "profile/impl/profiler_node.h"
#include "profile/impl/profiler_trace.h"
#include "profile/impl/profiler_state.h"
#include "profile/impl/profiler_container_size.h"
namespace __cxxprof_impl
{
/** @brief Hashtable size instrumentation trace producer. */
class __trace_vector_size : public __trace_container_size
{
public:
__trace_vector_size() : __trace_container_size() { __id = "vector-size"; }
};
//////////////////////////////////////////////////////////////////////////////
// Initialization and report.
//////////////////////////////////////////////////////////////////////////////
inline void __trace_vector_size_init()
{
__tables<0>::_S_vector_size = new __trace_vector_size();
}
inline void __trace_vector_size_report(FILE* __f,
__warning_vector_t& __warnings)
{
if (__tables<0>::_S_vector_size) {
__tables<0>::_S_vector_size->__collect_warnings(__warnings);
__tables<0>::_S_vector_size->__write(__f);
}
}
//////////////////////////////////////////////////////////////////////////////
// Implementations of instrumentation hooks.
//////////////////////////////////////////////////////////////////////////////
inline void __trace_vector_size_construct(const void* __obj, size_t __num)
{
if (!__profcxx_init()) return;
__tables<0>::_S_vector_size->__insert(__obj, __get_stack(), __num);
}
inline void __trace_vector_size_destruct(const void* __obj, size_t __num,
size_t __inum)
{
if (!__profcxx_init()) return;
__tables<0>::_S_vector_size->__destruct(__obj, __num, __inum);
}
inline void __trace_vector_size_resize(const void* __obj, size_t __from,
size_t __to)
{
if (!__profcxx_init()) return;
__tables<0>::_S_vector_size->__resize(__obj, __from, __to);
}
} // namespace __cxxprof_impl
#endif /* PROFCXX_PROFILER_VECTOR_SIZE_H__ */
// Profiling map/multimap implementation -*- C++ -*-
// Copyright (C) 2009 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
/** @file profile/map
* This file is a GNU profile extension to the Standard C++ Library.
*/
#ifndef _GLIBCXX_PROFILE_MAP
#define _GLIBCXX_PROFILE_MAP 1
#include <map>
#include <profile/map.h>
#include <profile/multimap.h>
#endif
// Profiling set/multiset implementation -*- C++ -*-
// Copyright (C) 2009 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
/** @file profile/set
* This file is a GNU profile extension to the Standard C++ Library.
*/
#ifndef _GLIBCXX_PROFILE_SET
#define _GLIBCXX_PROFILE_SET 1
#include <set>
#include <profile/set.h>
#include <profile/multiset.h>
#endif
......@@ -1393,4 +1393,8 @@ _GLIBCXX_END_NESTED_NAMESPACE
# include <debug/bitset>
#endif
#ifdef _GLIBCXX_PROFILE
# include <profile/bitset>
#endif
#endif /* _GLIBCXX_BITSET */
......@@ -72,4 +72,8 @@
# include <debug/deque>
#endif
#ifdef _GLIBCXX_PROFILE
# include <profile/deque>
#endif
#endif /* _GLIBCXX_DEQUE */
......@@ -70,5 +70,9 @@
# include <debug/list>
#endif
#ifdef _GLIBCXX_PROFILE
# include <profile/list>
#endif
#endif /* _GLIBCXX_LIST */
......@@ -65,4 +65,8 @@
# include <debug/map>
#endif
#ifdef _GLIBCXX_PROFILE
# include <profile/map>
#endif
#endif /* _GLIBCXX_MAP */
......@@ -65,4 +65,8 @@
# include <debug/set>
#endif
#ifdef _GLIBCXX_PROFILE
# include <profile/set>
#endif
#endif /* _GLIBCXX_SET */
......@@ -53,7 +53,7 @@
# include <tr1_impl/unordered_map>
#else
# define _GLIBCXX_INCLUDE_AS_CXX0X
#if defined(_GLIBCXX_DEBUG) || defined(_GLIBCXX_PARALLEL)
#if defined(_GLIBCXX_DEBUG) || defined(_GLIBCXX_PARALLEL) || defined(_GLIBCXX_PROFILE)
# define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace _GLIBCXX_STD_D {
# define _GLIBCXX_END_NAMESPACE_TR1 }
# define _GLIBCXX_TR1 _GLIBCXX_STD_D
......@@ -73,6 +73,10 @@
# include <debug/unordered_map>
#endif
#ifdef _GLIBCXX_PROFILE
# include <profile/unordered_map>
#endif
#endif // __GXX_EXPERIMENTAL_CXX0X__
#endif // _GLIBCXX_UNORDERED_MAP
......@@ -53,7 +53,7 @@
# include <tr1_impl/unordered_set>
#else
# define _GLIBCXX_INCLUDE_AS_CXX0X
#if defined(_GLIBCXX_DEBUG) || defined(_GLIBCXX_PARALLEL)
#if defined(_GLIBCXX_DEBUG) || defined(_GLIBCXX_PARALLEL) || defined(_GLIBCXX_PROFILE)
# define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace _GLIBCXX_STD_D {
# define _GLIBCXX_END_NAMESPACE_TR1 }
# define _GLIBCXX_TR1 _GLIBCXX_STD_D
......@@ -73,6 +73,9 @@
# include <debug/unordered_set>
#endif
#ifdef _GLIBCXX_PROFILE
# include <profile/unordered_set>
#endif
#endif // __GXX_EXPERIMENTAL_CXX0X__
#endif // _GLIBCXX_UNORDERED_SET
......@@ -34,7 +34,7 @@
* that both that copyright notice and this permission notice appear
* in supporting documentation. Hewlett-Packard Company makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
ded "as is" without express or implied warranty.
*
*
* Copyright (c) 1996
......@@ -73,5 +73,9 @@
# include <debug/vector>
#endif
#ifdef _GLIBCXX_PROFILE
# include <profile/vector>
#endif
#endif /* _GLIBCXX_VECTOR */
......@@ -409,6 +409,9 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1
_M_erase_node(_Node*, _Node**);
public:
// Expose insert_return_type for profiling mode.
typedef _Insert_Return_Type insert_return_type;
// Insert and erase
_Insert_Return_Type
insert(const value_type& __v)
......
......@@ -38,26 +38,26 @@ test01()
a.resize(98);
a.resize(99);
a.resize(100);
#ifndef _GLIBCXX_DEBUG
#if ! defined _GLIBCXX_DEBUG && ! defined _GLIBCXX_PROFILE
VERIFY( copycounter::copycount == 100 );
#else
VERIFY( copycounter::copycount == 100 + 4 );
#endif
a.resize(99);
a.resize(0);
#ifndef _GLIBCXX_DEBUG
#if ! defined _GLIBCXX_DEBUG && ! defined _GLIBCXX_PROFILE
VERIFY( copycounter::copycount == 100 );
#else
VERIFY( copycounter::copycount == 100 + 6 );
#endif
a.resize(100);
#ifndef _GLIBCXX_DEBUG
#if ! defined _GLIBCXX_DEBUG && ! defined _GLIBCXX_PROFILE
VERIFY( copycounter::copycount == 200 );
#else
VERIFY( copycounter::copycount == 200 + 7 );
#endif
a.clear();
#ifndef _GLIBCXX_DEBUG
#if ! defined _GLIBCXX_DEBUG && ! defined _GLIBCXX_PROFILE
VERIFY( copycounter::copycount == 200 );
#else
VERIFY( copycounter::copycount == 200 + 7 );
......
......@@ -28,7 +28,7 @@ void test01()
typedef std::list<int> list_type;
list_type l;
#ifndef _GLIBCXX_DEBUG
#if ! defined _GLIBCXX_DEBUG && ! defined _GLIBCXX_PROFILE
using std::_List_node;
#else
using std::_GLIBCXX_STD_D::_List_node;
......
// { dg-options "-Wno-deprecated" }
/* testing the gcc instrumented */
#include <ext/hash_map>
using namespace std;
using __gnu_cxx::hash_map;
int main()
{
hash_map <int, int> *tmp;
for (int j=1; j<=10; j++)
{
tmp = new hash_map<int, int>;
// Insert more than default item
for (int i=0; i<10000*j; i++) {
(*tmp)[i]= i;
}
delete tmp;
}
}
// { dg-options "-std=gnu++0x" }
/* testing the gcc instrumented */
#include <unordered_map>
#include <unordered_set>
using std::unordered_map;
using std::unordered_set;
void test_unordered_set()
{
// Test for unordered set
unordered_set <int> *tmp2;
tmp2 = new unordered_set<int>;
tmp2->insert(1);
delete tmp2;
}
void test_unordered_map()
{
unordered_map <int, int> *tmp;
for (int i=0; i<20; i++)
{
tmp = new unordered_map<int, int>(i+2);
// Insert more than default item
for (int j=0; j<10000; j++) {
(*tmp)[j]= j;
}
delete tmp;
}
tmp = new unordered_map<int, int>;
// Insert more than default item
for (int i=0; i<150000; i++) {
// (*tmp)[i] = i;
(*tmp).insert(unordered_map<int, int>::value_type(i, i));
}
(*tmp).erase(1);
delete tmp;
}
int main()
{
test_unordered_set();
test_unordered_map();
}
// Test vector: performance difference 25% (0.444s vs 0.539s)
// Advice: set tmp as 10000
#include <vector>
using std::vector;
int main()
{
vector <int> tmp;
for (int j=0; j<2000; j++)
// Insert more than default item
for (int i=0; i<10000; i++) {
tmp.push_back(i);
}
}
......@@ -41,26 +41,26 @@ test01()
a.resize(98);
a.resize(99);
a.resize(100);
#ifndef _GLIBCXX_DEBUG
#if !defined(_GLIBCXX_DEBUG) && !defined(_GLIBCXX_PROFILE)
VERIFY( copycounter::copycount == 100 + 1 );
#else
VERIFY( copycounter::copycount == 100 + 1 + 4 );
#endif
a.resize(99);
a.resize(0);
#ifndef _GLIBCXX_DEBUG
#if !defined(_GLIBCXX_DEBUG) && !defined(_GLIBCXX_PROFILE)
VERIFY( copycounter::copycount == 100 + 1 );
#else
VERIFY( copycounter::copycount == 100 + 1 + 6 );
#endif
a.resize(100);
#ifndef _GLIBCXX_DEBUG
#if !defined(_GLIBCXX_DEBUG) && !defined(_GLIBCXX_PROFILE)
VERIFY( copycounter::copycount == 200 + 2 );
#else
VERIFY( copycounter::copycount == 200 + 2 + 7 );
#endif
a.clear();
#ifndef _GLIBCXX_DEBUG
#if !defined(_GLIBCXX_DEBUG) && !defined(_GLIBCXX_PROFILE)
VERIFY( copycounter::copycount == 200 + 2 );
#else
VERIFY( copycounter::copycount == 200 + 2 + 7 );
......
......@@ -196,6 +196,9 @@ libgomp_flags=-B${glibcxx_builddir}/../libgomp \
atomic_flags=$(ATOMIC_FLAGS)
parallel_flags="unix/-D_GLIBCXX_PARALLEL/-fopenmp"
# Runs the testsuite in profile mode.
profile_flags = "unix/-D_GLIBCXX_PROFILE"
check-parallel: site.exp
-@(if test ! -d $${libgomp_dir}; then \
echo "Testing parallel mode failed as libgomp not present."; \
......@@ -214,8 +217,17 @@ check-performance-parallel: testsuite_files_performance ${performance_script}
CXXFLAGS="-D_GLIBCXX_PARALLEL -fopenmp $(atomic_flags) $(libgomp_flags)"; export CXXFLAGS; \
${check_performance_script} ${glibcxx_srcdir} ${glibcxx_builddir})
check-profile: site.exp
-@(outputdir=profile; export outputdir; \
if test ! -d $${outputdir}; then \
mkdir $${outputdir}; \
fi; \
srcdir=`$(am__cd) $(srcdir) && pwd`; export srcdir; \
EXPECT=$(EXPECT); export EXPECT; \
$(MAKE) CXXFLAGS="$(atomic_flags) " RUNTESTFLAGS="$(RUNTESTFLAGS) conformance.exp --outdir $${outputdir} --objdir $${outputdir} --target_board=$(profile_flags)" check-DEJAGNU; )
.PHONY: baseline_symbols new-abi-baseline \
check-abi check-compile check-performance check-parallel
check-abi check-compile check-performance check-parallel check-profile
# By adding these files here, automake will remove them for 'make clean'
CLEANFILES = *.txt *.tst *.exe core* filebuf_* tmp* ostream_* *.log *.sum \
......@@ -224,4 +236,4 @@ CLEANFILES = *.txt *.tst *.exe core* filebuf_* tmp* ostream_* *.log *.sum \
# To remove directories.
clean-local:
rm -rf parallel
rm -rf parallel profile
......@@ -299,6 +299,9 @@ libgomp_flags = -B${glibcxx_builddir}/../libgomp \
atomic_flags = $(ATOMIC_FLAGS)
parallel_flags = "unix/-D_GLIBCXX_PARALLEL/-fopenmp"
# Runs the testsuite in profile
profile_flags = "unix/-D_GLIBCXX_PROFILE"
# By adding these files here, automake will remove them for 'make clean'
CLEANFILES = *.txt *.tst *.exe core* filebuf_* tmp* ostream_* *.log *.sum \
testsuite_* site.exp abi_check baseline_symbols *TEST* *.dat \
......@@ -642,12 +645,21 @@ check-performance-parallel: testsuite_files_performance ${performance_script}
CXXFLAGS="-D_GLIBCXX_PARALLEL -fopenmp $(atomic_flags) $(libgomp_flags)"; export CXXFLAGS; \
${check_performance_script} ${glibcxx_srcdir} ${glibcxx_builddir})
check-profile: site.exp
-@(outputdir=profile; export outputdir; \
if test ! -d $${outputdir}; then \
mkdir $${outputdir}; \
fi; \
srcdir=`$(am__cd) $(srcdir) && pwd`; export srcdir; \
EXPECT=$(EXPECT); export EXPECT; \
$(MAKE) CXXFLAGS="$(atomic_flags)" RUNTESTFLAGS="$(RUNTESTFLAGS) conformance.exp --outdir $${outputdir} --objdir $${outputdir} --target_board=$(profile_flags)" check-DEJAGNU; )
.PHONY: baseline_symbols new-abi-baseline \
check-abi check-compile check-performance check-parallel
check-abi check-compile check-performance check-parallel check-profile
# To remove directories.
clean-local:
rm -rf parallel
rm -rf parallel profile
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
......
// { dg-options "-std=gnu++0x -O0 -D_GLIBCXX_PROFILE" }
// { dg-do compile }
// -*- C++ -*-
// Copyright (C) 2006, 2007, 2009 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <map>
#include <vector>
#include <unordered_map>
using std::map;
using std::vector;
using std::unordered_map;
struct dumb_hash {
size_t operator()(int x) const {return 0;}
size_t operator()(int x, int y) const {return x == y;}
};
int main() {
map<int, int> m_to_umap;
vector<int> v_to_list;
unordered_map<int, int> um_too_small;
unordered_map<int, int> um_too_large(1000000);
unordered_map<int, int, dumb_hash, dumb_hash> um_dumb_hash;
for (int i = 0; i < 10000; ++i) {
m_to_umap[i] = i;
v_to_list.insert(v_to_list.begin(), i);
um_too_small[i] = i;
um_too_small[i] = i;
um_dumb_hash[i] = i;
}
}
// -*- C++ -*-
// Copyright (C) 2006, 2007, 2009 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-options "-D_GLIBCXX_PROFILE" }
// { dg-do compile }
#include <stdio.h>
#include <malloc.h>
#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)
{
old_malloc_hook = __malloc_hook;
__malloc_hook = my_malloc_hook;
}
static void *
my_malloc_hook (size_t size, const void *caller)
{
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.
vector<int> v;
__malloc_hook = my_malloc_hook;
return result;
}
int main() {
int* test = (int*) malloc(sizeof(int));
*test = 1;
return *test;
}
// { dg-options "-D_GLIBCXX_DEBUG -D_GLIBCXX_PROFILE" }
// { dg-do compile }
// -*- C++ -*-
// Copyright (C) 2006, 2007, 2009 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <vector>
// { dg-error "Cannot use -D_GLIBCXX_PROFILE with " "" { target *-*-* } 166 }
// { dg-excess-errors "In file included from" }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment