Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(306)

Side by Side Diff: src/core/SkTraceEvent.h

Issue 702883002: Whitelist intentionally racy TRACE_EVENT reads and writes. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: this volatile makes no sense. Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/core/SkDynamicAnnotations.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014 Google Inc. 1 // Copyright (c) 2014 Google Inc.
2 // 2 //
3 // Use of this source code is governed by a BSD-style license that can be 3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file. 4 // found in the LICENSE file.
5 5
6 // This header file defines the set of trace_event macros without specifying 6 // This header file defines the set of trace_event macros without specifying
7 // how the events actually get collected and stored. If you need to expose trace 7 // how the events actually get collected and stored. If you need to expose trace
8 // events to some other universe, you can copy-and-paste this file as well as 8 // events to some other universe, you can copy-and-paste this file as well as
9 // trace_event.h, modifying the macros contained there as necessary for the 9 // trace_event.h, modifying the macros contained there as necessary for the
10 // target platform. The end result is that multiple libraries can funnel events 10 // target platform. The end result is that multiple libraries can funnel events
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 // again under lock. 155 // again under lock.
156 // 156 //
157 // Without the use of these static category pointers and enabled flags all 157 // Without the use of these static category pointers and enabled flags all
158 // trace points would carry a significant performance cost of acquiring a lock 158 // trace points would carry a significant performance cost of acquiring a lock
159 // and resolving the category. 159 // and resolving the category.
160 160
161 #ifndef SkTraceEvent_DEFINED 161 #ifndef SkTraceEvent_DEFINED
162 #define SkTraceEvent_DEFINED 162 #define SkTraceEvent_DEFINED
163 163
164 #include "SkEventTracer.h" 164 #include "SkEventTracer.h"
165 #include "SkDynamicAnnotations.h"
165 166
166 // By default, const char* argument values are assumed to have long-lived scope 167 // By default, const char* argument values are assumed to have long-lived scope
167 // and will not be copied. Use this macro to force a const char* to be copied. 168 // and will not be copied. Use this macro to force a const char* to be copied.
168 #define TRACE_STR_COPY(str) \ 169 #define TRACE_STR_COPY(str) \
169 skia::tracing_internals::TraceStringWithCopy(str) 170 skia::tracing_internals::TraceStringWithCopy(str)
170 171
171 // By default, uint64 ID argument values are not mangled with the Process ID in 172 // By default, uint64 ID argument values are not mangled with the Process ID in
172 // TRACE_EVENT_ASYNC macros. Use this macro to force Process ID mangling. 173 // TRACE_EVENT_ASYNC macros. Use this macro to force Process ID mangling.
173 #define TRACE_ID_MANGLE(id) \ 174 #define TRACE_ID_MANGLE(id) \
174 skia::tracing_internals::TraceID::ForceMangle(id) 175 skia::tracing_internals::TraceID::ForceMangle(id)
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 // const char* name, 758 // const char* name,
758 // SkEventTracer::Handle id) 759 // SkEventTracer::Handle id)
759 #define TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION \ 760 #define TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION \
760 SkEventTracer::GetInstance()->updateTraceEventDuration 761 SkEventTracer::GetInstance()->updateTraceEventDuration
761 762
762 // These operations are atomic in the Chrome tracing implementation 763 // These operations are atomic in the Chrome tracing implementation
763 // to cater to ARM's weak memory consistency; we're just doing read/ 764 // to cater to ARM's weak memory consistency; we're just doing read/
764 // write here because it's not strictly needed for correctness. 765 // write here because it's not strictly needed for correctness.
765 // So says Nat. 766 // So says Nat.
766 // FIXME 767 // FIXME
768 //
769 // Skia addition: we mark these as unprotected reads and writes to shut up TSAN.
767 770
768 #define TRACE_EVENT_API_ATOMIC_WORD intptr_t 771 #define TRACE_EVENT_API_ATOMIC_WORD intptr_t
769 #define TRACE_EVENT_API_ATOMIC_LOAD(var) (*(&var)) 772 #define TRACE_EVENT_API_ATOMIC_LOAD(var) SK_ANNOTATE_UNPROTECTED_READ(var)
770 #define TRACE_EVENT_API_ATOMIC_STORE(var, value) (var=value) 773 #define TRACE_EVENT_API_ATOMIC_STORE(var, value) SK_ANNOTATE_UNPROTECTED_WRITE(& var, value)
771 774
772 // Defines visibility for classes in trace_event.h 775 // Defines visibility for classes in trace_event.h
773 #define TRACE_EVENT_API_CLASS_EXPORT SK_API 776 #define TRACE_EVENT_API_CLASS_EXPORT SK_API
774 777
775 // The thread buckets for the sampling profiler. 778 // The thread buckets for the sampling profiler.
776 TRACE_EVENT_API_CLASS_EXPORT extern \ 779 TRACE_EVENT_API_CLASS_EXPORT extern \
777 TRACE_EVENT_API_ATOMIC_WORD g_trace_state[3]; 780 TRACE_EVENT_API_ATOMIC_WORD g_trace_state[3];
778 781
779 #define TRACE_EVENT_API_THREAD_BUCKET(thread_bucket) \ 782 #define TRACE_EVENT_API_THREAD_BUCKET(thread_bucket) \
780 g_trace_state[thread_bucket] 783 g_trace_state[thread_bucket]
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
1236 } 1239 }
1237 1240
1238 private: 1241 private:
1239 const char* previous_state_; 1242 const char* previous_state_;
1240 }; 1243 };
1241 1244
1242 } // namespace tracing_internals 1245 } // namespace tracing_internals
1243 } // namespace skia 1246 } // namespace skia
1244 1247
1245 #endif 1248 #endif
OLDNEW
« no previous file with comments | « include/core/SkDynamicAnnotations.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698