Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108136 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 33610 invoked from network); 15 Jan 2020 03:50:43 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 15 Jan 2020 03:50:43 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 3928F1804CF for ; Tue, 14 Jan 2020 17:57:42 -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.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-yb1-f170.google.com (mail-yb1-f170.google.com [209.85.219.170]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 14 Jan 2020 17:57:41 -0800 (PST) Received: by mail-yb1-f170.google.com with SMTP id z15so2260776ybm.8 for ; Tue, 14 Jan 2020 17:57:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=newclarity-net.20150623.gappssmtp.com; s=20150623; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=rIAWTwy2rWAA3A1mZV7C8STSGFVghvfbTN7md4ocV/U=; b=kP3Sj5VxOc5mCRq4uzwD0s9fYqsuujNxBlX2dpTxWDiQQ5CQ2zOZ42q6H0RngMa+O1 8XIoVXrLPMr2Y8nGzsxT29kTvSlZ9lhMylXJMthgvNqx0fnDQ1VEVeVSNUFDtFlzhLo9 FmBVifEM19k12LfXOZ+97ohjfFk6Po4sR6+9JZXVppjnDpGYHzJA0gC14dGO+PijQ0rF aeOx42Tne/GclBliid4nmKO5Q0T+Clwm6jI3VAVryW7CSJNPu86iQ8L1mSLf1uSt1+Hj OyJhgPxWPtKehFAOU9MEWvZ23/UHvb6WQB3ss4gnE0tZdeS64r1Eemr4p9QHZKmf0EKJ uF3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=rIAWTwy2rWAA3A1mZV7C8STSGFVghvfbTN7md4ocV/U=; b=NF++GKa/Q3BAcOBArP01gM/jNgTFlJiUZj4449YSYQT99EE3VVkzkgdqsQnh4XReJg 0E+157UTUCf9xMKPYRJcLBH4qglXca2eEyFD8OyFGoJ7AGqS7TQZNoEhrOWHiYoIg40B 0WveljNPx36BG6tq1cVaPZfNhYIX3yb1CVg2OgtIEgiBWP3uYMxIjaX9GmURvg0c5G69 KkY+IfqB9LevKtsg5JPGWZg3EL3JR6pFN1Mj1CcP/vTzCV6bBnxPmg/raR+JkVVmR3MD LpM5XZQUVgDlyAWRaYv55/PJ7B3IwUn6MRX+OpzegSMjeEgERolonP8X7lIEUX5Ye2gK 4M5A== X-Gm-Message-State: APjAAAVe/0ielO2OHKS/pd4OxrIXd0nMjTAaWzXdFbiTZKwOpe/+2mzn VVjv6aDdSrB4nK+uEDsVbGboOBIlodwAkA== X-Google-Smtp-Source: APXvYqw2Q6xxqyHBiw0HSIvosgbskjwQGZW3ByMcKvteWqw217WtCDaKcahF6ibsrfxLWNLCszUxQg== X-Received: by 2002:a25:dc46:: with SMTP id y67mr20210023ybe.83.1579053459952; Tue, 14 Jan 2020 17:57:39 -0800 (PST) Received: from ?IPv6:2601:c0:c680:5cc0:80fe:57d:ecbc:e1c1? ([2601:c0:c680:5cc0:80fe:57d:ecbc:e1c1]) by smtp.gmail.com with ESMTPSA id g65sm7491895ywd.109.2020.01.14.17.57.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Jan 2020 17:57:39 -0800 (PST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) In-Reply-To: Date: Tue, 14 Jan 2020 20:57:38 -0500 Cc: php internals Content-Transfer-Encoding: quoted-printable Message-ID: <90DE6E75-813C-4372-A8B7-799ADF74CEDE@newclarity.net> References: <2502e68d-a1bc-41c6-9763-8c0e2ac9e6f4@www.fastmail.com> To: Larry Garfield X-Mailer: Apple Mail (2.3445.104.11) Subject: Re: [PHP-DEV] Introducing compile time code execution to PHP preloading From: mike@newclarity.net (Mike Schinkel) > On Jan 14, 2020, at 7:50 PM, Larry Garfield = wrote: > I think you're still missing my point here. AST manipulation during = preload would exist to manipulate code that would be run *later*. = That's the point. Sure, the code in the run_once/preload/whatever block = would be written to run in that context, but its entire point is, = presumably, to improve the running of the *rest* of the code later. And respectfully, I think I am not missing your point but that possibly = you are misunderstand what I was proposing. I was not proposing *any* AST manipulation, at least not for what I was = defining as "Userland Preloading." Unless you define AST manipulation = as using PHP to generate code to insert literals into OpCode, but if so = I think that would be disingenuous.) If you remember I said this thread had gotten to the point I am seeing = these separate issues that should probably be three separate threads, = which I will repeat here: 1. Userland preloading 2. Userland loadable extensions 3. Projection API and related None of the above manipulate the AST directly, although #3 would do so = indirectly. (There is an argument to be made that we could split #3 = into higher level APIs and lower level AST manipulation which, IMO, = should be two different debates, for a total of at least 4 different = debates here.) So again, when I am proposing userland preloading I am *not* as part of = that proposal proposing AST manipulation, although I believe Robert = Hickman may have been and maybe I should start a different thread? That is why I find it hard to believe that PHP would generate code that = would fail when PHP runs that code. > That... is a completely different thing, yes, that has nothing to do = with the PHP 7.4 feature called preloading. Which would mean we've been = talking about two different things this whole damned time. *sigh* Yes. And I will take the blame for that. It did not occur to me until = Robert mentioned to me that it was confusing. > No, the whole point of the FFI extension is that a user-land developer = can load a .so file into PHP directly; basically doing the lib->PHP glue = code in PHP rather than in C. It does require the FFI extension itself = to be enabled, and to do safely requires using the preloader, which does = mean setting an ini setting. Interesting. So then maybe what I an asking for is to bundle FFI into = core so that it is available everywhere. > Not all hosts support that. The one I work for does, which is why = I've been playing with it lately to document it all for our customers. = :-) But the fact that such advanced features are not universally = available is... exactly why I am extremely cautious about having = functionality that results in subtle behavioral differences between = those environments where it's available and those where it's not. Another interesting option would be to enable loading and running of = WebAssembly in core. Do you have a position on that? > The existing preload logic has no impact on behavior other than = skipping the autoloader. Any behavioral change is limited to those = oddball libraries that do black magic during the autoloader, which are = already well off the beaten path. That makes it a "safe" optimization. So basically, I think this is what I have been asking for, but userland = accessible. =20 I would envision that if it modified any environment, such as setting a = preloaded or error levels etc. then all that environment would reset = during normal execution. > My underlying point, and then I will bow out of this thread as I am = tired of repeating myself, is that I am all for enabling more "safe" = optimizations, even letting userland developers build them, but we need = to be extremely careful about them being "safe" and not "a time bomb = that will introduce subtle behavioral differences between different run = modes that a developer is not expecting,thus slowly creating libraries = that will only function in one run mode or the other". I appreciate and agree with the desire not to have unsafe issues. But as = I have felt we were talking about two different things and you confirmed = that, maybe what I have actually been proposing is not something we need = to be at odds about? -Mike=