Skip to content

Commit 5ea3269

Browse files
committed
Recompile zephir code
1 parent 13e7528 commit 5ea3269

31 files changed

+1171
-3021
lines changed

composer.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@
1515
"authors": [
1616
{
1717
"name": "Andrew DalPino",
18-
"role": "Project Lead",
19-
"homepage": "https://github.com/andrewdalpino",
20-
"email": "support@andrewdalpino.com"
18+
"homepage": "https://github.com/andrewdalpino"
2119
},
2220
{
2321
"name": "Contributors",

ext/kernel/array.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
* following url: https://docs.zephir-lang.com/en/latest/license
1010
*/
1111

12-
#ifndef ZEPHIR_KERNEL_ARRAY_H
13-
#define ZEPHIR_KERNEL_ARRAY_H
1412
#define ZEPHIR_MAX_ARRAY_LEVELS 16
1513

1614
#include <php.h>
@@ -73,5 +71,3 @@ int zephir_fast_in_array(zval *needle, zval *haystack);
7371
Z_TRY_ADDREF_P(value); \
7472
zend_hash_next_index_insert(Z_ARRVAL_P(arr), value); \
7573
} while (0)
76-
77-
#endif /* ZEPHIR_KERNEL_ARRAY_H */

ext/kernel/exception.c

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ void zephir_throw_exception_debug(zval *object, const char *file, uint32_t line)
3838

3939
ZVAL_UNDEF(&curline);
4040

41-
ZEPHIR_MM_GROW();
41+
ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0);
42+
zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__);
4243

4344
if (Z_TYPE_P(object) != IS_OBJECT) {
4445
ZVAL_COPY_VALUE(&object_copy, object);
@@ -54,14 +55,8 @@ void zephir_throw_exception_debug(zval *object, const char *file, uint32_t line)
5455
zephir_check_call_status();
5556
if (ZEPHIR_IS_LONG(&curline, 0)) {
5657
default_exception_ce = zend_exception_get_default();
57-
58-
#if PHP_VERSION_ID >= 80000
5958
zend_update_property_string(default_exception_ce, Z_OBJ_P(object), SL("file"), file);
6059
zend_update_property_long(default_exception_ce, Z_OBJ_P(object), SL("line"), line);
61-
#else
62-
zend_update_property_string(default_exception_ce, object, SL("file"), file);
63-
zend_update_property_long(default_exception_ce, object, SL("line"), line);
64-
#endif
6560
}
6661
}
6762

