1
0
mirror of https://github.com/php/php-src.git synced 2026-04-25 08:58:28 +02:00
Commit Graph

4273 Commits

Author SHA1 Message Date
George Peter Banyard 069a9fa5e4 Pure Intersection types (#6799)
Implement pure intersection types RFC

RFC: https://wiki.php.net/rfc/pure-intersection-types

Co-authored-by: Nikita Popov <nikic@php.net>
Co-authored-by: Ilija Tovilo <ilutov@php.net>
2021-07-05 14:11:03 +02:00
Christoph M. Becker 9a42d2b87b Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix build
2021-07-04 23:15:14 +02:00
Christoph M. Becker d86c25d88e Fix build
`accel_system_id` gas been renamed to `zend_system_id`.
2021-07-04 23:13:50 +02:00
Christoph M. Becker b09134139e Merge branch 'PHP-8.0'
* PHP-8.0:
  Avoid OOB reads in create_name_with_username()
2021-07-04 22:56:37 +02:00
Christoph M. Becker 948b83d7ea Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Avoid OOB reads in create_name_with_username()
2021-07-04 22:54:48 +02:00
Christoph M. Becker b1840737e2 Avoid OOB reads in create_name_with_username()
`accel_uname_id` and `zend_system_id` are MD5 buffers which are not
NUL terminated.  Thus, we must not pass them to `snprintf()`.

Closes GH-6968.
2021-07-04 22:51:55 +02:00
Dmitry Stogov 4743c7a16f JIT/ARM64: Fixed incorrect trace linking. 2021-07-01 23:17:31 +03:00
Dmitry Stogov ff983131e7 JIT/ARM64: Fixed possible incorrect exception catching in function JIT. 2021-06-30 18:18:30 +03:00
Dmitry Stogov ef0d916d8f Merge branch 'PHP-8.0'
* PHP-8.0:
  JIT/x86: Fixed possible incorrect exception catching in function JIT.
2021-06-30 18:17:23 +03:00
Dmitry Stogov 99c0efc77a JIT/x86: Fixed possible incorrect exception catching in function JIT. 2021-06-30 18:16:38 +03:00
Patrick Allaert aff365871a Fixed some spaces used instead of tabs 2021-06-29 11:30:26 +02:00
Ganesh Kandu 6157fcc010 Fix typedef redefinition warnings.
Closes GH-7197.
2021-06-28 10:11:43 +02:00
Nikita Popov 0e932f7cea Don't directly include zend_jit_gdb.c
Compile the file separately and only include a header. There doesn't
seem to be a good reason to directly include the C file here, and
this ensures that there are no symbol clashes (see GH-7197).
2021-06-28 10:08:45 +02:00
Dmitry Stogov 973ae8d3e2 Move the whole "cold" path into the "cold" function. 2021-06-23 14:55:58 +03:00
Hao Sun 3e164dee99 JIT/AArch64: Support shifted immediate (#7165)
* JIT/AArch64: Support shifted immediate

As pointed out by MikePall in [1], shifted immediate value is supported.
See [2]. For example, `add x0, x1, #4096` would be encoded by DynASM
into `add x0, x1, #1, lsl #12` directly.

In this patch, a helper is added to check whether an immediate value is
in the two allowed ranges: (1) 0 to 4095, and (2) LSL #12 on all the
values from the first range.

Note that this helper works for add/adds/sub/subs/cmp/cmn instructions.

[1] https://github.com/LuaJIT/LuaJIT/pull/718
[2]
https://github.com/LuaJIT/LuaJIT/blob/v2.1/dynasm/dasm_arm64.lua#L342

Change-Id: I4870048b9b8e6c429b73a4803af2a3b2d5ec0fbb

* Deprecatd CMP_IMM/ADD_SUB_IMM and add test cases

Macros CMP_IMM and ADD_SUB_IMM are deprecated and instead we use
this helper to guard the immediate encoding.

Add two 64-bit only test cases, since 64-bit integers are used
and tested inside.

Change-Id: I0b42d4617b40372e2f4ce5b6ad31a4ddb7d89e49
2021-06-23 17:18:03 +08:00
Nikita Popov a30fab57eb Make can_elide_return_type_check() more robust
Rather than using def_info, check against the actual arg_info type.
As it is stored as a type mask nowadays, this is not much harder,
but more general and more robust as we don't need to deal with
inaccurate cases.
2021-06-18 11:17:32 +02:00
Dmitry Stogov d72c320ff6 JIT/ARM64: Fixed possible incorrect register allocation 2021-06-17 18:43:15 +03:00
Dmitry Stogov c02d7c4de8 Merge branch 'PHP-8.0'
* PHP-8.0:
  JIT/x86: Fixed possible incorrect register allocation
2021-06-17 18:42:57 +03:00
Dmitry Stogov ced8e88438 JIT/x86: Fixed possible incorrect register allocation 2021-06-17 18:42:11 +03:00
Dmitry Stogov 82bcc9b497 JIT/ARM64: Fixed "may be used uninitialized" compilation warning 2021-06-17 15:08:14 +03:00
Dmitry Stogov 6442cbfbc4 Merge branch 'PHP-8.0'
* PHP-8.0:
  JIT: Fixed failures of tracing JIT with CALL VM
2021-06-17 14:26:36 +03:00
Dmitry Stogov 1082669e24 JIT: Fixed failures of tracing JIT with CALL VM
This fixes:
- tests/lang/bug28800.phpt
- Zend/tests/settype_resource.phpt
- Zend/tests/type_declarations/scalar_return_basic_64bit.phpt
2021-06-17 14:21:40 +03:00
Dmitry Stogov cc0aac3f73 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed incorrect type inference for "(array)$null".
2021-06-17 13:05:45 +03:00
Dmitry Stogov df16fd149b Fixed incorrect type inference for "(array)$null". 2021-06-17 13:03:09 +03:00
Dmitry Stogov 3a78259525 JIT: Avoid too aggressive loop unrolling
This fixes tests/func/010.phpt failure with tracing JIT on ARM64.
2021-06-16 16:44:27 +03:00
Nikita Popov 591dcdbdb0 Use different error condition in ACCEL_LOG_FATAL test
This test fails on s390x with opcache. Presumably the large allocation
works fine there as long as it's not used.

Switch to a different error condition that produces a more reliable
failure.
2021-06-16 13:08:54 +02:00
Dmitry Stogov 8ae06582c6 Fixed incorrect map_ptr slots counting 2021-06-16 11:33:43 +03:00
Nikita Popov 7485978339 Migrate SKIPIF -> EXTENSIONS (#7138)
This is an automated migration of most SKIPIF extension_loaded checks.
2021-06-11 11:57:42 +02:00
Dmitry Stogov bd98d84e57 Reorder conditions and always mark methods in SHM as ZEND_ACC_IMMUTABLE 2021-06-10 22:19:37 +03:00
Dmitry Stogov b0dcc4c060 Functions with static variables are not separated anymore.
9a1da9f61f missed this part.
2021-06-10 20:57:43 +03:00
Nikita Popov 67cf04f791 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Mitigation for bug #81096
2021-06-10 10:54:21 +02:00
Nikita Popov 3f4bc94b00 Mitigation for bug #81096
This issue is properly fixed by GH-7121 on master. For older
branches, disable the use of range information in SCCP, to
reduce impact of potentially incorrect ranges.
2021-06-10 10:52:53 +02:00
Dmitry Stogov 7368d0c418 Fixed bug #81096: Inconsistent range inferece for variables passed by reference
Detect references before range inference and exclude them from range
inference.
2021-06-10 11:43:15 +03:00
sy-records 9333a22fa4 Fix typo 2021-06-10 10:24:41 +02:00
Dmitry Stogov 539948924c Typo 2021-06-09 17:50:16 +03:00
Dmitry Stogov cd90655ebc JIT/ARM64: Remove redundand x86 specific optimization for recursive calls
On ARM64 we always load "func" into REG0
2021-06-09 16:55:51 +03:00
Dmitry Stogov af319b072a JIT/ARM64: Improve JIT for MOD instruction.
Eliminate x86 specific register constrints (idiv imlicitly used
%eax and %rdx). On ARM64 we use reserved TMP registers.
2021-06-09 15:17:51 +03:00
Dmitry Stogov 62e0b83204 JIT/x86: Reuse code when MOD is going to be converted to AND. 2021-06-09 15:15:06 +03:00
Dmitry Stogov 3fa0c99a1b JIT/AArch64: Use only reserved TMP registers for EG(vm_interrupt) checks.
This removes limitation of REG0 usage for register-allocation.
2021-06-09 12:43:13 +03:00
Dmitry Stogov 029d06992e JIT/AArch64: Use only reserved TMP registers for EG(jit_trace_num) assignment.
This eliminates a need for checking CPU registers used at the entry to a
side trace.
2021-06-09 12:02:11 +03:00
Hao Sun ac80aeb3ac JIT/AArch64: Use 'tbnz/tbz' to check the signedness (#7123)
'tbnz/tbz' instruction can be used to check whether a given W or X
register value is negative or positive.

For example,
    ```
    tst x0, x0
    blt >1
    ```
can be optimized as `tbnz x0, #63, >1`

It's important to note that the jump range of 'tbnz/tbz' is limited, and
it's better NOT to use 'tbnz/tbz' if the target of 'b.cond' is a label
in section .cold_code or a global label, such as the instruction
sequence `tst RETVALw, RETVALw; blt ->trace_halt` at function
zend_jit_trace_exit_stub(), and the instruction sequence `tst REG0,
  REG0; blt >7` at function zend_jit_incdec_obj().

Minor updates:
Use macros BW_OP_32_WITH_CONST and GC_ADDREF at function
zend_jit_push_call_frame().

Change-Id: I1597609bdabf55ea2f9d24528e7a037bc3e5c3a1
2021-06-09 16:30:25 +08:00
Hao Sun c1bf4b3ed3 JIT/AArch64: Fix codestyle issues (#7125)
Fix codestyle issues, such as aligning comments, changing whitespace to
tab, adding necessary whitespace.

Change-Id: I0c6ae1e5d87a0f6832bc776294558d48a9b5d420
2021-06-09 14:57:09 +08:00
Ayesh Karunaratne b8e380ab09 Update deprecation message for incompatible float to int conversion
Updates the deprecation message for implicit incompatible float to int conversion from:

```
Implicit conversion from non-compatible float %.*H to int in %s on line %d
```

to

```
Implicit conversion from float %.*H to int loses precision in %s on line %d
```

Related: #6661
2021-06-07 14:36:11 +02:00
Dmitry Stogov 9c7797eb09 JIT/AArch64: Complete logical_immediate_p() using DynAsm helpers 2021-06-07 12:22:58 +03:00
Dmitry Stogov 4e0165e779 JIT/AArch64: Use LSL instruction (DynAsm was fixed by
2963214c15)
2021-06-07 11:24:34 +03:00
Hao Sun c995a359ff JIT/AArch64: Use 'shifted register' if available (#7108)
One shift instruction can be saved if 'shifted register' is used.

It's worth noting that the destination register of previous shift
instruction doesn't hold the shift result any longer now. And we have to
guarantee that 'shifted register' mode is applied to all the use sites
of this destination register.

Besides, several code-style issues are fixed.

Change-Id: I8bcdd092253d342d383732a926512e761e453808
2021-06-07 15:52:03 +08:00
Hao Sun 28b4f58d3b JIT/AArch64: Optimize add+ldr to ldr (#7109)
This patch is trivial.

Change-Id: I51b8eb5f12446643a53cc569d9398d0941a2f588
2021-06-07 15:51:34 +08:00
Mike Pall 2963214c15 DynASM/ARM64: Fix LSL/BFI* encoding with variable shifts. 2021-06-07 09:36:50 +03:00
Hao Sun d1e5b0e699 JIT/AArch64: [macos] Remove Clang warning due to -Wincompatible-pointer-types (#7098)
The following warning message would be produced for macOS on Apple
silicon.

```
php-src/ext/opcache/jit/zend_jit_arm64.dasc:15356:79: warning: incompatible pointer types passing 'ptrdiff_t *' (aka 'long *') to parameter of type 'int64_t *'
      (aka 'long long *') [-Wincompatible-pointer-types]
                        const char *name = zend_jit_disasm_find_symbol((ptrdiff_t)cp + offset - 4, &offset);
                                                                                                   ^~~~~~~
ext/opcache/jit/zend_jit_disasm.c:210:58: note: passing argument to parameter 'offset' here
                                               int64_t  *offset) {

                                                  ^
```

Flag -Wincompatible-pointer-types is enabled by default in Clang [1],
but not in GCC [2].

Adding explicit type conversion would remove this warning.

[1]
https://releases.llvm.org/10.0.0/tools/clang/docs/DiagnosticsReference.html#wincompatible-pointer-types
[2]
https://gcc.gnu.org/onlinedocs/gcc-9.1.0/gcc/Warning-Options.html#Warning-Options

Change-Id: Ia0777a5731ba8f0764e232c0d47aeaab076d13f5
2021-06-04 16:40:49 +08:00
Dmitry Stogov b15a8e6cde JIT/AArch64: Improved code generation for SL/SR and register allocation (#7096)
- perform constant shift by single instruction
  TODO: DynAsm: can't encode "lsl x0, x0, #var" !!!
- avoid usage of REG1 for variable shift (it was x86 limitation)
- enable register reuse for SL/SR instructions
- remove special scratch register handling for SL/SR (it was x86
  limitation)
- Remove need for extra scratch registers. AArch64 JIT backend
  don't use extra register for constants. It uses reserved TMP
  registers.
2021-06-04 09:32:23 +03:00