Bug 143140

Summary: IteratorClose should be called when jumping over the target for-of loop
Product: WebKit Reporter: Yusuke Suzuki <ysuzuki>
Component: JavaScriptCoreAssignee: Yusuke Suzuki <ysuzuki>
Status: RESOLVED FIXED    
Severity: Normal CC: benjamin, fpizlo, ggaren, mark.lam, rniwa
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch ggaren: review+

Description Yusuke Suzuki 2015-03-27 12:07:40 PDT
When executing the following script,

var iter = ...;

outer: for (var i of array) {
    for (var j of iter) {
        break outer;
    }
}

iter.return should be called.
Comment 1 Yusuke Suzuki 2015-03-27 12:08:23 PDT
The patch is already submitted in https://bugs.webkit.org/show_bug.cgi?id=142575,
I'll move it to here.
Comment 2 Yusuke Suzuki 2015-03-28 02:12:12 PDT
Created attachment 249659 [details]
Patch
Comment 3 Yusuke Suzuki 2015-03-28 02:27:06 PDT
Created attachment 249660 [details]
Patch
Comment 4 Yusuke Suzuki 2015-03-28 02:47:32 PDT
Created attachment 249661 [details]
Patch
Comment 5 Yusuke Suzuki 2015-03-30 10:39:51 PDT
Created attachment 249743 [details]
Patch
Comment 6 Geoffrey Garen 2015-03-31 16:55:57 PDT
Comment on attachment 249743 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=249743&action=review

r=me

> Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp:2358
> +            } else if (finallyContext.iterator) {

This should be an else with an ASSERT. It shouldn't be possible to have a finally context without either a block of code or an iterator close.
Comment 7 Yusuke Suzuki 2015-04-01 02:35:28 PDT
Comment on attachment 249743 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=249743&action=review

Thank you for your review! I'll fix and land it.

>> Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp:2358
>> +            } else if (finallyContext.iterator) {
> 
> This should be an else with an ASSERT. It shouldn't be possible to have a finally context without either a block of code or an iterator close.

You're right. Use else and ASSERT instead.
Comment 8 Yusuke Suzuki 2015-04-01 02:37:06 PDT
Committed r182226: <http://trac.webkit.org/changeset/182226>