summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjvoisin2018-03-08 10:58:46 +0100
committerjvoisin2018-03-08 10:58:46 +0100
commit83ba52143d0da9050811d4566b2b77c1b03b0079 (patch)
tree8845aed36e31839617e6940ce4878f2fc6c461fd /src
parentcdc9f69a7881e6969b292bb5c0633547720192e6 (diff)
Marginally improve the performances when dealing with eval
Diffstat (limited to 'src')
-rw-r--r--src/sp_execute.c52
1 files changed, 27 insertions, 25 deletions
diff --git a/src/sp_execute.c b/src/sp_execute.c
index bb9f64e..bb03ad9 100644
--- a/src/sp_execute.c
+++ b/src/sp_execute.c
@@ -35,10 +35,10 @@ ZEND_COLD static inline void terminate_if_writable(const char *filename) {
35 } 35 }
36} 36}
37 37
38static void is_builtin_matching(const char *restrict const filename, 38static void inline is_builtin_matching(const char *restrict const filename,
39 const char *restrict const function_name, 39 const char *restrict const function_name,
40 const char *restrict const param_name, 40 const char *restrict const param_name,
41 const sp_list_node *config) { 41 const sp_list_node *config) {
42 if (!config || !config->data) { 42 if (!config || !config->data) {
43 return; 43 return;
44 } 44 }
@@ -121,31 +121,37 @@ static void sp_execute_ex(zend_execute_data *execute_data) {
121 121
122 if (!execute_data) { 122 if (!execute_data) {
123 return; 123 return;
124 } else if (!execute_data->prev_execute_data ||
125 !execute_data->prev_execute_data->func ||
126 !ZEND_USER_CODE(execute_data->prev_execute_data->func->type) ||
127 !execute_data->prev_execute_data->opline) {
128 if (UNEXPECTED(true == should_disable(execute_data, NULL, NULL, NULL))) {
129 sp_terminate();
130 }
131 } else if (execute_data->prev_execute_data != NULL) {
132 if ((execute_data->prev_execute_data->opline->opcode == ZEND_DO_FCALL ||
133 execute_data->prev_execute_data->opline->opcode == ZEND_DO_UCALL ||
134 execute_data->prev_execute_data->opline->opcode ==
135 ZEND_DO_FCALL_BY_NAME)) {
136 if (UNEXPECTED(true == should_disable(execute_data, NULL, NULL, NULL))) {
137 sp_terminate();
138 }
139 }
140 } 124 }
141 125
142 if (UNEXPECTED(EX(func)->op_array.type == ZEND_EVAL_CODE)) { 126 if (UNEXPECTED(EX(func)->op_array.type == ZEND_EVAL_CODE)) {
143 SNUFFLEUPAGUS_G(in_eval)++;
144 const sp_list_node *config = 127 const sp_list_node *config =
145 SNUFFLEUPAGUS_G(config).config_disabled_constructs->construct_eval; 128 SNUFFLEUPAGUS_G(config).config_disabled_constructs->construct_eval;
146 char *filename = get_eval_filename((char *)zend_get_executed_filename()); 129 char *filename = get_eval_filename((char *)zend_get_executed_filename());
147 is_builtin_matching(filename, "eval", NULL, config); 130 is_builtin_matching(filename, "eval", NULL, config);
148 efree(filename); 131 efree(filename);
132
133 SNUFFLEUPAGUS_G(in_eval)++;
134 orig_execute_ex(execute_data);
135 SNUFFLEUPAGUS_G(in_eval)--;
136 return;
137 }
138
139 if (!execute_data->prev_execute_data ||
140 !execute_data->prev_execute_data->func ||
141 !ZEND_USER_CODE(execute_data->prev_execute_data->func->type) ||
142 !execute_data->prev_execute_data->opline) {
143 if (UNEXPECTED(true == should_disable(execute_data, NULL, NULL, NULL))) {
144 sp_terminate();
145 }
146 } else if ((execute_data->prev_execute_data->opline->opcode ==
147 ZEND_DO_FCALL ||
148 execute_data->prev_execute_data->opline->opcode ==
149 ZEND_DO_UCALL ||
150 execute_data->prev_execute_data->opline->opcode ==
151 ZEND_DO_FCALL_BY_NAME)) {
152 if (UNEXPECTED(true == should_disable(execute_data, NULL, NULL, NULL))) {
153 sp_terminate();
154 }
149 } 155 }
150 156
151 if (NULL != EX(func)->op_array.filename) { 157 if (NULL != EX(func)->op_array.filename) {
@@ -159,10 +165,6 @@ static void sp_execute_ex(zend_execute_data *execute_data) {
159 if (UNEXPECTED(true == should_drop_on_ret(EX(return_value), execute_data))) { 165 if (UNEXPECTED(true == should_drop_on_ret(EX(return_value), execute_data))) {
160 sp_terminate(); 166 sp_terminate();
161 } 167 }
162
163 if (UNEXPECTED(ZEND_EVAL_CODE == EX(func)->op_array.type)) {
164 SNUFFLEUPAGUS_G(in_eval)--;
165 }
166} 168}
167 169
168static void sp_zend_execute_internal(INTERNAL_FUNCTION_PARAMETERS) { 170static void sp_zend_execute_internal(INTERNAL_FUNCTION_PARAMETERS) {