|
43 | 43 | #include "control/RecompilationInfo.hpp" |
44 | 44 | #include "env/ClassLoaderTable.hpp" |
45 | 45 | #include "env/j9method.h" |
| 46 | +#include "env/J9RetainedMethodSet.hpp" |
46 | 47 | #include "env/TRMemory.hpp" |
47 | 48 | #include "env/VMJ9.h" |
48 | 49 | #include "env/VMAccessCriticalSection.hpp" |
@@ -186,6 +187,7 @@ J9::Compilation::Compilation(int32_t id, |
186 | 187 | _j9VMThread(j9vmThread), |
187 | 188 | _monitorAutos(m), |
188 | 189 | _monitorAutoSymRefsInCompiledMethod(getTypedAllocator<TR::SymbolReference*>(self()->allocator())), |
| 190 | + _keepaliveClasses(heapMemoryRegion), |
189 | 191 | _classForOSRRedefinition(m), |
190 | 192 | _classForStaticFinalFieldModification(m), |
191 | 193 | _profileInfo(NULL), |
@@ -232,6 +234,10 @@ J9::Compilation::Compilation(int32_t id, |
232 | 234 | for (int i = 0; i < CACHED_CLASS_POINTER_COUNT; i++) |
233 | 235 | _cachedClassPointers[i] = NULL; |
234 | 236 |
|
| 237 | + if (!self()->ilGenRequest().details().supportsInvalidation()) |
| 238 | + { |
| 239 | + self()->getOptions()->setOption(TR_DontInlineUnloadableMethods); |
| 240 | + } |
235 | 241 |
|
236 | 242 | // Add known object index to parm 0 so that other optmizations can be unlocked. |
237 | 243 | // It is safe to do so because method and method symbols of a archetype specimen |
@@ -1707,6 +1713,75 @@ J9::Compilation::populateAOTMethodDependencies(TR_OpaqueClassBlock *definingClas |
1707 | 1713 | } |
1708 | 1714 | #endif /* !defined(PERSISTENT_COLLECTIONS_UNSUPPORTED) */ |
1709 | 1715 |
|
| 1716 | +OMR::RetainedMethodSet * |
| 1717 | +J9::Compilation::createRetainedMethods(TR_ResolvedMethod *method) |
| 1718 | + { |
| 1719 | +#if defined(J9VM_OPT_JITSERVER) |
| 1720 | + if (self()->isRemoteCompilation()) |
| 1721 | + { |
| 1722 | + TR_ASSERT_FATAL(false, "client must not use Compilation::retainedMethods()"); |
| 1723 | + } |
| 1724 | +#endif |
| 1725 | + |
| 1726 | + if (self()->mustTrackRetainedMethods()) |
| 1727 | + { |
| 1728 | + return J9::RetainedMethodSet::create(self(), method); |
| 1729 | + } |
| 1730 | + else |
| 1731 | + { |
| 1732 | + return OMR::Compilation::createRetainedMethods(method); |
| 1733 | + } |
| 1734 | + } |
| 1735 | + |
| 1736 | +bool |
| 1737 | +J9::Compilation::mustTrackRetainedMethods() |
| 1738 | + { |
| 1739 | + if (self()->compileRelocatableCode()) |
| 1740 | + { |
| 1741 | + // AOT: Relationships between class loaders seen at compile time won't |
| 1742 | + // necessarily still hold at load time, so there's no point in tracking |
| 1743 | + // retained method sets. At load, the inlining table will be available, |
| 1744 | + // and bonds will be created as needed. |
| 1745 | + return false; |
| 1746 | + } |
| 1747 | + |
| 1748 | + if (self()->getOption(TR_NoClassGC)) |
| 1749 | + { |
| 1750 | + return false; |
| 1751 | + } |
| 1752 | + |
| 1753 | + return !self()->getOption(TR_AllowJitBodyToOutliveInlinedCode) |
| 1754 | + || self()->getOption(TR_DontInlineUnloadableMethods); |
| 1755 | + } |
| 1756 | + |
| 1757 | +const char * |
| 1758 | +J9::Compilation::bondMethodsTraceNote() |
| 1759 | + { |
| 1760 | +#if defined(J9VM_OPT_JITSERVER) |
| 1761 | + TR_ResolvedMethod *m = NULL; |
| 1762 | + if (self()->isOutOfProcessCompilation() |
| 1763 | + && self()->mustTrackRetainedMethods() |
| 1764 | + && self()->retainedMethods()->bondMethods().next(&m)) |
| 1765 | + { |
| 1766 | + return "approximate; client may find a more precise (smaller) set"; |
| 1767 | + } |
| 1768 | +#endif |
| 1769 | + |
| 1770 | + return NULL; |
| 1771 | + } |
| 1772 | + |
| 1773 | +void |
| 1774 | +J9::Compilation::addKeepaliveClass(TR_OpaqueClassBlock *c) |
| 1775 | + { |
| 1776 | + _keepaliveClasses.insert(c); |
| 1777 | + if (self()->getOption(TR_TraceRetainedMethods)) |
| 1778 | + { |
| 1779 | + int32_t len; |
| 1780 | + const char *name = TR::Compiler->cls.classNameChars(self(), c, len); |
| 1781 | + traceMsg(self(), "Added global keepalive class %p %.*s\n", c, len, name); |
| 1782 | + } |
| 1783 | + } |
| 1784 | + |
1710 | 1785 | #if defined(J9VM_OPT_JITSERVER) |
1711 | 1786 | void |
1712 | 1787 | J9::Compilation::addSerializationRecord(const AOTCacheRecord *record, uintptr_t reloDataOffset) |
|
0 commit comments