Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:87760 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 58873 invoked from network); 17 Aug 2015 08:33:14 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Aug 2015 08:33:14 -0000 Authentication-Results: pb1.pair.com smtp.mail=dmitry@zend.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=dmitry@zend.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 209.85.223.179 as permitted sender) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 209.85.223.179 mail-io0-f179.google.com Received: from [209.85.223.179] ([209.85.223.179:36677] helo=mail-io0-f179.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DE/A3-63805-94C91D55 for ; Mon, 17 Aug 2015 04:33:14 -0400 Received: by iodv127 with SMTP id v127so127308891iod.3 for ; Mon, 17 Aug 2015 01:33:11 -0700 (PDT) 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:date :message-id:subject:from:to:cc:content-type; bh=cEvXDJAlo6OdL6UVJKKZ7zD3j1wqt4t+w5BC+fio+mI=; b=UuSpuS4+Hn4GES6iVSP+dQgCsfxQ0besJFYFomdhl8f80MX/lZuflrV2yCsOK5ZH+6 Q1WRTj/n4/MebOwFPkOf4RB1bgUu20lAGdKTqnqLq7eBZPR9FxKWiVhRgHQRhGF+X3IH TiFIHLWLvxBctYTg31vvUSwc8baXI2DAXyeNVbX09dBYB4vqZ+xTpV8/P1bTNhoZb3cq JtVALSNXHPIi68MPRw2+8eOMp6UvAA6Rpu92Jcmf6GZvTCzvst0Gl5TbGGjIaVPFKAHn qC8D2R+WGwTXodT5ux4xvcKE+GDOxGQ/llmnsH2mfpD8M6orxcyonSMjQgqMCF0f7PuC 2qlw== X-Gm-Message-State: ALoCoQllqCh4INewYTCNDIqcsyQJXeVhfke10ZTiwHLdmpH5RevGRI6ODPtDkv/lf7twPS7eZ7GuVtsK7yVa0/JLWYJH2CWgm4PO0pr0J5RQCVpXgtGlaxaWd3Rlx8wlcLdTV8X451km7FKC8aLFKUPahrwKhtDrA7NjpMxSjGqROSCLbjztmeo= MIME-Version: 1.0 X-Received: by 10.107.148.8 with SMTP id w8mr308533iod.116.1439800390757; Mon, 17 Aug 2015 01:33:10 -0700 (PDT) Received: by 10.50.35.101 with HTTP; Mon, 17 Aug 2015 01:33:10 -0700 (PDT) In-Reply-To: <7736C746A64A480AB3F285609E5DADB5@pc1> References: <8BE12FDCDC5C457282790368866BD61E@pc1> <04E6618E3189404FB15D042E588A90FC@pc1> <7736C746A64A480AB3F285609E5DADB5@pc1> Date: Mon, 17 Aug 2015 11:33:10 +0300 Message-ID: To: Matt Wilmas Cc: PHP Internals Content-Type: multipart/alternative; boundary=001a113fe51ed6c3bc051d7da684 Subject: Re: [PHP-DEV] Parameter parsing for zval type? From: dmitry@zend.com (Dmitry Stogov) --001a113fe51ed6c3bc051d7da684 Content-Type: text/plain; charset=UTF-8 On Thu, Aug 13, 2015 at 1:12 AM, Matt Wilmas wrote: > H Dmitry, > > ----- Original Message ----- > From: "Dmitry Stogov" > Sent: Tuesday, August 11, 2015 > > On Tue, Aug 11, 2015 at 11:10 PM, Matt Wilmas >> wrote: >> >> [...] >>> >>> Look at e.g. is_numeric() or strpos() (needle). Plain zval param >>> parsing, >>> so NO ZVAL_DEREF() occurs (FAST_ZPP or traditional). These 2 example >>> functions don't handle IS_REFERENCE type, so they would break. >>> >>> Or is there no way for them (or any function?) to get a IS_REFERENCE? >>> Then *why* is there ZVAL_DEREF() in param parsing functions? We could >>> remove it! >>> >>> >> We probably may remove ZVAL_DEREF() for functions arguments passed by >> value, but we don't know if argument was passed by value or by reference >> in >> ZPP functions. Actually, in FAST_ZPP for scalars we may probably assume >> passing by value and remove ZVAL_DEREF(), but I'm not sure if this is 100% >> safe. >> > > Yes, speaking of scalars, I had already noticed that it doesn't make sense > to have a "separate" argument for the FAST_ZPP scalar _EX macros, as > there's nothing to separate (same with traditional '/') on simple values. > I was changing those macros, and don't think they're used anyway. > > Also, I think those simple/scalar types wouldn't be used with by-reference > arguments (?), as there would be nothing to update... > > Like I said in reply to Nikita, it seems like separating is needed for > by-reference args, so only need DEREF if *also* separating? It looks like > that was the idea with Z_PARAM_ZVAL_EX(). And for other types, separating > only applies to arrays or strings, I believe. > > As far as not 100% safe, you mean IS_REFERENCE type causing an error about > wrong type? Shouldn't that only happen if developer indicated by-ref arg, > but then used wrong type in parsing? > At least this case. We may change ZVAL_DEREF(...) into ZEND_ASSERT(!Z_ISREF_P(...)), to prevent silence crashes. Thanks. Dmitry. > > On the other hand, it seems like always using ZVAL_DEREF() won't hurt > anything? e.g. part of my confusion was that I thought IS_REFERENCE was > wanting to be *kept* in some cases (after parsing), but it seems to not be > the case. :-) > > Speaking of confusion, it also seems the DEREF stuff is unnecessary in > type.c:php_is_type(), for example. > > Thanks. Dmitry. >> > > Thanks, > Matt > --001a113fe51ed6c3bc051d7da684--