Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:116544 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 13297 invoked from network); 30 Nov 2021 23:24:22 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 30 Nov 2021 23:24:22 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 9A8B618053A for ; Tue, 30 Nov 2021 16:22:55 -0800 (PST) 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.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_HOTMAIL_RCVD2, FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS8075 40.80.0.0/12 X-Spam-Virus: No X-Envelope-From: Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam08olkn2051.outbound.protection.outlook.com [40.92.45.51]) (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 ; Tue, 30 Nov 2021 16:22:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OUc8wuNqFXA6j7Gea5jcCjs2vYeUEtxxL5Oxq6L9mghTG3tfjYKaF9ITbD7bI8b8v9uJ2G9Z3g/74+uAmPHYGyUW8Kkq3READ0R9aosgMf3CrIZiX05cc9h32U0xuXvwQKjIea26I2bCXV6dt7OAD0STD9dkmVclCvrB8StAaBSgqwSXU1eVnAiXYKRIAZa572G5WyiVwM52HYxi17wykq9wh0R8595+41CtTLq/RIn2g9B7NQpeiQnhzE2wAvB8PaiTPUu9T3agYN1nrw12hmVx/azOcx3vHxariReVlo0MOs8C5nOW1fpaIpgmLZfYExNUF8Fqo0R+Bq55HYktNQ== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=tIVbMQLSvxhmwQAnkc/7ezhvXvNmOYUYUxKy5zsP/ps=; b=AAl52dtuhQkqKz/WhU+qtDjR5zZ59a+3vODlOh0C7EMD/yMIp+gRb+gQ0rVq4q8WMihweaBo/nrenxj0jmUet9L8xYlcPXn/Z4b7LRB1qWxLkEwV3ZoeWDze/kMz/z6wkSkPiNdrAPy4NkmCH8nu6lBOFBDno6mC8E6/KiU9uqMxXDsJTfpFdUXkbDgAPSX++Io0Fh0NaFycCJ+9nGVEJrnSvRP4Yyditpm117LfmzL0qhTZmkqFBHK9Tm4sFu6H3S8R6qUN4fpDnk4EWuf3JJNmQgtgBJk79tkDIypup+PHxkPceVK4B3zeaYAMYcWATrWn2iSwrFaX/9F8k1twNw== 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=tIVbMQLSvxhmwQAnkc/7ezhvXvNmOYUYUxKy5zsP/ps=; b=erTxNUrt2MrYb9kLMCy6kbzAsQzqOKIJspMOoUuFvudUKK6tdRRdrgq5D8tEwAbI0GTH9Gj3FZK/6YKkbAYzy3nUzZj+3nNv4Lnz/YDNHn8Cg2+29EYgCnMbWudFAOad5snAPq42/5pw4x7bxyig6z884zsjD24k/g7cw6fzHARZ3PUaJb7JxiFS5ZlqQnq8SuUik0nc7czI9GjbAl4LK5pvBF7QNQZ7/HkscmNLL1YZjDSkRu6hwbP+B2sSAFYxZB1/VKZ9h+/Fj8kIaSGVXWjvtLhaqOI2Rhaq8bR2VxeV+bKCBR6C0lQ9h4Ctyb0yvdEepRmWQO1LO6nPJiugpA== Received: from DM6PR14MB4155.namprd14.prod.outlook.com (2603:10b6:5:21e::11) by DM6PR14MB2555.namprd14.prod.outlook.com (2603:10b6:5:119::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.20; Wed, 1 Dec 2021 00:22:53 +0000 Received: from DM6PR14MB4155.namprd14.prod.outlook.com ([fe80::cc75:8c06:6770:599f]) by DM6PR14MB4155.namprd14.prod.outlook.com ([fe80::cc75:8c06:6770:599f%4]) with mapi id 15.20.4734.024; Wed, 1 Dec 2021 00:22:53 +0000 To: Glash Gnome , "internals@lists.php.net" Thread-Topic: [PHP-DEV] Cache zend_function* Thread-Index: AQHX5J4kUdoPS3sKa0+taYJ49foeRKwcxNVt Date: Wed, 1 Dec 2021 00:22:53 +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: suggested_attachment_session_id: 8590dd6a-14f9-f974-e36f-f945f30b66f9 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [Pp8xNY58oKiw/SIvGBfFCUY1AOLZKiw3vEOQ3OHmBftg73PtJ9X1rdVCOihJ3LNX6nwlnIcce2A=] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: f9db7c4a-fcb5-46cd-649a-08d9b460b763 x-ms-traffictypediagnostic: DM6PR14MB2555: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: YBB2mo1fzBLo2TFn1qH+Xfk9EemXIO3nSMGeQvPqJd/PK/bZuSPC1kwsI1zo9Cioug9nReIgza2O0Blg20pHpbhn/m9wcP5KU6Vs+tnyAWsMdSEHseS6d3j6hjozaFjKlnNemDC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NEQreoSMjnzrnDoGgvXsoDy8AE7nu0PINRP/tbG2?= =?iso-8859-1?Q?iFwBYS8M77MjDKhJI97u39Rw6IxPz81sheeRSTkRc++eAah6AmVu91njaI?= =?iso-8859-1?Q?JJUa200Ir+ogKxv2KiVExuax+9im2idphpHRqcI5Fx2oyseq61ahD5LDpx?= =?iso-8859-1?Q?1SIKniPBvH3Y3r6x2T9Sh1UMIveR66eRVoup6dPE/bYeZyRtRQL2+/yrPE?= =?iso-8859-1?Q?nNcCLm51XfWHh35GZ5WAGaJ1+p6I4EZls+agUMmxz07LleCqotWZRE6f0l?= =?iso-8859-1?Q?5wpMBbxaPdU2uWjIFQ9ttW1MRqHWb0n3rlCBxCXw42Oz2YTD7JoloPKgcJ?= =?iso-8859-1?Q?ZPQtsq2g7dd23Jme4uQFn0YfTLn3NTugWhGTM4d+JH0irRo8062dy4BmW5?= =?iso-8859-1?Q?YKa0XIg6UfDyAxpgpIwaLzWU7DyQLMSlFMud9Y2x3hI1Tu2LcdgFhRihnf?= =?iso-8859-1?Q?HCvHtRHw+Xs8RVSL7k2XZ2wPj9mMCoMueadCA40HiYn2v0cozr3Vlb4UVJ?= =?iso-8859-1?Q?eWb/2jd3IeTbb/ODWFjSEErZjiBPJmvuKiQblcK89m2IkS7gY33c/TCuzw?= =?iso-8859-1?Q?5wjf9FoD3HKqZzdbi0sJmv7VPgvkKLKGy5coDh1hvqxoYpbElQEBqWGXdv?= =?iso-8859-1?Q?TFC9NdxrEBdZe7qADRG0JHdYl8Lt9szpxflv4eb2iBAuXOCqVtoPWmOjKW?= =?iso-8859-1?Q?/g=3D=3D?= Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: sct-15-20-3174-20-msonline-outlook-32894.templateTenant X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM6PR14MB4155.namprd14.prod.outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: f9db7c4a-fcb5-46cd-649a-08d9b460b763 X-MS-Exchange-CrossTenant-originalarrivaltime: 01 Dec 2021 00:22:53.5712 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR14MB2555 Subject: Re: [PHP-DEV] Cache zend_function* From: tysonandre775@hotmail.com (tyson andre) =0A= Hi Glash Gnome,=0A= =0A= > I'm doing the Cairo C API extension.=0A= > Also there is a wrapper written in php for the OOP side( example:=0A= > https://github.com/gtkphp/gtkphp/blob/main/lib/Cairo/Context.php)=0A= > =0A= > So far, so good.=0A= > =0A= > Now let's do the same thing with Gtk,=0A= > (https://github.com/gtkphp/gtkphp/blob/main/lib/Gtk/Widget.php#L7)=0A= > Luckily I can *store zend_function* pointer in the GtkWidgetClass*( C-lik= e=0A= > OOP)=0A= > =0A= > Finally, I do the same thing for GHashTable( C API + php OOP)=0A= > But now I need to *use a global zend_array/hash to store the overridden= =0A= > methods*=0A= > for the same reasons as https://github.com/php/php-src/pull/7695=0A= > =0A= > =0A= > I think it is better( more generic, simple to understand) to *overload th= e=0A= > zend_class_entry* .=0A= > =0A= > Do you think this is a good idea?=0A= > Is this possible ?=0A= > Do you have a solution for me?=0A= =0A= Are you talking about all methods or just ArrayAccess?=0A= =0A= If you're talking about https://github.com/gtkphp/php-ext-gtk-src/blob/mast= er/php_glib/hash-table.c=0A= it's possible to associate the table of overridden methods with the instanc= e of the object,=0A= and look it up in a C property of `intern->methods` to call the overridden = method.=0A= =0A= - If you're talking about avoiding doing a hash table lookup on every metho= d call to an instance, you can use a `methods` property.=0A= =0A= https://github.com/php/php-src/blob/PHP-8.1.0/ext/spl/spl_fixedarray.c#L241= -L301 does that - see create_object, spl_fixedarray_new, and `spl_fixedarra= y_object *intern;`=0A= (I implemented that in https://github.com/php/php-src/pull/6552)=0A= =0A= It turns out review comments mentioned something similar about `ArrayAccess= `.=0A= At the time I wasn't as familiar with how it'd be done for all classes and = work with inheritance, though I think it's possible.=0A= =0A= -=A0If `arraylike_funcs_ptr` were added to php for ArrayAccess, `instance->= ce->arrayaccess_funcs_ptr->offsetget->scope !=3D my_base_class_entry` could= be used to check if the internal implementation was overridden=0A= =0A= > Ideally these methods would be cached in the class_entry, but that's a la= rger change.=0A= =0A= =0A= ```c=0A= // Declared in Zend/zend.h=0A= // Initialized in Zend/zend_interfaces.c=0A= // ....=0A= /* allocated only if class implements Iterator or IteratorAggregate interf= ace */=0A= zend_class_iterator_funcs *iterator_funcs_ptr;=0A= ```=0A= =0A= Regards,=0A= Tyson=0A=