OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/api.h" | 5 #include "src/api.h" |
6 #include "src/heap/array-buffer-tracker.h" | 6 #include "src/heap/array-buffer-tracker.h" |
7 #include "src/isolate.h" | 7 #include "src/isolate.h" |
8 #include "test/cctest/cctest.h" | 8 #include "test/cctest/cctest.h" |
9 #include "test/cctest/heap/heap-utils.h" | 9 #include "test/cctest/heap/heap-utils.h" |
10 | 10 |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 Local<v8::ArrayBuffer> ab1 = v8::ArrayBuffer::New(isolate, 100); | 123 Local<v8::ArrayBuffer> ab1 = v8::ArrayBuffer::New(isolate, 100); |
124 Handle<JSArrayBuffer> buf1 = v8::Utils::OpenHandle(*ab1); | 124 Handle<JSArrayBuffer> buf1 = v8::Utils::OpenHandle(*ab1); |
125 CHECK(IsTracked(*buf1)); | 125 CHECK(IsTracked(*buf1)); |
126 heap::GcAndSweep(heap, NEW_SPACE); | 126 heap::GcAndSweep(heap, NEW_SPACE); |
127 heap::GcAndSweep(heap, NEW_SPACE); | 127 heap::GcAndSweep(heap, NEW_SPACE); |
128 | 128 |
129 Page* page_before_gc = Page::FromAddress(buf1->address()); | 129 Page* page_before_gc = Page::FromAddress(buf1->address()); |
130 page_before_gc->SetFlag(MemoryChunk::FORCE_EVACUATION_CANDIDATE_FOR_TESTING); | 130 page_before_gc->SetFlag(MemoryChunk::FORCE_EVACUATION_CANDIDATE_FOR_TESTING); |
131 CHECK(IsTracked(*buf1)); | 131 CHECK(IsTracked(*buf1)); |
132 | 132 |
133 heap->CollectAllGarbage(); | 133 CcTest::CollectAllGarbage(i::Heap::kFinalizeIncrementalMarkingMask); |
134 | 134 |
135 Page* page_after_gc = Page::FromAddress(buf1->address()); | 135 Page* page_after_gc = Page::FromAddress(buf1->address()); |
136 CHECK(IsTracked(*buf1)); | 136 CHECK(IsTracked(*buf1)); |
137 | 137 |
138 CHECK_NE(page_before_gc, page_after_gc); | 138 CHECK_NE(page_before_gc, page_after_gc); |
139 } | 139 } |
140 | 140 |
141 TEST(ArrayBuffer_UnregisterDuringSweep) { | 141 TEST(ArrayBuffer_UnregisterDuringSweep) { |
142 // Regular pages in old space (without compaction) are processed concurrently | 142 // Regular pages in old space (without compaction) are processed concurrently |
143 // in the sweeper. If we happen to unregister a buffer (either explicitly, or | 143 // in the sweeper. If we happen to unregister a buffer (either explicitly, or |
(...skipping 26 matching lines...) Expand all Loading... |
170 CHECK(IsTracked(*buf)); | 170 CHECK(IsTracked(*buf)); |
171 CHECK(IsTracked(*buf)); | 171 CHECK(IsTracked(*buf)); |
172 heap::GcAndSweep(heap, NEW_SPACE); | 172 heap::GcAndSweep(heap, NEW_SPACE); |
173 CHECK(IsTracked(*buf)); | 173 CHECK(IsTracked(*buf)); |
174 CHECK(IsTracked(*buf)); | 174 CHECK(IsTracked(*buf)); |
175 heap::GcAndSweep(heap, NEW_SPACE); | 175 heap::GcAndSweep(heap, NEW_SPACE); |
176 CHECK(IsTracked(*buf)); | 176 CHECK(IsTracked(*buf)); |
177 CHECK(IsTracked(*buf2)); | 177 CHECK(IsTracked(*buf2)); |
178 } | 178 } |
179 | 179 |
180 heap->CollectGarbage(OLD_SPACE); | 180 CcTest::CollectGarbage(OLD_SPACE); |
181 // |Externalize| will cause the buffer to be |Unregister|ed. Without | 181 // |Externalize| will cause the buffer to be |Unregister|ed. Without |
182 // barriers and proper synchronization this will trigger a data race on | 182 // barriers and proper synchronization this will trigger a data race on |
183 // TSAN. | 183 // TSAN. |
184 v8::ArrayBuffer::Contents contents = ab->Externalize(); | 184 v8::ArrayBuffer::Contents contents = ab->Externalize(); |
185 heap->isolate()->array_buffer_allocator()->Free(contents.Data(), | 185 heap->isolate()->array_buffer_allocator()->Free(contents.Data(), |
186 contents.ByteLength()); | 186 contents.ByteLength()); |
187 } | 187 } |
188 } | 188 } |
189 | 189 |
190 TEST(ArrayBuffer_NonLivePromotion) { | 190 TEST(ArrayBuffer_NonLivePromotion) { |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 Local<v8::ArrayBuffer> ab2 = v8::ArrayBuffer::New(isolate, 100); | 311 Local<v8::ArrayBuffer> ab2 = v8::ArrayBuffer::New(isolate, 100); |
312 Handle<JSArrayBuffer> buf2 = v8::Utils::OpenHandle(*ab2); | 312 Handle<JSArrayBuffer> buf2 = v8::Utils::OpenHandle(*ab2); |
313 CHECK_NE(Page::FromAddress(buf1->address()), | 313 CHECK_NE(Page::FromAddress(buf1->address()), |
314 Page::FromAddress(buf2->address())); | 314 Page::FromAddress(buf2->address())); |
315 heap::GcAndSweep(heap, OLD_SPACE); | 315 heap::GcAndSweep(heap, OLD_SPACE); |
316 } | 316 } |
317 } | 317 } |
318 | 318 |
319 } // namespace internal | 319 } // namespace internal |
320 } // namespace v8 | 320 } // namespace v8 |
OLD | NEW |