~clint-fewbar/ubuntu/precise/erlang/merge-15b

« back to all changes in this revision

Viewing changes to lib/compiler/src/beam_block.erl

  • Committer: Package Import Robot
  • Author(s): Sergei Golovan
  • Date: 2011-12-15 19:20:10 UTC
  • mfrom: (1.1.18) (3.5.15 sid)
  • mto: (3.5.16 sid)
  • mto: This revision was merged to the branch mainline in revision 33.
  • Revision ID: package-import@ubuntu.com-20111215192010-jnxcfe3tbrpp0big
Tags: 1:15.b-dfsg-1
* New upstream release.
* Upload to experimental because this release breaks external drivers
  API along with ABI, so several applications are to be fixed.
* Removed SSL patch because the old SSL implementation is removed from
  the upstream distribution.
* Removed never used patch which added native code to erlang beam files.
* Removed the erlang-docbuilder binary package because the docbuilder
  application was dropped by upstream.
* Documented dropping ${erlang-docbuilder:Depends} substvar in
  erlang-depends(1) manpage.
* Made erlang-base and erlang-base-hipe provide virtual package
  erlang-abi-15.b (the number means the first erlang version, which
  provides current ABI).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
%%
2
2
%% %CopyrightBegin%
3
3
%%
4
 
%% Copyright Ericsson AB 1999-2010. All Rights Reserved.
 
4
%% Copyright Ericsson AB 1999-2011. All Rights Reserved.
5
5
%%
6
6
%% The contents of this file are subject to the Erlang Public License,
7
7
%% Version 1.1, (the "License"); you may not use this file except in
36
36
 
37
37
        %% Collect basic blocks and optimize them.
38
38
        Is2 = blockify(Is1),
39
 
        Is3 = move_allocates(Is2),
40
 
        Is4 = beam_utils:live_opt(Is3),
41
 
        Is5 = opt_blocks(Is4),
42
 
        Is6 = beam_utils:delete_live_annos(Is5),
 
39
        Is3 = embed_lines(Is2),
 
40
        Is4 = move_allocates(Is3),
 
41
        Is5 = beam_utils:live_opt(Is4),
 
42
        Is6 = opt_blocks(Is5),
 
43
        Is7 = beam_utils:delete_live_annos(Is6),
43
44
 
44
45
        %% Optimize bit syntax.
45
 
        {Is,Lc} = bsm_opt(Is6, Lc0),
 
46
        {Is,Lc} = bsm_opt(Is7, Lc0),
46
47
 
47
48
        %% Done.
48
49
        {{function,Name,Arity,CLabel,Is},Lc}
148
149
collect({'catch',R,L})       -> {set,[R],[],{'catch',L}};
149
150
collect(_)                   -> error.
150
151
 
 
152
%% embed_lines([Instruction]) -> [Instruction]
 
153
%%  Combine blocks that would be split by line/1 instructions.
 
154
%%  Also move a line instruction before a block into the block,
 
155
%%  but leave the line/1 instruction after a block outside.
 
156
 
 
157
embed_lines(Is) ->
 
158
    embed_lines(reverse(Is), []).
 
159
 
 
160
embed_lines([{block,B2},{line,_}=Line,{block,B1}|T], Acc) ->
 
161
    B = {block,B1++[{set,[],[],Line}]++B2},
 
162
    embed_lines([B|T], Acc);
 
163
embed_lines([{block,B1},{line,_}=Line|T], Acc) ->
 
164
    B = {block,[{set,[],[],Line}|B1]},
 
165
    embed_lines([B|T], Acc);
 
166
embed_lines([I|Is], Acc) ->
 
167
    embed_lines(Is, [I|Acc]);
 
168
embed_lines([], Acc) -> Acc.
 
169
 
151
170
opt_blocks([{block,Bl0}|Is]) ->
152
171
    %% The live annotation at the beginning is not useful.
153
172
    [{'%live',_}|Bl] = Bl0,
225
244
        RevBif -> [{set,[Dst],As,{bif,RevBif,Fail}}|opt(Is)]
226
245
    end;
227
246
opt([{set,[X],[X],move}|Is]) -> opt(Is);
228
 
opt([{set,[D1],[{integer,Idx1},Reg],{bif,element,{f,0}}}=I1,
 
247
opt([{set,_,_,{line,_}}=Line1,
 
248
     {set,[D1],[{integer,Idx1},Reg],{bif,element,{f,0}}}=I1,
 
249
     {set,_,_,{line,_}}=Line2,
229
250
     {set,[D2],[{integer,Idx2},Reg],{bif,element,{f,0}}}=I2|Is])
230
251
  when Idx1 < Idx2, D1 =/= D2, D1 =/= Reg, D2 =/= Reg ->
231
 
    opt([I2,I1|Is]);
 
252
    opt([Line2,I2,Line1,I1|Is]);
232
253
opt([{set,Ds0,Ss,Op}|Is0]) ->   
233
254
    {Ds,Is} = opt_moves(Ds0, Is0),
234
255
    [{set,Ds,Ss,Op}|opt(Is)];