aboutsummaryrefslogtreecommitdiffstats
path: root/lib
AgeCommit message (Collapse)Author
2018-01-16ssl: RSA key exchange is considered broken do not support by defaultIngela Anderton Andin
2018-01-12Merge pull request #1680 from bjorng/bjorn/compiler/beam_blockBjörn Gustavsson
Run beam_block a second time
2018-01-12Merge pull request #1679 from bjorng/bjorn/compiler/sys_core_foldBjörn Gustavsson
Clean up and improve sys_core_fold optimizations
2018-01-12Merge pull request #1663 from bjorng/bjorn/compiler/refactor-annotationsBjörn Gustavsson
Refactor '%live' and '%def' annotations
2018-01-12Merge branch 'maint'Ingela Anderton Andin
2018-01-11ssl: Correct function for listing RC4 suitesIngela Anderton Andin
2018-01-11Run beam_block again after other optimizations have been runBjörn Gustavsson
Running beam_block again after the other optimizations have run will give it more opportunities for optimizations. In particular, more allocate_zero/2 instructions can be turned into allocate/2 instructions, and more get_tuple_element/3 instructions can store the retrieved value into the correct register at once. Out of a sample of about 700 modules in OTP, 64 modules were improved by this commit.
2018-01-11beam_bsm: Insert introduced 'move' instructions into blockBjörn Gustavsson
If possible, when adding move/2 instructions, try to insert them into a block. That could potentially allow them to be optimized.
2018-01-11Prepare beam_utils to run again after beam_splitBjörn Gustavsson
beam_utils:live_opt/1 is currently only run early (from beam_block). Prepare it to be run after beam_split when instructions with failure labels have been taken out of blocks. While we are it, also improve check_liveness/3. That will improve the optimizations in beam_record (replacing tuple matching instructions with an is_tagged_tuple instruction).
2018-01-11beam_utils: Correct handling of liveness for select_valBjörn Gustavsson
Since the select_val instruction never transfer directly to the next instruction, the incoming live registers should be ignored. This bug have not caused any problems yet, but it will in the future if we are to run the liveness optimizations again after the optimizations in beam_dead and beam_jump.
2018-01-11beam_block: Reorder element/2 calls in guardsBjörn Gustavsson
In a guard, reorder two consecutive calls to the element/2 BIF that access the same tuple and have the same failure label so that highest index is fetched first. That will allow the second element/2 to be replace with the slightly cheaper get_tuple_element/3 instruction.
2018-01-11Improve code generation for a 'case' with exported variablesBjörn Gustavsson
Consider a 'case' that exports variables and whose return value is ignored: foo(N) -> case N of 1 -> Res = one; 2 -> Res = two end, {ok,Res}. That code will be translated to the following Core Erlang code: 'foo'/1 = fun (_@c0) -> let <_@c5,Res> = case _@c0 of <1> when 'true' -> <'one','one'> <2> when 'true' -> <'two','two'> <_@c3> when 'true' -> primop 'match_fail'({'case_clause',_@c3}) end in {'ok',Res} The exported variables has been rewritten to explicit return values. Note that the original return value from the 'case' is bound to the variable _@c5, which is unused. The corresponding BEAM assembly code looks like this: {function, foo, 1, 2}. {label,1}. {line,[...]}. {func_info,{atom,t},{atom,foo},1}. {label,2}. {test,is_integer,{f,6},[{x,0}]}. {select_val,{x,0},{f,6},{list,[{integer,2},{f,3},{integer,1},{f,4}]}}. {label,3}. {move,{atom,two},{x,1}}. {move,{atom,two},{x,0}}. {jump,{f,5}}. {label,4}. {move,{atom,one},{x,1}}. {move,{atom,one},{x,0}}. {label,5}. {test_heap,3,2}. {put_tuple,2,{x,0}}. {put,{atom,ok}}. {put,{x,1}}. return. {label,6}. {line,[...]}. {case_end,{x,0}}. Because of the test_heap instruction following label 5, the assignment to {x,0} cannot be optimized away by the passes that optimize BEAM assembly code. Refactor the optimizations of 'let' in sys_core_fold to eliminate the unused variable. Thus: 'foo'/1 = fun (_@c0) -> let <Res> = case _@c0 of <1> when 'true' -> 'one' <2> when 'true' -> 'two' <_@c3> when 'true' -> primop 'match_fail'({'case_clause',_@c3}) end in {'ok',Res} The resulting BEAM code will look like: {function, foo, 1, 2}. {label,1}. {line,[...]}. {func_info,{atom,t},{atom,foo},1}. {label,2}. {test,is_integer,{f,6},[{x,0}]}. {select_val,{x,0},{f,6},{list,[{integer,2},{f,3},{integer,1},{f,4}]}}. {label,3}. {move,{atom,two},{x,0}}. {jump,{f,5}}. {label,4}. {move,{atom,one},{x,0}}. {label,5}. {test_heap,3,1}. {put_tuple,2,{x,1}}. {put,{atom,ok}}. {put,{x,0}}. {move,{x,1},{x,0}}. return. {label,6}. {line,[...]}. {case_end,{x,0}}.
2018-01-11Remove special cases in optimization of a simple letBjörn Gustavsson
Improve handling of #c_seq{}, making sure to simplify a #c_seq{} as much as possible. With that improvement, we can remove some special-case code from opt_simple_let_2/6.
2018-01-11sys_core_fold: Make it clear what part of Sub is usedBjörn Gustavsson
2018-01-11sys_core_fold: Simplify usage of move_case_into_arg/2Björn Gustavsson
2018-01-11Refactor '%live' and '%def' annotationsBjörn Gustavsson
The annotations in the optimizing passes currently looks like this: {'%live',NumRegistersUsed,RegistersUsedBitmap} {'%def',RegistersDefinedBitmap} (NumRegistersUsed is no longer used.) When I attempted to extend some optimizations, I found that I had to add additional clauses to tolerate/handle both types of annotations. That problem would only get worse if any more annotations are added in the future. To simplify annotation handling, this commit wraps both types of annotations in a {'%anno',_} tuple: {'%anno',{used,RegistersUsedBitmap}} {'%anno',{def,RegistersDefinedBitmap}} The '%live' annotation has been renamed to 'used' to make it somewhat clearer what it means, and the unused NumRegistersUsed part of the old annotation has been removed. Alternatives considered: My first attempt was to wrap the annotation in a 'set' tuple so that there would only be 'set' tuples in a block. For example: {set,[],[],{anno,{live,RegistersUsedBitmap}}} It was not as convenient as expected. Annotations often need to be handled specially from other instructions in a block. When they are wrapped in a 'set' tuple, they can very easily be handled incorrectly or passed on to the next pass. That causes subtle errors or worse code, and it can be difficult to debug. Therefore, my conclusion is that annotations should be distinct from other instructions, to make it obvious when one have missed to handle an annotation.
2018-01-11Merge branch 'maint'Ingela Anderton Andin
2018-01-11Merge branch 'ingela/ssl/timeout-cuddle' into maintIngela Anderton Andin
* ingela/ssl/timeout-cuddle: ssl: Tune timeouts
2018-01-11ssl: Tune timeoutsIngela Anderton Andin
2018-01-11Merge pull request #1678 from ↵John Högberg
jhogberg/john/compiler/reintroduce-tuple-arity-optimizations/OTP-14857 Reintroduce the tuple arity optimizations removed in PR #1673
2018-01-10beam_block: Improve optimization of allocate_zero instructionsBjörn Gustavsson
Turn more allocate_zero instructions into allocate instructions.
2018-01-10beam_type: Enhance coalescing of allocation instructionsBjörn Gustavsson
An 'allocate' or 'allocate_zero' instruction should not be shortly followed by a 'test_heap' instruction. For example, we don't want this type of code: {allocate_zero,3,4}. {line,...}. {test_heap,7,4}. {bif,element,{f,0},...,...}. While the code is safe because 'allocate_zero' has initialized the stack frame, it is wasteful. Also note that the code would become unsafe if the 'allocate_zero' instruction were to be replaced with an 'allocate' instruction. What we want to see is this: {allocate_heap_zero,3,7,4}. {line,...}. {bif,element,{f,0},...,...}.
2018-01-10Correct beam_utils:combine_heap_needs/2Björn Gustavsson
In 21dd6e55877832, beam_utils:combine_heap_needs/2 stopped wrapping an allocation list in an {alloc,...} tuple. That was not noticed because the faulty heap need created in beam_block was discarded by beam_type.
2018-01-10Correct beam_utils:is_killed/3Björn Gustavsson
beam_utils:is_killed/3 could incorrectly indicate that a register was killed, when in fact it was referenced by an instruction that did a GC.
2018-01-10Merge branch 'maint'Björn Gustavsson
* maint: beam_validator: Strengthen validation of GC instructions
2018-01-10Merge pull request #1674 from bjorng/bjorn/compiler/beam_validatorBjörn Gustavsson
beam_validator: Strengthen validation of GC instructions OTP-14863
2018-01-10Merge branch 'hasse/stdlib/erl_eval_stacktrace/OTP-14826/PR-1540'Hans Bolinder
* hasse/stdlib/erl_eval_stacktrace/OTP-14826/PR-1540: syntax_tools: Correct handling of stacktrace variable stdlib: Add check of stacktrace variable to erl_eval stdlib: Improve erl_eval's stacktraces
2018-01-10Merge branch 'maint'Hans Bolinder
* maint: dialyzer: Add a test of erl_tar:table/1,2 Fix false Dialyzer warnings for erl_tar:table/1
2018-01-10Merge branch ↵Hans Bolinder
'hasse/stdlib/incomplete_erl_tar_function_spec/OTP-14860/PR-1670' into maint * hasse/stdlib/incomplete_erl_tar_function_spec/OTP-14860/PR-1670: dialyzer: Add a test of erl_tar:table/1,2 Fix false Dialyzer warnings for erl_tar:table/1
2018-01-09Merge branch 'maint'Hans Nilsson
* maint: ssh: A compatibility testing suite using dockers This suite tests compatibility with different combinations of OpenSSH and OpenSSL. The peer SSH is running in a docker container.
2018-01-09Merge branch 'hans/ssh/docker_compat_tests/OTP-14194' into maintHans Nilsson
* hans/ssh/docker_compat_tests/OTP-14194: ssh: A compatibility testing suite using dockers This suite tests compatibility with different combinations of OpenSSH and OpenSSL. The peer SSH is running in a docker container.
2018-01-09syntax_tools: Correct handling of stacktrace variableHans Bolinder
A quick fix to make the test suite work with the updated erl_eval. [I think that if "A:B:_" is allowed, it should have a representation in the abstract format, but that's another story. The pretty printer should not modify the source code, just print it nicely, IMHO. (But removing parentheses is OK)]
2018-01-09stdlib: Add check of stacktrace variable to erl_evalHans Bolinder
Some of the functions of the erl_eval module do not call the Erlang code linter, so they need to explicitly check that the newly introduced stacktrace variable is not bound.
2018-01-09stdlib: Improve erl_eval's stacktracesHans Bolinder
The call "erlang:get_stacktrace()" is not handled explicitly. If there are issues, they can probably be ignored since erlang:get_stacktrace/1 will be deprecated and removed.
2018-01-09dialyzer: Add a test of erl_tar:table/1,2Hans Bolinder
2018-01-09Fix false Dialyzer warnings for erl_tar:table/1Guilherme Andrade
'tar_entry()' values are only returned if we specify the 'verbose' option when calling table/2, which table/1 doesn't do. Now, it appears that Dialyzer as of OTP 20 is clever enough to realize that the return type of table/1 must intersect with the return type of table/2, and so it ignores the fact that table/1 says it returns strings, and therefore its callers are expected to be dealing with 'tar_entry()' tuples, and never with strings. This is obviously a mismatch between what the code does and what the spec says is does, leading to false Dialyzer warnings on code that uses table/1 (and, presumably, also table/2 when called without the 'verbose' option.)
2018-01-09Merge branch 'maint'Siri Hansen
2018-01-09Merge branch 'siri/etop/include/ERL-534/OTP-14842' into maintSiri Hansen
* siri/etop/include/ERL-534/OTP-14842: [observer] Use include_lib instead of include with relative path Add runtime_tools/include to tertiary bootstrap
2018-01-09Merge branch 'maint'Hans Bolinder
* maint: dialyzer: Correct handling of erlang:abs/1
2018-01-09Merge branch 'hasse/dialyzer/fix_abs/OTP-14858/ERL-551' into maintHans Bolinder
* hasse/dialyzer/fix_abs/OTP-14858/ERL-551: dialyzer: Correct handling of erlang:abs/1
2018-01-09Merge branch 'maint'Siri Hansen
2018-01-09Merge branch 'siri/cdv/crash-when-truncated-in-mod-attr/ERL-537/OTP-14846' ↵Siri Hansen
into maint * siri/cdv/crash-when-truncated-in-mod-attr/ERL-537/OTP-14846: [cdv] Don't crash when dump is truncated in module attributes
2018-01-09Merge branch 'maint'Ingela Anderton Andin
2018-01-09Merge branch 'ingela/dtls/test-cuddle' into maintIngela Anderton Andin
* ingela/dtls/test-cuddle: dtls: Filter out rc4 for DTLS psk suites dtls: We do not need to wait for DTLS over UDP server
2018-01-08Reintroduce the arity optimization removed in OTP-14855John Högberg
We can safely tell when a test_arity or is_record instruction is superflous by keeping track of whether the size is exactly known or not.
2018-01-08dialyzer: Correct handling of erlang:abs/1Hans Bolinder
See also https://bugs.erlang.org/browse/ERL-551.
2018-01-08ssh: A compatibility testing suite using dockersHans Nilsson
This suite tests compatibility with different combinations of OpenSSH and OpenSSL. The peer SSH is running in a docker container.
2018-01-08Merge branch 'john/erts/putenv-thread-safety/OTP-14666'John Högberg
2018-01-08Merge branch 'maint'John Högberg
2018-01-08beam_validator: Strengthen validation of GC instructionsBjörn Gustavsson
beam_validator did not verify that the Y registers were initialized before executing the following instructions that could cause a GC: bs_append/8 bs_init2/6 bs_init_bits/6 gc_bif1/5 gc_bif2/6 gc_bif3/7 test_heap/2 That means that, for example, an incorrect optimization that replaced an 'allocate_zero' instruction with an 'allocate' instruction when it was not safe, would not be rejected by beam_validtor, but would instead cause a crash or other undefined behavior at runtime. Also fix a minor bug in beam_type exposed by the stronger checking. When compiling from .S files, beam_type did not handle the init/1 instruction and could produce unsafe code.