1 // Copyright 2020 The PDFium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "testing/fuzzers/xfa_process_state.h" 6 7 #include "fxjs/gc/heap.h" 8 #include "v8/include/libplatform/libplatform.h" 9 XFAProcessState(v8::Platform * platform,v8::Isolate * isolate)10XFAProcessState::XFAProcessState(v8::Platform* platform, v8::Isolate* isolate) 11 : platform_(platform), isolate_(isolate), heap_(FXGC_CreateHeap()) {} 12 ~XFAProcessState()13XFAProcessState::~XFAProcessState() { 14 FXGC_ForceGarbageCollection(heap_.get()); 15 } 16 GetHeap() const17cppgc::Heap* XFAProcessState::GetHeap() const { 18 return heap_.get(); 19 } 20 ForceGCAndPump()21void XFAProcessState::ForceGCAndPump() { 22 FXGC_ForceGarbageCollection(heap_.get()); 23 while (v8::platform::PumpMessageLoop(platform_, isolate_)) 24 continue; 25 } 26