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

Side by Side Diff: base/profiler/stack_sampling_profiler_unittest.cc

Issue 1029183002: Use a less compiler-specific way for preventing inlining / tail-call optimization. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: gcccccccc Created 5 years, 9 months 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 | « no previous file | 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <sstream> 5 #include <sstream>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/profiler/stack_sampling_profiler.h" 10 #include "base/profiler/stack_sampling_profiler.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 63
64 void TargetThread::WaitForThreadStart() { 64 void TargetThread::WaitForThreadStart() {
65 thread_started_event_.Wait(); 65 thread_started_event_.Wait();
66 } 66 }
67 67
68 void TargetThread::SignalThreadToFinish() { 68 void TargetThread::SignalThreadToFinish() {
69 finish_event_.Signal(); 69 finish_event_.Signal();
70 } 70 }
71 71
72 // static 72 // static
73 #if defined(_WIN64) 73 // Disable inlining for this function so that it gets its own stack frame.
74 // Disable optimizations for this function so that it gets its own stack frame. 74 NOINLINE void TargetThread::SignalAndWaitUntilSignaled(
75 #pragma optimize("", off)
76 #endif
77 void TargetThread::SignalAndWaitUntilSignaled(
78 WaitableEvent* thread_started_event, 75 WaitableEvent* thread_started_event,
79 WaitableEvent* finish_event) { 76 WaitableEvent* finish_event) {
80 thread_started_event->Signal(); 77 thread_started_event->Signal();
78 volatile int x = 1;
81 finish_event->Wait(); 79 finish_event->Wait();
80 x = 0; // Prevent tail call to WaitableEvent::Wait().
81 ALLOW_UNUSED_LOCAL(x);
82 } 82 }
83 #if defined(_WIN64)
84 #pragma optimize("", on)
85 #endif
86 83
87 // Called on the profiler thread when complete. Collects profiles produced by 84 // Called on the profiler thread when complete. Collects profiles produced by
88 // the profiler, and signals an event to allow the main thread to know that that 85 // the profiler, and signals an event to allow the main thread to know that that
89 // the profiler is done. 86 // the profiler is done.
90 void SaveProfilesAndSignalEvent(std::vector<Profile>* profiles, 87 void SaveProfilesAndSignalEvent(std::vector<Profile>* profiles,
91 WaitableEvent* event, 88 WaitableEvent* event,
92 const std::vector<Profile>& pending_profiles) { 89 const std::vector<Profile>& pending_profiles) {
93 *profiles = pending_profiles; 90 *profiles = pending_profiles;
94 event->Signal(); 91 event->Signal();
95 } 92 }
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 params.bursts = 1; 312 params.bursts = 1;
316 params.samples_per_burst = 2; 313 params.samples_per_burst = 2;
317 314
318 std::vector<Profile> profiles; 315 std::vector<Profile> profiles;
319 CaptureProfiles(params, &profiles, TimeDelta::FromMilliseconds(50)); 316 CaptureProfiles(params, &profiles, TimeDelta::FromMilliseconds(50));
320 317
321 EXPECT_TRUE(profiles.empty()); 318 EXPECT_TRUE(profiles.empty());
322 } 319 }
323 320
324 } // namespace tracked_objects 321 } // namespace tracked_objects
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698