4
%% Copyright Ericsson AB 2001-2009. All Rights Reserved.
4
%% Copyright Ericsson AB 2001-2010. All Rights Reserved.
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/.
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.
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]).
68
-import(erlang, [max/2]).
69
68
-import(lists, [foldl/3, foldr/3, mapfoldl/3, reverse/1]).
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
209
208
io:fwrite("Inlining: inline_size=~w inline_effort=~w\n",
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),
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)),
1442
%% Visit the body in the context saved in the structure.
1443
{E2, S2} = i(E1, Ctxt, Ren1, Env1, S1),
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),
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)}
1445
1453
%% For the (possibly renamed) argument variables to an inlined call,