Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/compiler/codegen/J9WatchedInstanceFieldSnippet.cpp
6000 views
1
/*******************************************************************************
2
* Copyright (c) 2019, 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
#include "codegen/J9WatchedInstanceFieldSnippet.hpp"
24
#include "codegen/Relocation.hpp"
25
26
TR::J9WatchedInstanceFieldSnippet::J9WatchedInstanceFieldSnippet(TR::CodeGenerator *cg, TR::Node *node, J9Method *m, UDATA loc, UDATA os)
27
: TR::Snippet(cg, node, generateLabelSymbol(cg), false)
28
{
29
instanceFieldData.method = m;
30
instanceFieldData.location = loc;
31
instanceFieldData.offset = os;
32
}
33
34
uint8_t *TR::J9WatchedInstanceFieldSnippet::emitSnippetBody()
35
{
36
uint8_t *cursor = cg()->getBinaryBufferCursor();
37
getSnippetLabel()->setCodeLocation(cursor);
38
TR::Node *node = getNode();
39
40
// We emit the dataSnippet based on the assumption that the J9JITWatchedInstanceFieldData structure is laid out as below:
41
/* typedef struct J9JITWatchedInstanceFieldData {
42
J9Method *method; // Currently executing method
43
UDATA location; // Bytecode PC index
44
UDATA offset; // Field offset (not including header)
45
} J9JITWatchedInstanceFieldData; */
46
47
// Emit each field and add a relocation record (for AOT compiles) for any field if needed.
48
49
J9JITWatchedInstanceFieldData *str = reinterpret_cast<J9JITWatchedInstanceFieldData *>(cursor);
50
str->method = instanceFieldData.method;
51
str->location = instanceFieldData.location;
52
str->offset = instanceFieldData.offset;
53
54
if (cg()->comp()->getOption(TR_UseSymbolValidationManager))
55
{
56
cg()->addExternalRelocation(
57
new (cg()->trHeapMemory()) TR::ExternalRelocation(cursor + offsetof(J9JITWatchedInstanceFieldData, method), reinterpret_cast<uint8_t *>(instanceFieldData.method), reinterpret_cast<uint8_t *>(TR::SymbolType::typeMethod), TR_SymbolFromManager, cg()),
58
__FILE__,
59
__LINE__,
60
node);
61
}
62
else
63
{
64
cg()->addExternalRelocation(new (cg()->trHeapMemory()) TR::ExternalRelocation(cursor + offsetof(J9JITWatchedInstanceFieldData, method), NULL, TR_RamMethod, cg()), __FILE__, __LINE__, node);
65
}
66
cursor += sizeof(J9JITWatchedInstanceFieldData);
67
68
return cursor;
69
}
70
71
void TR::J9WatchedInstanceFieldSnippet::print(TR::FILE *pOutFile, TR_Debug *debug)
72
{
73
uint8_t *bufferPos = getSnippetLabel()->getCodeLocation();
74
75
debug->printSnippetLabel(pOutFile, getSnippetLabel(), bufferPos, "J9WatchedInstanceFieldSnippet");
76
77
debug->printPrefix(pOutFile, NULL, bufferPos, sizeof(J9Method *));
78
trfprintf(pOutFile, "DC \t%p \t\t# J9Method", *(reinterpret_cast<J9Method **>(bufferPos)));
79
bufferPos += sizeof(J9Method *);
80
81
debug->printPrefix(pOutFile, NULL, bufferPos, sizeof(UDATA));
82
trfprintf(pOutFile, "DC \t%lu \t\t# location", *(reinterpret_cast<UDATA *>(bufferPos)));
83
bufferPos += sizeof(UDATA);
84
85
debug->printPrefix(pOutFile, NULL, bufferPos, sizeof(UDATA));
86
trfprintf(pOutFile, "DC \t%lu \t\t# offset", *(reinterpret_cast<UDATA *>(bufferPos)));
87
bufferPos += sizeof(UDATA);
88
}
89
90
91