Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:81765 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 26865 invoked from network); 4 Feb 2015 06:02:17 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Feb 2015 06:02:17 -0000 Authentication-Results: pb1.pair.com header.from=smalyshev@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=smalyshev@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.42 as permitted sender) X-PHP-List-Original-Sender: smalyshev@gmail.com X-Host-Fingerprint: 209.85.220.42 mail-pa0-f42.google.com Received: from [209.85.220.42] ([209.85.220.42:50252] helo=mail-pa0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 85/F3-20608-8E5B1D45 for ; Wed, 04 Feb 2015 01:02:16 -0500 Received: by mail-pa0-f42.google.com with SMTP id bj1so106299540pad.1 for ; Tue, 03 Feb 2015 22:02:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=Md5jdlGYnI5R3xb21JNviGqV/4USoOFgV6aK5q3mkD4=; b=XFYp1u+YuvwmytHmTT/Wrnzs3LcN+HrRu/D6gKU2lM6EWHTPIzfFBUODnPLzT+6BKo Xd5Xh6tWs0hxmSKXXCrdaU94JHhzwK4mf9gtvKwdg/yty7EVPkz/nuPdseIJnJHXZGEo g6I+81Z+LNK4UncTlsUB2jB1/J8N9tzZhE7I3r/l6xc0Zw2jFmXS4ZqvIL2TpMTSAVaz CckBeCRvlzOs+Dp4RnL4AyjuxigaqFyhIYmfgRdH5WDiimE9M+inwl/pxuRnyPsPYbuz lJ85c2/1cAOKMyXlm2ERpjp6QvNzhkbo/eA8caUWhqrgqr+l9lO0iKADnvfuUUPbo2C1 ecxQ== X-Received: by 10.70.47.104 with SMTP id c8mr21777584pdn.42.1423029733891; Tue, 03 Feb 2015 22:02:13 -0800 (PST) Received: from [192.168.2.145] (108-66-6-48.lightspeed.sntcca.sbcglobal.net. [108.66.6.48]) by mx.google.com with ESMTPSA id i3sm733731pdf.39.2015.02.03.22.02.12 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Feb 2015 22:02:13 -0800 (PST) Message-ID: <54D1B5DB.8090602@gmail.com> Date: Tue, 03 Feb 2015 22:02:03 -0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Xinchen Hui , PHP Internals , Dmitry Stogov References: In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [DICUSS]Cleanup resource handling APIs From: smalyshev@gmail.com (Stanislav Malyshev) 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 smalyshev@gmail.com