aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam
AgeCommit message (Collapse)Author
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-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-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-10erts: Add etp_the_non_valueSverker Eriksson
for a correct (non)value regardless of build type.
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-10erts: Fix building of Map result from match_specsBjörn-Egil Dahlberg
A faulty "box-value" entered into the heap which could cause a segmentation fault in the garbage collector if it was written on a heap fragment.
2015-04-10Keep dirty schedulers from waking other schedulersSteve Vinoski
Prevent dirty schedulers from checking regular run queues and trying to wake up regular schedulers.
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-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 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-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: 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-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-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-27erts: Eliminate potential heap fragments after Map creationBjörn-Egil Dahlberg
2015-03-27erts: Fix make_internal_hash for 0.0 vs -0.0Björn-Egil Dahlberg
The internal_hash should produce the same hash value for identical terms, in this case 0.0 =:= -0.0.
2015-03-27Merge branch 'maint'Sverker Eriksson
Conflicts: lib/stdlib/src/stdlib.appup.src
2015-03-27Merge branch 'sverk/large-list_to_integer-bug/OTP-12624' into maintSverker Eriksson
* sverk/large-list_to_integer-bug/OTP-12624: erts: Fix bug in list_to_integer for very large strings
2015-03-27Merge branch 'dgud/erts/fix-driver-thread-name'Dan Gudmundsson
* dgud/erts/fix-driver-thread-name: Fix thread name from driver api
2015-03-27Merge branch 'egil/fix-make_internal_hash'Björn-Egil Dahlberg
* egil/fix-make_internal_hash: erts: Fix missing case in make_internal_hash
2015-03-26Merge branch 'sverk/hamt-encode-size-bug/OTP-12585'Sverker Eriksson
* sverk/hamt-encode-size-bug/OTP-12585: erts: Fix bug in term_to_binary size estimation for hamt erts: Optimize term_to_binary size estimation
2015-03-26erts: Fix missing case in make_internal_hashBjörn-Egil Dahlberg
2015-03-26Merge branch 'rickard/time_api/OTP-11997'Rickard Green
* rickard/time_api/OTP-11997: Misc fixes Conflicts: erts/preloaded/ebin/erlang.beam erts/preloaded/ebin/erts_internal.beam
2015-03-26Misc fixesRickard Green
2015-03-26Merge branch 'egil/maint/process_dictionary-initial-size/OTP-12535' into maintBjörn-Egil Dahlberg
* egil/maint/process_dictionary-initial-size/OTP-12535: erts: Document option 'hpds' erts: Enable command line argument for initial pd size
2015-03-26Merge branch 'egil/maps/refactor-tagscheme/OTP-12585'Björn-Egil Dahlberg
* egil/maps/refactor-tagscheme/OTP-12585: erts: Refactor Map - use multiple values ESTACK_PUSHN erts: GC needs the size even if the frag is not referenced Revert "hipe: Handle separate hashmap tag correctly" erts: Combine flat and hash maps under one unifying tag
2015-03-25erts: Fix bug in term_to_binary size estimation for hamtSverker Eriksson
2015-03-25erts: Optimize term_to_binary size estimationSverker Eriksson
for tuples and maps containing ascii strings (lists).