Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
implement mono_arch_get_throw_corlib_exception
  • Loading branch information
Xinlong-Wu committed Apr 8, 2023
commit 8d26d93d4994abffd933b93e2030fbd49090e73e
10 changes: 5 additions & 5 deletions src/mono/mono/mini/cpu-riscv64.mdesc
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,11 @@ riscv_bge: src1:i src2:i len:8
riscv_bgeu: src1:i src2:i len:8
riscv_blt: src1:i src2:i len:8
riscv_bltu: src1:i src2:i len:8
riscv_exc_beq: src1:i src2:i len:8
riscv_exc_bne: src1:i src2:i len:8
riscv_exc_bgeu: src1:i src2:i len:8
riscv_exc_blt: src1:i src2:i len:8
riscv_exc_bltu: src1:i src2:i len:8
riscv_exc_beq: src1:i src2:i len:12
riscv_exc_bne: src1:i src2:i len:12
riscv_exc_bgeu: src1:i src2:i len:12
riscv_exc_blt: src1:i src2:i len:12
riscv_exc_bltu: src1:i src2:i len:12
riscv_slt: dest:i src1:i src2:i len:4
riscv_sltu: dest:i src1:i src2:i len:4
riscv_slti: dest:i src1:i len:4
Expand Down
13 changes: 8 additions & 5 deletions src/mono/mono/mini/exceptions-riscv.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ get_throw_trampoline (int size, gboolean corlib, gboolean rethrow, gboolean llvm
/* Save gregs */
code = mono_riscv_emit_store_stack (code, 0xffffffff, RISCV_FP, -gregs_offset, FALSE);
if (corlib && !llvm)
NOT_IMPLEMENTED;
/* The real ra is in A1 */
code = mono_riscv_emit_store (code, RISCV_A1, RISCV_FP, -gregs_offset + (RISCV_RA * sizeof(host_mgreg_t)), 0);

/* Save previous fp/sp */
code = mono_riscv_emit_load (code, RISCV_T0, RISCV_FP, -2 * sizeof(host_mgreg_t), 0);
Expand All @@ -170,8 +171,11 @@ get_throw_trampoline (int size, gboolean corlib, gboolean rethrow, gboolean llvm
/* Arg1 = exception object/type token */
// riscv_addi (code, RISCV_A0, RISCV_A0, 0);
/* Arg2 = caller ip, should be return address in this case */
if (corlib)
NOT_IMPLEMENTED;
if (corlib){
// caller ip are set to A1 already
if (llvm)
NOT_IMPLEMENTED;
}
else
code = mono_riscv_emit_load (code, RISCV_A1, RISCV_FP, -sizeof(host_mgreg_t), 0);
/* Arg 3 = gregs */
Expand Down Expand Up @@ -240,8 +244,7 @@ mono_arch_get_rethrow_preserve_exception (MonoTrampInfo **info, gboolean aot)
gpointer
mono_arch_get_throw_corlib_exception (MonoTrampInfo **info, gboolean aot)
{
*info = NULL;
return nop_stub (0xaa);
return get_throw_trampoline (384, TRUE, FALSE, FALSE, FALSE, "throw_corlib_exception", info, aot, FALSE);
}

#else
Expand Down
14 changes: 1 addition & 13 deletions src/mono/mono/mini/mini-riscv.c
Original file line number Diff line number Diff line change
Expand Up @@ -3217,19 +3217,7 @@ mono_riscv_emit_call (MonoCompile *cfg, guint8 *code, MonoJumpInfoType patch_typ
static guint8 *
mono_riscv_emit_branch_exc (MonoCompile *cfg, guint8 *code, int opcode, int sreg1, int sreg2, const char *exc_name)
{
// guint8 *p;

// riscv_auipc(code, RISCV_T0, 0);
// // load imm
// riscv_jal (code, RISCV_T1, sizeof (guint64) + 4);
// p = code;
// code += sizeof (guint64);
// riscv_ld (code, RISCV_T1, RISCV_T1, 0);
// // pc + imm
// riscv_add(code, RISCV_T0, RISCV_T0, RISCV_T1);

// *(guint64 *)p = (gsize)code;

riscv_auipc(code, RISCV_T0, 0);
switch (opcode) {
case OP_RISCV_EXC_BEQ:
riscv_bne (code, sreg1, sreg2, 8);
Expand Down