Skip to content

Conversation

GarboMuffin
Copy link
Member

@GarboMuffin GarboMuffin commented Sep 23, 2025

My understanding is that the new compiler tries to reason about -0 a good bit but the use of (x||0) prevents it from fixing all of the bugs. This replaces that syntax with a jsexecute function that returns 0 only for NaN and leaves -0 unchanged.

Draft because:

  • Need more performance testing. Brief initial testing found no slowdown in Linux in Scratch. @Geotale said this might even be faster in ideal conditions.
  • Need some solid test cases to add.

Test @ https://experiments.turbowarp.org/fix-negative-zero/

@Tacodiva
Copy link
Member

How does this effect performance?

@GarboMuffin
Copy link
Member Author

My only datapoint so far is that isNaN(value) ? 0 : value made Linux in Scratch run 50% slower in Firefox whereas value === value ? value : 0 made it have no measurable difference compared to develop. Maybe next weekend or so I can look around a bit more. I'm particularly worried about performance of generator functions in Firefox which don't get into the highest tier of JIT so probably no inlining at all in that case.

@GarboMuffin
Copy link
Member Author

some years ago i thought about gathering up some hundreds of projects so i can make a proper performance tracking and comparison system, though i never got around to that. would've been really cool to have these last weeks

@GarboMuffin
Copy link
Member Author

it's also on https://experiments.turbowarp.org/fix-negative-zero/ if you were interested in testing anything yourself

Linux in Scratch, in Firefox, with warp timer, goes from around 36s -> around 40s to boot so it's measurable though less catastrophic than I expected. Chrome in the same configuration is maybe just a tiny bit slower but I think it's within noise.

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.

-#/0 Returns positive Infinity with compiler off. TurboWarp breaks any operations that depend on negitive 0 and the value not being NaN
2 participants