| 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 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 666 } else { | 666 } else { |
| 667 if (sampler_->IsProfiling()) SendProfilingSignal(); | 667 if (sampler_->IsProfiling()) SendProfilingSignal(); |
| 668 if (RuntimeProfiler::IsEnabled()) RuntimeProfiler::NotifyTick(); | 668 if (RuntimeProfiler::IsEnabled()) RuntimeProfiler::NotifyTick(); |
| 669 Sleep(FULL_INTERVAL); | 669 Sleep(FULL_INTERVAL); |
| 670 } | 670 } |
| 671 } | 671 } |
| 672 } | 672 } |
| 673 | 673 |
| 674 void SendProfilingSignal() { | 674 void SendProfilingSignal() { |
| 675 if (!signal_handler_installed_) return; | 675 if (!signal_handler_installed_) return; |
| 676 // There doesn't seem to be a robust way to deliver a signal to a | 676 pthread_kill(vm_tid_, SIGPROF); |
| 677 // particular thread that may have terminated already. We send the | |
| 678 // signal to the whole process hoping the right thread will get | |
| 679 // it. | |
| 680 kill(vm_tgid_, SIGPROF); | |
| 681 } | 677 } |
| 682 | 678 |
| 683 void Sleep(SleepInterval full_or_half) { | 679 void Sleep(SleepInterval full_or_half) { |
| 684 // Convert ms to us and subtract 100 us to compensate delays | 680 // Convert ms to us and subtract 100 us to compensate delays |
| 685 // occuring during signal delivery. | 681 // occuring during signal delivery. |
| 686 useconds_t interval = sampler_->interval_ * 1000 - 100; | 682 useconds_t interval = sampler_->interval_ * 1000 - 100; |
| 687 if (full_or_half == HALF_INTERVAL) interval /= 2; | 683 if (full_or_half == HALF_INTERVAL) interval /= 2; |
| 688 int result = usleep(interval); | 684 int result = usleep(interval); |
| 689 #ifdef DEBUG | 685 #ifdef DEBUG |
| 690 if (result != 0 && errno != EINTR) { | 686 if (result != 0 && errno != EINTR) { |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 776 data_->signal_handler_installed_ = false; | 772 data_->signal_handler_installed_ = false; |
| 777 } | 773 } |
| 778 | 774 |
| 779 // This sampler is no longer the active sampler. | 775 // This sampler is no longer the active sampler. |
| 780 active_sampler_ = NULL; | 776 active_sampler_ = NULL; |
| 781 } | 777 } |
| 782 | 778 |
| 783 #endif // ENABLE_LOGGING_AND_PROFILING | 779 #endif // ENABLE_LOGGING_AND_PROFILING |
| 784 | 780 |
| 785 } } // namespace v8::internal | 781 } } // namespace v8::internal |
| OLD | NEW |