Hi!

>     as you can see, we use "r" to receive a IS_RESOURCE type, that
> means, check the type in ZEND_FETCH_RESOURCE is overhead..

Except that some functions could receive "z" and decide if it's the
resource or not afterwards... But I guess you could rely on the code
that decides it to check. Some code would crash (or produce some very
bad memory corruption) if somebody would forget to add this check when
porting such extension. Is saving one branch worth it?

>    ZEND_API void *zend_fetch_resource(zval *passed_id, int default_id,
> const char *resource_type_name, int *found_resource_type, int
> num_resource_types, ...)
> 
>    we use va_args to passing resource type, that means, the rescue
> type arguments can not be passed by register but by stack.. which is a
> little low effiicient .

Is it that bad? Functions are passing arguments via the stack all
around. The interface with fetch(), fetch2(), fetch3(), fetch4(), etc.
looks a little clunky.

As for storing the value directly instead of having the list - it would
work for all cases except for two important ones:

1. Persistent resources - they need to be stored somewhere, and not in
zvals that are supposed to be dead at the end of the request.
2. Cleanup at the end for non-persistent ones - zvals may be lost and
not destructed in many exceptional situations. Not destructing the
resource may mean having a stale lock forever or consuming connections
or handles, etc. So there should be some mechanism allowing for
destroying all resources that are transient.

-- 
Stas Malyshev
smalys...@gmail.com

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

Reply via email to