py: Implement full func arg passing for native emitter.
This patch gets full function argument passing working with native emitter. Includes named args, keyword args, default args, var args and var keyword args. Fully Python compliant. It reuses the bytecode mp_setup_code_state function to do all the hard work. This function is slightly adjusted to accommodate native calls, and the native emitter is forced a bit to emit similar prelude and code-info as bytecode.
This commit is contained in:
19
py/asmx64.c
19
py/asmx64.c
@@ -176,6 +176,10 @@ STATIC byte *asm_x64_get_cur_to_write_bytes(asm_x64_t *as, int num_bytes_to_writ
|
||||
}
|
||||
}
|
||||
|
||||
mp_uint_t asm_x64_get_code_pos(asm_x64_t *as) {
|
||||
return as->code_offset;
|
||||
}
|
||||
|
||||
mp_uint_t asm_x64_get_code_size(asm_x64_t *as) {
|
||||
return as->code_size;
|
||||
}
|
||||
@@ -222,6 +226,21 @@ STATIC void asm_x64_write_word64(asm_x64_t *as, int64_t w64) {
|
||||
c[7] = IMM64_L7(w64);
|
||||
}
|
||||
|
||||
// align must be a multiple of 2
|
||||
void asm_x64_align(asm_x64_t* as, mp_uint_t align) {
|
||||
// TODO fill unused data with NOPs?
|
||||
as->code_offset = (as->code_offset + align - 1) & (~(align - 1));
|
||||
}
|
||||
|
||||
void asm_x64_data(asm_x64_t* as, mp_uint_t bytesize, mp_uint_t val) {
|
||||
byte *c = asm_x64_get_cur_to_write_bytes(as, bytesize);
|
||||
// machine is little endian
|
||||
for (uint i = 0; i < bytesize; i++) {
|
||||
*c++ = val;
|
||||
val >>= 8;
|
||||
}
|
||||
}
|
||||
|
||||
/* unused
|
||||
STATIC void asm_x64_write_word32_to(asm_x64_t *as, int offset, int w32) {
|
||||
byte* c;
|
||||
|
||||
Reference in New Issue
Block a user