]> granicus.if.org Git - php/commitdiff
Simplify TMP var number decoding (without HashTable)
authorDmitry Stogov <dmitry@zend.com>
Mon, 6 Jul 2015 14:56:48 +0000 (17:56 +0300)
committerDmitry Stogov <dmitry@zend.com>
Mon, 6 Jul 2015 14:56:48 +0000 (17:56 +0300)
sapi/phpdbg/phpdbg_opcode.c
sapi/phpdbg/phpdbg_opcode.h
sapi/phpdbg/phpdbg_print.c
sapi/phpdbg/phpdbg_prompt.c

index fdfc0e9278c5561cadc3f2fb4f8ee890cf51c537..7dc9e7f1dfe6327fcf9562819708b1701553db25 100644 (file)
@@ -27,7 +27,7 @@
 
 ZEND_EXTERN_MODULE_GLOBALS(phpdbg);
 
-static inline char *phpdbg_decode_op(zend_op_array *ops, znode_op *op, uint32_t type, HashTable *vars) /* {{{ */
+static inline char *phpdbg_decode_op(zend_op_array *ops, znode_op *op, uint32_t type) /* {{{ */
 {
        char *decode = NULL;
 
@@ -39,18 +39,8 @@ static inline char *phpdbg_decode_op(zend_op_array *ops, znode_op *op, uint32_t
 
                case IS_VAR:
                case IS_TMP_VAR: {
-                       zend_ulong id = 0, *pid = NULL;
-                       if (vars != NULL) {
-                               if ((pid = zend_hash_index_find_ptr(vars, (zend_ulong) ops->vars - op->var))) {
-                                       id = *pid;
-                               } else {
-                                       id = zend_hash_num_elements(vars);
-                                       zend_hash_index_update_mem(vars, (zend_ulong) ops->vars - op->var, &id, sizeof(zend_ulong));
-                               }
-                       }
-                       asprintf(&decode, "@" ZEND_ULONG_FMT, id);
+                       asprintf(&decode, "@%" PRIu32, EX_VAR_TO_NUM(op->var) - ops->last_var);
                } break;
-
                case IS_CONST: {
                        zval *literal = RT_CONSTANT(ops, *op);
                        decode = phpdbg_short_zval_print(literal, 20);
@@ -59,7 +49,7 @@ static inline char *phpdbg_decode_op(zend_op_array *ops, znode_op *op, uint32_t
        return decode;
 } /* }}} */
 
-char *phpdbg_decode_opline(zend_op_array *ops, zend_op *op, HashTable *vars) /*{{{ */
+char *phpdbg_decode_opline(zend_op_array *ops, zend_op *op) /*{{{ */
 {
        char *decode[4] = {NULL, NULL, NULL, NULL};
 
@@ -79,7 +69,7 @@ char *phpdbg_decode_opline(zend_op_array *ops, zend_op *op, HashTable *vars) /*{
                break;
 
        default:
-               decode[1] = phpdbg_decode_op(ops, &op->op1, op->op1_type, vars);
+               decode[1] = phpdbg_decode_op(ops, &op->op1, op->op1_type);
                break;
        }
 
@@ -110,7 +100,7 @@ char *phpdbg_decode_opline(zend_op_array *ops, zend_op *op, HashTable *vars) /*{
                break;
 
        default:
-               decode[2] = phpdbg_decode_op(ops, &op->op2, op->op2_type, vars);
+               decode[2] = phpdbg_decode_op(ops, &op->op2, op->op2_type);
                break;
        }
 
@@ -120,7 +110,7 @@ char *phpdbg_decode_opline(zend_op_array *ops, zend_op *op, HashTable *vars) /*{
                asprintf(&decode[2], "%" PRIu32, op->result.num);
                break;
        default:
-               decode[3] = phpdbg_decode_op(ops, &op->result, op->result_type, vars);
+               decode[3] = phpdbg_decode_op(ops, &op->result, op->result_type);
                break;
        }
 
@@ -140,7 +130,7 @@ char *phpdbg_decode_opline(zend_op_array *ops, zend_op *op, HashTable *vars) /*{
        return decode[0];
 } /* }}} */
 
-void phpdbg_print_opline_ex(zend_execute_data *execute_data, HashTable *vars, zend_bool ignore_flags) /* {{{ */
+void phpdbg_print_opline_ex(zend_execute_data *execute_data, zend_bool ignore_flags) /* {{{ */
 {
        /* force out a line while stepping so the user knows what is happening */
        if (ignore_flags ||
@@ -149,7 +139,7 @@ void phpdbg_print_opline_ex(zend_execute_data *execute_data, HashTable *vars, ze
                (PHPDBG_G(oplog)))) {
 
                zend_op *opline = (zend_op *) execute_data->opline;
-               char *decode = phpdbg_decode_opline(&execute_data->func->op_array, opline, vars);
+               char *decode = phpdbg_decode_opline(&execute_data->func->op_array, opline);
 
                if (ignore_flags || (!(PHPDBG_G(flags) & PHPDBG_IS_QUIET) || (PHPDBG_G(flags) & PHPDBG_IS_STEPPING))) {
                        /* output line info */
@@ -187,7 +177,7 @@ void phpdbg_print_opline_ex(zend_execute_data *execute_data, HashTable *vars, ze
 
 void phpdbg_print_opline(zend_execute_data *execute_data, zend_bool ignore_flags) /* {{{ */
 {
-       phpdbg_print_opline_ex(execute_data, NULL, ignore_flags);
+       phpdbg_print_opline_ex(execute_data, ignore_flags);
 } /* }}} */
 
 const char *phpdbg_decode_opcode(zend_uchar opcode) /* {{{ */
index dc9d2d9dd00957191e3e0fd20e734da58602460d..ab7e9e261d204de86eb61140c0d91d8ec8fac204 100644 (file)
@@ -24,9 +24,9 @@
 #include "zend_types.h"
 
 const char *phpdbg_decode_opcode(zend_uchar);
-char *phpdbg_decode_opline(zend_op_array *ops, zend_op *op, HashTable *vars);
+char *phpdbg_decode_opline(zend_op_array *ops, zend_op *op);
 void phpdbg_print_opline(zend_execute_data *execute_data, zend_bool ignore_flags);
-void phpdbg_print_opline_ex(zend_execute_data *execute_data, HashTable *vars, zend_bool ignore_flags);
+void phpdbg_print_opline_ex(zend_execute_data *execute_data, zend_bool ignore_flags);
 
 typedef struct _phpdbg_oplog_entry phpdbg_oplog_entry;
 struct _phpdbg_oplog_entry {
index 70b8c2f807af73099b2cad944aad062a55e00ee4..95e0caf784bfa4def627ab6a49fdcabcc4a2e268 100644 (file)
@@ -55,7 +55,6 @@ static inline void phpdbg_print_function_helper(zend_function *method) /* {{{ */
        switch (method->type) {
                case ZEND_USER_FUNCTION: {
                        zend_op_array* op_array = &(method->op_array);
-                       HashTable vars;
 
                        if (op_array) {
                                zend_op *opline = &(op_array->opcodes[0]);
@@ -81,9 +80,8 @@ static inline void phpdbg_print_function_helper(zend_function *method) /* {{{ */
                                                op_array->last);
                                }
 
-                               zend_hash_init(&vars, op_array->last, NULL, NULL, 0);
                                do {
-                                       char *decode = phpdbg_decode_opline(op_array, opline, &vars);
+                                       char *decode = phpdbg_decode_opline(op_array, opline);
                                        if (decode != NULL) {
                                                phpdbg_writeln("print", "line=\"%u\" opnum=\"%u\" opcode=\"%s\" op=\"%s\"", " L%-4u #%-5u %-23s %s",
                                                        opline->lineno,
@@ -96,7 +94,6 @@ static inline void phpdbg_print_function_helper(zend_function *method) /* {{{ */
                                        }
                                        opline++;
                                } while (opcode++ < end);
-                               zend_hash_destroy(&vars);
                        }
                } break;
 
index db44a2ef3285e37c68df82d4433399c788e534f4..540706eae1e6b0c6af50ddd154e8b6f2f0fbd657 100644 (file)
@@ -1418,9 +1418,6 @@ void phpdbg_clean(zend_bool full) /* {{{ */
 void phpdbg_execute_ex(zend_execute_data *execute_data) /* {{{ */
 {
        zend_bool original_in_execution = PHPDBG_G(in_execution);
-       HashTable vars;
-
-       zend_hash_init(&vars, execute_data->func->op_array.last, NULL, NULL, 0);
 
        if ((PHPDBG_G(flags) & PHPDBG_IS_STOPPING) && !(PHPDBG_G(flags) & PHPDBG_IS_RUNNING)) {
                zend_bailout();
@@ -1531,7 +1528,7 @@ ex_is_caught:
                }
 
                /* not while in conditionals */
-               phpdbg_print_opline_ex(execute_data, &vars, 0);
+               phpdbg_print_opline_ex(execute_data, 0);
 
                if (PHPDBG_G(flags) & PHPDBG_IS_STEPPING && (PHPDBG_G(flags) & PHPDBG_STEP_OPCODE || execute_data->opline->lineno != PHPDBG_G(last_line))) {
                        PHPDBG_G(flags) &= ~PHPDBG_IS_STEPPING;
@@ -1581,7 +1578,6 @@ next:
 
                if (PHPDBG_G(vmret) != 0) {
                        if (PHPDBG_G(vmret) < 0) {
-                               zend_hash_destroy(&vars);
                                PHPDBG_G(in_execution) = original_in_execution;
                                return;
                        } else {