author | erikj |
Tue, 12 Sep 2017 19:03:39 +0200 | |
changeset 47216 | 71c04702a3d5 |
parent 42637 | hotspot/test/native/gc/g1/test_bufferingOopClosure.cpp@a9b83a4de25b |
permissions | -rw-r--r-- |
22772
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
1 |
/* |
42637
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
2 |
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. |
22772
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
4 |
* |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
8 |
* |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
13 |
* accompanied this code). |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
14 |
* |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
18 |
* |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
21 |
* questions. |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
22 |
*/ |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
23 |
|
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
24 |
#include "precompiled.hpp" |
30764 | 25 |
#include "gc/g1/bufferingOopClosure.hpp" |
22772
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
26 |
#include "memory/iterator.hpp" |
42637
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
27 |
#include "unittest.hpp" |
22772
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
28 |
|
42637
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
29 |
class BufferingOopClosureTest : public ::testing::Test { |
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
30 |
public: |
22772
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
31 |
// Helper class to fake a set of oop*s and narrowOop*s. |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
32 |
class FakeRoots { |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
33 |
public: |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
34 |
// Used for sanity checking of the values passed to the do_oops functions in the test. |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
35 |
static const uintptr_t NarrowOopMarker = uintptr_t(1) << (BitsPerWord -1); |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
36 |
|
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
37 |
int _num_narrow; |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
38 |
int _num_full; |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
39 |
void** _narrow; |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
40 |
void** _full; |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
41 |
|
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
42 |
FakeRoots(int num_narrow, int num_full) : |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
43 |
_num_narrow(num_narrow), |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
44 |
_num_full(num_full), |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
45 |
_narrow((void**)::malloc(sizeof(void*) * num_narrow)), |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
46 |
_full((void**)::malloc(sizeof(void*) * num_full)) { |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
47 |
|
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
48 |
for (int i = 0; i < num_narrow; i++) { |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
49 |
_narrow[i] = (void*)(NarrowOopMarker + (uintptr_t)i); |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
50 |
} |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
51 |
for (int i = 0; i < num_full; i++) { |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
52 |
_full[i] = (void*)(uintptr_t)i; |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
53 |
} |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
54 |
} |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
55 |
|
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
56 |
~FakeRoots() { |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
57 |
::free(_narrow); |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
58 |
::free(_full); |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
59 |
} |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
60 |
|
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
61 |
void oops_do_narrow_then_full(OopClosure* cl) { |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
62 |
for (int i = 0; i < _num_narrow; i++) { |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
63 |
cl->do_oop((narrowOop*)_narrow[i]); |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
64 |
} |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
65 |
for (int i = 0; i < _num_full; i++) { |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
66 |
cl->do_oop((oop*)_full[i]); |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
67 |
} |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
68 |
} |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
69 |
|
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
70 |
void oops_do_full_then_narrow(OopClosure* cl) { |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
71 |
for (int i = 0; i < _num_full; i++) { |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
72 |
cl->do_oop((oop*)_full[i]); |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
73 |
} |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
74 |
for (int i = 0; i < _num_narrow; i++) { |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
75 |
cl->do_oop((narrowOop*)_narrow[i]); |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
76 |
} |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
77 |
} |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
78 |
|
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
79 |
void oops_do_mixed(OopClosure* cl) { |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
80 |
int i; |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
81 |
for (i = 0; i < _num_full && i < _num_narrow; i++) { |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
82 |
cl->do_oop((oop*)_full[i]); |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
83 |
cl->do_oop((narrowOop*)_narrow[i]); |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
84 |
} |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
85 |
for (int j = i; j < _num_full; j++) { |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
86 |
cl->do_oop((oop*)_full[i]); |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
87 |
} |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
88 |
for (int j = i; j < _num_narrow; j++) { |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
89 |
cl->do_oop((narrowOop*)_narrow[i]); |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
90 |
} |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
91 |
} |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
92 |
|
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
93 |
static const int MaxOrder = 2; |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
94 |
|
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
95 |
void oops_do(OopClosure* cl, int do_oop_order) { |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
96 |
switch(do_oop_order) { |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
97 |
case 0: |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
98 |
oops_do_narrow_then_full(cl); |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
99 |
break; |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
100 |
case 1: |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
101 |
oops_do_full_then_narrow(cl); |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
102 |
break; |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
103 |
case 2: |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
104 |
oops_do_mixed(cl); |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
105 |
break; |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
106 |
default: |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
107 |
oops_do_narrow_then_full(cl); |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
108 |
break; |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
109 |
} |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
110 |
} |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
111 |
}; |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
112 |
|
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
113 |
class CountOopClosure : public OopClosure { |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
114 |
int _narrow_oop_count; |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
115 |
int _full_oop_count; |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
116 |
public: |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
117 |
CountOopClosure() : _narrow_oop_count(0), _full_oop_count(0) {} |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
118 |
void do_oop(narrowOop* p) { |
42637
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
119 |
EXPECT_NE(uintptr_t(0), (uintptr_t(p) & FakeRoots::NarrowOopMarker)) |
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
120 |
<< "The narrowOop was unexpectedly not marked with the NarrowOopMarker"; |
22772
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
121 |
_narrow_oop_count++; |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
122 |
} |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
123 |
|
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
124 |
void do_oop(oop* p){ |
42637
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
125 |
EXPECT_EQ(uintptr_t(0), (uintptr_t(p) & FakeRoots::NarrowOopMarker)) |
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
126 |
<< "The oop was unexpectedly marked with the NarrowOopMarker"; |
22772
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
127 |
_full_oop_count++; |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
128 |
} |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
129 |
|
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
130 |
int narrow_oop_count() { return _narrow_oop_count; } |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
131 |
int full_oop_count() { return _full_oop_count; } |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
132 |
int all_oop_count() { return _narrow_oop_count + _full_oop_count; } |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
133 |
}; |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
134 |
|
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
135 |
class DoNothingOopClosure : public OopClosure { |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
136 |
public: |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
137 |
void do_oop(narrowOop* p) {} |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
138 |
void do_oop(oop* p) {} |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
139 |
}; |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
140 |
|
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
141 |
static void testCount(int num_narrow, int num_full, int do_oop_order) { |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
142 |
FakeRoots fr(num_narrow, num_full); |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
143 |
|
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
144 |
CountOopClosure coc; |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
145 |
BufferingOopClosure boc(&coc); |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
146 |
|
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
147 |
fr.oops_do(&boc, do_oop_order); |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
148 |
|
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
149 |
boc.done(); |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
150 |
|
42637
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
151 |
EXPECT_EQ(num_narrow, coc.narrow_oop_count()) << "when running testCount(" |
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
152 |
<< num_narrow << ", " << num_full << ", " << do_oop_order << ")"; |
22772
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
153 |
|
42637
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
154 |
EXPECT_EQ(num_full, coc.full_oop_count()) << "when running testCount(" |
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
155 |
<< num_narrow << ", " << num_full << ", " << do_oop_order << ")"; |
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
156 |
|
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
157 |
EXPECT_EQ(num_narrow + num_full, coc.all_oop_count()) << "when running testCount(" |
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
158 |
<< num_narrow << ", " << num_full << ", " << do_oop_order << ")"; |
22772
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
159 |
} |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
160 |
|
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
161 |
static void testIsBufferEmptyOrFull(int num_narrow, int num_full, bool expect_empty, bool expect_full) { |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
162 |
FakeRoots fr(num_narrow, num_full); |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
163 |
|
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
164 |
DoNothingOopClosure cl; |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
165 |
BufferingOopClosure boc(&cl); |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
166 |
|
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
167 |
fr.oops_do(&boc, 0); |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
168 |
|
42637
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
169 |
EXPECT_EQ(expect_empty, boc.is_buffer_empty()) |
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
170 |
<< "when running testIsBufferEmptyOrFull(" |
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
171 |
<< num_narrow << ", " << num_full << ", " |
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
172 |
<< expect_empty << ", " << expect_full << ")"; |
22772
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
173 |
|
42637
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
174 |
EXPECT_EQ(expect_full, boc.is_buffer_full()) |
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
175 |
<< "when running testIsBufferEmptyOrFull(" |
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
176 |
<< num_narrow << ", " << num_full << ", " |
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
177 |
<< expect_empty << ", " << expect_full << ")"; |
22772
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
178 |
} |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
179 |
|
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
180 |
static void testEmptyAfterDone(int num_narrow, int num_full) { |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
181 |
FakeRoots fr(num_narrow, num_full); |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
182 |
|
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
183 |
DoNothingOopClosure cl; |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
184 |
BufferingOopClosure boc(&cl); |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
185 |
|
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
186 |
fr.oops_do(&boc, 0); |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
187 |
|
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
188 |
// Make sure all get processed. |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
189 |
boc.done(); |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
190 |
|
42637
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
191 |
EXPECT_TRUE(boc.is_buffer_empty()) << "Should be empty after call to done()." |
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
192 |
<< " testEmptyAfterDone(" << num_narrow << ", " << num_full << ")"; |
22772
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
193 |
} |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
194 |
|
42637
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
195 |
static int get_buffer_length() { |
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
196 |
return BufferingOopClosure::BufferLength; |
22772
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
197 |
} |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
198 |
}; |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
199 |
|
42637
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
200 |
TEST_VM_F(BufferingOopClosureTest, count_test) { |
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
201 |
int bl = BufferingOopClosureTest::get_buffer_length(); |
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
202 |
|
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
203 |
for (int order = 0; order < FakeRoots::MaxOrder; order++) { |
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
204 |
testCount(0, 0, order); |
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
205 |
testCount(10, 0, order); |
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
206 |
testCount(0, 10, order); |
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
207 |
testCount(10, 10, order); |
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
208 |
testCount(bl, 10, order); |
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
209 |
testCount(10, bl, order); |
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
210 |
testCount(bl, bl, order); |
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
211 |
testCount(bl + 1, 10, order); |
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
212 |
testCount(10, bl + 1, order); |
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
213 |
testCount(bl + 1, bl, order); |
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
214 |
testCount(bl, bl + 1, order); |
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
215 |
testCount(bl + 1, bl + 1, order); |
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
216 |
} |
22772
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
217 |
} |
2698c3a4ebb6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
218 |
|
42637
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
219 |
TEST_VM_F(BufferingOopClosureTest, buffer_empty_or_full) { |
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
220 |
int bl = BufferingOopClosureTest::get_buffer_length(); |
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
221 |
|
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
222 |
testIsBufferEmptyOrFull(0, 0, true, false); |
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
223 |
testIsBufferEmptyOrFull(1, 0, false, false); |
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
224 |
testIsBufferEmptyOrFull(0, 1, false, false); |
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
225 |
testIsBufferEmptyOrFull(1, 1, false, false); |
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
226 |
testIsBufferEmptyOrFull(10, 0, false, false); |
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
227 |
testIsBufferEmptyOrFull(0, 10, false, false); |
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
228 |
testIsBufferEmptyOrFull(10, 10, false, false); |
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
229 |
testIsBufferEmptyOrFull(0, bl, false, true); |
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
230 |
testIsBufferEmptyOrFull(bl, 0, false, true); |
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
231 |
testIsBufferEmptyOrFull(bl / 2, bl / 2, false, true); |
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
232 |
testIsBufferEmptyOrFull(bl - 1, 1, false, true); |
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
233 |
testIsBufferEmptyOrFull(1, bl - 1, false, true); |
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
234 |
// Processed |
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
235 |
testIsBufferEmptyOrFull(bl + 1, 0, false, false); |
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
236 |
testIsBufferEmptyOrFull(bl * 2, 0, false, true); |
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
237 |
} |
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
238 |
|
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
239 |
TEST_VM_F(BufferingOopClosureTest, empty_after_done) { |
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
240 |
int bl = BufferingOopClosureTest::get_buffer_length(); |
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
241 |
|
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
242 |
testEmptyAfterDone(0, 0); |
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
243 |
testEmptyAfterDone(1, 0); |
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
244 |
testEmptyAfterDone(0, 1); |
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
245 |
testEmptyAfterDone(1, 1); |
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
246 |
testEmptyAfterDone(10, 0); |
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
247 |
testEmptyAfterDone(0, 10); |
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
248 |
testEmptyAfterDone(10, 10); |
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
249 |
testEmptyAfterDone(0, bl); |
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
250 |
testEmptyAfterDone(bl, 0); |
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
251 |
testEmptyAfterDone(bl / 2, bl / 2); |
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
252 |
testEmptyAfterDone(bl - 1, 1); |
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
253 |
testEmptyAfterDone(1, bl - 1); |
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
254 |
// Processed |
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
255 |
testEmptyAfterDone(bl + 1, 0); |
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
256 |
testEmptyAfterDone(bl * 2, 0); |
a9b83a4de25b
8170490: Convert TestBufferingOopClosure_test to GTest
kzhaldyb
parents:
33105
diff
changeset
|
257 |
} |