1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-20 19:42:54 +02:00
Commit Graph

262 Commits

Author SHA1 Message Date
Lang Hames
55f68c12d5 [Orc] Make orcError return an error_code rather than Error.
This will allow orcError to be used in convertToErrorCode implementations,
which will help in transitioning Orc RPC to Error.

llvm-svn: 299610
2017-04-06 01:35:13 +00:00
Zachary Turner
56b7096cf5 [Windows] Remove the #include <eh.h> hack.
Prior to MSVC 2015 we had to manually include this header any
time we were going to include <thread> or <future> due to a
bug in MSVC's STL implementation.  This has been fixed in MSVC
for some time now, and we require VS 2015 minimum, so we can
remove this across all subprojects.

llvm-svn: 296906
2017-03-03 20:21:59 +00:00
Lang Hames
35ded6ae85 [Orc][RPC] Accept both const char* and char* arguments for string serialization.
llvm-svn: 296168
2017-02-24 20:56:43 +00:00
Lang Hames
982396d819 [Orc] Rename ObjectLinkingLayer -> RTDyldObjectLinkingLayer.
The current ObjectLinkingLayer (now RTDyldObjectLinkingLayer) links objects
in-process using MCJIT's RuntimeDyld class. In the near future I hope to add new
object linking layers (e.g. a remote linking layer that links objects in the JIT
target process, rather than the client), so I'm renaming this class to be more
descriptive.

llvm-svn: 295636
2017-02-20 05:45:14 +00:00
Lang Hames
7d65fb66f1 [Orc][RPC] Add a AsyncHandlerTraits specialization for non-value-type response
handler args.

The specialization just inherits from the std::decay'd response handler type.
This allows member functions (via MemberFunctionWrapper) to be used as async
handlers.

llvm-svn: 295151
2017-02-15 05:39:35 +00:00
Lang Hames
90897fe570 [Orc][RPC] Remove lanch policies in favor of async handlers.
Launch policies provided a mechanism for running RPC handlers on a background
thread (unblocking the main RPC receiver thread). Async handlers generalize
this by passing the responder function (the function that sends the RPC return
value) as an argument to the handler. The handler can optionally do its work on
a background thread (the same way launch policies do), but can also (a) can
inspect the call arguments before deciding to run the work on a different
thread, or (b) can use the responder in a subsequent RPC call (e.g. in the
handler of a callAsync), allowing the handler to call back to the originator (or
to a 3rd party) without blocking the listener thread, and without launching a
new thread.

llvm-svn: 295030
2017-02-14 05:40:01 +00:00
Lang Hames
efecfcc24b [Orc][RPC] Add a HandlerTratis specialization for free functions.
llvm-svn: 294392
2017-02-08 00:13:51 +00:00
Benjamin Kramer
d087048e1f [Orc] Add missing include.
llvm-svn: 293511
2017-01-30 17:54:57 +00:00
Lang Hames
d03dc789c1 [Orc][RPC] Have handleOne abandon pending responses upon channel failure.
llvm-svn: 293411
2017-01-29 04:25:16 +00:00
Lang Hames
666c80ef8b [Orc][RPC] Remove redundant braces. NFC.
llvm-svn: 293410
2017-01-29 04:09:01 +00:00
Lang Hames
4b3e1d3723 [Orc][RPC] Remove a couple of redundant calls to abandonAllPendingResponses.
appendCallAsync, which all RPC call functions ultimately build on, will call
abandonAllPendingResponses on channel error. These extra calls are redundant.

llvm-svn: 293405
2017-01-29 00:51:17 +00:00
Lang Hames
3b1a40837c [Orc][RPC] Unlock message send/receive locks on failure.
This fixes some destruction-of-locked-mutex errors in RawByteChannel.

llvm-svn: 293375
2017-01-28 10:19:47 +00:00
Lang Hames
66a00e8efc [Orc][RPC] Refactor ParallelCallGroup to decouple it from RPCEndpoint.
This refactor allows parallel calls to be made via an arbitrary async call
dispatcher. In particular, this allows ParallelCallGroup to be used with
derived RPC classes that expose custom async RPC call operations.

llvm-svn: 292891
2017-01-24 06:13:47 +00:00
Lang Hames
6da2e5c237 [Orc][RPC] Refactor some common remote-function-id negotiation code.
llvm-svn: 292886
2017-01-24 05:30:08 +00:00
Lang Hames
4879b869b8 [Orc][RPC] Add 'removeHandler' and 'clearHandlers' methods to RPC endpoints.
This can be used to free handler resources for handlers that won't be called
again.

llvm-svn: 292714
2017-01-21 07:46:03 +00:00
Lang Hames
4453349532 [Orc][RPC] Return unsupported rpc function errors from the non-retry cases in
negotiateFunction.

These cases were accidentally left out of r292055, resulting in a less
descriptive ECError being returned on these paths.

llvm-svn: 292193
2017-01-17 04:07:48 +00:00
Lang Hames
4a16700b79 [Orc][RPC] Add an RPCFunctionNotSupported error type and return it from
negotiateFunction where appropriate.

Replacing the old ECError with a custom type allows us to attach the name of
the function that could not be negotiated, enabling better diagnostics for
negotiation failures.

llvm-svn: 292055
2017-01-15 06:34:25 +00:00
Malcolm Parsons
26eb6a0783 Remove unused lambda captures. NFC
llvm-svn: 291916
2017-01-13 17:12:16 +00:00
Lang Hames
bfeb00f12a [Orc][RPC] Lock the pending results data structure when installing new result
handlers, make abandonPendingResults public API.

This should make installing asynchronous result handlers thread safe.

The abandonPendingResults method is made public so that clients can disconnect
from a remote even if they have asynchronous handlers awaing results from that
remote. The asynchronous handlers will all receive "abandoned result" errors as
their argument.

llvm-svn: 291399
2017-01-08 20:09:35 +00:00
Lang Hames
9a461e01f9 [Orc][RPC] Add an APICalls utility for grouping RPC funtions for registration.
APICalls allows groups of functions to be composed into an API that can be
registered as a unit with an RPC endpoint. Doing registration on a-whole API
basis (rather than per-function) allows missing API functions to be detected
early.

APICalls also allows Function membership to be tested at compile-time. This
allows clients to write static assertions that functions to be called are
members of registered APIs.

llvm-svn: 291380
2017-01-08 01:13:47 +00:00
Lang Hames
a0aefcef8e [Orc][RPC] Add a class-method version of addHandler to MultiThreadedRPCEndpoint.
This brings MultiThreadedRPCEndpoint's addHandler API in-line with
SingleThreadedRPCEndpoint's.

This will be tested in an up-coming unit-test for MultiThreadedRPCEndpoint.

llvm-svn: 291376
2017-01-08 00:18:51 +00:00
Lang Hames
3550b07759 [Orc][RPC] Rename Single/MultiThreadedRPC to Single/MultithreadedRPCEndpoint.
llvm-svn: 291374
2017-01-07 22:48:12 +00:00
Lang Hames
f2777a2c48 [Orc][RPC] Remove a redundant 'if' statement.
llvm-svn: 291373
2017-01-07 22:27:52 +00:00
Lang Hames
6a7892269d [Orc][RPC] Fix an obvious locking-order bug in RawByteChannel::startSendMessage.
The lock needs to be acquired before the data is sent, not afterwards. This
think-o slipped in during the refactor in r286620, but went unnoticed as the
resulting bug only manifests in multi-threaded clients (of which there are none
in-tree).

No unit test as the bug depends on thread scheduling.

llvm-svn: 291216
2017-01-06 06:22:31 +00:00
Lang Hames
ce9a1a6381 [Orc][RPC] Add a ParallelCallGroup utility for dispatching and waiting on
multiple asynchronous RPC calls.

ParallelCallGroup allows multiple asynchronous calls to be dispatched,
and provides a wait method that blocks until all asynchronous calls have
been executed on the remote and all return value handlers run on the
local machine.

This will allow, for example, the JIT client to issue memory allocation calls
for all sections in parallel, then block until all memory has been allocated
on the remote and the allocated addresses registered with the client, at which
point the JIT client can proceed to applying relocations.

llvm-svn: 290523
2016-12-25 21:55:05 +00:00
Lang Hames
57a3739158 [Orc][RPC] Clang-format RPCUtils header.
Some of the recent RPC call type-checking changes weren't formatted prior to
commit.

llvm-svn: 290520
2016-12-25 19:55:59 +00:00
Lang Hames
7277362100 [Orc] Add some static-assert checks to improve the error messages for RPC calls
and handler registrations.

Also add a unit test for alternate-type serialization/deserialization.

llvm-svn: 290223
2016-12-21 00:59:33 +00:00
Lang Hames
ae4ded751e [ORC][RPC] Use more meaningful template parameter names.
llvm-svn: 290015
2016-12-17 00:04:24 +00:00
Lang Hames
81c19e289d [Orc] Clang-format the recent RPC update (r286620 and related).
llvm-svn: 287195
2016-11-17 02:33:47 +00:00
Eugene Zelenko
0709ad4717 [ExecutionEngine] Fix examples build broken in r287126 and other Include What You Use warnings.
llvm-svn: 287130
2016-11-16 18:32:58 +00:00
Eugene Zelenko
c9557949b6 [ExecutionEngine] Fix some Clang-tidy modernize-use-default, modernize-use-equals-delete and Include What You Use warnings; other minor fixes.
Differential revision: https://reviews.llvm.org/D26729

llvm-svn: 287126
2016-11-16 18:07:33 +00:00
Lang Hames
34d0a4eee0 [ORC] Remove the 'const' qualifier from the member function wrapper, make the
lambda in wrapHandler mutable to allow it to pass the handler through as a
non-const value.

llvm-svn: 286732
2016-11-12 23:12:41 +00:00
Lang Hames
10f49a1aee [ORC] Add a WrappedHandlerReturn type to map handler return types onto error
return types.

This class allows user provided handlers to return either error-wrapped types
or plain types. In the latter case, the plain type is wrapped with a success
value of Error or Expected<T> type to fit it into the rest of the serialization
machinery.

This patch allows us to remove the RPC unit-test workaround added in r286646.

llvm-svn: 286701
2016-11-12 02:19:31 +00:00
Lang Hames
90b8d51a5a [RPC] Add const qualifier to MemberFnWrapper to make buildbots happy.
This is a temporary fix: The right solution is to make sure addHandler can
support mutable lambdas. I'll add that in a follow-up patch.

llvm-svn: 286661
2016-11-11 22:50:16 +00:00
Lang Hames
1fe248463b [ORC] Re-apply 286620 with fixes for the ErrorSuccess class.
llvm-svn: 286639
2016-11-11 21:42:09 +00:00
Lang Hames
5c71b8a84a [ORC] Revert r286620 while I investigate a bot failure.
llvm-svn: 286621
2016-11-11 19:46:46 +00:00
Lang Hames
63b8f82e8f [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
2016-11-11 19:42:44 +00:00
Mehdi Amini
3d0dd0ec2c Make the Error class constructor protected
This is forcing to use Error::success(), which is in a wide majority
of cases a lot more readable.

Differential Revision: https://reviews.llvm.org/D26481

llvm-svn: 286561
2016-11-11 04:28:40 +00:00
Chandler Carruth
87c5a6103e Add a missing return to the move assignment operator for
SequenceNumberManager.

Sadly, we don't have any unittests for this class because it is
a private class. Since it seems to have a nice isolated and testable
interface, it'd be great to extract it to a detail namespace and write
unit tests for it as then we could catch issues. I'll probably pester
Lang about that or some alternative refactoring.

This was noticed by PVS-Studio.

llvm-svn: 285990
2016-11-04 07:16:33 +00:00
Benjamin Kramer
c2de5980d3 Do a sweep over move ctors and remove those that are identical to the default.
All of these existed because MSVC 2013 was unable to synthesize default
move ctors. We recently dropped support for it so all that error-prone
boilerplate can go.

No functionality change intended.

llvm-svn: 284721
2016-10-20 12:20:28 +00:00
Reid Kleckner
35231b2beb Fix MSVC 2013 build by using our <thread> wrapper header
llvm-svn: 281365
2016-09-13 18:40:04 +00:00
Lang Hames
8b6cb5ccee [ORC] Clang-format RPCSerialization.h.
llvm-svn: 281269
2016-09-12 22:05:14 +00:00
Lang Hames
3ef5a324ab [ORC] Add some more documentation to RPCSerialization.h.
llvm-svn: 281268
2016-09-12 22:05:12 +00:00
Nico Weber
4db05df615 attempt to unbreak build after r281254
llvm-svn: 281262
2016-09-12 21:15:44 +00:00
Lang Hames
c33b4b8c14 [ORC] Add missing <thread> header to RPCSerialization.h.
llvm-svn: 281257
2016-09-12 20:45:01 +00:00
Lang Hames
d979505343 [ORC] Replace the serialize/deserialize function pair with a SerializationTraits
class.

SerializationTraits provides serialize and deserialize methods corresponding to
the earlier functions, but also provides a name for the type. In future, this
name will be used to render function signatures as strings, which will in turn
be used to negotiate and verify API support between RPC clients and servers.

llvm-svn: 281254
2016-09-12 20:34:41 +00:00
Lang Hames
3ab7a8d3ef [ORC] Rename RPCChannel to RPCByteChannel. NFC.
llvm-svn: 281171
2016-09-11 18:41:05 +00:00
Lang Hames
d1046d5a1d [ORC] Clone module flags metadata into the globals module in the
CompileOnDemandLayer.

Also contains a tweak to the orc-lazy jit in LLI to enable the test case.

llvm-svn: 280632
2016-09-04 17:53:30 +00:00
Lang Hames
36f355caf8 [ORC] Fix an unfinished comment.
llvm-svn: 280628
2016-09-04 16:31:41 +00:00
Lang Hames
a047e3a956 [ORC] Fix some missing fields in OrcRemoteTargetClient's move constructor.
llvm-svn: 280459
2016-09-02 03:45:44 +00:00