From e188505083c7d65a372826dc634b6179ac790361 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Tue, 16 Mar 2010 16:36:05 +0100 Subject: erts: Test compatibility of funs with R12 instead of R11 --- erts/emulator/test/Makefile | 2 +- erts/emulator/test/fun_r11_SUITE.erl | 76 ------------------------------------ erts/emulator/test/fun_r12_SUITE.erl | 75 +++++++++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+), 77 deletions(-) delete mode 100644 erts/emulator/test/fun_r11_SUITE.erl create mode 100644 erts/emulator/test/fun_r12_SUITE.erl diff --git a/erts/emulator/test/Makefile b/erts/emulator/test/Makefile index b1374950b2..5adc69ee57 100644 --- a/erts/emulator/test/Makefile +++ b/erts/emulator/test/Makefile @@ -61,7 +61,7 @@ MODULES= \ exception_SUITE \ float_SUITE \ fun_SUITE \ - fun_r11_SUITE \ + fun_r12_SUITE \ gc_SUITE \ guard_SUITE \ hash_SUITE \ diff --git a/erts/emulator/test/fun_r11_SUITE.erl b/erts/emulator/test/fun_r11_SUITE.erl deleted file mode 100644 index 61ba816cc8..0000000000 --- a/erts/emulator/test/fun_r11_SUITE.erl +++ /dev/null @@ -1,76 +0,0 @@ -%% -%% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2007-2009. 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(fun_r11_SUITE). --compile(r11). - --export([all/1,init_per_testcase/2,fin_per_testcase/2,dist_old_release/1]). - --define(default_timeout, ?t:minutes(1)). --include("test_server.hrl"). - -all(suite) -> [dist_old_release]. - -init_per_testcase(_Case, Config) -> - ?line Dog = test_server:timetrap(?default_timeout), - [{watchdog, Dog}|Config]. - -fin_per_testcase(_Case, Config) -> - Dog=?config(watchdog, Config), - test_server:timetrap_cancel(Dog), - ok. - -dist_old_release(Config) when is_list(Config) -> - case ?t:is_release_available("r11b") of - true -> do_dist_old(Config); - false -> {skip,"No R11B found"} - end. - -do_dist_old(Config) when is_list(Config) -> - ?line Pa = filename:dirname(code:which(?MODULE)), - Name = fun_dist_r11, - ?line {ok,Node} = ?t:start_node(Name, peer, - [{args,"-pa "++Pa}, - {erl,[{release,"r11b"}]}]), - - ?line Pid = spawn_link(Node, - fun() -> - receive - Fun when is_function(Fun) -> - R11BFun = fun(H) -> cons(H, [b,c]) end, - Fun(Fun, R11BFun) - end - end), - Self = self(), - Fun = fun(F, R11BFun) -> - {pid,Self} = erlang:fun_info(F, pid), - {module,?MODULE} = erlang:fun_info(F, module), - Self ! {ok,F,R11BFun} - end, - ?line Pid ! Fun, - ?line receive - {ok,Fun,R11BFun} -> - ?line [a,b,c] = R11BFun(a); - Other -> - ?line ?t:fail({bad_message,Other}) - end, - ok. - -cons(H, T) -> - [H|T]. diff --git a/erts/emulator/test/fun_r12_SUITE.erl b/erts/emulator/test/fun_r12_SUITE.erl new file mode 100644 index 0000000000..f21299ba67 --- /dev/null +++ b/erts/emulator/test/fun_r12_SUITE.erl @@ -0,0 +1,75 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2007-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(fun_r12_SUITE). + +-export([all/1,init_per_testcase/2,fin_per_testcase/2,dist_old_release/1]). + +-define(default_timeout, ?t:minutes(1)). +-include("test_server.hrl"). + +all(suite) -> [dist_old_release]. + +init_per_testcase(_Case, Config) -> + ?line Dog = test_server:timetrap(?default_timeout), + [{watchdog, Dog}|Config]. + +fin_per_testcase(_Case, Config) -> + Dog=?config(watchdog, Config), + test_server:timetrap_cancel(Dog), + ok. + +dist_old_release(Config) when is_list(Config) -> + case ?t:is_release_available("r12b") of + true -> do_dist_old(Config); + false -> {skip,"No R12B found"} + end. + +do_dist_old(Config) when is_list(Config) -> + ?line Pa = filename:dirname(code:which(?MODULE)), + Name = fun_dist_r12, + ?line {ok,Node} = ?t:start_node(Name, peer, + [{args,"-pa "++Pa}, + {erl,[{release,"r12b"}]}]), + + ?line Pid = spawn_link(Node, + fun() -> + receive + Fun when is_function(Fun) -> + R12BFun = fun(H) -> cons(H, [b,c]) end, + Fun(Fun, R12BFun) + end + end), + Self = self(), + Fun = fun(F, R12BFun) -> + {pid,Self} = erlang:fun_info(F, pid), + {module,?MODULE} = erlang:fun_info(F, module), + Self ! {ok,F,R12BFun} + end, + ?line Pid ! Fun, + ?line receive + {ok,Fun,R12BFun} -> + ?line [a,b,c] = R12BFun(a); + Other -> + ?line ?t:fail({bad_message,Other}) + end, + ok. + +cons(H, T) -> + [H|T]. -- cgit v1.2.3 From 4767bed8cf7b2c8ce580d574bf03e3f72217e8a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Tue, 16 Mar 2010 16:45:17 +0100 Subject: binary_SUITE: Don't test bit-level binary roundtrips with R11 nodes --- erts/emulator/test/binary_SUITE.erl | 32 +------------------------------- 1 file changed, 1 insertion(+), 31 deletions(-) diff --git a/erts/emulator/test/binary_SUITE.erl b/erts/emulator/test/binary_SUITE.erl index db2b3e10db..7ecc31aa29 100644 --- a/erts/emulator/test/binary_SUITE.erl +++ b/erts/emulator/test/binary_SUITE.erl @@ -55,7 +55,6 @@ otp_5484/1,otp_5933/1, ordering/1,unaligned_order/1,gc_test/1, bit_sized_binary_sizes/1, - bitlevel_roundtrip/1, otp_6817/1,deep/1,obsolete_funs/1,robustness/1,otp_8117/1, otp_8180/1]). @@ -70,7 +69,7 @@ all(suite) -> bad_binary_to_term_2,safe_binary_to_term2, bad_binary_to_term, bad_terms, t_hash, bad_size, bad_term_to_binary, more_bad_terms, otp_5484, otp_5933, ordering, unaligned_order, - gc_test, bit_sized_binary_sizes, bitlevel_roundtrip, otp_6817, otp_8117, + gc_test, bit_sized_binary_sizes, otp_6817, otp_8117, deep,obsolete_funs,robustness,otp_8180]. init_per_testcase(Func, Config) when is_atom(Func), is_list(Config) -> @@ -1150,35 +1149,6 @@ bsbs_1(A) -> Bin = binary_to_term(<<131,$M,5:32,A,0,0,0,0,0>>), BinSize = bit_size(Bin). -bitlevel_roundtrip(Config) when is_list(Config) -> - case ?t:is_release_available("r11b") of - true -> bitlevel_roundtrip_1(); - false -> {skip,"No R11B found"} - end. - -bitlevel_roundtrip_1() -> - Name = bitlevelroundtrip, - ?line N = list_to_atom(atom_to_list(Name) ++ "@" ++ hostname()), - ?line ?t:start_node(Name, slave, [{erl,[{release,"r11b"}]}]), - - ?line {<<128>>,1} = roundtrip(N, <<1:1>>), - ?line {<<64>>,2} = roundtrip(N, <<1:2>>), - ?line {<<16#E0>>,3} = roundtrip(N, <<7:3>>), - ?line {<<16#70>>,4} = roundtrip(N, <<7:4>>), - ?line {<<16#10>>,5} = roundtrip(N, <<2:5>>), - ?line {<<16#8>>,6} = roundtrip(N, <<2:6>>), - ?line {<<16#2>>,7} = roundtrip(N, <<1:7>>), - ?line {<<8,128>>,1} = roundtrip(N, <<8,1:1>>), - ?line {<<42,248>>,5} = roundtrip(N, <<42,31:5>>), - - ?line ?t:stop_node(N), - ok. - -roundtrip(Node, Term) -> - {badrpc,{'EXIT',Res}} = rpc:call(Node, erlang, exit, [Term]), - io:format("<<~p bits>> => ~w", [bit_size(Term),Res]), - Res. - deep(Config) when is_list(Config) -> ?line deep_roundtrip(lists:foldl(fun(E, A) -> [E,A] -- cgit v1.2.3 From 2090739366a79a7a134d77cbe10813c5fc42906b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Tue, 16 Mar 2010 15:51:39 +0100 Subject: test_server: Don't support communication with R11 nodes Since R14 does not need to be compatible with any older Erlang systems than R12, we no longer need to use the r11 compiler option when compiling the test_server_node module. --- lib/test_server/src/test_server_node.erl | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/test_server/src/test_server_node.erl b/lib/test_server/src/test_server_node.erl index ddc89d50d4..047487e82d 100644 --- a/lib/test_server/src/test_server_node.erl +++ b/lib/test_server/src/test_server_node.erl @@ -17,15 +17,12 @@ %% %CopyrightEnd% %% -module(test_server_node). --compile(r11). %%% %%% The same compiled code for this module must be possible to load -%%% in R11B, R12B and later. To make that possible no bit syntax -%%% must be used. +%%% in R12B and later. %%% - %% Test Controller interface -export([is_release_available/1]). -export([start_remote_main_target/1,stop/1]). -- cgit v1.2.3 From eeff53be2a9e3c5f48b5abbb30c90817f1ed83cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Tue, 16 Mar 2010 15:31:53 +0100 Subject: compiler: Don't support the r11 option The r11 option was used to generate BEAM modules that could loaded both on both R11 and R12/R13 to facilitate testing that R11 and R13 nodes could communicate with each other. Since R14 is only required to be compatible with R12 and R13 nodes, the r11 option is no longer needed. --- .gitignore | 1 - lib/compiler/src/compile.erl | 2 -- lib/compiler/test/Makefile | 22 ++-------------------- lib/compiler/test/test_lib.erl | 3 +-- 4 files changed, 3 insertions(+), 25 deletions(-) diff --git a/.gitignore b/.gitignore index 48ec7cba82..953d0fb68b 100644 --- a/.gitignore +++ b/.gitignore @@ -118,7 +118,6 @@ a.out.dSYM/ /lib/compiler/src/beam_opcodes.hrl /lib/compiler/src/core_parse.erl -/lib/compiler/test/*_r11_SUITE.erl /lib/compiler/test/*_no_opt_SUITE.erl /lib/compiler/test/*_post_opt_SUITE.erl diff --git a/lib/compiler/src/compile.erl b/lib/compiler/src/compile.erl index b853800d73..7194a10b14 100644 --- a/lib/compiler/src/compile.erl +++ b/lib/compiler/src/compile.erl @@ -162,8 +162,6 @@ expand_opt(report, Os) -> [report_errors,report_warnings|Os]; expand_opt(return, Os) -> [return_errors,return_warnings|Os]; -expand_opt(r11, Os) -> - [no_stack_trimming,no_binaries,no_constant_pool|Os]; expand_opt({debug_info_key,_}=O, Os) -> [encrypt_debug_info,O|Os]; expand_opt(no_binaries=O, Os) -> diff --git a/lib/compiler/test/Makefile b/lib/compiler/test/Makefile index ad2f63e9e5..4d3b4c98f1 100644 --- a/lib/compiler/test/Makefile +++ b/lib/compiler/test/Makefile @@ -53,17 +53,6 @@ NO_OPT= \ record \ trycatch -R11= \ - andor \ - apply \ - float \ - fun \ - match \ - num_bif \ - receive \ - record \ - trycatch - CORE_MODULES = \ bs_shadowed_size_var \ nested_call_in_case @@ -73,8 +62,6 @@ 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) -R11_MODULES= $(R11:%=%_r11_SUITE) -R11_ERL_FILES= $(R11_MODULES:%=%.erl) ERL_FILES= $(MODULES:%=%.erl) @@ -103,15 +90,13 @@ EBIN = . # Targets # ---------------------------------------------------- -make_emakefile: $(NO_OPT_ERL_FILES) $(POST_OPT_ERL_FILES) $(R11_ERL_FILES) +make_emakefile: $(NO_OPT_ERL_FILES) $(POST_OPT_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 +r11 $(ERL_COMPILE_FLAGS) \ - -o$(EBIN) $(R11_MODULES) >> $(EMAKEFILE) tests debug opt: make_emakefile erl $(ERL_MAKE_FLAGS) -make @@ -133,9 +118,6 @@ docs: %_post_opt_SUITE.erl: %_SUITE.erl sed -e 's;-module($(basename $<));-module($(basename $@));' $< > $@ -%_r11_SUITE.erl: %_SUITE.erl - sed -e 's;-module($(basename $<));-module($(basename $@));' $< > $@ - # ---------------------------------------------------- # Release Target # ---------------------------------------------------- @@ -148,7 +130,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) \ - $(R11_ERL_FILES) $(RELSYSDIR) + $(RELSYSDIR) chmod -f -R u+w $(RELSYSDIR) @tar cf - *_SUITE_data | (cd $(RELSYSDIR); tar xf -) diff --git a/lib/compiler/test/test_lib.erl b/lib/compiler/test/test_lib.erl index 3099538071..9ac7b8ac27 100644 --- a/lib/compiler/test/test_lib.erl +++ b/lib/compiler/test/test_lib.erl @@ -70,6 +70,5 @@ opt_opts(Mod) -> get_data_dir(Config) -> Data0 = ?config(data_dir, Config), {ok,Data1,_} = regexp:sub(Data0, "_no_opt_SUITE", "_SUITE"), - {ok,Data2,_} = regexp:sub(Data1, "_post_opt_SUITE", "_SUITE"), - {ok,Data,_} = regexp:sub(Data2, "_r11_SUITE", "_SUITE"), + {ok,Data,_} = regexp:sub(Data1, "_post_opt_SUITE", "_SUITE"), Data. -- cgit v1.2.3 From 2dc5a17b550e37b41410ad09ee636d877ca1f106 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Tue, 16 Mar 2010 15:27:01 +0100 Subject: compiler: Don't support the no_constant_pool option The no_constant_pool option was implied by the r11 option. It turns off the usage of the constant (literal) pool, so that BEAM instructions that use constants can be loaded in an R11 system. Since the r11 option has been removed, there is no need to retain the no_constant_pool option. --- lib/compiler/src/beam_block.erl | 2 -- lib/compiler/src/beam_flatten.erl | 1 - lib/compiler/src/beam_jump.erl | 1 - lib/compiler/src/beam_type.erl | 2 -- lib/compiler/src/compile.erl | 2 +- lib/compiler/src/sys_core_dsetel.erl | 2 -- lib/compiler/src/v3_codegen.erl | 3 -- lib/compiler/src/v3_kernel.erl | 66 ++++++------------------------------ lib/compiler/src/v3_kernel_pp.erl | 1 - lib/compiler/src/v3_life.erl | 2 -- lib/compiler/test/test_lib.erl | 1 - 11 files changed, 11 insertions(+), 72 deletions(-) diff --git a/lib/compiler/src/beam_block.erl b/lib/compiler/src/beam_block.erl index d4a4ddca8a..9be4888e15 100644 --- a/lib/compiler/src/beam_block.erl +++ b/lib/compiler/src/beam_block.erl @@ -140,7 +140,6 @@ collect({move,S,D}) -> {set,[D],[S],move}; collect({put_list,S1,S2,D}) -> {set,[D],[S1,S2],put_list}; collect({put_tuple,A,D}) -> {set,[D],[],{put_tuple,A}}; collect({put,S}) -> {set,[],[S],put}; -collect({put_string,L,S,D}) -> {set,[D],[],{put_string,L,S}}; collect({get_tuple_element,S,I,D}) -> {set,[D],[S],{get_tuple_element,I}}; collect({set_tuple_element,S,D,I}) -> {set,[],[S,D],{set_tuple_element,I}}; collect({get_list,S,D1,D2}) -> {set,[D1,D2],[S],get_list}; @@ -204,7 +203,6 @@ alloc_may_pass({set,_,_,{set_tuple_element,_}}) -> false; alloc_may_pass({set,_,_,put_list}) -> false; alloc_may_pass({set,_,_,{put_tuple,_}}) -> false; alloc_may_pass({set,_,_,put}) -> false; -alloc_may_pass({set,_,_,{put_string,_,_}}) -> false; alloc_may_pass({set,_,_,_}) -> true. combine_alloc({_,Ns,Nh1,Init}, {_,nostack,Nh2,[]}) -> diff --git a/lib/compiler/src/beam_flatten.erl b/lib/compiler/src/beam_flatten.erl index d9de7e2495..92211a9d3d 100644 --- a/lib/compiler/src/beam_flatten.erl +++ b/lib/compiler/src/beam_flatten.erl @@ -57,7 +57,6 @@ norm({set,[D],[S],fconv}) -> {fconv,S,D}; norm({set,[D],[S1,S2],put_list}) -> {put_list,S1,S2,D}; norm({set,[D],[],{put_tuple,A}}) -> {put_tuple,A,D}; norm({set,[],[S],put}) -> {put,S}; -norm({set,[D],[],{put_string,L,S}}) -> {put_string,L,S,D}; norm({set,[D],[S],{get_tuple_element,I}}) -> {get_tuple_element,S,I,D}; norm({set,[],[S,D],{set_tuple_element,I}}) -> {set_tuple_element,S,D,I}; norm({set,[D1,D2],[S],get_list}) -> {get_list,S,D1,D2}; diff --git a/lib/compiler/src/beam_jump.erl b/lib/compiler/src/beam_jump.erl index 739928f411..45902789ee 100644 --- a/lib/compiler/src/beam_jump.erl +++ b/lib/compiler/src/beam_jump.erl @@ -452,7 +452,6 @@ is_label_used_in_2({set,_,_,Info}, Lbl) -> {'catch',{f,F}} -> F =:= Lbl; {alloc,_,_} -> false; {put_tuple,_} -> false; - {put_string,_,_} -> false; {get_tuple_element,_} -> false; {set_tuple_element,_} -> false; _ when is_atom(Info) -> false diff --git a/lib/compiler/src/beam_type.erl b/lib/compiler/src/beam_type.erl index ba903a12b6..5b59e5f2ea 100644 --- a/lib/compiler/src/beam_type.erl +++ b/lib/compiler/src/beam_type.erl @@ -253,8 +253,6 @@ flt_need_heap_2({set,_,_,{put_tuple,_}}, H, Fl) -> {[],H+1,Fl}; flt_need_heap_2({set,_,_,put}, H, Fl) -> {[],H+1,Fl}; -flt_need_heap_2({set,_,_,{put_string,L,_Str}}, H, Fl) -> - {[],H+2*L,Fl}; %% Then the "neutral" instructions. We just pass them. flt_need_heap_2({set,[{fr,_}],_,_}, H, Fl) -> {[],H,Fl}; diff --git a/lib/compiler/src/compile.erl b/lib/compiler/src/compile.erl index 7194a10b14..eaec5a6d78 100644 --- a/lib/compiler/src/compile.erl +++ b/lib/compiler/src/compile.erl @@ -588,7 +588,7 @@ core_passes() -> kernel_passes() -> %% Destructive setelement/3 optimization and core lint. - [{unless,no_constant_pool,?pass(core_dsetel_module)}, %Not safe without constant pool. + [?pass(core_dsetel_module), {iff,dsetel,{listing,"dsetel"}}, {iff,clint,?pass(core_lint_module)}, diff --git a/lib/compiler/src/sys_core_dsetel.erl b/lib/compiler/src/sys_core_dsetel.erl index c38eab7b42..cc2977dafd 100644 --- a/lib/compiler/src/sys_core_dsetel.erl +++ b/lib/compiler/src/sys_core_dsetel.erl @@ -57,8 +57,6 @@ %% if X1 is used exactly once. %% Thus, we need to track variable usage. %% -%% NOTE: This pass must NOT be used if the no_constant_pool option is used. -%% -module(sys_core_dsetel). diff --git a/lib/compiler/src/v3_codegen.erl b/lib/compiler/src/v3_codegen.erl index 83113d1652..64a53c400e 100644 --- a/lib/compiler/src/v3_codegen.erl +++ b/lib/compiler/src/v3_codegen.erl @@ -209,7 +209,6 @@ need_heap_1(#l{ke={set,_,Val}}, H) -> {[],H + case Val of {cons,_} -> 2; {tuple,Es} -> 1 + length(Es); - {string,S} -> 2 * length(S); _Other -> 0 end}; need_heap_1(#l{ke={bif,dsetelement,_As,_Rs},i=I}, H) -> @@ -1424,8 +1423,6 @@ set_cg([{var,R}], Con, Le, Vdb, Bef, St) -> [{put_tuple,length(Es),Ret}] ++ cg_build_args(Es, Bef); {var,V} -> % Normally removed by kernel optimizer. [{move,fetch_var(V, Int),Ret}]; - {string,Str} = String -> - [{put_string,length(Str),String,Ret}]; Other -> [{move,Other,Ret}] end, diff --git a/lib/compiler/src/v3_kernel.erl b/lib/compiler/src/v3_kernel.erl index 8568071e57..9ee3dee5e0 100644 --- a/lib/compiler/src/v3_kernel.erl +++ b/lib/compiler/src/v3_kernel.erl @@ -126,12 +126,8 @@ copy_anno(Kdst, Ksrc) -> -spec module(cerl:c_module(), [compile:option()]) -> {'ok', #k_mdef{}, [warning()]}. -module(#c_module{anno=A,name=M,exports=Es,attrs=As,defs=Fs}, Options) -> - Lit = case member(no_constant_pool, Options) of - true -> no; - false -> dict:new() - end, - St0 = #kern{lit=Lit}, +module(#c_module{anno=A,name=M,exports=Es,attrs=As,defs=Fs}, _Options) -> + St0 = #kern{lit=dict:new()}, {Kfs,St} = mapfoldl(fun function/2, St0, Fs), Kes = map(fun (#c_var{name={_,_}=Fname}) -> Fname end, Es), Kas = map(fun ({#c_literal{val=N},V}) -> @@ -240,11 +236,6 @@ expr(#c_var{anno=A,name={_Name,Arity}}=Fname, Sub, St) -> expr(Fun, Sub, St); expr(#c_var{anno=A,name=V}, Sub, St) -> {#k_var{anno=A,name=get_vsub(V, Sub)},[],St}; -expr(#c_literal{anno=A,val=Lit}, Sub, #kern{lit=no}=St) -> - %% No constant pools for compatibility with a previous version. - %% Fully expand the literal. - Core = expand_literal(Lit, A), - expr(Core, Sub, St); expr(#c_literal{}=Lit, Sub, St) -> Core = handle_literal(Lit), expr(Core, Sub, St); @@ -265,9 +256,6 @@ expr(#k_float{}=V, _Sub, St) -> {V,[],St}; expr(#k_atom{}=V, _Sub, St) -> {V,[],St}; -expr(#k_string{}=V, _Sub, St) -> - %% Only for compatibility with a previous version. - {V,[],St}; expr(#c_cons{anno=A,hd=Ch,tl=Ct}, Sub, St0) -> %% Do cons in two steps, first the expressions left to right, then %% any remaining literals right to left. @@ -980,11 +968,6 @@ match_var([U|Us], Cs0, Def, St) -> %% according to type, the order is really irrelevant but tries to be %% smart. -match_con(Us, Cs0, Def, #kern{lit=no}=St) -> - %% No constant pool (for compatibility with R11B). - %% We must expand literals. - Cs = [expand_pat_lit_clause(C, true) || C <- Cs0], - match_con_1(Us, Cs, Def, St); match_con(Us, [C], Def, St) -> %% There is only one clause. We can keep literal tuples and %% lists, but we must convert []/integer/float/atom literals @@ -1783,7 +1766,6 @@ lit_vars(#k_int{}) -> []; lit_vars(#k_float{}) -> []; lit_vars(#k_atom{}) -> []; %%lit_vars(#k_char{}) -> []; -lit_vars(#k_string{}) -> []; lit_vars(#k_nil{}) -> []; lit_vars(#k_cons{hd=H,tl=T}) -> union(lit_vars(H), lit_vars(T)); @@ -1845,48 +1827,20 @@ handle_literal(#c_literal{anno=A,val=V}) -> case V of [_|_] -> #k_literal{anno=A,val=V}; + [] -> + #k_nil{anno=A}; V when is_tuple(V) -> #k_literal{anno=A,val=V}; V when is_bitstring(V) -> #k_literal{anno=A,val=V}; - _ -> - expand_literal(V, A) + V when is_integer(V) -> + #k_int{anno=A,val=V}; + V when is_float(V) -> + #k_float{anno=A,val=V}; + V when is_atom(V) -> + #k_atom{anno=A,val=V} end. -%% expand_literal(Literal, Anno) -> CoreTerm | KernelTerm -%% Fully expand the literal. Atomic terms such as integers are directly -%% translated to the Kernel Erlang format, while complex terms are kept -%% in the Core Erlang format (but the content is recursively processed). - -expand_literal([H|T]=V, A) when is_integer(H), 0 =< H, H =< 255 -> - case is_print_char_list(T) of - false -> - #c_cons{anno=A,hd=#k_int{anno=A,val=H},tl=expand_literal(T, A)}; - true -> - #k_string{anno=A,val=V} - end; -expand_literal([H|T], A) -> - #c_cons{anno=A,hd=expand_literal(H, A),tl=expand_literal(T, A)}; -expand_literal([], A) -> - #k_nil{anno=A}; -expand_literal(V, A) when is_tuple(V) -> - #c_tuple{anno=A,es=expand_literal_list(tuple_to_list(V), A)}; -expand_literal(V, A) when is_integer(V) -> - #k_int{anno=A,val=V}; -expand_literal(V, A) when is_float(V) -> - #k_float{anno=A,val=V}; -expand_literal(V, A) when is_atom(V) -> - #k_atom{anno=A,val=V}. - -expand_literal_list([H|T], A) -> - [expand_literal(H, A)|expand_literal_list(T, A)]; -expand_literal_list([], _) -> []. - -is_print_char_list([H|T]) when is_integer(H), 0 =< H, H =< 255 -> - is_print_char_list(T); -is_print_char_list([]) -> true; -is_print_char_list(_) -> false. - make_list(Es) -> foldr(fun(E, Acc) -> #c_cons{hd=E,tl=Acc} diff --git a/lib/compiler/src/v3_kernel_pp.erl b/lib/compiler/src/v3_kernel_pp.erl index b1ca907d11..40f1efe1f2 100644 --- a/lib/compiler/src/v3_kernel_pp.erl +++ b/lib/compiler/src/v3_kernel_pp.erl @@ -80,7 +80,6 @@ format_1(#k_atom{val=A}, _Ctxt) -> core_atom(A); format_1(#k_float{val=F}, _Ctxt) -> float_to_list(F); format_1(#k_int{val=I}, _Ctxt) -> integer_to_list(I); format_1(#k_nil{}, _Ctxt) -> "[]"; -format_1(#k_string{val=S}, _Ctxt) -> io_lib:write_string(S); format_1(#k_var{name=V}, _Ctxt) -> if is_atom(V) -> case atom_to_list(V) of diff --git a/lib/compiler/src/v3_life.erl b/lib/compiler/src/v3_life.erl index 8e6b153d57..9fda37530b 100644 --- a/lib/compiler/src/v3_life.erl +++ b/lib/compiler/src/v3_life.erl @@ -418,7 +418,6 @@ literal(#k_int{val=I}, _) -> {integer,I}; literal(#k_float{val=F}, _) -> {float,F}; literal(#k_atom{val=N}, _) -> {atom,N}; %%literal(#k_char{val=C}, _) -> {char,C}; -literal(#k_string{val=S}, _) -> {string,S}; literal(#k_nil{}, _) -> nil; literal(#k_cons{hd=H,tl=T}, Ctxt) -> {cons,[literal(H, Ctxt),literal(T, Ctxt)]}; @@ -443,7 +442,6 @@ literal2(#k_int{val=I}, _) -> {integer,I}; literal2(#k_float{val=F}, _) -> {float,F}; literal2(#k_atom{val=N}, _) -> {atom,N}; %%literal2(#k_char{val=C}, _) -> {char,C}; -literal2(#k_string{val=S}, _) -> {string,S}; literal2(#k_nil{}, _) -> nil; literal2(#k_cons{hd=H,tl=T}, Ctxt) -> {cons,[literal2(H, Ctxt),literal2(T, Ctxt)]}; diff --git a/lib/compiler/test/test_lib.erl b/lib/compiler/test/test_lib.erl index 9ac7b8ac27..382839d919 100644 --- a/lib/compiler/test/test_lib.erl +++ b/lib/compiler/test/test_lib.erl @@ -56,7 +56,6 @@ opt_opts(Mod) -> (no_new_binaries) -> true; (no_new_apply) -> true; (no_gc_bifs) -> true; - (no_constant_pool) -> true; (no_stack_trimming) -> true; (no_binaries) -> true; (debug_info) -> true; -- cgit v1.2.3 From bba60738a4de2528a361d815895191e8e0efd529 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Tue, 16 Mar 2010 15:54:35 +0100 Subject: erts: Don't support the put_string/3 instruction Since R14 does not need to load code that can also be loaded in an R11 run-time system, support for the put_string/3 instruction can be removed. --- erts/emulator/beam/beam_emu.c | 14 ------------- erts/emulator/beam/beam_load.c | 46 ------------------------------------------ erts/emulator/beam/ops.tab | 7 ------- lib/compiler/src/genop.tab | 2 +- 4 files changed, 1 insertion(+), 68 deletions(-) diff --git a/erts/emulator/beam/beam_emu.c b/erts/emulator/beam/beam_emu.c index 834cc8df61..6de423ecf8 100644 --- a/erts/emulator/beam/beam_emu.c +++ b/erts/emulator/beam/beam_emu.c @@ -1414,20 +1414,6 @@ void process_main(void) NextPF(2, next); } - OpCase(put_string_IId): - { - unsigned char* s; - int len; - Eterm result; - - len = Arg(0); /* Length. */ - result = NIL; - for (s = (unsigned char *) Arg(1); len > 0; s--, len--) { - PutList(make_small(*s), result, result, StoreSimpleDest); - } - StoreBifResult(2, result); - } - /* * Send is almost a standard call-BIF with two arguments, except for: * 1) It cannot be traced. diff --git a/erts/emulator/beam/beam_load.c b/erts/emulator/beam/beam_load.c index bbfeac5397..5e4375fc96 100644 --- a/erts/emulator/beam/beam_load.c +++ b/erts/emulator/beam/beam_load.c @@ -277,7 +277,6 @@ typedef struct { BeamInstr* code; /* Loaded code. */ int ci; /* Current index into loaded code. */ Label* labels; - BeamInstr put_strings; /* Linked list of put_string instructions. */ BeamInstr new_bs_put_strings; /* Linked list of i_new_bs_put_string instructions. */ StringPatch* string_patches; /* Linked list of position into string table to patch. */ BeamInstr catches; /* Linked list of catch_yf instructions. */ @@ -1388,7 +1387,6 @@ read_code_header(LoaderState* stp) stp->code[MI_COMPILE_SIZE_ON_HEAP] = 0; stp->code[MI_NUM_BREAKPOINTS] = 0; - stp->put_strings = 0; stp->new_bs_put_strings = 0; stp->catches = 0; return 1; @@ -2130,34 +2128,6 @@ load_code(LoaderState* stp) /* Remember offset for the on_load function. */ stp->on_load = ci; break; - case op_put_string_IId: - { - /* - * At entry: - * - * code[ci-4] &&lb_put_string_IId - * code[ci-3] length of string - * code[ci-2] offset into string table - * code[ci-1] destination register - * - * Since we don't know the address of the string table yet, - * just check the offset and length for validity, and use - * the instruction field as a link field to link all put_string - * instructions into a single linked list. At exit: - * - * code[ci-4] pointer to next put_string instruction (or 0 - * if this is the last) - */ - Uint offset = code[ci-2]; - Uint len = code[ci-3]; - unsigned strtab_size = stp->chunks[STR_CHUNK].size; - if (offset > strtab_size || offset + len > strtab_size) { - LoadError2(stp, "invalid string reference %d, size %d", offset, len); - } - code[ci-4] = stp->put_strings; - stp->put_strings = ci - 4; - } - break; case op_bs_put_string_II: { /* @@ -3593,22 +3563,6 @@ freeze_code(LoaderState* stp) } CHKBLK(ERTS_ALC_T_CODE,code); - - /* - * Go through all put_strings instructions, restore the pointer to - * the instruction and convert string offsets to pointers (to the - * LAST character). - */ - - index = stp->put_strings; - while (index != 0) { - Uint next = code[index]; - code[index] = BeamOpCode(op_put_string_IId); - code[index+2] = (BeamInstr) (str_table + code[index+2] + code[index+1] - 1); - index = next; - } - CHKBLK(ERTS_ALC_T_CODE,code); - /* * Go through all i_new_bs_put_strings instructions, restore the pointer to * the instruction and convert string offsets to pointers (to the diff --git a/erts/emulator/beam/ops.tab b/erts/emulator/beam/ops.tab index ce1df74f03..264cfd06e4 100644 --- a/erts/emulator/beam/ops.tab +++ b/erts/emulator/beam/ops.tab @@ -66,7 +66,6 @@ func_info M=a a==am_module_info A=u==1 | label L | move n r => too_old_compiler bif1 Fail u$func:erlang:is_constant/1 Src Dst => too_old_compiler - # # All the other instructions. # @@ -115,12 +114,6 @@ init Y1 | init Y2 => init2 Y1 Y2 %macro: init2 Init2 -pack %macro: init3 Init3 -pack -# -# Warning: The put_string instruction is specially treated in the loader. -# Don't change the instruction format unless you change the loader too. -# -put_string I I d - # Selecting values select_val S=q Fail=f Size=u Rest=* => const_select_val(S, Fail, Size, Rest) diff --git a/lib/compiler/src/genop.tab b/lib/compiler/src/genop.tab index 6874054495..994d7e4626 100644 --- a/lib/compiler/src/genop.tab +++ b/lib/compiler/src/genop.tab @@ -132,7 +132,7 @@ BEAM_FORMAT_NUMBER=0 # # Building terms. # -68: put_string/3 +68: -put_string/3 69: put_list/3 70: put_tuple/2 71: put/1 -- cgit v1.2.3 From d179c1522c73de550bce45c7f5d5055e04b93f32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Tue, 16 Mar 2010 16:13:54 +0100 Subject: compiler: Don't support the no_binaries option The no_binaries option terminates the compiler with an error if any bit syntax is used in the module being compiled. (It used to be implied by the removed r11 option.) --- lib/compiler/src/compile.erl | 3 --- lib/compiler/src/v3_core.erl | 46 ++++++++++----------------------------- lib/compiler/test/error_SUITE.erl | 35 ++--------------------------- lib/compiler/test/test_lib.erl | 1 - 4 files changed, 14 insertions(+), 71 deletions(-) diff --git a/lib/compiler/src/compile.erl b/lib/compiler/src/compile.erl index eaec5a6d78..5017fd2c23 100644 --- a/lib/compiler/src/compile.erl +++ b/lib/compiler/src/compile.erl @@ -164,9 +164,6 @@ expand_opt(return, Os) -> [return_errors,return_warnings|Os]; expand_opt({debug_info_key,_}=O, Os) -> [encrypt_debug_info,O|Os]; -expand_opt(no_binaries=O, Os) -> - %%Turn off the entire type optimization pass. - [no_topt,O|Os]; expand_opt(no_float_opt, Os) -> %%Turn off the entire type optimization pass. [no_topt|Os]; diff --git a/lib/compiler/src/v3_core.erl b/lib/compiler/src/v3_core.erl index dfe15de4ff..8b04969b05 100644 --- a/lib/compiler/src/v3_core.erl +++ b/lib/compiler/src/v3_core.erl @@ -213,10 +213,7 @@ clause({clause,Lc,H0,G0,B0}, St0) -> catch throw:nomatch -> St = add_warning(Lc, nomatch, St0), - {noclause,St}; %Bad pattern - throw:no_binaries -> - St = add_error(Lc, no_binaries, St0), - {noclause,St} + {noclause,St} %Bad pattern end. clause_arity({clause,_,H0,_,_}) -> length(H0). @@ -496,22 +493,18 @@ expr({tuple,L,Es0}, St0) -> {Es1,Eps,St1} = safe_list(Es0, St0), A = lineno_anno(L, St1), {ann_c_tuple(A, Es1),Eps,St1}; -expr({bin,L,Es0}, #core{opts=Opts}=St0) -> - St1 = case member(no_binaries, Opts) of - false -> St0; - true -> add_error(L, no_binaries, St0) - end, - try expr_bin(Es0, lineno_anno(L, St1), St1) of +expr({bin,L,Es0}, St0) -> + try expr_bin(Es0, lineno_anno(L, St0), St0) of {_,_,_}=Res -> Res catch throw:bad_binary -> - St2 = add_warning(L, bad_binary, St1), - LineAnno = lineno_anno(L, St2), + St = add_warning(L, bad_binary, St0), + LineAnno = lineno_anno(L, St), As = [#c_literal{anno=LineAnno,val=badarg}], {#icall{anno=#a{anno=LineAnno}, %Must have an #a{} module=#c_literal{anno=LineAnno,val=erlang}, name=#c_literal{anno=LineAnno,val=error}, - args=As},[],St2} + args=As},[],St} end; expr({block,_,Es0}, St0) -> %% Inline the block directly. @@ -618,10 +611,6 @@ expr({match,L,P0,E0}, St0) -> St = add_warning(L, nomatch, St2), {#icase{anno=#a{anno=Lanno}, args=[E2],clauses=[],fc=Fc},Eps,St}; - no_binaries -> - St = add_error(L, no_binaries, St2), - {#icase{anno=#a{anno=Lanno}, - args=[E2],clauses=[],fc=Fc},Eps,St}; Other when not is_atom(Other) -> {#imatch{anno=#a{anno=Lanno},pat=P2,arg=E2,fc=Fc},Eps,St2} end; @@ -1443,15 +1432,10 @@ pattern({cons,L,H,T}, St) -> ann_c_cons(lineno_anno(L, St), pattern(H, St), pattern(T, St)); pattern({tuple,L,Ps}, St) -> ann_c_tuple(lineno_anno(L, St), pattern_list(Ps, St)); -pattern({bin,L,Ps}, #core{opts=Opts}=St) -> - case member(no_binaries, Opts) of - false -> - %% We don't create a #ibinary record here, since there is - %% no need to hold any used/new annotations in a pattern. - #c_binary{anno=lineno_anno(L, St),segments=pat_bin(Ps, St)}; - true -> - throw(no_binaries) - end; +pattern({bin,L,Ps}, St) -> + %% We don't create a #ibinary record here, since there is + %% no need to hold any used/new annotations in a pattern. + #c_binary{anno=lineno_anno(L, St),segments=pat_bin(Ps, St)}; pattern({match,_,P1,P2}, St) -> pat_alias(pattern(P1, St), pattern(P2, St)). @@ -2116,21 +2100,15 @@ is_simp_bin(Es) -> %%% Handling of warnings. %%% --type err_desc() :: 'bad_binary' | 'no_binaries' | 'nomatch'. +-type err_desc() :: 'bad_binary' | 'nomatch'. -spec format_error(err_desc()) -> nonempty_string(). format_error(nomatch) -> "pattern cannot possibly match"; format_error(bad_binary) -> - "binary construction will fail because of a type mismatch"; -format_error(no_binaries) -> - "bit syntax is not allowed to be used when compatibility with a previous " - "version has been requested". + "binary construction will fail because of a type mismatch". add_warning(Line, Term, #core{ws=Ws,file=[{file,File}]}=St) when Line >= 0 -> St#core{ws=[{File,[{location(Line),?MODULE,Term}]}|Ws]}; add_warning(_, _, St) -> St. - -add_error(Line, Term, #core{es=Es,file=[{file,File}]}=St) -> - St#core{es=[{File,[{location(abs_line(Line)),?MODULE,Term}]}|Es]}. diff --git a/lib/compiler/test/error_SUITE.erl b/lib/compiler/test/error_SUITE.erl index cdd2434b25..4530313bb0 100644 --- a/lib/compiler/test/error_SUITE.erl +++ b/lib/compiler/test/error_SUITE.erl @@ -21,11 +21,11 @@ -include("test_server.hrl"). -export([all/1, - head_mismatch_line/1,r11b_binaries/1,warnings_as_errors/1]). + head_mismatch_line/1,warnings_as_errors/1]). all(suite) -> test_lib:recompile(?MODULE), - [head_mismatch_line,r11b_binaries,warnings_as_errors]. + [head_mismatch_line,warnings_as_errors]. %% Tests that a head mismatch is reported on the correct line (OTP-2125). head_mismatch_line(Config) when is_list(Config) -> @@ -42,37 +42,6 @@ get_compilation_errors(Config, Filename) -> ?line {error, [{_Name, E}|_], []} = compile:file(File, [return_errors]), E. -r11b_binaries(Config) when is_list(Config) -> - Ts = [{r11b_binaries, - <<" - t1(Bin) -> - case Bin of - _ when size(Bin) > 20 -> erlang:error(too_long); - <<_,T/binary>> -> t1(T); - <<>> -> ok - end. - - t2(<<_,T/bytes>>) -> - split_binary(T, 4). - - t3(X) -> - <<42,X/binary>>. - - t4(X) -> - <> = X, - N. - ">>, - [r11], - {error, - [{5,v3_core,no_binaries}, - {6,v3_core,no_binaries}, - {9,v3_core,no_binaries}, - {13,v3_core,no_binaries}, - {16,v3_core,no_binaries}], - []} }], - ?line [] = run(Config, Ts), - ok. - warnings_as_errors(Config) when is_list(Config) -> Ts = [{warnings_as_errors, <<" diff --git a/lib/compiler/test/test_lib.erl b/lib/compiler/test/test_lib.erl index 382839d919..43d2cacd59 100644 --- a/lib/compiler/test/test_lib.erl +++ b/lib/compiler/test/test_lib.erl @@ -57,7 +57,6 @@ opt_opts(Mod) -> (no_new_apply) -> true; (no_gc_bifs) -> true; (no_stack_trimming) -> true; - (no_binaries) -> true; (debug_info) -> true; (_) -> false end, Opts). -- cgit v1.2.3