Name Date Size #Lines LOC

..16-Nov-2021-

tests/H12-Oct-2020-

LICENSEH A D05-Dec-20192.7 KiB5747

Makefile.amH A D05-Dec-20192.3 KiB5634

Makefile.fragH A D05-Dec-201978 21

README.ZEND_MMH A D05-Dec-20191.3 KiB4429

README.ZEND_VMH A D05-Dec-20193.7 KiB10389

Zend.m4H A D05-Oct-202014.3 KiB618539

acinclude.m4H A D05-Oct-20206.6 KiB229208

bench.phpH A D05-Dec-20197.3 KiB423347

build.mkH A D05-Dec-2019849 4221

buildconfH A D05-Dec-2019675 3325

configure.acH A D05-Dec-20192.8 KiB134107

headerH A D05-Dec-20191.1 KiB1817

micro_bench.phpH A D05-Dec-20196.4 KiB359307

zend.cH A D05-Dec-201944.6 KiB1,6261,287

zend.hH A D16-Nov-202113 KiB348248

zend.icoH A D05-Dec-20191.3 KiB

zend_API.cH A D30-Aug-2020126.7 KiB4,3553,506

zend_API.hH A D05-Dec-201958.3 KiB1,3411,032

zend_alloc.cH A D27-Feb-202087.2 KiB2,9442,448

zend_alloc.hH A D05-Dec-201918.8 KiB413232

zend_alloc_sizes.hH A D05-Dec-20192.7 KiB7541

zend_arena.hH A D05-Dec-20193.9 KiB13587

zend_ast.cH A D05-Dec-201956 KiB2,0161,797

zend_ast.hH A D05-Dec-201911.2 KiB344264

zend_bitset.hH A D05-Dec-20196.9 KiB265193

zend_build.hH A D05-Dec-20191.7 KiB5721

zend_builtin_functions.cH A D31-Jul-202075.9 KiB2,7572,118

zend_builtin_functions.hH A D05-Dec-20191.6 KiB407

zend_closures.cH A D01-Oct-202025.1 KiB770565

zend_closures.hH A D05-Dec-20192.3 KiB5416

zend_compile.cH A D06-Dec-2019254.9 KiB8,7927,008

zend_compile.hH A D05-Dec-201939.6 KiB1,073683

zend_config.nw.hH A D05-Dec-20192.5 KiB9024

zend_config.w32.hH A D05-Dec-20192.6 KiB8942

zend_constants.cH A D05-Dec-201917.3 KiB546426

zend_constants.hH A D05-Dec-20196.3 KiB10762

zend_cpuinfo.cH A D05-Dec-20193.4 KiB11879

zend_cpuinfo.hH A D05-Dec-20197.1 KiB214146

zend_default_classes.cH A D05-Dec-20191.7 KiB4715

zend_dtrace.cH A D05-Dec-20194.1 KiB12572

zend_dtrace.dH A D05-Dec-20192.1 KiB3613

zend_dtrace.hH A D05-Dec-20192 KiB5721

zend_errors.hH A D05-Dec-20192.1 KiB5320

zend_exceptions.cH A D30-Jun-202034 KiB1,077806

zend_exceptions.hH A D05-Dec-20193.9 KiB9339

zend_execute.cH A D02-Sep-2020107.7 KiB3,6153,084

zend_execute.hH A D05-Dec-201915.2 KiB412305

zend_execute_API.cH A D13-Dec-201945.7 KiB1,6641,308

zend_extensions.cH A D05-Dec-20199.9 KiB336252

zend_extensions.hH A D05-Dec-20196 KiB16483

zend_float.cH A D05-Dec-20191.9 KiB6730

zend_float.hH A D05-Dec-201915.3 KiB429259

zend_gc.cH A D05-Dec-201938.7 KiB1,6431,350

zend_gc.hH A D05-Dec-20192.9 KiB9446

zend_generators.cH A D02-Sep-202037.2 KiB1,257885

zend_generators.hH A D05-Dec-20197.3 KiB14767

zend_globals.hH A D05-Dec-20197.4 KiB315189

zend_globals_macros.hH A D05-Dec-20192.8 KiB8036

zend_hash.cH A D12-Oct-202068.2 KiB2,7622,334

