}
/// @brief Reserve a compile callback.
- virtual CompileCallbackInfo getCompileCallback() = 0;
+ CompileCallbackInfo getCompileCallback() {
+ TargetAddress TrampolineAddr = getAvailableTrampolineAddr();
+ auto &Compile = this->ActiveTrampolines[TrampolineAddr];
+ return CompileCallbackInfo(TrampolineAddr, Compile);
+ }
/// @brief Get a CompileCallbackInfo for an existing callback.
CompileCallbackInfo getCompileCallbackInfo(TargetAddress TrampolineAddr) {
std::vector<TargetAddress> AvailableTrampolines;
private:
+
+ TargetAddress getAvailableTrampolineAddr() {
+ if (this->AvailableTrampolines.empty())
+ grow();
+ assert(!this->AvailableTrampolines.empty() &&
+ "Failed to grow available trampolines.");
+ TargetAddress TrampolineAddr = this->AvailableTrampolines.back();
+ this->AvailableTrampolines.pop_back();
+ return TrampolineAddr;
+ }
+
+ // Create new trampolines - to be implemented in subclasses.
+ virtual void grow() = 0;
+
virtual void anchor();
};
assert(!EC && "Failed to mprotect resolver block");
}
- /// @brief Get/create a compile callback with the given signature.
- CompileCallbackInfo getCompileCallback() final {
- TargetAddress TrampolineAddr = getAvailableTrampolineAddr();
- auto &Compile = this->ActiveTrampolines[TrampolineAddr];
- return CompileCallbackInfo(TrampolineAddr, Compile);
- }
-
private:
static TargetAddress reenter(void *CCMgr, void *TrampolineId) {
reinterpret_cast<uintptr_t>(TrampolineId)));
}
- TargetAddress getAvailableTrampolineAddr() {
- if (this->AvailableTrampolines.empty())
- grow();
- assert(!this->AvailableTrampolines.empty() &&
- "Failed to grow available trampolines.");
- TargetAddress TrampolineAddr = this->AvailableTrampolines.back();
- this->AvailableTrampolines.pop_back();
- return TrampolineAddr;
- }
-
- void grow() {
+ void grow() override {
assert(this->AvailableTrampolines.empty() && "Growing prematurely?");
std::error_code EC;
class DummyCallbackManager : public orc::JITCompileCallbackManager {
public:
- DummyCallbackManager()
- : JITCompileCallbackManager(0), NextStubAddress(0),
- UniversalCompile([]() { return 0; }) {
- }
-
- CompileCallbackInfo getCompileCallback() override {
- return CompileCallbackInfo(++NextStubAddress, UniversalCompile);
- }
+ DummyCallbackManager() : JITCompileCallbackManager(0) { }
public:
- TargetAddress NextStubAddress;
- CompileFtor UniversalCompile;
+ void grow() override { llvm_unreachable("not implemented"); }
};
class DummyStubsManager : public orc::IndirectStubsManagerBase {