aboutsummaryrefslogtreecommitdiffstats
path: root/erts
AgeCommit message (Collapse)Author
2015-04-13erl_term.h: Add is_not_map() macroBjörn Gustavsson
For consistency with other data types, add the is_not_map() macro.
2015-04-13Tigthen code for the i_get_map_elements/3 instructionBjörn Gustavsson
2015-04-13Pre-compute hash values for the general get_map_elements instructionBjörn Gustavsson
See the previous commit for justification and use cases.
2015-04-13Teach the loader to pre-compute the hash value for single-key lookupsBjörn Gustavsson
Let the loader pre-compute the hash value when a single, literal key is matched as in: #{<<"some_key">>:=V} = Map In my measurements, this optimization resulted in a 30 percent speedup for short binary keys. Unfortunately, this optimizization makes no difference for small maps with less than 32 keys, since the hash value is not used. Still, there are the following use cases: * A map used instead of a record with more than 32 entries. I have seen some applications with huge records. * Lookup in JSON dictionaries represented as maps. The hash value will only be used when the map is a hash map (currently, that means at least 32 entries).
2015-04-13Optimize use of i_get_map_element/4Björn Gustavsson
In the i_get_map_element/4 instruction, for literal keys other than atoms, the key would be put into x[0] instead of used directly in the instruction. The reason is that the original implementation of maps only supported atom keys.
2015-04-13beam_emu: Slightly optimize update_map_{assoc,exact}Björn Gustavsson
In the update loop for big maps, the E variable is restored for each turn of the loop. It only needs to be restored if a garbage collection has been performed. Also add a new test case that attempts to force several garbage collections while updating a map, to help us find bugs with incorrect restoration of the E variable after a garbage collection.
2015-04-13Sort maps keys in the loaderBjörn Gustavsson
The map instructions require that the keys in the instructions are sorted (for flatmaps). But that is an implementation detail that should not exposed outside of the BEAM virtual machine. Therefore, make the sorting of the keys the responsibility of the loader and not the compiler. Also note that the sort order for maps with numeric keys or keys with numeric components has changed in OTP 18. That means that code compiled for OTP 17 that operated on maps with map keys might not work in OTP 18 without the sorting in the loader (although it is unlikely to be an issue in practice).
2015-04-13De-optimize the has_map_fields instructionsBjörn Gustavsson
The has_map_fields instruction is infrequently used. Thus there is no need to have the fastest possible implementation; it is better to have an implementation that reduces the code size in the already big process_main() function. We can transform has_map_fields to a get_map_elements instruction, targeting the same unused x[0] register for all keys. That instruction will only be marginally slower than existing implementation.
2015-04-13erts/map_SUITE.erl: Add a test case that tests has_map_fieldsBjörn Gustavsson
The has_map_fields instruction was not tested at all by erts/map_SUITE.erl
2015-04-13Fully evaluate is_map/1 for literals at load-timeBjörn Gustavsson
The compiler will only emit is_map/1 instructions with literal argument if optimization is turned off. Therefore, the only reason for this commit is cleanliness.
2015-04-13map_SUITE: Add tests of is_map/1 with literal mapsBjörn Gustavsson
To be sure that the compiler and BEAM virtual machine correctly handles literals maps, we must test it.
2015-04-13Run a clone of map_SUITE without optimizationsBjörn Gustavsson
Create a clone of map_SUITE named map_no_opt_SUITE to ensure that the loader can cope with unoptimized map instructions.
2015-04-13Remove the fail label operand of the new_map instructionBjörn Gustavsson
The new_map instruction cannot fail, and thus needs no fail label.
2015-04-13Correct transformation of put_map_assoc to new_mapBjörn Gustavsson
A put_map_assoc instruction with an empty source map should be converted to a simpler new_map instruction. The transformation didn't happen because an empty source map is no longer represented as a NIL term (as it was in the beginning before map literals were implemented).
2015-04-13Remove support for put_map_exact without a source mapBjörn Gustavsson
Using the exact operator (':=') is only allowed when an existing map is being updated. Thus the following causes a compilation error: #{k:=v} Therefore there is no need to support the put_map_exact instruction without a source map.
2015-04-10Merge branch 'egil/maps-test-coverage'Björn-Egil Dahlberg
* egil/maps-test-coverage: erts: Remove code that was commented out erts: Cover maps:values/1 for large maps erts: Test maps:from_list/1 shrinking
2015-04-10Merge branch 'egil/fix-maps-deep-colliding-merge'Björn-Egil Dahlberg
* egil/fix-maps-deep-colliding-merge: erts: Fix deep colliding hash values in maps:from_list/1
2015-04-10Merge branch 'egil/fix-hash-float-zero/OTP-12641'Björn-Egil Dahlberg
* egil/fix-hash-float-zero/OTP-12641: erts: Ensure hashing of zero is consistent
2015-04-10erts: Ensure hashing of zero is consistentBjörn-Egil Dahlberg
Erlang treats positive and negative zero as equal, meaning, true = 0.0 =:= 0.0/-1 However, Erlangs hash functions: hash, phash and phash2 did not reflect this behaviour. Meaning, the hash values produced by the different hash functions would not be identical for positive and negative zero. This commit ensures that hash value of positive zero is always produced regardless of the signedness of the zero float, i.e. true = erlang:phash2(0.0) =:= erlang:phash2(0.0/-1)
2015-04-10erts: Remove code that was commented outBjörn-Egil Dahlberg
2015-04-09Merge branch 'sverk/maps-bin2term-eqhash-bug/12585'Sverker Eriksson
* sverk/maps-bin2term-eqhash-bug/12585: erts: Fix bug in map_from_list when keys clash in both value and hash erts: Fix bug in binary_to_term for big maps with 32 bit hash-clash
2015-04-09erts: Cover maps:values/1 for large mapsBjörn-Egil Dahlberg
2015-04-09erts: Test maps:from_list/1 shrinkingBjörn-Egil Dahlberg
Repeated keys will shrink map to a flatmap if the number of pairs drops below the limit.
2015-04-08Merge branch 'sverk/refactor-encode-size/OTP-12585'Sverker Eriksson
* sverk/refactor-encode-size/OTP-12585: erts: Optimize insert and delete for big maps erts: Optimize == and /= for unequal big maps erts: Refactor encode_size_struct_int Conflicts: erts/emulator/beam/erl_map.c
2015-04-08Merge branch 'sverk/ets-grow-faulty-assert/OTP-12647'Sverker Eriksson
* sverk/ets-grow-faulty-assert/OTP-12647: erts: Fix ets bug in debug VM
2015-04-08erts: Fix ets bug in debug VMSverker Eriksson
Symptom: ASSERT(segtab[seg_ix] == NULL) in alloc_seg() fails. Remedy: Make sure we set segment pointer to NULL in free_seg() even when we switch to smaller segtab.
2015-04-08Merge branch 'sverk/valgrind-broken_halt'Sverker Eriksson
* sverk/valgrind-broken_halt: erts: Suppress valgrind for bif_SUITE:erlang_halt
2015-04-07erts: Fix bug in map_from_list when keys clash in both value and hashSverker Eriksson
Subtle bug in qsort callback. Cast from Sint to int does not retain sign.
2015-04-07erts: Fix bug in binary_to_term for big maps with 32 bit hash-clashSverker Eriksson
binary_to_term threw badarg as the "reject_dupkey" case in hashmap_from_unsored_array was always triggered when hash-clash was found as the first round in the loop compared the key with itself.
2015-04-07erts: Fix deep colliding hash values in maps:from_list/1Björn-Egil Dahlberg
Reported-by: Jesper Louis Andersen
2015-04-01Merge tag 'OTP-17.5'Henrik Nord
=== OTP-17.5 === Changed Applications: - asn1-3.0.4 - common_test-1.10 - compiler-5.0.4 - crypto-3.5 - debugger-4.0.3 - dialyzer-2.7.4 - diameter-1.9 - eldap-1.1.1 - erts-6.4 - hipe-3.11.3 - inets-5.10.6 - kernel-3.2 - mnesia-4.12.5 - observer-2.0.4 - os_mon-2.3.1 - public_key-0.23 - runtime_tools-1.8.16 - ssh-3.2 - ssl-6.0 - stdlib-2.4 - syntax_tools-1.6.18 - test_server-3.8 - tools-2.7.2 - wx-1.3.3 Unchanged Applications: - cosEvent-2.1.15 - cosEventDomain-1.1.14 - cosFileTransfer-1.1.16 - cosNotification-1.1.21 - cosProperty-1.1.17 - cosTime-1.1.14 - cosTransactions-1.2.14 - edoc-0.7.16 - erl_docgen-0.3.7 - erl_interface-3.7.20 - et-1.5 - eunit-2.2.9 - gs-1.5.16 - ic-4.3.6 - jinterface-1.5.12 - megaco-3.17.3 - odbc-2.10.22 - orber-3.7.1 - ose-1.0.2 - otp_mibs-1.0.10 - parsetools-2.0.12 - percept-0.8.10 - reltool-0.6.6 - sasl-2.4.1 - snmp-5.1.1 - typer-0.9.8 - webtool-0.8.10 - xmerl-1.3.7 Conflicts: OTP_VERSION erts/vsn.mk lib/ssl/vsn.mk
2015-04-01Merge branch 'egil/fix-maps-tmp-heap'Björn-Egil Dahlberg
* egil/fix-maps-tmp-heap: erts: Test deep Maps updates erts: Use halfword secure tmp heap erts: Remove unused tmp heap in make_internal_hash Conflicts: erts/emulator/test/map_SUITE.erl
2015-04-01Merge branch 'egil/fix-maps-from_list-size'Björn-Egil Dahlberg
* egil/fix-maps-from_list-size: erts: Strengthen Maps merge tests erts: Try to test deep Maps collision erts: Fix size bug in maps:from_list/1 BIF
2015-03-31erts: Test deep Maps updatesBjörn-Egil Dahlberg
2015-03-31erts: Use halfword secure tmp heapBjörn-Egil Dahlberg
2015-03-31erts: Remove unused tmp heap in make_internal_hashBjörn-Egil Dahlberg
2015-03-31erts: Strengthen Maps merge testsBjörn-Egil Dahlberg
2015-03-31erts: Try to test deep Maps collisionBjörn-Egil Dahlberg
Ensure maps:size/1 is correct.
2015-03-31erts: Fix size bug in maps:from_list/1 BIFBjörn-Egil Dahlberg
The wrong size was imprinted on maps with deep hash key collisions.
2015-03-31Prepare releaseErlang/OTP
2015-03-31erts: Optimize insert and delete for big mapsSverker Eriksson
Do fast path without bit count for full internal nodes.
2015-03-30erts: Optimize == and /= for unequal big mapsSverker Eriksson
Bail out as soon as we find a diff between maps if we are not interested in term order.
2015-03-30erts: Refactor encode_size_struct_intSverker Eriksson
to handle the "start of list" case in one place and not seven. Note that this commit reverts (47d6fd3ccf35) back to using WSTACK and pushing raw pointers. We disable GC while yielding, so this should not be a problem.
2015-03-30erts: Suppress valgrind for bif_SUITE:erlang_haltSverker Eriksson
which does a deliberate deref of null pointer which is caught by a SEGV signal handler to resume crash dumping.
2015-03-30erts: Strengthen Maps testsBjörn-Egil Dahlberg
2015-03-30Merge branch 'egil/fix-maps-new_map-instruction'Björn-Egil Dahlberg
* egil/fix-maps-new_map-instruction: erts: Eliminate potential heap fragments after Map creation
2015-03-30Merge branch 'egil/fix-make_internal_hash-float'Björn-Egil Dahlberg
* egil/fix-make_internal_hash-float: erts: Add tests for internal_hash erts: Fix make_internal_hash for 0.0 vs -0.0
2015-03-30Merge branch 'egil/maps/tests'Björn-Egil Dahlberg
* egil/maps/tests: debugger: Strengthen Maps tests compiler: Strengthen Maps tests erts: Strengthen Maps tests
2015-03-27erts: Eliminate potential heap fragments after Map creationBjörn-Egil Dahlberg
2015-03-27erts: Add tests for internal_hashBjörn-Egil Dahlberg