History log of /PHP-8.2/Zend/zend_weakrefs.c (Results 1 – 25 of 47)
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


# 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 ...

# 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 ...

# 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)

# 3b92a966 25-Jun-2022 Ilija Tovilo

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

# 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 ...

# 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 ...

# 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


# 66c8bf98 03-Nov-2021 Nikita Popov

Merge branch 'PHP-8.0' into PHP-8.1

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


# 546e5586 03-Nov-2021 Nikita Popov

Fix WeakReference uniquing is TAG_HT is used

# d6bf375f 21-Oct-2021 Bob Weinand

Merge branch 'PHP-8.1'


# 51a9c68e 21-Oct-2021 Bob Weinand

Merge branch 'PHP-8.0' into PHP-8.1


# 471102ed 21-Oct-2021 Bob Weinand

Add ZEND_API for weakmap functionality via zend_weakrefs_hash_add/del

Closes GH-7600.

# 86531745 19-Oct-2021 Nikita Popov

Fix nested WeakMap destruction

This undoes the change from a4b209fdcfe799ab97f55c4c9d22d889813fc266
and addresses the original problem by dropping the unrefs during
shutdown. All obj

Fix nested WeakMap destruction

This undoes the change from a4b209fdcfe799ab97f55c4c9d22d889813fc266
and addresses the original problem by dropping the unrefs during
shutdown. All objects should get unref'ed without that, and this
code path should only get hit for dangling references due to
bailout.

Alternatively we'd have to relax some assertions that check that the
object is part of the weakrefs table, which seems worse.

Fixes oss-fuzz #40090.

show more ...

# a4b209fd 08-Oct-2021 Nikita Popov

Make weak ref notify robust against bailout

First drop it from EG(weakrefs), as the weakref_unref operation
may call a destructor, which may bail out.

Fixes oss-fuzz #39718.

# 570d9b63 20-Jul-2021 Joe Watkins

Not serializable flag permeation

# e081db04 12-Jul-2021 Nikita Popov

Don't return embedded HT from WeakMap get_gc() handler

This HT is embedded in the WeakMap and as such musn't be freed by
GC (or otherwise participate in GC). Instead add the values
c

Don't return embedded HT from WeakMap get_gc() handler

This HT is embedded in the WeakMap and as such musn't be freed by
GC (or otherwise participate in GC). Instead add the values
contained in it to the GC buffer.

show more ...

# 84a843df 30-Mar-2021 Dmitry Stogov

Use better function

12