Commit Graph

1121 Commits

Author SHA1 Message Date
Dmitry Stogov
249c2323f4 Allow CALL executor to keep few very often used vaiables in CPU registers.
This is disabled by default yet, but may be enabled compiling zend_execute.c with -DHAVE_GCC_GLOBAL_REGS.
Only tested on Linux x86 and x86_64 with GCC 4.9.2.
2015-03-13 03:28:21 +03:00
Dmitry Stogov
6289f7e52f Executor cleanup: fix GOTO and SWITCH VMs, remove aility to build additional PHP-5.0 compatible VM, hide executor implementation details. 2015-03-12 20:39:04 +03:00
Dmitry Stogov
a30d328671 Errors converted to exceptions are not "recoverable" anymore. 2015-03-10 10:31:55 +03:00
Dmitry Stogov
1c94ff0595 Implement engine exceptions
RFC: https://wiki.php.net/rfc/engine_exceptions_for_php7

Pending changes regarding naming of BaseException and whether it
should be an interface.
2015-03-09 14:01:32 +01:00
Bob Weinand
afad979c60 Reduced initial VM_STACK page size of Generators to 4 KB (256 slots)
Generators all have their own vm_stack, but usually don't go really deep.
In most cases even most of the 4 KB will remain unused (in my tests average is rather 1 KB), but this was tested a straightforward implementation without a lot of abstraction layers.
That way I'm using a more conservative 4 KB stack size which really should be enough for, I think, at least 90% of the cases.
This was necessary to not immediately run out of memory with 95%+ usused vm_stack space: If you have a few thousands of Generators active, your application quickly hits memory_limit with a stack page size of 256 KB...
In addition, it's also a bit faster (70% less instructions for zend_vm_stack_new_page) due to emalloc() not having to allocate a whole new segment (segment size 256 KB). Also no mmap()/malloc() necessary.
2015-03-07 13:25:21 +01:00
Dmitry Stogov
fa2450c5f8 Don't inline helpers for ArrayAccess objects 2015-03-03 03:28:31 +03:00
Dmitry Stogov
ff86267632 Fixed compilation warnings 2015-02-25 23:20:47 +03:00
Dmitry Stogov
c2c78dc963 Added specialized versions of DO_FCALL handler:
DO_ICALL - for internal functions
  DO_UCALL - for user functions
  DO_FCALL_BY_NAME - plain, most probably user, funcstions (not methods)
2015-02-25 10:37:21 +03:00
Dmitry Stogov
5f278e4d3a Use cache_slot offsets instead of indexes (simplify run-time instructions) 2015-02-25 01:52:35 +03:00
Dmitry Stogov
e97ae4fee8 Make zend_array_destroy() to free the corresponding zend_array 2015-02-24 18:34:37 +03:00
Dmitry Stogov
d85113702c Lazy duplication of op_array->static_variables 2015-02-20 13:28:26 +03:00
Dmitry Stogov
e10e151e9b Merged zend_array and HashTable into the single data structure.
Now each HashTable is also zend_array, so it's refcounted and may be a subject for Copy on Write
zend_array_dup() was changed to allocate and return HashTable, instead of taking preallocated HashTable as argument.
2015-02-13 22:20:39 +03:00
Dmitry Stogov
97fe15db43 Fix "forech" statemt behaviour according to https://wiki.php.net/rfc/php7_foreach
Squashed commit of the following:

commit 1e41295097
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Sat Jan 31 07:28:58 2015 +0300

    Generalize HashTableIterator API to allows its usage without involvement of HashTable.nInternalPonter

commit 5406f21b11
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Fri Jan 30 18:08:43 2015 +0300

    Reduced alghorithms complexity

commit b37f1d58d2
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Fri Jan 30 18:08:30 2015 +0300

    Fixed test name

commit fb2d079645
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Fri Jan 30 18:08:05 2015 +0300

    API cleanup

commit 08302c0d6d
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Fri Jan 30 14:20:46 2015 +0300

    Make array_splice() to preserve foreach hash position

commit cc4b7be41e
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Fri Jan 30 12:24:31 2015 +0300

    Make internal function, operation on array passed by reference, to preserve foreach hash position

commit 5aa9712b0a
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Fri Jan 30 09:49:35 2015 +0300

    Implement consistent behavior for foreach by value over plain object

commit 4c5b385ff5
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Fri Jan 30 07:56:37 2015 +0300

    More careful iterators update.

