Commit Graph

2078 Commits

Author SHA1 Message Date
Bob Weinand
4f077aee83 Allow for [] = $array; (alias for list()) 2016-05-20 01:51:05 +02:00
Dmitry Stogov
be071702b3 Fixed bug #72188 (Nested try/finally blocks losing return value) 2016-05-13 14:38:43 +03:00
Dmitry Stogov
ccf18da450 Eliminated checks for (func->op_array.fn_flags & ZEND_ACC_GENERATOR) in fast path of DO_FCALL* handlers.
This slightly improves calls to regular function and method calls in cost of a bit slower generator initialization.
Separate call frame for generators, allocated on heap, now created by ZEND_GENERATOR_CREATE instruction.
2016-05-13 01:40:15 +03:00
Dmitry Stogov
7b94b958cc Intern some known (and offten used) strings. 2016-05-12 13:47:22 +03:00
Dmitry Stogov
c19cb70dac Revert "Refactor zval cleanup into single function"
This reverts commit bac6fdb0c5.
2016-05-06 10:47:58 +03:00
Bob Weinand
bac6fdb0c5 Refactor zval cleanup into single function
Also use zval_ptr_dtor_nogc() everywhere in Zend in favor of zval_dtor()
2016-05-05 23:31:57 +02:00
Levi Morrison
9662259cb9 Add nullable parameter types
This works off of Dmitry's commit for nullable return types
2016-05-05 11:53:32 -06:00
Dmitry Stogov
49fe737e58 Implement nullable return types. 2016-05-05 09:34:16 -06:00
Nikita Popov
bfef17ab65 Merge branch 'PHP-7.0'
Conflicts:
	Zend/zend_compile.c
2016-05-04 18:43:55 +02:00
Nikita Popov
9af0c96af4 Fix bug #72159 2016-05-04 18:43:11 +02:00
Joe Watkins
dc78e02ad2 Merge branch 'PHP-7.0'
* PHP-7.0:
  add compiler option to disable builtins (special case function calls)
2016-05-04 10:54:29 +01:00
Joe Watkins
9bbee305e3 add compiler option to disable builtins (special case function calls) 2016-05-04 10:53:59 +01:00
Pierrick Charron
0aed2cc2a4 Allow catching multiple exception types in a single catch statement
This commit add the possibility to catch multiple exception types in
a single catch statement to avoid code duplication.

try {
	   // Some code...
} catch (ExceptionType1 | ExceptionType2 $e) {
	   // Code to handle the exception
} catch (\Exception $e) {
	   // ...
}
2016-05-01 18:47:08 -04:00
Nikita Popov
6a9a0f2090 Merge branch 'PHP-7.0' 2016-05-01 13:05:28 +02:00
Nikita Popov
d0069ca6c1 Fix ('\bar')() in namespace 2016-05-01 13:05:14 +02:00
Dmitry Stogov
2578d08033 Fixed compilation warnings 2016-04-29 14:44:56 +03:00
Nikita Popov
4f54c15cb1 Ct bind private/final $this method call args
The test covers two edge-cases wrt opcache support.
2016-04-27 17:10:44 +02:00
Bob Weinand
261eb5cc89 Merge branch 'PHP-7.0' 2016-04-21 21:51:50 +02:00
Bob Weinand
69efeb1223 Fix constant expr coaleasce with protected mode opcache 2016-04-21 21:51:00 +02:00
Bob Weinand
ecf6392243 Merge remote-tracking branch 'origin/PHP-7.0' 2016-04-21 02:50:14 +02:00
Bob Weinand
a287c3f776 Fix magic constants (__LINE__) with ?? for constant scalar exprs
Also fix general memory leak when root ast gets replaced in compile time evaluation
2016-04-21 02:45:09 +02:00
Bob Weinand
36202ef056 Merge remote-tracking branch 'origin/PHP-7.0' 2016-04-21 01:26:48 +02:00
Márcio Almada
9f3eab44df allow null coalescing (??) on constant expressions 2016-04-21 01:22:28 +02:00
Adam Harvey
c4f69b6dfd Fix ZTS builds by adding a missing TSRMLS_FETCH(). 2016-04-20 18:58:29 +02:00
Nikita Popov
c9d8dfed60 Merge branch 'PHP-7.0' 2016-04-20 18:43:43 +02:00
Nikita Popov
77bb96d7c9 Fix bug #71737
Also improve the error message for $this used in parameters.
2016-04-20 18:38:40 +02:00
Dmitry Stogov
ffc697ac27 Prevent usage in GC after free. 2016-04-19 01:31:49 +03:00
Nikita Popov
ea1f30057b Fully initialize DECLARE_CLASS/FUNCTION opcodes 2016-04-18 22:46:45 +02:00
Dmitry Stogov
b73517c1a1 Use DO_FCALL_BY_NAME instead of DO_FCALL, if possible 2016-04-14 16:07:28 +03:00
Dmitry Stogov
3444c1ae24 Use return type hints for type inference and eliminate useless VERIFY_RETRUN_TYPE opcodes. 2016-04-07 17:34:53 +03:00
Joe Watkins
14e4c610e9 Fix #69537: __debugInfo with empty string for key gives error 2016-04-03 12:40:29 +01:00
Joe Watkins
bff13d90a8 Merge branch 'PHP-7.0'
* PHP-7.0:
  fix #69537: __debugInfo with empty string for key gives error
2016-04-03 12:38:53 +01:00
Joe Watkins
91c10662c8 fix #69537: __debugInfo with empty string for key gives error 2016-04-03 12:38:25 +01:00
Andrea Faulds
1e82ad8038 Warn about invalid strings in arithmetic
Squashed commit of the following:

commit e05d3b6732
Author: Andrea Faulds <ajf@ajf.me>
Date:   Wed Mar 30 01:43:35 2016 +0100

    UPGRADING and NEWS

commit 6caf1d4585
Author: Andrea Faulds <ajf@ajf.me>
Date:   Sun Mar 20 21:18:33 2016 +0000

    Fixes

commit 6dadb1b0ef
Author: Andrea Faulds <ajf@ajf.me>
Date:   Sun Feb 14 02:15:01 2016 +0000

    Add test for numeric string errors in assignment

commit bd5f04e8dd
Author: Andrea Faulds <ajf@ajf.me>
Date:   Sat Feb 13 23:53:05 2016 +0000

    Add test for numeric string errors

commit c72e92f16d
Author: Andrea Faulds <ajf@ajf.me>
Date:   Tue Jan 26 23:28:33 2016 +0000

    Add test for scientific notation in integer operations

commit d94c08852d
Author: Andrea Faulds <ajf@ajf.me>
Date:   Sun Feb 14 01:25:57 2016 +0000

    Disable optimiser evaluation for numeric string errors

commit 30ee954ed1
Author: Andrea Faulds <ajf@ajf.me>
Date:   Sun Feb 14 01:46:25 2016 +0000

    fixup

commit a6403b79e0
Author: Andrea Faulds <ajf@ajf.me>
Date:   Sat Feb 13 22:00:27 2016 +0000

    Do not convert error-causing numeric strings ahead-of-time

commit f9dc354014
Author: Andrea Faulds <ajf@ajf.me>
Date:   Sat Feb 13 19:15:38 2016 +0000

    Disable compile-time evaluation for numeric string errors

commit e05b0cc849
Author: Andrea Faulds <ajf@ajf.me>
Date:   Fri Feb 5 11:42:26 2016 +0000

    Make _zval_get_long_func_noisy function for inlining

commit 84d66321a5
Author: Andrea Faulds <ajf@ajf.me>
Date:   Tue Jan 26 23:10:00 2016 +0000

    Update tests

commit 5ac4a0cc4b
Author: Andrea Faulds <ajf@ajf.me>
Date:   Tue Jan 26 22:08:19 2016 +0000

    Use is_numeric_string_ex for zval_get_long etc.

