Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/compiler/aarch64/codegen/ARM64Recompilation.cpp
6004 views
1
/*******************************************************************************
2
* Copyright (c) 2019, 2020 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
#include "codegen/ARM64Recompilation.hpp"
24
#include "codegen/ARM64RecompilationSnippet.hpp"
25
#include "codegen/CodeGenerator.hpp"
26
#include "codegen/GenerateInstructions.hpp"
27
28
TR_ARM64Recompilation::TR_ARM64Recompilation(TR::Compilation * comp)
29
: TR::Recompilation(comp)
30
{
31
_countingSupported = true;
32
33
setupMethodInfo();
34
}
35
36
TR::Recompilation *TR_ARM64Recompilation::allocate(TR::Compilation *comp)
37
{
38
if (comp->isRecompilationEnabled())
39
{
40
return new (comp->trHeapMemory()) TR_ARM64Recompilation(comp);
41
}
42
43
return NULL;
44
}
45
46
TR_PersistentMethodInfo *TR_ARM64Recompilation::getExistingMethodInfo(TR_ResolvedMethod *method)
47
{
48
int8_t *startPC = (int8_t *)method->startAddressForInterpreterOfJittedMethod();
49
TR_PersistentMethodInfo *info = getJittedBodyInfoFromPC(startPC)->getMethodInfo();
50
return info;
51
}
52
53
TR::Instruction *TR_ARM64Recompilation::generatePrePrologue()
54
{
55
TR_J9VMBase *fej9 = (TR_J9VMBase *)(comp()->fe());
56
57
// If in Full Speed Debug, allow to go through
58
if (!couldBeCompiledAgain() && !_compilation->getOption(TR_FullSpeedDebug))
59
return NULL;
60
61
// x9 may contain the vtable offset, and must be preserved here
62
// See PicBuilder.spp and Recompilation.spp
63
TR::Instruction *cursor = NULL;
64
TR::Machine *machine = cg()->machine();
65
TR::Register *x8 = machine->getRealRegister(TR::RealRegister::x8);
66
TR::Register *lr = machine->getRealRegister(TR::RealRegister::lr); // Link Register
67
TR::Register *xzr = machine->getRealRegister(TR::RealRegister::xzr); // zero register
68
TR::Node *firstNode = comp()->getStartTree()->getNode();
69
TR::SymbolReference *recompileMethodSymRef = cg()->symRefTab()->findOrCreateRuntimeHelper(TR_ARM64samplingRecompileMethod);
70
TR_PersistentJittedBodyInfo *info = getJittedBodyInfo();
71
72
// Force creation of switch to interpreter preprologue if in Full Speed Debug
73
if (cg()->mustGenerateSwitchToInterpreterPrePrologue())
74
{
75
cursor = cg()->generateSwitchToInterpreterPrePrologue(cursor, firstNode);
76
}
77
78
if (useSampling() && couldBeCompiledAgain())
79
{
80
// x8 must contain the saved LR; see Recompilation.spp
81
// cannot use generateMovInstruction() here
82
cursor = new (cg()->trHeapMemory()) TR::ARM64Trg1Src2Instruction(TR::InstOpCode::orrx, firstNode, x8, xzr, lr, cursor, cg());
83
cursor = generateImmSymInstruction(cg(), TR::InstOpCode::bl, firstNode,
84
(uintptr_t)recompileMethodSymRef->getMethodAddress(),
85
new (cg()->trHeapMemory()) TR::RegisterDependencyConditions(0, 0, cg()->trMemory()),
86
recompileMethodSymRef, NULL, cursor);
87
cursor = generateRelocatableImmInstruction(cg(), TR::InstOpCode::dd, firstNode, (uintptr_t)info, TR_BodyInfoAddress, cursor);
88
89
// space for preserving original jitEntry instruction
90
cursor = generateImmInstruction(cg(), TR::InstOpCode::dd, firstNode, 0, cursor);
91
}
92
93
return cursor;
94
}
95
96
TR::Instruction *TR_ARM64Recompilation::generatePrologue(TR::Instruction *cursor)
97
{
98
TR::Recompilation *recomp = comp()->getRecompilationInfo();
99
if (!recomp->useSampling())
100
{
101
// counting recompilation
102
TR_UNIMPLEMENTED();
103
}
104
return cursor;
105
}
106
107