IonMonkey: Invalid hoisting in basic/testBug529147.js

RESOLVED FIXED

Status

()

Core
JavaScript Engine
RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: sstangl, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

5 years ago
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.)
(Reporter)

Comment 1

5 years ago
Created attachment 581466 [details] [diff] [review]
Set NeverHoisted on MLoadSlots.

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+
(Reporter)

Comment 4

5 years ago
(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.
(Reporter)

Comment 5

5 years ago
http://hg.mozilla.org/projects/ionmonkey/rev/1c2192196b11
Blocks: 703376
Status: NEW → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.