-
Notifications
You must be signed in to change notification settings - Fork 739
/
Copy pathJ9SharedCache.hpp
620 lines (532 loc) · 28.2 KB
/
J9SharedCache.hpp
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
/*******************************************************************************
* 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
*******************************************************************************/
#ifndef J9SHARED_CACHE_HPP
#define J9SHARED_CACHE_HPP
#include "compiler/env/SharedCache.hpp"
#include <stdint.h>
#include <map>
#include "env/TRMemory.hpp"
#include "env/jittypes.h"
#include "il/DataTypes.hpp"
#include "runtime/J9Runtime.hpp"
#include "runtime/RuntimeAssumptions.hpp"
class TR_J9VMBase;
class TR_ResolvedMethod;
namespace TR { class CompilationInfo; }
#if defined(J9VM_OPT_JITSERVER)
namespace JITServer { class ServerStream; }
#endif
struct J9SharedClassConfig;
struct J9SharedClassCacheDescriptor;
struct J9SharedDataDescriptor;
/**
* \brief An interface to the VM's shared class cache.
*
* This class provides an interface to the VM's shared class cache as represented
* by the descriptors in J9SharedClassConfig::cacheDescriptorList.The cache
* descriptor list is a circular linked list. It is doubly linked when
* J9VM_OPT_MULTI_LAYER_SHARED_CLASS_CACHE is defined or singly linked otherwise.
*
* If J9VM_OPT_MULTI_LAYER_SHARED_CLASS_CACHE is not defined, the list consists of
* a single element who's next pointer refers back to itself. Offsets into the
* shared cache represent the distance from the start of the rom classes section or
* or start of the metadata section; the offset is then left shifted 1 bit in order
* to use the low bit to determine whether the offset is relative to the start of
* the rom classes section or the start of the metadata section. Converting between
* pointers and offsets can be done with simple pointer arithmetic.
*
* If J9VM_OPT_MULTI_LAYER_SHARED_CLASS_CACHE is defined, the head of the list
* represents the top-most (and therefore writable) layer of the shared class cache,
* the next element represents the (N-1)th layer, and so on. The element previous to
* the head represents the base layer. The list of cache layers can be thought of as
* a single logical cache starting at layer 0 and ending at layer N. Offsets into the
* shared cache represent the distance from the start of the cache. Converting
* between pointers and offsets requires traversing the list starting at the base
* layer.
*
* The layout of section of the SCC relevant for this class is:
*
* Increasing Address ----->
* *-------------*------------------*----------*
* | ROM CLASSES |---> FREE <---| METADATA |
* *-------------*------------------*----------*
* ^ ^ ^ ^
* | | | |
* | | | cacheDesc->metadataStartAddress
* | | |
* | | UPDATEPTR(cacheDesc->cacheStartAddress)
* | |
* | SEGUPDATEPTR(cacheDesc->cacheStartAddress)
* |
* cacheDesc->romclassStartAddress
*
* See CompositeCache.cpp for more details.
*/
class TR_J9SharedCache : public TR_SharedCache
{
public:
TR_ALLOC_SPECIALIZED(TR_Memory::SharedCache)
TR_J9SharedCache(TR_J9VMBase *fe);
TR_J9VMBase *fe() { return _fe; }
virtual bool isHint(TR_ResolvedMethod *, TR_SharedCacheHint, uint16_t *dataField = NULL);
virtual bool isHint(J9Method *, TR_SharedCacheHint, uint16_t *dataField = NULL);
virtual uint16_t getAllEnabledHints(J9Method *method);
virtual void addHint(J9Method *, TR_SharedCacheHint);
virtual void addHint(TR_ResolvedMethod *, TR_SharedCacheHint);
virtual bool isMostlyFull();
/**
* \brief Converts a shared cache offset, calculated from the end of the SCC, into the
* metadata section of the SCC into a pointer.
*
* \param[in] offset The offset to convert.
* \return A pointer. Raises a fatal assertion before returning NULL if the offset is invalid.
*/
virtual void *pointerFromOffsetInSharedCache(uintptr_t offset);
/**
* \brief Converts a pointer into the metadata section of the SCC into an offset, calculated
* from the end of the SCC.
*
* \param[in] ptr The pointer to convert.
* \return An offset. Raises a fatal assertion before returning 0 if the pointer is invalid.
*/
virtual uintptr_t offsetInSharedCacheFromPointer(void *ptr);
/**
* \brief Converts an offset into the ROMClass section into a J9ROMClass *.
*
* \param[in] offset The offset to convert.
* \return A J9ROMClass *. Raises a fatal assertion before returning NULL if the offset is invalid.
*/
virtual J9ROMClass *romClassFromOffsetInSharedCache(uintptr_t offset);
/**
* \brief Converts a J9ROMClass * pointer into the SCC into an offset.
*
* \param[in] romClass The J9ROMClass * to convert
* \return An offset. Raises a fatal assertion before returning 0 if the pointer is invalid.
*/
virtual uintptr_t offsetInSharedCacheFromROMClass(J9ROMClass *romClass);
/**
* \brief Converts an offset into the ROMClass section into a J9ROMMethod *.
*
* \param[in] offset The offset to convert
* \return A J9ROMMethod *. Raises a fatal assertion before returning NULL if the offset is invalid.
*/
virtual J9ROMMethod *romMethodFromOffsetInSharedCache(uintptr_t offset);
/**
* \brief Converts a J9ROMMethod * pointer into the SCC into an offset.
*
* \param[in] romMethod The J9ROMMethod * to convert
* \return An offset. Raises a fatal assertion before returning 0 if the pointer is invalid.
*/
virtual uintptr_t offsetInSharedCacheFromROMMethod(J9ROMMethod *romMethod);
/**
* \brief Converts an offset into the ROMClass section into a pointer.
*
* \param[in] offset The offset to convert
* \return A pointer. Raises a fatal assertion before returning NULL if the offset is invalid.
*/
virtual void *ptrToROMClassesSectionFromOffsetInSharedCache(uintptr_t offset);
/**
* \brief Converts a pointer into the ROM Classes section of the SCC into an offset.
*
* \param[in] ptr The pointer to convert
* \return An offset. Raises a fatal assertion before returning 0 if the pointer is invalid.
*/
virtual uintptr_t offsetInSharedCacheFromPtrToROMClassesSection(void *ptr);
virtual void persistIprofileInfo(TR::ResolvedMethodSymbol *, TR::Compilation *comp);
virtual void persistIprofileInfo(TR::ResolvedMethodSymbol *, TR_ResolvedMethod*, TR::Compilation *comp);
static const uint32_t maxClassChainLength = 32;
virtual bool canRememberClass(TR_OpaqueClassBlock *classPtr)
{
return rememberClass((J9Class *)classPtr, NULL, false) != NULL;
}
virtual uintptr_t *rememberClass(TR_OpaqueClassBlock *classPtr,
const AOTCacheClassChainRecord **classChainRecord = NULL)
{
return (uintptr_t *)rememberClass((J9Class *)classPtr, classChainRecord, true);
}
virtual uintptr_t *rememberClass(J9Class *clazz, const AOTCacheClassChainRecord **classChainRecord = NULL,
bool create = true);
virtual UDATA rememberDebugCounterName(const char *name);
virtual const char *getDebugCounterName(UDATA offset);
virtual bool classMatchesCachedVersion(J9Class *clazz, UDATA *chainData=NULL);
virtual bool classMatchesCachedVersion(TR_OpaqueClassBlock *classPtr, UDATA *chainData=NULL)
{
return classMatchesCachedVersion((J9Class *) classPtr, chainData);
}
virtual TR_OpaqueClassBlock *lookupClassFromChainAndLoader(uintptr_t *chainData, void *classLoader);
/**
* \brief Checks whether the specified pointer points into the metadata section
* of the shared cache.
*
* \param[in] ptr The pointer to check.
* \param[out] cacheOffset If ptr points into the shared cache and this parameter
* is not NULL the result of converting ptr into an offset will be
* returned here. If ptr does not point into the shared cache this
* parameter is ignored. The offset is calculated from the end of
* the SCC.
* \return True if the pointer points into the shared cache, false otherwise.
*/
virtual bool isPointerInSharedCache(void *ptr, uintptr_t *cacheOffset = NULL);
/**
* \brief Checks whether the specified offset, calculated from the end of the SCC,
* is within the metadata section of the shared cache.
*
* \param[in] offset The offset to check.
* \param[out] ptr If offset is within the shared cache and this parameter is not
* NULL the result of converting offset into a pointer will be returned
* here. If offset is not within the shared cache this parameter is ignored.
* \return True if the offset is within the shared cache, false otherwise.
*/
virtual bool isOffsetInSharedCache(uintptr_t encoded_offset, void *ptr = NULL);
/**
* \brief Checks whether the specified J9ROMClass exists in the SCC
*
* \param[in] romClass The J9ROMClass * to check
* \param[out] cacheOffset If the J9ROMClass is in the SCC and this parameter
* is not NULL the result of converting romClass into an offset will
* be returned here. If romClass does not point into the SCC, this
* parameter is ignored.
* \return True if romClass points into the SCC, false otherwise.
*/
virtual bool isROMClassInSharedCache(J9ROMClass *romClass, uintptr_t *cacheOffset = NULL);
/**
* \brief Checks whether the specified offset is within the ROMClass section
* of the shared cache.
*
* \param[in] offset The offset to check
* \param[out] romClass If offset is within the shared cache and this parameter is not
* NULL the result of converting offset into a J9ROMClass * will be returned
* here. If offset is not within the shared cache this parameter is ignored.
* \return True if the offset is within the shared cache, false otherwise.
*/
virtual bool isROMClassOffsetInSharedCache(uintptr_t offset, J9ROMClass **romClassPtr = NULL);
/**
* \brief Checks whether the specified J9ROMMethod exists in the SCC
*
* \param[in] romMethod The J9ROMMethod * to check
* \param[out] cacheOffset If the J9ROMMethod is in the SCC and this parameter
* is not NULL the result of converting romMethod into an offset will
* be returned here. If romMethod does not point into the SCC, this
* parameter is ignored.
* \return True if romMethod points into the SCC, false otherwise.
*/
virtual bool isROMMethodInSharedCache(J9ROMMethod *romMethod, uintptr_t *cacheOffset = NULL);
/**
* \brief Checks whether the specified offset is within the ROMClass section
* of the shared cache.
* \param[in] offset The offset to check
* \param[out] romMethodPtr If offset is within the shared cache and this parameter is not
* NULL the result of converting offset into a J9ROMMethod * will be returned
* here. If offset is not within the shared cache this parameter is ignored.
* \return True if the offset is within the shared cache, false otherwise.
*/
virtual bool isROMMethodOffsetInSharedCache(uintptr_t offset, J9ROMMethod **romMethodPtr = NULL);
/**
* \brief Checks whether the specified pointer points into the ROMClass section
* of the shared cache.
*
* \param[in] ptr The pointer to check
* \param[out] cacheOffset If ptr points into the shared cache and this parameter
* is not NULL the result of converting ptr into an offset will be
* returned here. If ptr does not point into the shared cache this
* parameter is ignored.
* \return True if the pointer points into the shared cache, false otherwise.
*/
virtual bool isPtrToROMClassesSectionInSharedCache(void *ptr, uintptr_t *cacheOffset = NULL);
/**
* \brief Checks whether the specified offset is within the ROMClass section
* of the shared cache.
*
* \param[in] offset The offset to check.
* \param[out] ptr If offset is within the shared cache and this parameter is not
* NULL the result of converting offset into a pointer will be returned
* here. If offset is not within the shared cache this parameter is ignored.
* \return True if the offset is within the shared cache, false otherwise.
*/
virtual bool isOffsetOfPtrToROMClassesSectionInSharedCache(uintptr_t offset, void **ptr = NULL);
J9ROMClass *startingROMClassOfClassChain(UDATA *classChain);
virtual uintptr_t getClassChainOffsetIdentifyingLoader(TR_OpaqueClassBlock *clazz, uintptr_t **classChain = NULL);
#if defined(J9VM_OPT_JITSERVER)
/**
* \brief Finds the offset in SCC of the class chain identifying the class loader of the given class.
* This is very similar to getClassChainOffsetIdentifyingLoader
* except that it will not fail the compilation if the offset is not valid.
* \return Returns the offset of the class chain that identifies given class or 0 is such offset is not valid.
*/
uintptr_t getClassChainOffsetIdentifyingLoaderNoFail(TR_OpaqueClassBlock *clazz, uintptr_t **classChain = NULL);
#endif /* defined(J9VM_OPT_JITSERVER) */
uintptr_t getClassChainOffsetIdentifyingLoaderNoThrow(TR_OpaqueClassBlock *clazz);
virtual const void *storeSharedData(J9VMThread *vmThread, const char *key, const J9SharedDataDescriptor *descriptor);
enum TR_J9SharedCacheDisabledReason
{
UNINITIALIZED,
NOT_DISABLED,
AOT_DISABLED,
AOT_HEADER_INVALID,
AOT_HEADER_FAILED_TO_ALLOCATE,
J9_SHARED_CACHE_FAILED_TO_ALLOCATE,
SHARED_CACHE_STORE_ERROR,
SHARED_CACHE_FULL,
// The following are probably equivalent to SHARED_CACHE_FULL -
// they could have failed because of no space but no error code is returned.
SHARED_CACHE_CLASS_CHAIN_STORE_FAILED,
AOT_HEADER_STORE_FAILED
};
static void setSharedCacheDisabledReason(TR_J9SharedCacheDisabledReason state) { _sharedCacheState = state; }
static TR_J9SharedCacheDisabledReason getSharedCacheDisabledReason() { return _sharedCacheState; }
static TR_YesNoMaybe isSharedCacheDisabledBecauseFull(TR::CompilationInfo *compInfo);
static void setStoreSharedDataFailedLength(UDATA length) {_storeSharedDataFailedLength = length; }
virtual J9SharedClassCacheDescriptor *getCacheDescriptorList();
protected:
/**
* \brief Helper method; used to check if a pointer is within the SCC
*
* \param[in] cacheDesc the J9SharedClassCacheDescriptor for the cache
* \param[in] ptr The pointer to check
* \return True if ptr is within the SCC, false otherwise
*/
static bool isPointerInCache(const J9SharedClassCacheDescriptor *cacheDesc, void *ptr);
/**
* \brief Helper method; used to check if an offset is within the SCC
*
* \param[in] cacheDesc the J9SharedClassCacheDescriptor for the cache
* \param[in] offset the offset to check
* \return True if offset is within the SCC, false otherwise
*/
static bool isOffsetInCache(const J9SharedClassCacheDescriptor *cacheDesc, uintptr_t offset);
static inline bool isOffsetFromStart(uintptr_t offset) { return ((offset & OFFSET_FROM_END) != OFFSET_FROM_END); }
static inline bool isOffsetFromEnd(uintptr_t offset) { return ((offset & OFFSET_FROM_END) == OFFSET_FROM_END); }
static inline uintptr_t encodeOffsetFromStart(uintptr_t offset) { return (offset << 1); }
static inline uintptr_t decodeOffsetFromStart(uintptr_t offset) { return (offset >> 1); }
static inline uintptr_t encodeOffsetFromEnd(uintptr_t offset) { return ((offset << 1) | OFFSET_FROM_END); }
static inline uintptr_t decodeOffsetFromEnd(uintptr_t offset) { return (offset >> 1); }
private:
// This class is intended to be a POD; keep it simple.
struct SCCHint
{
SCCHint() : flags(0), data(0) {}
void clear() { flags = 0; data = 0; }
uint16_t flags;
uint16_t data;
};
static const uintptr_t OFFSET_FROM_END = 0x1;
J9JITConfig *jitConfig() { return _jitConfig; }
J9JavaVM *javaVM() { return _javaVM; }
J9SharedClassConfig *sharedCacheConfig() { return _sharedCacheConfig; }
TR_AOTStats *aotStats() { return _aotStats; }
void log(char *format, ...);
SCCHint getHint(J9VMThread * vmThread, J9Method *method);
void convertUnsignedOffsetToASCII(UDATA offset, char *myBuffer);
void createClassKey(UDATA classOffsetInCache, char *key, uint32_t & keyLength);
uint32_t numInterfacesImplemented(J9Class *clazz);
bool writeClassToChain(J9ROMClass *romClass, UDATA * & chainPtr);
bool writeClassesToChain(J9Class *clazz, int32_t numSuperclasses, UDATA * & chainPtr);
bool writeInterfacesToChain(J9Class *clazz, UDATA * & chainPtr);
bool fillInClassChain(J9Class *clazz, UDATA *chainData, uint32_t chainLength,
uint32_t numSuperclasses, uint32_t numInterfaces);
bool romclassMatchesCachedVersion(J9ROMClass *romClass, UDATA * & chainPtr, UDATA *chainEnd);
UDATA *findChainForClass(J9Class *clazz, const char *key, uint32_t keyLength);
/**
* \brief Helper Method; Converts an offset into the ROMClass section into a pointer.
*
* \param offset The offset to convert
* \return A pointer. Raises a fatal assertion before returning NULL if the offset is invalid.
*/
void *romStructureFromOffsetInSharedCache(uintptr_t offset);
/**
* \brief Converts a pointer into the ROMClass section of the SCC into an offset.
*
* \param[in] romStructure The pointer to convert.
* \return An offset. Raises a fatal assertion before returning 0 if the pointer is invalid.
*/
uintptr_t offsetInSharedcacheFromROMStructure(void *romStructure);
/**
* \brief Checks whether the specified pointer points into the ROMClass section
* of the shared cache.
*
* \param[in] romStructure The pointer to check
* \param[out] cacheOffset If romStructure points into the shared cache and this parameter
* is not NULL the result of converting romStructure into an offset will be
* returned here. If romStructure does not point into the shared cache this
* parameter is ignored.
* \return True if the pointer points into the shared cache, false otherwise.
*/
bool isROMStructureInSharedCache(void *romStructure, uintptr_t *cacheOffset = NULL);
/**
* \brief Checks whether the specified offset is within the ROMClass section
* of the shared cache.
*
* \param[in] offset The offset to check.
* \param[out] romStructurePtr If offset is within the shared cache and this parameter is not
* NULL the result of converting offset into a pointer will be returned
* here. If offset is not within the shared cache this parameter is ignored.
* \return True if the offset is within the shared cache, false otherwise.
*/
bool isROMStructureOffsetInSharedCache(uintptr_t encoded_offset, void **romStructurePtr = NULL);
/**
* \brief Validates the provided class chain. This method modifies the chainPtr arg.
*
* \param[in] romClass The J9ROMClass of the class whose chain is to be validated
* \param[in] clazz The TR_OpaqueClassBlock of the class whose chain is to be validated
* \param[in,out] chainPtr Pointer to the start of the class chain passed by reference
* \param[in] chainEnd Pointer to the end of the class chain
* \return true if validation succeeded, false otherwise.
*/
bool validateClassChain(J9ROMClass *romClass, TR_OpaqueClassBlock *clazz, UDATA * & chainPtr, UDATA *chainEnd);
/**
* \brief Validates the super classes portion of the class chain. This method modifies the chainPtr arg.
*
* \param[in] clazz The TR_OpaqueClassBlock of the class whose chain is to be validated
* \param[in,out] chainPtr Pointer to the start of super classes portion of the class chain passed by reference
* \param[in] chainEnd Pointer to the end of the class chain
* \return true if validation succeeded, false otherwise.
*/
bool validateSuperClassesInClassChain(TR_OpaqueClassBlock *clazz, UDATA * & chainPtr, UDATA *chainEnd);
/**
* \brief Validates the interfaces portion of the class chain. This method modifies the chainPtr arg.
*
* \param[in] clazz The TR_OpaqueClassBlock of the class whose chain is to be validated
* \param[in,out] chainPtr Pointer to the start of interfaces portion of the class chain passed by reference
* \param[in] chainEnd Pointer to the end of the class chain
* \return true if validation succeeded, false otherwise.
*/
bool validateInterfacesInClassChain(TR_OpaqueClassBlock *clazz, UDATA * & chainPtr, UDATA *chainEnd);
/**
* \brief Helper method; used to check if a pointer is within the metadata section of the SCC
* \param[in] cacheDesc the J9SharedClassCacheDescriptor for the cache
* \param[in] ptr The pointer to check
* \return True if ptr is within the metadata section of the SCC, false otherwise
*/
virtual bool isPointerInMetadataSectionInCache(const J9SharedClassCacheDescriptor *cacheDesc, void *ptr);
/**
* \brief Helper method; used to check if an offset is within the metadata section of the SCC
*
* \param[in] cacheDesc the J9SharedClassCacheDescriptor for the cache
* \param[in] offset the offset to check
* \return True if offset is within the metadata section of the SCC, false otherwise
*/
virtual bool isOffsetInMetadataSectionInCache(const J9SharedClassCacheDescriptor *cacheDesc, uintptr_t offset);
/**
* \brief Helper method; used to check if a pointer is within the ROMClass section of the SCC
* \param[in] cacheDesc the J9SharedClassCacheDescriptor for the cache
* \param[in] ptr The pointer to check
* \return True if ptr is within the ROMClass section of the SCC, false otherwise
*/
virtual bool isPointerInROMClassesSectionInCache(const J9SharedClassCacheDescriptor *cacheDesc, void *ptr);
/**
* \brief Helper method; used to check if an offset is within the ROMClass section of the SCC
*
* \param[in] cacheDesc the J9SharedClassCacheDescriptor for the cache
* \param[in] offset the offset to check
* \return True if offset is within the ROMClass section of the SCC, false otherwise
*/
virtual bool isOffsetinROMClassesSectionInCache(const J9SharedClassCacheDescriptor *cacheDesc, uintptr_t offset);
/**
* \brief Gets the cached result of a prior class chain validation
*
* \param[in] clazz The class to be validated
*
* \return The cached CCVResult; CCVResult::notYetValidated if result does not exist.
*/
const CCVResult getCachedCCVResult(TR_OpaqueClassBlock *clazz);
/**
* \brief Caches the result of a class chain validation
*
* \param[in] clazz The class to be validated
* \param[in] result The result represented as a CCVResult
*
* \return The result of the insertion
*/
bool cacheCCVResult(TR_OpaqueClassBlock *clazz, CCVResult result);
uint16_t _initialHintSCount;
uint16_t _hintsEnabledMask;
J9JavaVM *_javaVM;
J9JITConfig *_jitConfig;
TR_J9VMBase *_fe;
TR::CompilationInfo *_compInfo;
TR_AOTStats *_aotStats;
J9SharedClassConfig *_sharedCacheConfig;
UDATA _numDigitsForCacheOffsets;
uint32_t _logLevel;
bool _verboseHints;
static TR_J9SharedCacheDisabledReason _sharedCacheState;
static TR_YesNoMaybe _sharedCacheDisabledBecauseFull;
static UDATA _storeSharedDataFailedLength;
};
#if defined(J9VM_OPT_JITSERVER)
/**
* \class TR_J9JITServerSharedCache
* \brief Class used by JITServer for querying client-side SharedCache information
*
* This class is an extension of the TR_J9SharedCache class which overrides a number
* of TR_J9SharedCache's APIs. TR_J9JITServerSharedCache is used by JITServer and
* the overridden APIs mostly send remote messages to JITClient to query information from
* the TR_J9SharedCache on the client. The information is needed for JITServer to
* compile code that is compatible with the client-side VM. To minimize the
* number of remote messages as a way to optimize JITServer performance, a
* lot of client-side TR_J9SharedCache information are cached on JITServer.
*/
class TR_J9JITServerSharedCache : public TR_J9SharedCache
{
public:
TR_ALLOC(TR_Memory::SharedCache)
TR_J9JITServerSharedCache(TR_J9VMBase *fe);
virtual bool isHint(TR_ResolvedMethod *, TR_SharedCacheHint, uint16_t *dataField = NULL) override { TR_ASSERT_FATAL(false, "called"); return false;}
virtual bool isHint(J9Method *, TR_SharedCacheHint, uint16_t *dataField = NULL) override { TR_ASSERT_FATAL(false, "called"); return false;}
virtual uint16_t getAllEnabledHints(J9Method *method) override { TR_ASSERT_FATAL(false, "called"); return 0;}
virtual void addHint(J9Method *, TR_SharedCacheHint) override;
virtual bool isMostlyFull() override { TR_ASSERT_FATAL(false, "called"); return false;}
virtual uintptr_t *rememberClass(J9Class *clazz, const AOTCacheClassChainRecord **classChainRecord = NULL,
bool create = true) override;
virtual UDATA rememberDebugCounterName(const char *name) override { TR_ASSERT_FATAL(false, "called"); return 0;}
virtual const char *getDebugCounterName(UDATA offset) override { TR_ASSERT_FATAL(false, "called"); return NULL;}
virtual bool classMatchesCachedVersion(J9Class *clazz, UDATA *chainData=NULL) override { TR_ASSERT_FATAL(false, "called"); return false;}
virtual TR_OpaqueClassBlock *lookupClassFromChainAndLoader(uintptr_t *chainData, void *classLoader) override { TR_ASSERT_FATAL(false, "called"); return NULL;}
static void setSharedCacheDisabledReason(TR_J9SharedCacheDisabledReason state) { TR_ASSERT_FATAL(false, "called"); }
static TR_J9SharedCacheDisabledReason getSharedCacheDisabledReason() { TR_ASSERT_FATAL(false, "called"); return TR_J9SharedCache::TR_J9SharedCacheDisabledReason::UNINITIALIZED;}
static TR_YesNoMaybe isSharedCacheDisabledBecauseFull(TR::CompilationInfo *compInfo) { TR_ASSERT_FATAL(false, "called"); return TR_no;}
static void setStoreSharedDataFailedLength(UDATA length) { TR_ASSERT_FATAL(false, "called"); }
virtual uintptr_t getClassChainOffsetIdentifyingLoader(TR_OpaqueClassBlock *clazz, uintptr_t **classChain = NULL) override;
virtual J9SharedClassCacheDescriptor *getCacheDescriptorList();
void setStream(JITServer::ServerStream *stream) { _stream = stream; }
virtual const void *storeSharedData(J9VMThread *vmThread, const char *key, const J9SharedDataDescriptor *descriptor) override;
private:
virtual bool isPointerInMetadataSectionInCache(const J9SharedClassCacheDescriptor *cacheDesc, void *ptr)
{
return isPointerInCache(cacheDesc, ptr);
}
virtual bool isOffsetInMetadataSectionInCache(const J9SharedClassCacheDescriptor *cacheDesc, uintptr_t offset)
{
return (isOffsetFromEnd(offset) && isOffsetInCache(cacheDesc, offset));
}
virtual bool isPointerInROMClassesSectionInCache(const J9SharedClassCacheDescriptor *cacheDesc, void *ptr)
{
return isPointerInCache(cacheDesc, ptr);
}
virtual bool isOffsetinROMClassesSectionInCache(const J9SharedClassCacheDescriptor *cacheDesc, uintptr_t offset)
{
return (isOffsetFromStart(offset) && isOffsetInCache(cacheDesc, offset));
}
JITServer::ServerStream *_stream;
};
#endif /* defined(J9VM_OPT_JITSERVER) */
#endif