forked from OSchip/llvm-project
[ORC] Reorder callWrapperAsync and callSPSWrapperAsync parameters.
The callee address is now the first parameter and the 'SendResult' function the second. This change improves consistentency with the non-async functions where the callee is the first address and the return value the second.
This commit is contained in:
parent
a42d5c34d0
commit
da7f993a8d
|
@ -1481,9 +1481,10 @@ public:
|
|||
/// \endcode{.cpp}
|
||||
///
|
||||
/// The given OnComplete function will be called to return the result.
|
||||
void callWrapperAsync(ExecutorProcessControl::SendResultFunction OnComplete,
|
||||
ExecutorAddr WrapperFnAddr, ArrayRef<char> ArgBuffer) {
|
||||
EPC->callWrapperAsync(std::move(OnComplete), WrapperFnAddr, ArgBuffer);
|
||||
void callWrapperAsync(ExecutorAddr WrapperFnAddr,
|
||||
ExecutorProcessControl::SendResultFunction OnComplete,
|
||||
ArrayRef<char> ArgBuffer) {
|
||||
EPC->callWrapperAsync(WrapperFnAddr, std::move(OnComplete), ArgBuffer);
|
||||
}
|
||||
|
||||
/// Run a wrapper function in the executor. The wrapper function should be
|
||||
|
@ -1500,10 +1501,10 @@ public:
|
|||
/// Run a wrapper function using SPS to serialize the arguments and
|
||||
/// deserialize the results.
|
||||
template <typename SPSSignature, typename SendResultT, typename... ArgTs>
|
||||
void callSPSWrapperAsync(SendResultT &&SendResult, ExecutorAddr WrapperFnAddr,
|
||||
void callSPSWrapperAsync(ExecutorAddr WrapperFnAddr, SendResultT &&SendResult,
|
||||
const ArgTs &...Args) {
|
||||
EPC->callSPSWrapperAsync<SPSSignature, SendResultT, ArgTs...>(
|
||||
std::forward<SendResultT>(SendResult), WrapperFnAddr, Args...);
|
||||
WrapperFnAddr, std::forward<SendResultT>(SendResult), Args...);
|
||||
}
|
||||
|
||||
/// Run a wrapper function using SPS to serialize the arguments and
|
||||
|
|
|
@ -43,35 +43,35 @@ public:
|
|||
WriteResultFn OnWriteComplete) override {
|
||||
using namespace shared;
|
||||
EPC.callSPSWrapperAsync<void(SPSSequence<SPSMemoryAccessUInt8Write>)>(
|
||||
std::move(OnWriteComplete), FAs.WriteUInt8s, Ws);
|
||||
FAs.WriteUInt8s, std::move(OnWriteComplete), Ws);
|
||||
}
|
||||
|
||||
void writeUInt16sAsync(ArrayRef<tpctypes::UInt16Write> Ws,
|
||||
WriteResultFn OnWriteComplete) override {
|
||||
using namespace shared;
|
||||
EPC.callSPSWrapperAsync<void(SPSSequence<SPSMemoryAccessUInt16Write>)>(
|
||||
std::move(OnWriteComplete), FAs.WriteUInt16s, Ws);
|
||||
FAs.WriteUInt16s, std::move(OnWriteComplete), Ws);
|
||||
}
|
||||
|
||||
void writeUInt32sAsync(ArrayRef<tpctypes::UInt32Write> Ws,
|
||||
WriteResultFn OnWriteComplete) override {
|
||||
using namespace shared;
|
||||
EPC.callSPSWrapperAsync<void(SPSSequence<SPSMemoryAccessUInt32Write>)>(
|
||||
std::move(OnWriteComplete), FAs.WriteUInt32s, Ws);
|
||||
FAs.WriteUInt32s, std::move(OnWriteComplete), Ws);
|
||||
}
|
||||
|
||||
void writeUInt64sAsync(ArrayRef<tpctypes::UInt64Write> Ws,
|
||||
WriteResultFn OnWriteComplete) override {
|
||||
using namespace shared;
|
||||
EPC.callSPSWrapperAsync<void(SPSSequence<SPSMemoryAccessUInt64Write>)>(
|
||||
std::move(OnWriteComplete), FAs.WriteUInt64s, Ws);
|
||||
FAs.WriteUInt64s, std::move(OnWriteComplete), Ws);
|
||||
}
|
||||
|
||||
void writeBuffersAsync(ArrayRef<tpctypes::BufferWrite> Ws,
|
||||
WriteResultFn OnWriteComplete) override {
|
||||
using namespace shared;
|
||||
EPC.callSPSWrapperAsync<void(SPSSequence<SPSMemoryAccessBufferWrite>)>(
|
||||
std::move(OnWriteComplete), FAs.WriteBuffers, Ws);
|
||||
FAs.WriteBuffers, std::move(OnWriteComplete), Ws);
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -207,8 +207,8 @@ public:
|
|||
/// \endcode{.cpp}
|
||||
///
|
||||
/// The given OnComplete function will be called to return the result.
|
||||
virtual void callWrapperAsync(SendResultFunction OnComplete,
|
||||
ExecutorAddr WrapperFnAddr,
|
||||
virtual void callWrapperAsync(ExecutorAddr WrapperFnAddr,
|
||||
SendResultFunction OnComplete,
|
||||
ArrayRef<char> ArgBuffer) = 0;
|
||||
|
||||
/// Run a wrapper function in the executor. The wrapper function should be
|
||||
|
@ -222,21 +222,22 @@ public:
|
|||
std::promise<shared::WrapperFunctionResult> RP;
|
||||
auto RF = RP.get_future();
|
||||
callWrapperAsync(
|
||||
WrapperFnAddr,
|
||||
[&](shared::WrapperFunctionResult R) { RP.set_value(std::move(R)); },
|
||||
WrapperFnAddr, ArgBuffer);
|
||||
ArgBuffer);
|
||||
return RF.get();
|
||||
}
|
||||
|
||||
/// Run a wrapper function using SPS to serialize the arguments and
|
||||
/// deserialize the results.
|
||||
template <typename SPSSignature, typename SendResultT, typename... ArgTs>
|
||||
void callSPSWrapperAsync(SendResultT &&SendResult, ExecutorAddr WrapperFnAddr,
|
||||
void callSPSWrapperAsync(ExecutorAddr WrapperFnAddr, SendResultT &&SendResult,
|
||||
const ArgTs &...Args) {
|
||||
shared::WrapperFunction<SPSSignature>::callAsync(
|
||||
[this,
|
||||
WrapperFnAddr](ExecutorProcessControl::SendResultFunction SendResult,
|
||||
const char *ArgData, size_t ArgSize) {
|
||||
callWrapperAsync(std::move(SendResult), WrapperFnAddr,
|
||||
callWrapperAsync(WrapperFnAddr, std::move(SendResult),
|
||||
ArrayRef<char>(ArgData, ArgSize));
|
||||
},
|
||||
std::move(SendResult), Args...);
|
||||
|
@ -304,8 +305,8 @@ public:
|
|||
llvm_unreachable("Unsupported");
|
||||
}
|
||||
|
||||
void callWrapperAsync(SendResultFunction OnComplete,
|
||||
ExecutorAddr WrapperFnAddr,
|
||||
void callWrapperAsync(ExecutorAddr WrapperFnAddr,
|
||||
SendResultFunction OnComplete,
|
||||
ArrayRef<char> ArgBuffer) override {
|
||||
llvm_unreachable("Unsupported");
|
||||
}
|
||||
|
@ -339,8 +340,8 @@ public:
|
|||
Expected<int32_t> runAsMain(ExecutorAddr MainFnAddr,
|
||||
ArrayRef<std::string> Args) override;
|
||||
|
||||
void callWrapperAsync(SendResultFunction OnComplete,
|
||||
ExecutorAddr WrapperFnAddr,
|
||||
void callWrapperAsync(ExecutorAddr WrapperFnAddr,
|
||||
SendResultFunction OnComplete,
|
||||
ArrayRef<char> ArgBuffer) override;
|
||||
|
||||
Error disconnect() override;
|
||||
|
|
|
@ -61,8 +61,8 @@ public:
|
|||
Expected<int32_t> runAsMain(ExecutorAddr MainFnAddr,
|
||||
ArrayRef<std::string> Args) override;
|
||||
|
||||
void callWrapperAsync(SendResultFunction OnComplete,
|
||||
ExecutorAddr WrapperFnAddr,
|
||||
void callWrapperAsync(ExecutorAddr WrapperFnAddr,
|
||||
SendResultFunction OnComplete,
|
||||
ArrayRef<char> ArgBuffer) override;
|
||||
|
||||
Error disconnect() override;
|
||||
|
|
|
@ -60,6 +60,7 @@ public:
|
|||
}
|
||||
Parent.EPC.callSPSWrapperAsync<
|
||||
rt::SPSSimpleExecutorMemoryManagerFinalizeSignature>(
|
||||
Parent.SAs.Finalize,
|
||||
[OnFinalize = std::move(OnFinalize)](Error SerializationErr,
|
||||
Error FinalizeErr) {
|
||||
if (SerializationErr)
|
||||
|
@ -67,7 +68,7 @@ public:
|
|||
else
|
||||
OnFinalize(std::move(FinalizeErr));
|
||||
},
|
||||
Parent.SAs.Finalize, Parent.SAs.Allocator, std::move(FR));
|
||||
Parent.SAs.Allocator, std::move(FR));
|
||||
}
|
||||
|
||||
Error deallocate() override {
|
||||
|
|
|
@ -109,8 +109,8 @@ SelfExecutorProcessControl::runAsMain(ExecutorAddr MainFnAddr,
|
|||
return orc::runAsMain(MainFnAddr.toPtr<MainTy>(), Args);
|
||||
}
|
||||
|
||||
void SelfExecutorProcessControl::callWrapperAsync(SendResultFunction SendResult,
|
||||
ExecutorAddr WrapperFnAddr,
|
||||
void SelfExecutorProcessControl::callWrapperAsync(ExecutorAddr WrapperFnAddr,
|
||||
SendResultFunction SendResult,
|
||||
ArrayRef<char> ArgBuffer) {
|
||||
using WrapperFnTy =
|
||||
shared::detail::CWrapperFunctionResult (*)(const char *Data, size_t Size);
|
||||
|
|
|
@ -54,8 +54,8 @@ Expected<int32_t> SimpleRemoteEPC::runAsMain(ExecutorAddr MainFnAddr,
|
|||
return Result;
|
||||
}
|
||||
|
||||
void SimpleRemoteEPC::callWrapperAsync(SendResultFunction OnComplete,
|
||||
ExecutorAddr WrapperFnAddr,
|
||||
void SimpleRemoteEPC::callWrapperAsync(ExecutorAddr WrapperFnAddr,
|
||||
SendResultFunction OnComplete,
|
||||
ArrayRef<char> ArgBuffer) {
|
||||
uint64_t SeqNo;
|
||||
{
|
||||
|
|
|
@ -49,11 +49,10 @@ TEST(ExecutionSessionWrapperFunctionCalls, RunVoidWrapperAsyncTemplate) {
|
|||
ExecutionSession ES(cantFail(SelfExecutorProcessControl::Create()));
|
||||
|
||||
std::promise<MSVCPError> RP;
|
||||
ES.callSPSWrapperAsync<void()>(
|
||||
[&](Error SerializationErr) {
|
||||
RP.set_value(std::move(SerializationErr));
|
||||
},
|
||||
ExecutorAddr::fromPtr(voidWrapper));
|
||||
ES.callSPSWrapperAsync<void()>(ExecutorAddr::fromPtr(voidWrapper),
|
||||
[&](Error SerializationErr) {
|
||||
RP.set_value(std::move(SerializationErr));
|
||||
});
|
||||
Error Err = RP.get_future().get();
|
||||
EXPECT_THAT_ERROR(std::move(Err), Succeeded());
|
||||
}
|
||||
|
@ -63,12 +62,13 @@ TEST(ExecutionSessionWrapperFunctionCalls, RunNonVoidWrapperAsyncTemplate) {
|
|||
|
||||
std::promise<MSVCPExpected<int32_t>> RP;
|
||||
ES.callSPSWrapperAsync<int32_t(int32_t, int32_t)>(
|
||||
ExecutorAddr::fromPtr(addWrapper),
|
||||
[&](Error SerializationErr, int32_t R) {
|
||||
if (SerializationErr)
|
||||
RP.set_value(std::move(SerializationErr));
|
||||
RP.set_value(std::move(R));
|
||||
},
|
||||
ExecutorAddr::fromPtr(addWrapper), 2, 3);
|
||||
2, 3);
|
||||
Expected<int32_t> Result = RP.get_future().get();
|
||||
EXPECT_THAT_EXPECTED(Result, HasValue(5));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue