lj_trace.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. ** Trace management.
  3. ** Copyright (C) 2005-2023 Mike Pall. See Copyright Notice in luajit.h
  4. */
  5. #ifndef _LJ_TRACE_H
  6. #define _LJ_TRACE_H
  7. #include "lj_obj.h"
  8. #if LJ_HASJIT
  9. #include "lj_jit.h"
  10. #include "lj_dispatch.h"
  11. /* Trace errors. */
  12. typedef enum {
  13. #define TREDEF(name, msg) LJ_TRERR_##name,
  14. #include "lj_traceerr.h"
  15. LJ_TRERR__MAX
  16. } TraceError;
  17. LJ_FUNC_NORET void lj_trace_err(jit_State *J, TraceError e);
  18. LJ_FUNC_NORET void lj_trace_err_info(jit_State *J, TraceError e);
  19. /* Trace management. */
  20. LJ_FUNC GCtrace * LJ_FASTCALL lj_trace_alloc(lua_State *L, GCtrace *T);
  21. LJ_FUNC void LJ_FASTCALL lj_trace_free(global_State *g, GCtrace *T);
  22. LJ_FUNC void lj_trace_reenableproto(GCproto *pt);
  23. LJ_FUNC void lj_trace_flushproto(global_State *g, GCproto *pt);
  24. LJ_FUNC void lj_trace_flush(jit_State *J, TraceNo traceno);
  25. LJ_FUNC int lj_trace_flushall(lua_State *L);
  26. LJ_FUNC void lj_trace_initstate(global_State *g);
  27. LJ_FUNC void lj_trace_freestate(global_State *g);
  28. /* Event handling. */
  29. LJ_FUNC void lj_trace_ins(jit_State *J, const BCIns *pc);
  30. LJ_FUNCA void LJ_FASTCALL lj_trace_hot(jit_State *J, const BCIns *pc);
  31. LJ_FUNCA void LJ_FASTCALL lj_trace_stitch(jit_State *J, const BCIns *pc);
  32. LJ_FUNCA int LJ_FASTCALL lj_trace_exit(jit_State *J, void *exptr);
  33. #if LJ_UNWIND_EXT
  34. LJ_FUNC uintptr_t LJ_FASTCALL lj_trace_unwind(jit_State *J, uintptr_t addr, ExitNo *ep);
  35. #endif
  36. /* Signal asynchronous abort of trace or end of trace. */
  37. #define lj_trace_abort(g) (G2J(g)->state &= ~LJ_TRACE_ACTIVE)
  38. #define lj_trace_end(J) (J->state = LJ_TRACE_END)
  39. #else
  40. #define lj_trace_flushall(L) (UNUSED(L), 0)
  41. #define lj_trace_initstate(g) UNUSED(g)
  42. #define lj_trace_freestate(g) UNUSED(g)
  43. #define lj_trace_abort(g) UNUSED(g)
  44. #define lj_trace_end(J) UNUSED(J)
  45. #endif
  46. #endif