Commit Graph

222 Commits

Author SHA1 Message Date
Xinchen Hui
a666285bc2 Happy New Year 2013-01-01 16:37:09 +08:00
Xinchen Hui
0a7395e009 Happy New Year 2013-01-01 16:28:54 +08:00
Dmitry Stogov
b8c719c068 Merge branch 'PHP-5.4' into PHP-5.5
* PHP-5.4:
  Traits refactoring
2012-12-25 10:33:01 +04:00
Dmitry Stogov
3f8c729e69 Traits refactoring 2012-12-25 10:23:08 +04:00
Dmitry Stogov
9c96fe52d9 Restored proper generators behaviour in conjunction with "finally". (Nikita) 2012-12-12 17:47:55 +04:00
Dmitry Stogov
70f83f35d0 . The VM stacks for passing function arguments and syntaticaly nested calls were merged into a single stack. The stack size needed for op_array execution is calculated at compile time and preallocated at once. As result all the stack push operatins don't require checks for stack overflow any more.
. Generators implementation was improved using the new VM stack. Now it's a bit more clear and faster.
2012-11-30 13:39:23 +04:00
Dmitry Stogov
eb4825b50b Improved "finally" im[plementation 2012-11-22 15:17:05 +04:00
Pierre Joye
2b7bddd82a Merge branch 'PHP-5.4'
* PHP-5.4:
  - fix build, there was no tsrm context there, doing a fetch but this is horribly slow, this fix needs improvement (or simply add a TSRM context in the signature in master
2012-09-05 13:00:41 +02:00
Pierre Joye
954e7a3b3c - fix build, there was no tsrm context there, doing a fetch but this is horribly slow, this fix needs improvement (or simply add a TSRM context in the signature in master 2012-09-05 13:00:04 +02:00
Dmitry Stogov
bceec038c8 Merge branch 'PHP-5.4'
* PHP-5.4:
  Fixed bug #62907 (Double free when use traits)

Conflicts:
	NEWS
2012-09-05 10:01:04 +04:00
Dmitry Stogov
6c0508f8d5 Fixed bug #62907 (Double free when use traits) 2012-09-05 09:58:22 +04:00
Nikita Popov
68c1e1cfe9 Add dedicated opcode for returns from a generator
Generators don't have a return value, so it doesn't make sense to have
a shared implementation here.
2012-08-24 13:51:39 +02:00
Nikita Popov
6517ed0215 Merge remote-tracking branch 'php-src/master' into addGeneratorsSupport
Conflicts:
	Zend/zend_vm_def.h
	Zend/zend_vm_execute.h
2012-08-24 13:29:40 +02:00
Xinchen Hui
60a29791e4 Fixed bug that jmp in try block jmp over finally block
Refactor the implemention,  make codes clear
2012-08-22 18:32:03 +08:00
Xinchen Hui
703a4e390d stash 2012-08-22 13:51:44 +08:00
Nikita Popov
1823b16fa1 Merge remote-tracking branch 'php-src/master' into addGeneratorsSupport
Merging master to fix Windows build

Conflicts:
	Zend/zend_language_scanner.c
	Zend/zend_language_scanner_defs.h
	Zend/zend_vm_def.h
2012-08-20 13:37:53 +02:00
Felipe Pena
b2a74b5bdb - Remove unused vars 2012-08-18 11:28:00 -03:00
Xinchen Hui
72b9b8f380 Make the codes clearer, and also check continue statement 2012-08-18 11:44:09 +08:00
Xinchen Hui
f2a8912e61 Refactor examing of jumping out of finally block 2012-08-18 00:16:34 +08:00
Nikita Popov
f4ce364628 Merge remote-tracking branch 'php-src/master' into addGeneratorsSupport
This is just an intial merge. It does not yet make generators and finally
work together.

Conflicts:
	Zend/zend_language_scanner.c
	Zend/zend_language_scanner_defs.h
	Zend/zend_vm_def.h
	Zend/zend_vm_execute.h
	Zend/zend_vm_execute.skl
	Zend/zend_vm_opcodes.h
2012-08-13 16:54:53 +02:00
Nikita Popov
134089372b Throw error also for return occuring before yield
Previously only an error was thrown when return occured after yield. Also
returns before the first yield would fail for by-ref generators.

Now the error message is handled in pass_two, so all returns are checked.
2012-07-22 20:11:09 +02:00
Dmitry Stogov
2ae8d2fbfb Fixed bug #61998 (Using traits with method aliases appears to result in crash during execution) 2012-05-21 13:57:41 +04:00
Felipe Pena
8775a37559 - Year++ 2012-01-01 13:15:04 +00:00
Felipe Pena
4e19825281 - Year++ 2012-01-01 13:15:04 +00:00
Arnaud Le Blanc
ea5a61e39b Improved ternary operator performance when returning arrays 2011-10-18 19:42:42 +00:00
Arnaud Le Blanc
07b7ba8b40 Improved ternary operator performance when returning arrays 2011-10-18 19:42:42 +00:00
Dmitry Stogov
4a25a7740d Fixed ZE specific compile warnings (Bug #55629) 2011-09-13 13:29:35 +00:00
Dmitry Stogov
e43ff1359e Fixed ZE specific compile warnings (Bug #55629) 2011-09-13 13:29:35 +00:00
Felipe Pena
0203cc3d44 - Year++ 2011-01-01 02:17:06 +00:00
Hartmut Holzgraefe
aaa2f1c30b marked char pointer arguments as const in lots of
places where strings pointed to are not modified 
to prevent compiler warnings about discarded qualifiers ...
2010-10-14 21:33:10 +00:00
Dmitry Stogov
f2df6a4a3e - Improved memory usage
. zend_function.pass_rest_by_reference is replaced by
    ZEND_ACC_PASS_REST_BY_REFERENCE in zend_function.fn_flags
  . zend_function.return_reference is replaced by ZEND_ACC_RETURN_REFERENCE
    in zend_function.fn_flags
  . zend_arg_info.required_num_args removed. it was needed only for internal
    functions. Now the first arg_info for internal function (which has special
    meaning) is represented by zend_internal_function_info structure.
  . zend_op_array.size, size_var, size_literal, current_brk_cont,
    backpatch_count moved into CG(context), because they are used only during
    compilation.
  . zend_op_array.start_op is moved into EG(start_op), because it's used
    only for 'interactive' execution of single top-level op-array.
  . zend_op_array.done_pass_two is replaced by ZEND_ACC_DONE_PASS_TWO in
    zend_op_array.fn_flags.
  . op_array.vars array is trimmed (reallocated) during pass_two.
  . zend_class_entry.constants_updated is replaced by
     ZEND_ACC_CONSTANTS_UPDATED in zend_class_entry.ce_flags
  . the size of zend_class_entry is reduced by sharing the same memory space
    by different information for internal and user classes.
    See zend_class_inttry.info union.
2010-09-15 07:38:52 +00:00
Dmitry Stogov
3cf5ab9e56 Use interned strings for class names 2010-08-05 13:10:15 +00:00
Felipe Pena
3ea3bbaca3 - Fix ZTS build 2010-07-06 15:52:39 +00:00
Dmitry Stogov
1a1178a685 eliminated unnecessary iterations during request startup/shutdown 2010-07-06 11:40:17 +00:00
Dmitry Stogov
743a2e29c1 Fixed bug #51822i (Segfault with strange __destruct() for static class variables) 2010-06-10 11:45:51 +00:00
Dmitry Stogov
f23e857676 Fixed ZTS build 2010-05-24 17:07:52 +00:00
Dmitry Stogov
c5237d82bf Added caches to eliminate repeatable run-time bindings of functions, classes, constants, methods and properties 2010-05-24 14:11:39 +00:00
Stefan Marr
fe4988241d Refactored part of the Traits implementation.
# - renamed php_runkit_function_copy_ctor to _duplicate_function
#   REM: runkit does not compile with trunk at the moment, fixing it would introduce even more version #ifs, don't know what the best way is to fix it
# - extracted traits related stuff from destroy_zend_class into _destroy_zend_class_traits_info
#   - need to investigate implementation/handling of internal classes further before enabling internal traits
2010-05-02 16:32:25 +00:00
Stefan Marr
cd6415f1a9 Implemented Traits for PHP as proposed in the RFC [TRAITS]
# RFC http://wiki.php.net/rfc/horizontalreuse#traits_-_reuse_of_behavior
# Ok, here we go, I guess that will result in more discussion, which is fine
# by me. But now, the patch is here, and properly archived.
# 
# See below a list of notes to the patch, it also includes a list of
# points which should be fixed
# 
# Internals of the Traits Patch
# -----------------------------
# 
# Open TODOs
# """"""""""
# 
# - Reflection API
# - support for traits for internal classes
#   - currently destroy_zend_class does not handle that case 
# 
# Introduced Structures
# """""""""""""""""""""
# 
# Data structures to encode the composition information specified in the
# source:
#  - zend_trait_method_reference
#  - zend_trait_precedence
#  - zend_trait_alias
# 
# Changes
# """""""
# 
# zend_class_entry
#  - uses NULL terminated lists of pointers for
#    - trait_aliases
#    - trait_precedences
#    - do you prefer an explicit counter?
#    - the information is only necessary during class composition
#      but might be interesting for reflection
#    - did not want to blow up class further with not really necessary length counters
# 
# added keywords
#   - trait
#   - insteadof
# 
# Added opcodes
#  ZEND_ADD_TRAIT
#    - similar to ZEND_ADD_INTERFACE
#    - adds the trait to the list of traits of a class, no actual composition done
#  ZEND_BIND_TRAITS
#    - emitted in zend_do_end_class_declaration
#    - concludes the class definition and will initiate the trait composition
#      when the class definition is encountered during runtime
# 
# Added Flags
#   ZEND_ACC_TRAIT = 0x120
#   ZEND_ACC_IMPLEMENT_TRAITS = 0x400000
#   ZEND_FETCH_CLASS_TRAIT = 14
# 
# zend_vm_execute.h
#  - not sure whether the handler initialization (ZEND_ADD_TRAIT_SPEC_HANDLER,
#    ZEND_BIND_TRAITS_SPEC_HANDLER) is correct, maybe it should be more selective
# 
# zend_compile.c
#  - refactored do_inherit_method_check
#    split into do_inherit_method_check and do_inheritance_check_on_method
#  - added helper functions use a '_' as prefix and are not mentioned in the
#    headers
#  - _copy_functions
#    prepare hash-maps of functions which should be merged into a class
#    here the aliases are handled
#  - _merge_functions
#    builds a hash-table of the methods which need to be added to a class
#    does the conflict detection
#  - reused php_runkit_function_copy_ctor
#    - it is not identical with the original code anymore, needed to update it
#      think I fixed some bugs, not sure whether all have been reported back to runkit
#    - has to be renamed, left the name for the moment, to make its origin obvious
#    - here might be optimization potential
#    - not sure whether everything needs to be copied
#      - copying the literals might be broken
#        - added it since the literals array is freed by efree and gave problems
#          with doubled frees
#      - all immutable parts of the zend_op array should not be copied
#        - am not sure which parts are immutable
#        - and not sure how to avoid doubled frees on the same arrays on shutdown
#  - _merge_functions_to_class
#    does the final merging with the target class to handle inherited
#    and overridden methods
#  - small helper for NULL terminated lists
#    zend_init_list, zend_add_to_list
# 
# zend_language_parser.y
#  - reused class definition for traits
#    - there should be something with regard to properties
#      - if they get explicitly defined, it might be worthwhile to
#        check that there are no collisions with other traits in a composition
#        (however, I would not introduce elaborate language features to control that
#         but a notice for such conflicts might be nice to the developers)
2010-04-22 22:05:56 +00:00
Dmitry Stogov
dd5c478be6 Added concept of interned strings. All strings constants known at compile time are allocated in a single copy and never changed. 2010-04-20 11:05:54 +00:00
Dmitry Stogov
94dd83722b Changed the structure of op_array.opcodes. The constant values are moved from opcode operands into a separate literal table 2010-04-20 10:57:45 +00:00
Sebastian Bergmann
d2281d1dff sed -i "s#1998-2009#1998-2010#g" **/*.c **/*.h **/*.php 2010-01-05 20:46:53 +00:00
Brian Shire
cb7a21a42b MFH: Make pass_two visible to extensions with ZEND_API (required for optimizer). 2009-06-05 23:20:59 +00:00
Sebastian Bergmann
08659c2dcd MFH: Bump copyright year, 3 of 3. 2008-12-31 11:15:49 +00:00
Matt Wilmas
22a5aea161 MFH: - Updated unary_op_type typedef with TSRMLS_DC
- Added binary_op_type typedef
- Added missing ZEND_BOOL_XOR to get_binary_op()
2008-08-29 18:12:47 +00:00
Dmitry Stogov
5521912b15 Use IS_CV for dirrent access to $this variable 2008-05-07 12:04:39 +00:00
Felipe Pena
f66f55edc5 MFH: Implemented "jump label" operator (limited "goto")
[DOC]
2008-03-28 14:35:01 +00:00
Dmitry Stogov
8c885b8913 Implemented concept of "delayed early binding" that allows opcode caches to perform class declaration (early and/or run-time binding) in exactly the same order as vanila php.
The following pseudo-code explains how it should be used in opcode cache.

function cache_compile_file($filename) {
        if (!is_cached($filename)) {
                ...
                orig_compiler_options = CG(compiler_optins);
                CG(compiler_options) |= ZEND_COMPILE_IGNORE_INTERNAL_CLASSES |
                                        ZEND_COMPILE_DELAYED_BINDING;
                $op_array = orig_compile_file($filename);
                CG(compiler_options) = orig_copiler_options;
                ...
        } else {
                $op_array = restore_from_cache($filename);
        }
        zend_do_delayed_early_binding($op_array);
}
2008-03-18 08:36:30 +00:00
Sebastian Bergmann
d1dded8751 MFH: Bump copyright year, 2 of 2. 2007-12-31 07:17:19 +00:00
Johannes Schlüter
45f6b4ce2f - MFH Improved version of ternary shortcut (Marcus) 2007-11-21 09:41:35 +00:00
Derick Rethans
991f1d8d7a - MFH: Initialize the reserved resource bits so that they can be reliably used. 2007-11-18 21:29:55 +00:00
Yiduo (David) Wang
4b4d634cb9 MFH: Added macros for managing zval refcounts and is_ref statuses 2007-10-07 05:22:07 +00:00
Dmitry Stogov
6c810b0d4c Improved memory usage by movig constants to read only memory. (Dmitry, Pierre) 2007-09-27 18:00:48 +00:00
Dmitry Stogov
e1814f0dbe WIN64 support 2007-04-16 08:09:56 +00:00
Dmitry Stogov
0291ad5fa6 Fixed bug #40236 (php -a function allocation eats memory) 2007-02-15 10:38:28 +00:00
Sebastian Bergmann
4223aa4d5e MFH: Bump year. 2007-01-01 09:36:18 +00:00
Dmitry Stogov
64e7be9b5a Fixed possible crash in interactive mode 2006-04-10 12:26:53 +00:00
Dmitry Stogov
161ae714ae zend_hash_apply() doesn't use ZEND_HASH_APPLY_... macros 2006-03-14 11:24:45 +00:00
Dmitry Stogov
ad10a538ee Optimized cleanup loops on request shutdown 2006-03-13 11:13:42 +00:00
Andi Gutmans
61e93ccfe8 - Update copyright notices to 2006 2006-01-04 23:53:05 +00:00
Dmitry Stogov
8768ab94b3 Fixed bug #34729 (Crash in ZTS mode under Apache) 2005-12-01 11:48:17 +00:00
Dmitry Stogov
248345d920 Support for class constants and static members for internal classes 2005-09-01 10:05:32 +00:00
foobar
916815b779 Bump up the year 2005-08-03 13:30:58 +00:00
Andi Gutmans
db507dd153 - Commit the variable fetch optimization.
- Extensions which delete global variables need to use new special function
- delete_global_variable() (I'm about to rename it) to remove them.
- Will post to internals@ or via commit messages if there's anything else.
2004-10-04 19:54:35 +00:00
Andi Gutmans
f82ed13625 - Commit new VM architecture. This one allows people (aka Derick) to
- ask the engine to use function handler mode. Will update the README
- about that.
2004-09-23 21:43:32 +00:00
Andi Gutmans
96ab56e146 - Roll back VM commit 2004-09-09 16:47:22 +00:00
Andi Gutmans
8eb8850c90 - Some architectural changes:
a) We specialize opcodes according to op_type fields. Each opcode has to
    be marked with which op_type's it uses.
 b) We support different execution methods. Function handlers, switch()
    and goto dispatching. goto seems to be the fastest but it really
    depends on the compiler and how well it optimizes. I suggest playing
    around with optimization flags.

- Warning: Things might break so keep us posted on how things are going.
  (Dmitry, Andi)
2004-09-08 22:14:12 +00:00
Sara Golemon
d96e7a170c Revert goto opcode 2004-07-29 17:45:31 +00:00
Sara Golemon
5865b3680a Add goto operator by popular request. 2004-07-29 15:23:47 +00:00
Stefan Esser
fb5cb59035 Fixed Zend Function Destructor to use correct TSRM handle. 2004-06-06 08:37:12 +00:00
Zeev Suraski
36a751840d - Abstract methods cannot have defaults for arguments
- Make function foo($a, $b=null) satisfy both foo($a) and foo($a, $b)
  prototypes
2004-02-25 09:25:37 +00:00
foobar
acf7a5e262 ws fix 2004-02-20 06:59:37 +00:00
Zeev Suraski
723641590a Optimize 2004-02-04 15:51:07 +00:00
Zeev Suraski
9e60cb553f Rewrote exception support. Fixes a few limitations and bugs in the old
implementation, and allows exceptions to 'fire' much earlier than before.

Instructions on how to use the new mechanism will follow on internals@
shortly...

Note - this (most probably) breaks the current implementation of
set_exception_handler()
2004-02-03 12:17:09 +00:00
foobar
ccfc46b0aa - Happy new year and PHP 5 for rest of the files too..
# Should the LICENSE and Zend/LICENSE dates be updated too?
2004-01-08 17:33:29 +00:00
Zeev Suraski
6f53e48bb9 This check shouldn't be necessary 2003-08-04 07:52:09 +00:00
Marcus Boerger
1f8fd69e78 Fix crash 2003-08-03 22:28:14 +00:00
Zeev Suraski
f8bbafd604 ntroduce infrastructure for supplying information about arguments,
including:

- Whether or not to pass by ref (replaces the old arg_types, with arg_info)
- Argument name (for future use, maybe introspection)
- Class/Interface name (for type hints)
- If a class/interface name is available, whether to allow a null instance

Both user and builtin functions share the same data structures.

To declare a builtin function that expects its first arg to be an instance
of class 'Person', its second argument as a regular arg, and its third by
reference, use:

ZEND_BEGIN_ARG_INFO(my_func_arg_info, 0)
    ZEND_ARG_OBJ_INFO(0, someone, Person, 1)
    ZEND_ARG_PASS_INFO(0)
    ZEND_ARG_PASS_INFO(1)
ZEND_END_ARG_INFO();

and use my_func_arg_info as the arg_info parameter to the ZEND_FE() family
of macros.

The first arg to each ZEND_ARG_*() macro is whether or not to pass by ref.

The boolean arg to ZEND_BEGIN_ARG_INFO() tells the engine whether to treat
the arguments for which there's no explicit information as pass by reference
or not.
The boolean argument to ZEND_ARG_OBJ_INFO() (4th arg) is whether or not to allownull values.
2003-08-03 17:40:44 +00:00
Stanislav Malyshev
237116aa27 Remove namespace leftovers 2003-07-23 08:58:46 +00:00
Andi Gutmans
288dacca0c - ZE coding style requires if ( instead of if( 2003-06-30 20:22:35 +00:00
James Cox
f68c7ff249 updating license information in the headers. 2003-06-10 20:04:29 +00:00
Stanislav Malyshev
f7f5a5ea6b MEGA-patch: namespaces are R.I.P. 2003-06-02 12:13:11 +00:00
Marcus Boerger
a023c1034b Bugfix #23670: implements and extends cause Apache 2 crash 2003-06-01 17:28:52 +00:00
Sterling Hughes
48b3303217 Patch by Marcus Börger to fix some memleaks 2003-04-18 18:40:53 +00:00
Andrei Zmievski
62f9eb8006 Split ZEND_NAMESPACE into user and internal namespaces. Hope this is
okay with engine folks.
2003-04-01 19:37:04 +00:00
Andrei Zmievski
5657b83691 Multi-purpose patch:
- The fields of zend_namespace were not completely initialized which
   led to a variety of problems.
 - The occurrence of class/interface/namespace definition is now
   captured.
 - Functions/classes/interfaces/namespaces can be preceded by doc
   comments which are stored for use by extensions.
2003-03-31 20:42:01 +00:00
Sebastian Bergmann
3fc852824f Eliminate TSRMLS_FETCH() calls in destroy_op_array() and zend_get_class_entry(). 2003-03-26 07:44:11 +00:00
Zeev Suraski
26dd8492ed Add support for interfaces 2003-03-05 11:14:44 +00:00
Stanislav Malyshev
e645f20d07 Allow namespaces to have a number of parts. I.e., now you can do:
namespace foo {
	function abc() {}
}
...
namespace foo {
	functio def() {}
}
2003-02-20 19:01:53 +00:00
Zeev Suraski
955636af69 Avoid using a C++ reserved word 2003-02-18 17:18:28 +00:00
Stanislav Malyshev
a4c3b2ce80 Namespace patch. Big changes:
1. Nested classes are gone.
2. New syntax for namespaces:
namespace foo {
	class X { ... }
	function bar { ... }
	var x = 1;
	const ZZ = 2;
}
3. Namespaced symbol access: $x = new foo::X; - etc.
For now, namespaces are case insensitive, just like classes.
Also, there can be no global class and namespace with the same name
(to avoid ambiguities in :: resolution).
2003-02-16 11:12:43 +00:00
Zeev Suraski
17439aa9c4 Rework static class properties - now supports access restrictions 2003-02-05 13:35:52 +00:00
Zeev Suraski
471947b188 Reimplement PPP properties 2003-02-04 12:12:34 +00:00
foobar
333406bdc2 - Added some missing CVS $Id$ tags, headers and footers. 2003-02-01 01:49:15 +00:00
Stanislav Malyshev
03f88ac2b2 Add additional stage to post-session cleanup.
We need separate cleanup stage because of the following problem:
Suppose we destroy class X, which destroys function table,
and in function table we have function foo() that has static $bar. Now if
object of class X was assigned to $bar, its destructor will be called and will
fail since X's function table is in mid-destruction.
So we want first of all to clean up all data and then move to tables
destruction.
Note that only run-time accessed data need to be cleaned up, pre-defined
data can not contain objects and thus are not probelmatic.
# Looks like we are having a lots of pain in the various parts of the body
# because of the destructors...
2003-01-29 17:54:48 +00:00
Sebastian Bergmann
2c5d4b8c23 Bump year. 2002-12-31 15:59:15 +00:00
Andi Gutmans
671fff2fde h WHitespace 2002-11-30 11:20:25 +00:00
Andi Gutmans
023836ae25 - Also tune jmpz_ex 2002-10-24 18:24:55 +00:00
Andi Gutmans
80109314b9 - Improve performance of part of the jmps. More to follow. 2002-10-24 18:04:12 +00:00
Andi Gutmans
536d4d8aab - Improve opcode dispatching 2002-10-19 09:45:51 +00:00