Closed Bug 710447 Opened 12 years ago Closed 12 years ago

IonMonkey: Invalid hoisting in basic/testBug529147.js

Categories

(Core :: JavaScript Engine, defect)

x86_64
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: sstangl, Unassigned)

References

Details

Attachments

(1 file)

basic/testBug529147.js returns an incorrect value due to invalid hoisting. The code looks something like this:

> var sum = 0; // global
> function foo(n) {
>   for (var i = 0; i < n; i++)
>     sum += 10;
> }

Around the global addition, MLoadSlot is marked as idempotent and movable. We hoist the global load and add out of the loop, then repeatedly store the same old value.

MLoadSlot should not be movable. (We can hoist it in some conditions -- but the analysis would be difficult or impossible if there is a storeslot or function call within the loop.)
We can't hoist unless it's provable that the loop cannot change the slot's value. Fixes test failure.
Attachment #581466 - Flags: review?(dvander)
This depends on having alias sets (bug 703376), right?  Associate the MLoadSlot with a TypeObject/property if possible, and then it is movable/hoistable just so long as it is not moved across an operation which could overwrite the type/property.
Comment on attachment 581466 [details] [diff] [review]
Set NeverHoisted on MLoadSlots.

bug 703376 should fix this and let us hoist MLoadSlot when possible - it's okay to land this to clear up orange if we take out the NeverHoisted bit as soon as bug 703376 lands.
Attachment #581466 - Flags: review?(dvander) → review+
(In reply to Brian Hackett (:bhackett) from comment #2)
> This depends on having alias sets (bug 703376), right?  Associate the
> MLoadSlot with a TypeObject/property if possible, and then it is
> movable/hoistable just so long as it is not moved across an operation which
> could overwrite the type/property.

Yes. We should keep the default state unhoistable, which alias sets can disprove. In the current state, we just hoist optimistically without reason, which is causing a number of test failures.

The test failures showed up only now due to greater test coverage from Bug 708441.
http://hg.mozilla.org/projects/ionmonkey/rev/1c2192196b11
Blocks: 703376
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.