Update of /cvsroot/monetdb/pathfinder/compiler
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv24398
Modified Files:
compile.c env.c qname.c scope.c
Log Message:
-- Extended the PFarray_t type to store a ``clear'' bit
that ensures that memory is erased during allocation.
-- Split up PFarray (size_t itemsize) into four variants
o PFarray_default (size_t itemsize),
o PFcarray_default (size_t itemsize),
o PFarray (size_t itemsize, unsigned int slots), and
o PFcarray (size_t itemsize, unsigned int slots)
where the '_default' variants are currently seeded with 20 slots,
the 'c' variants provide a cleared chunk of memory, and the slots
argument indicates how much memory is initially allocated (#slots).
-- Added memory debugging support for arrays:
If the environment variable ``PF_DEBUG_MEMORY'' is set the memory
reallocation for arrays reports the function that requires more
memory (and thus more slots for the storage).
REMARK: Currently the inital array sizes (#slots) are good guesses
about the upper limit of required slots. Anybody adding new
PFarray calls may start with a very low value. This way the
the debug printing may report (reallocation) problems in
comparison to a very high initial value whose consequences
might not be directly visible.
Index: scope.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/scope.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- scope.c 11 Jan 2008 10:46:56 -0000 1.14
+++ scope.c 17 Mar 2008 17:41:05 -0000 1.15
@@ -83,10 +83,10 @@
/* set up the entry hash table and its buckets */
for (i = 0; i < SCOPE_HASH_SZ; i++)
- s->hash[i] = PFarray (sizeof (entry_t));
+ s->hash[i] = PFarray (sizeof (entry_t), 20);
/* set up undo stack to maintain nested scopes */
- s->undo = PFarray (sizeof (int));
+ s->undo = PFarray (sizeof (int), 20);
return s;
}
Index: compile.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/compile.c,v
retrieving revision 1.142
retrieving revision 1.143
diff -u -d -r1.142 -r1.143
--- compile.c 27 Feb 2008 08:29:51 -0000 1.142
+++ compile.c 17 Mar 2008 17:41:05 -0000 1.143
@@ -327,6 +327,11 @@
/* setup sementation fault signal handler */
signal (SIGSEGV, segfault_handler);
#endif
+
+#ifndef NDEBUG
+ PFarray_init ();
+#endif
+
/*******************************************/
/* Split Point: Logical Algebra XML Import */
/*******************************************/
@@ -464,7 +469,7 @@
STOP_POINT(5);
/* create guide tree */
- guide_tree = PFguide_tree();
+ guide_tree = PFguide_tree ();
STOP_POINT(6);
@@ -869,6 +874,9 @@
PFmem_init ();
+#ifndef NDEBUG
+ PFarray_init ();
+#endif
/** initialize global state of the compiler */
PFstate_init (&PFstate);
Index: env.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/env.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- env.c 11 Jan 2008 10:46:56 -0000 1.14
+++ env.c 17 Mar 2008 17:41:05 -0000 1.15
@@ -78,9 +78,13 @@
* @return pointer to environment
*/
PFenv_t *
-PFenv (void)
+PFenv_ (unsigned int initial_slots)
{
- return (PFenv_t *) PFarray (sizeof (binding_t));
+ /*
+ * We rely on array cells automatically being initialized
+ * with NULL (PFcarray).
+ */
+ return (PFenv_t *) PFcarray (sizeof (binding_t), initial_slots);
}
/**
@@ -94,15 +98,6 @@
PFarray_t *
PFenv_lookup (PFenv_t *e, PFqname_t key)
{
- /*
- * The PFarray_... functions do not automatically adjust the
- * last information, except for the PFarray_add() and PFarray_del()
- * functions. We rely on array cells automatically being initialized
- * with NULL and, hence, take care of this initialization here.
- */
- while (PFarray_last (e) <= key)
- *((PFarray_t **) PFarray_add (e)) = NULL;
-
return *((PFarray_t **) PFarray_at (e, key));
}
@@ -121,19 +116,11 @@
assert (e);
- /*
- * The PFarray_... functions do not automatically adjust the
- * last information, except for the PFarray_add() and PFarray_del()
- * functions. We rely on array cells automatically being initialized
- * with NULL and, hence, take care of this here.
- */
- while (PFarray_last (e) <= key)
- *((PFarray_t **) PFarray_add (e)) = NULL;
-
a = *((PFarray_t **) PFarray_at (e, key));
if (! a)
- *((PFarray_t **) PFarray_at (e, key)) = PFarray (sizeof (void *));
+ *((PFarray_t **) PFarray_at (e, key))
+ = PFarray_default (sizeof (void *));
*((void **) PFarray_add (*((PFarray_t **) PFarray_at (e, key)))) = value;
Index: qname.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/qname.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- qname.c 11 Jan 2008 10:46:56 -0000 1.17
+++ qname.c 17 Mar 2008 17:41:05 -0000 1.18
@@ -211,12 +211,12 @@
void
PFqname_init (void)
{
- qnames = PFarray (sizeof (qname_internal_t));
- qname_hash = PFarray (sizeof (PFarray_t *));
+ qnames = PFarray (sizeof (qname_internal_t), 400);
+ qname_hash = PFarray (sizeof (PFarray_t *), HASH_BUCKETS);
for (unsigned int i = 0; i < HASH_BUCKETS; i++)
*((PFarray_t **) PFarray_at (qname_hash, i))
- = PFarray (sizeof (qname_hash_entry_t));
+ = PFarray (sizeof (qname_hash_entry_t), 50);
}
/**
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Monetdb-pf-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-pf-checkins