Commit 2453745c authored by Bartek Nowierski's avatar Bartek Nowierski Committed by Commit Bot

Add a trivial unwrapper option for perf testing

In this variant, the unwrapper does the least possible amount of work,
by simply clearing the generation bit. This is good for perf testing of
only the wrapper side.

Furthermore, it allows perf testing of partial wrapper implementations
that don't leave the wrapped pointer in a good state, but it doesn't
matter, because the unwrapper ignores that state.

Bug: 1073933
Change-Id: Ied6f7683888e321fb2992eb3124beb899f53e843
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2306489
Commit-Queue: Bartek Nowierski <bartekn@chromium.org>
Auto-Submit: Bartek Nowierski <bartekn@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#789793}
parent d1c934c3
...@@ -331,3 +331,5 @@ vs-chromium-project.txt ...@@ -331,3 +331,5 @@ vs-chromium-project.txt
# Ignore the default results output directory for tools/run-swarmed.py # Ignore the default results output directory for tools/run-swarmed.py
/results /results
.cache
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "build/build_config.h" #include "build/build_config.h"
#define CHECKED_PTR2_USE_NO_OP_WRAPPER 0 #define CHECKED_PTR2_USE_NO_OP_WRAPPER 0
#define CHECKED_PTR2_USE_TRIVIAL_UNWRAPPER 0
// Set it to 1 to avoid branches when checking if per-pointer protection is // Set it to 1 to avoid branches when checking if per-pointer protection is
// enabled. // enabled.
...@@ -534,13 +535,21 @@ class CheckedPtr { ...@@ -534,13 +535,21 @@ class CheckedPtr {
// dereferenced. It is allowed to crash on nullptr (it may or may not), // dereferenced. It is allowed to crash on nullptr (it may or may not),
// because it knows that the caller will crash on nullptr. // because it knows that the caller will crash on nullptr.
ALWAYS_INLINE T* GetForDereference() const { ALWAYS_INLINE T* GetForDereference() const {
#if CHECKED_PTR2_USE_TRIVIAL_UNWRAPPER
return static_cast<T*>(Impl::UnsafelyUnwrapPtrForComparison(wrapped_ptr_));
#else
return static_cast<T*>(Impl::SafelyUnwrapPtrForDereference(wrapped_ptr_)); return static_cast<T*>(Impl::SafelyUnwrapPtrForDereference(wrapped_ptr_));
#endif
} }
// This getter is meant for situations where the raw pointer is meant to be // This getter is meant for situations where the raw pointer is meant to be
// extracted outside of this class, but not necessarily with an intention to // extracted outside of this class, but not necessarily with an intention to
// dereference. It mustn't crash on nullptr. // dereference. It mustn't crash on nullptr.
ALWAYS_INLINE T* GetForExtraction() const { ALWAYS_INLINE T* GetForExtraction() const {
#if CHECKED_PTR2_USE_TRIVIAL_UNWRAPPER
return static_cast<T*>(Impl::UnsafelyUnwrapPtrForComparison(wrapped_ptr_));
#else
return static_cast<T*>(Impl::SafelyUnwrapPtrForExtraction(wrapped_ptr_)); return static_cast<T*>(Impl::SafelyUnwrapPtrForExtraction(wrapped_ptr_));
#endif
} }
// This getter is meant *only* for situations where the pointer is meant to be // This getter is meant *only* for situations where the pointer is meant to be
// compared (guaranteeing no dereference or extraction outside of this class). // compared (guaranteeing no dereference or extraction outside of this class).
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment