More efficient allocate of ivl_nexus_t objects.
This commit is contained in:
parent
9e21880cdc
commit
8856c07d88
32
t-dll.cc
32
t-dll.cc
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#ifdef HAVE_CVS_IDENT
|
||||
#ident "$Id: t-dll.cc,v 1.168 2007/03/26 18:17:51 steve Exp $"
|
||||
#ident "$Id: t-dll.cc,v 1.169 2007/03/26 20:32:47 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "config.h"
|
||||
|
|
@ -102,6 +102,31 @@ inline const char*dlerror(void)
|
|||
{ return strerror( errno ); }
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The custom new operator for the ivl_nexus_s type allows us to
|
||||
* allocate nexus objects in blocks. There are generally lots of them
|
||||
* permanently allocated, and allocating them in blocks reduces the
|
||||
* allocation overhead.
|
||||
*/
|
||||
static struct ivl_nexus_s * nexus_pool_ptr = 0;
|
||||
static int nexus_pool_remaining = 0;
|
||||
static const size_t NEXUS_POOL_SIZE = 4096;
|
||||
|
||||
void* ivl_nexus_s::operator new(size_t s)
|
||||
{
|
||||
assert(s == sizeof(struct ivl_nexus_s));
|
||||
if (nexus_pool_remaining <= 0) {
|
||||
nexus_pool_ptr = new struct ivl_nexus_s[NEXUS_POOL_SIZE];
|
||||
nexus_pool_remaining = NEXUS_POOL_SIZE;
|
||||
}
|
||||
|
||||
struct ivl_nexus_s*tmp = nexus_pool_ptr;
|
||||
nexus_pool_ptr += 1;
|
||||
nexus_pool_remaining -= 1;
|
||||
|
||||
return tmp;
|
||||
}
|
||||
|
||||
inline static const char *basename(ivl_scope_t scope, const char *inst)
|
||||
{
|
||||
inst += strlen(ivl_scope_name(scope));
|
||||
|
|
@ -231,7 +256,7 @@ ivl_signal_t dll_target::find_signal(ivl_design_s &des, const NetNet*net)
|
|||
ivl_scope_t scope = find_scope(des, net->scope());
|
||||
assert(scope);
|
||||
|
||||
const char*nname = net->name();
|
||||
perm_string nname = net->name();
|
||||
|
||||
for (unsigned idx = 0 ; idx < scope->nsigs_ ; idx += 1) {
|
||||
if (strcmp(scope->sigs_[idx]->name_, nname) == 0)
|
||||
|
|
@ -2200,6 +2225,9 @@ extern const struct target tgt_dll = { "dll", &dll_target_obj };
|
|||
|
||||
/*
|
||||
* $Log: t-dll.cc,v $
|
||||
* Revision 1.169 2007/03/26 20:32:47 steve
|
||||
* More efficient allocate of ivl_nexus_t objects.
|
||||
*
|
||||
* Revision 1.168 2007/03/26 18:17:51 steve
|
||||
* Remove pretense of general use for t_cookie.
|
||||
*
|
||||
|
|
|
|||
11
t-dll.h
11
t-dll.h
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#ifdef HAVE_CVS_IDENT
|
||||
#ident "$Id: t-dll.h,v 1.140 2007/03/26 16:51:49 steve Exp $"
|
||||
#ident "$Id: t-dll.h,v 1.141 2007/03/26 20:32:47 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "target.h"
|
||||
|
|
@ -477,12 +477,18 @@ struct ivl_nexus_ptr_s {
|
|||
# define __NEXUS_PTR_CON 2
|
||||
# define __NEXUS_PTR_LPM 3
|
||||
|
||||
/*
|
||||
* NOTE: ONLY allocat ivl_nexus_s objects with the included "new" operator.
|
||||
*/
|
||||
struct ivl_nexus_s {
|
||||
unsigned nptr_;
|
||||
struct ivl_nexus_ptr_s*ptrs_;
|
||||
const Nexus*nexus_;
|
||||
const char*name_;
|
||||
void*private_data;
|
||||
|
||||
void* operator new (size_t s);
|
||||
void operator delete(void*obj, size_t s); // Not implemented
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
@ -670,6 +676,9 @@ struct ivl_statement_s {
|
|||
|
||||
/*
|
||||
* $Log: t-dll.h,v $
|
||||
* Revision 1.141 2007/03/26 20:32:47 steve
|
||||
* More efficient allocate of ivl_nexus_t objects.
|
||||
*
|
||||
* Revision 1.140 2007/03/26 16:51:49 steve
|
||||
* do not calculate nexus name unless needed.
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue