Revert "[Orc] Directly emit machine code for the x86 resolver block and trampolines."
[oota-llvm.git] / tools / lli / ChildTarget / ChildTarget.cpp
index de264af2cdd1fe7c884ffee7b984aa2ddbcc37c5..6c537d47df3d1ee5443fd94d1b6faa3d0ad1bc35 100644 (file)
@@ -1,7 +1,8 @@
 #include "llvm/Config/config.h"
-#include "llvm/Support/Memory.h"
+#include "../RPCChannel.h"
 #include "../RemoteTarget.h"
 #include "../RemoteTargetMessage.h"
+#include "llvm/Support/Memory.h"
 #include <assert.h>
 #include <map>
 #include <stdint.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,12 @@ 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) ? Size : -1;
+  }
+  int ReadBytes(void *Data, size_t Size) {
+    return RPC.ReadBytes(Data, Size) ? Size : -1;
+  }
 
   // Communication handles (OS-specific)
   void *ConnectionData;
@@ -55,7 +60,7 @@ int main() {
 
 // Public methods
 void LLIChildTarget::initialize() {
-  initializeConnection();
+  RPC.createClient();
   sendChildActive();
 }
 
@@ -92,15 +97,15 @@ void LLIChildTarget::handleMessage(LLIMessageType messageType) {
 // Incoming message handlers
 void LLIChildTarget::handleAllocateSpace() {
   // Read and verify the message data size.
-  uint32_t DataSize;
+  uint32_t DataSize = 0;
   int rc = ReadBytes(&DataSize, 4);
   (void)rc;
   assert(rc == 4);
   assert(DataSize == 8);
 
   // Read the message arguments.
-  uint32_t Alignment;
-  uint32_t AllocSize;
+  uint32_t Alignment = 0;
+  uint32_t AllocSize = 0;
   rc = ReadBytes(&Alignment, 4);
   assert(rc == 4);
   rc = ReadBytes(&AllocSize, 4);
@@ -116,13 +121,13 @@ void LLIChildTarget::handleAllocateSpace() {
 
 void LLIChildTarget::handleLoadSection(bool IsCode) {
   // Read the message data size.
-  uint32_t DataSize;
+  uint32_t DataSize = 0;
   int rc = ReadBytes(&DataSize, 4);
   (void)rc;
   assert(rc == 4);
 
   // Read the target load address.
-  uint64_t Addr;
+  uint64_t Addr = 0;
   rc = ReadBytes(&Addr, 8);
   assert(rc == 8);
   size_t BufferSize = DataSize - 8;
@@ -145,14 +150,14 @@ void LLIChildTarget::handleLoadSection(bool IsCode) {
 
 void LLIChildTarget::handleExecute() {
   // Read the message data size.
-  uint32_t DataSize;
+  uint32_t DataSize = 0;
   int rc = ReadBytes(&DataSize, 4);
   (void)rc;
   assert(rc == 4);
   assert(DataSize == 8);
 
   // Read the target address.
-  uint64_t Addr;
+  uint64_t Addr = 0;
   rc = ReadBytes(&Addr, 8);
   assert(rc == 8);
 
@@ -231,9 +236,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