[Orc] Move delta-handling for trampoline sizes into the resolver block.
authorLang Hames <lhames@gmail.com>
Tue, 24 Mar 2015 04:27:02 +0000 (04:27 +0000)
committerLang Hames <lhames@gmail.com>
Tue, 24 Mar 2015 04:27:02 +0000 (04:27 +0000)
This is the first step towards adding a target-independent callback
handler API.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233049 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ExecutionEngine/Orc/IndirectionUtils.h
include/llvm/ExecutionEngine/Orc/OrcTargetSupport.h
lib/ExecutionEngine/Orc/OrcTargetSupport.cpp

index e9d3d34085db6692c54625cae3a56952f0c82ac5..6168684950ad8a743d1f5fcd4f9a3fc2e6fe9aa5 100644 (file)
@@ -56,7 +56,7 @@ public:
     // Moving the trampoline ID back to the available list first means there's at
     // least one available trampoline if the compile action triggers a request for
     // a new one.
-    AvailableTrampolines.push_back(I->first - TargetT::CallSize);
+    AvailableTrampolines.push_back(I->first);
     auto CallbackHandler = std::move(I->second);
     ActiveTrampolines.erase(I);
 
@@ -140,7 +140,7 @@ public:
   CompileCallbackInfo getCompileCallback(FunctionType &FT) {
     TargetAddress TrampolineAddr = getAvailableTrampolineAddr(FT.getContext());
     auto &CallbackHandler =
-      this->ActiveTrampolines[TrampolineAddr + TargetT::CallSize];
+      this->ActiveTrampolines[TrampolineAddr];
     Constant *AddrIntVal =
       ConstantInt::get(Type::getInt64Ty(FT.getContext()), TrampolineAddr);
     Constant *AddrPtrVal =
index c6f866a0469a5271f4e76c91262666cb9cab7003..045528b865bbfdc6befed4d38b580818ddb75de3 100644 (file)
@@ -32,8 +32,6 @@ public:
   /// @brief Get a label name from the given index.
   typedef std::function<std::string(unsigned)> LabelNameFtor;
 
-  static const unsigned CallSize = 6;
-
   /// @brief Insert the requested number of trampolines into the given module.
   /// @param M Module to insert the call block into.
   /// @param NumCalls Number of calls to create in the call block.
index b5dda8e4ee59de61e522bee8d2981b262d536576..4932ec16bb0fa246de6dac0138dbde5eab255d15 100644 (file)
@@ -53,6 +53,7 @@ const char* OrcX86_64::ResolverBlockName = "orc_resolver_block";
 
 void OrcX86_64::insertResolverBlock(
     Module &M, JITCompileCallbackManagerBase<OrcX86_64> &JCBM) {
+  const unsigned X86_64_TrampolineLength = 6;
   auto CallbackPtr = executeCompileCallback<OrcX86_64>;
   uint64_t CallbackAddr =
       static_cast<uint64_t>(reinterpret_cast<uintptr_t>(CallbackPtr));
@@ -77,6 +78,7 @@ void OrcX86_64::insertResolverBlock(
   AsmStream << "  leaq    jit_callback_manager_addr(%rip), %rdi\n"
             << "  movq    (%rdi), %rdi\n"
             << "  movq    " << ReturnAddrOffset << "(%rsp), %rsi\n"
+            << "  subq    $" << X86_64_TrampolineLength << ", %rsi\n"
             << "  movabsq $" << CallbackAddr << ", %rax\n"
             << "  callq   *%rax\n"
             << "  movq    %rax, " << ReturnAddrOffset << "(%rsp)\n";