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
19 #define HAVE_OPROFILE 1
20
21 #include <opagent.h>
22
23 static op_agent_t op_agent = NULL;
24
zend_jit_oprofile_register(const char * name,const void * start,size_t size)25 static void zend_jit_oprofile_register(const char *name,
26 const void *start,
27 size_t size)
28 {
29 if (op_agent) {
30 op_write_native_code(op_agent, name, (uint64_t)(zend_uintptr_t)start, start, size);
31 }
32 }
33
zend_jit_oprofile_startup(void)34 static int zend_jit_oprofile_startup(void)
35 {
36 op_agent = op_open_agent();
37 if (!op_agent) {
38 fprintf(stderr, "OpAgent initialization failed [%d]!\n", errno);
39 return 0;
40 }
41 return 1;
42 }
43
zend_jit_oprofile_shutdown(void)44 static void zend_jit_oprofile_shutdown(void)
45 {
46 if (op_agent) {
47 //??? sleep(60);
48 op_close_agent(op_agent);
49 }
50 }
51