Mercurial > hg > truffle
annotate src/share/vm/gc_implementation/g1/bufferingOopClosure.cpp @ 14355:937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
Reviewed-by: mgerdin, brutisso, tschatzl
author | stefank |
---|---|
date | Mon, 10 Feb 2014 12:51:51 +0100 |
parents | |
children |
rev | line source |
---|---|
14355
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
1 /* |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
4 * |
937cf56dede6
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 |
937cf56dede6
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 |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
8 * |
937cf56dede6
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 |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
937cf56dede6
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 |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
13 * accompanied this code). |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
14 * |
937cf56dede6
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 |
937cf56dede6
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, |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
18 * |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
937cf56dede6
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 |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
21 * questions. |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
22 * |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
23 */ |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
24 |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
25 #include "precompiled.hpp" |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
26 #include "gc_implementation/g1/bufferingOopClosure.hpp" |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
27 #include "memory/iterator.hpp" |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
28 #include "utilities/debug.hpp" |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
29 |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
30 /////////////// Unit tests /////////////// |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
31 |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
32 #ifndef PRODUCT |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
33 |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
34 class TestBufferingOopClosure { |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
35 |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
36 // Helper class to fake a set of oop*s and narrowOop*s. |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
37 class FakeRoots { |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
38 public: |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
39 // Used for sanity checking of the values passed to the do_oops functions in the test. |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
40 static const uintptr_t NarrowOopMarker = uintptr_t(1) << (BitsPerWord -1); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
41 |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
42 int _num_narrow; |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
43 int _num_full; |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
44 void** _narrow; |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
45 void** _full; |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
46 |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
47 FakeRoots(int num_narrow, int num_full) : |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
48 _num_narrow(num_narrow), |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
49 _num_full(num_full), |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
50 _narrow((void**)::malloc(sizeof(void*) * num_narrow)), |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
51 _full((void**)::malloc(sizeof(void*) * num_full)) { |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
52 |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
53 for (int i = 0; i < num_narrow; i++) { |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
54 _narrow[i] = (void*)(NarrowOopMarker + (uintptr_t)i); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
55 } |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
56 for (int i = 0; i < num_full; i++) { |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
57 _full[i] = (void*)(uintptr_t)i; |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
58 } |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
59 } |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
60 |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
61 ~FakeRoots() { |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
62 ::free(_narrow); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
63 ::free(_full); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
64 } |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
65 |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
66 void oops_do_narrow_then_full(OopClosure* cl) { |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
67 for (int i = 0; i < _num_narrow; i++) { |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
68 cl->do_oop((narrowOop*)_narrow[i]); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
69 } |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
70 for (int i = 0; i < _num_full; i++) { |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
71 cl->do_oop((oop*)_full[i]); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
72 } |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
73 } |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
74 |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
75 void oops_do_full_then_narrow(OopClosure* cl) { |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
76 for (int i = 0; i < _num_full; i++) { |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
77 cl->do_oop((oop*)_full[i]); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
78 } |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
79 for (int i = 0; i < _num_narrow; i++) { |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
80 cl->do_oop((narrowOop*)_narrow[i]); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
81 } |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
82 } |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
83 |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
84 void oops_do_mixed(OopClosure* cl) { |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
85 int i; |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
86 for (i = 0; i < _num_full && i < _num_narrow; i++) { |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
87 cl->do_oop((oop*)_full[i]); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
88 cl->do_oop((narrowOop*)_narrow[i]); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
89 } |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
90 for (int j = i; j < _num_full; j++) { |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
91 cl->do_oop((oop*)_full[i]); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
92 } |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
93 for (int j = i; j < _num_narrow; j++) { |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
94 cl->do_oop((narrowOop*)_narrow[i]); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
95 } |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
96 } |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
97 |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
98 static const int MaxOrder = 2; |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
99 |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
100 void oops_do(OopClosure* cl, int do_oop_order) { |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
101 switch(do_oop_order) { |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
102 case 0: |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
103 oops_do_narrow_then_full(cl); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
104 break; |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
105 case 1: |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
106 oops_do_full_then_narrow(cl); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
107 break; |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
108 case 2: |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
109 oops_do_mixed(cl); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
110 break; |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
111 default: |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
112 oops_do_narrow_then_full(cl); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
113 break; |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
114 } |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
115 } |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
116 }; |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
117 |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
118 class CountOopClosure : public OopClosure { |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
119 int _narrow_oop_count; |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
120 int _full_oop_count; |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
121 public: |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
122 CountOopClosure() : _narrow_oop_count(0), _full_oop_count(0) {} |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
123 void do_oop(narrowOop* p) { |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
124 assert((uintptr_t(p) & FakeRoots::NarrowOopMarker) != 0, |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
125 "The narrowOop was unexpectedly not marked with the NarrowOopMarker"); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
126 _narrow_oop_count++; |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
127 } |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
128 |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
129 void do_oop(oop* p){ |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
130 assert((uintptr_t(p) & FakeRoots::NarrowOopMarker) == 0, |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
131 "The oop was unexpectedly marked with the NarrowOopMarker"); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
132 _full_oop_count++; |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
133 } |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
134 |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
135 int narrow_oop_count() { return _narrow_oop_count; } |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
136 int full_oop_count() { return _full_oop_count; } |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
137 int all_oop_count() { return _narrow_oop_count + _full_oop_count; } |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
138 }; |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
139 |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
140 class DoNothingOopClosure : public OopClosure { |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
141 public: |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
142 void do_oop(narrowOop* p) {} |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
143 void do_oop(oop* p) {} |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
144 }; |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
145 |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
146 static void testCount(int num_narrow, int num_full, int do_oop_order) { |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
147 FakeRoots fr(num_narrow, num_full); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
148 |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
149 CountOopClosure coc; |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
150 BufferingOopClosure boc(&coc); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
151 |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
152 fr.oops_do(&boc, do_oop_order); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
153 |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
154 boc.done(); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
155 |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
156 #define assert_testCount(got, expected) \ |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
157 assert((got) == (expected), \ |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
158 err_msg("Expected: %d, got: %d, when running testCount(%d, %d, %d)", \ |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
159 (got), (expected), num_narrow, num_full, do_oop_order)) |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
160 |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
161 assert_testCount(num_narrow, coc.narrow_oop_count()); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
162 assert_testCount(num_full, coc.full_oop_count()); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
163 assert_testCount(num_narrow + num_full, coc.all_oop_count()); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
164 } |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
165 |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
166 static void testCount() { |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
167 int buffer_length = BufferingOopClosure::BufferLength; |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
168 |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
169 for (int order = 0; order < FakeRoots::MaxOrder; order++) { |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
170 testCount(0, 0, order); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
171 testCount(10, 0, order); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
172 testCount(0, 10, order); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
173 testCount(10, 10, order); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
174 testCount(buffer_length, 10, order); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
175 testCount(10, buffer_length, order); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
176 testCount(buffer_length, buffer_length, order); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
177 testCount(buffer_length + 1, 10, order); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
178 testCount(10, buffer_length + 1, order); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
179 testCount(buffer_length + 1, buffer_length, order); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
180 testCount(buffer_length, buffer_length + 1, order); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
181 testCount(buffer_length + 1, buffer_length + 1, order); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
182 } |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
183 } |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
184 |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
185 static void testIsBufferEmptyOrFull(int num_narrow, int num_full, bool expect_empty, bool expect_full) { |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
186 FakeRoots fr(num_narrow, num_full); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
187 |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
188 DoNothingOopClosure cl; |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
189 BufferingOopClosure boc(&cl); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
190 |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
191 fr.oops_do(&boc, 0); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
192 |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
193 #define assert_testIsBufferEmptyOrFull(got, expected) \ |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
194 assert((got) == (expected), \ |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
195 err_msg("Expected: %d, got: %d. testIsBufferEmptyOrFull(%d, %d, %s, %s)", \ |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
196 (got), (expected), num_narrow, num_full, \ |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
197 BOOL_TO_STR(expect_empty), BOOL_TO_STR(expect_full))) |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
198 |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
199 assert_testIsBufferEmptyOrFull(expect_empty, boc.is_buffer_empty()); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
200 assert_testIsBufferEmptyOrFull(expect_full, boc.is_buffer_full()); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
201 } |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
202 |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
203 static void testIsBufferEmptyOrFull() { |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
204 int bl = BufferingOopClosure::BufferLength; |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
205 |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
206 testIsBufferEmptyOrFull(0, 0, true, false); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
207 testIsBufferEmptyOrFull(1, 0, false, false); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
208 testIsBufferEmptyOrFull(0, 1, false, false); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
209 testIsBufferEmptyOrFull(1, 1, false, false); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
210 testIsBufferEmptyOrFull(10, 0, false, false); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
211 testIsBufferEmptyOrFull(0, 10, false, false); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
212 testIsBufferEmptyOrFull(10, 10, false, false); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
213 testIsBufferEmptyOrFull(0, bl, false, true); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
214 testIsBufferEmptyOrFull(bl, 0, false, true); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
215 testIsBufferEmptyOrFull(bl/2, bl/2, false, true); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
216 testIsBufferEmptyOrFull(bl-1, 1, false, true); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
217 testIsBufferEmptyOrFull(1, bl-1, false, true); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
218 // Processed |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
219 testIsBufferEmptyOrFull(bl+1, 0, false, false); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
220 testIsBufferEmptyOrFull(bl*2, 0, false, true); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
221 } |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
222 |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
223 static void testEmptyAfterDone(int num_narrow, int num_full) { |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
224 FakeRoots fr(num_narrow, num_full); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
225 |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
226 DoNothingOopClosure cl; |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
227 BufferingOopClosure boc(&cl); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
228 |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
229 fr.oops_do(&boc, 0); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
230 |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
231 // Make sure all get processed. |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
232 boc.done(); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
233 |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
234 assert(boc.is_buffer_empty(), |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
235 err_msg("Should be empty after call to done(). testEmptyAfterDone(%d, %d)", |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
236 num_narrow, num_full)); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
237 } |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
238 |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
239 static void testEmptyAfterDone() { |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
240 int bl = BufferingOopClosure::BufferLength; |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
241 |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
242 testEmptyAfterDone(0, 0); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
243 testEmptyAfterDone(1, 0); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
244 testEmptyAfterDone(0, 1); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
245 testEmptyAfterDone(1, 1); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
246 testEmptyAfterDone(10, 0); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
247 testEmptyAfterDone(0, 10); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
248 testEmptyAfterDone(10, 10); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
249 testEmptyAfterDone(0, bl); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
250 testEmptyAfterDone(bl, 0); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
251 testEmptyAfterDone(bl/2, bl/2); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
252 testEmptyAfterDone(bl-1, 1); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
253 testEmptyAfterDone(1, bl-1); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
254 // Processed |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
255 testEmptyAfterDone(bl+1, 0); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
256 testEmptyAfterDone(bl*2, 0); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
257 } |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
258 |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
259 public: |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
260 static void test() { |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
261 testCount(); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
262 testIsBufferEmptyOrFull(); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
263 testEmptyAfterDone(); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
264 } |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
265 }; |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
266 |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
267 void TestBufferingOopClosure_test() { |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
268 TestBufferingOopClosure::test(); |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
269 } |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
270 |
937cf56dede6
8033764: Remove the usage of StarTask from BufferingOopClosure
stefank
parents:
diff
changeset
|
271 #endif |