[ORC] Refactor the ORC RPC utilities to add some new features.
authorLang Hames <lhames@gmail.com>
Fri, 11 Nov 2016 19:42:44 +0000 (19:42 +0000)
committerLang Hames <lhames@gmail.com>
Fri, 11 Nov 2016 19:42:44 +0000 (19:42 +0000)
commitae1fdddbc4da0cffb219bc6f19b42a9e89f0c3b1
tree33a93248b3e54f91119ad33f7663bc6b1fda76ee
parentda0149dd74980bbe9175009b74f3a37cddec71cd
[ORC] Refactor the ORC RPC utilities to add some new features.

(1) Add support for function key negotiation.

The previous version of the RPC required both sides to maintain the same
enumeration for functions in the API. This means that any version skew between
the client and server would result in communication failure.

With this version of the patch functions (and serializable types) are defined
with string names, and the derived function signature strings are used to
negotiate the actual function keys (which are used for efficient call
serialization). This allows clients to connect to any server that supports a
superset of the API (based on the function signatures it supports).

(2) Add a callAsync primitive.

The callAsync primitive can be used to install a return value handler that will
run as soon as the RPC function's return value is sent back from the remote.

(3) Launch policies for RPC function handlers.

The new addHandler method, which installs handlers for RPC functions, takes two
arguments: (1) the handler itself, and (2) an optional "launch policy". When the
RPC function is called, the launch policy (if present) is invoked to actually
launch the handler. This allows the handler to be spawned on a background
thread, or added to a work list. If no launch policy is used, the handler is run
on the server thread itself. This should only be used for short-running
handlers, or entirely synchronous RPC APIs.

(4) Zero cost cross type serialization.

You can now define serialization from any type to a different "wire" type. For
example, this allows you to call an RPC function that's defined to take a
std::string while passing a StringRef argument. If a serializer from StringRef
to std::string has been defined for the channel type this will be used to
serialize the argument without having to construct a std::string instance.

This allows buffer reference types to be used as arguments to RPC calls without
requiring a copy of the buffer to be made.

llvm-svn: 286620
17 files changed:
llvm/examples/Kaleidoscope/BuildingAJIT/Chapter5/RemoteJITUtils.h
llvm/examples/Kaleidoscope/BuildingAJIT/Chapter5/toy.cpp
llvm/include/llvm/ExecutionEngine/Orc/OrcError.h
llvm/include/llvm/ExecutionEngine/Orc/OrcRemoteTargetClient.h
llvm/include/llvm/ExecutionEngine/Orc/OrcRemoteTargetRPCAPI.h
llvm/include/llvm/ExecutionEngine/Orc/OrcRemoteTargetServer.h
llvm/include/llvm/ExecutionEngine/Orc/RPCByteChannel.h [deleted file]
llvm/include/llvm/ExecutionEngine/Orc/RPCSerialization.h
llvm/include/llvm/ExecutionEngine/Orc/RPCUtils.h
llvm/include/llvm/ExecutionEngine/Orc/RawByteChannel.h [new file with mode: 0644]
llvm/lib/ExecutionEngine/Orc/CMakeLists.txt
llvm/lib/ExecutionEngine/Orc/OrcError.cpp
llvm/lib/ExecutionEngine/Orc/OrcRemoteTargetRPCAPI.cpp [deleted file]
llvm/tools/lli/ChildTarget/ChildTarget.cpp
llvm/tools/lli/RemoteJITUtils.h
llvm/tools/lli/lli.cpp
llvm/unittests/ExecutionEngine/Orc/RPCUtilsTest.cpp