@@ -88,13 +83,8 @@ void zephir_throw_exception_string_debug(zend_class_entry *ce, const char *messa
8883

8984
if (line > 0) {
9085
default_exception_ce = zend_exception_get_default();
91-
#if PHP_VERSION_ID >= 80000
9286
zend_update_property_string(default_exception_ce, Z_OBJ(object), "file", sizeof("file")-1, file);
9387
zend_update_property_long(default_exception_ce, Z_OBJ(object), "line", sizeof("line")-1, line);
94-
#else
95-
zend_update_property_string(default_exception_ce, &object, "file", sizeof("file")-1, file);
96-
zend_update_property_long(default_exception_ce, &object, "line", sizeof("line")-1, line);
97-
#endif
9888
}
9989

10090
if (ZEPHIR_LAST_CALL_STATUS != FAILURE) {

ext/kernel/fcall.c

Lines changed: 16 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -211,21 +211,12 @@ static void populate_fcic(zend_fcall_info_cache* fcic, zephir_call_type type, ze
211211
}
212212

213213
fcic->called_scope = called_scope;
214-
215-
#if PHP_VERSION_ID >= 80000
216214
calling_scope = zend_get_called_scope(EG(current_execute_data));
217-
#else
218-
calling_scope = zend_get_executed_scope();
219-
#endif
220-
221215
fcic->object = this_ptr ? Z_OBJ_P(this_ptr) : NULL;
222216
switch (type) {
223217
case zephir_fcall_parent:
224-
225-
#if PHP_VERSION_ID >= 80000
226218
if (ce && Z_TYPE_P(func) == IS_STRING) {
227219
fcic->function_handler = zend_hash_find_ptr(&ce->parent->function_table, Z_STR_P(func));
228-
229220
fcic->calling_scope = ce->parent;
230221
} else if (EXPECTED(calling_scope && calling_scope->parent)) {
231222
if (Z_TYPE_P(func) == IS_STRING) {
@@ -235,7 +226,7 @@ static void populate_fcic(zend_fcall_info_cache* fcic, zephir_call_type type, ze
235226
} else {
236227
return;
237228
}
238-
#endif
229+
239230
if (UNEXPECTED(!calling_scope || !calling_scope->parent)) {
240231
return;
241232
}
@@ -244,25 +235,17 @@ static void populate_fcic(zend_fcall_info_cache* fcic, zephir_call_type type, ze
244235
break;
245236

246237
case zephir_fcall_static:
247-
#if PHP_VERSION_ID >= 80000
248238
if (ce && Z_TYPE_P(func) == IS_STRING) {
249239
fcic->function_handler = zend_hash_find_ptr(&ce->function_table, Z_STR_P(func));
250240
fcic->calling_scope = ce;
251241
} else if (calling_scope && Z_TYPE_P(func) == IS_STRING) {
252242
fcic->function_handler = zend_hash_find_ptr(&calling_scope->function_table, Z_STR_P(func));
253243
fcic->calling_scope = called_scope;
254244
}
255-
#else
256-
fcic->calling_scope = called_scope;
257-
if (UNEXPECTED(!calling_scope)) {
258-
return;
259-
}
260-
#endif
261245

262246
break;
263247

264248
case zephir_fcall_self:
265-
#if PHP_VERSION_ID >= 80000
266249
if (ce && Z_TYPE_P(func) == IS_STRING) {
267250
fcic->function_handler = zend_hash_find_ptr(&ce->function_table, Z_STR_P(func));
268251
fcic->calling_scope = ce;
@@ -273,13 +256,9 @@ static void populate_fcic(zend_fcall_info_cache* fcic, zephir_call_type type, ze
273256
//fcic->called_scope = zend_get_called_scope(EG(current_execute_data));
274257
fcic->calling_scope = calling_scope;
275258
}
276-
#else
277-
fcic->calling_scope = calling_scope;
278-
#endif
279259
break;
280260

281261
case zephir_fcall_ce:
282-
#if PHP_VERSION_ID >= 80000
283262
if (ce && Z_TYPE_P(func) == IS_STRING) {
284263
fcic->function_handler = zend_hash_find_ptr(&ce->function_table, Z_STR_P(func));
285264

@@ -288,7 +267,6 @@ static void populate_fcic(zend_fcall_info_cache* fcic, zephir_call_type type, ze
288267
fcic->function_handler = zend_hash_find_ptr(&calling_scope->function_table, Z_STR_P(func));
289268
fcic->calling_scope = calling_scope;
290269
}
291-
#endif
292270
// TODO: Check for PHP 7.4 and PHP 8.0, as it rewrite from above
293271
fcic->calling_scope = ce;
294272
fcic->called_scope = ce;
@@ -297,23 +275,17 @@ static void populate_fcic(zend_fcall_info_cache* fcic, zephir_call_type type, ze
297275
case zephir_fcall_function:
298276
case zephir_fcall_method:
299277
if (Z_TYPE_P(func) == IS_OBJECT) {
300-
#if PHP_VERSION_ID >= 80000
301278
if (Z_OBJ_HANDLER_P(func, get_closure) && Z_OBJ_HANDLER_P(func, get_closure)(Z_OBJ_P(func), &fcic->calling_scope, &fcic->function_handler, &fcic->object, 0) == SUCCESS) {
302-
#else
303-
if (Z_OBJ_HANDLER_P(func, get_closure) && Z_OBJ_HANDLER_P(func, get_closure)(func, &fcic->calling_scope, &fcic->function_handler, &fcic->object) == SUCCESS) {
304-
#endif
305279
fcic->called_scope = fcic->calling_scope;
306280
break;
307281
}
308282

309283
return;
310284
}
311285

312-
#if PHP_VERSION_ID >= 80000
313286
if (ce && Z_TYPE_P(func) == IS_STRING) {
314287
fcic->function_handler = zend_hash_find_ptr(&ce->function_table, Z_STR_P(func));
315288
}
316-
#endif
317289
fcic->calling_scope = this_ptr ? Z_OBJCE_P(this_ptr) : NULL;
318290
fcic->called_scope = fcic->calling_scope;
319291
break;
@@ -383,12 +355,7 @@ int zephir_call_user_function(
383355
ZVAL_COPY_VALUE(&fci.function_name, function_name);
384356
fci.retval = retval_ptr ? retval_ptr : &local_retval_ptr;
385357
fci.param_count = param_count;
386-
387-
#if PHP_VERSION_ID < 80000
388-
fci.no_separation = 1;
389-
#else
390358
fci.named_params = NULL;
391-
#endif
392359

393360
if (cache_entry && *cache_entry) {
394361
/* We have a cache record, initialize scope */
@@ -402,22 +369,22 @@ int zephir_call_user_function(
402369
/* The caller is interested in caching OR we have the call cache enabled */
403370
resolve_callable(&callable, type, (object_pp && type != zephir_fcall_ce ? Z_OBJCE_P(object_pp) : obj_ce), object_pp, function_name);
404371

405-
#if PHP_VERSION_ID >= 80000
406-
char *is_callable_error = NULL;
407-
zend_execute_data *frame = EG(current_execute_data);
372+
char *is_callable_error = NULL;
373+
zend_execute_data *frame = EG(current_execute_data);
374+
#if PHP_VERSION_ID >= 80200
375+
if (obj_ce || !zend_is_callable_at_frame(&callable, fci.object, frame, IS_CALLABLE_SUPPRESS_DEPRECATIONS, &fcic, &is_callable_error)) {
376+
#else
408377
if (obj_ce || !zend_is_callable_at_frame(&callable, fci.object, frame, 0, &fcic, &is_callable_error)) {
409-
if (is_callable_error) {
410-
zend_error(E_WARNING, "%s", is_callable_error);
411-
efree(is_callable_error);
378+
#endif
379+
if (is_callable_error) {
380+
zend_error(E_WARNING, "%s", is_callable_error);
381+
efree(is_callable_error);
412382

413-
return FAILURE;
414-
}
383+
return FAILURE;
384+
}
415385

416386
populate_fcic(&fcic, type, obj_ce, object_pp, function_name, called_scope);
417387
}
418-
#else
419-
zend_is_callable_ex(&callable, fci.object, IS_CALLABLE_CHECK_SILENT, NULL, &fcic, NULL);
420-
#endif
421388
}
422389

423390
#ifdef _MSC_VER
@@ -432,12 +399,9 @@ int zephir_call_user_function(
432399
}
433400

434401
fci.params = p;
435-
436-
#if PHP_VERSION_ID >= 80000
437402
if (!fcic.function_handler) {
438403
ZVAL_COPY_VALUE(&fci.function_name, &callable);
439404
}
440-
#endif
441405

442406
status = zend_call_function(&fci, &fcic);
443407

@@ -630,31 +594,12 @@ int zephir_call_user_func_array_noex(zval *return_value, zval *handler, zval *pa
630594
return FAILURE;
631595
}
632596

633-
#if PHP_VERSION_ID < 80000
634-
zend_fcall_info_init(handler, 0, &fci, &fci_cache, NULL, &is_callable_error);
635-
636-
if (is_callable_error) {
637-
zend_error(E_WARNING, "%s", is_callable_error);
638-
efree(is_callable_error);
639-
} else {
640-
status = SUCCESS;
641-
}
642-
643-
if (status == SUCCESS) {
644-
zend_fcall_info_args(&fci, params);
645-
646-
fci.retval = return_value;
647-
zend_call_function(&fci, &fci_cache);
648-
649-
zend_fcall_info_args_clear(&fci, 1);
650-
}
651-
652-
if (EG(exception)) {
653-
status = SUCCESS;
654-
}
655-
#else
656597
zend_execute_data *frame = EG(current_execute_data);
598+
#if PHP_VERSION_ID >= 80200
599+
if (!zend_is_callable_at_frame(handler, NULL, frame, IS_CALLABLE_SUPPRESS_DEPRECATIONS, &fci_cache, &is_callable_error)) {
600+
#else
657601
if (!zend_is_callable_at_frame(handler, NULL, frame, 0, &fci_cache, &is_callable_error)) {
602+
#endif
658603
if (is_callable_error) {
659604
zend_error(E_WARNING, "%s", is_callable_error);
660605
efree(is_callable_error);
@@ -674,7 +619,6 @@ int zephir_call_user_func_array_noex(zval *return_value, zval *handler, zval *pa
674619
zend_fcall_info_args(&fci, params);
675620
status = zend_call_function(&fci, &fci_cache);
676621
zend_fcall_info_args_clear(&fci, 1);
677-
#endif
678622

679623
return status;
680624
}
@@ -696,11 +640,7 @@ void zephir_eval_php(zval *str, zval *retval_ptr, char *context)
696640
#if PHP_VERSION_ID >= 80200
697641
new_op_array = zend_compile_string(Z_STR_P(str), context, ZEND_COMPILE_POSITION_AFTER_OPEN_TAG);
698642
#else
699-
#if PHP_VERSION_ID >= 80000
700643
new_op_array = zend_compile_string(Z_STR_P(str), context);
701-
#else
702-
new_op_array = zend_compile_string(str, context);
703-
#endif
704644
#endif
705645

706646
CG(compiler_options) = original_compiler_options;

ext/kernel/fcall.h

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -167,71 +167,37 @@ typedef enum _zephir_call_type {
167167
ZEPHIR_LAST_CALL_STATUS = zephir_return_call_class_method(return_value, Z_TYPE_P(object) == IS_OBJECT ? Z_OBJCE_P(object) : NULL, zephir_fcall_method, object, method, strlen(method), cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_)); \
168168
} while (0)
169169

170-
#if PHP_VERSION_ID >= 80000
171170
#define ZEPHIR_RETURN_CALL_STATIC(method, cache, cache_slot, ...) \
172171
do { \
173172
zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \
174173
ZEPHIR_LAST_CALL_STATUS = zephir_return_call_class_method(return_value, (getThis() ? Z_OBJCE_P(getThis()) : NULL), zephir_fcall_static, getThis(), method, strlen(method), cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_)); \
175174
} while (0)
176-
#else
177-
#define ZEPHIR_RETURN_CALL_STATIC(method, cache, cache_slot, ...) \
178-
do { \
179-
zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \
180-
ZEPHIR_LAST_CALL_STATUS = zephir_return_call_class_method(return_value, NULL, zephir_fcall_static, NULL, method, strlen(method), cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_)); \
181-
} while (0)
182-
#endif
183175

184176
#define ZEPHIR_RETURN_CALL_PARENT(class_entry, this_ptr, method, cache, cache_slot, ...) \
185177
do { \
186178
zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \
187179
ZEPHIR_LAST_CALL_STATUS = zephir_return_call_class_method(return_value, class_entry, zephir_fcall_parent, this_ptr, method, strlen(method), cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_)); \
188180
} while (0)
189181

190-
#if PHP_VERSION_ID >= 80000
191182
#define ZEPHIR_CALL_SELF(return_value_ptr, method, cache, cache_slot, ...) \
192183
do { \
193184
zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \
194185
ZEPHIR_OBSERVE_OR_NULLIFY_PPZV(return_value_ptr); \
195186
ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, (getThis() ? Z_OBJCE_P(getThis()) : NULL), zephir_fcall_self, getThis(), method, strlen(method), cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_)); \
196187
} while (0)
197-
#else
198-
#define ZEPHIR_CALL_SELF(return_value_ptr, method, cache, cache_slot, ...) \
199-
do { \
200-
zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \
201-
ZEPHIR_OBSERVE_OR_NULLIFY_PPZV(return_value_ptr); \
202-
ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, NULL, zephir_fcall_self, NULL, method, strlen(method), cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_)); \
203-
} while (0)
204-
#endif
205188

206-
#if PHP_VERSION_ID >= 80000
207189
#define ZEPHIR_RETURN_CALL_SELF(method, cache, cache_slot, ...) \
208190
do { \
209191
zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \
210192
ZEPHIR_LAST_CALL_STATUS = zephir_return_call_class_method(return_value, (getThis() ? Z_OBJCE_P(getThis()) : NULL), zephir_fcall_self, getThis(), method, strlen(method), cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_)); \
211193
} while (0)
212-
#else
213-
#define ZEPHIR_RETURN_CALL_SELF(method, cache, cache_slot, ...) \
214-
do { \
215-
zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \
216-
ZEPHIR_LAST_CALL_STATUS = zephir_return_call_class_method(return_value, NULL, zephir_fcall_self, NULL, method, strlen(method), cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_)); \
217-
} while (0)
218-
#endif
219194

220-
#if PHP_VERSION_ID >= 80000
221195
#define ZEPHIR_CALL_STATIC(return_value_ptr, method, cache, cache_slot, ...) \
222196
do { \
223197
zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \
224198
ZEPHIR_OBSERVE_OR_NULLIFY_PPZV(return_value_ptr); \
225199
ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, (getThis() ? Z_OBJCE_P(getThis()) : NULL), zephir_fcall_static, getThis(), method, strlen(method), cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_)); \
226200
} while (0)
227-
#else
228-
#define ZEPHIR_CALL_STATIC(return_value_ptr, method, cache, cache_slot, ...) \
229-
do { \
230-
zval *params_[] = {ZEPHIR_FETCH_VA_ARGS __VA_ARGS__}; \
231-
ZEPHIR_OBSERVE_OR_NULLIFY_PPZV(return_value_ptr); \
232-
ZEPHIR_LAST_CALL_STATUS = zephir_call_class_method_aparams(return_value_ptr, NULL, zephir_fcall_static, NULL, method, strlen(method), cache, cache_slot, ZEPHIR_CALL_NUM_PARAMS(params_), ZEPHIR_PASS_CALL_PARAMS(params_)); \
233-
} while (0)
234-
#endif
235201

236202
#define ZEPHIR_CALL_CE_STATIC(return_value_ptr, class_entry, method, cache, cache_slot, ...) \
237203
do { \

0 commit comments

Comments
 (0)