Name | Date | Size | #Lines | LOC | ||
---|---|---|---|---|---|---|
.. | Today | - | ||||
Optimizer/ | H | 03-Nov-2024 | - | |||
asm/ | H | 03-Nov-2024 | - | |||
tests/ | H | Today | - | |||
LICENSE | H A D | 28-Sep-2023 | 2.7 KiB | 57 | 47 | |
Makefile.frag | H A D | 03-Nov-2024 | 2.3 KiB | 45 | 26 | |
README.md | H A D | 28-Sep-2023 | 4.5 KiB | 140 | 116 | |
Zend.m4 | H A D | 03-Nov-2024 | 11.7 KiB | 402 | 347 | |
bench.php | H A D | 28-Sep-2023 | 7.5 KiB | 423 | 347 | |
micro_bench.php | H A D | 28-Sep-2023 | 7.1 KiB | 359 | 307 | |
zend.c | H A D | 03-Nov-2024 | 57.4 KiB | 2,011 | 1,575 | |
zend.h | H A D | 03-Nov-2024 | 15.5 KiB | 421 | 308 | |
zend_API.c | H A D | 03-Nov-2024 | 152.3 KiB | 5,182 | 4,154 | |
zend_API.h | H A D | 03-Nov-2024 | 103.3 KiB | 2,535 | 2,025 | |
zend_alloc.c | H A D | 03-Nov-2024 | 93.8 KiB | 3,169 | 2,638 | |
zend_alloc.h | H A D | 03-Nov-2024 | 18.8 KiB | 405 | 233 | |
zend_alloc_sizes.h | H A D | 28-Sep-2023 | 2.6 KiB | 65 | 41 | |
zend_arena.h | H A D | 03-Nov-2024 | 5.9 KiB | 225 | 169 | |
zend_ast.c | H A D | 03-Nov-2024 | 72.7 KiB | 2,599 | 2,322 | |
zend_ast.h | H A D | 03-Nov-2024 | 13 KiB | 386 | 305 | |
zend_atomic.c | H A D | 03-Nov-2024 | 1.9 KiB | 48 | 19 | |
zend_atomic.h | H A D | 03-Nov-2024 | 5.6 KiB | 180 | 113 | |
zend_attributes.c | H A D | 03-Nov-2024 | 11.3 KiB | 397 | 295 | |
zend_attributes.h | H A D | 03-Nov-2024 | 5.5 KiB | 127 | 82 | |
zend_attributes.stub.php | H A D | 03-Nov-2024 | 1.6 KiB | 74 | 37 | |
zend_attributes_arginfo.h | H A D | 03-Nov-2024 | 12.1 KiB | 235 | 177 | |
zend_bitset.h | H A D | 03-Nov-2024 | 7.9 KiB | 302 | 232 | |
zend_build.h | H A D | 28-Sep-2023 | 1.6 KiB | 47 | 21 | |
zend_builtin_functions.c | H A D | 03-Nov-2024 | 55.2 KiB | 2,034 | 1,528 | |
zend_builtin_functions.h | H A D | 03-Nov-2024 | 1.5 KiB | 30 | 7 | |
zend_builtin_functions.stub.php | H A D | 03-Nov-2024 | 4.7 KiB | 201 | 62 | |
zend_builtin_functions_arginfo.h | H A D | 03-Nov-2024 | 13.9 KiB | 364 | 293 | |
zend_call_stack.c | H A D | 03-Nov-2024 | 14.8 KiB | 539 | 362 | |
zend_call_stack.h | H A D | 03-Nov-2024 | 2.8 KiB | 95 | 60 | |
zend_closures.c | H A D | 03-Nov-2024 | 29.6 KiB | 905 | 678 | |
zend_closures.h | H A D | 03-Nov-2024 | 2.2 KiB | 45 | 17 | |
zend_closures.stub.php | H A D | 28-Sep-2023 | 547 | 25 | 13 | |
zend_closures_arginfo.h | H A D | 03-Nov-2024 | 2 KiB | 54 | 39 | |
zend_compile.c | H A D | 03-Nov-2024 | 325.2 KiB | 11,010 | 8,852 | |
zend_compile.h | H A D | 03-Nov-2024 | 48.9 KiB | 1,221 | 770 | |
zend_config.w32.h | H A D | 03-Nov-2024 | 2 KiB | 61 | 30 | |
zend_constants.c | H A D | 03-Nov-2024 | 17.6 KiB | 594 | 415 | |
zend_constants.h | H A D | 03-Nov-2024 | 6.5 KiB | 107 | 71 | |
zend_constants.stub.php | H A D | 03-Nov-2024 | 1.7 KiB | 130 | 24 | |
zend_constants_arginfo.h | H A D | 03-Nov-2024 | 1.8 KiB | 32 | 26 | |
zend_cpuinfo.c | H A D | 03-Nov-2024 | 4.7 KiB | 154 | 113 | |
zend_cpuinfo.h | H A D | 03-Nov-2024 | 8.9 KiB | 273 | 200 | |
zend_default_classes.c | H A D | 28-Sep-2023 | 1.8 KiB | 44 | 23 | |
zend_dtrace.c | H A D | 28-Sep-2023 | 4.2 KiB | 122 | 78 | |
zend_dtrace.d | H A D | 28-Sep-2023 | 2.1 KiB | 36 | 13 | |
zend_dtrace.h | H A D | 28-Sep-2023 | 2 KiB | 49 | 22 | |
zend_enum.c | H A D | 03-Nov-2024 | 20.9 KiB | 623 | 500 | |
zend_enum.h | H A D | 03-Nov-2024 | 2.9 KiB | 65 | 36 | |
zend_enum.stub.php | H A D | 28-Sep-2023 | 273 | 16 | 10 | |
zend_enum_arginfo.h | H A D | 03-Nov-2024 | 1.7 KiB | 50 | 32 | |
zend_errors.h | H A D | 03-Nov-2024 | 2.3 KiB | 51 | 23 | |
zend_exceptions.c | H A D | 03-Nov-2024 | 31.7 KiB | 1,048 | 791 | |
zend_exceptions.h | H A D | 03-Nov-2024 | 4.4 KiB | 94 | 49 | |
zend_exceptions.stub.php | H A D | 03-Nov-2024 | 3.9 KiB | 173 | 91 | |
zend_exceptions_arginfo.h | H A D | 03-Nov-2024 | 17.5 KiB | 404 | 293 | |
zend_execute.c | H A D | 03-Nov-2024 | 168.9 KiB | 5,524 | 4,690 | |
zend_execute.h | H A D | 03-Nov-2024 | 22.2 KiB | 535 | 399 | |
zend_execute_API.c | H A D | 03-Nov-2024 | 52.7 KiB | 1,947 | 1,559 | |
zend_extensions.c | H A D | 03-Nov-2024 | 12.7 KiB | 403 | 303 | |
zend_extensions.h | H A D | 03-Nov-2024 | 6.2 KiB | 161 | 88 | |
zend_fibers.c | H A D | 03-Nov-2024 | 31 KiB | 1,092 | 767 | |
zend_fibers.h | H A D | 03-Nov-2024 | 5 KiB | 163 | 79 | |
zend_fibers.stub.php | H A D | 28-Sep-2023 | 752 | 38 | 19 | |
zend_fibers_arginfo.h | H A D | 03-Nov-2024 | 3.5 KiB | 97 | 70 | |
zend_float.c | H A D | 28-Sep-2023 | 1.8 KiB | 57 | 30 | |
zend_float.h | H A D | 03-Nov-2024 | 15.1 KiB | 416 | 259 | |
zend_gc.c | H A D | 03-Nov-2024 | 53.9 KiB | 2,128 | 1,742 | |
zend_gc.h | H A D | 03-Nov-2024 | 4.6 KiB | 161 | 108 | |
zend_gdb.c | H A D | 03-Nov-2024 | 4.4 KiB | 159 | 112 | |
zend_gdb.h | H A D | 28-Sep-2023 | 1.4 KiB | 28 | 6 | |
zend_generators.c | H A D | 03-Nov-2024 | 35.9 KiB | 1,200 | 833 | |
zend_generators.h | H A D | 03-Nov-2024 | 7.3 KiB | 136 | 65 | |
zend_generators.stub.php | H A D | 03-Nov-2024 | 533 | 31 | 15 | |
zend_generators_arginfo.h | H A D | 03-Nov-2024 | 2.7 KiB | 76 | 53 | |
zend_globals.h | H A D | 03-Nov-2024 | 9.5 KiB | 383 | 244 | |
zend_globals_macros.h | H A D | 03-Nov-2024 | 2.7 KiB | 72 | 38 | |
zend_hash.c | H A D | Today | 85 KiB | 3,443 | 2,932 | |
zend_hash.h | H A D | Today | 50.1 KiB | 1,686 | 1,324 | |
zend_highlight.c | H A D | 03-Nov-2024 | 5.6 KiB | 223 | 178 | |
zend_highlight.h | H A D | 03-Nov-2024 | 2.2 KiB | 51 | 24 | |
zend_hrtime.c | H A D | 17-Mar-2024 | 2.1 KiB | 71 | 33 | |
zend_hrtime.h | H A D | 17-Mar-2024 | 3.8 KiB | 108 | 70 | |
zend_inheritance.c | H A D | 03-Nov-2024 | 119.2 KiB | 3,467 | 2,791 | |
zend_inheritance.h | H A D | 03-Nov-2024 | 2.4 KiB | 48 | 18 | |
zend_ini.c | H A D | 03-Nov-2024 | 27.6 KiB | 1,057 | 788 | |
zend_ini.h | H A D | 03-Nov-2024 | 11.9 KiB | 260 | 154 | |
zend_ini_parser.y | H A D | 03-Nov-2024 | 13.6 KiB | 479 | 373 | |
zend_ini_scanner.h | H A D | 03-Nov-2024 | 1.9 KiB | 38 | 14 | |
zend_ini_scanner.l | H A D | 28-Sep-2023 | 17.5 KiB | 692 | 466 | |
zend_interfaces.c | H A D | 03-Nov-2024 | 22 KiB | 678 | 499 | |
zend_interfaces.h | H A D | 28-Sep-2023 | 4 KiB | 82 | 48 | |
zend_interfaces.stub.php | H A D | 28-Sep-2023 | 1.7 KiB | 86 | 43 | |
zend_interfaces_arginfo.h | H A D | 03-Nov-2024 | 7.8 KiB | 216 | 151 | |
zend_istdiostream.h | H A D | 03-Nov-2024 | 1.5 KiB | 35 | 13 | |
zend_iterators.c | H A D | 28-Sep-2023 | 3.3 KiB | 106 | 74 | |
zend_iterators.h | H A D | 03-Nov-2024 | 3.7 KiB | 92 | 37 | |
zend_language_parser.y | H A D | 03-Nov-2024 | 60.9 KiB | 1,774 | 1,490 | |
zend_language_scanner.h | H A D | 03-Nov-2024 | 3 KiB | 86 | 49 | |
zend_language_scanner.l | H A D | 03-Nov-2024 | 75.3 KiB | 3,155 | 2,488 | |
zend_list.c | H A D | 29-Oct-2023 | 9.2 KiB | 350 | 259 | |
zend_list.h | H A D | 28-Sep-2023 | 3.4 KiB | 77 | 40 | |
zend_llist.c | H A D | 28-Sep-2023 | 6.7 KiB | 312 | 229 | |
zend_llist.h | H A D | 03-Nov-2024 | 3.9 KiB | 92 | 59 | |
zend_long.h | H A D | 28-Sep-2023 | 4.1 KiB | 129 | 97 | |
zend_map_ptr.h | H A D | 03-Nov-2024 | 2.9 KiB | 82 | 54 | |
zend_max_execution_timer.c | H A D | 03-Nov-2024 | 3.8 KiB | 127 | 76 | |
zend_max_execution_timer.h | H A D | 28-Sep-2023 | 1.4 KiB | 37 | 13 | |
zend_mmap.h | H A D | 28-Sep-2023 | 1.5 KiB | 45 | 19 | |
zend_modules.h | H A D | 03-Nov-2024 | 4.7 KiB | 132 | 91 | |
zend_multibyte.c | H A D | 03-Nov-2024 | 7.2 KiB | 213 | 159 | |
zend_multibyte.h | H A D | 03-Nov-2024 | 4.8 KiB | 80 | 45 | |
zend_multiply.h | H A D | 03-Nov-2024 | 10 KiB | 357 | 285 | |
zend_object_handlers.c | H A D | 03-Nov-2024 | 61.5 KiB | 2,053 | 1,684 | |
zend_object_handlers.h | H A D | 03-Nov-2024 | 14.2 KiB | 283 | 136 | |
zend_objects.c | H A D | 03-Nov-2024 | 9.9 KiB | 307 | 237 | |
zend_objects.h | H A D | 03-Nov-2024 | 1.8 KiB | 36 | 12 | |
zend_objects_API.c | H A D | 03-Nov-2024 | 6.7 KiB | 209 | 151 | |
zend_objects_API.h | H A D | 03-Nov-2024 | 4.5 KiB | 117 | 70 | |
zend_observer.c | H A D | 03-Nov-2024 | 15.3 KiB | 405 | 306 | |
zend_observer.h | H A D | 03-Nov-2024 | 6.2 KiB | 131 | 80 | |
zend_opcode.c | H A D | 03-Nov-2024 | 36.6 KiB | 1,252 | 1,045 | |
zend_operators.c | H A D | 03-Nov-2024 | 97.5 KiB | 3,772 | 3,161 | |
zend_operators.h | H A D | 03-Nov-2024 | 32.7 KiB | 988 | 811 | |
zend_portability.h | H A D | 03-Nov-2024 | 23.8 KiB | 771 | 600 | |
zend_ptr_stack.c | H A D | 28-Sep-2023 | 2.9 KiB | 118 | 76 | |
zend_ptr_stack.h | H A D | 03-Nov-2024 | 4.2 KiB | 119 | 77 | |
zend_range_check.h | H A D | 28-Sep-2023 | 2.9 KiB | 68 | 32 | |
zend_signal.c | H A D | 03-Nov-2024 | 12.9 KiB | 449 | 315 | |
zend_signal.h | H A D | 03-Nov-2024 | 4 KiB | 113 | 72 | |
zend_smart_str.c | H A D | 03-Nov-2024 | 6.8 KiB | 224 | 181 | |
zend_smart_str.h | H A D | 03-Nov-2024 | 6.8 KiB | 201 | 157 | |
zend_smart_str_public.h | H A D | 03-Nov-2024 | 1.1 KiB | 27 | 7 | |
zend_smart_string.h | H A D | 28-Sep-2023 | 4.1 KiB | 114 | 78 | |
zend_smart_string_public.h | H A D | 28-Sep-2023 | 1.2 KiB | 30 | 9 | |
zend_sort.c | H A D | 28-Sep-2023 | 9.2 KiB | 308 | 192 | |
zend_sort.h | H A D | 03-Nov-2024 | 1.5 KiB | 29 | 7 | |
zend_stack.c | H A D | 28-Sep-2023 | 3.9 KiB | 161 | 115 | |
zend_stack.h | H A D | 03-Nov-2024 | 2.4 KiB | 52 | 26 | |
zend_stream.c | H A D | 28-Sep-2023 | 8.2 KiB | 289 | 226 | |
zend_stream.h | H A D | 03-Nov-2024 | 3.5 KiB | 101 | 66 | |
zend_string.c | H A D | 03-Nov-2024 | 15.9 KiB | 531 | 413 | |
zend_string.h | H A D | 03-Nov-2024 | 21.9 KiB | 644 | 501 | |
zend_strtod.c | H A D | 03-Nov-2024 | 92.1 KiB | 4,638 | 4,003 | |
zend_strtod.h | H A D | 03-Nov-2024 | 2.1 KiB | 46 | 21 | |
zend_strtod_int.h | H A D | 03-Nov-2024 | 3.1 KiB | 128 | 77 | |
zend_system_id.c | H A D | 03-Nov-2024 | 3.1 KiB | 92 | 63 | |
zend_system_id.h | H A D | 03-Nov-2024 | 1.4 KiB | 31 | 9 | |
zend_type_info.h | H A D | 03-Nov-2023 | 4.4 KiB | 85 | 51 | |
zend_types.h | H A D | 03-Nov-2024 | 50.8 KiB | 1,578 | 1,203 | |
zend_variables.c | H A D | 28-Sep-2023 | 4.6 KiB | 136 | 96 | |
zend_variables.h | H A D | 03-Nov-2024 | 3 KiB | 93 | 57 | |
zend_virtual_cwd.c | H A D | 03-Nov-2024 | 42.9 KiB | 1,759 | 1,427 | |
zend_virtual_cwd.h | H A D | 03-Nov-2024 | 12.5 KiB | 395 | 303 | |
zend_vm.h | H A D | 03-Nov-2024 | 1.9 KiB | 42 | 17 | |
zend_vm_def.h | H A D | 03-Nov-2024 | 285.7 KiB | 10,143 | 8,742 | |
zend_vm_execute.h | H A D | 03-Nov-2024 | 2.1 MiB | 65,825 | 58,530 | |
zend_vm_execute.skl | H A D | 28-Sep-2023 | 3.9 KiB | 157 | 133 | |
zend_vm_gen.php | H A D | 03-Nov-2024 | 137 KiB | 3,053 | 2,694 | |
zend_vm_handlers.h | H A D | 03-Nov-2024 | 90 KiB | 1,864 | 1,863 | |
zend_vm_opcodes.c | H A D | 03-Nov-2024 | 9 KiB | 461 | 437 | |
zend_vm_opcodes.h | H A D | 03-Nov-2024 | 12.4 KiB | 293 | 262 | |
zend_vm_trace_handlers.h | H A D | 28-Sep-2023 | 3.1 KiB | 113 | 84 | |
zend_vm_trace_lines.h | H A D | 28-Sep-2023 | 1.7 KiB | 43 | 19 | |
zend_vm_trace_map.h | H A D | 28-Sep-2023 | 2.6 KiB | 82 | 56 | |
zend_weakrefs.c | H A D | 03-Nov-2024 | 24.9 KiB | 778 | 611 | |
zend_weakrefs.h | H A D | 28-Sep-2023 | 3.2 KiB | 75 | 36 | |
zend_weakrefs.stub.php | H A D | 28-Sep-2023 | 826 | 40 | 16 | |
zend_weakrefs_arginfo.h | H A D | 03-Nov-2024 | 3.4 KiB | 89 | 65 |
README.md
1# Zend Engine 2 3## Zend memory manager 4 5### General 6 7The goal of the new memory manager (available since PHP 5.2) is to reduce memory 8allocation overhead and speedup memory management. 9 10### Debugging 11 12Normal: 13 14```bash 15sapi/cli/php -r 'leak();' 16``` 17 18Zend MM disabled: 19 20```bash 21USE_ZEND_ALLOC=0 valgrind --leak-check=full sapi/cli/php -r 'leak();' 22``` 23 24### Shared extensions 25 26Since PHP 5.3.11 it is possible to prevent shared extensions from unloading so 27that valgrind can correctly track the memory leaks in shared extensions. For 28this there is the `ZEND_DONT_UNLOAD_MODULES` environment variable. If set, then 29`DL_UNLOAD()` is skipped during the shutdown of shared extensions. 30 31## ZEND_VM 32 33`ZEND_VM` architecture allows specializing opcode handlers according to 34`op_type` fields and using different execution methods (call threading, switch 35threading and direct threading). As a result ZE2 got more than 20% speedup on 36raw PHP code execution (with specialized executor and direct threading execution 37method). As in most PHP applications raw execution speed isn't the limiting 38factor but system calls and database calls are, your mileage with this patch 39will vary. 40 41Most parts of the old zend_execute.c go into `zend_vm_def.h`. Here you can find 42opcode handlers and helpers. The typical opcode handler template looks like 43this: 44 45```c 46ZEND_VM_HANDLER(<OPCODE-NUMBER>, <OPCODE>, <OP1_TYPES>, <OP2_TYPES>) 47{ 48 <HANDLER'S CODE> 49} 50``` 51 52`<OPCODE-NUMBER>` is a opcode number (0, 1, ...) 53`<OPCODE>` is an opcode name (ZEN_NOP, ZEND_ADD, :) 54`<OP1_TYPES>` and `<OP2_TYPES>` are masks for allowed operand op_types. 55Specializer will generate code only for defined combination of types. You can 56use any combination of the following op_types UNUSED, CONST, VAR, TMP and CV 57also you can use ANY mask to disable specialization according operand's op_type. 58`<HANDLER'S CODE>` is a handler's code itself. For most handlers it stills the 59same as in old `zend_execute.c`, but now it uses macros to access opcode 60operands and some internal executor data. 61 62You can see the conformity of new macros to old code in the following list: 63 64```c 65EXECUTE_DATA 66 execute_data 67ZEND_VM_DISPATCH_TO_HANDLER(<OP>) 68 return <OP>_helper(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU) 69ZEND_VM_DISPATCH_TO_HELPER(<NAME>) 70 return <NAME>(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU) 71ZEND_VM_DISPATCH_TO_HELPER_EX(<NAME>,<PARAM>,<VAL>) 72 return <NAME>(<VAL>, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU) 73ZEND_VM_CONTINUE() 74 return 0 75ZEND_VM_NEXT_OPCODE() 76 NEXT_OPCODE() 77ZEND_VM_SET_OPCODE(<TARGET> 78 SET_OPCODE(<TARGET> 79ZEND_VM_INC_OPCODE() 80 INC_OPCOD() 81ZEND_VM_RETURN_FROM_EXECUTE_LOOP() 82 RETURN_FROM_EXECUTE_LOOP() 83ZEND_VM_C_LABEL(<LABEL>): 84 <LABEL>: 85ZEND_VM_C_GOTO(<LABEL>) 86 goto <LABEL> 87OP<X>_TYPE 88 opline->op<X>.op_type 89GET_OP<X>_ZVAL_PTR(<TYPE>) 90 get_zval_ptr(&opline->op<X>, EX(Ts), &free_op<X>, <TYPE>) 91GET_OP<X>_ZVAL_PTR_PTR(<TYPE>) 92 get_zval_ptr_ptr(&opline->op<X>, EX(Ts), &free_op<X>, <TYPE>) 93GET_OP<X>_OBJ_ZVAL_PTR(<TYPE>) 94 get_obj_zval_ptr(&opline->op<X>, EX(Ts), &free_op<X>, <TYPE>) 95GET_OP<X>_OBJ_ZVAL_PTR_PTR(<TYPE>) 96 get_obj_zval_ptr_ptr(&opline->op<X>, EX(Ts), &free_op<X>, <TYPE>) 97IS_OP<X>_TMP_FREE() 98 IS_TMP_FREE(free_op<X>) 99FREE_OP<X>() 100 FREE_OP(free_op<X>) 101FREE_OP<X>_IF_VAR() 102 FREE_VAR(free_op<X>) 103FREE_OP<X>_VAR_PTR() 104 FREE_VAR_PTR(free_op<X>) 105``` 106 107Executor's helpers can be defined without parameters or with one parameter. This 108is done with the following constructs: 109 110```c 111ZEND_VM_HELPER(<HELPER-NAME>, <OP1_TYPES>, <OP2_TYPES>) 112{ 113 <HELPER'S CODE> 114} 115 116ZEND_VM_HELPER_EX(<HELPER-NAME>, <OP1_TYPES>, <OP2_TYPES>, <PARAM_SPEC>) 117{ 118 <HELPER'S CODE> 119} 120``` 121 122The executors code is generated by the PHP script `zend_vm_gen.php`. It uses 123`zend_vm_def.h` and `zend_vm_execute.skl` as input and produces 124`zend_vm_opcodes.h` and `zend_vm_execute.h`. The first file is a list of opcode 125definitions. It is included from `zend_compile.h`. The second one is an executor 126code itself. It is included from `zend_execute.c`. 127 128`zend_vm_gen.php` can produce different kind of executors. You can select a 129different opcode threading model using `--with-vm-kind=CALL|SWITCH|GOTO|HYBRID`. 130You can disable opcode specialization using `--without-specializer`. 131At last you can debug the executor using the original `zend_vm_def.h` or the 132generated `zend_vm_execute.h` file. Debugging with the original file requires 133the `--with-lines` option. By default, Zend Engine uses the following 134command to generate the executor: 135 136```bash 137# Default VM kind is HYBRID 138php zend_vm_gen.php --with-vm-kind=HYBRID 139``` 140