-
-
Save krakjoe/3bd2ee8fc19c104ca0799d503d0dbd23 to your computer and use it in GitHub Desktop.
pcov user opcode handlers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/pcov.c b/pcov.c | |
index bd34eff..8c42845 100644 | |
--- a/pcov.c | |
+++ b/pcov.c | |
@@ -60,7 +60,6 @@ | |
static zval php_pcov_uncovered; | |
static zval php_pcov_covered; | |
-void (*zend_execute_ex_function)(zend_execute_data *execute_data); | |
zend_op_array* (*zend_compile_file_function)(zend_file_handle *fh, int type) = NULL; | |
ZEND_DECLARE_MODULE_GLOBALS(pcov) | |
@@ -208,7 +207,7 @@ static zend_always_inline int php_pcov_trace(zend_execute_data *execute_data) { | |
PCG(next) = &coverage->next; | |
} | |
- return zend_vm_call_opcode_handler(execute_data); | |
+ return ZEND_USER_OPCODE_DISPATCH; | |
} /* }}} */ | |
zend_op_array* php_pcov_compile_file(zend_file_handle *fh, int type) { /* {{{ */ | |
@@ -243,21 +242,6 @@ zend_op_array* php_pcov_compile_file(zend_file_handle *fh, int type) { /* {{{ */ | |
return result; | |
} /* }}} */ | |
-void php_pcov_execute_ex(zend_execute_data *execute_data) { /* {{{ */ | |
- int zrc = 0; | |
- | |
- while (1) { | |
- zrc = php_pcov_trace(execute_data); | |
- | |
- if (zrc != SUCCESS) { | |
- if (zrc < SUCCESS) { | |
- return; | |
- } | |
- execute_data = EG(current_execute_data); | |
- } | |
- } | |
-} /* }}} */ | |
- | |
void php_pcov_files_dtor(zval *zv) { /* {{{ */ | |
destroy_op_array(Z_PTR_P(zv)); | |
efree(Z_PTR_P(zv)); | |
@@ -276,8 +260,18 @@ PHP_MINIT_FUNCTION(pcov) | |
REGISTER_INI_ENTRIES(); | |
if (INI_BOOL("pcov.enabled")) { | |
- zend_execute_ex_function = zend_execute_ex; | |
- zend_execute_ex = php_pcov_execute_ex; | |
+ uint32_t it = 1, | |
+ end = 256; | |
+ | |
+ while (it < end) { | |
+ if (it == ZEND_HANDLE_EXCEPTION) { | |
+ it++; | |
+ continue; | |
+ } | |
+ | |
+ zend_set_user_opcode_handler(it, php_pcov_trace); | |
+ it++; | |
+ } | |
} | |
ZVAL_LONG(&php_pcov_uncovered, PHP_PCOV_UNCOVERED); | |
@@ -292,7 +286,18 @@ PHP_MINIT_FUNCTION(pcov) | |
PHP_MSHUTDOWN_FUNCTION(pcov) | |
{ | |
if (INI_BOOL("pcov.enabled")) { | |
- zend_execute_ex = zend_execute_ex_function; | |
+ uint32_t it = 1, | |
+ end = 256; | |
+ | |
+ while (it < end) { | |
+ if (it == ZEND_HANDLE_EXCEPTION) { | |
+ it++; | |
+ continue; | |
+ } | |
+ | |
+ zend_set_user_opcode_handler(it, NULL); | |
+ it++; | |
+ } | |
} | |
UNREGISTER_INI_ENTRIES(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment