<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[201433] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/201433">201433</a></dd>
<dt>Author</dt> <dd>fpizlo@apple.com</dd>
<dt>Date</dt> <dd>2016-05-26 14:58:42 -0700 (Thu, 26 May 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>ScopedLambda should have a lifetime story that makes sense to the compiler
https://bugs.webkit.org/show_bug.cgi?id=158118

Reviewed by Mark Lam.
Source/WTF:


Prior to this change, there were two lifetime bugs in ScopedLambda:
        
- scopedLambda(Functor&amp;&amp;) would bind Functor to const lambda&amp;, so the resulting ScopedLambdaFunctor
  would hold a reference to the original lambda. This would have surprising behavior; for example
  it meant that this code was wrong:
          
  auto l = scopedLambda&lt;things&gt;([&amp;] ...);
          
  The solution is to have explicit copy/move versions of scopedLambda() rather than rely on perfect
  forwarding.
        
- ScopedLambdaFunctor did not override its copy or move operations, so if the compiler did not RVO
  scopedLambda(), it would return a ScopedLambdaFunctor whose m_arg points to a dead temporary
  ScopedLambdaFunctor instance. The solution is to have explicit copy/move constructors and
  operators, which preserve the invariant that ScopedLambda::m_arg points to this.
        
One nice side-effect of all of these constructors and operators being explicit is that we can rely
on WTFMove's excellent assertions, which helped catch the first issue.
        
This reverts ParkingLot to use ScopedLambda again.

* wtf/ParkingLot.cpp:
(WTF::ParkingLot::parkConditionallyImpl):
(WTF::ParkingLot::unparkOne):
(WTF::ParkingLot::unparkOneImpl):
* wtf/ParkingLot.h:
(WTF::ParkingLot::parkConditionally):
(WTF::ParkingLot::unparkOne):
* wtf/ScopedLambda.h:
(WTF::scopedLambda):

Tools:

        
Added a test case. This test crashes before the fix and now it passes.

* TestWebKitAPI/CMakeLists.txt:
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WTF/ScopedLambda.cpp: Added.
(TestWebKitAPI::TEST):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWTFChangeLog">trunk/Source/WTF/ChangeLog</a></li>
<li><a href="#trunkSourceWTFwtfParkingLotcpp">trunk/Source/WTF/wtf/ParkingLot.cpp</a></li>
<li><a href="#trunkSourceWTFwtfParkingLoth">trunk/Source/WTF/wtf/ParkingLot.h</a></li>
<li><a href="#trunkSourceWTFwtfScopedLambdah">trunk/Source/WTF/wtf/ScopedLambda.h</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPICMakeListstxt">trunk/Tools/TestWebKitAPI/CMakeLists.txt</a></li>
<li><a href="#trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj">trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkToolsTestWebKitAPITestsWTFScopedLambdacpp">trunk/Tools/TestWebKitAPI/Tests/WTF/ScopedLambda.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWTFChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/ChangeLog (201432 => 201433)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/ChangeLog        2016-05-26 21:57:58 UTC (rev 201432)
+++ trunk/Source/WTF/ChangeLog        2016-05-26 21:58:42 UTC (rev 201433)
</span><span class="lines">@@ -1,3 +1,41 @@
</span><ins>+2016-05-26  Filip Pizlo  &lt;fpizlo@apple.com&gt;
+
+        ScopedLambda should have a lifetime story that makes sense to the compiler
+        https://bugs.webkit.org/show_bug.cgi?id=158118
+
+        Reviewed by Mark Lam.
+
+        Prior to this change, there were two lifetime bugs in ScopedLambda:
+        
+        - scopedLambda(Functor&amp;&amp;) would bind Functor to const lambda&amp;, so the resulting ScopedLambdaFunctor
+          would hold a reference to the original lambda. This would have surprising behavior; for example
+          it meant that this code was wrong:
+          
+          auto l = scopedLambda&lt;things&gt;([&amp;] ...);
+          
+          The solution is to have explicit copy/move versions of scopedLambda() rather than rely on perfect
+          forwarding.
+        
+        - ScopedLambdaFunctor did not override its copy or move operations, so if the compiler did not RVO
+          scopedLambda(), it would return a ScopedLambdaFunctor whose m_arg points to a dead temporary
+          ScopedLambdaFunctor instance. The solution is to have explicit copy/move constructors and
+          operators, which preserve the invariant that ScopedLambda::m_arg points to this.
+        
+        One nice side-effect of all of these constructors and operators being explicit is that we can rely
+        on WTFMove's excellent assertions, which helped catch the first issue.
+        
+        This reverts ParkingLot to use ScopedLambda again.
+
+        * wtf/ParkingLot.cpp:
+        (WTF::ParkingLot::parkConditionallyImpl):
+        (WTF::ParkingLot::unparkOne):
+        (WTF::ParkingLot::unparkOneImpl):
+        * wtf/ParkingLot.h:
+        (WTF::ParkingLot::parkConditionally):
+        (WTF::ParkingLot::unparkOne):
+        * wtf/ScopedLambda.h:
+        (WTF::scopedLambda):
+
</ins><span class="cx"> 2016-05-25  Anders Carlsson  &lt;andersca@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Get rid of WTF/Functional.h
</span></span></pre></div>
<a id="trunkSourceWTFwtfParkingLotcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/ParkingLot.cpp (201432 => 201433)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/ParkingLot.cpp        2016-05-26 21:57:58 UTC (rev 201432)
+++ trunk/Source/WTF/wtf/ParkingLot.cpp        2016-05-26 21:58:42 UTC (rev 201433)
</span><span class="lines">@@ -532,8 +532,8 @@
</span><span class="cx"> 
</span><span class="cx"> NEVER_INLINE bool ParkingLot::parkConditionallyImpl(
</span><span class="cx">     const void* address,
</span><del>-    std::function&lt;bool()&gt; validation,
-    std::function&lt;void()&gt; beforeSleep,
</del><ins>+    const ScopedLambda&lt;bool()&gt;&amp; validation,
+    const ScopedLambda&lt;void()&gt;&amp; beforeSleep,
</ins><span class="cx">     Clock::time_point timeout)
</span><span class="cx"> {
</span><span class="cx">     if (verbose)
</span><span class="lines">@@ -649,9 +649,9 @@
</span><span class="cx">     return result;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-NEVER_INLINE void ParkingLot::unparkOne(
</del><ins>+NEVER_INLINE void ParkingLot::unparkOneImpl(
</ins><span class="cx">     const void* address,
</span><del>-    std::function&lt;void(ParkingLot::UnparkResult)&gt; callback)
</del><ins>+    const ScopedLambda&lt;void(ParkingLot::UnparkResult)&gt;&amp; callback)
</ins><span class="cx"> {
</span><span class="cx">     if (verbose)
</span><span class="cx">         dataLog(toString(currentThread(), &quot;: unparking one the hard way.\n&quot;));
</span></span></pre></div>
<a id="trunkSourceWTFwtfParkingLoth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/ParkingLot.h (201432 => 201433)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/ParkingLot.h        2016-05-26 21:57:58 UTC (rev 201432)
+++ trunk/Source/WTF/wtf/ParkingLot.h        2016-05-26 21:58:42 UTC (rev 201433)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> #include &lt;chrono&gt;
</span><span class="cx"> #include &lt;functional&gt;
</span><span class="cx"> #include &lt;wtf/Atomics.h&gt;
</span><ins>+#include &lt;wtf/ScopedLambda.h&gt;
</ins><span class="cx"> #include &lt;wtf/Threading.h&gt;
</span><span class="cx"> 
</span><span class="cx"> namespace WTF {
</span><span class="lines">@@ -60,8 +61,8 @@
</span><span class="cx">     {
</span><span class="cx">         return parkConditionallyImpl(
</span><span class="cx">             address,
</span><del>-            std::function&lt;bool()&gt;(std::forward&lt;ValidationFunctor&gt;(validation)),
-            std::function&lt;void()&gt;(std::forward&lt;BeforeSleepFunctor&gt;(beforeSleep)),
</del><ins>+            scopedLambda&lt;bool()&gt;(std::forward&lt;ValidationFunctor&gt;(validation)),
+            scopedLambda&lt;void()&gt;(std::forward&lt;BeforeSleepFunctor&gt;(beforeSleep)),
</ins><span class="cx">             timeout);
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -100,9 +101,11 @@
</span><span class="cx">     // that race - see Rusty Russel's well-known usersem library - but it's not pretty. This form
</span><span class="cx">     // allows that race to be completely avoided, since there is no way that a thread can be parked
</span><span class="cx">     // while the callback is running.
</span><del>-    WTF_EXPORT_PRIVATE static void unparkOne(
-        const void* address,
-        std::function&lt;void(ParkingLot::UnparkResult)&gt; callback);
</del><ins>+    template&lt;typename Callback&gt;
+    static void unparkOne(const void* address, Callback&amp;&amp; callback)
+    {
+        unparkOneImpl(address, scopedLambda&lt;void(UnparkResult)&gt;(std::forward&lt;Callback&gt;(callback)));
+    }
</ins><span class="cx"> 
</span><span class="cx">     // Unparks every thread from the queue associated with the given address, which cannot be null.
</span><span class="cx">     WTF_EXPORT_PRIVATE static void unparkAll(const void* address);
</span><span class="lines">@@ -125,12 +128,12 @@
</span><span class="cx"> private:
</span><span class="cx">     WTF_EXPORT_PRIVATE static bool parkConditionallyImpl(
</span><span class="cx">         const void* address,
</span><del>-        std::function&lt;bool()&gt; validation,
-        std::function&lt;void()&gt; beforeSleep,
</del><ins>+        const ScopedLambda&lt;bool()&gt;&amp; validation,
+        const ScopedLambda&lt;void()&gt;&amp; beforeSleep,
</ins><span class="cx">         Clock::time_point timeout);
</span><span class="cx">     
</span><span class="cx">     WTF_EXPORT_PRIVATE static void unparkOneImpl(
</span><del>-        const void* address, std::function&lt;void(UnparkResult)&gt; callback);
</del><ins>+        const void* address, const ScopedLambda&lt;void(UnparkResult)&gt;&amp; callback);
</ins><span class="cx"> 
</span><span class="cx">     WTF_EXPORT_PRIVATE static void forEachImpl(const std::function&lt;void(ThreadIdentifier, const void*)&gt;&amp;);
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWTFwtfScopedLambdah"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/ScopedLambda.h (201432 => 201433)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/ScopedLambda.h        2016-05-26 21:57:58 UTC (rev 201432)
+++ trunk/Source/WTF/wtf/ScopedLambda.h        2016-05-26 21:58:42 UTC (rev 201433)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2015 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2015-2016 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -71,7 +71,33 @@
</span><span class="cx">         , m_functor(std::forward&lt;PassedFunctor&gt;(functor))
</span><span class="cx">     {
</span><span class="cx">     }
</span><ins>+    
+    // We need to make sure that copying and moving ScopedLambdaFunctor results in a ScopedLambdaFunctor
+    // whose ScopedLambda supertype still points to this rather than other.
+    ScopedLambdaFunctor(const ScopedLambdaFunctor&amp; other)
+        : ScopedLambda&lt;ResultType (ArgumentTypes...)&gt;(implFunction, this)
+        , m_functor(other.m_functor)
+    {
+    }
</ins><span class="cx"> 
</span><ins>+    ScopedLambdaFunctor(ScopedLambdaFunctor&amp;&amp; other)
+        : ScopedLambda&lt;ResultType (ArgumentTypes...)&gt;(implFunction, this)
+        , m_functor(WTFMove(other.m_functor))
+    {
+    }
+    
+    ScopedLambdaFunctor&amp; operator=(const ScopedLambdaFunctor&amp; other)
+    {
+        m_functor = other.m_functor;
+        return *this;
+    }
+    
+    ScopedLambdaFunctor&amp; operator=(ScopedLambdaFunctor&amp;&amp; other)
+    {
+        m_functor = WTFMove(other.m_functor);
+        return *this;
+    }
+
</ins><span class="cx"> private:
</span><span class="cx">     static ResultType implFunction(void* argument, ArgumentTypes... arguments)
</span><span class="cx">     {
</span><span class="lines">@@ -81,10 +107,23 @@
</span><span class="cx">     Functor m_functor;
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+// Can't simply rely on perfect forwarding because then the ScopedLambdaFunctor would point to the functor
+// by const reference. This would be surprising in situations like:
+//
+// auto scopedLambda = scopedLambda&lt;Foo(Bar)&gt;([&amp;] (Bar) -&gt; Foo { ... });
+//
+// We expected scopedLambda to be valid for its entire lifetime, but if it computed the lambda by reference
+// then it would be immediately invalid.
</ins><span class="cx"> template&lt;typename FunctionType, typename Functor&gt;
</span><ins>+ScopedLambdaFunctor&lt;FunctionType, Functor&gt; scopedLambda(const Functor&amp; functor)
+{
+    return ScopedLambdaFunctor&lt;FunctionType, Functor&gt;(functor);
+}
+
+template&lt;typename FunctionType, typename Functor&gt;
</ins><span class="cx"> ScopedLambdaFunctor&lt;FunctionType, Functor&gt; scopedLambda(Functor&amp;&amp; functor)
</span><span class="cx"> {
</span><del>-    return ScopedLambdaFunctor&lt;FunctionType, Functor&gt;(std::forward&lt;Functor&gt;(functor));
</del><ins>+    return ScopedLambdaFunctor&lt;FunctionType, Functor&gt;(WTFMove(functor));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace WTF
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (201432 => 201433)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2016-05-26 21:57:58 UTC (rev 201432)
+++ trunk/Tools/ChangeLog        2016-05-26 21:58:42 UTC (rev 201433)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2016-05-26  Filip Pizlo  &lt;fpizlo@apple.com&gt;
+
+        ScopedLambda should have a lifetime story that makes sense to the compiler
+        https://bugs.webkit.org/show_bug.cgi?id=158118
+
+        Reviewed by Mark Lam.
+        
+        Added a test case. This test crashes before the fix and now it passes.
+
+        * TestWebKitAPI/CMakeLists.txt:
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WTF/ScopedLambda.cpp: Added.
+        (TestWebKitAPI::TEST):
+
</ins><span class="cx"> 2016-05-26  Myles C. Maxfield  &lt;mmaxfield@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Build fix
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPICMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/CMakeLists.txt (201432 => 201433)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/CMakeLists.txt        2016-05-26 21:57:58 UTC (rev 201432)
+++ trunk/Tools/TestWebKitAPI/CMakeLists.txt        2016-05-26 21:58:42 UTC (rev 201433)
</span><span class="lines">@@ -67,6 +67,7 @@
</span><span class="cx">     ${TESTWEBKITAPI_DIR}/Tests/WTF/RefPtr.cpp
</span><span class="cx">     ${TESTWEBKITAPI_DIR}/Tests/WTF/SHA1.cpp
</span><span class="cx">     ${TESTWEBKITAPI_DIR}/Tests/WTF/SaturatedArithmeticOperations.cpp
</span><ins>+    ${TESTWEBKITAPI_DIR}/Tests/WTF/ScopedLambda.cpp
</ins><span class="cx">     ${TESTWEBKITAPI_DIR}/Tests/WTF/StringBuilder.cpp
</span><span class="cx">     ${TESTWEBKITAPI_DIR}/Tests/WTF/StringHasher.cpp
</span><span class="cx">     ${TESTWEBKITAPI_DIR}/Tests/WTF/StringImpl.cpp
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (201432 => 201433)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2016-05-26 21:57:58 UTC (rev 201432)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2016-05-26 21:58:42 UTC (rev 201433)
</span><span class="lines">@@ -369,6 +369,7 @@
</span><span class="cx">                 CE50D8CA1C8665CE0072EA5A /* OptionSet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CE50D8C81C8665CE0072EA5A /* OptionSet.cpp */; };
</span><span class="cx">                 CEA6CF2819CCF69D0064F5A7 /* open-and-close-window.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CEA6CF2719CCF69D0064F5A7 /* open-and-close-window.html */; };
</span><span class="cx">                 CEBABD491B71687C0051210A /* should-open-external-schemes.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CEBABD481B71687C0051210A /* should-open-external-schemes.html */; };
</span><ins>+                DC69AA641CF77C7D00C6272F /* ScopedLambda.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DC69AA621CF77C6500C6272F /* ScopedLambda.cpp */; settings = {COMPILER_FLAGS = &quot;-fno-elide-constructors&quot;; }; };
</ins><span class="cx">                 E1220DCA155B28AA0013E2FC /* MemoryCacheDisableWithinResourceLoadDelegate.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = E1220DC9155B287D0013E2FC /* MemoryCacheDisableWithinResourceLoadDelegate.html */; };
</span><span class="cx">                 E194E1BD177E53C7009C4D4E /* StopLoadingFromDidReceiveResponse.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = E194E1BC177E534A009C4D4E /* StopLoadingFromDidReceiveResponse.html */; };
</span><span class="cx">                 E19DB9791B32137C00DB38D4 /* NavigatorLanguage.mm in Sources */ = {isa = PBXBuildFile; fileRef = E19DB9781B32137C00DB38D4 /* NavigatorLanguage.mm */; };
</span><span class="lines">@@ -906,6 +907,7 @@
</span><span class="cx">                 CEA6CF2219CCF5BD0064F5A7 /* OpenAndCloseWindow.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = OpenAndCloseWindow.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 CEA6CF2719CCF69D0064F5A7 /* open-and-close-window.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = &quot;open-and-close-window.html&quot;; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 CEBABD481B71687C0051210A /* should-open-external-schemes.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = &quot;should-open-external-schemes.html&quot;; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                DC69AA621CF77C6500C6272F /* ScopedLambda.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScopedLambda.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 E1220D9F155B25480013E2FC /* MemoryCacheDisableWithinResourceLoadDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MemoryCacheDisableWithinResourceLoadDelegate.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 E1220DC9155B287D0013E2FC /* MemoryCacheDisableWithinResourceLoadDelegate.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = MemoryCacheDisableWithinResourceLoadDelegate.html; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 E194E1BA177E5145009C4D4E /* StopLoadingFromDidReceiveResponse.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = StopLoadingFromDidReceiveResponse.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -1372,6 +1374,7 @@
</span><span class="cx">                                 93A427A8180D9B0700CD24D7 /* RefPtr.cpp */,
</span><span class="cx">                                 E4C9ABC71B3DB1710040A987 /* RunLoop.cpp */,
</span><span class="cx">                                 14F3B11215E45EAB00210069 /* SaturatedArithmeticOperations.cpp */,
</span><ins>+                                DC69AA621CF77C6500C6272F /* ScopedLambda.cpp */,
</ins><span class="cx">                                 CD5393C91757BAC400C07123 /* SHA1.cpp */,
</span><span class="cx">                                 81B50192140F232300D9EB58 /* StringBuilder.cpp */,
</span><span class="cx">                                 93ABA80816DDAB91002DB2FA /* StringHasher.cpp */,
</span><span class="lines">@@ -1905,6 +1908,7 @@
</span><span class="cx">                                 7CCE7F2C1A411B1000447C4C /* PreventImageLoadWithAutoResizing.mm in Sources */,
</span><span class="cx">                                 7CCE7F0C1A411AE600447C4C /* PrivateBrowsingPushStateNoHistoryCallback.cpp in Sources */,
</span><span class="cx">                                 7CCE7EC81A411A7E00447C4C /* PublicSuffix.mm in Sources */,
</span><ins>+                                DC69AA641CF77C7D00C6272F /* ScopedLambda.cpp in Sources */,
</ins><span class="cx">                                 7CCE7F3E1A411B8E00447C4C /* RedBlackTree.cpp in Sources */,
</span><span class="cx">                                 7CCE7F3F1A411B8E00447C4C /* Ref.cpp in Sources */,
</span><span class="cx">                                 7CCE7F401A411B8E00447C4C /* RefCounter.cpp in Sources */,
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWTFScopedLambdacpp"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/WTF/ScopedLambda.cpp (0 => 201433)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WTF/ScopedLambda.cpp                                (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/ScopedLambda.cpp        2016-05-26 21:58:42 UTC (rev 201433)
</span><span class="lines">@@ -0,0 +1,51 @@
</span><ins>+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include &quot;config.h&quot;
+#include &lt;wtf/ScopedLambda.h&gt;
+#include &lt;wtf/Vector.h&gt;
+
+using namespace WTF;
+
+namespace TestWebKitAPI {
+
+// This test relies on this module being compiled with -fno-elide-constructors
+TEST(WTF_ScopedLambda, NoRVOLivenessBug)
+{
+    Vector&lt;int&gt; vector;
+    for (unsigned i = 0; i &lt; 10; ++i)
+        vector.append(i);
+    
+    auto lambda = scopedLambda&lt;int(size_t)&gt;(
+        [=] (size_t i) -&gt; int {
+            return vector[i];
+        });
+    
+    for (unsigned i = 0; i &lt; 10; ++i)
+        EXPECT_EQ(i, static_cast&lt;unsigned&gt;(lambda(i)));
+}
+
+} // namespace TestWebKitAPI
+
</ins></span></pre>
</div>
</div>

</body>
</html>