From fa5213fd7590c6a9ade13af1375c363b958927f1 Mon Sep 17 00:00:00 2001 From: Sverker Eriksson Date: Tue, 7 Feb 2012 19:43:31 +0100 Subject: erts: Cleanup non-blocking load --- erts/emulator/beam/beam_catches.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) (limited to 'erts/emulator/beam/beam_catches.c') diff --git a/erts/emulator/beam/beam_catches.c b/erts/emulator/beam/beam_catches.c index 548c10fa94..92f7ffe5a2 100644 --- a/erts/emulator/beam/beam_catches.c +++ b/erts/emulator/beam/beam_catches.c @@ -37,16 +37,21 @@ typedef struct { # define IF_DEBUG(x) #endif -struct bc_code_ix { /*SVERK A better name maybe... */ +struct bc_pool { int free_list; unsigned high_mark; unsigned tabsize; beam_catch_t *beam_catches; + /* + * Note that the 'beam_catches' area is shared by pools. Used slots + * are readonly as long as the module is not purgable. The free-list is + * protected by the code_ix lock. + */ - IF_DEBUG(int is_prepared;) + IF_DEBUG(int is_staging;) }; -static struct bc_code_ix bccix[ERTS_NUM_CODE_IX]; +static struct bc_pool bccix[ERTS_NUM_CODE_IX]; void beam_catches_init(void) { @@ -57,12 +62,12 @@ void beam_catches_init(void) bccix[0].high_mark = 0; bccix[0].beam_catches = erts_alloc(ERTS_ALC_T_CODE, sizeof(beam_catch_t)*DEFAULT_TABSIZE); - IF_DEBUG(bccix[0].is_prepared = 0); + IF_DEBUG(bccix[0].is_staging = 0); for (i=1; iis_prepared); + ASSERT(p->is_staging); /* * Allocate from free_list while it is non-empty. * If free_list is empty, allocate at high_mark. - * - * This avoids the need to initialise the free list in - * beam_catches_init(), which would cost O(TABSIZ) time. */ if (p->free_list >= 0) { i = p->free_list; @@ -137,7 +139,7 @@ unsigned beam_catches_cons(BeamInstr *cp, unsigned cdr) BeamInstr *beam_catches_car(unsigned i) { - struct bc_code_ix* p = &bccix[erts_active_code_ix()]; + struct bc_pool* p = &bccix[erts_active_code_ix()]; if (i >= p->tabsize ) { erl_exit(1, "beam_catches_delmod: index %#x is out of range\r\n", i); @@ -148,10 +150,10 @@ BeamInstr *beam_catches_car(unsigned i) void beam_catches_delmod(unsigned head, BeamInstr *code, unsigned code_bytes, ErtsCodeIndex code_ix) { - struct bc_code_ix* p = &bccix[code_ix]; + struct bc_pool* p = &bccix[code_ix]; unsigned i, cdr; - ASSERT((code_ix == erts_active_code_ix()) != bccix[erts_staging_code_ix()].is_prepared); + ASSERT((code_ix == erts_active_code_ix()) != bccix[erts_staging_code_ix()].is_staging); for(i = head; i != (unsigned)-1;) { if (i >= p->tabsize) { erl_exit(1, "beam_catches_delmod: index %#x is out of range\r\n", i); -- cgit v1.2.3