Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:92894 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 80513 invoked from network); 28 Apr 2016 18:55:53 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Apr 2016 18:55:53 -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.161.182 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.161.182 mail-yw0-f182.google.com Received: from [209.85.161.182] ([209.85.161.182:33914] helo=mail-yw0-f182.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 26/0B-28296-8BC52275 for ; Thu, 28 Apr 2016 14:55:52 -0400 Received: by mail-yw0-f182.google.com with SMTP id j74so121188840ywg.1 for ; Thu, 28 Apr 2016 11:55:52 -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; bh=XyUmz9h2x/EMPF4ypeiGWpd27Lds1/yJQDCA/VV1XSw=; b=VKUGWwdIFpCZu+Dfoso175cH/Gz8YyGi5HaixD0mrU4dKKk05JoisGwHcTuCf/yoSd OFmZkf2kYj/2GpNAVcTO/I9Ikn+6FLQG/0B2RgzvCe/HpQgriJKSPpzWBKoGEmSCcjbl g6y4yh6Piljxl0ViEXVcsxVOeR1aWTd0XvDJ2Cy+daAk8xaJ3pwAcIzn8rLWV0uYq6CK Cu9YYjqDT+M0Q129soTkGvoyyIuI5JuFdqvjP2AF22vjtehZEHdXKAIskiLFeYrWvN1y suo+K+fNKRu4Xnk6HFFuXOAGl9vtK3CSjXGkctqNvV8FiG79+doJHUnslpZft9kI8iPZ uiyQ== 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; bh=XyUmz9h2x/EMPF4ypeiGWpd27Lds1/yJQDCA/VV1XSw=; b=T0kpxkHgwwyB7+e7kyh0g/zlQ6DDvG5Uhne6DnsPbAERgNDjnXy0gs/wMUw3YRzO6L KESsSUX33jUJQMwrSxiY+5LC9woeehqliLOTNdnsOur9EglM4EK8w2dSa5MZdQIcV5Jk Ke4TMTUTrgNDeCF3u++P1Z0JfDASrbBUUUE7ckvVpeJm3lPKxNRvkOrFYn8LbzGrx3xb kriTnoTyqcG3wX9OFPczUMI7iMUM/eBIIt6O04qRLMUb8wuVUBJ4Q7XMUE2d7bwAAs+Y 8iNz+Pgu6xIeiaN/umdAYvgWjd+BgCRrZwMpfI2hpDG0b0hMqKI3oyGnlzehnEmN+PKs i4sg== X-Gm-Message-State: AOPr4FW9Jze6Es33Z8Ge0x8XC+KBzTgv6FDjNDlfHlGEJt2J835nyDOxwA2kLpuNTVLwy5C5yXurwOr+fNTGpQ== MIME-Version: 1.0 X-Received: by 10.129.40.147 with SMTP id o141mr8587385ywo.221.1461869749729; Thu, 28 Apr 2016 11:55:49 -0700 (PDT) Received: by 10.13.239.3 with HTTP; Thu, 28 Apr 2016 11:55:49 -0700 (PDT) In-Reply-To: References: Date: Thu, 28 Apr 2016 20:55:49 +0200 Message-ID: To: Dominic Grostate Cc: Sara Golemon , PHP internals Content-Type: multipart/alternative; boundary=001a113f43dc240513053190135f Subject: Re: [PHP-DEV] Inline functions From: nikita.ppv@gmail.com (Nikita Popov) --001a113f43dc240513053190135f Content-Type: text/plain; charset=UTF-8 On Thu, Apr 28, 2016 at 8:39 PM, Dominic Grostate < codekestrel@googlemail.com> wrote: > That sounds wicked. I look forward to benchmarking it and seeing how its > done. > On 28 Apr 2016 6:39 p.m., "Sara Golemon" wrote: > > > On Thu, Apr 28, 2016 at 1:21 AM, Dominic Grostate > > wrote: > > > As I understand it, the process by which the call stack is updated and > > > scope changed, is quite expensive. And from tests I can see that > > function > > > calls do actually add a not insignificant overhead to intensive > > repetitive > > > tasks. > > > > > > So how difficult would it be to get the engine to determine if an > inline > > is > > > feasible, then skip the fcall init, and dump the a functions opcode > emits > > > directly into the current scope? > > > > > I'm actually working on a proof-of-concept of that already. I've > > already got basic proxy methods getting inlined, and am working up > > through expression methods and trying to resolve scoping with $this > > and non-publics. > > > > I'll publish a branch on github when I have something interesting to > share. > > > > -Sara > > > I also have a proof-of-concept inlining implementation lying around: https://github.com/nikic/php-src/blob/opt/ext/opcache/Optimizer/inlining.c However it only inlines free functions and static methods, not instance methods, because the latter have the $this being null issue. Another complication when inlining methods is that we may only know the called method if it is either private or final, i.e. there is no possibility of it being overwritten in a child class. One tricky issue with inlining is that we need to unset all the variables of the inlined function after the call, otherwise we may cause issues with references and destruction order. If these unsets are not eliminated through DCE they may be pretty expensive (for a larger number of vars). Furthermore inlining increases the number of variables in the function (which need to be initialized and destroyed), which may be problematic when inlining into unlikely branches. (Register allocation for CVs would improve this). Nikita --001a113f43dc240513053190135f--