aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/src/Makefile
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2015-09-15 13:55:38 +0200
committerBjörn Gustavsson <[email protected]>2015-09-28 10:26:24 +0200
commit9504c0dd71d0b1b49251a97f45c71c8882ce7708 (patch)
tree0d977b4f78b982edc76d7e4b876f55bffdad3129 /lib/compiler/src/Makefile
parent9a1f7c4156093effddd555e88fd16a2ffd6ae75a (diff)
downloadotp-9504c0dd71d0b1b49251a97f45c71c8882ce7708.tar.gz
otp-9504c0dd71d0b1b49251a97f45c71c8882ce7708.tar.bz2
otp-9504c0dd71d0b1b49251a97f45c71c8882ce7708.zip
v3_codegen: Optimize matching of the final size-less binary segment
Consider the following function: f(Bin, Bool) -> case Bin of <<Val:16/binary,_/binary>> when Bool -> Val end. Simplified, the generated code looks like: bs_start_match2 Fail Live Bin => Bin bs_get_integer2 Fail Live Bin size=Sz unit=1 => Val bs_skip_bits2 Fail Bin size=all unit=8 is_eq_exact Fail Bool true The code generator will replace the bs_skip_bits2 instruction with a bs_test_unit instruction if it can be clearly seen that the context register will not be used again. In this case, it is not obvious without looking at the code at the Fail label. However, it turns out that bs_test_unit instruction is always safe beacuse of the way v3_kernel compiles pattern matching. It doesn't matter whether the match context will be used again. If it will be used again, the position in it will *not* be used. Instead, a bs_restore2 instruction will restore one of the saved instructions.
Diffstat (limited to 'lib/compiler/src/Makefile')
0 files changed, 0 insertions, 0 deletions