aboutsummaryrefslogtreecommitdiffstats
path: root/erts/preloaded
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2016-01-12 16:57:59 +0100
committerSverker Eriksson <[email protected]>2016-01-13 19:59:54 +0100
commit4c763443365591e170308a1c5f11a4586734ca4e (patch)
tree2cb663b23541827d3eebf19a582686de6c535cf9 /erts/preloaded
parenta4920dc4045f394f6f4ab1cc89d54d55722a66d6 (diff)
downloadotp-4c763443365591e170308a1c5f11a4586734ca4e.tar.gz
otp-4c763443365591e170308a1c5f11a4586734ca4e.tar.bz2
otp-4c763443365591e170308a1c5f11a4586734ca4e.zip
erts: Optimize erlang:check_process_code
by ignoring literals. erts_internal:check_process_code will be called again anyway (with option {copy_literals, true}) before the module is actually purged. No need to check literals twice.
Diffstat (limited to 'erts/preloaded')
-rw-r--r--erts/preloaded/ebin/erts_code_purger.beambin8832 -> 8884 bytes
-rw-r--r--erts/preloaded/ebin/erts_internal.beambin8168 -> 8536 bytes
-rw-r--r--erts/preloaded/src/erts_code_purger.erl5
-rw-r--r--erts/preloaded/src/erts_internal.erl42
4 files changed, 28 insertions, 19 deletions
diff --git a/erts/preloaded/ebin/erts_code_purger.beam b/erts/preloaded/ebin/erts_code_purger.beam
index c5aec6bb25..ca6c8570ed 100644
--- a/erts/preloaded/ebin/erts_code_purger.beam
+++ b/erts/preloaded/ebin/erts_code_purger.beam
Binary files differ
diff --git a/erts/preloaded/ebin/erts_internal.beam b/erts/preloaded/ebin/erts_internal.beam
index 4c66171965..d3d990519d 100644
--- a/erts/preloaded/ebin/erts_internal.beam
+++ b/erts/preloaded/ebin/erts_internal.beam
Binary files differ
diff --git a/erts/preloaded/src/erts_code_purger.erl b/erts/preloaded/src/erts_code_purger.erl
index 791ef72f13..e492ba1812 100644
--- a/erts/preloaded/src/erts_code_purger.erl
+++ b/erts/preloaded/src/erts_code_purger.erl
@@ -283,8 +283,9 @@ cpc_sched_kill(Pid,
killed = true}.
cpc_request(#cpc_static{tag = Tag, module = Mod}, Pid, AllowGc) ->
- erlang:check_process_code(Pid, Mod, [{async, {Tag, Pid, AllowGc}},
- {allow_gc, AllowGc}]).
+ erts_internal:check_process_code(Pid, Mod, [{async, {Tag, Pid, AllowGc}},
+ {allow_gc, AllowGc},
+ {copy_literals, true}]).
cpc_request_gc(CpcS, [Pid|Pids]) ->
cpc_request(CpcS, Pid, true),
diff --git a/erts/preloaded/src/erts_internal.erl b/erts/preloaded/src/erts_internal.erl
index e32d65ff59..84dedab930 100644
--- a/erts/preloaded/src/erts_internal.erl
+++ b/erts/preloaded/src/erts_internal.erl
@@ -202,22 +202,24 @@ port_info(_Result, _Item) ->
request_system_task(_Pid, _Prio, _Request) ->
erlang:nif_error(undefined).
--spec check_process_code(Module, OptionList) -> boolean() when
+-define(ERTS_CPC_ALLOW_GC, (1 bsl 0)).
+-define(ERTS_CPC_COPY_LITERALS, (1 bsl 1)).
+
+-spec check_process_code(Module, Flags) -> boolean() when
Module :: module(),
- Option :: {allow_gc, boolean()},
- OptionList :: [Option].
-check_process_code(_Module, _OptionList) ->
+ Flags :: non_neg_integer().
+check_process_code(_Module, _Flags) ->
erlang:nif_error(undefined).
-spec check_process_code(Pid, Module, OptionList) -> CheckResult | async when
Pid :: pid(),
Module :: module(),
RequestId :: term(),
- Option :: {async, RequestId} | {allow_gc, boolean()},
+ Option :: {async, RequestId} | {allow_gc, boolean()} | {copy_literals, boolean()},
OptionList :: [Option],
CheckResult :: boolean() | aborted.
check_process_code(Pid, Module, OptionList) ->
- {Async, AllowGC} = get_cpc_opts(OptionList, sync, true),
+ {Async, Flags} = get_cpc_opts(OptionList, sync, ?ERTS_CPC_ALLOW_GC),
case Async of
{async, ReqId} ->
{priority, Prio} = erlang:process_info(erlang:self(),
@@ -227,13 +229,12 @@ check_process_code(Pid, Module, OptionList) ->
{check_process_code,
ReqId,
Module,
- AllowGC}),
+ Flags}),
async;
sync ->
case Pid == erlang:self() of
true ->
- erts_internal:check_process_code(Module,
- [{allow_gc, AllowGC}]);
+ erts_internal:check_process_code(Module, Flags);
false ->
{priority, Prio} = erlang:process_info(erlang:self(),
priority),
@@ -243,7 +244,7 @@ check_process_code(Pid, Module, OptionList) ->
{check_process_code,
ReqId,
Module,
- AllowGC}),
+ Flags}),
receive
{check_process_code, ReqId, CheckResult} ->
CheckResult
@@ -251,13 +252,20 @@ check_process_code(Pid, Module, OptionList) ->
end
end.
-% gets async and allow_gc opts and verify valid option list
-get_cpc_opts([{async, _ReqId} = AsyncTuple | Options], _OldAsync, AllowGC) ->
- get_cpc_opts(Options, AsyncTuple, AllowGC);
-get_cpc_opts([{allow_gc, AllowGC} | Options], Async, _OldAllowGC) ->
- get_cpc_opts(Options, Async, AllowGC);
-get_cpc_opts([], Async, AllowGC) ->
- {Async, AllowGC}.
+% gets async and flag opts and verify valid option list
+get_cpc_opts([{async, _ReqId} = AsyncTuple | Options], _OldAsync, Flags) ->
+ get_cpc_opts(Options, AsyncTuple, Flags);
+get_cpc_opts([{allow_gc, AllowGC} | Options], Async, Flags) ->
+ get_cpc_opts(Options, Async, cpc_flags(Flags, ?ERTS_CPC_ALLOW_GC, AllowGC));
+get_cpc_opts([{copy_literals, CopyLit} | Options], Async, Flags) ->
+ get_cpc_opts(Options, Async, cpc_flags(Flags, ?ERTS_CPC_COPY_LITERALS, CopyLit));
+get_cpc_opts([], Async, Flags) ->
+ {Async, Flags}.
+
+cpc_flags(OldFlags, Bit, true) ->
+ OldFlags bor Bit;
+cpc_flags(OldFlags, Bit, false) ->
+ OldFlags band (bnot Bit).
-spec copy_literals(Module,Bool) -> 'true' | 'false' | 'aborted' when
Module :: module(),