diff options
author | Björn Gustavsson <[email protected]> | 2012-10-10 16:00:04 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2012-10-10 16:00:04 +0200 |
commit | b16c127d4dc2bb070d6e98e5c4cdc38220708a13 (patch) | |
tree | 60e0fe128f9fe6d36354952d70f06463683a112d /lib/compiler/src/compile.erl | |
parent | 55358002ddfa9f19e4142677d1ad4bd0a1760c0a (diff) | |
parent | e1aa422290b09a68bd761cbd0e70bd48442009b3 (diff) | |
download | otp-b16c127d4dc2bb070d6e98e5c4cdc38220708a13.tar.gz otp-b16c127d4dc2bb070d6e98e5c4cdc38220708a13.tar.bz2 otp-b16c127d4dc2bb070d6e98e5c4cdc38220708a13.zip |
Merge branch 'bjorn/compiler/minor-optimization-polishing/OTP-10193'
* bjorn/compiler/minor-optimization-polishing/OTP-10193: (25 commits)
beam_bsm: Handle calls slightly better
Break apart tail-recursive call instructions
Represent the 'send' instruction as a call_ext/2 instruction
Rewrite select_val and select_tuple_arity to a select instruction
Rewrite binary creation instructions to bs_init instructions
Rewrite bs_add, bs_utf*_size to BIF instructions in optimizations
Rewrite bs_put* instructions to a generic bs_put instruction
Refactor removal of unused labels
Introduce the mandatory beam_a and beam_z passes
compile: Fix bug in selection of passes
beam_receive: Optimize receives using refs created by spawn_monitor/{1,3}
compile: Give a friendler error message if a parse transform cannot be found
beam_jump: Don't move a block which can be entered via a fallthrough
beam_jump: Fix broken optimization
v3_kernel: Fix match code for matched out segment size in multiple clauses
Improve binary matching of literals
v3_codegen: Combine adjacent bs_match_string instructions
beam_bool: Recognize more safe optimizations
beam_utils: Correct usage calculations for GC BIFs in blocks
beam_utils:live_opt/1: Correct liveness calculation for 'try'
...
Diffstat (limited to 'lib/compiler/src/compile.erl')
-rw-r--r-- | lib/compiler/src/compile.erl | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/lib/compiler/src/compile.erl b/lib/compiler/src/compile.erl index 0a368df5d6..df1af36eeb 100644 --- a/lib/compiler/src/compile.erl +++ b/lib/compiler/src/compile.erl @@ -224,6 +224,8 @@ format_error({delete_temp,File,Error}) -> [File,file:format_error(Error)]); format_error({parse_transform,M,R}) -> io_lib:format("error in parse transform '~s': ~p", [M, R]); +format_error({undef_parse_transform,M}) -> + io_lib:format("undefined parse transform '~s'", [M]); format_error({core_transform,M,R}) -> io_lib:format("error in core transform '~s': ~p", [M, R]); format_error({crash,Pass,Reason}) -> @@ -551,12 +553,12 @@ select_list_passes_1([{iff,Flag,{done,Ext}}|Ps], Opts, Acc) -> end; select_list_passes_1([{iff=Op,Flag,List0}|Ps], Opts, Acc) when is_list(List0) -> case select_list_passes(List0, Opts) of - {done,_}=Done -> Done; + {done,List} -> {done,reverse(Acc) ++ List}; {not_done,List} -> select_list_passes_1(Ps, Opts, [{Op,Flag,List}|Acc]) end; select_list_passes_1([{unless=Op,Flag,List0}|Ps], Opts, Acc) when is_list(List0) -> case select_list_passes(List0, Opts) of - {done,_}=Done -> Done; + {done,List} -> {done,reverse(Acc) ++ List}; {not_done,List} -> select_list_passes_1(Ps, Opts, [{Op,Flag,List}|Acc]) end; select_list_passes_1([P|Ps], Opts, Acc) -> @@ -630,7 +632,8 @@ kernel_passes() -> asm_passes() -> %% Assembly level optimisations. [{delay, - [{unless,no_postopt, + [{pass,beam_a}, + {unless,no_postopt, [{pass,beam_block}, {iff,dblk,{listing,"block"}}, {unless,no_except,{pass,beam_except}}, @@ -657,13 +660,11 @@ asm_passes() -> {iff,dtrim,{listing,"trim"}}, {pass,beam_flatten}]}, - %% If post optimizations are turned off, we still coalesce - %% adjacent labels and remove unused labels to keep the - %% HiPE compiler happy. - {iff,no_postopt, - [?pass(beam_unused_labels), - {pass,beam_clean}]}, + %% If post optimizations are turned off, we still + %% need to do a few clean-ups to code. + {iff,no_postopt,[{pass,beam_clean}]}, + {pass,beam_z}, {iff,dopt,{listing,"optimize"}}, {iff,'S',{listing,"S"}}, {iff,'to_asm',{done,"S"}}]}, @@ -850,6 +851,10 @@ foldl_transform(St, [T|Ts]) -> {error,Es,Ws} -> {error,St#compile{warnings=St#compile.warnings ++ Ws, errors=St#compile.errors ++ Es}}; + {'EXIT',{undef,_}} -> + Es = [{St#compile.ifile,[{none,compile, + {undef_parse_transform,T}}]}], + {error,St#compile{errors=St#compile.errors ++ Es}}; {'EXIT',R} -> Es = [{St#compile.ifile,[{none,compile,{parse_transform,T,R}}]}], {error,St#compile{errors=St#compile.errors ++ Es}}; @@ -1236,10 +1241,6 @@ random_bytes_1(N, Acc) -> random_bytes_1(N-1, [random:uniform(255)|Acc]). save_core_code(St) -> {ok,St#compile{core_code=cerl:from_records(St#compile.code)}}. -beam_unused_labels(#compile{code=Code0}=St) -> - Code = beam_jump:module_labels(Code0), - {ok,St#compile{code=Code}}. - beam_asm(#compile{ifile=File,code=Code0, abstract_code=Abst,mod_options=Opts0}=St) -> Source = filename:absname(File), |