Last active
August 29, 2015 14:02
-
-
Save laruence/2a488a14e667de125546 to your computer and use it in GitHub Desktop.
Numeric zend_string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c | |
index ea75c15..a9a0500 100644 | |
--- a/Zend/zend_compile.c | |
+++ b/Zend/zend_compile.c | |
@@ -813,7 +813,7 @@ void fetch_array_dim(znode *result, znode *parent, znode *dim TSRMLS_DC) /* {{{ | |
ulong index; | |
int numeric = 0; | |
- ZEND_HANDLE_NUMERIC_EX(Z_STRVAL(CONSTANT(opline.op2.constant)), Z_STRLEN(CONSTANT(opline.op2.constant))+ | |
1, index, numeric = 1); | |
+ ZEND_HANDLE_NUMERIC_STR_EX(Z_STR(CONSTANT(opline.op2.constant)), index, numeric = 1); | |
if (numeric) { | |
zval_dtor(&CONSTANT(opline.op2.constant)); | |
ZVAL_LONG(&CONSTANT(opline.op2.constant), index); | |
@@ -5875,7 +5875,7 @@ void zend_do_init_array(znode *result, znode *expr, znode *offset, zend_bool is_ | |
int numeric = 0; | |
opline->extended_value |= ZEND_ARRAY_NOT_PACKED; | |
- ZEND_HANDLE_NUMERIC_EX(Z_STRVAL(CONSTANT(opline->op2.constant)), Z_STRLEN(CONSTANT(oplin | |
e->op2.constant))+1, index, numeric = 1); | |
+ ZEND_HANDLE_NUMERIC_STR_EX(Z_STR(CONSTANT(opline->op2.constant)), index, numeric = 1); | |
if (numeric) { | |
zval_dtor(&CONSTANT(opline->op2.constant)); | |
ZVAL_LONG(&CONSTANT(opline->op2.constant), index); | |
@@ -5907,7 +5907,7 @@ void zend_do_add_array_element(znode *result, znode *expr, znode *offset, zend_b | |
int numeric = 0; | |
init_opline->extended_value |= ZEND_ARRAY_NOT_PACKED; | |
- ZEND_HANDLE_NUMERIC_EX(Z_STRVAL(CONSTANT(opline->op2.constant)), Z_STRLEN(CONSTANT(opline->op2.c | |
onstant))+1, index, numeric = 1); | |
+ ZEND_HANDLE_NUMERIC_STR_EX(Z_STR(CONSTANT(opline->op2.constant)), index, numeric = 1); | |
if (numeric) { | |
zval_dtor(&CONSTANT(opline->op2.constant)); | |
ZVAL_LONG(&CONSTANT(opline->op2.constant), index); | |
diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c | |
index 37539d6..c74cc51 100644 | |
--- a/Zend/zend_execute.c | |
+++ b/Zend/zend_execute.c | |
@@ -1043,7 +1043,7 @@ num_index: | |
} else if (EXPECTED(Z_TYPE_P(dim) == IS_STRING)) { | |
offset_key = Z_STR_P(dim); | |
if (dim_type != IS_CONST) { | |
- ZEND_HANDLE_NUMERIC_EX(offset_key->val, offset_key->len+1, hval, goto num_index); | |
+ ZEND_HANDLE_NUMERIC_STR_EX(offset_key, hval, goto num_index); | |
} | |
str_index: | |
retval = zend_hash_find(ht, offset_key); | |
diff --git a/Zend/zend_hash.c b/Zend/zend_hash.c | |
index 08b4cb5..b55edfa 100644 | |
--- a/Zend/zend_hash.c | |
+++ b/Zend/zend_hash.c | |
@@ -188,6 +188,8 @@ static zend_always_inline Bucket *zend_hash_find_bucket(const HashTable *ht, zen | |
uint idx; | |
Bucket *p; | |
[xinchen@inf-dev-porsche.weibo.com:/home/huixinchen/opensource/php-ng/] | |
$ git diff > numeric_string.patch | |
[xinchen@inf-dev-porsche.weibo.com:/home/huixinchen/opensource/php-ng/] | |
$ cat Zend/tests/isset_str_offset.diff | |
cat: Zend/tests/isset_str_offset.diff: No such file or directory | |
[xinchen@inf-dev-porsche.weibo.com:/home/huixinchen/opensource/php-ng/] | |
$ cat numeric_string.patch | |
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c | |
index ea75c15..a9a0500 100644 | |
--- a/Zend/zend_compile.c | |
+++ b/Zend/zend_compile.c | |
@@ -813,7 +813,7 @@ void fetch_array_dim(znode *result, znode *parent, znode *dim TSRMLS_DC) /* {{{ | |
ulong index; | |
int numeric = 0; | |
- ZEND_HANDLE_NUMERIC_EX(Z_STRVAL(CONSTANT(opline.op2.constant)), Z_STRLEN(CONSTANT(opline.op2.constant))+1, index, numeric = 1); | |
+ ZEND_HANDLE_NUMERIC_STR_EX(Z_STR(CONSTANT(opline.op2.constant)), index, numeric = 1); | |
if (numeric) { | |
zval_dtor(&CONSTANT(opline.op2.constant)); | |
ZVAL_LONG(&CONSTANT(opline.op2.constant), index); | |
@@ -5875,7 +5875,7 @@ void zend_do_init_array(znode *result, znode *expr, znode *offset, zend_bool is_ | |
int numeric = 0; | |
opline->extended_value |= ZEND_ARRAY_NOT_PACKED; | |
- ZEND_HANDLE_NUMERIC_EX(Z_STRVAL(CONSTANT(opline->op2.constant)), Z_STRLEN(CONSTANT(opline->op2.constant))+1, index, numeric = 1); | |
+ ZEND_HANDLE_NUMERIC_STR_EX(Z_STR(CONSTANT(opline->op2.constant)), index, numeric = 1); | |
if (numeric) { | |
zval_dtor(&CONSTANT(opline->op2.constant)); | |
ZVAL_LONG(&CONSTANT(opline->op2.constant), index); | |
@@ -5907,7 +5907,7 @@ void zend_do_add_array_element(znode *result, znode *expr, znode *offset, zend_b | |
int numeric = 0; | |
init_opline->extended_value |= ZEND_ARRAY_NOT_PACKED; | |
- ZEND_HANDLE_NUMERIC_EX(Z_STRVAL(CONSTANT(opline->op2.constant)), Z_STRLEN(CONSTANT(opline->op2.constant))+1, index, numeric = 1); | |
+ ZEND_HANDLE_NUMERIC_STR_EX(Z_STR(CONSTANT(opline->op2.constant)), index, numeric = 1); | |
if (numeric) { | |
zval_dtor(&CONSTANT(opline->op2.constant)); | |
ZVAL_LONG(&CONSTANT(opline->op2.constant), index); | |
diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c | |
index 37539d6..c74cc51 100644 | |
--- a/Zend/zend_execute.c | |
+++ b/Zend/zend_execute.c | |
@@ -1043,7 +1043,7 @@ num_index: | |
} else if (EXPECTED(Z_TYPE_P(dim) == IS_STRING)) { | |
offset_key = Z_STR_P(dim); | |
if (dim_type != IS_CONST) { | |
- ZEND_HANDLE_NUMERIC_EX(offset_key->val, offset_key->len+1, hval, goto num_index); | |
+ ZEND_HANDLE_NUMERIC_STR_EX(offset_key, hval, goto num_index); | |
} | |
str_index: | |
retval = zend_hash_find(ht, offset_key); | |
diff --git a/Zend/zend_hash.c b/Zend/zend_hash.c | |
index 08b4cb5..b55edfa 100644 | |
--- a/Zend/zend_hash.c | |
+++ b/Zend/zend_hash.c | |
@@ -188,6 +188,8 @@ static zend_always_inline Bucket *zend_hash_find_bucket(const HashTable *ht, zen | |
uint idx; | |
Bucket *p; | |
+ ZEND_ASSERT(!IS_NUMERIC(key)); | |
+ | |
h = STR_HASH_VAL(key); | |
nIndex = h & ht->nTableMask; | |
idx = ht->arHash[nIndex]; | |
@@ -254,6 +256,7 @@ static zend_always_inline zval *_zend_hash_add_or_update_i(HashTable *ht, zend_s | |
TSRMLS_FETCH(); | |
#endif | |
+ ZEND_ASSERT(!IS_NUMERIC(key)); | |
IS_CONSISTENT(ht); | |
CHECK_INIT(ht, 0); | |
@@ -673,6 +676,7 @@ ZEND_API int zend_hash_del(HashTable *ht, zend_string *key) | |
TSRMLS_FETCH(); | |
#endif | |
+ ZEND_ASSERT(!IS_NUMERIC(key)); | |
IS_CONSISTENT(ht); | |
if (ht->u.flags & HASH_FLAG_PACKED) { | |
@@ -712,6 +716,7 @@ ZEND_API int zend_hash_del_ind(HashTable *ht, zend_string *key) | |
TSRMLS_FETCH(); | |
#endif | |
+ ZEND_ASSERT(!IS_NUMERIC(key)); | |
IS_CONSISTENT(ht); | |
if (ht->u.flags & HASH_FLAG_PACKED) { | |
@@ -1366,6 +1371,7 @@ ZEND_API zval *zend_hash_find(const HashTable *ht, zend_string *key) | |
{ | |
Bucket *p; | |
+ ZEND_ASSERT(!IS_NUMERIC(key)); | |
IS_CONSISTENT(ht); | |
if (ht->u.flags & HASH_FLAG_PACKED) { | |
@@ -1396,6 +1402,7 @@ ZEND_API int zend_hash_exists(const HashTable *ht, zend_string *key) | |
{ | |
Bucket *p; | |
+ ZEND_ASSERT(!IS_NUMERIC(key)); | |
IS_CONSISTENT(ht); | |
if (ht->u.flags & HASH_FLAG_PACKED) { | |
diff --git a/Zend/zend_hash.h b/Zend/zend_hash.h | |
index 8660f8b..c3b3e58 100644 | |
--- a/Zend/zend_hash.h | |
+++ b/Zend/zend_hash.h | |
@@ -235,9 +235,8 @@ END_EXTERN_C() | |
#define ZEND_INIT_SYMTABLE_EX(ht, n, persistent) \ | |
zend_hash_init(ht, n, NULL, ZVAL_PTR_DTOR, persistent) | |
-#define ZEND_HANDLE_NUMERIC_EX(key, length, idx, func) do { \ | |
+#define ZEND_HANDLE_NUMERIC_INTERNAL(key, length, idx, func) \ | |
register const char *tmp = key; \ | |
- \ | |
if (*tmp == '-') { \ | |
tmp++; \ | |
} \ | |
@@ -261,7 +260,7 @@ END_EXTERN_C() | |
if (idx-1 > LONG_MAX) { /* overflow */ \ | |
break; \ | |
} \ | |
- idx = 0 - idx; \ | |
+ idx = 0 - idx; \ | |
} else if (idx > LONG_MAX) { /* overflow */ \ | |
break; \ | |
} \ | |
@@ -270,10 +269,33 @@ END_EXTERN_C() | |
} \ | |
} while (0) | |
-#define ZEND_HANDLE_NUMERIC(key, length, func) do { \ | |
+#define ZEND_HANDLE_NUMERIC_EX(key, len, idx, func) do { \ | |
+ ZEND_HANDLE_NUMERIC_INTERNAL(key, len, idx, func) | |
+ | |
+#define ZEND_HANDLE_NUMERIC_STR_EX(str, idx, func) do { \ | |
+ if ((GC_FLAGS(str) & IS_STR_NUMERIC)) { \ | |
+ idx = str->h; \ | |
+ func; \ | |
+ break; \ | |
+ } \ | |
+ ZEND_HANDLE_NUMERIC_INTERNAL(str->val, str->len+1, idx, goto _numeric); \ | |
+ if (0) { \ | |
+_numeric: \ | |
+ str->h = idx; \ | |
+ GC_FLAGS(str) |= IS_STR_NUMERIC; \ | |
+ func; \ | |
+ } | |
+ | |
+#define ZEND_HANDLE_NUMERIC(key, len, func) do { \ | |
+ ulong idx; \ | |
+ \ | |
+ ZEND_HANDLE_NUMERIC_EX(key, len, idx, return func); \ | |
+} while (0) | |
+ | |
+#define ZEND_HANDLE_NUMERIC_STR(key, func) do { \ | |
ulong idx; \ | |
\ | |
- ZEND_HANDLE_NUMERIC_EX(key, length, idx, return func); \ | |
+ ZEND_HANDLE_NUMERIC_STR_EX(key, idx, return func); \ | |
} while (0) | |
@@ -307,49 +329,49 @@ static inline zval *zend_hash_str_find_ind(const HashTable *ht, const char *str, | |
static inline zval *zend_symtable_update(HashTable *ht, zend_string *key, zval *pData) | |
{ | |
- ZEND_HANDLE_NUMERIC(key->val, key->len+1, zend_hash_index_update(ht, idx, pData)); | |
+ ZEND_HANDLE_NUMERIC_STR(key, zend_hash_index_update(ht, idx, pData)); | |
return zend_hash_update(ht, key, pData); | |
} | |
static inline zval *zend_symtable_update_ind(HashTable *ht, zend_string *key, zval *pData) | |
{ | |
- ZEND_HANDLE_NUMERIC(key->val, key->len+1, zend_hash_index_update(ht, idx, pData)); | |
+ ZEND_HANDLE_NUMERIC_STR(key, zend_hash_index_update(ht, idx, pData)); | |
return zend_hash_update_ind(ht, key, pData); | |
} | |
static inline int zend_symtable_del(HashTable *ht, zend_string *key) | |
{ | |
- ZEND_HANDLE_NUMERIC(key->val, key->len+1, zend_hash_index_del(ht, idx)); | |
+ ZEND_HANDLE_NUMERIC_STR(key, zend_hash_index_del(ht, idx)); | |
return zend_hash_del(ht, key); | |
} | |
static inline int zend_symtable_del_ind(HashTable *ht, zend_string *key) | |
{ | |
- ZEND_HANDLE_NUMERIC(key->val, key->len+1, zend_hash_index_del(ht, idx)); | |
+ ZEND_HANDLE_NUMERIC_STR(key, zend_hash_index_del(ht, idx)); | |
return zend_hash_del_ind(ht, key); | |
} | |
static inline zval *zend_symtable_find(const HashTable *ht, zend_string *key) | |
{ | |
- ZEND_HANDLE_NUMERIC(key->val, key->len+1, zend_hash_index_find(ht, idx)); | |
+ ZEND_HANDLE_NUMERIC_STR(key, zend_hash_index_find(ht, idx)); | |
return zend_hash_find(ht, key); | |
} | |
static inline zval *zend_symtable_find_ind(const HashTable *ht, zend_string *key) | |
{ | |
- ZEND_HANDLE_NUMERIC(key->val, key->len+1, zend_hash_index_find(ht, idx)); | |
+ ZEND_HANDLE_NUMERIC_STR(key, zend_hash_index_find(ht, idx)); | |
return zend_hash_find_ind(ht, key); | |
} | |
static inline int zend_symtable_exists(HashTable *ht, zend_string *key) | |
{ | |
- ZEND_HANDLE_NUMERIC(key->val, key->len+1, zend_hash_index_exists(ht, idx)); | |
+ ZEND_HANDLE_NUMERIC_STR(key, zend_hash_index_exists(ht, idx)); | |
return zend_hash_exists(ht, key); | |
} | |
diff --git a/Zend/zend_string.h b/Zend/zend_string.h | |
index dfdc74e..fa2b4b1 100644 | |
--- a/Zend/zend_string.h | |
+++ b/Zend/zend_string.h | |
@@ -36,6 +36,7 @@ void zend_interned_strings_dtor(TSRMLS_D); | |
END_EXTERN_C() | |
#define IS_INTERNED(s) (GC_FLAGS(s) & IS_STR_INTERNED) | |
+#define IS_NUMERIC(s) (GC_FLAGS(s) & IS_STR_NUMERIC) | |
#define STR_HASH_VAL(s) zend_str_hash_val(s) | |
#define STR_FORGET_HASH_VAL(s) zend_str_forget_hash_val(s) | |
@@ -59,9 +60,11 @@ END_EXTERN_C() | |
#define STR_ALLOCA_ALLOC(str, _len, use_heap) do { \ | |
(str) = do_alloca(_STR_HEADER_SIZE + (_len) + 1, (use_heap)); \ | |
GC_REFCOUNT(str) = 1; \ | |
+ GC_FLAGS(str) = 0; \ | |
(str)->h = 0; \ | |
(str)->len = (_len); \ | |
} while (0) | |
+ | |
#define STR_ALLOCA_INIT(str, s, len, use_heap) do { \ | |
STR_ALLOCA_ALLOC(str, len, use_heap); \ | |
memcpy((str)->val, (s), (len)); \ | |
@@ -81,6 +84,7 @@ static zend_always_inline zend_ulong zend_str_hash_val(zend_string *s) | |
static zend_always_inline void zend_str_forget_hash_val(zend_string *s) | |
{ | |
s->h = 0; | |
+ GC_FLAGS(s) &= ~IS_STR_NUMERIC; | |
} | |
static zend_always_inline zend_uint zend_str_refcount(zend_string *s) | |
@@ -165,7 +169,16 @@ static zend_always_inline zend_string *zend_str_dup(zend_string *s, int persiste | |
if (IS_INTERNED(s)) { | |
return s; | |
} else { | |
- return STR_INIT(s->val, s->len, persistent); | |
+ zend_string *ret; | |
+ | |
+ ret = pemalloc(_STR_HEADER_SIZE + s->len + 1, persistent); | |
+ memcpy(ret, s, _STR_HEADER_SIZE + s->len + 1); | |
+ | |
+ GC_REFCOUNT(ret) = 1; | |
+ GC_FLAGS(ret) = (persistent ? IS_STR_PERSISTENT : 0) | (GC_FLAGS(s) & ~(IS_STR_PERSISTENT|IS_STR_PERMANENT)); | |
+ GC_INFO(ret) = 0; | |
+ | |
+ return ret; | |
} | |
} | |
diff --git a/Zend/zend_types.h b/Zend/zend_types.h | |
index 232fcba..6d27bd7 100644 | |
--- a/Zend/zend_types.h | |
+++ b/Zend/zend_types.h | |
@@ -308,10 +308,11 @@ static inline zend_uchar zval_get_type(const zval* pz) { | |
/* string flags (zval.value->gc.u.flags) */ | |
#define IS_STR_PERSISTENT (1<<0) /* allocated using malloc */ | |
#define IS_STR_INTERNED (1<<1) /* interned string */ | |
-#define IS_STR_PERMANENT (1<<2) /* relives request boundary */ | |
+#define IS_STR_NUMERIC (1<<2) /* is numeric string */ | |
+#define IS_STR_PERMANENT (1<<3) /* relives request boundary */ | |
-#define IS_STR_CONSTANT (1<<3) /* constant index */ | |
-#define IS_STR_CONSTANT_UNQUALIFIED (1<<4) /* the same as IS_CONSTANT_UNQUALIFIED */ | |
+#define IS_STR_CONSTANT (1<<4) /* constant index */ | |
+#define IS_STR_CONSTANT_UNQUALIFIED (1<<5) /* the same as IS_CONSTANT_UNQUALIFIED */ | |
/* object flags (zval.value->gc.u.flags) */ | |
#define IS_OBJ_APPLY_COUNT 0x07 | |
diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h | |
index 0b5dde1..c8487c6 100644 | |
--- a/Zend/zend_vm_def.h | |
+++ b/Zend/zend_vm_def.h | |
@@ -4707,12 +4707,13 @@ ZEND_VM_C_LABEL(str_index_prop): | |
result = 0; | |
if (UNEXPECTED(Z_TYPE_P(offset) != IS_LONG)) { | |
- if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */ | |
- || (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))) { | |
+ if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */) { | |
ZVAL_DUP(&tmp, offset); | |
convert_to_long(&tmp); | |
offset = &tmp; | |
+ } else if (Z_TYPE_P(offset) == IS_STRING /* or numeric string */) { | |
+ ulong idx; | |
+ ZEND_HANDLE_NUMERIC_STR_EX(Z_STR_P(offset), idx, ZVAL_LONG(&tmp, idx); offset = &tmp); | |
} | |
} | |
if (Z_TYPE_P(offset) == IS_LONG) { | |
diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h | |
index a5b678c..77680da 100644 | |
--- a/Zend/zend_vm_execute.h | |
+++ b/Zend/zend_vm_execute.h | |
@@ -15934,12 +15934,13 @@ str_index_prop: | |
result = 0; | |
if (UNEXPECTED(Z_TYPE_P(offset) != IS_LONG)) { | |
- if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */ | |
- || (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))) { | |
+ if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */) { | |
ZVAL_DUP(&tmp, offset); | |
convert_to_long(&tmp); | |
offset = &tmp; | |
+ } else if (Z_TYPE_P(offset) == IS_STRING /* or numeric string */) { | |
+ ulong idx; | |
+ ZEND_HANDLE_NUMERIC_STR_EX(Z_STR_P(offset), idx, ZVAL_LONG(&tmp, idx); offset = &tmp); | |
} | |
} | |
if (Z_TYPE_P(offset) == IS_LONG) { | |
@@ -17911,12 +17912,13 @@ str_index_prop: | |
result = 0; | |
if (UNEXPECTED(Z_TYPE_P(offset) != IS_LONG)) { | |
- if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */ | |
- || (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))) { | |
+ if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */) { | |
ZVAL_DUP(&tmp, offset); | |
convert_to_long(&tmp); | |
offset = &tmp; | |
+ } else if (Z_TYPE_P(offset) == IS_STRING /* or numeric string */) { | |
+ ulong idx; | |
+ ZEND_HANDLE_NUMERIC_STR_EX(Z_STR_P(offset), idx, ZVAL_LONG(&tmp, idx); offset = &tmp); | |
} | |
} | |
if (Z_TYPE_P(offset) == IS_LONG) { | |
@@ -20251,12 +20253,13 @@ str_index_prop: | |
result = 0; | |
if (UNEXPECTED(Z_TYPE_P(offset) != IS_LONG)) { | |
- if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */ | |
- || (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))) { | |
+ if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */) { | |
ZVAL_DUP(&tmp, offset); | |
convert_to_long(&tmp); | |
offset = &tmp; | |
+ } else if (Z_TYPE_P(offset) == IS_STRING /* or numeric string */) { | |
+ ulong idx; | |
+ ZEND_HANDLE_NUMERIC_STR_EX(Z_STR_P(offset), idx, ZVAL_LONG(&tmp, idx); offset = &tmp); | |
} | |
} | |
if (Z_TYPE_P(offset) == IS_LONG) { | |
@@ -23458,12 +23461,13 @@ str_index_prop: | |
result = 0; | |
if (UNEXPECTED(Z_TYPE_P(offset) != IS_LONG)) { | |
- if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */ | |
- || (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))) { | |
+ if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */) { | |
ZVAL_DUP(&tmp, offset); | |
convert_to_long(&tmp); | |
offset = &tmp; | |
+ } else if (Z_TYPE_P(offset) == IS_STRING /* or numeric string */) { | |
+ ulong idx; | |
+ ZEND_HANDLE_NUMERIC_STR_EX(Z_STR_P(offset), idx, ZVAL_LONG(&tmp, idx); offset = &tmp); | |
} | |
} | |
if (Z_TYPE_P(offset) == IS_LONG) { | |
@@ -24910,12 +24914,13 @@ str_index_prop: | |
result = 0; | |
if (UNEXPECTED(Z_TYPE_P(offset) != IS_LONG)) { | |
- if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */ | |
- || (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))) { | |
+ if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */) { | |
ZVAL_DUP(&tmp, offset); | |
convert_to_long(&tmp); | |
offset = &tmp; | |
+ } else if (Z_TYPE_P(offset) == IS_STRING /* or numeric string */) { | |
+ ulong idx; | |
+ ZEND_HANDLE_NUMERIC_STR_EX(Z_STR_P(offset), idx, ZVAL_LONG(&tmp, idx); offset = &tmp); | |
} | |
} | |
if (Z_TYPE_P(offset) == IS_LONG) { | |
@@ -26186,12 +26191,13 @@ str_index_prop: | |
result = 0; | |
if (UNEXPECTED(Z_TYPE_P(offset) != IS_LONG)) { | |
- if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */ | |
- || (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))) { | |
+ if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */) { | |
ZVAL_DUP(&tmp, offset); | |
convert_to_long(&tmp); | |
offset = &tmp; | |
+ } else if (Z_TYPE_P(offset) == IS_STRING /* or numeric string */) { | |
+ ulong idx; | |
+ ZEND_HANDLE_NUMERIC_STR_EX(Z_STR_P(offset), idx, ZVAL_LONG(&tmp, idx); offset = &tmp); | |
} | |
} | |
if (Z_TYPE_P(offset) == IS_LONG) { | |
@@ -27464,12 +27470,13 @@ str_index_prop: | |
result = 0; | |
if (UNEXPECTED(Z_TYPE_P(offset) != IS_LONG)) { | |
- if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */ | |
- || (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))) { | |
+ if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */) { | |
ZVAL_DUP(&tmp, offset); | |
convert_to_long(&tmp); | |
offset = &tmp; | |
+ } else if (Z_TYPE_P(offset) == IS_STRING /* or numeric string */) { | |
+ ulong idx; | |
+ ZEND_HANDLE_NUMERIC_STR_EX(Z_STR_P(offset), idx, ZVAL_LONG(&tmp, idx); offset = &tmp); | |
} | |
} | |
if (Z_TYPE_P(offset) == IS_LONG) { | |
@@ -29251,12 +29258,13 @@ str_index_prop: | |
result = 0; | |
if (UNEXPECTED(Z_TYPE_P(offset) != IS_LONG)) { | |
- if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */ | |
- || (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))) { | |
+ if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */) { | |
ZVAL_DUP(&tmp, offset); | |
convert_to_long(&tmp); | |
offset = &tmp; | |
+ } else if (Z_TYPE_P(offset) == IS_STRING /* or numeric string */) { | |
+ ulong idx; | |
+ ZEND_HANDLE_NUMERIC_STR_EX(Z_STR_P(offset), idx, ZVAL_LONG(&tmp, idx); offset = &tmp); | |
} | |
} | |
if (Z_TYPE_P(offset) == IS_LONG) { | |
@@ -32661,12 +32669,13 @@ str_index_prop: | |
result = 0; | |
if (UNEXPECTED(Z_TYPE_P(offset) != IS_LONG)) { | |
- if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */ | |
- || (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))) { | |
+ if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */) { | |
ZVAL_DUP(&tmp, offset); | |
convert_to_long(&tmp); | |
offset = &tmp; | |
+ } else if (Z_TYPE_P(offset) == IS_STRING /* or numeric string */) { | |
+ ulong idx; | |
+ ZEND_HANDLE_NUMERIC_STR_EX(Z_STR_P(offset), idx, ZVAL_LONG(&tmp, idx); offset = &tmp); | |
} | |
} | |
if (Z_TYPE_P(offset) == IS_LONG) { | |
@@ -34521,12 +34530,13 @@ str_index_prop: | |
result = 0; | |
if (UNEXPECTED(Z_TYPE_P(offset) != IS_LONG)) { | |
- if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */ | |
- || (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))) { | |
+ if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */) { | |
ZVAL_DUP(&tmp, offset); | |
convert_to_long(&tmp); | |
offset = &tmp; | |
+ } else if (Z_TYPE_P(offset) == IS_STRING /* or numeric string */) { | |
+ ulong idx; | |
+ ZEND_HANDLE_NUMERIC_STR_EX(Z_STR_P(offset), idx, ZVAL_LONG(&tmp, idx); offset = &tmp); | |
} | |
} | |
if (Z_TYPE_P(offset) == IS_LONG) { | |
@@ -36743,12 +36753,13 @@ str_index_prop: | |
result = 0; | |
if (UNEXPECTED(Z_TYPE_P(offset) != IS_LONG)) { | |
- if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */ | |
- || (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))) { | |
+ if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */) { | |
ZVAL_DUP(&tmp, offset); | |
convert_to_long(&tmp); | |
offset = &tmp; | |
+ } else if (Z_TYPE_P(offset) == IS_STRING /* or numeric string */) { | |
+ ulong idx; | |
+ ZEND_HANDLE_NUMERIC_STR_EX(Z_STR_P(offset), idx, ZVAL_LONG(&tmp, idx); offset = &tmp); | |
} | |
} | |
if (Z_TYPE_P(offset) == IS_LONG) { | |
@@ -39698,12 +39709,13 @@ str_index_prop: | |
result = 0; | |
if (UNEXPECTED(Z_TYPE_P(offset) != IS_LONG)) { | |
- if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */ | |
- || (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))) { | |
+ if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */) { | |
ZVAL_DUP(&tmp, offset); | |
convert_to_long(&tmp); | |
offset = &tmp; | |
+ } else if (Z_TYPE_P(offset) == IS_STRING /* or numeric string */) { | |
+ ulong idx; | |
+ ZEND_HANDLE_NUMERIC_STR_EX(Z_STR_P(offset), idx, ZVAL_LONG(&tmp, idx); offset = &tmp); | |
} | |
} | |
if (Z_TYPE_P(offset) == IS_LONG) { | |
diff --git a/ext/opcache/Optimizer/zend_optimizer.c b/ext/opcache/Optimizer/zend_optimizer.c | |
index 0c68cc1..1da574d 100644 | |
--- a/ext/opcache/Optimizer/zend_optimizer.c | |
+++ b/ext/opcache/Optimizer/zend_optimizer.c | |
@@ -299,7 +299,7 @@ check_numeric: | |
ulong index; | |
int numeric = 0; | |
- ZEND_HANDLE_NUMERIC_EX(Z_STRVAL_P(val), Z_STRLEN_P(val)+1, index, numeric = 1); | |
+ ZEND_HANDLE_NUMERIC_STR_EX(Z_STR_P(val), index, numeric = 1); | |
if (numeric) { | |
zval_dtor(val); | |
ZVAL_LONG(val, index); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment