aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/erl_nif.c
AgeCommit message (Collapse)Author
2012-08-17Relocate bodies of DTrace probes to the statically-linked VM.Scott Lystig Fritchie
Due to various operating systems (in both the DTrace and SystemTap worlds) not fully supporting DTrace probes (or SystemTap-compatibility mode probes) in shared libraries, we relocate those probes to the statically-linked virtual machine. This could be seen as pollution of the pristine VM by a (yet) experimental feature. However: 1. This code can be eliminated completely by the C preprocessor. 2. Leaving the probes in the dyntrace NIF shared library simply does not work correctly on too many platforms. *Many* thanks to Macneil Shonle at Basho for assisting when my RSI-injured fingers gave out. Tested on: * CentOS 5, SystemTap 1.3 * Solaris 10 (note) * Solaris 11 * OpenIndiana 151 * SmartOS 20120809T221258Z * FreeBSD 9.0-RELEASE (note) I had hoped to be able to test CentOS 6 + SystemTap 1.7, but the details of dealing with all dependencies for a 2.6.32-279.5.1.el6.x86_64 kernel are too time consuming right now. (note: Solaris 10 and FreeBSD 9.0-RELEASE can take a long time to compile)
2012-03-30Update copyright yearsBjörn-Egil Dahlberg
2012-03-22Ifdef all dynamic trace codePatrik Nyblom
2012-03-22Change to more specific configure options for dtracePatrik Nyblom
2012-03-22Add user tag spreading functionality to VM and use in filePatrik Nyblom
User tags in a dynamic trace enabled VM are spread throughout the system in the same way as seq_trace tokens. This is used by the file module and various other modules to get hold of the tag from the user process without changing the protocol.
2012-03-22Add DTrace support for OS X, Solaris, and Linux (via SystemTap), 3/4Scott Lystig Fritchie
Add probes to the virtual machine, except (mostly) the efile_drv.c driver and other file I/O-related source files.
2011-12-05Merge branch 'sverk/deprecate-nif-reload'Sverker Eriksson
* sverk/deprecate-nif-reload: erts: Deprecate the NIF reload mechanism OTP-9771
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-12-02Get cerl and distribution working in Win64Patrik Nyblom
Can still not setup -a, but cerl works.
2011-12-02Build Win64 Erlang emulator using MSYSunknown
Still does not run, just compiles.
2011-11-29erts: Deprecate the NIF reload mechanismSverker Eriksson
The reload mechanism is an odd feature that does not harmonize with how module upgrade is otherwise done. We do not want its presence to hinder future development of code loading and upgrade.
2011-11-25Fix clang linking problemBjörn Gustavsson
Inlining was not done in a portable way. clang follows the C99 semantics for inlining ('inline' essentially implies 'static' in C99, but not in GCC), so bp_sched2ix() was not visible outside beam_bp.c. Since the function need to be used from more than one source file, put the function definition in the beam_bp.h header file. Also, give it an 'erts_' prefix since it is globally visible.
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-09Merge branch 'sverk/enif_inspect-memleak/OTP-9668'Sverker Eriksson
* sverk/enif_inspect-memleak/OTP-9668: erts: Fix memory leak of enif_inspect_* on independent environment
2011-11-07erts: Remove unused variable in enif_make_binaryBjörn-Egil Dahlberg
2011-10-31erts: Fix memory leak of enif_inspect_* on independent environmentSverker Eriksson
Affects enif_inspect_iolist_as_binary() on iolists and enif_inspect_binary() on byte-unaligned binaries. Also need to allocate inspection buffers in ERTS_ALC_T_NIF for process independent environments, as we don't know when and where the environment will be freed.
2011-10-18Merge branch 'fm/enif_is_number'Henrik Nord
* fm/enif_is_number: Add NIF function enif_is_number Conflicts: erts/emulator/beam/erl_nif_api_funcs.h OTP-9629
2011-09-08Merge branch 'dev' into majorHenrik Nord
2011-09-02Fix enif_compare on 64bits machinesFilipe David Manana
In 64bits machines the Sint type has a size of 8 bytes, while on 32bits machines it has a 4 bytes size. enif_compare was ignoring this and therefore returning incorrect values when the result of the CMP function (which returns a Sint value) doesn't fit in 4 bytes. For example, passing the operands -1294536544000 and -1178704800000 to enif_compare would trigger the bug.
2011-07-13Merge branch 'dev' into majorSverker Eriksson
Conflicts: erts/emulator/test/nif_SUITE.erl erts/emulator/test/nif_SUITE_data/nif_SUITE.c sverker/enif_make_int64-halfword/OTP-9394
2011-07-01Rename enif_get_reverse_list to enif_make_reverse_listLukas Larsson
2011-06-30Fix halfword bug in enif_make_int64Sverker Eriksson
The bug was creating an invalid bignum instead of a small integer, causing strange comparing behavior (=:= failed but == succeeded).
2011-06-30Remove extra allocated heap fragmentLukas Larsson
2011-06-30Added enif_get_reverse_list to nif APILukas Larsson
2011-06-08Add NIF function enif_is_numberFilipe David Manana
This function allows for easily determining if a term represents or not a number (integer, float, small or big).
2011-05-10Replace io_list_len() with erts_iolist_size()Björn Gustavsson
The io_list_len() function returns an int, where a negative return value indicates a type error. One problem is that an int only consists of 32 bits in a 64-bit emulator. Changing the return type to Sint will solve that problem, but in the 32-bit emulator, a large iolist and a iolist with a type error will both return a negative number. (Noticed by Jon Meredith.) Another problem is that for iolists whose total size exceed the word size, the result would be truncated, leading to a subsequent buffer overflow and emulator crash. Therefore, introduce the new erts_iolist_size() function which returns a status indication and writes the result size through a passed pointer. If the result size does not fit in a word, return an overflow indication.
2011-03-24add support for checking if an ERL_NIF_TERM is an exceptionSteve Vinoski
Add the enif_is_exception function to allow callers to determine whether an ERL_NIF_TERM represents an exception. (Currently the only supported exception is badarg since only enif_make_badarg exists, but this will likely be expanded in future releases.) This allows NIF code to call other NIF functions that return ERL_NIF_TERM and properly check to see if the returned terms are exceptions. Without the enif_is_exception function, developers have to create their own means of checking whether a function creates an exception, such as returning boolean success/failure indicators or some other special value indicating that an exception is in effect. The declaration of enif_is_exception in erl_nif_api_funcs.h respects the order of declarations required to keep compatibility on Windows. Add a new test to verify the operation of enif_is_exception. Modify the erl_nif man page to add a description of enif_is_exception and also to clarify the requirements of calling the enif_make_badarg function. If code calls enif_make_badarg, the env passed in gets set with exception information and so the return value of the calling function MUST be the badarg term returned from enif_make_badarg. Also clarify that the result of enif_make_badarg may be passed only to enif_is_exception and not to any other NIF API functions.
2011-02-18Refuse to load NIF library on wrong VM variant (halfword/fullword)Sverker Eriksson
2011-02-03HALFWORD ETS match spec heap fragment optimizationSverker Eriksson
Introduce HAllocX to allocate heap fragments with a larger capacity than requested and by that reduce the number of fragments allocated.
2011-02-03HALFWORD Make more allocators use high mem (binary, fixed and driver)Sverker Eriksson
2011-02-03HALFWORD ETS relative termsSverker Eriksson
In halfword emulator, make ETS use a variant of the internal term format that uses relative offsets instead of absolute pointers. This will allow storage in high memory (>4G). Preprocessor macros (like list_val_rel(TERM,BASE)) are used to make normal (fullword) emulator almost completely unchanged while still reusing most of the code.
2010-11-25NIF 64-bit integer get/make bugfix for halfword emulator.Sverker Eriksson
2010-08-30Merge branch 'sverker/NIF-64bit-integers/OTP-8746' into devPatrik Nyblom
* sverker/NIF-64bit-integers/OTP-8746: Make windows 64bit types be declared more consistently Teach Windows about the int64 functions NIF doc official support note NIF 64-bit integer support
2010-08-12Increase vheap counter to Uint64Björn-Egil Dahlberg
This will reduce the risk of integer wrapping in bin vheap counting. The vheap size series will now use the golden ratio instead of doubling and fibonacci sequences. OTP #8730
2010-07-23NIF 64-bit integer supportSverker Eriksson
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-03Add a scheduler array for BpData at BeamInstr[-4]Björn-Egil Dahlberg
To solve the issue of multiple schedulers constantly updating the head pointer to the bp data wheel, each scheduler now has its own entrypoint to the wheel. This head pointer can be updated without a locking being taken. Previously there were no lock ...
2010-06-03OTP-8555 Send message from NIFSverker Eriksson
New NIF features: Send messages from a NIF, or from thread created by NIF, to any local process (enif_send) Store terms between NIF calls (enif_alloc_env, enif_make_copy) Create binary terms with user defined memory management (enif_make_resource_binary)
2010-05-24erl_nif: add make_atom_len, make_existing_atom_len and make_string_lenTuncer Ayaz
Add new NIF API functions - enif_make_atom_len - enif_make_existing_atom_len - enif_make_string_len These are basically the same as enif_make_atom, enif_make_existing_atom and enif_make_string except that the new functions require a length parameter instead of a null-terminated C-string. Signed-off-by: Tuncer Ayaz <[email protected]>
2010-05-24erl_nif: add enif_get_atom_length and enif_get_list_lengthTuncer Ayaz
Add new NIF API functions - enif_get_atom_length - enif_get_list_length Signed-off-by: Tuncer Ayaz <[email protected]>
2010-05-24erl_nif: add enif_is_list and enif_is_tupleTuncer Ayaz
Add new NIF API functions - enif_is_list - enif_is_tuple Signed-off-by: Tuncer Ayaz <[email protected]>
2010-05-17Add binary:longest_common_prefix/longest_common_suffixPatrik Nyblom
Add allcoator parameter to erts_get_aligned_binary_bytes_extra. Add testcases for the functions above. Add reference implementation for the functions above.
2010-04-28OTP-8474 NIF improvements after R13B04Sverker Eriksson
New NIF API function enif_make_new_binary
2010-03-10Adopt the new (R13B04) Nif functionality to the halfword codebasePatrik Nyblom
Change erl_int_sizes_config to include HALFWORD_HEAP_EMULATOR, which make it possible for the NIFs to figure out the term size.
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-12-09OTP-8304 Incompatible changes in the experimental NIF feature. Changed theSverker Eriksson
NIF function prototypes in order to allow more than 3 function arguments. Also an incompatible change in the return value of erlang:load_nif/2. Added support for references, floats and term comparison in NIFs. Read more in the documentation of erl_nif and erlang:load_nif/2.
2009-12-09OTP-8304 Incompatible changes in the experimental NIF feature. Changed theSverker Eriksson
NIF function prototypes in order to allow more than 3 function arguments. Also an incompatible change in the return value of erlang:load_nif/2. Added support for references, floats and term comparison in NIFs. Read more in the documentation of erl_nif and erlang:load_nif/2.