Bug 639883 - rm js_FinalizeStringRT (r=igor)

--HG--
extra : rebase_source : c7f77ad290112fe7d6c53255dbf5595c94be3422
This commit is contained in:
Luke Wagner 2011-03-31 16:05:31 -07:00
Родитель b26af94399
Коммит 8c0d9d3fb1
4 изменённых файлов: 30 добавлений и 40 удалений

Просмотреть файл

@ -363,10 +363,8 @@ js_FinishAtomState(JSRuntime *rt)
return;
}
for (AtomSet::Range r = state->atoms.all(); !r.empty(); r.popFront()) {
JSString *str = AtomEntryToKey(r.front());
js_FinalizeStringRT(rt, str);
}
for (AtomSet::Range r = state->atoms.all(); !r.empty(); r.popFront())
AtomEntryToKey(r.front())->finalize(rt);
#ifdef JS_THREADSAFE
js_FinishLock(&state->lock);

Просмотреть файл

@ -1782,36 +1782,6 @@ js_DestroyScriptsToGC(JSContext *cx, JSCompartment *comp)
}
}
/*
* This function is called from js_FinishAtomState to force the finalization
* of the permanently interned strings when cx is not available.
*/
void
js_FinalizeStringRT(JSRuntime *rt, JSString *str)
{
JS_RUNTIME_UNMETER(rt, liveStrings);
JS_ASSERT(str->isLinear() && !str->isStaticAtom());
if (str->isDependent()) {
/* A dependent string can not be external and must be valid. */
JS_ASSERT(str->arena()->header()->thingKind == FINALIZE_STRING);
JS_ASSERT(str->asDependent().base());
JS_RUNTIME_UNMETER(rt, liveDependentStrings);
} else {
unsigned thingKind = str->arena()->header()->thingKind;
JS_ASSERT(unsigned(FINALIZE_SHORT_STRING) <= thingKind &&
thingKind <= unsigned(FINALIZE_EXTERNAL_STRING));
jschar *chars = const_cast<jschar *>(str->asFlat().chars());
if (thingKind == FINALIZE_STRING) {
rt->stringMemoryUsed -= str->length() * 2;
rt->free_(chars);
} else if (thingKind == FINALIZE_EXTERNAL_STRING) {
((JSExternalString *)str)->finalize();
}
}
}
template<typename T>
static void
FinalizeArenaList(JSCompartment *comp, JSContext *cx, unsigned thingKind)

Просмотреть файл

@ -444,6 +444,10 @@ class JSFlatString : public JSLinearString
JS_ASSERT(isFlat());
return chars();
}
/* Only called by the GC for strings with the FINALIZE_STRING kind. */
inline void finalize(JSRuntime *rt);
};
JS_STATIC_ASSERT(sizeof(JSFlatString) == sizeof(JSString));
@ -627,6 +631,8 @@ class JSAtom : public JSFixedString
/* Return null if no static atom exists for the given (chars, length). */
static inline JSStaticAtom *lookupStatic(const jschar *chars, size_t length);
inline void finalize(JSRuntime *rt);
};
JS_STATIC_ASSERT(sizeof(JSAtom) == sizeof(JSString));

Просмотреть файл

@ -465,14 +465,20 @@ JSString::finalize(JSContext *cx)
JS_RUNTIME_UNMETER(cx->runtime, liveStrings);
if (isDependent()) {
if (isDependent())
JS_RUNTIME_UNMETER(cx->runtime, liveDependentStrings);
} else if (isFlat()) {
cx->runtime->stringMemoryUsed -= length() * 2;
cx->free_(const_cast<jschar *>(asFlat().chars()));
} else {
else if (isFlat())
asFlat().finalize(cx->runtime);
else
JS_ASSERT(isRope());
}
}
inline void
JSFlatString::finalize(JSRuntime *rt)
{
JS_ASSERT(!isShort());
rt->stringMemoryUsed -= length() * 2;
rt->free(const_cast<jschar *>(chars()));
}
inline void
@ -482,6 +488,16 @@ JSShortString::finalize(JSContext *cx)
JS_RUNTIME_UNMETER(cx->runtime, liveStrings);
}
inline void
JSAtom::finalize(JSRuntime *rt)
{
JS_ASSERT(isAtom());
if (arena()->header()->thingKind == js::gc::FINALIZE_STRING)
asFlat().finalize(rt);
else
JS_ASSERT(arena()->header()->thingKind == js::gc::FINALIZE_SHORT_STRING);
}
inline void
JSExternalString::finalize(JSContext *cx)
{