Skip to content

Commit 5a61619

Browse files
committed
Load string once
1 parent 697266a commit 5a61619

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

Zend/zend_vm_def.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7944,35 +7944,35 @@ ZEND_VM_HOT_HANDLER(168, ZEND_BIND_GLOBAL, CV, CONST, CACHE_SLOT)
79447944
{
79457945
USE_OPLINE
79467946
zend_free_op free_op1, free_op2;
7947-
zval *varname;
7947+
zend_string *varname;
79487948
zval *value;
79497949
zval *variable_ptr;
79507950
uintptr_t idx;
79517951
zend_reference *ref;
79527952

79537953
ZEND_VM_REPEATABLE_OPCODE
79547954

7955-
varname = GET_OP2_ZVAL_PTR(BP_VAR_R);
7955+
varname = Z_STR_P(GET_OP2_ZVAL_PTR(BP_VAR_R));
79567956

79577957
/* We store "hash slot index" + 1 (NULL is a mark of uninitialized cache slot) */
79587958
idx = (uintptr_t)CACHED_PTR(opline->extended_value) - 1;
79597959
if (EXPECTED(idx < EG(symbol_table).nNumUsed * sizeof(Bucket))) {
79607960
Bucket *p = (Bucket*)((char*)EG(symbol_table).arData + idx);
79617961

79627962
if (EXPECTED(Z_TYPE(p->val) != IS_UNDEF) &&
7963-
(EXPECTED(p->key == Z_STR_P(varname)) ||
7964-
(EXPECTED(p->h == ZSTR_H(Z_STR_P(varname))) &&
7963+
(EXPECTED(p->key == varname) ||
7964+
(EXPECTED(p->h == ZSTR_H(varname)) &&
79657965
EXPECTED(p->key != NULL) &&
7966-
EXPECTED(zend_string_equal_content(p->key, Z_STR_P(varname)))))) {
7966+
EXPECTED(zend_string_equal_content(p->key, varname))))) {
79677967

79687968
value = (zval*)p; /* value = &p->val; */
79697969
ZEND_VM_C_GOTO(check_indirect);
79707970
}
79717971
}
79727972

7973-
value = zend_hash_find_ex(&EG(symbol_table), Z_STR_P(varname), 1);
7973+
value = zend_hash_find_ex(&EG(symbol_table), varname, 1);
79747974
if (UNEXPECTED(value == NULL)) {
7975-
value = zend_hash_add_new(&EG(symbol_table), Z_STR_P(varname), &EG(uninitialized_zval));
7975+
value = zend_hash_add_new(&EG(symbol_table), varname, &EG(uninitialized_zval));
79767976
idx = (char*)value - (char*)EG(symbol_table).arData;
79777977
/* Store "hash slot index" + 1 (NULL is a mark of uninitialized cache slot) */
79787978
CACHE_PTR(opline->extended_value, (void*)(idx + 1));

Zend/zend_vm_execute.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41487,35 +41487,35 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_BIND_GLOBAL_SPEC_C
4148741487
{
4148841488
USE_OPLINE
4148941489

41490-
zval *varname;
41490+
zend_string *varname;
4149141491
zval *value;
4149241492
zval *variable_ptr;
4149341493
uintptr_t idx;
4149441494
zend_reference *ref;
4149541495

4149641496
ZEND_VM_REPEATABLE_OPCODE
4149741497

41498-
varname = RT_CONSTANT(opline, opline->op2);
41498+
varname = Z_STR_P(RT_CONSTANT(opline, opline->op2));
4149941499

4150041500
/* We store "hash slot index" + 1 (NULL is a mark of uninitialized cache slot) */
4150141501
idx = (uintptr_t)CACHED_PTR(opline->extended_value) - 1;
4150241502
if (EXPECTED(idx < EG(symbol_table).nNumUsed * sizeof(Bucket))) {
4150341503
Bucket *p = (Bucket*)((char*)EG(symbol_table).arData + idx);
4150441504

4150541505
if (EXPECTED(Z_TYPE(p->val) != IS_UNDEF) &&
41506-
(EXPECTED(p->key == Z_STR_P(varname)) ||
41507-
(EXPECTED(p->h == ZSTR_H(Z_STR_P(varname))) &&
41506+
(EXPECTED(p->key == varname) ||
41507+
(EXPECTED(p->h == ZSTR_H(varname)) &&
4150841508
EXPECTED(p->key != NULL) &&
41509-
EXPECTED(zend_string_equal_content(p->key, Z_STR_P(varname)))))) {
41509+
EXPECTED(zend_string_equal_content(p->key, varname))))) {
4151041510

4151141511
value = (zval*)p; /* value = &p->val; */
4151241512
goto check_indirect;
4151341513
}
4151441514
}
4151541515

41516-
value = zend_hash_find_ex(&EG(symbol_table), Z_STR_P(varname), 1);
41516+
value = zend_hash_find_ex(&EG(symbol_table), varname, 1);
4151741517
if (UNEXPECTED(value == NULL)) {
41518-
value = zend_hash_add_new(&EG(symbol_table), Z_STR_P(varname), &EG(uninitialized_zval));
41518+
value = zend_hash_add_new(&EG(symbol_table), varname, &EG(uninitialized_zval));
4151941519
idx = (char*)value - (char*)EG(symbol_table).arData;
4152041520
/* Store "hash slot index" + 1 (NULL is a mark of uninitialized cache slot) */
4152141521
CACHE_PTR(opline->extended_value, (void*)(idx + 1));

0 commit comments

Comments
 (0)