"GrafZahl" posted a comment on MediaWiki.r107277.
URL: http://www.mediawiki.org/wiki/Special:Code/MediaWiki/107277#c28543

Commit summary for MediaWiki.r107277:

Simplified profiling by wrapping wfProfileIn/Out calls in a class.
Profile all methods that call wfShellExec(), explicitly or implicitly.

GrafZahl's comment:

I did some more research, and it appears the PHP implementation by The PHP 
Group is the "reference implementation". A cursory examination of their source 
code seems to reveal that the destructors of objects which become unreferenced 
in the course of the usual stack frame leaving events (namely return and 
uncatched throw), are indeed called immediately (and thus in the expected 
order). This is, of course, not true for abnormal termination through exit().

Therefore, I suggest to deem the coding patterns of <code>ScopedLock</code> and 
<code>ScopedProfiling</code> safe for now until new information comes up.

For future reference:
* The opcode handlers for uncatched throw 
[https://svn.php.net/viewvc/php/php-src/trunk/Zend/zend_vm_execute.h?revision=321313&view=markup#l1032]
 and return 
[https://svn.php.net/viewvc/php/php-src/trunk/Zend/zend_vm_execute.h?revision=321313&view=markup#l1142][https://svn.php.net/viewvc/php/php-src/trunk/Zend/zend_vm_execute.h?revision=321313&view=markup#l2218][https://svn.php.net/viewvc/php/php-src/trunk/Zend/zend_vm_execute.h?revision=321313&view=markup#l6547][https://svn.php.net/viewvc/php/php-src/trunk/Zend/zend_vm_execute.h?revision=321313&view=markup#l10794][https://svn.php.net/viewvc/php/php-src/trunk/Zend/zend_vm_execute.h?revision=321313&view=markup#l26659]
 call 
<code>zend_leave_helper_SPEC</code>[https://svn.php.net/viewvc/php/php-src/trunk/Zend/zend_vm_execute.h?revision=321313&view=markup#l1113][https://svn.php.net/viewvc/php/php-src/trunk/Zend/zend_vm_execute.h?revision=321313&view=markup#l1143][https://svn.php.net/viewvc/php/php-src/trunk/Zend/zend_vm_execute.h?revision=321313&view=markup#l2258][https://svn.php.net/viewvc/php/php-src/trunk/Zend/zend_vm_execute.h?revision=321313&view=markup#l6587][https://svn.php.net/viewvc/php/php-src/trunk/Zend/zend_vm_execute.h?revision=321313&view=markup#l10834][https://svn.php.net/viewvc/php/php-src/trunk/Zend/zend_vm_execute.h?revision=321313&view=markup#l26699].
* The leave 
helper[https://svn.php.net/viewvc/php/php-src/trunk/Zend/zend_vm_execute.h?revision=321313&view=markup#l456]
 calls 
<code>zval_ptr_dtor</code>[https://svn.php.net/viewvc/php/php-src/trunk/Zend/zend_vm_execute.h?revision=321313&view=markup#l468],
 which is 
<code>_zval_ptr_dtor</code>[https://svn.php.net/viewvc/php/php-src/trunk/Zend/zend_variables.h?revision=306938&view=markup#l57].
* 
<code>_zval_ptr_dtor</code>[https://svn.php.net/viewvc/php/php-src/trunk/Zend/zend_execute_API.c?view=markup#l427]
 calls 
<code>zval_dtor</code>[https://svn.php.net/viewvc/php/php-src/trunk/Zend/zend_execute_API.c?view=markup#l438],
 which is 
<code>_zval_dtor</code>[https://svn.php.net/viewvc/php/php-src/trunk/Zend/zend_variables.h?revision=306938&view=markup#l56].
* 
<code>_zval_dtor</code>[https://svn.php.net/viewvc/php/php-src/trunk/Zend/zend_variables.h?revision=306938&view=markup#l30]
 calls <code>_zval_dtor_func</code> for 
objects[https://svn.php.net/viewvc/php/php-src/trunk/Zend/zend_variables.h?revision=306938&view=markup#l35].
* 
<code>_zval_dtor_func</code>[https://svn.php.net/viewvc/php/php-src/trunk/Zend/zend_variables.c?revision=311746&view=markup#l30]
 calls 
<code>del_ref</code>[https://svn.php.net/viewvc/php/php-src/trunk/Zend/zend_variables.c?revision=311746&view=markup#l52],
 presumably <code>zend_objects_store_del_ref</code>.
* This 
function[https://svn.php.net/viewvc/php/php-src/trunk/Zend/zend_objects_API.c?revision=306938&view=markup#l165]
 in turn calls 
<code>zend_objects_store_del_ref_by_handle_ex</code>[https://svn.php.net/viewvc/php/php-src/trunk/Zend/zend_objects_API.c?revision=306938&view=markup#l172].
* 
<code>zend_objects_store_del_ref_by_handle_ex</code>[https://svn.php.net/viewvc/php/php-src/trunk/Zend/zend_objects_API.c?revision=306938&view=markup#l181]
 invokes the object's 
destructor[https://svn.php.net/viewvc/php/php-src/trunk/Zend/zend_objects_API.c?revision=306938&view=markup#l206]
 if there are no other references.

_______________________________________________
MediaWiki-CodeReview mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-codereview

Reply via email to