Closed chqrlie closed 2 months ago
Some compilers are not happy...
Yes, gcc 32-bit optimizes the naive copy loop beyond sanity (uses SIMD instructions) which causes reads beyond the array boundaries. I am investigating other approaches. WIP
I ran extensive benchmarks to test various methods to convert integers to strings in base 10 or others.
You can run make testconv
on your system to test with different compilers and options.
I changed the variant used in cutils.c for better performance and to avoid some nasty over-optimisations by gcc on some CI targets.
The variant selected shifts 1 to 7 digits into a 64-bit register and writes them as an 8-byte block including the null terminator. This is quite fast, albeit not as fast as composing the string 2 digits at a time, which uses more memory and causes gcc to output warnings for what seems to be an optimisation issue.
is_upper_ascii()
andto_upper_ascii()
u32toa()
,i32toa()
,u64toa()
,i64toa()
u32toa_radix()
,u64toa_radix()
,i64toa_radix()
snprintf()
js_dtoa1()
js_number_toString()
for small intsJS_NewStringLen()
instead ofJS_NewString()
when possible