RESOLVED FIXED Bug 158892
Switching on symbols should be fast
https://bugs.webkit.org/show_bug.cgi?id=158892
Summary Switching on symbols should be fast
Filip Pizlo
Reported 2016-06-17 15:58:10 PDT
Patch forthcoming.
Attachments
something like this (12.98 KB, patch)
2016-06-17 15:59 PDT, Filip Pizlo
no flags
maybe the patch (30.54 KB, patch)
2016-06-18 16:44 PDT, Filip Pizlo
no flags
better patch (27.34 KB, patch)
2016-06-19 12:56 PDT, Filip Pizlo
no flags
awesome patch (27.34 KB, patch)
2016-06-25 20:10 PDT, Filip Pizlo
no flags
patch (29.76 KB, patch)
2016-06-25 20:12 PDT, Filip Pizlo
no flags
the patch (29.87 KB, patch)
2016-07-18 22:43 PDT, Filip Pizlo
no flags
the patch (30.69 KB, patch)
2016-07-18 22:54 PDT, Filip Pizlo
fpizlo: review-
the patch (41.89 KB, patch)
2016-07-19 00:16 PDT, Filip Pizlo
no flags
the patch (63.76 KB, patch)
2016-07-19 13:18 PDT, Filip Pizlo
no flags
performance (80.31 KB, text/plain)
2016-07-19 15:09 PDT, Filip Pizlo
no flags
Filip Pizlo
Comment 1 2016-06-17 15:59:35 PDT
Created attachment 281595 [details] something like this
Filip Pizlo
Comment 2 2016-06-18 16:44:03 PDT
Created attachment 281620 [details] maybe the patch This does the trick. What's sad about this is that this optimization really belongs in lower tiers, but currently it's not feasible to do it in DFG IR. You really need B3 IR to do it. But without the optimization, the code runs so incredibly slow that it takes a long time to get to FTL. It's starting to become quite clear that we need tier-up checks in straight-line code.
Filip Pizlo
Comment 3 2016-06-19 12:56:05 PDT
Created attachment 281622 [details] better patch
Filip Pizlo
Comment 4 2016-06-19 16:46:51 PDT
Looks like this has a bug: stress/float64-array-nan-inlined.js.default: test_script_12303: line 2: 55586 Segmentation fault: 11 ( "$@" ../../.vm/JavaScriptCore.framework/Resources/jsc --useFTLJIT\=false --useFunctionDotArguments\=true float64-array-nan-inlined.js ) stress/float64-array-nan-inlined.js.default: ERROR: Unexpected exit code: 139 Maybe it's latent so I'm still testing without the patch.
Filip Pizlo
Comment 5 2016-06-19 17:09:23 PDT
(In reply to comment #4) > Looks like this has a bug: > > stress/float64-array-nan-inlined.js.default: test_script_12303: line 2: > 55586 Segmentation fault: 11 ( "$@" > ../../.vm/JavaScriptCore.framework/Resources/jsc --useFTLJIT\=false > --useFunctionDotArguments\=true float64-array-nan-inlined.js ) > stress/float64-array-nan-inlined.js.default: ERROR: Unexpected exit code: 139 > > Maybe it's latent so I'm still testing without the patch. Wait, it has to be latent! It's a non-FTL test and this patch only changes FTL.
Filip Pizlo
Comment 6 2016-06-20 15:23:57 PDT
(In reply to comment #5) > (In reply to comment #4) > > Looks like this has a bug: > > > > stress/float64-array-nan-inlined.js.default: test_script_12303: line 2: > > 55586 Segmentation fault: 11 ( "$@" > > ../../.vm/JavaScriptCore.framework/Resources/jsc --useFTLJIT\=false > > --useFunctionDotArguments\=true float64-array-nan-inlined.js ) > > stress/float64-array-nan-inlined.js.default: ERROR: Unexpected exit code: 139 > > > > Maybe it's latent so I'm still testing without the patch. > > Wait, it has to be latent! It's a non-FTL test and this patch only changes > FTL. Yeah, it was an unrelated bug, and I fixed it.
Filip Pizlo
Comment 7 2016-06-25 20:10:17 PDT
Created attachment 282086 [details] awesome patch
Filip Pizlo
Comment 8 2016-06-25 20:12:23 PDT
Filip Pizlo
Comment 9 2016-07-18 22:43:51 PDT
Created attachment 283979 [details] the patch
Filip Pizlo
Comment 10 2016-07-18 22:54:38 PDT
Created attachment 283980 [details] the patch
Filip Pizlo
Comment 11 2016-07-18 23:06:18 PDT
Comment on attachment 283980 [details] the patch Oh man, this doesn't quite work! Fixing...
Filip Pizlo
Comment 12 2016-07-19 00:16:01 PDT
Created attachment 283981 [details] the patch
Saam Barati
Comment 13 2016-07-19 00:23:33 PDT
Comment on attachment 283981 [details] the patch View in context: https://bugs.webkit.org/attachment.cgi?id=283981&action=review > Source/JavaScriptCore/b3/B3ReduceStrength.cpp:439 > + // put them. We're not actually smart enough things to move things around at random. "smart enough things" => "smart enough" > Source/JavaScriptCore/b3/B3ReduceStrength.cpp:466 > + if (m_blockInsertionSet.execute() | m_changedCFG) { Should be "||"
Filip Pizlo
Comment 14 2016-07-19 10:11:21 PDT
(In reply to comment #13) > Comment on attachment 283981 [details] > the patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=283981&action=review > > > Source/JavaScriptCore/b3/B3ReduceStrength.cpp:439 > > + // put them. We're not actually smart enough things to move things around at random. > > "smart enough things" => "smart enough" Fixed. > > > Source/JavaScriptCore/b3/B3ReduceStrength.cpp:466 > > + if (m_blockInsertionSet.execute() | m_changedCFG) { > > Should be "||" That was sort of deliberate. I wanted to emphasize that every subexpression should execute for side-effects. I changed it to: m_changedCFG |= m_blockInsertionSet.execute(); if (m_changedCFG) {
Filip Pizlo
Comment 15 2016-07-19 13:18:46 PDT
Created attachment 284037 [details] the patch
Filip Pizlo
Comment 16 2016-07-19 15:09:25 PDT
Created attachment 284059 [details] performance
Keith Miller
Comment 17 2016-07-20 12:26:16 PDT
Comment on attachment 284037 [details] the patch r=me. Out of curiosity does this optimization kick in if the user doesn't write a switch explicitly? If so, maybe it would be worth adding a test. For example: if (a === sym1) ... if (a === sym2) ... ...
Filip Pizlo
Comment 18 2016-07-20 19:28:46 PDT
(In reply to comment #17) > Comment on attachment 284037 [details] > the patch > > r=me. Out of curiosity does this optimization kick in if the user doesn't > write a switch explicitly? If so, maybe it would be worth adding a test. For > example: > > if (a === sym1) > ... > if (a === sym2) > ... > ... It does kick in for this! Good idea, I will add a test for it.
Filip Pizlo
Comment 19 2016-07-20 22:42:02 PDT
(In reply to comment #18) > (In reply to comment #17) > > Comment on attachment 284037 [details] > > the patch > > > > r=me. Out of curiosity does this optimization kick in if the user doesn't > > write a switch explicitly? If so, maybe it would be worth adding a test. For > > example: > > > > if (a === sym1) > > ... > > if (a === sym2) > > ... > > ... > > It does kick in for this! Good idea, I will add a test for it. Yeah, I wrote a test like this - basically a scripted rewrite of bigswitch-indirect-symbol to use if - and it gets a speed-up from this patch.
Filip Pizlo
Comment 20 2016-07-20 23:24:23 PDT
Note You need to log in before you can comment on or make changes to this bug.