• Etienne Bergeron's avatar
    Avoid execution of stack checks when HandleVerifier is not enabled · 3d1d83a9
    Etienne Bergeron authored
    This CL is removing the stack checks executed in
      HandleVerifier::StartTracking(...)
      HandleVerifier::StopTracking(...)
    These stack checks were executed even hen the HandleVerifier
    is not enabled.
    
    There are three major changes:
    
    1) Lift out the body of the tracking functions to a separate
       function.
    
       void StartTracking(...) {
         if (enable_)
           StartTrackingImpl(...);  // StartTrackingImpl -> no-inline.
       }
    
       The intend of this change is to ensure no large local variable
       (e.g. StackFrame) is using space on the stack. When enable_ is
       false, no stack checks are executed.
    
    
    2) Lift the error reporting to a no-inline function
         ReportErrorOnScopedHandleOperation(...)
       These error reporting function make a local copy of the creation
       stackframe. Even if the error reporting code was not executed, the
       required local variables were accounted into the total stack size
       used by the tracking functions.
    
    3) Avoid copy of large objects to local variables
    
       Some tracking functions were making a local copy of the handle
       information.
          ScopedHandleVerifierInfo other = i->second;
       This class includes an instance of StackFrame (which is large).
       If possible, it's better to avoid the copy and the local variable
       needed on the stack.
    
    Bug: 1103763
    Change-Id: I01644028b85e4ee856b1a6c4fd4e107eb82dea07
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2291650
    Commit-Queue: Etienne Bergeron <etienneb@chromium.org>
    Reviewed-by: default avatarWill Harris <wfh@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#788615}
    3d1d83a9
scoped_handle_verifier.cc 7.71 KB