commit c21f088485
Author: Andrea Faulds <ajf@ajf.me>
Date:   Thu Jan 7 21:13:04 2016 +0000

    Update tests

commit 63e214cf81
Author: Andrea Faulds <ajf@ajf.me>
Date:   Wed Jan 6 00:28:01 2016 +0000

    Warn on non-/bad numeric strings in arithmetic
2016-03-30 01:44:27 +01:00
Bob Weinand
9600ddbd1a Merge remote-tracking branch 'origin/PHP-7.0' 2016-03-27 00:57:56 +01:00
Joe Watkins
4327370d13 fix #71414 (Interface method override inherited method and implemented in a trait causes fatal error) 2016-03-26 23:47:31 +00:00
Nikita Popov
b867bd1c8d Fix FETCH_CLASS_SELF comparisons
Turns out those don't form a bitfield.
2016-03-26 22:45:23 +01:00
Nikita Popov
8e5b139732 Evaluate arguments of new for classes without ctor
ML: http://markmail.org/message/4b3mk7jid64zvz34
2016-03-25 19:11:37 +01:00
Andrea Faulds
37c8bb5868 Allow specifying keys on list() elements
Squashed commit of the following:

commit 0361dbe356
Author: Andrea Faulds <ajf@ajf.me>
Date:   Fri Mar 25 16:59:20 2016 +0000

    UPGRADING and NEWS

commit dca9d4a36c
Author: Andrea Faulds <ajf@ajf.me>
Date:   Fri Mar 25 16:45:18 2016 +0000

    Add tests contributed by @jesseschalken

commit e557f77eab
Author: Andrea Faulds <ajf@ajf.me>
Date:   Fri Mar 25 16:44:51 2016 +0000

    Rebuild VM

commit 70942e4c3c
Author: Andrea Faulds <ajf@ajf.me>
Date:   Wed Feb 24 13:12:26 2016 +0000

    Add test for evaluation order of nested list() keys

commit ed3592e80c
Author: Andrea Faulds <ajf@ajf.me>
Date:   Wed Feb 24 12:42:04 2016 +0000

    Add test for evaluation order

commit 589756cbcc
Author: Andrea Faulds <ajf@ajf.me>
Date:   Tue Jan 19 17:29:34 2016 +0000

    Allow arbitrary expressions for key

commit 3f622077c3
Author: Andrea Faulds <ajf@ajf.me>
Date:   Tue Jan 19 17:45:10 2016 +0000

    Remove compile-time HANDLE_NUMERIC (see bug #63217)

commit bab758119a
Author: Andrea Faulds <ajf@ajf.me>
Date:   Sun Jan 17 01:20:26 2016 +0000

    Handle numeric strings

commit 14bfe93ddc
Author: Andrea Faulds <ajf@ajf.me>
Date:   Sun Jan 17 01:09:36 2016 +0000

    Allow trailing comma

commit f4c8b2cb30
Author: Andrea Faulds <ajf@ajf.me>
Date:   Sat Jan 16 23:47:11 2016 +0000

    Add tests

commit 0085884a61
Author: Andrea Faulds <ajf@ajf.me>
Date:   Sat Jan 16 22:24:23 2016 +0000

    Handle non-integer/string opcodes

commit e572d2d0ad
Author: Andrea Faulds <ajf@ajf.me>
Date:   Sat Jan 16 21:10:33 2016 +0000

    Disallow mixing keyed and unkeyed list() elements

commit cede13ccfe
Author: Andrea Faulds <ajf@ajf.me>
Date:   Sun Jan 10 20:46:44 2016 +0000

    list() with keys (no foreach or tests)
2016-03-25 17:18:42 +00:00
Dmitry Stogov
bc49f8b438 Fixed possible memory leak. 2016-03-23 00:46:48 +03:00
Nikita Popov
ac3a66cfad Merge branch 'PHP-7.0' 2016-03-21 22:50:03 +01:00
Nikita Popov
dc842bbf8d Fixed bug #71871 2016-03-21 22:49:18 +01:00
Nikita Popov
24f63b1c32 Fix broken merge 2016-03-20 01:35:51 +01:00
Xinchen Hui
93499bfd8a Fixed test & ZEND_BOOL should result TMP_VAR 2016-03-17 07:55:25 -07:00
Xinchen Hui
f2b6b26189 Merge branch 'PHP-7.0'
Conflicts:
	Zend/zend_compile.c
2016-03-17 07:51:26 -07:00
Xinchen Hui
910e6dc6b8 Fixed for master 2016-03-17 21:10:08 +08:00
Nikita Popov
64dae1ea76 Statically bind static method call arguments
If we know what method will be called, use ct-bound send opcodes.

The intl test is changed because a runtime error changed to a
compile-time error.
2016-03-14 17:50:56 +01:00
Dmitry Stogov
dc33c79a65 Evaluate ord(<string>), chr(<int>) and defined(<persistent-constant>) at compile time 2016-02-19 14:14:27 +03:00
Nikita Popov
d10911afde Simplify previous fix
I didn't notice that there already is a var with the same value.
2016-02-13 23:46:50 +01:00
Nikita Popov
502dd99a6c Fix ZEND_NEW live ranges
While the def starts at DO_FCALL, the variable should still be the
result of NEW, not DO_FCALL.

I had to fix the test for #68652, because the code started to
(correctly) free the "new self()" object, which triggered an
infinite destructor loop.
2016-02-13 19:04:54 +01:00
Nikita Popov
d1b777bd99 Merge branch 'PHP-7.0' 2016-02-12 17:58:12 +01:00
Nikita Popov
ccc06e252b Forbid yield from in by-reference generators
The current yield from implementation doesn't support by-ref
yields. It's likely not worthwhile to actually implement this,
but we should at least keep the door open for the future by
issuing a compile error.

Refs bug #71252.
2016-02-12 17:55:29 +01:00
Nikita Popov
44ed1cb5c0 Remove ZEND_CALL_CTOR_RESULT_UNUSED
Instead emit a FREE on the result of NEW.
2016-02-11 22:15:11 +01:00
Dmitry Stogov
8c2d55962e Combine conditions 2016-02-11 23:11:19 +03:00
Nikita Popov
5faedf5b3e Remove EXT_TYPE_UNUSED in favor of IS_UNUSED
This means we no longer allocate an unused VAR for the retval of
instructions that support unused results.

Nearly all instructions already used the result variable only if
it was used. The only exception to this was the return value
variable for internal function call results. I've adjusted the code
to use a stack zval for the unused return case now. As we have
retval specialization now, we know that it doesn't matter.
2016-02-11 18:02:19 +01:00
Nikita Popov
abc06b91cd Merge branch 'PHP-7.0'
Conflicts:
	Zend/zend_compile.c
2016-02-06 16:43:54 +01:00
Nikita Popov
9f82f21d01 Fix bug #71529 2016-02-06 16:43:28 +01:00
Nikita Popov
35662c9bd3 Forbid double use() and use() of param
Also commit a test I forgot to add for forbidden use() of
auto-globals.
2016-01-12 15:37:39 +01:00
Dmitry Stogov
6579e48417 Introduced BIND_STATIC opcode instead of FETCH_R/FETCH_W(static)+ASSIGN/ASSIGN_REF (similar to BIND_GLOBAL).
In the future we may refer to static variable by index instead of name, to eliminate hash lookup.
2016-01-12 12:20:35 +03:00
Xinchen Hui
9c2dde98db Merge branch 'PHP-7.0' 2016-01-07 07:05:31 -08:00
Xinchen Hui
16a2b47394 Fixed bug #71300 (Segfault in zend_fetch_string_offset) 2016-01-07 07:05:17 -08:00
Xinchen Hui
563659822d Merge branch 'PHP-7.0' 2016-01-02 17:56:54 +08:00
Xinchen Hui
97a9470d97 bump year which is missed in rev 49493a2 2016-01-02 17:56:11 +08:00
Xinchen Hui
3537e95dae bump year which is missed in rev 49493a2 2016-01-02 17:51:24 +08:00
Derick Rethans
5362f0ad7f MFH: Fix lineno for finally FAST_CALL and JMP 2015-12-31 09:46:43 +00:00
Nikita Popov
b3afeeabef Fix lineno for finally FAST_CALL and JMP 2015-12-30 23:49:07 +01:00
Nikita Popov
65e456f364 Introduce BIND_LEXICAL
This opcodes inserts a local CV into the closure static variable
table. This replaces the previous mechanism of having static
variables marked as LEXICAL, which perform a symtable lookup
during copying.

This means a) functions which contain closures no longer have to
rebuild their symtable (better performance) and b) we can now track
used variables in SSA.
2015-12-29 23:14:53 +01:00
Nikita Popov
4440436821 Forbid use() of auto-globals
We don't correctly support it, it doesn't make sense and it's also
forbidden for parameters.
2015-12-29 11:20:44 +01:00
Julien Pauli
7a2f60d3c7 Merge branch 'PHP-7.0'
* PHP-7.0:
  Remove mentions of "type hint" and "typehint"
2015-12-24 15:19:54 +01:00
Levi Morrison
2a7eeff33e Remove mentions of "type hint" and "typehint" 2015-12-24 15:19:31 +01:00
Dmitry Stogov
aa4a83fec7 Fixed bug #71196 (Memory leak with out-of-order live ranges) 2015-12-23 01:47:38 +03:00
Nikita Popov
88eae43ff9 Remove uses of VARs in extended_value
The DECLARE_(ANON_)INHERITED_CLASS(_DELAYED) opcodes were
referencing the parent ce VAR through extended_value. This is
hacky and we can't track the def-use chain in SSA.

To avoid this, the layout of declaration opcodes is changed
as follows: op1 points to the lcname and rtd_key literals, in
that order. (For anon/lambda declarations only one of lcname or
rtd_key is present.) This frees up op2, which is now used to
reference the parent ce VAR in inheriting declarations. The
jmp offset for anon class declarations is moved frop op2 to
extended_value.

The changes were applied both to class and function declarations
to keep everything symmetric.
2015-12-21 14:44:42 +01:00
Andrea Faulds
5d0dfda60c Merge branch 'PHP-7.0' 2015-12-19 02:35:19 +00:00
Andrea Faulds
42c8f5e91d Fix bug #70804
This follows on from a4648ded43 and
4e01269082.
Both -(+0.0) and +(-0.0) behaved incorrectly for the same reason.
2015-12-19 02:25:44 +00:00
Andrea Faulds
8d355bff85 Merge branch 'PHP-7.0' 2015-12-17 22:40:55 +00:00
Andrea Faulds
a4648ded43 Fix bug #52355 2015-12-17 22:39:29 +00:00
Nikita Popov
56f1106162 Use FETCH_CLASS_EXCEPTION for instanceof
This does not collide with NO_AUTOLOAD -- missing classes will be
silenced, but invalid use of self etc will result in an exception
instead of a fatal error.
2015-12-14 17:50:20 +01:00
Nikita Popov
0919178963 Add result op for ASSERT_CHECK to fix SSA
Otherwise one source of the phi node at the join point will be
borked.

I'm marking the ASSERT_CHECK result as unused in pass2, which is
a bit ugly.
2015-12-14 12:31:00 +01:00
Xinchen Hui
0d8f5a43d3 Merge branch 'PHP-7.0'
Conflicts:
	NEWS
2015-12-11 09:13:26 -08:00
Xinchen Hui
778e5f3da5 Fixed bug #71092 (Segmentation fault with return type hinting) 2015-12-11 09:11:28 -08:00
Nikita Popov
591fe26d5d Remove BP_VAR_REF
The distinction between BP_VAR_REF and BP_VAR_W is no longer
revelant, since we dropped support for =& new.
2015-12-11 15:56:52 +01:00
Nikita Popov
04e3d82b55 Make duplicate class constant error for internal class
And drop two duplicate constant declarations from intl. These
were leaking previously.
2015-12-10 22:22:49 +01:00
Nikita Popov
8e5e3301a1 Make ZEND_CLONE return a TMP_VAR
As the return value can't be reference and it's unlikely to be
unused.

Also remove some unnecessary checks for ce==NULL. A ce is required
nowadays.
2015-12-10 22:16:25 +01:00
Nikita Popov
f1278edefc Drop two compiler TODOs
Call-time pass by reference is now a parse error.
There is no benefit in dropping implementing_class currently.
2015-12-10 19:04:59 +01:00
Nikita Popov
c8a64e289c Reintroduce use of FETCH_GLOBAL_LOCK
Just found this old AST todo...

It no longer makes sense as an optimization due to the introduction
of BIND_GLOBAL, however it ensures that the global variable name is
not evaluated twice, which is presumably something we wish to
guarantee.
2015-12-10 19:04:59 +01:00
Nikita Popov
3fa86105f7 Remove FETCH_STATIC_MEMBER flag 2015-12-10 18:25:29 +01:00
Nikita Popov
3d4a2d2002 Merge branch 'PHP-7.0'
Conflicts:
	Zend/zend_vm_def.h
	Zend/zend_vm_execute.h
2015-12-10 18:24:29 +01:00
Nikita Popov
37f3425263 Fix Foo::${42} and similar
Fixes segfault on direct use, segfault on opcache evaluated use,
leak on temporary use.

Fixes analogeous segfault for ${42} on opcache eval as well.
2015-12-10 18:14:40 +01:00
Dmitry Stogov
5ee7b7d01a Don't create live-range across NOPs and some other instructions 2015-12-09 05:15:58 +03:00
Dmitry Stogov
c1803bf652 Avoid construction of empty live-ranges because of OP_DATA instruction 2015-12-08 18:10:07 +03:00
Dmitry Stogov
a75c195000 Implemented the RFC Support Class Constant Visibility.
Squashed commit of the following:

commit f11ca0e7a5
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Tue Dec 8 12:38:42 2015 +0300

    Fixed test expectation

commit 211f873f54
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Tue Dec 8 12:28:38 2015 +0300

    Embed zend_class_constant.flags into zend_class_constants.value.u2.access_flags

commit 51deab84b2
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Mon Dec 7 11:18:55 2015 +0300

    Fixed issues found by Nikita

commit 544dbd5b47
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Sat Dec 5 02:41:05 2015 +0300

    Refactored immplementation of https://wiki.php.net/rfc/class_const_visibility
    @reeze created an RFC here and I emailed internals here and didn't get any responses positive/negative.
2015-12-08 12:40:42 +03:00
Xinchen Hui
5c707a6cf8 Merge branch 'PHP-7.0' 2015-11-28 23:44:06 -08:00
Xinchen Hui
1f65006fce Fixed bug #70931 (Two errors messages are in conflict) 2015-11-28 23:43:41 -08:00
Nikita Popov
95283a0504 Merge branch 'PHP-7.0' 2015-11-26 16:57:11 +01:00
Nikita Popov
99dd7ee80b Forbid namespace\int type hint as well 2015-11-26 16:56:08 +01:00
Xinchen Hui
06bcaf98c5 Merge branch 'PHP-7.0' 2015-11-25 19:11:40 +08:00
Xinchen Hui
3cdbe347ae Always lower name 2015-11-25 19:11:22 +08:00
Xinchen Hui
05738eb71a Revert "Improved fix for Fully qualified (leading backslash) type names must fail"
This reverts commit 00865ae22f.
2015-11-25 19:06:42 +08:00
Xinchen Hui
c6b08e99fe Merge branch 'PHP-7.0' 2015-11-25 11:41:01 +08:00
Xinchen Hui
00865ae22f Improved fix for Fully qualified (leading backslash) type names must fail
it now all fails with COMPILE_ERROR instead of syntax error for T_ARRAY
but COMPILE_ERROR for int
2015-11-25 11:27:32 +08:00