Skip to content

Commit

Permalink
Merge pull request #4801 from dmitry-ten/sharedcache-query
Browse files Browse the repository at this point in the history
Add a new method for TR_J9SharedCache
  • Loading branch information
Irwin D'Souza committed Feb 21, 2019
2 parents e53970e + f6f7fb6 commit 5bb38eb
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 92 deletions.
30 changes: 6 additions & 24 deletions runtime/compiler/arm/codegen/J9AheadOfTimeCompile.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2018 IBM Corp. and others
* Copyright (c) 2000, 2019 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -344,11 +344,7 @@ uint8_t *J9::ARM::AheadOfTimeCompile::initializeAOTRelocationHeader(TR::Iterated
TR_OpaqueMethodBlock *j9method = (TR_OpaqueMethodBlock *) aconstNode->getAddress();
TR_OpaqueClassBlock *j9class = fej9->getClassFromMethodBlock(j9method);

void *loaderForClazz = fej9->getClassLoader(j9class);
void *classChainIdentifyingLoaderForClazz = sharedCache->persistentClassLoaderTable()->lookupClassChainAssociatedWithClassLoader(loaderForClazz);
//traceMsg(comp(),"classChainIdentifyingLoaderForClazz %p\n", classChainIdentifyingLoaderForClazz);
uintptrj_t classChainOffsetInSharedCache = (uintptrj_t) sharedCache->offsetInSharedCacheFromPointer(classChainIdentifyingLoaderForClazz);
//traceMsg(comp(),"classChainOffsetInSharedCache %p\n", classChainOffsetInSharedCache);
uintptrj_t classChainOffsetInSharedCache = sharedCache->getClassChainOffsetOfIdentifyingLoaderForClazzInSharedCache(j9class);
*(uintptrj_t *)cursor = classChainOffsetInSharedCache;
cursor += SIZEPOINTER;

Expand All @@ -370,12 +366,7 @@ uint8_t *J9::ARM::AheadOfTimeCompile::initializeAOTRelocationHeader(TR::Iterated
TR_OpaqueClassBlock *j9class = (TR_OpaqueClassBlock *) aconstNode->getAddress();
//traceMsg(comp(),"j9class %p\n", j9class);

void *loaderForClazz = fej9->getClassLoader(j9class);
//traceMsg(comp(),"loaderForClazz %p\n", loaderForClazz);
void *classChainIdentifyingLoaderForClazz = sharedCache->persistentClassLoaderTable()->lookupClassChainAssociatedWithClassLoader(loaderForClazz);
//traceMsg(comp(),"classChainIdentifyingLoaderForClazz %p\n", classChainIdentifyingLoaderForClazz);
uintptrj_t classChainOffsetInSharedCache = (uintptrj_t) sharedCache->offsetInSharedCacheFromPointer(classChainIdentifyingLoaderForClazz);
//traceMsg(comp(),"classChainOffsetInSharedCache %p\n", classChainOffsetInSharedCache);
uintptrj_t classChainOffsetInSharedCache = sharedCache->getClassChainOffsetOfIdentifyingLoaderForClazzInSharedCache(j9class);
*(uintptrj_t *)cursor = classChainOffsetInSharedCache;
cursor += SIZEPOINTER;

Expand All @@ -400,9 +391,7 @@ uint8_t *J9::ARM::AheadOfTimeCompile::initializeAOTRelocationHeader(TR::Iterated
*(uintptrj_t *)cursor = inlinedSiteIndex;
cursor += SIZEPOINTER;

void *loaderForClazz = fej9->getClassLoader(j9class);
void *classChainIdentifyingLoaderForClazz = sharedCache->persistentClassLoaderTable()->lookupClassChainAssociatedWithClassLoader(loaderForClazz);
uintptrj_t classChainOffsetInSharedCache = (uintptrj_t) sharedCache->offsetInSharedCacheFromPointer(classChainIdentifyingLoaderForClazz);
uintptrj_t classChainOffsetInSharedCache = sharedCache->getClassChainOffsetOfIdentifyingLoaderForClazzInSharedCache(j9class);
*(uintptrj_t *)cursor = classChainOffsetInSharedCache;
cursor += SIZEPOINTER;

Expand Down Expand Up @@ -501,12 +490,7 @@ uint8_t *J9::ARM::AheadOfTimeCompile::initializeAOTRelocationHeader(TR::Iterated
*(uintptrj_t *) cursor = (uintptrj_t) romClassOffsetInSharedCache;
cursor += SIZEPOINTER;

void *loaderForClazz = fej9->getClassLoader(inlinedCodeClass);
void *classChainIdentifyingLoaderForClazz =
sharedCache->persistentClassLoaderTable()->lookupClassChainAssociatedWithClassLoader(loaderForClazz);
//traceMsg(comp(),"classChainIdentifyingLoaderForClazz %p\n", classChainIdentifyingLoaderForClazz);
uintptrj_t classChainOffsetInSharedCache = (uintptrj_t) sharedCache->offsetInSharedCacheFromPointer(classChainIdentifyingLoaderForClazz);
//traceMsg(comp(),"classChainOffsetInSharedCache %p\n", classChainOffsetInSharedCache);
uintptrj_t classChainOffsetInSharedCache = sharedCache->getClassChainOffsetOfIdentifyingLoaderForClazzInSharedCache(inlinedCodeClass);
*(uintptrj_t *) cursor = classChainOffsetInSharedCache;
cursor += SIZEPOINTER;

Expand Down Expand Up @@ -628,9 +612,7 @@ uint8_t *J9::ARM::AheadOfTimeCompile::initializeAOTRelocationHeader(TR::Iterated
TR_OpaqueClassBlock *classToValidate = aotCI->_clazz;

//store the classchain's offset for the classloader for the class
void *loaderForClazzToValidate = fej9->getClassLoader(classToValidate);
void *classChainIdentifyingLoaderForClazzToValidate = sharedCache->persistentClassLoaderTable()->lookupClassChainAssociatedWithClassLoader(loaderForClazzToValidate);
uintptrj_t classChainOffsetInSharedCacheForCL = (uintptrj_t) sharedCache->offsetInSharedCacheFromPointer(classChainIdentifyingLoaderForClazzToValidate);
uintptrj_t classChainOffsetInSharedCacheForCL = sharedCache->getClassChainOffsetOfIdentifyingLoaderForClazzInSharedCache(classToValidate);
*(uintptrj_t *)cursor = classChainOffsetInSharedCacheForCL;
cursor += SIZEPOINTER;

Expand Down
10 changes: 10 additions & 0 deletions runtime/compiler/env/J9SharedCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "env/VMJ9.h"
#include "env/j9method.h"
#include "runtime/IProfiler.hpp"
#include "env/ClassLoaderTable.hpp"

#define LOG(n,c) \
if (_logLevel >= (3*n)) \
Expand Down Expand Up @@ -773,3 +774,12 @@ TR_J9SharedCache::lookupClassFromChainAndLoader(uintptrj_t *chainData, void *cla

return NULL;
}

uintptrj_t
TR_J9SharedCache::getClassChainOffsetOfIdentifyingLoaderForClazzInSharedCache(TR_OpaqueClassBlock *clazz)
{
void *loaderForClazz = _fe->getClassLoader(clazz);
void *classChainIdentifyingLoaderForClazz = persistentClassLoaderTable()->lookupClassChainAssociatedWithClassLoader(loaderForClazz);
uintptrj_t classChainOffsetInSharedCache = (uintptrj_t) offsetInSharedCacheFromPointer(classChainIdentifyingLoaderForClazz);
return classChainOffsetInSharedCache;
}
2 changes: 2 additions & 0 deletions runtime/compiler/env/J9SharedCache.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ class TR_J9SharedCache : public TR_SharedCache

J9ROMClass *startingROMClassOfClassChain(UDATA *classChain);

virtual uintptrj_t getClassChainOffsetOfIdentifyingLoaderForClazzInSharedCache(TR_OpaqueClassBlock *clazz);

enum TR_J9SharedCacheDisabledReason
{
UNINITIALIZED,
Expand Down
4 changes: 3 additions & 1 deletion runtime/compiler/env/SharedCache.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2018 IBM Corp. and others
* Copyright (c) 2000, 2019 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -50,6 +50,8 @@ class TR_SharedCache

virtual TR_OpaqueClassBlock *lookupClassFromChainAndLoader(uintptrj_t *cinaData, void *loader) { return NULL; }

virtual uintptrj_t getClassChainOffsetOfIdentifyingLoaderForClazzInSharedCache(TR_OpaqueClassBlock *clazz) { return 0; }

void setPersistentClassLoaderTable(TR_PersistentClassLoaderTable *table) { _persistentClassLoaderTable = table; }

TR_PersistentClassLoaderTable *persistentClassLoaderTable() { return _persistentClassLoaderTable; }
Expand Down
25 changes: 6 additions & 19 deletions runtime/compiler/p/codegen/J9AheadOfTimeCompile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -512,9 +512,7 @@ uint8_t *J9::Power::AheadOfTimeCompile::initializeAOTRelocationHeader(TR::Iterat
TR_OpaqueMethodBlock *j9method = (TR_OpaqueMethodBlock *) aconstNode->getAddress();
TR_OpaqueClassBlock *j9class = fej9->getClassFromMethodBlock(j9method);

void *loaderForClazz = fej9->getClassLoader(j9class);
void *classChainIdentifyingLoaderForClazz = sharedCache->persistentClassLoaderTable()->lookupClassChainAssociatedWithClassLoader(loaderForClazz);
uintptrj_t classChainOffsetInSharedCache = (uintptrj_t) sharedCache->offsetInSharedCacheFromPointer(classChainIdentifyingLoaderForClazz);
uintptrj_t classChainOffsetInSharedCache = sharedCache->getClassChainOffsetOfIdentifyingLoaderForClazzInSharedCache(j9class);
*(uintptrj_t *)cursor = classChainOffsetInSharedCache;
cursor += SIZEPOINTER;

Expand All @@ -535,9 +533,7 @@ uint8_t *J9::Power::AheadOfTimeCompile::initializeAOTRelocationHeader(TR::Iterat

TR_OpaqueClassBlock *j9class = (TR_OpaqueClassBlock *) aconstNode->getAddress();

void *loaderForClazz = fej9->getClassLoader(j9class);
void *classChainIdentifyingLoaderForClazz = sharedCache->persistentClassLoaderTable()->lookupClassChainAssociatedWithClassLoader(loaderForClazz);
uintptrj_t classChainOffsetInSharedCache = (uintptrj_t) sharedCache->offsetInSharedCacheFromPointer(classChainIdentifyingLoaderForClazz);
uintptrj_t classChainOffsetInSharedCache = sharedCache->getClassChainOffsetOfIdentifyingLoaderForClazzInSharedCache(j9class);
*(uintptrj_t *)cursor = classChainOffsetInSharedCache;
cursor += SIZEPOINTER;

Expand All @@ -563,9 +559,7 @@ uint8_t *J9::Power::AheadOfTimeCompile::initializeAOTRelocationHeader(TR::Iterat
*(uintptrj_t *)cursor = inlinedSiteIndex;
cursor += SIZEPOINTER;

void *loaderForClazz = fej9->getClassLoader(j9class);
void *classChainIdentifyingLoaderForClazz = sharedCache->persistentClassLoaderTable()->lookupClassChainAssociatedWithClassLoader(loaderForClazz);
uintptrj_t classChainOffsetInSharedCache = (uintptrj_t) sharedCache->offsetInSharedCacheFromPointer(classChainIdentifyingLoaderForClazz);
uintptrj_t classChainOffsetInSharedCache = sharedCache->getClassChainOffsetOfIdentifyingLoaderForClazzInSharedCache(j9class);
*(uintptrj_t *)cursor = classChainOffsetInSharedCache;
cursor += SIZEPOINTER;

Expand Down Expand Up @@ -684,10 +678,7 @@ uint8_t *J9::Power::AheadOfTimeCompile::initializeAOTRelocationHeader(TR::Iterat
*(uintptrj_t *) cursor = (uintptrj_t) romClassOffsetInSharedCache;
cursor += SIZEPOINTER;

void *loaderForClazz = fej9->getClassLoader(inlinedCodeClass);
void *classChainIdentifyingLoaderForClazz =
sharedCache->persistentClassLoaderTable()->lookupClassChainAssociatedWithClassLoader(loaderForClazz);
uintptrj_t classChainOffsetInSharedCache = (uintptrj_t) sharedCache->offsetInSharedCacheFromPointer(classChainIdentifyingLoaderForClazz);
uintptrj_t classChainOffsetInSharedCache = sharedCache->getClassChainOffsetOfIdentifyingLoaderForClazzInSharedCache(inlinedCodeClass);
*(uintptrj_t *) cursor = classChainOffsetInSharedCache;
cursor += SIZEPOINTER;

Expand Down Expand Up @@ -832,9 +823,7 @@ uint8_t *J9::Power::AheadOfTimeCompile::initializeAOTRelocationHeader(TR::Iterat
void *classChainForClassToValidate = record->_classChain;

//store the classchain's offset for the classloader for the class
void *loaderForClazzToValidate = fej9->getClassLoader(classToValidate);
void *classChainIdentifyingLoaderForClazzToValidate = sharedCache->persistentClassLoaderTable()->lookupClassChainAssociatedWithClassLoader(loaderForClazzToValidate);
uintptrj_t classChainOffsetInSharedCacheForCL = reinterpret_cast<uintptrj_t>(sharedCache->offsetInSharedCacheFromPointer(classChainIdentifyingLoaderForClazzToValidate));
uintptrj_t classChainOffsetInSharedCacheForCL = sharedCache->getClassChainOffsetOfIdentifyingLoaderForClazzInSharedCache(classToValidate);

//store the classchain's offset for the class that needs to be validated in the second run
void* classChainOffsetInSharedCache = sharedCache->offsetInSharedCacheFromPointer(classChainForClassToValidate);
Expand Down Expand Up @@ -1390,9 +1379,7 @@ uint8_t *J9::Power::AheadOfTimeCompile::initializeAOTRelocationHeader(TR::Iterat
TR_OpaqueClassBlock *classToValidate = aotCI->_clazz;

//store the classchain's offset for the classloader for the class
void *loaderForClazzToValidate = fej9->getClassLoader(classToValidate);
void *classChainIdentifyingLoaderForClazzToValidate = sharedCache->persistentClassLoaderTable()->lookupClassChainAssociatedWithClassLoader(loaderForClazzToValidate);
uintptrj_t classChainOffsetInSharedCacheForCL = (uintptrj_t) sharedCache->offsetInSharedCacheFromPointer(classChainIdentifyingLoaderForClazzToValidate);
uintptrj_t classChainOffsetInSharedCacheForCL = sharedCache->getClassChainOffsetOfIdentifyingLoaderForClazzInSharedCache(classToValidate);
*(uintptrj_t *)cursor = classChainOffsetInSharedCacheForCL;
cursor += SIZEPOINTER;

Expand Down
30 changes: 6 additions & 24 deletions runtime/compiler/x/codegen/J9AheadOfTimeCompile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,7 @@ uint8_t *J9::X86::AheadOfTimeCompile::initializeAOTRelocationHeader(TR::Iterated
TR_OpaqueMethodBlock *j9method = (TR_OpaqueMethodBlock *) aconstNode->getAddress();
TR_OpaqueClassBlock *j9class = fej9->getClassFromMethodBlock(j9method);

void *loaderForClazz = fej9->getClassLoader(j9class);
void *classChainIdentifyingLoaderForClazz = sharedCache->persistentClassLoaderTable()->lookupClassChainAssociatedWithClassLoader(loaderForClazz);
//traceMsg(comp(),"classChainIdentifyingLoaderForClazz %p\n", classChainIdentifyingLoaderForClazz);
uintptrj_t classChainOffsetInSharedCache = (uintptrj_t) sharedCache->offsetInSharedCacheFromPointer(classChainIdentifyingLoaderForClazz);
//traceMsg(comp(),"classChainOffsetInSharedCache %p\n", classChainOffsetInSharedCache);
uintptrj_t classChainOffsetInSharedCache = sharedCache->getClassChainOffsetOfIdentifyingLoaderForClazzInSharedCache(j9class);
*(uintptrj_t *)cursor = classChainOffsetInSharedCache;
cursor += SIZEPOINTER;

Expand All @@ -204,11 +200,7 @@ uint8_t *J9::X86::AheadOfTimeCompile::initializeAOTRelocationHeader(TR::Iterated

TR_OpaqueClassBlock *j9class = (TR_OpaqueClassBlock *) aconstNode->getAddress();

void *loaderForClazz = fej9->getClassLoader(j9class);
void *classChainIdentifyingLoaderForClazz = sharedCache->persistentClassLoaderTable()->lookupClassChainAssociatedWithClassLoader(loaderForClazz);
//traceMsg(comp(),"classChainIdentifyingLoaderForClazz %p\n", classChainIdentifyingLoaderForClazz);
uintptrj_t classChainOffsetInSharedCache = (uintptrj_t) sharedCache->offsetInSharedCacheFromPointer(classChainIdentifyingLoaderForClazz);
//traceMsg(comp(),"classChainOffsetInSharedCache %p\n", classChainOffsetInSharedCache);
uintptrj_t classChainOffsetInSharedCache = sharedCache->getClassChainOffsetOfIdentifyingLoaderForClazzInSharedCache(j9class);
*(uintptrj_t *)cursor = classChainOffsetInSharedCache;
cursor += SIZEPOINTER;

Expand All @@ -229,9 +221,7 @@ uint8_t *J9::X86::AheadOfTimeCompile::initializeAOTRelocationHeader(TR::Iterated
*(uintptrj_t *)cursor = inlinedSiteIndex;
cursor += SIZEPOINTER;

void *loaderForClazz = fej9->getClassLoader(j9class);
void *classChainIdentifyingLoaderForClazz = sharedCache->persistentClassLoaderTable()->lookupClassChainAssociatedWithClassLoader(loaderForClazz);
uintptrj_t classChainOffsetInSharedCache = (uintptrj_t) sharedCache->offsetInSharedCacheFromPointer(classChainIdentifyingLoaderForClazz);
uintptrj_t classChainOffsetInSharedCache = sharedCache->getClassChainOffsetOfIdentifyingLoaderForClazzInSharedCache(j9class);
*(uintptrj_t *)cursor = classChainOffsetInSharedCache;
cursor += SIZEPOINTER;

Expand Down Expand Up @@ -351,11 +341,7 @@ uint8_t *J9::X86::AheadOfTimeCompile::initializeAOTRelocationHeader(TR::Iterated
*(uintptrj_t *)cursor = (uintptrj_t) romClassOffsetInSharedCache;
cursor += SIZEPOINTER;

void *loaderForClazz = fej9->getClassLoader(inlinedCodeClass);
void *classChainIdentifyingLoaderForClazz = sharedCache->persistentClassLoaderTable()->lookupClassChainAssociatedWithClassLoader(loaderForClazz);
//traceMsg(comp(),"classChainIdentifyingLoaderForClazz %p\n", classChainIdentifyingLoaderForClazz);
uintptrj_t classChainOffsetInSharedCache = (uintptrj_t) sharedCache->offsetInSharedCacheFromPointer(classChainIdentifyingLoaderForClazz);
//traceMsg(comp(),"classChainOffsetInSharedCache %p\n", classChainOffsetInSharedCache);
uintptrj_t classChainOffsetInSharedCache = sharedCache->getClassChainOffsetOfIdentifyingLoaderForClazzInSharedCache(inlinedCodeClass);
*(uintptrj_t *)cursor = classChainOffsetInSharedCache;
cursor += SIZEPOINTER;

Expand Down Expand Up @@ -640,9 +626,7 @@ uint8_t *J9::X86::AheadOfTimeCompile::initializeAOTRelocationHeader(TR::Iterated
void *classChainForClassToValidate = record->_classChain;

//store the classchain's offset for the classloader for the class
void *loaderForClazzToValidate = fej9->getClassLoader(classToValidate);
void *classChainIdentifyingLoaderForClazzToValidate = sharedCache->persistentClassLoaderTable()->lookupClassChainAssociatedWithClassLoader(loaderForClazzToValidate);
uintptrj_t classChainOffsetInSharedCacheForCL = reinterpret_cast<uintptrj_t>(sharedCache->offsetInSharedCacheFromPointer(classChainIdentifyingLoaderForClazzToValidate));
uintptrj_t classChainOffsetInSharedCacheForCL = sharedCache->getClassChainOffsetOfIdentifyingLoaderForClazzInSharedCache(classToValidate);

//store the classchain's offset for the class that needs to be validated in the second run
void* classChainOffsetInSharedCache = sharedCache->offsetInSharedCacheFromPointer(classChainForClassToValidate);
Expand Down Expand Up @@ -1173,9 +1157,7 @@ uint8_t *J9::X86::AheadOfTimeCompile::initializeAOTRelocationHeader(TR::Iterated
TR_OpaqueClassBlock *classToValidate = aotCI->_clazz;

//store the classchain's offset for the classloader for the class
void *loaderForClazzToValidate = fej9->getClassLoader(classToValidate);
void *classChainIdentifyingLoaderForClazzToValidate = sharedCache->persistentClassLoaderTable()->lookupClassChainAssociatedWithClassLoader(loaderForClazzToValidate);
uintptrj_t classChainOffsetInSharedCacheForCL = (uintptrj_t) sharedCache->offsetInSharedCacheFromPointer(classChainIdentifyingLoaderForClazzToValidate);
uintptrj_t classChainOffsetInSharedCacheForCL = sharedCache->getClassChainOffsetOfIdentifyingLoaderForClazzInSharedCache(classToValidate);
*(uintptrj_t *)cursor = classChainOffsetInSharedCacheForCL;
cursor += SIZEPOINTER;

Expand Down

0 comments on commit 5bb38eb

Please sign in to comment.