Bug 711266 - JSRope::flatten needs unconditional post barriers; r=billm

For incremental barriers we check if compartment()->needsBarrier to defer the
cost when we are not in a GC cycle.  We cannot do this for cross-generation
barriers.  We need to remove the checks on the post barriers and rename the enum
to something  more specific.
This commit is contained in:
Terrence Cole 2011-12-15 17:34:59 -08:00
Родитель af19ff07c8
Коммит 9b83926c78
3 изменённых файлов: 9 добавлений и 8 удалений

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

@ -93,6 +93,8 @@ JSRope::init(JSString *left, JSString *right, size_t length)
d.lengthAndFlags = buildLengthAndFlags(length, ROPE_BIT); d.lengthAndFlags = buildLengthAndFlags(length, ROPE_BIT);
d.u1.left = left; d.u1.left = left;
d.s.u2.right = right; d.s.u2.right = right;
JSString::writeBarrierPost(d.u1.left, &d.u1.left);
JSString::writeBarrierPost(d.s.u2.right, &d.s.u2.right);
} }
JS_ALWAYS_INLINE JSRope * JS_ALWAYS_INLINE JSRope *
@ -113,6 +115,7 @@ JSDependentString::init(JSLinearString *base, const jschar *chars, size_t length
d.lengthAndFlags = buildLengthAndFlags(length, DEPENDENT_BIT); d.lengthAndFlags = buildLengthAndFlags(length, DEPENDENT_BIT);
d.u1.chars = chars; d.u1.chars = chars;
d.s.u2.base = base; d.s.u2.base = base;
JSString::writeBarrierPost(d.s.u2.base, &d.s.u2.base);
} }
JS_ALWAYS_INLINE JSDependentString * JS_ALWAYS_INLINE JSDependentString *

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

@ -187,7 +187,7 @@ JSRope::flattenInternal(JSContext *maybecx)
JSExtensibleString &left = this->leftChild()->asExtensible(); JSExtensibleString &left = this->leftChild()->asExtensible();
size_t capacity = left.capacity(); size_t capacity = left.capacity();
if (capacity >= wholeLength) { if (capacity >= wholeLength) {
if (b == WithBarrier) { if (b == WithIncrementalBarrier) {
JSString::writeBarrierPre(d.u1.left); JSString::writeBarrierPre(d.u1.left);
JSString::writeBarrierPre(d.s.u2.right); JSString::writeBarrierPre(d.s.u2.right);
} }
@ -198,8 +198,7 @@ JSRope::flattenInternal(JSContext *maybecx)
pos = wholeChars + (bits >> LENGTH_SHIFT); pos = wholeChars + (bits >> LENGTH_SHIFT);
left.d.lengthAndFlags = bits ^ (EXTENSIBLE_FLAGS | DEPENDENT_BIT); left.d.lengthAndFlags = bits ^ (EXTENSIBLE_FLAGS | DEPENDENT_BIT);
left.d.s.u2.base = (JSLinearString *)this; /* will be true on exit */ left.d.s.u2.base = (JSLinearString *)this; /* will be true on exit */
if (b == WithBarrier) JSString::writeBarrierPost(left.d.s.u2.base, &left.d.s.u2.base);
JSString::writeBarrierPost(this, &left.d.s.u2.base);
goto visit_right_child; goto visit_right_child;
} }
} }
@ -209,7 +208,7 @@ JSRope::flattenInternal(JSContext *maybecx)
pos = wholeChars; pos = wholeChars;
first_visit_node: { first_visit_node: {
if (b == WithBarrier) { if (b == WithIncrementalBarrier) {
JSString::writeBarrierPre(str->d.u1.left); JSString::writeBarrierPre(str->d.u1.left);
JSString::writeBarrierPre(str->d.s.u2.right); JSString::writeBarrierPre(str->d.s.u2.right);
} }
@ -250,8 +249,7 @@ JSRope::flattenInternal(JSContext *maybecx)
size_t progress = str->d.lengthAndFlags; size_t progress = str->d.lengthAndFlags;
str->d.lengthAndFlags = buildLengthAndFlags(pos - str->d.u1.chars, DEPENDENT_BIT); str->d.lengthAndFlags = buildLengthAndFlags(pos - str->d.u1.chars, DEPENDENT_BIT);
str->d.s.u2.base = (JSLinearString *)this; /* will be true on exit */ str->d.s.u2.base = (JSLinearString *)this; /* will be true on exit */
if (b == WithBarrier) JSString::writeBarrierPost(str->d.s.u2.base, &str->d.s.u2.base);
JSString::writeBarrierPost(this, &str->d.s.u2.base);
str = str->d.s.u3.parent; str = str->d.s.u3.parent;
if (progress == 0x200) if (progress == 0x200)
goto visit_right_child; goto visit_right_child;
@ -265,7 +263,7 @@ JSRope::flatten(JSContext *maybecx)
{ {
#if JSGC_INCREMENTAL #if JSGC_INCREMENTAL
if (compartment()->needsBarrier()) if (compartment()->needsBarrier())
return flattenInternal<WithBarrier>(maybecx); return flattenInternal<WithIncrementalBarrier>(maybecx);
else else
return flattenInternal<NoBarrier>(maybecx); return flattenInternal<NoBarrier>(maybecx);
#else #else

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

@ -426,7 +426,7 @@ class JSString : public js::gc::Cell
class JSRope : public JSString class JSRope : public JSString
{ {
enum UsingBarrier { WithBarrier, NoBarrier }; enum UsingBarrier { WithIncrementalBarrier, NoBarrier };
template<UsingBarrier b> template<UsingBarrier b>
JSFlatString *flattenInternal(JSContext *cx); JSFlatString *flattenInternal(JSContext *cx);