diff options
author | Damien George <damien.p.george@gmail.com> | 2018-10-13 12:57:32 +1100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2018-10-13 15:16:33 +1100 |
commit | 8e4b4bac7079caafbe40646b9303dc9e3ce23fbc (patch) | |
tree | 11bc88c0088d8fc5350c8b223955bbc490496167 /py/asmx64.c | |
parent | 8941c632909bbe51fb854065fbbd58458426a3cf (diff) |
py/asmx64: Change indirect calls to load fun ptr from the native table.
Instead of storing the function pointer directly in the assembly code.
This makes the generated code more independent of the runtime (so easier to
relocate the code), and reduces the generated code size.
Diffstat (limited to 'py/asmx64.c')
-rw-r--r-- | py/asmx64.c | 15 |
1 files changed, 2 insertions, 13 deletions
diff --git a/py/asmx64.c b/py/asmx64.c index 9a3d5fb0d..9cd2fc64c 100644 --- a/py/asmx64.c +++ b/py/asmx64.c @@ -621,21 +621,10 @@ void asm_x64_call_i1(asm_x64_t *as, void* func, int i1) { } */ -void asm_x64_call_ind(asm_x64_t *as, void *ptr, int temp_r64) { +void asm_x64_call_ind(asm_x64_t *as, size_t fun_id, int temp_r64) { assert(temp_r64 < 8); -#ifdef __LP64__ - asm_x64_mov_i64_to_r64_optimised(as, (int64_t)ptr, temp_r64); -#else - // If we get here, sizeof(int) == sizeof(void*). - asm_x64_mov_i64_to_r64_optimised(as, (int64_t)(unsigned int)ptr, temp_r64); -#endif + asm_x64_mov_mem64_to_r64(as, ASM_X64_REG_RBP, fun_id * WORD_SIZE, temp_r64); asm_x64_write_byte_2(as, OPCODE_CALL_RM32, MODRM_R64(2) | MODRM_RM_REG | MODRM_RM_R64(temp_r64)); - // this reduces code size by 2 bytes per call, but doesn't seem to speed it up at all - // doesn't work anymore because calls are 64 bits away - /* - asm_x64_write_byte_1(as, OPCODE_CALL_REL32); - asm_x64_write_word32(as, ptr - (void*)(as->code_base + as->code_offset + 4)); - */ } #endif // MICROPY_EMIT_X64 |