aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/src
AgeCommit message (Collapse)Author
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-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-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-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-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-03-31Remove unused commentsWasif Malik
2015-03-31Fix Host and Name type in slave.erlWasif Malik
In the start/1,2,3 and start_link/1,2,3 functions, the Host and Name arguments can be either string() or atom() but the specs only mentioned atom().
2015-03-27Merge branch 'maint'Sverker Eriksson
Conflicts: lib/stdlib/src/stdlib.appup.src
2015-03-26stdlib: Support upgrading from and to stdlib-2.3Björn Gustavsson
2015-03-20Merge branch 'rickard/time_api/OTP-11997'Rickard Green
* rickard/time_api/OTP-11997: (22 commits) Update primary bootstrap inets: Suppress deprecated warning on erlang:now/0 inets: Cleanup of multiple copies of functions Add inets_lib with common functions used by multiple modules inets: Update comments Suppress deprecated warning on erlang:now/0 Use new time API and be back-compatible in inets Remove unused functions and removed redundant test asn1 test SUITE: Eliminate use of now/0 Disable deprecated warning on erlang:now/0 in diameter_lib Use new time API and be back-compatible in ssh Replace all calls to now/0 in CT with new time API functions test_server: Replace usage of erlang:now() with usage of new API Replace usage of erlang:now() with usage of new API Replace usage of erlang:now() with usage of new API Replace usage of erlang:now() with usage of new API Replace usage of erlang:now() with usage of new API otp_SUITE: Warn for calls to erlang:now/0 Replace usage of erlang:now() with usage of new API Multiple timer wheels Erlang based BIF timer implementation for scalability Implement ethread events with timeout ... Conflicts: bootstrap/bin/start.boot bootstrap/bin/start_clean.boot bootstrap/lib/compiler/ebin/beam_asm.beam bootstrap/lib/compiler/ebin/compile.beam bootstrap/lib/kernel/ebin/auth.beam bootstrap/lib/kernel/ebin/dist_util.beam bootstrap/lib/kernel/ebin/global.beam bootstrap/lib/kernel/ebin/hipe_unified_loader.beam bootstrap/lib/kernel/ebin/inet_db.beam bootstrap/lib/kernel/ebin/inet_dns.beam bootstrap/lib/kernel/ebin/inet_res.beam bootstrap/lib/kernel/ebin/os.beam bootstrap/lib/kernel/ebin/pg2.beam bootstrap/lib/stdlib/ebin/dets.beam bootstrap/lib/stdlib/ebin/dets_utils.beam bootstrap/lib/stdlib/ebin/erl_tar.beam bootstrap/lib/stdlib/ebin/escript.beam bootstrap/lib/stdlib/ebin/file_sorter.beam bootstrap/lib/stdlib/ebin/otp_internal.beam bootstrap/lib/stdlib/ebin/qlc.beam bootstrap/lib/stdlib/ebin/random.beam bootstrap/lib/stdlib/ebin/supervisor.beam bootstrap/lib/stdlib/ebin/timer.beam erts/aclocal.m4 erts/emulator/beam/bif.c erts/emulator/beam/erl_bif_info.c erts/emulator/beam/erl_db_hash.c erts/emulator/beam/erl_init.c erts/emulator/beam/erl_process.h erts/emulator/beam/erl_thr_progress.c erts/emulator/beam/utils.c erts/emulator/sys/unix/sys.c erts/preloaded/ebin/erlang.beam erts/preloaded/ebin/erts_internal.beam erts/preloaded/ebin/init.beam erts/preloaded/src/erts_internal.erl lib/common_test/test/ct_hooks_SUITE_data/cth/tests/empty_cth.erl lib/diameter/src/base/diameter_lib.erl lib/kernel/src/os.erl lib/ssh/test/ssh_basic_SUITE.erl system/doc/efficiency_guide/advanced.xml
2015-03-20Replace usage of erlang:now() with usage of new APIRickard Green
2015-03-20Introduce a new time APIRickard Green
The old time API is based on erlang:now/0. The major issue with erlang:now/0 is that it was intended to be used for so many unrelated things. This tied these unrelated operations together and unnecessarily caused performance, scalability as well as accuracy, and precision issues for operations that do not need to have such issues. The new API spreads different functionality over multiple functions in order to improve on this. The new API consists of a number of new BIFs: - erlang:convert_time_unit/3 - erlang:monotonic_time/0 - erlang:monotonic_time/1 - erlang:system_time/0 - erlang:system_time/1 - erlang:time_offset/0 - erlang:time_offset/1 - erlang:timestamp/0 - erlang:unique_integer/0 - erlang:unique_integer/1 - os:system_time/0 - os:system_time/1 and a number of extensions of existing BIFs: - erlang:monitor(time_offset, clock_service) - erlang:system_flag(time_offset, finalize) - erlang:system_info(os_monotonic_time_source) - erlang:system_info(time_offset) - erlang:system_info(time_warp_mode) - erlang:system_info(time_correction) - erlang:system_info(start_time) See the "Time and Time Correction in Erlang" chapter of the ERTS User's Guide for more information.
2015-03-19Merge branch 'egil/maps/hamt/OTP-12585'Björn-Egil Dahlberg
* egil/maps/hamt/OTP-12585: (113 commits) erts: Fix bug in ESTACK and WSTACK kernel: Add spec for erts_debug:map_info/1 mnesia: Update mnesia tests to reflect new ETS hash erts: Ensure maps uses _rel functions in halfword erts: Do not treat errors as fatal in erl_printf_term erts: Update preloaded erts_internal.beam erts: Add map decomposition wrappers erts: Ensure halfword has correct temp-heap for maps hipe: Handle separate hashmap tag correctly erts: Fix map bug in dec_term for 32-bit debug VM stdlib: Update qlc tests to reflect new ETS hash stdlib: Remove obsolete hashmap references in io_lib erts: Enhance maps ordering tests hipe: Fix maps sort order testcase erts: Remove unused variable in crashdump creation erts: Fix typo in copy_struct for halfword emulator erts: Restrict GCC intrinsics by compiler version erts: Fix windows bug in hashmap_info erts: Fix typo in make_hash2 for 32-bit arch Fix beam_load assert ... Conflicts: erts/emulator/beam/bif.tab
2015-03-19stdlib: Remove obsolete hashmap references in io_libBjörn-Egil Dahlberg
2015-03-19Merge branch 'essen/ssl-alpn'Zandra Hird
* essen/ssl-alpn: ssl: Add TLS-ALPN support OTP-12580
2015-03-17Merge branch 'danielwhite/zip-port-leak-fix'Zandra Hird
OTP-12566 * danielwhite/zip-port-leak-fix: Describe zip handles an opaque type Document the termination semantics of a zip handle Prevent zip:zip_open/1,2 from leaking ports
2015-03-17ssl: Add TLS-ALPN supportLoïc Hoguin
This commit adds support for RFC7301, application-layer protocol negotiation. ALPN is the standard based approach to the NPN extension, and is required for HTTP/2. ALPN lives side by side with NPN and provides an equivalent feature but in this case it is the server that decides what protocol to use, not the client. When both ALPN and NPN are sent by a client, and the server is configured with both ALPN and NPN options, ALPN will always take precedence. This behavior can also be found in the OpenSSL implementation of ALPN. ALPN and NPN share the ssl:negotiated_protocol/1 function for retrieving the negotiated protocol. The previously existing function ssl:negotiated_next_protocol/1 still exists, but has been deprecated and removed from the documentation. The tests against OpenSSL require OpenSSL version 1.0.2+.
2015-03-16Merge branch 'nox/ets-update_counter-4'Zandra Hird
* nox/ets-update_counter-4: Create new BIF ets:update_counter/4 Allow 4-ary BIFs OTP-12563
2015-03-12stdlib: Enable io_lib:format/* for hamt mapsBjörn-Egil Dahlberg
This is a commit to enable printouts of hashmaps during development and will be enhanced once hashmaps are in place.
2015-03-12Create new BIF ets:update_counter/4Anthony Ramine
Conflicts: erts/emulator/beam/bif.tab lib/stdlib/src/ets.erl
2015-03-11Merge branch 'hb/pr/357'Hans Bolinder
* hb/pr/357: Make the scanned form of the io_lib format strings available for processing
2015-03-10Merge branch 'maint'Zandra Hird
2015-03-10Merge branch 'josevalim/jv-binary-ets' into maintZandra Hird
* josevalim/jv-binary-ets: Support binary standard input in ets:i/1 OTP-12550
2015-03-10Make the scanned form of the io_lib format strings available for processingRichard Carlsson
This adds three new functions to io_lib - scan_format/2, unscan_format/1, and build_text/1 - which expose the parsed form of the format control sequences to make it possible to easily modify or filter the input to io_lib:format/2. This can e.g. be used in order to replace unbounded-size control sequences like ~w or ~p with corresponding depth-limited ~W and ~P before doing the actual formatting.
2015-02-27Describe zip handles an opaque typeDaniel White
These are not intended to be treated as processes by consumers, and the type specs for the related functions have been updated accordingly.
2015-02-25Merge branch 'nox/stdlib/erl_lint-maps/OTP-12515'Björn Gustavsson
* nox/stdlib/erl_lint-maps/OTP-12515: Properly lint map expressions in erl_lint
2015-02-25Merge branch 'nox/stdlib/erl_lint-expr_list'Björn Gustavsson
* nox/stdlib/erl_lint-expr_list: Remove a few superfluous vt operations in erl_lint
2015-02-23Merge branch 'josevalim/stdlib/dict'Björn Gustavsson
* josevalim/stdlib/dict: Short-circuit common dict operations
2015-02-22Remove a few superfluous vt operations in erl_lintAnthony Ramine
Given any Vt1 and Vt2 values, vtmerge(vtnew(Vt1, Vt2), vtold(Vt1, Vt2)) is always equal to Vt1.
2015-02-19Short-circuit common dict operationsJosé Valim
Stop traversing all segments and buckets of empty dictionaries by adding a clause that checks the dictionary size. This improved compilation of an erlang project from 7.5s to 5.5s seconds when trying out a sample implementation of erl_lint that uses dicts.
2015-02-18Merge branch 'bjorn/stdlib/string-tokens/OTP-12422'Björn Gustavsson
* bjorn/stdlib/string-tokens/OTP-12422: Optimize string:tokens/2 Modernize and strengthen the test case for string:tokens/2
2015-02-18Optimize string:tokens/2Björn Gustavsson
We can save some time by reversing the original string before starting the tokenization. When there is only one separator, we can save even more time by treating that case specially so that we don't have to call lists:member/2 for each character.
2015-02-18Merge branch 'maint'Zandra Hird
2015-02-17make c:m/1 show module MD5Richard Carlsson
2015-02-16Properly lint map expressions in erl_lintAnthony Ramine
The returned variable table when linting a map expression shouldn't include variables that didn't appear in the expression. Reported-By: Alexei Sholik
2015-02-12core_lib: Deprecate functions that are no longer used by the compilerBjörn Gustavsson
2015-01-26Support binary standard input in ets:i/1José Valim
2015-01-17Prevent zip:zip_open/1,2 from leaking portsDaniel White
The case was discovered where a parent process would exit before closing the zip file. The result was that a port would be left open indefinitely, as the small zip server would not detect this condition. By comparison, the file module will close the associated port when the parent exits for any reason. This change would make the zip module more consistent with the semantics of similar modules. This change is breaking for any callers expecting to pass the handle to another process for processing (assuming it exits).
2015-01-16Merge branch 'oliv3/math_log2/OTP-12411'Marcus Arendt
* oliv3/math_log2/OTP-12411: Add math:log2/1