commit 721fc9e80d
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Thu Jan 29 21:43:28 2015 +0300

    Added new test

commit 15a23b1218
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Thu Jan 29 21:05:02 2015 +0300

    Reimplement iteration magic with HashTableIterators (see https://wiki.php.net/rfc/php7_foreach#implementation_details)

commit 10a3260b1f
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Thu Jan 29 21:04:44 2015 +0300

    New test

commit eef80c5837
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Wed Jan 28 16:52:21 2015 +0300

    Fixed foreach by reference iteration over constant array

commit 61e7391873
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Wed Jan 28 14:59:54 2015 +0300

    Fixed temporary variable re-allocation pass

commit 92e90c09f0
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Wed Jan 28 12:44:57 2015 +0300

    Fixed operand destruction in case of exceptions in iterator

commit dd2a36a207
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Wed Jan 28 10:02:34 2015 +0300

    Use GET_OP1_ZVAL_PTR_DEREF() (IS_TMP_VAR and IS_CONST can't be IS_REFERENCE)

commit 4638f7b914
Author: Dmitry Stogov <dmitry@zend.com>
Date:   Wed Jan 28 07:43:28 2015 +0300

    Change "foreach" statement behavior (this is just a PoC yet)

    - "foreach by value" don't relay on internal array/object pointer and doesnt perform array duplication. It just locks it incrementing reference counter. If the original array is modified by some code, the copy on write is performed and "foreach" still work with the old copy.

    - it makes no difference if array given to "foreach by value" is reference itself

    - "foreach by reference" still use internal array/object pointer and should work similar to PHP-5. (This id not completely implemented)
2015-02-12 13:57:12 +03:00
Dmitry Stogov
f5a9cfc33a Merge branch 'internal-function-return-types' of github.com:reeze/php-src into test
* 'internal-function-return-types' of github.com:reeze/php-src:
  Add load time return type checking to match user land logic
  Add test function arguments
  Implemented internal function return types
2015-02-05 11:01:07 +03:00
Reeze Xia
bff4c47fa7 Implemented internal function return types 2015-02-05 01:04:54 +08:00
Dmitry Stogov
8b46d45a9d Simplify code and add comments 2015-02-04 17:56:14 +03:00
Levi Morrison
c8576c5a46 Implement return types
RFC is documented here: https://wiki.php.net/rfc/return_types
2015-01-27 11:49:56 -07:00
Dmitry Stogov
371dc9b6a6 Fixed bug #68896 (Changing ArrayObject value cause Segment Fault) 2015-01-26 11:25:05 +03:00
Xinchen Hui
fc33f52d8c bump year 2015-01-15 23:27:30 +08:00
Dmitry Stogov
5a24ac8853 Improved access to object properties (cache property offset instead of pointer to property_info). 2015-01-13 11:33:00 +03:00
Stanislav Malyshev
b7a7b1a624 trailing whitespace removal 2015-01-10 15:07:38 -08:00
Dmitry Stogov
ab0b15b8ff Optimized destruction of extra arguments passed to user functions.
If no refcounted arguments are passed, then destruction code is not triggered at all.
(Full rebuild required)
2014-12-26 22:34:44 +03:00
Dmitry Stogov
fd4844e079 Removed useless checks 2014-12-22 19:04:29 +03:00
Dmitry Stogov
2646f7bcb9 Don't count variadic argument in zend_func.common.num_args. This allows faster CALL/RETURN code. 2014-12-22 16:44:39 +03:00
Anatol Belski
bdeb220f48 first shot remove TSRMLS_* things 2014-12-13 23:06:14 +01:00
Dmitry Stogov
3893c1fc3d Fixed compilation warnings 2014-12-12 21:57:34 +03:00
Dmitry Stogov
68cfeed70f Removed unnecessary checks 2014-12-12 21:57:12 +03:00
Dmitry Stogov
14e29f5146 Reduced size of zend_op on 64-bit systems.
the main idea - the smaller the zend_op structure, the lees memory traffic is required to load VM instructions during execution. The patch reduces the size of each opcode from 48 to 32 bytes (saves 16 bytes for each opcode, and applications use thousands of opoceds). This reduced the number of CPU cache misses by 12% and improved performance of real-life apps by 1-2%.

The patch affects how constants and jump targets are represented in VM during execution. Previously they were implemented as absolute 64-bit pointers. Now they are relative 32-bit offsets.

In run-time constant now should be accessed as:
  RT_CONSTANT(op_array, opine->op1) instead of opline->op1.zv
  EX_CONSTANT(opline->op1) instead of opline->op1.zv

Jump targets:
  OP_JMP_ADDR(opline, opline->op2) instead of opline->op2.jmp_addr

The patch doesn't change zend_op representation for 32-bit systems. They still use absolute addresses. The compile-time representation is also kept the same.
2014-12-12 10:19:41 +03:00
Anatol Belski
da78550006 fix TS build and C89 compat 2014-12-10 12:23:46 +01:00
Dmitry Stogov
5b3a69c29f Improved ASSIGN_<OP>, ASSIGN_DIM and UNSET_DIM 2014-12-09 15:15:24 +03:00
Dmitry Stogov
98e81e13cf simplified code 2014-12-09 12:17:55 +03:00
Dmitry Stogov
f70545678b Pass znode_op structure by value (it fits into one word) instead of pointer to structure. 2014-12-09 03:03:38 +03:00
Dmitry Stogov
11f7854e75 Move checks for references into slow paths. 2014-12-09 01:09:44 +03:00
Dmitry Stogov
b6c6e7960a Improved ASSIGN_DIM and ASSIGN_OBJ 2014-12-09 00:10:23 +03:00
Dmitry Stogov
db4271d332 Move checks for references into slow paths of handlers or helpers. Remove duplicate opcode handlers. 2014-12-08 18:11:14 +03:00
Dmitry Stogov
a417ebfc48 Get rid of duplicare FETCH_DIM_* handlers 2014-12-05 13:45:03 +03:00
Dmitry Stogov
5dd427eac2 Use zend_string* for op_array->arg_info[]->name and op_array->arg_info[]->class_name. For internal functions we still use char*. 2014-12-03 16:56:09 +03:00
Dmitry Stogov
1da14c9f81 Pack EX(frame_info) into EX(This).u1.v.reserved. Rename "frame"kind" into "call_kind" and VM_FRAME_... into ZEND_CALL_... 2014-11-28 10:33:03 +03:00
Dmitry Stogov
11384ba77b Pack EX(num_args) into EX(This).u2.num_args 2014-11-28 10:28:49 +03:00
Dmitry Stogov
9a36cb1a07 Get rid of EX(scope). In most cases we use EG(scope) anyway. EX(scope) was used to switch EG(scope) back after call, but it's possibleto use EX(func)->common.scope instead. 2014-11-28 10:21:18 +03:00
Dmitry Stogov
109baa0394 Fixed compilation warnings 2014-11-27 12:52:31 +03:00
Dmitry Stogov
216ef32173 Changed "finally" handling. Removed EX(fast_ret) and EX(delayed_exception). Allocate and use additional IS_TMP_VAR slot on VM stack instead. 2014-11-27 09:56:43 +03:00
Dmitry Stogov
303d73ecd2 Reimplemented silence operator (@) handling on exceptions. Now each silence region is stored in op_array->brk_cont_array. On exception ZEND_HANDLE_EXCEPTION handler traverse this array and restore original EG(error_reporting) if exception occured inside a "silence" region. 2014-11-26 22:44:58 +03:00
Anatol Belski
d36bf0e8ee fix TS build 2014-11-25 17:58:20 +01:00
Dmitry Stogov
1c569b41d5 Merge branch 'PHP-5.6'
* PHP-5.6:
  Better fix for bug #68446
2014-11-25 18:12:30 +03:00
Dmitry Stogov
e116595e63 Better fix for bug #68446 2014-11-25 18:09:08 +03:00
Dmitry Stogov
83ce1d9a78 Revert "Merge remote-tracking branch 'origin/PHP-5.6'"
This reverts commit 38229d13d1, reversing
changes made to 77f172725a.
2014-11-25 15:40:08 +03:00
Bob Weinand
aba95c2399 Revert "Fix bug #68446 (bug with constant defaults and type hints)"
This reverts commit 5ef138b0c7.
2014-11-25 12:24:29 +01:00
Dmitry Stogov
3727e26456 Improved zend_hash_clean() and added new optimized zend_symtable_clean() 2014-11-25 14:17:21 +03:00
Dmitry Stogov
85d04a48d9 Improved assignment to object property 2014-11-24 23:19:24 +03:00