src/share/vm/utilities/chunkedList.cpp

Tue, 24 Jul 2018 13:22:11 +0800

author
aoqi
date
Tue, 24 Jul 2018 13:22:11 +0800
changeset 9137
dc1769738300
parent 7333
b12a2a9b05ca
permissions
-rw-r--r--

#7048 added Loongson release info to hs_err crash files

stefank@7333 1 /*
stefank@7333 2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
stefank@7333 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
stefank@7333 4 *
stefank@7333 5 * This code is free software; you can redistribute it and/or modify it
stefank@7333 6 * under the terms of the GNU General Public License version 2 only, as
stefank@7333 7 * published by the Free Software Foundation.
stefank@7333 8 *
stefank@7333 9 * This code is distributed in the hope that it will be useful, but WITHOUT
stefank@7333 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
stefank@7333 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
stefank@7333 12 * version 2 for more details (a copy is included in the LICENSE file that
stefank@7333 13 * accompanied this code).
stefank@7333 14 *
stefank@7333 15 * You should have received a copy of the GNU General Public License version
stefank@7333 16 * 2 along with this work; if not, write to the Free Software Foundation,
stefank@7333 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
stefank@7333 18 *
stefank@7333 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
stefank@7333 20 * or visit www.oracle.com if you need additional information or have any
stefank@7333 21 * questions.
stefank@7333 22 *
stefank@7333 23 */
stefank@7333 24
stefank@7333 25 #include "precompiled.hpp"
stefank@7333 26 #include "utilities/chunkedList.hpp"
stefank@7333 27 #include "utilities/debug.hpp"
stefank@7333 28
stefank@7333 29 /////////////// Unit tests ///////////////
stefank@7333 30
stefank@7333 31 #ifndef PRODUCT
stefank@7333 32
stefank@7333 33 template <typename T>
stefank@7333 34 class TestChunkedList {
stefank@7333 35 typedef ChunkedList<T, mtOther> ChunkedListT;
stefank@7333 36
stefank@7333 37 public:
stefank@7333 38 static void testEmpty() {
stefank@7333 39 ChunkedListT buffer;
stefank@7333 40 assert(buffer.size() == 0, "assert");
stefank@7333 41 }
stefank@7333 42
stefank@7333 43 static void testFull() {
stefank@7333 44 ChunkedListT buffer;
stefank@7333 45 for (uintptr_t i = 0; i < ChunkedListT::BufferSize; i++) {
stefank@7333 46 buffer.push((T)i);
stefank@7333 47 }
stefank@7333 48 assert(buffer.size() == ChunkedListT::BufferSize, "assert");
stefank@7333 49 assert(buffer.is_full(), "assert");
stefank@7333 50 }
stefank@7333 51
stefank@7333 52 static void testSize() {
stefank@7333 53 ChunkedListT buffer;
stefank@7333 54 for (uintptr_t i = 0; i < ChunkedListT::BufferSize; i++) {
stefank@7333 55 assert(buffer.size() == i, "assert");
stefank@7333 56 buffer.push((T)i);
stefank@7333 57 assert(buffer.size() == i + 1, "assert");
stefank@7333 58 }
stefank@7333 59 }
stefank@7333 60
stefank@7333 61 static void testClear() {
stefank@7333 62 ChunkedListT buffer;
stefank@7333 63
stefank@7333 64 buffer.clear();
stefank@7333 65 assert(buffer.size() == 0, "assert");
stefank@7333 66
stefank@7333 67 for (uintptr_t i = 0; i < ChunkedListT::BufferSize / 2; i++) {
stefank@7333 68 buffer.push((T)i);
stefank@7333 69 }
stefank@7333 70 buffer.clear();
stefank@7333 71 assert(buffer.size() == 0, "assert");
stefank@7333 72
stefank@7333 73 for (uintptr_t i = 0; i < ChunkedListT::BufferSize; i++) {
stefank@7333 74 buffer.push((T)i);
stefank@7333 75 }
stefank@7333 76 buffer.clear();
stefank@7333 77 assert(buffer.size() == 0, "assert");
stefank@7333 78 }
stefank@7333 79
stefank@7333 80 static void testAt() {
stefank@7333 81 ChunkedListT buffer;
stefank@7333 82
stefank@7333 83 for (uintptr_t i = 0; i < ChunkedListT::BufferSize; i++) {
stefank@7333 84 buffer.push((T)i);
stefank@7333 85 assert(buffer.at(i) == (T)i, "assert");
stefank@7333 86 }
stefank@7333 87
stefank@7333 88 for (uintptr_t i = 0; i < ChunkedListT::BufferSize; i++) {
stefank@7333 89 assert(buffer.at(i) == (T)i, "assert");
stefank@7333 90 }
stefank@7333 91 }
stefank@7333 92
stefank@7333 93 static void test() {
stefank@7333 94 testEmpty();
stefank@7333 95 testFull();
stefank@7333 96 testSize();
stefank@7333 97 testClear();
stefank@7333 98 testAt();
stefank@7333 99 }
stefank@7333 100 };
stefank@7333 101
stefank@7333 102 class Metadata;
stefank@7333 103
stefank@7333 104 void TestChunkedList_test() {
stefank@7333 105 TestChunkedList<Metadata*>::test();
stefank@7333 106 TestChunkedList<size_t>::test();
stefank@7333 107 }
stefank@7333 108
stefank@7333 109 #endif

mercurial