Skip to content

Commit d8099d0

Browse files
committed
Changed data layout to allow more efficient operations
1 parent 3b25faa commit d8099d0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+454
-417
lines changed

Zend/zend.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -351,22 +351,22 @@ void zend_error_noreturn(int type, const char *format, ...) __attribute__ ((nore
351351

352352
static zend_always_inline zend_uint zval_refcount_p(zval* pz) {
353353
ZEND_ASSERT(Z_REFCOUNTED_P(pz));
354-
return Z_COUNTED_P(pz)->refcount;
354+
return GC_REFCOUNT(Z_COUNTED_P(pz));
355355
}
356356

357357
static zend_always_inline zend_uint zval_set_refcount_p(zval* pz, zend_uint rc) {
358358
ZEND_ASSERT(Z_REFCOUNTED_P(pz));
359-
return Z_COUNTED_P(pz)->refcount = rc;
359+
return GC_REFCOUNT(Z_COUNTED_P(pz)) = rc;
360360
}
361361

362362
static zend_always_inline zend_uint zval_addref_p(zval* pz) {
363363
ZEND_ASSERT(Z_REFCOUNTED_P(pz));
364-
return ++Z_COUNTED_P(pz)->refcount;
364+
return ++GC_REFCOUNT(Z_COUNTED_P(pz));
365365
}
366366

367367
static zend_always_inline zend_uint zval_delref_p(zval* pz) {
368368
ZEND_ASSERT(Z_REFCOUNTED_P(pz));
369-
return --Z_COUNTED_P(pz)->refcount;
369+
return --GC_REFCOUNT(Z_COUNTED_P(pz));
370370
}
371371

372372
/* excpt.h on Digital Unix 4.0 defines function_table */

Zend/zend_compile.c

+8-8
Original file line numberDiff line numberDiff line change
@@ -1911,8 +1911,8 @@ void zend_do_receive_param(zend_uchar op, znode *varname, const znode *initializ
19111911
if (class_type->op_type != IS_UNUSED) {
19121912
cur_arg_info->allow_null = 0;
19131913

1914-
if (class_type->u.constant.type != IS_NULL) {
1915-
if (class_type->u.constant.type == IS_ARRAY) {
1914+
if (Z_TYPE(class_type->u.constant) != IS_NULL) {
1915+
if (Z_TYPE(class_type->u.constant) == IS_ARRAY) {
19161916
cur_arg_info->type_hint = IS_ARRAY;
19171917
if (op == ZEND_RECV_INIT) {
19181918
if (Z_TYPE(initialization->u.constant) == IS_NULL || (Z_TYPE(initialization->u.constant) == IS_CONSTANT && !strcasecmp(Z_STRVAL(initialization->u.constant), "NULL")) || Z_TYPE(initialization->u.constant) == IS_CONSTANT_AST) {
@@ -1921,7 +1921,7 @@ void zend_do_receive_param(zend_uchar op, znode *varname, const znode *initializ
19211921
zend_error_noreturn(E_COMPILE_ERROR, "Default value for parameters with array type hint can only be an array or NULL");
19221922
}
19231923
}
1924-
} else if (class_type->u.constant.type == IS_CALLABLE) {
1924+
} else if (Z_TYPE(class_type->u.constant) == IS_CALLABLE) {
19251925
cur_arg_info->type_hint = IS_CALLABLE;
19261926
if (op == ZEND_RECV_INIT) {
19271927
if (Z_TYPE(initialization->u.constant) == IS_NULL || (Z_TYPE(initialization->u.constant) == IS_CONSTANT && !strcasecmp(Z_STRVAL(initialization->u.constant), "NULL")) || Z_TYPE(initialization->u.constant) == IS_CONSTANT_AST) {
@@ -5700,7 +5700,7 @@ void zend_do_fetch_constant(znode *result, znode *constant_container, znode *con
57005700
}
57015701
zend_do_build_full_name(NULL, constant_container, constant_name, 1 TSRMLS_CC);
57025702
*result = *constant_container;
5703-
result->u.constant.type = IS_CONSTANT | fetch_type;
5703+
Z_TYPE(result->u.constant) = IS_CONSTANT | fetch_type;
57045704
break;
57055705
case ZEND_RT:
57065706
if (constant_container->op_type == IS_CONST &&
@@ -5750,7 +5750,7 @@ void zend_do_fetch_constant(znode *result, znode *constant_container, znode *con
57505750
}
57515751

57525752
*result = *constant_name;
5753-
result->u.constant.type = IS_CONSTANT | fetch_type;
5753+
Z_TYPE(result->u.constant) = IS_CONSTANT | fetch_type;
57545754
break;
57555755
case ZEND_RT:
57565756
compound = memchr(Z_STRVAL(constant_name->u.constant), '\\', Z_STRLEN(constant_name->u.constant));
@@ -5900,9 +5900,9 @@ void zend_do_add_static_array_element(znode *result, znode *offset, const znode
59005900
switch (Z_TYPE(offset->u.constant) & IS_CONSTANT_TYPE_MASK) {
59015901
case IS_CONSTANT:
59025902
//??? /* Ugly hack to denote that this value has a constant index */
5903-
Z_STR(offset->u.constant)->gc.u.v.flags |= IS_STR_CONSTANT;
5903+
Z_GC_FLAGS(offset->u.constant) |= IS_STR_CONSTANT;
59045904
if (Z_TYPE(offset->u.constant) & IS_CONSTANT_UNQUALIFIED) {
5905-
Z_STR(offset->u.constant)->gc.u.v.flags |= IS_STR_CONSTANT_UNQUALIFIED;
5905+
Z_GC_FLAGS(offset->u.constant) |= IS_STR_CONSTANT_UNQUALIFIED;
59065906
}
59075907
//??? Z_TYPE(element) |= IS_CONSTANT_INDEX;
59085908
//??? Z_STRVAL(offset->u.constant) = erealloc(Z_STRVAL(offset->u.constant), Z_STRLEN(offset->u.constant)+3);
@@ -5917,7 +5917,7 @@ void zend_do_add_static_array_element(znode *result, znode *offset, const znode
59175917
//??? int len = sizeof(zend_ast *);
59185918
//??? Z_TYPE(element) |= IS_CONSTANT_INDEX;
59195919
key = STR_INIT((char*)&Z_AST(offset->u.constant), sizeof(zend_ast*), 0);
5920-
key->gc.u.v.flags |= IS_STR_AST;
5920+
GC_FLAGS(key) |= IS_STR_AST;
59215921
//??? key[len] = Z_TYPE(offset->u.constant);
59225922
//??? key[len + 1] = 0;
59235923
zend_symtable_update(Z_ARRVAL(result->u.constant), key, &element);

Zend/zend_exceptions.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ void zend_exception_set_previous(zend_object *exception, zend_object *add_previo
5252
previous = zend_read_property(default_exception_ce, pzv, "previous", sizeof("previous")-1, 1 TSRMLS_CC);
5353
if (Z_TYPE_P(previous) == IS_NULL) {
5454
zend_update_property(default_exception_ce, pzv, "previous", sizeof("previous")-1, &tmp TSRMLS_CC);
55-
add_previous->gc.refcount--;
55+
GC_REFCOUNT(add_previous)--;
5656
return;
5757
}
5858
pzv = previous;

Zend/zend_execute.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,7 @@ static inline zval *zend_fetch_dimension_address_inner(HashTable *ht, const zval
953953
zend_string *offset_key;
954954
ulong hval;
955955

956-
switch (dim->type) {
956+
switch (Z_TYPE_P(dim)) {
957957
case IS_NULL:
958958
offset_key = STR_EMPTY_ALLOC();
959959
goto fetch_string_dim;

Zend/zend_execute_API.c

+8-8
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ ZEND_API int zval_update_constant_ex(zval *p, void *arg, zend_class_entry *scope
561561
save = NULL;
562562
}
563563
zend_error(E_NOTICE, "Use of undefined constant %s - assumed '%s'", actual, actual);
564-
p->type = IS_STRING;
564+
Z_TYPE_P(p) = IS_STRING;
565565
if (!inline_change) {
566566
ZVAL_STRINGL(p, actual, actual_len);
567567
} else if (save && save->val != actual) {
@@ -600,19 +600,19 @@ ZEND_API int zval_update_constant_ex(zval *p, void *arg, zend_class_entry *scope
600600
zend_hash_move_forward(Z_ARRVAL_P(p));
601601
continue;
602602
}
603-
if (!(str_index->gc.u.v.flags & (IS_STR_CONSTANT | IS_STR_AST))) {
603+
if (!(GC_FLAGS(str_index) & (IS_STR_CONSTANT | IS_STR_AST))) {
604604
zend_hash_move_forward(Z_ARRVAL_P(p));
605605
continue;
606606
}
607607

608-
if (str_index->gc.u.v.flags & IS_STR_AST) {
608+
if (GC_FLAGS(str_index) & IS_STR_AST) {
609609
zend_ast_ref *ast = *(zend_ast_ref **)str_index->val;
610610

611611
zend_ast_evaluate(&const_value, ast->ast, scope TSRMLS_CC);
612612
zend_ast_destroy(ast->ast);
613613
efree(ast);
614614
//???
615-
} else if (!zend_get_constant_ex(str_index->val, str_index->len, &const_value, scope, str_index->gc.u.v.flags & ~(IS_STR_PERSISTENT | IS_STR_INTERNED |IS_STR_PERMANENT) TSRMLS_CC)) {
615+
} else if (!zend_get_constant_ex(str_index->val, str_index->len, &const_value, scope, GC_FLAGS(str_index) & ~(IS_STR_PERSISTENT | IS_STR_INTERNED |IS_STR_PERMANENT) TSRMLS_CC)) {
616616
char *actual, *str;
617617
const char *save = str_index->val;
618618
int len;
@@ -624,7 +624,7 @@ ZEND_API int zval_update_constant_ex(zval *p, void *arg, zend_class_entry *scope
624624
len -= ((colon - str) + 1);
625625
str = colon;
626626
} else {
627-
if (str_index->gc.u.v.flags & IS_STR_CONSTANT_UNQUALIFIED) {
627+
if (GC_FLAGS(str_index) & IS_STR_CONSTANT_UNQUALIFIED) {
628628
if ((actual = (char *)zend_memrchr(str, '\\', len))) {
629629
actual++;
630630
len -= (actual - str);
@@ -638,7 +638,7 @@ ZEND_API int zval_update_constant_ex(zval *p, void *arg, zend_class_entry *scope
638638
if (save[0] == '\\') {
639639
++save;
640640
}
641-
if (!(str_index->gc.u.v.flags & IS_STR_CONSTANT_UNQUALIFIED)) {
641+
if (!(GC_FLAGS(str_index) & IS_STR_CONSTANT_UNQUALIFIED)) {
642642
zend_error(E_ERROR, "Undefined constant '%s'", save);
643643
}
644644
zend_error(E_NOTICE, "Use of undefined constant %s - assumed '%s'", str, str);
@@ -1687,8 +1687,8 @@ ZEND_API void zend_rebuild_symbol_table(TSRMLS_D) /* {{{ */
16871687
EG(active_symbol_table) = *(EG(symtable_cache_ptr)--);
16881688
} else {
16891689
EG(active_symbol_table) = emalloc(sizeof(zend_array));
1690-
EG(active_symbol_table)->gc.refcount = 0;
1691-
EG(active_symbol_table)->gc.u.v.type = IS_ARRAY;
1690+
GC_REFCOUNT(EG(active_symbol_table)) = 0;
1691+
GC_TYPE_INFO(EG(active_symbol_table)) = IS_ARRAY;
16921692
zend_hash_init(&EG(active_symbol_table)->ht, ex->op_array->last_var, NULL, ZVAL_PTR_DTOR, 0);
16931693
/*printf("Cache miss! Initialized %x\n", EG(active_symbol_table));*/
16941694
}

0 commit comments

Comments
 (0)