Skip to content

Commit 4ff8ada

Browse files
committed
Build fixes
1 parent 11f39c6 commit 4ff8ada

File tree

6 files changed

+46
-18
lines changed

6 files changed

+46
-18
lines changed

Zend/zend_execute.c

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
+----------------------------------------------------------------------+
1919
*/
2020

21+
#include "zend_portability.h"
2122
#include "zend_types.h"
2223
#define ZEND_INTENSIVE_DEBUGGING 0
2324

@@ -1098,7 +1099,7 @@ static zend_never_inline bool check_property_type_generic(
10981099
}
10991100
#endif
11001101

1101-
static zend_type zend_resolve_generic_type(zend_class_reference *scope, uint32_t param_id) {
1102+
static zend_always_inline zend_type zend_resolve_generic_type(zend_class_reference *scope, uint32_t param_id) {
11021103
if (param_id >= scope->ce->num_bound_generic_args) {
11031104
ZEND_ASSERT(param_id - scope->ce->num_bound_generic_args < scope->args.num_types);
11041105
return scope->args.types[param_id - scope->ce->num_bound_generic_args];
@@ -1222,6 +1223,10 @@ static zend_always_inline bool zend_validate_generic_args(
12221223
# define HAVE_CACHE_SLOT 1
12231224
#endif
12241225

1226+
// TODO: cache_slot may not be worth it since ZSTR_CE_CACHE
1227+
#undef HAVE_CACHE_SLOT
1228+
#define HAVE_CACHE_SLOT 0
1229+
12251230
#define PROGRESS_CACHE_SLOT() if (HAVE_CACHE_SLOT) {cache_slot++;}
12261231

12271232
static zend_always_inline zend_class_entry *zend_fetch_ce_from_cache_slot(
@@ -1305,6 +1310,11 @@ static bool zend_check_intersection_type_from_cache_slot(zend_type_list *interse
13051310
return status;
13061311
}
13071312

1313+
// TODO
1314+
static bool zend_check_type_slow_recursive(
1315+
zend_type *type, zval *arg, zend_reference *ref, void **cache_slot,
1316+
zend_class_entry *scope, bool is_return_type, bool is_internal);
1317+
13081318
static zend_always_inline bool zend_check_type_slow(
13091319
zend_type *type, zval *arg, zend_reference *ref, void **cache_slot,
13101320
zend_class_entry *scope, bool is_return_type, bool is_internal)
@@ -1342,8 +1352,14 @@ static zend_always_inline bool zend_check_type_slow(
13421352
if (ZEND_TYPE_CONTAINS_CODE(real_type, Z_TYPE_P(arg))) {
13431353
return true;
13441354
}
1345-
if (zend_check_type_slow(
1346-
&real_type, arg, ref, /* cache_slot */ NULL, scope, is_return_type, is_internal)) {
1355+
if (ZEND_TYPE_HAS_PNR(real_type) && Z_TYPE_P(arg) == IS_OBJECT) {
1356+
ce = zend_fetch_ce_from_cache_slot(cache_slot, &real_type);
1357+
if (ce && instanceof_function(Z_OBJCE_P(arg), ce)) {
1358+
return true;
1359+
}
1360+
}
1361+
if (zend_check_type_slow_recursive(
1362+
&real_type, arg, ref, cache_slot, scope, is_return_type, is_internal)) {
13471363
return true;
13481364
}
13491365
}
@@ -1368,7 +1384,13 @@ static zend_always_inline bool zend_check_type_slow(
13681384
if (ZEND_TYPE_CONTAINS_CODE(real_type, Z_TYPE_P(arg))) {
13691385
return true;
13701386
}
1371-
if (zend_check_type_slow(
1387+
if (ZEND_TYPE_HAS_PNR(real_type) && Z_TYPE_P(arg) == IS_OBJECT) {
1388+
ce = zend_fetch_ce_from_cache_slot(cache_slot, &real_type);
1389+
if (ce && instanceof_function(Z_OBJCE_P(arg), ce)) {
1390+
return true;
1391+
}
1392+
}
1393+
if (zend_check_type_slow_recursive(
13721394
&real_type, arg, ref, /* cache_slot */ NULL, scope, is_return_type, is_internal)) {
13731395
return true;
13741396
}
@@ -1402,6 +1424,13 @@ static zend_always_inline bool zend_check_type_slow(
14021424
* because this case is already checked at compile-time. */
14031425
}
14041426

1427+
static bool zend_check_type_slow_recursive(
1428+
zend_type *type, zval *arg, zend_reference *ref, void **cache_slot,
1429+
zend_class_entry *scope, bool is_return_type, bool is_internal)
1430+
{
1431+
return zend_check_type_slow(type, arg, ref, cache_slot, scope, is_return_type, is_internal);
1432+
}
1433+
14051434
static zend_always_inline bool zend_check_type(
14061435
zend_type *type, zval *arg, void **cache_slot, zend_class_entry *scope,
14071436
bool is_return_type, bool is_internal)

ext/dom/php_dom.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -342,15 +342,15 @@ zval *dom_write_property(zend_object *object, zend_string *name, zval *value, vo
342342

343343
if (hnd) {
344344
if (!hnd->write_func) {
345-
zend_throw_error(NULL, "Cannot write read-only property %s::$%s", ZSTR_VAL(object->ce->name), ZSTR_VAL(name));
345+
zend_throw_error(NULL, "Cannot write read-only property %s::$%s", ZSTR_VAL(OBJ_NAME(object)), ZSTR_VAL(name));
346346
return &EG(error_zval);
347347
}
348348

349-
zend_property_info *prop = zend_get_property_info(object->ce, name, /* silent */ true);
349+
zend_property_info *prop = zend_get_property_info(OBJ_CE(object), name, /* silent */ true);
350350
if (prop && ZEND_TYPE_IS_SET(prop->type)) {
351351
zval tmp;
352352
ZVAL_COPY(&tmp, value);
353-
if (!zend_verify_property_type(prop, &tmp, ZEND_CALL_USES_STRICT_TYPES(EG(current_execute_data)))) {
353+
if (!zend_verify_property_type(object, prop, &tmp, ZEND_CALL_USES_STRICT_TYPES(EG(current_execute_data)))) {
354354
zval_ptr_dtor(&tmp);
355355
return &EG(error_zval);
356356
}
@@ -510,11 +510,11 @@ static void dom_update_refcount_after_clone(dom_object *original, xmlNodePtr ori
510510
static zend_object *dom_objects_store_clone_obj(zend_object *zobject) /* {{{ */
511511
{
512512
dom_object *intern = php_dom_obj_from_obj(zobject);
513-
dom_object *clone = dom_objects_set_class(intern->std.ce);
513+
dom_object *clone = dom_objects_set_class(OBJ_CE(&intern->std));
514514

515515
clone->std.handlers = dom_get_obj_handlers();
516516

517-
if (instanceof_function(intern->std.ce, dom_node_class_entry)) {
517+
if (instanceof_function(OBJ_CE(&intern->std), dom_node_class_entry)) {
518518
xmlNodePtr node = (xmlNodePtr)dom_object_get_node(intern);
519519
if (node != NULL) {
520520
xmlNodePtr cloned_node = xmlDocCopyNode(node, node->doc, 1);
@@ -534,7 +534,7 @@ static zend_object *dom_objects_store_clone_obj(zend_object *zobject) /* {{{ */
534534
static zend_object *dom_object_namespace_node_clone_obj(zend_object *zobject)
535535
{
536536
dom_object_namespace_node *intern = php_dom_namespace_node_obj_from_obj(zobject);
537-
zend_object *clone = dom_objects_namespace_node_new(intern->dom.std.ce);
537+
zend_object *clone = dom_objects_namespace_node_new(OBJ_CE(&intern->dom.std));
538538
dom_object_namespace_node *clone_intern = php_dom_namespace_node_obj_from_obj(clone);
539539

540540
xmlNodePtr original_node = dom_object_get_node(&intern->dom);
@@ -1087,8 +1087,8 @@ void dom_namednode_iter(dom_object *basenode, int ntype, dom_object *intern, xml
10871087
static void dom_objects_set_class_ex(zend_class_entry *class_type, dom_object *intern)
10881088
{
10891089
zend_class_entry *base_class = class_type;
1090-
while ((base_class->type != ZEND_INTERNAL_CLASS || base_class->info.internal.module->module_number != dom_module_entry.module_number) && base_class->parent != NULL) {
1091-
base_class = base_class->parent;
1090+
while ((base_class->type != ZEND_INTERNAL_CLASS || base_class->info.internal.module->module_number != dom_module_entry.module_number) && base_class->num_parents != 0) {
1091+
base_class = base_class->parents[0]->ce;
10921092
}
10931093

10941094
intern->prop_handler = zend_hash_find_ptr(&classes, base_class->name);

ext/dom/php_dom.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ void dom_mark_namespaces_for_copy_based_on_copy(xmlNodePtr copy, const xmlNode *
194194
#define DOM_GET_INTERN(__id, __intern) { \
195195
__intern = Z_DOMOBJ_P(__id); \
196196
if (UNEXPECTED(__intern->ptr == NULL)) { \
197-
zend_throw_error(NULL, "Couldn't fetch %s", ZSTR_VAL(__intern->std.ce->name));\
197+
zend_throw_error(NULL, "Couldn't fetch %s", ZSTR_VAL(OBJ_NAME(&__intern->std)));\
198198
RETURN_THROWS();\
199199
} \
200200
}

ext/libxml/libxml.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
+----------------------------------------------------------------------+
1616
*/
1717

18+
#include "zend_API.h"
1819
#ifdef HAVE_CONFIG_H
1920
#include "config.h"
2021
#endif
@@ -1258,10 +1259,7 @@ PHP_LIBXML_API xmlNodePtr php_libxml_import_node(zval *object)
12581259
php_libxml_func_handler *export_hnd;
12591260

12601261
if (Z_TYPE_P(object) == IS_OBJECT) {
1261-
ce = Z_OBJCE_P(object);
1262-
while (ce->parent != NULL) {
1263-
ce = ce->parent;
1264-
}
1262+
ce = zend_class_entry_get_root(Z_OBJCE_P(object));
12651263
if ((export_hnd = zend_hash_find_ptr(&php_libxml_exports, ce->name))) {
12661264
node = export_hnd->export_func(object);
12671265
}

ext/standard/var_unserializer.re

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,6 +1184,7 @@ object ":" uiv ":" ["] {
11841184

11851185
do {
11861186
zend_string *lc_name;
1187+
ce = NULL;
11871188

11881189
if (!(*var_hash)->allowed_classes && ZSTR_HAS_CE_CACHE(class_name)) {
11891190
zend_class_reference *class_ref = ZSTR_GET_CE_CACHE(class_name);

ext/tokenizer/tokenizer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ PHP_METHOD(PhpToken, tokenize)
100100
Z_PARAM_LONG(flags)
101101
ZEND_PARSE_PARAMETERS_END();
102102

103-
token_class = zend_get_called_scope(execute_data);
103+
token_class = zend_get_called_scope(execute_data)->ce;
104104

105105
/* Check construction preconditions in advance, so these are not repeated for each token. */
106106
if (token_class->ce_flags & ZEND_ACC_EXPLICIT_ABSTRACT_CLASS) {

0 commit comments

Comments
 (0)