aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/beam_load.c
AgeCommit message (Collapse)Author
2017-05-08Merge branch 'sverker/is_module_native-trace-bug/OTP-14390'Sverker Eriksson
* sverker/is_module_native-trace-bug/OTP-14390: erts: Fix code:is_module_native for local trace erts: Move and rename erts_is_native_break()
2017-05-04erts: Fix code:is_module_native for local traceSverker Eriksson
Local trace on first function in module made code:is_module_native/1 return true. Use new erts_is_function_native() to make a proper check.
2017-05-04erts: Move and rename erts_is_native_break()Sverker Eriksson
2017-05-04Update copyright yearRaimo Niskanen
2017-04-12erts: Introduce struct binary_internalsSverker Eriksson
to replace macro ERTS_INTERNAL_BINARY_FIELDS as header in Binary and friends.
2017-04-11erts: Introduce erts_bin_releaseSverker Eriksson
2017-04-05erts: Remove deliberate leak of hipe fun entriesSverker Eriksson
should be fixed since 32729cab75325de58bf127e6e8836348071b8682
2017-04-04erts: Refactor ErtsCodeInfo.nativeSverker Eriksson
into union with actual usage types.
2017-03-17erts: Change HIPE allocations from sys_allocSverker Eriksson
to long lived, short lived and native stack.
2017-02-14erts: Add deallocation veto for magic destructorsSverker Eriksson
A magic destructor can return 0 and thereby take control and prolong the lifetime of a magic binary.
2017-02-06Use magic refs for code loading stateRickard Green
2017-02-06Merge branch 'maint'Rickard Green
* maint: Atomic reference count of binaries also in non-SMP Conflicts: erts/emulator/beam/erl_fun.c
2017-02-06Atomic reference count of binaries also in non-SMPRickard Green
NIF resources was not handled in a thread-safe manner in the runtime system without SMP support. As a consequence of this fix, the following driver functions are now thread-safe also in the runtime system without SMP support: - driver_free_binary() - driver_realloc_binary() - driver_binary_get_refc() - driver_binary_inc_refc() - driver_binary_dec_refc()
2017-02-01Merge branch 'josevalim/atu8-chunk/PR-1078/OTP-14178'Björn Gustavsson
* josevalim/atu8-chunk/PR-1078/OTP-14178: Add new AtU8 beam chunk
2017-01-30Add new AtU8 beam chunkJosé Valim
The new chunk stores atoms encoded in UTF-8. beam_lib has also been modified to handle the new 'utf8_atoms' attribute while the 'atoms' attribute may be a missing chunk from now on. The binary_to_atom/2 BIF can now encode any utf8 binary with up to 255 characters. The list_to_atom/1 BIF can now accept codepoints higher than 255 with up to 255 characters (thanks to Björn Gustavsson).
2017-01-16Merge branch 'maint'Sverker Eriksson
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.
2016-11-29erts: Refactor BEAM_NIF_MIN_FUNC_SZSverker Eriksson
to be declared once in beam_load.h and get rid of #ifdef kludge.
2016-10-26erts: Remove unused argument to hipe_set_closure_stubSverker Eriksson
2016-10-17Merge branch 'sverker/hipe-code-loadnpurge/OTP-13968'Sverker Eriksson
* sverker/hipe-code-loadnpurge: (35 commits) erts: Cleanup dead code kernel,hipe: Fix dialyzer warnings erts: Replace unsafe Module.first_hipe_ref erts: Disable DBG_TRACE_MFA for debug build kernel: Fix code_SUITE:upgrade for non-hipe erts: Cleanup hipe trampoline code erts: Remove dead alloc stats in hipe_amd64.c erts: Remove code_SUITE:make_stub and make_stub_many_funs erts: Let code:make_stub_module raise 'notsup' erts: Fix bug in stack walk on risc erts: Fix old leak for ppc hipe code erts: Fix old leak for arm hipe code erts: Fix old leak of sparc hipe code erts: Fix old leak of hipe code on x86 32-bit erts: Enable exec_alloc for all hipe architectures erts: Remove debug printout for hipe loader state erts: Free hipe_refs and hipe_sdesc of a failed load erts: Refactor out hipe_purge_refs/sdesc erts: Refactor hipe_loader_state_dtor into a true destructor hipe: TRY fix llvm external calls to own module ...
2016-10-14Merge branch 'sverker/proc-dict-atom-hash/PR-1194'Sverker Eriksson
* sverker/proc-dict-atom-hash: kernel: Add test pdict_SUITE:literals erts: Refactor process dict hash pre-calculation Use atom value as hash value in process dictionary
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: 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: Refactor hipe_loader_state_dtor into a true destructorSverker Eriksson
that is only called once. Basically switch hipe_free_loader_state and hipe_loader_state_dtor.
2016-10-14erts: Fix early hipe patch loadingSverker Eriksson
by introducing hipe_bifs:commit_patch_load/1 that creates the HipeModule.
2016-10-14erts: Move new hipe ref and sdesc lists to loader stateSverker Eriksson
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 find_function_from_pc to return MFALukas Larsson
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: Refactor process dict hash pre-calculationSverker Eriksson
with new function erts_pd_make_hx()
2016-10-10Use atom value as hash value in process dictionaryVictor Ren
In the origin implementation, the hash value of atom term is retrieved from the atom table. Reading the atom table is expensive since it is in memory and leads to more cache missing. The size of a process dictionary is usually small. The atom value (the index) is unique and can be hash value for it. Using the atom value directly should be more efficient.
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-06Merge branch 'maint'Ingela Anderton Andin
2016-09-05erts: Reject beam file with too few functionsSverker Eriksson
2016-08-30Merge branch 'maint'Sverker Eriksson
2016-08-30Merge branch 'sverker/load-corrupt-beam/ERL-216/OTP-13848' into maintSverker Eriksson
* sverker/load-corrupt-beam/ERL-216: erts:: Unsignify a bunch of loader variables erts: Reject an invalid beam code header size erts: Fix load of beam with invalid imports and atom numbers
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-23erts:: Unsignify a bunch of loader variablesSverker Eriksson
2016-08-23erts: Reject an invalid beam code header sizeSverker Eriksson
2016-08-23erts: Fix load of beam with invalid imports and atom numbersSverker Eriksson
2016-08-08Separate literal area from codeRickard Green
2016-06-29Merge branch 'bjorn/gc-bifs'Björn Gustavsson
* bjorn/gc-bifs: compiler: Eliminate num_bif_SUITE erl_internal: Eliminate duplication of guard tests beam_debug: Improve the disassembly of gc_bif instructions Simplify creation of new GC BIFs make_tables: Remove broken automatic BIF aliasing
2016-06-22Simplify creation of new GC BIFsBjörn Gustavsson
Add the BIF type "gcbif" in bif.tab for defining GC BIFs. That will eliminate some of the hand-written administrative code for handling GC BIFs, saving the developer's time.
2016-06-22beam_makeops: Save some memory by making loader tables 'const'Björn Gustavsson
Before: $ size bin/x86_64-unknown-linux-gnu/beam.smp text data bss dec hex filename 3080982 188369 158472 3427823 344def bin/x86_64-unknown-linux-gnu/beam.smp After: $ size bin/x86_64-unknown-linux-gnu/beam.smp text data bss dec hex filename 3164694 104657 158472 3427823 344def bin/x86_64-unknown-linux-gnu/beam.smp
2016-05-17Merge branch 'sverker/hipe-amd64-code-alloc/OTP-13359'Sverker Eriksson
This merge is actually only some left overs. The bulk work for hipe-amd64-code-alloc has already been merge (without ticket number) at 42a1166b47721cd444.
2016-05-12erts: Remove compiler warningSverker Eriksson
'hx' may be used uninitialized
2016-05-04Reimplement -on_load()Björn Gustavsson
Load the module as old code; swap old and new code if the -on_load function succeeds. That way, a failed update attempt for a module that has an -on_load function will preserve the previous version of the code.