Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/compiler/codegen/J9AheadOfTimeCompile.cpp
6000 views
1
/*******************************************************************************
2
* Copyright (c) 2000, 2022 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/CodeGenerator.hpp"
24
#include "codegen/Instruction.hpp"
25
#include "env/SharedCache.hpp"
26
#include "env/jittypes.h"
27
#include "env/ClassLoaderTable.hpp"
28
#include "exceptions/PersistenceFailure.hpp"
29
#include "il/DataTypes.hpp"
30
#include "il/Node.hpp"
31
#include "il/Node_inlines.hpp"
32
#include "il/SymbolReference.hpp"
33
#include "il/StaticSymbol.hpp"
34
#include "env/VMJ9.h"
35
#include "codegen/AheadOfTimeCompile.hpp"
36
#include "runtime/RelocationRuntime.hpp"
37
#include "runtime/RelocationRecord.hpp"
38
#include "runtime/SymbolValidationManager.hpp"
39
#if defined(J9VM_OPT_JITSERVER)
40
#include "runtime/JITClientSession.hpp"
41
#endif /* defined(J9VM_OPT_JITSERVER) */
42
43
44
extern bool isOrderedPair(uint8_t reloType);
45
46
uintptr_t
47
J9::AheadOfTimeCompile::getClassChainOffset(TR_OpaqueClassBlock *classToRemember,
48
const AOTCacheClassChainRecord *&classChainRecord)
49
{
50
TR_J9VMBase *fej9 = (TR_J9VMBase *)self()->comp()->fe();
51
TR_SharedCache *sharedCache = fej9->sharedCache();
52
void *classChain = sharedCache->rememberClass(classToRemember, &classChainRecord);
53
if (!classChain)
54
self()->comp()->failCompilation<J9::ClassChainPersistenceFailure>("classChain == NULL");
55
return self()->offsetInSharedCacheFromPointer(sharedCache, classChain);
56
}
57
58
#if defined(J9VM_OPT_JITSERVER)
59
60
void
61
J9::AheadOfTimeCompile::addClassSerializationRecord(const AOTCacheClassChainRecord *classChainRecord,
62
const uintptr_t *romClassOffsetAddr)
63
{
64
const AOTCacheClassRecord *record = classChainRecord ? classChainRecord->rootClassRecord() : NULL;
65
self()->addSerializationRecord(record, romClassOffsetAddr);
66
}
67
68
void
69
J9::AheadOfTimeCompile::addClassSerializationRecord(TR_OpaqueClassBlock *ramClass, const uintptr_t *romClassOffsetAddr)
70
{
71
TR::Compilation *comp = self()->comp();
72
if (comp->isAOTCacheStore())
73
{
74
const AOTCacheClassRecord *record = comp->getClientData()->getClassRecord((J9Class *)ramClass, comp->getStream());
75
self()->addSerializationRecord(record, romClassOffsetAddr);
76
}
77
}
78
79
void
80
J9::AheadOfTimeCompile::addMethodSerializationRecord(J9Method *method, TR_OpaqueClassBlock *definingClass,
81
const uintptr_t *romMethodOffsetAddr)
82
{
83
TR::Compilation *comp = self()->comp();
84
if (comp->isAOTCacheStore())
85
{
86
const AOTCacheMethodRecord *record = comp->getClientData()->getMethodRecord(method, (J9Class *)definingClass,
87
comp->getStream());
88
self()->addSerializationRecord(record, romMethodOffsetAddr);
89
}
90
}
91
92
void
93
J9::AheadOfTimeCompile::addClassChainSerializationRecord(const AOTCacheClassChainRecord *classChainRecord,
94
const uintptr_t *classChainOffsetAddr)
95
{
96
self()->addSerializationRecord(classChainRecord, classChainOffsetAddr);
97
}
98
99
void
100
J9::AheadOfTimeCompile::addClassLoaderSerializationRecord(const AOTCacheClassChainRecord *classChainRecord,
101
const uintptr_t *loaderChainOffsetAddr)
102
{
103
const AOTCacheClassLoaderRecord *record = classChainRecord ? classChainRecord->rootClassLoaderRecord() : NULL;
104
self()->addSerializationRecord(record, loaderChainOffsetAddr);
105
}
106
107
void
108
J9::AheadOfTimeCompile::addWellKnownClassesSerializationRecord(const AOTCacheWellKnownClassesRecord *wkcRecord,
109
const uintptr_t *wkcOffsetAddr)
110
{
111
self()->addSerializationRecord(wkcRecord, wkcOffsetAddr);
112
}
113
114
void
115
J9::AheadOfTimeCompile::addSerializationRecord(const AOTCacheRecord *record, const uintptr_t *sccOffsetAddr)
116
{
117
TR::Compilation *comp = self()->comp();
118
if (comp->isAOTCacheStore())
119
{
120
uint8_t *start = self()->getRelocationData();
121
uint8_t *end = start + *(uintptr_t *)start;// Total size of relocation data is stored in the first word
122
TR_ASSERT_FATAL(((uint8_t *)sccOffsetAddr >= start + sizeof(uintptr_t)) && ((uint8_t *)sccOffsetAddr < end),
123
"SCC offset address %p not in range %p - %p", sccOffsetAddr, start + sizeof(uintptr_t), end);
124
comp->addSerializationRecord(record, (uint8_t *)sccOffsetAddr - start);
125
}
126
}
127
128
#endif /* defined(J9VM_OPT_JITSERVER) */
129
130
uintptr_t
131
J9::AheadOfTimeCompile::offsetInSharedCacheFromPointer(TR_SharedCache *sharedCache, void *ptr)
132
{
133
uintptr_t offset = 0;
134
if (sharedCache->isPointerInSharedCache(ptr, &offset))
135
return offset;
136
else
137
self()->comp()->failCompilation<J9::ClassChainPersistenceFailure>("Failed to find pointer %p in SCC", ptr);
138
139
return offset;
140
}
141
142
uintptr_t
143
J9::AheadOfTimeCompile::offsetInSharedCacheFromROMClass(TR_SharedCache *sharedCache, J9ROMClass *romClass)
144
{
145
uintptr_t offset = 0;
146
if (sharedCache->isROMClassInSharedCache(romClass, &offset))
147
return offset;
148
else
149
self()->comp()->failCompilation<J9::ClassChainPersistenceFailure>("Failed to find romClass %p in SCC", romClass);
150
151
return offset;
152
}
153
154
uintptr_t
155
J9::AheadOfTimeCompile::offsetInSharedCacheFromROMMethod(TR_SharedCache *sharedCache, J9ROMMethod *romMethod)
156
{
157
uintptr_t offset = 0;
158
if (sharedCache->isROMMethodInSharedCache(romMethod, &offset))
159
return offset;
160
else
161
self()->comp()->failCompilation<J9::ClassChainPersistenceFailure>("Failed to find romMethod %p in SCC", romMethod);
162
163
return offset;
164
}
165
166
uintptr_t
167
J9::AheadOfTimeCompile::findCorrectInlinedSiteIndex(void *constantPool, uintptr_t currentInlinedSiteIndex)
168
{
169
TR::Compilation *comp = self()->comp();
170
uintptr_t constantPoolForSiteIndex = 0;
171
uintptr_t inlinedSiteIndex = currentInlinedSiteIndex;
172
173
if (inlinedSiteIndex == (uintptr_t)-1)
174
{
175
constantPoolForSiteIndex = (uintptr_t)comp->getCurrentMethod()->constantPool();
176
}
177
else
178
{
179
constantPoolForSiteIndex = (uintptr_t)comp->getInlinedResolvedMethod(inlinedSiteIndex)->constantPool();
180
}
181
182
bool matchFound = false;
183
184
if ((uintptr_t)constantPool == constantPoolForSiteIndex)
185
{
186
// The constant pool and site index match, no need to find anything.
187
matchFound = true;
188
}
189
else
190
{
191
if ((uintptr_t)constantPool == (uintptr_t)comp->getCurrentMethod()->constantPool())
192
{
193
// The constant pool belongs to the current method being compiled, the correct site index is -1.
194
matchFound = true;
195
inlinedSiteIndex = (uintptr_t)-1;
196
}
197
else
198
{
199
// Look for the first call site whose inlined method's constant pool matches ours and return that site index as the correct one.
200
for (uintptr_t i = 0; i < comp->getNumInlinedCallSites(); i++)
201
{
202
if ((uintptr_t)constantPool == (uintptr_t)comp->getInlinedResolvedMethod(i)->constantPool())
203
{
204
matchFound = true;
205
inlinedSiteIndex = i;
206
break;
207
}
208
}
209
}
210
}
211
212
if (!matchFound)
213
self()->comp()->failCompilation<J9::AOTRelocationRecordGenerationFailure>("AOT header initialization can't find CP in inlined site list");
214
return inlinedSiteIndex;
215
}
216
217
static const char* getNameForMethodRelocation (int type)
218
{
219
switch ( type )
220
{
221
case TR_JNISpecialTargetAddress:
222
return "TR_JNISpecialTargetAddress";
223
case TR_JNIVirtualTargetAddress:
224
return "TR_JNIVirtualTargetAddress";
225
case TR_JNIStaticTargetAddress:
226
return "TR_JNIStaticTargetAddress";
227
case TR_StaticRamMethodConst:
228
return "TR_StaticRamMethodConst";
229
case TR_SpecialRamMethodConst:
230
return "TR_SpecialRamMethodConst";
231
case TR_VirtualRamMethodConst:
232
return "TR_VirtualRamMethodConst";
233
default:
234
TR_ASSERT(0, "We already cleared one switch, hard to imagine why we would have a different type here");
235
break;
236
}
237
238
return NULL;
239
}
240
241
uint8_t *
242
J9::AheadOfTimeCompile::initializeAOTRelocationHeader(TR::IteratedExternalRelocation *relocation)
243
{
244
TR::Compilation *comp = self()->comp();
245
TR_RelocationRuntime *reloRuntime = comp->reloRuntime();
246
TR_RelocationTarget *reloTarget = reloRuntime->reloTarget();
247
248
uint8_t *cursor = relocation->getRelocationData();
249
uint8_t targetKind = relocation->getTargetKind();
250
uint16_t sizeOfReloData = relocation->getSizeOfRelocationData();
251
uint8_t wideOffsets = relocation->needsWideOffsets() ? RELOCATION_TYPE_WIDE_OFFSET : 0;
252
253
// Zero-initialize header
254
memset(cursor, 0, sizeOfReloData);
255
256
TR_RelocationRecord storage;
257
TR_RelocationRecord *reloRecord = TR_RelocationRecord::create(&storage, reloRuntime, targetKind, reinterpret_cast<TR_RelocationRecordBinaryTemplate *>(cursor));
258
259
reloRecord->setSize(reloTarget, sizeOfReloData);
260
reloRecord->setType(reloTarget, static_cast<TR_RelocationRecordType>(targetKind));
261
reloRecord->setFlag(reloTarget, wideOffsets);
262
263
if (!self()->initializePlatformSpecificAOTRelocationHeader(relocation, reloTarget, reloRecord, targetKind))
264
self()->initializeCommonAOTRelocationHeader(relocation, reloTarget, reloRecord, targetKind);
265
266
cursor += self()->getSizeOfAOTRelocationHeader(static_cast<TR_RelocationRecordType>(targetKind));
267
return cursor;
268
}
269
270
void
271
J9::AheadOfTimeCompile::initializeCommonAOTRelocationHeader(TR::IteratedExternalRelocation *relocation,
272
TR_RelocationTarget *reloTarget,
273
TR_RelocationRecord *reloRecord,
274
uint8_t kind)
275
{
276
TR::Compilation *comp = self()->comp();
277
TR::SymbolValidationManager *symValManager = comp->getSymbolValidationManager();
278
TR_J9VMBase *fej9 = comp->fej9();
279
TR_SharedCache *sharedCache = fej9->sharedCache();
280
uint8_t * aotMethodCodeStart = reinterpret_cast<uint8_t *>(comp->getRelocatableMethodCodeStart());
281
282
switch (kind)
283
{
284
case TR_ConstantPool:
285
case TR_Thunks:
286
case TR_Trampolines:
287
{
288
TR_RelocationRecordConstantPool * cpRecord = reinterpret_cast<TR_RelocationRecordConstantPool *>(reloRecord);
289
290
cpRecord->setConstantPool(reloTarget, reinterpret_cast<uintptr_t>(relocation->getTargetAddress()));
291
cpRecord->setInlinedSiteIndex(reloTarget, reinterpret_cast<uintptr_t>(relocation->getTargetAddress2()));
292
}
293
break;
294
295
case TR_HelperAddress:
296
{
297
TR_RelocationRecordHelperAddress *haRecord = reinterpret_cast<TR_RelocationRecordHelperAddress *>(reloRecord);
298
TR::SymbolReference *symRef = reinterpret_cast<TR::SymbolReference *>(relocation->getTargetAddress());
299
300
haRecord->setEipRelative(reloTarget);
301
haRecord->setHelperID(reloTarget, static_cast<uint32_t>(symRef->getReferenceNumber()));
302
}
303
break;
304
305
case TR_RelativeMethodAddress:
306
{
307
TR_RelocationRecordMethodAddress *rmaRecord = reinterpret_cast<TR_RelocationRecordMethodAddress *>(reloRecord);
308
309
rmaRecord->setEipRelative(reloTarget);
310
}
311
break;
312
313
case TR_AbsoluteMethodAddress:
314
case TR_BodyInfoAddress:
315
case TR_RamMethod:
316
case TR_ClassUnloadAssumption:
317
case TR_AbsoluteMethodAddressOrderedPair:
318
case TR_ArrayCopyHelper:
319
case TR_ArrayCopyToc:
320
case TR_BodyInfoAddressLoad:
321
case TR_RecompQueuedFlag:
322
{
323
// Nothing to do
324
}
325
break;
326
327
case TR_MethodCallAddress:
328
{
329
TR_RelocationRecordMethodCallAddress *mcaRecord = reinterpret_cast<TR_RelocationRecordMethodCallAddress *>(reloRecord);
330
331
mcaRecord->setEipRelative(reloTarget);
332
mcaRecord->setAddress(reloTarget, relocation->getTargetAddress());
333
}
334
break;
335
336
case TR_AbsoluteHelperAddress:
337
{
338
TR_RelocationRecordAbsoluteHelperAddress *ahaRecord = reinterpret_cast<TR_RelocationRecordAbsoluteHelperAddress *>(reloRecord);
339
TR::SymbolReference *symRef = reinterpret_cast<TR::SymbolReference *>(relocation->getTargetAddress());
340
341
ahaRecord->setHelperID(reloTarget, static_cast<uint32_t>(symRef->getReferenceNumber()));
342
}
343
break;
344
345
case TR_JNIVirtualTargetAddress:
346
case TR_JNIStaticTargetAddress:
347
case TR_JNISpecialTargetAddress:
348
{
349
TR_RelocationRecordDirectJNICall *djnicRecord = reinterpret_cast<TR_RelocationRecordDirectJNICall *>(reloRecord);
350
TR_RelocationRecordInformation *recordInfo = reinterpret_cast<TR_RelocationRecordInformation*>(relocation->getTargetAddress());
351
352
uintptr_t offsetToReloLocation = recordInfo->data1;
353
TR_ASSERT_FATAL((offsetToReloLocation & ~0xFF) == 0,
354
"offsetToReloLocation %" OMR_PRIuPTR " cannot fit in a uint8_t",
355
offsetToReloLocation);
356
357
TR::SymbolReference *symRef = reinterpret_cast<TR::SymbolReference *>(recordInfo->data2);
358
uintptr_t inlinedSiteIndex = recordInfo->data3;
359
360
void *constantPool = symRef->getOwningMethod(comp)->constantPool();
361
inlinedSiteIndex = self()->findCorrectInlinedSiteIndex(constantPool, inlinedSiteIndex);
362
363
djnicRecord->setInlinedSiteIndex(reloTarget, inlinedSiteIndex);
364
djnicRecord->setConstantPool(reloTarget, reinterpret_cast<uintptr_t>(constantPool));
365
djnicRecord->setCpIndex(reloTarget, symRef->getCPIndex());
366
djnicRecord->setOffsetToReloLocation(reloTarget, static_cast<uint8_t>(offsetToReloLocation));
367
}
368
break;
369
370
case TR_StaticRamMethodConst:
371
case TR_SpecialRamMethodConst:
372
case TR_VirtualRamMethodConst:
373
case TR_ClassAddress:
374
{
375
TR_RelocationRecordConstantPoolWithIndex *cpiRecord = reinterpret_cast<TR_RelocationRecordConstantPoolWithIndex *>(reloRecord);
376
TR::SymbolReference *symRef = reinterpret_cast<TR::SymbolReference *>(relocation->getTargetAddress());
377
uintptr_t inlinedSiteIndex = reinterpret_cast<uintptr_t>(relocation->getTargetAddress2());
378
379
void *constantPool = symRef->getOwningMethod(comp)->constantPool();
380
inlinedSiteIndex = self()->findCorrectInlinedSiteIndex(constantPool, inlinedSiteIndex);
381
382
cpiRecord->setInlinedSiteIndex(reloTarget, inlinedSiteIndex);
383
cpiRecord->setConstantPool(reloTarget, reinterpret_cast<uintptr_t>(constantPool));
384
cpiRecord->setCpIndex(reloTarget, symRef->getCPIndex());
385
}
386
break;
387
388
case TR_CheckMethodEnter:
389
case TR_CheckMethodExit:
390
{
391
TR_RelocationRecordMethodTracingCheck *mtRecord = reinterpret_cast<TR_RelocationRecordMethodTracingCheck *>(reloRecord);
392
393
mtRecord->setDestinationAddress(reloTarget, reinterpret_cast<uintptr_t>(relocation->getTargetAddress()));
394
}
395
break;
396
397
case TR_VerifyClassObjectForAlloc:
398
{
399
TR_RelocationRecordVerifyClassObjectForAlloc *allocRecord = reinterpret_cast<TR_RelocationRecordVerifyClassObjectForAlloc *>(reloRecord);
400
401
TR::SymbolReference * classSymRef = reinterpret_cast<TR::SymbolReference *>(relocation->getTargetAddress());
402
TR_RelocationRecordInformation *recordInfo = reinterpret_cast<TR_RelocationRecordInformation*>(relocation->getTargetAddress2());
403
TR::LabelSymbol *label = reinterpret_cast<TR::LabelSymbol *>(recordInfo->data3);
404
TR::Instruction *instr = reinterpret_cast<TR::Instruction *>(recordInfo->data4);
405
406
uint32_t branchOffset = static_cast<uint32_t>(label->getCodeLocation() - instr->getBinaryEncoding());
407
408
allocRecord->setInlinedSiteIndex(reloTarget, static_cast<uintptr_t>(recordInfo->data2));
409
allocRecord->setConstantPool(reloTarget, reinterpret_cast<uintptr_t>(classSymRef->getOwningMethod(comp)->constantPool()));
410
allocRecord->setBranchOffset(reloTarget, static_cast<uintptr_t>(branchOffset));
411
allocRecord->setAllocationSize(reloTarget, static_cast<uintptr_t>(recordInfo->data1));
412
413
/* Temporary, will be cleaned up in a future PR */
414
if (comp->getOption(TR_UseSymbolValidationManager))
415
{
416
TR_OpaqueClassBlock *classOfMethod = reinterpret_cast<TR_OpaqueClassBlock *>(recordInfo->data5);
417
uint16_t classID = symValManager->getSymbolIDFromValue(static_cast<void *>(classOfMethod));
418
allocRecord->setCpIndex(reloTarget, static_cast<uintptr_t>(classID));
419
}
420
else
421
{
422
allocRecord->setCpIndex(reloTarget, static_cast<uintptr_t>(classSymRef->getCPIndex()));
423
}
424
}
425
break;
426
427
case TR_VerifyRefArrayForAlloc:
428
{
429
TR_RelocationRecordVerifyRefArrayForAlloc *allocRecord = reinterpret_cast<TR_RelocationRecordVerifyRefArrayForAlloc *>(reloRecord);
430
431
TR::SymbolReference * classSymRef = reinterpret_cast<TR::SymbolReference *>(relocation->getTargetAddress());
432
TR_RelocationRecordInformation *recordInfo = reinterpret_cast<TR_RelocationRecordInformation*>(relocation->getTargetAddress2());
433
TR::LabelSymbol *label = reinterpret_cast<TR::LabelSymbol *>(recordInfo->data3);
434
TR::Instruction *instr = reinterpret_cast<TR::Instruction *>(recordInfo->data4);
435
436
uint32_t branchOffset = static_cast<uint32_t>(label->getCodeLocation() - instr->getBinaryEncoding());
437
438
allocRecord->setInlinedSiteIndex(reloTarget, static_cast<uintptr_t>(recordInfo->data2));
439
allocRecord->setConstantPool(reloTarget, reinterpret_cast<uintptr_t>(classSymRef->getOwningMethod(comp)->constantPool()));
440
allocRecord->setBranchOffset(reloTarget, static_cast<uintptr_t>(branchOffset));
441
442
/* Temporary, will be cleaned up in a future PR */
443
if (comp->getOption(TR_UseSymbolValidationManager))
444
{
445
TR_OpaqueClassBlock *classOfMethod = reinterpret_cast<TR_OpaqueClassBlock *>(recordInfo->data5);
446
uint16_t classID = symValManager->getSymbolIDFromValue(static_cast<void *>(classOfMethod));
447
allocRecord->setCpIndex(reloTarget, static_cast<uintptr_t>(classID));
448
}
449
else
450
{
451
allocRecord->setCpIndex(reloTarget, static_cast<uintptr_t>(classSymRef->getCPIndex()));
452
}
453
}
454
break;
455
456
case TR_ValidateInstanceField:
457
{
458
TR_RelocationRecordValidateInstanceField *fieldRecord = reinterpret_cast<TR_RelocationRecordValidateInstanceField *>(reloRecord);
459
uintptr_t inlinedSiteIndex = reinterpret_cast<uintptr_t>(relocation->getTargetAddress());
460
TR::AOTClassInfo *aotCI = reinterpret_cast<TR::AOTClassInfo *>(relocation->getTargetAddress2());
461
uintptr_t classChainOffsetInSharedCache = self()->offsetInSharedCacheFromPointer(sharedCache, aotCI->_classChain);
462
463
fieldRecord->setInlinedSiteIndex(reloTarget, inlinedSiteIndex);
464
fieldRecord->setConstantPool(reloTarget, reinterpret_cast<uintptr_t>(aotCI->_constantPool));
465
fieldRecord->setCpIndex(reloTarget, static_cast<uintptr_t>(aotCI->_cpIndex));
466
fieldRecord->setClassChainOffsetInSharedCache(reloTarget, classChainOffsetInSharedCache,
467
self(), aotCI->getAOTCacheClassChainRecord());
468
}
469
break;
470
471
case TR_InlinedStaticMethodWithNopGuard:
472
case TR_InlinedSpecialMethodWithNopGuard:
473
case TR_InlinedVirtualMethodWithNopGuard:
474
case TR_InlinedInterfaceMethodWithNopGuard:
475
case TR_InlinedAbstractMethodWithNopGuard:
476
case TR_InlinedInterfaceMethod:
477
case TR_InlinedVirtualMethod:
478
case TR_InlinedStaticMethod:
479
case TR_InlinedSpecialMethod:
480
case TR_InlinedAbstractMethod:
481
{
482
TR_RelocationRecordInlinedMethod *imRecord = reinterpret_cast<TR_RelocationRecordInlinedMethod *>(reloRecord);
483
484
TR_RelocationRecordInformation *info = reinterpret_cast<TR_RelocationRecordInformation *>(relocation->getTargetAddress());
485
486
int32_t inlinedSiteIndex = static_cast<int32_t>(info->data1);
487
TR::SymbolReference *callSymRef = reinterpret_cast<TR::SymbolReference *>(info->data2);
488
TR_OpaqueClassBlock *thisClass = reinterpret_cast<TR_OpaqueClassBlock *>(info->data3);
489
uintptr_t destinationAddress = info->data4;
490
491
uint8_t flags = 0;
492
// Setup flags field with type of method that needs to be validated at relocation time
493
if (callSymRef->getSymbol()->getMethodSymbol()->isStatic())
494
flags = inlinedMethodIsStatic;
495
else if (callSymRef->getSymbol()->getMethodSymbol()->isSpecial())
496
flags = inlinedMethodIsSpecial;
497
else if (callSymRef->getSymbol()->getMethodSymbol()->isVirtual())
498
flags = inlinedMethodIsVirtual;
499
TR_ASSERT((flags & RELOCATION_CROSS_PLATFORM_FLAGS_MASK) == 0, "reloFlags bits overlap cross-platform flags bits\n");
500
501
TR_ResolvedMethod *resolvedMethod;
502
if (kind == TR_InlinedInterfaceMethodWithNopGuard ||
503
kind == TR_InlinedInterfaceMethod ||
504
kind == TR_InlinedAbstractMethodWithNopGuard ||
505
kind == TR_InlinedAbstractMethod)
506
{
507
resolvedMethod = comp->getInlinedResolvedMethod(inlinedSiteIndex);
508
}
509
else
510
{
511
resolvedMethod = callSymRef->getSymbol()->getResolvedMethodSymbol()->getResolvedMethod();
512
}
513
514
// Ugly; this will be cleaned up in a future PR
515
uintptr_t cpIndexOrData = 0;
516
if (comp->getOption(TR_UseSymbolValidationManager))
517
{
518
TR_OpaqueMethodBlock *method = resolvedMethod->getPersistentIdentifier();
519
uint16_t methodID = symValManager->getSymbolIDFromValue(static_cast<void *>(method));
520
uint16_t receiverClassID = symValManager->getSymbolIDFromValue(static_cast<void *>(thisClass));
521
522
cpIndexOrData = (((uintptr_t)receiverClassID << 16) | (uintptr_t)methodID);
523
}
524
else
525
{
526
cpIndexOrData = static_cast<uintptr_t>(callSymRef->getCPIndex());
527
}
528
529
TR_OpaqueClassBlock *inlinedMethodClass = resolvedMethod->containingClass();
530
J9ROMClass *romClass = reinterpret_cast<J9ROMClass *>(fej9->getPersistentClassPointerFromClassPointer(inlinedMethodClass));
531
uintptr_t romClassOffsetInSharedCache = self()->offsetInSharedCacheFromROMClass(sharedCache, romClass);
532
533
imRecord->setReloFlags(reloTarget, flags);
534
imRecord->setInlinedSiteIndex(reloTarget, inlinedSiteIndex);
535
imRecord->setConstantPool(reloTarget, reinterpret_cast<uintptr_t>(callSymRef->getOwningMethod(comp)->constantPool()));
536
imRecord->setCpIndex(reloTarget, cpIndexOrData);
537
imRecord->setRomClassOffsetInSharedCache(reloTarget, romClassOffsetInSharedCache, self(), inlinedMethodClass);
538
539
if (kind != TR_InlinedInterfaceMethod
540
&& kind != TR_InlinedVirtualMethod
541
&& kind != TR_InlinedSpecialMethod
542
&& kind != TR_InlinedStaticMethod
543
&& kind != TR_InlinedAbstractMethod)
544
{
545
reinterpret_cast<TR_RelocationRecordNopGuard *>(imRecord)->setDestinationAddress(reloTarget, destinationAddress);
546
}
547
}
548
break;
549
550
case TR_ValidateStaticField:
551
{
552
TR_RelocationRecordValidateStaticField *vsfRecord = reinterpret_cast<TR_RelocationRecordValidateStaticField *>(reloRecord);
553
554
uintptr_t inlinedSiteIndex = reinterpret_cast<uintptr_t>(relocation->getTargetAddress());
555
TR::AOTClassInfo *aotCI = reinterpret_cast<TR::AOTClassInfo *>(relocation->getTargetAddress2());
556
557
J9ROMClass *romClass = reinterpret_cast<J9ROMClass *>(fej9->getPersistentClassPointerFromClassPointer(aotCI->_clazz));
558
uintptr_t romClassOffsetInSharedCache = self()->offsetInSharedCacheFromROMClass(sharedCache, romClass);
559
560
vsfRecord->setInlinedSiteIndex(reloTarget, inlinedSiteIndex);
561
vsfRecord->setConstantPool(reloTarget, reinterpret_cast<uintptr_t>(aotCI->_constantPool));
562
vsfRecord->setCpIndex(reloTarget, aotCI->_cpIndex);
563
vsfRecord->setRomClassOffsetInSharedCache(reloTarget, romClassOffsetInSharedCache,
564
self(), aotCI->getAOTCacheClassChainRecord());
565
}
566
break;
567
568
case TR_ValidateClass:
569
{
570
TR_RelocationRecordValidateClass *vcRecord = reinterpret_cast<TR_RelocationRecordValidateClass *>(reloRecord);
571
572
uintptr_t inlinedSiteIndex = reinterpret_cast<uintptr_t>(relocation->getTargetAddress());
573
TR::AOTClassInfo *aotCI = reinterpret_cast<TR::AOTClassInfo *>(relocation->getTargetAddress2());
574
575
uintptr_t classChainOffsetInSharedCache = self()->offsetInSharedCacheFromPointer(sharedCache, aotCI->_classChain);
576
577
vcRecord->setInlinedSiteIndex(reloTarget, inlinedSiteIndex);
578
vcRecord->setConstantPool(reloTarget, reinterpret_cast<uintptr_t>(aotCI->_constantPool));
579
vcRecord->setCpIndex(reloTarget, aotCI->_cpIndex);
580
vcRecord->setClassChainOffsetInSharedCache(reloTarget, classChainOffsetInSharedCache,
581
self(), aotCI->getAOTCacheClassChainRecord());
582
}
583
break;
584
585
case TR_ProfiledMethodGuardRelocation:
586
case TR_ProfiledClassGuardRelocation:
587
case TR_ProfiledInlinedMethodRelocation:
588
{
589
TR_RelocationRecordProfiledInlinedMethod *pRecord = reinterpret_cast<TR_RelocationRecordProfiledInlinedMethod *>(reloRecord);
590
591
TR_RelocationRecordInformation *info = reinterpret_cast<TR_RelocationRecordInformation *>(relocation->getTargetAddress());
592
593
int32_t inlinedSiteIndex = static_cast<int32_t>(info->data1);
594
TR::SymbolReference *callSymRef = reinterpret_cast<TR::SymbolReference *>(info->data2);
595
596
TR_ResolvedMethod *owningMethod = callSymRef->getOwningMethod(comp);
597
598
TR_ResolvedMethod *inlinedMethod = comp->getInlinedResolvedMethod(inlinedSiteIndex);
599
TR_OpaqueClassBlock *inlinedCodeClass = reinterpret_cast<TR_OpaqueClassBlock *>(inlinedMethod->classOfMethod());
600
601
J9ROMClass *romClass = reinterpret_cast<J9ROMClass *>(fej9->getPersistentClassPointerFromClassPointer(inlinedCodeClass));
602
uintptr_t romClassOffsetInSharedCache = self()->offsetInSharedCacheFromROMClass(sharedCache, romClass);
603
traceMsg(comp, "class is %p, romclass is %p, offset is %llu\n", inlinedCodeClass, romClass, romClassOffsetInSharedCache);
604
605
uintptr_t classChainIdentifyingLoaderOffsetInSharedCache = sharedCache->getClassChainOffsetIdentifyingLoader(inlinedCodeClass);
606
607
const AOTCacheClassChainRecord *classChainRecord = NULL;
608
uintptr_t classChainOffsetInSharedCache = self()->getClassChainOffset(inlinedCodeClass, classChainRecord);
609
610
uintptr_t methodIndex = fej9->getMethodIndexInClass(inlinedCodeClass, inlinedMethod->getNonPersistentIdentifier());
611
612
// Ugly; this will be cleaned up in a future PR
613
uintptr_t cpIndexOrData = 0;
614
if (comp->getOption(TR_UseSymbolValidationManager))
615
{
616
uint16_t inlinedCodeClassID = symValManager->getSymbolIDFromValue(static_cast<void *>(inlinedCodeClass));
617
cpIndexOrData = static_cast<uintptr_t>(inlinedCodeClassID);
618
}
619
else
620
{
621
cpIndexOrData = static_cast<uintptr_t>(callSymRef->getCPIndex());
622
}
623
624
pRecord->setInlinedSiteIndex(reloTarget, inlinedSiteIndex);
625
pRecord->setConstantPool(reloTarget, reinterpret_cast<uintptr_t>(owningMethod->constantPool()));
626
pRecord->setCpIndex(reloTarget, cpIndexOrData);
627
pRecord->setRomClassOffsetInSharedCache(reloTarget, romClassOffsetInSharedCache, self(), classChainRecord);
628
pRecord->setClassChainIdentifyingLoaderOffsetInSharedCache(reloTarget, classChainIdentifyingLoaderOffsetInSharedCache,
629
self(), classChainRecord);
630
pRecord->setClassChainForInlinedMethod(reloTarget, classChainOffsetInSharedCache, self(), classChainRecord);
631
pRecord->setMethodIndex(reloTarget, methodIndex);
632
}
633
break;
634
635
case TR_MethodPointer:
636
{
637
TR_RelocationRecordMethodPointer *mpRecord = reinterpret_cast<TR_RelocationRecordMethodPointer *>(reloRecord);
638
639
TR::Node *aconstNode = reinterpret_cast<TR::Node *>(relocation->getTargetAddress());
640
uintptr_t inlinedSiteIndex = static_cast<uintptr_t>(aconstNode->getInlinedSiteIndex());
641
642
TR_OpaqueMethodBlock *j9method = reinterpret_cast<TR_OpaqueMethodBlock *>(aconstNode->getAddress());
643
if (aconstNode->getOpCodeValue() == TR::loadaddr)
644
j9method = reinterpret_cast<TR_OpaqueMethodBlock *>(aconstNode->getSymbolReference()->getSymbol()->castToStaticSymbol()->getStaticAddress());
645
646
TR_OpaqueClassBlock *j9class = fej9->getClassFromMethodBlock(j9method);
647
648
uintptr_t classChainOffsetOfCLInSharedCache = sharedCache->getClassChainOffsetIdentifyingLoader(j9class);
649
const AOTCacheClassChainRecord *classChainRecord = NULL;
650
uintptr_t classChainForInlinedMethodOffsetInSharedCache = self()->getClassChainOffset(j9class, classChainRecord);
651
652
uintptr_t vTableOffset = static_cast<uintptr_t>(fej9->getInterpreterVTableSlot(j9method, j9class));
653
654
mpRecord->setInlinedSiteIndex(reloTarget, inlinedSiteIndex);
655
mpRecord->setClassChainForInlinedMethod(reloTarget, classChainForInlinedMethodOffsetInSharedCache,
656
self(), classChainRecord);
657
mpRecord->setClassChainIdentifyingLoaderOffsetInSharedCache(reloTarget, classChainOffsetOfCLInSharedCache,
658
self(), classChainRecord);
659
mpRecord->setVTableSlot(reloTarget, vTableOffset);
660
}
661
break;
662
663
case TR_InlinedMethodPointer:
664
{
665
TR_RelocationRecordInlinedMethodPointer *impRecord = reinterpret_cast<TR_RelocationRecordInlinedMethodPointer *>(reloRecord);
666
667
impRecord->setInlinedSiteIndex(reloTarget, reinterpret_cast<uintptr_t>(relocation->getTargetAddress()));
668
}
669
break;
670
671
case TR_ClassPointer:
672
{
673
TR_RelocationRecordClassPointer *cpRecord = reinterpret_cast<TR_RelocationRecordClassPointer *>(reloRecord);
674
675
TR::Node *aconstNode = reinterpret_cast<TR::Node *>(relocation->getTargetAddress());
676
uintptr_t inlinedSiteIndex = static_cast<uintptr_t>(aconstNode->getInlinedSiteIndex());
677
678
TR_OpaqueClassBlock *j9class = NULL;
679
if (relocation->getTargetAddress2())
680
{
681
j9class = reinterpret_cast<TR_OpaqueClassBlock *>(relocation->getTargetAddress2());
682
}
683
else
684
{
685
if (aconstNode->getOpCodeValue() == TR::loadaddr)
686
j9class = reinterpret_cast<TR_OpaqueClassBlock *>(aconstNode->getSymbolReference()->getSymbol()->castToStaticSymbol()->getStaticAddress());
687
else
688
j9class = reinterpret_cast<TR_OpaqueClassBlock *>(aconstNode->getAddress());
689
}
690
691
uintptr_t classChainOffsetOfCLInSharedCache = sharedCache->getClassChainOffsetIdentifyingLoader(j9class);
692
const AOTCacheClassChainRecord *classChainRecord = NULL;
693
uintptr_t classChainForInlinedMethodOffsetInSharedCache = self()->getClassChainOffset(j9class, classChainRecord);
694
695
cpRecord->setInlinedSiteIndex(reloTarget, inlinedSiteIndex);
696
cpRecord->setClassChainForInlinedMethod(reloTarget, classChainForInlinedMethodOffsetInSharedCache,
697
self(), classChainRecord);
698
cpRecord->setClassChainIdentifyingLoaderOffsetInSharedCache(reloTarget, classChainOffsetOfCLInSharedCache,
699
self(), classChainRecord);
700
}
701
break;
702
703
case TR_ValidateArbitraryClass:
704
{
705
TR_RelocationRecordValidateArbitraryClass *vacRecord = reinterpret_cast<TR_RelocationRecordValidateArbitraryClass *>(reloRecord);
706
707
TR::AOTClassInfo *aotCI = reinterpret_cast<TR::AOTClassInfo *>(relocation->getTargetAddress2());
708
TR_OpaqueClassBlock *classToValidate = aotCI->_clazz;
709
710
uintptr_t classChainOffsetInSharedCacheForCL = sharedCache->getClassChainOffsetIdentifyingLoader(classToValidate);
711
712
void *classChainForClassToValidate = aotCI->_classChain;
713
uintptr_t classChainOffsetInSharedCache = self()->offsetInSharedCacheFromPointer(sharedCache, classChainForClassToValidate);
714
715
vacRecord->setClassChainIdentifyingLoaderOffset(reloTarget, classChainOffsetInSharedCacheForCL,
716
self(), aotCI->getAOTCacheClassChainRecord());
717
vacRecord->setClassChainOffsetForClassBeingValidated(reloTarget, classChainOffsetInSharedCache,
718
self(), aotCI->getAOTCacheClassChainRecord());
719
}
720
break;
721
722
case TR_J2IVirtualThunkPointer:
723
{
724
TR_RelocationRecordJ2IVirtualThunkPointer *vtpRecord = reinterpret_cast<TR_RelocationRecordJ2IVirtualThunkPointer *>(reloRecord);
725
726
TR_RelocationRecordInformation *info = reinterpret_cast<TR_RelocationRecordInformation*>(relocation->getTargetAddress());
727
728
vtpRecord->setConstantPool(reloTarget, info->data1);
729
vtpRecord->setInlinedSiteIndex(reloTarget, info->data2);
730
vtpRecord->setOffsetToJ2IVirtualThunkPointer(reloTarget, info->data3);
731
}
732
break;
733
734
case TR_ValidateClassByName:
735
{
736
TR_RelocationRecordValidateClassByName *cbnRecord = reinterpret_cast<TR_RelocationRecordValidateClassByName *>(reloRecord);
737
738
TR::ClassByNameRecord *svmRecord = reinterpret_cast<TR::ClassByNameRecord *>(relocation->getTargetAddress());
739
740
uintptr_t classChainOffsetInSharedCache = self()->offsetInSharedCacheFromPointer(sharedCache, svmRecord->_classChain);
741
742
cbnRecord->setClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_class));
743
cbnRecord->setBeholderID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_beholder));
744
cbnRecord->setClassChainOffset(reloTarget, classChainOffsetInSharedCache,
745
self(), svmRecord->getAOTCacheClassChainRecord());
746
}
747
break;
748
749
case TR_ValidateProfiledClass:
750
{
751
TR_RelocationRecordValidateProfiledClass *pcRecord = reinterpret_cast<TR_RelocationRecordValidateProfiledClass *>(reloRecord);
752
753
TR::ProfiledClassRecord *svmRecord = reinterpret_cast<TR::ProfiledClassRecord *>(relocation->getTargetAddress());
754
755
TR_OpaqueClassBlock *classToValidate = svmRecord->_class;
756
void *classChainForClassToValidate = svmRecord->_classChain;
757
758
//store the classchain's offset for the classloader for the class
759
uintptr_t classChainOffsetInSharedCacheForCL = sharedCache->getClassChainOffsetIdentifyingLoader(classToValidate);
760
761
//store the classchain's offset for the class that needs to be validated in the second run
762
uintptr_t classChainOffsetInSharedCache = self()->offsetInSharedCacheFromPointer(sharedCache, classChainForClassToValidate);
763
764
pcRecord->setClassID(reloTarget, symValManager->getSymbolIDFromValue(classToValidate));
765
pcRecord->setClassChainOffset(reloTarget, classChainOffsetInSharedCache,
766
self(), svmRecord->getAOTCacheClassChainRecord());
767
pcRecord->setClassChainOffsetForClassLoader(reloTarget, classChainOffsetInSharedCacheForCL,
768
self(), svmRecord->getAOTCacheClassChainRecord());
769
}
770
break;
771
772
case TR_ValidateClassFromCP:
773
{
774
TR_RelocationRecordValidateClassFromCP *cpRecord = reinterpret_cast<TR_RelocationRecordValidateClassFromCP *>(reloRecord);
775
776
TR::ClassFromCPRecord *svmRecord = reinterpret_cast<TR::ClassFromCPRecord *>(relocation->getTargetAddress());
777
778
cpRecord->setClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_class));
779
cpRecord->setBeholderID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_beholder));
780
cpRecord->setCpIndex(reloTarget, svmRecord->_cpIndex);
781
}
782
break;
783
784
case TR_ValidateDefiningClassFromCP:
785
{
786
TR_RelocationRecordValidateDefiningClassFromCP *dcpRecord = reinterpret_cast<TR_RelocationRecordValidateDefiningClassFromCP *>(reloRecord);
787
788
TR::DefiningClassFromCPRecord *svmRecord = reinterpret_cast<TR::DefiningClassFromCPRecord *>(relocation->getTargetAddress());
789
790
dcpRecord->setIsStatic(reloTarget, svmRecord->_isStatic);
791
dcpRecord->setClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_class));
792
dcpRecord->setBeholderID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_beholder));
793
dcpRecord->setCpIndex(reloTarget, svmRecord->_cpIndex);
794
}
795
break;
796
797
case TR_ValidateStaticClassFromCP:
798
{
799
TR_RelocationRecordValidateStaticClassFromCP *scpRecord = reinterpret_cast<TR_RelocationRecordValidateStaticClassFromCP *>(reloRecord);
800
801
TR::StaticClassFromCPRecord *svmRecord = reinterpret_cast<TR::StaticClassFromCPRecord *>(relocation->getTargetAddress());
802
803
scpRecord->setClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_class));
804
scpRecord->setBeholderID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_beholder));
805
scpRecord->setCpIndex(reloTarget, svmRecord->_cpIndex);
806
}
807
break;
808
809
case TR_ValidateArrayClassFromComponentClass:
810
{
811
TR_RelocationRecordValidateArrayClassFromComponentClass *acRecord = reinterpret_cast<TR_RelocationRecordValidateArrayClassFromComponentClass *>(reloRecord);
812
813
TR::ArrayClassFromComponentClassRecord *svmRecord = reinterpret_cast<TR::ArrayClassFromComponentClassRecord *>(relocation->getTargetAddress());
814
815
acRecord->setArrayClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_arrayClass));
816
acRecord->setComponentClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_componentClass));
817
}
818
break;
819
820
case TR_ValidateSuperClassFromClass:
821
{
822
TR_RelocationRecordValidateSuperClassFromClass *scRecord = reinterpret_cast<TR_RelocationRecordValidateSuperClassFromClass *>(reloRecord);
823
824
TR::SuperClassFromClassRecord *svmRecord = reinterpret_cast<TR::SuperClassFromClassRecord *>(relocation->getTargetAddress());
825
826
scRecord->setSuperClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_superClass));
827
scRecord->setChildClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_childClass));
828
}
829
break;
830
831
case TR_ValidateClassInstanceOfClass:
832
{
833
TR_RelocationRecordValidateClassInstanceOfClass *cicRecord = reinterpret_cast<TR_RelocationRecordValidateClassInstanceOfClass *>(reloRecord);
834
835
TR::ClassInstanceOfClassRecord *svmRecord = reinterpret_cast<TR::ClassInstanceOfClassRecord *>(relocation->getTargetAddress());
836
837
cicRecord->setObjectTypeIsFixed(reloTarget, svmRecord->_objectTypeIsFixed);
838
cicRecord->setCastTypeIsFixed(reloTarget, svmRecord->_castTypeIsFixed);
839
cicRecord->setIsInstanceOf(reloTarget, svmRecord->_isInstanceOf);
840
cicRecord->setClassOneID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_classOne));
841
cicRecord->setClassTwoID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_classTwo));
842
}
843
break;
844
845
case TR_ValidateSystemClassByName:
846
{
847
TR_RelocationRecordValidateSystemClassByName *scmRecord = reinterpret_cast<TR_RelocationRecordValidateSystemClassByName *>(reloRecord);
848
849
TR::SystemClassByNameRecord *svmRecord = reinterpret_cast<TR::SystemClassByNameRecord *>(relocation->getTargetAddress());
850
851
TR_OpaqueClassBlock *classToValidate = svmRecord->_class;
852
void *classChainForClassToValidate = svmRecord->_classChain;
853
854
// Store class chain to get name of class. Checking the class chain for
855
// this record eliminates the need for a separate class chain validation.
856
uintptr_t classChainOffsetInSharedCache = self()->offsetInSharedCacheFromPointer(sharedCache, classChainForClassToValidate);
857
858
scmRecord->setSystemClassID(reloTarget, symValManager->getSymbolIDFromValue(classToValidate));
859
scmRecord->setClassChainOffset(reloTarget, classChainOffsetInSharedCache,
860
self(), svmRecord->getAOTCacheClassChainRecord());
861
}
862
break;
863
864
case TR_ValidateClassFromITableIndexCP:
865
{
866
TR_RelocationRecordValidateClassFromITableIndexCP *cfitRecord = reinterpret_cast<TR_RelocationRecordValidateClassFromITableIndexCP *>(reloRecord);
867
868
TR::ClassFromITableIndexCPRecord *svmRecord = reinterpret_cast<TR::ClassFromITableIndexCPRecord *>(relocation->getTargetAddress());
869
870
cfitRecord->setClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_class));
871
cfitRecord->setBeholderID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_beholder));
872
cfitRecord->setCpIndex(reloTarget, svmRecord->_cpIndex);
873
}
874
break;
875
876
case TR_ValidateDeclaringClassFromFieldOrStatic:
877
{
878
TR_RelocationRecordValidateDeclaringClassFromFieldOrStatic *dcfsRecord = reinterpret_cast<TR_RelocationRecordValidateDeclaringClassFromFieldOrStatic *>(reloRecord);
879
880
TR::DeclaringClassFromFieldOrStaticRecord *svmRecord = reinterpret_cast<TR::DeclaringClassFromFieldOrStaticRecord *>(relocation->getTargetAddress());
881
882
dcfsRecord->setClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_class));
883
dcfsRecord->setBeholderID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_beholder));
884
dcfsRecord->setCpIndex(reloTarget, svmRecord->_cpIndex);
885
}
886
break;
887
888
case TR_ValidateConcreteSubClassFromClass:
889
{
890
TR_RelocationRecordValidateConcreteSubClassFromClass *csccRecord = reinterpret_cast<TR_RelocationRecordValidateConcreteSubClassFromClass *>(reloRecord);
891
892
TR::ConcreteSubClassFromClassRecord *svmRecord = reinterpret_cast<TR::ConcreteSubClassFromClassRecord *>(relocation->getTargetAddress());
893
894
csccRecord->setSuperClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_superClass));
895
csccRecord->setChildClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_childClass));
896
}
897
break;
898
899
case TR_ValidateClassChain:
900
{
901
TR_RelocationRecordValidateClassChain *ccRecord = reinterpret_cast<TR_RelocationRecordValidateClassChain *>(reloRecord);
902
903
TR::ClassChainRecord *svmRecord = reinterpret_cast<TR::ClassChainRecord *>(relocation->getTargetAddress());
904
905
TR_OpaqueClassBlock *classToValidate = svmRecord->_class;
906
void *classChainForClassToValidate = svmRecord->_classChain;
907
908
// Store class chain to get name of class. Checking the class chain for
909
// this record eliminates the need for a separate class chain validation.
910
uintptr_t classChainOffsetInSharedCache = self()->offsetInSharedCacheFromPointer(sharedCache, classChainForClassToValidate);
911
912
ccRecord->setClassID(reloTarget, symValManager->getSymbolIDFromValue(classToValidate));
913
ccRecord->setClassChainOffset(reloTarget, classChainOffsetInSharedCache,
914
self(), svmRecord->getAOTCacheClassChainRecord());
915
}
916
break;
917
918
case TR_ValidateMethodFromClass:
919
{
920
TR_RelocationRecordValidateMethodFromClass *mfcRecord = reinterpret_cast<TR_RelocationRecordValidateMethodFromClass *>(reloRecord);
921
922
TR::MethodFromClassRecord *svmRecord = reinterpret_cast<TR::MethodFromClassRecord *>(relocation->getTargetAddress());
923
924
mfcRecord->setMethodID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_method));
925
mfcRecord->setBeholderID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_beholder));
926
mfcRecord->setIndex(reloTarget, svmRecord->_index);
927
}
928
break;
929
930
case TR_ValidateStaticMethodFromCP:
931
{
932
TR_RelocationRecordValidateStaticMethodFromCP *smfcpRecord = reinterpret_cast<TR_RelocationRecordValidateStaticMethodFromCP *>(reloRecord);
933
934
TR::StaticMethodFromCPRecord *svmRecord = reinterpret_cast<TR::StaticMethodFromCPRecord *>(relocation->getTargetAddress());
935
936
TR_ASSERT_FATAL(
937
(svmRecord->_cpIndex & J9_SPECIAL_SPLIT_TABLE_INDEX_FLAG) == 0,
938
"static method cpIndex has special split table flag set");
939
940
if ((svmRecord->_cpIndex & J9_STATIC_SPLIT_TABLE_INDEX_FLAG) != 0)
941
smfcpRecord->setReloFlags(reloTarget, TR_VALIDATE_STATIC_OR_SPECIAL_METHOD_FROM_CP_IS_SPLIT);
942
943
smfcpRecord->setMethodID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_method));
944
smfcpRecord->setDefiningClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_definingClass));
945
smfcpRecord->setBeholderID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_beholder));
946
smfcpRecord->setCpIndex(reloTarget, static_cast<uint16_t>(svmRecord->_cpIndex & J9_SPLIT_TABLE_INDEX_MASK));
947
}
948
break;
949
950
case TR_ValidateSpecialMethodFromCP:
951
{
952
TR_RelocationRecordValidateSpecialMethodFromCP *smfcpRecord = reinterpret_cast<TR_RelocationRecordValidateSpecialMethodFromCP *>(reloRecord);
953
954
TR::SpecialMethodFromCPRecord *svmRecord = reinterpret_cast<TR::SpecialMethodFromCPRecord *>(relocation->getTargetAddress());
955
956
TR_ASSERT_FATAL(
957
(svmRecord->_cpIndex & J9_STATIC_SPLIT_TABLE_INDEX_FLAG) == 0,
958
"special method cpIndex has static split table flag set");
959
960
if ((svmRecord->_cpIndex & J9_SPECIAL_SPLIT_TABLE_INDEX_FLAG) != 0)
961
smfcpRecord->setReloFlags(reloTarget, TR_VALIDATE_STATIC_OR_SPECIAL_METHOD_FROM_CP_IS_SPLIT);
962
963
smfcpRecord->setMethodID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_method));
964
smfcpRecord->setDefiningClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_definingClass));
965
smfcpRecord->setBeholderID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_beholder));
966
smfcpRecord->setCpIndex(reloTarget, static_cast<uint16_t>(svmRecord->_cpIndex & J9_SPLIT_TABLE_INDEX_MASK));
967
}
968
break;
969
970
case TR_ValidateVirtualMethodFromCP:
971
{
972
TR_RelocationRecordValidateVirtualMethodFromCP *vmfcpRecord = reinterpret_cast<TR_RelocationRecordValidateVirtualMethodFromCP *>(reloRecord);
973
974
TR::VirtualMethodFromCPRecord *svmRecord = reinterpret_cast<TR::VirtualMethodFromCPRecord *>(relocation->getTargetAddress());
975
976
vmfcpRecord->setMethodID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_method));
977
vmfcpRecord->setDefiningClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_definingClass));
978
vmfcpRecord->setBeholderID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_beholder));
979
vmfcpRecord->setCpIndex(reloTarget, static_cast<uint16_t>(svmRecord->_cpIndex));
980
}
981
break;
982
983
case TR_ValidateVirtualMethodFromOffset:
984
{
985
TR_RelocationRecordValidateVirtualMethodFromOffset *vmfoRecord = reinterpret_cast<TR_RelocationRecordValidateVirtualMethodFromOffset *>(reloRecord);
986
987
TR::VirtualMethodFromOffsetRecord *svmRecord = reinterpret_cast<TR::VirtualMethodFromOffsetRecord *>(relocation->getTargetAddress());
988
989
TR_ASSERT_FATAL((svmRecord->_virtualCallOffset & 1) == 0, "virtualCallOffset must be even");
990
TR_ASSERT_FATAL(
991
svmRecord->_virtualCallOffset == (int32_t)(int16_t)svmRecord->_virtualCallOffset,
992
"virtualCallOffset must fit in a 16-bit signed integer");
993
994
uint16_t ignoreRtResolve = static_cast<uint16_t>(svmRecord->_ignoreRtResolve);
995
uint16_t virtualCallOffset = static_cast<uint16_t>(svmRecord->_virtualCallOffset);
996
997
vmfoRecord->setMethodID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_method));
998
vmfoRecord->setDefiningClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_definingClass));
999
vmfoRecord->setBeholderID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_beholder));
1000
vmfoRecord->setVirtualCallOffsetAndIgnoreRtResolve(reloTarget, (virtualCallOffset | ignoreRtResolve));
1001
}
1002
break;
1003
1004
case TR_ValidateInterfaceMethodFromCP:
1005
{
1006
TR_RelocationRecordValidateInterfaceMethodFromCP *imfcpRecord = reinterpret_cast<TR_RelocationRecordValidateInterfaceMethodFromCP *>(reloRecord);
1007
1008
TR::InterfaceMethodFromCPRecord *svmRecord = reinterpret_cast<TR::InterfaceMethodFromCPRecord *>(relocation->getTargetAddress());
1009
1010
imfcpRecord->setMethodID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_method));
1011
imfcpRecord->setDefiningClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_definingClass));
1012
imfcpRecord->setBeholderID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_beholder));
1013
imfcpRecord->setLookupID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_lookup));
1014
imfcpRecord->setCpIndex(reloTarget, static_cast<uint16_t>(svmRecord->_cpIndex));
1015
}
1016
break;
1017
1018
case TR_ValidateImproperInterfaceMethodFromCP:
1019
{
1020
TR_RelocationRecordValidateImproperInterfaceMethodFromCP *iimfcpRecord = reinterpret_cast<TR_RelocationRecordValidateImproperInterfaceMethodFromCP *>(reloRecord);
1021
1022
TR::ImproperInterfaceMethodFromCPRecord *svmRecord = reinterpret_cast<TR::ImproperInterfaceMethodFromCPRecord *>(relocation->getTargetAddress());
1023
1024
iimfcpRecord->setMethodID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_method));
1025
iimfcpRecord->setDefiningClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_definingClass));
1026
iimfcpRecord->setBeholderID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_beholder));
1027
iimfcpRecord->setCpIndex(reloTarget, static_cast<uint16_t>(svmRecord->_cpIndex));
1028
}
1029
break;
1030
1031
case TR_ValidateMethodFromClassAndSig:
1032
{
1033
TR_RelocationRecordValidateMethodFromClassAndSig *mfcsRecord = reinterpret_cast<TR_RelocationRecordValidateMethodFromClassAndSig *>(reloRecord);
1034
1035
TR::MethodFromClassAndSigRecord *svmRecord = reinterpret_cast<TR::MethodFromClassAndSigRecord *>(relocation->getTargetAddress());
1036
1037
// Store rom method to get name of method
1038
J9Method *methodToValidate = reinterpret_cast<J9Method *>(svmRecord->_method);
1039
J9ROMMethod *romMethod = static_cast<TR_J9VM *>(fej9)->getROMMethodFromRAMMethod(methodToValidate);
1040
uintptr_t romMethodOffsetInSharedCache = self()->offsetInSharedCacheFromROMMethod(sharedCache, romMethod);
1041
1042
mfcsRecord->setMethodID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_method));
1043
mfcsRecord->setDefiningClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_definingClass));
1044
mfcsRecord->setBeholderID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_beholder));
1045
mfcsRecord->setLookupClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_lookupClass));
1046
mfcsRecord->setRomMethodOffsetInSCC(reloTarget, romMethodOffsetInSharedCache, self(),
1047
methodToValidate, svmRecord->_definingClass);
1048
}
1049
break;
1050
1051
case TR_ValidateStackWalkerMaySkipFramesRecord:
1052
{
1053
TR_RelocationRecordValidateStackWalkerMaySkipFrames *swmsfRecord = reinterpret_cast<TR_RelocationRecordValidateStackWalkerMaySkipFrames *>(reloRecord);
1054
1055
TR::StackWalkerMaySkipFramesRecord *svmRecord = reinterpret_cast<TR::StackWalkerMaySkipFramesRecord *>(relocation->getTargetAddress());
1056
1057
swmsfRecord->setMethodID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_method));
1058
swmsfRecord->setMethodClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_methodClass));
1059
swmsfRecord->setSkipFrames(reloTarget, svmRecord->_skipFrames);
1060
}
1061
break;
1062
1063
case TR_ValidateClassInfoIsInitialized:
1064
{
1065
TR_RelocationRecordValidateClassInfoIsInitialized *ciiiRecord = reinterpret_cast<TR_RelocationRecordValidateClassInfoIsInitialized *>(reloRecord);
1066
1067
TR::ClassInfoIsInitialized *svmRecord = reinterpret_cast<TR::ClassInfoIsInitialized *>(relocation->getTargetAddress());
1068
1069
ciiiRecord->setClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_class));
1070
ciiiRecord->setIsInitialized(reloTarget, svmRecord->_isInitialized);
1071
}
1072
break;
1073
1074
case TR_ValidateMethodFromSingleImplementer:
1075
{
1076
TR_RelocationRecordValidateMethodFromSingleImpl *mfsiRecord = reinterpret_cast<TR_RelocationRecordValidateMethodFromSingleImpl *>(reloRecord);
1077
1078
TR::MethodFromSingleImplementer *svmRecord = reinterpret_cast<TR::MethodFromSingleImplementer *>(relocation->getTargetAddress());
1079
1080
mfsiRecord->setMethodID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_method));
1081
mfsiRecord->setDefiningClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_definingClass));
1082
mfsiRecord->setThisClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_thisClass));
1083
mfsiRecord->setCpIndexOrVftSlot(reloTarget, svmRecord->_cpIndexOrVftSlot);
1084
mfsiRecord->setCallerMethodID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_callerMethod));
1085
mfsiRecord->setUseGetResolvedInterfaceMethod(reloTarget, svmRecord->_useGetResolvedInterfaceMethod);
1086
}
1087
break;
1088
1089
case TR_ValidateMethodFromSingleInterfaceImplementer:
1090
{
1091
TR_RelocationRecordValidateMethodFromSingleInterfaceImpl *mfsiiRecord = reinterpret_cast<TR_RelocationRecordValidateMethodFromSingleInterfaceImpl *>(reloRecord);
1092
1093
TR::MethodFromSingleInterfaceImplementer *svmRecord = reinterpret_cast<TR::MethodFromSingleInterfaceImplementer *>(relocation->getTargetAddress());
1094
1095
mfsiiRecord->setMethodID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_method));
1096
mfsiiRecord->setDefiningClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_definingClass));
1097
mfsiiRecord->setThisClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_thisClass));
1098
mfsiiRecord->setCallerMethodID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_callerMethod));
1099
mfsiiRecord->setCpIndex(reloTarget, static_cast<uint16_t>(svmRecord->_cpIndex));
1100
}
1101
break;
1102
1103
case TR_ValidateMethodFromSingleAbstractImplementer:
1104
{
1105
TR_RelocationRecordValidateMethodFromSingleAbstractImpl *mfsaiRecord = reinterpret_cast<TR_RelocationRecordValidateMethodFromSingleAbstractImpl *>(reloRecord);
1106
1107
TR::MethodFromSingleAbstractImplementer *svmRecord = reinterpret_cast<TR::MethodFromSingleAbstractImplementer *>(relocation->getTargetAddress());
1108
1109
mfsaiRecord->setMethodID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_method));
1110
mfsaiRecord->setDefiningClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_definingClass));
1111
mfsaiRecord->setThisClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_thisClass));
1112
mfsaiRecord->setCallerMethodID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_callerMethod));
1113
mfsaiRecord->setVftSlot(reloTarget, svmRecord->_vftSlot);
1114
}
1115
break;
1116
1117
case TR_SymbolFromManager:
1118
{
1119
TR_RelocationRecordSymbolFromManager *sfmRecord = reinterpret_cast<TR_RelocationRecordSymbolFromManager *>(reloRecord);
1120
1121
uint8_t *symbol = relocation->getTargetAddress();
1122
uint16_t symbolID = comp->getSymbolValidationManager()->getSymbolIDFromValue(static_cast<void *>(symbol));
1123
1124
uint16_t symbolType = (uint16_t)(uintptr_t)relocation->getTargetAddress2();
1125
1126
sfmRecord->setSymbolID(reloTarget, symbolID);
1127
sfmRecord->setSymbolType(reloTarget, static_cast<TR::SymbolType>(symbolType));
1128
}
1129
break;
1130
1131
case TR_ResolvedTrampolines:
1132
{
1133
TR_RelocationRecordResolvedTrampolines *rtRecord = reinterpret_cast<TR_RelocationRecordResolvedTrampolines *>(reloRecord);
1134
1135
uint8_t *symbol = relocation->getTargetAddress();
1136
uint16_t symbolID = comp->getSymbolValidationManager()->getSymbolIDFromValue(static_cast<void *>(symbol));
1137
1138
rtRecord->setSymbolID(reloTarget, symbolID);
1139
}
1140
break;
1141
1142
case TR_MethodObject:
1143
{
1144
TR_RelocationRecordMethodObject *moRecord = reinterpret_cast<TR_RelocationRecordMethodObject *>(reloRecord);
1145
1146
TR::SymbolReference *symRef = reinterpret_cast<TR::SymbolReference *>(relocation->getTargetAddress());
1147
1148
moRecord->setInlinedSiteIndex(reloTarget, reinterpret_cast<uintptr_t>(relocation->getTargetAddress2()));
1149
moRecord->setConstantPool(reloTarget, reinterpret_cast<uintptr_t>(symRef->getOwningMethod(comp)->constantPool()));
1150
}
1151
break;
1152
1153
case TR_DataAddress:
1154
{
1155
TR_RelocationRecordDataAddress *daRecord = reinterpret_cast<TR_RelocationRecordDataAddress *>(reloRecord);
1156
1157
TR::SymbolReference *symRef = reinterpret_cast<TR::SymbolReference *>(relocation->getTargetAddress());
1158
uintptr_t inlinedSiteIndex = reinterpret_cast<uintptr_t>(relocation->getTargetAddress2());
1159
1160
void *constantPool = symRef->getOwningMethod(comp)->constantPool();
1161
inlinedSiteIndex = self()->findCorrectInlinedSiteIndex(constantPool, inlinedSiteIndex);
1162
1163
daRecord->setInlinedSiteIndex(reloTarget, inlinedSiteIndex);
1164
daRecord->setConstantPool(reloTarget, reinterpret_cast<uintptr_t>(constantPool));
1165
daRecord->setCpIndex(reloTarget, symRef->getCPIndex());
1166
daRecord->setOffset(reloTarget, symRef->getOffset());
1167
}
1168
break;
1169
1170
case TR_FixedSequenceAddress2:
1171
case TR_RamMethodSequence:
1172
{
1173
TR_RelocationRecordWithOffset *rwoRecord = reinterpret_cast<TR_RelocationRecordWithOffset *>(reloRecord);
1174
1175
TR_ASSERT_FATAL(relocation->getTargetAddress(), "target address is NULL");
1176
uintptr_t offset = relocation->getTargetAddress()
1177
? static_cast<uintptr_t>(relocation->getTargetAddress() - aotMethodCodeStart)
1178
: 0x0;
1179
1180
rwoRecord->setOffset(reloTarget, offset);
1181
}
1182
break;
1183
1184
case TR_ArbitraryClassAddress:
1185
{
1186
TR_RelocationRecordArbitraryClassAddress *acaRecord = reinterpret_cast<TR_RelocationRecordArbitraryClassAddress *>(reloRecord);
1187
1188
TR::SymbolReference *symRef = reinterpret_cast<TR::SymbolReference *>(relocation->getTargetAddress());
1189
TR::StaticSymbol *sym = symRef->getSymbol()->castToStaticSymbol();
1190
TR_OpaqueClassBlock *j9class = reinterpret_cast<TR_OpaqueClassBlock *>(sym->getStaticAddress());
1191
uintptr_t inlinedSiteIndex = reinterpret_cast<uintptr_t>(relocation->getTargetAddress2());
1192
1193
void *constantPool = symRef->getOwningMethod(comp)->constantPool();
1194
inlinedSiteIndex = self()->findCorrectInlinedSiteIndex(constantPool, inlinedSiteIndex);
1195
1196
uintptr_t classChainIdentifyingLoaderOffsetInSharedCache = sharedCache->getClassChainOffsetIdentifyingLoader(j9class);
1197
const AOTCacheClassChainRecord *classChainRecord = NULL;
1198
uintptr_t classChainOffsetInSharedCache = self()->getClassChainOffset(j9class, classChainRecord);
1199
1200
acaRecord->setInlinedSiteIndex(reloTarget, inlinedSiteIndex);
1201
acaRecord->setClassChainIdentifyingLoaderOffsetInSharedCache(reloTarget, classChainIdentifyingLoaderOffsetInSharedCache,
1202
self(), classChainRecord);
1203
acaRecord->setClassChainForInlinedMethod(reloTarget, classChainOffsetInSharedCache, self(), classChainRecord);
1204
}
1205
break;
1206
1207
case TR_GlobalValue:
1208
case TR_HCR:
1209
{
1210
TR_RelocationRecordWithOffset *rwoRecord = reinterpret_cast<TR_RelocationRecordWithOffset *>(reloRecord);
1211
1212
uintptr_t gv = reinterpret_cast<uintptr_t>(relocation->getTargetAddress());
1213
1214
rwoRecord->setOffset(reloTarget, gv);
1215
}
1216
break;
1217
1218
case TR_DebugCounter:
1219
{
1220
TR_RelocationRecordDebugCounter *dcRecord = reinterpret_cast<TR_RelocationRecordDebugCounter *>(reloRecord);
1221
1222
TR::DebugCounterBase *counter = reinterpret_cast<TR::DebugCounterBase *>(relocation->getTargetAddress());
1223
if (!counter || !counter->getReloData() || !counter->getName())
1224
comp->failCompilation<TR::CompilationException>("Failed to generate debug counter relo data");
1225
1226
TR::DebugCounterReloData *counterReloData = counter->getReloData();
1227
1228
uintptr_t offsetOfNameString = fej9->sharedCache()->rememberDebugCounterName(counter->getName());
1229
uint8_t flags = counterReloData->_seqKind;
1230
1231
TR_ASSERT((flags & RELOCATION_CROSS_PLATFORM_FLAGS_MASK) == 0, "reloFlags bits overlap cross-platform flags bits\n");
1232
dcRecord->setReloFlags(reloTarget, flags);
1233
dcRecord->setInlinedSiteIndex(reloTarget, static_cast<uintptr_t>(counterReloData->_callerIndex));
1234
dcRecord->setBCIndex(reloTarget, counterReloData->_bytecodeIndex);
1235
dcRecord->setDelta(reloTarget, counterReloData->_delta);
1236
dcRecord->setFidelity(reloTarget, counterReloData->_fidelity);
1237
dcRecord->setStaticDelta(reloTarget, counterReloData->_staticDelta);
1238
dcRecord->setOffsetOfNameString(reloTarget, offsetOfNameString);
1239
}
1240
break;
1241
1242
case TR_BlockFrequency:
1243
{
1244
TR_RelocationRecordBlockFrequency *bfRecord = reinterpret_cast<TR_RelocationRecordBlockFrequency *>(reloRecord);
1245
TR_RelocationRecordInformation *recordInfo = reinterpret_cast<TR_RelocationRecordInformation *>(relocation->getTargetAddress());
1246
TR::SymbolReference *tempSR = reinterpret_cast<TR::SymbolReference *>(recordInfo->data1);
1247
TR::StaticSymbol *staticSym = tempSR->getSymbol()->getStaticSymbol();
1248
1249
uint8_t flags = (uint8_t) recordInfo->data2;
1250
TR_ASSERT((flags & RELOCATION_CROSS_PLATFORM_FLAGS_MASK) == 0, "reloFlags bits overlap cross-platform flags bits\n");
1251
bfRecord->setReloFlags(reloTarget, flags);
1252
1253
TR_PersistentProfileInfo *profileInfo = comp->getRecompilationInfo()->getProfileInfo();
1254
TR_ASSERT(NULL != profileInfo, "PersistentProfileInfo not found when creating relocation record for block frequency\n");
1255
if (NULL == profileInfo)
1256
{
1257
comp->failCompilation<J9::AOTRelocationRecordGenerationFailure>("AOT header initialization can't find profile info");
1258
}
1259
1260
TR_BlockFrequencyInfo *blockFrequencyInfo = profileInfo->getBlockFrequencyInfo();
1261
TR_ASSERT(NULL != blockFrequencyInfo, "BlockFrequencyInfo not found when creating relocation record for block frequency\n");
1262
if (NULL == blockFrequencyInfo)
1263
{
1264
comp->failCompilation<J9::AOTRelocationRecordGenerationFailure>("AOT header initialization can't find block frequency info");
1265
}
1266
1267
uintptr_t frequencyArrayBase = reinterpret_cast<uintptr_t>(blockFrequencyInfo->getFrequencyArrayBase());
1268
uintptr_t frequencyPtr = reinterpret_cast<uintptr_t>(staticSym->getStaticAddress());
1269
1270
bfRecord->setFrequencyOffset(reloTarget, frequencyPtr - frequencyArrayBase);
1271
}
1272
break;
1273
1274
case TR_Breakpoint:
1275
{
1276
TR_RelocationRecordBreakpointGuard *bpgRecord = reinterpret_cast<TR_RelocationRecordBreakpointGuard *>(reloRecord);
1277
1278
int32_t inlinedSiteIndex = static_cast<int32_t>(reinterpret_cast<uintptr_t>(relocation->getTargetAddress()));
1279
uintptr_t destinationAddress = reinterpret_cast<uintptr_t>(relocation->getTargetAddress2());
1280
1281
bpgRecord->setInlinedSiteIndex(reloTarget, inlinedSiteIndex);
1282
bpgRecord->setDestinationAddress(reloTarget, destinationAddress);
1283
}
1284
break;
1285
1286
case TR_ValidateJ2IThunkFromMethod:
1287
{
1288
auto *thunkRecord = reinterpret_cast<TR_RelocationRecordValidateJ2IThunkFromMethod *>(reloRecord);
1289
auto *svmRecord = reinterpret_cast<TR::J2IThunkFromMethodRecord *>(relocation->getTargetAddress());
1290
thunkRecord->setThunkID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_thunk));
1291
thunkRecord->setMethodID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_method));
1292
}
1293
break;
1294
1295
default:
1296
TR_ASSERT(false, "Unknown relo type %d!\n", kind);
1297
comp->failCompilation<J9::AOTRelocationRecordGenerationFailure>("Unknown relo type %d!\n", kind);
1298
break;
1299
}
1300
}
1301
1302
uint8_t *
1303
J9::AheadOfTimeCompile::dumpRelocationHeaderData(uint8_t *cursor, bool isVerbose)
1304
{
1305
TR::Compilation *comp = TR::comp();
1306
TR_RelocationRuntime *reloRuntime = comp->reloRuntime();
1307
TR_RelocationTarget *reloTarget = reloRuntime->reloTarget();
1308
1309
TR_RelocationRecord storage;
1310
TR_RelocationRecord *reloRecord = TR_RelocationRecord::create(&storage, reloRuntime, reloTarget, reinterpret_cast<TR_RelocationRecordBinaryTemplate *>(cursor));
1311
1312
TR_ExternalRelocationTargetKind kind = reloRecord->type(reloTarget);
1313
1314
int32_t offsetSize = reloRecord->wideOffsets(reloTarget) ? 4 : 2;
1315
1316
uint8_t *startOfOffsets = cursor + self()->getSizeOfAOTRelocationHeader(kind);
1317
uint8_t *endOfCurrentRecord = cursor + reloRecord->size(reloTarget);
1318
1319
bool orderedPair = isOrderedPair(kind);
1320
1321
traceMsg(self()->comp(), "%16x ", cursor);
1322
traceMsg(self()->comp(), "%-5d", reloRecord->size(reloTarget));
1323
traceMsg(self()->comp(), "%-31s", TR::ExternalRelocation::getName(kind));
1324
traceMsg(self()->comp(), "%-6d", offsetSize);
1325
traceMsg(self()->comp(), "%s", (reloRecord->flags(reloTarget) & RELOCATION_TYPE_EIP_OFFSET) ? "Rel " : "Abs ");
1326
1327
// Print out the correct number of spaces when no index is available
1328
if (kind != TR_HelperAddress && kind != TR_AbsoluteHelperAddress)
1329
traceMsg(self()->comp(), " ");
1330
1331
switch (kind)
1332
{
1333
case TR_ConstantPool:
1334
case TR_Thunks:
1335
case TR_Trampolines:
1336
{
1337
TR_RelocationRecordConstantPool * cpRecord = reinterpret_cast<TR_RelocationRecordConstantPool *>(reloRecord);
1338
1339
self()->traceRelocationOffsets(startOfOffsets, offsetSize, endOfCurrentRecord, orderedPair);
1340
if (isVerbose)
1341
{
1342
traceMsg(self()->comp(), "\nInlined site index = %d, Constant pool = %x",
1343
cpRecord->inlinedSiteIndex(reloTarget),
1344
cpRecord->constantPool(reloTarget));
1345
}
1346
}
1347
break;
1348
1349
case TR_MethodObject:
1350
{
1351
TR_RelocationRecordConstantPool * cpRecord = reinterpret_cast<TR_RelocationRecordConstantPool *>(reloRecord);
1352
1353
self()->traceRelocationOffsets(startOfOffsets, offsetSize, endOfCurrentRecord, orderedPair);
1354
if (isVerbose)
1355
{
1356
traceMsg(self()->comp(), "\nInlined site index = %d, Constant pool = %x, flags = %x",
1357
cpRecord->inlinedSiteIndex(reloTarget),
1358
cpRecord->constantPool(reloTarget),
1359
(uint32_t)cpRecord->reloFlags(reloTarget));
1360
}
1361
}
1362
break;
1363
1364
case TR_HelperAddress:
1365
{
1366
TR_RelocationRecordHelperAddress *haRecord = reinterpret_cast<TR_RelocationRecordHelperAddress *>(reloRecord);
1367
1368
uint32_t helperID = haRecord->helperID(reloTarget);
1369
1370
traceMsg(self()->comp(), "%-6d", helperID);
1371
self()->traceRelocationOffsets(startOfOffsets, offsetSize, endOfCurrentRecord, orderedPair);
1372
if (isVerbose)
1373
{
1374
TR::SymbolReference *symRef = self()->comp()->getSymRefTab()->getSymRef(helperID);
1375
traceMsg(self()->comp(), "\nHelper method address of %s(%d)", self()->getDebug()->getName(symRef), helperID);
1376
}
1377
}
1378
break;
1379
1380
case TR_RelativeMethodAddress:
1381
case TR_AbsoluteMethodAddress:
1382
case TR_BodyInfoAddress:
1383
case TR_RamMethod:
1384
case TR_ClassUnloadAssumption:
1385
case TR_AbsoluteMethodAddressOrderedPair:
1386
case TR_ArrayCopyHelper:
1387
case TR_ArrayCopyToc:
1388
case TR_BodyInfoAddressLoad:
1389
case TR_RecompQueuedFlag:
1390
{
1391
self()->traceRelocationOffsets(startOfOffsets, offsetSize, endOfCurrentRecord, orderedPair);
1392
}
1393
break;
1394
1395
case TR_MethodCallAddress:
1396
{
1397
TR_RelocationRecordMethodCallAddress *mcaRecord = reinterpret_cast<TR_RelocationRecordMethodCallAddress *>(reloRecord);
1398
traceMsg(self()->comp(), "\n Method Call Address: address=" POINTER_PRINTF_FORMAT, mcaRecord->address(reloTarget));
1399
self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);
1400
}
1401
break;
1402
1403
case TR_AbsoluteHelperAddress:
1404
{
1405
TR_RelocationRecordAbsoluteHelperAddress *ahaRecord = reinterpret_cast<TR_RelocationRecordAbsoluteHelperAddress *>(reloRecord);
1406
1407
uint32_t helperID = ahaRecord->helperID(reloTarget);
1408
1409
traceMsg(self()->comp(), "%-6d", helperID);
1410
self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);
1411
if (isVerbose)
1412
{
1413
TR::SymbolReference *symRef = self()->comp()->getSymRefTab()->getSymRef(helperID);
1414
traceMsg(self()->comp(), "\nHelper method address of %s(%d)", self()->getDebug()->getName(symRef), helperID);
1415
}
1416
}
1417
break;
1418
1419
case TR_JNIVirtualTargetAddress:
1420
case TR_JNIStaticTargetAddress:
1421
case TR_JNISpecialTargetAddress:
1422
{
1423
TR_RelocationRecordDirectJNICall *djnicRecord = reinterpret_cast<TR_RelocationRecordDirectJNICall *>(reloRecord);
1424
1425
self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);
1426
if (isVerbose)
1427
{
1428
traceMsg(self()->comp(), "\n Direct to JNI Relocation (%s): inlinedIndex = %d, constantPool = %p, CPI = %d, offsetToReloLocation = %d",
1429
getNameForMethodRelocation(kind),
1430
djnicRecord->inlinedSiteIndex(reloTarget),
1431
djnicRecord->constantPool(reloTarget),
1432
djnicRecord->cpIndex(reloTarget),
1433
djnicRecord->offsetToReloLocation(reloTarget));
1434
}
1435
}
1436
break;
1437
1438
case TR_StaticRamMethodConst:
1439
case TR_SpecialRamMethodConst:
1440
case TR_VirtualRamMethodConst:
1441
{
1442
TR_RelocationRecordConstantPoolWithIndex *cpiRecord = reinterpret_cast<TR_RelocationRecordConstantPoolWithIndex *>(reloRecord);
1443
1444
self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);
1445
if (isVerbose)
1446
{
1447
traceMsg(self()->comp(), "\n Address Relocation (%s): inlinedIndex = %d, constantPool = %p, CPI = %d",
1448
getNameForMethodRelocation(kind),
1449
cpiRecord->inlinedSiteIndex(reloTarget),
1450
cpiRecord->constantPool(reloTarget),
1451
cpiRecord->cpIndex(reloTarget));
1452
}
1453
}
1454
break;
1455
1456
case TR_ClassAddress:
1457
{
1458
TR_RelocationRecordConstantPoolWithIndex *cpiRecord = reinterpret_cast<TR_RelocationRecordConstantPoolWithIndex *>(reloRecord);
1459
1460
self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);
1461
if (isVerbose)
1462
{
1463
traceMsg(self()->comp(), "\n Address Relocation (TR_ClassAddress): inlinedIndex = %d, constantPool = %p, CPI = %d, flags = %x",
1464
cpiRecord->inlinedSiteIndex(reloTarget),
1465
cpiRecord->constantPool(reloTarget),
1466
cpiRecord->cpIndex(reloTarget),
1467
(uint32_t)cpiRecord->reloFlags(reloTarget));
1468
}
1469
}
1470
break;
1471
1472
case TR_CheckMethodEnter:
1473
case TR_CheckMethodExit:
1474
{
1475
TR_RelocationRecordMethodTracingCheck *mtRecord = reinterpret_cast<TR_RelocationRecordMethodTracingCheck *>(reloRecord);
1476
1477
self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);
1478
if (isVerbose)
1479
{
1480
traceMsg(self()->comp(), "\nDestination address %x", mtRecord->destinationAddress(reloTarget));
1481
}
1482
}
1483
break;
1484
1485
case TR_VerifyClassObjectForAlloc:
1486
{
1487
TR_RelocationRecordVerifyClassObjectForAlloc *allocRecord = reinterpret_cast<TR_RelocationRecordVerifyClassObjectForAlloc *>(reloRecord);
1488
1489
self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);
1490
if (isVerbose)
1491
{
1492
traceMsg(self()->comp(), "\nVerify Class Object for Allocation: InlineCallSite index = %d, Constant pool = %x, index = %d, binaryEncode = %x, size = %d",
1493
allocRecord->inlinedSiteIndex(reloTarget),
1494
allocRecord->constantPool(reloTarget),
1495
allocRecord->cpIndex(reloTarget),
1496
allocRecord->branchOffset(reloTarget),
1497
allocRecord->allocationSize(reloTarget));
1498
}
1499
}
1500
break;
1501
1502
case TR_VerifyRefArrayForAlloc:
1503
{
1504
TR_RelocationRecordVerifyRefArrayForAlloc *allocRecord = reinterpret_cast<TR_RelocationRecordVerifyRefArrayForAlloc *>(reloRecord);
1505
1506
self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);
1507
if (isVerbose)
1508
{
1509
traceMsg(self()->comp(), "\nVerify Class Object for Allocation: InlineCallSite index = %d, Constant pool = %x, index = %d, binaryEncode = %x",
1510
allocRecord->inlinedSiteIndex(reloTarget),
1511
allocRecord->constantPool(reloTarget),
1512
allocRecord->cpIndex(reloTarget),
1513
allocRecord->branchOffset(reloTarget));
1514
}
1515
}
1516
break;
1517
1518
case TR_ValidateInstanceField:
1519
{
1520
TR_RelocationRecordValidateInstanceField *fieldRecord = reinterpret_cast<TR_RelocationRecordValidateInstanceField *>(reloRecord);
1521
1522
self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);
1523
if (isVerbose)
1524
{
1525
traceMsg(self()->comp(), "\nValidation Relocation: InlineCallSite index = %d, Constant pool = %x, cpIndex = %d, Class Chain offset = %x",
1526
fieldRecord->inlinedSiteIndex(reloTarget),
1527
fieldRecord->constantPool(reloTarget),
1528
fieldRecord->cpIndex(reloTarget),
1529
fieldRecord->classChainOffsetInSharedCache(reloTarget));
1530
}
1531
}
1532
break;
1533
1534
case TR_InlinedStaticMethodWithNopGuard:
1535
case TR_InlinedSpecialMethodWithNopGuard:
1536
case TR_InlinedVirtualMethodWithNopGuard:
1537
case TR_InlinedInterfaceMethodWithNopGuard:
1538
case TR_InlinedAbstractMethodWithNopGuard:
1539
{
1540
TR_RelocationRecordNopGuard *inlinedMethod = reinterpret_cast<TR_RelocationRecordNopGuard *>(reloRecord);
1541
1542
self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);
1543
if (isVerbose)
1544
{
1545
traceMsg(self()->comp(), "\nInlined Method: Inlined site index = %d, Constant pool = %x, cpIndex = %x, romClassOffsetInSharedCache=%p, destinationAddress = %p",
1546
inlinedMethod->inlinedSiteIndex(reloTarget),
1547
inlinedMethod->constantPool(reloTarget),
1548
inlinedMethod->cpIndex(reloTarget),
1549
inlinedMethod->romClassOffsetInSharedCache(reloTarget),
1550
inlinedMethod->destinationAddress(reloTarget));
1551
}
1552
}
1553
break;
1554
1555
case TR_ValidateStaticField:
1556
{
1557
TR_RelocationRecordValidateStaticField *vsfRecord = reinterpret_cast<TR_RelocationRecordValidateStaticField *>(reloRecord);
1558
1559
self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);
1560
if (isVerbose)
1561
{
1562
traceMsg(self()->comp(), "\nValidation Relocation: InlineCallSite index = %d, Constant pool = %x, cpIndex = %d, ROM Class offset = %x",
1563
vsfRecord->inlinedSiteIndex(reloTarget),
1564
vsfRecord->constantPool(reloTarget),
1565
vsfRecord->cpIndex(reloTarget),
1566
vsfRecord->romClassOffsetInSharedCache(reloTarget));
1567
}
1568
}
1569
break;
1570
1571
case TR_ValidateClass:
1572
{
1573
TR_RelocationRecordValidateClass *vcRecord = reinterpret_cast<TR_RelocationRecordValidateClass *>(reloRecord);
1574
1575
self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);
1576
if (isVerbose)
1577
{
1578
traceMsg(self()->comp(), "\nValidation Relocation: InlineCallSite index = %d, Constant pool = %x, cpIndex = %d, Class Chain offset = %x",
1579
vcRecord->inlinedSiteIndex(reloTarget),
1580
vcRecord->constantPool(reloTarget),
1581
vcRecord->cpIndex(reloTarget),
1582
vcRecord->classChainOffsetInSharedCache(reloTarget));
1583
}
1584
}
1585
break;
1586
1587
case TR_ProfiledMethodGuardRelocation:
1588
case TR_ProfiledClassGuardRelocation:
1589
case TR_ProfiledInlinedMethodRelocation:
1590
{
1591
TR_RelocationRecordProfiledInlinedMethod *pRecord = reinterpret_cast<TR_RelocationRecordProfiledInlinedMethod *>(reloRecord);
1592
1593
self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);
1594
if (isVerbose)
1595
{
1596
traceMsg(self()->comp(), "\nProfiled Class Guard: Inlined site index = %d, Constant pool = %x, cpIndex = %x, romClassOffsetInSharedCache=%p, classChainIdentifyingLoaderOffsetInSharedCache=%p, classChainForInlinedMethod %p, methodIndex %d",
1597
pRecord->inlinedSiteIndex(reloTarget),
1598
pRecord->constantPool(reloTarget),
1599
pRecord->romClassOffsetInSharedCache(reloTarget),
1600
pRecord->classChainIdentifyingLoaderOffsetInSharedCache(reloTarget),
1601
pRecord->classChainForInlinedMethod(reloTarget),
1602
pRecord->methodIndex(reloTarget));
1603
}
1604
}
1605
break;
1606
1607
case TR_MethodPointer:
1608
{
1609
TR_RelocationRecordMethodPointer *mpRecord = reinterpret_cast<TR_RelocationRecordMethodPointer *>(reloRecord);
1610
1611
self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);
1612
if (isVerbose)
1613
{
1614
traceMsg(self()->comp(), "\nMethod Pointer: Inlined site index = %d, classChainIdentifyingLoaderOffsetInSharedCache=%p, classChainForInlinedMethod %p, vTableOffset %x",
1615
mpRecord->inlinedSiteIndex(reloTarget),
1616
mpRecord->classChainIdentifyingLoaderOffsetInSharedCache(reloTarget),
1617
mpRecord->classChainForInlinedMethod(reloTarget),
1618
mpRecord->vTableSlot(reloTarget));
1619
}
1620
}
1621
break;
1622
1623
case TR_InlinedMethodPointer:
1624
{
1625
TR_RelocationRecordInlinedMethodPointer *impRecord = reinterpret_cast<TR_RelocationRecordInlinedMethodPointer *>(reloRecord);
1626
1627
self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);
1628
if (isVerbose)
1629
{
1630
traceMsg(self()->comp(), "\nInlined Method Pointer: Inlined site index = %d", impRecord->inlinedSiteIndex(reloTarget));
1631
}
1632
}
1633
break;
1634
1635
case TR_ClassPointer:
1636
case TR_ArbitraryClassAddress:
1637
{
1638
TR_RelocationRecordClassPointer *cpRecord = reinterpret_cast<TR_RelocationRecordClassPointer *>(reloRecord);
1639
1640
self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);
1641
if (isVerbose)
1642
{
1643
traceMsg(self()->comp(), "\nClass Pointer: Inlined site index = %d, classChainIdentifyingLoaderOffsetInSharedCache=%p, classChainForInlinedMethod %p",
1644
cpRecord->inlinedSiteIndex(reloTarget),
1645
cpRecord->classChainIdentifyingLoaderOffsetInSharedCache(reloTarget),
1646
cpRecord->classChainForInlinedMethod(reloTarget));
1647
}
1648
}
1649
break;
1650
1651
case TR_ValidateArbitraryClass:
1652
{
1653
TR_RelocationRecordValidateArbitraryClass *vacRecord = reinterpret_cast<TR_RelocationRecordValidateArbitraryClass *>(reloRecord);
1654
1655
self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);
1656
if (isVerbose)
1657
{
1658
traceMsg(self()->comp(), "\nValidateArbitraryClass Relocation: classChainOffsetForClassToValidate = %p, classChainIdentifyingClassLoader = %p",
1659
vacRecord->classChainOffsetForClassBeingValidated(reloTarget),
1660
vacRecord->classChainIdentifyingLoaderOffset(reloTarget));
1661
}
1662
}
1663
break;
1664
1665
case TR_InlinedInterfaceMethod:
1666
case TR_InlinedVirtualMethod:
1667
{
1668
TR_RelocationRecordInlinedMethod *imRecord = reinterpret_cast<TR_RelocationRecordInlinedMethod *>(reloRecord);
1669
1670
self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);
1671
if (isVerbose)
1672
{
1673
traceMsg(self()->comp(), "\n Removed Guard inlined method: Inlined site index = %d, Constant pool = %x, cpIndex = %x, romClassOffsetInSharedCache=%p",
1674
imRecord->inlinedSiteIndex(reloTarget),
1675
imRecord->constantPool(reloTarget),
1676
imRecord->cpIndex(reloTarget),
1677
imRecord->romClassOffsetInSharedCache(reloTarget));
1678
}
1679
}
1680
break;
1681
1682
case TR_J2IVirtualThunkPointer:
1683
{
1684
TR_RelocationRecordJ2IVirtualThunkPointer *vtpRecord = reinterpret_cast<TR_RelocationRecordJ2IVirtualThunkPointer *>(reloRecord);
1685
1686
self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);
1687
if (isVerbose)
1688
{
1689
traceMsg(self()->comp(), "\nInlined site index %lld, constant pool 0x%llx, offset to j2i thunk pointer 0x%llx",
1690
vtpRecord->inlinedSiteIndex(reloTarget),
1691
vtpRecord->constantPool(reloTarget),
1692
vtpRecord->getOffsetToJ2IVirtualThunkPointer(reloTarget));
1693
}
1694
}
1695
break;
1696
1697
case TR_ValidateClassByName:
1698
{
1699
TR_RelocationRecordValidateClassByName *cbnRecord = reinterpret_cast<TR_RelocationRecordValidateClassByName *>(reloRecord);
1700
1701
self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);
1702
if (isVerbose)
1703
{
1704
traceMsg(self()->comp(), "\n Validate Class By Name: classID=%d beholderID=%d classChainOffsetInSCC=%p ",
1705
(uint32_t)cbnRecord->classID(reloTarget),
1706
(uint32_t)cbnRecord->beholderID(reloTarget),
1707
(void *)cbnRecord->classChainOffset(reloTarget));
1708
}
1709
}
1710
break;
1711
1712
case TR_ValidateProfiledClass:
1713
{
1714
TR_RelocationRecordValidateProfiledClass *pcRecord = reinterpret_cast<TR_RelocationRecordValidateProfiledClass *>(reloRecord);
1715
1716
self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);
1717
if (isVerbose)
1718
{
1719
traceMsg(self()->comp(), "\n Validate Profiled Class: classID=%d classChainOffsetInSCC=%p classChainOffsetForCLInScc=%p ",
1720
(uint32_t)pcRecord->classID(reloTarget),
1721
(void *)pcRecord->classChainOffset(reloTarget),
1722
(void *)pcRecord->classChainOffsetForClassLoader(reloTarget));
1723
}
1724
}
1725
break;
1726
1727
case TR_ValidateClassFromCP:
1728
case TR_ValidateStaticClassFromCP:
1729
case TR_ValidateClassFromITableIndexCP:
1730
case TR_ValidateDeclaringClassFromFieldOrStatic:
1731
{
1732
TR_RelocationRecordValidateClassFromCP *cpRecord = reinterpret_cast<TR_RelocationRecordValidateClassFromCP *>(reloRecord);
1733
1734
self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);
1735
if (isVerbose)
1736
{
1737
const char *recordType;
1738
if (kind == TR_ValidateClassFromCP)
1739
recordType = "Class From CP";
1740
else if (kind == TR_ValidateStaticClassFromCP)
1741
recordType = "Static Class FromCP";
1742
else if (kind == TR_ValidateClassFromITableIndexCP)
1743
recordType = "Class From ITable Index CP";
1744
else if (kind == TR_ValidateDeclaringClassFromFieldOrStatic)
1745
recordType = "Declaring Class From Field or Static";
1746
else
1747
TR_ASSERT_FATAL(false, "Unknown relokind %d!\n", kind);
1748
1749
traceMsg(self()->comp(), "\n Validate %s: classID=%d, beholderID=%d, cpIndex=%d ",
1750
recordType,
1751
(uint32_t)cpRecord->classID(reloTarget),
1752
(uint32_t)cpRecord->beholderID(reloTarget),
1753
cpRecord->cpIndex(reloTarget));
1754
}
1755
}
1756
break;
1757
1758
case TR_ValidateDefiningClassFromCP:
1759
{
1760
TR_RelocationRecordValidateDefiningClassFromCP *dcpRecord = reinterpret_cast<TR_RelocationRecordValidateDefiningClassFromCP *>(reloRecord);
1761
1762
self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);
1763
if (isVerbose)
1764
{
1765
traceMsg(self()->comp(), "\n Validate Defining Class From CP: classID=%d, beholderID=%d, cpIndex=%d, isStatic=%s ",
1766
(uint32_t)dcpRecord->classID(reloTarget),
1767
(uint32_t)dcpRecord->beholderID(reloTarget),
1768
dcpRecord->cpIndex(reloTarget),
1769
dcpRecord->isStatic(reloTarget) ? "true" : "false");
1770
}
1771
}
1772
break;
1773
1774
case TR_ValidateArrayClassFromComponentClass:
1775
{
1776
TR_RelocationRecordValidateArrayClassFromComponentClass *acRecord = reinterpret_cast<TR_RelocationRecordValidateArrayClassFromComponentClass *>(reloRecord);
1777
1778
self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);
1779
if (isVerbose)
1780
{
1781
traceMsg(self()->comp(), "\n Validate Array Class From Component: arrayClassID=%d, componentClassID=%d ",
1782
(uint32_t)acRecord->arrayClassID(reloTarget),
1783
(uint32_t)acRecord->componentClassID(reloTarget));
1784
}
1785
}
1786
break;
1787
1788
case TR_ValidateSuperClassFromClass:
1789
case TR_ValidateConcreteSubClassFromClass:
1790
{
1791
TR_RelocationRecordValidateSuperClassFromClass *scRecord = reinterpret_cast<TR_RelocationRecordValidateSuperClassFromClass *>(reloRecord);
1792
1793
self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);
1794
if (isVerbose)
1795
{
1796
const char *recordType;
1797
if (kind == TR_ValidateSuperClassFromClass)
1798
recordType = "Super Class From Class";
1799
else if (kind == TR_ValidateConcreteSubClassFromClass)
1800
recordType = "Concrete SubClass From Class";
1801
else
1802
TR_ASSERT_FATAL(false, "Unknown relokind %d!\n", kind);
1803
1804
traceMsg(self()->comp(), "\n Validate %s: superClassID=%d, childClassID=%d ",
1805
recordType,
1806
(uint32_t)scRecord->superClassID(reloTarget),
1807
(uint32_t)scRecord->childClassID(reloTarget));
1808
}
1809
}
1810
break;
1811
1812
case TR_ValidateClassInstanceOfClass:
1813
{
1814
TR_RelocationRecordValidateClassInstanceOfClass *cicRecord = reinterpret_cast<TR_RelocationRecordValidateClassInstanceOfClass *>(reloRecord);
1815
1816
self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);
1817
if(isVerbose)
1818
{
1819
traceMsg(self()->comp(), "\n Validate Class InstanceOf Class: classOneID=%d, classTwoID=%d, objectTypeIsFixed=%s, castTypeIsFixed=%s, isInstanceOf=%s ",
1820
(uint32_t)cicRecord->classOneID(reloTarget),
1821
(uint32_t)cicRecord->classTwoID(reloTarget),
1822
cicRecord->objectTypeIsFixed(reloTarget) ? "true" : "false",
1823
cicRecord->castTypeIsFixed(reloTarget) ? "true" : "false",
1824
cicRecord->isInstanceOf(reloTarget) ? "true" : "false");
1825
}
1826
}
1827
break;
1828
1829
case TR_ValidateSystemClassByName:
1830
{
1831
TR_RelocationRecordValidateSystemClassByName *scmRecord = reinterpret_cast<TR_RelocationRecordValidateSystemClassByName *>(reloRecord);
1832
1833
self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);
1834
if (isVerbose)
1835
{
1836
traceMsg(self()->comp(), "\n Validate System Class By Name: systemClassID=%d classChainOffsetInSCC=%p ",
1837
(uint32_t)scmRecord->systemClassID(reloTarget),
1838
(void *)scmRecord->classChainOffset(reloTarget));
1839
}
1840
}
1841
break;
1842
1843
case TR_ValidateClassChain:
1844
{
1845
TR_RelocationRecordValidateClassChain *ccRecord = reinterpret_cast<TR_RelocationRecordValidateClassChain *>(reloRecord);
1846
1847
self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);
1848
if (isVerbose)
1849
{
1850
traceMsg(self()->comp(), "\n Validate Class Chain: classID=%d classChainOffsetInSCC=%p ",
1851
(uint32_t)ccRecord->classID(reloTarget),
1852
(void *)ccRecord->classChainOffset(reloTarget));
1853
}
1854
}
1855
break;
1856
1857
case TR_ValidateMethodFromClass:
1858
{
1859
TR_RelocationRecordValidateMethodFromClass *mfcRecord = reinterpret_cast<TR_RelocationRecordValidateMethodFromClass *>(reloRecord);
1860
1861
self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);
1862
if (isVerbose)
1863
{
1864
traceMsg(self()->comp(), "\n Validate Method By Name: methodID=%d, beholderID=%d, index=%d ",
1865
(uint32_t)mfcRecord->methodID(reloTarget),
1866
(uint32_t)mfcRecord->beholderID(reloTarget),
1867
mfcRecord->index(reloTarget));
1868
}
1869
}
1870
break;
1871
1872
case TR_ValidateStaticMethodFromCP:
1873
case TR_ValidateSpecialMethodFromCP:
1874
case TR_ValidateVirtualMethodFromCP:
1875
case TR_ValidateImproperInterfaceMethodFromCP:
1876
{
1877
TR_RelocationRecordValidateMethodFromCP *mfcpRecord = reinterpret_cast<TR_RelocationRecordValidateMethodFromCP *>(reloRecord);
1878
1879
self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);
1880
if (isVerbose)
1881
{
1882
const char *recordType;
1883
if (kind == TR_ValidateStaticMethodFromCP)
1884
recordType = "Static";
1885
else if (kind == TR_ValidateSpecialMethodFromCP)
1886
recordType = "Special";
1887
else if (kind == TR_ValidateVirtualMethodFromCP)
1888
recordType = "Virtual";
1889
else if (kind == TR_ValidateImproperInterfaceMethodFromCP)
1890
recordType = "Improper Interface";
1891
else
1892
TR_ASSERT_FATAL(false, "Unknown relokind %d!\n", kind);
1893
1894
traceMsg(self()->comp(), "\n Validate %s Method From CP: methodID=%d, definingClassID=%d, beholderID=%d, cpIndex=%d ",
1895
recordType,
1896
(uint32_t)mfcpRecord->methodID(reloTarget),
1897
(uint32_t)mfcpRecord->definingClassID(reloTarget),
1898
(uint32_t)mfcpRecord->beholderID(reloTarget),
1899
(uint32_t)mfcpRecord->cpIndex(reloTarget));
1900
}
1901
}
1902
break;
1903
1904
case TR_ValidateVirtualMethodFromOffset:
1905
{
1906
TR_RelocationRecordValidateVirtualMethodFromOffset *vmfoRecord = reinterpret_cast<TR_RelocationRecordValidateVirtualMethodFromOffset *>(reloRecord);
1907
1908
self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);
1909
if (isVerbose)
1910
{
1911
traceMsg(self()->comp(), "\n Validate Virtual Method From Offset: methodID=%d, definingClassID=%d, beholderID=%d, virtualCallOffset=%d, ignoreRtResolve=%s ",
1912
(uint32_t)vmfoRecord->methodID(reloTarget),
1913
(uint32_t)vmfoRecord->definingClassID(reloTarget),
1914
(uint32_t)vmfoRecord->beholderID(reloTarget),
1915
(uint32_t)(vmfoRecord->virtualCallOffsetAndIgnoreRtResolve(reloTarget) & ~1),
1916
(vmfoRecord->virtualCallOffsetAndIgnoreRtResolve(reloTarget) & 1) ? "true" : "false");
1917
}
1918
}
1919
break;
1920
1921
case TR_ValidateInterfaceMethodFromCP:
1922
{
1923
TR_RelocationRecordValidateInterfaceMethodFromCP *imfcpRecord = reinterpret_cast<TR_RelocationRecordValidateInterfaceMethodFromCP *>(reloRecord);
1924
1925
self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);
1926
if (isVerbose)
1927
{
1928
traceMsg(self()->comp(), "\n Validate Interface Method From CP: methodID=%d, definingClassID=%d, beholderID=%d, lookupID=%d, cpIndex=%d ",
1929
(uint32_t)imfcpRecord->methodID(reloTarget),
1930
(uint32_t)imfcpRecord->definingClassID(reloTarget),
1931
(uint32_t)imfcpRecord->beholderID(reloTarget),
1932
(uint32_t)imfcpRecord->lookupID(reloTarget),
1933
(uint32_t)imfcpRecord->cpIndex(reloTarget));
1934
}
1935
}
1936
break;
1937
1938
case TR_ValidateMethodFromClassAndSig:
1939
{
1940
TR_RelocationRecordValidateMethodFromClassAndSig *mfcsRecord = reinterpret_cast<TR_RelocationRecordValidateMethodFromClassAndSig *>(reloRecord);
1941
1942
self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);
1943
if (isVerbose)
1944
{
1945
traceMsg(self()->comp(), "\n Validate Method From Class and Sig: methodID=%d, definingClassID=%d, lookupClassID=%d, beholderID=%d, romMethodOffsetInSCC=%p ",
1946
(uint32_t)mfcsRecord->methodID(reloTarget),
1947
(uint32_t)mfcsRecord->definingClassID(reloTarget),
1948
(uint32_t)mfcsRecord->lookupClassID(reloTarget),
1949
(uint32_t)mfcsRecord->beholderID(reloTarget),
1950
(void *)mfcsRecord->romMethodOffsetInSCC(reloTarget));
1951
}
1952
}
1953
break;
1954
1955
case TR_ValidateStackWalkerMaySkipFramesRecord:
1956
{
1957
TR_RelocationRecordValidateStackWalkerMaySkipFrames *swmsfRecord = reinterpret_cast<TR_RelocationRecordValidateStackWalkerMaySkipFrames *>(reloRecord);
1958
1959
self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);
1960
if (isVerbose)
1961
{
1962
traceMsg(self()->comp(), "\n Validate Stack Walker May Skip Frames: methodID=%d, methodClassID=%d, skipFrames=%s ",
1963
(uint32_t)swmsfRecord->methodID(reloTarget),
1964
(uint32_t)swmsfRecord->methodClassID(reloTarget),
1965
swmsfRecord->skipFrames(reloTarget) ? "true" : "false");
1966
}
1967
}
1968
break;
1969
1970
case TR_ValidateClassInfoIsInitialized:
1971
{
1972
TR_RelocationRecordValidateClassInfoIsInitialized *ciiiRecord = reinterpret_cast<TR_RelocationRecordValidateClassInfoIsInitialized *>(reloRecord);
1973
1974
self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);
1975
if (isVerbose)
1976
{
1977
traceMsg(self()->comp(), "\n Validate Class Info Is Initialized: classID=%d, isInitialized=%s ",
1978
(uint32_t)ciiiRecord->classID(reloTarget),
1979
ciiiRecord->isInitialized(reloTarget) ? "true" : "false");
1980
}
1981
}
1982
break;
1983
1984
case TR_ValidateMethodFromSingleImplementer:
1985
{
1986
TR_RelocationRecordValidateMethodFromSingleImpl *mfsiRecord = reinterpret_cast<TR_RelocationRecordValidateMethodFromSingleImpl *>(reloRecord);
1987
1988
self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);
1989
if (isVerbose)
1990
{
1991
traceMsg(self()->comp(), "\n Validate Method From Single Implementor: methodID=%d, definingClassID=%d, thisClassID=%d, cpIndexOrVftSlot=%d, callerMethodID=%d, useGetResolvedInterfaceMethod=%d ",
1992
(uint32_t)mfsiRecord->methodID(reloTarget),
1993
(uint32_t)mfsiRecord->definingClassID(reloTarget),
1994
(uint32_t)mfsiRecord->thisClassID(reloTarget),
1995
(uint32_t)mfsiRecord->cpIndexOrVftSlot(reloTarget),
1996
(uint32_t)mfsiRecord->callerMethodID(reloTarget),
1997
(uint32_t)mfsiRecord->useGetResolvedInterfaceMethod(reloTarget));
1998
}
1999
}
2000
break;
2001
2002
case TR_ValidateMethodFromSingleInterfaceImplementer:
2003
{
2004
TR_RelocationRecordValidateMethodFromSingleInterfaceImpl *mfsiiRecord = reinterpret_cast<TR_RelocationRecordValidateMethodFromSingleInterfaceImpl *>(reloRecord);
2005
2006
self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);
2007
if (isVerbose)
2008
{
2009
traceMsg(self()->comp(), "\n Validate Method From Single Interface Implementor: methodID=%u, definingClassID=%u, thisClassID=%u, cpIndex=%u, callerMethodID=%u ",
2010
(uint32_t)mfsiiRecord->methodID(reloTarget),
2011
(uint32_t)mfsiiRecord->definingClassID(reloTarget),
2012
(uint32_t)mfsiiRecord->thisClassID(reloTarget),
2013
mfsiiRecord->cpIndex(reloTarget),
2014
(uint32_t)mfsiiRecord->callerMethodID(reloTarget));
2015
}
2016
}
2017
break;
2018
2019
case TR_ValidateMethodFromSingleAbstractImplementer:
2020
{
2021
TR_RelocationRecordValidateMethodFromSingleAbstractImpl *mfsaiRecord = reinterpret_cast<TR_RelocationRecordValidateMethodFromSingleAbstractImpl *>(reloRecord);
2022
2023
self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);
2024
if (isVerbose)
2025
{
2026
traceMsg(self()->comp(), "\n Validate Method From Single Abstract Implementor: methodID=%d, definingClassID=%d, thisClassID=%d, vftSlot=%d, callerMethodID=%d ",
2027
(uint32_t)mfsaiRecord->methodID(reloTarget),
2028
(uint32_t)mfsaiRecord->definingClassID(reloTarget),
2029
(uint32_t)mfsaiRecord->thisClassID(reloTarget),
2030
mfsaiRecord->vftSlot(reloTarget),
2031
(uint32_t)mfsaiRecord->callerMethodID(reloTarget));
2032
}
2033
}
2034
break;
2035
2036
case TR_SymbolFromManager:
2037
case TR_DiscontiguousSymbolFromManager:
2038
{
2039
TR_RelocationRecordSymbolFromManager *sfmRecord = reinterpret_cast<TR_RelocationRecordSymbolFromManager *>(reloRecord);
2040
2041
self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);
2042
if (isVerbose)
2043
{
2044
traceMsg(self()->comp(), "\n %sSymbol From Manager: symbolID=%d symbolType=%d flags=%x",
2045
kind == TR_DiscontiguousSymbolFromManager ? "Discontiguous " : "",
2046
(uint32_t)sfmRecord->symbolID(reloTarget),
2047
(uint32_t)sfmRecord->symbolType(reloTarget),
2048
(uint32_t)sfmRecord->reloFlags(reloTarget));
2049
}
2050
}
2051
break;
2052
2053
case TR_ResolvedTrampolines:
2054
{
2055
TR_RelocationRecordResolvedTrampolines *rtRecord = reinterpret_cast<TR_RelocationRecordResolvedTrampolines *>(reloRecord);
2056
2057
self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);
2058
if (isVerbose)
2059
{
2060
traceMsg(self()->comp(), "\n Resolved Trampoline: symbolID=%u ",
2061
(uint32_t)rtRecord->symbolID(reloTarget));
2062
}
2063
}
2064
break;
2065
2066
case TR_DataAddress:
2067
{
2068
TR_RelocationRecordDataAddress *daRecord = reinterpret_cast<TR_RelocationRecordDataAddress *>(reloRecord);
2069
2070
self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);
2071
if (isVerbose)
2072
{
2073
traceMsg(self()->comp(), "\nTR_DataAddress: InlinedCallSite index = %d, Constant pool = %x, cpIndex = %d, offset = %x, flags = %x",
2074
daRecord->inlinedSiteIndex(reloTarget),
2075
daRecord->constantPool(reloTarget),
2076
daRecord->cpIndex(reloTarget),
2077
daRecord->offset(reloTarget),
2078
(uint32_t)daRecord->reloFlags(reloTarget));
2079
}
2080
}
2081
break;
2082
2083
case TR_FixedSequenceAddress:
2084
case TR_FixedSequenceAddress2:
2085
case TR_RamMethodSequence:
2086
case TR_GlobalValue:
2087
case TR_HCR:
2088
{
2089
TR_RelocationRecordWithOffset *rwoRecord = reinterpret_cast<TR_RelocationRecordWithOffset *>(reloRecord);
2090
2091
self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);
2092
if (isVerbose)
2093
{
2094
const char *recordType;
2095
if (kind == TR_FixedSequenceAddress)
2096
recordType = "Fixed Sequence Relo";
2097
else if (kind == TR_FixedSequenceAddress2)
2098
recordType = "Load Address Relo";
2099
else if (kind == TR_RamMethodSequence)
2100
recordType = "Ram Method Sequence Relo";
2101
else if (kind == TR_GlobalValue)
2102
recordType = "Global Value";
2103
else if (kind == TR_HCR)
2104
recordType = "HCR";
2105
else
2106
TR_ASSERT_FATAL(false, "Unknown relokind %d!\n", kind);
2107
2108
traceMsg(self()->comp(),"%s: patch location offset = %p", recordType, (void *)rwoRecord->offset(reloTarget));
2109
}
2110
}
2111
break;
2112
2113
case TR_EmitClass:
2114
{
2115
TR_RelocationRecordEmitClass *ecRecord = reinterpret_cast<TR_RelocationRecordEmitClass *>(reloRecord);
2116
2117
self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);
2118
if (isVerbose)
2119
{
2120
traceMsg(self()->comp(), "\nTR_EmitClass: InlinedCallSite index = %d, bcIndex = %d",
2121
ecRecord->inlinedSiteIndex(reloTarget),
2122
ecRecord->bcIndex(reloTarget));
2123
}
2124
}
2125
break;
2126
2127
case TR_PicTrampolines:
2128
{
2129
TR_RelocationRecordPicTrampolines *ptRecord = reinterpret_cast<TR_RelocationRecordPicTrampolines *>(reloRecord);
2130
2131
self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);
2132
if (isVerbose)
2133
{
2134
traceMsg(self()->comp(), "\nTR_PicTrampolines: num trampolines = %d", ptRecord->numTrampolines(reloTarget));
2135
}
2136
}
2137
break;
2138
2139
case TR_DebugCounter:
2140
{
2141
TR_RelocationRecordDebugCounter *dcRecord = reinterpret_cast<TR_RelocationRecordDebugCounter *>(reloRecord);
2142
2143
self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);
2144
if (isVerbose)
2145
{
2146
traceMsg(self()->comp(), "\n Debug Counter: Inlined site index = %d, bcIndex = %d, delta = %d, fidelity = %d, staticDelta = %d, offsetOfNameString = %p",
2147
dcRecord->inlinedSiteIndex(reloTarget),
2148
dcRecord->bcIndex(reloTarget),
2149
dcRecord->delta(reloTarget),
2150
dcRecord->fidelity(reloTarget),
2151
dcRecord->staticDelta(reloTarget),
2152
(void *)dcRecord->offsetOfNameString(reloTarget));
2153
}
2154
}
2155
break;
2156
2157
case TR_BlockFrequency:
2158
{
2159
TR_RelocationRecordBlockFrequency *bfRecord = reinterpret_cast<TR_RelocationRecordBlockFrequency *>(reloRecord);
2160
2161
self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);
2162
if (isVerbose)
2163
{
2164
traceMsg(self()->comp(), "\n Frequency offset %lld", bfRecord->frequencyOffset(reloTarget));
2165
}
2166
}
2167
break;
2168
2169
case TR_Breakpoint:
2170
{
2171
TR_RelocationRecordBreakpointGuard *bpgRecord = reinterpret_cast<TR_RelocationRecordBreakpointGuard *>(reloRecord);
2172
2173
self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);
2174
if (isVerbose)
2175
{
2176
traceMsg(self()->comp(), "\n Breakpoint Guard: Inlined site index = %d, destinationAddress = %p",
2177
bpgRecord->inlinedSiteIndex(reloTarget),
2178
bpgRecord->destinationAddress(reloTarget));
2179
}
2180
}
2181
break;
2182
2183
case TR_ValidateJ2IThunkFromMethod:
2184
{
2185
auto *thunkRecord = reinterpret_cast<TR_RelocationRecordValidateJ2IThunkFromMethod *>(reloRecord);
2186
2187
self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);
2188
if (isVerbose)
2189
{
2190
traceMsg(
2191
self()->comp(),
2192
"\n Validate J2I Thunk From Method: thunkID=%d, methodID=%d",
2193
thunkRecord->thunkID(reloTarget),
2194
thunkRecord->methodID(reloTarget));
2195
}
2196
}
2197
break;
2198
2199
default:
2200
return cursor;
2201
}
2202
2203
traceMsg(self()->comp(), "\n");
2204
2205
return endOfCurrentRecord;
2206
}
2207
2208
void
2209
J9::AheadOfTimeCompile::dumpRelocationData()
2210
{
2211
// Don't trace unless traceRelocatableDataCG or traceRelocatableDataDetailsCG
2212
if (!self()->comp()->getOption(TR_TraceRelocatableDataCG) && !self()->comp()->getOption(TR_TraceRelocatableDataDetailsCG))
2213
{
2214
return;
2215
}
2216
2217
bool isVerbose = self()->comp()->getOption(TR_TraceRelocatableDataDetailsCG);
2218
2219
uint8_t *cursor = self()->getRelocationData();
2220
2221
if (!cursor)
2222
{
2223
traceMsg(self()->comp(), "No relocation data allocated\n");
2224
return;
2225
}
2226
2227
// Output the method
2228
traceMsg(self()->comp(), "%s\n", self()->comp()->signature());
2229
2230
if (self()->comp()->getOption(TR_TraceRelocatableDataCG))
2231
{
2232
traceMsg(self()->comp(), "\n\nRelocation Record Generation Info\n");
2233
traceMsg(self()->comp(), "%-35s %-32s %-5s %-9s %-10s %-8s\n", "Type", "File", "Line","Offset(M)","Offset(PC)", "Node");
2234
2235
TR::list<TR::Relocation*>& aotRelocations = self()->comp()->cg()->getExternalRelocationList();
2236
//iterate over aotRelocations
2237
if (!aotRelocations.empty())
2238
{
2239
for (auto relocation = aotRelocations.begin(); relocation != aotRelocations.end(); ++relocation)
2240
{
2241
if (*relocation)
2242
{
2243
(*relocation)->trace(self()->comp());
2244
}
2245
}
2246
}
2247
if (!self()->comp()->getOption(TR_TraceRelocatableDataCG) && !self()->comp()->getOption(TR_TraceRelocatableDataDetailsCG))
2248
{
2249
return;//otherwise continue with the other options
2250
}
2251
}
2252
2253
if (isVerbose)
2254
{
2255
traceMsg(self()->comp(), "Size of relocation data in AOT object is %d bytes\n", self()->getSizeOfAOTRelocations());
2256
}
2257
2258
uint8_t *endOfData;
2259
if (self()->comp()->target().is64Bit())
2260
{
2261
endOfData = cursor + *(uint64_t *)cursor;
2262
traceMsg(self()->comp(), "Size field in relocation data is %d bytes\n\n", *(uint64_t *)cursor);
2263
cursor += 8;
2264
}
2265
else
2266
{
2267
endOfData = cursor + *(uint32_t *)cursor;
2268
traceMsg(self()->comp(), "Size field in relocation data is %d bytes\n\n", *(uint32_t *)cursor);
2269
cursor += 4;
2270
}
2271
2272
if (self()->comp()->getOption(TR_UseSymbolValidationManager))
2273
{
2274
traceMsg(
2275
self()->comp(),
2276
"SCC offset of class chain offsets of well-known classes is: 0x%llx\n\n",
2277
(unsigned long long)*(uintptr_t *)cursor);
2278
cursor += sizeof (uintptr_t);
2279
}
2280
2281
traceMsg(self()->comp(), "Address Size %-31s", "Type");
2282
traceMsg(self()->comp(), "Width EIP Index Offsets\n"); // Offsets from Code Start
2283
2284
while (cursor < endOfData)
2285
{
2286
cursor = self()->dumpRelocationHeaderData(cursor, isVerbose);
2287
}
2288
}
2289
2290
void J9::AheadOfTimeCompile::interceptAOTRelocation(TR::ExternalRelocation *relocation)
2291
{
2292
OMR::AheadOfTimeCompile::interceptAOTRelocation(relocation);
2293
2294
TR_ExternalRelocationTargetKind kind = relocation->getTargetKind();
2295
2296
if (kind == TR_ClassAddress)
2297
{
2298
TR::SymbolReference *symRef = NULL;
2299
void *p = relocation->getTargetAddress();
2300
if (TR::AheadOfTimeCompile::classAddressUsesReloRecordInfo())
2301
symRef = (TR::SymbolReference*)((TR_RelocationRecordInformation*)p)->data1;
2302
else
2303
symRef = (TR::SymbolReference*)p;
2304
2305
if (symRef->getCPIndex() == -1)
2306
relocation->setTargetKind(TR_ArbitraryClassAddress);
2307
}
2308
else if (kind == TR_MethodPointer)
2309
{
2310
TR::Node *aconstNode = reinterpret_cast<TR::Node *>(relocation->getTargetAddress());
2311
2312
TR_OpaqueMethodBlock *j9method = reinterpret_cast<TR_OpaqueMethodBlock *>(aconstNode->getAddress());
2313
if (aconstNode->getOpCodeValue() == TR::loadaddr)
2314
{
2315
j9method =
2316
reinterpret_cast<TR_OpaqueMethodBlock *>(
2317
aconstNode->getSymbolReference()->getSymbol()->castToStaticSymbol()->getStaticAddress());
2318
}
2319
2320
uintptr_t inlinedSiteIndex = static_cast<uintptr_t>(aconstNode->getInlinedSiteIndex());
2321
TR_ResolvedMethod *inlinedMethod = TR::comp()->getInlinedResolvedMethod(inlinedSiteIndex);
2322
TR_OpaqueMethodBlock *inlinedJ9Method = inlinedMethod->getPersistentIdentifier();
2323
2324
/* If the j9method from the aconst node is the same as the j9method at
2325
* inlined call site at inlinedSiteIndex, switch the relo kind to
2326
* TR_InlinedMethodPointer; at relo time, the inlined site index is
2327
* sufficient to materialize the j9method pointer
2328
*/
2329
if (inlinedJ9Method == j9method)
2330
{
2331
relocation->setTargetKind(TR_InlinedMethodPointer);
2332
relocation->setTargetAddress(reinterpret_cast<uint8_t *>(inlinedSiteIndex));
2333
}
2334
}
2335
}
2336
2337