Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:100423 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 72204 invoked from network); 6 Sep 2017 17:20:27 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Sep 2017 17:20:27 -0000 Authentication-Results: pb1.pair.com smtp.mail=php@golemon.com; spf=softfail; sender-id=softfail Authentication-Results: pb1.pair.com header.from=php@golemon.com; sender-id=softfail Received-SPF: softfail (pb1.pair.com: domain golemon.com does not designate 209.85.220.169 as permitted sender) X-PHP-List-Original-Sender: php@golemon.com X-Host-Fingerprint: 209.85.220.169 mail-qk0-f169.google.com Received: from [209.85.220.169] ([209.85.220.169:34335] helo=mail-qk0-f169.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id EE/98-10715-95E20B95 for ; Wed, 06 Sep 2017 13:20:26 -0400 Received: by mail-qk0-f169.google.com with SMTP id b23so21181748qkg.1 for ; Wed, 06 Sep 2017 10:20:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=golemon-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-transfer-encoding; bh=awqA/hYW1FokASVtgsK+CoXMFlddMbjkMwo2BJnCfyY=; b=Jvhw7rBmrWINRrPDhkNb1K9HySDB6ZZehxPWblQPh3ADDifNBagmmqowFltFs/7z8i dJe8EdnXYjoxkVDzHxMrk/JhydZPr6YG4cjULs/NAtkwvtwHby3GKUb1R0LXd5Y+q4qD VHkU7ZGbv880uf6hutZSIitvhJbd6yfhOtUL466Qa/zUshLOFhUQRCYnutQh+Z7mrcCK JgJxKCQXSonfUxehZOJKFSGnQLaMDYgKWR9tfqOL/TtcrnxzPaxRnq8JaNSUtxOIvh98 RxolWE4hDT9ju1OdCVmIUxn5sQ7eEKjw49u1ugO3Wwy4x/a8ClrlxDo+oUdxCnMqLY6A p5eA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc:content-transfer-encoding; bh=awqA/hYW1FokASVtgsK+CoXMFlddMbjkMwo2BJnCfyY=; b=qkbDR0wz0Hyg+C2mTm5JjWVlCwIsfyXEQ+6LnEmwCBNbCgULl58/VzFylumygUsKHW 3IKxnRtA44XJ+6g6ItwCzVHC9jZnCR6vmUeN8ejnyKcfDVzbYDC8WbLZ5s3te+FkOdVb nREL3VA7y7As7BTz3zuRiWn1n4hJs6GqV66ZtrNzfesD59NEYZuLrK0cJiYYSeXg/79R 9LNBTnu4XNLyVvX95kaIVw58zXOQfF677CdDKrZNnw3ofUQaH4ttp7JZwEds5qtkA1Ff nh2+Fs0NeaiZSdKZ5f5V1ARoarQXA2CDTHzPMyu1O2smuDYHQouyyKsGRloofTQLQiOz ZGlg== X-Gm-Message-State: AHPjjUgQp2hdecyMjCLa6OEnikOzkyxEC7qnLP3HluYnC29HJPYGLPPJ 2EuP6gi52i5C6q/NZ5q/uakTT5L6b8sI X-Google-Smtp-Source: AOwi7QBar9hDrAtGPjGd6ai3OKyWzwwOKYgRGJOsdag9XrpRneinCtdGtMogpxf1xoTCIOQOWzu+WpeomjUn3yv2O2g= X-Received: by 10.55.75.17 with SMTP id y17mr4634069qka.114.1504718422116; Wed, 06 Sep 2017 10:20:22 -0700 (PDT) MIME-Version: 1.0 Sender: php@golemon.com Received: by 10.12.132.3 with HTTP; Wed, 6 Sep 2017 10:20:21 -0700 (PDT) X-Originating-IP: [206.252.215.26] In-Reply-To: References: Date: Wed, 6 Sep 2017 13:20:21 -0400 X-Google-Sender-Auth: zzyV4J4azATj3X2DPbzPGK58w3g Message-ID: To: =?UTF-8?Q?Fran=C3=A7ois_Laupretre?= Cc: Zeev Suraski , Nikita Popov , Zeev Suraski , Arvids Godjuks , Dan Ackroyd , "internals@lists.php.net" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Providing built-in functionality written in PHP (was RE: [PHP-DEV] [VOTE] UUID) From: pollita@php.net (Sara Golemon) On Wed, Sep 6, 2017 at 11:30 AM, Fran=C3=A7ois Laupretre wrote: >> Secondly, ideally, this shouldn't just be a mechanism to mix and match C >> and PHP - but actually make it easy for people to write pure PHP code >> that'll become integrated to the PHP binary. PCS can practically alread= y >> support that, we'd just need some build magic to take .php files during >> build, create the PCS wrapper for them and compile them right in. Have >> some sort of a standard where builtin.php files inside extension >> directories are included, or something of the sort? Definitely requires >> more thinking, but if this becomes a basic building block of PHP as I >> think >> it should, I wouldn't want end users to have to manually compile PHP cod= e >> into .phpc or create .c wrappers - but have it as automatic as possible. > > > Parsing the code, extracting symbol names, and generating all needed > information as a C include file is done offline because it requires a > working PHP interpreter. So, it cannot be done at build time (when compil= ing > the core). It is done the same way as the core files generated using PHP > (like zend_vm_execute.h/zend_vm_opcodes.h): each time, he modifies the PH= P > code, the developer must regenerate the '.phpc' files. The '.phpc' file w= ill > be managed in git and will be included in the source distribution. So, > nothing changes for the end user : phpize/configure/make. The same for > extensions included in the core: '.phpc' files are included in the source > distrib. I'll also probably include this code (re)generation in 'phpize'. > > So, the most difficult part, AFAIK, is how to make class and function cod= e > persistent, or load it just in time, or a combination of both. The case o= f > constants is more complex and out of scope at this time. I hope I have so= me > times during the next weeks to implement a prototype, at least for > functions. > I believe I brought this up during the previous round of PCS discussion, but HHVM does this with its SystemLib already. In short (ignoring the per-extension systemlibs for the moment), all the files named in hphp/system/php.txt* are bundled into a single file at compile time and that file is dropped into a .text section in the binary. Then on startup, that section is inspected and fed to the compiler. There's implementations in HHVM for doing this on Linux, Mac, and Windows. I can't say for sure that all of PHP's supported OSs have a solution available, but the big three certainly do. -Sara * The files to be included are explicitly named in order to guarantee load order and optimal hoistability. This enumeration may or may not be necessary based on how PHP's binds symbols. ** HHVM places some restrictions on what goes into a systemlib file. 1. No side-effects/psuedo-main. This is probably already a requirement of PCS, just pointing it out. 2. Files either need namespace blocks (with curly braces), or an implicit empty namespace will be applied to them. 3. No file-level namespaces or declare statements.