xref: /PHP-8.3/ext/opcache/jit/zend_jit_vtune.c (revision 2c90fe1d)
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 #if defined(__x86_64__) || defined(i386)
20 
21 #define HAVE_VTUNE 1
22 
23 #include "jit/vtune/jitprofiling.h"
24 #include "jit/vtune/jitprofiling.c"
25 
zend_jit_vtune_register(const char * name,const void * start,size_t size)26 static void zend_jit_vtune_register(const char *name,
27                                     const void *start,
28                                     size_t      size)
29 {
30 	iJIT_Method_Load jmethod = {0};
31 
32 	if (iJIT_IsProfilingActive() != iJIT_SAMPLING_ON) {
33 		return;
34 	}
35 
36 	jmethod.method_id = iJIT_GetNewMethodID();
37 	jmethod.method_name = (char*)name;
38 	jmethod.class_file_name = NULL;
39 	jmethod.source_file_name = NULL;
40 	jmethod.method_load_address = (void*)start;
41 	jmethod.method_size = size;
42 
43 	iJIT_NotifyEvent(iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED, (void*)&jmethod);
44 }
45 
46 #endif /* defined(__x86_64__) || defined(i386) */
47