diff options
author | Sverker Eriksson <[email protected]> | 2017-04-19 15:12:30 +0200 |
---|---|---|
committer | Sverker Eriksson <[email protected]> | 2017-04-19 15:12:30 +0200 |
commit | 37c64a77ce26fd242d6640187bafb6e2ec78b63b (patch) | |
tree | 34f8376deb37a896d12d4a9faf1eb00ebc4930f3 /lib/tools/src | |
parent | b5b5a7f7469bd041959d4b48e4eeff49faa7f377 (diff) | |
parent | 9437d8d73b31dd25504c3d652f0ad77ccd1239a3 (diff) | |
download | otp-37c64a77ce26fd242d6640187bafb6e2ec78b63b.tar.gz otp-37c64a77ce26fd242d6640187bafb6e2ec78b63b.tar.bz2 otp-37c64a77ce26fd242d6640187bafb6e2ec78b63b.zip |
Merge branch 'sverker/remove-latin1-atom-encoding'
AGAIN
* sverker/remove-latin1-atom-encoding:
tools: Fix more assumptions in lcnt about external format
Diffstat (limited to 'lib/tools/src')
-rw-r--r-- | lib/tools/src/lcnt.erl | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/lib/tools/src/lcnt.erl b/lib/tools/src/lcnt.erl index 22db947e7a..864d62f6c5 100644 --- a/lib/tools/src/lcnt.erl +++ b/lib/tools/src/lcnt.erl @@ -698,19 +698,47 @@ stats2record([{{File,Line},{Tries,Colls,{S,Ns,N}}}|Stats]) -> nt = N} | stats2record(Stats)]; stats2record([]) -> []. + clean_id_creation(Id) when is_pid(Id) -> Bin = term_to_binary(Id), - <<H:3/binary, L:16, Node:L/binary, Ids:8/binary, _Creation/binary>> = Bin, - Bin2 = list_to_binary([H, bytes16(L), Node, Ids, 0]), + <<H:3/binary, Rest/binary>> = Bin, + <<131, PidTag, AtomTag>> = H, + LL = atomlen_bits(AtomTag), + CL = creation_bits(PidTag), + <<L:LL, Node:L/binary, Ids:8/binary, _Creation/binary>> = Rest, + Bin2 = list_to_binary([H, <<L:LL>>, Node, Ids, <<0:CL>>]), binary_to_term(Bin2); clean_id_creation(Id) when is_port(Id) -> Bin = term_to_binary(Id), - <<H:3/binary, L:16, Node:L/binary, Ids:4/binary, _Creation/binary>> = Bin, - Bin2 = list_to_binary([H, bytes16(L), Node, Ids, 0]), + <<H:3/binary, Rest/binary>> = Bin, + <<131, PortTag, AtomTag>> = H, + LL = atomlen_bits(AtomTag), + CL = creation_bits(PortTag), + <<L:LL, Node:L/binary, Ids:4/binary, _Creation/binary>> = Rest, + Bin2 = list_to_binary([H, <<L:LL>>, Node, Ids, <<0:CL>>]), binary_to_term(Bin2); clean_id_creation(Id) -> Id. +-define(PID_EXT, $g). +-define(NEW_PID_EXT, $X). +-define(PORT_EXT, $f). +-define(NEW_PORT_EXT, $Y). +-define(ATOM_EXT, $d). +-define(SMALL_ATOM_EXT, $s). +-define(ATOM_UTF8_EXT, $v). +-define(SMALL_ATOM_UTF8_EXT, $w). + +atomlen_bits(?ATOM_EXT) -> 16; +atomlen_bits(?SMALL_ATOM_EXT) -> 8; +atomlen_bits(?ATOM_UTF8_EXT) -> 16; +atomlen_bits(?SMALL_ATOM_UTF8_EXT) -> 8. + +creation_bits(?PID_EXT) -> 8; +creation_bits(?NEW_PID_EXT) -> 32; +creation_bits(?PORT_EXT) -> 8; +creation_bits(?NEW_PORT_EXT) -> 32. + %% serializer state_default(Field) -> proplists:get_value(Field, state2list(#state{})). @@ -932,9 +960,6 @@ strings([{space, N, S} | Ss], Out) -> strings(Ss, Out ++ term2string(term2 strings([{left, N, S} | Ss], Out) -> strings(Ss, Out ++ term2string(term2string(" ~~s~~~ws", [N]), [S,""])); strings([S|Ss], Out) -> strings(Ss, Out ++ term2string("~ts", [S])). --define(SMALL_ATOM_UTF8_EXT, $w). --define(ATOM_UTF8_EXT, $v). --define(ATOM_EXT, $d). term2string({M,F,A}) when is_atom(M), is_atom(F), is_integer(A) -> term2string("~p:~p/~p", [M,F,A]); term2string(Term) when is_port(Term) -> |