aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler
AgeCommit message (Collapse)Author
2012-03-14v3_kernel: Clean up handling of guardsBjörn Gustavsson
Handling of guards become a mess when andalso/orelse in guards were introduced. Clean it up by using common code for most constructs, regardless of where they occur, and when needed use is_in_guard/1 to handle guard constructs differently.
2012-01-11v3_kernel: Introduce is_in_guard/1Björn Gustavsson
2012-01-11v3_kernel: Removed unreached clause for #k_bin_int{} in sub_size_var/1Björn Gustavsson
The size field of a #k_bin_int{} is always a literal integer (#k_int{}); thus there is no way this clause can match. While we are at it, remove a duplicated call to select_assert_match_possible/3 in select_bin_int/1.
2012-01-11v3_kernel: Remove unreached handling of #k_bin_int{} in arg_con/1Björn Gustavsson
arg_con/1 will never be called with #k_bin_int{} argument, since a #k_bin_int{} is constructed out of #k_bin_seg{} only after arg_con/1 has been called with a #k_bin_seg{} argument.
2012-01-11v3_codegen: Eliminate the special case of 'put' without destinationBjörn Gustavsson
If we let v3_kernel make sure that a 'put' operation always has a destination register, the special case in v3_codegen is not needed.
2012-01-11v3_kernel: Don't attempt to share identical literalsBjörn Gustavsson
It is unlikely that sharing literals will actually save any time. Literals that can be shared are usually small. It is more likely that maintaining the dictionary of literals will waste time.
2012-01-11v3_kernel: Handle sequences in guardsBjörn Gustavsson
A guard with a sequence will cause a crash in v3_codegen. Currently, it seems that a sequence in a guard will never happen when compiling from Erlang code, but there are several reasons to fix this problem anyway: * There are other compilers that generate Core Erlang code. * Changes to sys_core_fold (perhaps additional optimizations) may cause sequences to be generated in guards. * A previously uncovered line in sys_core_fold:opt_guard_try/1 will now be covered.
2012-01-11v3_kernel: Remove clauses that are never executed in arg_val/1Björn Gustavsson
arg_val/1 will never be called for single-valued types, so there is no need handle these types.
2012-01-11v3_kernel.hrl: Remove unused record #k_string{}Björn Gustavsson
2012-01-11v3_kernel.erl: Remove unused define of EXPENSIVE_BINARY_LIMITBjörn Gustavsson
2012-01-11sys_core_fold: Refactor previous_ctx_to_binary/2 to cover it completelyBjörn Gustavsson
2012-01-11sys_core_fold: Fix opt_guard_try/1Björn Gustavsson
opt_guard_try/1 assumed that it was only operating on guards, and implicitly assumed that any function call was to BIFs without any side effects.
2012-01-11sys_core_fold: Simplify opt_bool_not() to cover it completelyBjörn Gustavsson
In: case not Expr of ... we don't have the information to ascertain that Expr is a boolean expression. Therefore, add the catch-all clause unconditionally.
2012-01-11sys_core_fold: Remove duplicate optimizationBjörn Gustavsson
The second clause in opt_case_in_let_2/3 attempts to do the same optimization as opt_bool_case_redundant/1; it will never succeed.
2012-01-11compile_SUITE: Add test of 'sys_pre_attributes'Björn Gustavsson
2012-01-05Correct syntax in compiler.coverBjörn Gustavsson
Modules would not get excluded. While at it, no longer exclude sys_pre_attributes since we will want to test it.
2012-01-04Cover v3_kernel:get_line/1Björn Gustavsson
2012-01-04core_SUITE: Cover the nomatch_shadow warning in v3_kernelBjörn Gustavsson
2012-01-04core_SUITE: Cover v3_kernel:build_match/2Björn Gustavsson
2012-01-04bs_match_SUITE: Add a test case to cover bsm_ensure_no_partition_2/5Björn Gustavsson
Also correct the comment in bsm_ensure_no_partition_2/5, and while at it correct typos in the comment for bsm_nonempty/2.
2012-01-04core_fold_SUITE: Cover sys_core_fold:is_safe_bool_expr_1/3Björn Gustavsson
2012-01-04core_SUITE: Cover sys_core_fold:eval_is_boolean/2Björn Gustavsson
2012-01-04core_SUITE: Cover sys_core_fold:make_effect_seq/2Björn Gustavsson
We need to write a test case in Core Erlang in order to cover make_effect_seq/2, since v3_core does not generate "deep" Core Erlang code.
2012-01-04beam_validator_SUITE:beam_files/1: Validate modules in parallelBjörn Gustavsson
2012-01-04compilation_SUITE: Compile compiler modules in parallelBjörn Gustavsson
On my Mac Pro with 8 cores, this change make self_compile/1 more than twice as fast, and self_compile_old_inliner/1 more than 4 times faster.
2012-01-04compilation_SUITE: Prevent cover from being run on slave nodesBjörn Gustavsson
In the self compilation test cases, the compiler compiles itself and runs the newly compiled version on a slave node. Having the cover server starting on the slave node defeats the purpose of the test, since it will load the SAME cover-compiled code on the slave node. (It will also be slower, but will not improve coverage since it compiles the same source files again.) Use a shielded node to prevent the cover server from getting started on the slave node.
2012-01-04test_lib:p_run/2: Be careful about how many parallel processes we useBjörn Gustavsson
We probably don't gain anything by using more processes than available schedulers. Also, if 'cover' is being run, using more than one process may make it slower, so we will be very conservative and use only one process in that case.
2012-01-04Remove part_eval_SUITEBjörn Gustavsson
This test suite has been superseded by other test suites (e.g. guard_SUITE). Removing it does not decrease the coverage.
2012-01-04Add the beam_except pass to optimize exceptionsBjörn Gustavsson
In order to save space, rewrite suitable calls to erlang:error/{1,2} to special BEAM instructions. This code is probably longer than the code taken out of v3_life and v3_codegen in the previous commit, but it is much easier to understand and maintain since the BEAM assembler format is better understood than the v3_life format.
2012-01-04Eliminate the match_fail primop in v3_kernel and later passesBjörn Gustavsson
In the v3_life pass, it is assumed that a 'match_fail' primop only occur at the top-level and at the end of a function. But this code: do_split_cases(A) -> case A of x -> Z = dummy1; _ -> Z = dummy2, a=b end, Z. will be optimized by sys_core_fold to the following code: 'split_cases'/1 = fun (_cor0) -> let <_cor7,Z> = case _cor0 of <'x'> when 'true' -> < 'dummy1','dummy1' > <_cor6> when 'true' -> %% Here follows a 'match_fail' primop inside %% multiple return values: < primop 'match_fail'({'badmatch','b'}),'dummy2' > end in Z moving the 'match_fail' primop into a "values" construction. In the future, we would like to get rid of the v3_life pass (it is there for historical reasons), so in the mean-time we prefer to not add more code to it by generalizing the handling of 'match_fail'. Since the 'match_fail' primop can be simulated by erlang:error/{1,2}, the simplest solution is to translate 'match_fail' to a call to erlang:error/{1,2} in v3_kernel and remove the handling of 'match_fail' in v3_life and v3_codegen. It is tempting to get rid of 'match_fail' also in the Core Erlang format, but there are two issues: - Removing the support for 'match_fail' completely may break tools that generate Core Erlang code. We should not do that in a minor release. - There is no easy way to generate a 'function_clause' exception that will remain correct if it will be inlined into another function. (Calling "erlang:error(function_clause, Args)" is fine only if it is not inlined into another function.) A good solution probably involves introducing new instructions, which is better done in a major release. Noticed-by: Håkan Matsson Minimized-test-case-by: Erik Søe Sørensen
2011-12-12Prepare releaseErlang/OTP
2011-12-09Update copyright yearsBjörn-Egil Dahlberg
2011-12-06beam_validator: Fix type for failure label for bs_start_match2/5Björn Gustavsson
A bs_start_match2/5 instruction will never fail (take the branch) if given a match state or a binary. Therefore, the type at the failure label should be 'term', not match state or binary. Without this correction, the beam_validator will reject safe programs.
2011-12-06inline_SUITE: Add the comma_splitter/1 test caseBjörn Gustavsson
Compilation would fail with an error message similar to: comma_splitter: function split_at_comma/2+32: Internal consistency check failed - please report this bug. Instruction: {put,{x,0}} Error: {match_context,{x,0}}: Noticed-by: René Kijewski
2011-12-06Teach the compiler the 'no_dead' optionBjörn Gustavsson
To facilitate debugging of compiler bugs, teach the compiler the 'no_dead' option. Since the beam_dead pass used to do the necessary splitting of basic blocks to expose all labels, we must move that splitting into a separate pass that is always run.
2011-11-30compiler: Turn calls to math:pi/0 into constant valuesBjörn Gustavsson
Mark math:pi/0 as pure, informing the compiler that the value can be calculated at compile time.
2011-11-28Merge branch 'bjorn/compiler/options/OTP-9752'Björn Gustavsson
* bjorn/compiler/options/OTP-9752: filename documentation: Recommend against using filename:find_src/1,2 Teach filename:find_src/1,2 to handle slim or stripped BEAM files filename: Eliminate failing call to Mod:module_info(source_file) filename.erl:filter_options/1: Remove handling of dead options compiler: Don't include {cwd,_} in module_info(compile) compiler: Don't include source code options in module_info(compile) hipe: Teach hipe to handle slim or stripped BEAM files
2011-11-28Merge branch 'bjorn/major-release-cleanups'Björn Gustavsson
* bjorn/major-release-cleanups: observer tests: Test compatibility with R13, not R12 emulator tests: Test compatibility with R13, not R12 Teach the compiler the 'r14' option erl_lint: The types introduced in R12B-5 are no longer "newly introduced" otp_internal: Stop warning for functions removed in R12 or earlier Conflicts: lib/stdlib/src/otp_internal.erl
2011-11-24compiler: Don't include {cwd,_} in module_info(compile)Björn Gustavsson
The {cwd,Dir} option is always included if the module has been compiled by erlc. Since its presence cannot be relied upon and it wastes memory, get rid of it.
2011-11-24compiler: Don't include source code options in module_info(compile)Björn Gustavsson
As far as I know, the purpose of the compiler options included in Mod:module_info(compile) has never been documented. An educated guess is that they are there in case you want to re-compile the module with the same options, and also to aid in debugging when you need to know how a module was compiled. In neither case is there any need to include options given in the source itself in options included in Mod:module_info(compile). Including those options will only waste memory. Therefore, only include in the BEAM file the options that were given to compile:file/2.
2011-11-24hipe: Teach hipe to handle slim or stripped BEAM filesBjörn Gustavsson
2011-11-24Teach the compiler the 'r14' optionBjörn Gustavsson
2011-11-24sys_expand_pmod: Handle external funs in parameterized modulesBjörn Gustavsson
Starting in ff432e262e65243cbc983fcb002527f8fae8c78b, sys_pre_expand passes external funs through to the downstream passes. It used to translate external funs to a call to erlang:make_fun/3. Therefore, we will now need to handle external funs in sys_expand_pmod. Noticed-by: Stavros Aronis
2011-11-22Revert "Update version numbers for pre-release of R15"Björn-Egil Dahlberg
This reverts commit e21ff9b0b69219ab3853be7e80813156113152b7.
2011-11-22Update version numbers for pre-release of R15OTP_R15ABjörn Gustavsson
2011-11-08Merge branch 'bjorn/line-numbers/OTP-9468'Björn Gustavsson
* bjorn/line-numbers/OTP-9468: beam_type: Improve FP optimizations in the presence of line numbers
2011-11-07Merge branch 'bjorn/fun-improvements/OTP-9667'Björn Gustavsson
* bjorn/fun-improvements/OTP-9667: sys_pre_expand: Remove incorrect comment compiler: Eliminate use of deprecated erlang:hash/2 beam_asm: Fix broken NewIndex in fun entries beam_asm: Strenghten the calculation of Uniq for funs
2011-11-07sys_pre_expand: Remove incorrect commentBjörn Gustavsson
sys_pre_expand does not keep track of used or new variables (and have not done since about the time Core Erlang was introduced).
2011-11-07compiler: Eliminate use of deprecated erlang:hash/2Björn Gustavsson
Now that beam_asm computes the Index and Uniq values for funs, there is no need to compute those values in the sys_pre_expand and v3_kernel modules, thus eliminating the calls to the deprecated erlang:hash/2 function. It would be tempting to stop generating the name for the fun in sys_pre_expand so that we did not have to add the Info field to a tuple. But: * The debugger depends on the name being there. (Simple solution: Let the debugger generate the name itself.) * When a fun has been inlined into another function, the fun name in 'id' annotation will be used to notice the inlining and change the final clause of the top-level case from generating a 'function_clause' exception to a case_clause exception. (Possible workaround: Have the inliner set an inlined attribute on functions that have been inlined, or have the inliner rewrite 'function_clause' exceptions itself.)
2011-11-07beam_asm: Fix broken NewIndex in fun entriesBjörn Gustavsson
The calculation of the NewIndex field in fun entries is broken: the sys_pre_expand and v3_kernel modules keep separate index counters starting at zero; thus there is no guarantee that each fun within a module will have its own unique NewIndex. We don't really need the NewIndex any more (see below), but since we do need the NewUniq field, we should fix NewIndex for cleanliness sake. The simplest way is to assign NewIndex as late as possible, namely in beam_asm, and to set it to the same value as Index. Historical Note: Why NewIndex Was Introduced There was once an idea that the debugger should be able to interpret only a single function in a module (for speed). To make sure that interpreted funs could be called from BEAM code and vice versa, the fun identification must be visible in the abstract code. Therefore a NewIndex field was introduced in each fun in the abstract code. However, it turned out that interpreting single functions does not play well with aggressive code optimization. For example, in this code: f() -> X = 1, fun() -> X+2 end. the variable X will seem to be free in the fun, but an aggressive optimizer will replace X with 1 in the fun; thus the fun will no longer have any free variables. Therefore, the debugger will always interpret entire modules.