Commit Graph

318 Commits

Author SHA1 Message Date
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
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
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
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
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
Dmitry Stogov
8ad2b59e12 Disable stack reuse optimization for x86 PIC code. It may clobber local variable used for Global Offset Table. 2020-12-01 15:20:06 +03:00
Dmitry Stogov
841b00f641 Preallocate stack space for JIT in execute_ex() to eliminate JIT prologue/epilogue. 2020-11-30 17:56:08 +03:00
Sammy Kaye Powers
58d41b8c4f Provide unused retvals to observers
Make sure that the return value is available to observers, even if
it is not used by the caller.

Closes GH-6422.
2020-11-17 10:28:47 +01:00
Dmitry Stogov
855d8fa68f [Observer] Save opline before calling begin/end handlers 2020-11-11 13:06:55 +03:00
Dmitry Stogov
d5d31ea3b3 Cleanup observer API and add JIT support 2020-09-18 12:55:58 +03:00
Sammy Kaye Powers
9e94bcfdbc Remove specialization of SPEC(OBSERVER) handlers 2020-09-18 00:47:36 +03:00
Levi Morrison
66c3e900e2 Add zend_observer API
Closes GH-5857.

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
Co-authored-by: Sammy Powers <sammyk@datadoghq.com>
2020-09-01 09:59:59 -06:00
Nikita Popov
42eda5160d SAVE_OPLINE in NULL_HANDLER
Let's avoid crashing before the nice error message gets printed...
2020-08-11 15:14:50 +02:00
Nikita Popov
d92229d8c7 Implement named parameters
From an engine perspective, named parameters mainly add three
concepts:

 * The SEND_* opcodes now accept a CONST op2, which is the
   argument name. For now, it is looked up by linear scan and
   runtime cached.
 * This may leave UNDEF arguments on the stack. To avoid having
   to deal with them in other places, a CHECK_UNDEF_ARGS opcode
   is used to either replace them with defaults, or error.
 * For variadic functions, EX(extra_named_params) are collected
   and need to be freed based on ZEND_CALL_HAS_EXTRA_NAMED_PARAMS.

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

Closes GH-5357.
2020-07-31 15:53:36 +02:00
Nikita Popov
613a56d1cb Remove FREE_UNFETCHED concept
In master normal FREE_OPs work like FREE_UNFETCHED_OP used to, so
there is no point in keeping this distinction anymore, it's just
confusing.
2020-07-09 11:58:33 +02:00
Nikita Popov
5d0687e895 Assert exception set in HANDLE_EXCEPTION()
Some code paths were checking this manually, but we can turn this
into a general assertion to avoid surprises (functions returning
failure without throwing).
2020-07-07 11:31:05 +02:00
Nikita Popov
fb91611276 Remove #undefs from vm_gen
Possibly these were needed for VM_EXPORT, but they don't serve a
purpose now.
2020-07-07 11:25:28 +02:00
Nikita Popov
002c264d07 Remove ZEND_VM_EXPORT functionality
This hasn't been used since forever and makes things more confusing
than they already are.
2020-07-07 11:23:28 +02:00
Ayesh Karunaratne
d114812faf [ci skip] Various typo fixes in stub comments and CHANGES file 2020-06-25 23:32:40 +02:00
Dmitry Stogov
f4b46314f6 Prevent CGG reordering if hanlers order is defined by zend_vm_order.txt 2020-05-22 12:37:35 +03:00
Nikita Popov
d4de3f95d6 Remove spurious const qualifier from function return type 2020-02-06 11:59:52 +01:00
Nikita Popov
169805777c Merge branch 'PHP-7.4'
* PHP-7.4:
  Apply tidy formatting
2020-02-03 13:42:08 +01:00
Nikita Popov
58b17906f5 Apply tidy formatting
Mostly reindent PHP scripts to spaces.
2020-02-03 13:41:31 +01:00
Tyson Andre
a7580899f3 Support the same handler for multiple opcodes 2019-11-15 17:37:01 +03:00
Tyson Andre
e8525c2f68 Optimize int === int/double === double
Do this by reusing the implementation used for `==`
when both arguments are ints (IS_LONG) or both are floats (IS_DOUBLE)

