aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler
AgeCommit message (Collapse)Author
2017-01-17Merge branch 'egil/cuddle-tests' into maintBjörn-Egil Dahlberg
* egil/cuddle-tests: stdlib: Increase timetrap for rand_SUITE common_test: Increase timetrap for cth_hooks_SUITE compiler: Increase timetrap timeouts for lc_SUITE
2017-01-12Makefile: Warn for missings specBjörn Gustavsson
2017-01-12Add specs for the beam_*:module/2 functionsBjörn Gustavsson
2017-01-12beam_trim: Add types and specsBjörn Gustavsson
2017-01-12beam_listing: Add types and specsBjörn Gustavsson
2017-01-12beam_jump: Add types and specsBjörn Gustavsson
2017-01-12beam_except: Add types and specsBjörn Gustavsson
2017-01-12beam_dict: Add missing types and specsBjörn Gustavsson
2017-01-12beam_clean: Add types and specsBjörn Gustavsson
2017-01-12beam_bsm: Add missing types and specsBjörn Gustavsson
Also slightly refactor the code to simplify the types.
2017-01-12v3_codegen: Add missing types and specsBjörn Gustavsson
2017-01-12sys_pre_attributes: Correct and add missing types and specsBjörn Gustavsson
2017-01-12core_scan: Add missing types and specsBjörn Gustavsson
2017-01-12compile: Add missing types and specsBjörn Gustavsson
2017-01-12cerl: Add missing types and specsBjörn Gustavsson
2017-01-12v3_kernel_pp: Correct spec for format/1Björn Gustavsson
2017-01-12v3_life: Add types and specsBjörn Gustavsson
2017-01-12v3_life.hrl: Add types for all fieldsBjörn Gustavsson
2017-01-12beam_utils: Add types and specsBjörn Gustavsson
2017-01-12beam_asm: Add common types to describe operandsBjörn Gustavsson
2017-01-12sys_pre_attributes: Remove unnecessary flexibilityBjö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-12beam_dict: Simplify the internal format of the lambda tableBjö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-12Merge 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-11compiler: Do not spawn process when dialyzingHans 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-10Improve compilation speed for huge literal case expressionsBjö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-15compile: Reduce memory consumption during compilationBjö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-14Merge tag 'OTP-19.2'Dan Gudmundsson
=== OTP-19.2 === Changed Applications: - common_test-1.13 - compiler-7.0.3 - crypto-3.7.2 - dialyzer-3.0.3 - edoc-0.8.1 - erl_docgen-0.6.1 - erl_interface-3.9.2 - erts-8.2 - eunit-2.3.2 - hipe-3.15.3 - inets-6.3.4 - kernel-5.1.1 - mnesia-4.14.2 - observer-2.3 - odbc-2.12 - parsetools-2.1.4 - public_key-1.3 - runtime_tools-1.11 - sasl-3.0.2 - ssh-4.4 - ssl-8.1 - stdlib-3.2 - syntax_tools-2.1.1 - tools-2.9 - wx-1.8 Unchanged Applications: - asn1-4.0.4 - cosEvent-2.2.1 - cosEventDomain-1.2.1 - cosFileTransfer-1.2.1 - cosNotification-1.2.2 - cosProperty-1.2.1 - cosTime-1.2.2 - cosTransactions-1.3.2 - debugger-4.2.1 - diameter-1.12.1 - eldap-1.2.2 - et-1.6 - gs-1.6.2 - ic-4.4.2 - jinterface-1.7.1 - megaco-3.18.1 - orber-3.8.2 - os_mon-2.4.1 - otp_mibs-1.1.1 - percept-0.9 - reltool-0.7.2 - snmp-5.2.4 - typer-0.9.11 - xmerl-1.3.12 * tag 'OTP-19.2': Updated OTP version Prepare release Conflicts: OTP_VERSION
2016-12-09beam_type: Minimize number of regs in test_heap instructionsBjö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-09Prepare releaseErlang/OTP
2016-12-07Add option 'deterministic' for reproducible buildsBjö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-07Merge 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-07Update copyright-yearErlang/OTP
2016-12-02Merge 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-01compiler: Add regression testsBjörn-Egil Dahlberg
2016-12-01compiler: Optimize maps pattern matchingBjörn-Egil Dahlberg
2016-11-29Make warn_export_all the defaultRichard Carlsson
2016-11-29warn_obsolete_guard is already defaultRichard Carlsson
Update compiler documentation and remove superfluous erlc flags.
2016-11-28Merge 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-23Make use of the Header feature in yeccRichard Carlsson
2016-11-23Update obsolete author e-mailsRichard Carlsson
2016-11-23Correct copyright info on cerl-related filesRichard Carlsson
2016-11-23compiler: Test repeated map key warningsBjörn-Egil Dahlberg
2016-11-23compiler: Warn for repeated identical map keysBjö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-23Merge 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-18compile_SUITE: Make sure that guards are optimizedBjörn Gustavsson
Guards should use the more efficient 'test' instructions, not 'bif' instructions. Add a test to make sure that the optimizations don't degrade. We do have to keep an exception list for functions where we can't replace all 'bif' calls with 'test' instructions. We try to keep that list a short as practically possible.
2016-11-18beam_dead: Remove redundant 'or' instructionBjö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-18beam_dead: Remove redundant 'bif' instructionsBjö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-18Add test using LFE-generated Core Erlang modulesBjörn Gustavsson
Ensure that correct (not necessarily optimal) code is generated for Core Erlang code not originating from v3_core.
2016-11-18Remove beam_boolBjörn Gustavsson
The guard optimizations in v3_kernel has removed the need for beam_bool.
2016-11-18v3_kernel: Generate optimized code for guardsBjö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 $