Implement compatibility for PHP 7.x#1
Merged
Merged
Conversation
Member
Author
|
I'll change method chain to |
Member
Author
|
And write |
Member
Author
|
I merge this PR. |
hbtweb
added a commit
to hbtweb/php-java
that referenced
this pull request
May 3, 2026
Lifts the "non-empty abstract stack at BB boundary" restriction in the IR Builder. Previously threw on any BB-end with stack residue (typical javac shapes: ternary-store, short-circuit &&/||, anything that leaves a value on the stack across a branch). Now spills residual abstract-stack entries into synthetic local slots at branch sources (goto/condgoto/ifPop/implicit-fallthrough); target BBs reload from those slots at entry. JVM verifier guarantees all predecessors of a merge point deliver the same stack-shape, so per- target-PC slot allocation works. New helpers in Builder: bbEntrySlots[targetPc] map, nextSyntheticSlot counter, allocOrReuseSlots / spillStackToSlot / spillStackForBoth / reloadStackFromSlots. Method.maxLocals widened to include synthetic slots. Real-library probe: 86.5% β 99.3% IR coverage on commons-lang3 (485-fallback drop from this single change). The originally-estimated 1.5x perf headroom is dwarfed by the actual coverage impact.
hbtweb
added a commit
to hbtweb/php-java
that referenced
this pull request
May 3, 2026
Final state docs after the 2026-05-03 work plan landed.
ROADMAP.md:
- Sub-step 1c-Ξ² note updated with the empirical coverage finding
(95% of remaining fallbacks; perf vs coverage impact distinct)
- New sub-step entries: 1c-Ξ΅ (switch terminator), 1c-ΞΆ (rare-opcode
tail)
- Work-plan section enumerating items php-java#1βphp-java#10 in order, with php-java#10
(remove dead string-path) explicitly DEFERRED β needs rank-1
evidence on more than one JAR before subtracting 1500-line
fallback.
STATUS.md:
- Real-library probe section: 6-row series table showing
progression 65.6% β 86.5% β 99.3% β 99.9% β 99.9% β 100.0%.
- Architectural verdict: design holds against production
bytecode; sub-step 1c-Ξ² was the load-bearing lever.
bench/probe-real-library.md:
- TL;DR updated to the 6-row series view + final 100.0% reading.
hbtweb
added a commit
to hbtweb/php-java
that referenced
this pull request
May 3, 2026
The architectural piece. Before: AOT hardcoded `isStatic: true` for
all methods (Builder.php:283, Compiler.php:1046). After: read
MethodInfo.ACC_STATIC; emit instance methods as `public function`
with $L[0] = $this; emit static methods as `public static function`.
Threading: Compiler::compileFromGenericClass classifies each method,
passes $isStatic to tryBuildIrMethod and compileMethod. Builder::
buildMethod and Compiler::compileMethod accept $isStatic; widen
maxLocals to include the implicit `$this` slot for instance methods;
Lowerer prelude seeds `$L = [$this, $__a0, ...]` for non-static.
<init> emit: previously skipped at compileFromGenericClass:242. Now
emitted as `__construct` (the existing mangleMethod already maps
<init>β__construct). super(...).<init>() calls into JDK abstract
bases (Object/Record/Number/Enum/Throwable/Exception/RuntimeException/
Error) emit as no-op via isAbstractBaseInit guard β no PHP shim
needed for those, since PHP's `new \Class()` doesn't chain.
Inner-class FQN bug fix: classFqn for non-JDK classes now strips `$`
matching Compiler::mangle. `BenchRecord$Point` was producing a
literal `\PHPJava\Aot\Generated\BenchRecord$Point` reference, parsing
as PHP variable interpolation; now `BenchRecord_Point` consistent
with the class declaration.
End-to-end record validation: bench/aot-record.php runs Java records
(BenchRecord$Point) through the full AOT pipeline:
- Point.<init> as instance __construct
- Point.equals/hashCode/toString as instance methods routing through
the ObjectMethods bootstrap emit (commit 1aada77)
- super(java/lang/Record).<init>() elided
All 4 record tests PASS:
eqSame: 1 β eqDiff: 0 β hashCodeOk: 1 β toStr: 'Point[x=3, y=5]' β
Real-library probe: 100% IR coverage on 4983 methods of commons-lang3
(up from 4197 β instance methods + __construct previously hidden by
the probe's static-only regex; fixed in the same commit).
Snapshot baseline updated β every fixture grew by ~135 bytes for
the now-emitted __construct body.
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.
This pull request implement compatibility for PHP 7.x.
And I'm doing refactoring directories, variables and any more.
This pull request implementation is following:
array()to bracket[and]