[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

barraclough at apple.com barraclough at apple.com
Wed Dec 22 12:17:07 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 846dfcf4012bd1e05c20ae07e25e1280a5ae986e
Author: barraclough at apple.com <barraclough at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Aug 18 08:56:49 2010 +0000

    Rename UString::substr to substringSharingImpl, add to WTF::String.
    Now WTF::String can do everything that JSC::UString can do!
    
    Rubber stamped by Sam Weinig.
    
    * JavaScriptCore.exp:
    * bytecode/CodeBlock.cpp:
    (JSC::escapeQuotes):
    * bytecompiler/NodesCodegen.cpp:
    (JSC::substitute):
    * parser/SourceProvider.h:
    (JSC::UStringSourceProvider::getRange):
    * runtime/FunctionPrototype.cpp:
    (JSC::insertSemicolonIfNeeded):
    * runtime/JSGlobalObjectFunctions.cpp:
    (JSC::parseInt):
    * runtime/JSONObject.cpp:
    (JSC::gap):
    (JSC::Stringifier::indent):
    (JSC::Stringifier::unindent):
    * runtime/JSString.cpp:
    (JSC::JSString::replaceCharacter):
    * runtime/NumberPrototype.cpp:
    (JSC::numberProtoFuncToFixed):
    (JSC::numberProtoFuncToPrecision):
    * runtime/StringPrototype.cpp:
    (JSC::stringProtoFuncReplace):
    (JSC::trimString):
    * runtime/UString.cpp:
    (JSC::UString::substringSharingImpl):
    * runtime/UString.h:
    * wtf/text/WTFString.cpp:
    (WTF::String::substringSharingImpl):
    * wtf/text/WTFString.h:
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@65593 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index 6579955..1cf0f8c 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,5 +1,42 @@
 2010-08-18  Gavin Barraclough  <barraclough at apple.com>
 
+        Rubber stamped by Sam Weinig.
+
+        Rename UString::substr to substringSharingImpl, add to WTF::String.
+        Now WTF::String can do everything that JSC::UString can do!
+
+        * JavaScriptCore.exp:
+        * bytecode/CodeBlock.cpp:
+        (JSC::escapeQuotes):
+        * bytecompiler/NodesCodegen.cpp:
+        (JSC::substitute):
+        * parser/SourceProvider.h:
+        (JSC::UStringSourceProvider::getRange):
+        * runtime/FunctionPrototype.cpp:
+        (JSC::insertSemicolonIfNeeded):
+        * runtime/JSGlobalObjectFunctions.cpp:
+        (JSC::parseInt):
+        * runtime/JSONObject.cpp:
+        (JSC::gap):
+        (JSC::Stringifier::indent):
+        (JSC::Stringifier::unindent):
+        * runtime/JSString.cpp:
+        (JSC::JSString::replaceCharacter):
+        * runtime/NumberPrototype.cpp:
+        (JSC::numberProtoFuncToFixed):
+        (JSC::numberProtoFuncToPrecision):
+        * runtime/StringPrototype.cpp:
+        (JSC::stringProtoFuncReplace):
+        (JSC::trimString):
+        * runtime/UString.cpp:
+        (JSC::UString::substringSharingImpl):
+        * runtime/UString.h:
+        * wtf/text/WTFString.cpp:
+        (WTF::String::substringSharingImpl):
+        * wtf/text/WTFString.h:
+
+2010-08-18  Gavin Barraclough  <barraclough at apple.com>
+
         Windows build fix.
 
         * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
diff --git a/JavaScriptCore/JavaScriptCore.exp b/JavaScriptCore/JavaScriptCore.exp
index 5652d0f..5cfa1c2 100644
--- a/JavaScriptCore/JavaScriptCore.exp
+++ b/JavaScriptCore/JavaScriptCore.exp
@@ -516,9 +516,9 @@ __ZNK3JSC7JSValue16toObjectSlowCaseEPNS_9ExecStateE
 __ZNK3JSC7JSValue19synthesizePrototypeEPNS_9ExecStateE
 __ZNK3JSC7JSValue20toThisObjectSlowCaseEPNS_9ExecStateE
 __ZNK3JSC7JSValue9toIntegerEPNS_9ExecStateE
+__ZNK3JSC7UString20substringSharingImplEjj
 __ZNK3JSC7UString4utf8Eb
 __ZNK3JSC7UString5asciiEv
-__ZNK3JSC7UString6substrEjj
 __ZNK3JSC8JSObject11hasPropertyEPNS_9ExecStateERKNS_10IdentifierE
 __ZNK3JSC8JSObject11hasPropertyEPNS_9ExecStateEj
 __ZNK3JSC8JSObject12defaultValueEPNS_9ExecStateENS_22PreferredPrimitiveTypeE
diff --git a/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def b/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def
index bc4c837..934688f 100644
--- a/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def
+++ b/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def
@@ -285,7 +285,7 @@ EXPORTS
     ?stopProfiling at Profiler@JSC@@QAE?AV?$PassRefPtr at VProfile@JSC@@@WTF@@PAVExecState at 2@ABVUString at 2@@Z
     ?stopSampling at JSGlobalData@JSC@@QAEXXZ
     ?strtod at WTF@@YANPBDPAPAD at Z
-    ?substr at UString@JSC@@QBE?AV12 at II@Z
+    ?substringSharingImpl at UString@JSC@@QBE?AV12 at II@Z
     ?symbolTableGet at JSVariableObject@JSC@@IAE_NABVIdentifier at 2@AAVPropertyDescriptor at 2@@Z
     ?synthesizePrototype at JSValue@JSC@@ABEPAVJSObject at 2@PAVExecState at 2@@Z
     ?thisObject at DebuggerCallFrame@JSC@@QBEPAVJSObject at 2@XZ
diff --git a/JavaScriptCore/bytecode/CodeBlock.cpp b/JavaScriptCore/bytecode/CodeBlock.cpp
index b916595..0749cf6 100644
--- a/JavaScriptCore/bytecode/CodeBlock.cpp
+++ b/JavaScriptCore/bytecode/CodeBlock.cpp
@@ -52,7 +52,7 @@ static UString escapeQuotes(const UString& str)
     UString result = str;
     size_t pos = 0;
     while ((pos = result.find('\"', pos)) != notFound) {
-        result = makeString(result.substr(0, pos), "\"\\\"\"", result.substr(pos + 1));
+        result = makeString(result.substringSharingImpl(0, pos), "\"\\\"\"", result.substringSharingImpl(pos + 1));
         pos += 4;
     }
     return result;
diff --git a/JavaScriptCore/bytecompiler/NodesCodegen.cpp b/JavaScriptCore/bytecompiler/NodesCodegen.cpp
index 5b5a908..f098ba6 100644
--- a/JavaScriptCore/bytecompiler/NodesCodegen.cpp
+++ b/JavaScriptCore/bytecompiler/NodesCodegen.cpp
@@ -80,7 +80,7 @@ static void substitute(UString& string, const UString& substring)
 {
     size_t position = string.find("%s");
     ASSERT(position != notFound);
-    string = makeString(string.substr(0, position), substring, string.substr(position + 2));
+    string = makeString(string.substringSharingImpl(0, position), substring, string.substringSharingImpl(position + 2));
 }
 
 RegisterID* ThrowableExpressionData::emitThrowError(BytecodeGenerator& generator, bool isReferenceError, const char* message)
diff --git a/JavaScriptCore/parser/SourceProvider.h b/JavaScriptCore/parser/SourceProvider.h
index d1b2bbb..5ff1d14 100644
--- a/JavaScriptCore/parser/SourceProvider.h
+++ b/JavaScriptCore/parser/SourceProvider.h
@@ -67,7 +67,7 @@ namespace JSC {
 
         UString getRange(int start, int end) const
         {
-            return m_source.substr(start, end - start);
+            return m_source.substringSharingImpl(start, end - start);
         }
         const UChar* data() const { return m_source.characters(); }
         int length() const { return m_source.length(); }
diff --git a/JavaScriptCore/runtime/FunctionPrototype.cpp b/JavaScriptCore/runtime/FunctionPrototype.cpp
index a55d90a..c740624 100644
--- a/JavaScriptCore/runtime/FunctionPrototype.cpp
+++ b/JavaScriptCore/runtime/FunctionPrototype.cpp
@@ -77,7 +77,7 @@ static inline void insertSemicolonIfNeeded(UString& functionBody)
         UChar ch = functionBody[i];
         if (!Lexer::isWhiteSpace(ch) && !Lexer::isLineTerminator(ch)) {
             if (ch != ';' && ch != '}')
-                functionBody = makeString(functionBody.substr(0, i + 1), ";", functionBody.substr(i + 1, functionBody.length() - (i + 1)));
+                functionBody = makeString(functionBody.substringSharingImpl(0, i + 1), ";", functionBody.substringSharingImpl(i + 1, functionBody.length() - (i + 1)));
             return;
         }
     }
diff --git a/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp b/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp
index 4f4276a..1e20f7f 100644
--- a/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp
+++ b/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp
@@ -265,9 +265,9 @@ static double parseInt(const UString& s, int radix)
 
     if (number >= mantissaOverflowLowerBound) {
         if (radix == 10)
-            number = WTF::strtod(s.substr(firstDigitPosition, p - firstDigitPosition).utf8().data(), 0);
+            number = WTF::strtod(s.substringSharingImpl(firstDigitPosition, p - firstDigitPosition).utf8().data(), 0);
         else if (radix == 2 || radix == 4 || radix == 8 || radix == 16 || radix == 32)
-            number = parseIntOverflow(s.substr(firstDigitPosition, p - firstDigitPosition).utf8().data(), p - firstDigitPosition, radix);
+            number = parseIntOverflow(s.substringSharingImpl(firstDigitPosition, p - firstDigitPosition).utf8().data(), p - firstDigitPosition, radix);
     }
 
     if (!sawDigit)
diff --git a/JavaScriptCore/runtime/JSONObject.cpp b/JavaScriptCore/runtime/JSONObject.cpp
index 628e619..ba50721 100644
--- a/JavaScriptCore/runtime/JSONObject.cpp
+++ b/JavaScriptCore/runtime/JSONObject.cpp
@@ -165,7 +165,7 @@ static inline UString gap(ExecState* exec, JSValue space)
     // If the space value is a string, use it as the gap string, otherwise use no gap string.
     UString spaces = space.getString(exec);
     if (spaces.length() > maxGapLength) {
-        spaces = spaces.substr(0, maxGapLength);
+        spaces = spaces.substringSharingImpl(0, maxGapLength);
     }
     return spaces;
 }
