Repository navigation
Merged
Conversation
…(switch: ... endswitch;)
…n_compare(PHP_VERSION, ...), lower $GLOBALS[$name] with a computed name
…stead of failing when compensation cannot settle it or a scope reader meets a mismatch
…e globals table from global bindings, not the $GLOBALS view
… LLVM symbols and for synthesized helper names; Sig uses it
…re; repro for native callable identity (#615)
…(hash, date, spl, filter, iconv, random, reflection, sockets, curl, simplexml, libxml, zlib, pdo)
…utable_from_format()
…s a cell (null boxed), and a global filled only by unshaped element stores is an array of cells, not int
…is required, not at startup
…rs whether its file has run
…ction_exists() sees whether it ran
…cell; repro for an unassigned global reading 0 (#630)
…ds and constant compares
blacktrs
added a commit
that referenced
this pull request
Nov 12, 2026
…lution (#655) * Parser: parenthesized break/continue level, instanceof Name::$prop, ranges start at a receiver's '(' break(1); / continue((2)); parse as php does; `$x instanceof self::$prop` (and `[...]` subscripts) names the class by a static property's value, sharing new's new_variable parser. In ranges mode a postfix or binary node on a parenthesised operand starts at the '('. Fixes #618 Fixes #619 Fixes #505 * #[\Override] accepts a method implementing an abstract method of a used trait php counts an abstract method of a trait the class uses (directly or via trait-uses-trait) as overridden; a concrete trait method still is not. Fixes #617 * static::$p = v in a parent that does not declare $p lowers to php's run-time Error The parent-scope body is reached only by a direct call, where php throws "Access to undeclared static property C::$p"; the subclass-scope bodies keep their slots. The read of the same name said "Undefined constant C::$p"; both now share one helper with php's wording. Fixes #620 * Declaration guards fold class constants of declared classes `if (Logger::API >= 3) { trait Compat … } else { trait Compat … }` (sentry's Monolog compat traits) folds like a global constant guard. Fixes #621 * build: refuse "stdlib": false on an application that does not embed the runtime source The codegen calls runtime helpers (__mc_dtoa_core, …) directly, so such an app failed in clang with an undefined IR value. The option exists for the compiler, which compiles src/Runtime itself. Fixes #506 * xfail: drop the #407 repro (closed: not reproducible in AOT), link the #606 repro to its issue * DateTime::createFromFormat: Z offsets, escaped literals, microseconds, and the parsed or given zone P/O/p read 'Z' as UTC; an escaped format char must match the input. The object keeps the microseconds, takes the zone written in the string (or +00:00 for an epoch) and otherwise reads the fields as wall-clock time in $timezone or the default zone — it used to treat them as UTC and force +00:00. One helper serves DateTime and DateTimeImmutable. Fixes #572 * Builtin name sets back in sync: runtime function_exists, get_defined_functions, analyzer prelude Analyze\Builtins (which seeds the runtime function_exists table and get_defined_functions) missed 61 dispatch names, so a runtime-name function_exists('stripos') / ('gc_enable') answered false. The emitter-inline list gains the 8 names whose literal answer leaned on a stdlib body. The analyzer now indexes the 16 intl prelude files. calibrate.sh no longer reads "runtime\\libc\\strlen" or $name === $target as dispatch names and skips the *_off.php driver stand-ins. Fixes #646 * xfail: class_alias() name unusable for new/instanceof/static calls (#653) * Library .sig exports class constants again releaseAllClassMetadata (front-end memory trim) emptied every ClassDecl's consts before the export fold and the .sig writer read them, so an app importing a library class saw "Undefined constant Acme\\Point::NAME". Exported types (Module::typeDecls, library builds only) keep their metadata. libclass_smoke.sh looked for the pre-#631 method symbol spelling. Fixes #632 * Convert an int to float where the declared type admits float but not int Weak-mode php turns an int landing in a ?float / float|string slot into a float; such a slot is a cell and kept the int tag. Params convert in a callee-side prologue (direct, dynamic, default, by-ref, ?float variadic), returns through the declared hint (functions, methods, closures, arrow fns, get hooks), instance and static property stores, and a float variadic pack built from int args. Fixes #553 Fixes #554 Fixes #490 * Bind call arguments like php across spread, variadic, static and callable paths - Spread arrays: the positional run is the int-keyed prefix (__mir_array_pos_prefix); a string key naming no parameter goes to the variadic under its key, or throws "Unknown named parameter" / "Cannot use positional argument after named argument"; mixed-key literals count as keyed. The fixed+variadic split moves from lowering (positional array_slice) to the emitter, and a spread no longer refines the callee's params from the pack's array type. - func_get_args() sees spread arguments: argc and overflow come from the pack at run time. - ArgumentCountError names Class::method, not Class::::method. - $obj() on a variadic __invoke packs its arguments. - A variadic arm of an erased receiver packs the written arguments when lowering could not name the method. - A static method reached through an object ($o->m(...), [$o, 'm'], erased receiver) gets no $this; ResolveMethodFcc forwards every param of a static target. - A function-name string in a `callable` slot stays tagged, so the invoke resolves it by name instead of jumping to it as a closure. Fixes #571 Fixes #573 Fixes #574 Fixes #583 Fixes #593 Fixes #595 Fixes #596 Fixes #650 * Fold case in runtime class-name lookup, name the missing class in constant(), mark internal return types tentative in reflection Fixes #603 Fixes #604 Fixes #563 * Resolve runtime class names through the registry: get_parent_class, is_a, enum interfaces, Generator; type errors for array props and string args get_parent_class answers for runtime names and built-in classes, is_a folds case, UnitEnum/BackedEnum match enum cases, get_class names a Generator in a mixed slot, ReflectionMethod::invoke of __construct runs on the given object, a scalar stored into an array property and an array/object passed to a stdlib string parameter by runtime name throw TypeError. Fixes #332 Fixes #578 Fixes #579 Fixes #584 Fixes #588 Fixes #570 * Throw when a plain read of an unset typed property goes through an erased receiver Fixes #594 * Array-property type check no longer leaks every stored value The #579 check wrapped the value in a __mir_assert_array_prop call that retained it and was listed as owned, so every store into an `array` property leaked one reference (mysqli stmt_procedural LEAK on CI). Classed as a borrow it freed the argument temp before the store retained it. The check now goes through a temp local (is_scalar / is_null -> TypeError, else the local), the shape the int->float coercion uses, and the builtin is gone.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #622, Fixes #623, Fixes #624, Fixes #625
Why
First step toward compiling WordPress (7.1.4) into a native binary. Building the core front end (
index.php→wp-settings.php→wp-includes,wp-content) hit a series of gaps in the parser, lowering, type inference and include semantics. This PR closes the ones that block the build and the early request path, each with its own AOT case.Where WordPress stands with this PR
wp.binbuilds (≈5 min with-j 0, 232 MB); manifest:src: ["."], entryindex.php,wp-adminand SimplePie excluded for now.wp-config.php(no database) the binary prints the "Error establishing a database connection" page byte-identical to php.default-filters.phpand stops increate_initial_taxonomies()— the next item, not in this PR.What changes
Parser
var $xis a property modifier (it was parsed as a type namedvar).switch (…): … endswitch;syntax.Declarations and lowering
\true/\false/\nullfold in declaration guards like the bare literals (A class declared under if (\false) fails to lower, while if (false) compiles: "unsupported statement kind Class". #625).if, or inside a function body, is hoisted to the top level (one declaration per name; two behind an unfoldable guard is a clear compile error).version_compare(PHP_VERSION, …)folds at compile time.$GLOBALS[$name]with a computed name (read / write / isset / unset) through a generated by-name table.$obj::$prop = v/$cls::$prop = v.compact($names)with runtime names.MIR.verify.class_exists()is dropped (sodium_compat'sSplFixedArray).@param callableno longer narrows the parameter to a closure (it tookadd_filter()'s string callbacks for env pointers).Include semantics (what WordPress expects from php)
define()calls: they run when the file is required, not at startup (xmlrpc.php'sdefine('XMLRPC_REQUEST', true)madewp_die()answer in XML).function_exists()of a function declared in a not-yet-required file answers false; files of function declarations alone become lazy units for that.foreachloop variable that is a global writes through the global's cell.References, types, ownership
$l10n[$domain] = &$noop): the static's slot is a cell; a global filled only by unshaped element stores is an array of cells, notint.$GLOBALS-viewed global can be stored.compact/extract) meets a representation mismatch, instead of failing the build.Symbols
Compile\SymbolName):\mangles to., synthesized helper names use an injective escape.A\B_CandA_B\Cno longer collide (sodium_compat ships both spellings of several classes).Siguses the same function.Stdlib
extension_loaded()answers true for every linked extension (hash,date,spl,curl,zlib, …); WordPress refuses to boot withouthash.INI_*constants,DateTimeZonegroup constants,date_create_immutable_from_format().Bugs filed on the way (repro in
tests/aot/repro, XFAIL)$this->data = &$this->data['child'][$k][];) is refused at emit. #613 property bound by reference to a nested appended element is refused at emitcallableparameter is wrapped in a Closure, so is_string() on it answers false. #615 a string passed to a nativecallableparameter loses its identity (is_string()false)global $kbefore anything assigns it reads 0 instead of NULL. #630 a global read before it is assigned reads 0 instead of NULLNot in this PR
ext/xml(0/22) — needed by SimplePie and XML-RPC.wp-admin/includes/class-ftp.php) — needed to bringwp-adminback into the build.wp-config.phpfrom environment variables.Testing
tests/libs/lazy_units(tools/liblazyunits_smoke.sh).static,ref_,global,superglobal,foreach,reflect,namespace,attribute,callable,lib,datetime,extension_loaded;tests/parser/run.shgreen.\→.) and declaration-only files becoming lazy units.