Skip to content

Commit

Permalink
api: fix assembly code of closure implementation for amd64
Browse files Browse the repository at this point in the history
  • Loading branch information
mertcandav committed Aug 30, 2024
1 parent 5833143 commit e48e48a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions api/fn.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = {
Expand All @@ -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

Expand Down

0 comments on commit e48e48a

Please sign in to comment.