aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam
AgeCommit message (Collapse)Author
2018-12-20Merge branch 'maint'Lukas Larsson
Conflicts: erts/preloaded/ebin/atomics.beam erts/preloaded/ebin/counters.beam erts/preloaded/ebin/erl_prim_loader.beam erts/preloaded/ebin/erl_tracer.beam erts/preloaded/ebin/erlang.beam erts/preloaded/ebin/erts_code_purger.beam erts/preloaded/ebin/erts_dirty_process_signal_handler.beam erts/preloaded/ebin/erts_internal.beam erts/preloaded/ebin/erts_literal_area_collector.beam erts/preloaded/ebin/init.beam erts/preloaded/ebin/otp_ring0.beam erts/preloaded/ebin/persistent_term.beam erts/preloaded/ebin/prim_buffer.beam erts/preloaded/ebin/prim_eval.beam erts/preloaded/ebin/prim_file.beam erts/preloaded/ebin/prim_inet.beam erts/preloaded/ebin/prim_zip.beam erts/preloaded/ebin/zlib.beam
2018-12-20Merge branch 'lukas/erts/fix-seq_trace-reset_trace/OTP-15490' into maintLukas Larsson
* lukas/erts/fix-seq_trace-reset_trace/OTP-15490: erts: Fix seq_trace:reset_trace dirty gc bug erts: Use sys_memcpy in copy_one_frag
2018-12-18Merge branch 'maint'Sverker Eriksson
2018-12-18Merge branch 'sverker/big-band-bug/ERL-804/OTP-15487' into maintSverker Eriksson
* sverker/big-band-bug/ERL-804/OTP-15487: erts: Fix bug in 'band' of two negative numbers, one big
2018-12-18Merge branch 'sverker/fix-atomics-get-large-unsigned/PR-2061/OTP-15486' into ↵Sverker Eriksson
maint * sverker/fix-atomics-get-large-unsigned/PR-2061/OTP-15486: erts: Fix possible heap corruption getting atomics
2018-12-18Merge pull request #2053 from bjorng/bjorn/erts/trapping-length/OTP-15439Björn Gustavsson
Make length/1 yielding
2018-12-18Make length/1 yieldingBjörn Gustavsson
The guard BIF `length/1` would calculate the length of the list in one go without yielding, even if the list was were long. To make it even worse, the call to `length/1` would only cost a single reduction. This commit reimplements `length/1` so that it eats a number of reductions proportional to the length of the list, and yields if the available reductions run out.
2018-12-17erts: Fix bug in 'band' of two negative numbers, one bigSverker Eriksson
Similar bug as for bxor fixed by abc4fd372d476821448dfb9 Ex: 1> io:format("~.16B\n", [-16#1110000000000000000 band (-1)]). -1120000000000000000 Wrong result for (-X bsl WS) band -Y. where X is any positive integer WS is erlang:system_info(wordsize)*8*N where N is 1 or larger Y is any positive integer smaller than (1 bsl WS) Fix: The subtraction of 1 (for 2-complement conversion) must be carried along all the way to the last words.
2018-12-17Merge pull request #2057 from michalmuskala/mm/missing-annoBjörn Gustavsson
Add missing annotations in instrs.tab
2018-12-14Merge branch 'maint'Lukas Larsson
2018-12-14Merge branch 'lukas/erts/fix_lit_msg_copy_in_gc' into maintLukas Larsson
* lukas/erts/fix_lit_msg_copy_in_gc: erts: Use ptr_val for pointer in gc msg copy
2018-12-13erts: Fix possible heap corruption getting atomicsTomas Abrahamsson
Due to comparison as a signed integer, when getting an unsigned atomic in the range 2^63-1..2^64-1 (when the most significant bit was set), the heap could get corrupted when the integer was retrieved: hsz would get set to zero, but the code proceeded to build a bignum. Steps to reproduce (at least on x86_64): $ erl 1> A = atomics:new(1,[{signed,false}]). 2> atomics:put(A,1,18446744073709551615). 3> atomics:get(A,1). At the last step, the shell would print some garbage and hang.
2018-12-13erts: Fix seq_trace:reset_trace dirty gc bugLukas Larsson
When seq_trace:reset_trace could be called while a process was doing a dirty GC. This triggered a race where all signals was moved to the internal signal queue during the GC which in turn caused the a heap overrun problem. This fix makes it so that the main and msgq lock are taken before the clear. This will make sure that we are allowed to do the clear.
2018-12-13erts: Use sys_memcpy in copy_one_fragLukas Larsson
2018-12-13Add missing annotations in instrs.tabMichał Muskała
Dispatching a function and return never use the next instruction. It's unlikely for raw_raise to use the next instruction.
2018-12-13Merge pull request #2047 from bjorng/bjorn/erts/eliminate-gc-bifs/OTP-15440Björn Gustavsson
Simplify implementation of GC BIFs
2018-12-13Simplify GC BIFsBjörn Gustavsson
Summary: This commit simplifies the implementation of the "GC BIFs" so that they no longer need to do a garbage collection, removing duplicate code for all GC BIFs in the runtime system, as well as potentially reducing the size of the loaded BEAM code by using shorter instructions calling those BIFs. A GC BIF is a guard BIF that will do a garbage collection if it needs to build anything on the heap. For example, `abs/1` is a GC BIF because it might need to allocate space on the heap (if the result is a floating point number or the resulting integer is a bignum). Before R12, a guard BIF (such as `abs/1`) that need to allocate heap space would allocate outside of process's main heap, in a heap fragment. GC BIFs were introduced in R12B to support literals. During garbage collection it become necessary to quickly test whether a term was a literal. To make the check simple, guards BIFs were no longer allowed to create heap fragments. Instead GC BIFs were introduced. In OTP 19, the implementation of literals was changed to support storing messages in heap fragments outside of the main heap for a process. That change again made it allowed for guard BIFs to create heap fragments when they need to build terms on the heap. It would even be possible for the guard BIFs to build directly on the main heap if there is room there, because the compiler assumes that a new `test_heap/2` instruction must be emitted when building anything after calling a GC BIF. (We don't do that in this commit; see below.) This commit simplifies the implementation of the GC BIFs in the runtime system. Each GC BIF had a dual implementation: one that was used when the GC BIF was called directly and one used when it was called via `apply/3`. For example, `abs/1` was implemented in `abs_1()` and `erts_gc_abs_1()`. This commit removes the GC version of each BIF. The other version that allocates heap space using `HAlloc()` is updated to use the new `HeapFragOnlyAlloc()` macro that will allocate heap space in a heap fragment outside of the main heap. Because the BIFs will allocate outside of the main heap, the same `bif` instructions used by nonbuilding BIFs can be used for the (former) GC BIFs. Those instructions don't use the macros that save and restore the heap and stack pointers (SWAPOUT/SWAPIN). If the former GC BIFs would build on the main heap, either new instructions would be needed, or SWAPOUT/SWAPIN instructions would need to be added to the `bif` instructions. Instructions that call the former GC BIFs don't need the operand that specifies the number of live X registers. Therefore, the instructions that call the BIFs are usually one word shorter.
2018-12-13Merge branch 'bjorn/erts/remove-faulty-assertion'Björn Gustavsson
* bjorn/erts/remove-faulty-assertion: erl_bif_list: Remove faulty assertion
2018-12-13Merge branch 'maint'Björn Gustavsson
* maint: Fix reading beyond end of bignum in integer squaring
2018-12-13Fix reading beyond end of bignum in integer squaringBjörn Gustavsson
The multiplication of two bignums is specially optimized when the two operands have the same address, because squaring can be done more efficiently than multiplication of two arbitrary integers. That is, expressions such as `I * I` will be calculated by squaring the value of `I`. The optimized function for squaring would read one word beyond the end of the bignum in the last iteration of a loop. The garbage value would never be used. In almost all circumstances that would be harmless. Only if the read word happened to fall on the start of an unmapped page would the runtime crash. That is unlikely to happen because most bignums are stored on a process heap, and since the stack is located at the other end of the block that the heap is located in, the word beyond the end of bignum is guaranteed to be readable.
2018-12-11Merge branch 'sverker/erts/ets-debug-test-cuddle'Sverker Eriksson
* sverker/erts/ets-debug-test-cuddle: erts: Fix volatile ets test case failures on debug VM
2018-12-10erl_bif_list: Remove faulty assertionBjörn Gustavsson
The variable can be an empty list.
2018-12-10erts: Use ptr_val for pointer in gc msg copyLukas Larsson
Without this fix asserts would trigger in debug build but nothing else would break.
2018-12-07Merge pull request #2046 from ↵John Högberg
jhogberg/john/erts/mark-pooled-free-blocks-unused/OTP-15075 Mark free blocks in pooled carriers as unused
2018-12-07Mark free blocks in pooled carriers as unused (MADV_FREE)John Högberg
This lets the OS reclaim the physical memory associated with these blocks which reduces the impact of long-lived awkward allocations. A small allocated block will still keep a huge carrier alive, but the unused part of the carrier will now be available to the OS. Co-authored-by: Dmytro Lytovchenko <[email protected]>
2018-12-06Merge branch 'maint'Lukas Larsson
Conflicts: erts/emulator/beam/erl_process.c
2018-12-06Merge branch 'lukas/OTP-21.1.1/scheduler_pollset/OTP-15475' into maintLukas Larsson
* lukas/OTP-21.1.1/scheduler_pollset/OTP-15475: erts: Move fds with active true behaviour to own pollset erts: Fix lists_member_2 reduction count erts: Allow code_model_small to be set in xcomp setting erts: Implement delay_send using timer instead of poll erts: Optimize driver_set_timer(0) to fire at once erts: Optimize the inet driver multi timers for one timer erts: Move all inet tcp CONNECTED timers to multi timer erts: Add erts_io_notify_port_task_executed to check_io msacc state erts: Add pre-alloc to ALLOC msacc state erts: Make thr prgr wakeup current or sched 1 erts: Pass thread progress data where possible
2018-12-06erts: Move fds with active true behaviour to own pollsetLukas Larsson
At start of the VM a poll-set that the schedulers will check is created where fds that have triggered many (at the moment, many means 10) times without being deselected inbetween. In this scheduler specific poll-set fds do not use ONESHOT, which means that the number of syscalls goes down dramatically for such fds. This pollset is introduced in order to handle fds that are used by the erlang distribution and that never change their state from {active, true}. This pollset only handles ready_input events, ready_output is still handled by the poll threads. During overload, polling the scheduler poll-set is done on a 10ms timer.
2018-12-05erts: Fix volatile ets test case failures on debug VMSverker Eriksson
Symptom: Test cases with small key ranges sometimes failed on debug VM with: "No routing nodes in table? Debug feature 'ets_force_split' does not seem to work." Solution: Don't provoke randomly joins when force_split is set.
2018-12-05Merge branch 'maint'Lukas Larsson
2018-12-04erts: Fix copy of literal msg during gcLukas Larsson
A copy has to be made of the message as there is a trace token. There was a bug where the actual message was incorrectly modified even if it was a literal.
2018-12-03Merge branch 'maint'Lukas Larsson
2018-12-03erts: Fix some 32-bit gcc warningsLukas Larsson
2018-12-03erts: Fix lists_member_2 reduction countLukas Larsson
OTP-15474
2018-12-03erts: Optimize driver_set_timer(0) to fire at onceLukas Larsson
By optimizing driver_set_timer for 0 we can use it instead of select to do a yield in the driver. Use full for delay_send in the inet driver. OTP-15472
2018-12-03erts: Add pre-alloc to ALLOC msacc stateLukas Larsson
OTP-15450
2018-11-30Merge branch 'john/erts/assert-dirty-aux-work'John Högberg
* john/erts/assert-dirty-aux-work: Abort when aux work runs on a dirty scheduler
2018-11-27Merge branch 'maint'Lukas Larsson
2018-11-27Merge branch 'lukas/erts/fix-msacc-gc-states/OTP-15450' into maintLukas Larsson
* lukas/erts/fix-msacc-gc-states/OTP-15450: erts: Fix msacc GC states on dirty scheds
2018-11-27Abort when aux work runs on a dirty schedulerJohn Högberg
While the system will keep working, the aux work will never run and the affected scheduler never goes to sleep. OTP-15446 is a good example of this. As this error easily flies under the radar it's best to make it immediately visible. The assertions we had in debug builds were clearly not enough to catch all sources of this problem.
2018-11-27Merge branch 'maint'John Högberg
* maint: erts: fix attempt to start timer when executing on dirty scheduler
2018-11-27Merge pull request #2024 from max-au/fix_aux_work_on_dcpu_schedJohn Högberg
erts: fix attempt to start timer when executing on dirty scheduler OTP-15446
2018-11-26erts: fix attempt to start timer when executing on dirty schedulerMaxim Fedorov
Since OTP R20, there is a possibility for MAJOR garbage collection to run on dirty scheduler. So DistEntry destructor is being called on dirty scheduler as well. This, in turn, leads to an attempt to schedule timer on a dirty scheduler too, which is impossible (and will assert on debug build, but does succeed for release build, creating an infinite busy loop, since aux work wakes scheduler up, but dirty scheduler cannot execute aus work). There is a similar method in erl_hl_timer, see erts_start_timer_callback.
2018-11-26Merge branch 'maint'Sverker Eriksson
2018-11-26Merge branch 'sverker/erts/atomics-counters/OTP-13468' into maintSverker Eriksson
* sverker/erts/atomics-counters/OTP-13468: erts: Fix bug in counters erts: Refactor erl_bif_counters.c
2018-11-23erts: Fix bug in countersSverker Eriksson
Wow, that could have been embarrassing.
2018-11-23erts: Refactor erl_bif_counters.cSverker Eriksson
with more consistent naming.
2018-11-23Merge branch 'maint'John Högberg
* maint: Allow disabling retpoline in interpreter loop Add a ./configure flag for spectre mitigation
2018-11-23Merge branch 'john/erts/spectre-configure-flag-otp_20/OTP-15430/ERIERL-237' ↵John Högberg
into maint * john/erts/spectre-configure-flag-otp_20/OTP-15430/ERIERL-237: Allow disabling retpoline in interpreter loop Add a ./configure flag for spectre mitigation
2018-11-22Merge branch 'maint'Sverker Eriksson