jdk

Форк
0
/z
/
test_zAddress.cpp 
437 строк · 21.3 Кб
1
/*
2
 * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
 *
5
 * This code is free software; you can redistribute it and/or modify it
6
 * under the terms of the GNU General Public License version 2 only, as
7
 * published by the Free Software Foundation.
8
 *
9
 * This code is distributed in the hope that it will be useful, but WITHOUT
10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12
 * version 2 for more details (a copy is included in the LICENSE file that
13
 * accompanied this code).
14
 *
15
 * You should have received a copy of the GNU General Public License version
16
 * 2 along with this work; if not, write to the Free Software Foundation,
17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
 *
19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
 * or visit www.oracle.com if you need additional information or have any
21
 * questions.
22
 */
23

24
#include "precompiled.hpp"
25
#include "gc/z/zAddress.inline.hpp"
26
#include "gc/z/zGlobals.hpp"
27
#include "unittest.hpp"
28

29
class ZAddressTest : public ::testing::Test {
30
protected:
31
  static zpointer color(uintptr_t value, uintptr_t color) {
32
    return ZAddress::color(zaddress(value | ZAddressHeapBase), color);
33
  }
34

35
  static const uintptr_t valid_value = (1 << 3 /* LogMinObjectAlignment */);
36
  static const uintptr_t null_value = 0;
37

38
  enum ZColor {
39
    Uncolored,
40
    RemappedYoung0,
41
    RemappedYoung1,
42
    RemappedOld0,
43
    RemappedOld1,
44
    MarkedYoung0,
45
    MarkedYoung1,
46
    MarkedOld0,
47
    MarkedOld1,
48
    Finalizable0,
49
    Finalizable1,
50
    Remembered0,
51
    Remembered1,
52
    Remembered11
53
  };
54

55
  static uintptr_t make_color(ZColor remembered, ZColor remapped_young, ZColor remapped_old, ZColor marked_young, ZColor marked_old) {
56
    uintptr_t color = 0;
57
    switch (remapped_young) {
58
    case RemappedYoung0: {
59
      switch (remapped_old) {
60
      case RemappedOld0:
61
        color |= ZPointer::remap_bits(ZPointerRemapped00);
62
        break;
63
      case RemappedOld1:
64
        color |= ZPointer::remap_bits(ZPointerRemapped10);
65
        break;
66
      default:
67
        EXPECT_TRUE(false);
68
      }
69
      break;
70
    }
71
    case RemappedYoung1: {
72
      switch (remapped_old) {
73
      case RemappedOld0:
74
        color |= ZPointer::remap_bits(ZPointerRemapped01);
75
        break;
76
      case RemappedOld1:
77
        color |= ZPointer::remap_bits(ZPointerRemapped11);
78
        break;
79
      default:
80
        EXPECT_TRUE(false);
81
      }
82
      break;
83
    }
84
    default:
85
      EXPECT_TRUE(false);
86
    }
87

88
    switch (marked_young) {
89
    case MarkedYoung0:
90
      color |= ZPointerMarkedYoung0;
91
      break;
92
    case MarkedYoung1:
93
      color |= ZPointerMarkedYoung1;
94
      break;
95
    default:
96
      EXPECT_TRUE(false);
97
    }
98

99
    switch (marked_old) {
100
    case MarkedOld0:
101
      color |= ZPointerMarkedOld0;
102
      break;
103
    case MarkedOld1:
104
      color |= ZPointerMarkedOld1;
105
      break;
106
    case Finalizable0:
107
      color |= ZPointerFinalizable0;
108
      break;
109
    case Finalizable1:
110
      color |= ZPointerFinalizable1;
111
      break;
112
    default:
113
      EXPECT_TRUE(false);
114
    }
115

116
    switch (remembered) {
117
    case Remembered0:
118
      color |= ZPointerRemembered0;
119
      break;
120
    case Remembered1:
121
      color |= ZPointerRemembered1;
122
      break;
123
    case Remembered11:
124
      color |= ZPointerRemembered0 | ZPointerRemembered1;
125
      break;
126
    default:
127
      EXPECT_TRUE(false);
128
    }
129

130
    return color;
131
  }
132

133
  static zpointer color(uintptr_t addr,
134
                        ZColor remembered,
135
                        ZColor remapped_young,
136
                        ZColor remapped_old,
137
                        ZColor marked_young,
138
                        ZColor marked_old) {
139
    if (remembered == Uncolored &&
140
        remapped_young == Uncolored &&
141
        remapped_old == Uncolored &&
142
        marked_young == Uncolored &&
143
        marked_old == Uncolored) {
144
      return zpointer(addr);
145
    } else {
146
      return color(addr, make_color(remembered, remapped_young, remapped_old, marked_young, marked_old));
147
    }
148
  }
149

150
  static bool is_remapped_young_odd(uintptr_t bits) {
151
    return ZPointer::remap_bits(bits) & (ZPointerRemapped01 | ZPointerRemapped11);
152
  }
153

154
  static bool is_remapped_old_odd(uintptr_t bits) {
155
    return ZPointer::remap_bits(bits) & (ZPointerRemapped10 | ZPointerRemapped11);
156
  }
157

158
  static bool is_marked_young_odd(uintptr_t bits) {
159
    return bits & ZPointerMarkedYoung1;
160
  }
161

162
  static bool is_marked_old_odd(uintptr_t bits) {
163
    return bits & (ZPointerMarkedOld1 | ZPointerFinalizable1);
164
  }
165

166
  static bool is_remembered(uintptr_t bits) {
167
    return bits & (ZPointerRemembered0 | ZPointerRemembered1);
168
  }
169

170
  static bool is_remembered_odd(uintptr_t bits) {
171
    return bits & (ZPointerRemembered1);
172
  }
173

174
  static bool is_remembered_even(uintptr_t bits) {
175
    return bits & (ZPointerRemembered0);
176
  }
177

178
  static void test_is_checks_on(uintptr_t value,
179
                                ZColor remembered,
180
                                ZColor remapped_young,
181
                                ZColor remapped_old,
182
                                ZColor marked_young,
183
                                ZColor marked_old) {
184
    const zpointer ptr = color(value, remembered, remapped_young, remapped_old, marked_young, marked_old);
185
    uintptr_t ptr_raw = untype(ptr);
186

187
    EXPECT_TRUE(ZPointerLoadGoodMask != 0);
188
    EXPECT_TRUE(ZPointerStoreGoodMask != 0);
189

190
    bool ptr_raw_null = ptr_raw == 0;
191
    bool global_remapped_old_odd = is_remapped_old_odd(ZPointerLoadGoodMask);
192
    bool global_remapped_young_odd = is_remapped_young_odd(ZPointerLoadGoodMask);
193
    bool global_marked_old_odd = is_marked_old_odd(ZPointerStoreGoodMask);
194
    bool global_marked_young_odd = is_marked_young_odd(ZPointerStoreGoodMask);
195
    bool global_remembered_odd = is_remembered_odd(ZPointerStoreGoodMask);
196
    bool global_remembered_even = is_remembered_even(ZPointerStoreGoodMask);
197

198
    if (ptr_raw_null) {
199
      EXPECT_FALSE(ZPointer::is_marked_any_old(ptr));
200
      EXPECT_FALSE(ZPointer::is_load_good(ptr));
201
      EXPECT_TRUE(ZPointer::is_load_good_or_null(ptr));
202
      EXPECT_FALSE(ZPointer::is_load_bad(ptr));
203
      EXPECT_FALSE(ZPointer::is_mark_good(ptr));
204
      EXPECT_TRUE(ZPointer::is_mark_good_or_null(ptr));
205
      EXPECT_FALSE(ZPointer::is_mark_bad(ptr));
206
      EXPECT_FALSE(ZPointer::is_store_good(ptr));
207
      EXPECT_TRUE(ZPointer::is_store_good_or_null(ptr));
208
      EXPECT_FALSE(ZPointer::is_store_bad(ptr));
209
    } else {
210
      bool ptr_remapped_old_odd = is_remapped_old_odd(ptr_raw);
211
      bool ptr_remapped_young_odd = is_remapped_young_odd(ptr_raw);
212
      bool ptr_marked_old_odd = is_marked_old_odd(ptr_raw);
213
      bool ptr_marked_young_odd = is_marked_young_odd(ptr_raw);
214
      bool ptr_final = ptr_raw & (ZPointerFinalizable0 | ZPointerFinalizable1);
215
      bool ptr_remembered = is_power_of_2(ptr_raw & (ZPointerRemembered0 | ZPointerRemembered1));
216
      bool ptr_remembered_odd = is_remembered_odd(ptr_raw);
217
      bool ptr_remembered_even = is_remembered_even(ptr_raw);
218
      bool ptr_colored_null = !ptr_raw_null && (ptr_raw & ~ZPointerAllMetadataMask) == 0;
219

220
      bool same_old_marking = global_marked_old_odd == ptr_marked_old_odd;
221
      bool same_young_marking = global_marked_young_odd == ptr_marked_young_odd;
222
      bool same_old_remapping = global_remapped_old_odd == ptr_remapped_old_odd;
223
      bool same_young_remapping = global_remapped_young_odd == ptr_remapped_young_odd;
224
      bool same_remembered = ptr_remembered_even == global_remembered_even && ptr_remembered_odd == global_remembered_odd;
225

226
      EXPECT_EQ(ZPointer::is_marked_finalizable(ptr), same_old_marking && ptr_final);
227
      EXPECT_EQ(ZPointer::is_marked_any_old(ptr), same_old_marking);
228
      EXPECT_EQ(ZPointer::is_remapped(ptr), same_old_remapping && same_young_remapping);
229
      EXPECT_EQ(ZPointer::is_load_good(ptr), same_old_remapping && same_young_remapping);
230
      EXPECT_EQ(ZPointer::is_load_good_or_null(ptr), same_old_remapping && same_young_remapping);
231
      EXPECT_EQ(ZPointer::is_load_bad(ptr), !same_old_remapping || !same_young_remapping);
232
      EXPECT_EQ(ZPointer::is_mark_good(ptr), same_young_remapping && same_old_remapping && same_young_marking && same_old_marking);
233
      EXPECT_EQ(ZPointer::is_mark_good_or_null(ptr), same_young_remapping && same_old_remapping && same_young_marking && same_old_marking);
234
      EXPECT_EQ(ZPointer::is_mark_bad(ptr), !same_young_remapping || !same_old_remapping || !same_young_marking || !same_old_marking);
235
      EXPECT_EQ(ZPointer::is_store_good(ptr), same_young_remapping && same_old_remapping && same_young_marking && same_old_marking && ptr_remembered && same_remembered);
236
      EXPECT_EQ(ZPointer::is_store_good_or_null(ptr), same_young_remapping && same_old_remapping && same_young_marking && same_old_marking && ptr_remembered && same_remembered);
237
      EXPECT_EQ(ZPointer::is_store_bad(ptr), !same_young_remapping || !same_old_remapping || !same_young_marking || !same_old_marking || !ptr_remembered || !same_remembered);
238
    }
239
  }
240

241
  static void test_is_checks_on_all() {
242
    test_is_checks_on(valid_value, Remembered0, RemappedYoung0, RemappedOld0, MarkedYoung0, MarkedOld0);
243
    test_is_checks_on(null_value, Remembered0, RemappedYoung0, RemappedOld0, MarkedYoung0, MarkedOld0);
244
    test_is_checks_on(valid_value, Remembered0, RemappedYoung0, RemappedOld0, MarkedYoung0, MarkedOld1);
245
    test_is_checks_on(null_value, Remembered0, RemappedYoung0, RemappedOld0, MarkedYoung0, MarkedOld1);
246
    test_is_checks_on(valid_value, Remembered0, RemappedYoung0, RemappedOld0, MarkedYoung1, MarkedOld0);
247
    test_is_checks_on(null_value, Remembered0, RemappedYoung0, RemappedOld0, MarkedYoung1, MarkedOld0);
248
    test_is_checks_on(valid_value, Remembered0, RemappedYoung0, RemappedOld0, MarkedYoung1, MarkedOld1);
249
    test_is_checks_on(null_value, Remembered0, RemappedYoung0, RemappedOld0, MarkedYoung1, MarkedOld1);
250

251
    test_is_checks_on(valid_value, Remembered0, RemappedYoung0, RemappedOld1, MarkedYoung0, MarkedOld0);
252
    test_is_checks_on(null_value, Remembered0, RemappedYoung0, RemappedOld1, MarkedYoung0, MarkedOld0);
253
    test_is_checks_on(valid_value, Remembered0, RemappedYoung0, RemappedOld1, MarkedYoung0, MarkedOld1);
254
    test_is_checks_on(null_value, Remembered0, RemappedYoung0, RemappedOld1, MarkedYoung0, MarkedOld1);
255
    test_is_checks_on(valid_value, Remembered0, RemappedYoung0, RemappedOld1, MarkedYoung1, MarkedOld0);
256
    test_is_checks_on(null_value, Remembered0, RemappedYoung0, RemappedOld1, MarkedYoung1, MarkedOld0);
257
    test_is_checks_on(valid_value, Remembered0, RemappedYoung0, RemappedOld1, MarkedYoung1, MarkedOld1);
258
    test_is_checks_on(null_value, Remembered0, RemappedYoung0, RemappedOld1, MarkedYoung1, MarkedOld1);
259

260
    test_is_checks_on(valid_value, Remembered0, RemappedYoung1, RemappedOld0, MarkedYoung0, MarkedOld0);
261
    test_is_checks_on(null_value, Remembered0, RemappedYoung1, RemappedOld0, MarkedYoung0, MarkedOld0);
262
    test_is_checks_on(valid_value, Remembered0, RemappedYoung1, RemappedOld0, MarkedYoung0, MarkedOld1);
263
    test_is_checks_on(null_value, Remembered0, RemappedYoung1, RemappedOld0, MarkedYoung0, MarkedOld1);
264
    test_is_checks_on(valid_value, Remembered0, RemappedYoung1, RemappedOld0, MarkedYoung1, MarkedOld0);
265
    test_is_checks_on(null_value, Remembered0, RemappedYoung1, RemappedOld0, MarkedYoung1, MarkedOld0);
266
    test_is_checks_on(valid_value, Remembered0, RemappedYoung1, RemappedOld0, MarkedYoung1, MarkedOld1);
267
    test_is_checks_on(null_value, Remembered0, RemappedYoung1, RemappedOld0, MarkedYoung1, MarkedOld1);
268

269
    test_is_checks_on(valid_value, Remembered0, RemappedYoung1, RemappedOld1, MarkedYoung0, MarkedOld0);
270
    test_is_checks_on(null_value, Remembered0, RemappedYoung1, RemappedOld1, MarkedYoung0, MarkedOld0);
271
    test_is_checks_on(valid_value, Remembered0, RemappedYoung1, RemappedOld1, MarkedYoung0, MarkedOld1);
272
    test_is_checks_on(null_value, Remembered0, RemappedYoung1, RemappedOld1, MarkedYoung0, MarkedOld1);
273
    test_is_checks_on(valid_value, Remembered0, RemappedYoung1, RemappedOld1, MarkedYoung1, MarkedOld0);
274
    test_is_checks_on(null_value, Remembered0, RemappedYoung1, RemappedOld1, MarkedYoung1, MarkedOld0);
275
    test_is_checks_on(valid_value, Remembered0, RemappedYoung1, RemappedOld1, MarkedYoung1, MarkedOld1);
276
    test_is_checks_on(null_value, Remembered0, RemappedYoung1, RemappedOld1, MarkedYoung1, MarkedOld1);
277

278
    test_is_checks_on(valid_value, Remembered1, RemappedYoung0, RemappedOld0, MarkedYoung0, MarkedOld0);
279
    test_is_checks_on(null_value, Remembered1, RemappedYoung0, RemappedOld0, MarkedYoung0, MarkedOld0);
280
    test_is_checks_on(valid_value, Remembered1, RemappedYoung0, RemappedOld0, MarkedYoung0, MarkedOld1);
281
    test_is_checks_on(null_value, Remembered1, RemappedYoung0, RemappedOld0, MarkedYoung0, MarkedOld1);
282
    test_is_checks_on(valid_value, Remembered1, RemappedYoung0, RemappedOld0, MarkedYoung1, MarkedOld0);
283
    test_is_checks_on(null_value, Remembered1, RemappedYoung0, RemappedOld0, MarkedYoung1, MarkedOld0);
284
    test_is_checks_on(valid_value, Remembered1, RemappedYoung0, RemappedOld0, MarkedYoung1, MarkedOld1);
285
    test_is_checks_on(null_value, Remembered1, RemappedYoung0, RemappedOld0, MarkedYoung1, MarkedOld1);
286

287
    test_is_checks_on(valid_value, Remembered1, RemappedYoung0, RemappedOld1, MarkedYoung0, MarkedOld0);
288
    test_is_checks_on(null_value, Remembered1, RemappedYoung0, RemappedOld1, MarkedYoung0, MarkedOld0);
289
    test_is_checks_on(valid_value, Remembered1, RemappedYoung0, RemappedOld1, MarkedYoung0, MarkedOld1);
290
    test_is_checks_on(null_value, Remembered1, RemappedYoung0, RemappedOld1, MarkedYoung0, MarkedOld1);
291
    test_is_checks_on(valid_value, Remembered1, RemappedYoung0, RemappedOld1, MarkedYoung1, MarkedOld0);
292
    test_is_checks_on(null_value, Remembered1, RemappedYoung0, RemappedOld1, MarkedYoung1, MarkedOld0);
293
    test_is_checks_on(valid_value, Remembered1, RemappedYoung0, RemappedOld1, MarkedYoung1, MarkedOld1);
294
    test_is_checks_on(null_value, Remembered1, RemappedYoung0, RemappedOld1, MarkedYoung1, MarkedOld1);
295

296
    test_is_checks_on(valid_value, Remembered1, RemappedYoung1, RemappedOld0, MarkedYoung0, MarkedOld0);
297
    test_is_checks_on(null_value, Remembered1, RemappedYoung1, RemappedOld0, MarkedYoung0, MarkedOld0);
298
    test_is_checks_on(valid_value, Remembered1, RemappedYoung1, RemappedOld0, MarkedYoung0, MarkedOld1);
299
    test_is_checks_on(null_value, Remembered1, RemappedYoung1, RemappedOld0, MarkedYoung0, MarkedOld1);
300
    test_is_checks_on(valid_value, Remembered1, RemappedYoung1, RemappedOld0, MarkedYoung1, MarkedOld0);
301
    test_is_checks_on(null_value, Remembered1, RemappedYoung1, RemappedOld0, MarkedYoung1, MarkedOld0);
302
    test_is_checks_on(valid_value, Remembered1, RemappedYoung1, RemappedOld0, MarkedYoung1, MarkedOld1);
303
    test_is_checks_on(null_value, Remembered1, RemappedYoung1, RemappedOld0, MarkedYoung1, MarkedOld1);
304

305
    test_is_checks_on(valid_value, Remembered1, RemappedYoung1, RemappedOld1, MarkedYoung0, MarkedOld0);
306
    test_is_checks_on(null_value, Remembered1, RemappedYoung1, RemappedOld1, MarkedYoung0, MarkedOld0);
307
    test_is_checks_on(valid_value, Remembered1, RemappedYoung1, RemappedOld1, MarkedYoung0, MarkedOld1);
308
    test_is_checks_on(null_value, Remembered1, RemappedYoung1, RemappedOld1, MarkedYoung0, MarkedOld1);
309
    test_is_checks_on(valid_value, Remembered1, RemappedYoung1, RemappedOld1, MarkedYoung1, MarkedOld0);
310
    test_is_checks_on(null_value, Remembered1, RemappedYoung1, RemappedOld1, MarkedYoung1, MarkedOld0);
311
    test_is_checks_on(valid_value, Remembered1, RemappedYoung1, RemappedOld1, MarkedYoung1, MarkedOld1);
312
    test_is_checks_on(null_value, Remembered1, RemappedYoung1, RemappedOld1, MarkedYoung1, MarkedOld1);
313

314
    test_is_checks_on(valid_value, Remembered11, RemappedYoung0, RemappedOld0, MarkedYoung0, MarkedOld0);
315
    test_is_checks_on(null_value, Remembered11, RemappedYoung0, RemappedOld0, MarkedYoung0, MarkedOld0);
316
    test_is_checks_on(valid_value, Remembered11, RemappedYoung0, RemappedOld0, MarkedYoung0, MarkedOld1);
317
    test_is_checks_on(null_value, Remembered11, RemappedYoung0, RemappedOld0, MarkedYoung0, MarkedOld1);
318
    test_is_checks_on(valid_value, Remembered11, RemappedYoung0, RemappedOld0, MarkedYoung1, MarkedOld0);
319
    test_is_checks_on(null_value, Remembered11, RemappedYoung0, RemappedOld0, MarkedYoung1, MarkedOld0);
320
    test_is_checks_on(valid_value, Remembered11, RemappedYoung0, RemappedOld0, MarkedYoung1, MarkedOld1);
321
    test_is_checks_on(null_value, Remembered11, RemappedYoung0, RemappedOld0, MarkedYoung1, MarkedOld1);
322

323
    test_is_checks_on(valid_value, Remembered11, RemappedYoung0, RemappedOld1, MarkedYoung0, MarkedOld0);
324
    test_is_checks_on(null_value, Remembered11, RemappedYoung0, RemappedOld1, MarkedYoung0, MarkedOld0);
325
    test_is_checks_on(valid_value, Remembered11, RemappedYoung0, RemappedOld1, MarkedYoung0, MarkedOld1);
326
    test_is_checks_on(null_value, Remembered11, RemappedYoung0, RemappedOld1, MarkedYoung0, MarkedOld1);
327
    test_is_checks_on(valid_value, Remembered11, RemappedYoung0, RemappedOld1, MarkedYoung1, MarkedOld0);
328
    test_is_checks_on(null_value, Remembered11, RemappedYoung0, RemappedOld1, MarkedYoung1, MarkedOld0);
329
    test_is_checks_on(valid_value, Remembered11, RemappedYoung0, RemappedOld1, MarkedYoung1, MarkedOld1);
330
    test_is_checks_on(null_value, Remembered11, RemappedYoung0, RemappedOld1, MarkedYoung1, MarkedOld1);
331

332
    test_is_checks_on(valid_value, Remembered11, RemappedYoung1, RemappedOld0, MarkedYoung0, MarkedOld0);
333
    test_is_checks_on(null_value, Remembered11, RemappedYoung1, RemappedOld0, MarkedYoung0, MarkedOld0);
334
    test_is_checks_on(valid_value, Remembered11, RemappedYoung1, RemappedOld0, MarkedYoung0, MarkedOld1);
335
    test_is_checks_on(null_value, Remembered11, RemappedYoung1, RemappedOld0, MarkedYoung0, MarkedOld1);
336
    test_is_checks_on(valid_value, Remembered11, RemappedYoung1, RemappedOld0, MarkedYoung1, MarkedOld0);
337
    test_is_checks_on(null_value, Remembered11, RemappedYoung1, RemappedOld0, MarkedYoung1, MarkedOld0);
338
    test_is_checks_on(valid_value, Remembered11, RemappedYoung1, RemappedOld0, MarkedYoung1, MarkedOld1);
339
    test_is_checks_on(null_value, Remembered11, RemappedYoung1, RemappedOld0, MarkedYoung1, MarkedOld1);
340

341
    test_is_checks_on(valid_value, Remembered11, RemappedYoung1, RemappedOld1, MarkedYoung0, MarkedOld0);
342
    test_is_checks_on(null_value, Remembered11, RemappedYoung1, RemappedOld1, MarkedYoung0, MarkedOld0);
343
    test_is_checks_on(valid_value, Remembered11, RemappedYoung1, RemappedOld1, MarkedYoung0, MarkedOld1);
344
    test_is_checks_on(null_value, Remembered11, RemappedYoung1, RemappedOld1, MarkedYoung0, MarkedOld1);
345
    test_is_checks_on(valid_value, Remembered11, RemappedYoung1, RemappedOld1, MarkedYoung1, MarkedOld0);
346
    test_is_checks_on(null_value, Remembered11, RemappedYoung1, RemappedOld1, MarkedYoung1, MarkedOld0);
347
    test_is_checks_on(valid_value, Remembered11, RemappedYoung1, RemappedOld1, MarkedYoung1, MarkedOld1);
348
    test_is_checks_on(null_value, Remembered11, RemappedYoung1, RemappedOld1, MarkedYoung1, MarkedOld1);
349

350
    test_is_checks_on(null_value, Uncolored, Uncolored, Uncolored, Uncolored, Uncolored);
351
  }
352

353
  static void advance_and_test_young_phase(int& phase, int amount) {
354
    for (int i = 0; i < amount; ++i) {
355
      if (++phase & 1) {
356
        ZGlobalsPointers::flip_young_mark_start();
357
      } else {
358
        ZGlobalsPointers::flip_young_relocate_start();
359
      }
360
      test_is_checks_on_all();
361
    }
362
  }
363

364
  static void advance_and_test_old_phase(int& phase, int amount) {
365
    for (int i = 0; i < amount; ++i) {
366
      if (++phase & 1) {
367
        ZGlobalsPointers::flip_old_mark_start();
368
      } else {
369
        ZGlobalsPointers::flip_old_relocate_start();
370
      }
371
      test_is_checks_on_all();
372
    }
373
  }
374

375
  static void is_checks() {
376
    int young_phase = 0;
377
    int old_phase = 0;
378
    // Setup
379
    ZGlobalsPointers::initialize();
380
    test_is_checks_on_all();
381

382
    advance_and_test_old_phase(old_phase, 4);
383
    advance_and_test_young_phase(young_phase, 4);
384

385
    advance_and_test_old_phase(old_phase, 1);
386
    advance_and_test_young_phase(young_phase, 4);
387

388
    advance_and_test_old_phase(old_phase, 1);
389
    advance_and_test_young_phase(young_phase, 4);
390

391
    advance_and_test_old_phase(old_phase, 1);
392
    advance_and_test_young_phase(young_phase, 4);
393

394
    advance_and_test_old_phase(old_phase, 1);
395
    advance_and_test_young_phase(young_phase, 4);
396

397
    advance_and_test_old_phase(old_phase, 1);
398
    advance_and_test_young_phase(young_phase, 3);
399

400
    advance_and_test_old_phase(old_phase, 1);
401
    advance_and_test_young_phase(young_phase, 3);
402

403
    advance_and_test_old_phase(old_phase, 1);
404
    advance_and_test_young_phase(young_phase, 3);
405

406
    advance_and_test_old_phase(old_phase, 1);
407
    advance_and_test_young_phase(young_phase, 3);
408

409
    advance_and_test_old_phase(old_phase, 1);
410
    advance_and_test_young_phase(young_phase, 2);
411

412
    advance_and_test_old_phase(old_phase, 1);
413
    advance_and_test_young_phase(young_phase, 2);
414

415
    advance_and_test_old_phase(old_phase, 1);
416
    advance_and_test_young_phase(young_phase, 2);
417

418
    advance_and_test_old_phase(old_phase, 1);
419
    advance_and_test_young_phase(young_phase, 2);
420

421
    advance_and_test_old_phase(old_phase, 1);
422
    advance_and_test_young_phase(young_phase, 1);
423

424
    advance_and_test_old_phase(old_phase, 1);
425
    advance_and_test_young_phase(young_phase, 1);
426

427
    advance_and_test_old_phase(old_phase, 1);
428
    advance_and_test_young_phase(young_phase, 1);
429

430
    advance_and_test_old_phase(old_phase, 1);
431
    advance_and_test_young_phase(young_phase, 1);
432
  }
433
};
434

435
TEST_F(ZAddressTest, is_checks) {
436
  is_checks();
437
}
438

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.