void _jit_gen_spill_reg(jit_gencode_t gen, int reg, int other_reg, jit_value_t value) { int offset; /* Make sure that we have sufficient space */ jit_cache_setup_output(32); if(flush_if_too_far(gen)) { jit_gen_load_inst_ptr(gen, inst); } /* Output an appropriate instruction to spill the value */ if(value->has_global_register) { arm_mov_reg_reg(inst, _jit_reg_info[value->global_reg].cpu_reg, _jit_reg_info[reg].cpu_reg); } else { _jit_gen_fix_value(value); offset = (int)(value->frame_offset); if(reg < 16) { arm_store_membase(inst, reg, ARM_FP, offset); if(other_reg != -1) { /* Spill the other word register in a pair */ offset += sizeof(void *); arm_store_membase(inst, other_reg, ARM_FP, offset); } } else if(jit_type_normalize(value->type)->kind == JIT_TYPE_FLOAT32) { arm_store_membase_float32(inst, reg - 16, ARM_FP, offset); } else { arm_store_membase_float64(inst, reg - 16, ARM_FP, offset); } } /* End the code output process */ jit_cache_end_output(); }
void _jit_create_closure(unsigned char *buf, void *func, void *closure, void *_type) { arm_inst_buf inst; /* Initialize the instruction buffer */ arm_inst_buf_init(inst, buf, buf + jit_closure_size); /* Set up the local stack frame */ arm_setup_frame(inst, 0); arm_alu_reg_imm8(inst, ARM_SUB, ARM_SP, ARM_SP, 24); /* Create the apply argument block on the stack */ arm_store_membase(inst, ARM_R0, ARM_FP, -28); arm_store_membase(inst, ARM_R1, ARM_FP, -24); arm_store_membase(inst, ARM_R2, ARM_FP, -20); arm_store_membase(inst, ARM_R3, ARM_FP, -16); arm_alu_reg_imm(inst, ARM_ADD, ARM_R3, ARM_FP, 4); arm_store_membase(inst, ARM_R3, ARM_FP, -36); arm_store_membase(inst, ARM_R0, ARM_FP, -32); /* Set up the arguments for calling "func" */ arm_mov_reg_imm(inst, ARM_R0, (int)(jit_nint)closure); arm_mov_reg_reg(inst, ARM_R1, ARM_SP); /* Call the closure handling function */ arm_call(inst, func); /* Pop the current stack frame and return */ arm_pop_frame(inst, 0); }