Skip to content

AOT: string assignment uses addref instead of eager memcpy (#36192) - #36279

Merged
PurHur merged 1 commit into
masterfrom
agent/issue-36192-string-copy-on-write
Sep 2, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/issue-36192-string-copy-on-write

Conversation

@PurHur

@PurHur PurHur commented Sep 2, 2026

Copy link
Copy Markdown
Owner

Summary

  • Value-box string copies ($u = $s, boxing native strings, coerceToValuePtrForStore) now call __ref__addref instead of __string__separate (Zend zend_string_copy semantics).
  • __string__separate remains for mutation / hashtable-key ownership paths.
  • Adds AOT fixture + unit lint test + perf repro script.

Verify

./script/phpunit.sh --filter 'StringCopyOnWriteAotTest|aot_string_copy_addref_36192'
# OK (2 tests, 8 assertions)

./script/aot-smoke.sh
# aot-smoke: 9 passed, 0 failed

make dev-verify-fast
# dev-verify-fast: OK (99s wall)

make north-star5-verify-fast
# north-star5-verify: OK (fast)

# Perf repro (1 MB string × 20k aliasing assigns):
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/compile.php -o /tmp/s test/repro/string_copy_addref_36192.php && time /tmp/s'
# AOT: 0.004s (was 0.754s on master); Zend: 0.010s; output 20971520000

Closes #36192

Made with Cursor

Value-box string copies now share refcounted __string__ like Zend
zend_string_copy, fixing O(n) memcpy on every $u = $s assignment.
Mutation paths still use __string__separate / __ref__separate for writes.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur merged commit e589a2e into master Sep 2, 2026
1 check failed
@PurHur
PurHur deleted the agent/issue-36192-string-copy-on-write branch September 2, 2026 03:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant