aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/src/beam_utils.erl
AgeCommit message (Collapse)Author
2015-06-18Change license text to APLv2Bruce Yinhe
2015-04-29beam_utils: Re-use the local helper function drop_labels/1Björn Gustavsson
In 8470558, the drop_labels/1 function was added to beam_utils as a minor optimization. Since the function is already available, we might as well use it in index_label/3 too.
2015-04-29beam_utils: Teach check_liveness/3 to understand get_map_elementsBjörn Gustavsson
Understanding get_map_elements improves the stack trimming done by beam_trim.
2015-04-29beam_utils: Be less conservative about liveness for exit instructionsBjörn Gustavsson
beam_utils used to be overly conservative about liveness for exit instructions such as: call_ext erlang:exit/1 beam_utils would consider all y registers to be used, to avoid overwriting a catch or try tag. That does not seem to be a real risk. However, we miss opportunities for stack trimming if we consider y registers used by an exit instruction.
2015-04-22beam_utils: Optimize index_labels_1/2Björn Gustavsson
The execution time for beam_utils:index_labels_1/2 is among the longest in the beam_bool, beam_bsm, beam_receive, and beam_trim compiler passes. Therefore it is worthwhile to do the minor optimization of replacing a call to lists:dropwhile/2 with a special-purpose drop_labels function.
2015-03-09Introduce '%live' annotations with a complete register mapBjörn Gustavsson
As a preparation for fixing a bug, introduce a complete register map in the '%live' annotations.
2015-02-18beam_utils: Correct test for has_map_fields in is_pure_test/1Björn Gustavsson
The has_map_fields test was not recognized in is_pure_test/1, because beam_a has rewritten the {list,_} part of instruction.
2015-01-23Merge branch 'egil/fix-maps-compiler-coverage/OTP-12425'Björn-Egil Dahlberg
* egil/fix-maps-compiler-coverage/OTP-12425: compiler: Rename util function to adhere to name policy compiler: Remove get_map_elements label check in blocks compiler: Remove unnecassary guard for get_map_elements compiler: Remove dead code in beam_flatten compiler: Increase Maps code coverage
2015-01-21beam_utils: Remove unreachable clauses in live_opt/4Björn Gustavsson
beam_utils:live_opt() is only invoked on code that has been blockified by beam_block. Therefore the allocate/3 and allocate_heap/4 instructions only occur in their transformed form inside a block. While we are it, correct a comment. 'asm' has been replaced by 'from_asm'.
2015-01-12compiler: Rename util function to adhere to name policyBjörn-Egil Dahlberg
* beam_utils:joineven/1 -> beam_utils:join_even/1 * beam_utils:split_even/1 -> beam_utils:split_even/1
2014-08-26compiler: Use variables in Map beam assmeblerBjörn-Egil Dahlberg
2014-03-04Handle nil as a wait_timeout argument in beam_utils:live_opt/4Anthony Ramine
Reported-by: Ulf Norell
2014-02-13compiler: Change map instructions for fetching valuesBjörn-Egil Dahlberg
* Combine multiple get values with one instruction * Combine multiple check keys with one instruction
2014-01-28erts: Add the type-testing guard BIF is_map/1Björn-Egil Dahlberg
To add a type-testing guard BIF, the following steps are needed: * The BIF itself is added to bif.tab (note that it should be declared using "ubif", not "bif"), and its implementation to erl_bif_op.c. * erl_internal must be modified in 3 places: The type test must be recognized as guard BIF, as a type test, and it must be auto-imported. * There must be an instruction that implements the same type test as the BIF (it will be used in guards). beam_utils:bif_to_test/3 must be updated to recognize the new guard BIF.
2013-12-13Add missing recv_set, recv_mark and '%' to BEAM live annotationAnthony Ramine
2013-06-12Update copyright yearsBjörn-Egil Dahlberg
2013-05-29compiler: Correct liveness optimization for wait/1Björn Gustavsson
The live optimization in beam_utils:live_opt/4 did not take into account that the wait/1 instruction *never* falls through to the next instruction (it has the same effect on the control flow as the jump/1 instruction).
2013-03-19Fix slow compilation of complex guardsBjörn Gustavsson
beam_utils:is_not_used_at/3 could be very slow for complex guards, because the cached result for previously encountered labels were neither used nor updated within blocks. Reported-by: Magnus Müller
2012-11-26beam_utils: Improve is_not_used/3 for bit syntax matchingBjörn Gustavsson
2012-10-10Break apart tail-recursive call instructionsBjörn Gustavsson
Somewhat reduce the code bloat by eliminating special cases.
2012-10-10Represent the 'send' instruction as a call_ext/2 instructionBjörn Gustavsson
Somewhat reduce code bloat.
2012-10-10Rewrite select_val and select_tuple_arity to a select instructionBjörn Gustavsson
Eliminate some code bloat.
2012-10-09Rewrite binary creation instructions to bs_init instructionsBjörn Gustavsson
Rewrite the five binary creation instructions to a bs_init instruction, in order to somewhat reduce code bloat.
2012-10-09Rewrite bs_add, bs_utf*_size to BIF instructions in optimizationsBjörn Gustavsson
We can remove some code bloat by handling the special instructions as BIF instructions in the optimization passes. Also note that bs_utf*_size was not handled by beam_utils:check_liveness/3 (meaning the conservative answer instead of the correct answer would be returned).
2012-10-09Rewrite bs_put* instructions to a generic bs_put instructionBjörn Gustavsson
Seven bs_put_* instructions can be combined into one generic bs_put instruction to avoid some code bloat. That will also improve some optimizations (such as beam_trim) that did not handle all bs_put* variants.
2012-10-09beam_utils: Correct usage calculations for GC BIFs in blocksBjörn Gustavsson
The usage calculation only looked at the allocation in GC BIFs, not at the source and destination registers. Also, if there is a failure label, make sure that we test whether the register can be used there.
2012-10-09beam_utils:live_opt/1: Correct liveness calculation for 'try'Björn Gustavsson
The liveness at the failure label should be ignored, because if there is an exception, all x registers will be killed.
2012-10-09beam_utils: Extend live_opt/1 to recalculate live registers in allocsBjörn Gustavsson
The code generator uses conservative liveness information. Therefore the number of live registers in allocation instructions (such as test_heap/2) may be too high. Use the actual liveness information to lower the number of live register if it's too high. The main reason we want to do this is to enable more optimizations that depend on liveness analysis, such as the beam_bool and beam_dead passes.
2012-10-09beam_utils: Check liveness in catches and try/catch blocksBjörn Gustavsson
Less conservative liveness analysis allows more optimizations to be applied (such as the ones in beam_bool).
2012-08-15beam_utils:live_opt/1: Correct handling of try_case_end/1Björn Gustavsson
Liveness for the try_case_end/1 instruction should be calculated in the same way as for the case_end/1 instruction.
2012-03-30Update copyright yearsBjörn-Egil Dahlberg
2012-01-18compiler: Correct live calculation when get/1 is used in try...catchBjörn Gustavsson
In the following code excerpt, the instruction marked below was incorrectly removed: . . . {'try',{y,2},{f,TryCaseLabel}}. {bif,get,{f,0},[{x,0}],{x,0}}. {move,{x,1},{y,0}}. {move,{x,3},{y,1}}. <======= Incorrectly removed {jump,{f,TryEndLabel}}. {label,TryEndLabel}. {try_end,{y,2}}. {deallocate,3}. return. {label,TryCaseLabel}. {try_case,{y,2}}. . . . beam_utils indicated that {y,1} was not used at TryEndLabel, which by itself is correct. But it is still not safe to remove the instruction, because {y,1} might be used at TryCaseLabel if an exception occurs. Noticed-by: Eric Merritt
2011-12-09Update copyright yearsBjörn-Egil Dahlberg
2011-08-16compiler: Generate line instructionsBjörn Gustavsson
2010-12-02beam_utils: Fix check_liveness/3 for receive loopsBjörn Gustavsson
Sometimes the beam_bool pass wants to know whether an y register will be killed by the code that follows and will do (effectively): beam_utils:is_killed({y,Y}, Code, L) When asked to calculate the liveness for an y register, beam_utils:is_killed/3 will loop forever if the code includes a receive loop. Since this rarely occurs, fix the problem in the simplest and most conservative way. Reported-by: Christopher Williams
2010-11-26beam_utils: Fix liveness analysis for gc_bif instructionsBjörn Gustavsson
When gc_bif instructions occurred outside of a block, beam_utils:check_liveness/3 did not take into account that the instruction could do a garbage collection, and could falsely report that an x register would be killed. That could cause the beam_dead pass to make the code unsafe by removing the assignment to an x register that would subsequently be referenced by the garbage collector. Reported-by: Christopher Williams
2010-05-21Merge branch 'bg/compiler-cover-and-clean' into devErlang/OTP
* bg/compiler-cover-and-clean: v3_life: Remove clause that cannot match in match_fail/3 v3_life tests: Cover exception handling code in v3_life:function/1 beam_type: Remove redundant clause v3_core tests: Cover make_bool_switch_guard/5 v3_core tests: Cover handling of pattern aliases v3_core: Remove a clause in is_simple/1 that cannot match v3_core: Remove unused support for generating compilation errors Remove stray support for the put_literal/2 instruction Remove stray support for the bs_bits_to_bytes2/2 instruction Remove the bs_bits_to_bytes/3 instruction Cover handling of 'math' BIFs beam_bool: Remove a clause in live_regs/1 that cannot match beam_bool: Cover handling of bs_context_to_binary in initialized_regs/2 beam_bool: Remove a clause in initialized_regs/2 that cannot match beam_block: Remove a clause that will never be executed erts: Stop supporting non-literal empty tuples compile: Remove code that is only executed on Solaris Do not cover-analyze core_scan core_SUITE_data: Don't ignore *.core files in this directory OTP-8636 bg/compiler-cover-and-clean
2010-05-20Remove stray support for the bs_bits_to_bytes2/2 instructionBjörn Gustavsson
bs_bits_to_bytes2/2 was an experimental instruction added in R11, but was removed in R12. Although the beam_disasm and beam_validator modules do support instructions in older releases, there is no reason to have them support experimental instructions.
2009-11-20The R13B03 release.OTP_R13B03Erlang/OTP