<!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>[202597] 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/202597">202597</a></dd>
<dt>Author</dt> <dd>msaboff@apple.com</dd>
<dt>Date</dt> <dd>2016-06-28 17:38:58 -0700 (Tue, 28 Jun 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>REGRESSION (<a href="http://trac.webkit.org/projects/webkit/changeset/200946">r200946</a>): Improper backtracking from last alternative in sticky patterns
https://bugs.webkit.org/show_bug.cgi?id=159233

Reviewed by Mark Lam.

Source/JavaScriptCore:

Jump to fail exit code when the last alternative of a sticky pattern fails.

* yarr/YarrJIT.cpp:
(JSC::Yarr::YarrGenerator::backtrack):

LayoutTests:

Updated tests.

* js/regexp-sticky-expected.txt:
* js/script-tests/regexp-sticky.js:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsjsregexpstickyexpectedtxt">trunk/LayoutTests/js/regexp-sticky-expected.txt</a></li>
<li><a href="#trunkLayoutTestsjsscripttestsregexpstickyjs">trunk/LayoutTests/js/script-tests/regexp-sticky.js</a></li>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreyarrYarrJITcpp">trunk/Source/JavaScriptCore/yarr/YarrJIT.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (202596 => 202597)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-06-29 00:18:34 UTC (rev 202596)
+++ trunk/LayoutTests/ChangeLog        2016-06-29 00:38:58 UTC (rev 202597)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2016-06-28  Michael Saboff  &lt;msaboff@apple.com&gt;
+
+        REGRESSION (r200946): Improper backtracking from last alternative in sticky patterns
+        https://bugs.webkit.org/show_bug.cgi?id=159233
+
+        Reviewed by Mark Lam.
+
+        Updated tests.
+
+        * js/regexp-sticky-expected.txt:
+        * js/script-tests/regexp-sticky.js:
+
</ins><span class="cx"> 2016-06-28  Ryan Haddad  &lt;ryanhaddad@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Marking fast/images/composited-animated-gif-outside-viewport.html as flaky on ios-simulator
</span></span></pre></div>
<a id="trunkLayoutTestsjsregexpstickyexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/js/regexp-sticky-expected.txt (202596 => 202597)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/regexp-sticky-expected.txt        2016-06-29 00:18:34 UTC (rev 202596)
+++ trunk/LayoutTests/js/regexp-sticky-expected.txt        2016-06-29 00:38:58 UTC (rev 202597)
</span><span class="lines">@@ -26,10 +26,12 @@
</span><span class="cx"> PASS Unmatched Greedy
</span><span class="cx"> PASS Global Flag - exec
</span><span class="cx"> PASS Global Flag - match
</span><ins>+PASS Global Flag - Alternates, long to short
</ins><span class="cx"> PASS Unicode Flag - Any Character
</span><span class="cx"> PASS Unicode &amp; Ignore Case Flags
</span><span class="cx"> PASS Multiline
</span><span class="cx"> PASS Multiline with BOL Anchor
</span><ins>+PASS Multiline with EOL Anchor at start of Alternative
</ins><span class="cx"> PASS &quot;123 1234 &quot;.search(re) is 0
</span><span class="cx"> PASS &quot;123 1234 &quot;.search(re) is 0
</span><span class="cx"> PASS &quot; 123 1234 &quot;.search(re) is -1
</span></span></pre></div>
<a id="trunkLayoutTestsjsscripttestsregexpstickyjs"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/js/script-tests/regexp-sticky.js (202596 => 202597)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/script-tests/regexp-sticky.js        2016-06-29 00:18:34 UTC (rev 202596)
+++ trunk/LayoutTests/js/script-tests/regexp-sticky.js        2016-06-29 00:38:58 UTC (rev 202597)
</span><span class="lines">@@ -92,10 +92,12 @@
</span><span class="cx"> testStickyExec(&quot;Unmatched Greedy&quot;, /^\s*|\s*$/y, &quot;ab&quot;, 1, [null]);
</span><span class="cx"> testStickyExec(&quot;Global Flag - exec&quot;, /\s*(\+|[0-9]+)\s*/gy, &quot;3 + 4&quot;, 0, [&quot;3 ,3&quot;, &quot;+ ,+&quot;, &quot;4,4&quot;, null]);
</span><span class="cx"> testStickyMatch(&quot;Global Flag - match&quot;, /\s*(\+|[0-9]+)\s*/gy, &quot;3 + 4&quot;, 0, [[&quot;3 &quot;, &quot;+ &quot;, &quot;4&quot;], [&quot;3 &quot;, &quot;+ &quot;, &quot;4&quot;]]);
</span><ins>+testStickyMatch(&quot;Global Flag - Alternates, long to short&quot;, /x.|[\d]/gy, &quot;.a&quot;, 0, [null]);
</ins><span class="cx"> testStickyExec(&quot;Unicode Flag - Any Character&quot;, /./uy, &quot;a@\u{10402}1\u202a\u{12345}&quot;, 0, [&quot;a&quot;, &quot;@&quot;, &quot;\u{10402}&quot;, &quot;1&quot;, &quot;\u202a&quot;, &quot;\u{12345}&quot;, null]);
</span><span class="cx"> testStickyMatch(&quot;Unicode &amp; Ignore Case Flags&quot;, /(?:\u{118c0}|\u{10cb0}|\w):/iuy, &quot;a:\u{118a0}:x:\u{10cb0}&quot;, 0, [[&quot;a:&quot;], [&quot;\u{118a0}:&quot;], [&quot;x:&quot;], null]);
</span><span class="cx"> testStickyExec(&quot;Multiline&quot;, /(?:\w+ *)+(?:\n|$)/my, &quot;Line One\nLine Two&quot;, 0, [&quot;Line One\n&quot;, &quot;Line Two&quot;, null]);
</span><span class="cx"> testStickyMatch(&quot;Multiline with BOL Anchor&quot;, /^\d*\s?/my, &quot;13574\n295\n99&quot;, 0, [[&quot;13574\n&quot;], [&quot;295\n&quot;], [&quot;99&quot;], null]);
</span><ins>+testStickyExec(&quot;Multiline with EOL Anchor at start of Alternative&quot;, /.{2}|(?=$)./my, &quot;\n&quot;, 0, [null]);
</ins><span class="cx"> 
</span><span class="cx"> // Verify that String.search starts at 0 even with the sticky flag.
</span><span class="cx"> var re = new RegExp(&quot;\\d+\\s&quot;, &quot;y&quot;);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (202596 => 202597)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2016-06-29 00:18:34 UTC (rev 202596)
+++ trunk/Source/JavaScriptCore/ChangeLog        2016-06-29 00:38:58 UTC (rev 202597)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2016-06-28  Michael Saboff  &lt;msaboff@apple.com&gt;
+
+        REGRESSION (r200946): Improper backtracking from last alternative in sticky patterns
+        https://bugs.webkit.org/show_bug.cgi?id=159233
+
+        Reviewed by Mark Lam.
+
+        Jump to fail exit code when the last alternative of a sticky pattern fails.
+
+        * yarr/YarrJIT.cpp:
+        (JSC::Yarr::YarrGenerator::backtrack):
+
</ins><span class="cx"> 2016-06-28  Saam Barati  &lt;sbarati@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         some Watchpoints' ::fireInternal method will call operations that might GC where the GC will cause the watchpoint itself to destruct
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreyarrYarrJITcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/yarr/YarrJIT.cpp (202596 => 202597)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/yarr/YarrJIT.cpp        2016-06-29 00:18:34 UTC (rev 202596)
+++ trunk/Source/JavaScriptCore/yarr/YarrJIT.cpp        2016-06-29 00:38:58 UTC (rev 202597)
</span><span class="lines">@@ -1828,6 +1828,8 @@
</span><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 bool onceThrough = endOp.m_nextOp == notFound;
</span><ins>+                
+                JumpList lastStickyAlternativeFailures;
</ins><span class="cx"> 
</span><span class="cx">                 // First, generate code to handle cases where we backtrack out of an attempted match
</span><span class="cx">                 // of the last alternative. If this is a 'once through' set of alternatives then we
</span><span class="lines">@@ -1843,12 +1845,15 @@
</span><span class="cx">                         &amp;&amp; (alternative-&gt;m_minimumSize &gt; beginOp-&gt;m_alternative-&gt;m_minimumSize)
</span><span class="cx">                         &amp;&amp; (alternative-&gt;m_minimumSize - beginOp-&gt;m_alternative-&gt;m_minimumSize == 1))
</span><span class="cx">                         m_backtrackingState.linkTo(beginOp-&gt;m_reentry, this);
</span><del>-                    else {
</del><ins>+                    else if (m_pattern.sticky() &amp;&amp; m_ops[op.m_nextOp].m_op == OpBodyAlternativeEnd) {
+                        // It is a sticky pattern and the last alternative failed, jump to the end.
+                        m_backtrackingState.takeBacktracksToJumpList(lastStickyAlternativeFailures, this);
+                    } else {
</ins><span class="cx">                         // We need to generate a trampoline of code to execute before looping back
</span><span class="cx">                         // around to the first alternative.
</span><span class="cx">                         m_backtrackingState.link(this);
</span><span class="cx"> 
</span><del>-                        // No need to advance and retry for a stick pattern.
</del><ins>+                        // No need to advance and retry for a sticky pattern.
</ins><span class="cx">                         if (!m_pattern.sticky()) {
</span><span class="cx">                             // If the pattern size is not fixed, then store the start index for use if we match.
</span><span class="cx">                             if (!m_pattern.m_body-&gt;m_hasFixedSize) {
</span><span class="lines">@@ -1998,6 +2003,8 @@
</span><span class="cx">                     // run any matches, and need to return a failure state from JIT code.
</span><span class="cx">                     matchFailed.link(this);
</span><span class="cx">                 }
</span><ins>+
+                lastStickyAlternativeFailures.link(this);
</ins><span class="cx">                 removeCallFrame();
</span><span class="cx">                 generateFailReturn();
</span><span class="cx">                 break;
</span></span></pre>
</div>
</div>

</body>
</html>