Path: blob/master/runtime/gc_modron_standard/ConcurrentSweepGC.cpp
5985 views
1/*******************************************************************************2* Copyright (c) 1991, 2017 IBM Corp. and others3*4* This program and the accompanying materials are made available under5* the terms of the Eclipse Public License 2.0 which accompanies this6* distribution and is available at https://www.eclipse.org/legal/epl-2.0/7* or the Apache License, Version 2.0 which accompanies this distribution and8* is available at https://www.apache.org/licenses/LICENSE-2.0.9*10* This Source Code may also be made available under the following11* Secondary Licenses when the conditions for such availability set12* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU13* General Public License, version 2 with the GNU Classpath14* Exception [1] and GNU General Public License, version 2 with the15* OpenJDK Assembly Exception [2].16*17* [1] https://www.gnu.org/software/classpath/license.html18* [2] http://openjdk.java.net/legal/assembly-exception.html19*20* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception21*******************************************************************************/2223#include "j9.h"24#include "j9cfg.h"25#include "j9port.h"2627#if defined(J9VM_GC_CONCURRENT_SWEEP)2829#include "ConcurrentSweepGC.hpp"3031#include "ConcurrentSweepScheme.hpp"3233MM_ConcurrentSweepGC *34MM_ConcurrentSweepGC::newInstance(MM_EnvironmentBase *env)35{36MM_ConcurrentSweepGC *globalGC;3738globalGC = (MM_ConcurrentSweepGC *)env->getForge()->allocate(sizeof(MM_ConcurrentSweepGC), MM_AllocationCategory::FIXED, J9_GET_CALLSITE());39if (globalGC) {40new(globalGC) MM_ConcurrentSweepGC(env);41if (!globalGC->initialize(env)) {42globalGC->kill(env);43globalGC = NULL;44}45}46return globalGC;47}4849void50MM_ConcurrentSweepGC::internalPreCollect(MM_EnvironmentBase *env, MM_MemorySubSpace *subSpace, MM_AllocateDescription *allocDescription, U_32 gcCode)51{52/* Finish off any sweep work that was still in progress */53MM_ConcurrentSweepScheme *concurrentSweep = (MM_ConcurrentSweepScheme *)_sweepScheme;54if(concurrentSweep->isConcurrentSweepActive()) {55concurrentSweep->completeSweep(env, ABOUT_TO_GC);56}5758MM_ParallelGlobalGC::internalPreCollect(env, subSpace, allocDescription, gcCode);59}6061/**62* Pay the allocation tax for the mutator.63*/64void65MM_ConcurrentSweepGC::payAllocationTax(MM_EnvironmentBase *env, MM_MemorySubSpace *subspace, MM_MemorySubSpace *baseSubSpace, MM_AllocateDescription *allocDescription)66{67((MM_ConcurrentSweepScheme *)_sweepScheme)->payAllocationTax(env, baseSubSpace, allocDescription);68}6970/**71* Replenish a pools free lists to satisfy a given allocate.72* The given pool was unable to satisfy an allocation request of (at least) the given size. See if there is work73* that can be done to increase the free stores of the pool so that the request can be met.74* @note This call is made under the pools allocation lock (or equivalent)75* @note Base implementation does no work.76* @return True if the pool was replenished with a free entry that can satisfy the size, false otherwise.77*/78bool79MM_ConcurrentSweepGC::replenishPoolForAllocate(MM_EnvironmentBase *env, MM_MemoryPool *memoryPool, UDATA size)80{81return _sweepScheme->replenishPoolForAllocate(env, memoryPool, size);82}8384#endif /* J9VM_GC_CONCURRENT_SWEEP */858687