cc59f8b125
Original change's description: > Switch tracing to use v8::TracingController > > BUG=v8:6511 > R=fmeawad@chromium.org > > Cq-Include-Trybots: master.tryserver.chromium.linux:linux_chromium_rel_ng > Change-Id: I4961e4b61a9ddc98385ed97c3ffcbcaef2d9cba7 > Reviewed-on: https://chromium-review.googlesource.com/543144 > Commit-Queue: Jochen Eisinger <jochen@chromium.org> > Reviewed-by: Fadi Meawad <fmeawad@chromium.org> > Cr-Commit-Position: refs/heads/master@{#46307} BUG=v8:6511 TBR=fmeawad@chromium.org Cq-Include-Trybots: master.tryserver.chromium.linux:linux_chromium_rel_ng;master.tryserver.v8:v8_linux64_tsan_rel Change-Id: Ide32b409248dfd466e7c0bae1d8ae61d6a955d98 Reviewed-on: https://chromium-review.googlesource.com/558865 Commit-Queue: Jochen Eisinger <jochen@chromium.org> Reviewed-by: Jochen Eisinger <jochen@chromium.org> Cr-Commit-Position: refs/heads/master@{#46381}
104 lines
2.7 KiB
C++
104 lines
2.7 KiB
C++
// Copyright 2015 the V8 project authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include <stdlib.h>
|
|
|
|
#ifdef __linux__
|
|
#include <errno.h>
|
|
#include <fcntl.h>
|
|
#include <sys/stat.h>
|
|
#include <sys/types.h>
|
|
#include <unistd.h>
|
|
#endif
|
|
|
|
#include <utility>
|
|
|
|
#include "src/v8.h"
|
|
|
|
#include "src/full-codegen/full-codegen.h"
|
|
#include "src/global-handles.h"
|
|
#include "src/heap/incremental-marking.h"
|
|
#include "src/heap/spaces.h"
|
|
#include "src/objects-inl.h"
|
|
#include "test/cctest/cctest.h"
|
|
#include "test/cctest/heap/heap-utils.h"
|
|
|
|
using v8::IdleTask;
|
|
using v8::Task;
|
|
using v8::Isolate;
|
|
|
|
namespace v8 {
|
|
namespace internal {
|
|
|
|
class MockPlatform : public v8::Platform {
|
|
public:
|
|
explicit MockPlatform(v8::Platform* platform)
|
|
: platform_(platform), task_(nullptr) {}
|
|
virtual ~MockPlatform() { delete task_; }
|
|
|
|
void CallOnBackgroundThread(Task* task,
|
|
ExpectedRuntime expected_runtime) override {
|
|
platform_->CallOnBackgroundThread(task, expected_runtime);
|
|
}
|
|
|
|
void CallOnForegroundThread(v8::Isolate* isolate, Task* task) override {
|
|
task_ = task;
|
|
}
|
|
|
|
void CallDelayedOnForegroundThread(v8::Isolate* isolate, Task* task,
|
|
double delay_in_seconds) override {
|
|
platform_->CallDelayedOnForegroundThread(isolate, task, delay_in_seconds);
|
|
}
|
|
|
|
double MonotonicallyIncreasingTime() override {
|
|
return platform_->MonotonicallyIncreasingTime();
|
|
}
|
|
|
|
void CallIdleOnForegroundThread(v8::Isolate* isolate,
|
|
IdleTask* task) override {
|
|
platform_->CallIdleOnForegroundThread(isolate, task);
|
|
}
|
|
|
|
bool IdleTasksEnabled(v8::Isolate* isolate) override { return false; }
|
|
|
|
v8::TracingController* GetTracingController() override {
|
|
return platform_->GetTracingController();
|
|
}
|
|
|
|
bool PendingTask() { return task_ != nullptr; }
|
|
|
|
void PerformTask() {
|
|
Task* task = task_;
|
|
task_ = nullptr;
|
|
task->Run();
|
|
delete task;
|
|
}
|
|
|
|
private:
|
|
v8::Platform* platform_;
|
|
Task* task_;
|
|
};
|
|
|
|
TEST(IncrementalMarkingUsingTasks) {
|
|
if (!i::FLAG_incremental_marking) return;
|
|
FLAG_stress_incremental_marking = false;
|
|
CcTest::InitializeVM();
|
|
v8::Platform* old_platform = i::V8::GetCurrentPlatform();
|
|
MockPlatform platform(old_platform);
|
|
i::V8::SetPlatformForTesting(&platform);
|
|
i::heap::SimulateFullSpace(CcTest::heap()->old_space());
|
|
i::IncrementalMarking* marking = CcTest::heap()->incremental_marking();
|
|
marking->Stop();
|
|
marking->Start(i::GarbageCollectionReason::kTesting);
|
|
CHECK(platform.PendingTask());
|
|
while (platform.PendingTask()) {
|
|
platform.PerformTask();
|
|
}
|
|
CHECK(marking->IsStopped());
|
|
i::V8::SetPlatformForTesting(old_platform);
|
|
}
|
|
|
|
} // namespace internal
|
|
} // namespace v8
|