Insert missing write barrier in sliced string allocation.

BUG=v8:2237
TEST=test-heap/Regress2237

Review URL: https://chromiumcodereview.appspot.com/10781033

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@12127 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
yangguo@chromium.org 2012-07-18 13:39:53 +00:00
parent 1726fcf010
commit d340db9135
3 changed files with 38 additions and 2 deletions

View File

@ -2434,9 +2434,10 @@ String* SlicedString::parent() {
} }
void SlicedString::set_parent(String* parent) { void SlicedString::set_parent(String* parent, WriteBarrierMode mode) {
ASSERT(parent->IsSeqString() || parent->IsExternalString()); ASSERT(parent->IsSeqString() || parent->IsExternalString());
WRITE_FIELD(this, kParentOffset, parent); WRITE_FIELD(this, kParentOffset, parent);
CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kParentOffset, parent, mode);
} }

View File

@ -7595,7 +7595,8 @@ class ConsString: public String {
class SlicedString: public String { class SlicedString: public String {
public: public:
inline String* parent(); inline String* parent();
inline void set_parent(String* parent); inline void set_parent(String* parent,
WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
inline int offset(); inline int offset();
inline void set_offset(int offset); inline void set_offset(int offset);

View File

@ -1932,3 +1932,37 @@ TEST(ReleaseOverReservedPages) {
HEAP->CollectAllAvailableGarbage("triggered really hard"); HEAP->CollectAllAvailableGarbage("triggered really hard");
CHECK_EQ(1, old_pointer_space->CountTotalPages()); CHECK_EQ(1, old_pointer_space->CountTotalPages());
} }
TEST(Regress2237) {
InitializeVM();
v8::HandleScope scope;
Handle<String> slice(HEAP->empty_string());
{
// Generate a parent that lives in new-space.
v8::HandleScope inner_scope;
const char* c = "This text is long enough to trigger sliced strings.";
Handle<String> s = FACTORY->NewStringFromAscii(CStrVector(c));
CHECK(s->IsSeqAsciiString());
CHECK(HEAP->InNewSpace(*s));
// Generate a sliced string that is based on the above parent and
// lives in old-space.
FillUpNewSpace(HEAP->new_space());
AlwaysAllocateScope always_allocate;
Handle<String> t;
// TODO(mstarzinger): Unfortunately FillUpNewSpace() still leaves
// some slack, so we need to allocate a few sliced strings.
for (int i = 0; i < 16; i++) {
t = FACTORY->NewProperSubString(s, 5, 35);
}
CHECK(t->IsSlicedString());
CHECK(!HEAP->InNewSpace(*t));
*slice.location() = *t.location();
}
CHECK(SlicedString::cast(*slice)->parent()->IsSeqAsciiString());
HEAP->CollectAllGarbage(Heap::kNoGCFlags);
CHECK(SlicedString::cast(*slice)->parent()->IsSeqAsciiString());
}