Path: blob/master/runtime/compiler/codegen/J9GCStackAtlas.cpp
6000 views
/*******************************************************************************1* Copyright (c) 2000, 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#if defined(J9ZOS390)23#pragma csect(CODE,"TRJ9GCStackAtlas#C")24#pragma csect(STATIC,"TRJ9GCStackAtlas#S")25#pragma csect(TEST,"TRJ9GCStackAtlas#T")26#endif2728#include "codegen/GCStackAtlas.hpp"29#include "codegen/GCStackMap.hpp"30#include "compile/Compilation.hpp"31#include "codegen/CodeGenerator.hpp"323334void35J9::GCStackAtlas::close(TR::CodeGenerator *cg)36{37// Dump the atlas before merging. The atlas after merging is given by the38// dump of the external atlas39//40TR::Compilation *comp = cg->comp();4142if (comp->getOption(TR_TraceCG))43{44comp->getDebug()->print(comp->getOutFile(), self());45}4647TR_GCStackMap * parameterMap = 0;48if (self()->getInternalPointerMap())49{50parameterMap = self()->getParameterMap();51}5253if (comp->getOption(TR_DisableMergeStackMaps))54return;5556// Merge adjacent similar maps57//58uint8_t *start = cg->getCodeStart();59ListElement<TR_GCStackMap> *mapEntry, *next;60TR_GCStackMap *map, *nextMap;6162for (mapEntry = self()->getStackMapList().getListHead(); mapEntry; mapEntry = next)63{64next = mapEntry->getNextElement();65map = mapEntry->getData();6667// See if the next map can be merged with this one.68// If they have the same contents, the ranges are merged and a single map69// represents both ranges.70//71if (!next)72{73continue;74}7576nextMap = next->getData();7778int32_t mapBytes = map->getMapSizeInBytes();7980// TODO: We should be using mapsAreIdentical API here instead. Also it seems there is a similar comment in OMR,81// i.e. "Maps are the same". Do we need a common API here for map merging which can be extended?82if (nextMap != parameterMap &&83mapBytes == nextMap->getMapSizeInBytes() &&84map->getRegisterMap() == nextMap->getRegisterMap() &&85!memcmp(map->getMapBits(), nextMap->getMapBits(), mapBytes) &&86(comp->getOption(TR_DisableLiveMonitorMetadata) ||87((map->getLiveMonitorBits() != 0) == (nextMap->getLiveMonitorBits() != 0) &&88(map->getLiveMonitorBits() == 0 ||89!memcmp(map->getLiveMonitorBits(), nextMap->getLiveMonitorBits(), mapBytes)))) &&90((!nextMap->getInternalPointerMap() && !map->getInternalPointerMap()) ||91(nextMap->getInternalPointerMap() && map->getInternalPointerMap() &&92map->isInternalPointerMapIdenticalTo(nextMap))) &&93map->isByteCodeInfoIdenticalTo(nextMap))94{95// Maps are the same - can merge96//97if (comp->getOption(TR_TraceCG))98traceMsg(comp,99"Map with code offset range starting at [%08x] is identical to the previous map [%08x], merging and eliminating previous\n",100nextMap->getLowestCodeOffset(), map->getLowestCodeOffset());101102map->setLowestCodeOffset(nextMap->getLowestCodeOffset());103self()->getStackMapList().removeNext(mapEntry);104self()->decNumberOfMaps();105next = mapEntry;106}107}108}109110111