Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2006-2011 the V8 project authors. All rights reserved. | 1 // Copyright 2006-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 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 389 kMmapFd, kMmapFdOffset) != MAP_FAILED; | 389 kMmapFd, kMmapFdOffset) != MAP_FAILED; |
| 390 } | 390 } |
| 391 | 391 |
| 392 | 392 |
| 393 class Thread::PlatformData : public Malloced { | 393 class Thread::PlatformData : public Malloced { |
| 394 public: | 394 public: |
| 395 pthread_t thread_; // Thread handle for pthread. | 395 pthread_t thread_; // Thread handle for pthread. |
| 396 }; | 396 }; |
| 397 | 397 |
| 398 | 398 |
| 399 Thread::Thread(Isolate* isolate, const Options& options) | 399 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
Thanks! Somehow, I have missed this file.
| |
| 400 : data_(new PlatformData), | 400 : data_(new PlatformData), |
| 401 isolate_(isolate), | 401 isolate_(isolate), |
| 402 stack_size_(options.stack_size) { | 402 stack_size_(options.stack_size) { |
| 403 set_name(options.name); | 403 set_name(options.name); |
| 404 } | 404 } |
| 405 | 405 |
| 406 | 406 |
| 407 Thread::Thread(Isolate* isolate, const char* name) | 407 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.
| |
| 408 : data_(new PlatformData), | 408 : data_(new PlatformData), |
| 409 isolate_(isolate), | 409 isolate_(isolate), |
| 410 stack_size_(0) { | 410 stack_size_(0) { |
| 411 set_name(name); | 411 set_name(name); |
| 412 } | 412 } |
| 413 | 413 |
| 414 | 414 |
| 415 Thread::~Thread() { | 415 Thread::~Thread() { |
| 416 delete data_; | 416 delete data_; |
| 417 } | 417 } |
| 418 | 418 |
| 419 | 419 |
| 420 static void* ThreadEntry(void* arg) { | 420 static void* ThreadEntry(void* arg) { |
| 421 Thread* thread = reinterpret_cast<Thread*>(arg); | 421 Thread* thread = reinterpret_cast<Thread*>(arg); |
| 422 // This is also initialized by the first argument to pthread_create() but we | 422 // This is also initialized by the first argument to pthread_create() but we |
| 423 // don't know which thread will run first (the original thread or the new | 423 // don't know which thread will run first (the original thread or the new |
| 424 // one) so we initialize it here too. | 424 // one) so we initialize it here too. |
| 425 thread->data()->thread_ = pthread_self(); | 425 thread->data()->thread_ = pthread_self(); |
| 426 ASSERT(thread->data()->thread_ != kNoThread); | 426 ASSERT(thread->data()->thread_ != kNoThread); |
| 427 Thread::SetThreadLocal(Isolate::isolate_key(), thread->isolate()); | 427 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
Done.
| |
| 428 thread->Run(); | 428 thread->Run(); |
| 429 return NULL; | 429 return NULL; |
| 430 } | 430 } |
| 431 | 431 |
| 432 | 432 |
| 433 void Thread::set_name(const char* name) { | 433 void Thread::set_name(const char* name) { |
| 434 strncpy(name_, name, sizeof(name_)); | 434 strncpy(name_, name, sizeof(name_)); |
| 435 name_[sizeof(name_) - 1] = '\0'; | 435 name_[sizeof(name_) - 1] = '\0'; |
| 436 } | 436 } |
| 437 | 437 |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 654 | 654 |
| 655 | 655 |
| 656 class SignalSender : public Thread { | 656 class SignalSender : public Thread { |
| 657 public: | 657 public: |
| 658 enum SleepInterval { | 658 enum SleepInterval { |
| 659 HALF_INTERVAL, | 659 HALF_INTERVAL, |
| 660 FULL_INTERVAL | 660 FULL_INTERVAL |
| 661 }; | 661 }; |
| 662 | 662 |
| 663 explicit SignalSender(int interval) | 663 explicit SignalSender(int interval) |
| 664 : Thread(NULL, "SignalSender"), | 664 : Thread("SignalSender"), |
| 665 interval_(interval) {} | 665 interval_(interval) {} |
| 666 | 666 |
| 667 static void AddActiveSampler(Sampler* sampler) { | 667 static void AddActiveSampler(Sampler* sampler) { |
| 668 ScopedLock lock(mutex_); | 668 ScopedLock lock(mutex_); |
| 669 SamplerRegistry::AddActiveSampler(sampler); | 669 SamplerRegistry::AddActiveSampler(sampler); |
| 670 if (instance_ == NULL) { | 670 if (instance_ == NULL) { |
| 671 // Install a signal handler. | 671 // Install a signal handler. |
| 672 struct sigaction sa; | 672 struct sigaction sa; |
| 673 sa.sa_sigaction = ProfilerSignalHandler; | 673 sa.sa_sigaction = ProfilerSignalHandler; |
| 674 sigemptyset(&sa.sa_mask); | 674 sigemptyset(&sa.sa_mask); |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 818 | 818 |
| 819 void Sampler::Stop() { | 819 void Sampler::Stop() { |
| 820 ASSERT(IsActive()); | 820 ASSERT(IsActive()); |
| 821 SignalSender::RemoveActiveSampler(this); | 821 SignalSender::RemoveActiveSampler(this); |
| 822 SetActive(false); | 822 SetActive(false); |
| 823 } | 823 } |
| 824 | 824 |
| 825 #endif // ENABLE_LOGGING_AND_PROFILING | 825 #endif // ENABLE_LOGGING_AND_PROFILING |
| 826 | 826 |
| 827 } } // namespace v8::internal | 827 } } // namespace v8::internal |
| OLD | NEW |