author | herrick |
Mon, 17 Jun 2019 15:18:52 -0400 | |
branch | JDK-8200758-branch |
changeset 57412 | 02034583f4dc |
parent 50193 | 49c3e91c424f |
permissions | -rw-r--r-- |
42615
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
diff
changeset
|
1 |
/* |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
diff
changeset
|
2 |
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
diff
changeset
|
4 |
* |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
diff
changeset
|
8 |
* |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
diff
changeset
|
13 |
* accompanied this code). |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
diff
changeset
|
14 |
* |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
diff
changeset
|
18 |
* |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
diff
changeset
|
21 |
* questions. |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
diff
changeset
|
22 |
*/ |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
diff
changeset
|
23 |
|
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
diff
changeset
|
24 |
#include "precompiled.hpp" |
50193 | 25 |
#include "memory/metaspace/spaceManager.hpp" |
26 |
||
27 |
using metaspace::SpaceManager; |
|
42615
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
diff
changeset
|
28 |
|
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
diff
changeset
|
29 |
// The test function is only available in debug builds |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
diff
changeset
|
30 |
#ifdef ASSERT |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
diff
changeset
|
31 |
|
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
diff
changeset
|
32 |
#include "unittest.hpp" |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
diff
changeset
|
33 |
|
50193 | 34 |
|
35 |
static void test_adjust_initial_chunk_size(bool is_class) { |
|
36 |
const size_t smallest = SpaceManager::smallest_chunk_size(is_class); |
|
37 |
const size_t normal = SpaceManager::small_chunk_size(is_class); |
|
38 |
const size_t medium = SpaceManager::medium_chunk_size(is_class); |
|
39 |
||
40 |
#define do_test(value, expected, is_class_value) \ |
|
41 |
do { \ |
|
42 |
size_t v = value; \ |
|
43 |
size_t e = expected; \ |
|
44 |
assert(SpaceManager::adjust_initial_chunk_size(v, (is_class_value)) == e, \ |
|
45 |
"Expected: " SIZE_FORMAT " got: " SIZE_FORMAT, e, v); \ |
|
46 |
} while (0) |
|
47 |
||
48 |
// Smallest (specialized) |
|
49 |
do_test(1, smallest, is_class); |
|
50 |
do_test(smallest - 1, smallest, is_class); |
|
51 |
do_test(smallest, smallest, is_class); |
|
52 |
||
53 |
// Small |
|
54 |
do_test(smallest + 1, normal, is_class); |
|
55 |
do_test(normal - 1, normal, is_class); |
|
56 |
do_test(normal, normal, is_class); |
|
57 |
||
58 |
// Medium |
|
59 |
do_test(normal + 1, medium, is_class); |
|
60 |
do_test(medium - 1, medium, is_class); |
|
61 |
do_test(medium, medium, is_class); |
|
62 |
||
63 |
// Humongous |
|
64 |
do_test(medium + 1, medium + 1, is_class); |
|
65 |
||
66 |
#undef test_adjust_initial_chunk_size |
|
67 |
} |
|
42615
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
diff
changeset
|
68 |
|
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
diff
changeset
|
69 |
TEST(SpaceManager, adjust_initial_chunk_size) { |
50193 | 70 |
test_adjust_initial_chunk_size(true); |
71 |
test_adjust_initial_chunk_size(false); |
|
42615
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
diff
changeset
|
72 |
} |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
diff
changeset
|
73 |
|
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
diff
changeset
|
74 |
#endif // ASSERT |