aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib
AgeCommit message (Collapse)Author
2015-05-11Merge branch 'egil/fix-maps-copy-shallow'Björn-Egil Dahlberg
* egil/fix-maps-copy-shallow: erts: Make hashmap_get halfword safe erts: Fix ETS db_has_variable check for large Maps stdlib: Strengthen ETS Maps tests erts: Fix copy shallow for large Maps stdlib: Strengthen ETS Maps tests erts: ETS ordered_set cannot use it's optimization with Maps stdlib: Strengthen ETS Maps tests stdlib: Refactor away ?line macro
2015-05-08Fixed a typo in Maps docBruce Yinhe
2015-05-08Delete superfluous comma from `filtermap' exampleAndras Horvath
The code explaining the behaviour of `filtermap/2` had a syntax error and wouldn't compile
2015-05-08Merge branch 'bjorn/stdlib/fix-filename-split/OTP-12716'Björn Gustavsson
* bjorn/stdlib/fix-filename-split/OTP-12716: Correct filename:split(<<"">>)
2015-05-08Merge branch 'dgud/stdlib/rand/OTP-12586'Dan Gudmundsson
* dgud/stdlib/rand/OTP-12586: stdlib: Document and add normal distributed random value function stdlib: Add new random functionality/module
2015-05-07stdlib: Strengthen ETS Maps testsBjörn-Egil Dahlberg
Ensure db_has_variable is tested for large Maps as well.
2015-05-07stdlib: Strengthen ETS Maps testsBjörn-Egil Dahlberg
Strengthen tests of large Maps in ETS.
2015-05-07stdlib: Strengthen ETS Maps testsBjörn-Egil Dahlberg
The additional tests in match_object focus on ordered sets.
2015-05-07stdlib: Refactor away ?line macroBjörn-Egil Dahlberg
2015-05-06Correct filename:split(<<"">>)Björn Gustavsson
filename:split("") returns [], while filename:split(<<"">>) returns [<<"/">>]. Since the support in the filename module for binary arguments is much more recent than support for strings, change filename:split(<<"">>) so that it returns []. Noticed-by: KOUCHANG
2015-05-04Merge branch 'peppe/jcl_mode_improvements'Peter Andersson
* peppe/jcl_mode_improvements: Fix problem with unitialized edlin text buffer Fix shell crash when in switch command mode OTP-12673
2015-04-30stdlib: Document and add normal distributed random value functionDan Gudmundsson
It is needed in various tests. It uses the Ziggurat algorithm, which is the fastest that I know.
2015-04-30Ensure that erl_anno is used when building the primary bootstrapBjörn Gustavsson
As the erl_anno module is used by the compiler, it must be included in the set of modules that are used when building the primary bootstrap.
2015-04-30stdlib: Silence some of qlc's warningsHans Bolinder
As long as the Erlang Compiler and qlc do not agree on the location of LC warnings, qlc's own warnings about patterns and filters that always fail have been silenced.
2015-04-30stdlib: Use module erl_annoHans Bolinder
2015-04-30stdlib: Add module erl_annoHans Bolinder
Introduce erl_anno, an abstraction of the second element of tokens and tuples in the abstract format. The convention that negative line numbers can be used for silencing compiler warnings will no longer work in OTP 19; instead the annotation 'generated' is to be used.
2015-04-29stdlib: Add new random functionality/moduleKenji Rikitake
The old random module contains an old algorithm which have flaws and the api requires the user to invoke seed and or checking if seed have been invoked, if a non constant seed is to be used. The api contains the following features: - The user can invoke rand:unform/[0|1] directly and get a non constant seeding. - The api is split in functional and non functional functions, i.e. usage of _s functions will not affect the process dictionary. - The api contains several algorithms with different characteristics and can be extended with new algorithms in the future. - Contains state of the art random number generators. - Default algorithm is taylor made for erlang to be fast on 64bits machines.
2015-04-27Merge branch 'derek121/gen_server_doc_grammar'Zandra Hird
* derek121/gen_server_doc_grammar: Fix grammar in docs for multi_call/*
2015-04-27Merge branch 'bjorn/use-monotonic-time'Björn Gustavsson
* bjorn/use-monotonic-time: supervisor: Correct restart handling test_server: Use erlang:monotonic_time/0 compile: Teach 'time' option to show three significant decimals timer: Use monotonic_time/0 in tc/1,2,3
2015-04-27stdlib: Substitute set() for gb_sets:set() in gb_setsHans Bolinder
2015-04-22supervisor: Correct restart handlingBjörn Gustavsson
fbaa0bec replaced the use of now/0 with erlang:monotonic_time/1 but at the same time introduced a bug in inPeriod/3 so that it would always return 'true' (the subtraction Time - Now would always result in a non-positive number that would always be less than Period). The symptoms of the bug is that when a child has been restarted the maximum number of times allowed, the supervisor will terminate, regardless of how much time that elapses between the restarts. There was no test case that detected this problem. Add the missing test case to ensure that this bug stays killed. Reported-by: Rafał Studnicki
2015-04-22Fix problem with unitialized edlin text bufferPeter Andersson
Also make it possible to copy text buffer from current group process to the JCL mode
2015-04-22Merge branch 'bjorn/compiler/eprof'Björn Gustavsson
* bjorn/compiler/eprof: v3_life: Optimize updating of the variable data base beam_jump: Replace use of lists:dropwhile/2 with a custom function beam_asm: Eliminate unnecessary use of iolist_to_binary/1 beam_bsm: Optimize btb_index() beam_type: Eliminate redundant calls to checkerror_1/2 erl_expand_records: Simplify handling of call_ext instructions beam_utils: Optimize index_labels_1/2 beam_block: Optimize matching of binary literals Move rewriting of bs_match from beam_clean to beam_z v3_codegen: Reduce cost for fixing up bs_match_string instructions v3_codegen: Optimize "turning" of y registers v3_kernel: Optimize subst_vsub/3 orddict: Eliminate unnecessary consing in store/3 and others compile: Add the {eprof,Pass} option for easy eprof running compile: Eliminate unnecessary wrappers for compiler passes Add z_SUITE to validate loaded code test suite: Always place .core files in data directories test suites: Unload modules compiled from .core or .S compilation_SUITE: Unload tested modules using the code server
2015-04-22erl_expand_records: Simplify handling of call_ext instructionsBjörn Gustavsson
The erl_expand_records module have inherited code from sys_pre_expand. We can simplify the code for handling the call_ext instruction to make the code clearer and a smidge faster.
2015-04-22orddict: Eliminate unnecessary consing in store/3 and othersBjörn Gustavsson
As a minor optimization, eliminate unnecessary cons operations in store/3, append/3, append_list/3, update/4, and update_counter/3.
2015-04-21Merge branch 'zandra/fix-ssl-obsolete-arity'Zandra Hird
* zandra/fix-ssl-obsolete-arity: add arity to obsolete_1(ssl, negotiated_next_protocol, 1)
2015-04-20timer: Use monotonic_time/0 in tc/1,2,3Björn Gustavsson
2015-04-20Merge branch 'wmalik/slave-specs'Björn Gustavsson
* wmalik/slave-specs: Remove unused comments Fix Host and Name type in slave.erl
2015-04-20zip: Suppress a dialyzer warning for an unmatched returnBjörn Gustavsson
A warning for an unmatched return was introduced in aaa7c917. The caller of openzip_close/1 ignores the return value, which could be an error tuple. In this situation, handling a fatal error, it is OK to ignore the return value; thus, we only need to make it explicit that we are ignoring the return value.
2015-04-16Merge branch 'bjorn/maps'Björn Gustavsson
* bjorn/maps: Document the new {badmap,Term} and {badkey,Key} exceptions Raise more descriptive error messages for failed map operations erl_term.h: Add is_not_map() macro Tigthen code for the i_get_map_elements/3 instruction Pre-compute hash values for the general get_map_elements instruction Teach the loader to pre-compute the hash value for single-key lookups Optimize use of i_get_map_element/4 beam_emu: Slightly optimize update_map_{assoc,exact} v3_codegen: Don't sort map keys in map creation/update beam_validator: No longer require strict literal term order Sort maps keys in the loader De-optimize the has_map_fields instructions erts/map_SUITE.erl: Add a test case that tests has_map_fields Fully evaluate is_map/1 for literals at load-time map_SUITE: Add tests of is_map/1 with literal maps Run a clone of map_SUITE without optimizations Remove the fail label operand of the new_map instruction Correct transformation of put_map_assoc to new_map Remove support for put_map_exact without a source map
2015-04-15Document the new {badmap,Term} and {badkey,Key} exceptionsBjörn Gustavsson
2015-04-15Raise more descriptive error messages for failed map operationsBjörn Gustavsson
According to EEP-43 for maps, a 'badmap' exception should be generated when an attempt is made to update non-map term such as: <<>>#{a=>42} That was not implemented in the OTP 17. José Valim suggested that we should take the opportunity to improve the errors coming from map operations: http://erlang.org/pipermail/erlang-questions/2015-February/083588.html This commit implement better errors from map operations similar to his suggestion. When a map update operation (Map#{...}) or a BIF that expects a map is given a non-map term, the exception will be: {badmap,Term} This kind of exception is similar to the {badfun,Term} exception from operations that expect a fun. When a map operation requires a key that is not present in a map, the following exception will be raised: {badkey,Key} José Valim suggested that the exception should be {badkey,Key,Map}. We decided not to do that because the map could potentially be huge and cause problems if the error propagated through links to other processes. For BIFs, it could be argued that the exceptions could be simply 'badmap' and 'badkey', because the bad map and bad key can be found in the argument list for the BIF in the stack backtrace. However, for the map update operation (Map#{...}), the bad map or bad key will not be included in the stack backtrace, so that information must be included in the exception reason itself. For consistency, the BIFs should raise the same exceptions as update operation. If more than one key is missing, it is undefined which of keys that will be reported in the {badkey,Key} exception.
2015-04-14Fix grammar in docs for multi_call/*Derek Brown
2015-04-14Merge branch 'egil/fix-maps-module-exceptions/OTP-12657'Björn-Egil Dahlberg
* egil/fix-maps-module-exceptions/OTP-12657: stdlib: Correct maps module exceptions upon errors
2015-04-14stdlib: Correct orddict(3)Hans Bolinder
fold() and map() handle elements in a well-defined order. Thanks to Rabbe Fogelholm for pointing out the bug.
2015-04-13add arity to obsolete_1(ssl, negotiated_next_protocol, 1)Zandra Hird
2015-04-13stdlib: Correct maps module exceptions upon errorsBjörn-Egil Dahlberg
Bad input to maps module function will now yield exceptions: * {badmap,NotMap} or, * badarg
2015-04-10Merge branch 'bjorn/stdlib/cuddle-with-tests'Björn Gustavsson
* bjorn/stdlib/cuddle-with-tests: Eliminate deprecated now/0 used as timestamp Eliminate use of now/0 for creating a unique filename Eliminate use of deprecated now/0 for measuring time Eliminate use of deprecated now/0 for random number generation Speed up timer_simple_SUITE:timer_perf/1 Speed up timer_SUITE Optimize gen_server_SUITE:hibernate/1 Optimize gen_event_SUITE:hibernate/1 Optimize gen_fsm_SUITE:hibernate/1 Optimize unicode_SUITE:ex_binaries_errors* test cases Optimize unicode_SUITE:binaries_errors/1 binary_module_SUITE: Remove unnecessary calls to the binref module Optimize binary_module:random_ref_comp/1 Optimize io_proto_SUITE:unicode_options_gen/1
2015-04-10Eliminate deprecated now/0 used as timestampBjörn Gustavsson
Rewrite the code to measure and print elapsed time instead of just printing timestamps for the start and stop of each operation.
2015-04-10Eliminate use of now/0 for creating a unique filenameBjörn Gustavsson
Use erlang:unique_integer/1 instead.
2015-04-10Eliminate use of deprecated now/0 for measuring timeBjörn Gustavsson
Use erlang:monotonic_time/1 instead of now/0.
2015-04-10Eliminate use of deprecated now/0 for random number generationBjörn Gustavsson
Use erlang:timestamp/0 instead now/0 when seeding the random number generator.
2015-04-10Speed up timer_simple_SUITE:timer_perf/1Björn Gustavsson
In big_test/1, there is 9 seconds sleep before spawning any timers. Why? Before the sleep nrev processes are started, but they are likely to finish running before the 9 seconds have elapsed. Since I see no reason at all for the sleep, I will remove it.
2015-04-10Speed up timer_SUITEBjörn Gustavsson
The single test case in timer_SUITE is annoyingly slow. On average, its running time is about 4 minutes (estimated by a back-of-the-envelope calculation). Scale down the delay times in the main loop and the length of timers started. The running average time should now be around 80 seconds.
2015-04-10Optimize gen_server_SUITE:hibernate/1Björn Gustavsson
The running time for gen_server_SUITE:hibernate/1 is about 12 seconds because of 1000 ms sleeps in the test case. Introduce a helper function to avoid sleeping more than necessary. While we are it, also remove all ?line macros in the test case.
2015-04-10Optimize gen_event_SUITE:hibernate/1Björn Gustavsson
The running time for gen_event_SUITE:hibernate/1 is about 20 seconds because of 1000 ms sleeps in the test case. Introduce helper functions to avoid sleeping more than necessary. While we are it, also remove all ?line macros in the test case.
2015-04-10Optimize gen_fsm_SUITE:hibernate/1Björn Gustavsson
The running time for gen_fsm_SUITE:hibernate/1 is almost 30 seconds because of 1000 ms sleeps in the test case. Introduce helper functions to avoid sleeping more than necessary. While we are it, also remove all ?line macros in the test case.
2015-04-10Optimize unicode_SUITE:ex_binaries_errors* test casesBjörn Gustavsson
Refactor the code so that the error test cases for utf16 can share the code for big and little endian. Do the same for utf32. The major optimization is the observation that the following code: byte_size(unicode:characters_to_binary(List, unicode, {utf16,big}) can be replaced with: 2*length(List) which is much faster. (That optimization is not safe in general, but for the lists used in the error tests cases, it is.)
2015-04-10Optimize unicode_SUITE:binaries_errors/1Björn Gustavsson
unicode_SUITE:binaries_errors/1 is the slowest test case in unicode_SUITE. Its running time is about 50 seconds on my computer. Break apart unicode_SUITE:binaries_errors/1 into several test cases that can run in parallel.
2015-04-10binary_module_SUITE: Remove unnecessary calls to the binref moduleBjörn Gustavsson
The compile_pattern/1 function in the binref module is a dummy function. Therefore, calling binref:match/2 once with the plain pattern and once with a "pre-compiled" pattern will take twice as long, but will not help us find more errors. I shaved off one fourth of the running time for random_ref_comp/1 by eliminating the unnecessary calls to the binref module.