Age | Commit message (Collapse) | Author | |
---|---|---|---|
2017-12-08 | Use the new syntax for retrieving stack traces | Björn Gustavsson | |
2017-12-04 | v3_kernel: Make #k_break{} consistent with the code it follows | Björn Gustavsson | |
v3_kernel could generate a #k_break{} with only one variable, even if the preceding code and succeding code expected more than one value. It happened to work anyway because the value returned from the break was not actually used. | |||
2017-10-27 | Eliminate the v3_life pass | Björn Gustavsson | |
The v3_life pass does not do enough to be worth being its own pass. Essentially it does two things: * Calculates life-time information starting from the annotations that v3_kernel provides. That part can be moved into v3_codegen. * Rewrites the Kernel Erlang records to similar plain tuples (for example, #k_cons{hd=Hd,tl=Tl} is rewritten to {cons,Hd,Tl}). That rewriting is not needed and can be eliminated. | |||
2017-10-21 | Optimize matching of literals for single-valued types | Björn Gustavsson | |
If a type only has one clause and if the pattern is literal, the matching can be done more efficiently by directly comparing with the literal. Example: find(String, "") -> String; find(String, <<>>) -> String; find(String, SearchPattern) -> . . . Without this optimization, the relevant part of the code would look this: {test,bs_start_match2,{f,3},2,[{x,1},0],{x,2}}. {test,bs_test_tail2,{f,4},[{x,2},0]}. return. {label,3}. {test,is_nil,{f,4},[{x,1}]}. return. {label,4}. . . . That is, if {x,1} is a binary, a match context will be built to test whether {x,1} is an empty binary. With the optimization, the code will look this: {test,is_eq_exact,{f,3},[{x,1},{literal,<<>>}]}. return. {label,3}. {test,is_nil,{f,4},[{x,1}]}. return. {label,4}. . . . | |||
2017-06-13 | v3_kernel: Keep orddicts sorted | Björn Gustavsson | |
2017-05-04 | Update copyright year | Raimo Niskanen | |
2017-04-25 | Store abstract code in the Dbgi chunk | José Valim | |
The new Dbgi chunk returns data in the following format: {debug_info_v1, Backend, Data} This allows compilers to store the debug info in different formats. In order to retrieve a particular format, for instance, Erlang Abstract Format, one may invoke: Backend:debug_info(erlang_v1, Module, Data, Opts) Besides introducing the chunk above, this commit also: * Changes beam_lib:chunk(Beam, [:abstract_code]) to read from the new Dbgi chunk while keeping backwards compatibility with old .beams * Adds the {debug_info, {Backend, Data}} option to compile:file/2 and friends that are stored in the Dbgi chunk. This allows the debug info encryption mechanism to work across compilers * Improves dialyzer to work directly on Core Erlang, allowing languages that do not have the Erlang Abstract Format to be dialyzer as long as they emit the new chunk and their backend implementation is available Backwards compatibility is kept across the board except for those calling beam_lib:chunk(Beam, ["Abst"]), as the old chunk is no longer available. Note however the "Abst" chunk has always been optional. Future OTP versions may remove parsing the "Abst" chunk altogether from beam_lib once Erlang 19 and earlier is no longer supported. The current Dialyzer implementation still supports earlier .beam files and such may also be removed in future versions. | |||
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-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-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 | Use @ in variable names generated by core and kernel | José Valim | |
The previous variable names can be generated by projects like LFE and Elixir, leading to possible conflicts. Our first to choice to solve such conflicts was to use $ but that's not a valid variable name in core. Therefore we picked @ which is currently supported and still reduces the chance of conflicts. | |||
2016-09-21 | Simplify handling of internal BIFs | Björn Gustavsson | |
Do a simpler translation of internal BIFs. While we are it, also remove the dummy values of Index and Uniq from the make_fun internal operation. | |||
2016-09-21 | v3_life: Eliminate special handling of guards | Björn Gustavsson | |
Remove the special handling #k_try{} in guards in v3_life. If we introduce a new #k_protected{} record in v3_kernel, v3_life no longer needs to know whether it is processing guards or bodies. | |||
2016-05-25 | Merge branch 'kostis/compiler/v3_kernel/eta-conversion' | Björn Gustavsson | |
* kostis/compiler/v3_kernel/eta-conversion: v3_kernel: Fix typo in comment | |||
2016-05-23 | v3_kernel: Fix typo in comment | Kostis Sagonas | |
2016-05-09 | compiler: Let module_info(attributes) skip more attributes | Hans Bolinder | |
'callback' and 'optional_callbacks' are no longer wild attributes. | |||
2016-04-14 | v3_kernel: Construct literal lists properly | Björn Gustavsson | |
Use cerl:make_list/1 instead of a home-made make_list/1 to ensure that literal lists are constructed as literals. In a future release, we would like to forbid in the loader construction of literal lists using instructions like: put_list {atom,a} [] Dst The proper way is: move {literal,[a]} {x,0} Also update the comment about "put_list Const [] Dst" in ops.tab. | |||
2016-02-17 | compiler: Update the compiler to handle typed record fields | Björn Gustavsson | |
2015-11-11 | v3_kernel: Speed up compilation of modules with many funs | Björn Gustavsson | |
Using a map to store the number of free variables for funs instead of an orddict will speed up the v3_kernel pass for modules with a huge number of funs (such as NBAP-PDU-Contents in the asn1 test suite). | |||
2015-06-18 | Change license text to APLv2 | Bruce Yinhe | |
2015-05-21 | compiler: Use cerl_sets instead of sets in v3_kernel | Björn-Egil Dahlberg | |
2015-04-22 | v3_kernel: Optimize subst_vsub/3 | Björn Gustavsson | |
Profiling shows that subst_vsub/3 dominates the running time. It is therefore worthwhile optimizing it. | |||
2015-03-09 | v3_core: Add is_map tests before map instructions | Björn Gustavsson | |
If we have a sequence of put_map_* instructions operating on the same map, it will be more efficient if we can have one is_map/2 instruction before put_map_* instructions, so that each put_map_* does not need to test whether the argument is a map. | |||
2015-02-12 | Eliminate use of core_lib:literal_value/1 | Björn Gustavsson | |
Essentially, core_lib:literal_value/1 became useless when literals were introduced in R12. Since we always create #c_literal{} records whenever possible, literal_value/1 would *only* succeed when it was passed a #c_literal{} argument. | |||
2015-01-29 | Move grouping of map constructions from v3_core to v3_kernel | Björn Gustavsson | |
When translating a function with map construction: f(A) -> B = b, C = c, #{A=>1,B=>2,C=>3}. v3_core would break apart the map construction into three parts because of the way the map instructions in BEAM work -- variable keys need to be in their own instruction. In the example, constant propagation will turn two of the keys to literal keys. But the initial breaking apart will not be undone, so there will still be three map constructions: 'f'/1 = fun (_cor0) -> let <_cor3> = ~{::<_cor0,1>}~ in let <_cor4> = ~{::<'b',2>|_cor3}~ in ~{::<'c',3>|_cor4}~ It would be possible to complicate the sys_core_fold pass to regroup map operations so that we would get: 'f'/1 = fun (_cor0) -> let <_cor3> = ~{::<_cor0,1>}~ in ~{::<'b',2>,::<'c',3>|_cor3}~ A simpler way that allows to simplify the translation is to skip the grouping in v3_core and translate the function to: 'f'/1 = fun (_cor0) -> ~{::<_cor0,1>,::<'b',2>,::<'c',3>}~ We will then let v3_kernel do the grouping while translating from Core Erlang to Kernel Erlang. | |||
2014-08-22 | compiler: Use variables in Map kernel pass | Björn-Egil Dahlberg | |
2014-03-25 | compiler: Variable keys are not allowed in Maps | Björn-Egil Dahlberg | |
No need to check for variables in Map keys. | |||
2014-03-17 | compiler: Change #c_map{var} to #c_map{arg} | Björn-Egil Dahlberg | |
Not only variables are allowed as arguments, the name should reflect that. Change cerl Map argument interface * cerl:map_arg/1 is more suitable then cerl:map_val/1 in this case. | |||
2014-03-17 | compiler: Validate Map src | Björn-Egil Dahlberg | |
Reject all expressions that are known to fail. Emit 'badarg' for those expressions. Ex. []#{ a => 1} Is not a valid map update expression. | |||
2014-03-04 | Properly order Kernel code for maps with mixed pairs | Anthony Ramine | |
The Kernel instructions were not properly ordered when compiling maps with complex values mixed in assoc and exact pairs. Reported-by: Ulf Norell | |||
2014-02-13 | compiler: Change map instructions for fetching values | Björn-Egil Dahlberg | |
* Combine multiple get values with one instruction * Combine multiple check keys with one instruction | |||
2014-02-10 | Merge branch 'egil/compiler/maps-fix-codegen' | Björn-Egil Dahlberg | |
* egil/compiler/maps-fix-codegen: compiler: Fix codegen multiple updates for Maps erts,compiler: Correct and amend tests for Maps | |||
2014-02-07 | compiler: Fix codegen multiple updates for Maps | Björn-Egil Dahlberg | |
This fixes an error on multiple updates optimization for map pairs. The error was introduced with moving to term order in Maps. This also fixes an error where register life time was lost for values and could result in erroneuos values being emitted in for map pairs. Simplified v3_codegen by moving multiple update optimizations to v3_kernel. | |||
2014-02-07 | Merge branch 'hsv/using_lists_droplast' | Henrik Nord | |
* hsv/using_lists_droplast: lib/mnesia/test/ - Replace reverse(tl(reverse(L))) with lists:droplast/1 lib/ssh - Replace reverse(tl(reverse(L))) with lists:droplast/1 lib/wx - Replace reverse(tl(reverse(L))) with lists:droplast/1 Use lists:droplast/1 in orber/orber_interceptors.erl Import and use lists:droplast/1 in v3_core/v3_kernel OTP-11678 OTP-11677 | |||
2014-01-29 | compiler: Squash #c_map_pair_*{} to #c_map_pair{} | Björn-Egil Dahlberg | |
Simplify compiler internals and parsing of core format. | |||
2014-01-29 | compiler: Squash #k_map_pair_*{} to #k_map_pair{} | Björn-Egil Dahlberg | |
Simplify compiler internals for kernel passes. | |||
2014-01-28 | compiler: Rename map pattern to proper name | Björn-Egil Dahlberg | |
2014-01-28 | Pass the map pair operators through to the v3_codegen pass | Björn Gustavsson | |
2014-01-28 | compiler: Implement support for exact Op in Maps | Björn-Egil Dahlberg | |
The syntax is handled upto v3_kernel where it is reduced to previous behaviour for construction and updates. Meaning, the ':=' operator is handled exactly as '=>' operator. | |||
2014-01-28 | compiler: Fix multiple same keys | Björn-Egil Dahlberg | |
2014-01-28 | compiler: Handle literals, not just atoms, as keys in maps | Björn-Egil Dahlberg | |
2014-01-28 | Implement support for maps in the compiler | Björn Gustavsson | |
To make it possible to build the entire OTP system, also define dummys for the instructions in ops.tab. | |||
2014-01-24 | Import and use lists:droplast/1 in v3_core/v3_kernel | Hans Svensson | |
Also imported lists:last/1, and removed the local definition. | |||
2013-09-12 | Remove ^L characters hidden randomly in the code. Not those used in text ↵ | Pierre Fenoll | |
files as delimiters. While working on a tool that processes Erlang code and testing it against this repo, I found out about those little sneaky 0xff. I thought it may be of help to other people build such tools to remove non-conforming-to-standard characters. | |||
2013-09-05 | compiler: Conform returned errors to the documented format | Björn Gustavsson | |
ErrorInfo is documented to be: {ErrorLine,Module,ErrorDescriptor} but for some errors with line numbers it would look like: {Module,ErrorDescriptor} Ensure that all ErrorInfo tuples have three elements. Use 'none' instead of a line number: {none,Module,ErrorDescriptor} There already are errors that return 'none' when no line number is available, but that convention was not documented. Mention it in the documentation. Also make sure that the compiler will not print 'none' as a line number in error messages (if the 'report_errors' option is given) as that looks stupid. That is, when attempting to compile a non-existing module, the error message should be: non-existing.erl: no such file or directory and not: non-existing.erl:none: no such file or directory | |||
2013-01-25 | Update copyright years | Björn-Egil Dahlberg | |
2013-01-23 | Revert "Merge branch 'nox/rm-reverse-eta-conversion/OTP-10682'" | Fredrik Gustafsson | |
This reverts commit 750ecdea08fa5fa7e32b7f3019eed96c1699427e, reversing changes made to 2cfa0466c3b3c7bd5e3621aff0f3e2ca30addb68. | |||
2012-12-03 | Remove the reverse eta-conversion from v3_kernel | Anthony Ramine | |
Local function references should be handled directly as a make_fun internal BIF call instead of creating an extra lambda function every time they are used. |