summaryrefslogtreecommitdiff
path: root/erts/emulator/beam/external.c
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'maint' into masterSverker Eriksson2023-04-261-20/+29
|\ | | | | | | | | | | | | | | This merge commit contains additional jit implementation for the hashmap collision nodes in beam/jit/x86/instr_map.cpp beam/jit/arm/instr_map.cpp
| * Merge branch 'sverker/24/erts/hashmap-collision-nodes' into ↵Sverker Eriksson2023-04-261-20/+29
| |\ | | | | | | | | | sverker/25/erts/hashmap-collision-nodes
| | * erts: Implement hashmap collision nodesSverker Eriksson2023-04-261-20/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Restrict depth of hashmap tree to 8 levels. Instead of rehashing with salt, give up and put colliding keys in "collision nodes" at the bottom of the tree. Collision nodes are normal tuples of arity 2 or larger. The elements of collision nodes are key-value cons cells like the other nodes, but they are sorted in map-key order. We do linear search in them, but that's ok as they should be small and rare in practice. Why? We had some scary encounter with forever colliding term pairs in make_internal_hash(). Even though that has been fixed we will sleep better at night knowing the hashmaps may not recurse forever draining all memory of the machine.
* | | [erts] Option 'local' of term_to_binary/2 and term_to_iovec/2Rickard Green2023-03-151-201/+594
| | | | | | | | | | | | | | | | | | | | | Introduce a local external term format with an unspecified encoding. This external term format is used for supporting the 'local' option of term_to_binary/2 and term_to_iovec/2. Terms encoded on this format is only to be decoded by the same runtime system instance that encoded it.
* | | erts: Make term_to_binary encode atoms as UTF-8 by defaultSverker Eriksson2023-03-101-3/+4
| | | | | | | | | | | | | | | That is, the default 'minor_version' option is changed from 1 to 2 for term_to_binary and term_to_iovec.
* | | Update copyright yearErlang/OTP2023-02-141-1/+1
| | |
* | | Merge branch 'jv-atom-pointer-order' OTP-18414Sverker Eriksson2023-01-241-4/+14
|\ \ \
| * | | erts: Optimize flatmap internal ordering of atomsSverker Eriksson2023-01-241-4/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The internal ordering of flatmap keys are changed to let atoms be ordered according to atom index. This improves lookup of smalll maps with atom keys as it avoids memory access of the atom table entries. This internal flatmap key order is implemented by new function erts_cmp_flatmap_keys(). Only top level atoms are affected by the new order. The ordering of other term types is unchanged. The two documented term orders are of course also unchanged; arithmetic and "map-key" order. This commit: * Add and use erts_cmp_flatmap_keys(). * Adjust term_to_binary(_, [deterministic]) for flatmaps. * Reimplement flatmap comparison (Map1 < Map2) to be correct, but more complex and expensive as it cannot rely on atoms to be "map-key" ordered. * Remove erts_map_from_sorted_ks_and_vs() and replace all uses with erts_map_from_ks_and_vs() as we cannot assume atom keys sort order in compile time. ToDo: * Optimize erts_cmp_compound() to not be recursive on C stack for flatmaps. It's unusual with deep maps-in-maps (I guess) but we have limited C stack and should avoid possibilities for Erlang code to exhaust it. * Comment and explain the flatmap comparison algorithm. Upcoming PR-6718 will add features to * print maps sorted (~k). * iterate over maps in a ordered way. Credit to José Valim <jose.valim@dashbit.co> for the initial idea, commit and benchmarks in https://github.com/erlang/otp/pull/6151.
* | | | erts: Remove some process VHEAP macrosSverker Eriksson2023-01-231-2/+2
|/ / /
* | | Merge branch 'maint'Sverker Eriksson2022-11-301-60/+62
|\ \ \ | |/ /
| * | Merge 'sverker/25/erts/decode-unsorted-smallmap-in-hashmap/OTP-18343' into maintSverker Eriksson2022-11-301-60/+62
| |\ \
| | * \ Merge branch 'sverker/23/erts/decode-unsorted-smallmap-in-hashmap/OTP-18343' ↵Sverker Eriksson2022-11-301-60/+62
| | |\ \ | | | | | | | | | | | | | | | into sverker/25/erts/decode-unsorted-smallmap-in-hashmap/OTP-18343
| | | * | erts: Fix bug decoding unsorted flatmaps as keys in hashmapSverker Eriksson2022-11-301-59/+61
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | "binary_to_term" of a hashmap (> 32 keys) with unsorted flatmap(s) (<= 32 keys) as key(s) inside the hashmap. The map term would be created but the map keys could not be found with maps:get and friends. Other operations such as map compare and merge could probably also give incorrect results. This was only be a problem if the term was encoded outside the VM by erl_interface, jinterface or otherwise, as the VM itself always encodes flatmaps with sorted keys.
* | | | | Merge branch 'maint'Sverker Eriksson2022-11-171-10/+12
|\ \ \ \ \ | |/ / / /
| * | | | Merge branch 'fix-binary_to_term-integer-overflow-2' into maintSverker Eriksson2022-11-171-10/+12
| |\ \ \ \ | | | | | | | | | | | | | | | | | | OTP-18328
| | * \ \ \ Merge branch 'sverker/23/fix-binary_to_term-integer-overflow-2'Sverker Eriksson2022-11-081-10/+12
| | |\ \ \ \ | | | | | | | | | | | | | | | | | | | | | into sverker/24/fix-binary_to_term-integer-overflow-2
| | | * | | | dec_term: avoid integer overflow for LIST_EXTMikael Pettersson2022-11-081-10/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - use unsigned type for the length n - perform mutiplication by 2 in wider type Fixes #6439
* | | | | | | Merge branch 'maint'Sverker Eriksson2022-11-071-32/+46
|\ \ \ \ \ \ \ | |/ / / / / /
| * | | | | | Merge branch 'fix-binary_to_term-integer-overflow' into maintSverker Eriksson2022-11-071-32/+46
| |\ \ \ \ \ \ | | |/ / / / / | | | | / / / | | |_|/ / / | |/| | | | OTP-18306
| | * | | | Merge branch 'sverker/23/fix-binary_to_term-integer-overflow' into ↵Sverker Eriksson2022-11-021-32/+46
| | |\ \ \ \ | | | |/ / / | | | | | / | | | |_|/ | | |/| | sverker/24/fix-binary_to_term-integer-overflow
| | | * | erts: Fix decode of BINARY_EXT and BIT_BINARY_EXT when size >= 2GbMikael Pettersson2022-11-021-34/+48
| | | |/ | | | | | | | | | | | | Co-authored-by: Sverker Eriksson <sverker@erlang.org>
| * | | erts: Fix windows compile warningSverker Eriksson2022-08-161-1/+1
| | | | | | | | | | | | | | | | warning C4333: '>>': right shift by too large amount, data loss
* | | | Merge pull request #6101 from garazdawi/lukas/fix-win32-autoconf-cache/OTP-18053Lukas Larsson2022-06-211-1/+1
|\ \ \ \ | | | | | | | | | | Update windows configure cache
| * | | | erts: Fix cl.exe compiler warningLukas Larsson2022-06-211-1/+1
| | | | |
* | | | | Merge branch 'maint' into masterSverker Eriksson2022-06-201-59/+7
|\ \ \ \ \ | |/ / / / |/| / / / | |/ / /
| * | | Merge branch 'sverker/erts/remove-dead-hopeful' into maintSverker Eriksson2022-06-201-59/+7
| |\ \ \
| | * | | erts: Remove some dead code for obsolete hopeful encodingSverker Eriksson2022-06-031-59/+7
| | | | | | | | | | | | | | | | | | | | left in encode_size_struct_int().
* | | | | Utilize v4 external references for aliasesRickard Green2022-06-131-2/+5
| | | | |
* | | | | Make new link protocol mandatoryRickard Green2022-06-131-112/+0
|/ / / /
* | | | Merge branch 'sverker/24/fix-hopeful-fun-size-encoding/OTP-18104'Sverker Eriksson2022-06-081-4/+38
|\ \ \ \ | |/ / / |/| | | | | | | | | | | | | | | | | | | into sverker/25/fix-hopeful-fun-size-encoding/OTP-18104 This merge commit removes code that has to do with hopeful encoding of export-funs and bit-strings, which is no longer supported in OTP-25.
| * | | Merge branch 'sverker/23/fix-hopeful-fun-size-encoding/OTP-18104'Sverker Eriksson2022-06-081-7/+107
| |\ \ \ | | |/ / | |/| | | | | | into sverker/24/fix-hopeful-fun-size-encoding/OTP-18104
| | * | erts: Fix bug in bit string fallback encodingSverker Eriksson2022-06-081-1/+2
| | | | | | | | | | | | | | | | Size estimation was one byte short.
| | * | erts: Fix size encoding of fun containing off-heap binariesSverker Eriksson2022-06-081-39/+52
| | | |
| | * | erts: Fix fallback combo bug on pending connectionSverker Eriksson2022-05-201-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Sending a message on a pending connection containing both bitstring and export fun {<<1:1>>,fun a:b/0} would either be encoded as-is or with BOTH as fallbacks {{<<128>>,1},{a,b}}. Even if receiver only supported one of either DFLAG_BIT_BINARIES or DFLAG_EXPORT_PTR_TAG. For OTP this does not seem to be/been a practical problem as erl_interface got support for both in OTP-22.0.
| | * | erts: Fix encoding of NEW_FUN_EXT Size field for pending connectionSverker Eriksson2022-05-191-3/+90
| | |/ | | | | | | | | | | | | | | | | | | The Size field of NEW_FUN_EXT could (most likely) be incorrect when the fun was encoded toward a not yet established connection and it contains export funs (fun M:F/0) or bitstrings (<<5:7>>) in its environment.
* | | Merge branch 'sverker/24/hopeful-in-fun-env/OTP-18093' into ↵Sverker Eriksson2022-05-191-3/+4
|\ \ \ | | | | | | | | | | | | sverker/25/hopeful-in-fun-env/OTP-18093
| * \ \ Merge branch 'sverker/23/hopeful-in-fun-env/OTP-18093' into ↵Sverker Eriksson2022-05-191-3/+4
| |\ \ \ | | |/ / | |/| | | | | | sverker/24/hopeful-in-fun-env/OTP-18093
| | * | erts: Accept faulty Size field in NEW_FUN_EXTSverker Eriksson2022-05-191-3/+4
| | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a pragmatic semi-solution to remove the symptom of a bug that could cause invalid Size field in NEW_FUN_EXT encoded toward a pending connection. The Size field is not used for anything else than this sanitity check so I see it safe to accept NEW_FUN_EXT from buggy senders. erl_interface still relies on Size so I guess we have to fix the encoding bug also, even though sending funs to erl_interface is not that common.
* | | Update copyright yearErlang/OTP2022-03-231-1/+1
| | |
* | | Merge pull request #5746 from ↵John Högberg2022-03-111-2/+1
|\ \ \ | | | | | | | | | | | | | | | | jhogberg/john/erts/fix-parallel-monitor-signal-order erts: Fix parallel signal optimization for monitors
| * | | erts: Fix parallel signal optimizationJohn Högberg2022-03-081-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When the parallel signal optimization was enabled and signals were sent without a known sender (e.g. a monitor-by-name firing), they always landed in signal slot 0, which was rarely the same slot as messages sent from the same process, breaking our signal order guarantees. This commit fixes that by always keeping track of the sender regardless of how and where signal are sent.
* | | | Clean up size calculation for binary_to_term/1Björn Gustavsson2022-03-011-21/+41
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit cleans up the size calculation phase of binary_to_term/1: * Count sub terms in an **unsigned** 32-bit integer instead of in an **signed** 32-bit integer to ensure that the counter wraps on overflow. While the existing code worked on all platform we have tested it on, signed overflow is is undefined behavior in the C standard. * Be paranoid and use the overflow-checking ADDTERM() macro for **all** additions to the `term` variable. * Reject lists and large tuples early if the rest of the binary being decoded is obviously too short. (The same early rejection was already done for maps.) * Explicitly reject decoding maps with 2^31 or more elements on 64-bit platforms (on 32-bit platforms there is already code to reject maps with 2^30 or more elements). Decoding maps with that many elements has never worked correctly, but would fail in random ways (because the `term` variable would overflow and miscount the sub terms). We considered counting sub terms in a 64-bit counter on 64-bit machines to allow truly ginormous terms to be decoded, but decided that such terms are probably a mistake and that it is better to reject them.
* | | Merge branch 'maint'Rickard Green2021-12-131-1/+1
|\ \ \ | |/ / | | | | | | | | | * maint: Update copyright year
| * | Update copyright yearRickard Green2021-12-131-1/+1
| | |
* | | erts: Remove creation 0 as wildcardSverker Eriksson2021-11-041-16/+2
| | |
* | | Merge pull request #5254 from jhogberg/john/erts/optimize-fun-callsJohn Högberg2021-10-201-122/+133
|\ \ \ | | | | | | | | erts: Optimize fun calls
| * | | erts: Optimize fun callsJohn Högberg2021-10-201-122/+133
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | By making local and external funs share the same structure, we can remove a substantial amount of code from the `call_fun` family of instructions. As a result fun calls are now about 15% faster with the interpreter on my machine, 10% faster with the x64 JIT on that same machine, and 15% faster with the AArch64 JIT on my M1 Mac. The improvement is a bit less pronounced for funs with free variables, and a bit more for those without (including external funs).
* | | | Remove empty tuples from heap and create global empty tuple constantKjell Winblad2021-10-201-4/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | One can do several optimizations (e.g., in the emit_i_is_tagged_tuple and emit_i_is_tagged_tuple_ff instructions in the ARM JIT), if one can assume that the word after the arity word in boxed terms is located in allocated memory. This commit makes this assumption valid by: * creating a global constant for the empty tuple that is padded by one word, * chaining all placed that could create an empty tuple on the process heap so they instead create pointers to the global empty tuple constant and,
* | | | Merge branch 'maint'Sverker Eriksson2021-10-151-1/+2
|\ \ \ \ | |/ / / |/| / / | |/ /
| * | erts: Fix codechecker warningsSverker Eriksson2021-10-071-1/+2
| | |