I never posted a patch. Becuase the changes that im running are incomplete. I
change the compiler and executer. Other things will need to change to reflect
this type of change. Api calls like call_user_function() and userland functions
like get_defined_methods() in addtion i would think a couple new api functions
would come outta this. Like zend_method_exists() zend_get_method() i don't know
where else would need to change. but i will include what i have been testing
with in this email. I made these changes against 4.1.2 i can't get the cvs
version my company seems to block out some ports. So i will send you the patch
against 4.1.2.

 /* brad */

--- Yasuo Ohgaki <[EMAIL PROTECTED]> wrote:
> Hi Brad,
> 
> I would like to try your patch.
> Where did you post? I searched ze2 list messages, I couldn't find one.
> 
> --
> Yasuo Ohgaki
> 
> 
> Brad Lafountain wrote:
> > Ok...
> > These benchmarks are (win32)
> > php-4.1.2 Release_TS_inline (brad) vs php-4.1.2 binary from php.net (php)
> > 
> > i have attached the test scripts that i used. 
> > (I ran each about 10 times and averaged the times, I used cygwin's time
> > command)
> > 
> > case one (worse case for php):
> > brad - .11 sec
> > php - .45 sec
> > 
> > This is the worse case because php copies all of the functions from the
> > previous class to the extended class so this script has 100 classes with 10
> > different functions in each so the 100'th class will have 1000 functions.
> With
> > this test i still called a function defined in the base class. Not only is
> this
> > way faster the new way it uses less memory.
> > 
> > case two (worse case for brad):
> > brad - .060 sec
> > php - .080 sec
> > This test has 100 declared classes all inheriting each other, only defining
> a
> > constructor in each class. Then makes a instance of the 100'th class and
> calls
> > a method in the base class 100 times.
> > 
> > brad - .075 sec
> > php - .090 sec
> > The same thing as above but it calls the method 1000 times.
> > 
> > brad - .23 sec
> > php - .14 sec
> > again with 10000 method calls
> > 
> > As you can tell as the number of method calls go up the time of execution
> goes
> > up in the 'brad' version. IMHO doing 10000 calls to a method declared in a
> base
> > class of a inheritance chain of 100 classes and only loosing .09 seconds
> isn't
> > that bad at all.  Seing this type of path will solve a few problems.
> > 
> > --- Yasuo Ohgaki <[EMAIL PROTECTED]> wrote:
> > 
> >>Brad,
> >>How about post detailed benchmarks for your patch?
> >>
> >>IMHO. This bug is fatal. Especially those who are
> >>experienced with other OO languages, such as C++/Java.
> >>
> >>--
> >>Yasuo Ohgaki
> >>
> >>Brad Lafountain wrote:
> >>
> >>>This bug is eaisly fixable. This is also something that i have been trying
> >>
> >>to
> >>
> >>>push on a couple of threads now. You would need to do 3 things. 
> >>>
> >>>1) change the compiler so that inherited objects don't copy the opcodes 
> >>> of the functions. it will just store the parent's ce.
> >>>
> >>>2) change the executor so it will execute functions recursivly thru the
> >>> parents ce's
> >>>
> >>>( i was talking about this change on engine2 list andi was arguing that it
> >>>would be slower on execution of a function. I made the changes and it was
> >>>faster. See the 'Mulitple Inhertiance' thread on engine2 list. This would
> >>
> >>also
> >>
> >>>allow you to inherit overloaded objects defined in c.. ie Java)
> >>>
> >>>3) again change the compiler to test only the current ce for
> re-definitions
> >>
> >>of
> >>
> >>>the defined function. (derick already did this)
> >>>
> >>>So as far as im conserned making this change will solve many problems...
> >>
> >>But im
> >>
> >>>really still confused why andi doesn't want this change. I will send my
> >>
> >>diff if
> >>
> >>>you want.
> >>>
> >>> - Brad
> >>>
> >>>--- [EMAIL PROTECTED] wrote:
> >>>
> >>>
> >>>>ID:               16265
> >>>>Updated by:       [EMAIL PROTECTED]
> >>>>Reported By:      [EMAIL PROTECTED]
> >>>>-Status:           Open
> >>>>+Status:           Suspended
> >>>>Bug Type:         Scripting Engine problem
> >>>>Operating System: Linux
> >>>>PHP Version:      4.1.2
> >>>>New Comment:
> >>>>
> >>>>I'm suspending this for now, this issue is not easily solved
> >>>>unfortunately. But we keep this on the todo list for future releases.
> >>>>
> >>>>Derick
> >>>>
> >>>>
> >>>>Previous Comments:
> >>>>------------------------------------------------------------------------
> >>>>
> >>>>[2002-04-01 21:37:21] [EMAIL PROTECTED]
> >>>>
> >>>>Need to open again.
> >>>>This bug may be suspended.
> >>>>
> >>>>------------------------------------------------------------------------
> >>>>
> >>>>[2002-03-25 15:32:48] [EMAIL PROTECTED]
> >>>>
> >>>>Fixed in CVS, will also be in PHP 4.2.0
> >>>>
> >>>>Derick
> >>>>
> >>>>------------------------------------------------------------------------
> >>>>
> >>>>[2002-03-25 13:12:42] [EMAIL PROTECTED]
> >>>>
> >>>>PHP does not report multiply-defined errors for class member functions.
> >>>>For example, the following script below, when executed, only outputs
> >>>>"two", with no errors.
> >>>>
> >>>>Instead, PHP should be giving error messages since the function bar has
> >>>>been defined multiple times.
> >>>>
> >>>><?
> >>>>class foo
> >>>>{
> >>>>       function bar() {echo "one\n";}
> >>>>       function bar() {echo "two\n";}
> >>>>}
> >>>>
> >>>>$f = new foo();
> >>>>$f->bar();
> >>>>
> >>>>------------------------------------------------------------------------
> >>>>
> >>>>
> >>>>-- 
> >>>>Edit this bug report at http://bugs.php.net/?id=16265&edit=1
> >>>>
> >>>
> >>>
> >>>
> >>>__________________________________________________
> >>>Do You Yahoo!?
> >>>Yahoo! Tax Center - online filing with TurboTax
> >>>http://http://taxes.yahoo.com/
> >>
> >>
> >>
> >>-- 
> >>PHP Development Mailing List <http://www.php.net/>
> >>To unsubscribe, visit: http://www.php.net/unsub.php
> >>
> > 
> > 
> > 
> > __________________________________________________
> > Do You Yahoo!?
> > Yahoo! Tax Center - online filing with TurboTax
> > http://http://taxes.yahoo.com/
> 
> 
> 


