Closed Bug 946426 Opened 12 years ago Closed 12 years ago

While loop using "count-- != 0" as its condition is not optimized very well

Categories

(Core :: JavaScript Engine: JIT, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 946425

People

(Reporter: bzbarsky, Unassigned)

References

Details

Consider this script: (function(count) { var start = new Date; while (count-- != 0); var stop = new Date; print((stop - start) / 10000000 * 1e6); })(10000000); This prints about 2.6ns per iteration for me in the shell. With --ion-eager it's more like .9ns, which is what I would expect given bug 946422. Below is what JIT inspector says we're doing. We seem to be doing some sort of ValueToInt32 conversion (why?) and overflow checks (why?). This may be a duplicate of bug 946425... Block #3 -> #3 -> #4 :: 9998904 hits [Label] [InterruptCheckImplicit] [OsiPoint] [ValueToInt32:Normal] movq %rax, %r11 shrq $47, %r11 cmpl $0x1fff1, %r11d je ((690)) cmpl $0x1fff6, %r11d jne ((703)) xorl %ebx, %ebx jmp ((710)) ##link ((690)) jumps to ((710)) movl %eax, %ebx ##link ((710)) jumps to ((712)) [OsiPoint] [MoveGroup] movq %rbx, %rbp [SubI:OverflowCheck] subl $0x1, %ebp jo ((724)) [Box:Int32] movabsq $0xfff8800000000000, %rax orq %rbp, %rax [CompareAndBranch:ne] testl %ebx, %ebx jne ((745)) ##link ((745)) jumps to ((745))
(In reply to Boris Zbarsky [:bz] from comment #0) > This may be a duplicate of bug 946425... Yup, this looks fine now.
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.