aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/beam_bif_load.c
AgeCommit message (Collapse)Author
2012-03-06erts: Fix memory leak in code loadingSverker Eriksson
All magic binaries returned by prepare_loading/2 was leaking. prepare_loading/2 left the reference count as 2 of the magic binary when it should be 1 (only owned by the returned term).
2012-02-24erts: Set correct default tracing when loading codeSverker Eriksson
Default trace (on_load) was lost in commit 64bcf5db63d73fe when load_module/2 was split.
2012-02-23erts: Use correct macro for "yield-return"Sverker Eriksson
2012-02-23erts: Refactor code loading with renamingSverker Eriksson
Rename lock_code_ix as seize_code_write_permission. Don't want to call it a "lock" as it can be held between schedulings and different threads and is not managed by lock checker. Rename "activate" staging as "commit" staging. Why not be consistent and use git terminology all the way.
2012-02-23erts: Switch order between code_ix lock and thread blockingSverker Eriksson
Make for simpler code when we just can block threads and continue without having to release code_ix lock and repeat code lookups to avoid race.
2012-02-21erts: Fix race bug in finish_after_on_loadSverker Eriksson
Must block system before looking up module to not race with other "code upgrader".
2012-02-21erts: Activate staged code in a thread safe waySverker Eriksson
Activation of staged code is scheduled for a later moment when all schedulers have done a full memory barrier. This allow them to read active code index while executing without any memory barriers at all.
2012-02-21erts: Suspend processes waiting for code_ix lockSverker Eriksson
This will prevent blocking entrire schedulers in the rare case when several processes are racing to load/upgrade/delete/purge code.
2012-02-21erts: Fix single threaded fallback in new BIF finish_loading_1Sverker Eriksson
Must "start staging" even when we go single threaded.
2012-02-21Break apart erlang:load_module/2 into two separate BIFsBjörn Gustavsson
Introduce two new BIFs, erlang:prepare_loading/2 and erlang:finish_loading/1, and re-implement erlang:load_module/2 in Erlang code. We have two reasons for doing this: * To facilitate suspending a process if another process is already doing code loading. * In the future, we can implement parallel and atomic loading of several modules. Atomic loading works except for modules with on_load handlers. Because of that issue, erlang:finish_loading/2 will currently only accept a list with a single magic binary.
2012-02-21Use magic binaries in erts_prepare_loading() and erts_finish_loading()Björn Gustavsson
2012-02-21erts: Cleanup non-blocking loadSverker Eriksson
2012-02-21erts: Fix tracing bug for new non-blocking loadSverker Eriksson
Made on_load-tracing always set after commit on active code_ix when system is still blocked. Bug caused cprof_SUITE:on_load to fail.
2012-02-21erts: Fallback to blocking upgrade when tracing is enabledSverker Eriksson
2012-02-21erts: Keep count of number of global traced functions per moduleSverker Eriksson
2012-02-21erts: Move number-of-breakpoint counter from code to Module structSverker Eriksson
The is a refactoring in preparation to add a counter in Module struct for export entry tracing. It is nicer if the two are kept together.
2012-02-21erts: Rename "loader" code_ix as "staging" code_ixSverker Eriksson
Staging is a better and more general name as does not necessary need to involve code loading (can be deletion, tracing, etc).
2012-02-21erts: Fix purge of module with loaded nif librarySverker Eriksson
Easy fallback solution that goes single threaded if the module to be purged has a loaded nif lib.
2012-02-21erts: Fix case of breakpoint when deleting moduleSverker Eriksson
2012-02-21erts: Call erts_export_consolidate automaticallySverker Eriksson
Renamed merge_secondary_table and called by export_start_load
2012-02-21First try at non-blocking code loading!Sverker Eriksson
Implemented some code_ix locks and commented calls to erts_smp_thr_progress_block()
2012-02-21BEAM loader: Break out handling of ranges into beam_ranges.cBjörn Gustavsson
Having the entire implementation of range handling (address table) in one source file will help when we'll need to update the ranges without stopping all schedulers in the next commit.
2012-02-21erts: Fix code_ix handling and locking for some more bifsSverker Eriksson
2012-02-21erts: Multiple module tables using code_ixSverker Eriksson
2012-02-21erts: Use several addresses in each ExportSverker Eriksson
2012-02-21erts: Multiple export tab's using code_ixSverker Eriksson
Still blocking code loading
2012-02-21erts: First stab at code_ix interface and beam_catches using itSverker Eriksson
Code loading still blocking
2012-02-21erts: Refactor Module structSverker Eriksson
2011-12-02Get cerl and distribution working in Win64Patrik Nyblom
Can still not setup -a, but cerl works.
2011-11-17Allow refc binaries in literal poolsBjörn Gustavsson
To simplify the implementation of literal pools (constant pools) for the R12 release, a shortcut was taken regarding binaries -- all binaries would be stored as heap binaries regardless of size. To allow a module containing literals to be unloaded, literal terms are copied when sent to another process. That means that huge literal binaries will also be copied if they are sent to another process, which could be surprising. Another problem is that the arity field in the header for the heap object may not be wide enough to handle big binaries. Therefore, bite the bullet and allow refc binaries to be stored in literal pools. In short, the following need to be changed: * Each loaded module needs a MSO list, linking all refc binaries in the literal pool. * When check_process_code/2 copies literals to a process heap, it must link each referenced binary into the MSO list for the process and increment the reference counter for the binary. * purge_module/1 must decrement the reference counter for each refc binary in the literal pool.
2011-11-17BEAM loader: Don't stop other schedulers until truly neededBjörn Gustavsson
The erlang:module_load/2 BIF will stop all other schedulers before it starts to process the BEAM file. That is not a problem when starting the Erlang/OTP system, since the start-up is mostly sequential. It is a problem, however, when big BEAM files are loaded in an already running system. After the refactoring in the previous commits, we can now do most of the processing of the BEAM file before we stop the other schedulers, so that we can minimize the time when only one scheduler will be running. Suggested-by: Bob Ippolito
2011-11-14BEAM loader: Clean up handling of error reasonsBjörn Gustavsson
There is no reason to have erts_load_module() return integer values, only to have the caller convert the values to atoms. Return the appropriate atom directly from the place where the error is generated instead. Return NIL if the module was successfully loaded.
2011-11-14Remove the useless -l optionBjörn Gustavsson
The -l option used to print information about modules being loaded, but now it prints very little information.
2011-11-13Merge branch 'rickard/thr-progress-block/OTP-9631'Rickard Green
* rickard/thr-progress-block/OTP-9631: Replace system block with thread progress block
2011-11-13Replace system block with thread progress blockRickard Green
The ERTS internal system block functionality has been replaced by new functionality for blocking the system. The old system block functionality had contention issues and complexity issues. The new functionality piggy-backs on thread progress tracking functionality needed by newly introduced lock-free synchronization in the runtime system. When the functionality for blocking the system isn't used there is more or less no overhead at all. This since the functionality for tracking thread progress is there and needed anyway.
2011-11-02beam_loader: Support external funs in the literal poolBjörn Gustavsson
A future release of the compiler might want to treat external funs as literals. Make sure that the loader can cope with an export entry being created from both an entry in the literal pool and from the export table (i.e. if an external fun refers to an exported function in the same module).
2011-08-25Add erlang:check_old_code/1Björn Gustavsson
Add erlang:check_old_code/1 to quickly check whether a module has old code. If there is no old code, there is no need to call erlang:check_process_code/2 for all processes, which will save some time if there are many processes.
2011-08-25check_process_code/2: Quickly return 'false' if there is no old codeBjörn Gustavsson
There is no need to suspend the process if the module has no old code. Measurements show that this change will make erlang:check_process_code/2 in an SMP emulator about four times faster if the module has no old code.
2011-05-13Merge branch 'sverker/hipe-misc-fixing/OTP-9298' into devBjörn-Egil Dahlberg
* sverker/hipe-misc-fixing/OTP-9298: hipe_mkliterals print argv[0] in generated files Fix code:is_module_native segv on deleted module lock checking fix in hipe_bif2.c
2011-05-11Fix code:is_module_native segv on deleted moduleSverker Eriksson
2011-05-11Merge branch 'rickard/gc-other/OTP-9211' into devRickard Green
* rickard/gc-other/OTP-9211: Fix bad assertions Avoid scheduling of processes being garbage collected by others
2011-04-11Avoid scheduling of processes being garbage collected by othersRickard Green
2011-03-16erts: Remove unused variablesTuncer Ayaz
2010-08-27fix native code crash when calling unloaded module with on_load functionMikael Pettersson
As reported in erlang-bugs, the following sequence of events crashes the VM: 1. Module M1 is loaded and in native mode. 2. Module M2 is not loaded, in emulated mode, and has an on_load function. 3. M1 calls some function in M2. This works. 4. M1 again calls some function in M2. This segfaults. The reason for the crash is that when the beam loader fixes up export entries after a successful on_load function call, it erroneously clears the ->code[3] field in that module's export entries. This is redundant (no code in beam relies on ->code[3] being NULL), inconsistent with modules without on_load functions (there ->code[3] remains a valid beam instruction after the module is loaded), and breaks native code which needs the old ->address value in an export entry to remain valid after a module load step (before the load ->address points to ->code[3], after the load ->address points to the real code but uses of the old ->address value remain so ->code[3] must remain valid). Thus the fix for the crash is to simply not clear ->code[3]. This patch fixes R14A and should also fix R13B04. (There does exist a performance bug in this area, but it is unrelated to the on_load feature so will be fixed separately.)
2010-07-20One off-heap list, to eliminate two words per ETS object.Sverker Eriksson
Merging the three off-heap lists (binaries, funs and externals) into one list. This reduces memory consumption by two words (pointers) per ETS object.
2010-06-03Remove trailing character in beam_bif_loadBjörn-Egil Dahlberg
2010-03-10Add the BeamInstr data type for loaded BEAM codePatrik Nyblom
For cleanliness, use BeamInstr instead of the UWord data type to any machine-sized words that are used for BEAM instructions. Only use UWord for untyped words in general.
2010-03-10Store pointers to heap data in 32-bit wordsPatrik Nyblom
Store Erlang terms in 32-bit entities on the heap, expanding the pointers to 64-bit when needed. This works because all terms are stored on addresses in the 32-bit address range (the 32 most significant bits of pointers to term data are always 0). Introduce a new datatype called UWord (along with its companion SWord), which is an integer having the exact same size as the machine word (a void *), but might be larger than Eterm/Uint. Store code as machine words, as the instructions are pointers to executable code which might reside outside the 32-bit address range. Continuation pointers are stored on the 32-bit stack and hence must point to addresses in the low range, which means that loaded beam code much be placed in the low 32-bit address range (but, as said earlier, the instructions themselves are full words). No Erlang term data can be stored on C stacks (enforced by an earlier commit). This version gives a prompt, but test cases still fail (and dump core). The loader (and emulator loop) has instruction packing disabled. The main issues has been in rewriting loader and actual virtual machine. Subsystems (like distribution) does not work yet.
2010-02-11OTP-8335 Even more NIF featuresSverker Eriksson
2009-11-20The R13B03 release.OTP_R13B03Erlang/OTP