]> granicus.if.org Git - php/commitdiff
Moved compiler helper functions from zend_opcode.c to zend_compile.c
authorDmitry Stogov <dmitry@zend.com>
Tue, 13 Mar 2018 10:49:58 +0000 (13:49 +0300)
committerDmitry Stogov <dmitry@zend.com>
Tue, 13 Mar 2018 10:49:58 +0000 (13:49 +0300)
Zend/zend_compile.c
Zend/zend_compile.h
Zend/zend_opcode.c

index 9ce33737afda3a4b2ed2a464fcb47bc5bed3f2cf..ffc92323d790c3f1541346fa9eed0442feff6e6f 100644 (file)
@@ -91,6 +91,37 @@ ZEND_API zend_executor_globals executor_globals;
 static zend_op *zend_emit_op(znode *result, zend_uchar opcode, znode *op1, znode *op2);
 static zend_bool zend_try_ct_eval_array(zval *result, zend_ast *ast);
 
+static void init_op(zend_op *op)
+{
+       MAKE_NOP(op);
+       op->extended_value = 0;
+       op->lineno = CG(zend_lineno);
+}
+
+static zend_op *get_next_op(zend_op_array *op_array)
+{
+       uint32_t next_op_num = op_array->last++;
+       zend_op *next_op;
+
+       if (UNEXPECTED(next_op_num >= CG(context).opcodes_size)) {
+               CG(context).opcodes_size *= 4;
+               op_array->opcodes = erealloc(op_array->opcodes, CG(context).opcodes_size * sizeof(zend_op));
+       }
+
+       next_op = &(op_array->opcodes[next_op_num]);
+
+       init_op(next_op);
+
+       return next_op;
+}
+
+static zend_brk_cont_element *get_next_brk_cont_element(void)
+{
+       CG(context).last_brk_cont++;
+       CG(context).brk_cont_array = erealloc(CG(context).brk_cont_array, sizeof(zend_brk_cont_element) * CG(context).last_brk_cont);
+       return &CG(context).brk_cont_array[CG(context).last_brk_cont-1];
+}
+
 static void zend_destroy_property_info_internal(zval *zv) /* {{{ */
 {
        zend_property_info *property_info = Z_PTR_P(zv);
index 2c708bdd3069ebc558a78ed1f951bf4758a8779c..b03f8bd677148359d6bc533ab21ed4bbcc5c51d5 100644 (file)
@@ -772,10 +772,7 @@ ZEND_API int zend_unmangle_property_name_ex(const zend_string *name, const char
 #define ZEND_FUNCTION_DTOR zend_function_dtor
 #define ZEND_CLASS_DTOR destroy_zend_class
 
-zend_op *get_next_op(zend_op_array *op_array);
-void init_op(zend_op *op);
 ZEND_API int pass_two(zend_op_array *op_array);
-zend_brk_cont_element *get_next_brk_cont_element(void);
 ZEND_API zend_bool zend_is_compiling(void);
 ZEND_API char *zend_make_compiled_string_description(const char *name);
 ZEND_API void zend_initialize_class_data(zend_class_entry *ce, zend_bool nullify_handlers);
index 5e7164c3245aebadff25848c67dcfa5398776a19..f5348083213240cec8c99a3f9e5fd703c5075ba3 100644 (file)
@@ -45,11 +45,6 @@ static void zend_extension_op_array_dtor_handler(zend_extension *extension, zend
        }
 }
 
-static void op_array_alloc_ops(zend_op_array *op_array, uint32_t size)
-{
-       op_array->opcodes = erealloc(op_array->opcodes, size * sizeof(zend_op));
-}
-
 void init_op_array(zend_op_array *op_array, zend_uchar type, int initial_ops_size)
 {
        op_array->type = type;
@@ -60,8 +55,7 @@ void init_op_array(zend_op_array *op_array, zend_uchar type, int initial_ops_siz
        op_array->refcount = (uint32_t *) emalloc(sizeof(uint32_t));
        *op_array->refcount = 1;
        op_array->last = 0;
-       op_array->opcodes = NULL;
-       op_array_alloc_ops(op_array, initial_ops_size);
+       op_array->opcodes = emalloc(initial_ops_size * sizeof(zend_op));;
 
        op_array->last_var = 0;
        op_array->vars = NULL;
@@ -454,36 +448,6 @@ ZEND_API void destroy_op_array(zend_op_array *op_array)
        }
 }
 
-void init_op(zend_op *op)
-{
-       memset(op, 0, sizeof(zend_op));
-       op->lineno = CG(zend_lineno);
-}
-
-zend_op *get_next_op(zend_op_array *op_array)
-{
-       uint32_t next_op_num = op_array->last++;
-       zend_op *next_op;
-
-       if (next_op_num >= CG(context).opcodes_size) {
-               CG(context).opcodes_size *= 4;
-               op_array_alloc_ops(op_array, CG(context).opcodes_size);
-       }
-
-       next_op = &(op_array->opcodes[next_op_num]);
-
-       init_op(next_op);
-
-       return next_op;
-}
-
-zend_brk_cont_element *get_next_brk_cont_element(void)
-{
-       CG(context).last_brk_cont++;
-       CG(context).brk_cont_array = erealloc(CG(context).brk_cont_array, sizeof(zend_brk_cont_element) * CG(context).last_brk_cont);
-       return &CG(context).brk_cont_array[CG(context).last_brk_cont-1];
-}
-
 static void zend_update_extended_info(zend_op_array *op_array)
 {
        zend_op *opline = op_array->opcodes, *end=opline+op_array->last;