diff options
author | Alp Toker <alp@nuanti.com> | 2014-01-23 22:19:45 +0000 |
---|---|---|
committer | Alp Toker <alp@nuanti.com> | 2014-01-23 22:19:45 +0000 |
commit | 2a02d4bee3f683180a40b65a2c3833ceb64236c3 (patch) | |
tree | 89a2e96aafd4f6e946fa8c0f812d07f64c21501f /tools/lli/ChildTarget | |
parent | 2f49a7b24b4adfed31855edeb9d1b3f0386c188b (diff) | |
download | llvm-2a02d4bee3f683180a40b65a2c3833ceb64236c3.tar.gz llvm-2a02d4bee3f683180a40b65a2c3833ceb64236c3.tar.bz2 llvm-2a02d4bee3f683180a40b65a2c3833ceb64236c3.tar.xz |
lli: Factor portable messaging into a new RPCChannel facility
The client and server now use a single unified low-level RPC core built around
LLVM's existing cross-platform abstractions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199947 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/lli/ChildTarget')
-rw-r--r-- | tools/lli/ChildTarget/ChildTarget.cpp | 15 | ||||
-rw-r--r-- | tools/lli/ChildTarget/Unix/ChildTarget.inc | 46 | ||||
-rw-r--r-- | tools/lli/ChildTarget/Windows/ChildTarget.inc | 30 |
3 files changed, 9 insertions, 82 deletions
diff --git a/tools/lli/ChildTarget/ChildTarget.cpp b/tools/lli/ChildTarget/ChildTarget.cpp index de264af2cd..1e3000da46 100644 --- a/tools/lli/ChildTarget/ChildTarget.cpp +++ b/tools/lli/ChildTarget/ChildTarget.cpp @@ -1,5 +1,6 @@ #include "llvm/Config/config.h" #include "llvm/Support/Memory.h" +#include "../RPCChannel.h" #include "../RemoteTarget.h" #include "../RemoteTargetMessage.h" #include <assert.h> @@ -12,11 +13,11 @@ using namespace llvm; class LLIChildTarget { public: - ~LLIChildTarget(); // OS-specific destructor void initialize(); LLIMessageType waitForIncomingMessage(); void handleMessage(LLIMessageType messageType); RemoteTarget *RT; + RPCChannel RPC; private: // Incoming message handlers @@ -32,8 +33,10 @@ private: // OS-specific functions void initializeConnection(); - int WriteBytes(const void *Data, size_t Size); - int ReadBytes(void *Data, size_t Size); + int WriteBytes(const void *Data, size_t Size) { + return RPC.WriteBytes(Data, Size); + } + int ReadBytes(void *Data, size_t Size) { return RPC.ReadBytes(Data, Size); } // Communication handles (OS-specific) void *ConnectionData; @@ -55,7 +58,7 @@ int main() { // Public methods void LLIChildTarget::initialize() { - initializeConnection(); + RPC.createClient(); sendChildActive(); } @@ -231,9 +234,9 @@ void LLIChildTarget::sendExecutionComplete(int Result) { } #ifdef LLVM_ON_UNIX -#include "Unix/ChildTarget.inc" +#include "../Unix/RPCChannel.inc" #endif #ifdef LLVM_ON_WIN32 -#include "Windows/ChildTarget.inc" +#include "../Windows/RPCChannel.inc" #endif diff --git a/tools/lli/ChildTarget/Unix/ChildTarget.inc b/tools/lli/ChildTarget/Unix/ChildTarget.inc deleted file mode 100644 index 67a24ece96..0000000000 --- a/tools/lli/ChildTarget/Unix/ChildTarget.inc +++ /dev/null @@ -1,46 +0,0 @@ -//===- ChildTarget.inc - Child process for external JIT execution for Unix -==// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// Implementation of the Unix-specific parts of the ChildTarget class -// which executes JITed code in a separate process from where it was built. -// -//===----------------------------------------------------------------------===// - -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> - -namespace { - -struct ConnectionData_t { - int InputPipe; - int OutputPipe; - - ConnectionData_t(int in, int out) : InputPipe(in), OutputPipe(out) {} -}; - -} // namespace - -LLIChildTarget::~LLIChildTarget() { - delete static_cast<ConnectionData_t *>(ConnectionData); -} - -// OS-specific methods -void LLIChildTarget::initializeConnection() { - // Store the parent ends of the pipes - ConnectionData = (void*)new ConnectionData_t(STDIN_FILENO, STDOUT_FILENO); -} - -int LLIChildTarget::WriteBytes(const void *Data, size_t Size) { - return write(((ConnectionData_t*)ConnectionData)->OutputPipe, Data, Size); -} - -int LLIChildTarget::ReadBytes(void *Data, size_t Size) { - return read(((ConnectionData_t*)ConnectionData)->InputPipe, Data, Size); -} diff --git a/tools/lli/ChildTarget/Windows/ChildTarget.inc b/tools/lli/ChildTarget/Windows/ChildTarget.inc deleted file mode 100644 index 289f27a470..0000000000 --- a/tools/lli/ChildTarget/Windows/ChildTarget.inc +++ /dev/null @@ -1,30 +0,0 @@ -//=- ChildTarget.inc - Child process for external JIT execution for Windows -=// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// Non-implementation of the Windows-specific parts of the ChildTarget class -// which executes JITed code in a separate process from where it was built. -// -//===----------------------------------------------------------------------===// - -LLIChildTarget::~LLIChildTarget() { -} - -// The RemoteTargetExternal implementation should prevent us from ever getting -// here on Windows, but nothing prevents a user from running this directly. -void LLIChildTarget::initializeConnection() { - assert(0 && "lli-child-target is not implemented for Windows"); -} - -int LLIChildTarget::WriteBytes(const void *Data, size_t Size) { - return 0; -} - -int LLIChildTarget::ReadBytes(void *Data, size_t Size) { - return 0; -} |