1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim: set ts=8 sts=2 et sw=2 tw=80:
4 /* This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
10 #include "gc/GCLock.h"
11 #include "gc/GCRuntime.h"
12 #include "jsapi-tests/tests.h"
14 BEGIN_TEST(testGCChunkPool
) {
15 using namespace js::gc
;
21 for (int i
= 0; i
< N
; ++i
) {
22 void* ptr
= TenuredChunk::allocate(&cx
->runtime()->gc
);
24 TenuredChunk
* chunk
= TenuredChunk::emplace(ptr
, &cx
->runtime()->gc
, true);
28 MOZ_ASSERT(pool
.verify());
32 for (ChunkPool::Iter
iter(pool
); !iter
.done(); iter
.next(), ++i
) {
35 CHECK(i
== pool
.count());
36 MOZ_ASSERT(pool
.verify());
39 for (int i
= 0; i
< N
; ++i
) {
40 TenuredChunk
* chunkA
= pool
.pop();
41 TenuredChunk
* chunkB
= pool
.pop();
42 TenuredChunk
* chunkC
= pool
.pop();
47 MOZ_ASSERT(pool
.verify());
50 TenuredChunk
* chunk
= nullptr;
52 for (ChunkPool::Iter
iter(pool
); !iter
.done(); iter
.next(), --offset
) {
54 chunk
= pool
.remove(iter
.get());
59 MOZ_ASSERT(!pool
.contains(chunk
));
60 MOZ_ASSERT(pool
.verify());
64 js::AutoLockGC
lock(cx
->runtime());
65 for (ChunkPool::Iter
iter(pool
); !iter
.done();) {
66 TenuredChunk
* chunk
= iter
.get();
69 UnmapPages(chunk
, ChunkSize
);
74 END_TEST(testGCChunkPool
)