stores new offsets in op_array->opcodes[*].op?.num. You can use macros
EX_TMP_VAR() and EX_TMP_VAR_NUM() to access temp_variable by offset or
number. You can convert number to offset using EX_TMP_VAR_NUM(0, num) or
- offset to number (EX_TMP_VAR(0,offset)-EX_TMP_VAR_NUM(0,0)).
+ offset to number (EX_TMP_VAR_NUM(0,0)-EX_TMP_VAR(0,offset)).
- Removed execute_data->CVs field. The VM compiled variables always allocated
immediately after execute_data structure. Now they are accessed by offset
from the execute_data base pointer (instead of execute_data->CVs). You can
#define DECODE_CTOR(ce) \
((zend_class_entry*)(((zend_uintptr_t)(ce)) & ~(CTOR_CALL_BIT|CTOR_USED_BIT)))
+#undef EX
+#define EX(element) execute_data->element
+
ZEND_API zval** zend_get_compiled_variable_value(const zend_execute_data *execute_data, zend_uint var)
{
return EX_CV(var);
}
}
-#define ZEND_VM_NEXT_OPCODE() \
- CHECK_SYMBOL_TABLES() \
- ZEND_VM_INC_OPCODE(); \
- ZEND_VM_CONTINUE()
-
-#define ZEND_VM_SET_OPCODE(new_op) \
- CHECK_SYMBOL_TABLES() \
- OPLINE = new_op
-
-#define ZEND_VM_JMP(new_op) \
- if (EXPECTED(!EG(exception))) { \
- ZEND_VM_SET_OPCODE(new_op); \
- } else { \
- LOAD_OPLINE(); \
- } \
- ZEND_VM_CONTINUE()
-
-#define ZEND_VM_INC_OPCODE() \
- OPLINE++
-
-#ifdef __GNUC__
-# define ZEND_VM_GUARD(name) __asm__("#" #name)
-#else
-# define ZEND_VM_GUARD(name)
-#endif
-
-#include "zend_vm_execute.h"
-
-ZEND_API int zend_set_user_opcode_handler(zend_uchar opcode, user_opcode_handler_t handler)
-{
- if (opcode != ZEND_USER_OPCODE) {
- if (handler == NULL) {
- /* restore the original handler */
- zend_user_opcodes[opcode] = opcode;
- } else {
- zend_user_opcodes[opcode] = ZEND_USER_OPCODE;
- }
- zend_user_opcode_handlers[opcode] = handler;
- return SUCCESS;
- }
- return FAILURE;
-}
-
-ZEND_API user_opcode_handler_t zend_get_user_opcode_handler(zend_uchar opcode)
-{
- return zend_user_opcode_handlers[opcode];
-}
-
-ZEND_API zval *zend_get_zval_ptr(int op_type, const znode_op *node, const zend_execute_data *execute_data, zend_free_op *should_free, int type TSRMLS_DC) {
- return get_zval_ptr(op_type, node, execute_data, should_free, type);
-}
-
-ZEND_API zval **zend_get_zval_ptr_ptr(int op_type, const znode_op *node, const zend_execute_data *execute_data, zend_free_op *should_free, int type TSRMLS_DC) {
- return get_zval_ptr_ptr(op_type, node, execute_data, should_free, type);
-}
-
void zend_clean_and_cache_symbol_table(HashTable *symbol_table TSRMLS_DC) /* {{{ */
{
if (EG(symtable_cache_ptr) >= EG(symtable_cache_limit)) {
}
/* }}} */
-void zend_free_compiled_variables(zend_execute_data *execute_data) /* {{{ */
+static zend_always_inline void i_free_compiled_variables(zend_execute_data *execute_data) /* {{{ */
{
- int i;
- for (i = 0; i < EX(op_array)->last_var; ++i) {
- if (EX_CV(i)) {
- zval_ptr_dtor(EX_CV(i));
+ zval ***cv = EX_CV_NUM(execute_data, 0);
+ zval ***end = cv + EX(op_array)->last_var;
+ while (cv != end) {
+ if (*cv) {
+ zval_ptr_dtor(*cv);
}
- }
+ cv++;
+ }
+}
+/* }}} */
+
+void zend_free_compiled_variables(zend_execute_data *execute_data) /* {{{ */
+{
+ i_free_compiled_variables(execute_data);
}
/* }}} */
* +----------------------------------------+
*/
-zend_execute_data *zend_create_execute_data_from_op_array(zend_op_array *op_array, zend_bool nested TSRMLS_DC) /* {{{ */
+static zend_always_inline zend_execute_data *i_create_execute_data_from_op_array(zend_op_array *op_array, zend_bool nested TSRMLS_DC) /* {{{ */
{
zend_execute_data *execute_data;
}
/* }}} */
+zend_execute_data *zend_create_execute_data_from_op_array(zend_op_array *op_array, zend_bool nested TSRMLS_DC) /* {{{ */
+{
+ return i_create_execute_data_from_op_array(op_array, nested TSRMLS_CC);
+}
+/* }}} */
+
+#define ZEND_VM_NEXT_OPCODE() \
+ CHECK_SYMBOL_TABLES() \
+ ZEND_VM_INC_OPCODE(); \
+ ZEND_VM_CONTINUE()
+
+#define ZEND_VM_SET_OPCODE(new_op) \
+ CHECK_SYMBOL_TABLES() \
+ OPLINE = new_op
+
+#define ZEND_VM_JMP(new_op) \
+ if (EXPECTED(!EG(exception))) { \
+ ZEND_VM_SET_OPCODE(new_op); \
+ } else { \
+ LOAD_OPLINE(); \
+ } \
+ ZEND_VM_CONTINUE()
+
+#define ZEND_VM_INC_OPCODE() \
+ OPLINE++
+
+#ifdef __GNUC__
+# define ZEND_VM_GUARD(name) __asm__("#" #name)
+#else
+# define ZEND_VM_GUARD(name)
+#endif
+
+#include "zend_vm_execute.h"
+
+ZEND_API int zend_set_user_opcode_handler(zend_uchar opcode, user_opcode_handler_t handler)
+{
+ if (opcode != ZEND_USER_OPCODE) {
+ if (handler == NULL) {
+ /* restore the original handler */
+ zend_user_opcodes[opcode] = opcode;
+ } else {
+ zend_user_opcodes[opcode] = ZEND_USER_OPCODE;
+ }
+ zend_user_opcode_handlers[opcode] = handler;
+ return SUCCESS;
+ }
+ return FAILURE;
+}
+
+ZEND_API user_opcode_handler_t zend_get_user_opcode_handler(zend_uchar opcode)
+{
+ return zend_user_opcode_handlers[opcode];
+}
+
+ZEND_API zval *zend_get_zval_ptr(int op_type, const znode_op *node, const zend_execute_data *execute_data, zend_free_op *should_free, int type TSRMLS_DC) {
+ return get_zval_ptr(op_type, node, execute_data, should_free, type);
+}
+
+ZEND_API zval **zend_get_zval_ptr_ptr(int op_type, const znode_op *node, const zend_execute_data *execute_data, zend_free_op *should_free, int type TSRMLS_DC) {
+ return get_zval_ptr_ptr(op_type, node, execute_data, should_free, type);
+}
+
/*
* Local variables:
* tab-width: 4
}
/* Generators go throw a different cleanup process */
- if (EX(op_array)->fn_flags & ZEND_ACC_GENERATOR) {
+ if (UNEXPECTED((EX(op_array)->fn_flags & ZEND_ACC_GENERATOR) != 0)) {
/* The generator object is stored in return_value_ptr_ptr */
zend_generator *generator = (zend_generator *) EG(return_value_ptr_ptr);
EG(current_execute_data) = EX(prev_execute_data);
EG(opline_ptr) = NULL;
if (!EG(active_symbol_table)) {
- zend_free_compiled_variables(execute_data);
+ i_free_compiled_variables(execute_data);
}
if ((op_array->fn_flags & ZEND_ACC_CLOSURE) && op_array->prototype) {
#define ZEND_VM_DISPATCH(opcode, opline) return zend_vm_get_opcode_handler(opcode, opline)(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);
#define ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_INTERNAL execute_data TSRMLS_CC
-#undef EX
-#define EX(element) execute_data->element
-
ZEND_API void execute_ex(zend_execute_data *execute_data TSRMLS_DC)
{
original_in_execution = EG(in_execution);
EG(in_execution) = 1;
+ if (0) {
+zend_vm_enter:
+ execute_data = i_create_execute_data_from_op_array(EG(active_op_array), 1 TSRMLS_CC);
+ }
+
LOAD_REGS();
LOAD_OPLINE();
EG(in_execution) = original_in_execution;
return;
case 2:
- execute_data = zend_create_execute_data_from_op_array(EG(active_op_array), 1 TSRMLS_CC);
+ goto zend_vm_enter;
break;
case 3:
execute_data = EG(current_execute_data);
if (EG(exception)) {
return;
}
- zend_execute_ex(zend_create_execute_data_from_op_array(op_array, 0 TSRMLS_CC) TSRMLS_CC);
+ zend_execute_ex(i_create_execute_data_from_op_array(op_array, 0 TSRMLS_CC) TSRMLS_CC);
}
static int ZEND_FASTCALL zend_leave_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS)
}
/* Generators go throw a different cleanup process */
- if (EX(op_array)->fn_flags & ZEND_ACC_GENERATOR) {
+ if (UNEXPECTED((EX(op_array)->fn_flags & ZEND_ACC_GENERATOR) != 0)) {
/* The generator object is stored in return_value_ptr_ptr */
zend_generator *generator = (zend_generator *) EG(return_value_ptr_ptr);
EG(current_execute_data) = EX(prev_execute_data);
EG(opline_ptr) = NULL;
if (!EG(active_symbol_table)) {
- zend_free_compiled_variables(execute_data);
+ i_free_compiled_variables(execute_data);
}
if ((op_array->fn_flags & ZEND_ACC_CLOSURE) && op_array->prototype) {
original_in_execution = EG(in_execution);
EG(in_execution) = 1;
+ if (0) {
+zend_vm_enter:
+ execute_data = i_create_execute_data_from_op_array(EG(active_op_array), 1 TSRMLS_CC);
+ }
+
LOAD_REGS();
LOAD_OPLINE();
if (EG(exception)) {
return;
}
- zend_{%EXECUTOR_NAME%}_ex(zend_create_execute_data_from_op_array(op_array, 0 TSRMLS_CC) TSRMLS_CC);
+ zend_{%EXECUTOR_NAME%}_ex(i_create_execute_data_from_op_array(op_array, 0 TSRMLS_CC) TSRMLS_CC);
}
{%EXTERNAL_EXECUTOR%}
out($f,"#define ZEND_VM_LEAVE() return 3\n");
out($f,"#define ZEND_VM_DISPATCH(opcode, opline) return zend_vm_get_opcode_handler(opcode, opline)(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);\n\n");
out($f,"#define ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_INTERNAL execute_data TSRMLS_CC\n");
- out($f,"#undef EX\n");
- out($f,"#define EX(element) execute_data->element\n\n");
break;
case ZEND_VM_KIND_SWITCH:
out($f,"\n");
out($f,"#define LOAD_REGS()\n");
out($f,"#define ZEND_VM_CONTINUE() goto zend_vm_continue\n");
out($f,"#define ZEND_VM_RETURN() EG(in_execution) = original_in_execution; return\n");
- out($f,"#define ZEND_VM_ENTER() execute_data = zend_create_execute_data_from_op_array(EG(active_op_array), 1 TSRMLS_CC); LOAD_REGS(); LOAD_OPLINE(); ZEND_VM_CONTINUE()\n");
+ out($f,"#define ZEND_VM_ENTER() goto zend_vm_enter\n");
out($f,"#define ZEND_VM_LEAVE() ZEND_VM_CONTINUE()\n");
out($f,"#define ZEND_VM_DISPATCH(opcode, opline) dispatch_handler = zend_vm_get_opcode_handler(opcode, opline); goto zend_vm_dispatch;\n\n");
out($f,"#define ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_INTERNAL execute_data TSRMLS_CC\n");
- out($f,"#undef EX\n");
- out($f,"#define EX(element) execute_data->element\n\n");
break;
case ZEND_VM_KIND_GOTO:
out($f,"\n");
out($f,"#define LOAD_REGS()\n");
out($f,"#define ZEND_VM_CONTINUE() goto *(void**)(OPLINE->handler)\n");
out($f,"#define ZEND_VM_RETURN() EG(in_execution) = original_in_execution; return\n");
- out($f,"#define ZEND_VM_ENTER() execute_data = zend_create_execute_data_from_op_array(EG(active_op_array), 1 TSRMLS_CC); LOAD_REGS(); LOAD_OPLINE(); ZEND_VM_CONTINUE()\n");
+ out($f,"#define ZEND_VM_ENTER() goto zend_vm_enter\n");
out($f,"#define ZEND_VM_LEAVE() ZEND_VM_CONTINUE()\n");
out($f,"#define ZEND_VM_DISPATCH(opcode, opline) goto *(void**)(zend_vm_get_opcode_handler(opcode, opline));\n\n");
out($f,"#define ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_INTERNAL execute_data TSRMLS_CC\n");
- out($f,"#undef EX\n");
- out($f,"#define EX(element) execute_data->element\n\n");
break;
}
break;
$m[1]."\t\tEG(in_execution) = original_in_execution;\n".
$m[1]."\t\treturn;\n".
$m[1]."\tcase 2:\n" .
- $m[1]."\t\texecute_data = zend_create_execute_data_from_op_array(EG(active_op_array), 1 TSRMLS_CC);\n".
+ $m[1]."\t\tgoto zend_vm_enter;\n".
$m[1]."\t\tbreak;\n" .
$m[1]."\tcase 3:\n" .
$m[1]."\t\texecute_data = EG(current_execute_data);\n".
// Generate un-specialized executor
if (ZEND_VM_OLD_EXECUTOR) {
out($f,"\n/* Old executor */\n\n");
- out($f,"#undef EX\n");
- out($f,"#define EX(element) execute_data.element\n\n");
out($f,"#undef ZEND_VM_CONTINUE\n\n");
out($f,"#undef ZEND_VM_RETURN\n\n");
out($f,"#undef ZEND_VM_ENTER\n\n");
out($f,"#define CHECK_EXCEPTION() LOAD_OPLINE()\n");
out($f,"#define HANDLE_EXCEPTION() LOAD_OPLINE(); ZEND_VM_CONTINUE()\n");
out($f,"#define HANDLE_EXCEPTION_LEAVE() LOAD_OPLINE(); ZEND_VM_LEAVE()\n");
- out($f,"#undef EX\n");
- out($f,"#define EX(element) execute_data->element\n\n");
out($f,"#undef ZEND_VM_CONTINUE\n");
out($f,"#undef ZEND_VM_RETURN\n");
out($f,"#undef ZEND_VM_ENTER\n");