History log of /PHP-8.1/Zend/zend_weakrefs.c (Results 1 – 25 of 35)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 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)


Revision tags: php-8.1.7RC1, php-8.1.4RC1, php-8.1.3, php-8.1.2RC1
# 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 ...


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


Revision tags: php-7.3.32
# 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 ...


# 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


# 546e5586 03-Nov-2021 Nikita Popov

Fix WeakReference uniquing is TAG_HT is used


# 471102ed 21-Oct-2021 Bob Weinand

Add ZEND_API for weakmap functionality via zend_weakrefs_hash_add/del

Closes GH-7600.


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


Revision tags: php-7.3.31, php-7.3.30
# 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 ...


Revision tags: php-7.3.29, php-7.3.28
# 84a843df 30-Mar-2021 Dmitry Stogov

Use better function


# 6ce70447 12-Feb-2021 Máté Kocsis

Generate zend class entries based on stubs

Closes GH-6685


Revision tags: php-7.3.27
# 3e01f5af 15-Jan-2021 Nikita Popov

Replace zend_bool uses with bool

We're starting to see a mix between uses of zend_bool and bool.
Replace all usages with the standard bool type everywhere.

Of course, zend_bool

Replace zend_bool uses with bool

We're starting to see a mix between uses of zend_bool and bool.
Replace all usages with the standard bool type everywhere.

Of course, zend_bool is retained as an alias.

show more ...


# dfb9e033 02-Jan-2021 Tyson Andre

Use Z_PARAM_OBJ macros when zval isn't needed

In some cases, like spl_object_id, the code is simpler but equally efficient
after optimizations.

In other cases, like get_mangled_

Use Z_PARAM_OBJ macros when zval isn't needed

In some cases, like spl_object_id, the code is simpler but equally efficient
after optimizations.

In other cases, like get_mangled_object_vars(), the compiler can't infer that
the object in the zval won't change.

Closes GH-6567

show more ...


Revision tags: php-7.3.26, php-7.3.26RC1, php-7.3.25, php-7.3.25RC1, php-7.3.24, php-7.3.24RC1, php-7.3.23, php-7.3.23RC1, php-7.3.22, php-7.3.22RC1
# 1071d857 07-Aug-2020 Sara Golemon

Flesh out HashTable insertion APIs

Fills out the array/object-property insert helpers for zend_array, zend_object, and zend_reference.

This adds the following matrix of 18 APIs

Flesh out HashTable insertion APIs

Fills out the array/object-property insert helpers for zend_array, zend_object, and zend_reference.

This adds the following matrix of 18 APIs
add_next_index_T()
add_index_T()
add_assoc_T()
add_assoc_T_ex()
add_property_T()
add_property_T_ex()

Where T in array, object, reference

Converted internal callsites currently doing an explicit object wrap.

show more ...


# fa8d9b11 28-Aug-2020 George Peter Banyard

Improve type declarations for Zend APIs

Voidification of Zend API which always succeeded
Use bool argument types instead of int for boolean arguments
Use bool return type for functio

Improve type declarations for Zend APIs

Voidification of Zend API which always succeeded
Use bool argument types instead of int for boolean arguments
Use bool return type for functions which return true/false (1/0)
Use zend_result return type for functions which return SUCCESS/FAILURE as they don't follow normal boolean semantics

Closes GH-6002

show more ...


# 614c0b84 27-Aug-2020 Nikita Popov

Allow removing non-existing key from WeakMap

In line with usual PHP semantics. This previously triggered an
assertion failure.


# 0026d8a7 27-Aug-2020 Nikita Popov

Fix use-after-free is WeakMap key and value are the same

Drop the object from the WeakMap as the last step, as this might
end up destroying the object.


Revision tags: php-7.3.21
# 6e92487f 22-Jul-2020 twosee

Fix warnings of strict-prototypes

Closes GH-5887.


Revision tags: php-7.3.21RC1, php-7.3.20, php-7.3.20RC1, php-7.3.19
# d30cd7d7 26-May-2020 Máté Kocsis

Review the usage of apostrophes in error messages

Closes GH-5590


# 312201dc 01-Jul-2020 Nikita Popov

Add get_gc handle for object iterators

Optional handler with the same semantics as the object handler.


Revision tags: php-7.4.7RC1, php-7.3.19RC1, php-7.3.18RC1, php-7.2.30, php-7.3.17, php-7.3.17RC1, php-7.3.18, php-7.3.16, php-7.3.16RC1
# ff19ec2d 26-Feb-2020 Nikita Popov

Introduce InternalIterator

Userland classes that implement Traversable must do so either
through Iterator or IteratorAggregate. The same requirement does
not exist for internal class

Introduce InternalIterator

Userland classes that implement Traversable must do so either
through Iterator or IteratorAggregate. The same requirement does
not exist for internal classes: They can implement the internal
get_iterator mechanism, without exposing either the Iterator or
IteratorAggregate APIs. This makes them usable in get_iterator(),
but incompatible with any Iterator based APIs.

A lot of internal classes do this, because exposing the userland
APIs is simply a lot of work. This patch alleviates this issue by
providing a generic InternalIterator class, which acts as an
adapater between get_iterator and Iterator, and can be easily
used by many internal classes. At the same time, we extend the
requirement that Traversable implies Iterator or IteratorAggregate
to internal classes as well.

Closes GH-5216.

show more ...


12