From patchwork Thu Jun 24 18:53:45 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 56817 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 21599B6F1A for ; Fri, 25 Jun 2010 04:54:05 +1000 (EST) Received: (qmail 20472 invoked by alias); 24 Jun 2010 18:54:00 -0000 Received: (qmail 20454 invoked by uid 22791); 24 Jun 2010 18:53:59 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org Received: from vsmtp4.tin.it (HELO vsmtp4.tin.it) (212.216.176.224) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 24 Jun 2010 18:53:52 +0000 Received: from [192.168.0.4] (79.36.197.210) by vsmtp4.tin.it (8.5.113) id 4BCE3CBE05D66EE6; Thu, 24 Jun 2010 20:53:49 +0200 Message-ID: <4C23A9B9.30505@oracle.com> Date: Thu, 24 Jun 2010 20:53:45 +0200 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9) Gecko/20100317 SUSE/3.0.4-1.1.1 Thunderbird/3.0.4 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: libstdc++ Subject: [v3] Further small tweak to profile/impl X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Hi, tested x86_64-linux check-profile, committed. Paolo. ////////////////////// 2010-06-24 Paolo Carlini * include/profile/impl/profiler_trace.h (__trace_base<>:: __trace_base()): Move inline, simplify; formatting tweaks. * include/profile/impl/profiler_hash_func.h: Formatting tweaks. Index: include/profile/impl/profiler_hash_func.h =================================================================== --- include/profile/impl/profiler_hash_func.h (revision 161327) +++ include/profile/impl/profiler_hash_func.h (working copy) @@ -50,15 +50,15 @@ 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) { } - + : __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) { } - + : __object_info_base(__stack), _M_longest_chain(0), + _M_accesses(0), _M_hops(0) { } + virtual ~__hashfunc_info() { } void Index: include/profile/impl/profiler_trace.h =================================================================== --- include/profile/impl/profiler_trace.h (revision 161327) +++ include/profile/impl/profiler_trace.h (working copy) @@ -190,9 +190,14 @@ class __trace_base { public: - __trace_base(); - virtual ~__trace_base() {} + // 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), + __stack_table_byte_size(0), __id(0) { } + virtual ~__trace_base() { } + void __add_object(__object_t object, __object_info __info); __object_info* __get_object_info(__object_t __object); void __retire_object(__object_t __object); @@ -229,18 +234,6 @@ } template - __trace_base<__object_info, __stack_info>:: - __trace_base() - { - // Do not pick the initial size too large, as we don't know which - // diagnostics are more active. - __object_table.rehash(10000); - __stack_table.rehash(10000); - __stack_table_byte_size = 0; - __id = 0; - } - - template void __trace_base<__object_info, __stack_info>:: __add_object(__object_t __object, __object_info __info) @@ -326,19 +319,16 @@ __trace_base<__object_info, __stack_info>:: __write(FILE* __f) { - typename __stack_table_t::iterator __it; - - for (__it = __stack_table.begin(); __it != __stack_table.end(); ++__it) - { - if (__it->second.__is_valid()) - { - std::fprintf(__f, __id); - std::fprintf(__f, "|"); - __gnu_profile::__write(__f, __it->first); - std::fprintf(__f, "|"); - __it->second.__write(__f); - } - } + for (typename __stack_table_t::iterator __it + = __stack_table.begin(); __it != __stack_table.end(); ++__it) + if (__it->second.__is_valid()) + { + std::fprintf(__f, __id); + std::fprintf(__f, "|"); + __gnu_profile::__write(__f, __it->first); + std::fprintf(__f, "|"); + __it->second.__write(__f); + } } inline std::size_t @@ -414,18 +404,17 @@ *(__file_name + __root_len) = '.'; __builtin_memcpy(__file_name + __root_len + 1, __extension, __ext_len + 1); + FILE* __out_file = std::fopen(__file_name, "w"); - if (__out_file) + if (!__out_file) { - delete[] __file_name; - return __out_file; - } - else - { std::fprintf(stderr, "Could not open trace file '%s'.\n", __file_name); std::abort(); } + + delete[] __file_name; + return __out_file; } struct __warn @@ -544,8 +533,10 @@ struct __cost_factor_writer { FILE* __file; - __cost_factor_writer(FILE* __f) : __file(__f) { } - + + __cost_factor_writer(FILE* __f) + : __file(__f) { } + void operator() (const __cost_factor* __factor) { std::fprintf(__file, "%s = %f\n", __factor->__env_var, @@ -565,7 +556,7 @@ struct __cost_factor_setter { void - operator() (__cost_factor* __factor) + operator()(__cost_factor* __factor) { // Look it up in the process environment first. const char* __env_value = std::getenv(__factor->__env_var); @@ -663,7 +654,7 @@ * The common path is inlined fully. */ inline bool - __profcxx_init(void) + __profcxx_init() { if (__is_invalid()) __profcxx_init_unconditional();