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

Side by Side Diff: src/sampler.cc

Issue 21087012: Simplify implementation of Mutex. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix unit test. Created 7 years, 4 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/platform-win32.cc ('k') | src/spaces.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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 408
409 409
410 class SamplerThread : public Thread { 410 class SamplerThread : public Thread {
411 public: 411 public:
412 static const int kSamplerThreadStackSize = 64 * KB; 412 static const int kSamplerThreadStackSize = 64 * KB;
413 413
414 explicit SamplerThread(int interval) 414 explicit SamplerThread(int interval)
415 : Thread(Thread::Options("SamplerThread", kSamplerThreadStackSize)), 415 : Thread(Thread::Options("SamplerThread", kSamplerThreadStackSize)),
416 interval_(interval) {} 416 interval_(interval) {}
417 417
418 static void SetUp() { if (!mutex_) mutex_ = OS::CreateMutex(); } 418 static void SetUp() { if (!mutex_) mutex_ = new Mutex; }
419 static void TearDown() { delete mutex_; } 419 static void TearDown() { delete mutex_; }
420 420
421 static void AddActiveSampler(Sampler* sampler) { 421 static void AddActiveSampler(Sampler* sampler) {
422 bool need_to_start = false; 422 bool need_to_start = false;
423 ScopedLock lock(mutex_); 423 ScopedLock lock(mutex_);
424 if (instance_ == NULL) { 424 if (instance_ == NULL) {
425 // Start a thread that will send SIGPROF signal to VM threads, 425 // Start a thread that will send SIGPROF signal to VM threads,
426 // when CPU profiling will be enabled. 426 // when CPU profiling will be enabled.
427 instance_ = new SamplerThread(sampler->interval()); 427 instance_ = new SamplerThread(sampler->interval());
428 need_to_start = true; 428 need_to_start = true;
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 sample->Init(isolate_, state); 696 sample->Init(isolate_, state);
697 if (is_counting_samples_) { 697 if (is_counting_samples_) {
698 if (sample->state == JS || sample->state == EXTERNAL) { 698 if (sample->state == JS || sample->state == EXTERNAL) {
699 ++js_and_external_sample_count_; 699 ++js_and_external_sample_count_;
700 } 700 }
701 } 701 }
702 Tick(sample); 702 Tick(sample);
703 } 703 }
704 704
705 } } // namespace v8::internal 705 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/platform-win32.cc ('k') | src/spaces.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698