Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 1458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1469 | 1469 |
| 1470 // Entry point for threads. The supplied argument is a pointer to the thread | 1470 // Entry point for threads. The supplied argument is a pointer to the thread |
| 1471 // object. The entry function dispatches to the run method in the thread | 1471 // object. The entry function dispatches to the run method in the thread |
| 1472 // object. It is important that this function has __stdcall calling | 1472 // object. It is important that this function has __stdcall calling |
| 1473 // convention. | 1473 // convention. |
| 1474 static unsigned int __stdcall ThreadEntry(void* arg) { | 1474 static unsigned int __stdcall ThreadEntry(void* arg) { |
| 1475 Thread* thread = reinterpret_cast<Thread*>(arg); | 1475 Thread* thread = reinterpret_cast<Thread*>(arg); |
| 1476 // This is also initialized by the last parameter to _beginthreadex() but we | 1476 // This is also initialized by the last parameter to _beginthreadex() but we |
| 1477 // don't know which thread will run first (the original thread or the new | 1477 // don't know which thread will run first (the original thread or the new |
| 1478 // one) so we initialize it here too. | 1478 // one) so we initialize it here too. |
| 1479 Thread::SetThreadLocal(Isolate::isolate_key(), thread->isolate()); | 1479 Thread::SetThreadLocal(Isolate::isolate_key(), thread->isolate()); |
|
Vitaly Repeshko
2011/06/10 08:18:50
Remove this line.
mnaganov (inactive)
2011/06/10 09:31:32
Hmm... I've actually did this once. Something has
| |
| 1480 thread->Run(); | 1480 thread->Run(); |
| 1481 return 0; | 1481 return 0; |
| 1482 } | 1482 } |
| 1483 | 1483 |
| 1484 | 1484 |
| 1485 class Thread::PlatformData : public Malloced { | 1485 class Thread::PlatformData : public Malloced { |
| 1486 public: | 1486 public: |
| 1487 explicit PlatformData(HANDLE thread) : thread_(thread) {} | 1487 explicit PlatformData(HANDLE thread) : thread_(thread) {} |
| 1488 HANDLE thread_; | 1488 HANDLE thread_; |
| 1489 }; | 1489 }; |
| 1490 | 1490 |
| 1491 | 1491 |
| 1492 // Initialize a Win32 thread object. The thread has an invalid thread | 1492 // Initialize a Win32 thread object. The thread has an invalid thread |
| 1493 // handle until it is started. | 1493 // handle until it is started. |
| 1494 | 1494 |
| 1495 Thread::Thread(Isolate* isolate, const Options& options) | 1495 Thread::Thread(Isolate* isolate, const Options& options) |
|
Vitaly Repeshko
2011/06/10 08:18:50
Won't compile.
mnaganov (inactive)
2011/06/10 09:31:32
Done.
| |
| 1496 : isolate_(isolate), | 1496 : isolate_(isolate), |
| 1497 stack_size_(options.stack_size) { | 1497 stack_size_(options.stack_size) { |
| 1498 data_ = new PlatformData(kNoThread); | 1498 data_ = new PlatformData(kNoThread); |
| 1499 set_name(options.name); | 1499 set_name(options.name); |
| 1500 } | 1500 } |
| 1501 | 1501 |
| 1502 | 1502 |
| 1503 Thread::Thread(Isolate* isolate, const char* name) | 1503 Thread::Thread(Isolate* isolate, const char* name) |
|
Vitaly Repeshko
2011/06/10 08:18:50
Ditto.
mnaganov (inactive)
2011/06/10 09:31:32
Done.
| |
| 1504 : isolate_(isolate), | 1504 : isolate_(isolate), |
| 1505 stack_size_(0) { | 1505 stack_size_(0) { |
| 1506 data_ = new PlatformData(kNoThread); | 1506 data_ = new PlatformData(kNoThread); |
| 1507 set_name(name); | 1507 set_name(name); |
| 1508 } | 1508 } |
| 1509 | 1509 |
| 1510 | 1510 |
| 1511 void Thread::set_name(const char* name) { | 1511 void Thread::set_name(const char* name) { |
| 1512 OS::StrNCpy(Vector<char>(name_, sizeof(name_)), name, strlen(name)); | 1512 OS::StrNCpy(Vector<char>(name_, sizeof(name_)), name, strlen(name)); |
| 1513 name_[sizeof(name_) - 1] = '\0'; | 1513 name_[sizeof(name_) - 1] = '\0'; |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1864 HANDLE profiled_thread() { return profiled_thread_; } | 1864 HANDLE profiled_thread() { return profiled_thread_; } |
| 1865 | 1865 |
| 1866 private: | 1866 private: |
| 1867 HANDLE profiled_thread_; | 1867 HANDLE profiled_thread_; |
| 1868 }; | 1868 }; |
| 1869 | 1869 |
| 1870 | 1870 |
| 1871 class SamplerThread : public Thread { | 1871 class SamplerThread : public Thread { |
| 1872 public: | 1872 public: |
| 1873 explicit SamplerThread(int interval) | 1873 explicit SamplerThread(int interval) |
| 1874 : Thread(NULL, "SamplerThread"), | 1874 : Thread("SamplerThread"), |
| 1875 interval_(interval) {} | 1875 interval_(interval) {} |
| 1876 | 1876 |
| 1877 static void AddActiveSampler(Sampler* sampler) { | 1877 static void AddActiveSampler(Sampler* sampler) { |
| 1878 ScopedLock lock(mutex_); | 1878 ScopedLock lock(mutex_); |
| 1879 SamplerRegistry::AddActiveSampler(sampler); | 1879 SamplerRegistry::AddActiveSampler(sampler); |
| 1880 if (instance_ == NULL) { | 1880 if (instance_ == NULL) { |
| 1881 instance_ = new SamplerThread(sampler->interval()); | 1881 instance_ = new SamplerThread(sampler->interval()); |
| 1882 instance_->Start(); | 1882 instance_->Start(); |
| 1883 } else { | 1883 } else { |
| 1884 ASSERT(instance_->interval_ == sampler->interval()); | 1884 ASSERT(instance_->interval_ == sampler->interval()); |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2009 | 2009 |
| 2010 void Sampler::Stop() { | 2010 void Sampler::Stop() { |
| 2011 ASSERT(IsActive()); | 2011 ASSERT(IsActive()); |
| 2012 SamplerThread::RemoveActiveSampler(this); | 2012 SamplerThread::RemoveActiveSampler(this); |
| 2013 SetActive(false); | 2013 SetActive(false); |
| 2014 } | 2014 } |
| 2015 | 2015 |
| 2016 #endif // ENABLE_LOGGING_AND_PROFILING | 2016 #endif // ENABLE_LOGGING_AND_PROFILING |
| 2017 | 2017 |
| 2018 } } // namespace v8::internal | 2018 } } // namespace v8::internal |
| OLD | NEW |