Permalink
Browse files

- Improve comments, docs, code...

  • Loading branch information...
1 parent ceacc83 commit a904c1dabc1cb87228c5aa2c11fdd1a3e73f93f3 @andigutmans andigutmans committed Oct 27, 2004
Showing with 957 additions and 2,231 deletions.
  1. +32 −17 Zend/README.ZEND_VM
  2. +2 −177 Zend/zend_compile.h
  3. +0 −1,180 Zend/zend_vm_execute.h
  4. +923 −857 Zend/zend_vm_gen.php
View
@@ -9,22 +9,21 @@ 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
+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:
-#define <OPCODE>_SPEC() OPDEF(<OPCODE>, <OP1_TYPES>, <OP2_TYPES>)
-#if HAVE_OP(<OPCODE>)
-ZEND_VM_HANDLER(<OPCODE>)
+ZEND_VM_HANDLER(<OPCODE-NUMBER>, <OPCODE>, <OP1_TYPES>, <OP2_TYPES>)
{
<HANDLER'S CODE>
}
-#endif
+<OPCODE-NUMBER> is a opcode number (0, 1, ...)
<OPCODE> is an opcode name (ZEN_NOP, ZEND_ADD, :)
<OP1_TYPES> & <OP2_TYPES> 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.
+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.
@@ -72,19 +71,35 @@ FREE_OP<X>_IF_VAR()
FREE_OP<X>_VAR_PTR()
FREE_VAR_PTR(free_op<X>)
-If handler can receive control form some other handler it should be defined
-with macro ZEND_VM_HANDLER_EX() instead of ZEND_VM_HANDLER().
-The additional parameters of helpers (see ZEND_VM_DISPATCH_TO_HELPER_EX) mast
-be defined in the start of execute() function inside ZEND_VM_HELPER_VAR() macro.
+Executor's helpers can be defined without parameters or with one parameter.
+This is done with the following constructs:
-zend_vm.h and zend_vm_spec.h are used for abstraction of execution method and
-operands specialization. They mainly contain macros that are used for
-compile-time specialization.
+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 generated file requires --without-lines
+option. By default ZE2 uses the following command to generate executor:
-You can switch specialization on/off with define/undefined of the ZEND_VM_SPEC
-in the start of zend.vm.h and select execution method by defining ZEND_VM_KIND
-in the same place.
+$ php zend_vm_gen.php --with-vm-kind=CALL --without-lines
Zend Engine II currently includes two executors during the build process, one
is the specialized version and the other is the old one non-specialized with
View
@@ -546,186 +546,11 @@ ZEND_API int zend_auto_global_disable_jit(char *varname, zend_uint varname_lengt
int zendlex(znode *zendlval TSRMLS_DC);
/* BEGIN: OPCODES */
-#define ZEND_NOP 0
-
-#define ZEND_ADD 1
-#define ZEND_SUB 2
-#define ZEND_MUL 3
-#define ZEND_DIV 4
-#define ZEND_MOD 5
-#define ZEND_SL 6
-#define ZEND_SR 7
-#define ZEND_CONCAT 8
-#define ZEND_BW_OR 9
-#define ZEND_BW_AND 10
-#define ZEND_BW_XOR 11
-#define ZEND_BW_NOT 12
-#define ZEND_BOOL_NOT 13
-#define ZEND_BOOL_XOR 14
-#define ZEND_IS_IDENTICAL 15
-#define ZEND_IS_NOT_IDENTICAL 16
-#define ZEND_IS_EQUAL 17
-#define ZEND_IS_NOT_EQUAL 18
-#define ZEND_IS_SMALLER 19
-#define ZEND_IS_SMALLER_OR_EQUAL 20
-#define ZEND_CAST 21
-#define ZEND_QM_ASSIGN 22
-
-#define ZEND_ASSIGN_ADD 23
-#define ZEND_ASSIGN_SUB 24
-#define ZEND_ASSIGN_MUL 25
-#define ZEND_ASSIGN_DIV 26
-#define ZEND_ASSIGN_MOD 27
-#define ZEND_ASSIGN_SL 28
-#define ZEND_ASSIGN_SR 29
-#define ZEND_ASSIGN_CONCAT 30
-#define ZEND_ASSIGN_BW_OR 31
-#define ZEND_ASSIGN_BW_AND 32
-#define ZEND_ASSIGN_BW_XOR 33
-
-#define ZEND_PRE_INC 34
-#define ZEND_PRE_DEC 35
-#define ZEND_POST_INC 36
-#define ZEND_POST_DEC 37
-
-#define ZEND_ASSIGN 38
-#define ZEND_ASSIGN_REF 39
-
-#define ZEND_ECHO 40
-#define ZEND_PRINT 41
-
-#define ZEND_JMP 42
-#define ZEND_JMPZ 43
-#define ZEND_JMPNZ 44
-#define ZEND_JMPZNZ 45
-#define ZEND_JMPZ_EX 46
-#define ZEND_JMPNZ_EX 47
-#define ZEND_CASE 48
-#define ZEND_SWITCH_FREE 49
-#define ZEND_BRK 50
-#define ZEND_CONT 51
-#define ZEND_BOOL 52
-
-#define ZEND_INIT_STRING 53
-#define ZEND_ADD_CHAR 54
-#define ZEND_ADD_STRING 55
-#define ZEND_ADD_VAR 56
-
-#define ZEND_BEGIN_SILENCE 57
-#define ZEND_END_SILENCE 58
-
-#define ZEND_INIT_FCALL_BY_NAME 59
-#define ZEND_DO_FCALL 60
-#define ZEND_DO_FCALL_BY_NAME 61
-#define ZEND_RETURN 62
-
-#define ZEND_RECV 63
-#define ZEND_RECV_INIT 64
-
-#define ZEND_SEND_VAL 65
-#define ZEND_SEND_VAR 66
-#define ZEND_SEND_REF 67
-
-#define ZEND_NEW 68
-#define ZEND_JMP_NO_CTOR 69
-#define ZEND_FREE 70
-
-#define ZEND_INIT_ARRAY 71
-#define ZEND_ADD_ARRAY_ELEMENT 72
-
-#define ZEND_INCLUDE_OR_EVAL 73
-
-#define ZEND_UNSET_VAR 74
-#define ZEND_UNSET_DIM_OBJ 75
-
-#define ZEND_FE_RESET 77
-#define ZEND_FE_FETCH 78
-
-#define ZEND_EXIT 79
-
-
-/* the following 18 opcodes are 6 groups of 3 opcodes each, and must
- * remain in that order!
- */
-#define ZEND_FETCH_R 80
-#define ZEND_FETCH_DIM_R 81
-#define ZEND_FETCH_OBJ_R 82
-#define ZEND_FETCH_W 83
-#define ZEND_FETCH_DIM_W 84
-#define ZEND_FETCH_OBJ_W 85
-#define ZEND_FETCH_RW 86
-#define ZEND_FETCH_DIM_RW 87
-#define ZEND_FETCH_OBJ_RW 88
-#define ZEND_FETCH_IS 89
-#define ZEND_FETCH_DIM_IS 90
-#define ZEND_FETCH_OBJ_IS 91
-#define ZEND_FETCH_FUNC_ARG 92
-#define ZEND_FETCH_DIM_FUNC_ARG 93
-#define ZEND_FETCH_OBJ_FUNC_ARG 94
-#define ZEND_FETCH_UNSET 95
-#define ZEND_FETCH_DIM_UNSET 96
-#define ZEND_FETCH_OBJ_UNSET 97
-
-#define ZEND_FETCH_DIM_TMP_VAR 98
-#define ZEND_FETCH_CONSTANT 99
-
-/* Hole - 100 */
-
-#define ZEND_EXT_STMT 101
-#define ZEND_EXT_FCALL_BEGIN 102
-#define ZEND_EXT_FCALL_END 103
-#define ZEND_EXT_NOP 104
-
-#define ZEND_TICKS 105
-
-#define ZEND_SEND_VAR_NO_REF 106
-
-#define ZEND_CATCH 107
-#define ZEND_THROW 108
-
-#define ZEND_FETCH_CLASS 109
-
-#define ZEND_CLONE 110
-
-#define ZEND_INIT_CTOR_CALL 111
-#define ZEND_INIT_METHOD_CALL 112
-#define ZEND_INIT_STATIC_METHOD_CALL 113
-
-#define ZEND_ISSET_ISEMPTY_VAR 114
-#define ZEND_ISSET_ISEMPTY_DIM_OBJ 115
-
-#define ZEND_IMPORT_FUNCTION 116
-#define ZEND_IMPORT_CLASS 117
-#define ZEND_IMPORT_CONST 118
-
-#define ZEND_PRE_INC_OBJ 132
-#define ZEND_PRE_DEC_OBJ 133
-#define ZEND_POST_INC_OBJ 134
-#define ZEND_POST_DEC_OBJ 135
-
-#define ZEND_ASSIGN_OBJ 136
-#define ZEND_OP_DATA 137
-
-#define ZEND_INSTANCEOF 138
-
-#define ZEND_DECLARE_CLASS 139
-#define ZEND_DECLARE_INHERITED_CLASS 140
-#define ZEND_DECLARE_FUNCTION 141
-
-#define ZEND_RAISE_ABSTRACT_ERROR 142
+#include "zend_vm_opcodes.h"
+#define ZEND_OP_DATA 137
-#define ZEND_ADD_INTERFACE 144
-#define ZEND_VERIFY_ABSTRACT_CLASS 146
-
-#define ZEND_ASSIGN_DIM 147
-
-#define ZEND_ISSET_ISEMPTY_PROP_OBJ 148
-
-#define ZEND_HANDLE_EXCEPTION 149
-
-/* end of block */
/* END: OPCODES */
Oops, something went wrong.

0 comments on commit a904c1d

Please sign in to comment.