```php
// Before: nestedloop_ni took 0.442 seconds
// After: nestedloop_ni takes 0.401 seconds (same as nestedloop_ne)
function nestedloop_ni(int $k) {
  $x = 0;
  for ($i=0; $i < 50000000; $i++) {
    if ($i === $k) {
      $x++;
    }
  }
  print "$x\n";
}
function nestedloop_ne(int $k) {
  $x = 0;
  for ($i=0; $i < 50000000; $i++) {
    if ($i == $k) {
        $x++;
    }
  }
  print "$x\n";
}
```
2019-11-15 17:37:01 +03:00
Dmitry Stogov
f6f32f2cf0 SAMRT BRANCH improvement.
Avoid need of insertion NOP opcoes between unrelated SMART BRANCH instruction and following JMPZ/JMPNZ.
Now instead of checking the opcode of following instruction, the same information is encoded into SMART BRANH result_type.
2019-10-09 13:48:39 +03:00
Dmitry Stogov
eec04f6b56 Encapsulate all SMART BRANCH related logic inside macros. Result of SMART BRANCH may be uninitialized (on exception). 2019-10-08 16:37:21 +03:00
Nikita Popov
a66c60cce3 Throw Error when writing property of non-object
This removes object auto-vivification support.

This also means that we can remove the corresponding special
handling for typed properites: We no longer need to check that a
property is convertible to stdClass if such a conversion might
take place indirectly due to a nested property write.

Additionally OBJ_W style operations now no longer modify the
object operand, and as such we no longer need to treat op1 as a
def in SSA form.

The next step would be to actually compile the whole LHS of OBJ_W
operations in R rather than W mode, but that causes issues with
SimpleXML, whose object handlers depend on the current compilation
structure.

Part of https://wiki.php.net/rfc/engine_warnings.
2019-09-27 10:11:47 +02:00
Dmitry Stogov
470bbb8c70 Avoid code dupliction 2019-09-26 01:40:30 +03:00
Dmitry Stogov
02c83b809a ceanup 2019-09-10 15:12:42 +03:00
Dmitry Stogov
0f8bb9e37d Merge branch 'PHP-7.4'
* PHP-7.4:
  Remove HOT attribute from some VM handlers. Comparisons almost always followed by JMPZ/JMPNZ; JMPZNZ is rare used.
  Remove --with-zlib-dir option from mysqlnd config
2019-09-05 11:43:13 +03:00
Dmitry Stogov
7237da27fe Remove HOT attribute from some VM handlers. Comparisons almost always followed by JMPZ/JMPNZ; JMPZNZ is rare used. 2019-09-05 11:40:15 +03:00
Dmitry Stogov
57d9b94dea Simplify TMP/VAR operand releasing 2019-07-24 14:13:40 +03:00
Nikita Popov
9e4603f772 Try to fix macos build
By avoiding unused variable opline warnings. Also clean up the
replacement of ZEND_VM_SPEC -- we were sometimes treating it as
an always-defined constant with a value (what it actually is) and
sometimes as a conditionally defined constant (which it isn't, but
which still worked thanks to the specializer). Switch to only
treating it as a constant with a value.
2019-07-24 09:44:55 +02:00
Dmitry Stogov
8d51af9bc2 Fixed CALL VM 2019-07-24 01:52:05 +03:00
Dmitry Stogov
b30e4a5aa6 Avoid extra specialization for cold opcodes 2019-07-17 14:03:48 +03:00
Dmitry Stogov
6fbab09ef0 Remove old hack 2019-07-17 12:05:23 +03:00
Dmitry Stogov
349a388b90 Slit INC/DEC opcodes into hot/cold parts and remove specialized versioins for LONG_OR_DOUBLE. 2019-07-16 17:39:25 +03:00
Dmitry Stogov
2e26b063b6 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fixed incorrect specialization (missed IS_INDIRECT handling)
2019-07-16 01:54:22 +03:00
Dmitry Stogov
c570980175 Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  Fixed incorrect specialization (missed IS_INDIRECT handling)
2019-07-16 01:52:11 +03:00
Dmitry Stogov
9ccf3fb996 Fixed incorrect specialization (missed IS_INDIRECT handling) 2019-07-16 01:50:10 +03:00
Dmitry Stogov
350f2212ff Allow GOTO style helpers in HYBRID VM 2019-07-12 00:00:55 +03:00
Dmitry Stogov
ef1a1a0698 Separate "cold" parts of comparison instructions 2019-07-11 20:44:39 +03:00
Dmitry Stogov
be94c0c3c6 Separate "cold" parts of binary op instructions 2019-07-11 18:23:08 +03:00
Dmitry Stogov
8f0c87e1b6 Avoid unintended inlining 2019-07-09 14:01:48 +03:00
Dmitry Stogov
e1f418dd18 Remove duplicated code for (PRE|POST)_DEC_(OBJ|STATIC_PROP) opcodes 2019-07-09 10:46:04 +03:00
Dmitry Stogov
1804fd634e Fixed dispatch from inlined hybrid opcode to another opcode 2019-07-08 18:01:46 +03:00
Dmitry Stogov
48ca5a1e17 Replace ZEND_ASSIGN_ADD (and others) by ZEND_ASSIGN_OP, ZEND_ASSIGN_DIM_OP, ZEND_ASSGIN_OBJ_OP and ZEND_ASSIGN_STATIC_PROP_OP 2019-07-05 12:03:25 +03:00