Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/compiler/optimizer/DynamicLiteralPool.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 DYNAMICLITERALPOOL_INCL
24
#define DYNAMICLITERALPOOL_INCL
25
26
#include <stddef.h>
27
#include <stdint.h>
28
#include "compile/Compilation.hpp"
29
#include "env/TRMemory.hpp"
30
#include "env/jittypes.h"
31
#include "il/Block.hpp"
32
#include "il/ILOpCodes.hpp"
33
#include "il/Node.hpp"
34
#include "infra/Assert.hpp"
35
#include "infra/List.hpp"
36
#include "optimizer/Optimization.hpp"
37
#include "optimizer/OptimizationManager.hpp"
38
39
40
namespace TR { class SymbolReference; }
41
namespace TR { class TreeTop; }
42
43
44
class TR_DynamicLiteralPool : public TR::Optimization
45
{
46
public:
47
TR_DynamicLiteralPool(TR::OptimizationManager *manager);
48
static TR::Optimization *create(TR::OptimizationManager *manager)
49
{
50
return new (manager->allocator()) TR_DynamicLiteralPool(manager);
51
}
52
53
virtual int32_t perform();
54
virtual int32_t performOnBlock(TR::Block *);
55
virtual const char * optDetailString() const throw();
56
57
int32_t process(TR::TreeTop *, TR::TreeTop *);
58
59
TR::SymbolReference * getLitPoolAddressSym()
60
{
61
if (_litPoolAddressSym==NULL) initLiteralPoolBase();
62
return _litPoolAddressSym;
63
}
64
TR::Node * getAloadFromCurrentBlock(TR::Node *parent)
65
{
66
if (_aloadFromCurrentBlock==NULL)
67
{
68
setAloadFromCurrentBlock(TR::Node::createWithSymRef(parent, TR::aload, 0, getLitPoolAddressSym()));
69
dumpOptDetails(comp(), "New aload needed, it is: %p!\n", _aloadFromCurrentBlock);
70
}
71
else
72
{
73
dumpOptDetails(comp(), "Can re-use aload %p!\n",_aloadFromCurrentBlock);
74
}
75
return _aloadFromCurrentBlock;
76
}
77
void setAloadFromCurrentBlock(TR::Node *aloadNode) {_aloadFromCurrentBlock = aloadNode;}
78
79
TR::Node *getVMThreadAloadFromCurrentBlock(TR::Node *parent);
80
void setVMThreadAloadFromCurrentBlock(TR::Node *aloadNode) {_vmThreadAloadFromCurrentBlock = aloadNode;}
81
82
int32_t getNumChild() {return _numChild;}
83
void setNumChild(int32_t n) {_numChild=n;}
84
85
private:
86
87
TR::SymbolReference * _litPoolAddressSym;
88
TR::Block * _currentBlock;
89
TR::Node * _aloadFromCurrentBlock;
90
TR::Node * _vmThreadAloadFromCurrentBlock;
91
bool _changed;
92
int32_t _numChild;
93
94
void initLiteralPoolBase();
95
bool processBlock(TR::Block *block, vcount_t visitCount);
96
bool visitTreeTop(TR::TreeTop *, TR::Node *grandParent, TR::Node *parent, TR::Node *node, vcount_t visitCount);
97
bool transformLitPoolConst(TR::Node *grandParent, TR::Node *parent, TR::Node *child);
98
bool transformConstToIndirectLoad(TR::Node *parent, TR::Node *child);
99
bool transformStaticSymRefToIndirectLoad(TR::TreeTop *, TR::Node *parent, TR::Node * & child);
100
bool transformNeeded(TR::Node *grandParent, TR::Node *parent, TR::Node *child);
101
bool addNewAloadChild(TR::Node *node);
102
bool handleNodeUsingSystemStack(TR::TreeTop *, TR::Node *parent, TR::Node *node, vcount_t visitCount);
103
bool handleNodeUsingVMThread(TR::TreeTop *, TR::Node *parent, TR::Node *node, vcount_t visitCount);
104
};
105
106
#endif
107
108
109