Skip to content

Commit

Permalink
[pmc] rpa: fix custom_mark_destroy confusion
Browse files Browse the repository at this point in the history
custom_mark_destroy is only needed in the init method, which is fpa.set_integer_native.
optimize PObj_custom_mark_destroy_SETALL to use only one setter call.
  • Loading branch information
Reini Urban committed Jan 22, 2015
1 parent aae3b13 commit 606d9fd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
6 changes: 2 additions & 4 deletions include/parrot/pobj.h
Expand Up @@ -334,10 +334,8 @@ typedef enum PObj_enum {
(PObj_sysmem_FLAG | PObj_is_string_copy_FLAG | \
PObj_constant_FLAG | PObj_external_FLAG)))

#define PObj_custom_mark_destroy_SETALL(o) do { \
PObj_custom_mark_SET(o); \
PObj_custom_destroy_SET(o); \
} while (0)
#define PObj_custom_mark_destroy_SETALL(o) \
(PObj_get_FLAGS(o) |= PObj_custom_mark_FLAG | PObj_custom_destroy_FLAG)

#define PObj_gc_CLEAR(o) (PObj_get_FLAGS(o) \
&= ~PObj_custom_destroy_FLAG \
Expand Down
10 changes: 3 additions & 7 deletions src/pmc/resizablepmcarray.pmc
Expand Up @@ -222,7 +222,6 @@ Initializes the array.
PMC_offset(SELF) = 0;
if (LIKELY(n > 0)) {
PMC_threshold(SELF) = n;
PARROT_GC_WRITE_BARRIER(INTERP, SELF);
}
}

Expand Down Expand Up @@ -286,7 +285,6 @@ Resizes the array to C<size> elements.
}
#endif
PMC_offset(SELF) -= diff;
PObj_custom_mark_destroy_SETALL(SELF);
}
else { /* for empty arrays just reset the offset */
PMC_offset(SELF) = 0;
Expand Down Expand Up @@ -319,7 +317,6 @@ Resizes the array to C<size> elements.
PMC_threshold(SELF) = threshold;
PMC_size(SELF) = n - offset;
if (PMC_array(SELF) != array) { /* data moved? */
PObj_custom_mark_destroy_SETALL(SELF);
PMC_array(SELF) = array;
TRACE_RPAsize("resize move");
}
Expand Down Expand Up @@ -503,8 +500,6 @@ Sets the PMC value of the element keyed by C<key> to C<*src>.
data = PMC_array(SELF) = mem_gc_allocate_n_typed(INTERP, size, PMC *);
for (i = 0; i < size; ++i)
data[i] = VTABLE_get_pmc_keyed_int(INTERP, value, i);

PObj_custom_mark_destroy_SETALL(SELF);
}

/*
Expand Down Expand Up @@ -545,14 +540,15 @@ Delete the element at index C<key> and shift the rest to the left.
if (0 == key) {
data->offset++;
TRACE_RPAdata("delete fast", data);
TRACE_PMC(key, data->pmc_array[0]);
TRACE_PMC(key, data->pmc_array[data->offset-1]);
}
else {
PMC ** const off = &data->pmc_array[key + data->offset];
TRACE_RPAdata("delete slow", data);
TRACE_PMC(key + data->offset, data->pmc_array[key + data->offset]);
if (data->size > key) /* skip when last element */
if (data->size > key) { /* skip when last element */
memmove(off, off + 1, (data->size - key) * sizeof (PMC *));
}
}
}

Expand Down

0 comments on commit 606d9fd

Please sign in to comment.