Bug 85144

Summary: Bytecompiler should emit trivially fewer jumps in loops
Product: WebKit Reporter: Filip Pizlo <fpizlo>
Component: JavaScriptCoreAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: dglazkov, ggaren, mjs, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
the patch
oliver: review+, webkit.review.bot: commit-queue-
Archive of layout-test-results from ec2-cr-linux-03 none

Description Filip Pizlo 2012-04-28 15:58:55 PDT
Currently for a loop like:

while (foo) bar;

We emit code like:

     jmp continueTarget
topOfLoop:
     <code for bar>
continueTarget:
     <code for foo>
breakTarget:

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

     <code for foo>
     <code for bar>
continueTarget:
     <code for foo>
breakTarget:

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:
fast/filesystem/workers/file-writer-sync-truncate-extend.html
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