Skip to content

JIT: native lowering for typed function/method returns (#55) - #3231

Merged
PurHur merged 1 commit into
masterfrom
agent/issue-55-jit-return-types
May 30, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/issue-55-jit-return-types

Conversation

@PurHur

@PurHur PurHur commented May 29, 2026

Copy link
Copy Markdown
Owner

Summary

  • Complete JIT LLVM return lowering for v1 scalar/array return types (: string, : int, : bool, : float, : array, : ?T) on user functions and methods
  • Fix : array returns that materialize compile-time native arrays as __hashtable__* (LLVM verify was failing with struct vs pointer mismatch)
  • Add VM compliance PHPTs, AOT fixture, FunctionReturnTypeJitCompileTest (IR verify), and flip capability matrix JIT column to yes

php-src reference

  • Zend/zend_compile.czend_compile_return
  • Zend/zend_execute.cZEND_RETURN / ZEND_RETURN_VALUE
  • Zend/zend_type.c — return type validation

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
vendor/bin/phpunit --filter FunctionReturnTypeJitCompileTest
vendor/bin/phpunit --filter "VMTest::testCases.*function_return"
vendor/bin/phpunit --filter "AotTest::testCases.*function_return_string"
php bin/compile.php -o /tmp/ret-out /tmp/ret.php && /tmp/ret-out  # greet(): string fixture
'

Note: MCJIT execute (bin/jit.php repro) still segfaults in this harness for all scripts (#2055), independent of return types. IR generation + compileCommon() verify pass; AOT linked binary runs the return-type fixture successfully.

Closes #55

Made with Cursor

Add LLVM return coercion for float and native-array `: array` returns, compliance/AOT fixtures, and compile-verify tests. Update capability matrix to reflect JIT IR support (MCJIT execute still #2055).

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur merged commit 7a6ce7d into master May 30, 2026
@PurHur
PurHur deleted the agent/issue-55-jit-return-types branch May 30, 2026 05:07
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.

Language: JIT support for non-void function return types

1 participant