diff options
author | Rickard Green <[email protected]> | 2017-01-23 17:10:18 +0100 |
---|---|---|
committer | Rickard Green <[email protected]> | 2017-02-06 19:54:48 +0100 |
commit | b079018e38272604ffacfece9b97924a9e39df5c (patch) | |
tree | 87c0c5332a1dd466ba426a6f1ba464ecdc396399 /erts/etc | |
parent | aefe39da715130f3d1df10084495d3b7ee48337e (diff) | |
download | otp-b079018e38272604ffacfece9b97924a9e39df5c.tar.gz otp-b079018e38272604ffacfece9b97924a9e39df5c.tar.bz2 otp-b079018e38272604ffacfece9b97924a9e39df5c.zip |
Implement magic references
Magic references are *intentionally* indistinguishable from ordinary
references for the Erlang software. Magic references do not change
the language, and are intended as a pure runtime internal optimization.
An ordinary reference is typically used as a key in some table. A
magic reference has a direct pointer to a reference counted magic
binary. This makes it possible to implement various things without
having to do lookups in a table, but instead access the data directly.
Besides very fast lookups this can also improve scalability by
removing a potentially contended table. A couple of examples of
planned future usage of magic references are ETS table identifiers,
and BIF timer identifiers.
Besides future optimizations using magic references it should also
be possible to replace the exposed magic binary cludge with magic
references. That is, magic binaries that are exposed as empty
binaries to the Erlang software.
Diffstat (limited to 'erts/etc')
-rw-r--r-- | erts/etc/unix/etp-commands.in | 53 |
1 files changed, 29 insertions, 24 deletions
diff --git a/erts/etc/unix/etp-commands.in b/erts/etc/unix/etp-commands.in index c7e2ac169d..2bf04a6518 100644 --- a/erts/etc/unix/etp-commands.in +++ b/erts/etc/unix/etp-commands.in @@ -775,7 +775,7 @@ define etp-pid-1 set $etp_pid_1 = (Eterm)($arg0) if ($etp_pid_1 & 0xF) == 0x3 if (etp_arch_bits == 64) - if (etp_big_endian) + if (etp_endianness > 0) set $etp_pid_data = (unsigned) ((((Uint64) $etp_pid_1) >> 35) & 0x0fffffff) else set $etp_pid_data = (unsigned) ((((Uint64) $etp_pid_1) >> 4) & 0x0fffffff) @@ -835,7 +835,7 @@ define etp-port-1 set $etp_port_1 = (Eterm)($arg0) if ($etp_port_1 & 0xF) == 0x7 if (etp_arch_bits == 64) - if (etp_big_endian) + if (etp_endianness > 0) set $etp_port_data = (unsigned) ((((Uint64) $etp_port_1) >> 36) & 0x0fffffff) else set $etp_port_data = (unsigned) ((((Uint64) $etp_port_1) >> 4) & 0x0fffffff) @@ -952,30 +952,31 @@ define etp-ref-1 if ((Eterm)($arg0) & 0x3) != 0x2 printf "#NotBoxed<%#x>", (Eterm)($arg0) else - set $etp_ref_1_p = (RefThing *)((Eterm)($arg0) & ~0x3) + set $etp_ref_1_p = (ErtsORefThing *)((Eterm)($arg0) & ~0x3) if ($etp_ref_1_p->header & 0x3b) != 0x10 printf "#NotRef<%#x>", $etp_ref_1_p->header else - set $etp_ref_1_nump = (Uint32 *) 0 - set $etp_ref_1_error = 0 - if ($etp_ref_1_p->header >> 6) == 0 - set $etp_ref_1_error = 1 + if $etp_ref_1_p->header != etp_ref_header && $etp_ref_1_p->header != etp_magic_ref_header + printf "#InternalRefError<%#x>", ($arg0) else - if $etp_arch64 - set $etp_ref_1_i = (int) $etp_ref_1_p->data.ui32[0] - if (($etp_ref_1_i + 1) > (2 * ($etp_ref_1_p->header >> 6))) - set $etp_ref_1_error = 1 - else - set $etp_ref_1_nump = &$etp_ref_1_p->data.ui32[1] + set $etp_magic_ref = 0 + set $etp_ref_1_i = 3 + set $etp_ref_1_error = 0 + set $etp_ref_1_nump = (Uint32 *) 0 + if etp_ref_header == etp_magic_ref_header + if $etp_ref_1_p->marker != 0xffffffff + set $etp_magic_ref = 1 end + else + if $etp_ref_1_p->header == etp_magic_ref_header + set $etp_magic_ref = 1 + end + end + if $etp_magic_ref == 0 + set $etp_ref_1_nump = $etp_ref_1_p->num else - set $etp_ref_1_i = (int) ($etp_ref_1_p->header >> 6) - set $etp_ref_1_nump = &$etp_ref_1_p->data.ui32[0] + set $etp_ref_1_nump = ((ErtsMRefThing *) $etp_ref_1_p)->mb->refn end - end - if $etp_ref_1_error - printf "#InternalRefError<%#x>", ($arg0) - else printf "#Ref<0" set $etp_ref_1_i-- while $etp_ref_1_i >= 0 @@ -1593,7 +1594,7 @@ define etp-term-dump-pid set $etp_pid_1 = (Eterm)($arg0) if ($etp_pid_1 & 0xF) == 0x3 if (etp_arch_bits == 64) - if (etp_big_endian) + if (etp_endianness > 0) set $etp_pid_data = (unsigned) ((((Uint64) $etp_pid_1) >> 36) & 0x0fffffff) else set $etp_pid_data = (unsigned) ((((Uint64) $etp_pid_1) >> 4) & 0x0fffffff) @@ -1638,7 +1639,7 @@ define etp-pid2pix-1 # Args: Eterm # if (etp_arch_bits == 64) - if (etp_big_endian) + if (etp_endianness > 0) set $etp_pix = (int) (((Uint64) $arg0) & 0x0fffffff) else set $etp_pix = (int) ((((Uint64) $arg0) >> 32) & 0x0fffffff) @@ -2271,7 +2272,7 @@ define etp-port-id2pix-1 # Args: Eterm # if (etp_arch_bits == 64) - if (etp_big_endian) + if (etp_endianness > 0) set $etp_pix = (int) (((Uint64) $arg0) & 0x0fffffff) elser set $etp_pix = (int) ((((Uint64) $arg0) >> 32) & 0x0fffffff) @@ -2906,10 +2907,14 @@ define etp-system-info printf "Compile date: %s\n", etp_compile_date printf "Arch: %s\n", etp_arch printf "Endianness: " - if (etp_big_endian) + if (etp_endianness > 0) printf "Big\n" else - printf "Little\n" + if (etp_endianness < 0) + printf "Little\n" + else + printf "Unknown\n" + end end printf "Word size: %d-bit\n", etp_arch_bits printf "HiPE support: " |