Path: blob/master/runtime/gc_glue_java/ArrayletObjectModelBase.cpp
5985 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 "ArrayletObjectModelBase.hpp"23#include "GCExtensionsBase.hpp"2425bool26GC_ArrayletObjectModelBase::initialize(MM_GCExtensionsBase * extensions)27{28#if defined(OMR_GC_COMPRESSED_POINTERS) && defined(OMR_GC_FULL_POINTERS)29_compressObjectReferences = extensions->compressObjectReferences();30#endif /* defined(OMR_GC_COMPRESSED_POINTERS) && defined(OMR_GC_FULL_POINTERS) */31_omrVM = extensions->getOmrVM();32_arrayletRangeBase = NULL;33_arrayletRangeTop = (void *)UDATA_MAX;34_arrayletSubSpace = NULL;35#if defined(J9VM_GC_ENABLE_DOUBLE_MAP)36_enableDoubleMapping = false;37#endif /* J9VM_GC_ENABLE_DOUBLE_MAP */38_largestDesirableArraySpineSize = UDATA_MAX;3940return true;41}4243void44GC_ArrayletObjectModelBase::tearDown(MM_GCExtensionsBase * extensions)45{4647/* ensure that we catch any invalid uses during shutdown */48_omrVM = NULL;49_arrayletRangeTop = NULL;50_arrayletSubSpace = NULL;51_arrayletRangeBase = 0;52_largestDesirableArraySpineSize = 0;53}545556void57GC_ArrayletObjectModelBase::expandArrayletSubSpaceRange(MM_MemorySubSpace * subSpace, void * rangeBase, void * rangeTop, UDATA largestDesirableArraySpineSize)58{59/* Is this the first expand? */60if(NULL == _arrayletSubSpace) {61_arrayletRangeBase = rangeBase;62_arrayletRangeTop = rangeTop;63_arrayletSubSpace = subSpace;64_largestDesirableArraySpineSize = largestDesirableArraySpineSize;65} else {66/* Expand the valid range for arraylets. */67if (rangeBase < _arrayletRangeBase) {68_arrayletRangeBase = rangeBase;69}70if (rangeTop > _arrayletRangeTop) {71_arrayletRangeTop = rangeTop;72}73}74}7576UDATA77GC_ArrayletObjectModelBase::getSpineSizeWithoutHeader(ArrayLayout layout, UDATA numberArraylets, UDATA dataSize, bool alignData)78{79/* The spine consists of three (possibly empty) sections, not including the header:80* 1. the alignment word - padding between arrayoid and inline-data81* 2. the arrayoid - an array of pointers to the leaves82* 3. in-line data83* In hybrid specs, the spine may also include padding for a secondary size field in empty arrays84*/85UDATA const slotSize = J9GC_REFERENCE_SIZE(this);86MM_GCExtensionsBase* extensions = MM_GCExtensionsBase::getExtensions(_omrVM);87UDATA spineArrayoidSize = 0;88UDATA spinePaddingSize = 0;89if (InlineContiguous != layout) {90if (0 != dataSize) {91/* not in-line, so there in an arrayoid */92spinePaddingSize = alignData ? (extensions->getObjectAlignmentInBytes() - slotSize) : 0;93spineArrayoidSize = numberArraylets * slotSize;94}95}96UDATA spineDataSize = 0;97if (InlineContiguous == layout) {98spineDataSize = dataSize; // All data in spine99} else if (Hybrid == layout) {100#if defined(J9VM_GC_ENABLE_DOUBLE_MAP)101if (extensions->indexableObjectModel.isDoubleMappingEnabled()) {102spineDataSize = 0;103} else104#endif /* J9VM_GC_ENABLE_DOUBLE_MAP */105{106/* Last arraylet in spine */107spineDataSize = (dataSize & (_omrVM->_arrayletLeafSize - 1));108}109}110111return spinePaddingSize + spineArrayoidSize + spineDataSize;112}113114115