Permalink
Browse files

Da ubber fix

  • Loading branch information...
1 parent c2b4eab commit f9dbbcda3a04e852742c9518d81a3827dab71a9d @yiannist committed Mar 27, 2014
Showing with 11 additions and 12 deletions.
  1. +11 −12 lib/hipe/llvm/hipe_llvm_main.erl
@@ -342,8 +342,8 @@ create_sdesc_list([{ExnLbl, SPOff} | MoreExnAndSPOffs],
%% (thus, some of their arguments are passed to the stack). Because of the
%% Reserved Call Frame feature that the LLVM uses, the stack descriptors
%% are not correct since at the point of call the frame size is reduced
-%% proportionally to the number of arguments that are passed on the stack.
-%% Also the offsets of the roots need to be re-adjusted.
+%% by the number of arguments that are passed on the stack. Also, the
+%% offsets of the roots need to be re-adjusted.
fix_stack_descriptors(_, _, [], _) ->
[];
fix_stack_descriptors(RelocsDict, Relocs, SDescs, ExposedClosures) ->
@@ -427,7 +427,7 @@ find_offsets([{Off,Arity}|Rest], Offsets, Acc) ->
[I | RestOffsets] = lists:dropwhile(fun (Y) -> Y<Off end, Offsets),
find_offsets(Rest, RestOffsets, [{I, Arity}|Acc]).
-%% The functions below correct the arity of calls, that are identified
+%% The function below corrects the arity of calls, that are identified
%% by offset, in the stack descriptors.
fix_sdescs([], SDescs) -> SDescs;
fix_sdescs([{Offset, Arity} | Rest], SDescs) ->
@@ -436,16 +436,15 @@ fix_sdescs([{Offset, Arity} | Rest], SDescs) ->
fix_sdescs(Rest, SDescs);
{?SDESC, Offset, SDesc} ->
{ExnHandler, FrameSize, StkArity, Roots} = SDesc,
- DecRoot = fun(X) -> X-Arity end,
- NewRootsList = lists:map(DecRoot, tuple_to_list(Roots)),
- NewSDesc =
- case length(NewRootsList) > 0 andalso hd(NewRootsList) >= 0 of
- true ->
- {?SDESC, Offset, {ExnHandler, FrameSize-Arity, StkArity,
- list_to_tuple(NewRootsList)}};
- false ->
- {?SDESC, Offset, {ExnHandler, FrameSize, StkArity, Roots}}
+ DecRoot = fun(X) -> X - Arity end,
+ FixedRoots = lists:map(DecRoot, tuple_to_list(Roots)),
+ NewRoots =
+ case length(FixedRoots) > 0 andalso hd(FixedRoots) >= 0 of
+ true -> list_to_tuple(FixedRoots);
+ false -> Roots
end,
+ NewSDesc =
+ {?SDESC, Offset, {ExnHandler, FrameSize - Arity, StkArity, NewRoots}},
RestSDescs = lists:keydelete(Offset, 2, SDescs),
fix_sdescs(Rest, [NewSDesc | RestSDescs])
end.

0 comments on commit f9dbbcd

Please sign in to comment.