Skip to content

feat(core): align AOT and eval Core builtin support - #893

Draft
nahime0 wants to merge 118 commits into
mainfrom
feat/core-align
Draft

feat(core): align AOT and eval Core builtin support#893
nahime0 wants to merge 118 commits into
mainfrom
feat/core-align

Conversation

@nahime0

@nahime0 nahime0 commented Sep 4, 2026

Copy link
Copy Markdown
Member

Summary

Aligns the Core builtin contract and its AOT and Magician implementations, including the callable, ownership, and runtime-state regressions found during review. Rebased onto main at 217ff6caa without merging the PR.

The internal Core inventory is 59/59 on both backends. This is not a claim of complete PHP compatibility: the generated PHP 8.5 comparison is 57/62 functions. The inventory excludes clone, get_error_handler(), and get_exception_handler(); the comparison counts die and exit separately as language constructs.

Changes

  • Shared contracts, typed EIR lowering, and target-aware runtime support for Core introspection, handlers, and GC controls.
  • Class introspection through direct calls, statically selected CUF/CUFA, FCC, named arguments, and spread arguments. Mixed array extraction no longer corrupts later object introspection.
  • Shared resource identity and ownership, last-owner retirement, explicit-close propagation, descriptor-reuse protection, and preservation of standard streams during web request reset.
  • Error-handler suspension and exception-safe restoration, ordinary-warning dispatch, reporting masks, nullable error_reporting() queries, and unhandled user-error termination.
  • Native visibility of declarations from the current eval context, shared resource inventory, array-valued constant snapshots, and thin-eval catalog constants including PHP_INT_SIZE.
  • Reflection fixes for protected visibility, trait properties, declaration order, and enum method spelling.
  • Backtrace composition across native and eval boundaries, preserving eval markers, options, and limits.
  • Integration with main's PCNTL callback lifetime, argument planning, and distinct eval status codes.
  • Focused regression tests, examples, and regenerated builtin documentation.

Deliberate bounds

  • 59/59 measures implemented contract entries, not unrestricted PHP semantics. Class-introspection callable targets remain subject to the documented static-target limits.
  • Native constant/function inventories append declarations from the current function's eval context; this is not a new process-global registry across unrelated eval contexts.
  • Resource inventory visibility is shared, but eval fclose() still operates on eval-managed streams. Synchronizing native locals into eval also retains them until the next synchronization or context release.
  • Constant categories use the documented Core/user grouping. disable_functions is unsupported, so get_defined_functions() accepts the flag without changing the inventory.
  • get_required_files() remains PHP's alias of get_included_files().
  • GC compatibility fields such as threshold, buffer_size, and full do not claim Zend collector-buffer parity.

Validation

Before local testing was stopped at the user's request, all 69 Core codegen tests and 23 shared-contract tests passed after the rebase. Focused checks also passed for the Core/PCNTL context ownership interaction, distinct eval status codes, five-target bridge exports, SysV runtime call alignment, and target-aware E_ALL. The remaining PCNTL executable checks were interrupted rather than reported as passed. No complete local suite was run.

Generated documentation and builtin-to-EIR boundary audits passed against the combined contract. The PR CI supplies the complete executable target matrix and iOS compile/emitter checks; the user is monitoring that run. No merge is performed by this work.

@greptile-apps

greptile-apps Bot commented Sep 4, 2026

Copy link
Copy Markdown

Too many files changed for review (2167 files, 100 file limit).

@github-actions github-actions Bot added area:builtins Touches PHP builtin declarations or emitters. area:codegen Touches target-aware assembly or backend lowering. area:magician Touches eval, include execution, or elephc-magician. scope:multi-area Touches more compiler areas than the automatic area-label cap. size:xl Very large pull request that needs deliberate review planning. target:linux-x86_64 Contains behavior specific to the Linux x86_64 target. type:feature Introduces new user-visible behavior or capabilities. area:web Touches --web mode, its prelude, or elephc-web. and removed area:codegen Touches target-aware assembly or backend lowering. labels Sep 4, 2026
@nahime0
nahime0 requested review from Guikingone and removed request for Guikingone September 7, 2026 09:45
@nahime0

nahime0 commented Sep 7, 2026

Copy link
Copy Markdown
Member Author

Sorry @Guikingone, I've found some issues and must postpone your review on this one

@nahime0
nahime0 marked this pull request as draft September 7, 2026 10:10
@nahime0 nahime0 changed the title feat(core): complete AOT and eval builtin parity feat(core): align AOT and eval Core builtin support Sep 7, 2026
Keep error masks, handler descriptors, and class ids out of x9 when symbol helpers use it as address scratch.\n\nRoute conditional exception fallbacks through local labels so Darwin assemblers can link the external report helper.
Lower generated array_slice tails directly to typed EIR so variadic callees receive the element representation declared by their signature.
Keep returned cells alive when dynamic functions, closures, or methods return storage owned by a persistent static local.
Free resource inventory nodes during normal process teardown and Web request reset, clear the list, and restore the request-local resource id counter.
Remove the legacy Web prelude declaration now that trigger_error is supplied by the common Core builtin registry.
Update catalog counts, callback metadata, stream-context expectations, and the SysV analyzer inventory for the completed Core surface.
Route Web prelude warnings through a private formatter before the shared Core trigger_error builtin so session diagnostics keep their PHP category prefixes without redeclaring the public builtin.
Route Magician GC operations through platform-mangled eval bridge wrappers so Mach-O links Rust references to the internal runtime helpers correctly.
Make trigger_error accept only PHP user levels, emit located default diagnostics, and preserve fatal E_USER_ERROR semantics across AOT and eval. Resolve the default set_error_handler mask from the selected PHP profile and keep internal web diagnostics off the public trigger_error path.
@github-actions github-actions Bot added area:runtime Touches runtime helpers, GC, ownership, or bridge runtimes. and removed area:builtins Touches PHP builtin declarations or emitters. labels Sep 8, 2026
@github-actions github-actions Bot added area:codegen Touches target-aware assembly or backend lowering. and removed area:runtime Touches runtime helpers, GC, ownership, or bridge runtimes. labels Sep 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:codegen Touches target-aware assembly or backend lowering. area:magician Touches eval, include execution, or elephc-magician. area:web Touches --web mode, its prelude, or elephc-web. scope:multi-area Touches more compiler areas than the automatic area-label cap. size:xl Very large pull request that needs deliberate review planning. target:linux-x86_64 Contains behavior specific to the Linux x86_64 target. type:feature Introduces new user-visible behavior or capabilities.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant