Skip to content

Commit

Permalink
[gc] simplify the stack scanning loop
Browse files Browse the repository at this point in the history
just inc the stack ptr
reverse the hi <=> lo markers to make sense
comment the unsafe ptr dereference here, where asan and valgrind do complain.
  • Loading branch information
Reini Urban committed May 30, 2014
1 parent e2c0aba commit 8cdf3bd
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/gc/system.c
Expand Up @@ -455,22 +455,22 @@ trace_mem_block(PARROT_INTERP,
if (!lo_var_ptr || !hi_var_ptr)
return;

if (lo_var_ptr < hi_var_ptr) {
const size_t tmp_ptr = hi_var_ptr;
hi_var_ptr = lo_var_ptr;
lo_var_ptr = tmp_ptr;
/* We can the scan the pool upwards from lo to hi. */
if (hi_var_ptr < lo_var_ptr) {
const size_t tmp_ptr = lo_var_ptr;
lo_var_ptr = hi_var_ptr;
hi_var_ptr = tmp_ptr;
}

/* Get the expected prefix */
prefix = mem_pools
? mask & buffer_min
: 0;

for (cur_var_ptr = hi_var_ptr;
(ptrdiff_t)cur_var_ptr < (ptrdiff_t)lo_var_ptr;
cur_var_ptr = (size_t)((ptrdiff_t)cur_var_ptr + sizeof (void *))) {
const size_t ptr = *(size_t *)cur_var_ptr;
for (cur_var_ptr = lo_var_ptr; cur_var_ptr < (ptrdiff_t)hi_var_ptr; cur_var_ptr++) {

/* XXX yes, ptr may be uninitialized here. valgrind and asan complains. */
const size_t ptr = *(size_t *)cur_var_ptr;
if (!ptr)
continue;

Expand Down

0 comments on commit 8cdf3bd

Please sign in to comment.