Closed Bug 743345 Opened 12 years ago Closed 12 years ago

IonMonkey: very slow perf on bubble sort program with IIFE

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: dmandelin, Unassigned)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

Attached file test case
Spun off from bug 743328 comment 3. The attached benchmark is very fast if the IIFE wrapper is taken off, but very slow (24s) with it on.
The problem is that the presence of a FunctionEnvironment requires us to use MCallGetName(FunctionEnvironment) to resolve the Value of "SIZE". If SIZE is redefined within bubble_sort(), both versions of the benchmark complete in the same small timeframe.

Since bubble_sort() is defined within a function, we look through its scope chain to resolve SIZE, while the fast version bakes in a LoadSlot from the constant global object.

Looking through the scope chain is done by MCallGetName(MFunctionEnvironment) in the inner loop -- but MCallGetName is non-idempotent, so it is not only slower, but it also inhibits LICM, even more than is strictly necessary. So we wind up recalculating bounds checks and so on for each iteration. This causes the significant slowdown.
Ah, good catch. MCallGetName on its own is very expensive. So I guess this depends on scope stuff.
Now that we support scope chains, this is more than 2X faster on IonMonkey than JM+TI (and, v8!)
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → WORKSFORME
(In reply to David Anderson [:dvander] from comment #3)
> Now that we support scope chains, this is more than 2X faster on IonMonkey
> than JM+TI (and, v8!)

\o/
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: