From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22137 invoked by alias); 14 Oct 2014 09:03:07 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 22101 invoked by uid 89); 14 Oct 2014 09:03:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mail-wg0-f45.google.com Received: from mail-wg0-f45.google.com (HELO mail-wg0-f45.google.com) (74.125.82.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Tue, 14 Oct 2014 09:03:05 +0000 Received: by mail-wg0-f45.google.com with SMTP id m15so10247714wgh.4 for ; Tue, 14 Oct 2014 02:03:01 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.194.81.6 with SMTP id v6mr3616276wjx.39.1413277381517; Tue, 14 Oct 2014 02:03:01 -0700 (PDT) Received: by 10.194.20.74 with HTTP; Tue, 14 Oct 2014 02:03:01 -0700 (PDT) In-Reply-To: <1413222308-25753-4-git-send-email-dmalcolm@redhat.com> References: <1413222308-25753-1-git-send-email-dmalcolm@redhat.com> <1413222308-25753-4-git-send-email-dmalcolm@redhat.com> Date: Tue, 14 Oct 2014 09:14:00 -0000 Message-ID: Subject: Re: [PATCH 3/5] timevar.h: Add an auto_timevar class From: Richard Biener To: David Malcolm Cc: jit@gcc.gnu.org, GCC Patches Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2014-10/txt/msg01219.txt.bz2 On Mon, Oct 13, 2014 at 7:45 PM, David Malcolm wrote: > This is used in a couple of places in jit/jit-playback.c to ensure > that we pop the timevar on every exit path from a function. > > I could rewrite them if need be, but it does simplify things. Sorry to be bikeshedding but auto_timevar sounds odd - this is just a one-element timevar stack. Don't have a real better name though :/ Maybe timevar_pushpop ? Otherwise this looks ok. Thanks, Richard. > Written by Tom Tromey. > > gcc/ChangeLog: > * timevar.h (class auto_timevar): New class. > --- > gcc/timevar.h | 24 ++++++++++++++++++++++++ > 1 file changed, 24 insertions(+) > > diff --git a/gcc/timevar.h b/gcc/timevar.h > index 6703cc9..f018e39 100644 > --- a/gcc/timevar.h > +++ b/gcc/timevar.h > @@ -110,6 +110,30 @@ timevar_pop (timevar_id_t tv) > timevar_pop_1 (tv); > } > > +// This is a simple timevar wrapper class that pushes a timevar in its > +// constructor and pops the timevar in its destructor. > +class auto_timevar > +{ > + public: > + auto_timevar (timevar_id_t tv) > + : m_tv (tv) > + { > + timevar_push (m_tv); > + } > + > + ~auto_timevar () > + { > + timevar_pop (m_tv); > + } > + > + private: > + > + // Private to disallow copies. > + auto_timevar (const auto_timevar &); > + > + timevar_id_t m_tv; > +}; > + > extern void print_time (const char *, long); > > #endif /* ! GCC_TIMEVAR_H */ > -- > 1.8.5.3 >