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

Side by Side Diff: src/platform-macos.cc

Issue 9117032: Reduce the space used by the stack for the profiling thread. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 8 years, 11 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
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 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 return munmap(address, size) == 0; 466 return munmap(address, size) == 0;
467 } 467 }
468 468
469 469
470 class Thread::PlatformData : public Malloced { 470 class Thread::PlatformData : public Malloced {
471 public: 471 public:
472 PlatformData() : thread_(kNoThread) {} 472 PlatformData() : thread_(kNoThread) {}
473 pthread_t thread_; // Thread handle for pthread. 473 pthread_t thread_; // Thread handle for pthread.
474 }; 474 };
475 475
476
476 Thread::Thread(const Options& options) 477 Thread::Thread(const Options& options)
477 : data_(new PlatformData), 478 : data_(new PlatformData),
478 stack_size_(options.stack_size) { 479 stack_size_(options.stack_size()) {
479 set_name(options.name); 480 set_name(options.name());
480 }
481
482
483 Thread::Thread(const char* name)
484 : data_(new PlatformData),
485 stack_size_(0) {
486 set_name(name);
487 } 481 }
488 482
489 483
490 Thread::~Thread() { 484 Thread::~Thread() {
491 delete data_; 485 delete data_;
492 } 486 }
493 487
494 488
495 static void SetThreadName(const char* name) { 489 static void SetThreadName(const char* name) {
496 // pthread_setname_np is only available in 10.6 or later, so test 490 // pthread_setname_np is only available in 10.6 or later, so test
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 723
730 thread_act_t profiled_thread() { return profiled_thread_; } 724 thread_act_t profiled_thread() { return profiled_thread_; }
731 725
732 private: 726 private:
733 // Note: for profiled_thread_ Mach primitives are used instead of PThread's 727 // Note: for profiled_thread_ Mach primitives are used instead of PThread's
734 // because the latter doesn't provide thread manipulation primitives required. 728 // because the latter doesn't provide thread manipulation primitives required.
735 // For details, consult "Mac OS X Internals" book, Section 7.3. 729 // For details, consult "Mac OS X Internals" book, Section 7.3.
736 thread_act_t profiled_thread_; 730 thread_act_t profiled_thread_;
737 }; 731 };
738 732
733
739 class SamplerThread : public Thread { 734 class SamplerThread : public Thread {
740 public: 735 public:
736 static const int kSamplerThreadStackSize = 32 * KB;
737
741 explicit SamplerThread(int interval) 738 explicit SamplerThread(int interval)
742 : Thread("SamplerThread"), 739 : Thread(Thread::Options("SamplerThread", kSamplerThreadStackSize)),
743 interval_(interval) {} 740 interval_(interval) {}
744 741
745 static void AddActiveSampler(Sampler* sampler) { 742 static void AddActiveSampler(Sampler* sampler) {
746 ScopedLock lock(mutex_); 743 ScopedLock lock(mutex_);
747 SamplerRegistry::AddActiveSampler(sampler); 744 SamplerRegistry::AddActiveSampler(sampler);
748 if (instance_ == NULL) { 745 if (instance_ == NULL) {
749 instance_ = new SamplerThread(sampler->interval()); 746 instance_ = new SamplerThread(sampler->interval());
750 instance_->Start(); 747 instance_->Start();
751 } else { 748 } else {
752 ASSERT(instance_->interval_ == sampler->interval()); 749 ASSERT(instance_->interval_ == sampler->interval());
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
889 886
890 887
891 void Sampler::Stop() { 888 void Sampler::Stop() {
892 ASSERT(IsActive()); 889 ASSERT(IsActive());
893 SamplerThread::RemoveActiveSampler(this); 890 SamplerThread::RemoveActiveSampler(this);
894 SetActive(false); 891 SetActive(false);
895 } 892 }
896 893
897 894
898 } } // namespace v8::internal 895 } } // namespace v8::internal
OLDNEW
« src/cpu-profiler.cc ('K') | « src/platform-linux.cc ('k') | src/platform-openbsd.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698