~ubuntu-branches/ubuntu/trusty/erlang/trusty

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Clint Byrum
  • Date: 2011-05-05 15:48:43 UTC
  • mfrom: (3.5.13 sid)
  • Revision ID: james.westby@ubuntu.com-20110505154843-0om6ekzg6m7ugj27
Tags: 1:14.b.2-dfsg-3ubuntu1
* Merge from debian unstable.  Remaining changes:
  - Drop libwxgtk2.8-dev build dependency. Wx isn't in main, and not
    supposed to.
  - Drop erlang-wx binary.
  - Drop erlang-wx dependency from -megaco, -common-test, and -reltool, they
    do not really need wx. Also drop it from -debugger; the GUI needs wx,
    but it apparently has CLI bits as well, and is also needed by -megaco,
    so let's keep the package for now.
  - debian/patches/series: Do what I meant, and enable build-options.patch
    instead.
* Additional changes:
  - Drop erlang-wx from -et
* Dropped Changes:
  - patches/pcre-crash.patch: CVE-2008-2371: outer level option with
    alternatives caused crash. (Applied Upstream)
  - fix for ssl certificate verification in newSSL: 
    ssl_cacertfile_fix.patch (Applied Upstream)
  - debian/patches/series: Enable native.patch again, to get stripped beam
    files and reduce the package size again. (build-options is what
    actually accomplished this)
  - Remove build-options.patch on advice from upstream and because it caused
    odd build failures.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
%%
2
2
%% %CopyrightBegin%
3
 
%% 
4
 
%% Copyright Ericsson AB 2001-2009. All Rights Reserved.
5
 
%% 
 
3
%%
 
4
%% Copyright Ericsson AB 2001-2010. All Rights Reserved.
 
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
8
8
%% compliance with the License. You should have received a copy of the
9
9
%% Erlang Public License along with this software. If not, it can be
10
10
%% retrieved online at http://www.erlang.org/.
11
 
%% 
 
11
%%
12
12
%% Software distributed under the License is distributed on an "AS IS"
13
13
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14
14
%% the License for the specific language governing rights and limitations
15
15
%% under the License.
16
 
%% 
 
16
%%
17
17
%% %CopyrightEnd%
18
18
%%
19
19
%% Core Erlang inliner.
65
65
               try_evars/1, try_handler/1, tuple_es/1, tuple_arity/1,
66
66
               type/1, values_es/1, var_name/1]).
67
67
 
68
 
-import(erlang, [max/2]).
69
68
-import(lists, [foldl/3, foldr/3, mapfoldl/3, reverse/1]).
70
69
 
71
70
%%
201
200
        false ->
202
201
            ok
203
202
    end,
204
 
    Size = max(1, proplists:get_value(inline_size, Opts)),
205
 
    Effort = max(1, proplists:get_value(inline_effort, Opts)),
206
 
    Unroll = max(1, proplists:get_value(inline_unroll, Opts)),
 
203
    Size = erlang:max(1, proplists:get_value(inline_size, Opts)),
 
204
    Effort = erlang:max(1, proplists:get_value(inline_effort, Opts)),
 
205
    Unroll = erlang:max(1, proplists:get_value(inline_unroll, Opts)),
207
206
    case proplists:get_bool(verbose, Opts) of
208
207
        true ->
209
208
            io:fwrite("Inlining: inline_size=~w inline_effort=~w\n",
1429
1428
            {E, S};
1430
1429
       true ->
1431
1430
            %% Create local bindings for the parameters to their
1432
 
            %% respective operand structures from the app-structure, and
1433
 
            %% visit the body in the context saved in the structure.
 
1431
            %% respective operand structures from the app-structure.
1434
1432
            {Rs, Ren1, Env1, S1} = bind_locals(Vs, Opnds, Ren, Env, S),
1435
 
            {E1, S2} = i(fun_body(E), Ctxt, Ren1, Env1, S1),
 
1433
 
 
1434
            %% function_clause exceptions that have been inlined
 
1435
            %% into another function (or even into the same function)
 
1436
            %% will not work properly. The v3_kernel pass will
 
1437
            %% take care of it, but we will need to help it by
 
1438
            %% removing any function_name annotations on match_fail
 
1439
            %% primops that we inline.
 
1440
            E1 = kill_function_name_anns(fun_body(E)),
 
1441
 
 
1442
            %% Visit the body in the context saved in the structure.
 
1443
            {E2, S2} = i(E1, Ctxt, Ren1, Env1, S1),
1436
1444
 
1437
1445
            %% Create necessary bindings and/or set flags.
1438
 
            {E2, S3} = make_let_bindings(Rs, E1, S2),
 
1446
            {E3, S3} = make_let_bindings(Rs, E2, S2),
1439
1447
 
1440
1448
            %% Lastly, flag the application as inlined, since the inlining
1441
1449
            %% attempt was not aborted before we reached this point.
1442
 
            {E2, st__set_app_inlined(L, S3)}
 
1450
            {E3, st__set_app_inlined(L, S3)}
1443
1451
    end.
1444
1452
 
1445
1453
%% For the (possibly renamed) argument variables to an inlined call,
2370
2378
kill_id_anns([]) ->
2371
2379
    [].
2372
2380
 
 
2381
kill_function_name_anns(Body) ->
 
2382
    F = fun(P) ->
 
2383
                case type(P) of
 
2384
                    primop ->
 
2385
                        Ann = get_ann(P),
 
2386
                        Ann1 = lists:keydelete(function_name, 1, Ann),
 
2387
                        set_ann(P, Ann1);
 
2388
                    _ ->
 
2389
                        P
 
2390
                end
 
2391
        end,
 
2392
    cerl_trees:map(F, Body).
 
2393
 
2373
2394
 
2374
2395
%% =====================================================================
2375
2396
%% General utilities