Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:102045 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 95408 invoked from network); 17 Apr 2018 07:18:28 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Apr 2018 07:18:28 -0000 Authentication-Results: pb1.pair.com smtp.mail=dmitry@zend.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=dmitry@zend.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain zend.com from 104.47.33.126 cause and error) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 104.47.33.126 mail-bn3nam01on0126.outbound.protection.outlook.com Received: from [104.47.33.126] ([104.47.33.126:64416] helo=NAM01-BN3-obe.outbound.protection.outlook.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 12/28-36099-2CF95DA5 for ; Tue, 17 Apr 2018 03:18:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=RWSoftware.onmicrosoft.com; s=selector1-zend-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=ZGrwj+5cLSuxdXfw6uaqn+MPIyZ8mivdGxPAe/FmewM=; b=VVeycz/kpRs8Af+2HsrYGdJZR/68mCMd11p+lT7lKwsIUHD+Yk7vUb808XheiLYl25PqiabSbxXT4+qDRMNsNQEvf0v7dN6EujK1BsnvzcL5iOaTZXNtlJuMniiC3zhQevxKPxVWXJM8KSvQxMs1FElSGzvjtZ70Hg1zclZVPJw= Received: from BN6PR02MB3234.namprd02.prod.outlook.com (10.161.152.32) by BN6PR02MB3314.namprd02.prod.outlook.com (10.161.152.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.675.10; Tue, 17 Apr 2018 07:18:22 +0000 Received: from BN6PR02MB3234.namprd02.prod.outlook.com ([fe80::b5e1:42c:d6ad:56c]) by BN6PR02MB3234.namprd02.prod.outlook.com ([fe80::b5e1:42c:d6ad:56c%13]) with mapi id 15.20.0675.015; Tue, 17 Apr 2018 07:18:21 +0000 To: Stanislav Malyshev CC: Dmitry Stogov , Zeev Suraski , Xinchen Hui , Nikita Popov , Bob Weinand , "Anatol Belski (ab@php.net)" , "PHP internals list" Thread-Topic: [PHP-DEV] PHP FFI extenesion Thread-Index: AQHT0yrBnLpXxgz1HEWdw/jxKSLJkaQEFM4AgAB9ZWc= Date: Tue, 17 Apr 2018 07:18:21 +0000 Message-ID: References: ,<56794c33-a728-d399-2462-b62ba1b7a509@gmail.com> In-Reply-To: <56794c33-a728-d399-2462-b62ba1b7a509@gmail.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=dmitry@zend.com; x-originating-ip: [212.232.72.197] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;BN6PR02MB3314;7:7xjpA8Gp0Lz5kF+BJO/RETZNJi8Ev1dRCiljOh7X7z4m6g2hnWTLW2o6nlcIHjLaAtnyHhEKdkm23C0mB8QoESqoj6t9Fy4GsCGUPcdDRfzIyon+Ghgmp+xq0/7Tey1a3wogKWtjT3z9KsOjM6FXHecpVZFdoWufRltnVwWlxbpWs4Fh5Ckqq4ndi97ViJy4FbPWeqhrN5xGku135U3iWYdbsF3ljmC4q98s16OgQjDyPfqdXtL5kYHY1XEvRj34 x-ms-exchange-antispam-srfa-diagnostics: SOS;SOR; x-forefront-antispam-report: SFV:SKI;SCL:-1;SFV:NSPM;SFS:(10019020)(346002)(376002)(366004)(396003)(39380400002)(39850400004)(199004)(189003)(446003)(3846002)(6116002)(476003)(4326008)(6916009)(6436002)(59450400001)(486006)(31686004)(81166006)(81156014)(33896004)(68736007)(53546011)(1411001)(5660300001)(25786009)(3280700002)(6506007)(97736004)(966005)(76176011)(6486002)(8676002)(102836004)(11346002)(86362001)(9686003)(6512007)(26005)(236005)(186003)(2906002)(5250100002)(54896002)(6306002)(99286004)(316002)(229853002)(7736002)(3660700001)(606006)(54906003)(106356001)(53936002)(66066001)(39060400002)(31696002)(14454004)(6246003)(2900100001)(8936002)(478600001)(105586002)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:BN6PR02MB3314;H:BN6PR02MB3234.namprd02.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(5600026)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020);SRVR:BN6PR02MB3314; x-ms-traffictypediagnostic: BN6PR02MB3314: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(158342451672863)(166708455590820)(85827821059158); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6040522)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(3231232)(944501327)(52105095)(3002001)(6041310)(20161123562045)(20161123560045)(20161123558120)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:BN6PR02MB3314;BCL:0;PCL:0;RULEID:;SRVR:BN6PR02MB3314; x-forefront-prvs: 0645BEB7AA received-spf: None (protection.outlook.com: zend.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: sTlrN9OzmcZTfeLTMzQrw7ikiBJFQTZfMl3zlNPOnqFEcALDW+IXgMYQDNAzgAxSrWptuCjYOcfmV4Q6D+f1RfyKn0OTjF6UIVlq4SRU9tMpPyqPfioUcT+VMLqejqOOsUvu/56mApBW8WuA2/aQDzaTwYZbSeuICxiSVshnQIh8GgLBKLzhSxAno5/ry91Q spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: multipart/alternative; boundary="_000_af4cb226df794b29810e52028792c37demailandroidcom_" MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 675f0ec8-1936-4dc0-666e-08d5a43366e4 X-OriginatorOrg: zend.com X-MS-Exchange-CrossTenant-Network-Message-Id: 675f0ec8-1936-4dc0-666e-08d5a43366e4 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Apr 2018 07:18:21.8074 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 32210298-c08b-4829-8097-6b12c025a892 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR02MB3314 Subject: Re: [PHP-DEV] PHP FFI extenesion From: dmitry@zend.com (Dmitry Stogov) --_000_af4cb226df794b29810e52028792c37demailandroidcom_ Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable On Apr 17, 2018 2:49 AM, Stanislav Malyshev wrote: Hi! > I've spent some time thinking about simple FFI for PHP, and finally, borr= owed most ideas from LuaJIT. > > This is an initial PoC. It was tested on Linux only. > > > https://github.com/dstogov/php-ffi > > > I would appreciate review, comments and ideas about missing features and = functionality. > Looks interesting. On a cursory look, couple of thoughts: - I think all the classes involved should be made non-serializable and non-unserializable. Agree. - Does it load shared libraries, or only uses ones already loaded? If the former, I think there should be a way to unload them at the request end (even though it might be performance issue, and may be not possible if persistent resources are involved), otherwise we leak state between requests. I have a bit opposit idea. We will keep FFI for CLI but disable it for web = apps (like dl()). At the same time, we will develop a technology to preload and reuse PHP fi= les across requests. And allow FFI there. - OTOH, people may want to load a set of persistent definitions from a config file, etc. - the ffi definition probably won't change much, and having locked down set of FFI interfaces the rest of the code is using might be beneficial Yeah. Like this. - Since this thing is dealing with raw pointers, etc., from PHP code, there may be a lot of crashes from using this extension in a wrong way. I wonder which facilities we could provide for helping people to debug it (for people who aren't super-comfortable using gdb on PHP engine). Programming using FFI, is very similar to C. I'm not sure, if we may provide good debugging facilities. Thanks for review. Dmitry. -- Stas Malyshev smalyshev@gmail.com Hi! > I've spent some time thinking about simple FFI for PHP, and finally, borr= owed most ideas from LuaJIT. > > This is an initial PoC. It was tested on Linux only. > > > https://github.com/dstogov/php-ffi > > > I would appreciate review, comments and ideas about missing features and = functionality. > Looks interesting. On a cursory look, couple of thoughts: - I think all the classes involved should be made non-serializable and non-unserializable. - Does it load shared libraries, or only uses ones already loaded? If the former, I think there should be a way to unload them at the request end (even though it might be performance issue, and may be not possible if persistent resources are involved), otherwise we leak state between requests. - OTOH, people may want to load a set of persistent definitions from a config file, etc. - the ffi definition probably won't change much, and having locked down set of FFI interfaces the rest of the code is using might be beneficial - Since this thing is dealing with raw pointers, etc., from PHP code, there may be a lot of crashes from using this extension in a wrong way. I wonder which facilities we could provide for helping people to debug it (for people who aren't super-comfortable using gdb on PHP engine). -- Stas Malyshev smalyshev@gmail.com --_000_af4cb226df794b29810e52028792c37demailandroidcom_--