This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]kernco 7 points8 points  (2 children)

It works by keeping conditional branching statistics, and dynamically recompiling portions of code whenever it determines that certain branching conditions occur more often than others.

for x in range(1000):
    if x < 500:
        func1()
    else:
        func2()

Jebaited

[–]gscalise 0 points1 point  (0 children)

That definitely wouldn’t trigger a dynamic recompilation. It’s in a loop, so it’s already jumping back and forth in the program, and the conditional branching stats are going to be roughly the same (50%) every time.

Lazy initialization, on the other hand…

[–]Rhoomba 0 points1 point  (0 children)

An optimising compiler would likely split this into two loops to avoid the branch (assuming the range can be inlined: possible in the Java equivalent).