| Index: test/cctest/test-log.cc
|
| diff --git a/test/cctest/test-log.cc b/test/cctest/test-log.cc
|
| index 527183c505bc3ac67ffa8b014e49a1b521807099..44f2ac5a730067fcedc7f8c5be9b9d3e906c0a7f 100644
|
| --- a/test/cctest/test-log.cc
|
| +++ b/test/cctest/test-log.cc
|
| @@ -16,6 +16,7 @@
|
| #include "cpu-profiler.h"
|
| #include "v8threads.h"
|
| #include "cctest.h"
|
| +#include "vm-state-inl.h"
|
|
|
| using v8::internal::Address;
|
| using v8::internal::EmbeddedVector;
|
| @@ -246,7 +247,8 @@ class LogBufferMatcher {
|
|
|
|
|
| static void CheckThatProfilerWorks(LogBufferMatcher* matcher) {
|
| - CHECK(!LoggerTestHelper::IsSamplerActive());
|
| + CHECK(i::RuntimeProfiler::IsEnabled() ||
|
| + !LoggerTestHelper::IsSamplerActive());
|
| LoggerTestHelper::ResetSamplesTaken();
|
|
|
| LOGGER->ResumeProfiler(v8::PROFILER_MODULE_CPU, 0);
|
| @@ -272,7 +274,8 @@ static void CheckThatProfilerWorks(LogBufferMatcher* matcher) {
|
| }
|
|
|
| LOGGER->PauseProfiler(v8::PROFILER_MODULE_CPU, 0);
|
| - CHECK(!LoggerTestHelper::IsSamplerActive());
|
| + CHECK(i::RuntimeProfiler::IsEnabled() ||
|
| + !LoggerTestHelper::IsSamplerActive());
|
|
|
| // Wait 50 msecs to allow Profiler thread to process the last
|
| // tick sample it has got.
|
| @@ -291,8 +294,12 @@ static void CheckThatProfilerWorks(LogBufferMatcher* matcher) {
|
| TEST(ProfLazyMode) {
|
| ScopedLoggerInitializer initialize_logger(true);
|
|
|
| - // No sampling should happen prior to resuming profiler.
|
| - CHECK(!LoggerTestHelper::IsSamplerActive());
|
| + if (!i::V8::UseCrankshaft()) return;
|
| +
|
| + // No sampling should happen prior to resuming profiler unless we
|
| + // are runtime profiling.
|
| + CHECK(i::RuntimeProfiler::IsEnabled() ||
|
| + !LoggerTestHelper::IsSamplerActive());
|
|
|
| LogBufferMatcher matcher;
|
| // Nothing must be logged until profiling is resumed.
|
| @@ -409,7 +416,7 @@ class LoopingNonJsThread : public LoopingThread {
|
| class TestSampler : public v8::internal::Sampler {
|
| public:
|
| explicit TestSampler(v8::internal::Isolate* isolate)
|
| - : Sampler(isolate, 0, true),
|
| + : Sampler(isolate, 0, true, true),
|
| semaphore_(v8::internal::OS::CreateSemaphore(0)),
|
| was_sample_stack_called_(false) {
|
| }
|
| @@ -437,30 +444,38 @@ class TestSampler : public v8::internal::Sampler {
|
| } // namespace
|
|
|
| TEST(ProfMultipleThreads) {
|
| + TestSampler* sampler = NULL;
|
| + {
|
| + v8::Locker locker;
|
| + sampler = new TestSampler(v8::internal::Isolate::Current());
|
| + sampler->Start();
|
| + CHECK(sampler->IsActive());
|
| + }
|
| +
|
| LoopingJsThread jsThread(v8::internal::Isolate::Current());
|
| jsThread.Start();
|
| LoopingNonJsThread nonJsThread(v8::internal::Isolate::Current());
|
| nonJsThread.Start();
|
|
|
| - TestSampler sampler(v8::internal::Isolate::Current());
|
| - sampler.Start();
|
| - CHECK(!sampler.WasSampleStackCalled());
|
| + CHECK(!sampler->WasSampleStackCalled());
|
| jsThread.WaitForRunning();
|
| jsThread.SendSigProf();
|
| - CHECK(sampler.WaitForTick());
|
| - CHECK(sampler.WasSampleStackCalled());
|
| - sampler.Reset();
|
| - CHECK(!sampler.WasSampleStackCalled());
|
| + CHECK(sampler->WaitForTick());
|
| + CHECK(sampler->WasSampleStackCalled());
|
| + sampler->Reset();
|
| + CHECK(!sampler->WasSampleStackCalled());
|
| nonJsThread.WaitForRunning();
|
| nonJsThread.SendSigProf();
|
| - CHECK(!sampler.WaitForTick());
|
| - CHECK(!sampler.WasSampleStackCalled());
|
| - sampler.Stop();
|
| + CHECK(!sampler->WaitForTick());
|
| + CHECK(!sampler->WasSampleStackCalled());
|
| + sampler->Stop();
|
|
|
| jsThread.Stop();
|
| nonJsThread.Stop();
|
| jsThread.Join();
|
| nonJsThread.Join();
|
| +
|
| + delete sampler;
|
| }
|
|
|
| #endif // __linux__
|
|
|