author | stefank |
Mon, 11 Apr 2016 08:51:53 +0200 | |
changeset 37456 | bf26e0f4235f |
parent 33754 | 49614940dafc |
child 39977 | 2965795a0723 |
permissions | -rw-r--r-- |
33754
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
1 |
/* |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
2 |
* Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved. |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
4 |
* |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
8 |
* |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
13 |
* accompanied this code). |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
14 |
* |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
18 |
* |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
21 |
* questions. |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
22 |
* |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
23 |
*/ |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
24 |
|
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
25 |
#include "precompiled.hpp" |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
26 |
#include "memory/allocation.hpp" |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
27 |
#include "memory/resourceArea.hpp" |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
28 |
#include "utilities/debug.hpp" |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
29 |
#include "utilities/resourceHash.hpp" |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
30 |
|
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
31 |
#ifndef PRODUCT |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
32 |
|
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
33 |
/////////////// Unit tests /////////////// |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
34 |
|
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
35 |
class TestResourceHashtable : public AllStatic { |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
36 |
typedef void* K; |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
37 |
typedef int V; |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
38 |
|
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
39 |
static unsigned identity_hash(const K& k) { |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
40 |
return (unsigned)(uintptr_t)k; |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
41 |
} |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
42 |
|
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
43 |
static unsigned bad_hash(const K& k) { |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
44 |
return 1; |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
45 |
} |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
46 |
|
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
47 |
class EqualityTestIter { |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
48 |
public: |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
49 |
bool do_entry(K const& k, V const& v) { |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
50 |
assert((uintptr_t)k == (uintptr_t)v, ""); |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
51 |
return true; // continue iteration |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
52 |
} |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
53 |
}; |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
54 |
|
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
55 |
template< |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
56 |
unsigned (*HASH) (K const&) = primitive_hash<K>, |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
57 |
bool (*EQUALS)(K const&, K const&) = primitive_equals<K>, |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
58 |
unsigned SIZE = 256, |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
59 |
ResourceObj::allocation_type ALLOC_TYPE = ResourceObj::RESOURCE_AREA, |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
60 |
MEMFLAGS MEM_TYPE = mtInternal |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
61 |
> |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
62 |
class Runner : public AllStatic { |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
63 |
static void* as_K(uintptr_t val) { return (void*)val; } |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
64 |
|
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
65 |
public: |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
66 |
static void test_small() { |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
67 |
EqualityTestIter et; |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
68 |
ResourceHashtable<K, V, HASH, EQUALS, SIZE, ALLOC_TYPE, MEM_TYPE> rh; |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
69 |
|
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
70 |
assert(!rh.contains(as_K(0x1)), ""); |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
71 |
|
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
72 |
assert(rh.put(as_K(0x1), 0x1), ""); |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
73 |
assert(rh.contains(as_K(0x1)), ""); |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
74 |
|
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
75 |
assert(!rh.put(as_K(0x1), 0x1), ""); |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
76 |
|
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
77 |
assert(rh.put(as_K(0x2), 0x2), ""); |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
78 |
assert(rh.put(as_K(0x3), 0x3), ""); |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
79 |
assert(rh.put(as_K(0x4), 0x4), ""); |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
80 |
assert(rh.put(as_K(0x5), 0x5), ""); |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
81 |
|
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
82 |
assert(!rh.remove(as_K(0x0)), ""); |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
83 |
rh.iterate(&et); |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
84 |
|
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
85 |
assert(rh.remove(as_K(0x1)), ""); |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
86 |
rh.iterate(&et); |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
87 |
|
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
88 |
} |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
89 |
|
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
90 |
// We use keys with the low bits cleared since the default hash will do some shifting |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
91 |
static void test_small_shifted() { |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
92 |
EqualityTestIter et; |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
93 |
ResourceHashtable<K, V, HASH, EQUALS, SIZE, ALLOC_TYPE, MEM_TYPE> rh; |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
94 |
|
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
95 |
assert(!rh.contains(as_K(0x10)), ""); |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
96 |
|
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
97 |
assert(rh.put(as_K(0x10), 0x10), ""); |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
98 |
assert(rh.contains(as_K(0x10)), ""); |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
99 |
|
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
100 |
assert(!rh.put(as_K(0x10), 0x10), ""); |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
101 |
|
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
102 |
assert(rh.put(as_K(0x20), 0x20), ""); |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
103 |
assert(rh.put(as_K(0x30), 0x30), ""); |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
104 |
assert(rh.put(as_K(0x40), 0x40), ""); |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
105 |
assert(rh.put(as_K(0x50), 0x50), ""); |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
106 |
|
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
107 |
assert(!rh.remove(as_K(0x00)), ""); |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
108 |
|
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
109 |
assert(rh.remove(as_K(0x10)), ""); |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
110 |
|
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
111 |
rh.iterate(&et); |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
112 |
} |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
113 |
|
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
114 |
static void test(unsigned num_elements = SIZE) { |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
115 |
EqualityTestIter et; |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
116 |
ResourceHashtable<K, V, HASH, EQUALS, SIZE, ALLOC_TYPE, MEM_TYPE> rh; |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
117 |
|
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
118 |
for (uintptr_t i = 0; i < num_elements; ++i) { |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
119 |
assert(rh.put(as_K(i), i), ""); |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
120 |
} |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
121 |
|
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
122 |
rh.iterate(&et); |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
123 |
|
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
124 |
for (uintptr_t i = num_elements; i > 0; --i) { |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
125 |
uintptr_t index = i - 1; |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
126 |
assert(rh.remove(as_K(index)), ""); |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
127 |
} |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
128 |
rh.iterate(&et); |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
129 |
for (uintptr_t i = num_elements; i > 0; --i) { |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
130 |
uintptr_t index = i - 1; |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
131 |
assert(!rh.remove(as_K(index)), ""); |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
132 |
} |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
133 |
rh.iterate(&et); |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
134 |
} |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
135 |
}; |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
136 |
|
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
137 |
public: |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
138 |
static void run_tests() { |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
139 |
{ |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
140 |
ResourceMark rm; |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
141 |
Runner<>::test_small(); |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
142 |
Runner<>::test_small_shifted(); |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
143 |
Runner<>::test(); |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
144 |
} |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
145 |
|
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
146 |
{ |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
147 |
ResourceMark rm; |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
148 |
Runner<identity_hash>::test_small(); |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
149 |
Runner<identity_hash>::test_small_shifted(); |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
150 |
Runner<identity_hash>::test(); |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
151 |
} |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
152 |
|
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
153 |
{ |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
154 |
ResourceMark rm; |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
155 |
Runner<bad_hash>::test_small(); |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
156 |
Runner<bad_hash>::test_small_shifted(); |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
157 |
Runner<bad_hash>::test(); |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
158 |
} |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
159 |
|
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
160 |
|
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
161 |
assert(Thread::current()->resource_area()->nesting() == 0, "this code depends on not having an active ResourceMark"); |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
162 |
// The following test calls will cause an assert if resource allocations occur since we don't have an active mark |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
163 |
Runner<primitive_hash<K>, primitive_equals<K>, 512, ResourceObj::C_HEAP>::test_small(); |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
164 |
Runner<primitive_hash<K>, primitive_equals<K>, 512, ResourceObj::C_HEAP>::test_small_shifted(); |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
165 |
Runner<primitive_hash<K>, primitive_equals<K>, 512, ResourceObj::C_HEAP>::test(); |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
166 |
|
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
167 |
Runner<bad_hash, primitive_equals<K>, 512, ResourceObj::C_HEAP>::test_small(); |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
168 |
Runner<bad_hash, primitive_equals<K>, 512, ResourceObj::C_HEAP>::test_small_shifted(); |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
169 |
Runner<bad_hash, primitive_equals<K>, 512, ResourceObj::C_HEAP>::test(); |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
170 |
|
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
171 |
Runner<identity_hash, primitive_equals<K>, 1, ResourceObj::C_HEAP>::test_small(); |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
172 |
Runner<identity_hash, primitive_equals<K>, 1, ResourceObj::C_HEAP>::test_small_shifted(); |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
173 |
Runner<identity_hash, primitive_equals<K>, 1, ResourceObj::C_HEAP>::test(512); |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
174 |
} |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
175 |
}; |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
176 |
|
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
177 |
void TestResourcehash_test() { |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
178 |
TestResourceHashtable::run_tests(); |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
179 |
} |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
180 |
|
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
181 |
#endif // not PRODUCT |
49614940dafc
8055283: Expand ResourceHashtable with C_HEAP allocation, removal and some unit tests
mgerdin
parents:
diff
changeset
|
182 |