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

Unified Diff: test/cctest/heap/test-array-buffer-tracker.cc

Issue 2210263002: [heap] Improve size profiling for ArrayBuffer tracking (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase 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/heap/spaces.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-array-buffer-tracker.cc
diff --git a/test/cctest/heap/test-array-buffer-tracker.cc b/test/cctest/heap/test-array-buffer-tracker.cc
index b331f6bf3a5a8a3eee261e14449ccf96a57a8ecc..d20798bdf31692a47d1f8a537a9d94f3ece3d77d 100644
--- a/test/cctest/heap/test-array-buffer-tracker.cc
+++ b/test/cctest/heap/test-array-buffer-tracker.cc
@@ -314,5 +314,65 @@ UNINITIALIZED_TEST(ArrayBuffer_SemiSpaceCopyMultipleTasks) {
}
}
+TEST(ArrayBuffer_RetainedCounterPromotion) {
+ // The test checks that retained counters on ArrayBufferTracker are consistent
+ // with where the buffers are on the heap.
+ CcTest::InitializeVM();
+ LocalContext env;
+ v8::Isolate* isolate = env->GetIsolate();
+ Heap* heap = reinterpret_cast<Isolate*>(isolate)->heap();
+ ArrayBufferTracker* tracker = heap->array_buffer_tracker();
+ {
+ v8::HandleScope handle_scope(isolate);
+ Local<v8::ArrayBuffer> ab = v8::ArrayBuffer::New(isolate, 100);
+ Handle<JSArrayBuffer> buf = v8::Utils::OpenHandle(*ab);
+ CHECK(heap->InNewSpace(*buf));
+ CHECK_EQ(tracker->retained_from_new_space(), 100u);
+ CHECK_EQ(tracker->retained_from_old_space(), 0u);
+ heap::GcAndSweep(heap, OLD_SPACE);
+ CHECK(heap->InNewSpace(*buf));
+ CHECK_EQ(tracker->retained_from_new_space(), 100u);
+ CHECK_EQ(tracker->retained_from_old_space(), 0u);
+ heap::GcAndSweep(heap, OLD_SPACE);
+ CHECK(heap->InOldSpace(*buf));
+ CHECK_EQ(tracker->retained_from_new_space(), 0u);
+ CHECK_EQ(tracker->retained_from_old_space(), 100u);
+ }
+}
+
+TEST(ArrayBuffer_RetainedCounterNewSpace) {
+ // The test checks that retained counters on ArrayBufferTracker are consistent
+ // with where the buffers are on the heap.
+ CcTest::InitializeVM();
+ LocalContext env;
+ v8::Isolate* isolate = env->GetIsolate();
+ Heap* heap = reinterpret_cast<Isolate*>(isolate)->heap();
+ ArrayBufferTracker* tracker = heap->array_buffer_tracker();
+ {
+ v8::HandleScope handle_scope(isolate);
+ {
+ v8::HandleScope tmp_scope(isolate);
+ Local<v8::ArrayBuffer> ab = v8::ArrayBuffer::New(isolate, 100);
+ Handle<JSArrayBuffer> buf = v8::Utils::OpenHandle(*ab);
+ CHECK(heap->InNewSpace(*buf));
+ }
+ {
+ v8::HandleScope tmp_scope(isolate);
+ Local<v8::ArrayBuffer> ab = v8::ArrayBuffer::New(isolate, 50);
+ Handle<JSArrayBuffer> buf = v8::Utils::OpenHandle(*ab);
+ CHECK(heap->InNewSpace(*buf));
+ CHECK_EQ(tracker->retained_from_new_space(), 150u);
+ CHECK_EQ(tracker->retained_from_old_space(), 0u);
+ heap::GcAndSweep(heap, NEW_SPACE);
+ CHECK(heap->InNewSpace(*buf));
+ CHECK_EQ(tracker->retained_from_new_space(), 50u);
+ CHECK_EQ(tracker->retained_from_old_space(), 0u);
+ }
+ heap::GcAndSweep(heap, NEW_SPACE);
+ CHECK_EQ(tracker->retained_from_new_space(), 0u);
+ CHECK_EQ(tracker->retained_from_old_space(), 0u);
+ }
+}
+
} // namespace internal
} // namespace v8
« no previous file with comments | « src/heap/spaces.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698