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

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

Issue 9836108: Rollback of r11015, r11014, r11011, r11010 in trunk branch. (Closed) Base URL: https://v8.googlecode.com/svn/trunk
Patch Set: Finish file upload Created 8 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 | Annotate | Revision Log
« no previous file with comments | « src/runtime-profiler.h ('k') | src/v8.h » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 // Number of times a function has to be seen on the stack before it is 65 // Number of times a function has to be seen on the stack before it is
66 // optimized. 66 // optimized.
67 static const int kProfilerTicksBeforeOptimization = 2; 67 static const int kProfilerTicksBeforeOptimization = 2;
68 68
69 // Maximum size in bytes of generated code for a function to be optimized 69 // Maximum size in bytes of generated code for a function to be optimized
70 // the very first time it is seen on the stack. 70 // the very first time it is seen on the stack.
71 static const int kMaxSizeEarlyOpt = 500; 71 static const int kMaxSizeEarlyOpt = 500;
72 72
73 73
74 Atomic32 RuntimeProfiler::state_ = 0; 74 Atomic32 RuntimeProfiler::state_ = 0;
75 75 // TODO(isolates): Create the semaphore lazily and clean it up when no
76 // TODO(isolates): Clean up the semaphore when it is no longer required. 76 // longer required.
77 static LazySemaphore<0>::type semaphore = LAZY_SEMAPHORE_INITIALIZER; 77 Semaphore* RuntimeProfiler::semaphore_ = OS::CreateSemaphore(0);
78 78
79 #ifdef DEBUG 79 #ifdef DEBUG
80 bool RuntimeProfiler::has_been_globally_set_up_ = false; 80 bool RuntimeProfiler::has_been_globally_set_up_ = false;
81 #endif 81 #endif
82 bool RuntimeProfiler::enabled_ = false; 82 bool RuntimeProfiler::enabled_ = false;
83 83
84 84
85 RuntimeProfiler::RuntimeProfiler(Isolate* isolate) 85 RuntimeProfiler::RuntimeProfiler(Isolate* isolate)
86 : isolate_(isolate), 86 : isolate_(isolate),
87 sampler_threshold_(kSamplerThresholdInit), 87 sampler_threshold_(kSamplerThresholdInit),
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 } 405 }
406 406
407 407
408 void RuntimeProfiler::HandleWakeUp(Isolate* isolate) { 408 void RuntimeProfiler::HandleWakeUp(Isolate* isolate) {
409 // The profiler thread must still be waiting. 409 // The profiler thread must still be waiting.
410 ASSERT(NoBarrier_Load(&state_) >= 0); 410 ASSERT(NoBarrier_Load(&state_) >= 0);
411 // In IsolateEnteredJS we have already incremented the counter and 411 // In IsolateEnteredJS we have already incremented the counter and
412 // undid the decrement done by the profiler thread. Increment again 412 // undid the decrement done by the profiler thread. Increment again
413 // to get the right count of active isolates. 413 // to get the right count of active isolates.
414 NoBarrier_AtomicIncrement(&state_, 1); 414 NoBarrier_AtomicIncrement(&state_, 1);
415 semaphore.Pointer()->Signal(); 415 semaphore_->Signal();
416 } 416 }
417 417
418 418
419 bool RuntimeProfiler::IsSomeIsolateInJS() { 419 bool RuntimeProfiler::IsSomeIsolateInJS() {
420 return NoBarrier_Load(&state_) > 0; 420 return NoBarrier_Load(&state_) > 0;
421 } 421 }
422 422
423 423
424 bool RuntimeProfiler::WaitForSomeIsolateToEnterJS() { 424 bool RuntimeProfiler::WaitForSomeIsolateToEnterJS() {
425 Atomic32 old_state = NoBarrier_CompareAndSwap(&state_, 0, -1); 425 Atomic32 old_state = NoBarrier_CompareAndSwap(&state_, 0, -1);
426 ASSERT(old_state >= -1); 426 ASSERT(old_state >= -1);
427 if (old_state != 0) return false; 427 if (old_state != 0) return false;
428 semaphore.Pointer()->Wait(); 428 semaphore_->Wait();
429 return true; 429 return true;
430 } 430 }
431 431
432 432
433 void RuntimeProfiler::StopRuntimeProfilerThreadBeforeShutdown(Thread* thread) { 433 void RuntimeProfiler::StopRuntimeProfilerThreadBeforeShutdown(Thread* thread) {
434 // Do a fake increment. If the profiler is waiting on the semaphore, 434 // Do a fake increment. If the profiler is waiting on the semaphore,
435 // the returned state is 0, which can be left as an initial state in 435 // the returned state is 0, which can be left as an initial state in
436 // case profiling is restarted later. If the profiler is not 436 // case profiling is restarted later. If the profiler is not
437 // waiting, the increment will prevent it from waiting, but has to 437 // waiting, the increment will prevent it from waiting, but has to
438 // be undone after the profiler is stopped. 438 // be undone after the profiler is stopped.
439 Atomic32 new_state = NoBarrier_AtomicIncrement(&state_, 1); 439 Atomic32 new_state = NoBarrier_AtomicIncrement(&state_, 1);
440 ASSERT(new_state >= 0); 440 ASSERT(new_state >= 0);
441 if (new_state == 0) { 441 if (new_state == 0) {
442 // The profiler thread is waiting. Wake it up. It must check for 442 // The profiler thread is waiting. Wake it up. It must check for
443 // stop conditions before attempting to wait again. 443 // stop conditions before attempting to wait again.
444 semaphore.Pointer()->Signal(); 444 semaphore_->Signal();
445 } 445 }
446 thread->Join(); 446 thread->Join();
447 // The profiler thread is now stopped. Undo the increment in case it 447 // The profiler thread is now stopped. Undo the increment in case it
448 // was not waiting. 448 // was not waiting.
449 if (new_state != 0) { 449 if (new_state != 0) {
450 NoBarrier_AtomicIncrement(&state_, -1); 450 NoBarrier_AtomicIncrement(&state_, -1);
451 } 451 }
452 } 452 }
453 453
454 454
(...skipping 17 matching lines...) Expand all
472 472
473 bool RuntimeProfilerRateLimiter::SuspendIfNecessary() { 473 bool RuntimeProfilerRateLimiter::SuspendIfNecessary() {
474 if (!RuntimeProfiler::IsSomeIsolateInJS()) { 474 if (!RuntimeProfiler::IsSomeIsolateInJS()) {
475 return RuntimeProfiler::WaitForSomeIsolateToEnterJS(); 475 return RuntimeProfiler::WaitForSomeIsolateToEnterJS();
476 } 476 }
477 return false; 477 return false;
478 } 478 }
479 479
480 480
481 } } // namespace v8::internal 481 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime-profiler.h ('k') | src/v8.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698