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

Side by Side Diff: src/runtime-profiler.cc

Issue 7309013: Fix a few issues breaking cctest/test-lockers/Regress1433: (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « src/runtime-profiler.h ('k') | src/v8threads.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 #ifdef ENABLE_LOGGING_AND_PROFILING 316 #ifdef ENABLE_LOGGING_AND_PROFILING
317 Atomic32 old_state = NoBarrier_CompareAndSwap(&state_, 0, -1); 317 Atomic32 old_state = NoBarrier_CompareAndSwap(&state_, 0, -1);
318 ASSERT(old_state >= -1); 318 ASSERT(old_state >= -1);
319 if (old_state != 0) return false; 319 if (old_state != 0) return false;
320 semaphore_->Wait(); 320 semaphore_->Wait();
321 #endif 321 #endif
322 return true; 322 return true;
323 } 323 }
324 324
325 325
326 void RuntimeProfiler::WakeUpRuntimeProfilerThreadBeforeShutdown() { 326 void RuntimeProfiler::StopRuntimeProfilerThreadBeforeShutdown(Thread* thread) {
327 #ifdef ENABLE_LOGGING_AND_PROFILING 327 #ifdef ENABLE_LOGGING_AND_PROFILING
328 semaphore_->Signal(); 328 // Do a fake increment. If the profiler is waiting on the semaphore,
329 // the returned state is 0, which can be left as an initial state in
330 // case profiling is restarted later. If the profiler is not
331 // waiting, the increment will prevent it from waiting, but has to
332 // be undone after the profiler is stopped.
333 Atomic32 new_state = NoBarrier_AtomicIncrement(&state_, 1);
334 ASSERT(new_state >= 0);
335 if (new_state == 0) {
336 // The profiler thread is waiting. Wake it up. It must check for
337 // stop conditions before attempting to wait again.
338 semaphore_->Signal();
339 }
340 thread->Join();
341 // The profiler thread is now stopped. Undo the increment in case it
342 // was not waiting.
343 if (new_state != 0) {
344 NoBarrier_AtomicIncrement(&state_, -1);
345 }
329 #endif 346 #endif
330 } 347 }
331 348
332 349
333 void RuntimeProfiler::RemoveDeadSamples() { 350 void RuntimeProfiler::RemoveDeadSamples() {
334 for (int i = 0; i < kSamplerWindowSize; i++) { 351 for (int i = 0; i < kSamplerWindowSize; i++) {
335 Object* function = sampler_window_[i]; 352 Object* function = sampler_window_[i];
336 if (function != NULL && !HeapObject::cast(function)->IsMarked()) { 353 if (function != NULL && !HeapObject::cast(function)->IsMarked()) {
337 sampler_window_[i] = NULL; 354 sampler_window_[i] = NULL;
338 } 355 }
(...skipping 12 matching lines...) Expand all
351 #ifdef ENABLE_LOGGING_AND_PROFILING 368 #ifdef ENABLE_LOGGING_AND_PROFILING
352 if (!RuntimeProfiler::IsSomeIsolateInJS()) { 369 if (!RuntimeProfiler::IsSomeIsolateInJS()) {
353 return RuntimeProfiler::WaitForSomeIsolateToEnterJS(); 370 return RuntimeProfiler::WaitForSomeIsolateToEnterJS();
354 } 371 }
355 #endif 372 #endif
356 return false; 373 return false;
357 } 374 }
358 375
359 376
360 } } // namespace v8::internal 377 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime-profiler.h ('k') | src/v8threads.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698