RESOLVED FIXED 192966
DFGByteCodeParser rules for bitwise operations should consider type of their operands
https://bugs.webkit.org/show_bug.cgi?id=192966
Summary DFGByteCodeParser rules for bitwise operations should consider type of their ...
Caio Lima
Reported 2018-12-20 17:34:18 PST
Current implementation relies into `getPrediction()` to emit ArithBitOp or ValueBitOp. This rule is not efficient because there cases where we don't have profiling information and we sendup always emitting OSRExit or ValueBitOp.
Attachments
Patch (9.04 KB, patch)
2018-12-20 19:20 PST, Caio Lima
no flags
Benchmarks (96.83 KB, text/plain)
2018-12-20 19:33 PST, Caio Lima
no flags
Patch (9.82 KB, patch)
2019-01-10 05:44 PST, Caio Lima
no flags
Benchmarks (95.03 KB, text/plain)
2019-01-10 05:48 PST, Caio Lima
no flags
Patch (11.51 KB, patch)
2019-01-14 18:34 PST, Caio Lima
no flags
Caio Lima
Comment 1 2018-12-20 19:20:08 PST
Caio Lima
Comment 2 2018-12-20 19:33:09 PST
Created attachment 357919 [details] Benchmarks This patch seems perf neutral on x86_64
Yusuke Suzuki
Comment 3 2018-12-30 11:49:13 PST
Comment on attachment 357918 [details] Patch r=me
Caio Lima
Comment 4 2018-12-30 14:56:45 PST
(In reply to Yusuke Suzuki from comment #3) > Comment on attachment 357918 [details] > Patch > > r=me Thx for the review. I'm investigating a regression into zlib before landing.
Caio Lima
Comment 5 2018-12-31 07:22:07 PST
(In reply to Caio Lima from comment #4) > (In reply to Yusuke Suzuki from comment #3) > > Comment on attachment 357918 [details] > > Patch > > > > r=me > > Thx for the review. I'm investigating a regression into zlib before landing. We had a false alarm into zlib, but there is an odd case into Microbenchmark/slow-ternary. The problem is when we compile a function without executing some bitwise op. Since on ToT we emit ArithBitOp using ```getPrediction()```, generated code end up emitting ForceOSRExit when there is no profiling info. Because of this, we don't emit the rest of code followed by this block and the final version of the code is much simpler than the version we generated with this patch. Even though the ToT compiled code has an ForceOSRexit, the function runs almost all iterations before it fallback to Baseline JIT, and since the code is smaller, I think this makes ToT version run faster. I personally think that such regression comparing ToT and changes is acceptable, since our current rules emitting AirthBitOp and ValueBitOp are wrong, mainly because we don't benefit from prediction propagation on cases that profile is inexistent. What do you think about this result? I'm going to wait for your comments before moving forward.
Caio Lima
Comment 6 2019-01-02 07:04:41 PST
(In reply to Caio Lima from comment #5) > > We had a false alarm into zlib, but there is an odd case into > Microbenchmark/slow-ternary. The problem is when we compile a function > without executing some bitwise op. Since on ToT we emit ArithBitOp using > ```getPrediction()```, generated code end up emitting ForceOSRExit when > there is no profiling info. Because of this, we don't emit the rest of code > followed by this block and the final version of the code is much simpler > than the version we generated with this patch. Even though the ToT compiled > code has an ForceOSRexit, the function runs almost all iterations before it > fallback to Baseline JIT, and since the code is smaller, I think this makes > ToT version run faster. To illustrate better what I'm saying, here is the DFG code generated by ToT version (https://pastebin.com/3XEcYw7x) and here is DFG code generated with proposed changes (https://pastebin.com/MFRqGwvu). We can find the difference on Block #3 (line 110 and 118 in each file) where ToT version has ForceOSRExit, while changes version keeps generating code properly. ToT version removes Block #4-#9 while our changes version generates almost all of them.
Caio Lima
Comment 7 2019-01-07 09:32:49 PST
Ping discussion on comment #5
Caio Lima
Comment 8 2019-01-10 05:44:20 PST
Caio Lima
Comment 9 2019-01-10 05:48:02 PST
Created attachment 358786 [details] Benchmarks According this report, these changes are perf neutral. The changes comparing to previous version is that we are using getHeapPrediction() to set prediction propagation of ValueBitOp.
Caio Lima
Comment 10 2019-01-14 02:51:44 PST
Ping Review
Yusuke Suzuki
Comment 11 2019-01-14 14:43:19 PST
Comment on attachment 358784 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=358784&action=review r=me > Source/JavaScriptCore/ChangeLog:11 > + for ValueBitOp to use `getHeapPrediction()`. Can we have a test to ensure that JSC does not perform compile-fail loops? Like the following code would pose the issue if something is wrong. var object = { valueOf() { return integer; } }; // object with bit operation, which will produce Int32, but the operands of bit operation includes object.
Caio Lima
Comment 12 2019-01-14 18:34:05 PST
Comment on attachment 358784 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=358784&action=review Thank you very much for the review! >> Source/JavaScriptCore/ChangeLog:11 >> + for ValueBitOp to use `getHeapPrediction()`. > > Can we have a test to ensure that JSC does not perform compile-fail loops? > Like the following code would pose the issue if something is wrong. > > var object = { valueOf() { return integer; } }; > // object with bit operation, which will produce Int32, but the operands of bit operation includes object. Nice, added.
Caio Lima
Comment 13 2019-01-14 18:34:21 PST
WebKit Commit Bot
Comment 14 2019-01-15 02:14:37 PST
Comment on attachment 359115 [details] Patch Clearing flags on attachment: 359115 Committed r239980: <https://trac.webkit.org/changeset/239980>
WebKit Commit Bot
Comment 15 2019-01-15 02:14:39 PST
All reviewed patches have been landed. Closing bug.
Radar WebKit Bug Importer
Comment 16 2019-01-15 02:16:05 PST
Note You need to log in before you can comment on or make changes to this bug.