Compare commits

...
2339 Commits
Author SHA1 Message Date
Kamil Tekiela b601acf35e Fix typo, there is no MySQL 8.2.10 2021-06-03 19:02:53 +01:00
Christoph M. Becker 8a8e307cd5 Mark slow tests
Each of these tests took more than ten seconds on a recent AppVeyor CI
run; that appears to qualify them to be marked as slow tests.

Closes GH-7077.
2021-06-03 15:14:08 +02:00
David Carlier 007046fdd0 pcntl_rfork: following-up suggestions.
removing RFMEM constant.
treating beforehand the only case where rfork would return EINVAL.
2021-06-03 15:13:12 +02:00
Dmitry Stogov 643f3c2935 "http://" -> "https://" 2021-06-03 14:27:41 +03:00
Dmitry Stogov c658216425 JIT Refactoring:
- Move duplicate system independent functions from zend_jit_x86.dasc and
  zend_jit_arm64.dasc into zend_jit.c
  * zend_jit_is_constant_cmp_long_long()
  * zend_jit_needs_call_chain()
  * skip_valid_arguments()
  * zend_ssa_cv_info()
  * zend_jit_may_avoid_refcounting()
  * zend_get_known_property_info()
  * zend_may_be_dynamic_property()
- Move common definitions from zend_jit_x86.dasc and
  zend_jit_arm64.dasc into zend_jit.c
  * GCC_GLOBAL_REGS
  * PROFITABILITY_CHECKS
  * BP_JIT_IS
  * sp_adj_kind
  * sp_adj[]
- Remove unused DynAsm macros
  * ADDR_CMP (arm64)
- Inline and remove DynAsm macros used once
  * LOAD_BASE_ADDR (arm64 and x86)
  * PUSH_BASE_ADDR (x86)
  * MEM_OP3_3 (x86)
  * SET_Z_PTR (x86)
- Rename DynAsm macros
  * MEM_LOAD_OP_STORE -> MEM_UPDATE (arm64)
  * MEM_LOAD_OP_STORE_ZTS - > MEM_UPDATE_ZTS (arm64)
  * ADDR_OP1 -> PUSH_ADDR (x86)
  * ADDR_OP2_2 -> ADDR_STORE and ADDR_CMP (x86)
  * MEM_OP2_1_ZTS -> MEM_STORE_ZTS, MEM_CMP_ZTS, MEM_UPDATE_ZTRS (x86)
  * MEM_OP2_2 -> MEM_LOAD and MEM_LOAD_OP (x86)
  * MEM_OP2_2_ZTS -> MEM_LOAD_ZTS and MEM_LOAD_OP_ZTS (x86)
  * SSE_AVX_OP -> DOUBLE_CMP (x86)
  * SSE_GET_LONG -> DOUBLE_GET_LONG (x86)
  * SSE_GET_ZVAL_LVAL -> DOUBLE_GET_ZVAL_LVAL (x86)
  * SSE_GET_ZVAL_LVAL -> DOUBLE_GET_ZVAL_LVAL (x86)
  * SSE_GET_ZVAL_DVAL -> DOUBLE_GET_ZVAL_DVAL (x86)
  * SSE_SET_ZVAL_DVAL -> DOUBLE_SET_ZVAL_DVAL (x86)
2021-06-03 14:05:01 +03:00
Joe Watkins 5c3cb3583b Merge branch 'PHP-8.0'
* PHP-8.0:
  fix bug #72998
2021-06-03 10:34:00 +02:00
Joe Watkins 1143155fcb fix bug #72998
the function fn_complete in libedit null checks matches[2]
2021-06-03 10:33:10 +02:00
Dmitry Stogov 5de50e2817 Separate common code 2021-06-03 00:47:40 +03:00
Christoph M. Becker d5dd9d59ae Speed up test case
This test case did 100,000 includes of a non existing file to show the
memory leak; this is not necessary, because after the first failing
include, memory is not supposed to increase for further includes.

Closes GH-7088.
2021-06-02 23:19:38 +02:00
Ayesh Karunaratne a706d7302a Improve interface non-public method error message
Currently interface methods with visibility `private` or `protected` fail
with an error message:

  Access type for interface method A::b() must be omitted

However, explicitly setting visibility `public` is allowed and often desired.
This commit updates the error message to:

  Access type for interface method A::b() must be public
2021-06-02 20:08:36 +01:00
Hao Sun 467801d7bb JIT/AArch64: Code refactoring for macros (#7082)
* JIT/AArch64: Code refactoring for macros

Update the comments and rename arguments for some macros.

The following macros are renamed:
  SAFE_MEM_ACC_WITH_UOFFSET  -> MEM_ACC_64_WITH_UOFFSET
  SAFE_MEM_ACC_WITH_UOFFSET_32  -> MEM_ACC_32_WITH_UOFFSET
  SAFE_MEM_ACC_WITH_UOFFSET_BYTE -> MEM_ACC_8_WITH_UOFFSET
  MEM_STORE_BYTE_ZTS -> MEM_STORE_8_ZTS
  MEM_STORE_ZTS -> MEM_STORE_64_ZTS
  MEM_LOAD_ZTS -> MEM_LOAD_64_ZTS
  MEM_LOAD_BYTE_ZTS -> MEM_LOAD_8_ZTS
  ADD_IP_FROM_CST -> ADD_IP_WITH_CONST

The following macros are deprecated and removed:
  SET_Z_PTR, GET_Z_W2, SET_Z_W2

Change-Id: I767cf70f373e5f5a1090079e70f8e953a654da00

* Use MEM_ACCESS_*_WITH_UOFFSET

It's more accurate to use "MEM_ACCESS_*_WITH_UOFFSET" than
"MEM_ACC_*_WITH_UOFFSET".

Change-Id: I71479a809008848b61c4786016e6c10110e6aa8b

* Revert the updates for macros ADD_IP_WITH_CONST and LONG_ADD_SUB_WITH_IMM

As pointed by Dmitry, (int32_t) (1LL << 32) would make the assertion
"TRUE", which is not expected by us.

Change-Id: I767cf70f373e5f5a1090079e70f8e953a654da00
2021-06-02 22:32:17 +08:00
Dmitry Stogov 4a095a0252 Resolve CG(map_ptr_base) in disassembler 2021-06-02 15:17:41 +03:00
Nikita Popov 6ecc103439 Merge branch 'PHP-8.0'
* PHP-8.0:
  Try to fix libxml 2.9.12 tests
2021-06-02 12:22:48 +02:00
Nikita Popov 29b083dd0a Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Try to fix libxml 2.9.12 tests
2021-06-02 12:22:36 +02:00
Nikita Popov d818edeae2 Try to fix libxml 2.9.12 tests
The test expectations here were for PHP 8.0, try to adjust them
for PHP 7.4.
2021-06-02 12:21:45 +02:00
Nikita Popov 0aaa862fcf Add test for unsetting ReflectionClassConstant::$name
This test was supposed to be part of 50b4a7adf9.
2021-06-02 12:17:17 +02:00
Nikita Popov 96fe8141c3 Merge branch 'PHP-8.0'
* PHP-8.0:
  Skip test without ZMM
2021-06-01 12:08:04 +02:00
Nikita Popov 59a52d6942 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Skip test without ZMM
2021-06-01 12:07:51 +02:00
Nikita Popov d4f493b0b0 Skip test without ZMM 2021-06-01 12:07:33 +02:00
George Peter BanyardandNikita Popov b6958bb847 Implement "Deprecate implicit non-integer-compatible float to int conversions" RFC. (#6661)
RFC: https://wiki.php.net/rfc/implicit-float-int-deprecate

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
2021-05-31 15:48:45 +01:00
Nikita Popov e006fd4220 Adjust memory limit in one more test 2021-05-31 16:32:43 +02:00
Nikita Popov e9b005158f Fix output buffer discard on memory limit
Move this code directly into the error handler, and check the
heap->overflow flag. Discarding output here allows us to print
the normal memory limit message to standard output. Otherwise
nothing would be printed unless a different log medium was used,
which makes for a suboptimal debugging experience.
2021-05-31 16:30:36 +02:00
Peter van Dommelen 3a4ea6cb91 Don't automatically adjust memory_limit to 2M
As PHP has a minimum memory usage of 2M (size of allocator chunk),
setting a limit below that value is not meaningful and will be
automatically rounded up to the chunk size. Rather than doing this
silently, show the newly introduced error message.

The memory limit had to be increased to 2M for a number of tests.

tests/lang/bug45392 has been marked as XFAIL. This old bugfix is
not working as intended. The memory limit in main's `PG(memory_limit)`
differs from the one in zend_alloc. In zend_alloc the `AG(mm_heap)->limit`
is defined as `max(passed_value, ZEND_MM_CHUNK_SIZE)`. The check made in
an unclean shutdown will never be true unless the memory limit is lower
than ZEND_MM_CHUNK_SIZE, which happened to be the case in the test.
https://bugs.php.net/bug.php?id=45392
https://github.com/php/php-src/commit/fcc0fdd125fdb9e1713f91d027fe07d680a0cf36
2021-05-31 15:42:10 +02:00
Nikita Popov 1aafed5e98 Remove zend_set_memory_limit_ex() API
This was added temporarily for the PHP-8.0 branch to avoid an
ABI break.
2021-05-31 15:27:46 +02:00
Nikita Popov b4559e7ae4 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #81070
2021-05-31 15:24:29 +02:00
Nikita Popov 324ad2f42c Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fixed bug #81070

This is a non-trivial merge. To avoid an ABI break, a new
zend_set_memory_limit_ex() function is added.
2021-05-31 15:24:00 +02:00
Peter van Dommelen 1b3b5c94e5 Fixed bug #81070
When the memory limit is reduced using an `ini_set("memory_limit", ..)`
below the currently allocated memory, the out-of-memory check overflowed.
Instead of implementing additional checks during allocation,
`zend_set_memory_limit()` now validates the new memory limit. When
below the current memory usage the ini_set call will fail and throw
a warning.

This is part of GH-7040.
2021-05-31 15:18:58 +02:00
Nikita Popov 477f4fe67b Skip pcntl_rfork() in arginfo test
Same as pcntl_fork(), we don't want to have this side-effect in
this mass-test.
2021-05-31 14:55:55 +02:00
Nikita Popov 91eb201fd8 Allow initializing assignment to PDOStatement::$queryString
If the object is not created through PDO::prepare(), e.g. in a
mock scenario, it should still be possible to initialize the
$queryString property.

See bug #81084.
2021-05-31 14:54:29 +02:00
Christoph M. Becker 509d34955c Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #76694: native Windows cert verification uses CN as sever name
2021-05-31 14:37:55 +02:00
Christoph M. Becker 108105b2c6 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #76694: native Windows cert verification uses CN as sever name
2021-05-31 14:36:57 +02:00
Christoph M. Becker 7fd48264de Fix #76694: native Windows cert verification uses CN as sever name
This is not guaranteed to work, since the actual server name may only
be given as SAN.  Since we're doing the peer verification later anyway
(using the respective context options as appropriate), there is no need
to even supply a server name when verifying against the Windows cert
store.

Closes GH-7060.
2021-05-31 14:35:17 +02:00
Nikita Popov fa9cb6c314 Fix typo in constant name 2021-05-31 14:33:51 +02:00
Joe Watkins 9c1159a6d6 Merge branch 'master' of github.com:php/php-src
* 'master' of github.com:php/php-src:
  Fix bug #81090 in JIT as well
  Fixed bug #81090
2021-05-31 13:40:21 +02:00
Joe Watkins 660585e25f fix stub for pcntl_rfork 2021-05-31 13:39:49 +02:00
Nikita Popov 445b649228 Fix bug #81090 in JIT as well 2021-05-31 12:39:36 +02:00
Nikita Popov c27dedb0c7 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #81090
2021-05-31 12:34:21 +02:00
Nikita Popov ee74f2e57f Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fixed bug #81090
2021-05-31 12:33:59 +02:00
Nikita Popov 82f6f6da67 Fixed bug #81090
For concatenation, the in-place variant can be much more efficient,
because it will reallocate the string in-place. Special-case the
typed property compound assignment code for the case where we
concatenate to a string, in which case we know that the result
will also be a string, and we don't need the type check anyway.
2021-05-31 12:31:56 +02:00
David Carlier 95a9e558b6 Pull #6989 FreeBSD defines SO_ACCEPTFILTER 2021-05-31 11:40:20 +02:00
Bob Weinand 13d396bb59 Merge branch 'PHP-8.0' 2021-05-31 10:48:11 +02:00
Hao Sun e7be7f3f6c JIT/AArch64: Use ZR directly to zero FP register (#7081)
Zero register, i.e. xzr, can be used directly to zero FP register.

TODO: FMOV from ZR may be slow on some cores and the preferred
instructio is MOVI with immediate zero [1]. However, MOVI is not
recoginized by DynASM/arm64.

[1] https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=523d72071960

Change-Id: I0eaee4445e05adb45c6bb80ddb62ea02cdc9f4db
2021-05-31 16:47:26 +08:00
Bob Weinand 76a4ea5e2a Export ENV in .sh file generated by run-tests 2021-05-31 10:47:14 +02:00
Nikita Popov 27be6670b1 Correctly parse array_slice() argument in call_user_func_array() opt
We should be treating this argument using the normal zpp rules,
rather than performing a simple integer cast.
2021-05-31 10:38:25 +02:00
Nikita Popov 7db146eea7 Remove "inline" defines on Windows (#7071)
Newer MSVC versions support the `inline` keyword, so we do not need to explicitly define it. We also shouldn't define `inline` to `__forceinline`, as we already have `zend_always_inline` to indicate this requirement.
2021-05-31 10:05:18 +02:00
David Carlier 28382aa1ec pcntl: Adding pcntl_rfork support. 2021-05-31 09:19:15 +02:00
David CARLIER 20ef668978 pcntl add darwin specific flags for who/which especially (#7075)
PRIO_DARWIN_BG to be on part with pthread QOS class and
 energy efficiency.
2021-05-31 09:16:46 +02:00
Hao Sun 66826f644d JIT/AArch64: Use D registers for floating-point operations (#7080)
In AArch64, 32 registers, i.e. v0~v31, can be used by the SIMD and
floating-point operations. [1][2]

In PHP the floating-point operations use 64-bit DOUBLE type, and SIMD
operations are not supported currently. Hence we can use D registers
directly.

Note that "ZREG_V*" is kept to denote the register index.

[1]
https://developer.arm.com/documentation/den0024/a/ARMv8-Registers/NEON-and-floating-point-registers/Scalar-register-sizes
[2]
https://github.com/ARM-software/abi-aa/blob/2bcab1e3b22d55170c563c3c7940134089176746/aapcs64/aapcs64.rst#612simd-and-floating-point-registers

Change-Id: I286ce07a49e837b560e3401c742ec91fc561546b
2021-05-31 14:28:33 +08:00
Hao Sun 7c2a3a9400 JIT/AArch64: [macos][ZTS] Support fast path for tlv_get_addr (#7042)
* JIT/AArch64: [macos][ZTS] Support fast path for tlv_get_addr

Access to TLV(thread local variable) in macOS is in "dynamic" form and
function tlv_get_addr() is invoked to resolve the address. See the
example in [1].

Note there is one struct TLVDescriptor [2] for each TLV. The first
member holds the address of function tlv_get_addr(), and the other two
members, "key" and "offset", would be used inside tlv_get_addr().

The disassembly code for function tlv_get_addr() is shown in [3]. With
the value from system register, i.e. tpidrro_el0, together with "key"
and "offset", the TLV address can be obtained.

Note that the value from tpidrro_el0 varies for different threads, and
unique address for TLV is resolved.

It's worth noting that slow path would be executed, i.e. function
tlv_allocate_and_initialize_for_key(), for the first time of TLV access.

In this patch:
1. "_tsrm_ls_cache" is guaranteed to be accessed before any VM/JIT code
during the request startup, e.g. in init_executor(), therefore, slow
path can be avoided.

2. As TLVDecriptor is immutable and zend_jit_setup() executes once, we
get this structure in tsrm_get_ls_cache_tcb_offset(). Note the 'ldr'
instruction would be patched to 'add' by the linker.

3. Only fast path for tlv_get_addr() is implemented in macro
LOAD_TSRM_CACHE.

With this patch, all ~4k test cases can pass for ZTS+CALL in macOS on
Apple silicon.

[1] https://gist.github.com/shqking/4aab67e0105f7c1f2c549d57d5799f94
[2]
https://opensource.apple.com/source/dyld/dyld-195.6/src/threadLocalVariables.c.auto.html
[3] https://gist.github.com/shqking/329d7712c26bad49786ab0a544a4af43

Change-Id: I613e9c37e3ff2ecc3fab0f53f1e48a0246e12ee3
2021-05-31 14:27:00 +08:00
Anatol Belski 805b391d99 NEWS: UPGRADING.INTERNALS: Add PCRE2 10.37 info
[ci skip]

Signed-off-by: Anatol Belski <ab@php.net>
2021-05-30 13:06:16 +02:00
Nikita Popov 8c73dfe062 Remove silly code from openssl_pkey_free() test
W A T
2021-05-29 15:48:58 +02:00
Christoph M. Becker c8244dd989 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix typo in test case (doe → die)
2021-05-29 15:40:15 +02:00
Christoph M. Becker 140eca603c Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix typo in test case (doe → die)
2021-05-29 15:39:17 +02:00
Christoph M. Becker 4ab434fa0e Fix typo in test case (doe → die) 2021-05-29 15:36:40 +02:00
Anatol Belski 79755cad96 pcre2lib: Fix wrong check-in
Signed-off-by: Anatol Belski <ab@php.net>
2021-05-29 15:11:09 +02:00
Anatol Belski 5d4290088e pcre2lib: Pull PCRE2 10.37
Excerpt from the release news:

Version 10.37 26-May-2021
-------------------------

A few more bug fixes and tidies. The only change of real note is the removal of
the actual POSIX names regcomp etc. from the POSIX wrapper library because
these have caused issues for some applications (see 10.33 #2 below).

Version 10.36 04-December-2020
------------------------------

Again, mainly bug fixes and tidies. The only enhancements are the addition of
GNU grep's -m (aka --max-count) option to pcre2grep, and also unifying the
handling of substitution strings for both -O and callouts in pcre2grep, with
the addition of $x{...} and $o{...} to allow for characters whose code points
are greater than 255 in Unicode mode.

NOTE: there is an outstanding issue with JIT support for MacOS on arm64
hardware. For details, please see Bugzilla issue #2618.

Signed-off-by: Anatol Belski <ab@php.net>
2021-05-29 14:52:27 +02:00
Anatol Belski 56c16334e5 ext: Cleanup some dead assignments
Signed-off-by: Anatol Belski <ab@php.net>
2021-05-29 13:03:32 +02:00
Anatol Belski 20fc4fa888 Zend: Cleanup dead assignment in zend_compile_class_const
Signed-off-by: Anatol Belski <ab@php.net>
2021-05-29 13:03:05 +02:00
Nikita Popov ea256a218b Add %0 format to run-tests.php
This format matches against null bytes, and prevents the test
expectation from being interpreted as binary data.

bless_tests.php will automatically replace \0 with %0 as well.
2021-05-29 11:33:13 +02:00
Derick Alangi e838de342a [skip-ci] Improve documentation for better clarity to readers (#7066)
While reading the docs in the repo, I found & made a few improvements
to the documentation so it's clearer to its readers.

These improvements are around: typos, general punctuations, and grammar.
2021-05-29 05:17:51 +01:00
Christoph M. Becker 2454e3b9a5 Merge branch 'PHP-8.0'
* PHP-8.0:
  Speed up ext/dba/tests/bug78808.phpt
2021-05-28 23:25:29 +02:00
Christoph M. Becker af146a42ff Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Speed up ext/dba/tests/bug78808.phpt
2021-05-28 23:24:55 +02:00
Christoph M. Becker c11b52de95 Speed up ext/dba/tests/bug78808.phpt
This tests takes about 2 minutes on AppVeyor CI, what is super slow.
The problem is that we're doing 50,000 inserts of small keys and values
instead of only few inserts with large values, what basically has the
same effect regarding the mmap size.

Closes GH-7073.
2021-05-28 23:24:18 +02:00
Máté Kocsis 04d3a21029 Merge branch 'PHP-8.0'
* Fixed bug #81088 (error in regression test for oci_fetch_object() and oci_fetch_array()
2021-05-28 17:59:57 +02:00
Máté Kocsis a0af84bebd Fixed bug #81088 error in regression test for oci_fetch_object() and oci_fetch_array()
Closes GH-7072
2021-05-28 17:56:51 +02:00
Máté Kocsis 48981f4f1e Declare tentative return types for ext/standard (#7065) 2021-05-28 15:46:04 +02:00
Máté Kocsis 0b01d589f1 Declare tentative return types for ext/oci8 (#7070) 2021-05-28 15:39:53 +02:00
Máté Kocsis 83916e83b4 Declare tentative return types for ext/phar (#7052) 2021-05-28 15:07:15 +02:00
Máté Kocsis dd83ced6bd Declare tentative return types for ext/snmp
Closes GH-7064
2021-05-28 12:45:33 +02:00
Máté Kocsis 5e8bdafae4 Merge branch 'PHP-8.0'
* Fix the return types in ext/snmp (#7068)
2021-05-28 12:44:15 +02:00
Máté Kocsis 15ec7404f1 Fix the return types in ext/snmp (#7068) 2021-05-28 12:34:46 +02:00
twosee 2389ac229f Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix argument index in stream_select()
2021-05-28 17:41:52 +08:00
twosee b751c24e23 Fix argument index in stream_select()
Closes GH-7067.
2021-05-28 17:37:51 +08:00
Máté Kocsis 787db3af48 Declare tentative return types for ext/session (#7005) 2021-05-28 10:29:08 +02:00
Nikita Popov 100a1e8e21 Convert exception during inheritance to fatal error
Now that inheritance can throw deprecations again, these may be
converted to exception by a custom error handler. In this case
we need to convert the exception to a fatal error, as inheritance
cannot safely throw in the general case.
2021-05-28 10:19:23 +02:00
Nikita Popov 6e477d205e Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix session test
2021-05-28 09:45:21 +02:00
Nikita Popov ddb550f1f8 Fix session test 2021-05-28 09:45:06 +02:00
twosee 7e11b4d325 Improve memory allocation related code in zend_fibers (#7058)
- make_fcontext() never returns NULL.
- Show syscall error info in exception just like zend_alloc does (we also used php_win32_error_*() in Zend).
- MAP_ANON was marked as deprecated or compatibility macro on Linux, It would be better to use MAP_ANONYMOUS first.
- Makes the code consistent with the code of other modules in the kernel.
- adds some comments.
2021-05-28 12:04:44 +08:00
Máté Kocsis 29642623fd Promote "Session is not active" warning to exception
In normal circumstances, the session handler methods are not invoked when the session is not active.

Closes GH-7006
2021-05-27 23:26:15 +02:00
Máté Kocsis 53b5105edd Merge branch 'PHP-8.0'
* Fix session cleanup
* Fix the return type of SessionHandler::gc()
2021-05-27 23:08:27 +02:00
Máté Kocsis 6fb08f4607 Fix return type of SessionHandler::gc()
Relates to GH-7006
2021-05-27 23:07:27 +02:00
Máté Kocsis b165197f0f Fix session cleanup 2021-05-27 23:03:19 +02:00
Nikita Popov 010d6a491c Convert SKIPIF -> EXTENSIONS in new opcache test 2021-05-27 16:33:30 +02:00
Nikita Popov ba9c0b38cb Export zend_unary_op_produces_error() and use in optimizer
Don't repeat this logic, as it's going to become more complex.
2021-05-27 16:33:30 +02:00
Máté Kocsis 0224cc83fc Merge branch 'PHP-8.0'
* Add a few missing RETURN_THROWS();
* Fix a few ext/phar return types
2021-05-27 16:32:16 +02:00
Máté Kocsis 9bba9f68df Fix a few ext/phar return types 2021-05-27 16:31:18 +02:00
Máté Kocsis 2d47447d66 Add a few missing RETURN_THROWS();
Only PharFileInfo::compress() really needs it though.
2021-05-27 16:31:18 +02:00
Nikita Popov 853e681267 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80761
2021-05-27 16:00:23 +02:00
Nikita Popov 635303aec5 Fixed bug #80761
When row data split across multiple packets, allocate a temporary
buffer that can be reallocated, and only copy into the row buffer
pool arena once we know the final size. This avoids quadratic
memory usage for very large results.

(cherry picked from commit 1fc4c89214)
2021-05-27 16:00:03 +02:00
Nikita Popov 92dfd97315 Use early return in snmp
This avoids the odd dangling elses.
2021-05-27 15:03:59 +02:00
Remi Collet 2237102b74 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix snmp build without DES
2021-05-27 14:59:51 +02:00
Remi Collet f9fd3595ec Fix snmp build without DES 2021-05-27 14:58:07 +02:00
Nikita Popov 265dd19d63 Generate tokenizer_data.c from zend_language_parser.y
The order of the tokens in zend_language_parser.h depends on the
used bison version. To avoid spurious changes to tokenizer_data.c
generate tit from the zend_language_parser.y file instead.
2021-05-27 14:35:05 +02:00
Dmitry Stogov a50a1b643e Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #81051 (Broken property type handling after incrementing reference)
2021-05-27 15:23:20 +03:00
Dmitry Stogov ac65f6af6e Fixed bug #81051 (Broken property type handling after incrementing reference) 2021-05-27 15:22:34 +03:00
twosee 795efd7613 Add zend_getpagesize() and reuse it in accelerator and fiber (#7057) 2021-05-27 18:27:18 +08:00
Dmitry Stogov 3c827b3084 Fixed ARM64 JIT build 2021-05-27 13:22:07 +03:00
Dmitry Stogov 5557cb7950 Fix edge cases in JIT for ASSIGN_DIM_OP. 2021-05-27 13:19:24 +03:00
Christoph M. Becker ae6c1b0c4f Don't add unnecessary extensions to the test INI for AppVeyor
Several extension test suites have already been changed to rely on the
new behavior of `--EXTENSIONS--` section, i.e. to dynamically load
required extensions on demand.  Thus, there is no need to load these
extensions always, which should improve the performance of executing
the tests.
2021-05-27 11:39:42 +02:00
Christoph M. Becker 6f89da78d0 Adjust run-tests.php to dynamic extension loading
PR #6787 changed the behavior of the `--EXTENSIONS--` section, so that
not yet loaded extensions are dynamically loaded if possible.  However,
when no tests are specified for the runner, only tests for already
loaded extensions are run, what defeats the purpose of the improvement
of the `--EXTENSIONS--` behavior.  We cater to that by detecting
loadable extensions, and also run their tests.
2021-05-27 11:33:36 +02:00
Nikita Popov f57526a07a Store base path as zend_string in Phar::buildFrom*
This also removes the need to check for length overflow, as the
length is now size_t.
2021-05-27 10:57:51 +02:00
Nikita Popov 8c192c717c Accept regex as zend_string in Phar::buildFromDirectory()
No need to copy it...
2021-05-27 10:51:51 +02:00
Máté Kocsis 172c29879e Declare tentative return types for ext/zip (#7053) 2021-05-27 10:47:32 +02:00
Máté Kocsis 5beba0b038 Declare tentative return types for ext/json (#7051) 2021-05-27 10:47:15 +02:00
twosee 95d21f12e3 Add missing extern "C" in zend.h (#7056) 2021-05-27 15:53:30 +08:00
twosee 9066d695e9 Remove all *_EXTERN_C() in C source files (#7054) 2021-05-27 15:52:54 +08:00
Aaron Piotrowski 3939c9b07e Add internal Fiber API (#7045)
This additional internal fiber API creates and manipulates a Fiber object, allowing any internal function to start, resume, or suspend a fiber. The existing zend_fiber_context API allows custom C-based fiber creation using the bundled switching context, but does not interact with the PHP VM. This API behaves the same as calling Fiber object methods from user code, switching EGs, and triggering the fiber switch observer. In general, the Fiber object methods call these new API methods.
2021-05-27 08:33:40 +02:00
twosee 0e2ac303af Use ZEND_WIN32 instead of PHP_WIN32 (#7055) 2021-05-27 08:32:40 +02:00
Anatol Belski b9f3f35d4a libtool: Add CC tag explicitly
This fixes the scan-build build. CC is also the default tag, so there
should be no impact anywhere.

Signed-off-by: Anatol Belski <ab@php.net>
2021-05-26 22:41:50 +02:00
Máté Kocsis 6af5b369d7 Merge branch 'PHP-8.0'
* mysqli_get_client_info() cannot return null
2021-05-26 17:49:39 +02:00
Máté Kocsis ceb0951fa5 mysqli_get_client_info() cannot return null
This method is already deprecated
2021-05-26 17:48:35 +02:00
Máté Kocsis 62f7c0a2d6 Remove unnecessary return doc comment from PDOStatement::errorInfo() 2021-05-26 17:33:14 +02:00
Máté Kocsis 01775fa104 Declare tentative return types for ext/mysqli (#6998) 2021-05-26 17:29:58 +02:00
Nikita Popov b0961f2d04 Remove uses of TRUE/FALSE in mysqli/pdo_mysql
Replace with standard uses of true/false.
2021-05-26 15:07:23 +02:00
Nikita Popov b55793e45b Merge branch 'PHP-8.0'
* PHP-8.0:
  Update func info for mysqli_connect
2021-05-26 14:36:52 +02:00
Nikita Popov 9f6ee9f4d7 Update func info for mysqli_connect 2021-05-26 14:36:21 +02:00
Nikita Popov 12a4b2249d Merge branch 'PHP-8.0'
* PHP-8.0:
  Make tests compatible with libxml2 2.9.12
2021-05-26 13:21:43 +02:00
Nikita Popov 0b232cf71d Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Make tests compatible with libxml2 2.9.12
2021-05-26 13:20:36 +02:00
Stéphan KochenandNikita Popov f3d1e9ed06 Make tests compatible with libxml2 2.9.12
This version of libxml introduced quite a few changes. Most of
them are differences in error reporting, while some also change
behavior, e.g. null bytes are no longer supported and xinclude
recursion is limited.

Closes GH-7030. Closes GH-7046.

Co-authored-by: Nikita Popov <nikic@php.net>
2021-05-26 13:19:34 +02:00
Máté Kocsis fccb7274e8 Do not verify the signature of ReflectionEnumUnitCase::getValue()
This method legally have a different return type (UnitEnum) from its parent's return type (mixed).
2021-05-26 12:38:04 +02:00
Máté Kocsis b4b848bfa7 Fix the signature of ini_alter()
It should be the same as ini_set()
2021-05-26 12:32:38 +02:00
Máté Kocsis 657cb45b84 Declare tentative return types for ext/fileinfo
Relates to GH-6985
2021-05-26 12:30:31 +02:00
Máté Kocsis 737af24644 Declare tentative return types for ext/curl
Relates to GH-6985
2021-05-26 12:30:07 +02:00
Máté Kocsis 7da2151f7a Declare typed properties in ext/dom
Closes GH-7013
2021-05-26 12:23:43 +02:00
Nikita Popov f4865010a8 Add missing type declarations in soap tests 2021-05-26 12:21:45 +02:00
Máté Kocsis 8ae4b56027 Declare tentative return types for ext/soap
Closes GH-7001
2021-05-26 12:18:51 +02:00
Máté Kocsis 1a1a9b2e4a Merge branch 'PHP-8.0'
* Fix the return type of mysqli_connect()
2021-05-26 12:11:09 +02:00
Máté Kocsis 187c56ae2d Update mysqli stub hash 2021-05-26 12:09:54 +02:00
Máté Kocsis 97f7279353 Fix the return type of mysqli_connect() 2021-05-26 12:07:02 +02:00
Máté Kocsis a6c9f148b6 Merge branch 'PHP-8.0'
* Fix return type of mysqli::connect()
2021-05-26 11:56:21 +02:00
Máté Kocsis 86ef34fc61 Fix the return type of mysqli::connect() 2021-05-26 11:55:03 +02:00
Nikita Popov 07da2e3f28 Add comment for specialization in zend_hash_real_init_packed_ex()
As the seemingly reundant code may be confusing. Closes GH-6988.
2021-05-26 11:52:36 +02:00
Máté Kocsis a40cdd55f8 Declare tentative return types for ext/sqlite3
Closes GH-7000
2021-05-26 11:48:51 +02:00
Máté Kocsis 37a3c9bc8d Declare tentative return types for ext/simplexml
Closes GH-7003
2021-05-26 11:23:38 +02:00
Nikita Popov 312b72908d Convert some instanceof checks to assertions
Again, $this must be instanceof self.
2021-05-26 10:44:56 +02:00
twosee 2c0b4c8d21 Remove the redefinition of zend_error_info (#7044)
It causes -Wtypedef-redefinition warning.
2021-05-26 16:23:23 +08:00
Nikita Popov 82ccd47d39 Use ZEND_TLS for spl (#7043)
For extension globals that do not require cross-module visibility, we can
use ZEND_TLS as a more efficient TLS mechanism.
2021-05-26 09:36:23 +02:00
Máté Kocsis 97a849602d Declare tentative return types for ext/tidy
Closes GH-6999
2021-05-25 19:18:58 +02:00
Máté Kocsis 4ed66ff2a9 Declare tentative return types for ext/pdo
Closes GH-6996
2021-05-25 19:17:40 +02:00
Máté Kocsis 1b35056a33 Declare tentative return types for ext/xsl
Relates to GH-6995
2021-05-25 19:15:44 +02:00
Máté Kocsis 65995002f0 Declare tentative return types for ext/xmlwriter
Relates to GH-6995
2021-05-25 19:15:18 +02:00
Máté Kocsis a902622ad6 Declare tentative return types for ext/xmlreader
Relates to GH-6995
2021-05-25 19:14:48 +02:00
Nikita Popov 940f599be9 Convert check into assertion in ext/xmlreader
$this is requires to be instanceof self for quite a while now,
so make this an assertion.
2021-05-25 17:35:14 +02:00
Nikita Popov 3c96d7e618 Remove some unnecessary null pointer checks in ext/xmlreader
intern cannot be NULL.
2021-05-25 17:18:06 +02:00
Janakarajan Natarajan 4a68067c10 Use arm64-graviton2 on Travis (#7016) 2021-05-25 15:30:54 +02:00
Nikita Popov a76d35abcc Remove commented code from get_method handler 2021-05-25 15:25:51 +02:00
Christoph M. Becker fda53548b5 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #76359: open_basedir bypass through adding ".."
2021-05-25 13:47:25 +02:00
Christoph M. Becker a5601b2ab5 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #76359: open_basedir bypass through adding ".."
2021-05-25 13:46:38 +02:00
Christoph M. Becker ee9e07541f Fix #76359: open_basedir bypass through adding ".."
We explicitly forbid adding paths with a leading `..` to `open_basedir`
at runtime.

Closes GH-7024.
2021-05-25 13:44:53 +02:00
Kamil Tekiela 428340dfeb Add error reporting to mysqli_options (#7036) 2021-05-25 10:42:06 +01:00
Nikita Popov 7a766401eb Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix bug #81068: Fix possible use-after-free in realpath_cache_clean()
2021-05-25 11:41:06 +02:00
Nikita Popov 0fb371440d Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix bug #81068: Fix possible use-after-free in realpath_cache_clean()
2021-05-25 11:40:57 +02:00
Dimitry Andric 99a208566a Fix bug #81068: Fix possible use-after-free in realpath_cache_clean()
If ZTS is enabled, this can cause cwd_globals_ctor() to be called
multiple times, each with a freshly allocated virtual_cwd_globals
instance. At shutdown time however, cwd_globals_dtor() will call
realpath_cache_clean(), which then possibly cleans up the same
realpath_cache instance more than once. Using AddressSanitzer, this
shows up as a heap use-after-free.

To avoid this, add a helper function to do the actual work on one
instance of a realpath_cache, and call it both from cwd_globals_dtor()
and realpath_cache_clean(). The former uses the virtual_cwd_globals
parameter passed in via the destructor, the latter uses the CWDG()
macro.
2021-05-25 11:40:28 +02:00
Joe Watkins 531413f809 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #81076 Invalid implicit binds cause incorrect count in static vars of closure debug info
2021-05-25 11:27:20 +02:00
Joe Watkins 213063f6ca Fix #81076 Invalid implicit binds cause incorrect count in static vars of closure debug info 2021-05-25 11:26:38 +02:00
Joe Watkins 6408ebb731 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #77627 method_exists on Closure::__invoke
2021-05-25 11:23:08 +02:00
Joe Watkins cfd4d3df0b Fix #77627 method_exists on Closure::__invoke 2021-05-25 11:22:05 +02:00
DannyS712 724230d9a4 zend_language_parser.y: Fix a documentation typo
"loading" should be "leading" when discussing separators in namespace names
2021-05-25 10:08:59 +02:00
Nikita Popov 1fb9f5f93e Revert "Fix edge cases in JIT for ASSIGN_DIM_OP."
This reverts commit 4744dc8d21.

This seems to have broken some tests in sapi/fpm, and also causes
the test runner to get killed.
2021-05-24 20:46:42 +02:00
Christoph M. Becker e4e965039b Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix some imagecolor*() return types
2021-05-24 14:21:29 +02:00
Christoph M. Becker 8bcaaa3579 Fix some imagecolor*() return types
These functions either return always a valid color, or `-1` on failure,
but never `false`.

Closes GH-7041.
2021-05-24 14:19:29 +02:00
Dmitry Stogov 4744dc8d21 Fix edge cases in JIT for ASSIGN_DIM_OP.
(This fixes Zend/tests/bug79947.phpt and
Zend/tests/undef_index_to_exception.phpt without PROFITABILITY_CHECKS).
2021-05-24 13:35:04 +03:00
Dmitry Stogov 88631e329b DynASM/ARM64: Fix ADRP encoding with absolute address.
(Switch to Mike Pall's version)
2021-05-24 10:17:52 +03:00
Máté Kocsis bf42cf5ae0 Merge branch 'PHP-8.0'
* Fix imagesetclip() parameter names
2021-05-23 19:41:25 +02:00
Máté Kocsis 25e24715d7 Fix imagesetclip() parameter names
Closes GH-7035
2021-05-23 19:40:12 +02:00
Máté Kocsis 78ecd4a5f0 Declare tentative return types for ext/reflection
Closes GH-7011
2021-05-23 15:59:57 +02:00
Christoph M. Becker d61d21ad57 Merge branch 'PHP-8.0'
* PHP-8.0:
  SimpleXMLElement::addAttribute() is a void function
2021-05-22 22:31:51 +02:00
Christoph M. Becker 24d9527c75 SimpleXMLElement::addAttribute() is a void function
Closes GH-7033.
2021-05-22 22:28:34 +02:00
Christoph M. Becker dff0798552 Merge branch 'PHP-8.0'
* PHP-8.0:
  Update version in php_version.h as well
2021-05-22 15:48:13 +02:00
Christoph M. Becker dcdac65dab Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Update version in php_version.h as well
2021-05-22 15:47:35 +02:00
Christoph M. Becker 59522ba968 Update version in php_version.h as well
The version there is automatically updated during `./configure`, but
not on Windows.
2021-05-22 15:42:57 +02:00
Christoph M. Becker a375d54785 Migrate skip checks to --EXTENSIONS-- for ext/gd
Cf. PR #6787.

Closes GH-6994.
2021-05-22 15:38:51 +02:00
Nikita Popov a0c44fbaf1 Always define valgrind replacement symbol for zend_string_equal_val
The required symbol name seems to be very stable, so we can hardcode
a fallback. This avoids many false positives when PHP is not built
against valgrind.
2021-05-21 21:00:34 +02:00
Joe Watkins 1bfaba4134 Merge branch 'master' of github.com:php/php-src
* 'master' of github.com:php/php-src:
  Fix upload_2G test
2021-05-21 16:07:45 +02:00
Joe Watkins 4d883a0eba note in upgrading for b227a72285 2021-05-21 16:05:56 +02:00
Nikita Popov 1af891306a Fix upload_2G test
Include the new full_path key. This test is skipped on CI but
fails locally.
2021-05-21 16:02:40 +02:00
Joe Watkins b227a72285 ReflectionFunctionAbstract::getClosureUsedVariables
Make a distinction at compile time between bind types for static
  variables

  getStaticVariables remains unchanged

  Fixes #80071
2021-05-21 15:25:35 +02:00
Dmitry Stogov 77ce2537f7 Merge branch 'PHP-8.0'
* PHP-8.0:
  Disable ASSIGN + SEND_VAL fusion for cases when destroying of old value may throw an exception.
2021-05-21 13:38:50 +03:00
Dmitry Stogov 11a7310b49 Disable ASSIGN + SEND_VAL fusion for cases when destroying of old value may throw an exception. 2021-05-21 13:36:58 +03:00
David CARLIER 90b843beb6 Add FreeBSD to CI (#6974)
This is using Cirrus, as none of the CI providers we already use support FreeBSD.
2021-05-21 12:00:46 +02:00
Hao Sun 3ce26d80b7 JIT/AArch64: [macos] Fix arguments to variadic function (#7023)
zend_throw_error() and zend_error() are variadic functions. In Linux,
arguments are passed in registers, whereas they must be put on stack in
Macos [1][2].

In this patch:
1. preprocessor macro "__APPLE__" is used to distinguish the OS.
2. the third argument "CARG3" is the only variadic argument and put on
stack.
3. the invocation of zend_error() is converted back to regular call in
zend_jit_undefined_offset_stub() and zend_jit_undefined_index_stub().

With this patch, all ~4k test cases can pass for "nonZTS+CALL"
functional/tracing JIT with Macos Apple Silicion.

[1]
https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms#Overview
[2] https://github.com/below/HelloSilicon#listing-9-1

Change-Id: I49bc3233fc253ad3e77e8664464ff3e830dcd183
2021-05-21 17:59:15 +08:00
Nikita Popov b849aa6494 Merge branch 'PHP-8.0'
* PHP-8.0:
  Pass flags to #[Attribute] on internal attributes
2021-05-21 11:42:11 +02:00
Nikita Popov db6e60e744 Pass flags to #[Attribute] on internal attributes
While the specified restriction was checked, the #[Attribute]
attribute did not specify the flags parameter, so that Reflection
returned incorrect information.

In particular, Attribute itself has a CLASS target, not an ALL
target.
2021-05-21 11:40:23 +02:00
Nikita Popov b97a080034 Remove special UNREACHABLE_FREE handling in block pass
This results in an assertion failure when running under -e,
because there is an additional EXT_STMT + NOP before the FREE.
I don't think there's a strong reason to handle UNREACHABLE_FREE
specially here (it's only important that we *do* handle it), so
I'm dropping the code rather than adjusting it to scan over
certain opcodes.
2021-05-21 11:10:32 +02:00
Nikita Popov 9f263411eb XFAIL two intl tests on FreeBSD
These tests fail with the following diff:

========DIFF========
     date:  Tuesday, July 7, 2009 8:41:13 PM EDT
002+ msgf:  Wednesday, July 8, 2009 12:41:13 AM utc
002- msgf:  Tuesday, July 7, 2009 8:41:13 PM usnyc
========DONE========
FAIL Bug #58756: w.r.t MessageFormatter [ext/intl/tests/bug58756_MessageFormatter_variant2.phpt]

========DIFF========
001+ quinta-feira, 17 de maio de 2012 4:35:36 da tarde utc
001- quinta-feira, 17 de maio de 2012 5:35:36 da tarde ptlis
========DONE========
FAIL MessageFormat accepts IntlCalendar args [ext/intl/tests/msgfmt_format_intlcalendar_variant4.phpt]

That is, it appears that the timezone does not get applied. I don't
know why this happens, and don't want to spend more time trying to
figure this out.
2021-05-21 10:36:33 +02:00
Dmitry Stogov 0b4706819b Fix register save/restore around calls. (This fixes ext/opcache/tests/jit/fetch_dim_rw_001.phpt with -d opcache.jit=1202 without PROFITABILITY_CHECKS) 2021-05-21 11:12:22 +03:00
Dmitry Stogov e9d171805a Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix register save/restore around calls. (This fixes ext/opcache/tests/jit/fetch_dim_rw_001.phpt with -d opcache.jit=1202 without PROFITABILITY_CHECKS)
2021-05-21 11:10:20 +03:00
Dmitry Stogov 025c0763e7 Fix register save/restore around calls. (This fixes
ext/opcache/tests/jit/fetch_dim_rw_001.phpt with -d opcache.jit=1202
without PROFITABILITY_CHECKS)
2021-05-21 11:08:56 +03:00
Derick Rethans b624473b3e Merge branch 'PHP-8.0' 2021-05-21 09:03:31 +01:00
Derick Rethans 2b4acf0cee Merge branch 'detect_musl_and_turn_off_tls_attribute' into PHP-8.0 2021-05-21 09:03:23 +01:00
Derick Rethans 804420b011 Detect musl libc to not set tls_model attribute on that platform
This fixes:
``_tsrm_ls_cache: initial-exec TLS resolves to dynamic definition``
in shared extensions.
2021-05-21 09:02:46 +01:00
Dmitry Stogov ab1827f3d4 Merge branch 'PHP-8.0'
* PHP-8.0:
  Add missing undefined variable warning an result initialization. (This fixes Zend/tests/bug78531.phpt without PROFITABILITY_CHECKS).
2021-05-21 10:04:38 +03:00
Dmitry Stogov bf21261c63 Add missing undefined variable warning an result initialization.
(This fixes Zend/tests/bug78531.phpt without PROFITABILITY_CHECKS).
2021-05-21 10:03:00 +03:00
Hao Sun b8a29319a7 JIT/AArch64: Fix typo in commit dc0e259 (#7021)
PHP JIT/AArch64 building is broken. Instruction "beq" should be used.

Change-Id: I16c00f87bafb3a565141e1e02c9e15653f39a276
2021-05-21 14:06:33 +08:00
Dmitry Stogov 6881a002d4 Merge branch 'PHP-8.0'
* PHP-8.0:
  Don't assign to string offset after exception (This fixes Zend/tests/bug31098.phpt failure without PROFITABILITY_CHECKS)
2021-05-21 00:49:44 +03:00
Dmitry Stogov db309b2e4b Don't assign to string offset after exception (This fixes
Zend/tests/bug31098.phpt failure without PROFITABILITY_CHECKS)
2021-05-21 00:48:24 +03:00
Dmitry Stogov dc0e259154 Merge branch 'PHP-8.0'
* PHP-8.0:
  JIT: Fixed incorrect condition (this leaded to Zend/tests/type_declarations/typed_properties_083.phpt failure without PROFITABILITY_CHECKS)
2021-05-21 00:02:46 +03:00
Dmitry Stogov cce0cc8836 JIT: Fixed incorrect condition (this leaded to
Zend/tests/type_declarations/typed_properties_083.phpt failure without
PROFITABILITY_CHECKS)
2021-05-21 00:01:00 +03:00
Dmitry Stogov cb376d8f61 Fixed Zend/tests/type_declarations/union_types/incdec_prop.phpt failure
masked by PROFITABILITY_CHECKS.
2021-05-20 22:52:47 +03:00
Dmitry Stogov 6be0278332 Fixed 32-bit x86 disassembler 2021-05-20 20:17:50 +03:00
Dmitry Stogov 0838d5a719 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80968 (JIT segfault with return from required file)
2021-05-20 16:51:21 +03:00
Dmitry Stogov 4135ce9d38 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80968 (JIT segfault with return from required file)
2021-05-20 16:50:14 +03:00
Dmitry Stogov 6e2d47e071 Fixed bug #80968 (JIT segfault with return from required file) 2021-05-20 16:45:24 +03:00
ada-u 7eef766c3d Add mysqli.rollback_on_cached_plink to php.ini-* 2021-05-20 15:44:57 +02:00
Dmitry Stogov f44ff44516 JIT/AArch64: Fixed incorrect MEM_LOAD usage 2021-05-20 14:43:49 +03:00
Dmitry Stogov 53021b4b9b JIT/AArch64: Fixed DWARF frame description for helper stubs 2021-05-20 12:14:29 +03:00
Nikita Popov 7742f31f32 Disable workaround for ICU bug on newer versions
This is issue https://unicode-org.atlassian.net/browse/ICU-12584,
which has been fixed in ICU 64.1 by
https://github.com/unicode-org/icu/commit/a9d219691398f0168150ad5a3e5f381f84ca95df.

I'm disabling the workaround for ICU >= 65, as we don't seem to be
doing minor version checks in intl.
2021-05-20 10:10:27 +02:00
Nikita Popov f9990009c8 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix handling of open_basedir that contains cwd
2021-05-20 09:53:57 +02:00
Nikita Popov ef59d09af0 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix handling of open_basedir that contains cwd
2021-05-20 09:53:25 +02:00
Nikita Popov ee7a8acde9 Fix handling of open_basedir that contains cwd
While resolving the path, the last step will reduce it down to ""
(an empty string) and realpath() will resolve this to getcwd().
If open_basedir contains the CWD, then that means open_basedir
will be bypassed for paths that don't have any components that
exist (if one of the components exists, then we abort the realpath
loop at that point).

Closes GH-7015.
2021-05-20 09:52:21 +02:00
Dmitry Stogov e5d2681074 JIT/AArch64: Link traces through exit tables.
1. Generate exit table at the end of each trace (list of unconditional branches for all side exit)
2. Jump to this table if conditional branch to side exit can't be performed because of limited jump distance (+/-1MB) (avoid extra veneers for side exits).
3. During trace linking, update targets of conditional branches to this exit table, if target trace can't be reachd because of limited jump distance (+/-1MB)
2021-05-20 02:53:00 +03:00
Dmitry Stogov 7358457aa7 JIT: Don't include zend_jit_trace_info.jmp_table_size into zend_jit_trace_info.code_size 2021-05-20 02:46:14 +03:00
Dmitry Stogov 45325bd425 JIT/AArch64: Fixed code alignment 2021-05-20 02:32:35 +03:00
Sara Golemon 99a79fdb53 Merge branch 'PHP-8.0'
* PHP-8.0:
  Prep for 8.0.8
2021-05-19 19:19:55 +00:00
Sara Golemon 64918fee97 Prep for 8.0.8 2021-05-19 19:18:56 +00:00
Nikita Popov b8e4d9f387 Use shell-free proc_open() in parallel run-tests.php 2021-05-19 20:46:50 +02:00
Dmitry Stogov d52fdd5056 DynASM/ARM64: Fixed incorrect ADRP instruction encoding (-4 => +4) 2021-05-19 18:21:01 +03:00
Nikita Popov 28c27cdbe5 Skip posix_setrlimit() test on FreeBSD
FreeBSD does not report an error on the second call, the limit is
simply not raised.
2021-05-19 16:59:27 +02:00
Nikita Popov 11bf5ccf62 Set default_socket_timeout in test
If the read is not refused outright, this will timeout, and we
don't want to wait 60s for that.
2021-05-19 15:29:38 +02:00
Nikita Popov 23c90dcdfb Report error from socket read on timeout
A timeout is not considered a transient error (at the socket layer),
and should return -1 rather than 0.
2021-05-19 15:29:16 +02:00
Nikita Popov 4c15dffe3a Reduce timeout in FTP PASV connection failure test
If the connection times out rather than being refused outright,
don't wait the full 60 seconds that are used by default. If this
happens, the error message will also be different.
2021-05-19 15:08:40 +02:00
Christoph M. Becker adb0e4f18d Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #81048: phpinfo(INFO_VARIABLES) "Array to string conversion"
2021-05-19 14:10:02 +02:00
Christoph M. Becker 5dfdd694e7 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #81048: phpinfo(INFO_VARIABLES) "Array to string conversion"
2021-05-19 14:09:21 +02:00
Christoph M. Becker 36b9bdeeec Fix #81048: phpinfo(INFO_VARIABLES) "Array to string conversion"
Now that we properly dereference references of the superglobals. we
also need to dereference contained references to avoid to string
conversion.

Closes GH-7014.
2021-05-19 14:07:15 +02:00
Nikita Popov 0fd796133a Drop test that is always skipped
This test is skipped unconditionally, so I don't think there's
much point in keeping it.
2021-05-19 13:02:30 +02:00
Nikita Popov f31c531960 Merge branch 'PHP-8.0'
* PHP-8.0:
  Move preload_autoload assignment into preload_load()
2021-05-19 12:56:28 +02:00
Nikita Popov 62a9f97381 Move preload_autoload assignment into preload_load()
We need to set the preload autoloader even if preloading happened
in a different process. accel_preload() will only run in one.

In particular, this fixes the behavior if preload_user is used.
2021-05-19 12:55:46 +02:00
Nikita Popov 77201d7013 Avoid accessing localhost in some soap tests
On some systems, this can make these tests very slow, as they end
up waiting for a timeout.

Instead intercept the sent request using __doRequest().
2021-05-19 12:54:46 +02:00
Dmitry Stogov 9a907b2e17 JIT/AArch64: Combine ADRP+ADD+LDR into ADRP+LDR
before:
	adrp x15, #0xffff8ae5a000
	add x15, x15, #0xd90
	ldr d16, [x15]
after:
	adrp x15, #0xffff8ae5a000
	ldr d16, [x15, #0xd90]
2021-05-19 13:23:28 +03:00
Nikita Popov 2c6b85f6fe Remove bug49936.phpt
In the meantime, additional tests for ftp:// with opendir() have
been added, which tests actual behavior against a server. This one
just uses localhost (without running a server), which can make the
test very slow on systems that don't refuse the connection outright.
2021-05-19 12:14:16 +02:00
Dmitry Stogov ddb35fe14a JIT/AArch64: Use ADR/ADRP if it makes sense 2021-05-19 11:52:59 +03:00
Dmitry Stogov dec7b7493b DynASM/ARM64: Fixed incorrect ADRP instruction encoding
See: https://developer.arm.com/documentation/ddi0596/2021-03/Base-Instructions/ADRP--Form-PC-relative-address-to-4KB-page-
2021-05-19 11:51:30 +03:00
Nikita Popov 62cb7dc4f5 Disable FFI preload tests with opcache.preload_user 2021-05-19 10:36:55 +02:00
Nikita Popov 976dd997de Fix open_basedir tests when running from /tmp
If our cwd is in /tmp, these tests would fail. Use a directory
name that is less likely to clash.
2021-05-19 10:36:44 +02:00
Nikita Popov 7bc8f2c83f Skip unsupported socket option test on FreeBSD 2021-05-19 09:48:22 +02:00
Nikita Popov b9fbbcc867 Use different error condition in socket test
The previously used error does not occur on FreeBSD and instead
causes the operation to time out.

Also clean up the test a bit. And make sure it actually tests
something -- the point is that socket_last_error() should be 0
after socket_clear_error(). It's kind of pointless if the test
uses a wildcard for the final result instead.
2021-05-19 09:48:17 +02:00
Dmitry Stogov 2fabe2751c JIT/AArch64: Rename B_IMM26 into B_IMM. 2021-05-19 09:47:23 +03:00
Dmitry Stogov a6bb79f16d Correct DWARF frame description.
Now GDB correctly shows backtraces that involves JIT-ed code for
functional/tracing JIT, HYBRID/CALL VM, x86/AArch64 CPU.
(opcache.jit_debug=0x100 should be set).
2021-05-19 09:09:51 +03:00
Michael Voříšek fd8770edef Remove randominess from spl_object_hash 2021-05-19 01:39:35 +01:00
Dmitry Stogov 767a4af2c7 Introduce and use ZEND_JIT_TARGET_X86 and ZEND_JIT_TARGET_ARM64 macros.
Remove x86 specific code from ext/opcache/jit/zend_jit_arm64.dasc.
Fixed ARM64 build without libcapstone.
2021-05-18 21:59:32 +03:00
Nikita Popov 0123c99595 Fix bug55509.phpt skipif on FreeBSD 2021-05-18 19:35:03 +02:00
Nikita Popov 79c9028ca6 Relax error message expectation in socket test 2021-05-18 19:34:34 +02:00
Nikita Popov 06ea1a2502 Skip some strptime() tests on FreeBSD
tm_wday/tm_yday generally have unreliable behavior. What we're
testing is how glibc works.
2021-05-18 19:33:57 +02:00
Nikita Popov 5f090e06b4 Don't strictly check shmop size in test
On FreeBSD, this gets rounded up the page size.
2021-05-18 19:32:36 +02:00
Dmitry Stogov 5fe2062585 Correct DWARF frame description.
Now GDB correctly shows backtraces that involves JIT-ed code for
functional/tracing JIT, HYBRID/CALL VM, x86/AArch64 CPU.
(opcache.jit_debug=0x100 should be set).
2021-05-18 18:21:08 +03:00
Nikita Popov 11648c00e9 Don't include object hash in SplObjectStorage debug dump
The object hash is not particularly useful (anymore) and just
clutters the output. It encodes the same information as the
object ID, which is already part of the output.
2021-05-18 17:20:20 +02:00
Nikita Popov 485a42f495 Work around incorrect NSIG on FreeBSD 2021-05-18 17:07:06 +02:00
Nikita Popov d3e8ae1243 Drop PHP_FUNCTION declares from php_pcntl.h 2021-05-18 17:07:06 +02:00
Nikita Popov 87e76851e8 Fix posix getpwnum/getpwuid tests with empty passwd
On Linux passwd is "x", on FreeBSD it is just "".

Also switch the test to use EXPECTF, I don't see a reason why it
should use EXPECTREGEX.
2021-05-18 17:07:06 +02:00
George Peter Banyard db1bde73cf Use equals OR equal instead of >= && <=
For only two values this is clearer
2021-05-18 15:08:12 +01:00
Máté Kocsis a5e938dc86 Declare dynamic properties in ext/dom
Closes GH-6644
2021-05-18 15:12:35 +02:00
Derick Rethans 8d715b8416 Merge branch 'master' of github.com:php/php-src 2021-05-18 13:46:36 +01:00
Derick Rethans 5132d0b284 Merge branch 'PHP-8.0' 2021-05-18 13:46:14 +01:00
Derick Rethans 6bc7370532 Merge branch 'PHP-8.0' of github.com:php/php-src into PHP-8.0 2021-05-18 13:46:04 +01:00
Nikita Popov 446471b99b Remove error suppression from zend_optimizer_eval_binary_op()
All error conditions should be handled by
zend_binary_op_produces_error().

Pointed out by Girgias.
2021-05-18 14:45:55 +02:00
Derick Rethans 555b18794c Merge branch 'PHP-8.0' 2021-05-18 13:45:32 +01:00
Derick Rethans 8cd6acd69b Merge branch 'PHP-7.4' into PHP-8.0 2021-05-18 13:45:14 +01:00
Máté Kocsis 8f411006a3 Merge branch 'PHP-8.0'
* Fix some nullable return types in ext/simplexml
2021-05-18 14:44:53 +02:00
Derick Rethans 3938bfb564 The PHP 7.4 branch is now for 7.4.21 2021-05-18 13:44:01 +01:00
Máté Kocsis eedc988a4e Fix some nullable return types in ext/simplexml
Closes GH-7004
2021-05-18 14:43:36 +02:00
Dmitry Stogov dae662ffbc Fixed zend_long_is_power_of_two/zend_long_floor_log2 mess 2021-05-18 15:32:36 +03:00
Dmitry Stogov d6d0b1c389 Remove unnecessary #ifdef 2021-05-18 15:32:36 +03:00
Dmitry Stogov f70ac416c3 Fixed possible failure when repair after overflow detection 2021-05-18 15:32:36 +03:00
Dmitry Stogov a69701de2e Fix "store to misaligned address" ASAN warnings 2021-05-18 15:32:36 +03:00
Dmitry Stogov d6bf98428d Fixed format specifier 2021-05-18 15:32:35 +03:00
Dmitry Stogov f15f01aed7 JIT/AArch64: disable register allocation for expected ++/-- overflow case.
This fixes ext/opcache/tests/jit/inc_021.phpt with tracing JIT.
2021-05-18 15:32:35 +03:00
Dmitry Stogov fc3157ea0f Generate veneers to perform long jumps.
This makes symfony_demo app working with -d opcacge.jit=1205.
(21 MB of JIT-ed code).
2021-05-18 15:32:35 +03:00
Dmitry Stogov 0e8fc156f8 DynASM/ARM64: Add abiulity to plug-in generation of veneers to perform long jumps. 2021-05-18 15:32:35 +03:00
Dmitry Stogov 59ef219994 Fixed ZTS build. 2021-05-18 15:32:35 +03:00
Dmitry Stogov 8970b684e9 Use symbolic labels for BL and ADR instructions 2021-05-18 15:32:35 +03:00
Dmitry Stogov e1e050d752 Use better code for trace exits. Don't store CPU registers that can't be used by deoptimizer. 2021-05-18 15:32:35 +03:00
Dmitry Stogov 43b138852e Remove unused TMP4. Use intra-precedure call scratch registers for TMP2 and TMP3. 2021-05-18 15:32:35 +03:00
Dmitry Stogov 78cdb2a7a0 Allow to print JIT assemble without binary addresses (opcache.jit_debug=0x001) and with (opcache.jit_debug=0x401) for both ARM and x86. 2021-05-18 15:32:35 +03:00
Dmitry Stogov 5dd539b866 Fixed JIT memory usage debug info (opcache.jit_debug=0x200) 2021-05-18 15:32:35 +03:00
Dmitry Stogov 94ce76a331 Implemented AArch64 support for GDB/JIT interface.
Stack frame description is not accurate, so backtraces that involved
JIT-ed code may be brocken. Disassemble and breakpoints on JIT-ed code
work fine.
2021-05-18 15:32:35 +03:00
Dmitry Stogov b5aa339cfd Reenable PROFITABILITY_CHECKS 2021-05-18 15:32:35 +03:00
Dmitry Stogov da2bed357a Fixed incorrect range check (missed sign bit) 2021-05-18 15:32:35 +03:00
Hao Sun 1a6bcd0f80 Fix commit 8143a49: macro ADD_SUB_64_WITH_CONST_32 should be used
"(struct.._offset+offsetof(zend_..struct, field))" might exceed the
range of ADD_SUB_IMM, leading to DynASM error DASM_S_RANGE_I for
ZTS+CALL test variant.

Using macro ADD_SUB_64_WITH_CONST_32 would fix it.

Change-Id: I3233cefbcd1ddea16e7de6725c2dc5ff43373916
2021-05-18 15:32:35 +03:00
Dmitry Stogov 44220c5380 Fixed incorrect stack size calculation (sizeof(zval) == 16) 2021-05-18 15:32:34 +03:00
Dmitry Stogov 0b79199500 Peephole Code Optimization:
ldr + sxtw -> ldrsw
lsl + add/sub/cmp -> add/sub/cmp (shifted register)
LOAD_64BIT_VAL + add -> ADD_SUB_64_WITH_CONST
2021-05-18 15:32:34 +03:00
Dmitry Stogov 00270c6c01 Use better code for prologue and fix code generaion for "return -1". 2021-05-18 15:32:34 +03:00
Dmitry Stogov 3014cf4add Fix compilation warnings 2021-05-18 15:32:34 +03:00
Dmitry Stogov ee08686f7c Fixed JIT failure on Zend/tests/bug43175.phpt ZTS build, CALL VM. 2021-05-18 15:32:34 +03:00
Hao Sun fd3f247bda Revert the macro uses for Z_TYPE_P(val) in commit 1fff62b
As suggested by Dmitry, macro CMP_32_WITH_CONST is not necessary because
Z_TYPE_P(val) is of uchar type and it can be encoded as the imm field of
'cmp' instruction directly.

Change-Id: Icb8f9ee847b9a08cb1e9127e7faf6c89d1431922
2021-05-18 15:32:34 +03:00
Dmitry Stogov 59622d9ff2 Fixed profile based JIT (opcache.jit=1225) 2021-05-18 15:32:34 +03:00
Hao Sun 2de4a93d21 Fix commit 6e344ed: temporary register should be kept for GET_ZVAL_LVAL
Macro GET_ZVAL_LVAL is optimized in commit 6e3443d, using 'reg' as the
temporary register. However, the assertion would fail for "jit=1205".

This patch reverts this optimization for GET_ZVAL_LVAL.

Change-Id: Iecb134fa9438ef993e6393974caa5710657a462e
2021-05-18 15:32:34 +03:00
Hao Sun 77ecce7a60 Use fewer temporary registers if possible
For macro "SAFE_MEM_ACC_WITH_UOFFSET* ldr/ldrb", the target register can
be used as temporary register to load the offset if needed. Hence one
temporary register is saved for macros LONG_CMP, GET_ZVAL_LVAL,
CMP_ZVAL_TYPE, IF_ZVAL_TYPE and IF_NOT_ZVAL_TYPE.

Change-Id: I43f35186cec9a4157bc73b1cae6643aa59140de2
2021-05-18 15:32:34 +03:00
Hao Sun 65b834a686 Improve macro LONG_ADD_SUB_WITH_IMM
Offset "Z_OFFSET(op1_addr)" might be loaded into temporary registers for
two times, i.e. by these two SAFE_MEM_ACC_WITH_UOFFSET respectively.

This patch removes this case.

Change-Id: Ib1fde9c9a39f6b5f1ca322dc27b0a9d9d51fbef0
2021-05-18 15:32:34 +03:00
Hao Sun b6e9259620 Remove the deprecated macros
Macros PUSH_BASE_ADDR, PUSH_ADDR_ZTS, GET_ZVAL_W2, SET_ZVAL_W2,
IS_32BIT, PUSH_ADDR and PUSH_ZVAL_ADDR are 32-bit platform dependent in
the x86 implementation, hence they are derepcated in AArch64.

Macro ADDR_OP1 is only used by PASH_* macros, and it is deprecated in
AArch64.

Macros MEM_OP3_3 and AVX_OP are platform dependent and they are not used
in AArch64.

Macro LONG_OP_WITH_32BIT_CONST is replaced with LONG_ADD_SUB_WITH_IMM.

Macro DOUBLE_OP is not used because we use temporary FP register to load
the value from address firstly and then conduct FP math operations with
the help of DOUBLE_MATH_REG.

Macro LONG_MUL is deprecated. MUL between two LONG values is implemented
in a different way from ADD or SUB mainly because extra temporary
register is needed in order to detect integer overflow. See function
zend_jit_math_long_long().

Change-Id: I249f28820aaa86c7638ecf3eee08f8750a232397
2021-05-18 15:32:34 +03:00
Hao Sun 4c6d317730 Use macros CMP_*_WITH_CONST if possible
Macros CMP_*_WITH_CONST were introduced in [1]. We revisit all the uses
of 'cmp' instructions with constants, and apply these macros if
possible.

[1] https://github.com/php/php-src/commit/66ba9af

Change-Id: Idd233cb9afba84dd106fcc5ee8bf5417d91989c7
2021-05-18 15:32:34 +03:00
Hao Sun 8c794128be Use ADD_SUB_IMM for macros ADD_SUB_*_WITH_CONST*
Macros ADD_SUB_*_WITH_CONST* were introduced in [1], but it would be
more accurate to use ADD_SUB_IMM even though ADD_SUB_IMM == CMP_IMM.

Regarding the definition of ADD_SUB_IMM, the comment is updated since it
is used to guard 'subs' and adds' instructions as well.

[1] https://github.com/php/php-src/commit/0609b97

Change-Id: I102ebbf626a438da061f6c01b01029807de1ff14
2021-05-18 15:32:34 +03:00
Hao Sun b019ffe59c Don't use TMP3 except ZTS
Currently temporary register TMP3 is used in particular for ZTS mode.
Hence it would be better not to use it in other sites except ZTS.

In this patch, the value in TMP1, i.e. "REG1 + IP", might be clobbered
and should be calcauted again.

Change-Id: I17434d4f4b8d6f1e71f49eadb42e06db975d7bbe
2021-05-18 15:32:34 +03:00
Dmitry Stogov 609c3bee2e 'lea' -> 'add' 2021-05-18 15:32:34 +03:00
Dmitry Stogov 7ece98f2f4 Use proper macro 2021-05-18 15:32:33 +03:00
Dmitry Stogov fc377742a6 Fix compilation warning 2021-05-18 15:32:33 +03:00
Dmitry Stogov 123df80d40 Use B/BL intead of BR/BLR if possible 2021-05-18 15:32:33 +03:00
Dmitry Stogov ce9d59a347 Imroved code for constants loading 2021-05-18 15:32:33 +03:00
Dmitry Stogov 6036d159fb Imroved code for CV initialization 2021-05-18 15:32:33 +03:00
Dmitry Stogov db25a6ed16 Use single instruction 2021-05-18 15:32:33 +03:00
Dmitry Stogov 38474a4144 Use less temporary registers 2021-05-18 15:32:33 +03:00
Dmitry Stogov 731456a68e Introduce ADD_SUB_64_WITH_CONST/ADD_SUB_64_WITH_CONST_32/ADD_SUB_32_WITH_CONST macros 2021-05-18 15:32:33 +03:00
Dmitry Stogov 1df56b2873 Introduce CMP_64_WITH_CONST/CMP_64_WITH_CONST_32/CMP_32_WITH_CONST macros 2021-05-18 15:32:33 +03:00
Dmitry Stogov 2c147fe5eb Optimize AArch64 code generator
- use cbz/cbnz for comparison with zero
- use xzr/wzr instead of #0 in mov/cmp
- use "subs" imstead of "sub x1,...; cmp x1, xzr"
- avoid loading immediate value to register when it may be direclu used
  as a source immendiate operand in ldr*/str*/add*/sub*/cmp
2021-05-18 15:32:33 +03:00
Dmitry Stogov 6b50c390a6 Improve code for MUL overflow detection (less instructions and less
temporary registers)
2021-05-18 15:32:33 +03:00
Dmitry Stogov 186a5277aa Don't optimize MUL into SHIFT if we have to check for overflow 2021-05-18 15:32:33 +03:00
Dmitry Stogov a1389a774c Skip 64-bit related tests on 32-bit platforms 2021-05-18 15:32:33 +03:00
Dmitry Stogov 4a763cf9c1 Temporary disable PROFITABILITY_CHECKS for better test coverage and to
be in parity with AArch64 back-end.
2021-05-18 15:32:33 +03:00
Dmitry Stogov e5b99bc691 Fixed signed/unsigned comparison mess and add one missing case 2021-05-18 15:32:33 +03:00
Dmitry Stogov 34f1fdc0ee Moved tests from ext/opcache/tests/jit/arm64 to ext/opcache/tests/jit 2021-05-18 15:32:32 +03:00
Hao Sun 2bbeb7b0f5 Revisit 32-bit logical operations with constants
Add macro "BW_OP_32_WITH_CONST" for safe 32-bit logical operations with
constants.

Add macro "GET_LOW_8BITS" for 'and' operation with "0xff".

Change-Id: I57968069b43ac4c02d876e9290433a74b9d87742
2021-05-18 15:32:32 +03:00
Dmitry Stogov 03466cf55f Fixed signed/unsigned comparison mess 2021-05-18 15:32:32 +03:00
Dmitry Stogov 74beb3122b Remove useless SAFE_MEM_ACC_WITH_UOFFSET* 2021-05-18 15:32:32 +03:00
Dmitry Stogov 20e33e2ab4 Use TST_32_WITH_CONST macro 2021-05-18 15:32:32 +03:00
Dmitry Stogov 2b9c2886c5 ZREG_REG0 is not available in x86 build 2021-05-18 15:32:32 +03:00
Dmitry Stogov 412c172ac6 Attempt to fix Windows build 2021-05-18 15:32:32 +03:00
Dmitry Stogov f5d844b9cb Fixed register allocation.
This fixes ext/standard/tests/math/acos_basic.phpt with tracing JIT.
2021-05-18 15:32:32 +03:00
Dmitry Stogov c114e49100 Support for tracing JIT 2021-05-18 15:32:32 +03:00
Dmitry Stogov cde0abbbba Support for tracin JIT (incomplete, but abble to run Zend/bench.php) 2021-05-18 15:32:32 +03:00
Dmitry Stogov f49a7817be Fixed assertion 2021-05-18 15:32:32 +03:00
Hao Sun d96fe3de9b Add the missing parts for macros ZVAL_COPY_CONST and ZVAL_COPY_CONST_2
This patch adds the missing parts.

Change-Id: I5ce0128a2ebf7cf73ec109d44dc4aabfd02260f2
2021-05-18 15:32:32 +03:00
Hao Sun cba81db696 Fix incorrect macro LDR_STR_PIMM
The 'pimm' field of ldr/str instruction has different maximum values for
32-bit register and 64-bit register.

Change-Id: I14b4f1eedbcbb303696c22c1403b49d52426d390
2021-05-18 15:32:32 +03:00
Dmitry Stogov 9d809ff366 Implement trace patching 2021-05-18 15:32:32 +03:00
Dmitry Stogov 0f65a188d1 Fixed incorrect register usage 2021-05-18 15:32:32 +03:00
Dmitry Stogov 625e9cb229 Implement obvious trace side exits 2021-05-18 15:32:32 +03:00
Hao Sun 6a94b8b7b3 Support ZEND_JIT_ON_HOT_COUNTERS mode
This patch implements stub functions zend_jit_hybrid_hot_code_stub() and
zend_jit_hybrid_hot_counter_stub(), which is needed by HOT COUNTER mode,
i.e. 'opcache.jit=123x'.

Test case "defined_001.phpt" can pass now since HOT COUNTER mode is
required by this case.

Change-Id: I66efb07c75fc64723dc76eff533d024c868f8022
2021-05-18 15:32:31 +03:00
Hao Sun ee921d29a9 Support ZEND_JIT_ON_PROF_REQUEST mode
This patch implements function zend_jit_hybrid_profile_jit_stub(), which
is needed by ZEND_JIT_ON_PROF_REQUEST mode, i.e. 'opcache.jit=122x'.

Change-Id: Icb591c81675ffc077180229362882278ac8406c6
2021-05-18 15:32:31 +03:00
Hao Sun 5e05c70ee7 Optimizing LONG MUL to SHIFT: add overflow detection for x86
Similar to the AArch64 implementation, we compare "op" and "op << n >>
n" to detect integer overflow.

Note that instructions 'pushf' and 'popf' are used to save/restore the
flags set by 'cmp', otherwise, the follow-up 'shl' might change the
flags.

Note that test case "mul_004.phpt" can pass now for x86.

Change-Id: Ieee037f41dce298979b8a0964ca97598939c495c
2021-05-18 15:32:31 +03:00
Hao Sun 999720bf3a Remove the unnecessary 'bvs' check for IS_NOT_IDENTICAL case
This 'bvs' can be removed since the follow-up 'bne' also checks NaN.[1]

[1]
https://community.arm.com/developer/ip-products/processors/b/processors-ip-blog/posts/condition-codes-4-floating-point-comparisons-using-vfp

Change-Id: Ie67db499c6be39ae4b339db533f51dacaeab4e4c
2021-05-18 15:32:31 +03:00
Dmitry Stogov 2c90fe1d85 Fixed some compilation warnings 2021-05-18 15:32:31 +03:00
Dmitry Stogov c119817441 Enable register allocator (it was disabled because ZREG_NUM wasn't
available for preprocessor) and fix few related problems.
2021-05-18 15:32:31 +03:00
Dmitry Stogov 735e4ccf5e Support for ZTS 2021-05-18 15:32:31 +03:00
Dmitry Stogov 997374f41c Disable "red zone" usage (it leads to crashes). 2021-05-18 15:32:31 +03:00
Dmitry Stogov 57f2fe44c6 Use "red zone" for HYBRID VM.
Support for CALL VM and VM without global register variables.
2021-05-18 15:32:31 +03:00
Dmitry Stogov 39e80971c7 Make bit helpers to be inline 2021-05-18 15:32:31 +03:00
Dmitry Stogov add2544e1c Missed instruction 2021-05-18 15:32:31 +03:00
Dmitry Stogov 434eb1a3d9 Duplicate return 2021-05-18 15:32:31 +03:00
Dmitry Stogov 91aaea362f typo 2021-05-18 15:32:31 +03:00
Dmitry Stogov 018fca92ad Added missed UNDEF_OPLINE_RESULT 2021-05-18 15:32:31 +03:00
Hao Sun 4039c5865a Add the helper to check whether an immediate is valid for logical instructions
We implement a simplified version. Every value with one single bit can
be encoded for logical instructions and we suppose this quick check can
cover a lot of common masks.

Besides, add macro TST_64_WITH_ONE since it's used often to test 64-bit
register with constant 1.

Change-Id: I850a6ac6acbe2d12f85180e407344580ee6fea61
2021-05-18 15:32:31 +03:00
Hao Sun 86326b5ddb Fix the encoding of immediate for logical instructions
Previous implementation[1] of the immediate encoding for logical
instructions('and/orr/eor/tst') is incorrect. It's more complicated than
that of 'add/sub/ldr/str/movz'.[2]

Ideally a helper is needed to "determine whether an immediate value can
be encoded as the immediate operand of a logical instruction for the
given register size"[3].

Macros "BW_OP_x_WITH_CONST" and "TST_x_WITH_CONST" are defined to wrap
the logical instrunctions with constants. Currently this helper is not
implemented yet.

All the uses of bitwise operations and 'tst' are revisited and updated.

Note that test case bug80745.phpt will pass with this patch.

[1] https://github.com/php/php-src/commit/47d8252
[2]
https://dinfuehr.github.io/blog/encoding-of-immediate-values-on-aarch64/
[3]
https://github.com/llvm-mirror/llvm/blob/5c95b810cb3a7dee6d49c030363e5bf0bb41427e/lib/Target/AArch64/MCTargetDesc/AArch64AddressingModes.h#L213

Change-Id: I0bfa088cafcffe30e0f18fa1f0638338ef00eb20
2021-05-18 15:32:31 +03:00
Hao Sun 06b9eb500f Support failed test case: switch_jumptable.phpt
Opcodes ZEND_SWITCH_LONG, ZEND_SWITCH_STRING and ZEND_MATCH are
supported in this patch.

Change-Id: I71ae3d40e65ec1b29d3d9115ac41caef17cf6ae5
2021-05-18 15:32:30 +03:00
Hao Sun ff72c1575a Remove the TODO comments for DOUBLE CMP
As explained by Dmitry, 'ucomsd' in x86 sets 'p' flag, and it also
always sets 'z' and 'c' flags. [1]

Besides, remove one duplicate 'break'.

[1]. https://mudongliang.github.io/x86/html/file_module_x86_id_316.html

Change-Id: I767214c7ab8db31115801a3ae96b20320757899f
2021-05-18 15:32:30 +03:00
Hao Sun 42bec86a3c Optimizing LONG MUL to SHIFT: refine the trigger condition and add overflow detection
LONG MUL can be optimzied into left shift if either operand is a power
of two. Conditions "IS_SIGNED_32BIT()" and "is_power_of_two()" are used
to filter out invalid candidates. However, there exists one exception,
i.e. -2147483648(that is 0xffff,ffff,8000,0000). See the stand-alone
case[1].

Assume "a = 3; b = -2147483648;". The expected result of "a * b" is one
negative value. However, it would be optimized to "a << 31", which is
positive.

This trigger condition is refined.
1) For x86 implementation, another check for positive numbers is added.
Note that LONG type, i.e. zend_long, is defined as int32_t for x86 arch
and int64_t for x64 arch. This optimization only accepts values which
can be represented by int32_t type as default. See IS_SIGNED_32BIlT(),
2) For AArch64, we employ helper function zend_long_is_power_of_two()
since values of int64_t type are used.

Overflow detection for left shifting is added in this patch as well.

Note 1: bit helper functions are arch-independent and we move them into
zend_jit_internals.h.

Note 2: two test cases are added. Test case mul_003.phpt is used to
check the trigger condition and mul_004.phpt is designed to check
overflow detection.

Note 3: overflow detection for x86 is not implemented yet as I think
anotehr temporay register besides R0 is needed. Hence mul_004.phpt would
fail on x86 machine.
If we can use R1 as tmp_reg, the code can be updated as below.

```
  |	GET_ZVAL_LVAL result_reg, op1_addr
  if (may_overflow) {
    use_ovf_flag = 0;
    /* Compare 'op' and '((op << n) >> n)' for overflow.
     * Flag: jne -> overflow. je -> no overflow.
     */
    tmp_reg = ZREG_R1
    |	mov Ra(tmp_reg), Ra(result_reg)
    |	shl Ra(tmp_reg), floor_log2(Z_LVAL_P(Z_ZV(op2_addr)))
    |	sar Ra(tmp_reg), floor_log2(Z_LVAL_P(Z_ZV(op2_addr)))
    |	cmp Ra(tmp_reg), Ra(result_reg)
  }
  |	shl Ra(result_reg), floor_log2(Z_LVAL_P(Z_ZV(op2_addr)))
```

[1]. https://godbolt.org/z/1vKbfv8oG

Change-Id: Ie90e1d4e7c8b94a0c8f61386dfe650fa2c6879a1
2021-05-18 15:32:30 +03:00
Dmitry Stogov c84cc92633 Fixed type checks and return value handling 2021-05-18 15:32:30 +03:00
Dmitry Stogov 350115196c Create C call frames for helper functions that perform nested calls 2021-05-18 15:32:30 +03:00
Dmitry Stogov 1c6bea8153 Fixed incorrect efree() 2021-05-18 15:32:30 +03:00
Dmitry Stogov cf3c313150 Disable unsuitable optimization 2021-05-18 15:32:30 +03:00
Dmitry Stogov a1bf150b9e Fixed condition and avoid usage of non-temporary registers 2021-05-18 15:32:30 +03:00
Dmitry Stogov b9281168ab Wrong register 2021-05-18 15:32:30 +03:00
Dmitry Stogov 8f98474b5a Fixed type check 2021-05-18 15:32:30 +03:00
Dmitry Stogov c1020c4ecf Support for interupts 2021-05-18 15:32:30 +03:00
Dmitry Stogov 2854043742 Fixed compilation warnings 2021-05-18 15:32:29 +03:00
Dmitry Stogov 23b07035a9 Fixed map_ptr resolution 2021-05-18 15:32:29 +03:00
Dmitry Stogov b4f013a2df Fixed load of incorrect size 2021-05-18 15:32:29 +03:00
Dmitry Stogov 7c6b451ecc Fixed INC/DEC_PROP (tests/classes/incdec_property_*.phpt) 2021-05-18 15:32:29 +03:00
Dmitry Stogov 03537c4602 Temporary diable JIT for SWITCH and MATCH instructions (SWITCH should
work, MATCH is going to fail)
2021-05-18 15:32:29 +03:00
Dmitry Stogov 9776279415 Get rid of NYI in call/return sequences 2021-05-18 15:32:29 +03:00
Dmitry Stogov 1289ebcaab Implement exceptional stubs 2021-05-18 15:32:29 +03:00
Dmitry Stogov b550dbd68b Support for VERIFY_RETURN_TYPE, ISSET_ISEMPTY_CV, IN_ARRAY and ADD with
array operands.
2021-05-18 15:32:29 +03:00
Dmitry Stogov 36358c5a16 Get rid of NIY in spill code 2021-05-18 15:32:29 +03:00
Dmitry Stogov 326c9bf937 Support for PRE/POST_INC/DEC_OBJ 2021-05-18 15:32:29 +03:00
Dmitry Stogov f52ec02ea9 Get rid of testing NIY_STUBs 2021-05-18 15:32:29 +03:00
Dmitry Stogov 761b56ab0f Support for FETCH_THIS, FETCH_OBJ, ASSIGN_OBJ and ASSIGN_OBJ_OP 2021-05-18 15:32:29 +03:00
Dmitry Stogov 09070fa8bc Support for BIND_GLOBAL 2021-05-18 15:32:28 +03:00
Dmitry Stogov 0bfe4da47d Support for TYPE_CHECK 2021-05-18 15:32:28 +03:00
Dmitry Stogov 8c0cb57d9f Support for FETCH_CONST 2021-05-18 15:32:28 +03:00
Dmitry Stogov c86a4af06d Fixed reference-countoing. Use 32-bit registers. 2021-05-18 15:32:28 +03:00
Dmitry Stogov c1f390b983 Support for FE_RESET and FE_FETCH 2021-05-18 15:32:28 +03:00
Dmitry Stogov edf87fda3c Support for moving between allocated registers 2021-05-18 15:32:28 +03:00
Dmitry Stogov 695047369f Support for STRLEN and COUNT 2021-05-18 15:32:28 +03:00
Dmitry Stogov 2aac47b3fb Support for DEFINED 2021-05-18 15:32:28 +03:00
Dmitry Stogov c68ec03f2b Support for FREE and FE_FREE 2021-05-18 15:32:28 +03:00
Dmitry Stogov 7d8ee8a989 Support for missed IS_NOT_IDENTICAL cases 2021-05-18 15:32:28 +03:00
Dmitry Stogov 7d3e0a4af2 Support for ECHO with non-constant operand 2021-05-18 15:32:28 +03:00
Dmitry Stogov d9b2b26e99 Get rid of some NIY traps in DynADM macros 2021-05-18 15:32:28 +03:00
Dmitry Stogov a409eed4bf Support for more cases in INIT_METHOD_CALL, DO_FCALL* and RETURN 2021-05-18 15:32:28 +03:00
Dmitry Stogov 29ff75165d Support for SEND_VAL/SEND_VAR/SEND_REF/CHECK_FUNC_ARG/CHECK_UNDEF_ARGS 2021-05-18 15:32:28 +03:00
Hao Sun cb52d2731c Support LONG MUL with overflow detection
Overflow detection for LONG MUL is added in this patch. Quite different
from 'subs' and 'adds' where overflow can be easily checked via the V
flags, LONG MUL wouldn't set the flags.

We use 'smulh' instruction to get the upper 64 bits of the 128-bit
result and check the top 65 bits to tell whether integer overflow
occurs. [1]

Note that LONG MUL can be substituted by 'adds' or 'lsl' in some cases.
Hence, flag 'use_mul' is introduced in order to select the proper
overflow check check instruction afterwards.

[1]
https://community.arm.com/developer/ip-products/processors/b/processors-ip-blog/posts/detecting-overflow-from-mul

Change-Id: I67e8287e9044c2a96b188d4bf6674736713abfe9
2021-05-18 15:32:28 +03:00
Dmitry Stogov 0482102b04 Support for ASSIGN_DIM_OP 2021-05-18 15:32:28 +03:00
Dmitry Stogov 09647a0a90 Support for ASSIGN_OP 2021-05-18 15:32:27 +03:00
Dmitry Stogov e6d0a220f3 Support for ISSET_DIM 2021-05-18 15:32:27 +03:00
Dmitry Stogov be81cad827 Accurate RETVAL register usage 2021-05-18 15:32:27 +03:00
Dmitry Stogov 065948c19f Fixed copy/paste error 2021-05-18 15:32:27 +03:00
Dmitry Stogov 113e94f29a Fixed incorrect register usage 2021-05-18 15:32:27 +03:00
Dmitry Stogov e5e83e2ff3 Don't use FPR1 for consistency with x86 2021-05-18 15:32:27 +03:00
Dmitry Stogov 5800ea9a57 Support for FETCH_DIM* and ASSIGN_DIM (exception handling is incomplete) 2021-05-18 15:32:27 +03:00
Dmitry Stogov f2c161eda0 Support for IS_IDENTICAL/IS_NOT_IDENTICAL 2021-05-18 15:32:27 +03:00
Dmitry Stogov c826f3f1df Fixed copy/paste error 2021-05-18 15:32:27 +03:00
Dmitry Stogov 49286d92c9 Support for BOOL/BOOL_NOT with DOUBLE operand 2021-05-18 15:32:27 +03:00
Dmitry Stogov 17a404747d Support for comparison opcodes 2021-05-18 15:32:27 +03:00
Dmitry Stogov c55af8d828 Support for CONCAT 2021-05-18 15:32:27 +03:00
Dmitry Stogov aa01684b01 Support for INC/DEC 2021-05-18 15:32:27 +03:00
Dmitry Stogov bd26aea30b Fixed possible incorrect assumption if constant is a power of 2. 2021-05-18 15:32:27 +03:00
Dmitry Stogov 196928a8b3 Remove dead conditions 2021-05-18 15:32:27 +03:00
Dmitry Stogov 44c35078ea Support for LONG math (except of MUL overflow detection) 2021-05-18 15:32:27 +03:00
Hao Sun 36b5caa6b9 Revisit the encoding of immediate
Immediates in different lengths are used by AArch64 instructions.
Previous use of MAX_IMM12 is not accurate.

Note that immediate value can be optionally shifted and this mode is not
supported currently. We may want to support this in the near future.
2021-05-18 15:32:27 +03:00
Hao Sun 3f292dcb47 Remove the duplicate macro DOUBLE_GET_ZVAL_DVAL
We have defined macro GET_ZVAL_DVAL to replace the SSE_GET_ZVAL_DVAL in
x86 implementation. Hence, macro DOUBLE_GET_ZVAL_DVAL is not needed.
2021-05-18 15:32:26 +03:00
Hao Sun 191fb2a364 Updates for commits between 121a0f7 and 12dcf34
1. Pre-allocated bytes are missing in function
zend_jit_assign_const_stub().

2. 'w' register should be used for macro SET_ZVAL_TYPE_INFO.

3. 'w' register should be used to load "num_args" in function
zend_jit_do_fcall().

4. Remove the local path name in test case recv_002.phpt

5. One option is disabled temporarily in [1] and several test cases
would fail, e.g. shift_right_003.phpt. I suppose new execution paths are
touched. We will support them in the near future.

[1] https://github.com/php/php-src/commit/63d673d
2021-05-18 15:32:26 +03:00
Dmitry Stogov 4e291d8d83 Support for DOUBLE math 2021-05-18 15:32:26 +03:00
Dmitry Stogov 621830e46e Support for most cases of BOOL/BOOL_NOT/JMPZNZ/JMP[N]Z_EX 2021-05-18 15:32:26 +03:00
Dmitry Stogov ecee82c4ff Support for passing extra arguments.
Fixed ext/opcache/tests/jit/recv_001.phpt
2021-05-18 15:32:26 +03:00
Dmitry Stogov 73d5f43d8c Support for RECV/RECV_INIT 2021-05-18 15:32:26 +03:00
Dmitry Stogov 67b03e4a00 Support for bitwise operations with non-integer arguments 2021-05-18 15:32:26 +03:00
Dmitry Stogov b0c488a237 Support for bitwise operations with the same operands ($a ^ $a) 2021-05-18 15:32:26 +03:00
Dmitry Stogov f1c89c3900 Support for IS_LONG SUB and XOR. 2021-05-18 15:32:26 +03:00
Dmitry Stogov 63d674525b Support for missed case in zend_jit_tail_handler().
Fixed ext/opcache/tests/jit/ignored_opcodes.phpt
2021-05-18 15:32:26 +03:00
Dmitry Stogov 5d5c165a7b Support for most "uncommon" ASSIGN cases 2021-05-18 15:32:26 +03:00
Dmitry Stogov b12340fc46 Added tests for ASSIGN 2021-05-18 15:32:26 +03:00
Dmitry Stogov c12157700a Trmporary disable PROFITABILITY_CHECKS for better test coverage 2021-05-18 15:32:26 +03:00
Dmitry Stogov f24a8a2a24 Avoid useless "flags" byte extraction (it was inspired by unsuitable x86
specific optimization)
2021-05-18 15:32:25 +03:00
Dmitry Stogov ea15f90833 Use NIY_STUB instead of NIY in stubs 2021-05-18 15:32:25 +03:00
Dmitry Stogov 72981bf004 Replace "brk #0" with "NIY" (Not Implemented Yet) macro 2021-05-18 15:32:25 +03:00
Hao Sun 3bbc9fdfaf Support failed JIT test case: reg_alloc_002.phpt
Opcodes FE_RESET_R and FE_FETCH_R are met for the first time. Updates in
funtions zend_jit_fe_reset() and zend_jit_fe_fetch() are made to support
them.

Besides, one new path is covered in function zend_jit_inc_dec() for
opcode POST_INC.
2021-05-18 15:32:25 +03:00
Hao Sun c8c4132811 Support failed JIT test case: reg_alloc_003.phpt
Opcodes for $test are:

  BB0:
  0000 #1.CV0($char_code) [rc1, rcn, any] = RECV 1

  BB1:
  0001 #2.T1 [rc1, ...] = BW_AND #1.CV0($char_code) ...
  0002 #3.T2 [bool] RANGE[0..1] = BOOL_NOT #2.T1 [rc1, ...]
  0003 #4.T1 [bool] RANGE[0..1] = IS_EQUAL #1.CV0($char_code) ...
  0004 JMPZ #4.T1 [bool] RANGE[0..1] BB3
  ...

New path is covered in function zend_jit_long_math_helper() for opcode
BW_AND.

New path is covered in function zend_jit_bool_jmpznz() for opcode
BOOL_NOT.

Major changes lie in functions zend_jit_cmp(), zend_jit_cmp_slow() and
zend_jit_check_exception_undef_result() to support opocdes IS_EQUAL and
JMPZ.
2021-05-18 15:32:25 +03:00
Hao Sun f133644796 Support failed JIT test case: jmpz_ex_001.phpt
Opcodes for $Test::method are:

  BB0:
  0000 #0.T0 [rcn, any] = FETCH_OBJ_R THIS string("prop")
  0001 #1.T0 [bool] RANGE[0..1] = JMPZ_EX #0.T0 [rcn, any] BB3

  BB1:
  0002 #2.T1 [rcn, any] = FETCH_OBJ_R THIS string("prop")
  0003 INIT_METHOD_CALL 0 #2.T1 [rcn, any] string("method2")
  0004 #3.V1 [ref, rc1, rcn, any] = DO_FCALL
  ...

New path is covered in functions zend_jit_fetch_obj() and
zend_jit_zval_copy_deref() for FETCH_OBJ_R THIS opcode.

New path is covered in function zend_jit_init_method_call() for opcode
INIT_METHOD_CALL.

Major chagnes lie in function zend_jit_bool_jmpznz() to support opcode
JMPZ_EX.

Note that macro ZVAL_DTOR_FUNC is updated to remove the hard-coded use
of REG0.
2021-05-18 15:32:25 +03:00
Hao Sun 0a975548b0 Support failed JIT test case: jmpz_001.phpt
Opcode SEND_VAR_EX used in $test and opcode ZEND_SEND_VAR_NO_REF_EX used
in $main cover two new branches in function zend_jit_send_var()
respectively.

The updates in function zend_jit_bool_jmpznz() are made to support
opcode JMPNZ_EX used in $test.
2021-05-18 15:32:25 +03:00
Hao Sun 7309d5a705 Support failed JIT test case: send_var_ex_001.phpt
Opcodes for function $evaluate are:

  BB0:
  0000 ASSIGN_OBJ THIS string("evalParameters")
  0001 OP_DATA array(...)
  0002 INIT_NS_FCALL_BY_NAME 2 string("A\extract")
  0003 CHECK_FUNC_ARG 1
  0004 V1 = FETCH_OBJ_FUNC_ARG (ref) THIS string("evalParameters")
  0005 SEND_FUNC_ARG V1 1
  0006 T1 = FETCH_CONSTANT (unqualified-in-namespace) ...
  0007 SEND_VAL_EX T1 2
  0008 DO_FCALL_BY_NAME
  ...

Major changes are made in function zend_jit_fetch_constant() to support
FETCH_CONSTANT opcode.

Besdies, cold code is touched in functions zend_jit_check_func_arg() and
zend_jit_send_var() for opcodes CHECK_FUNC_ARG and SEND_FUNC_ARG
respectively.
2021-05-18 15:32:25 +03:00
Hao Sun 4c872ba24a Support failed JIT test case: send_val_001.phpt
Updates in function zend_jit_type_check() are made to support TYPE_CHECK
opcode for statement "is_array($type)".

New path is touched in function zend_jit_concat_helper() to support
opcode CONCAT for statement "$type ."ops"".

Besides, one new path is covered in function zend_jit_return() when
leaving.
2021-05-18 15:32:25 +03:00
Hao Sun f11b4407fb Support failed JIT test case: send_ref_001.phpt
Part of generated opcodes for $foo are:

  ...
  BB1:
  0002 INIT_FCALL 1 96 string("foo")
  0003 #5.V1 [rcn, object (instanceof A)] = FETCH_THIS
  0004 SEND_REF #5.V1 [rcn, object (instanceof A)] 1
  0005 DO_UCALL

Updates in functions zend_jit_fetch_this() and zend_jit_load_this() are
made to support FETCH_THIS opcode.

One new path is covered in function zend_jit_send_ref()  by SEND_REF
opcode.
2021-05-18 15:32:25 +03:00
Hao Sun bb67754722 Support failed JIT test case: mod_001.phpt
Instructions 'cqo' + 'idiv' are used in x86 to conduct MOD operation.
Specific registers RDX:RAX are used.

We use instructions 'sdiv' + 'msub' to accomplish the equivalent
functionality[1], and there is no such contrain on registers.

Similary to left/right shift operations in the previous patches,
boundary values, i.e. the second operand is 0 or -1, are handled.

[1]
https://stackoverflow.com/questions/35351470/obtaining-remainder-using-single-aarch64-instruction
2021-05-18 15:32:25 +03:00
Hao Sun bddad32201 Support failed JIT test case: shift_right_003.phpt
The following opcodes would be generated:

  ...
  BB1:
  0003 JMP BB3

  BB2:
  0004 INIT_FCALL 1 96 string("chr")
  0005 #10.T3 [long] = SR #3.CV0($int) [long] #7.CV2($i) ...
  0006 #11.T4 [long] RANGE[0..127] = BW_AND #10.T3 [long] ...
  0007 #12.T3 [long] RANGE[128..255] = BW_OR #11.T4 [long] ...
  0008 SEND_VAL #12.T3 [long] RANGE[128..255] 1
  0009 #13.V3 [ref, rc1, rcn, any] = DO_ICALL
  0010 ASSIGN_OP (CONCAT) #6.CV1($out) [rc1, rcn, string]
  0011 ADD #7.CV2($i)... int(7) #7.CV2($i) ... -> #15.CV2($i) ...

  BB3:
  0012 #8.T4 [long] = SR #3.CV0($int) #7.CV2($i) [long, double]
  0013 #9.T3 [bool] RANGE[0..1] = IS_SMALLER int(128) #8.T4
  0014 JMPNZ #9.T3 [bool] RANGE[0..1] BB2
  ...

Main changes are:
1. SR opcode covers new path in function zend_jit_long_math_helper().
2. BW_AND and BW_OR opcodes are supported. See macro LONG_OP.
3. Function zend_jit_concat_helper() is added to support ASSIGN_OP
opcode. Speficically, CONCAT and FAST_CONCAT is supported for statements
"$out .= ...".
4. New path is covered in function zend_jit_cmp_long_long() by
IS_SMALLER opcode.
5. New path is covered in macros ZVAL_PTR_DTOR and ZVAL_DTOR_FUNC when
leaving.
2021-05-18 15:32:25 +03:00
Hao Sun 2f7f11d06f Support failed JIT test case: shift_right_001.phpt
Similar to left shift, it's trivial to support right shift.

Note that bot shift_right_001.phpt and shift_right_002.phpt can pass
with this patch.
2021-05-18 15:32:25 +03:00
Hao Sun 17d0be85ee Support failed JIT test case: shift_left_002.phpt
This patch handles the case where the second operand is constant.
2021-05-18 15:32:24 +03:00
Hao Sun 1d4fdbd4e9 Support failed JIT test case: shift_left_001.phpt
This patch supports SL opcode. The range of the second operand is
checked against 0 and 64. If the second operand is negative, exception
would be raised. If the second operand is >= 64, the result is 0.

Besides, new path in macro ZVAL_COPY_VLAUE is covered for RETURN opcode.
2021-05-18 15:32:24 +03:00
Hao Sun a5f7af2b2a Support failed JIT test case: cmp_003.phpt
This test case is a big one. This patch mainly handles
smart_branch_opcode cases in function zend_jit_cmp_double_common().

Note that I failed to construct test cases to verify whether the missing
NaN check in x86 is buggy or not. One TODO is left to remind us when the
relevant code is touched.
2021-05-18 15:32:24 +03:00
Hao Sun f8a275d685 Support failed JIT test case: cmp_004.phpt
The following opcodes would be generated for $foo:

  0000 #2.CV0($test) [bool] RANGE[0..1] = RECV 1
  0001 #3.CV1($x) [long] RANGE[MIN..MAX] = RECV 2
  0002 JMPZ #2.CV0($test) [bool] RANGE[0..1] BB4
  0003 #4.T2 [bool] ... = IS_SMALLER_OR_EQUAL int(1) #3.CV1($x) ...
  0004 JMP BB5
  ...

The updates in function zend_jit_verify_arg_type() are made to support
RECV opcode.

The updates in function zend_jit_bool_jmpznz() are made to support JMPZ
opcode.

New path is covered in functions zend_jit_cmp() and
zend_jit_cmp_long_long() for IS_SMALLER_OR_EQUAL opcode.
2021-05-18 15:32:24 +03:00
Hao Sun b3519ad59d Support failed JIT test case: cmp_002.phpt
'smart_branch_opcode' JMPZ is used in this test case. Similar to the
previous patch, I still didn't get why NaN check is missing for the
cases ">" and ">=". In our implementation, we add such checks.
2021-05-18 15:32:24 +03:00
Hao Sun 91f4171577 Support failed JIT test case: cmp_001.phpt
Comparison between LONG and DOUBLE is (partially) supported in a similar
way to comparison between two LONG values. See the updates in function
zend_jit_cmp().

Key difference lies in handling NaN.

1. Instruction 'fcmp' is used to substitue 'ucomisd' in x86
implementation. Both of them raise invalid operation exception only when
either source operand is an SNaN.[1][2]

2. Parity flag is used in x86 to check whether either operand is NaN.[3]
I think this is QNaN case. As for AArch64, we use instruction 'bvs'.[4]

It's worthing noting that condition codes have different meanings for
floating-point comparions(e.g. 'fcmp')[4] compared to the
general-purpose comparisons(e.g. 'cmp').[5] For instance, 'b.hs' after
'fcmp' can check not only the cases "greater than, equal to" but also
the case "unordered"(that is NaN). We may simply treat it as a
combination of  'jae' and 'jp' in x86.

3. Instruction 'SETcc' is used in x86 for the case of ">=" or ">".
Note that flag "swap" is set in implementation, and it falls into cases
ZEND_IS_SMALLER or ZEND_IS_SMALLER_OR_EQUAL. We can use 'cset' in
AArch64.

However, it's weird that the NaN check is missing in x86. I suppose it
might be a bug. Take the case ">=" as an example. The two operands can
be  either DOUBLE + LONG or DOUBLE + DOUBLE. See the relevant code where
flag "swap" is set(i.e. function zend_jit_cmp_double_long() and function
zend_jit_cmp_double_double()). For the case "NaN >= 1.0", the expected
result should be FALSE, however, JIT/x86 would produce TRUE due to the
following "setae al". Unfortunately I haven't constructed one test case
to trigger that.

In our implementation, we choose to follow the case of "<" or "<=", and
I believe our implementation is safe anyway..

4. Temporary FP register is also needed and we reserve v16. See the
updates in file zend_jit_arm64.h.

5. Macro SET_ZVAL_TYPE_INFO_FROM_REG is misused in function
zend_jit_zval_copy_deref(). The second argument should be 32-bit long
and we fix it.

Note that simple test cases involving NaN are tested locally. I believe
it would get deeper testing by cmp_003.phpt(we will support it later).

[1]
https://developer.arm.com/documentation/dui0204/f/vector-floating-point-programming/vfp-instructions/fcmp?lang=en
[2] https://www.felixcloutier.com/x86/ucomisd
[3] https://en.wikipedia.org/wiki/Parity_flag
[4]
https://community.arm.com/developer/ip-products/processors/b/processors-ip-blog/posts/condition-codes-4-floating-point-comparisons-using-vfp
[5]
https://community.arm.com/developer/ip-products/processors/b/processors-ip-blog/posts/condition-codes-1-condition-flags-and-codes
2021-05-18 15:32:24 +03:00
Hao Sun e78e9a6e10 Support failed JIT test case: fetch_obj_001.phpt
This test case is a big one. Major changes are:

1. statement "foo($obj->a)"
One new path is covered in function zend_jit_fetch_obj() for the
involved FETCH_OBJ_W opcode. See the update around label 5.
Opcode SEND_REF is used. The updates in function zend_jit_send_ref() are
made to support it. Note that macro FREE_OP is executed for the first
time. Temproray registers are passed since they are used inside. As a
result, its use sites are updated accordingly.

2. statement "$a = array()" in $foo2
One new path in function zend_jit_assign_to_variable() is covered.

3. statements involving variable $d in $bar
One new path in function zend_jit_fetch_obj() is covered. See the
updates around label 7.

Note that in macro EMALLOC, condition ZEND_DEBUG can be covered by DEBUG
build, i.e. "./configure --enable-debug".
2021-05-18 15:32:24 +03:00
Hao Sun b7f7df6c06 Fix one bug in macro IF_GC_MAY_NOT_LEAK
Instruction is misused. 'dword', i.e. 32 bits, are loaded from memory.
Hence, 'ldr' should be used rather than 'ldrh'.
2021-05-18 15:32:24 +03:00
Hao Sun 9512fa4c06 Add necessary assertions on range for INIT_FCALL and DO_FCALL
Range checks are needed before encoding them into AArch64 instructions
as immediates.
2021-05-18 15:32:24 +03:00
Dmitry Stogov c8b2fa72b4 JIT/AArch64: INIT_FCALL and DO_FCALL support for optimized function code-generation (1204/1205) 2021-05-18 15:32:24 +03:00
Dmitry Stogov 1f9f1b3216 Replace --SKIPIF-- by --EXTENSIONS-- 2021-05-18 15:32:24 +03:00
Hao Sun 97766b6b28 Support failed JIT test case: fetch_obj_003.phpt
Opcode ASSIGN_OBJ_OP is used for statement "$x->a += 2;". The updates in
function zend_jit_assign_obj_op() are made to support this opcode.
2021-05-18 15:32:24 +03:00
Hao Sun 27ddf3f12b Support failed JIT test case: fetch_obj_002.phpt
One new path is covered inside function zend_jit_fetch_obj() due to the
use of FETCH_OBJ_R opcode. Note that function zend_jit_zval_copy_deref()
is invoked along this new path.

Updates in function zend_jit_free() are made to support FREE opcode.

Stub function zend_jit_leave_function_stub() is touched for the first
time.
2021-05-18 15:32:24 +03:00
Hao Sun ad5328b9fe Support failed JIT test case: fetch_obj_004.phpt
Opcode ASSIGN_OBJ is generated for statement "$x->a = 1;" and one new
path in function zend_jit_assign_obj() is covered. Note that function
zend_jit_assign_to_variable_call() is invoked along this new path.

Besides, helper function zend_objects_store_del() is used as the dtor
for objects.
2021-05-18 15:32:24 +03:00
Hao Sun ee4a429609 Support failed JIT test case: fetch_dim_rw_001.phpt
Opcode FETCH_DIM_RW is not touched before and the udpates in function
zend_jit_fetch_dim() and zend_jit_fetch_dimension_address_inner() are
made to support it.

Besides, one new path is covered in function zend_jit_return() when
leaving.
2021-05-18 15:32:24 +03:00
Hao Sun c5d6fc0363 Support failed JIT test case: fetch_dim_r_002.phpt
The opcodes for function $foo are:

  0001 INIT_FCALL 1 96 string("var_dump")
  0002 #2.T1 [null, long] = FETCH_DIM_R array(...) #1.CV0($n) [...]
  0003 SEND_VAL #2.T1 [null, long] 1
  0004 DO_ICALL
  0005 RETURN null

Opcode FETCH_DIM_R is not touched before, and the updates in function
zend_jit_fetch_dim_read() are made to support it.
As different types of arguments are used for $foo, several cases in
function zend_jit_fetch_dimension_address_inner() are covered as well.

Besides, opcode DO_ICALL can reach one site of cold code in function
zend_jit_do_fcall().
2021-05-18 15:32:24 +03:00
Hao Sun 99118a6931 Support failed JIT test case: fetch_dim_func_args_001.phpt
1. For statement "$a->change($a = array("a" => range(1, 5)));", the
following opcodes will be generated:

  0002 ASSIGN CV0($a) V1
  0003 INIT_METHOD_CALL 1 CV0($a) string("change")
  0004 INIT_NS_FCALL_BY_NAME 2 string("A\range")
  0005 SEND_VAL_EX int(1) 1
  0006 SEND_VAL_EX int(5) 2
  0007 V1 = DO_FCALL_BY_NAME

The updates in function zend_jit_init_fcall(), zend_jit_send_val() and
zend_jit_do_fcall() are made to support INIT_NS_FCALL_BY_NAME,
SEND_VAL_EX and DO_FCALL_BY_NAME respectively.

2. For method $change(), opcode RECV is used to obtain the argument:

  0000 #1.CV0($config) [rc1, rcn, array of [any, ref]] = RECV 1

Accordingly the updates in functions zend_jit_recv() and
zend_jit_verify_arg_type() are made.

3. For statement "array_keys($config["a"])", the following opcodes will
be generated:

  0001 INIT_NS_FCALL_BY_NAME 1 string("A\array_keys")
  0002 CHECK_FUNC_ARG 1
  0003 #3.V1 [ref, rc1, rcn, any] = FETCH_DIM_FUNC_ARG #1.CV0($config)
     ... -> #2.CV0($config) [rc1, rcn, ...
  0004 SEND_FUNC_ARG #3.V1 [ref, rc1, rcn, any] 1
  0005 #4.V1 [ref, rc1, rcn, any] = DO_FCALL_BY_NAME

CHECK_FUNC_ARG and SEND_FUNC_ARG are not supported before. See the
updates in functions zend_jit_check_func_arg() and zend_jit_send_var().

Besides, a new path is covered in macro OBJ_RELEASE when leaving.
2021-05-18 15:32:24 +03:00
Hao Sun 3748319f77 Support failed JIT test case: assign_035.phpt
1. For statement "echo $a->test()", opcode INIT_METHOD_CALL is
involved. The updates in function zend_jit_init_method_call() and
zend_jit_push_call_frame() are made to support it.

2. The updates in function zend_jit_leave_func() are made to support the
RETURN opcode used in functions $closure and $test.

3. The updates in function zend_jit_assign_to_variable() are used to
support statement "$x = $arr".

4. The updates in function zend_jit_fetch_dimension_address_inner() and
zend_jit_simple_assign() are made to support statement "$x['a'] =
$closure()", where opcode ASSIGN_DIM is involved.
2021-05-18 15:32:23 +03:00
Hao Sun 77b3d71a16 Support failed JIT test case: assign_036.phpt
This patch mainly supports the opcode FETCH_OBJ_R for statement
"$a->result = "okey";".
2021-05-18 15:32:23 +03:00
Hao Sun cb0dc59333 Support failed JIT test case: assign_static_prop_001.phpt
For function Foo(), the original handlers would be invoked for the first
two statements. And the third statement "$a = 42", where ASSIGN opcode
is involved, covers the cold code in function
zend_jit_assign_to_variable().

For function $main(), statement "var_dump(Foo::$prop);" covers a new
path in function zend_ jit_send_val() for SEND_VAL opcode.

Besides, another 2 test cases, i.e. fetch_dim_r_003.phpt and
fetch_dim_r_004.phpt, would pass as well with this patch.
2021-05-18 15:32:23 +03:00
Hao Sun 54a40ecd28 Support failed JIT test case: assign_dim_002.phpt
There are 6 user function calls in this test cases. The first 3
functions, i.e. foo(), foo1() and foo2(), can be supported already. In
this patch, we mainly focus on foo3(). Note that based on my test, once
foo3() gets supported, the remaining functions foo4() and foo5() can
pass as well.

Regarding function foo3(), we mainly focus on statement "$array = new
ArrayObject();", and the following two opcodes are involved.

  0009 V2 = NEW 0 string("ArrayObject")
  0010 DO_FCALL

Accordingly, functions zend_jit_handler(), zend_jit_cond_jmp() and
zend_jit_do_fcall() are invoked to generate the machine code. See the
handling process for case ZEND_NEW at file zend_jit.c. Hence, major
changes in this patch are made to support this statement.

Note that the updates at line 4840 in function zend_jit_do_fcall() are
made to support the later internal function call, i.e. var_dump().

Note that another test "noval_001.phpt" would pass with this patch as
well.
2021-05-18 15:32:23 +03:00
Hao Sun 3c21fac1f3 Support failed JIT test case: assign_dim_op_001.phpt
This test case covers one new path in macro TRY_ADDREF, touching macro
GC_ADDREF for the first time.
2021-05-18 15:32:23 +03:00
Hao Sun 70a0b183c0 Support failed JIT test case: assign_026.phpt
For statement "$a = new stdClass;", opcode NEW is used and JIT would
invoke the original handler at runtime.

Our major changes are made to support statements "$a->a=1;" and
"$a->b=2;" where opcode ASSIGN_OBJ are used.
2021-05-18 15:32:23 +03:00
Hao Sun 5538a4cee8 Support failed JIT test case: assign_025.phpt
Major changes are:
1. Support opcode FETCH_DIM_W for "$arr[0][0] = $ref;" in the loop. See
the updates in function zend_jit_fetch_dim().
2. Spill the registers and store the values into memory. See the updates
in function zend_jit_spill_store(). This is done for Phi function.
3. Invoke function zend_array_destory() as dtor for arrays. This is done
by zend_jit_free_cv() when leaving the function foo().
2021-05-18 15:32:23 +03:00
Hao Sun d7ae4d04ba Support failed JIT test case: assign_022.phpt
Major changes are made to support statement "$a[0] = $unref", where
opcode ASSIGN_DIM is involved.

Besides, one bug in macro GC_DELREF is fixed. The reference count would
be further checked after decreasing in macro ZVAL_PTR_DTOR, hence,
instruction "subs" should be used to set the flags. After fixing this
bug, external function zend_jit_array_free() is used as the dtor for the
array "$a".
2021-05-18 15:32:23 +03:00
Hao Sun d7a1427863 Support failed JIT test case: assign_024.phpt
Support assginment with undefined variable, and a warning would be
emitted.

Besides, test case assign_023.phpt would pass as well with this patch.
2021-05-18 15:32:23 +03:00
Hao Sun 31b0f9f5e0 Support failed JIT test case: assign_027.phpt
This patch is trivial, supporting the comparion with constant values,
i.e. "$i < 2" in this test case.
2021-05-18 15:32:23 +03:00
Hao Sun 7537d21d99 Support failed JIT test case: assign_012.phpt
Support the case where arguments might be reference.

Besides, another two test cases, assign_019.phpt and assign_032.phpt,
would pass as well with this patch.
2021-05-18 15:32:23 +03:00
Hao Sun 1684d277b5 Support failed JIT test case: assign_010.phpt
Following the previous patch, we continue to support failed JIT test
cases involving reference.

In assign_010.phpt, major changes are done to support the assignment "$a
= $b" where "$b" is a reference.

Honestly speaking, I didn't fully understand the syntax here but rather
to translate the x86 implementation into AArch64.

Besides, test case assign_011.phpt would pass as well with this patch.
2021-05-18 15:32:23 +03:00
Hao Sun 797612786d Support failed JIT test case: assign_002.phpt
Reference is involved in this test case, i.e. "$ref2 = & $ref1;".

1. Fix one bug in zend_do_fcall(). For each stack slot, the type
information gets initialized during the call frame allocation phase.

Opcode ZEND_ASSIGN_REF is associated to this statement. It's worth
noting that PHP JIT doesn't apply to this opcode actually. That means
the original handler(i.e. interpreter version) will be invoked at
runtime. Note that this mode works for a number of opcodes, not only
ZEND_ASSIGN_REF.

In the execution of original handler, the runtime type information of
$ref2 is accessed and this bug is triggered.

2. Support macros GET_Z_PTR and ZVAL_DEREF.

3. Cover new paths in function zend_jit_simple_assign() and macro
ZVAL_COPY_CONST.
2021-05-18 15:32:23 +03:00
haosun01 657b00d7c0 Hybrid use of registers
1. one **hybrid** solution of register usage
After the discussion with Dmitry, we may want to propose one hybrid
solution of register usage.

1) Following the x86 implementation, we define REG0/1/2 to be the
scratch registers. Clever tricks are utilized in x86 implementation for
better register allocation. Note that we define REG0/1/2 as x8/9/10. One
reason is that R0 and FCARG1 should be distinguished.

2) Temporary registers are also reserved(i.e. they are excluded from the
candidates of register allocator), and they would be used due to the
different addressing modes in AArch64.

2. update the 'make clean' target.

3. remove the unnecessary AArch64 related macros in zend_jit_internal.h.

[ci skip]

Change-Id: I627157b88b2344530d705751eb7f73a223ed83e5
CustomizedGitHooks: yes
2021-05-18 15:32:23 +03:00
Hao Sun 0de9494464 Initial support of JIT/arm64
SUMMARY

We implemented a prototype of PHP JIT/arm64. Briefly speaking,

1. build system
Changes to the build system are made so that PHP JIT can be successfully
built and run on ARM-based machine.
Major change lies in file zend_jit_arm64.dasc, where the handler for
each opcode is generated into machine code. Note that this file is just
copied from zend_jit_x86.dasc and the *unimplemented* parts are
substitued with 'brk' instruction for future work.

2. registers
AArch64 registers are defined in file zend_jit_arm64.h. From our
perspectives, the register usage is quite different from the x86
implementation due to the different ABI, number of registers and
addressing modes.
We had many confusions on this part, and will discuss it in details in
the final section.

3. opcodes
Several opcodes are partially supported, including INIT_FCALL, DO_UCALL,
DO_ICALL, RETURN, ADD, PRE_INC, JMP, QM_ASSIGN, etc. Hence, simple use
scenarios such as user function call, loops, addition with integer and
floating point numbers can be supported.
18 micro test cases are added under 'ext/opcache/tests/jit/arm64/'. Note
that majority of these test cases are design for functional JIT, and
cases 'hot_func_*.phpt' and 'loop_002.phpt' can trigger tracing JIT.

4. test
Our local test environment is an ARM-based server with Ubuntu 20.04 and
GCC-10. Note that both HYBRID and CALL VM modes are supported. We
suggest running the JIT test cases using the following command. Out of
all 130 test cases, 66 cases can be passed currently.
```
  $ make test TESTS='-d opcache.jit=1203 ext/opcache/tests/jit/'
```

DETAILS

1. I-cache flush
Instruction cache must be flushed for the JIT-ed code on AArch64. See
macro JIT_CACHE_FLUSH in file 'zend_jit_internal.h'.

2. Disassembler
Add initialization and jump target parse operations for AArch64 backed.
See the updates in file 'zend_jit_disasm.c'.

3. redzone
Enable redzone for AArch64. See the update in zend_vm_opcodes.h.
Redzone is designated to prevent 'vm_stack_data' from being optimized
out by compilers. It's worth noting that this 16-byte redzone might be
reused as temporary use(treated as extra stack space) for HYBRID mode.

4. stack space reservation
The definitions of HYBRID_SPAD, SPAD and NR_SPAD are a bit tricky for
x86/64.
In AArch64, HYBRID_SPAD and SPAD are both defined as 16. These 16 bytes
are pre-allocated for tempoerary usage along the exuection of JIT-ed
code. Take line 4185 in file zend_jit_arm64.dasc as an example. NR_SPAD
is defined as 48, out of which 32 bytes to save FP/IP/LR registers.
Note that we choose to always reserve HYBRID_SPAD bytes in HYBRID mode,
no matter whether redzone is used or not, for the sake of safety.

5. stack alignment
In AArch64 the stack pointer should be 16-byte aligned. Since shadow
stack is used for JIT, it's easy to guarantee the stack alignment, via
simply moving SP with an offset like 16 or a multiple of 16. That's why
NR_SPAD is defined as 48 and we use 32 of them to save FP/IP/LR
registers which only occupies 24 bytes.

6. global registers
x27 and x28 are reserved as global registers. See the updates in file
zend_jit_vm_helpers.c

7. function prologue for CALL mode
Two callee-saved registers x27 and x28 should saved in function
zend_jit_prologue() in file zend_jit_arm64.dasc. Besides the LR, i.e.
x30, should also be saved since runtime C helper functions(such as
zend_jit_find_func_helper) might be invoked along the execution of
JIT-ed code.

8. regset
Minor changes are done to regset operations particularly for AArch64.
See the updates in file zend_jit_internal.h.

REGISTER USAGE

In this section, we will first talk about our understanding on register
usage and then demonstrate our design.

1. Register usage for HYBRID/CALL modes
Registers are used similarly between HYBRID mode and CALL mode.

One difference is how FP and IP are saved. In HYBRID mode, they are
assigned to global registers, while in CALL mode they are saved/restored
on the VM stack explicitly in prologue/epilogue.

The other difference is that LR register should also be saved/restored
in CALL mode since JIT-ed code are invoked as normal functions.

2. Register usage for functional/tracing JIT
The way registers are used differs a lot between functional JIT and
tracing JIT.

For functional JIT, runtime C code (e.g. helper functions) would be
invoked along the execution of JIT-ed code. As the operands for *most*
opcodes are accessed via the stack slot, i.e. FP + offset. Hence there
is no need to save/restore local(caller-saved) registers before/after
invoking runtime C code.
Exception lies in Phi node and registers might be allocated for these
nodes. Currently I don't fully understand the reason, why registers are
allocated for Phi functions, because I suppose for different versions of
SSA variables at the Phi function, their postions on the stack slot
should be identical(in other words, access via the stack slot is enough
and there is no need to allocate registers).

For tracing JIT, runtime information are recorded for traces(before the
JIT compilation), and the data types and control flows are concrete as
well. Hence it's would be faster to conduct operations and computations
via registers rather than stack slots(as functional JIT does) for these
collected hot paths. Besides, runtime C code can be invoked for tracing
JIT, however this only happends for deoptimization and all registers are
saved to stack in advance.

3. Candidates for register allocator
1) opcode candidates
Function zend_jit_opline_supports_reg() determines the candidate opcodes
which can use CPU registers.

2) register candidates
Registers in set "ZEND_REGSET_FP + ZEND_REGSET_GP - ZEND_REGSET_FIXED -
ZEND_REGSET_PRESERVED" are available for register allocator.
Note that registers from ZEND_REGSET_FIXED are reserved for special
purpose, such as the stack pointer, and they are excluded from register
allocation process.
Note that registers from ZEND_REGSET_PRESERVED are callee-saved based on
the ABI and it's safe to not use them either.

4. Temporary registers
Temporary registers are needed by some opcodes to save intermediate
computation results.

1) Functions zend_jit_get_def_scratch_regset() and
zend_jit_get_scratch_regset() return which registers might be clobbered
by some opcodes. Hence register allocator would spill these scratch
registers if necessary when encountering these opcodes.

2) Macro ZEND_REGSET_LOW_PRIORITY denotes a set of registers which would
be allocated with low priority, and these registers can be used as
temporary usage to avoid conflicts to its best.

5. Compared to the x86 implementation, in JIT/arm64
1) Called-saved FP registers are included into ZEND_REGSET_PRESERVED for
AArch64.

2) We follow the logic of function zend_jit_opline_supports_reg().

3) We reserve 4 GPRs and 2 FPRs out from register allocator and use them
as temporary registers in particular. Note that these 6 registers are
included in set ZEND_REGSET_FIXED.
Since they are reserved, may-clobbered registers can be removed for most
opcodes except for function calls. Besides, low-priority registers are
defined as empty since all candidate registers are of the same priority.
See the updates in function zend_jit_get_scratch_regset() and macro
ZEND_REGSET_LOW_PRIORITY.

6. Why we reserve registers for temporary usage?
1) Addressing mode in AArch64 needs more temporary registers.
The addressing mode is different from x86 and tempory registers might be
*always* needed for most opcodes. For instance, an immediate must be
first moved into one register before storing into memory in AArch64,
whereas in x86 this immediate can be stored directly.

2) There are more registers in AArch64.
Compared to the solution in JIT/x86(that is, temporary registers are
reserved on demand, i.e. different registers for different opcodes under
different conditions), our solution seems a coarse-granularity and
brute-force solution, and the execution performance might be downgraded
to some extent since the number of candidate registers used for
allocation becomes less.
We suppose the performance loss might be acceptable since there are more
registers in AArch64.

3) Based on my understanding, scratch registers defined in x86 are
excluded from candidates for register allocator with *low possibility*,
and it can still allocate these registers. Special handling should be
conducted, such as checking 'reg != ZREG_R0'.
Hence, as we see it, it's simpler to reserve some temporary registers
exclusively. See the updates in function zend_jit_math_long_long() for
instance. TMP1 can be used directly without checking.

Co-Developed-by: Nick Gasson <Nick.Gasson@arm.com>
2021-05-18 15:32:23 +03:00
Nikita Popov c939bd2f10 Handle explicitly nullable types in optional-before-required deprecation
The exception for null default values here exists to keep compatibility
with PHP < 7.1 where "Foo $bar = null" was the canonical way to create
a nullable parameter. If the parameter is actually "?Foo $bar = null",
then clearly compatibility with PHP < 7.1 is not a concern, and we
can throw a deprecation notice.
2021-05-18 14:00:25 +02:00
Nikita Popov afc4d67c8b Consistently treat optional-before-required as required
There was a loophole here when it came to usage with named arguments,
which was not intended. Close the loophole thoroughly by actually
dropping the default value from the signature entirely. The default
is still used to make the type nullable, but not for anything else.
2021-05-18 12:40:58 +02:00
Christoph M. Becker 7331bc7205 Merge branch 'PHP-8.0'
* PHP-8.0:
  [ci skip] Removed incorrect news entry
2021-05-18 12:37:22 +02:00
Christoph M. Becker 6c3896b1e9 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  [ci skip] Removed incorrect news entry
2021-05-18 12:36:21 +02:00
Graham Campbell 66c3a174f5 [ci skip] Removed incorrect news entry
Closes GH-7007.
2021-05-18 12:34:46 +02:00
Nikita Popov 10a5e506ed Drop SXE_METHOD() macro
Don't break my grep.
2021-05-18 11:45:15 +02:00
Nikita Popov de6e401e05 Use common formatting for backtraces (#6977)
This makes debug_print_backtrace() use the same formatting as exception
backtraces. The only difference is that the final #{main} is omitted,
because it wouldn't make sense for limited backtraces, and wasn't there
previously either.
2021-05-18 11:43:37 +02:00
Nikita Popov 1c8bb6d681 Remove unnecessary LIBZEND_MM_ALIGN assignment
We're not using the variable in this branch.
2021-05-17 18:44:57 +02:00
Dmitry Stogov 941b55fe63 Fixed JIT failure after overflow detection (bench.php failure in 32-bit
build with -d opcache.jit=1254 -d opcache.jit_hot_loop=1 -d
opcache.jit_hot_func=1 -d opcache.jit_hot_return=1 -d
opcache.jit_hot_side_exit=1)
2021-05-17 18:21:43 +03:00
Nikita Popov 680d198d50 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #81019
2021-05-17 16:33:44 +02:00
Nikita Popov 0bff67c0ab Fixed bug #81019
Before the zval -> zend_object migration, this code used macros
like FORMATTER_METHOD_FETCH_OBJECT_NO_CHECK, which internally
clear the error. Now that they are no longer used, we need to
manually clear the error.
2021-05-17 16:33:35 +02:00
Nikita Popov 7cf1c27a33 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #81046
2021-05-17 15:47:13 +02:00
Nikita Popov c446d68f7c Fixed bug #81046
Literal compaction was incorrectly assuming that literals with
the same base literal and the same number of related literals
would be equal. Maybe that was the case historically, but at
least it isn't true in PHP 8, where FETCH_CONSTANT and INIT_METHOD
have distinct literals at the second position.

Fix this by making the cache key a concatenation of all literals,
rather than just the base literal. We still distinguish the number
of related literals based on a bias added to the string hash.
2021-05-17 15:46:49 +02:00
Nikita Popov 671fd3f25d Fix test expectation for libmysql-only test
This test now correctly displays an error message, yay.
2021-05-17 14:36:40 +02:00
Nikita Popov ec56650801 PDO MySQL: Check number of bounds params even if none are bound
The check for the number of bound parameters was only executed if
at least one was bound. We should also error if nothing was bound.
With mysqlnd, mysqlnd itself ended up emitting an error, but with
libmysqlclient this error condition would not be detected.
2021-05-17 14:29:47 +02:00
Nikita Popov 7ba0c74312 Fix line endings in test 2021-05-17 14:24:05 +02:00
Nikita Popov a39edab96e Skip float truncation test under libmysql
We don't return native types for libmysql, so this test doesn't
make sense.
2021-05-17 10:25:52 +02:00
Nikita Popov f0858d891f Record warnings during early binding
These should also get replayed when the class is loaded from
opcache.
2021-05-17 10:18:26 +02:00
Nikita Popov 3b7edb6587 Don't directly throw warning during method compatibility check
Only return the INHERITANCE_WARNING status.
2021-05-17 10:16:47 +02:00
Matteo Beccati 9939b2b71f Fix test on non-UTC setups 2021-05-17 09:24:49 +02:00
Máté Kocsis 29a76d94df Merge branch 'PHP-8.0'
* Fix some types in ext/oci8
2021-05-16 16:33:29 +02:00
Máté Kocsis f0736631d9 Fix some types in ext/oci8
Closes GH-6992
2021-05-16 16:26:54 +02:00
Christoph M. Becker 048cb9be05 Merge branch 'PHP-8.0'
* PHP-8.0:
  Properly push test artifacts
2021-05-16 14:47:15 +02:00
Christoph M. Becker a75a4a4a70 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Properly push test artifacts
2021-05-16 14:46:31 +02:00
Christoph M. Becker fb86a176ba Properly push test artifacts
Cf. https://www.appveyor.com/docs/packaging-artifacts/#pushing-artifacts-from-scripts.

Closes GH-6990.
2021-05-16 14:45:06 +02:00
George Peter Banyard c4d69c2e60 Fix test expectation now that -a doesn't work without readline
Follow-up upon 959e5787bd
2021-05-15 02:39:35 +01:00
Tyson Andre d60bc0e2d9 Support doc comments on enum cases (#6984)
Because php supports doc comments on class constants, I believe it would also
make sense to support them on enum cases.

I don't have strong opinions about whether attributes should be moved to be the
last element or whether the doc comment should go after the attribute,
but the ast will likely change again before php 8.1 is stable.
So far, all attributes are the last ast child node.

I didn't notice that doc comments weren't implemented due to
https://github.com/php/php-src/pull/6489 being a large change.

https://wiki.php.net/rfc/enumerations
did not mention whether or not doc comments were meant to be supported
2021-05-14 15:25:03 -04:00
Máté Kocsis 87e4970ebc Declare SNMP properties
Additionally, convert them to typed properties.

Closes GH-6742
2021-05-14 17:03:05 +02:00
Máté Kocsis 532c60cb92 Add support for tentative return types of internal methods
RFC: https://wiki.php.net/rfc/internal_method_return_types

Closses GH-6971
2021-05-14 15:55:25 +02:00
Nikita Popov 008bfcc7ba Use NO_DYNAMIC_PROPERTIES for Closure
Instead of manually implementing this, use the standard mechanism.
This has minor behavior changes (e.g. doing an isset() will now
return false instead of throwing) which are more in line with
typical behavior.
2021-05-14 14:48:56 +02:00
George Peter Banyard e7135cb817 Use zend_string_equals_* API in a couple of more place
Closes GH-6979
2021-05-14 13:45:17 +01:00
George Peter Banyard aca6aefd85 Remove 'register' type qualifier (#6980)
The compiler should be smart enough to optimize this on its own
2021-05-14 13:38:01 +01:00
Kamil Tekiela 2a486d48ed Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix NEWS
2021-05-14 12:36:07 +01:00
Kamil Tekiela 5c164a2223 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix NEWS
2021-05-14 12:34:46 +01:00
Kamil Tekiela ead72aabfb Fix NEWS 2021-05-14 12:33:32 +01:00
Kamil Tekiela dbfc9f99d1 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #81037 PDO discards error message text from prepared statement

Closes GH-6978.
2021-05-14 12:04:22 +01:00
Kamil Tekiela 574b551567 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fixed bug #81037 PDO discards error message text from prepared statement
2021-05-14 11:59:36 +01:00
Kamil Tekiela 6afbb74194 Fixed bug #81037 PDO discards error message text from prepared statement 2021-05-14 11:54:49 +01:00
Christoph M. Becker 3f890635ae Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #81032: GD install is affected by external libgd installation
2021-05-14 12:28:36 +02:00
Christoph M. Becker c455f49a6a Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #81032: GD install is affected by external libgd installation
2021-05-14 12:26:40 +02:00
Flavio Heleno 28e7addb9d Fix #81032: GD install is affected by external libgd installation
This PR replaces the bundled libgd includes from #include <foo.h> with
#include "foo.h" for gd-related headers to avoid including headers that
may be available in system directories instead of the expected local
headers.

Closes GH-6975.
2021-05-14 12:24:45 +02:00
Nikita Popov 8d409d955f Drop test-phpdbg and clean-phpdbg targets
test-phpdbg doesn't work entirely, and there doesn't seem to be
any cause for having a target that cleans phpdbg in particular.
2021-05-14 12:20:00 +02:00
Nikita Popov 6ce7b10e14 Add pkg.m4 upstream
Per https://github.com/php/php-src/pull/6907#issuecomment-826362572.
Closes GH-6907.

[ci skip]
2021-05-14 12:15:23 +02:00
Nikita Popov 959e5787bd Disable -a mode without readline
To avoid confusing, as -a without readline is not actually
interactive.

Discussion: https://externals.io/message/114426

Closes GH-6976.
2021-05-14 12:10:46 +02:00
Nikita Popov 840c78b2d8 Check RAND_egd after setting up openssl
Noticed this by accident: We should check functions in the library
only after setting it up.
2021-05-14 12:02:28 +02:00
Nikita Popov 6d5c60e945 Add UPGRADING/NEWS for full_path for file uploads
[ci skip]
2021-05-14 11:47:14 +02:00
Björn TantauandBjörn Tantau d764f1dc12 Fix #77372: Retain full path of files for directory uploads (#6917)
To fix https://bugs.php.net/bug.php?id=77372 and improve support of `<input type="file" name="files" multiple webkitdirectory>` I introduced another item to the `$_FILES` array called `full_path`, containing the full filename, as supplied by the user-agent.

Co-authored-by: Björn Tantau <bjoern@bjoern-tantau.de>
2021-05-14 11:43:55 +02:00
K 21422e8536 Optimize unpack() for named fields (#6958)
Create name using either zend_init_string_fast (no repetitions) or by concatenating the name with zend_print_ulong_to_buf. This is much more efficient than using snprintf. We also avoid repeated strlen() calculations.
2021-05-14 11:32:46 +02:00
Dmitry Stogov 4522dcb173 JIT/x86: disable register allocation for expected ++/-- overflow case.
This fixes ext/opcache/tests/jit/inc_021.phpt with tracing JIT.
2021-05-14 11:01:54 +03:00
Christoph M. Becker 4030a00e8b Merge branch 'PHP-8.0'
* PHP-8.0:
  Disable LSan for all PDO_Firebird tests
2021-05-13 23:36:33 +02:00
Christoph M. Becker b300c6b87f Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Disable LSan for all PDO_Firebird tests
2021-05-13 23:34:37 +02:00
Christoph M. Becker f6c15e2caf Disable LSan for all PDO_Firebird tests
The tests leak memory, likely due to a slightly unclean shutdown of
libfbclient.  To avoid failing CI, we disable LSan for all the tests.

Closes GH-6966.
2021-05-13 23:30:17 +02:00
Dmitry Stogov c94bb37326 Fixed indirect variable access detection when opcache.jit=1252
This fixes `make test TESTS="-d opcache.jit=1252 --repeat 3
Zend/tests/global_with_side_effect_name.phpt"`
2021-05-13 23:01:13 +03:00
George Peter Banyard 96adc806e0 Add -Wstrict-prototypes compiler warning
Disable it for the following extensions:
 - GD
 - pspell
 - readline

Closes GH-5888
2021-05-12 19:02:48 +01:00
George Peter Banyard ff988a6f4f Fix remaining [-Wstrict-prototypes] warnings
Two missing void qualifiers for parameter list.
2021-05-12 19:02:48 +01:00
George Peter Banyard 2068d230d9 Fix [-Wstrict-prototypes] warning in PCNTL extension
To achieve this we need to introduce a new wrapper function with
dummy arguments which calls pcntl_signal_dispatch() to respect
the function pointer signature for a tick function.
2021-05-12 19:02:48 +01:00
George Peter Banyard b7356692f6 Specify function pointer signature for scanf implementation
Fix [-Wstrict-prototypes] warnings in standard/scanf.c
2021-05-12 18:58:44 +01:00
George Peter Banyard e90180d06a Use standard function signature instead of K&R in Intrl extension
Drive-by removal of register qualifier.

Fix [-Wstrict-prototypes] warnings in Intl extension.
2021-05-12 18:54:55 +01:00
George Peter Banyard 57a8bf62dd Use standard function declaration style instead of K&R in libbcmath
Fixes [-Wstrict-prototypes] warnings.
2021-05-12 15:33:55 +01:00
George Peter Banyard a6a95e3f51 Do not reuse errno as local variable name
errno is a global variable/macro which is implementation defined,
and should not be reused.

This fixes some [-Wstrict-prototypes] warnings.
2021-05-12 15:32:16 +01:00
Dmitry Stogov 2e93bb7a45 Fixed possible use after free 2021-05-12 17:21:39 +03:00
George Peter Banyard c40231afbf Mark various functions with void arguments.
This fixes a bunch of [-Wstrict-prototypes] warning,
because in C func() and func(void) have different semantics.
2021-05-12 14:55:53 +01:00
Christoph M. Becker 320d6050e7 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #44643: bound parameters ignore explicit type definitions
2021-05-12 13:47:57 +02:00
Christoph M. Becker 63c558bcbb Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #44643: bound parameters ignore explicit type definitions
2021-05-12 13:47:01 +02:00
Christoph M. Becker 23a3bbb468 Fix #44643: bound parameters ignore explicit type definitions
If `SQLDescribeParam()` fails for a parameter, we must not assume
`SQL_LONGVARCHAR` for any param which is not `PDO_PARAM_LOB`.  At least
mapping `PDO_PARAM_INT` to `SQL_INTEGER` should be safe, and not
introduce a BC break.

Closes GH-6973.
2021-05-12 13:30:51 +02:00
Mike Pall 16d59a59c8 DynASM: Bump version to 1.5.0. 2021-05-12 13:40:13 +03:00
Mike Pall 5f44ed55c4 DynASM/ARM64: Add .long expr. Add .quad/.addr expr + refs.
Suggested by Dmitry Stogov, Hao Sun and Nick Gasson.
2021-05-12 13:36:32 +03:00
Dmitry Stogov 4a5074154b DynASM/x86: Fix x64 .aword refs. Add .qword, .quad, .addr and .long.
(Switch to .aword implementation by Make Pall)
2021-05-12 13:32:06 +03:00
Dmitry Stogov e25fce6533 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed JIT on first function execution (opcache.jit=1215) with CALL VM
2021-05-12 12:24:39 +03:00
Dmitry Stogov e96b984026 Fixed JIT on first function execution (opcache.jit=1215) with CALL VM 2021-05-12 12:24:18 +03:00
Dmitry Stogov c945c399aa Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed incorrect stack size calculation (sizeof(zval) == 16)
2021-05-12 02:09:14 +03:00
Dmitry Stogov 6fa4493f7b Fixed incorrect stack size calculation (sizeof(zval) == 16) 2021-05-12 02:08:53 +03:00
Dmitry Stogov 9f2389177e Fixed tracing JIT + preloading failures:
ext/opcache/tests/preload_003.phpt
ext/opcache/tests/preload_trait_multiple_fixup.phpt
ext/opcache/tests/preload_trait_static.phpt
2021-05-11 16:50:10 +03:00
Dmitry Stogov cb0854bc53 JIT class methods only when class entry is completely persistent.
This fixes a number of test failures on low optimization levels.
(e.g. use after free in Zend/tests/bug54268.phpt and tests/classes/protected_001.phpt with opcache.jit=1204)
2021-05-11 15:49:35 +03:00
Nikita Popov 4fe07d474c Add test for restoring error_reporting on fatal error during silencing
This guard against the issue that GH-6904 would introduce when
run under --repeat 2 mode.
2021-05-11 12:16:59 +02:00
Nikita Popov 07061482a0 Fix segfault in php -a without readline 2021-05-11 11:39:04 +02:00
Joe Watkins 8b8c8fd79c Merge branch 'PHP-8.0'
* PHP-8.0:
  missing ;
2021-05-11 11:11:35 +02:00
Joe Watkins 33a93b5ed7 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  missing ;
2021-05-11 11:10:52 +02:00
Joe Watkins ef3e0ee08a missing ; 2021-05-11 11:10:38 +02:00
Joe Watkins 3318dcc8ef Merge branch 'PHP-8.0'
* PHP-8.0:
  php-fpm: fix Solaris port events.mechanism
2021-05-11 11:08:35 +02:00
Joe Watkins 6ccbaa12e0 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  php-fpm: fix Solaris port events.mechanism
2021-05-11 11:07:47 +02:00
Joe Watkins 2558acbd66 Fixed bug #65800 php-fpm: fix Solaris port events.mechanism 2021-05-11 11:05:39 +02:00
Petr Sumbera 04078a597c php-fpm: fix Solaris port events.mechanism
Bug #65800
Fix by: rainer.jung@kippdata.de
2021-05-11 11:01:38 +02:00
dwgebler f5139878f9 Check parameters on compact() and throw warning if not string or array of strings (#6921)
compact() is documented (https://www.php.net/manual/en/function.compact) as a variadic function accepting parameters which are strings or arrays of strings referencing defined symbols.

In actuality, passing nonsense parameters e.g. compact(true, 42) merely returns an empty array. I propose throwing a warning in these cases, to prevent silent bugs.
2021-05-11 09:36:12 +02:00
Máté KocsisandNikita Popov 32aff25ceb Convert resources to objects in ext/pgsql
Closes GH-6791

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
2021-05-11 00:09:30 +02:00
Ayesh Karunaratne 57a635c655 Move resource-object classes of PSpell to \PSpell namespace
[namespaces in bundled extensions](https://wiki.php.net/rfc/namespaces_in_bundled_extensions) changes for PSpell.

 - Rename `PSpell` class to `\PSpell\Dictionary`
 - Rename `PSpellConfig` class to `\PSpell\Config`
 - Add entries to `UPGRADING` file.

Related: bd12c94f
2021-05-10 19:29:54 +02:00
Michael Voříšek 3ccc0409ce Remove no longer used "log_errors_max_len" ini directive (#6838)
This is a re-application of the original match against master.
The patch was originally applied to master, then reverted from
there, incorrectly applied to PHP-8.0, reverted from there due
to ABI break, and now lands on master again. We can only hope
that it does not get reverted again ;)
2021-05-10 19:26:33 +02:00
Nikita Popov 4f46bec5d4 Initialize zpp varargs variables
These are not initialized if no args are passed.
2021-05-10 19:19:26 +02:00
Nikita Popov a9695aa155 Merge branch 'PHP-8.0'
* PHP-8.0:
  Correct the argument names for ext/sodium functions
2021-05-10 17:22:41 +02:00
Paragon Initiative Enterprises 0c57ebb116 Correct the argument names for ext/sodium functions
Closes GH-6969.
2021-05-10 17:22:02 +02:00
Aaron Piotrowski 39fa55a4c9 Switch register_tick_function back to zend_parse_parameters
No reason to use fast ZPP in register_tick_function, so let’s keep the binary size down just a bit.
2021-05-10 10:17:29 -05:00
George Peter Banyard 8082b4c944 Use uint32_t for number of variadic arguments in ZPP 2021-05-10 16:06:22 +01:00
George Peter BanyardandAaron Piotrowski a9695cc615 Refactor register shutdown function mechanism
Use FCI/FCC structure instead of custom implementation which does the same.
This also fixes the "bug" which prevented static methods from being shutdown functions.

Closes GH-5829

Co-authored-by: Aaron Piotrowski <aaron@trowski.com>
2021-05-10 15:54:59 +01:00
Máté KocsisandJoe Watkins fcd18757b2 Add reproducer for possible issue with object return type inheritance (#6961)
Fix early inheritance

Co-authored-by: Joe Watkins <krakjoe@php.net>
2021-05-10 12:52:59 +02:00
Nikita Popov f71bfe4544 Merge branch 'PHP-8.0'
* PHP-8.0:
  Don't autoload classes during covariant type check against mixed
2021-05-10 09:46:49 +02:00
Nikita Popov 7fbfcfa851 Don't autoload classes during covariant type check against mixed
mixed should be behaving the same way as no type here, and not
require X to be autoloaded. Everything apart from "void" is trivially
covariant to "mixed".
2021-05-10 09:45:48 +02:00
Ayesh Karunaratne e0b947a8da Move resource-object classes of LDAP to \LDAP namespaces (#6963)
Another change as per accepted [namespaces in bundled extensions RFC](https://wiki.php.net/rfc/namespaces_in_bundled_extensions).

Related: #6925, #5945, #6960
2021-05-09 22:20:21 +02:00
Aaron Piotrowski 66bfad57de Remove unnecessay NULL
Z_PARAM_FUNC already sets params to NULL.
2021-05-09 14:55:05 -05:00
Aaron Piotrowski 0189585c9e Fix tick function with arguments
Tick function arguments need to be copied to fci params.
2021-05-09 14:08:20 -05:00
Aaron Piotrowski 7ec048f96d Do not free tick function entry
This memory is freed by zend_llist.
2021-05-09 11:44:32 -05:00
Aaron Piotrowski 3c3ec441e4 Move fiber stack allocation within try
If VM stack allocation fails, the bailout will be caught within the fiber.
2021-05-08 23:30:48 -05:00
Nikita Popov b5c0e7e0ec Merge branch 'PHP-8.0'
* PHP-8.0:
  Revert "Remove no longer used "log_errors_max_len" ini directive (#6838)"
  Add entries for log_errors_max_len INI directive removal
  Remove no longer used "log_errors_max_len" ini directive (#6838)
2021-05-08 20:56:00 +02:00
Nikita Popov 090627048c Revert "Remove no longer used "log_errors_max_len" ini directive (#6838)"
This reverts commit d2d227e547.

This is an ABI break.
2021-05-08 20:54:53 +02:00
Ben Ramsey c2b5284734 Add entries for log_errors_max_len INI directive removal 2021-05-08 13:35:35 -05:00
Ben Ramsey b5d5d06ff3 Revert "Remove no longer used "log_errors_max_len" ini directive (#6838)"
This reverts commit cc2c810dcf.
2021-05-08 13:23:58 -05:00
Aaron Piotrowski 5fb03758e5 Rename sanitizer members for clarity
These members hold the prior stack pointer and size, so bottom and capacity were poor name choices, prior_pointer and prior_size are more clear.
2021-05-08 13:12:06 -05:00
Michael Voříšek d2d227e547 Remove no longer used "log_errors_max_len" ini directive (#6838) 2021-05-08 13:05:13 -05:00
Ayesh Karunaratne 68224f2a41 Move FTP extension class FTPConnection to FTP\Connection
With the [namespaces in bundled extensions RFC](https://wiki.php.net/rfc/namespaces_in_bundled_extensions) passed, renaming the new `\FTPConnection` class to `\FTP\Connection`.
This also adds an entry to `./UPGRADING` file.

Related: #6925, #5945
2021-05-08 16:40:10 +02:00
Remi Collet 99d67d121a use getnameinfo instead of gethostbyaddr 2021-05-08 14:52:06 +02:00
George Peter Banyard 05e6f3ebde Refactor register_tick_function mechanism (#5828) 2021-05-08 10:09:09 +01:00
Michael Voříšek cc2c810dcf Remove no longer used "log_errors_max_len" ini directive (#6838) 2021-05-07 19:07:35 -05:00
Ben Ramsey c4fe9fb375 Add entries for new Sodium functions to NEWS 2021-05-07 17:50:28 -05:00
P.I.E. Security Team 9b794f8e5e Expose libsodium's Ristretto255 API (#6922) 2021-05-07 17:43:00 -05:00
Ben Ramsey 01ce8d3a78 Add entries for new behavior of PDO_ODBC server info/version attributes 2021-05-07 16:41:26 -05:00
Nikita Popov ef938d5ee4 Revert "Disable destructors on fuzzer bailout"
This reverts commit ed33262dbb.

With adjusted bailout handling in fibers, this should no longer
be necessary.
2021-05-07 23:06:20 +02:00
Aaron Piotrowski af2905968c Add sanitizer fiber switching support 2021-05-07 15:52:12 -05:00
Aaron Piotrowski ccc069d0bb Catch and repeat zend_bailout in fibers
This removes switching to main for fatal errors in fibers in favor of catching any zend_bailout in a fiber and calling zend_bailout again after switching to the previous fiber or {main}.
2021-05-07 15:52:11 -05:00
Nikita Popov ca8247654c Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix zip build
2021-05-07 22:42:50 +02:00
Nikita Popov 1c2e7b4ea0 Fix zip build 2021-05-07 22:42:31 +02:00
Christoph M. Becker cc86f70de9 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #80863: ZipArchive::extractTo() ignores references
2021-05-07 19:22:51 +02:00
Christoph M. Becker ab3052ab26 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #80863: ZipArchive::extractTo() ignores references
2021-05-07 19:21:58 +02:00
Christoph M. Becker 57918b1a1b Fix #80863: ZipArchive::extractTo() ignores references
We need to cater to references, when traversing the files to extract.
While we're at it, we move the `zval_file` declaration into a narrower
scope.

Closes GH-6959.
2021-05-07 19:15:29 +02:00
Nikita Popov 32b107e6a6 Use smart_str_extend() instead of smart_str_alloc()
These usages were re-implementing the exact functionality of
smart_str_extend().
2021-05-07 16:42:17 +02:00
Nikita Popov 072c50fc77 Merge branch 'PHP-8.0'
* PHP-8.0:
  Update msan job to Ubuntu 20.04
  Skip some tests under msan
2021-05-07 16:28:57 +02:00
Nikita Popov f547bddcc0 Update msan job to Ubuntu 20.04
Also don't explicitly specify symbolizer path. This doesn't appear
to be necessary anymore, and avoids a dependence on the specific
LLVM version used.
2021-05-07 16:28:01 +02:00
Nikita Popov af948ae24c Skip some tests under msan
These test functions which don't have msan interceptors. This
results in false positives running msan on ubuntu 20.04.
2021-05-07 16:26:49 +02:00
Máté Kocsis 4ece535f19 Merge branch 'PHP-8.0'
* Fix return type of php_user_filter::onCreate()
* Fix return type of mysqli::init()
* Fix return type of UConverter::fromUCallback() and UConverter::toUCallback()
2021-05-07 15:23:28 +02:00
Máté Kocsis 54e2ef0b81 Fix return type of UConverter::fromUCallback() and UConverter::toUCallback()
Closes GH-6950
2021-05-07 15:21:58 +02:00
Máté Kocsis e8361eb0e3 Fix return type of mysqli::init() 2021-05-07 15:21:41 +02:00
Máté Kocsis a3c38c2596 Fix return type of php_user_filter::onCreate() 2021-05-07 15:21:11 +02:00
Nikita Popov 4baf340c39 Merge branch 'PHP-8.0'
* PHP-8.0:
  Remove getservbyname() variation tests
  Use SOL_TCP instead of getprotobyname() in tests
2021-05-07 14:56:13 +02:00
Nikita Popov 12118d592a Remove getservbyname() variation tests
These are zpp variations, which we no longer test.
2021-05-07 14:55:27 +02:00
Nikita Popov 0413cf3c20 Use SOL_TCP instead of getprotobyname() in tests
This is more idiomatic anyway, and works on msan, which misses
interceptors for getprotobyname().
2021-05-07 14:55:18 +02:00
Nikita Popov 7b7a192d76 Merge branch 'PHP-8.0'
* PHP-8.0:
  Remove custom curl build on community job
2021-05-07 12:40:43 +02:00
Nikita Popov 9bf1224d07 Remove custom curl build on community job
This should no longer be necessary now that we're on Ubuntu 20.04.
2021-05-07 12:40:28 +02:00
Nikita Popov 50b4a7adf9 Property handle unset name on ReflectionClassConstant
While the typed property ensures that the value is a string,
we should make sure that we handle an unset property gracefully.

Do this by throwing the same error we would normally throw if
you access an uninitializde typed property.
2021-05-07 12:39:17 +02:00
Nikita Popov 26860c6b6a Fix -Wmaybe-uninitialized warning in intl uchar
This variable can indeed be uninitialized when passed to convert_cp,
though it will not actually be used if uninitialized. This is
still UB though, so let's fix it.
2021-05-07 12:20:16 +02:00
George Peter Banyard c757c61a8c Remove unnecessary error handler replacement in SPL
Document why it is needed in the remaining cases
Drive-by refactoring

Closes GH-6955
2021-05-07 11:17:56 +01:00
Nikita Popov 9eb295fc4c Fix -Wreturn-local-addr warning
zend_string_dup() can return the original string if it is interned.
Of course, the string can't be interned here, but GCC doesn't know
that and throws a warning in release builds.

Replace zend_string_dup() (which is a bad API anyway) with a direct
call to zend_string_init(), which makes it more obvious that the
original alloca'd string cannot be reused.
2021-05-07 12:11:52 +02:00
George Peter Banyard 2f1d0f2bc3 Throw directly instead of replacing error handler in ext/date (#6954) 2021-05-07 11:10:39 +01:00
Nikita Popov b9cfd288e5 Merge branch 'PHP-8.0'
* PHP-8.0:
  Update community, coverage and file cache jobs to Ubuntu 20.04
2021-05-07 11:31:36 +02:00
Nikita Popov 674b884c7a Update community, coverage and file cache jobs to Ubuntu 20.04
This fixes the issue with apt, and seems like a good idea in
general. The msan job is now the only one on 18.04, but that one
needs more work.
2021-05-07 11:29:34 +02:00
Nikita Popov 91dc10c906 Store SplFileObject open_mode as zend_string 2021-05-07 11:23:05 +02:00
Nikita Popov 9602db3b4a Fix open_mode for SplTempFileObject
open_mode was initialized to "wb", but the length set only to 1.
The effect of this was that the stream is opened using "wb", but
we only report "w".

Fix the length to report the actually used open_mode.
2021-05-07 11:18:51 +02:00
Nikita Popov 3b3f6de782 Use zend_string_concat3 in one place
A bit nicer than snprintf + passing the same length around three
times.
2021-05-07 10:43:40 +02:00
Nikita Popov 06e8ed5c86 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix azure build
2021-05-07 10:27:15 +02:00
Nikita Popov bcea74fd13 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix azure build
2021-05-07 10:26:59 +02:00
Nikita Popov 8deadfa31b Fix azure build
This is only needed on ubuntu-18.04, it works fine on ubuntu-20.04.
2021-05-07 10:26:04 +02:00
Calvin Buckley 207666ee84 Implement server type/version for PDO_ODBC getAttr (#6935)
As an example using the IBM Db2i ODBC driver:

    PDO::ATTR_SERVER_INFO: DB2/400 SQL
    PDO::ATTR_SERVER_VERSION: 07.02.0015
2021-05-06 20:15:13 -05:00
George Peter Banyard 2cd5a200f5 Refactor php_date_initialize_from_hash()
Use early returns
Formalize return type to bool
2021-05-06 21:48:52 +01:00
Ayesh Karunaratne 251da73a9a [skip-ci] Update UPGRADING file with new IMAP namespace
Followed by the bundled extension namespace RFC, #6925 updated the `IMAPConnection` class to `IMAP\Connection`.

This updates the UPGRADING file to reflect that change.
2021-05-06 20:57:56 +01:00
Nikita Popov ed33262dbb Disable destructors on fuzzer bailout
This is what we normally do for fatal errors. The reason why this
became necessary now, is that a bailout can switch from a fiber
back to the main stack. In that case we do not want to try
destroying the fiber.

Fixes oss-fuzz #33917.
2021-05-06 18:42:38 +02:00
Remi Collet e5b6f43ec7 get rid of inet_addr usage 2021-05-06 16:32:06 +02:00
Remi Collet 9ba3c367f7 fix litespeed build 2021-05-06 15:57:38 +02:00
K efe79e0de6 Simplify unpack logic (#6908)
- move endiannes check to compile time
- remove php_unpack function
- the compiler take care of sign extension
2021-05-06 15:20:05 +02:00
Christoph M. Becker 66ad7095b0 Merge branch 'PHP-8.0'
* PHP-8.0:
  Add simple Firebird payload fake server to test suite
2021-05-06 14:51:02 +02:00
Christoph M. Becker fb2bf8bd58 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Add simple Firebird payload fake server to test suite
2021-05-06 14:50:22 +02:00
Christoph M. Becker f95f8a3c1e Add simple Firebird payload fake server to test suite
This is meant to test against certain fixed responses of Firebird
servers.  For now we add just a most basic test which verifies a
connection attempt.

Closes GH-6940.
2021-05-06 14:47:57 +02:00
Nikita Popov 9ff8d362b3 Merge branch 'PHP-8.0'
* PHP-8.0:
  opcache: more reliable way to get the current binary on solaris/illumos
2021-05-06 14:34:28 +02:00
David Carlier d87d2f006c opcache: more reliable way to get the current binary on solaris/illumos
Closes GH-6920.
2021-05-06 14:33:53 +02:00
Remi Collet f9547f2b47 get rid of inet_aton and inet_ntoa use inet_ntop iand inet_pton where available standardize buffer size 2021-05-06 13:39:58 +02:00
KsaR 01b3fc03c3 Update http->https in license (#6945)
1. Update: http://www.php.net/license/3_01.txt to https, as there is anyway server header "Location:" to https.
2. Update few license 3.0 to 3.01 as 3.0 states "php 5.1.1, 4.1.1, and earlier".
3. In some license comments is "at through the world-wide-web" while most is without "at", so deleted.
4. fixed indentation in some files before |
2021-05-06 12:16:35 +02:00
Nikita Popov 13467bdcc0 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #81015
2021-05-06 10:47:22 +02:00
Nikita Popov dd3e56ba24 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fixed bug #81015
2021-05-06 10:46:30 +02:00
Nikita Popov 178bbe3478 Fixed bug #81015
Make sure that the previous opline is part of the same block,
otherwise it may be non-dominating.

The test case does not fail on PHP-7.4, but I think the general
problem can appear on 7.4 as well, so I'm applying the patch to
that branch.
2021-05-06 10:46:00 +02:00
Aaron Piotrowski 779fe8e43a Check current_execute_data instead of flags in fiber destructor
Checking EG(current_exectue_data) throws into the previous fiber instead of triggering a fatal error during shutdown. A fatal error is triggered only if the throwing destroyed fiber was resumed from {main}.
2021-05-05 10:48:30 -05:00
Nikita Popov f9ac667b98 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #81007
2021-05-05 16:54:06 +02:00
Nikita Popov bf9dc53435 Fixed bug #81007
Backport a change from the master branch. We usually test 32-bit
using -m32 from an x86-64 host, probably nobody tried using an
actual 32-bit host.
2021-05-05 16:53:43 +02:00
Máté Kocsis 7df7867624 Merge branch 'PHP-8.0'
* Fix the signature of PDOStatement::fetchObject()
2021-05-05 16:51:23 +02:00
Máté KocsisandNikita Popov 068c8db276 Fix the signature of PDOStatement::fetchObject()
The ?array $ctorArgs = null parameter is changed to array $constructorArgs = [], and an additional memory leak revealed by the new test case is fixed.

Closes GH-6937

Co-Authored-By: Nikita Popov <nikita.ppv@gmail.com>
2021-05-05 16:48:22 +02:00
Christoph M. Becker 1779f6838d Merge branch 'PHP-8.0'
* PHP-8.0:
  Add CONFLICTS file for PDO firebird tests
2021-05-05 15:26:23 +02:00
Christoph M. Becker 9e51b487f3 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Add CONFLICTS file for PDO firebird tests
2021-05-05 15:24:58 +02:00
Nikita Popov 896e4d3428 Add CONFLICTS file for PDO firebird tests
Just in case anybody executes these test in parallel on PHP 7.4.

(cherry picked from commit b4ffe54174)

Closes GH-6943.
2021-05-05 15:24:30 +02:00
George Peter Banyard 27d40da95d Convert IMAPConnection to IMAP\Connection 2021-05-05 14:22:43 +01:00
Christoph M. Becker f932d3d356 Merge branch 'PHP-8.0'
* PHP-8.0:
  Update version in php_version.h as well
2021-05-05 15:21:21 +02:00
Christoph M. Becker 8294ad3295 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Update version in php_version.h as well
2021-05-05 15:20:37 +02:00
Christoph M. Becker 125fc0b8d4 Update version in php_version.h as well
The version there is automatically updated during `./configure`, but
not on Windows.
2021-05-05 15:18:46 +02:00
Nikita Popov fb374f56a7 Rethrow exceptions in fiber destructor
We need to make sure that HANDLE_EXCEPTION is set when the fiber
throws during destruction.

Fixes oss-fuzz #33875.
2021-05-05 12:49:47 +02:00
Nikita Popov c15dc63ad2 Merge branch 'PHP-8.0'
* PHP-8.0:
  openssl_pkcs7_read: input is data not filename
2021-05-05 09:50:11 +02:00
Vincent JARDIN bb0107b63d openssl_pkcs7_read: input is data not filename
The argument should be an input string and not a filename.

Fix: https://github.com/php/doc-en/pull/559
Suggested-by: George Peter Banyard <girgias@php.net>

Closes GH-6942.
2021-05-05 09:49:53 +02:00
Sara Golemon 230ccda431 Merge branch 'PHP-8.0'
* PHP-8.0:
  Reset for 8.0.7
2021-05-04 17:18:40 +00:00
Sara Golemon f020d537b0 Reset for 8.0.7 2021-05-04 17:17:20 +00:00
Christoph M. Becker 592cfa309e Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #81011: mb_convert_encoding removes references from arrays
2021-05-04 18:40:23 +02:00
Christoph M. Becker d1c0cbdcb1 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #81011: mb_convert_encoding removes references from arrays
2021-05-04 18:39:39 +02:00
Christoph M. Becker 0cafd53d18 Fix #81011: mb_convert_encoding removes references from arrays
We need to dereference references.

Closes GH-6938.
2021-05-04 18:37:40 +02:00
Nikita Popov 4411026217 Close generator already in dtor phase
In the added test case, the Closure ends up being freed before
the generator during GC.

This patch closes the generator (and thus releases the held
closure / execute_data) already during dtor_obj, which will avoid
ordering issues in free_obj. dtor_obj is not always called, but
if it isn't, then we also won't run GC and will free_obj in
reverse construction order.

Fixes oss-fuzz #33947.
2021-05-04 16:59:59 +02:00
Nikita Popov 2aac616071 Merge branch 'PHP-8.0'
* PHP-8.0:
  Don't treat failed assignment as initialization
2021-05-04 14:46:52 +02:00
Nikita Popov 398cfb982e Don't treat failed assignment as initialization
Only reset the uninitialized property flag once the type check
has succeeded. Previously the property was treated as unset rather
than uninitialized after a failed assignment.

Noticed this edge-case while working on accessors...
2021-05-04 14:46:04 +02:00
Derick Rethans d2e989d176 Merge branch 'PHP-8.0' 2021-05-04 12:18:53 +01:00
Derick Rethans 5ce0fa2129 Merge branch 'PHP-7.4' into PHP-8.0 2021-05-04 12:18:41 +01:00
Derick Rethans 0328ff49cc Reset PHP-7.4 for 7.4.20 2021-05-04 12:18:27 +01:00
Nikita Popov 31c74aaeeb Use EXTENSIONS instead of SKIPIF section 2021-05-03 18:37:42 +02:00
Christoph M. Becker 895185e5ea Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #79100: Wrong FTP error messages
2021-05-03 15:25:17 +02:00
Christoph M. Becker c2a06f5d9a Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #79100: Wrong FTP error messages
2021-05-03 15:24:17 +02:00
Christoph M. Becker 42c72ef463 Fix #79100: Wrong FTP error messages
First we need to properly clear the `inbuf`, what is an amendment to
commit d2881adcbc[1].

Then we need to report `php_pollfd_for_ms()` failures right away; just
setting `errno` does not really help, since at least in some cases it
would have been overwritten before we actually could check it.  We use
`php_socket_strerror()` to get a proper error message, and define
`ETIMEDOUT` to the proper value on Windows; otherwise we catch the
definition in errno.h, which is not compatible with WinSock.  The
proper solution for this issue would likely be to include something
like ext/sockets/windows_common.h.

Finally, we ensure that we only report warnings using `inbuf`, if it is
not empty.

[1] <http://git.php.net/?p=php-src.git;a=commit;h=d2881adcbc9be60de7e7d45a3316b0e11b7eb1e8>.

Closes GH-6718.
2021-05-03 15:19:57 +02:00
Máté Kocsis e2ad44357e Merge branch 'PHP-8.0'
* Fix the default value of $mode in PDOStatement::fetch*()
2021-05-03 13:08:36 +02:00
Máté Kocsis 30d3062c9b Fix the default value of $mode in PDOStatement::fetch*()
Closes GH-6933
2021-05-03 13:06:38 +02:00
Christoph M. Becker 768e8b8319 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #73246: XMLReader: encoding length not checked
2021-05-03 12:30:29 +02:00
Christoph M. Becker 645815c5b7 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #73246: XMLReader: encoding length not checked
2021-05-03 12:29:24 +02:00
Christoph M. Becker 272df442f5 Fix #73246: XMLReader: encoding length not checked
libxml2 expects the passed encoding to be NUL terminated, so we reject
strings with NUL bytes right away.

Closes GH-6899.
2021-05-03 12:26:37 +02:00
Kamil Tekiela 54222a6fe4 Implement mysqli_fetch_column (#6798)
* Implement mysqli_fetch_column
2021-05-01 20:11:47 +01:00
Aaron Piotrowski 810fb59f66 Improve fiber backtraces
The start/resume/throw execute_data is now attached as the prev_execute_data to the bottom frame of the fiber stack when the fiber is running.
2021-04-30 12:17:50 -05:00
Aaron Piotrowski f3465e6740 Minor fiber fixes
Assert error is fatal when calling zend_error_suspend_fiber.

Added missing static.

Removed .S extension from output of configure.
2021-04-30 10:08:01 -05:00
Nikita Popov 28dbdd529c Re-enable observer fatal error test
Now that zend_call_function() no longer inserts dummy frames,
this should be safe and no longer fail on some platforms.
2021-04-30 16:05:35 +02:00
Nikita Popov 8fc5daeb3f Use sapi/cli/php to run tests for faster failure (#6931)
We always run test steps on azure, even if a previous step failed, because we
don't want a failure in one configuration to prevent testing of other
configurations. However, if building PHP fails in the first place, then we
currently end up testing the system PHP binary. This is not only useless, but
will also result in a test runner hang and cause the job to time out.

Avoid this by using sapi/cli/php instead of the installed php as the test
binary. If we fail to build, then it will not exist, and testing will fail
immediately.
2021-04-30 12:53:56 +02:00
Nikita Popov b9040852b3 Slightly clarify zend_wrong_parameter_error() implementation
This function may be called with Z_ERROR_FAILURE, and should do
nothing in that case. Otherwise, all cases need to be explicitly
handled.
2021-04-30 10:38:34 +02:00
Nikita Popov feab479884 Also destroy classes in reverse order with ZTS 2021-04-30 09:58:29 +02:00
Aaron Piotrowski 4166653298 Fix exception thrown during fiber destruction
Previously an exception thrown during fiber destruction resulted in a fatal error, but that exception should be able to be caught (unless we’ve entered shutdown, then still use a fatal error so the error is not hidden).
2021-04-30 00:26:47 -05:00
Nikita Popov 79d237c8b6 Remove some unnecessary exception type checks
These types are enforced by typed properties now.
2021-04-29 21:23:58 +02:00
Nikita Popov 79071d5e3e Don't duplicate internal prop info (#6929)
Userland property infos are no longer duplicated since PHP 7.4, when we
stopped setting SHADOW flags on inherited private properties. Stop duplicating
internal property infos as well.

This requires switching class destruction to work in reverse order, as child
classes may be reusing structures from parent classes, and as such should be
destroyed first.
2021-04-29 20:31:24 +02:00
Nikita Popov dd86987b2c Replay warnings during inheritance (#6928)
Since 3e6b447979 it is again possible to have
warnings (deprecations) during inheritance, and more such functionality is
likely in the future. This is a problem, because such warnings will only be
shown on the first request if the opcache inheritance cache is used. This
currently causes test failures in --repeat builds.

Fix this by uplifting the error recording functionality from opcache to Zend,
and then using it to persist a warning trace in the inheritance cache, which
can then be used to replay the warnings on subsequent executions.
2021-04-29 16:37:53 +02:00
Matteo Beccati f84936b30c Merge branch 'PHP-8.0'
* PHP-8.0:
  Revert "Fix #80892: PDO::PARAM_INT is treated the same as PDO::PARAM_STR"
2021-04-29 12:06:11 +02:00
Matteo Beccati 7bc9df4af2 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Revert "Fix #80892: PDO::PARAM_INT is treated the same as PDO::PARAM_STR"
2021-04-29 12:05:49 +02:00
Matteo Beccati b8e49fe872 Revert "Fix #80892: PDO::PARAM_INT is treated the same as PDO::PARAM_STR"
This reverts commit 340a06778c.
2021-04-29 11:59:16 +02:00
Nikita Popov e8e7c04a3a Use common struct to store error information
This is needed by both fibers and opcache (and GH-6903 also uses it),
so make it a common structure that can be used by any functionality
storing warnings/errors.
2021-04-29 11:50:54 +02:00
Nikita Popov bf7a244588 Merge branch 'PHP-8.0'
* PHP-8.0:
  Show used git commit in community tests
2021-04-29 11:05:04 +02:00
Nikita Popov 47bed58a53 Show used git commit in community tests
So we know exactly which revision was tested.
2021-04-29 11:03:48 +02:00
Nikita Popov 39e1af662b Fix out-of-tree build
Add Zend/asm as a build directory.
2021-04-29 10:13:47 +02:00
Nikita Popov 81d1c1bc78 Remove accidentally added flag 2021-04-29 09:46:47 +02:00
Nikita Popov 9a1da9f61f Don't use separate static variables in inherited methods
RFC: https://wiki.php.net/rfc/static_variable_inheritance

Closes GH-6719.
2021-04-28 17:08:50 +02:00
Nikita Popov 3e6b447979 Partially deprecate Serializable
If Serializable is implemented, require that __serialize() and
__unserialize() are implemented as well, else issue a deprecation
warning.

Also deprecate use of PDO::FETCH_SERIALIZE.

RFC: https://wiki.php.net/rfc/phase_out_serializable

Closes GH-6494.
2021-04-28 16:55:14 +02:00
Nikita Popov 5295e368b4 Filter return value of ReflectionClassConstant::getModifiers()
Don't return internal flags like IS_CASE.
2021-04-28 14:55:37 +02:00
Nikita Popov fd1d5ec2b4 Add ZEND_CLASS_CONST_FLAGS() macro
And drop Z_ACCESS_FLAGS(). We no longer store *only* access flags
in these.
2021-04-28 14:51:54 +02:00
Nikita Popov 88ce1c71b5 Look up func info using function name rather than lcname of call
As we already have the called zend_function here, let's use the
name directly, rather than using the lcname of the call. This means
that aliases would be handled correctly automatically.
2021-04-28 12:13:05 +02:00
Nikita Popov 97c6d6605e Remove FR/FX macros
Functions returning by-reference are generally a lost cause, we
won't be able to provide useful information for them.
2021-04-28 12:13:01 +02:00
Nikita Popov d0610898f6 Remove UNKNOWN_INFO func info entries
There's no need to explicitly list that we don't know anything
about a function -- that's the default state.
2021-04-28 11:45:34 +02:00
Nikita Popov bfa8b49196 Merge branch 'PHP-8.0'
* PHP-8.0:
  Remove incorrect func info for array_reduce() and pos()
2021-04-28 11:41:59 +02:00
Nikita Popov 2ceef24f4a Remove incorrect func info for array_reduce() and pos()
These are both clearly not rc1 functions. As they are otherwise
UNKNOWN_INFO, I'm just dropping them entirely.
2021-04-28 11:41:21 +02:00
Nikita Popov 08afe9891c Merge branch 'PHP-8.0'
* PHP-8.0:
  filter_var_array() may return array_of_ref
2021-04-28 11:28:06 +02:00
Nikita Popov 028dd891f9 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  filter_var_array() may return array_of_ref
2021-04-28 11:27:55 +02:00
Nikita Popov 5acab7ebb4 filter_var_array() may return array_of_ref
This function preserves references in the input array.
2021-04-28 11:27:14 +02:00
Nikita Popov b5778ce1b7 Merge branch 'PHP-8.0'
* PHP-8.0:
  fetch_assoc may return array_key_long
2021-04-28 11:20:55 +02:00
Nikita Popov 220ffb90d0 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  fetch_assoc may return array_key_long
2021-04-28 11:20:38 +02:00
Nikita Popov 67c4d1f5b9 fetch_assoc may return array_key_long
If the column name is a number (which is possible at least via
AS clauses), then symtable canonicalization will convert it into
an integer key.
2021-04-28 11:18:36 +02:00
Nikita Popov e8ef923dd6 Merge branch 'PHP-8.0'
* PHP-8.0:
  Remove assert_options() return value info
2021-04-28 11:06:54 +02:00
Nikita Popov 76d1120a48 Remove assert_options() return value info
The ASSERT_CALLBACK value is not validated at all -- it's possible
to set it to an arbitrary value. As such, the function can also
return any value or type (even without outright abuse, the opcache
func info was wrong in that the return can be rcn, and the array
can be array_of_ref).
2021-04-28 11:05:05 +02:00
Nikita Popov bd5419abd6 Merge branch 'PHP-8.0'
* PHP-8.0:
  password_get_info() may return array_of_null
2021-04-28 10:55:57 +02:00
Nikita Popov af9fadc55a Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  password_get_info() may return array_of_null
2021-04-28 10:55:43 +02:00
Nikita Popov c340f97ab0 password_get_info() may return array_of_null
The algo key is set to null if the algorithm can't be detected.
2021-04-28 10:54:31 +02:00
Nikita Popov 3ddab31842 Merge branch 'PHP-8.0'
* PHP-8.0:
  getdate() may return array_key_long
2021-04-28 10:48:04 +02:00
Nikita Popov 4a5bda6a8d Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  getdate() may return array_key_long
2021-04-28 10:47:45 +02:00
Nikita Popov c7387ab92f getdate() may return array_key_long
This function mostly uses string keys, but the timestamp is
returned at key 0 (why???)
2021-04-28 10:46:37 +02:00
Nikita Popov cb1d1138f6 Merge branch 'PHP-8.0'
* PHP-8.0:
  pg_connect() may return rcn
2021-04-28 10:38:07 +02:00
Nikita Popov 98a071e880 pg_connect() may return rcn
Without CONNECT_FORCE_NEW, pg_connect() may resuse an existing
connection and refcount may be larger than one.
2021-04-28 10:36:48 +02:00
Nikita Popov 2ffab441c8 Fix pgsql func info
Some functions can now return a value with refcount > 1.
2021-04-28 10:14:29 +02:00
Nikita Popov 331eddadc8 Make date/time type arguments of IntlDateFormatter ctor optional
Default them to IntlDateFormatter:FULL, which has value 0, which
was what you would get if you passed null to these arguments in
weak typing mode. The documentation called this ICU's default
date/time type.
2021-04-27 23:58:38 +02:00
Nikita Popov bd2c743f1d Merge branch 'PHP-8.0'
* PHP-8.0:
  Remove incorrect format argument
2021-04-27 22:23:22 +02:00
Nikita Popov 9ce5776922 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Remove incorrect format argument
2021-04-27 22:23:06 +02:00
Nikita Popov 3f71ba2611 Remove incorrect format argument
rc is not used by the printf format.
2021-04-27 22:22:32 +02:00
Dmitry Stogov 721bd973f9 Fixed CPU detection 2021-04-27 23:00:09 +03:00
Christoph M. Becker 7be5e78dab Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #80460: ODBC doesn't account for SQL_NO_TOTAL indicator
2021-04-27 17:12:58 +02:00
Christoph M. Becker 4c80e439a8 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #80460: ODBC doesn't account for SQL_NO_TOTAL indicator
2021-04-27 17:12:01 +02:00
Christoph M. Becker 7f83976200 Fix #80460: ODBC doesn't account for SQL_NO_TOTAL indicator
The `StrLen_or_IndPtr` parameter usually may be `SQL_NO_TOTAL`; we need
to cater to that possibility to avoid working with negative string
lengths and other issues.  A noteable exemption are calls to
`SQLGetData()` which return `SQL_SUCCESS`; in that case `SQL_NO_TOTAL`
can not occur.

Closes GH-6809.
2021-04-27 17:09:36 +02:00
Christoph M. Becker 9b59f931e8 Merge branch 'PHP-8.0'
* PHP-8.0:
  7.3.29 is next
2021-04-27 17:06:05 +02:00
Christoph M. Becker 606b2c39fc Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  7.3.29 is next
2021-04-27 16:58:32 +02:00
Christoph M. Becker 66308af539 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  7.3.29 is next
2021-04-27 16:56:53 +02:00
Christoph M. Becker 98c8ad9218 7.3.29 is next 2021-04-27 16:55:20 +02:00
Christoph M. Becker b52106f6b9 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix ./makedist wrt. to GH move
2021-04-27 15:51:24 +02:00
Christoph M. Becker e1f8763a2c Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix ./makedist wrt. to GH move
2021-04-27 15:50:54 +02:00
Christoph M. Becker 20b62ade29 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix ./makedist wrt. to GH move
2021-04-27 15:49:59 +02:00
Christoph M. BeckerandRemi Collet 096f148c61 Fix ./makedist wrt. to GH move
We can no longer export from git.php.net, and apparently exporting from
Github is not supported.  We apply a quick fix to export from the local
clone by default, still leaving an option to export from some other
repo.  This is, unfortunately, a minor BC break in a security release.

Co-authored-by: Remi Collet <remi@php.net>

Closes GH-6919.
2021-04-27 15:48:58 +02:00
Christoph M. Becker 006889f03f Merge branch 'PHP-8.0'
* PHP-8.0:
  Add missing NEWS entry for #80710
2021-04-27 13:44:28 +02:00
Christoph M. Becker 3e518e069d Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Add missing NEWS entry for #80710
2021-04-27 13:43:12 +02:00
Christoph M. Becker 12e15be921 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Add missing NEWS entry for #80710
2021-04-27 13:41:20 +02:00
Christoph M. Becker 60a68a45c3 Add missing NEWS entry for #80710 2021-04-27 13:38:39 +02:00
Nikita Popov 61ba79df17 Remove variable registration code from rfc1867
This now longer does anything -- registering a variable for a NULL
array is a no-op.
2021-04-27 12:30:46 +02:00
Michael Voříšek 4d78598e8e Remove spaces around version built type 2021-04-27 10:12:28 +02:00
Nikita Popov b74f5ee477 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix build warning
2021-04-27 10:11:20 +02:00
Nikita Popov 7544f66da9 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix build warning
2021-04-27 10:10:55 +02:00
Nikita Popov 310c0561a9 Fix build warning
This causes the build to fail on PHP-8.0 and higher.
2021-04-27 10:10:22 +02:00
Stanislav Malyshev 3d2c810eeb Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #80710: imap_mail_compose() header injection
2021-04-26 22:26:42 -07:00
Stanislav Malyshev a4d9ccbcd6 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #80710: imap_mail_compose() header injection
2021-04-26 21:49:38 -07:00
Stanislav Malyshev 568df31698 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #80710: imap_mail_compose() header injection
2021-04-26 21:48:16 -07:00
Christoph M. Becker 37962c61d2 Fix #80710: imap_mail_compose() header injection
Like `mail()` and `mb_send_mail()`, `imap_mail_compose()` must prevent
header injection.  For maximum backward compatibility, we still allow
header folding for general headers, and still accept trailing line
breaks for address lists.
2021-04-26 21:43:03 -07:00
Stanislav Malyshev 476888d99b Merge branch 'PHP-8.0'
* PHP-8.0:
  Revert "Fix #80852: Stack-overflow when json_encode()'ing SimpleXMLElement"
2021-04-26 21:03:23 -07:00
Stanislav Malyshev eed03fce59 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Revert "Fix #80852: Stack-overflow when json_encode()'ing SimpleXMLElement"
2021-04-26 21:02:09 -07:00
Stanislav Malyshev 2b3346208a Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Revert "Fix #80852: Stack-overflow when json_encode()'ing SimpleXMLElement"
2021-04-26 21:02:03 -07:00
Stanislav Malyshev 1b88c85cd8 Revert "Fix #80852: Stack-overflow when json_encode()'ing SimpleXMLElement"
Sorry, this solution seems to have BC breaks, will need to look
for better one.

This reverts commit 9f7e8b777c.
2021-04-26 21:01:25 -07:00
Stanislav Malyshev 833fac34d0 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #80852: Stack-overflow when json_encode()'ing SimpleXMLElement
2021-04-26 20:51:46 -07:00
Stanislav Malyshev 6de2d54425 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #80852: Stack-overflow when json_encode()'ing SimpleXMLElement
2021-04-26 20:50:29 -07:00
Stanislav Malyshev 76637017ac Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #80852: Stack-overflow when json_encode()'ing SimpleXMLElement
2021-04-26 20:50:15 -07:00
Christoph M. Becker 9f7e8b777c Fix #80852: Stack-overflow when json_encode()'ing SimpleXMLElement
We ignore `XML_ENTITY_DECL` nodes when getting the hash of the
properties of a `SimpleXMLElement`.
2021-04-26 20:43:45 -07:00
Máté Kocsis 12799847a6 Merge branch 'PHP-8.0'
* Fix pg_get_notify() parameter name
2021-04-26 19:38:57 +02:00
Máté Kocsis d1e590fe72 Fix pg_get_notify() parameter name
Closes GH-6916
2021-04-26 19:37:41 +02:00
Aaron Piotrowski c276c16b66 Implement Fibers
RFC: https://wiki.php.net/rfc/fibers

Closes GH-6875.
2021-04-26 11:07:06 -05:00
Nikita Popov ba337577a8 Use zend_string for pgsql_trim_message 2021-04-26 16:45:38 +02:00
Christoph M. Becker 50f5877769 Fix new test wrt. removed skipif.inc 2021-04-26 16:29:43 +02:00
Nikita Popov f26047fc9b Don't store resolved pgsql field/table oids as resources
Store these in hash tables indexed by oid. This is simpler and
more efficient, as we don't need to create resources or hash keys.
2021-04-26 15:24:07 +02:00
Christoph M. Becker 01b71f49d3 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #80901: Info leak in ftp extension
2021-04-26 15:09:34 +02:00
Christoph M. Becker 2bce26f2aa Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #80901: Info leak in ftp extension
2021-04-26 15:08:44 +02:00
Christoph M. Becker c0ae3a7fb7 Fix #80901: Info leak in ftp extension
We ensure that inbuf is NUL terminated on `ftp_readline()` failure.

Closes GH-6894.
2021-04-26 15:07:08 +02:00
Christoph M. Becker 61185252bf Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix typo in NEWS
2021-04-26 15:05:02 +02:00
Christoph M. Becker bc6fc61c04 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix typo in NEWS
2021-04-26 15:03:10 +02:00
Christoph M. Becker 7f9183ce20 Fix typo in NEWS 2021-04-26 15:02:13 +02:00
Nikita Popov 8a283f7b87 Store pgsql le_string as zend_string 2021-04-26 15:01:44 +02:00
Christoph M. Becker fff93b6946 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix Bug #80972: Memory exhaustion on invalid string offset
2021-04-26 14:59:45 +02:00
Christoph M. Becker 361df6d39c Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix Bug #80972: Memory exhaustion on invalid string offset
2021-04-26 14:59:18 +02:00
Christoph M. Becker 5d7219dce6 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #80901: Info leak in ftp extension
2021-04-26 14:46:43 +02:00
Christoph M. Becker 33d49551d1 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #80901: Info leak in ftp extension
2021-04-26 14:45:55 +02:00
Christoph M. Becker 09696eee9d Fix #80901: Info leak in ftp extension
We ensure that inbuf is NUL terminated on `ftp_readline()` failure.

Closes GH-6894.
2021-04-26 14:23:04 +02:00
George Peter Banyard 7372a3e117 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix Bug #80972: Memory exhaustion on invalid string offset
2021-04-26 13:22:37 +01:00
George Peter Banyard 97f8ca52fa Fix Bug #80972: Memory exhaustion on invalid string offset
Closes GH-6909
2021-04-26 13:22:12 +01:00
George Peter Banyard 418fcd22e8 Fix Bug #80972: Memory exhaustion on invalid string offset
Closes GH-6890
2021-04-26 13:21:40 +01:00
Joe Watkins f9d1a7290b exclude markdown 2021-04-26 13:33:36 +02:00
Joe Watkins fec4bdb112 Revert "Exclude more text-only paths from azure pipelines (#6876)"
This reverts commit ec8de47e1e.
2021-04-26 13:33:10 +02:00
Máté Kocsis b567a9d173 Use typed properties in ext/zip
Closes GH-6881
2021-04-26 13:21:17 +02:00
Calvin Buckley 28a66b3f02 Check liveness in PDO_ODBC
PDO drivers allow for it, and procedural ODBC has its own facility
for it, but PDO_ODBC doesn't. If a connection is severed (for example,
on IBM i, ending a databse job, or killing the network connection
elsewhere), a persistent connection could get stuck. This adapts the
procedural ODBC code to PDO for handling connection liveness, so PDO
can reconnect if needed.

A discussion about the method to check liveness is linked; this might
not be the best method, but it's what procedural ODBC uses, so it's
consistent.

Closes GH-6805.
2021-04-26 13:03:07 +02:00
Christoph M. Becker 93e6796fc0 Merge branch 'PHP-8.0'
* PHP-8.0:
  Export gzfwrite()
2021-04-26 12:12:48 +02:00
Christoph M. Becker fe219d912e Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Export gzfwrite()
2021-04-26 12:12:04 +02:00
Christoph M. Becker a2771296c0 Export gzfwrite()
Extensions calling `gzfwrite()` cannot be built when linked against
php.dll (built with zlib support) otherwise.

Closes GH-6880.
2021-04-26 12:09:31 +02:00
matt 25dc931d83 Fixed bug #80908
The last insert ID should be an unsigned integer.

Closes GH-6810.
2021-04-26 11:50:12 +02:00
Himanshu ec8de47e1e Exclude more text-only paths from azure pipelines (#6876)
Skip build for changes in text-only files.
2021-04-26 11:28:13 +02:00
Máté Kocsis 0cd06d1d19 Merge branch 'PHP-8.0'
* Fix arginfo/ZPP mismatch for simplexml_import_dom
2021-04-26 11:12:12 +02:00
Máté Kocsis cb84e5c332 Fix arginfo/ZPP mismatch for simplexml_import_dom
Closes GH-6905
2021-04-26 11:09:30 +02:00
Mark Gallagher 39876ba1c6 run-tests: Fix warning when specifying xdebug as a required extension 2021-04-25 22:07:00 +02:00
Kamil Tekiela 0a779040a0 Add test case for errorCode() 2021-04-25 15:57:43 +01:00
Kamil Tekiela 3292b9761a Add ZEND_ASSERT to stmt->errorCode 2021-04-25 15:57:43 +01:00
Anatol Belski 9b78000432 Revert "fileinfo: Obey POSIX in pattern conversion"
This reverts commit 343d1c2b1f.

Also remove the incompatible test data for time being. The new line
handling will need an extra fix.

Signed-off-by: Anatol Belski <ab@php.net>
2021-04-24 14:59:53 +02:00
Anatol Belski 343d1c2b1f fileinfo: Obey POSIX in pattern conversion
Signed-off-by: Anatol Belski <ab@php.net>
2021-04-24 01:40:15 +02:00
Anatol Belski 34bdab538b fileinfo: Pull upstream tests
Integrating the upstream tests is important to ensure the quality of the
patch and to ensure the parity in the function.

Signed-off-by: Anatol Belski <ab@php.net>
2021-04-23 22:01:34 +02:00
Nikita Popov 0c3f70730b Slightly clean up error_reporting() implementation
zend_long_to_str() cannot throw, and we don't really need the
do/while block either.
2021-04-23 17:11:35 +02:00
Christoph M. Becker 3bb62eee5b Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #67792: HTTP Authorization schemes are treated as case-sensitive
2021-04-23 15:58:21 +02:00
Christoph M. Becker 23a192d12d Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #67792: HTTP Authorization schemes are treated as case-sensitive
2021-04-23 15:57:11 +02:00
Christoph M. Becker 39ddf6b89c Fix #67792: HTTP Authorization schemes are treated as case-sensitive
We use `zend_binary_strncasecmp()` to avoid any locale issues, and
refactor.  We also add a test case for Digest authentication.

Closes GH-6900.
2021-04-23 15:54:17 +02:00
Nikita Popov 78e1f190fc Export zend_error_zstr_at()
This is the formerly static function zend_error_impl(), which is
the core error handling implementation.
2021-04-23 11:29:55 +02:00
Nikita Popov dc7030300c Use interned strings for error_get_last()
We have known strings for all the array keys, use them.
2021-04-23 11:05:14 +02:00
Nikita Popov b66eb866c9 Convert last_error_file to zend_string 2021-04-23 11:05:14 +02:00
Nikita Popov a1c6ee2164 Convert error filename to zend_string
Error handling functions/callbacks now accept the error filename
as a zend_string* instead of a const char*.
2021-04-23 11:05:14 +02:00
Dmitry Stogov 8c420bd265 Remove useless masking 2021-04-22 23:49:02 +03:00
Máté Kocsis 30a082cb16 Make some exception properties typed
Closes GH-6891
2021-04-22 10:22:50 +02:00
Nikita Popov 31b6f842cc Merge branch 'PHP-8.0'
* PHP-8.0:
  PHPDBG: fix bug parsing 3-word opcodes
2021-04-22 10:12:47 +02:00
Nikita Popov b0f030509a Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  PHPDBG: fix bug parsing 3-word opcodes
2021-04-22 10:12:25 +02:00
David Rans 054fad6d63 PHPDBG: fix bug parsing 3-word opcodes
PHPDBG won't parse opcodes correctly if they are more than two words
separated by underscores (as many opcodes, like ZEND_POST_INC, are).

Now opcodes that have more than one underscore (e.g. ZEND_POST_INC) are
parsed correctly.

Closes GH-6895.
2021-04-22 10:11:26 +02:00
Niklas Keller 59d5b3dd51 Accept null for microseconds argument in stream_select() (#6879)
The deprecation of passing null is thrown otherwise.

If the timeout is calculated conditionally before calling stream_select(), passing to avoid the deprecation seems unreasonable, example:

https://github.com/amphp/amp/blob/7d4bbc6e0b47c6bb39b6cce1a4b5942e0c5125fb/lib/Loop/NativeDriver.php#L286

Also enforce that if $seconds is null, then $microseconds should be null as well. However 0 is still accepted (with deprecation) for backwards compatibility.
2021-04-22 10:09:55 +02:00
Dmitry Stogov 76452651ba Fixed incorrect error message 2021-04-22 02:40:22 +03:00
Dmitry Stogov 3c37a3426b Fixed possible incorrect assumption if constant is a power of 2. 2021-04-22 02:32:49 +03:00
David CARLIER 7aba6de1d0 stream: Fix MacOS build. fsync as alias for fdatasync. (#6882)
If fdatasync is not available, use fsync instead.

For some reason, fdatasync is available when using clang from Xcode, even though no declaration is present in headers.
2021-04-21 16:21:43 +02:00
Máté Kocsis 533a6bcb29 Get rid of private final methods (#6892) 2021-04-21 10:08:25 +02:00
George Peter Banyard d24cf1a417 Introduce zend_error_unchecked()
To be used with custom formats like %H as otherwise the compiler complains about unknown formats
2021-04-20 19:41:36 +01:00
Christoph M. Becker 950bb84c7e Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix php_pgsql_fd_cast() wrt. php_stream_can_cast()
2021-04-20 18:32:05 +02:00
Christoph M. Becker 3c6480552d Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix php_pgsql_fd_cast() wrt. php_stream_can_cast()
2021-04-20 18:30:25 +02:00
Christoph M. Becker 1fcea24efb Fix php_pgsql_fd_cast() wrt. php_stream_can_cast()
`php_stream_can_cast()` forwards to `_php_stream_cast()` with `ret` set
to `NULL`.  `php_pgsql_fd_cast()` needs to cater to that, because
otherwise the stream would report that it is not castable.

This *might* fix https://bugs.php.net/73903.

Closes GH-6888.
2021-04-20 18:29:12 +02:00
Christoph M. Becker 8667dc92aa Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix misleading error message
2021-04-20 15:45:26 +02:00
Christoph M. Becker 0f40426450 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix misleading error message
2021-04-20 15:43:04 +02:00
Christoph M. Becker 263f14ac60 Fix misleading error message
Closes GH-6889.
2021-04-20 15:41:42 +02:00
Máté Kocsis f11411ea0d Use typed property in PDOException 2021-04-20 14:45:42 +02:00
Máté Kocsis a92f5cbe32 Use typed property in RegexIterator 2021-04-20 14:45:42 +02:00
Máté Kocsis 8c97fc88f3 Use typed properties in php_user_filter 2021-04-20 14:45:42 +02:00
Máté Kocsis 750b04a6e1 Use typed properties in ext/curl 2021-04-20 14:45:42 +02:00
Nikita Popov c4a749c932 Remove php includes from sccp.c 2021-04-20 12:26:12 +02:00
Nikita Popov b82242a88d Remove unnecessary php.h includes from Zend/
The Zend/ directory really shouldn't be including php headers.
These particular includes are plain unnecessary.
2021-04-20 12:21:45 +02:00
Máté Kocsis ec3bdd3ba8 Merge branch 'PHP-8.0'
* Fix return type of SessionHandler::read()
2021-04-20 11:57:48 +02:00
Máté Kocsis ffb1ff371c Fix return type of SessionHandler::read() 2021-04-20 11:56:54 +02:00
Nikita Popov 37173460b0 Update config.guess (#6886)
In particular, this pulls in support for Apple M1 detection.
2021-04-20 10:47:47 +02:00
Nikita Popov 9799cf989c Reset property table for disabled classes
To avoid retaining behavior about property visibility or types.
2021-04-20 10:35:10 +02:00
Nikita Popov a3da56226a Use -Wno-implicit-fallthrough for pcre
sljitNativeARM_64.c has implicit fallthrough.
2021-04-20 10:07:11 +02:00
Nikita Popov 5d2f6c4d5d Update mysql version on libmysqclient job
Apparently these files don't stay available forever. Update to
a newer version.
2021-04-20 09:59:30 +02:00
George Peter Banyard 612609e1bd Refactor PGSQL extension to use zend_string*
* Prevents some unnecessary strlen() computation
 * Use interned "NULL"
 * Certain PGSQL_API functions now accept zend_string* instead of char*

Closes GH-6792
2021-04-19 20:33:40 +01:00
George Peter Banyard 0ffb4a5c9d Boolify do_exec() 2021-04-19 20:33:05 +01:00
George Peter Banyard fabcfd6d81 Formalize return type to zend_result for PGSQL_API functions 2021-04-19 20:33:05 +01:00
George Peter Banyard 6eb23e2b83 ValueError if lengths is less than 0 2021-04-19 20:27:34 +01:00
George Peter Banyard 13693aaf7e Use ZEND_ASSERT() instead of plain assert() 2021-04-19 20:27:34 +01:00
George Peter Banyard 6569aedee3 Use ZEND_NUM_ARGS() explicitly 2021-04-19 20:27:34 +01:00
George Peter Banyard a5fb43f2b1 Boolify _php_pgsql_link_has_results() 2021-04-19 20:27:34 +01:00
George Peter Banyard 8ae9922348 Boolify _php_pgsql_detect_identifier_escape() and rename it
New name is  _php_pgsql_identifier_is_escaped()
2021-04-19 20:27:34 +01:00
George Peter Banyard 7a1af523fa Fix test output due to float to string locale independent change
Also use de_DE locale instead
2021-04-19 20:27:33 +01:00
Christoph M. Becker 84a3f59d45 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix expected error message
2021-04-19 18:49:55 +02:00
Christoph M. Becker 8a7b786b7f Fix expected error message
These are slightly changed as of PHP 8.0.0.
2021-04-19 18:48:44 +02:00
Dmitry Stogov 08dafda123 Fixed use-after-free introduced by ca49e53670 2021-04-19 18:16:14 +03:00
Christoph M. Becker c8a966a9ae Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #80960: opendir() warning wrong info when failed on Windows
2021-04-19 16:18:03 +02:00
Christoph M. Becker cb262cd974 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #80960: opendir() warning wrong info when failed on Windows
2021-04-19 16:17:01 +02:00
Christoph M. Becker ea3c992bff Fix #80960: opendir() warning wrong info when failed on Windows
Firstly, we must not forget to set appropriate error codes for "manual"
checks in `virtual_file_ex()`.

Secondly, we must not call `php_error_docref2()` for warnings regarding
unary functions; thus, we introduce `php_win32_docref1_from_error()`.

Closes GH-6872.
2021-04-19 16:12:22 +02:00
George Peter Banyard dcdc5d9069 Drop -Wno-implicit-fallthrough compiler flag
And add it back to ext/date, ext/hash, and ext/opcache
2021-04-19 13:59:18 +01:00
George Peter Banyard e3403d80af Use ZEND_FALLTHROUGH instead of a comment in PDO 2021-04-19 13:59:18 +01:00
George Peter Banyard cef0076a88 Signal that the stream option passed is an error
Otherwise this falls through to the next case statement.
2021-04-19 13:59:18 +01:00
Nikita Popov 71cbef78ba Fixed bug #80111
Remove traverse_pointer before destroying the element contents.
2021-04-19 14:41:19 +02:00
Nikita Popov 044de83635 Prefer ZVAL_COPY
Instead of ZVAL_COPY_VALUE + Z_TRY_ADDREF. Also fix another leak
in SplDoublyLinkedList::add(), the push case was leaking as well.
2021-04-19 14:35:36 +02:00
Nikita Popov 497fadcacd Fix leak in SplDoublyLinkedList::add() 2021-04-19 13:08:35 +02:00
Nikita Popov 02db708cd4 Remove generic dtor+ctor from SPL dllist
This is only ever used with zvals. It was particularly confusing
because a lot of code mixed the generic code with zval specific
code.
2021-04-19 13:02:19 +02:00
Matt Brown 6cd0b48cac Implement never return type
The never type can be used to indicate that a function never
returns, for example because it always unwinds.

RFC: https://wiki.php.net/rfc/noreturn_type

Closes GH-6761.
2021-04-19 11:27:29 +02:00
Nikita Popov 6adfe9da98 Fix error messages for sodium_crypto_stream_xchacha20
And test them. Also adjust the constant check in the test so that
it actually runs.
2021-04-19 11:10:37 +02:00
P.I.E. Security Team f7f1f7fce2 Add crypto_stream_xchacha20 to ext/sodium (#6868)
Paragon Initiative Enterprises is aware of PHP applications that use sodium_compat's ParagonIE\Sodium\Core\XChaCha20 class directly for stream encryption.

Greater performance and security assurance is offered by exposing libsodium's crypto_stream_xchacha20 API to PHP users.

It's acceptable to only include this change in PHP 8.1+; the offending applications are more than welcome to either install ext/sodium from PECL or upgrade to 8.1 when it comes out later this year.

Ref: https://github.com/jedisct1/libsodium-php/pull/211
2021-04-19 11:04:29 +02:00
Nikita Popov 8bb81226c1 Handle debug_print_backtrace() from main script
If there is nothing to print, the smart_str will hold a nullptr.

Fixes oss-fuzz #33334.
2021-04-19 10:20:30 +02:00
twosee d05da0f06c Merge branch 'PHP-8.0'
* PHP-8.0:
  Backport "ignore some opcodes in the JIT check"
2021-04-19 14:29:17 +08:00
twosee d4a206b276 Backport "ignore some opcodes in the JIT check"
This is a backport of fc64a7bef4 to the PHP-8.0 branch so that extensions don’t have to bypass the JIT check in a hacky way.
2021-04-19 14:28:15 +08:00
Máté Kocsis 2bebe104c1 Update mysqli arginfo hash
[skip-ci]
2021-04-18 11:03:51 +02:00
Nikita Popov a460bf41db Fix i386 build on azure (#6877)
Explicitly specify --build=i686.
2021-04-17 20:35:01 +02:00
Christoph M. Becker 38b42314a4 Merge branch 'PHP-8.0'
* PHP-8.0:
  Update php_version.h
2021-04-16 17:56:44 +02:00
Christoph M. Becker d918c1443e Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Update php_version.h
2021-04-16 17:45:41 +02:00
Christoph M. Becker 0071c7ed7e Update php_version.h 2021-04-16 17:42:29 +02:00
Dmitry Stogov f1ad9199ef Better support for cross-compilation 2021-04-16 17:28:54 +03:00
twosee 0236bbc777 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80958
2021-04-16 16:19:43 +08:00
twosee ecc4bf14f0 Fixed bug #80958
Missing check after zval_try_get_string().

Closes GH-6871.
2021-04-16 16:17:37 +08:00
K 438189531c Speed up array_column for consecutive objects of the same class 2021-04-16 09:52:57 +02:00
twosee 122deea506 Add ASan and UBSan options (#6825)
When we need to enable ASan/UBSan in PHP extension, we also need to enable it in PHP kernel. Providing these options makes it easier for us to enable ASan/UBSan when compiling PHP.
And we use --enable-address-sanitizer and --enable-undefined-sanitizer in azure-pipelines.yml instead of changing CFLAGS manually.
We also add compile flag check to MSan.
2021-04-16 12:41:25 +08:00
twosee 559c3f6d86 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80929
2021-04-16 09:59:01 +08:00
twosee 09f55604ec Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fixed bug #80929
2021-04-16 09:49:36 +08:00
twosee c0b1bdcdc3 Fixed bug #80929
The function name should be kept if Closure was created from the function which is marked as ZEND_ACC_CALL_VIA_TRAMPOLINE, because it is not a one-time thing and it may be called multiple times.

Closes GH-6867.
2021-04-16 09:48:36 +08:00
Nikita Popov f1ce44d1cb Fix static variables in main script with file cache
If the script will be cached in SHM (!corrupted), then we cannot
allocate the static variables on the arena. Instead do the same
thing we do during normal persistence and allocate a map ptr slot.
2021-04-15 16:37:28 +02:00
Alex Dowad 7159907d30 Fix mbstring support for ISO-2022-JP-MS encoding
- Treat it as error if multi-byte string or escape sequence is truncated
- Don't allow 'control' characters or escape sequences to appear in the middle
  of a multi-byte char

As with ISO-2022-JP-KDDI, the main reference used to develop the tests was
the behavior of the existing code. It would have been better to have some
independent reference which we could cross-check our code against, but I
couldn't find one.
2021-04-15 15:52:31 +02:00
Alex Dowad 570e89a9f3 Fix mbstring support for ISO-2022-JP-KDDI encoding
- Treat it as an error if a multi-byte character or escape sequence is truncated
- When converting other encodings to ISO-2022-JP-KDDI, don't swallow trailing
  hash characters or digits
- Don't allow 'control' characters to appear in the middle of a multi-byte char

Note: I was not able to find any kind of official or even semi-official
specification for this legacy encoding. Therefore, the test suite for
ISO-2022-JP-KDDI is based largely on the behavior of the existing code.

Verifying the correctness of program code in this way is very questionable.
In a sense, all you are proving is that the code "does what it does". However,
the test suite will still expose any unintended _changes_ to behavior.
2021-04-15 15:52:31 +02:00
Alex Dowad f5f3ee7aee Add test suite for mUTF-7 (IMAP) encoding 2021-04-15 15:52:31 +02:00
Alex Dowad 78dc160e3b Catch and handle errors in mUTF-7 (IMAP) conversion 2021-04-15 15:52:31 +02:00
Alex Dowad cef4b94eef Code cleanup in mbfilter_utf7imap.c 2021-04-15 15:52:31 +02:00
Alex Dowad 8abc5e6827 Catch and handle errors in UTF-7 text conversion 2021-04-15 15:52:31 +02:00
Alex Dowad 689978a63b Code cleanup in mbfilter_utf7.c 2021-04-15 15:52:31 +02:00
Alex Dowad ebe6500a0b Fix error reporting bug for Unicode -> CP50220 conversion
To detect errors in conversion from Unicode to another text encoding, each
mbstring conversion filter object maintains a count of 'bad' characters. After
a conversion operation finishes, this count is checked to see if there was any
error.

The problem with CP50220 was that mbstring used a chain of two conversion filter
objects. The 'bad character count' would be incremented on the second object in
the chain, but this didn't do anything, as only the count on the first such
object is ever checked.

Fix this by implementing the conversion using a single conversion filter object,
rather than a chain of two. This is possible because of the recent refactoring,
which pulled out the needed logic for CP50220 conversion into a helper function.
2021-04-15 15:52:31 +02:00
Alex Dowad 1f130d4e58 Refactor mbfl_filt_tl_jisx0201_jisx0208 by moving kana conversion into helper function
This will enable us to simplify the code for CP50220 conversion, which also relies
on this same kana conversion logic.
2021-04-15 15:52:31 +02:00
Alex Dowad 319a340843 Simplify code for working with halfwidth/fullwidth kana conversion filter
There's no need to dynamically allocate a struct to hold the 'mode' parameter;
just store it directly in `filt->opaque`. Some other things were also being done
in an unnecessarily roundabout way.

Also, the 'copy' function for CP50220 conversion filters was *both* broken
and unnecessary. Broken, because it malloc'd memory which was never freed by
anything. Unnecessary, because the point of the copy is so that various
algorithms can try running bytes through a conversion filter and see how many
output bytes or characters result, and then back out by restoring the filters
to their previous state. But here's the thing; CP50220 conversion filters don't
hold cached bytes, which is the main thing which would need to be restored to a
previous state.
2021-04-15 15:52:31 +02:00
Alex Dowad a900ec3397 Remove unneeded 'filter_ctor' member from mbfl_convert_filter struct
This function pointer is only called when initializing the struct. After that
nothing is done with it. Therefore, there is no need to keep it in the struct.
2021-04-15 15:52:31 +02:00
Alex Dowad affc3076f3 Remove unused 'next_filter' member from mbfl_filt_tl_jisx0201_jisx0208_param struct 2021-04-15 15:52:31 +02:00
Alex Dowad 636251a522 Remove useless function mbfl_filt_tl_jisx0201_jisx0208_init
This constructor function doesn't do anything different than the generic one.
There's no need to invoke it, either, when initializing a CP50220 conversion
filter.
2021-04-15 15:52:31 +02:00
Nikita Popov b8942b8313 Fix test for older ICU versions
Apply the change that was done for variant7 to the other variants
as well.
2021-04-15 15:20:17 +02:00
Nikita Popov 41a28cea10 Merge branch 'PHP-8.0'
* PHP-8.0:
  Remove AMD64 jobs from Travis
2021-04-15 15:16:49 +02:00
Nikita Popov d0fd118f9b Remove AMD64 jobs from Travis
We're only interested in the ARM64 and S390X jobs, x86 is already
extensively tested on Azure.
2021-04-15 15:16:18 +02:00
Nikita Popov 8e8dcf5f4c Implement debug_print_backtrace() on top of zend_fetch_backtrace()
As debug_print_backtrace() is not performance-critical, this
implements it by formatting the zend_fetch_backtrace() result.
This means there is only one place implementing the backtrace
construction logic, and they cannot go out of sync.
zend_fetch_backtrace() has much better test coverage, because
it is used by exceptions.

Closes GH-6869.
2021-04-15 15:15:20 +02:00
Dmitry Stogov 0fdf668dce Keep fci->object unchanged 2021-04-15 15:31:45 +03:00
Dmitry Stogov ca49e53670 Stop inserting fake frames on VM stack.
Now similar "fake" frames now materialized when fetching debug
backtraces. The patch also fixes few incorrect backtraces for generators
in *.phpt tests.
2021-04-15 15:30:10 +03:00
Nikita Popov 7af3a392f1 Merge branch 'PHP-8.0'
* PHP-8.0:
  Handle ref return from Iterator::key()
2021-04-15 13:06:04 +02:00
Nikita Popov 46f9fed0d8 Handle ref return from Iterator::key()
Handle this in the implementation of get_current_key of user_it,
so that the callers may assume that the key is not a reference.

Fixes oss-fuzz #33018.
2021-04-15 13:05:48 +02:00
Nikita Popov dfe8dbdc0d Destroy file handle earlier in execute fuzzer
I'm not quite sure why this is relevant, but if matches what other
code does and fixes oss-fuzz #32517.
2021-04-15 12:55:58 +02:00
Nikita Popov 25f23781a8 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix return-by-ref from array_reduce callback
2021-04-15 12:32:41 +02:00
Nikita Popov f40c8fdf67 Fix return-by-ref from array_reduce callback
Fixes oss-fuzz #32990.
2021-04-15 12:32:05 +02:00
Nikita Popov 91b6895e79 Implement zend_print_flat_zval_r() using smart_str
Use the same implementation approach as for the non-flat
zend_print_zval_r() function.
2021-04-15 11:47:16 +02:00
twosee 1215563288 Micro optimizations for http_fopen_wrapper.c (#6864) 2021-04-15 16:34:17 +08:00
Nikita Popov cf7f5cbfac mysqlnd: Free empty param bind
Even if the param bind is empty, there might still be an allocation
for it that we need to free.
2021-04-15 10:14:19 +02:00
Kamil Tekiela 14fd14d780 Silence the deprecation notice on var_dump 2021-04-14 13:47:48 +01:00
Kamil Tekiela 45bad6474e Mysqli bind in execute (#6271) 2021-04-14 12:52:51 +01:00
twosee 44a35c9219 Fix E_DEPRECATED in phar (#6824)
shell_exec() can return null both when an error occurs or the program produces no output, or return false when popen failed, and treating null/false as an empty string has no effect on the behavior of phar here.
2021-04-14 18:21:14 +08:00
Nikita Popov b145256938 Fix type used in driver_reconnect_write
Now that the value is coerced to the correct type, we should be
treating this as a boolean, not an integer (treating it as an
integer was already incorrect before -- if people used the
property as documented they'd likely get garbage).
2021-04-14 09:58:15 +02:00
twosee c457be80dd Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80900
2021-04-14 00:21:37 +08:00
twosee a3e6735999 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fixed bug #80900

# Conflicts:
#	ext/opcache/Optimizer/sccp.c
2021-04-14 00:15:06 +08:00
twosee 7c6cf09463 Fixed bug #80900
SCCP optimization marks the wrong target feasible when the constant is of the incorrect type.

Closes GH-6861.
2021-04-14 00:07:32 +08:00
Christoph M. Becker bebb0b7bbe Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #80933: SplFileObject::DROP_NEW_LINE is broken for NUL and CR
2021-04-13 16:50:15 +02:00
Christoph M. Becker 80f921d7e0 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #80933: SplFileObject::DROP_NEW_LINE is broken for NUL and CR
2021-04-13 16:49:57 +02:00
Christoph M. BeckerandNikita Popov 976e71a2fa Fix #80933: SplFileObject::DROP_NEW_LINE is broken for NUL and CR
`buf` may contain NUL bytes, so we must not use `strcspn()` but rather
a binary safe variant.  However, we also must not detect a stray CR as
line ending, and since we only need to check line endings at the end
of the buffer, we can nicely optimize.

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>

Closes GH-6836.
2021-04-13 16:49:06 +02:00
Nikita Popov 91908bcd52 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix function/file mixup in backtrace printing
2021-04-13 16:34:17 +02:00
Levi Morrison 6fd13d0afd Fix function/file mixup in backtrace printing
The error says "Function name" is not a string, but it's actually
investigating the "file" field, not "function".

Closes GH-6768.
2021-04-13 16:33:30 +02:00
David Gebler cbcfd86026 Add fsync() and fdatasync() functions
fsync is a straightforward wrapper around the same C function
(implemented on Windows API as _commit() with identical signature).

From the man pages:

    fsync() transfers ("flushes") all modified in-core data of (i.e.,
    modified buffer cache pages for) the file referred to by the file
    descriptor fd to the disk device (or other permanent storage
    device) so that all changed information can be retrieved even if
    the system crashes or is rebooted.  This includes writing through
    or flushing a disk cache if present.  The call blocks until the
    device reports that the transfer has completed.

RFC: https://wiki.php.net/rfc/fsync_function

Closes GH-6650.
2021-04-13 16:09:22 +02:00
Nikita Popov 0c5711856f Add zend_ulong_to_str() API
No point in going through a smart_str and append_unsigned if we
can construct the result directly...
2021-04-13 15:56:24 +02:00
Nikita Popov 65a5c184d7 Add functions to convert i64/u64 to string
PDO implement half of this, but this functionality is generally
useful. Provide these as zend_u64_to_str and zend_i64_to_str to
complement zend_long_to_str.
2021-04-13 15:43:23 +02:00
Nikita Popov 0e7b4d09ec Add tests for mysqli property writing
Forgot to git add these in the previous commit.
2021-04-13 15:32:49 +02:00
Nikita Popov d905e77483 Enforce types when writing to mysqli dynamic properties
Previously this just assumed that the value was of a certain type.

I'm doing this in a generic way that checks against the declared
property type -- the handler function can then assume the value
to be of the correct type.
2021-04-13 15:30:56 +02:00
Dmitry Stogov 0fc3818cc5 Initialize fast class cache 2021-04-13 15:54:02 +03:00
Nikita Popov 0c7cdbbaba Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix return type of sparc atomic helper
2021-04-13 14:37:26 +02:00
Nikita Popov ec24f14820 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix return type of sparc atomic helper
2021-04-13 14:37:18 +02:00
David Carlier 5ccb5fd91e Fix return type of sparc atomic helper
Closes GH-6808.
2021-04-13 14:36:58 +02:00
Dmitry Stogov a439d9f232 Call zend_generator_check_placeholder_frame() only for frames with
ZEND_CALL_GENERATOR flag
2021-04-13 15:25:05 +03:00
Derick Rethans 7bd0b1078b Merge branch 'PHP-8.0' 2021-04-13 11:50:28 +01:00
Derick Rethans f20ca94b1c Merge branch 'PHP-7.4' into PHP-8.0 2021-04-13 11:50:20 +01:00
Derick Rethans f99926f554 Put back inadvertedly removed NEWS entries 2021-04-13 11:48:50 +01:00
Gabriel Caruso 79872ac9c2 8.0.6 is the next version 2021-04-13 12:41:21 +02:00
Derick Rethans be533a35c1 Merge branch 'PHP-8.0' 2021-04-13 11:35:09 +01:00
Derick Rethans 3c06794e93 Merge branch 'PHP-7.4' into PHP-8.0 2021-04-13 11:34:55 +01:00
Derick Rethans 8e48895f48 Prepare for 7.4.19 2021-04-13 11:34:40 +01:00
Josh Soref 462da6e09c Fix spelling and grammar mistakes
This PR corrects misspellings identified by the check-spelling action.

The misspellings have been reported at jsoref@b6ba3e2#commitcomment-48946465

The action reports that the changes in this PR would make it happy: jsoref@602417c

Closes GH-6822.
2021-04-13 12:09:37 +02:00
Nikita Popov 02557e62c9 Merge branch 'PHP-8.0'
* PHP-8.0:
  change PHP_EGG_LOGO_DATA_URI to php8 elePHPant called InPHPinity
2021-04-13 11:49:58 +02:00
Noriko Yamamoto 2ebd1c4e86 change PHP_EGG_LOGO_DATA_URI to php8 elePHPant called InPHPinity
Closes GH-6827.
2021-04-13 11:49:42 +02:00
Derick Rethans 8e3f341a59 Merge branch 'PHP-8.0' 2021-04-13 10:01:02 +01:00
Derick Rethans fac39fa36d Merge branch 'PHP-7.4' into PHP-8.0 2021-04-13 10:00:54 +01:00
Derick Rethans d4f7e8cedc Prepare NEWS for 7.4.18RC1 2021-04-13 10:00:45 +01:00
twosee d5456baf52 Use zend_throw_unwind_exit() for assert.bail (#6826)
We can use unwind_exit instead of the evil zend_bailout without breaking the original behavior in this way because the original zend_bailout will longjmp out of the executor, so the exception will never be caught and it always triggers the E_ERROR here.
2021-04-13 15:23:36 +08:00
Kamil Tekiela b7a298b20c Deprecate unused mysqli constants (#6850)
Deprecated:
MYSQLI_SERVER_QUERY_NO_GOOD_INDEX_USED
MYSQLI_SERVER_QUERY_NO_INDEX_USED
MYSQLI_SERVER_QUERY_WAS_SLOW
MYSQLI_SERVER_PS_OUT_PARAMS
MYSQLI_DATA_TRUNCATED
MYSQLI_NO_DATA
2021-04-13 00:11:54 +01:00
K 3a05cda314 SplPriorityQueue performance improvements (#6859)
This optimization is targeting cases when a SplPriorityQueue instance is used
exclusively with double or long priorities.

During the first insertion into an empty queue, the comparator is changed to
the specialized one if the priority of inserted inserted key is long or double.
During insertion to non-empty queue, comparator is swapped back to the generic
one on type conflict.

As a result code like following, where the weight field is always double or
int, runs almost twice as fast.

foreach ($items as $item) {
  $pqueue->insert($item, -$item->weight);
  if ($pqueue->count() > $size) {
    $pqueue->extract();
  }
}
2021-04-12 20:39:34 +02:00
Sammy Kaye PowersandNikita Popov 12c558981a Add some documentation to the embed SAPI (#6856)
* Add some documentation to the embed SAPI

* Apply suggestions from code review

Co-authored-by: Nikita Popov <nikita.ppv@googlemail.com>

* Remove superfluous sapi/ include step

Co-authored-by: Nikita Popov <nikita.ppv@googlemail.com>
2021-04-12 14:34:21 -04:00
Nikita Popov 916071d6cc Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80950
2021-04-12 16:07:08 +02:00
Nikita Popov 1395b874f4 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fixed bug #80950
2021-04-12 16:06:50 +02:00
Nikita Popov a1fdfa700b Fixed bug #80950
Function info for curl_exec() incorrect specified that the
function cannot return true. This is already fixed in PHP 8,
as the func info entry was removed there.
2021-04-12 16:05:37 +02:00
Dmitry Stogov aeebed2a5b Use fast class cache 2021-04-12 14:52:05 +03:00
Nikita Popov 19775afab3 Merge branch 'PHP-8.0'
* PHP-8.0:
  PDO: Respect connection transaction state for dtor rollback
2021-04-12 12:39:50 +02:00
Nikita Popov 8effbd1cb0 PDO: Respect connection transaction state for dtor rollback
As mentioned in bug #80949, if a transaction is implicitly
committed, then PDO may still issue a ROLLBACK when the PDO
object is destroyed, as the transaction is still marked as active
in PDO's (inaccurate) transaction emulation.

Make sure we use the connection transaction state also for that
final ROLLBACK. A caveat here is that the connection might have
been dropped already, which may be the case for some drivers if
construction fails. Make sure we don't crash in that case.
2021-04-12 12:39:44 +02:00
Christoph M. Becker 4196438bb0 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #79812: Potential integer overflow in pcntl_exec()
2021-04-12 12:17:02 +02:00
Christoph M. Becker d74c61c133 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #79812: Potential integer overflow in pcntl_exec()
2021-04-12 12:15:07 +02:00
Christoph M. Becker 0a36d417e8 Fix #79812: Potential integer overflow in pcntl_exec()
We use the proper type, and make sure that no overflow can occur by
using `safe_emalloc()` (we can assume that neither string length is
`SIZE_MAX`).

Closes GH-6845.
2021-04-12 12:12:40 +02:00
Nikita Popov d58cab06c6 Merge branch 'PHP-8.0'
* PHP-8.0:
  Disable ifunc support on openbsd
2021-04-12 11:28:29 +02:00
Nikita Popov 6700198d64 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Disable ifunc support on openbsd
2021-04-12 11:28:24 +02:00
David Carlier a04fac84e7 Disable ifunc support on openbsd
Enabling it leads to segfault when resolvers are used e.g.
php_stripslashes.

Closes GH-6851.
2021-04-12 11:27:50 +02:00
Nikita Popov dae23ab723 Merge branch 'PHP-8.0'
* PHP-8.0:
  Remove the "getdir" function which was introduced accidentally
2021-04-12 11:14:28 +02:00
Rowan Tommins 4e98e65d53 Remove the "getdir" function which was introduced accidentally
The actual name of this function is dir(), but ever since it was
introduced in PHP 3, its internal name was "getdir", leading to it
being mistaken for an alias. This went unnoticed until the switch
to stubs for generating arginfo, at which point getdir() became a
real but undocumented function.

Fixes bug #80914.

Closes GH-6855.
2021-04-12 11:13:57 +02:00
Nikita Popov 6bd46d2f68 Don't use range information from a prototype method
The method may be overridden.
2021-04-12 10:30:04 +02:00
Dmitry Stogov 70bb12feec Merge branch 'PHP-8.0'
* PHP-8.0:
  Update zend_alloc.c
2021-04-12 09:28:57 +03:00
Dmitry Stogov 9c6b926dae Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Update zend_alloc.c
2021-04-12 09:28:41 +03:00
fishmore 600402d986 Update zend_alloc.c
Don't free main thunk.  It will crash.
2021-04-12 09:28:24 +03:00
Matteo Beccati d0229374ce Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #80892: PDO::PARAM_INT is treated the same as PDO::PARAM_STR
2021-04-12 08:06:38 +02:00
Matteo Beccati 4f236635e7 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #80892: PDO::PARAM_INT is treated the same as PDO::PARAM_STR
2021-04-12 08:05:41 +02:00
Matteo Beccati 340a06778c Fix #80892: PDO::PARAM_INT is treated the same as PDO::PARAM_STR 2021-04-12 08:03:07 +02:00
Matteo Beccati be1fbdbb78 Merge branch 'PHP-8.0'
* PHP-8.0:
  Increased test compatibility
2021-04-11 17:32:22 +02:00
Matteo Beccati 7f4784c1c9 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Increased test compatibility
2021-04-11 17:32:13 +02:00
Matteo Beccati da3a807f22 Increased test compatibility
The test expects no masked signals at the beginning, but when run as part
of a Bamboo build, SIGQUIT is already masked and the test fails.
2021-04-11 17:19:58 +02:00
K dc47b99391 SplHeap: replace zend_parse_parameters with ZEND_PARSE_PARAMETERS* macros
this change alone speeds up top-k computation significantly
2021-04-11 16:09:25 +02:00
Nikita Popov 765cb40bf5 Go back to not reporting startup leaks
Unfortunately CG(unclean_shutdown) may not be initialized at this
point in ZTS builds.
2021-04-11 11:01:04 +02:00
Nikita Popov 2973a71a91 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix gidlist allocation leak on error
2021-04-11 10:38:16 +02:00
Nikita Popov 26d417d758 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix gidlist allocation leak on error
2021-04-11 10:38:07 +02:00
Nikita Popov 454d297564 Fix gidlist allocation leak on error 2021-04-11 10:37:40 +02:00
Kamil Tekiela 381ab44ccc Remove unused properties in mysqlnd (#6849)
* can_ret_as_str_in_uni and is_possibly_blob is no longer used anywhere
* Removed mysqlnd_stmt_fetch_row_buffered header
* Removed unicode constants leftovers
2021-04-10 23:36:53 +01:00
Nikita Popov bd3ba5465b Revert "Don't allocate temporary file cache memory on arena"
This reverts commit 4440ac3ed6.

This fix wasn't correct, as we do retain the arena-allocation
for the file cache only case. This will need some other way to
reconcile both modes.
2021-04-10 12:46:22 +02:00
Anatol Belski 6ab4286f2e fileinfo: Fix version in patch update script
Signed-off-by: Anatol Belski <ab@php.net>
2021-04-09 23:18:21 +02:00
Nikita Popov cbf3240d91 Don't report leak on unclean_shutdown during startup
In particular if an invalid ini option is specified.
2021-04-09 21:16:02 +02:00
George Peter Banyard dc402cb0fc Fix SNMP
This one had objid_query->array_output = ( (st & SNMP_CMD_SET) ? false : true ); initially
which means that if it was equal to 0 it would be equal to true.
2021-04-09 18:53:31 +01:00
George Peter Banyard d842bc7e22 Refactor dom_has_feature() to use zend_string* 2021-04-09 18:45:08 +01:00
George Peter Banyard 633319586a Refactor SNMP extension a bit
Use RETURN_* macros instead of RETVAL_* + return;
Use proper boolean types
Use zend_string instead of char* to prevent unnecessary strlen calculation

Closes GH-6846
2021-04-09 17:12:54 +01:00
Nikita Popov a1e914513e Test interned_strings_buffer=0 in CI
This is tested on the previous file_cache job as part of nightly
builds.
2021-04-09 17:11:56 +02:00
Nikita Popov 4440ac3ed6 Don't allocate temporary file cache memory on arena
During unserialization, static_variables and runtime_cache may be
allocated on the arena, and then later freed when the checkpoint
is released.

As we're only doing a single large allocation here, simply move
this to the normal allocator, so there is no interference with
other arena allocations.
2021-04-09 17:11:50 +02:00
Nikita Popov e0e19fd955 Fix file cache
We should only access xlat if this is called from persist, not
when it is called from file cache.
2021-04-09 16:52:18 +02:00
Dmitry Stogov 4dcde9cf18 Don't evalutae ZEND_AST_CLASS_CONST to ZEND_AST_CONSTANT ar
compile-time. Keep at to run-time and use Fast Class Cache during
run-time evaluation.
2021-04-09 17:48:28 +03:00
Nikita Popov 718dd06744 Don't suppress startup leaks 2021-04-09 16:32:58 +02:00
Nikita Popov f0d783b7bf Free expanded filename in php_init_config()
This leak ends up getting suppressed, but is rather annoying when
not using ZEND_TRACKED_ALLOC.
2021-04-09 16:29:03 +02:00
Nikita Popov 3585f5aafc Explicitly set interned_strings_buffer in logging tests
These tests cannot be run with interned_strings_buffer=0.
2021-04-09 15:41:00 +02:00
Nikita Popov 4ce5d2ea88 Add known strings for jit autoglobals
We always create interned strings for all autoglobals anyway, so
we might as well add known strings to make them more widely usable.
2021-04-09 15:37:59 +02:00
Nikita Popov ce4afd50a9 Remove special handling of method named during preloading
Nowadays op_arrays always hold a ref to the function_name, even
if they are fully shared. As such, I don't believe that this code
is necessary anymore, and it interferes with the code that
releases function_names the appropriate number of times while
persisting.
2021-04-09 15:08:46 +02:00
Nikita Popov b196d4ae3e Accept zend_string instead of zval in compile_filename 2021-04-09 14:33:34 +02:00
Nikita Popov 46ee57e910 Don't leak accel key if interning fails 2021-04-09 14:24:07 +02:00
Dmitry Stogov 12ed58eca0 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed type inference for OP_DATA
2021-04-09 14:53:44 +03:00
Dmitry Stogov 61e385a358 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fixed type inference for OP_DATA
2021-04-09 14:53:34 +03:00
Dmitry Stogov 7a8ffcec7d Fixed type inference for OP_DATA 2021-04-09 14:52:55 +03:00
Nikita Popov 46a884bb67 Don't leak include_path if it cannot be interned 2021-04-09 13:05:27 +02:00
Nikita Popov 24969b7cd0 Fix incorrect --CREDITS-- section 2021-04-09 12:40:04 +02:00
Nikita Popov fe9f4298b5 Fix class map ptr for parent type if interning disabled
As zend_update_parent_ce() only runs later, the parent reference
may still point to the original class entry rather than the
persisted one. Memory held by the original class entry may have
already been deallocated. Avoid use-after-free by explicitly
fetching the persisted parent CE.
2021-04-09 12:24:12 +02:00
Dmitry Stogov 000564a599 Use Fast Class Cache 2021-04-09 12:48:54 +03:00
Dmitry Stogov f681c4a775 Use Fast Class Cache to speedup object unserialization 2021-04-09 11:36:13 +03:00
George Peter Banyard 09efad615b Use zend_string_equals_(literal_)ci() API more often
Also drive-by usage of zend_ini_parse_bool()

Closes GH-6844
2021-04-09 02:34:50 +01:00
Dmitry Stogov f191e4f257 Avoid destructor call for LONG keys 2021-04-09 00:49:27 +03:00
Dmitry Stogov 556d752667 Prevent call of var_push_dtor_value() on hot path.
When serialising object properties, they are oftet may override the
default values, however default values are most often scalars, interned
strings or immutable arrays.
2021-04-09 00:40:17 +03:00
Dmitry Stogov d8e4fbae62 Fast Class Cache
This is generalization of idea, that was previously usesd for caching
resolution of class_entries in zend_type. Now very similar mechanizm is
used for general zend_string into zend_class_entry resolution.

Interned zend_string with IS_STR_CLASS_NAME_MAP_PTR GC_FLAG uses its
refcount to adress corresponding zend_class_entry cache slot.
The refcount keeps an offset to this slot from CG(map_ptr_base).
Flag may be checked by ZSTR_HAS_CE_CACHE(str), cache slot may be read by
ZSTR_GET_CE_CACHE(str) and set by ZSTR_SET_CE_CACHE(str, ce).
2021-04-08 23:37:40 +03:00
Nikita Popov ad4b928750 Drop unused fgetss_state member 2021-04-08 22:27:00 +02:00
Nikita Popov 47a722e77f Merge branch 'PHP-8.0'
* PHP-8.0:
  Don't mark non-refcounted phi as live
2021-04-08 18:24:57 +02:00
Nikita Popov 332a367538 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Don't mark non-refcounted phi as live
2021-04-08 18:21:00 +02:00
Nikita Popov 29fa4d203a Don't mark non-refcounted phi as live
If the value is not refcounted, then it doesn't matter if the
FREE gets dropped.
2021-04-08 18:20:09 +02:00
Nikita Popov dbe2cdd7dc Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix DCE of FREE of COALESCE

Note that this is a non-trivial merge, as opt/coalesce.phpt
regresses with this change. I'll have to see if it can be
improved.
2021-04-08 17:06:40 +02:00
Nikita Popov 59b2a899ca Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix DCE of FREE of COALESCE
2021-04-08 17:01:19 +02:00
Nikita Popov 0826a54836 Fix DCE of FREE of COALESCE
When encountering the following SSA graph:

    BB1:
    #2.T1 [string] = COALESCE #1.CV0($str) [null, string] BB2

    BB2:
    #5.T1 [string] = QM_ASSIGN string("")

    BB3:
    #7.X1 [string] = Phi(#2.X1 [string], #5.X1 [string])
    FREE #7.T1 [string]

We would currently determine that #7, #5 are dead, and eliminate
the FREE and QM_ASSIGN. However, we cannot eliminate #2, as
COALESCE is also responsible for control flow.

Fix this my marking all non-CV phis as live to start with. This
can be relaxed to check the kind of the source instruction, but
I couldn't immediately come up with a case where it would be
useful.
2021-04-08 17:01:13 +02:00
Remi Collet 513ad9791d Merge branch 'PHP-8.0'
* PHP-8.0:
  Improve fix for #80783
2021-04-08 15:28:48 +02:00
Remi Collet f421ebc056 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Improve fix for #80783
2021-04-08 15:28:29 +02:00
Remi Collet 25f5a1b2e1 Improve fix for #80783 2021-04-08 15:28:03 +02:00
Nikita Popov 7f4513f1cb Merge branch 'PHP-8.0'
* PHP-8.0:
  Support more than NGROUPS_MAX groups on macos
2021-04-08 12:25:26 +02:00
Nikita Popov 032905b5a0 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Support more than NGROUPS_MAX groups on macos
2021-04-08 12:25:16 +02:00
Nikita Popov eebcfeb68e Support more than NGROUPS_MAX groups on macos
I suspect this is the cause for our recent CI failures. Apparently,
on macos it is possible for getgroups() to return more than
NGROUPS_MAX groups. We avoid an EINVAL in that case by fetching
the exact number of groups in advance. This should work on both
macos and posix systems.
2021-04-08 12:23:39 +02:00
Nikita Popov 3e2e2f12cb Display error message when posix_getgroups() test fails
This test started having many intermittent failures on MacOS
recently.
2021-04-08 10:45:43 +02:00
Max Semenik 7f2f0c007c Migrate skip checks to --EXTENSIONS--, p4
For rationale, see #6787

Extensions migrated in part 4:
* simplexml
* skeleton
* soap
* spl
* sqlite3
* sysvmsg
* sysvsem
* tidy - also removed a check for an ancient dependency version
2021-04-08 10:36:44 +02:00
Dmitry Stogov 4034d83432 unserialize() optimization 2021-04-07 18:36:14 +03:00
Dmitry Stogov b3e59dc16f unserialize() optimization 2021-04-07 15:24:53 +03:00
Christoph M. Becker 0496d225a2 Merge branch 'PHP-8.0'
* PHP-8.0:
  Update version in main/php_version.h as well
2021-04-07 12:54:26 +02:00
Christoph M. Becker ba6714a200 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Update version in main/php_version.h as well
2021-04-07 12:52:44 +02:00
Christoph M. Becker 0a181ca27a Update version in main/php_version.h as well
Otherwise the file is modified by each new build, what is confusing.
2021-04-07 12:45:21 +02:00
George Peter Banyard 5caaf40b43 Introduce pseudo-keyword ZEND_FALLTHROUGH
And use it instead of comments
2021-04-07 00:46:29 +01:00
George Peter Banyard 8a86fe11da Add missing break; in Zlib extension 2021-04-07 00:46:17 +01:00
Derick Rethans 4e3d469c4a Skip test on 32bit, as the timestamp range is outside 32bit range 2021-04-06 23:54:51 +01:00
Anatol Belski 7251f3900e fileinfo: Update the patch
Signed-off-by: Anatol Belski <ab@php.net>
2021-04-06 22:43:05 +02:00
Derick Rethans a6702348cd Merge branch 'timelib-and-date-time-fixes' 2021-04-06 20:50:58 +01:00
Derick Rethans 091c0920b9 Upgrade timelib to 2021.03 and fix many date/time issues 2021-04-06 20:50:32 +01:00
Dmitry Stogov ffb1dd0839 Use zend_hash_append*() in zend_fetch_debug_backtrace() 2021-04-06 18:25:50 +03:00
Dmitry Stogov a13a1be734 Use ZEND_HASH_FILL_* API for explode() 2021-04-06 16:57:02 +03:00
Dmitry Stogov e86bea8d45 Extend ZEND_HASH_FILL_* API with ZEND_HASH_FILL_GROW and use it to optimize get_declared_classes() 2021-04-06 16:18:47 +03:00
Nikita Popov e10a7107a5 Make tokenizer_data_gen.php compatible with older PHP
Our PHP requirement is currently PHP 7.1, so don't use flexible
heredoc.
2021-04-06 15:13:21 +02:00
Christoph M. Becker 67e545f1bb Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #80880: SSL_read on shutdown, ftp/proc_open
2021-04-06 14:08:54 +02:00
Christoph M. Becker de9734a5bb Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #80880: SSL_read on shutdown, ftp/proc_open
2021-04-06 14:07:25 +02:00
Christoph M. Becker 9688071679 Fix #80880: SSL_read on shutdown, ftp/proc_open
When `SSL_read()` after `SSL_shutdown()` fails with `SSL_ERROR_SYSCALL`,
we should not warn about this, because it is likely caused by the peer
having closed the connection without having sent a close_notify
shutdown alert.

Signed-off-by: Christoph M. Becker <cmbecker69@gmx.de>

Closes GH-6803.
2021-04-06 14:03:19 +02:00
Anatol Belski ecfb888354 fileinfo: Turn back the WS check mitigation
Looks like there's still a timing issue shown on some pipeline runs.

Signed-off-by: Anatol Belski <ab@php.net>
2021-04-06 12:29:04 +02:00
Nikita Popov 57eb29f1d3 Update zend_vm_gen.php with zend_vm_opcode.c/h changes
The generated files were modified directly, resulting in mysterious
build failures depending on exact build order.
2021-04-06 11:35:05 +02:00
Nikita Popov 7a306c0813 Fix skipif section in test
This was migrated to --EXTENSIONS--.
2021-04-06 09:58:49 +02:00
twosee fc64a7bef4 Ignore some opcodes in JIT check
Some user opcode handler actually gets called when JIT is used, so do not disable JIT even if these user opcode handlers were registered, just ignore them.

ZEND_EXIT can help Swoole to detect exit/die operation and exit from the current coroutine and record exit_status correctly.
ZEND_*_SILENCE can help Swoole to switch EG(error_reporting) to keep the right behavior when using the error control operator.
So we ignore ZEND_EXIT, ZEND_BEGIN_SILENCE, ZEND_END_SILENCE in JIT check here.

Closes GH-6640.
2021-04-06 11:58:20 +08:00
twosee cb8f39f247 Add zend_get_opcode_id() to get opcode id from name 2021-04-06 11:44:10 +08:00
Anatol Belski 4af6679d78 fileinfo: Update libmagic.patch
Signed-off-by: Anatol Belski <ab@php.net>
2021-04-05 22:41:00 +02:00
Anatol Belski f60dc3bd34 fileinfo: More VS compat
Signed-off-by: Anatol Belski <ab@php.net>
2021-04-05 21:23:26 +02:00
Nikita Popov 61f4525c2b Merge branch 'PHP-8.0'
* PHP-8.0:
  .gdbinit: make zbacktrace show the correct stack when switching threads
2021-04-05 21:12:11 +02:00
Nikita Popov 304190c49d Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  .gdbinit: make zbacktrace show the correct stack when switching threads
2021-04-05 21:11:19 +02:00
Dylan K. Taylor 50f476591f .gdbinit: make zbacktrace show the correct stack when switching threads
I found this mainly to be a problem when working with threading
extensions. zbacktrace doesn't show the correct stack when switching
threads.

Closes GH-6814.
2021-04-05 21:10:52 +02:00
Anatol Belski cd238bd09d fileinfo: Fix VS compat
Signed-off-by: Anatol Belski <ab@php.net>
2021-04-05 21:10:20 +02:00
Anatol Belski f7ab54cbe7 fileinfo: Restore config.h for libmagic
Signed-off-by: Anatol Belski <ab@php.net>
2021-04-05 20:56:41 +02:00
Anatol Belski 3b9173dc8f fileinfo: Port libmagic 5.40
Signed-off-by: Anatol Belski <ab@php.net>
2021-04-05 20:19:07 +02:00
Dmitry Stogov 22019a1edd Fixed unintended string duplication 2021-04-05 17:55:42 +03:00
Dmitry Stogov 9e12dbbaf2 micro-optimization 2021-04-05 16:11:24 +03:00
Dmitry Stogov 368766ec28 Set expectations 2021-04-05 15:21:13 +03:00
George Peter Banyard 705e93a22f Fix necessary extensions list for OPcache test 2021-04-05 06:34:13 +01:00
Max Semenik e9f783fcdd Migrate skip checks to --EXTENSIONS--, p3
For rationale, see #6787

Extensions migrated in part 3:
* ftp
* gmp
* iconv
* opcache
* shmop
2021-04-03 15:23:25 +02:00
Dmitry Stogov 33f938bad0 Fixed macros 2021-04-02 19:22:30 +03:00
Dmitry Stogov 46865392fe Attempt to fix ext/spl/tests/bug67359.phpt broken by f323baa845 2021-04-02 19:09:29 +03:00
Joe Watkins 92665cdcbb update release process doc (#6829) 2021-04-02 17:13:00 +02:00
Dmitry Stogov 93430e2b14 clear only neccessary part of spl_filesystem_object 2021-04-02 17:51:18 +03:00
Dmitry Stogov 758ca0198e We don't have to clear zend_object structure, it's initialized by zend_object_std_init() anyway. 2021-04-02 16:11:34 +03:00
Dmitry Stogov f323baa845 Reduce number of stat() calls 2021-04-02 13:39:12 +03:00
Dmitry Stogov c2fc25fdf2 Avoid reading of property name in ASSIGN_OBJ if it can be accessed through run-time cache slot. 2021-04-01 17:55:49 +03:00
Dmitry Stogov 1b94b5b61c Avoid reading of property name in FETCH_OBJ_R/IS if it can be accessed through run-time cache slot. 2021-04-01 16:18:05 +03:00
Max Semenik bd9f4fa676 Migrate skip checks to --EXTENSIONS--, p2
For rationale, see https://github.com/php/php-src/pull/6787

Make extension checks lowercase, add a special case for opcache
that has internal name not matching .so filename.

Extensions migrated in part 2:
* dom
* exif
* fileinfo
* ffi
2021-04-01 12:08:24 +01:00
Mike Pall 83b01a920e DynASM: Fix global label references
ARM64 patch contributed by Hao Sun and Nick Gasson.
2021-03-31 23:55:36 +03:00
Mike Pall 0b4f83f68f DynASM/ARM64: Add VREG support.
Contributed by Hao Sun and Nick Gasson.
2021-03-31 23:54:22 +03:00
Dmitry Stogov b428c51aea Merge upstream DynAsm changes from LuaJIT 2021-03-31 23:51:19 +03:00
Dmitry Stogov 24388fd573 Merge branch 'PHP-8.0'
* PHP-8.0:
  Changed PowerPC CPU registers used by Zend VM to work around GCC bug.
2021-03-31 13:12:00 +03:00
Dmitry Stogov e0996decc3 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Changed PowerPC CPU registers used by Zend VM to work around GCC bug.
2021-03-31 13:11:11 +03:00
Dmitry Stogov 39d8fc1edc Changed PowerPC CPU registers used by Zend VM to work around GCC bug.
Old registers (r28/r29) might be clobbered by _restgpr routine used for return from C function compiled with -Os.
2021-03-31 13:10:21 +03:00
Dmitry Stogov a6dd92f820 Remove reference to $GLOBALS. We don't create an actual variable for $GLOBALS any more . 2021-03-31 12:28:23 +03:00
Dmitry Stogov 84a843dff6 Use better function 2021-03-30 20:20:54 +03:00
Dmitry Stogov 8c001d5ba3 We don't create an actual variable for $GLOBALS any more. 2021-03-30 15:12:10 +03:00
Christoph M. Becker 90da9bf53b Merge branch 'PHP-8.0'
* PHP-8.0:
  Handle reference zvals when outputting superglobals in phpinfo()

Signed-off-by: Christoph M. Becker <cmbecker69@gmx.de>
2021-03-30 13:55:36 +02:00
Christoph M. Becker 443478109b Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Handle reference zvals when outputting superglobals in phpinfo()

Signed-off-by: Christoph M. Becker <cmbecker69@gmx.de>
2021-03-30 13:52:38 +02:00
Rowan Tommins 206fd35a98 Handle reference zvals when outputting superglobals in phpinfo()
Fixes <https://bugs.php.net/80915>.

Closes GH-80915.

Signed-off-by: Christoph M. Becker <cmbecker69@gmx.de>
2021-03-30 13:49:22 +02:00
Dmitry Stogov 849ae12e7a Simplify auto-globals checks 2021-03-30 13:56:29 +03:00
Nikita Popov fba8b955e9 Fix incorrect prop_name release
After 2c4346f9de the property
name should no longer be released.

This should fix the preloading failure under asan.
2021-03-30 12:53:09 +02:00
Nikita Popov 202a701a4e Merge branch 'PHP-8.0'
* PHP-8.0:
  Remove zero size special case for copy_to_stream
2021-03-29 15:22:50 +02:00
Nikita Popov b95b553489 Remove zero size special case for copy_to_stream
This doesn't seem to serve a purpose anymore. Stats are expensive,
so doing an unnecessary stat just to short-circuit the zero size
case is rather dubious. It can also break with stream wrappers
that return inaccurate sizes (symfony/symfony#40574) and probably
can also break with stream filters.

Drop the special case and adjust code to make it more obvious that
it will still be handled correctly.

Closes GH-6807.
2021-03-29 15:21:59 +02:00
George Peter Banyard 8560d168d3 Align types with the output of zend_hash_num_elements() 2021-03-29 14:20:22 +01:00
George Peter Banyard caaf2e9981 [skip-ci] Update UPGRADING documents for the new argument for fputcsv() 2021-03-29 13:55:18 +01:00
Cameron Hall 5b29eba7ca Fix #42357: fputcsv() has an optional parameter for line endings
fputcsv does not terminate lines correctly as per RFC 41801[1]. After adding a new parameter fputcsv may now use a user defined line ending,. In order to maintain backwards compatibility fputcsv() still terminates lines with "\n" by default.

Also fixes: #46367[2], #62770[3]
Ref: #42357[4]

[1] <https://tools.ietf.org/html/rfc4180>
[2] <https://bugs.php.net/bug.php?id=46367>
[3] <https://bugs.php.net/bug.php?id=62770>
[4] <https://bugs.php.net/bug.php?id=42357>
2021-03-29 13:34:38 +01:00
Christoph M. Becker 8f1ec5be60 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #69668: SOAP special XML characters in namespace URIs not encoded

Signed-off-by: Christoph M. Becker <cmbecker69@gmx.de>
2021-03-29 14:20:13 +02:00
Christoph M. Becker dd227f61df Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #69668: SOAP special XML characters in namespace URIs not encoded

Signed-off-by: Christoph M. Becker <cmbecker69@gmx.de>
2021-03-29 14:19:39 +02:00
Christoph M. Becker 75cb678206 Fix #69668: SOAP special XML characters in namespace URIs not encoded
`xmlNewNs()` does not XML encode the passed `href`, so we need to do
that manually.

Closes GH-6804.

Signed-off-by: Christoph M. Becker <cmbecker69@gmx.de>
2021-03-29 14:17:55 +02:00
Bartosz Gorski 49a20cf3db Removed mentions of git.php.net from the documentation 2021-03-29 14:05:20 +02:00
Kennedy Tedesco 63983e02fe Use ZVAL_TRUE() directly
Just a minor change.
2021-03-29 10:28:23 +02:00
Nuno Maduro e44f610443 Removes 'Parallel Edition' output in tests
Closes GH-6806.
2021-03-29 00:49:40 +02:00
Jakub Zelenka 4ed4b64df8 Update NEWS and UPGRADING for FPM addition of pm.max_spawn_rate 2021-03-28 21:15:35 +01:00
Jakub Zelenka 4361fffaea Add extra run test for pm.max_spawn_rate 2021-03-28 21:06:45 +01:00
Paulius Sapragonas eac1609a84 Max spawn child processes rate an once
* Add functionality to expect log config options
2021-03-28 20:53:58 +01:00
Kamil Tekiela 830d385351 Fix typos in fetch_all error message 2021-03-28 20:36:17 +01:00
Levi Morrison 8d743d5281 Revert "Revert "Revert "[skip-ci] Fix typo"""
This reverts commit 2b0f239b21.
2021-03-28 11:53:30 -06:00
Nikita Popov 2b0f239b21 Revert "Revert "[skip-ci] Fix typo""
This reverts commit 046827a7e8.
2021-03-28 18:15:57 +02:00
Nikita Popov 046827a7e8 Revert "[skip-ci] Fix typo"
This reverts commit c730aa26bd.

This looks like the result of a compromised git account. Commit
access has already been revoked.
2021-03-28 11:16:39 +02:00
Rasmus Lerdorf c730aa26bd [skip-ci] Fix typo
Fixes minor typo.

Signed-off-by: Rasmus Lerdorf <rasmus@lerdorf.com>
2021-03-28 05:57:07 +02:00
Tyson Andre 92aeda524b Fix json_encode regression with JSON_PRETTY_PRINT
This makes the json encoding behavior the same as it was prior to the memory
optimizations added in f9f8c1c79c
(for objects with declared properties)

This is based on the code for the unoptimized case below the changes.

Buggy output prior to this commit:
```
{
"prop":"value"}
```

Correct output:

```
{
    "prop": "value"
}
```

Closes GH-6811
2021-03-27 18:47:54 -04:00
Anatol Belski e0e3d9851a hash: Fix -Warray-parameter= warnings
Signed-off-by: Anatol Belski <ab@php.net>
2021-03-26 23:29:01 +01:00
Nikita Popov 2c4346f9de Remove unnecessary property unmangling in trait binding
The unmangled name is already available as the hashtable key,
use it directly.
2021-03-26 12:14:32 +01:00
Nikita Popov 5da23eb46c Free static variables in execute fuzzer
Fixes a leak in the seed corpus.
2021-03-26 11:59:14 +01:00
Dmitry Stogov 7b2b9b4079 Improved JIT for TYPE_CHECK opcode 2021-03-25 23:48:08 +03:00
Máté Kocsis aa45eedef0 Merge branch 'PHP-8.0' 2021-03-25 19:32:21 +01:00
Máté Kocsis d7ae64627f Fix PDOStatement::bindColumn() parameter default value 2021-03-25 19:31:04 +01:00
Dmitry Stogov 22fc522483 Improve JIT for IS_IDENTICAL 2021-03-25 17:27:03 +03:00
Dmitry Stogov 2f3538c215 Improved type inference for FE_FETCH_R 2021-03-25 16:00:36 +03:00
George Peter Banyard 56c18c4038 Drop unneessary if branch and adjust arg_num type
This if branch seems to be a remain of when certain type errors where E_WARNINGs, something which isn't the case since PHP 8.0.
2021-03-25 02:12:06 +00:00
Christoph M. Becker 6c89359124 Merge branch 'PHP-8.0'
* PHP-8.0:
  XFAIL on WIN64 because of problem in libffi
2021-03-24 13:58:14 +01:00
Dmitry Stogov 6800f0a3c2 XFAIL on WIN64 because of problem in libffi
(cherry picked from commit 6689bedd17)
2021-03-24 13:57:31 +01:00
Christoph M. Becker 6adec555db Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #73533: Invalid memory access in php_libxml_xmlCheckUTF8
2021-03-24 11:53:53 +01:00
Christoph M. Becker 5832be768c Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #73533: Invalid memory access in php_libxml_xmlCheckUTF8
2021-03-24 11:52:54 +01:00
Christoph M. Becker 498eb8e052 Fix #73533: Invalid memory access in php_libxml_xmlCheckUTF8
A string passed to `php_libxml_xmlCheckUTF8()` may be longer than
1<<31-1 bytes, so we're better using a `size_t`.

Closes GH-6802.
2021-03-24 11:50:50 +01:00
Nikita Popov 74075896e1 Revert "Do not check exact values of unstable metrices in FPM status test"
This reverts commit 5b01c4863f.

The previous commit fixes the 32-bit issue. Maybe this one is also
needed, but let's see if any failures of this form turn up first.
2021-03-24 10:07:56 +01:00
Nikita Popov 9403840ae3 Fix printf type in fpm status 2021-03-24 10:07:53 +01:00
Dmitry Stogov 3e996622c7 Replace function with macro 2021-03-24 10:36:47 +03:00
Jakub Zelenka 5b01c4863f Do not check exact values of unstable metrices in FPM status test 2021-03-23 22:10:30 +00:00
Dmitry Stogov 7adaec1ce8 Move system independent code out from x86 specific header 2021-03-23 17:12:15 +03:00
Dmitry Stogov c290de157c Move x86 dependent code out from platform independed parts. 2021-03-23 16:39:51 +03:00
Christoph M. Becker f4412f56a2 Merge branch 'PHP-8.0'
* PHP-8.0:
  Properly initialize PS(mod) on RINIT
2021-03-23 13:14:49 +01:00
Christoph M. Becker 733b514326 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Properly initialize PS(mod) on RINIT
2021-03-23 13:13:43 +01:00
Christoph M. Becker 688e56d0ac Properly initialize PS(mod) on RINIT
We need to do that in case a user handler has been set.  However, we
can't do that in `php_rinit_session_globals()` since that function is
called by PHP function `session_destroy()` too, but in that case we
don't want to reset PS(mod).

Closes GH-6795.
2021-03-23 13:12:19 +01:00
Dmitry Stogov 617276d807 Use capstone disassembler, if available. 2021-03-23 12:39:42 +03:00
Christoph M. Becker fd62917730 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #80889: amendment
2021-03-22 22:51:12 +01:00
Christoph M. Becker 90be86fc91 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #80889: amendment
2021-03-22 22:49:46 +01:00
Jakub Zelenka 72a22d92cd Fix types in FPM status openmetrics format 2021-03-22 21:32:15 +00:00
Christoph M. Becker 838951c2d6 Fix #80889: amendment
`session_set_save_handler()` may be called with callables instead of an
object; we need to cater to that as well.

We also extract a set_user_save_handler_ini() function to avoid code
duplication.

Closes GH-6796.
2021-03-22 22:17:35 +01:00
Nikita Popov f42f539324 Revert "Use better function"
This reverts commit 9162116a85.

This causes many "__HALT_COMPILER(); must be declared in a phar"
errors in phar tests on windows.
2021-03-22 17:53:37 +01:00
Max Semenik 56f90492d6 Migrate skip checks to --EXTENSIONS--, p1
For rationale, see https://github.com/php/php-src/pull/6787

Extensions migrated in this part:
* bcmath
* bz2
* calendar
* com_dotnet
* ctype

Closes GH-6797.
2021-03-22 17:51:02 +01:00
Dmitry Stogov 550a662f67 strtr() optimization 2021-03-22 17:37:11 +03:00
Nikita Popov 79a9f809ee Fix const warning 2021-03-22 15:19:06 +01:00
Nikita Popov 6a5d60085d Support VERIFY_RETURN_TYPE elision with unused operand
This handles the degenerate case where SCCP replaced the value in
the RETURN opcode with a constant, but the VERIFY_RETURN is still
there. We can still apply the same optimization, just don't need
to adjust the use list in this case.

The result is still sub-optimal in that a dead QM_ASSIGN is left
behind.
2021-03-22 14:54:29 +01:00
Dmitry Stogov 8ed8cf86a9 Use zend_string* instead of char* 2021-03-22 14:56:16 +03:00
Dmitry Stogov 9162116a85 Use better function 2021-03-22 14:55:54 +03:00
Nikita Popov 48986653fe Remove unused READDIR_R lock 2021-03-22 10:48:59 +01:00
Max Semenik 6c9a05667b run-tests: use the EXTENSIONS section for skipping
Currently, most skip checks are just for making sure an extension is
available. Even with recent addition of skip caching, this makes tests
needlessly slow:
* Checks for the same extension in its tests can have small differences
  impacting cacheability.
* Even identical skip checks in two tests can still be executed twice if
  they're run by different workers.

To remedy this, I'm repurposing the existing --EXTENSIONS-- section of
.phpt files to specify wjich extensions are required for current test to
run. Current behavior:
1) If the extension is already visible to PHP, all is good
2) If it isn't, assume it's present as a shared module and attempt to add
   it via a command line parameter
3) If that works, all is good
4) If it doesn't, PHP fails with a cryptic error message trying to
   execute the test itself

After this commit:
1) and 2) are kept unchanged
3) Check if shared extension file from 2) is actually present
4) Skip the test if it isn't

Other benefits include clear skip reasons (vs. sometimes none in many
current skip checks) and moving test information from code to metadata,
opening more opportunities for search and analysis.

Since --EXTENSIONS-- is barely ever used, this change poses no risk of
hidden failures.

As a demonstration of the new approach, this commit migrates one
extension to it. If merged, I will migrate other extensions in
subsequent PRs.

Closes GH-6787.
2021-03-22 09:53:38 +01:00
Jakub Zelenka a3e1082e0a Merge branch 'PHP-8.0' 2021-03-21 21:21:38 +00:00
Jakub Zelenka 4dca1140cf Merge branch 'PHP-7.4' into PHP-8.0 2021-03-21 21:21:05 +00:00
Jakub Zelenka bc7ea73da5 Use ServerClientTestCase in a test for default_socket_timeout=-1 2021-03-21 21:19:40 +00:00
Jakub Zelenka 118cd3efd3 Merge branch 'PHP-8.0' 2021-03-21 19:01:50 +00:00
Jakub Zelenka 713b82131b Merge branch 'PHP-7.4' into PHP-8.0 2021-03-21 19:00:38 +00:00
Jakub Zelenka 538f95b1b7 Fix NEWS entry position for the latest FPM fix 2021-03-21 18:58:57 +00:00
Jakub Zelenka c483b59124 Fix bug #80024: Duplication of info about inherited socket after pool removing 2021-03-21 18:52:07 +00:00
Jakub Zelenka 37969dcab0 Update NEWS for FPM process renaming on macOS 2021-03-21 18:42:55 +00:00
David CARLIER d54fa6f778 fpm master/child process rename, enable on mac os.
Note the change appears mainly in command like ps.
2021-03-21 18:36:12 +00:00
Jakub Zelenka 661731d4f1 Upadate NEWS and UPRADING with info about FPM openmetrics format addition 2021-03-21 18:32:19 +00:00
Jakub Zelenka c6c571d92b Fix indent in FPM openmetrics status 2021-03-21 18:24:46 +00:00
Cees-Jan Kiewiet d36ac9640a Add support for openmetrics formatting to FPM status 2021-03-21 18:08:53 +00:00
Máté Kocsis cd40fc3cb1 Convert resources to objects in ext/ldap
Closes GH-6770
2021-03-21 10:43:25 +01:00
Dmitry Stogov 6690547a58 Use zend_hash_lookup() 2021-03-19 23:34:38 +03:00
Dmitry Stogov 340013ad01 Add zend_hash_lookup() and zend_hash_index_lookup() functions.
Thet search for an element with given key/index and add an empty one (NULL), if no found.
2021-03-19 22:36:24 +03:00
Christoph M. Becker 64e589cab6 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #80889: Cannot set save handler when save_handler is invalid
2021-03-19 17:05:32 +01:00
Christoph M. Becker 2a1ed81ffc Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #80889: Cannot set save handler when save_handler is invalid
2021-03-19 17:03:54 +01:00
Christoph M. Becker 06bfada99b Fix #80889: Cannot set save handler when save_handler is invalid
There is no need to require a (valid) save_handler to be set, when a
user handler is supposed to be set.  We just have to make sure, that
no user handler is already set in this case.

Closes GH-6788.
2021-03-19 16:59:54 +01:00
Nikita Popov 5fd2a5b13b Fix handling of unknown class in trait precedence list
Fixes oss-fuzz #31983.
2021-03-19 16:04:47 +01:00
Dmitry Stogov 89c61186ff micro-optimization 2021-03-19 16:57:42 +03:00
Nikita Popov 7279a66139 Install de_DE locale on azure 2021-03-19 11:34:42 +01:00
Nikita Popov 2d0e2733c8 Support prototypes in call graph
Even if we don't know the exact method being called, include it
in the call graph with the is_prototype flag. In particular, we
can still make use of return types from prototype methods, as
PHP 8 makes LSP violations a hard error.

Most other places are adjusted to skip calls with !is_prototype.
Maybe some of them would be fine, but ignoring them is conservative.
2021-03-19 10:49:15 +01:00
Dmitry Stogov 6689bedd17 XFAIL on WIN64 because of problem in libffi 2021-03-19 12:19:24 +03:00
Nikita Popov e67156e967 Add missing rc1/rcn to return type initialization 2021-03-19 10:04:56 +01:00
Nikita Popov dcac654fd5 Allow inferring narrowed return type
Even if an explicit return type is given, we might still infer
a more narrow one based on return statements. We shouldn't
pessimize this just because a type has been declared.
2021-03-18 17:11:56 +01:00
Nikita Popov 2f73cbb1b1 Update one more use of NO_AUTOLOAD 2021-03-18 16:25:22 +01:00
Máté Kocsis d91051da2c Update mysqli stub hash 2021-03-18 16:09:25 +01:00
Christoph M. Becker 02fdf9fd3b Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #80783: PDO ODBC truncates BLOB records at every 256th byte
2021-03-18 15:31:23 +01:00
Nikita Popov 8690efd1f8 Update opt test
And fix a type in the fetch class flags dumping while here.
2021-03-18 15:25:40 +01:00
Christoph M. Becker 97cfdcd73b Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #80783: PDO ODBC truncates BLOB records at every 256th byte
2021-03-18 15:18:53 +01:00
Nikita Popov 4df39f4bd0 Don't imply SILENT from NO_AUTOLOAD
We have separate flags for non-autoloading class fetches and
silent class fetches. There's no reason why NO_AUTOLOAD should
be special-cased to be implicitly silent.
2021-03-18 15:15:21 +01:00
Christoph M. Becker bccca0b53a Fix #80783: PDO ODBC truncates BLOB records at every 256th byte
It is not guaranteed, that the driver inserts only a single NUL byte at
the end of the buffer.  Apparently, there is no way to find out the
actual data length in the buffer after calling `SQLGetData()`, so we
adjust after the next `SQLGetData()` call.

We also prevent PDO::ODBC_ATTR_ASSUME_UTF8 from fetching garbage, by
fetching all chunks with the same C type.

Closes GH-6716.
2021-03-18 15:13:27 +01:00
Dmitry Stogov c8a8c47f7e Merge branch 'PHP-8.0'
* PHP-8.0:
  Additional fix for bug #80847. On x86_64 part of structure may be passed in CPU registers.
2021-03-18 16:16:29 +03:00
Dmitry Stogov 465cfc499b Additional fix for bug #80847.
On x86_64 part of structure may be passed in CPU registers.
2021-03-18 16:13:42 +03:00
Dmitry Stogov 9373d159c2 "zend-test" was renamed to "zend_test" 2021-03-18 14:36:46 +03:00
Nikita Popov 3b88e65265 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix locale switch back to C in pcre
2021-03-18 10:51:04 +01:00
Nikita Popov 4dce2f83f5 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix locale switch back to C in pcre
2021-03-18 10:50:57 +01:00
Nikita Popov 4be867e910 Fix locale switch back to C in pcre
The compile context is shared between patterns, so we need to set
the character tables unconditionally in case we switched from
a non-C locale to the C locale.
2021-03-18 10:48:43 +01:00
Nikita Popov 234af00bcb Destroy constant values before object store
Now that constants can contain objects (currently only enums),
we should destroy them before we free the object store, otherwise
there will be false positive leak reports.

This doesn't affect the fast_shutdown sequence.
2021-03-18 10:31:28 +01:00
Dharman 7e9f6d2a48 Deprecate OO style mysqli::get_client_info method
Deprecate passing connection object to mysqli_get_client_info()

Closes GH-6777.
2021-03-17 20:10:18 +00:00
Dmitry Stogov eb8f5e4347 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80861 (erronous array key overflow in 2D array with JIT)
2021-03-17 23:00:22 +03:00
Dmitry Stogov 7e494d9225 Fixed bug #80861 (erronous array key overflow in 2D array with JIT) 2021-03-17 22:59:59 +03:00
Ilija Tovilo d628d7e015 Add enums to UPGRADING [ci skip] 2021-03-17 19:15:35 +01:00
Ilija ToviloandNikita Popov 269c8dac1d Implement enums
RFC: https://wiki.php.net/rfc/enumerations

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>

Closes GH-6489.
2021-03-17 19:08:03 +01:00
George Peter Banyard a6fc427b8c Use zend_string_equals() API instead of strcmp() in various places
Closes GH-6784
2021-03-17 16:36:23 +00:00
George Peter Banyard a74e248c43 Use zend_string_equals() API instead of strcmp() in COM extension 2021-03-17 16:36:16 +00:00
George Peter Banyard 6acb079906 Use zend_string_equals() API instead of strcmp() in Date extension 2021-03-17 16:36:16 +00:00
George Peter Banyard 4b20c03387 Use zend_string_equals() API instead of strcmp() in Filter extension 2021-03-17 16:36:16 +00:00
George Peter Banyard 48ac3881a3 Use zend_string_equals() API instead of strcmp() in PGSQL extension
And tiny drive by refactor at the same time for more usages
2021-03-17 16:36:16 +00:00
George Peter Banyard 84e12626e7 Use zend_string_equals() API instead of strcmp() in SOAP extension 2021-03-17 16:36:16 +00:00
George Peter Banyard ddfe269aa8 Use zend_string_equals() API instead of strcmp() in main.c 2021-03-17 16:36:16 +00:00
Nikita Popov 00aa03bf8e Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix signed/unsigned warnings in PDO ODBC
2021-03-17 16:34:34 +01:00
Nikita Popov 34e39ebaf5 Fix signed/unsigned warnings in PDO ODBC
Add add skipif to test.

(cherry picked from commit aa58db7232)
2021-03-17 16:33:32 +01:00
Nikita Popov e9d78339e7 Use absolute paths in tokenizer_data_gen.php
To make it work with out-of-tree builds.
2021-03-17 15:54:02 +01:00
Christoph M. Becker 128082c86f Initalize return_value before use
Otherwise we likely segfault[1].  We fix the same issue for
PDO_Firebird as well.

[1] <https://ci.appveyor.com/project/php/php-src/builds/38267250/job/6y3ngn1k6ryxx6j3?fullLog=true#L9783>

Closes GH-6785.
2021-03-17 15:39:50 +01:00
Nikita Popov 92a969421c Merge branch 'PHP-8.0'
* PHP-8.0:
  imagecolortransparent() cannot return null
2021-03-17 15:09:26 +01:00
Nikita Popov d80118dc16 imagecolortransparent() cannot return null 2021-03-17 15:09:06 +01:00
Nikita Popov db538775e1 Merge branch 'PHP-8.0'
* PHP-8.0:
  Return bool from imageinterlace()
2021-03-17 15:06:46 +01:00
Nikita Popov c17434429d Return bool from imageinterlace()
The function accepts a bool since PHP 8.0, so it should also return
a bool to keep things consistent.

Furthermore a null return from this functions is not possible.
2021-03-17 15:05:09 +01:00
Dmitry Stogov 8f0ca7c16c Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80839 (PHP problem with JIT)
2021-03-17 16:55:42 +03:00
Dmitry Stogov faf1567212 Fixed bug #80839 (PHP problem with JIT) 2021-03-17 16:55:09 +03:00
Dmitry Stogov 356ef5bd0e Fix CLANG/RELEASE build (this is a workaround for probable bug in CLANG) 2021-03-17 15:50:36 +03:00
Christoph M. Becker e65f705ce3 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #66783: UAF when appending DOMDocument to element
2021-03-17 12:40:40 +01:00
Christoph M. Becker fddd0ac552 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #66783: UAF when appending DOMDocument to element
2021-03-17 12:40:03 +01:00
Christoph M. Becker a08847ab39 Fix #66783: UAF when appending DOMDocument to element
According to the DOM standard, elements may only contain element, text,
processing instruction and comment nodes[1].  It is also specified that
a HierarchyRequestError should be thrown if a document is to be
inserted[2].  We follow that standard, and prevent the use-after-free
this way.

[1] <https://dom.spec.whatwg.org/#node-trees>
[2] <https://dom.spec.whatwg.org/#mutation-algorithms>

Closes GH-6765.
2021-03-17 12:37:18 +01:00
Nikita Popov 709e45d89b Avoid unnecessary static_variables persistence
static_variables should be treated the same way as all other
op_array components nowadays (only static_variables_ptr is
special). There's no need to persist/serialize it is separately
per shared op_array.
2021-03-17 12:20:58 +01:00
Christoph M. Becker 994d4199d5 Merge branch 'PHP-8.0'
* PHP-8.0:
  8.0.5 is next
2021-03-17 12:15:35 +01:00
Christoph M. Becker c7fadd2328 8.0.5 is next
We also move the NEWS entry for bug 80847 to the proper version.
2021-03-17 12:14:26 +01:00
Nikita Popov 4cff8c10a9 Simplify attribute persistence
For an inherited op_array, directly fetch the xlat entry, as we
do for everything else.
2021-03-17 11:52:45 +01:00
Nikita Popov 69018da09b Fix PDO test under libmysqlclient 2021-03-17 11:26:41 +01:00
Máté Kocsis f15d52796e Declare PDORow::queryString property
Relates GH-6742
2021-03-17 09:42:35 +01:00
Dmitry Stogov 1494e87bd0 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80847 (CData structs with fields of type struct can't be passed as C function argument)
2021-03-17 09:56:07 +03:00
Dmitry Stogov 38ebb55c7c Fixed bug #80847 (CData structs with fields of type struct can't be passed as C function argument) 2021-03-17 09:55:20 +03:00
George Peter Banyard ebaeb93c3f Add API to fetch bool value for PDO attribute values
Closes GH-6766
2021-03-17 00:58:01 +00:00
George Peter Banyard c465462e91 Use standard PDO way for fetching integer attribute values 2021-03-17 00:58:01 +00:00
George Peter Banyard 32fb9b6fd1 Validate string is numeric for integer PDO attribute value 2021-03-17 00:58:00 +00:00
Máté Kocsis e0aab7413b Promote DOM invalid state errors during property access
Closes GH-6780
2021-03-16 20:22:32 +01:00
Dmitry Stogov c732ab400a Change Zend Stream API to use zend_string* instead of char*.
This allows to eliminate re-calculation of string lenght and hash value.
See the detailed list of changes in UPGRADING.INTERNALS.
2021-03-16 20:31:36 +03:00
Ilija Tovilo 9bbeb0555b Add tokenizer_data_gen to build process
Closes GH-6723.
2021-03-16 14:53:59 +01:00
Nikita Popov e35f9dfecc Don't check executability
As $(PHP) is not an absolute path, test -x doesn't do anything
meaningful. Rely on the autoconf check.
2021-03-16 14:36:10 +01:00
Nikita Popov 59e610092a Check for WRONG_PROPERTY_INFO 2021-03-16 14:24:48 +01:00
Nikita Popov 4f750f7171 Revert "Remove some unnecessary explicit header dependencies"
This reverts commit c386b1fb17.

It looks like at least some of these might be needed for ordering
in a clean build?
2021-03-16 14:22:25 +01:00
Nikita Popov 9b816d83f6 Automatically run zend_vm_gen.php if zend_vm_def.h changes 2021-03-16 13:08:37 +01:00
Nikita Popov c386b1fb17 Remove some unnecessary explicit header dependencies
These are now automatically tracked by the build system.
2021-03-16 13:02:23 +01:00
Nikita Popov fa9e2b31b8 Check for php program in autoconf
Use the detected PHP (minimum 7.1) to run gen_stubs, and other
code generation scripts in the future.
2021-03-16 12:30:56 +01:00
Max Semenik 9140c9038a run-tests.php: class for test file loading
This moves a bunch of code outside of run_tests(), making it a bit
more manageable. Additionally, accessors provide better readability
than isset() and friends.

This is a minimal patch that moves the code but does not refactor
much. For the sake of reviewing experience, it does not involve
further refactoring which could include:
* Removing setSection()
* Fixing up the mess with hasSection() vs. sectionNotEmpty(), only
  one of which is really needed.
* Moving more repetitive code into the new class.
All of this will be done with later commits.

Closes GH-6678.
2021-03-16 11:51:55 +01:00
Nikita Popov 77ebf81492 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix refcount inference for typed properties
2021-03-16 11:18:12 +01:00
Nikita Popov 53e9c36cd9 Add sanity check for type of read_property return value
If an internal class overrides read_property and declared property
types, make sure that the returned value matches the declared
type (in debug builds).
2021-03-16 10:42:47 +01:00
Derick Rethans aad283e9f3 Merge branch 'PHP-8.0' 2021-03-16 09:41:47 +00:00
Derick Rethans 89f0bd92a0 Merge branch 'PHP-8.0' 2021-03-16 09:40:32 +00:00
Máté Kocsis 66f16f4eb2 Merge branch 'PHP-8.0'
* Fix crash in LDAP search functions during argument validation
* Fix ldap_next_entry() parameter name
2021-03-16 09:34:41 +01:00
Máté Kocsis 87b263d2d7 Merge branch 'PHP-8.0' 2021-03-15 23:47:58 +01:00
Christoph M. Becker 0b2bb98af9 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #80817: dba_popen() may cause segfault during RSHUTDOWN
2021-03-15 18:40:30 +01:00
George Peter Banyard f89f600d4f Add comment explaining empty default case 2021-03-15 16:39:40 +00:00
George Peter Banyard 6cc0d7c0ec Boolify pdo_dbh_attribute_set() 2021-03-15 14:48:33 +00:00
George Peter Banyard 3e6940fe29 Boolify pdo_hash_methods() 2021-03-15 14:48:33 +00:00
George Peter Banyard 262744ff0d Boolify pdo_stmt_describe_columns() 2021-03-15 14:48:33 +00:00
George Peter Banyard 63c4e8b5ab Voidify internal pdo_sqlstate_init_error_table()
This always returned SUCCESS
2021-03-15 14:48:33 +00:00
George Peter Banyard 0807c6cbb0 Remove php_pdo_str_tolower_dup() function 2021-03-15 14:48:33 +00:00
Dharman 5e1056edb6 Change the default error mode of mysqli
Make MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT the new mysqli
error reporting default. Explicitly call
mysqli_report(MYSQLI_REPORT_OFF) to preserve previous behavior.

RFC: https://wiki.php.net/rfc/mysqli_default_errmode

Closes GH-6629.
2021-03-15 14:55:31 +01:00
Nikita Popov b82b85709d Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix bug #80866
2021-03-15 14:48:09 +01:00
Nikita Popov 5604c2d05c Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix bug #80837
2021-03-15 14:38:56 +01:00
Nikita Popov 7e3840df90 Assert that stmt is set in PDORow 2021-03-15 14:22:49 +01:00
Nikita Popov 7e2f1a80d6 Merge branch 'PHP-8.0'
* PHP-8.0:
  Update ubuntu on i386 job
  Downgrade security level in tests using TLS < 1.2
2021-03-15 14:12:49 +01:00
Máté Kocsis 4833309bd2 Use typed properties in ext/mysqli
Closes GH-6739
2021-03-15 13:11:57 +01:00
Nikita Popov f7751f2d8b Use zend_objects_not_comparable in PDO 2021-03-15 13:01:42 +01:00
Dharman 8573eb9e5c Add CLEAN sections to mysqli and PDO mysql tests
Closes GH-6756.
2021-03-15 11:01:12 +01:00
Nikita Popov 3b9ea4d289 Merge branch 'PHP-8.0'
* PHP-8.0:
  ext/opcache: fix configure output while checking mmap MAP_ANON support
2021-03-15 10:53:08 +01:00
Dharman 3dfd3558ca Deprecate mysqli driver_version property
The driver version hasn't been updated in 13 years, so this number
is essentially meaningless. Check PHP_VERSION_ID instead.
2021-03-15 10:48:36 +01:00
Nikita Popov 11dbed9b2f Remove dead mysqli_driver_construct() function
This function was never registered with PHP, and the body is
commented out.
2021-03-15 10:40:48 +01:00
Dharman 4bd3cb6626 Clean up mysqli_driver test cases
And remove an unnecessary test case that is already covered by the
other two.
2021-03-15 10:34:55 +01:00
Dharman 5801ead8ea Remove redundant macros in mysqli_driver implementation
This class doesn't define many properties, and the macros make
customization hard.
2021-03-15 10:34:05 +01:00
Dharman 475ea62dd7 Remove unused mysqli global
And fix formatting issues.
2021-03-15 10:33:03 +01:00
Dharman 321e0d451d client_info is a constant and doesn't need a connection
Closes GH-6767.
2021-03-15 10:24:42 +01:00
George Peter Banyard d4530f807a Use zend_string* & more legible API for php_get_display_errors_mode() 2021-03-14 15:06:15 +00:00
Calison 021c988a6f Return early on php display error for better legibility
Closes GH-6760

Signed-off-by: George Peter Banyard <girgias@php.net>
2021-03-14 14:25:26 +00:00
Anatol Belski 8ff6dbb57c hash: xxhash: Use canonicalization routine from existing API
Signed-off-by: Anatol Belski <ab@php.net>
2021-03-13 21:38:10 +01:00
Dmitry Stogov d5a15d2c91 Remove deprecated code 2021-03-13 01:04:43 +03:00
Dmitry Stogov fe3dbe5294 Fixed compilation warning 2021-03-12 21:50:26 +03:00
Dmitry Stogov 3d11743372 Inline "array" part of FE_FETCH_R handler into HYBRID VM 2021-03-11 22:33:01 +03:00
Dmitry Stogov 278d452a6a zend_verify_recv_arg_type_helper is not "cold". 2021-03-11 15:57:02 +03:00
Dmitry Stogov d0e043b294 Avoid repeatable work when error_reporting() is called with the same argument few times. 2021-03-11 14:27:53 +03:00
Dmitry Stogov 65859fe17e Inheritance cache optimization 2021-03-11 13:42:35 +03:00
Dmitry Stogov d02197853e Fixed assertion (ext/opcache/zend_persist.c:327: zend_accel_get_type_map_ptr: Assertion `ret > 2' failed) 2021-03-10 17:39:26 +03:00
Dmitry Stogov d336ccaa08 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80814 (threaded mod_php won't load on FreeBSD: No space available for static Thread Local Storage)
2021-03-10 16:04:33 +03:00
Dmitry Stogov 1d5f359f56 Use spl_filesystem_object.file_name for SPL_FS_DIR as a cache and prevent multiple file name reconstruction. 2021-03-09 17:37:24 +03:00
Christoph M. Becker 9f826e8ce9 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #51903: simplexml_load_file() doesn't use HTTP headers
2021-03-08 15:16:55 +01:00
Christoph M. Becker 8d58504035 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #80838: HTTP wrapper waits for HTTP 1 response after HTTP 101
2021-03-08 14:52:45 +01:00
Máté Kocsis 495bf5cdd0 Merge branch 'PHP-8.0' 2021-03-06 00:56:47 +01:00
George Wang 16c2afb8b9 Merge branch 'PHP-8.0' 2021-03-05 11:01:27 -05:00
Nikita Popov 8a134c9a26 Merge branch 'PHP-8.0'
* PHP-8.0:
  Add supports for FreeBSD's PROT_MAX to let mprotect knows X flag can be applied in addition.
2021-03-05 16:44:25 +01:00
Nikita Popov 08ad9af2ca Reduce date test threshold further
Still seeing the occasional spurious failure.
2021-03-05 16:31:24 +01:00
Christoph M. Becker 9f7c6a824a Merge branch 'PHP-8.0'
* PHP-8.0:
  Print error code if CreateMutex() fails
2021-03-05 15:09:26 +01:00
Dmitry Stogov b84f4ed7c3 typo 2021-03-05 12:31:04 +03:00
Nikita Popov 670b19af3e Reduce threshold in ext/date/tests/bug73837.phpt
Now that this code is faster, we're seeing many spurious failures.
2021-03-04 17:02:02 +01:00
Max Semenik c639d34a6e Update mysqli tests to work with newer MySQL server
* @@session.old_passwords is present only in 5.6 and 5.7. Newer versions
  already behave as if they have old_passwords=2.
* SET PASSWORD FOR ... = PASSWORD(...) syntax was removed in 8.0.

For all affected tests, versions that don't support newer SQL are
already explicitly excluded with version checks.

Closes GH-6729.
2021-03-04 16:34:11 +01:00
Nikita Popov 0074a1d4e3 Make the nocache tag actually work
If nocache is used, then we should return an empty string result,
so the test doesn't get marked as borked.

Also limit to an occurrence at the start, just like other skip
tags.
2021-03-04 16:34:10 +01:00
Nikita Popov 4d43cbe333 Add mechanism to skip the skipif cache
If the SKIPIF section return nocache, don't cache the result. This
is used by tests that perform complex test set in conjunction with
skip checks, and need to be evaluated every time.
2021-03-04 16:28:11 +01:00
Nikita Popov 97de8cfc71 Fix dynamic func def persist with preloading
If we find an existing serialization of the op_array, of course
we also need to actually make use of it...
2021-03-04 16:15:05 +01:00
Nikita Popov b853201a6d run-tests.php: Preserve .php on leak in one more place 2021-03-04 16:09:29 +01:00
Dmitry Stogov 6543d4bc1d Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix ASAN warning (Zend/zend_string.h:165:2: runtime error: null pointer passed as argument 2 of memcpy(), which is declared to never be null)
2021-03-04 17:28:25 +03:00
Dmitry Stogov 16649cb60d Cache haschildren/getchildren methods of recursive iterators. 2021-03-04 17:04:55 +03:00
twosee db33af7104 Remove duplicated SSL_CTX_set_verify()
Duplicated with line 920.
Our minimal OpenSSL version is v1.0.1 (See https://github.com/openssl/openssl/blob/OpenSSL_1_0_1-stable/ssl/ssl_lib.c#L2039).
Removing it does not affect program behavior.
Closes GH-6751.
2021-03-04 17:51:29 +08:00
Dmitry Stogov b4e9b18463 Avoid useless date conversion 2021-03-04 12:27:31 +03:00
Nikita Popov 500b4b4945 Explicitly print reference wrappers in debug_zval_dump()
Closes GH-6750.
2021-03-04 10:11:37 +01:00
Dmitry Stogov 4b59071844 Switch to new ZPP 2021-03-04 02:11:21 +03:00
Dmitry Stogov dd3bfb3704 Switch to new ZPP 2021-03-04 02:10:53 +03:00
Dmitry Stogov d02734f05e Loop invariant code motion 2021-03-04 02:10:10 +03:00
Christoph M. Becker 1c56a830ce Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #80825: ZipArchive::isCompressionMethodSupported does not exist
2021-03-03 22:57:51 +01:00
Alex McLean ec5e811dbd Add test cases for bcmath ValueErrors
Closes GH-6714

Signed-off-by: George Peter Banyard <girgias@php.net>
2021-03-03 18:35:15 +00:00
Gabriel Caruso c3165467f5 Replaced deprecated hw.ncpu with hm. logicalcpu
Found that at ziglang/zig#1252.

Closes GH-5541
2021-03-03 18:33:50 +00:00
Christoph M. Becker 2dc2436e08 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix test wrt. server.inc changes
2021-03-03 12:05:03 +01:00
Christoph M. Becker 8162abeb17 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #78719: http wrapper silently ignores long Location headers
2021-03-03 10:48:43 +01:00
Máté Kocsis 91739b8c89 Fix bug #80816 Document the removal of alias class entries from ext/spl
Closes GH-6748 [skip-ci]
2021-03-03 09:43:55 +01:00
Levi Morrison 2317b81c62 Add const to zend_extension_version_info.build_id
This is a follow-up to:
https://github.com/php/php-src/commit/3c6ab4b3ea5854fd44a2945bb65bf027a6c94890

Closes GH-6744.
2021-03-02 18:42:58 -07:00
Nikita Popov 3a867b9827 Fixed bug #80808
If the ZEROFILL flag is set for a field, do not convert it into
an integer (text protocol) or convert it explicitly into a padded
string (binary protocol).
2021-03-02 10:59:34 +01:00
Dmitry Stogov c28751c69c Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80802: (zend_jit_fetch_indirect_var assert failure with tracing JIT)
2021-03-02 00:01:01 +03:00
Dmitry Stogov 9da66e6ad0 Optimized object conversion to array without rebulding properties HashTable 2021-03-01 22:37:37 +03:00
Dmitry Stogov f9f8c1c79c Optimized object encoding without rebulding properties HashTable 2021-03-01 22:37:05 +03:00
Christoph M. Becker 87a5a0e2cb Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #80751: Comma in recipient name breaks email delivery
2021-03-01 18:50:58 +01:00
Máté Kocsis 1cb823c82e Declare XMLReader properties
Closes GH-6741
2021-03-01 16:58:23 +01:00
Nikita Popov 056eac6b03 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80811
2021-03-01 16:30:19 +01:00
Nikita Popov 26c3fa2759 Merge branch 'PHP-8.0'
* PHP-8.0:
  Always remove HT iterators, even for uninit HT
2021-03-01 16:22:51 +01:00
Tyson Andre b4fbf1d381 Optimize serializing class names
Because of the memcpy, compilers can't infer that ZSTR_LEN (i.e. class_name->len)
did not change, so they copy it out of memory into a register for the last two
accesses.
php_var_serialize_string already does something similar.

Closes GH-6734
2021-03-01 09:41:13 -05:00
Nikita Popov b652267383 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80805
2021-03-01 15:13:50 +01:00
Dmitry Stogov fa14eedbea Optimized object serialization without rebulding properties HashTable 2021-03-01 16:10:56 +03:00
Dmitry Stogov 56afe2f230 Incomplete class may have only single "MAGIC_MEMBER" 2021-03-01 14:53:30 +03:00
Dmitry Stogov b0c7ea4919 Change the order of properties used in foreach(), var_dump(), serialize(), comparison, etc. Now properties are ordered according to their layout in zend_object structure. 2021-03-01 13:43:22 +03:00
Dmitry Stogov c9a9362c78 Added UPGRADING note. 2021-03-01 13:42:34 +03:00
Nikita Popov 47a2e5c785 Reference dynamic functions through dynamic_defs
Currently, dynamically declared functions and closures are inserted
into the function table under a runtime definition key, and then later
possibly renamed. When opcache is not used and a file containing a
closure is repeatedly included, this leads to a very large memory leak,
as the no longer needed closure declarations will never be freed
(https://bugs.php.net/bug.php?id=76982).

With this patch, dynamic functions are instead stored in a
dynamic_func_defs member on the op_array, which opcodes reference
by index. When the parent op_array is destroyed, the dynamic_func_defs
it contains are also destroyed (unless they are stilled used elsewhere,
e.g. because they have been bound, or are used by a live closure). This
resolves the fundamental part of the leak, though doesn't completely
fix it yet due to some arena allocations.

The main non-obvious change here is to static variable handling:
We can't destroy static_variables_ptr in destroy_op_array, as e.g.
that would clear the static variables in a dynamic function when
the op_array containing it is destroyed. Static variable destruction
is separated out for this reason (we already do static variable
destruction separately for normal functions, so we only need to
handle main scripts).

Closes GH-5595.
2021-03-01 11:35:54 +01:00
Dmitry Stogov 72c3ededed Change the order of properties used for var_dump(), serialize(), comparison, etc.
Now properties are ordered according to their layout in zend_object structure.
2021-03-01 13:29:49 +03:00
Max Semenik b86dfb0e74 Fix E_DEPRECATED in zend_vm_gen.php
explode(): Passing null to parameter #2 ($string) of type string is
deprecated

Closes GH-6698.
2021-03-01 11:22:18 +01:00
Max Semenik bdd7c48764 run-tests: drop support for ancient Valgrind versions
Valgrind 3.3.0 was released in 2007, not even RHEL has crap older than
this. It could be argued that 3.8.0, released in 2012, could be a safe
cutoff too.

Closes GH-6728.
2021-03-01 11:21:30 +01:00
Nikita Popov 1ec7cc96dc Clarify types in XmlReader property handling
Make it clearer that the specified type is really the only type
that can be returned.
2021-03-01 09:54:24 +01:00
Patrick Allaert 6f38a53940 Remove useless conditional #ifdef
Closes GH-6737

Signed-off-by: George Peter Banyard <girgias@php.net>
2021-02-27 13:23:00 +00:00
George Peter Banyard bfd3fda0f4 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix Bug #80800 imap_open() fails when the flags parameter includes CL_EXPUNGE
2021-02-27 13:14:23 +00:00
Dmitry Stogov 6c5942f835 serialize() optimization 2021-02-26 13:30:19 +03:00
Dmitry Stogov 17ad94df12 Optimize out zend_strpprintf() usage for simple concationaton 2021-02-26 10:34:30 +03:00
Dmitry Stogov 13e4ce386b Improve SPL directory and stat() cache using zend_srting* instead of char* 2021-02-26 02:28:46 +03:00
Felipe Pena 5e8ae15c3d Merge branch 'PHP-8.0' 2021-02-25 20:57:30 +00:00
George Peter Banyard 3a4b89661e Remove quicktester
This is barely used and more of a hinderence than anything else

Closes GH-6712
2021-02-25 17:39:31 +00:00
Remi Collet 8c206ba5ac Merge branch 'PHP-8.0'
* PHP-8.0:
  skip test with openssl < 1.1.0
2021-02-25 13:54:34 +01:00
Christoph M. Becker 51914610ab Merge branch 'PHP-8.0'
* PHP-8.0:
  Capture Microsoft-defined HRESULT exit codes exit codes
2021-02-25 12:05:27 +01:00
Nikita Popov 362116c80b Merge branch 'PHP-8.0'
* PHP-8.0:
  crc32 module, clang spurious warning removal.
2021-02-25 10:19:06 +01:00
Dmitry Stogov 0f6c00200b Speed up __sleep() and __wakeup() calls 2021-02-25 12:16:22 +03:00
Nikita Popov 7920c9dd44 Merge branch 'PHP-8.0'
* PHP-8.0:
  mysqlnd pam fix test error message
2021-02-25 09:52:18 +01:00
Nikita Popov 4a8b93425d Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix potential file collision in dom tests
  Fix bug #80757 (Exit code is 0 when could not open file)
  Update NEWS
2021-02-24 21:31:03 +01:00
Dmitry Stogov 5caf29a01e Switch few functions useful in Symphony apps to new ZPP API. 2021-02-24 19:13:11 +03:00
Dmitry Stogov 99d0f502dc Fixed error message 2021-02-24 19:12:32 +03:00
Nikita Popov 23afc62080 Allow pointer to end of memory in IS_UNSERIALIZED()
We already use <= for IS_SERIALIZED(), but the same general
problem can also occur for IS_UNSERIALIZED(). We don't seem to
hit this in practice prior to GH-5595 though.
2021-02-24 11:46:35 +01:00
Dmitry Stogov ae2ea348dd Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80782 (DASM_S_RANGE_VREG on PHP_INT_MIN-1)
2021-02-24 12:20:49 +03:00
Dylan T e5551d50e7 zend_compile.c: fix typo
Don't mind me, I just happened to be browsing this code. 🙃

Closes GH-6721.

[ci skip]
2021-02-24 10:10:19 +01:00
Max Semenik dda0cea5cd run-tests: add skip cache
Currently every --SKIPIF-- section in every test file results in 1
extra execution of PHP, every --EXTENSIONS-- section - in 2 executions.
This is quite wasteful, as skip checking code is extremely repetitive
and extensions are fixed for every binary/ini/command parameters
combination.

This patch adds caching to all such checks.

On my machine, the gains are quite noticeable: 36s instead of 43s
with -j16, 292s instead of 337s without concurrency. Cache stats are
3780 hits, 1247 misses in the latter case. In the future, tests could
be adjusted to have more uniform skip checks to improve performance even
more.

Closes GH-6681.
2021-02-23 15:05:49 +01:00
Christoph M. Becker b84e3b1ced Merge branch 'PHP-8.0'
* PHP-8.0:
  run-tests: fixed exit code not being set on BORKED tests
2021-02-23 13:23:22 +01:00
Nikita Popov fc1a012c49 Fix Windows build
Don't add to a void pointer.
2021-02-23 12:23:08 +01:00
Christoph M. Becker 062c09e198 Merge branch 'PHP-8.0'
* PHP-8.0:
  Update php_version.h to proper version number
2021-02-23 12:18:03 +01:00
Nikita Popov 771b0bd1df Remove free_chunk API
This API only works in very limited circumstances -- relying on
it will invariably lead to leaks. The correct way to "free" something
from the pool is to use the checkpoint API.
2021-02-23 11:46:34 +01:00
Nikita Popov 6e6d6bb4fc Remove resize_chunk API
The last user has been dropped in the previous commit. This has
never worked meaningfully in the first place.
2021-02-23 11:18:48 +01:00
Nikita Popov 1fc4c89214 Fixed bug #80761
When row data split across multiple packets, allocate a temporary
buffer that can be reallocated, and only copy into the row buffer
pool arena once we know the final size. This avoids quadratic
memory usage for very large results.
2021-02-23 11:17:31 +01:00
Nikita Popov 8be711be47 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80786
2021-02-23 10:22:20 +01:00
Cameron Porter 24e7299c9d Fixed bug #80724
FilesystemIterator::FOLLOW_SYMLINKS is currently treated as a directory
key mode flag, even though it does not change the way that the key
during iteration is set. To address this, FOLLOW_SYMLINKS has been
converted into an OTHER flag.

Closes GH-6695.
2021-02-23 09:50:36 +01:00
Darek SlusarczykandNikita Popov da011a312a Fix #80329: Add option to specify LOAD DATA LOCAL white list folder
* allow the user to specify a folder where files that can be sent
   via LOAD DATA LOCAL can exist
 * add mysqli.local_infile_directory for mysqli
   (ignored if mysqli.allow_local_infile is enabled)
 * add PDO::MYSQL_ATTR_LOCAL_INFILE_DIRECTORY for pdo_mysql
   (ignored if PDO::MYSQL_ATTR_LOCAL_INFILE is enabled)
 * add related tests
 * fixes for building with libmysql 8.x
 * small improvement in existing tests
 * update php.ini-[development|production] files

Closes GH-6448.

Co-authored-by: Nikita Popov <nikic@php.net>
2021-02-23 09:30:46 +01:00
Christoph M. Becker 7f8ea83ef4 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #75776: Flushing streams with compression filter is broken
2021-02-22 15:33:57 +01:00
Máté Kocsis 4c6533c257 Generate class entries from stubs for com, standard, xmlreader, xmlwriter, xsl, zip, Zend
Closes GH-6706
2021-02-22 15:24:03 +01:00
Christoph M. Becker d03be8bf86 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #80771: phpinfo(INFO_CREDITS) displays nothing in CLI
2021-02-22 14:34:45 +01:00
Christoph M. Becker 59d030c55b Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #80774: session_name() problem with backslash
2021-02-22 12:36:43 +01:00
Nikita Popov 8e8e0017b9 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix trampoline leak on dynamic static call of non-static method
2021-02-22 10:33:16 +01:00
Nikita Popov b3f4a3105c Don't resolve special class names
Adjust zend_resolve_class_name() to not resolve special class names.
This avoids the need to only call this function after a preliminary
check for non-default fetch types. Doing so is somewhat fragile
when dynamic class names are involved.

Fixes oss-fuzz #31139.
2021-02-22 10:11:14 +01:00
Nikita Popov de03bc8eb7 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80781
2021-02-22 09:38:44 +01:00
Markus Staab fd3692ba41 Fix typo [ci skip]
Closes GH-6713.
2021-02-22 09:02:31 +01:00
Anatol Belski 6ffa9b118a NEWS: Associate FR to xxHash additions
[ci skip]

Signed-off-by: Anatol Belski <ab@php.net>
2021-02-21 13:50:59 +01:00
Anatol Belski 6055b72d0e UPGRADING: Add note about xxHash secret and fix a typo
[ci skip]

Signed-off-by: Anatol Belski <ab@php.net>
2021-02-21 13:36:28 +01:00
Anatol Belski 20501c72c8 hash: Implement secret support for xxh3 and xxh128
A secret can be passed through the options array. The length is
currently in the range of 136 to 256 bytes. The concerned algos are
already marked as non serializable.

Signed-off-by: Anatol Belski <ab@php.net>
2021-02-20 23:26:59 +01:00
Dmitry Stogov 3b29f5164d Revert "Remove class validation. zend_lookup_class_ex() performs it anyway."
This reverts commit 61cf1355fd.

Class name validation is only performed if key is not passed. Here, lc_name is passed as key.
2021-02-20 18:51:03 +03:00
Dmitry Stogov 61cf1355fd Remove class validation. zend_lookup_class_ex() performs it anyway. 2021-02-20 17:01:16 +03:00
Dmitry Stogov ac7e967b67 Reduce ZPP API overhead 2021-02-20 13:59:29 +03:00
Nikita Popov f37fe68e63 Fix closure GC handler for fake closures
Fixes oss-fuzz #31135.
2021-02-20 11:16:37 +01:00
Dmitry Stogov 59590663d7 Fixed NULL pointer dereference 2021-02-20 11:20:29 +03:00
Dmitry Stogov bb1d61a848 Attempt to fix ext\standard\tests\file\basename_bug66395_variation2-win32.phpt and ext\standard\tests\file\pathinfo_basic1-win32.phpt 2021-02-19 21:48:19 +03:00
Dmitry Stogov 5e01542526 Improve basename(). Avoid calling mblen() for ASCII compatible locales. 2021-02-19 15:42:21 +03:00
Anton Vasiliev be9200998f Fix typo
Closes GH-6708

Signed-off-by: George Peter Banyard <girgias@php.net>
2021-02-18 18:04:51 +00:00
Nikita Popov a843c8a4b6 Fix crash during default value evaluation 2021-02-18 16:44:10 +01:00
Dmitry Stogov 9619562dbc Properly relove self::CONSTANT at compile time 2021-02-18 17:18:57 +03:00
Nikita Popov db2e2af13a Fixed bug #53826
We should handle the case where the method doesn't exist, and
where it is not visible the same way.
2021-02-18 14:17:47 +01:00
Dmitry Stogov 6e988eaefb We don't need map_ptr slots for op_array.run_time_cache during preloading. 2021-02-18 15:46:48 +03:00
Máté Kocsis 4f4c031f62 Generate ext/spl class entries from stubs
Closes GH-6709
2021-02-18 13:01:51 +01:00
Nikita Popov 6b0f14fe3b Fixed bug #75474
For fake closures, we need to share static variables with the
original function, not work on a separate copy. Calling a function
through Closure::fromCallable() should have the same behavior as
calling it directly.
2021-02-18 11:39:28 +01:00
Nikita Popov 5d160e309e Fix static variable behavior with inheritance
When a method is inherited, the static variables will now always
use the initial values, rather than the values at the time of
inheritance. As such, behavior no longer depends on whether
inheritance happens before or after a method has been called.

This is implemented by always keeping static_variables as the
original values, and static_variables_ptr as the modified copy.

Closes GH-6705.
2021-02-18 11:18:19 +01:00
Nikita Popov e03284739f Initialize property to UNDEF on unserialize overwrite
The UNDEF marker here is important to prevent the creation of
a reference to the property currently being overwritten, which
would then leak.

This fixes oss-fuzz 6029559193534464, which was incorrectly
merged into oss-fuzz #30584 (which is reported at
https://github.com/google/oss-fuzz/issues/5211).
2021-02-18 11:10:20 +01:00
Nikita Popov 4fdaf84cc3 Merge branch 'PHP-8.0'
* PHP-8.0:
  Avoid signed integer overflow in substr()
2021-02-18 10:35:17 +01:00
Nikita Popov b87080f3c2 Don't use unmangled name if property not found
This restores the previous behavior for this case. We'll continue
to use the mangled name, even if it does not correspond to a
declared property.

This also fixes an assertion failure for the case of property
overwrite, as the add_new was not guaranteed to be "new" previously.

Fixes oss-fuzz #31045.
2021-02-18 10:17:23 +01:00
Christoph M. Becker b074e3b52b Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #80763: msgfmt_format() does not accept DateTime references
2021-02-17 17:31:47 +01:00
Nikita Popov de5b42219c Avoid writing zend_vm_opcodes.h if it did not change
Now that we track header changes, a change to zend_vm_opcodes.h
requires rebuilding essentially the whole tree. In most cases,
changes to zend_vm_def.h don't actually result in any header
changes though.

Avoid touching the file by first checking whether the to be written
contents are actually the same.
2021-02-17 17:18:57 +01:00
Alex Erohin cbfdc1fd54 Coding style tweaks for zend_vm_gen.php
- fixed array style for $vm_kind_name and $op_types
- deleted unnecessary else statement for is_hot_helper function
- fixed concatenation style
- fixed style of using whitespace between "(" and switch/foreach - replaced !is_null with "!=="

Closes GH-6704.
2021-02-17 17:05:34 +01:00
Nikita Popov 4ea90c15de Merge branch 'PHP-8.0'
* PHP-8.0:
  Color LEAK&FAIL like a failure
2021-02-17 16:40:33 +01:00
Sara Golemon 922fb12121 Merge branch 'PHP-8.0'
* PHP-8.0:
  Prep for 8.0.4
2021-02-17 15:25:37 +00:00
Dmitry Stogov 76b3635607 unserialize() optimization. Omit class name validation before hash lookup, and perform it only before autoloading. 2021-02-17 13:30:52 +03:00
Dmitry Stogov 5c78e87399 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80745 (JIT produces Assert failure and UNKNOWN:0 var_dumps in code involving bitshifts)
2021-02-17 11:51:50 +03:00
Nikita Popov bbb86ba7e2 Merge branch 'PHP-8.0'
* PHP-8.0:
  Remove generated zend_jit_x86.c on `make clean`
2021-02-17 09:45:31 +01:00
Dmitry Stogov 319f73e06b Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80742 (Opcache JIT makes some boolean logic unexpectedly be true)
2021-02-16 20:02:48 +03:00
Máté Kocsis 803779e84b Add support for generating properties with union type of multiple classes
Closes GH-6701
2021-02-16 15:50:13 +01:00
Nikita Popov 6bfe1aa19a Merge branch 'PHP-8.0'
* PHP-8.0:
  Handle incomplete result set metadata more gracefully
2021-02-16 15:35:01 +01:00
Máté Kocsis cad66533f0 Generate class entries from stubs for ldap, libxml, mbstring and mysqli
Closes GH-6684
2021-02-16 14:46:19 +01:00
Nikita Popov 8b4ae72efb Fix unused variable warning 2021-02-16 14:24:58 +01:00
Nikita Popov ce0bc58c22 Merge branch 'PHP-8.0'
* PHP-8.0:
  Mark resource-like objects as non-comparable
2021-02-16 14:22:03 +01:00
Dmitry Stogov 081349fe16 Improved unserialize() performance. Checks for object propery "visibility change" were moved, to be performed only if name/visibility had been really changed. 2021-02-16 15:27:58 +03:00
Máté Kocsis bf0f6aaf18 Improve class entry generation
Related to GH-6701
2021-02-16 13:09:56 +01:00
Nikita Popov 1f04f162a6 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80723
2021-02-16 12:34:00 +01:00
Derick Rethans 2fe6df771f Merge branch 'PHP-8.0' 2021-02-16 11:31:53 +00:00
Derick Rethans e3bb2c9d9a Merge branch 'PHP-8.0' 2021-02-16 11:27:24 +00:00
Dmitry Stogov f8cf7152a9 Microoptimization of STRLEN and IN_ARRAY opcodes (based on https://github.com/php/php-src/pull/4981) 2021-02-16 14:11:47 +03:00
Nikita Popov eb8ad30cf1 Fix quadratic slowdown under asan in timelib
This is a hotfix for https://github.com/derickr/timelib/pull/94
until the issue is resolved upstream.
2021-02-16 11:56:17 +01:00
Florian Sowade c4d508c2bc Add dependency tracking for header files
This ensures all .c files which include a header file directly or
indirectly are rebuilt whenever the header file is changed.

Closes GH-6693.
2021-02-16 10:50:03 +01:00
Alexander Moskalev e727919b97 cURL: make possible to send file from buffer string
Add CURLStringFile class which works similarly to CURLFile, but
uploads a file from a string rather than a file. This avoids the
need to create a temporary file, or use of a data:// stream.

Basic usage:

    $file = new CURLStringFile($data, 'filename.txt', 'text/plain');
    curl_setopt($curl, CURLOPT_POSTFIELDS, ['file' => $file]);

Closes GH-6456.
2021-02-16 10:24:22 +01:00
Nikita Popov d16341dabe Merge branch 'PHP-8.0'
* PHP-8.0:
  Increase timeout on asan job
2021-02-16 10:16:13 +01:00
Nikita Popov 45e6dc7beb Merge branch 'PHP-8.0'
* PHP-8.0:
  Suppress OpenSSL error on missing optional config
2021-02-16 10:12:59 +01:00
Nikita Popov 353f7ffb6b Delref only after successful allocation
Otherwise we may have inconsistent refcounts after OOM.

I expect this problem is much more prevalent, but this at least
fixes some string/array separation cases.

Fixes oss-fuzz #30999.
2021-02-16 10:01:46 +01:00
Christoph M. Becker 0cdc634fc4 Merge branch 'PHP-8.0'
* PHP-8.0:
  Adapt test case for libcurl 7.75.0+
2021-02-16 00:30:03 +01:00
Nikita Popov 5f0b995e6c Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80747
2021-02-15 15:34:54 +01:00
Nikita Popov e70f1b0488 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix symtable cache being used while cleaning symtable
2021-02-15 14:59:07 +01:00
Nikita Popov 643a727c37 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix assertion failure in cufa optimization with named args
2021-02-15 12:43:50 +01:00
Nikita Popov c91ea947b2 Use typed proprety for Transliterator::$id
This is a read-only property for which Transliterator internally
assigns a string value.

Also clean up the code handling this property a bit.
2021-02-15 12:27:25 +01:00
Nikita Popov 2ccf630917 Used typed properties for reflection $name and $class
These are read-only properties, and Reflection makes sure to assign
only strings.
2021-02-15 12:09:18 +01:00
Máté Kocsis a730dc0cf9 Generate class entries for snmp, soap, sockets, sodium, sqlite3, sysv*, tidy
Closes GH-6696
2021-02-15 11:45:26 +01:00
Nikita Popov f01ad22bab Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #78680: mysqlnd pam plugin missing terminating null
2021-02-15 11:33:01 +01:00
David Carlier fe01a7c515 Avoid repeatedly calling strlen in FPM setproctitle implementation
Closes GH-6689.
2021-02-15 11:29:18 +01:00
Nikita Popov 549235d327 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix leak when breaking out of FilesystemIterator
  Fixed bug #80600
2021-02-15 10:38:32 +01:00
Dmitry Stogov 15f713bd85 Persist class name before methods, because it may be used insted of "self" 2021-02-15 12:33:53 +03:00
Max Semenik 1f3f7c4374 CI: add --depth 1 to git clone for speed
Closes GH-6690.
2021-02-15 09:49:50 +01:00
David CARLIER 2b93ae601a Use VM_MAKE_TAG for macos memory tag
In case Apple changes the meaning of the macro in the future.

Closes GH-6687.
2021-02-15 09:48:04 +01:00
Max Semenik b11771271e Remove stray mentions of mbstring.func_overload
This feature has been completely removed.

Closes GH-6688.
2021-02-15 09:47:28 +01:00
Christopher Jones 843198eb84 Fix failures due to new deprecations 2021-02-15 12:17:46 +11:00
Máté Kocsis 5b5bfd6be4 Generate class entries from stubs for phar, posix, pspell, readline, reflection, session, shmop
Closes GH-6692
2021-02-15 00:11:22 +01:00
Máté Kocsis af56982a5e Generate class entries from stubs for oci8, odbc, openssl, pcntl, pdo, pgsql
Closes GH-6691
2021-02-14 23:19:21 +01:00
Máté Kocsis 6ce70447ac Generate zend class entries based on stubs
Closes GH-6685
2021-02-14 23:18:28 +01:00
Máté Kocsis 31088eef45 Enable class entry generation for sapi extensions 2021-02-14 12:03:48 +01:00
Tyson Andre 8ffc20ace6 Optimize Traversable unpacking in zend_vm_def.h
The C compiler sees that a dynamic function is being called, so it cannot infer
that iter->funcs has not changed.

This results in more assembly instructions and slightly more time to execute that code
path.

Unpacking traversables to arrays(`ZEND_ADD_ARRAY_UNPACK`),
starting foreach loops (`ZEND_FE_FETCH*`), etc. are affected.

```
<?php
/*
 * Before: 1.576 seconds
 * After:  1.474 seconds
 */
function example() {
    $start = hrtime(true);
    $it = new SplFixedArray(1000);
    $total = 0;
    for ($i = 0; $i < 100000; $i++) {
        $total += count([...$it]);
    }
    $end = hrtime(true);
    printf("Elapsed: %.6f\n", ($end - $start) / 1_000_000_000);
}
example();
```
2021-02-13 09:34:48 -05:00
Nikita Popov f74a02d263 Revert "Implement fetching TLS TCB offset on MacOS"
This reverts commit 1106ff9a0e.

Looks like this sauses segfaults on MacOs ZTS with JIT.
2021-02-12 15:16:05 +01:00
Nikita Popov b10416a652 Deprecate passing null to non-nullable arg of internal function
This deprecates passing null to non-nullable scale arguments of
internal functions, with the eventual goal of making the behavior
consistent with userland functions, where null is never accepted
for non-nullable arguments.

This change is expected to cause quite a lot of fallout. In most
cases, calling code should be adjusted to avoid passing null. In
some cases, PHP should be adjusted to make some function arguments
nullable. I have already fixed a number of functions before landing
this, but feel free to file a bug if you encounter a function that
doesn't accept null, but probably should. (The rule of thumb for
this to be applicable is that the function must have special behavior
for 0 or "", which is distinct from the natural behavior of the
parameter.)

RFC: https://wiki.php.net/rfc/deprecate_null_to_scalar_internal_arg

Closes GH-6475.
2021-02-11 21:46:13 +01:00
Nikita Popov f06895488a Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80718
2021-02-11 16:50:14 +01:00
Nikita Popov f0b387d1e4 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80719
2021-02-11 16:14:12 +01:00
David Carlier 1106ff9a0e Implement fetching TLS TCB offset on MacOS
Tested with php-cgi and wordpress and 1255 for jit settings.

Closes GH-6659.
2021-02-11 15:48:20 +01:00
Nikita Popov 070e24d7a9 Allow all scalar types in ini_set()
This changes ini_set() to accept all scalar types
(string|int|float|bool|null) for the new value. The idea here is
that while the INI system ultimately works with strings, its value
interpretation is designed to be consistent with PHP's casting rules,
e.g. "1" and "" are interpreted as boolean true and false respectively.

I personally believe that writing ini_set('precision', 10) makes more
sense than ini_set('precision', '10'), and find strict_types to be
unnecessarily pedantic here.

Closes GH-6680.
2021-02-11 15:01:16 +01:00
Dmitry Stogov dcf389228c Avoid useless SHM data duplication 2021-02-11 16:51:08 +03:00
Tyson Andre 808da26a33 Fix typo in warnings_during_sccp
Should be capture_warnings_during_sccp

Related to 4c088c5da7
2021-02-11 08:23:01 -05:00
Levi Morrison 18f9d6bb7e Sort some decls in spl_iterators.h
There are enough of them that sorting makes it a bit nicer.
2021-02-11 05:11:11 -07:00
Nikita Popov 4c088c5da7 Handle warnings during sccp function evaluation
Some upcoming changes like https://wiki.php.net/rfc/deprecate_null_to_scalar_internal_arg
will make it somewhat inconvenient to determine whether a given
function invocation will generate a diagnostic. Rather than trying
to exclude this in advance, call the function with diagnostics
suppressed, and check whether anything was thrown.

This adds a new EG flag that is kept specific to the SCCP use-case.
This does not use the error_cb hook as it is a (non-TLS) global,
and doesn't fully suppress error handling besides.

Test this by removing the in advance checks for implode and array_flip.
2021-02-11 12:36:35 +01:00
Nikita Popov 4224b704b1 Merge branch 'PHP-8.0'
* PHP-8.0:
  Update func info after password_get_info() change
2021-02-11 11:44:36 +01:00
Nikita Popov bfbac70ec5 Merge branch 'PHP-8.0'
* PHP-8.0:
  Don't return null from password_get_info()
2021-02-11 10:23:09 +01:00
Max Semenik 0d3ab673aa run-tests: fix JUnit counts
In 19680f886f, I forgot about my own TODO. At least, now I understand what
this line was about :P
2021-02-11 09:47:56 +01:00
Nikita Popov e396506cd6 Merge branch 'PHP-8.0'
* PHP-8.0:
  Don't throw additional Error in require_once if exception already thrown
2021-02-11 09:42:05 +01:00
Dmitry Stogov e1fda1025c Link unbound simple classes (without parent/intefaces/traits) in first place. 2021-02-10 23:57:50 +03:00
Dmitry Stogov b113f7e88e Unserialize op_array->scope before passing to zend_file_cache_unserialize_type().
Don't use scope of closures.
2021-02-10 23:55:59 +03:00
Dmitry Stogov ef51648185 Use zend_type.ce_cache__ptr for caching class resulution during argument/result type checks 2021-02-10 18:00:00 +03:00
Dmitry Stogov a8f6d44c1c Fixed map_ptr slot sharing for trait/self 2021-02-10 17:59:11 +03:00
Nikita Popov 1cd33d83db Merge branch 'PHP-8.0'
* PHP-8.0:
  Make mysqli_ssl_set() arguments nullable
2021-02-10 15:33:25 +01:00
Dmitry Stogov 6aea64c444 Reuse single map_ptr slot for indentical class names 2021-02-10 15:22:09 +03:00
Nikita Popov 89c55afeb5 Merge branch 'PHP-8.0'
* PHP-8.0:
  Make finfo_open() $magic_database nullable
2021-02-10 12:21:15 +01:00
Nikita Popov 6cef8508b4 Merge branch 'PHP-8.0'
* PHP-8.0:
  Don't pass null action to __doRequest
2021-02-10 12:04:05 +01:00
Nikita Popov 35b2426e21 Merge branch 'PHP-8.0'
* PHP-8.0:
  Clarify that location is required in do_request
  Regenerate arginfo file
2021-02-10 11:19:15 +01:00
Nikita Popov dd64928f38 Merge branch 'PHP-8.0'
* PHP-8.0:
  Accept null $location in SoapClient::__setLocation()
2021-02-10 10:52:28 +01:00
Nikita Popov 8e7b476d40 Merge branch 'PHP-8.0'
* PHP-8.0:
  Make SoapVar arguments nullable
2021-02-10 10:37:53 +01:00
Máté Kocsis 8f4146fd2a Merge branch 'PHP-8.0' 2021-02-09 22:44:45 +01:00
Tyson Andre d9510342ee Optimize ZEND_COUNT opcodes on arrays in the jit
Avoid the overhead of a call and checking types
when the argument is definitely an array.
Avoid the overhead of gc when `__destruct` won't get called.

This seemed cheap enough to check for in the jit.

Because of https://wiki.php.net/rfc/restrict_globals_usage
we can be sure in the ZEND_COUNT handler that the array count does not have to
be recomputed in php 8.1.

The below example took 0.854 seconds before the optimization,
and 0.564 seconds after the optimization, giving the same result

```php
<?php
/** @jit */
function bench_count(int $n): int {
    $total = 0;
    $arr = [];
    for ($i = 0; $i < $n; $i++) {
        $arr[] = $i;
        $total += count($arr);
    }
    return $total;
}

function main() {
    $n = 1000;
    $iterations = 50000;
    $start = microtime(true);
    $result = 0;
    for ($i = 0; $i < $iterations; $i++) {
        $result += bench_count($n);
    }
    $elapsed = microtime(true) - $start;

    printf("Total for n=%d, iterations=%d = %d, elapsed=%.3f\n", $n, $iterations, $result, $elapsed);
}
main();
```

Before

```asm
mov $0x7feb8cf8a858, %r15
mov $ZEND_COUNT_SPEC_CV_UNUSED_HANDLER, %rax
call *%rax
```

After

```asm
mov 0x70(%r14), %rdi - Copy the count from the `zend_array*` pointer
mov %rdi, (%rax)     - Store the count in the destination's value
mov $0x4, 0x8(%rax)  - Store IS_LONG(4) in the destination's type
```

And add tracing jit support

Closes GH-5584
2021-02-09 16:09:32 -05:00
Dmitry Stogov c098952d72 Use IS_ALIAS_PTR to make distinct between aliasses and real classes 2021-02-10 00:00:55 +03:00
Dmitry Stogov 4b79dba932 Added Inheritance Cache.
This is a new transparent technology that eliminates overhead of PHP class inheritance.

PHP  classes are compiled and cached (by opcahce) separately, however their "linking" was done at run-time - on each request. The process of "linking" may involve a number of compatibility checks and borrowing methods/properties/constants form parent and traits. This takes significant time, but the result is the same on each request.

Inheritance Cache performs "linking" for unique set of all the depending classes (parent, interfaces, traits, property types, method types involved into compatibility checks) once and stores result in opcache shared memory. As a part of the this patch, I removed limitations for immutable classes (unresolved constants, typed properties and covariant type checks). So now all classes stored in opcache are "immutable". They may be lazily loaded into process memory, if necessary, but this usually occurs just once (on first linking).

The patch shows 8% improvement on Symphony "Hello World" app.
2021-02-09 22:53:57 +03:00
Nikita Popov 550aee0be3 Merge branch 'PHP-8.0'
* PHP-8.0:
  Properly check imagegd() signature
  Make imagegd $file parameter nullable
2021-02-09 15:19:56 +01:00
Nikita Popov 9d54609a19 Merge branch 'PHP-8.0'
* PHP-8.0:
  Use E_ERROR to report arginfo/zpp mismatch
  Make NumberFormatter ctor $pattern nullable
  Make IntlDateFormatter ctor $pattern nullable
2021-02-09 14:37:41 +01:00
Máté Kocsis 8c14675217 Remove a few more unnecessary @generate-function-entries annotations 2021-02-09 13:37:54 +01:00
Máté Kocsis c6723728df Generate ext/intl class entries from stubs
Closes GH-6670
2021-02-09 13:37:24 +01:00
Máté Kocsis 99b08ac281 Implicitly enable function entry generation when class entry generation is enabled
Closes GH-6675
2021-02-09 13:37:24 +01:00
Nikita Popov ccc70ec5d4 Merge branch 'PHP-8.0'
* PHP-8.0:
  Make Phar $fileNotFoundScript nullable
2021-02-09 12:57:58 +01:00
Nikita Popov e32d5e8fe7 Merge branch 'PHP-8.0'
* PHP-8.0:
  Make createDocument() $namespace nullable
2021-02-09 12:29:50 +01:00
Nikita Popov cfb94b22d5 Merge branch 'PHP-8.0'
* PHP-8.0:
  Make getElementsByTagNameNS $namespace nullable
2021-02-09 12:20:56 +01:00
Nikita Popov 27cd7a11cb Add support for string keys in array unpacking
This adds support for:

    $array1 = ['a' => 1, 'b' => 2];
    $array2 = ['b' => 3, 'c' => 4];
    $array = [...$array1, ...$array2];
    // => ['a' => 1, 'b' => 3, 'c' => 4]

RFC: https://wiki.php.net/rfc/array_unpacking_string_keys

Closes GH-6584.
2021-02-09 10:04:27 +01:00
George Peter Banyard 3fbd3d2e2f Remove usage of float keys in arrays
Also make test output not produce trailling whitespaces

Closes GH-6662
2021-02-09 02:55:54 +00:00
Christoph M. Becker 23bb95639f Merge branch 'PHP-8.0'
* PHP-8.0:
  Avoid C4090 level 1 warning
2021-02-08 23:13:19 +01:00
Máté Kocsis 98fb565c74 Generate class entries from stubs for another batch of extensions
Closes GH-6669
2021-02-08 19:53:55 +01:00
Christoph M. Becker 882b418a01 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix locale dependent parsing of PostgreSQL version number
2021-02-08 19:01:42 +01:00
Christoph M. Becker 050214b1f1 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #80706: mail(): Headers after Bcc headers may be ignored
2021-02-08 18:44:20 +01:00
Max Semenik 19680f886f run-tests.php: move JUnit stuff into a class
This is part one of my work that was announced at
https://externals.io/message/110391

Closes GH-6671.
2021-02-08 18:28:11 +01:00
Nikita Popov 99a1bc0881 Skip two gettext tests under --repeat
gettext leaks global state across requests, so don't repeat these
tests. See also GH-6641.
2021-02-08 09:49:33 +01:00
Nikita Popov 8be1cd6671 Merge branch 'PHP-8.0'
* PHP-8.0:
  Restore Laravel test workaround
2021-02-07 18:02:58 +01:00
Tyson Andre f28970126e Merge remote-tracking branch 'php.net/PHP-8.0'
Conflicts:
	ext/zend_test/test.c
	ext/zend_test/test.stub.php
	ext/zend_test/test_arginfo.h
2021-02-06 14:17:50 -05:00
Tyson Andre b4c6d5f799 Properly render 2+ namespaces functions in build/gen_stub.php
Affects both INIT_NS_CLASS_ENTRY and ZEND_NS_FE

Add test cases of the global function and namespaced values

Closes GH-6664
2021-02-06 14:09:25 -05:00
Christoph M. Becker 320843fe7b Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix test expectation for PHP 8.0
  Use ST_Y() instead of the deprecated/removed Y() in test
2021-02-05 14:55:45 +01:00
Christoph M. Becker 3b08b422a7 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #74779: x() and y() truncating floats to integers
2021-02-05 13:12:30 +01:00
Nikita Popov ce79d9476c Merge branch 'PHP-8.0'
* PHP-8.0:
  Try SIGTERM before SIGKILL in opcache restart
2021-02-04 17:07:39 +01:00
Nikita Popov 8786625e1e Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix CLI server worker support
2021-02-04 15:24:20 +01:00
Christoph M. Becker 286f63809c [ci skip] Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix newly introduced compiler warning
2021-02-03 12:46:00 +01:00
David Gebler 7d7fe25003 Add IL compat flag to Windows builds
Enabled by default; use `--disable-vs-link-compat` to disable.

Closes GH-6658.
2021-02-03 11:43:38 +01:00
Christoph M. Becker 8b21e4e951 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #53467: Phar cannot compress large archives
2021-02-03 11:25:02 +01:00
Máté Kocsis 5f21062054 Generate class entries for a few extensions
Relates to GH-6644
2021-02-03 09:24:09 +01:00
Benjamin Eberlei c5f4c3dddb [ci-skip] Merge branch 'PHP-8.0' 2021-02-02 20:30:30 +01:00
Christoph M. Becker 70df89eafb [ci skip] Merge branch 'PHP-8.0'
* PHP-8.0:
  7.3.28 is next
2021-02-02 17:11:42 +01:00
Nikita Popov d281cd8b4b Merge branch 'PHP-8.0'
* PHP-8.0:
  Update year to 2021
2021-02-02 16:47:03 +01:00
Nikita Popov e591cc7575 Merge branch 'PHP-8.0'
* PHP-8.0:
  Remove unnecessary cast in snmp_set_oid_output_format
2021-02-02 16:44:12 +01:00
Nikita Popov 8c00c919e3 Merge branch 'PHP-8.0'
* PHP-8.0:
  Add missing derefs in CurlFile
2021-02-02 10:32:25 +01:00
Nikita Popov 9576a2ad1e Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix persistent leak on load_wsdl_ex failure
2021-02-02 10:07:19 +01:00
Christoph M. Becker 4939d72ca3 Merge branch 'PHP-8.0'
* PHP-8.0:
  Revert "Updated to version 2021.1 (2021a)"
2021-02-01 13:44:42 +01:00
Christoph M. Becker eea4aac1a0 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #80654: file_get_contents() maxlen fails above (2**31)-1 bytes
2021-02-01 13:01:27 +01:00
Levi MorrisonandNikita Popov 32dd853624 Document .dtor_obj and .free_obj
Closes GH-6656.

Co-authored-by: Nikita Popov <nikic@php.net>
2021-02-01 10:53:36 +01:00
twosee 23a7b0f323 Fix environment variable not work in run-tests.php
Closes GH-6657.
2021-02-01 17:27:19 +08:00
David CARLIER 559fc46b9f Fix ubsan warning on macos
Closes GH-6652.
2021-02-01 10:25:00 +01:00
Nikita Popov a53e360d98 Merge branch 'PHP-8.0'
* PHP-8.0:
  XFAIL observer_error_05.phpt test
2021-02-01 10:24:18 +01:00
Nikita Popov 866e3e03de Create .php and .sh on valgrind failure 2021-02-01 10:10:09 +01:00
Nikita Popov 495a522b28 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix Laravel build on community job
2021-02-01 09:49:19 +01:00
Nikita Popov 800685e2f9 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix build
  crc32 mac build fix
2021-02-01 09:46:39 +01:00
Stanislav Malyshev f2994786f3 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix bug #80672 - Null Dereference in SoapClient
2021-02-01 00:17:02 -08:00
Christoph M. Becker 042e0d89bd Merge branch 'PHP-8.0'
* PHP-8.0:
  Add missing stub for SodiumException
2021-01-28 23:26:26 +01:00
Remi Collet 88c339465e Merge branch 'PHP-8.0'
* PHP-8.0:
  NEWS
  NEWS
  Fix #80682 opcache doesn't honour pcre.jit option
2021-01-28 16:27:00 +01:00
Dmitry Stogov c83cbc52a0 Remove useless zend_update_class_constants() calls 2021-01-28 16:38:36 +03:00
Nikita Popov 83be073abe Move optimizer into core
This only moves the files, adjusts the build system, exports APIs
and does minor fixups to make sure the code builds.

This does not yet try to make the optimizer usable independently
of opcache.

Closes GH-6642.
2021-01-28 10:38:25 +01:00
Nikita Popov ac561f2c25 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix stub for Serializable::serialize()
2021-01-28 10:15:45 +01:00
Nikita Popov 6971c720b0 Merge branch 'PHP-8.0'
* PHP-8.0:
  Observe fake closures
2021-01-28 10:05:51 +01:00
Stanislav Malyshev 23961ef382 Merge branch 'PHP-8.0'
* PHP-8.0:
  Rm unneeded function
2021-01-27 00:19:21 -08:00
Stanislav Malyshev 3a35c5eacd Merge branch 'PHP-8.0'
* PHP-8.0:
  Rm unneeded function
2021-01-27 00:15:50 -08:00
Stanislav Malyshev 7eff4057de Merge branch 'PHP-8.0'
* PHP-8.0:
  Alternative fix for bug 77423
2021-01-26 23:01:40 -08:00
Dmitry Stogov b6bfb27b8e Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed observer API and JIT compatibility
2021-01-26 21:31:51 +03:00
Christoph M. Becker f8be72a58c Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #70091: Phar does not mark UTF-8 filenames in ZIP archives
2021-01-26 19:15:56 +01:00
Christoph M. Becker 5185df00d6 Merge branch 'PHP-8.0'
* PHP-8.0:
  Update version
2021-01-26 19:10:04 +01:00
Dmitry Stogov 1d2fd57c99 Merge branch 'PHP-8.0'
* PHP-8.0:
  Allow observer handlers disabling optimization in RETURN opcode handler, that may cause loss value of returned local variable.
2021-01-26 19:25:50 +03:00
Nikita Popov 26f573840f Remove unused mmap member in phpdbg_file_source 2021-01-26 17:11:06 +01:00
Dmitry Stogov 9948142e50 Merge branch 'PHP-8.0'
* PHP-8.0:
  Skip dummy frames allocated on CPU stack of zend_call_function(). (Usage of "current_observed_frame" varible looks unsafe to me).
2021-01-26 18:44:56 +03:00
Nikita Popov b3189e7dad Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix VAR return type verification
2021-01-26 15:18:04 +01:00
Nikita Popov 0368dc9f28 Fix proptable canonicalization bypass in ArrayObject
When an ArrayObject wraps an object, we should be using the
proptable canonicalilzation rules, which require all keys to be
strings.
2021-01-26 14:05:41 +01:00
Nikita Popov 776726da03 Add missing resource key warning for unset()
It was present on other operations, including isset(), but was
missing for unset().
2021-01-26 12:51:02 +01:00
Máté KocsisandNikita Popov 1954e59758 Add support for generating class entries from stubs
Closes GH-6289

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
2021-01-26 11:50:36 +01:00
David CARLIER 4414fd93d0 Distinguishing opcache SHM on stats tools for Mac
Closes GH-6628.
2021-01-26 10:51:33 +01:00
Christoph M. Becker 5a0e4067b6 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #75850: Unclear error message wrt. __halt_compiler() w/o semicolon
2021-01-25 18:49:50 +01:00
Nikita Popov 6bc97b5921 Merge branch 'PHP-8.0'
* PHP-8.0:
  Improve switch continue warning
2021-01-25 16:18:11 +01:00
Nikita Popov c8f809fcff Remove unnecessary TRUE/FALSE defines in tidy
Instead use standard true/false.
2021-01-25 15:54:15 +01:00
Christoph M. Becker 9343ff1ceb Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #53251: bindtextdomain with null dir doesn't return old value
2021-01-25 15:44:44 +01:00
Nikita Popov 7571edc398 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix opcache phpize build on FreeBSD
  Updated to version 2021.1 (2021a)
2021-01-25 15:11:56 +01:00
tzmfreedom a8dd009f23 Allow specifying sqlite3 DSN (file:/) in PDO SQLite
Closes GH-6610.
2021-01-25 14:44:56 +01:00
Nikita Popov cc3e03c512 Fix parsing of semi-reserved tokens at offset > 4 GB
To avoid increasing the size of parser stack elements by storing
size_t offset and length, this instead only stores the start
offset (or rather pointer now) and determines the length of the
identifier in zend_lex_tstring.
2021-01-25 14:37:36 +01:00
Derick Rethans b67409e3d2 Updated to version 2021.1 (2021a) 2021-01-25 10:44:07 +00:00
Derick Rethans 951204bc13 Empty merge 2021-01-25 10:44:07 +00:00
Nikita Popov 321bd6b1f4 Improve error message for leading comma in keyed list assignment
Print "Cannot use empty array entries in keyed array assignment"
instead of "Cannot mix keyed and unkeyed array entries in assignments"
for a leading comma.
2021-01-25 11:13:37 +01:00
Nikita Popov 4846913946 Disable jit in observer opline test
This test fails in --repeat mode with tracing JIT.
2021-01-25 10:41:34 +01:00
Darek Slusarczyk ed24f0f201 Fix #80330: Replace language in APIs and source code/docs
Rename MYSQLI_REFRESH_SLAVE to MYSQLI_REFRESH_REPLICA in line with
upstream change in MySQL. The old name is retained for
backwards-compatibility reasons, and may be deprecated/removed in
the future.

Closes GH-6632.
2021-01-25 10:10:47 +01:00
Tyson Andre 71301f5baf Add documentation of array_is_list() to UPGRADING 2021-01-24 16:24:33 -05:00
Christoph M. Becker 34041e6c57 Merge branch 'PHP-8.0'
* PHP-8.0:
  Add missing stub for SNMPException
2021-01-24 17:58:51 +01:00
Christoph M. Becker 062a891be7 Merge branch 'PHP-8.0'
* PHP-8.0:
  Add missing stub for com_exception
2021-01-24 16:07:34 +01:00
Christoph M. Becker 0374943a0b Merge branch 'PHP-8.0'
* PHP-8.0:
  Add missing SKIPIF clause for recently introduced test case
2021-01-21 17:30:26 +01:00
Nikita Popov 3370b5fd87 Accept zend_string in zend_prepare_string_for_scanning 2021-01-21 10:31:32 +01:00
Dmitry Stogov ba89dcb75a Fixed crash in ZTS build with --repeat option 2021-01-21 11:39:13 +03:00
DuskandTyson Andre 13c430b1db Add array_is_list(array $array) function
This function tests if an array contains only sequential integer keys. While
list isn't an official type, this usage is consistent with the community usage
of "list" as an annotation type, cf.
https://psalm.dev/docs/annotating_code/type_syntax/array_types/#lists

Rebased and modified version of #4886

- Use .stub.php files
- Add opcache constant evaluation when argument is a constant
- Change from is_list(mixed $value) to array_is_list(array $array)

RFC: https://wiki.php.net/rfc/is_list

Co-Authored-By: Tyson Andre <tysonandre775@hotmail.com>
Co-Authored-By: Dusk <dusk@woofle.net>

Closes GH-6070
2021-01-20 18:53:48 -05:00
Christoph M. Becker 04db2c8735 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #80648: Fix for bug 79296 should be based on runtime version
2021-01-20 16:25:08 +01:00
Christoph M. Becker a48d9ede08 Merge branch 'PHP-8.0'
* PHP-8.0:
  Add missing SKIPIF clauses to new test cases
2021-01-20 11:05:39 +01:00
Nikita Popov 32cf58f7ba Merge branch 'PHP-8.0'
* PHP-8.0:
  Skip preloading test on windows
2021-01-20 10:09:46 +01:00
Dmitry Stogov 378f870d7c Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80634 (write_property handler of internal classes is skipped on preloaded JITted code)
2021-01-20 11:04:30 +03:00
Alex Dowad d8c785b894 Update 'East Asian Width' table to comply with Unicode 13.0
Instead of manually maintaining the data in eaw_table.h, it is now automatically
generated by ucgendat/ucgendat.php, using the EastAsianWidth.txt file from
the Unicode Consortium.

Something must be said about the deleted test case. Back in 2004, someone
noticed that `mb_strwidth` didn't comply with Unicode 4.0. A test case was
added to expose the problem. Well, time keeps moving on, and with the changing
years, new Unicodes are born and old Unicodes die. Some characters which were
counted as double-width in Unicode 4.0 are no longer such in Unicode 13.0,
which renders the test case obsolete.

At the same time, make a couple of spelling/grammar fixes in ucgendat.php.
2021-01-19 20:38:44 +02:00
Gabriel Caruso 28fa0b6365 Merge branch 'PHP-8.0' 2021-01-19 13:15:58 -03:00
Gabriel Caruso f65fea0a24 Merge branch 'PHP-8.0' 2021-01-19 12:33:59 -03:00
George Peter Banyard ef36de1317 Use zend_string_equals() in PDO
Closes GH-6623
2021-01-19 15:11:21 +00:00
Derick Rethans 6bc7f62b95 Merge branch 'PHP-8.0' 2021-01-19 14:59:29 +00:00
Nikita Popov dbe5725ff3 Rename zend-test to zend_test
The extension name should match the name of the ext/ directory,
otherwise it will not get picked up by run-tests. It would be possible
to remap this in run-tests, but I think it's better to rename the
extension to follow the standard format. Other extensions also
use underscore instead of hyphen (e.g. pdo_mysql and not pdo-mysql).
Of course, the ./configure option remains hyphenated.

Closes GH-6613.
2021-01-19 15:28:15 +01:00
Nikita Popov d1fe9ae05f Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix observer tests on Windows
2021-01-19 15:27:38 +01:00
Nikita Popov 8c3d279cb3 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80644: ResourceBundle::get() doesn't reset error state
2021-01-19 15:21:09 +01:00
George Peter Banyard a6e8ebf99a Use standard C99 64bits int types
Closes GH-6622
2021-01-19 13:44:36 +00:00
George Peter Banyard b44e29f843 php_pdo_register_driver() might fail
Therefore correctly report failure in MINIT for the drivers which didn't.
2021-01-19 12:55:07 +00:00
George Peter Banyard 424b4802d2 Remove unnecessary (char*) casts
The functions accepts a const char*
2021-01-19 12:40:50 +00:00
George Peter Banyard a78aea8948 Refactor PDO's last inserted ID handler to use and return zend_string
Closes GH-6617
2021-01-19 11:54:25 +00:00
George Peter Banyard 94ea8e247b Refactor PDO doer handler to use zend_string 2021-01-19 11:42:39 +00:00
Nikita Popov 9be0ee4309 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #42560
2021-01-19 11:44:49 +01:00
Christoph M. Becker a4992cbf66 Merge branch 'PHP-8.0'
* PHP-8.0:
  ldap_search() and friends can return array
2021-01-19 10:35:35 +01:00
Christoph M. Becker e1a1918f26 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #69279: Compressed ZIP Phar extractTo() creates garbage files
2021-01-19 10:31:06 +01:00
Nikita Popov e422ab2af7 Merge branch 'PHP-8.0'
* PHP-8.0:
  Keep JIT region executable under ZTS
2021-01-19 10:28:42 +01:00
Nikita Popov 29cf59895a Merge branch 'PHP-8.0'
* PHP-8.0:
  Observe unused return values in JIT
2021-01-19 10:10:08 +01:00
Nikita Popov 64a4128c16 Merge branch 'PHP-8.0'
* PHP-8.0:
  Disable opcache optimizations during some observer tests
2021-01-19 10:03:28 +01:00
Dmitry Stogov b3bbb8fe3b Mark classes cached by opcache by ZEND_ACC_CACHED flag and prevent useless copying and desrpoying of immutable data. 2021-01-19 11:55:09 +03:00
Dmitry Stogov c195fcd678 Avoid modification of trait info 2021-01-19 11:54:01 +03:00
sj-i 6a1e74eb32 Delete an outdated comment for read_property and read_dimension. [ci skip]
The comment is outdated as of PHP7.
For example, in the current code, zend_assign_op_overloaded_property() expects the refcount of the returned value from read_property to be greater than 0 when the returned value is a refcounted, to call zval_ptr_dtor() later.

History:
- The same description was originally written in a commit in 2004 alongside the write side. https://github.com/php/php-src/commit/c8c0e979826b677de5f786920289056242ea5c54
- One requested to put the description in somewhere. https://externals.io/message/7789
- Then it was added as a comment in zend_object_handler.h . https://github.com/php/php-src/commit/7d3215d33321173c58db4d86b7398e16c5c55d13
- At the time the comment was written, there were at least three places where the code actually set the reference count to 0 in read_properties.
	- https://github.com/php/php-src/blob/7d3215d33321173c58db4d86b7398e16c5c55d13/ext/dom/php_dom.c#L229
	- https://github.com/php/php-src/blob/7d3215d33321173c58db4d86b7398e16c5c55d13/ext/mysqli/mysqli.c#L190
	- https://github.com/php/php-src/blob/7d3215d33321173c58db4d86b7398e16c5c55d13/ext/simplexml/simplexml.c#L245
- All three of the above were removed during the development of PHP 7.
	- https://github.com/php/php-src/commit/2f0a758fbbf39ff8684d167f86c708cc361db782
	- https://github.com/php/php-src/commit/2402d6cbbc5e04362b23b183f9129a8db230bcce
	- https://github.com/php/php-src/commit/a975c7e0fe95a94c119eb1c8e519b2357aa50dcc
- In the current code, even when they generate and return a refcounted value, its refcount would be 1.

Closes GH-6618.
2021-01-19 09:49:39 +01:00
Nikita Popov a9efcb1561 gen_stub: Also verify implementation-alias
This makes --verify also check @implementation-alias. Failures are
ignored using @no-verify instead. Some mistakes have been made that
would have been caught by this...

Closes GH-6615.
2021-01-19 09:48:33 +01:00
Nikita Popov d340be0d32 Merge branch 'PHP-8.0'
* PHP-8.0:
  SplFileObject::fgets() cannot return false
2021-01-18 16:47:47 +01:00
Nikita Popov f0d6151918 gen_stub: Don't use $aliasMap during verification
Some functions have multiple aliases, while the $aliasMap can
only record one.

Methodsynopsis generation probably shouldn't use it either, but
at least that case seems to only be interested in whether there
is an alias at all.
2021-01-18 16:04:14 +01:00
Nikita Popov 2b677aaa34 Merge branch 'PHP-8.0'
* PHP-8.0:
  Sync gzgets signature with fgets
2021-01-18 15:47:31 +01:00
Craig Francis 50eca61f68 Use ENT_QUOTES|ENT_SUBSTITUTE default for HTML encoding and decoding functions
htmlspecialchars() etc now use ENT_QUOTES | ENT_SUBSTITUTE rather
than ENT_COMPAT by default.

Closes GH-6583.
2021-01-18 15:45:28 +01:00
Nikita Popov 496e4741a3 gen_stub: Compare phpdoc return type in --verify 2021-01-18 14:41:53 +01:00
Nikita Popov 49e030d551 Merge branch 'PHP-8.0'
* PHP-8.0:
  Sync datefmt_get_calendar_object signature
  Sync intlcal_create_instance() and IntlCalendar::createInstance()
  Sync date_diff and DateTime::diff return type
2021-01-18 14:39:51 +01:00
Nikita Popov 0f26f9b340 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix parameter name of PharData::getMetadata()
2021-01-18 14:16:33 +01:00
Nikita Popov 85bfa2243a gen_stub: Allow additional text after @return
In case the stub file also contains documentation.
2021-01-18 13:13:32 +01:00
Nikita Popov 43d5cef448 gen_stub: Automatically add function name to exceptions
This makes sure that it's present even on exceptions from deeper
down the stack, where we can't add it manually.
2021-01-18 13:13:32 +01:00
Nikita Popov 37aaf2ffff Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix stub for Phar::setStub()
2021-01-18 13:01:01 +01:00
Christoph M. Becker d0e3fb495f Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #80595: Resetting POSTFIELDS to empty array breaks request
2021-01-18 11:01:39 +01:00
David Carlier ebca8deaaf posix: adding freebsd specific rlimit constants
Respectively number of kqueues, pty limits per user.

Closes GH-6608.
2021-01-18 10:44:21 +01:00
Nikita Popov 35dece02bb Remove redundant posix_getrlimit_basic.phpt
It is identical to posix_getrlimit.phpt, apart from one extra
message being printed.
2021-01-18 10:41:07 +01:00
Nikita Popov e8a0ae186f Fix memsize check for xxh32
Copy-paste mistake: The memsize limit for xxh32 should be 16,
rather than 32 (which is correct for xxh64).

Probably fixes oss-fuzz #29661.
2021-01-18 10:35:01 +01:00
Nikita Popov 9862296d46 Fix $GLOBALS[] in isset and unset
I've previously addressed the case of assignments, but the same
issue exists for isset and unset.

Fixes oss-fuzz #29699.
2021-01-18 10:31:38 +01:00
David CARLIER a3e55286a6 hrtime implementation update for Mac
Using a more modern and simpler api available since Sierra (2016).

Closes GH-6609.
2021-01-18 10:01:21 +01:00
Ayesh Karunaratne 3dad63b5b2 Curl: Add CURLOPT_DOH_URL option
From libcurl version 7.62.0 and later, it supports DNS-over-HTTPS with
[`CURLOPT_DOH_URL`](https://curl.se/libcurl/c/CURLOPT_DOH_URL.html) option.
This adds integration with the `CURLOPT_DOH_URL` option if libcurl version
is >= 7.62.0 (0x073E00).

For reference, Ubuntu 20.04+ `libcurl4-openssl-dev`-based PHP builds use Curl 7.68.

Closes GH-6612.
2021-01-18 10:00:31 +01:00
Anatol Belski 2d0dd4d08f NEWS: Fix typo [ci skip]
Signed-off-by: Anatol Belski <ab@php.net>
2021-01-17 18:21:19 +01:00
Tyson Andre 81d20d003c Skip bug77423 if filter extension is unavailable. 2021-01-17 10:44:45 -05:00
Alex Dowad a06c20a17c Remove useless constant MBFL_ENCTYPE_MBCS
This flag indicated that an encoding was 'multi-byte'; it can use a variable
number of bytes to encode each character. As it turns out, we don't actually
need to check this flag anywhere, so it's better to remove it.
2021-01-15 21:55:41 +02:00
Alex Dowad 6cbeb6476e Remove unused macros from mbfilter_cp51932.c, mbfilter_iso2022jp_mobile.c 2021-01-15 21:55:41 +02:00
Alex Dowad 34ece40872 Remove useless mbstring encoding 'JIS-ms'
MicroSoft invented three encodings very similar to ISO-2022-JP/JIS7/JIS8, called
CP50220, CP50221, and CP50222. All three are supported by mbstring.

Since these encodings are very similar, some code can be shared. Actually,
conversion of CP50220/1/2 to Unicode is exactly the same operation; it's when
converting from Unicode to CP50220/1/2 that some small differences arise in how
certain katakana are handled.

The most important common code was a function called `mbfl_filt_wchar_jis_ms`.
The `jis_ms` part doubtless refers to the fact that these encodings are modified
versions of 'JIS' invented by 'MS'. mbstring also went a step further and exported
'JIS-ms' to userland as a separate encoding from CP50220/1/2. If users requested
'JIS-ms' conversion, they got something like CP50220/1/2, minus their special
ways of handling half-width katakana when converting from Unicode.

But... that 'encoding' is not something which actually exists in the world outside
of mbstring. CP50220/1/2 do exist in MicroSoft software, but not 'JIS-ms'.

For a text encoding conversion library, inventing new variant encodings and
implementing them is not very productive. Our interest is in handling text
encodings which real people actually use for... you know, storing actual text
and things like that.
2021-01-15 21:55:41 +02:00
Alex Dowad fcbe45de10 Remove useless mbstring encoding 'CP50220-raw'
CP50220 is a variant of ISO-2022-JP invented by MicroSoft, which handles some
Unicode characters which are not representable in ISO-2022-JP by converting
them to similar characters which are representable.

What, then, is CP50220-raw? An Internet search turns up absolutely nothing.
Reference works which I consulted don't say anything about it. Other text
conversion libraries don't support it.

From looking at the code: It's just the same as CP50220, but it accepts
unmapped JIS X 0208 characters passed through from other Japanese encodings
and silently encodes them using the usual ISO-2022-JP escape sequence and
representation for JIS X 0208 characters.

It's hard to see how this could be useful. OK, let me come out and say it:
it's _not_ useful. We can confidently jettison this (mis)feature.
2021-01-15 21:55:41 +02:00
Alex Dowad 888f5d7729 CP5022{0,1,2}: treat truncated multibyte characters as error 2021-01-15 21:55:41 +02:00
Alex Dowad 2a93a8bb8c Add test suite for CP5022{0,1,2} 2021-01-15 21:55:41 +02:00
Nikita Popov cebdad4b53 Protect against buffer overflow in xxhash unserialization
We need to make sure that memsize is < 32 bytes.

Fixes oss-fuzz #29538.
2021-01-15 17:29:33 +01:00
Nikita Popov 141c4be70a Limit unserialization element count more aggressively
This is slightly more aggressive about rejecting obviously incorrect
element counts. Previously the number of elements was allowed to
match the number of characters. Now it is the number of characters
divided by two (this can actually be increased further to at least 4).

This doesn't really matter in the grand scheme of things (as it
just cuts maximum memory usage by half), but should fix
oss-fuzz #29356.
2021-01-15 17:07:51 +01:00
Nikita Popov 21562aa98d Check for append to $GLOBALS
Fixes oss-fuzz #29389.
2021-01-15 16:58:31 +01:00
Nikita Popov 3e01f5afb1 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.
2021-01-15 12:33:06 +01:00
Nikita Popov e2c8ab7c33 Print "interned" instead of fake refcount in debug_zval_dump()
debug_zval_dump() currently prints refcount 1 for interned strings
and arrays, which does not really reflect the truth. These values
are not refcounted, so the refcount is misleading. Instead print
an "interned" tag.

Closes GH-6598.
2021-01-15 12:21:24 +01:00
Nikita Popov 869221cfb6 Build PDO OCI and OCI8 on azure
The extensions are build as shared to only check that they compile,
without running tests. The OCI8 extension does not properly SKIPIF
no database is available.

It should be noted that if we do want to also test these, then
(apart from running a database) it will also be necessary to configure
with LIBS="-Wl,--disable-new-dtags" in order to force the use of RPATH
instead of RUNPATH, the latter of which does not affect dlopened
libraries. Using LD_LIBRARY_PATH does not mesh well with our test
suite.

Closes GH-6604.
2021-01-15 12:12:13 +01:00
Nikita Popov daa420a0da Fix misleading indentation warning in pdo_oci 2021-01-15 11:51:43 +01:00
Nikita Popov 16cf1b915d compare_function() returns zend_result 2021-01-15 11:51:28 +01:00
Nikita Popov 058756b3bb Remove the convert_to_long_base function
This function is unused in php-src, and has somewhat dubious
semantics, especially since we switched convert_to_long to not
use strtol for the base 10 case.

If you want to convert strings from a different base, use
ZEND_STRTOL directly.
2021-01-15 10:43:26 +01:00
Alex Dowad 0ec34da8e0 CP5022{0,1,2}: treat unrecognized escapes as error 2021-01-15 08:30:36 +02:00
Alex Dowad a50607d11d CP5022{0,1,2}: use JISX0201 for U+203E (overline)
Same issue as d497c0e96f addressed for JIS7/JIS8, but for CP5022{0,1,2} this time.
2021-01-15 08:30:30 +02:00
Alex Dowad 5e5243ab65 CP5022{0,1,2}: convert Unicode codepoints in 'user' area (0xE000-E757) correctly
Unicode has a range of 'private' codepoints which individual applications can
use for their own purposes. When they were inventing CP932, MicroSoft mapped
these 'private' or 'user' codepoints to ten new rows added to the JIS X 0208
character table. (JIS X 0208 is based on a 94x94 table; MS used rows 95-114
for private characters.)

`mbfl_filt_conv_wchar_jis_ms` converted these private codepoints to rows 85-94
rather than 95-114. The code included a link to a document on the OpenGroup
web site, dating back to 1996 [1], which proposed mapping private codepoints to
these rows. However, that is not consistent with what mbstring does when
converting CP5022x to Unicode.

There seems to be a dearth of information on CP5022x on the web. However, I
did find one (Japanese-language) page on CP50221, which states that it maps
kuten codes 0x7F21-0x927E to the 'private' Unicode codepoints [2].

As a side note, using rows higher than 95 does seem to defeat one purpose of
using an ISO-2022-JP variant: ISO-2022-JP was specifically designed to be
"7-bit clean", but once you go beyond row 95, the ku codes are 0x80 and up,
so 8 bits are needed.

[1] https://web.archive.org/web/20000229180004/http://www.opengroup.or.jp/jvc/cde/ucs-conv.html
[2] https://www.wdic.org/w/WDIC/Microsoft%20Windows%20Codepage%20%3A%2050221
2021-01-15 08:26:46 +02:00
Alex Dowad 6e9c8386cb CP5022{0,1,2}: convert characters in ku 0x2D (13th row) correctly
Essentially, CP5022{0,1,2} are to CP932 as ISO-2022-JP is to Shift-JIS.
As Shift-JIS and ISO-2022-JP both encode characters from the JIS X 0208 charset,
CP932 and CP5022x both encode characters from JIS X 0208 _plus_ extra characters
added as MicroSoft vendor extensions.

Among the added characters are a number of symbols which MS put in the 13th row
of the 94x94 character table. (In JIS X 0208, that row is empty.)

mbfilter_cp50220x.c had an `if` clause which was intended to handle the
conversion of characters in that 13th row, but it was dead code, as the previous
clause was always true in those cases. The solution is to reverse the order of
those two clauses (just as they already appeared in mbfilter_cp932.c).
2021-01-15 08:26:38 +02:00
Alex Dowad cdd0724291 Stricter handling of erroneous input when converting CP5022{0,1,2} text encoding
Don't allow escape sequences to start in the middle of a multibyte character.
Also, don't silently pass through illegal bytes which appear where the 2nd
byte of a multibyte character should be.
2021-01-15 08:25:44 +02:00
George Peter Banyard eec11c29d7 [skip-ci] Add minimal build instruction for Fedora 2021-01-15 03:50:32 +00:00
Anna Filina df30f09be5 Add test to verify file_get_contents error with folder
Closes GH-6600.
2021-01-14 23:49:26 +01:00
Alex Dowad 4299e2de42 JIS7/JIS8 encoding: treat truncated multibyte characters as error 2021-01-14 22:34:16 +02:00
Alex Dowad b67e358e75 JIS7/JIS8 encoding: handle invalid 2nd byte for Kanji correctly
Previously, in ISO-2022-JP/JIS7/JIS8, if an escape sequence (starting with 0x1B)
appeared where the 2nd byte of a multibyte character should have been, mbstring
would forget all about the truncated multibyte character and happily accept the
escape sequence. However, such sequences are not legal and should be flagged as
errors.

Also, any other illegal bytes appearing where the 2nd byte of a multibyte
character was expected were just passed through quietly to the output. Fix that.

Also add a test suite for both ISO-2022-JP and JIS7/JIS8. (These are extremely
similar encodings; JIS7 and JIS8 are variants of ISO-2022-JP. mbstring's 'JIS'
is actually a combination of JIS7 _and_ JIS8, since the extensions which each
one adds to ISO-2022-JP are disjoint.)
2021-01-14 22:31:31 +02:00
Alex Dowad d497c0e96f JIS7/JIS8 encoding: use JISX0201 for U+203E (overline)
In other legacy Japanese encodings like Shift-JIS, we are now using a specific
JISX 0208 character for the Unicode overline (U+203E). Previously, the single
byte 0x7E was used, but an ASCII 0x7E does not represent an overline, so this
was changed.

However, JIS7/JIS8 can represent characters in the JISX 0201 character set as
well. That character set also includes an overline character, which takes less
bytes to encode than the corresponding JISX 0208 character, so we'll use it.

This is what mbstring had been doing for a long time; but it changed as a
side effect of the recent changes to how U+203E is encoded in Shift-JIS, etc.
So change it back.
2021-01-14 22:26:24 +02:00
Alex Dowad 40384da36a JIS7/JIS8 encoding: treat unrecognized escapes as error 2021-01-14 22:26:24 +02:00
Alex Dowad c11e12ffe0 Add comment explaining why ISO-2022-JP-2004, etc strings end with ESC ( B
These encodings have multiple modes which can be selected via escape sequences.
The default starting mode is ASCII. If a string _ends_ in a different mode, we
emit a 'redundant' escape sequence to switch back to ASCII.

If the resulting string is never concatenated with other strings, that extra
escape sequence serves no purpose. But if the resulting string is concatenated
with other strings of the same encoding, it ensures that the resulting string
will be valid.
2021-01-14 22:26:24 +02:00
Alex Dowad 4b95fdf2ca ISO-2022-JP-2004 conversion: handle invalid characters correctly 2021-01-14 22:26:24 +02:00
Alex Dowad e14bdc041a ISO-2022-JP-2004 conversion: treat unrecognized escapes as error 2021-01-14 22:26:24 +02:00
Alex Dowad 4d65c2a992 ISO-2022-JP-2004 conversion: represent backslash and tilde as ASCII
This issue dates back to some commits I merged recently, which made encodings
like Shift-JIS-2004 use appropriate JIS X 0208 characters to represent
backslashes and tildes, rather than single-byte characters which are used in
those encodings with a different meaning (for example, in these encodings,
0x5C is used for a halfwidth Yen sign, rather than a backslash).

There was an unintended side effect: ISO-2022-JP-2004 was also made to
represent backslashes and tildes using JIS X 0208 characters. However,
ISO-2022-JP explicitly includes ASCII as one of its selectable character sets,
and ISO-2022-JP-2004 is just an extension of ISO-2022-JP. So when converting
text to ISO-2022-JP-2004, we can convert Unicode backslashes and tildes to ASCII
rather than using the corresponding JIS X 0208 characters.
2021-01-14 22:26:24 +02:00
Nikita Popov b429228420 Remove zend_locale_sprintf_double()
This function is unused, and also not particularly useful now that
PHP no longer prints doubles in a locale-sensitive way unless
someone really goes out of their way to force it.
2021-01-14 12:13:34 +01:00
Nikita Popov 422d1665a2 Make convert_to_*_ex simple aliases of convert_to_*
Historically, the _ex variants separated the zval first, if a
conversion was necessary. This distinction no longer makes sense
since PHP 7.

The only difference that was still left is that _ex checked whether
the type is the same first, but the usage of these macros did not
actually distinguish on whether such an inlined check is valuable
or not in a given context.

Also drop the unused convert_to_explicit_type macros.
2021-01-14 12:11:11 +01:00
Nikita Popov 1b2aba285d Remove Z_PARAM separate params where they don't make sense
Separation can only possibly make sense for array parameters
(or something that can contain arrays, like zval parameters). It
never makes sense to separate a bool.

The deref parameters are also of dubious utility, but leaving them
for now.
2021-01-14 11:58:08 +01:00
Nikita Popov ec58a6f1b0 Remove SEPARATE_ZVAL_IF_NOT_REF() macro
This macro hasn't made sense since PHP 7. The correct pattern to
use is ZVAL_DEREF + SEPARATE_ZVAL_NOREF.
2021-01-14 11:08:44 +01:00
Nikita Popov aa51785889 Remove SEPARATE_ARG_IF_REF macro
The name doesn't correspond to what it does at all, and all the
existing usages appear to be unnecessary.

Usage of this macro can be replaced by ZVAL_DEREF + Z_TRY_ADDREF_P.
2021-01-14 10:53:56 +01:00
Nikita Popov cc4a247a5e Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80617: Type narrowing warning in ZEND_TYPE_INIT_CODE
2021-01-14 10:09:16 +01:00
Nikita Popov ad5ae0634d Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80596: Fix anonymous class union typehint errors
2021-01-14 10:04:47 +01:00
sj-i 5a5f0adb2f Fix outdated comment about refcounting in array.c [ci skip]
Originally the reference count was incremented in here.
PHP7 removed the refcounting.
https://github.com/php/php-src/commit/aa8ecbedcb94e9e22e8fd7ffd539377e747153f7#diff-9c1967d7282ea72ecea9d5dae0dab7349a34d48cc7a10ca38ff49a616f628e40L1954

Closes GH-6603.
2021-01-14 09:52:40 +01:00
sj-i 37b94ac38a Fix #51758: delete an outdated comment from zend_object_handler.h [ci skip]
The same description was originally written in a commit in 2004 which fixes a bug in the pre-released simplexml.
https://github.com/php/php-src/commit/c8c0e979826b677de5f786920289056242ea5c54

One requested to put the description in somewhere.
https://externals.io/message/7789

Then it was added as a comment in zend_object_handler.h .
https://github.com/php/php-src/commit/7d3215d33321173c58db4d86b7398e16c5c55d13

At the time of the comment written, the refcount of RHS was simply incremented before calling the write handler in the process of ZEND_ASSIGN_OBJ.
https://github.com/php/php-src/blob/c8c0e979826b677de5f786920289056242ea5c54/Zend/zend_execute.c#L407

The refcount of a zval may be 0 or 1 if the write handler is called from zend_API in that era.
https://github.com/php/php-src/blob/c8c0e979826b677de5f786920289056242ea5c54/Zend/zend_API.c#L1058-L1170

The original fix in simplexml was removed in 2018, because scalar types don't have reference counter anymore as of PHP7.
https://github.com/php/php-src/commit/f7f790fcc9d57bcd0b6d356994c67ec746a5ac23
https://github.com/php/php-src/commit/4a475a4976db92e71949786cdf5990c61514261e

It seems that the original intent of this prescription was preventing unintended modification to the RHS and values which share the memory location with the RHS in assignments.

In the first place, it is not usual trying to change the RHS in a write handler, IMHO. I don't think the description makes sense in the current situation about handling of refcount, so I simply delete the whole sentences.

Because write_dimension has no return value, the mentioning about the return value is moved to the comment for write_property only.

Closes GH-6597.
2021-01-14 09:50:00 +01:00
Dmitry Stogov 924ec32426 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80422 (php_opcache.dll crashes when using Apache 2.4 with JIT)
2021-01-14 08:16:50 +03:00
Adam Baratz 4affb585a8 Remove flakiness from tests 2021-01-13 19:39:41 -05:00
Nikita Popov d8b22c56cf Fix INDIRECT elements leaked by SPL __serialize implementations 2021-01-12 15:35:19 +01:00
Dmitry Stogov 1a44599dee Always use CG(arena) for unin type lists 2021-01-12 16:33:38 +03:00
Christoph M. Becker 1a0fa12753 Merge branch 'PHP-8.0'
* PHP-8.0:
  socket_create_pair() can no longer return NULL
2021-01-12 12:09:13 +01:00
Nikita Popov 13e049ecfd Merge branch 'PHP-8.0'
* PHP-8.0:
  Use arc4random_buf on macOS
2021-01-12 10:43:18 +01:00
Nikita Popov 45a4d07dd0 Merge branch 'PHP-8.0'
* PHP-8.0:
  Add support for union types for internal functions
2021-01-12 10:15:13 +01:00
Nikita Popov a69da19c6b Merge branch 'PHP-8.0'
* PHP-8.0:
  Use ephemeral port in socket_create_listen_used.phpt
2021-01-12 10:09:38 +01:00
Nikita Popov 1f6a3e603b Remove unused bind_hash member
The last usage has been removed in aa16aee51c,
so drop the member as well.
2021-01-12 09:52:58 +01:00
Nikita Popov 700c2189e1 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80545
2021-01-12 09:50:54 +01:00
Dmitry Stogov aa16aee51c Cleanup:
- ZCG(bind_hash) is not used anymore
- zend_accel_function_hash_copy() and zend_accel_function_hash_copy_from_shm() are the same
- zend_accel_class_hash_copy() and zend_accel_class_hash_copy_from_shm() are almost the same
2021-01-12 08:54:09 +03:00
Adam Baratz b569698095 Add MSSQL setup to Azure Pipelines build 2021-01-11 21:46:41 -05:00
Dmitry Stogov 65c789148b PHP array cannot refer to EG(symbol_table) any more. Replace corresponding checks by ZEND_ASSERT(). 2021-01-11 19:26:08 +03:00
Christoph M. Becker 91eb9a1383 Merge branch 'PHP-8.0'
* PHP-8.0:
  Revert fix for bug 76813 and re2c version bump
2021-01-11 17:21:42 +01:00
Dmitry Stogov 9fc11762e5 PHP array cannot refer to EG(symbol_table) any more. Replace corresponding checks by ZEND_ASSERT(). 2021-01-11 18:26:01 +03:00
Nikita Popov 3b542021e4 Fuzzer: Gracefully handle hashes that cannot be serialized 2021-01-11 15:45:43 +01:00
Christoph M. Becker c7fe18aca6 Merge branch 'PHP-8.0'
* PHP-8.0:
  Revert "Fix #76813: Access violation near NULL on source operand"
2021-01-11 13:22:37 +01:00
Dmitry Stogov c6b2b3b1b5 Merge branch 'PHP-8.0'
* PHP-8.0:
  Add guard if lvalue of assignment may be a reference, but wasn't a reference during recording
2021-01-11 15:13:32 +03:00
Dmitry Stogov d9e441be42 Better CPU registers usage 2021-01-11 14:40:30 +03:00
Dmitry Stogov 59401aa2ef Remove redundand IS_INDIRECT checks (they were necessary for $GLOBALS handling) 2021-01-11 14:39:21 +03:00
Anatol Belski e497a9f241 NEWS: Add xxhash note [ci skip]
Signed-off-by: Anatol Belski <ab@php.net>
2021-01-09 21:51:10 +01:00
Anatol Belski 7703b85428 UPGRADING: Add xxHash notes [ci skip]
Signed-off-by: Anatol Belski <ab@php.net>
2021-01-09 21:50:46 +01:00
Anatol Belski 2cee1be6d1 hash: Use hrtime() in the bench script [ci skip]
Signed-off-by: Anatol Belski <ab@php.net>
2021-01-09 21:41:45 +01:00
Anatol Belski 23590f7c53 hash: Implement xxHash
The implementation bundles the xxHash v0.8.0 release and includes all the variants

- xxh32, 32-bit wide
- xxh64, 64-bit wide
- xxh3, 64-bit wide
- xxh128, 128-bit wide

An initial hash state can be passed through the options arrray. An additional
functionality not targeted in this implementation is the secret support in xxh3
and xxh128. That can be added at a later point.

The serialization for xxh3 and xxh128 should not be implemented, as the
state would contain the secret. Despite the xxHash is a non crypto
algorithm, the secret would be serialized as plain text which would be
insecure.

Closes GH-6524

Signed-off-by: Anatol Belski <ab@php.net>
2021-01-09 19:35:32 +01:00
Shivam Mathur c1391227da Fix pdo_oci - declare quotedlen in oci_driver.c
Closes GH-6590
2021-01-09 04:27:40 +00:00
George Peter Banyard b3c5b8cf24 Merge branch 'PHP-8.0'
* PHP-8.0:
  Rename ``zip_ent`` parameter to ``zip_entry`` for consistency
2021-01-08 22:32:19 +00:00
Nikita Popov 8b2b8563ef Remove some unnecessary zend_delete_global_variable uses 2021-01-08 11:31:31 +01:00
Nikita Popov 792f8fb1b5 Switch name variable to zend_string 2021-01-07 15:53:47 +00:00
Nikita Popov 7aa00369b0 Switch bound_param_map to zend_string 2021-01-07 15:53:47 +00:00
Nikita Popov 1b31a76221 Remove freeq member 2021-01-07 15:53:47 +00:00
George Peter Banyard 848f7e0e07 Refactor PDO placeholder's quoted string to zend_string 2021-01-07 15:53:54 +00:00
George Peter Banyard 63cda0fea8 Refactor PDO's quoter handler to return a zend_string
Closes GH-6547
2021-01-07 15:53:48 +00:00
Tyson Andre df0fa5b178 Clean up remaining opcodes for foreach([] as $x)
Previously, two useless FE_RESET_R and FE_FREE would be left over whether the empty array
was from a literal, a variable, or a class constant.

This doesn't pick up the RESET_RW case due to a weakness in our "may throw"
modeling. (for foreach by reference).

Co-Authored-By: Nikita Popov <nikita.ppv@gmail.com>
using https://gist.github.com/nikic/58d367ad605e10299f5433d2d83a0b5b

Closes GH-4949
2021-01-07 09:43:31 -05:00
Nikita Popov 3460af5262 Fold dirname in sccp for non-windows platforms 2021-01-07 14:27:12 +01:00
Christoph M. Becker c5812389b8 Merge branch 'PHP-8.0'
* PHP-8.0:
  Avoid modifying the return value of readline_completion_function()
2021-01-07 13:49:02 +01:00
Nikita Popov 7b2c098f87 Merge branch 'PHP-8.0'
* PHP-8.0:
  Make fetch_* OO same as func
2021-01-06 15:03:28 +01:00
Nikita Popov 63263abff8 Remove unnecessary INDIRECT checks in JIT helpers 2021-01-06 14:28:17 +01:00
Christoph M. Becker f4bff315bd Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #80592: all floats are the same in ODBC parameters
2021-01-06 13:56:15 +01:00
Nikita Popov 26fc4bea44 Remove some INDIRECT handling in standard library 2021-01-06 12:46:31 +01:00
Nikita Popov 22793884b6 Remove some INDIRECT handling in VM 2021-01-06 12:46:31 +01:00
Nikita Popov 3c68f38fda Restrict allowed usages of $GLOBALS
This restricts allowed usage of $GLOBALS, with the effect that
plain PHP arrays can no longer contain INDIRECT elements.

RFC: https://wiki.php.net/rfc/restrict_globals_usage

Closes GH-6487.
2021-01-06 12:46:24 +01:00
Nikita Popov 73f989a83b Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix/improve mysqli stubs
2021-01-06 11:29:38 +01:00
George Peter Banyard 9052f3b7d2 Update UPGRADIN.INTERNALS 2021-01-06 10:26:37 +00:00
George Peter Banyard 1a58611ae5 Voidify PDO's fetch_error handler 2021-01-06 10:20:57 +00:00
George Peter Banyard 60a61afd3c Boolify PDO's preparer handler 2021-01-06 10:20:57 +00:00
George Peter Banyard 53ba72ec03 Voidify PDO's closer handler 2021-01-06 10:20:57 +00:00
George Peter Banyard 954d3743cc Boolify PDO's quoter handler 2021-01-06 10:21:06 +00:00
George Peter Banyard 43f69160cf Boolify PDO's set_attribute driver function 2021-01-06 10:20:59 +00:00
George Peter Banyard d04adf60be Boolify PDO's transaction handlers
This includes begin(), commit(), rollBack(), and inTransaction()
2021-01-06 10:20:57 +00:00
George Peter Banyard 6728c1bd72 Formalize pdo_dbh_check_liveness_func() return type to zend_result 2021-01-06 10:20:57 +00:00
George Peter Banyard ca5fcb83bf Add/expand comments for PDO handlers 2021-01-06 10:20:57 +00:00
George Peter Banyard 01c8fe8fc0 Convert strcmp() usage to zend_string_equals_literal() 2021-01-06 10:20:57 +00:00
Christoph M. Becker b4269664fa Merge branch 'PHP-8.0'
* PHP-8.0:
  Add missing SKIPIF clause for require_hash.phpt
2021-01-06 11:02:23 +01:00
Christoph M. Becker 555bd2f0ef Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #77565: Incorrect locator detection in ZIP-based phars
2021-01-05 23:46:46 +01:00
Sara Golemon 3d0c905a08 Update instructions regarding web-php/include/version.inc 2021-01-05 15:34:40 +00:00
Christoph M. Becker e9d5169b0b Merge branch 'PHP-8.0'
* PHP-8.0:
  Prevent double-free of Phar ZIP stream
2021-01-05 14:32:04 +01:00
Christoph M. Becker 6fc0f8e933 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix memory leak in Phar::webPhar() on Windows
2021-01-05 14:27:14 +01:00
Nikita Popov 5c3a3dd2aa Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix infinite recursion in unlinked_instanceof
2021-01-05 13:04:00 +01:00
Nikita Popov d29d3a4bf6 Fix use-after-scope in SplObjectStorage::unserialize()
Introduced by the recent switch to a zend_object. Unserialize the
object into a tmp_var to avoid leaving behind a stack reference.

Fixes oss-fuzz #29271.
2021-01-05 12:44:17 +01:00
Nikita Popov 0067c3ced1 Fix lexing of zero octal followed by whitespace
We'd call strtol starting at the whitespace, and strtol strips
whitespace...

Fixes oss-fuzz #29272.
2021-01-05 12:25:19 +01:00
Nikita Popov ed4f18b463 Merge branch 'PHP-8.0'
* PHP-8.0:
  gdbinit: use ____print_str to print htable keys
2021-01-05 10:13:21 +01:00
George Peter Banyard 589bdf30b2 Implement Explicit octal notation for integers RFC
RFC: https://wiki.php.net/rfc/explicit_octal_notation

Add an extensive test suits for other variants of integer literals

Closes GH-6360
2021-01-04 21:09:23 +01:00
Nikita Popov ab9f497b90 Fix curl_getinfo() funcinfo
This can now return any type with any refcount.
2021-01-04 18:57:57 +01:00
Christoph M. Becker 7d30943dc9 Merge branch 'PHP-8.0'
* PHP-8.0:
  [ci skip] Add forgotten NEWS entry (bug 80560)
2021-01-04 18:20:00 +01:00
George Peter Banyard af1b89f36c Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix bug #80584: 0x and 0X are considered valid hex numbers by filter_var()
2021-01-04 18:08:04 +01:00
Christoph M. Becker a8413902b1 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #76929: zip-based phar does not respect phar.require_hash
2021-01-04 17:49:07 +01:00
Nikita Popov 5276ca6179 Manually store CURLOPT_PRIVATE data
This is simpler than going through curl, because we can manage
the memory more easily (in particular, this removes the need for
to_free->str). Additionally this allows the CURLOPT_PRIVATE data
to have any type, instead of being implicitly cast to string.
2021-01-04 16:59:57 +01:00
Nikita Popov 5c21d39d55 Remove method member from php_curl_callback
For these callbacks a non-null callback already indicates that
a user callback should be used. We don't need an additional
member to tell us the same thing.
2021-01-04 16:24:20 +01:00
Nikita Popov ee6cb72dee Remove unused still_running member 2021-01-04 16:24:19 +01:00
Tyson Andre e622e868c7 Reduce memory usage of SplObjectStorage
Track an 8-byte pointer as the key instead of 16-byte zval.
(4 byte on 32-bit builds)

The memory used for a set of 1 million objects decreased from
114 MiB to 106 MiB.

Use the new `Z_PARAM_*` APIs to parse the `zend_object*` pointer directly

Closes GH-6566
2021-01-04 10:20:44 -05:00
Nikita Popov ce2e1076d4 Don't allocate php_curl_handlers separately
Always allocated together with php_curl... no point in that.
2021-01-04 15:59:18 +01:00
Nikita Popov cc11130b38 Don't allocate php_curlm_handlers separately
This is always allocated together with the php_curlm structure,
there's no point in making it a separate allocation.
2021-01-04 15:59:18 +01:00
Tyson Andre 0d99628ac1 Fix edge case serializing __PHP_Incomplete_Class properties.
This was using strcmp instead of zend_string_equals_literal.
As a result, the property count didn't match the number of properties
being serialized if properties started with
"__PHP_Incomplete_Class\0" (unlikely)

(before, `'O:8:"Missing_":1:{}'` would be serialized, which failed to
unserialize)

Everywhere else expects the MAGIC_MEMBER to match exactly,
and this should use zend_string_equals_literal as an example for other code.

This has used strcmp since 2004 in deb84befae

Closes GH-6555
2021-01-04 09:46:54 -05:00
Tyson Andre a25886d163 Optimize SplFixedArray when magic methods aren't overridden
This decreases the memory usage of SplFixedArrays by 32 bytes per object
on 64-bit systems (use 1 null pointer instead of 5 null pointers)
If allocating a lot of arrays of size 1, memory usage was 19.44MiB before this
change, and 16.24MiB after the change.

Existing tests continue to pass.

Subclassing SplFixedArray is already inefficient and rarely done.
It checks for the existence of 5 methods every time a subclass is instantiated.
(and has to switch back from C to the php vm to call those methods)

Closes GH-6552
2021-01-04 09:44:08 -05:00
Nikita Popov 7eed6c0c05 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix newly added GMP test
2021-01-04 15:27:41 +01:00
Nikita Popov 66ffa1c9d2 Use single typedef for curl callbacks
There's no value in making these separate types.
2021-01-04 15:19:01 +01:00
Nikita Popov e69a65a2b5 Export php_getenv() API
This exports a php_getenv() API which will fetch an environment
variable in a thread-safe manner (assuming all other environment
manipulations are thread-safe ... ha ha ha).

Closes GH-6571.
2021-01-04 14:52:07 +01:00
George Peter Banyard 01f7722faa Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix GMP comparison object handler
2021-01-04 14:48:48 +01:00
Nikita Popov 4b544f25ef Merge branch 'PHP-8.0'
* PHP-8.0:
  Try to fix intermittent failures of stream_server_reneg_limit.phpt on macos
2021-01-04 14:33:02 +01:00
Nikita Popov a6eb370d50 Merge branch 'PHP-8.0'
* PHP-8.0:
  Throw ValueError instead of TypeError for malformed GMP number
2021-01-04 14:30:19 +01:00
zeriyoshi 53ee3f7f89 Use php_random_bytes() in mt_srand() and uniqid()
Use php_random_bytes() to generate the MT19937 seed if none is
explicitly given. Also use it to generate more_entry for uniqid().

These changes should not impact user-observable behavior apart
from result statistics.

Closes GH-6520.
2021-01-04 14:20:49 +01:00
Dharman 2f1d32d25c Avoid throwing warnings in mysqlnd
Instead report them as proper client errors.

Closes GH-6530.
2021-01-04 12:31:56 +01:00
Christoph M. Becker 9b269df6af Merge branch 'PHP-8.0'
* PHP-8.0:
  SQLite3::query() cannot return null
2021-01-04 12:16:46 +01:00
Nikita Popov f91ece0d07 Merge branch 'PHP-8.0'
* PHP-8.0:
  Mac M1 crc32 detection support
2021-01-04 11:42:17 +01:00
Nikita Popov faeca51ed3 Merge branch 'PHP-8.0'
* PHP-8.0:
  Disable non-cron travis jobs
2021-01-04 10:55:57 +01:00
Stanislav Malyshev 9a3ea5ffbc Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix test name
  [ci skip] Update NEWS
  [ci skip] Update NEWS
  [ci skip] Fix order
  [ci skip] Unpdate NEWS
  Fix bug #79405 - gethostbyname() silently truncates after a null byte
  Fix #77423: parse_url() will deliver a wrong host to user
  Fix #77423: parse_url() will deliver a wrong host to user
2021-01-04 01:53:54 -08:00
Nikita Popov e54499219f Skip tests under asan
When PDO firebird is loaded and these posix tests are run with
parallelism, LeakSanitizer will occasionally segfault. I was not
able to root cause this issue, as I failed to reproduce it in
simpler circumstances. I don't think it's an issue on our side
though.
2021-01-04 10:45:49 +01:00
Stanislav Malyshev 7daf2d8602 Fix bug #79405 - gethostbyname() silently truncates after a null byte 2021-01-04 01:20:22 -08:00
Christoph M. Becker 5174de7cd3 Fix #77423: parse_url() will deliver a wrong host to user
To avoid that `parse_url()` returns an erroneous host, which would be
valid for `FILTER_VALIDATE_URL`, we make sure that only userinfo which
is valid according to RFC 3986 is treated as such.

For consistency with the existing url parsing code, we use ctype
functions, although that is not necessarily correct.
2021-01-04 01:20:21 -08:00
Remi Collet 9bf43c4590 rename COMPILER and ARCHITECTURE macro (too generic) 2021-01-04 10:13:54 +01:00
Christoph M. Becker b30462bead Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix imap stubs
2021-01-03 16:20:01 +01:00
Christoph M. Becker 533af1eb14 Merge branch 'PHP-8.0'
* PHP-8.0:
  ZipArchive methods do not return NULL
2021-01-03 16:12:24 +01:00
Tyson Andre dfb9e03336 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
2021-01-02 16:10:14 -05:00
Christoph M. Becker 64c753e7c8 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix parameter name
2021-01-01 23:05:09 +01:00
Christoph M. Becker d017b3e1a0 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix build
2021-01-01 17:42:27 +01:00
Máté Kocsis 6f954cc119 Merge branch 'PHP-8.0' 2021-01-01 16:53:16 +01:00
Christoph M. Becker e8e0d52d36 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix ReflectionClass::getConstants() stub
2021-01-01 14:47:10 +01:00
Christoph M. Becker 68afd0c99c Merge branch 'PHP-8.0'
* PHP-8.0:
  [ci skip] Fix pgsql constant names in UPGRADING
2020-12-31 00:30:49 +01:00
Máté Kocsis dc4d8400b4 Merge branch 'PHP-8.0' 2020-12-30 18:28:33 +01:00
Christoph M. Becker 35333bd1c6 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #80560: Strings containing only a base prefix return 0 object
2020-12-30 12:50:39 +01:00
George Peter Banyard 6c3b69bd7b Remove superfluous return statement. 2020-12-29 16:55:19 +01:00
Tyson Andre f29dcc168a Remove redundant check in SplObjectStorage->count 2020-12-29 10:16:21 -05:00
Dmitry Stogov 984df80e27 Merge branch 'PHP-8.0'
* PHP-8.0:
  Initialize EX(call)->func by single instruction
  Reuse value stored in %r0 instead of immediate operand
2020-12-29 13:21:06 +03:00
Christoph M. Becker 0e7bae6afa Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix ffi stubs
2020-12-28 19:05:32 +01:00
Máté Kocsis 74e39ce06c Merge branch 'PHP-8.0' 2020-12-28 14:46:00 +01:00
Christoph M. Becker e4e318bad3 Merge branch 'PHP-8.0'
* PHP-8.0:
  Bump minimum re2c version to 0.13.7
2020-12-28 13:44:00 +01:00
Christoph M. Becker 0b796c33f7 Merge branch 'PHP-8.0'
* PHP-8.0:
  php_formatted_print() throws on failure
2020-12-27 22:41:27 +01:00
Christoph M. Becker 03251f29df Merge branch 'PHP-8.0'
* PHP-8.0:
  Replace sort() function calls with ksort() in basic ksort test
2020-12-27 18:32:29 +01:00
Christoph M. Becker bbae3dd7ff Merge branch 'PHP-8.0'
* PHP-8.0:
  DateTime*::getOffset() no longer returns false as of PHP 8.0.0
2020-12-26 15:13:56 +01:00
Tyson Andre 7edf034080 [skip ci] fix typo in NEWS 2020-12-25 12:27:17 -05:00
Dmitry Stogov 14b5fff632 Merge branch 'PHP-8.0'
* PHP-8.0:
  Eliminate redundand comparison insructions
2020-12-24 16:59:27 +03:00
Máté Kocsis 5638fafa66 Merge branch 'PHP-8.0' 2020-12-24 11:46:10 +01:00
Christopher Jones ec6f6dfcfc Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix PDO_OCI test
2020-12-24 17:48:53 +11:00
Christopher Jones e387e4da0e Fix PDO_OCI build 2020-12-24 17:18:57 +11:00
George Peter Banyard 4935fbe90f Update hash for IMAP stubs after adding final qualifier 2020-12-23 21:56:31 +01:00
Ayesh Karunaratne af68d4aae6 IMAP: Declare IMAPConnection class as final (stub+test)
Updates the `IMAPConnection` class stub to make sure it has the `final` flag, and adds a test to verify it.
2020-12-23 21:21:32 +01:00
Ayesh Karunaratne 7f1659afcb IMAP: Disallow direct new IMAPConnection() construct
Disallows constructing an `IMAPConnection` class directly with `new IMAPConnection` construct, by throwing an `Error` exception if attempted.
`imap_open` is still the only way to create `IMAPConnection` objects.
2020-12-23 21:21:32 +01:00
Christoph M. Becker 4050589302 Merge branch 'PHP-8.0'
* PHP-8.0:
  Add regression test for bug #76770
2020-12-23 16:47:32 +01:00
Christoph M. Becker 89d4b6b790 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #80384: limit read buffer size
2020-12-23 13:53:19 +01:00
Nikita Popov 438b025a28 Support native types in PDO SQLite
Return integers and floats as native types if possible. As usual,
the old behavior can be restored by enabling ATTR_STRINGIFY_FETCHES.

Fixes bug #38334.
2020-12-23 11:25:31 +01:00
Ayesh Karunaratne 012439b78e FTP: Disallow direct FTPConnection construction
Similar to other resource to object migrations, `FTPConnection` class is not allowed to be constructed with `new FTPConnection`.
Related to b4503fbf88.

Closes GH-6533.
2020-12-23 09:54:38 +01:00
George Peter Banyard c6a8f201b1 EXPECTF imap_errors() test's authentication error 2020-12-22 23:14:11 +01:00
George Peter Banyard 7606994356 Make imap_errors() test no hang
Instead of attempting to connect with an invalid password, connect as an anonymous user.
As this is disabled in our Dovecot configuration, this generates an error, and fails fast.
2020-12-22 19:55:30 +01:00
George Peter Banyard a80a029896 Optimize Dovecot configuration for IMAP tests
Closes GH-6531
2020-12-22 19:55:30 +01:00
Nikita Popov caa710037e Rewrite PDO result binding
Instead of requiring the type to be determined in advance by the
describer function and then requiring get_col to return a buffer
of appropriate type, allow get_col to return an arbitrary zval.
See UPGRADING.INTERNALS for a more detailed description of the
change.

This makes the result fetching simpler, more efficient and more
flexible. The general possibility already existed via the special
PDO_PARAM_ZVAL type, but the usage was very inconvenient and/or
inefficient. Now it's possible to easily implement behavior like
"return int if it fits, otherwise string" and to avoid any kind
of complex management of temporary buffers.

This also fixes bug #40913 (our second highest voted bug of all
time, for some reason). PARAM_LOB result bindings will now
consistently return a stream resource, independently of the used
database driver.

I've tried my best to update all PDO drivers for this change, but
some of the changes may be broken, as I cannot test or even build
some of these drivers (in particular PDO dblib and PDO oci).
Fixes are appreciated -- a working CI setup would be even more
appreciated ;)
2020-12-22 15:56:34 +01:00
Nikita Popov 57d69b5137 Don't use explicitly nullable column in bug_73234.phpt
Firebird doesn't support this. It is nullable by default.

The test still fails, but now for a legitimate reason...
2020-12-22 10:34:54 +01:00
Nikita Popov b4ffe54174 Add CONFLICTS file for PDO firebird tests 2020-12-22 10:31:35 +01:00
Nikita Popov 381624818b Fix bug_69356.phpt for firebird
Firebird does not support selecting without a table. Use the same
code we use elsewhere, which adds "FROM DUAL" or "FROM RDS$DATABASE"
as necessary.
2020-12-22 10:26:07 +01:00
Nikita Popov 9294074c09 PDO Firebird: Use recreate table
Firebird does not have "if exists", and the switch to exception
error mode broke the suppressed exec calls.

Firebird does have a "recreate table" command that effective
perform a "drop table if exists" beforehand.
2020-12-22 10:20:41 +01:00
Nikita Popov a9253b0e22 Suppress zend_signals warnings if pdo_firebird loaded 2020-12-22 10:20:41 +01:00
George Peter Banyard 27afc455c3 Add IMAP resource to object conversion to UPGRADING 2020-12-22 03:09:00 +01:00
George Peter Banyard 383779e502 Convert IMAP resource to object
Closes GH-6418
2020-12-22 03:06:35 +01:00
Nikita Popov 694400616e Build PDO Firebird on Azure
Once again, this only builds the driver, all tests will be skipped.

Closes GH-6529.
2020-12-22 00:07:43 +01:00
Nikita Popov 26e0d389bc Show slow SKIPIF sections as well 2020-12-21 22:55:49 +01:00
Nikita Popov cc23fcfca6 PDO Firebird: Fix uninitialized var warning 2020-12-21 21:47:00 +01:00
Nikita Popov 0dfc4e7e41 Build PDO odbc on azure
We already install the necessary libs for the odbc extension, so
we may as well build PDO ODBC.

As we don't setup an ODBC server, the tests will be skipped.

Close GH-6528.
2020-12-21 18:37:45 +01:00
Nikita Popov 737195c3ae PDO: Honor ATTR_STRINGIFY_FETCHES for booleans
Of the important PDO drivers, this affects only PDO PgSQL, as
both MySQL and SQLite do not return native boolean types.
2020-12-21 15:32:32 +01:00
Derick Rethans 5a3c1f61d4 Merge branch 'PHP-8.0' into master 2020-12-21 10:32:17 +00:00
Nikita Popov 442fa318a0 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix bug #80537
2020-12-21 10:23:42 +01:00
Christopher Jones 4c5e47d113 Merge branch 'PHP-8.0'
* PHP-8.0:
  Description typo
2020-12-21 15:47:06 +11:00
Christopher Jones 9af1ad7a95 Merge branch 'PHP-8.0'
* PHP-8.0:
  Bundle PECL OCI8 3.0.1
2020-12-21 15:38:35 +11:00
Christopher Jones f66888f94d Merge branch 'PHP-8.0'
* PHP-8.0:
  Retrofit NEWS
2020-12-21 15:08:40 +11:00
Christoph M. Becker 78bdbfc24a Merge branch 'PHP-8.0'
* PHP-8.0:
  Revert "DateTime:: and DateTimeImmutable::getTimestamp() may return false"
2020-12-20 23:07:34 +01:00
Christoph M. Becker dccaaa956a Merge branch 'PHP-8.0'
* PHP-8.0:
  DateTime:: and DateTimeImmutable::getTimestamp() may return false
2020-12-20 19:32:36 +01:00
Christoph M. Becker b85f0d1cd0 Convert file_info resources to objects
Besides our general desire to get rid of the legacy resource types,
this is particularly appealing for fileinfo, because there are already
respective objects.

Closes GH-5987.
2020-12-20 18:19:22 +01:00
Christoph M. Becker 54c866106e Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix ext/date stubs
2020-12-20 18:14:40 +01:00
Nikita Popov c7cccc1c9a Fix leak 2020-12-18 21:48:21 +01:00
Nikita Popov 7904a087ec Back memory stream by a zend_string
This allows reusing an existing zend_string inside a memory stream
without reallocating. For non-readonly streams, the string will
only get separated on write.
2020-12-18 17:07:07 +01:00
Nikita Popov 9ec6392d80 Remove unused smax member from memory stream 2020-12-18 16:40:23 +01:00
Nikita Popov fd36b089cf Remove unused pdo_pgsql_column member 2020-12-18 15:50:59 +01:00
Nikita Popov bd5ff73c0a Try to fix azure pipelines config
Is this space the problem?
2020-12-18 14:05:52 +01:00
Nikita Popov 7a5cc7aa67 Add basic libmysqlclient CI job
This tests that mysqli and pdo_mysql build against libmysqlclient,
and that tests pass for pdo_mysql. mysqli has too many test failures.

This is not an officially supported configuration.
2020-12-18 12:52:54 +01:00
Nikita Popov 037512cfce Move fetch_all implementation out of mysqlnd
There doesn't seem to be any compelling reason to implement this
in mysqlnd rather than mysqli. It's just a loop over fetch_into.

This makes the function available under libmysqlclient as well,
and thus fixes bug #79372.
2020-12-18 12:27:30 +01:00
Nikita Popov be93e5a120 Make mysqli_stmt_next_result available under libmysql
The libmysqlclient version we require supports mysql_stmt_next_result.
2020-12-18 11:32:41 +01:00
Nikita Popov b88a493aaa PDO MySQL: Make test libmysql compatible 2020-12-18 11:28:15 +01:00
Nikita Popov 9718e5987f Merge branch 'PHP-8.0'
* PHP-8.0:
  PDO MySQL: Handle boolean parameter binding with libmysql
2020-12-18 11:02:36 +01:00
Nikita Popov 4ceea869ee Merge branch 'PHP-8.0'
* PHP-8.0:
  MySQLnd: Support cursors in store/get result
2020-12-18 10:20:55 +01:00
Nikita Popov 73533c7dc9 PDO MySQL: Use correct type when setting INT_AND_FLOAT_NATIVE
mysqlnd expects this to be an unsigned int, not a bool.
2020-12-17 18:50:24 +01:00
Levi Morrison 710f3985c5 Skip invalid file descriptor test on Mac 2020-12-17 09:11:10 -07:00
Nikita Popov 108d1e9a50 MySQLnd: Remove mnd_malloc/free etc.
There were only two uses of non-zmm allocation functions left,
which really did not need to use the system allocator. Remove
them, and remove the system allocator based APIs.
2020-12-17 17:01:09 +01:00
Nikita Popov 8898c1e75c MySQLnd: Fix potential leak when reading cursor
Perform the same checkpointing twe do in other row reading
functions.
2020-12-17 16:14:17 +01:00
Nikita Popov 1144b85b82 MySQLnd: Avoid some reallocations in PS decoder 2020-12-17 14:41:47 +01:00
hgsgtk 003d9ba125 Fix typo 'pices' in strings/join_basic.phpt
Closes GH-6519.
2020-12-17 14:19:05 +01:00
Nikita Popov c18b1aea28 PDO MySQL: Use native types for results
Previously, PDO MySQL only fetched data as native int/float if
native prepared statements were used. This patch updates PDO to
have the same behavior for emulated prepared statements, and thus
removes the largest remaining discrepancy between these two modes.

Note that PDO already has a ATTR_STRINGIFY_FETCHES option to control
whether native types are desired or not. The previous output can
be restored by enabling this option.

Most of the tests make use of that option, because this allows the
tests to work under libmysqlclient as well, which currently always
returns string results (independently of whether native or emulated
PS are used).
2020-12-17 10:54:34 +01:00
Nikita Popov 33e904915e MySQLnd: Clean up and optimize mysqlnd result set handling
This is a larger overhaul of the mysqlnd result set infrastructure:

 * Drop support for two different types of buffered results sets
   ("c" and "zval"). Possibly these made sense at some earlier
   time, but now (with minor adjustments) one option is strictly
   worse than the other. Buffered result sets already buffer the
   full row packets, from which zvals can be decoded. The "zval"
   style additionally also buffered the decoded zvals. As result
   sets, even buffered ones, are generally only traversed once,
   this just ends up wasting memory. Now, a potentially useful
   variation here would be to buffer the decoded zvals instead of
   the row packets, but that's not what the code was doing.
 * To make it really strictly better, pre-allocate the zval row
   buffer and reuse it for all rows. Previously the "c" style always
   allocated a new buffer for each row.
 * The fetch_row API now provides a populated zval[]. The task of
   populating an array is deferred to fetch_row_into, which also
   avoids duplicating this code in multiple places. The fetch_row_c
   API is also implemented on top of fetch_row now, rather than
   duplicating large parts of the code.
 * The row fetching code for prepared statements and normal result
   sets has been mostly merged. These already used the same
   infrastructure, but prepared statements used separate row
   fetching functions that were nearly the same as the normal ones.
   This requires passing the stmt into the result set, rather than
   just a flag. The only part that remains separate is reading of
   unbuffered results in the presence of PS cursors.
2020-12-17 10:15:02 +01:00
Nikita Popov 890e4caf0b Drop support for max_length in mysqli_fetch_fields()
Retain the field, but always populate it with zero. This was
already the case for PS without length updating.

max_length has nothing lost in the field metadata -- it is a
property of the specific result set, and requires scanning the
whole result set to compute. PHP itself never uses max_length
with mysqlnd, it is only exposed in the raw mysqli API.

Keeping it for just that purpose is not worthwhile given the costs
involved. People who actually need this for some reason can easily
calculate it themselves, while making it obvious that the
calculation requires a full result set scan.
2020-12-17 10:01:02 +01:00
Levi Morrison 95a4e1ea3b Fix ubsan error on Mac
Fixes this error:
> Zend/zend_alloc.c:473:73: runtime error: left shift of 250 by 24 places cannot be represented in type 'int'
2020-12-16 21:24:31 -07:00
Christoph M. Becker 58d459f1ef Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #80521: Parameters with underscores no longer recognized
2020-12-16 20:06:01 +01:00
Nikita Popov bc4140d7a8 Merge branch 'PHP-8.0'
* PHP-8.0:
  Detect overlarge step for character range()
2020-12-16 17:02:20 +01:00
Nikita Popov 52435f94a3 Merge branch 'PHP-8.0'
* PHP-8.0:
  PDO MySQL: Use mysqlnd column names
2020-12-16 15:18:43 +01:00
Nikita Popov 1c29db19d4 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #67983
2020-12-16 10:54:36 +01:00
Nikita Popov 8bd5310a1e Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix bug #80523
2020-12-16 10:20:57 +01:00
Nikita Popov cfe2b36a6d Fix ATTR_ORACLE_NULLS with PARAM_ZVAL
PARAM_ZVAL with a STR result should be treated the same way as
PARAM_STR in this regard.
2020-12-15 17:12:46 +01:00
Derick Rethans f66f2b2b4f Merge branch 'PHP-8.0' 2020-12-15 14:13:55 +00:00
Gabriel Caruso 1314ae65e2 Merge branch 'PHP-8.0' 2020-12-15 11:05:19 -03:00
Gabriel Caruso 82af0ea73d Merge branch 'PHP-8.0' 2020-12-15 10:33:28 -03:00
Nikita Popov 806465892e MySQLnd: Drop free_result_internal
Merge it into free_result. There is a large number of different
free_* functions for result sets, let's avoid having one more.
Only difference is that it does not increment stats, and that
seems like a bug as free_stmt_result is still freeing a result.
2020-12-15 12:35:58 +01:00
Dmitry Stogov 6c05b33e84 Merge branch 'PHP-8.0'
* PHP-8.0:
  Optimize out result value of ASSIGN, ASSIGN_OP and INC/DEC opcodes, if possible.
2020-12-15 14:34:21 +03:00
Nikita Popov 6bda0c14f5 MySQLnd: Simplify management of zval row buffer
Something odd was being done here, with the row packet having a
flag for whether it should allocate the zval buffer, which would
then get moved into the result set.

Keep the management of this buffer purely at the result set level.
This also allows us to easily reuse the same buffer for all results,
rather than allocating a new one for each fetch.
2020-12-15 12:00:05 +01:00
Christoph M. Becker 6b37cdda66 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #77322: PharData::addEmptyDir('/') Possible integer overflow
2020-12-15 11:46:46 +01:00
Christoph M. Becker 6e2614ef6c Merge branch 'PHP-8.0'
* PHP-8.0:
  7.3.27 is next
2020-12-15 11:32:43 +01:00
Nikita Popov 362c29241d Remove mysqlnd_extension enum
ext/mysql is no longer supported, drop handling for it from
mysqlnd.
2020-12-15 10:55:53 +01:00
Nikita Popov be4f73f328 MySQLnd: Remove unused fetch_field_data method
This method is not used, and is implemented in a very dubious
way.
2020-12-15 10:47:39 +01:00
Levi Morrison 36ff92e6fb Remove very old -no-cpp-precomp compatibility flag on Mac
Closes GH-6501.
2020-12-15 10:19:26 +01:00
Nikita Popov 0896f36bc6 Merge branch 'PHP-8.0'
* PHP-8.0:
  JIT: Update invalid opcache.jit INI value message to include "tracing" and "function" values
2020-12-15 10:18:54 +01:00
Nikita Popov 3642042629 Merge branch 'PHP-8.0'
* PHP-8.0:
  IBM i PASE doesn't support ITIMER_PROF
2020-12-15 10:15:52 +01:00
jellyNoone c1e977f1bb Add more tests that document late static binding
Closes GH-6515.
2020-12-15 10:04:39 +01:00
Nikita Popov f9942b061d Merge branch 'PHP-8.0'
* PHP-8.0:
  JIT disabled build fix.
2020-12-15 09:51:51 +01:00
Christoph M. Becker b59156ca8c Merge branch 'PHP-8.0'
* PHP-8.0:
  Add Windows support for OCI 19
2020-12-14 23:14:31 +01:00
Christoph M. Becker 5263fffdbf Merge branch 'PHP-8.0'
* PHP-8.0:
  Drop pdo_mysql_prepare_load_data.phpt
2020-12-14 18:28:29 +01:00
Nikita Popov 3c63b26b6d Use zmm for row_c data
This API already doesn't match libmysqlclient, so we may as well
use the zmm.
2020-12-14 13:43:30 +01:00
Dmitry Stogov f1e2cd8625 Merge branch 'PHP-8.0'
* PHP-8.0:
  Remove unused flag
2020-12-14 15:29:34 +03:00
Dmitry Stogov c3c7b673d1 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80506 (Immediate SIGSEGV upon ini_set("opcache.jit_debug", 1))
2020-12-14 15:28:27 +03:00
Nikita Popov 7088cffe8a mysqlnd_error_info_init() cannot fail 2020-12-14 12:31:45 +01:00
Nikita Popov 35d752f4fc Remove more OOM checks 2020-12-14 12:28:26 +01:00
Nikita Popov 141eb346b0 Remove MYSQLND_STRING_TO_INT_CONVERSION define
This has been unconditionally enabled for a long time already
(the actual conversion is behind an additional runtime flag).
2020-12-14 12:03:43 +01:00
Nikita Popov 5d9bd14ccc MySQLnd: Remove some unnecessary allocator failure checks
emalloc/pemalloc are infallible.
2020-12-14 11:58:43 +01:00
Nikita Popov 86e317ad80 MySQLnd: Remove fail thresholds from infallible allocators
emalloc() etc are infallibe by design. Having a failure threshold
for them is a violation of the API contract.
2020-12-14 11:51:30 +01:00
Nikita Popov 2d51c203f0 PDO: Store/pass query_string as zend_string
Rather than storing char* + size_t, use a zend_string*. Also
avoid various copies of the query string.
2020-12-14 10:43:28 +01:00
Nikita Popov c288b5294b Fix compile warnings in PDO Firebird 2020-12-14 10:36:36 +01:00
Nikita Popov f2ddfcc7bb Fix MHANDLEFUNC signature
The last parameter is int, not short int.
2020-12-14 10:25:03 +01:00
Nikita Popov 47fe412518 Allow building dblib with machine-dependent libdir
Use the same approach as for GMP: If no explicit directory is
given, assume it must be on the default include path and libdir.
Otherwise use the provided path. It does not look like libsybdb
has support for pkg-config.
2020-12-14 10:25:03 +01:00
Nikita Popov aa58db7232 Fix signed/unsigned warnings in PDO ODBC
Add add skipif to test.
2020-12-14 10:03:56 +01:00
Christoph M. Becker 2b7eb0e26a Disallow version_compare() $operator abbreviations
`version_compare()` does a sloppy check for the `$operators` argument
which allows arbitrary abbreviations of the supported operators to be
accepted.  This is both undocumented and unexpected, and could lead to
subtle BC breaks, if the order of the comparisions will be changed.
Therefore we change to strict comparisons.

Closes GH-6510.
2020-12-13 23:55:33 +01:00
Anatol Belski 269a8841ae hash: Fix signatures in the final callback defs
Signed-off-by: Anatol Belski <ab@php.net>
2020-12-13 21:17:46 +01:00
Jakub Zelenka 97d2dd0f90 Merge branch 'PHP-8.0' 2020-12-13 18:43:04 +00:00
Anatol Belski ffcc93e3e5 UPGRADING.INTERNALS: Document hash init signature changes [ci skip]
Signed-off-by: Anatol Belski <ab@php.net>
2020-12-13 16:52:01 +01:00
Anatol Belski c6d3c68fb4 UPGRADING: Document algorithm specific hash options [ci skip]
Signed-off-by: Anatol Belski <ab@php.net>
2020-12-13 16:46:32 +01:00
Anatol Belski 110b4e9094 hash: Support custom algo parameters
The concrete need on this change is to support passing an initial seed
to the murmur hash. Passing a custom seed is important in terms of
randomizing the hash function.

The suggested implementation adds a HashTable parameter to all the
init callbacks. Further on, an array with custom arguments is accepted
from `hash` or `hash_init` from the user land. Currently several things
like `hash_hkdf` are not touched, as they don't need passing custom
args.

Some convenience macros have been added to the SHA/MD families of
functions, so the consuming code doesn't have to be changed widely.

Another way to implement this is to add another type of the init that
would accept a HT with arguments. However, that would still require
touching all the context structs in all the algos. That would also
increase the size of those structs. As an init function is called just
once, the way of modifying the existing init callback has been seen
as more preferrable.

Closes GH-6400.

Signed-off-by: Anatol Belski <ab@php.net>
Co-Developed-by: Nikita Popov <nikita.ppv@googlemail.com>
Signed-off-by: Nikita Popov <nikita.ppv@googlemail.com>
Acked-by: Michael Wallner <mike@php.net>
Reviewed-by: Máté Kocsis <kocsismate@woohoolabs.com>
Reviewed-by: Eddie Kohler <ekohler@gmail.com>
2020-12-13 14:14:07 +01:00
Nikita Popov 70c22dec28 Merge branch 'PHP-8.0'
* PHP-8.0:
  Remove bug41347.phpt as the error cases are already tested
2020-12-11 16:47:54 +01:00
Nikita Popov 154f27a998 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #79132
2020-12-11 16:36:07 +01:00
Nikita Popov d5f692296c Merge branch 'PHP-8.0'
* PHP-8.0:
  PDO MySQL: Fix nextRowset() on libmysqlclient with native PS
  PDO MySQL: Don't skip two LOCAL_INFILE tests with libmysqlclient
2020-12-11 14:49:58 +01:00
Nikita Popov 9b5f9084a4 Merge branch 'PHP-8.0'
* PHP-8.0:
  PDO MySQL: Unskip bug_41125.phpt
2020-12-11 14:12:35 +01:00
Nikita Popov d09d930e48 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #67004
2020-12-11 12:56:10 +01:00
Nikita Popov 96ec26ec71 Merge branch 'PHP-8.0'
* PHP-8.0:
  PDO MySQL: Use stmt_next_result with libmysqlclient as well
  PDO MySQL: Fix libmysql option test
2020-12-11 12:21:11 +01:00
Nikita Popov 09cc096357 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #62889
2020-12-11 11:25:56 +01:00
Nikita Popov b4ff7d4e2b Merge branch 'PHP-8.0'
* PHP-8.0:
  PDO MySQL: Fix leak with libmysqlclient and multiple rowsets
2020-12-11 10:53:04 +01:00
Nikita Popov 2d6330dd5e Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix test cases for MariaDB
2020-12-11 09:53:50 +01:00
Nikita Popov 1af2edd105 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #72368
2020-12-10 16:54:52 +01:00
Nikita Popov d6c3b8baab Merge branch 'PHP-8.0'
* PHP-8.0:
  Allow drivers to omit error code
2020-12-10 16:04:48 +01:00
Nikita Popov 786cb68221 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #79131
2020-12-10 15:53:30 +01:00
Dmitry Stogov 6ec7d4c406 Merge branch 'PHP-8.0'
* PHP-8.0:
  Eliminate some repeatable IS_REFERENCE checks
2020-12-10 14:46:03 +03:00
Nikita Popov 16e8c1af68 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #79872 by improving error message
2020-12-10 11:48:49 +01:00
Nikita Popov 207fcb0523 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #76815
2020-12-10 11:24:27 +01:00
Nikita Popov 030845eb68 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #71145
2020-12-10 10:31:43 +01:00
twosee a38aaf6cbd Merge branch 'PHP-8.0'
* PHP-8.0:
  EXTERN_C wrapping for GC buffer APIs
2020-12-10 17:16:08 +08:00
Nikita Popov bbd65c1ac7 Merge branch 'PHP-8.0'
* PHP-8.0:
  Backport fix for bug #70066
2020-12-10 10:05:48 +01:00
Dmitry Stogov d92b001d50 Merge branch 'PHP-8.0'
* PHP-8.0:
  Perform early guard type check for result of FETCH_CONSTANT
2020-12-09 22:25:04 +03:00
hgsgtk 6992c38ecc Fix typo 'variabled' in named_params/undef_var.phpt
Closes GH-6499.
2020-12-09 19:29:07 +01:00
Nikita Popov e268709400 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #70066
2020-12-09 17:25:18 +01:00
Nikita Popov 6b2d28b034 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #66878
2020-12-09 16:38:35 +01:00
Nikita Popov 77a06ccadd Merge branch 'PHP-8.0'
* PHP-8.0:
  Remove unnecessary more_results() checks
  Add ifdef for mysqlnd only function
2020-12-09 16:19:58 +01:00
Nikita Popov f6b22da490 Merge branch 'PHP-8.0'
* PHP-8.0:
  PDO MySQL: Extract common code for handling PS results
  PDO MySQL: Use set_row_count() helper
2020-12-09 15:29:03 +01:00
Dmitry Stogov 974b4429cd Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed IS_32BIT/IS_SIGNED_32BIT mess
2020-12-09 17:17:25 +03:00
Nikita Popov bd096f33b8 Merge branch 'PHP-8.0'
* PHP-8.0:
  PDO MySQL: Make sure nextRowset() works with partially consumed result
2020-12-09 14:51:11 +01:00
Nikita Popov 39d20b474d Merge branch 'PHP-8.0'
* PHP-8.0:
  PDO MySQL: Handle error during closeCursor()
2020-12-09 14:05:54 +01:00
Nikita Popov 7eae14690f Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #78154
2020-12-09 12:47:48 +01:00
Nikita Popov de22980ac8 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix stmt_free_result implementation and usage
  Make XFAILED test less broken
2020-12-09 11:24:48 +01:00
Nikita Popov c77bf40ad9 Merge branch 'PHP-8.0'
* PHP-8.0:
  Handle changing column count in mysqlnd result binding
2020-12-09 10:30:36 +01:00
Nikita Popov dc58a1e6d7 Merge branch 'PHP-8.0'
* PHP-8.0:
  PDO MySQL: Normalize handling of empty stored procedure result set
2020-12-08 17:02:13 +01:00
Nikita Popov 0ac8518d76 Merge branch 'PHP-8.0'
* PHP-8.0:
  Handle column count change in PDO MySQL
2020-12-08 16:42:54 +01:00
Nikita Popov f531b84b13 Merge branch 'PHP-8.0'
* PHP-8.0:
  Enable XFAILed test
2020-12-08 16:04:08 +01:00
Christoph M. Becker 78c0338ba9 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #48725: Support for flushing in zlib stream
2020-12-08 12:25:03 +01:00
Christoph M. Becker 615197ae3d Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #77069: stream filter loses final block of data
2020-12-08 11:49:41 +01:00
Christoph M. Becker 748d553c24 Merge branch 'PHP-8.0'
* PHP-8.0:
  ldap_exop_whoami() does not return TRUE
2020-12-08 11:44:19 +01:00
Nikita Popov c22f1d4551 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #63185
2020-12-08 11:36:03 +01:00
Dmitry Stogov 75d7e606cc Merge branch 'PHP-8.0'
* PHP-8.0:
  Avoid unnecessary checks
2020-12-08 13:11:05 +03:00
Nikita Popov c4f97a100e Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix another typed resource issue in unserialization
2020-12-07 12:36:16 +01:00
Dmitry Stogov b9ee87583b Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80480 (Segmentation fault with JIT enabled)
2020-12-07 13:29:11 +03:00
Christoph M. Becker c9f3cf89f3 Clarify and assert that printf() and friends never return NULL
Closes GH-6491.
2020-12-06 23:33:53 +01:00
Nikita Popov 8bb7417ca2 Increase timeout on msan job
[ci skip]
2020-12-05 10:38:57 +01:00
Nikita Popov 89bbaf505a Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80458
2020-12-04 17:01:19 +01:00
Christoph M. Becker 7adc3e8d88 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #75102: `PharData` says invalid checksum for valid tar
2020-12-04 13:05:08 +01:00
Nikita Popov 174832902c Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix removal of type source during unserialization
2020-12-04 12:57:37 +01:00
Christoph M. Becker 8591bb70a4 Return early from php_search_array() 2020-12-04 01:17:26 +01:00
George Peter Banyard fec771db87 Merge branch 'PHP-8.0'
* PHP-8.0:
  Standardize behaviour for int message number between functions
  Add tests for passing a UID instead of a message number
2020-12-03 17:44:47 +00:00
Nikita Popov 97338ba853 Merge branch 'PHP-8.0'
* PHP-8.0:
  Upload coverage data to codecov.io
2020-12-03 12:05:19 +01:00
Nikita Popov a5dea658bf Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix mysqli_expire_password test for mariadb
2020-12-03 11:02:16 +01:00
Nikita Popov c0ea8363a6 Merge branch 'PHP-8.0'
* PHP-8.0:
  fix mysqli_stmt_get_result_metadata_fetch_field test for mariadb
2020-12-03 10:45:32 +01:00
Nikita Popov aff9a850a1 Merge branch 'PHP-8.0'
* PHP-8.0:
  Remove PHP 5 mysqli tests
  Fix typos in mysql tests
2020-12-03 10:43:16 +01:00
Nikita Popov 52d3666863 Merge branch 'PHP-8.0'
* PHP-8.0:
  Backport fix for bug #78750
2020-12-03 10:22:27 +01:00
Nikita Popov 15a33bc1e0 Merge branch 'PHP-8.0'
* PHP-8.0:
  Make is_file() and friends return false when path contains 0-byte
2020-12-03 09:45:23 +01:00
Christoph M. Becker 52bd07e204 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix failing VirtualProtect() calls
2020-12-02 16:53:43 +01:00
Nikita Popov 0040e59999 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80457
2020-12-02 11:29:56 +01:00
Nikita Popov bfa4f8188d Don't disable phpdbg on macos
I'm not sure what the original issue here was, but it seems to
be working fine now, so let's make sure it stays that way...
2020-12-02 11:04:08 +01:00
Nikita Popov fef08723c1 Ensure consistent error message in phpdbg parser
This would be either $end or "end of file" depending on bison
version. Explicitly specify "end of command" instead, which seems
more appropriate in context.
2020-12-02 11:03:58 +01:00
Nikita Popov ecb1592ea6 Merge branch 'PHP-8.0'
* PHP-8.0:
  Don't throw from imagecreatefromstring() with too short string
2020-12-02 10:55:45 +01:00
Nikita Popov 2dcf71cbfd Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80462
2020-12-02 10:19:42 +01:00
Sara Golemon 1071d85764 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.
2020-12-01 18:36:21 +00:00
George Peter Banyard 0811ccb44d Merge branch 'PHP-8.0'
* PHP-8.0:
  Backport IMAP test modernization to PHP-8.0 branch
2020-12-01 16:39:11 +00:00
Christoph M. Becker 13eee7712e Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #73809: Phar Zip parse crash - mmap fail
2020-12-01 17:00:53 +01:00
Dmitry Stogov f71cc45fb8 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80447 (Strange out of memory error when running with JIT)
2020-12-01 16:47:11 +03:00
Dmitry Stogov 828f6806f3 Merge branch 'PHP-8.0'
* PHP-8.0:
  Bug #80447 (Strange out of memory error when running with JIT)
2020-12-01 16:43:41 +03:00
Nikita Popov b2d7528641 Don't try to open null file
If the loader is not found, directly return null, instead of
trying to open it.
2020-12-01 14:20:36 +01:00
Dmitry Stogov 5b078e7858 Merge branch 'PHP-8.0'
* PHP-8.0:
  Disable stack reuse optimization for x86 PIC code. It may clobber local variable used for Global Offset Table.
2020-12-01 15:26:37 +03:00
Nikita Popov 3b4fb2ebea Determine run-tests executables consistently 2020-12-01 12:36:25 +01:00
Nikita Popov 6fdc988592 Don't pass null to strlen() 2020-12-01 12:36:18 +01:00
Nikita Popov 715d89e166 Merge branch 'PHP-8.0'
* PHP-8.0:
  Don't use scope when validating Attribute
2020-12-01 11:50:22 +01:00
Nikita Popov 1912ff5ccb Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix use after free with file cache and arena allocated strings
2020-12-01 11:32:28 +01:00
codinghuang 3c6ab4b3ea Add const modifier for zend_extension members
Closes GH-6462.
2020-12-01 10:40:26 +01:00
Nikita Popov c034f200aa Merge branch 'PHP-8.0'
* PHP-8.0:
  Don't mark cpu_supports functions as always inline
2020-12-01 10:24:02 +01:00
Dmitry Stogov 3030d4aa12 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed incorrect "skipif.inc" include
2020-12-01 11:34:36 +03:00
Dmitry Stogov c3a6cf01af Merge branch 'PHP-8.0'
* PHP-8.0:
  Skip test if JIT is not available
2020-12-01 09:59:25 +03:00
Anatol Belski 886712b346 hash: Add build dir for ext/hash/murmur
Signed-off-by: Anatol Belski <ab@php.net>
2020-11-30 20:48:37 +01:00
Christoph M. Becker ecb1aa4afe Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #62004: SplFileObject: fgets after seek returns wrong line
2020-11-30 16:04:04 +01:00
Dmitry Stogov e1656bac7d Merge branch 'PHP-8.0'
* PHP-8.0:
  Preallocate stack space for JIT in execute_ex() to eliminate JIT prologue/epilogue.
2020-11-30 17:56:32 +03:00
Dmitry Stogov 68520291af Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed "may be used uninitialized" compilation warnings
2020-11-30 17:47:02 +03:00
Christoph M. Becker 875741b1cf Merge branch 'PHP-8.0'
* PHP-8.0:
  Drop all JIT related XFAILS from phpdbg test suite
2020-11-30 15:24:44 +01:00
Nikita Popov 4ce33486d7 Merge branch 'PHP-8.0'
* PHP-8.0:
  Next attempt to fix bug #80368
2020-11-30 15:17:35 +01:00
George Peter Banyard e42bf726c0 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix Bug #80438: imap_msgno() incorrectly warns and return false on valid UIDs in PHP 8.0.0
  Rename XmlParser to XMLParser for consistency with XMLWriter/XMLReader
2020-11-30 14:08:49 +00:00
Nikita Popov 39c59e084c Merge branch 'PHP-8.0'
* PHP-8.0:
  Suppress stream errors in mysqlnd
2020-11-30 15:06:40 +01:00
Dmitry Stogov a3d0752a0a Merge branch 'PHP-8.0'
* PHP-8.0:
  Hide phpdbg/JIT incompatibility macro (JIT is disabled for phpdbg)
2020-11-30 16:43:04 +03:00
Nikita Popov 8405eaf2cd Merge branch 'PHP-8.0'
* PHP-8.0:
  Add additional entries to unserialize corpus
2020-11-30 14:33:06 +01:00
Nikita Popov 8c2cc0e8fd Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix another ref source management bug in unserialize
2020-11-30 14:24:05 +01:00
Christoph M. Becker de7f3f0bd3 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #76813: Access violation near NULL on source operand
2020-11-30 12:33:44 +01:00
Dmitry Stogov 034270d69a Merge branch 'PHP-8.0'
* PHP-8.0:
  Disable JIT with incompatible third-party extensions
2020-11-30 13:59:33 +03:00
Nikita Popov 48725d89aa Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80437
2020-11-30 11:42:07 +01:00
Nikita Popov 89891d75c3 Merge branch 'PHP-8.0'
* PHP-8.0:
  Only replace IN_ARRAY result type for JMPZ/JMPNZ
2020-11-30 11:19:13 +01:00
Christoph M. Becker ce3ff8ec7d php_tidy_create_node() expects a fixed set of node_types
This static function is not supposed to deal with arbitrary
`node_type`s, so there is no need to do so.

Closes GH-6467.
2020-11-30 10:29:46 +01:00
Nikita Popov 90d5c40e25 Merge branch 'PHP-8.0'
* PHP-8.0:
  Use ephemeral ports in mcast_ipv*_recv.phpt
2020-11-30 09:50:05 +01:00
Christoph M. Becker d838b64c8f Merge branch 'PHP-8.0'
* PHP-8.0:
  tidy::repairFile() and ::repairString() return string|false
2020-11-30 00:29:55 +01:00
Christoph M. Becker b1a30d8ab1 Fix typos in comments 2020-11-28 13:52:46 +01:00
Nikita Popov 236eb60e96 Merge branch 'PHP-8.0'
* PHP-8.0:
  Respect strict_types during sccp function call evaluation
2020-11-27 20:24:25 +01:00
Tyson Andre 74f4586540 Remove duplicate str_split check, fix test expectation 2020-11-27 12:21:54 -05:00
Nikita Popov 99a3dbce81 Merge branch 'PHP-8.0'
* PHP-8.0:
  Don't check for throwing calls in sccp function evaluation
2020-11-27 17:50:48 +01:00
Nikita Popov 30c89166ec Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix handling of sccp exceptions
2020-11-27 17:44:48 +01:00
Jakub Zelenka 4662a8c893 Merge branch 'PHP-8.0' 2020-11-27 16:35:46 +00:00
Nikita Popov 16795a2f83 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix build for non-x86
2020-11-27 17:04:56 +01:00
Nikita Popov 46428a843c Merge branch 'PHP-8.0'
* PHP-8.0:
  Handle exceptions during SCCP function evaluation
2020-11-27 17:01:48 +01:00
Nikita Popov 3459099541 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix AVX detection
2020-11-27 14:49:57 +01:00
Nikita Popov cfde3cd2ae Merge branch 'PHP-8.0'
* PHP-8.0:
  Only use travis for cron jobs
2020-11-27 14:18:35 +01:00
Nikita Popov 497a0e5a0e Merge branch 'PHP-8.0'
* PHP-8.0:
  Make sure zend_cpu_supports_pclmul() is always defined
2020-11-27 12:22:53 +01:00
Christoph M. Becker d39cbfc141 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix mysqli_get_client_stats test
2020-11-27 11:51:50 +01:00
Nikita Popov 9234446ca0 Merge branch 'PHP-8.0'
* PHP-8.0:
  Avoid direct calls to zend_cpu_supports()
  Assert that cpuinfo is initialized before use
  Move avx check into a macro
2020-11-27 11:19:56 +01:00
Nikita Popov d56e255445 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80368
2020-11-27 10:58:40 +01:00
Nikita Popov 877fa6b8a6 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80433
2020-11-27 10:52:21 +01:00
Nikita Popov e7e3debcc9 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80425
2020-11-27 10:03:28 +01:00
Christopher Jones f131234efa Merge branch 'PHP-8.0' into master
* PHP-8.0:
  Update PECL package release date
2020-11-27 10:17:54 +11:00
Christoph M. Becker 0b7c286aed Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix bug number
2020-11-26 23:41:09 +01:00
Dmitry Stogov 0bb559bb24 Merge branch 'PHP-8.0'
* PHP-8.0:
  Eliminate dead stores
2020-11-26 21:05:29 +03:00
Nikita Popov 08006e8337 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix bug #80402: Don't strip -lpthread
2020-11-26 11:56:07 +01:00
Sara Golemon 72484e0fd1 Merge branch 'PHP-8.0'
* PHP-8.0:
  Remove -dev from ZEND_VERSION
2020-11-26 02:20:37 +00:00
Alex Dowad c9fea7db72 Convert U+00AF (MACRON) to 0x8150 (FULLWIDTH MACRON) in some SJIS variants
Except for vanilla Shift-JIS, where 0x7E is a halfwidth overline/macron.
As for Shift-JIS-2004, it has an added character (byte sequence 0x854A)
which was defined as a halfwidth macron in JIS X 0213:2000, so we use that.
2020-11-25 20:51:45 +02:00
Alex Dowad ecf718470b Convert U+FF5E (FULLWIDTH TILDE) to 0x8160 (WAVE DASH) in SJIS variants
By entering this character in the JIS X 0208 conversion table, we can
remove a bunch of explicit `if` clauses in different conversion filters.
It also means that U+FF5E can be converted into SJIS-mac now; I don't
know why this one SJIS variant rejected U+FF5E before, since 0x8160
means the same thing in SJIS-mac as the others.
2020-11-25 20:51:45 +02:00
Alex Dowad 4f3bd2e235 Convert U+203E (OVERLINE) to 0x8150 (FULLWIDTH MACRON) in some SJIS variants
Converting U+203E to 0x7E was especially wrong for CP932, where 0x7E
represents a tilde.

For vanilla Shift-JIS and Shift-JIS-2004, converting to 0x7E is acceptable,
since 0x7E does represent an overline/macron in those encodings.

Follow the same principle in CP51932, which is closely related to CP932.
2020-11-25 20:51:45 +02:00
Alex Dowad 0d0029d729 0x7E is not a tilde in Shift-JIS{,-2004} 2020-11-25 20:51:45 +02:00
Alex Dowad e4ee979111 0x5C is not a Yen sign in CP932 (or CP51932)
When Microsoft created CP932 (their version of Shift-JIS), they explicitly
used bytes 0-0x7F to represent ASCII characters rather than JIS X 0201
characters.

So when converting Unicode to CP932, it is not correct to convert U+00A5
to CP932 0x5C. Fortunately, CP932 does have a multi-byte FULLWIDTH YEN SIGN
character which we can use instead.

CP51932 uses the same extended character set as CP932; while CP932 is
MicroSoft's extended version of Shift-JIS, CP51932 is their extended version
of EUC-JP. So the same reasoning applies to CP51932.
2020-11-25 20:51:45 +02:00
Alex Dowad 315d48b434 0x5C is not a backslash in Shift-JIS-2004
Shift-JIS-2004 is an extension of Shift-JIS, which uses 0x5C for the Yen
sign. Therefore, it is not correct to convert ASCII 0x5C (backslash) to
Shift-JIS-2004 0x5C (yen sign). JIS X 0208 does have a backslash, so we
can convert ASCII backslash to SJIS-2004 backslash instead.

From time immemorial, there has been confusion around the treatment
of 0x5C bytes on systems using legacy Japanese encodings. JIS X 0201
specified that 0x5C means a yen sign, and thus fonts on Japanese systems,
including early versions of Windows, displayed a 0x5C byte as a yen sign.
This meant that when ASCII text files were displayed on such systems,
what were meant to be backslashes would appear as yen signs. Japanese C
programmers could write character escapes using yen signs, and C compilers
built on the assumption that the input was ASCII would interpret these
escapes as desired. Likewise for shell scripts. Et cetera, et cetera...

Therefore, if the input to `mb_convert_encoding` is (for example) a C
program, and after converting to Shift-JIS-2004, the user wishes to feed
the output into a C compiler, *then* perhaps ASCII 0x5C should be mapped
to SJIS 0x5C. However, this scenario is ridiculous and will never happen.

A more realistic scenario might be: an article written in SJIS-2004 has
embedded Windows file paths (like 'C:\Program Files'), with yen signs used
as a path separator. If we convert SJIS-2004 0x5C to ASCII 0x5C, then the
path separators will be 'fixed' by the conversion.

For general written texts, it is much better to convert backslashes to...
backslashes. And yen signs, to yen signs.
2020-11-25 20:51:44 +02:00
Alex Dowad 5c805655db Enhance handling of CP51932 encoding
- Don't pass 'control' characters through in the middle of a multi-byte char
- Treat truncated multi-byte characters as an error
2020-11-25 20:51:44 +02:00
Alex Dowad beef597124 Fix mbstring support for SJIS-Mobile (DoCoMo, KDDI, and Softbank variants of Shift-JIS)
Lots of problems here.

- Don't pass 'control' characters through silently in the middle of a
  multi-byte character.
- Treat it as an error if a multi-byte character is truncated.
- For ESC sequences used to encode emoji on earlier Softbank phones, if an
  invalid ESC sequence is found, don't pass it through. Rather, handle it as
  an error and respect `mb_substitute_character`.
- In ranges used by mobile vendors for emoji, if a certain byte sequence
  doesn't map to any emoji, don't emit a mangled value (actually a raw
  (ku*94)+ten value, which may not even be a valid Unicode codepoint at all).
- When converting Unicode to SJIS-Mobile, don't mangle codepoints which fall
  in the 2nd range of MicroSoft vendor extensions.

Some vendor-specific emoji have been mapped to standard Unicode codepoints
now, rather than 'private use area' codepoints. When the legacy code was
written, these codepoints may not have existed yet in the Unicode standard
which was current at that time.

Also do a major code cleanup -- remove dead code, rearrange what is left,
use some new macros and helper functions to make the code clearer...
2020-11-25 20:51:44 +02:00
Alex Dowad bbbadae0ae Combine MBFL_ENCTYPE_MWC2{BE,LE} constants
These constants indicate that a text encoding uses 2+ bytes for each character,
and is either big endian or little endian (respectively). But nothing in
mbstring cares about the difference between MBFL_ENCTYPE_MWC2BE and
MBFL_ENCTYPE_MWC2LE.

(Actually, nothing cares about whether these flags are set at all...
maybe we should just remove them?)
2020-11-25 19:52:19 +02:00
Alex Dowad 72660c416a Combine MBFL_ENCTYPE_WCS{2,4}{BE,LE} constants
These flags identify text encodings in mbstring which use a constant number of
bytes per character. While some parts of the code do use these flags, usually
to detect cases which can be optimized due to constant-width encoding, nothing
cares whether the encodings are 'LE' (little-endian) or 'BE' (big-endian).

So we can simplify things by combining constants.
2020-11-25 19:52:19 +02:00
Alex Dowad 5ffcf563bd Don't pass invalid JIS X 0212, JIS X 0213, and Windows-CP932 characters through
Similarly to JIS X 0208, mbstring would pass kuten codes which are not mapped
in the JIS X 0212, JIS X 0213, or CP932 character sets through silently when
converting to another Japanese encoding.
2020-11-25 19:52:19 +02:00
Alex Dowad 8ae0473324 Don't pass invalid JIS X 0208 characters through
Many Japanese encodings, such as JIS7/8, Shift JIS, ISO-2022-JP, EUC-JP, and
so on encode characters from the JIS X 0208 character set. JIS X 0208 is based
on the concept of a 94x94 table, with numbered rows and columns. However,
more than a thousand of the cells in that table are empty; JIS X 0208 does not
actually use all 94x94=8,836 possible kuten codes.

mbstring had a dubious feature whereby, if a Japanese string contained one of
these 'unmapped' kuten codes, and it was being converted to another Japanese
encoding which was also based on JIS X 0208, the non-existent character would
be silently passed through, and the unmapped kuten code would be re-encoded
using the normal encoding method of the target text encoding.

Again, this _only_ happened if converting the text with the funky kuten code
to a Japanese encoding. If one tried converting it to Unicode, mbstring would
treat that as an error.

If somebody, somewhere, made their own private extension to JIS X 0208, and
used the regular Japanese encodings like Shift JIS and EUC-JP to encode this
private character set, then this feature might conceivably be useful. But how
likely is that? If someone is using Shift JIS, EUC-JP, ISO-2022-JP, etc. to
encode a funky version of JIS X 0208 with extra characters added, then that
should be treated as a separate text encoding.

The code which flags such characters with MBFL_WCSPLANE_JIS0208 is retained
solely for error reporting in `mbfl_filt_conv_illegal_output`.
2020-11-25 19:52:19 +02:00
Alex Dowad 2759874a42 Enhance handling of CP932 text encoding
- Don't allow control characters to appear in the middle of a multi-byte
  character. (This was a strange feature of mbstring; it doesn't make much
  sense, and iconv doesn't allow it.)
- Treat truncated multi-byte characters as an error.
2020-11-25 19:52:19 +02:00
Alex Dowad b489c1bc4d Bugfixes for findInvalidChars (helper for mbstring test suite) 2020-11-25 19:52:19 +02:00
Nikita Popov 635e0539a2 Merge branch 'PHP-8.0'
* PHP-8.0:
  Add UPGRADING note for PDO::inTransaction()

[ci skip]
2020-11-25 17:28:38 +01:00
Nikita Popov c3d113653d Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80411
2020-11-25 17:25:08 +01:00
Nikita Popov de8bae4d5c Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix unserialization ref source management, again
2020-11-25 17:05:25 +01:00
Nikita Popov bd1c2ede99 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed error reporting in mysqli_stmt::__construct
2020-11-25 16:29:22 +01:00
Nikita Popov 18bc3c1a3d Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix phpt reindentation in tidy script
  Reindent more mysqli tests
2020-11-25 16:08:36 +01:00
Nikita Popov 5b224fb86c Merge branch 'PHP-8.0'
* PHP-8.0:
  Reindent ext/mysqli tests
  Allow running tidy.php on specific directory
2020-11-25 15:58:39 +01:00
Nikita Popov bb42738040 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix ref source management during unserialization
2020-11-25 12:28:15 +01:00
Nikita Popov 2b7d5eddfc Merge branch 'PHP-8.0'
* PHP-8.0:
  sockets: Fix variable/macro name collision on AIX
2020-11-25 11:55:05 +01:00
Nikita Popov 7db29d2186 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80377
2020-11-25 11:48:51 +01:00
Christopher Jones 30770e576a Merge branch 'PHP-8.0' into master
* PHP-8.0:
  Fix test diff
2020-11-25 16:42:52 +11:00
Dmitry Stogov e2227ddb05 Merge branch 'PHP-8.0'
* PHP-8.0:
  Use diferent temporary register (%r0 may keep a method address)
2020-11-25 03:50:55 +03:00
Dmitry Stogov c4f4406349 Merge branch 'PHP-8.0'
* PHP-8.0:
  Revert "Fixed bug #80377"
2020-11-25 01:13:21 +03:00
Christoph M. Becker b324ab6f15 Merge branch 'PHP-8.0'
* PHP-8.0:
  [ci skip] Fix misspelled method names
2020-11-24 18:19:07 +01:00
Nikita Popov 6ae7bceecf Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix usage of casted string in ReflectionParameter ctor
2020-11-24 16:43:02 +01:00
Nikita Popov 36cfa11198 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80377
2020-11-24 15:53:24 +01:00
Nikita Popov 14eabd9523 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80393
2020-11-24 15:27:50 +01:00
Christoph M. Becker 55a0a7f134 Merge branch 'PHP-8.0'
* PHP-8.0:
  Allow PHP_CURL_APIs to be imported by DLLs
2020-11-24 14:12:55 +01:00
Christoph M. Becker cbf8191f79 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #77961: finfo_open crafted magic parsing SIGABRT
2020-11-24 14:07:18 +01:00
Christoph M. Becker c0747da701 Merge branch 'PHP-8.0'
* PHP-8.0:
  [ci skip] Update generate_patch.sh
2020-11-24 13:39:15 +01:00
Christoph M. Becker f7096c45d6 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #80366: Return Value of zend_fstat() not Checked
2020-11-24 13:11:00 +01:00
Nikita Popov 3763255666 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80362: Running dtrace scripts can cause php to crash
2020-11-24 13:02:17 +01:00
Nikita Popov 7965bc3656 Use pkg-config for libargon2
We already tried this in PHP 7.4, but ran into issues, because
alpine did not support pkg-config for libargon2 (or had a broken
pc file, not sure). The Alpine issue has been resolved in the
meantime, so let's give this another try.
2020-11-24 11:52:43 +01:00
Nikita Popov 61a3cff2fb Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80404
2020-11-24 11:38:50 +01:00
Nikita Popov 679bb56858 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80391
2020-11-24 10:10:01 +01:00
Nikita Popov 756261cf9a Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix PDOStatement::fetchObject() stub
2020-11-24 09:49:52 +01:00
Christopher Jones 1126b8a062 Merge branch 'PHP-8.0' into master
* PHP-8.0:
  Sync README with package.xml
2020-11-24 10:46:00 +11:00
Christoph M. Becker 326012a31f Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix COMPersistHelper::__construct() stub
2020-11-24 00:23:55 +01:00
Gabriel Caruso ce9f7b139f [ci-skip] Use HTTPS for links on PHP ini files 2020-11-23 22:00:58 +01:00
Remi Collet 49faa33ce1 Merge branch 'PHP-8.0' into master
* PHP-8.0:
  zip extension is 1.19.2
2020-11-23 15:59:23 +01:00
Dmitry Stogov b994237619 Merge branch 'PHP-8.0'
* PHP-8.0:
  zend_jit_trace_stack_frame.stack can't be NULL
2020-11-23 16:19:54 +03:00
Dmitry Stogov 7f4b8f1349 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed use-after-free in PHPUnit tests
2020-11-23 14:43:04 +03:00
Dmitry Stogov 1c10d18573 Merge branch 'PHP-8.0'
* PHP-8.0:
  Keep value of register before possible side exit
2020-11-23 12:08:23 +03:00
Christoph M. Becker 4f68662f5b Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #77594: ob_tidyhandler is never reset
2020-11-22 14:05:52 +01:00
Máté Kocsis 2e4d44509b Merge branch 'PHP-8.0' 2020-11-21 23:17:55 +01:00
Nikita Popov 52b9aae62a Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix typos in php.ini files
2020-11-20 16:50:57 +01:00
Nikita Popov 51b51d5aba Merge branch 'PHP-8.0'
* PHP-8.0:
  UPGRADING: (real) cast has been removed
  Use MIN/MAX when dumping RANGE[]
2020-11-20 16:49:14 +01:00
Dmitry Stogov 62526a0725 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed incorrect TRACE_FRAME_MASK_NESTED flag setting
2020-11-20 18:23:11 +03:00
Dmitry Stogov a5a78f3819 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed 32-bit JIT
2020-11-20 15:12:58 +03:00
Christoph M. Becker 38b80aaf85 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #72964: White space not unfolded for CC/Bcc headers
2020-11-19 19:27:12 +01:00
Christoph M. Becker dc8fb9dc8b Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #80345: PHPIZE configuration has outdated PHP_RELEASE_VERSION
2020-11-19 16:28:27 +01:00
Sara Golemon 2efeaca40c Merge branch 'PHP-8.0'
* PHP-8.0:
  8.0 branch should be prepping for 8.0.1
2020-11-19 14:38:31 +00:00
Sara Golemon 5a25e7d122 Merge branch 'PHP-8.0'
* PHP-8.0:
  Prepare NEWS file for GA
2020-11-19 14:34:47 +00:00
Dmitry Stogov 02fa213d36 Merge branch 'PHP-8.0'
* PHP-8.0:
  Added missing deoptimization code for trampoline handling
2020-11-19 12:32:49 +03:00
Nikita Popov 72ce6a131e Merge branch 'PHP-8.0'
* PHP-8.0:
  Export zend_is_callable_at_frame
2020-11-19 10:30:38 +01:00
Nikita Popov 8579f3d331 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix curl_multi_getcontent() parameter name
2020-11-19 10:18:10 +01:00
Christoph M. Becker 9b5f96e465 Fix inclusion order for phpize builds on Windows
`configure` for `phpize` builds on Windows creates Makefile and
config.pickle.h and includes the latter via the command line option
`/FI`.  That implies that config.pickle.h is always included before
config.w32.h, which means that standard definitions always override
extension specific definitions, while it should be the other way round.

Therefore, we change the inclusion order by including config.pickle.h
at the end of config.w32.h if the former is available, and also make
sure to avoid any potential C4005 warnings by `#undef`ining the macros
before defining them.

Closes GH-6269.
2020-11-18 12:50:26 +01:00
Nikita Popov a6bcad4a9e Merge branch 'PHP-8.0'
* PHP-8.0:
  Short-circuit get_gc for currently running generator
2020-11-18 12:46:32 +01:00
Dmitry Stogov 511a50d0d2 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed register clobbering
2020-11-18 10:22:41 +03:00
Dmitry Stogov fa7af81c22 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed trampoline handling
2020-11-17 23:56:39 +03:00
Dmitry Stogov d96ff29cc2 Merge branch 'PHP-8.0'
* PHP-8.0:
  Update NEWS for 8.0.0
  Update NEWS for PHP 8.0.0RC5
2020-11-17 23:54:48 +03:00
Dmitry Stogov 0ef67ba841 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed allocated register clobbering
2020-11-17 18:32:01 +03:00
Dmitry Stogov 87ae111a5c Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed false pasitive ASAN NULL pointer dereference warning
2020-11-17 16:24:44 +03:00
Nikita Popov 14458ec7e9 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #80312: change default engine from MyISAM to InnoDB in tests
2020-11-17 13:16:32 +01:00
Nikita Popov 5e84975aed Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80370: Segmentation fault reflecting attributes of dynamic property
2020-11-17 10:54:38 +01:00
Nikita Popov 5bd7305cf0 Merge branch 'PHP-8.0'
* PHP-8.0:
  Provide unused retvals to observers
2020-11-17 10:30:20 +01:00
Nikita Popov c4b2a40fdd Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix incorrectly optimized out live range
2020-11-17 10:20:52 +01:00
Sammy Kaye Powers e974becbb1 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fire open observer end handlers after a zend_bailout
2020-11-16 15:13:29 -08:00
Dmitry Stogov 977134352d Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed MAY_BE_INDIRECT inference
2020-11-16 18:17:17 +03:00
Christoph M. Becker fe27c5371e Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #74558: Can't rebind closure returned by Closure::fromCallable()
2020-11-16 14:34:52 +01:00
Dmitry Stogov 6e50e2abc0 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed alias handling
2020-11-16 16:11:48 +03:00
Dmitry Stogov 18d2b7f79a Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed reference-counting
  Fixed incorrect FETCH_THIS optimization
2020-11-16 14:52:18 +03:00
Dmitry Stogov 04393f29a8 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed inconsistent VM stack state
2020-11-16 13:21:03 +03:00
Dmitry Stogov 849b9e2bcd Merge branch 'PHP-8.0'
* PHP-8.0:
  Trampoline cleanup
2020-11-16 12:06:09 +03:00
Christoph M. Becker c3885f2316 Add --repeat flag to usage info of run-tests.php
Closes GH-6429.
2020-11-15 16:41:46 +01:00
Christoph M. Becker 604e66edd2 Merge branch 'PHP-8.0'
* PHP-8.0:
  [ci skip] Add note that imagedestroy() no longer has an effect
2020-11-14 15:18:52 +01:00
Nikita Popov 1a6d4875a0 Merge branch 'PHP-8.0'
* PHP-8.0:
  Inline pair production in json parser
2020-11-13 14:57:31 +01:00
Christoph M. Becker 1e0610fe24 Merge branch 'PHP-8.0'
* PHP-8.0:
  Strip trailing line breaks and periods from Windows error messages
2020-11-12 16:43:57 +01:00
Nikita Popov be29853353 Merge branch 'PHP-8.0'
* PHP-8.0:
  Don't assume libmysqlclient library name
2020-11-12 15:12:57 +01:00
Nikita Popov 4d24a6928f Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix memory leak when user filter onCreate returns false
2020-11-12 12:18:49 +01:00
Nikita Popov aa70770115 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix memory leak with bcsqrt on number 0<X<1
2020-11-12 11:38:23 +01:00
Nikita Popov 4e6ea169ae Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix reflection getDefaultValue() with user arg info
2020-11-12 11:02:50 +01:00
Dmitry Stogov d54e197bae Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed incorrectly eliminated type store
2020-11-11 20:14:40 +03:00
Dmitry Stogov 9f13c8feb1 Merge branch 'PHP-8.0'
* PHP-8.0:
  Remove assertion
2020-11-11 18:34:30 +03:00
Nikita Popov fe73616db6 Merge branch 'PHP-8.0'
* PHP-8.0:
  Handle errors during next_result()
2020-11-11 16:03:32 +01:00
Dmitry Stogov fa355615a4 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed incorrect invariant guard motion
2020-11-11 17:35:14 +03:00
Dmitry Stogov aa84e2c364 Merge branch 'PHP-8.0'
* PHP-8.0:
  Stop on fake frame
  Fixed reference-counting propagation
2020-11-11 14:55:08 +03:00
Nikita Popov 01de00073f Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix double free when socket_accept fails
2020-11-11 12:48:44 +01:00
Nikita Popov d637f0dd3e Merge branch 'PHP-8.0'
* PHP-8.0:
  Retain reference to share handle from curl handle
2020-11-11 11:56:39 +01:00
Dmitry Stogov 329d38c3e1 Merge branch 'PHP-8.0'
* PHP-8.0:
  [Observer+JIT] Save opline before calling begin/end handlers
2020-11-11 13:51:07 +03:00
Dmitry Stogov a15d215f75 Merge branch 'PHP-8.0'
* PHP-8.0:
  [Observer] Save opline before calling begin/end handlers
2020-11-11 13:07:12 +03:00
Alex Dowad e169ad3b61 Consolidate all single-byte encodings in one source file
We can squeeze out a lot of duplicated code in this way.
2020-11-11 11:18:59 +02:00
Alex Dowad 17d82b6886 Enhance mbstring support for UCS-2 text
- For consistency with UTF-16, UTF-32, and UCS-4, strip leading byte
  order marks.
- Treat it as an error if string is truncated (i.e. has an odd number
  of bytes).
2020-11-11 11:18:59 +02:00
Alex Dowad 6dd75478d5 Leading BOM is stripped for UTF-32
For consistency with UTF-16 and UCS-4.

Also, do some code cleanup.
2020-11-11 11:18:59 +02:00
Alex Dowad 1cf12c02f0 Add test suite for SJIS-mac encoding 2020-11-11 11:18:58 +02:00
Alex Dowad fbdcab953d Unicode -> SJIS-mac conversion doesn't reject valid codepoints after a bad transcoding hint
To give the background on this issue, here is an excerpt from JAPANESE.txt,
from the Unicode Consortium:

    Apple has defined a block of 32 corporate characters as "transcoding
    hints." These are used in combination with standard Unicode characters
    to force them to be treated in a special way for mapping to other
    encodings; they have no other effect. Sixteen of these transcoding
    hints are "grouping hints" - they indicate that the next 2-4 Unicode
    characters should be treated as a single entity for transcoding. The
    other sixteen transcoding hints are "variant tags" - they are like
    combining characters, and can follow a standard Unicode (or a sequence
    consisting of a base character and other combining characters) to
    cause it to be treated in a special way for transcoding. These always
    terminate a combining-character sequence.

    The transcoding coding hints used in this mapping table are:

    0xF860  group next 2 characters as a single entity for transcoding
    0xF861  group next 3 characters as a single entity for transcoding
    0xF862  group next 4 characters as a single entity for transcoding
    0xF87A  variant tag for "negative" (i.e. black & white reversed)
    0xF87E  variant tag for vertical form
    0xF87F  variant tag for other alternate form

    For example, the Apple addition character 0x85AB is Roman numeral
    thirteen. There is no single Unicode for this (although there are
    standard Unicodes for Roman numerals 1-12). Using the grouping hint
    0xF862 in combination with standard Unicodes, we can map this as
    0xF862+0x0058+0x0049+0x0049+0x0049 (i.e. X + I + I + I).

Our SJIS-mac conversion code actually recognizes some special sequences
which start with an Apple 'transcoding hint'. However, if a transcoding
hint is misplaced and is not followed by one of the expected sequences,
we can just emit one error marker for the bad transcoding hint and then
process the following codepoint as normal.
2020-11-11 11:18:58 +02:00
Alex Dowad b27a34c5a9 SJIS-mac encoding conversion: Stop the carnage of innocent Unicode codepoints
When converting Unicode to MacJapanese, some special sequences of Unicode
codepoints are collapsed into a single SJIS character. When the implementation
sees a codepoint which *might* begin such a sequence, it is cached and examined
again after the next codepoint arrives.

If it turns out that it wasn't one of the 'special' sequences, then a 'fallback'
conversion table is consulted to convert the cached codepoint. Then we re-enter
the regular conversion code to convert the immediately following codepoint.
BUT, local variables need to be reinitialized properly when doing this!

Because the locals weren't reinitialized, the sad result was that some codepoints
would get chopped up into bit salad and emitted as something totally bogus
(which might not even be valid SJIS-mac text at all).
2020-11-11 11:18:58 +02:00
Alex Dowad 7f0e86b2dc Convert Unicode halfwidth Yen sign to MacJapanese halfwidth Yen sign
Since 1993, Unicode has had a specific codepoint for a fullwidth Yen sign.
Likewise, MacJapanese has separate kuten codes for halfwidth and fullwidth
Yen signs. But mbstring mapped _both_ Yen sign codepoints to the
MacJapanese fullwidth Yen sign.

It's probably more appropriate to map the 'ordinary' Yen sign to the
MacJapanese halfwidth Yen sign. Besides, this means that the conversion
between Unicode and MacJapanese is closer to being lossless and reversible.
2020-11-11 11:18:58 +02:00
Alex Dowad 4c39cd3d1d SJIS-mac encoding conversion: handle invalid (or truncated) 2nd byte for Kanji correctly
Also, don't accept 1st bytes above 0xED, since none of the possible 2-byte
sequences starting with 0xEE and above are actually mapped to any character.
2020-11-11 11:18:58 +02:00
Alex Dowad d40f9cf735 Add test suite for SJIS-2004 encoding 2020-11-11 11:18:58 +02:00
Alex Dowad eda73a5f6f Don't mangle non-Japanese chars which appear after a 'combining' kana in SJIS-2004
Unicode has 'combining' characters which join with another following character.
Japanese hiragana and katakana with the 'two dots' voice mark can be represented
in this way, with one Unicode character for the 'base' kana and another one which
adds the voice mark.

In SJIS-2004, however, there are dedicated characters for voiced and unvoiced
kana. So some special checks are done to identify sequences of Unicode characters
which need to be 'collapsed' into a single SJIS-2004 character.

If a kana is immediately followed by some other unrelated character, like a
Cyrillic letter, then the cached kana should be output 'as is' and we
proceed with encoding the unrelated character. When doing this, though,
we need to re-initialize local variables, or else the unrelated character
will be mangled in some cases.
2020-11-11 11:18:58 +02:00
Alex Dowad 2f98bd8844 SJIS-2004 encoding conversion: handle invalid (or truncated) 2nd byte for Kanji correctly
If the 2nd byte of a 2-byte character is invalid, then mb_substitute_character()
should be respected. Instead, what mbstring was doing was 'swallowing' the
first byte, then emitting the 2nd byte as if it was an ASCII character.

Likewise, if the 2nd byte is missing, instead of just keeping quiet, report an
illegal character as specified by mb_substitute_character().
2020-11-11 11:18:58 +02:00
Alex Dowad a5827c2d35 Fix broken binary search function in mbstring
This faulty binary search would never reject values at the very high
end of the range being searched, even if they were not actually in
the table.

Among other things, this meant that some Unicode codepoints which do
not correspond to any character in JIS X 0213 would be converted to
bogus Shift-JIS-2004 values rather than being rejected.
2020-11-11 11:18:58 +02:00
Alex Dowad b05ad5112a Don't redundantly flush mbstring filters multiple times
Each flush function in a chain of mbstring conversion filters always
calls the next flush function in the chain. So it is not necessary to
explicitly flush the second filter in a chain. (Due to this bug, in many
cases, flush functions were actually being called three times.)
2020-11-11 11:18:58 +02:00
Alex Dowad d1d50c2b7a Test EUC-JP and Shift-JIS more thoroughly
Previously, the unit tests for these text encodings covered all mappings
from legacy -> Unicode, and all _reversible_ mappings from Unicode -> legacy.
However, we should also test the few Unicode -> legacy mappings which
are not reversible.
2020-11-11 11:18:58 +02:00
Nikita Popov 1562d76a84 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix community job
2020-11-11 09:28:44 +01:00
Derick Rethans 71f035e6f3 Merge branch 'PHP-8.0' 2020-11-10 17:58:50 +00:00
Nikita Popov 5cf70dfa6b Merge branch 'PHP-8.0'
* PHP-8.0:
  Add integration test for symfony preloading
2020-11-10 11:46:07 +01:00
Christoph M. Becker 0947ea8d98 Merge branch 'PHP-8.0'
* PHP-8.0:
  7.3.26 is next
2020-11-10 11:11:34 +01:00
Nikita Popov 4945bc2609 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix phi use chain management when renaming variable
2020-11-09 17:08:46 +01:00
Nikita Popov b6a93c38bf Merge branch 'PHP-8.0'
* PHP-8.0:
  Use true/false instead of TRUE/FALSE in intl
2020-11-09 14:44:46 +01:00
Nikita Popov 5143b4d8aa Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80310: Support for icu4c 68.1.
2020-11-09 14:35:48 +01:00
Alex Dowad 3e7acf901d Remove mbstring identify filters
mbstring had an 'identify filter' for almost every supported text encoding
which was used when auto-detecting the most likely encoding for a string.
It would run over the string and set a 'flag' if it saw anything which
did not appear likely to be the encoding in question.

One problem with this scheme was that encodings which merely appeared
less likely to be the correct one were completely rejected, even if there
was no better candidate. Another problem was that the 'identify filters'
had a huge amount of code duplication with the 'conversion filters'.

Eliminate the identify filters. Instead, when auto-detecting text
encoding, use conversion filters to see whether the input string is valid
in candidate encodings or not. At the same type, watch the type of
codepoints which the string decodes to and mark it as less likely if
non-printable characters (ESC, form feed, bell, etc.) or 'private use
area' codepoints are seen.

Interestingly, one old test case in which JIS text was misidentified
as UTF-8 (and this wrong behavior was enshrined in the test) was 'fixed'
and the JIS string is now auto-detected as JIS.
2020-11-09 13:45:17 +02:00
Alex Dowad a416f938f3 Treat non-ASCII characters as erroneous when converting ASCII text 2020-11-09 13:45:17 +02:00
Alex Dowad 8f6889b20d Fix mbstring support for EUC-JP text encoding
- Don't allow control characters to appear in the middle of a multi-byte
  character. (A strange feature, or perhaps misfeature, of mbstring which is
  not present in other libraries such as iconv.)
- When checking whether string is valid, reject kuten codes which do not
  map to any character, whether converting from EUC-JP to another encoding,
  or converting another encoding which uses JIS X 0208/0212 charsets to
  EUC-JP.
- Truncated multi-byte characters are treated as an error.
2020-11-09 13:45:17 +02:00
Alex Dowad ad7e0f16cc Fix mbstring support for Shift-JIS
- Reject otherwise valid kuten codes which don't map to anything in JIS X 0208.
- Handle truncated multi-byte characters as an error.
- Convert Shift-JIS 0x7E to Unicode 0x203E (overline) as recommended by the
  Unicode Consortium, and as iconv does.
- Convert Shift-JIS 0x5C to Unicode 0xA5 (yen sign) as recommended by the
  Unicode Consortium, and as iconv does.
  (NOTE: This will affect PHP scripts which use an internal encoding of
  Shift-JIS! PHP assigns a special meaning to 0x5C, the backslash. For example,
  it is used for escapes in double-quoted strings. Mapping the Shift-JIS yen
  sign to the Unicode yen sign means the yen sign will not be usable for
  C escapes in double-quoted strings. Japanese PHP programmers who want to
  write their source code in Shift-JIS for some strange reason will have to
  use the JIS X 0208 backlash or 'REVERSE SOLIDUS' character for their C
  escapes.)
- Convert Unicode 0x5C (backslash) to Shift-JIS 0x815F (reverse solidus).
- Immediately handle error if first Shift-JIS byte is over 0xEF, rather than
  waiting to see the next byte. (Previously, the value used was 0xFC, which is
  the limit for the 2nd byte and not the 1st byte of a multi-byte character.)
- Don't allow 'control characters' to appear in the middle of a multi-byte
  character.

The test case for bug 47399 is now obsolete. That test assumed that a number
of Shift-JIS byte sequences which don't map to any character were 'valid'
(because the byte values were within the legal ranges).
2020-11-09 13:45:16 +02:00
Alex Dowad cc03c54c36 Remove useless byte{2,4}{be,le} encodings from mbstring
There is no meaningful difference between these and UCS-{2,4}. They are
just a little bit more lax about passing errors silently. They also have
no known use.

Alias to UCS-{2,4} in case someone, somewhere is using them.
2020-11-09 13:45:16 +02:00
Alex Dowad 3eb8828d1a Fix issues with mbstring encoding tests
I made some mistakes on this code, which meant that not everything which
should be tested was actually being tested.
2020-11-09 13:45:16 +02:00
Nikita Popov 12ab4cbd00 Merge branch 'PHP-8.0'
* PHP-8.0:
  Remove embedded property from mysqli_driver
2020-11-09 11:03:14 +01:00
Nikita Popov 31d975a461 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80334
2020-11-09 10:19:40 +01:00
Dmitry Stogov 13a8f3b30f Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed missaligned access
2020-11-09 11:50:51 +03:00
Nikita Popov 6033c77653 Merge branch 'PHP-8.0'
* PHP-8.0:
  Skip preload test under asan
2020-11-09 09:47:12 +01:00
Nikita Popov e09ad4a8b6 Merge branch 'PHP-8.0'
* PHP-8.0:
  Rename PhpToken::getAll() to PhpToken::tokenize()
2020-11-09 09:41:23 +01:00
Derick Rethans b0b4a5930b Merge branch 'PHP-8.0' 2020-11-07 18:49:11 +00:00
Christoph M. Becker 6768f4705c Merge branch 'PHP-8.0'
* PHP-8.0:
  Split tests for compatibility with ICU 68.1
2020-11-06 17:45:29 +01:00
George Peter Banyard c4646371f1 Stabalize IMAP parallel testing, again
Drive by clean-up
Use less the default mailbox again
2020-11-06 14:26:47 +00:00
Remi Collet 21594edd2d Merge branch 'PHP-8.0'
* PHP-8.0:
  Raise E_WARNING on PHP related errors
2020-11-06 11:00:56 +01:00
Dmitry Stogov 668ac03ca4 Merge branch 'PHP-8.0'
* PHP-8.0:
  Move stack overflow checks out of the loops
2020-11-06 12:10:28 +03:00
Remi Collet ca5c8c3ffd Merge branch 'PHP-8.0'
* PHP-8.0:
  report about ZSTD compression availability
  only display libzip both headers/library versions if they differ
2020-11-06 09:59:47 +01:00
Nikita Popov 9bdf2212cc Merge branch 'PHP-8.0'
* PHP-8.0:
  Backport preloading trait fixup fixes
2020-11-05 16:38:02 +01:00
Dmitry Stogov 5cd88ccddb Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed incorrect invariant guard motion
2020-11-05 18:32:46 +03:00
Nikita Popov 046143859d Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixup trait methods even if no traits are used
2020-11-05 13:16:31 +01:00
Nikita Popov 1fea175765 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix multiple trait fixup
2020-11-05 12:11:20 +01:00
Nikita Popov 313a56add0 Merge branch 'PHP-8.0'
* PHP-8.0:
  End output handlers in preload shutdown
2020-11-04 16:05:48 +01:00
Nikita Popov bb1dd83af3 Merge branch 'PHP-8.0'
* PHP-8.0:
  getlastmod() can return false
2020-11-04 15:53:17 +01:00
Nikita Popov c380812ed2 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix static variable in methods inheritance during preloading
2020-11-04 15:43:00 +01:00
Christoph M. Becker bceab5b7c0 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #80266: parse_url silently drops port number 0
2020-11-04 14:58:47 +01:00
Nikita Popov 80e063c28e Merge branch 'PHP-8.0'
* PHP-8.0:
  Assert that references are not persisted
2020-11-04 14:52:47 +01:00
George Peter Banyard d17fae8a1c Fix parallel testing for IMAP
The script for the clean section was missing the $ Meta-character to only delete the default
mailbox when it's an exact match.

Reinstore parallel testing for more tests.
2020-11-04 12:40:12 +00:00
Nikita Popov 3f400a7981 Merge branch 'PHP-8.0'
* PHP-8.0:
  Don't xfail method_static_var.phpt
2020-11-04 12:31:28 +01:00
Nikita Popov bae3a35ce6 Merge branch 'PHP-8.0'
* PHP-8.0:
  Don't disable opcache for generic tests
2020-11-04 11:12:22 +01:00
Nikita Popov 6457043a75 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix dynamic function definition in preload script
2020-11-04 10:56:24 +01:00
George Peter Banyard 28eb23cedb Make all IMAP fetch*() tests conflict with the default mailbox 2020-11-03 18:44:37 +00:00
Anatol Belski 4b3438d8ce hash: murmur: Initialize final hash explicitly
Signed-off-by: Anatol Belski <ab@php.net>
2020-11-03 18:41:39 +01:00
Nikita Popov b43c455b98 Merge branch 'PHP-8.0'
* PHP-8.0:
  Don't disable early binding during preloading script
2020-11-03 16:47:42 +01:00
Nikita Popov d0a07cd0fa Merge branch 'PHP-8.0'
* PHP-8.0:
  Report parse errors during preloading
2020-11-03 16:25:08 +01:00
Nikita Popov 8d43896013 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix use of type copy ctor when importing trait properties
2020-11-03 15:30:00 +01:00
Nikita Popov fa7272780b Merge branch 'PHP-8.0'
* PHP-8.0:
  Allow unlinked classes when performing in_compilation variance check
2020-11-03 14:50:15 +01:00
Nikita Popov b4b91a8240 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix variance checks on resolved union types
2020-11-03 14:19:53 +01:00
Nikita Popov fa15f03241 Merge branch 'PHP-8.0'
* PHP-8.0:
  Don't ignore internal classes during preloading
2020-11-03 11:51:29 +01:00
Nikita Popov a600443190 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix persisting property info table with internal parent
2020-11-03 11:31:58 +01:00
Nikita Popov ac5486b832 Merge branch 'PHP-8.0'
* PHP-8.0:
  Preserve trait method alias name during preloading
2020-11-03 10:57:01 +01:00
George Peter Banyard 06ddda22fe Modernize IMAP tests
Use constants when appropriate, drop some ouputs which depends on env vars

Enable parallel testing.

Closes GH-6380
2020-11-03 09:50:42 +00:00
Nikita Popov e1cbfb38f6 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix another implicit function declaration in configure
2020-11-03 10:39:33 +01:00
Nikita Popov 6e30a40c28 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix typo in UPGRADING
  Improved error message for typed class properties with null as default value
2020-11-03 09:35:20 +01:00
Alex Dowad ff953f254c Add test suite for ARMSCII-8 encoding 2020-11-02 21:31:06 +02:00
Alex Dowad 9f5a4b3bd9 Fix mbstring support for ARMSCII-8
- Identify filter was completely wrong.
- Respect `mb_substitute_character` rather than converting invalid bytes to
  Unicode 0xFFFD (generic replacement character).
- Don't convert Unicode 0xFFFD to a valid ARMSCII-8 character.
- When converting ARMSCII-8 to ARMSCII-8, don't pass invalid bytes through
  silently.
2020-11-02 21:31:06 +02:00
Alex Dowad be1a215538 Optimize (AND FIX) mb_check_encoding (cut execution time by 50%+)
Previously, `mb_check_encoding` did an awful lot of unneeded work. In order to
determine whether a string was valid or not, it would convert the whole string
into wchar (code points), which required dynamically allocating a (potentially
large) buffer. Then it would turn right around and convert that big 'ol buffer
of code points back to the original encoding again. Finally, it would check
whether any invalid bytes were detected during that long and onerous process.

The thing is, mbstring _already_ has machinery for detecting whether a string
is valid in a certain encoding or not, and it doesn't require copying any data
around or allocating buffers. Better yet, it can fail fast when an invalid byte
is found. Why not use it? It's sure a lot faster!

Further, the legacy code was also badly broken. Why? Because aside from
checking whether illegal characters were detected, it would also check whether
the conversion to and from wchars was lossless. But, some encodings have
more than one valid encoding for the same character. In such cases, it is
not possible to make the conversion to and from wchars lossless for every
valid character. So `mb_check_encoding` would actually reject good strings
in a lot of encodings!
2020-11-02 21:31:06 +02:00
Alex Dowad 335c1b98c2 Add test suite for KOI8-U encoding 2020-11-02 21:31:06 +02:00
Alex Dowad e81458862b Remove dead code from mbfilter_koi8u.c (and do general code cleanup) 2020-11-02 21:31:06 +02:00
Alex Dowad f9826fba46 All bytes are valid in KOI8-U encoding 2020-11-02 21:31:06 +02:00
Alex Dowad 9db4387f14 Add test suite for KOI8-R encoding 2020-11-02 21:31:06 +02:00
Alex Dowad fde7794556 Remove dead code from mbfilter_iso8859_{2,4,5,9,10,13,14,15,16}.c
...Plus some dead code related to ISO-8859-1.
2020-11-02 21:31:06 +02:00
Alex Dowad 0a8ebb36a5 Remove dead code from mbfilter_koi8r.c 2020-11-02 21:31:06 +02:00
Alex Dowad 7b97789ec0 All bytes are valid in KOI8-R encoding 2020-11-02 21:31:06 +02:00
Alex Dowad 9980534a4e Add test suite for CP850 encoding 2020-11-02 21:31:06 +02:00
Alex Dowad b6e75265d0 Remove dead code from mbfilter_cp850.c (and do general code cleanup)
Since there are no invalid bytes in CP850, these `if` conditions will never
be true.
2020-11-02 21:31:06 +02:00
Alex Dowad 8926252ee8 All bytes are valid in CP850 encoding 2020-11-02 21:31:06 +02:00
Alex Dowad 0485bed4c7 Add test suite for CP866 encoding 2020-11-02 21:31:06 +02:00
Alex Dowad 20a404f765 Remove dead code from mbfilter_cp866.c (and do general code cleanup)
Since there are no invalid bytes in CP866, these `if` conditions will never
be true.
2020-11-02 21:31:06 +02:00
Alex Dowad bc04e0cc6d All bytes are valid in CP866 encoding 2020-11-02 21:31:05 +02:00
Alex Dowad 0b13305ccc Add test suite for CP1254 encoding 2020-11-02 21:31:05 +02:00
Alex Dowad e6d17cfe44 Fix mbstring support for CP1254 encoding
One funny thing: while the original author used Unicode 0xFFFD (generic
replacement character) for invalid bytes in CP1251 and CP1252, for CP1254
they used 0xFFFE, which is not a valid Unicode codepoint at all, but is a
reversed byte-order mark. Probably this was by mistake.

Anyways,

- Fixed identify filter, which was completely wrong.
- Don't convert Unicode 0xFFFE to a random (but valid) CP1254 byte.
- When converting CP1254 to CP1254, don't pass invalid bytes through silently.
2020-11-02 21:31:05 +02:00
Alex Dowad eb4151e89e Add test suite for CP1251 encoding 2020-11-02 21:31:05 +02:00
Alex Dowad 44bd5804b0 Fix mbstring support for CP1251 encoding
- Identify filter was as wrong as wrong can be.
- Invalid CP1251 byte 0x98 was converted to Unicode 0xFFFD (generic
  replacement character), rather than respecting `mb_substitute_character`.
- Unicode 0xFFFD was converted to some random CP1251 byte.
- When converting CP1251 to CP1251, don't pass invalid bytes through silently.
2020-11-02 21:31:05 +02:00
Alex Dowad b18b9c9ef6 Test cases for mbstring encodings are less repetitive 2020-11-02 21:31:05 +02:00
Christoph M. Becker a1dcbb2c8a Merge branch 'PHP-8.0'
* PHP-8.0:
  [ci skip] Fix small typo
2020-11-02 18:11:52 +01:00
Nikita Popov d5dff02e72 Merge branch 'PHP-8.0'
* PHP-8.0:
  Rename opcache.jit_max_loops_unroll to opcache.jit_max_loop_unrolls
2020-11-02 12:25:28 +01:00
Christoph M. Becker 4fa02d5089 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #70461: disable md5 code when it is not supported in net-snmp
2020-11-02 11:42:26 +01:00
Nikita Popov bcdb54d476 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix tests for MariaDB
2020-11-02 09:59:45 +01:00
Anatol Belski 0659d4459e hash: murmur: Fix GCC support version for no_sanitize
While AddressSanitizer is supported as of 4.8, the no_sanitize attribute
appears in 8.0.

Signed-off-by: Anatol Belski <ab@php.net>
2020-11-01 21:47:39 +01:00
Anatol Belski 58e71efe7c hash: murmur: Suppress sanitize warnings under GCC
Signed-off-by: Anatol Belski <ab@php.net>
2020-11-01 21:22:03 +01:00
Jakub Zelenka c3a6debc08 Bump minimal OpenSSL version to 1.0.2 2020-11-01 20:10:37 +00:00
Anatol Belski 347a3f8736 UPGRADING: Add murmurhash note [ci skip]
Signed-off-by: Anatol Belski <ab@php.net>
2020-10-31 19:19:00 +01:00
Anatol Belski 5e162093d8 NEWS: Add murmurhash info [ci skip]
Signed-off-by: Anatol Belski <ab@php.net>
2020-10-31 19:16:24 +01:00
Anatol Belski 72e91e9fc8 hash: Add MurmurHash3 with streaming support
The implementation is based on the upstream PMurHash. The following
variants are implemented

- murmur3a, 32-bit hash
- murmur3c, 128-bit hash for x86
- murmur3f, 128-bit hash for x64

The custom seed support is not targeted by this implementation. It will
need a major change to the API, so then custom arguments can be passed
through `hash_init`. For now, the starting hash is always zero.

Fixes bug #68109, closes #6059

Signed-off-by: Anatol Belski <ab@php.net>
Co-Developed-by: Michael Wallner <mike@php.net>
Signed-off-by: Michael Wallner <mike@php.net>
2020-10-31 16:44:18 +01:00
Alex Dowad 831abe2d90 Add test suite for CP1252 encoding
Also remove a bogus test (bug62545.phpt) which wrongly assumed that all invalid
characters in CP1251 and CP1252 should map to Unicode 0xFFFD (REPLACEMENT
CHARACTER).

mbstring has an interface to specify what invalid characters should be
replaced with; it's called `mb_substitute_character`. If a user wants to see
the Unicode 'replacement character', they can specify that using
`mb_substitute_character`. But if they specify something else, we should
follow that.
2020-10-30 22:13:27 +02:00
Alex Dowad b5ff87ca71 Fix mbstring support for CP1252 encoding
It's a bit surprising how much was broken here.

- Identify filter was utterly and completely wrong.
- Instead of handling invalid CP1252 bytes as specified by
  `mb_substitute_character`, it would convert them to Unicode 0xFFFD
  (generic replacement character).
- When converting ISO-8859-1 to CP1252, invalid ISO-8859-1 bytes would
  be passed through silently.
- Unicode codepoints from 0x80-0x9F were converted to CP1252 bytes 0x80-0x9F,
  which is wrong.
- Unicode codepoint 0xFFFD was converted to CP1252 0x9F, which is very wrong.

Also clean up some unneeded code, and make the conversion table consistent with
others by using zero as a 'invalid' marker, rather than 0xFFFD.
2020-10-30 22:13:27 +02:00
Alex Dowad 2ce15d9c8d Merge branch 'PHP-8.0' 2020-10-30 22:12:00 +02:00
Alex Dowad e2dc80b4e4 Merge branch 'PHP-8.0' 2020-10-30 22:07:41 +02:00
Nikita Popov 1b3b430f47 Add --repeat testing mode
This testing mode executes the test multiple times in the same
process (but in different requests). It is primarily intended to
catch tracing JIT bugs, but also catches state leaks across
requests.

Closes GH-6365.
2020-10-30 17:29:33 +01:00
Nikita Popov ada2a55e07 Merge branch 'PHP-8.0'
* PHP-8.0:
  FIxed bug #80299
2020-10-30 17:24:02 +01:00
Nikita Popov 3e2b127e63 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix SSA integrity violation for type inference in dead code
2020-10-30 15:52:59 +01:00
Christoph M. Becker fdbfb416e3 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix bug79177.phpt wrt. JIT
2020-10-30 15:50:17 +01:00
Nikita Popov b32a48f16b Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix signed integer overflow
2020-10-30 12:39:47 +01:00
Nikita Popov da4d5e9480 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80290
2020-10-30 11:13:44 +01:00
Dmitry Stogov fab8ef62ff Merge branch 'PHP-8.0'
* PHP-8.0:
  Create TSSA loops for recursive call/return traces and move invariant type guards out of loops.
2020-10-30 13:10:08 +03:00
divinity76 6c71d3476b Use constant size string in hash bench.php
I don't like the previous behaviour where the bytes to hash change
every time the code changes, that may make it difficult to compare
hash() performance changes over time.

Use a fixed number instead, and allow passing an override for a
different length.

Closes GH-6386.

[ci skip]
2020-10-30 09:54:48 +01:00
Nikita Popov dd008fd124 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix bug #72413: Segfault with get_result and PS cursors
2020-10-29 16:42:00 +01:00
Nikita Popov 39532f9c52 Merge branch 'PHP-8.0'
* PHP-8.0:
  Handle errors during PDO row fetch
2020-10-29 14:18:22 +01:00
Christoph M. Becker 278ee5837d Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix format specifier
2020-10-29 13:11:00 +01:00
Nikita Popov 60ab7a36c7 Merge branch 'PHP-8.0'
* PHP-8.0:
  Report gone away error in one more place
2020-10-29 12:47:32 +01:00
Christoph M. Becker 4273ec8551 Merge branch 'PHP-8.0'
* PHP-8.0:
  [ci skip] Fix NEWS order
2020-10-29 12:16:41 +01:00
Christoph M. Becker 3d11a0feb0 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #44618: Fetching may rely on uninitialized data
2020-10-29 12:04:21 +01:00
Nikita Popov 5e695343ec Merge branch 'PHP-8.0'
* PHP-8.0:
  Retain QUIT_SEND connection state
2020-10-29 10:40:10 +01:00
Nikita Popov f3c9597bc2 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #65825
2020-10-28 17:15:51 +01:00
Christoph M. Becker 92381864a5 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #79177: FFI doesn't handle well PHP exceptions within callback
2020-10-28 13:49:47 +01:00
Nikita Popov bd555b6cca Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #66528
2020-10-28 12:18:26 +01:00
Dmitry Stogov 84a0d4880c Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed run-time binding of preloaded dynamically declared function
2020-10-28 13:51:55 +03:00
Nikita Popov 67598afbdb Merge branch 'PHP-8.0'
* PHP-8.0:
  Handle mysqli errors in more cases
  Sync test with master
2020-10-28 11:37:54 +01:00
Nikita Popov dc03e621b8 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix bug #79375
2020-10-28 11:04:41 +01:00
Dmitry Stogov 94fd97eea3 Merge branch 'PHP-8.0'
* PHP-8.0:
  Don't force rebuild of symbol table, when populating $http_response_header variable by the HTTP stream wrapper
2020-10-28 12:59:42 +03:00
Nikita Popov ab0ec3f24a Check for null dbh methods in get_gc
Methods may not be set at the point where get_gc is called. Fixes
a segfault in Laravel.
2020-10-28 10:44:13 +01:00
Dmitry Stogov a49200a031 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed memory leak in Zend/tests/bug78999.phpt
2020-10-28 10:47:56 +03:00
Dmitry Stogov a73b2ddc30 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed tracing JIT support for aliasses (Zend/tests/bug75420.13.phpt and ext/standard/tests/streams/bug60106.phpt)
2020-10-27 23:45:32 +03:00
Dmitry Stogov c80cb79796 Fix conflict 2020-10-27 16:42:26 +03:00
Dmitry Stogov 1f1dbd7f48 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed support for named parameters (Zend/tests/named_params/references.phpt)
  Update NEWS for 8.0.0RC4
  Update NEWS for PHP 8.0.0RC3
2020-10-27 16:36:58 +03:00
Nikita Popov 5b46bdef92 Merge branch 'PHP-8.0'
* PHP-8.0:
  Don't throw for out of bounds offsets in strspn()
2020-10-27 11:42:18 +01:00
Máté Kocsis 543bcd88aa Merge branch 'PHP-8.0' 2020-10-27 11:28:48 +01:00
Dmitry Stogov b961b7f0b5 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed support for typed references
2020-10-27 12:59:53 +03:00
Nikita Popov 2e097098f4 Merge branch 'PHP-8.0'
* PHP-8.0:
  Skip bug46024.phpt under asan
2020-10-27 10:35:54 +01:00
Alex Dowad e26234a044 UTF-32 conversion treats truncated characters as illegal 2020-10-27 10:19:01 +02:00
Alex Dowad 7047e5d2c4 Add identify filter for UTF-32{,BE,LE} 2020-10-27 10:19:01 +02:00
Alex Dowad d8895cd054 Improve error handling for UTF-16{,BE,LE}
Catch various errors such as the first part of a surrogate pair not being
followed by a proper second part, the first part of a surrogate pair appearing
at the end of a string, the second part of a surrogate pair appearing out
of place, and so on.
2020-10-27 10:19:01 +02:00
Alex Dowad d9ddeb6e85 UTF-16 text conversion handles truncated characters as illegal
This broke one old test (Zend/tests/multibyte_encoding_003.phpt), which used
a PHP script encoded as UTF-16. The problem was that to terminate the test
script, we need the text: "\n--EXPECT--". Out of that text, the terminating
newline (0x0A byte) becomes part of the resulting test script; but a bare
0x0A byte with no 0x00 is not valid UTF-16.

Since we now treat truncated UTF-16 characters as erroneous, an extra '?' is
appended to the output as an 'illegal character' marker.

Really, if we are running PHP scripts which are treated as encoded in UTF-16
or some other arbitrary text encoding (not ASCII), and the script is not
actually a valid string in that encoding, inserting '?' characters into the
code which the PHP interpreter runs is a bad thing to do. In such cases, the
script shouldn't be treated as UTF-16 (or whatever) at all.

I wonder if mbstring's encoding detection is being used in 'non-strict' mode?
2020-10-27 10:19:00 +02:00
Dmitry Stogov 9bfb158872 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed tracing JIT for tests/classes/unset_properties.phpt
2020-10-27 10:31:09 +03:00
Dmitry Stogov 990bac4efc Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed memory leak
2020-10-27 01:20:46 +03:00
Sammy Kaye Powers 6cd0ec70b5 Merge branch 'PHP-8.0'
* PHP-8.0:
  Add missing observer tests
2020-10-26 15:15:45 -07:00
Dmitry Stogov 9fd5851551 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed register allocation
  Fixed MAY_BE_INDIRECT inference.
2020-10-26 21:49:14 +03:00
Dmitry Stogov f663546b2a Merge branch 'PHP-8.0'
* PHP-8.0:
  Better JIT support for aliases
2020-10-26 19:05:23 +03:00
Nikita Popov 18d373e8c3 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix inconsistency in PDO transaction state
2020-10-26 17:01:25 +01:00
Nikita Popov 94b0204da6 Merge branch 'PHP-8.0'
* PHP-8.0:
  Deny serialization of finfo objects
2020-10-26 16:54:58 +01:00
Nikita Popov 4485f10330 Merge branch 'PHP-8.0'
* PHP-8.0:
  Deny cloning of fileinfo objects
2020-10-26 16:52:22 +01:00
Nikita Popov 3489e98333 Merge branch 'PHP-8.0'
* PHP-8.0:
  Consistent error handling in mysqli_poll
2020-10-26 16:25:31 +01:00
Christoph M. Becker 0768ccf125 Merge branch 'PHP-8.0'
* PHP-8.0:
  Revert "Fix out-of-bounds write"
2020-10-26 15:42:32 +01:00
Nikita Popov fa5f083cd9 Merge branch 'PHP-8.0'
* PHP-8.0:
  Re-enable laravel tests
2020-10-26 14:31:55 +01:00
Dmitry Stogov 55c5763be5 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed incorrect register allocation in ext/gd/tests/imagecopyresampled_variation1.phpt
2020-10-26 15:57:23 +03:00
Christoph M. Becker 838671dd43 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #80268: loadHTML() truncates at NUL bytes
2020-10-26 13:15:33 +01:00
Nikita Popov 3fb6e3a887 Merge branch 'PHP-8.0'
* PHP-8.0:
  Don't set xdebug.default_enable in run-tests
2020-10-26 13:11:00 +01:00
Nikita Popov 18c4408fa5 Merge branch 'PHP-8.0'
* PHP-8.0:
  Declare may_retry_reparse_point on windows only
2020-10-26 12:41:19 +01:00
Nikita Popov e0ea3e8a01 Remove dated results from ext/hash/bench.php
These are not exactly representative anymore.
2020-10-26 12:25:00 +01:00
Christoph M. Becker 820ac06b6c Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #62474: com_event_sink crashes on certain arguments
2020-10-26 11:55:46 +01:00
Christoph M. Becker f4b0b32e2d Raise E_WARNING on PHP related errors
If Zip operations fails due to PHP error conditions before libzip even
has been called, there is no meaningful indication what failed; the
functions just return false, and the Zip status indicated that no error
did occur.  Therefore we raise `E_WARNING` in these cases.

Closes GH-6356.
2020-10-26 11:40:06 +01:00
Christoph M. Becker ed64d1b5a9 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #80258: Windows Deduplication Enabled, randon permission errors
2020-10-26 11:22:55 +01:00
Christoph M. Becker 02632a5080 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #80280: ADD_EXTENSION_DEP() fails for ext/standard and ext/date
2020-10-26 11:06:25 +01:00
Christoph M. Becker 09b2cbf4f7 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix bug 76618
  Fix bug 76618
2020-10-26 11:00:13 +01:00
Nikita Popov 8e74374820 Merge branch 'PHP-8.0'
* PHP-8.0:
  Use separate directory in dit_004.phpt
2020-10-26 09:26:26 +01:00
Nikita Popov 99d6e448e3 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix parameter stats generation

[ci skip]
2020-10-26 09:05:44 +01:00
Nikita Popov 406005577f Merge branch 'PHP-8.0'
* PHP-8.0:
  Document breaking change in strspn/strcspn

[ci skip]
2020-10-26 08:59:11 +01:00
Nikita Popov 927ab74ffc Merge branch 'PHP-8.0'
* PHP-8.0:
  Revert "Make ReflectionUnionType final"
2020-10-26 08:52:50 +01:00
Máté Kocsis f46c881f0e Merge branch 'PHP-8.0' 2020-10-25 20:16:11 +01:00
Christoph M. Becker 1554e903bf Merge branch 'PHP-8.0'
* PHP-8.0:
  [ci skip] Fix typos in UPGRADING
2020-10-25 16:27:45 +01:00
Christoph M. Becker a9f657218a Merge branch 'PHP-8.0' into master
* PHP-8.0:
  Define config var PHP_JSON
2020-10-24 15:36:44 +02:00
George Peter Banyard 77582ec13f Merge branch 'PHP-8.0'
* PHP-8.0:
  Throw Value/TypeError for invalid $bodies in imap_mail_compose()
2020-10-23 20:48:52 +01:00
Nikita Popov ac1ccce264 waitpid in ftp server tests
This is not relevant right now, but ensures consistent order if
the tests are repeated.
2020-10-23 16:56:23 +02:00
Nikita Popov 8f17d48b69 Allow running session tests in parallel
Use unique session IDs and/or save paths. Also removes the annoying
order-dependence of session tests.
2020-10-23 16:55:11 +02:00
Máté Kocsis 09f4f305ec Merge branch 'PHP-8.0' 2020-10-23 16:34:40 +02:00
Nikita Popov 6ab4e330ac Use ephemeral port in more server tests
Port the main php_cli_server.inc to use ephemeral ports, thus
allowing CLI server tests to be parallelized.

A complication here is that we also need to give each test a
separate doc root, to avoid index.php files writing over each
other.

Closes GH-6375.
2020-10-23 14:26:34 +02:00
Nikita Popov 3859e74347 Fix pasv_port determination
Apparently the ftp server is also used by ext/standard/tests/streams,
and only that part actually uses pasv.
2020-10-23 11:46:54 +02:00
Nikita Popov 08eb917fd5 Use ephemeral port in ftp tests
And enable them to run in parallel.
2020-10-23 10:48:21 +02:00
Nikita Popov a876577ebe Merge branch 'PHP-8.0'
* PHP-8.0:
  Make GC default threshold handling consistent
2020-10-23 10:31:55 +02:00
Nikita Popov a185cc839f Merge branch 'PHP-8.0'
* PHP-8.0:
  Don't allow passing unknown named params to class without ctor
2020-10-23 09:47:36 +02:00
Nikita Popov f9fd3313cf Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed some typos

[ci skip]
2020-10-23 09:34:37 +02:00
Dmitry Stogov 680466cd82 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed register allocation
  Fixed reference-counter inference
  Missed warning
2020-10-22 23:17:19 +03:00
Máté Kocsis 65c4a78805 Merge branch 'PHP-8.0' 2020-10-22 19:03:04 +02:00
George Peter Banyard 77d14477db Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix bug 76618
2020-10-22 17:06:07 +01:00
Dmitry Stogov 66271df663 Merge branch 'PHP-8.0'
* PHP-8.0:
  Checj type guards before loading values into CPU registers
  Avoid register allocation for ASSIGN into aliased variable (it might be indirectly changed into IS_REFERENCE)
2020-10-22 18:24:22 +03:00
George Peter Banyard 35f1b0bfaa Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix segfaults after conversion from zval to zend_string params
2020-10-22 15:50:42 +01:00
Nikita Popov 5ebe04d39d Merge branch 'PHP-8.0'
* PHP-8.0:
  Don't crash on uninitialized tidy object
2020-10-22 16:06:16 +02:00
Nikita Popov 393264a82f Merge branch 'PHP-8.0'
* PHP-8.0:
  Properly validate ArrayObject::asort() argument
2020-10-22 15:20:51 +02:00
Nikita Popov 38b3d43035 Fix zpp for GdFont|int
Use Z_PARAM_OBJ_OF_TYPE_OR_LONG to get standard behavior.
2020-10-22 15:07:01 +02:00
Nikita Popov 66757b5cf4 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix parameter name of pspell_config_save_repl()
2020-10-22 14:56:00 +02:00
Nikita Popov 5a8b01aee7 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix stub for dba_key_split()
2020-10-22 14:52:03 +02:00
Nikita Popov 3f0e94e3c7 Accept zend_string in highlight_string API 2020-10-22 14:35:40 +02:00
Nikita Popov bcb5ae15e0 Merge branch 'PHP-8.0'
* PHP-8.0:
  Make highlight_string() accept string in zpp
2020-10-22 14:31:54 +02:00
Nikita Popov 22bf92564c Remove unused pasv_listen() function 2020-10-22 14:23:07 +02:00
Nikita Popov 9a92676828 Merge branch 'PHP-8.0'
* PHP-8.0:
  Don't leak pcntl last_error across requests
2020-10-22 14:22:16 +02:00
Nikita Popov 8909d608b7 Merge branch 'PHP-8.0'
* PHP-8.0:
  Don't leak json error_code across requests
2020-10-22 12:42:26 +02:00
Nikita Popov fc59294bab Merge branch 'PHP-8.0'
* PHP-8.0:
  Don't leak pcre error_code across requests
  Updated to version 2020.4 (2020d)
2020-10-22 11:20:21 +02:00
Derick Rethans 674f719081 Updated to version 2020.4 (2020d) 2020-10-22 10:12:27 +01:00
Derick Rethans 480975bd3f Empty merge 2020-10-22 10:12:27 +01:00
Nikita Popov a58e371cef Remove unused single.leaf member 2020-10-22 10:42:26 +02:00
Nikita Popov 9d974aa1dd Don't allow properties on former resource objects 2020-10-22 10:37:16 +02:00
Nikita Popov 909468b3e6 Merge branch 'PHP-8.0'
* PHP-8.0:
  Don't allow properties on GdImage
2020-10-22 10:34:44 +02:00
Nikita Popov ff82234948 Merge branch 'PHP-8.0'
* PHP-8.0:
  Simplify and fix generator tree management
2020-10-22 10:27:01 +02:00
Sara Golemon bd12c94f46 Convert pspell resources to objects 2020-10-22 00:46:05 +00:00
Sara Golemon da97b031f0 NEWS for gdFont conversion 2020-10-21 23:43:28 +00:00
Sara Golemon bc40bce868 Convert gdFont from resource to object 2020-10-21 23:41:41 +00:00
Sara Golemon b4503fbf88 Convert FTP resource to object 2020-10-21 22:29:23 +00:00
Nikita Popov 00dab1d7a8 Merge branch 'PHP-8.0'
* PHP-8.0:
  Update bcmath.scale when calling bcscale()
2020-10-21 17:07:12 +02:00
Dmitry Stogov 585f20ab2f Merge branch 'PHP-8.0'
* PHP-8.0:
  More accurate live range construction
2020-10-21 16:05:34 +03:00
Dmitry Stogov c39c7002da Merge branch 'PHP-8.0'
* PHP-8.0:
  Eliminate useless mov(s)
2020-10-21 16:03:54 +03:00
Nikita Popov de98d7d2d1 Merge branch 'PHP-8.0'
* PHP-8.0:
  Add test for zend_extension loading
2020-10-21 12:17:14 +02:00
Nikita Popov a5597c3e8d Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix invalid memory read on libpath
2020-10-21 10:07:24 +02:00
Dmitry Stogov 7f595ba5ce Merge branch 'PHP-8.0'
* PHP-8.0:
  Eliminate dead type store
2020-10-20 23:37:39 +03:00
Dmitry Stogov e2f347ed12 Merge branch 'PHP-8.0'
* PHP-8.0:
  Improve JIT for fetching character form string
2020-10-20 20:31:09 +03:00
Christoph M. Becker 9e9505669f Merge branch 'PHP-8.0' into master
* PHP-8.0:
  Fix #80242: imap_mail_compose() segfaults for multipart with rfc822
2020-10-20 19:02:32 +02:00
Nikita Popov d7a16bf2da Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix default value handling of mysqli_fetch_object()
2020-10-20 16:48:28 +02:00
Christoph M. Becker 11a2419c35 Merge branch 'PHP-8.0' into master
* PHP-8.0:
  Add char* cast to avoid compiler warnings
2020-10-20 16:34:40 +02:00
Nikita Popov 30ebf826e6 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80256
2020-10-20 15:36:02 +02:00
Christoph M. Becker b8ff94ad23 Merge branch 'PHP-8.0' into master
* PHP-8.0:
  Properly fix #80220
2020-10-20 13:37:07 +02:00
Nikita Popov e0054fc942 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix bug #79643: Invalid memory read when opcache.interned_strings_buffer is 0
2020-10-20 12:51:17 +02:00
Dmitry Stogov 35557fe7c4 Merge branch 'PHP-8.0'
* PHP-8.0:
  Improve register allocator (register reuse)
2020-10-20 13:46:47 +03:00
Dmitry Stogov 27c239fda4 Merge branch 'PHP-8.0'
* PHP-8.0:
  Improve register allocator (give preference to loop variables).
2020-10-20 12:22:32 +03:00
Nikita Popov 1a82aadff7 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix CCM tag length setting for old OpenSSL versions
2020-10-20 10:53:01 +02:00
Nikita Popov 426815d1b5 Merge branch 'PHP-8.0'
* PHP-8.0:
  Increase timeout on file cache job

[ci skip]
2020-10-20 09:54:17 +02:00
Dmitry Stogov 50f58602cb Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed range propagation
2020-10-20 02:27:53 +03:00
Dmitry Stogov f119d46b01 Merge branch 'PHP-8.0'
* PHP-8.0:
  Avoid partial register stall
2020-10-19 23:23:04 +03:00
Dmitry Stogov c5f94ca563 Merge branch 'PHP-8.0'
* PHP-8.0:
  Use zero-extended mov insted of sign-signed movsxd
2020-10-19 19:43:20 +03:00
Nikita Popov 2dc228040a Use zend_accel_error_noreturn in more places
Missed the place in accelerator_blacklist that was the actual
motivation here...
2020-10-19 16:59:00 +02:00
Nikita Popov cfb272defc Add zend_accel_error_noreturn() helper
Avoid confusing the compiler when code relies on the fact that
LOG_FATAL/LOG_ERROR will bailout/abort.
2020-10-19 16:09:03 +02:00
Nikita Popov 9426c6e967 Don't use global for array_walk_fci
There's really no good reason for this to be a global, we can
easily pass it down to php_array_walk().
2020-10-19 15:33:03 +02:00
Nikita Popov d1845ac008 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80255
2020-10-19 15:14:57 +02:00
Nikita Popov dbfa6aa9c4 Merge branch 'PHP-8.0'
* PHP-8.0:
  Revert "Fix bug #64865: Use CONTEXT_DOCUMENT_ROOT for scanning dir tree"
2020-10-19 11:24:26 +02:00
Nikita Popov ec82c2067e Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix bug #79983: Add support for OCB mode
2020-10-19 11:09:32 +02:00
Nikita Popov 2b4ea0a3f9 Merge branch 'PHP-8.0'
* PHP-8.0:
  Disable Laravel testing
2020-10-19 10:45:01 +02:00
Nikita Popov d2ac772510 Merge branch 'PHP-8.0'
* PHP-8.0:
  Add additional initialization checks to SplFileInfo
  Updated to version 2020.3 (2020c)
2020-10-19 10:35:40 +02:00
Derick Rethans 3fe95c75ee Updated to version 2020.3 (2020c) 2020-10-19 09:31:04 +01:00
Derick Rethans e66e5d401b Empty merge 2020-10-19 09:31:04 +01:00
Nikita Popov e437ed1a4b Merge branch 'PHP-8.0'
* PHP-8.0:
  Check PDOStatement initialization during iteration
2020-10-19 10:23:15 +02:00
Christoph M. Becker 521c36c855 Remove IGNORE_URL_WIN macro
This macro is defined to zero as of PHP 5.0.0, and as the comment
indicates, is no longer relevant.  Thus, we remove the definition and
all usages from the core and bundled extensions.

Closes GH-6351.
2020-10-18 23:36:36 +02:00
Máté Kocsis 7fe9df5978 Merge branch 'PHP-8.0' 2020-10-17 12:01:40 +02:00
Alex Dowad 84c180d88b Add test suite for ISO-8859-x encoding verification and conversion 2020-10-16 22:25:48 +02:00
Alex Dowad bc18e32690 Do not pass invalid ISO-8859-{3,6,7,8} characters through silently
mbstring has a bad habit of passing invalid characters through silently
when converting to the same (or a "compatible") encoding.

For example, if you give it an invalid JIS X 0208 kuten code encoded with SJIS,
and try to convert that to EUC-JP, mbstring will just quietly re-encode the
invalid code in the EUC-JP representation.

At the same, some parts of the code (like `mb_check_encoding`) assume that
invalid characters will be treated as... well, invalid. Let's unbreak things
by actually catching errors and reporting them, instead of swallowing them.
2020-10-16 22:17:45 +02:00
Alex Dowad 5c6b2a7ad2 Add identify filter for ISO-8859-8 (Latin/Hebrew) 2020-10-16 22:17:45 +02:00
Alex Dowad ea687018cd Add identify filter for ISO-8859-7 (Latin/Greek) 2020-10-16 22:17:45 +02:00
Alex Dowad a6603b60f7 Add identify filter for ISO-8859-6 (Latin/Arabic)
Note that some text encoding conversion libraries, such as Solaris iconv
and FreeBSD iconv, map 0x30-0x39 to the Arabic script numerals rather than
the 'regular' Roman numerals. (That is, to Unicode codepoints 0x660-0x669.)

Further, Windows CP28596 adds more mappings to use the unused bytes in
ISO-8859-6.
2020-10-16 22:17:45 +02:00
Alex Dowad 23270d7f9e Add identify filter for ISO-8859-3 (Latin-3)
There are some bytes in this encoding which are not mapped to any character.
Notably, MicroSoft added their own mappings for these 'unused' bits in their
version of Latin-3, called CP28593.
2020-10-16 22:17:45 +02:00
Alex Dowad 7b9bed0150 Add identify filter for ISO-8859-16 (Latin-10) encoding
Interestingly, it looks like the original author intended to add an identify filter
for this encoding, but never did so. The needed struct is there, but was never added
to the list of identify filters in mbfl_ident.c.
2020-10-16 20:56:45 +02:00
Nikita Popov 9a669fa3d6 Merge branch 'PHP-8.0'
* PHP-8.0:
  Properly handle NULL output start filename
2020-10-16 18:38:34 +02:00
Nikita Popov d694e43c86 Remove unused global 2020-10-16 17:32:02 +02:00
Nikita Popov 808029c049 Merge branch 'PHP-8.0'
* PHP-8.0:
  Make sure output start filename is not freed early
2020-10-16 17:29:22 +02:00
Nikita Popov 60ece88c28 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix leak when setting dynamic property on generator
2020-10-16 16:58:58 +02:00
Christoph M. Becker ab208aa144 Merge branch 'PHP-8.0' into master
* PHP-8.0:
  [ci skip] Make it clear what GD uses instead of resources
2020-10-16 12:16:28 +02:00
Máté Kocsis e73bf01f9d Merge branch 'PHP-8.0' 2020-10-16 11:00:05 +02:00
Nikita Popov ccf7c516a9 Merge branch 'PHP-8.0'
* PHP-8.0:
  DragonFlyBSD build update for opcache JIT part.
2020-10-15 14:50:34 +02:00
Dmitry Stogov 14a1e66676 Merge branch 'PHP-8.0'
* PHP-8.0:
  Avoid refcounting when return CV (similar to optimization in VM).
2020-10-15 15:27:59 +03:00
Nikita Popov a9b986a970 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix bug #80055
2020-10-15 14:24:44 +02:00
Christoph M. Becker f5b2dedc09 Merge branch 'PHP-8.0' into master
* PHP-8.0:
  Fix broken fix for #80239
2020-10-15 13:21:27 +02:00
Christoph M. Becker 42d6844358 Merge branch 'PHP-8.0' into master
* PHP-8.0:
  Fix #80239: imap_rfc822_write_address() leaks memory
2020-10-15 12:58:07 +02:00
Côme Chilliet a7170727b5 Merge branch 'PHP-8.0'
* PHP-8.0:
  Change $controls parameter to default to null in ext/ldap
2020-10-15 11:49:38 +02:00
Nikita Popov 100ac24084 Merge branch 'PHP-8.0'
* PHP-8.0:
  Skip arginfo test under msan
2020-10-15 10:46:40 +02:00
Nikita Popov d384233c87 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix leak in gmp_export()
2020-10-15 10:18:13 +02:00
Christoph M. Becker 4601926635 Merge branch 'PHP-8.0' into master
* PHP-8.0:
  Adapt test expectation to cURL 7.73.0
2020-10-14 19:12:32 +02:00
Nikita Popov e6e9f64a96 Merge branch 'PHP-8.0'
* PHP-8.0:
  Sync zpp in phar interceptors
2020-10-14 16:58:13 +02:00
Nikita Popov a16699e1e5 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix null foreground in imagewbmp
  Mark ldap_exop() param as UNKNOWN
2020-10-14 16:40:57 +02:00
Nikita Popov 1fc31979a4 Merge branch 'PHP-8.0'
* PHP-8.0:
  More arginfo/zpp verification
2020-10-14 16:26:27 +02:00
Nikita Popov a008094fc8 Merge branch 'PHP-8.0'
* PHP-8.0:
  Initialize calendar_long variable
2020-10-14 11:58:44 +02:00
Nikita Popov 59a8007d88 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix nullability of openssl_cms_sign() parameter
2020-10-14 11:34:28 +02:00
Nikita Popov adf59840db Merge branch 'PHP-8.0'
* PHP-8.0:
  Allow passing $tag for non-authenticated encryption
2020-10-14 10:57:22 +02:00
Nikita Popov 5070549577 Sanity check zpp max argument count
This would have prevented 9b4094c.

Closes GH-6334.
2020-10-14 10:06:55 +02:00
Alex Dowad 7dc16374b4 Remove unused IS_SJIS1 and IS_SJIS2 macros 2020-10-14 08:31:51 +02:00
Dmitry Stogov b2ff40cfdf Merge branch 'PHP-8.0'
* PHP-8.0:
  Added missing side exit
  Update NEWS for 8.0.0RC3
  Update NEWS for PHP 8.0.0RC2
2020-10-14 01:19:24 +03:00
Nikita Popov bd2488bc49 Merge branch 'PHP-8.0'
* PHP-8.0:
  Normalize mb_ereg() return value
2020-10-13 20:41:33 +02:00
Alex Dowad 7bb5b435af mUTF-7 (UTF7-IMAP) conversion: handle illegal (non-RFC-compliant) input correctly
Instead of looking the other way and letting things slide, report errors when
the input does not follow the RFC.
2020-10-13 20:26:14 +02:00
Alex Dowad b43a7deacf Add 'mUTF-7' alias for UTF7-IMAP encoding 2020-10-13 20:26:14 +02:00
Alex Dowad b975817265 Add comment explaining mUTF-7 to mbfilter_utf7imap.c 2020-10-13 20:26:14 +02:00
Alex Dowad 648c1cb51e Add identify filter for UCS-2, UCS-2BE, and UCS-2LE encodings 2020-10-13 20:26:14 +02:00
Alex Dowad 374f31e364 Add mbstring identify filter for 'binary' encoding 2020-10-13 20:26:13 +02:00
Alex Dowad 97beecc251 Add identify filter for UTF-16, UTF-16LE, UTF-16BE
There was one faulty test in the suite which only passed before because UTF-16 had no
identify filter. After this was fixed, it exposed the problem with the test.
2020-10-13 20:26:13 +02:00
Christoph M. Becker 6af54d864d Merge branch 'PHP-8.0' into master
* PHP-8.0:
  Fix #64076: imap_sort() does not return FALSE on failure
2020-10-13 19:41:54 +02:00
Nikita Popov 4371a4b241 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix incorrect zpp parameter count in mb_substr() / mb_strcut()
2020-10-13 17:47:11 +02:00
Nikita Popov 66c332bfff Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix default value for some pgsql functions
2020-10-13 17:29:16 +02:00
Nikita Popov 3581c77c76 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix null handling in mysqli_begin_transaction()
2020-10-13 17:13:14 +02:00
Nikita Popov 40e920ebd9 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix argument nullability in mbstring
2020-10-13 16:03:29 +02:00
Nikita Popov 5f11cdadf8 Merge branch 'PHP-8.0'
* PHP-8.0:
  Don't accept null in pg_unescape_bytea()
2020-10-13 15:37:23 +02:00
Christoph M. Becker e6b1f45363 Merge branch 'PHP-8.0' into master
* PHP-8.0:
  Update ext/odbc parameter names
2020-10-13 15:34:48 +02:00
Nikita Popov fbaa7a97e7 Merge branch 'PHP-8.0'
* PHP-8.0:
  Use $statement in mysqli
2020-10-13 14:20:13 +02:00
Derick Rethans 58e5335c00 Merge branch 'PHP-8.0' into master 2020-10-13 12:29:28 +01:00
Christoph M. Becker 98a20acbaa Merge branch 'PHP-8.0' into master
* PHP-8.0:
  Ignore memory leaks reported for some libc-client functions
2020-10-13 13:13:26 +02:00
Dmitry Stogov 95337e9702 Merge branch 'PHP-8.0'
* PHP-8.0:
  Give preference to live-ranges with register hints to improve register reuse.
2020-10-13 14:00:57 +03:00
Nikita Popov 12f33a3a4d Merge branch 'PHP-8.0'
* PHP-8.0:
  Update ext/pdo_pgsql parameter names
2020-10-13 12:32:08 +02:00
Nikita Popov ddfa53ec60 Merge branch 'PHP-8.0'
* PHP-8.0:
  Update ext/pgsql parameter names
2020-10-13 12:30:59 +02:00
Nikita Popov 796d06b8ab Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix handling of throwing undef var in verify return
2020-10-13 11:45:43 +02:00
Nikita Popov 19eb1b8602 Merge branch 'PHP-8.0'
* PHP-8.0:
  Update ext/sodium parameter names
2020-10-13 10:41:43 +02:00
Dmitry Stogov 184db168ab Merge branch 'PHP-8.0'
* PHP-8.0:
  Avoid useless register allocation
2020-10-13 11:37:51 +03:00
Nikita Popov 9987b3f35a Merge branch 'PHP-8.0'
* PHP-8.0:
  Update ext/phar parameter names
2020-10-13 10:21:41 +02:00
Christoph M. Becker 3f51db55be Merge branch 'PHP-8.0' into master
* PHP-8.0:
  7.3.25 is next
2020-10-13 09:56:32 +02:00
Alex Dowad a98838e3b6 Handle illegal bytes properly when converting to '7bit' encoding
Previously, mbstring would silently drop illegal bytes when converting a
string to '7bit' encoding.
2020-10-13 06:12:38 +02:00
Alex Dowad 4aa7430f68 Add mbstring identify filter for '7bit' encoding 2020-10-13 06:12:38 +02:00
Alex Dowad 0ffc1f55b3 Refactor mbfl_ident.c, mbfl_encoding.c, mbfl_memory_device.c, mbfl_string.c
- Make everything less gratuitously verbose
- Don't litter the code with lots of unneeded NULL checks (for things which
  will never be NULL)
- Don't return success/failure code from functions which can never fail
- For encoding structs, don't use pointers to pointers to pointers for the
  list of alias strings. Pointers to pointers (2 levels of indirection)
  is what actually makes sense. This gets rid of some extraneous
  dereference operations.
2020-10-13 06:12:38 +02:00
Alex Dowad e8b8ecbd4e Remove useless constants MBFL_CHP_{CTL,DIGIT,UALPHA,LALPHA,MSPECIAL} 2020-10-13 06:12:37 +02:00
Alex Dowad aabbee2318 Remove useless validity check when converting UTF-16LE -> wchar
The check ensures that the decoded codepoint is between 0x10000-0x10FFFF,
which is the valid range which can be encoded in a UTF-16 surrogate pair.
However, just looking at the code, it's obvious that this will be true.
First of all, 0x10000 is added to the decoded codepoint on the previous
line, so how could it be less than 0x10000?

Further, even if the 20 data bits already decoded were 0xFFFFF (all ones),
when you add 0x10000, it comes to 0x10FFFF, which is the very top of the
valid range. So how could the decoded codepoint be more than 0x10FFFF?
It can't.
2020-10-13 06:12:37 +02:00
Alex Dowad f474e5502c Refactor UTF-16LE -> wchar conversion code 2020-10-13 06:12:37 +02:00
Alex Dowad 3f1851dec2 Avoid compiler warnings related to mbstring flush functions 2020-10-13 06:12:37 +02:00
Christoph M. Becker d523de69d7 Merge branch 'PHP-8.0' into master
* PHP-8.0:
  Fix #80226: imap_sort() leaks sortpgm memory
2020-10-12 23:22:19 +02:00
Dmitry Stogov 9c3c67b1bf Merge branch 'PHP-8.0'
* PHP-8.0:
  Perform trace range propagation
2020-10-13 00:19:02 +03:00
Christoph M. Becker 51cb9b8373 Merge branch 'PHP-8.0' into master
* PHP-8.0:
  Change parameters types from int to bool
2020-10-12 23:10:41 +02:00
Dmitry Stogov 1fe1a58268 Merge branch 'PHP-8.0'
* PHP-8.0:
  Eliminate dead stores
2020-10-12 22:59:48 +03:00
Máté Kocsis 270def3d91 Merge branch 'PHP-8.0' 2020-10-12 18:09:08 +02:00
Nikita Popov 656c37abe2 Merge branch 'PHP-8.0'
* PHP-8.0:
  intl: report more information about message pattern parse errors
2020-10-12 16:44:46 +02:00
Nikita Popov c0b4dea858 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80225
2020-10-12 16:35:20 +02:00
Christoph M. Becker 8e4022b461 Merge branch 'PHP-8.0' into master
* PHP-8.0:
  Fix #80216: imap_mail_compose() does not validate types/encodings
2020-10-12 16:31:03 +02:00
Christoph M. Becker 2e17c937bf Merge branch 'PHP-8.0' into master
* PHP-8.0:
  Fix #80223: imap_mail_compose() leaks envelope on malformed bodies
2020-10-12 15:10:55 +02:00
Christoph M. Becker c3365bb301 Merge branch 'PHP-8.0' into master
* PHP-8.0:
  Fix #80220: imap_mail_compose() may leak memory
2020-10-12 13:34:42 +02:00
Nikita Popov e735de6eae Add GC support for PDO driver data
Add a get_gc method that can be implemented by drivers, which can
be used to add additional zvals to the GC buffer.

Implement GC support for PDO SQLite callbacks in particular.

Closes GH-6262.
2020-10-12 13:00:41 +02:00
Nikita Popov d731b764e5 Merge branch 'PHP-8.0'
* PHP-8.0:
  Revert "Add missing X509 purpose constants"
2020-10-12 12:56:30 +02:00
Nikita Popov 649505e751 Merge branch 'PHP-8.0'
* PHP-8.0:
  Add missing X509 purpose constants
2020-10-12 11:53:59 +02:00
Nikita Popov 14830ab2a3 Merge branch 'PHP-8.0'
* PHP-8.0:
  Detect self-addition of array more accurately
  Deindirect source elements in zend_hash_merge
2020-10-12 11:25:36 +02:00
Nikita Popov ed3f197f9f Merge branch 'PHP-8.0'
* PHP-8.0:
  Backport schedule in yaml
2020-10-12 10:07:01 +02:00
Nikita Popov 57721d6172 Merge branch 'PHP-8.0'
* PHP-8.0:
  Avoid non-object in FE_FREE
2020-10-12 09:47:22 +02:00
Christoph M. Becker d519e4500e Merge branch 'PHP-8.0' into master
* PHP-8.0:
  XMLReader::open() and XMLReader::xml() are now static
2020-10-11 18:50:49 +02:00
Christoph M. Becker 2451e937b5 Merge branch 'PHP-8.0' into master
* PHP-8.0:
  Remove return types from XMLWriter stubs
2020-10-11 18:23:26 +02:00
Derick Rethans 8bc29d963e Merge branch 'PHP-8.0' into master 2020-10-11 14:54:18 +01:00
Christoph M. Becker d2e5061901 Merge branch 'PHP-8.0' into master
* PHP-8.0:
  Fix #80215: imap_mail_compose() may modify by-val parameters
2020-10-10 23:29:11 +02:00
Christoph M. Becker e67814f67b Merge branch 'PHP-8.0' into master
* PHP-8.0:
  Fix #80213: imap_mail_compose() segfaults on certain $bodies
2020-10-10 19:20:13 +02:00
George Peter Banyard 49783e35f0 Add compiler flags which aren't included in -Wall or -Wextra
Adds the following compiler flags:
 . -Wduplicated-cond
 . -Wlogical-op
 . -Wformat-truncation
 . -fno-common

Closes GH-6199
2020-10-10 17:26:49 +01:00
George Peter Banyard 3c84f65683 Add -Wno-logical-op compiler flag to Sodium extension 2020-10-10 17:26:49 +01:00
Christoph M. Becker 08fd6e9bbe Merge branch 'PHP-8.0' into master
* PHP-8.0:
  Fix #80175: PHP8 RC1 - JIT Buffer not working
2020-10-10 17:47:19 +02:00
Christoph M. Becker 2583b18c4a Merge branch 'PHP-8.0' into master
* PHP-8.0:
  Change imap_mail_compose() $body param to $bodies
2020-10-10 17:40:26 +02:00
George Peter Banyard 150ebfdf77 Suppress bogus [-Wlogical-op] warning from GCC
See GCC bug 69602: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69602
which emits the warning for (errno == EWOULDBLOCK || errno == EAGAIN)
which is the correct way of handling errors as the value of EWOULDBLOCK
and EAGAIN is implementation defined.

Therefore introduce a new macro function PHP_IS_TRANSIENT_ERROR()
which handles the case when EWOULDBLOCK and EAGAIN are identical.

Thanks to @twose for the idea.
2020-10-10 14:45:20 +01:00
George Peter Banyard f211f1586f Fix [-Wlogical-op] in IMAP 2020-10-10 14:45:02 +01:00
Nikita Popov 1bd4d77eb6 Merge branch 'PHP-8.0'
* PHP-8.0:
  Don't specify symfony branch
2020-10-10 11:09:00 +02:00
George Peter Banyard a29b4a7bea Fix [-Wduplicated-branches] in CLI SAPI 2020-10-09 20:54:39 +01:00
George Peter Banyard 3b22b5fdf6 Fix [-Wduplicated-cond] in MySQLnd driver
Changing it to TYPE_C as this is the only other type in the mysqlnd_buffered_type enum
2020-10-09 20:54:23 +01:00
George Peter Banyard fd1672a7f3 Fix [-Wduplicated-cond] in MBString extension 2020-10-09 20:54:23 +01:00
Dmitry Stogov cfba35c5ad Merge branch 'PHP-8.0'
* PHP-8.0:
  Eliminate dead load
2020-10-09 18:58:25 +03:00
Nikita Popov e7ae0af9f5 Merge branch 'PHP-8.0'
* PHP-8.0:
  Update ext/gd parameter names
2020-10-09 17:10:30 +02:00
Nikita Popov 5c39ac8ef5 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80186
2020-10-09 17:02:40 +02:00
Nikita Popov ad22b72d2f Merge branch 'PHP-8.0'
* PHP-8.0:
  Update to mime-db 1.45
2020-10-09 16:22:55 +02:00
Nikita Popov 77d4fd437d Merge branch 'PHP-8.0'
* PHP-8.0:
  Remove string length limit from levenshtein()
2020-10-09 16:12:44 +02:00
Nikita Popov f351c47154 Merge branch 'PHP-8.0'
* PHP-8.0:
  Add support for Solaris 11.4 openpty implementation.
2020-10-09 16:10:26 +02:00
Dmitry Stogov 7cdce0252f Merge branch 'PHP-8.0'
* PHP-8.0:
  Keep the same JIT code for PHP-8.0 and master (workaround against PHP-8.0 ABI freeze)
2020-10-09 17:00:43 +03:00
Nikita Popov 1af7c9b372 Add scheduled builds to yaml pipeline
Not sure if this is going to work, as the UI configured scheduled
builds are supposed to take precedence ... but I have no idea
how to access them.
2020-10-09 15:56:44 +02:00
Nikita Popov 64862d15ea Merge branch 'PHP-8.0'
* PHP-8.0:
  Enable Azure pipeline builds on PHP-8.0
2020-10-09 15:31:02 +02:00
Nikita Popov 05c1ab294a Merge branch 'PHP-8.0'
* PHP-8.0:
  Make iconv errno support test pass on Solaris.
2020-10-09 15:25:31 +02:00
Dmitry Stogov e0942d2d7c Merge branch 'PHP-8.0'
* PHP-8.0:
  Eliminate more dead type stores
2020-10-09 16:15:20 +03:00
Patrick Allaert 15a92e8d7a Removed broken php_url_encode_hash macro
Broken since ~15 years ago (2994c23670)

Closes GH-6253.
2020-10-09 15:08:29 +02:00
Nikita Popov 3f392b6ba8 Merge branch 'PHP-8.0'
* PHP-8.0:
  Revert "Change calling convention of zval_update_constant[_ex]() to fastcall."
2020-10-09 15:07:20 +02:00
Nikita Popov 6c74e081db Merge branch 'PHP-8.0'
* PHP-8.0:
  XFAIL test broken by timelib update
2020-10-09 14:05:41 +02:00
Dmitry Stogov af0208f296 Merge branch 'PHP-8.0'
* PHP-8.0:
  Eliminate more dead type stores
2020-10-09 14:31:30 +03:00
Gabriel Caruso 14806e0824 Prepare for PHP 8.1
Closes GH-6305.
2020-10-09 11:37:27 +02:00
5888 changed files with 420844 additions and 255302 deletions

No files matched your search

+28
View File
@@ -0,0 +1,28 @@
env:
CIRRUS_CLONE_DEPTH: 1
ARCH: amd64
freebsd_instance:
image_family: freebsd-13-0
task:
name: FREEBSD_DEBUG_NTS
install_script:
#- sed -i -e 's/quarterly/latest/g' /etc/pkg/FreeBSD.conf
#- pkg upgrade -y
- kldload accf_http
- pkg install -y autoconf bison gmake re2c icu libiconv png freetype2 enchant2 bzip2 krb5 t1lib gmp tidyp libsodium libzip libxml2 libxslt openssl oniguruma pkgconf webp
script:
- ./buildconf -f
- ./configure --prefix=/usr/local --enable-debug --enable-option-checking=fatal --enable-fpm --with-pdo-sqlite --without-pear --with-bz2 --with-jpeg --with-webp --with-freetype --enable-gd --enable-exif --with-zip --with-zlib --enable-soap --enable-xmlreader --with-xsl --with-libxml --enable-shmop --enable-pcntl --enable-mbstring --with-curl --enable-sockets --with-openssl --with-iconv=/usr/local --enable-bcmath --enable-calendar --enable-ftp --with-kerberos --with-ffi --enable-zend-test --enable-intl --with-mhash --with-sodium --enable-werror --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d
- gmake -j2
- mkdir /etc/php.d
- gmake install
- echo opcache.enable_cli=1 > /etc/php.d/opcache.ini
- echo opcache.protect_memory=1 >> /etc/php.d/opcache.ini
# Specify opcache.preload_user as we're running as root.
- echo opcache.preload_user=root >> /etc/php.d/opcache.ini
tests_script:
- export SKIP_IO_CAPTURE_TESTS=1
- export CI_NO_IPV6=1
- sapi/cli/php run-tests.php -P -q -j2 -g FAIL,XFAIL,BORK,WARN,LEAK,XLEAK,SKIP --offline --show-diff --show-slow 1000 --set-timeout 120 -d zend_extension=opcache.so
+1 -3
View File
@@ -11,9 +11,7 @@ end
define ____executor_globals
if basic_functions_module.zts
if !$tsrm_ls
set $tsrm_ls = ts_resource_ex(0, 0)
end
set $tsrm_ls = _tsrm_ls_cache
set $eg = ((zend_executor_globals*) (*((void ***) $tsrm_ls))[executor_globals_id-1])
set $cg = ((zend_compiler_globals*) (*((void ***) $tsrm_ls))[compiler_globals_id-1])
set $eg_ptr = $eg
+3
View File
@@ -41,6 +41,9 @@
# Standard object files generated during build process
*.o
# Dependency files generated during build process
*.dep
# Cache directories created by Autoconf tools
autom4te.cache/
+4 -7
View File
@@ -68,14 +68,11 @@ env:
jobs:
include:
- env: ENABLE_ZTS=0 ENABLE_DEBUG=0
arch: amd64
if: type = cron
- env: ENABLE_ZTS=1 ENABLE_DEBUG=1
arch: amd64
if: type = cron
- env: ENABLE_ZTS=1 ENABLE_DEBUG=1 SKIP_IO_CAPTURE_TESTS=1 ARM64=1
arch: arm64
arch: arm64-graviton2
dist: bionic
virt: lxd
group: edge
if: type = cron
- env: ENABLE_ZTS=1 ENABLE_DEBUG=1 SKIP_IO_CAPTURE_TESTS=1 S390X=1
arch: s390x
+1 -1
View File
@@ -3,7 +3,7 @@
This file lists several standards that any programmer adding or changing code in
PHP should follow. Since this file was added at a very late stage of the
development of PHP v3.0, the code base does not fully follow it, but new
features are going in that general direction. Many sections have been recoded to
features are going in that general direction. Many sections have been rewritten to
use these rules.
## Code implementation
+4 -4
View File
@@ -135,6 +135,7 @@ locations.
├─ .git/ # Git configuration and source directory
├─ TSRM/ # Thread Safe Resource Manager
└─ Zend/ # Zend Engine
├─ asm/ # Bundled from src/asm in https://github.com/boostorg/context
├─ zend_vm_execute.h # Generated by `Zend/zend_vm_gen.php`
├─ zend_vm_opcodes.c # Generated by `Zend/zend_vm_gen.php`
├─ zend_vm_opcodes.h # Generated by `Zend/zend_vm_gen.php`
@@ -146,6 +147,7 @@ locations.
├─ config.sub # https://git.savannah.gnu.org/cgit/config.git
├─ libtool.m4 # https://git.savannah.gnu.org/cgit/libtool.git
├─ ltmain.sh # https://git.savannah.gnu.org/cgit/libtool.git
├─ pkg.m4 # https://gitlab.freedesktop.org/pkg-config/pkg-config
├─ shtool # https://www.gnu.org/software/shtool/
└─ ...
├─ docs/ # PHP internals and repository documentation
@@ -327,7 +329,8 @@ Currently we have the following branches in use:
| Branch | |
| --------- | --------- |
| master | Active development branch for PHP 8.0, which is open for backwards incompatible changes and major internal API changes. |
| master | Active development branch for PHP 8.1, which is open for backwards incompatible changes and major internal API changes. |
| PHP-8.0 | Is used to release the PHP 8.0.x series. This is a current stable version and is open for bugfixes only. |
| PHP-7.4 | Is used to release the PHP 7.4.x series. This is a current stable version and is open for bugfixes only. |
| PHP-7.3 | Is used to release the PHP 7.3.x series. This is a current stable version and is open for bugfixes only. |
| PHP-7.2 | Is used to release the PHP 7.2.x series. This is an old stable version and is open for security fixes only. |
@@ -397,9 +400,6 @@ Example:
When you change the NEWS file for a bug fix, then please keep the bugs sorted in
decreasing order under the fixed version.
You can use [gitweb](https://git.php.net/) to look at PHP Git repository in
various ways.
## Copyright and license headers
New source code files should include the following header block:
+104 -615
View File
@@ -1,650 +1,139 @@
PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? 2021, PHP 8.0.4
?? ??? ????, PHP 8.1.0alpha1
- Core:
. Fixed bug #75776 (Flushing streams with compression filter is broken). (cmb)
. Fixed bug #80811 (Function exec without $output but with $restult_code
parameter crashes). (Nikita)
. Fixed bug #80814 (threaded mod_php won't load on FreeBSD: No space
available for static Thread Local Storage). (Dmitry)
- Dba:
. Fixed bug #80817 (dba_popen() may cause segfault during RSHUTDOWN). (cmb)
- IMAP:
. Fixed bug #80800 (imap_open() fails when the flags parameter includes
CL_EXPUNGE). (girgias)
- Intl:
. Fixed bug #80763 (msgfmt_format() does not accept DateTime references).
(cmb)
- Libxml:
. Fixed bug #51903 (simplexml_load_file() doesn't use HTTP headers). (cmb)
- MySQLnd:
. Fixed bug #80837 (Calling stmt_store_result after fetch doesn't throw an
error). (Kamil Tekiela)
- Opcache:
. Fixed bug #80786 (PHP crash using JIT). (Nikita)
. Fixed bug #80782 (DASM_S_RANGE_VREG on PHP_INT_MIN-1). (Dmitry)
- PCRE:
. Fixed bug #80866 (preg_split ignores limit flag when pattern with \K has
0-width fullstring match). (Kamil Tekiela)
- Session:
. Fixed bug #80774 (session_name() problem with backslash). (cmb)
- Standard:
. Fixed bug #80771 (phpinfo(INFO_CREDITS) displays nothing in CLI). (cmb)
. Fixed bug #78719 (http wrapper silently ignores long Location headers).
(cmb)
. Fixed bug #80838 (HTTP wrapper waits for HTTP 1 response after HTTP 101).
(manuelm)
- Zip:
. Fixed bug #80825 (ZipArchive::isCompressionMethodSupported does not exist).
(cmb)
18 Feb 2021, PHP 8.0.3
- Core:
. Fixed #80706 (mail(): Headers after Bcc headers may be ignored). (cmb)
- DOM:
. Fixed bug #80600 (DOMChildNode::remove() doesn't work on CharacterData
nodes). (beberlei)
- Gettext:
. Fixed bug #53251 (bindtextdomain with null dir doesn't return old value).
(cmb)
- MySQLnd:
. Fixed bug #78680 (mysqlnd's mysql_clear_password does not transmit
null-terminated password). (Daniel Black)
. Fixed bug #80713 (SegFault when disabling ATTR_EMULATE_PREPARES and
MySQL 8.0). (Nikita)
- MySQLi:
. Fixed bug #74779 (x() and y() truncating floats to integers). (cmb)
- Opcache:
. Fixed bug #80634 (write_property handler of internal classes is skipped on
preloaded JITted code). (Dmitry)
. Fixed bug #80682 (opcache doesn't honour pcre.jit option). (Remi)
. Fixed bug #80742 (Opcache JIT makes some boolean logic unexpectedly be
true). (Dmitry)
. Fixed bug #80745 (JIT produces Assert failure and UNKNOWN:0 var_dumps in
code involving bitshifts). (Dmitry)
- OpenSSL:
. Fixed bug #80747 (Providing RSA key size < 512 generates key that crash
PHP). (Nikita)
- Phar:
. Fixed bug #75850 (Unclear error message wrt. __halt_compiler() w/o
semicolon) (cmb)
. Fixed bug #70091 (Phar does not mark UTF-8 filenames in ZIP archives). (cmb)
. Fixed bug #53467 (Phar cannot compress large archives). (cmb, lserni)
- Socket:
. Fixed bug #80723 (Different sockets compare as equal (regression in 8.0)).
(Nikita)
- SPL:
. Fixed bug#80719 (Iterating after failed ArrayObject::setIteratorClass()
causes Segmentation fault). (Nikita)
- Standard:
. Fixed bug #80654 (file_get_contents() maxlen fails above (2**31)-1 bytes).
(cmb)
. Fixed bug #80718 (ext/standard/dl.c fallback code path with syntax error).
(Nikita)
21 Jan 2021, PHP 8.0.2
- Core:
. Fixed bug #80523 (bogus parse error on >4GB source code). (Nikita)
. Fixed bug #80384 (filter buffers entire read until file closed). (Adam
Seitz, cmb)
. Fixed bug #80596 (Invalid union type TypeError in anonymous classes).
(Daniil Gentili)
. Fixed bug #80617 (GCC throws warning about type narrowing in
ZEND_TYPE_INIT_CODE). (Nikita)
- BCMath:
. Fixed bug #80545 (bcadd('a', 'a') doesn't throw an exception).
(Jens de Nies)
- Curl:
. Fixed bug #80595 (Resetting POSTFIELDS to empty array breaks request). (cmb)
. Fixed inclusion order for phpize builds on Windows. (cmb)
. Added missing hashtable insertion APIs for arr/obj/ref. (Sara)
. Fixed bug #75474 (function scope static variables are not bound to a unique
function). (Nikita)
. Fixed bug #53826 (__callStatic fired in base class through a parent call if
the method is private). (Nikita)
. Implemented FR #77372 (Relative file path is removed from uploaded file).
(Björn Tantau)
. Fixed bug #81076 (incorrect debug info on Closures with implicit binds).
(krakjoe)
- Standard:
. Fixed bug #77627 (method_exists on Closure::__invoke inconsistency).
(krakjoe)
- Date:
. Fixed bug #80376 (last day of the month causes runway cpu usage). (Derick)
- DOM:
. Fixed bug #80537 (Wrong parameter type in DOMElement::removeAttributeNode
stub). (Nikita)
- Filter:
. Fixed bug #80584 (0x and 0X are considered valid hex numbers by
filter_var()). (girgias)
- GMP:
. Fixed bug #80560 (Strings containing only a base prefix return 0 object).
(girgias)
- Intl:
. Fixed bug #80644 (Missing resource causes subsequent get() calls to fail).
(Nikita)
- MySQLi:
. Fixed bug #67983 (mysqlnd with MYSQLI_OPT_INT_AND_FLOAT_NATIVE fails to
interpret bit columns). (Nikita)
. Fixed bug #64638 (Fetching resultsets from stored procedure with cursor
fails). (Nikita)
. Fixed bug #72862 (segfault using prepared statements on stored procedures
that use a cursor). (Nikita)
. Fixed bug #77935 (Crash in mysqlnd_fetch_stmt_row_cursor when calling an SP
with a cursor). (Nikita)
- ODBC:
. Fixed bug #80592 (all floats are the same in ODBC parameters). (cmb)
- Opcache:
. Fixed bug #80422 (php_opcache.dll crashes when using Apache 2.4 with JIT).
(Dmitry)
- PDO_Firebird:
. Fixed bug #80521 (Parameters with underscores no longer recognized). (cmb,
Simonov Denis)
- Phar:
. Fixed bug #76929 (zip-based phar does not respect phar.require_hash).
(david at bamsoftware, cmb)
. Fixed bug #77565 (Incorrect locator detection in ZIP-based phars). (cmb)
. Fixed bug #69279 (Compressed ZIP Phar extractTo() creates garbage files).
(cmb)
- Phpdbg:
. Reverted fix for bug #76813 (Access violation near NULL on source operand).
(cmb)
07 Jan 2021, PHP 8.0.1
- Core:
. Fixed bug #80345 (PHPIZE configuration has outdated PHP_RELEASE_VERSION).
(cmb)
. Fixed bug #72964 (White space not unfolded for CC/Bcc headers). (cmb)
. Fixed bug #80391 (Iterable not covariant to mixed). (Nikita)
. Fixed bug #80393 (Build of PHP extension fails due to configuration gap
with libtool). (kir dot morozov at gmail dot com)
. Fixed bug #77069 (stream filter loses final block of data). (cmb)
- Fileinfo:
. Fixed bug #77961 (finfo_open crafted magic parsing SIGABRT). (cmb)
. Fixed bug #52480 (Incorrect difference using DateInterval) (Derick)
. Fixed bug #62326 (date_diff() function returns false result) (Derick)
. Fixed bug #64992 (dst not handled past 2038) (Derick)
. Fixed bug #65003 (Wrong date diff) (Derick)
. Fixed bug #66545 (DateTime. diff returns negative values) (Derick)
. Fixed bug #68503 (date_diff on two dates with timezone set localised
returns wrong results) (Derick)
. Fixed bug #69806 (Incorrect date from timestamp) (Derick)
. Fixed bug #71700 (Extra day on diff between begin and end of march 2016)
(Derick)
. Fixed bug #71826 (DateTime::diff confuse on timezone 'Asia/Tokyo') (Derick)
. Fixed bug #73460 (Datetime add not realising it already applied DST
change) (Derick)
. Fixed bug #74173 (DateTimeImmutable::getTimestamp() triggers DST switch in
incorrect time) (Derick)
. Fixed bug #74274 (Handling DST transitions correctly) (Derick)
. Fixed bug #74524 (Date diff is bad calculated, in same time zone) (Derick)
. Fixed bug #75167 (DateTime::add does only care about backward DST
transition, not forward) (Derick)
. Fixed bug #76032 (DateTime->diff having issues with leap days for
timezones ahead of UTC) (Derick)
. Fixed bug #76374 (Date difference varies according day time) (Derick)
. Fixed bug #77571 (DateTime's diff DateInterval incorrect in timezones from
UTC+01:00 to UTC+12:00 (Derick)
. Fixed bug #78452 (diff makes wrong in hour for Asia/Tehran) (Derick)
. Fixed bug #79452 (DateTime::diff() generates months differently between
time zones) (Derick)
. Fixed bug #79698 (timelib mishandles future timestamps (triggered by 'zic
-b slim')) (Derick)
. Fixed bug #79716 (Invalid date time created (with day "00")) (Derick)
. Fixed bug #80610 (DateTime calculate wrong with DateInterval) (Derick)
. Fixed bug #80664 (DateTime objects behave incorrectly around DST
transition) (Derick)
. Fixed bug #80913 (DateTime(Immutable)::sub around DST yield incorrect
time) (Derick)
- FPM:
. Fixed bug #69625 (FPM returns 200 status on request without
SCRIPT_FILENAME env). (Jakub Zelenka)
. Added openmetrics status format. (Cees-Jan Kiewiet)
. Enable process renaming on macOS. (devnexen)
. Added pm.max_spawn_rate option to configure max spawn child processes rate.
(Paulius Sapragonas)
. Fixed bug #65800 (Events port mechanism). (psumbera)
- IMAP
. Fixed bug #80438 (imap_msgno() incorrectly warns and return false on valid UIDs in PHP 8.0.0). (girgias)
. Fix a regression with valid UIDs in imap_savebody() (girgias)
. Make warnings for invalid message numbers/UIDs between functions consistent (girgias)
- Intl:
. Fixed bug #80425 (MessageFormatAdapter::getArgTypeList redefined). (Nikita)
- OCI8
. Create Windows DLLs for Oracle Client 19c. (cmb)
- Opcache:
. Fixed bug #80404 (Incorrect range inference result when division results
in float). (Nikita)
. Fixed bug #80377 (Opcache misses executor_globals). (Nikita)
. Fixed bug #80433 (Unable to disable the use of the AVX command when using
JIT). (Nikita)
. Fixed bug #80447 (Strange out of memory error when running with JIT).
(Dmitry)
. Fixed bug #80480 (Segmentation fault with JIT enabled). (Dmitry)
. Fixed bug #80506 (Immediate SIGSEGV upon ini_set("opcache.jit_debug", 1)).
(Dmitry)
- OpenSSL:
. Fixed bug #80368 (OpenSSL extension fails to build against LibreSSL due to
lack of OCB support). (Nikita)
- PDO MySQL:
. Fixed bug #80458 (PDOStatement::fetchAll() throws for upsert queries).
(Kamil Tekiela)
. Fixed bug #63185 (nextRowset() ignores MySQL errors with native prepared
statements). (Nikita)
. Fixed bug #78152 (PDO::exec() - Bad error handling with multiple commands).
(Nikita)
. Fixed bug #66878 (Multiple rowsets not returned unless PDO statement object
is unset()). (Nikita)
. Fixed bug #70066 (Unexpected "Cannot execute queries while other unbuffered
queries"). (Nikita)
. Fixed bug #71145 (Multiple statements in init command triggers unbuffered
query error). (Nikita)
. Fixed bug #76815 (PDOStatement cannot be GCed/closeCursor-ed when a
PROCEDURE resultset SIGNAL). (Nikita)
. Fixed bug #79872 (Can't execute query with pending result sets). (Nikita)
. Fixed bug #79131 (PDO does not throw an exception when parameter values are
missing). (Nikita)
. Fixed bug #72368 (PdoStatement->execute() fails but does not throw an
exception). (Nikita)
. Fixed bug #62889 (LOAD DATA INFILE broken). (Nikita)
. Fixed bug #67004 (Executing PDOStatement::fetch() more than once prevents
releasing resultset). (Nikita)
. Fixed bug #79132 (PDO re-uses parameter values from earlier calls to
execute()). (Nikita)
- Phar:
. Fixed bug #73809 (Phar Zip parse crash - mmap fail). (cmb)
. Fixed bug #75102 (`PharData` says invalid checksum for valid tar). (cmb)
. Fixed bug #77322 (PharData::addEmptyDir('/') Possible integer overflow).
(cmb)
- Phpdbg:
. Fixed bug #76813 (Access violation near NULL on source operand). (cmb)
- SPL:
. Fixed #62004 (SplFileObject: fgets after seek returns wrong line). (cmb)
- Standard:
. Fixed bug #77423 (FILTER_VALIDATE_URL accepts URLs with invalid userinfo).
(CVE-2020-7071) (cmb)
. Fixed bug #80366 (Return Value of zend_fstat() not Checked). (sagpant, cmb)
- Tidy:
. Fixed bug #77594 (ob_tidyhandler is never reset). (cmb)
- Tokenizer:
. Fixed bug #80462 (Nullsafe operator tokenize with TOKEN_PARSE flag fails).
(Nikita)
- XML:
. XmlParser opaque object renamed to XMLParser for consistency with other XML objects. (girgias)
- Zlib:
. Fixed #48725 (Support for flushing in zlib stream). (cmb)
26 Nov 2020, PHP 8.0.0
- BZ2:
. Fixed bug #71263 (fread() does not report bzip2.decompress errors). (cmb)
- CLI:
. Allow debug server binding to an ephemeral port via `-S localhost:0`. (Sara)
- COM:
. Fixed bug #55847 (DOTNET .NET 4.0 GAC new location). (cmb)
. Fixed bug #62474 (com_event_sink crashes on certain arguments). (cmb)
- Calendar:
. Fixed bug #80007 (Potential type confusion in unixtojd() parameter parsing).
(Andy Postnikov)
- Core:
. Fixed bug #36365 (scandir duplicates file name at every 65535th file).
(cmb)
. Fixed bug #49555 (Fatal error "Function must be a string" message should be
renamed). (Nikita)
. Fixed bug #62294 (register_shutdown_function() does not correctly handle
exit code). (Nikita)
. Fixed bug #62609 (Allow implementing Traversable on abstract classes).
(Nikita)
. Fixed bug #65274 (Enhance undefined class constant error with class name).
(Nikita)
. Fixed bug #65275 (Calling exit() in a shutdown function does not change the
exit value in CLI). (Nikita)
. Fixed bug #69084 (Unclear error message when not implementing a renamed
abstract trait function). (Nikita)
. Fixed bug #70839 (Converting optional argument to variadic forbidden by LSP
checks). (Nikita)
. Fixed bug #74558 (Can't rebind closure returned by Closure::fromCallable()).
(cmb)
. Fixed bug #77561 (Shebang line not stripped for non-primary script).
(Nikita)
. Fixed bug #77619 (Wrong reflection on MultipleIterator::__construct).
(Fabien Villepinte)
. Fixed bug #77966 (Cannot alias a method named "namespace"). (Nikita)
. Fixed bug #78236 (convert error on receiving variables when duplicate [).
(cmb)
. Fixed bug #78770 (Incorrect callability check inside internal methods).
(Nikita)
. Fixed bug #79108 (Referencing argument in a function makes it a reference
in the stack trace). (Nikita)
. Fixed bug #79368 ("Unexpected end of file" is not an acceptable error
message). (Alex Dowad)
. Fixed bug #79462 (method_exists and property_exists incoherent behavior).
(cmb)
. Fixed bug #79467 (data:// wrappers are writable). (cmb)
. Fixed bug #79521 (Check __set_state structure). (carusogabriel)
. Fixed bug #79790 ("Illegal offset type" exception during AST evaluation
not handled properly). (Nikita)
. Fixed bug #79791 (Assertion failure when unsetting variable during binary
op). (Nikita)
. Fixed bug #79828 (Segfault when trying to access non-existing variable).
(Nikita)
. Fixed bug #79841 (Syntax error in configure / unescaped "[]" in php.m4).
(Nikita)
. Fixed bug #79852 (count(DOMNodeList) doesn't match
count(IteratorIterator(DOMNodeList))). (Nikita)
. Fixed bug #79867 (Promoted untyped properties should get null default
value). (Nikita)
. Fixed bug #79897 (Promoted constructor params with attribs cause crash).
(Deus Kane)
. Fixed bug #79927 (Generator doesn't throw exception after multiple yield
from iterable). (Nikita)
. Fixed bug #79946 (Build fails due to undeclared UINT32_C). (Nikita)
. Fixed bug #79948 (Exit in auto-prepended file does not abort PHP execution).
(Nikita)
. Fixed bug #80045 (memleak after two set_exception_handler calls with
__call). (Nikita)
. Fixed bug #80096 (Segmentation fault with named arguments in nested call).
(Nikita)
. Fixed bug #80109 (Cannot skip arguments when extended debug is enabled).
(Nikita)
. Fixed bug #80225 (broken namespace usage in eval code). (Nikita)
. Fixed bug #80258 (Windows Deduplication Enabled, randon permission errors).
(cmb)
. Fixed bug #80280 (ADD_EXTENSION_DEP() fails for ext/standard and ext/date).
(cmb)
. Fixed bug #80334 (assert() vs named parameters - confusing error). (Nikita)
. Fixed bug #80055 (Abstract trait methods returning "self" cannot be
fulfilled by traits). (Nikita)
. Fixed faulty generator cleanup with yield from. (Bob)
. Implement #[Attr] Attribute syntax as per final vote in RFC
https://wiki.php.net/rfc/shorter_attribute_syntax_change
. Implemented FR #47074 (phpinfo() reports "On" as 1 for the some
extensions). (cmb)
. Implemented FR #72089 (require() throws fatal error instead of exception).
(Nikita)
. Removed the pdo_odbc.db2_instance_name php.ini directive. (Kalle)
. Use SSE2 instructions do locale independent strtolower. (Laruence)
- Curl:
. Bumped required libcurl version to 7.29.0. (cmb)
. Fixed bug #80121 (Null pointer deref if CurlHandle directly instantiated).
(Nikita)
- DOM:
. Add property DOMXPath::$registerNodeNamespaces and constructor argument
that allow global flag to configure query() or evaluate() calls.
. Fixed bug #79968 (DOMChildNode API crash on unattached nodes). (Benjamin)
. Fixed bug #80268 (loadHTML() truncates at NUL bytes). (cmb)
- Date:
. Fixed bug #60302 (DateTime::createFromFormat should new static(), not new
self()). (Derick)
. Fixed bug #65547 (Default value for sunrise/sunset zenith still wrong).
(cmb)
. Fixed bug #69044 (discrepancy between time and microtime). (krakjoe)
. Fixed bug #80057 (DateTimeImmutable::createFromFormat() does not populate
time). (Derick)
. Implemented FR #79903 (datetime: new format "p", same as "P" but returning
"Z" for UTC). (gharlan)
- Enchant:
. Add LIBENCHANT_VERSION macro.
. Add enchant_dict_add and enchant_dict_is_added functions.
. Deprecate enchant_broker_set_dict_path, enchant_broker_get_dict_path,
enchant_dict_add_to_personal and enchant_dict_is_in_session.
. Use libenchant-2 when available.
- FFI:
. Added FFI\CType::getName() method. (chopins)
. Fixed bug #79177 (FFI doesn't handle well PHP exceptions within callback).
(cmb, Dmitry, Nikita)
. Fixed bug #79749 (Converting FFI instances to bool fails). (cmb)
- FPM:
. Add pm.status_listen option. (Jakub Zelenka)
- Fileinfo:
. Upgrade to libmagic 5.39. (Anatol)
- FTP:
. Convert resource<ftp> to object \FTP\Connection. (Sara)
- GD:
. Added imagegetinterpolation(). (cmb)
. Fixed bug #55005 (imagepolygon num_points requirement). (cmb)
. Made the $num_points parameter of php_imagepolygon optional. (cmb)
. Removed deprecated image2wbmp(). (cmb)
. Removed deprecated png2wbmp() and jpeg2wbmp(). (cmb)
. Replaced gd resources with objects. (Mark Randall)
. Convert resource<gd font> to object \GdFont. (Sara)
- IMAP:
. Fixed bug #64076 (imap_sort() does not return FALSE on failure). (cmb)
. Fixed bug #76618 (segfault on imap_reopen). (girgias)
. Fixed bug #80213 (imap_mail_compose() segfaults on certain $bodies). (cmb)
. Fixed bug #80215 (imap_mail_compose() may modify by-val parameters). (cmb)
. Fixed bug #80216 (imap_mail_compose() does not validate types/encodings).
(cmb)
. Fixed bug #80220 (imap_mail_compose() may leak memory). (cmb)
. Fixed bug #80223 (imap_mail_compose() leaks envelope on malformed bodies).
(cmb)
. Fixed bug #80226 (imap_sort() leaks sortpgm memory). (cmb)
. Fixed bug #80239 (imap_rfc822_write_address() leaks memory). (cmb)
. Fixed bug #80242 (imap_mail_compose() segfaults for multipart with rfc822).
(cmb)
. Fixed minor regression caused by fixing bug #80220. (cmb)
- Iconv:
. Dropped support for iconv without proper errno setting. (cmb)
- Intl:
. Removed deprecated INTL_IDNA_VARIANT_2003. (cmb)
- JIT:
. Fixed bug #77857 (Wrong result if executed with JIT). (Laruence)
. Fixed bug #79255 (PHP cannot be compiled with enable JIT).
(Laruence, Dmitry)
. Fixed bug #79582 (Crash seen when opcache.jit=1235 and
opcache.jit_debug=2). (Laruence)
. Fixed bug #79743 (Fatal error when assigning to array property
with JIT enabled). (Laruence)
. Fixed bug #79864 (JIT segfault in Symfony OptionsResolver). (Dmitry)
. Fixed bug #79888 (Incorrect execution with JIT enabled). (Dmitry)
- JSON:
. The JSON extension is now an integral part of PHP and cannot be disabled
as per RFC: https://wiki.php.net/rfc/always_enable_json (tandre)
- hash:
. Implemented FR #68109 (Add MurmurHash V3). (Anatol, Michael)
. Implemented FR #73385 (Add xxHash support). (Anatol)
- LDAP:
. Fixed memory leaks. (ptomulik)
. Removed deprecated ldap_sort. (mcmic)
- MBString:
. Fixed bug #76999 (mb_regex_set_options() return current options). (cmb)
. Removed the unused $is_hex parameter from mb_decode_numericentity(). (cmb)
. Convert resource<ldap link> to object \LDAP\Connection. (Máté)
. Convert resource<ldap result> to object \LDAP\Result. (Máté)
. Convert resource<ldap result entry> to object \LDAP\ResultEntry. (Máté)
- MySQLi:
. Fixed bug #76809 (SSL settings aren't respected when persistent connections
are used). (fabiomsouto)
. Fixed bug #70372 (Emulate mysqli_fetch_all() for libmysqlclient). (Nikita)
. Fixed bug #80330 (Replace language in APIs and source code/docs).
(Darek Ślusarczyk)
. Fixed bug #80329 (Add option to specify LOAD DATA LOCAL white list folder
(including libmysql)). (Darek Ślusarczyk)
- Mysqlnd:
. Fixed #60594 (mysqlnd exposes 160 lines of stats in phpinfo). (PeeHaa)
- MySQLnd:
. Fixed bug #80761 (PDO uses too much memory). (Nikita)
- OCI8:
. Deprecated old OCI8 function aliases. (Jens de Nies)
. Modernized oci_register_taf_callback() callable argument parsing
implementation. (girgias)
. Removed obsolete no-op function oci_internal_debug(). (Jens de Nies)
- ODBC:
. Fixed bug #22986 (odbc_connect() may reuse persistent connection). (cmb)
. Fixed bug #44618 (Fetching may rely on uninitialized data). (cmb)
- Opcache:
. Fixed bug #76535 (Opcache does not replay compile-time warnings). (Nikita)
. Fixed bug #78654 (Incorrectly computed opcache checksum on files with
non-ascii characters). (mhagstrand)
. Fixed bug #79665 (ini_get() and opcache_get_configuration() inconsistency).
(cmb)
. Fixed bug #80030 (Optimizer segfault with isset on static property with
undef dynamic class name). (Nikita)
. Fixed bug #80175 (PHP8 RC1 - JIT Buffer not working). (cmb)
. Fixed bug #80184 (Complex expression in while / if statements resolves to
false incorrectly). (Nikita)
. Fixed bug #80255 (Opcache bug (bad condition result) in 8.0.0rc1). (Nikita)
. Fixed run-time binding of preloaded dynamically declared function. (Dmitry)
- OPcache:
. Added inheritance cache. (Dmitry)
- OpenSSL:
. Added Cryptographic Message Syntax (CMS) support. (Eliot Lear)
. Bump minimal OpenSSL version to 1.0.2. (Jakub Zelenka)
- PCRE:
. Don't ignore invalid escape sequences. (sjon)
. Updated to PCRE2 10.35. (cmb)
. Bundled PCRE2 is 10.37.
- PDO:
. Changed default PDO error mode to exceptions. (AllenJB)
. Fixed bug #77849 (Disable cloning of PDO handle/connection objects).
(camporter)
. Fixed bug #40913 (PDO_MYSQL: PDO::PARAM_LOB does not bind to a stream for
fetching a BLOB). (Nikita)
- PDO_Firebird:
. Fixed bug #64937 (Firebird PDO preprocessing sql). (Simonov Denis)
. PDO MySQL:
. Fixed bug #80908 (PDO::lastInsertId() return wrong). (matt)
. Fixed bug #81037 (PDO discards error message text from prepared
statement). (Kamil Tekiela)
- PDO_OCI:
. Added support for setting and getting the oracle OCI 18c call timeout.
(camporter)
. PDO ODBC:
. Implement PDO_ATTR_SERVER_VERSION and PDO_ATTR_SERVER_INFO for
PDO::getAttribute(). (Calvin Buckley)
- PDO_PGSQL:
. Bumped required libpq version to 9.1. (cmb)
. PDO SQLite:
. Fixed bug #38334 (Proper data-type support for PDO_SQLITE). (Nikita)
- PGSQL:
. Bumped required libpq version to 9.1. (cmb)
- PgSQL:
. Convert resource<pgsql link> to object \PgSql\Connection. (Máté)
. Convert resource<pgsql result> to object \PgSql\Result. (Máté)
. Convert resource<pgsql large object> to object \PgSql\Lob. (Máté)
- Phpdbg:
. Fixed bug #76596 (phpdbg support for display_errors=stderr). (kabel)
. Fixed bug #76801 (too many open files). (alekitto)
. Fixed bug #77800 (phpdbg segfaults on listing some conditional breakpoints).
(krakjoe)
. Fixed bug #77805 (phpdbg build fails when readline is shared). (krakjoe)
- PSpell:
. Convert resource<pspell> to object \PSpell\Dictionary. (Sara)
. Convert resource<pspell config> to object \PSpell\Config. (Sara)
- readline:
. Fixed bug #72998 (invalid read in readline completion). (krakjoe)
- Reflection:
. Fixed bug #64592 (ReflectionClass::getMethods() returns methods out of
scope). (Nikita)
. Fixed bug #69180 (Reflection does not honor trait conflict resolution /
method aliasing). (Nikita)
. Fixed bug #74939 (Nested traits' aliased methods are lowercased). (Nikita)
. Fixed bug #77325 (ReflectionClassConstant::$class returns wrong class when
extending). (Nikita)
. Fixed bug #78697 (ReflectionClass::implementsInterface - inaccurate error
message with traits). (villfa)
. Fixed bug #80190 (ReflectionMethod::getReturnType() does not handle static
as part of union type). (Nikita)
. Fixed bug #80299 (ReflectionFunction->invokeArgs confused in arguments).
(Nikita)
. Fixed bug #80370 (getAttributes segfault on dynamic properties). (Benjamin
Eberlei)
. Implement #79628 (Add $filter parameter for ReflectionClass::getConstants
and ReflectionClass::getReflectionConstants) (carusogabriel)
. Implement ReflectionProperty::hasDefaultValue and
Reflection::getDefaultValue (beberlei)
- SNMP:
. Fixed bug #70461 (disable md5 code when it is not supported in net-snmp).
(Alexander Bergmann, cmb)
- SPL:
. Fixed bug #65006 (spl_autoload_register fails with multiple callables using
self, same method). (Nikita)
. Fixed bug #65387 (Circular references in SPL iterators are not garbage
collected). (Nikita)
. Fixed bug #71236 (Second call of spl_autoload_register() does nothing if it
has no arguments). (Nikita)
. Fixed bug #79987 (Memory leak in SplFileInfo because of missing
zend_restore_error_handling()). (Dmitry)
. SplFixedArray is now IteratorAggregate rather than Iterator. (alexdowad)
- SQLite3:
. Added SQLite3::setAuthorizer() and respective class constants. (bohwaz)
- Session:
. Fixed bug #73529 (session_decode() silently fails on wrong input). (cmb)
. Fixed bug #78624 (session_gc return value for user defined session
handlers). (bshaffer)
- Shmop:
. Converted shmop resources to objects. (cmb)
- SimpleXML:
. Fixed bug #63575 (Root elements are not properly cloned). (cmb)
. Fixed bug #75245 (Don't set content of elements with only whitespaces).
(eriklundin)
. Implement ReflectionFunctionAbstract::getClosureUsedVariables (krakjoe)
- Sodium:
. Fixed bug #77646 (sign_detached() strings not terminated). (Frank)
. Added the XChaCha20 stream cipher functions. (P.I.E. Security Team)
. Added the Ristretto255 functions, which are available in libsodium 1.0.18.
(P.I.E. Security Team)
- Standard:
. Don't force rebuild of symbol table, when populating $http_response_header
variable by the HTTP stream wrapper. (Dmitry)
. Fixed bug #47983 (mixed LF and CRLF line endings in mail()). (cmb)
. Fixed bug #64060 (lstat_stat_variation7.phpt fails on certain file systems).
(M. Voelker, cmb)
. Fixed bug #75902 (str_replace should warn when misused with nested arrays).
(Nikita)
. Fixed bug #76859 (stream_get_line skips data if used with data-generating
filter). (kkopachev)
. Fixed bug #77204 (getimagesize(): Read error! should mention file path).
(peter279k)
. Fixed bug #78385 (parse_url() does not include 'query' when question mark
is the last char). (Islam Israfilov)
. Fixed bug #79868 (Sorting with array_unique gives unwanted result). (Nikita)
. Fixed bug #80256 (file_get_contents strip first line with chunked encoding
redirect). (Nikita)
. Fixed bug #80266 (parse_url silently drops port number 0). (cmb, Nikita)
. Fixed bug #80290 (Double free when ASSERT_CALLBACK is used with a dynamic
message). (Nikita)
. Implemented FR #78638 (__PHP_Incomplete_Class should be final). (Laruence)
. Made quoting of cmd execution functions consistent. (cmb)
- Tidy:
. Removed the unused $use_include_path parameter from tidy_repair_string().
(cmb)
- Tokenizer:
. Fixed bug #80328 (PhpToken::getAll() confusing name). (Nikita)
- XML:
. Fixed bug #76874 (xml_parser_free() should never leak memory). (Nikita)
- XMLWriter:
. Changed functions to accept/return XMLWriter objects instead of resources.
(cmb)
. Implemented FR #79344 (xmlwriter_write_attribute_ns: $prefix should be
nullable). (cmb)
. Removed return types from XMLWriter stubs. (cmb)
- Zip:
. Add "flags" options to ZipArchive::addGlob and addPattern methods
keeping previous behavior having FL_OVERWRITE by default. (Remi)
. Add ZipArchive::EM_UNKNOWN and ZipArchive::EM_TRAD_PKWARE constants. (Remi)
. Add ZipArchive::isCompressionMethodSupported() and
ZipArchive::isEncryptionMethodSupported() method (libzip 1.7.0). (Remi)
. Add ZipArchive::replaceFile() method. (Remi)
. Add ZipArchive::setCancelCallback method (since libzip 1.6.0). (Remi)
. Add ZipArchive::setMtimeName and ZipArchive::setMtimeIndex methods. (Remi)
. Add ZipArchive::setProgressCallback method (since libzip 1.3.0). (Remi)
. Add lastId property to ZipArchive. (Remi)
. Add optional "flags" parameter to ZipArchive::addEmptyDir, addFile and
addFromString methods. (Remi)
. Fixed bug #50678 (files extracted by ZipArchive class lost their
original modified time). (Remi)
. Fixed bug #72374 (remove_path strips first char of filename). (tyage, Remi)
. Implemented FR #77960 (add compression / encryption options for
ZipArchive::addGlob and ZipArchive::addPattern). (Remi)
. ZipArchive::status and ZipArchive::statusSys properties and
ZipArchive::getStatusString() method stay valid after the archive
is closed. (Remi)
- Zlib:
. Fixed bug #71417 (fread() does not report zlib.inflate errors). (cmb)
. Fixed bug #78792 (zlib.output_compression disabled by Content-Type: image/).
(cmb)
- SPL:
. Fixed bug #80724 (FilesystemIterator::FOLLOW_SYMLINKS remove KEY_AS_FILE
from bitmask). (Cameron Porter)
<<< NOTE: Insert NEWS from last stable release here prior to actual release! >>>
+11 -9
View File
@@ -40,12 +40,17 @@ For other systems, see the [installation chapter](https://php.net/install).
*For Windows, see [Build your own PHP on Windows](https://wiki.php.net/internals/windows/stepbystepbuild_sdk_2).*
For a minimal PHP build from Git, you will need autoconf, bison, and re2c. For
a default build, you will additionally need libxml2 and libsqlite3. On Ubuntu,
you can install these using:
a default build, you will additionally need libxml2 and libsqlite3.
On Ubuntu, you can install these using:
sudo apt install -y pkg-config build-essential autoconf bison re2c \
libxml2-dev libsqlite3-dev
On Fedora, you can install these using:
sudo dnf install re2c bison autoconf make libtool ccache libxml2-devel sqlite-devel
Generate configure:
./buildconf
@@ -98,10 +103,8 @@ Extension Community Library - [PECL](https://pecl.php.net).
## Contributing
The PHP source code is located in the Git repository at
[git.php.net](https://git.php.net). Contributions are most welcome by forking
the [GitHub mirror repository](https://github.com/php/php-src) and sending a
pull request.
Contributions are most welcome by forking the
[GitHub repository](https://github.com/php/php-src) and sending a pull request.
Discussions are done on GitHub, but depending on the topic can also be relayed
to the official PHP developer mailing list internals@lists.php.net.
@@ -122,9 +125,8 @@ ticket at [bugs.php.net](https://bugs.php.net) and reference the bug id using
magic_quotes behavior and therefore should not raise a warning at any time.
The patch removes this warning.
Pull requests are not merged directly on GitHub. All PRs will be pulled and
pushed through [git.php.net](https://git.php.net). See
[Git workflow](https://wiki.php.net/vcs/gitworkflow) for more details.
See [Git workflow](https://wiki.php.net/vcs/gitworkflow) for more details on the
pull request workflow.
### Guidelines for contributors
+15
View File
@@ -741,6 +741,21 @@ TSRM_API size_t tsrm_get_ls_cache_tcb_offset(void)
asm ("leal _tsrm_ls_cache@ntpoff,%0"
: "=r" (ret));
return ret;
#elif defined(__aarch64__)
size_t ret;
# ifdef __APPLE__
// Points to struct TLVDecriptor for _tsrm_ls_cache in macOS.
asm("adrp %0, #__tsrm_ls_cache@TLVPPAGE\n\t"
"ldr %0, [%0, #__tsrm_ls_cache@TLVPPAGEOFF]"
: "=r" (ret));
# else
asm("mov %0, xzr\n\t"
"add %0, %0, #:tprel_hi12:_tsrm_ls_cache, lsl #12\n\t"
"add %0, %0, #:tprel_lo12_nc:_tsrm_ls_cache"
: "=r" (ret));
# endif
return ret;
#else
return 0;
#endif
+1 -1
View File
@@ -147,7 +147,7 @@ TSRM_API const char *tsrm_api_name(void);
# define __has_attribute(x) 0
#endif
#if !__has_attribute(tls_model) || defined(__FreeBSD__)
#if !__has_attribute(tls_model) || defined(__FreeBSD__) || defined(__MUSL__)
# define TSRM_TLS_MODEL_ATTR
#elif __PIC__
# define TSRM_TLS_MODEL_ATTR __attribute__((tls_model("initial-exec")))
+2 -2
View File
@@ -5,7 +5,7 @@
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
@@ -254,7 +254,7 @@ TSRM_API int tsrm_win32_access(const char *pathname, int mode)
goto Finished;
}
/* Different identity, we need a new impersontated token as well */
/* Different identity, we need a new impersonated token as well */
if (!TWG(impersonation_token_sid) || !EqualSid(token_sid, TWG(impersonation_token_sid))) {
if (TWG(impersonation_token_sid)) {
free(TWG(impersonation_token_sid));
+1 -1
View File
@@ -5,7 +5,7 @@
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+329 -1044
View File
File diff suppressed because it is too large. Load diff
+92 -443
View File
@@ -1,461 +1,110 @@
PHP 8.0 INTERNALS UPGRADE NOTES
PHP 8.1 INTERNALS UPGRADE NOTES
1. Internal API changes
a. Object Handlers API
b. ZEND_OVERLOADED_FUNCTION and corresponding call_method() object handler
c. TSRM changes
d. get() and set() object handlers
e. zend_parse_parameters 'L' specifier
f. Arginfo argument types
g. zend_free_op type and should_free argument of zend_get_zval_ptr()
h. zend_value_error()
i. get_closure() object handler
j. compare_objects() and compare() object handlers
k. The 'I' length modifier
l. Some VM instructions switched to IS_TMP_VAR result instead of IS_VAR
m. All internal functions must have arginfo
n. zend_hash_sort compare function and zend_hash_sort signature change
o. cast_object() object handler is now required
p. ARG_COUNT() macro removed
q. GC_COLLECTABLE flag
r. Cannot implement Traversable only
s. zend_fcall_info no_separation flag removed
t. Signature changes
u. Error Notification callbacks to replace zend_error_cb overwrite use-cases
v. Removed Zend APIs
w. Renamed Zend APIs
x. ZEND_EXT_NOP no longer emitted
a. Removed Zend APIs
b. Zend Stream API
c. zend_get_opcode_id()
2. Build system changes
a. Abstract
b. Unix build system changes
c. Windows build system changes
a. New compiler flags
3. Module changes
a. ext/hash
b. ext/pdo
c. ext/standard
d. ext/pgsql
e. ext/pcre
========================
1. Internal API changes
========================
a. The Object Handlers API was changed to receive zend_object* instead of
zval* and zend_string* instead of zval* for property names. See also
section t for other similar changes.
b. ZEND_OVERLOADED_FUNCTION and corresponding call_method() object handler
were removed. ZEND_INTERNAL_FUNCTION with ZEND_ACC_CALL_VIA_HANDLER and
defined "handler" callback should be used instead. This "handler" callback
should also take care about function cleanup. See ext/zend_test/test.c
for example.
c. The following things have been removed from TSRM:
- TSRMLS_DC
- TSRMLS_D
- TSRMLS_CC
- TSRMLS_C
- TSRMLS_FETCH
- TSRMLS_FETCH_FROM_CTX
- TSRMLS_SET_CTX
- tsrm_new_interpreter_context
- tsrm_set_interpreter_context
- tsrm_free_interpreter_context
- support for GNUPTH, SGI ST, and BETHREADS
d. The get() and set() object handlers have been removed. The get() handler
can generally be replaced with cast_object(). Some uses of set() may be
replaced by do_operation(). If set() was used to overload direct
assignments using "=", then this is no longer supported and the
functionality should be provided in some other way (for example, as
modification of an object property).
e. The zend_parse_parameters 'L' specifier and the Z_PARAM_STRICT_LONG()
family of macros have been removed. Use 'l' and Z_PARAM_LONG() instead,
which, despite the confusing name, actually have stricter input validation.
f. Arginfo argument types for internal functions are no longer checked.
Instead type checks should be performed using the zend_parse_parameters()
or ZEND_PARSE_PARAMETERS_*() APIs.
g. The zend_free_op type and the "should_free" and "type" arguments of
zend_get_zval_ptr() were removed. It's possible to get the old
"should_free" value using the following code:
zval *ret = zend_get_zval_ptr(
opline, opline->op1_type, &opline->op1, execute_data);
zval *should_free = (op_type & (IS_TMP_VAR|IS_VAR)) ? ret : NULL;
h. Added the zend_value_error() function, which is intended to be used
to raise ValueError when inappropriate argument values are passed
to functions.
i. get_closure() object handlers now accept an additional zend_bool parameter
`check_only`. If it is true, the handler is called to check whether the
object is callable; in this case the handler should not throw an exception.
j. compare_objects() handler was removed. Extensions should use compare() object
handler instead and check if both arguments are objects and have the same
compare handler, using ZEND_COMPARE_OBJECTS_FALLBACK() macro.
k. The 'I' length modifier, used to denote 32 and 64bit integer from the custom
snprintf and spprintf implementations has been removed.
Use the ZEND_LONG_FMT, ZEND_ULONG_FMT and ZEND_XLONG_FMT macros defined in
php-src/Zend/zend_long.h
The 'v' format from the custom snprintf and spprintf implementations has
been removed. Use the standard 's' format instead.
l. Some VM instructions switched to IS_TMP_VAR result instead of IS_VAR.
Actually, all assignments (ZEND_ASSIGN, ZEND_ASSIGN_DIM, ZEND_ASSIGN_OBJ,
ZEND_ASSIGN_STATIC_PROP), all compound assignments (ZEND_ASSIGN_OP,
ZEND_ASSIGN_DIM_OP, ZEND_ASSIGN_OBJ_OP, ZEND_ASSIGN_STATIC_PROP_OP) and all
pre increments/decrements (ZEND_PRE_INC, ZEND_PRE_DEC, ZEND_PRE_INC_OBJ
ZEND_PRE_DEC_OBJ, ZEND_PRE_INC_STATIC_PROP ZEND_PRE_DEC_STATIC_PROP).
m. All internal functions and methods are now required to specify arginfo
information, otherwise warnings will be thrown on startup.
n. The zend_hash_sort and zend_hash_minmax APIs now accept a comparison
function with the following signature:
typedef int (*bucket_compare_func_t)(Bucket *a, Bucket *b);
Previously compare_func_t was used, which accepted void pointers.
Furthermore, the return type of zend_hash_sort and zend_ts_hash_sort has
been changed from int to void; these functions always succeed.
o. The cast_object() handler is now required, i.e. must be non-null. You can
indicate that casting is not supported by always returning FAILURE.
p. The ARG_COUNT() macro has been removed use ZEND_NUM_ARGS() instead.
q. GC_COLLECTABLE flag was inverted into GC_NOT_COLLECTABLE.
Assignments to GC_TYPE_INFO() might need to be changed to properly
set the value of the GC_NOT_COLLECTABLE flag.
r. Just for for userland classes, it is no longer allowed to implement only
the Traversable interface. Instead, it is necessary to implement either
Iterator or IteratorAggregate. You can do the latter by implementing
zend_ce_aggregate and providing the following method implementation:
ZEND_METHOD(MyClass, getIterator) {
ZEND_PARSE_PARAMETERS_NONE();
zend_create_internal_iterator_zval(return_value, ZEND_THIS);
}
s. The zend_fcall_info no_separation flag has been removed, and separation is
never allowed. If you wish to pass (or allow passing) arguments by
reference, explicitly create those arguments as references using
ZEND_MAKE_REF. This removal also affects call_user_function_ex(), which
should be replaced by call_user_function().
t. The following ZEND_API function have changed signature:
1. Void in Zend Engine 4.0:
- add_assoc_*()
- add_index_*()
- add_property_*()
- object_init()
- zend_declare_class_constant*()
- zend_declare_property*()
- zend_startup_modules()
- zend_wrong_parameters_none_error()
- zend_fcall_info_argp()
- zend_fcall_info_argv()
- zend_fcall_info_argn()
- zend_startup()
- zend_set_memory_limit()
- pass_two()
- zend_startup_constants()
- zend_shutdown_constants()
- zend_startup_extensions_mechanism()
- zend_startup_extensions()
- zend_register_extension()
- highlight_string()
- zend_ini_startup()
- zend_ini_shutdown()
- zend_ini_global_shutdown()
- zend_ini_deactivate()
- zend_copy_ini_directives()
- zend_prepare_string_for_scanning()
- zend_init_rsrc_list()
- zend_list_close()
- zend_signal()
- zend_sigaction()
- zend_stack_init()
- zend_stack_del_top()
- zend_stack_destroy()
2. Argument int to uint32_t in Zend Engine 4.0:
- _zend_get_parameters_array_ex()
- zend_copy_parameters_array()
- zend_fcall_info_args_save()
- zend_fcall_info_args_restore()
- zend_fcall_info_argp()
- zend_fcall_info_argv()
- zend_fcall_info_argn()
- zend_wrong_parameter*()
- zend_wrong_callback_error()
- zend_parse_arg_class()
3. Argument int to bool in Zend Engine 4.0:
- add_next_index_bool()
- zend_register_class_alias_ex()
- add_assoc_bool_ex()
- add_index_bool()
- zend_fcall_info_args_clear()
- zend_set_local_var()
- zend_set_local_var_str()
- zend_parse_arg_*()
- shutdown_memory_manager()
- zend_memory_usage()
- zend_memory_peak_usage()
- zend_mm_shutdown()
- zend_eval_string*()
- zend_set_timeout()
- _zend_hash_append_ex()
- _zend_hash_append_ptr_ex()
- zend_alter_ini_entry_ex()
- (*zend_encoding_list_parser) typedef
- zend_multibyte_parse_encoding_list()
- zend_safe_address()
- zend_string_tolower_ex()
- zend_string_alloc()
- zend_string_safe_alloc()
- zend_string_init()
- zend_string_dup()
- zend_string_realloc()
- zend_string_extend()
- zend_string_truncate()
- zend_string_safe_realloc()
- zend_string_release_ex()
- zend_ts_hash_merge()
- zend_ts_hash_sort()
4. Argument int to size_t in Zend Engine 4.0:
- zend_set_hash_symbol()
5. Argument zval* to zend_object* in Zend Engine 4.0:
- zend_read_property()
- zend_update_property()
- zend_unset_property()
- zend_call_method()
- zend_objects_clone_obj()
- zend_get_closure_method_def()
- zend_throw_exception_hook()
- zend_throw_exception_internal()
- zend_get_exception_base()
6. Argument zval* to zend_long in Zend Engine 4.0:
- _php_math_longtobase()
7. Return type from int to zend_result in Zend Engine 4.0:
- (*stream_open_function) in _zend_utility_functions
- (*zend_post_startup_cb)
- (*zend_preload_autoload)
- zend_execute_scripts()
- zend_post_startup()
- _zend_get_parameters_array_ex()
- zend_copy_parameters_array()
- zend_parse_parameters()
- zend_parse_parameters_ex()
- zend_parse_method_parameters()
- zend_parse_method_parameters_ex()
- zend_parse_method_parameters()
- zend_register_functions()
- zend_startup_module()
- zend_startup_module_ex()
- zend_register_class_alias_ex()
- zend_disable_function()
- zend_disable_class()
- zend_update_class_constants()
- zend_update_static_property*()
- object_init_ex()
- object_and_properties_init()
- add_index_zval()
- add_next_index_long_*()
- array_set_zval_key()
- _call_user_function_impl()
- zend_fcall_info_*()
- zend_call_function()
- zend_set_hash_symbol()
- zend_delete_global_variable()
- zend_set_local_var()
- zend_set_local_var_str()
- zend_forbid_dynamic_call()
- zend_get_default_from_internal_arg_info()
- zend_try_assign_typed_ref*()
- zend_ast_evaluate()
- zend_startup_builtin_functions()
- do_bind_function()
- do_bind_class()
- zend_unmangle_property_name_ex()
- zend_register_auto_global()
- zend_register_constant()
- zend_exception_error()
- zend_eval_string*()
- zend_undefined_offset_write()
- zend_undefined_index_write()
- zval_update_constant(_ex)()
- zend_load_extension()
- zend_load_extension_handle()
- zend_hash_del(_ind)()
- zend_hash_str_del(_ind)()
- zend_hash_index_del()
- zend_hash_move_forward_ex()
- zend_hash_move_backward_ex()
- zend_hash_get_current_key_ex()
- zend_hash_get_current_key_type_ex()
- zend_symtable_del(_ind)()
- zend_symtable_str_del(_ind)()
- highlight_file()
- zend_do_link_class()
- zend_alter_ini_entry*()
- zend_restore_ini_entry()
- zend_ini_register_displayer()
- zend_ini_open_file_for_scanning()
- zend_ini_prepare_string_for_scanning()
- zend_user_it_valid()
- zend_create_internal_iterator_zval()
- zend_multibyte_set_filter()
- zend_lex_tstring()
- _zend_module_entry module_startup_func, module_shutdown_func,
request_startup_func, request_shutdown_func, and post_deactivate_func function pointers
- (*zend_encoding_list_parser) typedef
- (*zend_encoding_internal_encoding_setter) typedef
- zend_multibyte_set_functions()
- zend_multibyte_set_script_encoding_by_string()
- add_function()
- sub_function()
- mul_function()
- pow_function()
- div_function()
- mod_function()
- boolean_xor_function()
- boolean_not_function()
- bitwise_not_function()
- bitwise_or_function()
- bitwise_and_function()
- bitwise_xor_function()
- shift_left_function()
- shift_right_function()
- concat_function()
- is_equal_function(
- is_identical_function()
- is_not_identical_function()
- is_not_equal_function()
- is_smaller_function()
- is_smaller_or_equal_function(zv
- increment_function()
- decrement_function()
- zend_stream_open()
- zend_stream_fixup()
- zend_ts_hash_del()
- zend_ts_hash_index_del()
8. Return type from int to bool in Zend Engine 4.0:
- zend_make_printable_zval()
- zend_parse_arg_*()
- is_zend_mm()
- is_zend_ptr()
- zend_mm_is_custom_heap()
- (*zend_mm_chunk_truncate_t)
- (*zend_mm_chunk_extend_t)
- zend_bitset_empty()
- zend_is_smart_branch()
- zend_check_arg_send_type()
- zend_verify_const_access()
- zend_gdb_register_code()
- zend_gdb_present()
- _zend_handle_numeric_str(_ex)()
- zend_hash_exists_ind()
- zend_hash_str_exists_ind()
- zend_symtable_exists(_ind)()
- zend_symtable_str_exists()
- (*zend_encoding_lexer_compatibility_checker)
- zend_object_is_true()
- i_zend_is_true()
- zendi_smart_streq()
- zend_stack_is_empty()
- zend_ts_hash_exists()
- zend_ts_hash_index_exists()
9. Argument void to const char* in Zend Engine 4.0:
- zend_get_op_array_extension_handle()
10. Argument zend_extension to const char* in Zend Engine 4.0:
- zend_get_resource_handle()
11. Argument const char * to HMODULE in Zend Engine 4.0:
- php_win32_image_compatible()
12. const char * argument dropped in Zend Engine 4.0:
- php_win32_crt_compatible()
u. Instead of overwriting zend_error_cb extensions with debugging, monitoring
use-cases catching Errors/Exceptions are strongly encouraged to use
the new error observer API instead.
Error observering callbacks are guaranteed to be called regardless of
the users error_reporting setting or userland error handler return values.
Register observer callbacks during MINIT of an extension:
void my_error_observer_cb(int type,
const char *error_filename,
uint32_t error_lineno,
zend_string *message) {
}
zend_observer_error_register(my_error_observer_cb);
v. The following APIs have been removed from the Zend Engine:
- zend_ts_hash_init_ex(), drop the last argument and use zend_ts_hash_init() instead
- zend_hash_init_ex(), drop the last argument and use zend_hash_init() instead
- zval_internal_dtor(), use zval_internal_ptr_dtor() instead
- zval_dtor_func(), use rc_dtor_func() instead
- zval_ptr_dtor_wrapper(), use zval_ptr_dtor() instead
- zval_internal_ptr_dtor_wrapper(), use zval_internal_ptr_dtor() instead
w. The following APIs have been renamed:
- _zend_ts_hash_init() to zend_ts_hash_init()
x. In COMPILE_EXTENDED_STMT mode, a ZEND_EXT_NOP opcode will no longer be
generated at the start of a function. Use the new observer APIs or hook
into zend_execute_ex instead.
a. The following APIs have been removed from the Zend Engine:
- The spl_ce_Aggregate, spl_ce_ArrayAccess, spl_ce_Countable, spl_ce_Iterator, spl_ce_Serializable,
spl_ce_Stringable, spl_ce_Traversable alias class entries have been removed in favor of zend_ce_aggregate,
zend_ce_arrayaccess, zend_ce_countable, zend_ce_iterator, zend_ce_serializable, zend_ce_stringable,
zend_ce_traversable.
b. Zend Stream API has been changed to use "zend_string*" instead of "char*"
- zend_file_handle.filename now is zend_string*
- zend_file_handle.free_filename is removed. Now zend_file_handle.filename is always released.
- added zend_file_handle.primary_script flag. SAPIs should set it for main executed script.
- added zend_file_handle.in_list flag, which is set when a file_handle is added into CG(open_files)
- added zend_stream_init_filename_ex() function, that takes filename as zend_string*
- the "filename" parameter of functons zend_stream_open(), php_stream_open_for_zend_ex() and
callback zend_stream_open_function() has been removed (it's now passed as a "filename" field of the
file_handle parameter)
- in zend_fopen() and zend_resolve_path() callbacks filename now passed as zend_string*
- file_handles should be destroyed by zend_destroy_file_handle() function (usually in the same function
the same function where they were created by zend_stream_init_*()). Previously there were two different
destructors zend_destroy_file_handle() and zend_file_handle_dtor().
- zend_ini_scanner_globals.filename now is zend_string*
c. Added the zend_get_opcode_id() function, which is intended to get opcode id from name.
========================
2. Build system changes
========================
a. Abstract
1. Symbol HAVE_HASH_EXT is removed and is no longer defined. It should be
considered to have hash extension always available since PHP 7.4.
2. Symbol HAVE_PCRE is removed and is no longer defined. It should be
considered to have pcre extension always available since PHP 7.4.
3. Symbol HAVE_LOCALE_H has been removed and is no longer defined.
4. --disable-inline-optimization (which actually disabled all compiler
optimizations) has been removed. If you wish to build PHP on a host
with extremely constrained memory, and compilation fails with an "out
of memory" message, add "-O0" to CFLAGS.
5. build system and provider are displayed in phpinfo from environment:
- PHP_BUILD_SYSTEM (default is same as PHP_UNAME)
- PHP_BUILD_PROVIDER (no default)
b. Unix build system changes
1. --enable-maintainer-zts is renamed --enable-zts for parity with Windows
and as recognition that ZTS is not a "maintainer" or experimental
feature.
2. The PHP_CHECK_GCC_ARG() m4 macro has been removed in favor of
AX_CHECK_COMPILE_FLAG().
3. The 6th argument of PHP_ADD_SOURCES_X has been removed.
4. The 'special-flags' (3rd) argument of PHP_ADD_SOURCES_X are
now appended instead of prepended to previous compiler flags.
This means compiler flags passed to PHP_NEW_EXTENSION and PHP_ADD_SOURCES
are now appended, this allows to disable compiler flags set by Zend/Zend.m4
(e.g. disable certain compiler flags enabled by -Wextra)
c. Windows build system changes
- The configuration option --enable-crt-debug has been removed. The VC
debug heap can now be enabled for debug builds by setting the environment
variable PHP_WIN32_DEBUG_HEAP to a non-negative number before PHP process
startup.
a. New compiler flags
- [-Wimplicit-fallthrough=1] is now enabled by default.
It is possible to use the new ZEND_FALLTHROUGH macro keyword to suppress the warning.
========================
3. Module changes
========================
a. ext/hash
- The init signatures are extended with an additional `HashTable*`
argument. The passed HT is to contain the algorithm specific
configuration. If an algorithm doesn't make use of any additional
configuration, the argument is to be marked with ZEND_ATTRIBUTE_UNUSED.
b. ext/pdo
- The "preparer" callback now accepts a zend_string* instead of
char* + size_t pair the query string. Similarly, the query_string and
active_query_string members of pdo_stmt_t are now zend_string*.
- The way in which drivers provide results has changed: Previously,
the "describer" callback populated the "pdo_type" member in the
pdo_column_data structure, and the "get_col" callback then had to return
pointers to data of appropriate type.
In PHP 8.1, the "describer" callback no longer determines the pdo_type
(and this member has been removed from pdo_column_data). Instead, the
"get_col" callback accepts a zval pointer that may be populated with a
value of arbitrary type. This gives drivers more flexibility in
determining result types (e.g. based on whether a specific integer fits
the PHP integer type) and avoid awkward juggling of temporary buffers.
As the "describer" no longer determines pdo_type, the "get_column_meta"
function is now responsible for providing this information for use by
getColumnMeta(). The type provided here does not need to match the type
returned by get_col (in fact no corresponding type might exist, e.g. for
floats). It should be the closest logical equivalent for the column type.
- The transaction, set_attribute, and preparer handler's return type
has been formalized to bool instead of int.
- The check_liveness handler's return type has been formalized to zend_return
instead of int.
- The closer, and fetch_error handlers have been voidified.
- The quoter handler now returns the quoted string as zend_string* instead
of returning a boolean, and the quoted string as a pair of out params.
Similarly the unquoted string is now a zend_string* instead of a pair of
char* and size_t length.
- The doer handler now accepts a zend_string* instead of char* + size_t
pair for the SQL statement.
- The last_id handler now returns a zend_string* instead of returning a
char* and the length as an out param, and accepts a zend_string* instead
of char* for the optional sequence/table name.
- The php_pdo_str_tolower_dup() PDO_API has been removed use zend_str_tolower_dup()
or zend_string_tolower_ex().
c. ext/standard
- The PHP API php_fputcsv() now takes an extra zend_string* argument at the end
for a custom EOL sequence, passing NULL provides the old default of "\n".
d. ext/pgsql
- The functions php_pgsql_meta_data(), php_pgsql_convert(), php_pgsql_insert(),
php_pgsql_update(), php_pgsql_delete(), and php_pgsql_select() have had
their return type formalized to zend_result.
- The functions php_pgsql_meta_data(), php_pgsql_convert(), php_pgsql_insert(),
php_pgsql_update(), php_pgsql_delete(), and php_pgsql_select() now accept a
zend_string* instead of a char* for the table name.
e. ext/pcre
- Bundled PCRE2 is at version 10.37. The most important diff to the previous
version is the JIT support on the S390 platform.
+5
View File
@@ -32,6 +32,11 @@ $(srcdir)/zend_ini_parser.c: $(srcdir)/zend_ini_parser.y
$(srcdir)/zend_ini_scanner.c: $(srcdir)/zend_ini_scanner.l
@(cd $(top_srcdir); $(RE2C) $(RE2C_FLAGS) --no-generation-date --case-inverted -cbdFt Zend/zend_ini_scanner_defs.h -oZend/zend_ini_scanner.c Zend/zend_ini_scanner.l)
$(srcdir)/zend_vm_execute.h $(srcdir)/zend_vm_opcodes.c: $(srcdir)/zend_vm_def.h $(srcdir)/zend_vm_execute.skl $(srcdir)/zend_vm_gen.php
@if test ! -z "$(PHP)"; then \
$(PHP) $(srcdir)/zend_vm_gen.php; \
fi;
$(builddir)/zend_highlight.lo $(builddir)/zend_compile.lo: $(srcdir)/zend_language_parser.h
Zend/zend_execute.lo: $(srcdir)/zend_vm_execute.h $(srcdir)/zend_vm_opcodes.h
@@ -7,7 +7,7 @@
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
@@ -19,7 +19,6 @@
+----------------------------------------------------------------------+
*/
#include "php.h"
#include "Optimizer/zend_optimizer.h"
#include "Optimizer/zend_optimizer_internal.h"
#include "zend_API.h"
@@ -399,7 +398,7 @@ static void zend_optimize_block(zend_basic_block *block, zend_op_array *op_array
Tsource[VAR_NUM(opline->op1.var)] = NULL;
break;
}
/* break missing intentionally */
ZEND_FALLTHROUGH;
case ZEND_IS_EQUAL:
case ZEND_IS_NOT_EQUAL:
@@ -893,7 +892,7 @@ optimize_const_unary_op:
src = VAR_SOURCE(opline->op1);
if (src && src->opcode == ZEND_QM_ASSIGN) {
zend_op *op = src + 1;
zend_bool optimize = 1;
bool optimize = 1;
while (op < opline) {
if ((op->op1_type == opline->op1_type
@@ -968,14 +967,6 @@ static void assemble_code_blocks(zend_cfg *cfg, zend_op_array *op_array, zend_op
continue;
}
if (b->flags & (ZEND_BB_REACHABLE|ZEND_BB_UNREACHABLE_FREE)) {
if (b->flags & ZEND_BB_UNREACHABLE_FREE) {
/* Only keep the FREE for the loop var */
ZEND_ASSERT(op_array->opcodes[b->start].opcode == ZEND_FREE
|| op_array->opcodes[b->start].opcode == ZEND_FE_FREE);
len += b->len = 1;
continue;
}
opline = op_array->opcodes + b->start + b->len - 1;
if (opline->opcode == ZEND_JMP) {
zend_basic_block *next = b + 1;
@@ -1037,7 +1028,7 @@ static void assemble_code_blocks(zend_cfg *cfg, zend_op_array *op_array, zend_op
break;
case ZEND_JMPZNZ:
opline->extended_value = ZEND_OPLINE_TO_OFFSET(opline, new_opcodes + blocks[b->successors[1]].start);
/* break missing intentionally */
ZEND_FALLTHROUGH;
case ZEND_JMPZ:
case ZEND_JMPNZ:
case ZEND_JMPZ_EX:
@@ -1458,7 +1449,7 @@ static void zend_jmp_optimization(zend_basic_block *block, zend_op_array *op_arr
/* is not used on the following path and */
/* should be used once on the branch path. */
/* */
/* The pattern works well only if jums processed in */
/* The pattern works well only if jumps processed in */
/* direct order, otherwise it breaks JMPZ_EX */
/* sequences too early. */
last_op->result.var = target->result.var;
@@ -7,7 +7,7 @@
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
@@ -21,7 +21,6 @@
* - compact literals table
*/
#include "php.h"
#include "Optimizer/zend_optimizer.h"
#include "Optimizer/zend_optimizer_internal.h"
#include "zend_API.h"
@@ -113,6 +112,41 @@ static uint32_t add_static_slot(HashTable *hash,
return ret;
}
static zend_string *create_str_cache_key(zval *literal, uint32_t flags)
{
ZEND_ASSERT(Z_TYPE_P(literal) == IS_STRING);
uint32_t num_related = LITERAL_NUM_RELATED(flags);
if (num_related == 1) {
return zend_string_copy(Z_STR_P(literal));
}
if ((flags & LITERAL_KIND_MASK) == LITERAL_VALUE) {
/* Don't merge LITERAL_VALUE that has related literals */
return NULL;
}
/* Concatenate all the related literals for the cache key. */
zend_string *key;
if (num_related == 2) {
ZEND_ASSERT(Z_TYPE_P(literal + 1) == IS_STRING);
key = zend_string_concat2(
Z_STRVAL_P(literal), Z_STRLEN_P(literal),
Z_STRVAL_P(literal + 1), Z_STRLEN_P(literal + 1));
} else if (num_related == 3) {
ZEND_ASSERT(Z_TYPE_P(literal + 1) == IS_STRING && Z_TYPE_P(literal + 2) == IS_STRING);
key = zend_string_concat3(
Z_STRVAL_P(literal), Z_STRLEN_P(literal),
Z_STRVAL_P(literal + 1), Z_STRLEN_P(literal + 1),
Z_STRVAL_P(literal + 2), Z_STRLEN_P(literal + 2));
} else {
ZEND_ASSERT(0 && "Currently not needed");
}
/* Add a bias to the hash so we can distinguish keys
* that would otherwise be the same after concatenation. */
ZSTR_H(key) = zend_string_hash_val(key) + num_related - 1;
return key;
}
void zend_optimizer_compact_literals(zend_op_array *op_array, zend_optimizer_ctx *ctx)
{
zend_op *opline, *end;
@@ -241,9 +275,6 @@ void zend_optimizer_compact_literals(zend_op_array *op_array, zend_optimizer_ctx
case ZEND_RECV_INIT:
LITERAL_INFO(opline->op2.constant, LITERAL_VALUE, 1);
break;
case ZEND_DECLARE_FUNCTION:
LITERAL_INFO(opline->op1.constant, LITERAL_VALUE, 2);
break;
case ZEND_DECLARE_CLASS:
case ZEND_DECLARE_CLASS_DELAYED:
LITERAL_INFO(opline->op1.constant, LITERAL_VALUE, 2);
@@ -407,16 +438,7 @@ void zend_optimizer_compact_literals(zend_op_array *op_array, zend_optimizer_ctx
}
break;
case IS_STRING: {
if (LITERAL_NUM_RELATED(info[i].flags) == 1) {
key = zend_string_copy(Z_STR(op_array->literals[i]));
} else if ((info[i].flags & LITERAL_KIND_MASK) != LITERAL_VALUE) {
key = zend_string_init(Z_STRVAL(op_array->literals[i]), Z_STRLEN(op_array->literals[i]), 0);
ZSTR_H(key) = ZSTR_HASH(Z_STR(op_array->literals[i])) +
LITERAL_NUM_RELATED(info[i].flags) - 1;
} else {
/* Don't merge LITERAL_VALUE that has related literals */
key = NULL;
}
key = create_str_cache_key(&op_array->literals[i], info[i].flags);
if (key && (pos = zend_hash_find(&hash, key)) != NULL &&
Z_TYPE(op_array->literals[Z_LVAL_P(pos)]) == IS_STRING &&
LITERAL_NUM_RELATED(info[i].flags) == LITERAL_NUM_RELATED(info[Z_LVAL_P(pos)].flags) &&
@@ -469,7 +491,7 @@ void zend_optimizer_compact_literals(zend_op_array *op_array, zend_optimizer_ctx
map[i] = l_empty_arr;
break;
}
/* break missing intentionally */
ZEND_FALLTHROUGH;
default:
/* don't merge other types */
map[i] = j;
@@ -776,7 +798,6 @@ void zend_optimizer_compact_literals(zend_op_array *op_array, zend_optimizer_ctx
bind_var_slot[opline->op2.constant] = opline->extended_value;
}
break;
case ZEND_DECLARE_LAMBDA_FUNCTION:
case ZEND_DECLARE_ANON_CLASS:
case ZEND_DECLARE_CLASS_DELAYED:
opline->extended_value = cache_size;
@@ -7,7 +7,7 @@
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
@@ -16,7 +16,6 @@
+----------------------------------------------------------------------+
*/
#include "ZendAccelerator.h"
#include "Optimizer/zend_optimizer_internal.h"
#include "zend_bitset.h"
@@ -7,7 +7,7 @@
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
@@ -17,7 +17,6 @@
+----------------------------------------------------------------------+
*/
#include "ZendAccelerator.h"
#include "Optimizer/zend_optimizer_internal.h"
#include "Optimizer/zend_inference.h"
#include "Optimizer/zend_ssa.h"
@@ -60,7 +59,7 @@ typedef struct {
unsigned reorder_dtor_effects : 1;
} context;
static inline zend_bool is_bad_mod(const zend_ssa *ssa, int use, int def) {
static inline bool is_bad_mod(const zend_ssa *ssa, int use, int def) {
if (def < 0) {
/* This modification is not tracked by SSA, assume the worst */
return 1;
@@ -72,16 +71,17 @@ static inline zend_bool is_bad_mod(const zend_ssa *ssa, int use, int def) {
return 0;
}
static inline zend_bool may_have_side_effects(
static inline bool may_have_side_effects(
zend_op_array *op_array, zend_ssa *ssa,
const zend_op *opline, const zend_ssa_op *ssa_op,
zend_bool reorder_dtor_effects) {
bool reorder_dtor_effects) {
switch (opline->opcode) {
case ZEND_NOP:
case ZEND_IS_IDENTICAL:
case ZEND_IS_NOT_IDENTICAL:
case ZEND_QM_ASSIGN:
case ZEND_FREE:
case ZEND_FE_FREE:
case ZEND_TYPE_CHECK:
case ZEND_DEFINED:
case ZEND_ADD:
@@ -155,6 +155,7 @@ static inline zend_bool may_have_side_effects(
case ZEND_TICKS:
case ZEND_YIELD:
case ZEND_YIELD_FROM:
case ZEND_VERIFY_NEVER_TYPE:
/* Intrinsic side effects */
return 1;
case ZEND_DO_FCALL:
@@ -233,19 +234,32 @@ static inline zend_bool may_have_side_effects(
}
return 0;
case ZEND_BIND_STATIC:
if (op_array->static_variables
&& (opline->extended_value & ZEND_BIND_REF) != 0) {
zval *value =
(zval*)((char*)op_array->static_variables->arData +
(opline->extended_value & ~ZEND_BIND_REF));
if (Z_TYPE_P(value) == IS_CONSTANT_AST) {
/* AST may contain undefined constants */
if (op_array->static_variables) {
/* Implicit and Explicit bind static is effectively prologue of closure so
report it has side effects like RECV, RECV_INIT; This allows us to
reflect on the closure and discover used variable at runtime */
if ((opline->extended_value & (ZEND_BIND_IMPLICIT|ZEND_BIND_EXPLICIT))) {
return 1;
}
if ((opline->extended_value & ZEND_BIND_REF) != 0) {
zval *value =
(zval*)((char*)op_array->static_variables->arData +
(opline->extended_value & ~ZEND_BIND_REF));
if (Z_TYPE_P(value) == IS_CONSTANT_AST) {
/* AST may contain undefined constants */
return 1;
}
}
}
return 0;
case ZEND_CHECK_VAR:
return (OP1_INFO() & MAY_BE_UNDEF) != 0;
case ZEND_FE_RESET_R:
case ZEND_FE_RESET_RW:
/* Model as not having side-effects -- let the side-effect be introduced by
* FE_FETCH if the array is not known to be non-empty. */
return (OP1_INFO() & MAY_BE_ANY) != MAY_BE_ARRAY;
default:
/* For everything we didn't handle, assume a side-effect */
return 1;
@@ -304,7 +318,7 @@ static zend_always_inline void add_phi_sources_to_worklists(context *ctx, zend_s
} FOREACH_PHI_SOURCE_END();
}
static inline zend_bool is_var_dead(context *ctx, int var_num) {
static inline bool is_var_dead(context *ctx, int var_num) {
zend_ssa_var *var = &ctx->ssa->vars[var_num];
if (var->definition_phi) {
return zend_bitset_in(ctx->phi_dead, var_num);
@@ -319,7 +333,7 @@ static inline zend_bool is_var_dead(context *ctx, int var_num) {
}
// Sometimes we can mark the var as EXT_UNUSED
static zend_bool try_remove_var_def(context *ctx, int free_var, int use_chain, zend_op *opline) {
static bool try_remove_var_def(context *ctx, int free_var, int use_chain, zend_op *opline) {
if (use_chain >= 0) {
return 0;
}
@@ -373,8 +387,27 @@ static zend_bool try_remove_var_def(context *ctx, int free_var, int use_chain, z
return 0;
}
static zend_always_inline zend_bool may_be_refcounted(uint32_t type) {
return (type & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_REF)) != 0;
}
static inline bool is_free_of_live_var(context *ctx, zend_op *opline, zend_ssa_op *ssa_op) {
switch (opline->opcode) {
case ZEND_FREE:
/* It is always safe to remove FREEs of non-refcounted values, even if they are live. */
if (!may_be_refcounted(ctx->ssa->var_info[ssa_op->op1_use].type)) {
return 0;
}
ZEND_FALLTHROUGH;
case ZEND_FE_FREE:
return !is_var_dead(ctx, ssa_op->op1_use);
default:
return 0;
}
}
/* Returns whether the instruction has been DCEd */
static zend_bool dce_instr(context *ctx, zend_op *opline, zend_ssa_op *ssa_op) {
static bool dce_instr(context *ctx, zend_op *opline, zend_ssa_op *ssa_op) {
zend_ssa *ssa = ctx->ssa;
int free_var = -1;
zend_uchar free_var_type;
@@ -384,17 +417,14 @@ static zend_bool dce_instr(context *ctx, zend_op *opline, zend_ssa_op *ssa_op) {
}
/* We mark FREEs as dead, but they're only really dead if the destroyed var is dead */
if (opline->opcode == ZEND_FREE
&& (ssa->var_info[ssa_op->op1_use].type & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_REF))
&& !is_var_dead(ctx, ssa_op->op1_use)) {
if (is_free_of_live_var(ctx, opline, ssa_op)) {
return 0;
}
if ((opline->op1_type & (IS_VAR|IS_TMP_VAR))&& !is_var_dead(ctx, ssa_op->op1_use)) {
if (!try_remove_var_def(ctx, ssa_op->op1_use, ssa_op->op1_use_chain, opline)) {
if (ssa->var_info[ssa_op->op1_use].type & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_REF)
&& opline->opcode != ZEND_CASE
&& opline->opcode != ZEND_CASE_STRICT) {
if (may_be_refcounted(ssa->var_info[ssa_op->op1_use].type)
&& opline->opcode != ZEND_CASE && opline->opcode != ZEND_CASE_STRICT) {
free_var = ssa_op->op1_use;
free_var_type = opline->op1_type;
}
@@ -402,7 +432,7 @@ static zend_bool dce_instr(context *ctx, zend_op *opline, zend_ssa_op *ssa_op) {
}
if ((opline->op2_type & (IS_VAR|IS_TMP_VAR)) && !is_var_dead(ctx, ssa_op->op2_use)) {
if (!try_remove_var_def(ctx, ssa_op->op2_use, ssa_op->op2_use_chain, opline)) {
if (ssa->var_info[ssa_op->op2_use].type & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_REF)) {
if (may_be_refcounted(ssa->var_info[ssa_op->op2_use].type)) {
if (free_var >= 0) {
// TODO: We can't free two vars. Keep instruction alive.
zend_bitset_excl(ctx->instr_dead, opline - ctx->op_array->opcodes);
@@ -464,7 +494,7 @@ static void try_remove_trivial_phi(context *ctx, zend_ssa_phi *phi) {
}
}
static inline zend_bool may_break_varargs(const zend_op_array *op_array, const zend_ssa *ssa, const zend_ssa_op *ssa_op) {
static inline bool may_break_varargs(const zend_op_array *op_array, const zend_ssa *ssa, const zend_ssa_op *ssa_op) {
if (ssa_op->op1_def >= 0
&& ssa->vars[ssa_op->op1_def].var < op_array->num_args) {
return 1;
@@ -480,13 +510,13 @@ static inline zend_bool may_break_varargs(const zend_op_array *op_array, const z
return 0;
}
int dce_optimize_op_array(zend_op_array *op_array, zend_ssa *ssa, zend_bool reorder_dtor_effects) {
int dce_optimize_op_array(zend_op_array *op_array, zend_ssa *ssa, bool reorder_dtor_effects) {
int i;
zend_ssa_phi *phi;
int removed_ops = 0;
/* DCE of CV operations that changes arguments may affect vararg functions. */
zend_bool has_varargs = (ssa->cfg.flags & ZEND_FUNC_VARARG) != 0;
bool has_varargs = (ssa->cfg.flags & ZEND_FUNC_VARARG) != 0;
context ctx;
ctx.ssa = ssa;
@@ -509,7 +539,18 @@ int dce_optimize_op_array(zend_op_array *op_array, zend_ssa *ssa, zend_bool reor
ctx.phi_dead = alloca(sizeof(zend_ulong) * ctx.phi_worklist_len);
memset(ctx.phi_dead, 0xff, sizeof(zend_ulong) * ctx.phi_worklist_len);
/* Mark reacable instruction without side effects as dead */
/* Mark non-CV phis as live. Even if the result is unused, we generally cannot remove one
* of the producing instructions, as it combines producing the result with control flow.
* This can be made more precise if there are any cases where this is not the case. */
FOREACH_PHI(phi) {
if (phi->var >= op_array->last_var
&& may_be_refcounted(ssa->var_info[phi->ssa_var].type)) {
zend_bitset_excl(ctx.phi_dead, phi->ssa_var);
add_phi_sources_to_worklists(&ctx, phi, 0);
}
} FOREACH_PHI_END();
/* Mark reachable instruction without side effects as dead */
int b = ssa->cfg.blocks_count;
while (b > 0) {
int op_data = -1;
@@ -7,7 +7,7 @@
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
@@ -16,7 +16,6 @@
+----------------------------------------------------------------------+
*/
#include "php.h"
#include "Optimizer/zend_optimizer.h"
#include "Optimizer/zend_optimizer_internal.h"
#include "zend_API.h"
@@ -280,7 +279,7 @@ static void zend_ssa_remove_nops(zend_op_array *op_array, zend_ssa *ssa, zend_op
free_alloca(shiftlist, use_heap);
}
static zend_bool safe_instanceof(zend_class_entry *ce1, zend_class_entry *ce2) {
static bool safe_instanceof(zend_class_entry *ce1, zend_class_entry *ce2) {
if (ce1 == ce2) {
return 1;
}
@@ -291,7 +290,7 @@ static zend_bool safe_instanceof(zend_class_entry *ce1, zend_class_entry *ce2) {
return instanceof_function(ce1, ce2);
}
static inline zend_bool can_elide_return_type_check(
static inline bool can_elide_return_type_check(
zend_op_array *op_array, zend_ssa *ssa, zend_ssa_op *ssa_op) {
zend_arg_info *info = &op_array->arg_info[-1];
zend_ssa_var_info *use_info = &ssa->var_info[ssa_op->op1_use];
@@ -322,7 +321,7 @@ static inline zend_bool can_elide_return_type_check(
return 1;
}
static zend_bool opline_supports_assign_contraction(
static bool opline_supports_assign_contraction(
zend_ssa *ssa, zend_op *opline, int src_var, uint32_t cv_var) {
if (opline->opcode == ZEND_NEW) {
/* see Zend/tests/generators/aborted_yield_during_new.phpt */
@@ -380,7 +379,8 @@ int zend_dfa_optimize_calls(zend_op_array *op_array, zend_ssa *ssa)
zend_op *send_array;
zend_op *send_needly;
zend_bool strict = 0;
bool strict = 0;
ZEND_ASSERT(!call_info->is_prototype);
if (call_info->caller_init_opline->extended_value == 2) {
send_array = call_info->caller_call_opline - 1;
@@ -612,7 +612,7 @@ static void zend_ssa_replace_control_link(zend_op_array *op_array, zend_ssa *ssa
if (ZEND_OFFSET_TO_OPLINE_NUM(op_array, opline, opline->extended_value) == old->start) {
opline->extended_value = ZEND_OPLINE_NUM_TO_OFFSET(op_array, opline, dst->start);
}
/* break missing intentionally */
ZEND_FALLTHROUGH;
case ZEND_JMPZ:
case ZEND_JMPNZ:
case ZEND_JMPZ_EX:
@@ -924,7 +924,7 @@ optimize_jmpnz:
if (opline->op1_type == IS_CONST) {
zval *zv = CT_CONSTANT_EX(op_array, opline->op1.constant);
zend_uchar type = Z_TYPE_P(zv);
zend_bool correct_type =
bool correct_type =
(opline->opcode == ZEND_SWITCH_LONG && type == IS_LONG)
|| (opline->opcode == ZEND_SWITCH_STRING && type == IS_STRING)
|| (opline->opcode == ZEND_MATCH && (type == IS_LONG || type == IS_STRING));
@@ -1235,7 +1235,6 @@ void zend_dfa_optimize_op_array(zend_op_array *op_array, zend_optimizer_ctx *ctx
&& ssa->ops[op_1].op1_def == v
&& ssa->ops[op_1].op1_use >= 0
&& ssa->ops[op_1].op1_use_chain == -1
&& ssa->vars[v].use_chain >= 0
&& can_elide_return_type_check(op_array, ssa, &ssa->ops[op_1])) {
// op_1: VERIFY_RETURN_TYPE #orig_var.? [T] -> #v.? [T] => NOP
@@ -1244,10 +1243,11 @@ void zend_dfa_optimize_op_array(zend_op_array *op_array, zend_optimizer_ctx *ctx
if (zend_ssa_unlink_use_chain(ssa, op_1, orig_var)) {
int ret = ssa->vars[v].use_chain;
ssa->ops[ret].op1_use = orig_var;
ssa->ops[ret].op1_use_chain = ssa->vars[orig_var].use_chain;
ssa->vars[orig_var].use_chain = ret;
if (ret >= 0) {
ssa->ops[ret].op1_use = orig_var;
ssa->ops[ret].op1_use_chain = ssa->vars[orig_var].use_chain;
ssa->vars[orig_var].use_chain = ret;
}
ssa->vars[v].definition = -1;
ssa->vars[v].use_chain = -1;
@@ -7,7 +7,7 @@
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
@@ -16,7 +16,6 @@
+----------------------------------------------------------------------+
*/
#include "php.h"
#include "Optimizer/zend_optimizer.h"
#include "Optimizer/zend_optimizer_internal.h"
#include "zend_bitset.h"
@@ -388,7 +387,7 @@ int zend_ssa_escape_analysis(const zend_script *script, zend_op_array *op_array,
int ssa_vars_count = ssa->vars_count;
int i, root, use;
int *ees;
zend_bool has_allocations;
bool has_allocations;
int num_non_escaped;
ALLOCA_FLAG(use_heap)
@@ -469,7 +468,7 @@ int zend_ssa_escape_analysis(const zend_script *script, zend_op_array *op_array,
/* 4. Process referential dependencies */
if (num_non_escaped) {
zend_bool changed;
bool changed;
do {
changed = 0;
@@ -7,7 +7,7 @@
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
@@ -23,7 +23,6 @@
* - remove NOPs
*/
#include "php.h"
#include "Optimizer/zend_optimizer.h"
#include "Optimizer/zend_optimizer_internal.h"
#include "zend_API.h"
@@ -7,7 +7,7 @@
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
@@ -21,7 +21,6 @@
* - optimize INIT_FCALL_BY_NAME to DO_FCALL
*/
#include "php.h"
#include "Optimizer/zend_optimizer.h"
#include "Optimizer/zend_optimizer_internal.h"
#include "zend_API.h"
@@ -39,8 +38,8 @@
typedef struct _optimizer_call_info {
zend_function *func;
zend_op *opline;
zend_bool is_prototype;
zend_bool try_inline;
bool is_prototype;
bool try_inline;
uint32_t func_arg_num;
} optimizer_call_info;
@@ -59,7 +58,7 @@ static void zend_delete_call_instructions(zend_op *opline)
MAKE_NOP(opline);
return;
}
/* break missing intentionally */
ZEND_FALLTHROUGH;
case ZEND_NEW:
case ZEND_INIT_DYNAMIC_CALL:
case ZEND_INIT_USER_CALL:
@@ -178,7 +177,7 @@ void zend_optimize_func_calls(zend_op_array *op_array, zend_optimizer_ctx *ctx)
ctx->script, op_array, opline, &call_stack[call].is_prototype);
call_stack[call].try_inline =
!call_stack[call].is_prototype && opline->opcode != ZEND_NEW;
/* break missing intentionally */
ZEND_FALLTHROUGH;
case ZEND_INIT_DYNAMIC_CALL:
case ZEND_INIT_USER_CALL:
call_stack[call].opline = opline;
@@ -7,7 +7,7 @@
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
@@ -19,7 +19,6 @@
+----------------------------------------------------------------------+
*/
#include "php.h"
#include "Optimizer/zend_optimizer.h"
#include "Optimizer/zend_optimizer_internal.h"
#include "zend_API.h"
@@ -7,7 +7,7 @@
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
@@ -40,7 +40,7 @@ void zend_optimizer_pass1(zend_op_array *op_array, zend_optimizer_ctx *ctx)
{
zend_op *opline = op_array->opcodes;
zend_op *end = opline + op_array->last;
zend_bool collect_constants = (ZEND_OPTIMIZER_PASS_15 & ctx->optimization_level)?
bool collect_constants = (ZEND_OPTIMIZER_PASS_15 & ctx->optimization_level)?
(op_array == &ctx->script->main_op_array) : 0;
while (opline < end) {
@@ -111,7 +111,7 @@ constant_binary_op:
|| opline->extended_value == ZEND_DIV
|| opline->extended_value == ZEND_POW) {
if (Z_TYPE(ZEND_OP2_LITERAL(opline)) == IS_STRING) {
/* don't optimise if it should produce a runtime numeric string error */
/* don't optimize if it should produce a runtime numeric string error */
if (is_numeric_string(Z_STRVAL(ZEND_OP2_LITERAL(opline)), Z_STRLEN(ZEND_OP2_LITERAL(opline)), NULL, NULL, 0)) {
convert_scalar_to_number(&ZEND_OP2_LITERAL(opline));
}
@@ -119,12 +119,12 @@ constant_binary_op:
} else if (opline->extended_value == ZEND_MOD
|| opline->extended_value == ZEND_SL
|| opline->extended_value == ZEND_SR) {
if (Z_TYPE(ZEND_OP2_LITERAL(opline)) != IS_LONG) {
/* don't optimise if it should produce a runtime numeric string error */
if (!(Z_TYPE(ZEND_OP2_LITERAL(opline)) == IS_STRING
&& !is_numeric_string(Z_STRVAL(ZEND_OP2_LITERAL(opline)), Z_STRLEN(ZEND_OP2_LITERAL(opline)), NULL, NULL, 0))) {
convert_to_long(&ZEND_OP2_LITERAL(opline));
zval *op2 = &ZEND_OP2_LITERAL(opline);
if (Z_TYPE_P(op2) != IS_LONG) {
if (!zend_is_op_long_compatible(op2)) {
break;
}
convert_to_long(op2);
}
} else if (opline->extended_value == ZEND_CONCAT) {
if (Z_TYPE(ZEND_OP2_LITERAL(opline)) != IS_STRING) {
@@ -235,8 +235,7 @@ constant_binary_op:
Z_TYPE(ZEND_OP1_LITERAL(opline)) == IS_STRING) {
/* for A::B */
if (op_array->scope &&
!strncasecmp(Z_STRVAL(ZEND_OP1_LITERAL(opline)),
ZSTR_VAL(op_array->scope->name), Z_STRLEN(ZEND_OP1_LITERAL(opline)) + 1)) {
zend_string_equals_ci(Z_STR(ZEND_OP1_LITERAL(opline)), op_array->scope->name)) {
ce = op_array->scope;
} else {
if ((ce = zend_hash_find_ptr(EG(class_table),
@@ -269,7 +268,7 @@ constant_binary_op:
if ((cc = zend_hash_find_ptr(&ce->constants_table,
Z_STR(ZEND_OP2_LITERAL(opline)))) != NULL &&
(Z_ACCESS_FLAGS(cc->value) & ZEND_ACC_PPP_MASK) == ZEND_ACC_PUBLIC) {
(ZEND_CLASS_CONST_FLAGS(cc) & ZEND_ACC_PPP_MASK) == ZEND_ACC_PUBLIC) {
c = &cc->value;
if (Z_TYPE_P(c) == IS_CONSTANT_AST) {
zend_ast *ast = Z_ASTVAL_P(c);
@@ -312,7 +311,7 @@ constant_binary_op:
}
if (send1_opline->opcode != ZEND_SEND_VAL ||
send1_opline->op1_type != IS_CONST) {
/* don't colllect constants after unknown function call */
/* don't collect constants after unknown function call */
collect_constants = 0;
break;
}
@@ -324,7 +323,7 @@ constant_binary_op:
}
if (send1_opline->opcode != ZEND_SEND_VAL ||
send1_opline->op1_type != IS_CONST) {
/* don't colllect constants after unknown function call */
/* don't collect constants after unknown function call */
collect_constants = 0;
break;
}
@@ -336,7 +335,7 @@ constant_binary_op:
if (init_opline->opcode != ZEND_INIT_FCALL ||
init_opline->op2_type != IS_CONST ||
Z_TYPE(ZEND_OP2_LITERAL(init_opline)) != IS_STRING) {
/* don't colllect constants after unknown function call */
/* don't collect constants after unknown function call */
collect_constants = 0;
break;
}
@@ -505,7 +504,7 @@ constant_binary_op:
break;
}
}
/* don't colllect constants after any other function call */
/* don't collect constants after any other function call */
collect_constants = 0;
break;
}
@@ -677,6 +676,7 @@ constant_binary_op:
case ZEND_COALESCE:
case ZEND_ASSERT_CHECK:
case ZEND_JMP_NULL:
case ZEND_VERIFY_NEVER_TYPE:
collect_constants = 0;
break;
}
@@ -7,7 +7,7 @@
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
@@ -23,7 +23,6 @@
* - optimize series of JMPs
*/
#include "php.h"
#include "Optimizer/zend_optimizer.h"
#include "Optimizer/zend_optimizer_internal.h"
#include "zend_API.h"
@@ -261,7 +260,7 @@ void zend_optimizer_pass3(zend_op_array *op_array, zend_optimizer_ctx *ctx)
/* is not used on the following path and */
/* should be used once on the branch path. */
/* */
/* The pattern works well only if jums processed in */
/* The pattern works well only if jumps processed in */
/* direct order, otherwise it breaks JMPZ_EX */
/* sequences too early. */
opline->result.var = target->result.var;
@@ -7,7 +7,7 @@
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
@@ -17,16 +17,15 @@
+----------------------------------------------------------------------+
*/
#include "php.h"
#include "zend_API.h"
#include "zend_exceptions.h"
#include "zend_ini.h"
#include "zend_type_info.h"
#include "ZendAccelerator.h"
#include "Optimizer/zend_optimizer_internal.h"
#include "Optimizer/zend_call_graph.h"
#include "Optimizer/zend_inference.h"
#include "Optimizer/scdf.h"
#include "Optimizer/zend_dump.h"
#include "ext/standard/php_string.h"
#include "zend_exceptions.h"
/* This implements sparse conditional constant propagation (SCCP) based on the SCDF framework. The
* used value lattice is defined as follows:
@@ -142,7 +141,7 @@ static void dup_partial_object(zval *dst, zval *src)
Z_ARR_P(dst) = zend_array_dup(Z_ARR_P(src));
}
static inline zend_bool value_known(zval *zv) {
static inline bool value_known(zval *zv) {
return !IS_TOP(zv) && !IS_BOT(zv);
}
@@ -207,7 +206,7 @@ static zval *get_op2_value(sccp_ctx *ctx, zend_op *opline, zend_ssa_op *ssa_op)
}
}
static zend_bool can_replace_op1(
static bool can_replace_op1(
const zend_op_array *op_array, zend_op *opline, zend_ssa_op *ssa_op) {
switch (opline->opcode) {
case ZEND_PRE_INC:
@@ -276,7 +275,7 @@ static zend_bool can_replace_op1(
return 1;
}
static zend_bool can_replace_op2(
static bool can_replace_op2(
const zend_op_array *op_array, zend_op *opline, zend_ssa_op *ssa_op) {
switch (opline->opcode) {
/* Do not accept CONST */
@@ -289,7 +288,7 @@ static zend_bool can_replace_op2(
return 1;
}
static zend_bool try_replace_op1(
static bool try_replace_op1(
sccp_ctx *ctx, zend_op *opline, zend_ssa_op *ssa_op, int var, zval *value) {
if (ssa_op->op1_use == var && can_replace_op1(ctx->scdf.op_array, opline, ssa_op)) {
zval zv;
@@ -339,7 +338,7 @@ replace_op1_simple:
return 0;
}
static zend_bool try_replace_op2(
static bool try_replace_op2(
sccp_ctx *ctx, zend_op *opline, zend_ssa_op *ssa_op, int var, zval *value) {
if (ssa_op->op2_use == var && can_replace_op2(ctx->scdf.op_array, opline, ssa_op)) {
zval zv;
@@ -426,9 +425,14 @@ static inline int fetch_array_elem(zval **result, zval *op1, zval *op2) {
case IS_LONG:
*result = zend_hash_index_find(Z_ARR_P(op1), Z_LVAL_P(op2));
return SUCCESS;
case IS_DOUBLE:
*result = zend_hash_index_find(Z_ARR_P(op1), zend_dval_to_lval(Z_DVAL_P(op2)));
case IS_DOUBLE: {
zend_long lval = zend_dval_to_lval(Z_DVAL_P(op2));
if (!zend_is_long_compatible(Z_DVAL_P(op2), lval)) {
return FAILURE;
}
*result = zend_hash_index_find(Z_ARR_P(op1), lval);
return SUCCESS;
}
case IS_STRING:
*result = zend_symtable_find(Z_ARR_P(op1), Z_STR_P(op2));
return SUCCESS;
@@ -509,9 +513,14 @@ static inline int ct_eval_del_array_elem(zval *result, zval *key) {
case IS_LONG:
zend_hash_index_del(Z_ARR_P(result), Z_LVAL_P(key));
break;
case IS_DOUBLE:
zend_hash_index_del(Z_ARR_P(result), zend_dval_to_lval(Z_DVAL_P(key)));
case IS_DOUBLE: {
zend_long lval = zend_dval_to_lval(Z_DVAL_P(key));
if (!zend_is_long_compatible(Z_DVAL_P(key), lval)) {
return FAILURE;
}
zend_hash_index_del(Z_ARR_P(result), lval);
break;
}
case IS_STRING:
zend_symtable_del(Z_ARR_P(result), Z_STR_P(key));
break;
@@ -549,11 +558,16 @@ static inline int ct_eval_add_array_elem(zval *result, zval *value, zval *key) {
SEPARATE_ARRAY(result);
value = zend_hash_index_update(Z_ARR_P(result), Z_LVAL_P(key), value);
break;
case IS_DOUBLE:
case IS_DOUBLE: {
zend_long lval = zend_dval_to_lval(Z_DVAL_P(key));
if (!zend_is_long_compatible(Z_DVAL_P(key), lval)) {
return FAILURE;
}
SEPARATE_ARRAY(result);
value = zend_hash_index_update(
Z_ARR_P(result), zend_dval_to_lval(Z_DVAL_P(key)), value);
Z_ARR_P(result), lval, value);
break;
}
case IS_STRING:
SEPARATE_ARRAY(result);
value = zend_symtable_update(Z_ARR_P(result), Z_STR_P(key), value);
@@ -576,9 +590,10 @@ static inline int ct_eval_add_array_unpack(zval *result, zval *array) {
SEPARATE_ARRAY(result);
ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(array), key, value) {
if (key) {
return FAILURE;
value = zend_hash_update(Z_ARR_P(result), key, value);
} else {
value = zend_hash_next_index_insert(Z_ARR_P(result), value);
}
value = zend_hash_next_index_insert(Z_ARR_P(result), value);
if (!value) {
return FAILURE;
}
@@ -592,7 +607,7 @@ static inline int ct_eval_assign_dim(zval *result, zval *value, zval *key) {
case IS_NULL:
case IS_FALSE:
array_init(result);
/* break missing intentionally */
ZEND_FALLTHROUGH;
case IS_ARRAY:
case PARTIAL_ARRAY:
return ct_eval_add_array_elem(result, value, key);
@@ -695,7 +710,7 @@ static inline int ct_eval_assign_obj(zval *result, zval *value, zval *key) {
case IS_NULL:
case IS_FALSE:
empty_partial_object(result);
/* break missing intentionally */
ZEND_FALLTHROUGH;
case PARTIAL_OBJECT:
return ct_eval_add_obj_prop(result, value, key);
default:
@@ -728,7 +743,7 @@ static inline void ct_eval_type_check(zval *result, uint32_t type_mask, zval *op
static inline int ct_eval_in_array(zval *result, uint32_t extended_value, zval *op1, zval *op2) {
HashTable *ht;
zend_bool res;
bool res;
if (Z_TYPE_P(op2) != IS_ARRAY) {
return FAILURE;
@@ -781,13 +796,15 @@ static inline int ct_eval_array_key_exists(zval *result, zval *op1, zval *op2) {
return SUCCESS;
}
static zend_bool can_ct_eval_func_call(zend_string *name, uint32_t num_args, zval **args) {
static bool can_ct_eval_func_call(zend_string *name, uint32_t num_args, zval **args) {
/* Functions that can be evaluated independently of what the arguments are.
* It's okay if these functions throw on invalid arguments, but they should not warn. */
if (false
|| zend_string_equals_literal(name, "array_diff")
|| zend_string_equals_literal(name, "array_diff_assoc")
|| zend_string_equals_literal(name, "array_diff_key")
|| zend_string_equals_literal(name, "array_flip")
|| zend_string_equals_literal(name, "array_is_list")
|| zend_string_equals_literal(name, "array_key_exists")
|| zend_string_equals_literal(name, "array_keys")
|| zend_string_equals_literal(name, "array_merge")
@@ -797,8 +814,13 @@ static zend_bool can_ct_eval_func_call(zend_string *name, uint32_t num_args, zva
|| zend_string_equals_literal(name, "array_values")
|| zend_string_equals_literal(name, "base64_decode")
|| zend_string_equals_literal(name, "base64_encode")
#ifndef ZEND_WIN32
/* On Windows this function may be code page dependent. */
|| zend_string_equals_literal(name, "dirname")
#endif
|| zend_string_equals_literal(name, "imagetypes")
|| zend_string_equals_literal(name, "in_array")
|| zend_string_equals_literal(name, "implode")
|| zend_string_equals_literal(name, "ltrim")
|| zend_string_equals_literal(name, "php_sapi_name")
|| zend_string_equals_literal(name, "php_uname")
@@ -823,41 +845,6 @@ static zend_bool can_ct_eval_func_call(zend_string *name, uint32_t num_args, zva
return true;
}
/* For the following functions we need to check arguments to prevent warnings during
* evaluation. */
if (num_args == 1) {
if (zend_string_equals_literal(name, "array_flip")) {
zval *entry;
if (Z_TYPE_P(args[0]) != IS_ARRAY) {
return false;
}
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(args[0]), entry) {
/* Throws warning for non int/string values. */
if (Z_TYPE_P(entry) != IS_LONG && Z_TYPE_P(entry) != IS_STRING) {
return false;
}
} ZEND_HASH_FOREACH_END();
return true;
}
if (zend_string_equals_literal(name, "implode")) {
zval *entry;
if (Z_TYPE_P(args[0]) != IS_ARRAY) {
return false;
}
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(args[0]), entry) {
/* May throw warning during conversion to string. */
if (Z_TYPE_P(entry) > IS_STRING) {
return false;
}
} ZEND_HASH_FOREACH_END();
return true;
}
return false;
}
if (num_args == 2) {
if (zend_string_equals_literal(name, "str_repeat")) {
/* Avoid creating overly large strings at compile-time. */
@@ -866,29 +853,6 @@ static zend_bool can_ct_eval_func_call(zend_string *name, uint32_t num_args, zva
&& Z_TYPE_P(args[1]) == IS_LONG
&& zend_safe_address(Z_STRLEN_P(args[0]), Z_LVAL_P(args[1]), 0, &overflow) < 64 * 1024
&& !overflow;
} else if (zend_string_equals_literal(name, "implode")) {
zval *entry;
if ((Z_TYPE_P(args[0]) != IS_STRING || Z_TYPE_P(args[1]) != IS_ARRAY)
&& (Z_TYPE_P(args[0]) != IS_ARRAY || Z_TYPE_P(args[1]) != IS_STRING)) {
return false;
}
/* May throw warning during conversion to string. */
if (Z_TYPE_P(args[0]) == IS_ARRAY) {
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(args[0]), entry) {
if (Z_TYPE_P(entry) > IS_STRING) {
return false;
}
} ZEND_HASH_FOREACH_END();
} else {
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(args[1]), entry) {
if (Z_TYPE_P(entry) > IS_STRING) {
return false;
}
} ZEND_HASH_FOREACH_END();
}
return true;
}
return false;
}
@@ -966,6 +930,10 @@ static inline int ct_eval_func_call(
execute_data->prev_execute_data = &dummy_frame;
EG(current_execute_data) = execute_data;
/* Enable suppression and counting of warnings. */
ZEND_ASSERT(EG(capture_warnings_during_sccp) == 0);
EG(capture_warnings_during_sccp) = 1;
EX(func) = func;
EX_NUM_ARGS() = num_args;
for (i = 0; i < num_args; i++) {
@@ -984,6 +952,12 @@ static inline int ct_eval_func_call(
retval = FAILURE;
}
if (EG(capture_warnings_during_sccp) > 1) {
zval_ptr_dtor(result);
retval = FAILURE;
}
EG(capture_warnings_during_sccp) = 0;
efree(execute_data);
EG(current_execute_data) = prev_execute_data;
return retval;
@@ -1812,7 +1786,7 @@ static void sccp_visit_instr(scdf_ctx *scdf, zend_op *opline, zend_ssa_op *ssa_o
}
/* We're only interested in functions with up to three arguments right now */
if (call->num_args > 3 || call->send_unpack) {
if (call->num_args > 3 || call->send_unpack || call->is_prototype) {
SET_RESULT_BOT(result);
break;
}
@@ -1953,9 +1927,9 @@ static void sccp_mark_feasible_successors(
case ZEND_SWITCH_STRING:
case ZEND_MATCH:
{
zend_bool strict_comparison = opline->opcode == ZEND_MATCH;
bool strict_comparison = opline->opcode == ZEND_MATCH;
zend_uchar type = Z_TYPE_P(op1);
zend_bool correct_type =
bool correct_type =
(opline->opcode == ZEND_SWITCH_LONG && type == IS_LONG)
|| (opline->opcode == ZEND_SWITCH_STRING && type == IS_STRING)
|| (opline->opcode == ZEND_MATCH && (type == IS_LONG || type == IS_STRING));
@@ -1983,7 +1957,7 @@ static void sccp_mark_feasible_successors(
scdf_mark_edge_feasible(scdf, block_num, target);
return;
}
s = 0;
s = block->successors_count - 1;
break;
}
default:
@@ -2051,7 +2025,7 @@ static int join_partial_objects(zval *a, zval *b)
return SUCCESS;
}
static void join_phi_values(zval *a, zval *b, zend_bool escape) {
static void join_phi_values(zval *a, zval *b, bool escape) {
if (IS_BOT(a) || IS_TOP(b)) {
return;
}
@@ -7,7 +7,7 @@
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
@@ -16,7 +16,6 @@
+----------------------------------------------------------------------+
*/
#include "ZendAccelerator.h"
#include "Optimizer/zend_optimizer_internal.h"
#include "Optimizer/scdf.h"
@@ -185,7 +184,7 @@ void scdf_solve(scdf_ctx *scdf, const char *name) {
/* If a live range starts in a reachable block and ends in an unreachable block, we should
* not eliminate the latter. While it cannot be reached, the FREE opcode of the loop var
* is necessary for the correctness of temporary compaction. */
static zend_bool kept_alive_by_loop_var_free(scdf_ctx *scdf, uint32_t block_idx) {
static bool kept_alive_by_loop_var_free(scdf_ctx *scdf, uint32_t block_idx) {
uint32_t i;
const zend_op_array *op_array = scdf->op_array;
const zend_cfg *cfg = &scdf->ssa->cfg;
@@ -7,7 +7,7 @@
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
@@ -89,7 +89,7 @@ static inline uint32_t scdf_edge(zend_cfg *cfg, int from, int to) {
ZEND_UNREACHABLE();
}
static inline zend_bool scdf_is_edge_feasible(scdf_ctx *scdf, int from, int to) {
static inline bool scdf_is_edge_feasible(scdf_ctx *scdf, int from, int to) {
uint32_t edge = scdf_edge(&scdf->ssa->cfg, from, to);
return zend_bitset_in(scdf->feasible_edges, edge);
}
@@ -7,7 +7,7 @@
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
@@ -16,13 +16,12 @@
+----------------------------------------------------------------------+
*/
#include "ZendAccelerator.h"
#include "Optimizer/zend_optimizer_internal.h"
/* The ssa_verify_integrity() function ensures that that certain invariants of the SSA form and
* CFG are upheld and prints messages to stderr if this is not the case. */
static inline zend_bool is_in_use_chain(zend_ssa *ssa, int var, int check) {
static inline bool is_in_use_chain(zend_ssa *ssa, int var, int check) {
int use;
FOREACH_USE(&ssa->vars[var], use) {
if (use == check) {
@@ -32,7 +31,7 @@ static inline zend_bool is_in_use_chain(zend_ssa *ssa, int var, int check) {
return 0;
}
static inline zend_bool is_in_phi_use_chain(zend_ssa *ssa, int var, zend_ssa_phi *check) {
static inline bool is_in_phi_use_chain(zend_ssa *ssa, int var, zend_ssa_phi *check) {
zend_ssa_phi *phi;
FOREACH_PHI_USE(&ssa->vars[var], phi) {
if (phi == check) {
@@ -42,21 +41,21 @@ static inline zend_bool is_in_phi_use_chain(zend_ssa *ssa, int var, zend_ssa_phi
return 0;
}
static inline zend_bool is_used_by_op(zend_ssa *ssa, int op, int check) {
static inline bool is_used_by_op(zend_ssa *ssa, int op, int check) {
zend_ssa_op *ssa_op = &ssa->ops[op];
return (ssa_op->op1_use == check)
|| (ssa_op->op2_use == check)
|| (ssa_op->result_use == check);
}
static inline zend_bool is_defined_by_op(zend_ssa *ssa, int op, int check) {
static inline bool is_defined_by_op(zend_ssa *ssa, int op, int check) {
zend_ssa_op *ssa_op = &ssa->ops[op];
return (ssa_op->op1_def == check)
|| (ssa_op->op2_def == check)
|| (ssa_op->result_def == check);
}
static inline zend_bool is_in_phi_sources(zend_ssa *ssa, zend_ssa_phi *phi, int check) {
static inline bool is_in_phi_sources(zend_ssa *ssa, zend_ssa_phi *phi, int check) {
int source;
FOREACH_PHI_SOURCE(phi, source) {
if (source == check) {
@@ -66,7 +65,7 @@ static inline zend_bool is_in_phi_sources(zend_ssa *ssa, zend_ssa_phi *phi, int
return 0;
}
static inline zend_bool is_in_predecessors(zend_cfg *cfg, zend_basic_block *block, int check) {
static inline bool is_in_predecessors(zend_cfg *cfg, zend_basic_block *block, int check) {
int i, *predecessors = &cfg->predecessors[block->predecessor_offset];
for (i = 0; i < block->predecessors_count; i++) {
if (predecessors[i] == check) {
@@ -76,7 +75,7 @@ static inline zend_bool is_in_predecessors(zend_cfg *cfg, zend_basic_block *bloc
return 0;
}
static inline zend_bool is_in_successors(zend_basic_block *block, int check) {
static inline bool is_in_successors(zend_basic_block *block, int check) {
int s;
for (s = 0; s < block->successors_count; s++) {
if (block->successors[s] == check) {
@@ -86,7 +85,7 @@ static inline zend_bool is_in_successors(zend_basic_block *block, int check) {
return 0;
}
static inline zend_bool is_var_type(zend_uchar type) {
static inline bool is_var_type(zend_uchar type) {
return (type & (IS_CV|IS_VAR|IS_TMP_VAR)) != 0;
}
@@ -7,7 +7,7 @@
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
@@ -16,7 +16,6 @@
+----------------------------------------------------------------------+
*/
#include "php.h"
#include "zend_compile.h"
#include "zend_extensions.h"
#include "Optimizer/zend_optimizer.h"
@@ -44,7 +43,7 @@ static void zend_op_array_collect(zend_op_array *op_array, void *context)
call_graph->op_arrays_count++;
}
int zend_analyze_calls(zend_arena **arena, zend_script *script, uint32_t build_flags, zend_op_array *op_array, zend_func_info *func_info)
ZEND_API int zend_analyze_calls(zend_arena **arena, zend_script *script, uint32_t build_flags, zend_op_array *op_array, zend_func_info *func_info)
{
zend_op *opline = op_array->opcodes;
zend_op *end = opline + op_array->last;
@@ -53,7 +52,7 @@ int zend_analyze_calls(zend_arena **arena, zend_script *script, uint32_t build_f
int call = 0;
zend_call_info **call_stack;
ALLOCA_FLAG(use_heap);
zend_bool is_prototype;
bool is_prototype;
call_stack = do_alloca((op_array->last / 2) * sizeof(zend_call_info*), use_heap);
call_info = NULL;
@@ -65,8 +64,7 @@ int zend_analyze_calls(zend_arena **arena, zend_script *script, uint32_t build_f
call_stack[call] = call_info;
func = zend_optimizer_get_called_func(
script, op_array, opline, &is_prototype);
/* TODO: Support prototypes? */
if (func && !is_prototype) {
if (func) {
call_info = zend_arena_calloc(arena, 1, sizeof(zend_call_info) + (sizeof(zend_send_arg_info) * ((int)opline->extended_value - 1)));
call_info->caller_op_array = op_array;
call_info->caller_init_opline = opline;
@@ -74,6 +72,7 @@ int zend_analyze_calls(zend_arena **arena, zend_script *script, uint32_t build_f
call_info->callee_func = func;
call_info->num_args = opline->extended_value;
call_info->next_callee = func_info->callee_info;
call_info->is_prototype = is_prototype;
func_info->callee_info = call_info;
if (build_flags & ZEND_CALL_TREE) {
@@ -194,7 +193,11 @@ static void zend_analyze_recursion(zend_call_graph *call_graph)
op_array = call_graph->op_arrays[i];
func_info = call_graph->func_infos + i;
call_info = func_info->caller_info;
while (call_info) {
for (; call_info; call_info = call_info->next_caller) {
if (call_info->is_prototype) {
/* Might be calling an overridden child method and not actually recursive. */
continue;
}
if (call_info->caller_op_array == op_array) {
call_info->recursive = 1;
func_info->flags |= ZEND_FUNC_RECURSIVE | ZEND_FUNC_RECURSIVE_DIRECTLY;
@@ -205,7 +208,6 @@ static void zend_analyze_recursion(zend_call_graph *call_graph)
func_info->flags |= ZEND_FUNC_RECURSIVE | ZEND_FUNC_RECURSIVE_INDIRECTLY;
}
}
call_info = call_info->next_caller;
}
}
@@ -219,7 +221,7 @@ static void zend_sort_op_arrays(zend_call_graph *call_graph)
// TODO: perform topological sort of cyclic call graph
}
int zend_build_call_graph(zend_arena **arena, zend_script *script, zend_call_graph *call_graph) /* {{{ */
ZEND_API int zend_build_call_graph(zend_arena **arena, zend_script *script, zend_call_graph *call_graph) /* {{{ */
{
call_graph->op_arrays_count = 0;
zend_foreach_op_array(script, zend_op_array_calc, call_graph);
@@ -233,7 +235,7 @@ int zend_build_call_graph(zend_arena **arena, zend_script *script, zend_call_gra
}
/* }}} */
void zend_analyze_call_graph(zend_arena **arena, zend_script *script, zend_call_graph *call_graph) /* {{{ */
ZEND_API void zend_analyze_call_graph(zend_arena **arena, zend_script *script, zend_call_graph *call_graph) /* {{{ */
{
int i;
@@ -245,7 +247,7 @@ void zend_analyze_call_graph(zend_arena **arena, zend_script *script, zend_call_
}
/* }}} */
zend_call_info **zend_build_call_map(zend_arena **arena, zend_func_info *info, const zend_op_array *op_array) /* {{{ */
ZEND_API zend_call_info **zend_build_call_map(zend_arena **arena, zend_func_info *info, const zend_op_array *op_array) /* {{{ */
{
zend_call_info **map, *call;
if (!info->callee_info) {
@@ -7,7 +7,7 @@
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
@@ -34,9 +34,10 @@ struct _zend_call_info {
zend_function *callee_func;
zend_call_info *next_caller;
zend_call_info *next_callee;
zend_bool recursive;
zend_bool send_unpack; /* Parameters passed by SEND_UNPACK or SEND_ARRAY */
zend_bool named_args; /* Function has named arguments */
bool recursive;
bool send_unpack; /* Parameters passed by SEND_UNPACK or SEND_ARRAY */
bool named_args; /* Function has named arguments */
bool is_prototype; /* An overridden child method may be called */
int num_args;
zend_send_arg_info arg_info[1];
};
@@ -44,7 +45,7 @@ struct _zend_call_info {
struct _zend_func_info {
int num;
uint32_t flags;
zend_ssa ssa; /* Static Single Assignmnt Form */
zend_ssa ssa; /* Static Single Assignment Form */
zend_call_info *caller_info; /* where this function is called from */
zend_call_info *callee_info; /* which functions are called from this one */
zend_call_info **call_map; /* Call info associated with init/call/send opnum */
@@ -59,10 +60,10 @@ typedef struct _zend_call_graph {
BEGIN_EXTERN_C()
int zend_build_call_graph(zend_arena **arena, zend_script *script, zend_call_graph *call_graph);
void zend_analyze_call_graph(zend_arena **arena, zend_script *script, zend_call_graph *call_graph);
zend_call_info **zend_build_call_map(zend_arena **arena, zend_func_info *info, const zend_op_array *op_array);
int zend_analyze_calls(zend_arena **arena, zend_script *script, uint32_t build_flags, zend_op_array *op_array, zend_func_info *func_info);
ZEND_API int zend_build_call_graph(zend_arena **arena, zend_script *script, zend_call_graph *call_graph);
ZEND_API void zend_analyze_call_graph(zend_arena **arena, zend_script *script, zend_call_graph *call_graph);
ZEND_API zend_call_info **zend_build_call_map(zend_arena **arena, zend_func_info *info, const zend_op_array *op_array);
ZEND_API int zend_analyze_calls(zend_arena **arena, zend_script *script, uint32_t build_flags, zend_op_array *op_array, zend_func_info *func_info);
END_EXTERN_C()
@@ -7,7 +7,7 @@
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
@@ -16,13 +16,13 @@
+----------------------------------------------------------------------+
*/
#include "php.h"
#include "zend_compile.h"
#include "zend_cfg.h"
#include "zend_func_info.h"
#include "zend_worklist.h"
#include "zend_optimizer.h"
#include "zend_optimizer_internal.h"
#include "zend_sort.h"
static void zend_mark_reachable(zend_op *opcodes, zend_cfg *cfg, zend_basic_block *b) /* {{{ */
{
@@ -269,7 +269,7 @@ static void initialize_block(zend_basic_block *block) {
block_map[i]++; \
} while (0)
int zend_build_cfg(zend_arena **arena, const zend_op_array *op_array, uint32_t build_flags, zend_cfg *cfg) /* {{{ */
ZEND_API int zend_build_cfg(zend_arena **arena, const zend_op_array *op_array, uint32_t build_flags, zend_cfg *cfg) /* {{{ */
{
uint32_t flags = 0;
uint32_t i;
@@ -279,7 +279,7 @@ int zend_build_cfg(zend_arena **arena, const zend_op_array *op_array, uint32_t b
int blocks_count = 0;
zend_basic_block *blocks;
zval *zv;
zend_bool extra_entry_block = 0;
bool extra_entry_block = 0;
cfg->flags = build_flags & (ZEND_CFG_STACKLESS|ZEND_CFG_RECV_ENTRY);
@@ -301,6 +301,7 @@ int zend_build_cfg(zend_arena **arena, const zend_op_array *op_array, uint32_t b
case ZEND_GENERATOR_RETURN:
case ZEND_EXIT:
case ZEND_MATCH_ERROR:
case ZEND_VERIFY_NEVER_TYPE:
if (i + 1 < op_array->last) {
BB_START(i + 1);
}
@@ -314,6 +315,7 @@ int zend_build_cfg(zend_arena **arena, const zend_op_array *op_array, uint32_t b
break;
case ZEND_INCLUDE_OR_EVAL:
flags |= ZEND_FUNC_INDIRECT_VAR_ACCESS;
ZEND_FALLTHROUGH;
case ZEND_GENERATOR_CREATE:
case ZEND_YIELD:
case ZEND_YIELD_FROM:
@@ -514,6 +516,7 @@ int zend_build_cfg(zend_arena **arena, const zend_op_array *op_array, uint32_t b
case ZEND_EXIT:
case ZEND_THROW:
case ZEND_MATCH_ERROR:
case ZEND_VERIFY_NEVER_TYPE:
break;
case ZEND_JMP:
block->successors_count = 1;
@@ -599,7 +602,7 @@ int zend_build_cfg(zend_arena **arena, const zend_op_array *op_array, uint32_t b
}
/* }}} */
int zend_cfg_build_predecessors(zend_arena **arena, zend_cfg *cfg) /* {{{ */
ZEND_API int zend_cfg_build_predecessors(zend_arena **arena, zend_cfg *cfg) /* {{{ */
{
int j, s, edges;
zend_basic_block *b;
@@ -682,7 +685,7 @@ static void compute_postnum_recursive(
/* Computes dominator tree using algorithm from "A Simple, Fast Dominance Algorithm" by
* Cooper, Harvey and Kennedy. */
int zend_cfg_compute_dominators_tree(const zend_op_array *op_array, zend_cfg *cfg) /* {{{ */
ZEND_API int zend_cfg_compute_dominators_tree(const zend_op_array *op_array, zend_cfg *cfg) /* {{{ */
{
zend_basic_block *blocks = cfg->blocks;
int blocks_count = cfg->blocks_count;
@@ -795,7 +798,7 @@ static void swap_blocks(block_info *a, block_info *b) {
*b = tmp;
}
int zend_cfg_identify_loops(const zend_op_array *op_array, zend_cfg *cfg) /* {{{ */
ZEND_API int zend_cfg_identify_loops(const zend_op_array *op_array, zend_cfg *cfg) /* {{{ */
{
int i, j, k, n;
int time;
@@ -7,7 +7,7 @@
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
@@ -116,11 +116,11 @@ typedef struct _zend_cfg {
BEGIN_EXTERN_C()
int zend_build_cfg(zend_arena **arena, const zend_op_array *op_array, uint32_t build_flags, zend_cfg *cfg);
ZEND_API int zend_build_cfg(zend_arena **arena, const zend_op_array *op_array, uint32_t build_flags, zend_cfg *cfg);
void zend_cfg_remark_reachable_blocks(const zend_op_array *op_array, zend_cfg *cfg);
int zend_cfg_build_predecessors(zend_arena **arena, zend_cfg *cfg);
int zend_cfg_compute_dominators_tree(const zend_op_array *op_array, zend_cfg *cfg);
int zend_cfg_identify_loops(const zend_op_array *op_array, zend_cfg *cfg);
ZEND_API int zend_cfg_build_predecessors(zend_arena **arena, zend_cfg *cfg);
ZEND_API int zend_cfg_compute_dominators_tree(const zend_op_array *op_array, zend_cfg *cfg);
ZEND_API int zend_cfg_identify_loops(const zend_op_array *op_array, zend_cfg *cfg);
END_EXTERN_C()
@@ -7,7 +7,7 @@
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
@@ -16,7 +16,6 @@
+----------------------------------------------------------------------+
*/
#include "php.h"
#include "zend_compile.h"
#include "zend_dfg.h"
@@ -195,7 +194,7 @@ add_op1_def:
if (!zend_bitset_in(def, var_num)) {
zend_bitset_incl(use, var_num);
}
/* break missing intentionally */
ZEND_FALLTHROUGH;
case ZEND_INIT_ARRAY:
if (((build_flags & ZEND_SSA_RC_INFERENCE)
|| (opline->extended_value & ZEND_ARRAY_ELEMENT_REF))
@@ -242,7 +241,7 @@ add_op1_def:
}
/* }}} */
void zend_dfg_add_use_def_op(const zend_op_array *op_array, const zend_op *opline, uint32_t build_flags, zend_bitset use, zend_bitset def) /* {{{ */
ZEND_API void zend_dfg_add_use_def_op(const zend_op_array *op_array, const zend_op *opline, uint32_t build_flags, zend_bitset use, zend_bitset def) /* {{{ */
{
_zend_dfg_add_use_def_op(op_array, opline, build_flags, use, def);
}
@@ -7,7 +7,7 @@
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
@@ -44,7 +44,7 @@ typedef struct _zend_dfg {
BEGIN_EXTERN_C()
int zend_build_dfg(const zend_op_array *op_array, const zend_cfg *cfg, zend_dfg *dfg, uint32_t build_flags);
void zend_dfg_add_use_def_op(const zend_op_array *op_array, const zend_op *opline, uint32_t build_flags, zend_bitset use, zend_bitset def);
ZEND_API void zend_dfg_add_use_def_op(const zend_op_array *op_array, const zend_op *opline, uint32_t build_flags, zend_bitset use, zend_bitset def);
END_EXTERN_C()
@@ -7,7 +7,7 @@
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
@@ -16,7 +16,6 @@
+----------------------------------------------------------------------+
*/
#include "php.h"
#include "zend_compile.h"
#include "zend_cfg.h"
#include "zend_ssa.h"
@@ -101,7 +100,7 @@ static void zend_dump_class_fetch_type(uint32_t fetch_type)
break;
}
if (fetch_type & ZEND_FETCH_CLASS_NO_AUTOLOAD) {
fprintf(stderr, " (no-autolod)");
fprintf(stderr, " (no-autoload)");
}
if (fetch_type & ZEND_FETCH_CLASS_SILENT) {
fprintf(stderr, " (silent)");
@@ -133,7 +132,7 @@ static void zend_dump_unused_op(const zend_op *opline, znode_op op, uint32_t fla
}
}
void zend_dump_var(const zend_op_array *op_array, zend_uchar var_type, int var_num)
ZEND_API void zend_dump_var(const zend_op_array *op_array, zend_uchar var_type, int var_num)
{
if (var_type == IS_CV && var_num < op_array->last_var) {
fprintf(stderr, "CV%d($%s)", var_num, op_array->vars[var_num]->val);
@@ -332,7 +331,7 @@ static void zend_dump_ssa_var_info(const zend_ssa *ssa, int ssa_var_num, uint32_
dump_flags);
}
void zend_dump_ssa_var(const zend_op_array *op_array, const zend_ssa *ssa, int ssa_var_num, zend_uchar var_type, int var_num, uint32_t dump_flags)
ZEND_API void zend_dump_ssa_var(const zend_op_array *op_array, const zend_ssa *ssa, int ssa_var_num, zend_uchar var_type, int var_num, uint32_t dump_flags)
{
if (ssa_var_num >= 0) {
fprintf(stderr, "#%d.", ssa_var_num);
@@ -405,7 +404,7 @@ static void zend_dump_range_constraint(const zend_op_array *op_array, const zend
}
}
void zend_dump_op(const zend_op_array *op_array, const zend_basic_block *b, const zend_op *opline, uint32_t dump_flags, const zend_ssa *ssa, const zend_ssa_op *ssa_op)
ZEND_API void zend_dump_op(const zend_op_array *op_array, const zend_basic_block *b, const zend_op *opline, uint32_t dump_flags, const zend_ssa *ssa, const zend_ssa_op *ssa_op)
{
const char *name = zend_get_opcode_name(opline->opcode);
uint32_t flags = zend_get_opcode_flags(opline->opcode);
@@ -471,6 +470,9 @@ void zend_dump_op(const zend_op_array *op_array, const zend_basic_block *b, cons
case IS_VOID:
fprintf(stderr, " (void)");
break;
case IS_NEVER:
fprintf(stderr, " (never)");
break;
default:
fprintf(stderr, " (\?\?\?)");
break;
@@ -881,7 +883,7 @@ void zend_dump_op_array_name(const zend_op_array *op_array)
}
}
void zend_dump_op_array(const zend_op_array *op_array, uint32_t dump_flags, const char *msg, const void *data)
ZEND_API void zend_dump_op_array(const zend_op_array *op_array, uint32_t dump_flags, const char *msg, const void *data)
{
int i;
const zend_cfg *cfg = NULL;
@@ -926,7 +928,7 @@ void zend_dump_op_array(const zend_op_array *op_array, uint32_t dump_flags, cons
}
}
if (func_flags & ZEND_FUNC_IRREDUCIBLE) {
fprintf(stderr, ", irreducable");
fprintf(stderr, ", irreducible");
}
if (func_flags & ZEND_FUNC_NO_LOOPS) {
fprintf(stderr, ", no_loops");
@@ -7,7 +7,7 @@
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
@@ -30,15 +30,15 @@
BEGIN_EXTERN_C()
void zend_dump_op_array(const zend_op_array *op_array, uint32_t dump_flags, const char *msg, const void *data);
void zend_dump_op(const zend_op_array *op_array, const zend_basic_block *b, const zend_op *opline, uint32_t dump_flags, const zend_ssa *ssa, const zend_ssa_op *ssa_op);
ZEND_API void zend_dump_op_array(const zend_op_array *op_array, uint32_t dump_flags, const char *msg, const void *data);
ZEND_API void zend_dump_op(const zend_op_array *op_array, const zend_basic_block *b, const zend_op *opline, uint32_t dump_flags, const zend_ssa *ssa, const zend_ssa_op *ssa_op);
void zend_dump_dominators(const zend_op_array *op_array, const zend_cfg *cfg);
void zend_dump_dfg(const zend_op_array *op_array, const zend_cfg *cfg, const zend_dfg *dfg);
void zend_dump_phi_placement(const zend_op_array *op_array, const zend_ssa *ssa);
void zend_dump_variables(const zend_op_array *op_array);
void zend_dump_ssa_variables(const zend_op_array *op_array, const zend_ssa *ssa, uint32_t dump_flags);
void zend_dump_ssa_var(const zend_op_array *op_array, const zend_ssa *ssa, int ssa_var_num, zend_uchar var_type, int var_num, uint32_t dump_flags);
void zend_dump_var(const zend_op_array *op_array, zend_uchar var_type, int var_num);
ZEND_API void zend_dump_ssa_var(const zend_op_array *op_array, const zend_ssa *ssa, int ssa_var_num, zend_uchar var_type, int var_num, uint32_t dump_flags);
ZEND_API void zend_dump_var(const zend_op_array *op_array, zend_uchar var_type, int var_num);
void zend_dump_op_array_name(const zend_op_array *op_array);
void zend_dump_const(const zval *zv);
void zend_dump_ht(HashTable *ht);
@@ -7,7 +7,7 @@
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
@@ -17,7 +17,6 @@
+----------------------------------------------------------------------+
*/
#include "php.h"
#include "zend_compile.h"
#include "zend_extensions.h"
#include "zend_ssa.h"
@@ -45,10 +44,6 @@ typedef struct _func_info_t {
{name, sizeof(name)-1, (MAY_BE_RC1 | (info)), NULL}
#define FN(name, info) \
{name, sizeof(name)-1, (MAY_BE_RC1 | MAY_BE_RCN | (info)), NULL}
#define FR(name, info) \
{name, sizeof(name)-1, (MAY_BE_REF | (info)), NULL}
#define FX(name, info) \
{name, sizeof(name)-1, (MAY_BE_RC1 | MAY_BE_RCN | MAY_BE_REF | (info)), NULL}
#define FC(name, callback) \
{name, sizeof(name)-1, 0, callback}
@@ -90,12 +85,9 @@ static uint32_t zend_range_info(const zend_call_info *call_info, const zend_ssa
}
}
#define UNKNOWN_INFO (MAY_BE_ANY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF)
static const func_info_t func_infos[] = {
/* zend */
F1("zend_version", MAY_BE_STRING),
FN("func_get_arg", UNKNOWN_INFO),
FN("func_get_args", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_ANY),
F1("get_class_vars", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF),
F1("get_class_methods", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_STRING),
@@ -212,7 +204,7 @@ static const func_info_t func_infos[] = {
F1("base64_decode", MAY_BE_FALSE | MAY_BE_STRING),
F1("base64_encode", MAY_BE_STRING),
F1("password_hash", MAY_BE_STRING),
F1("password_get_info", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_LONG | MAY_BE_ARRAY_OF_STRING | MAY_BE_ARRAY_OF_ARRAY),
F1("password_get_info", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_NULL | MAY_BE_ARRAY_OF_LONG | MAY_BE_ARRAY_OF_STRING | MAY_BE_ARRAY_OF_ARRAY),
F1("convert_uuencode", MAY_BE_STRING),
F1("convert_uudecode", MAY_BE_FALSE | MAY_BE_STRING),
F1("pow", MAY_BE_LONG | MAY_BE_DOUBLE | MAY_BE_OBJECT),
@@ -250,14 +242,7 @@ static const func_info_t func_infos[] = {
F1("get_current_user", MAY_BE_STRING),
F1("get_cfg_var", MAY_BE_FALSE | MAY_BE_STRING | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_STRING | MAY_BE_ARRAY_OF_ARRAY),
F1("error_get_last", MAY_BE_NULL | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_LONG | MAY_BE_ARRAY_OF_STRING),
FN("call_user_func", UNKNOWN_INFO),
FN("call_user_func_array", UNKNOWN_INFO),
FN("call_user_method", UNKNOWN_INFO),
FN("call_user_method_array", UNKNOWN_INFO),
FN("forward_static_call", UNKNOWN_INFO),
FN("forward_static_call_array", UNKNOWN_INFO),
F1("serialize", MAY_BE_STRING),
FN("unserialize", UNKNOWN_INFO),
F1("var_export", MAY_BE_NULL | MAY_BE_STRING),
F1("print_r", MAY_BE_TRUE | MAY_BE_STRING),
F0("register_shutdown_function", MAY_BE_NULL | MAY_BE_FALSE),
@@ -360,19 +345,10 @@ static const func_info_t func_infos[] = {
F0("usort", MAY_BE_TRUE),
F0("uasort", MAY_BE_TRUE),
F0("uksort", MAY_BE_TRUE),
FN("end", UNKNOWN_INFO),
FN("prev", UNKNOWN_INFO),
FN("next", UNKNOWN_INFO),
FN("reset", UNKNOWN_INFO),
FN("current", UNKNOWN_INFO),
FN("min", UNKNOWN_INFO),
FN("max", UNKNOWN_INFO),
F1("compact", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY),
F1("array_fill", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_ANY),
F1("array_fill_keys", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY),
FC("range", zend_range_info),
FN("array_pop", UNKNOWN_INFO),
FN("array_shift", UNKNOWN_INFO),
F1("array_splice", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY),
F1("array_slice", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY),
F1("array_replace", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY),
@@ -382,7 +358,6 @@ static const func_info_t func_infos[] = {
F1("array_count_values", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_LONG),
F1("array_column", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY),
F1("array_reverse", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY),
F1("array_reduce", UNKNOWN_INFO),
F1("array_flip", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_LONG | MAY_BE_ARRAY_OF_STRING),
F1("array_change_key_case", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY),
FN("array_rand", MAY_BE_LONG | MAY_BE_STRING | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_LONG | MAY_BE_ARRAY_OF_STRING),
@@ -404,8 +379,6 @@ static const func_info_t func_infos[] = {
F1("array_filter", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY),
F1("array_chunk", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY),
F1("array_combine", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY),
F1("pos", UNKNOWN_INFO),
F1("assert_options", MAY_BE_NULL | MAY_BE_LONG | MAY_BE_STRING | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_STRING | MAY_BE_ARRAY_OF_OBJECT | MAY_BE_OBJECT),
F1("str_rot13", MAY_BE_STRING),
F1("stream_get_filters", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_STRING),
F1("stream_bucket_make_writeable", MAY_BE_NULL | MAY_BE_OBJECT),
@@ -418,7 +391,7 @@ static const func_info_t func_infos[] = {
F1("strftime", MAY_BE_FALSE | MAY_BE_STRING),
F1("gmstrftime", MAY_BE_FALSE | MAY_BE_STRING),
F1("localtime", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_LONG),
F1("getdate", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_LONG | MAY_BE_ARRAY_OF_STRING),
F1("getdate", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_LONG | MAY_BE_ARRAY_OF_STRING),
F1("date_create", MAY_BE_FALSE | MAY_BE_OBJECT),
F1("date_create_immutable", MAY_BE_FALSE | MAY_BE_OBJECT),
F1("date_create_from_format", MAY_BE_FALSE | MAY_BE_OBJECT),
@@ -452,7 +425,7 @@ static const func_info_t func_infos[] = {
F1("preg_grep", MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY),
/* ext/mysqli */
F1("mysqli_connect", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_OBJECT),
F1("mysqli_connect", MAY_BE_FALSE | MAY_BE_OBJECT),
F0("mysqli_close", MAY_BE_TRUE),
F1("mysqli_connect_error", MAY_BE_NULL | MAY_BE_STRING),
F1("mysqli_get_client_stats", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_STRING),
@@ -461,7 +434,7 @@ static const func_info_t func_infos[] = {
F1("mysqli_query", MAY_BE_FALSE | MAY_BE_TRUE | MAY_BE_OBJECT),
F1("mysqli_get_charset", MAY_BE_NULL | MAY_BE_OBJECT),
F1("mysqli_fetch_array", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY),
F1("mysqli_fetch_assoc", MAY_BE_NULL | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_ANY),
F1("mysqli_fetch_assoc", MAY_BE_NULL | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY),
F1("mysqli_fetch_all", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY),
F1("mysqli_fetch_object", MAY_BE_NULL | MAY_BE_OBJECT),
F1("mysqli_affected_rows", MAY_BE_LONG | MAY_BE_STRING),
@@ -478,7 +451,7 @@ static const func_info_t func_infos[] = {
F1("mysqli_fetch_field_direct", MAY_BE_FALSE | MAY_BE_OBJECT),
F1("mysqli_fetch_lengths", MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_LONG),
F1("mysqli_fetch_row", MAY_BE_NULL | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_ANY),
F1("mysqli_get_client_info", MAY_BE_NULL | MAY_BE_STRING),
F1("mysqli_get_client_info", MAY_BE_STRING),
F1("mysqli_get_host_info", MAY_BE_STRING),
F1("mysqli_get_server_info", MAY_BE_STRING),
F1("mysqli_info", MAY_BE_NULL | MAY_BE_STRING),
@@ -504,7 +477,6 @@ static const func_info_t func_infos[] = {
F1("curl_init", MAY_BE_FALSE | MAY_BE_OBJECT),
F1("curl_copy_handle", MAY_BE_FALSE | MAY_BE_OBJECT),
F1("curl_version", MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_LONG | MAY_BE_ARRAY_OF_STRING | MAY_BE_ARRAY_OF_ARRAY),
F1("curl_getinfo", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_STRING | MAY_BE_LONG | MAY_BE_DOUBLE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY),
F1("curl_error", MAY_BE_STRING),
F1("curl_strerror", MAY_BE_NULL | MAY_BE_STRING),
F1("curl_multi_strerror", MAY_BE_NULL | MAY_BE_STRING),
@@ -686,35 +658,30 @@ static const func_info_t func_infos[] = {
F1("session_encode", MAY_BE_FALSE | MAY_BE_STRING),
/* ext/pgsql */
F1("pg_connect", MAY_BE_FALSE | MAY_BE_RESOURCE),
FN("pg_pconnect", MAY_BE_FALSE | MAY_BE_RESOURCE),
F1("pg_dbname", MAY_BE_STRING),
F1("pg_last_error", MAY_BE_STRING),
F1("pg_options", MAY_BE_STRING),
F1("pg_port", MAY_BE_STRING),
F1("pg_tty", MAY_BE_STRING),
F1("pg_host", MAY_BE_STRING),
F1("pg_version", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_STRING | MAY_BE_ARRAY_OF_LONG | MAY_BE_ARRAY_OF_NULL),
F1("pg_parameter_status", MAY_BE_FALSE | MAY_BE_STRING),
F1("pg_query", MAY_BE_FALSE | MAY_BE_RESOURCE),
F1("pg_query_params", MAY_BE_FALSE | MAY_BE_RESOURCE),
F1("pg_prepare", MAY_BE_FALSE | MAY_BE_RESOURCE),
F1("pg_execute", MAY_BE_FALSE | MAY_BE_RESOURCE),
F1("pg_query", MAY_BE_FALSE | MAY_BE_OBJECT),
F1("pg_query_params", MAY_BE_FALSE | MAY_BE_OBJECT),
F1("pg_prepare", MAY_BE_FALSE | MAY_BE_OBJECT),
F1("pg_execute", MAY_BE_FALSE | MAY_BE_OBJECT),
FN("pg_last_notice", MAY_BE_FALSE | MAY_BE_TRUE | MAY_BE_STRING | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY ),
F1("pg_field_table", MAY_BE_FALSE | MAY_BE_LONG | MAY_BE_STRING),
F1("pg_field_name", MAY_BE_STRING),
F1("pg_field_type", MAY_BE_STRING),
F1("pg_field_type_oid", MAY_BE_LONG | MAY_BE_STRING),
F1("pg_fetch_result", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_STRING),
F1("pg_fetch_row", MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_NULL | MAY_BE_ARRAY_OF_STRING),
F1("pg_fetch_assoc", MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_NULL | MAY_BE_ARRAY_OF_STRING),
F1("pg_fetch_assoc", MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_NULL | MAY_BE_ARRAY_OF_STRING),
F1("pg_fetch_array", MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_NULL | MAY_BE_ARRAY_OF_STRING),
F1("pg_fetch_object", MAY_BE_FALSE | MAY_BE_OBJECT),
F1("pg_fetch_all", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_ARRAY),
F1("pg_fetch_all_columns", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_NULL | MAY_BE_ARRAY_OF_STRING),
F1("pg_last_oid", MAY_BE_FALSE | MAY_BE_LONG | MAY_BE_STRING),
F1("pg_lo_create", MAY_BE_FALSE | MAY_BE_LONG | MAY_BE_STRING),
F1("pg_lo_open", MAY_BE_FALSE | MAY_BE_RESOURCE),
F1("pg_lo_open", MAY_BE_FALSE | MAY_BE_OBJECT),
F1("pg_lo_read", MAY_BE_FALSE | MAY_BE_STRING),
F1("pg_lo_import", MAY_BE_FALSE | MAY_BE_LONG | MAY_BE_STRING),
F1("pg_copy_to", MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_STRING),
@@ -725,13 +692,13 @@ static const func_info_t func_infos[] = {
F1("pg_escape_identifier", MAY_BE_FALSE | MAY_BE_STRING),
F1("pg_result_error", MAY_BE_FALSE | MAY_BE_STRING),
F1("pg_result_error_field", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_STRING),
F1("pg_get_result", MAY_BE_FALSE | MAY_BE_RESOURCE),
F1("pg_get_result", MAY_BE_FALSE | MAY_BE_OBJECT),
F1("pg_result_status", MAY_BE_LONG | MAY_BE_STRING),
F1("pg_get_notify", MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY),
F1("pg_socket", MAY_BE_FALSE | MAY_BE_RESOURCE),
F1("pg_socket", MAY_BE_FALSE | MAY_BE_OBJECT),
F1("pg_meta_data", MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_ARRAY),
F1("pg_convert", MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_ANY),
F1("pg_insert", MAY_BE_FALSE | MAY_BE_TRUE | MAY_BE_RESOURCE | MAY_BE_STRING),
F1("pg_insert", MAY_BE_FALSE | MAY_BE_TRUE | MAY_BE_OBJECT | MAY_BE_STRING),
F1("pg_update", MAY_BE_FALSE | MAY_BE_TRUE | MAY_BE_STRING),
F1("pg_delete", MAY_BE_FALSE | MAY_BE_TRUE | MAY_BE_STRING),
F1("pg_select", MAY_BE_FALSE | MAY_BE_STRING | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_ARRAY),
@@ -752,10 +719,8 @@ static const func_info_t func_infos[] = {
F1("exif_thumbnail", MAY_BE_FALSE | MAY_BE_STRING),
/* ext/filter */
FN("filter_input", UNKNOWN_INFO),
FN("filter_var", UNKNOWN_INFO),
F1("filter_input_array", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY),
F1("filter_var_array", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY),
F1("filter_var_array", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF),
F1("filter_list", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_STRING),
/* ext/gettext */
@@ -776,7 +741,7 @@ static const func_info_t func_infos[] = {
#endif
/* ext/fileinfo */
F1("finfo_open", MAY_BE_FALSE | MAY_BE_RESOURCE),
F1("finfo_open", MAY_BE_FALSE | MAY_BE_OBJECT),
F1("finfo_file", MAY_BE_FALSE | MAY_BE_STRING),
F1("finfo_buffer", MAY_BE_FALSE | MAY_BE_STRING),
F1("mime_content_type", MAY_BE_FALSE | MAY_BE_STRING),
@@ -838,16 +803,17 @@ static const func_info_t func_infos[] = {
};
static HashTable func_info;
int zend_func_info_rid = -1;
ZEND_API int zend_func_info_rid = -1;
static uint32_t get_internal_func_info(
const zend_call_info *call_info, const zend_ssa *ssa, zend_string *lcname) {
if (call_info->callee_func->common.scope) {
const zend_call_info *call_info, const zend_ssa *ssa) {
zend_function *callee_func = call_info->callee_func;
if (callee_func->common.scope) {
/* This is a method, not a function. */
return 0;
}
zval *zv = zend_hash_find_ex(&func_info, lcname, 1);
zval *zv = zend_hash_find_ex(&func_info, callee_func->common.function_name, 1);
if (!zv) {
return 0;
}
@@ -860,9 +826,9 @@ static uint32_t get_internal_func_info(
}
}
uint32_t zend_get_func_info(
ZEND_API uint32_t zend_get_func_info(
const zend_call_info *call_info, const zend_ssa *ssa,
zend_class_entry **ce, zend_bool *ce_is_instanceof)
zend_class_entry **ce, bool *ce_is_instanceof)
{
uint32_t ret = 0;
const zend_function *callee_func = call_info->callee_func;
@@ -870,40 +836,27 @@ uint32_t zend_get_func_info(
*ce_is_instanceof = 0;
if (callee_func->type == ZEND_INTERNAL_FUNCTION) {
zend_string *lcname = Z_STR_P(CRT_CONSTANT_EX(call_info->caller_op_array, call_info->caller_init_opline, call_info->caller_init_opline->op2));
uint32_t internal_ret = get_internal_func_info(call_info, ssa, lcname);
uint32_t internal_ret = get_internal_func_info(call_info, ssa);
#if !ZEND_DEBUG
if (internal_ret) {
return internal_ret;
}
#endif
if (callee_func->common.fn_flags & ZEND_ACC_HAS_RETURN_TYPE) {
ret = zend_fetch_arg_info_type(NULL, callee_func->common.arg_info - 1, ce);
*ce_is_instanceof = 1;
} else {
#if 0
fprintf(stderr, "Unknown internal function '%s'\n", func->common.function_name);
#endif
ret = MAY_BE_ANY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF
| MAY_BE_RC1 | MAY_BE_RCN;
}
if (callee_func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) {
ret |= MAY_BE_REF;
}
ret = zend_get_return_info_from_signature_only(
callee_func, /* script */ NULL, ce, ce_is_instanceof, /* use_tentative_return_info */ !call_info->is_prototype);
#if ZEND_DEBUG
if (internal_ret) {
zend_string *name = callee_func->common.function_name;
/* Check whether the func_info information is a subset of the information we can
* compute from the specified return type, otherwise it contains redundant types. */
if (internal_ret & ~ret) {
fprintf(stderr, "Inaccurate func info for %s()\n", ZSTR_VAL(lcname));
fprintf(stderr, "Inaccurate func info for %s()\n", ZSTR_VAL(name));
}
/* Check whether the func info is completely redundant with arginfo.
* Ignore UNKNOWN_INFO for now. */
if (internal_ret == ret && (internal_ret & MAY_BE_ANY) != MAY_BE_ANY) {
fprintf(stderr, "Useless func info for %s()\n", ZSTR_VAL(lcname));
/* Check whether the func info is completely redundant with arginfo. */
if (internal_ret == ret) {
fprintf(stderr, "Useless func info for %s()\n", ZSTR_VAL(name));
}
/* If the return type is not mixed, check that the types match exactly if we exclude
* RC and array information. */
@@ -913,28 +866,25 @@ uint32_t zend_get_func_info(
/* Func info may contain "true" types as well as isolated "null" and "false". */
if (diff && !(diff == MAY_BE_FALSE && (ret & MAY_BE_FALSE))
&& (internal_ret_any & ~(MAY_BE_NULL|MAY_BE_FALSE))) {
fprintf(stderr, "Incorrect func info for %s()\n", ZSTR_VAL(lcname));
fprintf(stderr, "Incorrect func info for %s()\n", ZSTR_VAL(name));
}
}
return internal_ret;
}
#endif
} else {
// FIXME: the order of functions matters!!!
zend_func_info *info = ZEND_FUNC_INFO((zend_op_array*)callee_func);
if (info) {
ret = info->return_info.type;
*ce = info->return_info.ce;
*ce_is_instanceof = info->return_info.is_instanceof;
if (!call_info->is_prototype) {
// FIXME: the order of functions matters!!!
zend_func_info *info = ZEND_FUNC_INFO((zend_op_array*)callee_func);
if (info) {
ret = info->return_info.type;
*ce = info->return_info.ce;
*ce_is_instanceof = info->return_info.is_instanceof;
}
}
if (!ret) {
ret = MAY_BE_ANY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF
| MAY_BE_RC1 | MAY_BE_RCN;
/* For generators RETURN_REFERENCE refers to the yielded values. */
if ((callee_func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE)
&& !(callee_func->common.fn_flags & ZEND_ACC_GENERATOR)) {
ret |= MAY_BE_REF;
}
ret = zend_get_return_info_from_signature_only(
callee_func, /* TODO: script */ NULL, ce, ce_is_instanceof, /* use_tentative_return_info */ !call_info->is_prototype);
}
}
return ret;
@@ -7,7 +7,7 @@
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
@@ -54,11 +54,11 @@ typedef struct _zend_call_info zend_call_info;
BEGIN_EXTERN_C()
extern int zend_func_info_rid;
extern ZEND_API int zend_func_info_rid;
uint32_t zend_get_func_info(
ZEND_API uint32_t zend_get_func_info(
const zend_call_info *call_info, const zend_ssa *ssa,
zend_class_entry **ce, zend_bool *ce_is_instanceof);
zend_class_entry **ce, bool *ce_is_instanceof);
int zend_func_info_startup(void);
int zend_func_info_shutdown(void);
@@ -7,7 +7,7 @@
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
@@ -16,7 +16,6 @@
+----------------------------------------------------------------------+
*/
#include "php.h"
#include "zend_compile.h"
#include "zend_generators.h"
#include "zend_inference.h"
@@ -61,7 +60,7 @@
/* Pop elements in unspecified order from worklist until it is empty */
#define WHILE_WORKLIST(worklist, len, i) do { \
zend_bool _done = 0; \
bool _done = 0; \
while (!_done) { \
_done = 1; \
ZEND_BITSET_FOREACH(worklist, len, i) { \
@@ -158,12 +157,12 @@
} \
} while (0)
static inline zend_bool add_will_overflow(zend_long a, zend_long b) {
static inline bool add_will_overflow(zend_long a, zend_long b) {
return (b > 0 && a > ZEND_LONG_MAX - b)
|| (b < 0 && a < ZEND_LONG_MIN - b);
}
#if 0
static inline zend_bool sub_will_overflow(zend_long a, zend_long b) {
static inline bool sub_will_overflow(zend_long a, zend_long b) {
return (b > 0 && a < ZEND_LONG_MIN + b)
|| (b < 0 && a > ZEND_LONG_MAX + b);
}
@@ -207,7 +206,7 @@ static void zend_ssa_check_scc_var(const zend_op_array *op_array, zend_ssa *ssa,
}
/* }}} */
int zend_ssa_find_sccs(const zend_op_array *op_array, zend_ssa *ssa) /* {{{ */
ZEND_API int zend_ssa_find_sccs(const zend_op_array *op_array, zend_ssa *ssa) /* {{{ */
{
int index = 0, *dfs, *root;
zend_worklist_stack stack;
@@ -253,7 +252,7 @@ int zend_ssa_find_sccs(const zend_op_array *op_array, zend_ssa *ssa) /* {{{ */
}
/* }}} */
int zend_ssa_find_false_dependencies(const zend_op_array *op_array, zend_ssa *ssa) /* {{{ */
ZEND_API int zend_ssa_find_false_dependencies(const zend_op_array *op_array, zend_ssa *ssa) /* {{{ */
{
zend_ssa_var *ssa_vars = ssa->vars;
zend_ssa_op *ssa_ops = ssa->ops;
@@ -513,7 +512,7 @@ static void zend_ssa_range_and(zend_long a, zend_long b, zend_long c, zend_long
}
}
static inline zend_bool zend_abs_range(
static inline bool zend_abs_range(
zend_long min, zend_long max, zend_long *abs_min, zend_long *abs_max) {
if (min == ZEND_LONG_MIN) {
/* Cannot take absolute value of LONG_MIN */
@@ -539,7 +538,7 @@ static inline zend_long safe_shift_left(zend_long n, zend_long s) {
return (zend_long) ((zend_ulong) n << (zend_ulong) s);
}
static inline zend_bool shift_left_overflows(zend_long n, zend_long s) {
static inline bool shift_left_overflows(zend_long n, zend_long s) {
/* This considers shifts that shift in the sign bit to be overflowing as well */
if (n >= 0) {
return s >= SIZEOF_ZEND_LONG * 8 - 1 || safe_shift_left(n, s) < n;
@@ -1003,7 +1002,7 @@ int zend_inference_calc_range(const zend_op_array *op_array, zend_ssa *ssa, int
return zend_inference_propagate_range(op_array, ssa, opline, ssa_op, var, tmp);
}
int zend_inference_propagate_range(const zend_op_array *op_array, zend_ssa *ssa, zend_op *opline, zend_ssa_op* ssa_op, int var, zend_ssa_range *tmp)
ZEND_API int zend_inference_propagate_range(const zend_op_array *op_array, zend_ssa *ssa, zend_op *opline, zend_ssa_op* ssa_op, int var, zend_ssa_range *tmp)
{
zend_long op1_min, op2_min, op1_max, op2_max;
@@ -1463,7 +1462,7 @@ int zend_inference_propagate_range(const zend_op_array *op_array, zend_ssa *ssa,
}
call_info = func_info->call_map[opline - op_array->opcodes];
if (!call_info) {
if (!call_info || call_info->is_prototype) {
break;
}
if (call_info->callee_func->type == ZEND_USER_FUNCTION) {
@@ -1504,7 +1503,7 @@ int zend_inference_propagate_range(const zend_op_array *op_array, zend_ssa *ssa,
return 0;
}
void zend_inference_init_range(const zend_op_array *op_array, zend_ssa *ssa, int var, zend_bool underflow, zend_long min, zend_long max, zend_bool overflow)
void zend_inference_init_range(const zend_op_array *op_array, zend_ssa *ssa, int var, bool underflow, zend_long min, zend_long max, bool overflow)
{
if (underflow) {
min = ZEND_LONG_MIN;
@@ -1941,6 +1940,18 @@ static void add_usages(const zend_op_array *op_array, zend_ssa *ssa, zend_bitset
if (op->op2_def >= 0) {
zend_bitset_incl(worklist, op->op2_def);
}
} else if (use + 1 < op_array->last
&& op_array->opcodes[use + 1].opcode == ZEND_OP_DATA) {
op++;
if (op->result_def >= 0) {
zend_bitset_incl(worklist, op->result_def);
}
if (op->op1_def >= 0) {
zend_bitset_incl(worklist, op->op1_def);
}
if (op->op2_def >= 0) {
zend_bitset_incl(worklist, op->op2_def);
}
}
use = zend_ssa_next_use(ssa->ops, var, use);
} while (use >= 0);
@@ -1955,7 +1966,7 @@ static void emit_type_narrowing_warning(const zend_op_array *op_array, zend_ssa
zend_error(E_WARNING, "Narrowing occurred during type inference of %s. Please file a bug report on bugs.php.net", def_op_name);
}
uint32_t zend_array_element_type(uint32_t t1, zend_uchar op_type, int write, int insert)
ZEND_API uint32_t zend_array_element_type(uint32_t t1, zend_uchar op_type, int write, int insert)
{
uint32_t tmp = 0;
@@ -2198,7 +2209,7 @@ static uint32_t zend_convert_type_declaration_mask(uint32_t type_mask) {
return result_mask;
}
uint32_t zend_fetch_arg_info_type(const zend_script *script, zend_arg_info *arg_info, zend_class_entry **pce)
ZEND_API uint32_t zend_fetch_arg_info_type(const zend_script *script, zend_arg_info *arg_info, zend_class_entry **pce)
{
uint32_t tmp;
@@ -2345,7 +2356,7 @@ static zend_always_inline int _zend_update_type_info(
zend_ssa_op *ssa_op,
const zend_op **ssa_opcodes,
zend_long optimization_level,
zend_bool update_worklist)
bool update_worklist)
{
uint32_t t1, t2;
uint32_t tmp, orig;
@@ -3162,12 +3173,9 @@ static zend_always_inline int _zend_update_type_info(
case ZEND_ADD_ARRAY_UNPACK:
tmp = ssa_var_info[ssa_op->result_use].type;
ZEND_ASSERT(tmp & MAY_BE_ARRAY);
/* Ignore string keys as they will throw. */
if (t1 & MAY_BE_ARRAY_KEY_LONG) {
tmp |= MAY_BE_ARRAY_KEY_LONG | (t1 & (MAY_BE_ARRAY_OF_ANY|MAY_BE_ARRAY_OF_REF));
}
tmp |= t1 & (MAY_BE_ARRAY_KEY_ANY|MAY_BE_ARRAY_OF_ANY|MAY_BE_ARRAY_OF_REF);
if (t1 & MAY_BE_OBJECT) {
tmp |= MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_ANY;
tmp |= MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY;
}
UPDATE_SSA_TYPE(tmp, ssa_op->result_def);
break;
@@ -3213,12 +3221,18 @@ static zend_always_inline int _zend_update_type_info(
break;
case ZEND_FE_FETCH_R:
case ZEND_FE_FETCH_RW:
tmp = t2 & MAY_BE_REF;
tmp = 0;
if (opline->op2_type == IS_CV) {
tmp = t2 & MAY_BE_REF;
}
if (t1 & MAY_BE_OBJECT) {
if (opline->opcode == ZEND_FE_FETCH_RW) {
tmp |= MAY_BE_REF | MAY_BE_ANY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF;
} else {
tmp |= MAY_BE_REF | MAY_BE_RCN | MAY_BE_ANY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF;
tmp |= MAY_BE_RCN | MAY_BE_ANY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF;
if (opline->op2_type != IS_CV) {
tmp |= MAY_BE_REF;
}
}
}
if (t1 & MAY_BE_ARRAY) {
@@ -3231,6 +3245,9 @@ static zend_always_inline int _zend_update_type_info(
}
if (t1 & MAY_BE_ARRAY_OF_REF) {
tmp |= MAY_BE_RC1 | MAY_BE_RCN;
if (opline->op2_type != IS_CV) {
tmp |= MAY_BE_REF;
}
} else if (tmp & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)) {
tmp |= MAY_BE_RC1 | MAY_BE_RCN;
}
@@ -3478,7 +3495,7 @@ static zend_always_inline int _zend_update_type_info(
}
zend_class_entry *ce;
zend_bool ce_is_instanceof;
bool ce_is_instanceof;
tmp = zend_get_func_info(call_info, ssa, &ce, &ce_is_instanceof);
UPDATE_SSA_TYPE(tmp, ssa_op->result_def);
if (ce) {
@@ -3488,7 +3505,7 @@ static zend_always_inline int _zend_update_type_info(
break;
case ZEND_FETCH_CONSTANT:
case ZEND_FETCH_CLASS_CONSTANT:
UPDATE_SSA_TYPE(MAY_BE_RC1|MAY_BE_RCN|MAY_BE_NULL|MAY_BE_FALSE|MAY_BE_TRUE|MAY_BE_LONG|MAY_BE_DOUBLE|MAY_BE_STRING|MAY_BE_RESOURCE|MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_ANY|MAY_BE_ARRAY_OF_ANY, ssa_op->result_def);
UPDATE_SSA_TYPE(MAY_BE_RC1|MAY_BE_RCN|MAY_BE_ANY|MAY_BE_ARRAY_KEY_ANY|MAY_BE_ARRAY_OF_ANY, ssa_op->result_def);
break;
case ZEND_STRLEN:
tmp = MAY_BE_LONG;
@@ -3522,6 +3539,12 @@ static zend_always_inline int _zend_update_type_info(
} else {
zend_arg_info *ret_info = op_array->arg_info - 1;
tmp = zend_fetch_arg_info_type(script, ret_info, &ce);
// TODO: We could model more precisely how illegal types are converted.
uint32_t extra_types = t1 & ~tmp;
if (!extra_types) {
tmp &= t1;
}
}
if (opline->op1_type & (IS_TMP_VAR|IS_VAR|IS_CV)) {
UPDATE_SSA_TYPE(tmp, ssa_op->op1_def);
@@ -3595,7 +3618,7 @@ unknown_opcode:
return SUCCESS;
}
int zend_update_type_info(
ZEND_API int zend_update_type_info(
const zend_op_array *op_array,
zend_ssa *ssa,
const zend_script *script,
@@ -3661,7 +3684,7 @@ int zend_infer_types_ex(const zend_op_array *op_array, const zend_script *script
int ssa_vars_count = ssa->vars_count;
int i, j;
uint32_t tmp, worklist_len = zend_bitset_len(ssa_vars_count);
zend_bool update_worklist = 1;
bool update_worklist = 1;
while (!zend_bitset_empty(worklist, worklist_len)) {
j = zend_bitset_first(worklist, worklist_len);
@@ -3732,18 +3755,18 @@ int zend_infer_types_ex(const zend_op_array *op_array, const zend_script *script
return SUCCESS;
}
static zend_bool is_narrowable_instr(zend_op *opline) {
static bool is_narrowable_instr(zend_op *opline) {
return opline->opcode == ZEND_ADD || opline->opcode == ZEND_SUB
|| opline->opcode == ZEND_MUL || opline->opcode == ZEND_DIV;
}
static zend_bool is_effective_op1_double_cast(zend_op *opline, zval *op2) {
static bool is_effective_op1_double_cast(zend_op *opline, zval *op2) {
return (opline->opcode == ZEND_ADD && Z_LVAL_P(op2) == 0)
|| (opline->opcode == ZEND_SUB && Z_LVAL_P(op2) == 0)
|| (opline->opcode == ZEND_MUL && Z_LVAL_P(op2) == 1)
|| (opline->opcode == ZEND_DIV && Z_LVAL_P(op2) == 1);
}
static zend_bool is_effective_op2_double_cast(zend_op *opline, zval *op1) {
static bool is_effective_op2_double_cast(zend_op *opline, zval *op1) {
/* In PHP it holds that (double)(0-$int) is bitwise identical to 0.0-(double)$int,
* so allowing SUB here is fine. */
return (opline->opcode == ZEND_ADD && Z_LVAL_P(op1) == 0)
@@ -3766,11 +3789,11 @@ static zend_bool is_effective_op2_double_cast(zend_op *opline, zval *op1) {
* E.g. 0+$i and 0.0+$i only differ by that cast. If then the consuming instruction of this
* result will perform a double cast anyway, the conversion is safe.
*
* The checks happens recursively, while keeping track of which variables are already visisted to
* The checks happens recursively, while keeping track of which variables are already visited to
* avoid infinite loops. An iterative, worklist driven approach would be possible, but the state
* management more cumbersome to implement, so we don't bother for now.
*/
static zend_bool can_convert_to_double(
static bool can_convert_to_double(
const zend_op_array *op_array, zend_ssa *ssa, int var_num,
zval *value, zend_bitset visited) {
zend_ssa_var *var = &ssa->vars[var_num];
@@ -3908,7 +3931,7 @@ static int zend_type_narrowing(const zend_op_array *op_array, const zend_script
zend_bitset visited, worklist;
int i, v;
zend_op *opline;
zend_bool narrowed = 0;
bool narrowed = 0;
ALLOCA_FLAG(use_heap)
visited = ZEND_BITSET_ALLOCA(2 * bitset_len, use_heap);
@@ -3976,22 +3999,43 @@ static int is_recursive_tail_call(const zend_op_array *op_array,
return 0;
}
void zend_init_func_return_info(const zend_op_array *op_array,
const zend_script *script,
zend_ssa_var_info *ret)
{
if (op_array->fn_flags & ZEND_ACC_HAS_RETURN_TYPE) {
zend_arg_info *ret_info = op_array->arg_info - 1;
zend_ssa_range tmp_range = {0, 0, 0, 0};
ret->type = zend_fetch_arg_info_type(script, ret_info, &ret->ce);
if (op_array->fn_flags & ZEND_ACC_RETURN_REFERENCE) {
ret->type |= MAY_BE_REF;
}
ret->is_instanceof = (ret->ce) ? 1 : 0;
ret->range = tmp_range;
ret->has_range = 0;
uint32_t zend_get_return_info_from_signature_only(
const zend_function *func, const zend_script *script,
zend_class_entry **ce, bool *ce_is_instanceof, bool use_tentative_return_info) {
uint32_t type;
if (func->common.fn_flags & ZEND_ACC_HAS_RETURN_TYPE &&
(use_tentative_return_info || !ZEND_ARG_TYPE_IS_TENTATIVE(func->common.arg_info - 1))
) {
zend_arg_info *ret_info = func->common.arg_info - 1;
type = zend_fetch_arg_info_type(script, ret_info, ce);
*ce_is_instanceof = ce != NULL;
} else {
type = MAY_BE_ANY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF
| MAY_BE_RC1 | MAY_BE_RCN;
*ce = NULL;
*ce_is_instanceof = false;
}
/* For generators RETURN_REFERENCE refers to the yielded values. */
if ((func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE)
&& !(func->common.fn_flags & ZEND_ACC_GENERATOR)) {
type |= MAY_BE_REF;
}
return type;
}
ZEND_API void zend_init_func_return_info(
const zend_op_array *op_array, const zend_script *script, zend_ssa_var_info *ret)
{
ZEND_ASSERT((op_array->fn_flags & ZEND_ACC_HAS_RETURN_TYPE));
zend_ssa_range tmp_range = {0, 0, 0, 0};
bool is_instanceof = false;
ret->type = zend_get_return_info_from_signature_only(
(zend_function *) op_array, script, &ret->ce, &is_instanceof, /* use_tentative_return_info */ 1);
ret->is_instanceof = is_instanceof;
ret->range = tmp_range;
ret->has_range = 0;
}
void zend_func_return_info(const zend_op_array *op_array,
@@ -4023,6 +4067,12 @@ void zend_func_return_info(const zend_op_array *op_array,
return;
}
if (!ret->type) {
/* We will intersect the type later. */
ret->type = MAY_BE_ANY | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_KEY_ANY
| MAY_BE_RC1 | MAY_BE_RCN | MAY_BE_REF;
}
for (j = 0; j < blocks_count; j++) {
if ((blocks[j].flags & ZEND_BB_REACHABLE) && blocks[j].len != 0) {
zend_op *opline = op_array->opcodes + blocks[j].start + blocks[j].len - 1;
@@ -4182,10 +4232,10 @@ void zend_func_return_info(const zend_op_array *op_array,
if (tmp_has_range < 0) {
tmp_has_range = 0;
}
ret->type = tmp;
ret->ce = tmp_ce;
ret->is_instanceof = tmp_is_instanceof;
}
ret->type &= tmp;
ret->range = tmp_range;
ret->has_range = tmp_has_range;
}
@@ -4223,7 +4273,7 @@ static int zend_infer_types(const zend_op_array *op_array, const zend_script *sc
return SUCCESS;
}
int zend_ssa_inference(zend_arena **arena, const zend_op_array *op_array, const zend_script *script, zend_ssa *ssa, zend_long optimization_level) /* {{{ */
ZEND_API int zend_ssa_inference(zend_arena **arena, const zend_op_array *op_array, const zend_script *script, zend_ssa *ssa, zend_long optimization_level) /* {{{ */
{
zend_ssa_var_info *ssa_var_info;
int i;
@@ -4295,7 +4345,7 @@ void zend_inference_check_recursive_dependencies(zend_op_array *op_array)
free_alloca(worklist, use_heap);
}
int zend_may_throw_ex(const zend_op *opline, const zend_ssa_op *ssa_op, const zend_op_array *op_array, zend_ssa *ssa, uint32_t t1, uint32_t t2)
ZEND_API int zend_may_throw_ex(const zend_op *opline, const zend_ssa_op *ssa_op, const zend_op_array *op_array, zend_ssa *ssa, uint32_t t1, uint32_t t2)
{
if (opline->op1_type == IS_CV) {
if (t1 & MAY_BE_UNDEF) {
@@ -4390,6 +4440,7 @@ int zend_may_throw_ex(const zend_op *opline, const zend_ssa_op *ssa_op, const ze
case ZEND_BEGIN_SILENCE:
case ZEND_END_SILENCE:
case ZEND_FREE:
case ZEND_FE_FREE:
case ZEND_SEPARATE:
case ZEND_TYPE_CHECK:
case ZEND_DEFINED:
@@ -4430,22 +4481,29 @@ int zend_may_throw_ex(const zend_op *opline, const zend_ssa_op *ssa_op, const ze
return (t1 & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)) ||
(t2 & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE));
case ZEND_DIV:
if (!OP2_HAS_RANGE() ||
(OP2_MIN_RANGE() <= 0 && OP2_MAX_RANGE() >= 0)) {
/* Division by zero */
return 1;
}
ZEND_FALLTHROUGH;
case ZEND_SUB:
case ZEND_MUL:
case ZEND_POW:
return (t1 & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)) ||
(t2 & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE));
/* Ops may throw if not an integer */
case ZEND_MOD:
if (!OP2_HAS_RANGE() ||
(OP2_MIN_RANGE() <= 0 && OP2_MAX_RANGE() >= 0)) {
/* Division by zero */
return 1;
}
/* break missing intentionally */
case ZEND_SUB:
case ZEND_MUL:
case ZEND_POW:
return (t1 & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)) ||
(t2 & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE));
ZEND_FALLTHROUGH;
case ZEND_SL:
case ZEND_SR:
return (t1 & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)) ||
(t2 & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)) ||
return (t1 & (MAY_BE_STRING|MAY_BE_DOUBLE|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)) ||
(t2 & (MAY_BE_STRING|MAY_BE_DOUBLE|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)) ||
!OP2_HAS_RANGE() ||
OP2_MIN_RANGE() < 0;
case ZEND_CONCAT:
@@ -4459,10 +4517,10 @@ int zend_may_throw_ex(const zend_op *opline, const zend_ssa_op *ssa_op, const ze
&& (t2 & MAY_BE_ANY) == MAY_BE_STRING) {
return 0;
}
return (t1 & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)) ||
(t2 & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE));
return (t1 & (MAY_BE_STRING|MAY_BE_DOUBLE|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)) ||
(t2 & (MAY_BE_STRING|MAY_BE_DOUBLE|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE));
case ZEND_BW_NOT:
return (t1 & (MAY_BE_NULL|MAY_BE_FALSE|MAY_BE_TRUE|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE));
return (t1 & (MAY_BE_NULL|MAY_BE_FALSE|MAY_BE_TRUE|MAY_BE_DOUBLE|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE));
case ZEND_PRE_INC:
case ZEND_POST_INC:
case ZEND_PRE_DEC:
@@ -4536,6 +4594,7 @@ int zend_may_throw_ex(const zend_op *opline, const zend_ssa_op *ssa_op, const ze
if (t1 & MAY_BE_REF) {
return 1;
}
ZEND_FALLTHROUGH;
case ZEND_BIND_STATIC:
case ZEND_UNSET_VAR:
return (t1 & (MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_ARRAY_OF_OBJECT|MAY_BE_ARRAY_OF_RESOURCE|MAY_BE_ARRAY_OF_ARRAY));
@@ -4632,6 +4691,9 @@ int zend_may_throw_ex(const zend_op *opline, const zend_ssa_op *ssa_op, const ze
return 0;
EMPTY_SWITCH_DEFAULT_CASE()
}
/* GCC is getting confused here for the Wimplicit-fallthrough warning with
* EMPTY_SWITCH_DEFAULT_CASE() macro */
return 0;
case ZEND_ARRAY_KEY_EXISTS:
if ((t2 & MAY_BE_ANY) != MAY_BE_ARRAY) {
return 1;
@@ -4673,7 +4735,7 @@ int zend_may_throw_ex(const zend_op *opline, const zend_ssa_op *ssa_op, const ze
}
}
int zend_may_throw(const zend_op *opline, const zend_ssa_op *ssa_op, const zend_op_array *op_array, zend_ssa *ssa)
ZEND_API int zend_may_throw(const zend_op *opline, const zend_ssa_op *ssa_op, const zend_op_array *op_array, zend_ssa *ssa)
{
return zend_may_throw_ex(opline, ssa_op, op_array, ssa, OP1_INFO(), OP2_INFO());
}
@@ -7,7 +7,7 @@
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
@@ -40,7 +40,7 @@
|MAY_BE_ARRAY_OF_ARRAY|MAY_BE_ARRAY_OF_OBJECT|MAY_BE_ARRAY_OF_RESOURCE)
#define DEFINE_SSA_OP_HAS_RANGE(opN) \
static zend_always_inline zend_bool _ssa_##opN##_has_range(const zend_op_array *op_array, const zend_ssa *ssa, const zend_op *opline, const zend_ssa_op *ssa_op) \
static zend_always_inline bool _ssa_##opN##_has_range(const zend_op_array *op_array, const zend_ssa *ssa, const zend_op *opline, const zend_ssa_op *ssa_op) \
{ \
if (opline->opN##_type == IS_CONST) { \
zval *zv = CRT_CONSTANT(opline->opN); \
@@ -239,53 +239,52 @@ DEFINE_SSA_OP_DEF_INFO(result)
#define OP2_DATA_DEF_INFO() (_ssa_op2_def_info(op_array, ssa, (opline+1), (ssa_op+1)))
#define RES_INFO() (_ssa_result_def_info(op_array, ssa, opline, ssa_op))
static zend_always_inline zend_bool zend_add_will_overflow(zend_long a, zend_long b) {
static zend_always_inline bool zend_add_will_overflow(zend_long a, zend_long b) {
return (b > 0 && a > ZEND_LONG_MAX - b)
|| (b < 0 && a < ZEND_LONG_MIN - b);
}
static zend_always_inline zend_bool zend_sub_will_overflow(zend_long a, zend_long b) {
static zend_always_inline bool zend_sub_will_overflow(zend_long a, zend_long b) {
return (b > 0 && a < ZEND_LONG_MIN + b)
|| (b < 0 && a > ZEND_LONG_MAX + b);
}
BEGIN_EXTERN_C()
int zend_ssa_find_false_dependencies(const zend_op_array *op_array, zend_ssa *ssa);
int zend_ssa_find_sccs(const zend_op_array *op_array, zend_ssa *ssa);
int zend_ssa_inference(zend_arena **raena, const zend_op_array *op_array, const zend_script *script, zend_ssa *ssa, zend_long optimization_level);
ZEND_API int zend_ssa_find_false_dependencies(const zend_op_array *op_array, zend_ssa *ssa);
ZEND_API int zend_ssa_find_sccs(const zend_op_array *op_array, zend_ssa *ssa);
ZEND_API int zend_ssa_inference(zend_arena **raena, const zend_op_array *op_array, const zend_script *script, zend_ssa *ssa, zend_long optimization_level);
uint32_t zend_array_element_type(uint32_t t1, zend_uchar op_type, int write, int insert);
ZEND_API uint32_t zend_array_element_type(uint32_t t1, zend_uchar op_type, int write, int insert);
int zend_inference_calc_range(const zend_op_array *op_array, zend_ssa *ssa, int var, int widening, int narrowing, zend_ssa_range *tmp);
int zend_inference_propagate_range(const zend_op_array *op_array, zend_ssa *ssa, zend_op *opline, zend_ssa_op* ssa_op, int var, zend_ssa_range *tmp);
void zend_inference_init_range(const zend_op_array *op_array, zend_ssa *ssa, int var, zend_bool underflow, zend_long min, zend_long max, zend_bool overflow);
ZEND_API int zend_inference_propagate_range(const zend_op_array *op_array, zend_ssa *ssa, zend_op *opline, zend_ssa_op* ssa_op, int var, zend_ssa_range *tmp);
void zend_inference_init_range(const zend_op_array *op_array, zend_ssa *ssa, int var, bool underflow, zend_long min, zend_long max, bool overflow);
int zend_inference_narrowing_meet(zend_ssa_var_info *var_info, zend_ssa_range *r);
int zend_inference_widening_meet(zend_ssa_var_info *var_info, zend_ssa_range *r);
void zend_inference_check_recursive_dependencies(zend_op_array *op_array);
int zend_infer_types_ex(const zend_op_array *op_array, const zend_script *script, zend_ssa *ssa, zend_bitset worklist, zend_long optimization_level);
uint32_t zend_fetch_arg_info_type(
ZEND_API uint32_t zend_fetch_arg_info_type(
const zend_script *script, zend_arg_info *arg_info, zend_class_entry **pce);
void zend_init_func_return_info(const zend_op_array *op_array,
const zend_script *script,
zend_ssa_var_info *ret);
ZEND_API void zend_init_func_return_info(
const zend_op_array *op_array, const zend_script *script, zend_ssa_var_info *ret);
uint32_t zend_get_return_info_from_signature_only(
const zend_function *func, const zend_script *script,
zend_class_entry **ce, bool *ce_is_instanceof, bool use_tentative_return_info);
void zend_func_return_info(const zend_op_array *op_array,
const zend_script *script,
int recursive,
int widening,
zend_ssa_var_info *ret);
int zend_may_throw_ex(const zend_op *opline, const zend_ssa_op *ssa_op, const zend_op_array *op_array, zend_ssa *ssa, uint32_t t1, uint32_t t2);
int zend_may_throw(const zend_op *opline, const zend_ssa_op *ssa_op, const zend_op_array *op_array, zend_ssa *ssa);
ZEND_API int zend_may_throw_ex(const zend_op *opline, const zend_ssa_op *ssa_op, const zend_op_array *op_array, zend_ssa *ssa, uint32_t t1, uint32_t t2);
ZEND_API int zend_may_throw(const zend_op *opline, const zend_ssa_op *ssa_op, const zend_op_array *op_array, zend_ssa *ssa);
int zend_update_type_info(const zend_op_array *op_array,
zend_ssa *ssa,
const zend_script *script,
zend_op *opline,
zend_ssa_op *ssa_op,
const zend_op **ssa_opcodes,
zend_long optimization_level);
ZEND_API int zend_update_type_info(
const zend_op_array *op_array, zend_ssa *ssa, const zend_script *script,
zend_op *opline, zend_ssa_op *ssa_op, const zend_op **ssa_opcodes,
zend_long optimization_level);
END_EXTERN_C()
@@ -7,7 +7,7 @@
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
@@ -19,7 +19,6 @@
+----------------------------------------------------------------------+
*/
#include "php.h"
#include "Optimizer/zend_optimizer.h"
#include "Optimizer/zend_optimizer_internal.h"
#include "zend_API.h"
@@ -51,19 +50,12 @@ void zend_optimizer_collect_constant(zend_optimizer_ctx *ctx, zval *name, zval*
int zend_optimizer_eval_binary_op(zval *result, zend_uchar opcode, zval *op1, zval *op2) /* {{{ */
{
binary_op_type binary_op = get_binary_op(opcode);
int er, ret;
if (zend_binary_op_produces_error(opcode, op1, op2)) {
return FAILURE;
}
er = EG(error_reporting);
EG(error_reporting) = 0;
ret = binary_op(result, op1, op2);
EG(error_reporting) = er;
return ret;
binary_op_type binary_op = get_binary_op(opcode);
return binary_op(result, op1, op2);
}
/* }}} */
@@ -72,11 +64,7 @@ int zend_optimizer_eval_unary_op(zval *result, zend_uchar opcode, zval *op1) /*
unary_op_type unary_op = get_unary_op(opcode);
if (unary_op) {
if (opcode == ZEND_BW_NOT
&& Z_TYPE_P(op1) != IS_LONG
&& Z_TYPE_P(op1) != IS_DOUBLE
&& Z_TYPE_P(op1) != IS_STRING) {
/* produces "Unsupported operand types" exception */
if (zend_unary_op_produces_error(opcode, op1)) {
return FAILURE;
}
return unary_op(result, op1);
@@ -325,7 +313,7 @@ int zend_optimizer_update_op1_const(zend_op_array *op_array,
if (opline->opcode == ZEND_CONCAT && opline->op2_type == IS_CONST) {
opline->opcode = ZEND_FAST_CONCAT;
}
/* break missing intentionally */
ZEND_FALLTHROUGH;
default:
opline->op1.constant = zend_optimizer_add_literal(op_array, val);
break;
@@ -353,7 +341,7 @@ int zend_optimizer_update_op2_const(zend_op_array *op_array,
(opline + 1)->op2.var == opline->result.var) {
return 0;
}
/* break missing intentionally */
ZEND_FALLTHROUGH;
case ZEND_INSTANCEOF:
REQUIRES_STRING(val);
drop_leading_backslash(val);
@@ -507,7 +495,7 @@ int zend_optimizer_update_op2_const(zend_op_array *op_array,
if (opline->opcode == ZEND_CONCAT && opline->op1_type == IS_CONST) {
opline->opcode = ZEND_FAST_CONCAT;
}
/* break missing intentionally */
ZEND_FALLTHROUGH;
default:
opline->op2.constant = zend_optimizer_add_literal(op_array, val);
break;
@@ -674,7 +662,7 @@ void zend_optimizer_migrate_jump(zend_op_array *op_array, zend_op *new_opline, z
break;
case ZEND_JMPZNZ:
new_opline->extended_value = ZEND_OPLINE_NUM_TO_OFFSET(op_array, new_opline, ZEND_OFFSET_TO_OPLINE_NUM(op_array, opline, opline->extended_value));
/* break missing intentionally */
ZEND_FALLTHROUGH;
case ZEND_JMPZ:
case ZEND_JMPNZ:
case ZEND_JMPZ_EX:
@@ -720,7 +708,7 @@ void zend_optimizer_shift_jump(zend_op_array *op_array, zend_op *opline, uint32_
break;
case ZEND_JMPZNZ:
opline->extended_value = ZEND_OPLINE_NUM_TO_OFFSET(op_array, opline, ZEND_OFFSET_TO_OPLINE_NUM(op_array, opline, opline->extended_value) - shiftlist[ZEND_OFFSET_TO_OPLINE_NUM(op_array, opline, opline->extended_value)]);
/* break missing intentionally */
ZEND_FALLTHROUGH;
case ZEND_JMPZ:
case ZEND_JMPNZ:
case ZEND_JMPZ_EX:
@@ -785,7 +773,7 @@ static zend_class_entry *get_class_entry_from_op1(
}
zend_function *zend_optimizer_get_called_func(
zend_script *script, zend_op_array *op_array, zend_op *opline, zend_bool *is_prototype)
zend_script *script, zend_op_array *op_array, zend_op *opline, bool *is_prototype)
{
*is_prototype = 0;
switch (opline->opcode) {
@@ -832,8 +820,8 @@ zend_function *zend_optimizer_get_called_func(
zend_string *func_name = Z_STR_P(CRT_CONSTANT(opline->op2) + 1);
zend_function *fbc = zend_hash_find_ptr(&ce->function_table, func_name);
if (fbc) {
zend_bool is_public = (fbc->common.fn_flags & ZEND_ACC_PUBLIC) != 0;
zend_bool same_scope = fbc->common.scope == op_array->scope;
bool is_public = (fbc->common.fn_flags & ZEND_ACC_PUBLIC) != 0;
bool same_scope = fbc->common.scope == op_array->scope;
if (is_public || same_scope) {
return fbc;
}
@@ -851,9 +839,9 @@ zend_function *zend_optimizer_get_called_func(
zend_function *fbc = zend_hash_find_ptr(
&op_array->scope->function_table, method_name);
if (fbc) {
zend_bool is_private = (fbc->common.fn_flags & ZEND_ACC_PRIVATE) != 0;
zend_bool is_final = (fbc->common.fn_flags & ZEND_ACC_FINAL) != 0;
zend_bool same_scope = fbc->common.scope == op_array->scope;
bool is_private = (fbc->common.fn_flags & ZEND_ACC_PRIVATE) != 0;
bool is_final = (fbc->common.fn_flags & ZEND_ACC_FINAL) != 0;
bool same_scope = fbc->common.scope == op_array->scope;
if (is_private) {
/* Only use private method if in the same scope. We can't even use it
* as a prototype, as it may be overridden with changed signature. */
@@ -1340,6 +1328,7 @@ static void zend_adjust_fcall_stack_size_graph(zend_op_array *op_array)
zend_op *opline = call_info->caller_init_opline;
if (opline && call_info->callee_func && opline->opcode == ZEND_INIT_FCALL) {
ZEND_ASSERT(!call_info->is_prototype);
opline->op1.num = zend_vm_calc_used_stack(opline->extended_value, call_info->callee_func);
}
call_info = call_info->next_callee;
@@ -1347,7 +1336,7 @@ static void zend_adjust_fcall_stack_size_graph(zend_op_array *op_array)
}
}
static zend_bool needs_live_range(zend_op_array *op_array, zend_op *def_opline) {
static bool needs_live_range(zend_op_array *op_array, zend_op *def_opline) {
zend_func_info *func_info = ZEND_FUNC_INFO(op_array);
zend_ssa_op *ssa_op = &func_info->ssa.ops[def_opline - op_array->opcodes];
int ssa_var = ssa_op->result_def;
@@ -1367,16 +1356,24 @@ static zend_bool needs_live_range(zend_op_array *op_array, zend_op *def_opline)
return (type & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_REF)) != 0;
}
static void zend_foreach_op_array_helper(
zend_op_array *op_array, zend_op_array_func_t func, void *context) {
func(op_array, context);
for (uint32_t i = 0; i < op_array->num_dynamic_func_defs; i++) {
func(op_array->dynamic_func_defs[i], context);
}
}
void zend_foreach_op_array(zend_script *script, zend_op_array_func_t func, void *context)
{
zend_class_entry *ce;
zend_string *key;
zend_op_array *op_array;
func(&script->main_op_array, context);
zend_foreach_op_array_helper(&script->main_op_array, func, context);
ZEND_HASH_FOREACH_PTR(&script->function_table, op_array) {
func(op_array, context);
zend_foreach_op_array_helper(op_array, func, context);
} ZEND_HASH_FOREACH_END();
ZEND_HASH_FOREACH_STR_KEY_PTR(&script->class_table, key, ce) {
@@ -1387,7 +1384,7 @@ void zend_foreach_op_array(zend_script *script, zend_op_array_func_t func, void
if (op_array->scope == ce
&& op_array->type == ZEND_USER_FUNCTION
&& !(op_array->fn_flags & ZEND_ACC_TRAIT_CLONE)) {
func(op_array, context);
zend_foreach_op_array_helper(op_array, func, context);
}
} ZEND_HASH_FOREACH_END();
} ZEND_HASH_FOREACH_END();
@@ -1405,7 +1402,7 @@ static void step_dump_after_optimizer(zend_op_array *op_array, void *context) {
zend_dump_op_array(op_array, ZEND_DUMP_LIVE_RANGES, "after optimizer", NULL);
}
int zend_optimize_script(zend_script *script, zend_long optimization_level, zend_long debug_level)
ZEND_API int zend_optimize_script(zend_script *script, zend_long optimization_level, zend_long debug_level)
{
zend_class_entry *ce;
zend_string *key;
@@ -7,7 +7,7 @@
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
@@ -89,8 +89,10 @@ typedef struct _zend_script {
uint32_t first_early_binding_opline; /* the linked list of delayed declarations */
} zend_script;
int zend_optimize_script(zend_script *script, zend_long optimization_level, zend_long debug_level);
BEGIN_EXTERN_C()
ZEND_API int zend_optimize_script(zend_script *script, zend_long optimization_level, zend_long debug_level);
int zend_optimizer_startup(void);
int zend_optimizer_shutdown(void);
END_EXTERN_C()
#endif
@@ -7,7 +7,7 @@
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
@@ -71,7 +71,7 @@ typedef struct _zend_optimizer_ctx {
target = src; \
} while (0)
static inline zend_bool zend_optimizer_is_loop_var_free(const zend_op *opline) {
static inline bool zend_optimizer_is_loop_var_free(const zend_op *opline) {
return (opline->opcode == ZEND_FE_FREE && opline->extended_value != ZEND_FREE_ON_RETURN)
|| (opline->opcode == ZEND_FREE && opline->extended_value == ZEND_FREE_SWITCH);
}
@@ -109,12 +109,12 @@ void zend_optimizer_nop_removal(zend_op_array *op_array, zend_optimizer_ctx *ctx
void zend_optimizer_compact_literals(zend_op_array *op_array, zend_optimizer_ctx *ctx);
void zend_optimizer_compact_vars(zend_op_array *op_array);
zend_function *zend_optimizer_get_called_func(
zend_script *script, zend_op_array *op_array, zend_op *opline, zend_bool *is_prototype);
zend_script *script, zend_op_array *op_array, zend_op *opline, bool *is_prototype);
uint32_t zend_optimizer_classify_function(zend_string *name, uint32_t num_args);
void zend_optimizer_migrate_jump(zend_op_array *op_array, zend_op *new_opline, zend_op *opline);
void zend_optimizer_shift_jump(zend_op_array *op_array, zend_op *opline, uint32_t *shiftlist);
int sccp_optimize_op_array(zend_optimizer_ctx *ctx, zend_op_array *op_arrya, zend_ssa *ssa, zend_call_info **call_map);
int dce_optimize_op_array(zend_op_array *op_array, zend_ssa *ssa, zend_bool reorder_dtor_effects);
int sccp_optimize_op_array(zend_optimizer_ctx *ctx, zend_op_array *op_array, zend_ssa *ssa, zend_call_info **call_map);
int dce_optimize_op_array(zend_op_array *op_array, zend_ssa *ssa, bool reorder_dtor_effects);
int zend_ssa_escape_analysis(const zend_script *script, zend_op_array *op_array, zend_ssa *ssa);
typedef void (*zend_op_array_func_t)(zend_op_array *, void *context);
@@ -7,7 +7,7 @@
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
@@ -17,7 +17,6 @@
+----------------------------------------------------------------------+
*/
#include "php.h"
#include "zend_compile.h"
#include "zend_dfg.h"
#include "zend_ssa.h"
@@ -25,14 +24,14 @@
#include "zend_inference.h"
#include "Optimizer/zend_optimizer_internal.h"
static zend_bool dominates(const zend_basic_block *blocks, int a, int b) {
static bool dominates(const zend_basic_block *blocks, int a, int b) {
while (blocks[b].level > blocks[a].level) {
b = blocks[b].idom;
}
return a == b;
}
static zend_bool will_rejoin(
static bool will_rejoin(
const zend_cfg *cfg, const zend_dfg *dfg, const zend_basic_block *block,
int other_successor, int exclude, int var) {
int i;
@@ -58,7 +57,7 @@ static zend_bool will_rejoin(
return 0;
}
static zend_bool needs_pi(const zend_op_array *op_array, zend_dfg *dfg, zend_ssa *ssa, int from, int to, int var) /* {{{ */
static bool needs_pi(const zend_op_array *op_array, zend_dfg *dfg, zend_ssa *ssa, int from, int to, int var) /* {{{ */
{
zend_basic_block *from_block, *to_block;
int other_successor;
@@ -285,6 +284,14 @@ static void place_essa_pis(
default:
continue;
}
/* The following patterns all inspect the opline directly before the JMPZ opcode.
* Make sure that it is part of the same block, otherwise it might not be a dominating
* assignment. */
if (blocks[j].len == 1) {
continue;
}
if (opline->op1_type == IS_TMP_VAR &&
((opline-1)->opcode == ZEND_IS_EQUAL ||
(opline-1)->opcode == ZEND_IS_NOT_EQUAL ||
@@ -713,7 +720,7 @@ add_op1_def:
break;
case ZEND_ADD_ARRAY_ELEMENT:
ssa_ops[k].result_use = var[EX_VAR_TO_NUM(opline->result.var)];
/* break missing intentionally */
ZEND_FALLTHROUGH;
case ZEND_INIT_ARRAY:
if (((build_flags & ZEND_SSA_RC_INFERENCE)
|| (opline->extended_value & ZEND_ARRAY_ELEMENT_REF))
@@ -768,7 +775,7 @@ add_op1_def:
}
/* }}} */
int zend_ssa_rename_op(const zend_op_array *op_array, const zend_op *opline, uint32_t k, uint32_t build_flags, int ssa_vars_count, zend_ssa_op *ssa_ops, int *var) /* {{{ */
ZEND_API int zend_ssa_rename_op(const zend_op_array *op_array, const zend_op *opline, uint32_t k, uint32_t build_flags, int ssa_vars_count, zend_ssa_op *ssa_ops, int *var) /* {{{ */
{
return _zend_ssa_rename_op(op_array, opline, k, build_flags, ssa_vars_count, ssa_ops, var);
}
@@ -891,7 +898,7 @@ static int zend_ssa_rename(const zend_op_array *op_array, uint32_t build_flags,
}
/* }}} */
int zend_build_ssa(zend_arena **arena, const zend_script *script, const zend_op_array *op_array, uint32_t build_flags, zend_ssa *ssa) /* {{{ */
ZEND_API int zend_build_ssa(zend_arena **arena, const zend_script *script, const zend_op_array *op_array, uint32_t build_flags, zend_ssa *ssa) /* {{{ */
{
zend_basic_block *blocks = ssa->cfg.blocks;
zend_ssa_block *ssa_blocks;
@@ -1042,7 +1049,7 @@ int zend_build_ssa(zend_arena **arena, const zend_script *script, const zend_op_
}
/* }}} */
int zend_ssa_compute_use_def_chains(zend_arena **arena, const zend_op_array *op_array, zend_ssa *ssa) /* {{{ */
ZEND_API int zend_ssa_compute_use_def_chains(zend_arena **arena, const zend_op_array *op_array, zend_ssa *ssa) /* {{{ */
{
zend_ssa_var *ssa_vars;
int i;
@@ -1508,7 +1515,7 @@ static void propagate_phi_type_widening(zend_ssa *ssa, int var) /* {{{ */
}
/* }}} */
void zend_ssa_rename_var_uses(zend_ssa *ssa, int old, int new, zend_bool update_types) /* {{{ */
void zend_ssa_rename_var_uses(zend_ssa *ssa, int old, int new, bool update_types) /* {{{ */
{
zend_ssa_var *old_var = &ssa->vars[old];
zend_ssa_var *new_var = &ssa->vars[new];
@@ -1527,7 +1534,7 @@ void zend_ssa_rename_var_uses(zend_ssa *ssa, int old, int new, zend_bool update_
/* If the op already uses the new var, don't add the op to the use
* list again. Instead move the use_chain to the correct operand. */
zend_bool add_to_use_chain = 1;
bool add_to_use_chain = 1;
if (ssa_op->result_use == new) {
add_to_use_chain = 0;
} else if (ssa_op->op1_use == new) {
@@ -1579,7 +1586,7 @@ void zend_ssa_rename_var_uses(zend_ssa *ssa, int old, int new, zend_bool update_
/* Update phi use chains */
FOREACH_PHI_USE(old_var, phi) {
int j;
zend_bool after_first_new_source = 0;
bool after_first_new_source = 0;
/* If the phi already uses the new var, find its use chain, as we may
* need to move it to a different source operand. */
@@ -7,7 +7,7 @@
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
@@ -25,8 +25,8 @@
typedef struct _zend_ssa_range {
zend_long min;
zend_long max;
zend_bool underflow;
zend_bool overflow;
bool underflow;
bool overflow;
} zend_ssa_range;
typedef enum _zend_ssa_negative_lat {
@@ -145,9 +145,9 @@ typedef struct _zend_ssa {
BEGIN_EXTERN_C()
int zend_build_ssa(zend_arena **arena, const zend_script *script, const zend_op_array *op_array, uint32_t build_flags, zend_ssa *ssa);
int zend_ssa_rename_op(const zend_op_array *op_array, const zend_op *opline, uint32_t k, uint32_t build_flags, int ssa_vars_count, zend_ssa_op *ssa_ops, int *var);
int zend_ssa_compute_use_def_chains(zend_arena **arena, const zend_op_array *op_array, zend_ssa *ssa);
ZEND_API int zend_build_ssa(zend_arena **arena, const zend_script *script, const zend_op_array *op_array, uint32_t build_flags, zend_ssa *ssa);
ZEND_API int zend_ssa_compute_use_def_chains(zend_arena **arena, const zend_op_array *op_array, zend_ssa *ssa);
ZEND_API int zend_ssa_rename_op(const zend_op_array *op_array, const zend_op *opline, uint32_t k, uint32_t build_flags, int ssa_vars_count, zend_ssa_op *ssa_ops, int *var);
int zend_ssa_unlink_use_chain(zend_ssa *ssa, int op, int var);
void zend_ssa_remove_predecessor(zend_ssa *ssa, int from, int to);
@@ -155,7 +155,7 @@ void zend_ssa_remove_instr(zend_ssa *ssa, zend_op *opline, zend_ssa_op *ssa_op);
void zend_ssa_remove_phi(zend_ssa *ssa, zend_ssa_phi *phi);
void zend_ssa_remove_uses_of_var(zend_ssa *ssa, int var_num);
void zend_ssa_remove_block(zend_op_array *op_array, zend_ssa *ssa, int b);
void zend_ssa_rename_var_uses(zend_ssa *ssa, int old_var, int new_var, zend_bool update_types);
void zend_ssa_rename_var_uses(zend_ssa *ssa, int old_var, int new_var, bool update_types);
static zend_always_inline void _zend_ssa_remove_def(zend_ssa_var *var)
{
@@ -215,7 +215,7 @@ static zend_always_inline zend_ssa_phi* zend_ssa_next_use_phi(const zend_ssa *ss
return NULL;
}
static zend_always_inline zend_bool zend_ssa_is_no_val_use(const zend_op *opline, const zend_ssa_op *ssa_op, int var)
static zend_always_inline bool zend_ssa_is_no_val_use(const zend_op *opline, const zend_ssa_op *ssa_op, int var)
{
if (opline->opcode == ZEND_ASSIGN
|| opline->opcode == ZEND_UNSET_CV
@@ -7,7 +7,7 @@
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+10 -2
View File
@@ -206,9 +206,16 @@ else
AC_DEFINE(ZEND_DEBUG,0,[ ])
fi
test -n "$GCC" && CFLAGS="-Wall -Wextra -Wno-strict-aliasing -Wno-implicit-fallthrough -Wno-unused-parameter -Wno-sign-compare $CFLAGS"
test -n "$GCC" && CFLAGS="-Wall -Wextra -Wno-strict-aliasing -Wno-unused-parameter -Wno-sign-compare $CFLAGS"
dnl Check if compiler supports -Wno-clobbered (only GCC)
AX_CHECK_COMPILE_FLAG([-Wno-clobbered], CFLAGS="-Wno-clobbered $CFLAGS", , [-Werror])
dnl Check for support for implicit fallthrough level 1, also add after previous CFLAGS as level 3 is enabled in -Wextra
AX_CHECK_COMPILE_FLAG([-Wimplicit-fallthrough=1], CFLAGS="$CFLAGS -Wimplicit-fallthrough=1", , [-Werror])
AX_CHECK_COMPILE_FLAG([-Wduplicated-cond], CFLAGS="-Wduplicated-cond $CFLAGS", , [-Werror])
AX_CHECK_COMPILE_FLAG([-Wlogical-op], CFLAGS="-Wlogical-op $CFLAGS", , [-Werror])
AX_CHECK_COMPILE_FLAG([-Wformat-truncation], CFLAGS="-Wformat-truncation $CFLAGS", , [-Werror])
AX_CHECK_COMPILE_FLAG([-Wstrict-prototypes], CFLAGS="-Wstrict-prototypes $CFLAGS", , [-Werror])
AX_CHECK_COMPILE_FLAG([-fno-common], CFLAGS="-fno-common $CFLAGS", , [-Werror])
test -n "$DEBUG_CFLAGS" && CFLAGS="$CFLAGS $DEBUG_CFLAGS"
@@ -271,7 +278,8 @@ int main()
AC_DEFINE_UNQUOTED(ZEND_MM_ALIGNMENT_LOG2, $LIBZEND_MM_ALIGN_LOG2, [ ])
], [], [
dnl Cross compilation needs something here.
LIBZEND_MM_ALIGN=8
AC_DEFINE_UNQUOTED(ZEND_MM_ALIGNMENT, 8, [ ])
AC_DEFINE_UNQUOTED(ZEND_MM_ALIGNMENT_LOG2, 3, [ ])
])
AC_MSG_RESULT(done)
+23
View File
@@ -0,0 +1,23 @@
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
+114
View File
@@ -0,0 +1,114 @@
/*
Copyright Edward Nevill + Oliver Kowalke 2015
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
*/
/*******************************************************
* *
* ------------------------------------------------- *
* | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | *
* ------------------------------------------------- *
* | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c| *
* ------------------------------------------------- *
* | d8 | d9 | d10 | d11 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | *
* ------------------------------------------------- *
* | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c| *
* ------------------------------------------------- *
* | d12 | d13 | d14 | d15 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | *
* ------------------------------------------------- *
* | 0x40| 0x44| 0x48| 0x4c| 0x50| 0x54| 0x58| 0x5c| *
* ------------------------------------------------- *
* | x19 | x20 | x21 | x22 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | *
* ------------------------------------------------- *
* | 0x60| 0x64| 0x68| 0x6c| 0x70| 0x74| 0x78| 0x7c| *
* ------------------------------------------------- *
* | x23 | x24 | x25 | x26 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | *
* ------------------------------------------------- *
* | 0x80| 0x84| 0x88| 0x8c| 0x90| 0x94| 0x98| 0x9c| *
* ------------------------------------------------- *
* | x27 | x28 | FP | LR | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 40 | 41 | 42 | 43 | | | *
* ------------------------------------------------- *
* | 0xa0| 0xa4| 0xa8| 0xac| | | *
* ------------------------------------------------- *
* | PC | align | | | *
* ------------------------------------------------- *
* *
*******************************************************/
.file "jump_arm64_aapcs_elf_gas.S"
.text
.align 2
.global jump_fcontext
.type jump_fcontext, %function
jump_fcontext:
# prepare stack for GP + FPU
sub sp, sp, #0xb0
# save d8 - d15
stp d8, d9, [sp, #0x00]
stp d10, d11, [sp, #0x10]
stp d12, d13, [sp, #0x20]
stp d14, d15, [sp, #0x30]
# save x19-x30
stp x19, x20, [sp, #0x40]
stp x21, x22, [sp, #0x50]
stp x23, x24, [sp, #0x60]
stp x25, x26, [sp, #0x70]
stp x27, x28, [sp, #0x80]
stp x29, x30, [sp, #0x90]
# save LR as PC
str x30, [sp, #0xa0]
# store RSP (pointing to context-data) in X0
mov x4, sp
# restore RSP (pointing to context-data) from X1
mov sp, x0
# load d8 - d15
ldp d8, d9, [sp, #0x00]
ldp d10, d11, [sp, #0x10]
ldp d12, d13, [sp, #0x20]
ldp d14, d15, [sp, #0x30]
# load x19-x30
ldp x19, x20, [sp, #0x40]
ldp x21, x22, [sp, #0x50]
ldp x23, x24, [sp, #0x60]
ldp x25, x26, [sp, #0x70]
ldp x27, x28, [sp, #0x80]
ldp x29, x30, [sp, #0x90]
# return transfer_t from jump
# pass transfer_t as first arg in context function
# X0 == FCTX, X1 == DATA
mov x0, x4
# load pc
ldr x4, [sp, #0xa0]
# restore stack from GP + FPU
add sp, sp, #0xb0
ret x4
.size jump_fcontext,.-jump_fcontext
# Mark that we don't need executable stack.
.section .note.GNU-stack,"",%progbits
+109
View File
@@ -0,0 +1,109 @@
/*
Copyright Edward Nevill + Oliver Kowalke 2015
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
*/
/*******************************************************
* *
* ------------------------------------------------- *
* | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | *
* ------------------------------------------------- *
* | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c| *
* ------------------------------------------------- *
* | d8 | d9 | d10 | d11 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | *
* ------------------------------------------------- *
* | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c| *
* ------------------------------------------------- *
* | d12 | d13 | d14 | d15 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | *
* ------------------------------------------------- *
* | 0x40| 0x44| 0x48| 0x4c| 0x50| 0x54| 0x58| 0x5c| *
* ------------------------------------------------- *
* | x19 | x20 | x21 | x22 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | *
* ------------------------------------------------- *
* | 0x60| 0x64| 0x68| 0x6c| 0x70| 0x74| 0x78| 0x7c| *
* ------------------------------------------------- *
* | x23 | x24 | x25 | x26 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | *
* ------------------------------------------------- *
* | 0x80| 0x84| 0x88| 0x8c| 0x90| 0x94| 0x98| 0x9c| *
* ------------------------------------------------- *
* | x27 | x28 | FP | LR | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 40 | 41 | 42 | 43 | | | *
* ------------------------------------------------- *
* | 0xa0| 0xa4| 0xa8| 0xac| | | *
* ------------------------------------------------- *
* | PC | align | | | *
* ------------------------------------------------- *
* *
*******************************************************/
.text
.globl _jump_fcontext
.balign 16
_jump_fcontext:
; prepare stack for GP + FPU
sub sp, sp, #0xb0
; save d8 - d15
stp d8, d9, [sp, #0x00]
stp d10, d11, [sp, #0x10]
stp d12, d13, [sp, #0x20]
stp d14, d15, [sp, #0x30]
; save x19-x30
stp x19, x20, [sp, #0x40]
stp x21, x22, [sp, #0x50]
stp x23, x24, [sp, #0x60]
stp x25, x26, [sp, #0x70]
stp x27, x28, [sp, #0x80]
stp fp, lr, [sp, #0x90]
; save LR as PC
str lr, [sp, #0xa0]
; store RSP (pointing to context-data) in X0
mov x4, sp
; restore RSP (pointing to context-data) from X1
mov sp, x0
; load d8 - d15
ldp d8, d9, [sp, #0x00]
ldp d10, d11, [sp, #0x10]
ldp d12, d13, [sp, #0x20]
ldp d14, d15, [sp, #0x30]
; load x19-x30
ldp x19, x20, [sp, #0x40]
ldp x21, x22, [sp, #0x50]
ldp x23, x24, [sp, #0x60]
ldp x25, x26, [sp, #0x70]
ldp x27, x28, [sp, #0x80]
ldp fp, lr, [sp, #0x90]
; return transfer_t from jump
; pass transfer_t as first arg in context function
; X0 == FCTX, X1 == DATA
mov x0, x4
; load pc
ldr x4, [sp, #0xa0]
; restore stack from GP + FPU
add sp, sp, #0xb0
ret x4
+88
View File
@@ -0,0 +1,88 @@
/*
Copyright Oliver Kowalke 2009.
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
*/
/*******************************************************
* *
* ------------------------------------------------- *
* | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | *
* ------------------------------------------------- *
* | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c| *
* ------------------------------------------------- *
* | s16 | s17 | s18 | s19 | s20 | s21 | s22 | s23 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | *
* ------------------------------------------------- *
* | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c| *
* ------------------------------------------------- *
* | s24 | s25 | s26 | s27 | s28 | s29 | s30 | s31 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | *
* ------------------------------------------------- *
* | 0x40| 0x44| 0x48| 0x4c| 0x50| 0x54| 0x58| 0x5c| *
* ------------------------------------------------- *
* |hiddn| v1 | v2 | v3 | v4 | v5 | v6 | v7 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | *
* ------------------------------------------------- *
* | 0x60| 0x64| 0x68| 0x6c| 0x70| 0x74| 0x78| 0x7c| *
* ------------------------------------------------- *
* | v8 | lr | pc | FCTX| DATA| | *
* ------------------------------------------------- *
* *
*******************************************************/
.file "jump_arm_aapcs_elf_gas.S"
.text
.globl jump_fcontext
.align 2
.type jump_fcontext,%function
.syntax unified
jump_fcontext:
@ save LR as PC
push {lr}
@ save hidden,V1-V8,LR
push {a1,v1-v8,lr}
@ prepare stack for FPU
sub sp, sp, #64
#if (defined(__VFP_FP__) && !defined(__SOFTFP__))
@ save S16-S31
vstmia sp, {d8-d15}
#endif
@ store RSP (pointing to context-data) in A1
mov a1, sp
@ restore RSP (pointing to context-data) from A2
mov sp, a2
#if (defined(__VFP_FP__) && !defined(__SOFTFP__))
@ restore S16-S31
vldmia sp, {d8-d15}
#endif
@ prepare stack for FPU
add sp, sp, #64
@ restore hidden,V1-V8,LR
pop {a4,v1-v8,lr}
@ return transfer_t from jump
str a1, [a4, #0]
str a3, [a4, #4]
@ pass transfer_t as first arg in context function
@ A1 == FCTX, A2 == DATA
mov a2, a3
@ restore PC
pop {pc}
.size jump_fcontext,.-jump_fcontext
@ Mark that we don't need executable stack.
.section .note.GNU-stack,"",%progbits
+95
View File
@@ -0,0 +1,95 @@
/*
Copyright Oliver Kowalke 2009.
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
*/
/*******************************************************
* *
* ------------------------------------------------- *
* | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | *
* ------------------------------------------------- *
* | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c| *
* ------------------------------------------------- *
* | s16 | s17 | s18 | s19 | s20 | s21 | s22 | s23 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | *
* ------------------------------------------------- *
* | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c| *
* ------------------------------------------------- *
* | s24 | s25 | s26 | s27 | s28 | s29 | s30 | s31 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | *
* ------------------------------------------------- *
* | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c| *
* ------------------------------------------------- *
* | sjlj|hiddn| v1 | v2 | v3 | v4 | v5 | v6 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | *
* ------------------------------------------------- *
* | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c| *
* ------------------------------------------------- *
* | v7 | v8 | lr | pc | FCTX| DATA| | *
* ------------------------------------------------- *
* *
*******************************************************/
.text
.globl _jump_fcontext
.align 2
_jump_fcontext:
@ save LR as PC
push {lr}
@ save hidden,V1-V8,LR
push {a1,v1-v8,lr}
@ locate TLS to save/restore SjLj handler
mrc p15, 0, v2, c13, c0, #3
bic v2, v2, #3
@ load TLS[__PTK_LIBC_DYLD_Unwind_SjLj_Key]
ldr v1, [v2, #8]
@ save SjLj handler
push {v1}
@ prepare stack for FPU
sub sp, sp, #64
#if (defined(__VFP_FP__) && !defined(__SOFTFP__))
@ save S16-S31
vstmia sp, {d8-d15}
#endif
@ store RSP (pointing to context-data) in A1
mov a1, sp
@ restore RSP (pointing to context-data) from A2
mov sp, a2
#if (defined(__VFP_FP__) && !defined(__SOFTFP__))
@ restore S16-S31
vldmia sp, {d8-d15}
#endif
@ prepare stack for FPU
add sp, sp, #64
@ r#estore SjLj handler
pop {v1}
@ store SjLj handler in TLS
str v1, [v2, #8]
@ restore hidden,V1-V8,LR
pop {a4,v1-v8,lr}
@ return transfer_t from jump
str a1, [a4, #0]
str a3, [a4, #4]
@ pass transfer_t as first arg in context function
@ A1 == FCTX, A2 == DATA
mov a2, a3
@ restore PC
pop {pc}
+24
View File
@@ -0,0 +1,24 @@
/*
Copyright Sergue E. Leontiev 2013.
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
*/
// Stub file for universal binary
#if defined(__i386__)
#include "jump_i386_sysv_macho_gas.S"
#elif defined(__x86_64__)
#include "jump_x86_64_sysv_macho_gas.S"
#elif defined(__ppc__)
#include "jump_ppc32_sysv_macho_gas.S"
#elif defined(__ppc64__)
#include "jump_ppc64_sysv_macho_gas.S"
#elif defined(__arm__)
#include "jump_arm_aapcs_macho_gas.S"
#elif defined(__arm64__)
#include "jump_arm64_aapcs_macho_gas.S"
#else
#error "No arch's"
#endif
+116
View File
@@ -0,0 +1,116 @@
; Copyright Oliver Kowalke 2009.
; Distributed under the Boost Software License, Version 1.0.
; (See accompanying file LICENSE_1_0.txt or copy at
; http://www.boost.org/LICENSE_1_0.txt)
; ---------------------------------------------------------------------------------
; | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
; ---------------------------------------------------------------------------------
; | 0h | 04h | 08h | 0ch | 010h | 014h | 018h | 01ch |
; ---------------------------------------------------------------------------------
; | fc_mxcsr|fc_x87_cw| fc_strg |fc_deallo| limit | base | fc_seh | EDI |
; ---------------------------------------------------------------------------------
; ---------------------------------------------------------------------------------
; | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
; ---------------------------------------------------------------------------------
; | 020h | 024h | 028h | 02ch | 030h | 034h | 038h | 03ch |
; ---------------------------------------------------------------------------------
; | ESI | EBX | EBP | EIP | to | data | EH NXT |SEH HNDLR|
; ---------------------------------------------------------------------------------
.386
.XMM
.model flat, c
.code
jump_fcontext PROC BOOST_CONTEXT_EXPORT
; prepare stack
lea esp, [esp-02ch]
IFNDEF BOOST_USE_TSX
; save MMX control- and status-word
stmxcsr [esp]
; save x87 control-word
fnstcw [esp+04h]
ENDIF
assume fs:nothing
; load NT_TIB into ECX
mov edx, fs:[018h]
assume fs:error
; load fiber local storage
mov eax, [edx+010h]
mov [esp+08h], eax
; load current deallocation stack
mov eax, [edx+0e0ch]
mov [esp+0ch], eax
; load current stack limit
mov eax, [edx+08h]
mov [esp+010h], eax
; load current stack base
mov eax, [edx+04h]
mov [esp+014h], eax
; load current SEH exception list
mov eax, [edx]
mov [esp+018h], eax
mov [esp+01ch], edi ; save EDI
mov [esp+020h], esi ; save ESI
mov [esp+024h], ebx ; save EBX
mov [esp+028h], ebp ; save EBP
; store ESP (pointing to context-data) in EAX
mov eax, esp
; firstarg of jump_fcontext() == fcontext to jump to
mov ecx, [esp+030h]
; restore ESP (pointing to context-data) from ECX
mov esp, ecx
IFNDEF BOOST_USE_TSX
; restore MMX control- and status-word
ldmxcsr [esp]
; restore x87 control-word
fldcw [esp+04h]
ENDIF
assume fs:nothing
; load NT_TIB into EDX
mov edx, fs:[018h]
assume fs:error
; restore fiber local storage
mov ecx, [esp+08h]
mov [edx+010h], ecx
; restore current deallocation stack
mov ecx, [esp+0ch]
mov [edx+0e0ch], ecx
; restore current stack limit
mov ecx, [esp+010h]
mov [edx+08h], ecx
; restore current stack base
mov ecx, [esp+014h]
mov [edx+04h], ecx
; restore current SEH exception list
mov ecx, [esp+018h]
mov [edx], ecx
mov ecx, [esp+02ch] ; restore EIP
mov edi, [esp+01ch] ; restore EDI
mov esi, [esp+020h] ; restore ESI
mov ebx, [esp+024h] ; restore EBX
mov ebp, [esp+028h] ; restore EBP
; prepare stack
lea esp, [esp+030h]
; return transfer_t
; FCTX == EAX, DATA == EDX
mov edx, [eax+034h]
; jump to context
jmp ecx
jump_fcontext ENDP
END
+83
View File
@@ -0,0 +1,83 @@
/*
Copyright Oliver Kowalke 2009.
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
*/
/****************************************************************************************
* *
* ---------------------------------------------------------------------------------- *
* | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | *
* ---------------------------------------------------------------------------------- *
* | 0x0 | 0x4 | 0x8 | 0xc | 0x10 | 0x14 | 0x18 | 0x1c | *
* ---------------------------------------------------------------------------------- *
* | fc_mxcsr|fc_x87_cw| EDI | ESI | EBX | EBP | EIP | hidden | *
* ---------------------------------------------------------------------------------- *
* ---------------------------------------------------------------------------------- *
* | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | *
* ---------------------------------------------------------------------------------- *
* | 0x20 | 0x24 | | *
* ---------------------------------------------------------------------------------- *
* | to | data | | *
* ---------------------------------------------------------------------------------- *
* *
****************************************************************************************/
.file "jump_i386_sysv_elf_gas.S"
.text
.globl jump_fcontext
.align 2
.type jump_fcontext,@function
jump_fcontext:
leal -0x18(%esp), %esp /* prepare stack */
#if !defined(BOOST_USE_TSX)
stmxcsr (%esp) /* save MMX control- and status-word */
fnstcw 0x4(%esp) /* save x87 control-word */
#endif
movl %edi, 0x8(%esp) /* save EDI */
movl %esi, 0xc(%esp) /* save ESI */
movl %ebx, 0x10(%esp) /* save EBX */
movl %ebp, 0x14(%esp) /* save EBP */
/* store ESP (pointing to context-data) in ECX */
movl %esp, %ecx
/* first arg of jump_fcontext() == fcontext to jump to */
movl 0x20(%esp), %eax
/* second arg of jump_fcontext() == data to be transferred */
movl 0x24(%esp), %edx
/* restore ESP (pointing to context-data) from EAX */
movl %eax, %esp
/* address of returned transport_t */
movl 0x1c(%esp), %eax
/* return parent fcontext_t */
movl %ecx, (%eax)
/* return data */
movl %edx, 0x4(%eax)
movl 0x18(%esp), %ecx /* restore EIP */
#if !defined(BOOST_USE_TSX)
ldmxcsr (%esp) /* restore MMX control- and status-word */
fldcw 0x4(%esp) /* restore x87 control-word */
#endif
movl 0x8(%esp), %edi /* restore EDI */
movl 0xc(%esp), %esi /* restore ESI */
movl 0x10(%esp), %ebx /* restore EBX */
movl 0x14(%esp), %ebp /* restore EBP */
leal 0x20(%esp), %esp /* prepare stack */
/* jump to context */
jmp *%ecx
.size jump_fcontext,.-jump_fcontext
/* Mark that we don't need executable stack. */
.section .note.GNU-stack,"",%progbits
+74
View File
@@ -0,0 +1,74 @@
/*
Copyright Oliver Kowalke 2009.
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
*/
/****************************************************************************************
* *
* ---------------------------------------------------------------------------------- *
* | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | *
* ---------------------------------------------------------------------------------- *
* | 0x0 | 0x4 | 0x8 | 0xc | 0x10 | 0x14 | 0x18 | 0x1c | *
* ---------------------------------------------------------------------------------- *
* | fc_mxcsr|fc_x87_cw| EDI | ESI | EBX | EBP | EIP | to | *
* ---------------------------------------------------------------------------------- *
* ---------------------------------------------------------------------------------- *
* | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | *
* ---------------------------------------------------------------------------------- *
* | 0x20 | | *
* ---------------------------------------------------------------------------------- *
* | data | | *
* ---------------------------------------------------------------------------------- *
* *
****************************************************************************************/
.text
.globl _jump_fcontext
.align 2
_jump_fcontext:
leal -0x18(%esp), %esp /* prepare stack */
#if !defined(BOOST_USE_TSX)
stmxcsr (%esp) /* save MMX control- and status-word */
fnstcw 0x4(%esp) /* save x87 control-word */
#endif
movl %edi, 0x8(%esp) /* save EDI */
movl %esi, 0xc(%esp) /* save ESI */
movl %ebx, 0x10(%esp) /* save EBX */
movl %ebp, 0x14(%esp) /* save EBP */
/* store ESP (pointing to context-data) in ECX */
movl %esp, %ecx
/* first arg of jump_fcontext() == fcontext to jump to */
movl 0x1c(%esp), %eax
/* second arg of jump_fcontext() == data to be transferred */
movl 0x20(%esp), %edx
/* restore ESP (pointing to context-data) from EAX */
movl %eax, %esp
/* return parent fcontext_t */
movl %ecx, %eax
/* returned data is stored in EDX */
movl 0x18(%esp), %ecx /* restore EIP */
#if !defined(BOOST_USE_TSX)
ldmxcsr (%esp) /* restore MMX control- and status-word */
fldcw 0x4(%esp) /* restore x87 control-word */
#endif
movl 0x8(%esp), %edi /* restore EDI */
movl 0xc(%esp), %esi /* restore ESI */
movl 0x10(%esp), %ebx /* restore EBX */
movl 0x14(%esp), %ebp /* restore EBP */
leal 0x1c(%esp), %esp /* prepare stack */
/* jump to context */
jmp *%ecx
+119
View File
@@ -0,0 +1,119 @@
/*
Copyright Oliver Kowalke 2009.
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
*/
/*******************************************************
* *
* ------------------------------------------------- *
* | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | *
* ------------------------------------------------- *
* | 0 | 4 | 8 | 12 | 16 | 20 | 24 | 28 | *
* ------------------------------------------------- *
* | F20 | F22 | F24 | F26 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | *
* ------------------------------------------------- *
* | 32 | 36 | 40 | 44 | 48 | 52 | 56 | 60 | *
* ------------------------------------------------- *
* | F28 | F30 | S0 | S1 | S2 | S3 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | *
* ------------------------------------------------- *
* | 64 | 68 | 72 | 76 | 80 | 84 | 88 | 92 | *
* ------------------------------------------------- *
* | S4 | S5 | S6 | S7 | FP |hiddn| RA | PC | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | *
* ------------------------------------------------- *
* | 96 | 100 | 104 | 108 | 112 | 116 | 120 | 124 | *
* ------------------------------------------------- *
* | ABI ARGS | GP | FCTX| DATA| | *
* ------------------------------------------------- *
* *
* *****************************************************/
.file "jump_mips32_o32_elf_gas.S"
.text
.globl jump_fcontext
.align 2
.type jump_fcontext,@function
.ent jump_fcontext
jump_fcontext:
# reserve space on stack
addiu $sp, $sp, -96
sw $s0, 48($sp) # save S0
sw $s1, 52($sp) # save S1
sw $s2, 56($sp) # save S2
sw $s3, 60($sp) # save S3
sw $s4, 64($sp) # save S4
sw $s5, 68($sp) # save S5
sw $s6, 72($sp) # save S6
sw $s7, 76($sp) # save S7
sw $fp, 80($sp) # save FP
sw $a0, 84($sp) # save hidden, address of returned transfer_t
sw $ra, 88($sp) # save RA
sw $ra, 92($sp) # save RA as PC
#if defined(__mips_hard_float)
s.d $f20, ($sp) # save F20
s.d $f22, 8($sp) # save F22
s.d $f24, 16($sp) # save F24
s.d $f26, 24($sp) # save F26
s.d $f28, 32($sp) # save F28
s.d $f30, 40($sp) # save F30
#endif
# store SP (pointing to context-data) in A0
move $a0, $sp
# restore SP (pointing to context-data) from A1
move $sp, $a1
#if defined(__mips_hard_float)
l.d $f20, ($sp) # restore F20
l.d $f22, 8($sp) # restore F22
l.d $f24, 16($sp) # restore F24
l.d $f26, 24($sp) # restore F26
l.d $f28, 32($sp) # restore F28
l.d $f30, 40($sp) # restore F30
#endif
lw $s0, 48($sp) # restore S0
lw $s1, 52($sp) # restore S1
lw $s2, 56($sp) # restore S2
lw $s3, 60($sp) # restore S3
lw $s4, 64($sp) # restore S4
lw $s5, 68($sp) # restore S5
lw $s6, 72($sp) # restore S6
lw $s7, 76($sp) # restore S7
lw $fp, 80($sp) # restore FP
lw $v0, 84($sp) # restore hidden, address of returned transfer_t
lw $ra, 88($sp) # restore RA
# load PC
lw $t9, 92($sp)
# adjust stack
addiu $sp, $sp, 96
# return transfer_t from jump
sw $a0, ($v0) # fctx of transfer_t
sw $a2, 4($v0) # data of transfer_t
# pass transfer_t as first arg in context function
# A0 == fctx, A1 == data
move $a1, $a2
# jump to context
jr $t9
.end jump_fcontext
.size jump_fcontext, .-jump_fcontext
/* Mark that we don't need executable stack. */
.section .note.GNU-stack,"",%progbits
+124
View File
@@ -0,0 +1,124 @@
/*
Copyright Jiaxun Yang 2018.
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
*/
/*******************************************************
* *
* ------------------------------------------------- *
* | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | *
* ------------------------------------------------- *
* | 0 | 8 | 16 | 24 | *
* ------------------------------------------------- *
* | F24 | F25 | F26 | F27 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | *
* ------------------------------------------------- *
* | 32 | 40 | 48 | 56 | *
* ------------------------------------------------- *
* | F28 | F29 | F30 | F31 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | *
* ------------------------------------------------- *
* | 64 | 72 | 80 | 88 | *
* ------------------------------------------------- *
* | S0 | S1 | S2 | S3 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | *
* ------------------------------------------------- *
* | 96 | 100 | 104 | 108 | 112 | 116 | 120 | 124 | *
* ------------------------------------------------- *
* | S4 | S5 | S6 | S7 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | *
* ------------------------------------------------- *
* | 128 | 132 | 136 | 140 | 144 | 148 | 152 | 156 | *
* ------------------------------------------------- *
* | FP | GP | RA | PC | *
* ------------------------------------------------- *
* *
* *****************************************************/
.file "jump_mips64_n64_elf_gas.S"
.text
.globl jump_fcontext
.align 3
.type jump_fcontext,@function
.ent jump_fcontext
jump_fcontext:
# reserve space on stack
daddiu $sp, $sp, -160
sd $s0, 64($sp) # save S0
sd $s1, 72($sp) # save S1
sd $s2, 80($sp) # save S2
sd $s3, 88($sp) # save S3
sd $s4, 96($sp) # save S4
sd $s5, 104($sp) # save S5
sd $s6, 112($sp) # save S6
sd $s7, 120($sp) # save S7
sd $fp, 128($sp) # save FP
sd $ra, 144($sp) # save RA
sd $ra, 152($sp) # save RA as PC
#if defined(__mips_hard_float)
s.d $f24, 0($sp) # save F24
s.d $f25, 8($sp) # save F25
s.d $f26, 16($sp) # save F26
s.d $f27, 24($sp) # save F27
s.d $f28, 32($sp) # save F28
s.d $f29, 40($sp) # save F29
s.d $f30, 48($sp) # save F30
s.d $f31, 56($sp) # save F31
#endif
# store SP (pointing to old context-data) in v0 as return
move $v0, $sp
# get SP (pointing to new context-data) from a0 param
move $sp, $a0
#if defined(__mips_hard_float)
l.d $f24, 0($sp) # restore F24
l.d $f25, 8($sp) # restore F25
l.d $f26, 16($sp) # restore F26
l.d $f27, 24($sp) # restore F27
l.d $f28, 32($sp) # restore F28
l.d $f29, 40($sp) # restore F29
l.d $f30, 48($sp) # restore F30
l.d $f31, 56($sp) # restore F31
#endif
ld $s0, 64($sp) # restore S0
ld $s1, 72($sp) # restore S1
ld $s2, 80($sp) # restore S2
ld $s3, 88($sp) # restore S3
ld $s4, 96($sp) # restore S4
ld $s5, 104($sp) # restore S5
ld $s6, 112($sp) # restore S6
ld $s7, 120($sp) # restore S7
ld $fp, 128($sp) # restore FP
ld $ra, 144($sp) # restore RAa
# load PC
ld $t9, 152($sp)
# adjust stack
daddiu $sp, $sp, 160
move $a0, $v0 # move old sp from v0 to a0 as param
move $v1, $a1 # move *data from a1 to v1 as return
# jump to context
jr $t9
.end jump_fcontext
.size jump_fcontext, .-jump_fcontext
/* Mark that we don't need executable stack. */
.section .note.GNU-stack,"",%progbits
+201
View File
@@ -0,0 +1,201 @@
/*
Copyright Oliver Kowalke 2009.
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
*/
/*******************************************************
* *
* ------------------------------------------------- *
* | 0 | 4 | 8 | 12 | 16 | 20 | 24 | 28 | *
* ------------------------------------------------- *
* |bchai|hiddn| fpscr | PC | CR | R14 | R15 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 32 | 36 | 40 | 44 | 48 | 52 | 56 | 60 | *
* ------------------------------------------------- *
* | R16 | R17 | R18 | R19 | R20 | R21 | R22 | R23 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 64 | 68 | 72 | 76 | 80 | 84 | 88 | 92 | *
* ------------------------------------------------- *
* | R24 | R25 | R26 | R27 | R28 | R29 | R30 | R31 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 96 | 100 | 104 | 108 | 112 | 116 | 120 | 124 | *
* ------------------------------------------------- *
* | F14 | F15 | F16 | F17 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 128 | 132 | 136 | 140 | 144 | 148 | 152 | 156 | *
* ------------------------------------------------- *
* | F18 | F19 | F20 | F21 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 160 | 164 | 168 | 172 | 176 | 180 | 184 | 188 | *
* ------------------------------------------------- *
* | F22 | F23 | F24 | F25 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 192 | 196 | 200 | 204 | 208 | 212 | 216 | 220 | *
* ------------------------------------------------- *
* | F26 | F27 | F28 | F29 | *
* ------------------------------------------------- *
* ------------------------|------------ *
* | 224 | 228 | 232 | 236 | 240 | 244 | *
* ------------------------|------------ *
* | F30 | F31 |bchai| LR | *
* ------------------------|------------ *
* *
*******************************************************/
.file "jump_ppc32_sysv_elf_gas.S"
.text
.globl jump_fcontext
.align 2
.type jump_fcontext,@function
jump_fcontext:
# Linux: jump_fcontext( hidden transfer_t * R3, R4, R5)
# Other: transfer_t R3:R4 = jump_fcontext( R3, R4)
mflr %r0 # return address from LR
mffs %f0 # FPSCR
mfcr %r8 # condition register
stwu %r1, -240(%r1) # allocate stack space, R1 % 16 == 0
stw %r0, 244(%r1) # save LR in caller's frame
#ifdef __linux__
stw %r3, 4(%r1) # hidden pointer
#endif
stfd %f0, 8(%r1) # FPSCR
stw %r0, 16(%r1) # LR as PC
stw %r8, 20(%r1) # CR
# Save registers R14 to R31.
# Don't change R2, the thread-local storage pointer.
# Don't change R13, the small data pointer.
stw %r14, 24(%r1)
stw %r15, 28(%r1)
stw %r16, 32(%r1)
stw %r17, 36(%r1)
stw %r18, 40(%r1)
stw %r19, 44(%r1)
stw %r20, 48(%r1)
stw %r21, 52(%r1)
stw %r22, 56(%r1)
stw %r23, 60(%r1)
stw %r24, 64(%r1)
stw %r25, 68(%r1)
stw %r26, 72(%r1)
stw %r27, 76(%r1)
stw %r28, 80(%r1)
stw %r29, 84(%r1)
stw %r30, 88(%r1)
stw %r31, 92(%r1)
# Save registers F14 to F31 in slots with 8-byte alignment.
# 4-byte alignment may stall the pipeline of some processors.
# Less than 4 may cause alignment traps.
stfd %f14, 96(%r1)
stfd %f15, 104(%r1)
stfd %f16, 112(%r1)
stfd %f17, 120(%r1)
stfd %f18, 128(%r1)
stfd %f19, 136(%r1)
stfd %f20, 144(%r1)
stfd %f21, 152(%r1)
stfd %f22, 160(%r1)
stfd %f23, 168(%r1)
stfd %f24, 176(%r1)
stfd %f25, 184(%r1)
stfd %f26, 192(%r1)
stfd %f27, 200(%r1)
stfd %f28, 208(%r1)
stfd %f29, 216(%r1)
stfd %f30, 224(%r1)
stfd %f31, 232(%r1)
# store RSP (pointing to context-data) in R7/R6
# restore RSP (pointing to context-data) from R4/R3
#ifdef __linux__
mr %r7, %r1
mr %r1, %r4
lwz %r3, 4(%r1) # hidden pointer
#else
mr %r6, %r1
mr %r1, %r3
#endif
lfd %f0, 8(%r1) # FPSCR
lwz %r0, 16(%r1) # PC
lwz %r8, 20(%r1) # CR
mtfsf 0xff, %f0 # restore FPSCR
mtctr %r0 # load CTR with PC
mtcr %r8 # restore CR
# restore R14 to R31
lwz %r14, 24(%r1)
lwz %r15, 28(%r1)
lwz %r16, 32(%r1)
lwz %r17, 36(%r1)
lwz %r18, 40(%r1)
lwz %r19, 44(%r1)
lwz %r20, 48(%r1)
lwz %r21, 52(%r1)
lwz %r22, 56(%r1)
lwz %r23, 60(%r1)
lwz %r24, 64(%r1)
lwz %r25, 68(%r1)
lwz %r26, 72(%r1)
lwz %r27, 76(%r1)
lwz %r28, 80(%r1)
lwz %r29, 84(%r1)
lwz %r30, 88(%r1)
lwz %r31, 92(%r1)
# restore F14 to F31
lfd %f14, 96(%r1)
lfd %f15, 104(%r1)
lfd %f16, 112(%r1)
lfd %f17, 120(%r1)
lfd %f18, 128(%r1)
lfd %f19, 136(%r1)
lfd %f20, 144(%r1)
lfd %f21, 152(%r1)
lfd %f22, 160(%r1)
lfd %f23, 168(%r1)
lfd %f24, 176(%r1)
lfd %f25, 184(%r1)
lfd %f26, 192(%r1)
lfd %f27, 200(%r1)
lfd %f28, 208(%r1)
lfd %f29, 216(%r1)
lfd %f30, 224(%r1)
lfd %f31, 232(%r1)
# restore LR from caller's frame
lwz %r0, 244(%r1)
mtlr %r0
# adjust stack
addi %r1, %r1, 240
# return transfer_t
#ifdef __linux__
stw %r7, 0(%r3)
stw %r5, 4(%r3)
#else
mr %r3, %r6
# %r4, %r4
#endif
# jump to context
bctr
.size jump_fcontext, .-jump_fcontext
/* Mark that we don't need executable stack. */
.section .note.GNU-stack,"",%progbits
+201
View File
@@ -0,0 +1,201 @@
/*
Copyright Oliver Kowalke 2009.
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
*/
/******************************************************
* *
* ------------------------------------------------- *
* | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | *
* ------------------------------------------------- *
* | 0 | 4 | 8 | 12 | 16 | 20 | 24 | 28 | *
* ------------------------------------------------- *
* | F14 | F15 | F16 | F17 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | *
* ------------------------------------------------- *
* | 32 | 36 | 40 | 44 | 48 | 52 | 56 | 60 | *
* ------------------------------------------------- *
* | F18 | F19 | F20 | F21 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | *
* ------------------------------------------------- *
* | 64 | 68 | 72 | 76 | 80 | 84 | 88 | 92 | *
* ------------------------------------------------- *
* | F22 | F23 | F24 | F25 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | *
* ------------------------------------------------- *
* | 96 | 100 | 104 | 108 | 112 | 116 | 120 | 124 | *
* ------------------------------------------------- *
* | F26 | F27 | F28 | F29 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | *
* ------------------------------------------------- *
* | 128 | 132 | 136 | 140 | 144 | 148 | 152 | 156 | *
* ------------------------------------------------- *
* | F30 | F31 | fpscr | R13 | R14 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | *
* ------------------------------------------------- *
* | 160 | 164 | 168 | 172 | 176 | 180 | 184 | 188 | *
* ------------------------------------------------- *
* | R15 | R16 | R17 | R18 | R19 | R20 | R21 | R22 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | *
* ------------------------------------------------- *
* | 192 | 196 | 200 | 204 | 208 | 212 | 216 | 220 | *
* ------------------------------------------------- *
* | R23 | R24 | R25 | R26 | R27 | R28 | R29 | R30 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | *
* ------------------------------------------------- *
* | 224 | 228 | 232 | 236 | 240 | 244 | 248 | 252 | *
* ------------------------------------------------- *
* | R31 |hiddn| CR | LR | PC |bchai|linkr| FCTX| *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 64 | | *
* ------------------------------------------------- *
* | 256 | | *
* ------------------------------------------------- *
* | DATA| | *
* ------------------------------------------------- *
* *
*******************************************************/
.text
.globl _jump_fcontext
.align 2
_jump_fcontext:
; reserve space on stack
subi r1, r1, 244
stfd f14, 0(r1) # save F14
stfd f15, 8(r1) # save F15
stfd f16, 16(r1) # save F16
stfd f17, 24(r1) # save F17
stfd f18, 32(r1) # save F18
stfd f19, 40(r1) # save F19
stfd f20, 48(r1) # save F20
stfd f21, 56(r1) # save F21
stfd f22, 64(r1) # save F22
stfd f23, 72(r1) # save F23
stfd f24, 80(r1) # save F24
stfd f25, 88(r1) # save F25
stfd f26, 96(r1) # save F26
stfd f27, 104(r1) # save F27
stfd f28, 112(r1) # save F28
stfd f29, 120(r1) # save F29
stfd f30, 128(r1) # save F30
stfd f31, 136(r1) # save F31
mffs f0 # load FPSCR
stfd f0, 144(r1) # save FPSCR
stw r13, 152(r1) # save R13
stw r14, 156(r1) # save R14
stw r15, 160(r1) # save R15
stw r16, 164(r1) # save R16
stw r17, 168(r1) # save R17
stw r18, 172(r1) # save R18
stw r19, 176(r1) # save R19
stw r20, 180(r1) # save R20
stw r21, 184(r1) # save R21
stw r22, 188(r1) # save R22
stw r23, 192(r1) # save R23
stw r24, 196(r1) # save R24
stw r25, 200(r1) # save R25
stw r26, 204(r1) # save R26
stw r27, 208(r1) # save R27
stw r28, 212(r1) # save R28
stw r29, 216(r1) # save R29
stw r30, 220(r1) # save R30
stw r31, 224(r1) # save R31
stw r3, 228(r1) # save hidden
# save CR
mfcr r0
stw r0, 232(r1)
# save LR
mflr r0
stw r0, 236(r1)
# save LR as PC
stw r0, 240(r1)
# store RSP (pointing to context-data) in R6
mr r6, r1
# restore RSP (pointing to context-data) from R4
mr r1, r4
lfd f14, 0(r1) # restore F14
lfd f15, 8(r1) # restore F15
lfd f16, 16(r1) # restore F16
lfd f17, 24(r1) # restore F17
lfd f18, 32(r1) # restore F18
lfd f19, 40(r1) # restore F19
lfd f20, 48(r1) # restore F20
lfd f21, 56(r1) # restore F21
lfd f22, 64(r1) # restore F22
lfd f23, 72(r1) # restore F23
lfd f24, 80(r1) # restore F24
lfd f25, 88(r1) # restore F25
lfd f26, 96(r1) # restore F26
lfd f27, 104(r1) # restore F27
lfd f28, 112(r1) # restore F28
lfd f29, 120(r1) # restore F29
lfd f30, 128(r1) # restore F30
lfd f31, 136(r1) # restore F31
lfd f0, 144(r1) # load FPSCR
mtfsf 0xff, f0 # restore FPSCR
lwz r13, 152(r1) # restore R13
lwz r14, 156(r1) # restore R14
lwz r15, 160(r1) # restore R15
lwz r16, 164(r1) # restore R16
lwz r17, 168(r1) # restore R17
lwz r18, 172(r1) # restore R18
lwz r19, 176(r1) # restore R19
lwz r20, 180(r1) # restore R20
lwz r21, 184(r1) # restore R21
lwz r22, 188(r1) # restore R22
lwz r23, 192(r1) # restore R23
lwz r24, 196(r1) # restore R24
lwz r25, 200(r1) # restore R25
lwz r26, 204(r1) # restore R26
lwz r27, 208(r1) # restore R27
lwz r28, 212(r1) # restore R28
lwz r29, 216(r1) # restore R29
lwz r30, 220(r1) # restore R30
lwz r31, 224(r1) # restore R31
lwz r3, 228(r1) # restore hidden
# restore CR
lwz r0, 232(r1)
mtcr r0
# restore LR
lwz r0, 236(r1)
mtlr r0
# load PC
lwz r0, 240(r1)
# restore CTR
mtctr r0
# adjust stack
addi r1, r1, 244
# return transfer_t
stw r6, 0(r3)
stw r5, 4(r3)
# jump to context
bctr
+221
View File
@@ -0,0 +1,221 @@
/*
Copyright Oliver Kowalke 2009.
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
*/
/*******************************************************
* *
* ------------------------------------------------- *
* | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | *
* ------------------------------------------------- *
* | 0 | 4 | 8 | 12 | 16 | 20 | 24 | 28 | *
* ------------------------------------------------- *
* | TOC | R14 | R15 | R16 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | *
* ------------------------------------------------- *
* | 32 | 36 | 40 | 44 | 48 | 52 | 56 | 60 | *
* ------------------------------------------------- *
* | R17 | R18 | R19 | R20 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | *
* ------------------------------------------------- *
* | 64 | 68 | 72 | 76 | 80 | 84 | 88 | 92 | *
* ------------------------------------------------- *
* | R21 | R22 | R23 | R24 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | *
* ------------------------------------------------- *
* | 96 | 100 | 104 | 108 | 112 | 116 | 120 | 124 | *
* ------------------------------------------------- *
* | R25 | R26 | R27 | R28 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | *
* ------------------------------------------------- *
* | 128 | 132 | 136 | 140 | 144 | 148 | 152 | 156 | *
* ------------------------------------------------- *
* | R29 | R30 | R31 | hidden | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | *
* ------------------------------------------------- *
* | 160 | 164 | 168 | 172 | 176 | 180 | 184 | 188 | *
* ------------------------------------------------- *
* | CR | LR | PC | back-chain| *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | *
* ------------------------------------------------- *
* | 192 | 196 | 200 | 204 | 208 | 212 | 216 | 220 | *
* ------------------------------------------------- *
* | cr saved | lr saved | compiler | linker | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | *
* ------------------------------------------------- *
* | 224 | 228 | 232 | 236 | 240 | 244 | 248 | 252 | *
* ------------------------------------------------- *
* | TOC saved | FCTX | DATA | | *
* ------------------------------------------------- *
* *
*******************************************************/
.file "jump_ppc64_sysv_elf_gas.S"
.globl jump_fcontext
#if _CALL_ELF == 2
.text
.align 2
jump_fcontext:
addis %r2, %r12, .TOC.-jump_fcontext@ha
addi %r2, %r2, .TOC.-jump_fcontext@l
.localentry jump_fcontext, . - jump_fcontext
#else
.section ".opd","aw"
.align 3
jump_fcontext:
# ifdef _CALL_LINUX
.quad .L.jump_fcontext,.TOC.@tocbase,0
.type jump_fcontext,@function
.text
.align 2
.L.jump_fcontext:
# else
.hidden .jump_fcontext
.globl .jump_fcontext
.quad .jump_fcontext,.TOC.@tocbase,0
.size jump_fcontext,24
.type .jump_fcontext,@function
.text
.align 2
.jump_fcontext:
# endif
#endif
# reserve space on stack
subi %r1, %r1, 184
#if _CALL_ELF != 2
std %r2, 0(%r1) # save TOC
#endif
std %r14, 8(%r1) # save R14
std %r15, 16(%r1) # save R15
std %r16, 24(%r1) # save R16
std %r17, 32(%r1) # save R17
std %r18, 40(%r1) # save R18
std %r19, 48(%r1) # save R19
std %r20, 56(%r1) # save R20
std %r21, 64(%r1) # save R21
std %r22, 72(%r1) # save R22
std %r23, 80(%r1) # save R23
std %r24, 88(%r1) # save R24
std %r25, 96(%r1) # save R25
std %r26, 104(%r1) # save R26
std %r27, 112(%r1) # save R27
std %r28, 120(%r1) # save R28
std %r29, 128(%r1) # save R29
std %r30, 136(%r1) # save R30
std %r31, 144(%r1) # save R31
#if _CALL_ELF != 2
std %r3, 152(%r1) # save hidden
#endif
# save CR
mfcr %r0
std %r0, 160(%r1)
# save LR
mflr %r0
std %r0, 168(%r1)
# save LR as PC
std %r0, 176(%r1)
# store RSP (pointing to context-data) in R6
mr %r6, %r1
#if _CALL_ELF == 2
# restore RSP (pointing to context-data) from R3
mr %r1, %r3
#else
# restore RSP (pointing to context-data) from R4
mr %r1, %r4
ld %r2, 0(%r1) # restore TOC
#endif
ld %r14, 8(%r1) # restore R14
ld %r15, 16(%r1) # restore R15
ld %r16, 24(%r1) # restore R16
ld %r17, 32(%r1) # restore R17
ld %r18, 40(%r1) # restore R18
ld %r19, 48(%r1) # restore R19
ld %r20, 56(%r1) # restore R20
ld %r21, 64(%r1) # restore R21
ld %r22, 72(%r1) # restore R22
ld %r23, 80(%r1) # restore R23
ld %r24, 88(%r1) # restore R24
ld %r25, 96(%r1) # restore R25
ld %r26, 104(%r1) # restore R26
ld %r27, 112(%r1) # restore R27
ld %r28, 120(%r1) # restore R28
ld %r29, 128(%r1) # restore R29
ld %r30, 136(%r1) # restore R30
ld %r31, 144(%r1) # restore R31
#if _CALL_ELF != 2
ld %r3, 152(%r1) # restore hidden
#endif
# restore CR
ld %r0, 160(%r1)
mtcr %r0
# restore LR
ld %r0, 168(%r1)
mtlr %r0
# load PC
ld %r12, 176(%r1)
# restore CTR
mtctr %r12
# adjust stack
addi %r1, %r1, 184
#if _CALL_ELF == 2
# copy transfer_t into transfer_fn arg registers
mr %r3, %r6
# arg pointer already in %r4
# jump to context
bctr
.size jump_fcontext, .-jump_fcontext
#else
# zero in r3 indicates first jump to context-function
cmpdi %r3, 0
beq use_entry_arg
# return transfer_t
std %r6, 0(%r3)
std %r5, 8(%r3)
# jump to context
bctr
use_entry_arg:
# copy transfer_t into transfer_fn arg registers
mr %r3, %r6
mr %r4, %r5
# jump to context
bctr
# ifdef _CALL_LINUX
.size .jump_fcontext, .-.L.jump_fcontext
# else
.size .jump_fcontext, .-.jump_fcontext
# endif
#endif
/* Mark that we don't need executable stack. */
.section .note.GNU-stack,"",%progbits
+164
View File
@@ -0,0 +1,164 @@
/*
Copyright Oliver Kowalke 2009.
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
*/
/*******************************************************
* *
* ------------------------------------------------- *
* | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | *
* ------------------------------------------------- *
* | 0 | 4 | 8 | 12 | 16 | 20 | 24 | 28 | *
* ------------------------------------------------- *
* | TOC | R14 | R15 | R16 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | *
* ------------------------------------------------- *
* | 32 | 36 | 40 | 44 | 48 | 52 | 56 | 60 | *
* ------------------------------------------------- *
* | R17 | R18 | R19 | R20 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | *
* ------------------------------------------------- *
* | 64 | 68 | 72 | 76 | 80 | 84 | 88 | 92 | *
* ------------------------------------------------- *
* | R21 | R22 | R23 | R24 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | *
* ------------------------------------------------- *
* | 96 | 100 | 104 | 108 | 112 | 116 | 120 | 124 | *
* ------------------------------------------------- *
* | R25 | R26 | R27 | R28 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | *
* ------------------------------------------------- *
* | 128 | 132 | 136 | 140 | 144 | 148 | 152 | 156 | *
* ------------------------------------------------- *
* | R29 | R30 | R31 | hidden | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | *
* ------------------------------------------------- *
* | 160 | 164 | 168 | 172 | 176 | 180 | 184 | 188 | *
* ------------------------------------------------- *
* | CR | LR | PC | back-chain| *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | *
* ------------------------------------------------- *
* | 192 | 196 | 200 | 204 | 208 | 212 | 216 | 220 | *
* ------------------------------------------------- *
* | cr saved | lr saved | compiler | linker | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | *
* ------------------------------------------------- *
* | 224 | 228 | 232 | 236 | 240 | 244 | 248 | 252 | *
* ------------------------------------------------- *
* | TOC saved | FCTX | DATA | | *
* ------------------------------------------------- *
* *
*******************************************************/
.text
.align 2
.globl _jump_fcontext
_jump_fcontext:
; reserve space on stack
subi r1, r1, 184
std r14, 8(r1) ; save R14
std r15, 16(r1) ; save R15
std r16, 24(r1) ; save R16
std r17, 32(r1) ; save R17
std r18, 40(r1) ; save R18
std r19, 48(r1) ; save R19
std r20, 56(r1) ; save R20
std r21, 64(r1) ; save R21
std r22, 72(r1) ; save R22
std r23, 80(r1) ; save R23
std r24, 88(r1) ; save R24
std r25, 96(r1) ; save R25
std r26, 104(r1) ; save R26
std r27, 112(r1) ; save R27
std r28, 120(r1) ; save R28
std r29, 128(r1) ; save R29
std r30, 136(r1) ; save R30
std r31, 144(r1) ; save R31
std r3, 152(r1) ; save hidden
; save CR
mfcr r0
std r0, 160(r1)
; save LR
mflr r0
std r0, 168(r1)
; save LR as PC
std r0, 176(r1)
; store RSP (pointing to context-data) in R6
mr r6, r1
; restore RSP (pointing to context-data) from R4
mr r1, r4
ld r14, 8(r1) ; restore R14
ld r15, 16(r1) ; restore R15
ld r16, 24(r1) ; restore R16
ld r17, 32(r1) ; restore R17
ld r18, 40(r1) ; restore R18
ld r19, 48(r1) ; restore R19
ld r20, 56(r1) ; restore R20
ld r21, 64(r1) ; restore R21
ld r22, 72(r1) ; restore R22
ld r23, 80(r1) ; restore R23
ld r24, 88(r1) ; restore R24
ld r25, 96(r1) ; restore R25
ld r26, 104(r1) ; restore R26
ld r27, 112(r1) ; restore R27
ld r28, 120(r1) ; restore R28
ld r29, 128(r1) ; restore R29
ld r30, 136(r1) ; restore R30
ld r31, 144(r1) ; restore R31
ld r3, 152(r1) ; restore hidden
; restore CR
ld r0, 160(r1)
mtcr r0
; restore LR
ld r0, 168(r1)
mtlr r0
; load PC
ld r12, 176(r1)
# restore CTR
mtctr r12
# adjust stack
addi r1, r1, 184
# zero in r3 indicates first jump to context-function
cmpdi r3, 0
beq use_entry_arg
# return transfer_t
std r6, 0(r3)
std r5, 8(r3)
# jump to context
bctr
use_entry_arg:
# copy transfer_t into transfer_fn arg registers
mr r3, r6
mr r4, r5
# jump to context
bctr
+156
View File
@@ -0,0 +1,156 @@
/*******************************************************
* ------------------------------------------------- *
* | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | *
* ------------------------------------------------- *
* | 0 | 8 | 16 | 24 | *
* ------------------------------------------------- *
* | t.fctx | t.data | r2 | r6 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | *
* ------------------------------------------------- *
* | 32 | 40 | 48 | 56 | *
* ------------------------------------------------- *
* | r7 | r8 | r9 | r10 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | *
* ------------------------------------------------- *
* | 64 | 72 | 80 | 88 | *
* ------------------------------------------------- *
* | r11 | r12 | r13 | r14 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | *
* ------------------------------------------------- *
* | 96 | 104 | 112 | 120 | *
* ------------------------------------------------- *
* | f8 | f9 | f10 | f11 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | *
* ------------------------------------------------- *
* | 128 | 136 | 144 | 152 | *
* ------------------------------------------------- *
* | f12 | f13 | f14 | f15 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | *
* ------------------------------------------------- *
* | 160 | 168 | 176 | | *
* ------------------------------------------------- *
* | fpc | pc | | | *
* ------------------------------------------------- *
*******************************************************/
.text
.align 8
.global jump_fcontext
.type jump_fcontext, @function
#define ARG_OFFSET 0
#define GR_OFFSET 16
#define FP_OFFSET 96
#define FPC_OFFSET 160
#define PC_OFFSET 168
#define CONTEXT_SIZE 176
#define REG_SAVE_AREA_SIZE 160
/*
typedef void* fcontext_t;
struct transfer_t {
fcontext_t fctx;
void * data;
};
transfer_t jump_fcontext( fcontext_t const to,
void * data);
Incoming args
r2 - Hidden argument to the location where the return transfer_t needs to be returned
r3 - Context we want to switch to
r4 - Data pointer
*/
jump_fcontext:
.machine "z10"
/* Reserve stack space to store the current context. */
aghi %r15,-CONTEXT_SIZE
/* Save the argument register holding the location of the return value. */
stg %r2,GR_OFFSET(%r15)
/* Save the call-saved general purpose registers. */
stmg %r6,%r14,GR_OFFSET+8(%r15)
/* Save call-saved floating point registers. */
std %f8,FP_OFFSET(%r15)
std %f9,FP_OFFSET+8(%r15)
std %f10,FP_OFFSET+16(%r15)
std %f11,FP_OFFSET+24(%r15)
std %f12,FP_OFFSET+32(%r15)
std %f13,FP_OFFSET+40(%r15)
std %f14,FP_OFFSET+48(%r15)
std %f15,FP_OFFSET+56(%r15)
/* Save the return address as current pc. */
stg %r14,PC_OFFSET(%r15)
/* Save the floating point control register. */
stfpc FPC_OFFSET(%r15)
/* Backup the stack pointer pointing to the old context-data into r1. */
lgr %r1,%r15
/* Load the new context pointer as stack pointer. */
lgr %r15,%r3
/* Restore the call-saved GPRs from the new context. */
lmg %r6,%r14,GR_OFFSET+8(%r15)
/* Restore call-saved floating point registers. */
ld %f8,FP_OFFSET(%r15)
ld %f9,FP_OFFSET+8(%r15)
ld %f10,FP_OFFSET+16(%r15)
ld %f11,FP_OFFSET+24(%r15)
ld %f12,FP_OFFSET+32(%r15)
ld %f13,FP_OFFSET+40(%r15)
ld %f14,FP_OFFSET+48(%r15)
ld %f15,FP_OFFSET+56(%r15)
/* Load the floating point control register. */
lfpc FPC_OFFSET(%r15)
/* Restore PC - the location where we will jump to at the end. */
lg %r5,PC_OFFSET(%r15)
ltg %r2,GR_OFFSET(%r15)
jnz use_return_slot
/* We restore a make_fcontext context. Use the function
argument slot in the context we just saved and allocate the
register save area for the target function. */
la %r2,ARG_OFFSET(%r1)
aghi %r15,-REG_SAVE_AREA_SIZE
use_return_slot:
/* Save the two fields in transfer_t. When calling a
make_fcontext function this becomes the function argument of
the target function, otherwise it will be the return value of
jump_fcontext. */
stg %r1,0(%r2)
stg %r4,8(%r2)
/* Free the restored context. */
aghi %r15,CONTEXT_SIZE
/* Jump to the PC loaded from the new context. */
br %r5
.size jump_fcontext,.-jump_fcontext
.section .note.GNU-stack,"",%progbits
+205
View File
@@ -0,0 +1,205 @@
; Copyright Oliver Kowalke 2009.
; Distributed under the Boost Software License, Version 1.0.
; (See accompanying file LICENSE_1_0.txt or copy at
; http://www.boost.org/LICENSE_1_0.txt)
; ----------------------------------------------------------------------------------
; | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
; ----------------------------------------------------------------------------------
; | 0x0 | 0x4 | 0x8 | 0xc | 0x10 | 0x14 | 0x18 | 0x1c |
; ----------------------------------------------------------------------------------
; | SEE registers (XMM6-XMM15) |
; ----------------------------------------------------------------------------------
; ----------------------------------------------------------------------------------
; | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
; ----------------------------------------------------------------------------------
; | 0x20 | 0x24 | 0x28 | 0x2c | 0x30 | 0x34 | 0x38 | 0x3c |
; ----------------------------------------------------------------------------------
; | SEE registers (XMM6-XMM15) |
; ----------------------------------------------------------------------------------
; ----------------------------------------------------------------------------------
; | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 |
; ----------------------------------------------------------------------------------
; | 0xe40 | 0x44 | 0x48 | 0x4c | 0x50 | 0x54 | 0x58 | 0x5c |
; ----------------------------------------------------------------------------------
; | SEE registers (XMM6-XMM15) |
; ----------------------------------------------------------------------------------
; ----------------------------------------------------------------------------------
; | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 |
; ----------------------------------------------------------------------------------
; | 0x60 | 0x64 | 0x68 | 0x6c | 0x70 | 0x74 | 0x78 | 0x7c |
; ----------------------------------------------------------------------------------
; | SEE registers (XMM6-XMM15) |
; ----------------------------------------------------------------------------------
; ----------------------------------------------------------------------------------
; | 32 | 32 | 33 | 34 | 35 | 36 | 37 | 38 |
; ----------------------------------------------------------------------------------
; | 0x80 | 0x84 | 0x88 | 0x8c | 0x90 | 0x94 | 0x98 | 0x9c |
; ----------------------------------------------------------------------------------
; | SEE registers (XMM6-XMM15) |
; ----------------------------------------------------------------------------------
; ----------------------------------------------------------------------------------
; | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 |
; ----------------------------------------------------------------------------------
; | 0xa0 | 0xa4 | 0xa8 | 0xac | 0xb0 | 0xb4 | 0xb8 | 0xbc |
; ----------------------------------------------------------------------------------
; | fc_mxcsr|fc_x87_cw| <alignment> | fbr_strg | fc_dealloc |
; ----------------------------------------------------------------------------------
; ----------------------------------------------------------------------------------
; | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 |
; ----------------------------------------------------------------------------------
; | 0xc0 | 0xc4 | 0xc8 | 0xcc | 0xd0 | 0xd4 | 0xd8 | 0xdc |
; ----------------------------------------------------------------------------------
; | limit | base | R12 | R13 |
; ----------------------------------------------------------------------------------
; ----------------------------------------------------------------------------------
; | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 |
; ----------------------------------------------------------------------------------
; | 0xe0 | 0xe4 | 0xe8 | 0xec | 0xf0 | 0xf4 | 0xf8 | 0xfc |
; ----------------------------------------------------------------------------------
; | R14 | R15 | RDI | RSI |
; ----------------------------------------------------------------------------------
; ----------------------------------------------------------------------------------
; | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 |
; ----------------------------------------------------------------------------------
; | 0x100 | 0x104 | 0x108 | 0x10c | 0x110 | 0x114 | 0x118 | 0x11c |
; ----------------------------------------------------------------------------------
; | RBX | RBP | hidden | RIP |
; ----------------------------------------------------------------------------------
; ----------------------------------------------------------------------------------
; | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 |
; ----------------------------------------------------------------------------------
; | 0x120 | 0x124 | 0x128 | 0x12c | 0x130 | 0x134 | 0x138 | 0x13c |
; ----------------------------------------------------------------------------------
; | parameter area |
; ----------------------------------------------------------------------------------
; ----------------------------------------------------------------------------------
; | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 |
; ----------------------------------------------------------------------------------
; | 0x140 | 0x144 | 0x148 | 0x14c | 0x150 | 0x154 | 0x158 | 0x15c |
; ----------------------------------------------------------------------------------
; | FCTX | DATA | |
; ----------------------------------------------------------------------------------
.code
jump_fcontext PROC BOOST_CONTEXT_EXPORT FRAME
.endprolog
; prepare stack
lea rsp, [rsp-0118h]
IFNDEF BOOST_USE_TSX
; save XMM storage
movaps [rsp], xmm6
movaps [rsp+010h], xmm7
movaps [rsp+020h], xmm8
movaps [rsp+030h], xmm9
movaps [rsp+040h], xmm10
movaps [rsp+050h], xmm11
movaps [rsp+060h], xmm12
movaps [rsp+070h], xmm13
movaps [rsp+080h], xmm14
movaps [rsp+090h], xmm15
; save MMX control- and status-word
stmxcsr [rsp+0a0h]
; save x87 control-word
fnstcw [rsp+0a4h]
ENDIF
; load NT_TIB
mov r10, gs:[030h]
; save fiber local storage
mov rax, [r10+020h]
mov [rsp+0b0h], rax
; save current deallocation stack
mov rax, [r10+01478h]
mov [rsp+0b8h], rax
; save current stack limit
mov rax, [r10+010h]
mov [rsp+0c0h], rax
; save current stack base
mov rax, [r10+08h]
mov [rsp+0c8h], rax
mov [rsp+0d0h], r12 ; save R12
mov [rsp+0d8h], r13 ; save R13
mov [rsp+0e0h], r14 ; save R14
mov [rsp+0e8h], r15 ; save R15
mov [rsp+0f0h], rdi ; save RDI
mov [rsp+0f8h], rsi ; save RSI
mov [rsp+0100h], rbx ; save RBX
mov [rsp+0108h], rbp ; save RBP
mov [rsp+0110h], rcx ; save hidden address of transport_t
; preserve RSP (pointing to context-data) in R9
mov r9, rsp
; restore RSP (pointing to context-data) from RDX
mov rsp, rdx
IFNDEF BOOST_USE_TSX
; restore XMM storage
movaps xmm6, [rsp]
movaps xmm7, [rsp+010h]
movaps xmm8, [rsp+020h]
movaps xmm9, [rsp+030h]
movaps xmm10, [rsp+040h]
movaps xmm11, [rsp+050h]
movaps xmm12, [rsp+060h]
movaps xmm13, [rsp+070h]
movaps xmm14, [rsp+080h]
movaps xmm15, [rsp+090h]
; restore MMX control- and status-word
ldmxcsr [rsp+0a0h]
; save x87 control-word
fldcw [rsp+0a4h]
ENDIF
; load NT_TIB
mov r10, gs:[030h]
; restore fiber local storage
mov rax, [rsp+0b0h]
mov [r10+020h], rax
; restore current deallocation stack
mov rax, [rsp+0b8h]
mov [r10+01478h], rax
; restore current stack limit
mov rax, [rsp+0c0h]
mov [r10+010h], rax
; restore current stack base
mov rax, [rsp+0c8h]
mov [r10+08h], rax
mov r12, [rsp+0d0h] ; restore R12
mov r13, [rsp+0d8h] ; restore R13
mov r14, [rsp+0e0h] ; restore R14
mov r15, [rsp+0e8h] ; restore R15
mov rdi, [rsp+0f0h] ; restore RDI
mov rsi, [rsp+0f8h] ; restore RSI
mov rbx, [rsp+0100h] ; restore RBX
mov rbp, [rsp+0108h] ; restore RBP
mov rax, [rsp+0110h] ; restore hidden address of transport_t
; prepare stack
lea rsp, [rsp+0118h]
; load return-address
pop r10
; transport_t returned in RAX
; return parent fcontext_t
mov [rax], r9
; return data
mov [rax+08h], r8
; transport_t as 1.arg of context-function
mov rcx, rax
; indirect jump to context
jmp r10
jump_fcontext ENDP
END
+91
View File
@@ -0,0 +1,91 @@
/*
Copyright Oliver Kowalke 2009.
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
*/
/****************************************************************************************
* *
* ---------------------------------------------------------------------------------- *
* | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | *
* ---------------------------------------------------------------------------------- *
* | 0x0 | 0x4 | 0x8 | 0xc | 0x10 | 0x14 | 0x18 | 0x1c | *
* ---------------------------------------------------------------------------------- *
* | fc_mxcsr|fc_x87_cw| R12 | R13 | R14 | *
* ---------------------------------------------------------------------------------- *
* ---------------------------------------------------------------------------------- *
* | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | *
* ---------------------------------------------------------------------------------- *
* | 0x20 | 0x24 | 0x28 | 0x2c | 0x30 | 0x34 | 0x38 | 0x3c | *
* ---------------------------------------------------------------------------------- *
* | R15 | RBX | RBP | RIP | *
* ---------------------------------------------------------------------------------- *
* *
****************************************************************************************/
.file "jump_x86_64_sysv_elf_gas.S"
.text
.globl jump_fcontext
.type jump_fcontext,@function
.align 16
jump_fcontext:
leaq -0x38(%rsp), %rsp /* prepare stack */
#if !defined(BOOST_USE_TSX)
stmxcsr (%rsp) /* save MMX control- and status-word */
fnstcw 0x4(%rsp) /* save x87 control-word */
#endif
movq %r12, 0x8(%rsp) /* save R12 */
movq %r13, 0x10(%rsp) /* save R13 */
movq %r14, 0x18(%rsp) /* save R14 */
movq %r15, 0x20(%rsp) /* save R15 */
movq %rbx, 0x28(%rsp) /* save RBX */
movq %rbp, 0x30(%rsp) /* save RBP */
/* store RSP (pointing to context-data) in RAX */
movq %rsp, %rax
/* restore RSP (pointing to context-data) from RDI */
movq %rdi, %rsp
movq 0x38(%rsp), %r8 /* restore return-address */
#if !defined(BOOST_USE_TSX)
ldmxcsr (%rsp) /* restore MMX control- and status-word */
fldcw 0x4(%rsp) /* restore x87 control-word */
#endif
movq 0x8(%rsp), %r12 /* restore R12 */
movq 0x10(%rsp), %r13 /* restore R13 */
movq 0x18(%rsp), %r14 /* restore R14 */
movq 0x20(%rsp), %r15 /* restore R15 */
movq 0x28(%rsp), %rbx /* restore RBX */
movq 0x30(%rsp), %rbp /* restore RBP */
leaq 0x40(%rsp), %rsp /* prepare stack */
/* return transfer_t from jump */
#if !defined(_ILP32)
/* RAX == fctx, RDX == data */
movq %rsi, %rdx
#else
/* RAX == data:fctx */
salq $32, %rsi
orq %rsi, %rax
#endif
/* pass transfer_t as first arg in context function */
#if !defined(_ILP32)
/* RDI == fctx, RSI == data */
#else
/* RDI == data:fctx */
#endif
movq %rax, %rdi
/* indirect jump to context */
jmp *%r8
.size jump_fcontext,.-jump_fcontext
/* Mark that we don't need executable stack. */
.section .note.GNU-stack,"",%progbits
+75
View File
@@ -0,0 +1,75 @@
/*
Copyright Oliver Kowalke 2009.
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
*/
/****************************************************************************************
* *
* ---------------------------------------------------------------------------------- *
* | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | *
* ---------------------------------------------------------------------------------- *
* | 0x0 | 0x4 | 0x8 | 0xc | 0x10 | 0x14 | 0x18 | 0x1c | *
* ---------------------------------------------------------------------------------- *
* | fc_mxcsr|fc_x87_cw| R12 | R13 | R14 | *
* ---------------------------------------------------------------------------------- *
* ---------------------------------------------------------------------------------- *
* | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | *
* ---------------------------------------------------------------------------------- *
* | 0x20 | 0x24 | 0x28 | 0x2c | 0x30 | 0x34 | 0x38 | 0x3c | *
* ---------------------------------------------------------------------------------- *
* | R15 | RBX | RBP | RIP | *
* ---------------------------------------------------------------------------------- *
* *
****************************************************************************************/
.text
.globl _jump_fcontext
.align 8
_jump_fcontext:
leaq -0x38(%rsp), %rsp /* prepare stack */
#if !defined(BOOST_USE_TSX)
stmxcsr (%rsp) /* save MMX control- and status-word */
fnstcw 0x4(%rsp) /* save x87 control-word */
#endif
movq %r12, 0x8(%rsp) /* save R12 */
movq %r13, 0x10(%rsp) /* save R13 */
movq %r14, 0x18(%rsp) /* save R14 */
movq %r15, 0x20(%rsp) /* save R15 */
movq %rbx, 0x28(%rsp) /* save RBX */
movq %rbp, 0x30(%rsp) /* save RBP */
/* store RSP (pointing to context-data) in RAX */
movq %rsp, %rax
/* restore RSP (pointing to context-data) from RDI */
movq %rdi, %rsp
movq 0x38(%rsp), %r8 /* restore return-address */
#if !defined(BOOST_USE_TSX)
ldmxcsr (%rsp) /* restore MMX control- and status-word */
fldcw 0x4(%rsp) /* restore x87 control-word */
#endif
movq 0x8(%rsp), %r12 /* restore R12 */
movq 0x10(%rsp), %r13 /* restore R13 */
movq 0x18(%rsp), %r14 /* restore R14 */
movq 0x20(%rsp), %r15 /* restore R15 */
movq 0x28(%rsp), %rbx /* restore RBX */
movq 0x30(%rsp), %rbp /* restore RBP */
leaq 0x40(%rsp), %rsp /* prepare stack */
/* return transfer_t from jump */
/* RAX == fctx, RDX == data */
movq %rsi, %rdx
/* pass transfer_t as first arg in context function */
/* RDI == fctx, RSI == data */
movq %rax, %rdi
/* indirect jump to context */
jmp *%r8
+85
View File
@@ -0,0 +1,85 @@
/*
Copyright Edward Nevill + Oliver Kowalke 2015
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
*/
/*******************************************************
* *
* ------------------------------------------------- *
* | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | *
* ------------------------------------------------- *
* | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c| *
* ------------------------------------------------- *
* | d8 | d9 | d10 | d11 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | *
* ------------------------------------------------- *
* | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c| *
* ------------------------------------------------- *
* | d12 | d13 | d14 | d15 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | *
* ------------------------------------------------- *
* | 0x40| 0x44| 0x48| 0x4c| 0x50| 0x54| 0x58| 0x5c| *
* ------------------------------------------------- *
* | x19 | x20 | x21 | x22 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | *
* ------------------------------------------------- *
* | 0x60| 0x64| 0x68| 0x6c| 0x70| 0x74| 0x78| 0x7c| *
* ------------------------------------------------- *
* | x23 | x24 | x25 | x26 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | *
* ------------------------------------------------- *
* | 0x80| 0x84| 0x88| 0x8c| 0x90| 0x94| 0x98| 0x9c| *
* ------------------------------------------------- *
* | x27 | x28 | FP | LR | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 40 | 41 | 42 | 43 | | | *
* ------------------------------------------------- *
* | 0xa0| 0xa4| 0xa8| 0xac| | | *
* ------------------------------------------------- *
* | PC | align | | | *
* ------------------------------------------------- *
* *
*******************************************************/
.file "make_arm64_aapcs_elf_gas.S"
.text
.align 2
.global make_fcontext
.type make_fcontext, %function
make_fcontext:
# shift address in x0 (allocated stack) to lower 16 byte boundary
and x0, x0, ~0xF
# reserve space for context-data on context-stack
sub x0, x0, #0xb0
# third arg of make_fcontext() == address of context-function
# store address as a PC to jump in
str x2, [x0, #0xa0]
# save address of finish as return-address for context-function
# will be entered after context-function returns (LR register)
adr x1, finish
str x1, [x0, #0x98]
ret x30 // return pointer to context-data (x0)
finish:
# exit code is zero
mov x0, #0
# exit application
bl _exit
.size make_fcontext,.-make_fcontext
# Mark that we don't need executable stack.
.section .note.GNU-stack,"",%progbits
+83
View File
@@ -0,0 +1,83 @@
/*
Copyright Edward Nevill + Oliver Kowalke 2015
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
*/
/*******************************************************
* *
* ------------------------------------------------- *
* | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | *
* ------------------------------------------------- *
* | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c| *
* ------------------------------------------------- *
* | d8 | d9 | d10 | d11 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | *
* ------------------------------------------------- *
* | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c| *
* ------------------------------------------------- *
* | d12 | d13 | d14 | d15 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | *
* ------------------------------------------------- *
* | 0x40| 0x44| 0x48| 0x4c| 0x50| 0x54| 0x58| 0x5c| *
* ------------------------------------------------- *
* | x19 | x20 | x21 | x22 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | *
* ------------------------------------------------- *
* | 0x60| 0x64| 0x68| 0x6c| 0x70| 0x74| 0x78| 0x7c| *
* ------------------------------------------------- *
* | x23 | x24 | x25 | x26 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | *
* ------------------------------------------------- *
* | 0x80| 0x84| 0x88| 0x8c| 0x90| 0x94| 0x98| 0x9c| *
* ------------------------------------------------- *
* | x27 | x28 | FP | LR | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 40 | 41 | 42 | 43 | | | *
* ------------------------------------------------- *
* | 0xa0| 0xa4| 0xa8| 0xac| | | *
* ------------------------------------------------- *
* | PC | align | | | *
* ------------------------------------------------- *
* *
*******************************************************/
.text
.globl _make_fcontext
.balign 16
_make_fcontext:
; shift address in x0 (allocated stack) to lower 16 byte boundary
and x0, x0, ~0xF
; reserve space for context-data on context-stack
sub x0, x0, #0xb0
; third arg of make_fcontext() == address of context-function
; store address as a PC to jump in
str x2, [x0, #0xa0]
adr x1, finish
; save address of finish as return-address for context-function
; will be entered after context-function returns (LR register)
str x1, [x0, #0x98]
ret lr ; return pointer to context-data (x0)
finish:
; exit code is zero
mov x0, #0
; exit application
bl __exit
+81
View File
@@ -0,0 +1,81 @@
/*
Copyright Oliver Kowalke 2009.
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
*/
/*******************************************************
* *
* ------------------------------------------------- *
* | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | *
* ------------------------------------------------- *
* | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c| *
* ------------------------------------------------- *
* | s16 | s17 | s18 | s19 | s20 | s21 | s22 | s23 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | *
* ------------------------------------------------- *
* | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c| *
* ------------------------------------------------- *
* | s24 | s25 | s26 | s27 | s28 | s29 | s30 | s31 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | *
* ------------------------------------------------- *
* | 0x40| 0x44| 0x48| 0x4c| 0x50| 0x54| 0x58| 0x5c| *
* ------------------------------------------------- *
* |hiddn| v1 | v2 | v3 | v4 | v5 | v6 | v7 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | *
* ------------------------------------------------- *
* | 0x60| 0x64| 0x68| 0x6c| 0x70| 0x74| 0x78| 0x7c| *
* ------------------------------------------------- *
* | v8 | lr | pc | FCTX| DATA| | *
* ------------------------------------------------- *
* *
*******************************************************/
.file "make_arm_aapcs_elf_gas.S"
.text
.globl make_fcontext
.align 2
.type make_fcontext,%function
.syntax unified
make_fcontext:
@ shift address in A1 to lower 16 byte boundary
bic a1, a1, #15
@ reserve space for context-data on context-stack
sub a1, a1, #124
@ third arg of make_fcontext() == address of context-function
str a3, [a1, #104]
@ compute address of returned transfer_t
add a2, a1, #108
mov a3, a2
str a3, [a1, #64]
@ compute abs address of label finish
adr a2, finish
@ save address of finish as return-address for context-function
@ will be entered after context-function returns
str a2, [a1, #100]
#if (defined(__VFP_FP__) && !defined(__SOFTFP__))
#endif
bx lr @ return pointer to context-data
finish:
@ exit code is zero
mov a1, #0
@ exit application
bl _exit@PLT
.size make_fcontext,.-make_fcontext
@ Mark that we don't need executable stack.
.section .note.GNU-stack,"",%progbits
+71
View File
@@ -0,0 +1,71 @@
/*
Copyright Oliver Kowalke 2009.
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
*/
/*******************************************************
* *
* ------------------------------------------------- *
* | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | *
* ------------------------------------------------- *
* | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c| *
* ------------------------------------------------- *
* | s16 | s17 | s18 | s19 | s20 | s21 | s22 | s23 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | *
* ------------------------------------------------- *
* | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c| *
* ------------------------------------------------- *
* | s24 | s25 | s26 | s27 | s28 | s29 | s30 | s31 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | *
* ------------------------------------------------- *
* | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c| *
* ------------------------------------------------- *
* | sjlj|hiddn| v1 | v2 | v3 | v4 | v5 | v6 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | *
* ------------------------------------------------- *
* | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c| *
* ------------------------------------------------- *
* | v7 | v8 | lr | pc | FCTX| DATA| | *
* ------------------------------------------------- *
* *
*******************************************************/
.text
.globl _make_fcontext
.align 2
_make_fcontext:
@ shift address in A1 to lower 16 byte boundary
bic a1, a1, #15
@ reserve space for context-data on context-stack
sub a1, a1, #124
@ third arg of make_fcontext() == address of context-function
str a3, [a1, #108]
@ compute address of returned transfer_t
add a2, a1, #112
mov a3, a2
str a3, [a1, #68]
@ compute abs address of label finish
adr a2, finish
@ save address of finish as return-address for context-function
@ will be entered after context-function returns
str a2, [a1, #104]
bx lr @ return pointer to context-data
finish:
@ exit code is zero
mov a1, #0
@ exit application
bl __exit
+24
View File
@@ -0,0 +1,24 @@
/*
Copyright Sergue E. Leontiev 2013.
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
*/
// Stub file for universal binary
#if defined(__i386__)
#include "make_i386_sysv_macho_gas.S"
#elif defined(__x86_64__)
#include "make_x86_64_sysv_macho_gas.S"
#elif defined(__ppc__)
#include "make_ppc32_sysv_macho_gas.S"
#elif defined(__ppc64__)
#include "make_ppc64_sysv_macho_gas.S"
#elif defined(__arm__)
#include "make_arm_aapcs_macho_gas.S"
#elif defined(__arm64__)
#include "make_arm64_aapcs_macho_gas.S"
#else
#error "No arch's"
#endif
+140
View File
@@ -0,0 +1,140 @@
; Copyright Oliver Kowalke 2009.
; Distributed under the Boost Software License, Version 1.0.
; (See accompanying file LICENSE_1_0.txt or copy at
; http://www.boost.org/LICENSE_1_0.txt)
; ---------------------------------------------------------------------------------
; | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
; ---------------------------------------------------------------------------------
; | 0h | 04h | 08h | 0ch | 010h | 014h | 018h | 01ch |
; ---------------------------------------------------------------------------------
; | fc_mxcsr|fc_x87_cw| fc_strg |fc_deallo| limit | base | fc_seh | EDI |
; ---------------------------------------------------------------------------------
; ---------------------------------------------------------------------------------
; | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
; ---------------------------------------------------------------------------------
; | 020h | 024h | 028h | 02ch | 030h | 034h | 038h | 03ch |
; ---------------------------------------------------------------------------------
; | ESI | EBX | EBP | EIP | to | data | EH NXT |SEH HNDLR|
; ---------------------------------------------------------------------------------
.386
.XMM
.model flat, c
; standard C library function
_exit PROTO, value:SDWORD
.code
make_fcontext PROC BOOST_CONTEXT_EXPORT
; first arg of make_fcontext() == top of context-stack
mov eax, [esp+04h]
; reserve space for first argument of context-function
; EAX might already point to a 16byte border
lea eax, [eax-08h]
; shift address in EAX to lower 16 byte boundary
and eax, -16
; reserve space for context-data on context-stack
; on context-function entry: (ESP -0x4) % 8 == 0
; additional space is required for SEH
lea eax, [eax-040h]
; save MMX control- and status-word
stmxcsr [eax]
; save x87 control-word
fnstcw [eax+04h]
; first arg of make_fcontext() == top of context-stack
mov ecx, [esp+04h]
; save top address of context stack as 'base'
mov [eax+014h], ecx
; second arg of make_fcontext() == size of context-stack
mov edx, [esp+08h]
; negate stack size for LEA instruction (== substraction)
neg edx
; compute bottom address of context stack (limit)
lea ecx, [ecx+edx]
; save bottom address of context-stack as 'limit'
mov [eax+010h], ecx
; save bottom address of context-stack as 'dealloction stack'
mov [eax+0ch], ecx
; set fiber-storage to zero
xor ecx, ecx
mov [eax+08h], ecx
; third arg of make_fcontext() == address of context-function
; stored in EBX
mov ecx, [esp+0ch]
mov [eax+024h], ecx
; compute abs address of label trampoline
mov ecx, trampoline
; save address of trampoline as return-address for context-function
; will be entered after calling jump_fcontext() first time
mov [eax+02ch], ecx
; compute abs address of label finish
mov ecx, finish
; save address of finish as return-address for context-function in EBP
; will be entered after context-function returns
mov [eax+028h], ecx
; traverse current seh chain to get the last exception handler installed by Windows
; note that on Windows Server 2008 and 2008 R2, SEHOP is activated by default
; the exception handler chain is tested for the presence of ntdll.dll!FinalExceptionHandler
; at its end by RaiseException all seh-handlers are disregarded if not present and the
; program is aborted
assume fs:nothing
; load NT_TIB into ECX
mov ecx, fs:[0h]
assume fs:error
walk:
; load 'next' member of current SEH into EDX
mov edx, [ecx]
; test if 'next' of current SEH is last (== 0xffffffff)
inc edx
jz found
dec edx
; exchange content; ECX contains address of next SEH
xchg edx, ecx
; inspect next SEH
jmp walk
found:
; load 'handler' member of SEH == address of last SEH handler installed by Windows
mov ecx, [ecx+04h]
; save address in ECX as SEH handler for context
mov [eax+03ch], ecx
; set ECX to -1
mov ecx, 0ffffffffh
; save ECX as next SEH item
mov [eax+038h], ecx
; load address of next SEH item
lea ecx, [eax+038h]
; save next SEH
mov [eax+018h], ecx
ret ; return pointer to context-data
trampoline:
; move transport_t for entering context-function
; FCTX == EAX, DATA == EDX
mov [esp], eax
mov [esp+04h], edx
push ebp
; jump to context-function
jmp ebx
finish:
; exit code is zero
xor eax, eax
mov [esp], eax
; exit application
call _exit
hlt
make_fcontext ENDP
END
+107
View File
@@ -0,0 +1,107 @@
/*
Copyright Oliver Kowalke 2009.
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
*/
/****************************************************************************************
* *
* ---------------------------------------------------------------------------------- *
* | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | *
* ---------------------------------------------------------------------------------- *
* | 0x0 | 0x4 | 0x8 | 0xc | 0x10 | 0x14 | 0x18 | 0x1c | *
* ---------------------------------------------------------------------------------- *
* | fc_mxcsr|fc_x87_cw| EDI | ESI | EBX | EBP | EIP | hidden | *
* ---------------------------------------------------------------------------------- *
* ---------------------------------------------------------------------------------- *
* | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | *
* ---------------------------------------------------------------------------------- *
* | 0x20 | 0x24 | | *
* ---------------------------------------------------------------------------------- *
* | to | data | | *
* ---------------------------------------------------------------------------------- *
* *
****************************************************************************************/
.file "make_i386_sysv_elf_gas.S"
.text
.globl make_fcontext
.align 2
.type make_fcontext,@function
make_fcontext:
/* first arg of make_fcontext() == top of context-stack */
movl 0x4(%esp), %eax
/* reserve space for first argument of context-function
eax might already point to a 16byte border */
leal -0x8(%eax), %eax
/* shift address in EAX to lower 16 byte boundary */
andl $-16, %eax
/* reserve space for context-data on context-stack */
leal -0x28(%eax), %eax
/* third arg of make_fcontext() == address of context-function */
/* stored in EBX */
movl 0xc(%esp), %ecx
movl %ecx, 0x10(%eax)
/* save MMX control- and status-word */
stmxcsr (%eax)
/* save x87 control-word */
fnstcw 0x4(%eax)
/* return transport_t */
/* FCTX == EDI, DATA == ESI */
leal 0x8(%eax), %ecx
movl %ecx, 0x1c(%eax)
/* compute abs address of label trampoline */
call 1f
/* address of trampoline 1 */
1: popl %ecx
/* compute abs address of label trampoline */
addl $trampoline-1b, %ecx
/* save address of trampoline as return address */
/* will be entered after calling jump_fcontext() first time */
movl %ecx, 0x18(%eax)
/* compute abs address of label finish */
call 2f
/* address of label 2 */
2: popl %ecx
/* compute abs address of label finish */
addl $finish-2b, %ecx
/* save address of finish as return-address for context-function */
/* will be entered after context-function returns */
movl %ecx, 0x14(%eax)
ret /* return pointer to context-data */
trampoline:
/* move transport_t for entering context-function */
movl %edi, (%esp)
movl %esi, 0x4(%esp)
pushl %ebp
/* jump to context-function */
jmp *%ebx
finish:
call 3f
/* address of label 3 */
3: popl %ebx
/* compute address of GOT and store it in EBX */
addl $_GLOBAL_OFFSET_TABLE_+[.-3b], %ebx
/* exit code is zero */
xorl %eax, %eax
movl %eax, (%esp)
/* exit application */
call _exit@PLT
hlt
.size make_fcontext,.-make_fcontext
/* Mark that we don't need executable stack. */
.section .note.GNU-stack,"",%progbits
+90
View File
@@ -0,0 +1,90 @@
/*
Copyright Oliver Kowalke 2009.
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
*/
/****************************************************************************************
* *
* ---------------------------------------------------------------------------------- *
* | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | *
* ---------------------------------------------------------------------------------- *
* | 0x0 | 0x4 | 0x8 | 0xc | 0x10 | 0x14 | 0x18 | 0x1c | *
* ---------------------------------------------------------------------------------- *
* | fc_mxcsr|fc_x87_cw| EDI | ESI | EBX | EBP | EIP | to | *
* ---------------------------------------------------------------------------------- *
* ---------------------------------------------------------------------------------- *
* | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | *
* ---------------------------------------------------------------------------------- *
* | 0x20 | | *
* ---------------------------------------------------------------------------------- *
* | data | | *
* ---------------------------------------------------------------------------------- *
* *
****************************************************************************************/
.text
.globl _make_fcontext
.align 2
_make_fcontext:
/* first arg of make_fcontext() == top of context-stack */
movl 0x4(%esp), %eax
/* reserve space for first argument of context-function
eax might already point to a 16byte border */
leal -0x8(%eax), %eax
/* shift address in EAX to lower 16 byte boundary */
andl $-16, %eax
/* reserve space for context-data on context-stack */
leal -0x2c(%eax), %eax
/* third arg of make_fcontext() == address of context-function */
/* stored in EBX */
movl 0xc(%esp), %ecx
movl %ecx, 0x10(%eax)
/* save MMX control- and status-word */
stmxcsr (%eax)
/* save x87 control-word */
fnstcw 0x4(%eax)
/* compute abs address of label trampoline */
call 1f
/* address of trampoline 1 */
1: popl %ecx
/* compute abs address of label trampoline */
addl $trampoline-1b, %ecx
/* save address of trampoline as return address */
/* will be entered after calling jump_fcontext() first time */
movl %ecx, 0x18(%eax)
/* compute abs address of label finish */
call 2f
/* address of label 2 */
2: popl %ecx
/* compute abs address of label finish */
addl $finish-2b, %ecx
/* save address of finish as return-address for context-function */
/* will be entered after context-function returns */
movl %ecx, 0x14(%eax)
ret /* return pointer to context-data */
trampoline:
/* move transport_t for entering context-function */
movl %eax, (%esp)
movl %edx, 0x4(%esp)
pushl %ebp
/* jump to context-function */
jmp *%ebx
finish:
/* exit code is zero */
xorl %eax, %eax
movl %eax, (%esp)
/* exit application */
call __exit
hlt
+97
View File
@@ -0,0 +1,97 @@
/*
Copyright Oliver Kowalke 2009.
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
*/
/*******************************************************
* *
* ------------------------------------------------- *
* | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | *
* ------------------------------------------------- *
* | 0 | 4 | 8 | 12 | 16 | 20 | 24 | 28 | *
* ------------------------------------------------- *
* | F20 | F22 | F24 | F26 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | *
* ------------------------------------------------- *
* | 32 | 36 | 40 | 44 | 48 | 52 | 56 | 60 | *
* ------------------------------------------------- *
* | F28 | F30 | S0 | S1 | S2 | S3 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | *
* ------------------------------------------------- *
* | 64 | 68 | 72 | 76 | 80 | 84 | 88 | 92 | *
* ------------------------------------------------- *
* | S4 | S5 | S6 | S7 | FP |hiddn| RA | PC | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | *
* ------------------------------------------------- *
* | 96 | 100 | 104 | 108 | 112 | 116 | 120 | 124 | *
* ------------------------------------------------- *
* | ABI ARGS | GP | FCTX| DATA| | *
* ------------------------------------------------- *
* *
* *****************************************************/
.file "make_mips32_o32_elf_gas.S"
.text
.globl make_fcontext
.align 2
.type make_fcontext,@function
.ent make_fcontext
make_fcontext:
#ifdef __PIC__
.set noreorder
.cpload $t9
.set reorder
#endif
# shift address in A0 to lower 16 byte boundary
li $v1, -16 # 0xfffffffffffffff0
and $v0, $v1, $a0
# reserve space for context-data on context-stack
# includes an extra 32 bytes for:
# - 16-byte incoming argument area required by mips ABI used when
# jump_context calls the initial function
# - 4 bytes to save our GP register used in finish
# - 8 bytes to as space for transfer_t returned to finish
# - 4 bytes for alignment
addiu $v0, $v0, -128
# third arg of make_fcontext() == address of context-function
sw $a2, 92($v0)
# save global pointer in context-data
sw $gp, 112($v0)
# compute address of returned transfer_t
addiu $t0, $v0, 116
sw $t0, 84($v0)
# compute abs address of label finish
la $t9, finish
# save address of finish as return-address for context-function
# will be entered after context-function returns
sw $t9, 88($v0)
jr $ra # return pointer to context-data
finish:
# reload our gp register (needed for la)
lw $gp, 16($sp)
# call _exit(0)
# the previous function should have left the 16 bytes incoming argument
# area on the stack which we reuse for calling _exit
la $t9, _exit
move $a0, $zero
jr $t9
.end make_fcontext
.size make_fcontext, .-make_fcontext
/* Mark that we don't need executable stack. */
.section .note.GNU-stack,"",%progbits
+96
View File
@@ -0,0 +1,96 @@
/*
Copyright Jiaxun Yang 2018.
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
*/
/*******************************************************
* *
* ------------------------------------------------- *
* | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | *
* ------------------------------------------------- *
* | 0 | 8 | 16 | 24 | *
* ------------------------------------------------- *
* | F24 | F25 | F26 | F27 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | *
* ------------------------------------------------- *
* | 32 | 40 | 48 | 56 | *
* ------------------------------------------------- *
* | F28 | F29 | F30 | F31 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | *
* ------------------------------------------------- *
* | 64 | 72 | 80 | 88 | *
* ------------------------------------------------- *
* | S0 | S1 | S2 | S3 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | *
* ------------------------------------------------- *
* | 96 | 100 | 104 | 108 | 112 | 116 | 120 | 124 | *
* ------------------------------------------------- *
* | S4 | S5 | S6 | S7 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | *
* ------------------------------------------------- *
* | 128 | 132 | 136 | 140 | 144 | 148 | 152 | 156 | *
* ------------------------------------------------- *
* | FP | GP | RA | PC | *
* ------------------------------------------------- *
* *
* *****************************************************/
.file "make_mips64_n64_elf_gas.S"
.text
.globl make_fcontext
.align 3
.type make_fcontext,@function
.ent make_fcontext
make_fcontext:
#ifdef __PIC__
.set noreorder
.cpload $t9
.set reorder
#endif
# shift address in A0 to lower 16 byte boundary
li $v1, 0xfffffffffffffff0
and $v0, $v1, $a0
# reserve space for context-data on context-stack
daddiu $v0, $v0, -160
# third arg of make_fcontext() == address of context-function
sd $a2, 152($v0)
# save global pointer in context-data
sd $gp, 136($v0)
# psudo instruction compute abs address of label finish based on GP
dla $t9, finish
# save address of finish as return-address for context-function
# will be entered after context-function returns
sd $t9, 144($v0)
jr $ra # return pointer to context-data
finish:
# reload our gp register (needed for la)
daddiu $t0, $sp, -160
ld $gp, 136($t0)
# call _exit(0)
# the previous function should have left the 16 bytes incoming argument
# area on the stack which we reuse for calling _exit
dla $t9, _exit
move $a0, $zero
jr $t9
.end make_fcontext
.size make_fcontext, .-make_fcontext
/* Mark that we don't need executable stack. */
.section .note.GNU-stack,"",%progbits
+146
View File
@@ -0,0 +1,146 @@
/*
Copyright Oliver Kowalke 2009.
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
*/
/*******************************************************
* *
* ------------------------------------------------- *
* | 0 | 4 | 8 | 12 | 16 | 20 | 24 | 28 | *
* ------------------------------------------------- *
* |bchai|hiddn| fpscr | PC | CR | R14 | R15 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 32 | 36 | 40 | 44 | 48 | 52 | 56 | 60 | *
* ------------------------------------------------- *
* | R16 | R17 | R18 | R19 | R20 | R21 | R22 | R23 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 64 | 68 | 72 | 76 | 80 | 84 | 88 | 92 | *
* ------------------------------------------------- *
* | R24 | R25 | R26 | R27 | R28 | R29 | R30 | R31 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 96 | 100 | 104 | 108 | 112 | 116 | 120 | 124 | *
* ------------------------------------------------- *
* | F14 | F15 | F16 | F17 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 128 | 132 | 136 | 140 | 144 | 148 | 152 | 156 | *
* ------------------------------------------------- *
* | F18 | F19 | F20 | F21 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 160 | 164 | 168 | 172 | 176 | 180 | 184 | 188 | *
* ------------------------------------------------- *
* | F22 | F23 | F24 | F25 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 192 | 196 | 200 | 204 | 208 | 212 | 216 | 220 | *
* ------------------------------------------------- *
* | F26 | F27 | F28 | F29 | *
* ------------------------------------------------- *
* ------------------------|------------ *
* | 224 | 228 | 232 | 236 | 240 | 244 | *
* ------------------------|------------ *
* | F30 | F31 |bchai| LR | *
* ------------------------|------------ *
* *
*******************************************************/
.file "make_ppc32_sysv_elf_gas.S"
.text
.globl make_fcontext
.align 2
.type make_fcontext,@function
make_fcontext:
# save return address into R6
mflr %r6
# first arg of make_fcontext() == top address of context-function
# shift address in R3 to lower 16 byte boundary
clrrwi %r3, %r3, 4
# reserve space on context-stack, including 16 bytes of linkage
# and parameter area + 240 bytes of context-data (R1 % 16 == 0)
subi %r3, %r3, 16 + 240
# third arg of make_fcontext() == address of context-function
#ifdef __linux__
# save context-function as PC
stw %r5, 16(%r3)
#else
# save context-function for trampoline
stw %r5, 248(%r3)
#endif
# set back-chain to zero
li %r0, 0
stw %r0, 240(%r3)
# copy FPSCR to new context
mffs %f0
stfd %f0, 8(%r3)
#ifdef __linux__
# set hidden pointer for returning transfer_t
la %r0, 248(%r3)
stw %r0, 4(%r3)
#endif
# load address of label 1 into R4
bl 1f
1: mflr %r4
#ifndef __linux__
# compute abs address of trampoline, use as PC
addi %r7, %r4, trampoline - 1b
stw %r7, 16(%r3)
#endif
# compute abs address of label finish
addi %r4, %r4, finish - 1b
# save address of finish as return-address for context-function
# will be entered after context-function returns
stw %r4, 244(%r3)
# restore return address from R6
mtlr %r6
blr # return pointer to context-data
#ifndef __linux__
trampoline:
# On systems other than Linux, jump_fcontext is returning the
# transfer_t in R3:R4, but we need to pass transfer_t * R3 to
# our context-function.
lwz %r0, 8(%r1) # address of context-function
mtctr %r0
stw %r3, 8(%r1)
stw %r4, 12(%r1)
la %r3, 8(%r1) # address of transfer_t
bctr
#endif
finish:
# Use the secure PLT for _exit(0). If we use the insecure BSS PLT
# here, then the linker may use the insecure BSS PLT even if the
# C++ compiler wanted the secure PLT.
# set R30 for secure PLT, large model
bl 2f
2: mflr %r30
addis %r30, %r30, .Ltoc - 2b@ha
addi %r30, %r30, .Ltoc - 2b@l
# call _exit(0) with special addend 0x8000 for large model
li %r3, 0
bl _exit + 0x8000@plt
.size make_fcontext, .-make_fcontext
/* Provide the GOT pointer for secure PLT, large model. */
.section .got2,"aw"
.Ltoc = . + 0x8000
/* Mark that we don't need executable stack. */
.section .note.GNU-stack,"",%progbits
+137
View File
@@ -0,0 +1,137 @@
/*
Copyright Oliver Kowalke 2009.
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
*/
/******************************************************
* *
* ------------------------------------------------- *
* | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | *
* ------------------------------------------------- *
* | 0 | 4 | 8 | 12 | 16 | 20 | 24 | 28 | *
* ------------------------------------------------- *
* | F14 | F15 | F16 | F17 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | *
* ------------------------------------------------- *
* | 32 | 36 | 40 | 44 | 48 | 52 | 56 | 60 | *
* ------------------------------------------------- *
* | F18 | F19 | F20 | F21 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | *
* ------------------------------------------------- *
* | 64 | 68 | 72 | 76 | 80 | 84 | 88 | 92 | *
* ------------------------------------------------- *
* | F22 | F23 | F24 | F25 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | *
* ------------------------------------------------- *
* | 96 | 100 | 104 | 108 | 112 | 116 | 120 | 124 | *
* ------------------------------------------------- *
* | F26 | F27 | F28 | F29 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | *
* ------------------------------------------------- *
* | 128 | 132 | 136 | 140 | 144 | 148 | 152 | 156 | *
* ------------------------------------------------- *
* | F30 | F31 | fpscr | R13 | R14 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | *
* ------------------------------------------------- *
* | 160 | 164 | 168 | 172 | 176 | 180 | 184 | 188 | *
* ------------------------------------------------- *
* | R15 | R16 | R17 | R18 | R19 | R20 | R21 | R22 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | *
* ------------------------------------------------- *
* | 192 | 196 | 200 | 204 | 208 | 212 | 216 | 220 | *
* ------------------------------------------------- *
* | R23 | R24 | R25 | R26 | R27 | R28 | R29 | R30 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | *
* ------------------------------------------------- *
* | 224 | 228 | 232 | 236 | 240 | 244 | 248 | 252 | *
* ------------------------------------------------- *
* | R31 |hiddn| CR | LR | PC |bchai|linkr| FCTX| *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 64 | | *
* ------------------------------------------------- *
* | 256 | | *
* ------------------------------------------------- *
* | DATA| | *
* ------------------------------------------------- *
* *
*******************************************************/
.text
.globl _make_fcontext
.align 2
_make_fcontext:
# save return address into R6
mflr r6
# first arg of make_fcontext() == top address of context-function
# shift address in R3 to lower 16 byte boundary
clrrwi r3, r3, 4
# reserve space for context-data on context-stack
# including 64 byte of linkage + parameter area (R1 16 == 0)
subi r3, r3, 336
# third arg of make_fcontext() == address of context-function
stw r5, 240(r3)
# set back-chain to zero
li r0, 0
stw r0, 244(r3)
mffs f0 # load FPSCR
stfd f0, 144(r3) # save FPSCR
# compute address of returned transfer_t
addi r0, r3, 252
mr r4, r0
stw r4, 228(r3)
# load LR
mflr r0
# jump to label 1
bl 1f
1:
# load LR into R4
mflr r4
# compute abs address of label finish
addi r4, r4, finish - 1b
# restore LR
mtlr r0
# save address of finish as return-address for context-function
# will be entered after context-function returns
stw r4, 236(r3)
# restore return address from R6
mtlr r6
blr # return pointer to context-data
finish:
# save return address into R0
mflr r0
# save return address on stack, set up stack frame
stw r0, 4(r1)
# allocate stack space, R1 16 == 0
stwu r1, -16(r1)
# exit code is zero
li r3, 0
# exit application
bl _exit@plt
+177
View File
@@ -0,0 +1,177 @@
/*
Copyright Oliver Kowalke 2009.
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
*/
/*******************************************************
* *
* ------------------------------------------------- *
* | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | *
* ------------------------------------------------- *
* | 0 | 4 | 8 | 12 | 16 | 20 | 24 | 28 | *
* ------------------------------------------------- *
* | TOC | R14 | R15 | R16 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | *
* ------------------------------------------------- *
* | 32 | 36 | 40 | 44 | 48 | 52 | 56 | 60 | *
* ------------------------------------------------- *
* | R17 | R18 | R19 | R20 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | *
* ------------------------------------------------- *
* | 64 | 68 | 72 | 76 | 80 | 84 | 88 | 92 | *
* ------------------------------------------------- *
* | R21 | R22 | R23 | R24 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | *
* ------------------------------------------------- *
* | 96 | 100 | 104 | 108 | 112 | 116 | 120 | 124 | *
* ------------------------------------------------- *
* | R25 | R26 | R27 | R28 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | *
* ------------------------------------------------- *
* | 128 | 132 | 136 | 140 | 144 | 148 | 152 | 156 | *
* ------------------------------------------------- *
* | R29 | R30 | R31 | hidden | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | *
* ------------------------------------------------- *
* | 160 | 164 | 168 | 172 | 176 | 180 | 184 | 188 | *
* ------------------------------------------------- *
* | CR | LR | PC | back-chain| *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | *
* ------------------------------------------------- *
* | 192 | 196 | 200 | 204 | 208 | 212 | 216 | 220 | *
* ------------------------------------------------- *
* | cr saved | lr saved | compiler | linker | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | *
* ------------------------------------------------- *
* | 224 | 228 | 232 | 236 | 240 | 244 | 248 | 252 | *
* ------------------------------------------------- *
* | TOC saved | FCTX | DATA | | *
* ------------------------------------------------- *
* *
*******************************************************/
.file "make_ppc64_sysv_elf_gas.S"
.globl make_fcontext
#if _CALL_ELF == 2
.text
.align 2
make_fcontext:
addis %r2, %r12, .TOC.-make_fcontext@ha
addi %r2, %r2, .TOC.-make_fcontext@l
.localentry make_fcontext, . - make_fcontext
#else
.section ".opd","aw"
.align 3
make_fcontext:
# ifdef _CALL_LINUX
.quad .L.make_fcontext,.TOC.@tocbase,0
.type make_fcontext,@function
.text
.align 2
.L.make_fcontext:
# else
.hidden .make_fcontext
.globl .make_fcontext
.quad .make_fcontext,.TOC.@tocbase,0
.size make_fcontext,24
.type .make_fcontext,@function
.text
.align 2
.make_fcontext:
# endif
#endif
# save return address into R6
mflr %r6
# first arg of make_fcontext() == top address of context-stack
# shift address in R3 to lower 16 byte boundary
clrrdi %r3, %r3, 4
# reserve space for context-data on context-stack
# including 64 byte of linkage + parameter area (R1 % 16 == 0)
subi %r3, %r3, 248
# third arg of make_fcontext() == address of context-function
# entry point (ELFv2) or descriptor (ELFv1)
#if _CALL_ELF == 2
# save address of context-function entry point
std %r5, 176(%r3)
#else
# save address of context-function entry point
ld %r4, 0(%r5)
std %r4, 176(%r3)
# save TOC of context-function
ld %r4, 8(%r5)
std %r4, 0(%r3)
#endif
# set back-chain to zero
li %r0, 0
std %r0, 184(%r3)
#if _CALL_ELF != 2
# zero in r3 indicates first jump to context-function
std %r0, 152(%r3)
#endif
# load LR
mflr %r0
# jump to label 1
bl 1f
1:
# load LR into R4
mflr %r4
# compute abs address of label finish
addi %r4, %r4, finish - 1b
# restore LR
mtlr %r0
# save address of finish as return-address for context-function
# will be entered after context-function returns
std %r4, 168(%r3)
# restore return address from R6
mtlr %r6
blr # return pointer to context-data
finish:
# save return address into R0
mflr %r0
# save return address on stack, set up stack frame
std %r0, 8(%r1)
# allocate stack space, R1 % 16 == 0
stdu %r1, -32(%r1)
# exit code is zero
li %r3, 0
# exit application
bl _exit
nop
#if _CALL_ELF == 2
.size make_fcontext, .-make_fcontext
#else
# ifdef _CALL_LINUX
.size .make_fcontext, .-.L.make_fcontext
# else
.size .make_fcontext, .-.make_fcontext
# endif
#endif
/* Mark that we don't need executable stack. */
.section .note.GNU-stack,"",%progbits
+126
View File
@@ -0,0 +1,126 @@
/*
Copyright Oliver Kowalke 2009.
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
*/
/*******************************************************
* *
* ------------------------------------------------- *
* | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | *
* ------------------------------------------------- *
* | 0 | 4 | 8 | 12 | 16 | 20 | 24 | 28 | *
* ------------------------------------------------- *
* | TOC | R14 | R15 | R16 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | *
* ------------------------------------------------- *
* | 32 | 36 | 40 | 44 | 48 | 52 | 56 | 60 | *
* ------------------------------------------------- *
* | R17 | R18 | R19 | R20 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | *
* ------------------------------------------------- *
* | 64 | 68 | 72 | 76 | 80 | 84 | 88 | 92 | *
* ------------------------------------------------- *
* | R21 | R22 | R23 | R24 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | *
* ------------------------------------------------- *
* | 96 | 100 | 104 | 108 | 112 | 116 | 120 | 124 | *
* ------------------------------------------------- *
* | R25 | R26 | R27 | R28 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | *
* ------------------------------------------------- *
* | 128 | 132 | 136 | 140 | 144 | 148 | 152 | 156 | *
* ------------------------------------------------- *
* | R29 | R30 | R31 | hidden | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | *
* ------------------------------------------------- *
* | 160 | 164 | 168 | 172 | 176 | 180 | 184 | 188 | *
* ------------------------------------------------- *
* | CR | LR | PC | back-chain| *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | *
* ------------------------------------------------- *
* | 192 | 196 | 200 | 204 | 208 | 212 | 216 | 220 | *
* ------------------------------------------------- *
* | cr saved | lr saved | compiler | linker | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | *
* ------------------------------------------------- *
* | 224 | 228 | 232 | 236 | 240 | 244 | 248 | 252 | *
* ------------------------------------------------- *
* | TOC saved | FCTX | DATA | | *
* ------------------------------------------------- *
* *
.text
.globl _make_fcontext
_make_fcontext:
; save return address into R6
mflr r6
; first arg of make_fcontext() == top address of context-function
; shift address in R3 to lower 16 byte boundary
clrrwi r3, r3, 4
; reserve space for context-data on context-stack
; including 64 byte of linkage + parameter area (R1 16 == 0)
subi r3, r3, 248
; third arg of make_fcontext() == address of context-function
stw r5, 176(r3)
; set back-chain to zero
li %r0, 0
std %r0, 184(%r3)
; compute address of returned transfer_t
addi %r0, %r3, 232
mr %r4, %r0
std %r4, 152(%r3)
; load LR
mflr r0
; jump to label 1
bl l1
l1:
; load LR into R4
mflr r4
; compute abs address of label finish
addi r4, r4, lo16((finish - .) + 4)
; restore LR
mtlr r0
; save address of finish as return-address for context-function
; will be entered after context-function returns
std r4, 168(r3)
; restore return address from R6
mtlr r6
blr ; return pointer to context-data
finish:
; save return address into R0
mflr r0
; save return address on stack, set up stack frame
stw r0, 8(r1)
; allocate stack space, R1 16 == 0
stwu r1, -32(r1)
; set return value to zero
li r3, 0
; exit application
bl __exit
nop
+108
View File
@@ -0,0 +1,108 @@
/*******************************************************
* ------------------------------------------------- *
* | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | *
* ------------------------------------------------- *
* | 0 | 8 | 16 | 24 | *
* ------------------------------------------------- *
* | t.fctx | t.data | r2 | r6 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | *
* ------------------------------------------------- *
* | 32 | 40 | 48 | 56 | *
* ------------------------------------------------- *
* | r7 | r8 | r9 | r10 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | *
* ------------------------------------------------- *
* | 64 | 72 | 80 | 88 | *
* ------------------------------------------------- *
* | r11 | r12 | r13 | r14 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | *
* ------------------------------------------------- *
* | 96 | 104 | 112 | 120 | *
* ------------------------------------------------- *
* | f8 | f9 | f10 | f11 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | *
* ------------------------------------------------- *
* | 128 | 136 | 144 | 152 | *
* ------------------------------------------------- *
* | f12 | f13 | f14 | f15 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | *
* ------------------------------------------------- *
* | 160 | 168 | 176 | | *
* ------------------------------------------------- *
* | fpc | pc | | | *
* ------------------------------------------------- *
*******************************************************/
.text
.align 8
.global make_fcontext
.type make_fcontext, @function
#define ARG_OFFSET 0
#define GR_OFFSET 16
#define R14_OFFSET 88
#define FP_OFFSET 96
#define FPC_OFFSET 160
#define PC_OFFSET 168
#define CONTEXT_SIZE 176
/*
fcontext_t make_fcontext( void * sp, std::size_t size, void (* fn)( transfer_t) );
Create and return a context below SP to call FN.
Incoming args
r2 - The stack location where to create the context
r3 - The size of the context
r4 - The address of the context function
*/
make_fcontext:
.machine "z10"
/* Align the stack to an 8 byte boundary. */
nill %r2,0xfff0
/* Allocate stack space for the context. */
aghi %r2,-CONTEXT_SIZE
/* Set the r2 save slot to zero. This indicates jump_fcontext
that this is a special context. */
mvghi GR_OFFSET(%r2),0
/* Save the floating point control register. */
stfpc FPC_OFFSET(%r2)
/* Store the address of the target function as new pc. */
stg %r4,PC_OFFSET(%r2)
/* Store a pointer to the finish routine as r14. If a function
called via context routines just returns that value will be
loaded and used as return address. Hence the program will
just exit. */
larl %r1,finish
stg %r1,R14_OFFSET(%r2)
/* Return as usual with the new context returned in r2. */
br %r14
finish:
/* In finish tasks, you load the exit code and exit the
make_fcontext This is called when the context-function is
entirely executed. */
lghi %r2,0
brasl %r14,_exit@PLT
.size make_fcontext,.-make_fcontext
.section .note.GNU-stack,"",%progbits
+163
View File
@@ -0,0 +1,163 @@
; Copyright Oliver Kowalke 2009.
; Distributed under the Boost Software License, Version 1.0.
; (See accompanying file LICENSE_1_0.txt or copy at
; http://www.boost.org/LICENSE_1_0.txt)
; ----------------------------------------------------------------------------------
; | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
; ----------------------------------------------------------------------------------
; | 0x0 | 0x4 | 0x8 | 0xc | 0x10 | 0x14 | 0x18 | 0x1c |
; ----------------------------------------------------------------------------------
; | SEE registers (XMM6-XMM15) |
; ----------------------------------------------------------------------------------
; ----------------------------------------------------------------------------------
; | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
; ----------------------------------------------------------------------------------
; | 0x20 | 0x24 | 0x28 | 0x2c | 0x30 | 0x34 | 0x38 | 0x3c |
; ----------------------------------------------------------------------------------
; | SEE registers (XMM6-XMM15) |
; ----------------------------------------------------------------------------------
; ----------------------------------------------------------------------------------
; | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 |
; ----------------------------------------------------------------------------------
; | 0xe40 | 0x44 | 0x48 | 0x4c | 0x50 | 0x54 | 0x58 | 0x5c |
; ----------------------------------------------------------------------------------
; | SEE registers (XMM6-XMM15) |
; ----------------------------------------------------------------------------------
; ----------------------------------------------------------------------------------
; | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 |
; ----------------------------------------------------------------------------------
; | 0x60 | 0x64 | 0x68 | 0x6c | 0x70 | 0x74 | 0x78 | 0x7c |
; ----------------------------------------------------------------------------------
; | SEE registers (XMM6-XMM15) |
; ----------------------------------------------------------------------------------
; ----------------------------------------------------------------------------------
; | 32 | 32 | 33 | 34 | 35 | 36 | 37 | 38 |
; ----------------------------------------------------------------------------------
; | 0x80 | 0x84 | 0x88 | 0x8c | 0x90 | 0x94 | 0x98 | 0x9c |
; ----------------------------------------------------------------------------------
; | SEE registers (XMM6-XMM15) |
; ----------------------------------------------------------------------------------
; ----------------------------------------------------------------------------------
; | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 |
; ----------------------------------------------------------------------------------
; | 0xa0 | 0xa4 | 0xa8 | 0xac | 0xb0 | 0xb4 | 0xb8 | 0xbc |
; ----------------------------------------------------------------------------------
; | fc_mxcsr|fc_x87_cw| <alignment> | fbr_strg | fc_dealloc |
; ----------------------------------------------------------------------------------
; ----------------------------------------------------------------------------------
; | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 |
; ----------------------------------------------------------------------------------
; | 0xc0 | 0xc4 | 0xc8 | 0xcc | 0xd0 | 0xd4 | 0xd8 | 0xdc |
; ----------------------------------------------------------------------------------
; | limit | base | R12 | R13 |
; ----------------------------------------------------------------------------------
; ----------------------------------------------------------------------------------
; | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 |
; ----------------------------------------------------------------------------------
; | 0xe0 | 0xe4 | 0xe8 | 0xec | 0xf0 | 0xf4 | 0xf8 | 0xfc |
; ----------------------------------------------------------------------------------
; | R14 | R15 | RDI | RSI |
; ----------------------------------------------------------------------------------
; ----------------------------------------------------------------------------------
; | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 |
; ----------------------------------------------------------------------------------
; | 0x100 | 0x104 | 0x108 | 0x10c | 0x110 | 0x114 | 0x118 | 0x11c |
; ----------------------------------------------------------------------------------
; | RBX | RBP | hidden | RIP |
; ----------------------------------------------------------------------------------
; ----------------------------------------------------------------------------------
; | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 |
; ----------------------------------------------------------------------------------
; | 0x120 | 0x124 | 0x128 | 0x12c | 0x130 | 0x134 | 0x138 | 0x13c |
; ----------------------------------------------------------------------------------
; | parameter area |
; ----------------------------------------------------------------------------------
; ----------------------------------------------------------------------------------
; | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 |
; ----------------------------------------------------------------------------------
; | 0x140 | 0x144 | 0x148 | 0x14c | 0x150 | 0x154 | 0x158 | 0x15c |
; ----------------------------------------------------------------------------------
; | FCTX | DATA | |
; ----------------------------------------------------------------------------------
; standard C library function
EXTERN _exit:PROC
.code
; generate function table entry in .pdata and unwind information in
make_fcontext PROC BOOST_CONTEXT_EXPORT FRAME
; .xdata for a function's structured exception handling unwind behavior
.endprolog
; first arg of make_fcontext() == top of context-stack
mov rax, rcx
; shift address in RAX to lower 16 byte boundary
; == pointer to fcontext_t and address of context stack
and rax, -16
; reserve space for context-data on context-stack
; on context-function entry: (RSP -0x8) % 16 == 0
sub rax, 0150h
; third arg of make_fcontext() == address of context-function
; stored in RBX
mov [rax+0100h], r8
; first arg of make_fcontext() == top of context-stack
; save top address of context stack as 'base'
mov [rax+0c8h], rcx
; second arg of make_fcontext() == size of context-stack
; negate stack size for LEA instruction (== substraction)
neg rdx
; compute bottom address of context stack (limit)
lea rcx, [rcx+rdx]
; save bottom address of context stack as 'limit'
mov [rax+0c0h], rcx
; save address of context stack limit as 'dealloction stack'
mov [rax+0b8h], rcx
; set fiber-storage to zero
xor rcx, rcx
mov [rax+0b0h], rcx
; save MMX control- and status-word
stmxcsr [rax+0a0h]
; save x87 control-word
fnstcw [rax+0a4h]
; compute address of transport_t
lea rcx, [rax+0140h]
; store address of transport_t in hidden field
mov [rax+0110h], rcx
; compute abs address of label trampoline
lea rcx, trampoline
; save address of trampoline as return-address for context-function
; will be entered after calling jump_fcontext() first time
mov [rax+0118h], rcx
; compute abs address of label finish
lea rcx, finish
; save address of finish as return-address for context-function in RBP
; will be entered after context-function returns
mov [rax+0108h], rcx
ret ; return pointer to context-data
trampoline:
; store return address on stack
; fix stack alignment
push rbp
; jump to context-function
jmp rbx
finish:
; exit code is zero
xor rcx, rcx
; exit application
call _exit
hlt
make_fcontext ENDP
END
+82
View File
@@ -0,0 +1,82 @@
/*
Copyright Oliver Kowalke 2009.
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
*/
/****************************************************************************************
* *
* ---------------------------------------------------------------------------------- *
* | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | *
* ---------------------------------------------------------------------------------- *
* | 0x0 | 0x4 | 0x8 | 0xc | 0x10 | 0x14 | 0x18 | 0x1c | *
* ---------------------------------------------------------------------------------- *
* | fc_mxcsr|fc_x87_cw| R12 | R13 | R14 | *
* ---------------------------------------------------------------------------------- *
* ---------------------------------------------------------------------------------- *
* | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | *
* ---------------------------------------------------------------------------------- *
* | 0x20 | 0x24 | 0x28 | 0x2c | 0x30 | 0x34 | 0x38 | 0x3c | *
* ---------------------------------------------------------------------------------- *
* | R15 | RBX | RBP | RIP | *
* ---------------------------------------------------------------------------------- *
* *
****************************************************************************************/
.file "make_x86_64_sysv_elf_gas.S"
.text
.globl make_fcontext
.type make_fcontext,@function
.align 16
make_fcontext:
/* first arg of make_fcontext() == top of context-stack */
movq %rdi, %rax
/* shift address in RAX to lower 16 byte boundary */
andq $-16, %rax
/* reserve space for context-data on context-stack */
/* on context-function entry: (RSP -0x8) % 16 == 0 */
leaq -0x40(%rax), %rax
/* third arg of make_fcontext() == address of context-function */
/* stored in RBX */
movq %rdx, 0x28(%rax)
/* save MMX control- and status-word */
stmxcsr (%rax)
/* save x87 control-word */
fnstcw 0x4(%rax)
/* compute abs address of label trampoline */
leaq trampoline(%rip), %rcx
/* save address of trampoline as return-address for context-function */
/* will be entered after calling jump_fcontext() first time */
movq %rcx, 0x38(%rax)
/* compute abs address of label finish */
leaq finish(%rip), %rcx
/* save address of finish as return-address for context-function */
/* will be entered after context-function returns */
movq %rcx, 0x30(%rax)
ret /* return pointer to context-data */
trampoline:
/* store return address on stack */
/* fix stack alignment */
push %rbp
/* jump to context-function */
jmp *%rbx
finish:
/* exit code is zero */
xorq %rdi, %rdi
/* exit application */
call _exit@PLT
hlt
.size make_fcontext,.-make_fcontext
/* Mark that we don't need executable stack. */
.section .note.GNU-stack,"",%progbits
+76
View File
@@ -0,0 +1,76 @@
/*
Copyright Oliver Kowalke 2009.
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
*/
/****************************************************************************************
* *
* ---------------------------------------------------------------------------------- *
* | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | *
* ---------------------------------------------------------------------------------- *
* | 0x0 | 0x4 | 0x8 | 0xc | 0x10 | 0x14 | 0x18 | 0x1c | *
* ---------------------------------------------------------------------------------- *
* | fc_mxcsr|fc_x87_cw| R12 | R13 | R14 | *
* ---------------------------------------------------------------------------------- *
* ---------------------------------------------------------------------------------- *
* | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | *
* ---------------------------------------------------------------------------------- *
* | 0x20 | 0x24 | 0x28 | 0x2c | 0x30 | 0x34 | 0x38 | 0x3c | *
* ---------------------------------------------------------------------------------- *
* | R15 | RBX | RBP | RIP | *
* ---------------------------------------------------------------------------------- *
* *
****************************************************************************************/
.text
.globl _make_fcontext
.align 8
_make_fcontext:
/* first arg of make_fcontext() == top of context-stack */
movq %rdi, %rax
/* shift address in RAX to lower 16 byte boundary */
andq $-16, %rax
/* reserve space for context-data on context-stack */
/* on context-function entry: (RSP -0x8) % 16 == 0 */
leaq -0x40(%rax), %rax
/* third arg of make_fcontext() == address of context-function */
/* stored in RBX */
movq %rdx, 0x28(%rax)
/* save MMX control- and status-word */
stmxcsr (%rax)
/* save x87 control-word */
fnstcw 0x4(%rax)
/* compute abs address of label trampoline */
leaq trampoline(%rip), %rcx
/* save address of trampoline as return-address for context-function */
/* will be entered after calling jump_fcontext() first time */
movq %rcx, 0x38(%rax)
/* compute abs address of label finish */
leaq finish(%rip), %rcx
/* save address of finish as return-address for context-function */
/* will be entered after context-function returns */
movq %rcx, 0x30(%rax)
ret /* return pointer to context-data */
trampoline:
/* store return address on stack */
/* fix stack alignment */
push %rbp
/* jump to context-function */
jmp *%rbx
finish:
/* exit code is zero */
xorq %rdi, %rdi
/* exit application */
call __exit
hlt
+33
View File
@@ -0,0 +1,33 @@
--TEST--
static variables in methods inherited from parent class
--FILE--
<?php
class C {
function foo ($y = null) {
static $x = null;
if (!is_null($y)) {
$x = [$y];
}
return $x;
}
}
$c = new C();
$c->foo(42);
$d = new class extends C {};
var_dump($d->foo());
var_dump($d->foo(24));
var_dump($c->foo());
?>
--EXPECT--
array(1) {
[0]=>
int(42)
}
array(1) {
[0]=>
int(24)
}
array(1) {
[0]=>
int(24)
}
+34
View File
@@ -0,0 +1,34 @@
--TEST--
static variables in methods inherited from parent class (can't cache objects)
--FILE--
<?php
class C {
function foo ($y = null) {
static $x = null;
if (!is_null($y)) {
$x = [$y];
}
return $x;
}
}
$c = new C();
$c->foo(new stdClass);
$d = new class extends C {};
var_dump($d->foo());
var_dump($d->foo(24));
var_dump($c->foo());
?>
--EXPECT--
array(1) {
[0]=>
object(stdClass)#2 (0) {
}
}
array(1) {
[0]=>
int(24)
}
array(1) {
[0]=>
int(24)
}
+1
View File
@@ -23,6 +23,7 @@ function skipFunction($function): bool {
|| $function === 'mail'
|| $function === 'mb_send_mail'
|| $function === 'pcntl_fork'
|| $function === 'pcntl_rfork'
|| $function === 'posix_kill'
|| $function === 'posix_setrlimit'
|| $function === 'sapi_windows_generate_ctrl_event'
+4
View File
@@ -13,9 +13,13 @@ echo "Done\n";
--EXPECTF--
Warning: Undefined array key -1 in %s on line %d
Deprecated: Implicit conversion from non-compatible float -1.1 to int in %s on line %d
Warning: Undefined array key -1 in %s on line %d
Warning: Undefined array key -1 in %s on line %d
Deprecated: Implicit conversion from non-compatible float -1.1 to int in %s on line %d
Warning: Undefined array key -1 in %s on line %d
Done
-1
View File
@@ -2,7 +2,6 @@
Add $GLOBALS to itself
--FILE--
<?php
$GLOBALS += $GLOBALS;
$x = $GLOBALS + $GLOBALS;
?>
===DONE===
@@ -1,5 +1,5 @@
--TEST--
Array unpacking does not work with non-integer keys
Array unpacking does not work with non-integer/string keys
--FILE--
<?php
function gen() {
@@ -15,4 +15,4 @@ try {
?>
--EXPECT--
Exception: Cannot unpack Traversable with non-integer keys
Exception: Keys must be of type int|string during array unpacking
+50 -14
View File
@@ -1,22 +1,58 @@
--TEST--
array unpacking with string keys (not supported)
Array unpacking with string keys
--FILE--
<?php
try {
$array = [1, 2, "foo" => 3, 4];
var_dump([...$array]);
} catch (Error $ex) {
var_dump($ex->getMessage());
}
try {
$iterator = new ArrayIterator([1, 2, "foo" => 3, 4]);
var_dump([...$iterator]);
} catch (Error $ex) {
var_dump($ex->getMessage());
// Works with both arrays and Traversables.
$array = [1, 2, "foo" => 3, 4];
var_dump([...$array]);
$iterator = new ArrayIterator([1, 2, "foo" => 3, 4]);
var_dump([...$iterator]);
// Test overwriting behavior.
$array1 = ["foo" => 1];
$array2 = ["foo" => 2];
var_dump(["foo" => 0, ...$array1, ...$array2]);
var_dump(["foo" => 0, ...$array1, ...$array2, "foo" => 3]);
// Test numeric string key from iterator.
function gen() {
yield "42" => 42;
}
var_dump([...gen()]);
?>
--EXPECT--
string(36) "Cannot unpack array with string keys"
string(42) "Cannot unpack Traversable with string keys"
array(4) {
[0]=>
int(1)
[1]=>
int(2)
["foo"]=>
int(3)
[2]=>
int(4)
}
array(4) {
[0]=>
int(1)
[1]=>
int(2)
["foo"]=>
int(3)
[2]=>
int(4)
}
array(1) {
["foo"]=>
int(2)
}
array(1) {
["foo"]=>
int(3)
}
array(1) {
[0]=>
int(42)
}
@@ -1,10 +1,23 @@
--TEST--
Unpacking of string keys detected at compile-time
Unpacking of string keys is supported at compile-time
--FILE--
<?php
var_dump([...['a' => 'b']]);
var_dump(['a' => 'X', ...['a' => 'b']]);
var_dump([...['a' => 'b'], 'a' => 'X']);
?>
--EXPECTF--
Fatal error: Cannot unpack array with string keys in %s on line %d
--EXPECT--
array(1) {
["a"]=>
string(1) "b"
}
array(1) {
["a"]=>
string(1) "b"
}
array(1) {
["a"]=>
string(1) "X"
}
@@ -12,12 +12,14 @@ foreach ($attributes as $attribute) {
$a = $attribute->newInstance();
var_dump(get_class($a));
var_dump($a->flags == Attribute::TARGET_ALL);
var_dump($a->flags == Attribute::TARGET_CLASS);
}
?>
--EXPECT--
string(9) "Attribute"
array(0) {
array(1) {
[0]=>
int(1)
}
string(9) "Attribute"
bool(true)
@@ -2,8 +2,8 @@
Attribute validation callback of internal attributes.
--SKIPIF--
<?php
if (!extension_loaded('zend-test')) {
echo "skip requires zend-test extension\n";
if (!extension_loaded('zend_test')) {
echo "skip requires zend_test extension\n";
}
--FILE--
<?php
+2 -2
View File
@@ -19,8 +19,8 @@ class Test {}
?>
--EXPECTF--
#0 MyAttribute->__construct() called at [%s031_backtrace.php:12]
#1 ReflectionAttribute->newInstance() called at [%s:%d]
#0 %s031_backtrace.php(12): MyAttribute->__construct()
#1 %s(%d): ReflectionAttribute->newInstance()
array(2) {
[0]=>
array(7) {
+1 -1
View File
@@ -3,7 +3,7 @@ Bug #21478 (Zend/zend_alloc.c :: shutdown_memory_manager produces segfault)
--FILE--
<?php
class debugfilter extends php_user_filter {
function filter($in, $out, &$consumed, $closing) {
function filter($in, $out, &$consumed, $closing): int {
while ($bucket = stream_bucket_make_writeable($in)) {
$bucket->data = strtoupper($bucket->data);
stream_bucket_append($out, $bucket);
+2 -2
View File
@@ -57,12 +57,12 @@ array(3) {
}
Child::__construct
array(3) {
["Baz"]=>
int(4)
["Foo"]=>
int(1)
["Bar"]=>
int(2)
["Baz"]=>
int(4)
}
array(1) {
["Foo"]=>
+3 -3
View File
@@ -22,6 +22,6 @@ function GenerateError2($A1)
GenerateError2("Test2");
?>
--EXPECTF--
#0 userErrorHandler(2, Undefined variable $b, %s, %d) called at [%s:%d]
#1 GenerateError1(Test1) called at [%sbug29896.php:16]
#2 GenerateError2(Test2) called at [%sbug29896.php:19]
#0 %s(%d): userErrorHandler(2, 'Undefined varia...', '%s', %d)
#1 %s(%d): GenerateError1('Test1')
#2 %s(%d): GenerateError2('Test2')
Loaded 100 of 5888 files, more files were not shown because too many files have changed in this diff. Show more