Yasuo Ohgaki
yohga****@users*****
2002年 8月 2日 (金) 18:48:16 JST
yohgaki 02/08/02 18:48:16 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_modules.h zend_object_handlers.c zend_object_handlers.h zend_objects.c zend_objects.h zend_operators.c zend_ts_hash.c zend_ts_hash.h zend_variables.c zend_variables.h Added: . zend_config.nw.h zend_mm.c zend_mm.h zend_objects_API.c zend_objects_API.h zend_types.h RFCs 004.txt Log: Merge from cvs.php.net Revision Changes Path 1.7 +308 -0 ZendEngine2/ChangeLog Index: ChangeLog =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/ChangeLog,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- ChangeLog 19 May 2002 23:06:12 -0000 1.6 +++ ChangeLog 2 Aug 2002 09:48:15 -0000 1.7 @@ -1,3 +1,311 @@ +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.3 +2 -1 ZendEngine2/Makefile.am Index: Makefile.am =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/Makefile.am,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- Makefile.am 29 Apr 2002 02:25:26 -0000 1.2 +++ Makefile.am 2 Aug 2002 09:48:15 -0000 1.3 @@ -13,7 +13,8 @@ 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_ini.c zend_qsort.c zend_objects.c zend_object_handlers.c \ + zend_object_API.c libZend_la_LDFLAGS = libZend_la_LIBADD = @ZEND_EXTRA_LIBS@ 1.4 +50 -48 ZendEngine2/ZEND_CHANGES Index: ZEND_CHANGES =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/ZEND_CHANGES,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- ZEND_CHANGES 19 May 2002 23:06:12 -0000 1.3 +++ ZEND_CHANGES 2 Aug 2002 09:48:15 -0000 1.4 @@ -19,15 +19,6 @@ 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 @@ -68,18 +59,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: @@ -88,15 +79,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: @@ -143,7 +134,7 @@ script, this script will yield a parser error with the Zend Engine 2.0, since 'delete' is now a reserved word. - * Namespaces. + * Nested classes (namespaces). The Zend Engine 1.0 provided only three scopes: the global scope, the class scope and the function scope. All scopes but @@ -153,21 +144,31 @@ 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 namespaces to - manage the symbol collision problem by making it possible to + The Zend Engine 2.0 introduces the concept of nested classes + to solve 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 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] + 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. + * Classes may contain classes. @@ -188,7 +189,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'); @@ -252,7 +253,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 @@ -307,7 +308,7 @@ class MyOuterClass { const Hello = "Hello, World\n"; } - + import const Hello from MyOuterClass; print Hello; ?> @@ -339,14 +340,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"; } } @@ -389,7 +390,7 @@ function __destruct() { print 'Destroying ' . $this->name . "\n"; - } + } } $obj = new MyDestructableClass(); @@ -441,20 +442,20 @@ Old code that has no user-defined functions 'catch', 'throw' and 'try' will run without modifications. - * Derefencing objects returned from functions. + * Dereferencing 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"; } } @@ -514,6 +515,7 @@ } ?> + * __autoload(). TBD. Changes in the Zend Engine 1.0 1.3 +4 -0 ZendEngine2/Zend.dsp Index: Zend.dsp =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/Zend.dsp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- Zend.dsp 29 Apr 2002 02:25:26 -0000 1.2 +++ Zend.dsp 2 Aug 2002 09:48:15 -0000 1.3 @@ -187,6 +187,10 @@ # 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.3 +2 -2 ZendEngine2/Zend.m4 Index: Zend.m4 =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/Zend.m4,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- Zend.m4 29 Apr 2002 02:25:26 -0000 1.2 +++ Zend.m4 2 Aug 2002 09:48:15 -0000 1.3 @@ -1,5 +1,5 @@ dnl -dnl $Id: Zend.m4,v 1.30 2002/04/22 11:06:22 sebastian Exp $ +dnl $Id: Zend.m4,v 1.31 2002/06/24 16:10:33 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 experimental ZTS) +AC_MSG_CHECKING(whether to enable thread-safety) AC_MSG_RESULT($ZEND_EXPERIMENTAL_ZTS) AC_MSG_CHECKING(whether to enable inline optimization for GCC) 1.3 +16 -0 ZendEngine2/ZendTS.dsp Index: ZendTS.dsp =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/ZendTS.dsp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ZendTS.dsp 29 Apr 2002 02:25:26 -0000 1.2 +++ ZendTS.dsp 2 Aug 2002 09:48:15 -0000 1.3 @@ -212,6 +212,10 @@ # 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 @@ -220,6 +224,10 @@ # 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 @@ -364,6 +372,10 @@ # 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 @@ -373,6 +385,10 @@ # 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.3 +4 -0 ZendEngine2/acconfig.h Index: acconfig.h =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/acconfig.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- acconfig.h 29 Apr 2002 02:25:26 -0000 1.2 +++ acconfig.h 2 Aug 2002 09:48:15 -0000 1.3 @@ -2,7 +2,9 @@ #define ZEND_DLEXPORT #define ZEND_DLIMPORT +#ifndef NETWARE @TOP@ +#endif #undef uint #undef ulong @@ -10,7 +12,9 @@ /* 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.4 +1 -1 ZendEngine2/zend.c Index: zend.c =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- zend.c 9 May 2002 04:31:04 -0000 1.3 +++ zend.c 2 Aug 2002 09:48:15 -0000 1.4 @@ -500,7 +500,7 @@ zend_destroy_rsrc_list(&EG(persistent_list) TSRMLS_CC); #endif zend_destroy_rsrc_list_dtors(); - zend_hash_destroy(&module_registry); + zend_hash_graceful_reverse_destroy(&module_registry); #ifndef ZTS /* In ZTS mode these are freed by compiler_globals_dtor() */ 1.5 +19 -18 ZendEngine2/zend.h Index: zend.h =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- zend.h 12 May 2002 23:15:01 -0000 1.4 +++ zend.h 2 Aug 2002 09:48:15 -0000 1.5 @@ -17,12 +17,12 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend.h,v 1.170 2002/05/02 17:20:48 andi Exp $ */ +/* $Id: zend.h,v 1.175 2002/06/29 19:37:10 andi Exp $ */ #ifndef ZEND_H #define ZEND_H -#define ZEND_VERSION "2.0.0-dev" +#define ZEND_VERSION "2.0.0-alpha2" #define ZEND_ENGINE_2 #define ZEND_MULTIBYTE @@ -44,6 +44,9 @@ #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 ';' @@ -52,6 +55,18 @@ # 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 @@ -119,7 +134,7 @@ # endif #endif -#if (HAVE_ALLOCA || (defined (__GNUC__) && __GNUC__ >= 2)) && !(defined(ZTS) && defined(ZEND_WIN32)) +#if (HAVE_ALLOCA || (defined (__GNUC__) && __GNUC__ >= 2)) && !(defined(ZTS) && defined(ZEND_WIN32)) && !(defined(ZTS) && defined(NETWARE)) # define do_alloca(p) alloca(p) # define free_alloca(p) #else @@ -164,11 +179,7 @@ #include "zend_errors.h" #include "zend_alloc.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; +#include "zend_types.h" #ifdef HAVE_LIMITS_H # include <limits.h> @@ -539,16 +550,6 @@ #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.4 +1 -1 ZendEngine2/zend_API.c Index: zend_API.c =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_API.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- zend_API.c 2 May 2002 23:04:38 -0000 1.3 +++ zend_API.c 2 Aug 2002 09:48:15 -0000 1.4 @@ -1362,7 +1362,7 @@ lcname = estrndup(Z_STRVAL_PP(obj), Z_STRLEN_PP(obj)); zend_str_tolower(lcname, Z_STRLEN_PP(obj)); - if(zend_hash_find(EG(class_table), lcname, Z_STRLEN_PP(obj) + 1, (void**)&pce) == SUCCESS) { + if (zend_lookup_class(lcname, Z_STRLEN_PP(obj), &pce TSRMLS_CC) == SUCCESS) { ce = *pce; } 1.4 +5 -13 ZendEngine2/zend_API.h Index: zend_API.h =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_API.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- zend_API.h 2 May 2002 23:04:38 -0000 1.3 +++ zend_API.h 2 Aug 2002 09:48:15 -0000 1.4 @@ -29,6 +29,8 @@ #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)) @@ -82,19 +84,7 @@ -#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_CLASS_ENTRY(class_container, class_name, functions) INIT_OVERLOADED_CLASS_ENTRY(class_container, class_name, functions, NULL, NULL, NULL) #define INIT_OVERLOADED_CLASS_ENTRY(class_container, class_name, functions, handle_fcall, handle_propget, handle_propset) \ { \ @@ -426,6 +416,8 @@ #define ZEND_RSHUTDOWN_FUNCTION ZEND_MODULE_DEACTIVATE_D #define ZEND_MINFO_FUNCTION ZEND_MODULE_INFO_D +END_EXTERN_C() + #endif /* ZEND_API_H */ 1.3 +72 -85 ZendEngine2/zend_alloc.c Index: zend_alloc.c =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_alloc.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- zend_alloc.c 29 Apr 2002 02:25:26 -0000 1.2 +++ zend_alloc.c 2 Aug 2002 09:48:15 -0000 1.3 @@ -31,15 +31,24 @@ # 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_WIN32 +#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) #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)) @@ -88,10 +97,8 @@ #define REMOVE_POINTER_FROM_LIST(p) \ - if (!p->persistent && p==AG(head)) { \ + if (p==AG(head)) { \ AG(head) = p->pNext; \ - } else if (p->persistent && p==AG(phead)) { \ - AG(phead) = p->pNext; \ } else { \ p->pLast->pNext = p->pNext; \ } \ @@ -100,19 +107,11 @@ } #define ADD_POINTER_TO_LIST(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->pNext = AG(head); \ + if (AG(head)) { \ + AG(head)->pLast = p; \ + } \ + AG(head) = p; \ p->pLast = (zend_mem_header *) NULL; #define DECLARE_CACHE_VARS() \ @@ -152,7 +151,6 @@ 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); @@ -177,8 +175,10 @@ HANDLE_UNBLOCK_INTERRUPTIONS(); return (void *)p; } - p->persistent = p->cached = 0; + p->cached = 0; +#if ZEND_DEBUG || !defined(ZEND_MM) 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 - && !p->persistent && (CACHE_INDEX < MAX_CACHED_MEMORY) && (AG(cache_count)[CACHE_INDEX] < MAX_CACHED_ENTRIES)) { + && (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,7 +237,9 @@ return; } HANDLE_BLOCK_INTERRUPTIONS(); +#if ZEND_DEBUG || !defined(ZEND_MM) REMOVE_POINTER_FROM_LIST(p); +#endif #if MEMORY_LIMIT AG(allocated_memory) -= SIZE; @@ -294,7 +296,9 @@ 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) { @@ -305,11 +309,15 @@ 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; @@ -396,14 +404,7 @@ ZEND_API void start_memory_manager(TSRMLS_D) { -#if 0 -#ifndef ZTS - int i, j; - void *cached_entries[MAX_CACHED_MEMORY][MAX_CACHED_ENTRIES]; -#endif -#endif - - AG(phead) = AG(head) = NULL; + AG(head) = NULL; #if MEMORY_LIMIT AG(memory_limit) = 1<<30; /* ridiculous limit, effectively no limit */ @@ -412,30 +413,17 @@ 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))); - -#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 +#ifdef ZEND_MM + zend_mm_startup(&AG(mm_heap), 256*1024); +#elif defined(ZEND_WIN32) + AG(memory_heap) = HeapCreate(HEAP_NO_SERIALIZE, 256*1024, 0); #endif #if ZEND_DEBUG @@ -448,30 +436,43 @@ 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_WIN32) && !ZEND_DEBUG +#if defined(ZEND_MM) && !ZEND_DEBUG + if (clean_cache) { + zend_mm_shutdown(&AG(mm_heap)); + return; + } +#elif defined(ZEND_WIN32) && !ZEND_DEBUG if (clean_cache && AG(memory_heap)) { HeapDestroy(AG(memory_heap)); return; } #endif - 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; +#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; } - 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++) { @@ -486,7 +487,9 @@ AG(cache_count)[i] = 0; } } +#endif /* !ZEND_DISABLE_MEMORY_CACHE */ +#if ZEND_DEBUG || !defined(ZEND_MM) p = AG(head); t = AG(head); while (t) { @@ -571,14 +574,21 @@ } } while (0); +#endif -#if defined(ZEND_WIN32) && ZEND_DEBUG +#endif + +#if defined(ZEND_MM) && ZEND_DEBUG + if (clean_cache) { + zend_mm_shutdown(&AG(mm_heap)); + return; + } +#elif defined(ZEND_WIN32) && ZEND_DEBUG if (clean_cache && AG(memory_heap)) { HeapDestroy(AG(memory_heap)); + return; } #endif - -#endif } @@ -735,29 +745,6 @@ 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.3 +5 -5 ZendEngine2/zend_alloc.h Index: zend_alloc.h =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_alloc.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- zend_alloc.h 29 Apr 2002 02:25:26 -0000 1.2 +++ zend_alloc.h 2 Aug 2002 09:48:15 -0000 1.3 @@ -26,6 +26,8 @@ #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 @@ -43,10 +45,11 @@ THREAD_T thread_id; # endif #endif +#if ZEND_DEBUG || !defined(ZEND_MM) struct _zend_mem_header *pNext; struct _zend_mem_header *pLast; - unsigned int size:30; - unsigned int persistent:1; +#endif + unsigned int size:31; unsigned int cached:1; } zend_mem_header; @@ -79,7 +82,6 @@ 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) @@ -89,7 +91,6 @@ #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) @@ -99,7 +100,6 @@ #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.6 +21 -15 ZendEngine2/zend_builtin_functions.c Index: zend_builtin_functions.c =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_builtin_functions.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- zend_builtin_functions.c 19 May 2002 23:06:12 -0000 1.5 +++ zend_builtin_functions.c 2 Aug 2002 09:48:15 -0000 1.6 @@ -559,7 +559,7 @@ SEPARATE_ZVAL(arg); zend_str_tolower(Z_STRVAL_PP(arg), Z_STRLEN_PP(arg)); - if(zend_hash_find(EG(class_table), Z_STRVAL_PP(arg), Z_STRLEN_PP(arg)+1, (void **)&pce) == SUCCESS) { + if (zend_lookup_class(Z_STRVAL_PP(arg), Z_STRLEN_PP(arg), &pce TSRMLS_CC) == SUCCESS) { ce = *pce; } } @@ -588,7 +588,7 @@ } /* TBI!! new object handlers */ - if(!IS_ZEND_STD_OBJECT(**obj)) { + if(!HAS_CLASS_ENTRY(**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_hash_find(EG(class_table), lcname, (*class_name)->value.str.len+1, (void **)&pce) == FAILURE) { + if (zend_lookup_class(lcname, Z_STRLEN_PP(class_name), &pce TSRMLS_CC) == FAILURE) { efree(lcname); RETURN_FALSE; } else { @@ -706,14 +706,15 @@ if (Z_TYPE_PP(class) == IS_OBJECT) { /* TBI!! new object handlers */ - if(!IS_ZEND_STD_OBJECT(**class)) { + if(!HAS_CLASS_ENTRY(**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_hash_find(EG(class_table), Z_STRVAL_PP(class), Z_STRLEN_PP(class)+1, (void **)&pce) == SUCCESS) { + + if (zend_lookup_class(Z_STRVAL_PP(class), Z_STRLEN_PP(class), &pce TSRMLS_CC) == SUCCESS) { ce = *pce; } } @@ -751,7 +752,7 @@ } /* TBI!! new object handlers */ - if(!IS_ZEND_STD_OBJECT(**klass)) { + if(!HAS_CLASS_ENTRY(**klass)) { RETURN_FALSE; } @@ -1198,6 +1199,7 @@ 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; @@ -1230,15 +1232,19 @@ filename = ptr->function_state.function->op_array.filename; - 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 (!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; + } if (ptr->opline) { lineno = ptr->opline->lineno; 1.3 +31 -28 ZendEngine2/zend_compile.c Index: zend_compile.c =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_compile.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- zend_compile.c 29 Apr 2002 02:25:26 -0000 1.2 +++ zend_compile.c 2 Aug 2002 09:48:15 -0000 1.3 @@ -243,7 +243,7 @@ opline->opcode = ZEND_ASSIGN_BW_XOR_OBJ; break; default: - zend_error(E_ERROR, "Unknown binary op opcode %d", op); + zend_error(E_COMPILE_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_ERROR, "Can't use method return value in write context"); + zend_error(E_COMPILE_ERROR, "Can't use method return value in write context"); } if (type == ZEND_PARSED_FUNCTION_CALL) { - zend_error(E_ERROR, "Can't use function return value in write context"); + zend_error(E_COMPILE_ERROR, "Can't use function return value in write context"); } } @@ -717,11 +717,6 @@ 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; @@ -1081,8 +1076,6 @@ 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 *)); @@ -1186,7 +1179,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_ERROR, "Can't pass arguments to __clone()"); + zend_error(E_COMPILE_ERROR, "Can't pass arguments to __clone()"); } /* FIXME: throw_list */ zend_stack_del_top(&CG(function_call_stack)); @@ -1411,7 +1404,7 @@ opline->op2.u.opline_num = *catch_opline; break; default: - zend_error(E_ERROR, "Bad opcode in throw list"); + zend_error(E_COMPILE_ERROR, "Bad opcode in throw list"); break; } } @@ -1478,16 +1471,25 @@ static void do_inherit_parent_constructor(zend_class_entry *ce) { - if (ce->parent - && !zend_hash_exists(&ce->function_table, ce->name, ce->name_length+1)) { - zend_function *function; + zend_function *function; + + if (!ce->parent || ce->constructor) { + return; + } + 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) @@ -1545,7 +1547,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_ERROR, "Can't create class. Fatal error, please report!"); + zend_error(E_COMPILE_ERROR, "Can't create class. Fatal error, please report!"); } } @@ -1584,7 +1586,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_ERROR, "Cannot redeclare class %s", last); + zend_error(E_COMPILE_ERROR, "Cannot redeclare class %s", last); return FAILURE; } return SUCCESS; @@ -2087,7 +2089,7 @@ if (CG(active_class_entry)) { if (runtime_inheritance) { - zend_error(E_ERROR, "Only first level classes can inherit from undefined classes"); + zend_error(E_COMPILE_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; @@ -2214,17 +2216,18 @@ SET_UNUSED(opline_ptr->op2); opline_ptr->op2.u.EA.type = ZEND_FETCH_FROM_THIS; - 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 (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; + } } - *result = opline_ptr->result; return; } 1.3 +28 -25 ZendEngine2/zend_constants.c Index: zend_constants.c =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_constants.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- zend_constants.c 29 Apr 2002 02:25:26 -0000 1.2 +++ zend_constants.c 2 Aug 2002 09:48:15 -0000 1.3 @@ -27,8 +27,7 @@ void free_zend_constant(zend_constant *c) { - if (!(c->flags & CONST_PERSISTENT) - || (c->flags & CONST_EFREE_PERSISTENT)) { + if (!(c->flags & CONST_PERSISTENT)) { zval_dtor(&c->value); } free(c->name); @@ -40,9 +39,6 @@ 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); - } } } @@ -220,26 +216,27 @@ { zend_constant *c; char *lookup_name; - int retval; - - lookup_name = do_alloca(name_len+1); - memcpy(lookup_name, name, name_len+1); + int retval = 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; + 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 { - retval=1; - *result = c->value; - zval_copy_ctor(result); + retval=0; } - } else { - retval=0; + free_alloca(lookup_name); } - free_alloca(lookup_name); + if (retval) { + *result = c->value; + zval_copy_ctor(result); + } return retval; } @@ -247,24 +244,30 @@ ZEND_API int zend_register_constant(zend_constant *c TSRMLS_DC) { - char *lowercase_name = zend_strndup(c->name, c->name_len); + char *lowercase_name; int ret = SUCCESS; #if 0 printf("Registering constant for module %d\n", c->module_number); #endif - zend_str_tolower(lowercase_name, c->name_len); + 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); + } + 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) - || (c->flags & CONST_EFREE_PERSISTENT)) { + if (!(c->flags & CONST_PERSISTENT)) { zval_dtor(&c->value); } zend_error(E_NOTICE,"Constant %s already defined", lowercase_name); ret = FAILURE; } - free(lowercase_name); + free_alloca(lowercase_name); return ret; } 1.3 +0 -4 ZendEngine2/zend_constants.h Index: zend_constants.h =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_constants.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- zend_constants.h 29 Apr 2002 02:25:27 -0000 1.2 +++ zend_constants.h 2 Aug 2002 09:48:15 -0000 1.3 @@ -25,10 +25,6 @@ #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.6 +17 -29 ZendEngine2/zend_execute.c Index: zend_execute.c =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_execute.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- zend_execute.c 12 May 2002 23:17:05 -0000 1.5 +++ zend_execute.c 2 Aug 2002 09:48:15 -0000 1.6 @@ -307,6 +307,7 @@ *retval = EG(uninitialized_zval_ptr); SELECTIVE_PZVAL_LOCK(*retval, result); + PZVAL_UNLOCK(value); return; } @@ -1551,8 +1552,12 @@ } NEXT_OPCODE(); case ZEND_ASSIGN_REF: - 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(); + { + 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(); + } case ZEND_JMP: #if DEBUG_ZEND>=2 printf("Jumping to %d\n", EX(opline)->op1.u.opline_num); @@ -1839,7 +1844,7 @@ class_name_strlen = tmp.value.str.len; } - if (zend_hash_find(EG(class_table), class_name_strval, class_name_strlen+1, (void **) &pce) == FAILURE) { + if (zend_lookup_class(class_name_strval, class_name_strlen, &pce TSRMLS_CC) == FAILURE) { zend_error(E_ERROR, "Class '%s' not found", class_name_strval); } else { EX(Ts)[EX(opline)->result.u.var].EA.class_entry = *pce; @@ -1881,7 +1886,9 @@ EX(fbc) = EX(fbc_constructor); if(EX(fbc)->type == ZEND_USER_FUNCTION) { /* HACK!! */ - EX(calling_scope) = Z_OBJCE_P(EX(object)); + /* The scope should be the scope of the class where the constructor + was initially declared in */ + EX(calling_scope) = EX(fbc)->common.scope; } else { EX(calling_scope) = NULL; } @@ -1891,31 +1898,15 @@ 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)); - 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 = 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; - 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) { @@ -1948,15 +1939,12 @@ } if(EX(fbc)->type == ZEND_USER_FUNCTION) { - EX(calling_scope) = Z_OBJCE_P(EX(object)); + EX(calling_scope) = EX(fbc)->common.scope; } else { EX(calling_scope) = NULL; } - if (!is_const) { - zval_dtor(&tmp); - FREE_OP(EX(Ts), &EX(opline)->op2, EG(free_op2)); - } + FREE_OP(EX(Ts), &EX(opline)->op2, EG(free_op2)); NEXT_OPCODE(); } @@ -2572,7 +2560,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 constant. Improve this error message"); + zend_error(E_ERROR, "Undefined class constant '%s'", EX(opline)->op2.u.constant.value.str.val); } } NEXT_OPCODE(); 1.3 +4 -1 ZendEngine2/zend_execute.h Index: zend_execute.h =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_execute.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- zend_execute.h 29 Apr 2002 02:25:27 -0000 1.2 +++ zend_execute.h 2 Aug 2002 09:48:15 -0000 1.3 @@ -49,6 +49,7 @@ } temp_variable; +BEGIN_EXTERN_C() ZEND_API extern void (*zend_execute)(zend_op_array *op_array TSRMLS_DC); void init_executor(TSRMLS_D); @@ -63,7 +64,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) @@ -160,5 +161,7 @@ #define IS_OVERLOADED_OBJECT 1 #define IS_STRING_OFFSET 2 + +END_EXTERN_C() #endif /* ZEND_EXECUTE_H */ 1.4 +43 -11 ZendEngine2/zend_execute_API.c Index: zend_execute_API.c =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_execute_API.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- zend_execute_API.c 9 May 2002 04:31:04 -0000 1.3 +++ zend_execute_API.c 2 Aug 2002 09:48:15 -0000 1.4 @@ -160,7 +160,7 @@ zend_ptr_stack_init(&EG(user_error_handlers)); EG(orig_error_reporting) = EG(error_reporting); - zend_objects_init(&EG(objects), 1024); + zend_objects_store_init(&EG(objects_store), 1024); EG(full_tables_cleanup) = 0; #ifdef ZEND_WIN32 @@ -183,7 +183,7 @@ void shutdown_executor(TSRMLS_D) { zend_try { - zend_objects_call_destructors(&EG(objects) TSRMLS_CC); + zend_objects_store_call_destructors(&EG(objects_store) 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_destroy(&EG(objects)); + zend_objects_store_destroy(&EG(objects_store)); } 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_hash_find(EG(class_table), last, strlen(last)+1, (void **)&ce) == FAILURE) { - zend_error(E_ERROR, "Invalid class! Improve this error message"); + if (zend_lookup_class(last, strlen(last), &ce TSRMLS_CC) == FAILURE) { + zend_error(E_ERROR, "Undefined class '%s'", last); } 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, "Invalid class! Improve this error message"); + if (zend_hash_find(&(*ce)->class_table, last, strlen(last)+1, (void **)&ce) == FAILURE) { + zend_error(E_ERROR, "Undefined sub-class '%s'", last); } last = cur; } - if (zend_hash_find(&ce->constants_table, last, strlen(last)+1, (void **) &value) == FAILURE) { - zend_error(E_ERROR, "Invalid class! Improve this error message"); + if (zend_hash_find(&(*ce)->constants_table, last, strlen(last)+1, (void **) &value) == FAILURE) { + zend_error(E_ERROR, "Undefined class constant '%s'", last); } 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_hash_find(EG(class_table), lc_class, Z_STRLEN_PP(object_pp) + 1, (void **) &ce); + found = zend_lookup_class(lc_class, Z_STRLEN_PP(object_pp), &ce TSRMLS_CC); efree(lc_class); if (found == FAILURE) return FAILURE; @@ -637,6 +637,38 @@ 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.3 +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.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- zend_fast_cache.h 29 Apr 2002 02:25:27 -0000 1.2 +++ zend_fast_cache.h 2 Aug 2002 09:48:15 -0000 1.3 @@ -25,7 +25,7 @@ # if ZEND_DEBUG # define ZEND_ENABLE_FAST_CACHE 0 # else -# define ZEND_ENABLE_FAST_CACHE 1 +# define ZEND_ENABLE_FAST_CACHE 0 # endif #endif 1.4 +6 -2 ZendEngine2/zend_globals.h Index: zend_globals.h =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_globals.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- zend_globals.h 9 May 2002 04:31:04 -0000 1.3 +++ zend_globals.h 2 Aug 2002 09:48:15 -0000 1.4 @@ -32,6 +32,7 @@ #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*/ @@ -200,7 +201,7 @@ int lambda_count; HashTable ini_directives; - zend_objects objects; + zend_objects_store objects_store; zval *exception; struct _zend_execute_data *current_execute_data; @@ -208,10 +209,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]; @@ -230,6 +231,9 @@ unsigned int allocated_memory; unsigned int allocated_memory_peak; unsigned char memory_exhausted; +#endif +#ifdef ZEND_MM + zend_mm_heap mm_heap; #endif }; 1.3 +58 -6 ZendEngine2/zend_hash.h Index: zend_hash.h =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_hash.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- zend_hash.h 29 Apr 2002 02:25:27 -0000 1.2 +++ zend_hash.h 2 Aug 2002 09:48:15 -0000 1.3 @@ -21,6 +21,7 @@ #define ZEND_HASH_H #include <sys/types.h> +#include "zend.h" #define HASH_KEY_IS_STRING 1 #define HASH_KEY_IS_LONG 2 @@ -188,17 +189,68 @@ 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) { - ulong h = 5381; - char *arEnd = arKey + nKeyLength; + register ulong hash = 5381; - while (arKey < arEnd) { - h += (h << 5); - h ^= (ulong) *arKey++; + /* 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++; } - return h; + 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; } + ZEND_API ulong zend_hash_func(char *arKey, uint nKeyLength); 1.3 +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.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- zend_ini_scanner.l 29 Apr 2002 02:25:27 -0000 1.2 +++ zend_ini_scanner.l 2 Aug 2002 09:48:15 -0000 1.3 @@ -125,11 +125,11 @@ return CFG_FALSE; } -<INITIAL>[[][^[]+[\]]{NEWLINE}? { +<INITIAL>[[][^[]+[\]][ ]*{NEWLINE}? { /* SECTION */ - /* eat trailng ] */ - while (yyleng>0 && (yytext[yyleng-1]=='\n' || yytext[yyleng-1]=='\r' || yytext[yyleng-1]==']')) { + /* eat trailng and spaces ] */ + while (yyleng>0 && (yytext[yyleng-1]=='\n' || yytext[yyleng-1]=='\r' || yytext[yyleng-1]==']' || yytext[yyleng-1]==' ')) { yyleng--; yytext[yyleng]=0; } 1.3 +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.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- zend_language_parser.y 29 Apr 2002 02:25:27 -0000 1.2 +++ zend_language_parser.y 2 Aug 2002 09:48:15 -0000 1.3 @@ -173,7 +173,6 @@ 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); } @@ -440,6 +439,7 @@ 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 '=' '&' 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 '=' '&' 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 '=' '&' 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 { $$ = $1; } + | '+' static_scalar { $$ = $2; } | '-' 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.3 +2 -0 ZendEngine2/zend_list.h Index: zend_list.h =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_list.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- zend_list.h 29 Apr 2002 02:25:27 -0000 1.2 +++ zend_list.h 2 Aug 2002 09:48:15 -0000 1.3 @@ -24,6 +24,7 @@ #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 @@ -105,5 +106,6 @@ if (le_id == 0) { \ le_id = zend_fetch_list_dtor_id(le_type_name); \ } +END_EXTERN_C() #endif 1.3 +3 -0 ZendEngine2/zend_llist.c Index: zend_llist.c =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_llist.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- zend_llist.c 29 Apr 2002 02:25:27 -0000 1.2 +++ zend_llist.c 2 Aug 2002 09:48:15 -0000 1.3 @@ -140,6 +140,9 @@ data = old_tail->data; l->tail = l->tail->prev; + if (l->dtor) { + l->dtor(data); + } pefree(old_tail, l->persistent); --l->count; 1.3 +1 -1 ZendEngine2/zend_modules.h Index: zend_modules.h =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_modules.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- zend_modules.h 29 Apr 2002 02:25:27 -0000 1.2 +++ zend_modules.h 2 Aug 2002 09:48:15 -0000 1.3 @@ -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 20010927 +#define ZEND_MODULE_API_NO 20020429 #ifdef ZTS #define USING_ZTS 1 #else 1.4 +14 -6 ZendEngine2/zend_object_handlers.c Index: zend_object_handlers.c =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_object_handlers.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- zend_object_handlers.c 2 May 2002 23:04:38 -0000 1.3 +++ zend_object_handlers.c 2 Aug 2002 09:48:15 -0000 1.4 @@ -3,6 +3,7 @@ #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 @@ -151,12 +152,19 @@ { 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, method_name, method_len+1, (void **)&func_method) == FAILURE) { + if(zend_hash_find(&zobj->ce->function_table, lc_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; } @@ -224,9 +232,9 @@ } zend_object_handlers std_object_handlers = { - zend_objects_add_ref, /* add_ref */ - zend_objects_del_ref, /* del_ref */ - zend_objects_delete_obj, /* delete_obj */ + zend_objects_store_add_ref, /* add_ref */ + zend_objects_store_del_ref, /* del_ref */ + zend_objects_store_delete_obj, /* delete_obj */ zend_objects_clone_obj, /* clone_obj */ zend_std_read_property, /* read_property */ 1.4 +1 -0 ZendEngine2/zend_object_handlers.h Index: zend_object_handlers.h =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_object_handlers.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- zend_object_handlers.h 2 May 2002 23:04:38 -0000 1.3 +++ zend_object_handlers.h 2 Aug 2002 09:48:15 -0000 1.4 @@ -74,5 +74,6 @@ 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.4 +8 -143 ZendEngine2/zend_objects.c Index: zend_objects.c =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_objects.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- zend_objects.c 19 May 2002 23:06:12 -0000 1.3 +++ zend_objects.c 2 Aug 2002 09:48:15 -0000 1.4 @@ -3,21 +3,6 @@ #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) { @@ -58,142 +43,27 @@ zend_objects_call_destructor(object, handle TSRMLS_CC); /* Nuke the object */ zend_hash_destroy(object->properties); - efree(object->properties); - + FREE_HASHTABLE(object->properties); + efree(object); } - -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(); - 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 = emalloc(sizeof(zend_object)); (*object)->ce = class_type; - - retval.handle = handle; + retval.handle = zend_objects_store_put(*object, (zend_objects_store_dtor_t) zend_objects_destroy_object, NULL TSRMLS_CC); retval.handlers = &std_object_handlers; -#if ZEND_DEBUG_OBJECTS - fprintf(stderr, "Allocated object id #%d\n", handle); -#endif return retval; } -zend_object *zend_objects_get_address(zval *zobject) +ZEND_API zend_object *zend_objects_get_address(zval *zobject) { - zend_object_handle handle = Z_OBJ_HANDLE_P(zobject); TSRMLS_FETCH(); - - 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 + return (zend_object *)zend_object_store_get_object(zobject TSRMLS_CC); } zend_object_value zend_objects_clone_obj(zval *zobject TSRMLS_DC) @@ -203,12 +73,7 @@ zend_object *new_object; zend_object_handle handle = Z_OBJ_HANDLE_P(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; + old_object = zend_objects_get_address(zobject); retval = zend_objects_new(&new_object, old_object->ce); if (old_object->ce->clone) { 1.4 +1 -30 ZendEngine2/zend_objects.h Index: zend_objects.h =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_objects.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- zend_objects.h 19 May 2002 23:06:12 -0000 1.3 +++ zend_objects.h 2 Aug 2002 09:48:15 -0000 1.4 @@ -3,37 +3,8 @@ #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_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_API zend_object *zend_objects_get_address(zval *object); zend_object_value zend_objects_clone_obj(zval *object TSRMLS_DC); #endif /* ZEND_OBJECTS_H */ 1.3 +18 -10 ZendEngine2/zend_operators.c Index: zend_operators.c =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_operators.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- zend_operators.c 29 Apr 2002 02:25:27 -0000 1.2 +++ zend_operators.c 2 Aug 2002 09:48:15 -0000 1.3 @@ -1509,6 +1509,7 @@ ZEND_API int decrement_function(zval *op1) { long lval; + double dval; switch (op1->type) { case IS_LONG: @@ -1528,16 +1529,23 @@ op1->value.lval = -1; op1->type = IS_LONG; 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; + } + 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; } break; default: 1.3 +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.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- zend_ts_hash.c 29 Apr 2002 02:25:28 -0000 1.2 +++ zend_ts_hash.c 2 Aug 2002 09:48:15 -0000 1.3 @@ -55,7 +55,7 @@ ht->mx_reader = tsrm_mutex_alloc(); ht->mx_writer = tsrm_mutex_alloc(); ht->reader = 0; - return zend_hash_init(&(ht->hash), nSize, pHashFunction, pDestructor, persistent); + return zend_hash_init(TS_HASH(ht), 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(&(ht->hash), nSize, pHashFunction, pDestructor, persistent, bApplyProtection); + return zend_hash_init_ex(TS_HASH(ht), 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(&(ht->hash)); + zend_hash_destroy(TS_HASH(ht)); } ZEND_API void zend_ts_hash_clean(TsHashTable *ht) { ht->reader = 0; - zend_hash_clean(&(ht->hash)); + zend_hash_clean(TS_HASH(ht)); } 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(&(ht->hash), arKey, nKeyLength, pData, nDataSize, pDest, flag); + retval = zend_hash_add_or_update(TS_HASH(ht), 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(&(ht->hash), arKey, nKeyLength, h, pData, nDataSize, pDest, flag); + retval = zend_hash_quick_add_or_update(TS_HASH(ht), 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(&(ht->hash), h, pData, nDataSize, pDest, flag); + retval = zend_hash_index_update_or_next_insert(TS_HASH(ht), 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(&(ht->hash), arKey, nKeyLength); + retval = zend_hash_add_empty_element(TS_HASH(ht), 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(&(ht->hash)); + zend_hash_graceful_destroy(TS_HASH(ht)); } ZEND_API void zend_ts_hash_apply(TsHashTable *ht, apply_func_t apply_func TSRMLS_DC) { begin_write(ht); - zend_hash_apply(&(ht->hash), apply_func TSRMLS_CC); + zend_hash_apply(TS_HASH(ht), 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(&(ht->hash), apply_func, argument TSRMLS_CC); + zend_hash_apply_with_argument(TS_HASH(ht), 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(&(ht->hash), apply_func, num_args, args); + zend_hash_apply_with_arguments(TS_HASH(ht), 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(&(ht->hash), apply_func TSRMLS_CC); + zend_hash_reverse_apply(TS_HASH(ht), apply_func TSRMLS_CC); end_write(ht); } @@ -167,7 +167,7 @@ int retval; begin_write(ht); - retval = zend_hash_del_key_or_index(&(ht->hash), arKey, nKeyLength, h, flag); + retval = zend_hash_del_key_or_index(TS_HASH(ht), arKey, nKeyLength, h, flag); end_write(ht); return retval; @@ -178,7 +178,7 @@ ulong retval; begin_read(ht); - retval = zend_get_hash_value(&(ht->hash), arKey, nKeyLength); + retval = zend_get_hash_value(TS_HASH(ht), arKey, nKeyLength); end_read(ht); return retval; @@ -189,7 +189,7 @@ int retval; begin_read(ht); - retval = zend_hash_find(&(ht->hash), arKey, nKeyLength, pData); + retval = zend_hash_find(TS_HASH(ht), arKey, nKeyLength, pData); end_read(ht); return retval; @@ -200,7 +200,7 @@ int retval; begin_read(ht); - retval = zend_hash_quick_find(&(ht->hash), arKey, nKeyLength, h, pData); + retval = zend_hash_quick_find(TS_HASH(ht), arKey, nKeyLength, h, pData); end_read(ht); return retval; @@ -211,7 +211,7 @@ int retval; begin_read(ht); - retval = zend_hash_index_find(&(ht->hash), h, pData); + retval = zend_hash_index_find(TS_HASH(ht), h, pData); end_read(ht); return retval; @@ -222,7 +222,7 @@ int retval; begin_read(ht); - retval = zend_hash_exists(&(ht->hash), arKey, nKeyLength); + retval = zend_hash_exists(TS_HASH(ht), arKey, nKeyLength); end_read(ht); return retval; @@ -233,7 +233,7 @@ int retval; begin_read(ht); - retval = zend_hash_index_exists(&(ht->hash), h); + retval = zend_hash_index_exists(TS_HASH(ht), h); end_read(ht); return retval; @@ -243,7 +243,7 @@ { begin_read(source); begin_write(target); - zend_hash_copy(&(target->hash), &(source->hash), pCopyConstructor, tmp, size); + zend_hash_copy(TS_HASH(target), TS_HASH(source), pCopyConstructor, tmp, size); end_write(target); end_read(source); } @@ -252,7 +252,7 @@ { begin_read(source); begin_write(target); - zend_hash_merge(&(target->hash), &(source->hash), pCopyConstructor, tmp, size, overwrite); + zend_hash_merge(TS_HASH(target), TS_HASH(source), pCopyConstructor, tmp, size, overwrite); end_write(target); end_read(source); } @@ -261,7 +261,7 @@ { begin_read(source); begin_write(target); - zend_hash_merge_ex(&(target->hash), &(source->hash), pCopyConstructor, size, pReplaceOrig); + zend_hash_merge_ex(TS_HASH(target), TS_HASH(source), pCopyConstructor, size, pReplaceOrig); end_write(target); end_read(source); } @@ -271,7 +271,7 @@ int retval; begin_write(ht); - retval = zend_hash_sort(&(ht->hash), sort_func, compare_func, renumber TSRMLS_CC); + retval = zend_hash_sort(TS_HASH(ht), 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(&(ht1->hash), &(ht2->hash), compar, ordered TSRMLS_CC); + retval = zend_hash_compare(TS_HASH(ht1), TS_HASH(ht2), compar, ordered TSRMLS_CC); end_read(ht2); end_read(ht1); @@ -295,7 +295,7 @@ int retval; begin_read(ht); - retval = zend_hash_minmax(&(ht->hash), compar, flag, pData TSRMLS_CC); + retval = zend_hash_minmax(TS_HASH(ht), compar, flag, pData TSRMLS_CC); end_read(ht); return retval; @@ -306,7 +306,7 @@ int retval; begin_read(ht); - retval = zend_hash_num_elements(&(ht->hash)); + retval = zend_hash_num_elements(TS_HASH(ht)); end_read(ht); return retval; @@ -317,7 +317,7 @@ int retval; begin_write(ht); - retval = zend_hash_rehash(&(ht->hash)); + retval = zend_hash_rehash(TS_HASH(ht)); end_write(ht); return retval; @@ -327,14 +327,14 @@ void zend_ts_hash_display_pListTail(TsHashTable *ht) { begin_read(ht); - zend_hash_display_pListTail(&(ht->hash)); + zend_hash_display_pListTail(TS_HASH(ht)); end_read(ht); } void zend_ts_hash_display(TsHashTable *ht) { begin_read(ht); - zend_hash_display(&(ht->hash)); + zend_hash_display(TS_HASH(ht)); end_read(ht); } #endif 1.3 +2 -0 ZendEngine2/zend_ts_hash.h Index: zend_ts_hash.h =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_ts_hash.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- zend_ts_hash.h 29 Apr 2002 02:25:28 -0000 1.2 +++ zend_ts_hash.h 2 Aug 2002 09:48:15 -0000 1.3 @@ -32,6 +32,8 @@ 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.3 +0 -31 ZendEngine2/zend_variables.c Index: zend_variables.c =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_variables.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- zend_variables.c 29 Apr 2002 02:25:28 -0000 1.2 +++ zend_variables.c 2 Aug 2002 09:48:15 -0000 1.3 @@ -138,37 +138,6 @@ } -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.3 +0 -2 ZendEngine2/zend_variables.h Index: zend_variables.h =================================================================== RCS file: /cvsroot/php-i18n/ZendEngine2/zend_variables.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- zend_variables.h 29 Apr 2002 02:25:28 -0000 1.2 +++ zend_variables.h 2 Aug 2002 09:48:15 -0000 1.3 @@ -32,8 +32,6 @@ #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); 1.2 +79 -0 ZendEngine2/zend_config.nw.h 1.2 +333 -0 ZendEngine2/zend_mm.c 1.2 +63 -0 ZendEngine2/zend_mm.h 1.2 +258 -0 ZendEngine2/zend_objects_API.c 1.2 +49 -0 ZendEngine2/zend_objects_API.h 1.2 +29 -0 ZendEngine2/zend_types.h 1.2 +107 -0 ZendEngine2/RFCs/004.txt