ReviewOS

zig-utils/zig-js

Intl: reclaim DurationFormat part-group scratch after flattening

#639
Closed chris opened this 9 days ago ·
9 days ago

Problem

Intl.DurationFormat.prototype.formatToParts builds an outer list of part groups plus one nested ArrayList<DurPart> per displayed group through the realm arena. After it copies every part into JavaScript result objects, none of those list buffers are needed, but they remain retained until Context teardown.

After #638 removes the preceding RelativeTimeFormat byte-run retention, the exact 4 MiB structural-parts witness reaches this next boundary and fails at grp.append(self.arena, ...). This is invocation metadata, not result ownership.

Required implementation

  • Allocate the outer group list and every nested part list through the interpreter scratch allocator.
  • Deinitialize all nested lists and the outer list on success and every error path after their contents have been flattened or abandoned.
  • Preserve DurationFormat grouping, digital separators, numbering translation, unit annotations, and result object ownership.
  • Do not raise the heap limit, move result strings into scratch, or special-case the witness.

Acceptance

  • The exact 4 MiB structural-parts witness passes normally and under TSan.
  • DurationFormat formatToParts semantics and Test262 subtree have no regressions.
  • Full exact unit shard 0 passes without leaks.

Parents: #475, #480 Related: #638, #637, #636

9 days ago

c69d4844 reclaims DurationFormat group arrays, combined-fraction storage, digit translation, and nested NumberFormat parts after managed result materialization. DurationFormat units pass 3/3 normal and TSan; Test262 DurationFormat remains 110 pass, 0 fail. Fresh Linux CI is pending.

9 days ago

Closing with fresh Linux run 32388315489: the unchanged bounded Intl structural-parts witness passed in unit shard 0 and TSan unit shard 0, with zero failures/leaks in both shards. DurationFormat Test262 remained 110/110 (0 flips).

Sign in to comment on this issue.