History log of /php-src/Zend/zend_weakrefs.c (Results 1 – 25 of 57)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 1d94fb86 14-Oct-2024 Arnaud Le Blanc

Fix handling of invalid iterator in zend_weakmap_iterator_get_current_key()

Fixes GH-16371
Closes GH-16436


# 3401d557 14-Oct-2024 Tim Düsterhus

zend_weakrefs: Add `zend_weakrefs_hash_(clean|destroy)()` (#16439)

These are equivalent to `zend_hash_clean()` and `zend_hash_destroy()`
respectively, but take care of correctly unregist

zend_weakrefs: Add `zend_weakrefs_hash_(clean|destroy)()` (#16439)

These are equivalent to `zend_hash_clean()` and `zend_hash_destroy()`
respectively, but take care of correctly unregistering the weak references to
the keys.

This addition rounds off the weakmap functionality added in
471102edcd19c79be2541188ae8a211a2cbc85bb by taking one possible footgun away
from the user.

show more ...


# c588db1e 18-Jun-2024 Máté Kocsis

Use RETURN_THROWS() for WeakMap methods


# c461b600 24-May-2024 Levi Morrison

refactor: change `zend_is_true` to return `bool` (#14301)

Previously this returned `int`. Many functions actually take advantage
of the fact this returns exactly 0 or 1. For instance,

refactor: change `zend_is_true` to return `bool` (#14301)

Previously this returned `int`. Many functions actually take advantage
of the fact this returns exactly 0 or 1. For instance,
`main/streams/xp_socket.c` does:

sockopts |= STREAM_SOCKOP_IPV6_V6ONLY_ENABLED * zend_is_true(tmpzval);

And `Zend/zend_compile.c` does:

child = &ast->child[2 - zend_is_true(zend_ast_get_zval(ast->child[0]))];

I changed a few places trivially from `int` to `bool`, but there are
still many places such as the object handlers which return `int` that
should eventually be `bool`.

show more ...


# 8e62e2b8 22-May-2024 Cristian Rodríguez

Mark multple functions as static (#13864)

* Mark many functions as static

Multiple functions are missing the static qualifier.

* remove unused struct sigactions

st

Mark multple functions as static (#13864)

* Mark many functions as static

Multiple functions are missing the static qualifier.

* remove unused struct sigactions

struct sigaction act, old_term, old_quit, old_int;
all unused.

* optimizer: minXOR and maxXOR are unused

show more ...


# 700fbca5 08-Mar-2024 Niels Dossche <7771979+nielsdos@users.noreply.github.com>

Change getThis() into ZEND_THIS where possible (#13641)


# d6d33700 08-Mar-2024 Niels Dossche <7771979+nielsdos@users.noreply.github.com>

Implement GH-13609: Dump wrapped object in WeakReference class (#13621)

I chose "object" as that's also the argument name in WeakReference::create.


# 97267215 10-Jan-2024 David CARLIER

general signatures discrepencies fixes (#13122)


# cbf67e4f 16-Jul-2023 Arnaud Le Blanc

Remove WeakMap entries whose key is only reachable through the entry value (#10932)


# bf1cfc07 16-Jan-2023 Christoph M. Becker

Revert GH-10300

Cf. <https://github.com/php/php-src/pull/10220#issuecomment-1383739816>.

This reverts commit 68ada76f9a659745f572539b72afa06fa75a866f.
his reverts commit 45384c6

Revert GH-10300

Cf. <https://github.com/php/php-src/pull/10220#issuecomment-1383739816>.

This reverts commit 68ada76f9a659745f572539b72afa06fa75a866f.
his reverts commit 45384c6e201eda9963e2fcc18946a9446230a2d6.
This reverts commit ef7fbfd71025f034b0bfcb413efd181ce798fc1b.
This reverts commit 9b9ea0d7c696f2990a159b2a2dafbc04547dc10f.
This reverts commit f15747c26be4a2330dc0cf3ea442f53f30f84cac.
This reverts commit e883ba93c40827fafd7868517eb48e04569f76ab.
This reverts commit 7e87551c3775d26e20b06a4032a00053db6452cc.
This reverts commit 921274d2b8966641a00c0a767ae40ba7187bdffc.
This reverts commit fc1f528e5e3ee45ab17ae8dcfad6a6422ff2002d.
This reverts commit 0961715cdafb5d39124667ff94f3b56453ce71f1.
This reverts commit a93f264526e1cdade71d887800c1c448c411bfdc.
This reverts commit 72dd94e1c6d29203b8f6473317f626e6d6d6fbdc.
This reverts commit 29b2dc89645e741f91cc920964432dccd2aaef14.
This reverts commit 05c7653bba7571852f5ce6fc0d220a1a829bc4c0.
This reverts commit 5190e5c260ee05e3f3c3d1168263a1a6637441d0.
This reverts commit 6b55bf228cb2da8705737d414f394950a92d8aae.
This reverts commit 184b4a12d3215d105720d005b31e365249e2eb21.
This reverts commit 4c31b7888a561e920fd3889ba8d99368f3c2d9e6.
This reverts commit d44e9680f080b4918cfed268b96f90ea35975617.
This reverts commit 4069a5c43f419d76e1254c8e49b4cad9968a408f.

show more ...


# a93f2645 04-Jan-2023 Max Kellermann

Zend/zend_weakrefs: include cleanup


# 5a0b68be 14-Sep-2022 Bob Weinand

Revert "Store default object handlers alongside the class entry"

This reverts commit 9e6eab3c139b41dc976dd5305fd1a6e387e5e27f.

Reverted along a01dd9fedaecd2e5b95bc5c2e8d6542116addea

Revert "Store default object handlers alongside the class entry"

This reverts commit 9e6eab3c139b41dc976dd5305fd1a6e387e5e27f.

Reverted along a01dd9fedaecd2e5b95bc5c2e8d6542116addeae.

show more ...


Revision tags: php-8.2.0RC1, php-8.1.10, php-8.0.23, php-8.0.23RC1, php-8.1.10RC1, php-8.2.0beta3, php-8.2.0beta2, php-8.1.9, php-8.0.22
# 9e6eab3c 22-Jul-2022 Bob Weinand

Store default object handlers alongside the class entry

Object handlers being separate from class entries is a legacy inherited from PHP 5. Today it has little benefit to keep them separate:

Store default object handlers alongside the class entry

Object handlers being separate from class entries is a legacy inherited from PHP 5. Today it has little benefit to keep them separate: in fact, accessing object handlers usually requires not-so-safe hacks.
While it is possible to swap handlers in a custom installed create_object handler, this mostly is tedious, as well as it requires allocating the object handlers struct at runtime, possibly caching it etc..

This allows extensions, which intend to observe other classes to install their own class handlers.
The life cycle of internal classes may now be simply observed by swapping the class handlers in post_startup stage.
The life cycle of userland classes may be observed by iterating over the new classes in zend_compile_file and zend_compile_string and then swapping their handlers.

In general, this would also be a first step in directly tying the object handlers to classes. Especially given that I am not aware of any case where the object handlers would be different between various instances of a given class.

Signed-off-by: Bob Weinand <bobwei9@hotmail.com>

show more ...


Revision tags: php-8.1.9RC1, php-8.2.0beta1, php-8.0.22RC1
# 45529412 15-Jul-2022 Arnaud Le Blanc

Merge branch 'PHP-8.1'

* PHP-8.1:
[ci skip] NEWS
Fix `WeakMap` object reference offset causing `TypeError` (#8995)


# aadb24e8 15-Jul-2022 Arnaud Le Blanc

Merge branch 'PHP-8.0' into PHP-8.1


# ede92a86 15-Jul-2022 Tobias Bachert

Fix `WeakMap` object reference offset causing `TypeError` (#8995)

Revision tags: php-8.0.21, php-8.1.8, php-8.2.0alpha3
# 3b92a966 25-Jun-2022 Ilija Tovilo

Convert return type of various object handlers from int to zend_result (#8755)

Revision tags: php-8.1.8RC1, php-8.2.0alpha2, php-8.0.21RC1, php-8.0.20, php-8.1.7, php-8.2.0alpha1, php-7.4.30, php-8.1.7RC1, php-8.0.20RC1, php-8.1.6, php-8.0.19, php-8.1.6RC1, php-8.0.19RC1, php-8.0.18, php-8.1.5, php-7.4.29, php-8.1.5RC1, php-8.0.18RC1, php-8.1.4, php-8.0.17, php-8.1.4RC1, php-8.0.17RC1, php-8.1.3, php-8.0.16, php-7.4.28, php-8.1.3RC1, php-8.0.16RC1, php-8.1.2, php-8.0.15, php-8.1.2RC1, php-8.0.15RC1, php-8.0.14, php-8.1.1, php-7.4.27, php-8.1.1RC1, php-8.0.14RC1, php-7.4.27RC1
# 7504cf18 28-Nov-2021 Tyson Andre

Improve performance of WeakReference/WeakMap. Avoid hash collisions on pointers. (#7690)

Shift pointers by ZEND_MM_ALIGNMENT_LOG2
to avoid the noticeable performance degradation caused b

Improve performance of WeakReference/WeakMap. Avoid hash collisions on pointers. (#7690)

Shift pointers by ZEND_MM_ALIGNMENT_LOG2
to avoid the noticeable performance degradation caused by hash table collisions.
in `EG(weakrefs)` and zend_weakmap->ht

On 64-bit platforms, pointers are usually aligned to at least 8 bytes,
so only one in 8 hash buckets were actually getting used.
(With the metadata needed to track allocations,
alignment might be at least 16 bytes in practice)

Address review comments, add optimization

Make it public for any extensions that need to work with EG(weakrefs)
for instrumentation, debugging, etc. (e.g. zend_test)

PHP 8.1 and previous releases would use the raw pointer value as a hash key instead.

show more ...

Revision tags: php-8.1.0
# 2611e4bc 20-Nov-2021 Tyson Andre

Optimize the destructor of WeakMap for large WeakMaps

Postpone calling any destructors of entries within the weak map
itself until after the singleton `EG(weakmap)` is updated to remove

Optimize the destructor of WeakMap for large WeakMaps

Postpone calling any destructors of entries within the weak map
itself until after the singleton `EG(weakmap)` is updated to remove all
keys in the weak map.

Before, zend_weakref_unregister would do two hash table lookups when freeing an
entry from a WeakMap

- Free from `EG(weakrefs)` if that was the last reference
- zend_weakref_unref_single to remove the entry from the WeakMap itself

After this change, only the first hash table lookup is done.
The freeing of entries from the weak map itself is done sequentially in
`zend_hash_destroy` without hashing or scanning buckets.

It may be a good idea to prevent modification of a WeakMap after the weak map
starts to get freed.

Closes GH-7672

show more ...

# 90c16dba 20-Nov-2021 Tyson Andre

Merge branch 'PHP-8.1'


# e8283ee8 20-Nov-2021 Tyson Andre

Merge branch 'PHP-8.0' into PHP-8.1


# 241bd3f4 20-Nov-2021 Tyson Andre

Fix use after free when WeakMap is modified during field write

(When a value's destructor triggers a resizing or rehashing of the WeakMap)

Closes GH-7671

# b6419f91 20-Nov-2021 Tyson Andre

Micro-optimizations for WeakMap

Skip WeakMap lookup check used only for debug assertion in non-debug builds

Use the `zend_hash_lookup` helper to optimize adding a WeakMap entry

Micro-optimizations for WeakMap

Skip WeakMap lookup check used only for debug assertion in non-debug builds

Use the `zend_hash_lookup` helper to optimize adding a WeakMap entry
if the entry doesn't already exist.

Closes GH-7670

show more ...

Revision tags: php-8.0.13, php-7.4.26, php-7.3.33, php-8.1.0RC6
# 90b7bde6 03-Nov-2021 Dmitry Stogov

Use more compact representation for packed arrays.

- for packed arrays we store just an array of zvals without keys.
- the elements of packed array are accessible throuf as ht->arPacked[

Use more compact representation for packed arrays.

- for packed arrays we store just an array of zvals without keys.
- the elements of packed array are accessible throuf as ht->arPacked[i]
instead of ht->arData[i]
- in addition to general ZEND_HASH_FOREACH_* macros, we introduced similar
familied for packed (ZEND_HASH_PACKED_FORECH_*) and real hashes
(ZEND_HASH_MAP_FOREACH_*)
- introduced an additional family of macros to access elements of array
(packed or real hashes) ZEND_ARRAY_ELEMET_SIZE, ZEND_ARRAY_ELEMET_EX,
ZEND_ARRAY_ELEMET, ZEND_ARRAY_NEXT_ELEMENT, ZEND_ARRAY_PREV_ELEMENT
- zend_hash_minmax() prototype was changed to compare only values

Because of smaller data set, this patch may show performance improvement
on some apps and benchmarks that use packed arrays. (~1% on PHP-Parser)

TODO:
- sapi/phpdbg needs special support for packed arrays (WATCH_ON_BUCKET).
- zend_hash_sort_ex() may require converting packed arrays to hash.

show more ...

# 59d43a4f 03-Nov-2021 Nikita Popov

Merge branch 'PHP-8.1'

* PHP-8.1:
Fix WeakReference uniquing is TAG_HT is used


123