aboutsummaryrefslogtreecommitdiffstats
path: root/erts
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2016-10-02 16:17:21 +0200
committerSverker Eriksson <[email protected]>2016-10-14 14:29:16 +0200
commit1e8588e8c310a628fb0215ef15dc3cc29f98c336 (patch)
tree43bc0fb812e0cd5a4c3ea2f8927ac22d97e4b0d3 /erts
parent6ce2fbadd41b657820276856299911470fb0a706 (diff)
downloadotp-1e8588e8c310a628fb0215ef15dc3cc29f98c336.tar.gz
otp-1e8588e8c310a628fb0215ef15dc3cc29f98c336.tar.bz2
otp-1e8588e8c310a628fb0215ef15dc3cc29f98c336.zip
erts: Refactor hipe_loader_state_dtor into a true destructor
that is only called once. Basically switch hipe_free_loader_state and hipe_loader_state_dtor.
Diffstat (limited to 'erts')
-rw-r--r--erts/emulator/beam/beam_load.c2
-rw-r--r--erts/emulator/hipe/hipe_load.c26
-rw-r--r--erts/emulator/hipe/hipe_load.h2
3 files changed, 13 insertions, 17 deletions
diff --git a/erts/emulator/beam/beam_load.c b/erts/emulator/beam/beam_load.c
index 4a833689e3..813788f66c 100644
--- a/erts/emulator/beam/beam_load.c
+++ b/erts/emulator/beam/beam_load.c
@@ -6528,7 +6528,7 @@ erts_make_stub_module(Process* p, Eterm hipe_magic_bin, Eterm Beam, Eterm Info)
erts_free_aligned_binary_bytes(temp_alloc);
free_loader_state(magic);
- hipe_free_loader_state(hipe_magic);
+ hipe_free_loader_state(hipe_stp);
return mod;
}
diff --git a/erts/emulator/hipe/hipe_load.c b/erts/emulator/hipe/hipe_load.c
index 48f0cab293..6261857d8f 100644
--- a/erts/emulator/hipe/hipe_load.c
+++ b/erts/emulator/hipe/hipe_load.c
@@ -32,13 +32,8 @@
#include "erl_binary.h"
#include "hipe_load.h"
-/*
- * This destructor function can safely be called multiple times.
- */
-static void
-hipe_loader_state_dtor(Binary* magic)
+void hipe_free_loader_state(HipeLoaderState *stp)
{
- HipeLoaderState* stp = ERTS_MAGIC_BIN_DATA(magic);
if (stp->module == NIL) return;
erts_fprintf(stderr, "Destroying HiPE loader state for module %T\n",
@@ -64,6 +59,16 @@ hipe_loader_state_dtor(Binary* magic)
*/
}
+static void
+hipe_loader_state_dtor(Binary* magic)
+{
+ HipeLoaderState* stp = ERTS_MAGIC_BIN_DATA(magic);
+
+ ASSERT(ERTS_MAGIC_BIN_DESTRUCTOR(magic) == hipe_loader_state_dtor);
+
+ hipe_free_loader_state(stp);
+}
+
Binary *hipe_alloc_loader_state(Eterm module)
{
HipeLoaderState *stp;
@@ -90,15 +95,6 @@ Binary *hipe_alloc_loader_state(Eterm module)
return magic;
}
-void hipe_free_loader_state(Binary *magic)
-{
- if (ERTS_MAGIC_BIN_DESTRUCTOR(magic) != hipe_loader_state_dtor)
- return;
-
- /* Why does BEAM do a refc_dec here? What is holding that reference? */
- hipe_loader_state_dtor(magic);
-}
-
HipeLoaderState *
hipe_get_loader_state(Binary *magic)
{
diff --git a/erts/emulator/hipe/hipe_load.h b/erts/emulator/hipe/hipe_load.h
index 17dd3c3c05..40c8a8aa2a 100644
--- a/erts/emulator/hipe/hipe_load.h
+++ b/erts/emulator/hipe/hipe_load.h
@@ -42,7 +42,7 @@ typedef struct hipe_loader_state {
} HipeLoaderState;
extern Binary *hipe_alloc_loader_state(Eterm module);
-extern void hipe_free_loader_state(Binary *binary);
+extern void hipe_free_loader_state(HipeLoaderState*);
extern HipeLoaderState *hipe_get_loader_state(Binary *binary);
#endif /* HIPE_LOAD_H */