Repository navigation
perf(jit): lower every string relation through one content compare - #315
Merged
Merged
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
STRING_EQ and STRING_NE lowered natively while STRING_LT, GT, LE and GE bridged, although all six are one byte-wise content comparison. One stringCompare now leaves the flags of left against right (the first differing word, byte-reversed, or byte; else the lengths) and each relation reads them with its unsigned condition, fused into a branch when one follows. Equality still leaves early on unequal lengths. Also state the string units in instruction-set.md (string.len is the UTF-8 byte length; new/encode_utf32 use code points; ordering is unsigned byte-wise), and drop a generator branch for a KindAny CONST_GET that called a removed intern method and never generated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
siyul-park
force-pushed
the
perf/jit-string-compare
branch
from
November 10, 2026 03:41
21203bd to
0cf7017
Compare
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.
Summary
Part B of the string review (plan: one model, standard pieces). Strings stay what they are: an immutable Go string per heap ref, compared by content, with append-only concat storage and constants deduplicated at load. There is no interning and no rope. This PR removes the inconsistencies the review found:
STRING_EQ/NElowered natively, butLT/GT/LE/GEbridged, although all six are one byte-wise content comparison.stringComparereplacesstringEqand leaves the flags of left against right:Each relation reads the flags with its unsigned condition (
EQ/NE/LO/HI/LS/HS) throughm.set, so a following branch fuses on the flags. Equality still leaves early on unequal lengths. Every path intooutarrives straight after itsCMP, andCBZkeeps the flags. Only loads, so no Go pointer is written.instruction-set.md:string.lenis the UTF-8 byte length;string.new_utf32/encode_utf32use code points; ordering is unsigned byte-wise. Threaded already behaves this way; it was just undocumented.KindAnyCONST_GET,internal/codegen/slot.goemittedi.intern(...), a method that no longer exists.make generateleavesthreaded.gounchanged, so the branch never generated.Evidence
TestMachine_Lower: six relation rows. Red before the change (expected len=56 actual len=52).TestWithThreshold"compares strings and refs natively": all six relations over 14 new pairs, with results equal to threaded. The pairs cover:"é"vs"z"and high bytes within a word;Red before: the ordering relations never went native.
LT–GE, with zero bridges. Red before: 47 bridges.STRING_LTas their "unlowered op" and now useSTRING_CONCAT. They are not weakened.go test ./interp ./internal/...,make generate && make check-generated(no diff),make checkandgit diff --check: pass.Rejected along the way
Part A, a deferred-release buffer that removed
ExitRelease(2557 exits per Run on string-build), removed every release exit but measured string-build +3%. It also delayed hostCloseside effects, so it was dropped. Exit counts were not the cost.🤖 Generated with Claude Code