Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:81579 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 14173 invoked from network); 2 Feb 2015 10:49:01 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Feb 2015 10:49:01 -0000 Authentication-Results: pb1.pair.com header.from=laruence@php.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=xinchen.h@zend.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 209.85.215.45 as permitted sender) X-PHP-List-Original-Sender: xinchen.h@zend.com X-Host-Fingerprint: 209.85.215.45 mail-la0-f45.google.com Received: from [209.85.215.45] ([209.85.215.45:37671] helo=mail-la0-f45.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 49/00-13421-9165FC45 for ; Mon, 02 Feb 2015 05:48:57 -0500 Received: by mail-la0-f45.google.com with SMTP id gd6so39231909lab.4 for ; Mon, 02 Feb 2015 02:48:54 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-type; bh=WJBql+h/uShe8lxf4xMDKzOZy59VGLo2C1ppq8xv6MY=; b=A2K/9vf5Sostan9vGTXJnK32ZPSUEGnk/H5iyLV33JeiXLvBwH48jK2qbr9igE76mG 2kdWvyba5W7lky665sOZFw53BdiyqwP3iIClARQNQpy8Oz+qc3tOYuqOAyTtPR/t3naW TV3vfOCbDd68CQJQeywjLhWIXXywX7lbiQc+HII526FbDEykG/im7kIBhVDhQJ/3mX/5 04cNz+Rgvvi2N8CLEquB1n5qe3S5Yd9kgQ1Rr5566YkKsjag3dJQghuaXNjJ1yLIkfwC kmMSE+uweyrlAfl/wlujq548CwYPfmVjGSmlc4xXLVjiC91jJxNLqhrZVYj0dVOWKGVA rKxA== X-Gm-Message-State: ALoCoQlNTTZRr7tYuB73z9uDOrF2XKVI8bv87OXgFsxj8YLEIjlO8wfB7vLaU4v17VFU2ORxRed/gIwtzHCv0WZsoqSdQ9cluH092/cIAQ9aqSjYq6l1nD4yFVnFm6WFWC+gaNcK7ntgeYPAEwvdQsMf/fWTyaavZw== X-Received: by 10.112.136.233 with SMTP id qd9mr1449361lbb.61.1422874134174; Mon, 02 Feb 2015 02:48:54 -0800 (PST) Received: from mail-la0-f54.google.com (mail-la0-f54.google.com. [209.85.215.54]) by mx.google.com with ESMTPSA id q9sm4312250lbo.29.2015.02.02.02.48.52 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 02 Feb 2015 02:48:53 -0800 (PST) Received: by mail-la0-f54.google.com with SMTP id hv19so39169750lab.13 for ; Mon, 02 Feb 2015 02:48:52 -0800 (PST) X-Received: by 10.152.219.161 with SMTP id pp1mr19058518lac.30.1422874132050; Mon, 02 Feb 2015 02:48:52 -0800 (PST) MIME-Version: 1.0 Received: by 10.114.28.193 with HTTP; Mon, 2 Feb 2015 02:48:31 -0800 (PST) In-Reply-To: References: Date: Mon, 2 Feb 2015 18:48:31 +0800 Message-ID: To: PHP Internals , Dmitry Stogov Content-Type: text/plain; charset=UTF-8 Subject: Re: [DICUSS]Cleanup resource handling APIs From: laruence@php.net (Xinchen Hui) Hey: if no objections, I will commit it.. (no bc breaks, no handle removing , only APIs change) dmitry suggest we change zend_fetch_resource to zend_verify_resource, I think it make sense.. will do it. thanks On Mon, Feb 2, 2015 at 1:34 PM, Xinchen Hui wrote: > Hey: > > we used to use lval of zval as a handle to access resource type.. > > but now, we introduced a new type IS_RESOURCE, which make the > handle(id) sort of redundant . > > further more, the common usage when handling resource is like: > > if (zend_parse_parameters(ZEND_NUM_ARGS(), "rl", &result, > &offset) == FAILURE) { > return; > } > ZEND_FETCH_RESOURCE(mysql_result, MYSQL_RES *, result, -1, "MySQL > result", le_result); > > as you can see, we use "r" to receive a IS_RESOURCE type, that > means, check the type in ZEND_FETCH_RESOURCE is overhead.. > > and: > > 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 . > > so, I'd like propose a zend_resource handling API cleanup.. > > 1. DROP ZEND_REGISTER_RESOURCE/FETCH_RESOURCE. > > 2. add : > > ZEND_API void *zend_fetch_resource(zend_resource *res, const > char *resource_type_name, int resource_type); > ZEND_API void *zend_fetch_resource2(zend_resource *res, const char > *resource_type_name, int *found_type, int resource_type, int > resource_type2); > ZEND_API void *zend_fetch_resource_ex(zval *res, const char > *resource_type_name, int resource_type); > ZEND_API void *zend_fetch_resource2_ex(zval *res, const char > *resource_type_name, int *found_type, int resource_type, int > resource_type2); > > a underworking patch could be found at: > https://github.com/php/php-src/pull/1042 > > any ideas & objections? > > thanks > > -- > Xinchen Hui > @Laruence > http://www.laruence.com/ -- Xinchen Hui @Laruence http://www.laruence.com/