Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:109019 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 50490 invoked from network); 14 Mar 2020 21:46:06 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 14 Mar 2020 21:46:06 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id E4D511804DD for ; Sat, 14 Mar 2020 13:08:05 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS8075 40.64.0.0/10 X-Spam-Virus: No X-Envelope-From: Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10olkn2049.outbound.protection.outlook.com [40.92.40.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sat, 14 Mar 2020 13:08:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AQYHB7LeCBnEGL8mxwPgIz2QNsz83pIsxlpja9Iti9UYJMCVg0kLQcv6Cl11a7eM+ltccoH39sR8XuR/Auw5f4ea7/ahK4/VBOznagg+GBbf81+t1GOrswPzC7g8Y6gvzxQw5lYCFXfmyuRT8Sbzwghl2HOjsEu3e1hnLK5F2etY/VH/Clz2rlQtc2M5Uco0Nj5KMxSkd51VbTp8KThpX+e6bH/P5DY1YAKwmvLgB2v9XPqHdYCEv+CSuWzmQsYaUE4/X6BDcIUSLqkqHX9fGvtlIL/Oenb/fI/0IzsvINpnrUnXf7ZyirIOrPJWyO3mS2PDQPkYIAgzDGpFb6VzhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RWo8QgqYs2yK2KWFc6VtCoaMUAuDbZBEdmYi9cknn5c=; b=BBMv7zToxrixklLzQ9p+YWqLTWe9CBw/+fUBHq96SY/gQQ0cvu9zhT+YjdmIFYzsEIg4PLOkIOydWNdgarIWYXlsVuvWPGaaGrrCFmxKt527QpdyGv2dUtXVBBJIY5zCvbDWPJhA6bBTXPuTEqCFYoFSyoUx91w4DTyP94k4LegXxUf+tnqR0hykdOI0zWWHLOBpzT2U+fxaPJ9OI2SE3LNZ3cO8dmZDvgEk1JFgPEcN6OBFu6quSI4pI0RXgkQzO8y6S9fJ9BhLEKYmaMGR7rD0x1Gvdpk3PtAMpq26lFNKPEsez/2JenF52KEVjJWs2Bv8MlhukA503iQFYSaToA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RWo8QgqYs2yK2KWFc6VtCoaMUAuDbZBEdmYi9cknn5c=; b=uCga2B/yv2BXmd9mfwXtyEjwCi4JAlbwQJdyrO5aK4VQEmBg45Y8FgH7QO9K0I+JBPbM8jcwyVI+nZSvtjS8/fzW3qXKRBPE4spZHVM0jWYuZeCh/bnOuieOHBiPNiCKx0dDzBxwrHWZM7aW2cS+inL49Ng9A+PBER6IqI2BZr3kMjuR6yPcOUnu90wfO0oYoithXAIYqsKVjE4NpftKU7XBPkRmmkaQ0jnhrkv6DMmZQd2yqUHI2pd//Z0rh6xTWIr6gcRAQNTTfo4A7aTr71FAyVRP9B9fvA8rJ7aO9Qoy5PJ9bQtBZa8O4wQPITdzdWOMBAg7fBrmh1jjSIIqNg== Received: from BN7NAM10FT043.eop-nam10.prod.protection.outlook.com (2a01:111:e400:7e8f::38) by BN7NAM10HT124.eop-nam10.prod.protection.outlook.com (2a01:111:e400:7e8f::172) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2814.13; Sat, 14 Mar 2020 20:08:04 +0000 Received: from DM5PR07MB3067.namprd07.prod.outlook.com (10.13.156.58) by BN7NAM10FT043.mail.protection.outlook.com (10.13.156.110) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2814.13 via Frontend Transport; Sat, 14 Mar 2020 20:08:04 +0000 Received: from DM5PR07MB3067.namprd07.prod.outlook.com ([fe80::1133:bcac:caf1:d588]) by DM5PR07MB3067.namprd07.prod.outlook.com ([fe80::1133:bcac:caf1:d588%3]) with mapi id 15.20.2814.018; Sat, 14 Mar 2020 20:08:04 +0000 To: Nikita Popov , PHP internals Thread-Topic: [PHP-DEV] [RFC] Explicit call-site pass-by-reference (again) Thread-Index: AQHV5/gVuNPktrT3uUeGjfXLvU2u7KhIoHDQ Date: Sat, 14 Mar 2020 20:08:04 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-CA, en-US Content-Language: en-CA X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:862182C0666EA36D92F9D1EAAEBE88FDD30E4542F369F4B4647E51D0363DA7E5;UpperCasedChecksum:D352C69CE3546E39D73235BEB530C3D422EF79C5E7549AC45D3754411D285F05;SizeAsReceived:7148;Count:45 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [Wz6awjXbmwsm1i8pxKC74PDbt8N0hqU1MbtBMEFBY6g8Qh4QQHRC963xFFo5OVbT] x-ms-publictraffictype: Email x-incomingheadercount: 45 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: fa94dc58-e402-4f1f-e3c9-08d7c8536793 x-ms-traffictypediagnostic: BN7NAM10HT124: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: +P42LfdiolYE+jcu/aPiTr4y5nfl6mx145AM+Dv68IEh9alfiU5A/tIuyKCxAuI5YN4R0tt0z4YjltgAKZ8ExsEZ3FTKmXNcoJlwRfV3lfgSsyck31L7bvEH+owffaanibXPuvC0OBYrUuP6TmEQpnKlLRYtENLvbdTyhTNJuPTZ5KW+TEpJbSHYFyB9vDwRUM0BQLOZusPCJ8XLg7WZ3ZkM7Ho9wXUxPURb6aTgVHM= x-ms-exchange-antispam-messagedata: 2WMzhNu1JtnKbaxFdYRERKxFxzf2bKIyOwtBcvfuTCyIZ2KEU1ytt4ujiuIXKw1mL9a9uN3tqpkFKeYPvW8oF4vg0E18wsgiXQCmdmymdNL95POoViuSeqhcuFScr7di9ML8qfOU+49vP14LNkl8B1Qb/cjlTnN8AS5Cnne+uqNpR2yajJ0Iu3yFXsPOLUrttFDL/iHYMxl0Z5CcI0CgQg== x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: hotmail.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: fa94dc58-e402-4f1f-e3c9-08d7c8536793 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Mar 2020 20:08:04.1180 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN7NAM10HT124 Subject: Re: [PHP-DEV] [RFC] Explicit call-site pass-by-reference (again) From: tysonandre775@hotmail.com (tyson andre) Hi internals,=0A= =0A= One idea I had that was related to this (but not in the scope of this RFC)= =0A= would be adding a way to force the interpreter to treat an argument (variab= le, array field, property access, etc) as being passed by value,=0A= and refuse to modify it by reference (e.g. emit a notice and create a separ= ate reference (or throw an Error))=0A= =0A= i.e. instead of using the opcode SEND_VAR_EX, use a brand new opcode kind S= END_VAR_BY_VALUE that would do that, if the method signature was unknown.= =0A= =0A= - Currently, php emits a notice and creates a temporary reference for non-v= ariables, such as when passing the result of a function returning a non-ref= erence to a reference parameter.=0A= - I assume SEND_VAR_BY_VALUE is equivalent to the new opcode needed if a su= bsequent RFC made call-site pass-by-reference mandatory in a given file.=0A= =0A= Possible syntaxes (only within argument lists):=0A= =0A= ```=0A= $a->someMethod(*$foo);=0A= $a->someMethod(&&$foo);=0A= $a->someMethod(\$foo);=0A= $a->someMethod(identity($foo)); // add a new keyword such as identity or v= alue=0A= $a->someMethod(=3D$foo);=0A= ```=0A= =0A= Context: From the current thread's RFC https://wiki.php.net/rfc/explicit_se= nd_by_ref=0A= =0A= > In fact, our inability to determine at compile-time whether a certain arg= ument is passed by-value or by-reference is one of the most significant obs= tacles in our ability to analyze and optimize compiled code=0A= =0A= I suggested this because it would be useful for optimizing frequently used = code (after profiling it (e.g. with phpspy) and checking opcache debug outp= ut),=0A= especially in frequently called functions/methods.=0A= =0A= I'd prefer a declare directive (or edition) to make call-site pass-by-refer= ence mandatory to pass by reference over this suggestion, though.=0A= =0A= - Tyson=