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

Side by Side Diff: src/platform-win32.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 1508 matching lines...) Expand 10 before | Expand all | Expand 10 after
1519 explicit PlatformData(HANDLE thread) : thread_(thread) {} 1519 explicit PlatformData(HANDLE thread) : thread_(thread) {}
1520 HANDLE thread_; 1520 HANDLE thread_;
1521 unsigned thread_id_; 1521 unsigned thread_id_;
1522 }; 1522 };
1523 1523
1524 1524
1525 // Initialize a Win32 thread object. The thread has an invalid thread 1525 // Initialize a Win32 thread object. The thread has an invalid thread
1526 // handle until it is started. 1526 // handle until it is started.
1527 1527
1528 Thread::Thread(const Options& options) 1528 Thread::Thread(const Options& options)
1529 : stack_size_(options.stack_size) { 1529 : stack_size_(options.stack_size()) {
1530 data_ = new PlatformData(kNoThread); 1530 data_ = new PlatformData(kNoThread);
1531 set_name(options.name); 1531 set_name(options.name());
1532 }
1533
1534
1535 Thread::Thread(const char* name)
1536 : stack_size_(0) {
1537 data_ = new PlatformData(kNoThread);
1538 set_name(name);
1539 } 1532 }
1540 1533
1541 1534
1542 void Thread::set_name(const char* name) { 1535 void Thread::set_name(const char* name) {
1543 OS::StrNCpy(Vector<char>(name_, sizeof(name_)), name, strlen(name)); 1536 OS::StrNCpy(Vector<char>(name_, sizeof(name_)), name, strlen(name));
1544 name_[sizeof(name_) - 1] = '\0'; 1537 name_[sizeof(name_) - 1] = '\0';
1545 } 1538 }
1546 1539
1547 1540
1548 // Close our own handle for the thread. 1541 // Close our own handle for the thread.
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
1894 1887
1895 HANDLE profiled_thread() { return profiled_thread_; } 1888 HANDLE profiled_thread() { return profiled_thread_; }
1896 1889
1897 private: 1890 private:
1898 HANDLE profiled_thread_; 1891 HANDLE profiled_thread_;
1899 }; 1892 };
1900 1893
1901 1894
1902 class SamplerThread : public Thread { 1895 class SamplerThread : public Thread {
1903 public: 1896 public:
1897 static const int kSamplerThreadStackSize = 32 * KB;
1898
1904 explicit SamplerThread(int interval) 1899 explicit SamplerThread(int interval)
1905 : Thread("SamplerThread"), 1900 : Thread(Thread::Options("SamplerThread", kSamplerThreadStackSize)),
1906 interval_(interval) {} 1901 interval_(interval) {}
1907 1902
1908 static void AddActiveSampler(Sampler* sampler) { 1903 static void AddActiveSampler(Sampler* sampler) {
1909 ScopedLock lock(mutex_); 1904 ScopedLock lock(mutex_);
1910 SamplerRegistry::AddActiveSampler(sampler); 1905 SamplerRegistry::AddActiveSampler(sampler);
1911 if (instance_ == NULL) { 1906 if (instance_ == NULL) {
1912 instance_ = new SamplerThread(sampler->interval()); 1907 instance_ = new SamplerThread(sampler->interval());
1913 instance_->Start(); 1908 instance_->Start();
1914 } else { 1909 } else {
1915 ASSERT(instance_->interval_ == sampler->interval()); 1910 ASSERT(instance_->interval_ == sampler->interval());
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
2039 2034
2040 2035
2041 void Sampler::Stop() { 2036 void Sampler::Stop() {
2042 ASSERT(IsActive()); 2037 ASSERT(IsActive());
2043 SamplerThread::RemoveActiveSampler(this); 2038 SamplerThread::RemoveActiveSampler(this);
2044 SetActive(false); 2039 SetActive(false);
2045 } 2040 }
2046 2041
2047 2042
2048 } } // namespace v8::internal 2043 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698