Path: blob/master/runtime/gc_realtime/EnvironmentRealtime.cpp
5986 views
/*******************************************************************************1* Copyright (c) 1991, 2019 IBM Corp. and others2*3* This program and the accompanying materials are made available under4* the terms of the Eclipse Public License 2.0 which accompanies this5* distribution and is available at https://www.eclipse.org/legal/epl-2.0/6* or the Apache License, Version 2.0 which accompanies this distribution and7* is available at https://www.apache.org/licenses/LICENSE-2.0.8*9* This Source Code may also be made available under the following10* Secondary Licenses when the conditions for such availability set11* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU12* General Public License, version 2 with the GNU Classpath13* Exception [1] and GNU General Public License, version 2 with the14* OpenJDK Assembly Exception [2].15*16* [1] https://www.gnu.org/software/classpath/license.html17* [2] http://openjdk.java.net/legal/assembly-exception.html18*19* 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-exception20*******************************************************************************/2122#include "omr.h"23#include "omrcfg.h"2425#include "EnvironmentRealtime.hpp"26#include "GCExtensionsBase.hpp"27#include "HeapRegionQueue.hpp"28#include "OSInterface.hpp"29#include "RealtimeGC.hpp"30#include "RealtimeRootScanner.hpp"31#include "SegregatedAllocationTracker.hpp"32#include "Timer.hpp"3334MM_EnvironmentRealtime *35MM_EnvironmentRealtime::newInstance(MM_GCExtensionsBase *extensions, OMR_VMThread *omrVMThread)36{37void *envPtr;38MM_EnvironmentRealtime *env = NULL;3940envPtr = (void *)pool_newElement(extensions->environments);41if (envPtr) {42if (omrVMThread) {43env = new(envPtr) MM_EnvironmentRealtime(omrVMThread);44} else {45env = new(envPtr) MM_EnvironmentRealtime(extensions->getOmrVM());46}47if (!env->initialize(extensions)) {48env->kill();49env = NULL;50}51}5253return env;54}5556void57MM_EnvironmentRealtime::kill()58{59MM_EnvironmentBase::kill();60}6162bool63MM_EnvironmentRealtime::initialize(MM_GCExtensionsBase *extensions)64{65/* initialize base class */66if(!MM_EnvironmentBase::initialize(extensions)) {67return false;68}6970if (NULL == (_timer = MM_Timer::newInstance(this, _osInterface))) {71return false;72}7374_monitorCacheCleared = FALSE;7576_distanceToYieldTimeCheck = extensions->distanceToYieldTimeCheck;7778_overflowCache = (MM_HeapRegionDescriptorRealtime**)getForge()->allocate(sizeof(MM_HeapRegionDescriptorRealtime *) * extensions->overflowCacheCount, MM_AllocationCategory::FIXED, OMR_GET_CALLSITE());79if (NULL == _overflowCache) {80return false;81}8283_yieldDisableDepth = 0;8485return true;86}8788void89MM_EnvironmentRealtime::tearDown(MM_GCExtensionsBase *extensions)90{91if (_overflowCache != NULL) {92getForge()->free(_overflowCache);93_overflowCache = NULL;94}95if (NULL != _timer) {96_timer->kill(this);97_timer = NULL;98}99100/* tearDown base class */101MM_EnvironmentBase::tearDown(extensions);102}103104void MM_EnvironmentRealtime::disableYield()105{106_yieldDisableDepth++;107}108109void MM_EnvironmentRealtime::enableYield()110{111_yieldDisableDepth--;112assert1(_yieldDisableDepth >= 0);113}114115void116MM_EnvironmentRealtime::reportScanningSuspended() {117if (NULL != _rootScanner) {118_rootScanner->reportScanningSuspended();119}120}121122void123MM_EnvironmentRealtime::reportScanningResumed() {124if (NULL != _rootScanner) {125_rootScanner->reportScanningResumed();126}127}128129130