Browse files

Removed unnecsary interp arg from Parrot_pa_insert. Changed the ARGIN…

…(self) to ARGMOD. Fixed some spelling typos.
  • Loading branch information...
1 parent 0c62b2d commit 3d3c8334205b219f8e6042e99a1255901669fe69 @petdance petdance committed Apr 12, 2012
Showing with 50 additions and 49 deletions.
  1. +24 −23 include/parrot/pointer_array.h
  2. +9 −9 src/gc/gc_gms.c
  3. +3 −3 src/gc/gc_ms2.c
  4. +14 −14 t/src/pointer_array.t
View
47 include/parrot/pointer_array.h
@@ -1,5 +1,5 @@
/*
-Copyright (C) 2010-2011, Parrot Foundation.
+Copyright (C) 2010-2012, Parrot Foundation.
=head1 NAME
@@ -84,10 +84,9 @@ Insert pointer into the array.
static
PARROT_INLINE
void *
-Parrot_pa_insert(PARROT_INTERP, ARGIN(Parrot_Pointer_Array *self), ARGIN(void *ptr))
+Parrot_pa_insert(ARGMOD(Parrot_Pointer_Array *self), ARGIN(void *ptr))
{
- Parrot_Pointer_Array_Chunk *chunk;
- void *ret;
+ void *ret;
/* Reuse removed cell */
if (self->next_free) {
@@ -98,27 +97,29 @@ Parrot_pa_insert(PARROT_INTERP, ARGIN(Parrot_Pointer_Array *self), ARGIN(void *p
ret = self->next_free;
*self->next_free = ptr;
self->next_free = next;
- return ret;
}
-
- /* If there is no free chunks */
- if (self->current_chunk >= self->total_chunks
- || !self->chunks[self->current_chunk]->num_free) {
- self->current_chunk = self->total_chunks++;
- mem_internal_realloc_n_typed(self->chunks,
- self->total_chunks,
- Parrot_Pointer_Array_Chunk*);
- self->chunks[self->current_chunk] = mem_internal_allocate_typed(Parrot_Pointer_Array_Chunk);
- self->chunks[self->current_chunk]->num_free = CELL_PER_CHUNK;
- self->chunks[self->current_chunk]->next_free = 0;
+ else {
+ Parrot_Pointer_Array_Chunk *chunk;
+
+ /* If there is no free chunks */
+ if (self->current_chunk >= self->total_chunks
+ || !self->chunks[self->current_chunk]->num_free) {
+ self->current_chunk = self->total_chunks++;
+ mem_internal_realloc_n_typed(self->chunks,
+ self->total_chunks,
+ Parrot_Pointer_Array_Chunk*);
+ self->chunks[self->current_chunk] = mem_internal_allocate_typed(Parrot_Pointer_Array_Chunk);
+ self->chunks[self->current_chunk]->num_free = CELL_PER_CHUNK;
+ self->chunks[self->current_chunk]->next_free = 0;
+ }
+
+ chunk = self->chunks[self->current_chunk];
+ --chunk->num_free;
+ /* Invariant: all chunks after chunk->next_free are free */
+ /* We handle previously freed chunks early */
+ ret = &chunk->data[chunk->next_free];
+ chunk->data[chunk->next_free++] = ptr;
}
-
- chunk = self->chunks[self->current_chunk];
- --chunk->num_free;
- /* Invariant: all chunks after chunk->next_free are free */
- /* We handle previously freed chunks early */
- ret = &chunk->data[chunk->next_free];
- chunk->data[chunk->next_free++] = ptr;
return ret;
}
View
18 src/gc/gc_gms.c
@@ -937,7 +937,7 @@ gc_gms_cleanup_dirty_list(PARROT_INTERP,
PObj_live_CLEAR(pmc);
PObj_GC_on_dirty_list_CLEAR(pmc);
Parrot_pa_remove(interp, dirty_list, item->ptr);
- item->ptr = Parrot_pa_insert(interp, self->objects[gen], item);
+ item->ptr = Parrot_pa_insert(self->objects[gen], item);
gc_gms_seal_object(interp, pmc);
}
else {
@@ -1028,7 +1028,7 @@ gc_gms_process_work_list(PARROT_INTERP,
PARROT_ASSERT(!PObj_GC_on_dirty_list_TEST(pmc));
Parrot_pa_remove(interp, work_list, item->ptr);
- item->ptr = Parrot_pa_insert(interp, self->objects[gen], item););
+ item->ptr = Parrot_pa_insert(self->objects[gen], item););
}
@@ -1071,12 +1071,12 @@ gc_gms_sweep_pools(PARROT_INTERP, ARGMOD(MarkSweep_GC *self))
Parrot_pa_remove(interp, self->objects[i], item->ptr);
/* If this was freshly allocated object in C stack - move it to dirty list */
if (PObj_GC_soil_root_TEST(pmc)) {
- item->ptr = Parrot_pa_insert(interp, self->dirty_list, item);
+ item->ptr = Parrot_pa_insert(self->dirty_list, item);
PObj_GC_soil_root_CLEAR(pmc);
PObj_GC_on_dirty_list_SET(pmc);
}
else {
- item->ptr = Parrot_pa_insert(interp, self->objects[i + 1], item);
+ item->ptr = Parrot_pa_insert(self->objects[i + 1], item);
gc_gms_seal_object(interp, pmc);
}
}
@@ -1111,7 +1111,7 @@ gc_gms_sweep_pools(PARROT_INTERP, ARGMOD(MarkSweep_GC *self))
PObj_live_CLEAR(str);
if (move_to_old) {
Parrot_pa_remove(interp, self->strings[i], item->ptr);
- item->ptr = Parrot_pa_insert(interp, self->strings[i + 1], item);
+ item->ptr = Parrot_pa_insert(self->strings[i + 1], item);
SET_GEN_FLAGS(str, i + 1);
}
}
@@ -1170,7 +1170,7 @@ gc_gms_mark_pmc_header(PARROT_INTERP, ARGMOD(PMC *pmc))
PObj_live_SET(pmc);
Parrot_pa_remove(interp, self->objects[gen], item->ptr);
- item->ptr = Parrot_pa_insert(interp, self->work_list, item);
+ item->ptr = Parrot_pa_insert(self->work_list, item);
}
/*
@@ -1417,7 +1417,7 @@ gc_gms_allocate_pmc_header(PARROT_INTERP, UINTVAL flags)
interp->gc_sys->stats.mem_used_last_collect += sizeof (PMC);
item = (pmc_alloc_struct *)Parrot_gc_pool_allocate(interp, pool);
- item->ptr = Parrot_pa_insert(interp, self->objects[0], item);
+ item->ptr = Parrot_pa_insert(self->objects[0], item);
return &(item->pmc);
}
@@ -1533,7 +1533,7 @@ gc_gms_allocate_string_header(PARROT_INTERP, SHIM(UINTVAL flags))
interp->gc_sys->stats.mem_used_last_collect += sizeof (STRING);
item = (string_alloc_struct *)Parrot_gc_pool_allocate(interp, pool);
- item->ptr = Parrot_pa_insert(interp, self->strings[0], item);
+ item->ptr = Parrot_pa_insert(self->strings[0], item);
ret = &(item->str);
memset(ret, 0, sizeof (STRING));
@@ -1939,7 +1939,7 @@ gc_gms_write_barrier(PARROT_INTERP, ARGMOD(PMC *pmc))
return;
Parrot_pa_remove(interp, self->objects[gen], item->ptr);
- item->ptr = Parrot_pa_insert(interp, self->dirty_list, item);
+ item->ptr = Parrot_pa_insert(self->dirty_list, item);
pmc->flags |= PObj_GC_on_dirty_list_FLAG;
View
6 src/gc/gc_ms2.c
@@ -706,7 +706,7 @@ gc_ms2_allocate_pmc_header(PARROT_INTERP, UINTVAL flags)
interp->gc_sys->stats.memory_used += sizeof (PMC);
ptr = (pmc_alloc_struct *)Parrot_gc_pool_allocate(interp, pool);
- ptr->ptr = Parrot_pa_insert(interp, self->objects, ptr);
+ ptr->ptr = Parrot_pa_insert(self->objects, ptr);
return &ptr->pmc;
}
@@ -760,7 +760,7 @@ gc_ms2_mark_pmc_header(PARROT_INTERP, ARGMOD(PMC *pmc))
if (!PObj_constant_TEST(pmc)) {
Parrot_pa_remove(interp, self->objects, item->ptr);
- item->ptr = Parrot_pa_insert(interp, self->new_objects, item);
+ item->ptr = Parrot_pa_insert(self->new_objects, item);
}
}
@@ -815,7 +815,7 @@ gc_ms2_allocate_string_header(PARROT_INTERP, UINTVAL flags)
interp->gc_sys->stats.memory_used += sizeof (STRING);
ptr = (string_alloc_struct *)Parrot_gc_pool_allocate(interp, pool);
- ptr->ptr = Parrot_pa_insert(interp, self->strings, ptr);
+ ptr->ptr = Parrot_pa_insert(self->strings, ptr);
ret = &ptr->str;
memset(ret, 0, sizeof (STRING));
View
28 t/src/pointer_array.t
@@ -1,5 +1,5 @@
#!perl
-# Copyright (C) 2006-2010, Parrot Foundation.
+# Copyright (C) 2006-2012, Parrot Foundation.
use strict;
use warnings;
@@ -54,7 +54,7 @@ int main(int argc, char* argv[])
printf("ok 1\n");
/* Push first pointer */
- pi = Parrot_pa_insert(interp, pa, &i);
+ pi = Parrot_pa_insert(pa, &i);
if (pa->total_chunks != 1) {
printf("Fail to allocate 1 chunk");
@@ -70,7 +70,7 @@ int main(int argc, char* argv[])
/* Insert many pointers */
for (count = CELL_PER_CHUNK * 2; count; count--) {
- pi = Parrot_pa_insert(interp, pa, &i);
+ pi = Parrot_pa_insert(pa, &i);
}
if (pa->total_chunks < 2) {
printf("Fail to allocate more chunks");
@@ -108,9 +108,9 @@ int main(int argc, char* argv[])
void *pi, *pj, *pk;
/* Push first pointer */
- pi = Parrot_pa_insert(interp, pa, &i);
- pj = Parrot_pa_insert(interp, pa, &j);
- pk = Parrot_pa_insert(interp, pa, &k);
+ pi = Parrot_pa_insert(pa, &i);
+ pj = Parrot_pa_insert(pa, &j);
+ pk = Parrot_pa_insert(pa, &k);
POINTER_ARRAY_ITER(pa,
if (ptr == &i)
@@ -120,7 +120,7 @@ int main(int argc, char* argv[])
else if (ptr == &k)
++count;
else {
- printf("Unkown poiner! %p - %p %p %p", ptr, pi, pj, pk);
+ printf("Unknown pointer! %p - %p %p %p", ptr, pi, pj, pk);
return EXIT_FAILURE;
}
);
@@ -140,7 +140,7 @@ int main(int argc, char* argv[])
else if (ptr == &k)
++count;
else {
- printf("Unkown poiner! %p - %p %p %p", ptr, pi, pj, pk);
+ printf("Unknown pointer! %p - %p %p %p", ptr, pi, pj, pk);
return EXIT_FAILURE;
}
);
@@ -156,7 +156,7 @@ int main(int argc, char* argv[])
if (ptr == &j)
++count;
else {
- printf("Unkown poiner! %p - %p %p %p", ptr, pi, pj, pk);
+ printf("Unknown pointer! %p - %p %p %p", ptr, pi, pj, pk);
return EXIT_FAILURE;
}
);
@@ -167,10 +167,10 @@ int main(int argc, char* argv[])
printf("ok 4\n");
/* Push stuff back. Twice. */
- pi = Parrot_pa_insert(interp, pa, &i);
- pi = Parrot_pa_insert(interp, pa, &i);
- pk = Parrot_pa_insert(interp, pa, &k);
- pk = Parrot_pa_insert(interp, pa, &k);
+ pi = Parrot_pa_insert(pa, &i);
+ pi = Parrot_pa_insert(pa, &i);
+ pk = Parrot_pa_insert(pa, &k);
+ pk = Parrot_pa_insert(pa, &k);
POINTER_ARRAY_ITER(pa,
if (ptr == &i)
++count;
@@ -179,7 +179,7 @@ int main(int argc, char* argv[])
else if (ptr == &k)
++count;
else {
- printf("Unkown poiner! %p - %p %p %p", ptr, pi, pj, pk);
+ printf("Unknown pointer! %p - %p %p %p", ptr, pi, pj, pk);
return EXIT_FAILURE;
}
);

0 comments on commit 3d3c833

Please sign in to comment.