aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/module.c
diff options
context:
space:
mode:
Diffstat (limited to 'erts/emulator/beam/module.c')
-rw-r--r--erts/emulator/beam/module.c69
1 files changed, 52 insertions, 17 deletions
diff --git a/erts/emulator/beam/module.c b/erts/emulator/beam/module.c
index d4f6e17c56..93ce8fcf9f 100644
--- a/erts/emulator/beam/module.c
+++ b/erts/emulator/beam/module.c
@@ -26,6 +26,7 @@
#include "erl_vm.h"
#include "global.h"
#include "module.h"
+#include "beam_catches.h"
#ifdef DEBUG
# define IF_DEBUG(x) x
@@ -67,6 +68,23 @@ static int module_cmp(Module* tmpl, Module* obj)
return tmpl->module != obj->module;
}
+void erts_module_instance_init(struct erl_module_instance* modi)
+{
+ modi->code_hdr = 0;
+ modi->code_length = 0;
+ modi->catches = BEAM_CATCHES_NIL;
+ modi->nif = NULL;
+ modi->num_breakpoints = 0;
+ modi->num_traced_exports = 0;
+#ifdef HIPE
+ modi->first_hipe_ref = NULL;
+ modi->first_hipe_sdesc = NULL;
+ modi->hipe_code_start = NULL;
+# ifdef DEBUG
+ modi->hipe_code_size = 0;
+# endif
+#endif
+}
static Module* module_alloc(Module* tmpl)
{
@@ -74,18 +92,16 @@ static Module* module_alloc(Module* tmpl)
erts_smp_atomic_add_nob(&tot_module_bytes, sizeof(Module));
obj->module = tmpl->module;
- obj->curr.code_hdr = 0;
- obj->old.code_hdr = 0;
- obj->curr.code_length = 0;
- obj->old.code_length = 0;
obj->slot.index = -1;
- obj->curr.nif = NULL;
- obj->old.nif = NULL;
- obj->curr.num_breakpoints = 0;
- obj->old.num_breakpoints = 0;
- obj->curr.num_traced_exports = 0;
- obj->old.num_traced_exports = 0;
+ erts_module_instance_init(&obj->curr);
+ erts_module_instance_init(&obj->old);
obj->on_load = 0;
+#ifdef HIPE
+ obj->first_hipe_mfa = NULL;
+ obj->new_hipe_refs = NULL;
+ obj->new_hipe_sdesc = NULL;
+#endif
+ DBG_TRACE_MFA(make_atom(obj->module), 0, 0, "module_alloc");
return obj;
}
@@ -139,19 +155,14 @@ erts_get_module(Eterm mod, ErtsCodeIndex code_ix)
}
}
-Module*
-erts_put_module(Eterm mod)
+
+static Module* put_module(Eterm mod, IndexTable* mod_tab)
{
Module e;
- IndexTable* mod_tab;
int oldsz, newsz;
Module* res;
ASSERT(is_atom(mod));
- ERTS_SMP_LC_ASSERT(erts_initialized == 0
- || erts_has_code_write_permission());
-
- mod_tab = &module_tables[erts_staging_code_ix()];
e.module = atom_val(mod);
oldsz = index_table_sz(mod_tab);
res = (Module*) index_put_entry(mod_tab, (void*) &e);
@@ -160,6 +171,24 @@ erts_put_module(Eterm mod)
return res;
}
+Module*
+erts_put_module(Eterm mod)
+{
+ ERTS_SMP_LC_ASSERT(erts_initialized == 0
+ || erts_has_code_write_permission());
+
+ return put_module(mod, &module_tables[erts_staging_code_ix()]);
+}
+
+Module*
+erts_put_active_module(Eterm mod)
+{
+ ASSERT(is_atom(mod));
+ //SVERK Why not? ERTS_SMP_LC_ASSERT(erts_smp_thr_progress_is_blocking());
+
+ return put_module(mod, &module_tables[erts_active_code_ix()]);
+}
+
Module *module_code(int i, ErtsCodeIndex code_ix)
{
return (Module*) erts_index_lookup(&module_tables[code_ix], i);
@@ -186,6 +215,11 @@ static ERTS_INLINE void copy_module(Module* dst_mod, Module* src_mod)
dst_mod->curr = src_mod->curr;
dst_mod->old = src_mod->old;
dst_mod->on_load = src_mod->on_load;
+#ifdef HIPE
+ dst_mod->first_hipe_mfa = src_mod->first_hipe_mfa;
+ dst_mod->new_hipe_refs = src_mod->new_hipe_refs;
+ dst_mod->new_hipe_sdesc = src_mod->new_hipe_sdesc;
+#endif
}
void module_start_staging(void)
@@ -217,6 +251,7 @@ void module_start_staging(void)
src_mod = (Module*) erts_index_lookup(src, i);
dst_mod = (Module*) index_put_entry(dst, src_mod);
ASSERT(dst_mod != src_mod);
+
copy_module(dst_mod, src_mod);
}
newsz = index_table_sz(dst);