Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:23
erlang
2975-erts-Make-etp-understand-literal-tag.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 2975-erts-Make-etp-understand-literal-tag.patch of Package erlang
From 1e978ad84187950db349c8eaab6bf46f11135982 Mon Sep 17 00:00:00 2001 From: Sverker Eriksson <sverker@erlang.org> Date: Wed, 17 Feb 2021 13:14:06 +0100 Subject: [PATCH 5/5] erts: Make etp understand literal tag --- erts/emulator/beam/erl_init.c | 5 ++ erts/etc/unix/etp-commands.in | 92 +++++++++++++++++------------------ 2 files changed, 51 insertions(+), 46 deletions(-) diff --git a/erts/emulator/beam/erl_init.c b/erts/emulator/beam/erl_init.c index 17f8d8dc02..c61094c95b 100644 --- a/erts/emulator/beam/erl_init.c +++ b/erts/emulator/beam/erl_init.c @@ -118,6 +118,11 @@ const Eterm etp_magic_ref_header = ERTS_MAGIC_REF_THING_HEADER; const Eterm etp_magic_ref_header = ERTS_REF_THING_HEADER; #endif const Eterm etp_the_non_value = THE_NON_VALUE; +#ifdef TAG_LITERAL_PTR +const Eterm etp_ptr_mask = (~(Eterm)7); +#else +const Eterm etp_ptr_mask = (~(Eterm)3); +#endif #ifdef ERTS_HOLE_MARKER const Eterm etp_hole_marker = ERTS_HOLE_MARKER; #else diff --git a/erts/etc/unix/etp-commands.in b/erts/etc/unix/etp-commands.in index 9784deedce..1648daefa6 100644 --- a/erts/etc/unix/etp-commands.in +++ b/erts/etc/unix/etp-commands.in @@ -133,14 +133,14 @@ define etp-1 if (($arg0) & 0x3) == 1 # Cons pointer if $etp_flat - printf "<etpf-cons %p>", (($arg0)-1) + printf "<etpf-cons %p>", (($arg0) & etp_ptr_mask) else etp-list-1 ($arg0) ($arg1) end else if (($arg0) & 0x3) == 2 if $etp_flat - printf "<etpf-boxed %p>", (($arg0)-2) + printf "<etpf-boxed %p>", (($arg0) etp_ptr_mask) else etp-boxed-1 ($arg0) ($arg1) end @@ -222,12 +222,12 @@ define etp-list-printable-1 $etp_list_printable if ($etp_list_p & 0x3) == 0x1 # Cons pointer - set $etp_list_n = ((Eterm*)($etp_list_p & ~0x3))[0] + set $etp_list_n = ((Eterm*)($etp_list_p & etp_ptr_mask))[0] if ($etp_list_n & 0xF) == 0xF etp-ct-printable-1 ($etp_list_n>>4) if $etp_ct_printable # Printable - set $etp_list_p = ((Eterm*)($etp_list_p & ~0x3))[1] + set $etp_list_p = ((Eterm*)($etp_list_p & etp_ptr_mask))[1] set $etp_list_i++ else set $etp_list_printable = 0 @@ -246,9 +246,9 @@ define etp-list-printable-1 set $etp_list_p = ($arg0) set $etp_list_i = 0 while $etp_list_p != $etp_nil - set $etp_list_n = ((Eterm*)($etp_list_p & ~0x3))[0] + set $etp_list_n = ((Eterm*)($etp_list_p & etp_ptr_mask))[0] etp-char-1 ($etp_list_n>>4) '"' - set $etp_list_p = ((Eterm*)($etp_list_p & ~0x3))[1] + set $etp_list_p = ((Eterm*)($etp_list_p & etp_ptr_mask))[1] set $etp_list_i++ if $etp_list_p == $etp_nil printf "\"" @@ -279,22 +279,22 @@ define etp-list-2 if ($arg1) >= $etp_max_depth printf "...]" else - etp-1 (((Eterm*)(($arg0)&~0x3))[0]) (($arg1)+1) - if ((Eterm*)(($arg0) & ~0x3))[1] == $etp_nil + etp-1 (((Eterm*)(($arg0)&etp_ptr_mask))[0]) (($arg1)+1) + if ((Eterm*)(($arg0) & etp_ptr_mask))[1] == $etp_nil # Tail is [] printf "]" else if $etp_chart etp-chart-entry-1 ($arg0) ($arg1) 2 end - if (((Eterm*)(($arg0)&~0x3))[1]&0x3) == 0x1 + if (((Eterm*)(($arg0)&etp_ptr_mask))[1]&0x3) == 0x1 # Tail is cons cell printf "," - etp-list-2 (((Eterm*)(($arg0)&~0x3))[1]) (($arg1)+1) + etp-list-2 (((Eterm*)(($arg0)&etp_ptr_mask))[1]) (($arg1)+1) else # Tail is other term printf "|" - etp-1 (((Eterm*)(($arg0)&~0x3))[1]) (($arg1)+1) + etp-1 (((Eterm*)(($arg0)&etp_ptr_mask))[1]) (($arg1)+1) printf "]" end end @@ -313,9 +313,9 @@ define etpf-cons # Cons pointer set $etp_flat = 1 printf "[" - etp-1 (((Eterm*)((Eterm)($arg0)&~0x3))[0]) + etp-1 (((Eterm*)((Eterm)($arg0)&etp_ptr_mask))[0]) printf "|" - etp-1 (((Eterm*)((Eterm)($arg0)&~0x3))[1]) + etp-1 (((Eterm*)((Eterm)($arg0)&etp_ptr_mask))[1]) printf "]\n" set $etp_flat = 0 end @@ -339,42 +339,42 @@ define etp-boxed-1 if (($arg0) & 0x3) != 0x2 printf "#NotBoxed<%p>", ($arg0) else - if (((Eterm*)(($arg0) & ~0x3))[0] & 0x3) != 0x0 + if (((Eterm*)(($arg0) & etp_ptr_mask))[0] & 0x3) != 0x0 if $etp_chart - etp-chart-entry-1 (($arg0)&~0x3) ($arg1) 1 + etp-chart-entry-1 (($arg0)&etp_ptr_mask) ($arg1) 1 end printf "#BoxedError<%p>", ($arg0) else if $etp_chart - etp-chart-entry-1 (($arg0)&~0x3) ($arg1) \ - ((((Eterm*)(($arg0)&~0x3))[0]>>6)+1) + etp-chart-entry-1 (($arg0)&etp_ptr_mask) ($arg1) \ + ((((Eterm*)(($arg0)&etp_ptr_mask))[0]>>6)+1) end - if (((Eterm*)(($arg0) & ~0x3))[0] & 0x3f) == 0x0 + if (((Eterm*)(($arg0) & etp_ptr_mask))[0] & 0x3f) == 0x0 printf "{" - etp-array-1 ((Eterm*)(($arg0)&~0x3)) ($arg1) ($arg1) \ - 1 ((((Eterm*)(($arg0)&~0x3))[0]>>6)+1) '}' + etp-array-1 ((Eterm*)(($arg0)&etp_ptr_mask)) ($arg1) ($arg1) \ + 1 ((((Eterm*)(($arg0)&etp_ptr_mask))[0]>>6)+1) '}' else - if (((Eterm*)(($arg0) & ~0x3))[0] & 0x3c) == 0x3c + if (((Eterm*)(($arg0) & etp_ptr_mask))[0] & 0x3c) == 0x3c # A map - if (((Eterm*)(($arg0) & ~0x3))[0] & 0xc0) == 0x0 + if (((Eterm*)(($arg0) & etp_ptr_mask))[0] & 0xc0) == 0x0 # Flat map printf "#{Keys:" - etp-1 ((flatmap_t*)(($arg0)&~0x3))->keys (($arg1)+1) + etp-1 ((flatmap_t*)(($arg0)&etp_ptr_mask))->keys (($arg1)+1) printf " Values:{" - etp-array-1 ((Eterm*)(($arg0)&~0x3)+3) ($arg1) ($arg1) \ - 0 ((flatmap_t*)(($arg0)&~0x3))->size '}' + etp-array-1 ((Eterm*)(($arg0)&etp_ptr_mask)+3) ($arg1) ($arg1) \ + 0 ((flatmap_t*)(($arg0)&etp_ptr_mask))->size '}' printf "}" else # Hashmap - printf "#<%x>{", (((((Eterm*)(($arg0)&~0x3))[0])>>(6+2+8))&0xffff) - if (((Eterm*)(($arg0) & ~0x3))[0] & 0xc0) >= 0x80 + printf "#<%x>{", (((((Eterm*)(($arg0)&etp_ptr_mask))[0])>>(6+2+8))&0xffff) + if (((Eterm*)(($arg0) & etp_ptr_mask))[0] & 0xc0) >= 0x80 # head bitmap/array - etp-bitmap-array-1 ((Eterm*)(($arg0)&~0x3)+2) ($arg1) ($arg1) \ - 0 (((((Eterm*)(($arg0)&~0x3))[0])>>(6+2+8))&0xffff) '}' + etp-bitmap-array-1 ((Eterm*)(($arg0)&etp_ptr_mask)+2) ($arg1) ($arg1) \ + 0 (((((Eterm*)(($arg0)&etp_ptr_mask))[0])>>(6+2+8))&0xffff) '}' else # node bitmap - etp-bitmap-array-1 ((Eterm*)(($arg0)&~0x3)+1) ($arg1) ($arg1) \ - 0 (((((Eterm*)(($arg0)&~0x3))[0])>>(6+2+8))&0xffff) '}' + etp-bitmap-array-1 ((Eterm*)(($arg0)&etp_ptr_mask)+1) ($arg1) ($arg1) \ + 0 (((((Eterm*)(($arg0)&etp_ptr_mask))[0])>>(6+2+8))&0xffff) '}' end end else @@ -393,10 +393,10 @@ define etp-boxed-immediate-1 if (($arg0) & 0x3) != 0x2 printf "#NotBoxed<%p>", ($arg0) else - if (((Eterm*)(($arg0) & ~0x3))[0] & 0x3) != 0x0 + if (((Eterm*)(($arg0) & etp_ptr_mask))[0] & 0x3) != 0x0 printf "#BoxedError<%p>", ($arg0) else - set $etp_boxed_immediate_p = (Eterm*)(($arg0) & ~0x3) + set $etp_boxed_immediate_p = (Eterm*)(($arg0) & etp_ptr_mask) set $etp_boxed_immediate_h = ($etp_boxed_immediate_p[0] >> 2) & 0xF if $etp_boxed_immediate_h == 0xC etp-extpid-1 ($arg0) @@ -543,7 +543,7 @@ end # printf "%% Max depth for term %d\n", $etp_chart_id # else # if ($arg2) < ($arg3) -# etp-1 (((Eterm*)(($arg0)&~0x3))[$arg2]) (($arg1)+1) +# etp-1 (((Eterm*)(($arg0)&etp_ptr_mask))[$arg2]) (($arg1)+1) # etpa-1 ($arg0) (($arg1)+1) (($arg2)+1) ($arg3) # end # end @@ -861,7 +861,7 @@ define etp-extpid-1 if ((Eterm)($arg0) & 0x3) != 0x2 printf "#NotBoxed<%p>", (Eterm)($arg0) else - set $etp_extpid_1_p = (ExternalThing*)((Eterm)($arg0) & ~0x3) + set $etp_extpid_1_p = (ExternalThing*)((Eterm)($arg0) & etp_ptr_mask) if ($etp_extpid_1_p->header & 0x3f) != 0x30 printf "#NotExternalPid<%p>", $etp_extpid_1_p->header else @@ -921,7 +921,7 @@ define etp-extport-1 if ((Eterm)($arg0) & 0x3) != 0x2 printf "#NotBoxed<%p>", (Eterm)($arg0) else - set $etp_extport_1_p = (ExternalThing*)((Eterm)($arg0) & ~0x3) + set $etp_extport_1_p = (ExternalThing*)((Eterm)($arg0) & etp_ptr_mask) if ($etp_extport_1_p->header & 0x3F) != 0x34 printf "#NotExternalPort<%p>", $etp_extport_1->header else @@ -957,7 +957,7 @@ define etp-bignum-1 if ((Eterm)($arg0) & 0x3) != 0x2 printf "#NotBoxed<%p>", (Eterm)($arg0) else - set $etp_bignum_1_p = (Eterm*)((Eterm)($arg0) & ~0x3) + set $etp_bignum_1_p = (Eterm*)((Eterm)($arg0) & etp_ptr_mask) if ($etp_bignum_1_p[0] & 0x3b) != 0x08 printf "#NotBignum<%p>", $etp_bignum_1_p[0] else @@ -996,7 +996,7 @@ define etp-float-1 if ((Eterm)($arg0) & 0x3) != 0x2 printf "#NotBoxed<%p>", (Eterm)($arg0) else - set $etp_float_1_p = (Eterm*)((Eterm)($arg0) & ~0x3) + set $etp_float_1_p = (Eterm*)((Eterm)($arg0) & etp_ptr_mask) if ($etp_float_1_p[0] & 0x3f) != 0x18 printf "#NotFloat<%p>", $etp_float_1_p[0] else @@ -1015,7 +1015,7 @@ define etp-ref-1 if ((Eterm)($arg0) & 0x3) != 0x2 printf "#NotBoxed<%p>", (Eterm)($arg0) else - set $etp_ref_1_p = (ErtsORefThing *)((Eterm)($arg0) & ~0x3) + set $etp_ref_1_p = (ErtsORefThing *)((Eterm)($arg0) & etp_ptr_mask) if ($etp_ref_1_p->header & 0x3b) != 0x10 printf "#NotRef<%p>", $etp_ref_1_p->header else @@ -1062,7 +1062,7 @@ define etp-extref-1 if ((Eterm)($arg0) & 0x3) != 0x2 printf "#NotBoxed<%p>", (Eterm)($arg0) else - set $etp_extref_1_p = (ExternalThing*)((Eterm)($arg0) & ~0x3) + set $etp_extref_1_p = (ExternalThing*)((Eterm)($arg0) & etp_ptr_mask) if ($etp_extref_1_p->header & 0x3F) != 0x38 printf "#NotExternalRef<%p>", $etp_extref_1->header else @@ -1864,7 +1864,7 @@ define etp-term-dump else if (($arg0) & 0x3) == 1 # Cons pointer - set $etp_term_dump_cons_p = ((Eterm*)(($arg0) & ~0x3)) + set $etp_term_dump_cons_p = ((Eterm*)(($arg0) & etp_ptr_mask)) if $etp_term_dump_cons_p > $etp_heapdump_heap && $etp_term_dump_cons_p < $etp_heapdump_end printf "| C:0x%08x ", $etp_term_dump_cons_p #printf "| C: --> %5d ", $etp_heapdump_p - $etp_term_dump_cons_p - 1 @@ -3503,9 +3503,9 @@ define etp-dictdump else set $etp_dictdump_written = 1 end - etp-1 (((Eterm*)((Eterm)$etp_dictdump_p&~0x3))[0]) 0 + etp-1 (((Eterm*)((Eterm)$etp_dictdump_p&etp_ptr_mask))[0]) 0 set $etp_dictdump_cnt-- - set $etp_dictdump_p = ((Eterm*)((Eterm)$etp_dictdump_p & ~0x3))[1] + set $etp_dictdump_p = ((Eterm*)((Eterm)$etp_dictdump_p & etp_ptr_mask))[1] end if $etp_dictdump_p != $etp_nil printf "#DictSlotError<%d>:", $etp_dictdump_i @@ -3617,7 +3617,7 @@ define etp-search-heaps etp-1 ($arg0) 0 set $etp_flat = 0 printf ":...\n" - etp-search-heaps-1 ((Eterm*)((Eterm)($arg0)&~(Eterm)3)) + etp-search-heaps-1 ((Eterm*)((Eterm)($arg0)&etp_ptr_mask)) end define etp-search-heaps-1 @@ -4113,11 +4113,11 @@ define etp-chart-entry-1 set $etp_chart_id++ printf "#%d:", $etp_chart_id end - append binary value etp-commands.bin ($arg0)&~0x3 + append binary value etp-commands.bin ($arg0)&etp_ptr_mask append binary value etp-commands.bin (Eterm)(($arg2)*sizeof(Eterm)) append binary value etp-commands.bin (Eterm)$etp_chart_id append binary value etp-commands.bin (Eterm)($arg1) -# printf "<dumped %p %lu %lu %lu>", ($arg0)&~0x3, \ +# printf "<dumped %p %lu %lu %lu>", ($arg0)&etp_ptr_mask, \ # (Eterm)(($arg2)*sizeof(Eterm)), (Eterm)$etp_chart_id, (Eterm)($arg1) end -- 2.26.2
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor