Path: blob/master/runtime/gc_glue_java/CompactSchemeFixupObject.cpp
5990 views
/*******************************************************************************1* Copyright (c) 1991, 2021 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 "CompactSchemeFixupObject.hpp"2324#include "objectdescription.h"2526#include "CollectorLanguageInterfaceImpl.hpp"27#include "EnvironmentStandard.hpp"28#include "Debug.hpp"29#include "HeapRegionIteratorStandard.hpp"30#include "MixedObjectIterator.hpp"31#include "ObjectAccessBarrier.hpp"32#include "OwnableSynchronizerObjectBuffer.hpp"33#include "ParallelDispatcher.hpp"34#include "PointerContiguousArrayIterator.hpp"35#include "FlattenedContiguousArrayIterator.hpp"36#include "Task.hpp"3738void39MM_CompactSchemeFixupObject::fixupMixedObject(omrobjectptr_t objectPtr)40{41GC_MixedObjectIterator it(_omrVM, objectPtr);42GC_SlotObject *slotObject;4344while (NULL != (slotObject = it.nextSlot())) {45_compactScheme->fixupObjectSlot(slotObject);46}47}4849void50MM_CompactSchemeFixupObject::fixupArrayObject(omrobjectptr_t objectPtr)51{52GC_PointerContiguousArrayIterator it(_omrVM, objectPtr);53GC_SlotObject *slotObject;5455while (NULL != (slotObject = it.nextSlot())) {56_compactScheme->fixupObjectSlot(slotObject);57}58}5960void61MM_CompactSchemeFixupObject::fixupFlattenedArrayObject(omrobjectptr_t objectPtr)62{63GC_FlattenedContiguousArrayIterator it(_omrVM, objectPtr);64GC_SlotObject *slotObject;6566while (NULL != (slotObject = it.nextSlot())) {67_compactScheme->fixupObjectSlot(slotObject);68}69}7071MMINLINE void72MM_CompactSchemeFixupObject::addOwnableSynchronizerObjectInList(MM_EnvironmentBase *env, omrobjectptr_t objectPtr)73{74/* if isObjectInOwnableSynchronizerList() return NULL, it means the object isn't in OwnableSynchronizerList,75* it could be the constructing object which would be added in the list after the construction finish later. ignore the object to avoid duplicated reference in the list. */76if (NULL != _extensions->accessBarrier->isObjectInOwnableSynchronizerList(objectPtr)) {77env->getGCEnvironment()->_ownableSynchronizerObjectBuffer->add(env, objectPtr);78}79}8081void82MM_CompactSchemeFixupObject::fixupObject(MM_EnvironmentStandard *env, omrobjectptr_t objectPtr)83{84switch(env->getExtensions()->objectModel.getScanType(objectPtr)) {85case GC_ObjectModel::SCAN_MIXED_OBJECT_LINKED:86case GC_ObjectModel::SCAN_ATOMIC_MARKABLE_REFERENCE_OBJECT:87case GC_ObjectModel::SCAN_MIXED_OBJECT:88case GC_ObjectModel::SCAN_CLASS_OBJECT:89case GC_ObjectModel::SCAN_CLASSLOADER_OBJECT:90case GC_ObjectModel::SCAN_REFERENCE_MIXED_OBJECT:91fixupMixedObject(objectPtr);92break;9394case GC_ObjectModel::SCAN_POINTER_ARRAY_OBJECT:95fixupArrayObject(objectPtr);96break;9798case GC_ObjectModel::SCAN_PRIMITIVE_ARRAY_OBJECT:99/* nothing to do */100break;101102case GC_ObjectModel::SCAN_OWNABLESYNCHRONIZER_OBJECT:103addOwnableSynchronizerObjectInList(env, objectPtr);104fixupMixedObject(objectPtr);105break;106107case GC_ObjectModel::SCAN_FLATTENED_ARRAY_OBJECT:108fixupFlattenedArrayObject(objectPtr);109break;110111default:112Assert_MM_unreachable();113}114}115116117void118MM_CompactSchemeFixupObject::verifyForwardingPtr(omrobjectptr_t objectPtr, omrobjectptr_t forwardingPtr)119{120assume0(forwardingPtr <= objectPtr);121assume0(J9GC_J9OBJECT_CLAZZ(forwardingPtr, _extensions) && ((UDATA)J9GC_J9OBJECT_CLAZZ(forwardingPtr, _extensions) & 0x3) == 0);122}123124125