aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/src/beam_dead.erl
AgeCommit message (Collapse)Author
2013-01-25Update copyright yearsBjörn-Egil Dahlberg
2012-10-10Rewrite select_val and select_tuple_arity to a select instructionBjörn Gustavsson
Eliminate some code bloat.
2012-10-09Improve binary matching of literalsBjörn Gustavsson
The bs_match_string instruction is used to speed up matching of binary literals. For example, given this source code: foo1(<<1,2,3>>) -> ok. The matching part of the code will look like: {test,bs_start_match2,{f,1},1,[{x,0},0],{x,0}}. {test,bs_match_string,{f,3},[{x,0},24,{string,[1,2,3]}]}. {test,bs_test_tail2,{f,3},[{x,0},0]}. Nice. However, if we do a simple change to the source code: foo2(<<1,2,3>>) -> ok; foo2(<<>>) -> error. the resulting matching code will look like (sligthly simplified): {test,bs_start_match2,{f,4},1,[{x,0},0],{x,0}}. {test,bs_get_integer2,{f,7},1,[{x,0},{integer,8},1,Flags],{x,1}}. {test,is_eq_exact,{f,8},[{x,1},{integer,1}]}. {test,bs_match_string,{f,6},[{x,0},16,{string,[2,3]}]}. {test,bs_test_tail2,{f,6},[{x,0},0]}. {move,{atom,ok},{x,0}}. return. {label,6}. {bs_restore2,{x,0},{atom,start}}. {label,7}. {test,bs_test_tail2,{f,8},[{x,0},0]}. That is, matching of the first byte is not combined into the bs_match_string instruction that follows. Fix this problem by allowing a bs_match_string instruction to be used if all clauses will match either the same integer literal or the empty binary.
2011-12-06Teach the compiler the 'no_dead' optionBjörn Gustavsson
To facilitate debugging of compiler bugs, teach the compiler the 'no_dead' option. Since the beam_dead pass used to do the necessary splitting of basic blocks to expose all labels, we must move that splitting into a separate pass that is always run.
2011-08-16compiler: Generate line instructionsBjörn Gustavsson
2011-05-20Update copyright yearsBjörn-Egil Dahlberg
2011-04-12beam_dead: Remove uncovered special case handling of empty blocksBjörn Gustavsson
There is never any empty blocks when beam_dead is invoked. Even if there were, they will be removed a little bit later in forward/4.
2011-04-12beam_dead: Remove uncovered clauses in binary matching optimizationBjörn Gustavsson
In the optimization of binary matching, it seems that two clauses cannot never be reached. Removing the clauses is safe, since that would only mean that an opportunity for an optimization is lost
2011-04-12beam_dead: Remove uncoverable case clause in update_value_dict/3Björn Gustavsson
Because the code generator (v3_codegen) would not include the same value more than once in a select_val/3 instruction and because a label can only be referenced by one select_val/3 instruction, there is no way that the correct value could already be in the gb_tree. (Even if it could happen, this change is safe because only opportunity for an optimization would be missed; incorrect code would not be generated.)
2011-04-12beam_dead: Remove code that cannot be covered in forward/4Björn Gustavsson
Since the optimizations in forward/4 already depends on some assumptions on how code is generated anyway, document the assumptions in a comment and remove the uncoverable code.
2010-06-02Merge branch 'bg/compiler' into devErlang/OTP
* bg/compiler: beam_peep: Remove optimization already done by beam_dead beam_dead: Combine is_eq_exact instructions into select_val instructions Evaluate is_record/3 at compile-time using type information Evaluate element/2 at compile-time using type information erl_expand_records: Replace is_record() with matching OTP-8668 bg/compiler The compiler optimizes record operations better.
2010-06-02beam_dead: Combine is_eq_exact instructions into select_val instructionsBjörn Gustavsson
Combine a sequence of chained is_eq_exact instructions into a select_val instruction.
2009-11-20The R13B03 release.OTP_R13B03Erlang/OTP