From e48e48a9868297d1ba6732a4d71c4e2bccc2a87c Mon Sep 17 00:00:00 2001 From: mertcandav Date: Fri, 30 Aug 2024 22:41:03 +0300 Subject: [PATCH] api: fix assembly code of closure implementation for amd64 --- api/fn.hpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/api/fn.hpp b/api/fn.hpp index bb85b9d70..2c61a3318 100644 --- a/api/fn.hpp +++ b/api/fn.hpp @@ -122,11 +122,11 @@ namespace jule #if defined(ARCH_AMD64) static const char __closure_thunk[] = { 0xF3, 0x44, 0x0F, 0x7E, 0x3D, 0xF7, 0xBF, 0xFF, 0xFF, // movq xmm15, QWORD PTR [rip - userdata] - 0xFF, 0x25, 0xF9, 0xBF, 0xFF, 0xFF // jmp QWORD PTR [rip - fn] + 0xFF, 0x25, 0xF9, 0xBF, 0xFF, 0xFF, // jmp QWORD PTR [rip - fn] }; static char __closure_get_ctx_bytes[] = { - 0xE0, 0x03, 0x11, 0xAA, // mov x0, x17 - 0xC0, 0x03, 0x5F, 0xD6 // ret + 0x66, 0x4C, 0x0F, 0x7E, 0xF8, // movq rax, xmm15 + 0xC3, // ret }; #elif defined(ARCH_I386) static char __closure_thunk[] = { @@ -139,17 +139,17 @@ namespace jule static char __closure_get_ctx_bytes[] = { 0x66, 0x0F, 0x7E, 0xF8, // movd eax, xmm7 0x8B, 0x80, 0xFB, 0xBF, 0xFF, 0xFF, // mov eax, DWORD PTR [eax - 0x4005] - 0xc3 // ret + 0xc3, // ret }; #elif defined(ARCH_ARM64) static char __closure_thunk[] = { 0x11, 0x00, 0xFE, 0x58, // ldr x17, userdata 0x30, 0x00, 0xFE, 0x58, // ldr x16, fn - 0x00, 0x02, 0x1F, 0xD6 // br x16 + 0x00, 0x02, 0x1F, 0xD6, // br x16 }; static char __closure_get_ctx_bytes[] = { 0xE0, 0x03, 0x11, 0xAA, // mov x0, x17 - 0xC0, 0x03, 0x5F, 0xD6 // ret + 0xC0, 0x03, 0x5F, 0xD6, // ret }; #endif