aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/src
AgeCommit message (Collapse)Author
2010-06-02Teach compiler to override autoimport with importPatrik Nyblom
2010-06-02First prototype for local functions overriding autoimportedPatrik Nyblom
Import directives still not sorted out!
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_peep: Remove optimization already done by beam_deadBjörn Gustavsson
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.
2010-06-02Evaluate is_record/3 at compile-time using type informationBjörn Gustavsson
2010-06-02Evaluate element/2 at compile-time using type informationBjörn Gustavsson
The erl_expand_records compiler pass translates the following code: h(X) when X#r1.a =:= 1 -> ok. to (essentially): h({r1,V1,V2}=X) when element(2, X) =:= 1 -> ok. Since the guard can only be executed when the pattern matching has succeeded, we know that the second element in the tuple X must have been bound to V2. Thus we can eliminate the call to element/2 like this: h({r1,V1,V2}=X) when V1 =:= 1 -> ok.
2010-05-27Cleanup branch 'bg/compiler-cover-and-clean'Kostis Sagonas
Commit 329f737c03db51918361e127560a6f700e99028e removed some unused code, but also introduced the need for further clean-ups. Fix a spec so that its return corresponds to reality. Take out code that will never match from a function.
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-20v3_life: Remove clause that cannot match in match_fail/3Björn Gustavsson
The clause that attempts to match a #k_literal{} where the value is an atom cannot possibly match, since single atoms are always encoded as #k_atom{}.
2010-05-20beam_type: Remove redundant clauseBjörn Gustavsson
The clause does not server any useful purpose, since it does the same as the default clause at the end.
2010-05-20v3_core: Remove a clause in is_simple/1 that cannot matchBjörn Gustavsson
The is_simple/1 function does not need to handle #c_binary{}, since it will never be called with a #c_binary{} argument.
2010-05-20v3_core: Remove unused support for generating compilation errorsBjörn Gustavsson
The state record #core{} has a "es" field that can be used for causing a compilation error. Since incorrect programs have been rejected much earlier by erl_lint, no errors were actually stored in the "es" fields. Therefore, get rid of the "es" field and the support for generating a compilation error in the v3_core module.
2010-05-20Remove stray support for the put_literal/2 instructionBjörn Gustavsson
put_literal/2 was an experimental instruction added in R11 to support literals, but before the R12 release support for literals was implemented for all instruction, making the put_literal/2 instruction redundant. Although the beam_disasm module supports dissambley of instructions in older releases, there is no reason to have it support experimental instructions.
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.
2010-05-20Remove the bs_bits_to_bytes/3 instructionBjörn Gustavsson
The last compiler to generate code that uses the bs_bits_to_bytes/3 instruction was the R11 compiler. Since we don't support loading R11 *.beam files in R14, removing the remaining support for the instruction.
2010-05-20beam_bool: Remove a clause in live_regs/1 that cannot matchBjörn Gustavsson
live_regs/1 folds over a list of tuples, so a clause matching an element being an empty list can never match. If the list for some unfathomable reason would contain an empty list, there will be an internal compiler error and no *.beam file will be created. Thus this change is safe.
2010-05-20beam_bool: Remove a clause in initialized_regs/2 that cannot matchBjörn Gustavsson
When scanning a reversed instruction sequence for a function, it is impossible to reach the end of the list, because each function must have a fun_info/4 instruction followed by a label/1 instruction at the beginning, and there is a clause that will handle those instructions. If for some unfathomable reason the end of the list would be reached, with this change there will be an internal compiler error and no *.beam file will be created. Thus this change is safe.
2010-05-20beam_block: Remove a clause that will never be executedBjörn Gustavsson
Since the introduction of literals in R12B, empty tuples are literals. Thus the put_tuple/2 instruction is always followed by at least one put/1 instruction. Therefore the alloc_may_pass/1 function in beam_block no longer needs a clause for for "put_tuple", because the clause for "put" will always be reached first (since the instruction stream is scanned in reverse execution order). Note that if the compiler would generate a "put_tuple 0 Dst" instruction for some unfathomable reason, we should still be because the run-time system will now refuse to load a module containing such an instruction.
2010-05-20compile: Remove code that is only executed on SolarisBjörn Gustavsson
On Solaris only, the 'time' option would include the process size for the Erlang virtual machine in its output. Since few compiler developers use Solaris nowadays, remove the code.
2010-05-20Merge branch 'pan/otp_8217_binary' into devErlang/OTP
* pan/otp_8217_binary: Add documentation for binary module Add more tests and make some go easier on small systems Correct Boyer More and trapping for longest_common_suffix Add longer timetrap to testcases and add binary to app file Add guard BIFs binary_part/2,3 Add binary:{encode,decode}_unsigned({1,2} Add referenced_byte_size/1 Add binary:list_to_bin/1 and binary:copy/1,2 Add bin_to_list/{1,2,3} Add binary:longest_common_prefix/longest_common_suffix Add binary:part to erl_bif_binary.c Move binary module bif's to erl_bif_binary.c Count reductions for process even when not trapping Add random compare testcase Teach BIF's binary:match/matches interrupting/restarting Teach binary.c the semantics to take longest instead of shortest match Initial commit of the binary EEP OTP-8217 Implement EEP31 The module binary from EEP31 (and EEP9) is implemented.
2010-05-17Add guard BIFs binary_part/2,3Patrik Nyblom
Add the gc_bif's to the VM. Add infrastructure for gc_bif's (guard bifs that can gc) with two and. three arguments in VM (loader and VM). Add compiler support for gc_bif with three arguments. Add compiler (and interpreter) support for new guard BIFs. Add testcases for new guard BIFs in compiler and emulator.
2010-05-12Merge branch 'bg/compiler-attributes' into devErlang/OTP
* bg/compiler-attributes: Remove opaque declarations from the attributes
2010-05-12Remove opaque declarations from the attributesBjörn Gustavsson
-opaque declarations should not be retained in the attributes (because they will be loaded along with the code and are not useful). While at it, filter away those Dialyzer attributes as early as possible - in v3_kernel.
2010-05-12Merge branch 'bg/opt-receive' into devErlang/OTP
* bg/opt-receive: Test that gen_server:call/2,3 are fast even with a huge message queue erts: Add tests for the receive optimization Update primary bootstrap erts: Implement recv_mark/1 and recv_set/1 for real compiler tests: Cover the error handling code in beam_receive compiler test: Test optimization of receive statements Optimize selective receives in the presence of a large message queue Introduce the new recv_mark/1 and recv_mark/1 instructions Compile tests that communicate with R12 nodes with the r12 option Move p_run/2 to test_lib gen: Inline wait_resp_mon/2 to help the compiler optimize OTP-8623 bg/opt-receive reveive statements that can only read out a newly created reference are now specially optimized so that it will execute in constant time regardless of the number of messages in the receive queue for the process. That optimization will benefit calls to gen_server:call(). (See gen:do_call/4 for an example of a receive statement that will be optimized.)
2010-05-11Optimize selective receives in the presence of a large message queueBjörn Gustavsson
If a gen_server process has many messages in its message queue and calls another gen_server process, the selective receive in gen_server:call() will have to go through the entire message queue. Have the compiler generate the new mark_recv/1 and mark_recv/1 instructions that can avoid going through the entire message queue.
2010-05-11Introduce the new recv_mark/1 and recv_mark/1 instructionsBjörn Gustavsson
Make the recv_mark/1 and recv_mark/1 instructions known to the compiler and run-time system. For the moment, make the loader ignore any occurrences of those instructions in BEAM files. Also update hipe_beam_to_icode to ignore those instructions.
2010-04-27Merge branch 'bg/compiler-suppress-result-ignored' into devErlang/OTP
* bg/compiler-suppress-result-ignored: compiler tests: Eliminate "result of expression is ignored" warnings Silence warnings for expressions that are assigned to "_" OTP-8602 bg/compiler-suppress-result-ignored It is now possible to suppress the warning in code such as "list_to_integer(S), ok" by assigning the ignored value "_" like this: "_ = list_to_integer(S), ok".
2010-04-19beam_type: Improve coalescing of fmove/2 and move/2 instructionsBjörn Gustavsson
The following instruction sequence: fmove {fr,Fr} {x,TempXreg} move {x,TempXreg} {y,Dest} is rewritten to: fmove {fr,Fr} {y,Dest} (Provided that {x,TempXreg} is killed by the instructions following the sequence.) Generalize the optimization to also handle: fmove {fr,Fr} {x,TempXreg} move {x,TempXreg} {_,Dest} That is, the destination register can be either an X or Y register.
2010-04-15Silence warnings for expressions that are assigned to "_"Björn Gustavsson
There is currently no zero-cost way to silence the warning "the result of the expression is ignored", which is issued for code such as: list_to_integer(S), ok Such code can be useful for assertions or input validation. Teach the compiler to silence the warning for expressions that are explicitly assigned to to the "_" variable, such as: _ = list_to_integer(S), ok Implement it by having the v3_core pass annotate calls in Core Erlang like this: let <_> = ( call 'erlang':'list_to_integer'(S) -| ['result_not_wanted'] ) in 'ok' and modifiy sys_core_fold to suppress the warning for any call having the annotation. We deliberately do not make it possible to silence the warnings for expressions like: {build,an,unnecessary,term}, ok or is_list(L), ok because we don't know of any real-world scenarios in which that would be useful.
2010-04-01Merge branch 'bg/compiler-inliner' into devErlang/OTP
* bg/compiler-inliner: pmod_SUITE: Again test inlining parameterized modules compiler tests: Cope with missing args in function_clause for native code compiler tests: Compile a few more modules with 'inline' Consistently rewrite an inlined function_clause exception to case_clause compiler tests: Test the 'inline' option better compiler: Suppress bs_context_to_binary/1 for a literal operand compiler: Fix binary matching bug in the inliner sys_core_inline: Don't generated multiple compiler_generated annos OTP-8552 bg/compiler-inliner Several problems in the inliner have been fixed.
2010-03-26Consistently rewrite an inlined function_clause exception to case_clauseBjörn Gustavsson
A function_clause exception is generated by jumping to a func_info/3 instruction at the beginning of the function. The x registers are assumed to contain the arguments for the function. That means that a func_info/3 instruction copied from another function (or even from the same function if not at the top level) will not work, so it must be replaced with an instruction that generates a case_clause exception. In Core Erlang, a func_info/3 instruction is represented as a the primop match_fail({function_clause,Arg1,...ArgN}). The current mechanism that is supposed to replace the primop match_fail(function_clause) with match_fail(case_clause) will fail to do that in the following circumstances: 1. If the inliner has inlined a function into itself. Fix that by having the inliner clear the function_name annotations on all match_fail primops in functions that are inlined. (To simplify doing that, the annotation is now on the primop node itself and not on the 'function_clause' atom inside it.) 2. If the inliner has rewritten the tuple node in the primop node to a literal (when inlining a function call with literal arguments), v3_kernel would not recognize the match_fail(function_clause) primop and would not rewrite it. Fix it by making v3_kernel smarter. Also simplify the "old" inliner (sys_core_inline) to only clear the function_name annotations instead of rewriting function_clause execptions to case_clause execptions itself.
2010-03-26compiler: Suppress bs_context_to_binary/1 for a literal operandBjörn Gustavsson
The inliner can cause illegal uses of the bs_context_to_binary/1 instruction, such as: bs_context_to_binary {literal,"string"} or bs_context_to_binary {integer,1} Remove the bs_context_to_binary/1 instruction if the operand is not a register (it is clearly not needed).
2010-03-26compiler: Fix binary matching bug in the inlinerBjörn Gustavsson
The inliner incorrectly assumes that a literal cannot match a binary in code such as: t() -> bc(<<"string">>). bc(<<A:1,T/bits>>) -> [A|bc(T)]; bc(<<>>) -> []. The bug was introduced when binary literals were introduced.
2010-03-26sys_core_inline: Don't generated multiple compiler_generated annosBjörn Gustavsson
Multiple compiler_generated annotations are harmless, but makes listing files harder to read during debugging.
2010-03-25Merge branch 'bg/compiler-remove-r11-support' into devErlang/OTP
* bg/compiler-remove-r11-support: compiler: Don't support the no_binaries option erts: Don't support the put_string/3 instruction compiler: Don't support the no_constant_pool option compiler: Don't support the r11 option test_server: Don't support communication with R11 nodes binary_SUITE: Don't test bit-level binary roundtrips with R11 nodes erts: Test compatibility of funs with R12 instead of R11 OTP-8531 bg/compiler-remove-r11-support
2010-03-22compiler: Don't support the no_binaries optionBjörn Gustavsson
The no_binaries option terminates the compiler with an error if any bit syntax is used in the module being compiled. (It used to be implied by the removed r11 option.)
2010-03-22erts: Don't support the put_string/3 instructionBjörn Gustavsson
Since R14 does not need to load code that can also be loaded in an R11 run-time system, support for the put_string/3 instruction can be removed.
2010-03-22compiler: Don't support the no_constant_pool optionBjörn Gustavsson
The no_constant_pool option was implied by the r11 option. It turns off the usage of the constant (literal) pool, so that BEAM instructions that use constants can be loaded in an R11 system. Since the r11 option has been removed, there is no need to retain the no_constant_pool option.
2010-03-22compiler: Don't support the r11 optionBjörn Gustavsson
The r11 option was used to generate BEAM modules that could loaded both on both R11 and R12/R13 to facilitate testing that R11 and R13 nodes could communicate with each other. Since R14 is only required to be compatible with R12 and R13 nodes, the r11 option is no longer needed.
2010-03-17compiler: Provide more information if the v3_life pass crashesBjörn Gustavsson
Print the name and arity of the function being compiled if the v3_life compiler pass crashes to facilitate finding out which part of the source code that triggered the problem.
2010-02-17OTP-8447 Bit string comprehensions can now be used in parameterizedHans Bolinder
modules. (Thanks to Jebu Ittiachen.)
2010-02-10Merge branch 'ks/compiler' into ccase/r13b04_devErlang/OTP
* ks/compiler: compiler: keep line numbers for attributes compiler Makefile: alphabetize module names compile.erl: eliminate compiler warning
2010-02-10Support the configure option --enable-native-libsKostis Sagonas
2010-02-10compiler: keep line numbers for attributesKostis Sagonas
In the future, we might want to generate warnings for attributes, referring to them with line numbers. sys_pre_expand used to replace line number for attributes with 0. Change sys_pre_expand to retain the real line number. v3_core used to throw away the line numbers. Change v3_core so that it retains the line numbers in annotations. While at it, do some tidying as suggested by tidier.
2010-02-10compiler Makefile: alphabetize module namesKostis Sagonas
2010-02-10compile.erl: eliminate compiler warningKostis Sagonas
2010-01-30compiler: make ignore_native_errors also handle internal hipe errorsBjörn Gustavsson
We must also catch exits, not only errors, since the hipe compilers does an exit/1 if an internal error is found.
2010-01-30Teach the compiler the no_native optionBjörn Gustavsson
Implement the 'no_native' option to disable native-code compilation. If given in a module like this: -compile(no_native). it will override a 'native' option given on the command line.
2010-01-20Merge branch 'cf/compile_warning_as_error' into ccase/r13b04_devErlang/OTP
* cf/compile_warning_as_error: Add option -Werror in erlc(1) compile: add flag warnings_as_errors to treat warnings as errors compile.erl: remove trailing whitespace OTP-8382 The -Werror option for erlc and the compiler option warnings_as_errors will cause warnings to be treated as errors. (Thanks to Christopher Faulet.)