Bug 604756 diagnostic: serialize flatten to test if concurrent calls cause the bug, r=dvander, a=beta 7 blocker

This commit is contained in:
David Mandelin 2010-10-26 19:02:01 -07:00
Родитель 817f4533d7
Коммит 84d7826ab9
1 изменённых файлов: 14 добавлений и 0 удалений

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

@ -104,6 +104,18 @@ js_GetStringChars(JSContext *cx, JSString *str)
void
JSString::flatten()
{
// Diagnostic: serialize all calls to this function to see
// if concurrent calls are crashing us.
JS_LOCK_RUNTIME(asCell()->compartment()->rt);
// The main body of this function can be executed only if
// the string is a rope. With multiple threads, it's possible
// we waited while another one ran, and the string has
// already been flattened for us.
if (!isRope()) {
JS_UNLOCK_RUNTIME(asCell()->compartment()->rt);
return;
}
JSString *topNode;
jschar *chars;
size_t capacity;
@ -181,6 +193,8 @@ JSString::flatten()
/* Set null terminator. */
chars[pos] = 0;
topNode->initFlatMutable(chars, pos, capacity);
JS_UNLOCK_RUNTIME(asCell()->compartment()->rt);
}
#ifdef JS_TRACER