Closed Bug 1623437 Opened 6 years ago Closed 6 years ago

ARM64: Improve negative zero check for LMulI

Categories

(Core :: JavaScript Engine: JIT, defect, P2)

defect

Tracking

()

RESOLVED FIXED
mozilla76
Tracking Status
firefox76 --- fixed

People

(Reporter: iain, Assigned: iain)

References

Details

Attachments

(1 file)

Servo had profiles suggesting that Ion is recompiling repeatedly on arm64. jdm and I investigated, and it looks like the primary culprit in his testcase is our handling of integer multiplies producing zero.

For what I assume are good reasons, when an integer multiplication "should" produce negative zero, we bail out to handle it in baseline. (For reasons I haven't tracked down yet, the bailout kind is Bailout_DoubleOutput, which immediately invalidates the IonScript.) For x86/x64, we test to see if the result of the multiply is zero, then use an OOL path to decide whether it was negative zero. For arm64, we don't do that. Instead, we bail out whenever the result of the multiply is zero, negative or not.

Here's a cut down testcase:

var r = 0;
function scale(t) {
  r = r * t;
};

for (var i = 0; i < 10000; i++) { scale(1); }

On arm64, this throws away the IonScript when we execute r = r * t. What's worse, even though we're bailing out with Bailout_DoubleOutput, there's no real double here, so the typeset doesn't change and we make the same mistake next time scale is compiled.

We should fix visitMulI on arm64 so that it doesn't bail out unless the zero is actually negative.

Good find.

Longer-term we should really try to catch these bailout -> compile -> bailout loops in debug builds.

(In reply to Jan de Mooij [:jandem] from comment #1)

Good find.

Longer-term we should really try to catch these bailout -> compile -> bailout loops in debug builds.

One idea in the past was to checksum the generated code, then record and assert that we did not already produced this code since the last GC.

(In reply to Nicolas B. Pierron [:nbp] from comment #2)

One idea in the past was to checksum the generated code, then record and assert that we did not already produced this code since the last GC.

Yeah, with WarpBuilder we can hopefully do this a bit more easily with the WarpSnapshot interface (eventually).

Whenever Ion multiplies two integers on ARM64, if the result is zero, we will not only bail out, but invalidate the script. This is causing repeated invalidations in Servo. This patch fixes the negative zero handling for LMulI on ARM64.

Assignee: nobody → iireland
Status: NEW → ASSIGNED
Pushed by iireland@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/94b4897b1963 ARM64: Check for negative zero in MulI bailout r=nbp
Regressions: 1624072
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla76
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: