(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
66 lines
2.2 KiB
C++
66 lines
2.2 KiB
C++
//===---------------- OrcError.cpp - Error codes for ORC ------------------===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// Error codes for ORC.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "llvm/ExecutionEngine/Orc/OrcError.h"
|
|
#include "llvm/Support/ErrorHandling.h"
|
|
#include "llvm/Support/ManagedStatic.h"
|
|
|
|
using namespace llvm;
|
|
using namespace llvm::orc;
|
|
|
|
namespace {
|
|
|
|
// FIXME: This class is only here to support the transition to llvm::Error. It
|
|
// will be removed once this transition is complete. Clients should prefer to
|
|
// deal with the Error value directly, rather than converting to error_code.
|
|
class OrcErrorCategory : public std::error_category {
|
|
public:
|
|
const char *name() const noexcept override { return "orc"; }
|
|
|
|
std::string message(int condition) const override {
|
|
switch (static_cast<OrcErrorCode>(condition)) {
|
|
case OrcErrorCode::RemoteAllocatorDoesNotExist:
|
|
return "Remote allocator does not exist";
|
|
case OrcErrorCode::RemoteAllocatorIdAlreadyInUse:
|
|
return "Remote allocator Id already in use";
|
|
case OrcErrorCode::RemoteMProtectAddrUnrecognized:
|
|
return "Remote mprotect call references unallocated memory";
|
|
case OrcErrorCode::RemoteIndirectStubsOwnerDoesNotExist:
|
|
return "Remote indirect stubs owner does not exist";
|
|
case OrcErrorCode::RemoteIndirectStubsOwnerIdAlreadyInUse:
|
|
return "Remote indirect stubs owner Id already in use";
|
|
case OrcErrorCode::UnexpectedRPCCall:
|
|
return "Unexpected RPC call";
|
|
case OrcErrorCode::UnexpectedRPCResponse:
|
|
return "Unexpected RPC response";
|
|
case OrcErrorCode::UnknownRPCFunction:
|
|
return "Unknown RPC function";
|
|
}
|
|
llvm_unreachable("Unhandled error code");
|
|
}
|
|
};
|
|
|
|
static ManagedStatic<OrcErrorCategory> OrcErrCat;
|
|
}
|
|
|
|
namespace llvm {
|
|
namespace orc {
|
|
|
|
Error orcError(OrcErrorCode ErrCode) {
|
|
typedef std::underlying_type<OrcErrorCode>::type UT;
|
|
return errorCodeToError(
|
|
std::error_code(static_cast<UT>(ErrCode), *OrcErrCat));
|
|
}
|
|
}
|
|
}
|