aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam
AgeCommit message (Collapse)Author
2011-08-16Lookup and include filenames and line numbers in exceptionsBjörn Gustavsson
2011-08-16Fix decrement of continuation pointersBjörn Gustavsson
2011-08-16Refactor building of the exception stacktraceBjörn Gustavsson
As a preparation for providing information about the source location for an MFA item in an exception stacktrace, refactor the code that builds the exception stacktrace. Basically we need two passes over the saved continuation counters: a first pass to calculate the needed heap space and a second pass to actually build the stacktrace.
2011-08-16BEAM loader: Load the line tableBjörn Gustavsson
2011-08-16emulator: Add a fourth element in exception stacktracesBjörn Gustavsson
This commit is a preparation for introducing location information (filename/line number) in stacktraces in exceptions. Currently a stack trace looks like: [{Mod1,Function1,Arity1}, . . . {ModN,FunctionN,ArityN}] Add a forth element to each tuple that can be used indication the filename and line number of the source file: [{Mod1,Function1,Arity1,Location1}, . . . {ModN,FunctionN,ArityN,LocationN}] In this commit, the fourth element will just be an empty list, and we will change all code that look at or manipulate stacktraces.
2011-08-16compiler, emulator: Introduce the line/1 instructionBjörn Gustavsson
Introduce the line/1 instruction in the compiler and the BEAM virtual machine. It will not yet be generated by the compiler and will not actually carry any information.
2011-08-05Merge branch 'dev' into majorBjörn Gustavsson
* dev: Fix binary construction with huge literal sizes beam_load.c: Add overflow check of tag values beam_makeops: Add some sanity checks Fix construction of <<0:((1 bsl 32)-1)>>
2011-08-03Fix binary construction with huge literal sizesBjörn Gustavsson
Constructing binaries using the bit syntax with literals sizes that would not fit in an Uint will either cause an emulator crash or the loading to be aborted. Use the new TAG_o tag introduced in the previous commit to make sure that the attempt to create huge binary literals will generate a system_limit exception at run-time.
2011-08-03beam_load.c: Add overflow check of tag valuesBjörn Gustavsson
The handling of large values for other tags than TAG_i (integer) is buggy. Any tag value equal to or greater than 2^40 (5 bytes) will abort loading. Tag values fitting in 5 bytes will be truncated to 4 bytes values. Those bugs cause real problems because the bs_init2/6 and bs_init_bits/6 instructions unfortunately use TAG_u to encode literal sizes (using TAG_i would have been a better choice, but it is too late to change that now). Any binary size that cannot fit in an Uint should cause a system_limit exception at run-time, but instead the buggy handling will either cause an emulator crash (for values in the range 2^32 to 2^40-1) or abort loading. In this commit, implement overflow checking of tag values as a preparation for fixing the binary construction instructions. If any tag value cannot fit in an Uint (except for TAG_i), change the tag to the special TAG_o overflow tag.
2011-08-03Fix construction of <<0:((1 bsl 32)-1)>>Björn Gustavsson
Attempting to construct <<0:((1 bsl 32)-1)>>, the largest bitstring allowed in a 32 bit emulator, would cause an emulator crash because of integer overflow. Fix the problem by using an Uint64 to avoid integer overflow. Do not attempt to handle construction of <<0:((1 bsl 64)-1>> in a 64-bit emulator, because that will certainly cause the emulator to terminate anyway because of insufficient memory.
2011-07-29Merge branch 'dev' into majorSverker Eriksson
2011-07-29Merge branch 'sverker/allocator-aoff/OTP-9424' into devSverker Eriksson
* sverker/allocator-aoff/OTP-9424: New allocator: Address order first fit (aoff)
2011-07-26Merge branch 'dev' into majorSverker Eriksson
2011-07-20Small fixups for rickard/sbmbc/OTP-9339Sverker Eriksson
alloc_no of sbmbc_low_alloc was set to ERTS_ALC_A_STANDARD_LOW
2011-07-18New allocator: Address order first fit (aoff)Sverker Eriksson
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-13Merge branch 'sverker/enif_make_int64-halfword/OTP-9394' into devSverker Eriksson
* sverker/enif_make_int64-halfword/OTP-9394: Fix halfword bug in enif_make_int64
2011-07-12Merge branch 'dev' into majorSverker Eriksson
2011-07-11Merge branch 'rickard/sbmbc/OTP-9339' into maint-r14Erlang/OTP
* rickard/sbmbc/OTP-9339: Use separate memory carriers for small blocks
2011-07-11Merge branch 'sverker/ets_delete-deadlock-race/OTP-9423' into maint-r14Erlang/OTP
* sverker/ets_delete-deadlock-race/OTP-9423: Fix bug in ets:delete for write_concurrency that could lead to deadlock
2011-07-08Use separate memory carriers for small blocksRickard Green
2011-07-08Merge branch 'rickard/atomics-api/OTP-9014' into majorRickard Green
* rickard/atomics-api/OTP-9014: Use new atomic API in runtime system Improve ethread atomics
2011-07-07Fix a match-spec trace bug that could cause emulator crashSverker Eriksson
A trace matchspec with 'enable_trace' or 'disable_trace' in body could cause an emulator crash if a concurrent process altered the trace setting of the traced function by calling erlang:trace_pattern. The effect was a deallocation of the binary holding the matchspec program while it was running. Fixed by increasing reference count of ms-binary in the cases when 'enable_trace' or 'disable_trace' may cause a system block that may alter the ongoing trace. The paradox here is that db_prog_match() is using erts_smp_block_system() to do 'enable_trace' and 'disable_trace' in a safe (atomic) way. But that also have the (non-atomic) effect that racing thread might block the system and change the trace settings with erlang:trace_pattern.
2011-07-07Fix bug in ets:delete for write_concurrency that could lead to deadlockSverker Eriksson
Relocking in ets_delete_1() and remove_named_tab() was done by unlocking the table without clearing the is_thread_safe flag. A racing thread could then read-lock the table and then incorrectly write-unlock the table as db_unlock() looked at is_thread_safe to determine which kind of lock to unlock. Several fixes: 1. Make db_unlock() use argument 'kind' instead of is_thread_safe to determine lock type. 2. Make relock logic use db_lock() and db_unlock() instead of directly accessing lock primitives. 3. Do ownership transfer earlier in ets_delete_1 to avoid racing owner process to also start deleting the same table.
2011-07-01Add version commentLukas Larsson
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-14Use new atomic API in runtime systemRickard Green
All uses of the old deprecated atomic API in the runtime system have been replaced with the use of the new atomic API. In a lot of places this change imply a relaxation of memory barriers used.
2011-06-14Improve ethread atomicsRickard Green
The ethread atomics API now also provide double word size atomics. Double word size atomics are implemented using native atomic instructions on x86 (when the cmpxchg8b instruction is available) and on x86_64 (when the cmpxchg16b instruction is available). On other hardware where 32-bit atomics or word size atomics are available, an optimized fallback is used; otherwise, a spinlock, or a mutex based fallback is used. The ethread library now performs runtime tests for presence of hardware features, such as for example SSE2 instructions, instead of requiring this to be determined at compile time. There are now functions implementing each atomic operation with the following implied memory barrier semantics: none, read, write, acquire, release, and full. Some of the operation-barrier combinations aren't especially useful. But instead of filtering useful ones out, and potentially miss a useful one, we implement them all. A much smaller set of functionality for native atomics are required to be implemented than before. More or less only cmpxchg and a membar macro are required to be implemented for each atomic size. Other functions will automatically be constructed from these. It is, of course, often wise to implement more that this if possible from a performance perspective.
2011-05-20Update copyright yearsBjörn-Egil Dahlberg
2011-05-19Merge branch 'rickard/driver_async_cancel/OTP-9302' into devRikard Green
* rickard/driver_async_cancel/OTP-9302: Fix driver_async_cancel()
2011-05-18Fix driver_async_cancel()Rickard Green
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-13Merge branch 'rickard/barriers/OTP-9281' into devRickard Green
* rickard/barriers/OTP-9281: Silence warnings Fix build with hipe on amd64 Reduce number of atomic ops Use 32-bit atomic for port snapshot Remove pointless erts_ports_alive variable Ensure quick break Ensure that all rehashing information are seen when done Ensure that stack updates are seen when stack is released Add needed barriers for write_concurrency tables Homogenize memory barriers on atomics
2011-05-13Silence warningsRickard Green
2011-05-13Fix build with hipe on amd64Rickard Green
2011-05-13Reduce number of atomic opsRickard Green
Counters for active, and used schedulers have been coalesced in order to reduce the amount of atomic operations needed. Some currently not strictly necessary barriers have also been added in order to be future proof.
2011-05-13Use 32-bit atomic for port snapshotRickard Green
2011-05-13Remove pointless erts_ports_alive variableRickard Green
2011-05-13Ensure that all rehashing information are seen when doneRickard Green
This is not a bugfix. The change is done in order to avoid a future bug.
2011-05-13Ensure that stack updates are seen when stack is releasedRickard Green
Ets tables using ordered_set could potentially get into an internally inconsistent state.
2011-05-13Merge branch 'bjorn/fix-warnings/OTP-9250' into devBjörn Gustavsson
* bjorn/fix-warnings/OTP-9250: Eliminate alias warning in gcc 4.5.2 erl_trace: Eliminate alias warning
2011-05-13Merge branch 'bjorn/fix-binary-overflow/OTP-9118' into devBjörn Gustavsson
* bjorn/fix-binary-overflow/OTP-9118: Fix overflow in list_to_bitstring/1 Replace io_list_len() with erts_iolist_size() Make port_command/2 reject non-byte sized bitstrings io.c: Make io_list_vec_len() less general iolist_size/1: Fix truncation of result Test iolist_size/1 with bad arguments binary_SUITE: Remove workaround for avoiding stack overflow
2011-05-13Add needed barriers for write_concurrency tablesRickard Green
Ets tables using the write_concurrency option could potentially get into an internally inconsistent state.
2011-05-12Merge branch 'sverker/halfword-printf-relative-terms/OTP-9292' into devBjörn-Egil Dahlberg
* sverker/halfword-printf-relative-terms/OTP-9292: ETS usage of erts_printf %R erts_printf %R for relative ets-terms in halfword-vm Another halfword is_same-bug for ETS ordered_set
2011-05-12Merge branch 'sverker/halfword-high-alloc/OTP-9291' into devBjörn-Egil Dahlberg
* sverker/halfword-high-alloc/OTP-9291: Present 'low' memory count for halfword-vm with erlang:memory() Fix faulty values from erlang:memory() on halfword-vm Allow allocator disable for high memory (better valgrind for halfword) Expand the use of high memory allocation in halfword emulator
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