Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/compiler/optimizer/InterProceduralAnalyzer.hpp
6000 views
1
/*******************************************************************************
2
* Copyright (c) 2000, 2019 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
#ifndef IPA_h
24
#define IPA_h
25
26
#include <stdint.h>
27
#include "env/TRMemory.hpp"
28
#include "il/Node.hpp"
29
#include "infra/Link.hpp"
30
#include "infra/List.hpp"
31
32
class TR_ClassExtendCheck;
33
class TR_ClassLoadCheck;
34
class TR_FrontEnd;
35
class TR_OpaqueClassBlock;
36
class TR_OpaqueMethodBlock;
37
class TR_ResolvedMethod;
38
namespace OMR { class RuntimeAssumption; }
39
namespace TR { class ResolvedMethodSymbol; }
40
namespace TR { class SymbolReference; }
41
namespace TR { class SymbolReferenceTable; }
42
namespace TR { class Compilation; }
43
44
namespace TR {
45
46
class GlobalSymbol : public TR_Link<TR::GlobalSymbol>
47
{
48
public:
49
GlobalSymbol(TR::SymbolReference *symRef) : _symRef(symRef) { }
50
TR::SymbolReference *_symRef;
51
};
52
53
struct PriorPeekInfo
54
{
55
TR_ResolvedMethod *_method;
56
TR_LinkHead<TR_ClassLoadCheck> _classesThatShouldNotBeLoaded;
57
TR_LinkHead<TR_ClassExtendCheck> _classesThatShouldNotBeNewlyExtended;
58
TR_LinkHead<TR::GlobalSymbol> _globalsWritten;
59
};
60
61
class InterProceduralAnalyzer
62
{
63
public:
64
TR_ALLOC(TR_Memory::InterProceduralAnalyzer)
65
66
InterProceduralAnalyzer(TR::Compilation *, bool trace);
67
68
int32_t perform();
69
70
TR_FrontEnd * fe() { return _fe; }
71
TR::Compilation * comp() { return _compilation; }
72
73
TR_Memory * trMemory() { return _trMemory; }
74
TR_StackMemory trStackMemory() { return _trMemory; }
75
TR_HeapMemory trHeapMemory() { return _trMemory; }
76
77
List<OMR::RuntimeAssumption> *analyzeCall(TR::Node *);
78
List<OMR::RuntimeAssumption> *analyzeCallGraph(TR::Node *, bool *);
79
List<OMR::RuntimeAssumption> *analyzeMethod(TR::Node *, TR_ResolvedMethod *, bool *);
80
81
bool isOnPeekingStack(TR_ResolvedMethod *method);
82
bool capableOfPeekingVirtualCalls();
83
bool trace() { return _trace; }
84
85
bool addClassThatShouldNotBeLoaded(char *name, int32_t len);
86
bool addClassThatShouldNotBeNewlyExtended(TR_OpaqueClassBlock *clazz);
87
bool addSingleClassThatShouldNotBeNewlyExtended(TR_OpaqueClassBlock *clazz);
88
bool addMethodThatShouldNotBeNewlyOverridden(TR_OpaqueMethodBlock *method);
89
bool addWrittenGlobal(TR::SymbolReference *symRef);
90
uint32_t hash(void * h, uint32_t size);
91
92
virtual bool alreadyPeekedMethod(TR_ResolvedMethod *method, bool *success, TR::PriorPeekInfo **);
93
virtual bool analyzeNode(TR::Node *node, vcount_t visitCount, bool *success) = 0;
94
95
protected:
96
//
97
// data
98
//
99
int32_t _sniffDepth, _maxSniffDepth;
100
int32_t _totalPeekedBytecodeSize;
101
int32_t _maxPeekedBytecodeSize;
102
bool _maxSniffDepthExceeded;
103
bool _trace;
104
TR_OpaqueClassBlock *_classPointer;
105
TR::Compilation *_compilation;
106
TR_Memory * _trMemory;
107
TR::SymbolReferenceTable *_symRefTab;
108
TR::SymbolReferenceTable *_currentPeekingSymRefTab;
109
TR_FrontEnd *_fe;
110
TR::ResolvedMethodSymbol *_currentMethodSymbol;
111
List<TR::PriorPeekInfo> _successfullyPeekedMethods;
112
List<TR_ResolvedMethod> _unsuccessfullyPeekedMethods;
113
TR_ScratchList<TR_ClassLoadCheck> _classesThatShouldNotBeLoadedInCurrentPeek;
114
TR_ScratchList<TR_ClassExtendCheck> _classesThatShouldNotBeNewlyExtendedInCurrentPeek;
115
TR_ScratchList<TR_ClassExtendCheck> * _classesThatShouldNotBeNewlyExtendedInCurrentPeekHT;
116
TR_ScratchList<TR::GlobalSymbol> _globalsWrittenInCurrentPeek;
117
ListElement<TR_ClassLoadCheck> *_prevClc;
118
ListElement<TR_ClassExtendCheck> *_prevCec;
119
ListElement<TR::GlobalSymbol> *_prevSymRef;
120
121
public:
122
TR_LinkHead<TR_ClassLoadCheck> _classesThatShouldNotBeLoaded;
123
TR_LinkHead<TR_ClassExtendCheck> _classesThatShouldNotBeNewlyExtended;
124
TR_LinkHead<TR_ClassExtendCheck> *_classesThatShouldNotBeNewlyExtendedHT;
125
TR_LinkHead<TR::GlobalSymbol> _globalsWritten;
126
};
127
128
}
129
130
#endif
131
132