| OLD | NEW |
| 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 bool ThreadHandle::IsSelf() const { | 388 bool ThreadHandle::IsSelf() const { |
| 389 return pthread_equal(data_->thread_, pthread_self()); | 389 return pthread_equal(data_->thread_, pthread_self()); |
| 390 } | 390 } |
| 391 | 391 |
| 392 | 392 |
| 393 bool ThreadHandle::IsValid() const { | 393 bool ThreadHandle::IsValid() const { |
| 394 return data_->thread_ != kNoThread; | 394 return data_->thread_ != kNoThread; |
| 395 } | 395 } |
| 396 | 396 |
| 397 | 397 |
| 398 Thread::Thread() : ThreadHandle(ThreadHandle::INVALID) { | 398 Thread::Thread(Isolate* isolate) |
| 399 : ThreadHandle(ThreadHandle::INVALID), |
| 400 isolate_(isolate) { |
| 399 } | 401 } |
| 400 | 402 |
| 401 | 403 |
| 402 Thread::~Thread() { | 404 Thread::~Thread() { |
| 403 } | 405 } |
| 404 | 406 |
| 405 | 407 |
| 406 static void* ThreadEntry(void* arg) { | 408 static void* ThreadEntry(void* arg) { |
| 407 Thread* thread = reinterpret_cast<Thread*>(arg); | 409 Thread* thread = reinterpret_cast<Thread*>(arg); |
| 408 // This is also initialized by the first argument to pthread_create() but we | 410 // This is also initialized by the first argument to pthread_create() but we |
| 409 // don't know which thread will run first (the original thread or the new | 411 // don't know which thread will run first (the original thread or the new |
| 410 // one) so we initialize it here too. | 412 // one) so we initialize it here too. |
| 411 thread->thread_handle_data()->thread_ = pthread_self(); | 413 thread->thread_handle_data()->thread_ = pthread_self(); |
| 412 ASSERT(thread->IsValid()); | 414 ASSERT(thread->IsValid()); |
| 415 Thread::SetThreadLocal(Isolate::isolate_key(), thread->isolate()); |
| 413 thread->Run(); | 416 thread->Run(); |
| 414 return NULL; | 417 return NULL; |
| 415 } | 418 } |
| 416 | 419 |
| 417 | 420 |
| 418 void Thread::Start() { | 421 void Thread::Start() { |
| 419 pthread_create(&thread_handle_data()->thread_, NULL, ThreadEntry, this); | 422 pthread_create(&thread_handle_data()->thread_, NULL, ThreadEntry, this); |
| 420 ASSERT(IsValid()); | 423 ASSERT(IsValid()); |
| 421 } | 424 } |
| 422 | 425 |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 PlatformData() { | 593 PlatformData() { |
| 591 signal_handler_installed_ = false; | 594 signal_handler_installed_ = false; |
| 592 } | 595 } |
| 593 | 596 |
| 594 bool signal_handler_installed_; | 597 bool signal_handler_installed_; |
| 595 struct sigaction old_signal_handler_; | 598 struct sigaction old_signal_handler_; |
| 596 struct itimerval old_timer_value_; | 599 struct itimerval old_timer_value_; |
| 597 }; | 600 }; |
| 598 | 601 |
| 599 | 602 |
| 600 Sampler::Sampler(int interval, bool profiling) | 603 Sampler::Sampler(Isolate* isolate, int interval, bool profiling) |
| 601 : interval_(interval), profiling_(profiling), active_(false) { | 604 : isolate_(isolate), |
| 605 interval_(interval), |
| 606 profiling_(profiling), |
| 607 active_(false) { |
| 602 data_ = new PlatformData(); | 608 data_ = new PlatformData(); |
| 603 } | 609 } |
| 604 | 610 |
| 605 | 611 |
| 606 Sampler::~Sampler() { | 612 Sampler::~Sampler() { |
| 607 delete data_; | 613 delete data_; |
| 608 } | 614 } |
| 609 | 615 |
| 610 | 616 |
| 611 void Sampler::Start() { | 617 void Sampler::Start() { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 644 } | 650 } |
| 645 | 651 |
| 646 // This sampler is no longer the active sampler. | 652 // This sampler is no longer the active sampler. |
| 647 active_sampler_ = NULL; | 653 active_sampler_ = NULL; |
| 648 active_ = false; | 654 active_ = false; |
| 649 } | 655 } |
| 650 | 656 |
| 651 #endif // ENABLE_LOGGING_AND_PROFILING | 657 #endif // ENABLE_LOGGING_AND_PROFILING |
| 652 | 658 |
| 653 } } // namespace v8::internal | 659 } } // namespace v8::internal |
| OLD | NEW |