Yasuo Ohgaki
yohga****@users*****
2002年 8月 3日 (土) 17:56:17 JST
yohgaki 02/08/03 17:56:17 Modified: . ChangeLog Makefile.am ZEND_CHANGES Zend.dsp Zend.m4 ZendTS.dsp acconfig.h zend.c zend.h zend_API.c zend_API.h zend_alloc.c zend_alloc.h zend_builtin_functions.c zend_compile.c zend_constants.c zend_constants.h zend_execute.c zend_execute.h zend_execute_API.c zend_fast_cache.h zend_globals.h zend_hash.h zend_ini_scanner.l zend_language_parser.y zend_list.h zend_llist.c zend_mm.c zend_modules.h zend_object_handlers.c zend_object_handlers.h zend_objects.c zend_objects.h zend_objects_API.c zend_operators.c zend_ts_hash.c zend_ts_hash.h zend_variables.c zend_variables.h Log: revert recent bogus commits Revision Changes Path 1.8 +0 -308 ZendEngine2/ChangeLog Index: ChangeLog =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/ChangeLog,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- ChangeLog 2 Aug 2002 09:48:15 -0000 1.7 +++ ChangeLog 3 Aug 2002 08:56:16 -0000 1.8 @@ -1,311 +1,3 @@ -2002-07-01 Andi Gutmans <andi****@zend*****> - - * zend_compile.c: - Fix bug when acccessing $this not in class scope. - - * zend_objects.h - zend_objects.c: - Export zend_object_get_address() - -2002-06-30 Andi Gutmans <andi****@zend*****> - - * ZEND_CHANGES: - Remember to document autoload when I have time. - -2002-06-30 Derick Rethans <d.ret****@jdime*****> - - * zend_modules.h: - MFZE1 - -2002-06-29 Andi Gutmans <andi****@zend*****> - - * zend.h: - Get ready for alpha2 - - * zend_execute_API.c: - Invalid -> Undefined - - * zend_language_parser.y: - Add missing semi-colon. - - * zend_execute_API.c - zend_execute.c: - Improve some error messages. - - * zend_compile.c: - Revert previous fix. - - * zend_compile.c: - Change E_ERROR -> E_COMPILE_ERROR where needed. - - * zend_compile.c: - - Fix for bug #17882. We complain if the same method is declared twice. - - * zend.h - zend_operators.c: - Fix bug 15037 - - Bump version to alpha2-dev - -2002-06-28 Andi Gutmans <andi****@zend*****> - - * zend_operators.c: - WS fix - -2002-06-26 Andi Gutmans <andi****@zend*****> - - * zend_execute_API.c: - - Autoloading support based on patch from Ivan Ristic. - - Again I hope this feature ends up working well because if it doesn't we - - might need to nuke it. This only works for global scoped classes and it - - will never work for sub-classes so don't even ask!!!!! - - Just define an __autoload() function in the global scope and it will be - - called with the class name as the parameter if it doesn't manage to find - - the class. - - * zend_API.c - zend_builtin_functions.c - zend_mm.h: - Centralize global class fetch - - * zend_alloc.c - zend_execute.c: - - Fix problem with scope's not changing correctly during method calls. - - Reapply a tiny optimization to the allocator so that in non-debug mode - - we clean memory without detecting leaks. - -2002-06-24 Andi Gutmans <andi****@zend*****> - - * zend_fast_cache.h: - - MFZE1 (Turn off fast cache until we make sure it performs well.) - - * zend_alloc.c: - More fixes (warnings, bug fixes etc.) - - * zend_execute.c: - - Revert patch which checks at run-time if you're allowed to assign - - certain values by reference. - - We still need to find a solution for cases when this shouldn't be allowed - - as it might cause leaks. - - * zend_alloc.c: - Fix crash bug and clean up a bit. - -2002-06-24 Sebastian Bergmann <sb****@sebas*****> - - * Zend.m4: IMHO, ZTS should no longer be labeled experimental. - -2002-06-24 Andi Gutmans <andi****@zend*****> - - * zend_alloc.c: - MFZE1 - - * zend_alloc.c: - Don't use cache if we're using ZEND_MM - - * zend_mm.c: - - Hardcode alignment to 8. We might need a configure check for this. - - * zend_mm.c - zend_mm.h: - Improve memory manager to allocate small blocks quickly. - - * zend_alloc.h - zend_mm.h - zend_alloc.c: - - Don't keep allocated blocks in a linked list if we're in non-debug mode - - as now the memory manager takes care to nuke all leaking blocks. - - * zend.h - zend_types.h: - MFZE1 - -2002-06-23 Andi Gutmans <andi****@zend*****> - - * zend_compile.c - zend_execute.c: - - Fix problem with constructor not being inherited and called correctly. - - * zend_mm.c: - Fix small bug - - * zend_mm.c: - - Almost completely implement realloc(). It now resizes in place when - - possible. - -2002-06-22 Andi Gutmans <andi****@zend*****> - - * zend_alloc.c - zend_mm.c: - Fix crash when zend_mm_shutdown is called more than once. - - * zend_alloc.c - zend_alloc.h - zend_globals.h - zend_language_parser.y: - MFZE1 - - * zend_constants.h - zend_objects.c - zend_variables.c - zend_variables.h - zend_constants.c - zend_alloc.c - zend_alloc.h: - Nuke persist_alloc(). - -2002-06-19 Andi Gutmans <andi****@zend*****> - - * zend_globals.h: - - This was also supposed to be part of the previous ZEND_MM commit :) - - * zend_alloc.c: - - Oops, this was supposed to be part of the previous #ifdef ZEND_MM change - - * zend_mm.h: - Use #ifdef for ZEND_MM - - * zend_mm.c: - Make sure MAX is defined - - * zend_constants.c: - - Fix problem where you couldn't define constants with different cases but - - the same name. - -2002-06-18 Derick Rethans <d.ret****@jdime*****> - - * zend.c: - MFZE1 - -2002-06-17 Andi Gutmans <andi****@zend*****> - - * zend_mm.c: - Improve speed of alignment calculation - - * zend_mm.c - zend_mm.h - zend_alloc.c: - - Fix a bug and add code which frees actual allocated segments at the end - - of execution (this still doesn't work because some blocks remain - - referenced after the memory manager is killed. - - * zend_mm.c - zend_mm.h: - Save space per-allocated block. - -2002-06-16 Andi Gutmans <andi****@zend*****> - - * zend_execute.c - zend_execute.h - zend_execute_API.c: - Fix bug in class constants - - Start centralizing main class lookups. This will help implement - - __autload() - - * zend_mm.c - zend_mm.h: - - Remove debug code which doesn't work anymore and add headers. - - * zend_globals.h - zend_mm.c - zend_mm.h - zend_alloc.c - ZendTS.dsp: - Commit an initial version of a home made memory manager. - - It's just for seeing if this would be an advantage to PHP in MT - - environments. If this is to become production material there is still - - a long way to go. - -2002-06-15 Andi Gutmans <andi****@zend*****> - - * zend_objects.h - zend_objects_API.c: - - Fix copy&paste problem where we allocated according to an old structure - - decleration and not the new one. - -2002-06-11 Andi Gutmans <andi****@zend*****> - - * zend_builtin_functions.c: - - Don't show debug_backtrace() in the trace itself. - - This patch is a bit ugly because the whole code itself is pretty complex - - and hard to re-order. - - * zend_execute.c - zend_language_parser.y: - - Fix problem with assigning functions by reference. - -2002-06-11 Sebastian Bergmann <sb****@sebas*****> - - * RFCs/004.txt: Add __delegate(). - -2002-06-10 Harald Radi <haral****@nme*****> - - * zend_ts_hash.h - zend_ts_hash.c: added TS_HASH macro - -2002-06-10 Stanislav Malyshev <stas****@zend*****> - - * zend_execute.c: Fix leak - -2002-06-09 Harald Radi <haral****@nme*****> - - * zend_API.h - zend_builtin_functions.c - zend_object_handlers.h: - only check for an available class entry instead of - the std_object_handlers on some places - - -2002-06-08 Andi Gutmans <andi****@zend*****> - - * zend_hash.h - zend.h: - This should improve performance on Windows - - * zend_hash.h: - - Add a loop unrolled version of the hash function and a bit of an - - explanation about our hash function (Ralf S. Engelschall) - -2002-06-06 Sebastian Bergmann <sb****@sebas*****> - - * RFCs/004.txt: Add RFC on delegation. - -2002-06-05 Sebastian Bergmann <sb****@sebas*****> - - * zend_execute.c: Remove unused local variable. - -2002-06-05 Andi Gutmans <andi****@zend*****> - - * zend_compile.c - zend_execute.c - zend_object_handlers.c: - - Allow overloaded objects to receive the method name in its original - - case. - -2002-06-05 Derick Rethans <d.ret****@jdime*****> - - * zend_llist.c: - Fix memleak (patch by Stefan Sesser) - -2002-06-04 Derick Rethans <d.ret****@jdime*****> - - * zend_ini_scanner.l: - Fix for bug #17462 (Patch by Edin Kadribasic) - -2002-05-31 Andi Gutmans <andi****@zend*****> - - * ZendTS.dsp: - Add zend_objects_API.* to dsp - - * zend_objects_API.c: - Fix build (one more coming up) - - * zend_objects.c: - Fix build - -2002-05-31 Sebastian Bergmann <sb****@sebas*****> - - * Zend.dsp: Add zend_objects_API.c to project. - -2002-05-31 Stanislav Malyshev <stas****@zend*****> - - * Makefile.am - zend_execute_API.c - zend_globals.h - zend_object_handlers.c - zend_objects.c - zend_objects.h - zend_objects_API.c - zend_objects_API.h: Generalize object storage and reference bookkeeping - -2002-05-30 Venkat Raghavan S <rvenk****@novel*****> - - * zend.h - zend_config.nw.h - acconfig.h: NetWare changes - -2002-05-26 Andi Gutmans <andi****@zend*****> - - * zend_multibyte.c: - - Add empty zend_multibyte.c to allow build with 4.3.0-dev. - -2002-05-24 Sebastian Bergmann <sb****@sebas*****> - - * ZEND_CHANGES: Fugbix typo. - -2002-05-24 Andi Gutmans <andi****@zend*****> - - * ZEND_CHANGES: - Add a bit of information. - -2002-05-20 Zeev Suraski <zeev****@zend*****> - - * zend_API.h - zend_execute.h - zend_list.h: MFZE1 (Expose more C++ APIs) - 2002-05-14 Andi Gutmans <andi****@zend*****> * zend_objects.c 1.4 +1 -2 ZendEngine2/Makefile.am Index: Makefile.am =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/Makefile.am,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- Makefile.am 2 Aug 2002 09:48:15 -0000 1.3 +++ Makefile.am 3 Aug 2002 08:56:16 -0000 1.4 @@ -13,8 +13,7 @@ zend_opcode.c zend_operators.c zend_ptr_stack.c zend_stack.c \ zend_variables.c zend.c zend_API.c zend_extensions.c zend_hash.c \ zend_list.c zend_indent.c zend_builtin_functions.c zend_sprintf.c \ - zend_ini.c zend_qsort.c zend_objects.c zend_object_handlers.c \ - zend_object_API.c + zend_ini.c zend_qsort.c zend_objects.c zend_object_handlers.c libZend_la_LDFLAGS = libZend_la_LIBADD = @ZEND_EXTRA_LIBS@ 1.5 +48 -50 ZendEngine2/ZEND_CHANGES Index: ZEND_CHANGES =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/ZEND_CHANGES,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- ZEND_CHANGES 2 Aug 2002 09:48:15 -0000 1.4 +++ ZEND_CHANGES 3 Aug 2002 08:56:16 -0000 1.5 @@ -19,6 +19,15 @@ the box or after a very small amount of modifications would be high. + [Not sure if the following will be implemented after all] + To simplify migration, the Zend Engine 2.0 supports an optional + 'auto-clone' feature, which performs a cloning of the object + whenever it would have been copied in the Zend Engine 1.0. + Optionally, it emits an E_NOTICE message whenever such an + automatic clone occurs, in order to allow developers to + gradually migrate to the behavior of the Zend Engine 2 (without + automatic clones). + * Private Members. The Zend Engine 2.0 introduces private member variables. Note @@ -59,18 +68,18 @@ duplication, the Zend Engine 1.0 did a bitwise copy making an identical replica of all the object's properties. - Creating a copy of an object with fully replicated properties is - not always the wanted behavior. A good example of the need for + Creating a copy of an object with fully replicated properties is + not always the wanted behavior. A good example of the need for copy constructors, is if you have an object which represents a GTK window and the object holds the resource of this GTK window, when you create a duplicate you might want to create a new window with the same properties and have the new object hold the - resource of the new window. Another example is if your object - holds a reference to another object which it uses and when you - replicate the parent object you want to create a new instance of + resource of the new window. Another example is if your object + holds a reference to another object which it uses and when you + replicate the parent object you want to create a new instance of this other object so that the replica has its own separate copy. - An object copy is created by calling the object's __clone() + An object copy is created by calling the object's __clone() method. Example: @@ -79,15 +88,15 @@ $copy_of_object = $object->__clone(); ?> - When the developer asks to create a new copy of an object, the - Zend Engine will check if a __clone() method has been defined or - not. If not, it will call a default __clone() which will copy - all of the object's properties. If a __clone() method is - defined, then it will be responsible to set the necessary - properties in the created object. For convenience, the engine - will supply a function that imports all of the properties from - the source object, so that they can start with a by-value - replica of the source object, and only override properties that + When the developer asks to create a new copy of an object, the + Zend Engine will check if a __clone() method has been defined or + not. If not, it will call a default __clone() which will copy + all of the object's properties. If a __clone() method is + defined, then it will be responsible to set the necessary + properties in the created object. For convenience, the engine + will supply a function that imports all of the properties from + the source object, so that they can start with a by-value + replica of the source object, and only override properties that need to be changed. [The function hasn't been implemented yet] Example: @@ -134,7 +143,7 @@ script, this script will yield a parser error with the Zend Engine 2.0, since 'delete' is now a reserved word. - * Nested classes (namespaces). + * Namespaces. The Zend Engine 1.0 provided only three scopes: the global scope, the class scope and the function scope. All scopes but @@ -144,31 +153,21 @@ Zend Engine 1.0's scoping methods were inherently limited for solving symbol name collision problems. - The Zend Engine 2.0 introduces the concept of nested classes - to solve the symbol collision problem by making it possible to + The Zend Engine 2.0 introduces the concept of namespaces to + manage the symbol collision problem by making it possible to define multiple symbol tables able to contain all types of - symbols. The Zend Engine is aware of a current class, - defaulting to the global scope. Each class can contain it's - own set of constants, functions and static variables. In order - to access a class's local symbols you can use the self:: class - accessor, for example, you can do self::$my_static_name = "Hello". - You can also use the class's name such as - MyClass::$my_static_name = "Hello". WIth both constants and - functions, if you don't specify a class context the current class - will be searched first and if the search fails then the global - scope will be searched. If you want to force PHP to only check the - global scope you can use the main:: accessor. For example, - main::strlen() to make sure you're calling the strlen() in the main - scope. You will only need to worry about this if you are defining - methods which have the same name as global functions. For - constants you can use the same notation such as self::MY_CONSTANT - or main::MY_CONSTANT. - Sometimes you will not want to access constants, functions or classes - via the class accessor (i.e. MyClass::) because you use them very - often and are an extremely slow typist. In this case, you can import - functions, classes and constants from classes with the import keyword. - It's quite self explanatory and there are a few examples below. - + symbols. The Zend Engine is aware of a current namespace, + defaulting to the current global one. The current namespace may + be changed on a file-by-file basis. Symbols in other namespaces + than the current one may be referenced using a new namespace + operator. + + Namespaces and classes are the same with the Zend Engine 2.0, + except that you can't instantiate a namespace with "new". This + essentially also makes a class a namespace, so the scoping rules + for namespaces apply for classes. Some of the consequences of + this are: [Not finalized. Right now we basically have nested + classes so you can instantiate any nested class] * Classes may contain classes. @@ -189,7 +188,7 @@ function db_connect($user) { print "Connecting to Oracle database '$this->host' as $user\n"; } - } + } $MySQL_obj = new DB::MySQL(); $MySQL_obj->db_connect('Susan'); @@ -253,7 +252,7 @@ $obj->foo(); ?> - This prints "foobar" two times, since a bar() method exists + This prints "foobar" two times, since a bar() method exists in the current namespace. * It is possible to "import" symbols from one namespace into @@ -308,7 +307,7 @@ class MyOuterClass { const Hello = "Hello, World\n"; } - + import const Hello from MyOuterClass; print Hello; ?> @@ -340,14 +339,14 @@ <?php class BaseClass { function __construct() { - print "In BaseClass constructor\n"; + print "In BaseClass constructor\n"; } } class SubClass extends BaseClass { function __construct() { parent::__construct(); - print "In SubClass constructor\n"; + print "In SubClass constructor\n"; } } @@ -390,7 +389,7 @@ function __destruct() { print 'Destroying ' . $this->name . "\n"; - } + } } $obj = new MyDestructableClass(); @@ -442,20 +441,20 @@ Old code that has no user-defined functions 'catch', 'throw' and 'try' will run without modifications. - * Dereferencing objects returned from functions. + * Derefencing objects returned from functions. Example: <?php class Circle { function draw() { - print "Circle\n"; + print "Circle\n"; } } class Square { function draw() { - print "Square\n"; + print "Square\n"; } } @@ -515,7 +514,6 @@ } ?> - * __autoload(). TBD. Changes in the Zend Engine 1.0 1.4 +0 -4 ZendEngine2/Zend.dsp Index: Zend.dsp =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/Zend.dsp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- Zend.dsp 2 Aug 2002 09:48:15 -0000 1.3 +++ Zend.dsp 3 Aug 2002 08:56:16 -0000 1.4 @@ -187,10 +187,6 @@ # End Source File # Begin Source File -SOURCE=.\zend_objects_API.c -# End Source File -# Begin Source File - SOURCE=.\zend_opcode.c # End Source File # Begin Source File 1.4 +2 -2 ZendEngine2/Zend.m4 Index: Zend.m4 =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/Zend.m4,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- Zend.m4 2 Aug 2002 09:48:15 -0000 1.3 +++ Zend.m4 3 Aug 2002 08:56:16 -0000 1.4 @@ -1,5 +1,5 @@ dnl -dnl $Id: Zend.m4,v 1.31 2002/06/24 16:10:33 sebastian Exp $ +dnl $Id: Zend.m4,v 1.30 2002/04/22 11:06:22 sebastian Exp $ dnl dnl This file contains Zend specific autoconf functions. dnl @@ -141,7 +141,7 @@ ZEND_MEMORY_LIMIT=no ]) -AC_MSG_CHECKING(whether to enable thread-safety) +AC_MSG_CHECKING(whether to enable experimental ZTS) AC_MSG_RESULT($ZEND_EXPERIMENTAL_ZTS) AC_MSG_CHECKING(whether to enable inline optimization for GCC) 1.4 +0 -16 ZendEngine2/ZendTS.dsp Index: ZendTS.dsp =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/ZendTS.dsp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- ZendTS.dsp 2 Aug 2002 09:48:15 -0000 1.3 +++ ZendTS.dsp 3 Aug 2002 08:56:16 -0000 1.4 @@ -212,10 +212,6 @@ # End Source File # Begin Source File -SOURCE=.\zend_mm.c -# End Source File -# Begin Source File - SOURCE=.\zend_object_handlers.c # End Source File # Begin Source File @@ -224,10 +220,6 @@ # End Source File # Begin Source File -SOURCE=.\zend_objects_API.c -# End Source File -# Begin Source File - SOURCE=.\zend_opcode.c # End Source File # Begin Source File @@ -372,10 +364,6 @@ # End Source File # Begin Source File -SOURCE=.\zend_mm.h -# End Source File -# Begin Source File - SOURCE=.\zend_modules.h # End Source File # Begin Source File @@ -385,10 +373,6 @@ # Begin Source File SOURCE=.\zend_objects.h -# End Source File -# Begin Source File - -SOURCE=.\zend_objects_API.h # End Source File # Begin Source File 1.4 +0 -4 ZendEngine2/acconfig.h Index: acconfig.h =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/acconfig.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- acconfig.h 2 Aug 2002 09:48:15 -0000 1.3 +++ acconfig.h 3 Aug 2002 08:56:16 -0000 1.4 @@ -2,9 +2,7 @@ #define ZEND_DLEXPORT #define ZEND_DLIMPORT -#ifndef NETWARE @TOP@ -#endif #undef uint #undef ulong @@ -12,9 +10,7 @@ /* Define if you want to enable memory limit support */ #define MEMORY_LIMIT 0 -#ifndef NETWARE @BOTTOM@ -#endif #ifdef HAVE_STDLIB_H # include <stdlib.h> 1.5 +1 -1 ZendEngine2/zend.c Index: zend.c =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- zend.c 2 Aug 2002 09:48:15 -0000 1.4 +++ zend.c 3 Aug 2002 08:56:16 -0000 1.5 @@ -500,7 +500,7 @@ zend_destroy_rsrc_list(&EG(persistent_list) TSRMLS_CC); #endif zend_destroy_rsrc_list_dtors(); - zend_hash_graceful_reverse_destroy(&module_registry); + zend_hash_destroy(&module_registry); #ifndef ZTS /* In ZTS mode these are freed by compiler_globals_dtor() */ 1.6 +18 -19 ZendEngine2/zend.h Index: zend.h =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- zend.h 2 Aug 2002 09:48:15 -0000 1.5 +++ zend.h 3 Aug 2002 08:56:16 -0000 1.6 @@ -17,12 +17,12 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend.h,v 1.175 2002/06/29 19:37:10 andi Exp $ */ +/* $Id: zend.h,v 1.170 2002/05/02 17:20:48 andi Exp $ */ #ifndef ZEND_H #define ZEND_H -#define ZEND_VERSION "2.0.0-alpha2" +#define ZEND_VERSION "2.0.0-dev" #define ZEND_ENGINE_2 #define ZEND_MULTIBYTE @@ -44,9 +44,6 @@ #ifdef ZEND_WIN32 # include "zend_config.w32.h" # define ZEND_PATHS_SEPARATOR ';' -#elif defined(NETWARE) -# include "zend_config.nw.h" -# include "acconfig.h" #elif defined(__riscos__) # include "zend_config.h" # define ZEND_PATHS_SEPARATOR ';' @@ -55,18 +52,6 @@ # define ZEND_PATHS_SEPARATOR ':' #endif - -#ifdef ZEND_WIN32 -/* Only use this macro if you know for sure that all of the switches values - are covered by its case statements */ -#define EMPTY_SWITCH_DEFAULT_CASE() \ - default: \ - __assume(0); \ - break; -#else -#define EMPTY_SWITCH_DEFAULT_CASE() -#endif - /* all HAVE_XXX test have to be after the include of zend_config above */ #ifdef HAVE_UNIX_H @@ -134,7 +119,7 @@ # endif #endif -#if (HAVE_ALLOCA || (defined (__GNUC__) && __GNUC__ >= 2)) && !(defined(ZTS) && defined(ZEND_WIN32)) && !(defined(ZTS) && defined(NETWARE)) +#if (HAVE_ALLOCA || (defined (__GNUC__) && __GNUC__ >= 2)) && !(defined(ZTS) && defined(ZEND_WIN32)) # define do_alloca(p) alloca(p) # define free_alloca(p) #else @@ -179,7 +164,11 @@ #include "zend_errors.h" #include "zend_alloc.h" -#include "zend_types.h" +typedef unsigned char zend_bool; +typedef unsigned char zend_uchar; +typedef unsigned int zend_uint; +typedef unsigned long zend_ulong; +typedef unsigned short zend_ushort; #ifdef HAVE_LIMITS_H # include <limits.h> @@ -550,6 +539,16 @@ #define ZEND_MAX_RESERVED_RESOURCES 4 +#ifdef ZEND_WIN32 +/* Only use this macro if you know for sure that all of the switches values + are covered by its case statements */ +#define EMPTY_SWITCH_DEFAULT_CASE() \ + default: \ + __assume(0); \ + break; +#else +#define EMPTY_SWITCH_DEFAULT_CASE() +#endif #endif /* ZEND_H */ 1.5 +1 -1 ZendEngine2/zend_API.c Index: zend_API.c =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_API.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- zend_API.c 2 Aug 2002 09:48:15 -0000 1.4 +++ zend_API.c 3 Aug 2002 08:56:16 -0000 1.5 @@ -1362,7 +1362,7 @@ lcname = estrndup(Z_STRVAL_PP(obj), Z_STRLEN_PP(obj)); zend_str_tolower(lcname, Z_STRLEN_PP(obj)); - if (zend_lookup_class(lcname, Z_STRLEN_PP(obj), &pce TSRMLS_CC) == SUCCESS) { + if(zend_hash_find(EG(class_table), lcname, Z_STRLEN_PP(obj) + 1, (void**)&pce) == SUCCESS) { ce = *pce; } 1.5 +13 -5 ZendEngine2/zend_API.h Index: zend_API.h =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_API.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- zend_API.h 2 Aug 2002 09:48:15 -0000 1.4 +++ zend_API.h 3 Aug 2002 08:56:16 -0000 1.5 @@ -29,8 +29,6 @@ #include "zend_variables.h" #include "zend_execute.h" - -BEGIN_EXTERN_C() #define ZEND_FN(name) zif_##name #define ZEND_NAMED_FUNCTION(name) void name(INTERNAL_FUNCTION_PARAMETERS) #define ZEND_FUNCTION(name) ZEND_NAMED_FUNCTION(ZEND_FN(name)) @@ -84,7 +82,19 @@ -#define INIT_CLASS_ENTRY(class_container, class_name, functions) INIT_OVERLOADED_CLASS_ENTRY(class_container, class_name, functions, NULL, NULL, NULL) +#define INIT_CLASS_ENTRY(class_container, class_name, functions) \ + { \ + class_container.name = strdup(class_name); \ + class_container.name_length = sizeof(class_name)-1; \ + class_container.builtin_functions = functions; \ + class_container.constructor = NULL; \ + class_container.destructor = NULL; \ + class_container.clone = NULL; \ + class_container.create_object = NULL; \ + class_container.handle_function_call = NULL; \ + class_container.handle_property_get = NULL; \ + class_container.handle_property_set = NULL; \ + } #define INIT_OVERLOADED_CLASS_ENTRY(class_container, class_name, functions, handle_fcall, handle_propget, handle_propset) \ { \ @@ -416,8 +426,6 @@ #define ZEND_RSHUTDOWN_FUNCTION ZEND_MODULE_DEACTIVATE_D #define ZEND_MINFO_FUNCTION ZEND_MODULE_INFO_D -END_EXTERN_C() - #endif /* ZEND_API_H */ 1.4 +85 -72 ZendEngine2/zend_alloc.c Index: zend_alloc.c =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_alloc.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- zend_alloc.c 2 Aug 2002 09:48:15 -0000 1.3 +++ zend_alloc.c 3 Aug 2002 08:56:16 -0000 1.4 @@ -31,24 +31,15 @@ # include <unistd.h> #endif -#include "zend_mm.h" - #ifndef ZTS ZEND_API zend_alloc_globals alloc_globals; #endif -#ifdef ZEND_MM -#define ZEND_DISABLE_MEMORY_CACHE 1 -#else #define ZEND_DISABLE_MEMORY_CACHE 0 -#endif -#ifdef ZEND_MM -#define ZEND_DO_MALLOC(size) zend_mm_alloc(&AG(mm_heap), size) -#define ZEND_DO_FREE(ptr) zend_mm_free(&AG(mm_heap), ptr) -#define ZEND_DO_REALLOC(ptr, size) zend_mm_realloc(&AG(mm_heap), ptr, size) -#elif defined(ZEND_WIN32) + +#ifdef ZEND_WIN32 #define ZEND_DO_MALLOC(size) (AG(memory_heap) ? HeapAlloc(AG(memory_heap), HEAP_NO_SERIALIZE, size) : malloc(size)) #define ZEND_DO_FREE(ptr) (AG(memory_heap) ? HeapFree(AG(memory_heap), HEAP_NO_SERIALIZE, ptr) : free(ptr)) #define ZEND_DO_REALLOC(ptr, size) (AG(memory_heap) ? HeapReAlloc(AG(memory_heap), HEAP_NO_SERIALIZE, ptr, size) : realloc(ptr, size)) @@ -97,8 +88,10 @@ #define REMOVE_POINTER_FROM_LIST(p) \ - if (p==AG(head)) { \ + if (!p->persistent && p==AG(head)) { \ AG(head) = p->pNext; \ + } else if (p->persistent && p==AG(phead)) { \ + AG(phead) = p->pNext; \ } else { \ p->pLast->pNext = p->pNext; \ } \ @@ -107,11 +100,19 @@ } #define ADD_POINTER_TO_LIST(p) \ - p->pNext = AG(head); \ - if (AG(head)) { \ - AG(head)->pLast = p; \ - } \ - AG(head) = p; \ + if (p->persistent) { \ + p->pNext = AG(phead); \ + if (AG(phead)) { \ + AG(phead)->pLast = p; \ + } \ + AG(phead) = p; \ + } else { \ + p->pNext = AG(head); \ + if (AG(head)) { \ + AG(head)->pLast = p; \ + } \ + AG(head) = p; \ + } \ p->pLast = (zend_mem_header *) NULL; #define DECLARE_CACHE_VARS() \ @@ -151,6 +152,7 @@ AG(cache_stats)[CACHE_INDEX][1]++; memcpy((((char *) p) + sizeof(zend_mem_header) + MEM_HEADER_PADDING + size), &mem_block_end_magic, sizeof(long)); #endif + p->persistent = 0; p->cached = 0; p->size = size; return (void *)((char *)p + sizeof(zend_mem_header) + MEM_HEADER_PADDING); @@ -175,10 +177,8 @@ HANDLE_UNBLOCK_INTERRUPTIONS(); return (void *)p; } - p->cached = 0; -#if ZEND_DEBUG || !defined(ZEND_MM) + p->persistent = p->cached = 0; ADD_POINTER_TO_LIST(p); -#endif p->size = size; /* Save real size for correct cache output */ #if ZEND_DEBUG p->filename = __zend_filename; @@ -228,7 +228,7 @@ #endif if (!ZEND_DISABLE_MEMORY_CACHE - && (CACHE_INDEX < MAX_CACHED_MEMORY) && (AG(cache_count)[CACHE_INDEX] < MAX_CACHED_ENTRIES)) { + && !p->persistent && (CACHE_INDEX < MAX_CACHED_MEMORY) && (AG(cache_count)[CACHE_INDEX] < MAX_CACHED_ENTRIES)) { AG(cache)[CACHE_INDEX][AG(cache_count)[CACHE_INDEX]++] = p; p->cached = 1; #if ZEND_DEBUG @@ -237,9 +237,7 @@ return; } HANDLE_BLOCK_INTERRUPTIONS(); -#if ZEND_DEBUG || !defined(ZEND_MM) REMOVE_POINTER_FROM_LIST(p); -#endif #if MEMORY_LIMIT AG(allocated_memory) -= SIZE; @@ -296,9 +294,7 @@ CALCULATE_REAL_SIZE_AND_CACHE_INDEX(size); HANDLE_BLOCK_INTERRUPTIONS(); -#if ZEND_DEBUG || !defined(ZEND_MM) REMOVE_POINTER_FROM_LIST(p); -#endif p = (zend_mem_header *) ZEND_DO_REALLOC(p, sizeof(zend_mem_header)+MEM_HEADER_PADDING+SIZE+END_MAGIC_SIZE); if (!p) { if (!allow_failure) { @@ -309,15 +305,11 @@ exit(1); #endif } -#if ZEND_DEBUG || !defined(ZEND_MM) ADD_POINTER_TO_LIST(orig); -#endif HANDLE_UNBLOCK_INTERRUPTIONS(); return (void *)NULL; } -#if ZEND_DEBUG || !defined(ZEND_MM) ADD_POINTER_TO_LIST(p); -#endif #if ZEND_DEBUG p->filename = __zend_filename; p->lineno = __zend_lineno; @@ -404,7 +396,14 @@ ZEND_API void start_memory_manager(TSRMLS_D) { - AG(head) = NULL; +#if 0 +#ifndef ZTS + int i, j; + void *cached_entries[MAX_CACHED_MEMORY][MAX_CACHED_ENTRIES]; +#endif +#endif + + AG(phead) = AG(head) = NULL; #if MEMORY_LIMIT AG(memory_limit) = 1<<30; /* ridiculous limit, effectively no limit */ @@ -413,19 +412,32 @@ AG(allocated_memory_peak) = 0; #endif -#if ZEND_ENABLE_FAST_CACHE memset(AG(fast_cache_list_head), 0, sizeof(AG(fast_cache_list_head))); -#endif -#if !ZEND_DISABLE_MEMORY_CACHE memset(AG(cache_count), 0, sizeof(AG(cache_count))); -#endif -#ifdef ZEND_MM - zend_mm_startup(&AG(mm_heap), 256*1024); -#elif defined(ZEND_WIN32) +#ifdef ZEND_WIN32 AG(memory_heap) = HeapCreate(HEAP_NO_SERIALIZE, 256*1024, 0); #endif +#if 0 +#ifndef ZTS + /* Initialize cache, to prevent fragmentation */ + /* We can't do this in ZTS mode, because calling emalloc() from within start_memory_manager() + * will yield an endless recursion calling to alloc_globals_ctor() + */ + for (i=1; i<MAX_CACHED_MEMORY; i++) { + for (j=0; j<PRE_INIT_CACHE_ENTRIES; j++) { + cached_entries[i][j] = emalloc(8*i); + } + } + for (i=1; i<MAX_CACHED_MEMORY; i++) { + for (j=0; j<PRE_INIT_CACHE_ENTRIES; j++) { + efree(cached_entries[i][j]); + } + } +#endif +#endif + #if ZEND_DEBUG memset(AG(cache_stats), 0, sizeof(AG(cache_stats))); memset(AG(fast_cache_stats), 0, sizeof(AG(fast_cache_stats))); @@ -436,43 +448,30 @@ ZEND_API void shutdown_memory_manager(int silent, int clean_cache TSRMLS_DC) { zend_mem_header *p, *t; - + unsigned int fci, i, j; #if ZEND_DEBUG int had_leaks = 0; #endif + zend_fast_cache_list_entry *fast_cache_list_entry, *next_fast_cache_list_entry; -#if defined(ZEND_MM) && !ZEND_DEBUG - if (clean_cache) { - zend_mm_shutdown(&AG(mm_heap)); - return; - } -#elif defined(ZEND_WIN32) && !ZEND_DEBUG +#if defined(ZEND_WIN32) && !ZEND_DEBUG if (clean_cache && AG(memory_heap)) { HeapDestroy(AG(memory_heap)); return; } #endif -#if ZEND_ENABLE_FAST_CACHE - { - zend_fast_cache_list_entry *fast_cache_list_entry, *next_fast_cache_list_entry; - unsigned int fci; - - for (fci=0; fci<MAX_FAST_CACHE_TYPES; fci++) { - fast_cache_list_entry = AG(fast_cache_list_head)[fci]; - while (fast_cache_list_entry) { - next_fast_cache_list_entry = fast_cache_list_entry->next; - efree(fast_cache_list_entry); - fast_cache_list_entry = next_fast_cache_list_entry; - } - AG(fast_cache_list_head)[fci] = NULL; + for (fci=0; fci<MAX_FAST_CACHE_TYPES; fci++) { + fast_cache_list_entry = AG(fast_cache_list_head)[fci]; + while (fast_cache_list_entry) { + next_fast_cache_list_entry = fast_cache_list_entry->next; + efree(fast_cache_list_entry); + fast_cache_list_entry = next_fast_cache_list_entry; } + AG(fast_cache_list_head)[fci] = NULL; } -#endif /* ZEND_ENABLE_FAST_CACHE */ -#if !ZEND_DISABLE_MEMORY_CACHE if (1 || clean_cache) { - unsigned int i, j; zend_mem_header *ptr; for (i=1; i<MAX_CACHED_MEMORY; i++) { @@ -487,9 +486,7 @@ AG(cache_count)[i] = 0; } } -#endif /* !ZEND_DISABLE_MEMORY_CACHE */ -#if ZEND_DEBUG || !defined(ZEND_MM) p = AG(head); t = AG(head); while (t) { @@ -574,21 +571,14 @@ } } while (0); -#endif -#endif - -#if defined(ZEND_MM) && ZEND_DEBUG - if (clean_cache) { - zend_mm_shutdown(&AG(mm_heap)); - return; - } -#elif defined(ZEND_WIN32) && ZEND_DEBUG +#if defined(ZEND_WIN32) && ZEND_DEBUG if (clean_cache && AG(memory_heap)) { HeapDestroy(AG(memory_heap)); - return; } #endif + +#endif } @@ -745,6 +735,29 @@ zend_debug_alloc_output("------------------------------------------------\n"); } #endif + + +ZEND_API int _persist_alloc(void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) +{ + zend_mem_header *p = (zend_mem_header *) ((char *)ptr-sizeof(zend_mem_header)-MEM_HEADER_PADDING); + TSRMLS_FETCH(); + +#if ZEND_DEBUG + _mem_block_check(ptr, 1 ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC); +#endif + + HANDLE_BLOCK_INTERRUPTIONS(); + + /* remove the block from the non persistent list */ + REMOVE_POINTER_FROM_LIST(p); + + p->persistent = 1; + + /* add the block to the persistent list */ + ADD_POINTER_TO_LIST(p); + HANDLE_UNBLOCK_INTERRUPTIONS(); + return REAL_SIZE(p->size)+sizeof(zend_mem_header)+MEM_HEADER_PADDING; +} /* 1.4 +5 -5 ZendEngine2/zend_alloc.h Index: zend_alloc.h =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_alloc.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- zend_alloc.h 2 Aug 2002 09:48:15 -0000 1.3 +++ zend_alloc.h 3 Aug 2002 08:56:16 -0000 1.4 @@ -26,8 +26,6 @@ #include "../TSRM/TSRM.h" #include "zend_globals_macros.h" -#include "zend_mm.h" - #define MEM_BLOCK_START_MAGIC 0x7312F8DCL #define MEM_BLOCK_END_MAGIC 0x2A8FCC84L #define MEM_BLOCK_FREED_MAGIC 0x99954317L @@ -45,11 +43,10 @@ THREAD_T thread_id; # endif #endif -#if ZEND_DEBUG || !defined(ZEND_MM) struct _zend_mem_header *pNext; struct _zend_mem_header *pLast; -#endif - unsigned int size:31; + unsigned int size:30; + unsigned int persistent:1; unsigned int cached:1; } zend_mem_header; @@ -82,6 +79,7 @@ ZEND_API void *_erealloc(void *ptr, size_t size, int allow_failure ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC); ZEND_API char *_estrdup(const char *s ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC); ZEND_API char *_estrndup(const char *s, unsigned int length ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC); +ZEND_API int _persist_alloc(void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC); /* Standard wrapper macros */ #define emalloc(size) _emalloc((size) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC) @@ -91,6 +89,7 @@ #define erealloc_recoverable(ptr, size) _erealloc((ptr), (size), 1 ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC) #define estrdup(s) _estrdup((s) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC) #define estrndup(s, length) _estrndup((s), (length) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC) +#define persist_alloc(p) _persist_alloc((p) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC) /* Relay wrapper macros */ #define emalloc_rel(size) _emalloc((size) ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_CC) @@ -100,6 +99,7 @@ #define erealloc_recoverable_rel(ptr, size) _erealloc((ptr), (size), 1 ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_CC) #define estrdup_rel(s) _estrdup((s) ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_CC) #define estrndup_rel(s, length) _estrndup((s), (length) ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_CC) +#define persist_alloc_rel(p) _persist_alloc((p) ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_CC) /* Selective persistent/non persistent allocation macros */ #define pemalloc(size, persistent) ((persistent)?malloc(size):emalloc(size)) 1.7 +15 -21 ZendEngine2/zend_builtin_functions.c Index: zend_builtin_functions.c =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_builtin_functions.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- zend_builtin_functions.c 2 Aug 2002 09:48:15 -0000 1.6 +++ zend_builtin_functions.c 3 Aug 2002 08:56:16 -0000 1.7 @@ -559,7 +559,7 @@ SEPARATE_ZVAL(arg); zend_str_tolower(Z_STRVAL_PP(arg), Z_STRLEN_PP(arg)); - if (zend_lookup_class(Z_STRVAL_PP(arg), Z_STRLEN_PP(arg), &pce TSRMLS_CC) == SUCCESS) { + if(zend_hash_find(EG(class_table), Z_STRVAL_PP(arg), Z_STRLEN_PP(arg)+1, (void **)&pce) == SUCCESS) { ce = *pce; } } @@ -588,7 +588,7 @@ } /* TBI!! new object handlers */ - if(!HAS_CLASS_ENTRY(**obj)) { + if(!IS_ZEND_STD_OBJECT(**obj)) { RETURN_FALSE; } @@ -647,7 +647,7 @@ lcname = estrndup((*class_name)->value.str.val, (*class_name)->value.str.len); zend_str_tolower(lcname, (*class_name)->value.str.len); - if (zend_lookup_class(lcname, Z_STRLEN_PP(class_name), &pce TSRMLS_CC) == FAILURE) { + if (zend_hash_find(EG(class_table), lcname, (*class_name)->value.str.len+1, (void **)&pce) == FAILURE) { efree(lcname); RETURN_FALSE; } else { @@ -706,15 +706,14 @@ if (Z_TYPE_PP(class) == IS_OBJECT) { /* TBI!! new object handlers */ - if(!HAS_CLASS_ENTRY(**class)) { + if(!IS_ZEND_STD_OBJECT(**class)) { RETURN_FALSE; } ce = Z_OBJCE_PP(class); } else if (Z_TYPE_PP(class) == IS_STRING) { SEPARATE_ZVAL(class); zend_str_tolower(Z_STRVAL_PP(class), Z_STRLEN_PP(class)); - - if (zend_lookup_class(Z_STRVAL_PP(class), Z_STRLEN_PP(class), &pce TSRMLS_CC) == SUCCESS) { + if(zend_hash_find(EG(class_table), Z_STRVAL_PP(class), Z_STRLEN_PP(class)+1, (void **)&pce) == SUCCESS) { ce = *pce; } } @@ -752,7 +751,7 @@ } /* TBI!! new object handlers */ - if(!HAS_CLASS_ENTRY(**klass)) { + if(!IS_ZEND_STD_OBJECT(**klass)) { RETURN_FALSE; } @@ -1199,7 +1198,6 @@ char *class_name; zend_uint class_name_length; zval *stack_frame; - zend_bool first_time = 1; ptr = EG(current_execute_data); lineno = ptr->opline->lineno; @@ -1232,19 +1230,15 @@ filename = ptr->function_state.function->op_array.filename; - if (!first_time) { /* Skip the first context which is debug_backtrace() itself */ - add_assoc_string_ex(stack_frame, "function", sizeof("function"), function_name, 1); - if (class_name) { - add_assoc_string_ex(stack_frame, "class", sizeof("class"), class_name, 1); - } - add_assoc_string_ex(stack_frame, "file", sizeof("file"), filename, 1); - add_assoc_long_ex(stack_frame, "line", sizeof("line"), lineno); - /* add_assoc_stringl_ex(stack_frame, "class", sizeof("class")-1, class_name, class_name_length, 1); */ - - add_next_index_zval(return_value, stack_frame); - } else { - first_time = 0; - } + add_assoc_string_ex(stack_frame, "function", sizeof("function"), function_name, 1); + if (class_name) { + add_assoc_string_ex(stack_frame, "class", sizeof("class"), class_name, 1); + } + add_assoc_string_ex(stack_frame, "file", sizeof("file"), filename, 1); + add_assoc_long_ex(stack_frame, "line", sizeof("line"), lineno); + /* add_assoc_stringl_ex(stack_frame, "class", sizeof("class")-1, class_name, class_name_length, 1); */ + + add_next_index_zval(return_value, stack_frame); if (ptr->opline) { lineno = ptr->opline->lineno; 1.4 +28 -31 ZendEngine2/zend_compile.c Index: zend_compile.c =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_compile.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- zend_compile.c 2 Aug 2002 09:48:15 -0000 1.3 +++ zend_compile.c 3 Aug 2002 08:56:16 -0000 1.4 @@ -243,7 +243,7 @@ opline->opcode = ZEND_ASSIGN_BW_XOR_OBJ; break; default: - zend_error(E_COMPILE_ERROR, "Unknown binary op opcode %d", op); + zend_error(E_ERROR, "Unknown binary op opcode %d", op); } opline->op2 = last_op->op2; @@ -632,10 +632,10 @@ zend_uint type = variable->u.EA.type; if (type & ZEND_PARSED_METHOD_CALL) { - zend_error(E_COMPILE_ERROR, "Can't use method return value in write context"); + zend_error(E_ERROR, "Can't use method return value in write context"); } if (type == ZEND_PARSED_FUNCTION_CALL) { - zend_error(E_COMPILE_ERROR, "Can't use function return value in write context"); + zend_error(E_ERROR, "Can't use function return value in write context"); } } @@ -717,6 +717,11 @@ zend_op *opline, *opline_ptr; int num_of_created_opcodes = 0; + /* + if (zend_variable_buffer_empty(TSRMLS_C) && (type == BP_VAR_W || type == BP_VAR_RW)) { + zend_error(E_ERROR, "Method can't be used as l-value"); + } + */ zend_stack_top(&CG(bp_stack), (void **) &fetch_list_ptr); le = fetch_list_ptr->head; @@ -1076,6 +1081,8 @@ last_op->extended_value = ZEND_FETCH_FROM_THIS; } + zend_lowercase_znode_if_const(&last_op->op2); + left_bracket->u.constant.value.lval = ZEND_INIT_FCALL_BY_NAME; zend_stack_push(&CG(function_call_stack), (void *) &ptr, sizeof(zend_function *)); @@ -1179,7 +1186,7 @@ if (is_method && function_name && function_name->u.constant.value.lval == ZEND_CLONE) { if (argument_list->u.constant.value.lval > 0) { - zend_error(E_COMPILE_ERROR, "Can't pass arguments to __clone()"); + zend_error(E_ERROR, "Can't pass arguments to __clone()"); } /* FIXME: throw_list */ zend_stack_del_top(&CG(function_call_stack)); @@ -1404,7 +1411,7 @@ opline->op2.u.opline_num = *catch_opline; break; default: - zend_error(E_COMPILE_ERROR, "Bad opcode in throw list"); + zend_error(E_ERROR, "Bad opcode in throw list"); break; } } @@ -1471,25 +1478,16 @@ static void do_inherit_parent_constructor(zend_class_entry *ce) { - zend_function *function; - - if (!ce->parent || ce->constructor) { - return; - } + if (ce->parent + && !zend_hash_exists(&ce->function_table, ce->name, ce->name_length+1)) { + zend_function *function; - if (!zend_hash_exists(&ce->function_table, ce->name, ce->name_length+1)) { if (zend_hash_find(&ce->parent->function_table, ce->parent->name, ce->parent->name_length+1, (void **) &function)==SUCCESS) { /* inherit parent's constructor */ zend_hash_update(&ce->function_table, ce->name, ce->name_length+1, function, sizeof(zend_function), NULL); function_add_ref(function); } } - if (zend_hash_find(&ce->parent->function_table, ZEND_CONSTRUCTOR_FUNC_NAME, sizeof(ZEND_CONSTRUCTOR_FUNC_NAME), (void **) &function)==SUCCESS) { - /* inherit parent's constructor */ - zend_hash_update(&ce->function_table, ZEND_CONSTRUCTOR_FUNC_NAME, sizeof(ZEND_CONSTRUCTOR_FUNC_NAME), function, sizeof(zend_function), NULL); - function_add_ref(function); - } - ce->constructor = ce->parent->constructor; } void zend_do_inheritance(zend_class_entry *ce, zend_class_entry *parent_ce) @@ -1547,7 +1545,7 @@ new_class_entry->parent = NULL; if (zend_hash_update(class_table, new_class_entry->name, name_length+1, &new_class_entry, sizeof(zend_class_entry *), NULL) == FAILURE) { - zend_error(E_COMPILE_ERROR, "Can't create class. Fatal error, please report!"); + zend_error(E_ERROR, "Can't create class. Fatal error, please report!"); } } @@ -1586,7 +1584,7 @@ new_ce->refcount++; if (zend_hash_add(&ce->class_table, last, strlen(last)+1, &new_ce, sizeof(zend_class_entry *), NULL) == FAILURE) { new_ce->refcount--; - zend_error(E_COMPILE_ERROR, "Cannot redeclare class %s", last); + zend_error(E_ERROR, "Cannot redeclare class %s", last); return FAILURE; } return SUCCESS; @@ -2089,7 +2087,7 @@ if (CG(active_class_entry)) { if (runtime_inheritance) { - zend_error(E_COMPILE_ERROR, "Only first level classes can inherit from undefined classes"); + zend_error(E_ERROR, "Only first level classes can inherit from undefined classes"); } zend_hash_update(&CG(active_class_entry)->class_table, new_class_entry->name, new_class_entry->name_length+1, &new_class_entry, sizeof(zend_class_entry *), NULL); CG(active_class_entry) = new_class_entry; @@ -2216,18 +2214,17 @@ SET_UNUSED(opline_ptr->op2); opline_ptr->op2.u.EA.type = ZEND_FETCH_FROM_THIS; - if (CG(active_class_entry)) { - if ((opline_ptr->op1.op_type == IS_CONST) && zend_hash_exists(&CG(active_class_entry)->private_properties, opline_ptr->op1.u.constant.value.str.val, opline_ptr->op1.u.constant.value.str.len+1)) { - char *priv_name; - int priv_name_length; - - mangle_private_property_name(&priv_name, &priv_name_length, CG(active_class_entry)->name, CG(active_class_entry)->name_length, opline_ptr->op1.u.constant.value.str.val, opline_ptr->op1.u.constant.value.str.len); - - STR_FREE(opline_ptr->op1.u.constant.value.str.val); - opline_ptr->op1.u.constant.value.str.val = priv_name; - opline_ptr->op1.u.constant.value.str.len = priv_name_length; - } + if ((opline_ptr->op1.op_type == IS_CONST) && zend_hash_exists(&CG(active_class_entry)->private_properties, opline_ptr->op1.u.constant.value.str.val, opline_ptr->op1.u.constant.value.str.len+1)) { + char *priv_name; + int priv_name_length; + + mangle_private_property_name(&priv_name, &priv_name_length, CG(active_class_entry)->name, CG(active_class_entry)->name_length, opline_ptr->op1.u.constant.value.str.val, opline_ptr->op1.u.constant.value.str.len); + + STR_FREE(opline_ptr->op1.u.constant.value.str.val); + opline_ptr->op1.u.constant.value.str.val = priv_name; + opline_ptr->op1.u.constant.value.str.len = priv_name_length; } + *result = opline_ptr->result; return; } 1.4 +25 -28 ZendEngine2/zend_constants.c Index: zend_constants.c =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_constants.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- zend_constants.c 2 Aug 2002 09:48:15 -0000 1.3 +++ zend_constants.c 3 Aug 2002 08:56:16 -0000 1.4 @@ -27,7 +27,8 @@ void free_zend_constant(zend_constant *c) { - if (!(c->flags & CONST_PERSISTENT)) { + if (!(c->flags & CONST_PERSISTENT) + || (c->flags & CONST_EFREE_PERSISTENT)) { zval_dtor(&c->value); } free(c->name); @@ -39,6 +40,9 @@ c->name = zend_strndup(c->name, c->name_len); if (!(c->flags & CONST_PERSISTENT)) { zval_copy_ctor(&c->value); + if (c->flags & CONST_EFREE_PERSISTENT) { /* persist_alloc()'d data */ + persist_alloc(&c->value); + } } } @@ -216,27 +220,26 @@ { zend_constant *c; char *lookup_name; - int retval = 1; + int retval; - if (zend_hash_find(EG(zend_constants), name, name_len+1, (void **) &c) == FAILURE) { - lookup_name = do_alloca(name_len+1); - memcpy(lookup_name, name, name_len+1); - zend_str_tolower(lookup_name, name_len); - - if (zend_hash_find(EG(zend_constants), lookup_name, name_len+1, (void **) &c)==SUCCESS) { - if ((c->flags & CONST_CS) && memcmp(c->name, name, name_len)!=0) { - retval=0; - } - } else { + lookup_name = do_alloca(name_len+1); + memcpy(lookup_name, name, name_len+1); + + zend_str_tolower(lookup_name, name_len); + + if (zend_hash_find(EG(zend_constants), lookup_name, name_len+1, (void **) &c)==SUCCESS) { + if ((c->flags & CONST_CS) && memcmp(c->name, name, name_len)!=0) { retval=0; + } else { + retval=1; + *result = c->value; + zval_copy_ctor(result); } - free_alloca(lookup_name); + } else { + retval=0; } - if (retval) { - *result = c->value; - zval_copy_ctor(result); - } + free_alloca(lookup_name); return retval; } @@ -244,30 +247,24 @@ ZEND_API int zend_register_constant(zend_constant *c TSRMLS_DC) { - char *lowercase_name; + char *lowercase_name = zend_strndup(c->name, c->name_len); int ret = SUCCESS; #if 0 printf("Registering constant for module %d\n", c->module_number); #endif - lowercase_name = do_alloca(c->name_len); - - memcpy(lowercase_name, c->name, c->name_len); - - if (!(c->flags & CONST_CS)) { - zend_str_tolower(lowercase_name, c->name_len); - } - + zend_str_tolower(lowercase_name, c->name_len); if (zend_hash_add(EG(zend_constants), lowercase_name, c->name_len, (void *) c, sizeof(zend_constant), NULL)==FAILURE) { free(c->name); - if (!(c->flags & CONST_PERSISTENT)) { + if (!(c->flags & CONST_PERSISTENT) + || (c->flags & CONST_EFREE_PERSISTENT)) { zval_dtor(&c->value); } zend_error(E_NOTICE,"Constant %s already defined", lowercase_name); ret = FAILURE; } - free_alloca(lowercase_name); + free(lowercase_name); return ret; } 1.4 +4 -0 ZendEngine2/zend_constants.h Index: zend_constants.h =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_constants.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- zend_constants.h 2 Aug 2002 09:48:15 -0000 1.3 +++ zend_constants.h 3 Aug 2002 08:56:16 -0000 1.4 @@ -25,6 +25,10 @@ #define CONST_CS (1<<0) /* Case Sensitive */ #define CONST_PERSISTENT (1<<1) /* Persistent */ +#define CONST_EFREE_PERSISTENT (1<<2) /* In conjunction with CONST_PERSISTENT, + * means that the constant should be freed + * using zval_dtor() on shutdown. + */ typedef struct _zend_constant { zval value; 1.7 +29 -17 ZendEngine2/zend_execute.c Index: zend_execute.c =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_execute.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- zend_execute.c 2 Aug 2002 09:48:15 -0000 1.6 +++ zend_execute.c 3 Aug 2002 08:56:16 -0000 1.7 @@ -307,7 +307,6 @@ *retval = EG(uninitialized_zval_ptr); SELECTIVE_PZVAL_LOCK(*retval, result); - PZVAL_UNLOCK(value); return; } @@ -1552,12 +1551,8 @@ } NEXT_OPCODE(); case ZEND_ASSIGN_REF: - { - zval **value_ptr_ptr = get_zval_ptr_ptr(&EX(opline)->op2, EX(Ts), BP_VAR_W); - - zend_assign_to_variable_reference(&EX(opline)->result, get_zval_ptr_ptr(&EX(opline)->op1, EX(Ts), BP_VAR_W), value_ptr_ptr, EX(Ts) TSRMLS_CC); - NEXT_OPCODE(); - } + zend_assign_to_variable_reference(&EX(opline)->result, get_zval_ptr_ptr(&EX(opline)->op1, EX(Ts), BP_VAR_W), get_zval_ptr_ptr(&EX(opline)->op2, EX(Ts), BP_VAR_W), EX(Ts) TSRMLS_CC); + NEXT_OPCODE(); case ZEND_JMP: #if DEBUG_ZEND>=2 printf("Jumping to %d\n", EX(opline)->op1.u.opline_num); @@ -1844,7 +1839,7 @@ class_name_strlen = tmp.value.str.len; } - if (zend_lookup_class(class_name_strval, class_name_strlen, &pce TSRMLS_CC) == FAILURE) { + if (zend_hash_find(EG(class_table), class_name_strval, class_name_strlen+1, (void **) &pce) == FAILURE) { zend_error(E_ERROR, "Class '%s' not found", class_name_strval); } else { EX(Ts)[EX(opline)->result.u.var].EA.class_entry = *pce; @@ -1886,9 +1881,7 @@ EX(fbc) = EX(fbc_constructor); if(EX(fbc)->type == ZEND_USER_FUNCTION) { /* HACK!! */ - /* The scope should be the scope of the class where the constructor - was initially declared in */ - EX(calling_scope) = EX(fbc)->common.scope; + EX(calling_scope) = Z_OBJCE_P(EX(object)); } else { EX(calling_scope) = NULL; } @@ -1898,15 +1891,31 @@ case ZEND_INIT_METHOD_CALL: { zval *function_name; + zval tmp; + zend_bool is_const; char *function_name_strval; int function_name_strlen; zend_ptr_stack_n_push(&EG(arg_types_stack), 2, EX(fbc), EX(object)); - function_name = get_zval_ptr(&EX(opline)->op2, EX(Ts), &EG(free_op2), BP_VAR_R); - function_name_strval = function_name->value.str.val; - function_name_strlen = function_name->value.str.len; + is_const = (EX(opline)->op2.op_type == IS_CONST); + + if (is_const) { + function_name_strval = EX(opline)->op2.u.constant.value.str.val; + function_name_strlen = EX(opline)->op2.u.constant.value.str.len; + } else { + function_name = get_zval_ptr(&EX(opline)->op2, EX(Ts), &EG(free_op2), BP_VAR_R); + + tmp = *function_name; + zval_copy_ctor(&tmp); + convert_to_string(&tmp); + function_name = &tmp; + zend_str_tolower(tmp.value.str.val, tmp.value.str.len); + function_name_strval = tmp.value.str.val; + function_name_strlen = tmp.value.str.len; + } + EX(calling_scope) = EG(scope); if (EX(opline)->extended_value == ZEND_FETCH_FROM_THIS) { @@ -1939,12 +1948,15 @@ } if(EX(fbc)->type == ZEND_USER_FUNCTION) { - EX(calling_scope) = EX(fbc)->common.scope; + EX(calling_scope) = Z_OBJCE_P(EX(object)); } else { EX(calling_scope) = NULL; } - FREE_OP(EX(Ts), &EX(opline)->op2, EG(free_op2)); + if (!is_const) { + zval_dtor(&tmp); + FREE_OP(EX(Ts), &EX(opline)->op2, EG(free_op2)); + } NEXT_OPCODE(); } @@ -2560,7 +2572,7 @@ EX(Ts)[EX(opline)->result.u.var].tmp_var = **value; zval_copy_ctor(&EX(Ts)[EX(opline)->result.u.var].tmp_var); } else { - zend_error(E_ERROR, "Undefined class constant '%s'", EX(opline)->op2.u.constant.value.str.val); + zend_error(E_ERROR, "Undefined constant. Improve this error message"); } } NEXT_OPCODE(); 1.4 +1 -4 ZendEngine2/zend_execute.h Index: zend_execute.h =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_execute.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- zend_execute.h 2 Aug 2002 09:48:15 -0000 1.3 +++ zend_execute.h 3 Aug 2002 08:56:16 -0000 1.4 @@ -49,7 +49,6 @@ } temp_variable; -BEGIN_EXTERN_C() ZEND_API extern void (*zend_execute)(zend_op_array *op_array TSRMLS_DC); void init_executor(TSRMLS_D); @@ -64,7 +63,7 @@ FREE_ZVAL(p); } } -ZEND_API int zend_lookup_class(char *name, int name_length, zend_class_entry ***ce TSRMLS_DC); + ZEND_API int zend_eval_string(char *str, zval *retval_ptr, char *string_name TSRMLS_DC); static inline int i_zend_is_true(zval *op) @@ -161,7 +160,5 @@ #define IS_OVERLOADED_OBJECT 1 #define IS_STRING_OFFSET 2 - -END_EXTERN_C() #endif /* ZEND_EXECUTE_H */ 1.5 +11 -43 ZendEngine2/zend_execute_API.c Index: zend_execute_API.c =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_execute_API.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- zend_execute_API.c 2 Aug 2002 09:48:15 -0000 1.4 +++ zend_execute_API.c 3 Aug 2002 08:56:16 -0000 1.5 @@ -160,7 +160,7 @@ zend_ptr_stack_init(&EG(user_error_handlers)); EG(orig_error_reporting) = EG(error_reporting); - zend_objects_store_init(&EG(objects_store), 1024); + zend_objects_init(&EG(objects), 1024); EG(full_tables_cleanup) = 0; #ifdef ZEND_WIN32 @@ -183,7 +183,7 @@ void shutdown_executor(TSRMLS_D) { zend_try { - zend_objects_store_call_destructors(&EG(objects_store) TSRMLS_CC); + zend_objects_call_destructors(&EG(objects) TSRMLS_CC); zend_ptr_stack_destroy(&EG(arg_types_stack)); @@ -236,7 +236,7 @@ zend_ptr_stack_destroy(&EG(user_error_handlers)); EG(error_reporting) = EG(orig_error_reporting); - zend_objects_store_destroy(&EG(objects_store)); + zend_objects_destroy(&EG(objects)); } zend_end_try(); } @@ -331,13 +331,13 @@ if (strchr(p->value.str.val, ':')) { char *cur, *temp; char *last; - zend_class_entry **ce; + zend_class_entry *ce; zval **value; last = tsrm_strtok_r(p->value.str.val, ":", &temp); - if (zend_lookup_class(last, strlen(last), &ce TSRMLS_CC) == FAILURE) { - zend_error(E_ERROR, "Undefined class '%s'", last); + if (zend_hash_find(EG(class_table), last, strlen(last)+1, (void **)&ce) == FAILURE) { + zend_error(E_ERROR, "Invalid class! Improve this error message"); } last = tsrm_strtok_r(NULL, ":", &temp); @@ -347,13 +347,13 @@ if (!cur) { break; } - if (zend_hash_find(&(*ce)->class_table, last, strlen(last)+1, (void **)&ce) == FAILURE) { - zend_error(E_ERROR, "Undefined sub-class '%s'", last); + if (zend_hash_find(&ce->class_table, last, strlen(last)+1, (void **)&ce) == FAILURE) { + zend_error(E_ERROR, "Invalid class! Improve this error message"); } last = cur; } - if (zend_hash_find(&(*ce)->constants_table, last, strlen(last)+1, (void **) &value) == FAILURE) { - zend_error(E_ERROR, "Undefined class constant '%s'", last); + if (zend_hash_find(&ce->constants_table, last, strlen(last)+1, (void **) &value) == FAILURE) { + zend_error(E_ERROR, "Invalid class! Improve this error message"); } const_value = **value; zval_copy_ctor(&const_value); @@ -500,7 +500,7 @@ lc_class = estrndup(Z_STRVAL_PP(object_pp), Z_STRLEN_PP(object_pp)); zend_str_tolower(lc_class, Z_STRLEN_PP(object_pp)); - found = zend_lookup_class(lc_class, Z_STRLEN_PP(object_pp), &ce TSRMLS_CC); + found = zend_hash_find(EG(class_table), lc_class, Z_STRLEN_PP(object_pp) + 1, (void **) &ce); efree(lc_class); if (found == FAILURE) return FAILURE; @@ -637,38 +637,6 @@ return SUCCESS; } -ZEND_API int zend_lookup_class(char *name, int name_length, zend_class_entry ***ce TSRMLS_DC) -{ - zval **args[1]; - zval *autoload_function; - zval *class_name; - zval *retval_ptr; - int retval; - - if (zend_hash_find(EG(class_table), name, name_length+1, (void **) ce) == SUCCESS) { - return SUCCESS; - } - - MAKE_STD_ZVAL(autoload_function); - ZVAL_STRINGL(autoload_function, "__autoload", sizeof("__autoload")-1, 1); - - MAKE_STD_ZVAL(class_name); - ZVAL_STRINGL(class_name, name, name_length, 1); - args[0] = &class_name; - - retval = call_user_function_ex(EG(function_table), NULL, autoload_function, &retval_ptr, 1, args, 0, NULL TSRMLS_CC); - - zval_ptr_dtor(&autoload_function); - zval_ptr_dtor(&class_name); - - if (retval == FAILURE) { - return FAILURE; - } - - zval_ptr_dtor(&retval_ptr); - - return zend_hash_find(EG(class_table), name, name_length + 1, (void **) ce); -} ZEND_API int zend_eval_string(char *str, zval *retval_ptr, char *string_name TSRMLS_DC) { 1.4 +1 -1 ZendEngine2/zend_fast_cache.h Index: zend_fast_cache.h =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_fast_cache.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- zend_fast_cache.h 2 Aug 2002 09:48:15 -0000 1.3 +++ zend_fast_cache.h 3 Aug 2002 08:56:16 -0000 1.4 @@ -25,7 +25,7 @@ # if ZEND_DEBUG # define ZEND_ENABLE_FAST_CACHE 0 # else -# define ZEND_ENABLE_FAST_CACHE 0 +# define ZEND_ENABLE_FAST_CACHE 1 # endif #endif 1.5 +2 -6 ZendEngine2/zend_globals.h Index: zend_globals.h =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_globals.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- zend_globals.h 2 Aug 2002 09:48:15 -0000 1.4 +++ zend_globals.h 3 Aug 2002 08:56:16 -0000 1.5 @@ -32,7 +32,6 @@ #include "zend_llist.h" #include "zend_fast_cache.h" #include "zend_objects.h" -#include "zend_objects_API.h" /* Define ZTS if you want a thread-safe Zend */ /*#undef ZTS*/ @@ -201,7 +200,7 @@ int lambda_count; HashTable ini_directives; - zend_objects_store objects_store; + zend_objects objects; zval *exception; struct _zend_execute_data *current_execute_data; @@ -209,10 +208,10 @@ void *reserved[ZEND_MAX_RESERVED_RESOURCES]; }; -#include "zend_mm.h" struct _zend_alloc_globals { zend_mem_header *head; /* standard list */ + zend_mem_header *phead; /* persistent list */ void *cache[MAX_CACHED_MEMORY][MAX_CACHED_ENTRIES]; unsigned int cache_count[MAX_CACHED_MEMORY]; void *fast_cache_list_head[MAX_FAST_CACHE_TYPES]; @@ -231,9 +230,6 @@ unsigned int allocated_memory; unsigned int allocated_memory_peak; unsigned char memory_exhausted; -#endif -#ifdef ZEND_MM - zend_mm_heap mm_heap; #endif }; 1.4 +6 -58 ZendEngine2/zend_hash.h Index: zend_hash.h =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_hash.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- zend_hash.h 2 Aug 2002 09:48:15 -0000 1.3 +++ zend_hash.h 3 Aug 2002 08:56:16 -0000 1.4 @@ -21,7 +21,6 @@ #define ZEND_HASH_H #include <sys/types.h> -#include "zend.h" #define HASH_KEY_IS_STRING 1 #define HASH_KEY_IS_LONG 2 @@ -189,68 +188,17 @@ ZEND_API int zend_hash_rehash(HashTable *ht); -/* - * DJBX33A (Daniel J. Bernstein, Times 33 with Addition) - * - * This is Daniel J. Bernstein's popular `times 33' hash function as - * posted by him years ago on comp.lang.c. It basically uses a function - * like ``hash(i) = hash(i-1) * 33 + str[i]''. This is one of the best - * known hash functions for strings. Because it is both computed very - * fast and distributes very well. - * - * The magic of number 33, i.e. why it works better than many other - * constants, prime or not, has never been adequately explained by - * anyone. So I try an explanation: if one experimentally tests all - * multipliers between 1 and 256 (as RSE did now) one detects that even - * numbers are not useable at all. The remaining 128 odd numbers - * (except for the number 1) work more or less all equally well. They - * all distribute in an acceptable way and this way fill a hash table - * with an average percent of approx. 86%. - * - * If one compares the Chi^2 values of the variants, the number 33 not - * even has the best value. But the number 33 and a few other equally - * good numbers like 17, 31, 63, 127 and 129 have nevertheless a great - * advantage to the remaining numbers in the large set of possible - * multipliers: their multiply operation can be replaced by a faster - * operation based on just one shift plus either a single addition - * or subtraction operation. And because a hash function has to both - * distribute good _and_ has to be very fast to compute, those few - * numbers should be preferred and seems to be the reason why Daniel J. - * Bernstein also preferred it. - * - * - * -- Ralf S. Engelschall <rse****@engel*****> - */ - static inline ulong zend_inline_hash_func(char *arKey, uint nKeyLength) { - register ulong hash = 5381; + ulong h = 5381; + char *arEnd = arKey + nKeyLength; - /* variant with the hash unrolled eight times */ - for (; nKeyLength >= 8; nKeyLength -= 8) { - hash = ((hash << 5) + hash) + *arKey++; - hash = ((hash << 5) + hash) + *arKey++; - hash = ((hash << 5) + hash) + *arKey++; - hash = ((hash << 5) + hash) + *arKey++; - hash = ((hash << 5) + hash) + *arKey++; - hash = ((hash << 5) + hash) + *arKey++; - hash = ((hash << 5) + hash) + *arKey++; - hash = ((hash << 5) + hash) + *arKey++; + while (arKey < arEnd) { + h += (h << 5); + h ^= (ulong) *arKey++; } - switch (nKeyLength) { - case 7: hash = ((hash << 5) + hash) + *arKey++; /* fallthrough... */ - case 6: hash = ((hash << 5) + hash) + *arKey++; /* fallthrough... */ - case 5: hash = ((hash << 5) + hash) + *arKey++; /* fallthrough... */ - case 4: hash = ((hash << 5) + hash) + *arKey++; /* fallthrough... */ - case 3: hash = ((hash << 5) + hash) + *arKey++; /* fallthrough... */ - case 2: hash = ((hash << 5) + hash) + *arKey++; /* fallthrough... */ - case 1: hash = ((hash << 5) + hash) + *arKey++; break; - case 0: break; -EMPTY_SWITCH_DEFAULT_CASE() - } - return hash; + return h; } - ZEND_API ulong zend_hash_func(char *arKey, uint nKeyLength); 1.4 +3 -3 ZendEngine2/zend_ini_scanner.l Index: zend_ini_scanner.l =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_ini_scanner.l,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- zend_ini_scanner.l 2 Aug 2002 09:48:15 -0000 1.3 +++ zend_ini_scanner.l 3 Aug 2002 08:56:16 -0000 1.4 @@ -125,11 +125,11 @@ return CFG_FALSE; } -<INITIAL>[[][^[]+[\]][ ]*{NEWLINE}? { +<INITIAL>[[][^[]+[\]]{NEWLINE}? { /* SECTION */ - /* eat trailng and spaces ] */ - while (yyleng>0 && (yytext[yyleng-1]=='\n' || yytext[yyleng-1]=='\r' || yytext[yyleng-1]==']' || yytext[yyleng-1]==' ')) { + /* eat trailng ] */ + while (yyleng>0 && (yytext[yyleng-1]=='\n' || yytext[yyleng-1]=='\r' || yytext[yyleng-1]==']')) { yyleng--; yytext[yyleng]=0; } 1.4 +3 -3 ZendEngine2/zend_language_parser.y Index: zend_language_parser.y =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_language_parser.y,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- zend_language_parser.y 2 Aug 2002 09:48:15 -0000 1.3 +++ zend_language_parser.y 3 Aug 2002 08:56:16 -0000 1.4 @@ -173,6 +173,7 @@ unticked_statement { zend_do_ticks(TSRMLS_C); } ; + unticked_statement: '{' inner_statement_list '}' | T_IF '(' expr ')' { zend_do_if_cond(&$3, &$4 TSRMLS_CC); } statement { zend_do_if_after_statement(&$4, 1 TSRMLS_CC); } elseif_list else_single { zend_do_if_end(TSRMLS_C); } @@ -439,7 +440,6 @@ is_reference: /* empty */ { $$.op_type = ZEND_RETURN_VAL; } | '&' { $$.op_type = ZEND_RETURN_REF; } -; class_variable_decleration: class_variable_decleration ',' T_VARIABLE { zend_do_declare_property(&$3, NULL, $1.op_type TSRMLS_CC); } @@ -478,7 +478,7 @@ expr_without_variable: T_LIST '(' { zend_do_list_init(TSRMLS_C); } assignment_list ')' '=' expr { zend_do_list_end(&$$, &$7 TSRMLS_CC); } | variable '=' expr { zend_check_writable_variable(&$$); zend_do_end_variable_parse(BP_VAR_W, 0 TSRMLS_CC); zend_do_assign(&$$, &$1, &$3 TSRMLS_CC); } - | variable '=' '&' variable { zend_do_end_variable_parse(BP_VAR_W, 0 TSRMLS_CC); zend_do_end_variable_parse(BP_VAR_W, 0 TSRMLS_CC); zend_do_assign_ref(&$$, &$1, &$4 TSRMLS_CC); } + | variable '=' '&' w_variable { zend_check_writable_variable(&$$); zend_do_end_variable_parse(BP_VAR_W, 0 TSRMLS_CC); zend_do_assign_ref(&$$, &$1, &$4 TSRMLS_CC); } | variable '=' '&' T_NEW new_class_entry { zend_check_writable_variable(&$$); zend_do_extended_fcall_begin(TSRMLS_C); zend_do_begin_new_object(&$4, &$5 TSRMLS_CC); } ctor_arguments { zend_do_end_new_object(&$3, &$4, &$7 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C); zend_do_end_variable_parse(BP_VAR_W, 0 TSRMLS_CC); zend_do_assign_ref(&$$, &$1, &$3 TSRMLS_CC); } | T_NEW new_class_entry { zend_do_extended_fcall_begin(TSRMLS_C); zend_do_begin_new_object(&$1, &$2 TSRMLS_CC); } ctor_arguments { zend_do_end_new_object(&$$, &$1, &$4 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);} | variable T_PLUS_EQUAL expr { zend_check_writable_variable(&$$); zend_do_end_variable_parse(BP_VAR_RW, 0 TSRMLS_CC); zend_do_binary_assign_op(ZEND_ASSIGN_ADD, &$$, &$1, &$3 TSRMLS_CC); } @@ -609,7 +609,7 @@ static_scalar: /* compile-time evaluated scalars */ common_scalar { $$ = $1; } | T_STRING { zend_do_fetch_constant(&$$, NULL, &$1, ZEND_CT TSRMLS_CC); } - | '+' static_scalar { $$ = $2; } + | '+' static_scalar { $$ = $1; } | '-' static_scalar { zval minus_one; minus_one.type = IS_LONG; minus_one.value.lval = -1; mul_function(&$2.u.constant, &$2.u.constant, &minus_one TSRMLS_CC); $$ = $2; } | T_ARRAY '(' static_array_pair_list ')' { $$ = $3; $$.u.constant.type = IS_CONSTANT_ARRAY; } | parse_class_name_entry T_STRING { zend_do_fetch_constant(&$$, &$1, &$2, ZEND_CT TSRMLS_CC); } 1.4 +0 -2 ZendEngine2/zend_list.h Index: zend_list.h =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_list.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- zend_list.h 2 Aug 2002 09:48:15 -0000 1.3 +++ zend_list.h 3 Aug 2002 08:56:16 -0000 1.4 @@ -24,7 +24,6 @@ #include "zend_hash.h" #include "zend_globals.h" -BEGIN_EXTERN_C() #define ZEND_RESOURCE_LIST_TYPE_STD 1 #define ZEND_RESOURCE_LIST_TYPE_EX 2 @@ -106,6 +105,5 @@ if (le_id == 0) { \ le_id = zend_fetch_list_dtor_id(le_type_name); \ } -END_EXTERN_C() #endif 1.4 +0 -3 ZendEngine2/zend_llist.c Index: zend_llist.c =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_llist.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- zend_llist.c 2 Aug 2002 09:48:15 -0000 1.3 +++ zend_llist.c 3 Aug 2002 08:56:16 -0000 1.4 @@ -140,9 +140,6 @@ data = old_tail->data; l->tail = l->tail->prev; - if (l->dtor) { - l->dtor(data); - } pefree(old_tail, l->persistent); --l->count; 1.3 +5 -16 ZendEngine2/zend_mm.c Index: zend_mm.c =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_mm.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- zend_mm.c 2 Aug 2002 09:48:15 -0000 1.2 +++ zend_mm.c 3 Aug 2002 08:56:16 -0000 1.3 @@ -19,6 +19,7 @@ #include <stdlib.h> #include <string.h> +#include "zend.h" #include "zend_mm.h" #if WIN32|WINNT @@ -34,26 +35,14 @@ #define MAX(a, b) (((a)>(b))?(a):(b)) #endif -/* Platform alignment test */ -typedef union _mm_align_test { - void *ptr; - double dbl; - long lng; -} mm_align_test; - -#if (defined (__GNUC__) && __GNUC__ >= 2) -#define ZEND_MM_ALIGNMENT (__alignof__ (mm_align_test)) -#else -#define ZEND_MM_ALIGNMENT (sizeof(mm_align_test)) -#endif - -/* We're going to need some kind of configure test for this */ -#undef ZEND_MM_ALIGNMENT +#ifndef ZEND_MM_ALIGNMENT #define ZEND_MM_ALIGNMENT 8 +#define ZEND_MM_ALIGNMENT_LOG2 3 +#endif #define ZEND_MM_ALIGNMENT_MASK ~(ZEND_MM_ALIGNMENT-1) -#define ZEND_MM_BUCKET_INDEX(true_size) (true_size >> 3) +#define ZEND_MM_BUCKET_INDEX(true_size) (true_size >> ZEND_MM_ALIGNMENT_LOG2) #define ZEND_MM_GET_FREE_LIST_BUCKET(index, free_list_bucket) \ if (index < ZEND_MM_NUM_BUCKETS) { \ 1.4 +1 -1 ZendEngine2/zend_modules.h Index: zend_modules.h =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_modules.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- zend_modules.h 2 Aug 2002 09:48:15 -0000 1.3 +++ zend_modules.h 3 Aug 2002 08:56:16 -0000 1.4 @@ -34,7 +34,7 @@ ZEND_API extern unsigned char second_arg_force_ref[]; ZEND_API extern unsigned char third_arg_force_ref[]; -#define ZEND_MODULE_API_NO 20020429 +#define ZEND_MODULE_API_NO 20010927 #ifdef ZTS #define USING_ZTS 1 #else 1.5 +6 -14 ZendEngine2/zend_object_handlers.c Index: zend_object_handlers.c =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_object_handlers.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- zend_object_handlers.c 2 Aug 2002 09:48:15 -0000 1.4 +++ zend_object_handlers.c 3 Aug 2002 08:56:16 -0000 1.5 @@ -3,7 +3,6 @@ #include "zend_variables.h" #include "zend_API.h" #include "zend_objects.h" -#include "zend_objects_API.h" #include "zend_object_handlers.h" #define DEBUG_OBJECT_HANDLERS 0 @@ -152,19 +151,12 @@ { zend_object *zobj; zend_function *func_method; - char *lc_method_name; - - lc_method_name = do_alloca(method_len+1); - /* Create a zend_copy_str_tolower(dest, src, src_length); */ - memcpy(lc_method_name, method_name, method_len+1); - zend_str_tolower(lc_method_name, method_len); - + zobj = Z_OBJ_P(object); - if(zend_hash_find(&zobj->ce->function_table, lc_method_name, method_len+1, (void **)&func_method) == FAILURE) { + if(zend_hash_find(&zobj->ce->function_table, method_name, method_len+1, (void **)&func_method) == FAILURE) { zend_error(E_ERROR, "Call to undefined function %s()", method_name); } - - free_alloca(lc_method_name); + return func_method; } @@ -232,9 +224,9 @@ } zend_object_handlers std_object_handlers = { - zend_objects_store_add_ref, /* add_ref */ - zend_objects_store_del_ref, /* del_ref */ - zend_objects_store_delete_obj, /* delete_obj */ + zend_objects_add_ref, /* add_ref */ + zend_objects_del_ref, /* del_ref */ + zend_objects_delete_obj, /* delete_obj */ zend_objects_clone_obj, /* clone_obj */ zend_std_read_property, /* read_property */ 1.5 +0 -1 ZendEngine2/zend_object_handlers.h Index: zend_object_handlers.h =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_object_handlers.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- zend_object_handlers.h 2 Aug 2002 09:48:15 -0000 1.4 +++ zend_object_handlers.h 3 Aug 2002 08:56:16 -0000 1.5 @@ -74,6 +74,5 @@ extern zend_object_handlers std_object_handlers; #define IS_ZEND_STD_OBJECT(z) ((z).type == IS_OBJECT && Z_OBJ_HT(z) == &std_object_handlers) -#define HAS_CLASS_ENTRY(z) (Z_OBJ_HT(z)->get_class_entry != NULL) #endif 1.5 +143 -8 ZendEngine2/zend_objects.c Index: zend_objects.c =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_objects.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- zend_objects.c 2 Aug 2002 09:48:15 -0000 1.4 +++ zend_objects.c 3 Aug 2002 08:56:16 -0000 1.5 @@ -3,6 +3,21 @@ #include "zend_variables.h" #include "zend_API.h" +#define ZEND_DEBUG_OBJECTS 0 + +void zend_objects_init(zend_objects *objects, zend_uint init_size) +{ + objects->object_buckets = (zend_object_bucket *) emalloc(init_size * sizeof(zend_object_bucket)); + objects->top = 1; /* Skip 0 so that handles are true */ + objects->size = init_size; + objects->free_list_head = -1; +} + +void zend_objects_destroy(zend_objects *objects) +{ + efree(objects->object_buckets); +} + static inline void zend_objects_call_destructor(zend_object *object, zend_object_handle handle TSRMLS_DC) { if (object->ce->destructor) { @@ -43,27 +58,142 @@ zend_objects_call_destructor(object, handle TSRMLS_CC); /* Nuke the object */ zend_hash_destroy(object->properties); - FREE_HASHTABLE(object->properties); - efree(object); + efree(object->properties); + } + +void zend_objects_call_destructors(zend_objects *objects TSRMLS_DC) +{ + zend_uint i = 1; + + for (i = 1; i < objects->top ; i++) { + if (EG(objects).object_buckets[i].valid) { + EG(objects).object_buckets[i].destructor_called = 1; + zend_objects_destroy_object(&EG(objects).object_buckets[i].bucket.obj.object, i TSRMLS_CC); + EG(objects).object_buckets[i].valid = 0; + } + } +} + + zend_object_value zend_objects_new(zend_object **object, zend_class_entry *class_type) -{ +{ + zend_object_handle handle; zend_object_value retval; TSRMLS_FETCH(); - *object = emalloc(sizeof(zend_object)); + if (EG(objects).free_list_head != -1) { + handle = EG(objects).free_list_head; + EG(objects).free_list_head = EG(objects).object_buckets[handle].bucket.free_list.next; + } else { + if (EG(objects).top == EG(objects).size) { + EG(objects).size <<= 1; + EG(objects).object_buckets = (zend_object_bucket *) erealloc(EG(objects).object_buckets, EG(objects).size * sizeof(zend_object_bucket)); + } + handle = EG(objects).top++; + } + EG(objects).object_buckets[handle].valid = 1; + EG(objects).object_buckets[handle].destructor_called = 0; + EG(objects).object_buckets[handle].bucket.obj.refcount = 1; + + *object = &EG(objects).object_buckets[handle].bucket.obj.object; + (*object)->ce = class_type; - retval.handle = zend_objects_store_put(*object, (zend_objects_store_dtor_t) zend_objects_destroy_object, NULL TSRMLS_CC); + + retval.handle = handle; retval.handlers = &std_object_handlers; +#if ZEND_DEBUG_OBJECTS + fprintf(stderr, "Allocated object id #%d\n", handle); +#endif return retval; } -ZEND_API zend_object *zend_objects_get_address(zval *zobject) +zend_object *zend_objects_get_address(zval *zobject) { + zend_object_handle handle = Z_OBJ_HANDLE_P(zobject); TSRMLS_FETCH(); - return (zend_object *)zend_object_store_get_object(zobject TSRMLS_CC); + + if (!EG(objects).object_buckets[handle].valid) { + zend_error(E_ERROR, "Trying to access invalid object"); + } + return &EG(objects).object_buckets[handle].bucket.obj.object; +} + +void zend_objects_add_ref(zval *object TSRMLS_DC) +{ + zend_object_handle handle = Z_OBJ_HANDLE_P(object); + + if (!EG(objects).object_buckets[handle].valid) { + zend_error(E_ERROR, "Trying to add reference to invalid object"); + } + + EG(objects).object_buckets[handle].bucket.obj.refcount++; +#if ZEND_DEBUG_OBJECTS + fprintf(stderr, "Increased refcount of object id #%d\n", handle); +#endif +} + +void zend_objects_delete_obj(zval *zobject TSRMLS_DC) +{ + zend_object *object; + zend_object_handle handle = Z_OBJ_HANDLE_P(zobject); + + if (!EG(objects).object_buckets[handle].valid) { + zend_error(E_ERROR, "Trying to delete invalid object"); + } + + object = &EG(objects).object_buckets[handle].bucket.obj.object; + + if (!EG(objects).object_buckets[handle].destructor_called) { + EG(objects).object_buckets[handle].destructor_called = 1; + zend_objects_destroy_object(object, handle TSRMLS_CC); + } + + EG(objects).object_buckets[handle].valid = 0; + +#if ZEND_DEBUG_OBJECTS + fprintf(stderr, "Deleted object id #%d\n", handle); +#endif + +} + +#define ZEND_OBJECTS_ADD_TO_FREE_LIST() \ + EG(objects).object_buckets[handle].bucket.free_list.next = EG(objects).free_list_head; \ + EG(objects).free_list_head = handle; \ + EG(objects).object_buckets[handle].valid = 0; + +void zend_objects_del_ref(zval *zobject TSRMLS_DC) +{ + zend_object_handle handle = Z_OBJ_HANDLE_P(zobject); + + if (--EG(objects).object_buckets[handle].bucket.obj.refcount == 0) { + zend_object *object; + do { + if (EG(objects).object_buckets[handle].valid) { + if (!EG(objects).object_buckets[handle].destructor_called) { + object = &EG(objects).object_buckets[handle].bucket.obj.object; + EG(objects).object_buckets[handle].destructor_called = 1; + zend_objects_destroy_object(object, handle TSRMLS_CC); + if (EG(objects).object_buckets[handle].bucket.obj.refcount == 0) { + ZEND_OBJECTS_ADD_TO_FREE_LIST(); + } + break; + } + } + ZEND_OBJECTS_ADD_TO_FREE_LIST(); + } while (0); + +#if ZEND_DEBUG_OBJECTS + fprintf(stderr, "Deallocated object id #%d\n", handle); +#endif + } +#if ZEND_DEBUG_OBJECTS + else { + fprintf(stderr, "Decreased refcount of object id #%d\n", handle); + } +#endif } zend_object_value zend_objects_clone_obj(zval *zobject TSRMLS_DC) @@ -73,7 +203,12 @@ zend_object *new_object; zend_object_handle handle = Z_OBJ_HANDLE_P(zobject); - old_object = zend_objects_get_address(zobject); + + if (!EG(objects).object_buckets[handle].valid) { + zend_error(E_ERROR, "Trying to clone invalid object"); + } + + old_object = &EG(objects).object_buckets[handle].bucket.obj.object; retval = zend_objects_new(&new_object, old_object->ce); if (old_object->ce->clone) { 1.5 +30 -1 ZendEngine2/zend_objects.h Index: zend_objects.h =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_objects.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- zend_objects.h 2 Aug 2002 09:48:15 -0000 1.4 +++ zend_objects.h 3 Aug 2002 08:56:16 -0000 1.5 @@ -3,8 +3,37 @@ #include "zend.h" +typedef struct _zend_object_bucket { + zend_bool valid; + zend_bool destructor_called; + union _bucket { + struct { + zend_object object; + zend_uint refcount; + } obj; + struct { + int next; + } free_list; + } bucket; +} zend_object_bucket; + +typedef struct _zend_objects { + zend_object_bucket *object_buckets; + zend_uint top; + zend_uint size; + int free_list_head; +} zend_objects; + +void zend_objects_init(zend_objects *objects, zend_uint init_size); +void zend_objects_call_destructors(zend_objects *objects TSRMLS_DC); +void zend_objects_destroy(zend_objects *objects); zend_object_value zend_objects_new(zend_object **object, zend_class_entry *class_type); -ZEND_API zend_object *zend_objects_get_address(zval *object); + +zend_object *zend_objects_get_address(zval *object); + +void zend_objects_add_ref(zval *object TSRMLS_DC); +void zend_objects_del_ref(zval *object TSRMLS_DC); +void zend_objects_delete_obj(zval *object TSRMLS_DC); zend_object_value zend_objects_clone_obj(zval *object TSRMLS_DC); #endif /* ZEND_OBJECTS_H */ 1.3 +8 -3 ZendEngine2/zend_objects_API.c Index: zend_objects_API.c =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_objects_API.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- zend_objects_API.c 2 Aug 2002 09:48:15 -0000 1.2 +++ zend_objects_API.c 3 Aug 2002 08:56:16 -0000 1.3 @@ -115,12 +115,17 @@ if (--obj->refcount == 0) { if (EG(objects_store).object_buckets[handle].valid) { - if(obj->dtor && !EG(objects_store).object_buckets[handle].destructor_called) { + if(!EG(objects_store).object_buckets[handle].destructor_called) { EG(objects_store).object_buckets[handle].destructor_called = 1; - obj->dtor(obj->object, handle TSRMLS_CC); + if (obj->dtor) { + obj->dtor(obj->object, handle TSRMLS_CC); + } + EG(objects_store).object_buckets[handle].valid = 0; + if (obj->refcount == 0) { + ZEND_OBJECTS_STORE_ADD_TO_FREE_LIST(); + } } } - ZEND_OBJECTS_STORE_ADD_TO_FREE_LIST(); #if ZEND_DEBUG_OBJECTS fprintf(stderr, "Deallocated object id #%d\n", handle); #endif 1.4 +10 -18 ZendEngine2/zend_operators.c Index: zend_operators.c =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_operators.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- zend_operators.c 2 Aug 2002 09:48:15 -0000 1.3 +++ zend_operators.c 3 Aug 2002 08:56:16 -0000 1.4 @@ -1509,7 +1509,6 @@ ZEND_API int decrement_function(zval *op1) { long lval; - double dval; switch (op1->type) { case IS_LONG: @@ -1529,23 +1528,16 @@ op1->value.lval = -1; op1->type = IS_LONG; break; - } - switch(is_numeric_string(op1->value.str.val, op1->value.str.len, &lval, &dval, 0)) { - case IS_LONG: - STR_FREE(op1->value.str.val); - if(lval == LONG_MIN) { - double d = (double)lval; - ZVAL_DOUBLE(op1, d-1); - } else { - op1->value.lval = lval-1; - op1->type = IS_LONG; - } - break; - case IS_DOUBLE: - STR_FREE(op1->value.str.val); - op1->value.dval = dval - 1; - op1->type = IS_DOUBLE; - break; + } else if (is_numeric_string(op1->value.str.val, op1->value.str.len, &lval, NULL, 0)==IS_LONG) { /* long */ + STR_FREE(op1->value.str.val); + if(lval == LONG_MIN) { + double d = (double)lval; + ZVAL_DOUBLE(op1, d-1); + } else { + op1->value.lval = lval-1; + op1->type = IS_LONG; + } + break; } break; default: 1.4 +30 -30 ZendEngine2/zend_ts_hash.c Index: zend_ts_hash.c =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_ts_hash.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- zend_ts_hash.c 2 Aug 2002 09:48:15 -0000 1.3 +++ zend_ts_hash.c 3 Aug 2002 08:56:16 -0000 1.4 @@ -55,7 +55,7 @@ ht->mx_reader = tsrm_mutex_alloc(); ht->mx_writer = tsrm_mutex_alloc(); ht->reader = 0; - return zend_hash_init(TS_HASH(ht), nSize, pHashFunction, pDestructor, persistent); + return zend_hash_init(&(ht->hash), nSize, pHashFunction, pDestructor, persistent); } ZEND_API int zend_ts_hash_init_ex(TsHashTable *ht, uint nSize, hash_func_t pHashFunction, dtor_func_t pDestructor, zend_bool persistent, zend_bool bApplyProtection) @@ -63,20 +63,20 @@ ht->mx_reader = tsrm_mutex_alloc(); ht->mx_writer = tsrm_mutex_alloc(); ht->reader = 0; - return zend_hash_init_ex(TS_HASH(ht), nSize, pHashFunction, pDestructor, persistent, bApplyProtection); + return zend_hash_init_ex(&(ht->hash), nSize, pHashFunction, pDestructor, persistent, bApplyProtection); } ZEND_API void zend_ts_hash_destroy(TsHashTable *ht) { tsrm_mutex_free(ht->mx_reader); tsrm_mutex_free(ht->mx_reader); - zend_hash_destroy(TS_HASH(ht)); + zend_hash_destroy(&(ht->hash)); } ZEND_API void zend_ts_hash_clean(TsHashTable *ht) { ht->reader = 0; - zend_hash_clean(TS_HASH(ht)); + zend_hash_clean(&(ht->hash)); } ZEND_API int zend_ts_hash_add_or_update(TsHashTable *ht, char *arKey, uint nKeyLength, void *pData, uint nDataSize, void **pDest, int flag) @@ -84,7 +84,7 @@ int retval; begin_write(ht); - retval = zend_hash_add_or_update(TS_HASH(ht), arKey, nKeyLength, pData, nDataSize, pDest, flag); + retval = zend_hash_add_or_update(&(ht->hash), arKey, nKeyLength, pData, nDataSize, pDest, flag); end_write(ht); return retval; @@ -95,7 +95,7 @@ int retval; begin_write(ht); - retval = zend_hash_quick_add_or_update(TS_HASH(ht), arKey, nKeyLength, h, pData, nDataSize, pDest, flag); + retval = zend_hash_quick_add_or_update(&(ht->hash), arKey, nKeyLength, h, pData, nDataSize, pDest, flag); end_write(ht); return retval; @@ -106,7 +106,7 @@ int retval; begin_write(ht); - retval = zend_hash_index_update_or_next_insert(TS_HASH(ht), h, pData, nDataSize, pDest, flag); + retval = zend_hash_index_update_or_next_insert(&(ht->hash), h, pData, nDataSize, pDest, flag); end_write(ht); return retval; @@ -117,7 +117,7 @@ int retval; begin_write(ht); - retval = zend_hash_add_empty_element(TS_HASH(ht), arKey, nKeyLength); + retval = zend_hash_add_empty_element(&(ht->hash), arKey, nKeyLength); end_write(ht); return retval; @@ -127,20 +127,20 @@ { tsrm_mutex_free(ht->mx_reader); tsrm_mutex_free(ht->mx_reader); - zend_hash_graceful_destroy(TS_HASH(ht)); + zend_hash_graceful_destroy(&(ht->hash)); } ZEND_API void zend_ts_hash_apply(TsHashTable *ht, apply_func_t apply_func TSRMLS_DC) { begin_write(ht); - zend_hash_apply(TS_HASH(ht), apply_func TSRMLS_CC); + zend_hash_apply(&(ht->hash), apply_func TSRMLS_CC); end_write(ht); } ZEND_API void zend_ts_hash_apply_with_argument(TsHashTable *ht, apply_func_arg_t apply_func, void *argument TSRMLS_DC) { begin_write(ht); - zend_hash_apply_with_argument(TS_HASH(ht), apply_func, argument TSRMLS_CC); + zend_hash_apply_with_argument(&(ht->hash), apply_func, argument TSRMLS_CC); end_write(ht); } @@ -150,7 +150,7 @@ va_start(args, num_args); begin_write(ht); - zend_hash_apply_with_arguments(TS_HASH(ht), apply_func, num_args, args); + zend_hash_apply_with_arguments(&(ht->hash), apply_func, num_args, args); end_write(ht); va_end(args); } @@ -158,7 +158,7 @@ ZEND_API void zend_ts_hash_reverse_apply(TsHashTable *ht, apply_func_t apply_func TSRMLS_DC) { begin_write(ht); - zend_hash_reverse_apply(TS_HASH(ht), apply_func TSRMLS_CC); + zend_hash_reverse_apply(&(ht->hash), apply_func TSRMLS_CC); end_write(ht); } @@ -167,7 +167,7 @@ int retval; begin_write(ht); - retval = zend_hash_del_key_or_index(TS_HASH(ht), arKey, nKeyLength, h, flag); + retval = zend_hash_del_key_or_index(&(ht->hash), arKey, nKeyLength, h, flag); end_write(ht); return retval; @@ -178,7 +178,7 @@ ulong retval; begin_read(ht); - retval = zend_get_hash_value(TS_HASH(ht), arKey, nKeyLength); + retval = zend_get_hash_value(&(ht->hash), arKey, nKeyLength); end_read(ht); return retval; @@ -189,7 +189,7 @@ int retval; begin_read(ht); - retval = zend_hash_find(TS_HASH(ht), arKey, nKeyLength, pData); + retval = zend_hash_find(&(ht->hash), arKey, nKeyLength, pData); end_read(ht); return retval; @@ -200,7 +200,7 @@ int retval; begin_read(ht); - retval = zend_hash_quick_find(TS_HASH(ht), arKey, nKeyLength, h, pData); + retval = zend_hash_quick_find(&(ht->hash), arKey, nKeyLength, h, pData); end_read(ht); return retval; @@ -211,7 +211,7 @@ int retval; begin_read(ht); - retval = zend_hash_index_find(TS_HASH(ht), h, pData); + retval = zend_hash_index_find(&(ht->hash), h, pData); end_read(ht); return retval; @@ -222,7 +222,7 @@ int retval; begin_read(ht); - retval = zend_hash_exists(TS_HASH(ht), arKey, nKeyLength); + retval = zend_hash_exists(&(ht->hash), arKey, nKeyLength); end_read(ht); return retval; @@ -233,7 +233,7 @@ int retval; begin_read(ht); - retval = zend_hash_index_exists(TS_HASH(ht), h); + retval = zend_hash_index_exists(&(ht->hash), h); end_read(ht); return retval; @@ -243,7 +243,7 @@ { begin_read(source); begin_write(target); - zend_hash_copy(TS_HASH(target), TS_HASH(source), pCopyConstructor, tmp, size); + zend_hash_copy(&(target->hash), &(source->hash), pCopyConstructor, tmp, size); end_write(target); end_read(source); } @@ -252,7 +252,7 @@ { begin_read(source); begin_write(target); - zend_hash_merge(TS_HASH(target), TS_HASH(source), pCopyConstructor, tmp, size, overwrite); + zend_hash_merge(&(target->hash), &(source->hash), pCopyConstructor, tmp, size, overwrite); end_write(target); end_read(source); } @@ -261,7 +261,7 @@ { begin_read(source); begin_write(target); - zend_hash_merge_ex(TS_HASH(target), TS_HASH(source), pCopyConstructor, size, pReplaceOrig); + zend_hash_merge_ex(&(target->hash), &(source->hash), pCopyConstructor, size, pReplaceOrig); end_write(target); end_read(source); } @@ -271,7 +271,7 @@ int retval; begin_write(ht); - retval = zend_hash_sort(TS_HASH(ht), sort_func, compare_func, renumber TSRMLS_CC); + retval = zend_hash_sort(&(ht->hash), sort_func, compare_func, renumber TSRMLS_CC); end_write(ht); return retval; @@ -283,7 +283,7 @@ begin_read(ht1); begin_read(ht2); - retval = zend_hash_compare(TS_HASH(ht1), TS_HASH(ht2), compar, ordered TSRMLS_CC); + retval = zend_hash_compare(&(ht1->hash), &(ht2->hash), compar, ordered TSRMLS_CC); end_read(ht2); end_read(ht1); @@ -295,7 +295,7 @@ int retval; begin_read(ht); - retval = zend_hash_minmax(TS_HASH(ht), compar, flag, pData TSRMLS_CC); + retval = zend_hash_minmax(&(ht->hash), compar, flag, pData TSRMLS_CC); end_read(ht); return retval; @@ -306,7 +306,7 @@ int retval; begin_read(ht); - retval = zend_hash_num_elements(TS_HASH(ht)); + retval = zend_hash_num_elements(&(ht->hash)); end_read(ht); return retval; @@ -317,7 +317,7 @@ int retval; begin_write(ht); - retval = zend_hash_rehash(TS_HASH(ht)); + retval = zend_hash_rehash(&(ht->hash)); end_write(ht); return retval; @@ -327,14 +327,14 @@ void zend_ts_hash_display_pListTail(TsHashTable *ht) { begin_read(ht); - zend_hash_display_pListTail(TS_HASH(ht)); + zend_hash_display_pListTail(&(ht->hash)); end_read(ht); } void zend_ts_hash_display(TsHashTable *ht) { begin_read(ht); - zend_hash_display(TS_HASH(ht)); + zend_hash_display(&(ht->hash)); end_read(ht); } #endif 1.4 +0 -2 ZendEngine2/zend_ts_hash.h Index: zend_ts_hash.h =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_ts_hash.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- zend_ts_hash.h 2 Aug 2002 09:48:15 -0000 1.3 +++ zend_ts_hash.h 3 Aug 2002 08:56:16 -0000 1.4 @@ -32,8 +32,6 @@ BEGIN_EXTERN_C() -#define TS_HASH(table) (&(table->hash)) - /* startup/shutdown */ ZEND_API int zend_ts_hash_init(TsHashTable *ht, uint nSize, hash_func_t pHashFunction, dtor_func_t pDestructor, zend_bool persistent); ZEND_API int zend_ts_hash_init_ex(TsHashTable *ht, uint nSize, hash_func_t pHashFunction, dtor_func_t pDestructor, zend_bool persistent, zend_bool bApplyProtection); 1.4 +31 -0 ZendEngine2/zend_variables.c Index: zend_variables.c =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_variables.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- zend_variables.c 2 Aug 2002 09:48:15 -0000 1.3 +++ zend_variables.c 3 Aug 2002 08:56:16 -0000 1.4 @@ -138,6 +138,37 @@ } +ZEND_API int zval_persist(zval *zvalue TSRMLS_DC) +{ + switch (zvalue->type) { + case IS_OBJECT: + case IS_RESOURCE: + return FAILURE; /* resources and objects cannot be persisted */ + break; + case IS_BOOL: + case IS_LONG: + case IS_NULL: + break; + case IS_CONSTANT: + case IS_STRING: + if (zvalue->value.str.val) { + if (zvalue->value.str.len==0) { + zvalue->value.str.val = empty_string; + return SUCCESS; + } + } + persist_alloc(zvalue->value.str.val); + break; + case IS_ARRAY: + case IS_CONSTANT_ARRAY: + persist_alloc(zvalue->value.ht); + zend_hash_apply(zvalue->value.ht, (apply_func_t) zval_persist TSRMLS_CC); + break; + } + return SUCCESS; +} + + ZEND_API int zend_print_variable(zval *var) { return zend_print_zval(var, 0); 1.4 +2 -0 ZendEngine2/zend_variables.h Index: zend_variables.h =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_variables.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- zend_variables.h 2 Aug 2002 09:48:15 -0000 1.3 +++ zend_variables.h 3 Aug 2002 08:56:16 -0000 1.4 @@ -32,6 +32,8 @@ #define zval_dtor(zvalue) _zval_dtor((zvalue) ZEND_FILE_LINE_CC) #define zval_ptr_dtor(zval_ptr) _zval_ptr_dtor((zval_ptr) ZEND_FILE_LINE_CC) +ZEND_API int zval_persist(zval *zvalue TSRMLS_DC); + #if ZEND_DEBUG ZEND_API int _zval_copy_ctor_wrapper(zval *zvalue); ZEND_API void _zval_dtor_wrapper(zval *zvalue);