/Util/EventTimer.h

http://unladen-swallow.googlecode.com/ · C Header · 61 lines · 45 code · 12 blank · 4 comment · 0 complexity · 9cf3b2465514fa772511b7c300a19fca MD5 · raw file

  1. #ifndef UTIL_EVENTTIMER_H
  2. #define UTIL_EVENTTIMER_H
  3. #include "Python.h"
  4. #ifdef WITH_TSC
  5. /* This must be kept in sync with event_names in EventTimer.cc */
  6. typedef enum {
  7. CALL_START_EVAL, // Top of CALL_FUNCTION_* opcodes
  8. CALL_START_LLVM, // Top of CALL_FUNCTION_* LLVM IRs
  9. CALL_ENTER_EVAL, // Top of PyEval_EvalFrame
  10. CALL_ENTER_PYOBJ_CALL, // Any call to PyObject_Call from eval.cc
  11. CALL_ENTER_C, // Before calling C methods in eval.cc
  12. CALL_ENTER_LLVM, // Top of function entry block in LLVM
  13. CALL_END_EVAL, // Bottom of CALL_FUNCTION* opcodes
  14. LLVM_COMPILE_START, // Before JITing or looking up native code
  15. LLVM_COMPILE_END, // After JITing or looking up native code
  16. JIT_START, // Start of LLVM jitting
  17. JIT_END, // End of LLVM jitting
  18. EXCEPT_RAISE_EVAL, // Exception raised in eval loop
  19. EXCEPT_RAISE_LLVM, // Exception raised in LLVM
  20. EXCEPT_CATCH_EVAL, // Exception caught in eval loop
  21. EXCEPT_CATCH_LLVM, // Exception caught in LLVM
  22. LOAD_GLOBAL_ENTER_EVAL, // Start of a LOAD_GLOBAL opcode in the eval loop
  23. LOAD_GLOBAL_EXIT_EVAL, // End of a LOAD_GLOBAL opcode in the eval loop
  24. LOAD_GLOBAL_ENTER_LLVM, // Start of a LOAD_GLOBAL opcode in LLVM
  25. LOAD_GLOBAL_EXIT_LLVM, // End of a LOAD_GLOBAL opcode in LLVM
  26. EVAL_COMPILE_START, // Start of the entire compilation in eval loop
  27. EVAL_COMPILE_END, // End of the entire compilation in eval loop
  28. FLUSH_START, // Start of the TSC event flush
  29. FLUSH_END, // Enf of the TSC event flush
  30. } _PyTscEventId;
  31. typedef unsigned PY_LONG_LONG tsc_t;
  32. typedef struct {
  33. long thread_id;
  34. _PyTscEventId event_id;
  35. tsc_t time;
  36. } _PyTscEvent;
  37. /* Log an event and the TSC when it occurred. */
  38. #ifdef __cplusplus
  39. extern "C" PyAPI_FUNC(void) _PyLog_TscEvent(_PyTscEventId event);
  40. #else
  41. extern PyAPI_FUNC(void) _PyLog_TscEvent(_PyTscEventId event);
  42. #endif
  43. /* Simple macro that wraps up the ifdef WITH_TSC check so that callers don't
  44. have to spell it out in their code. */
  45. #define PY_LOG_TSC_EVENT(event) _PyLog_TscEvent(event)
  46. #else
  47. #define PY_LOG_TSC_EVENT(event)
  48. #endif /* WITH_TSC */
  49. #endif /* UTIL_EVENTTIMER_H */