Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:91761 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 91823 invoked from network); 19 Mar 2016 07:08:07 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Mar 2016 07:08:07 -0000 Authentication-Results: pb1.pair.com smtp.mail=cornelius.howl@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=cornelius.howl@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.180 as permitted sender) X-PHP-List-Original-Sender: cornelius.howl@gmail.com X-Host-Fingerprint: 209.85.214.180 mail-ob0-f180.google.com Received: from [209.85.214.180] ([209.85.214.180:33256] helo=mail-ob0-f180.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 64/B2-03097-5DAFCE65 for ; Sat, 19 Mar 2016 02:08:06 -0500 Received: by mail-ob0-f180.google.com with SMTP id fz5so136918385obc.0 for ; Sat, 19 Mar 2016 00:08:05 -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=Hwm+xFx/1yfwzWXbIoyjNywIu+HRInnAsQd22O0Op48=; b=d5Oks1wRhZ3yHi4/CDrvS+ycNxjrgPbljjKxeH455Ufytd4Vs59a7SLUjdtbJ+N/TV s1qocBjEyAHZMRia4P++zsqh0Hm54neokf4om+ulpO4xP20hT9VYvDKt/yTPDP/wRO3d 6oO4frZsVawR+xxvkQVk1pKGfH99UQEgMqa3BCZveQFJ7J7FsE4J7vnWzt81QCrp1LLg KQl/9WQi3POCIF8PKsUl+C6GYLDB7/HtpVuRPXkRkPB68LLHeDVLRnOvOo6+IhwmMZ0d Jb8NvRIredIxkV0pcE9cl2oXooa3Roo7CNAXTDzaOPYvXP9D6TK7at8BnVH2PRSkcPpE leFA== 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=Hwm+xFx/1yfwzWXbIoyjNywIu+HRInnAsQd22O0Op48=; b=gtdIwuvjKT9vY3lQkj0+a8CDD2xIbhSsizkk1103kvf/0Ucn9S+Ka5QoHOX3cnbX7W mxwzVuhmsMCCzTcxun1Vralq/Q/KsWTpQGljxWUUcwBOL+qN82GHTERjVe/eMfvTMCr7 EAoq8GLTQ3e3w9+RPqKfl2vW2l9ZC3T2tQ7HlR92KG8bimEK8lLPnLUOcuAcZ03r2r7j kugHid3GvdBc1x527aJMbB0auL8r/Q0B6k7OXJDkgyTKJ5+0mn2/gV1wGZwglzBNksmV KpP1hBAU/Y2jGprP2FzwHCdJxkzGXk+/tnRgv+qvA0MjkAGIzx0t/ml3u2JGBjOL7QZa dnCg== X-Gm-Message-State: AD7BkJKB208sMjQXZ4Qo6v9nxyPOdbpHOUQAKD12kMpfTEx0GUS3xzsiitti8q00YIhXekzd8Al5PpZARZSx1w== MIME-Version: 1.0 X-Received: by 10.60.50.98 with SMTP id b2mr11892371oeo.38.1458371282432; Sat, 19 Mar 2016 00:08:02 -0700 (PDT) Received: by 10.157.7.167 with HTTP; Sat, 19 Mar 2016 00:08:02 -0700 (PDT) In-Reply-To: References: Date: Sat, 19 Mar 2016 15:08:02 +0800 Message-ID: To: Dmitry Stogov Cc: internals , Xinchen Hui Content-Type: multipart/alternative; boundary=001a11c1e2763d79fc052e61862b Subject: Re: [PHP-DEV] Object getter method optimization From: cornelius.howl@gmail.com (Lin Yo-An) --001a11c1e2763d79fc052e61862b Content-Type: text/plain; charset=UTF-8 Hi Dmitry, Thanks for your reply! You're correct. let me try to explain your points: If I have a main.php and worker.php And I defined work($worker) { $status = $worker->getStatus(); } inside main.php when main.php is compiled, we don't know what the class entry of $worker is. What we only know is invoking a method "getStatus" on $worker CV unless we know we have to compile worker.php before main.php and add a type hint on $worker. Is it correct? Since the original approach doesn't work, here comes another new idea: When executing method call on an object, if we found the method body are just 2 op codes (FETCH_OBJ_R and RETURN), we then denote the method is a "getter method" And the next time, when we execute the same method, we found the "getter method" flag, we simply execute FETCH_OBJ_R on that object and return the value to avoid extra op code execution time. Do you think if this could work? Best Regards and Thanks for your work on PHP VM Yo-An Lin On Fri, Mar 18, 2016 at 3:36 PM, Dmitry Stogov wrote: > Hi Yo-An Lin, > > Unfortunately, this approach won't work. > At first, at compile time we don't know the body of called getter. > At second, the called method might be changed even at run-time, because of > polymorphism. > > Tricks like this might be implemented using JIT and polymorphic inline > caches. > > Thanks. Dmitry. > > ________________________________________ > From: Lin Yo-An > Sent: Friday, March 18, 2016 05:23 > To: internals > Subject: [PHP-DEV] Object getter method optimization > > Hello Everyone, > > > I am recently trying to write an optimizer that could optimize the getter > method call into just one object fetch opcode. > > I'd like to know thoughts from you guys, here is the note: > https://c9s.hackpad.com/INLINE-OP-TVGo9WcshbZ > > -- > Best Regards, > > Yo-An Lin > https://github.com/c9s > -- Best Regards, Yo-An Lin --001a11c1e2763d79fc052e61862b--