| Index: src/cpu-profiler.cc
|
| diff --git a/src/cpu-profiler.cc b/src/cpu-profiler.cc
|
| index 264309511904c11c565fe3872a8d56567f68590b..efc18e59838eb4537e827b0ee5d4b0ea91130bf9 100644
|
| --- a/src/cpu-profiler.cc
|
| +++ b/src/cpu-profiler.cc
|
| @@ -34,6 +34,7 @@
|
| #include "frames-inl.h"
|
| #include "hashmap.h"
|
| #include "log-inl.h"
|
| +#include "vm-state-inl.h"
|
|
|
| #include "../include/v8-profiler.h"
|
|
|
| @@ -225,7 +226,7 @@ void ProfilerEventsProcessor::RegExpCodeCreateEvent(
|
| void ProfilerEventsProcessor::AddCurrentStack() {
|
| TickSampleEventRecord record;
|
| TickSample* sample = &record.sample;
|
| - sample->state = VMState::current_state();
|
| + sample->state = Isolate::Current()->current_vm_state();
|
| sample->pc = reinterpret_cast<Address>(sample); // Not NULL.
|
| sample->frames_count = 0;
|
| for (StackTraceFrameIterator it;
|
| @@ -364,9 +365,9 @@ CpuProfile* CpuProfiler::FindProfile(Object* security_token, unsigned uid) {
|
| }
|
|
|
|
|
| -TickSample* CpuProfiler::TickSampleEvent() {
|
| - if (CpuProfiler::is_profiling()) {
|
| - return Isolate::Current()->cpu_profiler()->processor_->TickSampleEvent();
|
| +TickSample* CpuProfiler::TickSampleEvent(Isolate* isolate) {
|
| + if (CpuProfiler::is_profiling(isolate)) {
|
| + return isolate->cpu_profiler()->processor_->TickSampleEvent();
|
| } else {
|
| return NULL;
|
| }
|
| @@ -440,7 +441,7 @@ void CpuProfiler::FunctionCreateEvent(JSFunction* function) {
|
| }
|
| profiler->processor_->FunctionCreateEvent(
|
| function->address(),
|
| - function->code()->address(),
|
| + function->shared()->code()->address(),
|
| security_token_id);
|
| }
|
|
|
| @@ -506,7 +507,8 @@ CpuProfiler::CpuProfiler()
|
| next_profile_uid_(1),
|
| token_enumerator_(new TokenEnumerator()),
|
| generator_(NULL),
|
| - processor_(NULL) {
|
| + processor_(NULL),
|
| + is_profiling_(false) {
|
| }
|
|
|
|
|
| @@ -536,6 +538,7 @@ void CpuProfiler::StartProcessorIfNotStarted() {
|
| LOGGER->logging_nesting_ = 0;
|
| generator_ = new ProfileGenerator(profiles_);
|
| processor_ = new ProfilerEventsProcessor(Isolate::Current(), generator_);
|
| + NoBarrier_Store(&is_profiling_, true);
|
| processor_->Start();
|
| // Enumerate stuff we already have in the heap.
|
| if (HEAP->HasBeenSetup()) {
|
| @@ -550,7 +553,9 @@ void CpuProfiler::StartProcessorIfNotStarted() {
|
| LOGGER->LogAccessorCallbacks();
|
| }
|
| // Enable stack sampling.
|
| - reinterpret_cast<Sampler*>(LOGGER->ticker_)->Start();
|
| + Sampler* sampler = reinterpret_cast<Sampler*>(LOGGER->ticker_);
|
| + if (!sampler->IsActive()) sampler->Start();
|
| + sampler->IncreaseProfilingDepth();
|
| }
|
| }
|
|
|
| @@ -581,12 +586,15 @@ CpuProfile* CpuProfiler::StopCollectingProfile(Object* security_token,
|
|
|
| void CpuProfiler::StopProcessorIfLastProfile(const char* title) {
|
| if (profiles_->IsLastProfile(title)) {
|
| - reinterpret_cast<Sampler*>(LOGGER->ticker_)->Stop();
|
| + Sampler* sampler = reinterpret_cast<Sampler*>(LOGGER->ticker_);
|
| + sampler->DecreaseProfilingDepth();
|
| + sampler->Stop();
|
| processor_->Stop();
|
| processor_->Join();
|
| delete processor_;
|
| delete generator_;
|
| processor_ = NULL;
|
| + NoBarrier_Store(&is_profiling_, false);
|
| generator_ = NULL;
|
| LOGGER->logging_nesting_ = saved_logging_nesting_;
|
| }
|
|
|