Common: CallLambdaTrampoline can return a value
As it is currently written, CallLambdaTrampoline does not return a value. However, some of the functions that are being wrapped may return a value that the JIT is expected to understand. A compiler *cough cough clang* may opt to alter %rax after the wrapped lambda returns, e.g. popping a previous value, which can clobber the return value. If we actually have a return value, then the compiler must not clobber it.
This commit is contained in:
parent
8a50dc857b
commit
bd196e8c71
|
@ -709,10 +709,9 @@ public:
|
||||||
// (this method might be a thunk in the case of multi-inheritance) so we
|
// (this method might be a thunk in the case of multi-inheritance) so we
|
||||||
// have to go through a trampoline function.
|
// have to go through a trampoline function.
|
||||||
template <typename T, typename... Args>
|
template <typename T, typename... Args>
|
||||||
static void CallLambdaTrampoline(const std::function<T(Args...)>* f,
|
static T CallLambdaTrampoline(const std::function<T(Args...)>* f, Args... args)
|
||||||
Args... args)
|
|
||||||
{
|
{
|
||||||
(*f)(args...);
|
return (*f)(args...);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function expects you to have set up the state.
|
// This function expects you to have set up the state.
|
||||||
|
|
|
@ -964,10 +964,9 @@ public:
|
||||||
// (this method might be a thunk in the case of multi-inheritance) so we
|
// (this method might be a thunk in the case of multi-inheritance) so we
|
||||||
// have to go through a trampoline function.
|
// have to go through a trampoline function.
|
||||||
template <typename T, typename... Args>
|
template <typename T, typename... Args>
|
||||||
static void CallLambdaTrampoline(const std::function<T(Args...)>* f,
|
static T CallLambdaTrampoline(const std::function<T(Args...)>* f, Args... args)
|
||||||
Args... args)
|
|
||||||
{
|
{
|
||||||
(*f)(args...);
|
return (*f)(args...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, typename... Args>
|
template <typename T, typename... Args>
|
||||||
|
|
Loading…
Reference in New Issue