Re: [PHP-DEV] ZE2 + F3P

2002-11-22 Thread Marcus Börger
At 03:59 22.11.2002, Marcus Börger wrote:

In the following link you will find final, public, protected and private 
(f + 3p) for ZE2:
http://marcus-boerger.de/php/ext/ze2/

What it does:

(...)

- 'speed guys' continued: during compile time (zend_compile.c)


Forgot to complete this section :-)

In function Zend/zend_compile.c/zend_do_inheritance() where functions are 
inherited i added
additional checks. The old code simple merged the hash tables. I added:
1) for each inherited method: 1*call + 1*comparision + 1*ored_assignment + 
1 jump
2) for each overloaded method: 1*call + 3 check blocks
Without errors these blocks do:
2 assignments + 3*jump + 3*test + 3*logical_op
+ optional: 3*test + 1*logical_op + 3*jumps
+ optional: 1* logical_op + 1*ored_assignment

For an *optimizing* compiler and an Intel CPU > PII each number above 
result in one single instruction.
But you will have to add the stack frames for the calls and assignments 
require more operations than one
operation.

Above countings are without guarantee because i simply counted what i would 
expect from expirience

Optional means when using 3p in certain situations. In other words when not 
using 3p those are
not executed so i guess the overhead is acceptable.




(...)
- i store abstract in fn_flags to disallow overloading a method with an 
abstract method. There is no
  further change in abstract.

By storing abstract in fn_flags we can have "is_abstract($obj)". The 
current implementation does not
allow this check.



(...)

What's left:

- create a global scope with a name that can be referred by the error 
message. Not doing this will
  either result in errors when working with "dynaming function call by 
name" (i guess so) or we have
  to check or skip class/namespace names in error messages.


The easiest way would be to avoid problems in error messages would be to 
use a define
#define SCOPE_NAME(scope) (scope ? scope->name : "")



(...)
- more than i know yet - i guess :-)


is_abstract($obj_or_class_or_method)
is_final($obj_or_class_or_method)
is_private($method)
is_protected($method)
is_public($method)

But those are easy to implement :-)

marcus


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




[PHP-DEV] ZE2 + F3P

2002-11-21 Thread Marcus Börger
In the following link you will find final, public, protected and private (f 
+ 3p) for ZE2:
http://marcus-boerger.de/php/ext/ze2/

What it does:

- introduced final, public, protected, private member functions (methods)
 -> Since we have aggregation already (and a patch from me some days 
before shows that it can
 work even with ZE2) and 3p member variables i thought why not having 
3p member functions.
 -> This does not make "PHP a strictly typed language". But it makes PHP 
more OO powerfull
 and allows real "Class-Design".

- i also introduced a forth visibility "private+hidden". That means when 
you inherit a private method
  it is always marked as hidden. This way you cannot overload a private 
method in a second derived
  class. You could check without inheriting the private method as hidden 
but that would take longer.

- and i added a fifth visibility "". This is currently mapped to puiblic 
but the informaion is kept.
  I could have forced this to public but found it better to keep the 
visibility "" to make it possible
  to display the correct decorated method string.

- since abstract made it already into ZE2 i wanted to have final 
(overloading not allowed) what could
  be thought of as the opposite of abstract (must be overloaded).

- Every method now knows its scope. This allows better error messages since 
we can allways
  show class and method name. Without this part of the patch we cannot 
allways do this.

- When at compile time a class inherits methods from another class there 
are several checks
  to veify that you do not change the visibility, do not mix static and 
non static and do not overload
  private methods.

- for the 'speed guys': during runtime (zend_execute.c) public static 
methods only have one
  additional check. public methods have one additional call and one 
additional check. protected
  and private checks take longer since they often require rekursive scope 
lookups.

- 'speed guys' continued: during compile time (zend_compile.c)

- before this patch we had the structure member is_static in 
zend_op_array/zend_function. Now
  we have fn_flags which stores information about 
abstract/final/static/public/protected/private. On
  modern CPUs it makes no speed difference if we have a packed bitset or 
single boolean values
  but we require less memory.

- i store abstract in fn_flags to disallow overloading a method with an 
abstract method. There is no
  further change in abstract.

- last but not least i made 27 tests for everything i had in mind during 
patching the ZendEngine.

What's left:

- create a global scope with a name that can be referred by the error 
message. Not doing this will
  either result in errors when working with "dynaming function call by 
name" (i guess so) or we have
  to check or skip class/namespace names in error messages.

- i haven't experimented with aggregation yet since it does not work 
without my patch mentioned
  already.

- the other OO features "interfaces and such": but i remember all those 
were disagreed on this list.

- more tests

- more than i know yet - i guess :-)

regards
marcus




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