Folus Wen dd8509b6b1 [Add][GPL][php] 2 yıl önce
..
Optimizer dd8509b6b1 [Add][GPL][php] 2 yıl önce
asm dd8509b6b1 [Add][GPL][php] 2 yıl önce
tests dd8509b6b1 [Add][GPL][php] 2 yıl önce
LICENSE dd8509b6b1 [Add][GPL][php] 2 yıl önce
Makefile.frag dd8509b6b1 [Add][GPL][php] 2 yıl önce
README.md dd8509b6b1 [Add][GPL][php] 2 yıl önce
Zend.m4 dd8509b6b1 [Add][GPL][php] 2 yıl önce
bench.php dd8509b6b1 [Add][GPL][php] 2 yıl önce
micro_bench.php dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend.c dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_API.c dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_API.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_alloc.c dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_alloc.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_alloc_sizes.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_arena.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_ast.c dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_ast.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_attributes.c dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_attributes.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_attributes.stub.php dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_attributes_arginfo.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_bitset.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_build.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_builtin_functions.c dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_builtin_functions.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_builtin_functions.stub.php dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_builtin_functions_arginfo.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_closures.c dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_closures.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_closures.stub.php dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_closures_arginfo.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_compile.c dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_compile.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_config.w32.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_constants.c dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_constants.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_cpuinfo.c dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_cpuinfo.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_default_classes.c dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_dtrace.c dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_dtrace.d dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_dtrace.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_enum.c dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_enum.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_enum.stub.php dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_enum_arginfo.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_errors.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_exceptions.c dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_exceptions.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_exceptions.stub.php dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_exceptions_arginfo.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_execute.c dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_execute.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_execute_API.c dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_extensions.c dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_extensions.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_fibers.c dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_fibers.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_fibers.stub.php dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_fibers_arginfo.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_float.c dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_float.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_gc.c dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_gc.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_gdb.c dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_gdb.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_generators.c dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_generators.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_generators.stub.php dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_generators_arginfo.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_globals.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_globals_macros.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_hash.c dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_hash.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_highlight.c dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_highlight.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_inheritance.c dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_inheritance.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_ini.c dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_ini.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_ini_parser.y dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_ini_scanner.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_ini_scanner.l dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_interfaces.c dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_interfaces.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_interfaces.stub.php dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_interfaces_arginfo.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_istdiostream.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_iterators.c dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_iterators.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_language_parser.y dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_language_scanner.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_language_scanner.l dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_list.c dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_list.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_llist.c dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_llist.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_long.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_map_ptr.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_modules.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_multibyte.c dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_multibyte.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_multiply.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_object_handlers.c dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_object_handlers.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_objects.c dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_objects.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_objects_API.c dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_objects_API.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_observer.c dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_observer.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_opcode.c dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_operators.c dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_operators.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_portability.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_ptr_stack.c dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_ptr_stack.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_range_check.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_signal.c dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_signal.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_smart_str.c dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_smart_str.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_smart_str_public.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_smart_string.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_smart_string_public.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_sort.c dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_sort.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_stack.c dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_stack.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_stream.c dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_stream.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_string.c dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_string.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_strtod.c dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_strtod.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_strtod_int.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_system_id.c dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_system_id.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_type_info.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_types.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_variables.c dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_variables.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_virtual_cwd.c dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_virtual_cwd.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_vm.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_vm_def.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_vm_execute.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_vm_execute.skl dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_vm_gen.php dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_vm_handlers.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_vm_opcodes.c dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_vm_opcodes.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_vm_trace_handlers.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_vm_trace_lines.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_vm_trace_map.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_weakrefs.c dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_weakrefs.h dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_weakrefs.stub.php dd8509b6b1 [Add][GPL][php] 2 yıl önce
zend_weakrefs_arginfo.h dd8509b6b1 [Add][GPL][php] 2 yıl önce

README.md

Zend Engine

Zend memory manager

General

The goal of the new memory manager (available since PHP 5.2) is to reduce memory allocation overhead and speedup memory management.

Debugging

Normal:

sapi/cli/php -r 'leak();'

Zend MM disabled:

USE_ZEND_ALLOC=0 valgrind --leak-check=full sapi/cli/php -r 'leak();'

Shared extensions

Since PHP 5.3.11 it is possible to prevent shared extensions from unloading so that valgrind can correctly track the memory leaks in shared extensions. For this there is the ZEND_DONT_UNLOAD_MODULES environment variable. If set, then DL_UNLOAD() is skipped during the shutdown of shared extensions.

ZEND_VM

