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