blob: f66ed15c92c46fcb3ee8a1236e2f6bfb0a9a1fdf [file]
// Copyright 2020 The PDFium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "testing/fuzzers/xfa_process_state.h"
#include "fxjs/gc/heap.h"
#include "v8/include/libplatform/libplatform.h"
XFAProcessState::XFAProcessState(v8::Platform* platform, v8::Isolate* isolate)
: platform_(platform), isolate_(isolate), heap_(FXGC_CreateHeap(isolate)) {}
XFAProcessState::~XFAProcessState() {
FXGC_ForceGarbageCollection(heap_.get());
}
cppgc::Heap* XFAProcessState::GetHeap() const {
return heap_ ? heap_->GetStandaloneHeap() : nullptr;
}
void XFAProcessState::ForceGCAndPump() {
FXGC_ForceGarbageCollection(heap_.get());
while (v8::platform::PumpMessageLoop(platform_, isolate_)) {
continue;
}
}