diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /js/src/jsapi-tests/testGCChunkPool.cpp | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'js/src/jsapi-tests/testGCChunkPool.cpp')
-rw-r--r-- | js/src/jsapi-tests/testGCChunkPool.cpp | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/js/src/jsapi-tests/testGCChunkPool.cpp b/js/src/jsapi-tests/testGCChunkPool.cpp new file mode 100644 index 000000000..68faa3150 --- /dev/null +++ b/js/src/jsapi-tests/testGCChunkPool.cpp @@ -0,0 +1,71 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- +* vim: set ts=8 sts=4 et sw=4 tw=99: +*/ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "mozilla/Move.h" + +#include "gc/GCRuntime.h" +#include "gc/Heap.h" + +#include "jsapi-tests/tests.h" + +BEGIN_TEST(testGCChunkPool) +{ + const int N = 10; + js::gc::ChunkPool pool; + + // Create. + for (int i = 0; i < N; ++i) { + js::gc::Chunk* chunk = js::gc::Chunk::allocate(cx); + CHECK(chunk); + pool.push(chunk); + } + MOZ_ASSERT(pool.verify()); + + // Iterate. + uint32_t i = 0; + for (js::gc::ChunkPool::Iter iter(pool); !iter.done(); iter.next(), ++i) + CHECK(iter.get()); + CHECK(i == pool.count()); + MOZ_ASSERT(pool.verify()); + + // Push/Pop. + for (int i = 0; i < N; ++i) { + js::gc::Chunk* chunkA = pool.pop(); + js::gc::Chunk* chunkB = pool.pop(); + js::gc::Chunk* chunkC = pool.pop(); + pool.push(chunkA); + pool.push(chunkB); + pool.push(chunkC); + } + MOZ_ASSERT(pool.verify()); + + // Remove. + js::gc::Chunk* chunk = nullptr; + int offset = N / 2; + for (js::gc::ChunkPool::Iter iter(pool); !iter.done(); iter.next(), --offset) { + if (offset == 0) { + chunk = pool.remove(iter.get()); + break; + } + } + CHECK(chunk); + MOZ_ASSERT(!pool.contains(chunk)); + MOZ_ASSERT(pool.verify()); + pool.push(chunk); + + // Destruct. + js::AutoLockGC lock(cx); + for (js::gc::ChunkPool::Iter iter(pool); !iter.done();) { + js::gc::Chunk* chunk = iter.get(); + iter.next(); + pool.remove(chunk); + js::gc::UnmapPages(chunk, js::gc::ChunkSize); + } + + return true; +} +END_TEST(testGCChunkPool) |