| 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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 | 162 |
| 163 | 163 |
| 164 void* OS::Allocate(const size_t requested, | 164 void* OS::Allocate(const size_t requested, |
| 165 size_t* allocated, | 165 size_t* allocated, |
| 166 bool is_executable) { | 166 bool is_executable) { |
| 167 const size_t msize = RoundUp(requested, getpagesize()); | 167 const size_t msize = RoundUp(requested, getpagesize()); |
| 168 int prot = PROT_READ | PROT_WRITE | (is_executable ? PROT_EXEC : 0); | 168 int prot = PROT_READ | PROT_WRITE | (is_executable ? PROT_EXEC : 0); |
| 169 void* mbase = mmap(NULL, msize, prot, MAP_PRIVATE | MAP_ANON, -1, 0); | 169 void* mbase = mmap(NULL, msize, prot, MAP_PRIVATE | MAP_ANON, -1, 0); |
| 170 | 170 |
| 171 if (mbase == MAP_FAILED) { | 171 if (mbase == MAP_FAILED) { |
| 172 LOG(StringEvent("OS::Allocate", "mmap failed")); | 172 LOG(ISOLATE, StringEvent("OS::Allocate", "mmap failed")); |
| 173 return NULL; | 173 return NULL; |
| 174 } | 174 } |
| 175 *allocated = msize; | 175 *allocated = msize; |
| 176 UpdateAllocatedSpaceLimits(mbase, msize); | 176 UpdateAllocatedSpaceLimits(mbase, msize); |
| 177 return mbase; | 177 return mbase; |
| 178 } | 178 } |
| 179 | 179 |
| 180 | 180 |
| 181 void OS::Free(void* address, const size_t size) { | 181 void OS::Free(void* address, const size_t size) { |
| 182 // TODO(1240712): munmap has a return value which is ignored here. | 182 // TODO(1240712): munmap has a return value which is ignored here. |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 bool ThreadHandle::IsSelf() const { | 408 bool ThreadHandle::IsSelf() const { |
| 409 return pthread_equal(data_->thread_, pthread_self()); | 409 return pthread_equal(data_->thread_, pthread_self()); |
| 410 } | 410 } |
| 411 | 411 |
| 412 | 412 |
| 413 bool ThreadHandle::IsValid() const { | 413 bool ThreadHandle::IsValid() const { |
| 414 return data_->thread_ != kNoThread; | 414 return data_->thread_ != kNoThread; |
| 415 } | 415 } |
| 416 | 416 |
| 417 | 417 |
| 418 Thread::Thread() : ThreadHandle(ThreadHandle::INVALID) { | 418 Thread::Thread(Isolate* isolate) |
| 419 : ThreadHandle(ThreadHandle::INVALID), |
| 420 isolate_(isolate) { |
| 419 set_name("v8:<unknown>"); | 421 set_name("v8:<unknown>"); |
| 420 } | 422 } |
| 421 | 423 |
| 422 | 424 |
| 423 Thread::Thread(const char* name) : ThreadHandle(ThreadHandle::INVALID) { | 425 Thread::Thread(Isolate* isolate, const char* name) |
| 426 : ThreadHandle(ThreadHandle::INVALID), |
| 427 isolate_(isolate) { |
| 424 set_name(name); | 428 set_name(name); |
| 425 } | 429 } |
| 426 | 430 |
| 427 | 431 |
| 428 Thread::~Thread() { | 432 Thread::~Thread() { |
| 429 } | 433 } |
| 430 | 434 |
| 431 | 435 |
| 432 static void* ThreadEntry(void* arg) { | 436 static void* ThreadEntry(void* arg) { |
| 433 Thread* thread = reinterpret_cast<Thread*>(arg); | 437 Thread* thread = reinterpret_cast<Thread*>(arg); |
| 434 // This is also initialized by the first argument to pthread_create() but we | 438 // This is also initialized by the first argument to pthread_create() but we |
| 435 // don't know which thread will run first (the original thread or the new | 439 // don't know which thread will run first (the original thread or the new |
| 436 // one) so we initialize it here too. | 440 // one) so we initialize it here too. |
| 437 thread->thread_handle_data()->thread_ = pthread_self(); | 441 thread->thread_handle_data()->thread_ = pthread_self(); |
| 438 ASSERT(thread->IsValid()); | 442 ASSERT(thread->IsValid()); |
| 443 Thread::SetThreadLocal(Isolate::isolate_key(), thread->isolate()); |
| 439 thread->Run(); | 444 thread->Run(); |
| 440 return NULL; | 445 return NULL; |
| 441 } | 446 } |
| 442 | 447 |
| 443 | 448 |
| 444 void Thread::set_name(const char* name) { | 449 void Thread::set_name(const char* name) { |
| 445 strncpy(name_, name, sizeof(name_)); | 450 strncpy(name_, name, sizeof(name_)); |
| 446 name_[sizeof(name_) - 1] = '\0'; | 451 name_[sizeof(name_) - 1] = '\0'; |
| 447 } | 452 } |
| 448 | 453 |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 705 | 710 |
| 706 | 711 |
| 707 static void* SenderEntry(void* arg) { | 712 static void* SenderEntry(void* arg) { |
| 708 Sampler::PlatformData* data = | 713 Sampler::PlatformData* data = |
| 709 reinterpret_cast<Sampler::PlatformData*>(arg); | 714 reinterpret_cast<Sampler::PlatformData*>(arg); |
| 710 data->SignalSender(); | 715 data->SignalSender(); |
| 711 return 0; | 716 return 0; |
| 712 } | 717 } |
| 713 | 718 |
| 714 | 719 |
| 715 Sampler::Sampler(int interval) | 720 Sampler::Sampler(Isolate* isolate, int interval) |
| 716 : interval_(interval), | 721 : isolate_(isolate), |
| 722 interval_(interval), |
| 717 profiling_(false), | 723 profiling_(false), |
| 718 active_(false), | 724 active_(false), |
| 719 samples_taken_(0) { | 725 samples_taken_(0) { |
| 720 data_ = new PlatformData(this); | 726 data_ = new PlatformData(this); |
| 721 } | 727 } |
| 722 | 728 |
| 723 | 729 |
| 724 Sampler::~Sampler() { | 730 Sampler::~Sampler() { |
| 725 ASSERT(!data_->signal_sender_launched_); | 731 ASSERT(!data_->signal_sender_launched_); |
| 726 delete data_; | 732 delete data_; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 772 data_->signal_handler_installed_ = false; | 778 data_->signal_handler_installed_ = false; |
| 773 } | 779 } |
| 774 | 780 |
| 775 // This sampler is no longer the active sampler. | 781 // This sampler is no longer the active sampler. |
| 776 active_sampler_ = NULL; | 782 active_sampler_ = NULL; |
| 777 } | 783 } |
| 778 | 784 |
| 779 #endif // ENABLE_LOGGING_AND_PROFILING | 785 #endif // ENABLE_LOGGING_AND_PROFILING |
| 780 | 786 |
| 781 } } // namespace v8::internal | 787 } } // namespace v8::internal |
| OLD | NEW |