<!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>[55943] 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/55943">55943</a></dd>
<dt>Author</dt> <dd>barraclough@apple.com</dd>
<dt>Date</dt> <dd>2010-03-12 15:49:05 -0800 (Fri, 12 Mar 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>Bug 36075 - Clean up screwyness re static string impls &amp; Identifiers.

Reviewed by Oliver Hunt.

JavaScriptCore: 

* API/JSClassRef.cpp:
(OpaqueJSClass::~OpaqueJSClass): Classname may be null/empty, and these are an identifer.  This is okay, since the null/empty strings are shared across all threads.
* JavaScriptCore.exp:
* runtime/Identifier.cpp:
(JSC::Identifier::add): No need to explicitly hash null reps, this is done in the ststic UStringImpl constructor.
(JSC::Identifier::addSlowCase): UStringImpl::empty() handled &amp; checkCurrentIdentifierTable now called in the header.
(JSC::Identifier::checkCurrentIdentifierTable): Replaces checkSameIdentifierTable (this no longer checked the rep since the identifierTable pointer was removed from UString::Rep long ago).
* runtime/Identifier.h:
(JSC::Identifier::add): Replace call to checkSameIdentifierTable with call to checkCurrentIdentifierTable at head of function.
* runtime/UStringImpl.cpp:
(JSC::UStringImpl::~UStringImpl): Remove call to checkConsistency - this function no longer checks anything interesting.
* runtime/UStringImpl.h:
(JSC::UStringOrRopeImpl::UStringOrRopeImpl): Set s_refCountFlagIsIdentifier in static constructor.
(JSC::UStringImpl::UStringImpl): remove calls to checkConsistency (see above), add new ASSERT to substring constructor.
(JSC::UStringImpl::setHash): ASSERT not static (static strings set the hash in their constructor, should not reach this code path).
(JSC::UStringImpl::create): Add missing ASSERT.
(JSC::UStringImpl::setIsIdentifier): ASSERT !isStatic() (static strings hash set in constructor).

WebCore: 

* platform/text/StringImpl.cpp:
(WebCore::StringImpl::~StringImpl): Add ASSERT
(WebCore::StringImpl::sharedBuffer): Add ASSERT
* platform/text/StringImpl.h:
(WebCore::StringImpl::setHash): Add ASSERT
(WebCore::StringImpl::isStatic): added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkJavaScriptCoreAPIJSClassRefcpp">trunk/JavaScriptCore/API/JSClassRef.cpp</a></li>
<li><a href="#trunkJavaScriptCoreChangeLog">trunk/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkJavaScriptCoreJavaScriptCoreexp">trunk/JavaScriptCore/JavaScriptCore.exp</a></li>
<li><a href="#trunkJavaScriptCoreruntimeIdentifiercpp">trunk/JavaScriptCore/runtime/Identifier.cpp</a></li>
<li><a href="#trunkJavaScriptCoreruntimeIdentifierh">trunk/JavaScriptCore/runtime/Identifier.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>
<li><a href="#trunkWebCoreChangeLog">trunk/WebCore/ChangeLog</a></li>
<li><a href="#trunkWebCoreplatformtextStringImplcpp">trunk/WebCore/platform/text/StringImpl.cpp</a></li>
<li><a href="#trunkWebCoreplatformtextStringImplh">trunk/WebCore/platform/text/StringImpl.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkJavaScriptCoreAPIJSClassRefcpp"></a>
<div class="modfile"><h4>Modified: trunk/JavaScriptCore/API/JSClassRef.cpp (55942 => 55943)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JavaScriptCore/API/JSClassRef.cpp        2010-03-12 23:17:12 UTC (rev 55942)
+++ trunk/JavaScriptCore/API/JSClassRef.cpp        2010-03-12 23:49:05 UTC (rev 55943)
</span><span class="lines">@@ -111,7 +111,8 @@
</span><span class="cx"> 
</span><span class="cx"> OpaqueJSClass::~OpaqueJSClass()
</span><span class="cx"> {
</span><del>-    ASSERT(!m_className.rep()-&gt;isIdentifier());
</del><ins>+    // The empty string is shared across threads &amp; is an identifier, in all other cases we should have done a deep copy in className(), below. 
+    ASSERT(!m_className.size() || !m_className.rep()-&gt;isIdentifier());
</ins><span class="cx"> 
</span><span class="cx">     if (m_staticValues) {
</span><span class="cx">         OpaqueJSClassStaticValuesTable::const_iterator end = m_staticValues-&gt;end();
</span></span></pre></div>
<a id="trunkJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/JavaScriptCore/ChangeLog (55942 => 55943)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JavaScriptCore/ChangeLog        2010-03-12 23:17:12 UTC (rev 55942)
+++ trunk/JavaScriptCore/ChangeLog        2010-03-12 23:49:05 UTC (rev 55943)
</span><span class="lines">@@ -1,3 +1,27 @@
</span><ins>+2010-03-11  Gavin Barraclough  &lt;barraclough@apple.com&gt;
+
+        Reviewed by Oliver Hunt.
+
+        Bug 36075 - Clean up screwyness re static string impls &amp; Identifiers.
+
+        * API/JSClassRef.cpp:
+        (OpaqueJSClass::~OpaqueJSClass): Classname may be null/empty, and these are an identifer.  This is okay, since the null/empty strings are shared across all threads.
+        * JavaScriptCore.exp:
+        * runtime/Identifier.cpp:
+        (JSC::Identifier::add): No need to explicitly hash null reps, this is done in the ststic UStringImpl constructor.
+        (JSC::Identifier::addSlowCase): UStringImpl::empty() handled &amp; checkCurrentIdentifierTable now called in the header.
+        (JSC::Identifier::checkCurrentIdentifierTable): Replaces checkSameIdentifierTable (this no longer checked the rep since the identifierTable pointer was removed from UString::Rep long ago).
+        * runtime/Identifier.h:
+        (JSC::Identifier::add): Replace call to checkSameIdentifierTable with call to checkCurrentIdentifierTable at head of function.
+        * runtime/UStringImpl.cpp:
+        (JSC::UStringImpl::~UStringImpl): Remove call to checkConsistency - this function no longer checks anything interesting.
+        * runtime/UStringImpl.h:
+        (JSC::UStringOrRopeImpl::UStringOrRopeImpl): Set s_refCountFlagIsIdentifier in static constructor.
+        (JSC::UStringImpl::UStringImpl): remove calls to checkConsistency (see above), add new ASSERT to substring constructor.
+        (JSC::UStringImpl::setHash): ASSERT not static (static strings set the hash in their constructor, should not reach this code path).
+        (JSC::UStringImpl::create): Add missing ASSERT.
+        (JSC::UStringImpl::setIsIdentifier): ASSERT !isStatic() (static strings hash set in constructor).
+
</ins><span class="cx"> 2010-03-12  Peter Varga  &lt;pvarga@inf.u-szeged.hu&gt;
</span><span class="cx"> 
</span><span class="cx">         Reviewed by David Levin.
</span></span></pre></div>
<a id="trunkJavaScriptCoreJavaScriptCoreexp"></a>
<div class="modfile"><h4>Modified: trunk/JavaScriptCore/JavaScriptCore.exp (55942 => 55943)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JavaScriptCore/JavaScriptCore.exp        2010-03-12 23:17:12 UTC (rev 55942)
+++ trunk/JavaScriptCore/JavaScriptCore.exp        2010-03-12 23:49:05 UTC (rev 55943)
</span><span class="lines">@@ -92,8 +92,8 @@
</span><span class="cx"> __ZN14OpaqueJSString6createERKN3JSC7UStringE
</span><span class="cx"> __ZN3JSC10Identifier11addSlowCaseEPNS_12JSGlobalDataEPNS_11UStringImplE
</span><span class="cx"> __ZN3JSC10Identifier11addSlowCaseEPNS_9ExecStateEPNS_11UStringImplE
</span><del>-__ZN3JSC10Identifier24checkSameIdentifierTableEPNS_12JSGlobalDataEPNS_11UStringImplE
-__ZN3JSC10Identifier24checkSameIdentifierTableEPNS_9ExecStateEPNS_11UStringImplE
</del><ins>+__ZN3JSC10Identifier27checkCurrentIdentifierTableEPNS_12JSGlobalDataE
+__ZN3JSC10Identifier27checkCurrentIdentifierTableEPNS_9ExecStateE
</ins><span class="cx"> __ZN3JSC10Identifier3addEPNS_9ExecStateEPKc
</span><span class="cx"> __ZN3JSC10Identifier4fromEPNS_9ExecStateEi
</span><span class="cx"> __ZN3JSC10Identifier4fromEPNS_9ExecStateEj
</span></span></pre></div>
<a id="trunkJavaScriptCoreruntimeIdentifiercpp"></a>
<div class="modfile"><h4>Modified: trunk/JavaScriptCore/runtime/Identifier.cpp (55942 => 55943)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JavaScriptCore/runtime/Identifier.cpp        2010-03-12 23:17:12 UTC (rev 55942)
+++ trunk/JavaScriptCore/runtime/Identifier.cpp        2010-03-12 23:49:05 UTC (rev 55943)
</span><span class="lines">@@ -124,11 +124,8 @@
</span><span class="cx"> 
</span><span class="cx"> PassRefPtr&lt;UString::Rep&gt; Identifier::add(JSGlobalData* globalData, const char* c)
</span><span class="cx"> {
</span><del>-    if (!c) {
-        UString::Rep* rep = UString::null().rep();
-        rep-&gt;hash();
-        return rep;
-    }
</del><ins>+    if (!c)
+        return UString::null().rep();
</ins><span class="cx">     if (!c[0])
</span><span class="cx">         return UString::Rep::empty();
</span><span class="cx">     if (!c[1])
</span><span class="lines">@@ -209,19 +206,18 @@
</span><span class="cx"> PassRefPtr&lt;UString::Rep&gt; Identifier::addSlowCase(JSGlobalData* globalData, UString::Rep* r)
</span><span class="cx"> {
</span><span class="cx">     ASSERT(!r-&gt;isIdentifier());
</span><ins>+    // The empty &amp; null strings are static singletons, and static strings are handled
+    // in ::add() in the header, so we should never get here with a zero length string.
+    ASSERT(r-&gt;length());
+
</ins><span class="cx">     if (r-&gt;length() == 1) {
</span><span class="cx">         UChar c = r-&gt;characters()[0];
</span><span class="cx">         if (c &lt;= 0xFF)
</span><span class="cx">             r = globalData-&gt;smallStrings.singleCharacterStringRep(c);
</span><del>-            if (r-&gt;isIdentifier()) {
-#ifndef NDEBUG
-                checkSameIdentifierTable(globalData, r);
-#endif
</del><ins>+            if (r-&gt;isIdentifier())
</ins><span class="cx">                 return r;
</span><del>-            }
</del><span class="cx">     }
</span><del>-    if (!r-&gt;length())
-        return UString::Rep::empty();
</del><ins>+
</ins><span class="cx">     return *globalData-&gt;identifierTable-&gt;add(r).first;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -252,26 +248,25 @@
</span><span class="cx"> 
</span><span class="cx"> #ifndef NDEBUG
</span><span class="cx"> 
</span><del>-void Identifier::checkSameIdentifierTable(ExecState* exec, UString::Rep*)
</del><ins>+void Identifier::checkCurrentIdentifierTable(JSGlobalData* globalData)
</ins><span class="cx"> {
</span><del>-    ASSERT_UNUSED(exec, exec-&gt;globalData().identifierTable == currentIdentifierTable());
</del><ins>+    // Check the identifier table accessible through the threadspecific matches the
+    // globalData's identifier table.
+    ASSERT_UNUSED(globalData, globalData-&gt;identifierTable == currentIdentifierTable());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Identifier::checkSameIdentifierTable(JSGlobalData* globalData, UString::Rep*)
</del><ins>+void Identifier::checkCurrentIdentifierTable(ExecState* exec)
</ins><span class="cx"> {
</span><del>-    ASSERT_UNUSED(globalData, globalData-&gt;identifierTable == currentIdentifierTable());
</del><ins>+    checkCurrentIdentifierTable(&amp;exec-&gt;globalData());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #else
</span><span class="cx"> 
</span><del>-void Identifier::checkSameIdentifierTable(ExecState*, UString::Rep*)
-{
-}
</del><ins>+// These only exists so that our exports are the same for debug and release builds.
+// This would be an ASSERT_NOT_REACHED(), but we're in NDEBUG only code here!
+void Identifier::checkCurrentIdentifierTable(JSGlobalData*) { CRASH(); }
+void Identifier::checkCurrentIdentifierTable(ExecState*) { CRASH(); }
</ins><span class="cx"> 
</span><del>-void Identifier::checkSameIdentifierTable(JSGlobalData*, UString::Rep*)
-{
-}
-
</del><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> ThreadSpecific&lt;ThreadIdentifierTableData&gt;* g_identifierTableSpecific = 0;
</span></span></pre></div>
<a id="trunkJavaScriptCoreruntimeIdentifierh"></a>
<div class="modfile"><h4>Modified: trunk/JavaScriptCore/runtime/Identifier.h (55942 => 55943)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JavaScriptCore/runtime/Identifier.h        2010-03-12 23:17:12 UTC (rev 55942)
+++ trunk/JavaScriptCore/runtime/Identifier.h        2010-03-12 23:49:05 UTC (rev 55943)
</span><span class="lines">@@ -93,30 +93,28 @@
</span><span class="cx"> 
</span><span class="cx">         static PassRefPtr&lt;UString::Rep&gt; add(ExecState* exec, UString::Rep* r)
</span><span class="cx">         {
</span><del>-            if (r-&gt;isIdentifier()) {
</del><span class="cx"> #ifndef NDEBUG
</span><del>-                checkSameIdentifierTable(exec, r);
</del><ins>+            checkCurrentIdentifierTable(exec);
</ins><span class="cx"> #endif
</span><ins>+            if (r-&gt;isIdentifier())
</ins><span class="cx">                 return r;
</span><del>-            }
</del><span class="cx">             return addSlowCase(exec, r);
</span><span class="cx">         }
</span><span class="cx">         static PassRefPtr&lt;UString::Rep&gt; add(JSGlobalData* globalData, UString::Rep* r)
</span><span class="cx">         {
</span><del>-            if (r-&gt;isIdentifier()) {
</del><span class="cx"> #ifndef NDEBUG
</span><del>-                checkSameIdentifierTable(globalData, r);
</del><ins>+            checkCurrentIdentifierTable(globalData);
</ins><span class="cx"> #endif
</span><ins>+            if (r-&gt;isIdentifier())
</ins><span class="cx">                 return r;
</span><del>-            }
</del><span class="cx">             return addSlowCase(globalData, r);
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         static PassRefPtr&lt;UString::Rep&gt; addSlowCase(ExecState*, UString::Rep* r);
</span><span class="cx">         static PassRefPtr&lt;UString::Rep&gt; addSlowCase(JSGlobalData*, UString::Rep* r);
</span><span class="cx"> 
</span><del>-        static void checkSameIdentifierTable(ExecState*, UString::Rep*);
-        static void checkSameIdentifierTable(JSGlobalData*, UString::Rep*);
</del><ins>+        static void checkCurrentIdentifierTable(ExecState*);
+        static void checkCurrentIdentifierTable(JSGlobalData*);
</ins><span class="cx">     };
</span><span class="cx">     
</span><span class="cx">     inline bool operator==(const Identifier&amp; a, const Identifier&amp; b)
</span></span></pre></div>
<a id="trunkJavaScriptCoreruntimeUStringImplcpp"></a>
<div class="modfile"><h4>Modified: trunk/JavaScriptCore/runtime/UStringImpl.cpp (55942 => 55943)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JavaScriptCore/runtime/UStringImpl.cpp        2010-03-12 23:17:12 UTC (rev 55942)
+++ trunk/JavaScriptCore/runtime/UStringImpl.cpp        2010-03-12 23:49:05 UTC (rev 55943)
</span><span class="lines">@@ -41,7 +41,6 @@
</span><span class="cx"> UStringImpl::~UStringImpl()
</span><span class="cx"> {
</span><span class="cx">     ASSERT(!isStatic());
</span><del>-    checkConsistency();
</del><span class="cx"> 
</span><span class="cx">     if (isIdentifier())
</span><span class="cx">         Identifier::remove(this);
</span></span></pre></div>
<a id="trunkJavaScriptCoreruntimeUStringImplh"></a>
<div class="modfile"><h4>Modified: trunk/JavaScriptCore/runtime/UStringImpl.h (55942 => 55943)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JavaScriptCore/runtime/UStringImpl.h        2010-03-12 23:17:12 UTC (rev 55942)
+++ trunk/JavaScriptCore/runtime/UStringImpl.h        2010-03-12 23:49:05 UTC (rev 55943)
</span><span class="lines">@@ -72,7 +72,7 @@
</span><span class="cx"> 
</span><span class="cx">     enum StaticStringConstructType { ConstructStaticString };
</span><span class="cx">     UStringOrRopeImpl(unsigned length, StaticStringConstructType)
</span><del>-        : m_refCountAndFlags(s_refCountFlagStatic | BufferOwned)
</del><ins>+        : m_refCountAndFlags(s_refCountFlagStatic | s_refCountFlagIsIdentifier | BufferOwned)
</ins><span class="cx">         , m_length(length)
</span><span class="cx">     {
</span><span class="cx">         ASSERT(!isRope());
</span><span class="lines">@@ -125,7 +125,6 @@
</span><span class="cx">         , m_hash(0)
</span><span class="cx">     {
</span><span class="cx">         hash();
</span><del>-        checkConsistency();
</del><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // Create a normal string with internal storage (BufferInternal)
</span><span class="lines">@@ -137,7 +136,6 @@
</span><span class="cx">     {
</span><span class="cx">         ASSERT(m_data);
</span><span class="cx">         ASSERT(m_length);
</span><del>-        checkConsistency();
</del><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // Create a UStringImpl adopting ownership of the provided buffer (BufferOwned)
</span><span class="lines">@@ -149,7 +147,6 @@
</span><span class="cx">     {
</span><span class="cx">         ASSERT(m_data);
</span><span class="cx">         ASSERT(m_length);
</span><del>-        checkConsistency();
</del><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // Used to create new strings that are a substring of an existing UStringImpl (BufferSubstring)
</span><span class="lines">@@ -161,7 +158,7 @@
</span><span class="cx">     {
</span><span class="cx">         ASSERT(m_data);
</span><span class="cx">         ASSERT(m_length);
</span><del>-        checkConsistency();
</del><ins>+        ASSERT(m_substringBuffer-&gt;bufferOwnership() != BufferSubstring);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // Used to construct new strings sharing an existing SharedUChar (BufferShared)
</span><span class="lines">@@ -173,12 +170,12 @@
</span><span class="cx">     {
</span><span class="cx">         ASSERT(m_data);
</span><span class="cx">         ASSERT(m_length);
</span><del>-        checkConsistency();
</del><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // For use only by Identifier's XXXTranslator helpers.
</span><span class="cx">     void setHash(unsigned hash)
</span><span class="cx">     {
</span><ins>+        ASSERT(!isStatic());
</ins><span class="cx">         ASSERT(!m_hash);
</span><span class="cx">         ASSERT(hash == computeHash(m_data, m_length));
</span><span class="cx">         m_hash = hash;
</span><span class="lines">@@ -193,10 +190,12 @@
</span><span class="cx">     static PassRefPtr&lt;UStringImpl&gt; create(PassRefPtr&lt;SharedUChar&gt;, const UChar*, unsigned length);
</span><span class="cx">     static PassRefPtr&lt;UStringImpl&gt; create(PassRefPtr&lt;UStringImpl&gt; rep, unsigned offset, unsigned length)
</span><span class="cx">     {
</span><ins>+        ASSERT(rep);
+        ASSERT(length &lt;= rep-&gt;length());
+
</ins><span class="cx">         if (!length)
</span><span class="cx">             return empty();
</span><del>-        ASSERT(rep);
-        rep-&gt;checkConsistency();
</del><ins>+
</ins><span class="cx">         UStringImpl* ownerRep = (rep-&gt;bufferOwnership() == BufferSubstring) ? rep-&gt;m_substringBuffer : rep.get();
</span><span class="cx">         return adoptRef(new UStringImpl(rep-&gt;m_data + offset, length, ownerRep));
</span><span class="cx">     }
</span><span class="lines">@@ -247,6 +246,7 @@
</span><span class="cx">     bool isIdentifier() const { return m_refCountAndFlags &amp; s_refCountFlagIsIdentifier; }
</span><span class="cx">     void setIsIdentifier(bool isIdentifier)
</span><span class="cx">     {
</span><ins>+        ASSERT(!isStatic());
</ins><span class="cx">         if (isIdentifier)
</span><span class="cx">             m_refCountAndFlags |= s_refCountFlagIsIdentifier;
</span><span class="cx">         else
</span><span class="lines">@@ -272,14 +272,6 @@
</span><span class="cx">             memcpy(destination, source, numCharacters * sizeof(UChar));
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    ALWAYS_INLINE void checkConsistency() const
-    {
-        // There is no recursion of substrings.
-        ASSERT((bufferOwnership() != BufferSubstring) || (m_substringBuffer-&gt;bufferOwnership() != BufferSubstring));
-        // Static strings cannot be put in identifier tables, because they are globally shared.
-        ASSERT(!isStatic() || !isIdentifier());
-    }
-
</del><span class="cx"> private:
</span><span class="cx">     // This number must be at least 2 to avoid sharing empty, null as well as 1 character strings from SmallStrings.
</span><span class="cx">     static const unsigned s_copyCharsInlineCutOff = 20;
</span><span class="lines">@@ -287,7 +279,6 @@
</span><span class="cx">     BufferOwnership bufferOwnership() const { return static_cast&lt;BufferOwnership&gt;(m_refCountAndFlags &amp; s_refCountMaskBufferOwnership); }
</span><span class="cx">     bool isStatic() const { return m_refCountAndFlags &amp; s_refCountFlagStatic; }
</span><span class="cx"> 
</span><del>-    // unshared data
</del><span class="cx">     const UChar* m_data;
</span><span class="cx">     union {
</span><span class="cx">         void* m_buffer;
</span></span></pre></div>
<a id="trunkWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/ChangeLog (55942 => 55943)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/ChangeLog        2010-03-12 23:17:12 UTC (rev 55942)
+++ trunk/WebCore/ChangeLog        2010-03-12 23:49:05 UTC (rev 55943)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2010-03-11  Gavin Barraclough  &lt;barraclough@apple.com&gt;
+
+        Reviewed by Oliver Hunt.
+
+        Bug 36075 - Clean up screwyness re static string impls &amp; Identifiers.
+
+        * platform/text/StringImpl.cpp:
+        (WebCore::StringImpl::~StringImpl): Add ASSERT
+        (WebCore::StringImpl::sharedBuffer): Add ASSERT
+        * platform/text/StringImpl.h:
+        (WebCore::StringImpl::setHash): Add ASSERT
+        (WebCore::StringImpl::isStatic): added.
+
</ins><span class="cx"> 2010-03-12  Enrica Casucci  &lt;enrica@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Reviewed by Simon Fraser.
</span></span></pre></div>
<a id="trunkWebCoreplatformtextStringImplcpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/platform/text/StringImpl.cpp (55942 => 55943)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/platform/text/StringImpl.cpp        2010-03-12 23:17:12 UTC (rev 55942)
+++ trunk/WebCore/platform/text/StringImpl.cpp        2010-03-12 23:49:05 UTC (rev 55943)
</span><span class="lines">@@ -48,6 +48,8 @@
</span><span class="cx"> 
</span><span class="cx"> StringImpl::~StringImpl()
</span><span class="cx"> {
</span><ins>+    ASSERT(!isStatic());
+
</ins><span class="cx">     if (inTable())
</span><span class="cx">         AtomicString::remove(this);
</span><span class="cx"> 
</span><span class="lines">@@ -129,6 +131,8 @@
</span><span class="cx"> {
</span><span class="cx">     if (m_length &lt; minLengthToShare)
</span><span class="cx">         return 0;
</span><ins>+    // All static strings are smaller that the minimim length to share.
+    ASSERT(!isStatic());
</ins><span class="cx"> 
</span><span class="cx">     BufferOwnership ownership = bufferOwnership();
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkWebCoreplatformtextStringImplh"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/platform/text/StringImpl.h (55942 => 55943)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/platform/text/StringImpl.h        2010-03-12 23:17:12 UTC (rev 55942)
+++ trunk/WebCore/platform/text/StringImpl.h        2010-03-12 23:49:05 UTC (rev 55943)
</span><span class="lines">@@ -127,6 +127,7 @@
</span><span class="cx">     // For use only by AtomicString's XXXTranslator helpers.
</span><span class="cx">     void setHash(unsigned hash)
</span><span class="cx">     {
</span><ins>+        ASSERT(!isStatic());
</ins><span class="cx">         ASSERT(!m_hash);
</span><span class="cx">         ASSERT(hash == computeHash(m_data, m_length));
</span><span class="cx">         m_hash = hash;
</span><span class="lines">@@ -252,6 +253,7 @@
</span><span class="cx">     static PassRefPtr&lt;StringImpl&gt; createStrippingNullCharactersSlowCase(const UChar*, unsigned length);
</span><span class="cx">     
</span><span class="cx">     BufferOwnership bufferOwnership() const { return static_cast&lt;BufferOwnership&gt;(m_refCountAndFlags &amp; s_refCountMaskBufferOwnership); }
</span><ins>+    bool isStatic() const { return m_refCountAndFlags &amp; s_refCountFlagStatic; }
</ins><span class="cx"> 
</span><span class="cx">     static const unsigned s_refCountMask = 0xFFFFFFE0;
</span><span class="cx">     static const unsigned s_refCountIncrement = 0x20;
</span></span></pre>
</div>
</div>

</body>
</html>