aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/test
diff options
context:
space:
mode:
authorErlang/OTP <[email protected]>2010-04-01 05:34:09 +0000
committerErlang/OTP <[email protected]>2010-04-01 05:34:09 +0000
commit263643a357e7a11724c599045ca35ba9aef2438c (patch)
tree659f70100c5d868b827ff13ee924bf7d8ba9e590 /lib/compiler/test
parent943ad16fa4b6335b6e170cc94fc7df9041ff4e47 (diff)
parentf958b8bdbc63c5cbc60502047a4fab548fe9fd89 (diff)
downloadotp-263643a357e7a11724c599045ca35ba9aef2438c.tar.gz
otp-263643a357e7a11724c599045ca35ba9aef2438c.tar.bz2
otp-263643a357e7a11724c599045ca35ba9aef2438c.zip
Merge branch 'bg/compiler-inliner' into dev
* bg/compiler-inliner: pmod_SUITE: Again test inlining parameterized modules compiler tests: Cope with missing args in function_clause for native code compiler tests: Compile a few more modules with 'inline' Consistently rewrite an inlined function_clause exception to case_clause compiler tests: Test the 'inline' option better compiler: Suppress bs_context_to_binary/1 for a literal operand compiler: Fix binary matching bug in the inliner sys_core_inline: Don't generated multiple compiler_generated annos OTP-8552 bg/compiler-inliner Several problems in the inliner have been fixed.
Diffstat (limited to 'lib/compiler/test')
-rw-r--r--lib/compiler/test/Makefile30
-rw-r--r--lib/compiler/test/bs_match_SUITE.erl88
-rw-r--r--lib/compiler/test/bs_utf_SUITE.erl14
-rw-r--r--lib/compiler/test/guard_SUITE.erl21
-rw-r--r--lib/compiler/test/lc_SUITE.erl20
-rw-r--r--lib/compiler/test/pmod_SUITE.erl4
-rw-r--r--lib/compiler/test/test_lib.erl4
7 files changed, 110 insertions, 71 deletions
diff --git a/lib/compiler/test/Makefile b/lib/compiler/test/Makefile
index 4d3b4c98f1..2d08e71e09 100644
--- a/lib/compiler/test/Makefile
+++ b/lib/compiler/test/Makefile
@@ -53,6 +53,25 @@ NO_OPT= \
record \
trycatch
+INLINE= \
+ andor \
+ apply \
+ bs_bincomp \
+ bs_bit_binaries \
+ bs_construct \
+ bs_match \
+ bs_utf \
+ core_fold \
+ float \
+ fun \
+ guard \
+ lc \
+ match \
+ misc \
+ num_bif \
+ receive \
+ record
+
CORE_MODULES = \
bs_shadowed_size_var \
nested_call_in_case
@@ -62,6 +81,8 @@ NO_OPT_MODULES= $(NO_OPT:%=%_no_opt_SUITE)
NO_OPT_ERL_FILES= $(NO_OPT_MODULES:%=%.erl)
POST_OPT_MODULES= $(NO_OPT:%=%_post_opt_SUITE)
POST_OPT_ERL_FILES= $(POST_OPT_MODULES:%=%.erl)
+INLINE_MODULES= $(INLINE:%=%_inline_SUITE)
+INLINE_ERL_FILES= $(INLINE_MODULES:%=%.erl)
ERL_FILES= $(MODULES:%=%.erl)
@@ -90,13 +111,15 @@ EBIN = .
# Targets
# ----------------------------------------------------
-make_emakefile: $(NO_OPT_ERL_FILES) $(POST_OPT_ERL_FILES)
+make_emakefile: $(NO_OPT_ERL_FILES) $(POST_OPT_ERL_FILES) $(INLINE_ERL_FILES)
$(ERL_TOP)/make/make_emakefile $(ERL_COMPILE_FLAGS) -o$(EBIN) $(MODULES) \
> $(EMAKEFILE)
$(ERL_TOP)/make/make_emakefile +no_copt +no_postopt $(ERL_COMPILE_FLAGS) \
-o$(EBIN) $(NO_OPT_MODULES) >> $(EMAKEFILE)
$(ERL_TOP)/make/make_emakefile +no_copt $(ERL_COMPILE_FLAGS) \
-o$(EBIN) $(POST_OPT_MODULES) >> $(EMAKEFILE)
+ $(ERL_TOP)/make/make_emakefile +inline $(ERL_COMPILE_FLAGS) \
+ -o$(EBIN) $(INLINE_MODULES) >> $(EMAKEFILE)
tests debug opt: make_emakefile
erl $(ERL_MAKE_FLAGS) -make
@@ -118,6 +141,9 @@ docs:
%_post_opt_SUITE.erl: %_SUITE.erl
sed -e 's;-module($(basename $<));-module($(basename $@));' $< > $@
+%_inline_SUITE.erl: %_SUITE.erl
+ sed -e 's;-module($(basename $<));-module($(basename $@));' $< > $@
+
# ----------------------------------------------------
# Release Target
# ----------------------------------------------------
@@ -130,7 +156,7 @@ release_tests_spec: make_emakefile
$(INSTALL_DATA) compiler.dynspec compiler.cover \
$(EMAKEFILE) $(ERL_FILES) $(CORE_FILES) $(RELSYSDIR)
$(INSTALL_DATA) $(NO_OPT_ERL_FILES) $(POST_OPT_ERL_FILES) \
- $(RELSYSDIR)
+ $(INLINE_ERL_FILES) $(RELSYSDIR)
chmod -f -R u+w $(RELSYSDIR)
@tar cf - *_SUITE_data | (cd $(RELSYSDIR); tar xf -)
diff --git a/lib/compiler/test/bs_match_SUITE.erl b/lib/compiler/test/bs_match_SUITE.erl
index 5c2797170b..75b6f801e7 100644
--- a/lib/compiler/test/bs_match_SUITE.erl
+++ b/lib/compiler/test/bs_match_SUITE.erl
@@ -1,19 +1,19 @@
%%
%% %CopyrightBegin%
-%%
-%% Copyright Ericsson AB 2005-2009. All Rights Reserved.
-%%
+%%
+%% Copyright Ericsson AB 2005-2010. All Rights Reserved.
+%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
-%%
+%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
-%%
+%%
%% %CopyrightEnd%
%%
@@ -302,15 +302,15 @@ partitioned_bs_match(Config) when is_list(Config) ->
?line error = partitioned_bs_match(10, <<7,8,15,13>>),
?line error = partitioned_bs_match(100, {a,tuple,is,'not',a,binary}),
?line ok = partitioned_bs_match(0, <<>>),
- ?line {'EXIT',{function_clause,[{?MODULE,partitioned_bs_match,[-1,blurf]}|_]}} =
- (catch partitioned_bs_match(-1, blurf)),
- ?line {'EXIT',{function_clause,[{?MODULE,partitioned_bs_match,[-1,<<1,2,3>>]}|_]}} =
- (catch partitioned_bs_match(-1, <<1,2,3>>)),
-
+ ?line fc(partitioned_bs_match, [-1,blurf],
+ catch partitioned_bs_match(-1, blurf)),
+ ?line fc(partitioned_bs_match, [-1,<<1,2,3>>],
+ catch partitioned_bs_match(-1, <<1,2,3>>)),
?line {17,<<1,2,3>>} = partitioned_bs_match_2(1, <<17,1,2,3>>),
?line {7,<<1,2,3>>} = partitioned_bs_match_2(7, <<17,1,2,3>>),
- ?line {'EXIT',{function_clause,[{?MODULE,partitioned_bs_match_2,[4,<<0:17>>]}|_]}} =
- (catch partitioned_bs_match_2(4, <<0:17>>)),
+
+ ?line fc(partitioned_bs_match_2, [4,<<0:17>>],
+ catch partitioned_bs_match_2(4, <<0:17>>)),
ok.
partitioned_bs_match(_, <<42:8,T/binary>>) ->
@@ -327,12 +327,10 @@ partitioned_bs_match_2(Len, <<_:8,T/binary>>) ->
function_clause(Config) when is_list(Config) ->
?line ok = function_clause_1(<<0,7,0,7,42>>),
- ?line {'EXIT',{function_clause,
- [{?MODULE,function_clause_1,[<<0,1,2,3>>]}|_]}} =
- (catch function_clause_1(<<0,1,2,3>>)),
- ?line {'EXIT',{function_clause,
- [{?MODULE,function_clause_1,[<<0,1,2,3>>]}|_]}} =
- (catch function_clause_1(<<0,7,0,1,2,3>>)),
+ ?line fc(function_clause_1, [<<0,1,2,3>>],
+ catch function_clause_1(<<0,1,2,3>>)),
+ ?line fc(function_clause_1, [<<0,1,2,3>>],
+ catch function_clause_1(<<0,7,0,1,2,3>>)),
ok.
function_clause_1(<<0:8,7:8,T/binary>>) ->
@@ -349,22 +347,17 @@ unit(Config) when is_list(Config) ->
?line 99 = peek8(<<99>>),
?line 100 = peek8(<<100,101>>),
- ?line {'EXIT',{function_clause,[{?MODULE,peek8,[<<100,101,0:1>>]}|_]}} =
- (catch peek8(<<100,101,0:1>>)),
+ ?line fc(peek8, [<<100,101,0:1>>], catch peek8(<<100,101,0:1>>)),
?line 37484 = peek16(<<37484:16>>),
?line 37489 = peek16(<<37489:16,5566:16>>),
- ?line {'EXIT',{function_clause,[{?MODULE,peek16,[<<8>>]}|_]}} =
- (catch peek16(<<8>>)),
- ?line {'EXIT',{function_clause,[{?MODULE,peek16,[<<42:15>>]}|_]}} =
- (catch peek16(<<42:15>>)),
- ?line {'EXIT',{function_clause,[{?MODULE,peek16,[<<1,2,3,4,5>>]}|_]}} =
- (catch peek16(<<1,2,3,4,5>>)),
+ ?line fc(peek16, [<<8>>], catch peek16(<<8>>)),
+ ?line fc(peek16, [<<42:15>>], catch peek16(<<42:15>>)),
+ ?line fc(peek16, [<<1,2,3,4,5>>], catch peek16(<<1,2,3,4,5>>)),
?line 127 = peek7(<<127:7>>),
?line 100 = peek7(<<100:7,19:7>>),
- ?line {'EXIT',{function_clause,[{?MODULE,peek7,[<<1,2>>]}|_]}} =
- (catch peek7(<<1,2>>)),
+ ?line fc(peek7, [<<1,2>>], catch peek7(<<1,2>>)),
ok.
peek1(<<B:8,_/bitstring>>) -> B.
@@ -533,15 +526,13 @@ bs_sum(Config) when is_list(Config) ->
?line 6 = bs_sum_1([1,2,3|0]),
?line 7 = bs_sum_1([1,2,3|one]),
- ?line {'EXIT',{function_clause,_}} = (catch bs_sum_1({too,big,tuple})),
- ?line {'EXIT',{function_clause,_}} = (catch bs_sum_1([1,2,3|{too,big,tuple}])),
+ ?line fc(catch bs_sum_1({too,big,tuple})),
+ ?line fc(catch bs_sum_1([1,2,3|{too,big,tuple}])),
?line [] = sneaky_alias(<<>>),
?line [559,387655] = sneaky_alias(id(<<559:32,387655:32>>)),
- ?line {'EXIT',{function_clause,[{?MODULE,sneaky_alias,[<<1>>]}|_]}} =
- (catch sneaky_alias(id(<<1>>))),
- ?line {'EXIT',{function_clause,[{?MODULE,sneaky_alias,[[1,2,3,4]]}|_]}} =
- (catch sneaky_alias(lists:seq(1, 4))),
+ ?line fc(sneaky_alias, [<<1>>], catch sneaky_alias(id(<<1>>))),
+ ?line fc(sneaky_alias, [[1,2,3,4]], catch sneaky_alias(lists:seq(1, 4))),
ok.
bs_sum_1(<<H,T/binary>>) -> H+bs_sum_1(T);
@@ -559,9 +550,9 @@ sneaky_alias(<<From:32,L/binary>>) -> [From|sneaky_alias(L)].
coverage(Config) when is_list(Config) ->
?line 0 = coverage_fold(fun(B, A) -> A+B end, 0, <<>>),
?line 6 = coverage_fold(fun(B, A) -> A+B end, 0, <<1,2,3>>),
- ?line {'EXIT',{function_clause,_}} = (catch coverage_fold(fun(B, A) ->
- A+B
- end, 0, [a,b,c])),
+ ?line fc(catch coverage_fold(fun(B, A) ->
+ A+B
+ end, 0, [a,b,c])),
?line {<<>>,not_a_tuple} = coverage_build(<<>>, <<>>, not_a_tuple),
?line {<<16#76,"abc",16#A9,"abc">>,{x,42,43}} =
@@ -573,9 +564,8 @@ coverage(Config) when is_list(Config) ->
?line do_coverage_bin_to_term_list([]),
?line do_coverage_bin_to_term_list([lists:seq(0, 10),{a,b,c},<<23:42>>]),
- ?line {'EXIT',{function_clause,
- [{?MODULE,coverage_bin_to_term_list,[<<0,0,0,7>>]}|_]}} =
- (catch do_coverage_bin_to_term_list_1(<<7:32>>)),
+ ?line fc(coverage_bin_to_term_list, [<<0,0,0,7>>],
+ catch do_coverage_bin_to_term_list_1(<<7:32>>)),
?line <<>> = coverage_per_key(<<4:32>>),
?line <<$a,$b,$c>> = coverage_per_key(<<7:32,"abc">>),
@@ -731,13 +721,12 @@ encode_octet_string(<<OctetString/binary>>, Len) ->
simon(Config) when is_list(Config) ->
?line one = simon(blurf, <<>>),
?line two = simon(0, <<42>>),
- ?line {'EXIT',{function_clause,[{?MODULE,simon,[17,<<1>>]}|_]}} = (catch simon(17, <<1>>)),
- ?line {'EXIT',{function_clause,[{?MODULE,simon,[0,<<1,2,3>>]}|_]}} = (catch simon(0, <<1,2,3>>)),
+ ?line fc(simon, [17,<<1>>], catch simon(17, <<1>>)),
+ ?line fc(simon, [0,<<1,2,3>>], catch simon(0, <<1,2,3>>)),
?line one = simon2(blurf, <<9>>),
?line two = simon2(0, <<9,1>>),
- ?line {'EXIT',{function_clause,[{?MODULE,simon2,[0,<<9,10,11>>]}|_]}} =
- (catch simon2(0, <<9,10,11>>)),
+ ?line fc(simon2, [0,<<9,10,11>>], catch simon2(0, <<9,10,11>>)),
ok.
simon(_, <<>>) -> one;
@@ -985,6 +974,17 @@ haystack_2(Haystack) ->
B
end || {X,Y} <- Subs ].
+fc({'EXIT',{function_clause,_}}) -> ok;
+fc({'EXIT',{{case_clause,_},_}}) when ?MODULE =:= bs_match_inline_SUITE -> ok.
+
+fc(Name, Args, {'EXIT',{function_clause,[{?MODULE,Name,Args}|_]}}) -> ok;
+fc(Name, Args, {'EXIT',{function_clause,[{?MODULE,Name,Arity}|_]}})
+ when length(Args) =:= Arity ->
+ true = test_server:is_native(?MODULE);
+fc(_, Args, {'EXIT',{{case_clause,ActualArgs},_}})
+ when ?MODULE =:= bs_match_inline_SUITE ->
+ Args = tuple_to_list(ActualArgs).
+
check(F, R) ->
R = F().
diff --git a/lib/compiler/test/bs_utf_SUITE.erl b/lib/compiler/test/bs_utf_SUITE.erl
index d93bdef73d..4281874a24 100644
--- a/lib/compiler/test/bs_utf_SUITE.erl
+++ b/lib/compiler/test/bs_utf_SUITE.erl
@@ -1,19 +1,19 @@
%%
%% %CopyrightBegin%
-%%
-%% Copyright Ericsson AB 2008-2009. All Rights Reserved.
-%%
+%%
+%% Copyright Ericsson AB 2008-2010. All Rights Reserved.
+%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
-%%
+%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
-%%
+%%
%% %CopyrightEnd%
%%
@@ -314,7 +314,7 @@ coverage(Config) when is_list(Config) ->
?line 0 = coverage_2(<<4096/utf8,65536/utf8,0>>),
?line 1 = coverage_2(<<1024/utf8,1025/utf8,1>>),
- ?line {'EXIT',{function_clause,_}} = (catch coverage_3(1)),
+ ?line fc(catch coverage_3(1)),
%% Cover beam_flatten (combining the heap allocation in
%% a subsequent test_heap instruction into the bs_init2
@@ -394,3 +394,5 @@ utf32_data() ->
<<16#41:32/little,NotIdentical:32/little,
16#0391:32/little,16#2E:32/little>>}.
+fc({'EXIT',{function_clause,_}}) -> ok;
+fc({'EXIT',{{case_clause,_},_}}) when ?MODULE =:= bs_utf_inline_SUITE -> ok.
diff --git a/lib/compiler/test/guard_SUITE.erl b/lib/compiler/test/guard_SUITE.erl
index 5ae41f13e7..f3960b28c3 100644
--- a/lib/compiler/test/guard_SUITE.erl
+++ b/lib/compiler/test/guard_SUITE.erl
@@ -1,19 +1,19 @@
%%
%% %CopyrightBegin%
-%%
-%% Copyright Ericsson AB 2001-2009. All Rights Reserved.
-%%
+%%
+%% Copyright Ericsson AB 2001-2010. All Rights Reserved.
+%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
-%%
+%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
-%%
+%%
%% %CopyrightEnd%
%%
-module(guard_SUITE).
@@ -1316,11 +1316,11 @@ cqlc(M, F, As, St) ->
andalso_semi(Config) when is_list(Config) ->
?line ok = andalso_semi_foo(0),
?line ok = andalso_semi_foo(1),
- ?line {'EXIT',{function_clause,_}} = (catch andalso_semi_foo(2)),
+ ?line fc(catch andalso_semi_foo(2)),
?line ok = andalso_semi_bar([a,b,c]),
?line ok = andalso_semi_bar(1),
- ?line {'EXIT',{function_clause,_}} = (catch andalso_semi_bar([a,b])),
+ ?line fc(catch andalso_semi_bar([a,b])),
ok.
andalso_semi_foo(Bar) when is_integer(Bar) andalso Bar =:= 0; Bar =:= 1 ->
@@ -1332,8 +1332,8 @@ andalso_semi_bar(Bar) when is_list(Bar) andalso length(Bar) =:= 3; Bar =:= 1 ->
tuple_size(Config) when is_list(Config) ->
?line 10 = do_tuple_size({1,2,3,4}),
- ?line {'EXIT',{function_clause,_}} = (catch do_tuple_size({1,2,3})),
- ?line {'EXIT',{function_clause,_}} = (catch do_tuple_size(42)),
+ ?line fc(catch do_tuple_size({1,2,3})),
+ ?line fc(catch do_tuple_size(42)),
?line error = ludicrous_tuple_size({a,b,c}),
?line error = ludicrous_tuple_size([a,b,c]),
@@ -1374,3 +1374,6 @@ check(F, Result) ->
io:format(" Got: ~p\n", [Other]),
test_server:fail()
end.
+
+fc({'EXIT',{function_clause,_}}) -> ok;
+fc({'EXIT',{{case_clause,_},_}}) when ?MODULE =:= guard_inline_SUITE -> ok.
diff --git a/lib/compiler/test/lc_SUITE.erl b/lib/compiler/test/lc_SUITE.erl
index e62b2cd77e..40bf67e1fa 100644
--- a/lib/compiler/test/lc_SUITE.erl
+++ b/lib/compiler/test/lc_SUITE.erl
@@ -1,19 +1,19 @@
%%
%% %CopyrightBegin%
-%%
-%% Copyright Ericsson AB 2001-2009. All Rights Reserved.
-%%
+%%
+%% Copyright Ericsson AB 2001-2010. All Rights Reserved.
+%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
-%%
+%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
-%%
+%%
%% %CopyrightEnd%
%%
-module(lc_SUITE).
@@ -66,8 +66,7 @@ basic(Config) when is_list(Config) ->
?line {'EXIT',_} = (catch [X || X <- L1, list_to_atom(X) == dum]),
?line [] = [X || X <- L1, X+1 < 2],
?line {'EXIT',_} = (catch [X || X <- L1, odd(X)]),
- ?line {'EXIT',{function_clause,[{?MODULE,_,[x]}|_]}} =
- (catch [E || E <- id(x)]),
+ ?line fc([x], catch [E || E <- id(x)]),
ok.
tuple_list() ->
@@ -160,3 +159,10 @@ empty_generator(Config) when is_list(Config) ->
id(I) -> I.
+fc(Args, {'EXIT',{function_clause,[{?MODULE,_,Args}|_]}}) -> ok;
+fc(Args, {'EXIT',{function_clause,[{?MODULE,Name,Arity}|_]}})
+ when length(Args) =:= Arity ->
+ true = test_server:is_native(?MODULE);
+fc(Args, {'EXIT',{{case_clause,ActualArgs},_}})
+ when ?MODULE =:= lc_inline_SUITE ->
+ Args = tuple_to_list(ActualArgs).
diff --git a/lib/compiler/test/pmod_SUITE.erl b/lib/compiler/test/pmod_SUITE.erl
index 293e110c45..13503ce905 100644
--- a/lib/compiler/test/pmod_SUITE.erl
+++ b/lib/compiler/test/pmod_SUITE.erl
@@ -38,8 +38,8 @@ fin_per_testcase(Case, Config) when is_atom(Case), is_list(Config) ->
basic(Config) when is_list(Config) ->
?line basic_1(Config, []),
-% ?line basic_1(Config, [inline]),
-% ?line basic_1(Config, [{inline,500},inline]),
+ ?line basic_1(Config, [inline]),
+ ?line basic_1(Config, [{inline,500},inline]),
ok.
basic_1(Config, Opts) ->
diff --git a/lib/compiler/test/test_lib.erl b/lib/compiler/test/test_lib.erl
index 231b86b0b6..844bbfc4b9 100644
--- a/lib/compiler/test/test_lib.erl
+++ b/lib/compiler/test/test_lib.erl
@@ -58,6 +58,7 @@ opt_opts(Mod) ->
(no_gc_bifs) -> true;
(no_stack_trimming) -> true;
(debug_info) -> true;
+ (inline) -> true;
(_) -> false
end, Opts).
@@ -68,5 +69,6 @@ opt_opts(Mod) ->
get_data_dir(Config) ->
Data0 = ?config(data_dir, Config),
{ok,Data1,_} = regexp:sub(Data0, "_no_opt_SUITE", "_SUITE"),
- {ok,Data,_} = regexp:sub(Data1, "_post_opt_SUITE", "_SUITE"),
+ {ok,Data2,_} = regexp:sub(Data1, "_post_opt_SUITE", "_SUITE"),
+ {ok,Data,_} = regexp:sub(Data2, "_inline_SUITE", "_SUITE"),
Data.