From 7cb4725bcf18f3158e60750ea658e51ab4586e31 Mon Sep 17 00:00:00 2001 From: Sverker Eriksson Date: Tue, 31 Jan 2012 14:24:40 +0100 Subject: erts: Refactor code_ix Move implementation from beam_load into new file code_ix.c and module.c and make some function inline. --- erts/emulator/Makefile.in | 1 + erts/emulator/beam/beam_catches.h | 4 ++ erts/emulator/beam/beam_load.c | 119 -------------------------------------- erts/emulator/beam/code_ix.c | 110 +++++++++++++++++++++++++++++++++++ erts/emulator/beam/code_ix.h | 39 ++++++++++--- erts/emulator/beam/module.c | 7 +++ erts/emulator/beam/module.h | 41 ++++++++++++- 7 files changed, 192 insertions(+), 129 deletions(-) create mode 100644 erts/emulator/beam/code_ix.c (limited to 'erts') diff --git a/erts/emulator/Makefile.in b/erts/emulator/Makefile.in index dad09383cf..942cde3af4 100644 --- a/erts/emulator/Makefile.in +++ b/erts/emulator/Makefile.in @@ -705,6 +705,7 @@ EMU_OBJS = \ $(OBJDIR)/beam_load.o $(OBJDIR)/beam_bif_load.o \ $(OBJDIR)/beam_debug.o $(OBJDIR)/beam_bp.o \ $(OBJDIR)/beam_catches.o \ + $(OBJDIR)/code_ix.o \ $(OBJDIR)/beam_ranges.o RUN_OBJS = \ diff --git a/erts/emulator/beam/beam_catches.h b/erts/emulator/beam/beam_catches.h index 4a0e070c69..b2bd2351a5 100644 --- a/erts/emulator/beam/beam_catches.h +++ b/erts/emulator/beam/beam_catches.h @@ -20,6 +20,10 @@ #ifndef __BEAM_CATCHES_H #define __BEAM_CATCHES_H +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif +#include "sys.h" #include "code_ix.h" #define BEAM_CATCHES_NIL (-1) diff --git a/erts/emulator/beam/beam_load.c b/erts/emulator/beam/beam_load.c index e966f423ec..7ac2b9f77e 100644 --- a/erts/emulator/beam/beam_load.c +++ b/erts/emulator/beam/beam_load.c @@ -5940,122 +5940,3 @@ static int safe_mul(UWord a, UWord b, UWord* resp) } } - -/*SVERK Do these deserve a file of their own maybe? */ - -static erts_smp_atomic32_t the_active_code_index; -static erts_smp_atomic32_t the_loader_code_index; - -static erts_smp_mtx_t sverk_code_ix_lock; /*SVERK FIXME */ -static erts_smp_rwmtx_t the_old_code_rwlocks[ERTS_NUM_CODE_IX]; - -#if 0 -# define CIX_TRACE(text) erts_fprintf(stderr, "CIX_TRACE: " text " act=%u load=%u\r\n", erts_active_code_ix(), erts_staging_code_ix()) -#else -# define CIX_TRACE(text) -#endif - -void erts_code_ix_init(void) -{ - int i; - - erts_smp_atomic32_init_nob(&the_active_code_index, 0); - erts_smp_atomic32_init_nob(&the_loader_code_index, 0); - erts_smp_mtx_init_x(&sverk_code_ix_lock, "sverk_code_ix_lock", NIL); /*SVERK FIXME */ - for (i=0; i