Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/compiler/codegen/J9GCStackAtlas.cpp
6000 views
1
/*******************************************************************************
2
* Copyright (c) 2000, 2021 IBM Corp. and others
3
*
4
* This program and the accompanying materials are made available under
5
* the terms of the Eclipse Public License 2.0 which accompanies this
6
* 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 and
8
* is available at https://www.apache.org/licenses/LICENSE-2.0.
9
*
10
* This Source Code may also be made available under the following
11
* Secondary Licenses when the conditions for such availability set
12
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
13
* General Public License, version 2 with the GNU Classpath
14
* Exception [1] and GNU General Public License, version 2 with the
15
* OpenJDK Assembly Exception [2].
16
*
17
* [1] https://www.gnu.org/software/classpath/license.html
18
* [2] http://openjdk.java.net/legal/assembly-exception.html
19
*
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-exception
21
*******************************************************************************/
22
23
#if defined(J9ZOS390)
24
#pragma csect(CODE,"TRJ9GCStackAtlas#C")
25
#pragma csect(STATIC,"TRJ9GCStackAtlas#S")
26
#pragma csect(TEST,"TRJ9GCStackAtlas#T")
27
#endif
28
29
#include "codegen/GCStackAtlas.hpp"
30
#include "codegen/GCStackMap.hpp"
31
#include "compile/Compilation.hpp"
32
#include "codegen/CodeGenerator.hpp"
33
34
35
void
36
J9::GCStackAtlas::close(TR::CodeGenerator *cg)
37
{
38
// Dump the atlas before merging. The atlas after merging is given by the
39
// dump of the external atlas
40
//
41
TR::Compilation *comp = cg->comp();
42
43
if (comp->getOption(TR_TraceCG))
44
{
45
comp->getDebug()->print(comp->getOutFile(), self());
46
}
47
48
TR_GCStackMap * parameterMap = 0;
49
if (self()->getInternalPointerMap())
50
{
51
parameterMap = self()->getParameterMap();
52
}
53
54
if (comp->getOption(TR_DisableMergeStackMaps))
55
return;
56
57
// Merge adjacent similar maps
58
//
59
uint8_t *start = cg->getCodeStart();
60
ListElement<TR_GCStackMap> *mapEntry, *next;
61
TR_GCStackMap *map, *nextMap;
62
63
for (mapEntry = self()->getStackMapList().getListHead(); mapEntry; mapEntry = next)
64
{
65
next = mapEntry->getNextElement();
66
map = mapEntry->getData();
67
68
// See if the next map can be merged with this one.
69
// If they have the same contents, the ranges are merged and a single map
70
// represents both ranges.
71
//
72
if (!next)
73
{
74
continue;
75
}
76
77
nextMap = next->getData();
78
79
int32_t mapBytes = map->getMapSizeInBytes();
80
81
// TODO: We should be using mapsAreIdentical API here instead. Also it seems there is a similar comment in OMR,
82
// i.e. "Maps are the same". Do we need a common API here for map merging which can be extended?
83
if (nextMap != parameterMap &&
84
mapBytes == nextMap->getMapSizeInBytes() &&
85
map->getRegisterMap() == nextMap->getRegisterMap() &&
86
!memcmp(map->getMapBits(), nextMap->getMapBits(), mapBytes) &&
87
(comp->getOption(TR_DisableLiveMonitorMetadata) ||
88
((map->getLiveMonitorBits() != 0) == (nextMap->getLiveMonitorBits() != 0) &&
89
(map->getLiveMonitorBits() == 0 ||
90
!memcmp(map->getLiveMonitorBits(), nextMap->getLiveMonitorBits(), mapBytes)))) &&
91
((!nextMap->getInternalPointerMap() && !map->getInternalPointerMap()) ||
92
(nextMap->getInternalPointerMap() && map->getInternalPointerMap() &&
93
map->isInternalPointerMapIdenticalTo(nextMap))) &&
94
map->isByteCodeInfoIdenticalTo(nextMap))
95
{
96
// Maps are the same - can merge
97
//
98
if (comp->getOption(TR_TraceCG))
99
traceMsg(comp,
100
"Map with code offset range starting at [%08x] is identical to the previous map [%08x], merging and eliminating previous\n",
101
nextMap->getLowestCodeOffset(), map->getLowestCodeOffset());
102
103
map->setLowestCodeOffset(nextMap->getLowestCodeOffset());
104
self()->getStackMapList().removeNext(mapEntry);
105
self()->decNumberOfMaps();
106
next = mapEntry;
107
}
108
}
109
}
110
111