| 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 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 | 587 |
| 588 Thread::~Thread() { | 588 Thread::~Thread() { |
| 589 } | 589 } |
| 590 | 590 |
| 591 | 591 |
| 592 static void* ThreadEntry(void* arg) { | 592 static void* ThreadEntry(void* arg) { |
| 593 Thread* thread = reinterpret_cast<Thread*>(arg); | 593 Thread* thread = reinterpret_cast<Thread*>(arg); |
| 594 // This is also initialized by the first argument to pthread_create() but we | 594 // This is also initialized by the first argument to pthread_create() but we |
| 595 // don't know which thread will run first (the original thread or the new | 595 // don't know which thread will run first (the original thread or the new |
| 596 // one) so we initialize it here too. | 596 // one) so we initialize it here too. |
| 597 prctl(PR_SET_NAME, thread->name(), 0, 0, 0); | 597 prctl(PR_SET_NAME, |
| 598 reinterpret_cast<unsigned long>(thread->name()), // NOLINT |
| 599 0, 0, 0); |
| 598 thread->thread_handle_data()->thread_ = pthread_self(); | 600 thread->thread_handle_data()->thread_ = pthread_self(); |
| 599 ASSERT(thread->IsValid()); | 601 ASSERT(thread->IsValid()); |
| 600 Thread::SetThreadLocal(Isolate::isolate_key(), thread->isolate()); | 602 Thread::SetThreadLocal(Isolate::isolate_key(), thread->isolate()); |
| 601 thread->Run(); | 603 thread->Run(); |
| 602 return NULL; | 604 return NULL; |
| 603 } | 605 } |
| 604 | 606 |
| 605 | 607 |
| 606 void Thread::set_name(const char* name) { | 608 void Thread::set_name(const char* name) { |
| 607 strncpy(name_, name, sizeof(name_)); | 609 strncpy(name_, name, sizeof(name_)); |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 951 SignalSender* sender = reinterpret_cast<SignalSender*>(raw_sender); | 953 SignalSender* sender = reinterpret_cast<SignalSender*>(raw_sender); |
| 952 sender->SendProfilingSignal(sampler->platform_data()->vm_tid()); | 954 sender->SendProfilingSignal(sampler->platform_data()->vm_tid()); |
| 953 } | 955 } |
| 954 | 956 |
| 955 static void DoRuntimeProfile(Sampler* sampler, void* ignored) { | 957 static void DoRuntimeProfile(Sampler* sampler, void* ignored) { |
| 956 if (!sampler->isolate()->IsInitialized()) return; | 958 if (!sampler->isolate()->IsInitialized()) return; |
| 957 sampler->isolate()->runtime_profiler()->NotifyTick(); | 959 sampler->isolate()->runtime_profiler()->NotifyTick(); |
| 958 } | 960 } |
| 959 | 961 |
| 960 void SendProfilingSignal(int tid) { | 962 void SendProfilingSignal(int tid) { |
| 963 if (!signal_handler_installed_) return; |
| 961 // Glibc doesn't provide a wrapper for tgkill(2). | 964 // Glibc doesn't provide a wrapper for tgkill(2). |
| 962 syscall(SYS_tgkill, vm_tgid_, tid, SIGPROF); | 965 syscall(SYS_tgkill, vm_tgid_, tid, SIGPROF); |
| 963 } | 966 } |
| 964 | 967 |
| 965 void Sleep(SleepInterval full_or_half) { | 968 void Sleep(SleepInterval full_or_half) { |
| 966 // Convert ms to us and subtract 100 us to compensate delays | 969 // Convert ms to us and subtract 100 us to compensate delays |
| 967 // occuring during signal delivery. | 970 // occuring during signal delivery. |
| 968 useconds_t interval = interval_ * 1000 - 100; | 971 useconds_t interval = interval_ * 1000 - 100; |
| 969 if (full_or_half == HALF_INTERVAL) interval /= 2; | 972 if (full_or_half == HALF_INTERVAL) interval /= 2; |
| 970 int result = usleep(interval); | 973 int result = usleep(interval); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1025 | 1028 |
| 1026 void Sampler::Stop() { | 1029 void Sampler::Stop() { |
| 1027 ASSERT(IsActive()); | 1030 ASSERT(IsActive()); |
| 1028 SignalSender::RemoveActiveSampler(this); | 1031 SignalSender::RemoveActiveSampler(this); |
| 1029 SetActive(false); | 1032 SetActive(false); |
| 1030 } | 1033 } |
| 1031 | 1034 |
| 1032 #endif // ENABLE_LOGGING_AND_PROFILING | 1035 #endif // ENABLE_LOGGING_AND_PROFILING |
| 1033 | 1036 |
| 1034 } } // namespace v8::internal | 1037 } } // namespace v8::internal |
| OLD | NEW |