• David 'Digit' Turner's avatar
    Introduce base::trace_event::TraceArguments helper class. · eebbd7f6
    David 'Digit' Turner authored
    NOTE: This a reland of [1] which got reverted in [2].
    
    This CL introduces the TraceArguments helper class to simplify
    the way TRACE_EVENTXXX macro named arguments are passed to the
    trace log. By using a small dedicated data structure, it is
    possible to generate less code at each trace call site,
    compared to the old way that relies on passing 5 specially
    crafted arguments to TraceLog methods.
    
    For example, this optimization can save about 12 kiB in
    libmonochrome.so for the 32-bit ARM build of Chrome on Android.
    For more details, see corresponding bug entry.
    
    This CL does the following:
    
    - Introduce the new class in base/trace_event/trace_arguments.h
    
    - Move the definition of TraceValue to trace_arguments.h and
      augment the union with templated methods to support easy
      initialization from a large set of C++ value types.
    
    - Add new TraceLog methods to add trace events using an
      optional TraceArguments parameter, instead of a bag of
      5 ones (count + names + types + values + convertables).
    
    - Simplify internal templates using C++11 universal references
      and std::forward<> to remove special-casing convertable
      arguments in trace event calls.
    
    - Remove the now obsolete TraceValueUnion type from trace_event.h
    
    - Update base/trace_event/ code to use TraceArguments and the
      new TraceEvent move operations.
    
    - Note that this keeps a few forwarding data types, values and
      methods to avoid other direct callers from the Chromium tree,
      these will be updated in future CLs. One Blink header needs
      to be modified though because it specializes a template
      defined in trace_arguments.h, to support sending WTF::CString
      references as trace arguments.
    
    BUG=898794
    R=oysteine@chromium.org,chiniforooshan@chromium.org,alexiln@chromium.org,primiano@chromium.org,torne@chromium.org
    TBR=torne@chromium.org,primiano@chromium.org
    
    [1] https://chromium-review.googlesource.com/c/1298997
    [2] https://chromium-review.googlesource.com/c/1305250
    
    Change-Id: I67fa434ab1c29b65abd0f327d1c9d27973f54f6a
    Reviewed-on: https://chromium-review.googlesource.com/c/1318919
    Commit-Queue: David Turner <digit@chromium.org>
    Reviewed-by: default avatarAlexandr Ilin <alexilin@chromium.org>
    Reviewed-by: default avataroysteine <oysteine@chromium.org>
    Reviewed-by: default avatarDavid Turner <digit@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#615099}
    eebbd7f6
trace_event.h 46.8 KB