From 4a3e501fb39a7276d84fdc33d566bbd7c42ff607 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Fri, 8 Aug 2014 13:47:34 +0400 Subject: [PATCH] cleanup --- Zend/zend.c | 7 +++++-- Zend/zend_ast.c | 1 - Zend/zend_compile.h | 10 ++++------ Zend/zend_execute.c | 39 +++++++++++++++++++-------------------- Zend/zend_execute.h | 3 --- main/output.c | 2 -- main/streams/userspace.c | 1 - 7 files changed, 28 insertions(+), 35 deletions(-) diff --git a/Zend/zend.c b/Zend/zend.c index effc376f197..bc5156d621d 100644 --- a/Zend/zend.c +++ b/Zend/zend.c @@ -227,8 +227,11 @@ again: break; } case IS_TRUE: - // TODO: use interned string ??? - ZVAL_NEW_STR(expr_copy, STR_INIT("1", 1, 0)); + if (CG(one_char_string)['1']) { + ZVAL_INT_STR(expr_copy, CG(one_char_string)['1']); + } else { + ZVAL_NEW_STR(expr_copy, STR_INIT("1", 1, 0)); + } break; case IS_RESOURCE: { char buf[sizeof("Resource id #") + MAX_LENGTH_OF_LONG]; diff --git a/Zend/zend_ast.c b/Zend/zend_ast.c index 180e55404cb..810b9b1fe81 100644 --- a/Zend/zend_ast.c +++ b/Zend/zend_ast.c @@ -109,7 +109,6 @@ static void zend_ast_add_array_element(zval *result, zval *offset, zval *expr TS break; case IS_STRING: zend_symtable_update(Z_ARRVAL_P(result), Z_STR_P(offset), expr); -//??? zval_dtor(offset); break; case IS_NULL: diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h index 3a085f6db74..fa333545f4e 100644 --- a/Zend/zend_compile.h +++ b/Zend/zend_compile.h @@ -719,12 +719,10 @@ int zend_add_literal(zend_op_array *op_array, zval *zv TSRMLS_DC); #define ZEND_FETCH_CLASS_DEFAULT 0 #define ZEND_FETCH_CLASS_SELF 1 #define ZEND_FETCH_CLASS_PARENT 2 -#define ZEND_FETCH_CLASS_MAIN 3 /* unused ??? */ -#define ZEND_FETCH_CLASS_GLOBAL 4 /* unused ??? */ -#define ZEND_FETCH_CLASS_AUTO 5 -#define ZEND_FETCH_CLASS_INTERFACE 6 -#define ZEND_FETCH_CLASS_STATIC 7 -#define ZEND_FETCH_CLASS_TRAIT 14 +#define ZEND_FETCH_CLASS_STATIC 3 +#define ZEND_FETCH_CLASS_AUTO 4 +#define ZEND_FETCH_CLASS_INTERFACE 5 +#define ZEND_FETCH_CLASS_TRAIT 6 #define ZEND_FETCH_CLASS_MASK 0x0f #define ZEND_FETCH_CLASS_NO_AUTOLOAD 0x80 #define ZEND_FETCH_CLASS_SILENT 0x0100 diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 48dbc7a4974..700ce4b090c 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -133,8 +133,7 @@ static const zend_internal_function zend_pass_function = { /* End of zend_execute_locks.h */ -// TODO: avoid global variable usage ??? -#define CV_DEF_OF(i) (EG(current_execute_data)->func->op_array.vars[i]) +#define CV_DEF_OF(i) (EX(func)->op_array.vars[i]) #define CTOR_CALL_BIT 0x1 #define CTOR_USED_BIT 0x2 @@ -182,7 +181,7 @@ static zend_always_inline zval *_get_zval_ptr_var_deref(zend_uint var, const zen return ret; } -static zend_never_inline zval *_get_zval_cv_lookup(zval *ptr, zend_uint var, int type TSRMLS_DC) +static zend_never_inline zval *_get_zval_cv_lookup(zval *ptr, zend_uint var, int type, const zend_execute_data *execute_data TSRMLS_DC) { zend_string *cv; @@ -206,7 +205,7 @@ static zend_never_inline zval *_get_zval_cv_lookup(zval *ptr, zend_uint var, int return ptr; } -static zend_always_inline zval *_get_zval_cv_lookup_BP_VAR_R(zval *ptr, zend_uint var TSRMLS_DC) +static zend_always_inline zval *_get_zval_cv_lookup_BP_VAR_R(zval *ptr, zend_uint var, const zend_execute_data *execute_data TSRMLS_DC) { zend_string *cv = CV_DEF_OF(EX_VAR_TO_NUM(var)); @@ -214,7 +213,7 @@ static zend_always_inline zval *_get_zval_cv_lookup_BP_VAR_R(zval *ptr, zend_uin return &EG(uninitialized_zval); } -static zend_always_inline zval *_get_zval_cv_lookup_BP_VAR_UNSET(zval *ptr, zend_uint var TSRMLS_DC) +static zend_always_inline zval *_get_zval_cv_lookup_BP_VAR_UNSET(zval *ptr, zend_uint var, const zend_execute_data *execute_data TSRMLS_DC) { zend_string *cv = CV_DEF_OF(EX_VAR_TO_NUM(var)); @@ -222,12 +221,12 @@ static zend_always_inline zval *_get_zval_cv_lookup_BP_VAR_UNSET(zval *ptr, zend return &EG(uninitialized_zval); } -static zend_always_inline zval *_get_zval_cv_lookup_BP_VAR_IS(zval *ptr, zend_uint var TSRMLS_DC) +static zend_always_inline zval *_get_zval_cv_lookup_BP_VAR_IS(zval *ptr, zend_uint var, const zend_execute_data *execute_data TSRMLS_DC) { return &EG(uninitialized_zval); } -static zend_always_inline zval *_get_zval_cv_lookup_BP_VAR_RW(zval *ptr, zend_uint var TSRMLS_DC) +static zend_always_inline zval *_get_zval_cv_lookup_BP_VAR_RW(zval *ptr, zend_uint var, const zend_execute_data *execute_data TSRMLS_DC) { zend_string *cv = CV_DEF_OF(EX_VAR_TO_NUM(var)); @@ -236,7 +235,7 @@ static zend_always_inline zval *_get_zval_cv_lookup_BP_VAR_RW(zval *ptr, zend_ui return ptr; } -static zend_always_inline zval *_get_zval_cv_lookup_BP_VAR_W(zval *ptr, zend_uint var TSRMLS_DC) +static zend_always_inline zval *_get_zval_cv_lookup_BP_VAR_W(zval *ptr, zend_uint var, const zend_execute_data *execute_data TSRMLS_DC) { ZVAL_NULL(ptr); return ptr; @@ -247,7 +246,7 @@ static zend_always_inline zval *_get_zval_ptr_cv(const zend_execute_data *execut zval *ret = EX_VAR(var); if (UNEXPECTED(Z_TYPE_P(ret) == IS_UNDEF)) { - return _get_zval_cv_lookup(ret, var, type TSRMLS_CC); + return _get_zval_cv_lookup(ret, var, type, execute_data TSRMLS_CC); } return ret; } @@ -257,7 +256,7 @@ static zend_always_inline zval *_get_zval_ptr_cv_deref(const zend_execute_data * zval *ret = EX_VAR(var); if (UNEXPECTED(Z_TYPE_P(ret) == IS_UNDEF)) { - return _get_zval_cv_lookup(ret, var, type TSRMLS_CC); + return _get_zval_cv_lookup(ret, var, type, execute_data TSRMLS_CC); } ZVAL_DEREF(ret); return ret; @@ -268,7 +267,7 @@ static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_R(const zend_execute_dat zval *ret = EX_VAR(var); if (UNEXPECTED(Z_TYPE_P(ret) == IS_UNDEF)) { - return _get_zval_cv_lookup_BP_VAR_R(ret, var TSRMLS_CC); + return _get_zval_cv_lookup_BP_VAR_R(ret, var, execute_data TSRMLS_CC); } return ret; } @@ -278,7 +277,7 @@ static zend_always_inline zval *_get_zval_ptr_cv_deref_BP_VAR_R(const zend_execu zval *ret = EX_VAR(var); if (UNEXPECTED(Z_TYPE_P(ret) == IS_UNDEF)) { - return _get_zval_cv_lookup_BP_VAR_R(ret, var TSRMLS_CC); + return _get_zval_cv_lookup_BP_VAR_R(ret, var, execute_data TSRMLS_CC); } ZVAL_DEREF(ret); return ret; @@ -289,7 +288,7 @@ static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_UNSET(const zend_execute zval *ret = EX_VAR(var); if (UNEXPECTED(Z_TYPE_P(ret) == IS_UNDEF)) { - return _get_zval_cv_lookup_BP_VAR_UNSET(ret, var TSRMLS_CC); + return _get_zval_cv_lookup_BP_VAR_UNSET(ret, var, execute_data TSRMLS_CC); } return ret; } @@ -299,7 +298,7 @@ static zend_always_inline zval *_get_zval_ptr_cv_deref_BP_VAR_UNSET(const zend_e zval *ret = EX_VAR(var); if (UNEXPECTED(Z_TYPE_P(ret) == IS_UNDEF)) { - return _get_zval_cv_lookup_BP_VAR_UNSET(ret, var TSRMLS_CC); + return _get_zval_cv_lookup_BP_VAR_UNSET(ret, var, execute_data TSRMLS_CC); } ZVAL_DEREF(ret); return ret; @@ -310,7 +309,7 @@ static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_IS(const zend_execute_da zval *ret = EX_VAR(var); if (Z_TYPE_P(ret) == IS_UNDEF) { - return _get_zval_cv_lookup_BP_VAR_IS(ret, var TSRMLS_CC); + return _get_zval_cv_lookup_BP_VAR_IS(ret, var, execute_data TSRMLS_CC); } return ret; } @@ -320,7 +319,7 @@ static zend_always_inline zval *_get_zval_ptr_cv_deref_BP_VAR_IS(const zend_exec zval *ret = EX_VAR(var); if (Z_TYPE_P(ret) == IS_UNDEF) { - return _get_zval_cv_lookup_BP_VAR_IS(ret, var TSRMLS_CC); + return _get_zval_cv_lookup_BP_VAR_IS(ret, var, execute_data TSRMLS_CC); } ZVAL_DEREF(ret); return ret; @@ -331,7 +330,7 @@ static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_RW(const zend_execute_da zval *ret = EX_VAR(var); if (UNEXPECTED(Z_TYPE_P(ret) == IS_UNDEF)) { - return _get_zval_cv_lookup_BP_VAR_RW(ret, var TSRMLS_CC); + return _get_zval_cv_lookup_BP_VAR_RW(ret, var, execute_data TSRMLS_CC); } return ret; } @@ -341,7 +340,7 @@ static zend_always_inline zval *_get_zval_ptr_cv_deref_BP_VAR_RW(const zend_exec zval *ret = EX_VAR(var); if (UNEXPECTED(Z_TYPE_P(ret) == IS_UNDEF)) { - return _get_zval_cv_lookup_BP_VAR_RW(ret, var TSRMLS_CC); + return _get_zval_cv_lookup_BP_VAR_RW(ret, var, execute_data TSRMLS_CC); } ZVAL_DEREF(ret); return ret; @@ -352,7 +351,7 @@ static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_W(const zend_execute_dat zval *ret = EX_VAR(var); if (Z_TYPE_P(ret) == IS_UNDEF) { - return _get_zval_cv_lookup_BP_VAR_W(ret, var TSRMLS_CC); + return _get_zval_cv_lookup_BP_VAR_W(ret, var, execute_data TSRMLS_CC); } return ret; } @@ -367,7 +366,7 @@ static zend_always_inline zval *_get_zval_ptr_cv_deref_BP_VAR_W(const zend_execu zval *ret = EX_VAR(var); if (Z_TYPE_P(ret) == IS_UNDEF) { - return _get_zval_cv_lookup_BP_VAR_W(ret, var TSRMLS_CC); + return _get_zval_cv_lookup_BP_VAR_W(ret, var, execute_data TSRMLS_CC); } ZVAL_DEREF(ret); return ret; diff --git a/Zend/zend_execute.h b/Zend/zend_execute.h index 3ebf1c95f11..cb7ca70ef32 100644 --- a/Zend/zend_execute.h +++ b/Zend/zend_execute.h @@ -115,9 +115,6 @@ again: result = Z_TYPE(tmp) == IS_TRUE; break; } - - // TODO: do we really need this warning ??? - // Nikita, add your comments here. zend_error(E_RECOVERABLE_ERROR, "Object of class %s could not be converted to boolean", Z_OBJ_P(op)->ce->name->val); } else if (Z_OBJ_HT_P(op)->get) { zval rv; diff --git a/main/output.c b/main/output.c index 2531dee2ab6..68f3fa11b99 100644 --- a/main/output.c +++ b/main/output.c @@ -992,8 +992,6 @@ static inline php_output_handler_status_t php_output_handler_op(php_output_handl } zend_fcall_info_argn(&handler->func.user->fci TSRMLS_CC, 0); -//??? zval_ptr_dtor(&ob_data); -//??? zval_ptr_dtor(&ob_mode); zval_ptr_dtor(&retval); } else { diff --git a/main/streams/userspace.c b/main/streams/userspace.c index 058b9d707e3..c41826155cb 100644 --- a/main/streams/userspace.c +++ b/main/streams/userspace.c @@ -285,7 +285,6 @@ static void user_stream_create_object(struct php_user_stream_wrapper *uwrap, php { /* create an instance of our class */ object_init_ex(object, uwrap->ce); -//??? Z_SET_ISREF_P(object); if (context) { add_property_resource(object, "context", context->res);