__________________________________________________
Do You Yahoo!?
Yahoo! Tax Center - online filing with TurboTax
http://taxes.yahoo.com/
--- zend_compile.c      Mon Dec 17 00:22:24 2001
+++ zend_compile_brad.c Thu Mar 28 09:41:30 2002
@@ -1565,17 +1565,18 @@
                CG(active_ce_parent_class_name).value.str.len = 
parent_class_name->u.constant.value.str.len;
 
                if (zend_hash_find(CG(class_table), 
parent_class_name->u.constant.value.str.val, 
parent_class_name->u.constant.value.str.len+1, (void **) &parent_class)==SUCCESS) {
-                       /* copy functions */
+                       /* copy functions
                        zend_hash_copy(&CG(class_entry).function_table, 
&parent_class->function_table, (copy_ctor_func_t) function_add_ref, 
&tmp_zend_function, sizeof(zend_function));
+                       */
 
                        /* copy default properties */
                        zend_hash_copy(&CG(class_entry).default_properties, 
&parent_class->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, 
sizeof(zval *));
 
-                       /* copy overloaded handlers */
+                       /* copy overloaded handlers 
                        CG(class_entry).handle_function_call = 
parent_class->handle_function_call;
                        CG(class_entry).handle_property_get  = 
parent_class->handle_property_get;
                        CG(class_entry).handle_property_set  = 
parent_class->handle_property_set;
-
+                       */
                        CG(class_entry).parent = parent_class;
 
                        zval_dtor(&parent_class_name->u.constant);
--- zend_execute.c      Mon Dec 17 00:22:24 2001
+++ zend_execute_brad.c Tue Apr  2 11:19:06 2002
@@ -1552,9 +1552,28 @@
                                                object.ptr = NULL;
                                                active_function_table = 
EG(function_table);
                                        }
-                                       if (zend_hash_find(active_function_table, 
function_name->value.str.val, function_name->value.str.len+1, (void **) 
&function)==FAILURE) {
-                                               zend_error(E_ERROR, "Call to undefined 
function:  %s()", function_name->value.str.val);
+
+                                       if(zend_hash_find(active_function_table, 
+function_name->value.str.val, function_name->value.str.len+1, (void **) &function) == 
+FAILURE) 
+                                       {
+                                               if(object.ptr != NULL && 
+Z_OBJCE_P(object.ptr) != NULL)
+                                               {
+                                                       zend_class_entry *tmp_ce = 
+Z_OBJCE_P(object.ptr);
+                                                       function = NULL;
+                                                       while(tmp_ce->parent != NULL)
+                                                       {
+                                                               active_function_table 
+=  &(tmp_ce->parent->function_table);
+                                                               if 
+(zend_hash_find(active_function_table, Z_STRVAL_P(function_name), 
+Z_STRLEN_P(function_name) + 1, (void **) &function)!=FAILURE) {
+                                                                       break;
+                                                               }
+                                                               tmp_ce = 
+tmp_ce->parent;
+                                                       }
+                                                       if(function == NULL)
+                                                               zend_error(E_ERROR, 
+"Call to undefined function: %s()", Z_STRVAL_P(function_name));
+                                               }
+                                               else
+                                                       zend_error(E_ERROR, "Call to 
+undefined function:  %s()", Z_STRVAL_P(function_name));
                                        }
+
                                        zval_dtor(&tmp);
                                        fbc = function;
 overloaded_function_call_cont:

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to