Commit aa4b47b9 authored by Michael Lippautz's avatar Michael Lippautz Committed by Commit Bot

cppgc: Fix GCInvoker task handle

The handle was always created empty which resulted in a DCHECK crash
in debug builds and in never-cancelled tasks in release builds.

Bug: chromium:1056170
Change-Id: I798ce65c37738bbe9c60b44b692ff04536f6d830
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2388101Reviewed-by: 's avatarAnton Bikineev <bikineev@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69653}
parent 47b60053
......@@ -38,7 +38,9 @@ class GCInvoker::GCInvokerImpl final : public GarbageCollector {
}
explicit GCTask(GarbageCollector* collector)
: collector_(collector), saved_epoch_(collector->epoch()) {}
: collector_(collector),
handle_(Handle::NonEmptyTag{}),
saved_epoch_(collector->epoch()) {}
private:
void Run() final {
......
......@@ -6,6 +6,7 @@
#include "include/cppgc/platform.h"
#include "src/heap/cppgc/heap.h"
#include "test/unittests/heap/cppgc/test-platform.h"
#include "testing/gmock/include/gmock/gmock-matchers.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
......@@ -83,7 +84,7 @@ TEST(GCInvokerTest, ConservativeGCIsInvokedSynchronouslyWhenSupported) {
invoker.CollectGarbage(GarbageCollector::Config::ConservativeAtomicConfig());
}
TEST(GCInvokerTest, ConservativeGCIsInvokedAsPreciseGCViaPlatform) {
TEST(GCInvokerTest, ConservativeGCIsScheduledAsPreciseGCViaPlatform) {
std::shared_ptr<cppgc::TaskRunner> runner =
std::shared_ptr<cppgc::TaskRunner>(new MockTaskRunner());
MockPlatform platform(runner);
......@@ -96,6 +97,17 @@ TEST(GCInvokerTest, ConservativeGCIsInvokedAsPreciseGCViaPlatform) {
invoker.CollectGarbage(GarbageCollector::Config::ConservativeAtomicConfig());
}
TEST(GCInvokerTest, ConservativeGCIsInvokedAsPreciseGCViaPlatform) {
testing::TestPlatform platform;
MockGarbageCollector gc;
GCInvoker invoker(&gc, &platform,
cppgc::Heap::StackSupport::kNoConservativeStackScan);
EXPECT_CALL(gc, epoch).WillRepeatedly(::testing::Return(0));
EXPECT_CALL(gc, CollectGarbage);
invoker.CollectGarbage(GarbageCollector::Config::ConservativeAtomicConfig());
platform.WaitAllForegroundTasks();
}
TEST(GCInvokerTest, IncrementalGCIsStarted) {
// Since StartIncrementalGarbageCollection doesn't scan the stack, support for
// conservative stack scanning should not matter.
......
......@@ -19,13 +19,17 @@ namespace testing {
class TestTaskRunner : public v8::TaskRunner {
public:
void PostTask(std::unique_ptr<v8::Task> task) override;
void PostNonNestableTask(std::unique_ptr<v8::Task> task) override;
void PostDelayedTask(std::unique_ptr<v8::Task> task, double) override;
bool NonNestableTasksEnabled() const override { return true; }
void PostNonNestableTask(std::unique_ptr<v8::Task> task) override;
bool NonNestableDelayedTasksEnabled() const override { return true; }
void PostNonNestableDelayedTask(std::unique_ptr<v8::Task> task,
double) override;
void PostIdleTask(std::unique_ptr<v8::IdleTask> task) override;
bool IdleTasksEnabled() override { return true; }
void PostIdleTask(std::unique_ptr<v8::IdleTask> task) override;
bool RunSingleTask();
bool RunSingleIdleTask(double duration_in_seconds);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment