Commit d340db91 authored by yangguo@chromium.org's avatar yangguo@chromium.org

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
parent 1726fcf0
......@@ -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());
WRITE_FIELD(this, kParentOffset, parent);
CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kParentOffset, parent, mode);
}
......
......@@ -7595,7 +7595,8 @@ class ConsString: public String {
class SlicedString: public String {
public:
inline String* parent();
inline void set_parent(String* parent);
inline void set_parent(String* parent,
WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
inline int offset();
inline void set_offset(int offset);
......
......@@ -1932,3 +1932,37 @@ TEST(ReleaseOverReservedPages) {
HEAP->CollectAllAvailableGarbage("triggered really hard");
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());
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment