Age | Commit message (Collapse) | Author |
|
|
|
|
|
|
|
* sverker/inline-sys_memcpy:
erts: Fix some zero size sys_memcpy
|
|
Communication between Erlang processes has conceptually always been
performed through asynchronous signaling. The runtime system
implementation has however previously preformed most operation
synchronously. In a system with only one true thread of execution, this
is not problematic (often the opposite). In a system with multiple threads
of execution (as current runtime system implementation with SMP support)
it becomes problematic. This since it often involves locking of structures
when updating them which in turn cause resource contention. Utilizing
true asynchronous communication often avoids these resource contention
issues.
The case that triggered this change was contention on the link lock due
to frequent updates of the monitor trees during communication with a
frequently used server. The signal order delivery guarantees of the
language makes it hard to change the implementation of only some signals
to use true asynchronous signaling. Therefore the implementations
of (almost) all signals have been changed.
Currently the following signals have been implemented as true
asynchronous signals:
- Message signals
- Exit signals
- Monitor signals
- Demonitor signals
- Monitor triggered signals (DOWN, CHANGE, etc)
- Link signals
- Unlink signals
- Group leader signals
All of the above already defined as asynchronous signals in the
language. The implementation of messages signals was quite
asynchronous to begin with, but had quite strict delivery constraints
due to the ordering guarantees of signals between a pair of processes.
The previously used message queue partitioned into two halves has been
replaced by a more general signal queue partitioned into three parts
that service all kinds of signals. More details regarding the signal
queue can be found in comments in the erl_proc_sig_queue.h file.
The monitor and link implementations have also been completely replaced
in order to fit the new asynchronous signaling implementation as good
as possible. More details regarding the new monitor and link
implementations can be found in the erl_monitor_link.h file.
|
|
|
|
|
|
|
|
Currently HiPE amd64 assumes the runtime system code is loaded into
the low 2G of the address space. However, this is not the case when
PIE is enabled, it is loaded into a random location. So trampolines
are required to call BIFs, and also we have first to load the address
of sse2_fnegate_mask to a regisiter before xorpd in fchs.
|
|
|
|
Consider the following function:
function({function,Name,Arity,CLabel,Is0}, Lc0) ->
try
%% Optimize the code for the function.
catch
Class:Error:Stack ->
io:format("Function: ~w/~w\n", [Name,Arity]),
erlang:raise(Class, Error, Stack)
end.
The stacktrace is retrieved, but it is only used in the call
to erlang:raise/3. There is no need to build a stacktrace
in this function. We can avoid the building if we introduce
an instruction called raw_raise/3 that works exactly like
the erlang:raise/3 BIF except that its third argument must
be a raw stacktrace.
|
|
Replace double pointer with return that can mostly be ignored.
Use restrict pointers.
|
|
particularly slow erlc when compiler is hipe compiled.
hipe_unified_loader:load did not patch external call sites
and instead caused a double hipe mode switch per call.
hipe_unified_loader:load is only used
for early modules first loaded as beam
and by code:atomic_load and friends.
|
|
|
|
in order to detect incompatible changes in primop interface
(which we just did for bs_put_utf8) and refuse hipe loading.
|
|
by preventing it from doing GC, which generated code relies on.
|
|
|
|
Add syntax in try/catch to retrieve the stacktrace directly
|
|
* maint:
fix output formatting in several HiPE debug BIFs
|
|
This commit adds a new syntax for retrieving the stacktrace
without calling erlang:get_stacktrace/0. That allow us to
deprecate erlang:get_stacktrace/0 and ultimately remove it.
The problem with erlang:get_stacktrace/0 is that it can keep huge
terms in a process for an indefinite time after an exception. The
stacktrace can be huge after a 'function_clause' exception or a failed
call to a BIF or operator, because the arguments for the call will be
included in the stacktrace. For example:
1> catch abs(lists:seq(1, 1000)).
{'EXIT',{badarg,[{erlang,abs,
[[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20|...]],
[]},
{erl_eval,do_apply,6,[{file,"erl_eval.erl"},{line,674}]},
{erl_eval,expr,5,[{file,"erl_eval.erl"},{line,431}]},
{shell,exprs,7,[{file,"shell.erl"},{line,687}]},
{shell,eval_exprs,7,[{file,"shell.erl"},{line,642}]},
{shell,eval_loop,3,[{file,"shell.erl"},{line,627}]}]}}
2> erlang:get_stacktrace().
[{erlang,abs,
[[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,
23,24|...]],
[]},
{erl_eval,do_apply,6,[{file,"erl_eval.erl"},{line,674}]},
{erl_eval,expr,5,[{file,"erl_eval.erl"},{line,431}]},
{shell,exprs,7,[{file,"shell.erl"},{line,687}]},
{shell,eval_exprs,7,[{file,"shell.erl"},{line,642}]},
{shell,eval_loop,3,[{file,"shell.erl"},{line,627}]}]
3>
We can extend the syntax for clauses in try/catch to optionally bind
the stacktrace to a variable.
Here is an example using the current syntax:
try
Expr
catch C:E ->
Stk = erlang:get_stacktrace(),
.
.
.
In the new syntax, it would look like:
try
Expr
catch
C:E:Stk ->
.
.
.
Only a variable (not a pattern) is allowed in the stacktrace position,
to discourage matching of the stacktrace. (Matching would also be
expensive, because the raw format of the stacktrace would have to be
converted to the cooked form before matching.)
Note that:
try
Expr
catch E ->
.
.
.
is a shorthand for:
try
Expr
catch throw:E ->
.
.
.
If the stacktrace is to be retrieved for a throw, the 'throw:'
prefix must be explicitly included:
try
Expr
catch throw:E:Stk ->
.
.
.
|
|
|
|
HiPE: Support for literal tag, tests and bugfixes
|
|
Fix formatting in hipe_bifs:show_pcb/1, hipe_bifs:show_estack/1,
and hipe_bifs:show_nstack/1.
fflush(stdout) before switching from printf() to erts_printf() to
avoid garbled output.
Adjust field lengths to work on both 64- and 32-bit systems.
Tested on Linux/x86_64 (64-bit) and Linux/ARMv7 (32-bit).
|
|
* sverker/cleanup-hipe_bs_validate_unicode:
erts: Remove obsolete hipe primop bs_validate_unicode
|
|
|
|
which was replaced by 'is_unicode' in 5369e34a892bfd8ab5aa98df330e3bbf19497b71
but kept for ABI compatibility in OTP-20.*.
|
|
Literal tags are used by the VM as an alternative to reserving a large
virtual memory space in order to be able to quickly identify which terms
are literals. The use of literal tags harms performance, but is useful
to support systems where allocating a large amount of virtual memory is
not an option.
|
|
Since gcunsafe values are live over is_divisible calls (although only
the happy path, which never GCd), it should be a primop so there cannot
be any GCs.
|
|
When the code switches from printf() to erts_printf() the output
becomes garbled. Fixed by fflush()ing stdout first.
Fixed formatting of the "H E A P" banner for 64-bit systems.
|
|
|
|
by introducing new primop 'is_unicode'
with no exception (ab)use and no GC.
Replaces bs_validate_unicode which is kept for backward compat for now.
|
|
Fix for x86_64 only.
The calling native code can not handle a GC
as it has a raw pointer where to write the binary data.
If a GC happens the data (utf32) will be written
to the old deallocated heap.
|
|
Introduce the IsOpCode() macro that can be used to compare
instructions.
|
|
The BeamOp() macro in erl_vm.h is clumsy to use. All users
cast the return value to BeamInstr.
Define new macros that are easier to use. In the future,
we might want to pack an operand into the same word as
the pointer to the instruction, so we will define two macros.
BeamIsOpCode() is used to rewrite code like this:
if (Instr == (BeamInstr) BeamOp(op_i_func_info_IaaI) {
...
}
to:
if (BeamIsOpCode(Instr, op_i_func_info_IaaI)) {
...
}
BeamOpCodeAddr(op_apply_bif) is used when we need the address
for an instruction.
Also elimiminate the global variables em_* in beam_emu.c.
They are not really needed. Use the BeamOpCodeAddr() macro
instead.
|
|
Instructions that used to be implemented in beam_emu.c
were not marked as cold as it would make no difference.
|
|
|
|
|
|
|
|
|
|
This refactor was done using the unifdef tool like this:
for file in $(find erts/ -name *.[ch]); do unifdef -t -f defile -o $file $file; done
where defile contained:
#define ERTS_SMP 1
#define USE_THREADS 1
#define DDLL_SMP 1
#define ERTS_HAVE_SMP_EMU 1
#define SMP 1
#define ERL_BITS_REENTRANT 1
#define ERTS_USE_ASYNC_READY_Q 1
#define FDBLOCK 1
#undef ERTS_POLL_NEED_ASYNC_INTERRUPT_SUPPORT
#define ERTS_POLL_ASYNC_INTERRUPT_SUPPORT 0
#define ERTS_POLL_USE_WAKEUP_PIPE 1
#define ERTS_POLL_USE_UPDATE_REQUESTS_QUEUE 1
#undef ERTS_HAVE_PLAIN_EMU
#undef ERTS_SIGNAL_STATE
|
|
The implementation is still hidden behind ERTS_ENABLE_LOCK_COUNT, and
all categories are still enabled by default, but the actual counting can be
toggled at will.
OTP-13170
|
|
|
|
to replace macro ERTS_INTERNAL_BINARY_FIELDS
as header in Binary and friends.
|
|
Only term_to_binary needed some extra attention
as it used to initialize refc as 0 instead of 1.
|
|
which serves no purpose after all the
hipe load&purge fixes merged at
32729cab75325de58bf127e6e8836348071b8682
|
|
instead of ugly negative indexing.
|
|
|
|
7814ec18b made hipe_bifs:alloc_data/3 expect alignments greater than 8
from erts_alloc(), which is not something that it guarantees. Fix it up
so that it pads the allocation up to the required alignment, in case it
does not initially satisfy the alignment requirement.
|
|
to long lived, short lived and native stack.
|
|
|