Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:67646 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 63043 invoked from network); 7 Jun 2013 17:14:39 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Jun 2013 17:14:39 -0000 Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.176 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.214.176 mail-ob0-f176.google.com Received: from [209.85.214.176] ([209.85.214.176:46152] helo=mail-ob0-f176.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id FF/F4-33815-DF412B15 for ; Fri, 07 Jun 2013 13:14:38 -0400 Received: by mail-ob0-f176.google.com with SMTP id v19so6918623obq.35 for ; Fri, 07 Jun 2013 10:14:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=a9g08+qx0Npua99FKP6YQvNN4javMM1XGQsGL9nPZ/w=; b=CWQKLugBEoNXpyr9CKENyTsglh6c0l4dCifF2PsvzdjXRIi9J2QM8OUWDy5lWUbo7B iv7ks0ntaeqt8SCNafAznrBfHkfqb5Z0l3fypy0bLNZsmapmAa8h4vRxZfgWHienoRTb dQjzolvv/rRIPoaXNceRFNg/nNEIiHMlO/ig1vm785SRlygNtobO9JFFaBUquMPjWOkg fOh17jMzMjt5jMr/OxZ3c04r6ntAxwkmC6l9Q6zHb4FMY25IJ/B/P7bNwfBCu3nAFG6i FNDTpSPY4XRLUcFp5z9hnih0mrl7AYWGF+QwFZaZehkikWXd5Vmn6Ja8j+SEcJ2ZZzvl 6L9w== MIME-Version: 1.0 X-Received: by 10.182.45.197 with SMTP id p5mr21549078obm.92.1370625275125; Fri, 07 Jun 2013 10:14:35 -0700 (PDT) Received: by 10.182.97.228 with HTTP; Fri, 7 Jun 2013 10:14:35 -0700 (PDT) In-Reply-To: References: Date: Fri, 7 Jun 2013 19:14:35 +0200 Message-ID: To: Dmitry Stogov Cc: PHP internals Content-Type: multipart/alternative; boundary=047d7b67637aa4e79b04de939096 Subject: Re: [PHP-DEV] [RFC] Internal operator overloading and GMP improvements From: nikita.ppv@gmail.com (Nikita Popov) --047d7b67637aa4e79b04de939096 Content-Type: text/plain; charset=ISO-8859-1 On Wed, May 15, 2013 at 7:12 AM, Dmitry Stogov wrote: > According to fast-path execution, I would really like to not introduce the > additional checks. > Especially for concat_function I would change it in the following way: > > if (Z_TYPE_P(op1) != IS_STRING) { > if (Z_TYPE_P(op1) == IS_OBJECT && Z_OBJ_HANDLER_P(op1, do_operation)) { > return Z_OBJ_HANDLER_P(op1, do_operation)(ZEND_CONCAT, result, op1, op2 TSRMLS_CC); > } > zend_make_printable_zval(op1, &op1_copy, &use_copy1); > } > if (Z_TYPE_P(op2) != IS_STRING) { > if (Z_TYPE_P(op2) == IS_OBJECT && Z_OBJ_HANDLER_P(op2, do_operation)) { > return Z_OBJ_HANDLER_P(op2, do_operation)(ZEND_CONCAT, result, op1, op2 TSRMLS_CC); > } zend_make_printable_zval(op2, &op2_copy, &use_copy2); > } > > > And in similar way for mod, shift, etc > > if (UNEXPECTED(Z_TYPE_P(op1) != IS_LONG)) { > > if (Z_TYPE_P(op1) == IS_OBJECT && Z_OBJ_HANDLER_P(op1, do_operation)) { > return Z_OBJ_HANDLER_P(op1, do_operation)(ZEND_MOD, result, op1, op2 TSRMLS_CC); > } > zendi_convert_to_long(op1, op1_copy, result); > } > op1_lval = Z_LVAL_P(op1); > if (UNEXPECTED(Z_TYPE_P(op2) != IS_LONG)) { > > if (Z_TYPE_P(op2) == IS_OBJECT && Z_OBJ_HANDLER_P(op2, do_operation)) { > return Z_OBJ_HANDLER_P(op2, do_operation)(ZEND_MOD, result, op1, op2 TSRMLS_CC); > } zendi_convert_to_long(op2, op2_copy, result); > } > I now added checks to make sure that the overloading code is never in the fast path. As an example see mod_function: https://github.com/php/php-src/pull/342/files#L2R1034 I had to use if (Z_TYPE_P(op1) != IS_LONG || Z_TYPE_P(op2) != IS_LONG) checks instead of individual checks as in your examples, otherwise the code would behave differently (with no fallback to the normal code if FAILURE is returned and also if the second operand is an object then the first one would already be cast to long). If there is no more feedback on the RFC, then I'll start voting in a day or two. Nikita --047d7b67637aa4e79b04de939096--