Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:91836 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 78480 invoked from network); 22 Mar 2016 08:45:42 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Mar 2016 08:45:42 -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 207.46.100.109 as permitted sender) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 207.46.100.109 mail-by2on0109.outbound.protection.outlook.com Received: from [207.46.100.109] ([207.46.100.109:40092] helo=na01-by2-obe.outbound.protection.outlook.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id FA/53-46740-33601F65 for ; Tue, 22 Mar 2016 03:45:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=RWSoftware.onmicrosoft.com; s=selector1-zend-com; h=From:To:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=rBUYb/NqsCyBrMBR1LpAMBUvzhnBKCXv+QCMWImbzQQ=; b=SExK3FivQGr7yvLnfkp+i1YdYbTDWZtnCzwBNMisPH9ka2meLGSlSxBn5M9f2/pUx5Xi4/iBxXDVJmbSuZZ893fVaYvoNTUegBeGE4AGXo7QnC5Ca7iICuCuSKxFZR0+mppMxjRpAdDE8unpWl5hIefVD2PrU19neoVxPTVdQnQ= Received: from BY2PR0201MB1784.namprd02.prod.outlook.com (10.163.72.26) by BY2PR0201MB1783.namprd02.prod.outlook.com (10.163.72.25) with Microsoft SMTP Server (TLS) id 15.1.434.16; Tue, 22 Mar 2016 08:45:35 +0000 Received: from BY2PR0201MB1784.namprd02.prod.outlook.com ([10.163.72.26]) by BY2PR0201MB1784.namprd02.prod.outlook.com ([10.163.72.26]) with mapi id 15.01.0434.021; Tue, 22 Mar 2016 08:45:35 +0000 To: Lin Yo-An CC: internals , Xinchen Hui , Nikita Popov Thread-Topic: [PHP-DEV] Object getter method optimization Thread-Index: AQHRgL1CHqvU9JYTqUmE//kwh6SMdJ9ezu2rgAGLvwCABNAUmA== Date: Tue, 22 Mar 2016 08:45:34 +0000 Message-ID: References: , In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: lists.php.net; dkim=none (message not signed) header.d=none;lists.php.net; dmarc=none action=none header.from=zend.com; x-originating-ip: [92.62.57.172] x-ms-office365-filtering-correlation-id: b1b18ed2-993a-4268-34b2-08d3522e55e3 x-microsoft-exchange-diagnostics: 1;BY2PR0201MB1783;5:o+FRMTw3DWf+RW324DEPXrwjZevzc4/DJ1S0fB99k640Ygmvh3tTgEXHZ47DUvARBJi2Z19/nszi0U4qgG/x7G4GRk6xvEhBGqbWhHzkXDS6y7M//B0AEFpAq4kAeqOQWglLbqMuQj7rBp6EsdiXTg==;24:j8+Y0ygUY8B3jhiDO52+cx3I/Kc234DvBrBN0NCAYNIe9vXzilLQ/jxAtl1ZsEZlO9vXh5c92bCflOxC9RhyCoPSR3B+nXNYBODhhttTRzM= x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR0201MB1783; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046);SRVR:BY2PR0201MB1783;BCL:0;PCL:0;RULEID:;SRVR:BY2PR0201MB1783; x-forefront-prvs: 08897B549D x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(24454002)(53754006)(377454003)(11100500001)(5003600100002)(33656002)(16236675004)(189998001)(74316001)(19625215002)(5002640100001)(3846002)(5008740100001)(106116001)(66066001)(92566002)(1096002)(99286002)(76176999)(54356999)(6116002)(50986999)(110136002)(102836003)(5004730100002)(586003)(1220700001)(76576001)(15975445007)(2900100001)(2950100001)(122556002)(87936001)(19617315012)(19580405001)(19580395003)(19627405001)(16799955002)(81166005)(77096005)(4326007)(2906002)(10400500002)(3280700002)(3660700001)(3900700001)(86362001);DIR:OUT;SFP:1102;SCL:1;SRVR:BY2PR0201MB1783;H:BY2PR0201MB1784.namprd02.prod.outlook.com;FPR:;SPF:None;MLV:sfv;LANG:en; spamdiagnosticoutput: 1:23 spamdiagnosticmetadata: NSPM Content-Type: multipart/alternative; boundary="_000_BY2PR0201MB178466E2EC48C8E9E15DFDC2BF800BY2PR0201MB1784_" MIME-Version: 1.0 X-OriginatorOrg: zend.com X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Mar 2016 08:45:34.9329 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 32210298-c08b-4829-8097-6b12c025a892 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR0201MB1783 Subject: Re: [PHP-DEV] Object getter method optimization From: dmitry@zend.com (Dmitry Stogov) --_000_BY2PR0201MB178466E2EC48C8E9E15DFDC2BF800BY2PR0201MB1784_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi Yo-An Lin, This "run-time inlining" approach may work. PHP compiler (or optimizer) may mark functions and methods suitable for "ru= n-time" inlining (e.g. methods without arguments and FETCH_OBJ_R UNUSED, CO= NST -> TMP; RETURN TMP). Then INIT_METHOD_CALL may check this flag and execute "optimized code seque= nce" instead of pushing stack frame and real call. However, I'm not sure what kind of performance impact this may make, becaus= e we will have to make additional check on each INIT_METHOD_CALL execution. Thanks. Dmitry. ________________________________ From: Lin Yo-An Sent: Saturday, March 19, 2016 10:08 To: Dmitry Stogov Cc: internals; Xinchen Hui Subject: Re: [PHP-DEV] Object getter method optimization 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 =3D $worker->getStatus(); } inside ma= in.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 w= e 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 ju= st 2 op codes (FETCH_OBJ_R and RETURN), we then denote the method is a "get= ter method" And the next time, when we execute the same method, we found the "getter me= thod" flag, we simply execute FETCH_OBJ_R on that object and return the val= ue 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 cach= es. 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 --_000_BY2PR0201MB178466E2EC48C8E9E15DFDC2BF800BY2PR0201MB1784_--