From 5114b37bfae910f9c9e4273b2683de06506914ea Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Tue, 15 Jul 2014 15:13:15 -0500 Subject: [PATCH] Change the x86emitter jmp emitter from using s32 to sptr. This doesn't change anything on x86_32, but it is required on x86_64 so we don't lose precision. Also adds an assert to see if the distance is greater than the maximum 32bit jump, which can't be hit on x86_32, but can be on x86_64. --- common/src/x86emitter/jmp.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/common/src/x86emitter/jmp.cpp b/common/src/x86emitter/jmp.cpp index f5a65e1a07..97bed03330 100644 --- a/common/src/x86emitter/jmp.cpp +++ b/common/src/x86emitter/jmp.cpp @@ -126,7 +126,12 @@ __emitinline void xJccKnownTarget( JccComparisonType comparison, const void* tar { // Perform a 32 bit jump instead. :( s32* bah = xJcc32( comparison ); - *bah = (s32)target - (s32)xGetPtr(); + sptr distance = (sptr)target - (sptr)xGetPtr(); + + // This assert won't physically happen on x86 targets + pxAssertDev(distance >= -0x80000000LL && distance < 0x80000000LL, "Jump target is too far away, needs an indirect register"); + + *bah = (s32)distance; } }