aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2018-01-19 09:53:54 +0100
committerBjörn Gustavsson <[email protected]>2018-01-19 09:53:54 +0100
commit065834abd6cff359fd246e3470dfad5b9c501d15 (patch)
treee24292cd098b1216497252ae45d192a310bc9bd8
parentdb58a0c04ca183de5e5436e0ae97e3f109a458fe (diff)
parentc2a9915a451a3c6ad618f55a2871a43403333b7f (diff)
downloadotp-065834abd6cff359fd246e3470dfad5b9c501d15.tar.gz
otp-065834abd6cff359fd246e3470dfad5b9c501d15.tar.bz2
otp-065834abd6cff359fd246e3470dfad5b9c501d15.zip
Merge branch 'bjorn/erts/optimize-utf8/OTP-14774'
* bjorn/erts/optimize-utf8/OTP-14774: Optimize matching of an 'utf8' segment in the binary syntax
-rw-r--r--erts/emulator/beam/bs_instrs.tab16
1 files changed, 15 insertions, 1 deletions
diff --git a/erts/emulator/beam/bs_instrs.tab b/erts/emulator/beam/bs_instrs.tab
index 9f03b19731..b11903a47b 100644
--- a/erts/emulator/beam/bs_instrs.tab
+++ b/erts/emulator/beam/bs_instrs.tab
@@ -919,9 +919,23 @@ i_bs_get_integer(Fail, Live, FlagsAndUnit, Ms, Sz, Dst) {
}
i_bs_get_utf8(Ctx, Fail, Dst) {
+ Eterm result;
ErlBinMatchBuffer* mb = ms_matchbuffer($Ctx);
- Eterm result = erts_bs_get_utf8(mb);
+ if (mb->size - mb->offset < 8) {
+ $FAIL($Fail);
+ }
+ if (BIT_OFFSET(mb->offset) != 0) {
+ result = erts_bs_get_utf8(mb);
+ } else {
+ byte b = mb->base[BYTE_OFFSET(mb->offset)];
+ if (b < 128) {
+ result = make_small(b);
+ mb->offset += 8;
+ } else {
+ result = erts_bs_get_utf8(mb);
+ }
+ }
if (is_non_value(result)) {
$FAIL($Fail);
}