aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/beam_load.c
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2012-01-12 20:12:59 +0100
committerSverker Eriksson <[email protected]>2012-02-21 12:23:08 +0100
commit64bcf5db63d73fe09298dac8cf5f6cad33fe7253 (patch)
tree8a9ec2d51b32bb2da2b97de4077e0dc6d956cd25 /erts/emulator/beam/beam_load.c
parent5d4759518008a3bdd9c7e9d2adde94a4bd01169e (diff)
downloadotp-64bcf5db63d73fe09298dac8cf5f6cad33fe7253.tar.gz
otp-64bcf5db63d73fe09298dac8cf5f6cad33fe7253.tar.bz2
otp-64bcf5db63d73fe09298dac8cf5f6cad33fe7253.zip
Break apart erlang:load_module/2 into two separate BIFs
Introduce two new BIFs, erlang:prepare_loading/2 and erlang:finish_loading/1, and re-implement erlang:load_module/2 in Erlang code. We have two reasons for doing this: * To facilitate suspending a process if another process is already doing code loading. * In the future, we can implement parallel and atomic loading of several modules. Atomic loading works except for modules with on_load handlers. Because of that issue, erlang:finish_loading/2 will currently only accept a list with a single magic binary.
Diffstat (limited to 'erts/emulator/beam/beam_load.c')
-rw-r--r--erts/emulator/beam/beam_load.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/erts/emulator/beam/beam_load.c b/erts/emulator/beam/beam_load.c
index a9246a84c1..cc4f5b5893 100644
--- a/erts/emulator/beam/beam_load.c
+++ b/erts/emulator/beam/beam_load.c
@@ -847,6 +847,27 @@ erts_alloc_loader_state(void)
return magic;
}
+/*
+ * Return the module name (a tagged atom) for the prepared code
+ * in the magic binary, or NIL if the binary does not contain
+ * prepared code.
+ */
+int
+erts_module_for_prepared_code(Binary* magic)
+{
+ LoaderState* stp;
+
+ if (ERTS_MAGIC_BIN_DESTRUCTOR(magic) != loader_state_dtor) {
+ return NIL;
+ }
+ stp = ERTS_MAGIC_BIN_DATA(magic);
+ if (stp->code != 0) {
+ return stp->module;
+ } else {
+ return NIL;
+ }
+}
+
static void
free_loader_state(Binary* magic)
{