Created attachment 683731 [details] demo html when iterating over string and doing character comparison the JS engine is two times slower than V8.
v8 generates code for character compares. We only have one very simple optimization for ==/!=. Which checks for ptr==ptr, atoms and string length. I think optimizing this very case could be simple. Last time I tried implementing a whole string compare path everything got very ugly, because of register pressure.
The problem is that IonMonkey does not yet provide a fast path for atom inequalities (see MCompare::infer in ion/MIR.cpp), so currently the result of charAt returns another atom which is boxed and pushed twice to call into a VM function which unbox its operands and compare the atoms. Note: x2 times slower does not seems too bad knowing the overhead of VM function calls, both in terms of spilling and it terms of number of instructions.