Bug 85144 - Bytecompiler should emit trivially fewer jumps in loops
Summary: Bytecompiler should emit trivially fewer jumps in loops
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
Depends on:
Reported: 2012-04-28 15:58 PDT by Filip Pizlo
Modified: 2012-05-20 03:00 PDT (History)
4 users (show)

See Also:

the patch (2.85 KB, patch)
2012-04-28 16:02 PDT, Filip Pizlo
oliver: review+
webkit.review.bot: commit-queue-
Details | Formatted Diff | Diff
Archive of layout-test-results from ec2-cr-linux-03 (6.26 MB, application/zip)
2012-04-28 16:48 PDT, WebKit Review Bot
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Filip Pizlo 2012-04-28 15:58:55 PDT
Currently for a loop like:

while (foo) bar;

We emit code like:

     jmp continueTarget
     <code for bar>
     <code for foo>

But it would be more efficient in almost all cases to instead emit:

     <code for foo>
     <code for bar>
     <code for foo>

This will lead to more bytecode, and will otherwise be natural for LLInt and Baseline.  But for DFG, it's a hearty win since it reduces the number of basic blocks and makes the data flow relationships between foo and bar more obvious.
Comment 1 Filip Pizlo 2012-04-28 16:02:22 PDT
Created attachment 139375 [details]
the patch
Comment 2 Maciej Stachowiak 2012-04-28 16:11:41 PDT
As a comment unrelated to this patch, it would be nice to have a fallback for emitNodeInConditionContext that knows how to generate regular code plus the branch for nodes without a specialized emitNodeInConditionContext - it's lame to have to do the fallback at every call site.
Comment 3 WebKit Review Bot 2012-04-28 16:48:43 PDT
Comment on attachment 139375 [details]
the patch

Attachment 139375 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/12556753

New failing tests:
Comment 4 WebKit Review Bot 2012-04-28 16:48:49 PDT
Created attachment 139377 [details]
Archive of layout-test-results from ec2-cr-linux-03

The attached test failures were seen while running run-webkit-tests on the chromium-ews.
Bot: ec2-cr-linux-03  Port: <class 'webkitpy.common.config.ports.ChromiumXVFBPort'>  Platform: Linux-2.6.35-28-virtual-x86_64-with-Ubuntu-10.10-maverick
Comment 5 Filip Pizlo 2012-04-28 16:53:26 PDT
Landed in http://trac.webkit.org/changeset/115587
Comment 6 Geoffrey Garen 2012-04-28 17:49:13 PDT
I believe that ForInNode would also benefit from this optimization.
Comment 7 Filip Pizlo 2012-05-20 03:00:10 PDT
Merged in http://trac.webkit.org/changeset/117706