Age | Commit message (Collapse) | Author |
|
|
|
It was not possible to preserve extra arguments in transformations.
The following (hypothetical) example will now work:
some_op Lit=c SizeArg Rest=* => move Lit x | some_op x SizeArg Rest
|
|
files as delimiters.
While working on a tool that processes Erlang code and testing it against this repo,
I found out about those little sneaky 0xff. I thought it may be of help to other
people build such tools to remove non-conforming-to-standard characters.
|
|
|
|
|
|
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.
|
|
* 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
|
|
|
|
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.
|
|
|
|
|
|
* 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
|
|
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.
|
|
The concept of code_write_permission is used by tracing as well
and is not specific to code_ix.
|
|
|
|
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.
|
|
|
|
Move implementation from beam_load into new file code_ix.c and module.c
and make some function inline.
|
|
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.
|
|
|
|
Staging is a better and more general name as does not necessary need
to involve code loading (can be deletion, tracing, etc).
|
|
|
|
As it can only be used at initialization for preloading
|
|
Renamed merge_secondary_table and called by export_start_load
|
|
Implemented some code_ix locks
and commented calls to erts_smp_thr_progress_block()
|
|
|
|
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.
|
|
|
|
|
|
Still blocking code loading
|
|
Code loading still blocking
|
|
The default array was defined but not used.
|
|
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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
|
|
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.
|
|
|
|
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.
|
|
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.
|
|
* 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
|
|
Since refc binaries are now supported in literal pools, there is no
longer any need to allow the creation of over-sized heap binaries.
|
|
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.
|
|
|
|
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.
|
|
|