-
Notifications
You must be signed in to change notification settings - Fork 747
/
Copy pathJ9AheadOfTimeCompile.cpp
2656 lines (2223 loc) · 126 KB
/
J9AheadOfTimeCompile.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*******************************************************************************
* Copyright IBM Corp. and others 2000
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/
* or the Apache License, Version 2.0 which accompanies this distribution and
* is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* This Source Code may also be made available under the following
* Secondary Licenses when the conditions for such availability set
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
* General Public License, version 2 with the GNU Classpath
* Exception [1] and GNU General Public License, version 2 with the
* OpenJDK Assembly Exception [2].
*
* [1] https://www.gnu.org/software/classpath/license.html
* [2] https://openjdk.org/legal/assembly-exception.html
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 OR GPL-2.0-only WITH OpenJDK-assembly-exception-1.0
*******************************************************************************/
#include "codegen/CodeGenerator.hpp"
#include "codegen/Instruction.hpp"
#include "env/SharedCache.hpp"
#include "env/jittypes.h"
#include "env/ClassLoaderTable.hpp"
#include "exceptions/PersistenceFailure.hpp"
#include "il/DataTypes.hpp"
#include "il/Node.hpp"
#include "il/Node_inlines.hpp"
#include "il/SymbolReference.hpp"
#include "il/StaticSymbol.hpp"
#include "env/VerboseLog.hpp"
#include "env/VMJ9.h"
#include "codegen/AheadOfTimeCompile.hpp"
#include "runtime/RelocationRuntime.hpp"
#include "runtime/RelocationRecord.hpp"
#include "runtime/SymbolValidationManager.hpp"
#if defined(J9VM_OPT_JITSERVER)
#include "runtime/JITClientSession.hpp"
#endif /* defined(J9VM_OPT_JITSERVER) */
extern bool isOrderedPair(uint8_t reloType);
uintptr_t
J9::AheadOfTimeCompile::getClassChainOffset(TR_OpaqueClassBlock *classToRemember,
const AOTCacheClassChainRecord *&classChainRecord)
{
TR_J9VMBase *fej9 = (TR_J9VMBase *)self()->comp()->fe();
TR_SharedCache *sharedCache = fej9->sharedCache();
uintptr_t classChainOffset = sharedCache->rememberClass(classToRemember, &classChainRecord);
if (TR_SharedCache::INVALID_CLASS_CHAIN_OFFSET == classChainOffset)
self()->comp()->failCompilation<J9::ClassChainPersistenceFailure>("classChainOffset == INVALID_CLASS_CHAIN_OFFSET");
return classChainOffset;
}
#if defined(J9VM_OPT_JITSERVER)
void
J9::AheadOfTimeCompile::addClassSerializationRecord(const AOTCacheClassChainRecord *classChainRecord,
const uintptr_t *romClassOffsetAddr)
{
const AOTCacheClassRecord *record = classChainRecord ? classChainRecord->rootClassRecord() : NULL;
self()->addSerializationRecord(record, romClassOffsetAddr);
}
void
J9::AheadOfTimeCompile::addClassSerializationRecord(TR_OpaqueClassBlock *ramClass, const uintptr_t *romClassOffsetAddr)
{
TR::Compilation *comp = self()->comp();
if (comp->isAOTCacheStore())
{
bool missingLoaderInfo = false;
const AOTCacheClassRecord *record = comp->getClientData()->getClassRecord((J9Class *)ramClass, comp->getStream(), missingLoaderInfo);
self()->addSerializationRecord(record, romClassOffsetAddr);
}
}
void
J9::AheadOfTimeCompile::addMethodSerializationRecord(J9Method *method, TR_OpaqueClassBlock *definingClass,
const uintptr_t *romMethodOffsetAddr)
{
TR::Compilation *comp = self()->comp();
if (comp->isAOTCacheStore())
{
const AOTCacheMethodRecord *record = comp->getClientData()->getMethodRecord(method, (J9Class *)definingClass,
comp->getStream());
self()->addSerializationRecord(record, romMethodOffsetAddr);
}
}
void
J9::AheadOfTimeCompile::addClassChainSerializationRecord(const AOTCacheClassChainRecord *classChainRecord,
const uintptr_t *classChainOffsetAddr)
{
self()->addSerializationRecord(classChainRecord, classChainOffsetAddr);
}
void
J9::AheadOfTimeCompile::addClassLoaderSerializationRecord(const AOTCacheClassChainRecord *classChainRecord,
const uintptr_t *loaderChainOffsetAddr)
{
const AOTCacheClassLoaderRecord *record = classChainRecord ? classChainRecord->rootClassLoaderRecord() : NULL;
self()->addSerializationRecord(record, loaderChainOffsetAddr);
}
void
J9::AheadOfTimeCompile::addWellKnownClassesSerializationRecord(const AOTCacheWellKnownClassesRecord *wkcRecord,
const uintptr_t *wkcOffsetAddr)
{
self()->addSerializationRecord(wkcRecord, wkcOffsetAddr);
}
void
J9::AheadOfTimeCompile::addSerializationRecord(const AOTCacheRecord *record, const uintptr_t *sccOffsetAddr)
{
TR::Compilation *comp = self()->comp();
if (comp->isAOTCacheStore())
{
uint8_t *start = self()->getRelocationData();
uint8_t *end = start + *(uintptr_t *)start;// Total size of relocation data is stored in the first word
TR_ASSERT_FATAL(((uint8_t *)sccOffsetAddr >= start + sizeof(uintptr_t)) && ((uint8_t *)sccOffsetAddr < end),
"SCC offset address %p not in range %p - %p", sccOffsetAddr, start + sizeof(uintptr_t), end);
#if defined(DEBUG)
if (record && TR::Options::getVerboseOption(TR_VerboseJITServer))
{
const AOTSerializationRecord *r = record->dataAddr();
TR_VerboseLog::writeLineLocked(TR_Vlog_JITServer,
"AOT cache %s: Adding record type %u ID %zu for SCC offset %zu at relo data offset %zu in method %s",
comp->getClientData()->getAOTCache()->name().c_str(), r->type(), r->id(),
*sccOffsetAddr, (uint8_t *)sccOffsetAddr - start, comp->signature()
);
}
#endif /* defined(DEBUG) */
comp->addSerializationRecord(record, (uint8_t *)sccOffsetAddr - start);
}
}
#endif /* defined(J9VM_OPT_JITSERVER) */
uintptr_t
J9::AheadOfTimeCompile::offsetInSharedCacheFromPointer(TR_SharedCache *sharedCache, void *ptr)
{
uintptr_t offset = 0;
if (sharedCache->isPointerInSharedCache(ptr, &offset))
return offset;
else
self()->comp()->failCompilation<J9::ClassChainPersistenceFailure>("Failed to find pointer %p in SCC", ptr);
return offset;
}
uintptr_t
J9::AheadOfTimeCompile::offsetInSharedCacheFromWellKnownClasses(TR_SharedCache *sharedCache, void *wellKnownClassesPtr)
{
#if defined(J9VM_OPT_JITSERVER)
TR::Compilation *comp = self()->comp();
ClientSessionData *clientData = comp->getClientData();
// This is a server compilation that is ignoring the client's SCC, so just return the
// idAndType of the cached AOT cache well-known classes serialization record.
if (clientData && clientData->useServerOffsets(comp->getStream()) && comp->isAOTCacheStore())
{
auto record = comp->getSymbolValidationManager()->aotCacheWellKnownClassesRecord();
if (record)
return record->data().idAndType();
else
comp->failCompilation<J9::ClassChainPersistenceFailure>("Failed to find cached well-known classes record in SVM");
}
#endif /* defined(J9VM_OPT_JITSERVER) */
return offsetInSharedCacheFromPointer(sharedCache, wellKnownClassesPtr);
}
uintptr_t
J9::AheadOfTimeCompile::offsetInSharedCacheFromClass(TR_SharedCache *sharedCache, TR_OpaqueClassBlock *clazz)
{
uintptr_t offset = 0;
if (sharedCache->isClassInSharedCache(clazz, &offset))
return offset;
else
self()->comp()->failCompilation<J9::ClassChainPersistenceFailure>("Failed to find clazz %p in SCC", clazz);
return offset;
}
uintptr_t
J9::AheadOfTimeCompile::offsetInSharedCacheFromMethod(TR_SharedCache *sharedCache, TR_OpaqueMethodBlock *method, TR_OpaqueClassBlock *definingClass)
{
uintptr_t offset = TR_SharedCache::INVALID_ROM_METHOD_OFFSET;
if (sharedCache->isMethodInSharedCache(method, definingClass, &offset))
return offset;
else
self()->comp()->failCompilation<J9::ClassChainPersistenceFailure>("Failed to find method %p in SCC", method);
return offset;
}
uintptr_t
J9::AheadOfTimeCompile::findCorrectInlinedSiteIndex(void *constantPool, uintptr_t currentInlinedSiteIndex)
{
TR::Compilation *comp = self()->comp();
uintptr_t constantPoolForSiteIndex = 0;
uintptr_t inlinedSiteIndex = currentInlinedSiteIndex;
if (inlinedSiteIndex == (uintptr_t)-1)
{
constantPoolForSiteIndex = (uintptr_t)comp->getCurrentMethod()->constantPool();
}
else
{
constantPoolForSiteIndex = (uintptr_t)comp->getInlinedResolvedMethod(inlinedSiteIndex)->constantPool();
}
bool matchFound = false;
if ((uintptr_t)constantPool == constantPoolForSiteIndex)
{
// The constant pool and site index match, no need to find anything.
matchFound = true;
}
else
{
if ((uintptr_t)constantPool == (uintptr_t)comp->getCurrentMethod()->constantPool())
{
// The constant pool belongs to the current method being compiled, the correct site index is -1.
matchFound = true;
inlinedSiteIndex = (uintptr_t)-1;
}
else
{
// Look for the first call site whose inlined method's constant pool matches ours and return that site index as the correct one.
for (uintptr_t i = 0; i < comp->getNumInlinedCallSites(); i++)
{
if ((uintptr_t)constantPool == (uintptr_t)comp->getInlinedResolvedMethod(i)->constantPool())
{
matchFound = true;
inlinedSiteIndex = i;
break;
}
}
}
}
if (!matchFound)
self()->comp()->failCompilation<J9::AOTRelocationRecordGenerationFailure>("AOT header initialization can't find CP in inlined site list");
return inlinedSiteIndex;
}
static const char* getNameForMethodRelocation (int type)
{
switch ( type )
{
case TR_JNISpecialTargetAddress:
return "TR_JNISpecialTargetAddress";
case TR_JNIVirtualTargetAddress:
return "TR_JNIVirtualTargetAddress";
case TR_JNIStaticTargetAddress:
return "TR_JNIStaticTargetAddress";
case TR_StaticRamMethodConst:
return "TR_StaticRamMethodConst";
case TR_SpecialRamMethodConst:
return "TR_SpecialRamMethodConst";
case TR_VirtualRamMethodConst:
return "TR_VirtualRamMethodConst";
case TR_ClassAddress:
return "TR_ClassAddress";
case TR_StaticDefaultValueInstance:
return "TR_StaticDefaultValueInstance";
default:
TR_ASSERT(0, "We already cleared one switch, hard to imagine why we would have a different type here");
break;
}
return NULL;
}
uint8_t *
J9::AheadOfTimeCompile::initializeAOTRelocationHeader(TR::IteratedExternalRelocation *relocation)
{
TR::Compilation *comp = self()->comp();
TR_RelocationRuntime *reloRuntime = comp->reloRuntime();
TR_RelocationTarget *reloTarget = reloRuntime->reloTarget();
uint8_t *cursor = relocation->getRelocationData();
uint8_t targetKind = relocation->getTargetKind();
uint16_t sizeOfReloData = relocation->getSizeOfRelocationData();
// Zero-initialize header
memset(cursor, 0, sizeOfReloData);
TR_RelocationRecord storage;
TR_RelocationRecord *reloRecord = TR_RelocationRecord::create(&storage, reloRuntime, targetKind, reinterpret_cast<TR_RelocationRecordBinaryTemplate *>(cursor));
reloRecord->setType(reloTarget, static_cast<TR_RelocationRecordType>(targetKind));
reloRecord->setSize(reloTarget, sizeOfReloData);
if (relocation->needsWideOffsets())
reloRecord->setWideOffsets(reloTarget);
if (!self()->initializePlatformSpecificAOTRelocationHeader(relocation, reloTarget, reloRecord, targetKind))
self()->initializeCommonAOTRelocationHeader(relocation, reloTarget, reloRecord, targetKind);
cursor += self()->getSizeOfAOTRelocationHeader(static_cast<TR_RelocationRecordType>(targetKind));
return cursor;
}
void
J9::AheadOfTimeCompile::initializeCommonAOTRelocationHeader(TR::IteratedExternalRelocation *relocation,
TR_RelocationTarget *reloTarget,
TR_RelocationRecord *reloRecord,
uint8_t kind)
{
TR::Compilation *comp = self()->comp();
TR::SymbolValidationManager *symValManager = comp->getSymbolValidationManager();
TR_J9VMBase *fej9 = comp->fej9();
TR_SharedCache *sharedCache = fej9->sharedCache();
uint8_t * aotMethodCodeStart = reinterpret_cast<uint8_t *>(comp->getRelocatableMethodCodeStart());
switch (kind)
{
case TR_ConstantPool:
case TR_Thunks:
case TR_Trampolines:
{
TR_RelocationRecordConstantPool * cpRecord = reinterpret_cast<TR_RelocationRecordConstantPool *>(reloRecord);
cpRecord->setConstantPool(reloTarget, reinterpret_cast<uintptr_t>(relocation->getTargetAddress()));
cpRecord->setInlinedSiteIndex(reloTarget, reinterpret_cast<uintptr_t>(relocation->getTargetAddress2()));
}
break;
case TR_HelperAddress:
{
TR_RelocationRecordHelperAddress *haRecord = reinterpret_cast<TR_RelocationRecordHelperAddress *>(reloRecord);
TR::SymbolReference *symRef = reinterpret_cast<TR::SymbolReference *>(relocation->getTargetAddress());
haRecord->setEipRelative(reloTarget);
haRecord->setHelperID(reloTarget, static_cast<uint32_t>(symRef->getReferenceNumber()));
}
break;
case TR_RelativeMethodAddress:
{
TR_RelocationRecordMethodAddress *rmaRecord = reinterpret_cast<TR_RelocationRecordMethodAddress *>(reloRecord);
rmaRecord->setEipRelative(reloTarget);
}
break;
case TR_AbsoluteMethodAddress:
case TR_BodyInfoAddress:
case TR_RamMethod:
case TR_ClassUnloadAssumption:
case TR_AbsoluteMethodAddressOrderedPair:
case TR_ArrayCopyHelper:
case TR_ArrayCopyToc:
case TR_BodyInfoAddressLoad:
case TR_RecompQueuedFlag:
case TR_CatchBlockCounter:
case TR_StartPC:
{
// Nothing to do
}
break;
case TR_MethodCallAddress:
{
TR_RelocationRecordMethodCallAddress *mcaRecord = reinterpret_cast<TR_RelocationRecordMethodCallAddress *>(reloRecord);
mcaRecord->setEipRelative(reloTarget);
mcaRecord->setAddress(reloTarget, relocation->getTargetAddress());
}
break;
case TR_AbsoluteHelperAddress:
{
TR_RelocationRecordAbsoluteHelperAddress *ahaRecord = reinterpret_cast<TR_RelocationRecordAbsoluteHelperAddress *>(reloRecord);
TR::SymbolReference *symRef = reinterpret_cast<TR::SymbolReference *>(relocation->getTargetAddress());
ahaRecord->setHelperID(reloTarget, static_cast<uint32_t>(symRef->getReferenceNumber()));
}
break;
case TR_JNIVirtualTargetAddress:
case TR_JNIStaticTargetAddress:
case TR_JNISpecialTargetAddress:
{
TR_RelocationRecordDirectJNICall *djnicRecord = reinterpret_cast<TR_RelocationRecordDirectJNICall *>(reloRecord);
TR_RelocationRecordInformation *recordInfo = reinterpret_cast<TR_RelocationRecordInformation*>(relocation->getTargetAddress());
uintptr_t offsetToReloLocation = recordInfo->data1;
TR_ASSERT_FATAL((offsetToReloLocation & ~0xFF) == 0,
"offsetToReloLocation %" OMR_PRIuPTR " cannot fit in a uint8_t",
offsetToReloLocation);
TR::SymbolReference *symRef = reinterpret_cast<TR::SymbolReference *>(recordInfo->data2);
uintptr_t inlinedSiteIndex = recordInfo->data3;
void *constantPool = symRef->getOwningMethod(comp)->constantPool();
inlinedSiteIndex = self()->findCorrectInlinedSiteIndex(constantPool, inlinedSiteIndex);
djnicRecord->setInlinedSiteIndex(reloTarget, inlinedSiteIndex);
djnicRecord->setConstantPool(reloTarget, reinterpret_cast<uintptr_t>(constantPool));
djnicRecord->setCpIndex(reloTarget, symRef->getCPIndex());
djnicRecord->setOffsetToReloLocation(reloTarget, static_cast<uint8_t>(offsetToReloLocation));
}
break;
case TR_StaticRamMethodConst:
case TR_SpecialRamMethodConst:
case TR_VirtualRamMethodConst:
case TR_StaticDefaultValueInstance:
case TR_ClassAddress:
{
TR_RelocationRecordConstantPoolWithIndex *cpiRecord = reinterpret_cast<TR_RelocationRecordConstantPoolWithIndex *>(reloRecord);
TR::SymbolReference *symRef = reinterpret_cast<TR::SymbolReference *>(relocation->getTargetAddress());
uintptr_t inlinedSiteIndex = reinterpret_cast<uintptr_t>(relocation->getTargetAddress2());
void *constantPool = symRef->getOwningMethod(comp)->constantPool();
inlinedSiteIndex = self()->findCorrectInlinedSiteIndex(constantPool, inlinedSiteIndex);
cpiRecord->setInlinedSiteIndex(reloTarget, inlinedSiteIndex);
cpiRecord->setConstantPool(reloTarget, reinterpret_cast<uintptr_t>(constantPool));
cpiRecord->setCpIndex(reloTarget, symRef->getCPIndex());
}
break;
case TR_CheckMethodEnter:
case TR_CheckMethodExit:
{
TR_RelocationRecordMethodTracingCheck *mtRecord = reinterpret_cast<TR_RelocationRecordMethodTracingCheck *>(reloRecord);
mtRecord->setDestinationAddress(reloTarget, reinterpret_cast<uintptr_t>(relocation->getTargetAddress()));
}
break;
case TR_VerifyClassObjectForAlloc:
{
TR_RelocationRecordVerifyClassObjectForAlloc *allocRecord = reinterpret_cast<TR_RelocationRecordVerifyClassObjectForAlloc *>(reloRecord);
TR::SymbolReference * classSymRef = reinterpret_cast<TR::SymbolReference *>(relocation->getTargetAddress());
TR_RelocationRecordInformation *recordInfo = reinterpret_cast<TR_RelocationRecordInformation*>(relocation->getTargetAddress2());
TR::LabelSymbol *label = reinterpret_cast<TR::LabelSymbol *>(recordInfo->data3);
TR::Instruction *instr = reinterpret_cast<TR::Instruction *>(recordInfo->data4);
uint32_t branchOffset = static_cast<uint32_t>(label->getCodeLocation() - instr->getBinaryEncoding());
allocRecord->setInlinedSiteIndex(reloTarget, static_cast<uintptr_t>(recordInfo->data2));
allocRecord->setConstantPool(reloTarget, reinterpret_cast<uintptr_t>(classSymRef->getOwningMethod(comp)->constantPool()));
allocRecord->setBranchOffset(reloTarget, static_cast<uintptr_t>(branchOffset));
allocRecord->setAllocationSize(reloTarget, static_cast<uintptr_t>(recordInfo->data1));
/* Temporary, will be cleaned up in a future PR */
if (comp->getOption(TR_UseSymbolValidationManager))
{
TR_OpaqueClassBlock *classOfMethod = reinterpret_cast<TR_OpaqueClassBlock *>(recordInfo->data5);
uint16_t classID = symValManager->getSymbolIDFromValue(static_cast<void *>(classOfMethod));
allocRecord->setCpIndex(reloTarget, static_cast<uintptr_t>(classID));
}
else
{
allocRecord->setCpIndex(reloTarget, static_cast<uintptr_t>(classSymRef->getCPIndex()));
}
}
break;
case TR_VerifyRefArrayForAlloc:
{
TR_RelocationRecordVerifyRefArrayForAlloc *allocRecord = reinterpret_cast<TR_RelocationRecordVerifyRefArrayForAlloc *>(reloRecord);
TR::SymbolReference * classSymRef = reinterpret_cast<TR::SymbolReference *>(relocation->getTargetAddress());
TR_RelocationRecordInformation *recordInfo = reinterpret_cast<TR_RelocationRecordInformation*>(relocation->getTargetAddress2());
TR::LabelSymbol *label = reinterpret_cast<TR::LabelSymbol *>(recordInfo->data3);
TR::Instruction *instr = reinterpret_cast<TR::Instruction *>(recordInfo->data4);
uint32_t branchOffset = static_cast<uint32_t>(label->getCodeLocation() - instr->getBinaryEncoding());
allocRecord->setInlinedSiteIndex(reloTarget, static_cast<uintptr_t>(recordInfo->data2));
allocRecord->setConstantPool(reloTarget, reinterpret_cast<uintptr_t>(classSymRef->getOwningMethod(comp)->constantPool()));
allocRecord->setBranchOffset(reloTarget, static_cast<uintptr_t>(branchOffset));
/* Temporary, will be cleaned up in a future PR */
if (comp->getOption(TR_UseSymbolValidationManager))
{
TR_OpaqueClassBlock *classOfMethod = reinterpret_cast<TR_OpaqueClassBlock *>(recordInfo->data5);
uint16_t classID = symValManager->getSymbolIDFromValue(static_cast<void *>(classOfMethod));
allocRecord->setCpIndex(reloTarget, static_cast<uintptr_t>(classID));
}
else
{
allocRecord->setCpIndex(reloTarget, static_cast<uintptr_t>(classSymRef->getCPIndex()));
}
}
break;
case TR_ValidateInstanceField:
{
TR_RelocationRecordValidateInstanceField *fieldRecord = reinterpret_cast<TR_RelocationRecordValidateInstanceField *>(reloRecord);
uintptr_t inlinedSiteIndex = reinterpret_cast<uintptr_t>(relocation->getTargetAddress());
TR::AOTClassInfo *aotCI = reinterpret_cast<TR::AOTClassInfo *>(relocation->getTargetAddress2());
fieldRecord->setInlinedSiteIndex(reloTarget, inlinedSiteIndex);
fieldRecord->setConstantPool(reloTarget, reinterpret_cast<uintptr_t>(aotCI->_constantPool));
fieldRecord->setCpIndex(reloTarget, static_cast<uintptr_t>(aotCI->_cpIndex));
fieldRecord->setClassChainOffsetInSharedCache(reloTarget, aotCI, self());
}
break;
case TR_InlinedStaticMethodWithNopGuard:
case TR_InlinedSpecialMethodWithNopGuard:
case TR_InlinedVirtualMethodWithNopGuard:
case TR_InlinedInterfaceMethodWithNopGuard:
case TR_InlinedAbstractMethodWithNopGuard:
case TR_InlinedInterfaceMethod:
case TR_InlinedVirtualMethod:
case TR_InlinedStaticMethod:
case TR_InlinedSpecialMethod:
case TR_InlinedAbstractMethod:
{
TR_RelocationRecordInlinedMethod *imRecord = reinterpret_cast<TR_RelocationRecordInlinedMethod *>(reloRecord);
TR_RelocationRecordInformation *info = reinterpret_cast<TR_RelocationRecordInformation *>(relocation->getTargetAddress());
int32_t inlinedSiteIndex = static_cast<int32_t>(info->data1);
TR::SymbolReference *callSymRef = reinterpret_cast<TR::SymbolReference *>(info->data2);
TR_OpaqueClassBlock *thisClass = reinterpret_cast<TR_OpaqueClassBlock *>(info->data3);
uintptr_t destinationAddress = info->data4;
uint8_t flags = 0;
TR_ResolvedMethod *resolvedMethod;
if (kind == TR_InlinedInterfaceMethodWithNopGuard ||
kind == TR_InlinedInterfaceMethod ||
kind == TR_InlinedAbstractMethodWithNopGuard ||
kind == TR_InlinedAbstractMethod)
{
resolvedMethod = comp->getInlinedResolvedMethod(inlinedSiteIndex);
}
else
{
resolvedMethod = callSymRef->getSymbol()->getResolvedMethodSymbol()->getResolvedMethod();
}
TR_OpaqueMethodBlock *method = resolvedMethod->getPersistentIdentifier();
// Ugly; this will be cleaned up in a future PR
uintptr_t cpIndexOrData = 0;
if (comp->getOption(TR_UseSymbolValidationManager))
{
uint16_t methodID = symValManager->getSymbolIDFromValue(static_cast<void *>(method));
uint16_t receiverClassID = symValManager->getSymbolIDFromValue(static_cast<void *>(thisClass));
cpIndexOrData = (((uintptr_t)receiverClassID << 16) | (uintptr_t)methodID);
}
else
{
cpIndexOrData = static_cast<uintptr_t>(callSymRef->getCPIndex());
}
// Setup flags field with type of method that needs to be validated at relocation time
if (callSymRef->getSymbol()->getMethodSymbol()->isStatic())
flags = inlinedMethodIsStatic;
else if (callSymRef->getSymbol()->getMethodSymbol()->isSpecial())
flags = inlinedMethodIsSpecial;
else if (callSymRef->getSymbol()->getMethodSymbol()->isVirtual())
flags = inlinedMethodIsVirtual;
if (fej9->isMethodTracingEnabled(reinterpret_cast<J9Method *>(method)))
flags |= methodTracingEnabled;
TR_OpaqueClassBlock *inlinedMethodClass = resolvedMethod->containingClass();
uintptr_t romClassOffsetInSharedCache = self()->offsetInSharedCacheFromClass(sharedCache, inlinedMethodClass);
imRecord->setReloFlags(reloTarget, flags);
imRecord->setInlinedSiteIndex(reloTarget, inlinedSiteIndex);
imRecord->setConstantPool(reloTarget, reinterpret_cast<uintptr_t>(callSymRef->getOwningMethod(comp)->constantPool()));
imRecord->setCpIndex(reloTarget, cpIndexOrData);
imRecord->setRomClassOffsetInSharedCache(reloTarget, romClassOffsetInSharedCache, self(), inlinedMethodClass);
if (kind != TR_InlinedInterfaceMethod
&& kind != TR_InlinedVirtualMethod
&& kind != TR_InlinedSpecialMethod
&& kind != TR_InlinedStaticMethod
&& kind != TR_InlinedAbstractMethod)
{
reinterpret_cast<TR_RelocationRecordNopGuard *>(imRecord)->setDestinationAddress(reloTarget, destinationAddress);
}
}
break;
case TR_ValidateStaticField:
{
TR_RelocationRecordValidateStaticField *vsfRecord = reinterpret_cast<TR_RelocationRecordValidateStaticField *>(reloRecord);
uintptr_t inlinedSiteIndex = reinterpret_cast<uintptr_t>(relocation->getTargetAddress());
TR::AOTClassInfo *aotCI = reinterpret_cast<TR::AOTClassInfo *>(relocation->getTargetAddress2());
uintptr_t romClassOffsetInSharedCache = self()->offsetInSharedCacheFromClass(sharedCache, aotCI->_clazz);
vsfRecord->setInlinedSiteIndex(reloTarget, inlinedSiteIndex);
vsfRecord->setConstantPool(reloTarget, reinterpret_cast<uintptr_t>(aotCI->_constantPool));
vsfRecord->setCpIndex(reloTarget, aotCI->_cpIndex);
vsfRecord->setRomClassOffsetInSharedCache(reloTarget, romClassOffsetInSharedCache, self(), aotCI);
}
break;
case TR_ValidateClass:
{
TR_RelocationRecordValidateClass *vcRecord = reinterpret_cast<TR_RelocationRecordValidateClass *>(reloRecord);
uintptr_t inlinedSiteIndex = reinterpret_cast<uintptr_t>(relocation->getTargetAddress());
TR::AOTClassInfo *aotCI = reinterpret_cast<TR::AOTClassInfo *>(relocation->getTargetAddress2());
vcRecord->setInlinedSiteIndex(reloTarget, inlinedSiteIndex);
vcRecord->setConstantPool(reloTarget, reinterpret_cast<uintptr_t>(aotCI->_constantPool));
vcRecord->setCpIndex(reloTarget, aotCI->_cpIndex);
vcRecord->setClassChainOffsetInSharedCache(reloTarget, aotCI, self());
}
break;
case TR_ProfiledMethodGuardRelocation:
case TR_ProfiledClassGuardRelocation:
case TR_ProfiledInlinedMethodRelocation:
{
TR_RelocationRecordProfiledInlinedMethod *pRecord = reinterpret_cast<TR_RelocationRecordProfiledInlinedMethod *>(reloRecord);
TR_RelocationRecordInformation *info = reinterpret_cast<TR_RelocationRecordInformation *>(relocation->getTargetAddress());
int32_t inlinedSiteIndex = static_cast<int32_t>(info->data1);
TR::SymbolReference *callSymRef = reinterpret_cast<TR::SymbolReference *>(info->data2);
TR_ResolvedMethod *owningMethod = callSymRef->getOwningMethod(comp);
TR_ResolvedMethod *inlinedMethod = comp->getInlinedResolvedMethod(inlinedSiteIndex);
TR_OpaqueClassBlock *inlinedCodeClass = reinterpret_cast<TR_OpaqueClassBlock *>(inlinedMethod->classOfMethod());
uintptr_t romClassOffsetInSharedCache = self()->offsetInSharedCacheFromClass(sharedCache, inlinedCodeClass);
traceMsg(comp, "class is %p, romclass is %p, offset is %llu\n",
inlinedCodeClass,
reinterpret_cast<J9ROMClass *>(fej9->getPersistentClassPointerFromClassPointer(inlinedCodeClass)),
romClassOffsetInSharedCache);
uintptr_t classChainIdentifyingLoaderOffsetInSharedCache = sharedCache->getClassChainOffsetIdentifyingLoader(inlinedCodeClass);
const AOTCacheClassChainRecord *classChainRecord = NULL;
uintptr_t classChainOffsetInSharedCache = self()->getClassChainOffset(inlinedCodeClass, classChainRecord);
uintptr_t methodIndex = fej9->getMethodIndexInClass(inlinedCodeClass, inlinedMethod->getNonPersistentIdentifier());
uint8_t flags = 0;
TR_OpaqueMethodBlock *method = inlinedMethod->getPersistentIdentifier();
if (fej9->isMethodTracingEnabled(reinterpret_cast<J9Method *>(method)))
flags = methodTracingEnabled;
// Ugly; this will be cleaned up in a future PR
uintptr_t cpIndexOrData = 0;
if (comp->getOption(TR_UseSymbolValidationManager))
{
uint16_t inlinedCodeClassID = symValManager->getSymbolIDFromValue(static_cast<void *>(inlinedCodeClass));
cpIndexOrData = static_cast<uintptr_t>(inlinedCodeClassID);
}
else
{
cpIndexOrData = static_cast<uintptr_t>(callSymRef->getCPIndex());
}
pRecord->setReloFlags(reloTarget, flags);
pRecord->setInlinedSiteIndex(reloTarget, inlinedSiteIndex);
pRecord->setConstantPool(reloTarget, reinterpret_cast<uintptr_t>(owningMethod->constantPool()));
pRecord->setCpIndex(reloTarget, cpIndexOrData);
pRecord->setRomClassOffsetInSharedCache(reloTarget, romClassOffsetInSharedCache, self(), inlinedCodeClass, classChainRecord);
pRecord->setClassChainIdentifyingLoaderOffsetInSharedCache(reloTarget, classChainIdentifyingLoaderOffsetInSharedCache,
self(), classChainRecord);
pRecord->setClassChainForInlinedMethod(reloTarget, classChainOffsetInSharedCache, self(), classChainRecord, inlinedCodeClass);
pRecord->setMethodIndex(reloTarget, methodIndex);
}
break;
case TR_MethodPointer:
{
TR_RelocationRecordMethodPointer *mpRecord = reinterpret_cast<TR_RelocationRecordMethodPointer *>(reloRecord);
TR::Node *aconstNode = reinterpret_cast<TR::Node *>(relocation->getTargetAddress());
uintptr_t inlinedSiteIndex = static_cast<uintptr_t>(aconstNode->getInlinedSiteIndex());
TR_OpaqueMethodBlock *j9method = reinterpret_cast<TR_OpaqueMethodBlock *>(aconstNode->getAddress());
if (aconstNode->getOpCodeValue() == TR::loadaddr)
j9method = reinterpret_cast<TR_OpaqueMethodBlock *>(aconstNode->getSymbolReference()->getSymbol()->castToStaticSymbol()->getStaticAddress());
TR_OpaqueClassBlock *j9class = fej9->getClassFromMethodBlock(j9method);
uintptr_t classChainOffsetOfCLInSharedCache = sharedCache->getClassChainOffsetIdentifyingLoader(j9class);
const AOTCacheClassChainRecord *classChainRecord = NULL;
uintptr_t classChainForInlinedMethodOffsetInSharedCache = self()->getClassChainOffset(j9class, classChainRecord);
uintptr_t vTableOffset = static_cast<uintptr_t>(fej9->getInterpreterVTableSlot(j9method, j9class));
mpRecord->setInlinedSiteIndex(reloTarget, inlinedSiteIndex);
mpRecord->setClassChainForInlinedMethod(reloTarget, classChainForInlinedMethodOffsetInSharedCache,
self(), classChainRecord, j9class);
mpRecord->setClassChainIdentifyingLoaderOffsetInSharedCache(reloTarget, classChainOffsetOfCLInSharedCache,
self(), classChainRecord);
mpRecord->setVTableSlot(reloTarget, vTableOffset);
}
break;
case TR_InlinedMethodPointer:
{
TR_RelocationRecordInlinedMethodPointer *impRecord = reinterpret_cast<TR_RelocationRecordInlinedMethodPointer *>(reloRecord);
impRecord->setInlinedSiteIndex(reloTarget, reinterpret_cast<uintptr_t>(relocation->getTargetAddress()));
}
break;
case TR_ClassPointer:
{
TR_RelocationRecordClassPointer *cpRecord = reinterpret_cast<TR_RelocationRecordClassPointer *>(reloRecord);
TR::Node *aconstNode = reinterpret_cast<TR::Node *>(relocation->getTargetAddress());
uintptr_t inlinedSiteIndex = static_cast<uintptr_t>(aconstNode->getInlinedSiteIndex());
TR_OpaqueClassBlock *j9class = NULL;
if (relocation->getTargetAddress2())
{
j9class = reinterpret_cast<TR_OpaqueClassBlock *>(relocation->getTargetAddress2());
}
else
{
if (aconstNode->getOpCodeValue() == TR::loadaddr)
j9class = reinterpret_cast<TR_OpaqueClassBlock *>(aconstNode->getSymbolReference()->getSymbol()->castToStaticSymbol()->getStaticAddress());
else
j9class = reinterpret_cast<TR_OpaqueClassBlock *>(aconstNode->getAddress());
}
uintptr_t classChainOffsetOfCLInSharedCache = sharedCache->getClassChainOffsetIdentifyingLoader(j9class);
const AOTCacheClassChainRecord *classChainRecord = NULL;
uintptr_t classChainForInlinedMethodOffsetInSharedCache = self()->getClassChainOffset(j9class, classChainRecord);
cpRecord->setInlinedSiteIndex(reloTarget, inlinedSiteIndex);
cpRecord->setClassChainForInlinedMethod(reloTarget, classChainForInlinedMethodOffsetInSharedCache,
self(), classChainRecord, j9class);
cpRecord->setClassChainIdentifyingLoaderOffsetInSharedCache(reloTarget, classChainOffsetOfCLInSharedCache,
self(), classChainRecord);
}
break;
case TR_ValidateArbitraryClass:
{
TR_RelocationRecordValidateArbitraryClass *vacRecord = reinterpret_cast<TR_RelocationRecordValidateArbitraryClass *>(reloRecord);
TR::AOTClassInfo *aotCI = reinterpret_cast<TR::AOTClassInfo *>(relocation->getTargetAddress2());
TR_OpaqueClassBlock *classToValidate = aotCI->_clazz;
uintptr_t classChainOffsetInSharedCacheForCL = sharedCache->getClassChainOffsetIdentifyingLoader(classToValidate);
vacRecord->setClassChainIdentifyingLoaderOffset(reloTarget, classChainOffsetInSharedCacheForCL,
self(), aotCI->getAOTCacheClassChainRecord());
vacRecord->setClassChainOffsetForClassBeingValidated(reloTarget, aotCI, self());
}
break;
case TR_J2IVirtualThunkPointer:
{
TR_RelocationRecordJ2IVirtualThunkPointer *vtpRecord = reinterpret_cast<TR_RelocationRecordJ2IVirtualThunkPointer *>(reloRecord);
TR_RelocationRecordInformation *info = reinterpret_cast<TR_RelocationRecordInformation*>(relocation->getTargetAddress());
vtpRecord->setConstantPool(reloTarget, info->data1);
vtpRecord->setInlinedSiteIndex(reloTarget, info->data2);
vtpRecord->setOffsetToJ2IVirtualThunkPointer(reloTarget, info->data3);
}
break;
case TR_ValidateClassByName:
{
TR_RelocationRecordValidateClassByName *cbnRecord = reinterpret_cast<TR_RelocationRecordValidateClassByName *>(reloRecord);
TR::ClassByNameRecord *svmRecord = reinterpret_cast<TR::ClassByNameRecord *>(relocation->getTargetAddress());
cbnRecord->setClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_class));
cbnRecord->setBeholderID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_beholder));
cbnRecord->setClassChainOffset(reloTarget, svmRecord, self());
}
break;
case TR_ValidateProfiledClass:
{
TR_RelocationRecordValidateProfiledClass *pcRecord = reinterpret_cast<TR_RelocationRecordValidateProfiledClass *>(reloRecord);
TR::ProfiledClassRecord *svmRecord = reinterpret_cast<TR::ProfiledClassRecord *>(relocation->getTargetAddress());
TR_OpaqueClassBlock *classToValidate = svmRecord->_class;
//store the classchain's offset for the classloader for the class
uintptr_t classChainOffsetInSharedCacheForCL = sharedCache->getClassChainOffsetIdentifyingLoader(classToValidate);
pcRecord->setClassID(reloTarget, symValManager->getSymbolIDFromValue(classToValidate));
//store the classchain's offset for the class that needs to be validated in the second run
pcRecord->setClassChainOffset(reloTarget, svmRecord, self());
pcRecord->setClassChainOffsetForClassLoader(reloTarget, classChainOffsetInSharedCacheForCL,
self(), svmRecord->getAOTCacheClassChainRecord());
}
break;
case TR_ValidateClassFromCP:
{
TR_RelocationRecordValidateClassFromCP *cpRecord = reinterpret_cast<TR_RelocationRecordValidateClassFromCP *>(reloRecord);
TR::ClassFromCPRecord *svmRecord = reinterpret_cast<TR::ClassFromCPRecord *>(relocation->getTargetAddress());
cpRecord->setClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_class));
cpRecord->setBeholderID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_beholder));
cpRecord->setCpIndex(reloTarget, svmRecord->_cpIndex);
}
break;
case TR_ValidateDefiningClassFromCP:
{
TR_RelocationRecordValidateDefiningClassFromCP *dcpRecord = reinterpret_cast<TR_RelocationRecordValidateDefiningClassFromCP *>(reloRecord);
TR::DefiningClassFromCPRecord *svmRecord = reinterpret_cast<TR::DefiningClassFromCPRecord *>(relocation->getTargetAddress());
dcpRecord->setIsStatic(reloTarget, svmRecord->_isStatic);
dcpRecord->setClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_class));
dcpRecord->setBeholderID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_beholder));
dcpRecord->setCpIndex(reloTarget, svmRecord->_cpIndex);
}
break;
case TR_ValidateStaticClassFromCP:
{
TR_RelocationRecordValidateStaticClassFromCP *scpRecord = reinterpret_cast<TR_RelocationRecordValidateStaticClassFromCP *>(reloRecord);
TR::StaticClassFromCPRecord *svmRecord = reinterpret_cast<TR::StaticClassFromCPRecord *>(relocation->getTargetAddress());
scpRecord->setClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_class));
scpRecord->setBeholderID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_beholder));
scpRecord->setCpIndex(reloTarget, svmRecord->_cpIndex);
}
break;
case TR_ValidateArrayClassFromComponentClass:
{
TR_RelocationRecordValidateArrayClassFromComponentClass *acRecord = reinterpret_cast<TR_RelocationRecordValidateArrayClassFromComponentClass *>(reloRecord);
TR::ArrayClassFromComponentClassRecord *svmRecord = reinterpret_cast<TR::ArrayClassFromComponentClassRecord *>(relocation->getTargetAddress());
acRecord->setArrayClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_arrayClass));
acRecord->setComponentClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_componentClass));
}
break;
case TR_ValidateSuperClassFromClass:
{
TR_RelocationRecordValidateSuperClassFromClass *scRecord = reinterpret_cast<TR_RelocationRecordValidateSuperClassFromClass *>(reloRecord);
TR::SuperClassFromClassRecord *svmRecord = reinterpret_cast<TR::SuperClassFromClassRecord *>(relocation->getTargetAddress());
scRecord->setSuperClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_superClass));
scRecord->setChildClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_childClass));
}
break;
case TR_ValidateClassInstanceOfClass:
{
TR_RelocationRecordValidateClassInstanceOfClass *cicRecord = reinterpret_cast<TR_RelocationRecordValidateClassInstanceOfClass *>(reloRecord);
TR::ClassInstanceOfClassRecord *svmRecord = reinterpret_cast<TR::ClassInstanceOfClassRecord *>(relocation->getTargetAddress());
cicRecord->setObjectTypeIsFixed(reloTarget, svmRecord->_objectTypeIsFixed);
cicRecord->setCastTypeIsFixed(reloTarget, svmRecord->_castTypeIsFixed);
cicRecord->setIsInstanceOf(reloTarget, svmRecord->_isInstanceOf);
cicRecord->setClassOneID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_classOne));
cicRecord->setClassTwoID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_classTwo));
}
break;
case TR_ValidateSystemClassByName:
{
TR_RelocationRecordValidateSystemClassByName *scmRecord = reinterpret_cast<TR_RelocationRecordValidateSystemClassByName *>(reloRecord);
TR::SystemClassByNameRecord *svmRecord = reinterpret_cast<TR::SystemClassByNameRecord *>(relocation->getTargetAddress());
TR_OpaqueClassBlock *classToValidate = svmRecord->_class;
scmRecord->setSystemClassID(reloTarget, symValManager->getSymbolIDFromValue(classToValidate));
// Store class chain to get name of class. Checking the class chain for
// this record eliminates the need for a separate class chain validation.
scmRecord->setClassChainOffset(reloTarget, svmRecord, self());
}
break;
case TR_ValidateClassFromITableIndexCP:
{
TR_RelocationRecordValidateClassFromITableIndexCP *cfitRecord = reinterpret_cast<TR_RelocationRecordValidateClassFromITableIndexCP *>(reloRecord);
TR::ClassFromITableIndexCPRecord *svmRecord = reinterpret_cast<TR::ClassFromITableIndexCPRecord *>(relocation->getTargetAddress());
cfitRecord->setClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_class));
cfitRecord->setBeholderID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_beholder));
cfitRecord->setCpIndex(reloTarget, svmRecord->_cpIndex);
}
break;
case TR_ValidateDeclaringClassFromFieldOrStatic:
{
TR_RelocationRecordValidateDeclaringClassFromFieldOrStatic *dcfsRecord = reinterpret_cast<TR_RelocationRecordValidateDeclaringClassFromFieldOrStatic *>(reloRecord);
TR::DeclaringClassFromFieldOrStaticRecord *svmRecord = reinterpret_cast<TR::DeclaringClassFromFieldOrStaticRecord *>(relocation->getTargetAddress());
dcfsRecord->setClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_class));
dcfsRecord->setBeholderID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_beholder));
dcfsRecord->setCpIndex(reloTarget, svmRecord->_cpIndex);
}
break;
case TR_ValidateConcreteSubClassFromClass:
{
TR_RelocationRecordValidateConcreteSubClassFromClass *csccRecord = reinterpret_cast<TR_RelocationRecordValidateConcreteSubClassFromClass *>(reloRecord);
TR::ConcreteSubClassFromClassRecord *svmRecord = reinterpret_cast<TR::ConcreteSubClassFromClassRecord *>(relocation->getTargetAddress());
csccRecord->setSuperClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_superClass));
csccRecord->setChildClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_childClass));
}
break;
case TR_ValidateClassChain:
{
TR_RelocationRecordValidateClassChain *ccRecord = reinterpret_cast<TR_RelocationRecordValidateClassChain *>(reloRecord);
TR::ClassChainRecord *svmRecord = reinterpret_cast<TR::ClassChainRecord *>(relocation->getTargetAddress());
TR_OpaqueClassBlock *classToValidate = svmRecord->_class;
ccRecord->setClassID(reloTarget, symValManager->getSymbolIDFromValue(classToValidate));
// Store class chain to get name of class. Checking the class chain for
// this record eliminates the need for a separate class chain validation.
ccRecord->setClassChainOffset(reloTarget, svmRecord, self());
}
break;
case TR_ValidateMethodFromClass:
{
TR_RelocationRecordValidateMethodFromClass *mfcRecord = reinterpret_cast<TR_RelocationRecordValidateMethodFromClass *>(reloRecord);
TR::MethodFromClassRecord *svmRecord = reinterpret_cast<TR::MethodFromClassRecord *>(relocation->getTargetAddress());
mfcRecord->setMethodID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_method));
mfcRecord->setBeholderID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_beholder));
mfcRecord->setIndex(reloTarget, svmRecord->_index);
}
break;
case TR_ValidateStaticMethodFromCP:
{
TR_RelocationRecordValidateStaticMethodFromCP *smfcpRecord = reinterpret_cast<TR_RelocationRecordValidateStaticMethodFromCP *>(reloRecord);
TR::StaticMethodFromCPRecord *svmRecord = reinterpret_cast<TR::StaticMethodFromCPRecord *>(relocation->getTargetAddress());
TR_ASSERT_FATAL(
(svmRecord->_cpIndex & J9_SPECIAL_SPLIT_TABLE_INDEX_FLAG) == 0,
"static method cpIndex has special split table flag set");
if ((svmRecord->_cpIndex & J9_STATIC_SPLIT_TABLE_INDEX_FLAG) != 0)
smfcpRecord->setReloFlags(reloTarget, staticSpecialMethodFromCpIsSplit);
smfcpRecord->setMethodID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_method));
smfcpRecord->setDefiningClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_definingClass));
smfcpRecord->setBeholderID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_beholder));
smfcpRecord->setCpIndex(reloTarget, static_cast<uint16_t>(svmRecord->_cpIndex & J9_SPLIT_TABLE_INDEX_MASK));
}
break;
case TR_ValidateSpecialMethodFromCP:
{
TR_RelocationRecordValidateSpecialMethodFromCP *smfcpRecord = reinterpret_cast<TR_RelocationRecordValidateSpecialMethodFromCP *>(reloRecord);
TR::SpecialMethodFromCPRecord *svmRecord = reinterpret_cast<TR::SpecialMethodFromCPRecord *>(relocation->getTargetAddress());
TR_ASSERT_FATAL(
(svmRecord->_cpIndex & J9_STATIC_SPLIT_TABLE_INDEX_FLAG) == 0,
"special method cpIndex has static split table flag set");
if ((svmRecord->_cpIndex & J9_SPECIAL_SPLIT_TABLE_INDEX_FLAG) != 0)
smfcpRecord->setReloFlags(reloTarget, staticSpecialMethodFromCpIsSplit);
smfcpRecord->setMethodID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_method));
smfcpRecord->setDefiningClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_definingClass));
smfcpRecord->setBeholderID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_beholder));
smfcpRecord->setCpIndex(reloTarget, static_cast<uint16_t>(svmRecord->_cpIndex & J9_SPLIT_TABLE_INDEX_MASK));
}
break;
case TR_ValidateVirtualMethodFromCP:
{
TR_RelocationRecordValidateVirtualMethodFromCP *vmfcpRecord = reinterpret_cast<TR_RelocationRecordValidateVirtualMethodFromCP *>(reloRecord);
TR::VirtualMethodFromCPRecord *svmRecord = reinterpret_cast<TR::VirtualMethodFromCPRecord *>(relocation->getTargetAddress());