From 8fe47a47cf30eb3bf50a5cdb4e07f6fa135d21c7 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Tue, 13 Jun 2017 13:48:58 +0300 Subject: [PATCH] Avoid run-time checks performed at compile-time. --- Zend/zend_vm_def.h | 3 ++- Zend/zend_vm_execute.h | 27 ++++++++++++++++++--------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index dc00f3ce12..7b390939bc 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -6520,7 +6520,8 @@ ZEND_VM_C_LABEL(isset_str_offset): ZVAL_DEREF(offset); } if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */ - || (Z_TYPE_P(offset) == IS_STRING /* or numeric string */ + || (OP2_TYPE != IS_CONST + && Z_TYPE_P(offset) == IS_STRING /* or numeric string */ && IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) { lval = zval_get_long(offset); ZEND_VM_C_GOTO(isset_str_offset); diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index b34082a2f7..35bf0d3eae 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -6180,7 +6180,8 @@ isset_str_offset: ZVAL_DEREF(offset); } if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */ - || (Z_TYPE_P(offset) == IS_STRING /* or numeric string */ + || (IS_CONST != IS_CONST + && Z_TYPE_P(offset) == IS_STRING /* or numeric string */ && IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) { lval = zval_get_long(offset); goto isset_str_offset; @@ -10055,7 +10056,8 @@ isset_str_offset: ZVAL_DEREF(offset); } if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */ - || (Z_TYPE_P(offset) == IS_STRING /* or numeric string */ + || (IS_CV != IS_CONST + && Z_TYPE_P(offset) == IS_STRING /* or numeric string */ && IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) { lval = zval_get_long(offset); goto isset_str_offset; @@ -11989,7 +11991,8 @@ isset_str_offset: ZVAL_DEREF(offset); } if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */ - || (Z_TYPE_P(offset) == IS_STRING /* or numeric string */ + || ((IS_TMP_VAR|IS_VAR) != IS_CONST + && Z_TYPE_P(offset) == IS_STRING /* or numeric string */ && IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) { lval = zval_get_long(offset); goto isset_str_offset; @@ -38401,7 +38404,8 @@ isset_str_offset: ZVAL_DEREF(offset); } if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */ - || (Z_TYPE_P(offset) == IS_STRING /* or numeric string */ + || (IS_CONST != IS_CONST + && Z_TYPE_P(offset) == IS_STRING /* or numeric string */ && IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) { lval = zval_get_long(offset); goto isset_str_offset; @@ -44735,7 +44739,8 @@ isset_str_offset: ZVAL_DEREF(offset); } if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */ - || (Z_TYPE_P(offset) == IS_STRING /* or numeric string */ + || (IS_CV != IS_CONST + && Z_TYPE_P(offset) == IS_STRING /* or numeric string */ && IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) { lval = zval_get_long(offset); goto isset_str_offset; @@ -48285,7 +48290,8 @@ isset_str_offset: ZVAL_DEREF(offset); } if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */ - || (Z_TYPE_P(offset) == IS_STRING /* or numeric string */ + || ((IS_TMP_VAR|IS_VAR) != IS_CONST + && Z_TYPE_P(offset) == IS_STRING /* or numeric string */ && IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) { lval = zval_get_long(offset); goto isset_str_offset; @@ -50327,7 +50333,8 @@ isset_str_offset: ZVAL_DEREF(offset); } if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */ - || (Z_TYPE_P(offset) == IS_STRING /* or numeric string */ + || (IS_CONST != IS_CONST + && Z_TYPE_P(offset) == IS_STRING /* or numeric string */ && IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) { lval = zval_get_long(offset); goto isset_str_offset; @@ -52522,7 +52529,8 @@ isset_str_offset: ZVAL_DEREF(offset); } if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */ - || (Z_TYPE_P(offset) == IS_STRING /* or numeric string */ + || (IS_CV != IS_CONST + && Z_TYPE_P(offset) == IS_STRING /* or numeric string */ && IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) { lval = zval_get_long(offset); goto isset_str_offset; @@ -53817,7 +53825,8 @@ isset_str_offset: ZVAL_DEREF(offset); } if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */ - || (Z_TYPE_P(offset) == IS_STRING /* or numeric string */ + || ((IS_TMP_VAR|IS_VAR) != IS_CONST + && Z_TYPE_P(offset) == IS_STRING /* or numeric string */ && IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) { lval = zval_get_long(offset); goto isset_str_offset; -- 2.40.0