diff options
author | Björn Gustavsson <[email protected]> | 2015-01-27 09:16:07 +0100 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2015-01-29 09:37:17 +0100 |
commit | 25603134a658a64d5b024fe1668d9db6f331b2e2 (patch) | |
tree | 351a0310742d6730b87c1285de20ad1b46664621 /lib/compiler/src/cerl.erl | |
parent | 440c54f6a6b78015e8c8e0c7d16ad3cbb3d22147 (diff) | |
download | otp-25603134a658a64d5b024fe1668d9db6f331b2e2.tar.gz otp-25603134a658a64d5b024fe1668d9db6f331b2e2.tar.bz2 otp-25603134a658a64d5b024fe1668d9db6f331b2e2.zip |
Move grouping of map constructions from v3_core to v3_kernel
When translating a function with map construction:
f(A) ->
B = b,
C = c,
#{A=>1,B=>2,C=>3}.
v3_core would break apart the map construction into three
parts because of the way the map instructions in BEAM work --
variable keys need to be in their own instruction.
In the example, constant propagation will turn two of the
keys to literal keys. But the initial breaking apart will
not be undone, so there will still be three map constructions:
'f'/1 =
fun (_cor0) ->
let <_cor3> = ~{::<_cor0,1>}~
in let <_cor4> = ~{::<'b',2>|_cor3}~
in ~{::<'c',3>|_cor4}~
It would be possible to complicate the sys_core_fold pass
to regroup map operations so that we would get:
'f'/1 =
fun (_cor0) ->
let <_cor3> = ~{::<_cor0,1>}~
in ~{::<'b',2>,::<'c',3>|_cor3}~
A simpler way that allows to simplify the translation is
to skip the grouping in v3_core and translate the function
to:
'f'/1 =
fun (_cor0) ->
~{::<_cor0,1>,::<'b',2>,::<'c',3>}~
We will then let v3_kernel do the grouping while translating
from Core Erlang to Kernel Erlang.
Diffstat (limited to 'lib/compiler/src/cerl.erl')
0 files changed, 0 insertions, 0 deletions