|
13 | 13 | #ifndef ORC_RT_WRAPPER_FUNCTION_UTILS_H |
14 | 14 | #define ORC_RT_WRAPPER_FUNCTION_UTILS_H |
15 | 15 |
|
16 | | -#include "orc_rt/c_api.h" |
17 | | -#include "common.h" |
18 | 16 | #include "error.h" |
19 | 17 | #include "executor_address.h" |
| 18 | +#include "orc_rt/c_api.h" |
20 | 19 | #include "simple_packed_serialization.h" |
21 | 20 | #include <type_traits> |
22 | 21 |
|
@@ -288,30 +287,22 @@ class WrapperFunction<SPSRetTagT(SPSTagTs...)> { |
288 | 287 | using ResultSerializer = detail::ResultSerializer<SPSRetTagT, RetT>; |
289 | 288 |
|
290 | 289 | public: |
291 | | - template <typename RetT, typename... ArgTs> |
292 | | - static Error call(const void *FnTag, RetT &Result, const ArgTs &...Args) { |
| 290 | + template <typename DispatchFn, typename RetT, typename... ArgTs> |
| 291 | + static Error call(DispatchFn &&Dispatch, RetT &Result, const ArgTs &...Args) { |
293 | 292 |
|
294 | 293 | // RetT might be an Error or Expected value. Set the checked flag now: |
295 | 294 | // we don't want the user to have to check the unused result if this |
296 | 295 | // operation fails. |
297 | 296 | detail::ResultDeserializer<SPSRetTagT, RetT>::makeSafe(Result); |
298 | 297 |
|
299 | | - // Since the functions cannot be zero/unresolved on Windows, the following |
300 | | - // reference taking would always be non-zero, thus generating a compiler |
301 | | - // warning otherwise. |
302 | | -#if !defined(_WIN32) |
303 | | - if (ORC_RT_UNLIKELY(!&__orc_rt_jit_dispatch_ctx)) |
304 | | - return make_error<StringError>("__orc_rt_jit_dispatch_ctx not set"); |
305 | | - if (ORC_RT_UNLIKELY(!&__orc_rt_jit_dispatch)) |
306 | | - return make_error<StringError>("__orc_rt_jit_dispatch not set"); |
307 | | -#endif |
308 | 298 | auto ArgBuffer = |
309 | 299 | WrapperFunctionResult::fromSPSArgs<SPSArgList<SPSTagTs...>>(Args...); |
310 | 300 | if (const char *ErrMsg = ArgBuffer.getOutOfBandError()) |
311 | 301 | return make_error<StringError>(ErrMsg); |
312 | 302 |
|
313 | | - WrapperFunctionResult ResultBuffer = __orc_rt_jit_dispatch( |
314 | | - &__orc_rt_jit_dispatch_ctx, FnTag, ArgBuffer.data(), ArgBuffer.size()); |
| 303 | + WrapperFunctionResult ResultBuffer = |
| 304 | + Dispatch(ArgBuffer.data(), ArgBuffer.size()); |
| 305 | + |
315 | 306 | if (auto ErrMsg = ResultBuffer.getOutOfBandError()) |
316 | 307 | return make_error<StringError>(ErrMsg); |
317 | 308 |
|
@@ -347,10 +338,11 @@ template <typename... SPSTagTs> |
347 | 338 | class WrapperFunction<void(SPSTagTs...)> |
348 | 339 | : private WrapperFunction<SPSEmpty(SPSTagTs...)> { |
349 | 340 | public: |
350 | | - template <typename... ArgTs> |
351 | | - static Error call(const void *FnTag, const ArgTs &...Args) { |
| 341 | + template <typename DispatchFn, typename... ArgTs> |
| 342 | + static Error call(DispatchFn &&Dispatch, const ArgTs &...Args) { |
352 | 343 | SPSEmpty BE; |
353 | | - return WrapperFunction<SPSEmpty(SPSTagTs...)>::call(FnTag, BE, Args...); |
| 344 | + return WrapperFunction<SPSEmpty(SPSTagTs...)>::call( |
| 345 | + std::forward<DispatchFn>(Dispatch), BE, Args...); |
354 | 346 | } |
355 | 347 |
|
356 | 348 | using WrapperFunction<SPSEmpty(SPSTagTs...)>::handle; |
|
0 commit comments