+
+const ClassInfo JSString::s_info = { "string", 0, 0, 0, CREATE_METHOD_TABLE(JSString) };
+
+void JSRopeString::RopeBuilder::expand()
+{
+ ASSERT(m_index == JSRopeString::s_maxInternalRopeLength);
+ JSString* jsString = m_jsString;
+ RELEASE_ASSERT(jsString);
+ m_jsString = jsStringBuilder(&m_vm);
+ m_index = 0;
+ append(jsString);
+}
+
+void JSString::destroy(JSCell* cell)
+{
+ JSString* thisObject = static_cast<JSString*>(cell);
+ thisObject->JSString::~JSString();
+}
+
+void JSString::dumpToStream(const JSCell* cell, PrintStream& out)
+{
+ const JSString* thisObject = jsCast<const JSString*>(cell);
+ out.printf("<%p, %s, [%u], ", thisObject, thisObject->className(), thisObject->length());
+ if (thisObject->isRope())
+ out.printf("[rope]");
+ else {
+ WTF::StringImpl* ourImpl = thisObject->m_value.impl();
+ if (ourImpl->is8Bit())
+ out.printf("[8 %p]", ourImpl->characters8());
+ else
+ out.printf("[16 %p]", ourImpl->characters16());
+ }
+ out.printf(">");
+}
+
+void JSString::visitChildren(JSCell* cell, SlotVisitor& visitor)
+{
+ JSString* thisObject = jsCast<JSString*>(cell);
+ Base::visitChildren(thisObject, visitor);
+
+ if (thisObject->isRope())
+ static_cast<JSRopeString*>(thisObject)->visitFibers(visitor);
+ else {
+ StringImpl* impl = thisObject->m_value.impl();
+ ASSERT(impl);
+ visitor.reportExtraMemoryUsage(thisObject, impl->costDuringGC());
+ }
+}
+
+void JSRopeString::visitFibers(SlotVisitor& visitor)
+{
+ for (size_t i = 0; i < s_maxInternalRopeLength && m_fibers[i]; ++i)
+ visitor.append(&m_fibers[i]);
+}