diff options
author | Björn Gustavsson <[email protected]> | 2019-03-05 05:44:48 +0100 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2019-03-06 15:42:43 +0100 |
commit | b96e5bd87c6aaaf96fa9c6e3679d95df74d1a499 (patch) | |
tree | ed075ffa80374c65fed94e1df802dfb07ae19e6b /erts/emulator/beam/beam_load.c | |
parent | db9a338a0480067a6f05551ce62c33f3aaf1a08a (diff) | |
download | otp-b96e5bd87c6aaaf96fa9c6e3679d95df74d1a499.tar.gz otp-b96e5bd87c6aaaf96fa9c6e3679d95df74d1a499.tar.bz2 otp-b96e5bd87c6aaaf96fa9c6e3679d95df74d1a499.zip |
Eliminate unused i_bs_skip_bits_all2 instruction
Starting in OTP 19 (in commit 9504c0dd71d0), the compiler emits
a test_unit instruction instead of a skip instruction at the end
of binary. We can do the same replacement in the loader to get
rid of the i_bs_skip_bits_all2 instruction.
Diffstat (limited to 'erts/emulator/beam/beam_load.c')
-rw-r--r-- | erts/emulator/beam/beam_load.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/erts/emulator/beam/beam_load.c b/erts/emulator/beam/beam_load.c index 5aaba78de4..e3232f1beb 100644 --- a/erts/emulator/beam/beam_load.c +++ b/erts/emulator/beam/beam_load.c @@ -3565,10 +3565,22 @@ gen_skip_bits2(LoaderState* stp, GenOpArg Fail, GenOpArg Ms, NATIVE_ENDIAN(Flags); NEW_GENOP(stp, op); if (Size.type == TAG_a && Size.val == am_all) { - op->op = genop_i_bs_skip_bits_all2_3; + /* + * This kind of skip instruction will only be found in modules + * compiled before OTP 19. From OTP 19, the compiler generates + * a test_unit instruction of a bs_skip at the end of a + * binary. + * + * It is safe to replace the skip instruction with a test_unit + * instruction, because the position will never be used again. + * If the match context itself is used again, it will be used by + * a bs_restore2 instruction which will overwrite the position + * by one of the stored positions. + */ + op->op = genop_bs_test_unit_3; op->arity = 3; op->a[0] = Fail; - op->a[1] = Ms; + op->a[1] = Ms; op->a[2] = Unit; } else if (Size.type == TAG_i) { op->op = genop_i_bs_skip_bits_imm2_3; |