Skip to content

perf: mixed concat, MLIR strcat, parse_float and UTF-8 policy (#747) - #1356

Closed
godofecht wants to merge 2 commits into
mainfrom
cursor/string-io-remaining-747-2b26
Closed

godofecht wants to merge 2 commits into
mainfrom
cursor/string-io-remaining-747-2b26

Conversation

@godofecht

Copy link
Copy Markdown
Contributor

Part of #747.

Intent

Linked issue or roadmap item: #747 (remaining gaps after merged #1337).

What changed, and why is this the smallest useful change?

The first slice joined pure-string + chains and added integer parse/format plus buffered I/O. This slice finishes the five leftover implementation gaps: mixed numeric concatenation, MLIR strcat lowering, a fast parse_float, an explicit UTF-8 policy, and allocation counters on the harness rows.

Overlap check

  • I searched open pull requests and recent commits for overlapping work.
  • This does not duplicate another active implementation, or the relationship is explained below.

Overlap / dependency notes: No open PR implements the remaining #747 gaps. Nearby open PRs (#1348, #1346, #1345, #1265, #1267, #1268) touch other issues or the harness, not concat lowering, parse_float, or the UTF-8 policy.

Evidence

Baseline before this change: mixed "x=" + n + " y=" + m used nested pairwise __flowc_str_concat; MLIR lowered every string + to __flow_str_concat; no parse_float; UTF-8 was bytes-as-stored with no documented policy; the new harness rows printed no allocations: / copies: lines.

Targeted proof that exercises the changed behaviour:

  • tests/cgen/string_concat_mixed (C must contain __flowc_str_concatn(4, and must not nest pairwise joins)
  • tests/lang/test_parse_float.flow, tests/lang/test_utf8_policy.flow, extended test_string_concat_chain
  • compiler/scripts/roundtrip.flow stage_a_strcat mixed-concatn check

Why that proof would detect the old failure or regression: the mixed golden fails on nested __flowc_str_concat(__flowc_str_concat("n="; parse tests fail if junk/hex/overflow is accepted or 1.5 is wrong; UTF-8 tests fail if overlong/surrogate/truncated sequences are accepted or io_read_text treats invalid bytes as success.

Repository gate(s) run: pending on this revision (host selftest, cgen goldens, ./flow test-lang subset, gen_stdlib_docs --check, harness). Bootstrap C not yet regenerated.

Generated/bootstrap state, if any: docs/library/stdlib-api.md regenerated. Bootstrap C regeneration is a follow-up commit after the edited compiler selftests.

Risk

Compatibility, performance, security, lifetime, backend, or release implications:

  • C and MLIR backends now flatten mixed chains. __flowc_str_of_* results remain heap strings that stay live until concatn copies them.
  • Concat results are still process-lifetime (malloc, never freed).
  • New stdlib functions are additive. Hex floats are rejected (stricter than Python float()).
  • No unresolved language/API design decision is being implemented implicitly. The UTF-8 policy is documented in docs/library/strings.md (fail closed, no silent replace).
  • No unrelated generated artifacts or local state are included.
  • Docs changed when user-visible behaviour or syntax changed.
  • docs/project/Questions.md not required; the policy is explicit rather than an open design question.

Compatibility

  • No user-visible compatibility change.
  • Additive stdlib/docs recorded in docs/project/CHANGELOG.md.

Remaining gaps (not this PR)

Issue acceptance is therefore not fully closed.

Agent handoff

Bootstrap C will be committed separately (fix: regenerate bootstrap C after mixed concat and MLIR strcat). Do not merge.

Open in Web Open in Cursor 

Finish the remaining #747 gaps after the first slice: flatten mixed
numeric + chains to one concatn, lower n-way string + in MLIR as one
malloc plus per-part memcpy, add a linear parse_float and fail-closed
UTF-8 helpers, and print allocation/copy counters on the harness rows.

Co-authored-by: Abhishek Shivakumar <[email protected]>
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: godofecht <[email protected]>
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.

2 participants