Age | Commit message (Collapse) | Author | |
---|---|---|---|
2017-01-12 | core_scan: Add missing types and specs | Björn Gustavsson | |
2017-01-12 | compile: Add missing types and specs | Björn Gustavsson | |
2017-01-12 | cerl: Add missing types and specs | Björn Gustavsson | |
2017-01-12 | v3_kernel_pp: Correct spec for format/1 | Björn Gustavsson | |
2017-01-12 | v3_life: Add types and specs | Björn Gustavsson | |
2017-01-12 | v3_life.hrl: Add types for all fields | Björn Gustavsson | |
2017-01-12 | beam_utils: Add types and specs | Björn Gustavsson | |
2017-01-12 | beam_asm: Add common types to describe operands | Björn Gustavsson | |
2017-01-12 | sys_pre_attributes: Remove unnecessary flexibility | Björn Gustavsson | |
The compiler passes always Options as list to parse_transform/2. There is no need accept a non-list. There is also no need to handle an improper Options list. The compiler itself will crash if the Options list is improper. | |||
2017-01-12 | beam_dict: Simplify the internal format of the lambda table | Björn Gustavsson | |
Since Index =:= OldIndex and OldUniq =:= 0, there is no need to store OldIndex and OldUniq in the internal data structure for the lambda table. | |||
2017-01-12 | Merge branch 'maint' | Hans Bolinder | |
* maint: dialyzer: Compact 'file' annotations in Core code dialyzer: Try to reduce memory usage dialyzer: Use less memory when translating contracts dialyzer: Use maps instaed of dict dialyzer: Use maps instead of dict for module contracts map dialyzer: Compress a few more ETS tables dialyzer: Optimize memory consumption dialyzer: Reduce memory consumption during 'remote' phase dialyzer: Update code for finding parallelism compiler: Do not spawn process when dialyzing dialyzer: Reduce ETS usage during the typesig phase dialyzer: Optimize graph condensation dialyzer: Do not send full PLTs as messages | |||
2017-01-11 | compiler: Do not spawn process when dialyzing | Hans Bolinder | |
Memory consumption is reduced during the compilation phase by keeping the Core parse tree shared. In particular the file annotation takes a lot of memory when not shared. | |||
2017-01-10 | Improve compilation speed for huge literal case expressions | Björn Gustavsson | |
Code with huge literal case expressions such as the following would compile very slowly: case "Very long literal string (thousands of characters)..." of . . . end. The reason is that in the case optimization each character in the string would be handled individually. Fix this bug by handling literals all at once. | |||
2016-12-15 | compile: Reduce memory consumption during compilation | Björn Gustavsson | |
The compiler would keep the data structures for two compiler passes in memory. That could increase the maximum amount of memory that the compiler uses, and could also have a negative impact on performance (terms that would not be used again would be copied by a garbage collection). Here is an example that shows how the previous version of the code could get captured: a_compiler_pass(Mod, St) -> case Mod:module(St#compile.code, St#compile.options) of {ok,Code} -> {ok,St#compile{code=Code}}; ... The reference to the code from the previous pass will only be released when St is updated. We can avoid the problem by passing the current version of the code as a function argument: a_compiler_pass(Mod, Code0, St) -> case Mod:module(Code0, St#compile.options) of {ok,Code} -> {ok,Code,St}; ... In practice, this change does not seem to significantly speed up the compiler, but it does not do any harm either. It should help dialyzer in situations when dialyzer compiles several large modules at the same time. | |||
2016-12-09 | beam_type: Minimize number of regs in test_heap instructions | Björn Gustavsson | |
The beam_type may pass move and recalculates test_heap instructions. The number of live registers are not always the lowest. Minimize the number of registers by running beam_utils:live_opt/1 one more time. | |||
2016-12-07 | Add option 'deterministic' for reproducible builds | Björn Gustavsson | |
Add the option 'deterministic' to make it easier to achieve reproducible builds. This option omits the {options,...} and {source,...} tuples in M:module_info(compile), because those options may contain absolute paths. The author of ERL-310 suggested that only compiler options that may contain absolute paths (such as {i,...}) should be excluded. But I find it confusing to keep only some options. Alternatives considered: Always omitting this information. Since this information has been available for a long time, that would probably break some workflows. As an example that some people care about {source,...}, 2d785c07fbf9 made it possible to give a compiler option to set {source,...}. ERL-310 | |||
2016-12-07 | Merge branch 'maint' | Dan Gudmundsson | |
* maint: Update copyright-year Conflicts: lib/dialyzer/src/dialyzer.hrl lib/dialyzer/src/dialyzer_options.erl lib/dialyzer/test/opaque_SUITE_data/src/recrec/dialyzer.hrl lib/dialyzer/test/opaque_SUITE_data/src/recrec/dialyzer_races.erl lib/hipe/icode/hipe_icode.erl lib/hipe/main/hipe.erl lib/hipe/main/hipe.hrl.src lib/hipe/main/hipe_main.erl | |||
2016-12-07 | Update copyright-year | Erlang/OTP | |
2016-12-02 | Merge branch 'egil/compiler/opt-maps-pattern-matching/OTP-14072' | Björn-Egil Dahlberg | |
* egil/compiler/opt-maps-pattern-matching/OTP-14072: compiler: Add regression tests compiler: Optimize maps pattern matching compiler: Allow for unaligned match argument in value groups | |||
2016-12-01 | compiler: Optimize maps pattern matching | Björn-Egil Dahlberg | |
2016-11-28 | Merge branch 'egil/compiler/maps-warn-repeated-keys/OTP-14058' | Björn-Egil Dahlberg | |
* egil/compiler/maps-warn-repeated-keys/OTP-14058: compiler: Test repeated map key warnings compiler: Warn for repeated identical map keys | |||
2016-11-23 | Make use of the Header feature in yecc | Richard Carlsson | |
2016-11-23 | Update obsolete author e-mails | Richard Carlsson | |
2016-11-23 | Correct copyright info on cerl-related files | Richard Carlsson | |
2016-11-23 | compiler: Warn for repeated identical map keys | Björn-Egil Dahlberg | |
A map expression such as, #{'a' => 1, 'b' => 2, 'a' => 3} will produce a warning for the repeated key 'a'. | |||
2016-11-23 | Merge branch 'maint' | Björn Gustavsson | |
* maint: Update primary bootstrap document {yield/nb_yield}() limitation Suppress warnings from v3_kernel when inlining is turned on | |||
2016-11-18 | beam_dead: Remove redundant 'or' instruction | Björn Gustavsson | |
In practice, this optimization will only apply to contrived guards that are almost never used in real applications. The only reason we add this optimization is to help approach the goal of zero tolerance for 'bif' instructions instead of 'test' instructions in guards. | |||
2016-11-18 | beam_dead: Remove redundant 'bif' instructions | Björn Gustavsson | |
A 'bif' or 'gc_bif' instruction is redundant if it has the same failure label as a 'jump' instruction immediately following it. There is no need to test for liveness of the destination register, because the code at the failure label cannot safely assume that the destination register is initialized. See the comments in the code for further details. In practice, this optimization will only apply to contrived guards that are almost never used in real applications. The only reason we add this optimization is to help approach the goal of zero tolerance for 'bif' instructions instead of 'test' instructions in guards. | |||
2016-11-18 | Remove beam_bool | Björn Gustavsson | |
The guard optimizations in v3_kernel has removed the need for beam_bool. | |||
2016-11-18 | v3_kernel: Generate optimized code for guards | Björn Gustavsson | |
The compiler produces poor code for complex guard expressions with andalso/orelse. Here is an example from the filename module: -define(IS_DRIVELETTER(Letter),(((Letter >= $A) andalso (Letter =< $Z)) orelse ((Letter >= $a) andalso (Letter =< $z)))). skip_prefix(Name, false) -> Name; skip_prefix([L, DrvSep|Name], DrvSep) when ?IS_DRIVELETTER(L) -> Name; skip_prefix(Name, _) -> Name. beam_bool fails to simplify the code for the guard, leaving several 'bif' instructions: {function, skip_prefix, 2, 49}. {label,48}. {line,[{location,"filename.erl",187}]}. {func_info,{atom,filename},{atom,skip_prefix},2}. {label,49}. {test,is_ne_exact,{f,52},[{x,1},{atom,false}]}. {test,is_nonempty_list,{f,52},[{x,0}]}. {get_list,{x,0},{x,2},{x,3}}. {test,is_nonempty_list,{f,52},[{x,3}]}. {get_list,{x,3},{x,4},{x,5}}. {bif,'=:=',{f,52},[{x,1},{x,4}],{x,6}}. {test,is_ge,{f,50},[{x,2},{integer,65}]}. {bif,'=<',{f,52},[{x,2},{integer,90}],{x,7}}. {test,is_eq_exact,{f,51},[{x,7},{atom,false}]}. {test,is_ge,{f,50},[{x,2},{integer,97}]}. {bif,'=<',{f,52},[{x,2},{integer,122}],{x,7}}. {jump,{f,51}}. {label,50}. {move,{atom,false},{x,7}}. {label,51}. {bif,'=:=',{f,52},[{x,7},{atom,true}],{x,7}}. {test,is_eq_exact,{f,52},[{x,6},{atom,true}]}. {test,is_eq_exact,{f,52},[{x,7},{atom,true}]}. {move,{x,5},{x,0}}. return. {label,52}. return. We can add optimizations of guard tests to v3_kernel to achive a better result: {function, skip_prefix, 2, 49}. {label,48}. {line,[{location,"filename.erl",187}]}. {func_info,{atom,filename},{atom,skip_prefix},2}. {label,49}. {test,is_ne_exact,{f,51},[{x,1},{atom,false}]}. {test,is_nonempty_list,{f,51},[{x,0}]}. {get_list,{x,0},{x,2},{x,3}}. {test,is_nonempty_list,{f,51},[{x,3}]}. {get_list,{x,3},{x,4},{x,5}}. {test,is_eq_exact,{f,51},[{x,1},{x,4}]}. {test,is_ge,{f,51},[{x,2},{integer,65}]}. {test,is_lt,{f,50},[{integer,90},{x,2}]}. {test,is_ge,{f,51},[{x,2},{integer,97}]}. {test,is_ge,{f,51},[{integer,122},{x,2}]}. {label,50}. {move,{x,5},{x,0}}. return. {label,51}. return. Looking at the STDLIB application, there were 112 lines of BIF calls in guards that beam_bool failed to convert to test instructions. This commit eliminates all those BIF calls. Here is how I counted the instructions: $ PATH=$ERL_TOP/bin:$PATH erlc -I ../include -I ../../kernel/include -S *.erl $ grep "bif,'[=<>]" *.S | grep -v f,0 dets.S: {bif,'=:=',{f,547},[{x,4},{atom,read_write}],{x,4}}. dets.S: {bif,'=:=',{f,547},[{x,5},{atom,saved}],{x,5}}. dets.S: {bif,'=:=',{f,589},[{x,5},{atom,read}],{x,5}}. . . . $ grep "bif,'[=<>]" *.S | grep -v f,0 | wc 112 224 6765 $ | |||
2016-11-18 | Suppress warnings from v3_kernel when inlining is turned on | Björn Gustavsson | |
v3_kernel may produce unwanted and confusing warnings for code that has been inlined with the new inliner (cerl_inline). Consider this code: -compile(inline). compute1(X) -> add(X, 0). compute2(X, Y) -> add(X, Y). add(1, 0) -> 1; add(1, Y) -> %% "this clause cannot match..." 1 + Y; add(X, Y) -> X + Y. v3_kernel warns because add/2 has been inlined into compute1/1 and only the first clause in add/2 will match. But the other clauses are needed when add/2 is inlined into compute2/2, so the user cannot do anything to eliminate the warning (short of manually inlining add/2, defeating the purpose of the 'inline' option). The warning would be reasonable if compute2/2 didn't exist, but it would be too complicated for the compiler to figure whether a warning make sense or not. Therefore, suppress all warnings generated by v3_kernel if cerl_inline has been run. ERL-301 | |||
2016-11-13 | sys_core_fold: Remove unnecessary calls to opt_bool_case/1 | Björn Gustavsson | |
The fixpoint iteration added in 05130e48 makes those calls superfluous. | |||
2016-11-03 | Merge branch 'gandrade/fmod/PR-1216/OTP-14000' | Björn Gustavsson | |
* gandrade/fmod/PR-1216/OTP-14000: Add test cases for math:fmod/2 BIF Support math:fmod/2 BIF on compiler Add math:fmod/2 BIF | |||
2016-11-02 | Support math:fmod/2 BIF on compiler | Guilherme Andrade | |
2016-10-28 | sys_core_fold: Use less effort optimizing not in lets | Björn Gustavsson | |
There are two calls opt_not_in_let(). Since 05130e4855 introduced iteration to a fixpoint, only the first call is needed. Removing the redundant call will slightly speed up compilation. | |||
2016-10-28 | sys_core_fold: Eliminate complaint from core_lint | Björn Gustavsson | |
2016-10-28 | Merge branch 'maint' | Björn Gustavsson | |
* maint: Don't copy funs into guards | |||
2016-10-27 | Don't copy funs into guards | Björn Gustavsson | |
Funs must not be created in guards. The instruction for creating a fun clobbers all X registers, which is a bad thing to do in a guard. | |||
2016-10-26 | Merge branch 'maint' | Björn Gustavsson | |
* maint: Don't let inline_list_funcs degrade optimizations | |||
2016-10-24 | Don't let inline_list_funcs degrade optimizations | Björn Gustavsson | |
83199af0263 refactored sys_core_fold to break out the code for the inline_lists_funcs option to its own module. Unfortunately, it also accidentally turned off compile-time evaluation of calls to BIFs with wholly or partial constant arguments. For example, the code for the following funtion gets much worse when inline_list_funcs is used: b() -> R0 = #r{}, R1 = setelement(1+2, R0, "deux"), R2 = setelement(1+3, R1, "trois"), R3 = setelement(1+5, R2, "cinq"), R4 = setelement(1+2, R3, "DEUX"), R4. ERL-285 | |||
2016-10-07 | Merge branch 'maint' | Björn Gustavsson | |
* maint: beam_bsm: Eliminate unsafe optimization | |||
2016-10-06 | beam_bsm: Eliminate unsafe optimization | Björn Gustavsson | |
The following code causes a compiler failure: first_after(Data, Offset) -> case byte_size(Data) > Offset of false -> {First, Rest} = {ok, ok}, ok; true -> <<_:Offset/binary, Rest/binary>> = Data, %% 'Rest' saved in y(0) before the call. {First, _} = match_first(Data, Rest), %% When beam_bsm sees the code, the following line %% which uses y(0) has been optimized away. {First, Rest} = {First, Rest}, First end. match_first(_, <<First:1/binary, Rest/binary>>) -> {First, Rest}. Here is the error message from beam_validator: t: function first_after/2+15: Internal consistency check failed - please report this bug. Instruction: {call,2,{f,7}} Error: {multiple_match_contexts,[{x,1},0]}: Basically, what happens is that at time of code generation, the variable 'Rest' is needed after the call to match_first/2 and is therefore saved in y(0). When beam_bsm (a late optimization pass) sees the code, the use of y(0) following the call to match_first/2 has been optimized away. beam_bsm therefore assumes that the delayed sub-binary creation is safe. (Actually, it is safe, but beam_validator does not realize it.) The bug was caused by two separate commits: e199e2471a reduced the number of special cases to handle in BEAM optimization passed by breaking apart the tail-recursive call instructions (call_only and call_last) into separate instructions. Unfortunately, the special handling for tail calls was lost, which resulted in worse code (i.e. the delayed sub-binary creation optimization could not be applied). e1aa422290 tried to compensate, but did so in a way that was not always safe. Teaching beam_validator that this kind of code is safe would be expensive. Instead, we will undo the damage caused by the two commits. Re-introduce the special handling of tail-recursive calls in beam_bsm that was lost in the first commit. (Effectively) revert the change in the second commit. ERL-268 | |||
2016-10-05 | Merge branch 'maint' | Björn Gustavsson | |
* maint: Update primary bootstrap beam_block: Avoid unsafe inclusion of get_map_elements in blocks | |||
2016-10-05 | beam_block: Avoid unsafe inclusion of get_map_elements in blocks | Björn Gustavsson | |
c2035ebb8b restricted the get_map_elements instruction so that it could only occur at the beginning of a block. It turns out that including it anywhere in a block is unsafe. Therefore, never put get_map_elements instruction in blocks. (Also remove the beam_utils:join_even/2 function since it is no longer used.) ERL-266 | |||
2016-09-29 | Merge branch 'rickard/time-unit/OTP-13831' | Rickard Green | |
* rickard/time-unit/OTP-13831: Replace usage of deprecated time units | |||
2016-09-29 | compiler: Allow for unaligned match argument in value groups | Björn-Egil Dahlberg | |
At this stage in match compilation we are allowed to change the alignment of arguments and constructors as long as they are the same aligned in the same group. | |||
2016-09-29 | Merge branch 'josevalim/compiler/at-var/PR-1081/OTP-13924' | Björn Gustavsson | |
* josevalim/compiler/at-var/PR-1081/OTP-13924: Use @ in variable names generated by core and kernel | |||
2016-09-26 | sys_core_fold: Run optimizations to a fixpoint | Björn Gustavsson | |
Run the optimizations until a fixpoint is reached, or until the maximum iteration count is reached. The hope is that in the future we can many small optimizations instead of optimizations that try to do everything in one pass. This change allows us to remove the ad-hoc calls to expr/2 to run more optimizations on a piece of code. | |||
2016-09-26 | sys_core_fold: Improve case optimization | Björn Gustavsson | |
The optimization that avoids building a tuple in a case expression would not work if any clause matched a tuple as in the following example: f(A, B) -> case {A,B} of {<<X>>,Y} -> {X,Y} end. The generated Core Erlang code would look like this (note the tuples in the case expression and the pattern): 'f'/2 = fun (_cor1,_cor0) -> case {_cor1,_cor0} of <{#{#<X>(8,1,'integer',['unsigned'|['big']])}#,Y}> when 'true' -> {X,Y} . . . end It is expected that the code should look like this (note that tuples have been replaced with "values"): 'f'/2 = fun (_cor1,_cor0) -> %% Line 5 case <_cor1,_cor0> of <#{#<X>(8,1,'integer',['unsigned'|['big']])}#,Y> -> {X,Y} . . . end While at it, also fix bugs in the handling of pattern with aliases. The bindings were produced in the wrong order (creating 'let's with referring to free variables), but in most cases the incorrect bindings were discarded later without causing any harm. | |||
2016-09-26 | sys_core_fold: Correct scope verification code | Björn Gustavsson | |
703e8f4490bf broke the scope verification code (by calling ordsets:is_subset/2 with an unsorted second argument). While we are it, also optimize the verification function by avoiding converting the map to a sorted list. |