aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/beam_bif_load.c
AgeCommit message (Collapse)Author
2017-02-06Use magic refs for code loading stateRickard Green
2017-01-18Remove double check of NifExport when checking process codeRickard Green
2017-01-17Merge branch 'rickard/ds-features-20'Rickard Green
OTP-14152 * rickard/ds-features-20: Remove experimental disclaimer on dirty schedulers Scheduler wall time support for dirty schedulers Always return info from system_info(dirty_[cpu|io]_schedulers*) Improve etp-commands Switch between scheduler types when multi-scheduling is blocked Perform potentially long GC on dirty schedulers if available Return and exception trace for nif-export scheduled BIFs Optimize handling of BIF errors Support for dirty BIFs Reduction counting on non-tail return
2017-01-16Merge branch 'maint'Sverker Eriksson
2017-01-16Merge branch 'maint-19' into maintSverker Eriksson
2017-01-12Perform potentially long GC on dirty schedulers if availableRickard Green
2017-01-12Support for dirty BIFsRickard Green
2017-01-12Merge branch 'sverker/make-export-fun-race/OTP-14144' into maint-19Erlang/OTP
* sverker/make-export-fun-race/OTP-14144: erts: Fix race bug between export fun creation and code loading
2017-01-12erts: Fix race bug between export fun creation and code loadingSverker Eriksson
Symptom: SEGV crash on ARM in delete_code() -> export_list(). Could probably happen on other machines as well. Problem: Staging export table was iterated in an unsafe way while an entry was added for a new export fun. Solution: Correct write order and some memory barriers.
2017-01-11Merge branch 'maint'Rickard Green
* maint: Fix issues with abandoned heap Conflicts: erts/emulator/beam/beam_bif_load.c
2017-01-11Merge branch 'rickard/abandoned-heap-bugs' into maintRickard Green
OTP-14134 OTP-14135 * rickard/abandoned-heap-bugs: Fix issues with abandoned heap
2017-01-10Fix issues with abandoned heapRickard Green
2017-01-09Merge branch 'maint'Sverker Eriksson
2017-01-09erts: Fix error report message for erlang:delete/1Sverker Eriksson
2016-11-23Merge branch 'maint'Rickard Green
* maint: Update etp-commands for dirty schedulers Fix scheduling of system tasks on processes executing dirty Fix call time tracing with dirty schedulers Fix send of exit signal to process executing dirty Fix dirty scheduler process priority Fix alloc-util hard-debug Silence debug warning when no beam jump table is used with dirty schedulers Fix check_process_code() when NifExport is in use Fix GC when NifExport is in use Fix saving of original arguments when rescheduling via NifExport Conflicts: erts/emulator/beam/beam_bif_load.c erts/emulator/beam/erl_nif.c
2016-11-23Merge branch 'rickard/nif-scheduling-fixes' into maintRickard Green
* rickard/nif-scheduling-fixes: Fix check_process_code() when NifExport is in use - OTP-14048 Fix GC when NifExport is in use - OTP-14049 Fix saving of original arguments when rescheduling via NifExport - OTP-14050
2016-11-22Fix check_process_code() when NifExport is in useRickard Green
2016-10-27Merge branch 'maint'Sverker Eriksson
2016-10-26erts: Avoid delayed fun undef raceSverker Eriksson
Avoid suspending fun caller not just if purge is already done but also if purge of another module has started. Another purge of the same module again cannot happen as making current to old transition includes thread progress.
2016-10-14Merge branch 'master' into sverker/hipe-code-loadnpurgeSverker Eriksson
Conflicts: erts/emulator/beam/beam_bif_load.c erts/emulator/beam/beam_load.c and added macro DBG_TRACE_MFA_P in beam_load.h
2016-10-14erts: Replace unsafe Module.first_hipe_refSverker Eriksson
with hash table mod2mfa_tab
2016-10-14erts: Let code:make_stub_module raise 'notsup'Sverker Eriksson
if hipe is disabled. Makes the code simpler to just ifdef away a lot of hipe stuff.
2016-10-14erts: Move new hipe ref and sdesc lists to loader stateSverker Eriksson
2016-10-14erts: Check hipe stack in check_process_codeMagnus Lång
This is part of commit 1bd508921dd93086b05e7d0038b816b36c421d86. I did not include the fun-checking as we have a new purge strategy for funs in OTP 20. That remains to be solved some other way for hipe.
2016-10-14Add a loader state for HiPE code loadingMagnus Lång
Just like the BEAM loader state (as returned by erlang:prepare_loading/2), the HiPE loader state is contained in a magic binary. Eventually, we will separate HiPE loading into a prepare and a finalise phase, like the BEAM loader, where the prepare phase will be implemented by hipe_unified_loader and the finalise phase be implemented in C by hipe_load.c and beam_load.c, making prepare side-effect free and finalise atomic. The finalise phase will be exposed through the erlang:finish_loading/1 API, just like the BEAM loader, as this will allow HiPE and BEAM modules to be mixed in the same atomic "commit". The usage of a loader state makes it easier to keep track of all resources allocated during loading, and will not only make it easy to prevent leaks when hipe_unified_loader crashes, but also paves the way for proper, leak-free, unloading of HiPE modules.
2016-10-12erts: Refactor rename Export.code[] to Export.beam[]Sverker Eriksson
to avoid scary merge errors.
2016-10-12erts: Refactor out func_info into structLukas Larsson
This commit adds two new structs to be used to represent erlang code in erts. ErtsCodeInfo is used to describe the i_func_info header that is part of all Export entries and the prelude of each function. This replaces all the BeamInstr * that were previously used to point to these locations. After this change the code should never use BeamInstr * with offsets to figure out different parts of the func_info header. ErtsCodeMFA is a struct that is used to descripe a MFA in code. It is used within ErtsCodeInfo and also in Process->current. All function that previously took Eterm * or BeamInstr * to identify a MFA now use the ErtsCodeMFA or ErtsCodeInfo where appropriate. The code has been tested to work when adding a new field to the ErtsCodeInfo struct, but some updates are needed in ops.tab to make it work.
2016-10-10erts: Improve hipe load/upgrade/purge machinerySverker Eriksson
A step toward better integration of hipe load and purge Highlights: * code_server no longer needs to call hipe_unified_loader:post_beam_load/1 Instead new internal function hipe_redirect_to_module() is called by loading BIFs to patch native call sites if needed. * hipe_purge_module() is called by erts_internal:purge_module/2 to purge any native code. * struct hipe_mfa_info redesigned and only used for exported functions that are called from or implemented by native code. A list of native call sites (struct hipe_ref) are kept for each hipe_mfa_info. * struct hipe_sdesc used by hipe_find_mfa_from_ra() to build native stack traces.
2016-09-15Merge branch 'maint'Björn Gustavsson
* maint: erts: Add nif_SUITE:t_on_load erts: Improve nif_SUITE:upgrade test Don't leak old code when loading a modules with an on_load function Conflicts: erts/preloaded/ebin/erts_code_purger.beam erts/preloaded/ebin/erts_internal.beam erts/preloaded/src/erts_code_purger.erl
2016-09-14Don't leak old code when loading a modules with an on_load functionBjörn Gustavsson
Normally, calling code:delete/1 before re-loading the code for a module is unnecessary but causes no problem. But there will be be problems if the new code has an on_load function. Code with an on_load function will always be loaded as old code to allowed it to be easily purged if the on_load function would fail. If the on_load function succeeds, the old and current code will be swapped. So in the scenario where code:delete/1 has been called explicitly, there is old code but no current code. Loading code with an on_load function will cause the reference to the old code to be overwritten. That will at best cause a memory leak, and at worst an emulator crash (especially if NIFs are involved). To avoid that situation, we will put the code with the on_load function in a special, third slot in Module. ERL-240
2016-09-02Merge branch 'maint'Rickard Green
* maint: Introduce literal sweep of native stack in new purge strategy
2016-09-02Introduce literal sweep of native stack in new purge strategyRickard Green
2016-09-01Merge branch 'rickard/remove-old-purge-strategy/OTP-13844'Rickard Green
* rickard/remove-old-purge-strategy/OTP-13844: Avoid selective receive in code-purger process Remove old purge strategy Conflicts: erts/emulator/beam/beam_bif_load.c erts/emulator/beam/global.h
2016-09-01Merge branch 'maint'Rickard Green
* maint: Fix reclaim of literal areas Conflicts: erts/emulator/beam/global.h
2016-09-01Merge branch 'rickard/new-purge-strategy/OTP-13833' into maintRickard Green
* rickard/new-purge-strategy/OTP-13833: Fix reclaim of literal areas Conflicts: erts/emulator/beam/beam_bif_load.c
2016-09-01Fix reclaim of literal areasRickard Green
2016-08-31Remove old purge strategyRickard Green
2016-08-29Merge branch 'maint'Rickard Green
* maint: Fix tracing of processes executing dirty Perform check_process_code while process is executing dirty Fix purge of code Reclaim literal area after purge has completed Separate literal area from code Conflicts: erts/emulator/beam/global.h
2016-08-29Merge branch 'rickard/ds-purge-module/OTP-13808' into maintRickard Green
* rickard/ds-purge-module/OTP-13808: Perform check_process_code while process is executing dirty Conflicts: erts/doc/src/erl_nif.xml
2016-08-29Merge branch 'rickard/fun-purge-bug/OTP-13809' and ↵Rickard Green
'rickard/new-purge-strategy/OTP-13833' into maint * rickard/fun-purge-bug/OTP-13809: Fix purge of code Reclaim literal area after purge has completed Separate literal area from code Conflicts: erts/doc/src/erlang.xml erts/emulator/beam/beam_bif_load.c erts/emulator/beam/erl_init.c erts/preloaded/ebin/init.beam
2016-08-29Perform check_process_code while process is executing dirtyRickard Green
2016-08-29Fix purge of codeRickard Green
Ensure that we cannot get any dangling pointers into code that has been purged. This is done by a two phase purge. At first phase all fun entries pointing into the code to purge are marked for purge. All processes trying to call these funs will be suspended and by this we avoid getting new direct references into the code. When all processes has been checked, these processes are resumed. The new purge strategy now also completely ignore the existence of indirect references to the code (funs). If such exist, they will cause bad fun exceptions to the caller, but will not prevent a soft purge or cause a kill of a process having such live references during a hard purge. This since it is impossible to give any guarantees that no processes in the system have such indirect references. Even when the system is completely clean from such references, new ones can appear via distribution and/or disk.
2016-08-26Reclaim literal area after purge has completedRickard Green
2016-08-08Separate literal area from codeRickard Green
2016-08-01Merge branch 'egil/erts/dont-copy-literals/OTP-13529'Björn-Egil Dahlberg
* egil/erts/dont-copy-literals/OTP-13529: erts: Refactor literal purge area arguments erts: No need to literal opt message token erts: Don't copy literals in enif_send erts: Fix literal size calculation in check_process_code erts: Remove the need for copying of literals
2016-08-01erts: Fix literal size calculation in check_process_codeBjörn-Egil Dahlberg
We want to know the total size of literals of all heap fragmens.
2016-07-06check_process_code: Sweep HiPE stack for literalsMagnus Lång
Because check_process_code neglected checking the HiPE stack for references to the literal area, such references would survive the purge and subsequent deletion of a module and its literal area. These dangling references would then cause incorrect behaviour or even hard crashes of the VM. By simply adding a scan of the HiPE stack to check_process_code and erts_garbage_collect_literals, this problem is fixed. In order to support full stack walks without deleting the graylimit trap, a new stack walking interface function, nstack_walk_init_sdesc_ignore_trap() was introduced.
2016-05-20erts: Refactor ERTS_MSG_COMBINED_HFRAG to heap fragmentBjörn-Egil Dahlberg
2016-05-20erts: Copy literals in messages on module purgeBjörn-Egil Dahlberg
During check process code, explicitly copy all referenced literals in a message (in the private queue) to a heap fragment and attach it to the message reference. Not all types of message communication does an explicit copy of a literal and this needs to be taken care of before a module is purged.
2016-05-04Merge branch 'bjorn/fix-on_load/OTP-12593'Björn Gustavsson
* bjorn/fix-on_load/OTP-12593: Update documentation regarding improvements Correctly handle multiple load attempts when on_load is pending Avoid deadlock when an on_load function makes an external call to the module itself code_server: Eliminate unnecessary Tag in handle_call/3 Reimplement -on_load() Refactor erts_finish_loading() and insert_new_code() code_SUITE: Make on_load_binary/1 clearer by using merl