Commit Graph

424 Commits

Author SHA1 Message Date
Nikita Popov
6a9127c100 Assert that HT entries using add_new APIs are really new 2019-07-04 17:12:55 +02:00
Nikita Popov
51fb8dc422 Add specialized pair construction API
Closes GH-3990.
2019-06-11 12:29:55 +02:00
Sebastian Pop
6fad150cfd [AArch64] Use NEON to initialize zend_hash
On A72, google-benchmark measure before and after the patch:
--------------------------------------------------------------
Benchmark                    Time             CPU   Iterations
--------------------------------------------------------------
BM_hash_init_before       43.6 ns         43.6 ns     16052937
BM_hash_init_after        27.0 ns         27.0 ns     25877296

Patch written by Ali Saidi <alisaidi@amazon.com>
and Sebastian Pop <spop@amazon.com>
2019-05-07 16:21:44 +02:00
Nikita Popov
bd6ebf40b2 Don't overwrite iterator count during real init 2019-04-16 12:21:20 +02:00
Nikita Popov
2bdd212887 Merge branch 'PHP-7.3' into PHP-7.4 2019-04-16 12:21:16 +02:00
Nikita Popov
f9a755d0d2 Fix HT flags copying wrt iterator count
HT_FLAGS() includes the full flag word, including the iterator
count. When we're fully reassigning it, we need to make sure that
we either really do want to copy the iterator count (as in some
cases in array.c) or we need to mask only the actual flag byte.

Add an assert to hash_iterators_del() to make sure the iterator
count is non-zero (which is how I ran into this) and make sure that
the iterator count is correctly preserved during array splicing.
2019-04-16 12:14:45 +02:00
Nikita Popov
32fb2d9343 Merge branch 'PHP-7.3' into PHP-7.4 2019-04-16 10:39:48 +02:00
Nikita Popov
9a9eed472b Fix second part of bug #77903
When a HT iterator is one past the end and we rehash, we need to make
sure that it is move to the new one past the end position, to make
sure that newly inserted elements are picked up.
2019-04-16 10:38:20 +02:00
Nikita Popov
e1b4cabbd6 Partial fix for bug #77903
In the hash position APIs, make sure we always advance to the next
non-undef element and not just when the position is 0 (similar to
what foreach does). This can happen when the position of an
ArrayIterator is one past its current end and a new element is
inserted not directly at that position because the array is packed.

There is still a bug here (as shown in the tests), but this is a
separate issue that also affects plain array iteration in foreach.
2019-04-16 10:23:11 +02:00
Nikita Popov
2191eac3b3 Merge branch 'PHP-7.3' into PHP-7.4 2019-04-10 12:23:01 +02:00
Nikita Popov
6615b9c287 Merge branch 'PHP-7.2' into PHP-7.3 2019-04-10 12:22:34 +02:00
Nikita Popov
c7a86a38a3 Fix pgsql use after free trying to reuse closed connection
When a connection is closed, we also need to remove the hash entry
from the regular_list, as it now points to freed memory. To do this
store a reverse mapping from the connection to the hash string.

It would be nicer to introduce a wrapping structure for the pgsql
link resource that could store the hash (and notices), but that would
require large changes to the extension, so I'm going for a more
minimal fix here.
2019-04-10 12:18:57 +02:00
Peter Kokot
92ac598aab Remove local variables
This patch removes the so called local variables defined per
file basis for certain editors to properly show tab width, and
similar settings. These are mainly used by Vim and Emacs editors
yet with recent changes the once working definitions don't work
anymore in Vim without custom plugins or additional configuration.
Neither are these settings synced across the PHP code base.

A simpler and better approach is EditorConfig and fixing code
using some code style fixing tools in the future instead.

This patch also removes the so called modelines for Vim. Modelines
allow Vim editor specifically to set some editor configuration such as
syntax highlighting, indentation style and tab width to be set in the
first line or the last 5 lines per file basis. Since the php test
files have syntax highlighting already set in most editors properly and
EditorConfig takes care of the indentation settings, this patch removes
these as well for the Vim 6.0 and newer versions.

With the removal of local variables for certain editors such as
Emacs and Vim, the footer is also probably not needed anymore when
creating extensions using ext_skel.php script.

Additionally, Vim modelines for setting php syntax and some editor
settings has been removed from some *.phpt files.  All these are
mostly not relevant for phpt files neither work properly in the
middle of the file.
2019-02-03 21:03:00 +01:00
Zeev Suraski
a81202ac49 Adios, yearly copyright ranges 2019-01-30 11:48:28 +01:00
Dmitry Stogov
76d8f3923e Revert HASH_FLAG_INITIALIZED into HASH_FLAG_UNINITIALIZED. 2018-12-28 11:22:18 +03:00
Dmitry Stogov
d6f4652255 Added specialized code for small arrays 2018-12-20 17:55:01 +03:00
Dmitry Stogov
dddf3c501e Added specialized code for small arrays 2018-12-19 17:40:34 +03:00
Zeev Suraski
9afce019e0 Future-proof email addresses 2018-11-01 18:35:32 +02:00
Zeev Suraski
54dc07f3dc Update email addresses. We're still @Zend, but future proofing it... 2018-11-01 17:20:07 +02:00
Pedro Magalhães
c2c202193a Use HT_MIN_SIZE when duplicating an empty array 2018-10-05 12:14:42 +02:00
Dmitry Stogov
27b0fecd2e Turn zend_hash_exists() into inline function 2018-09-19 13:55:53 +03:00
Nikita Popov
dfa166e7ed Remove unused ZEND_FILE_LINE in i_zval_ptr_dtor 2018-09-16 17:16:26 +02:00
Dmitry Stogov
7eb255e9db Merge branch 'PHP-7.3'
* PHP-7.3:
  Fixed bug #76800 (foreach inconsistent if array modified during loop)
2018-09-14 10:33:32 +03:00
Dmitry Stogov
17c7b71057 Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  Fixed bug #76800 (foreach inconsistent if array modified during loop)
2018-09-14 10:32:31 +03:00
Dmitry Stogov
3bc4a63fc2 Fixed bug #76800 (foreach inconsistent if array modified during loop) 2018-09-14 10:28:31 +03:00
Dmitry Stogov
437e91e194 Keep collision list ordered from higher to lower buckets. 2018-09-04 01:19:07 +03:00
Dmitry Stogov
cd9f0a22fc Perform run-time binding reusing HashTable bucket (without new bucket insertion). 2018-08-29 00:35:07 +03:00
Dmitry Stogov
5674cf888d Use better macros 2018-07-30 16:48:34 +03:00
Dmitry Stogov
909f943fe5 Loop optimization 2018-07-30 16:08:45 +03:00
Peter Kokot
8d3f8ca12a Remove unused Git attributes ident
The $Id$ keywords were used in Subversion where they can be substituted
with filename, last revision number change, last changed date, and last
user who changed it.

In Git this functionality is different and can be done with Git attribute
ident. These need to be defined manually for each file in the
.gitattributes file and are afterwards replaced with 40-character
hexadecimal blob object name which is based only on the particular file
contents.

This patch simplifies handling of $Id$ keywords by removing them since
they are not used anymore.
2018-07-25 00:53:25 +02:00
Dmitry Stogov
ebd1f5af3e API cleanup.
Removed useless filename and lineno arguments, used in DEBUG build.
The patch doesn't break source compatibility of public API (only binary compatibility).
2018-07-23 15:24:07 +03:00
Dmitry Stogov
3b6e1ee4ee Improved "Fast Shutdown". 2018-07-17 17:31:04 +03:00
Dmitry Stogov
0b90cf85a6 Removed "dead" code (zend_hash_update() never fails) 2018-06-01 11:58:57 +03:00
Dmitry Stogov
0d72bb8fcb Optimize zend_new_array() for special case, when size <= HT_MIN_SIZE 2018-05-31 01:17:55 +03:00
Dmitry Stogov
37069d7d2f Replace unused generic zend_hash_*add_or_update() functions by compact implmentations. 2018-05-29 01:38:27 +03:00
Dmitry Stogov
f4b7239cae _zend_hash_index_add_or_update_i() optimization 2018-05-29 00:09:49 +03:00
Dmitry Stogov
5eb1f92f31 Use zend_string_release_ex() instread of zend_string_release() in places, where we sure about string persistence. 2018-05-28 16:27:12 +03:00
Xinchen Hui
a48ade17db Cleanup 2018-05-08 17:32:35 +08:00
Dmitry Stogov
a0e4488ec7 Optimize zend_hash_find() for the most usual case 2018-05-07 15:18:02 +03:00
Dmitry Stogov
34ed8e53fe Changed worst HashTable load factor from 1.0 to 0.5 2018-05-04 02:41:35 +03:00
Dmitry Stogov
dc091870ea Prefer reloading key->h 2018-04-02 23:43:37 +03:00
Dmitry Stogov
a795bd8265 Optimize zend_hash_real_init() 2018-03-23 00:13:45 +03:00
Dmitry Stogov
8598240c69 Fixed a behavior break introduced by d7f2dc4ec6 2018-03-22 16:37:34 +03:00
Dmitry Stogov
d7f2dc4ec6 Improve HashTable iterators handling:
- Avoid iterators check/update on each HashTable update opration
- Keep position equal (or above) nNumUsed instead of HT_INVALID_IDX
- Fixed iterators handling in array_unshift()
2018-03-22 02:41:49 +03:00
Dmitry Stogov
feb22b24cf Micro optimization 2018-03-21 12:39:56 +03:00
Dmitry Stogov
28ab2060ee Micro optimization 2018-03-21 11:57:54 +03:00
Dmitry Stogov
47f5f87826 Merge branch 'PHP-7.2'
* PHP-7.2:
  Don't keep HashTable.pDestructor in SHM and always set it into ZVAL_PTR_DTOR in zval_array_dup(). Keeping pointer to a function in SHM is not safe because of ASLR.
2018-03-06 01:02:31 +03:00
Dmitry Stogov
b48d2f6d10 Merge branch 'PHP-7.1' into PHP-7.2
* PHP-7.1:
  Don't keep HashTable.pDestructor in SHM and always set it into ZVAL_PTR_DTOR in zval_array_dup(). Keeping pointer to a function in SHM is not safe because of ASLR.
2018-03-06 01:00:14 +03:00
Dmitry Stogov
b711a96acb Don't keep HashTable.pDestructor in SHM and always set it into ZVAL_PTR_DTOR in zval_array_dup().
Keeping pointer to a function in SHM is not safe because of ASLR.
2018-03-06 00:56:16 +03:00
Dmitry Stogov
baa9890112 Completely hide GC implementation details into zend_gc.c 2018-02-27 21:08:26 +03:00