Skip to content

Commit

Permalink
Simplify fix_sdescs by removing redundant check
Browse files Browse the repository at this point in the history
  • Loading branch information
yiannist committed Mar 29, 2014
1 parent c28b0d5 commit 789c452
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions lib/hipe/llvm/hipe_llvm_main.erl
Expand Up @@ -427,25 +427,21 @@ find_offsets([{Off,Arity}|Rest], Offsets, Acc) ->
[I | RestOffsets] = lists:dropwhile(fun (Y) -> Y<Off end, Offsets), [I | RestOffsets] = lists:dropwhile(fun (Y) -> Y<Off end, Offsets),
find_offsets(Rest, RestOffsets, [{I, Arity}|Acc]). find_offsets(Rest, RestOffsets, [{I, Arity}|Acc]).


%% The function below corrects the arity of calls, that are identified %% The function below corrects the stack descriptors of calls with arguments
%% by offset, in the stack descriptors. %% that are passed on the stack (more the NR_ARG_REGS) by subtracting the
%% number of stacked arguments from the frame size and from the offset of the
%% roots.
fix_sdescs([], SDescs) -> SDescs; fix_sdescs([], SDescs) -> SDescs;
fix_sdescs([{Offset, Arity} | Rest], SDescs) -> fix_sdescs([{Offset, Arity} | Rest], SDescs) ->
case lists:keyfind(Offset, 2, SDescs) of case lists:keyfind(Offset, 2, SDescs) of
false -> false ->
fix_sdescs(Rest, SDescs); fix_sdescs(Rest, SDescs);
{?SDESC, Offset, SDesc} -> {?SDESC, Offset, {ExnHandler, FrameSize, StkArity, Roots}} ->
{ExnHandler, FrameSize, StkArity, Roots} = SDesc,
FixedRoots = [X - Arity || X <- tuple_to_list(Roots)], FixedRoots = [X - Arity || X <- tuple_to_list(Roots)],
NewRoots = FixedSDesc =
case FixedRoots of {?SDESC, Offset, {ExnHandler, FrameSize - Arity, StkArity, FixedRoots}},
[H|_] when H >= 0 -> list_to_tuple(FixedRoots);
_ -> Roots
end,
NewSDesc =
{?SDESC, Offset, {ExnHandler, FrameSize - Arity, StkArity, NewRoots}},
RestSDescs = lists:keydelete(Offset, 2, SDescs), RestSDescs = lists:keydelete(Offset, 2, SDescs),
fix_sdescs(Rest, [NewSDesc | RestSDescs]) fix_sdescs(Rest, [FixedSDesc | RestSDescs])
end. end.




Expand Down

0 comments on commit 789c452

Please sign in to comment.