| 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 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 bool ThreadHandle::IsSelf() const { | 397 bool ThreadHandle::IsSelf() const { |
| 398 return pthread_equal(data_->thread_, pthread_self()); | 398 return pthread_equal(data_->thread_, pthread_self()); |
| 399 } | 399 } |
| 400 | 400 |
| 401 | 401 |
| 402 bool ThreadHandle::IsValid() const { | 402 bool ThreadHandle::IsValid() const { |
| 403 return data_->thread_ != kNoThread; | 403 return data_->thread_ != kNoThread; |
| 404 } | 404 } |
| 405 | 405 |
| 406 | 406 |
| 407 Thread::Thread() : ThreadHandle(ThreadHandle::INVALID) { | 407 Thread::Thread(Isolate* isolate) |
| 408 : ThreadHandle(ThreadHandle::INVALID), |
| 409 isolate_(isolate) { |
| 408 } | 410 } |
| 409 | 411 |
| 410 | 412 |
| 411 Thread::~Thread() { | 413 Thread::~Thread() { |
| 412 } | 414 } |
| 413 | 415 |
| 414 | 416 |
| 415 static void* ThreadEntry(void* arg) { | 417 static void* ThreadEntry(void* arg) { |
| 416 Thread* thread = reinterpret_cast<Thread*>(arg); | 418 Thread* thread = reinterpret_cast<Thread*>(arg); |
| 417 // This is also initialized by the first argument to pthread_create() but we | 419 // This is also initialized by the first argument to pthread_create() but we |
| 418 // don't know which thread will run first (the original thread or the new | 420 // don't know which thread will run first (the original thread or the new |
| 419 // one) so we initialize it here too. | 421 // one) so we initialize it here too. |
| 420 thread->thread_handle_data()->thread_ = pthread_self(); | 422 thread->thread_handle_data()->thread_ = pthread_self(); |
| 421 ASSERT(thread->IsValid()); | 423 ASSERT(thread->IsValid()); |
| 424 Thread::SetThreadLocal(Isolate::isolate_key(), thread->isolate()); |
| 422 thread->Run(); | 425 thread->Run(); |
| 423 return NULL; | 426 return NULL; |
| 424 } | 427 } |
| 425 | 428 |
| 426 | 429 |
| 427 void Thread::Start() { | 430 void Thread::Start() { |
| 428 pthread_create(&thread_handle_data()->thread_, NULL, ThreadEntry, this); | 431 pthread_create(&thread_handle_data()->thread_, NULL, ThreadEntry, this); |
| 429 ASSERT(IsValid()); | 432 ASSERT(IsValid()); |
| 430 } | 433 } |
| 431 | 434 |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 604 PlatformData() { | 607 PlatformData() { |
| 605 signal_handler_installed_ = false; | 608 signal_handler_installed_ = false; |
| 606 } | 609 } |
| 607 | 610 |
| 608 bool signal_handler_installed_; | 611 bool signal_handler_installed_; |
| 609 struct sigaction old_signal_handler_; | 612 struct sigaction old_signal_handler_; |
| 610 struct itimerval old_timer_value_; | 613 struct itimerval old_timer_value_; |
| 611 }; | 614 }; |
| 612 | 615 |
| 613 | 616 |
| 614 Sampler::Sampler(int interval, bool profiling) | 617 Sampler::Sampler(Isolate* isolate, int interval, bool profiling) |
| 615 : interval_(interval), profiling_(profiling), active_(false) { | 618 : isolate_(isolate), |
| 619 interval_(interval), |
| 620 profiling_(profiling), |
| 621 active_(false) { |
| 616 data_ = new PlatformData(); | 622 data_ = new PlatformData(); |
| 617 } | 623 } |
| 618 | 624 |
| 619 | 625 |
| 620 Sampler::~Sampler() { | 626 Sampler::~Sampler() { |
| 621 delete data_; | 627 delete data_; |
| 622 } | 628 } |
| 623 | 629 |
| 624 | 630 |
| 625 void Sampler::Start() { | 631 void Sampler::Start() { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 658 } | 664 } |
| 659 | 665 |
| 660 // This sampler is no longer the active sampler. | 666 // This sampler is no longer the active sampler. |
| 661 active_sampler_ = NULL; | 667 active_sampler_ = NULL; |
| 662 active_ = false; | 668 active_ = false; |
| 663 } | 669 } |
| 664 | 670 |
| 665 #endif // ENABLE_LOGGING_AND_PROFILING | 671 #endif // ENABLE_LOGGING_AND_PROFILING |
| 666 | 672 |
| 667 } } // namespace v8::internal | 673 } } // namespace v8::internal |
| OLD | NEW |