Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
786 changes: 5 additions & 781 deletions NEWS

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions Zend/Optimizer/compact_literals.c
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,12 @@ void zend_optimizer_compact_literals(zend_op_array *op_array, zend_optimizer_ctx
cache_size += 2 * sizeof(void *);
}
break;
case ZEND_CALLABLE_CONVERT:
if (opline->extended_value != (uint32_t)-1) {
opline->extended_value = cache_size;
cache_size += sizeof(void *);
}
break;
}
opline++;
}
Expand Down
8 changes: 8 additions & 0 deletions Zend/tests/closures/fcc-cache.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
--TEST--
FCCs are cached and shared
--FILE--
<?php
var_dump(strlen(...) === strlen(...));
?>
--EXPECT--
bool(true)
6 changes: 3 additions & 3 deletions Zend/tests/exit/exit_as_function.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ foreach ($values as $value) {
}

?>
--EXPECT--
--EXPECTF--
string(4) "exit"
string(3) "die"
object(Closure)#1 (2) {
object(Closure)#%d (2) {
["function"]=>
string(4) "exit"
["parameter"]=>
Expand All @@ -31,7 +31,7 @@ object(Closure)#1 (2) {
string(10) "<optional>"
}
}
object(Closure)#2 (2) {
object(Closure)#%d (2) {
["function"]=>
string(4) "exit"
["parameter"]=>
Expand Down
8 changes: 4 additions & 4 deletions Zend/tests/first_class_callable/constexpr/namespace_004.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ foo();

?>
--EXPECTF--
object(Closure)#1 (2) {
object(Closure)#%d (2) {
["function"]=>
string(6) "strrev"
["parameter"]=>
Expand All @@ -36,7 +36,7 @@ object(Closure)#1 (2) {
}
}
string(3) "cba"
object(Closure)#2 (2) {
object(Closure)#%d (2) {
["function"]=>
string(6) "strrev"
["parameter"]=>
Expand All @@ -46,7 +46,7 @@ object(Closure)#2 (2) {
}
}
string(3) "cba"
object(Closure)#2 (2) {
object(Closure)#%d (2) {
["function"]=>
string(6) "strrev"
["parameter"]=>
Expand All @@ -56,7 +56,7 @@ object(Closure)#2 (2) {
}
}
string(3) "cba"
object(Closure)#1 (2) {
object(Closure)#%d (2) {
["function"]=>
string(6) "strrev"
["parameter"]=>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ var_dump(test1(...));
var_dump(test2(...));

?>
--EXPECT--
object(Closure)#1 (1) {
--EXPECTF--
object(Closure)#%d (1) {
["function"]=>
string(5) "test1"
}
object(Closure)#1 (1) {
object(Closure)#%d (1) {
["function"]=>
string(5) "test2"
}
14 changes: 7 additions & 7 deletions Zend/tests/magic_methods/trampoline_closure_named_arguments.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ var_dump($type);
var_dump($type->getName());

?>
--EXPECT--
--EXPECTF--
-- Non-static cases --
string(4) "test"
array(3) {
Expand All @@ -69,15 +69,15 @@ array(4) {
["a"]=>
int(123)
["b"]=>
object(Test)#1 (0) {
object(Test)#%d (0) {
}
}
string(4) "test"
array(2) {
["a"]=>
int(123)
["b"]=>
object(Test)#1 (0) {
object(Test)#%d (0) {
}
}
string(4) "test"
Expand Down Expand Up @@ -114,15 +114,15 @@ array(4) {
["a"]=>
int(123)
["b"]=>
object(Test)#1 (0) {
object(Test)#%d (0) {
}
}
string(10) "testStatic"
array(2) {
["a"]=>
int(123)
["b"]=>
object(Test)#1 (0) {
object(Test)#%d (0) {
}
}
string(10) "testStatic"
Expand All @@ -136,12 +136,12 @@ array(1) {
-- Reflection tests --
array(1) {
[0]=>
object(ReflectionParameter)#4 (1) {
object(ReflectionParameter)#%d (1) {
["name"]=>
string(9) "arguments"
}
}
bool(true)
object(ReflectionNamedType)#5 (0) {
object(ReflectionNamedType)#%d (0) {
}
string(5) "mixed"
72 changes: 36 additions & 36 deletions Zend/zend_attributes_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Zend/zend_builtin_functions_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion Zend/zend_compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -3965,7 +3965,14 @@ static bool zend_compile_call_common(znode *result, zend_ast *args_ast, zend_fun
opline->op1.num = zend_vm_calc_used_stack(0, fbc);
}

zend_emit_op_tmp(result, ZEND_CALLABLE_CONVERT, NULL, NULL);
zend_op *callable_convert_op = zend_emit_op_tmp(result, ZEND_CALLABLE_CONVERT, NULL, NULL);
if (opline->opcode == ZEND_INIT_FCALL
|| opline->opcode == ZEND_INIT_FCALL_BY_NAME
|| opline->opcode == ZEND_INIT_NS_FCALL_BY_NAME) {
callable_convert_op->extended_value = zend_alloc_cache_slot();
} else {
callable_convert_op->extended_value = (uint32_t)-1;
}
return true;
}

Expand Down
6 changes: 6 additions & 0 deletions Zend/zend_execute_API.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ void init_executor(void) /* {{{ */
zend_fiber_init();
zend_weakrefs_init();

zend_hash_init(&EG(callable_convert_cache), 8, NULL, ZVAL_PTR_DTOR, 0);

EG(active) = 1;
}
/* }}} */
Expand Down Expand Up @@ -420,6 +422,8 @@ ZEND_API void zend_shutdown_executor_values(bool fast_shutdown)
zend_stack_clean(&EG(user_error_handlers), (void (*)(void *))ZVAL_PTR_DTOR, 1);
zend_stack_clean(&EG(user_exception_handlers), (void (*)(void *))ZVAL_PTR_DTOR, 1);

zend_hash_clean(&EG(callable_convert_cache));

#if ZEND_DEBUG
if (!CG(unclean_shutdown)) {
gc_collect_cycles();
Expand Down Expand Up @@ -516,6 +520,8 @@ void shutdown_executor(void) /* {{{ */
if (EG(ht_iterators) != EG(ht_iterators_slots)) {
efree(EG(ht_iterators));
}

zend_hash_destroy(&EG(callable_convert_cache));
}

#if ZEND_DEBUG
Expand Down
2 changes: 2 additions & 0 deletions Zend/zend_globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,8 @@ struct _zend_executor_globals {

zend_strtod_state strtod_state;

HashTable callable_convert_cache;

void *reserved[ZEND_MAX_RESERVED_RESOURCES];
};

Expand Down
Loading