aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2011-08-26 11:43:23 +0200
committerBjörn Gustavsson <[email protected]>2011-08-26 11:43:23 +0200
commitd2408a6285505641b42495bdd2284871fb9931dd (patch)
tree9b37d6743ec56c5cb287926b25c734760213961b /lib
parentbb92a8ee06841754910150d8ec05b2022a9fbe94 (diff)
parent67f89ecba0ef3a1f707c6c3b40d32605b7e2b352 (diff)
downloadotp-d2408a6285505641b42495bdd2284871fb9931dd.tar.gz
otp-d2408a6285505641b42495bdd2284871fb9931dd.tar.bz2
otp-d2408a6285505641b42495bdd2284871fb9931dd.zip
Merge branch 'dev' into major
* dev: code: Optimize purge/1 and soft_purge/1 using check_old_code/1 Add erlang:check_old_code/1 check_process_code/2: Quickly return 'false' if there is no old code
Diffstat (limited to 'lib')
-rw-r--r--lib/hipe/cerl/erl_bif_types.erl5
-rw-r--r--lib/kernel/src/code_server.erl17
2 files changed, 17 insertions, 5 deletions
diff --git a/lib/hipe/cerl/erl_bif_types.erl b/lib/hipe/cerl/erl_bif_types.erl
index 606fd307ea..43c2ac2615 100644
--- a/lib/hipe/cerl/erl_bif_types.erl
+++ b/lib/hipe/cerl/erl_bif_types.erl
@@ -672,6 +672,9 @@ type(erlang, call_on_load_function, 1, Xs) ->
type(erlang, cancel_timer, 1, Xs) ->
strict(arg_types(erlang, cancel_timer, 1), Xs,
fun (_) -> t_sup(t_integer(), t_atom('false')) end);
+type(erlang, check_old_code, 1, Xs) ->
+ strict(arg_types(erlang, check_old_code, 1), Xs,
+ fun (_) -> t_boolean() end);
type(erlang, check_process_code, 2, Xs) ->
strict(arg_types(erlang, check_process_code, 2), Xs,
fun (_) -> t_boolean() end);
@@ -3394,6 +3397,8 @@ arg_types(erlang, call_on_load_function, 1) ->
[t_atom()];
arg_types(erlang, cancel_timer, 1) ->
[t_reference()];
+arg_types(erlang, check_old_code, 1) ->
+ [t_atom()];
arg_types(erlang, check_process_code, 2) ->
[t_pid(), t_atom()];
arg_types(erlang, crc32, 1) ->
diff --git a/lib/kernel/src/code_server.erl b/lib/kernel/src/code_server.erl
index 4a1fc7df34..85bbff9cc3 100644
--- a/lib/kernel/src/code_server.erl
+++ b/lib/kernel/src/code_server.erl
@@ -1379,8 +1379,12 @@ absname_vr([[X, $:]|Name], _, _AbsBase) ->
%% Kill all processes running code from *old* Module, and then purge the
%% module. Return true if any processes killed, else false.
-do_purge(Mod) ->
- do_purge(processes(), to_atom(Mod), false).
+do_purge(Mod0) ->
+ Mod = to_atom(Mod0),
+ case erlang:check_old_code(Mod) of
+ false -> false;
+ true -> do_purge(processes(), Mod, false)
+ end.
do_purge([P|Ps], Mod, Purged) ->
case erlang:check_process_code(P, Mod) of
@@ -1399,16 +1403,19 @@ do_purge([], Mod, Purged) ->
Purged.
%% do_soft_purge(Module)
-%% Purge old code only if no procs remain that run old code
+%% Purge old code only if no procs remain that run old code.
%% Return true in that case, false if procs remain (in this
%% case old code is not purged)
do_soft_purge(Mod) ->
- catch do_soft_purge(processes(), Mod).
+ case erlang:check_old_code(Mod) of
+ false -> true;
+ true -> do_soft_purge(processes(), Mod)
+ end.
do_soft_purge([P|Ps], Mod) ->
case erlang:check_process_code(P, Mod) of
- true -> throw(false);
+ true -> false;
false -> do_soft_purge(Ps, Mod)
end;
do_soft_purge([], Mod) ->