Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/compiler/env/J9SharedCache.hpp
6000 views
1
/*******************************************************************************
2
* Copyright (c) 2000, 2021 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
#ifndef J9SHARED_CACHE_HPP
24
#define J9SHARED_CACHE_HPP
25
26
#include "compiler/env/SharedCache.hpp"
27
28
#include <stdint.h>
29
#include <map>
30
#include "env/TRMemory.hpp"
31
#include "env/jittypes.h"
32
#include "il/DataTypes.hpp"
33
#include "runtime/J9Runtime.hpp"
34
#include "runtime/RuntimeAssumptions.hpp"
35
36
class TR_J9VMBase;
37
class TR_ResolvedMethod;
38
namespace TR { class CompilationInfo; }
39
#if defined(J9VM_OPT_JITSERVER)
40
namespace JITServer { class ServerStream; }
41
#endif
42
43
struct J9SharedClassConfig;
44
struct J9SharedClassCacheDescriptor;
45
struct J9SharedDataDescriptor;
46
47
/**
48
* \brief An interface to the VM's shared class cache.
49
*
50
* This class provides an interface to the VM's shared class cache as represented
51
* by the descriptors in J9SharedClassConfig::cacheDescriptorList.The cache
52
* descriptor list is a circular linked list. It is doubly linked when
53
* J9VM_OPT_MULTI_LAYER_SHARED_CLASS_CACHE is defined or singly linked otherwise.
54
*
55
* If J9VM_OPT_MULTI_LAYER_SHARED_CLASS_CACHE is not defined, the list consists of
56
* a single element who's next pointer refers back to itself. Offsets into the
57
* shared cache represent the distance from the start of the rom classes section or
58
* or start of the metadata section; the offset is then left shifted 1 bit in order
59
* to use the low bit to determine whether the offset is relative to the start of
60
* the rom classes section or the start of the metadata section. Converting between
61
* pointers and offsets can be done with simple pointer arithmetic.
62
*
63
* If J9VM_OPT_MULTI_LAYER_SHARED_CLASS_CACHE is defined, the head of the list
64
* represents the top-most (and therefore writable) layer of the shared class cache,
65
* the next element represents the (N-1)th layer, and so on. The element previous to
66
* the head represents the base layer. The list of cache layers can be thought of as
67
* a single logical cache starting at layer 0 and ending at layer N. Offsets into the
68
* shared cache represent the distance from the start of the cache. Converting
69
* between pointers and offsets requires traversing the list starting at the base
70
* layer.
71
*
72
* The layout of section of the SCC relevant for this class is:
73
*
74
* Increasing Address ----->
75
* *-------------*------------------*----------*
76
* | ROM CLASSES |---> FREE <---| METADATA |
77
* *-------------*------------------*----------*
78
* ^ ^ ^ ^
79
* | | | |
80
* | | | cacheDesc->metadataStartAddress
81
* | | |
82
* | | UPDATEPTR(cacheDesc->cacheStartAddress)
83
* | |
84
* | SEGUPDATEPTR(cacheDesc->cacheStartAddress)
85
* |
86
* cacheDesc->romclassStartAddress
87
*
88
* See CompositeCache.cpp for more details.
89
*/
90
class TR_J9SharedCache : public TR_SharedCache
91
{
92
public:
93
TR_ALLOC_SPECIALIZED(TR_Memory::SharedCache)
94
95
TR_J9SharedCache(TR_J9VMBase *fe);
96
97
virtual bool isHint(TR_ResolvedMethod *, TR_SharedCacheHint, uint16_t *dataField = NULL);
98
virtual bool isHint(J9Method *, TR_SharedCacheHint, uint16_t *dataField = NULL);
99
virtual uint16_t getAllEnabledHints(J9Method *method);
100
virtual void addHint(J9Method *, TR_SharedCacheHint);
101
virtual void addHint(TR_ResolvedMethod *, TR_SharedCacheHint);
102
virtual bool isMostlyFull();
103
104
/**
105
* \brief Converts a shared cache offset, calculated from the end of the SCC, into the
106
* metadata section of the SCC into a pointer.
107
*
108
* \param[in] offset The offset to convert.
109
* \return A pointer. Raises a fatal assertion before returning NULL if the offset is invalid.
110
*/
111
virtual void *pointerFromOffsetInSharedCache(uintptr_t offset);
112
113
/**
114
* \brief Converts a pointer into the metadata section of the SCC into an offset, calculated
115
* from the end of the SCC.
116
*
117
* \param[in] ptr The pointer to convert.
118
* \return An offset. Raises a fatal assertion before returning 0 if the pointer is invalid.
119
*/
120
virtual uintptr_t offsetInSharedCacheFromPointer(void *ptr);
121
122
/**
123
* \brief Converts an offset into the ROMClass section into a J9ROMClass *.
124
*
125
* \param[in] offset The offset to convert.
126
* \return A J9ROMClass *. Raises a fatal assertion before returning NULL if the offset is invalid.
127
*/
128
virtual J9ROMClass *romClassFromOffsetInSharedCache(uintptr_t offset);
129
130
/**
131
* \brief Converts a J9ROMClass * pointer into the SCC into an offset.
132
*
133
* \param[in] romClass The J9ROMClass * to convert
134
* \return An offset. Raises a fatal assertion before returning 0 if the pointer is invalid.
135
*/
136
virtual uintptr_t offsetInSharedCacheFromROMClass(J9ROMClass *romClass);
137
138
/**
139
* \brief Converts an offset into the ROMClass section into a J9ROMMethod *.
140
*
141
* \param[in] offset The offset to convert
142
* \return A J9ROMMethod *. Raises a fatal assertion before returning NULL if the offset is invalid.
143
*/
144
virtual J9ROMMethod *romMethodFromOffsetInSharedCache(uintptr_t offset);
145
146
/**
147
* \brief Converts a J9ROMMethod * pointer into the SCC into an offset.
148
*
149
* \param[in] romMethod The J9ROMMethod * to convert
150
* \return An offset. Raises a fatal assertion before returning 0 if the pointer is invalid.
151
*/
152
virtual uintptr_t offsetInSharedCacheFromROMMethod(J9ROMMethod *romMethod);
153
154
/**
155
* \brief Converts an offset into the ROMClass section into a pointer.
156
*
157
* \param[in] offset The offset to convert
158
* \return A pointer. Raises a fatal assertion before returning NULL if the offset is invalid.
159
*/
160
virtual void *ptrToROMClassesSectionFromOffsetInSharedCache(uintptr_t offset);
161
162
/**
163
* \brief Converts a pointer into the ROM Classes section of the SCC into an offset.
164
*
165
* \param[in] ptr The pointer to convert
166
* \return An offset. Raises a fatal assertion before returning 0 if the pointer is invalid.
167
*/
168
virtual uintptr_t offsetInSharedCacheFromPtrToROMClassesSection(void *ptr);
169
170
171
virtual void persistIprofileInfo(TR::ResolvedMethodSymbol *, TR::Compilation *comp);
172
virtual void persistIprofileInfo(TR::ResolvedMethodSymbol *, TR_ResolvedMethod*, TR::Compilation *comp);
173
174
static const uint32_t maxClassChainLength = 32;
175
176
virtual bool canRememberClass(TR_OpaqueClassBlock *classPtr)
177
{
178
return rememberClass((J9Class *)classPtr, NULL, false) != NULL;
179
}
180
181
virtual uintptr_t *rememberClass(TR_OpaqueClassBlock *classPtr,
182
const AOTCacheClassChainRecord **classChainRecord = NULL)
183
{
184
return (uintptr_t *)rememberClass((J9Class *)classPtr, classChainRecord, true);
185
}
186
187
virtual uintptr_t *rememberClass(J9Class *clazz, const AOTCacheClassChainRecord **classChainRecord = NULL,
188
bool create = true);
189
190
virtual UDATA rememberDebugCounterName(const char *name);
191
virtual const char *getDebugCounterName(UDATA offset);
192
193
virtual bool classMatchesCachedVersion(J9Class *clazz, UDATA *chainData=NULL);
194
virtual bool classMatchesCachedVersion(TR_OpaqueClassBlock *classPtr, UDATA *chainData=NULL)
195
{
196
return classMatchesCachedVersion((J9Class *) classPtr, chainData);
197
}
198
199
virtual TR_OpaqueClassBlock *lookupClassFromChainAndLoader(uintptr_t *chainData, void *classLoader);
200
201
/**
202
* \brief Checks whether the specified pointer points into the metadata section
203
* of the shared cache.
204
*
205
* \param[in] ptr The pointer to check.
206
* \param[out] cacheOffset If ptr points into the shared cache and this parameter
207
* is not NULL the result of converting ptr into an offset will be
208
* returned here. If ptr does not point into the shared cache this
209
* parameter is ignored. The offset is calculated from the end of
210
* the SCC.
211
* \return True if the pointer points into the shared cache, false otherwise.
212
*/
213
virtual bool isPointerInSharedCache(void *ptr, uintptr_t *cacheOffset = NULL);
214
215
/**
216
* \brief Checks whether the specified offset, calculated from the end of the SCC,
217
* is within the metadata section of the shared cache.
218
*
219
* \param[in] offset The offset to check.
220
* \param[out] ptr If offset is within the shared cache and this parameter is not
221
* NULL the result of converting offset into a pointer will be returned
222
* here. If offset is not within the shared cache this parameter is ignored.
223
* \return True if the offset is within the shared cache, false otherwise.
224
*/
225
virtual bool isOffsetInSharedCache(uintptr_t encoded_offset, void *ptr = NULL);
226
227
/**
228
* \brief Checks whether the specified J9ROMClass exists in the SCC
229
*
230
* \param[in] romClass The J9ROMClass * to check
231
* \param[out] cacheOffset If the J9ROMClass is in the SCC and this parameter
232
* is not NULL the result of converting romClass into an offset will
233
* be returned here. If romClass does not point into the SCC, this
234
* parameter is ignored.
235
* \return True if romClass points into the SCC, false otherwise.
236
*/
237
virtual bool isROMClassInSharedCache(J9ROMClass *romClass, uintptr_t *cacheOffset = NULL);
238
239
/**
240
* \brief Checks whether the specified offset is within the ROMClass section
241
* of the shared cache.
242
*
243
* \param[in] offset The offset to check
244
* \param[out] romClass If offset is within the shared cache and this parameter is not
245
* NULL the result of converting offset into a J9ROMClass * will be returned
246
* here. If offset is not within the shared cache this parameter is ignored.
247
* \return True if the offset is within the shared cache, false otherwise.
248
*/
249
virtual bool isROMClassOffsetInSharedCache(uintptr_t offset, J9ROMClass **romClassPtr = NULL);
250
251
/**
252
* \brief Checks whether the specified J9ROMMethod exists in the SCC
253
*
254
* \param[in] romMethod The J9ROMMethod * to check
255
* \param[out] cacheOffset If the J9ROMMethod is in the SCC and this parameter
256
* is not NULL the result of converting romMethod into an offset will
257
* be returned here. If romMethod does not point into the SCC, this
258
* parameter is ignored.
259
* \return True if romMethod points into the SCC, false otherwise.
260
*/
261
virtual bool isROMMethodInSharedCache(J9ROMMethod *romMethod, uintptr_t *cacheOffset = NULL);
262
263
/**
264
* \brief Checks whether the specified offset is within the ROMClass section
265
* of the shared cache.
266
* \param[in] offset The offset to check
267
* \param[out] romMethodPtr If offset is within the shared cache and this parameter is not
268
* NULL the result of converting offset into a J9ROMMethod * will be returned
269
* here. If offset is not within the shared cache this parameter is ignored.
270
* \return True if the offset is within the shared cache, false otherwise.
271
*/
272
virtual bool isROMMethodOffsetInSharedCache(uintptr_t offset, J9ROMMethod **romMethodPtr = NULL);
273
274
/**
275
* \brief Checks whether the specified pointer points into the ROMClass section
276
* of the shared cache.
277
*
278
* \param[in] ptr The pointer to check
279
* \param[out] cacheOffset If ptr points into the shared cache and this parameter
280
* is not NULL the result of converting ptr into an offset will be
281
* returned here. If ptr does not point into the shared cache this
282
* parameter is ignored.
283
* \return True if the pointer points into the shared cache, false otherwise.
284
*/
285
virtual bool isPtrToROMClassesSectionInSharedCache(void *ptr, uintptr_t *cacheOffset = NULL);
286
287
/**
288
* \brief Checks whether the specified offset is within the ROMClass section
289
* of the shared cache.
290
*
291
* \param[in] offset The offset to check.
292
* \param[out] ptr If offset is within the shared cache and this parameter is not
293
* NULL the result of converting offset into a pointer will be returned
294
* here. If offset is not within the shared cache this parameter is ignored.
295
* \return True if the offset is within the shared cache, false otherwise.
296
*/
297
virtual bool isOffsetOfPtrToROMClassesSectionInSharedCache(uintptr_t offset, void **ptr = NULL);
298
299
J9ROMClass *startingROMClassOfClassChain(UDATA *classChain);
300
301
virtual uintptr_t getClassChainOffsetIdentifyingLoader(TR_OpaqueClassBlock *clazz, uintptr_t **classChain = NULL);
302
303
#if defined(J9VM_OPT_JITSERVER)
304
/**
305
* \brief Finds the offset in SCC of the class chain identifying the class loader of the given class.
306
* This is very similar to getClassChainOffsetIdentifyingLoader
307
* except that it will not fail the compilation if the offset is not valid.
308
* \return Returns the offset of the class chain that identifies given class or 0 is such offset is not valid.
309
*/
310
uintptr_t getClassChainOffsetIdentifyingLoaderNoFail(TR_OpaqueClassBlock *clazz, uintptr_t **classChain = NULL);
311
#endif /* defined(J9VM_OPT_JITSERVER) */
312
313
virtual const void *storeSharedData(J9VMThread *vmThread, char *key, J9SharedDataDescriptor *descriptor);
314
315
enum TR_J9SharedCacheDisabledReason
316
{
317
UNINITIALIZED,
318
NOT_DISABLED,
319
AOT_DISABLED,
320
AOT_HEADER_INVALID,
321
AOT_HEADER_FAILED_TO_ALLOCATE,
322
J9_SHARED_CACHE_FAILED_TO_ALLOCATE,
323
SHARED_CACHE_STORE_ERROR,
324
SHARED_CACHE_FULL,
325
// The following are probably equivalent to SHARED_CACHE_FULL -
326
// they could have failed because of no space but no error code is returned.
327
SHARED_CACHE_CLASS_CHAIN_STORE_FAILED,
328
AOT_HEADER_STORE_FAILED
329
};
330
331
static void setSharedCacheDisabledReason(TR_J9SharedCacheDisabledReason state) { _sharedCacheState = state; }
332
static TR_J9SharedCacheDisabledReason getSharedCacheDisabledReason() { return _sharedCacheState; }
333
static TR_YesNoMaybe isSharedCacheDisabledBecauseFull(TR::CompilationInfo *compInfo);
334
static void setStoreSharedDataFailedLength(UDATA length) {_storeSharedDataFailedLength = length; }
335
336
virtual J9SharedClassCacheDescriptor *getCacheDescriptorList();
337
338
protected:
339
/**
340
* \brief Helper method; used to check if a pointer is within the SCC
341
*
342
* \param[in] cacheDesc the J9SharedClassCacheDescriptor for the cache
343
* \param[in] ptr The pointer to check
344
* \return True if ptr is within the SCC, false otherwise
345
*/
346
static bool isPointerInCache(const J9SharedClassCacheDescriptor *cacheDesc, void *ptr);
347
348
/**
349
* \brief Helper method; used to check if an offset is within the SCC
350
*
351
* \param[in] cacheDesc the J9SharedClassCacheDescriptor for the cache
352
* \param[in] offset the offset to check
353
* \return True if offset is within the SCC, false otherwise
354
*/
355
static bool isOffsetInCache(const J9SharedClassCacheDescriptor *cacheDesc, uintptr_t offset);
356
357
static inline bool isOffsetFromStart(uintptr_t offset) { return ((offset & OFFSET_FROM_END) != OFFSET_FROM_END); }
358
static inline bool isOffsetFromEnd(uintptr_t offset) { return ((offset & OFFSET_FROM_END) == OFFSET_FROM_END); }
359
static inline uintptr_t encodeOffsetFromStart(uintptr_t offset) { return (offset << 1); }
360
static inline uintptr_t decodeOffsetFromStart(uintptr_t offset) { return (offset >> 1); }
361
static inline uintptr_t encodeOffsetFromEnd(uintptr_t offset) { return ((offset << 1) | OFFSET_FROM_END); }
362
static inline uintptr_t decodeOffsetFromEnd(uintptr_t offset) { return (offset >> 1); }
363
364
private:
365
// This class is intended to be a POD; keep it simple.
366
struct SCCHint
367
{
368
SCCHint() : flags(0), data(0) {}
369
void clear() { flags = 0; data = 0; }
370
uint16_t flags;
371
uint16_t data;
372
};
373
374
static const uintptr_t OFFSET_FROM_END = 0x1;
375
376
J9JITConfig *jitConfig() { return _jitConfig; }
377
J9JavaVM *javaVM() { return _javaVM; }
378
TR_J9VMBase *fe() { return _fe; }
379
J9SharedClassConfig *sharedCacheConfig() { return _sharedCacheConfig; }
380
381
TR_AOTStats *aotStats() { return _aotStats; }
382
383
void log(char *format, ...);
384
385
SCCHint getHint(J9VMThread * vmThread, J9Method *method);
386
387
void convertUnsignedOffsetToASCII(UDATA offset, char *myBuffer);
388
void createClassKey(UDATA classOffsetInCache, char *key, uint32_t & keyLength);
389
390
uint32_t numInterfacesImplemented(J9Class *clazz);
391
392
bool writeClassToChain(J9ROMClass *romClass, UDATA * & chainPtr);
393
bool writeClassesToChain(J9Class *clazz, int32_t numSuperclasses, UDATA * & chainPtr);
394
bool writeInterfacesToChain(J9Class *clazz, UDATA * & chainPtr);
395
bool fillInClassChain(J9Class *clazz, UDATA *chainData, uint32_t chainLength,
396
uint32_t numSuperclasses, uint32_t numInterfaces);
397
398
bool romclassMatchesCachedVersion(J9ROMClass *romClass, UDATA * & chainPtr, UDATA *chainEnd);
399
UDATA *findChainForClass(J9Class *clazz, const char *key, uint32_t keyLength);
400
401
/**
402
* \brief Helper Method; Converts an offset into the ROMClass section into a pointer.
403
*
404
* \param offset The offset to convert
405
* \return A pointer. Raises a fatal assertion before returning NULL if the offset is invalid.
406
*/
407
void *romStructureFromOffsetInSharedCache(uintptr_t offset);
408
409
/**
410
* \brief Converts a pointer into the ROMClass section of the SCC into an offset.
411
*
412
* \param[in] romStructure The pointer to convert.
413
* \return An offset. Raises a fatal assertion before returning 0 if the pointer is invalid.
414
*/
415
uintptr_t offsetInSharedcacheFromROMStructure(void *romStructure);
416
417
/**
418
* \brief Checks whether the specified pointer points into the ROMClass section
419
* of the shared cache.
420
*
421
* \param[in] romStructure The pointer to check
422
* \param[out] cacheOffset If romStructure points into the shared cache and this parameter
423
* is not NULL the result of converting romStructure into an offset will be
424
* returned here. If romStructure does not point into the shared cache this
425
* parameter is ignored.
426
* \return True if the pointer points into the shared cache, false otherwise.
427
*/
428
bool isROMStructureInSharedCache(void *romStructure, uintptr_t *cacheOffset = NULL);
429
430
/**
431
* \brief Checks whether the specified offset is within the ROMClass section
432
* of the shared cache.
433
*
434
* \param[in] offset The offset to check.
435
* \param[out] romStructurePtr If offset is within the shared cache and this parameter is not
436
* NULL the result of converting offset into a pointer will be returned
437
* here. If offset is not within the shared cache this parameter is ignored.
438
* \return True if the offset is within the shared cache, false otherwise.
439
*/
440
bool isROMStructureOffsetInSharedCache(uintptr_t encoded_offset, void **romStructurePtr = NULL);
441
442
/**
443
* \brief Validates the provided class chain. This method modifies the chainPtr arg.
444
*
445
* \param[in] romClass The J9ROMClass of the class whose chain is to be validated
446
* \param[in] clazz The TR_OpaqueClassBlock of the class whose chain is to be validated
447
* \param[in,out] chainPtr Pointer to the start of the class chain passed by reference
448
* \param[in] chainEnd Pointer to the end of the class chain
449
* \return true if validation succeeded, false otherwise.
450
*/
451
bool validateClassChain(J9ROMClass *romClass, TR_OpaqueClassBlock *clazz, UDATA * & chainPtr, UDATA *chainEnd);
452
453
/**
454
* \brief Validates the super classes portion of the class chain. This method modifies the chainPtr arg.
455
*
456
* \param[in] clazz The TR_OpaqueClassBlock of the class whose chain is to be validated
457
* \param[in,out] chainPtr Pointer to the start of super classes portion of the class chain passed by reference
458
* \param[in] chainEnd Pointer to the end of the class chain
459
* \return true if validation succeeded, false otherwise.
460
*/
461
bool validateSuperClassesInClassChain(TR_OpaqueClassBlock *clazz, UDATA * & chainPtr, UDATA *chainEnd);
462
463
/**
464
* \brief Validates the interfaces portion of the class chain. This method modifies the chainPtr arg.
465
*
466
* \param[in] clazz The TR_OpaqueClassBlock of the class whose chain is to be validated
467
* \param[in,out] chainPtr Pointer to the start of interfaces portion of the class chain passed by reference
468
* \param[in] chainEnd Pointer to the end of the class chain
469
* \return true if validation succeeded, false otherwise.
470
*/
471
bool validateInterfacesInClassChain(TR_OpaqueClassBlock *clazz, UDATA * & chainPtr, UDATA *chainEnd);
472
473
/**
474
* \brief Helper method; used to check if a pointer is within the metadata section of the SCC
475
* \param[in] cacheDesc the J9SharedClassCacheDescriptor for the cache
476
* \param[in] ptr The pointer to check
477
* \return True if ptr is within the metadata section of the SCC, false otherwise
478
*/
479
virtual bool isPointerInMetadataSectionInCache(const J9SharedClassCacheDescriptor *cacheDesc, void *ptr);
480
481
/**
482
* \brief Helper method; used to check if an offset is within the metadata section of the SCC
483
*
484
* \param[in] cacheDesc the J9SharedClassCacheDescriptor for the cache
485
* \param[in] offset the offset to check
486
* \return True if offset is within the metadata section of the SCC, false otherwise
487
*/
488
virtual bool isOffsetInMetadataSectionInCache(const J9SharedClassCacheDescriptor *cacheDesc, uintptr_t offset);
489
490
/**
491
* \brief Helper method; used to check if a pointer is within the ROMClass section of the SCC
492
* \param[in] cacheDesc the J9SharedClassCacheDescriptor for the cache
493
* \param[in] ptr The pointer to check
494
* \return True if ptr is within the ROMClass section of the SCC, false otherwise
495
*/
496
virtual bool isPointerInROMClassesSectionInCache(const J9SharedClassCacheDescriptor *cacheDesc, void *ptr);
497
498
/**
499
* \brief Helper method; used to check if an offset is within the ROMClass section of the SCC
500
*
501
* \param[in] cacheDesc the J9SharedClassCacheDescriptor for the cache
502
* \param[in] offset the offset to check
503
* \return True if offset is within the ROMClass section of the SCC, false otherwise
504
*/
505
virtual bool isOffsetinROMClassesSectionInCache(const J9SharedClassCacheDescriptor *cacheDesc, uintptr_t offset);
506
507
/**
508
* \brief Gets the cached result of a prior class chain validation
509
*
510
* \param[in] clazz The class to be validated
511
*
512
* \return The cached CCVResult; CCVResult::notYetValidated if result does not exist.
513
*/
514
const CCVResult getCachedCCVResult(TR_OpaqueClassBlock *clazz);
515
516
/**
517
* \brief Caches the result of a class chain validation
518
*
519
* \param[in] clazz The class to be validated
520
* \param[in] result The result represented as a CCVResult
521
*
522
* \return The result of the insertion
523
*/
524
bool cacheCCVResult(TR_OpaqueClassBlock *clazz, CCVResult result);
525
526
uint16_t _initialHintSCount;
527
uint16_t _hintsEnabledMask;
528
529
J9JavaVM *_javaVM;
530
J9JITConfig *_jitConfig;
531
TR_J9VMBase *_fe;
532
TR::CompilationInfo *_compInfo;
533
534
TR_AOTStats *_aotStats;
535
J9SharedClassConfig *_sharedCacheConfig;
536
UDATA _numDigitsForCacheOffsets;
537
538
uint32_t _logLevel;
539
bool _verboseHints;
540
541
static TR_J9SharedCacheDisabledReason _sharedCacheState;
542
static TR_YesNoMaybe _sharedCacheDisabledBecauseFull;
543
static UDATA _storeSharedDataFailedLength;
544
};
545
546
547
#if defined(J9VM_OPT_JITSERVER)
548
/**
549
* \class TR_J9JITServerSharedCache
550
* \brief Class used by JITServer for querying client-side SharedCache information
551
*
552
* This class is an extension of the TR_J9SharedCache class which overrides a number
553
* of TR_J9SharedCache's APIs. TR_J9JITServerSharedCache is used by JITServer and
554
* the overridden APIs mostly send remote messages to JITClient to query information from
555
* the TR_J9SharedCache on the client. The information is needed for JITServer to
556
* compile code that is compatible with the client-side VM. To minimize the
557
* number of remote messages as a way to optimize JITServer performance, a
558
* lot of client-side TR_J9SharedCache information are cached on JITServer.
559
*/
560
561
class TR_J9JITServerSharedCache : public TR_J9SharedCache
562
{
563
public:
564
TR_ALLOC(TR_Memory::SharedCache)
565
566
TR_J9JITServerSharedCache(TR_J9VMBase *fe);
567
568
virtual bool isHint(TR_ResolvedMethod *, TR_SharedCacheHint, uint16_t *dataField = NULL) override { TR_ASSERT_FATAL(false, "called"); return false;}
569
virtual bool isHint(J9Method *, TR_SharedCacheHint, uint16_t *dataField = NULL) override { TR_ASSERT_FATAL(false, "called"); return false;}
570
virtual uint16_t getAllEnabledHints(J9Method *method) override { TR_ASSERT_FATAL(false, "called"); return 0;}
571
virtual void addHint(J9Method *, TR_SharedCacheHint) override;
572
virtual bool isMostlyFull() override { TR_ASSERT_FATAL(false, "called"); return false;}
573
574
virtual uintptr_t *rememberClass(J9Class *clazz, const AOTCacheClassChainRecord **classChainRecord = NULL,
575
bool create = true) override;
576
577
virtual UDATA rememberDebugCounterName(const char *name) override { TR_ASSERT_FATAL(false, "called"); return 0;}
578
virtual const char *getDebugCounterName(UDATA offset) override { TR_ASSERT_FATAL(false, "called"); return NULL;}
579
580
virtual bool classMatchesCachedVersion(J9Class *clazz, UDATA *chainData=NULL) override { TR_ASSERT_FATAL(false, "called"); return false;}
581
582
virtual TR_OpaqueClassBlock *lookupClassFromChainAndLoader(uintptr_t *chainData, void *classLoader) override { TR_ASSERT_FATAL(false, "called"); return NULL;}
583
584
static void setSharedCacheDisabledReason(TR_J9SharedCacheDisabledReason state) { TR_ASSERT_FATAL(false, "called"); }
585
static TR_J9SharedCacheDisabledReason getSharedCacheDisabledReason() { TR_ASSERT_FATAL(false, "called"); return TR_J9SharedCache::TR_J9SharedCacheDisabledReason::UNINITIALIZED;}
586
static TR_YesNoMaybe isSharedCacheDisabledBecauseFull(TR::CompilationInfo *compInfo) { TR_ASSERT_FATAL(false, "called"); return TR_no;}
587
static void setStoreSharedDataFailedLength(UDATA length) { TR_ASSERT_FATAL(false, "called"); }
588
589
virtual uintptr_t getClassChainOffsetIdentifyingLoader(TR_OpaqueClassBlock *clazz, uintptr_t **classChain = NULL) override;
590
591
virtual J9SharedClassCacheDescriptor *getCacheDescriptorList();
592
593
void setStream(JITServer::ServerStream *stream) { _stream = stream; }
594
virtual const void *storeSharedData(J9VMThread *vmThread, char *key, J9SharedDataDescriptor *descriptor);
595
596
private:
597
598
virtual bool isPointerInMetadataSectionInCache(const J9SharedClassCacheDescriptor *cacheDesc, void *ptr)
599
{
600
return isPointerInCache(cacheDesc, ptr);
601
}
602
virtual bool isOffsetInMetadataSectionInCache(const J9SharedClassCacheDescriptor *cacheDesc, uintptr_t offset)
603
{
604
return (isOffsetFromEnd(offset) && isOffsetInCache(cacheDesc, offset));
605
}
606
virtual bool isPointerInROMClassesSectionInCache(const J9SharedClassCacheDescriptor *cacheDesc, void *ptr)
607
{
608
return isPointerInCache(cacheDesc, ptr);
609
}
610
virtual bool isOffsetinROMClassesSectionInCache(const J9SharedClassCacheDescriptor *cacheDesc, uintptr_t offset)
611
{
612
return (isOffsetFromStart(offset) && isOffsetInCache(cacheDesc, offset));
613
}
614
615
JITServer::ServerStream *_stream;
616
};
617
#endif /* defined(J9VM_OPT_JITSERVER) */
618
619
#endif
620
621