Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/compiler/z/codegen/J9ZSnippet.cpp
6004 views
1
/*******************************************************************************
2
* Copyright (c) 2000, 2016 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/Snippet.hpp"
24
#include "codegen/CodeGenerator.hpp"
25
#include "codegen/InstOpCode.hpp"
26
#include "infra/Assert.hpp"
27
28
/**
29
* Helper method to insert Runtime Instrumentation Hooks RION or RIOFF in snippet
30
*
31
* @param cg Code Generator Pointer
32
* @param cursor Current binary encoding cursor
33
* @param op Runtime Instrumentation opcode: TR::InstOpCode::RION or TR::InstOpCode::RIOFF
34
* @param isPrivateLinkage Whether the snippet is involved in a private JIT linkage (i.e. Call Helper to JITCODE)
35
* @return Updated binary encoding cursor after RI hook generation.
36
*/
37
uint8_t *
38
J9::Z::Snippet::generateRuntimeInstrumentationOnOffInstruction(TR::CodeGenerator *cg, uint8_t *cursor, TR::InstOpCode::Mnemonic op, bool isPrivateLinkage)
39
{
40
if (cg->getSupportsRuntimeInstrumentation())
41
{
42
if (!isPrivateLinkage || cg->getEnableRIOverPrivateLinkage())
43
{
44
if (op == TR::InstOpCode::RION)
45
*(int32_t *) cursor = 0xAA010000;
46
else if (op == TR::InstOpCode::RIOFF)
47
*(int32_t *) cursor = 0xAA030000;
48
else
49
TR_ASSERT( 0, "Unexpected RI opcode.");
50
cursor += sizeof(int32_t);
51
}
52
}
53
return cursor;
54
}
55
56
57
/**
58
* Helper method to query the length of Runtime Instrumentation Hooks RION or RIOFF in snippet
59
*
60
* @param cg Code Generator Pointer
61
* @param isPrivateLinkage Whether the snippet is involved in a private JIT linkage (i.e. Call Helper to JITCODE)
62
* @return The length of RION or RIOFF encoding if generated. Zero otherwise.
63
*/
64
uint32_t
65
J9::Z::Snippet::getRuntimeInstrumentationOnOffInstructionLength(TR::CodeGenerator *cg, bool isPrivateLinkage)
66
{
67
if (cg->getSupportsRuntimeInstrumentation())
68
{
69
if (!isPrivateLinkage || cg->getEnableRIOverPrivateLinkage())
70
return sizeof(int32_t); // Both RION and RIOFF are 32-bit (4-byte) instructions.
71
}
72
return 0;
73
}
74
75