com php-src: Use zval_ptr_dtor_nogc to destroy lite rals: Zend/zend_ast.c Zend/zend_compile.c Zend/ zend_execute.c Zend/zend_execute.h Zend/zend_opco
de.c Zend/zend_variables.h

From: Date: Wed, 03 Sep 2014 13:18:06 +0000
Subject: com php-src: Use zval_ptr_dtor_nogc to destroy lite rals: Zend/zend_ast.c Zend/zend_compile.c Zend/ zend_execute.c Zend/zend_execute.h Zend/zend_opco
de.c Zend/zend_variables.h
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-81402@lists.php.net to get a copy of this message
Commit: 9e753531842f524a1a147ca0244c041e59ecd117 Author: Nikita Popov <nikic@php.net> Wed, 3 Sep 2014 15:16:32 +0200 Parents: c52511c30703d2921f813ccf1557bc042a7cd9d2 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=9e753531842f524a1a147ca0244c041e59ecd117 Log: Use zval_ptr_dtor_nogc to destroy literals Also move the definition of zval_ptr_dtor_nogc to zend_variables.h (from zend_execute.h/.c) as it's used in a few places. Changed paths: M Zend/zend_ast.c M Zend/zend_compile.c M Zend/zend_execute..c M Zend/zend_execute.h M Zend/zend_opcode.c M Zend/zend_variables.h Diff: diff --git a/Zend/zend_ast.c b/Zend/zend_ast.c index 2f7c9fd..8c9607f 100644 --- a/Zend/zend_ast.c +++ b/Zend/zend_ast..c @@ -382,16 +382,11 @@ static void zend_ast_destroy_ex(zend_ast *ast, zend_bool free) { switch (ast->kind) { case ZEND_AST_ZVAL: - { /* Destroy value without using GC: When opcache moves arrays into SHM it will * free the zend_array structure, so references to it from outside the op array * become invalid. GC would cause such a reference in the root buffer. */ - zval *zv = zend_ast_get_zval(ast); - if (Z_REFCOUNTED_P(zv) && !Z_DELREF_P(zv)) { - _zval_dtor_func_for_ptr(Z_COUNTED_P(zv) ZEND_FILE_LINE_CC); - } + zval_ptr_dtor_nogc(zend_ast_get_zval(ast)); break; - } case ZEND_AST_FUNC_DECL: case ZEND_AST_CLOSURE: case ZEND_AST_METHOD: diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 0b42f95..a5a3229 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -600,10 +600,7 @@ void zend_do_free(znode *op1 TSRMLS_DC) /* {{{ */ /* Destroy value without using GC: When opcache moves arrays into SHM it will * free the zend_array structure, so references to it from outside the op array * become invalid. GC would cause such a reference in the root buffer. */ - zval *zv = &op1->u.constant; - if (Z_REFCOUNTED_P(zv) && !Z_DELREF_P(zv)) { - _zval_dtor_func_for_ptr(Z_COUNTED_P(zv) ZEND_FILE_LINE_CC); - } + zval_ptr_dtor_nogc(&op1->u.constant); } } /* }}} */ diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 9237e97..d981773 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -83,7 +83,6 @@ static const zend_internal_function zend_pass_function = { #undef zval_ptr_dtor #define zval_ptr_dtor(zv) i_zval_ptr_dtor(zv ZEND_FILE_LINE_CC TSRMLS_CC) -#define zval_ptr_dtor_nogc(zv) i_zval_ptr_dtor_nogc(zv ZEND_FILE_LINE_CC TSRMLS_CC) #define PZVAL_LOCK(z) if (Z_REFCOUNTED_P(z)) Z_ADDREF_P((z)) #define SELECTIVE_PZVAL_LOCK(pzv, opline) if (RETURN_VALUE_USED(opline)) { PZVAL_LOCK(pzv); } diff --git a/Zend/zend_execute.h b/Zend/zend_execute.h index ed905ff..77e6a9e 100644 --- a/Zend/zend_execute.h +++ b/Zend/zend_execute.h @@ -63,16 +63,6 @@ static zend_always_inline void i_zval_ptr_dtor(zval *zval_ptr ZEND_FILE_LINE_DC } } -static zend_always_inline void i_zval_ptr_dtor_nogc(zval *zval_ptr ZEND_FILE_LINE_DC TSRMLS_DC) -{ - if (Z_REFCOUNTED_P(zval_ptr)) { - if (!Z_DELREF_P(zval_ptr)) { - ZEND_ASSERT(zval_ptr != &EG(uninitialized_zval)); - _zval_dtor_func_for_ptr(Z_COUNTED_P(zval_ptr) ZEND_FILE_LINE_CC); - } - } -} - static zend_always_inline int i_zend_is_true(zval *op TSRMLS_DC) { int result; @@ -237,7 +227,7 @@ static zend_always_inline void zend_vm_stack_free_extra_args(zend_execute_data * zval *p = end + (call->num_args - first_extra_arg); do { p--; - i_zval_ptr_dtor_nogc(p ZEND_FILE_LINE_CC TSRMLS_CC); + zval_ptr_dtor_nogc(p); } while (p != end); } } @@ -252,7 +242,7 @@ static zend_always_inline void zend_vm_stack_free_args(zend_execute_data *call T do { p--; - i_zval_ptr_dtor_nogc(p ZEND_FILE_LINE_CC TSRMLS_CC); + zval_ptr_dtor_nogc(p); } while (p != end); } } diff --git a/Zend/zend_opcode.c b/Zend/zend_opcode.c index d5c4693..db1f1cf 100644 --- a/Zend/zend_opcode.c +++ b/Zend/zend_opcode.c @@ -343,7 +343,7 @@ ZEND_API void destroy_op_array(zend_op_array *op_array TSRMLS_DC) if (literal) { end = literal + op_array->last_literal; while (literal < end) { - zval_dtor(literal); + zval_ptr_dtor_nogc(literal); literal++; } efree(op_array->literals); diff --git a/Zend/zend_variables..h b/Zend/zend_variables.h index c55ce23..538d2a5 100644 --- a/Zend/zend_variables.h +++ b/Zend/zend_variables.h @@ -36,6 +36,13 @@ static zend_always_inline void _zval_dtor(zval *zvalue ZEND_FILE_LINE_DC) _zval_dtor_func(Z_COUNTED_P(zvalue) ZEND_FILE_LINE_RELAY_CC); } +static zend_always_inline void _zval_ptr_dtor_nogc(zval *zval_ptr ZEND_FILE_LINE_DC) +{ + if (Z_REFCOUNTED_P(zval_ptr) && !Z_DELREF_P(zval_ptr)) { + _zval_dtor_func_for_ptr(Z_COUNTED_P(zval_ptr) ZEND_FILE_LINE_CC); + } +} + ZEND_API void _zval_copy_ctor_func(zval *zvalue ZEND_FILE_LINE_DC); #define zval_copy_ctor_func(zv) _zval_copy_ctor_func(zv ZEND_FILE_LINE_CC) @@ -98,6 +105,7 @@ ZEND_API void _zval_dtor_wrapper(zval *zvalue); #define zval_opt_copy_ctor_no_imm(zvalue) _zval_opt_copy_ctor_no_imm((zvalue) ZEND_FILE_LINE_CC) #define zval_dtor(zvalue) _zval_dtor((zvalue) ZEND_FILE_LINE_CC) #define zval_ptr_dtor(zval_ptr) _zval_ptr_dtor((zval_ptr) ZEND_FILE_LINE_CC) +#define zval_ptr_dtor_nogc(zval_ptr) _zval_ptr_dtor_nogc((zval_ptr) ZEND_FILE_LINE_CC) #define zval_internal_dtor(zvalue) _zval_internal_dtor((zvalue) ZEND_FILE_LINE_CC) #define zval_internal_ptr_dtor(zvalue) _zval_internal_ptr_dtor((zvalue) ZEND_FILE_LINE_CC) #define zval_dtor_wrapper _zval_dtor_wrapper

« previous php.cvs (#81402) next »