zend_hash.hH A D05-Dec-201934.6 KiB1,157898

zend_highlight.cH A D05-Dec-20195.9 KiB241185

zend_highlight.hH A D05-Dec-20192.4 KiB6124

zend_inheritance.cH A D05-Dec-201964.5 KiB1,8061,423

zend_inheritance.hH A D05-Dec-20192 KiB5113

zend_ini.cH A D21-Aug-202019 KiB764566

zend_ini.hH A D05-Dec-20199.7 KiB208138

zend_ini_parser.yH A D20-Dec-201911.9 KiB432316

zend_ini_scanner.cH A D05-Dec-201987.8 KiB3,8843,700

zend_ini_scanner.hH A D05-Dec-20192 KiB4814

zend_ini_scanner.lH A D05-Dec-201916.7 KiB662434

zend_ini_scanner_defs.hH A D05-Dec-2019225 1411

zend_interfaces.cH A D05-Dec-201918.8 KiB588428

zend_interfaces.hH A D05-Dec-20194.3 KiB9347

zend_istdiostream.hH A D05-Dec-20191.6 KiB4513

zend_iterators.cH A D05-Dec-20193 KiB10767

zend_iterators.hH A D05-Dec-20193.5 KiB9130

zend_language_parser.yH A D05-Dec-201947.3 KiB1,3781,163

zend_language_scanner.cH A D04-Sep-2020186.7 KiB8,1927,783

zend_language_scanner.hH A D05-Dec-20192.8 KiB8742

zend_language_scanner.lH A D04-Sep-202066.2 KiB2,8152,221

zend_language_scanner_defs.hH A D06-Aug-2020251 1512

zend_list.cH A D05-Dec-20199.3 KiB370272

zend_list.hH A D05-Dec-20193.5 KiB8740

zend_llist.cH A D05-Dec-20196.8 KiB320227

zend_llist.hH A D05-Dec-20193.8 KiB8747

zend_long.hH A D05-Dec-20194.3 KiB14098

zend_modules.hH A D05-Dec-20194.8 KiB14291

zend_multibyte.cH A D05-Dec-20197.3 KiB222159

zend_multibyte.hH A D05-Dec-20194.9 KiB8945

zend_multiply.hH A D05-Dec-20199.8 KiB354272

zend_object_handlers.cH A D05-Dec-201954.3 KiB1,8231,437

zend_object_handlers.hH A D05-Dec-201911.2 KiB234116

zend_objects.cH A D05-Dec-20198.9 KiB300222

zend_objects.hH A D05-Dec-20191.9 KiB4612

zend_objects_API.cH A D05-Dec-20196.6 KiB211147

zend_objects_API.hH A D05-Dec-20194.2 KiB11256

zend_opcode.cH A D05-Dec-201922.5 KiB768645

zend_operators.cH A D12-Oct-202081 KiB3,2792,743

zend_operators.hH A D05-Dec-201930.7 KiB891735

zend_portability.hH A D05-Dec-201918.8 KiB653507

zend_ptr_stack.cH A D05-Dec-20193.1 KiB12978

zend_ptr_stack.hH A D05-Dec-20194.4 KiB12977

zend_range_check.hH A D05-Dec-20193.1 KiB7832

zend_signal.cH A D05-Dec-201912.9 KiB458315

zend_signal.hH A D05-Dec-20194 KiB12372

zend_smart_str.cH A D21-Sep-20215.7 KiB184140

zend_smart_str.hH A D05-Dec-20195.5 KiB163115

zend_smart_str_public.hH A D05-Dec-20191.4 KiB387

zend_smart_string.hH A D05-Dec-20194.4 KiB12678

zend_smart_string_public.hH A D05-Dec-20191.5 KiB429

zend_sort.cH A D05-Dec-201910.7 KiB384244

zend_sort.hH A D05-Dec-20191.7 KiB408

zend_sprintf.cH A D05-Dec-20191.6 KiB5116

zend_stack.cH A D05-Dec-20194 KiB175118

zend_stack.hH A D05-Dec-20192.5 KiB6024

zend_stream.cH A D05-Dec-201910.4 KiB355277

zend_stream.hH A D05-Dec-20193.4 KiB10964

zend_string.cH A D05-Dec-201913.2 KiB488375

zend_string.hH A D03-Sep-202015.7 KiB469342

zend_strtod.cH A D05-Dec-201990.4 KiB4,5543,916

zend_strtod.hH A D05-Dec-20192 KiB4714

zend_strtod_int.hH A D05-Dec-20193.6 KiB15895

zend_ts_hash.cH A D05-Dec-20198.4 KiB386281

zend_ts_hash.hH A D05-Dec-20195.6 KiB14378

zend_type_info.hH A D05-Dec-20193.2 KiB6933

zend_types.hH A D05-Dec-201937.5 KiB1,235948

zend_variables.cH A D05-Dec-20195.6 KiB169116

zend_variables.hH A D05-Dec-20193.4 KiB10761

zend_virtual_cwd.cH A D26-Oct-202049.3 KiB1,9961,611

zend_virtual_cwd.hH A D05-Dec-201912.1 KiB374274

zend_vm.hH A D05-Dec-20192.1 KiB5116

zend_vm_def.hH A D01-Oct-2020251.8 KiB8,8847,660

zend_vm_execute.hH A D01-Oct-20202.1 MiB65,53257,377

zend_vm_execute.sklH A D05-Dec-20192.8 KiB123100

zend_vm_gen.phpH A D05-Dec-2019111.4 KiB3,1362,786

zend_vm_handlers.hH A D05-Dec-201997.6 KiB2,0602,059

zend_vm_opcodes.cH A D05-Dec-20198.4 KiB441417

zend_vm_opcodes.hH A D05-Dec-201912.9 KiB280250

zend_vm_trace_handlers.hH A D05-Dec-20193.1 KiB11384

zend_vm_trace_map.hH A D05-Dec-20192.6 KiB8256

README.ZEND_MM

1Zend Memory Manager
2===================
3
4General:
5--------
6
7The goal of the new memory manager (available since PHP 5.2) is to reduce memory
8allocation overhead and speedup memory management.
9
10The new manager's "configure" has no "--disable-zend-memory-manager" option,
11but it has "--enable-malloc-mm" instead.  It is enabled by default in DEBUG
12build and disabled by default in RELEASE build. When enabled it allows selecting
13between malloc and emalloc at runtime so you can use internal and external memory
14debuggers without recompilation.
15
16Debugging:
17----------
18
19Normal:
20
21    $ sapi/cli/php -r 'leak();'
22
23Zend MM disabled:
24
25    $ USE_ZEND_ALLOC=0 valgrind --leak-check=full sapi/cli/php -r 'leak();'
26
27Shared extensions:
28------------------
29
30Since PHP 5.3.11 it is possible to prevent shared extensions from unloading so
31that valgrind can correctly track the memory leaks in shared extensions. For
32this there is the ZEND_DONT_UNLOAD_MODULES environment variable. If set, then
33DL_UNLOAD() is skipped during the shutdown of shared extensions.
34
35
36Tweaking:
37---------
38
39The Zend MM can be tweaked using ZEND_MM_MEM_TYPE and ZEND_MM_SEG_SIZE environment
40variables.  Default values are "malloc" and "256K". Dependent on target system you
41can also use "mmap_anon", "mmap_zero" and "win32" storage managers.
42
43	$ ZEND_MM_MEM_TYPE=mmap_anon ZEND_MM_SEG_SIZE=1M sapi/cli/php ..etc.
44

README.ZEND_VM

