aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel/src
diff options
context:
space:
mode:
authorKostis Sagonas <[email protected]>2016-10-18 13:08:38 +0200
committerKostis Sagonas <[email protected]>2016-10-18 13:08:38 +0200
commit0c7e4330ddced978934dd63520795554b29244a2 (patch)
treed3f874a3abd48a81fe1aa31d2fc142ab25d5d6fa /lib/kernel/src
parent0c480fab8830febf8911d2eb6618a144dc90b8cc (diff)
downloadotp-0c7e4330ddced978934dd63520795554b29244a2.tar.gz
otp-0c7e4330ddced978934dd63520795554b29244a2.tar.bz2
otp-0c7e4330ddced978934dd63520795554b29244a2.zip
Code cleanup to remove confusing assertion
The code of add_ref/6 contained an assertion that somehow appeared twice. Also, a recent commit (2b2de61) suppressed an unmatched return warning in a non-optimal way. By changing the return type of hipe_bifs:add_ref/2 to be 'ok' instead of [] the code can be cleaned up and simplified. While at it, fixed the wrong indentation of some nearby code.
Diffstat (limited to 'lib/kernel/src')
-rw-r--r--lib/kernel/src/hipe_unified_loader.erl31
1 files changed, 14 insertions, 17 deletions
diff --git a/lib/kernel/src/hipe_unified_loader.erl b/lib/kernel/src/hipe_unified_loader.erl
index a7e30a048f..ce7408a3cc 100644
--- a/lib/kernel/src/hipe_unified_loader.erl
+++ b/lib/kernel/src/hipe_unified_loader.erl
@@ -772,27 +772,26 @@ find_const(ConstNo, []) ->
add_ref(CalleeMFA, Address, FunDefs, RefType, Trampoline, RemoteOrLocal) ->
CallerMFA = address_to_mfa_lth(Address, FunDefs),
- _ = case RemoteOrLocal of
+ case RemoteOrLocal of
local ->
%% just a sanity assertion
- {M,_,_} = CalleeMFA,
- {M,_,_} = CallerMFA;
+ {_M,_,_} = CalleeMFA,
+ ok;
remote ->
hipe_bifs:add_ref(CalleeMFA, {CallerMFA,Address,RefType,Trampoline,
get(hipe_loader_state)})
- end,
- ok.
+ end.
-% For FunDefs sorted from low to high addresses
+%% For FunDefs sorted from low to high addresses
address_to_mfa_lth(Address, FunDefs) ->
- case address_to_mfa_lth(Address, FunDefs, false) of
- false ->
- ?error_msg("Local adddress not found ~w\n",[Address]),
- exit({?MODULE, local_address_not_found});
- MFA ->
- MFA
- end.
-
+ case address_to_mfa_lth(Address, FunDefs, false) of
+ false ->
+ ?error_msg("Local adddress not found ~w\n",[Address]),
+ exit({?MODULE, local_address_not_found});
+ MFA ->
+ MFA
+ end.
+
address_to_mfa_lth(Address, [#fundef{address=Adr, mfa=MFA}|Rest], Prev) ->
if Address < Adr ->
Prev;
@@ -802,7 +801,7 @@ address_to_mfa_lth(Address, [#fundef{address=Adr, mfa=MFA}|Rest], Prev) ->
address_to_mfa_lth(_Address, [], Prev) ->
Prev.
-% For FunDefs sorted from high to low addresses
+%% For FunDefs sorted from high to low addresses
%% address_to_mfa_htl(Address, [#fundef{address=Adr, mfa=MFA}|_Rest]) when Address >= Adr -> MFA;
%% address_to_mfa_htl(Address, [_ | Rest]) -> address_to_mfa_htl(Address, Rest);
%% address_to_mfa_htl(Address, []) ->
@@ -868,8 +867,6 @@ assert_local_patch(Address) when is_integer(Address) ->
%% ____________________________________________________________________
%%
-%% Beam: nil() | binary() (used as a flag)
-
enter_code(CodeSize, CodeBinary, CalleeMFAs, LoaderState) ->
true = byte_size(CodeBinary) =:= CodeSize,
{CodeAddress,Trampolines} = hipe_bifs:enter_code(CodeBinary, CalleeMFAs,