| 1 |
import sys |
| 2 |
from rpython.memory.gc.semispace import SemiSpaceGC |
| 3 |
from rpython.memory.gc.generation import GenerationGC, WORD |
| 4 |
from rpython.memory.gc.semispace import GCFLAG_EXTERNAL, GCFLAG_FORWARDED |
| 5 |
from rpython.memory.gc.semispace import GCFLAG_HASHMASK |
| 6 |
from rpython.memory.gc.generation import GCFLAG_NO_YOUNG_PTRS |
| 7 |
from rpython.memory.gc.generation import GCFLAG_NO_HEAP_PTRS |
| 8 |
from rpython.memory.gc.semispace import GC_HASH_TAKEN_ADDR |
| 9 |
from rpython.memory.gc.semispace import GC_HASH_HASFIELD |
| 10 |
from rpython.rtyper.lltypesystem import lltype, llmemory, llarena |
| 11 |
from rpython.rtyper.lltypesystem.llmemory import raw_malloc_usage |
| 12 |
from rpython.rtyper.lltypesystem.lloperation import llop |
| 13 |
from rpython.rlib.debug import ll_assert, have_debug_prints |
| 14 |
from rpython.rlib.debug import debug_print, debug_start, debug_stop |
| 15 |
from rpython.rlib.rarithmetic import ovfcheck |
| 16 |
from rpython.rtyper.lltypesystem import rffi |
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
MAX_SEMISPACE_AGE = 3 |
| 61 |
|
| 62 |
GCFLAG_UNVISITED = GenerationGC.first_unused_gcflag << 0 |
| 63 |
_gcflag_next_bit = GenerationGC.first_unused_gcflag << 1 |
| 64 |
GCFLAG_AGE_ONE = _gcflag_next_bit |
| 65 |
GCFLAG_AGE_MAX = _gcflag_next_bit * MAX_SEMISPACE_AGE |
| 66 |
GCFLAG_AGE_MASK = 0 |
| 67 |
while GCFLAG_AGE_MASK < GCFLAG_AGE_MAX: |
| 68 |
GCFLAG_AGE_MASK |= _gcflag_next_bit |
| 69 |
_gcflag_next_bit <<= 1 |
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
GENERATION3_COLLECT_THRESHOLD = 20 |
| 74 |
|
| 75 |
class HybridGC(GenerationGC): |
| 76 |
"""A two-generations semi-space GC like the GenerationGC, |
| 77 |
except that objects above a certain size are handled separately: |
| 78 |
they are allocated via raw_malloc/raw_free in a mark-n-sweep fashion. |
| 79 |
""" |
| 80 |
first_unused_gcflag = _gcflag_next_bit |
| 81 |
prebuilt_gc_objects_are_static_roots = True |
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
TRANSLATION_PARAMS = GenerationGC.TRANSLATION_PARAMS.copy() |
| 86 |
TRANSLATION_PARAMS['large_object'] = 6*1024 |
| 87 |
TRANSLATION_PARAMS['large_object_gcptrs'] = 31*1024 |
| 88 |
TRANSLATION_PARAMS['min_nursery_size'] = 128*1024 |
| 89 |
|
| 90 |
|
| 91 |
def __init__(self, *args, **kwds): |
| 92 |
large_object = kwds.pop('large_object', 6*WORD) |
| 93 |
large_object_gcptrs = kwds.pop('large_object_gcptrs', 8*WORD) |
| 94 |
self.generation3_collect_threshold = kwds.pop( |
| 95 |
'generation3_collect_threshold', GENERATION3_COLLECT_THRESHOLD) |
| 96 |
GenerationGC.__init__(self, *args, **kwds) |
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
self.nonlarge_max = large_object - 1 |
| 111 |
self.nonlarge_gcptrs_max = large_object_gcptrs - 1 |
| 112 |
assert self.nonlarge_gcptrs_max <= self.lb_young_var_basesize |
| 113 |
assert self.nonlarge_max <= self.nonlarge_gcptrs_max |
| 114 |
|
| 115 |
def setup(self): |
| 116 |
self.large_objects_collect_trigger = self.param_space_size |
| 117 |
self._initial_trigger = self.large_objects_collect_trigger |
| 118 |
self.rawmalloced_objects_to_trace = self.AddressStack() |
| 119 |
self.count_semispaceonly_collects = 0 |
| 120 |
|
| 121 |
self.gen2_rawmalloced_objects = self.AddressStack() |
| 122 |
self.gen3_rawmalloced_objects = self.AddressStack() |
| 123 |
GenerationGC.setup(self) |
| 124 |
|
| 125 |
def set_max_heap_size(self, size): |
| 126 |
raise NotImplementedError |
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
def malloc_varsize_clear(self, typeid, length, size, itemsize, |
| 132 |
offset_to_length): |
| 133 |
size_gc_header = self.gcheaderbuilder.size_gc_header |
| 134 |
nonvarsize = size_gc_header + size |
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
if self.has_gcptr_in_varsize(typeid): |
| 142 |
nonlarge_max = self.nonlarge_gcptrs_max |
| 143 |
else: |
| 144 |
nonlarge_max = self.nonlarge_max |
| 145 |
|
| 146 |
if not raw_malloc_usage(itemsize): |
| 147 |
too_many_items = raw_malloc_usage(nonvarsize) > nonlarge_max |
| 148 |
else: |
| 149 |
maxlength = nonlarge_max - raw_malloc_usage(nonvarsize) |
| 150 |
maxlength = maxlength // raw_malloc_usage(itemsize) |
| 151 |
too_many_items = length > maxlength |
| 152 |
|
| 153 |
if not too_many_items: |
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
totalsize = nonvarsize + itemsize * length |
| 158 |
result = self.nursery_free |
| 159 |
if raw_malloc_usage(totalsize) <= self.nursery_top - result: |
| 160 |
llarena.arena_reserve(result, totalsize) |
| 161 |
|
| 162 |
self.init_gc_object(result, typeid, flags=0) |
| 163 |
(result + size_gc_header + offset_to_length).signed[0] = length |
| 164 |
self.nursery_free = result + llarena.round_up_for_allocation( |
| 165 |
totalsize) |
| 166 |
return llmemory.cast_adr_to_ptr(result+size_gc_header, |
| 167 |
llmemory.GCREF) |
| 168 |
return self.malloc_varsize_slowpath(typeid, length) |
| 169 |
|
| 170 |
def malloc_varsize_slowpath(self, typeid, length): |
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
size_gc_header = self.gcheaderbuilder.size_gc_header |
| 176 |
nonvarsize = size_gc_header + self.fixed_size(typeid) |
| 177 |
itemsize = self.varsize_item_sizes(typeid) |
| 178 |
offset_to_length = self.varsize_offset_to_length(typeid) |
| 179 |
try: |
| 180 |
varsize = ovfcheck(itemsize * length) |
| 181 |
totalsize = ovfcheck(nonvarsize + varsize) |
| 182 |
except OverflowError: |
| 183 |
raise MemoryError() |
| 184 |
if self.has_gcptr_in_varsize(typeid): |
| 185 |
nonlarge_max = self.nonlarge_gcptrs_max |
| 186 |
else: |
| 187 |
nonlarge_max = self.nonlarge_max |
| 188 |
if raw_malloc_usage(totalsize) > nonlarge_max: |
| 189 |
result = self.malloc_varsize_marknsweep(totalsize) |
| 190 |
flags = self.GCFLAGS_FOR_NEW_EXTERNAL_OBJECTS | GCFLAG_UNVISITED |
| 191 |
else: |
| 192 |
result = self.malloc_varsize_collecting_nursery(totalsize) |
| 193 |
flags = self.GCFLAGS_FOR_NEW_YOUNG_OBJECTS |
| 194 |
self.init_gc_object(result, typeid, flags) |
| 195 |
(result + size_gc_header + offset_to_length).signed[0] = length |
| 196 |
return llmemory.cast_adr_to_ptr(result+size_gc_header, llmemory.GCREF) |
| 197 |
|
| 198 |
malloc_varsize_slowpath._dont_inline_ = True |
| 199 |
|
| 200 |
def can_move(self, addr): |
| 201 |
tid = self.header(addr).tid |
| 202 |
return not (tid & GCFLAG_EXTERNAL) |
| 203 |
|
| 204 |
def malloc_varsize_collecting_nursery(self, totalsize): |
| 205 |
result = self.collect_nursery() |
| 206 |
ll_assert(raw_malloc_usage(totalsize) <= self.nursery_top - result, |
| 207 |
"not enough room in malloc_varsize_collecting_nursery()") |
| 208 |
llarena.arena_reserve(result, totalsize) |
| 209 |
self.nursery_free = result + llarena.round_up_for_allocation( |
| 210 |
totalsize) |
| 211 |
return result |
| 212 |
|
| 213 |
def _check_rawsize_alloced(self, size_estimate): |
| 214 |
self.large_objects_collect_trigger -= size_estimate |
| 215 |
if self.large_objects_collect_trigger < 0: |
| 216 |
debug_start("gc-rawsize-collect") |
| 217 |
debug_print("allocated", (self._initial_trigger - |
| 218 |
self.large_objects_collect_trigger), |
| 219 |
"bytes, triggering full collection") |
| 220 |
self.semispace_collect() |
| 221 |
debug_stop("gc-rawsize-collect") |
| 222 |
|
| 223 |
def malloc_varsize_marknsweep(self, totalsize): |
| 224 |
|
| 225 |
|
| 226 |
|
| 227 |
self._check_rawsize_alloced(raw_malloc_usage(totalsize)) |
| 228 |
result = self.allocate_external_object(totalsize) |
| 229 |
if not result: |
| 230 |
raise MemoryError() |
| 231 |
|
| 232 |
|
| 233 |
llmemory.raw_memclear(result, totalsize) |
| 234 |
size_gc_header = self.gcheaderbuilder.size_gc_header |
| 235 |
self.gen2_rawmalloced_objects.append(result + size_gc_header) |
| 236 |
return result |
| 237 |
|
| 238 |
def allocate_external_object(self, totalsize): |
| 239 |
|
| 240 |
|
| 241 |
return llmemory.raw_malloc(totalsize) |
| 242 |
|
| 243 |
def init_gc_object_immortal(self, addr, typeid, |
| 244 |
flags=(GCFLAG_NO_YOUNG_PTRS | |
| 245 |
GCFLAG_NO_HEAP_PTRS | |
| 246 |
GCFLAG_AGE_MAX)): |
| 247 |
GenerationGC.init_gc_object_immortal(self, addr, typeid, flags) |
| 248 |
|
| 249 |
|
| 250 |
|
| 251 |
|
| 252 |
|
| 253 |
|
| 254 |
|
| 255 |
def collect(self, gen=2): |
| 256 |
if gen > 1: |
| 257 |
self.count_semispaceonly_collects = self.generation3_collect_threshold |
| 258 |
GenerationGC.collect(self, gen) |
| 259 |
|
| 260 |
def is_collecting_gen3(self): |
| 261 |
count = self.count_semispaceonly_collects |
| 262 |
return count >= self.generation3_collect_threshold |
| 263 |
|
| 264 |
|
| 265 |
|
| 266 |
|
| 267 |
def starting_full_collect(self): |
| 268 |
|
| 269 |
|
| 270 |
|
| 271 |
self.count_semispaceonly_collects += 1 |
| 272 |
if self.is_collecting_gen3(): |
| 273 |
|
| 274 |
|
| 275 |
self.gen3_rawmalloced_objects.foreach(self._set_gcflag_unvisited, |
| 276 |
None) |
| 277 |
ll_assert(not self.rawmalloced_objects_to_trace.non_empty(), |
| 278 |
"rawmalloced_objects_to_trace should be empty at start") |
| 279 |
self._nonmoving_copy_count = 0 |
| 280 |
self._nonmoving_copy_size = 0 |
| 281 |
|
| 282 |
def _set_gcflag_unvisited(self, obj, ignored): |
| 283 |
ll_assert(not (self.header(obj).tid & GCFLAG_UNVISITED), |
| 284 |
"bogus GCFLAG_UNVISITED on gen3 obj") |
| 285 |
self.header(obj).tid |= GCFLAG_UNVISITED |
| 286 |
|
| 287 |
def collect_roots(self): |
| 288 |
if not self.is_collecting_gen3(): |
| 289 |
GenerationGC.collect_roots(self) |
| 290 |
else: |
| 291 |
|
| 292 |
|
| 293 |
|
| 294 |
self.root_walker.walk_roots( |
| 295 |
SemiSpaceGC._collect_root, |
| 296 |
SemiSpaceGC._collect_root, |
| 297 |
SemiSpaceGC._collect_root) |
| 298 |
|
| 299 |
def surviving(self, obj): |
| 300 |
|
| 301 |
|
| 302 |
|
| 303 |
|
| 304 |
flags = self.header(obj).tid & (GCFLAG_FORWARDED|GCFLAG_UNVISITED) |
| 305 |
return flags == GCFLAG_FORWARDED |
| 306 |
|
| 307 |
def is_last_generation(self, obj): |
| 308 |
return ((self.header(obj).tid & (GCFLAG_EXTERNAL|GCFLAG_AGE_MASK)) == |
| 309 |
(GCFLAG_EXTERNAL|GCFLAG_AGE_MAX)) |
| 310 |
|
| 311 |
def visit_external_object(self, obj): |
| 312 |
hdr = self.header(obj) |
| 313 |
if hdr.tid & GCFLAG_UNVISITED: |
| 314 |
|
| 315 |
hdr.tid &= ~GCFLAG_UNVISITED |
| 316 |
self.rawmalloced_objects_to_trace.append(obj) |
| 317 |
|
| 318 |
def make_a_copy(self, obj, objsize): |
| 319 |
|
| 320 |
|
| 321 |
|
| 322 |
|
| 323 |
|
| 324 |
tid = self.header(obj).tid |
| 325 |
|
| 326 |
|
| 327 |
|
| 328 |
|
| 329 |
|
| 330 |
|
| 331 |
if not (tid & GCFLAG_NO_YOUNG_PTRS): |
| 332 |
tid |= GCFLAG_NO_YOUNG_PTRS |
| 333 |
elif (tid & GCFLAG_AGE_MASK) < GCFLAG_AGE_MAX: |
| 334 |
tid += GCFLAG_AGE_ONE |
| 335 |
else: |
| 336 |
newobj = self.make_a_nonmoving_copy(obj, objsize) |
| 337 |
if newobj: |
| 338 |
return newobj |
| 339 |
tid &= ~GCFLAG_AGE_MASK |
| 340 |
|
| 341 |
|
| 342 |
return self._make_a_copy_with_tid(obj, objsize, tid) |
| 343 |
|
| 344 |
def make_a_nonmoving_copy(self, obj, objsize): |
| 345 |
|
| 346 |
|
| 347 |
totalsize = self.size_gc_header() + objsize |
| 348 |
tid = self.header(obj).tid |
| 349 |
if tid & GCFLAG_HASHMASK: |
| 350 |
totalsize_incl_hash = totalsize + llmemory.sizeof(lltype.Signed) |
| 351 |
else: |
| 352 |
totalsize_incl_hash = totalsize |
| 353 |
newaddr = self.allocate_external_object(totalsize_incl_hash) |
| 354 |
if not newaddr: |
| 355 |
return llmemory.NULL |
| 356 |
self._nonmoving_copy_count += 1 |
| 357 |
self._nonmoving_copy_size += raw_malloc_usage(totalsize) |
| 358 |
|
| 359 |
llmemory.raw_memcopy(obj - self.size_gc_header(), newaddr, totalsize) |
| 360 |
if tid & GCFLAG_HASHMASK: |
| 361 |
hash = self._get_object_hash(obj, objsize, tid) |
| 362 |
(newaddr + totalsize).signed[0] = hash |
| 363 |
tid |= GC_HASH_HASFIELD |
| 364 |
|
| 365 |
|
| 366 |
|
| 367 |
|
| 368 |
|
| 369 |
newobj = newaddr + self.size_gc_header() |
| 370 |
hdr = self.header(newobj) |
| 371 |
hdr.tid = tid | self.GCFLAGS_FOR_NEW_EXTERNAL_OBJECTS |
| 372 |
ll_assert(self.is_last_generation(newobj), |
| 373 |
"make_a_nonmoving_copy: object too young") |
| 374 |
self.gen3_rawmalloced_objects.append(newobj) |
| 375 |
self.last_generation_root_objects.append(newobj) |
| 376 |
self.rawmalloced_objects_to_trace.append(newobj) |
| 377 |
return newobj |
| 378 |
|
| 379 |
def scan_copied(self, scan): |
| 380 |
|
| 381 |
|
| 382 |
progress = True |
| 383 |
while progress: |
| 384 |
newscan = GenerationGC.scan_copied(self, scan) |
| 385 |
progress = newscan != scan |
| 386 |
scan = newscan |
| 387 |
while self.rawmalloced_objects_to_trace.non_empty(): |
| 388 |
obj = self.rawmalloced_objects_to_trace.pop() |
| 389 |
self.trace_and_copy(obj) |
| 390 |
progress = True |
| 391 |
return scan |
| 392 |
|
| 393 |
def finished_full_collect(self): |
| 394 |
ll_assert(not self.rawmalloced_objects_to_trace.non_empty(), |
| 395 |
"rawmalloced_objects_to_trace should be empty at end") |
| 396 |
debug_print("| [hybrid] made nonmoving: ", |
| 397 |
self._nonmoving_copy_size, "bytes in", |
| 398 |
self._nonmoving_copy_count, "objs") |
| 399 |
rawmalloced_trigger = 0 |
| 400 |
|
| 401 |
if self.is_collecting_gen3(): |
| 402 |
rawmalloced_trigger += self.sweep_rawmalloced_objects(generation=3) |
| 403 |
rawmalloced_trigger += self.sweep_rawmalloced_objects(generation=2) |
| 404 |
self.large_objects_collect_trigger = (rawmalloced_trigger + |
| 405 |
self.space_size) |
| 406 |
if self.is_collecting_gen3(): |
| 407 |
self.count_semispaceonly_collects = 0 |
| 408 |
self._initial_trigger = self.large_objects_collect_trigger |
| 409 |
|
| 410 |
def sweep_rawmalloced_objects(self, generation): |
| 411 |
|
| 412 |
|
| 413 |
if generation == 2: |
| 414 |
objects = self.gen2_rawmalloced_objects |
| 415 |
|
| 416 |
|
| 417 |
|
| 418 |
|
| 419 |
|
| 420 |
elif generation == 3: |
| 421 |
objects = self.gen3_rawmalloced_objects |
| 422 |
|
| 423 |
|
| 424 |
gen3roots = self.last_generation_root_objects |
| 425 |
newgen3roots = self.AddressStack() |
| 426 |
while gen3roots.non_empty(): |
| 427 |
obj = gen3roots.pop() |
| 428 |
if not (self.header(obj).tid & GCFLAG_UNVISITED): |
| 429 |
newgen3roots.append(obj) |
| 430 |
gen3roots.delete() |
| 431 |
self.last_generation_root_objects = newgen3roots |
| 432 |
else: |
| 433 |
ll_assert(False, "bogus 'generation'") |
| 434 |
return 0 |
| 435 |
|
| 436 |
surviving_objects = self.AddressStack() |
| 437 |
|
| 438 |
alive_count = alive_size = dead_count = dead_size = 0 |
| 439 |
debug = have_debug_prints() |
| 440 |
while objects.non_empty(): |
| 441 |
obj = objects.pop() |
| 442 |
tid = self.header(obj).tid |
| 443 |
if tid & GCFLAG_UNVISITED: |
| 444 |
if debug: |
| 445 |
dead_count+=1 |
| 446 |
dead_size+=raw_malloc_usage(self.get_size_incl_hash(obj)) |
| 447 |
addr = obj - self.gcheaderbuilder.size_gc_header |
| 448 |
llmemory.raw_free(addr) |
| 449 |
else: |
| 450 |
if debug: |
| 451 |
alive_count+=1 |
| 452 |
alive_size+=raw_malloc_usage(self.get_size_incl_hash(obj)) |
| 453 |
if generation == 3: |
| 454 |
surviving_objects.append(obj) |
| 455 |
elif generation == 2: |
| 456 |
ll_assert((tid & GCFLAG_AGE_MASK) < GCFLAG_AGE_MAX, |
| 457 |
"wrong age for generation 2 object") |
| 458 |
tid += GCFLAG_AGE_ONE |
| 459 |
if (tid & GCFLAG_AGE_MASK) == GCFLAG_AGE_MAX: |
| 460 |
|
| 461 |
self.gen3_rawmalloced_objects.append(obj) |
| 462 |
|
| 463 |
self.last_generation_root_objects.append(obj) |
| 464 |
else: |
| 465 |
|
| 466 |
tid |= GCFLAG_UNVISITED |
| 467 |
surviving_objects.append(obj) |
| 468 |
self.header(obj).tid = tid |
| 469 |
objects.delete() |
| 470 |
if generation == 2: |
| 471 |
self.gen2_rawmalloced_objects = surviving_objects |
| 472 |
elif generation == 3: |
| 473 |
self.gen3_rawmalloced_objects = surviving_objects |
| 474 |
debug_print("| [hyb] gen", generation, |
| 475 |
"nonmoving now alive: ", |
| 476 |
alive_size, "bytes in", |
| 477 |
alive_count, "objs") |
| 478 |
debug_print("| [hyb] gen", generation, |
| 479 |
"nonmoving freed: ", |
| 480 |
dead_size, "bytes in", |
| 481 |
dead_count, "objs") |
| 482 |
return alive_size |
| 483 |
|
| 484 |
def id(self, ptr): |
| 485 |
obj = llmemory.cast_ptr_to_adr(ptr) |
| 486 |
|
| 487 |
|
| 488 |
if not self.is_valid_gc_object(obj): |
| 489 |
return llmemory.cast_adr_to_int(obj) |
| 490 |
|
| 491 |
if self._is_external(obj): |
| 492 |
|
| 493 |
if self.is_last_generation(obj): |
| 494 |
|
| 495 |
|
| 496 |
|
| 497 |
|
| 498 |
result = self.objects_with_id.get(obj, obj) |
| 499 |
else: |
| 500 |
|
| 501 |
|
| 502 |
result = obj |
| 503 |
else: |
| 504 |
result = self._compute_id(obj) |
| 505 |
return llmemory.cast_adr_to_int(result) * 2 |
| 506 |
|
| 507 |
|
| 508 |
|
| 509 |
def debug_check_object(self, obj): |
| 510 |
"""Check the invariants about 'obj' that should be true |
| 511 |
between collections.""" |
| 512 |
GenerationGC.debug_check_object(self, obj) |
| 513 |
tid = self.header(obj).tid |
| 514 |
if tid & GCFLAG_UNVISITED: |
| 515 |
ll_assert(self._d_gen2ro.contains(obj), |
| 516 |
"GCFLAG_UNVISITED on non-gen2 object") |
| 517 |
|
| 518 |
def debug_check_consistency(self): |
| 519 |
if self.DEBUG: |
| 520 |
self._d_gen2ro = self.gen2_rawmalloced_objects.stack2dict() |
| 521 |
GenerationGC.debug_check_consistency(self) |
| 522 |
self._d_gen2ro.delete() |
| 523 |
self.gen2_rawmalloced_objects.foreach(self._debug_check_gen2, None) |
| 524 |
self.gen3_rawmalloced_objects.foreach(self._debug_check_gen3, None) |
| 525 |
|
| 526 |
def _debug_check_gen2(self, obj, ignored): |
| 527 |
tid = self.header(obj).tid |
| 528 |
ll_assert(bool(tid & GCFLAG_EXTERNAL), |
| 529 |
"gen2: missing GCFLAG_EXTERNAL") |
| 530 |
ll_assert(bool(tid & GC_HASH_TAKEN_ADDR), |
| 531 |
"gen2: missing GC_HASH_TAKEN_ADDR") |
| 532 |
ll_assert(bool(tid & GCFLAG_UNVISITED), |
| 533 |
"gen2: missing GCFLAG_UNVISITED") |
| 534 |
ll_assert((tid & GCFLAG_AGE_MASK) < GCFLAG_AGE_MAX, |
| 535 |
"gen2: age field too large") |
| 536 |
def _debug_check_gen3(self, obj, ignored): |
| 537 |
tid = self.header(obj).tid |
| 538 |
ll_assert(bool(tid & GCFLAG_EXTERNAL), |
| 539 |
"gen3: missing GCFLAG_EXTERNAL") |
| 540 |
ll_assert(bool(tid & GC_HASH_TAKEN_ADDR), |
| 541 |
"gen3: missing GC_HASH_TAKEN_ADDR") |
| 542 |
ll_assert(not (tid & GCFLAG_UNVISITED), |
| 543 |
"gen3: unexpected GCFLAG_UNVISITED") |
| 544 |
ll_assert((tid & GCFLAG_AGE_MASK) == GCFLAG_AGE_MAX, |
| 545 |
"gen3: wrong age field") |