<!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>[55679] trunk/JavaScriptCore</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/55679">55679</a></dd>
<dt>Author</dt> <dd>barraclough@apple.com</dd>
<dt>Date</dt> <dd>2010-03-08 12:31:02 -0800 (Mon, 08 Mar 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>Reverting 55035, this caused a regression.
(https://bugs.webkit.org/show_bug.cgi?id=35843)

Reviewed by NOBODY (reverting regression).

* runtime/JSString.cpp:
(JSC::JSString::resolveRope):
(JSC::JSString::getStringPropertyDescriptor):
* runtime/JSString.h:
(JSC::jsSingleCharacterSubstring):
(JSC::JSString::getIndex):
(JSC::JSString::getStringPropertySlot):
* runtime/UStringImpl.cpp:
* runtime/UStringImpl.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkJavaScriptCoreChangeLog">trunk/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkJavaScriptCoreruntimeJSStringcpp">trunk/JavaScriptCore/runtime/JSString.cpp</a></li>
<li><a href="#trunkJavaScriptCoreruntimeJSStringh">trunk/JavaScriptCore/runtime/JSString.h</a></li>
<li><a href="#trunkJavaScriptCoreruntimeUStringImplcpp">trunk/JavaScriptCore/runtime/UStringImpl.cpp</a></li>
<li><a href="#trunkJavaScriptCoreruntimeUStringImplh">trunk/JavaScriptCore/runtime/UStringImpl.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/JavaScriptCore/ChangeLog (55678 => 55679)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JavaScriptCore/ChangeLog        2010-03-08 20:22:09 UTC (rev 55678)
+++ trunk/JavaScriptCore/ChangeLog        2010-03-08 20:31:02 UTC (rev 55679)
</span><span class="lines">@@ -1,3 +1,20 @@
</span><ins>+2010-03-08  Gavin Barraclough  &lt;barraclough@apple.com&gt;
+
+        Reviewed by NOBODY (reverting regression).
+
+        Reverting 55035, this caused a regression.
+        (https://bugs.webkit.org/show_bug.cgi?id=35843)
+
+        * runtime/JSString.cpp:
+        (JSC::JSString::resolveRope):
+        (JSC::JSString::getStringPropertyDescriptor):
+        * runtime/JSString.h:
+        (JSC::jsSingleCharacterSubstring):
+        (JSC::JSString::getIndex):
+        (JSC::JSString::getStringPropertySlot):
+        * runtime/UStringImpl.cpp:
+        * runtime/UStringImpl.h:
+
</ins><span class="cx"> 2010-03-08  Stuart Morgan  &lt;stuartmorgan@chromium.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Reviewed by Darin Adler.
</span></span></pre></div>
<a id="trunkJavaScriptCoreruntimeJSStringcpp"></a>
<div class="modfile"><h4>Modified: trunk/JavaScriptCore/runtime/JSString.cpp (55678 => 55679)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JavaScriptCore/runtime/JSString.cpp        2010-03-08 20:22:09 UTC (rev 55678)
+++ trunk/JavaScriptCore/runtime/JSString.cpp        2010-03-08 20:31:02 UTC (rev 55679)
</span><span class="lines">@@ -50,6 +50,13 @@
</span><span class="cx">     if (PassRefPtr&lt;UStringImpl&gt; newImpl = UStringImpl::tryCreateUninitialized(m_length, buffer))
</span><span class="cx">         m_value = newImpl;
</span><span class="cx">     else {
</span><ins>+        for (unsigned i = 0; i &lt; m_fiberCount; ++i) {
+            m_other.m_fibers[i]-&gt;deref();
+            m_other.m_fibers[i] = 0;
+        }
+        m_fiberCount = 0;
+        ASSERT(!isRope());
+        ASSERT(m_value == UString());
</ins><span class="cx">         throwOutOfMemoryError(exec);
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="lines">@@ -180,7 +187,7 @@
</span><span class="cx">     bool isStrictUInt32;
</span><span class="cx">     unsigned i = propertyName.toStrictUInt32(&amp;isStrictUInt32);
</span><span class="cx">     if (isStrictUInt32 &amp;&amp; i &lt; m_length) {
</span><del>-        descriptor.setDescriptor(getIndex(exec, i), DontDelete | ReadOnly);
</del><ins>+        descriptor.setDescriptor(jsSingleCharacterSubstring(exec, value(exec), i), DontDelete | ReadOnly);
</ins><span class="cx">         return true;
</span><span class="cx">     }
</span><span class="cx">     
</span></span></pre></div>
<a id="trunkJavaScriptCoreruntimeJSStringh"></a>
<div class="modfile"><h4>Modified: trunk/JavaScriptCore/runtime/JSString.h (55678 => 55679)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JavaScriptCore/runtime/JSString.h        2010-03-08 20:22:09 UTC (rev 55678)
+++ trunk/JavaScriptCore/runtime/JSString.h        2010-03-08 20:31:02 UTC (rev 55679)
</span><span class="lines">@@ -41,6 +41,7 @@
</span><span class="cx"> 
</span><span class="cx">     JSString* jsSingleCharacterString(JSGlobalData*, UChar);
</span><span class="cx">     JSString* jsSingleCharacterString(ExecState*, UChar);
</span><ins>+    JSString* jsSingleCharacterSubstring(JSGlobalData*, const UString&amp;, unsigned offset);
</ins><span class="cx">     JSString* jsSingleCharacterSubstring(ExecState*, const UString&amp;, unsigned offset);
</span><span class="cx">     JSString* jsSubstring(JSGlobalData*, const UString&amp;, unsigned offset, unsigned length);
</span><span class="cx">     JSString* jsSubstring(ExecState*, const UString&amp;, unsigned offset, unsigned length);
</span><span class="lines">@@ -364,10 +365,8 @@
</span><span class="cx">         return fixupVPtr(globalData, new (globalData) JSString(globalData, UString(&amp;c, 1)));
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    inline JSString* jsSingleCharacterSubstring(ExecState* exec, const UString&amp; s, unsigned offset)
</del><ins>+    inline JSString* jsSingleCharacterSubstring(JSGlobalData* globalData, const UString&amp; s, unsigned offset)
</ins><span class="cx">     {
</span><del>-        JSGlobalData* globalData = &amp;exec-&gt;globalData();
-
</del><span class="cx">         ASSERT(offset &lt; static_cast&lt;unsigned&gt;(s.size()));
</span><span class="cx">         UChar c = s.data()[offset];
</span><span class="cx">         if (c &lt;= 0xFF)
</span><span class="lines">@@ -392,21 +391,7 @@
</span><span class="cx">     inline JSString* JSString::getIndex(ExecState* exec, unsigned i)
</span><span class="cx">     {
</span><span class="cx">         ASSERT(canGetIndex(i));
</span><del>-        if (!isRope())
-            return jsSingleCharacterSubstring(exec, m_value, i);
-
-        if (i &lt; m_other.m_fibers[0]-&gt;length())
-            return jsString(exec, singleCharacterSubstring(m_other.m_fibers[0], i));
-        i -= m_other.m_fibers[0]-&gt;length();
-
-        ASSERT(m_fiberCount &gt;= 2);
-        if (i &lt; m_other.m_fibers[1]-&gt;length())
-            return jsString(exec, singleCharacterSubstring(m_other.m_fibers[1], i));
-        i -= m_other.m_fibers[1]-&gt;length();
-
-        ASSERT(m_fiberCount == 3);
-        ASSERT(i &lt; m_other.m_fibers[2]-&gt;length());
-        return jsString(exec, singleCharacterSubstring(m_other.m_fibers[2], i));
</del><ins>+        return jsSingleCharacterSubstring(&amp;exec-&gt;globalData(), value(exec), i);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     inline JSString* jsString(JSGlobalData* globalData, const UString&amp; s)
</span><span class="lines">@@ -460,6 +445,7 @@
</span><span class="cx">     inline JSString* jsEmptyString(ExecState* exec) { return jsEmptyString(&amp;exec-&gt;globalData()); }
</span><span class="cx">     inline JSString* jsString(ExecState* exec, const UString&amp; s) { return jsString(&amp;exec-&gt;globalData(), s); }
</span><span class="cx">     inline JSString* jsSingleCharacterString(ExecState* exec, UChar c) { return jsSingleCharacterString(&amp;exec-&gt;globalData(), c); }
</span><ins>+    inline JSString* jsSingleCharacterSubstring(ExecState* exec, const UString&amp; s, unsigned offset) { return jsSingleCharacterSubstring(&amp;exec-&gt;globalData(), s, offset); }
</ins><span class="cx">     inline JSString* jsSubstring(ExecState* exec, const UString&amp; s, unsigned offset, unsigned length) { return jsSubstring(&amp;exec-&gt;globalData(), s, offset, length); }
</span><span class="cx">     inline JSString* jsNontrivialString(ExecState* exec, const UString&amp; s) { return jsNontrivialString(&amp;exec-&gt;globalData(), s); }
</span><span class="cx">     inline JSString* jsNontrivialString(ExecState* exec, const char* s) { return jsNontrivialString(&amp;exec-&gt;globalData(), s); }
</span><span class="lines">@@ -475,7 +461,7 @@
</span><span class="cx">         bool isStrictUInt32;
</span><span class="cx">         unsigned i = propertyName.toStrictUInt32(&amp;isStrictUInt32);
</span><span class="cx">         if (isStrictUInt32 &amp;&amp; i &lt; m_length) {
</span><del>-            slot.setValue(getIndex(exec, i));
</del><ins>+            slot.setValue(jsSingleCharacterSubstring(exec, value(exec), i));
</ins><span class="cx">             return true;
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="lines">@@ -485,7 +471,7 @@
</span><span class="cx">     ALWAYS_INLINE bool JSString::getStringPropertySlot(ExecState* exec, unsigned propertyName, PropertySlot&amp; slot)
</span><span class="cx">     {
</span><span class="cx">         if (propertyName &lt; m_length) {
</span><del>-            slot.setValue(getIndex(exec, propertyName));
</del><ins>+            slot.setValue(jsSingleCharacterSubstring(exec, value(exec), propertyName));
</ins><span class="cx">             return true;
</span><span class="cx">         }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkJavaScriptCoreruntimeUStringImplcpp"></a>
<div class="modfile"><h4>Modified: trunk/JavaScriptCore/runtime/UStringImpl.cpp (55678 => 55679)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JavaScriptCore/runtime/UStringImpl.cpp        2010-03-08 20:22:09 UTC (rev 55678)
+++ trunk/JavaScriptCore/runtime/UStringImpl.cpp        2010-03-08 20:31:02 UTC (rev 55679)
</span><span class="lines">@@ -149,24 +149,4 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-PassRefPtr&lt;UStringImpl&gt; singleCharacterSubstring(UStringOrRopeImpl* impl, unsigned index)
-{
-top:
-    if (impl-&gt;isRope()) {
-        URopeImpl* rope = static_cast&lt;URopeImpl*&gt;(impl);
-        for (unsigned i = 0; i &lt; rope-&gt;m_fiberCount; ++i) {
-            UStringOrRopeImpl* currentFiber = rope-&gt;fibers(i);
-            unsigned fiberLength = currentFiber-&gt;length();
-            if (index &lt; fiberLength) {
-                impl = currentFiber;
-                goto top;
-            }
-            index -= fiberLength;
-        }
-        CRASH();
-    }
-
-    return static_cast&lt;UStringImpl*&gt;(impl)-&gt;singleCharacterSubstring(index);
-}
-
</del><span class="cx"> } // namespace JSC
</span></span></pre></div>
<a id="trunkJavaScriptCoreruntimeUStringImplh"></a>
<div class="modfile"><h4>Modified: trunk/JavaScriptCore/runtime/UStringImpl.h (55678 => 55679)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JavaScriptCore/runtime/UStringImpl.h        2010-03-08 20:22:09 UTC (rev 55678)
+++ trunk/JavaScriptCore/runtime/UStringImpl.h        2010-03-08 20:31:02 UTC (rev 55679)
</span><span class="lines">@@ -213,8 +213,6 @@
</span><span class="cx">         ASSERT(!isStatic() || !isIdentifier());
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    PassRefPtr&lt;UStringImpl&gt; singleCharacterSubstring(unsigned index) { ASSERT(index &lt; length()); return create(this, index, 1); }
-
</del><span class="cx"> private:
</span><span class="cx">     // For SmallStringStorage, which allocates an array and uses an in-place new.
</span><span class="cx">     UStringImpl() { }
</span><span class="lines">@@ -345,7 +343,6 @@
</span><span class="cx">     Fiber m_fibers[1];
</span><span class="cx"> 
</span><span class="cx">     friend class UStringOrRopeImpl;
</span><del>-    friend PassRefPtr&lt;UStringImpl&gt; singleCharacterSubstring(UStringOrRopeImpl* ropeoid, unsigned index);
</del><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> inline void UStringOrRopeImpl::deref()
</span><span class="lines">@@ -358,8 +355,6 @@
</span><span class="cx"> 
</span><span class="cx"> bool equal(const UStringImpl*, const UStringImpl*);
</span><span class="cx"> 
</span><del>-PassRefPtr&lt;UStringImpl&gt; singleCharacterSubstring(UStringOrRopeImpl* ropeoid, unsigned index);
-
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #endif
</span></span></pre>
</div>
</div>

</body>
</html>