From 3d438cc06add9e6cdf54baf4e092b99760770397 Mon Sep 17 00:00:00 2001 From: Andi Gutmans Date: Thu, 9 Sep 2004 17:04:12 +0000 Subject: [PATCH] - Commit VM explanation. --- Zend/README.ZEND_VM | 87 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 Zend/README.ZEND_VM diff --git a/Zend/README.ZEND_VM b/Zend/README.ZEND_VM new file mode 100644 index 0000000000..3a302991ab --- /dev/null +++ b/Zend/README.ZEND_VM @@ -0,0 +1,87 @@ +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 then 20% speedup on raw PHP +code execution (with specialized executor and direct threading execution +method). As most in most PHP applications raw execution speed isn't the +limiting factor but system calls and database callls are, your mileage with +this patch will vary. + +Most parts of the old zend_execute.c go into zend_vm_handlers.h. Here you can +find opcode handlers and helpers. The typical opcode handler template looks +like this: + +#define _SPEC() OPDEF(, , ) +#if HAVE_OP() +ZEND_VM_HANDLER() +{ + +} +#endif + + is an opcode name (ZEN_NOP, ZEND_ADD, :) + & are masks for allowed operand op_types. Specializer +will generate code only for defined combination of types. You can also use +M_ANY mask to disable specialization according operand's op_type. + 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() + return _helper(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU) +ZEND_VM_DISPATCH_TO_HELPER() + return (ZEND_OPCODE_HANDLER_ARGS_PASSTHRU) +ZEND_VM_DISPATCH_TO_HELPER_EX(,,) + return (, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU) +ZEND_VM_CONTINUE() + return 0 +ZEND_VM_NEXT_OPCOD() + NEXT_OPCODE() +ZEND_VM_SET_OPCODE( + SET_OPCODE( +ZEND_VM_INC_OPCODE() + INC_OPCOD() +ZEND_VM_RETURN_FROM_EXECUTE_LOOP() + RETURN_FROM_EXECUTE_LOOP() +ZEND_VM_C_LABEL(