aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/beam_load.c
AgeCommit message (Collapse)Author
2013-04-30Fix some sign warnings found with ClangAnthony Ramine
2013-02-25erts: Fix crash on halfword and code_SUITE:big_boot_embeddedSverker Eriksson
2013-01-31compiler: Use the literal pool for floating point constantsBjörn Gustavsson
The BEAM loader will put floating point constants into the literal pools for the module, but it will not check for duplicates. We can do much better by having the compiler use the literal pool for floating point constants.
2013-01-25Merge branch 'pan/fix-compiler-warnings-clang-and-new-gcc'Patrik Nyblom
* pan/fix-compiler-warnings-clang-and-new-gcc: Fix compiler warnings from GCC 4.7.1 on ARCH Linux Fix clang compiler warnings on FreeBSD in erts
2013-01-25Update copyright yearsBjörn-Egil Dahlberg
2013-01-23Fix clang compiler warnings on FreeBSD in ertsPatrik Nyblom
The following are deliberately left, as I have only a list of compiler warnings and no system to test on: hipe/hipe_x86_signal.c:264:5: warning: no previous prototype for function '_sigaction' [-Wmissing-prototypes] int __SIGACTION(int signum, const struct sigaction *act, struct sigaction *oldact) ^ hipe/hipe_x86_signal.c:222:21: note: expanded from macro '__SIGACTION' ^ 1 warning generated. sys/unix/sys_float.c:835:16: warning: declaration of 'struct exception' will not be visible outside of this function [-Wvisibility] matherr(struct exception *exc) ^ sys/unix/sys_float.c:835:1: warning: no previous prototype for function 'matherr' [-Wmissing-prototypes] matherr(struct exception *exc) ^ 2 warnings generated. drivers/unix/unix_efile.c:1504:11: warning: implicit declaration of function 'sendfile' [-Wimplicit-function-declaration] retval = sendfile(in_fd, out_fd, *offset, SENDFILE_CHUNK_SIZE, ^ 1 warning generated.
2013-01-16UTF-8 support for distributionRickard Green
2013-01-08erts: Change internal representation of atoms to utf8Sverker Eriksson
2012-10-05Merge branch 'sverk/code-load-refactor-later-op'Sverker Eriksson
* sverk/code-load-refactor-later-op: erts: Fix faulty lock check assert erts: Refactor naming regarding code_write_permission erts: Refactor tracing to use erts_schedule_thr_prgr_later_op erts: Allow thr_prgr_later_op to reschedule erts: Refactor code loading to use erts_schedule_thr_prgr_later_op erts: Remove some compiler warnings
2012-09-26Fix missing information in crash dump for native-compiled modulesBjörn Gustavsson
In the erl_crash.dump file, native-compiled modules did not have any information about attributes and compilation. The problem is that the code:make_stub_module/3 BIF (which is internally used when native code is loaded) did not copy the size field the attribute and compilation info chunks. Those size fields are only used when writing crash dumps.
2012-08-31erts: Refactor naming regarding code_write_permissionSverker Eriksson
The concept of code_write_permission is used by tracing as well and is not specific to code_ix.
2012-02-21erts: Fix type bugSverker Eriksson
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: Refactor code_ixSverker Eriksson
Move implementation from beam_load into new file code_ix.c and module.c and make some function inline.
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: Cleanup code loadingSverker Eriksson
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: Remove secondary_export_tableSverker Eriksson
2012-02-21erts: Rename erts_load_module to erts_preload_moduleSverker Eriksson
As it can only be used at initialization for preloading
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_ranges: Make ranges safe with multi-scheduling activeBjörn Gustavsson
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: 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: Make use of def_lambdas optimization during loadingSverker Eriksson
The default array was defined but not used.
2012-02-21erts: Refactor Module structSverker Eriksson
2012-02-01beam_load: Fix faulty assertion in module_info(native_addresses)Björn Gustavsson
Commit 64ccd8c9b7a782ca777ca4649dbb1f4a1ef00bce introduced BIF stubs. The stub functions were not actually remove the loaded code, but the name of the function in the func_info instruction was changed to [] to mark it as invalid. The actual code for module_info(native_addresses) did not need to be updated (a BIF stub can never have a native address and a function without a native address will never be included in the list), but the assertion that the name is an atom is no no longer correct.
2012-01-24beam_load.c: Allow stubs for BIFsBjörn Gustavsson
We want to be able to write type specifications for BIFs in the same way as for any other function. Currently, the type for BIFs need to be described in erl_bif_types. To avoid extending the compiler and Dialyzer with special directives for providing specifications for BIFs, we have decided to let the loader accept a local definition for a function which exists as a BIF. As an example, here is how a stub for lists:reverse/2 can be defined: -export([reverse/2]). -spec reverse([term()], term()) -> [term()]. reverse(_, _) -> erlang:nif_error(undef). Essentially, the loader will discard the local definition of reverse/2. Other functions in the same module must *not* do local calls to a BIF stub. If a local call to a BIF is found, the loader will refuse to load the module. That is, the following call is not allowed: reverse(List) -> reverse(List, []). but the following is: reverse(List) -> ?MODULE:reverse(List, []). A few words about the implementation. It turns out to be too complicated to actually discard the BIF stubs. Although it would be possibly with some jiggery pokery in ops.tab, the code would be difficult to maintain and it could slow down loading of modules that don't define BIFs (which are almost all modules). Therefore, the stub functions are kept in the loaded code, but their names in the func_info instruction are invalidated so that module_info(functions) can filter them out.
2012-01-11beam_load.c: Don't show unnecessary context in errorsBjörn Gustavsson
For errors that occur after reading the code chunking, saying that the error occurred in the last function in the module and in the instruction int_code_end/0 is just confusing.
2012-01-11beam_load.c: Remove useless call to next_heap_size()Björn Gustavsson
The idea was probably to cause less fragmentation. Even if that would be true, it is irrelevant because the short-lived allocator that is used does not have any problems with fragmentation. In CodeNeed() we will simply double the size of the area used for code instead of using the next heap size.
2012-01-11beam_load.c: apply/2 does not need a special caseBjörn Gustavsson
It is wrongly assumed in the BEAM loader that apply/2 is a BIF and must be treated specially. Also make it clearer in ops.tab that apply/3 is a BIF, but apply/2 is not.
2011-12-07BEAM loader: Fix bug that allowed loading of more than two versionsBjörn Gustavsson
In commit b67d3e5447f4b2bca3ed92f3db84adb3f79f9b16 (which cleaned up handling of error reasons), the test of the return value from beam_make_current_old() in insert_new_code() was not updated, which meant that it never was true and any number of versions of code could be loaded for a module.
2011-12-02Iron out bugs in Win64 found in daily buildsPatrik Nyblom
Almost all uses of the 'long' datatype is removed from VM and tests Emulator test now runs w/o drivers crashing Nasty abs bug fixed in VM as well as type errors in allocator debug functions Still one allocator test that fails, domain knowledge is needed to fix that. Fix type inconsistency in beam_load causing crashes
2011-11-26beam_load.c: Add init_iff_file() for verifying the IFF headerBjörn Gustavsson
Add init_iff_file() for verifying the IFF header. Also let it handle compressed BEAM files so that it will be done in one place. That means that code:get_chunk/2 and code:module_md5/1 will now support compressed BEAM files.
2011-11-26beam_code.c: Don't reinvent state initialization and deallocationBjörn Gustavsson
2011-11-26beam_load.c: Optimize code:get_chunk/2Björn Gustavsson
The undocumented code:get_chunk/2 BIF is supposed to be a fast way to extract a chunk from a BEAM file when loading native code. In practice, it might not have been faster because it happened to calculate an MD5 checksum for the chunk it extracted because it shared the scan_iff_file() function with the erlang:load_module/2 BIF. Split scan_iff_file() into scan_iff_file() and verify_chunks(), so that the unnecessary MD5 calculation can be avoided.
2011-11-26beam_load.c: Eliminate memory leak in code:make_stub_module/3Björn Gustavsson
code:make_stub_module/3 leaked memory if given either a corrupt BEAM file, or a compressed BEAM file and an error occurred, or a binary not aligned on byte boundaries.
2011-11-18Merge branch 'pan/binary_match_scope/OTP-9701'Patrik Nyblom
* pan/binary_match_scope/OTP-9701: Remove remaining gcc 4.6 assigned-but-not-used warnings from erts Remove GCC 4.6 set-but-not-used warning from erl_bif_binary Make binary:match with scope return correct values
2011-11-17external.c: Remove the option to create over-sized heap binariesBjörn Gustavsson
Since refc binaries are now supported in literal pools, there is no longer any need to allow the creation of over-sized heap binaries.
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-16Remove remaining gcc 4.6 assigned-but-not-used warnings from ertsPatrik Nyblom
2011-11-14BEAM loader: Refactor code loading into separate functionsBjörn Gustavsson
Break apart code loading into the three functions: erts_alloc_loader_state() erts_prepare_loading() erts_finish_loading() The erts_alloc_loader_state() and erts_prepare_loading() can be executed with all schedulers running. Only erts_finish_loading() needs to be run in a single-scheduling system.
2011-11-14beam_load.c: Factor out cleaning up of the loader state into free_state()Björn Gustavsson
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-14beam_load.c: Simplify handling of the bs_put_string_II instructionBjörn Gustavsson
Remove the special-case handling of the bs_put_string_II instruction; simply use the string patch mechanism that is already used for the i_bs_match_string_* instructions.
2011-11-14beam_load.c: Remove the unused struct LoadedCodeBjörn Gustavsson