Closed Bug 1120069 Opened 10 years ago Closed 10 years ago

IonMonkey: Implement MTruncateToInt32 recover instruction

Categories

(Core :: JavaScript Engine: JIT, defect)

x86_64
Windows 7
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla38

People

(Reporter: andy.zsshen, Assigned: andy.zsshen, Mentored)

References

Details

Attachments

(5 files, 10 obsolete files)

(deleted), image/png
Details
(deleted), image/png
Details
(deleted), image/png
Details
(deleted), patch
Details | Diff | Splinter Review
(deleted), patch
nbp
: review+
Details | Diff | Splinter Review
User Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36
Implement MTruncateToInt32 in js/src/jit/Recover.cpp. See Bug 1003801 comment 0 for explanation.
Mentor: nicolas.b.pierron
OS: Windows 8.1 → Windows 7
Whiteboard: [good first bug][lang=c++]
Attached patch Recover_MTruncateToInt32.patch (obsolete) (deleted) — Splinter Review
The implemented recovering code and its test case.
Attachment #8547020 - Flags: review?(nicolas.b.pierron)
Whiteboard: [good first bug][lang=c++]
Attached patch Recover_MTruncateToInt32.patch (obsolete) (deleted) — Splinter Review
Update the patch. It can pass the try server testing: https://treeherder.mozilla.org/ui/#/jobs?repo=try&revision=b74bb7207092
Attachment #8547020 - Attachment is obsolete: true
Attachment #8547020 - Flags: review?(nicolas.b.pierron)
Attachment #8547286 - Flags: review?(nicolas.b.pierron)
Comment on attachment 8547286 [details] [diff] [review] Recover_MTruncateToInt32.patch Review of attachment 8547286 [details] [diff] [review]: ----------------------------------------------------------------- ::: js/src/jit-test/tests/ion/dce-with-rinstructions.js @@ +1029,5 @@ > } > > +var uceFault_trunc_to_int32_number = eval(uneval(uceFault).replace('uceFault', 'uceFault_trunc_to_int32_number')); > +function rtrunc_to_int32_number(i) { > + var x = Math.imul(i + 0.12, i + 0.23); use a bitwise operator instead of Math.imul, such as (i + 0.12) | 0 @@ +1041,5 @@ > + var t1 = i + 0.12; > + var t2 = i + 0.23; > + var o1 = { valueOf: function() { return t1; } }; > + var o2 = { valueOf: function() { return t2; } }; > + var x = Math.imul(o1, o2); same here. ::: js/src/jit/MIR.h @@ +4638,5 @@ > #endif > > + bool writeRecoverData(CompactBufferWriter &writer) const; > + bool canRecoverOnBailout() const { > + return true; I am surprised the test case does highlight the issue, Can you verify with iongraph that the second test is using recover instructions. ::: js/src/jit/Recover.cpp @@ +1104,5 @@ > +{ > + RootedValue result(cx); > + > + // Directly apply public conversion. > + double in = iter.read().toNumber(); Use: if (!ToNumber(cx, val, &dbl)) return false; instead of toNumber, as the ToNumber function will handle the conversion from string to integers. Add a test case for strings such as assertEq( (i + "0") | 0, 990)
Attachment #8547286 - Flags: review?(nicolas.b.pierron) → feedback+
Attached patch Recover_MTruncateToInt32.patch (obsolete) (deleted) — Splinter Review
Update the number conversion and refine the test cases.
Attachment #8547286 - Attachment is obsolete: true
Attachment #8547643 - Flags: review?(nicolas.b.pierron)
Attached image rtrunc_to_int32_number (obsolete) (deleted) —
The iongraph for rtrunct_to_int32_number
Attached image rtrunc_to_int32_object (obsolete) (deleted) —
The iongraph for rtrunc_to_int32_object
Comment on attachment 8547643 [details] [diff] [review] Recover_MTruncateToInt32.patch Review of attachment 8547643 [details] [diff] [review]: ----------------------------------------------------------------- ::: js/src/jit-test/tests/ion/dce-with-rinstructions.js @@ +1031,5 @@ > +var uceFault_trunc_to_int32_number = eval(uneval(uceFault).replace('uceFault', 'uceFault_trunc_to_int32_number')); > +function rtrunc_to_int32_number(i) { > + var x = (i + 0.12) | 0; > + if (uceFault_trunc_to_int32_number(i) || uceFault_trunc_to_int32_number(i)) > + assertEq(x, (i + 0.12) | 0); replace this by 99. @@ +1042,5 @@ > + var o1 = { valueOf: function() { return t1; } }; > + var x = o1 | 0; > + t1 = 777.12; > + if (uceFault_trunc_to_int32_object(i) || uceFault_trunc_to_int32_object(i)) > + assertEq(x, (i + 0.12) | 0); same here. @@ +1049,5 @@ > +var uceFault_trunc_to_int32_string = eval(uneval(uceFault).replace('uceFault', 'uceFault_trunc_to_int32_string')); > +function rtrunc_to_int32_string(i) { > + var x = (i + "0") | 0; > + if (uceFault_trunc_to_int32_string(i) || uceFault_trunc_to_int32_string(i)) > + assertEq(x, (i + "0") | 0); replace it by 990 ::: js/src/jit/MIR.h @@ +4638,5 @@ > #endif > > + bool writeRecoverData(CompactBufferWriter &writer) const; > + bool canRecoverOnBailout() const { > + return true; Can you attach the last MIR phase of the 3 test function that are added in dce-with-rinstructions.js ? I really doubt that we want to return true here.
Attached image rtrunc_to_int32_string (obsolete) (deleted) —
The iongraph for rtrunc_to_int32_string. It is weird... As these graph show, the truncatetoint32 operations are not colored as gray. However, the program will call RTruncateToInt32::recover() when I set a break point at the function prologue for verification.
Attached patch Recover_TruncateToInt32.patch (obsolete) (deleted) — Splinter Review
Add the input MIR type checking for canRecoverOnBailout().
Attachment #8547643 - Attachment is obsolete: true
Attachment #8547643 - Flags: review?(nicolas.b.pierron)
Attachment #8548995 - Flags: review?(nicolas.b.pierron)
Comment on attachment 8548995 [details] [diff] [review] Recover_TruncateToInt32.patch Review of attachment 8548995 [details] [diff] [review]: ----------------------------------------------------------------- ::: js/src/jit/MIR.h @@ +4638,5 @@ > #endif > > + bool writeRecoverData(CompactBufferWriter &writer) const; > + bool canRecoverOnBailout() const { > + return input()->type() != MIRType_Object; We probably want an inequality, in order to prevent accepting boxed objects.
Attachment #8548995 - Flags: review?(nicolas.b.pierron) → feedback+
Attached patch Recover_TruncateToInt32.patch (obsolete) (deleted) — Splinter Review
Refine the return condition for canRecoverOnBailout(). The try testing result: https://treeherder.mozilla.org/#/jobs?repo=try&revision=2e3e602a7582
Attachment #8548995 - Attachment is obsolete: true
Attachment #8551302 - Flags: review?(nicolas.b.pierron)
Attached image func226-pass17-Sink-mir.gv.png (deleted) —
The iongraph for rtrunc_to_int32_number.
Attachment #8547645 - Attachment is obsolete: true
Attached image func227-pass17-Sink-mir.gv.png (deleted) —
The iongraph for rtrunc_to_int32_object
Attachment #8547647 - Attachment is obsolete: true
Attached image func229-pass17-Sink-mir.gv.png (deleted) —
The iongraph for rtrunc_to_int32_string
Attachment #8547656 - Attachment is obsolete: true
Comment on attachment 8551302 [details] [diff] [review] Recover_TruncateToInt32.patch Review of attachment 8551302 [details] [diff] [review]: ----------------------------------------------------------------- Sounds good to land :)
Attachment #8551302 - Flags: review?(nicolas.b.pierron) → review+
Keywords: checkin-needed
Assignee: nobody → andy.zsshen
Hi, this patch failed to apply: applying Recover_TruncateToInt32.patch patching file js/src/jit-test/tests/ion/dce-with-rinstructions.js Hunk #2 FAILED at 1187 1 out of 2 hunks FAILED -- saving rejects to file js/src/jit-test/tests/ion/dce-with-rinstructions.js.rej patch failed, unable to continue (try -v) patch failed, rejects left in working dir errors during apply, please fix and refresh Recover_TruncateToInt32.patch could you take a look, thanks!
Flags: needinfo?(andy.zsshen)
Keywords: checkin-needed
Attached patch Recover_TruncateToInt32.patch (deleted) — Splinter Review
Resolve the conflict.
Attachment #8551302 - Attachment is obsolete: true
Flags: needinfo?(andy.zsshen)
Keywords: checkin-needed
Status: UNCONFIRMED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla38
Comment on attachment 8553151 [details] [diff] [review] Recover_TruncateToInt32.patch Review of attachment 8553151 [details] [diff] [review]: ----------------------------------------------------------------- ::: js/src/jit/Recover.cpp @@ +1143,5 @@ > + > + double in; > + if (!ToNumber(cx, value, &in)) > + return false; > + int out = ToInt32(in); int out = JS::ToInt32(in);
Depends on: 1125588
Attached patch Recover_TruncateToInt32_Refine.patch (obsolete) (deleted) — Splinter Review
Code refinement: Change ToNumber() to ToInt32() for value range testing. Try testing result: https://treeherder.mozilla.org/#/jobs?repo=try&revision=addfb387c306
Attached patch Recover_TruncateToInt32_Refine.patch (obsolete) (deleted) — Splinter Review
Code refinement: Change ToNumber() to ToInt32() for value range testing. Try testing result: https://treeherder.mozilla.org/#/jobs?repo=try&revision=addfb387c306
Attachment #8554580 - Attachment is obsolete: true
Attachment #8554584 - Flags: review?(nicolas.b.pierron)
Comment on attachment 8554584 [details] [diff] [review] Recover_TruncateToInt32_Refine.patch Review of attachment 8554584 [details] [diff] [review]: ----------------------------------------------------------------- ::: js/src/jit/Recover.cpp @@ +1141,5 @@ > RootedValue value(cx, iter.read()); > RootedValue result(cx); > > + int32_t trunc; > + if (!ToInt32(cx, value, &trunc)) Add the JS:: namespace specifier. And make sure jsapi.h is #include in this file.
Attachment #8554584 - Flags: review?(nicolas.b.pierron)
1. Include the jsapi.h 2. Add the JS:: namespace specification
Attachment #8554584 - Attachment is obsolete: true
Attachment #8554605 - Flags: review?(nicolas.b.pierron)
Comment on attachment 8554605 [details] [diff] [review] Recover_TruncateToInt32_Refine.patch Review of attachment 8554605 [details] [diff] [review]: ----------------------------------------------------------------- This looks good :)
Attachment #8554605 - Flags: review?(nicolas.b.pierron) → review+
Keywords: checkin-needed
Keywords: checkin-needed
Before check-in, It should be better to run the test again: https:https://treeherder.mozilla.org/#/jobs?repo=try&revision=9e0db6e9b100
Keywords: checkin-needed
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: