Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Common: CallLambdaTrampoline can return a value #2697

Merged
merged 1 commit into from Jul 4, 2015

Conversation

endrift
Copy link
Contributor

@endrift endrift commented Jul 4, 2015

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.

@endrift endrift changed the title x86Emitter: CallLambdaTrampoline can return a value Common: CallLambdaTrampoline can return a value Jul 4, 2015
@@ -971,10 +971,10 @@ class XEmitter
// (this method might be a thunk in the case of multi-inheritance) so we
// have to go through a trampoline function.
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)

This comment was marked as off-topic.

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.
@degasus
Copy link
Member

degasus commented Jul 4, 2015

LGTM, however, I have no clue about Jit64...

@degasus
Copy link
Member

degasus commented Jul 4, 2015

CC stable @Armada651

@Tilka
Copy link
Member

Tilka commented Jul 4, 2015

lgtm

The place where the return value is used is here.

@Sonicadvance1
Copy link
Contributor

Tilka added a commit that referenced this pull request Jul 4, 2015
Common: CallLambdaTrampoline can return a value
@Tilka Tilka merged commit 3bbb2ed into dolphin-emu:master Jul 4, 2015
@phire
Copy link
Member

phire commented Jul 4, 2015

Has been cherry-picked into stable.

@endrift endrift deleted the fix-jit-trampoline branch July 5, 2015 01:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
6 participants