Age | Commit message (Collapse) | Author |
|
sys_pre_expand does not keep track of used or new variables (and have
not done since about the time Core Erlang was introduced).
|
|
Now that beam_asm computes the Index and Uniq values for funs, there
is no need to compute those values in the sys_pre_expand and v3_kernel
modules, thus eliminating the calls to the deprecated erlang:hash/2
function.
It would be tempting to stop generating the name for the fun in
sys_pre_expand so that we did not have to add the Info field to a tuple.
But:
* The debugger depends on the name being there. (Simple solution:
Let the debugger generate the name itself.)
* When a fun has been inlined into another function, the fun name in
'id' annotation will be used to notice the inlining and change the
final clause of the top-level case from generating a 'function_clause'
exception to a case_clause exception. (Possible workaround: Have the
inliner set an inlined attribute on functions that have been inlined, or
have the inliner rewrite 'function_clause' exceptions itself.)
|
|
The calculation of the NewIndex field in fun entries is broken: the
sys_pre_expand and v3_kernel modules keep separate index counters
starting at zero; thus there is no guarantee that each fun within a
module will have its own unique NewIndex.
We don't really need the NewIndex any more (see below), but since
we do need the NewUniq field, we should fix NewIndex for cleanliness
sake. The simplest way is to assign NewIndex as late as possible,
namely in beam_asm, and to set it to the same value as Index.
Historical Note: Why NewIndex Was Introduced
There was once an idea that the debugger should be able to interpret
only a single function in a module (for speed). To make sure that
interpreted funs could be called from BEAM code and vice versa,
the fun identification must be visible in the abstract code.
Therefore a NewIndex field was introduced in each fun in the abstract
code.
However, it turned out that interpreting single functions does not
play well with aggressive code optimization. For example, in this
code:
f() ->
X = 1,
fun() -> X+2 end.
the variable X will seem to be free in the fun, but an aggressive
optimizer will replace X with 1 in the fun; thus the fun will no
longer have any free variables. Therefore, the debugger will always
interpret entire modules.
|
|
Funs are identified by a triple, <Module,Uniq,Index>, where Module is
the module name, Uniq is a 27 bit hash value of some intermediate
representation of the code for the fun, and index is a small integer.
When a fun is loaded, the triple for the fun will be compared to
previously loaded funs. If all elements in the triple in the newly
loaded fun are the same, the newly loaded fun will replace the previous
fun. The idea is that if Uniq are the same, the code for the fun is also
the same.
The problem is that Uniq is only based on the intermediate representation
of the fun itself. If the fun calls local functions in the same module,
Uniq may remain the same even if the behavior of the fun has been changed.
See
http://erlang.org/pipermail/erlang-bugs/2007-June/000368.htlm
for an example.
As a long-term plan to fix this problem, the NewIndex and NewUniq
fields was added to each fun in the R8 release (where NewUniq is the
MD5 of the BEAM code for the module). Unfortunately, it turns
out that the compiler does not assign unique value to NewIndex (if it
isn't tested, it doesn't work), so we cannot use the
<Module,NewUniq,NewIndex> triple as identification.
It would be possible to use <Module,NewUniq,Index>, but that seems
ugly. Therefore, fix the problem by making Uniq more unique by
taking 27 bits from the MD5 for the BEAM code. That only requires
a change to the compiler.
Also update a test case for cover, which now fails because of the
stronger Uniq calculation. (The comment in test case about why the
Pid2 process survived is not correct.)
|
|
* bjorn/erts/beam-loader-fixes:
Print transformtions sorted on the name of the first instruction
Share code for call of predicate and transformation functions
Simplify transformations of gc_bif[123] instructions
Refactor 'too_old_compiler' handling
Introduce 'try_me_else_fail'
Combine 'store_var' with 'next_arg'
Merge 'next_instr' and 'is_op' into 'next_instr'
Merge 'new_instr' and 'store_op' into 'new_instr'
Combine a 'call' instruction with the following 'end' instruction
Remove some unnecessary type constraints in transformations
Get rid of redundant 'try_me_else' and 'fail' instructions
Add some more information in instruction comments
In transformations, don't store variables that are never used
Remove redundant 'next_arg' before 'next_instr'
Generalize and rename is_set_var_instr() to is_instr()
Remove too_old_compiler handling for very old instruction variants
Remove the special instructions for the hybrid heap emulator
Remove optimization of 'move R R'
|
|
* bjorn/some-configure-clean-ups:
erts/configure.in: Remove test for reversed setvbuf() arguments
erts/configure.in: Remove broken support for System V
erts/configure.in: Don't check for the presence of mach-o/dyld.h
erts/configure.in: Remove useless --disable-fixalloc option
|
|
|
|
|
|
Each gc_bif[123] instruction must have both a transformation in
ops.tab and special code in gen_guard_bif[123]().
Rewrite it to do most of the work in gen_guard_bif[123]().
|
|
In the handling of generic instructions, we used to always
test whether the instruction was 'too_old_compiler' and abort
loading with a special error message.
Refactor the code so that we only do test if we an error
has occurred. That will allow us to make the test more expensive
in the future, allowing us to customize error messages for certain
opcode without any cost in the successful case.
|
|
|
|
'store_var' is always followed by 'next_arg'.
|
|
'next_instr' is always followed by 'is_op'.
|
|
Since the 'new_instr' instruction always occurs before the
'store_op' instruction, we can merge the instructions into one.
Also, there is no need to include the arity of the BEAM
instruction as an operand, since the arity can be looked up
based on the opcode.
|
|
A 'call' instruction in the loader transformation language is
always followed by an 'end' instruction, so we can replace the
'call' instruction with a 'call_end' instruction.
|
|
We don't need type constraints that essentially are assertions;
the wrong type will be detected and loading aborted when no specific
instruction can be found.
|
|
If the left part of a transformation will always match, omit the
the 'try_me_else' and 'fail' instructions.
As part of this optimization, make it an error to have a
transformation that can never be reached because of a previous
transformation that will always match. (Remove one transformation
from ops.tab that was found to be unreachable.)
|
|
|
|
This optimization will save some space (in the loader tables) and
some loading time.
|
|
Fix the incorrect code that attempted to remove a single
'next_arg' instructions before 'next_instr'.
|
|
It is more useful to have a helper function that can test for
any instruction.
|
|
is_list/2 and other test instructions with a zero label was last
generated by the v1 BEAM compiler which was last supported in R6B.
Since BEAM modules produced by that compiler will be rejected with
a nice error message for other reasons (e.g. by the test for the
module_info/0,1 functions), retaining those transformations serves
no useful purpose.
|
|
The hybrid-heap emulator is broken since R12, so there is no
need to keep those instructions.
|
|
Ancient versions of BEAM compiler could generate move instruction with
the same source and destination registers, so the loader would optimize
away such instructions.
|
|
* hb/kernel/fix_disk_log/OTP-9508:
Fix two minor disk_log bugs
|
|
* anders/diameter/tls_over_tcp/OTP-9605:
Move init/end_per_suite into testcases
Skip tls testsuite if there's no openssl
Clarify that ssl must be started for TLS support
Add tls support at connection establishment
Add tls testsuite
Documentation updates
Close transport if tls is requested over sctp
Handle tls notification for tcp
Lift recursion in tcp message reception up the call chain
Add tls support to capabilities exchange
|
|
* anders/diameter/testsuite_robustness/OTP-9619:
Make testsuites more robust in case of init failure
|
|
* anders/diameter/eprotonosupport/OTP-9615:
gen_sctp:open/0-2 might return {error, eprotonosupport}
|
|
* anders/diameter/doc_dependencies/OTP-9612:
Simplify depend.sed for better compatibility
|
|
See ac2810603b7aaad24129fadf887d9e8deff31d2f.
|
|
Previously error:badarg was raise if there was no underlying support
for SCTP. Handle both new and old failure until OTP-9239 is merged.
|
|
In particular, move code out of init_per_suite since failure
causes end_per_suite to be skipped. Cleanup is simpler if both
init and cleanup happen as testcases.
|
|
* sa/callback-attr:
Add callback specs into 'application' module in kernel
Add callback specs to tftp module following internet documentation
Add callback specs to inets_service module following possibly deprecated comments
Add '-callback' attributes in stdlib's behaviours
Update primary bootstrap
Update the documentation with information on the callback attribute
Automatically generate 'behaviour_info' function from '-callback' attributes
Add '-callback' attribute to language syntax
OTP-9621
|
|
|
|
|
|
comments
|
|
Replace the behaviour_info(callbacks) export in stdlib's behaviours with
-callback' attributes for all the callbacks.
|
|
|
|
|
|
'behaviour_info(callbacks)' is a special function that is defined in a module
which describes a behaviour and returns a list of its callbacks.
This function is now automatically generated using the '-callback' specs. An
error is returned by lint if user defines both '-callback' attributes and the
behaviour_info/1 function. If no type info is needed for a callback use a
generic spec for it.
|
|
Behaviours may define specs for their callbacks using the familiar spec syntax,
replacing the '-spec' keyword with '-callback'. Simple lint checks are performed
to ensure that no callbacks are defined twice and all types referred are
declared.
These attributes can be then used by tools to provide documentation to the
behaviour or find discrepancies in the callback definitions in the callback
module.
|
|
|
|
Sed on Solaris doesn't remember matches after branching.
|
|
Also update app testsuite to allow for "undefined" calls
from diameter_tcp to ssl.
|
|
This is the method added in draft-ietf-dime-rfc3588bis, whereby
a TLS handshake immediately follows connection establishment and
CER/CEA is sent over the secured connection.
|
|
|
|
|
|
RFC 3588 requires that a Diameter server support TLS but in
practise this seems to mean TLS over SCTP since there are limitations
with running over SCTP: see RFC 6083 (DTLS over SCTP), which is a
response to RFC 3436 (TLS over SCTP). The current RFC 3588 draft
acknowledges this by equating the Inband-Security-Id value TLS
with TLS/TCP and DTLS/SCTP but underlying support for DTLS is
still thin on the ground.
|
|
If TLS has been configured on Inband-Security-Id then the transport
process receives a message from the peer_fsm process indicating
whether or not to upgrade to TLS.
The current draft of RFC 3588 deprecates (but retains for backwards
compatibility) the use of Inband-Security-Id for negotiating TLS,
adding the possibility of TLS having be negotiated before capabilities
exchange. This commit handles the deprecated case.
|
|
When an initial message is received and TLS is a possibility, must
wait for a message from the peer process before either commencing
a handshake or receiving more messages.
|