Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(99)

Unified Diff: test/cctest/heap/test-heap.cc

Issue 2242183003: Clear recorded slots when making a string external (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix leak in test by stack-allocating temporary object Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/objects.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/heap/test-heap.cc
diff --git a/test/cctest/heap/test-heap.cc b/test/cctest/heap/test-heap.cc
index 3e524debb9ab57e2bf47087274f66bef1512a6a5..308df8ad58d62c44cd2088dbcf7aa334c735ad3f 100644
--- a/test/cctest/heap/test-heap.cc
+++ b/test/cctest/heap/test-heap.cc
@@ -6818,6 +6818,65 @@ TEST(Regress615489) {
CHECK_LE(size_after, size_before);
}
+class StaticOneByteResource : public v8::String::ExternalOneByteStringResource {
+ public:
+ explicit StaticOneByteResource(const char* data) : data_(data) {}
+
+ ~StaticOneByteResource() {}
+
+ const char* data() const { return data_; }
+
+ size_t length() const { return strlen(data_); }
+
+ private:
+ const char* data_;
+};
+
+TEST(Regress631969) {
+ FLAG_manual_evacuation_candidates_selection = true;
+ FLAG_parallel_compaction = false;
+ FLAG_concurrent_sweeping = false;
+ CcTest::InitializeVM();
+ v8::HandleScope scope(CcTest::isolate());
+ Heap* heap = CcTest::heap();
+ // Get the heap in clean state.
+ heap->CollectGarbage(OLD_SPACE);
+ heap->CollectGarbage(OLD_SPACE);
+ Isolate* isolate = CcTest::i_isolate();
+ Factory* factory = isolate->factory();
+ // Allocate two strings in a fresh page and mark the page as evacuation
+ // candidate.
+ heap::SimulateFullSpace(heap->old_space());
+ Handle<String> s1 = factory->NewStringFromStaticChars("123456789", TENURED);
+ Handle<String> s2 = factory->NewStringFromStaticChars("01234", TENURED);
+ Page::FromAddress(s1->address())
+ ->SetFlag(MemoryChunk::FORCE_EVACUATION_CANDIDATE_FOR_TESTING);
+
+ heap::SimulateIncrementalMarking(heap, false);
+
+ // Allocate a cons string and promote it to a fresh page in the old space.
+ heap::SimulateFullSpace(heap->old_space());
+ Handle<String> s3;
+ factory->NewConsString(s1, s2).ToHandle(&s3);
+ heap->CollectGarbage(NEW_SPACE);
+ heap->CollectGarbage(NEW_SPACE);
+
+ // Finish incremental marking.
+ IncrementalMarking* marking = heap->incremental_marking();
+ while (!marking->IsComplete()) {
+ marking->Step(MB, i::IncrementalMarking::NO_GC_VIA_STACK_GUARD);
+ if (marking->IsReadyToOverApproximateWeakClosure()) {
+ marking->FinalizeIncrementally();
+ }
+ }
+
+ {
+ StaticOneByteResource external_string("12345678901234");
+ s3->MakeExternal(&external_string);
+ heap->CollectGarbage(OLD_SPACE);
+ }
+}
+
TEST(LeftTrimFixedArrayInBlackArea) {
FLAG_black_allocation = true;
CcTest::InitializeVM();
« no previous file with comments | « src/objects.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698