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