summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/runtime/JSString.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-05-07 11:21:11 +0200
committerSimon Hausmann <simon.hausmann@nokia.com>2012-05-07 11:21:11 +0200
commit2cf6c8816a73e0132bd8fa3b509d62d7c51b6e47 (patch)
tree988e8c5b116dd0466244ae2fe5af8ee9be926d76 /Source/JavaScriptCore/runtime/JSString.cpp
parentdd91e772430dc294e3bf478c119ef8d43c0a3358 (diff)
downloadqtwebkit-2cf6c8816a73e0132bd8fa3b509d62d7c51b6e47.tar.gz
Imported WebKit commit 7e538425aa020340619e927792f3d895061fb54b (http://svn.webkit.org/repository/webkit/trunk@116286)
Diffstat (limited to 'Source/JavaScriptCore/runtime/JSString.cpp')
-rw-r--r--Source/JavaScriptCore/runtime/JSString.cpp35
1 files changed, 22 insertions, 13 deletions
diff --git a/Source/JavaScriptCore/runtime/JSString.cpp b/Source/JavaScriptCore/runtime/JSString.cpp
index e84ce3620..904cc4d3e 100644
--- a/Source/JavaScriptCore/runtime/JSString.cpp
+++ b/Source/JavaScriptCore/runtime/JSString.cpp
@@ -36,9 +36,9 @@ static const unsigned substringFromRopeCutoff = 4;
const ClassInfo JSString::s_info = { "string", 0, 0, 0, CREATE_METHOD_TABLE(JSString) };
-void JSString::RopeBuilder::expand()
+void JSRopeString::RopeBuilder::expand()
{
- ASSERT(m_index == JSString::s_maxInternalRopeLength);
+ ASSERT(m_index == JSRopeString::s_maxInternalRopeLength);
JSString* jsString = m_jsString;
m_jsString = jsStringBuilder(&m_globalData);
m_index = 0;
@@ -55,11 +55,18 @@ void JSString::visitChildren(JSCell* cell, SlotVisitor& visitor)
{
JSString* thisObject = jsCast<JSString*>(cell);
Base::visitChildren(thisObject, visitor);
- for (size_t i = 0; i < s_maxInternalRopeLength && thisObject->m_fibers[i]; ++i)
- visitor.append(&thisObject->m_fibers[i]);
+
+ if (thisObject->isRope())
+ static_cast<JSRopeString*>(thisObject)->visitFibers(visitor);
+}
+
+void JSRopeString::visitFibers(SlotVisitor& visitor)
+{
+ for (size_t i = 0; i < s_maxInternalRopeLength && m_fibers[i]; ++i)
+ visitor.append(&m_fibers[i]);
}
-void JSString::resolveRope(ExecState* exec) const
+void JSRopeString::resolveRope(ExecState* exec) const
{
ASSERT(isRope());
@@ -128,7 +135,7 @@ void JSString::resolveRope(ExecState* exec) const
// Vector before performing any concatenation, but by working backwards we likely
// only fill the queue with the number of substrings at any given level in a
// rope-of-ropes.)
-void JSString::resolveRopeSlowCase8(LChar* buffer) const
+void JSRopeString::resolveRopeSlowCase8(LChar* buffer) const
{
LChar* position = buffer + m_length; // We will be working backwards over the rope.
Vector<JSString*, 32> workQueue; // Putting strings into a Vector is only OK because there are no GC points in this method.
@@ -144,8 +151,9 @@ void JSString::resolveRopeSlowCase8(LChar* buffer) const
workQueue.removeLast();
if (currentFiber->isRope()) {
- for (size_t i = 0; i < s_maxInternalRopeLength && currentFiber->m_fibers[i]; ++i)
- workQueue.append(currentFiber->m_fibers[i].get());
+ JSRopeString* currentFiberAsRope = static_cast<JSRopeString*>(currentFiber);
+ for (size_t i = 0; i < s_maxInternalRopeLength && currentFiberAsRope->m_fibers[i]; ++i)
+ workQueue.append(currentFiberAsRope->m_fibers[i].get());
continue;
}
@@ -159,7 +167,7 @@ void JSString::resolveRopeSlowCase8(LChar* buffer) const
ASSERT(!isRope());
}
-void JSString::resolveRopeSlowCase(UChar* buffer) const
+void JSRopeString::resolveRopeSlowCase(UChar* buffer) const
{
UChar* position = buffer + m_length; // We will be working backwards over the rope.
Vector<JSString*, 32> workQueue; // These strings are kept alive by the parent rope, so using a Vector is OK.
@@ -172,8 +180,9 @@ void JSString::resolveRopeSlowCase(UChar* buffer) const
workQueue.removeLast();
if (currentFiber->isRope()) {
- for (size_t i = 0; i < s_maxInternalRopeLength && currentFiber->m_fibers[i]; ++i)
- workQueue.append(currentFiber->m_fibers[i].get());
+ JSRopeString* currentFiberAsRope = static_cast<JSRopeString*>(currentFiber);
+ for (size_t i = 0; i < s_maxInternalRopeLength && currentFiberAsRope->m_fibers[i]; ++i)
+ workQueue.append(currentFiberAsRope->m_fibers[i].get());
continue;
}
@@ -187,7 +196,7 @@ void JSString::resolveRopeSlowCase(UChar* buffer) const
ASSERT(!isRope());
}
-void JSString::outOfMemory(ExecState* exec) const
+void JSRopeString::outOfMemory(ExecState* exec) const
{
for (size_t i = 0; i < s_maxInternalRopeLength && m_fibers[i]; ++i)
m_fibers[i].clear();
@@ -197,7 +206,7 @@ void JSString::outOfMemory(ExecState* exec) const
throwOutOfMemoryError(exec);
}
-JSString* JSString::getIndexSlowCase(ExecState* exec, unsigned i)
+JSString* JSRopeString::getIndexSlowCase(ExecState* exec, unsigned i)
{
ASSERT(isRope());
resolveRope(exec);