diff options
author | Björn Gustavsson <[email protected]> | 2013-02-19 15:00:23 +0100 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2013-05-31 14:52:14 +0200 |
commit | f4c7a59d96b110f79cc0fcc16286ece770a166a3 (patch) | |
tree | 15e21db104b2e60de18ee166ab47614a09b4b1ea /bootstrap | |
parent | 23a99bfc9cde454b91e75f9cb1801666581b7051 (diff) | |
download | otp-f4c7a59d96b110f79cc0fcc16286ece770a166a3.tar.gz otp-f4c7a59d96b110f79cc0fcc16286ece770a166a3.tar.bz2 otp-f4c7a59d96b110f79cc0fcc16286ece770a166a3.zip |
asn1_constructed_per: Optimize decoding of CHOICE
Optimize the decoding of CHOICE. Most important is to inline decoding
of the extension bit (if present) and decoding of the choice index
to give the BEAM compiler more opportunities for optimization.
We will also change the structure of the generated code. The current
code uses a flattened case for both the root and extension alternatives:
case Choice + NumRootChoices * Ext of
%% Root alternatives.
0 - ...;
:
LastRootAlternative -> ...;
%% Extension alternatives.
LastRootAlternative+1 -> ...;
:
%% Unknown extension.
_ -> ...;
end
We will instead generate nested cases:
case Ext of
0 ->
case Choice of
%% Root alternatives.
0 - ...;
:
LastRootAlternative -> ...
end;
1 ->
%% Extension alternatives.
<Decode the open type here>
case Choice of
0 -> ...;
:
LastExtensionAlternative -> ...;
%% Unknown extension.
_ -> ...;
end
end
Nested cases should be slightly faster. For decoding of the extensions,
it also makes it possible to hoist the decoding of the open type up
from each case to before the case switching on the extension index,
thus reducing the size of the generated code.
We will also do another change to the structure. Currently, the
big flat clase is wrapped in code that repackages the return values:
{Alt,{Value,RemainingEncodedData}} =
case Choice + NumRootChoices * Ext of
:
end,
{{Value,Alt},RemainingEncodedData}.
We still need to do the repackaging, but we can push it down to
the case arm for decoding each alternative. In many cases, that
will give the BEAM compiler the opportunity to avoid building the
temporary tuples.
Diffstat (limited to 'bootstrap')
0 files changed, 0 insertions, 0 deletions