From: Richard Biener <richard.guenther@gmail.com>
To: David Malcolm <dmalcolm@redhat.com>
Cc: jit@gcc.gnu.org, GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH 3/5] timevar.h: Add an auto_timevar class
Date: Wed, 01 Jan 2014 00:00:00 -0000 [thread overview]
Message-ID: <CAFiYyc30e=H0aObkGg0Cfk-srBFbsxsg5MRAFKPVw-wk5DV1bQ@mail.gmail.com> (raw)
In-Reply-To: <1413301915.9513.68.camel@surprise>
On Tue, Oct 14, 2014 at 5:51 PM, David Malcolm <dmalcolm@redhat.com> wrote:
> On Tue, 2014-10-14 at 11:03 +0200, Richard Biener wrote:
>> On Mon, Oct 13, 2014 at 7:45 PM, David Malcolm <dmalcolm@redhat.com> 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.
>
> Sorry that the usage examples didn't make it through in my original
> email; these are in patch 06/10 in gcc/jit/jit-playback.c and look like
> this:
>
> playback::context::
> compile ()
> {
> ... lots of code...
>
> {
> auto_timevar assemble_timevar (TV_ASSEMBLE);
>
> ... lots of code, with multiple return paths...
>
> }
>
> }
>
> the idea being that the timevar_pop happens implicitly at the exit from
> the scope (e.g. via one of the error-handling returns).
>
> FWIW I rather like the current name: I think of it as an RAII-style way
> of not having to manually call timevar_pop.
>
> The "auto_" prefix to me evokes both such RAII types as "auto_ptr" and
> "auto_vec", and the fact that it's intended to be on the stack i.e. have
> "auto" storage class.
Yeah, I got that. Anyway, objection withdrawn (ok, it really wasn't an
objection).
The patch is ok.
Thanks,
Richard.
>> 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
>> >
>
>
prev parent reply other threads:[~2014-10-15 7:44 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-01 0:00 [PATCH 0/5] Merger of jit branch (v2) David Malcolm
2014-01-01 0:00 ` [PATCH 4/5] State cleanups David Malcolm
2014-01-01 0:00 ` [PATCH 4/5] State cleanups -- also note for MPX work Jeff Law
2014-01-01 0:00 ` David Malcolm
2014-01-01 0:00 ` Jeff Law
2014-01-01 0:00 ` [PATCH 2/5] gcc: configure and Makefile changes needed by jit David Malcolm
2014-01-01 0:00 ` Jeff Law
2014-01-01 0:00 ` David Malcolm
2014-01-01 0:00 ` Joseph S. Myers
2014-01-01 0:00 ` Jeff Law
2014-01-01 0:00 ` David Malcolm
2014-01-01 0:00 ` [PATCH] Avoid the need to install when running the jit testsuite David Malcolm
2014-01-01 0:00 ` Joseph S. Myers
2014-01-01 0:00 ` [jit] Drop libgccjit.pc David Malcolm
2014-01-01 0:00 ` Basile Starynkevitch
2014-01-01 0:00 ` David Malcolm
2014-01-01 0:00 ` [PATCH 1/5] libiberty: Expose choose_tmpdir, and fix constness of return type David Malcolm
2014-01-01 0:00 ` Jeff Law
2014-01-01 0:00 ` David Malcolm
2014-01-01 0:00 ` Patches 5-10 of jit merger (was: Re: [PATCH 0/5] Merger of jit branch (v2)) David Malcolm
2014-01-01 0:00 ` [PATCH 05/10] JIT-related changes outside of jit subdir David Malcolm
2014-01-01 0:00 ` Joseph S. Myers
2014-01-01 0:00 ` [jit] Add Sphinx to install.texi David Malcolm
2014-01-01 0:00 ` Joseph S. Myers
2014-01-01 0:00 ` Gerald Pfeifer
2014-01-01 0:00 ` David Malcolm
2014-01-01 0:00 ` [jit] Tweaks " David Malcolm
2014-01-01 0:00 ` [PATCH 05/10] JIT-related changes outside of jit subdir Jeff Law
2014-01-01 0:00 ` [PATCH 06/10] Heart of the JIT implementation (was: Re: [PATCH 0/5] Merger of jit branch (v2)) David Malcolm
2014-01-01 0:00 ` Joseph S. Myers
2014-01-01 0:00 ` [jit] Error-handling within gcc::jit::dump David Malcolm
2014-01-01 0:00 ` Joseph S. Myers
2014-01-01 0:00 ` [PATCH 06/10] Heart of the JIT implementation (was: Re: [PATCH 0/5] Merger of jit branch (v2)) David Malcolm
2014-01-01 0:00 ` Joseph S. Myers
2014-01-01 0:00 ` [PATCH 06/10] Heart of the JIT implementation Jeff Law
2014-01-01 0:00 ` [PATCH 07/10] Testsuite for the JIT (Re: Patches 5-10 of jit merger (was: Re: [PATCH 0/5] Merger of jit branch (v2))) David Malcolm
2014-01-01 0:00 ` [PATCH 07/10] Testsuite for the JIT (Re: Patches 5-10 of jit merger Jeff Law
2014-01-01 0:00 ` Mike Stump
2014-01-01 0:00 ` [PATCH 10/10] ChangeLog files (Re: Patches 5-10 of jit merger (was: Re: [PATCH 0/5] Merger of jit branch (v2))) David Malcolm
2014-01-01 0:00 ` [PATCH 10/10] ChangeLog files (Re: Patches 5-10 of jit merger Jeff Law
2014-01-01 0:00 ` [PATCH 09/10] Prebuilt texinfo documentation for the JIT library (Re: Patches 5-10 of jit merger) David Malcolm
2014-01-01 0:00 ` Jeff Law
2014-01-01 0:00 ` [PATCH 08/10] Documentation " David Malcolm
2014-01-01 0:00 ` Jeff Law
2014-01-01 0:00 ` [jit] Update the docs David Malcolm
2014-01-01 0:00 ` [PATCH 3/5] timevar.h: Add an auto_timevar class David Malcolm
2014-01-01 0:00 ` Richard Biener
2014-01-01 0:00 ` David Malcolm
2014-01-01 0:00 ` Richard Biener [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAFiYyc30e=H0aObkGg0Cfk-srBFbsxsg5MRAFKPVw-wk5DV1bQ@mail.gmail.com' \
--to=richard.guenther@gmail.com \
--cc=dmalcolm@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jit@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).