Skip to content

JIT: Self-host spine link — Struct::getElementType on __string__ pointer params #1880

Description

@PurHur

Problem

make bootstrap-selfhost-lib-spine-smoke / native link of compiler_lib_spine_smoke fails on harness when expanding real JIT lowering on string builtins:

Call to undefined method Struct::getElementType()

Stack points at generated code in lib/JIT/Builtin/Type/String_.php (e.g. strlen / __string__alloc paths) calling:

$string->typeOf()->getElementType()->getName()

on LLVM values whose typeOf() is already a pointer (__string__*), not a struct wrapper — getElementType() is invalid on Struct in PHPLLVM for that shape.

This blocks:

Goal

Spine bundle links under AOT with real String_ JIT lowering (no Struct::getElementType fatal).

Implementation hints

Area Files Approach
Root cause lib/JIT/Builtin/Type/String_.php Audit all typeOf()->getElementType() on params; use Context::getStringFromType() / struct name from pointer element type
Pattern lib/JIT/JitValueBox.php, lib/JIT/Context.php Existing helpers resolve __string__ / __value__ without double getElementType
Regression test/selfhost/compiler_lib_spine_smoke/ Must link in make bootstrap-selfhost-lib-spine-smoke
Policy lib/JIT/SelfHostBuiltinPolicy.php Keep stub until fix proven; then allowlist symbol batch

Repro (Docker)

make docker-build-22
docker run --rm -v "$(pwd):/compiler" -w /compiler php-compiler:22.04-dev \
  bash -lc 'make bootstrap-selfhost-lib-spine-smoke 2>&1 | tail -40'

Acceptance criteria

Dependencies

Verification (local / Docker only)

make bootstrap-selfhost-lib-spine-smoke
BOOTSTRAP_LIB_SPINE_VM_SMOKE=1 make bootstrap-selfhost-lib-spine-vm-smoke

No GitHub Actions.

Links

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions