Skip to content

Add JIT/AOT for fopen, fread, and fclose (#1117)#1141

Merged
PurHur merged 1 commit into
masterfrom
fix/1117-fopen-fread-fclose-jit
May 23, 2026
Merged

Add JIT/AOT for fopen, fread, and fclose (#1117)#1141
PurHur merged 1 commit into
masterfrom
fix/1117-fopen-fread-fclose-jit

Conversation

@PurHur
Copy link
Copy Markdown
Owner

@PurHur PurHur commented May 23, 2026

Summary

  • Add __compiler_fopen, __compiler_fread, and __compiler_fclose runtime helpers in phpc_stream.c and register them for LLVM JIT/AOT.
  • Add JitFopen, JitFread, and JitFclose lowering helpers; wire fopen/fread/fclose stdlib builtins to use them.
  • Fix resource-typed locals receiving fopen() handles: keep long/bool handles in __value__ boxes instead of calling __value__readObject.
  • Add compliance PHPT fopen_fread_fclose_jit.phpt and list fopen/fread/fclose as required self-host filesystem builtins.

Test plan

  • fopen_fread_fclose_jit.phpt path via bin/jit.php and bin/compile.php (Docker, tar pipe)
  • SelfHostBuiltinPolicyTest::testRequiredBundleCategories
  • Full JITTest suite (harness LLVM/env; targeted stream tests pass)

Closes #1117

Made with Cursor

Expose __compiler_fopen, __compiler_fread, and __compiler_fclose in phpc_stream.c
with LLVM lowering helpers. Keep stream handles in __value__ boxes when assigning
fopen() results to resource-typed locals so fread/fclose read the native handle.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stdlib: JIT fopen/fread/fclose for stream I/O

1 participant