1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 18:54:02 +01:00

[ORC] Add C API functions to obtain and clear the symbol string pool.

Symbol string pool entries are ref counted, but not automatically cleared.
This can cause the size of the pool to grow without bound if it's not
periodically cleared. These functions allow that to be done via the C API.
This commit is contained in:
Lang Hames 2020-10-01 21:12:19 -07:00
parent effa9c6dc7
commit ca02de21bc
2 changed files with 36 additions and 0 deletions

View File

@ -43,6 +43,11 @@ typedef uint64_t LLVMOrcJITTargetAddress;
*/
typedef struct LLVMOrcOpaqueExecutionSession *LLVMOrcExecutionSessionRef;
/**
* A reference to an orc::SymbolStringPool.
*/
typedef struct LLVMOrcOpaqueSymbolStringPool *LLVMOrcSymbolStringPoolRef;
/**
* A reference to an orc::SymbolStringPool table entry.
*/
@ -110,6 +115,27 @@ void LLVMOrcExecutionSessionSetErrorReporter(
LLVMOrcExecutionSessionRef ES, LLVMOrcErrorReporterFunction ReportError,
void *Ctx);
/**
* Return a reference to the SymbolStringPool for an ExecutionSession.
*
* Ownership of the pool remains with the ExecutionSession: The caller is
* not required to free the pool.
*/
LLVMOrcSymbolStringPoolRef
LLVMOrcExecutionSessionGetSymbolStringPool(LLVMOrcExecutionSessionRef ES);
/**
* Clear all unreferenced symbol string pool entries.
*
* This can be called at any time to release unused entries in the
* ExecutionSession's string pool. Since it locks the pool (preventing
* interning of any new strings) it is recommended that it only be called
* infrequently, ideally when the caller has reason to believe that some
* entries will have become unreferenced, e.g. after removing a module or
* closing a JITDylib.
*/
void LLVMOrcSymbolStringPoolClearDeadEntries(LLVMOrcSymbolStringPoolRef SSP);
/**
* Intern a string in the ExecutionSession's SymbolStringPool and return a
* reference to it. This increments the ref-count of the pool entry, and the

View File

@ -43,6 +43,7 @@ public:
} // end namespace llvm
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ExecutionSession, LLVMOrcExecutionSessionRef)
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(SymbolStringPool, LLVMOrcSymbolStringPoolRef)
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(OrcV2CAPIHelper::PoolEntry,
LLVMOrcSymbolStringPoolEntryRef)
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(JITDylib, LLVMOrcJITDylibRef)
@ -65,6 +66,15 @@ void LLVMOrcExecutionSessionSetErrorReporter(
[=](Error Err) { ReportError(Ctx, wrap(std::move(Err))); });
}
LLVMOrcSymbolStringPoolRef
LLVMOrcExecutionSessionGetSymbolStringPool(LLVMOrcExecutionSessionRef ES) {
return wrap(unwrap(ES)->getSymbolStringPool().get());
}
void LLVMOrcSymbolStringPoolClearDeadEntries(LLVMOrcSymbolStringPoolRef SSP) {
unwrap(SSP)->clearDeadEntries();
}
LLVMOrcSymbolStringPoolEntryRef
LLVMOrcExecutionSessionIntern(LLVMOrcExecutionSessionRef ES, const char *Name) {
return wrap(