From b45686b4bc9b8bf07190d6b13b2e9a8167c61184 Mon Sep 17 00:00:00 2001 From: Sverker Eriksson Date: Thu, 19 Jan 2012 14:53:26 +0100 Subject: erts: Add abort logic to export tables --- erts/emulator/beam/export.c | 15 ++++++++++----- erts/emulator/beam/index.h | 2 ++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/erts/emulator/beam/export.c b/erts/emulator/beam/export.c index e5d9da187a..c74a40b0db 100644 --- a/erts/emulator/beam/export.c +++ b/erts/emulator/beam/export.c @@ -141,13 +141,11 @@ export_alloc(struct export_entry* tmpl_e) return &blob->entryv[blob->top_ix]; } -/*SVERK static void export_free(struct export_entry* obj) { erts_free(ERTS_ALC_T_EXPORT, (void*) obj); } -*/ void init_export_table(void) @@ -163,7 +161,7 @@ init_export_table(void) f.hash = (H_FUN) export_hash; f.cmp = (HCMP_FUN) export_cmp; f.alloc = (HALLOC_FUN) export_alloc; - f.free = (HFREE_FUN) NULL; /*SVERK export_free;*/ + f.free = (HFREE_FUN) export_free; for (i=0; ihtable.fun.alloc = (HALLOC_FUN) &export_alloc; /* restore */ - /*SVERK Remember dst->entries in order to purge on abort */ + entries_at_start_load = dst->entries; IF_DEBUG(debug_start_load_ix = dst_ix); } @@ -449,7 +449,12 @@ void export_end_load(int commit) { ASSERT(debug_start_load_ix == erts_loader_code_ix()); - /*SVERK Purge if abort */ + if (!commit) { /* abort */ + IndexTable* tab = &export_tables[erts_loader_code_ix()]; + + ASSERT(entries_at_start_load <= tab->entries); + index_erase_latest_from(tab, entries_at_start_load); + } IF_DEBUG(debug_start_load_ix = -1); } diff --git a/erts/emulator/beam/index.h b/erts/emulator/beam/index.h index 67b250590b..69d1cc0a22 100644 --- a/erts/emulator/beam/index.h +++ b/erts/emulator/beam/index.h @@ -58,6 +58,8 @@ int index_get(IndexTable*, void*); int index_put(IndexTable*, void*); void erts_index_merge(Hash*, IndexTable*); +/* Erase all entries with index 'ix' and higher +*/ void index_erase_latest_from(IndexTable*, Uint ix); ERTS_GLB_INLINE IndexSlot* erts_index_lookup(IndexTable*, Uint); -- cgit v1.2.3