1ZEND_VM
2=======
3
4ZEND_VM architecture allows specializing opcode handlers according to op_type
5fields and using different execution methods (call threading, switch threading
6and direct threading). As a result ZE2 got more than 20% speedup on raw PHP
7code execution (with specialized executor and direct threading execution
8method). As in most PHP applications raw execution speed isn't the limiting
9factor but system calls and database calls are, your mileage with this patch
10will vary.
11
12Most parts of the old zend_execute.c go into zend_vm_def.h. Here you can
13find opcode handlers and helpers. The typical opcode handler template looks
14like this:
15
16ZEND_VM_HANDLER(<OPCODE-NUMBER>, <OPCODE>, <OP1_TYPES>, <OP2_TYPES>)
17{
18	<HANDLER'S CODE>
19}
20
21<OPCODE-NUMBER> is a opcode number (0, 1, ...)
22<OPCODE> is an opcode name (ZEN_NOP, ZEND_ADD, :)
23<OP1_TYPES> & <OP2_TYPES> are masks for allowed operand op_types. Specializer
24will generate code only for defined combination of types. You can use any
25combination of the following op_types UNUSED, CONST, VAR, TMP and  CV also
26you can use ANY mask to disable specialization according operand's op_type.
27<HANDLER'S CODE> is a handler's code itself. For most handlers it stills the
28same as in old zend_execute.c, but now it uses macros to access opcode operands
29and some internal executor data.
30
31You can see the conformity of new macros to old code in the following list:
32
33EXECUTE_DATA
34	execute_data
35ZEND_VM_DISPATCH_TO_HANDLER(<OP>)
36	return <OP>_helper(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU)
37ZEND_VM_DISPATCH_TO_HELPER(<NAME>)
38	return <NAME>(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU)
39ZEND_VM_DISPATCH_TO_HELPER_EX(<NAME>,<PARAM>,<VAL>)
40	return <NAME>(<VAL>, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU)
41ZEND_VM_CONTINUE()
42	return 0
43ZEND_VM_NEXT_OPCODE()
44	NEXT_OPCODE()
45ZEND_VM_SET_OPCODE(<TARGET>
46	SET_OPCODE(<TARGET>
47ZEND_VM_INC_OPCODE()
48	INC_OPCOD()
49ZEND_VM_RETURN_FROM_EXECUTE_LOOP()
50	RETURN_FROM_EXECUTE_LOOP()
51ZEND_VM_C_LABEL(<LABEL>):
52	<LABEL>:
53ZEND_VM_C_GOTO(<LABEL>)
54	goto <LABEL>
55OP<X>_TYPE
56	opline->op<X>.op_type
57GET_OP<X>_ZVAL_PTR(<TYPE>)
58	get_zval_ptr(&opline->op<X>, EX(Ts), &free_op<X>, <TYPE>)
59GET_OP<X>_ZVAL_PTR_PTR(<TYPE>)
60	get_zval_ptr_ptr(&opline->op<X>, EX(Ts), &free_op<X>, <TYPE>)
61GET_OP<X>_OBJ_ZVAL_PTR(<TYPE>)
62	get_obj_zval_ptr(&opline->op<X>, EX(Ts), &free_op<X>, <TYPE>)
63GET_OP<X>_OBJ_ZVAL_PTR_PTR(<TYPE>)
64	get_obj_zval_ptr_ptr(&opline->op<X>, EX(Ts), &free_op<X>, <TYPE>)
65IS_OP<X>_TMP_FREE()
66	IS_TMP_FREE(free_op<X>)
67FREE_OP<X>()
68	FREE_OP(free_op<X>)
69FREE_OP<X>_IF_VAR()
70	FREE_VAR(free_op<X>)
71FREE_OP<X>_VAR_PTR()
72	FREE_VAR_PTR(free_op<X>)
73
74
75Executor's helpers can be defined without parameters or with one parameter.
76This is done with the following constructs:
77
78ZEND_VM_HELPER(<HELPER-NAME>, <OP1_TYPES>, <OP2_TYPES>)
79{
80	<HELPER'S CODE>
81}
82
83ZEND_VM_HELPER_EX(<HELPER-NAME>, <OP1_TYPES>, <OP2_TYPES>, <PARAM_SPEC>)
84{
85	<HELPER'S CODE>
86}
87
88Executor's code is generated by PHP script zend_vm_gen.php it uses zend_vm_def.h
89and zend_vm_execute.skl as input and produces zend_vm_opcodes.h and
90zend_vm_execute.h. The first file is a list of opcode definitions. It is
91included from zend_compile.h. The second one is an executor code itself. It is
92included from zend_execute.c.
93
94zend_vm_gen.php can produce different kind of executors. You can select
95different opcode threading model using --with-vm-kind=CALL|SWITCH|GOTO. You can
96disable opcode specialization using --without-specializer. You can include or
97exclude old executor together with specialized one using --without-old-executor.
98At last you can debug executor using original zend_vm_def.h or generated file
99zend_vm_execute.h. Debugging with original file requires --with-lines
100option. By default ZE2 uses the following command to generate executor:
101
102$ php zend_vm_gen.php --with-vm-kind=CALL
103