aboutsummaryrefslogtreecommitdiffstats
path: root/erts/preloaded/src/init.erl
AgeCommit message (Collapse)Author
2016-04-26erts: Add profiling of startupBjörn-Egil Dahlberg
Usage: erl -profile_boot ...
2016-04-15erts: Implement tracer modulesLukas Larsson
Add the possibility to use modules as trace data receivers. The functions in the module have to be nifs as otherwise complex trace probes will be very hard to handle (complex means trace probes for ports for example). This commit changes the way that the ptab->tracer field works from always being an immediate, to now be NIL if no tracer is present or else be the tuple {TracerModule, TracerState} where TracerModule is an atom that is later used to lookup the appropriate tracer callbacks to call and TracerState is just passed to the tracer callback. The default process and port tracers have been rewritten to use the new API. This commit also changes the order which trace messages are delivered to the potential tracer process. Any enif_send done in a tracer module may be delayed indefinitely because of lock order issues. If a message is delayed any other trace message send from that process is also delayed so that order is preserved for each traced entity. This means that for some trace events (i.e. send/receive) the events may come in an unintuitive order (receive before send) to the trace receiver. Timestamps are taken when the trace message is generated so trace messages from differented processes may arrive with the timestamp out of order. Both the erlang:trace and seq_trace:set_system_tracer accept the new tracer module tracers and also the backwards compatible arguments. OTP-10267
2016-04-13Merge branch 'henrik/update-copyrightyear'Henrik Nord
* henrik/update-copyrightyear: update copyright-year
2016-03-17init: Load modules in parallel using the new loader BIFsBjörn Gustavsson
Use erlang:prepare_loading/1 and erlang:finish_loading/1 to load modules in parallel to potentially decrease start-up times.
2016-03-16init: Correct spec for fetch_loaded/1Björn Gustavsson
fetch_loaded/1 returns a list of tuples, not a list of atoms.
2016-03-15update copyright-yearHenrik Nord
2016-01-13erts: Make erlang:purge_module/1 safeSverker Eriksson
Problem: erlang:purge_module/1 is not safe in the sense that very bad things may happen if the code to be purged is still referred to by live processes. Introduce erts_internal:purge_module which is the same as the old erlang:purge_module BIF (except it returns false if no such old module). Implement erlang:purge_module in Erlang and let it invoke erts_code_purger for safe purging where all clogging processes first are killed.
2015-12-16init: Eliminate the concat/1 functionBjörn Gustavsson
There is no need to use the concat/1 function since all arguments that are passed to it have known types.
2015-12-16Clean up start of erl_prim_loaderBjörn Gustavsson
The 'init' module fetches command line parameters and passes them to erl_prim_loader:start/3. The code can be simplified if 'init' calls a new erl_prim_loader:start/0 function that itself fetches the necessary command line parameters. Also remove the documentation for the start() function, since it there is no way that it can be usefully called by a user application. While we are at it, also get rid of '-id' command line parameter, which is fetched and stored but never actually used.
2015-12-16Remove erl_prim_loader:get_files/2Björn Gustavsson
erl_prim_loader:get_files/2 was an optimization introduced before the SMP emulator (that is, before R11). The idea was to use the async threads in the efile driver to read multiple BEAM files from the disk in parallel. In a modern computer with the SMP emulator, loading a BEAM module seems to be more time-consuming than reading it from disk. To optimize loading we would need to load several modules in parallel. We could modify get_files/2 so that it would support parallel loading, but it is cleaner to first remove get_files/2 and then (in a future commit), introduce new functions to support parallel loading.
2015-12-16Reduce the ludicrous number of arguments for eval_script()Björn Gustavsson
The compact wall of arguments makes it hard to see what is actually happening in eval_script(). Collect the arguments into a record.
2015-12-16Clean up handling of boot_varsBjörn Gustavsson
Expansion of $ROOT in paths are handled specially compared to boot variables. There is no reason $ROOT can't be handled as a boot variable. We can simplify the expansion of boot variables if we spend a little extra effort upfront collecting all boot variables into a map. Make the error checking for -boot_var arguments stricter. Only allow -boot_var followed by exactly two arguments to help users catch errors earlier.
2015-12-16Remove useless 'catch' in start_it/1Björn Gustavsson
The last clause in start_it/1 calls a function in some module. It goes to great length to catch any exception and pass them on unchanged, and if there was a normal return, it will just return the return value. It can been seen that the entire 'catch' construction with the reference trick is totally unnecessary.
2015-12-16Simplify get_flag() and get_flag_list()Björn Gustavsson
The get_flag/3 function which returns a default value if the flag doesn't exist, is implemented in terms of get_flag/2 which throws an exception if the flag doesn't exist. get_flag/3 is frequently used for the flags that don't exist, which means that means that an exception will be generated and catched for no good reason. Reimplement get_flag/3 so that it doesn't have to call get_flag/2 and catch an exception. Eliminate the get_flag/2 function by writing a special purpose function for the only time it's used, that is for retrieving the value for the -root flag. As a side-effect, we will get a nicer error message if there is something wrong with the -root flag. Similarly, simplify get_flag_list/3 and remove get_flag_list/2. We can also eliminate search/3 and use the lists:keyfind/3 BIF instead.
2015-12-16Clean up parsing and lookup of flagsBjörn Gustavsson
The handling of flags has been incrementally messed up over time, leading to convoluted code. Rewrite the parsing and lookup of flags. By using the appropriate data structures, the code will become simpler.
2015-11-05Fix crash on init restartLuis Rascao
On load handler process not being launched on a restart, NIF's such as asn1rt_nif require it to be present for correct loading.
2015-06-18Change license text to APLv2Bruce Yinhe
2015-05-08Optimized timer implementationRickard Green
2015-03-20Erlang based BIF timer implementation for scalabilityRickard Green
2014-04-11The encoding for '-eval Program' should be UTF-8Björn Gustavsson
If file:name_native_encoding() returns 'utf8', any arguments following the -run option are assumed to be encoded in UTF-8. -eval should treat is argument the same way.
2013-05-28Allow unicode characters for boot and config in init:make_permanentSiri Hansen
When release_handler makes a release permanent, it calls init:make_permanent/2 in order to set the path to the config and boot file. The paths are coverterd to binaries, and this commit changes this conversion from using lists_to_binary/1 to using unicode:characters_to_binary/3 with the encoding set according to the file name encoding mode (+fnu/fna/fnl).
2013-05-06Fix unmatched_returns warnings in STDLIB and KernelHans Bolinder
2013-01-25Make arguments given with -s option to erl aware of file name encodingSiri Hansen
OTP-10702 Arguments to functions started with the -s option to erl were converted to atoms with list_to_atom(binary_to_list(Bin)) and thus were always seen as latin1 encoded. For other arguments to erl the conversion (to string) would take into account the file name translation mode (set with +fnl, +fnu or +fna switch to erl) and try to convert using unicode:characters_to_list/2. The reason behind this is that it must be possible to give paths and filenames on the command line and get the expected encoding. With the same reasoning, this commit changes the behaviour for arguments to functions started with the -s option to also take into account the file name translation mode. The arguments are now converted to atoms by list_to_atom(unicode:characters_to_list(Bin,file:native_name_encoding())
2012-08-31Update copyright yearsBjörn-Egil Dahlberg
2012-08-21Fix init:restart with hipelibsSverker Eriksson
This is a workaround for init:restart. The root problem is that delete/purge_module does not clean up internal hipe bookkeeping (hipe_mfa_info's) properly. Symptom: Execution of deallocated beam code.
2012-08-14Make get/putenv and erlexec understand UnicodePatrik Nyblom
Putenv and getenv needs to convert to the proper environment strings in Unicode depending on platform and user settings for filename encoding. Also erlexec needs to pass environment strings in an appropriate way for kernel to pick up. All environment strings on the command line, as well as home directory, is now passed in UTF8 on windows and in whatever encoding you have on Unix, kernel tries to convert all parameters and environments from UTF8 before making strings.
2011-09-16Fix typos in erts/preloaded/srcTuncer Ayaz
2011-06-20Add more specs and typesHans Bolinder
An incorrect spec, rpc:yield/1, has been fixed.
2010-11-09init: Fix two erroneous specsKostis Sagonas
While at it, introduced a state() type and used it in some place.
2010-10-20Teach -init_debug to print info about on_load handlers begin runBjörn Gustavsson
2010-10-20Fix hang in on_load handlers in embedded modeBjörn Gustavsson
In embedded mode, all on_load handlers will be called after loading all modules but before starting any servers. Therefore, if an on_load handler calls any function in the code module that calls the code server (such as code:priv_dir/1), there will be a deadlock because the code server has not yet been started. Fix this problem by invoking the on_load handlers after having started most servers in the kernel application.
2010-02-11Merge branch 'ks/erts' into ccase/r13b04_devErlang/OTP
* ks/erts: hipe_bif0.c: Remove $Id$ erts/preloaded: Add types and specs
2010-02-11erts/preloaded: Add types and specsKostis Sagonas
2009-12-13Change the expected return value for on_load functionsBjörn Gustavsson
An on_load function is supposed to return 'true' to indicate that the module should be loaded, and 'false' if it should be unloaded. But returning any other term, as well as causing an exception, will also unload the module. Since we don't like boolean values mixed with other values, change the expected return value as follows: * If 'ok' is returned, the module will remain loaded and become callable. * If any other value is returned (or an exception is generated), the module will be unloaded. Also, if the returned value is not an atom, send a warning message to the error_logger (using error_logger:warning_msg/2). The new interpretation of the return value means that an on_load function can now directly return the return value from erlang:load_nif/2.
2009-11-20The R13B03 release.OTP_R13B03Erlang/OTP