Skip to content

Fix the x 1 idiv and x -1 exp simplifications in PSStackToTree - #22438

Merged
calixteman merged 1 commit into
mozilla:masterfrom
b84330808:fix-ps-idiv-exp-simplifications
Nov 7, 2026
Merged

calixteman merged 1 commit into
mozilla:masterfrom
b84330808:fix-ps-idiv-exp-simplifications

Conversation

@b84330808

Copy link
Copy Markdown
Contributor

Two algebraic simplifications in PSStackToTree change the result, so the Wasm and JS compilers disagree with the interpreter:

  • x 1 idiv was simplified to x. With a non-integer input, { 1 idiv } returned 7.5 from the compilers and 7 from the interpreter. It's now simplified to truncate(x).
  • x -1 exp was rewritten as 1 x div. For x = 0 that gives 0, since a division by zero returns 0, whereas exp gives Infinity, which is then clipped to the range. The rewrite is removed.

The existing tests only used integer inputs or asserted the old tree shape, so they're updated, and new cases run both operators with the inputs above.

`x 1 idiv` was simplified to `x`, so the Wasm and JS compilers returned a
non-integer x unchanged (e.g. 7.5), whereas the interpreter truncates it
(7). It's now simplified to `truncate(x)`.

`x -1 exp` was rewritten as `1 x div`, which gives 0 for x = 0 since a
division by zero returns 0, whereas the interpreter computes Infinity,
which is then clipped to the range. This rewrite is removed.
@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Viewer preview

🗑️ Viewer previews removed.

@codecov-commenter

codecov-commenter commented Nov 6, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.53%. Comparing base (56ba3ff) to head (3a326e3).
⚠️ Report is 38 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #22438   +/-   ##
=======================================
  Coverage   90.52%   90.53%           
=======================================
  Files         276      276           
  Lines       68551    68549    -2     
=======================================
  Hits        62059    62059           
+ Misses       6492     6490    -2     
Flag Coverage Δ
fonttest 9.10% <ø> (ø)
unittest 62.78% <100.00%> (-0.01%) ⬇️
unittestcli 60.38% <100.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@codspeed

codspeed Bot commented Nov 6, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 11.73%

⚡ 2 improved benchmarks
✅ 86 untouched benchmarks
⏩ 174 skipped benchmarks1

Performance Changes

Benchmark BASE HEAD Efficiency
⚡ Autolinker.processLinks: 10 links in each of 1000 text items 67.5 ms 59.7 ms +13.1%
⚡ Autolinker.processLinks: 2 links in each of 5000 text items 78.8 ms 71.4 ms +10.39%

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing b84330808:fix-ps-idiv-exp-simplifications (3a326e3) with master (bfe4cca)

Open in CodSpeed

Footnotes

  1. 174 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@calixteman calixteman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you.

@calixteman
calixteman merged commit 5258159 into mozilla:master Nov 7, 2026
27 of 28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants