[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.17-1283-gcf603cf
barraclough at apple.com
barraclough at apple.com
Tue Jan 5 23:54:28 UTC 2010
The following commit has been merged in the webkit-1.1 branch:
commit 7790c23bf968ec42539d8e09edaa7b1e3c936397
Author: barraclough at apple.com <barraclough at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Fri Dec 18 22:59:18 2009 +0000
Add createNonCopying method to UString to make replace constructor passed bool,
to make behaviour more explicit. Add createFromUTF8 to UString (wrapping method
on UString::Rep), since other cases of transliteration (e.g. from ascii) are
performed in UString constructors. Add/use setHash & size() accessors on Rep,
rather than accessing _hash/len directly.
Reviewed by Sam Weinig.
* API/JSClassRef.cpp:
(OpaqueJSClass::OpaqueJSClass):
* API/OpaqueJSString.cpp:
(OpaqueJSString::ustring):
* JavaScriptCore.exp:
* runtime/ArrayPrototype.cpp:
(JSC::arrayProtoFuncToString):
* runtime/Identifier.cpp:
(JSC::Identifier::equal):
(JSC::CStringTranslator::translate):
(JSC::UCharBufferTranslator::translate):
(JSC::Identifier::addSlowCase):
* runtime/JSString.cpp:
(JSC::JSString::resolveRope):
* runtime/JSString.h:
(JSC::JSString::Rope::Fiber::refAndGetLength):
(JSC::JSString::Rope::append):
* runtime/StringBuilder.h:
(JSC::StringBuilder::release):
* runtime/StringConstructor.cpp:
(JSC::stringFromCharCodeSlowCase):
* runtime/StringPrototype.cpp:
(JSC::substituteBackreferencesSlow):
(JSC::stringProtoFuncToLowerCase):
(JSC::stringProtoFuncToUpperCase):
(JSC::stringProtoFuncFontsize):
(JSC::stringProtoFuncLink):
* runtime/UString.cpp:
(JSC::UString::UString):
(JSC::UString::createNonCopying):
(JSC::UString::createFromUTF8):
* runtime/UString.h:
(JSC::UString::Rep::setHash):
(JSC::UString::~UString):
(JSC::makeString):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@52346 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/JavaScriptCore/API/JSClassRef.cpp b/JavaScriptCore/API/JSClassRef.cpp
index c8a6806..f751c5a 100644
--- a/JavaScriptCore/API/JSClassRef.cpp
+++ b/JavaScriptCore/API/JSClassRef.cpp
@@ -52,7 +52,7 @@ OpaqueJSClass::OpaqueJSClass(const JSClassDefinition* definition, OpaqueJSClass*
, callAsConstructor(definition->callAsConstructor)
, hasInstance(definition->hasInstance)
, convertToType(definition->convertToType)
- , m_className(UString::Rep::createFromUTF8(definition->className))
+ , m_className(UString::createFromUTF8(definition->className).rep()->ref())
, m_staticValues(0)
, m_staticFunctions(0)
{
@@ -61,7 +61,7 @@ OpaqueJSClass::OpaqueJSClass(const JSClassDefinition* definition, OpaqueJSClass*
if (const JSStaticValue* staticValue = definition->staticValues) {
m_staticValues = new OpaqueJSClassStaticValuesTable();
while (staticValue->name) {
- m_staticValues->add(UString::Rep::createFromUTF8(staticValue->name),
+ m_staticValues->add(UString::createFromUTF8(staticValue->name).rep()->ref(),
new StaticValueEntry(staticValue->getProperty, staticValue->setProperty, staticValue->attributes));
++staticValue;
}
@@ -70,7 +70,7 @@ OpaqueJSClass::OpaqueJSClass(const JSClassDefinition* definition, OpaqueJSClass*
if (const JSStaticFunction* staticFunction = definition->staticFunctions) {
m_staticFunctions = new OpaqueJSClassStaticFunctionsTable();
while (staticFunction->name) {
- m_staticFunctions->add(UString::Rep::createFromUTF8(staticFunction->name),
+ m_staticFunctions->add(UString::createFromUTF8(staticFunction->name).rep()->ref(),
new StaticFunctionEntry(staticFunction->callAsFunction, staticFunction->attributes));
++staticFunction;
}
diff --git a/JavaScriptCore/API/OpaqueJSString.cpp b/JavaScriptCore/API/OpaqueJSString.cpp
index 7c7b1af..f740abe 100644
--- a/JavaScriptCore/API/OpaqueJSString.cpp
+++ b/JavaScriptCore/API/OpaqueJSString.cpp
@@ -42,7 +42,7 @@ PassRefPtr<OpaqueJSString> OpaqueJSString::create(const UString& ustring)
UString OpaqueJSString::ustring() const
{
if (this && m_characters)
- return UString(m_characters, m_length, true);
+ return UString(m_characters, m_length);
return UString::null();
}
diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index 84621fa..239f126 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,49 @@
+2009-12-18 Gavin Barraclough <barraclough at apple.com>
+
+ Reviewed by Sam Weinig.
+
+ Add createNonCopying method to UString to make replace constructor passed bool,
+ to make behaviour more explicit. Add createFromUTF8 to UString (wrapping method
+ on UString::Rep), since other cases of transliteration (e.g. from ascii) are
+ performed in UString constructors. Add/use setHash & size() accessors on Rep,
+ rather than accessing _hash/len directly.
+
+ * API/JSClassRef.cpp:
+ (OpaqueJSClass::OpaqueJSClass):
+ * API/OpaqueJSString.cpp:
+ (OpaqueJSString::ustring):
+ * JavaScriptCore.exp:
+ * runtime/ArrayPrototype.cpp:
+ (JSC::arrayProtoFuncToString):
+ * runtime/Identifier.cpp:
+ (JSC::Identifier::equal):
+ (JSC::CStringTranslator::translate):
+ (JSC::UCharBufferTranslator::translate):
+ (JSC::Identifier::addSlowCase):
+ * runtime/JSString.cpp:
+ (JSC::JSString::resolveRope):
+ * runtime/JSString.h:
+ (JSC::JSString::Rope::Fiber::refAndGetLength):
+ (JSC::JSString::Rope::append):
+ * runtime/StringBuilder.h:
+ (JSC::StringBuilder::release):
+ * runtime/StringConstructor.cpp:
+ (JSC::stringFromCharCodeSlowCase):
+ * runtime/StringPrototype.cpp:
+ (JSC::substituteBackreferencesSlow):
+ (JSC::stringProtoFuncToLowerCase):
+ (JSC::stringProtoFuncToUpperCase):
+ (JSC::stringProtoFuncFontsize):
+ (JSC::stringProtoFuncLink):
+ * runtime/UString.cpp:
+ (JSC::UString::UString):
+ (JSC::UString::createNonCopying):
+ (JSC::UString::createFromUTF8):
+ * runtime/UString.h:
+ (JSC::UString::Rep::setHash):
+ (JSC::UString::~UString):
+ (JSC::makeString):
+
2009-12-18 Geoffrey Garen <ggaren at apple.com>
Reviewed by Cameron Zwarich and Gavin Barraclough.
diff --git a/JavaScriptCore/JavaScriptCore.exp b/JavaScriptCore/JavaScriptCore.exp
index 0897947..5e34bab 100644
--- a/JavaScriptCore/JavaScriptCore.exp
+++ b/JavaScriptCore/JavaScriptCore.exp
@@ -225,6 +225,7 @@ __ZN3JSC7Profile10restoreAllEv
__ZN3JSC7Profile5focusEPKNS_11ProfileNodeE
__ZN3JSC7Profile7excludeEPKNS_11ProfileNodeE
__ZN3JSC7Profile7forEachEMNS_11ProfileNodeEFvvE
+__ZN3JSC7UString16createNonCopyingEPti
__ZN3JSC7UString3Rep11computeHashEPKci
__ZN3JSC7UString3Rep11computeHashEPKti
__ZN3JSC7UString3Rep12sharedBufferEv
@@ -238,7 +239,6 @@ __ZN3JSC7UString4fromEj
__ZN3JSC7UString4fromEl
__ZN3JSC7UStringC1EPKc
__ZN3JSC7UStringC1EPKti
-__ZN3JSC7UStringC1EPtib
__ZN3JSC7UStringaSEPKc
__ZN3JSC8Debugger23recompileAllJSFunctionsEPNS_12JSGlobalDataE
__ZN3JSC8Debugger6attachEPNS_14JSGlobalObjectE
diff --git a/JavaScriptCore/runtime/ArrayPrototype.cpp b/JavaScriptCore/runtime/ArrayPrototype.cpp
index 5b359e7..2086f98 100644
--- a/JavaScriptCore/runtime/ArrayPrototype.cpp
+++ b/JavaScriptCore/runtime/ArrayPrototype.cpp
@@ -205,7 +205,7 @@ JSValue JSC_HOST_CALL arrayProtoFuncToString(ExecState* exec, JSObject*, JSValue
}
ASSERT(buffer.size() == totalSize);
unsigned finalSize = buffer.size();
- return jsString(exec, UString(buffer.releaseBuffer(), finalSize, false));
+ return jsString(exec, UString::createNonCopying(buffer.releaseBuffer(), finalSize));
}
JSValue JSC_HOST_CALL arrayProtoFuncToLocaleString(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&)
diff --git a/JavaScriptCore/runtime/Identifier.cpp b/JavaScriptCore/runtime/Identifier.cpp
index 7db723b..8e3ecaa 100644
--- a/JavaScriptCore/runtime/Identifier.cpp
+++ b/JavaScriptCore/runtime/Identifier.cpp
@@ -77,7 +77,7 @@ void deleteIdentifierTable(IdentifierTable* table)
bool Identifier::equal(const UString::Rep* r, const char* s)
{
- int length = r->len;
+ int length = r->size();
const UChar* d = r->data();
for (int i = 0; i != length; ++i)
if (d[i] != (unsigned char)s[i])
@@ -87,7 +87,7 @@ bool Identifier::equal(const UString::Rep* r, const char* s)
bool Identifier::equal(const UString::Rep* r, const UChar* s, int length)
{
- if (r->len != length)
+ if (r->size() != length)
return false;
const UChar* d = r->data();
for (int i = 0; i != length; ++i)
@@ -115,7 +115,7 @@ struct CStringTranslator {
d[i] = static_cast<unsigned char>(c[i]); // use unsigned char to zero-extend instead of sign-extend
UString::Rep* r = UString::Rep::create(d, static_cast<int>(length)).releaseRef();
- r->_hash = hash;
+ r->setHash(hash);
location = r;
}
@@ -180,7 +180,7 @@ struct UCharBufferTranslator {
d[i] = buf.s[i];
UString::Rep* r = UString::Rep::create(d, buf.length).releaseRef();
- r->_hash = hash;
+ r->setHash(hash);
location = r;
}
@@ -213,7 +213,7 @@ PassRefPtr<UString::Rep> Identifier::add(ExecState* exec, const UChar* s, int le
PassRefPtr<UString::Rep> Identifier::addSlowCase(JSGlobalData* globalData, UString::Rep* r)
{
ASSERT(!r->identifierTable());
- if (r->len == 1) {
+ if (r->size() == 1) {
UChar c = r->data()[0];
if (c <= 0xFF)
r = globalData->smallStrings.singleCharacterStringRep(c);
@@ -224,7 +224,7 @@ PassRefPtr<UString::Rep> Identifier::addSlowCase(JSGlobalData* globalData, UStri
return r;
}
}
- if (!r->len) {
+ if (!r->size()) {
UString::Rep::empty().hash();
return &UString::Rep::empty();
}
diff --git a/JavaScriptCore/runtime/JSString.cpp b/JavaScriptCore/runtime/JSString.cpp
index 28ae6f7..71d9973 100644
--- a/JavaScriptCore/runtime/JSString.cpp
+++ b/JavaScriptCore/runtime/JSString.cpp
@@ -125,7 +125,7 @@ void JSString::resolveRope(ExecState* exec) const
currentFiber = rope->fibers(ropeLengthMinusOne);
} else {
UString::Rep* string = currentFiber.string();
- unsigned length = string->len;
+ unsigned length = string->size();
position -= length;
copyChars(position, string->data(), length);
diff --git a/JavaScriptCore/runtime/JSString.h b/JavaScriptCore/runtime/JSString.h
index 865f383..54e67d9 100644
--- a/JavaScriptCore/runtime/JSString.h
+++ b/JavaScriptCore/runtime/JSString.h
@@ -96,7 +96,7 @@ namespace JSC {
{
if (isString()) {
UString::Rep* rep = string();
- return rep->ref()->len;
+ return rep->ref()->size();
} else {
Rope* r = rope();
r->ref();
@@ -135,7 +135,7 @@ namespace JSC {
{
UString::Rep* rep = string.rep();
m_fibers[index++] = Fiber(rep);
- m_stringLength += rep->ref()->len;
+ m_stringLength += rep->ref()->size();
}
void append(unsigned& index, JSString* jsString)
{
diff --git a/JavaScriptCore/runtime/StringBuilder.h b/JavaScriptCore/runtime/StringBuilder.h
index 6de2c3f..b6a1406 100644
--- a/JavaScriptCore/runtime/StringBuilder.h
+++ b/JavaScriptCore/runtime/StringBuilder.h
@@ -64,14 +64,13 @@ public:
void resize(size_t size) { buffer.resize(size); }
size_t size() const { return buffer.size(); }
- UChar operator[](size_t i) { return buffer.at(i); }
- const UChar operator[](size_t i) const { return buffer.at(i); }
+ UChar operator[](size_t i) const { return buffer.at(i); }
UString release()
{
buffer.shrinkToFit();
size_t length = buffer.size();
- return UString(buffer.releaseBuffer(), length, false);
+ return UString::createNonCopying(buffer.releaseBuffer(), length);
}
private:
diff --git a/JavaScriptCore/runtime/StringConstructor.cpp b/JavaScriptCore/runtime/StringConstructor.cpp
index 2f3adbe..8165ff2 100644
--- a/JavaScriptCore/runtime/StringConstructor.cpp
+++ b/JavaScriptCore/runtime/StringConstructor.cpp
@@ -35,7 +35,7 @@ static NEVER_INLINE JSValue stringFromCharCodeSlowCase(ExecState* exec, const Ar
ArgList::const_iterator end = args.end();
for (ArgList::const_iterator it = args.begin(); it != end; ++it)
*p++ = static_cast<UChar>((*it).toUInt32(exec));
- return jsString(exec, UString(buf, p - buf, false));
+ return jsString(exec, UString::createNonCopying(buf, p - buf));
}
static JSValue JSC_HOST_CALL stringFromCharCode(ExecState* exec, JSObject*, JSValue, const ArgList& args)
diff --git a/JavaScriptCore/runtime/StringPrototype.cpp b/JavaScriptCore/runtime/StringPrototype.cpp
index 5f470fd..205f469 100644
--- a/JavaScriptCore/runtime/StringPrototype.cpp
+++ b/JavaScriptCore/runtime/StringPrototype.cpp
@@ -212,7 +212,7 @@ static NEVER_INLINE UString substituteBackreferencesSlow(const UString& replacem
substitutedReplacement.shrinkToFit();
unsigned size = substitutedReplacement.size();
- return UString(substitutedReplacement.releaseBuffer(), size, false);
+ return UString::createNonCopying(substitutedReplacement.releaseBuffer(), size);
}
static inline UString substituteBackreferences(const UString& replacement, const UString& source, const int* ovector, RegExp* reg)
@@ -722,7 +722,7 @@ JSValue JSC_HOST_CALL stringProtoFuncToLowerCase(ExecState* exec, JSObject*, JSV
buffer[i] = toASCIILower(c);
}
if (!(ored & ~0x7f))
- return jsString(exec, UString(buffer.releaseBuffer(), sSize, false));
+ return jsString(exec, UString::createNonCopying(buffer.releaseBuffer(), sSize));
bool error;
int length = Unicode::toLower(buffer.data(), sSize, sData, sSize, &error);
@@ -734,7 +734,7 @@ JSValue JSC_HOST_CALL stringProtoFuncToLowerCase(ExecState* exec, JSObject*, JSV
}
if (length == sSize && memcmp(buffer.data(), sData, length * sizeof(UChar)) == 0)
return sVal;
- return jsString(exec, UString(buffer.releaseBuffer(), length, false));
+ return jsString(exec, UString::createNonCopying(buffer.releaseBuffer(), length));
}
JSValue JSC_HOST_CALL stringProtoFuncToUpperCase(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&)
@@ -756,7 +756,7 @@ JSValue JSC_HOST_CALL stringProtoFuncToUpperCase(ExecState* exec, JSObject*, JSV
buffer[i] = toASCIIUpper(c);
}
if (!(ored & ~0x7f))
- return jsString(exec, UString(buffer.releaseBuffer(), sSize, false));
+ return jsString(exec, UString::createNonCopying(buffer.releaseBuffer(), sSize));
bool error;
int length = Unicode::toUpper(buffer.data(), sSize, sData, sSize, &error);
@@ -768,7 +768,7 @@ JSValue JSC_HOST_CALL stringProtoFuncToUpperCase(ExecState* exec, JSObject*, JSV
}
if (length == sSize && memcmp(buffer.data(), sData, length * sizeof(UChar)) == 0)
return sVal;
- return jsString(exec, UString(buffer.releaseBuffer(), length, false));
+ return jsString(exec, UString::createNonCopying(buffer.releaseBuffer(), length));
}
JSValue JSC_HOST_CALL stringProtoFuncLocaleCompare(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
@@ -877,7 +877,7 @@ JSValue JSC_HOST_CALL stringProtoFuncFontsize(ExecState* exec, JSObject*, JSValu
buffer[19 + stringSize] = 'n';
buffer[20 + stringSize] = 't';
buffer[21 + stringSize] = '>';
- return jsNontrivialString(exec, UString(buffer, bufferSize, false));
+ return jsNontrivialString(exec, UString::createNonCopying(buffer, bufferSize));
}
return jsNontrivialString(exec, makeString("<font size=\"", a0.toString(exec), "\">", s, "</font>"));
@@ -919,7 +919,7 @@ JSValue JSC_HOST_CALL stringProtoFuncLink(ExecState* exec, JSObject*, JSValue th
buffer[12 + linkTextSize + stringSize] = '/';
buffer[13 + linkTextSize + stringSize] = 'a';
buffer[14 + linkTextSize + stringSize] = '>';
- return jsNontrivialString(exec, UString(buffer, bufferSize, false));
+ return jsNontrivialString(exec, UString::createNonCopying(buffer, bufferSize));
}
enum {
diff --git a/JavaScriptCore/runtime/UString.cpp b/JavaScriptCore/runtime/UString.cpp
index 50d23c4..267112f 100644
--- a/JavaScriptCore/runtime/UString.cpp
+++ b/JavaScriptCore/runtime/UString.cpp
@@ -610,22 +610,25 @@ UString::UString(const UChar* c, int length)
m_rep = Rep::createCopying(c, length);
}
-UString::UString(UChar* c, int length, bool copy)
+UString::UString(const Vector<UChar>& buffer)
{
- if (length == 0)
+ if (!buffer.size())
m_rep = &Rep::empty();
- else if (copy)
- m_rep = Rep::createCopying(c, length);
else
- m_rep = Rep::create(c, length);
+ m_rep = Rep::createCopying(buffer.data(), buffer.size());
}
-UString::UString(const Vector<UChar>& buffer)
+UString UString::createNonCopying(UChar* c, int length)
{
- if (!buffer.size())
- m_rep = &Rep::empty();
+ if (length == 0)
+ return UString(&Rep::empty());
else
- m_rep = Rep::createCopying(buffer.data(), buffer.size());
+ return Rep::create(c, length);
+}
+
+UString UString::createFromUTF8(const char* string)
+{
+ return Rep::createFromUTF8(string);
}
static ALWAYS_INLINE int newCapacityWithOverflowCheck(const int currentCapacity, const int extendLength, const bool plusOne = false)
diff --git a/JavaScriptCore/runtime/UString.h b/JavaScriptCore/runtime/UString.h
index b880f9c..016a21d 100644
--- a/JavaScriptCore/runtime/UString.h
+++ b/JavaScriptCore/runtime/UString.h
@@ -117,6 +117,7 @@ namespace JSC {
unsigned hash() const { if (_hash == 0) _hash = computeHash(data(), len); return _hash; }
unsigned computedHash() const { ASSERT(_hash); return _hash; } // fast path for Identifiers
+ void setHash(unsigned hash) { ASSERT(hash == computeHash(data(), len)); _hash = hash; } // fast path for Identifiers
static unsigned computeHash(const UChar*, int length);
static unsigned computeHash(const char*, int length);
@@ -240,25 +241,26 @@ namespace JSC {
// Constructor for non-null-terminated ASCII string.
UString(const char*, int length);
UString(const UChar*, int length);
- UString(UChar*, int length, bool copy);
+ UString(const Vector<UChar>& buffer);
UString(const UString& s)
: m_rep(s.m_rep)
{
}
- UString(const Vector<UChar>& buffer);
-
- ~UString()
- {
- }
-
// Special constructor for cases where we overwrite an object in place.
UString(PlacementNewAdoptType)
: m_rep(PlacementNewAdopt)
{
}
+ ~UString()
+ {
+ }
+
+ static UString createNonCopying(UChar* c, int length);
+ static UString createFromUTF8(const char*);
+
static UString from(int);
static UString from(long long);
static UString from(unsigned int);
@@ -624,7 +626,7 @@ namespace JSC {
result += adapter1.length();
adapter2.writeTo(result);
- return UString(buffer, length, false);
+ return UString::createNonCopying(buffer, length);
}
template<typename StringType1, typename StringType2, typename StringType3>
@@ -646,7 +648,7 @@ namespace JSC {
result += adapter2.length();
adapter3.writeTo(result);
- return UString(buffer, length, false);
+ return UString::createNonCopying(buffer, length);
}
template<typename StringType1, typename StringType2, typename StringType3, typename StringType4>
@@ -671,7 +673,7 @@ namespace JSC {
result += adapter3.length();
adapter4.writeTo(result);
- return UString(buffer, length, false);
+ return UString::createNonCopying(buffer, length);
}
template<typename StringType1, typename StringType2, typename StringType3, typename StringType4, typename StringType5>
@@ -699,7 +701,7 @@ namespace JSC {
result += adapter4.length();
adapter5.writeTo(result);
- return UString(buffer, length, false);
+ return UString::createNonCopying(buffer, length);
}
template<typename StringType1, typename StringType2, typename StringType3, typename StringType4, typename StringType5, typename StringType6>
@@ -730,7 +732,7 @@ namespace JSC {
result += adapter5.length();
adapter6.writeTo(result);
- return UString(buffer, length, false);
+ return UString::createNonCopying(buffer, length);
}
template<typename StringType1, typename StringType2, typename StringType3, typename StringType4, typename StringType5, typename StringType6, typename StringType7>
@@ -764,7 +766,7 @@ namespace JSC {
result += adapter6.length();
adapter7.writeTo(result);
- return UString(buffer, length, false);
+ return UString::createNonCopying(buffer, length);
}
template<typename StringType1, typename StringType2, typename StringType3, typename StringType4, typename StringType5, typename StringType6, typename StringType7, typename StringType8>
@@ -801,7 +803,7 @@ namespace JSC {
result += adapter7.length();
adapter8.writeTo(result);
- return UString(buffer, length, false);
+ return UString::createNonCopying(buffer, length);
}
} // namespace JSC
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list