aboutsummaryrefslogtreecommitdiffstats
path: root/erts
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2011-08-10 11:31:42 +0200
committerBjörn Gustavsson <[email protected]>2011-08-25 08:46:38 +0200
commit1c40ae26dfb9b5578e7d307f901d4178d6244849 (patch)
tree4128051e4c3dd20cf1db63f81234ed5d21782107 /erts
parentd48eaa0731017e5cdadca0af77ac14cd949b6c67 (diff)
downloadotp-1c40ae26dfb9b5578e7d307f901d4178d6244849.tar.gz
otp-1c40ae26dfb9b5578e7d307f901d4178d6244849.tar.bz2
otp-1c40ae26dfb9b5578e7d307f901d4178d6244849.zip
check_process_code/2: Quickly return 'false' if there is no old code
There is no need to suspend the process if the module has no old code. Measurements show that this change will make erlang:check_process_code/2 in an SMP emulator about four times faster if the module has no old code.
Diffstat (limited to 'erts')
-rw-r--r--erts/emulator/beam/beam_bif_load.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/erts/emulator/beam/beam_bif_load.c b/erts/emulator/beam/beam_bif_load.c
index d76a7d8e9f..7b5781beeb 100644
--- a/erts/emulator/beam/beam_bif_load.c
+++ b/erts/emulator/beam/beam_bif_load.c
@@ -175,6 +175,13 @@ check_process_code_2(BIF_ALIST_2)
Eterm res;
if (internal_pid_index(BIF_ARG_1) >= erts_max_processes)
goto error;
+ modp = erts_get_module(BIF_ARG_2);
+ if (modp == NULL) { /* Doesn't exist. */
+ return am_false;
+ } else if (modp->old_code == NULL) { /* No old code. */
+ return am_false;
+ }
+
#ifdef ERTS_SMP
rp = erts_pid2proc_suspend(BIF_P, ERTS_PROC_LOCK_MAIN,
BIF_ARG_1, ERTS_PROC_LOCK_MAIN);
@@ -188,7 +195,6 @@ check_process_code_2(BIF_ALIST_2)
ERTS_BIF_YIELD2(bif_export[BIF_check_process_code_2], BIF_P,
BIF_ARG_1, BIF_ARG_2);
}
- modp = erts_get_module(BIF_ARG_2);
res = check_process_code(rp, modp);
#ifdef ERTS_SMP
if (BIF_P != rp) {
@@ -412,11 +418,6 @@ check_process_code(Process* rp, Module* modp)
#endif
#define INSIDE(a) (start <= (a) && (a) < end)
- if (modp == NULL) { /* Doesn't exist. */
- return am_false;
- } else if (modp->old_code == NULL) { /* No old code. */
- return am_false;
- }
/*
* Pick up limits for the module.