• Home
  • History
  • Annotate
  • only in this directory
Name Date Size

..Today708

bench.phpH A D04-févr.-20207,5 KiB

LICENSEH A D13-févr.-20192,7 KiB

Makefile.fragH A D06-juin-20192 KiB

micro_bench.phpH A D04-févr.-20207,1 KiB

README.mdH A D20-mai-20194,5 KiB

tests/H13-oct.-202067,7 KiB

zend.cH A D23-juil.-202049,5 KiB

zend.hH A D16-mars-202013,6 KiB

Zend.m4H A D06-oct.-202013,8 KiB

zend_alloc.cH A D28-févr.-202089,4 KiB

zend_alloc.hH A D31-janv.-202018,8 KiB

zend_alloc_sizes.hH A D13-févr.-20192,6 KiB

zend_API.cH A D31-août-2020129,2 KiB

zend_API.hH A D12-juil.-201969,4 KiB

zend_arena.hH A D01-juil.-20195,9 KiB

zend_ast.cH A D04-févr.-202058,8 KiB

zend_ast.hH A D03-mai-201911,4 KiB

zend_bitset.hH A D13-févr.-20196,7 KiB

zend_build.hH A D13-févr.-20191,6 KiB

zend_builtin_functions.cH A D03-août-202073,7 KiB

zend_builtin_functions.hH A D13-févr.-20191,5 KiB

zend_closures.cH A D08-juil.-202026,2 KiB

zend_closures.hH A D13-févr.-20192,2 KiB

zend_compile.cH A D08-juil.-2020261,7 KiB

zend_compile.hH A D23-oct.-201942,6 KiB

zend_config.w32.hH A D07-mars-20192,6 KiB

zend_constants.cH A D13-févr.-201917,2 KiB

zend_constants.hH A D13-févr.-20196,2 KiB

zend_cpuinfo.cH A D13-févr.-20193,3 KiB

zend_cpuinfo.hH A D02-juil.-20197,1 KiB

zend_default_classes.cH A D12-mars-20191,6 KiB

zend_dtrace.cH A D13-févr.-20194 KiB

zend_dtrace.dH A D13-févr.-20192,1 KiB

zend_dtrace.hH A D13-févr.-20191,9 KiB

zend_errors.hH A D13-févr.-20192 KiB

zend_exceptions.cH A D01-juil.-202034 KiB

zend_exceptions.hH A D13-févr.-20193,8 KiB

zend_execute.cH A D03-sept.-2020144,7 KiB

zend_execute.hH A D10-déc.-201916,5 KiB

zend_execute_API.cH A D25-août-202046,1 KiB

zend_extensions.cH A D13-févr.-20199,9 KiB

zend_extensions.hH A D03-sept.-20195,9 KiB

zend_float.cH A D13-févr.-20191,8 KiB

zend_float.hH A D27-mai-202015,1 KiB

zend_gc.cH A D25-nov.-201939,1 KiB

zend_gc.hH A D11-juil.-20192,8 KiB

zend_generators.cH A D03-sept.-202037,5 KiB

zend_generators.hH A D13-févr.-20197,2 KiB

zend_globals.hH A D16-déc.-20197,6 KiB

zend_globals_macros.hH A D14-mars-20192,7 KiB

zend_hash.cH A D13-oct.-202070,2 KiB

zend_hash.hH A D12-juin-201935,6 KiB

zend_highlight.cH A D29-mars-20195,8 KiB

zend_highlight.hH A D13-févr.-20192,2 KiB

zend_inheritance.cH A D07-oct.-202090 KiB

zend_inheritance.hH A D13-sept.-20192 KiB

zend_ini.cH A D24-août-202017,4 KiB

zend_ini.hH A D30-mai-20199,6 KiB

zend_ini_parser.yH A D15-mai-202011,8 KiB

zend_ini_scanner.hH A D13-févr.-20191,8 KiB

zend_ini_scanner.lH A D10-févr.-202016,8 KiB

zend_interfaces.cH A D12-juin-201919,2 KiB

zend_interfaces.hH A D13-févr.-20194,2 KiB

zend_istdiostream.hH A D13-févr.-20191,5 KiB

zend_iterators.cH A D13-févr.-20193,1 KiB

zend_iterators.hH A D13-févr.-20193,3 KiB

zend_language_parser.yH A D30-janv.-202048,1 KiB

zend_language_scanner.hH A D13-févr.-20192,7 KiB

zend_language_scanner.lH A D16-sept.-202068,2 KiB

zend_list.cH A D26-juin-20199 KiB

zend_list.hH A D26-juin-20193,4 KiB

zend_llist.cH A D13-févr.-20196,7 KiB

zend_llist.hH A D13-févr.-20193,7 KiB

zend_long.hH A D13-févr.-20194,2 KiB

zend_map_ptr.hH A D13-févr.-20193,1 KiB

zend_modules.hH A D03-sept.-20194,7 KiB

zend_multibyte.cH A D13-févr.-20197,2 KiB

zend_multibyte.hH A D13-févr.-20194,7 KiB

zend_multiply.hH A D13-févr.-20199,6 KiB

zend_object_handlers.cH A D16-sept.-202056,5 KiB

zend_object_handlers.hH A D19-févr.-201913,2 KiB

zend_objects.cH A D28-oct.-20199,5 KiB

zend_objects.hH A D13-févr.-20191,8 KiB

zend_objects_API.cH A D29-août-20196,6 KiB

zend_objects_API.hH A D13-févr.-20194,6 KiB

zend_opcode.cH A D31-janv.-202033,2 KiB

zend_operators.cH A D13-oct.-202081,4 KiB

zend_operators.hH A D24-févr.-202033,3 KiB

zend_portability.hH A D24-janv.-202019,7 KiB

zend_ptr_stack.cH A D13-févr.-20193 KiB

zend_ptr_stack.hH A D13-févr.-20194,2 KiB

zend_range_check.hH A D13-févr.-20192,9 KiB

zend_signal.cH A D18-juin-202012,6 KiB

zend_signal.hH A D08-avr.-20194 KiB

zend_smart_str.cH A D13-févr.-20195,5 KiB

zend_smart_str.hH A D13-févr.-20195,4 KiB

zend_smart_str_public.hH A D13-févr.-20191,2 KiB

zend_smart_string.hH A D13-févr.-20194,3 KiB

zend_smart_string_public.hH A D13-févr.-20191,4 KiB

zend_sort.cH A D13-févr.-201910,6 KiB

zend_sort.hH A D13-févr.-20191,6 KiB

zend_stack.cH A D13-févr.-20193,9 KiB

zend_stack.hH A D13-févr.-20192,3 KiB

zend_stream.cH A D27-avr.-20207 KiB

zend_stream.hH A D25-juil.-20193,5 KiB

zend_string.cH A D19-avr.-201912,4 KiB

zend_string.hH A D04-sept.-202016,9 KiB

zend_strtod.cH A D24-janv.-202090,5 KiB

zend_strtod.hH A D13-févr.-20191,8 KiB

zend_strtod_int.hH A D13-févr.-20193,4 KiB

zend_ts_hash.cH A D13-févr.-20198 KiB

zend_ts_hash.hH A D19-févr.-20195,6 KiB

zend_type_info.hH A D13-févr.-20193 KiB

zend_types.hH A D12-déc.-201939,6 KiB

zend_variables.cH A D13-févr.-20194,6 KiB

zend_variables.hH A D13-févr.-20193,2 KiB

zend_virtual_cwd.cH A D29-juil.-202042,1 KiB

zend_virtual_cwd.hH A D15-juil.-201912,4 KiB

zend_vm.hH A D13-févr.-20191,9 KiB

zend_vm_def.hH A D13-oct.-2020265,1 KiB

zend_vm_execute.hH A D13-oct.-20201,9 MiB

zend_vm_execute.sklH A D27-mai-20203,5 KiB

zend_vm_gen.phpH A D04-févr.-2020142,8 KiB

zend_vm_handlers.hH A D25-juil.-201985,9 KiB

zend_vm_opcodes.cH A D25-juil.-20198,3 KiB

zend_vm_opcodes.hH A D08-juil.-201911,8 KiB

zend_vm_trace_handlers.hH A D13-févr.-20193,1 KiB

zend_vm_trace_map.hH A D13-févr.-20192,6 KiB

zend_weakrefs.cH A D03-juin-20196,4 KiB

zend_weakrefs.hH A D14-mars-20191,4 KiB

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
122Executor's code is generated by 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
129different opcode threading model using `--with-vm-kind=CALL|SWITCH|GOTO`. You
130can disable opcode specialization using `--without-specializer`. You can include
131or exclude old executor together with specialized one using
132`--without-old-executor`. At last you can debug executor using original
133`zend_vm_def.h` or generated file `zend_vm_execute.h`. Debugging with original
134file requires `--with-lines` option. By default ZE2 uses the following command
135to generate executor:
136
137```bash
138php zend_vm_gen.php --with-vm-kind=CALL
139```
140