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

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

Issue 9017009: Reduce signal sender thread stack size to 32k. 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
« no previous file with comments | « src/platform-linux.cc ('k') | src/platform-openbsd.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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 extern char** backtrace_symbols(void* const*, int) 68 extern char** backtrace_symbols(void* const*, int)
69 __attribute__((weak_import)); 69 __attribute__((weak_import));
70 extern void backtrace_symbols_fd(void* const*, int, int) 70 extern void backtrace_symbols_fd(void* const*, int, int)
71 __attribute__((weak_import)); 71 __attribute__((weak_import));
72 } 72 }
73 73
74 74
75 namespace v8 { 75 namespace v8 {
76 namespace internal { 76 namespace internal {
77 77
78 // 0 is never a valid thread id on MacOSX since a ptread_t is 78 // 0 is never a valid thread id on MacOSX since a pthread_t is
79 // a pointer. 79 // a pointer.
80 static const pthread_t kNoThread = (pthread_t) 0; 80 static const pthread_t kNoThread = (pthread_t) 0;
81 81
82 82
83 double ceiling(double x) { 83 double ceiling(double x) {
84 // Correct Mac OS X Leopard 'ceil' behavior. 84 // Correct Mac OS X Leopard 'ceil' behavior.
85 if (-1.0 < x && x < 0.0) { 85 if (-1.0 < x && x < 0.0) {
86 return -0.0; 86 return -0.0;
87 } else { 87 } else {
88 return ceil(x); 88 return ceil(x);
89 } 89 }
90 } 90 }
91 91
92 92
93 static Mutex* limit_mutex = NULL; 93 static Mutex* limit_mutex = NULL;
94 94
95 95
96 void OS::Setup() { 96 void OS::Setup() {
97 // Seed the random number generator. We preserve microsecond resolution. 97 // Seed the random number generator. We preserve microsecond resolution.
98 uint64_t seed = Ticks() ^ (getpid() << 16); 98 uint64_t seed = Ticks() ^ (getpid() << 16);
99 srandom(static_cast<unsigned int>(seed)); 99 srandom(static_cast<unsigned int>(seed));
100 limit_mutex = CreateMutex(); 100 limit_mutex = CreateMutex();
101 } 101 }
102 102
103 103
104 // We keep the lowest and highest addresses mapped as a quick way of 104 // We keep the lowest and highest addresses mapped as a quick way of
105 // determining that pointers are outside the heap (used mostly in assertions 105 // determining that pointers are outside the heap (used mostly in assertions
106 // and verification). The estimate is conservative, ie, not all addresses in 106 // and verification). The estimate is conservative, i.e., not all addresses in
107 // 'allocated' space are actually allocated to our heap. The range is 107 // 'allocated' space are actually allocated to our heap. The range is
108 // [lowest, highest), inclusive on the low and and exclusive on the high end. 108 // [lowest, highest), inclusive on the low and and exclusive on the high end.
109 static void* lowest_ever_allocated = reinterpret_cast<void*>(-1); 109 static void* lowest_ever_allocated = reinterpret_cast<void*>(-1);
110 static void* highest_ever_allocated = reinterpret_cast<void*>(0); 110 static void* highest_ever_allocated = reinterpret_cast<void*>(0);
111 111
112 112
113 static void UpdateAllocatedSpaceLimits(void* address, int size) { 113 static void UpdateAllocatedSpaceLimits(void* address, int size) {
114 ASSERT(limit_mutex != NULL); 114 ASSERT(limit_mutex != NULL);
115 ScopedLock lock(limit_mutex); 115 ScopedLock lock(limit_mutex);
116 116
(...skipping 349 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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 885
889 886
890 void Sampler::Stop() { 887 void Sampler::Stop() {
891 ASSERT(IsActive()); 888 ASSERT(IsActive());
892 SamplerThread::RemoveActiveSampler(this); 889 SamplerThread::RemoveActiveSampler(this);
893 SetActive(false); 890 SetActive(false);
894 } 891 }
895 892
896 893
897 } } // namespace v8::internal 894 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/platform-linux.cc ('k') | src/platform-openbsd.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698