SPU: add stx/ftx counters

Just count pure transaction successes and failures.
This commit is contained in:
Nekotekina 2020-10-29 05:01:45 +03:00
parent 688a456642
commit 8ce0819b42
5 changed files with 61 additions and 31 deletions

View file

@ -56,7 +56,32 @@ namespace asmjit
asmjit::Runtime& get_global_runtime();
// Emit xbegin and adjacent loop, return label at xbegin (don't use xabort please)
[[nodiscard]] asmjit::Label build_transaction_enter(X86Assembler& c, Label fallback, const X86Gp& ctr, uint less_than);
template <typename F>
[[nodiscard]] inline asmjit::Label build_transaction_enter(asmjit::X86Assembler& c, asmjit::Label fallback, const asmjit::X86Gp& ctr, uint less_than, F func)
{
Label fall = c.newLabel();
Label begin = c.newLabel();
c.jmp(begin);
c.bind(fall);
// First invoked after failure
func();
c.add(ctr, 1);
// Don't repeat on zero status (may indicate syscall or interrupt)
c.test(x86::eax, x86::eax);
c.jz(fallback);
// Other bad statuses are ignored regardless of repeat flag (TODO)
c.cmp(ctr, less_than);
c.jae(fallback);
c.align(kAlignCode, 16);
c.bind(begin);
return fall;
// xbegin should be issued manually, allows to add more check before entering transaction
}
}
// Build runtime function with asmjit::X86Assembler