Skip to content

Implement compatibility for PHP 7.x#1

Merged
m3m0r7 merged 96 commits into
masterfrom
php-java-2
Feb 27, 2019
Merged

Implement compatibility for PHP 7.x#1
m3m0r7 merged 96 commits into
masterfrom
php-java-2

Conversation

@m3m0r7
Copy link
Copy Markdown
Member

@m3m0r7 m3m0r7 commented Feb 22, 2019

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:

  • Add composer
  • Add namespace
  • Rename files and directories
  • Use autoload on composer
  • Use type
  • Replace array() to bracket [ and ]
  • Remove compatibility for PHP 5.x.
  • Optimize binary reader
  • Optimize binary tools (calculate hex, calculate unsigned values and so on)
  • Update coding rules to base on PSR-2
  • Optimize class structures.
  • Fix English grammar and words. (Sorry, I could not write/read English when I am younger :()
  • Handle to methods with variable size arguments.

@m3m0r7 m3m0r7 changed the title Update PHP Java Implement compatibility for PHP 7.x Feb 23, 2019
@m3m0r7
Copy link
Copy Markdown
Member Author

m3m0r7 commented Feb 26, 2019

I'll change method chain to get(Static|Dynamic)(Fields|Methods)() to get(Static|Dynamic)Accessor()->get(Fields|Methods)().

@m3m0r7
Copy link
Copy Markdown
Member Author

m3m0r7 commented Feb 26, 2019

And write PHP problems section in README

@m3m0r7
Copy link
Copy Markdown
Member Author

m3m0r7 commented Feb 27, 2019

I merge this PR.

@m3m0r7 m3m0r7 merged commit 32e2cf9 into master Feb 27, 2019
@m3m0r7 m3m0r7 deleted the php-java-2 branch February 27, 2019 06:37
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.
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.

1 participant