@@ -468,13 +468,13 @@ inline void Stringifier::indent()
     if (newSize > m_repeatedGap.length())
         m_repeatedGap = makeString(m_repeatedGap, m_gap);
     ASSERT(newSize <= m_repeatedGap.length());
-    m_indent = m_repeatedGap.substr(0, newSize);
+    m_indent = m_repeatedGap.substringSharingImpl(0, newSize);
 }
 
 inline void Stringifier::unindent()
 {
     ASSERT(m_indent.length() >= m_gap.length());
-    m_indent = m_repeatedGap.substr(0, m_indent.length() - m_gap.length());
+    m_indent = m_repeatedGap.substringSharingImpl(0, m_indent.length() - m_gap.length());
 }
 
 inline void Stringifier::startNewLine(StringBuilder& builder) const
diff --git a/JavaScriptCore/runtime/JSString.cpp b/JavaScriptCore/runtime/JSString.cpp
index 0ed02df..bc0120f 100644
--- a/JavaScriptCore/runtime/JSString.cpp
+++ b/JavaScriptCore/runtime/JSString.cpp
@@ -112,7 +112,7 @@ JSValue JSString::replaceCharacter(ExecState* exec, UChar character, const UStri
         size_t matchPosition = m_value.find(character);
         if (matchPosition == notFound)
             return JSValue(this);
-        return jsString(exec, m_value.substr(0, matchPosition), replacement, m_value.substr(matchPosition + 1));
+        return jsString(exec, m_value.substringSharingImpl(0, matchPosition), replacement, m_value.substringSharingImpl(matchPosition + 1));
     }
 
     RopeIterator end;
@@ -147,10 +147,10 @@ JSValue JSString::replaceCharacter(ExecState* exec, UChar character, const UStri
             continue;
         }
 
-        builder.append(UString(string).substr(0, matchPosition));
+        builder.append(UString(string).substringSharingImpl(0, matchPosition));
         if (replacement.length())
             builder.append(replacement);
-        builder.append(UString(string).substr(matchPosition + 1));
+        builder.append(UString(string).substringSharingImpl(matchPosition + 1));
         matchString = 0;
     }
 
diff --git a/JavaScriptCore/runtime/NumberPrototype.cpp b/JavaScriptCore/runtime/NumberPrototype.cpp
index 7be8c73..80b7ce0 100644
--- a/JavaScriptCore/runtime/NumberPrototype.cpp
+++ b/JavaScriptCore/runtime/NumberPrototype.cpp
@@ -293,8 +293,8 @@ EncodedJSValue JSC_HOST_CALL numberProtoFuncToFixed(ExecState* exec)
     int kMinusf = k - f;
 
     if (kMinusf < static_cast<int>(m.length()))
-        return JSValue::encode(jsString(exec, makeString(s, m.substr(0, kMinusf), ".", m.substr(kMinusf))));
-    return JSValue::encode(jsString(exec, makeString(s, m.substr(0, kMinusf))));
+        return JSValue::encode(jsString(exec, makeString(s, m.substringSharingImpl(0, kMinusf), ".", m.substringSharingImpl(kMinusf))));
+    return JSValue::encode(jsString(exec, makeString(s, m.substringSharingImpl(0, kMinusf))));
 }
 
 static void fractionalPartToString(char* buf, int& i, const char* result, int resultLength, int fractionalDigits)
@@ -456,7 +456,7 @@ EncodedJSValue JSC_HOST_CALL numberProtoFuncToPrecision(ExecState* exec)
         m = integerPartNoExp(n);
         if (e < -6 || e >= precision) {
             if (m.length() > 1)
-                m = makeString(m.substr(0, 1), ".", m.substr(1));
+                m = makeString(m.substringSharingImpl(0, 1), ".", m.substringSharingImpl(1));
             if (e >= 0)
                 return JSValue::encode(jsMakeNontrivialString(exec, s, m, "e+", UString::number(e)));
             return JSValue::encode(jsMakeNontrivialString(exec, s, m, "e-", UString::number(-e)));
@@ -470,7 +470,7 @@ EncodedJSValue JSC_HOST_CALL numberProtoFuncToPrecision(ExecState* exec)
         return JSValue::encode(jsString(exec, makeString(s, m)));
     if (e >= 0) {
         if (e + 1 < static_cast<int>(m.length()))
-            return JSValue::encode(jsString(exec, makeString(s, m.substr(0, e + 1), ".", m.substr(e + 1))));
+            return JSValue::encode(jsString(exec, makeString(s, m.substringSharingImpl(0, e + 1), ".", m.substringSharingImpl(e + 1))));
         return JSValue::encode(jsString(exec, makeString(s, m)));
     }
     return JSValue::encode(jsMakeNontrivialString(exec, s, "0.", charSequence('0', -(e + 1)), m));
diff --git a/JavaScriptCore/runtime/StringPrototype.cpp b/JavaScriptCore/runtime/StringPrototype.cpp
index ef5d137..cfbb3be 100644
--- a/JavaScriptCore/runtime/StringPrototype.cpp
+++ b/JavaScriptCore/runtime/StringPrototype.cpp
@@ -446,7 +446,7 @@ EncodedJSValue JSC_HOST_CALL stringProtoFuncReplace(ExecState* exec)
     
     size_t matchEnd = matchPos + matchLen;
     int ovector[2] = { matchPos, matchEnd };
-    return JSValue::encode(jsString(exec, source.substr(0, matchPos), substituteBackreferences(replacementString, source, ovector, 0), source.substr(matchEnd)));
+    return JSValue::encode(jsString(exec, source.substringSharingImpl(0, matchPos), substituteBackreferences(replacementString, source, ovector, 0), source.substringSharingImpl(matchEnd)));
 }
 
 EncodedJSValue JSC_HOST_CALL stringProtoFuncToString(ExecState* exec)
@@ -1090,7 +1090,7 @@ static inline JSValue trimString(ExecState* exec, JSValue thisValue, int trimKin
     if (left == 0 && right == str.length() && thisValue.isString())
         return thisValue;
 
-    return jsString(exec, str.substr(left, right - left));
+    return jsString(exec, str.substringSharingImpl(left, right - left));
 }
 
 EncodedJSValue JSC_HOST_CALL stringProtoFuncTrim(ExecState* exec)
diff --git a/JavaScriptCore/runtime/UString.cpp b/JavaScriptCore/runtime/UString.cpp
index 225cf28..ac3acfd 100644
--- a/JavaScriptCore/runtime/UString.cpp
+++ b/JavaScriptCore/runtime/UString.cpp
@@ -204,22 +204,17 @@ UString UString::number(double d)
     return UString(buffer, length);
 }
 
-UString UString::substr(unsigned pos, unsigned len) const
+UString UString::substringSharingImpl(unsigned offset, unsigned length) const
 {
     // FIXME: We used to check against a limit of Heap::minExtraCost / sizeof(UChar).
 
-    unsigned s = length();
+    unsigned stringLength = this->length();
+    offset = min(offset, stringLength);
+    length = min(length, stringLength - offset);
 
-    if (pos >= s)
-        pos = s;
-    unsigned limit = s - pos;
-    if (len > limit)
-        len = limit;
-
-    if (pos == 0 && len == s)
+    if (!offset && length == stringLength)
         return *this;
-
-    return UString(StringImpl::create(m_impl, pos, len));
+    return UString(StringImpl::create(m_impl, offset, length));
 }
 
 bool operator==(const UString& s1, const char *s2)
diff --git a/JavaScriptCore/runtime/UString.h b/JavaScriptCore/runtime/UString.h
index 7f2e08e..cd73c28 100644
--- a/JavaScriptCore/runtime/UString.h
+++ b/JavaScriptCore/runtime/UString.h
@@ -107,7 +107,7 @@ public:
     size_t reverseFind(const UString& str, unsigned start = UINT_MAX) const
         { return m_impl ? m_impl->reverseFind(str.impl(), start) : notFound; }
 
-    UString substr(unsigned pos = 0, unsigned len = UINT_MAX) const;
+    UString substringSharingImpl(unsigned pos, unsigned len = UINT_MAX) const;
 
 private:
     RefPtr<StringImpl> m_impl;
diff --git a/JavaScriptCore/wtf/text/WTFString.cpp b/JavaScriptCore/wtf/text/WTFString.cpp
index dd9ff94..7d44d21 100644
--- a/JavaScriptCore/wtf/text/WTFString.cpp
+++ b/JavaScriptCore/wtf/text/WTFString.cpp
@@ -245,6 +245,19 @@ String String::substring(unsigned pos, unsigned len) const
     return m_impl->substring(pos, len);
 }
 
+String String::substringSharingImpl(unsigned offset, unsigned length) const
+{
+    // FIXME: We used to check against a limit of Heap::minExtraCost / sizeof(UChar).
+
+    unsigned stringLength = this->length();
+    offset = min(offset, stringLength);
+    length = min(length, stringLength - offset);
+
+    if (!offset && length == stringLength)
+        return *this;
+    return String(StringImpl::create(m_impl, offset, length));
+}
+
 String String::lower() const
 {
     if (!m_impl)
diff --git a/JavaScriptCore/wtf/text/WTFString.h b/JavaScriptCore/wtf/text/WTFString.h
index 6344ca1..fafef12 100644
--- a/JavaScriptCore/wtf/text/WTFString.h
+++ b/JavaScriptCore/wtf/text/WTFString.h
@@ -208,6 +208,7 @@ public:
     void remove(unsigned pos, int len = 1);
 
     String substring(unsigned pos, unsigned len = UINT_MAX) const;
+    String substringSharingImpl(unsigned pos, unsigned len = UINT_MAX) const;
     String left(unsigned len) const { return substring(0, len); }
     String right(unsigned len) const { return substring(length() - len, len); }
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list