zend_jit_oprofile.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. +----------------------------------------------------------------------+
  3. | Zend JIT |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) The PHP Group |
  6. +----------------------------------------------------------------------+
  7. | This source file is subject to version 3.01 of the PHP license, |
  8. | that is bundled with this package in the file LICENSE, and is |
  9. | available through the world-wide-web at the following url: |
  10. | https://www.php.net/license/3_01.txt |
  11. | If you did not receive a copy of the PHP license and are unable to |
  12. | obtain it through the world-wide-web, please send a note to |
  13. | license@php.net so we can mail you a copy immediately. |
  14. +----------------------------------------------------------------------+
  15. | Authors: Dmitry Stogov <dmitry@php.net> |
  16. +----------------------------------------------------------------------+
  17. */
  18. #define HAVE_OPROFILE 1
  19. #include <opagent.h>
  20. static op_agent_t op_agent = NULL;
  21. static void zend_jit_oprofile_register(const char *name,
  22. const void *start,
  23. size_t size)
  24. {
  25. if (op_agent) {
  26. op_write_native_code(op_agent, name, (uint64_t)(zend_uintptr_t)start, start, size);
  27. }
  28. }
  29. static int zend_jit_oprofile_startup(void)
  30. {
  31. op_agent = op_open_agent();
  32. if (!op_agent) {
  33. fprintf(stderr, "OpAgent initialization failed [%d]!\n", errno);
  34. return 0;
  35. }
  36. return 1;
  37. }
  38. static void zend_jit_oprofile_shutdown(void)
  39. {
  40. if (op_agent) {
  41. //??? sleep(60);
  42. op_close_agent(op_agent);
  43. }
  44. }