[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.21-584-g1e41756
barraclough at apple.com
barraclough at apple.com
Fri Feb 26 22:15:50 UTC 2010
The following commit has been merged in the webkit-1.1 branch:
commit eda36b0eebdf93aebdf0c02d4f18e4773b22764a
Author: barraclough at apple.com <barraclough at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Tue Feb 9 11:55:39 2010 +0000
Three small string fixes:
(1) StringBuilder::release should CRASH if the buffer allocation failed.
(2) Remove weird, dead code from JSString::tryGetValue, replace with an ASSERT.
(3) Move UString::createFromUTF8 out to the API, as tryCreateStringFromUTF8.
This is only used from the API, and (now) unlike other UString::create
methods may return UString::null() to indicate failure cases. Better
handle these in the API.
Reviewed by Oliver Hunt.
* API/JSClassRef.cpp:
(tryCreateStringFromUTF8):
(OpaqueJSClass::OpaqueJSClass):
(OpaqueJSClassContextData::OpaqueJSClassContextData):
* runtime/JSString.h:
(JSC::Fiber::tryGetValue):
* runtime/StringBuilder.h:
(JSC::StringBuilder::release):
* runtime/UString.cpp:
(JSC::UString::UString):
(JSC::UString::from):
(JSC::UString::find):
* runtime/UString.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@54545 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/JavaScriptCore/API/JSClassRef.cpp b/JavaScriptCore/API/JSClassRef.cpp
index d75d5cd..37bbff8 100644
--- a/JavaScriptCore/API/JSClassRef.cpp
+++ b/JavaScriptCore/API/JSClassRef.cpp
@@ -33,12 +33,28 @@
#include <runtime/JSGlobalObject.h>
#include <runtime/ObjectPrototype.h>
#include <runtime/Identifier.h>
+#include <wtf/unicode/UTF8.h>
using namespace std;
using namespace JSC;
+using namespace WTF::Unicode;
const JSClassDefinition kJSClassDefinitionEmpty = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+UString tryCreateStringFromUTF8(const char* string)
+{
+ if (!string)
+ return UString::null();
+
+ size_t length = strlen(string);
+ Vector<UChar, 1024> buffer(length);
+ UChar* p = buffer.data();
+ if (conversionOK != convertUTF8ToUTF16(&string, string + length, &p, p + length))
+ return UString::null();
+
+ return UString(buffer.data(), p - buffer.data());
+}
+
OpaqueJSClass::OpaqueJSClass(const JSClassDefinition* definition, OpaqueJSClass* protoClass)
: parentClass(definition->parentClass)
, prototypeClass(0)
@@ -53,7 +69,7 @@ OpaqueJSClass::OpaqueJSClass(const JSClassDefinition* definition, OpaqueJSClass*
, callAsConstructor(definition->callAsConstructor)
, hasInstance(definition->hasInstance)
, convertToType(definition->convertToType)
- , m_className(UString::createFromUTF8(definition->className).rep()->ref())
+ , m_className(tryCreateStringFromUTF8(definition->className))
, m_staticValues(0)
, m_staticFunctions(0)
{
@@ -62,9 +78,12 @@ OpaqueJSClass::OpaqueJSClass(const JSClassDefinition* definition, OpaqueJSClass*
if (const JSStaticValue* staticValue = definition->staticValues) {
m_staticValues = new OpaqueJSClassStaticValuesTable();
while (staticValue->name) {
- // Use a local variable here to sidestep an RVCT compiler bug.
- StaticValueEntry* entry = new StaticValueEntry(staticValue->getProperty, staticValue->setProperty, staticValue->attributes);
- m_staticValues->add(UString::createFromUTF8(staticValue->name).rep()->ref(), entry);
+ UString valueName = tryCreateStringFromUTF8(staticValue->name);
+ if (!valueName.isNull()) {
+ // Use a local variable here to sidestep an RVCT compiler bug.
+ StaticValueEntry* entry = new StaticValueEntry(staticValue->getProperty, staticValue->setProperty, staticValue->attributes);
+ m_staticValues->add(valueName.rep()->ref(), entry);
+ }
++staticValue;
}
}
@@ -72,9 +91,12 @@ OpaqueJSClass::OpaqueJSClass(const JSClassDefinition* definition, OpaqueJSClass*
if (const JSStaticFunction* staticFunction = definition->staticFunctions) {
m_staticFunctions = new OpaqueJSClassStaticFunctionsTable();
while (staticFunction->name) {
- // Use a local variable here to sidestep an RVCT compiler bug.
- StaticFunctionEntry* entry = new StaticFunctionEntry(staticFunction->callAsFunction, staticFunction->attributes);
- m_staticFunctions->add(UString::createFromUTF8(staticFunction->name).rep()->ref(), entry);
+ UString functionName = tryCreateStringFromUTF8(staticFunction->name);
+ if (!functionName.isNull()) {
+ // Use a local variable here to sidestep an RVCT compiler bug.
+ StaticFunctionEntry* entry = new StaticFunctionEntry(staticFunction->callAsFunction, staticFunction->attributes);
+ m_staticFunctions->add(functionName.rep()->ref(), entry);
+ }
++staticFunction;
}
}
@@ -146,12 +168,9 @@ OpaqueJSClassContextData::OpaqueJSClassContextData(OpaqueJSClass* jsClass)
// Use a local variable here to sidestep an RVCT compiler bug.
StaticValueEntry* entry = new StaticValueEntry(it->second->getProperty, it->second->setProperty, it->second->attributes);
staticValues->add(UString::Rep::create(it->first->data(), it->first->size()), entry);
-
}
-
} else
staticValues = 0;
-
if (jsClass->m_staticFunctions) {
staticFunctions = new OpaqueJSClassStaticFunctionsTable;
diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index 1acabd5..54c4e5f 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,29 @@
+2010-02-09 Gavin Barraclough <barraclough at apple.com>
+
+ Reviewed by Oliver Hunt.
+
+ Three small string fixes:
+ (1) StringBuilder::release should CRASH if the buffer allocation failed.
+ (2) Remove weird, dead code from JSString::tryGetValue, replace with an ASSERT.
+ (3) Move UString::createFromUTF8 out to the API, as tryCreateStringFromUTF8.
+ This is only used from the API, and (now) unlike other UString::create
+ methods may return UString::null() to indicate failure cases. Better
+ handle these in the API.
+
+ * API/JSClassRef.cpp:
+ (tryCreateStringFromUTF8):
+ (OpaqueJSClass::OpaqueJSClass):
+ (OpaqueJSClassContextData::OpaqueJSClassContextData):
+ * runtime/JSString.h:
+ (JSC::Fiber::tryGetValue):
+ * runtime/StringBuilder.h:
+ (JSC::StringBuilder::release):
+ * runtime/UString.cpp:
+ (JSC::UString::UString):
+ (JSC::UString::from):
+ (JSC::UString::find):
+ * runtime/UString.h:
+
2010-02-09 Janne Koskinen <janne.p.koskinen at digia.com>
Reviewed by Laszlo Gombos.
diff --git a/JavaScriptCore/runtime/JSString.h b/JavaScriptCore/runtime/JSString.h
index af03025..cff8e3a 100644
--- a/JavaScriptCore/runtime/JSString.h
+++ b/JavaScriptCore/runtime/JSString.h
@@ -283,8 +283,9 @@ namespace JSC {
}
const UString tryGetValue() const
{
- if (isRope())
- UString();
+ // If this is a rope, m_value should be null -
+ // if this is not a rope, m_value should be non-null.
+ ASSERT(isRope() == m_value.isNull());
return m_value;
}
unsigned length() { return m_stringLength; }
diff --git a/JavaScriptCore/runtime/StringBuilder.h b/JavaScriptCore/runtime/StringBuilder.h
index e121dfc..6bfa0c4 100644
--- a/JavaScriptCore/runtime/StringBuilder.h
+++ b/JavaScriptCore/runtime/StringBuilder.h
@@ -69,6 +69,8 @@ public:
UString release()
{
buffer.shrinkToFit();
+ if (!buffer.data())
+ CRASH();
return UString::adopt(buffer);
}
diff --git a/JavaScriptCore/runtime/UString.cpp b/JavaScriptCore/runtime/UString.cpp
index dc927b1..4a89a23 100644
--- a/JavaScriptCore/runtime/UString.cpp
+++ b/JavaScriptCore/runtime/UString.cpp
@@ -53,7 +53,7 @@ using namespace WTF::Unicode;
using namespace std;
namespace JSC {
-
+
extern const double NaN;
extern const double Inf;
@@ -146,7 +146,7 @@ bool operator==(const CString& c1, const CString& c2)
return len == c2.size() && (len == 0 || memcmp(c1.c_str(), c2.c_str(), len) == 0);
}
-// These static strings are immutable, except for rc, whose initial value is chosen to
+// These static strings are immutable, except for rc, whose initial value is chosen to
// reduce the possibility of it becoming zero due to ref/deref not being thread-safe.
static UChar sharedEmptyChar;
UStringImpl* UStringImpl::s_empty;
@@ -174,32 +174,18 @@ UString::UString(const char* c, int length)
UString::UString(const UChar* c, int length)
{
- if (length == 0)
+ if (length == 0)
m_rep = &Rep::empty();
else
m_rep = Rep::create(c, length);
}
-UString UString::createFromUTF8(const char* string)
-{
- if (!string)
- return null();
-
- size_t length = strlen(string);
- Vector<UChar, 1024> buffer(length);
- UChar* p = buffer.data();
- if (conversionOK != convertUTF8ToUTF16(&string, string + length, &p, p + length))
- return null();
-
- return UString(buffer.data(), p - buffer.data());
-}
-
UString UString::from(int i)
{
UChar buf[1 + sizeof(i) * 3];
UChar* end = buf + sizeof(buf) / sizeof(UChar);
UChar* p = end;
-
+
if (i == 0)
*--p = '0';
else if (i == INT_MIN) {
@@ -261,7 +247,7 @@ UString UString::from(unsigned int u)
UChar buf[sizeof(u) * 3];
UChar* end = buf + sizeof(buf) / sizeof(UChar);
UChar* p = end;
-
+
if (u == 0)
*--p = '0';
else {
@@ -270,7 +256,7 @@ UString UString::from(unsigned int u)
u /= 10;
}
}
-
+
return UString(p, static_cast<int>(end - p));
}
@@ -597,7 +583,7 @@ int UString::find(UChar ch, int pos) const
if (*c == ch)
return static_cast<int>(c - data());
}
-
+
return -1;
}
diff --git a/JavaScriptCore/runtime/UString.h b/JavaScriptCore/runtime/UString.h
index c6b1ccf..7d9ec49 100644
--- a/JavaScriptCore/runtime/UString.h
+++ b/JavaScriptCore/runtime/UString.h
@@ -81,7 +81,6 @@ namespace JSC {
typedef UStringImpl Rep;
public:
- // UString constructors passed char*s assume ISO Latin-1 encoding; for UTF8 use 'createFromUTF8', below.
UString();
UString(const char*); // Constructor for null-terminated string.
UString(const char*, int length);
@@ -109,8 +108,6 @@ namespace JSC {
return Rep::adopt(vector);
}
- static UString createFromUTF8(const char*);
-
static UString from(int);
static UString from(long long);
static UString from(unsigned int);
diff --git a/JavaScriptCore/runtime/UStringImpl.h b/JavaScriptCore/runtime/UStringImpl.h
index 8b2c4ac..6010ba6 100644
--- a/JavaScriptCore/runtime/UStringImpl.h
+++ b/JavaScriptCore/runtime/UStringImpl.h
@@ -87,6 +87,7 @@ public:
template<size_t inlineCapacity>
static PassRefPtr<UStringImpl> adopt(Vector<UChar, inlineCapacity>& vector)
{
+ ASSERT(vector.data());
if (unsigned length = vector.size())
return adoptRef(new UStringImpl(vector.releaseBuffer(), length, BufferOwned));
return &empty();
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list