ZEND_VM architecture allows specializing opcode handlers according to op_type fields and using different execution methods (call threading, switch threading and direct threading). As a result ZE2 got more than 20% speedup on raw PHP code execution (with specialized executor and direct threading execution method). As in most PHP applications raw execution speed isn't the limiting factor but system calls and database calls are, your mileage with this patch will vary.

Most parts of the old zend_execute.c go into zend_vm_def.h. Here you can find opcode handlers and helpers. The typical opcode handler template looks like this:

ZEND_VM_HANDLER(<OPCODE-NUMBER>, <OPCODE>, <OP1_TYPES>, <OP2_TYPES>)
{
    <HANDLER'S CODE>
}

<OPCODE-NUMBER> is a opcode number (0, 1, ...) <OPCODE> is an opcode name (ZEN_NOP, ZEND_ADD, :) <OP1_TYPES> and <OP2_TYPES> are masks for allowed operand op_types. Specializer will generate code only for defined combination of types. You can use any combination of the following op_types UNUSED, CONST, VAR, TMP and CV also you can use ANY mask to disable specialization according operand's op_type. <HANDLER'S CODE> is a handler's code itself. For most handlers it stills the same as in old zend_execute.c, but now it uses macros to access opcode operands and some internal executor data.

You can see the conformity of new macros to old code in the following list:

EXECUTE_DATA
    execute_data
ZEND_VM_DISPATCH_TO_HANDLER(<OP>)
    return <OP>_helper(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU)
ZEND_VM_DISPATCH_TO_HELPER(<NAME>)
    return <NAME>(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU)
ZEND_VM_DISPATCH_TO_HELPER_EX(<NAME>,<PARAM>,<VAL>)
    return <NAME>(<VAL>, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU)
ZEND_VM_CONTINUE()
    return 0
ZEND_VM_NEXT_OPCODE()
    NEXT_OPCODE()
ZEND_VM_SET_OPCODE(<TARGET>
    SET_OPCODE(<TARGET>
ZEND_VM_INC_OPCODE()
    INC_OPCOD()
ZEND_VM_RETURN_FROM_EXECUTE_LOOP()
    RETURN_FROM_EXECUTE_LOOP()
ZEND_VM_C_LABEL(<LABEL>):
    <LABEL>:
ZEND_VM_C_GOTO(<LABEL>)
    goto <LABEL>
OP<X>_TYPE
    opline->op<X>.op_type
GET_OP<X>_ZVAL_PTR(<TYPE>)
    get_zval_ptr(&opline->op<X>, EX(Ts), &free_op<X>, <TYPE>)
GET_OP<X>_ZVAL_PTR_PTR(<TYPE>)
    get_zval_ptr_ptr(&opline->op<X>, EX(Ts), &free_op<X>, <TYPE>)
GET_OP<X>_OBJ_ZVAL_PTR(<TYPE>)
    get_obj_zval_ptr(&opline->op<X>, EX(Ts), &free_op<X>, <TYPE>)
GET_OP<X>_OBJ_ZVAL_PTR_PTR(<TYPE>)
    get_obj_zval_ptr_ptr(&opline->op<X>, EX(Ts), &free_op<X>, <TYPE>)
IS_OP<X>_TMP_FREE()
    IS_TMP_FREE(free_op<X>)
FREE_OP<X>()
    FREE_OP(free_op<X>)
FREE_OP<X>_IF_VAR()
    FREE_VAR(free_op<X>)
FREE_OP<X>_VAR_PTR()
    FREE_VAR_PTR(free_op<X>)

Executor's helpers can be defined without parameters or with one parameter. This is done with the following constructs:

ZEND_VM_HELPER(<HELPER-NAME>, <OP1_TYPES>, <OP2_TYPES>)
{
    <HELPER'S CODE>
}

ZEND_VM_HELPER_EX(<HELPER-NAME>, <OP1_TYPES>, <OP2_TYPES>, <PARAM_SPEC>)
{
    <HELPER'S CODE>
}

Executor's code is generated by PHP script zend_vm_gen.php it uses zend_vm_def.h and zend_vm_execute.skl as input and produces zend_vm_opcodes.h and zend_vm_execute.h. The first file is a list of opcode definitions. It is included from zend_compile.h. The second one is an executor code itself. It is included from zend_execute.c.

zend_vm_gen.php can produce different kind of executors. You can select different opcode threading model using --with-vm-kind=CALL|SWITCH|GOTO. You can disable opcode specialization using --without-specializer. You can include or exclude old executor together with specialized one using --without-old-executor. At last you can debug executor using original zend_vm_def.h or generated file zend_vm_execute.h. Debugging with original file requires --with-lines option. By default ZE2 uses the following command to generate executor:

php zend_vm_gen.php --with-vm-kind=CALL