Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:92899 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 89220 invoked from network); 28 Apr 2016 19:38:34 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Apr 2016 19:38:34 -0000 Authentication-Results: pb1.pair.com smtp.mail=codekestrel@googlemail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=codekestrel@googlemail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain googlemail.com designates 74.125.82.67 as permitted sender) X-PHP-List-Original-Sender: codekestrel@googlemail.com X-Host-Fingerprint: 74.125.82.67 mail-wm0-f67.google.com Received: from [74.125.82.67] ([74.125.82.67:33730] helo=mail-wm0-f67.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E2/CC-28296-8B662275 for ; Thu, 28 Apr 2016 15:38:33 -0400 Received: by mail-wm0-f67.google.com with SMTP id r12so296172wme.0 for ; Thu, 28 Apr 2016 12:38:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc; bh=PuHj/qD5CA6hollN299yCLwXfaUCL2tq/T7qdhSv65A=; b=MSMIppbYwwiSMFkisEWmI0bxjdb7CUxMIU0bVoK1QYDr/IW4+Zgijrnm3efLnu2r2C sBQdwNIg82n7McOSnOLoibZ+J2Jqjw0OtxpNb8lSkoJ1wQQPBzr+EUgj5RZGSuZzhQWy 3utLuWuailT13NcFlcYHEIZnwK89L7K49ISA1sI1R9WdSiKlAn3Fk0c7X4nx+o8DrU8v w4ZdDZRJx6i+kVuG66EbDJACdT50rwkxD9G87k6/TGHyZefiDkGnW+iGtACu2ycPJbNc UCKW4yfno1gCpxNkvOfKXYciVId9vFAMfNagtL3aED/qvpHA8yw4PHUILPfpRr6rdUNS x29w== 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=PuHj/qD5CA6hollN299yCLwXfaUCL2tq/T7qdhSv65A=; b=DtFqdyOdJi1OSNlE1nh0wEep1zKYljAVdIWaWeeFeWCYbcNptt1kMhvZ15HOxDr41t pnoAkMv/1YZub2aJ2TxNUPN/3EJ4AKwOXNIUlbCzoj7mw40z85Vl5EFjU2f1Ow/0Gyah RpFzvMMwWZ5Omwd59IozY2PELC7OgS9Ln1G/Jtn7IT9BCfNRyssOvdMsJ17BquLHFGKM DIw7e9daXph5WlLYIS7eb+JKF0jzCdFPwdkH+xes+jyuP1YZn4abzrxRpFd8DngyhRWA WLwSYPExFFiGG+LAxdHFP4Kx95JJJNeG9XIDV5m0nG86SOoIYs7QH9GFRKpwSyrpIOZp eClw== X-Gm-Message-State: AOPr4FWBYoqbcjUwN2fWQ2NS3XpRS0PZkEktMCoVR/EG53NDWnt5Fi7NxLRaSUJjyAP9snjq4MnNG9sXYn6yWA== MIME-Version: 1.0 X-Received: by 10.194.115.196 with SMTP id jq4mr17200351wjb.101.1461872309218; Thu, 28 Apr 2016 12:38:29 -0700 (PDT) Received: by 10.28.140.10 with HTTP; Thu, 28 Apr 2016 12:38:28 -0700 (PDT) Received: by 10.28.140.10 with HTTP; Thu, 28 Apr 2016 12:38:28 -0700 (PDT) In-Reply-To: References: Date: Thu, 28 Apr 2016 20:38:28 +0100 Message-ID: To: Nikita Popov Cc: PHP internals , Sara Golemon Content-Type: multipart/alternative; boundary=001a1130cd7cb2b502053190ab44 Subject: Re: [PHP-DEV] Inline functions From: codekestrel@googlemail.com (Dominic Grostate) --001a1130cd7cb2b502053190ab44 Content-Type: text/plain; charset=UTF-8 I figured class methods would be a problem, especially if it were implemented at compile time as the compiler wouldn't necessarily know which class it refers to. Curious though, which part of the function call causes the performance hit? I've noticed that the number of parameters it has contributes a large part it. On 28 Apr 2016 7:55 p.m., "Nikita Popov" wrote: > 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 > --001a1130cd7cb2b502053190ab44--